From 40d1bc00fea04b73040e3998d44b9aa054f27597 Mon Sep 17 00:00:00 2001 From: Averane <57575687+Averane1@users.noreply.github.com> Date: Sat, 5 Feb 2022 20:52:39 -0400 Subject: [PATCH 001/257] EnDemoheishi OK and documented (#584) * EnDemoheishi decomp first pass * object decomp * whitespace between declarations and statements added * various PR fixes * format for CI * various PR fixes 2 + format * missed one texture output name * fix texture docs in unrelated files * fix demoheishi shared texture naming * made object sdn properties generic for soldiers * missed outName modifications * fixed references to updated function names * reverting some texture changes to unrelated objects & use object specific names for lips and fingers textures * added textId comment * various PR comments addressed * added enum for animations * reverting halt animation naming * moved animation enum to actor class * fixed enum names * fix typo * more PR fixes * format * fix for broken build after other PR merge * format * merge fixes * isTalking * Enum - Calf to shin Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Object - Calf to shin Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * DList - Calf to Shin Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --- assets/xml/objects/object_sdn.xml | 124 ++++++------- spec | 3 +- .../ovl_En_Demo_heishi/z_en_demo_heishi.c | 170 +++++++++++++++--- .../ovl_En_Demo_heishi/z_en_demo_heishi.h | 44 ++++- .../ovl_En_Ending_Hero4/z_en_ending_hero4.c | 2 +- .../ovl_En_Ending_Hero6/z_en_ending_hero6.c | 4 +- tools/disasm/functions.txt | 14 +- tools/disasm/variables.txt | 8 +- 8 files changed, 265 insertions(+), 104 deletions(-) diff --git a/assets/xml/objects/object_sdn.xml b/assets/xml/objects/object_sdn.xml index 9cc607047..691a272ee 100644 --- a/assets/xml/objects/object_sdn.xml +++ b/assets/xml/objects/object_sdn.xml @@ -1,66 +1,66 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index de8b9a950..56f6db7da 100644 --- a/spec +++ b/spec @@ -4956,8 +4956,7 @@ beginseg name "ovl_En_Demo_heishi" compress include "build/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.o" - include "build/data/ovl_En_Demo_heishi/ovl_En_Demo_heishi.data.o" - include "build/data/ovl_En_Demo_heishi/ovl_En_Demo_heishi.reloc.o" + include "build/src/overlays/actors/ovl_En_Demo_heishi/ovl_En_Demo_heishi_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c index b7e160990..d38727322 100644 --- a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c +++ b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c @@ -5,6 +5,7 @@ */ #include "z_en_demo_heishi.h" +#include "objects/object_sdn/object_sdn.h" #define FLAGS 0x00000009 @@ -15,10 +16,22 @@ void EnDemoheishi_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDemoheishi_Update(Actor* thisx, GlobalContext* globalCtx); void EnDemoheishi_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BE975C(EnDemoheishi* this, GlobalContext* globalCtx); -void func_80BE980C(EnDemoheishi* this, GlobalContext* globalCtx); +void EnDemoheishi_ChangeAnimation(EnDemoheishi* this, s32 animIndex); +void EnDemoheishi_SetupIdle(EnDemoheishi* this); +void EnDemoheishi_Idle(EnDemoheishi* this, GlobalContext* globalCtx); +void EnDemoheishi_SetupTalk(EnDemoheishi* this); +void EnDemoheishi_Talk(EnDemoheishi* this, GlobalContext* globalCtx); +s32 EnDemoheishi_OverrideLimbDraw(GlobalContext* globalctx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx); + +typedef enum { + /* 0 */ DEMOHEISHI_ANIMATION_STAND_HAND_ON_HIP, + /* 1 */ DEMOHEISHI_ANIMATION_CHEER_WITH_SPEAR, + /* 2 */ DEMOHEISHI_ANIMATION_WAVE, + /* 3 */ DEMOHEISHI_ANIMATION_SIT_AND_REACH, + /* 4 */ DEMOHEISHI_ANIMATION_STAND_UP +} EnDemoheishiAnimationIndex; -#if 0 const ActorInit En_Demo_heishi_InitVars = { ACTOR_EN_DEMO_HEISHI, ACTORCAT_NPC, @@ -31,37 +44,152 @@ const ActorInit En_Demo_heishi_InitVars = { (ActorFunc)EnDemoheishi_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BE9A50 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 40, 40, 0, { 0, 0, 0 } }, }; -#endif +static u16 sTextIds[] = { 0x1473 }; // Shiro initial intro text -extern ColliderCylinderInit D_80BE9A50; +void EnDemoheishi_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDemoheishi* this = THIS; -extern UNK_TYPE D_06003BFC; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSoldierSkeleton, &gSoldierWave, this->jointTable, + this->morphTable, 17); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 6; + this->actor.gravity = -3.0f; + Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + EnDemoheishi_SetupIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/EnDemoheishi_Init.s") +void EnDemoheishi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDemoheishi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/EnDemoheishi_Destroy.s") + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE95EC.s") +void EnDemoheishi_ChangeAnimation(EnDemoheishi* this, s32 animIndex) { + static AnimationHeader* sAnimations[] = { + &gSoldierStandHandOnHip, &gSoldierCheerWithSpear, &gSoldierWave, &gSoldierSitAndReach, &gSoldierStandUp, + }; + static u8 sAnimModes[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE9678.s") + this->animIndex = animIndex; + this->frameCount = Animation_GetLastFrame(sAnimations[animIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->frameCount, + sAnimModes[this->animIndex], -10.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE970C.s") +void EnDemoheishi_SetHeadRotation(EnDemoheishi* this) { + s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + s32 absYawDiff = ABS_ALT(yawDiff); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE975C.s") + this->headRotXTarget = 0; + if ((this->actor.xzDistToPlayer < 200.0f) && (absYawDiff < 0x4E20)) { + this->headRotXTarget = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + if (this->headRotXTarget > 0x2710) { + this->headRotXTarget = 0x2710; + } else if (this->headRotXTarget < -0x2710) { + this->headRotXTarget = -0x2710; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE97F0.s") +void EnDemoheishi_SetupIdle(EnDemoheishi* this) { + EnDemoheishi_ChangeAnimation(this, DEMOHEISHI_ANIMATION_STAND_HAND_ON_HIP); + this->textIdIndex = 0; + this->actor.textId = sTextIds[this->textIdIndex]; + this->isTalking = false; + this->actionFunc = EnDemoheishi_Idle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE980C.s") +void EnDemoheishi_Idle(EnDemoheishi* this, GlobalContext* globalCtx) { + s32 absYawDiff; + s16 yawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/EnDemoheishi_Update.s") + this->actor.flags &= ~ACTOR_FLAG_8000000; + yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + absYawDiff = ABS_ALT(yawDiff); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE9974.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + EnDemoheishi_SetupTalk(this); + } else if (absYawDiff <= 0x4BB8) { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/EnDemoheishi_Draw.s") +void EnDemoheishi_SetupTalk(EnDemoheishi* this) { + this->isTalking = true; + this->actionFunc = EnDemoheishi_Talk; +} + +void EnDemoheishi_Talk(EnDemoheishi* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + EnDemoheishi_SetupIdle(this); + } +} + +void EnDemoheishi_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDemoheishi* this = THIS; + + SkelAnime_Update(&this->skelAnime); + if (this->timer != 0) { + this->timer--; + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_SetScale(&this->actor, 0.01f); + EnDemoheishi_SetHeadRotation(this); + + Actor_SetFocus(&this->actor, 60.0f); + Math_SmoothStepToS(&this->headRotX, this->headRotXTarget, 1, 0xBB8, 0); + Math_SmoothStepToS(&this->headRotY, this->headRotYTarget, 1, 0x3E8, 0); + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); +} + +s32 EnDemoheishi_OverrideLimbDraw(GlobalContext* globalctx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnDemoheishi* this = THIS; + + if (limbIndex == DEMOHEISHI_LIMB_HEAD) { + rot->x += this->headRotX; + rot->y += this->headRotY; + rot->z += this->headRotZ; + } + + return false; +} + +void EnDemoheishi_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDemoheishi* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnDemoheishi_OverrideLimbDraw, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.h b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.h index 8dcdc899d..e6a2f9a91 100644 --- a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.h +++ b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.h @@ -7,12 +7,46 @@ struct EnDemoheishi; typedef void (*EnDemoheishiActionFunc)(struct EnDemoheishi*, GlobalContext*); +typedef enum { + /* 0 */ DEMOHEISHI_LIMB_NONE, + /* 1 */ DEMOHEISHI_LIMB_ROOT, + /* 2 */ DEMOHEISHI_LIMB_PELVIS, + /* 3 */ DEMOHEISHI_LIMB_LEFT_THIGH, + /* 4 */ DEMOHEISHI_LIMB_LEFT_SHIN, + /* 5 */ DEMOHEISHI_LIMB_LEFT_FOOT, + /* 6 */ DEMOHEISHI_LIMB_RIGHT_THIGH, + /* 7 */ DEMOHEISHI_LIMB_RIGHT_SHIN, + /* 8 */ DEMOHEISHI_LIMB_RIGHT_FOOT, + /* 9 */ DEMOHEISHI_LIMB_TORSO, + /* 10 */ DEMOHEISHI_LIMB_LEFT_SHOULDER, + /* 11 */ DEMOHEISHI_LIMB_LEFT_FOREARM, + /* 12 */ DEMOHEISHI_LIMB_LEFT_HAND, + /* 13 */ DEMOHEISHI_LIMB_RIGHT_SHOULDER, + /* 14 */ DEMOHEISHI_LIMB_RIGHT_FOREARM, + /* 15 */ DEMOHEISHI_LIMB_RIGHT_HAND_WITH_SPEAR, + /* 16 */ DEMOHEISHI_LIMB_HEAD, + /* 17 */ DEMOHEISHI_LIMB_MAX +} EnDemoheishiLimbs; + typedef struct EnDemoheishi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x110]; - /* 0x0254 */ EnDemoheishiActionFunc actionFunc; - /* 0x0258 */ char unk_258[0x68]; -} EnDemoheishi; // size = 0x2C0 + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[DEMOHEISHI_LIMB_MAX]; + /* 0x1EE */ Vec3s morphTable[DEMOHEISHI_LIMB_MAX]; + /* 0x254 */ EnDemoheishiActionFunc actionFunc; + /* 0x258 */ s16 headRotY; + /* 0x25A */ s16 headRotX; + /* 0x25C */ s16 headRotZ; + /* 0x25E */ s16 headRotYTarget; + /* 0x260 */ s16 headRotXTarget; + /* 0x262 */ s16 headRotZTarget; + /* 0x264 */ s32 animIndex; + /* 0x268 */ s16 timer; + /* 0x26C */ f32 frameCount; + /* 0x270 */ s16 isTalking; + /* 0x272 */ s16 textIdIndex; + /* 0x274 */ ColliderCylinder colliderCylinder; +} EnDemoheishi; //size = 0x2C0 extern const ActorInit En_Demo_heishi_InitVars; diff --git a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c index 59e1fd836..82070a2fa 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c +++ b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c @@ -38,7 +38,7 @@ void EnEndingHero4_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_sdn_Skel_00D640, &object_sdn_Anim_002A84, this->jointTable, + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSoldierSkeleton, &gSoldierCheerWithSpear, this->jointTable, this->morphTable, 17); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); func_80C23748(this); diff --git a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c index 1b296098f..b2c592494 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c +++ b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c @@ -38,13 +38,13 @@ const ActorInit En_Ending_Hero6_InitVars = { static FlexSkeletonHeader* sSkeletons[] = { &object_dt_Skel_00B0CC, &object_bai_Skel_007908, &object_toryo_Skel_007150, - &object_sdn_Skel_00D640, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, + &gSoldierSkeleton, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, }; static AnimationHeader* sAnimations[] = { &object_dt_Anim_000BE0, &object_bai_Anim_0011C0, &object_toryo_Anim_000E50, - &object_sdn_Anim_002A84, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, + &gSoldierCheerWithSpear, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, }; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 96bb6a06c..87e56de8a 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16170,14 +16170,14 @@ 0x80BE93D8:("EnHeishi_Draw",), 0x80BE9510:("EnDemoheishi_Init",), 0x80BE95C0:("EnDemoheishi_Destroy",), - 0x80BE95EC:("func_80BE95EC",), - 0x80BE9678:("func_80BE9678",), - 0x80BE970C:("func_80BE970C",), - 0x80BE975C:("func_80BE975C",), - 0x80BE97F0:("func_80BE97F0",), - 0x80BE980C:("func_80BE980C",), + 0x80BE95EC:("EnDemoheishi_ChangeAnimation",), + 0x80BE9678:("EnDemoheishi_SetHeadRotation",), + 0x80BE970C:("EnDemoheishi_SetupIdle",), + 0x80BE975C:("EnDemoheishi_Idle",), + 0x80BE97F0:("EnDemoheishi_SetupTalk",), + 0x80BE980C:("EnDemoheishi_Talk",), 0x80BE9864:("EnDemoheishi_Update",), - 0x80BE9974:("func_80BE9974",), + 0x80BE9974:("EnDemoheishi_OverrideLimbDraw",), 0x80BE99CC:("EnDemoheishi_Draw",), 0x80BE9B20:("EnDt_Init",), 0x80BE9C48:("EnDt_Destroy",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index ec70cbd0f..b303f8553 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -16195,10 +16195,10 @@ 0x80BE947C:("D_80BE947C","UNK_TYPE1","",0x1), 0x80BE9490:("D_80BE9490","UNK_TYPE1","",0x1), 0x80BE9A30:("En_Demo_heishi_InitVars","UNK_TYPE1","",0x1), - 0x80BE9A50:("D_80BE9A50","UNK_TYPE1","",0x1), - 0x80BE9A7C:("D_80BE9A7C","UNK_TYPE1","",0x1), - 0x80BE9A80:("D_80BE9A80","UNK_TYPE1","",0x1), - 0x80BE9A94:("D_80BE9A94","UNK_TYPE1","",0x1), + 0x80BE9A50:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80BE9A7C:("sTextIds","UNK_TYPE1","",0x1), + 0x80BE9A80:("sAnimations","UNK_TYPE1","",0x1), + 0x80BE9A94:("sAnimModes","UNK_TYPE1","",0x1), 0x80BEB1B0:("En_Dt_InitVars","UNK_TYPE1","",0x1), 0x80BEB1D0:("D_80BEB1D0","UNK_TYPE1","",0x1), 0x80BEB208:("D_80BEB208","UNK_TYPE1","",0x1), From 0f7f5de084d8b176de923ed8de0bcb63228dbf1d Mon Sep 17 00:00:00 2001 From: Parker Burnett Date: Sun, 13 Feb 2022 12:02:31 -0500 Subject: [PATCH 002/257] En_am OK (#501) * en_am ok * clean up * applying feedback and some docs, need finish still * this should fix things * fixing things * fixing things and running format * post actor_fixer * adding object header and fixing comments * formatting and adding enum for limbs * addressing pr, naming things, cleanup * fixing enum in header * doing some docs and fixing format --- assets/xml/objects/object_am.xml | 34 +- spec | 3 +- src/overlays/actors/ovl_En_Am/z_en_am.c | 512 +++++++++++++++++++++--- src/overlays/actors/ovl_En_Am/z_en_am.h | 17 +- tools/disasm/functions.txt | 14 +- undefined_syms.txt | 7 - 6 files changed, 497 insertions(+), 90 deletions(-) diff --git a/assets/xml/objects/object_am.xml b/assets/xml/objects/object_am.xml index c135b7b0b..b0737cb50 100644 --- a/assets/xml/objects/object_am.xml +++ b/assets/xml/objects/object_am.xml @@ -1,8 +1,8 @@  - - + + @@ -21,21 +21,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/spec b/spec index 56f6db7da..d9f933e8e 100644 --- a/spec +++ b/spec @@ -1004,8 +1004,7 @@ beginseg name "ovl_En_Am" compress include "build/src/overlays/actors/ovl_En_Am/z_en_am.o" - include "build/data/ovl_En_Am/ovl_En_Am.data.o" - include "build/data/ovl_En_Am/ovl_En_Am.reloc.o" + include "build/src/overlays/actors/ovl_En_Am/ovl_En_Am_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.c b/src/overlays/actors/ovl_En_Am/z_en_am.c index 355d37e59..083bcfa41 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -5,8 +5,10 @@ */ #include "z_en_am.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "overlays/actors/ovl_En_Bombf/z_en_bombf.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_400 | ACTOR_FLAG_4 | ACTOR_FLAG_1) #define THIS ((EnAm*)thisx) @@ -15,18 +17,26 @@ void EnAm_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnAm_Update(Actor* thisx, GlobalContext* globalCtx); void EnAm_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808B0040(EnAm* this, GlobalContext* globalCtx); -void func_808B0124(EnAm* this, GlobalContext* globalCtx); +void func_808AFF9C(EnAm* this); +void EnAm_RemoveEnemyTexture(EnAm* this, GlobalContext* globalCtx); +void EnAm_WakeUp(EnAm* this); +void EnAm_ApplyEnemyTexture(EnAm* this, GlobalContext* globalCtx); +void func_808B0358(EnAm* this); void func_808B03C0(EnAm* this, GlobalContext* globalCtx); +void func_808B0460(EnAm* this); void func_808B04A8(EnAm* this, GlobalContext* globalCtx); void func_808B0508(EnAm* this, GlobalContext* globalCtx); +void func_808B057C(EnAm* this); void func_808B05C8(EnAm* this, GlobalContext* globalCtx); +void func_808B0640(EnAm* this); void func_808B066C(EnAm* this, GlobalContext* globalCtx); +void EnAm_TakeDamage(EnAm* this, GlobalContext* globalCtx); void func_808B07A8(EnAm* this, GlobalContext* globalCtx); +void func_808B0820(EnAm* this); void func_808B0894(EnAm* this, GlobalContext* globalCtx); void func_808B0B4C(EnAm* this, GlobalContext* globalCtx); +void EnAm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* actor); -#if 0 const ActorInit En_Am_InitVars = { ACTOR_EN_AM, ACTORCAT_ENEMY, @@ -39,22 +49,47 @@ const ActorInit En_Am_InitVars = { (ActorFunc)EnAm_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808B1070 = { - { COLTYPE_HIT5, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0x81C2C788, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sEnemyCylinderInit = { + { + COLTYPE_HIT5, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0x81C2C788, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 23, 98, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808B109C = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x760D3877, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x760D3877, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 23, 98, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_808B10C8 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0xF), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0xF), @@ -89,81 +124,448 @@ static DamageTable D_808B10C8 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808B10E8 = { 1, 23, 98, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 23, 98, MASS_HEAVY }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808B10F0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 14, ICHAIN_CONTINUE), ICHAIN_S8(hintId, 19, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -4000, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -#endif +static Vec3f sVelocity = { 0.0f, -1.5f, 0.0f }; -extern ColliderCylinderInit D_808B1070; -extern ColliderCylinderInit D_808B109C; -extern DamageTable D_808B10C8; -extern CollisionCheckInfoInit D_808B10E8; -extern InitChainEntry D_808B10F0[]; +static Vec3f sAccel = { 0.0f, -(1.0f / 5.0f), 0.0f }; -extern UNK_TYPE D_06000238; -extern UNK_TYPE D_0600033C; -extern UNK_TYPE D_06005B3C; +static Color_RGBA8 D_808B1118 = { 100, 100, 100, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/EnAm_Init.s") +static Color_RGBA8 D_808B111C = { 40, 40, 40, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/EnAm_Destroy.s") +static Color_RGBA8 D_808B1120 = { 150, 150, 150, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808AFE38.s") +static Color_RGBA8 D_808B1124 = { 100, 100, 100, 150 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808AFF9C.s") +static Vec3f D_808B1128[] = { + { 4700.0f, -500.0f, 1800.0f }, { 4700.0f, -500.0f, -1800.0f }, { 2000.0f, -1500.0f, 0.0f }, + { 2000.0f, 0.0f, -1500.0f }, { 2000.0f, 0.0f, 1500.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0040.s") +static Vec3f D_808B1164[] = { + { 0.0f, -3000.0f, 0.0f }, + { 700.0f, -800.0f, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B00D8.s") +static Vec3f D_808B117C[] = { + { 800.0f, 1000.0f, -1000.0f }, + { 800.0f, 1000.0f, 1000.0f }, + { 800.0f, -1000.0f, 1000.0f }, + { 800.0f, -1000.0f, -1000.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0124.s") +void EnAm_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAm* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0208.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 300.0f / 7.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_am_Skel_005948, &gArmosPushedBackAnim, this->jointTable, + this->morphTable, OBJECT_AM_LIMB_MAX); + Collider_InitAndSetCylinder(globalCtx, &this->enemyCollider, &this->actor, &sEnemyCylinderInit); + Collider_InitAndSetCylinder(globalCtx, &this->interactCollider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->actor.home.pos.x -= 9.0f * Math_SinS(this->actor.shape.rot.y); + this->actor.home.pos.z -= 9.0f * Math_CosS(this->actor.shape.rot.y); + this->actor.world.pos.x = this->actor.home.pos.x; + this->actor.world.pos.z = this->actor.home.pos.z; + func_808AFF9C(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0358.s") +void EnAm_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAm* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B03C0.s") + Collider_DestroyCylinder(globalCtx, &this->enemyCollider); + Collider_DestroyCylinder(globalCtx, &this->interactCollider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0460.s") +void EnAm_SpawnEffects(EnAm* this, GlobalContext* globalCtx) { + s32 i; + Vec3f effectPos; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B04A8.s") + // Dust Clouds that spawn from the hop + for (i = 4; i > 0; i--) { + effectPos.x = randPlusMinusPoint5Scaled(65.0f) + this->actor.world.pos.x; + effectPos.y = randPlusMinusPoint5Scaled(10.0f) + (this->actor.world.pos.y + 40.0f); + effectPos.z = randPlusMinusPoint5Scaled(65.0f) + this->actor.world.pos.z; + EffectSsKiraKira_SpawnSmall(globalCtx, &effectPos, &sVelocity, &sAccel, &D_808B1118, &D_808B111C); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_WALK); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 4.0f, 3, 8.0f, 300, 15, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B04E4.s") +void func_808AFF9C(EnAm* this) { + f32 lastFrame = Animation_GetLastFrame(&gArmosPushedBackAnim); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0508.s") + Animation_Change(&this->skelAnime, &gArmosPushedBackAnim, 0.0f, lastFrame, lastFrame, 0, 0.0f); + this->enemyCollider.info.bumper.dmgFlags = 0x80000088; + this->interactCollider.info.bumper.dmgFlags = 0x77CFFF77; + if (this->actor.colChkInfo.health != 0) { + this->enemyCollider.base.atFlags &= ~AT_ON; + } + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actionFunc = EnAm_RemoveEnemyTexture; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B057C.s") +void EnAm_RemoveEnemyTexture(EnAm* this, GlobalContext* globalCtx) { + if (((this->enemyCollider.base.ocFlags1 & OC1_HIT) && (this->enemyCollider.base.ocFlags2 & OC2_HIT_PLAYER)) || + (this->interactCollider.base.acFlags & AC_HIT)) { + if (this->textureBlend == 0) { + EnAm_WakeUp(this); + } + } else if (this->textureBlend > 10) { + this->textureBlend -= 10; + } else { + this->textureBlend = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + this->unkFlag = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B05C8.s") +void EnAm_WakeUp(EnAm* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_WAVE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_VOICE); + this->returnHomeTimer = 300; + this->actionFunc = EnAm_ApplyEnemyTexture; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0640.s") +void EnAm_ApplyEnemyTexture(EnAm* this, GlobalContext* globalCtx) { + s32 tempTextureBlend; + f32 cos; + u8 pad; + f32 rand; + f32 sin; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B066C.s") + if (this->textureBlend + 20 >= 255) { + this->textureBlend = 255; + this->actor.flags |= ACTOR_FLAG_1; + this->enemyCollider.info.bumper.dmgFlags = 0x81C2C788; + this->interactCollider.info.bumper.dmgFlags = 0x760D3877; + this->enemyCollider.base.atFlags |= AT_ON; + this->actor.shape.yOffset = 0.0f; + func_808B0358(this); + } else { + tempTextureBlend = this->textureBlend + 20; + rand = randPlusMinusPoint5Scaled(10.0f); + cos = Math_CosS(this->actor.shape.rot.y) * rand; + sin = Math_SinS(this->actor.shape.rot.y) * rand; + this->actor.world.pos.x = this->actor.home.pos.x + cos; + this->actor.world.pos.z = this->actor.home.pos.z + sin; + this->textureBlend = tempTextureBlend; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B06D0.s") +void func_808B0208(EnAm* this, GlobalContext* globalCtx) { + // If the armos is against a wall, rotate and turn away from it + if ((this->actor.speedXZ > 0.0f) && (this->actor.bgCheckFlags & 8)) { + this->actor.world.rot.y = (this->actor.wallYaw * 2) - this->actor.world.rot.y; + this->actor.world.pos.x += this->actor.speedXZ * Math_SinS(this->actor.world.rot.y); + this->actor.world.pos.z += this->actor.speedXZ * Math_CosS(this->actor.world.rot.y); + } + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 8.0f) != 0) { + this->actor.speedXZ = this->speed; + this->actor.velocity.y = 12.0f; + } else if (this->skelAnime.curFrame > 11.0f) { + if (!(this->actor.bgCheckFlags & 1)) { + this->skelAnime.curFrame = 11.0f; + } else { + Math_ScaledStepToS(&this->actor.world.rot.y, this->armosYaw, 0x1F40); + this->actor.speedXZ = 0.0f; + if (this->actor.bgCheckFlags & 2) { + EnAm_SpawnEffects(this, globalCtx); + } + } + } + if (this->actionFunc != func_808B0894) { + this->actor.shape.rot.y = this->actor.world.rot.y; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B07A8.s") +void func_808B0358(EnAm* this) { + Animation_PlayLoopSetSpeed(&this->skelAnime, &gArmosHopAnim, 4.0f); + this->explodeTimer = 3; + this->actor.speedXZ = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->speed = 6.0f; + this->actionFunc = func_808B03C0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0820.s") +void func_808B03C0(EnAm* this, GlobalContext* globalCtx) { + this->armosYaw = this->actor.yawTowardsPlayer; + func_808B0208(this, globalCtx); + if (this->actor.bgCheckFlags & 2) { + this->explodeTimer--; + } + if (this->explodeTimer == 0) { + func_808B0640(this); + } else if ((this->returnHomeTimer == 0) || Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 240.0f) { + func_808B0460(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0894.s") +void func_808B0460(EnAm* this) { + this->actor.world.rot.y = this->actor.shape.rot.y; + this->speed = 0.0f; + this->armosYaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + this->actionFunc = func_808B04A8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0AD0.s") +void func_808B04A8(EnAm* this, GlobalContext* globalCtx) { + func_808B0208(this, globalCtx); + if (this->armosYaw == this->actor.world.rot.y) { + func_808B057C(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0B4C.s") +void func_808B04E4(EnAm* this) { + this->speed = 0.0f; + this->armosYaw = this->actor.home.rot.y; + this->actionFunc = func_808B0508; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0B9C.s") +void func_808B0508(EnAm* this, GlobalContext* globalCtx) { + func_808B0208(this, globalCtx); + if (!(this->actor.bgCheckFlags & 1)) { + Math_StepToF(&this->actor.world.pos.x, this->actor.home.pos.x, 2.0f); + Math_StepToF(&this->actor.world.pos.z, this->actor.home.pos.z, 2.0f); + } + if (this->actor.home.rot.y == this->actor.world.rot.y) { + func_808AFF9C(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/EnAm_Update.s") +void func_808B057C(EnAm* this) { + this->speed = 6.0f; + this->armosYaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + this->explodeTimer = 1; + this->actionFunc = func_808B05C8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0EA4.s") +void func_808B05C8(EnAm* this, GlobalContext* globalCtx) { + this->armosYaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + func_808B0208(this, globalCtx); + if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 8.0f) { + func_808B04E4(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/EnAm_Draw.s") +void func_808B0640(EnAm* this) { + this->explodeTimer = 40; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->speed = 0.0f; + this->actionFunc = func_808B066C; +} + +void func_808B066C(EnAm* this, GlobalContext* globalCtx) { + if (this->explodeTimer != 0) { + this->explodeTimer--; + } else { + this->armosYaw = this->actor.yawTowardsPlayer; + func_808B0208(this, globalCtx); + if (this->armosYaw == this->actor.shape.rot.y) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_VOICE); + func_808B0358(this); + } + } +} + +void EnAm_TakeDamage(EnAm* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gArmosTakeDamageAnim, 1.0f, 4.0f, + Animation_GetLastFrame(&gArmosTakeDamageAnim) - 6, 2, 0.0f); + func_800BE504(&this->actor, &this->enemyCollider); + this->actor.speedXZ = 6.0f; + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, Animation_GetLastFrame(&gArmosTakeDamageAnim) - 10); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DAMAGE); + this->enemyCollider.base.acFlags &= ~AC_ON; + this->textureBlend = 255; + this->actionFunc = func_808B07A8; +} + +void func_808B07A8(EnAm* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + if (SkelAnime_Update(&this->skelAnime)) { + if (this->actor.colChkInfo.health == 0) { + func_808B0820(this); + } else { + this->enemyCollider.base.acFlags |= AC_ON; + func_808B0358(this); + } + } +} + +void func_808B0820(EnAm* this) { + Animation_PlayLoopSetSpeed(&this->skelAnime, &gArmosHopAnim, 4.0f); + this->explodeTimer = 64; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.speedXZ = 0.0f; + this->speed = 6.0f; + this->actionFunc = func_808B0894; +} + +void func_808B0894(EnAm* this, GlobalContext* globalCtx) { + s32 i; + Vec3f dustPos; + s32 pad; + + this->explodeTimer--; + this->armosYaw = this->actor.yawTowardsPlayer; + func_808B0208(this, globalCtx); + if (this->explodeTimer == 1) { + EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 2, 0); + if (bomb != NULL) { + bomb->timer = 0; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DEAD); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xB0); + + for (i = 0; i < 8; i++) { + dustPos.x = (Math_SinS(0) * 7.0f) + this->actor.world.pos.x; + dustPos.y = (randPlusMinusPoint5Scaled(10.0f) * 6.0f) + (this->actor.world.pos.y + 40.0f); + dustPos.z = (Math_CosS(0) * 7.0f) + this->actor.world.pos.z; + + func_800B0EB0(globalCtx, &dustPos, &gZeroVec3f, &gZeroVec3f, &D_808B1120, &D_808B1124, 200, 45, 12); + } + } else if (this->explodeTimer == 0) { + Actor_MarkForDeath(&this->actor); + return; + } else if (!(this->explodeTimer & 3)) { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 4); + } + if (this->actor.world.rot.z < 0x1F40) { + this->actor.world.rot.z += 0x320; + } + this->actor.shape.rot.y += this->actor.world.rot.z; +} + +void func_808B0AD0(EnAm* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gArmosPushedBackAnim, 1.0f, 0.0f, 8.0f, 2, 0.0f); + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.speedXZ = -6.0f; + this->actionFunc = func_808B0B4C; +} + +void func_808B0B4C(EnAm* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + if (SkelAnime_Update(&this->skelAnime)) { + func_808B0358(this); + } +} + +s32 EnAm_UpdateDamage(EnAm* this, GlobalContext* globalCtx) { + if (this->enemyCollider.base.acFlags & AC_HIT) { + this->enemyCollider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&this->actor, &this->enemyCollider.info); + if (!Actor_ApplyDamage(&this->actor)) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + if (this->actor.colChkInfo.damageEffect == 0xD) { + return true; + } + if (this->actor.colChkInfo.health != 0) { + this->enemyCollider.base.atFlags &= ~AT_ON; + } + this->enemyCollider.base.atFlags &= ~AT_HIT; + if (this->actor.colChkInfo.damageEffect == 0x4) { + this->effectScale = 0.7f; + this->effectAlpha = 4.0f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->enemyCollider.info.bumper.hitPos.x, + this->enemyCollider.info.bumper.hitPos.y, this->enemyCollider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_LARGE_LIGHT_RAYS); + } + EnAm_TakeDamage(this, globalCtx); + return true; + } + return false; +} + +void EnAm_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAm* this = THIS; + s32 pad; + + if (EnAm_UpdateDamage(this, globalCtx) == false) { + if (this->enemyCollider.base.atFlags & AT_BOUNCED) { + this->enemyCollider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); + if (this->actor.colChkInfo.health == 0) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; + } else { + func_808B0AD0(this, globalCtx); + } + } + } + if (this->returnHomeTimer != 0) { + this->returnHomeTimer--; + } + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 30.0f, 100.0f, 0x1D); + Actor_SetFocus(&this->actor, 64.0f); + Collider_UpdateCylinder(&this->actor, &this->enemyCollider); + Collider_UpdateCylinder(&this->actor, &this->interactCollider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->enemyCollider.base); + if (this->enemyCollider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->enemyCollider.base); + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->interactCollider.base); + if (this->enemyCollider.base.atFlags & AC_ON) { + this->actor.flags |= ACTOR_FLAG_1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->enemyCollider.base); + } + Math_StepToF(&this->effectAlpha, 0.0f, 0.05f); + this->effectScale = (this->effectAlpha + 1.0f) * 0.35f; + this->effectScale = (this->effectScale > 0.7f) ? 0.7f : this->effectScale; +} + +void EnAm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 i; + s32 phi_s3; + Vec3f* phi_s1; + Vec3f* phi_s2; + EnAm* this = THIS; + + phi_s2 = 0; + phi_s1 = 0; + if (limbIndex == 4) { + phi_s2 = &this->limbPos[0]; + phi_s1 = D_808B1128; + phi_s3 = 5; + } else if (limbIndex == 13) { + phi_s2 = &this->limbPos[9]; + phi_s1 = D_808B117C; + phi_s3 = 4; + } else if ((limbIndex == 7) || (limbIndex == 10)) { + phi_s2 = (limbIndex == 7) ? &this->limbPos[5] : &this->limbPos[7]; + phi_s1 = D_808B1164; + phi_s3 = 2; + } else { + phi_s3 = 0; + } + for (i = 0; i < phi_s3; i++, phi_s2++, phi_s1++) { + Matrix_MultiplyVector3fByState(phi_s1, phi_s2); + } +} + +void EnAm_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx* gfx; + EnAm* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + gfx = POLY_OPA_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + gDPSetEnvColor(&gfx[1], 0, 0, 0, this->textureBlend); + POLY_OPA_DISP = &gfx[2]; + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, EnAm_PostLimbDraw, + &this->actor); + func_800BE680(globalCtx, &this->actor, this->limbPos, 13, this->effectScale, 0.0f, this->effectAlpha, 20); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.h b/src/overlays/actors/ovl_En_Am/z_en_am.h index 59d8abbad..02ba4dd4a 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.h +++ b/src/overlays/actors/ovl_En_Am/z_en_am.h @@ -2,6 +2,7 @@ #define Z_EN_AM_H #include "global.h" +#include "objects/object_am/object_am.h" struct EnAm; @@ -9,9 +10,21 @@ typedef void (*EnAmActionFunc)(struct EnAm*, GlobalContext*); typedef struct EnAm { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xEC]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[OBJECT_AM_LIMB_MAX]; + /* 0x01DC */ Vec3s morphTable[OBJECT_AM_LIMB_MAX]; /* 0x0230 */ EnAmActionFunc actionFunc; - /* 0x0234 */ char unk_234[0x14C]; + /* 0x0234 */ u8 textureBlend; // 0 = statue textures; 255 = enemy textures + /* 0x0236 */ s16 explodeTimer; // timer counting down till armos explodes + /* 0x0238 */ s16 returnHomeTimer; // Timer that counts down till an armos will return to its spawn position + /* 0x023A */ s16 unkFlag; + /* 0x023C */ s16 armosYaw; // Yaw of Armos + /* 0x0240 */ f32 speed; // Hopping speed of Armos + /* 0x0244 */ f32 effectAlpha; + /* 0x0248 */ f32 effectScale; + /* 0x024C */ Vec3f limbPos[13]; + /* 0x02E8 */ ColliderCylinder enemyCollider; // Collider for when Armos is Hostile + /* 0x0334 */ ColliderCylinder interactCollider; // Collider for when an interactable Armos is docile } EnAm; // size = 0x380 extern const ActorInit En_Am_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 87e56de8a..2933a97bf 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -5873,11 +5873,11 @@ 0x808AF8F8:("EnBombf_Draw",), 0x808AFCD0:("EnAm_Init",), 0x808AFDF8:("EnAm_Destroy",), - 0x808AFE38:("func_808AFE38",), + 0x808AFE38:("EnAm_SpawnEffects",), 0x808AFF9C:("func_808AFF9C",), - 0x808B0040:("func_808B0040",), - 0x808B00D8:("func_808B00D8",), - 0x808B0124:("func_808B0124",), + 0x808B0040:("EnAm_RemoveEnemyTexture",), + 0x808B00D8:("EnAm_WakeUp",), + 0x808B0124:("EnAm_ApplyEnemyTexture",), 0x808B0208:("func_808B0208",), 0x808B0358:("func_808B0358",), 0x808B03C0:("func_808B03C0",), @@ -5889,15 +5889,15 @@ 0x808B05C8:("func_808B05C8",), 0x808B0640:("func_808B0640",), 0x808B066C:("func_808B066C",), - 0x808B06D0:("func_808B06D0",), + 0x808B06D0:("EnAm_TakeDamage",), 0x808B07A8:("func_808B07A8",), 0x808B0820:("func_808B0820",), 0x808B0894:("func_808B0894",), 0x808B0AD0:("func_808B0AD0",), 0x808B0B4C:("func_808B0B4C",), - 0x808B0B9C:("func_808B0B9C",), + 0x808B0B9C:("EnAm_UpdateDamage",), 0x808B0CC8:("EnAm_Update",), - 0x808B0EA4:("func_808B0EA4",), + 0x808B0EA4:("EnAm_PostLimbDraw",), 0x808B0F98:("EnAm_Draw",), 0x808B1330:("EnDekubaba_Init",), 0x808B1504:("EnDekubaba_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 30b7873fa..ecc7f4d93 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1162,13 +1162,6 @@ D_06009E70 = 0x06009E70; D_0600A0D8 = 0x0600A0D8; -// ovl_En_Am - -D_06000238 = 0x06000238; -D_0600033C = 0x0600033C; -D_06005948 = 0x06005948; -D_06005B3C = 0x06005B3C; - // ovl_En_An D_06000308 = 0x06000308; From 5fa02d9725e3c33ee1a0a8bf93723615d2fdd9e2 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 13 Feb 2022 23:14:13 +0000 Subject: [PATCH 003/257] En_Arrow (1 non-matching) (#551) * En_Arrow * Remove comment * UNK_TYPE1 * Add thing * Merge * Merge * PR * PR * PR --- include/functions.h | 6 +- spec | 5 +- src/code/z_fireobj.c | 2 +- src/overlays/actors/ovl_En_Arrow/z_en_arrow.c | 720 +++++++++++++++++- src/overlays/actors/ovl_En_Arrow/z_en_arrow.h | 57 +- .../actors/ovl_Obj_Syokudai/z_obj_syokudai.c | 2 +- .../effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h | 5 +- 7 files changed, 759 insertions(+), 38 deletions(-) diff --git a/include/functions.h b/include/functions.h index 7749761aa..6abcd11ad 100644 --- a/include/functions.h +++ b/include/functions.h @@ -576,10 +576,10 @@ void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstSca // void EffectSsStick_Spawn(UNK_TYPE4 uParm1, UNK_PTR puParm2, UNK_TYPE2 uParm3); // void EffectSsSibuki_Spawn(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); void EffectSsSibuki_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos); -// void EffectSsStone1_Spawn(UNK_TYPE4 uParm1, UNK_PTR puParm2, UNK_TYPE4 uParm3); +void EffectSsStone1_Spawn(GlobalContext* globalCtx, Vec3f* arg1, s32 arg2); // void EffectSsHitMark_Spawn(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, UNK_TYPE2 uParm3, Vec3f* pzParm4); void EffectSsHitMark_SpawnFixedScale(GlobalContext* globalCtx, s32 type, Vec3f* pos); -// void EffectSsHitMark_SpawnCustomScale(void); +void EffectSsHitMark_SpawnCustomScale(GlobalContext* globalCtx, s32 type, s16 scale, Vec3f* pos); // void EffectSsFhgFlash_SpawnShock(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, UNK_TYPE2 uParm4, UNK_TYPE1 param_5); // void EffectSsKFire_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE1 param_6); void EffectSsSolderSrchBall_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16* linkDetected, s16 drawFlag); @@ -2099,7 +2099,7 @@ s32 func_801242B4(Player* player); // void func_80125D4C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_801262C8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_801263FC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -void func_80126440(GlobalContext* globalCtx, Collider* param_2, s32* param_3, Vec3f* param_4, Vec3f* param_5); +s32 func_80126440(GlobalContext* globalCtx, Collider* param_2, s32* param_3, Vec3f* param_4, Vec3f* param_5); // void func_801265C8(void); // void func_8012669C(void); // void func_80126808(void); diff --git a/spec b/spec index d9f933e8e..139f84845 100644 --- a/spec +++ b/spec @@ -846,8 +846,11 @@ beginseg name "ovl_En_Arrow" compress include "build/src/overlays/actors/ovl_En_Arrow/z_en_arrow.o" - include "build/data/ovl_En_Arrow/ovl_En_Arrow.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_En_Arrow/ovl_En_Arrow_reloc.o" +#else include "build/data/ovl_En_Arrow/ovl_En_Arrow.reloc.o" +#endif endseg beginseg diff --git a/src/code/z_fireobj.c b/src/code/z_fireobj.c index 2cf05e02a..9cc126cf8 100644 --- a/src/code/z_fireobj.c +++ b/src/code/z_fireobj.c @@ -242,7 +242,7 @@ void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor) { } else if ((fire->collision.base.acFlags & 2) && (arrow->actor.update != NULL) && (arrow->actor.id == ACTOR_EN_ARROW)) { arrow->actor.params = 0; - arrow->unk_1C0 = 0x800; + arrow->collider.info.toucher.dmgFlags = 0x800; } fire->collision.dim.pos.x = fire->position.x; fire->collision.dim.pos.y = fire->position.y; diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index 097c90fe0..adfce2f19 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -5,8 +5,10 @@ */ #include "z_en_arrow.h" +#include "overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnArrow*)thisx) @@ -20,7 +22,6 @@ void func_8088ACE0(EnArrow* this, GlobalContext* globalCtx); void func_8088B630(EnArrow* this, GlobalContext* globalCtx); void func_8088B6B0(EnArrow* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Arrow_InitVars = { ACTOR_EN_ARROW, ACTORCAT_ITEMACTION, @@ -33,45 +34,718 @@ const ActorInit En_Arrow_InitVars = { (ActorFunc)EnArrow_Draw, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_8088C1E0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_TYPE_PLAYER, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK2, { 0x00000020, 0x00, 0x02 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_NEAREST | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_NONE, }, +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_TYPE_PLAYER, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK2, + { 0x00000020, 0x00, 0x02 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_NEAREST | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8088C230[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(terminalVelocity, -150, ICHAIN_STOP), }; +void EnArrow_Init(Actor* thisx, GlobalContext* globalCtx) { + static EffectBlureInit2 D_8088C234 = { + 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, + 0, 1, 0, { 255, 255, 170, 255 }, { 0, 150, 0, 0 }, + }; + static EffectBlureInit2 D_8088C258 = { + 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, + 0, 1, 0, { 255, 200, 0, 255 }, { 255, 0, 0, 0 }, + }; + static EffectBlureInit2 D_8088C27C = { + 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, + 0, 1, 0, { 170, 255, 255, 255 }, { 0, 0x64, 255, 0 }, + }; + static EffectBlureInit2 D_8088C2A0 = { + 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, + 0, 1, 0, { 255, 255, 170, 255 }, { 255, 255, 0, 0 }, + }; + EnArrow* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + if (this->actor.params == ENARROW_MINUS8) { + this->unk_263 = 1; + this->actor.params = 8; + } + + if (this->actor.params < ENARROW_6) { + SkelAnime_Init(globalCtx, &this->arrow.skelAnime, &gameplay_keep_Skel_014560, &gameplay_keep_Anim_0128BC, + this->arrow.jointTable, this->arrow.jointTable, 5); + if (this->actor.params < ENARROW_3) { + if (this->actor.params == ENARROW_1) { + D_8088C234.elemDuration = 4; + } else { + D_8088C234.elemDuration = 16; + } + Effect_Add(globalCtx, &this->unk_240, EFFECT_BLURE2, 0, 0, &D_8088C234); + } else if (this->actor.params == ENARROW_3) { + Effect_Add(globalCtx, &this->unk_240, EFFECT_BLURE2, 0, 0, &D_8088C258); + } else if (this->actor.params == ENARROW_4) { + Effect_Add(globalCtx, &this->unk_240, EFFECT_BLURE2, 0, 0, &D_8088C27C); + } else if (this->actor.params == ENARROW_5) { + Effect_Add(globalCtx, &this->unk_240, EFFECT_BLURE2, 0, 0, &D_8088C2A0); + } + } + + Collider_InitQuad(globalCtx, &this->collider); + Collider_SetQuad(globalCtx, &this->collider, &this->actor, &sQuadInit); + + if (this->actor.params < ENARROW_6) { + this->collider.info.toucherFlags &= ~(TOUCH_SFX_WOOD | TOUCH_SFX_HARD); + this->collider.info.toucherFlags |= 0; + } + + if (this->actor.params < ENARROW_0) { + this->collider.base.atFlags = (AT_TYPE_ENEMY | AT_ON); + } else { + this->collider.info.toucher.dmgFlags = func_800BC188(this->actor.params); + if (this->actor.params == ENARROW_8) { + this->collider.info.toucher.damage = 1; + } + + if (this->actor.params == ENARROW_7) { + Actor_SetScale(&this->actor, 1.0f); + } + } + this->actionFunc = func_8088A594; +} + +void EnArrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnArrow* this = THIS; + + if (this->actor.params < ENARROW_6) { + Effect_Destroy(globalCtx, this->unk_240); + } + + Collider_DestroyQuad(globalCtx, &this->collider); + + if ((this->unk_264 != NULL) && (this->unk_264->update != NULL)) { + this->unk_264->flags &= ~0x8000; + } + + if ((this->actor.params >= ENARROW_3) && (this->actor.params < ENARROW_6) && (this->actor.child == NULL)) { + func_80115D5C(&globalCtx->state); + } +} + +void func_8088A514(EnArrow* this) { + f32 temp_f0 = 16.0f - this->bubble.unk_144; + + Actor_SetSpeeds(&this->actor, CLAMP(temp_f0, 1.0f, 80.0f)); +} + +void func_8088A594(EnArrow* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->actor.parent != NULL) { + if (this->actor.params == ENARROW_7) { + if (Math_SmoothStepToF(&this->bubble.unk_144, 16.0f, 0.07f, 1.8f, 0.0f) > 0.5f) { + func_800B9010(&this->actor, NA_SE_PL_DEKUNUTS_BUBLE_BREATH - SFX_FLAG); + return; + } + + this->bubble.unk_148++; + if (this->bubble.unk_148 > 20) { + this->actionFunc = func_8088ACE0; + func_80115D5C(&globalCtx->state); + } + } + } else { + if ((this->actor.params != ENARROW_8) && (player->unk_D57 == 0)) { + if (this->actor.params == ENARROW_7) { + func_80115D5C(&globalCtx->state); + } + Actor_MarkForDeath(&this->actor); + return; + } + + switch (this->actor.params) { + case ENARROW_6: + func_800B8E58(player, NA_SE_IT_SLING_SHOT); + break; + + case ENARROW_0: + case ENARROW_1: + case ENARROW_2: + func_800B8E58(player, NA_SE_IT_ARROW_SHOT); + break; + + case ENARROW_3: + case ENARROW_4: + case ENARROW_5: + func_800B8E58(player, NA_SE_IT_MAGIC_ARROW_SHOT); + + case ENARROW_7: + func_800B8E58(player, NA_SE_PL_DEKUNUTS_FIRE); + break; + } + + this->actionFunc = func_8088ACE0; + Math_Vec3f_Copy(&this->unk_228, &this->actor.world.pos); + + if (this->actor.params == ENARROW_7) { + this->bubble.unk_144 = CLAMP_MIN(this->bubble.unk_144, 3.5f); + func_8088A514(this); + this->unk_260 = 99; + func_80115D5C(&globalCtx->state); + } else if (this->actor.params >= ENARROW_6) { + if ((this->actor.params == ENARROW_8) && (this->actor.world.rot.x < 0)) { + Actor_SetScale(&this->actor, 0.009f); + this->unk_260 = 40; + } else { + Actor_SetSpeeds(&this->actor, 80.0f); + this->unk_260 = 15; + } + this->actor.shape.rot.x = 0; + this->actor.shape.rot.y = 0; + this->actor.shape.rot.z = 0; + } else { + Actor_SetSpeeds(&this->actor, 150.0f); + this->unk_260 = 16; + } + } +} + +void func_8088A7D8(GlobalContext* globalCtx, EnArrow* this) { + this->actionFunc = func_8088B6B0; + Animation_PlayOnce(&this->arrow.skelAnime, &gameplay_keep_Anim_012860); + this->actor.world.rot.y += (s32)(0x6000 * (Rand_ZeroOne() - 0.5f)) + 0x8000; + this->actor.speedXZ *= 0.02f + (0.02f * Rand_ZeroOne()); + this->actor.gravity = -1.5f; + this->unk_260 = 50; + this->unk_263 = 1; +} + +void func_8088A894(EnArrow* this, GlobalContext* globalCtx) { + CollisionPoly* sp74; + Vec3f sp68; + Vec3f sp5C; + Vec3f sp50; + f32 sp4C; + f32 temp_f0; + s32 sp44; + + Math_Vec3f_Diff(&this->actor.world.pos, &this->unk_228, &sp68); + sp4C = ((this->actor.world.pos.x - this->unk_264->world.pos.x) * sp68.x) + + ((this->actor.world.pos.y - this->unk_264->world.pos.y) * sp68.y) + + ((this->actor.world.pos.z - this->unk_264->world.pos.z) * sp68.z); + if (sp4C < 0.0f) { + return; + } + + temp_f0 = Math3D_LengthSquared(&sp68); + if (temp_f0 < 1.0f) { + return; + } + + temp_f0 = sp4C / temp_f0; + Math_Vec3f_Scale(&sp68, temp_f0); + Math_Vec3f_Sum(&this->unk_264->world.pos, &sp68, &sp5C); + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->unk_264->world.pos, &sp5C, &sp50, &sp74, true, true, true, + true, &sp44)) { + this->unk_264->world.pos.x = ((sp5C.x <= sp50.x) ? 1.0f : -1.0f) + sp50.x; + this->unk_264->world.pos.y = ((sp5C.y <= sp50.y) ? 1.0f : -1.0f) + sp50.y; + this->unk_264->world.pos.z = ((sp5C.z <= sp50.z) ? 1.0f : -1.0f) + sp50.z; + } else { + Math_Vec3f_Copy(&this->unk_264->world.pos, &sp5C); + } +} + +void func_8088AA98(EnArrow* this, GlobalContext* globalCtx) { + WaterBox* sp54; + f32 sp50 = this->actor.world.pos.y; + Vec3f sp44; + f32 temp_f0; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, + &sp54) && + (this->actor.world.pos.y < sp50) && !(this->actor.bgCheckFlags & 0x20)) { + this->actor.bgCheckFlags |= 0x20; + + Math_Vec3f_Diff(&this->actor.world.pos, &this->actor.home.pos, &sp44); + + if (sp44.y != 0.0f) { + temp_f0 = sqrtf(SQ(sp44.x) + SQ(sp44.z)); + if (temp_f0 != 0.0f) { + temp_f0 = (((sp50 - this->actor.home.pos.y) / sp44.y) * temp_f0) / temp_f0; + } + sp44.x = this->actor.home.pos.x + (sp44.x * temp_f0); + sp44.y = sp50; + sp44.z = this->actor.home.pos.z + (sp44.z * temp_f0); + EffectSsGSplash_Spawn(globalCtx, &sp44, NULL, NULL, 0, 300); + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); + + EffectSsGRipple_Spawn(globalCtx, &sp44, 100, 500, 0); + EffectSsGRipple_Spawn(globalCtx, &sp44, 100, 500, 4); + EffectSsGRipple_Spawn(globalCtx, &sp44, 100, 500, 8); + + if ((this->actor.params == ENARROW_4) || (this->actor.params == ENARROW_3)) { + if ((this->actor.params == ENARROW_4) && (func_8088B6B0 != this->actionFunc)) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_ICEFLOE, sp44.x, sp44.y, sp44.z, 0, 0, 0, 300); + Actor_MarkForDeath(&this->actor); + return; + } + + this->actor.params = ENARROW_2; + this->collider.info.toucher.dmgFlags = 0x20; + + if (this->actor.child != NULL) { + Actor_MarkForDeath(this->actor.child); + return; + } + + func_80115D5C(&globalCtx->state); + } + } +} + +#ifdef NON_MATCHING +// Stack. Scoped variable required to fix code gen at the bottom, likely sp60/54 there, +// but sp50 must be declared below those so maybe not? +void func_8088ACE0(EnArrow* this, GlobalContext* globalCtx) { + CollisionPoly* spAC; + s32 spA8; + Vec3f sp9C; + s32 phi_a2 = 0; + EffectSsSbnInitParams sp84; + u16 sp82; + Actor* sp7C; + f32 sp78; + f32 sp74; + f32 temp_f12_2; + Vec3f sp60; + Vec3f sp54; + s32 sp50; + + if ((DECR(this->unk_260) == 0) || + ((this->actor.params == ENARROW_7) && + ((this->unk_262 != 0) || (phi_a2 = (this->collider.base.atFlags & AT_HIT) != 0)))) { + if (this->actor.params == ENARROW_7) { + if (phi_a2 && (this->collider.info.atHitInfo->elemType != ELEMTYPE_UNK4) && + (this->collider.base.atFlags & AT_BOUNCED)) { + if ((this->collider.base.at != NULL) && (this->collider.base.at->id != ACTOR_OBJ_SYOKUDAI)) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); + this->actor.world.rot.y += BINANG_ROT180((s16)randPlusMinusPoint5Scaled(8000.0f)); + this->actor.velocity.y = -this->actor.velocity.y; + this->bubble.unk_149 = -1; + return; + } + } + + if ((this->unk_262 != 0) || phi_a2) { + EffectSsStone1_Spawn(globalCtx, &this->actor.world.pos, 0); + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_IT_DEKUNUTS_BUBLE_VANISH); + + if ((this->unk_262 != 0) && (this->actor.wallBgId == BG_ACTOR_MAX)) { + + Math_Vec3f_Copy(&sp84.unk_00, &this->actor.world.pos); + sp84.unk_0C = this->actor.wallPoly; + sp84.unk_10 = this->bubble.unk_144; + EffectSs_Spawn(globalCtx, EFFECT_SS_SBN, 128, &sp84.unk_00); + } + } + Actor_MarkForDeath(&this->actor); + return; + } + + sp50 = + (this->actor.params != ENARROW_0) && (this->actor.params < ENARROW_8) && (this->collider.base.atFlags & AT_HIT); + + if (sp50 || (this->unk_262 != 0)) { + if (this->actor.params >= ENARROW_6) { + if (sp50) { + this->actor.world.pos.x = (this->actor.world.pos.x + this->actor.prevPos.x) * 0.5f; + this->actor.world.pos.y = (this->actor.world.pos.y + this->actor.prevPos.y) * 0.5f; + this->actor.world.pos.z = (this->actor.world.pos.z + this->actor.prevPos.z) * 0.5f; + } + + if (this->actor.params == ENARROW_8) { + iREG(50) = -1; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_M_FIRE1, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, this->actor.speedXZ == 0.0f); + sp82 = NA_SE_IT_DEKU; + } else { + sp82 = NA_SE_IT_SLING_REFLECT; + } + EffectSsStone1_Spawn(globalCtx, &this->actor.world.pos, 0); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, sp82); + Actor_MarkForDeath(&this->actor); + } else { + EffectSsHitMark_SpawnCustomScale(globalCtx, 0, 150, &this->actor.world.pos); + + if (sp50 && (this->collider.info.atHitInfo->elemType != ELEMTYPE_UNK4)) { + sp7C = this->collider.base.at; + + if ((sp7C->update != NULL) && !(this->collider.base.atFlags & AT_BOUNCED) && (sp7C->flags & 0x4000)) { + this->unk_264 = sp7C; + func_8088A894(this, globalCtx); + Math_Vec3f_Diff(&sp7C->world.pos, &this->actor.world.pos, &this->unk_268); + sp7C->flags |= 0x8000; + this->collider.base.atFlags &= ~AT_HIT; + this->actor.speedXZ *= 0.5f; + this->actor.velocity.y *= 0.5f; + } else { + this->unk_261 |= 1; + this->unk_261 |= 2; + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); + func_8088A7D8(globalCtx, this); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_HOOKSHOT_STICK_CRE); + } + } else if (this->unk_262 != 0) { + this->actionFunc = func_8088B630; + Animation_PlayOnce(&this->arrow.skelAnime, &gameplay_keep_Anim_0128BC); + if (this->actor.params >= ENARROW_0) { + this->unk_260 = 60; + } else { + this->unk_260 = 20; + } + if ((this->actor.params >= ENARROW_3) && (this->actor.params < ENARROW_6)) { + this->actor.draw = NULL; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_ARROW_STICK_OBJ); + this->unk_261 |= 1; + } + } + } else { + func_8088AA98(this, globalCtx); + if (this->actor.params == ENARROW_7) { + if (this->bubble.unk_149 == 0) { + sp78 = sqrtf(SQ(this->actor.speedXZ) + SQ(this->actor.velocity.y)); + sp74 = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; + temp_f12_2 = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; + + this->actor.prevPos.x = this->actor.world.pos.x - (sp74 * (10.0f / sp78)); + this->actor.prevPos.y = this->actor.world.pos.y - (this->actor.velocity.y * (10.0f / sp78)); + this->actor.prevPos.z = this->actor.world.pos.z - (temp_f12_2 * (10.0f / sp78)); + + this->bubble.unk_149 = 1; + } + + if (Math_StepToF(&this->bubble.unk_144, 1.0f, 0.4f)) { + this->unk_260 = 0; + } else { + this->bubble.unk_14A += (s16)(this->bubble.unk_144 * (500.0f + Rand_ZeroFloat(1400.0f))); + this->actor.world.rot.x += (s16)(500.0f * Math_SinS(this->bubble.unk_14A)); + this->actor.shape.rot.x = this->actor.world.rot.x; + + this->bubble.unk_14C += (s16)(this->bubble.unk_144 * (500.0f + Rand_ZeroFloat(1400.0f))); + this->actor.world.rot.y += (s16)(500.0f * Math_SinS(this->bubble.unk_14C)); + + this->actor.shape.rot.y = this->actor.world.rot.y; + + func_8088A514(this); + } + func_800B9010(&this->actor, NA_SE_IT_DEKUNUTS_BUBLE_SHOT_LEVEL - SFX_FLAG); + } else if (this->unk_260 < 7) { + this->actor.gravity = -0.4f; + } + + Math_Vec3f_Copy(&this->unk_228, &this->actor.world.pos); + + if (this->actor.speedXZ == 0.0f) { + this->actor.velocity.y -= 1.0f; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } + Actor_UpdatePos(&this->actor); + } else { + Actor_MoveWithGravity(&this->actor); + } + + this->unk_262 = BgCheck_ProjectileLineTest(&globalCtx->colCtx, &this->actor.prevPos, &this->actor.world.pos, + &sp9C, &this->actor.wallPoly, 1, 1, 1, 1, &spA8); + if (this->unk_262 != 0) { + func_800B90AC(globalCtx, &this->actor, this->actor.wallPoly, spA8, &sp9C); + Math_Vec3f_Copy(&this->actor.world.pos, &sp9C); + this->actor.wallBgId = spA8; + } + + if (this->actor.params < ENARROW_6) { + this->actor.shape.rot.x = Math_FAtan2F(this->actor.speedXZ, -this->actor.velocity.y); + } + } + + if (this->unk_264 != NULL) { + if (this->unk_264->update != NULL) { + s32 pad; + + Math_Vec3f_Sum(&this->unk_228, &this->unk_268, &sp60); + Math_Vec3f_Sum(&this->actor.world.pos, &this->unk_268, &sp54); + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp60, &sp54, &sp9C, &spAC, true, true, true, true, + &spA8)) { + this->unk_264->world.pos.x = ((sp54.x <= sp9C.x) ? 1.0f : -1.0f) + sp9C.x; + this->unk_264->world.pos.y = ((sp54.y <= sp9C.y) ? 1.0f : -1.0f) + sp9C.y; + this->unk_264->world.pos.z = ((sp54.z <= sp9C.z) ? 1.0f : -1.0f) + sp9C.z; + + Math_Vec3f_Diff(&this->unk_264->world.pos, &this->actor.world.pos, &this->unk_268); + this->unk_264->flags &= ~0x8000; + this->unk_264 = NULL; + } else { + Math_Vec3f_Sum(&this->actor.world.pos, &this->unk_268, &this->unk_264->world.pos); + } + + if ((this->unk_262 != 0) && (this->unk_264 != NULL)) { + this->unk_264->flags &= ~0x8000; + this->unk_264 = NULL; + } + } else { + this->unk_264 = NULL; + } + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088ACE0.s") #endif -extern ColliderQuadInit D_8088C1E0; -extern InitChainEntry D_8088C230[]; +void func_8088B630(EnArrow* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->arrow.skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/EnArrow_Init.s") + if (this->actor.wallBgId != BG_ACTOR_MAX) { + BgCheck2_UpdateActorAttachedToMesh(&globalCtx->colCtx, this->actor.wallBgId, &this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/EnArrow_Destroy.s") + if (DECR(this->unk_260) == 0) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088A514.s") +void func_8088B6B0(EnArrow* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->arrow.skelAnime); + Actor_MoveWithGravity(&this->actor); + func_8088AA98(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088A594.s") + if (DECR(this->unk_260) == 0) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088A7D8.s") +void EnArrow_Update(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f D_8088C2CC = { 0.0f, 0.5f, 0.0f }; + static Vec3f D_8088C2D8 = { 0.0f, 0.5f, 0.0f }; + static Color_RGBA8 D_8088C2E4 = { 255, 255, 100, 255 }; + static Color_RGBA8 D_8088C2E8 = { 255, 50, 0, 0 }; + s32 pad; + EnArrow* this = THIS; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088A894.s") + if ((this->unk_263 != 0) || + ((this->actor.params >= ENARROW_0) && ((this->actor.params == ENARROW_7) || (player->unk_D57 != 0))) || + !func_80123358(globalCtx, player)) { + this->actionFunc(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088AA98.s") + if ((this->actor.params >= ENARROW_3) && (this->actor.params < ENARROW_6)) { + s16 sp44[] = { ACTOR_ARROW_FIRE, ACTOR_ARROW_ICE, ACTOR_ARROW_LIGHT }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088ACE0.s") + if (this->actor.child == NULL) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, sp44[this->actor.params - ENARROW_3], + this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + } + } else if (this->actor.params == ENARROW_0) { + func_800B0EB0(globalCtx, &this->unk_234, &D_8088C2CC, &D_8088C2D8, &D_8088C2E4, &D_8088C2E8, 100, 0, 8); + } + Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.prevPos); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088B630.s") +typedef struct { + /* 0x00 */ Vec3f unk_00[2]; + /* 0x18 */ Vec3f unk_18[2][2]; + /* 0x48 */ Vec3f unk_48; +} EnArrowUnkStruct; // size = 0x54 -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088B6B0.s") +void func_8088B88C(GlobalContext* globalCtx, EnArrow* this, EnArrowUnkStruct* arg2) { + Vec3f* sp4C; + Vec3f sp40; + Vec3f sp34; + s32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/EnArrow_Update.s") + Matrix_MultiplyVector3fByState(&arg2->unk_48, &this->unk_234); + if (func_8088ACE0 == this->actionFunc) { + if (this->unk_244 == 0) { + sp4C = arg2->unk_00; + } else { + sp4C = arg2->unk_18[globalCtx->gameplayFrames % 2]; + } + Matrix_MultiplyVector3fByState(&sp4C[0], &sp40); + Matrix_MultiplyVector3fByState(&sp4C[1], &sp34); + if (this->actor.params < ENARROW_8) { + sp30 = this->actor.params < ENARROW_6; + if (this->unk_264 == 0) { + sp30 &= func_80126440(globalCtx, &this->collider.base, &this->unk_244, &sp40, &sp34); + } else if (sp30 && (sp40.x == this->unk_248) && (sp40.y == this->unk_24C) && (sp40.z == this->unk_250) && + (sp34.x == this->unk_254) && (sp34.y == this->unk_258) && (sp34.z == this->unk_25C)) { + sp30 = false; + } + if (sp30) { + EffectBlure_AddVertex(Effect_GetByIndex(this->unk_240), &sp40, &sp34); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088B88C.s") +void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { + static EnArrowUnkStruct D_8088C2EC[] = { + { + { + { 400.0f, 400.0f, 0.0f }, + { -400.0f, 400.0f, 0.0f }, + }, + { + { + { 400.0f, 400.0f, 1500.0f }, + { -400.0f, 400.0f, 1500.0f }, + }, + { + { 400.0f, 400.0f, 1500.0f }, + { -400.0f, 400.0f, 1500.0f }, + }, + }, + { 0.0f, 0.0f, -300.0f }, + }, + { + { + { 20.0f, -20.0f, 20.0f }, + { 20.0f, -20.0f, 20.0f }, + }, + { + { + { 20.0f, -20.0f, 20.0f }, + { -20.0f, 20.0f, 20.0f }, + }, + { + { -20.0f, -20.0f, 20.0f }, + { 20.0f, 20.0f, 20.0f }, + }, + }, + { 0.0f, 0.0f, 20.0f }, + }, + }; + EnArrow* this = THIS; + s32 phi_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/EnArrow_Draw.s") + if (this->actor.params < ENARROW_6) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawLod(globalCtx, this->arrow.skelAnime.skeleton, this->arrow.skelAnime.jointTable, NULL, NULL, + &this->actor, this->actor.projectedPos.z < 160.0f ? 0 : 1); + } else if (this->actor.params == ENARROW_7) { + s32 spA4 = 255 - (s32)(this->bubble.unk_144 * 4.0f); + f32 spA0 = (this->actor.speedXZ * 0.1f) + 1.0f; + f32 sp9C = (1.0f / spA0); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->bubble.unk_149 >= 0) { + func_8088B88C(globalCtx, this, &D_8088C2EC[1]); + } else { + Collider_ResetQuadAT(globalCtx, &this->collider.base); + } + + sp9C *= 0.002f; + spA0 *= 0.002f; + + Matrix_Scale(this->bubble.unk_144 * sp9C, this->bubble.unk_144 * sp9C, this->bubble.unk_144 * spA0, + MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, 460.0f, MTXMODE_APPLY); + + if (this->actor.speedXZ == 0.0f) { + func_800B8118(&this->actor, globalCtx, MTXMODE_NEW); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_06F380); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); + gDPSetCombineLERP(POLY_XLU_DISP++, TEXEL1, 0, PRIM_LOD_FRAC, TEXEL0, TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0, + COMBINED, 0, ENVIRONMENT, 0, COMBINED, 0, ENVIRONMENT, 0); + gDPSetEnvColor(POLY_XLU_DISP++, 230, 225, 150, spA4); + + Matrix_NormalizeXYZ(&gIdentityMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_XLU_DISP++, &D_01000000, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_06F9F0); + } else { + func_800B8050(&this->actor, globalCtx, MTXMODE_NEW); + + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06F380); + gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL1, 0, PRIM_LOD_FRAC, TEXEL0, TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0, + COMBINED, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x7F, 230, 225, 150, 255); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06FAE0); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + return; + } else if (this->actor.speedXZ != 0.0f) { + u8 sp63 = (Math_CosS(this->unk_260 * 5000) * 127.5f) + 127.5f; + f32 sp5C; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C240(globalCtx->state.gfxCtx); + + gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + + if (this->actor.params == ENARROW_6) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, sp63); + sp5C = 50.0f; + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 12, 0, 0, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 0, sp63); + sp5C = 150.0f; + } + + Matrix_StatePush(); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + if (this->actor.speedXZ == 0.0f) { + phi_v0 = 0; + } else { + phi_v0 = (globalCtx->gameplayFrames % 256) * 4000; + } + + Matrix_InsertZRotation_s(phi_v0, MTXMODE_APPLY); + Matrix_Scale(sp5C, sp5C, sp5C, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + + Matrix_StatePop(); + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else if (this->actor.velocity.y != 0.0f) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_058BA0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + func_8088B88C(globalCtx, this, &D_8088C2EC[0]); +} diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h index 119507d4d..f318cf152 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h @@ -7,15 +7,56 @@ struct EnArrow; typedef void (*EnArrowActionFunc)(struct EnArrow*, GlobalContext*); +enum { + /* -8 */ ENARROW_MINUS8 = -8, + /* 0 */ ENARROW_0 = 0, + /* 1 */ ENARROW_1, + /* 2 */ ENARROW_2, + /* 3 */ ENARROW_3, + /* 4 */ ENARROW_4, + /* 5 */ ENARROW_5, + /* 6 */ ENARROW_6, + /* 7 */ ENARROW_7, + /* 8 */ ENARROW_8, +}; + +typedef struct { + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[5]; +} EnArrowArrow; // size = 0x1A8 + +typedef struct { + /* 0x144 */ f32 unk_144; + /* 0x148 */ u8 unk_148; + /* 0x149 */ s8 unk_149; + /* 0x14A */ s16 unk_14A; + /* 0x14C */ s16 unk_14C; +} EnArrowBubble; // size = 0x150 + typedef struct EnArrow { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x7C]; - /* 0x01C0 */ s32 unk_1C0; - /* 0x01C4 */ char unk_1C4[0x9C]; - /* 0x0260 */ u8 unk_260; // timer in OoT - /* 0x0261 */ u8 unk_261; // hitFlags in OoT - /* 0x0262 */ char unk_262[0x12]; - /* 0x0274 */ EnArrowActionFunc actionFunc; + /* 0x000 */ Actor actor; + union { + EnArrowArrow arrow; + EnArrowBubble bubble; + }; + /* 0x1A8 */ ColliderQuad collider; + /* 0x228 */ Vec3f unk_228; + /* 0x234 */ Vec3f unk_234; + /* 0x240 */ s32 unk_240; + /* 0x244 */ s32 unk_244; + /* 0x248 */ f32 unk_248; + /* 0x24C */ f32 unk_24C; + /* 0x250 */ f32 unk_250; + /* 0x254 */ f32 unk_254; + /* 0x258 */ f32 unk_258; + /* 0x25C */ f32 unk_25C; + /* 0x260 */ u8 unk_260; // timer in OoT + /* 0x261 */ u8 unk_261; // hitFlags in OoT + /* 0x262 */ u8 unk_262; + /* 0x263 */ u8 unk_263; + /* 0x264 */ Actor* unk_264; + /* 0x268 */ Vec3f unk_268; + /* 0x274 */ EnArrowActionFunc actionFunc; } EnArrow; // size = 0x278 extern const ActorInit En_Arrow_InitVars; 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 5033a1dc0..3a15f845b 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -221,7 +221,7 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { (flameColliderHurtboxActor->id == ACTOR_EN_ARROW)) { flameColliderHurtboxActor->params = 0; - ((EnArrow*)flameColliderHurtboxActor)->unk_1C0 = 0x800; + ((EnArrow*)flameColliderHurtboxActor)->collider.info.toucher.dmgFlags = 0x800; } } if ((this->snuffTimer > OBJ_SYOKUDAI_SNUFF_NEVER) && diff --git a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h index 40c3d693c..ba2355d23 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h +++ b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h @@ -4,7 +4,10 @@ #include "global.h" typedef struct { - char unk_0[UNK_SIZE]; + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ CollisionPoly* unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ char unk_14[UNK_SIZE]; } EffectSsSbnInitParams; // size = ? extern const EffectSsInit Effect_Ss_Sbn_InitVars; From 66b309218c47aae6ac55f1eb3de2127b7ddf5bca Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 13 Feb 2022 23:24:26 +0000 Subject: [PATCH 004/257] Bg_Dblue_Movebg (#568) * Bg_Dblue_Movebg * UNK_TYPE1 * PR * Match Draw (thanks Anon58) * Match * data * PR --- include/functions.h | 4 +- spec | 4 +- .../ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c | 845 +++++++++++++++++- .../ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h | 47 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 2 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 2 +- src/overlays/actors/ovl_En_Fz/z_en_fz.c | 4 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 2 +- .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 2 +- src/overlays/actors/ovl_En_Ot/z_en_ot.c | 4 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 2 +- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 2 +- .../actors/ovl_Obj_Hunsui/z_obj_hunsui.h | 2 + undefined_syms.txt | 9 - 14 files changed, 878 insertions(+), 53 deletions(-) diff --git a/include/functions.h b/include/functions.h index 6abcd11ad..f71b4a5fa 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3669,8 +3669,8 @@ void func_8019F88C(Vec3f* arg0, u16 sfxId, UNK_TYPE arg2); // void func_8019F900(void); // void func_8019FA18(void); void func_8019FAD8(Vec3f* param_1, u16 sfxId, f32 param_3); -// void func_8019FB0C(void); -// void func_8019FC20(void); +void func_8019FB0C(Vec3f* arg0, u16 sfxId, f32 arg2, s32 arg3); +void func_8019FC20(Vec3f* pos, u16 sfxId); // void func_8019FCB8(void); // void func_8019FD90(void); void func_8019FDC8(UNK_PTR arg0, u16 sfxId, UNK_TYPE arg2); diff --git a/spec b/spec index 139f84845..5358cdd42 100644 --- a/spec +++ b/spec @@ -2706,9 +2706,7 @@ beginseg name "ovl_Bg_Dblue_Movebg" compress include "build/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.o" - include "build/data/ovl_Bg_Dblue_Movebg/ovl_Bg_Dblue_Movebg.data.o" - include "build/data/ovl_Bg_Dblue_Movebg/ovl_Bg_Dblue_Movebg.bss.o" - include "build/data/ovl_Bg_Dblue_Movebg/ovl_Bg_Dblue_Movebg.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Dblue_Movebg/ovl_Bg_Dblue_Movebg_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c index aa4a32581..b241ae6b9 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c @@ -5,8 +5,10 @@ */ #include "z_bg_dblue_movebg.h" +#include "objects/object_dblue_object/object_dblue_object.h" +#include "overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgDblueMovebg*)thisx) @@ -15,7 +17,33 @@ void BgDblueMovebg_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgDblueMovebg_Update(Actor* thisx, GlobalContext* globalCtx); void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A2A1E0(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2A32C(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2A444(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2A670(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2A688(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2A714(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2A7F8(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2AAB8(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2AED0(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2B1A0(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2B274(Actor* thisx, GlobalContext* globalCtx); +void func_80A2B308(Actor* thisx, GlobalContext* globalCtx); + +BgDblueMovebg* D_80A2BBF0; + +typedef struct { + u8 unk_00; + u8 unk_01; +} BgDblueMovebgUnkStruct; + +BgDblueMovebgUnkStruct D_80A2BBF4; + +u8 D_80A2B870[][2] = { + { 0x01, 0x01 }, { 0x01, 0x00 }, { 0x02, 0x03 }, { 0x02, 0x01 }, { 0x02, 0x02 }, { 0x02, 0x00 }, { 0x03, 0x07 }, + { 0x03, 0x03 }, { 0x03, 0x05 }, { 0x03, 0x01 }, { 0x03, 0x06 }, { 0x03, 0x02 }, { 0x03, 0x04 }, { 0x03, 0x00 }, +}; + const ActorInit Bg_Dblue_Movebg_InitVars = { ACTOR_BG_DBLUE_MOVEBG, ACTORCAT_BG, @@ -28,46 +56,813 @@ const ActorInit Bg_Dblue_Movebg_InitVars = { (ActorFunc)BgDblueMovebg_Draw, }; -#endif +Gfx* D_80A2B8AC[] = { + NULL, + object_dblue_object_DL_0069D8, + NULL, + NULL, + NULL, + NULL, + object_dblue_object_DL_004848, + object_dblue_object_DL_0061B8, + NULL, + NULL, + NULL, + NULL, +}; -extern UNK_TYPE D_06004848; -extern UNK_TYPE D_060052B8; -extern UNK_TYPE D_06008778; +Gfx* D_80A2B8DC[] = { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, object_dblue_object_DL_00CAA0, NULL, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A29A80.s") +CollisionHeader* D_80A2B90C[] = { + NULL, + &object_dblue_object_Colheader_006EA8, + NULL, + NULL, + NULL, + &object_dblue_object_Colheader_00D3DC, + &object_dblue_object_Colheader_005D28, + &object_dblue_object_Colheader_00714C, + &object_dblue_object_Colheader_00AED0, + &object_dblue_object_Colheader_00AED0, + NULL, + NULL, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/BgDblueMovebg_Init.s") +AnimatedMaterial* D_80A2B93C[] = { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, object_dblue_object_Matanimheader_00CC18, NULL, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/BgDblueMovebg_Destroy.s") +s16 D_80A2B96C[] = { 0, 0x16C, -0x16C, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A128.s") +s16 D_80A2B974[] = { -1, -1 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A1E0.s") +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A32C.s") +Vec3f D_80A2B988 = { 1785.0f, 0.0f, 220.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A444.s") +s32 func_80A29A80(GlobalContext* globalCtx, s32 arg1, s32 arg2) { + s32 sp2C = 1; + s32 val; + s32 val2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A670.s") + if (arg2 < 14) { + val = D_80A2B870[arg2][0]; + val2 = D_80A2B870[arg2][1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A688.s") + while (val--) { + if ((1 << val) & val2) { + if (!Flags_GetSwitch(globalCtx, arg1 + val)) { + sp2C = 0; + break; + } + } else if (Flags_GetSwitch(globalCtx, arg1 + val)) { + sp2C = 0; + break; + } + } + } else { + sp2C = 0; + switch (arg2) { + case 14: + if (!Flags_GetSwitch(globalCtx, arg1)) { + sp2C = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A714.s") + if (Flags_GetSwitch(globalCtx, arg1 + 1) && Flags_GetSwitch(globalCtx, arg1 + 2) && + Flags_GetSwitch(globalCtx, arg1 + 3)) { + sp2C += 2; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A7F8.s") + case 15: + if (!Flags_GetSwitch(globalCtx, arg1) || + (Flags_GetSwitch(globalCtx, arg1 + 1) && Flags_GetSwitch(globalCtx, arg1 + 2) && + Flags_GetSwitch(globalCtx, arg1 + 3))) { + sp2C = 1; + } + break; + } + } + return sp2C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2AAB8.s") +void BgDblueMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueMovebg* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2ABD0.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->unk_160 = BGDBLUEMOVEBG_GET_F(thisx); + this->unk_1BC = BGDBLUEMOVEBG_GET_F000(thisx); + this->unk_1C0 = BGDBLUEMOVEBG_GET_FF0(thisx); + DynaPolyActor_Init(&this->dyna, 1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2AED0.s") + if ((this->unk_160 == 9) || (this->unk_160 == 8)) { + if (D_80A2BBF4.unk_00 != 0) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + this->unk_170 = this->dyna.actor.room; + this->dyna.actor.room = -1; + D_80A2BBF4.unk_00 = 1; + this->unk_171 = this->dyna.actor.world.rot.z; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.z = 0; + } else if (this->unk_160 == 6) { + if (D_80A2BBF4.unk_01 != 0) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + this->unk_171 = this->dyna.actor.world.rot.z; + this->unk_170 = this->dyna.actor.room; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.room = -1; + D_80A2BBF4.unk_01 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2B1A0.s") + if (D_80A2B90C[this->unk_160] != NULL) { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_80A2B90C[this->unk_160]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/BgDblueMovebg_Update.s") + this->unk_164 = D_80A2B8AC[this->unk_160]; + this->unk_168 = D_80A2B8DC[this->unk_160]; + this->unk_16C = D_80A2B93C[this->unk_160]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2B274.s") + func_8013E3B8(&this->dyna.actor, this->unk_1B6, ARRAY_COUNT(this->unk_1B6)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2B308.s") + switch (this->unk_160) { + case 1: + this->unk_1C4 = this->dyna.actor.world.rot.x; + this->unk_1C8 = this->dyna.actor.world.rot.z; + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.z = 0; + if (func_80A29A80(globalCtx, this->unk_1C8, this->unk_1C4)) { + this->unk_172 |= 1; + } else { + this->unk_172 &= ~1; + } + this->unk_17E = 0; + this->unk_184 = 0.0f; + if (Flags_GetSwitch(globalCtx, this->unk_1C0)) { + this->unk_18C = 0x384; + } else { + this->unk_18C = 0; + } + this->dyna.actor.shape.rot.y += (s16)((this->unk_18C / 10.0f) * (0x10000 / 360.0f)); + this->actionFunc = func_80A2A714; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/BgDblueMovebg_Draw.s") + case 6: + this->unk_178 = func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC); + this->unk_1CC = D_80A2B96C[this->unk_178]; + this->unk_1CE = this->unk_1CC; + this->actionFunc = func_80A2A1E0; + break; + + case 7: + this->unk_1C4 = this->dyna.actor.world.rot.x; + this->unk_1C8 = this->dyna.actor.world.rot.z; + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.z = 0; + if (Flags_GetSwitch(globalCtx, this->unk_1C0)) { + Actor_MarkForDeath(&this->dyna.actor); + break; + } + this->unk_18C = 0; + this->dyna.actor.draw = func_80A2B308; + this->unk_17E = 0; + this->unk_184 = 0.0f; + this->dyna.actor.shape.rot.y += (s16)((this->unk_18C / 10.0f) * (0x10000 / 360.0f)); + this->actionFunc = func_80A2A32C; + break; + + case 8: + case 9: + this->unk_2F8[1] = NULL; + this->unk_2F8[0] = NULL; + label: + for (i = 0; i < ARRAY_COUNT(D_80A2B974); i++) { + D_80A2B974[i] = this->unk_1B6[i]; + } + this->unk_178 = func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC); + this->unk_1CC = D_80A2B96C[this->unk_178]; + this->unk_1CE = this->unk_1CC; + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledX(2240.0f, &this->unk_190); + Matrix_GetStateTranslationAndScaledX(-10.0f, &this->unk_19C); + Math_Vec3f_Sum(&this->unk_190, &this->dyna.actor.world.pos, &this->unk_190); + Math_Vec3f_Sum(&this->unk_19C, &this->dyna.actor.world.pos, &this->unk_19C); + D_80A2BBF0 = this; + this->dyna.actor.flags |= ACTOR_FLAG_20; + this->actionFunc = func_80A2AED0; + break; + + case 10: + this->actionFunc = func_80A2B1A0; + break; + + case 11: + this->unk_1CC = D_80A2B96C[func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC)]; + D_80A2BBF0 = this; + this->dyna.actor.flags |= ACTOR_FLAG_20; + this->dyna.actor.update = Actor_Noop; + this->dyna.actor.draw = func_80A2B274; + break; + } +} + +void BgDblueMovebg_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgDblueMovebg* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if ((this->unk_160 == 9) || (this->unk_160 == 8)) { + Audio_StopSfxByPos(&this->unk_1A8); + } +} + +void func_80A2A128(BgDblueMovebg* this, GlobalContext* globalCtx) { + Actor* phi_s0 = NULL; + + while (true) { + phi_s0 = SubS_FindActor(globalCtx, phi_s0, ACTORCAT_BG, ACTOR_OBJ_HUNSUI); + if (phi_s0 != NULL) { + if ((OBJHUNSUI_GET_F000(phi_s0) == 5) && (phi_s0->update != NULL)) { + this->unk_2F8[1] = phi_s0; + } else if ((OBJHUNSUI_GET_F000(phi_s0) == 6) && (phi_s0->update != NULL)) { + this->unk_2F8[0] = phi_s0; + } + phi_s0 = phi_s0->next; + } + + if (phi_s0 == NULL) { + break; + } + } +} + +void func_80A2A1E0(BgDblueMovebg* this, GlobalContext* globalCtx) { + s32 temp_v0 = func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC); + + if (temp_v0 != this->unk_178) { + switch (temp_v0) { + case 1: + case 2: + this->unk_17E = 40; + break; + + case 0: + case 3: + this->unk_17E = 15; + break; + } + } + this->unk_178 = temp_v0; + + if (this->unk_17E <= 0) { + this->unk_1CE = D_80A2B96C[temp_v0]; + } else { + this->unk_17E--; + } + + Math_StepToS(&this->unk_1CC, this->unk_1CE, 12); + this->dyna.actor.shape.rot.y += this->unk_1CC; + + if (globalCtx->roomCtx.currRoom.num == 0) { + this->unk_164 = object_dblue_object_DL_004848; + } else if (globalCtx->roomCtx.currRoom.num == 8) { + this->unk_164 = NULL; + } + + if (globalCtx->roomCtx.currRoom.num != this->unk_170) { + if (globalCtx->roomCtx.currRoom.num != this->unk_171) { + if ((globalCtx->roomCtx.prevRoom.num != this->unk_170) && + (globalCtx->roomCtx.prevRoom.num != this->unk_171)) { + D_80A2BBF4.unk_01 = 0; + Actor_MarkForDeath(&this->dyna.actor); + } + } + } +} + +void func_80A2A32C(BgDblueMovebg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 phi_v0; + f32 phi_f0; + s32 phi_v1; + + if (this->dyna.pushForce != 0.0f) { + this->unk_18E = BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.yawTowardsPlayer); + this->unk_184 = this->dyna.actor.xzDistToPlayer; + + if (this->dyna.pushForce >= 0.0f) { + phi_f0 = 1.0f; + } else { + phi_f0 = -1.0f; + } + + if (BINANG_SUB(this->dyna.actor.yawTowardsPlayer, player->actor.shape.rot.y) > 0) { + phi_v0 = -1; + } else { + phi_v0 = 1; + } + this->unk_17E = phi_v0 * phi_f0; + + phi_v1 = false; + if (this->unk_17E > 0) { + phi_v1 = true; + } + + if (phi_v1) { + this->unk_180 = func_800F2178(this->unk_1B6[0]); + this->unk_1D2 = this->unk_1B6[0]; + this->unk_172 |= 8; + this->actionFunc = func_80A2A444; + } else { + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } + } +} + +void func_80A2A444(BgDblueMovebg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp20; + Player* temp_a3; + s16 temp_v0; + + this->unk_188++; + this->unk_188 = CLAMP_MAX(this->unk_188, 5); + + sp20 = Math_StepToS(&this->unk_18A, 900, this->unk_188); + temp_v0 = this->unk_18A * this->unk_17E; + this->dyna.actor.shape.rot.y = + (s32)((this->unk_18C + temp_v0) * 0.1f * (0x10000 / 360.0f)) + this->dyna.actor.home.rot.y; + + if ((player->stateFlags2 & 0x10) && (this->unk_184 > 0.0f)) { + player->actor.world.pos.x = + (Math_SinS(this->dyna.actor.shape.rot.y - this->unk_18E) * this->unk_184) + this->dyna.actor.home.pos.x; + player->actor.world.pos.z = + (Math_CosS(this->dyna.actor.shape.rot.y - this->unk_18E) * this->unk_184) + this->dyna.actor.home.pos.z; + } else { + this->unk_184 = 0.0f; + } + + if (sp20) { + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + Flags_SetSwitch(globalCtx, this->unk_1C0); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + + if (func_80A29A80(globalCtx, this->unk_1C8, this->unk_1C4)) { + this->unk_172 |= 1; + } else { + this->unk_172 &= ~1; + } + + if (!(this->unk_174 & 1) && (this->unk_172 & 1)) { + func_801000CC(NA_SE_EV_PIPE_STREAM_START); + } + func_80A2A670(this, globalCtx); + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_COCK_SWITCH_ROLL - SFX_FLAG); + } +} + +void func_80A2A670(BgDblueMovebg* this, GlobalContext* globalCtx) { + this->actionFunc = func_80A2A688; +} + +void func_80A2A688(BgDblueMovebg* this, GlobalContext* globalCtx) { + this->unk_180--; + if (this->unk_180 <= 0) { + ActorCutscene_Stop(this->unk_1B6[0]); + } + + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 60.0f, 2.0f) && + (this->unk_180 <= 0)) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void func_80A2A714(BgDblueMovebg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 phi_v0; + f32 phi_f0; + + if (this->dyna.pushForce != 0.0f) { + this->unk_18E = BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.yawTowardsPlayer); + this->unk_184 = this->dyna.actor.xzDistToPlayer; + if (this->dyna.pushForce >= 0.0f) { + phi_f0 = 1.0f; + } else { + phi_f0 = -1.0f; + } + + if (BINANG_SUB(this->dyna.actor.yawTowardsPlayer, player->actor.shape.rot.y) > 0) { + phi_v0 = -1; + } else { + phi_v0 = 1; + } + this->unk_17E = phi_v0 * phi_f0; + + this->unk_180 = func_800F2178(this->unk_1B6[0]); + this->unk_1D2 = this->unk_1B6[0]; + this->unk_172 |= 8; + this->actionFunc = func_80A2A7F8; + } +} + +void func_80A2A7F8(BgDblueMovebg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp28; + s16 sp26; + s32 temp; + + this->unk_188++; + this->unk_188 = CLAMP_MAX(this->unk_188, 5); + + sp28 = Math_StepToS(&this->unk_18A, 900, this->unk_188); + sp26 = this->unk_18A * this->unk_17E; + this->dyna.actor.shape.rot.y = + (s32)((this->unk_18C + sp26) * 0.1f * (0x10000 / 360.0f)) + this->dyna.actor.home.rot.y; + + if ((player->stateFlags2 & 0x10) && (this->unk_184 > 0.0f)) { + player->actor.world.pos.x = + (Math_SinS(this->dyna.actor.shape.rot.y - this->unk_18E) * this->unk_184) + this->dyna.actor.home.pos.x; + player->actor.world.pos.z = + (Math_CosS(this->dyna.actor.shape.rot.y - this->unk_18E) * this->unk_184) + this->dyna.actor.home.pos.z; + } else { + this->unk_184 = 0.0f; + } + + if (sp28) { + temp = (this->unk_18C + sp26 + 3600) % 3600; + + if ((temp == 900) || (temp == 2700)) { + Flags_SetSwitch(globalCtx, this->unk_1C0); + } else { + Flags_UnsetSwitch(globalCtx, this->unk_1C0); + } + + player->stateFlags1 |= 0x20; + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + + this->unk_18C = (this->unk_18C + sp26 + 3600) % 3600; + this->unk_188 = 0; + this->unk_18A = 0; + this->unk_17E = 0; + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + + if (func_80A29A80(globalCtx, this->unk_1C8, this->unk_1C4)) { + this->unk_172 |= 1; + } else { + this->unk_172 &= ~1; + } + + if (!(this->unk_174 & 1) && (this->unk_172 & 1)) { + func_801000CC(NA_SE_EV_PIPE_STREAM_START); + } + + this->unk_174 = this->unk_172; + this->unk_1D0 = 17; + this->actionFunc = func_80A2AAB8; + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_COCK_SWITCH_ROLL - SFX_FLAG); + } +} + +void func_80A2AAB8(BgDblueMovebg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp18; + + if (this->unk_180-- <= 0) { + ActorCutscene_Stop(this->unk_1B6[0]); + } + + sp18 = false; + if ((this->unk_1D0 > 0) && ((D_80A2B974[0] >= 0) || (D_80A2B974[1] >= 0))) { + if (ActorCutscene_GetCurrentIndex() != -1) { + sp18 = true; + } + } + + if (!sp18 && (this->unk_180 <= 0)) { + this->unk_1D0--; + + if (this->unk_1D0 == 1) { + this->dyna.pushForce = 0.0f; + player->stateFlags1 |= 0x20; + player->stateFlags2 &= ~0x10; + } + + if (this->unk_1D0 <= 0) { + player->stateFlags1 &= ~0x20; + this->actionFunc = func_80A2A714; + } + } +} + +void func_80A2ABD0(BgDblueMovebg* this, GlobalContext* globalCtx) { + Vec3f spAC; + f32 temp_f0; + f32 temp_f20; + s32 phi_v0; + s32 i; + s32 j; + + for (i = 0; i < ARRAY_COUNT(this->unk_2F8); i++) { + if (this->unk_2F8[i] == NULL) { + func_80A2A128(this, globalCtx); + continue; + } + + for (j = 0; j < ARRAY_COUNT(this->unk_1D8[0]); j++) { + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x + (j * 0x2000), MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&D_80A2B988, &spAC); + Math_Vec3f_Sum(&this->dyna.actor.world.pos, &spAC, &spAC); + Math_Vec3f_Copy(&this->unk_238[i][j], &spAC); + temp_f20 = spAC.y - this->unk_2F8[i]->world.pos.y; + temp_f0 = Math_Vec3f_DistXZ(&this->unk_2F8[i]->world.pos, &spAC); + + if ((this->unk_300[i][j] != 0) && (temp_f20 <= 12.0f) && (temp_f20 >= 0.0f) && (temp_f0 <= 60.0f)) { + phi_v0 = 1; + } else { + phi_v0 = 1; + phi_v0 = (s64)phi_v0; + if (((temp_f20 >= 0.0f) && ((temp_f20 > 0.0f) || (temp_f0 > 60.f))) || + ((temp_f20 < 0.0f) && ((temp_f20 < -150.0f) || (temp_f0 > 40.0f)))) { + phi_v0 = 0; + } + } + + if (phi_v0) { + this->unk_300[i][j] = i + 1; + Math_StepToF(&this->unk_1F8[i][j], 1.0f, 0.2f); + Math_StepToS(&this->unk_1D8[i][j], 255, 20); + } else { + this->unk_300[i][j] = 0; + Math_StepToF(&this->unk_1F8[i][j], 0.0f, 0.01f); + Math_StepToS(&this->unk_1D8[i][j], 0, 20); + } + } + } +} + +void func_80A2AED0(BgDblueMovebg* this, GlobalContext* globalCtx) { + s32 pad; + s32 temp_v0_3; + + if (globalCtx->roomCtx.currRoom.num != this->unk_170) { + if (globalCtx->roomCtx.currRoom.num != this->unk_171) { + if ((globalCtx->roomCtx.prevRoom.num != this->unk_170) && + (globalCtx->roomCtx.prevRoom.num != this->unk_171)) { + D_80A2BBF4.unk_00 = 0; + Actor_MarkForDeath(&this->dyna.actor); + return; + } + } + } + + temp_v0_3 = func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC); + if (temp_v0_3 != this->unk_178) { + switch (temp_v0_3) { + case 1: + case 2: + this->unk_1D2 = this->unk_1B6[0]; + this->unk_17E = 40; + break; + + case 0: + case 3: + this->unk_1D2 = this->unk_1B6[1]; + this->unk_17E = 15; + break; + } + this->unk_172 |= 8; + } + this->unk_178 = temp_v0_3; + + if (!(this->unk_172 & 8)) { + if (this->unk_17E <= 0) { + this->unk_1CE = D_80A2B96C[temp_v0_3]; + } else { + this->unk_17E--; + } + } + + Math_StepToS(&this->unk_1CC, this->unk_1CE, 12); + this->dyna.actor.shape.rot.x += this->unk_1CC; + + if (this->unk_160 == 8) { + if (globalCtx->roomCtx.currRoom.num == 8) { + func_80A2ABD0(this, globalCtx); + this->unk_172 |= 0x20; + } else { + this->unk_172 &= ~0x20; + } + } + + if (globalCtx->roomCtx.currRoom.num == 0) { + this->unk_164 = object_dblue_object_DL_008778; + } else if (globalCtx->roomCtx.currRoom.num == 8) { + this->unk_164 = object_dblue_object_DL_00A528; + } + + if (this == D_80A2BBF0) { + Vec3f sp54; + f32 sp50; + + if (Math3D_PointDistToLine2D(globalCtx->view.eye.x, globalCtx->view.eye.z, this->unk_190.x, this->unk_190.z, + this->unk_19C.x, this->unk_19C.z, &sp54.x, &sp54.z, &sp50)) { + sp54.y = this->dyna.actor.world.pos.y; + } else { + if (Math_Vec3f_DistXYZ(&globalCtx->view.eye, &this->unk_190) <= + Math_Vec3f_DistXYZ(&globalCtx->view.eye, &this->unk_19C)) { + Math_Vec3f_Copy(&sp54, &this->unk_190); + } else { + Math_Vec3f_Copy(&sp54, &this->unk_19C); + } + } + + SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &sp54, &this->unk_1A8); + this->unk_1D4 = ABS(this->unk_1CC) / 364.0f; + } +} + +void func_80A2B1A0(BgDblueMovebg* this, GlobalContext* globalCtx) { + switch (func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC)) { + case 1: + this->dyna.actor.shape.rot.z = this->dyna.actor.home.rot.z; + break; + + case 2: + this->dyna.actor.shape.rot.z = BINANG_ROT180(this->dyna.actor.home.rot.z); + break; + } +} + +void BgDblueMovebg_Update(Actor* thisx, GlobalContext* globalCtx) { + BgDblueMovebg* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->unk_172 & 8) { + if (func_8013E2D4(&this->dyna.actor, this->unk_1D2, -1, 0)) { + this->unk_172 &= ~8; + } + } +} + +void func_80A2B274(Actor* thisx, GlobalContext* globalCtx) { + BgDblueMovebg* this = THIS; + s16 temp_v1; + + if (this != D_80A2BBF0) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + temp_v1 = D_80A2B96C[func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC)]; + if (temp_v1 != 0) { + if (temp_v1 > 0) { + func_8019FC20(&this->dyna.actor.projectedPos, NA_SE_EV_DUMMY_WATER_WHEEL_RR - SFX_FLAG); + } else { + func_8019FC20(&this->dyna.actor.projectedPos, NA_SE_EV_DUMMY_WATER_WHEEL_LR - SFX_FLAG); + } + } +} + +void func_80A2B308(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueMovebg* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->unk_164); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BgDblueMovebg* this = THIS; + s32 i; + s32 j; + Gfx* gfx; + Gfx* gfx2; + + Matrix_StatePush(); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((this->unk_160 == 9) || (this->unk_160 == 8) || (this->dyna.actor.flags & ACTOR_FLAG_40)) { + if (this->unk_16C != NULL) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(this->unk_16C)); + } + + if ((this->unk_164 != 0) || (this->unk_160 == 6)) { + gfx2 = Gfx_CallSetupDL(POLY_OPA_DISP, 0x19); + + gSPMatrix(&gfx2[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->unk_160 == 6) { + gSPDisplayList(&gfx2[1], object_dblue_object_DL_0052B8); + if (this->unk_164 != 0) { + gSPDisplayList(&gfx2[2], this->unk_164); + POLY_OPA_DISP = &gfx2[3]; + } else { + POLY_OPA_DISP = &gfx2[2]; + } + } else { + gSPDisplayList(&gfx2[1], this->unk_164); + POLY_OPA_DISP = &gfx2[2]; + } + } + + if (this->unk_168 != NULL) { + gfx = func_8012C2B4(POLY_XLU_DISP); + + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], this->unk_168); + + POLY_XLU_DISP = &gfx[2]; + } + } + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if ((this->unk_160 == 8) && (this->unk_172 & 0x20)) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_dblue_object_Matanimheader_00CE00)); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + gfx = func_8012C2B4(POLY_XLU_DISP); + + for (i = 0; i < ARRAY_COUNT(this->unk_1D8[0]); i++) { + for (j = 0; j < ARRAY_COUNT(this->unk_1D8); j++) { + if (this->unk_1D8[j][i] > 0) { + if (this->unk_1F8[j][i] > 0.1f) { + gSPSegment( + gfx++, 0x09, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, + (s32)(((globalCtx->gameplayFrames % 128) * -9.0f) / this->unk_1F8[j][i]), + 0x20, 0x20, 1, 0, 0, 0x20, 0x20)); + } + Matrix_StatePush(); + Matrix_InsertXRotation_s(i * 0x2000, MTXMODE_APPLY); + Matrix_InsertTranslation(1785.0f, 0.0f, 270.0f, MTXMODE_APPLY); + if (j != 0) { + Matrix_InsertZRotation_s(-0x8000, MTXMODE_APPLY); + } + Matrix_Scale(this->unk_1F8[j][i] * this->dyna.actor.scale.x, + this->unk_1F8[j][i] * this->dyna.actor.scale.y, + this->unk_1F8[j][i] * this->dyna.actor.scale.z, MTXMODE_APPLY); + + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetEnvColor(gfx++, 255, 255, 255, this->unk_1D8[j][i]); + gSPDisplayList(gfx++, object_dblue_object_DL_00CD10); + + Matrix_StatePop(); + } + } + } + POLY_XLU_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if ((this->unk_160 == 9) || (this->unk_160 == 8)) { + if (this->unk_1CC >= 0) { + func_8019FB0C(&this->unk_1A8, NA_SE_EV_BIG_WATER_WHEEL_RR - SFX_FLAG, this->unk_1D4, 32); + } else { + func_8019FB0C(&this->unk_1A8, NA_SE_EV_BIG_WATER_WHEEL_LR - SFX_FLAG, this->unk_1D4, 32); + } + } +} diff --git a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h index aeef09c87..01d11886a 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h +++ b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h @@ -7,11 +7,50 @@ struct BgDblueMovebg; typedef void (*BgDblueMovebgActionFunc)(struct BgDblueMovebg*, GlobalContext*); +#define BGDBLUEMOVEBG_GET_F(thisx) ((thisx)->params & 0xF) +#define BGDBLUEMOVEBG_GET_FF0(thisx) (((thisx)->params >> 4) & 0xFF) +#define BGDBLUEMOVEBG_GET_F000(thisx) (((thisx)->params >> 0xC) & 0xF) + typedef struct BgDblueMovebg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgDblueMovebgActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x210]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgDblueMovebgActionFunc actionFunc; + /* 0x160 */ s32 unk_160; + /* 0x164 */ Gfx* unk_164; + /* 0x168 */ Gfx* unk_168; + /* 0x16C */ TexturePtr unk_16C; + /* 0x170 */ s8 unk_170; + /* 0x171 */ s8 unk_171; + /* 0x172 */ u16 unk_172; + /* 0x174 */ u16 unk_174; + /* 0x178 */ s32 unk_178; + /* 0x17C */ UNK_TYPE1 unk17C[2]; + /* 0x17E */ s16 unk_17E; + /* 0x180 */ s16 unk_180; + /* 0x184 */ f32 unk_184; + /* 0x188 */ s16 unk_188; + /* 0x18A */ s16 unk_18A; + /* 0x18C */ s16 unk_18C; + /* 0x18E */ s16 unk_18E; + /* 0x190 */ Vec3f unk_190; + /* 0x19C */ Vec3f unk_19C; + /* 0x1A8 */ Vec3f unk_1A8; + /* 0x1B4 */ UNK_TYPE1 unk1B4[2]; + /* 0x1B6 */ s16 unk_1B6[2]; + /* 0x1BC */ s32 unk_1BC; + /* 0x1C0 */ s32 unk_1C0; + /* 0x1C4 */ s32 unk_1C4; + /* 0x1C8 */ s32 unk_1C8; + /* 0x1CC */ s16 unk_1CC; + /* 0x1CE */ s16 unk_1CE; + /* 0x1D0 */ s16 unk_1D0; + /* 0x1D2 */ s16 unk_1D2; + /* 0x1D4 */ f32 unk_1D4; + /* 0x1D8 */ s16 unk_1D8[2][8]; + /* 0x1F8 */ f32 unk_1F8[2][8]; + /* 0x238 */ Vec3f unk_238[2][8]; + /* 0x2F8 */ Actor* unk_2F8[2]; + /* 0x300 */ u8 unk_300[2][8]; + /* 0x310 */ UNK_TYPE1 unk310[0x60]; } BgDblueMovebg; // size = 0x370 extern const ActorInit Bg_Dblue_Movebg_InitVars; diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index 245095bc0..7323a8630 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -1621,7 +1621,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, effect->unk_26 + (i * 3), (effect->unk_26 + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, 0); + Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index 06dc70beb..ad55a9df7 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -2946,7 +2946,7 @@ void EnBigslime_DrawMinislime(EnBigslime* this, GlobalContext* globalCtx2) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, &gMinislimeNormalDL); if (minislime->frozenAlpha > 0) { - Matrix_InsertTranslation(0.0f, (0.1f - minislime->frozenScale) * -4000.0f, 0.0f, 1); + Matrix_InsertTranslation(0.0f, (0.1f - minislime->frozenScale) * -4000.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(0.1f, minislime->frozenScale, 0.1f, MTXMODE_APPLY); AnimatedMat_Draw(globalCtx, this->minislimeFrozenTexAnim); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, minislime->frozenAlpha); diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.c b/src/overlays/actors/ovl_En_Fz/z_en_fz.c index 1efcd42e7..be2382ef0 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -619,7 +619,7 @@ void func_809334B8(EnFz* this, GlobalContext* globalCtx) { sp58.y = this->actor.world.pos.y + 20.0f; sp58.z = this->actor.world.pos.z; - Matrix_RotateY(this->actor.shape.rot.y, 0); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); sp64.x = 0.0f; sp64.y = -2.0f; @@ -736,7 +736,7 @@ void func_809338E0(EnFz* this, GlobalContext* globalCtx) { sp58.y = this->actor.world.pos.y + 20.0f; sp58.z = this->actor.world.pos.z; - Matrix_RotateY(this->actor.shape.rot.y, 0); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); sp64.x = 0.0f; sp64.y = -2.0f; 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 4f7145ceb..b3a84c672 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -786,7 +786,7 @@ void func_8094F3D0(EnGm* this, GlobalContext* globalCtx) { this->unk_3AC = 0.0f; } Math_SmoothStepToF(&this->unk_3B0, this->unk_3AC, 0.8f, 40.0f, 10.0f); - Matrix_InsertTranslation(this->unk_3B0, 0.0f, 0.0f, 1); + Matrix_InsertTranslation(this->unk_3B0, 0.0f, 0.0f, MTXMODE_APPLY); this->unk_3F0 = sp28; } 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 8905b116c..3d046f073 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -1358,7 +1358,7 @@ void func_8094220C(EnGoroiwa* this, GlobalContext* globalCtx) { ptr->unk_18 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &ptr->unk_28, &spD0, &this->actor, &spC4); if (ptr->unk_10 <= 0.0f) { - Matrix_InsertRotation(ptr->unk_1C, ptr->unk_1E, ptr->unk_20, 0); + Matrix_InsertRotation(ptr->unk_1C, ptr->unk_1E, ptr->unk_20, MTXMODE_NEW); Matrix_MultiplyVector3fByState(&D_80942E6C, &spB8); temp_f20 = this->unk_1DC * 0.9f; diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index ecaae682a..83538be6d 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -437,7 +437,7 @@ void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx) { Vec3f sp38; this->unk_3A0 += 0x2D8; - Matrix_RotateY(this->unk_3A0, 0); + Matrix_RotateY(this->unk_3A0, MTXMODE_NEW); Matrix_GetStateTranslationAndScaledZ(26.259998f, &sp5C); Matrix_GetStateTranslationAndScaledZ(-26.259998f, &sp50); this->unk_348.x = this->unk_394.x + sp5C.x; @@ -461,7 +461,7 @@ void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 12.0f)) { - Matrix_RotateY(func_800DFCDC(GET_ACTIVE_CAM(globalCtx)), 0); + Matrix_RotateY(func_800DFCDC(GET_ACTIVE_CAM(globalCtx)), MTXMODE_NEW); sp38.x = 1.0f; sp38.y = 8.1f; sp38.z = 0.0f; diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c index e4456636b..0849e8cec 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -683,7 +683,7 @@ void EnPametfrog_WallPause(EnPametfrog* this, GlobalContext* globalCtx) { } else { SkelAnime_Update(&this->skelAnime); this->timer--; - Matrix_InsertRotationAroundUnitVector_f(this->wallRotation, &this->unk_2DC, 0); + Matrix_InsertRotationAroundUnitVector_f(this->wallRotation, &this->unk_2DC, MTXMODE_NEW); Matrix_MultiplyVector3fByState(&this->unk_2D0, &vec); Math_Vec3f_Copy(&this->unk_2D0, &vec); Math3D_CrossProduct(&this->unk_2DC, &this->unk_2D0, &this->unk_2E8); diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 392fe62bc..bc863b9d0 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -275,7 +275,7 @@ void func_808D90F0(EnSw* this, s32 arg1, s16 arg2) { temp = arg2; } - Matrix_InsertRotationAroundUnitVector_f(BINANG_TO_RAD(temp), &this->unk_368, 0); + Matrix_InsertRotationAroundUnitVector_f(BINANG_TO_RAD(temp), &this->unk_368, MTXMODE_NEW); Matrix_MultiplyVector3fByState(&this->unk_350, &sp2C); Math_Vec3f_Copy(&this->unk_350, &sp2C); Math3D_CrossProduct(&this->unk_368, &this->unk_350, &this->unk_35C); diff --git a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h index e4bacf821..c71a8a3d1 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h @@ -7,6 +7,8 @@ struct ObjHunsui; typedef void (*ObjHunsuiActionFunc)(struct ObjHunsui*, GlobalContext*); +#define OBJHUNSUI_GET_F000(thisx) (((thisx)->params >> 0xC) & 0xF) + typedef struct ObjHunsui { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_144[0x18]; diff --git a/undefined_syms.txt b/undefined_syms.txt index ecc7f4d93..b9e2c4c15 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -603,15 +603,6 @@ D_0600D250 = 0x0600D250; D_060002C8 = 0x060002C8; D_060005C4 = 0x060005C4; -// ovl_Bg_Dblue_Movebg - -D_06004848 = 0x06004848; -D_060052B8 = 0x060052B8; -D_06008778 = 0x06008778; -D_0600A528 = 0x0600A528; -D_0600CD10 = 0x0600CD10; -D_0600CE00 = 0x0600CE00; - // ovl_Bg_Dblue_Waterfall D_06003250 = 0x06003250; From 5fe04d87e0ca0e185ddc369ea3622b4ee09ab170 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 13 Feb 2022 23:39:10 +0000 Subject: [PATCH 005/257] Bg_Ikana_Rotaryroom (#573) * Bg_Ikana_Rotaryroom * Merge * Merge * PR * PR --- spec | 3 +- .../ovl_Bg_Ikana_Block/z_bg_ikana_block.h | 7 +- .../z_bg_ikana_rotaryroom.c | 977 +++++++++++++++++- .../z_bg_ikana_rotaryroom.h | 41 +- undefined_syms.txt | 8 - 5 files changed, 966 insertions(+), 70 deletions(-) diff --git a/spec b/spec index 5358cdd42..b5d694934 100644 --- a/spec +++ b/spec @@ -4308,8 +4308,7 @@ beginseg name "ovl_Bg_Ikana_Rotaryroom" compress include "build/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.o" - include "build/data/ovl_Bg_Ikana_Rotaryroom/ovl_Bg_Ikana_Rotaryroom.data.o" - include "build/data/ovl_Bg_Ikana_Rotaryroom/ovl_Bg_Ikana_Rotaryroom.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/ovl_Bg_Ikana_Rotaryroom_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h index 48e65613f..112e4ad00 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h @@ -11,7 +11,12 @@ typedef struct BgIkanaBlock { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_144[0x1C]; /* 0x0160 */ BgIkanaBlockActionFunc actionFunc; - /* 0x0164 */ char unk_164[0x1C]; + /* 0x0164 */ char unk_164[0xC]; + /* 0x0170 */ f32 unk_170; + /* 0x0174 */ char unk_174[0x8]; + /* 0x017C */ u8 unk_17C; + /* 0x017D */ char unk_17D[0x1]; + /* 0x017E */ u8 unk_17E; } BgIkanaBlock; // size = 0x180 extern const ActorInit Bg_Ikana_Block_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c index f4263f783..13d8161e2 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c @@ -5,8 +5,11 @@ */ #include "z_bg_ikana_rotaryroom.h" +#include "overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h" +#include "overlays/actors/ovl_En_Torch2/z_en_torch2.h" +#include "objects/object_ikana_obj/object_ikana_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgIkanaRotaryroom*)thisx) @@ -16,8 +19,19 @@ void BgIkanaRotaryroom_Update(Actor* thisx, GlobalContext* globalCtx); void BgIkanaRotaryroom_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80B814B8(BgIkanaRotaryroom* this, GlobalContext* globalCtx); +void func_80B818B4(BgIkanaRotaryroom* this); +void func_80B818C8(Actor* thisx, GlobalContext* globalCtx); +void func_80B81978(BgIkanaRotaryroom* this); +void func_80B8198C(Actor* thisx, GlobalContext* globalCtx); +void func_80B819DC(BgIkanaRotaryroom* this); +void func_80B819F0(Actor* thisx, GlobalContext* globalCtx); +void func_80B81A64(BgIkanaRotaryroom* this); +void func_80B81A80(Actor* thisx, GlobalContext* globalCtx); +void func_80B81B84(BgIkanaRotaryroom* this); +void func_80B81BA0(Actor* thisx, GlobalContext* globalCtx); +void func_80B81DAC(BgIkanaRotaryroom* this); +void func_80B81DC8(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Ikana_Rotaryroom_InitVars = { ACTOR_BG_IKANA_ROTARYROOM, ACTORCAT_BG, @@ -30,108 +44,959 @@ const ActorInit Bg_Ikana_Rotaryroom_InitVars = { (ActorFunc)BgIkanaRotaryroom_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_80B820E0[2] = { +static ColliderJntSphElementInit sJntSphElementsInit1[2] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00002000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00002000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 0, { { -3450, 450, 0 }, 60 }, 100 }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00002000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00002000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 0, { { 3450, 450, 0 }, 60 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B82128 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_JNTSPH, }, - 2, D_80B820E0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit1 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementsInit1, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80B82138[1] = { +static ColliderJntSphElementInit sJntSphElementsInit2[1] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00002000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00002000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 0, { { -3750, 1200, 0 }, 60 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B8215C = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_JNTSPH, }, - 1, D_80B82138, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit2, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B82214[] = { +Vec3f D_80B8216C = { 225.0f, -280.0f, -210.0f }; + +Vec3f D_80B82178 = { -255.0f, -280.0f, 210.0f }; + +typedef struct { + /* 0x00 */ s8 unk_00; + /* 0x01 */ s8 unk_01; + /* 0x04 */ Vec3f unk_04; +} BgIkanaRotaryroomStruct4; // size = 0x10 + +BgIkanaRotaryroomStruct4 D_80B82184[2][2] = { + { { 0, 0, { -375.0f, -170.0f, 0.0f } }, { 0, 0, { 375.0f, -170.0f, 0.0f } } }, + { { 0, 0, { -435.0f, -180.0f, 0.0f } }, { 0, 1, { 435.0f, -180.0f, 0.0f } } }, +}; + +Vec3s D_80B821C4[] = { + { -150, 194, -120 }, { -120, 194, -30 }, { -150, 194, 120 }, { 120, 194, 120 }, { 180, 194, 30 }, + { 150, 194, -90 }, { 60, 194, -120 }, { -60, 194, 90 }, { 30, 194, 120 }, { 49, 194, -105 }, +}; + +f32 D_80B82200[] = { 64.0f, 66.0f, 66.0f, 30.0f, 41.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +CollisionHeader* D_80B82218[] = { &object_ikana_obj_Colheader_006368, &object_ikana_obj_Colheader_0084F8 }; -extern ColliderJntSphElementInit D_80B820E0[2]; -extern ColliderJntSphInit D_80B82128; -extern ColliderJntSphElementInit D_80B82138[1]; -extern ColliderJntSphInit D_80B8215C; -extern InitChainEntry D_80B82214[]; +void func_80B802E0(BgIkanaRotaryroom* this) { + s32 pad; -extern UNK_TYPE D_060048A0; -extern UNK_TYPE D_06007B68; + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B802E0.s") + Collider_UpdateSpheres(0, &this->collider); + if (!BGIKANAROTARYROOM_GET_1(&this->dyna.actor)) { + Collider_UpdateSpheres(1, &this->collider); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80358.s") +void func_80B80358(Vec3f* arg0) { + arg0->x += (arg0->x >= 0.0f) ? 0.5f : -0.5f; + arg0->y += (arg0->y >= 0.0f) ? 0.5f : -0.5f; + arg0->z += (arg0->z >= 0.0f) ? 0.5f : -0.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80440.s") + arg0->x = (s32)arg0->x; + arg0->y = (s32)arg0->y; + arg0->z = (s32)arg0->z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80550.s") +void func_80B80440(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp50; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80778.s") + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + if (Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor))) { + Matrix_InsertTranslation(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); + } else { + Matrix_InsertTranslation(D_80B8216C.x, D_80B8216C.y, D_80B8216C.z, MTXMODE_APPLY); + } + Matrix_GetStateTranslation(&sp50); + func_80B80358(&sp50); + this->unk_204.unk_00 = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_BG_IKANA_BLOCK, sp50.x, sp50.y, sp50.z, this->dyna.actor.shape.rot.x, + this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, -1, + ActorCutscene_GetAdditionalCutscene(this->dyna.actor.cutscene), this->dyna.actor.unk20, NULL); + Matrix_StatePop(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80894.s") +void func_80B80550(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad; + s32 spC8 = BGIKANAROTARYROOM_GET_1(&this->dyna.actor); + s32 spC4; + s32 pad2; + Vec3f spB4; + Actor* actor; + s32 i; + BgIkanaRotaryroomStruct4* ptr; + MtxF sp68; + Vec3s sp60; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80C88.s") + if (Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_FE(&this->dyna.actor))) { + spC4 = 1; + } else { + spC4 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80F08.s") + actor = globalCtx->actorCtx.actorLists[ACTORCAT_DOOR].first; + Matrix_StatePush(); + sp60.x = BINANG_ROT180(this->dyna.actor.home.rot.x); + sp60.y = this->dyna.actor.home.rot.y; + sp60.z = this->dyna.actor.home.rot.z; + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &sp60); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81010.s") + while (actor != NULL) { + if (actor->id == ACTOR_DOOR_SHUTTER) { + Math_Vec3f_Diff(&actor->world.pos, &this->dyna.actor.world.pos, &spB4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81234.s") + for (i = 0; i < ARRAY_COUNT(D_80B82184); i++) { + ptr = &D_80B82184[spC8][i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B814B8.s") + if ((Math3D_Vec3fDistSq(&spB4, &D_80B82184[spC8][i].unk_04) < SQ(250.0f)) && + ((ptr->unk_00 ^ spC4) && (ptr->unk_01 == 0U))) { + Matrix_StatePush(); + Matrix_InsertTranslation(spB4.x, spB4.y, spB4.z, MTXMODE_APPLY); + Matrix_RotateY(actor->shape.rot.y - this->dyna.actor.home.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(actor->shape.rot.x - this->dyna.actor.home.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(actor->shape.rot.z - this->dyna.actor.home.rot.z, MTXMODE_APPLY); + Matrix_GetStateTranslation(&actor->world.pos); + func_80B80358(&actor->world.pos); + Matrix_CopyCurrentState(&sp68); + func_8018219C(&sp68, &actor->shape.rot, 0); + Matrix_StatePop(); + } + } + } + actor = actor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81570.s") + Matrix_StatePop(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B816A4.s") +BgIkanaRotaryroomStruct4* func_80B80778(BgIkanaRotaryroom* this, GlobalContext* globalCtx, Actor* arg2) { + s32 i; + Vec3f sp68; + s32 pad[2]; + s32 temp_s3 = BGIKANAROTARYROOM_GET_1(&this->dyna.actor); + BgIkanaRotaryroomStruct4* sp58 = NULL; + BgIkanaRotaryroomStruct4* ptr; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/BgIkanaRotaryroom_Init.s") + if (1) {} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/BgIkanaRotaryroom_Destroy.s") + if (arg2->id == ACTOR_DOOR_SHUTTER) { + Matrix_StatePush(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B818B4.s") + for (i = 0; i < ARRAY_COUNT(D_80B82184); i++) { + ptr = &D_80B82184[temp_s3][i]; + if ((ptr->unk_01 == 0) && + (Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot), + Matrix_MultiplyVector3fByState(&ptr->unk_04, &sp68), + (Math3D_Vec3fDistSq(&arg2->world.pos, &sp68) < SQ(250.0f)))) { + sp58 = ptr; + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B818C8.s") + Matrix_StatePop(); + } + return sp58; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81978.s") +void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad[7]; + Actor* actor = this->unk_204.unk_00; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B8198C.s") + Matrix_StatePush(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B819DC.s") + Matrix_InsertZRotation_s(-this->dyna.actor.shape.rot.z, MTXMODE_NEW); + Matrix_InsertXRotation_s(-this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateY(-this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertTranslation(-this->dyna.actor.world.pos.x, -this->dyna.actor.world.pos.y, + -this->dyna.actor.world.pos.z, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B819F0.s") + if (actor != NULL) { + Matrix_StatePush(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81A64.s") + Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_CopyCurrentState(&this->unk_204.unk_04); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81A80.s") + Matrix_StatePop(); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81B84.s") + for (i = 0; i < ARRAY_COUNT(this->unk_248); i++) { + this->unk_248[i].unk_00 = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81BA0.s") + actor = globalCtx->actorCtx.actorLists[ACTORCAT_DOOR].first; + i = 0; + while (actor != NULL) { + if (func_80B80778(this, globalCtx, actor) && (i < 2)) { + this->unk_248[i].unk_00 = actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81DAC.s") + Matrix_StatePush(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81DC8.s") + Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_CopyCurrentState(&this->unk_248[i].unk_04); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/BgIkanaRotaryroom_Update.s") + Matrix_StatePop(); + i++; + } + actor = actor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/BgIkanaRotaryroom_Draw.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { + this->unk_2D0[i].unk_00 = NULL; + } + + actor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + i = 0; + while (actor != NULL) { + if ((actor->id == ACTOR_EN_TORCH2) && (actor->update != NULL) && (i < ARRAY_COUNT(this->unk_2D0))) { + this->unk_2D0[i].unk_00 = actor; + + Matrix_StatePush(); + + Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_CopyCurrentState(&this->unk_2D0[i].unk_04); + + Matrix_StatePop(); + i++; + } + actor = actor->next; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { + this->unk_3E0[i].unk_00 = NULL; + } + + actor = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; + i = 0; + while (actor != NULL) { + if ((actor->update != NULL) && (actor->id != ACTOR_EN_WATER_EFFECT) && (i < ARRAY_COUNT(this->unk_3E0))) { + this->unk_3E0[i].unk_00 = actor; + this->unk_3E0[i].unk_44 = actor->shape.rot; + this->unk_3E0[i].unk_4C = 0.0f; + + Matrix_StatePush(); + + Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_CopyCurrentState(&this->unk_3E0[i].unk_04); + + Matrix_StatePop(); + i++; + } + actor = actor->next; + } + + actor = &GET_PLAYER(globalCtx)->actor; + if (actor->update != NULL) { + this->unk_520.unk_40 = actor->shape.rot; + + Matrix_StatePush(); + + Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_CopyCurrentState(&this->unk_520.unk_00); + + Matrix_StatePop(); + } + + Matrix_StatePop(); +} + +void func_80B80C88(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad[5]; + BgIkanaBlock* ikanaBlock = (BgIkanaBlock*)this->unk_204.unk_00; + Player* player; + Actor* ptr; + Actor* ptr2; + Actor* ptr3; + s32 i; + MtxF sp3C; + + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + + if (ikanaBlock != NULL) { + Matrix_StatePush(); + + Matrix_InsertMatrix(&this->unk_204.unk_04, MTXMODE_APPLY); + Matrix_GetStateTranslation(&ikanaBlock->actor.world.pos); + func_80B80358(&ikanaBlock->actor.world.pos); + Matrix_CopyCurrentState(&sp3C); + func_8018219C(&sp3C, &ikanaBlock->actor.shape.rot, 0); + + Matrix_StatePop(); + } + + for (i = 0; i < ARRAY_COUNT(this->unk_248); i++) { + ptr = this->unk_248[i].unk_00; + if (ptr != NULL) { + Matrix_StatePush(); + + Matrix_InsertMatrix(&this->unk_248[i].unk_04, MTXMODE_APPLY); + Matrix_GetStateTranslation(&ptr->world.pos); + func_80B80358(&ptr->world.pos); + Matrix_CopyCurrentState(&sp3C); + func_8018219C(&sp3C, &ptr->shape.rot, 0); + + Matrix_StatePop(); + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { + ptr2 = this->unk_2D0[i].unk_00; + if (ptr2 != NULL) { + Matrix_StatePush(); + + Matrix_InsertMatrix(&this->unk_2D0[i].unk_04, MTXMODE_APPLY); + Matrix_GetStateTranslation(&ptr2->world.pos); + func_80B80358(&ptr2->world.pos); + Matrix_CopyCurrentState(&sp3C); + func_8018219C(&sp3C, &ptr2->shape.rot, 0); + + Matrix_StatePop(); + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { + ptr3 = this->unk_3E0[i].unk_00; + if (ptr3 != NULL) { + Matrix_StatePush(); + + Matrix_InsertMatrix(&this->unk_3E0[i].unk_04, MTXMODE_APPLY); + Matrix_GetStateTranslation(&ptr3->world.pos); + func_80B80358(&ptr3->world.pos); + Matrix_CopyCurrentState(&sp3C); + func_8018219C(&sp3C, &ptr3->shape.rot, 0); + + Matrix_StatePop(); + } + } + + player = GET_PLAYER(globalCtx); + if (player != NULL) { + Matrix_StatePush(); + + Matrix_InsertMatrix(&this->unk_520.unk_00, MTXMODE_APPLY); + Matrix_GetStateTranslation(&player->actor.world.pos); + Math_Vec3f_Copy(&player->actor.home.pos, &player->actor.world.pos); + func_80B80358(&player->actor.world.pos); + Matrix_CopyCurrentState(&sp3C); + func_8018219C(&sp3C, &player->actor.shape.rot, 0); + + Matrix_StatePop(); + player->actor.freezeTimer = 2; + } + + Matrix_StatePop(); +} + +s32 func_80B80F08(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad; + BgIkanaBlock* sp40 = (BgIkanaBlock*)this->unk_204.unk_00; + Vec3f sp34; + Vec3f sp28; + s32 sp24 = false; + + if (sp40 != NULL) { + Matrix_StatePush(); + + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_InsertTranslation(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); + Matrix_GetStateTranslation(&sp34); + Matrix_SetStateRotationAndTranslation(sp40->actor.world.pos.x, sp40->actor.world.pos.y + sp40->unk_170, + sp40->actor.world.pos.z, &sp40->actor.shape.rot); + Matrix_GetStateTranslation(&sp28); + + Matrix_StatePop(); + + if (Math3D_Vec3fDistSq(&sp34, &sp28) < 3.0f) { + if (!Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor))) { + sp24 = true; + } + Flags_SetSwitch(globalCtx, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor)); + } + } + return sp24; +} + +void func_80B81010(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad; + f32 temp_f0; + s32 temp_s2; + s32 phi_s7; + s32 i; + Actor* ptr; + Vec3f sp84; + BgIkanaRotaryroomStruct2* ptr2; + CollisionPoly* sp7C; + s32 sp78; + + if (ActorCutscene_GetCurrentIndex() == this->dyna.actor.cutscene) { + phi_s7 = true; + + for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { + ptr = this->unk_3E0[i].unk_00; + ptr2 = &this->unk_3E0[i]; + + if (ptr != NULL) { + temp_s2 = Math_ScaledStepToS(&ptr->shape.rot.x, ptr2->unk_44.x, 0xBB8) & 1; + temp_s2 &= Math_ScaledStepToS(&ptr->shape.rot.y, ptr2->unk_44.y, 0xBB8); + temp_s2 &= Math_ScaledStepToS(&ptr->shape.rot.z, ptr2->unk_44.z, 0xBB8); + + ptr2->unk_4C -= 2.0f; + if (ptr2->unk_4C < -30.0f) { + ptr2->unk_4C = -30.0f; + } + + Math_Vec3f_Copy(&ptr->prevPos, &ptr->world.pos); + + ptr->world.pos.y += ptr2->unk_4C; + + sp84.x = ptr->prevPos.x; + sp84.y = ptr->prevPos.y + 50.0f; + sp84.z = ptr->prevPos.z; + + temp_f0 = BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &sp7C, &sp78, NULL, &sp84); + if (ptr->world.pos.y <= temp_f0) { + ptr->world.pos.y = temp_f0; + } else { + temp_s2 = false; + } + + if (temp_s2) { + ptr2->unk_00 = NULL; + } else { + phi_s7 = false; + } + } + } + + if (phi_s7) { + this->unk_578 = NULL; + } + } else { + for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { + ptr = this->unk_3E0[i].unk_00; + if (ptr != NULL) { + ptr->shape.rot = this->unk_3E0[i].unk_44; + Math_Vec3f_Copy(&ptr->prevPos, &ptr->world.pos); + } + } + this->unk_578 = NULL; + } +} + +void func_80B81234(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player = GET_PLAYER(globalCtx); + BgIkanaRotaryroomStruct3* ptr; + s32 sp64; + Vec3f sp58; + Vec3f sp4C; + f32 temp_f0; + f32 sp44 = D_80B82200[player->transformation] * 0.5f; + CollisionPoly* sp40; + s32 sp3C; + + if (ActorCutscene_GetCurrentIndex() == this->dyna.actor.cutscene) { + if (player == NULL) { + return; + } + + ptr = &this->unk_520; + + if (player->actor.freezeTimer > 0) { + sp58.x = ptr->unk_4C.x; + sp58.y = ptr->unk_4C.y + 50.0f; + sp58.z = ptr->unk_4C.z; + + sp64 = Math_ScaledStepToS(&player->actor.shape.rot.x, ptr->unk_40.x, 2000) & 1; + sp64 &= Math_ScaledStepToS(&player->actor.shape.rot.y, ptr->unk_40.y, 2000); + sp64 &= Math_ScaledStepToS(&player->actor.shape.rot.z, ptr->unk_40.z, 2000); + + ptr->unk_48 = ptr->unk_48 - 2.1f; + ptr->unk_48 = ptr->unk_48 * 0.98f; + if (ptr->unk_48 < -30.0f) { + ptr->unk_48 = -30.0f; + } + ptr->unk_4C.y += ptr->unk_48; + + Matrix_StatePush(); + + Matrix_RotateY(player->actor.shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(player->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(player->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledY(sp44, &sp4C); + + Matrix_StatePop(); + + temp_f0 = BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &sp40, &sp3C, NULL, &sp58); + if (ptr->unk_4C.y <= temp_f0) { + ptr->unk_4C.y = temp_f0; + } else { + sp64 = 0; + } + + Math_Vec3f_Copy(&player->actor.home.pos, &player->actor.world.pos); + + player->actor.world.pos.x = ptr->unk_4C.x - sp4C.x; + player->actor.world.pos.y = (ptr->unk_4C.y - sp4C.y) + sp44; + player->actor.world.pos.z = ptr->unk_4C.z - sp4C.z; + + if (sp64 != 0) { + Math_Vec3f_Copy(&player->actor.home.pos, &player->actor.world.pos); + this->unk_57C = NULL; + } else { + player->actor.freezeTimer = 2; + } + } + } else { + if (player != NULL) { + player->actor.shape.rot = this->unk_520.unk_40; + Math_Vec3f_Copy(&player->actor.home.pos, &player->actor.world.pos); + } + this->unk_57C = NULL; + } +} + +void func_80B814B8(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (ActorCutscene_GetCurrentIndex() == this->dyna.actor.cutscene) { + if (player->actor.bgCheckFlags & 0x100) { + func_800B8E58(player, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->unk_92); + func_80169EFC(globalCtx); + func_800B8E58(player, NA_SE_VO_LI_TAKEN_AWAY + player->ageProperties->unk_92); + globalCtx->unk_18845 = 1; + play_sound(NA_SE_OC_ABYSS); + this->actionFunc = NULL; + } + } else { + this->actionFunc = NULL; + } +} + +void func_80B81570(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp70; + Vec3f sp64; + s32 pad; + s32 pad2; + + Matrix_StatePush(); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + + for (i = 0; i < ARRAY_COUNT(D_80B821C4); i++) { + sp64.x = D_80B821C4[i].x; + sp64.y = D_80B821C4[i].y; + sp64.z = D_80B821C4[i].z; + + Matrix_MultiplyVector3fByState(&sp64, &sp70); + + sp70.x += this->dyna.actor.world.pos.x; + sp70.y += this->dyna.actor.world.pos.y; + sp70.z += this->dyna.actor.world.pos.z; + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, sp70.x, sp70.y, sp70.z, 0, 0, 0, 1); + } + + Matrix_StatePop(); +} + +s32 func_80B816A4(BgIkanaRotaryroom* this) { + s32 i; + s32 count = 0; + + for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { + if (this->unk_3E0[i].unk_00 != NULL) { + count++; + } + } + + return count; +} + +void BgIkanaRotaryroom_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgIkanaRotaryroom* this = THIS; + s32 sp34 = BGIKANAROTARYROOM_GET_1(&this->dyna.actor); + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + + if (Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_FE(&this->dyna.actor))) { + this->dyna.actor.shape.rot.x = -0x8000; + } else { + this->dyna.actor.shape.rot.x = 0; + } + + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_80B82218[sp34]); + + Collider_InitJntSph(globalCtx, &this->collider); + if (!sp34) { + Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit1, this->colliderElements); + } else { + Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit2, this->colliderElements); + } + + func_80B802E0(this); + + if (sp34 == true) { + this->unk_1FC = Lib_SegmentedToVirtual(&object_ikana_obj_Matanimheader_007B68); + } + + if (!sp34) { + func_80B80440(this, globalCtx); + } else { + func_80B81570(this, globalCtx); + } + + func_80B80550(this, globalCtx); + func_80B818B4(this); +} + +void BgIkanaRotaryroom_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyJntSph(globalCtx, &this->collider); +} + +void func_80B818B4(BgIkanaRotaryroom* this) { + this->unk_200 = func_80B818C8; +} + +void func_80B818C8(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + s32 sp20; + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + sp20 = BGIKANAROTARYROOM_GET_FE(&this->dyna.actor); + if (Flags_GetSwitch(globalCtx, sp20)) { + Flags_UnsetSwitch(globalCtx, sp20); + } else { + Flags_SetSwitch(globalCtx, sp20); + } + func_80B81978(this); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80B81978(BgIkanaRotaryroom* this) { + this->unk_200 = func_80B8198C; +} + +void func_80B8198C(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + + if (this->unk_204.unk_00 == NULL) { + func_80B819DC(this); + } else if (((BgIkanaBlock*)this->unk_204.unk_00)->unk_17C & 1) { + ((BgIkanaBlock*)this->unk_204.unk_00)->unk_17C |= 8; + func_80B819DC(this); + } +} + +void func_80B819DC(BgIkanaRotaryroom* this) { + this->unk_200 = func_80B819F0; +} + +void func_80B819F0(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (this->dyna.actor.cutscene >= 0) { + func_800B7298(globalCtx, &this->dyna.actor, 7); + } + func_80B81A64(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void func_80B81A64(BgIkanaRotaryroom* this) { + this->unk_584 = 25; + this->unk_200 = func_80B81A80; +} + +void func_80B81A80(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + s32 pad; + s32 i; + BgIkanaRotaryroomStruct1* ptr; + + func_800B9010(thisx, NA_SE_EV_EARTHQUAKE - SFX_FLAG); + this->unk_584--; + + if (this->unk_584 <= 0) { + if (1) {} + if (1) {} + if (1) {} + if (1) {} + func_80B80894(this, globalCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { + ptr = &this->unk_2D0[i]; + if (ptr->unk_00 != NULL) { + ((EnTorch2*)ptr->unk_00)->state = 3; + } + } + + func_80B81B84(this); + } else if (this->unk_584 == 15) { + s16 sp26 = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + + Quake_SetSpeed(sp26, 0x7B30); + Quake_SetQuakeValues(sp26, 6, 0, 100, 0); + Quake_SetCountdown(sp26, 22); + } +} + +void func_80B81B84(BgIkanaRotaryroom* this) { + this->unk_584 = 0x2001; + this->unk_200 = func_80B81BA0; +} + +void func_80B81BA0(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + s32 sp30 = 0; + s32 i; + + func_800B9010(&this->dyna.actor, NA_SE_EV_EARTHQUAKE - SFX_FLAG); + + if (this->unk_584 > 0) { + this->unk_584--; + } + + thisx->shape.rot.x += 0x1F4; + + if (!(this->unk_584 & 7)) { + s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + + Quake_SetSpeed(quake, 0x7B30); + Quake_SetQuakeValues(quake, (s32)(Rand_ZeroOne() * 2.5f) + 3, 0, 10, 0); + Quake_SetCountdown(quake, 15); + } + + if (Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_FE(&this->dyna.actor))) { + if (this->dyna.actor.shape.rot.x < 0) { + this->dyna.actor.shape.rot.x = -0x8000; + sp30 = 1; + } + } else if (this->dyna.actor.shape.rot.x >= 0) { + this->dyna.actor.shape.rot.x = 0; + sp30 = 1; + } + + func_80B80C88(this, globalCtx); + + if (sp30 != 0) { + Player* player = GET_PLAYER(globalCtx); + BgIkanaRotaryroomStruct1* ptr; + BgIkanaBlock* block = (BgIkanaBlock*)this->unk_204.unk_00; + + if (block != NULL) { + block->unk_17C &= ~8; + block->unk_17C |= 4; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { + ptr = &this->unk_2D0[i]; + if (ptr->unk_00 != NULL) { + ((EnTorch2*)ptr->unk_00)->state = 4; + } + } + + this->unk_520.unk_48 = 0.0f; + this->unk_520.unk_4C.x = player->actor.world.pos.x; + this->unk_520.unk_4C.y = player->actor.world.pos.y - D_80B82200[player->transformation]; + this->unk_520.unk_4C.z = player->actor.world.pos.z; + + if (func_80B816A4(this) > 0) { + this->unk_578 = func_80B81010; + } + + this->unk_57C = func_80B81234; + this->actionFunc = func_80B814B8; + func_80B802E0(this); + func_80B81DAC(this); + } +} + +void func_80B81DAC(BgIkanaRotaryroom* this) { + this->unk_584 = 20; + this->unk_200 = func_80B81DC8; +} + +void func_80B81DC8(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgIkanaRotaryroom* this = THIS; + + if (this->unk_584 > 10) { + func_800B9010(&this->dyna.actor, NA_SE_EV_EARTHQUAKE - SFX_FLAG); + } + this->unk_584--; + + if (this->unk_584 <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + func_80B818B4(this); + } else if (this->unk_584 == 19) { + s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + + Quake_SetSpeed(quake, 0x4E20); + Quake_SetQuakeValues(quake, 5, 0, 40, 60); + Quake_SetCountdown(quake, 17); + } +} + +void BgIkanaRotaryroom_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + BgIkanaRotaryroomStruct1* ptr; + BgIkanaRotaryroomStruct1* ptr2; + BgIkanaRotaryroomStruct2* ptr3; + s32 i; + + if ((this->unk_204.unk_00 != NULL) && (this->unk_204.unk_00->update == NULL)) { + this->unk_204.unk_00 = NULL; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_248); i++) { + ptr = &this->unk_248[i]; + if ((ptr->unk_00 != NULL) && (ptr->unk_00->update == NULL)) { + ptr->unk_00 = NULL; + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { + ptr2 = &this->unk_2D0[i]; + if ((ptr2->unk_00 != NULL) && (ptr2->unk_00->update == NULL)) { + ptr2->unk_00 = NULL; + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { + ptr3 = &this->unk_3E0[i]; + if ((ptr3->unk_00 != NULL) && (ptr3->unk_00->update == NULL)) { + ptr3->unk_00 = NULL; + } + } + + if (func_80B80F08(this, globalCtx)) { + if (this->unk_204.unk_00 != NULL) { + ((BgIkanaBlock*)this->unk_204.unk_00)->unk_17E = 1; + } + } + + this->unk_200(&this->dyna.actor, globalCtx); + + if (this->unk_578 != NULL) { + this->unk_578(this, globalCtx); + } + + if (this->unk_57C != NULL) { + this->unk_57C(this, globalCtx); + } + + if (this->actionFunc != NULL) { + this->actionFunc(this, globalCtx); + } +} + +void BgIkanaRotaryroom_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + s32 param = BGIKANAROTARYROOM_GET_1(&this->dyna.actor); + + if (!param) { + Gfx_DrawDListOpa(globalCtx, object_ikana_obj_DL_0048A0); + Gfx_DrawDListXlu(globalCtx, object_ikana_obj_DL_004710); + } else { + AnimatedMat_Draw(globalCtx, this->unk_1FC); + Gfx_DrawDListOpa(globalCtx, object_ikana_obj_DL_007448); + Gfx_DrawDListXlu(globalCtx, object_ikana_obj_DL_007360); + } +} diff --git a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.h b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.h index d446d5e92..1e27fb485 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.h @@ -6,12 +6,47 @@ struct BgIkanaRotaryroom; typedef void (*BgIkanaRotaryroomActionFunc)(struct BgIkanaRotaryroom*, GlobalContext*); +typedef void (*BgIkanaRotaryroomUnkFunc)(Actor*, GlobalContext*); +typedef void (*BgIkanaRotaryroomUnkFunc2)(struct BgIkanaRotaryroom*, GlobalContext*); + +#define BGIKANAROTARYROOM_GET_1(thisx) ((thisx)->params & 1) +#define BGIKANAROTARYROOM_GET_FE(thisx) (((thisx)->params >> 1) & 0x7F) +#define BGIKANAROTARYROOM_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) + +typedef struct { + /* 0x00 */ Actor* unk_00; + /* 0x04 */ MtxF unk_04; +} BgIkanaRotaryroomStruct1; // size = 0x44 + +typedef struct { + /* 0x00 */ Actor* unk_00; + /* 0x04 */ MtxF unk_04; + /* 0x44 */ Vec3s unk_44; + /* 0x4C */ f32 unk_4C; +} BgIkanaRotaryroomStruct2; // size = 0x50 + +typedef struct { + /* 0x00 */ MtxF unk_00; + /* 0x40 */ Vec3s unk_40; + /* 0x48 */ f32 unk_48; + /* 0x4C */ Vec3f unk_4C; +} BgIkanaRotaryroomStruct3; // size = 0x58 typedef struct BgIkanaRotaryroom { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x43C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderJntSph collider; + /* 0x017C */ ColliderJntSphElement colliderElements[2]; + /* 0x01FC */ AnimatedMaterial* unk_1FC; + /* 0x0200 */ BgIkanaRotaryroomUnkFunc unk_200; + /* 0x0204 */ BgIkanaRotaryroomStruct1 unk_204; + /* 0x0248 */ BgIkanaRotaryroomStruct1 unk_248[2]; + /* 0x02D0 */ BgIkanaRotaryroomStruct1 unk_2D0[4]; + /* 0x03E0 */ BgIkanaRotaryroomStruct2 unk_3E0[4]; + /* 0x0520 */ BgIkanaRotaryroomStruct3 unk_520; + /* 0x0578 */ BgIkanaRotaryroomUnkFunc2 unk_578; + /* 0x057C */ BgIkanaRotaryroomUnkFunc2 unk_57C; /* 0x0580 */ BgIkanaRotaryroomActionFunc actionFunc; - /* 0x0584 */ char unk_584[0x4]; + /* 0x0584 */ s16 unk_584; } BgIkanaRotaryroom; // size = 0x588 extern const ActorInit Bg_Ikana_Rotaryroom_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index b9e2c4c15..44de5a329 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -700,14 +700,6 @@ D_06001AD8 = 0x06001AD8; D_06001E18 = 0x06001E18; D_06002358 = 0x06002358; -// ovl_Bg_Ikana_Rotaryroom - -D_06004710 = 0x06004710; -D_060048A0 = 0x060048A0; -D_06007360 = 0x06007360; -D_06007448 = 0x06007448; -D_06007B68 = 0x06007B68; - // ovl_Bg_Ikninside D_0600CC78 = 0x0600CC78; From 9e9b84cb2ce941ae3aa1ca9398a0865451f658cf Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 13 Feb 2022 23:58:41 +0000 Subject: [PATCH 006/257] Dm_Char05 (#583) * Dm_Char05 * Params * Syms * Earpstone * Merge --- assets/xml/objects/object_dmask.xml | 12 +- include/z64item.h | 16 +- spec | 3 +- .../actors/ovl_Dm_Char05/z_dm_char05.c | 755 ++++++++++++++++-- .../actors/ovl_Dm_Char05/z_dm_char05.h | 32 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 8 - 7 files changed, 765 insertions(+), 65 deletions(-) diff --git a/assets/xml/objects/object_dmask.xml b/assets/xml/objects/object_dmask.xml index f2411c147..a7b3874ec 100644 --- a/assets/xml/objects/object_dmask.xml +++ b/assets/xml/objects/object_dmask.xml @@ -2,15 +2,18 @@ - + + - + + - + + @@ -19,6 +22,7 @@ - + + diff --git a/include/z64item.h b/include/z64item.h index 6c9672c54..ab0a236fa 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -349,7 +349,11 @@ typedef enum { typedef enum { /* 0x00 */ GID_BOTTLE, + /* 0x02 */ GID_02 = 0x02, + /* 0x03 */ GID_03, /* 0x0A */ GID_COMPASS = 0x0A, + /* 0x0E */ GID_0E = 0x0E, + /* 0x0F */ GID_0F, /* 0x10 */ GID_MASK_ALL_NIGHT = 0x10, /* 0x11 */ GID_NUTS, /* 0x17 */ GID_BOMB_BAG_20 = 0x17, @@ -367,11 +371,19 @@ typedef enum { /* 0x31 */ GID_POTION_RED, /* 0x32 */ GID_POTION_BLUE, /* 0x33 */ GID_SHIELD_MIRROR, - /* 0x3B */ GID_FAIRY = 0x3B, + /* 0x3A */ GID_3A = 0x3A, + /* 0x3B */ GID_FAIRY, + /* 0x3E */ GID_3E = 0x3E, + /* 0x44 */ GID_44 = 0x44, + /* 0x45 */ GID_45, /* 0x55 */ GID_SWORD_KOKIRI = 0x55, /* 0x66 */ GID_SWORD_RAZOR = 0x66, /* 0x67 */ GID_SWORD_GILDED, - /* 0x68 */ GID_SWORD_GREAT_FAIRY + /* 0x68 */ GID_SWORD_GREAT_FAIRY, + /* 0x6A */ GID_6A = 0x6A, + /* 0x6B */ GID_6B, + /* 0x70 */ GID_70 = 0x70, + /* 0x71 */ GID_71, } GetItemDrawID; // TODO: fill diff --git a/spec b/spec index b5d694934..bfc1e0ef5 100644 --- a/spec +++ b/spec @@ -3305,8 +3305,7 @@ beginseg name "ovl_Dm_Char05" compress include "build/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.o" - include "build/data/ovl_Dm_Char05/ovl_Dm_Char05.data.o" - include "build/data/ovl_Dm_Char05/ovl_Dm_Char05.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Char05/ovl_Dm_Char05_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c index 1f61d302f..b30a63fe2 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c @@ -5,6 +5,7 @@ */ #include "z_dm_char05.h" +#include "objects/object_dmask/object_dmask.h" #define FLAGS 0x00000030 @@ -28,8 +29,12 @@ void func_80AACD1C(DmChar05* this, GlobalContext* globalCtx); void func_80AACD68(DmChar05* this, GlobalContext* globalCtx); void func_80AACE10(DmChar05* this, GlobalContext* globalCtx); void func_80AACE5C(DmChar05* this, GlobalContext* globalCtx); +void func_80AADD9C(GlobalContext* globalCtx, DmChar05* this); +void func_80AADE78(GlobalContext* globalCtx, DmChar05* this); +void func_80AADF54(GlobalContext* globalCtx, DmChar05* this); +void func_80AAE030(GlobalContext* globalCtx, DmChar05* this); +void func_80AAE114(GlobalContext* globalCtx, DmChar05* this); -#if 0 const ActorInit Dm_Char05_InitVars = { ACTOR_DM_CHAR05, ACTORCAT_ITEMACTION, @@ -42,86 +47,746 @@ const ActorInit Dm_Char05_InitVars = { (ActorFunc)DmChar05_Draw, }; -#endif +static ActorAnimationEntry sAnimations[] = { + { &object_dmask_Anim_001090, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_dmask_Anim_004288, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_dmask_Anim_0001A8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_dmask_Anim_00017C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_dmask_Anim_0011A0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_dmask_Anim_0013A4, 1.0f, 0.0f, -1.0f, 0, 0.0f }, +}; -extern UNK_TYPE D_060001D0; -extern UNK_TYPE D_060010B0; -extern UNK_TYPE D_060013D0; -extern UNK_TYPE D_06001E70; -extern UNK_TYPE D_060042B0; +void func_80AAC5A0(SkelAnime* skelAnime, ActorAnimationEntry* animation, u16 arg2) { + f32 phi_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC5A0.s") + animation += arg2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC63C.s") + if (animation->frameCount < 0.0f) { + phi_f2 = Animation_GetLastFrame(animation->animation); + } else { + phi_f2 = animation->frameCount; + } + Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, phi_f2, + animation->mode, animation->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC6E4.s") +void func_80AAC63C(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC770.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_dmask_Skel_010B0, NULL, NULL, NULL, 0); + if (DMCHAR05_GET(&this->actor) == DMCHAR05_0) { + func_80AAC5A0(&this->skelAnime, &sAnimations[0], 0); + } else { + func_80AAC5A0(&this->skelAnime, &sAnimations[1], 0); + } + this->actionFunc = func_80AACC48; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC7FC.s") +void func_80AAC6E4(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC888.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_dmask_Skel_042B0, NULL, NULL, NULL, 0); + func_80AAC5A0(&this->skelAnime, &sAnimations[1], 0); + this->actionFunc = func_80AACC48; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/DmChar05_Init.s") +void func_80AAC770(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/DmChar05_Destroy.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dmask_Skel_001D0, NULL, NULL, NULL, 0); + func_80AAC5A0(&this->skelAnime, &sAnimations[3], 0); + this->actionFunc = func_80AACC48; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC990.s") +void func_80AAC7FC(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC9DC.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_dmask_Skel_013D0, NULL, NULL, NULL, 0); + func_80AAC5A0(&this->skelAnime, &sAnimations[4], 0); + this->actionFunc = func_80AACC48; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACA98.s") +void func_80AAC888(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACAE4.s") + this->actionFunc = func_80AACA98; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACBE4.s") +void DmChar05_Init(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACC48.s") + this->unk_18C = 0; + this->unk_18E = 0; + this->unk_19C = 0; + this->unk_1A0 = 0; + this->unk_1A4 = 0; + this->unk_1A8 = 0; + this->unk_1AC = 100; + this->unk_1B0 = 1000; + this->unk_1B4 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACC6C.s") + switch (DMCHAR05_GET(&this->actor)) { + case DMCHAR05_0: + func_80AAC63C(thisx, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACCD4.s") + case DMCHAR05_1: + func_80AAC6E4(thisx, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACD0C.s") + case DMCHAR05_2: + func_80AAC770(thisx, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACD1C.s") + case DMCHAR05_3: + func_80AAC7FC(thisx, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACD68.s") + case DMCHAR05_4: + func_80AAC888(thisx, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACE10.s") + case DMCHAR05_5: + case DMCHAR05_6: + case DMCHAR05_7: + case DMCHAR05_8: + case DMCHAR05_9: + case DMCHAR05_10: + case DMCHAR05_11: + case DMCHAR05_12: + this->actionFunc = func_80AACBE4; + break; + } + Actor_SetScale(&this->actor, 0.01f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACE5C.s") +void DmChar05_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACF04.s") +void func_80AAC990(DmChar05* this, GlobalContext* globalCtx) { + s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_GOLONMASK); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAD3F8.s") + if (objectIdx >= 0) { + this->unk_18F = objectIdx; + this->actionFunc = func_80AAC9DC; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAD450.s") +void func_80AAC9DC(DmChar05* this, GlobalContext* globalCtx) { + u32 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAD4A8.s") + if (func_800EE29C(globalCtx, 0x6D) != 0) { + temp_v0 = func_800EE200(globalCtx, 0x6D); + if (globalCtx->csCtx.npcActions[temp_v0]->unk0 == 4) { + this->unk_18E = 1; + this->unk_190.x = globalCtx->csCtx.npcActions[temp_v0]->unk0C.x; + this->unk_190.y = globalCtx->csCtx.npcActions[temp_v0]->unk0C.y; + this->unk_190.z = globalCtx->csCtx.npcActions[temp_v0]->unk0C.z; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/DmChar05_Update.s") +void func_80AACA98(DmChar05* this, GlobalContext* globalCtx) { + s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_MASK13); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAD964.s") + if (objectIdx >= 0) { + this->unk_18F = objectIdx; + this->actionFunc = func_80AACAE4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAD980.s") +void func_80AACAE4(DmChar05* this, GlobalContext* globalCtx) { + u32 sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAD998.s") + if (func_800EE29C(globalCtx, 0x234)) { + sp24 = func_800EE200(globalCtx, 0x234); + if (globalCtx->csCtx.npcActions[sp24]->unk0 == 2) { + if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[sp24]->startFrame) { + Item_Give(globalCtx, ITEM_MASK_COUPLE); + } + this->unk_18E = 1; + this->unk_190.x = globalCtx->csCtx.npcActions[sp24]->unk0C.x; + this->unk_190.y = globalCtx->csCtx.npcActions[sp24]->unk0C.y; + this->unk_190.z = globalCtx->csCtx.npcActions[sp24]->unk0C.z; + } else { + this->unk_18E = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AADA90.s") +void func_80AACBE4(DmChar05* this, GlobalContext* globalCtx) { + static s16 D_80AAE2F0[] = { + OBJECT_GI_MASK17, OBJECT_GI_MASK14, OBJECT_GI_MASK10, OBJECT_GI_MASK21, + OBJECT_GI_MASK11, OBJECT_GI_MASK20, OBJECT_GI_RABIT_MASK, OBJECT_GI_MASK12, + }; + s32 params = DMCHAR05_GET(&this->actor) - DMCHAR05_5; + s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, D_80AAE2F0[params]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AADB4C.s") + if (objectIdx >= 0) { + this->unk_18F = objectIdx; + this->actionFunc = func_80AACD0C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AADC00.s") +void func_80AACC48(DmChar05* this, GlobalContext* globalCtx) { + if (this->unk_1B4 != 0) { + this->actionFunc = func_80AACC6C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/DmChar05_Draw.s") +void func_80AACC6C(DmChar05* this, GlobalContext* globalCtx) { + if (this->unk_19C < 247) { + this->unk_19C += 8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AADD9C.s") + if (this->unk_1A0 < 247) { + this->unk_1A0 += 8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AADE78.s") + if (this->unk_1A4 < 247) { + this->unk_1A4 += 8; + } else { + this->unk_19C = 255; + this->unk_1A0 = 255; + this->unk_1A4 = 255; + this->actionFunc = func_80AACCD4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AADF54.s") +void func_80AACCD4(DmChar05* this, GlobalContext* globalCtx) { + if (this->unk_1AC < 975) { + this->unk_1AC += 25; + } else { + this->unk_1AC = 996; + this->actionFunc = func_80AACD0C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAE030.s") +void func_80AACD0C(DmChar05* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAE114.s") +void func_80AACD1C(DmChar05* this, GlobalContext* globalCtx) { + s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_ZORAMASK); + + if (objectIdx >= 0) { + this->unk_18F = objectIdx; + this->actionFunc = func_80AACD68; + } +} + +void func_80AACD68(DmChar05* this, GlobalContext* globalCtx) { + u32 temp_v0; + + if (func_800EE29C(globalCtx, 0x1D9)) { + temp_v0 = func_800EE200(globalCtx, 0x1D9); + this->unk_18E = 1; + this->unk_190.x = globalCtx->csCtx.npcActions[temp_v0]->unk0C.x; + this->unk_190.y = globalCtx->csCtx.npcActions[temp_v0]->unk0C.y; + this->unk_190.z = globalCtx->csCtx.npcActions[temp_v0]->unk0C.z; + } +} + +void func_80AACE10(DmChar05* this, GlobalContext* globalCtx) { + s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_MASK15); + + if (objectIdx >= 0) { + this->unk_18F = objectIdx; + this->actionFunc = func_80AACE5C; + } +} + +void func_80AACE5C(DmChar05* this, GlobalContext* globalCtx) { + u32 temp_v0; + + if (func_800EE29C(globalCtx, 0x206)) { + temp_v0 = func_800EE200(globalCtx, 0x206); + this->unk_18E = 1; + this->unk_190.x = globalCtx->csCtx.npcActions[temp_v0]->unk0C.x; + this->unk_190.y = globalCtx->csCtx.npcActions[temp_v0]->unk0C.y; + this->unk_190.z = globalCtx->csCtx.npcActions[temp_v0]->unk0C.z; + } +} + +void func_80AACF04(DmChar05* this, GlobalContext* globalCtx) { + u8 sp2F = true; + u32 temp_v0; + + switch (DMCHAR05_GET(&this->actor)) { + case DMCHAR05_0: + if (func_800EE29C(globalCtx, 0x6D)) { + temp_v0 = func_800EE200(globalCtx, 0x6D); + + if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[temp_v0]->startFrame) { + switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + case 1: + sp2F = false; + break; + + case 2: + this->unk_1B4 = 1; + break; + + case 3: + this->unk_18C = 0; + break; + + case 4: + Item_Give(globalCtx, ITEM_MASK_GORON); + sp2F = false; + this->actionFunc = func_80AAC990; + break; + + case 5: + sp2F = false; + Actor_MarkForDeath(&this->actor); + break; + + default: + sp2F = false; + break; + } + + if (sp2F) { + func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + } + } + + func_800EDF24(&this->actor, globalCtx, temp_v0); + } + break; + + case DMCHAR05_1: + if (func_800EE29C(globalCtx, 0x1D9)) { + temp_v0 = func_800EE200(globalCtx, 0x1D9); + + if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[temp_v0]->startFrame) { + switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + case 1: + sp2F = false; + break; + + case 2: + this->unk_18C = 1; + this->unk_1B4 = 1; + break; + + case 3: + this->unk_18C = 1; + break; + + case 4: + Item_Give(globalCtx, ITEM_MASK_ZORA); + sp2F = false; + this->actionFunc = func_80AACD1C; + break; + + case 5: + sp2F = false; + Actor_MarkForDeath(&this->actor); + break; + + default: + sp2F = false; + break; + } + + if (sp2F) { + func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + } + } + + func_800EDF24(&this->actor, globalCtx, temp_v0); + } + break; + + case DMCHAR05_2: + if (func_800EE29C(globalCtx, 0x206)) { + temp_v0 = func_800EE200(globalCtx, 0x206); + + if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[temp_v0]->startFrame) { + switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + case 1: + sp2F = false; + break; + + case 2: + this->unk_18C = 3; + break; + + case 3: + this->unk_18C = 2; + break; + + case 4: + Item_Give(globalCtx, ITEM_MASK_GIBDO); + sp2F = false; + this->actionFunc = func_80AACE10; + break; + + case 5: + sp2F = false; + Actor_MarkForDeath(&this->actor); + break; + + default: + sp2F = false; + break; + } + + if (sp2F) { + func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + } + } + + func_800EDF24(&this->actor, globalCtx, temp_v0); + } + break; + + case DMCHAR05_3: + if (func_800EE29C(globalCtx, 0x22F)) { + temp_v0 = func_800EE200(globalCtx, 0x22F); + + if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[temp_v0]->startFrame) { + switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + default: + sp2F = false; + break; + + case 1: + sp2F = false; + break; + + case 2: + this->unk_18C = 4; + break; + + case 3: + this->unk_18C = 5; + break; + + case 4: + this->unk_18C = 5; + break; + } + + if (sp2F) { + func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + } + } + + if (globalCtx->csCtx.npcActions[temp_v0]->unk0 != 4) { + func_800EDF24(&this->actor, globalCtx, temp_v0); + } else { + func_800EDE34(&this->actor, globalCtx, temp_v0); + } + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (this->unk_18C == 4) { + this->unk_18C++; + func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + } + } + break; + } +} + +void func_80AAD3F8(DmChar05* this, GlobalContext* globalCtx) { + if (globalCtx->csCtx.frames == 490) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); + } + + if (globalCtx->csCtx.frames > 550) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MASK_FLOAT - SFX_FLAG); + } +} + +void func_80AAD450(DmChar05* this, GlobalContext* globalCtx) { + if (globalCtx->csCtx.frames == 262) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); + } + + if (globalCtx->csCtx.frames > 318) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MASK_FLOAT - SFX_FLAG); + } +} + +void func_80AAD4A8(DmChar05* this, GlobalContext* globalCtx) { + if (DMCHAR05_GET(&this->actor) == DMCHAR05_0) { + if (func_800EE29C(globalCtx, 0x6D) && + (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x6D)]->unk0 == 3)) { + if (Animation_OnFrame(&this->skelAnime, 14.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_0); + } else if (Animation_OnFrame(&this->skelAnime, 19.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_1); + } + } + } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_1) { + if (func_800EE29C(globalCtx, 0x1D9)) { + if ((globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1D9)]->unk0 == 3) && + Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_SAND); + } + } + } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_2) { + if (func_800EE29C(globalCtx, 0x206) && + (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x206)]->unk0 == 2)) { + if (Animation_OnFrame(&this->skelAnime, 7.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_0); + } + + if (Animation_OnFrame(&this->skelAnime, 14.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_1); + } + + if (Animation_OnFrame(&this->skelAnime, 18.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_1); + } + } + } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_3) { + if (globalCtx->sceneNum == SCENE_OKUJOU) { + if (gSaveContext.sceneSetupIndex == 2) { + if (globalCtx->csCtx.unk_12 == 0) { + func_80AAD3F8(this, globalCtx); + } else if (globalCtx->csCtx.unk_12 == 1) { + func_80AAD450(this, globalCtx); + } + } + } else if (globalCtx->sceneNum == SCENE_SPOT00) { + if (gSaveContext.sceneSetupIndex == 9) { + if ((globalCtx->csCtx.unk_12 == 0) && (globalCtx->csCtx.frames == 255)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); + } + } else if ((gSaveContext.sceneSetupIndex == 0xB) && (globalCtx->csCtx.frames == 115)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER_PREDEMO); + } + } + } +} + +void DmChar05_Update(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; + + func_80AACF04(this, globalCtx); + if (func_800EE29C(globalCtx, 0x6D)) { + if (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x6D)]->unk0 == 3) { + SkelAnime_Update(&this->skelAnime); + } + } else if (func_800EE29C(globalCtx, 0x1D9)) { + if (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1D9)]->unk0 == 3) { + SkelAnime_Update(&this->skelAnime); + } + } else if (func_800EE29C(globalCtx, 0x206)) { + if (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x206)]->unk0 == 2) { + SkelAnime_Update(&this->skelAnime); + } + } else if (func_800EE29C(globalCtx, 0x22F)) { + if ((globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x22F)]->unk0 == 2) || + (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x22F)]->unk0 == 3)) { + SkelAnime_Update(&this->skelAnime); + } + + if (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x22F)]->unk0 == 4) { + this->actor.world.rot.y += 0x258; + this->actor.shape.rot.y += 0x258; + } + } + this->actionFunc(this, globalCtx); + func_80AAD4A8(this, globalCtx); +} + +s32 DmChar05_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + return false; +} + +void DmChar05_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +} + +void func_80AAD998(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; + s32 pad[2]; + + if (this->unk_18E == 0) { + if (func_800EE29C(globalCtx, 0x6D) && + (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x6D)]->unk0 != 1)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, this->unk_19C, this->unk_1A0, this->unk_1A4, this->unk_1A8, + this->unk_1AC, this->unk_1B0); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + DmChar05_OverrideLimbDraw, DmChar05_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } else if (this->unk_18E == 1) { + func_80AADD9C(globalCtx, this); + } +} + +void func_80AADA90(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; + + if (this->unk_18E == 0) { + if (func_800EE29C(globalCtx, 0x1D9) && + (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1D9)]->unk0 != 1)) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + DmChar05_OverrideLimbDraw, DmChar05_PostLimbDraw, &this->actor); + } + } else if (this->unk_18E == 1) { + func_80AADE78(globalCtx, this); + } +} + +void func_80AADB4C(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; + + if (this->unk_18E == 0) { + if (func_800EE29C(globalCtx, 0x206) && + (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x206)]->unk0 != 1)) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, NULL, &this->actor); + } + } else if (this->unk_18E == 1) { + func_80AADF54(globalCtx, this); + } +} + +void func_80AADC00(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DmChar05* this = THIS; + u32 temp_v0; + + if (func_800EE29C(globalCtx, 0x22F)) { + temp_v0 = func_800EE200(globalCtx, 0x22F); + + if ((globalCtx->csCtx.npcActions[temp_v0]->unk0 != 1) && (globalCtx->csCtx.npcActions[temp_v0]->unk0 != 4)) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + DmChar05_OverrideLimbDraw, DmChar05_PostLimbDraw, &this->actor); + } + + if (globalCtx->csCtx.npcActions[temp_v0]->unk0 == 4) { + Matrix_InsertTranslation(-600.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Gfx_DrawDListOpa(globalCtx, object_dmask_DL_001E70); + } + } +} + +void DmChar05_Draw(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; + + switch (DMCHAR05_GET(&this->actor)) { + case DMCHAR05_0: + func_80AAD998(thisx, globalCtx); + break; + + case DMCHAR05_1: + func_80AADA90(thisx, globalCtx); + break; + + case DMCHAR05_2: + func_80AADB4C(thisx, globalCtx); + break; + + case DMCHAR05_3: + func_80AADC00(thisx, globalCtx); + break; + + case DMCHAR05_4: + func_80AAE030(globalCtx, this); + break; + + case DMCHAR05_5: + case DMCHAR05_6: + case DMCHAR05_7: + case DMCHAR05_8: + case DMCHAR05_9: + case DMCHAR05_10: + case DMCHAR05_11: + case DMCHAR05_12: + func_80AAE114(globalCtx, this); + break; + } +} + +void func_80AADD9C(GlobalContext* globalCtx, DmChar05* this) { + if (this->actor.objBankIndex == this->unk_18F) { + Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); + GetItem_Draw(globalCtx, GID_44); + } + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + this->actor.objBankIndex = this->unk_18F; + } +} + +void func_80AADE78(GlobalContext* globalCtx, DmChar05* this) { + if (this->actor.objBankIndex == this->unk_18F) { + Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); + GetItem_Draw(globalCtx, GID_45); + } + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + this->actor.objBankIndex = this->unk_18F; + } +} + +void func_80AADF54(GlobalContext* globalCtx, DmChar05* this) { + if (this->actor.objBankIndex == this->unk_18F) { + Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); + GetItem_Draw(globalCtx, GID_6B); + } + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + this->actor.objBankIndex = this->unk_18F; + } +} + +void func_80AAE030(GlobalContext* globalCtx, DmChar05* this) { + if (this->unk_18E != 0) { + if (this->actor.objBankIndex == this->unk_18F) { + Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); + GetItem_Draw(globalCtx, GID_03); + } + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + this->actor.objBankIndex = this->unk_18F; + } + } +} + +void func_80AAE114(GlobalContext* globalCtx, DmChar05* this) { + s32 sp34; + s16 sp24[] = { + GID_02, GID_6A, GID_70, GID_3A, GID_0E, GID_0F, GID_3E, GID_71, + }; + + sp34 = DMCHAR05_GET(&this->actor) - DMCHAR05_5; + if (this->actor.objBankIndex == this->unk_18F) { + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); + GetItem_Draw(globalCtx, sp24[sp34]); + } + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + this->actor.objBankIndex = this->unk_18F; + } +} diff --git a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.h b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.h index a2e1a6208..83bb67948 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.h +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.h @@ -7,11 +7,39 @@ struct DmChar05; typedef void (*DmChar05ActionFunc)(struct DmChar05*, GlobalContext*); +#define DMCHAR05_GET(thisx) ((thisx)->params) + +enum { + /* 0 */ DMCHAR05_0, + /* 1 */ DMCHAR05_1, + /* 2 */ DMCHAR05_2, + /* 3 */ DMCHAR05_3, + /* 4 */ DMCHAR05_4, + /* 5 */ DMCHAR05_5, + /* 6 */ DMCHAR05_6, + /* 7 */ DMCHAR05_7, + /* 8 */ DMCHAR05_8, + /* 9 */ DMCHAR05_9, + /* 10 */ DMCHAR05_10, + /* 11 */ DMCHAR05_11, + /* 12 */ DMCHAR05_12, +}; + typedef struct DmChar05 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ DmChar05ActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x2C]; + /* 0x018C */ s16 unk_18C; + /* 0x018E */ u8 unk_18E; + /* 0x018F */ u8 unk_18F; + /* 0x0190 */ Vec3f unk_190; + /* 0x019C */ u32 unk_19C; + /* 0x01A0 */ u32 unk_1A0; + /* 0x01A4 */ u32 unk_1A4; + /* 0x01A8 */ s32 unk_1A8; + /* 0x01AC */ s32 unk_1AC; + /* 0x01B0 */ s32 unk_1B0; + /* 0x01B4 */ u8 unk_1B4; } DmChar05; // size = 0x1B8 extern const ActorInit Dm_Char05_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 2933a97bf..6a9fb8555 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -11605,8 +11605,8 @@ 0x80AAD450:("func_80AAD450",), 0x80AAD4A8:("func_80AAD4A8",), 0x80AAD78C:("DmChar05_Update",), - 0x80AAD964:("func_80AAD964",), - 0x80AAD980:("func_80AAD980",), + 0x80AAD964:("DmChar05_OverrideLimbDraw",), + 0x80AAD980:("DmChar05_PostLimbDraw",), 0x80AAD998:("func_80AAD998",), 0x80AADA90:("func_80AADA90",), 0x80AADB4C:("func_80AADB4C",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 44de5a329..d58ac55d7 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1034,14 +1034,6 @@ D_0600AD68 = 0x0600AD68; D_06020550 = 0x06020550; -// ovl_Dm_Char05 - -D_060001D0 = 0x060001D0; -D_060010B0 = 0x060010B0; -D_060013D0 = 0x060013D0; -D_06001E70 = 0x06001E70; -D_060042B0 = 0x060042B0; - // ovl_Dm_Char06 D_060013A8 = 0x060013A8; From 009ad45f484444674a280ed7b1fbbb62e504c042 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sun, 13 Feb 2022 16:14:58 -0800 Subject: [PATCH 007/257] Add comment to Arrow_Ice xml and update DL names (#605) * Add comment to Arrow_Ice xml and update DL names * Update asset names * Improve texture names --- assets/xml/overlays/ovl_Arrow_Ice.xml | 11 ++++++----- src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/assets/xml/overlays/ovl_Arrow_Ice.xml b/assets/xml/overlays/ovl_Arrow_Ice.xml index 96c0f2522..9ac5d04e0 100644 --- a/assets/xml/overlays/ovl_Arrow_Ice.xml +++ b/assets/xml/overlays/ovl_Arrow_Ice.xml @@ -1,11 +1,12 @@ + - - - + + + - - + + diff --git a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c index 75002f17e..f9c4fc178 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -228,11 +228,11 @@ void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(this->radius * 0.2f, this->height * 3.0f, this->radius * 0.2f, MTXMODE_APPLY); Matrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, sIceArrowDL); + gSPDisplayList(POLY_XLU_DISP++, gIceArrowMaterialDL); gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 511 - (stateFrames * 5) % 512, 0, 128, 32, 1, 511 - (stateFrames * 10) % 512, 511 - (stateFrames * 10) % 512, 4, 16)); - gSPDisplayList(POLY_XLU_DISP++, sIceArrowVtxDL); + gSPDisplayList(POLY_XLU_DISP++, gIceArrowModelDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } From 7ba82882b2e5b4408318cabddcb6191f26ccb2ff Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sun, 13 Feb 2022 16:21:28 -0800 Subject: [PATCH 008/257] Clean up En_Giant header (#614) * Clean up En_Giant header * Run ./format.sh * Move defines to be near the enums * Move the limb enum to the object --- assets/xml/objects/object_giant.xml | 32 ++++----- src/overlays/actors/ovl_En_Giant/z_en_giant.c | 54 +++++++++++++- src/overlays/actors/ovl_En_Giant/z_en_giant.h | 70 +------------------ 3 files changed, 70 insertions(+), 86 deletions(-) diff --git a/assets/xml/objects/object_giant.xml b/assets/xml/objects/object_giant.xml index edaeee039..8698d176b 100644 --- a/assets/xml/objects/object_giant.xml +++ b/assets/xml/objects/object_giant.xml @@ -51,24 +51,24 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + 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 85f1798e3..4338988b8 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -5,7 +5,6 @@ */ #include "z_en_giant.h" -#include "objects/object_giant/object_giant.h" #define FLAGS 0x00000030 @@ -20,6 +19,59 @@ void EnGiant_PerformClockTowerSuccessActions(EnGiant* this, GlobalContext* globa void EnGiant_PlayClockTowerFailureAnimation(EnGiant* this, GlobalContext* globalCtx); void EnGiant_PerformCutsceneActions(EnGiant* this, GlobalContext* globalCtx); +#define GIANT_TYPE_IS_NOT_TERMINA_FIELD(type) (type > GIANT_TYPE_OCEAN_TERMINA_FIELD) +#define GIANT_TYPE_IS_TERMINA_FIELD(type) (type <= GIANT_TYPE_OCEAN_TERMINA_FIELD) +#define GIANT_TYPE_IS_CLOCK_TOWER_SUCCESS(type) \ + (type >= GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_SUCCESS && type <= GIANT_TYPE_OCEAN_CLOCK_TOWER_SUCCESS) +#define GIANT_TYPE_IS_CHAMBER_OR_ENDING(type) \ + (type >= GIANT_TYPE_MOUNTAIN_GIANTS_CHAMBER_AND_ENDING && type <= GIANT_TYPE_OCEAN_GIANTS_CHAMBER_AND_ENDING) +#define GIANT_TYPE_IS_CLOCK_TOWER_FAILURE(type) \ + (type >= GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_FAILURE && type <= GIANT_TYPE_OCEAN_CLOCK_TOWER_FAILURE) + +/** + * These values are used to index into sAnimations to pick the appropriate animation. + */ +typedef enum { + /* 0 */ GIANT_ANIMATION_LOOK_UP_START, + /* 1 */ GIANT_ANIMATION_LOOK_UP_LOOP, + /* 2 */ GIANT_ANIMATION_FALLING_OVER, + /* 3 */ GIANT_ANIMATION_RAISED_ARMS_START, + /* 4 */ GIANT_ANIMATION_RAISED_ARMS_LOOP, + /* 5 */ GIANT_ANIMATION_STRUGGLE_START, + /* 6 */ GIANT_ANIMATION_STRUGGLE_LOOP, + /* 7 */ GIANT_ANIMATION_IDLE_LOOP, + /* 8 */ GIANT_ANIMATION_WALKING_LOOP, + /* 9 */ GIANT_ANIMATION_BIG_CALL_START, + /* 10 */ GIANT_ANIMATION_BIG_CALL_LOOP, + /* 11 */ GIANT_ANIMATION_BIG_CALL_END, + /* 12 */ GIANT_ANIMATION_SMALL_CALL_START, + /* 13 */ GIANT_ANIMATION_SMALL_CALL_LOOP, + /* 14 */ GIANT_ANIMATION_SMALL_CALL_END, + /* 15 */ GIANT_ANIMATION_MAX +} GiantAnimationIndex; + +/** + * Used as values for csAction. The UNKNOWN ones are never used in-game. + */ +typedef enum { + /* 0 */ GIANT_CS_ACTION_NONE, + /* 1 */ GIANT_CS_ACTION_IDLE, + /* 2 */ GIANT_CS_ACTION_WALKING, + /* 3 */ GIANT_CS_ACTION_LOOKING_UP, + /* 4 */ GIANT_CS_ACTION_RAISING_ARMS, + /* 5 */ GIANT_CS_ACTION_STRUGGLING, + /* 6 */ GIANT_CS_ACTION_FALLING_OVER, + /* 7 */ GIANT_CS_ACTION_IDLE_FADE_IN, + /* 8 */ GIANT_CS_ACTION_TALKING, + /* 9 */ GIANT_CS_ACTION_DONE_TALKING, + /* 10 */ GIANT_CS_ACTION_TEACHING_OATH_TO_ORDER, + /* 11 */ GIANT_CS_ACTION_PLAYER_LEARNED_OATH_TO_ORDER, + /* 12 */ GIANT_CS_ACTION_UNKNOWN_12, + /* 13 */ GIANT_CS_ACTION_UNKNOWN_13, + /* 14 */ GIANT_CS_ACTION_UNKNOWN_14, + /* 15 */ GIANT_CS_ACTION_HOLDING_UP_MOON_IN_CLOCK_TOWER +} GiantCsActionIndex; + const ActorInit En_Giant_InitVars = { ACTOR_EN_GIANT, ACTORCAT_NPC, diff --git a/src/overlays/actors/ovl_En_Giant/z_en_giant.h b/src/overlays/actors/ovl_En_Giant/z_en_giant.h index e28aa2a32..c8d45ad39 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.h +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.h @@ -2,13 +2,9 @@ #define Z_EN_GIANT_H #include "global.h" +#include "objects/object_giant/object_giant.h" #define GIANT_TYPE(thisx) ((thisx)->params & 0xF) -#define GIANT_TYPE_IS_NOT_TERMINA_FIELD(type) (type > GIANT_TYPE_OCEAN_TERMINA_FIELD) -#define GIANT_TYPE_IS_TERMINA_FIELD(type) (type <= GIANT_TYPE_OCEAN_TERMINA_FIELD) -#define GIANT_TYPE_IS_CLOCK_TOWER_SUCCESS(type) (type >= GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_SUCCESS && type <= GIANT_TYPE_OCEAN_CLOCK_TOWER_SUCCESS) -#define GIANT_TYPE_IS_CHAMBER_OR_ENDING(type) (type >= GIANT_TYPE_MOUNTAIN_GIANTS_CHAMBER_AND_ENDING && type <= GIANT_TYPE_OCEAN_GIANTS_CHAMBER_AND_ENDING) -#define GIANT_TYPE_IS_CLOCK_TOWER_FAILURE(type) (type >= GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_FAILURE && type <= GIANT_TYPE_OCEAN_CLOCK_TOWER_FAILURE) /** * The giants are divided into types based on where in the game they appear. @@ -42,70 +38,6 @@ typedef enum { /* 15 */ GIANT_TYPE_OCEAN_CLOCK_TOWER_FAILURE, } GiantType; -/** - * These values are used to index into sAnimationTable to pick the appropriate animation. - */ -typedef enum { - /* 0 */ GIANT_ANIMATION_LOOK_UP_START, - /* 1 */ GIANT_ANIMATION_LOOK_UP_LOOP, - /* 2 */ GIANT_ANIMATION_FALLING_OVER, - /* 3 */ GIANT_ANIMATION_RAISED_ARMS_START, - /* 4 */ GIANT_ANIMATION_RAISED_ARMS_LOOP, - /* 5 */ GIANT_ANIMATION_STRUGGLE_START, - /* 6 */ GIANT_ANIMATION_STRUGGLE_LOOP, - /* 7 */ GIANT_ANIMATION_IDLE_LOOP, - /* 8 */ GIANT_ANIMATION_WALKING_LOOP, - /* 9 */ GIANT_ANIMATION_BIG_CALL_START, - /* 10 */ GIANT_ANIMATION_BIG_CALL_LOOP, - /* 11 */ GIANT_ANIMATION_BIG_CALL_END, - /* 12 */ GIANT_ANIMATION_SMALL_CALL_START, - /* 13 */ GIANT_ANIMATION_SMALL_CALL_LOOP, - /* 14 */ GIANT_ANIMATION_SMALL_CALL_END, - /* 15 */ GIANT_ANIMATION_MAX -} GiantAnimationIndex; - -/** - * Used as values for csAction. The UNKNOWN ones are never used in-game. - */ -typedef enum { - /* 0 */ GIANT_CS_ACTION_NONE, - /* 1 */ GIANT_CS_ACTION_IDLE, - /* 2 */ GIANT_CS_ACTION_WALKING, - /* 3 */ GIANT_CS_ACTION_LOOKING_UP, - /* 4 */ GIANT_CS_ACTION_RAISING_ARMS, - /* 5 */ GIANT_CS_ACTION_STRUGGLING, - /* 6 */ GIANT_CS_ACTION_FALLING_OVER, - /* 7 */ GIANT_CS_ACTION_IDLE_FADE_IN, - /* 8 */ GIANT_CS_ACTION_TALKING, - /* 9 */ GIANT_CS_ACTION_DONE_TALKING, - /* 10 */ GIANT_CS_ACTION_TEACHING_OATH_TO_ORDER, - /* 11 */ GIANT_CS_ACTION_PLAYER_LEARNED_OATH_TO_ORDER, - /* 12 */ GIANT_CS_ACTION_UNKNOWN_12, - /* 13 */ GIANT_CS_ACTION_UNKNOWN_13, - /* 14 */ GIANT_CS_ACTION_UNKNOWN_14, - /* 15 */ GIANT_CS_ACTION_HOLDING_UP_MOON_IN_CLOCK_TOWER -} GiantCsActionIndex; - -typedef enum { - /* 0 */ GIANT_LIMB_NONE, - /* 1 */ GIANT_LIMB_HEAD, - /* 2 */ GIANT_LIMB_LEFT_THIGH, - /* 3 */ GIANT_LIMB_LEFT_LOWER_LEG, - /* 4 */ GIANT_LIMB_LEFT_FOOT, - /* 5 */ GIANT_LIMB_RIGHT_THIGH, - /* 6 */ GIANT_LIMB_RIGHT_LOWER_LEG, - /* 7 */ GIANT_LIMB_RIGHT_FOOT, - /* 8 */ GIANT_LIMB_LEFT_SHOULDER, - /* 9 */ GIANT_LIMB_LEFT_UPPER_ARM, - /* 10 */ GIANT_LIMB_LEFT_FOREARM, - /* 11 */ GIANT_LIMB_LEFT_HAND, - /* 12 */ GIANT_LIMB_RIGHT_SHOULDER, - /* 13 */ GIANT_LIMB_RIGHT_UPPER_ARM, - /* 14 */ GIANT_LIMB_RIGHT_FOREARM, - /* 15 */ GIANT_LIMB_RIGHT_HAND, - /* 16 */ GIANT_LIMB_MAX, -} EnGiantLimbs; - struct EnGiant; typedef void (*EnGiantActionFunc)(struct EnGiant*, GlobalContext*); From 0625803c17e89a7feafd387df5f867e6ed5c36dc Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 13 Feb 2022 16:30:30 -0800 Subject: [PATCH 009/257] Ovl_En_Cne_01 Ok and Documented (#641) * Decomp and document Cne01 * Document object_cne * split enhy header from z64 * Cleanup * Actually include new z_en_hy header * Actor flags * Add header to object_cne * screen defines * Useage of ENHY_LIMB_MAX --- assets/xml/objects/object_cne.xml | 93 ++--- include/functions.h | 16 +- include/variables.h | 3 - include/z64.h | 24 -- include/z_en_hy.h | 92 +++++ spec | 3 +- src/code/z_en_hy.c | 126 ++++--- .../actors/ovl_En_Cne_01/z_en_cne_01.c | 343 ++++++++++++++---- .../actors/ovl_En_Cne_01/z_en_cne_01.h | 10 +- tools/disasm/functions.txt | 18 +- tools/disasm/variables.txt | 6 +- undefined_syms.txt | 25 +- 12 files changed, 506 insertions(+), 253 deletions(-) create mode 100644 include/z_en_hy.h diff --git a/assets/xml/objects/object_cne.xml b/assets/xml/objects/object_cne.xml index 72447ceec..acddaee86 100644 --- a/assets/xml/objects/object_cne.xml +++ b/assets/xml/objects/object_cne.xml @@ -1,47 +1,54 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/functions.h b/include/functions.h index f71b4a5fa..69abef304 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1478,21 +1478,7 @@ void SoundSource_UpdateAll(GlobalContext* globalCtx); void SoundSource_PlaySfxAtFixedWorldPos(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u16 sfxId); void SoundSource_PlaySfxEachFrameAtFixedWorldPos(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u16 sfxId); u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx); -s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex); -Actor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx); -void EnHy_ChangeObjectAndAnim(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex); -s32 EnHy_UpdateSkelAnime(EnHy* enHy, GlobalContext* globalCtx); -void EnHy_Blink(EnHy* enHy, s32 arg1); -s32 EnHy_Init(EnHy* enHy, GlobalContext* globalCtx, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex); -void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, Actor* arg2, s16 arg3, s16 arg4); -s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5); -s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3); -s32 EnHy_SetPointFowards(EnHy* enHy, GlobalContext* globalCtx, f32 gravity, s16 animIndex); -s32 EnHy_SetPointBackwards(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex); -s32 EnHy_MoveForwards(EnHy* enHy, f32 arg1); -s32 EnHy_MoveBackwards(EnHy* enHy, f32 arg1); -void EnHy_UpdateCollider(EnHy* enHy, GlobalContext* globalCtx); -s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 arg2); + u16 Text_GetFaceReaction(GlobalContext* globalCtx, u32 reactionSet); void EnvFlags_UnsetAll(GlobalContext* globalCtx); void EnvFlags_Set(GlobalContext* globalCtx, s16 flag); diff --git a/include/variables.h b/include/variables.h index 93cec7fe0..19234ff0a 100644 --- a/include/variables.h +++ b/include/variables.h @@ -881,9 +881,6 @@ extern s801BB170 D_801BB170[118]; // extern UNK_TYPE1 D_801BC210; extern Gfx D_801BC240[9]; extern Gfx D_801BC288[3]; -// extern UNK_TYPE1 D_801BC3F0; -// extern UNK_TYPE1 D_801BC400; -// extern UNK_TYPE1 D_801BC410; // extern UNK_TYPE1 D_801BC41E; extern ActorCutscene actorCutscenesGlobalCutscenes[8]; extern s16 actorCutsceneCurrent; diff --git a/include/z64.h b/include/z64.h index c1fd33a07..ae912f488 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1373,30 +1373,6 @@ typedef struct { /* 0x24 */ s16 unk_24; } struct_800BD888_arg1; // size = 0x28 -typedef struct EnHy { - /* 0x000 */ Actor actor; - /* 0x144 */ UNK_TYPE1 unk_144[0x8]; - /* 0x14C */ SkelAnime skelAnime; - /* 0x190 */ s8 unk190; - /* 0x191 */ s8 unk191; - /* 0x192 */ s8 unk192; - /* 0x193 */ s8 animObjIndex; - /* 0x194 */ ColliderCylinder collider; - /* 0x1E0 */ UNK_TYPE1 unk_1E0[0x4]; - /* 0x1E4 */ Path* path; - /* 0x1E8 */ s16 curPoint; - /* 0x1EA */ UNK_TYPE1 unk_1EA[0x2]; - /* 0x1EC */ Vec3f leftFootPos; - /* 0x1F8 */ Vec3f rightFootPos; - /* 0x204 */ u8 isLeftFootOnGround; - /* 0x205 */ u8 isRightFootOnGround; - /* 0x206 */ Vec3s jointTable[16]; - /* 0x266 */ Vec3s morphTable[16]; - /* 0x2C6 */ UNK_TYPE1 unk_2C6[0x120]; - /* 0x3E6 */ s16 eyeTexIndex; - /* 0x3E8 */ s16 blinkTimer; -} EnHy; - typedef struct { /* 0x0 */ u8 unk0; /* 0x4 */ s32 unk4; diff --git a/include/z_en_hy.h b/include/z_en_hy.h new file mode 100644 index 000000000..df94df171 --- /dev/null +++ b/include/z_en_hy.h @@ -0,0 +1,92 @@ +#ifndef Z_EN_HY_H +#define Z_EN_HY_H + +#include "global.h" + +struct EnHy; + +#define ENHY_LIMB_MAX 16 + +typedef enum { + /* 0 */ ENHY_ANIMATION_AOB_0, + /* 1 */ ENHY_ANIMATION_BOJ_1, + /* 2 */ ENHY_ANIMATION_BOJ_2, + /* 3 */ ENHY_ANIMATION_BOJ_3, + /* 4 */ ENHY_ANIMATION_BOJ_4, + /* 5 */ ENHY_ANIMATION_BOJ_5, + /* 6 */ ENHY_ANIMATION_BBA_6, + /* 7 */ ENHY_ANIMATION_BJI_7, + /* 8 */ ENHY_ANIMATION_BJI_8, + /* 9 */ ENHY_ANIMATION_BJI_9, + /* 10 */ ENHY_ANIMATION_BOJ_10, + /* 11 */ ENHY_ANIMATION_OS_ANIME_11, + /* 12 */ ENHY_ANIMATION_BOJ_12, + /* 13 */ ENHY_ANIMATION_BOJ_13, + /* 14 */ ENHY_ANIMATION_BOJ_14, + /* 15 */ ENHY_ANIMATION_BOJ_15, + /* 16 */ ENHY_ANIMATION_BOJ_16, + /* 17 */ ENHY_ANIMATION_BOJ_17, + /* 18 */ ENHY_ANIMATION_BOJ_18, + /* 19 */ ENHY_ANIMATION_BOJ_19, + /* 20 */ ENHY_ANIMATION_BOJ_20, + /* 21 */ ENHY_ANIMATION_MAX +} EnHyAnimation; + +typedef void (*EnHyActionFunc)(struct EnHy*, GlobalContext*); + +typedef struct EnHy { + /* 0x000 */ Actor actor; + /* 0x144 */ EnHyActionFunc actionFunc; + /* 0x148 */ EnHyActionFunc tmpActionFunc; + /* 0x14C */ SkelAnime skelAnime; + /* 0x190 */ s8 headObjIndex; // Limb 15 + /* 0x191 */ s8 skelUpperObjIndex; // Limbs 8-14 + /* 0x192 */ s8 skelLowerObjIndex; // Limbs 1-7 + /* 0x193 */ s8 animObjIndex; + /* 0x194 */ ColliderCylinder collider; + /* 0x1E0 */ u16 textId; + /* 0x1E2 */ u8 waitingOnInit; + /* 0x1E3 */ u8 inMsgState3; + /* 0x1E4 */ Path* path; + /* 0x1E8 */ s16 curPoint; + /* 0x1EC */ Vec3f leftFootPos; + /* 0x1F8 */ Vec3f rightFootPos; + /* 0x204 */ u8 isLeftFootOnGround; + /* 0x205 */ u8 isRightFootOnGround; + /* 0x206 */ Vec3s jointTable[ENHY_LIMB_MAX]; + /* 0x266 */ Vec3s morphTable[ENHY_LIMB_MAX]; + /* 0x2C6 */ Vec3s focusTarget; + /* 0x2CC */ Vec3s headRot; + /* 0x2D2 */ Vec3s torsoRot; + /* 0x2D8 */ Vec3s tmpFocusTarget; + /* 0x2DE */ Vec3s tmpHeadRot; + /* 0x2E4 */ Vec3s tmpTorsoRot; + /* 0x2EA */ s16 limbRotTableY[16]; + /* 0x30A */ s16 limbRotTableZ[16]; + /* 0x32C */ Vec3f bodyPartsPos[15]; + /* 0x3E0 */ UNK_TYPE1 unk_3E0[0x6]; + /* 0x3E6 */ s16 eyeTexIndex; + /* 0x3E8 */ s16 blinkTimer; +} EnHy; // size = 0x3EC + +extern s8 gEnHyBodyParts[]; +extern s8 gEnHyBodyPartsIndex[]; +extern u8 gEnHyShadowSize[]; + +s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex); +struct EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx); +void EnHy_ChangeObjectAndAnim(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex); +s32 EnHy_UpdateSkelAnime(EnHy* enHy, GlobalContext* globalCtx); +void EnHy_Blink(EnHy* enHy, s32 arg1); +s32 EnHy_Init(EnHy* enHy, GlobalContext* globalCtx, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex); +void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, struct EnDoor* door, s16 arg3, s16 arg4); +s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5); +s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3); +s32 EnHy_SetPointFowards(EnHy* enHy, GlobalContext* globalCtx, f32 gravity, s16 animIndex); +s32 EnHy_SetPointBackwards(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex); +s32 EnHy_MoveForwards(EnHy* enHy, f32 speedTarget); +s32 EnHy_MoveBackwards(EnHy* enHy, f32 speedTarget); +void EnHy_UpdateCollider(EnHy* enHy, GlobalContext* globalCtx); +s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThreshold); + +#endif // Z_EN_HY_H diff --git a/spec b/spec index bfc1e0ef5..c4de1495c 100644 --- a/spec +++ b/spec @@ -2477,8 +2477,7 @@ beginseg name "ovl_En_Cne_01" compress include "build/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.o" - include "build/data/ovl_En_Cne_01/ovl_En_Cne_01.data.o" - include "build/data/ovl_En_Cne_01/ovl_En_Cne_01.reloc.o" + include "build/src/overlays/actors/ovl_En_Cne_01/ovl_En_Cne_01_reloc.o" endseg beginseg diff --git a/src/code/z_en_hy.c b/src/code/z_en_hy.c index e0c487262..4fac2c2ae 100644 --- a/src/code/z_en_hy.c +++ b/src/code/z_en_hy.c @@ -3,78 +3,79 @@ * Description: Unused System for NPCs (includes animation, door interaction, blinking, pathing, and collider helpers) */ -#include "global.h" +#include "z_en_hy.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" +#include "objects/object_aob/object_aob.h" +#include "objects/object_bba/object_bba.h" +#include "objects/object_bji/object_bji.h" +#include "objects/object_boj/object_boj.h" +#include "objects/object_os_anime/object_os_anime.h" -extern AnimationHeader D_0600007C; -extern AnimationHeader D_0600066C; -extern AnimationHeader D_0600071C; -extern AnimationHeader D_060008C0; -extern AnimationHeader D_06000AB0; -extern AnimationHeader D_06000FDC; -extern AnimationHeader D_06001494; -extern AnimationHeader D_06001908; -extern AnimationHeader D_06001EE0; -extern AnimationHeader D_06005DC4; -extern AnimationHeader D_06005D9C; -extern AnimationHeader D_0600DED8; -extern AnimationHeader D_0600F920; -extern AnimationHeader D_0600FC1C; -extern AnimationHeader D_0600FEE4; -extern AnimationHeader D_06010330; - -static ActorAnimationEntryS animations[] = { - { &D_0600007C, 1.0f, 0, -1, 0, 0 }, { &D_06001494, 1.0f, 0, -1, 0, 0 }, { &D_06001494, 1.0f, 0, -1, 0, -8 }, - { &D_06001908, 1.0f, 0, -1, 0, 0 }, { &D_06001908, 1.0f, 0, -1, 0, -8 }, { &D_060008C0, 1.0f, 0, -1, 0, 0 }, - { &D_06005DC4, 1.0f, 0, -1, 0, 0 }, { &D_06000FDC, 1.0f, 0, -1, 0, 0 }, { &D_06000AB0, 1.0f, 0, -1, 0, -8 }, - { &D_0600066C, 1.0f, 0, -1, 0, 0 }, { &D_0600071C, 1.0f, 0, -1, 0, 0 }, { &D_06001EE0, 1.0f, 0, -1, 0, 0 }, - { &D_0600DED8, 1.5f, 0, -1, 2, 0 }, { &D_0600F920, 1.5f, 0, -1, 2, 0 }, { &D_0600FC1C, 1.0f, 0, -1, 0, 0 }, - { &D_0600FEE4, 1.0f, 0, -1, 0, 0 }, { &D_06010330, 1.0f, 0, -1, 0, 0 }, { &D_0600FC1C, 1.0f, 0, -1, 0, -8 }, - { &D_0600FEE4, 1.0f, 0, -1, 0, -8 }, { &D_06010330, 1.0f, 0, -1, 0, -8 }, { &D_06005D9C, 1.0f, 0, -1, 0, -8 }, +ActorAnimationEntryS sAnimations[] = { + { &object_aob_Anim_00007C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_001494, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_001494, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, + { &object_boj_Anim_001908, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_001908, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, + { &object_boj_Anim_0008C0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_bba_Anim_005DC4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_bji_Anim_000FDC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_bji_Anim_000AB0, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, + { &object_bji_Anim_00066C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_00071C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_os_anime_Anim_001EE0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_00DED8, 1.5f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_boj_Anim_00F920, 1.5f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_boj_Anim_00FC1C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_00FEE4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_010330, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_00FC1C, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, + { &object_boj_Anim_00FEE4, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, + { &object_boj_Anim_010330, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, + { &object_boj_Anim_005D9C, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, }; -s8 D_801BC3F0[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2 }; +s8 gEnHyBodyParts[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2 }; -s8 D_801BC400[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13, 0 }; +s8 gEnHyBodyPartsIndex[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; -u8 D_801BC410[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +u8 gEnHyShadowSize[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { s16 frameCount; s32 isChanged = false; - if (animIndex >= 0 && animIndex <= 20) { + if (animIndex >= ENHY_ANIMATION_AOB_0 && animIndex < ENHY_ANIMATION_MAX) { isChanged = true; - frameCount = animations[animIndex].frameCount; + frameCount = sAnimations[animIndex].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(&animations[animIndex].animationSeg->common); + frameCount = Animation_GetLastFrame(&sAnimations[animIndex].animationSeg->common); } - Animation_Change(skelAnime, animations[animIndex].animationSeg, animations[animIndex].playbackSpeed, - animations[animIndex].frame, frameCount, animations[animIndex].mode, - animations[animIndex].transitionRate); + Animation_Change(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed, + sAnimations[animIndex].frame, frameCount, sAnimations[animIndex].mode, + sAnimations[animIndex].transitionRate); } return isChanged; } -//! @TODO: Return Door instance when c and h files are split -Actor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) { - Actor* nearestDoor = NULL; +EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) { + EnDoor* nearestDoor = NULL; Actor* doorIter = NULL; - Actor* door; + EnDoor* door; f32 dist; s32 isSetup = false; f32 minDist = 0.0f; do { doorIter = SubS_FindActor(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); - door = doorIter; - dist = Actor_DistanceBetweenActors(actor, door); + door = (EnDoor*)doorIter; + dist = Actor_DistanceBetweenActors(actor, &door->actor); if (!isSetup || (dist < minDist)) { nearestDoor = door; minDist = dist; isSetup = true; } - doorIter = door->next; + doorIter = door->actor.next; } while (doorIter != NULL); if (1) {} @@ -111,27 +112,29 @@ void EnHy_Blink(EnHy* enHy, s32 eyeTexMaxIndex) { s32 EnHy_Init(EnHy* enHy, GlobalContext* globalCtx, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex) { s32 isInitialized = false; - if ((func_8013D8DC(enHy->animObjIndex, globalCtx) == 1) && (func_8013D8DC(enHy->unk190, globalCtx) == 1) && - (func_8013D8DC(enHy->unk191, globalCtx) == 1) && (func_8013D8DC(enHy->unk192, globalCtx) == 1)) { - enHy->actor.objBankIndex = enHy->unk192; + if ((func_8013D8DC(enHy->animObjIndex, globalCtx) == true) && + (func_8013D8DC(enHy->headObjIndex, globalCtx) == true) && + (func_8013D8DC(enHy->skelUpperObjIndex, globalCtx) == true) && + (func_8013D8DC(enHy->skelLowerObjIndex, globalCtx) == true)) { + enHy->actor.objBankIndex = enHy->skelLowerObjIndex; isInitialized = true; ActorShape_Init(&enHy->actor.shape, 0.0f, NULL, 0.0f); gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[enHy->actor.objBankIndex].segment); SkelAnime_InitFlex(globalCtx, &enHy->skelAnime, skeletonHeaderSeg, NULL, enHy->jointTable, enHy->morphTable, - 16); + ENHY_LIMB_MAX); EnHy_ChangeObjectAndAnim(enHy, globalCtx, animIndex); } + return isInitialized; } -//! @TODO: Should just take EnDoor instead of actor when c and h are split -void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, Actor* door, s16 arg3, s16 arg4) { +void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, EnDoor* door, s16 arg3, s16 arg4) { s32 pad; s8 sp3B; Vec3f offset; f32 phi_f0; - Actor_OffsetOfPointInActorCoords(door, &offset, &enHy->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&door->actor, &offset, &enHy->actor.world.pos); phi_f0 = (offset.z >= 0.0f) ? 1.0f : -1.0f; sp3B = ((s8)phi_f0 < 0) ? 0 : 2; EnHy_ChangeObjectAndAnim(enHy, globalCtx, (sp3B == 0) ? arg3 : arg4); @@ -139,14 +142,14 @@ void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, Actor* door, s16 arg3, enHy->skelAnime.prevTransl = *enHy->skelAnime.jointTable; enHy->skelAnime.moveFlags |= 3; AnimationContext_SetMoveActor(globalCtx, &enHy->actor, &enHy->skelAnime, 1.0f); - ((EnDoor*)door)->unk_1A1 = 1; - ((EnDoor*)door)->unk_1A0 = sp3B; + door->unk_1A1 = 1; + door->unk_1A0 = sp3B; } s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5) { s32 ret = false; s16 yaw; - Actor* door; + EnDoor* door; s32 pad; if (func_8013D68C(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { @@ -154,7 +157,7 @@ s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3 if (door != NULL) { ret = true; func_800F0BB4(enHy, globalCtx, door, arg3, arg4); - yaw = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->world.pos); + yaw = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->actor.world.pos); enHy->actor.world.pos.x += arg5 * Math_SinS(yaw); enHy->actor.world.pos.z += arg5 * Math_CosS(yaw); enHy->actor.world.rot.y = -yaw; @@ -168,7 +171,7 @@ s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3 s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3) { s32 ret = false; s32 pad; - Actor* door; + EnDoor* door; enHy->curPoint = 0; if (func_8013D68C(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { @@ -176,10 +179,10 @@ s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3) { if (door != NULL) { ret = true; func_800F0BB4(enHy, globalCtx, door, arg2, arg3); - enHy->actor.shape.rot.y = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->world.pos); + enHy->actor.shape.rot.y = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->actor.world.pos); enHy->actor.world.rot.y = enHy->actor.shape.rot.y; enHy->actor.gravity = 0.0f; - enHy->actor.flags &= ~1; + enHy->actor.flags &= ~ACTOR_FLAG_1; } } return ret; @@ -187,16 +190,16 @@ s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3) { s32 EnHy_SetPointFowards(EnHy* enHy, GlobalContext* globalCtx, f32 gravity, s16 animIndex) { enHy->actor.gravity = gravity; - enHy->actor.flags |= 1; + enHy->actor.flags |= ACTOR_FLAG_1; EnHy_ChangeObjectAndAnim(enHy, globalCtx, animIndex); enHy->curPoint++; - return 0; + return false; } s32 EnHy_SetPointBackwards(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex) { EnHy_ChangeObjectAndAnim(enHy, globalCtx, animIndex); enHy->curPoint--; - return 0; + return false; } s32 EnHy_MoveForwards(EnHy* enHy, f32 speedTarget) { @@ -212,6 +215,7 @@ s32 EnHy_MoveForwards(EnHy* enHy, f32 speedTarget) { reachedEnd = true; } } + return reachedEnd; } @@ -228,6 +232,7 @@ s32 EnHy_MoveBackwards(EnHy* enHy, f32 speedTarget) { reachedEnd = true; } } + return reachedEnd; } @@ -267,5 +272,6 @@ s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThr if (enHy->isRightFootOnGround && !wasRightFootOnGround && isFootOnGround) { Actor_PlaySfxAtPos(&enHy->actor, sfxId); } - return 0; + + return false; } diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index 698878d71..8b47025e4 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -5,8 +5,9 @@ */ #include "z_en_cne_01.h" +#include "objects/object_cne/object_cne.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_8 | ACTOR_FLAG_1) #define THIS ((EnCne01*)thisx) @@ -15,12 +16,12 @@ void EnCne01_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnCne01_Update(Actor* thisx, GlobalContext* globalCtx); void EnCne01_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809CB520(EnCne01* this, GlobalContext* globalCtx); -void func_809CB5A0(EnCne01* this, GlobalContext* globalCtx); -void func_809CB5D8(EnCne01* this, GlobalContext* globalCtx); -void func_809CB5FC(EnCne01* this, GlobalContext* globalCtx); +void EnCne01_Walk(EnHy* this, GlobalContext* globalCtx); +void EnCne01_FaceForward(EnHy* this, GlobalContext* globalCtx); +void EnCne01_Talk(EnHy* this, GlobalContext* globalCtx); + +typedef enum { CNE01_DMG_EFF_NONE } EnCne01DamageEffect; -#if 0 const ActorInit En_Cne_01_InitVars = { ACTOR_EN_CNE_01, ACTORCAT_NPC, @@ -33,85 +34,295 @@ const ActorInit En_Cne_01_InitVars = { (ActorFunc)EnCne01_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809CBF00 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 64, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_809CBF2C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_809CBF38 = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(0, 0x0), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(0, 0x0), - /* Zora boomerang */ DMG_ENTRY(0, 0x0), - /* Normal arrow */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x0), - /* Goron punch */ DMG_ENTRY(0, 0x0), - /* Sword */ DMG_ENTRY(0, 0x0), - /* Goron pound */ DMG_ENTRY(0, 0x0), - /* Fire arrow */ DMG_ENTRY(0, 0x0), - /* Ice arrow */ DMG_ENTRY(0, 0x0), - /* Light arrow */ DMG_ENTRY(0, 0x0), - /* Goron spikes */ DMG_ENTRY(0, 0x0), - /* Deku spin */ DMG_ENTRY(0, 0x0), - /* Deku bubble */ DMG_ENTRY(0, 0x0), - /* Deku launch */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(0, 0x0), - /* Zora punch */ DMG_ENTRY(0, 0x0), - /* Spin attack */ DMG_ENTRY(0, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(0, 0x0), +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Deku Stick */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Horse trample */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Explosives */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Zora boomerang */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Normal arrow */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Hookshot */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Goron punch */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Sword */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Goron pound */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Fire arrow */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Ice arrow */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Light arrow */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Goron spikes */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Deku spin */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Deku bubble */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Deku launch */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Zora barrier */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Normal shield */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Light ray */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Thrown object */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Zora punch */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Spin attack */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Sword beam */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Unblockable */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Powder Keg */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), }; -#endif +static u16 D_809CBF58[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; -extern ColliderCylinderInit D_809CBF00; -extern CollisionCheckInfoInit2 D_809CBF2C; -extern DamageTable D_809CBF38; +void EnCne01_UpdateModel(EnCne01* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f focus; -extern UNK_TYPE D_060000F0; -extern UNK_TYPE D_06001300; + EnHy_UpdateSkelAnime(&this->enHy, globalCtx); + if (func_8013D5E8(this->enHy.actor.shape.rot.y, 0x36B0, this->enHy.actor.yawTowardsPlayer)) { + focus.x = player->actor.world.pos.x; + focus.y = player->bodyPartsPos[7].y + 3.0f; + focus.z = player->actor.world.pos.z; + func_8013D2E0(&focus, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.focusTarget, + &this->enHy.headRot, &this->enHy.torsoRot, D_809CBF58); + } else { + Math_SmoothStepToS(&this->enHy.focusTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.focusTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.headRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.headRot.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.torsoRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.torsoRot.y, 0, 4, 0x3E8, 1); + } + func_8013D9C8(globalCtx, this->enHy.limbRotTableY, this->enHy.limbRotTableZ, ARRAY_COUNT(this->enHy.limbRotTableY)); + EnHy_UpdateCollider(&this->enHy, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB290.s") +s32 EnCne01_TestIsTalking(EnCne01* this, GlobalContext* globalCtx) { + s32 isTalking = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB404.s") + if (Actor_ProcessTalkRequest(&this->enHy.actor, &globalCtx->state)) { + isTalking = true; + this->enHy.textId = 0x10B9; + this->enHy.tmpFocusTarget = this->enHy.focusTarget; + this->enHy.tmpHeadRot = this->enHy.headRot; + this->enHy.tmpTorsoRot = this->enHy.torsoRot; + this->enHy.tmpActionFunc = this->enHy.actionFunc; + this->enHy.actionFunc = EnCne01_Talk; + } + return isTalking; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB4A0.s") +s32 func_809CB4A0(EnCne01* this, GlobalContext* globalCtx) { + s16 x; + s16 y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB520.s") + Actor_GetScreenPos(globalCtx, &this->enHy.actor, &x, &y); + //! @bug: Both x and y conditionals are always true, || should be an && + if (!this->enHy.waitingOnInit && ((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT))) { + func_800B85E0(&this->enHy.actor, globalCtx, 30.0f, EXCH_ITEM_2E); + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB5A0.s") +void EnCne01_FinishInit(EnHy* this, GlobalContext* globalCtx) { + if (EnHy_Init(this, globalCtx, &gCneSkel, ENHY_ANIMATION_OS_ANIME_11)) { + this->actor.flags |= ACTOR_FLAG_1; + this->actor.draw = EnCne01_Draw; + this->waitingOnInit = false; + if (ENCNE01_GET_PATH(&this->actor) == ENCNE01_NO_PATH) { + this->actionFunc = EnCne01_FaceForward; + } else { + this->actionFunc = EnCne01_Walk; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB5D8.s") +void EnCne01_Walk(EnHy* this, GlobalContext* globalCtx) { + if (EnHy_MoveForwards(this, 1.0f)) { + this->curPoint = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB5FC.s") +void EnCne01_FaceForward(EnHy* this, GlobalContext* globalCtx) { + this->actor.shape.rot = this->actor.world.rot; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/EnCne01_Init.s") +void EnCne01_Talk(EnHy* this, GlobalContext* globalCtx) { + s16 yaw; + u8 talkstate; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/EnCne01_Destroy.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xFA0, 1); + talkstate = Message_GetState(&globalCtx->msgCtx); + this->inMsgState3 = (talkstate == 3) ? true : false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/EnCne01_Update.s") + switch (talkstate) { + case 0: + yaw = ABS_ALT(this->actor.shape.rot.y - this->actor.yawTowardsPlayer); + if (yaw < 0x64) { + func_801518B0(globalCtx, this->textId, NULL); + } + break; + case 2: + this->actor.textId = 0; + this->focusTarget = this->tmpFocusTarget; + this->headRot = this->tmpHeadRot; + this->torsoRot = this->tmpTorsoRot; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc = this->tmpActionFunc; + this->tmpActionFunc = NULL; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB920.s") +void EnCne01_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnCne01* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CBBC8.s") + this->enHy.animObjIndex = func_8013D924(OBJECT_OS_ANIME, globalCtx); + this->enHy.headObjIndex = func_8013D924(OBJECT_CNE, globalCtx); + this->enHy.skelUpperObjIndex = func_8013D924(OBJECT_CNE, globalCtx); + this->enHy.skelLowerObjIndex = func_8013D924(OBJECT_CNE, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CBCA0.s") + if ((this->enHy.animObjIndex < 0) || (this->enHy.headObjIndex < 0) || (this->enHy.skelUpperObjIndex < 0) || + (this->enHy.skelLowerObjIndex < 0)) { + Actor_MarkForDeath(&this->enHy.actor); + } + this->enHy.actor.draw = NULL; + Collider_InitCylinder(globalCtx, &this->enHy.collider); + Collider_SetCylinder(globalCtx, &this->enHy.collider, &this->enHy.actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->enHy.actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->enHy.actor.flags &= ~ACTOR_FLAG_1; + this->enHy.path = func_8013D648(globalCtx, ENCNE01_GET_PATH(&this->enHy.actor), ENCNE01_NO_PATH); + this->enHy.waitingOnInit = true; + Actor_SetScale(&this->enHy.actor, 0.01f); + this->enHy.actionFunc = EnCne01_FinishInit; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/EnCne01_Draw.s") +void EnCne01_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnCne01* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->enHy.collider); +} + +void EnCne01_Update(Actor* thisx, GlobalContext* globalCtx) { + EnCne01* this = THIS; + + EnCne01_TestIsTalking(this, globalCtx); + this->enHy.actionFunc(&this->enHy, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, &this->enHy.actor, 0.0f, 0.0f, 0.0f, 4); + EnCne01_UpdateModel(this, globalCtx); + func_809CB4A0(this, globalCtx); +} + +s32 EnCne01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnCne01* this = THIS; + s8 bodyPart; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + bodyPart = gEnHyBodyParts[limbIndex]; + if (bodyPart >= 0) { + Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.bodyPartsPos[bodyPart]); + } + + if (limbIndex == CNE_LIMB_HEAD) { + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->enHy.headObjIndex].segment); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->enHy.headObjIndex].segment); + *dList = gCneHeadBrownHairDL; + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->enHy.skelLowerObjIndex].segment); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + if (limbIndex == CNE_LIMB_HEAD) { + Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->enHy.headRot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->enHy.headRot.x, MTXMODE_APPLY); + Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if (limbIndex == CNE_LIMB_TORSO) { + Matrix_InsertXRotation_s(-this->enHy.torsoRot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->enHy.torsoRot.x, MTXMODE_APPLY); + } + + if ((limbIndex == CNE_LIMB_HEAD) && this->enHy.inMsgState3 && ((globalCtx->state.frames % 2) == 0)) { + Matrix_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if ((limbIndex == CNE_LIMB_TORSO) || (limbIndex == CNE_LIMB_LEFT_UPPER_ARM) || + (limbIndex == CNE_LIMB_RIGHT_UPPER_ARM)) { + rot->y += (s16)(Math_SinS(this->enHy.limbRotTableY[limbIndex]) * 200.0f); + rot->z += (s16)(Math_CosS(this->enHy.limbRotTableZ[limbIndex]) * 200.0f); + } + + return false; +} + +void EnCne01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnCne01* this = THIS; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == CNE_LIMB_RIGHT_FOOT) { + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (limbIndex == CNE_LIMB_HEAD) { + Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.actor.focus.pos); + } +} + +void EnCne01_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +} + +void EnCne01_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnCne01* this = THIS; + s32 i; + u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(u8[64][64])); + u8* shadowTexIter; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(globalCtx->state.gfxCtx, 160, 180, 255, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(globalCtx->state.gfxCtx, 160, 180, 255, 0)); + gSPSegment(POLY_OPA_DISP++, 0x0A, Gfx_EnvColor(globalCtx->state.gfxCtx, 160, 180, 255, 0)); + gDPPipeSync(POLY_OPA_DISP++); + SkelAnime_DrawTransformFlexOpa(globalCtx, this->enHy.skelAnime.skeleton, this->enHy.skelAnime.jointTable, + this->enHy.skelAnime.dListCount, EnCne01_OverrideLimbDraw, EnCne01_PostLimbDraw, + EnCne01_TransformLimbDraw, &this->enHy.actor); + Matrix_InsertXRotation_s(0, MTXMODE_NEW); + + for (i = 0, shadowTexIter = shadowTex; i < (s32)sizeof(u8[64][64]); i++) { + *shadowTexIter++ = 0; + } + for (i = 0; i < 5; i++) { + func_8013CD64(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, + ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSize, gEnHyBodyPartsIndex); + } + func_8013CF04(&this->enHy.actor, &globalCtx->state.gfxCtx, shadowTex); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h index db0e797e9..98e7021cf 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h @@ -1,16 +1,18 @@ #ifndef Z_EN_CNE_01_H #define Z_EN_CNE_01_H -#include "global.h" +#include "z_en_hy.h" struct EnCne01; typedef void (*EnCne01ActionFunc)(struct EnCne01*, GlobalContext*); +#define ENCNE01_GET_PATH(thisx) (((thisx)->params & 0x7E00) >> 9) +#define ENCNE01_NO_PATH 0x3F + typedef struct EnCne01 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnCne01ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4D4]; + /* 0x000 */ EnHy enHy; + /* 0x3EC */ UNK_TYPE1 unk_3EC[0x230]; } EnCne01; // size = 0x61C extern const ActorInit En_Cne_01_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 6a9fb8555..bbd720e72 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -9141,19 +9141,19 @@ 0x809CB210:("EnBoj04_Destroy",), 0x809CB220:("EnBoj04_Update",), 0x809CB230:("EnBoj04_Draw",), - 0x809CB290:("func_809CB290",), - 0x809CB404:("func_809CB404",), + 0x809CB290:("EnCne01_UpdateModel",), + 0x809CB404:("EnCne01_TestIsTalking",), 0x809CB4A0:("func_809CB4A0",), - 0x809CB520:("func_809CB520",), - 0x809CB5A0:("func_809CB5A0",), - 0x809CB5D8:("func_809CB5D8",), - 0x809CB5FC:("func_809CB5FC",), + 0x809CB520:("EnCne01_FinishInit",), + 0x809CB5A0:("EnCne01_Walk",), + 0x809CB5D8:("EnCne01_FaceForward",), + 0x809CB5FC:("EnCne01_Talk",), 0x809CB72C:("EnCne01_Init",), 0x809CB86C:("EnCne01_Destroy",), 0x809CB898:("EnCne01_Update",), - 0x809CB920:("func_809CB920",), - 0x809CBBC8:("func_809CBBC8",), - 0x809CBCA0:("func_809CBCA0",), + 0x809CB920:("EnCne01_OverrideLimbDraw",), + 0x809CBBC8:("EnCne01_PostLimbDraw",), + 0x809CBCA0:("EnCne01_TransformLimbDraw",), 0x809CBCB4:("EnCne01_Draw",), 0x809CC060:("func_809CC060",), 0x809CC1D4:("func_809CC1D4",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index b303f8553..802bc6c96 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -917,9 +917,9 @@ 0x801BC240:("D_801BC240","Gfx","[9]",0x48), 0x801BC288:("D_801BC288","Gfx","[3]",0x18), 0x801BC2A0:("D_801BC2A0","UNK_TYPE1","",0x1), - 0x801BC3F0:("D_801BC3F0","UNK_TYPE1","",0x1), - 0x801BC400:("D_801BC400","UNK_TYPE1","",0x1), - 0x801BC410:("D_801BC410","s32",[],0x10), + 0x801BC3F0:("gEnHyBodyParts","UNK_TYPE1","",0x1), + 0x801BC400:("gEnHyBodyPartsIndex","UNK_TYPE1","",0x1), + 0x801BC410:("gEnHyShadowSize","s32",[],0x10), 0x801BC420:("sReactionTextIds","u16","[]",0x140A), 0x801BD830:("actorCutscenesGlobalCutscenes","ActorCutscene","[8]",0x80), 0x801BD8B0:("actorCutsceneCurrent","s16","",0x2), diff --git a/undefined_syms.txt b/undefined_syms.txt index d58ac55d7..d99d255b5 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -550,25 +550,6 @@ D_06011AB8 = 0x06011AB8; D_06012A80 = 0x06012A80; D_06013138 = 0x06013138; -// z_en_hy.c - -D_0600007C = 0x0600007C; -D_0600066C = 0x0600066C; -D_0600071C = 0x0600071C; -D_060008C0 = 0x060008C0; -D_06000AB0 = 0x06000AB0; -D_06000FDC = 0x06000FDC; -D_06001494 = 0x06001494; -D_06001908 = 0x06001908; -D_06001EE0 = 0x06001EE0; -D_06005DC4 = 0x06005DC4; -D_06005D9C = 0x06005D9C; -D_0600DED8 = 0x0600DED8; -D_0600F920 = 0x0600F920; -D_0600FC1C = 0x0600FC1C; -D_0600FEE4 = 0x0600FEE4; -D_06010330 = 0x06010330; - // ovl_Bg_Astr_Bombwall D_06002178 = 0x06002178; @@ -1290,11 +1271,6 @@ D_0600C3E0 = 0x0600C3E0; D_06001000 = 0x06001000; -// ovl_En_Cne_01 - -D_060000F0 = 0x060000F0; -D_06001300 = 0x06001300; - // ovl_En_Crow D_060000F0 = 0x060000F0; @@ -1405,6 +1381,7 @@ D_06003DC8 = 0x06003DC8; // ovl_En_Fishing +D_0600007C = 0x0600007C; D_0600CFE0 = 0x0600CFE0; D_06011058 = 0x06011058; From d588870b7a176b258285403dd58181be1775d045 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sun, 13 Feb 2022 16:40:19 -0800 Subject: [PATCH 010/257] Document sun textures/displaylist (#642) * Document sun textures/displaylist * Fix gSunEvening1Tex's outname * Add comment explaining the textures should be 64x64 --- assets/xml/objects/gameplay_keep.xml | 17 ++++++++++------- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 2 +- .../actors/ovl_En_Encount2/z_en_encount2.c | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 4ca6f2c4f..ebbd02808 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1316,15 +1316,18 @@ - - - - - - + + + + + + + + + - + diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index c85a48eb8..c0e1781e5 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -523,7 +523,7 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, GlobalContext* globalCtx2) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_079B10)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB10); for (i = 0; i < globalCtx->envCtx.unk_F2[3]; i++) { diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index 07187d90d..c4094adde 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -277,7 +277,7 @@ void EnEncount2_DrawParticles(EnEncount2* this, GlobalContext* globalCtx) { Matrix_InsertTranslation(sPtr->pos.x, sPtr->pos.y, sPtr->pos.z, MTXMODE_NEW); Matrix_Scale(sPtr->scale, sPtr->scale, sPtr->scale, MTXMODE_APPLY); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_079B10)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB10); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); From 45cee7d8af09395d8ab19461454b079748e2abae Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Mon, 14 Feb 2022 00:58:19 +0000 Subject: [PATCH 011/257] Obj_Dhouse (#648) * Obj_Dhouse * PR * PR --- spec | 3 +- .../actors/ovl_Obj_Dhouse/z_obj_dhouse.c | 517 +++++++++++++++++- .../actors/ovl_Obj_Dhouse/z_obj_dhouse.h | 37 +- undefined_syms.txt | 7 - 4 files changed, 522 insertions(+), 42 deletions(-) diff --git a/spec b/spec index c4de1495c..3302e9d41 100644 --- a/spec +++ b/spec @@ -3891,8 +3891,7 @@ beginseg name "ovl_Obj_Dhouse" compress include "build/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.o" - include "build/data/ovl_Obj_Dhouse/ovl_Obj_Dhouse.data.o" - include "build/data/ovl_Obj_Dhouse/ovl_Obj_Dhouse.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Dhouse/ovl_Obj_Dhouse_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c index 1177a6855..bec773c2f 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c @@ -1,12 +1,13 @@ /* * File: z_obj_dhouse.c * Overlay: ovl_Obj_Dhouse - * Description: Dinner plate Prop + * Description: Stone bridge that Keeta sleeps under */ #include "z_obj_dhouse.h" +#include "objects/object_dhouse/object_dhouse.h" -#define FLAGS 0x00400010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_400000) #define THIS ((ObjDhouse*)thisx) @@ -15,7 +16,17 @@ void ObjDhouse_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjDhouse_Update(Actor* thisx, GlobalContext* globalCtx); void ObjDhouse_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B12E7C(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3); +void func_80B13170(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3); +void func_80B13908(ObjDhouse* this); +void func_80B1391C(ObjDhouse* this, GlobalContext* globalCtx); +void func_80B1392C(ObjDhouse* this); +void func_80B13940(ObjDhouse* this, GlobalContext* globalCtx); +void func_80B139D8(ObjDhouse* this); +void func_80B139F4(ObjDhouse* this, GlobalContext* globalCtx); +void func_80B13C08(Actor* thisx, GlobalContext* globalCtx); +void func_80B13E40(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Obj_Dhouse_InitVars = { ACTOR_OBJ_DHOUSE, ACTORCAT_BG, @@ -28,58 +39,504 @@ const ActorInit Obj_Dhouse_InitVars = { (ActorFunc)ObjDhouse_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B13FB4[] = { +ObjDhouseStruct3 D_80B13E90[] = { + { + object_dhouse_DL_006E28, + object_dhouse_DL_006CE0, + { 84.2f, 30.480001f, 109.68001f }, + { 3.0f, 21.0f, 11.0f }, + 5500, + 500, + -500, + 7, + }, + { + object_dhouse_DL_0070A8, + object_dhouse_DL_006EF8, + { 40.8f, -38.72f, 62.12f }, + { -5.0f, 22.0f, 8.0f }, + 600, + -300, + 2000, + 4, + }, + { + object_dhouse_DL_007348, + object_dhouse_DL_007190, + { 125.31999f, -34.52f, 62.12f }, + { 8.0f, 13.0f, 6.0f }, + -2400, + 200, + -300, + 4, + }, + { + object_dhouse_DL_007568, + object_dhouse_DL_007438, + { 150.56f, -80.520004f, 62.12f }, + { -4.0f, 7.0f, 3.0f }, + 100, + 50, + 850, + 8, + }, + { + object_dhouse_DL_007780, + object_dhouse_DL_007638, + { 82.08f, 21.32f, -99.64f }, + { -7.0f, 34.0f, -1.0f }, + -2400, + -100, + 1000, + 5, + }, + { + object_dhouse_DL_007A00, + object_dhouse_DL_007850, + { 45.64f, -38.16f, -56.24f }, + { -1.0f, 20.0f, -16.0f }, + -2000, + 700, + 500, + 6, + }, + { + object_dhouse_DL_007C98, + object_dhouse_DL_007AE8, + { 140.4f, -60.84f, -56.24f }, + { 2.0f, 27.0f, -10.0f }, + -1000, + -500, + -500, + 9, + }, +}; + +Vec3f D_80B13FA8 = { 0.0f, 0.3f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 8000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +Vec3f D_80B13FC4 = { 160.0f, 0.0f, 240.0f }; -extern InitChainEntry D_80B13FB4[]; +void ObjDhouse_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjDhouse* this = THIS; -extern UNK_TYPE D_06004928; -extern UNK_TYPE D_06005A78; -extern UNK_TYPE D_06008040; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/ObjDhouse_Init.s") + DynaPolyActor_Init(&this->dyna, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/ObjDhouse_Destroy.s") + if (Flags_GetSwitch(globalCtx, OBJDHOUSE_GET_7F(&this->dyna.actor))) { + this->dyna.actor.draw = func_80B13E40; + func_80B13908(this); + } else { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_dhouse_Colheader_008040); + this->dyna.actor.flags |= ACTOR_FLAG_10; + func_80B1392C(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B12A50.s") +void ObjDhouse_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjDhouse* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B12A88.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B12B38.s") +void func_80B12A50(ObjDhouseStruct1* this, ObjDhouseStruct3* ptr3, Vec3f* arg2) { + arg2->x = this->unk_00.x + ptr3->unk_08.x; + arg2->y = this->unk_00.y + ptr3->unk_08.y; + arg2->z = this->unk_00.z + ptr3->unk_08.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B12D78.s") +void func_80B12A88(Actor* thisx) { + ObjDhouse* this = THIS; + s32 i; + ObjDhouseStruct1* ptr; + ObjDhouseStruct3* ptr3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B12E7C.s") + for (i = 0, ptr = &this->unk_160[0], ptr3 = &D_80B13E90[0]; i < ARRAY_COUNT(this->unk_160); i++, ptr3++, ptr++) { + Math_Vec3f_Copy(&ptr->unk_00, &this->dyna.actor.world.pos); + Math_Vec3f_Copy(&ptr->unk_0C, &ptr3->unk_14); + ptr->unk_18 = this->dyna.actor.shape.rot; + ptr->unk_1E = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13170.s") +void func_80B12B38(ObjDhouse* this2, GlobalContext* globalCtx) { + ObjDhouse* this = this2; + s32 i; + f32 temp_f0; + CollisionPoly* sp90; + s32 phi_s3; + Vec3f sp80; + s32 sp7C; + ObjDhouseStruct1* ptr; + ObjDhouseStruct3* ptr3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13474.s") + for (i = 0, ptr = &this->unk_160[0], ptr3 = &D_80B13E90[0]; i < ARRAY_COUNT(this->unk_160); i++, ptr3++, ptr++) { + if (ptr->unk_1E >= 0) { + if (ptr->unk_1E >= ptr3->unk_26) { + ptr->unk_0C.y -= 2.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13724.s") + Math_Vec3f_Scale(&ptr->unk_0C, 0.96f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13908.s") + ptr->unk_00.x += ptr->unk_0C.x; + ptr->unk_00.y += ptr->unk_0C.y; + ptr->unk_00.z += ptr->unk_0C.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B1391C.s") + ptr->unk_18.x += ptr3->unk_20.x; + ptr->unk_18.y += ptr3->unk_20.y; + ptr->unk_18.z += ptr3->unk_20.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B1392C.s") + if (ptr->unk_1E == ptr3->unk_26) { + func_80B12E7C(this, globalCtx, ptr, ptr3); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13940.s") + phi_s3 = false; + if (ptr->unk_0C.y < 0.0f) { + func_80B12A50(ptr, ptr3, &sp80); + temp_f0 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp90, &sp7C, &this->dyna.actor, &sp80); + if (((sp80.y - 35.0f) < temp_f0) && (temp_f0 > (BGCHECK_Y_MIN + 1.0f))) { + phi_s3 = true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B139D8.s") + if (phi_s3) { + ptr->unk_1E = -1; + func_80B13170(this, globalCtx, ptr, ptr3); + } else if (ptr->unk_1E > 60) { + ptr->unk_1E = -1; + } else { + ptr->unk_1E++; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B139F4.s") +s32 func_80B12D78(ObjDhouse* this) { + s32 i; + ObjDhouseStruct2* ptr2 = &this->unk_240[0]; + s32 count = 0; + ObjDhouseStruct2* ptr22 = &this->unk_240[1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/ObjDhouse_Update.s") + for (i = 1; i < ARRAY_COUNT(this->unk_240); i++, ptr22++) { + if (ptr22->unk_28 < ptr2->unk_28) { + ptr2 = ptr22; + count = i; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/ObjDhouse_Draw.s") + return count; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13C08.s") +void func_80B12E7C(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3) { + s32 i; + Vec3f spA0; + Vec3f sp94; + Vec3f sp88; + ObjDhouseStruct2* ptr2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13E40.s") + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultiplyVector3fXZByCurrentState(&D_80B13FC4, &sp94); + sp94.y = 100.0f; + func_80B12A50(ptr, ptr3, &spA0); + + for (i = 0; i < 15; i++) { + ptr2 = &this->unk_240[func_80B12D78(this)]; + + ptr2->unk_00.x = Rand_ZeroOne() - 0.5f; + ptr2->unk_00.y = Rand_ZeroOne(); + ptr2->unk_00.z = Rand_ZeroOne() - 0.5f; + + ptr2->unk_0C.x = ptr2->unk_00.x * 24.0f; + ptr2->unk_0C.y = ptr2->unk_00.y * 34.0f; + ptr2->unk_0C.z = ptr2->unk_00.z * 24.0f; + + ptr2->unk_00.x = (ptr2->unk_00.x * 140.0f) + spA0.x; + ptr2->unk_00.y = ((ptr2->unk_00.y - 0.2f) * 50.0f) + spA0.y; + ptr2->unk_00.z = (ptr2->unk_00.z * 140.0f) + spA0.z; + + ptr2->unk_18 = (Rand_ZeroOne() * 0.057f) + 0.003f; + + ptr2->unk_1C.x = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.y = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.z = (u32)Rand_Next() >> 0x10; + + ptr2->unk_22 = ((u32)Rand_Next() >> 0x11) - 0x3FFF; + ptr2->unk_24 = ((u32)Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_29 = 0; + ptr2->unk_28 = 40; + + if ((i % 2) != 0) { + sp88.x = ((Rand_ZeroOne() - 0.5f) * sp94.x) + ptr2->unk_00.x; + sp88.y = ((Rand_ZeroOne() - 0.3f) * sp94.y) + ptr2->unk_00.y; + sp88.z = ((Rand_ZeroOne() - 0.5f) * sp94.z) + ptr2->unk_00.z; + + func_800B1210(globalCtx, &sp88, &gZeroVec3f, &D_80B13FA8, (s32)(Rand_ZeroOne() * 130.0f) + 20, + (s32)(Rand_ZeroOne() * 140.0f) + 60); + } + } +} + +void func_80B13170(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3) { + s32 i; + Vec3f sp98; + Vec3f sp8C; + ObjDhouseStruct2* ptr2; + + func_80B12A50(ptr, ptr3, &sp98); + + for (i = 0; i < 11; i++) { + ptr2 = &this->unk_240[func_80B12D78(this)]; + + ptr2->unk_00.x = Rand_ZeroOne() - 0.5f; + ptr2->unk_00.y = Rand_ZeroOne(); + ptr2->unk_00.z = Rand_ZeroOne() - 0.5f; + + ptr2->unk_0C.x = ptr2->unk_00.x * 23.0f; + ptr2->unk_0C.y = (ptr2->unk_00.y * 19.0f) + 5.0f; + ptr2->unk_0C.z = ptr2->unk_00.z * 23.0f; + + ptr2->unk_00.x = (ptr2->unk_00.x * 80.0f) + sp98.x; + ptr2->unk_00.y = (ptr2->unk_00.y * 23.0f) + sp98.y + 15.0f; + ptr2->unk_00.z = (ptr2->unk_00.z * 80.0f) + sp98.z; + + ptr2->unk_1C.x = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.y = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.z = (u32)Rand_Next() >> 0x10; + + ptr2->unk_22 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_24 = ((u32)Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + + ptr2->unk_28 = 40; + + if (i < 3) { + ptr2->unk_18 = (Rand_ZeroOne() * 0.06f) + 0.12f; + ptr2->unk_29 = 1; + } else { + ptr2->unk_18 = (Rand_ZeroOne() * 0.05f) + 0.003f; + ptr2->unk_29 = 0; + } + + if ((i % 2) != 0) { + sp8C.x = ((Rand_ZeroOne() - 0.5f) * 160.0f) + ptr2->unk_00.x; + sp8C.y = (Rand_ZeroOne() * 120.0f) + ptr2->unk_00.y; + sp8C.z = ((Rand_ZeroOne() - 0.5f) * 160.0f) + ptr2->unk_00.z; + + func_800B1210(globalCtx, &sp8C, &gZeroVec3f, &D_80B13FA8, (s32)(Rand_ZeroOne() * 140.0f) + 20, + (s32)(Rand_ZeroOne() * 140.0f) + 40); + } + } +} + +void func_80B13474(ObjDhouse* this, GlobalContext* globalCtx, Vec3f* arg2) { + s32 i; + Vec3f sp88; + ObjDhouseStruct2* ptr2; + + for (i = 0; i < 5; i++) { + ptr2 = &this->unk_240[func_80B12D78(this)]; + + ptr2->unk_00.x = Rand_ZeroOne() - 0.5f; + ptr2->unk_00.y = Rand_ZeroOne(); + ptr2->unk_00.z = Rand_ZeroOne() - 0.5f; + + ptr2->unk_0C.x = ptr2->unk_00.x * 18.0f; + ptr2->unk_0C.y = ptr2->unk_00.y * 23.0f; + ptr2->unk_0C.z = ptr2->unk_00.z * 18.0f; + + ptr2->unk_00.x = (ptr2->unk_00.x * 40.0f) + arg2->x; + ptr2->unk_00.y = ((ptr2->unk_00.y - 0.4f) * 20.0f) + arg2->y; + ptr2->unk_00.z = (ptr2->unk_00.z * 40.0f) + arg2->z; + + ptr2->unk_1C.x = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.y = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.z = (u32)Rand_Next() >> 0x10; + + ptr2->unk_22 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_24 = ((u32)Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + + ptr2->unk_28 = 40; + ptr2->unk_18 = (Rand_ZeroOne() * 0.07f) + 0.003f; + ptr2->unk_29 = 0; + + sp88.x = ((Rand_ZeroOne() * 70.0f) - 35.0f) + ptr2->unk_00.x; + sp88.y = (Rand_ZeroOne() * 60.0f) + ptr2->unk_00.y; + sp88.z = ((Rand_ZeroOne() * 70.0f) - 35.0f) + ptr2->unk_00.z; + + func_800B1210(globalCtx, &sp88, &gZeroVec3f, &D_80B13FA8, (s32)(Rand_ZeroOne() * 80.0f) + 20, + (s32)(Rand_ZeroOne() * 90.0f) + 40); + } +} + +void func_80B13724(ObjDhouse* this, GlobalContext* globalCtx) { + f32 temp_f0; + f32 temp_f20 = this->dyna.actor.home.pos.y - 300.0f; + s32 i; + CollisionPoly* sp80; + ObjDhouseStruct2* ptr2; + Vec3f sp70; + s32 sp6C; + + for (i = 0, ptr2 = &this->unk_240[0]; i < ARRAY_COUNT(this->unk_240); i++, ptr2++) { + if (ptr2->unk_28 > 0) { + ptr2->unk_0C.y -= 2.2f; + + Math_Vec3f_Scale(&ptr2->unk_0C, 0.95f); + + ptr2->unk_00.x += ptr2->unk_0C.x; + ptr2->unk_00.y += ptr2->unk_0C.y; + ptr2->unk_00.z += ptr2->unk_0C.z; + + if (ptr2->unk_00.y < temp_f20) { + ptr2->unk_28 = 0; + } else { + ptr2->unk_1C.x += ptr2->unk_22; + ptr2->unk_1C.y += ptr2->unk_24; + ptr2->unk_1C.z += ptr2->unk_26; + ptr2->unk_28--; + + if (ptr2->unk_29 & 1) { + temp_f0 = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp80, &sp6C, &this->dyna.actor, &ptr2->unk_00); + if (((ptr2->unk_00.y - 20.0f) < temp_f0) && (temp_f0 > BGCHECK_Y_MIN + 1.0f)) { + Math_Vec3f_Copy(&sp70, &ptr2->unk_00); + ptr2->unk_28 = 0; + func_80B13474(this, globalCtx, &sp70); + } + } + } + } + } +} + +void func_80B13908(ObjDhouse* this) { + this->actionFunc = func_80B1391C; +} + +void func_80B1391C(ObjDhouse* this, GlobalContext* globalCtx) { +} + +void func_80B1392C(ObjDhouse* this) { + this->actionFunc = func_80B13940; +} + +void func_80B13940(ObjDhouse* this, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + s32 sp20 = false; + + if (Flags_GetSwitch(globalCtx, OBJDHOUSE_GET_7F(&this->dyna.actor))) { + sp20 = true; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_EXPLSION_LONG); + } + + if (sp20) { + func_80B12A88(&this->dyna.actor); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = func_80B13C08; + this->dyna.actor.flags |= ACTOR_FLAG_20; + func_80B139D8(this); + } +} + +void func_80B139D8(ObjDhouse* this) { + this->unk_1370 = 120; + this->actionFunc = func_80B139F4; +} + +void func_80B139F4(ObjDhouse* this, GlobalContext* globalCtx) { + Camera* camera = GET_ACTIVE_CAM(globalCtx); + s16 quake; + + if (this->unk_1370 == 117) { + quake = Quake_Add(camera, 3); + Quake_SetSpeed(quake, 20000); + Quake_SetQuakeValues(quake, 8, 0, 0, 0); + Quake_SetCountdown(quake, 17); + } else if (this->unk_1370 == 105) { + quake = Quake_Add(camera, 3); + Quake_SetSpeed(quake, 20000); + Quake_SetQuakeValues(quake, 7, 0, 0, 0); + Quake_SetCountdown(quake, 20); + } else if (this->unk_1370 == 90) { + quake = Quake_Add(camera, 3); + Quake_SetSpeed(quake, 20000); + Quake_SetQuakeValues(quake, 5, 0, 0, 0); + Quake_SetCountdown(quake, 62); + } + + this->unk_1370--; + if (this->unk_1370 <= 0) { + this->dyna.actor.draw = func_80B13E40; + this->dyna.actor.flags &= ~ACTOR_FLAG_20; + this->dyna.actor.flags &= ~ACTOR_FLAG_10; + func_80B13908(this); + } else { + func_80B12B38(this, globalCtx); + func_80B13724(this, globalCtx); + } +} + +void ObjDhouse_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjDhouse* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void ObjDhouse_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_dhouse_DL_005A78); +} + +void func_80B13C08(Actor* thisx, GlobalContext* globalCtx) { + ObjDhouse* this = THIS; + ObjDhouseStruct1* ptr; + ObjDhouseStruct2* ptr2; + ObjDhouseStruct3* ptr3; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dhouse_DL_004928); + + for (i = 0, ptr = &this->unk_160[0], ptr3 = &D_80B13E90[0]; i < ARRAY_COUNT(this->unk_160); i++, ptr3++, ptr++) { + if (ptr->unk_1E >= 0) { + Matrix_SetStateRotationAndTranslation(ptr->unk_00.x + ptr3->unk_08.x, ptr->unk_00.y + ptr3->unk_08.y, + ptr->unk_00.z + ptr3->unk_08.z, &ptr->unk_18); + Matrix_InsertTranslation(-ptr3->unk_08.x, -ptr3->unk_08.y, -ptr3->unk_08.z, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, ptr3->unk_00); + gSPDisplayList(POLY_OPA_DISP++, ptr3->unk_04); + } + } + + for (i = 0, ptr2 = &this->unk_240[0]; i < ARRAY_COUNT(this->unk_240); i++, ptr2++) { + if (ptr2->unk_28 > 0) { + Matrix_SetStateRotationAndTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &ptr2->unk_1C); + Matrix_Scale(ptr2->unk_18, ptr2->unk_18, ptr2->unk_18, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dhouse_DL_0081D8); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80B13E40(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_dhouse_DL_004928); +} diff --git a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.h b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.h index 793aabfac..053928c1c 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.h +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.h @@ -7,11 +7,42 @@ struct ObjDhouse; typedef void (*ObjDhouseActionFunc)(struct ObjDhouse*, GlobalContext*); +#define OBJDHOUSE_GET_7F(thisx) ((thisx)->params & 0x7F) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3s unk_18; + /* 0x1E */ s8 unk_1E; +} ObjDhouseStruct1; // size = 0x20 + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ f32 unk_18; + /* 0x1C */ Vec3s unk_1C; + /* 0x22 */ s16 unk_22; + /* 0x24 */ s16 unk_24; + /* 0x26 */ s16 unk_26; + /* 0x28 */ s8 unk_28; + /* 0x29 */ u8 unk_29; +} ObjDhouseStruct2; // size = 0x2C + +typedef struct { + /* 0x00 */ Gfx* unk_00; + /* 0x04 */ Gfx* unk_04; + /* 0x08 */ Vec3f unk_08; + /* 0x14 */ Vec3f unk_14; + /* 0x20 */ Vec3s unk_20; + /* 0x26 */ s8 unk_26; +} ObjDhouseStruct3; // size = 0x28 + typedef struct ObjDhouse { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjDhouseActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x1214]; + /* 0x0160 */ ObjDhouseStruct1 unk_160[7]; + /* 0x0240 */ ObjDhouseStruct2 unk_240[100]; + /* 0x1370 */ s16 unk_1370; } ObjDhouse; // size = 0x1374 extern const ActorInit Obj_Dhouse_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index d99d255b5..72d74dc40 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2160,13 +2160,6 @@ D_06001040 = 0x06001040; D_06000180 = 0x06000180; D_06000BA0 = 0x06000BA0; -// ovl_Obj_Dhouse - -D_06004928 = 0x06004928; -D_06005A78 = 0x06005A78; -D_06008040 = 0x06008040; -D_060081D8 = 0x060081D8; - // ovl_Obj_Dora D_06003FD0 = 0x06003FD0; From 3597e4809fa07f9f2fba445e56a1c8321afa2bfc Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sun, 13 Feb 2022 17:07:26 -0800 Subject: [PATCH 012/257] En_Jg (Goron Elder) OK and documented. Also document object_jg (#594) * Migrate data to C * Init / Destroy / Update / Draw * Functions called from Update * Better Init match * A few more functions * A few more functions * Drum-spawning function OK * EnJg OK * Name a few struct vars * Name some static vars * Name limbs * Name limb DLs * Name some textures * Name all remaining textures * First pass animation names + use object in actor file * Add drum to XML + clean it up * Better translations, thanks Emily! * Some more documentation * Improvements * Params accessor for s_goro * Proper object symbols for Jg_Gakki * Delete unnecessary undefined_syms * Text defines for my own sanity * Some more names * Document point/path stuff * Name every function, even if the names are bad * Params macro for if he's in goron shrine * Some misc improvements * Document EnJg_GetShrineGoronToFocusOn better * Final cleanup before PR * Change action name because this actor is dumb! * Run actorfixer * Rename some variables now that a function is named * ProcessTalkRequest takes GameState * Run actorfixer * Use new actor flags * Update text ID names to match my text ID PR * Define the limb enum in the object * Be consistent about where the EnumName is * Don't name limbs after the actor * Basic enum for drum limb * Fix stuff after merge * Do if/else if/else * Remove textId defines * Decimal weekEventReg accesses --- assets/xml/objects/object_jg.xml | 210 ++-- spec | 3 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 975 +++++++++++++++++- src/overlays/actors/ovl_En_Jg/z_en_jg.h | 34 +- .../actors/ovl_En_S_Goro/z_en_s_goro.c | 2 +- .../actors/ovl_En_S_Goro/z_en_s_goro.h | 2 + .../actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c | 6 +- tools/disasm/functions.txt | 52 +- undefined_syms.txt | 10 - 9 files changed, 1107 insertions(+), 187 deletions(-) diff --git a/assets/xml/objects/object_jg.xml b/assets/xml/objects/object_jg.xml index 03d7c3ce5..17889995f 100644 --- a/assets/xml/objects/object_jg.xml +++ b/assets/xml/objects/object_jg.xml @@ -1,100 +1,118 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index 3302e9d41..a139b1b1c 100644 --- a/spec +++ b/spec @@ -4250,8 +4250,7 @@ beginseg name "ovl_En_Jg" compress include "build/src/overlays/actors/ovl_En_Jg/z_en_jg.o" - include "build/data/ovl_En_Jg/ovl_En_Jg.data.o" - include "build/data/ovl_En_Jg/ovl_En_Jg.reloc.o" + include "build/src/overlays/actors/ovl_En_Jg/ovl_En_Jg_reloc.o" endseg beginseg 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 ce8651d3c..0dc1d5df5 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -5,17 +5,65 @@ */ #include "z_en_jg.h" +#include "overlays/actors/ovl_En_S_Goro/z_en_s_goro.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnJg*)thisx) +#define FLAG_SHRINE_GORON_ARMS_RAISED (1 << 0) +#define FLAG_LOOKING_AT_PLAYER (1 << 2) +#define FLAG_DRUM_SPAWNED (1 << 3) + void EnJg_Init(Actor* thisx, GlobalContext* globalCtx); void EnJg_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnJg_Update(Actor* thisx, GlobalContext* globalCtx); void EnJg_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnJg_GoronShrineTalk(EnJg* this, GlobalContext* globalCtx); +void EnJg_GoronShrineCheer(EnJg* this, GlobalContext* globalCtx); +void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, GlobalContext* globalCtx); +void EnJg_Walk(EnJg* this, GlobalContext* globalCtx); +void EnJg_Talk(EnJg* this, GlobalContext* globalCtx); +void EnJg_SetupWalk(EnJg* this, GlobalContext* globalCtx); +void EnJg_FrozenIdle(EnJg* this, GlobalContext* globalCtx); +void EnJg_EndFrozenInteraction(EnJg* this, GlobalContext* globalCtx); +void EnJg_TeachLullabyIntro(EnJg* this, GlobalContext* globalCtx); +void EnJg_LullabyIntroCutsceneAction(EnJg* this, GlobalContext* globalCtx); +s32 EnJg_GetNextTextId(EnJg* this); +s32 EnJg_GetStartingConversationTextId(EnJg* this, GlobalContext* globalCtx); +void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ EN_JG_ANIMATION_IDLE, + /* 1 */ EN_JG_ANIMATION_WALK, + /* 2 */ EN_JG_ANIMATION_WAVING, + /* 3 */ EN_JG_ANIMATION_SHAKING_HEAD, + /* 4 */ EN_JG_ANIMATION_SURPRISE_START, + /* 5 */ EN_JG_ANIMATION_SURPRISE_LOOP, + /* 6 */ EN_JG_ANIMATION_ANGRY, + /* 7 */ EN_JG_ANIMATION_FROZEN_START, + /* 8 */ EN_JG_ANIMATION_FROZEN_LOOP, + /* 9 */ EN_JG_ANIMATION_WALK_2, + /* 10 */ EN_JG_ANIMATION_TAKING_OUT_DRUM, + /* 11 */ EN_JG_ANIMATION_DRUM_IDLE, + /* 12 */ EN_JG_ANIMATION_PLAYING_DRUM, + /* 13 */ EN_JG_ANIMATION_THINKING, + /* 14 */ EN_JG_ANIMATION_REMEMBERING, + /* 15 */ EN_JG_ANIMATION_STRONG_REMEMBERING, + /* 16 */ EN_JG_ANIMATION_DEPRESSED, + /* 17 */ EN_JG_ANIMATION_CUTSCENE_IDLE, + /* 18 */ EN_JG_ANIMATION_CRADLE, + /* 19 */ EN_JG_ANIMATION_MAX, +} EnJgAnimationIndex; + +typedef enum { + /* 0x0 */ EN_JG_ACTION_FIRST_THAW, + /* 0x1 */ EN_JG_ACTION_SPAWNING, + /* 0x2 */ EN_JG_ACTION_FROZEN_OR_NON_FIRST_THAW, + /* 0x3 */ EN_JG_ACTION_LULLABY_INTRO_CS, +} EnJgAction; + const ActorInit En_Jg_InitVars = { ACTOR_EN_JG, ACTORCAT_NPC, @@ -28,18 +76,29 @@ const ActorInit En_Jg_InitVars = { (ActorFunc)EnJg_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B75820 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 60, 80, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B7584C = { 0, 50, 80, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 50, 80, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80B75858 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -74,70 +133,896 @@ static DamageTable D_80B75858 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -#endif +static ActorAnimationEntryS sAnimations[] = { + { &gGoronElderIdleAnim, 1.0f, 0, -1, 0, -10 }, { &gGoronElderWalkAnim, 1.0f, 0, -1, 0, -10 }, + { &gGoronElderWavingAnim, 1.0f, 0, -1, 0, -10 }, { &gGoronElderHeadShakeAnim, 1.0f, 0, -1, 0, -10 }, + { &gGoronElderSurpriseStartAnim, 1.0f, 0, -1, 2, -10 }, { &gGoronElderSurpriseLoopAnim, 1.0f, 0, -1, 0, -10 }, + { &gGoronElderAngryAnim, 1.0f, 0, -1, 0, -10 }, { &gGoronElderSurpriseStartAnim, 2.0f, 0, -1, 2, 0 }, + { &gGoronElderSurpriseStartAnim, -2.0f, 0, -1, 2, 0 }, { &gGoronElderWalkAnim, -1.0f, 0, -1, 0, -10 }, + { &gGoronElderTakeOutDrumAnim, 1.0f, 0, -1, 2, 0 }, { &gGoronElderDrumIdleAnim, 1.0f, 0, -1, 0, 0 }, + { &gGoronElderPlayingDrumAnim, 1.0f, 1, 44, 2, 0 }, { &gGoronElderThinkingAnim, 1.0f, 0, -1, 0, 0 }, + { &gGoronElderRememberingAnim, 1.0f, 0, -1, 2, 0 }, { &gGoronElderStrongRememberingAnim, 1.0f, 0, -1, 2, 0 }, + { &gGoronElderDepressedAnim, 1.0f, 0, -1, 0, 0 }, { &gGoronElderIdleAnim, 1.0f, 0, -1, 0, 0 }, + { &gGoronElderCradleAnim, 1.0f, 0, -1, 0, 0 }, +}; -extern ColliderCylinderInit D_80B75820; -extern CollisionCheckInfoInit2 D_80B7584C; -extern DamageTable D_80B75858; +static Vec3f sSfxPos = { 0.0f, 0.0f, 0.0f }; -extern UNK_TYPE D_0601ADC0; +static Vec3f sFocusOffset = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73A90.s") +static Vec3f sBreathPosOffset = { 1000.0f, -500.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73AE4.s") +static Vec3f sBreathVelOffset = { 0.0f, 0.0f, 0.75f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73B98.s") +static Vec3f sBreathAccelOffset = { 0.0f, 0.0f, -0.070000000298f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73C58.s") +/** + * When the elder and the Gorons in the shrine are doing a cheer + * for Darmani, the camera will focus on specific Gorons for + * certain parts of the cheer. This function is responsible for + * returning a pointer to the specified Goron so the camera + * can focus on them. + */ +Actor* EnJg_GetShrineGoronToFocusOn(GlobalContext* globalCtx, u8 focusedShrineGoronParam) { + Actor* actorIterator = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73DF4.s") + while (actorIterator != NULL) { + if ((actorIterator->id == ACTOR_EN_S_GORO) && + (EN_S_GORO_GET_PARAM_F(actorIterator) == focusedShrineGoronParam)) { + return actorIterator; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73E3C.s") + actorIterator = actorIterator->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73F1C.s") + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B7406C.s") +void EnJg_UpdateCollision(EnJg* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B7408C.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 30.0f, 30.0f, 7); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74134.s") +s16 EnJg_GetWalkingYRotation(Path* path, s32 pointIndex, Vec3f* pos, f32* distSQ) { + Vec3s* points; + f32 diffX; + f32 diffZ; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B741F8.s") + if (path != NULL) { + points = Lib_SegmentedToVirtual(path->points); + points = &points[pointIndex]; + diffX = points[0].x - pos->x; + diffZ = points[0].z - pos->z; + } else { + diffX = 0.0f; + diffZ = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B742F8.s") + *distSQ = SQ(diffX) + SQ(diffZ); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74440.s") + return RADF_TO_BINANG(Math_Acot2F(diffZ, diffX)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74550.s") +s32 EnJg_ReachedPoint(EnJg* this, Path* path, s32 pointIndex) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 pathCount = path->count; + s32 currentPoint = pointIndex; + s32 reached = false; + f32 diffX; + f32 diffZ; + f32 px; + f32 pz; + f32 d; + Vec3f point; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B747C8.s") + Math_Vec3s_ToVec3f(&point, &points[pointIndex]); + if (currentPoint == 0) { + diffX = points[1].x - points[0].x; + diffZ = points[1].z - points[0].z; + } else if (currentPoint == (pathCount - 1)) { + diffX = points[pathCount - 1].x - points[pathCount - 2].x; + diffZ = points[pathCount - 1].z - points[pathCount - 2].z; + } else { + diffX = points[currentPoint + 1].x - points[currentPoint - 1].x; + diffZ = points[currentPoint + 1].z - points[currentPoint - 1].z; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74840.s") + func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B749D0.s") + if (((this->actor.world.pos.x * px) + (pz * this->actor.world.pos.z) + d) > 0.0f) { + reached = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74AD8.s") + return reached; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74B54.s") +s16 EnJg_GetCutsceneForTeachingLullabyIntro(EnJg* this) { + s16 temp = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74BC8.s") + if (temp > 0) { + return this->actor.cutscene; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74E5C.s") + return ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B750A0.s") +void EnJg_SetupGoronShrineCheer(EnJg* this) { + ActorCutscene_Stop(this->cutscene); + if (this->focusedShrineGoronParam == 10) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + this->actionFunc = EnJg_GoronShrineTalk; + } else { + this->cutscene = 0x7C; + } + } else { + this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B7517C.s") + ActorCutscene_SetIntentToPlay(this->cutscene); + this->actionFunc = EnJg_GoronShrineCheer; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B751F8.s") + switch (this->textId) { + case 0xDD0: // The greatest Goron hero of all? + case 0xDD2: // The immortal Goron? + case 0xDD3: // The star we wish upon? + case 0xDD4: // "Darmani, greatest of Gorons!" + case 0xDD6: // Darmani, greatest in the world! + this->flags |= FLAG_SHRINE_GORON_ARMS_RAISED; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/EnJg_Init.s") + default: + this->flags &= ~FLAG_SHRINE_GORON_ARMS_RAISED; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/EnJg_Destroy.s") +void EnJg_SetupTalk(EnJg* this, GlobalContext* globalCtx) { + switch (this->textId) { + case 0xDAC: // What was I doing? + this->animationIndex = EN_JG_ANIMATION_SHAKING_HEAD; + func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Talk; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/EnJg_Update.s") + case 0xDAD: // I must hurry! + this->animationIndex = EN_JG_ANIMATION_SURPRISE_START; + func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_AlternateTalkOrWalkInPlace; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B75658.s") + case 0xDB7: // You're Darmani! + this->animationIndex = EN_JG_ANIMATION_SURPRISE_START; + func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Talk; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B75708.s") + case 0xDAE: // Do you have business with the Elder? + case 0xDB3: // As Elder, I must do something + case 0xDB6: // "Hunh???" + case 0xDBA: // I've been made a fool of! + case 0xDBD: // "...What?" + case 0xDC4: // It's so cold I can't play + this->animationIndex = EN_JG_ANIMATION_IDLE; + func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Talk; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/EnJg_Draw.s") + case 0xDB0: // It's this cold snap + case 0xDBB: // If I can see past the illusion, you'll vanish + case 0xDBC: // Following me won't do you any good + case 0xDC6: // I am counting on you + this->animationIndex = EN_JG_ANIMATION_ANGRY; + func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Talk; + break; + + case 0xDB4: // This is our problem (first) + case 0xDB5: // This is our problem (repeat) + this->animationIndex = EN_JG_ANIMATION_WAVING; + func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Talk; + break; + } +} + +void EnJg_Idle(EnJg* this, GlobalContext* globalCtx) { + EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(this, globalCtx); +} + +void EnJg_GoronShrineIdle(EnJg* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->flags |= FLAG_LOOKING_AT_PLAYER; + func_801518B0(globalCtx, this->textId, &this->actor); + this->actionFunc = EnJg_GoronShrineTalk; + } else if ((this->actor.xzDistToPlayer < 100.0f) || (this->actor.isTargeted)) { + func_800B863C(&this->actor, globalCtx); + this->textId = EnJg_GetStartingConversationTextId(this, globalCtx); + } +} + +void EnJg_GoronShrineTalk(EnJg* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { + if ((this->textId == 0xDCC) || (this->textId == 0xDDD) || (this->textId == 0xDE0)) { + // There is nothing more to say after these lines, so end the current conversation. + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->flags &= ~FLAG_LOOKING_AT_PLAYER; + this->actionFunc = EnJg_GoronShrineIdle; + } else { + this->textId = EnJg_GetNextTextId(this); + func_801518B0(globalCtx, this->textId, &this->actor); + } + } +} + +void EnJg_GoronShrineCheer(EnJg* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->cutscene)) { + switch (this->textId) { + case 0xDD0: // The greatest Goron hero of all? + case 0xDD2: // The immortal Goron? + case 0xDD3: // The star we wish upon? + case 0xDD4: // "Darmani, greatest of Gorons!" + case 0xDD6: // Darmani, greatest in the world! + // Focus on a specifc Goron for these lines + this->shrineGoron = EnJg_GetShrineGoronToFocusOn(globalCtx, this->focusedShrineGoronParam); + ActorCutscene_Start(this->cutscene, this->shrineGoron); + func_800E0308(globalCtx->cameraPtrs[0], this->shrineGoron); + break; + + default: + // Focus on the whole group for these lines + ActorCutscene_Start(this->cutscene, &this->actor); + func_800E0308(globalCtx->cameraPtrs[0], this->shrineGoron); + break; + } + this->actionFunc = EnJg_GoronShrineTalk; + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + if (this->focusedShrineGoronParam == 10) { + this->actionFunc = EnJg_GoronShrineTalk; + } else { + ActorCutscene_Stop(0x7C); + } + } + ActorCutscene_SetIntentToPlay(this->cutscene); + } +} + +/** + * You need to reach a certain point in the conversation when talking with the elder before + * he starts walking for the first time. This function specifically handles this scenario; the + * reason they used this instead of EnJg_Talk is seemingly to bypass EnJg_SetupWalk resetting + * the freeze timer. + * + * Additionally, when the elder has reached the end of his specified path, this function will + * set his speed to 0, causing him to walk in place. + */ +void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, GlobalContext* globalCtx) { + u8 messageState = Message_GetState(&globalCtx->msgCtx); + s16 currentFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animationSeg); + + if (this->animationIndex == EN_JG_ANIMATION_SURPRISE_START) { + if (currentFrame == lastFrame) { + this->animationIndex = EN_JG_ANIMATION_SURPRISE_LOOP; + func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + } + } else if (this->animationIndex == EN_JG_ANIMATION_SURPRISE_LOOP) { + if ((messageState == 5) && (func_80147624(globalCtx))) { + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->flags &= ~FLAG_LOOKING_AT_PLAYER; + this->animationIndex = EN_JG_ANIMATION_WALK; + func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Walk; + } + } else if (this->animationIndex == EN_JG_ANIMATION_WALK) { + Math_ApproachF(&this->actor.speedXZ, 0.0f, 0.2f, 1.0f); + EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(this, globalCtx); + } +} + +void EnJg_Walk(EnJg* this, GlobalContext* globalCtx) { + s16 yRotation; + f32 distSQ; + + if (this->path != NULL) { + yRotation = EnJg_GetWalkingYRotation(this->path, this->currentPoint, &this->actor.world.pos, &distSQ); + if (this->actor.bgCheckFlags & 8) { + yRotation = this->actor.wallYaw; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + + if (EnJg_ReachedPoint(this, this->path, this->currentPoint)) { + if (this->currentPoint >= (this->path->count - 1)) { + // Force the elder to walk in place + this->animationIndex = EN_JG_ANIMATION_WALK; + this->actionFunc = EnJg_AlternateTalkOrWalkInPlace; + } else { + this->currentPoint++; + Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); + } + } else { + Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); + } + } + + EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(this, globalCtx); +} + +void EnJg_Talk(EnJg* this, GlobalContext* globalCtx) { + u8 messageState = Message_GetState(&globalCtx->msgCtx); + s16 currentFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animationSeg); + u16 temp; + + if ((this->animationIndex == EN_JG_ANIMATION_SURPRISE_START) && (currentFrame == lastFrame)) { + this->animationIndex = EN_JG_ANIMATION_SURPRISE_LOOP; + func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + } + + if ((messageState == 5) && (func_80147624(globalCtx))) { + temp = this->textId; + if ((temp == 0xDB4) || (temp == 0xDB5) || (temp == 0xDC4) || (temp == 0xDC6)) { + // There is nothing more to say after these lines, so end the current conversation. + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->flags &= ~FLAG_LOOKING_AT_PLAYER; + this->actionFunc = EnJg_SetupWalk; + return; + } + + temp = this->textId; + if ((temp == 0xDBB) || (temp == 0xDBC)) { + if (!(gSaveContext.weekEventReg[24] & 0x80)) { + // The player hasn't talked to the Goron Child at least once, so they can't learn + // the Lullaby Intro. End the current conversation with the player. + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->flags &= ~FLAG_LOOKING_AT_PLAYER; + this->actionFunc = EnJg_SetupWalk; + } else if (((gSaveContext.weekEventReg[24] & 0x40)) || + (CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO))) { + // The player already has the Lullaby or Lullaby Intro, so say "I'm counting on you" + this->textId = EnJg_GetNextTextId(this); + func_801518B0(globalCtx, this->textId, &this->actor); + this->actionFunc = EnJg_SetupTalk; + } else { + // To get to this point, the player *has* talked to the Goron Child, but doesn't + // already have the Lullaby or Lullaby Intro. End the current conversation and + // start the cutscene that teaches the Lullaby Intro. + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->flags &= ~FLAG_LOOKING_AT_PLAYER; + this->cutscene = EnJg_GetCutsceneForTeachingLullabyIntro(this); + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->cutscene); + this->actionFunc = EnJg_TeachLullabyIntro; + } + } else { + this->textId = EnJg_GetNextTextId(this); + func_801518B0(globalCtx, this->textId, &this->actor); + this->actionFunc = EnJg_SetupTalk; + } + } +} + +void EnJg_SetupWalk(EnJg* this, GlobalContext* globalCtx) { + if (this->animationIndex != EN_JG_ANIMATION_WALK) { + this->animationIndex = EN_JG_ANIMATION_WALK; + this->freezeTimer = 1000; + func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Walk; + } else { + this->freezeTimer = 1000; + this->actionFunc = EnJg_Walk; + } +} + +void EnJg_Freeze(EnJg* this, GlobalContext* globalCtx) { + s16 currentFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animationSeg); + + 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->icePoly = Actor_Spawn(&globalCtx->actorCtx, globalCtx, 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); + this->animationIndex = EN_JG_ANIMATION_FROZEN_LOOP; + func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_FrozenIdle; + } else if (this->animationIndex == EN_JG_ANIMATION_FROZEN_START) { + this->action = EN_JG_ACTION_FROZEN_OR_NON_FIRST_THAW; + if (currentFrame == lastFrame) { + this->freezeTimer = 1000; + this->icePoly = Actor_Spawn(&globalCtx->actorCtx, globalCtx, 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); + this->animationIndex = EN_JG_ANIMATION_FROZEN_LOOP; + func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_FrozenIdle; + } + } +} + +void EnJg_FrozenIdle(EnJg* this, GlobalContext* globalCtx) { + if (this->icePoly->update == NULL) { + this->icePoly = NULL; + if (this->animationIndex == EN_JG_ANIMATION_FROZEN_LOOP) { + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + this->animationIndex = EN_JG_ANIMATION_IDLE; + + // If you've never talked to the elder before, he stands + // around idle until you've talked to him at least once. + // Otherwise, he immediately begins walking after being + // thawed out. + if (this->textId == 0xDAC) { + func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Idle; + } else { + this->freezeTimer = 1000; + func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Walk; + } + } + } + } else { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_801518B0(globalCtx, 0x236, &this->actor); // The old Goron is frozen solid! + this->actionFunc = EnJg_EndFrozenInteraction; + } else if (this->actor.isTargeted) { + func_800B863C(&this->actor, globalCtx); + } + } +} + +void EnJg_EndFrozenInteraction(EnJg* this, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx) != 0) { + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = EnJg_FrozenIdle; + } +} + +void EnJg_TeachLullabyIntro(EnJg* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->cutscene)) { + ActorCutscene_Start(this->cutscene, &this->actor); + this->actionFunc = EnJg_LullabyIntroCutsceneAction; + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->cutscene); + } +} + +void EnJg_LullabyIntroCutsceneAction(EnJg* this, GlobalContext* globalCtx) { + s32 pad; + + if (func_800EE29C(globalCtx, 0x1D6)) { + u32 actionIndex = func_800EE200(globalCtx, 0x1D6); + + if (this->csAction != globalCtx->csCtx.npcActions[actionIndex]->unk0) { + this->csAction = globalCtx->csCtx.npcActions[actionIndex]->unk0; + + switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + case 1: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_CUTSCENE_IDLE; + if (this->drum != NULL) { + Actor_MarkForDeath(this->drum); + this->drum = NULL; + } + break; + + case 2: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_TAKING_OUT_DRUM; + break; + + case 3: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_DRUM_IDLE; + break; + + case 4: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_PLAYING_DRUM; + break; + + case 5: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_THINKING; + break; + + case 6: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_REMEMBERING; + break; + + case 7: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_STRONG_REMEMBERING; + break; + + case 8: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_DEPRESSED; + break; + + case 9: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_CRADLE; + break; + + default: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_IDLE; + break; + } + + func_8013BC6C(&this->skelAnime, sAnimations, this->cutsceneAnimationIndex); + } + + if ((!(this->flags & FLAG_DRUM_SPAWNED)) && + (((this->cutsceneAnimationIndex == EN_JG_ANIMATION_TAKING_OUT_DRUM) && + (Animation_OnFrame(&this->skelAnime, 14.0f)) && (this->action != EN_JG_ACTION_LULLABY_INTRO_CS)) || + (((this->cutsceneAnimationIndex == EN_JG_ANIMATION_DRUM_IDLE) || + (this->cutsceneAnimationIndex == EN_JG_ANIMATION_PLAYING_DRUM)) && + (this->action == EN_JG_ACTION_LULLABY_INTRO_CS)))) { + this->flags |= FLAG_DRUM_SPAWNED; + this->drum = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_OBJ_JG_GAKKI, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, + this->actor.params, this->actor.cutscene, this->actor.unk20, NULL); + } + + if (this->cutsceneAnimationIndex == EN_JG_ANIMATION_TAKING_OUT_DRUM) { + if (Animation_OnFrame(&this->skelAnime, 23.0f)) { + Audio_PlaySfxAtPos(&sSfxPos, NA_SE_EV_WOOD_BOUND_S); + } else if (Animation_OnFrame(&this->skelAnime, 38.0f)) { + Audio_PlaySfxAtPos(&sSfxPos, NA_SE_EV_OBJECT_SLIDE); + } + } + } else { + this->csAction = 99; + this->freezeTimer = 1000; + gSaveContext.weekEventReg[24] |= 0x40; + this->actionFunc = EnJg_Idle; + } +} + +/** + * Returns the "next" text ID that the elder should use based on his current text ID. + * Note that the results here can be counterintuitive, because his current text ID can + * cause multiple text boxes to display in sequence; this function will return the text + * ID that starts the *next* sequence. + * + * Sequences generally seem to be tied to text IDs that should all share the same animation. + */ +s32 EnJg_GetNextTextId(EnJg* this) { + switch (this->textId) { + case 0xDAC: // What was I doing? + return 0xDAD; // I must hurry! + + case 0xDAE: // Do you have business with the Elder? + return 0xDB0; // It's this cold snap + + case 0xDB0: // It's this cold snap + return 0xDB3; // As Elder, I must do something + + case 0xDB3: // As Elder, I must do something + return 0xDB4; // This is our problem (first) + + case 0xDB6: // "Hunh???" + return 0xDB7; // You're Darmani! + + case 0xDB7: // You're Darmani! + return 0xDBA; // I've been made a fool of! + + case 0xDBA: // I've been made a fool of! + return 0xDBB; // If I can see past the illusion, you'll vanish + + case 0xDBB: // If I can see past the illusion, you'll vanish + case 0xDBC: // Following me won't do you any good + return 0xDC6; // I am counting on you + + case 0xDCB: // Welcome to spring + return 0xDCC; // We're holding the Goron Races + + case 0xDDE: // Come back after entering the race + return 0xDDF; // My son is waiting for you + + case 0xDDF: // My son is waiting for you + return 0xDE0; // Go beyond Twin Islands Cave + + case 0xDCD: // I've been waiting impatiently for you + return 0xDCE; // I heard you sealed the blizzard + + case 0xDCE: // I heard you sealed the blizzard + return 0xDCF; // Spring has come thanks to you + + case 0xDCF: // Spring has come thanks to you + this->focusedShrineGoronParam = 3; + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->cutscene); + this->actionFunc = EnJg_GoronShrineCheer; + return 0xDD0; // The greatest Goron hero of all? + + case 0xDD0: // The greatest Goron hero of all? + EnJg_SetupGoronShrineCheer(this); + return 0xDD1; // "Darmani!" + + case 0xDD1: // "Darmani!" + switch (this->focusedShrineGoronParam) { + case 3: + this->focusedShrineGoronParam = 4; + EnJg_SetupGoronShrineCheer(this); + return 0xDD2; // The immortal Goron? + + case 4: + this->focusedShrineGoronParam = 5; + EnJg_SetupGoronShrineCheer(this); + return 0xDD3; // The star we wish upon? + + case 5: + this->focusedShrineGoronParam = 6; + EnJg_SetupGoronShrineCheer(this); + return 0xDD4; // "Darmani, greatest of Gorons!" + + default: + return 0xDD4; // "Darmani, greatest of Gorons!" + } + break; + + case 0xDD2: // The immortal Goron? + EnJg_SetupGoronShrineCheer(this); + return 0xDD1; // "Darmani!" + + case 0xDD3: // The star we wish upon? + EnJg_SetupGoronShrineCheer(this); + return 0xDD1; // "Darmani!" + + case 0xDD4: // "Darmani, greatest of Gorons!" + EnJg_SetupGoronShrineCheer(this); + return 0xDD5; // "Greatest of Gorons!" + + case 0xDD5: // "Greatest of Gorons!" + this->focusedShrineGoronParam = 7; + EnJg_SetupGoronShrineCheer(this); + return 0xDD6; // Darmani, greatest in the world! + + case 0xDD6: // Darmani, greatest in the world! + EnJg_SetupGoronShrineCheer(this); + return 0xDD7; // "Greatest in the world!" + + case 0xDD7: // "Greatest in the world!" + this->focusedShrineGoronParam = 10; + EnJg_SetupGoronShrineCheer(this); + this->flags &= ~FLAG_SHRINE_GORON_ARMS_RAISED; + return 0xDD8; // My son went to see the races + + case 0xDD8: // My son went to see the races + return 0xDD9; // I yield to a younger one + + case 0xDD9: // I yield to a younger one + return 0xDDA; // A Goron who takes care of all + + case 0xDDA: // A Goron who takes care of all + return 0xDDB; // The chosen one, Darmani! + + case 0xDDB: // The chosen one, Darmani! + return 0xDDC; // Everyone would accept you + + case 0xDDC: // Everyone would accept you + gSaveContext.weekEventReg[77] |= 0x80; + return 0xDDD; // Think it over slowly + + default: + return 0; + } +} + +/** + * Returns the text ID of the first thing the elder should say when you talk to him + * under most circumstances. Some circumstances (like the very first time the player + * talks to him after he thaws) bypass this function. + */ +s32 EnJg_GetStartingConversationTextId(EnJg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (!EN_JG_IS_IN_GORON_SHRINE(&this->actor)) { + if (player->transformation == PLAYER_FORM_GORON) { + if ((gSaveContext.weekEventReg[24] & 0x10) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) || + CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO)) { + // The player has already talked as a Goron at least once. + return 0xDBC; // Following me won't do you any good + } + + // The player has never talked as a Goron. + return 0xDB6; // "Hunh???" + } + + if (gSaveContext.weekEventReg[24] & 0x20) { + // The player has already talked as a non-Goron at least once. + return 0xDB5; // This is our problem (repeat) + } + + // The player has never talked as a non-Goron. + return 0xDAE; // Do you have business with the Elder? + } + + if (player->transformation == PLAYER_FORM_GORON) { + if (gSaveContext.weekEventReg[77] & 0x80) { + // The player has heard the Goron Shrine cheer as a Goron at least once. + return 0xDDE; // Come back after entering the race + } + + // The player has never heard the Goron Shrine cheer as a Goron. + return 0xDCD; // I've been waiting impatiently for you + } + + // The player is talking to the elder in Goron Shrine as a non-Goron. + return 0xDCB; // Welcome to spring +} + +void EnJg_SpawnBreath(EnJg* this, GlobalContext* globalCtx) { + s16 scale = (Rand_ZeroOne() * 20.0f) + 30.0f; + + if (globalCtx->state.frames % 8 == 0) { + EffectSsIceSmoke_Spawn(globalCtx, &this->breathPos, &this->breathVelocity, &this->breathAccel, scale); + } +} + +/** + * This function has two purposes: + * - If the player starts talking to the elder, this stops him from moving, makes him face + * towards the player, updates certain weekEventRegs, and calls EnJg_SetupTalk. + * - If the player is *not* talking to the elder, this decrements his freeze timer. If his + * freeze timer is 0 or negative, this function starts the process of freezing him before + * handing it off to EnJg_Freeze. + */ +void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, GlobalContext* globalCtx) { + s16 currentFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animationSeg); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->flags |= FLAG_LOOKING_AT_PLAYER; + this->actor.speedXZ = 0.0f; + + if (this->textId == 0xDAC) { + this->action = EN_JG_ACTION_FIRST_THAW; + } else if (this->textId == 0xDAE) { + gSaveContext.weekEventReg[24] |= 0x20; + } else if (this->textId == 0xDB6) { + gSaveContext.weekEventReg[24] |= 0x10; + } + + func_801518B0(globalCtx, this->textId, &this->actor); + this->actionFunc = EnJg_SetupTalk; + } else { + if ((this->actor.xzDistToPlayer < 100.0f) || (this->actor.isTargeted)) { + func_800B863C(&this->actor, globalCtx); + if (this->action == EN_JG_ACTION_FIRST_THAW) { + this->textId = EnJg_GetStartingConversationTextId(this, globalCtx); + } + } + + this->freezeTimer--; + if ((this->freezeTimer <= 0) && (currentFrame == lastFrame)) { + this->animationIndex = EN_JG_ANIMATION_FROZEN_START; + func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + Audio_PlaySfxAtPos(&sSfxPos, NA_SE_EV_FREEZE_S); + this->actionFunc = EnJg_Freeze; + } + } +} + +void EnJg_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnJg* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronElderSkel, &gGoronElderIdleAnim, this->jointTable, + this->morphTable, GORON_ELDER_LIMB_MAX); + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + Actor_SetScale(&this->actor, 0.01f); + + if (!EN_JG_IS_IN_GORON_SHRINE(thisx)) { + if ((globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7) && + (globalCtx->csCtx.unk_12 == 0)) { + // This is the elder that appears in the cutscene for learning the full Goron Lullaby. + this->animationIndex = EN_JG_ANIMATION_IDLE; + this->action = EN_JG_ACTION_LULLABY_INTRO_CS; + func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_LullabyIntroCutsceneAction; + } else { + // This is the elder that appears in Mountain Village or the Path to Goron Village in winter. + this->path = func_8013D648(globalCtx, EN_JG_GET_PATH(thisx), 0x3F); + this->animationIndex = EN_JG_ANIMATION_SURPRISE_START; + this->action = EN_JG_ACTION_SPAWNING; + this->freezeTimer = 1000; + this->textId = 0xDAC; // What was I doing? + func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Freeze; + } + } else { + // This is the elder that appears in Goron Shrine in spring. + this->animationIndex = EN_JG_ANIMATION_IDLE; + this->cutscene = this->actor.cutscene; + func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_GoronShrineIdle; + } +} + +void EnJg_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnJg* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnJg_Update(Actor* thisx, GlobalContext* globalCtx) { + EnJg* this = THIS; + + if ((this->actionFunc != EnJg_FrozenIdle) && (this->actionFunc != EnJg_EndFrozenInteraction)) { + EnJg_UpdateCollision(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + SkelAnime_Update(&this->skelAnime); + + if ((this->action != EN_JG_ACTION_LULLABY_INTRO_CS) && (!EN_JG_IS_IN_GORON_SHRINE(&this->actor))) { + EnJg_SpawnBreath(this, globalCtx); + } + + func_800E9250(globalCtx, &this->actor, &this->unusedRotation1, &this->unusedRotation2, this->actor.focus.pos); + } + this->actionFunc(this, globalCtx); +} + +s32 EnJg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnJg* this = THIS; + + if (limbIndex == GORON_ELDER_LIMB_ROOT) { + if (this->flags & FLAG_LOOKING_AT_PLAYER) { + Math_SmoothStepToS(&this->rootRotationWhenTalking, this->actor.yawTowardsPlayer - this->actor.shape.rot.y, + 5, 0x1000, 0x100); + Matrix_RotateY(this->rootRotationWhenTalking, MTXMODE_APPLY); + } else { + Math_SmoothStepToS(&this->rootRotationWhenTalking, 0, 5, 0x1000, 0x100); + Matrix_RotateY(this->rootRotationWhenTalking, MTXMODE_APPLY); + } + } + + return false; +} + +void EnJg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnJg* this = THIS; + + if (limbIndex == GORON_ELDER_LIMB_HEAD) { + Matrix_MultiplyVector3fByState(&sFocusOffset, &this->actor.focus.pos); + } + + if (limbIndex == GORON_ELDER_LIMB_LOWER_LIP) { + Matrix_MultiplyVector3fByState(&sBreathPosOffset, &this->breathPos); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sBreathVelOffset, &this->breathVelocity); + Matrix_MultiplyVector3fByState(&sBreathAccelOffset, &this->breathAccel); + } +} + +void EnJg_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnJg* this = THIS; + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnJg_OverrideLimbDraw, EnJg_PostLimbDraw, &this->actor); +} 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 3a860feb2..67ba1d638 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.h +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.h @@ -2,16 +2,42 @@ #define Z_EN_JG_H #include "global.h" +#include "objects/object_jg/object_jg.h" + +#define EN_JG_IS_IN_GORON_SHRINE(thisx) ((thisx)->params & 0x1) +#define EN_JG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 10) struct EnJg; typedef void (*EnJgActionFunc)(struct EnJg*, GlobalContext*); typedef struct EnJg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x98]; - /* 0x01DC */ EnJgActionFunc actionFunc; - /* 0x01E0 */ char unk_1E0[0x1F4]; + /* 0x000 */ Actor actor; + /* 0x144 */ Actor* shrineGoron; + /* 0x148 */ Actor* icePoly; + /* 0x14C */ ColliderCylinder collider; + /* 0x198 */ SkelAnime skelAnime; + /* 0x1DC */ EnJgActionFunc actionFunc; + /* 0x1E0 */ Path* path; + /* 0x1E4 */ s32 currentPoint; + /* 0x1E8 */ Actor* drum; + /* 0x1EC */ Vec3s unusedRotation1; // probably meant to be a head rotation to look at the player + /* 0x1F2 */ Vec3s unusedRotation2; // probably meant to be a body rotation to look at the player + /* 0x1F8 */ Vec3s jointTable[GORON_ELDER_LIMB_MAX]; + /* 0x2CA */ Vec3s morphTable[GORON_ELDER_LIMB_MAX]; + /* 0x39C */ s16 rootRotationWhenTalking; + /* 0x39E */ s16 animationIndex; + /* 0x3A0 */ s16 action; + /* 0x3A2 */ s16 freezeTimer; + /* 0x3A4 */ Vec3f breathPos; + /* 0x3B0 */ Vec3f breathVelocity; + /* 0x3BC */ Vec3f breathAccel; + /* 0x3C8 */ s16 cutscene; + /* 0x3CA */ u8 cutsceneAnimationIndex; + /* 0x3CB */ u8 csAction; + /* 0x3CC */ u16 flags; + /* 0x3CE */ u16 textId; + /* 0x3D0 */ u8 focusedShrineGoronParam; } EnJg; // size = 0x3D4 extern const ActorInit En_Jg_InitVars; 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 07d0dc3f9..394ac5b05 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 @@ -1,7 +1,7 @@ /* * File: z_en_s_goro.c * Overlay: ovl_En_S_Goro - * Description: Goron Complaining About Crying / Bomb Shop Goron + * Description: Goron in Goron Shrine / Bomb Shop Goron */ #include "z_en_s_goro.h" diff --git a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.h b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.h index 489499b33..99c35127a 100644 --- a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.h +++ b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.h @@ -3,6 +3,8 @@ #include "global.h" +#define EN_S_GORO_GET_PARAM_F(thisx) ((thisx)->params & 0xF) + struct EnSGoro; typedef void (*EnSGoroActionFunc)(struct EnSGoro*, GlobalContext*); diff --git a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c index a70d14600..b8a1406d7 100644 --- a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c +++ b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c @@ -31,16 +31,16 @@ const ActorInit Obj_Jg_Gakki_InitVars = { void ObjJgGakki_Init(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; ObjJgGakki* this = THIS; - f32 frameCount = Animation_GetLastFrame(&gGoronElderDrumAnim); + f32 frameCount = Animation_GetLastFrame(&gGoronElderDrumTakeOutAnim); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &gGoronElderDrumSkel, NULL, NULL, NULL, 0); if (((globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7)) && (globalCtx->csCtx.unk_12 == 0)) { - Animation_Change(&this->skelAnime, &gGoronElderDrumAnim, 1.0f, frameCount, frameCount, 2, 0.0f); + Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, frameCount, frameCount, 2, 0.0f); } else if ((globalCtx->sceneNum == SCENE_17SETUGEN) || (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA)) { - Animation_Change(&this->skelAnime, &gGoronElderDrumAnim, 1.0f, 0.0f, frameCount, 2, 0.0f); + Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, 0.0f, frameCount, 2, 0.0f); } else { Actor_MarkForDeath(&this->actor); } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index bbd720e72..5d6fe3750 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -14407,35 +14407,35 @@ 0x80B72E88:("EnRailSkb_OverrideLimbDraw",), 0x80B7302C:("EnRailSkb_PostLimbDraw",), 0x80B731EC:("EnRailSkb_Draw",), - 0x80B73A90:("func_80B73A90",), - 0x80B73AE4:("func_80B73AE4",), - 0x80B73B98:("func_80B73B98",), - 0x80B73C58:("func_80B73C58",), - 0x80B73DF4:("func_80B73DF4",), - 0x80B73E3C:("func_80B73E3C",), - 0x80B73F1C:("func_80B73F1C",), - 0x80B7406C:("func_80B7406C",), - 0x80B7408C:("func_80B7408C",), - 0x80B74134:("func_80B74134",), - 0x80B741F8:("func_80B741F8",), - 0x80B742F8:("func_80B742F8",), - 0x80B74440:("func_80B74440",), - 0x80B74550:("func_80B74550",), - 0x80B747C8:("func_80B747C8",), - 0x80B74840:("func_80B74840",), - 0x80B749D0:("func_80B749D0",), - 0x80B74AD8:("func_80B74AD8",), - 0x80B74B54:("func_80B74B54",), - 0x80B74BC8:("func_80B74BC8",), - 0x80B74E5C:("func_80B74E5C",), - 0x80B750A0:("func_80B750A0",), - 0x80B7517C:("func_80B7517C",), - 0x80B751F8:("func_80B751F8",), + 0x80B73A90:("EnJg_GetShrineGoronToFocusOn",), + 0x80B73AE4:("EnJg_UpdateCollision",), + 0x80B73B98:("EnJg_GetWalkingYRotation",), + 0x80B73C58:("EnJg_ReachedPoint",), + 0x80B73DF4:("EnJg_GetCutsceneForTeachingLullabyIntro",), + 0x80B73E3C:("EnJg_SetupGoronShrineCheer",), + 0x80B73F1C:("EnJg_SetupTalk",), + 0x80B7406C:("EnJg_Idle",), + 0x80B7408C:("EnJg_GoronShrineIdle",), + 0x80B74134:("EnJg_GoronShrineTalk",), + 0x80B741F8:("EnJg_GoronShrineCheer",), + 0x80B742F8:("EnJg_AlternateTalkOrWalkInPlace",), + 0x80B74440:("EnJg_Walk",), + 0x80B74550:("EnJg_Talk",), + 0x80B747C8:("EnJg_SetupWalk",), + 0x80B74840:("EnJg_Freeze",), + 0x80B749D0:("EnJg_FrozenIdle",), + 0x80B74AD8:("EnJg_EndFrozenInteraction",), + 0x80B74B54:("EnJg_TeachLullabyIntro",), + 0x80B74BC8:("EnJg_LullabyIntroCutsceneAction",), + 0x80B74E5C:("EnJg_GetNextTextId",), + 0x80B750A0:("EnJg_GetStartingConversationTextId",), + 0x80B7517C:("EnJg_SpawnBreath",), + 0x80B751F8:("EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer",), 0x80B753A0:("EnJg_Init",), 0x80B75564:("EnJg_Destroy",), 0x80B75590:("EnJg_Update",), - 0x80B75658:("func_80B75658",), - 0x80B75708:("func_80B75708",), + 0x80B75658:("EnJg_OverrideLimbDraw",), + 0x80B75708:("EnJg_PostLimbDraw",), 0x80B757AC:("EnJg_Draw",), 0x80B76030:("func_80B76030",), 0x80B76110:("func_80B76110",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 72d74dc40..c60f50de5 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1541,11 +1541,6 @@ D_0600BA30 = 0x0600BA30; D_0600BCC8 = 0x0600BCC8; D_0600C240 = 0x0600C240; -// ovl_En_Jg - -D_0601ADC0 = 0x0601ADC0; -D_0601AFF0 = 0x0601AFF0; - // ovl_En_Jgame_Tsn D_06008AB8 = 0x06008AB8; @@ -2201,11 +2196,6 @@ D_06001888 = 0x06001888; D_060003A0 = 0x060003A0; -// ovl_Obj_Jg_Gakki - -D_0601B1E8 = 0x0601B1E8; -D_0601B210 = 0x0601B210; - // ovl_Obj_Kendo_Kanban D_06000180 = 0x06000180; From a5e631d03f1bb34bb31f41972d12ab0461d92223 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Mon, 14 Feb 2022 01:18:42 +0000 Subject: [PATCH 013/257] En_Zov (#649) * En_Zov * PR * PR --- assets/xml/objects/object_zov.xml | 10 +- spec | 3 +- src/overlays/actors/ovl_En_Zov/z_en_zov.c | 599 ++++++++++++++++++++-- src/overlays/actors/ovl_En_Zov/z_en_zov.h | 26 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 5 - 6 files changed, 600 insertions(+), 47 deletions(-) diff --git a/assets/xml/objects/object_zov.xml b/assets/xml/objects/object_zov.xml index 17d6382a9..e485291b3 100644 --- a/assets/xml/objects/object_zov.xml +++ b/assets/xml/objects/object_zov.xml @@ -37,15 +37,17 @@ - + - + - + + - + + diff --git a/spec b/spec index a139b1b1c..80de5a585 100644 --- a/spec +++ b/spec @@ -4741,8 +4741,7 @@ beginseg name "ovl_En_Zov" compress include "build/src/overlays/actors/ovl_En_Zov/z_en_zov.o" - include "build/data/ovl_En_Zov/ovl_En_Zov.data.o" - include "build/data/ovl_En_Zov/ovl_En_Zov.reloc.o" + include "build/src/overlays/actors/ovl_En_Zov/ovl_En_Zov_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.c b/src/overlays/actors/ovl_En_Zov/z_en_zov.c index 278ffa7fe..b1b93217f 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.c +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.c @@ -5,8 +5,10 @@ */ #include "z_en_zov.h" +#include "objects/object_zov/object_zov.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnZov*)thisx) @@ -15,6 +17,7 @@ void EnZov_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnZov_Update(Actor* thisx, GlobalContext* globalCtx); void EnZov_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80BD1570(EnZov* this, s16 index, u8 mode); void func_80BD187C(EnZov* this, GlobalContext* globalCtx); void func_80BD19FC(EnZov* this, GlobalContext* globalCtx); void func_80BD1BF0(EnZov* this, GlobalContext* globalCtx); @@ -23,8 +26,8 @@ void func_80BD1C84(EnZov* this, GlobalContext* globalCtx); void func_80BD1D94(EnZov* this, GlobalContext* globalCtx); void func_80BD1DB8(EnZov* this, GlobalContext* globalCtx); void func_80BD1F1C(EnZov* this, GlobalContext* globalCtx); +s32 func_80BD1FC8(GlobalContext* globalCtx, EnZov* this); -#if 0 const ActorInit En_Zov_InitVars = { ACTOR_EN_ZOV, ACTORCAT_NPC, @@ -37,63 +40,593 @@ const ActorInit En_Zov_InitVars = { (ActorFunc)EnZov_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BD26E0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 40, 0, { 0, 0, 0 } }, }; -#endif +static AnimationHeader* D_80BD270C[] = { + &object_zov_Anim_00D3EC, &object_zov_Anim_008120, &object_zov_Anim_00B4CC, &object_zov_Anim_00A888, + &object_zov_Anim_00C510, &object_zov_Anim_00CAA8, &object_zov_Anim_008120, &object_zov_Anim_00A888, + &object_zov_Anim_002B5C, &object_zov_Anim_00418C, &object_zov_Anim_005A6C, &object_zov_Anim_0066A4, + &object_zov_Anim_0017D4, &object_zov_Anim_0023F4, +}; -extern ColliderCylinderInit D_80BD26E0; +static Vec3f D_80BD2744 = { 400.0f, 600.0f, 0.0f }; -extern UNK_TYPE D_0600D3EC; +static Vec3f D_80BD2750 = { 400.0f, 600.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/EnZov_Init.s") +static TexturePtr D_80BD275C[] = { object_zov_Tex_013C38, object_zov_Tex_015138, object_zov_Tex_014138 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/EnZov_Destroy.s") +static TexturePtr D_80BD2768[] = { object_zov_Tex_0135F8, object_zov_Tex_014538 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD13DC.s") +static s8 D_80BD2770[] = { + 1, 2, 1, 0, 0, 1, 2, 1, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1440.s") +void EnZov_Init(Actor* thisx, GlobalContext* globalCtx) { + EnZov* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1470.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->actor, 0.01f); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_zov_Skel_016258, &object_zov_Anim_00D3EC, this->jontTable, + this->morphTable, 23); + Animation_PlayLoop(&this->skelAnime, &object_zov_Anim_00D3EC); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1570.s") + this->unk_320 = 0; + this->unk_32C = -1; + this->unk_326 = -1; + this->unk_328[0] = this->actor.cutscene; + this->unk_328[1] = 0x7C; + this->unk_322 = 0; + this->actionFunc = func_80BD1C84; + this->unk_144 = func_80BD1FC8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD15A4.s") + Math_Vec3f_Copy(&this->unk_2FC, &this->actor.world.pos); + Math_Vec3f_Copy(&this->unk_308, &this->actor.world.pos); + Math_Vec3f_Copy(&this->unk_314, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD160C.s") + switch (ENZOV_GET_F(&this->actor)) { + case ENZOV_F_1: + this->actionFunc = func_80BD1F1C; + func_80BD1570(this, 9, 0); + if (!(gSaveContext.weekEventReg[55] & 0x80)) { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1764.s") + case ENZOV_F_2: + this->actionFunc = func_80BD1C38; + this->actor.shape.shadowDraw = NULL; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD187C.s") + default: + this->unk_320 |= 2; + if ((gSaveContext.weekEventReg[55] & 0x80) || (gSaveContext.weekEventReg[53] & 0x20)) { + Actor_MarkForDeath(&this->actor); + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD19FC.s") +void EnZov_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnZov* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1AE0.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1BF0.s") +void func_80BD13DC(EnZov* this) { + if (this->unk_32C != -1) { + if (ActorCutscene_GetCurrentIndex() == this->unk_328[this->unk_32C]) { + ActorCutscene_Stop(this->unk_328[this->unk_32C]); + } + this->unk_32C = -1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1C38.s") +void func_80BD1440(EnZov* this, s16 arg1) { + func_80BD13DC(this); + this->unk_32C = arg1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1C84.s") +void func_80BD1470(EnZov* this, s16 index, u8 mode, f32 transitionRate) { + f32 frame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1D30.s") + if (((index != this->unk_322) || mode) && (index >= 0) && (index < ARRAY_COUNT(D_80BD270C))) { + switch (index) { + case 6: + frame = 30.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1D94.s") + case 7: + frame = 57.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1DB8.s") + default: + frame = 0.0f; + break; + } + Animation_Change(&this->skelAnime, D_80BD270C[index], 1.0f, frame, Animation_GetLastFrame(D_80BD270C[index]), + mode, transitionRate); + this->unk_322 = index; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1F1C.s") +void func_80BD1570(EnZov* this, s16 index, u8 mode) { + func_80BD1470(this, index, mode, 5.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1FC8.s") +s32 func_80BD15A4(EnZov* this, GlobalContext* globalCtx) { + if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsFacingPlayer(&this->actor, 0x3000)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/EnZov_Update.s") +void func_80BD160C(EnZov* this, GlobalContext* globalCtx) { + s32 textId = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD2380.s") + if (gSaveContext.weekEventReg[53] & 0x20) { + this->unk_320 &= ~2; + if (gSaveContext.playerForm != PLAYER_FORM_ZORA) { + textId = 0x1024; + if ((this->unk_322 == 0) || (this->unk_322 == 4)) { + func_80BD1570(this, 4, 2); + } else { + func_80BD1570(this, 6, 2); + } + } else if (this->unk_320 & 4) { + textId = 0x1023; + } else { + textId = 0x1022; + this->unk_320 |= 4; + func_80BD1570(this, 3, 2); + } + } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + func_80BD1570(this, 2, 2); + this->actionFunc = func_80BD19FC; + this->unk_324 = 10; + func_80BD1440(this, 0); + } else { + textId = 0x1020; + func_80BD1570(this, 5, 2); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD2404.s") + this->unk_320 |= 1; + if (textId != 0) { + func_801518B0(globalCtx, textId, &this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/EnZov_Draw.s") +void func_80BD1764(EnZov* this) { + if (SkelAnime_Update(&this->skelAnime)) { + switch (this->unk_322) { + case 1: + case 6: + func_80BD1570(this, 6, 2); + break; + + case 3: + case 7: + func_80BD1570(this, 7, 2); + break; + + case 4: + func_80BD1570(this, 0, 0); + break; + + case 8: + func_80BD1570(this, 9, 0); + break; + + case 10: + func_80BD1570(this, 11, 0); + break; + + case 12: + func_80BD1570(this, 13, 0); + break; + + default: + func_80BD1570(this, 0, 0); + this->unk_320 &= ~1; + break; + } + + SkelAnime_Update(&this->skelAnime); + } +} + +void func_80BD187C(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 5: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x1022: + func_80151938(globalCtx, 0x1023); + break; + + case 0x1023: + if ((this->unk_322 != 6) && (this->unk_322 != 1)) { + func_80BD1570(this, 1, 2); + } + func_801477B4(globalCtx); + this->actionFunc = func_80BD1C84; + break; + + case 0x1024: + if (this->unk_322 != 6) { + func_80BD1570(this, 0, 0); + } + func_801477B4(globalCtx); + this->actionFunc = func_80BD1C84; + break; + + default: + this->unk_320 &= ~1; + func_80BD1570(this, 0, 0); + func_801477B4(globalCtx); + this->actionFunc = func_80BD1C84; + break; + } + } + break; + + case 2: + func_801477B4(globalCtx); + this->actionFunc = func_80BD1C84; + this->unk_320 &= ~1; + func_80BD1570(this, 0, 0); + break; + } +} + +void func_80BD19FC(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); + if (this->unk_322 == 0) { + if (!(this->unk_320 & 2)) { + this->unk_320 |= 2; + this->unk_2EE = 3; + } + + if (this->unk_324 > 0) { + this->unk_324--; + } else { + func_80BD13DC(this); + func_801518B0(globalCtx, 0x1021, &this->actor); + ((EnElf*)(GET_PLAYER(globalCtx)->tatlActor))->unk_264 |= 4; + Actor_ChangeFocus(&this->actor, globalCtx, GET_PLAYER(globalCtx)->tatlActor); + this->actionFunc = func_80BD187C; + } + } else if (Animation_OnFrame(&this->skelAnime, 10.0f)) { + this->unk_320 &= ~2; + this->unk_2EE = 3; + } +} + +s32 func_80BD1AE0(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); + + if (func_800EE29C(globalCtx, 0x1F8)) { + s16 temp_v1 = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1F8)]->unk0; + + if (temp_v1 != this->unk_326) { + this->unk_326 = temp_v1; + switch (this->unk_326) { + case 1: + func_80BD1570(this, 0, 0); + break; + + case 2: + func_80BD1570(this, 8, 2); + this->unk_320 |= 0x10; + break; + + case 3: + func_80BD1470(this, 10, 2, 0.0f); + break; + + case 4: + func_80BD1570(this, 12, 2); + break; + } + } + return true; + } + return false; +} + +void func_80BD1BF0(EnZov* this, GlobalContext* globalCtx) { + if (!func_80BD1AE0(this, globalCtx)) { + func_80BD1570(this, 0, 0); + this->actionFunc = func_80BD1C84; + } +} + +void func_80BD1C38(EnZov* this, GlobalContext* globalCtx) { + if (func_80BD1AE0(this, globalCtx)) { + func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x1F8)); + } +} + +void func_80BD1C84(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80BD187C; + func_80BD160C(this, globalCtx); + } else if (func_80BD15A4(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } + + if (func_800EE29C(globalCtx, 0x1F8)) { + this->actionFunc = func_80BD1BF0; + func_80BD1BF0(this, globalCtx); + } +} + +void func_80BD1D30(EnZov* this, GlobalContext* globalCtx) { + u16 textId; + + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.weekEventReg[79] & 1) { + textId = 0x1032; + } else { + textId = 0x1033; + } + } else { + textId = 0x1031; + } + func_801518B0(globalCtx, textId, &this->actor); +} + +void func_80BD1D94(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); +} + +void func_80BD1DB8(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); + this->actor.world.rot.y = this->actor.shape.rot.y; + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x1033: + case 0x1034: + case 0x1035: + case 0x1036: + case 0x1037: + case 0x1038: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x1039: + globalCtx->nextEntranceIndex = globalCtx->setupExitList[ENZOV_GET_FE00(&this->actor)]; + globalCtx->unk_1887F = 5; + globalCtx->sceneLoadFlag = 0x14; + gSaveContext.weekEventReg[78] |= 1; + this->actionFunc = func_80BD1D94; + globalCtx->msgCtx.unk11F10 = 0; + Audio_QueueSeqCmd(0x101400FF); + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_80BD1F1C; + break; + } + } +} + +void func_80BD1F1C(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); + + if (this->actor.home.rot.y != this->actor.shape.rot.y) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x1000, 0x200); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80BD1DB8; + func_80BD1D30(this, globalCtx); + } else if (func_80BD15A4(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +s32 func_80BD1FC8(GlobalContext* globalCtx, EnZov* this) { + s32 ret; + s32 pad; + + ret = func_8013A530(globalCtx, &this->actor, 4, &this->actor.focus.pos, &this->actor.shape.rot, 10.0f, 300.0f, -1); + ret |= func_8013A530(globalCtx, &this->actor, 5, &this->unk_308, &this->actor.shape.rot, 50.0f, 160.0f, 0x3000); + ret |= func_8013A530(globalCtx, &this->actor, 6, &this->unk_314, &this->actor.shape.rot, 50.0f, 160.0f, 0x3000); + return ret; +} + +void EnZov_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZov* this = THIS; + + Actor_MoveWithGravity(&this->actor); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 4); + + this->actionFunc(this, globalCtx); + + if (!func_800EE29C(globalCtx, 0x1F8)) { + this->unk_320 &= ~0x10; + } + + if ((this->unk_320 & 1) && func_80BD15A4(this, globalCtx)) { + func_800E9250(globalCtx, &this->actor, &this->unk_2F0, &this->unk_2F6, this->actor.focus.pos); + } else { + if ((this->unk_320 & 0x10) && (this->unk_322 == 0)) { + Math_SmoothStepToS(&this->unk_2F0.x, -0x1B58, 6, 0x1838, 0x64); + } else { + Math_SmoothStepToS(&this->unk_2F0.x, 0, 6, 0x1838, 0x64); + } + Math_SmoothStepToS(&this->unk_2F0.y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_2F6.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_2F6.y, 0, 6, 0x1838, 0x64); + } + + if (DECR(this->unk_2EE) == 0) { + this->unk_2EE = Rand_S16Offset(60, 60); + } + + this->unk_2EC = this->unk_2EE; + if (this->unk_2EC >= 3) { + this->unk_2EC = 0; + } + + if ((this->unk_32C != -1) && (ActorCutscene_GetCurrentIndex() != this->unk_328[this->unk_32C])) { + if ((this->unk_32C == 0) && (ActorCutscene_GetCurrentIndex() == 0x7C)) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_328[this->unk_32C]); + } else if (ActorCutscene_GetCanPlayNext(this->unk_328[this->unk_32C])) { + ActorCutscene_Start(this->unk_328[this->unk_32C], &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->unk_328[this->unk_32C]); + } + } +} + +s32 EnZov_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnZov* this = THIS; + + if (limbIndex == 12) { + rot->x += this->unk_2F0.y; + if ((this->unk_320 & 0x10) && (this->unk_322 == 0)) { + rot->z += this->unk_2F0.x; + } + } + + if (limbIndex == 11) { + rot->x += this->unk_2F6.y; + } + return false; +} + +void EnZov_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnZov* this = THIS; + + if (limbIndex == 12) { + Matrix_MultiplyVector3fByState(&D_80BD2744, &this->actor.focus.pos); + Math_Vec3f_Copy(&this->unk_2FC, &this->actor.focus.pos); + this->unk_2FC.y += 10.0f; + } + + if (limbIndex == 18) { + Matrix_MultiplyVector3fByState(&D_80BD2750, &this->unk_308); + } + + if (limbIndex == 13) { + Matrix_MultiplyVector3fByState(&D_80BD2750, &this->unk_314); + } +} + +void EnZov_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnZov* this = THIS; + Gfx* gfx; + s32 curFrame; + s32 phi_a1; + u8 phi_v1; + + if (1) {} + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + phi_a1 = 0; + curFrame = this->skelAnime.curFrame; + phi_v1 = this->unk_2EC; + + switch (this->unk_322) { + case 0: + if ((this->unk_2EC == 0) && !(this->unk_320 & 0x10)) { + phi_v1 = 1; + } + break; + + case 5: + if (this->unk_2EC == 0) { + phi_v1 = 1; + } + break; + + case 2: + if (curFrame < 23) { + phi_v1 = 0; + } else if (curFrame >= 26) { + phi_v1 = 1; + } else if (curFrame == 24) { + phi_v1 = 0; + } else { + phi_v1 = 1; + } + break; + + case 3: + case 7: + if (curFrame <= 50) { + if (curFrame < 43) { + phi_v1 = 0; + } else { + phi_v1 = D_80BD2770[(curFrame - 43) & 3]; + } + } + phi_a1 = 1; + break; + + case 4: + if ((curFrame < 14) || (curFrame >= 24)) { + phi_v1 = 1; + } else { + phi_v1 = D_80BD2770[4 + ((curFrame - 14) & 3)]; + } + phi_a1 = 1; + break; + + case 8: + phi_v1 = 0; + break; + + case 9: + phi_v1 = 0; + phi_a1 = 1; + break; + } + + gfx = POLY_OPA_DISP; + gSPSegment(&gfx[0], 0x09, Lib_SegmentedToVirtual(D_80BD275C[phi_v1])); + gSPSegment(&gfx[1], 0x08, Lib_SegmentedToVirtual(D_80BD2768[phi_a1])); + POLY_OPA_DISP = &gfx[2]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnZov_OverrideLimbDraw, EnZov_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.h b/src/overlays/actors/ovl_En_Zov/z_en_zov.h index 2a4650544..ce1cc9d0f 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.h +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.h @@ -6,10 +6,34 @@ struct EnZov; typedef void (*EnZovActionFunc)(struct EnZov*, GlobalContext*); +typedef s32 (*EnZovUnkFunc)(GlobalContext*, struct EnZov*); + +#define ENZOV_GET_F(thisx) ((thisx)->params & 0xF) +#define ENZOV_GET_FE00(thisx) (((thisx)->params & 0xFE00) >> 9) + +#define ENZOV_F_1 1 +#define ENZOV_F_2 2 typedef struct EnZov { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1EC]; + /* 0x0144 */ EnZovUnkFunc unk_144; + /* 0x0148 */ Vec3s jontTable[23]; + /* 0x01D2 */ Vec3s morphTable[23]; + /* 0x025C */ SkelAnime skelAnime; + /* 0x02A0 */ ColliderCylinder collider; + /* 0x02EC */ s16 unk_2EC; + /* 0x02EE */ s16 unk_2EE; + /* 0x02F0 */ Vec3s unk_2F0; + /* 0x02F6 */ Vec3s unk_2F6; + /* 0x02FC */ Vec3f unk_2FC; + /* 0x0308 */ Vec3f unk_308; + /* 0x0314 */ Vec3f unk_314; + /* 0x0320 */ u16 unk_320; + /* 0x0322 */ s16 unk_322; + /* 0x0324 */ s16 unk_324; + /* 0x0326 */ s16 unk_326; + /* 0x0328 */ s16 unk_328[2]; + /* 0x032C */ s16 unk_32C; /* 0x0330 */ EnZovActionFunc actionFunc; } EnZov; // size = 0x334 diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 5d6fe3750..fc1336465 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -15730,8 +15730,8 @@ 0x80BD1F1C:("func_80BD1F1C",), 0x80BD1FC8:("func_80BD1FC8",), 0x80BD20B4:("EnZov_Update",), - 0x80BD2380:("func_80BD2380",), - 0x80BD2404:("func_80BD2404",), + 0x80BD2380:("EnZov_OverrideLimbDraw",), + 0x80BD2404:("EnZov_PostLimbDraw",), 0x80BD24B4:("EnZov_Draw",), 0x80BD2A30:("func_80BD2A30",), 0x80BD2AE0:("func_80BD2AE0",), diff --git a/undefined_syms.txt b/undefined_syms.txt index c60f50de5..38b0953cc 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2080,11 +2080,6 @@ D_06004FE4 = 0x06004FE4; D_06005098 = 0x06005098; D_06005250 = 0x06005250; -// ovl_En_Zov - -D_0600D3EC = 0x0600D3EC; -D_06016258 = 0x06016258; - // ovl_En_Zow D_060029F0 = 0x060029F0; From 18e714e09847e441551705b424d0ec8488fa1834 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sun, 13 Feb 2022 17:28:19 -0800 Subject: [PATCH 014/257] Document object_cow (#650) * Document object_cow * Respond to reviews * Reorder flags --- assets/xml/objects/object_cow.xml | 87 +++++++++++-------- src/overlays/actors/ovl_En_Cow/z_en_cow.c | 37 ++++---- src/overlays/actors/ovl_En_Cow/z_en_cow.h | 12 +-- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 8 +- 4 files changed, 77 insertions(+), 67 deletions(-) diff --git a/assets/xml/objects/object_cow.xml b/assets/xml/objects/object_cow.xml index 390c54b36..535d5dd85 100644 --- a/assets/xml/objects/object_cow.xml +++ b/assets/xml/objects/object_cow.xml @@ -1,38 +1,57 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index c41c055ee..fd42fd3f3 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -5,9 +5,8 @@ */ #include "z_en_cow.h" -#include "objects/object_cow/object_cow.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnCow*)thisx) @@ -107,9 +106,9 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { switch (EN_COW_TYPE(thisx)) { case EN_COW_TYPE_DEFAULT: case EN_COW_TYPE_ABDUCTED: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowBodySkel, NULL, this->jointTable, this->morphTable, + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowSkel, NULL, this->jointTable, this->morphTable, COW_LIMB_MAX); - Animation_PlayLoop(&this->skelAnime, &gCowBodyChewAnim); + Animation_PlayLoop(&this->skelAnime, &gCowChewAnim); Collider_InitAndSetCylinder(globalCtx, &this->colliders[0], &this->actor, &sCylinderInit); Collider_InitAndSetCylinder(globalCtx, &this->colliders[1], &this->actor, &sCylinderInit); @@ -136,7 +135,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { break; case EN_COW_TYPE_TAIL: SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, - COW_LIMB_MAX); + COW_TAIL_LIMB_MAX); Animation_PlayLoop(&this->skelAnime, &gCowTailIdleAnim); this->actor.update = EnCow_UpdateTail; @@ -145,7 +144,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { EnCow_SetTailPos(this); - this->actor.flags &= ~EN_COW_FLAG_IS_TAIL; + this->actor.flags &= ~ACTOR_FLAG_1; this->animationTimer = Rand_ZeroFloat(1000.0f) + 40.0f; break; } @@ -171,13 +170,13 @@ void EnCow_UpdateAnimation(EnCow* this, GlobalContext* globalCtx) { this->animationTimer--; } else { this->animationTimer = Rand_ZeroFloat(500.0f) + 40.0f; - Animation_Change(&this->skelAnime, &gCowBodyChewAnim, 1.0f, this->skelAnime.curFrame, - Animation_GetLastFrame(&gCowBodyChewAnim), ANIMMODE_ONCE, 1.0f); + Animation_Change(&this->skelAnime, &gCowChewAnim, 1.0f, this->skelAnime.curFrame, + Animation_GetLastFrame(&gCowChewAnim), ANIMMODE_ONCE, 1.0f); } if (this->actor.xzDistToPlayer < 150.0f) { if (!(this->flags & EN_COW_FLAG_PLAYER_HAS_APPROACHED)) { this->flags |= EN_COW_FLAG_PLAYER_HAS_APPROACHED; - if (this->skelAnime.animation == &gCowBodyChewAnim) { + if (this->skelAnime.animation == &gCowChewAnim) { this->animationTimer = 0; } } @@ -202,7 +201,7 @@ void EnCow_UpdateAnimation(EnCow* this, GlobalContext* globalCtx) { void EnCow_TalkEnd(EnCow* this, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_801477B4(globalCtx); this->actionFunc = EnCow_Idle; } @@ -210,7 +209,7 @@ void EnCow_TalkEnd(EnCow* this, GlobalContext* globalCtx) { void EnCow_GiveMilkEnd(EnCow* this, GlobalContext* globalCtx) { if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = EnCow_Idle; } } @@ -226,7 +225,7 @@ void EnCow_GiveMilkWait(EnCow* this, GlobalContext* globalCtx) { void EnCow_GiveMilk(EnCow* this, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_801477B4(globalCtx); this->actionFunc = EnCow_GiveMilkWait; Actor_PickUp(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); @@ -255,7 +254,7 @@ void EnCow_Talk(EnCow* this, GlobalContext* globalCtx) { this->actionFunc = EnCow_TalkEnd; } } else { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 170.0f); this->actor.textId = 0x32C8; //! @bug textId is reset to this no matter the intial value } @@ -273,7 +272,7 @@ void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 25000) { D_801BDAA4 = 0; this->actionFunc = EnCow_Talk; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 170.0f); this->actor.textId = 0x32C8; // Text to give milk after playing Epona's Song. @@ -297,7 +296,7 @@ void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x32CA; // Text if you don't have an empty bottle. } - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 170.0f); this->actionFunc = EnCow_Talk; } @@ -344,12 +343,12 @@ void EnCow_Update(Actor* thisx, GlobalContext* globalCtx2) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); if (SkelAnime_Update(&this->skelAnime)) { - if (this->skelAnime.animation == &gCowBodyChewAnim) { + if (this->skelAnime.animation == &gCowChewAnim) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_COW_CRY); - Animation_Change(&this->skelAnime, &gCowBodyMoveHeadAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gCowBodyMoveHeadAnim), ANIMMODE_ONCE, 1.0f); + Animation_Change(&this->skelAnime, &gCowMooAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCowMooAnim), + ANIMMODE_ONCE, 1.0f); } else { - Animation_Change(&this->skelAnime, &gCowBodyChewAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCowBodyChewAnim), + Animation_Change(&this->skelAnime, &gCowChewAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCowChewAnim), ANIMMODE_LOOP, 1.0f); } } diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.h b/src/overlays/actors/ovl_En_Cow/z_en_cow.h index fd865cecb..bb9319ad9 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.h +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.h @@ -2,10 +2,10 @@ #define Z_EN_COW_H #include "global.h" +#include "objects/object_cow/object_cow.h" #define EN_COW_TYPE(thisx) ((thisx)->params & 0xF) -#define EN_COW_FLAG_IS_TAIL (1 << 0) // This is never set but it is cleared for tail types #define EN_COW_FLAG_PLAYER_HAS_APPROACHED (1 << 1) #define EN_COW_FLAG_WONT_GIVE_MILK (1 << 2) @@ -19,16 +19,6 @@ struct EnCow; typedef void (*EnCowActionFunc)(struct EnCow*, GlobalContext*); -typedef enum { - /* 0 */ COW_LIMB_NONE, - /* 1 */ COW_LIMB_ROOT, - /* 2 */ COW_LIMB_HEAD, - /* 3 */ COW_LIMB_JAW, - /* 4 */ COW_LIMB_NOSE, - /* 5 */ COW_LIMB_NOSE_RING, - /* 6 */ COW_LIMB_MAX, -} ObjectCowLimbs; - typedef struct EnCow { /* 0x0000 */ Actor actor; /* 0x0144 */ ColliderCylinder colliders[2]; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 6b50e10e8..0df7e2a27 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -2364,8 +2364,9 @@ void func_80B47FA8(Actor* thisx, GlobalContext* globalCtx) { Actor_SetObjectDependency(globalCtx, thisx); this->actor.update = func_80B48060; this->actor.draw = func_80B4E158; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowBodySkel, NULL, this->jointTable, this->morphTable, 6); - Animation_PlayLoop(&this->skelAnime, &gCowBodyMoveHeadAnim); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowSkel, NULL, this->jointTable, this->morphTable, + COW_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gCowMooAnim); } } @@ -2407,7 +2408,8 @@ void func_80B481C4(Actor* thisx, GlobalContext* globalCtx) { Actor_SetObjectDependency(globalCtx, &this->actor); this->actor.update = func_80B4827C; this->actor.draw = func_80B4E1B0; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, 6); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, + COW_TAIL_LIMB_MAX); Animation_PlayLoop(&this->skelAnime, &gCowTailSwishAnim); } } From 7565f9f052e5761ff9ffffacf8b5ca66cb346f4d Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Mon, 14 Feb 2022 01:32:56 +0000 Subject: [PATCH 015/257] En_Insect (#652) * En_Insect * WHO DIDN'T FORMAT?! * PR --- spec | 3 +- .../actors/ovl_En_Insect/z_en_insect.c | 472 ++++++++++++++++-- .../actors/ovl_En_Insect/z_en_insect.h | 15 +- tools/disasm/functions.txt | 4 +- 4 files changed, 452 insertions(+), 42 deletions(-) diff --git a/spec b/spec index 80de5a585..d5116fff1 100644 --- a/spec +++ b/spec @@ -1359,8 +1359,7 @@ beginseg name "ovl_En_Insect" compress include "build/src/overlays/actors/ovl_En_Insect/z_en_insect.o" - include "build/data/ovl_En_Insect/ovl_En_Insect.data.o" - include "build/data/ovl_En_Insect/ovl_En_Insect.reloc.o" + include "build/src/overlays/actors/ovl_En_Insect/ovl_En_Insect_reloc.o" endseg beginseg 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 b3c1d2dd1..75c70113e 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.c +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.c @@ -5,6 +5,7 @@ */ #include "z_en_insect.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000000 @@ -15,15 +16,22 @@ void EnInsect_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnInsect_Update(Actor* thisx, GlobalContext* globalCtx); void EnInsect_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_8091AC78(EnInsect* this); void func_8091ACC4(EnInsect* this, GlobalContext* globalCtx); +void func_8091AE10(EnInsect* this); void func_8091AE5C(EnInsect* this, GlobalContext* globalCtx); +void func_8091B030(EnInsect* this); void func_8091B07C(EnInsect* this, GlobalContext* globalCtx); void func_8091B2D8(EnInsect* this, GlobalContext* globalCtx); +void func_8091B3D0(EnInsect* this); void func_8091B440(EnInsect* this, GlobalContext* globalCtx); +void func_8091B618(EnInsect* this); void func_8091B670(EnInsect* this, GlobalContext* globalCtx); +void func_8091B928(EnInsect* this); void func_8091B984(EnInsect* this, GlobalContext* globalCtx); -#if 0 +s16 D_8091BD60 = 0; + const ActorInit En_Insect_InitVars = { ACTOR_EN_INSECT, ACTORCAT_ITEMACTION, @@ -36,74 +44,466 @@ const ActorInit En_Insect_InitVars = { (ActorFunc)EnInsect_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8091BD84[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 5 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8091BDA8 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_8091BD84, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8091BDBC[] = { +u16 D_8091BDB8[] = { 0, 5 }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 700, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 20, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 30, ICHAIN_STOP), }; -#endif +Vec3f D_8091BDCC = { 0.0f, 0.0f, 0.0f }; -extern ColliderJntSphElementInit D_8091BD84[1]; -extern ColliderJntSphInit D_8091BDA8; -extern InitChainEntry D_8091BDBC[]; +void func_8091A8A0(EnInsect* this) { + this->unk_30C = D_8091BDB8[ENINSECT_GET_1(&this->actor)]; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091A8A0.s") +f32 EnInsect_XZDistanceSquared(Vec3f* arg0, Vec3f* arg1) { + return SQ(arg0->x - arg1->x) + SQ(arg0->z - arg1->z); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091A8C4.s") +s32 EnInsect_InBottleRange(EnInsect* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + Vec3f sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091A8F4.s") + if (this->actor.xzDistToPlayer < 32.0f) { + sp1C.x = player->actor.world.pos.x + (Math_SinS(BINANG_ROT180(this->actor.yawTowardsPlayer)) * 16.0f); + sp1C.y = player->actor.world.pos.y; + sp1C.z = player->actor.world.pos.z + (Math_CosS(BINANG_ROT180(this->actor.yawTowardsPlayer)) * 16.0f); + if (EnInsect_XZDistanceSquared(&sp1C, &this->actor.world.pos) <= SQ(20.0f)) { + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091A9E4.s") +void func_8091A9E4(EnInsect* this) { + if (this->unk_316 > 0) { + this->unk_316--; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/EnInsect_Init.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MUSI_WALK); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/EnInsect_Destroy.s") + this->unk_316 = 3.0f / CLAMP_MIN(this->skelAnime.playSpeed, 0.1f); + if (this->unk_316 < 2) { + this->unk_316 = 2; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091AC78.s") +void EnInsect_Init(Actor* thisx, GlobalContext* globalCtx) { + EnInsect* this = THIS; + f32 rand; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091ACC4.s") + this->actor.world.rot.y = Rand_Next() & 0xFFFF; + this->actor.home.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.y = this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091AE10.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + func_8091A8A0(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091AE5C.s") + SkelAnime_Init(globalCtx, &this->skelAnime, &gameplay_keep_Skel_0527A0, &gameplay_keep_Anim_05140C, + this->jointTable, this->morphTable, 24); + Animation_Change(&this->skelAnime, &gameplay_keep_Anim_05140C, 1.0f, 0.0f, 0.0f, 1, 0.0f); + Collider_InitJntSph(globalCtx, &this->collider); + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B030.s") + { + ColliderJntSphElement* colliderElement = &this->collider.elements[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B07C.s") + colliderElement->dim.worldSphere.radius = colliderElement->dim.modelSphere.radius * colliderElement->dim.scale; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B274.s") + this->actor.colChkInfo.mass = 30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B2D8.s") + if (this->unk_30C & 1) { + this->actor.gravity = -0.2f; + this->actor.terminalVelocity = -2.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B3D0.s") + if (this->unk_30C & 4) { + this->unk_314 = Rand_S16Offset(200, 40); + this->actor.flags |= ACTOR_FLAG_10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B440.s") + rand = Rand_ZeroOne(); + if (rand < 0.3f) { + func_8091AC78(this); + } else if (rand < 0.4f) { + func_8091AE10(this); + } else { + func_8091B030(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B618.s") +void EnInsect_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyJntSph(globalCtx, &THIS->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B670.s") +void func_8091AC78(EnInsect* this) { + this->unk_312 = Rand_S16Offset(5, 35); + this->actionFunc = func_8091ACC4; + this->unk_30C |= 0x100; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B928.s") +void func_8091ACC4(EnInsect* this, GlobalContext* globalCtx) { + f32 temp_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B984.s") + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/EnInsect_Update.s") + temp_f2 = (Rand_ZeroOne() * 0.8f) + (this->actor.speedXZ * 1.2f); + if (temp_f2 < 0.0f) { + this->skelAnime.playSpeed = 0.0f; + } else { + f32 clamped = CLAMP_MAX(temp_f2, 1.9f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/EnInsect_Draw.s") + this->skelAnime.playSpeed = clamped; + } + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y = this->actor.world.rot.y; + + if (this->unk_312 <= 0) { + func_8091AE10(this); + } + + if ((this->unk_30C & 4) && (this->unk_314 <= 0)) { + func_8091B3D0(this); + } else if ((this->unk_30C & 1) && (this->actor.bgCheckFlags & 0x40)) { + func_8091B618(this); + } else if (this->actor.xzDistToPlayer < 40.0f) { + func_8091B030(this); + } +} + +void func_8091AE10(EnInsect* this) { + this->unk_312 = Rand_S16Offset(10, 45); + this->actionFunc = func_8091AE5C; + this->unk_30C |= 0x100; +} + +void func_8091AE5C(EnInsect* this, GlobalContext* globalCtx) { + s32 pad; + f32 temp_f0; + + Math_SmoothStepToF(&this->actor.speedXZ, 1.5f, 0.1f, 0.5f, 0.0f); + + if ((EnInsect_XZDistanceSquared(&this->actor.world.pos, &this->actor.home.pos) > SQ(40.0f)) || + (this->unk_312 < 4)) { + Math_ScaledStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos), + 0x7D0); + } else if ((this->actor.child != NULL) && (&this->actor != this->actor.child)) { + Math_ScaledStepToS(&this->actor.world.rot.y, + Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.child->world.pos), 0x7D0); + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + + temp_f0 = this->actor.speedXZ * 1.4f; + this->skelAnime.playSpeed = CLAMP(temp_f0, 0.7f, 1.9f); + SkelAnime_Update(&this->skelAnime); + + if (this->unk_312 <= 0) { + func_8091AC78(this); + } + + if ((this->unk_30C & 4) && (this->unk_314 <= 0)) { + func_8091B3D0(this); + } else if ((this->unk_30C & 1) && (this->actor.bgCheckFlags & 0x40)) { + func_8091B618(this); + } else if (this->actor.xzDistToPlayer < 40.0f) { + func_8091B030(this); + } +} + +void func_8091B030(EnInsect* this) { + this->unk_312 = Rand_S16Offset(10, 40); + this->actionFunc = func_8091B07C; + this->unk_30C |= 0x100; +} + +void func_8091B07C(EnInsect* this, GlobalContext* globalCtx) { + s32 pad; + f32 speed; + s16 frames; + s16 yaw; + s32 sp38 = this->actor.xzDistToPlayer < 40.0f; + + Math_SmoothStepToF(&this->actor.speedXZ, 1.8f, 0.1f, 0.5f, 0.0f); + + if ((EnInsect_XZDistanceSquared(&this->actor.world.pos, &this->actor.home.pos) > SQ(160.0f)) || + (this->unk_312 < 4)) { + Math_ScaledStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos), + 0x7D0); + } else if (sp38) { + frames = globalCtx->state.frames; + yaw = BINANG_ROT180(this->actor.yawTowardsPlayer); + if ((frames & 0x10) != 0) { + if ((frames & 0x20) != 0) { + yaw += 0x2000; + } + } else if ((frames & 0x20) != 0) { + yaw -= 0x2000; + } + + if (globalCtx) {} + Math_ScaledStepToS(&this->actor.world.rot.y, yaw, 0x7D0); + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + + speed = this->actor.speedXZ * 1.6f; + this->skelAnime.playSpeed = CLAMP(speed, 0.8f, 1.9f); + SkelAnime_Update(&this->skelAnime); + + if ((this->unk_312 <= 0) || !sp38) { + func_8091AC78(this); + } else if ((this->unk_30C & 1) && (this->actor.bgCheckFlags & 0x40)) { + func_8091B618(this); + } +} + +void func_8091B274(EnInsect* this) { + this->unk_312 = 200; + Actor_SetScale(&this->actor, 0.001f); + this->actor.draw = NULL; + this->actor.speedXZ = 0.0f; + this->skelAnime.playSpeed = 0.3f; + this->actionFunc = func_8091B2D8; + this->unk_30C &= ~0x100; +} + +void func_8091B2D8(EnInsect* this, GlobalContext* globalCtx) { + if ((this->unk_312 == 20) && !(this->unk_30C & 4)) { + this->actor.draw = EnInsect_Draw; + } else if (this->unk_312 == 0) { + if (this->unk_30C & 4) { + Actor_MarkForDeath(&this->actor); + return; + } + + Actor_SetScale(&this->actor, 0.01f); + func_8091AC78(this); + } else if (this->unk_312 < 20) { + Actor_SetScale(&this->actor, CLAMP_MAX(this->actor.scale.x + 0.001f, 0.01f)); + SkelAnime_Update(&this->skelAnime); + } +} + +void func_8091B3D0(EnInsect* this) { + this->unk_312 = 60; + this->skelAnime.playSpeed = 1.9f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); + Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); + this->actionFunc = func_8091B440; + this->unk_30C &= ~0x100; + this->unk_30C |= 8; +} + +void func_8091B440(EnInsect* this, GlobalContext* globalCtx) { + s32 pad[2]; + Vec3f sp34; + + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f); + Math_StepToS(&this->actor.shape.rot.x, 0x2AAA, 0x160); + Actor_SetScale(&this->actor, CLAMP_MIN(this->actor.scale.x - 0.0002f, 0.001f)); + + this->actor.shape.yOffset -= 0.8f; + this->actor.world.pos.x = (Rand_ZeroOne() + this->actor.home.pos.x) - 0.5f; + this->actor.world.pos.z = (Rand_ZeroOne() + this->actor.home.pos.z) - 0.5f; + + SkelAnime_Update(&this->skelAnime); + + if ((this->unk_312 > 20) && (Rand_ZeroOne() < 0.1f)) { + sp34.x = Math_SinS(this->actor.shape.rot.y) * -0.6f; + sp34.y = Math_SinS(this->actor.shape.rot.x) * 0.6f; + sp34.z = Math_CosS(this->actor.shape.rot.y) * -0.6f; + func_800B1210(globalCtx, &this->actor.world.pos, &sp34, &D_8091BDCC, (Rand_ZeroOne() * 5.0f) + 8.0f, + (Rand_ZeroOne() * 5.0f) + 8.0f); + } + + if (this->unk_312 <= 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_8091B618(EnInsect* this) { + this->unk_312 = Rand_S16Offset(120, 50); + this->unk_310 = 0; + this->unk_30E = this->unk_310; + this->actionFunc = func_8091B670; + this->unk_30C &= ~0x100; +} + +void func_8091B670(EnInsect* this, GlobalContext* globalCtx) { + s32 pad[2]; + s16 temp; + Vec3f sp40; + + if (this->unk_312 > 80) { + Math_StepToF(&this->actor.speedXZ, 0.6f, 0.08f); + } else { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.02f); + } + + this->actor.velocity.y = 0.0f; + this->actor.world.pos.y += this->actor.depthInWater; + + this->skelAnime.playSpeed = CLAMP(this->unk_312 * 0.018f, 0.1f, 1.9f); + SkelAnime_Update(&this->skelAnime); + + if (this->unk_312 > 80) { + this->unk_30E += Rand_S16Offset(-50, 100); + this->unk_310 += Rand_S16Offset(-300, 600); + } + + temp = this->skelAnime.playSpeed * 200.0f; + this->unk_30E = CLAMP(this->unk_30E, -temp, temp); + this->actor.world.rot.y += this->unk_30E; + + temp = this->skelAnime.playSpeed * 1000.0f; + this->unk_310 = CLAMP(this->unk_310, -temp, temp); + + this->actor.shape.rot.y += this->unk_310; + Math_ScaledStepToS(&this->actor.world.rot.x, 0, 0xBB8); + this->actor.shape.rot.x = this->actor.world.rot.x; + + if (Rand_ZeroOne() < 0.03f) { + sp40.x = this->actor.world.pos.x; + sp40.y = this->actor.world.pos.y + this->actor.depthInWater; + sp40.z = this->actor.world.pos.z; + EffectSsGRipple_Spawn(globalCtx, &sp40, 40, 200, 4); + } + + if ((this->unk_312 <= 0) || ((this->unk_30C & 4) && (this->unk_314 <= 0))) { + func_8091B928(this); + } else if (!(this->actor.bgCheckFlags & 0x40)) { + func_8091AC78(this); + } +} + +void func_8091B928(EnInsect* this) { + this->unk_312 = 100; + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->actor.terminalVelocity = -0.8f; + this->actor.gravity = -0.04f; + this->unk_30C &= ~1; + this->actionFunc = func_8091B984; + this->unk_30C &= ~0x100; + this->unk_30C |= 8; +} + +void func_8091B984(EnInsect* this, GlobalContext* globalCtx) { + this->actor.shape.rot.x -= 0x1F4; + this->actor.shape.rot.y += 0xC8; + Actor_SetScale(&this->actor, CLAMP_MIN(this->actor.scale.x - 0.00005f, 0.001f)); + + if ((this->actor.depthInWater > 5.0f) && (this->actor.depthInWater < 30.0f) && (Rand_ZeroOne() < 0.3f)) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, -5.0f, 5.0f, 5.0f, (Rand_ZeroOne() * 0.04f) + 0.02f); + } + + if (this->unk_312 <= 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnInsect_Update(Actor* thisx, GlobalContext* globalCtx) { + EnInsect* this = THIS; + s32 phi_v0; + + if ((this->actor.child != NULL) && (this->actor.child->update == NULL) && (&this->actor != this->actor.child)) { + this->actor.child = NULL; + } + + if (this->unk_312 > 0) { + this->unk_312--; + } + + if (this->unk_314 > 0) { + this->unk_314--; + } + + this->actionFunc(this, globalCtx); + + if (this->actor.update != NULL) { + Actor_MoveWithGravity(&this->actor); + if (this->unk_30C & 0x100) { + if (this->unk_30C & 1) { + if (this->actor.bgCheckFlags & 1) { + func_8091A9E4(this); + } + } else { + func_8091A9E4(this); + } + } + + phi_v0 = 0; + if (this->unk_30C & 1) { + phi_v0 = 4; + } + + if (phi_v0 != 0) { + phi_v0 |= 0x40; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 8.0f, 5.0f, 0.0f, phi_v0); + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + func_8091B274(this); + } else if ((this->actor.xzDistToPlayer < 50.0f) && (this->actionFunc != func_8091B2D8)) { + if (!(this->unk_30C & 0x20) && (this->unk_314 < 180)) { + ColliderJntSphElement* colliderElement = &this->collider.elements[0]; + + colliderElement->dim.worldSphere.center.x = this->actor.world.pos.x; + colliderElement->dim.worldSphere.center.y = this->actor.world.pos.y; + colliderElement->dim.worldSphere.center.z = this->actor.world.pos.z; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (!(this->unk_30C & 8) && (D_8091BD60 < 4) && EnInsect_InBottleRange(this, globalCtx) && + Actor_PickUp(&this->actor, globalCtx, GI_MAX, 60.0f, 30.0f)) { + D_8091BD60++; + } + } + + Actor_SetFocus(&this->actor, 0.0f); + } +} + +void EnInsect_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnInsect* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); + D_8091BD60 = 0; +} 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 be1ea96dd..612c6ab20 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.h +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.h @@ -7,11 +7,22 @@ struct EnInsect; typedef void (*EnInsectActionFunc)(struct EnInsect*, GlobalContext*); +#define ENINSECT_GET_1(thisx) ((thisx)->params & 1) + typedef struct EnInsect { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C4]; + /* 0x0144 */ ColliderJntSph collider; + /* 0x0164 */ ColliderJntSphElement colliderElements[1]; + /* 0x01A4 */ SkelAnime skelAnime; + /* 0x01E8 */ Vec3s jointTable[24]; + /* 0x0278 */ Vec3s morphTable[24]; /* 0x0308 */ EnInsectActionFunc actionFunc; - /* 0x030C */ char unk_30C[0xC]; + /* 0x030C */ u16 unk_30C; + /* 0x030E */ s16 unk_30E; + /* 0x0310 */ s16 unk_310; + /* 0x0312 */ s16 unk_312; + /* 0x0314 */ s16 unk_314; + /* 0x0316 */ s16 unk_316; } EnInsect; // size = 0x318 extern const ActorInit En_Insect_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index fc1336465..b008d3340 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -6912,8 +6912,8 @@ 0x8091A5A0:("func_8091A5A0",), 0x8091A7B0:("func_8091A7B0",), 0x8091A8A0:("func_8091A8A0",), - 0x8091A8C4:("func_8091A8C4",), - 0x8091A8F4:("func_8091A8F4",), + 0x8091A8C4:("EnInsect_XZDistanceSquared",), + 0x8091A8F4:("EnInsect_InBottleRange",), 0x8091A9E4:("func_8091A9E4",), 0x8091AA78:("EnInsect_Init",), 0x8091AC4C:("EnInsect_Destroy",), From 01ca078226f37a2ba5be90e957ffe081db059fdf Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Mon, 14 Feb 2022 12:38:46 +1100 Subject: [PATCH 016/257] Import code_8019AF00.c (Audio) data & bss, introduce z64ocarina.h (#575) * Import code_8018AF00 Data * code_8019AF00.c BSS Imported * format * Small touch-up * rename `bgm.h` to `sequence.h` * Missed a variable * PR Feedback 1 --- include/{bgm.h => sequence.h} | 146 +- include/variables.h | 3 +- include/z64.h | 3 +- include/z64audio.h | 91 +- include/z64ocarina.h | 125 ++ spec | 2 - src/code/audio/code_8019AF00.c | 1887 ++++++++++++++++++++- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 4 +- tools/disasm/variables.txt | 382 ++--- 9 files changed, 2353 insertions(+), 290 deletions(-) rename include/{bgm.h => sequence.h} (60%) create mode 100644 include/z64ocarina.h diff --git a/include/bgm.h b/include/sequence.h similarity index 60% rename from include/bgm.h rename to include/sequence.h index c3ac3b1d1..d46e96aea 100644 --- a/include/bgm.h +++ b/include/sequence.h @@ -1,5 +1,5 @@ -#ifndef BGM_H -#define BGM_H +#ifndef SEQUENCE_H +#define SEQUENCE_H #define NA_BGM_STOP 0x100000FF @@ -133,4 +133,146 @@ #define NA_BGM_END_CREDITS_2 0x82 // The End/Credits II "STAFFROLL2" #define NA_BGM_DISABLED 0xFFFF +typedef enum { + /* 0 */ SEQ_PLAYER_BGM_MAIN, + /* 1 */ SEQ_PLAYER_FANFARE, + /* 2 */ SEQ_PLAYER_SFX, + /* 3 */ SEQ_PLAYER_BGM_SUB, + /* 4 */ SEQ_PLAYER_NATURE +} SequencePlayerId; + +typedef enum { + /* 0 */ SEQ_MODE_DEFAULT, + /* 1 */ SEQ_MODE_ENEMY, + /* 2 */ SEQ_MODE_STILL, // Not moving or first-person view + /* 3 */ SEQ_MODE_IGNORE +} SequenceMode; + +typedef enum { + /* 0x0 */ CHANNEL_IO_PORT_0, + /* 0x1 */ CHANNEL_IO_PORT_1, + /* 0x2 */ CHANNEL_IO_PORT_2, + /* 0x3 */ CHANNEL_IO_PORT_3, + /* 0x4 */ CHANNEL_IO_PORT_4, + /* 0x5 */ CHANNEL_IO_PORT_5, + /* 0x6 */ CHANNEL_IO_PORT_6, + /* 0x7 */ CHANNEL_IO_PORT_7 +} ChannelIOPort; + +typedef enum { + /* 0x0 */ NATURE_CHANNEL_STREAM_0, + /* 0x1 */ NATURE_CHANNEL_CRITTER_0, + /* 0x2 */ NATURE_CHANNEL_CRITTER_1, + /* 0x3 */ NATURE_CHANNEL_CRITTER_2, + /* 0x4 */ NATURE_CHANNEL_CRITTER_3, + /* 0x5 */ NATURE_CHANNEL_CRITTER_4, + /* 0x6 */ NATURE_CHANNEL_CRITTER_5, + /* 0x7 */ NATURE_CHANNEL_CRITTER_6, + /* 0x8 */ NATURE_CHANNEL_CRITTER_7, + /* 0xC */ NATURE_CHANNEL_STREAM_1 = 12, + /* 0xD */ NATURE_CHANNEL_UNK, + /* 0xE */ NATURE_CHANNEL_RAIN, + /* 0xF */ NATURE_CHANNEL_LIGHTNING +} NatureChannelIdx; // playerIdx = 4 + +typedef enum { + /* 0x00 */ NATURE_AMBIENCE_0, + /* 0x01 */ NATURE_AMBIENCE_1, + /* 0x02 */ NATURE_AMBIENCE_2, + /* 0x03 */ NATURE_AMBIENCE_3, + /* 0x04 */ NATURE_AMBIENCE_4, + /* 0x05 */ NATURE_AMBIENCE_5, + /* 0x06 */ NATURE_AMBIENCE_6, + /* 0x07 */ NATURE_AMBIENCE_7, + /* 0x08 */ NATURE_AMBIENCE_8, + /* 0x09 */ NATURE_AMBIENCE_9, + /* 0x0A */ NATURE_AMBIENCE_A, + /* 0x0B */ NATURE_AMBIENCE_B, + /* 0x0C */ NATURE_AMBIENCE_C, + /* 0x0D */ NATURE_AMBIENCE_D, + /* 0x0E */ NATURE_AMBIENCE_E, + /* 0x0F */ NATURE_AMBIENCE_F, + /* 0x10 */ NATURE_AMBIENCE_10, + /* 0x11 */ NATURE_AMBIENCE_11, + /* 0x12 */ NATURE_AMBIENCE_12, + /* 0x13 */ NATURE_AMBIENCE_13 +} NatureAmbienceId; // playerIdx = 4 + +typedef enum { + /* 0x00 */ NATURE_STREAM_0, + /* 0x01 */ NATURE_STREAM_1, + /* 0x02 */ NATURE_STREAM_2, + /* 0x03 */ NATURE_STREAM_3 +} NatureStreamId; + +typedef enum { + /* 0x00 */ NATURE_CRITTER_00, + /* 0x01 */ NATURE_CRITTER_01, + /* 0x02 */ NATURE_CRITTER_02, + /* 0x03 */ NATURE_CRITTER_03, + /* 0x04 */ NATURE_CRITTER_04, + /* 0x05 */ NATURE_CRITTER_05, + /* 0x06 */ NATURE_CRITTER_06, + /* 0x07 */ NATURE_CRITTER_07, + /* 0x08 */ NATURE_CRITTER_08, + /* 0x09 */ NATURE_CRITTER_09, + /* 0x0A */ NATURE_CRITTER_10, + /* 0x0B */ NATURE_CRITTER_11, + /* 0x0C */ NATURE_CRITTER_12, + /* 0x0D */ NATURE_CRITTER_13, + /* 0x0E */ NATURE_CRITTER_14, + /* 0x0F */ NATURE_CRITTER_15, + /* 0x10 */ NATURE_CRITTER_16, + /* 0x11 */ NATURE_CRITTER_17, + /* 0x12 */ NATURE_CRITTER_18, + /* 0x13 */ NATURE_CRITTER_19 +} NatureAmimalId; + +#define NATURE_IO_CRITTER_0_TYPE(type) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_0_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_0_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_0_PORT5(reverb) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_CRITTER_1_TYPE(type) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_1_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_1_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_1_PORT5(reverb) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_CRITTER_2_TYPE(type) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_2_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_2_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_2_PORT5(reverb) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_CRITTER_3_TYPE(type) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_3_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_3_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_3_PORT5(reverb) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_CRITTER_4_TYPE(type) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_4_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_4_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_4_PORT5(reverb) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_CRITTER_5_TYPE(type) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_5_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_5_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_5_PORT5(reverb) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_CRITTER_6_TYPE(type) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_6_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_6_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_6_PORT5(reverb) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_STREAM_0_TYPE(type) NATURE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_2, type +#define NATURE_IO_STREAM_0_PORT3(data) NATURE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_3, data +#define NATURE_IO_STREAM_0_PORT4(data) NATURE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_4, data + +#define NATURE_IO_STREAM_1_TYPE(type) NATURE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_2, type +#define NATURE_IO_STREAM_1_PORT3(data) NATURE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_3, data +#define NATURE_IO_STREAM_1_PORT4(data) NATURE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_4, data + +#define NATURE_IO_RAIN_PORT4(data) NATURE_CHANNEL_RAIN, CHANNEL_IO_PORT_4, data + +#define NATURE_IO_ENTRIES_END 0xFF + #endif diff --git a/include/variables.h b/include/variables.h index 19234ff0a..adbc8eb10 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1689,7 +1689,7 @@ extern UNK_PTR D_801D618C; // extern UNK_TYPE1 D_801D6648; // extern UNK_TYPE1 D_801D664C; // extern UNK_TYPE1 D_801D6650; -extern f32 D_801D6654; +extern f32 gSfxVolume; // extern UNK_TYPE1 D_801D6658; // extern UNK_TYPE1 D_801D665C; // extern UNK_TYPE1 D_801D6660; @@ -3340,6 +3340,7 @@ extern FaultAddrConvClient sGraphFaultAddrConvClient; extern FaultClient sGraphFaultClient; extern GfxMasterList* gGfxMasterDL; extern CfbInfo sGraphCfbInfos[3]; +extern OSTime sGraphTaskStartTime; extern OSMesgQueue sSiIntMsgQ; extern OSMesg sSiIntMsgBuf[1]; extern u32 gSegments[NUM_SEGMENTS]; diff --git a/include/z64.h b/include/z64.h index ae912f488..83d3a47da 100644 --- a/include/z64.h +++ b/include/z64.h @@ -17,9 +17,9 @@ #include "scheduler.h" #include "xstdio.h" -#include "bgm.h" #include "color.h" #include "ichain.h" +#include "sequence.h" #include "sfx.h" #include "z64actor.h" @@ -34,6 +34,7 @@ #include "z64light.h" #include "z64math.h" #include "z64object.h" +#include "z64ocarina.h" #include "z64player.h" #include "z64scene.h" #include "z64save.h" diff --git a/include/z64audio.h b/include/z64audio.h index 89fff01c7..db43aad48 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -20,6 +20,13 @@ #define AIBUF_LEN 0x580 +typedef enum { + /* 0 */ AUDIO_FS_STEREO, + /* 1 */ AUDIO_FS_HEADSET, + /* 2 */ AUDIO_FS_SURROUND, + /* 3 */ AUDIO_FS_MONO +} AudioFileSelectOption; + typedef enum { /* 0 */ AUDIO_MODE_STEREO, /* 1 */ AUDIO_MODE_HEADSET, @@ -71,63 +78,6 @@ typedef enum { /* 3 */ CACHE_PERMANENT } AudioCacheType; -typedef enum { - /* 0 */ OCARINA_SONG_SONATA, - /* 1 */ OCARINA_SONG_GORON_LULLABY, - /* 2 */ OCARINA_SONG_NEW_WAVE, - /* 3 */ OCARINA_SONG_ELEGY, - /* 4 */ OCARINA_SONG_OATH, - /* 5 */ OCARINA_SONG_SARIAS, - /* 6 */ OCARINA_SONG_TIME, - /* 7 */ OCARINA_SONG_HEALING, - /* 8 */ OCARINA_SONG_EPONAS, - /* 9 */ OCARINA_SONG_SOARING, - /* 10 */ OCARINA_SONG_STORMS, - /* 11 */ OCARINA_SONG_SUNS, - /* 12 */ OCARINA_SONG_INVERTED_TIME, - /* 13 */ OCARINA_SONG_DOUBLE_TIME, - /* 14 */ OCARINA_SONG_GORON_LULLABY_INTRO, - /* 15 */ OCARINA_SONG_WIND_FISH_HUMAN, // "Ballad of the Wind Fish" - /* 16 */ OCARINA_SONG_WIND_FISH_GORON, - /* 17 */ OCARINA_SONG_WIND_FISH_ZORA, - /* 18 */ OCARINA_SONG_WIND_FISH_DEKU, - /* 19 */ OCARINA_SONG_EVAN_PART1, - /* 20 */ OCARINA_SONG_EVAN_PART2, - /* 21 */ OCARINA_SONG_ZELDAS_LULLABY, - /* 22 */ OCARINA_SONG_SCARECROW, - /* 23 */ OCARINA_SONG_TERMINA_WALL, - /* 24 */ OCARINA_SONG_MAX, -} OcarinaSongId; - -typedef enum { - /* 0 */ OCARINA_BTN_A, - /* 1 */ OCARINA_BTN_C_DOWN, - /* 2 */ OCARINA_BTN_C_RIGHT, - /* 3 */ OCARINA_BTN_C_LEFT, - /* 4 */ OCARINA_BTN_C_UP, - /* -1 */ OCARINA_BTN_INVALID = 0xFF -} OcarinaButtonIdx; - -typedef enum { - /* 0x0 */ OCARINA_PITCH_C4, - /* 0x1 */ OCARINA_PITCH_DFLAT4, - /* 0x2 */ OCARINA_PITCH_D4, - /* 0x3 */ OCARINA_PITCH_EFLAT4, - /* 0x4 */ OCARINA_PITCH_E4, - /* 0x5 */ OCARINA_PITCH_F4, - /* 0x6 */ OCARINA_PITCH_GFLAT4, - /* 0x7 */ OCARINA_PITCH_G4, - /* 0x8 */ OCARINA_PITCH_AFLAT4, - /* 0x9 */ OCARINA_PITCH_A4, - /* 0xA */ OCARINA_PITCH_BFLAT4, - /* 0xB */ OCARINA_PITCH_B4, - /* 0xC */ OCARINA_PITCH_C5, - /* 0xD */ OCARINA_PITCH_DFLAT5, - /* 0xE */ OCARINA_PITCH_D5, - /* 0xF */ OCARINA_PITCH_EFLAT5, - /* -1 */ OCARINA_PITCH_NONE = 0xFF -} OcarinaNoteIdx; - typedef s32 (*DmaHandler)(OSPiHandle* handle, OSIoMesg* mb, s32 direction); struct Note; @@ -1155,31 +1105,4 @@ typedef struct { /* 0x10 */ f32* vol; } SoundRequest; // size = 0x14 -/** - * Note: - * Flag for resolving C_RIGHT and C_LEFT only being two semitones apart - * 0x40 - BTN_Z is pressed to lower note by a semitone - * 0x80 - BTN_R is pressed to raise note by a semitone - */ - -typedef struct { - /* 0x0 */ u8 noteIdx; - /* 0x2 */ u16 length; // number of frames the note is sustained - /* 0x4 */ u8 volume; - /* 0x5 */ u8 vibrato; - /* 0x6 */ s8 bend; - /* 0x7 */ u8 BFlat4Flag; // BFlat4Flag See note above -} OcarinaNote; // size = 0x8 - -typedef struct { - /* 0x0 */ u8 numButtons; - /* 0x1 */ u8 buttonIdx[8]; -} OcarinaSongButtons; // size = 0x9 - -typedef struct { - /* 0x0 */ u8 buttonIdx; - /* 0x1 */ u8 state; - /* 0x2 */ u8 pos; -} OcarinaStaff; // size = 0x3 - #endif diff --git a/include/z64ocarina.h b/include/z64ocarina.h new file mode 100644 index 000000000..bcff0a3f2 --- /dev/null +++ b/include/z64ocarina.h @@ -0,0 +1,125 @@ +#ifndef Z64OCARINA_H +#define Z64OCARINA_H + +#include "ultra64.h" + +typedef enum { + /* 0 */ OCARINA_SONG_SONATA, + /* 1 */ OCARINA_SONG_GORON_LULLABY, + /* 2 */ OCARINA_SONG_NEW_WAVE, + /* 3 */ OCARINA_SONG_ELEGY, + /* 4 */ OCARINA_SONG_OATH, + /* 5 */ OCARINA_SONG_SARIAS, + /* 6 */ OCARINA_SONG_TIME, + /* 7 */ OCARINA_SONG_HEALING, + /* 8 */ OCARINA_SONG_EPONAS, + /* 9 */ OCARINA_SONG_SOARING, + /* 10 */ OCARINA_SONG_STORMS, + /* 11 */ OCARINA_SONG_SUNS, + /* 12 */ OCARINA_SONG_INVERTED_TIME, + /* 13 */ OCARINA_SONG_DOUBLE_TIME, + /* 14 */ OCARINA_SONG_GORON_LULLABY_INTRO, + /* 15 */ OCARINA_SONG_WIND_FISH_HUMAN, // "Ballad of the Wind Fish" + /* 16 */ OCARINA_SONG_WIND_FISH_GORON, + /* 17 */ OCARINA_SONG_WIND_FISH_ZORA, + /* 18 */ OCARINA_SONG_WIND_FISH_DEKU, + /* 19 */ OCARINA_SONG_EVAN_PART1, + /* 20 */ OCARINA_SONG_EVAN_PART2, + /* 21 */ OCARINA_SONG_ZELDAS_LULLABY, + /* 22 */ OCARINA_SONG_SCARECROW, + /* 23 */ OCARINA_SONG_TERMINA_WALL, + /* 24 */ OCARINA_SONG_MAX, + /* 24 */ OCARINA_SONG_SCARECROW_LONG = OCARINA_SONG_MAX +} OcarinaSongId; + +typedef enum { + /* 0 */ OCARINA_BTN_A, + /* 1 */ OCARINA_BTN_C_DOWN, + /* 2 */ OCARINA_BTN_C_RIGHT, + /* 3 */ OCARINA_BTN_C_LEFT, + /* 4 */ OCARINA_BTN_C_UP, + /* -1 */ OCARINA_BTN_INVALID = 0xFF +} OcarinaButtonIdx; + +// Uses scientific pitch notation relative to middle C +// https://en.wikipedia.org/wiki/Scientific_pitch_notation +typedef enum { + /* 0x0 */ OCARINA_PITCH_C4, + /* 0x1 */ OCARINA_PITCH_DFLAT4, + /* 0x2 */ OCARINA_PITCH_D4, + /* 0x3 */ OCARINA_PITCH_EFLAT4, + /* 0x4 */ OCARINA_PITCH_E4, + /* 0x5 */ OCARINA_PITCH_F4, + /* 0x6 */ OCARINA_PITCH_GFLAT4, + /* 0x7 */ OCARINA_PITCH_G4, + /* 0x8 */ OCARINA_PITCH_AFLAT4, + /* 0x9 */ OCARINA_PITCH_A4, + /* 0xA */ OCARINA_PITCH_BFLAT4, + /* 0xB */ OCARINA_PITCH_B4, + /* 0xC */ OCARINA_PITCH_C5, + /* 0xD */ OCARINA_PITCH_DFLAT5, + /* 0xE */ OCARINA_PITCH_D5, + /* 0xF */ OCARINA_PITCH_EFLAT5, + /* -1 */ OCARINA_PITCH_NONE = 0xFF +} OcarinaPitch; + +// Mainly set by func_80152CAC in z_message.c +typedef enum { + /* 0 */ OCARINA_INSTRUMENT_OFF, + /* 1 */ OCARINA_INSTRUMENT_DEFAULT, + /* 2 */ OCARINA_INSTRUMENT_FEMALE_VOICE, + /* 3 */ OCARINA_INSTRUMENT_WHISTLING_FLUTE, + /* 4 */ OCARINA_INSTRUMENT_HARP, + /* 5 */ OCARINA_INSTRUMENT_IKANA_KING, + /* 6 */ OCARINA_INSTRUMENT_TATL, + /* 7 */ OCARINA_INSTRUMENT_GORON_DRUMS, + /* 8 */ OCARINA_INSTRUMENT_ZORA_GUITAR, + /* 9 */ OCARINA_INSTRUMENT_DEKU_PIPES, + /* 10 */ OCARINA_INSTRUMENT_MONKEY, + /* 11 */ OCARINA_INSTRUMENT_DEKU_TRUMPET, // Pull out ocarina for captured monkey + /* 12 */ OCARINA_INSTRUMENT_ELDER_GORON_DRUMS, + /* 13 */ OCARINA_INSTRUMENT_PIANO, + /* 14 */ OCARINA_INSTRUMENT_BASS_GUITAR, + /* 15 */ OCARINA_INSTRUMENT_BABY_SINGING, + /* 16 */ OCARINA_INSTRUMENT_AMPLIFIED_GUITAR, // Related to (gSaveContext.weekEventReg[0x29] & 0x20) +} OcarinaInstrumentId; + +typedef enum { + /* 0 */ OCARINA_RECORD_OFF, + /* 1 */ OCARINA_RECORD_SCARECROW_LONG, + /* 2 */ OCARINA_RECORD_SCARECROW_SPAWN, + /* -1 */ OCARINA_RECORD_REJECTED = 0xFF +} OcarinaRecordingState; + +/** + * BFlat4Flag Note: + * Flag for resolving whether (noteIdx = NOTE_BFLAT4) + * gets mapped to either C_RIGHT and C_LEFT + * + * This is required as C_RIGHT and C_LEFT are the only notes + * that map to two semitones apart (NOTE_A4 and NOTE_B4) + * 0x40 - BTN_Z is pressed to lower note by a semitone + * 0x80 - BTN_R is pressed to raise note by a semitone + */ + +typedef struct { + /* 0x0 */ u8 noteIdx; // number of semitones above middle C + /* 0x2 */ u16 length; // number of frames the note is sustained + /* 0x4 */ u8 volume; + /* 0x5 */ u8 vibrato; + /* 0x6 */ s8 bend; // frequency multiplicative offset from the pitch defined by noteIdx + /* 0x7 */ u8 BFlat4Flag; // See note above +} OcarinaNote; // size = 0x8 + +typedef struct { + /* 0x0 */ u8 numButtons; + /* 0x1 */ u8 buttonIdx[8]; +} OcarinaSongButtons; // size = 0x9 + +typedef struct { + /* 0x0 */ u8 buttonIdx; + /* 0x1 */ u8 state; // original name: "status" + /* 0x2 */ u8 pos; // original name: "locate" +} OcarinaStaff; // size = 0x3 + +#endif diff --git a/spec b/spec index d5116fff1..a5c9e3876 100644 --- a/spec +++ b/spec @@ -643,8 +643,6 @@ beginseg pad_text include "build/asm/code/code_8019AEC0.text.o" // handwritten include "build/src/code/audio/code_8019AF00.o" - include "build/data/code/code_8019AF00.data.o" - include "build/data/code/code_8019AF00.bss.o" include "build/src/code/audio/code_801A4EB0.o" include "build/data/code/code_801A4EB0.data.o" include "build/src/code/audio/code_801A51F0.o" diff --git a/src/code/audio/code_8019AF00.c b/src/code/audio/code_8019AF00.c index 5d0a166a2..3a498178c 100644 --- a/src/code/audio/code_8019AF00.c +++ b/src/code/audio/code_8019AF00.c @@ -1,6 +1,1882 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/D_801E0BD0.s") +typedef struct { + /* 0x0 */ s8 x; + /* 0x1 */ s8 y; +} OcarinaControlStick; // size = 0x2 + +typedef struct { + /* 0x0 */ u16 playerIO; + /* 0x2 */ u16 channelMask; + /* 0x4 */ u8 channelIO[3 * 33 + 1]; +} NatureAmbienceDataIO; // size = 0x68 + +typedef struct { + /* 0x0 */ Vec3f* pos; + /* 0x4 */ f32 freqScale; + /* 0x8 */ s8 reverbAdd; +} SfxSettings; // size = 0x9 + +typedef struct { + /* 0x0 */ f32 vol; + /* 0x4 */ f32 freqScale; + /* 0x8 */ s8 reverb; + /* 0x9 */ s8 panSigned; + /* 0xA */ s8 stereoBits; + /* 0xB */ u8 filter; + /* 0xC */ u8 unk_0C; + /* 0xD */ u8 unk_0D; +} SfxPlayerState; // size = 0xE + +typedef enum { + /* 0x0 */ SFX_CHANNEL_PLAYER0, // SfxPlayerBank + /* 0x1 */ SFX_CHANNEL_PLAYER1, + /* 0x2 */ SFX_CHANNEL_PLAYER2, + /* 0x3 */ SFX_CHANNEL_ITEM0, // SfxItemBank + /* 0x4 */ SFX_CHANNEL_ITEM1, + /* 0x5 */ SFX_CHANNEL_ENV0, // SfxEnvironmentBank + /* 0x6 */ SFX_CHANNEL_ENV1, + /* 0x7 */ SFX_CHANNEL_ENV2, + /* 0x8 */ SFX_CHANNEL_ENEMY0, // SfxEnemyBank + /* 0x9 */ SFX_CHANNEL_ENEMY1, + /* 0xA */ SFX_CHANNEL_ENEMY2, + /* 0xB */ SFX_CHANNEL_SYSTEM0, // SfxSystemBank + /* 0xC */ SFX_CHANNEL_SYSTEM1, + /* 0xD */ SFX_CHANNEL_OCARINA, // SfxOcarinaBank + /* 0xE */ SFX_CHANNEL_VOICE0, // SfxVoiceBank + /* 0xF */ SFX_CHANNEL_VOICE1 +} SfxChannelIdx; // playerIdx = 2 + +// Global IO ports for sequences, 8 global ports per seqPlayer +typedef enum { + /* 0x0 */ SEQ_PLAYER_IO_PORT_0, + /* 0x1 */ SEQ_PLAYER_IO_PORT_1, + /* 0x2 */ SEQ_PLAYER_IO_PORT_2, + /* 0x3 */ SEQ_PLAYER_IO_PORT_3, + /* 0x4 */ SEQ_PLAYER_IO_PORT_4, + /* 0x5 */ SEQ_PLAYER_IO_PORT_5, + /* 0x6 */ SEQ_PLAYER_IO_PORT_6, + /* 0x7 */ SEQ_PLAYER_IO_PORT_7, +} SeqPlayerIOPort; + +typedef struct { + /* 0x0 */ f32 value; + /* 0x4 */ f32 target; + /* 0x8 */ f32 step; + /* 0xC */ s32 remainingFrames; +} FreqLerp; // size = 0x10 + +// Sfx bss +SfxSettings sSfxSettings[8]; +u8 sSfxSettingsFlags; +f32 sTwoSemitonesLoweredFreq; +s8 sSfxIncreasedReverb; +f32 sSfxSyncedVolume; +f32 sSfxSyncedVolumeForMetalEffects; +f32 sSfxSyncedFreq; +FreqLerp sRiverFreqScaleLerp; +FreqLerp sWaterfallFreqScaleLerp; +f32 sSfxAdjustedFreq; +s8 sSfxCustomReverb; +u8 sRiverSoundMainBgmVol; +u8 sRiverSoundMainBgmCurrentVol; +u8 sRiverSoundMainBgmLower; +u8 sRiverSoundMainBgmRestore; +u8 sGanonsTowerVol; +f32* sSfxVolumeCur; +f32 sSfxVolumeTarget; +f32 sSfxVolumeRate; +u16 sSceneSeqId1; +SfxPlayerState sSfxChannelState[16]; + +// Sequence bss +u8 D_801FD3A8; +u8 D_801FD3A9; +u8 sRiverSoundBgmTimer; +u8 sFanfareState; +u16 sFanfareSeqId; +u8 sMuteOnlySfxAndNatureSeq; +u8 sAllPlayersMutedExceptOcaAndSys; +u8 sAudioPauseState; +u8 sSpatialSeqIsActive[4]; +u8 sSequenceFilter[8 * 4]; +u8 sIsFinalHoursOrSoaring; +u8 sObjSoundFanfareSeqId; +u8 sObjSoundFanfareRequested; +Vec3f sObjSoundFanfarePos; +u8 sObjSoundPlayerIdx; +Vec3f sObjSoundPos; +s16 sObjSoundFlags; +f32 sObjSoundMinDist; +f32 sObjSoundMaxDist; +f32 sObjSoundMaxVol; +f32 sObjSoundMinVol; +Vec3f sSpatialSeqNoFilterPos; +Vec3f sSpatialSeqFilterPos; +f32 sSpatialSeqMaxDist; +u8 sSpatialSeqSeqId; +u8 sSpatialSeqFlags; +u8 D_801FD432; +u8 sSpatialSubBgmFadeTimer; +u8 D_801FD434; +u8 sSpatialSeqPlayerIdx; +u8 sSpatialSeqFadeTimer; +u16 D_801FD438; + +// AudioOcarina bss +OcarinaStaff sPlayingStaff; +OcarinaStaff sPlaybackStaff; +OcarinaStaff sRecordingStaff; +u32 sOcarinaUpdateTaskCurrent; +OcarinaControlStick sOcarinaInputStickRel; +u32 sOcarinaInputButtonCur; +u32 sOcarinaInputButtonStart; +u32 sOcarinaInputButtonPrev; +s32 sOcaInputBtnPress; +u8 sOcarinaResetDelay; +u8 sOcarinaResetUnused; +u8 sOcarinaHasStartedSong; +u8 sFirstOcarinaSongIdx; +u8 sLastOcarinaSongIdx; +u32 sOcarinaAvailSongs; +u8 sOcarinaStaffPlayingPos; +u16 sMusicStaffPos[OCARINA_SONG_MAX]; +u16 sMusicStaffCurHeldLength[OCARINA_SONG_MAX]; +u16 sMusicStaffExpectedLength[OCARINA_SONG_MAX]; +u8 sMusicStaffExpectedPitch[OCARINA_SONG_MAX]; // Next required pitch in song playback +u8 D_801FD518[OCARINA_SONG_MAX]; +u32 D_801FD530[OCARINA_SONG_MAX]; +OcarinaNote sRecordingSongNote; +u16 sCustomSequencePc; + +// Sfx Data +u8 D_801D6600[] = { + true, false, true, true, false, false, true, +}; +u8 D_801D6608[] = { + true, true, true, true, true, false, true, +}; +u8 gChannelsPerBank[4][7] = { + { 3, 2, 3, 3, 2, 1, 2 }, + { 3, 2, 2, 2, 2, 2, 2 }, + { 3, 2, 2, 2, 2, 2, 2 }, + { 4, 1, 0, 0, 2, 2, 2 }, +}; +u8 gUsedChannelsPerBank[4][7] = { + { 3, 2, 3, 2, 2, 1, 1 }, + { 3, 1, 1, 1, 2, 1, 1 }, + { 3, 1, 1, 1, 2, 1, 1 }, + { 2, 1, 0, 0, 1, 1, 1 }, +}; +f32 sGiantsMaskFreq = 0.89167805f; // Around 2 semitones down in pitch +s8 sGiantsMaskReverbAdd = 0x40; +f32 sWaterWheelVolume = 0.65f; +f32 gSfxVolume = 1.0f; +s8 sSfxTimer = 20; +s8 sSfxTimerLerpRange2 = 30; +s8 sSfxTimerLerpRange1 = 20; +f32 sBehindScreenZ[2] = { -15.0f, -65.0f }; // Unused Remnant of OoT +u8 sAudioIncreasingTranspose = 0; // Remnant of OoT, only unsed in unused functions +u8 gMorphaTransposeTable[16] = { 0, 0, 0, 1, 1, 2, 4, 6, 8, 8, 8, 8, 8, 8, 8, 8 }; // Unused Remnant of OoT +u8 sPrevChargeLevel = 0; +f32 sChargeLevelsSfxFreq[] = { 1.0f, 1.12246f, 1.33484f, 1.33484f }; +f32 sCurChargeLevelSfxFreq = 1.0f; +u8 sGanonsTowerLevelsVol[] = { + 127, 80, 75, 73, 70, 68, 65, 60 // volumes +}; +u8 sEnterGanonsTowerTimer = 0; +u16 sSfxVolumeDuration = 0; + +// System Data +s8 sAudioFileSelectSetting = AUDIO_FS_STEREO; +s8 sAudioIsWindowOpen = false; +s8 sAudioCutsceneFlag = false; +s8 sSpecReverb = 0; +s8 sAudioEnvReverb = 0; +s8 sAudioCodeReverb = 0; + +// Sequence Data +u8 sPrevSeqMode = 0; +f32 sAudioEnemyDist = 0.0f; +s8 sAudioEnemyVol = 127; +u16 sPrevMainBgmSeqId = NA_BGM_DISABLED; +u8 sBgmPlayerIOPort7 = 0; +u8 sSceneSeqId2 = NA_BGM_GENERAL_SFX; +u32 sNumFramesStill = 0; +u32 sNumFramesMoving = 0; +u8 sAudioBaseFilter = 0; +u8 sAudioExtraFilter = 0; +u8 sAudioBaseFilter2 = 0; +u8 sAudioExtraFilter2 = 0; +s8 gUnderwaterSfxReverbAdd = 0; +Vec3f* sRiverSoundBgmPos = NULL; +f32 sRiverSoundXZDistToPlayer = 2000.0f; +u8 sObjSoundMainBgmSeqId = NA_BGM_GENERAL_SFX; +u8 sSeqFlags[] = { + 0x3, // NA_BGM_GENERAL_SFX + 0x1, // NA_BGM_NATURE_AMBIENCE + 0x1, // NA_BGM_TERMINA_FIELD + 0x8, // NA_BGM_CHASE + 0, // NA_BGM_MAJORAS_THEME + 0, // NA_BGM_CLOCK_TOWER + 0x1, // NA_BGM_STONE_TOWER_TEMPLE + 0x1, // NA_BGM_INV_STONE_TOWER_TEMPLE + 0x2, // NA_BGM_FAILURE_0 + 0x2, // NA_BGM_FAILURE_1 + 0, // NA_BGM_HAPPY_MASK_SALESMAN + 0, // NA_BGM_SONG_OF_HEALING + 0x1, // NA_BGM_SWAMP_REGION + 0, // NA_BGM_ALIEN_INVASION + 0x2, // NA_BGM_SWAMP_CRUISE + 0, // NA_BGM_SHARPS_CURSE + 0x1, // NA_BGM_GREAT_BAY_REGION + 0x1, // NA_BGM_IKANA_REGION + 0, // NA_BGM_DEKU_KING + 0x1, // NA_BGM_MOUNTAIN_REGION + 0, // NA_BGM_PIRATES_FORTRESS + 0, // NA_BGM_CLOCK_TOWN_DAY_1 + 0, // NA_BGM_CLOCK_TOWN_DAY_2 + 0, // NA_BGM_CLOCK_TOWN_DAY_3 + 0x40, // NA_BGM_FILE_SELECT + 0x10, // NA_BGM_CLEAR_EVENT + 0, // NA_BGM_ENEMY + 0x8, // NA_BGM_BOSS + 0x1, // NA_BGM_WOODFALL_TEMPLE + 0, // NA_BGM_MARKET + 0, // NA_BGM_OPENING + 0x20, // NA_BGM_INSIDE_A_HOUSE + 0x2, // NA_BGM_GAME_OVER + 0, // NA_BGM_CLEAR_BOSS + 0x2, // NA_BGM_GET_ITEM + 0x2, // NA_BGM_GATE_OPEN + 0x2, // NA_BGM_GET_HEART + 0x8, // NA_BGM_TIMED_MINI_GAME + 0, // NA_BGM_GORON_RACE + 0, // NA_BGM_MUSIC_BOX_HOUSE + 0, // NA_BGM_FAIRY_FOUNTAIN + 0, // NA_BGM_ZELDAS_LULLABY + 0, // NA_BGM_ROSA_SISTERS + 0x2, // NA_BGM_OPEN_CHEST + 0, // NA_BGM_MARINE_RESEARCH_LAB + 0x40, // NA_BGM_GIANTS_THEME + 0, // NA_BGM_SONG_OF_STORMS + 0, // NA_BGM_ROMANI_RANCH + 0, // NA_BGM_GORON_VILLAGE + 0, // NA_BGM_MAYORS_OFFICE + 0x2, // NA_BGM_OCA_EPONA + 0x2, // NA_BGM_OCA_SUNS + 0x2, // NA_BGM_OCA_TIME + 0x2, // NA_BGM_OCA_STORM + 0x10, // NA_BGM_ZORA_HALL + 0x2, // NA_BGM_GET_NEW_MASK + 0x8, // NA_BGM_MINI_BOSS + 0x2, // NA_BGM_GET_SMALL_ITEM + 0, // NA_BGM_ASTRAL_OBSERVATORY + 0x1, // NA_BGM_CAVERN + 0x11, // NA_BGM_MILK_BAR + 0x2, // NA_BGM_ZELDA_APPEAR + 0, // NA_BGM_SARIAS_SONG + 0, // NA_BGM_GORON_GOAL + 0, // NA_BGM_HORSE + 0, // NA_BGM_HORSE_GOAL + 0, // NA_BGM_INGO + 0, // NA_BGM_KOTAKE_POTION_SHOP + 0x20, // NA_BGM_SHOP + 0x2, // NA_BGM_OWL + 0x20, // NA_BGM_MINI_GAME + 0x2, // NA_BGM_OCA_SOARING + 0x2, // NA_BGM_OCA_HEALING + 0x2, // NA_BGM_INVERTED_SONG_OF_TIME + 0x2, // NA_BGM_SONG_OF_DOUBLE_TIME + 0x2, // NA_BGM_SONATA_OF_AWAKENING + 0x2, // NA_BGM_GORON_LULLABY + 0x2, // NA_BGM_NEW_WAVE_BOSSA_NOVA + 0x2, // NA_BGM_ELEGY_OF_EMPTINESS + 0x2, // NA_BGM_OATH_TO_ORDER + 0, // NA_BGM_SWORD_TRAINING_HALL + 0x2, // NA_BGM_GORON_LULLABY_INTRO + 0x2, // NA_BGM_OCA_FAIRY + 0x2, // NA_BGM_BREMEN_MARCH + 0x2, // NA_BGM_BALLAD_OF_THE_WIND_FISH + 0x8, // NA_BGM_SONG_OF_SOARING + 0, // NA_BGM_MILK_BAR_DUPLICATE + 0, // NA_BGM_FINAL_HOURS + 0x2, // NA_BGM_MIKAU_RIFF + 0x2, // NA_BGM_MIKAU_FINALE + 0, // NA_BGM_FROG_SONG + 0x2, // NA_BGM_OCA_SONATA + 0x2, // NA_BGM_OCA_LULLABY + 0x2, // NA_BGM_OCA_NEW_WAVE + 0x2, // NA_BGM_OCA_ELEGY + 0x2, // NA_BGM_OCA_OATH + 0, // NA_BGM_MAJORAS_LAIR + 0x2, // NA_BGM_OCA_LULLABY_INTRO + 0x2, // NA_BGM_OCA_GUITAR_BASS_SESSION + 0x2, // NA_BGM_PIANO_SESSION + 0x2, // NA_BGM_INDIGO_GO_SESSION + 0x1, // NA_BGM_SNOWHEAD_TEMPLE + 0x1, // NA_BGM_GREAT_BAY_TEMPLE + 0x2, // NA_BGM_NEW_WAVE_SAXOPHONE + 0x2, // NA_BGM_NEW_WAVE_VOCAL + 0, // NA_BGM_MAJORAS_WRATH + 0, // NA_BGM_MAJORAS_INCARNATION + 0, // NA_BGM_MAJORAS_MASK + 0x2, // NA_BGM_BASS_PLAY + 0x2, // NA_BGM_DRUMS_PLAY + 0x2, // NA_BGM_PIANO_PLAY + 0x1, // NA_BGM_IKANA_CASTLE + 0, // NA_BGM_GATHERING_GIANTS + 0x4, // NA_BGM_KAMARO_DANCE + 0, // NA_BGM_CREMIA_CARRIAGE + 0x2, // NA_BGM_KEATON_QUIZ + 0, // NA_BGM_END_CREDITS_1 + 0, // NA_BGM_OPENING_LOOP + 0, // NA_BGM_TITLE_THEME + 0x2, // NA_BGM_DUNGEON_APPEAR + 0x2, // NA_BGM_WOODFALL_CLEAR + 0x2, // NA_BGM_SNOWHEAD_CLEAR + 0, // + 0, // NA_BGM_INTO_THE_MOON + 0, // NA_BGM_GOODBYE_GIANT + 0, // NA_BGM_TATL_AND_TAEL + 0, // NA_BGM_MOONS_DESTRUCTION + 0, // NA_BGM_END_CREDITS_2 +}; + +s8 sSpecReverbs[20] = { + 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +NatureAmbienceDataIO sNatureAmbienceData[20] = { + // natureSeqId: 0 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_09), + NATURE_IO_CRITTER_0_BEND_PITCH(64), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(32), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_1_BEND_PITCH(0), + NATURE_IO_CRITTER_1_NUM_LAYERS(1), + NATURE_IO_CRITTER_1_PORT5(16), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_10), + NATURE_IO_CRITTER_2_BEND_PITCH(112), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(48), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_03), + NATURE_IO_CRITTER_3_BEND_PITCH(127), + NATURE_IO_CRITTER_3_NUM_LAYERS(0), + NATURE_IO_CRITTER_3_PORT5(16), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_00), + NATURE_IO_CRITTER_4_BEND_PITCH(127), + NATURE_IO_CRITTER_4_NUM_LAYERS(1), + NATURE_IO_CRITTER_4_PORT5(16), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_5_BEND_PITCH(127), + NATURE_IO_CRITTER_5_NUM_LAYERS(3), + NATURE_IO_CRITTER_5_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 1 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(64), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(32), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_16), + NATURE_IO_CRITTER_1_BEND_PITCH(0), + NATURE_IO_CRITTER_1_NUM_LAYERS(1), + NATURE_IO_CRITTER_1_PORT5(16), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_12), + NATURE_IO_CRITTER_2_BEND_PITCH(112), + NATURE_IO_CRITTER_2_NUM_LAYERS(0), + NATURE_IO_CRITTER_2_PORT5(48), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_15), + NATURE_IO_CRITTER_3_BEND_PITCH(127), + NATURE_IO_CRITTER_3_NUM_LAYERS(1), + NATURE_IO_CRITTER_3_PORT5(16), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_06), + NATURE_IO_CRITTER_4_BEND_PITCH(127), + NATURE_IO_CRITTER_4_NUM_LAYERS(1), + NATURE_IO_CRITTER_4_PORT5(16), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_5_BEND_PITCH(127), + NATURE_IO_CRITTER_5_NUM_LAYERS(3), + NATURE_IO_CRITTER_5_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 2 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(64), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(48), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_10), + NATURE_IO_CRITTER_1_BEND_PITCH(0), + NATURE_IO_CRITTER_1_NUM_LAYERS(1), + NATURE_IO_CRITTER_1_PORT5(16), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_2_BEND_PITCH(48), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(32), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_03), + NATURE_IO_CRITTER_3_BEND_PITCH(127), + NATURE_IO_CRITTER_3_NUM_LAYERS(0), + NATURE_IO_CRITTER_3_PORT5(16), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_4_BEND_PITCH(64), + NATURE_IO_CRITTER_4_NUM_LAYERS(1), + NATURE_IO_CRITTER_4_PORT5(0), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_5_BEND_PITCH(127), + NATURE_IO_CRITTER_5_NUM_LAYERS(0), + NATURE_IO_CRITTER_5_PORT5(63), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 3 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_09), + NATURE_IO_CRITTER_0_BEND_PITCH(64), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(32), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_1_BEND_PITCH(64), + NATURE_IO_CRITTER_1_NUM_LAYERS(0), + NATURE_IO_CRITTER_1_PORT5(48), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_10), + NATURE_IO_CRITTER_2_BEND_PITCH(32), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(32), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_14), + NATURE_IO_CRITTER_3_BEND_PITCH(64), + NATURE_IO_CRITTER_3_NUM_LAYERS(1), + NATURE_IO_CRITTER_3_PORT5(16), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_00), + NATURE_IO_CRITTER_4_BEND_PITCH(127), + NATURE_IO_CRITTER_4_NUM_LAYERS(1), + NATURE_IO_CRITTER_4_PORT5(16), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_5_BEND_PITCH(127), + NATURE_IO_CRITTER_5_NUM_LAYERS(3), + NATURE_IO_CRITTER_5_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 4 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(64), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(32), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_02), + NATURE_IO_CRITTER_1_BEND_PITCH(64), + NATURE_IO_CRITTER_1_NUM_LAYERS(1), + NATURE_IO_CRITTER_1_PORT5(16), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_12), + NATURE_IO_CRITTER_2_BEND_PITCH(112), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(48), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_13), + NATURE_IO_CRITTER_3_BEND_PITCH(64), + NATURE_IO_CRITTER_3_NUM_LAYERS(1), + NATURE_IO_CRITTER_3_PORT5(16), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_4_BEND_PITCH(64), + NATURE_IO_CRITTER_4_NUM_LAYERS(1), + NATURE_IO_CRITTER_4_PORT5(16), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_02), + NATURE_IO_CRITTER_5_BEND_PITCH(112), + NATURE_IO_CRITTER_5_NUM_LAYERS(0), + NATURE_IO_CRITTER_5_PORT5(48), + + // Channel 14 + NATURE_IO_RAIN_PORT4(63), + + // End + NATURE_IO_ENTRIES_END, + + }, + }, + + // natureSeqId: 5 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_09), + NATURE_IO_CRITTER_0_BEND_PITCH(64), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(32), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_1_BEND_PITCH(0), + NATURE_IO_CRITTER_1_NUM_LAYERS(1), + NATURE_IO_CRITTER_1_PORT5(16), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_10), + NATURE_IO_CRITTER_2_BEND_PITCH(112), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(48), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_13), + NATURE_IO_CRITTER_3_BEND_PITCH(127), + NATURE_IO_CRITTER_3_NUM_LAYERS(0), + NATURE_IO_CRITTER_3_PORT5(63), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_00), + NATURE_IO_CRITTER_4_BEND_PITCH(127), + NATURE_IO_CRITTER_4_NUM_LAYERS(1), + NATURE_IO_CRITTER_4_PORT5(16), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_5_BEND_PITCH(127), + NATURE_IO_CRITTER_5_NUM_LAYERS(3), + NATURE_IO_CRITTER_5_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 6 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_11), + NATURE_IO_CRITTER_0_BEND_PITCH(112), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(48), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_15), + NATURE_IO_CRITTER_1_BEND_PITCH(112), + NATURE_IO_CRITTER_1_NUM_LAYERS(0), + NATURE_IO_CRITTER_1_PORT5(63), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_11), + NATURE_IO_CRITTER_2_BEND_PITCH(48), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(16), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_14), + NATURE_IO_CRITTER_3_BEND_PITCH(48), + NATURE_IO_CRITTER_3_NUM_LAYERS(1), + NATURE_IO_CRITTER_3_PORT5(16), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_11), + NATURE_IO_CRITTER_4_BEND_PITCH(127), + NATURE_IO_CRITTER_4_NUM_LAYERS(0), + NATURE_IO_CRITTER_4_PORT5(32), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_02), + NATURE_IO_CRITTER_5_BEND_PITCH(127), + NATURE_IO_CRITTER_5_NUM_LAYERS(0), + NATURE_IO_CRITTER_5_PORT5(48), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 7 + { + 0xC001, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 8 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_0_BEND_PITCH(127), + NATURE_IO_CRITTER_0_NUM_LAYERS(3), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 9 + { + 0xC00F, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_16), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(2), + NATURE_IO_CRITTER_0_PORT5(16), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_12), + NATURE_IO_CRITTER_1_BEND_PITCH(112), + NATURE_IO_CRITTER_1_NUM_LAYERS(0), + NATURE_IO_CRITTER_1_PORT5(48), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_15), + NATURE_IO_CRITTER_2_BEND_PITCH(127), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 10 + { + 0xC081, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_1), + NATURE_IO_STREAM_0_PORT3(8), + + // Channel 7 + NATURE_IO_CRITTER_6_TYPE(NATURE_CRITTER_11), + NATURE_IO_CRITTER_6_BEND_PITCH(112), + NATURE_IO_CRITTER_6_NUM_LAYERS(2), + NATURE_IO_CRITTER_6_PORT5(32), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 11 + { + 0xC00F, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_3), + NATURE_IO_STREAM_0_PORT3(8), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_0_BEND_PITCH(127), + NATURE_IO_CRITTER_0_NUM_LAYERS(3), + NATURE_IO_CRITTER_0_PORT5(16), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_00), + NATURE_IO_CRITTER_1_BEND_PITCH(127), + NATURE_IO_CRITTER_1_NUM_LAYERS(2), + NATURE_IO_CRITTER_1_PORT5(16), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_06), + NATURE_IO_CRITTER_2_BEND_PITCH(127), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 12 + { + 0xC007, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_00), + NATURE_IO_CRITTER_0_BEND_PITCH(127), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_1_BEND_PITCH(127), + NATURE_IO_CRITTER_1_NUM_LAYERS(3), + NATURE_IO_CRITTER_1_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 13 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 14 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 15 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 16 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 17 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 18 + { + 0xC000, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 19 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + + }, + }, +}; + +// AudioOcarina Data +u8 sIsOcarinaInputEnabled = false; +s8 sOcarinaInstrumentId = OCARINA_INSTRUMENT_OFF; +u8 sCurOcarinaPitch = OCARINA_PITCH_NONE; +u8 sPrevOcarinaPitch = 0; +u8 sCurOcarinaButtonIdx = 0; +u8 sMusicStaffPrevPitch = 0; +f32 sCurOcarinaBendFreq = 1.0f; +f32 sDefaultOcarinaVolume = 0.68503935f; +s8 sCurOcarinaBendIdx = 0; +s8 sCurOcarinaVolume = 0x57; +s8 sCurOcarinaVibrato = 0; +u8 sPlaybackState = 0; +u8 D_801D6FE4 = 0xFF; +u8 D_801D6FE8 = 0xFF; +u32 sOcarinaFlags = 0; +s32 sPlaybackNoteTimer = 0; +u16 sPlaybackNotePos = 0; +u16 sPlaybackStaffPos = 0; +u32 sPrevOcarinaSongFlags = 0; // Stores sOcarinaFlags but never used +u8 sPlaybackNoteValue = OCARINA_PITCH_NONE; +u8 sNotePlaybackVolume = 0; +u8 sNotePlaybackVibrato = 0; +s8 sNotePlaybackBend = 0; +f32 sNormalizedNotePlaybackTone = 1.0f; +f32 sNormalizedNotePlaybackVolume = 1.0f; +u32 sOcarinaPlaybackTaskStart = 0; +u32 sOcarinaWallCounter = 0; +u8 sCurOcarinaSong[8] = { + OCARINA_PITCH_C4, OCARINA_PITCH_C4, OCARINA_PITCH_C4, OCARINA_PITCH_C4, + OCARINA_PITCH_C4, OCARINA_PITCH_C4, OCARINA_PITCH_C4, OCARINA_PITCH_C4, +}; +u8 sOcarinaSongAppendPos = 0; +u8 sOcarinaSongStartingPos = 0; + +u8 sButtonToNoteMap[5] = { + OCARINA_PITCH_D4, // OCARINA_BTN_A + OCARINA_PITCH_F4, // OCARINA_BTN_C_DOWN + OCARINA_PITCH_A4, // OCARINA_BTN_C_RIGHT + OCARINA_PITCH_B4, // OCARINA_BTN_C_LEFT + OCARINA_PITCH_D5, // OCARINA_BTN_C_UP +}; + +u8 sOcaMemoryGameAppendPos = 0; +u8 sOcaMemoryGameEndPos = 0; +u8 sOcaMemoryGameNumNotes[] = { 5, 6, 8 }; +OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { + // 0: Sonata of Awakening + { + { OCARINA_PITCH_D5, 19, 92, 0, 0, 0 }, + { OCARINA_PITCH_B4, 19, 90, 0, 0, 0 }, + { OCARINA_PITCH_D5, 19, 90, 0, 0, 0 }, + { OCARINA_PITCH_B4, 38, 90, 0, 0, 0 }, + { OCARINA_PITCH_D4, 39, 92, 0, 0, 0 }, + { OCARINA_PITCH_A4, 76, 89, 0, 0, 0 }, + { OCARINA_PITCH_D4, 77, 82, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 86, 0, 0, 0 }, + }, + + // 1: Goron Lullaby + { + { OCARINA_PITCH_D4, 41, 80, 0, 0, 0 }, + { OCARINA_PITCH_A4, 40, 72, 0, 0, 0 }, + { OCARINA_PITCH_B4, 39, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 42, 76, 0, 0, 0 }, + { OCARINA_PITCH_A4, 40, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 39, 76, 0, 0, 0 }, + { OCARINA_PITCH_A4, 41, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 80, 76, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 40, 76, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 2: New Wave Bossa Nova + { + { OCARINA_PITCH_B4, 64, 74, 0, 0, 0 }, + { OCARINA_PITCH_D5, 13, 88, 0, 0, 0 }, + { OCARINA_PITCH_B4, 12, 90, 0, 0, 0 }, + { OCARINA_PITCH_A4, 78, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 12, 76, 0, 0, 0 }, + { OCARINA_PITCH_B4, 13, 76, 0, 0, 0 }, + { OCARINA_PITCH_A4, 114, 76, 6, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 3: Elegy of Emptyness + { + { OCARINA_PITCH_A4, 85, 93, 0, 0, 0 }, + { OCARINA_PITCH_B4, 43, 91, 0, 0, 0 }, + { OCARINA_PITCH_A4, 43, 93, 0, 0, 0 }, + { OCARINA_PITCH_F4, 21, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 21, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 43, 101, 0, 0, 0 }, + { OCARINA_PITCH_B4, 85, 95, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 94, 0, 0, 0 }, + }, + + // 4: Oath to Order + { + { OCARINA_PITCH_A4, 97, 104, 0, 0, 0 }, + { OCARINA_PITCH_F4, 48, 88, 0, 0, 0 }, + { OCARINA_PITCH_D4, 49, 78, 0, 0, 0 }, + { OCARINA_PITCH_F4, 49, 78, 0, 0, 0 }, + { OCARINA_PITCH_A4, 48, 94, 0, 0, 0 }, + { OCARINA_PITCH_D5, 97, 100, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 96, 0, 0, 0 }, + + }, + + // 5: Sarias Song + { + { OCARINA_PITCH_F4, 17, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 17, 88, 0, 0, 0 }, + { OCARINA_PITCH_B4, 34, 80, 0, 0, 0 }, + { OCARINA_PITCH_F4, 17, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 17, 88, 0, 0, 0 }, + { OCARINA_PITCH_B4, 136, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 6: Song of Time + { + { OCARINA_PITCH_A4, 32, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 65, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 33, 80, 0, 0, 0 }, + { OCARINA_PITCH_A4, 32, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 65, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 99, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 7: Song of Healing + { + { OCARINA_PITCH_B4, 32, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 33, 69, 0, 0, 0 }, + { OCARINA_PITCH_B4, 32, 94, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 121, 86, 2, 0, 0 }, + { OCARINA_PITCH_NONE, 10, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 8: Eponas Song + { + { OCARINA_PITCH_D5, 18, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 18, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 72, 80, 0, 0, 0 }, + { OCARINA_PITCH_D5, 18, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 18, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 144, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 9: Song of Soaring + { + { OCARINA_PITCH_F4, 18, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 18, 80, 0, 0, 0 }, + { OCARINA_PITCH_D5, 36, 94, 0, 0, 0 }, + { OCARINA_PITCH_F4, 18, 73, 0, 0, 0 }, + { OCARINA_PITCH_B4, 18, 76, 0, 0, 0 }, + { OCARINA_PITCH_D5, 108, 96, 2, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 10: Song of Storms + { + { OCARINA_PITCH_D4, 11, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 11, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 45, 80, 0, 0, 0 }, + { OCARINA_PITCH_D4, 11, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 11, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 90, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 11: Suns Song + { + { OCARINA_PITCH_A4, 12, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 13, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 29, 80, 2, 0, 0 }, + { OCARINA_PITCH_NONE, 9, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 12, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 13, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 120, 80, 3, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 12: Inverted Song of Time + { + { OCARINA_PITCH_F4, 32, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 65, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 80, 0, 0, 0 }, + { OCARINA_PITCH_F4, 32, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 65, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 99, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 13: Song of Double Time + { + { OCARINA_PITCH_A4, 29, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 30, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 29, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 30, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 29, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 99, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 0, 0, 0, 0 }, + }, + + // 14: Goron Lullaby Intro + { + { OCARINA_PITCH_D4, 32, 78, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 90, 0, 0, 0 }, + { OCARINA_PITCH_B4, 33, 87, 0, 0, 0 }, + { OCARINA_PITCH_D4, 32, 92, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 86, 0, 0, 0 }, + { OCARINA_PITCH_B4, 130, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 15: Milk Bar Jam "Ballad of the Wind Fish" Human + { + { OCARINA_PITCH_D5, 89, 80, 0, 0, 0 }, + { OCARINA_PITCH_A4, 41, 72, 0, 0, 0 }, + { OCARINA_PITCH_B4, 22, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 91, 76, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 30, 66, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 16: Milk Bar Jam "Ballad of the Wind Fish" Goron + { + { OCARINA_PITCH_D4, 52, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, + { OCARINA_PITCH_D4, 8, 72, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, + { OCARINA_PITCH_D4, 30, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, + { OCARINA_PITCH_F4, 34, 76, 0, 0, 0 }, + { OCARINA_PITCH_D4, 52, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, + { OCARINA_PITCH_D4, 8, 72, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, + { OCARINA_PITCH_D4, 30, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, + { OCARINA_PITCH_A4, 34, 76, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 17: Milk Bar Jam "Ballad of the Wind Fish" Zora + { + { OCARINA_PITCH_D5, 11, 80, 0, 0, 0 }, + { OCARINA_PITCH_A4, 11, 72, 0, 0, 0 }, + { OCARINA_PITCH_F4, 11, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 100, 76, 0, 0, 0 }, + { OCARINA_PITCH_D5, 11, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 11, 76, 0, 0, 0 }, + { OCARINA_PITCH_A4, 11, 72, 0, 0, 0 }, + { OCARINA_PITCH_F4, 100, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 18: Milk Bar Jam "Ballad of the Wind Fish" Deku + { + { OCARINA_PITCH_A4, 54, 80, 0, 0, 0 }, + { OCARINA_PITCH_D4, 77, 72, 0, 0, 0 }, + { OCARINA_PITCH_F4, 19, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 20, 76, 0, 0, 0 }, + { OCARINA_PITCH_A4, 78, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 19: Evan HP (Zora Band Leader) Song Part 1 + { + { OCARINA_PITCH_A4, 33, 100, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 92, 0, 0, 0 }, + { OCARINA_PITCH_A4, 37, 104, 0, 0, 0 }, + { OCARINA_PITCH_F4, 24, 100, 0, 0, 0 }, + { OCARINA_PITCH_D4, 70, 97, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 96, 0, 0, 0 }, + { OCARINA_PITCH_D4, 12, 93, 0, 0, 0 }, + { OCARINA_PITCH_F4, 12, 100, 0, 0, 0 }, + { OCARINA_PITCH_A4, 12, 62, 0, 0, 0 }, + { OCARINA_PITCH_D4, 170, 91, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 20: Evan HP (Zora Band Leader) Song Part 2 + { + { OCARINA_PITCH_B4, 33, 107, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 100, 0, 0, 0 }, + { OCARINA_PITCH_B4, 37, 104, 0, 0, 0 }, + { OCARINA_PITCH_A4, 24, 97, 0, 0, 0 }, + { OCARINA_PITCH_F4, 70, 104, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 104, 0, 0, 0 }, + { OCARINA_PITCH_F4, 12, 90, 0, 0, 0 }, + { OCARINA_PITCH_A4, 12, 96, 0, 0, 0 }, + { OCARINA_PITCH_B4, 12, 81, 0, 0, 0 }, + { OCARINA_PITCH_F4, 170, 66, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 21: Zeldas Lullaby + { + { OCARINA_PITCH_B4, 51, 84, 0, 0, 0 }, + { OCARINA_PITCH_D5, 25, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 78, 80, 0, 0, 0 }, + { OCARINA_PITCH_B4, 51, 84, 0, 0, 0 }, + { OCARINA_PITCH_D5, 25, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 100, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 22: Scarecrow + { + { OCARINA_PITCH_D4, 3, 0, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 255, 0, 0, 0 }, + }, + + // 23: Termina Field 2D Song Buttons Appearing on Wall (In OoT, this is Ocarina Memory Game) + { + { OCARINA_PITCH_D4, 3, 0, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 255, 0, 0, 0 }, + }, +}; + +OcarinaNote sOoTOcarinaSongNotes[9][20] = { + // Minuet + { + { OCARINA_PITCH_D4, 18, 86, 0, 0, 0 }, + { OCARINA_PITCH_D5, 18, 92, 0, 0, 0 }, + { OCARINA_PITCH_B4, 72, 86, 0, 0, 0 }, + { OCARINA_PITCH_A4, 18, 80, 0, 0, 0 }, + { OCARINA_PITCH_B4, 18, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 144, 86, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 86, 0, 0, 0 }, + }, + + // Bolero + { + { OCARINA_PITCH_F4, 15, 80, 0, 0, 0 }, + { OCARINA_PITCH_D4, 15, 72, 0, 0, 0 }, + { OCARINA_PITCH_F4, 15, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 15, 76, 0, 0, 0 }, + { OCARINA_PITCH_A4, 15, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 15, 74, 0, 0, 0 }, + { OCARINA_PITCH_A4, 15, 78, 0, 0, 0 }, + { OCARINA_PITCH_F4, 135, 66, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // Serenade + { + { OCARINA_PITCH_D4, 36, 60, 0, 0, 0 }, + { OCARINA_PITCH_F4, 36, 78, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 82, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 82, 0, 0, 0 }, + { OCARINA_PITCH_A4, 36, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 144, 90, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // Requiem + { + { OCARINA_PITCH_D4, 45, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 23, 86, 0, 0, 0 }, + { OCARINA_PITCH_D4, 22, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 45, 86, 0, 0, 0 }, + { OCARINA_PITCH_F4, 45, 94, 0, 0, 0 }, + { OCARINA_PITCH_D4, 180, 94, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 94, 0, 0, 0 }, + }, + + // Nocturne + { + { OCARINA_PITCH_B4, 36, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 18, 82, 0, 0, 0 }, + { OCARINA_PITCH_D4, 18, 60, 0, 0, 0 }, + { OCARINA_PITCH_B4, 18, 90, 0, 0, 0 }, + { OCARINA_PITCH_A4, 18, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 144, 96, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 96, 0, 0, 0 }, + }, + + // Prelude + { + { OCARINA_PITCH_D5, 15, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 45, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 15, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 15, 82, 0, 0, 0 }, + { OCARINA_PITCH_B4, 15, 86, 0, 0, 0 }, + { OCARINA_PITCH_D5, 60, 90, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 75, 90, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // Sarias + { + { OCARINA_PITCH_F4, 17, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 17, 88, 0, 0, 0 }, + { OCARINA_PITCH_B4, 34, 80, 0, 0, 0 }, + { OCARINA_PITCH_F4, 17, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 17, 88, 0, 0, 0 }, + { OCARINA_PITCH_B4, 136, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // Zeldas Lullaby + { + { OCARINA_PITCH_B4, 51, 84, 0, 0, 0 }, + { OCARINA_PITCH_D5, 25, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 78, 80, 0, 0, 0 }, + { OCARINA_PITCH_B4, 51, 84, 0, 0, 0 }, + { OCARINA_PITCH_D5, 25, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 100, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // Suns Song + { + { OCARINA_PITCH_A4, 12, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 13, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 29, 80, 2, 0, 0 }, + { OCARINA_PITCH_NONE, 9, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 12, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 13, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 120, 80, 3, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, +}; + +u8 sOoTOcarinaSongsNumNotes[] = { + 6, // Minuet + 8, // Bolero + 5, // Serenade + 6, // Requiem + 7, // Nocturne + 6, // Prelude + 6, // Sarias + 6, // Zeldas Lullaby + 6, // Suns Song +}; + +OcarinaNote* sPlaybackSong = sOcarinaSongNotes[OCARINA_SONG_SONATA]; +u8 sFrogsSongNotes[14] = { + OCARINA_BTN_A, OCARINA_BTN_C_LEFT, OCARINA_BTN_C_RIGHT, OCARINA_BTN_C_DOWN, OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, OCARINA_BTN_C_DOWN, OCARINA_BTN_A, OCARINA_BTN_C_DOWN, OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, OCARINA_BTN_C_RIGHT, OCARINA_BTN_C_LEFT, OCARINA_BTN_A, +}; +u8* gFrogsSongPtr = sFrogsSongNotes; +u8 sRecordingState = OCARINA_RECORD_OFF; +u8 sRecordSongPos = 0; +u32 sOcarinaRecordTaskStart = 0; +u8 sRecordOcarinaPitch = 0; +u8 sRecordOcarinaVolume = 0; +u8 sRecordOcarinaVibrato = 0; +s8 sRecordOcarinaBendIdx = 0; +u8 sRecordOcarinaButtonIdx = 0; +u8 sPlayedOcarinaSongIdxPlusOne = 0; +u8 sMusicStaffNumNotesPerTest = 0; +u8 D_801D8530 = false; +u32 D_801D8534 = 0; +u8 sIsOcarinaNoteChanged = false; + +OcarinaNote sScarecrowsLongSongNotes[108] = { + { OCARINA_PITCH_NONE, 0, 0, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 0, 0, 0, 0 }, +}; + +OcarinaNote* gScarecrowLongSongPtr = sScarecrowsLongSongNotes; +u8* gScarecrowSpawnSongPtr = (u8*)&sOcarinaSongNotes[OCARINA_SONG_SCARECROW]; +OcarinaNote* sTerminaWallSongPtr = sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL]; + +u8 sNoteToButtonMap[16] = { + OCARINA_BTN_A, // OCARINA_PITCH_C4 + OCARINA_BTN_A, // OCARINA_PITCH_DFLAT4 + OCARINA_BTN_A, // OCARINA_PITCH_D4 + OCARINA_BTN_A, // OCARINA_PITCH_EFLAT4 + OCARINA_BTN_C_DOWN, // OCARINA_PITCH_E4 + OCARINA_BTN_C_DOWN, // OCARINA_PITCH_F4 + OCARINA_BTN_C_DOWN, // OCARINA_PITCH_GFLAT4 + OCARINA_BTN_C_RIGHT, // OCARINA_PITCH_G4 + OCARINA_BTN_C_RIGHT, // OCARINA_PITCH_AFLAT4 + OCARINA_BTN_C_RIGHT, // OCARINA_PITCH_A4 + OCARINA_BTN_C_RIGHT + OCARINA_BTN_C_LEFT, // OCARINA_PITCH_BFLAT4: Interface/Overlap between C_RIGHT and C_LEFT + OCARINA_BTN_C_LEFT, // OCARINA_PITCH_B4 + OCARINA_BTN_C_LEFT, // OCARINA_PITCH_C5 + OCARINA_BTN_C_UP, // OCARINA_PITCH_DFLAT5 + OCARINA_BTN_C_UP, // OCARINA_PITCH_D5 + OCARINA_BTN_C_UP, // OCARINA_PITCH_EFLAT5 +}; + +// seqData written in the music macro language +// Only used in unused functions +u8 sCustomSequenceScript[400] = { + 0xFE, 0xFE, 0xD3, 0x20, 0xD7, 0x00, 0x01, 0xCC, 0x00, 0x70, 0x90, 0x00, 0x16, 0xDB, 0x64, 0xDD, 0x78, + 0xFE, 0x00, 0xF3, 0xFC, 0xFF, 0xC3, 0x88, 0x00, 0x29, 0x89, 0x00, 0x2B, 0xDF, 0x7F, 0xE9, 0x0F, 0xDD, + 0x37, 0xD4, 0x40, 0xC1, 0x52, 0xFE, 0x80, 0xF3, 0xFC, 0xFF, 0xC2, 0xFB, 0xC0, 0x00, 0xC1, 0x57, 0xC9, +}; + +OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { + // 0: Sonata of Awakening + { + 7, + { + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + }, + }, + + // 1: Goron Lullaby + { + 8, + { + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + }, + }, + + // 2: New Wave Bossa Nova + { + 7, + { + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 3: Elegy of Emptyness + { + 7, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + }, + }, + + // 4: Oath to Order + { + 6, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_UP, + }, + }, + + // 5; Sarias Song + { + 6, + { + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + }, + }, + + // 6: Song of Time + { + 6, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + }, + }, + + // 7: Song of Healing + { + 6, + { + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + }, + }, + + // 8: Eponas Song + { + 6, + { + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 9: Song of Soaring + { + 6, + { + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + }, + }, + + // 10: Song of Storms + { + 6, + { + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_UP, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_UP, + }, + }, + + // 11: Suns Song + { + 6, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_UP, + }, + }, + + // 12: Inverted Song of Time + { + 6, + { + OCARINA_BTN_C_DOWN, + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 13; Song of Double Time + { + 6, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_DOWN, + }, + }, + + // 14: Goron Lullaby Intro + { + 6, + { + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + }, + }, + + // 15: Milk Bar Jam "Ballad of the Wind Fish" Human + { + 4, + { + OCARINA_BTN_C_UP, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 16: Milk Bar Jam "Ballad of the Wind Fish" Goron + { + 8, + { + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 17: Milk Bar Jam "Ballad of the Wind Fish" Zora + { + 8, + { + OCARINA_BTN_C_UP, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_A, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + }, + }, + + // 18: Milk Bar Jam "Ballad of the Wind Fish" Deku + { + 5, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 19: Evan HP (Zora Band Leader) Song Part 1 + { + 8, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + }, + }, + + // 20: Evan HP (Zora Band Leader) Song Part 2 + { + 8, + { + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_DOWN, + }, + }, + + // 21: Zeldas Lullaby + { + 6, + { + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 22: Scarecrow + { + 8, + { + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + }, + }, + + // 23: Termina Field 2D Song Buttons Appearing on Wall (In OoT, this is Ocarina Memory Game) + { + 8, + { + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + }, + }, +}; + +// Static In-Function Data +u8 sScarecrowAfterCreditsState = 0; +u8 sScarecrowAfterCreditsIntrumentId = OCARINA_INSTRUMENT_DEFAULT; +u16 sScarecrowAfterCreditsTimer = 1200; +u8 sRequestCustomSequence = false; +s8 D_801D8B30[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 60, 61, 61, 61, 62, 62, 62, 63, 63, 63, 64, 64, + 64, 65, 65, 65, 66, 66, 66, 67, 67, 67, 68, 68, 69, 69, 70, 70, 71, 71, 72, 73, 74, 75, + 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, + 98, 99, 100, 101, 102, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, +}; +f32 sBigBellsVolume[8] = { + 1.0f, 0.9f, 0.8f, 0.7f, 0.6f, 0.5f, 0.4f, 0.3f, +}; +u8 sBgmPlayers[2] = { SEQ_PLAYER_BGM_MAIN, SEQ_PLAYER_BGM_SUB }; +f32 sSfxOriginalPos[] = { 0.0f, 0.0f, 0.0f }; + +// OoT's soundEffects from EnRiverSound +const u16 gAudioEnvironmentalSfx[] = { + NA_SE_EV_RIVER_STREAM - SFX_FLAG, NA_SE_EV_WAVE - SFX_FLAG, + NA_SE_EV_WATER_WALL_BIG - SFX_FLAG, NA_SE_EV_WATER_WALL - SFX_FLAG, + NA_SE_EV_MAGMA_LEVEL - SFX_FLAG, NA_SE_EV_MAGMA_LEVEL_M - SFX_FLAG, + NA_SE_EV_MAGMA_LEVEL_L - SFX_FLAG, NA_SE_EV_TORCH - SFX_FLAG, + NA_SE_EV_FOUNTAIN - SFX_FLAG, NA_SE_EV_DRAIN - SFX_FLAG, + NA_SE_EV_CROWD - SFX_FLAG, NA_SE_EV_WATER_CONVECTION - SFX_FLAG, + NA_SE_EV_GORON_CHEER - SFX_FLAG, NA_SE_EV_WATER_WALL_BIG_SILENT - SFX_FLAG, + NA_SE_EV_WATER_BUBBLE - SFX_FLAG, NA_SE_EV_COW_CRY_LV - SFX_FLAG, + NA_SE_EV_MAKE_TURRET - SFX_FLAG, NA_SE_EV_BOILED_WATER_S - SFX_FLAG, + NA_SE_EV_BOILED_WATER_L - SFX_FLAG, NA_SE_EV_WAVE_S - SFX_FLAG, + NA_SE_EV_WAVE_S - SFX_FLAG, NA_SE_EV_WAVE_S - SFX_FLAG, +}; + +/** +const u8 sIsOcarinaSongReserved[OCARINA_SONG_MAX] = { + true, // OCARINA_SONG_SONATA + true, // OCARINA_SONG_GORON_LULLABY + true, // OCARINA_SONG_NEW_WAVE + true, // OCARINA_SONG_ELEGY + true, // OCARINA_SONG_OATH + false, // OCARINA_SONG_SARIAS + true, // OCARINA_SONG_TIME + true, // OCARINA_SONG_HEALING + true, // OCARINA_SONG_EPONAS + true, // OCARINA_SONG_SOARING + true, // OCARINA_SONG_STORMS + false, // OCARINA_SONG_SUNS + true, // OCARINA_SONG_INVERTED_TIME + true, // OCARINA_SONG_DOUBLE_TIME + true, // OCARINA_SONG_GORON_LULLABY_INTRO + false, // OCARINA_SONG_WIND_FISH_HUMAN + false, // OCARINA_SONG_WIND_FISH_GORON + false, // OCARINA_SONG_WIND_FISH_ZORA + false, // OCARINA_SONG_WIND_FISH_DEKU + true, // OCARINA_SONG_EVAN_PART1 + true, // OCARINA_SONG_EVAN_PART2 + false, // OCARINA_SONG_ZELDAS_LULLABY + true, // OCARINA_SONG_SCARECROW + false, // OCARINA_SONG_TERMINA_WALL +}; +*/ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019AF00.s") @@ -56,7 +1932,14 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C8D8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/D_801E0C14.s") +const char sAudioOcarinaUnusedText0[] = "key step is too long !!! %d:%d>%d\n"; +const char sAudioOcarinaUnusedText1[] = "You played %d Melody !!! (last step:%d)\n"; +const char sAudioOcarinaUnusedText2[] = "pass 0\n"; +const char sAudioOcarinaUnusedText3[] = "pass 1\n"; +const char sAudioOcarinaUnusedText4[] = "pass 2\n"; +const char sAudioOcarinaUnusedText5[] = "last key is bad !!! %d %d %02X %02X\n"; +const char sAudioOcarinaUnusedText6[] = "last key step is too short !!! %d:%d %d<%d\n"; +const char sAudioOcarinaUnusedText7[] = "check is over!!! %d %d %d\n"; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CD08.s") diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index f0d6ac9db..5f4f6461b 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -314,7 +314,7 @@ void func_80AA01C0(DmStk* this, GlobalContext* globalCtx) { case 785: func_8019F128(NA_SE_SY_STALKIDS_PSYCHO); - func_8019FE74(&D_801D6654, 0.0f, 150); + func_8019FE74(&gSfxVolume, 0.0f, 150); break; case 560: @@ -344,7 +344,7 @@ void func_80AA0264(DmStk* this, GlobalContext* globalCtx) { break; case 650: - func_8019FE74(&D_801D6654, 0.0f, 80); + func_8019FE74(&gSfxVolume, 0.0f, 80); break; case 265: diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 802bc6c96..d82b93e99 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2304,122 +2304,116 @@ 0x801D6200:("D_801D6200","UNK_TYPE1","",0x1), 0x801D6600:("D_801D6600","UNK_TYPE1","",0x1), 0x801D6608:("D_801D6608","UNK_TYPE1","",0x1), - 0x801D6610:("D_801D6610","UNK_TYPE1","",0x1), - 0x801D662C:("D_801D662C","UNK_TYPE1","",0x1), - 0x801D6648:("D_801D6648","UNK_TYPE1","",0x1), - 0x801D664C:("D_801D664C","UNK_TYPE1","",0x1), - 0x801D6650:("D_801D6650","UNK_TYPE1","",0x1), - 0x801D6654:("D_801D6654","UNK_TYPE4","",0x4), - 0x801D6658:("D_801D6658","UNK_TYPE1","",0x1), - 0x801D665C:("D_801D665C","UNK_TYPE1","",0x1), - 0x801D6660:("D_801D6660","UNK_TYPE1","",0x1), - 0x801D666C:("D_801D666C","UNK_TYPE1","",0x1), - 0x801D6680:("D_801D6680","UNK_TYPE1","",0x1), - 0x801D6684:("D_801D6684","UNK_TYPE1","",0x1), - 0x801D6694:("D_801D6694","UNK_TYPE4","",0x4), - 0x801D6698:("D_801D6698","UNK_TYPE1","",0x1), - 0x801D669E:("D_801D669E","UNK_TYPE1","",0x1), - 0x801D669F:("D_801D669F","UNK_TYPE1","",0x1), - 0x801D66A0:("D_801D66A0","UNK_TYPE1","",0x1), - 0x801D66A4:("D_801D66A4","UNK_TYPE2","",0x2), - 0x801D66A8:("D_801D66A8","UNK_TYPE1","",0x1), - 0x801D66AC:("D_801D66AC","UNK_TYPE1","",0x1), - 0x801D66B0:("D_801D66B0","UNK_TYPE1","",0x1), - 0x801D66B4:("D_801D66B4","UNK_TYPE1","",0x1), - 0x801D66B8:("D_801D66B8","UNK_TYPE1","",0x1), - 0x801D66BC:("D_801D66BC","UNK_TYPE1","",0x1), - 0x801D66C0:("D_801D66C0","UNK_TYPE1","",0x1), - 0x801D66C4:("D_801D66C4","f32","",0x4), - 0x801D66C8:("D_801D66C8","UNK_TYPE1","",0x1), - 0x801D66CC:("D_801D66CC","UNK_TYPE2","",0x2), - 0x801D66D0:("D_801D66D0","UNK_TYPE1","",0x1), - 0x801D66D4:("D_801D66D4","UNK_TYPE1","",0x1), - 0x801D66D8:("D_801D66D8","UNK_TYPE4","",0x4), - 0x801D66DC:("D_801D66DC","UNK_TYPE4","",0x4), - 0x801D66E0:("D_801D66E0","UNK_TYPE1","",0x1), - 0x801D66E4:("D_801D66E4","UNK_TYPE1","",0x1), - 0x801D66E8:("D_801D66E8","UNK_TYPE1","",0x1), - 0x801D66EC:("D_801D66EC","UNK_TYPE1","",0x1), - 0x801D66F0:("D_801D66F0","UNK_TYPE1","",0x1), - 0x801D66F4:("D_801D66F4","UNK_TYPE4","",0x4), - 0x801D66F8:("D_801D66F8","UNK_TYPE4","",0x4), - 0x801D66FC:("D_801D66FC","UNK_TYPE1","",0x1), - 0x801D6700:("D_801D6700","UNK_TYPE1","",0x1), - 0x801D6780:("D_801D6780","UNK_TYPE1","",0x1), - 0x801D6794:("D_801D6794","UNK_TYPE1","",0x1), - 0x801D6FB4:("D_801D6FB4","UNK_TYPE1","",0x1), - 0x801D6FB8:("D_801D6FB8","UNK_TYPE1","",0x1), - 0x801D6FBC:("D_801D6FBC","UNK_TYPE1","",0x1), - 0x801D6FC0:("D_801D6FC0","UNK_TYPE1","",0x1), - 0x801D6FC4:("D_801D6FC4","UNK_TYPE1","",0x1), - 0x801D6FC8:("D_801D6FC8","UNK_TYPE1","",0x1), - 0x801D6FCC:("D_801D6FCC","f32","",0x4), - 0x801D6FD0:("D_801D6FD0","UNK_TYPE1","",0x1), - 0x801D6FD4:("D_801D6FD4","UNK_TYPE1","",0x1), - 0x801D6FD8:("D_801D6FD8","UNK_TYPE1","",0x1), - 0x801D6FDC:("D_801D6FDC","UNK_TYPE1","",0x1), - 0x801D6FE0:("D_801D6FE0","UNK_TYPE1","",0x1), + 0x801D6610:("gChannelsPerBank","UNK_TYPE1","",0x1), + 0x801D662C:("gUsedChannelsPerBank","UNK_TYPE1","",0x1), + 0x801D6648:("sGiantsMaskFreq","UNK_TYPE1","",0x1), + 0x801D664C:("sGiantsMaskReverbAdd","UNK_TYPE1","",0x1), + 0x801D6650:("sWaterWheelVolume","UNK_TYPE1","",0x1), + 0x801D6654:("gSfxVolume","UNK_TYPE4","",0x4), + 0x801D6658:("sSfxTimer","UNK_TYPE1","",0x1), + 0x801D665C:("sSfxTimerLerpRange2","UNK_TYPE1","",0x1), + 0x801D6660:("sSfxTimerLerpRange1","s8","",0x1), + 0x801D6664:("D_801D6664","f32","[2]",0x8), + 0x801D666C:("sAudioIncreasingTranspose","UNK_TYPE1","",0x1), + 0x801D6680:("sPrevChargeLevel","UNK_TYPE1","",0x1), + 0x801D6684:("sChargeLevelsSfxFreq","UNK_TYPE1","",0x1), + 0x801D6694:("sCurChargeLevelSfxFreq","UNK_TYPE4","",0x4), + 0x801D6698:("sGanonsTowerLevelsVol","u8","[8]",0x8), + 0x801D66A0:("sEnterGanonsTowerTimer","UNK_TYPE1","",0x1), + 0x801D66A4:("sSfxVolumeDuration","UNK_TYPE2","",0x2), + 0x801D66A8:("sAudioFileSelectSetting","UNK_TYPE1","",0x1), + 0x801D66AC:("sAudioIsWindowOpen","UNK_TYPE1","",0x1), + 0x801D66B0:("sAudioCutsceneFlag","UNK_TYPE1","",0x1), + 0x801D66B4:("sSpecReverb","UNK_TYPE1","",0x1), + 0x801D66B8:("sAudioEnvReverb","UNK_TYPE1","",0x1), + 0x801D66BC:("sAudioCodeReverb","UNK_TYPE1","",0x1), + 0x801D66C0:("sPrevSeqMode","UNK_TYPE1","",0x1), + 0x801D66C4:("sAudioEnemyDist","f32","",0x4), + 0x801D66C8:("sAudioEnemyVol","UNK_TYPE1","",0x1), + 0x801D66CC:("sPrevMainBgmSeqId","UNK_TYPE2","",0x2), + 0x801D66D0:("sBgmPlayerIOPort7","UNK_TYPE1","",0x1), + 0x801D66D4:("sSceneSeqId2","UNK_TYPE1","",0x1), + 0x801D66D8:("sNumFramesStill","UNK_TYPE4","",0x4), + 0x801D66DC:("sNumFramesMoving","UNK_TYPE4","",0x4), + 0x801D66E0:("sAudioBaseFilter","UNK_TYPE1","",0x1), + 0x801D66E4:("sAudioExtraFilter","UNK_TYPE1","",0x1), + 0x801D66E8:("sAudioBaseFilter2","UNK_TYPE1","",0x1), + 0x801D66EC:("sAudioExtraFilter2","UNK_TYPE1","",0x1), + 0x801D66F0:("gUnderwaterSfxReverbAdd","UNK_TYPE1","",0x1), + 0x801D66F4:("sRiverSoundBgmPos","UNK_TYPE4","",0x4), + 0x801D66F8:("sRiverSoundXZDistToPlayer","UNK_TYPE4","",0x4), + 0x801D66FC:("sObjSoundMainBgmSeqId","UNK_TYPE1","",0x1), + 0x801D6700:("sSeqFlags","UNK_TYPE1","",0x1), + 0x801D6780:("sSpecReverbs","UNK_TYPE1","",0x1), + 0x801D6794:("sNatureAmbienceData","UNK_TYPE1","",0x1), + 0x801D6FB4:("sIsOcarinaInputEnabled","UNK_TYPE1","",0x1), + 0x801D6FB8:("sOcarinaInstrumentId","UNK_TYPE1","",0x1), + 0x801D6FBC:("sCurOcarinaPitch","UNK_TYPE1","",0x1), + 0x801D6FC0:("sPrevOcarinaPitch","UNK_TYPE1","",0x1), + 0x801D6FC4:("sCurOcarinaButtonIdx","UNK_TYPE1","",0x1), + 0x801D6FC8:("sMusicStaffPrevPitch","UNK_TYPE1","",0x1), + 0x801D6FCC:("sCurOcarinaBendFreq","f32","",0x4), + 0x801D6FD0:("sDefaultOcarinaVolume","UNK_TYPE1","",0x1), + 0x801D6FD4:("sCurOcarinaBendIdx","UNK_TYPE1","",0x1), + 0x801D6FD8:("sCurOcarinaVolume","UNK_TYPE1","",0x1), + 0x801D6FDC:("sCurOcarinaVibrato","UNK_TYPE1","",0x1), + 0x801D6FE0:("sPlaybackState","UNK_TYPE1","",0x1), 0x801D6FE4:("D_801D6FE4","UNK_TYPE1","",0x1), 0x801D6FE8:("D_801D6FE8","UNK_TYPE1","",0x1), - 0x801D6FEC:("D_801D6FEC","UNK_TYPE4","",0x4), - 0x801D6FF0:("D_801D6FF0","UNK_TYPE4","",0x4), - 0x801D6FF4:("D_801D6FF4","UNK_TYPE2","",0x2), - 0x801D6FF8:("D_801D6FF8","UNK_TYPE2","",0x2), - 0x801D6FFC:("D_801D6FFC","UNK_TYPE4","",0x4), - 0x801D7000:("D_801D7000","UNK_TYPE1","",0x1), - 0x801D7004:("D_801D7004","UNK_TYPE1","",0x1), - 0x801D7008:("D_801D7008","UNK_TYPE1","",0x1), - 0x801D700C:("D_801D700C","UNK_TYPE1","",0x1), - 0x801D7010:("D_801D7010","f32","",0x4), - 0x801D7014:("D_801D7014","f32","",0x4), - 0x801D7018:("D_801D7018","UNK_TYPE4","",0x4), - 0x801D701C:("D_801D701C","UNK_TYPE4","",0x4), - 0x801D701E:("D_801D701E","UNK_TYPE1","",0x1), - 0x801D701F:("D_801D701F","UNK_TYPE1","",0x1), - 0x801D7020:("D_801D7020","UNK_TYPE1","",0x1), - 0x801D7028:("D_801D7028","UNK_TYPE1","",0x1), - 0x801D702C:("D_801D702C","UNK_TYPE1","",0x1), - 0x801D7030:("D_801D7030","UNK_TYPE1","",0x1), - 0x801D7038:("D_801D7038","UNK_TYPE1","",0x1), - 0x801D703C:("D_801D703C","UNK_TYPE1","",0x1), - 0x801D7040:("D_801D7040","UNK_TYPE1","",0x1), - 0x801D7044:("D_801D7044","UNK_TYPE1","",0x1), - 0x801D7E04:("D_801D7E04","UNK_TYPE4","",0x4), - 0x801D7EA4:("D_801D7EA4","UNK_TYPE1","",0x1), - 0x801D7F44:("D_801D7F44","UNK_TYPE1","",0x1), - 0x801D84E4:("D_801D84E4","UNK_TYPE1","",0x1), - 0x801D84F0:("D_801D84F0","UNK_PTR","",0x4), - 0x801D84F4:("D_801D84F4","UNK_TYPE1","",0x1), - 0x801D8508:("D_801D8508","UNK_TYPE1","",0x1), - 0x801D850C:("D_801D850C","UNK_TYPE1","",0x1), - 0x801D8510:("D_801D8510","UNK_TYPE4","",0x4), - 0x801D8514:("D_801D8514","UNK_TYPE1","",0x1), - 0x801D8518:("D_801D8518","UNK_TYPE1","",0x1), - 0x801D851C:("D_801D851C","UNK_TYPE1","",0x1), - 0x801D8520:("D_801D8520","UNK_TYPE1","",0x1), - 0x801D8524:("D_801D8524","UNK_TYPE1","",0x1), - 0x801D8528:("D_801D8528","UNK_TYPE1","",0x1), - 0x801D852C:("D_801D852C","UNK_TYPE1","",0x1), + 0x801D6FEC:("sOcarinaFlags","UNK_TYPE4","",0x4), + 0x801D6FF0:("sPlaybackNoteTimer","UNK_TYPE4","",0x4), + 0x801D6FF4:("sPlaybackNotePos","UNK_TYPE2","",0x2), + 0x801D6FF8:("sPlaybackStaffPos","UNK_TYPE2","",0x2), + 0x801D6FFC:("sPrevOcarinaSongFlags","UNK_TYPE4","",0x4), + 0x801D7000:("sPlaybackNoteValue","UNK_TYPE1","",0x1), + 0x801D7004:("sNotePlaybackVolume","UNK_TYPE1","",0x1), + 0x801D7008:("sNotePlaybackVibrato","UNK_TYPE1","",0x1), + 0x801D700C:("sNotePlaybackBend","UNK_TYPE1","",0x1), + 0x801D7010:("sNormalizedNotePlaybackTone","f32","",0x4), + 0x801D7014:("sNormalizedNotePlaybackVolume","f32","",0x4), + 0x801D7018:("sOcarinaPlaybackTaskStart","UNK_TYPE4","",0x4), + 0x801D701C:("sOcarinaWallCounter","UNK_TYPE4","",0x4), + 0x801D7020:("sCurOcarinaSong","u8","[8]",0x8), + 0x801D7028:("sOcarinaSongAppendPos","UNK_TYPE1","",0x1), + 0x801D702C:("sOcarinaSongStartingPos","UNK_TYPE1","",0x1), + 0x801D7030:("sButtonToNoteMap","UNK_TYPE1","",0x1), + 0x801D7038:("sOcaMemoryGameAppendPos","UNK_TYPE1","",0x1), + 0x801D703C:("sOcaMemoryGameEndPos","UNK_TYPE1","",0x1), + 0x801D7040:("sOcaMemoryGameNumNotes","UNK_TYPE1","",0x1), + 0x801D7044:("sOcarinaSongNotes","OcarinaNote","[24][20]",0xF00), + 0x801D7F44:("sOoTOcarinaSongNotes","OcarinaNote","[9][20]",0x5A0), + 0x801D84E4:("sOoTOcarinaSongsNumNotes","UNK_TYPE1","",0x1), + 0x801D84F0:("sPlaybackSong","UNK_PTR","",0x4), + 0x801D84F4:("sFrogsSongNotes","u8","[14]",0xE), + 0x801D8504:("gFrogsSongPtr","u8*","",0x4), + 0x801D8508:("sRecordingState","UNK_TYPE1","",0x1), + 0x801D850C:("sRecordSongPos","UNK_TYPE1","",0x1), + 0x801D8510:("sOcarinaRecordTaskStart","UNK_TYPE4","",0x4), + 0x801D8514:("sRecordOcarinaPitch","UNK_TYPE1","",0x1), + 0x801D8518:("sRecordOcarinaVolume","UNK_TYPE1","",0x1), + 0x801D851C:("sRecordOcarinaVibrato","UNK_TYPE1","",0x1), + 0x801D8520:("sRecordOcarinaBendIdx","UNK_TYPE1","",0x1), + 0x801D8524:("sRecordOcarinaButtonIdx","UNK_TYPE1","",0x1), + 0x801D8528:("sPlayedOcarinaSongIdxPlusOne","UNK_TYPE1","",0x1), + 0x801D852C:("sMusicStaffNumNotesPerTest","UNK_TYPE1","",0x1), 0x801D8530:("D_801D8530","UNK_TYPE1","",0x1), 0x801D8534:("D_801D8534","UNK_TYPE4","",0x4), - 0x801D8538:("D_801D8538","UNK_TYPE1","",0x1), - 0x801D853C:("D_801D853C","UNK_TYPE1","",0x1), - 0x801D853E:("D_801D853E","UNK_TYPE2","",0x2), - 0x801D8544:("D_801D8544","UNK_TYPE1","",0x1), - 0x801D889C:("D_801D889C","UNK_PTR","",0x4), - 0x801D88A0:("D_801D88A0","UNK_PTR","",0x4), - 0x801D88A4:("D_801D88A4","UNK_PTR","",0x4), - 0x801D88A8:("D_801D88A8","UNK_TYPE1","",0x1), - 0x801D88B8:("D_801D88B8","UNK_TYPE1","",0x1), - 0x801D8A48:("D_801D8A48","UNK_TYPE1","",0x1), - 0x801D8B20:("D_801D8B20","UNK_TYPE1","",0x1), - 0x801D8B24:("D_801D8B24","UNK_PTR","",0x4), - 0x801D8B28:("D_801D8B28","UNK_TYPE2","",0x2), - 0x801D8B2C:("D_801D8B2C","UNK_TYPE1","",0x1), + 0x801D8538:("sIsOcarinaNoteChanged","UNK_TYPE1","",0x1), + 0x801D853C:("sScarecrowsLongSongNotes","OcarinaNote","[108]",0x360), + 0x801D889C:("gScarecrowLongSongPtr","UNK_PTR","",0x4), + 0x801D88A0:("gScarecrowSpawnSongPtr","UNK_PTR","",0x4), + 0x801D88A4:("sTerminaWallSongPtr","UNK_PTR","",0x4), + 0x801D88A8:("sNoteToButtonMap","UNK_TYPE1","",0x1), + 0x801D88B8:("sCustomSequenceScript","UNK_TYPE1","",0x1), + 0x801D8A48:("gOcarinaSongButtons","UNK_TYPE1","",0x1), + 0x801D8B20:("sScarecrowAfterCreditsState","UNK_TYPE1","",0x1), + 0x801D8B24:("sScarecrowAfterCreditsIntrumentId","UNK_PTR","",0x4), + 0x801D8B28:("sScarecrowAfterCreditsTimer","UNK_TYPE2","",0x2), + 0x801D8B2C:("sRequestCustomSequence","UNK_TYPE1","",0x1), 0x801D8B30:("D_801D8B30","UNK_TYPE1","",0x1), - 0x801D8BB0:("D_801D8BB0","UNK_TYPE1","",0x1), - 0x801D8BD0:("D_801D8BD0","UNK_TYPE2","",0x2), - 0x801D8BD4:("D_801D8BD4","UNK_TYPE4","",0x4), + 0x801D8BB0:("sBigBellsVolume","UNK_TYPE1","",0x1), + 0x801D8BD0:("sBgmPlayers","UNK_TYPE2","",0x2), + 0x801D8BD4:("sSfxOriginalPos","UNK_TYPE4","",0x4), 0x801D8BE0:("D_801D8BE0","UNK_TYPE1","",0x1), 0x801D8E3C:("D_801D8E3C","UNK_TYPE1","",0x1), 0x801D8E40:("D_801D8E40","UNK_TYPE4","",0x4), @@ -3791,16 +3785,16 @@ 0x801E07C4:("jtbl_801E07C4","UNK_PTR","",0x4), 0x801E0948:("jtbl_801E0948","UNK_PTR","",0x4), 0x801E0A08:("jtbl_801E0A08","UNK_PTR","",0x4), - 0x801E0BD0:("D_801E0BD0","UNK_TYPE1","",0x1), - 0x801E0BFC:("D_801E0BFC","UNK_TYPE1","",0x1), - 0x801E0C14:("D_801E0C14","char","[]",0x1), - 0x801E0C38:("D_801E0C38","char","[]",0x1), - 0x801E0C64:("D_801E0C64","char","[]",0x1), - 0x801E0C6C:("D_801E0C6C","char","[]",0x1), - 0x801E0C74:("D_801E0C74","char","[]",0x1), - 0x801E0C7C:("D_801E0C7C","char","[]",0x1), - 0x801E0CA4:("D_801E0CA4","char","[]",0x1), - 0x801E0CD0:("D_801E0CD0","char","[]",0x1), + 0x801E0BD0:("gAudioEnvironmentalSfx","UNK_TYPE1","",0x1), + 0x801E0BFC:("sIsOcarinaSongReserved","UNK_TYPE1","",0x1), + 0x801E0C14:("sAudioOcarinaUnusedText0","char","[]",0x1), + 0x801E0C38:("sAudioOcarinaUnusedText1","char","[]",0x1), + 0x801E0C64:("sAudioOcarinaUnusedText2","char","[]",0x1), + 0x801E0C6C:("sAudioOcarinaUnusedText3","char","[]",0x1), + 0x801E0C74:("sAudioOcarinaUnusedText4","char","[]",0x1), + 0x801E0C7C:("sAudioOcarinaUnusedText5","char","[]",0x1), + 0x801E0CA4:("sAudioOcarinaUnusedText6","char","[]",0x1), + 0x801E0CD0:("sAudioOcarinaUnusedText7","char","[]",0x1), 0x801E0CEC:("D_801E0CEC","f32","",0x4), 0x801E0CF0:("D_801E0CF0","f32","",0x4), 0x801E0CF4:("D_801E0CF4","f32","",0x4), @@ -4297,87 +4291,83 @@ 0x801FD158:("D_801FD158","UNK_TYPE1","",0x1), 0x801FD198:("D_801FD198","UNK_TYPE1","",0x1), 0x801FD1E0:("D_801FD1E0","UNK_TYPE1","",0x1), - 0x801FD1F0:("D_801FD1F0","UNK_TYPE1","",0x1), - 0x801FD250:("D_801FD250","UNK_TYPE1","",0x1), - 0x801FD254:("D_801FD254","UNK_TYPE1","",0x1), - 0x801FD258:("D_801FD258","UNK_TYPE1","",0x1), - 0x801FD25C:("D_801FD25C","UNK_TYPE1","",0x1), - 0x801FD260:("D_801FD260","UNK_TYPE1","",0x1), - 0x801FD264:("D_801FD264","UNK_TYPE1","",0x1), - 0x801FD268:("D_801FD268","UNK_TYPE1","",0x1), - 0x801FD278:("D_801FD278","UNK_TYPE1","",0x1), - 0x801FD288:("D_801FD288","UNK_TYPE1","",0x1), - 0x801FD28C:("D_801FD28C","UNK_TYPE1","",0x1), - 0x801FD28D:("D_801FD28D","UNK_TYPE1","",0x1), - 0x801FD28E:("D_801FD28E","UNK_TYPE1","",0x1), - 0x801FD28F:("D_801FD28F","UNK_TYPE1","",0x1), - 0x801FD290:("D_801FD290","UNK_TYPE1","",0x1), - 0x801FD291:("D_801FD291","UNK_TYPE1","",0x1), - 0x801FD294:("D_801FD294","UNK_TYPE1","",0x1), - 0x801FD298:("D_801FD298","UNK_TYPE1","",0x1), - 0x801FD29C:("D_801FD29C","UNK_TYPE1","",0x1), - 0x801FD2A0:("D_801FD2A0","UNK_TYPE1","",0x1), - 0x801FD2A8:("D_801FD2A8","UNK_TYPE1","",0x1), + 0x801FD1F0:("sSfxSettings","UNK_TYPE1","",0x1), + 0x801FD250:("sSfxSettingsFlags","UNK_TYPE1","",0x1), + 0x801FD254:("sTwoSemitonesLoweredFreq","UNK_TYPE1","",0x1), + 0x801FD258:("sSfxIncreasedReverb","UNK_TYPE1","",0x1), + 0x801FD25C:("sSfxSyncedVolume","UNK_TYPE1","",0x1), + 0x801FD260:("sSfxSyncedVolumeForMetalEffects","UNK_TYPE1","",0x1), + 0x801FD264:("sSfxSyncedFreq","UNK_TYPE1","",0x1), + 0x801FD268:("sRiverFreqScaleLerp","UNK_TYPE1","",0x1), + 0x801FD278:("sWaterfallFreqScaleLerp","UNK_TYPE1","",0x1), + 0x801FD288:("sSfxAdjustedFreq","UNK_TYPE1","",0x1), + 0x801FD28C:("sSfxCustomReverb","UNK_TYPE1","",0x1), + 0x801FD28D:("sRiverSoundMainBgmVol","UNK_TYPE1","",0x1), + 0x801FD28E:("sRiverSoundMainBgmCurrentVol","UNK_TYPE1","",0x1), + 0x801FD28F:("sRiverSoundMainBgmLower","UNK_TYPE1","",0x1), + 0x801FD290:("sRiverSoundMainBgmRestore","UNK_TYPE1","",0x1), + 0x801FD291:("sGanonsTowerVol","UNK_TYPE1","",0x1), + 0x801FD294:("sSfxVolumeCur","UNK_TYPE1","",0x1), + 0x801FD298:("sSfxVolumeTarget","UNK_TYPE1","",0x1), + 0x801FD29C:("sSfxVolumeRate","UNK_TYPE1","",0x1), + 0x801FD2A0:("sSceneSeqId1","UNK_TYPE1","",0x1), + 0x801FD2A8:("sSfxChannelState","UNK_TYPE1","",0x1), 0x801FD3A8:("D_801FD3A8","UNK_TYPE1","",0x1), 0x801FD3A9:("D_801FD3A9","UNK_TYPE1","",0x1), - 0x801FD3AA:("D_801FD3AA","UNK_TYPE1","",0x1), - 0x801FD3AB:("D_801FD3AB","UNK_TYPE1","",0x1), - 0x801FD3AC:("D_801FD3AC","UNK_TYPE1","",0x1), - 0x801FD3AE:("D_801FD3AE","UNK_TYPE1","",0x1), - 0x801FD3AF:("D_801FD3AF","UNK_TYPE1","",0x1), - 0x801FD3B0:("D_801FD3B0","UNK_TYPE1","",0x1), - 0x801FD3B4:("D_801FD3B4","UNK_TYPE1","",0x1), - 0x801FD3B7:("D_801FD3B7","UNK_TYPE1","",0x1), - 0x801FD3B8:("D_801FD3B8","UNK_TYPE1","",0x1), - 0x801FD3D8:("D_801FD3D8","UNK_TYPE1","",0x1), - 0x801FD3D9:("D_801FD3D9","UNK_TYPE1","",0x1), - 0x801FD3DA:("D_801FD3DA","UNK_TYPE1","",0x1), - 0x801FD3E0:("D_801FD3E0","UNK_TYPE1","",0x1), - 0x801FD3EC:("D_801FD3EC","UNK_TYPE1","",0x1), - 0x801FD3F0:("D_801FD3F0","UNK_TYPE1","",0x1), - 0x801FD3FC:("D_801FD3FC","UNK_TYPE1","",0x1), - 0x801FD400:("D_801FD400","UNK_TYPE1","",0x1), - 0x801FD404:("D_801FD404","UNK_TYPE1","",0x1), - 0x801FD408:("D_801FD408","UNK_TYPE1","",0x1), - 0x801FD40C:("D_801FD40C","UNK_TYPE1","",0x1), - 0x801FD410:("D_801FD410","UNK_TYPE1","",0x1), - 0x801FD420:("D_801FD420","UNK_TYPE1","",0x1), - 0x801FD42C:("D_801FD42C","UNK_TYPE1","",0x1), - 0x801FD430:("D_801FD430","UNK_TYPE1","",0x1), - 0x801FD431:("D_801FD431","UNK_TYPE1","",0x1), + 0x801FD3AA:("sRiverSoundBgmTimer","UNK_TYPE1","",0x1), + 0x801FD3AB:("sFanfareState","UNK_TYPE1","",0x1), + 0x801FD3AC:("sFanfareSeqId","UNK_TYPE1","",0x1), + 0x801FD3AE:("sMuteOnlySfxAndNatureSeq","UNK_TYPE1","",0x1), + 0x801FD3AF:("sAllPlayersMutedExceptOcaAndSys","UNK_TYPE1","",0x1), + 0x801FD3B0:("sAudioPauseState","UNK_TYPE1","",0x1), + 0x801FD3B4:("sSpatialSeqIsActive","u8","[4]",0x4), + 0x801FD3B8:("sSequenceFilter","UNK_TYPE1","",0x1), + 0x801FD3D8:("sIsFinalHoursOrSoaring","UNK_TYPE1","",0x1), + 0x801FD3D9:("sObjSoundFanfareSeqId","UNK_TYPE1","",0x1), + 0x801FD3DA:("sObjSoundFanfareRequested","UNK_TYPE1","",0x1), + 0x801FD3E0:("sObjSoundFanfarePos","UNK_TYPE1","",0x1), + 0x801FD3EC:("sObjSoundPlayerIdx","UNK_TYPE1","",0x1), + 0x801FD3F0:("sObjSoundPos","UNK_TYPE1","",0x1), + 0x801FD3FC:("sObjSoundFlags","UNK_TYPE1","",0x1), + 0x801FD400:("sObjSoundMinDist","UNK_TYPE1","",0x1), + 0x801FD404:("sObjSoundMaxDist","UNK_TYPE1","",0x1), + 0x801FD408:("sObjSoundMaxVol","UNK_TYPE1","",0x1), + 0x801FD40C:("sObjSoundMinVol","UNK_TYPE1","",0x1), + 0x801FD410:("sSpatialSeqNoFilterPos","UNK_TYPE1","",0x1), + 0x801FD420:("sSpatialSeqFilterPos","UNK_TYPE1","",0x1), + 0x801FD42C:("sSpatialSeqMaxDist","UNK_TYPE1","",0x1), + 0x801FD430:("sSpatialSeqSeqId","UNK_TYPE1","",0x1), + 0x801FD431:("sSpatialSeqFlags","UNK_TYPE1","",0x1), 0x801FD432:("D_801FD432","UNK_TYPE1","",0x1), - 0x801FD433:("D_801FD433","UNK_TYPE1","",0x1), + 0x801FD433:("sSpatialSubBgmFadeTimer","UNK_TYPE1","",0x1), 0x801FD434:("D_801FD434","UNK_TYPE1","",0x1), - 0x801FD435:("D_801FD435","UNK_TYPE1","",0x1), - 0x801FD436:("D_801FD436","UNK_TYPE1","",0x1), + 0x801FD435:("sSpatialSeqPlayerIdx","UNK_TYPE1","",0x1), + 0x801FD436:("sSpatialSeqFadeTimer","UNK_TYPE1","",0x1), 0x801FD438:("D_801FD438","UNK_TYPE1","",0x1), - 0x801FD43A:("D_801FD43A","UNK_TYPE1","",0x1), - 0x801FD43B:("D_801FD43B","UNK_TYPE1","",0x1), - 0x801FD43E:("D_801FD43E","UNK_TYPE1","",0x1), - 0x801FD442:("D_801FD442","UNK_TYPE1","",0x1), - 0x801FD448:("D_801FD448","UNK_TYPE1","",0x1), - 0x801FD44C:("D_801FD44C","UNK_TYPE1","",0x1), - 0x801FD44D:("D_801FD44D","UNK_TYPE1","",0x1), - 0x801FD450:("D_801FD450","UNK_TYPE1","",0x1), - 0x801FD454:("D_801FD454","UNK_TYPE1","",0x1), - 0x801FD458:("D_801FD458","UNK_TYPE1","",0x1), - 0x801FD45C:("D_801FD45C","UNK_TYPE1","",0x1), - 0x801FD460:("D_801FD460","UNK_TYPE1","",0x1), - 0x801FD461:("D_801FD461","UNK_TYPE1","",0x1), - 0x801FD462:("D_801FD462","UNK_TYPE1","",0x1), - 0x801FD463:("D_801FD463","UNK_TYPE1","",0x1), - 0x801FD464:("D_801FD464","UNK_TYPE1","",0x1), - 0x801FD468:("D_801FD468","UNK_TYPE1","",0x1), - 0x801FD46C:("D_801FD46C","UNK_TYPE1","",0x1), - 0x801FD470:("D_801FD470","UNK_TYPE1","",0x1), - 0x801FD4A0:("D_801FD4A0","UNK_TYPE1","",0x1), - 0x801FD4D0:("D_801FD4D0","UNK_TYPE1","",0x1), - 0x801FD500:("D_801FD500","UNK_TYPE1","",0x1), + 0x801FD43A:("sPlayingStaff","OcarinaStaff","",0x3), + 0x801FD43E:("sPlaybackStaff","OcarinaStaff","",0x3), + 0x801FD442:("sRecordingStaff","OcarinaStaff","",0x3), + 0x801FD448:("sOcarinaUpdateTaskCurrent","UNK_TYPE1","",0x1), + 0x801FD44C:("sOcarinaInputStickRel","OcarinaControlStick","",0x2), + 0x801FD450:("sOcarinaInputButtonCur","UNK_TYPE1","",0x1), + 0x801FD454:("sOcarinaInputButtonStart","UNK_TYPE1","",0x1), + 0x801FD458:("sOcarinaInputButtonPrev","UNK_TYPE1","",0x1), + 0x801FD45C:("sOcaInputBtnPress","UNK_TYPE1","",0x1), + 0x801FD460:("sOcarinaResetDelay","UNK_TYPE1","",0x1), + 0x801FD461:("sOcarinaResetUnused","UNK_TYPE1","",0x1), + 0x801FD462:("sOcarinaHasStartedSong","UNK_TYPE1","",0x1), + 0x801FD463:("sFirstOcarinaSongIdx","UNK_TYPE1","",0x1), + 0x801FD464:("sLastOcarinaSongIdx","UNK_TYPE1","",0x1), + 0x801FD468:("sOcarinaAvailSongs","UNK_TYPE1","",0x1), + 0x801FD46C:("sOcarinaStaffPlayingPos","UNK_TYPE1","",0x1), + 0x801FD470:("sMusicStaffPos","UNK_TYPE1","",0x1), + 0x801FD4A0:("sMusicStaffCurHeldLength","UNK_TYPE1","",0x1), + 0x801FD4D0:("sMusicStaffExpectedLength","UNK_TYPE1","",0x1), + 0x801FD500:("sMusicStaffExpectedPitch","UNK_TYPE1","",0x1), 0x801FD518:("D_801FD518","UNK_TYPE1","",0x1), - 0x801FD530:("D_801FD530","UNK_TYPE1","",0x1), - 0x801FD533:("D_801FD533","UNK_TYPE1","",0x1), - 0x801FD590:("D_801FD590","UNK_TYPE1","",0x1), - 0x801FD598:("D_801FD598","UNK_TYPE1","",0x1), + 0x801FD530:("D_801FD530","u32","[24]",0x60), + 0x801FD590:("sRecordingSongNote","UNK_TYPE1","",0x1), + 0x801FD598:("sCustomSequencePc","UNK_TYPE1","",0x1), 0x801FD5A0:("D_801FD5A0","UNK_TYPE1","",0x1), 0x801FD5A4:("D_801FD5A4","UNK_TYPE1","",0x1), 0x801FD5B8:("D_801FD5B8","UNK_TYPE1","",0x1), From 6e62ae4075a5f5b76ccd3265204682f3474a5735 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 13 Feb 2022 18:10:56 -0800 Subject: [PATCH 017/257] SubS Animations and LimbRotTables (#624) * Bring over the matching code, rename struct vars to be consistent, and move animation structs to z64animation.h * Clean up function prototypes * Format and some stack var renames * Update tutorial * Rename animation structs * Rename SubS functions * Rename Actor function * Rename arg names * Bring over code for func_8013D9C8 * Rename and cleanup * Some more cleanup * Small cleanup * Animmode enum * Adjust actorfixer * More uses of animmode enum, as well as fixing typo * Change hex 0xD to 13 * typo * Fix merge * Format * Fix merge * Actorfixer * Format --- docs/tutorial/beginning_decomp.md | 2 +- include/functions.h | 60 ++++----- include/z64actor.h | 18 --- include/z64animation.h | 28 ++++- src/code/z_actor.c | 2 +- src/code/z_en_hy.c | 10 +- src/code/z_skelanime.c | 20 +-- src/code/z_sub_s.c | 62 +++++++++- .../actors/ovl_Dm_Char05/z_dm_char05.c | 16 +-- src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c | 6 +- src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c | 6 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 113 +++++++++++------ .../ovl_En_Akindonuts/z_en_akindonuts.c | 73 ++++++----- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 37 +++--- .../actors/ovl_En_Baisen/z_en_baisen.c | 2 +- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 20 +-- .../actors/ovl_En_Cne_01/z_en_cne_01.c | 3 +- src/overlays/actors/ovl_En_Dai/z_en_dai.c | 20 +-- src/overlays/actors/ovl_En_Dg/z_en_dg.c | 40 +++--- src/overlays/actors/ovl_En_Dnk/z_en_dnk.c | 64 ++++++---- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 98 +++++++-------- src/overlays/actors/ovl_En_Dnp/z_en_dnp.c | 43 ++++--- src/overlays/actors/ovl_En_Dnq/z_en_dnq.c | 34 +++-- src/overlays/actors/ovl_En_Dns/z_en_dns.c | 21 ++-- src/overlays/actors/ovl_En_Fg/z_en_fg.c | 18 +-- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 42 ++++--- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 27 ++-- src/overlays/actors/ovl_En_Geg/z_en_geg.c | 42 ++++--- src/overlays/actors/ovl_En_Geg/z_en_geg.h | 6 +- .../actors/ovl_En_Ginko_Man/z_en_ginko_man.c | 58 ++++----- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 35 +++--- src/overlays/actors/ovl_En_Go/z_en_go.c | 45 ++++--- src/overlays/actors/ovl_En_Hg/z_en_hg.c | 40 +++--- src/overlays/actors/ovl_En_Hgo/z_en_hgo.c | 34 ++--- .../actors/ovl_En_Hint_Skb/z_en_hint_skb.c | 50 ++++---- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 19 +-- src/overlays/actors/ovl_En_In/z_en_in.c | 39 +++--- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 77 +++++++----- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 6 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 48 +++---- .../actors/ovl_En_Ma_Yto/z_en_ma_yto.c | 32 ++--- .../actors/ovl_En_Ma_Yts/z_en_ma_yts.c | 52 ++++---- src/overlays/actors/ovl_En_Muto/z_en_muto.c | 2 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 78 +++++++----- src/overlays/actors/ovl_En_Ot/z_en_ot.c | 38 +++--- src/overlays/actors/ovl_En_Owl/z_en_owl.c | 7 +- .../actors/ovl_En_Pamera/z_en_pamera.c | 64 +++++----- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 25 ++-- .../actors/ovl_En_Rail_Skb/z_en_rail_skb.c | 56 +++++---- .../actors/ovl_En_Railgibud/z_en_railgibud.c | 70 ++++++----- src/overlays/actors/ovl_En_Rg/z_en_rg.c | 10 +- src/overlays/actors/ovl_En_Rsn/z_en_rsn.c | 4 +- .../actors/ovl_En_Scopenuts/z_en_scopenuts.c | 69 ++++++----- .../actors/ovl_En_Sellnuts/z_en_sellnuts.c | 117 ++++++++++-------- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 62 +++++----- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 16 +-- src/overlays/actors/ovl_En_St/z_en_st.c | 32 ++--- .../actors/ovl_En_Suttari/z_en_suttari.c | 56 +++++---- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 14 +-- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 12 +- .../ovl_En_Talk_Gibud/z_en_talk_gibud.c | 49 ++++---- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 70 +++++------ src/overlays/actors/ovl_En_Trt/z_en_trt.c | 25 ++-- src/overlays/actors/ovl_En_Trt2/z_en_trt2.c | 25 ++-- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 28 +++-- src/overlays/actors/ovl_En_Zo/z_en_zo.c | 23 ++-- tools/actorfixer.py | 12 +- tools/disasm/functions.txt | 8 +- tools/sizes/code_functions.csv | 8 +- 69 files changed, 1390 insertions(+), 1058 deletions(-) diff --git a/docs/tutorial/beginning_decomp.md b/docs/tutorial/beginning_decomp.md index 01cc21cf3..b46bd219a 100644 --- a/docs/tutorial/beginning_decomp.md +++ b/docs/tutorial/beginning_decomp.md @@ -397,7 +397,7 @@ An actor with SkelAnime has three structs in the Actor struct that handle it: on There are two different sorts of SkelAnime, although for decompilation purposes there is not much difference between them. Looking at the prototype of `SkelAnime_InitFlex` from `functions.h` (or even the definition in `z_skelanime.c`), ```C void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, - AnimationHeader* animationSeg, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); + AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); ``` we can read off the types of the various arguments: - The `SkelAnime` struct is at `this + 0x144` diff --git a/include/functions.h b/include/functions.h index 69abef304..5b7da53e4 100644 --- a/include/functions.h +++ b/include/functions.h @@ -782,7 +782,7 @@ s32 func_800BD2B4(GlobalContext* globalCtx, Actor* actor, s16* arg2, f32 arg3, u void func_800BD888(Actor* actor, struct_800BD888_arg1* arg1, s16 arg2, s16 arg3); void func_800BD9E0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s16 alpha); void func_800BDAA0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s16 alpha); -void Actor_ChangeAnimation(SkelAnime* skelAnime, ActorAnimationEntry* animation, s32 index); +void Actor_ChangeAnimationByInfo(SkelAnime* skelAnime, AnimationInfo* animation, s32 index); void Actor_Noop(Actor* actor, GlobalContext* globalCtx); void Gfx_DrawDListOpa(GlobalContext* globalCtx, Gfx* dlist); @@ -2363,7 +2363,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, TransformLimbDrawOpa transformLimbDraw, Actor* actor, Mtx** mtx); void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, TransformLimbDrawOpa transformLimbDraw, Actor* actor); -void SkelAnime_GetFrameData(AnimationHeader* animationSeg, s32 currentFrame, s32 limbCount, Vec3s* dst); +void SkelAnime_GetFrameData(AnimationHeader* animation, s32 currentFrame, s32 limbCount, Vec3s* dst); s16 Animation_GetLength(void* animation); s16 Animation_GetLastFrame(void* animation); Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); @@ -2381,7 +2381,7 @@ void AnimationContext_DisableQueue(GlobalContext* globalCtx); AnimationEntry* AnimationContext_AddEntry(AnimationContext* animationCtx, AnimationType type); void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader* animation, s32 frame, s32 limbCount, Vec3s* frameTable); void AnimationContext_SetCopyAll(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src); -void AnimationContext_SetInterp(GlobalContext* globalCtx, s32 limbCount, Vec3s* arg2, Vec3s* arg3, f32 arg4); +void AnimationContext_SetInterp(GlobalContext* globalCtx, s32 vecCount, Vec3s* base, Vec3s* mod, f32 weight); void AnimationContext_SetCopyTrue(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index); void AnimationContext_SetCopyFalse(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index); void AnimationContext_SetMoveActor(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 arg3); @@ -2399,25 +2399,25 @@ s32 LinkAnimation_Morph(GlobalContext* globalCtx, SkelAnime* skelAnime); void LinkAnimation_AnimateFrame(GlobalContext* globalCtx, SkelAnime* skelAnime); s32 LinkAnimation_Loop(GlobalContext* globalCtx, SkelAnime* skelAnime); s32 LinkAnimation_Once(GlobalContext* globalCtx, SkelAnime* skelAnime); -void Animation_SetMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 transitionRate); -void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 playbackSpeed, f32 frame, f32 frameCount, u8 animationMode, f32 transitionRate); -void LinkAnimation_PlayOnce(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg); -void LinkAnimation_PlayOnceSetSpeed(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 playbackSpeed); -void LinkAnimation_PlayLoop(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg); -void LinkAnimation_PlayLoopSetSpeed(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 playbackSpeed); +void Animation_SetMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 morphFrames); +void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed, f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames); +void LinkAnimation_PlayOnce(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation); +void LinkAnimation_PlayOnceSetSpeed(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed); +void LinkAnimation_PlayLoop(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation); +void LinkAnimation_PlayLoopSetSpeed(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed); void LinkAnimation_CopyJointToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime); void LinkAnimation_CopyMorphToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime); -void LinkAnimation_LoadToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 frame); -void LinkAnimation_LoadToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 frame); +void LinkAnimation_LoadToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 frame); +void LinkAnimation_LoadToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 frame); void LinkAnimation_InterpJointMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 frame); -void LinkAnimation_BlendToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 transitionFrame, LinkAnimationHeader* linkAnimetionEntrySeg2, f32 frame, f32 transitionRate, Vec3s* jointTable); -void LinkAnimation_BlendToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 transitionFrame, LinkAnimationHeader* linkAnimetionEntrySeg2, f32 frame, f32 transitionRate, Vec3s* jointTable); +void LinkAnimation_BlendToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, Vec3s* blendTable); +void LinkAnimation_BlendToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, Vec3s* blendTable); void LinkAnimation_EndLoop(SkelAnime* skelAnime); -s32 Animation_OnFrameImpl(SkelAnime* skelAnime, f32 arg1, f32 updateRate); -s32 LinkAnimation_OnFrame(SkelAnime* skelAnime, f32 arg1); -void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); +s32 Animation_OnFrameImpl(SkelAnime* skelAnime, f32 frame, f32 updateRate); +s32 LinkAnimation_OnFrame(SkelAnime* skelAnime, f32 frame); +void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); -void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg); +void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation); void SkelAnime_SetUpdate(SkelAnime* skelAnime); s32 SkelAnime_Update(SkelAnime* skelAnime); s32 SkelAnime_Morph(SkelAnime* skelAnime); @@ -2426,20 +2426,20 @@ void SkelAnime_AnimateFrame(SkelAnime* skelAnime); s32 SkelAnime_LoopFull(SkelAnime* skelAnime); s32 SkelAnime_LoopPartial(SkelAnime* skelAnime); s32 SkelAnime_Once(SkelAnime* skelAnime); -void Animation_ChangeImpl(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed, f32 frame, f32 frameCount, u8 animationType, f32 transitionRate, s8 unk2); -void Animation_Change(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed, f32 frame, f32 frameCount, u8 mode, f32 transitionRate); -void Animation_PlayOnce(SkelAnime* skelAnime, AnimationHeader* animationSeg); -void Animation_MorphToPlayOnce(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate); -void Animation_PlayOnceSetSpeed(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed); -void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animationSeg); -void Animation_MorphToLoop(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate); -void Animation_PlayLoopSetSpeed(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed); +void Animation_ChangeImpl(SkelAnime* skelAnime, AnimationHeader* animation, f32 playSpeed, f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames, s8 taper); +void Animation_Change(SkelAnime* skelAnime, AnimationHeader* animation, f32 playSpeed, f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames); +void Animation_PlayOnce(SkelAnime* skelAnime, AnimationHeader* animation); +void Animation_MorphToPlayOnce(SkelAnime* skelAnime, AnimationHeader* animation, f32 morphFrames); +void Animation_PlayOnceSetSpeed(SkelAnime* skelAnime, AnimationHeader* animation, f32 playSpeed); +void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animation); +void Animation_MorphToLoop(SkelAnime* skelAnime, AnimationHeader* animation, f32 morphFrames); +void Animation_PlayLoopSetSpeed(SkelAnime* skelAnime, AnimationHeader* animation, f32 playSpeed); void Animation_EndLoop(SkelAnime* skelAnime); void Animation_Reverse(SkelAnime* skelAnime); void SkelAnime_CopyFrameTableTrue(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* index); -void SkelAnime_CopyFrameTableFalse(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* arg3); +void SkelAnime_CopyFrameTableFalse(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* copyFlag); void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle); -s32 Animation_OnFrame(SkelAnime* skelAnime, f32 arg1); +s32 Animation_OnFrame(SkelAnime* skelAnime, f32 frame); void SkelAnime_Free(SkelAnime* skelAnime, GlobalContext* globalCtx); void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); // void func_80137970(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); @@ -2503,7 +2503,7 @@ s32 func_8013B6B0(Path* path, f32* arg1, s32* arg2, s32 arg3, s32 arg4, s32* arg void func_8013B878(GlobalContext* globalCtx, Path* path, s32 arg2, Vec3f* arg3); Path* func_8013BB34(GlobalContext* globalCtx, u8 arg1, s32 arg2); Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId); -s32 func_8013BC6C(SkelAnime* skelAnime, ActorAnimationEntryS* arg1, s32 arg2); +s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index); s32 func_8013BD40(Actor* actor, Path* path, s32 arg2); Path* func_8013BEDC(GlobalContext* globalCtx, u8 arg1, u8 arg2, s32* arg3); s32 func_8013C068(Path* path, s32 arg1, Vec3f* arg2, f32 arg3, s32 arg4); @@ -2524,7 +2524,7 @@ s16 func_8013D83C(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); s8 func_8013D8DC(s8 arg0, GlobalContext* globalCtx); s8 func_8013D924(s16 arg0, GlobalContext* globalCtx); Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); -s32 func_8013D9C8(GlobalContext* globalCtx, s16* arg1, s16* arg2, s32 arg3); +s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 limbRotTableLen); s32 func_8013DB90(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2); s32 func_8013DC40(Path* arg0, s32 arg1, s32 arg2, Vec3f* arg3); void func_8013DCE0(GlobalContext* globalCtx, Vec3f* arg1, Actor* arg2, struct_8013DF3C_arg1* arg3, Path* arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, u8 arg9); @@ -2533,7 +2533,7 @@ void func_8013DF3C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); s32 func_8013E054(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); s32 func_8013E07C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); s32 func_8013E0A4(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); -void func_8013E1C8(SkelAnime* skelAnime, struct_80B8E1A8 animations[], s32 animationIndex, s32* actorAnimationIndex); +void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, s32* curIndex); s32 func_8013E2D4(Actor* actor, s16 arg1, s16 arg2, s32 arg3); s32 func_8013E3B8(Actor* actor, s16 cutscenes[], s16 len); void func_8013E4B0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Plane* plane); diff --git a/include/z64actor.h b/include/z64actor.h index 8c6992f49..9c0aa7e7d 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -297,24 +297,6 @@ typedef enum { /* 0x0C */ ACTORCAT_MAX } ActorType; -typedef struct { - /* 0x00 */ AnimationHeader* animation; - /* 0x04 */ f32 playSpeed; - /* 0x08 */ f32 startFrame; - /* 0x0C */ f32 frameCount; - /* 0x10 */ u8 mode; - /* 0x14 */ f32 morphFrames; -} ActorAnimationEntry; // size = 0x18 - -typedef struct { - /* 0x00 */ AnimationHeader* animationSeg; - /* 0x04 */ f32 playbackSpeed; - /* 0x08 */ s16 frame; - /* 0x0A */ s16 frameCount; - /* 0x0C */ u8 mode; - /* 0x0E */ s16 transitionRate; -} ActorAnimationEntryS; // size = 0x10 - typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ f32 unkC; diff --git a/include/z64animation.h b/include/z64animation.h index 2aa97e2ec..10b145d38 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -316,11 +316,29 @@ typedef struct { /* 0x008 */ Gfx* unk_8; } Struct_800A5E28; // size = 0xC -typedef struct struct_80B8E1A8 { - /* 0x00 */ AnimationHeader* animationSeg; - /* 0x04 */ f32 playbackSpeed; +typedef struct { + /* 0x00 */ AnimationHeader* animation; + /* 0x04 */ f32 playSpeed; + /* 0x08 */ f32 startFrame; + /* 0x0C */ f32 frameCount; + /* 0x10 */ u8 mode; + /* 0x14 */ f32 morphFrames; +} AnimationInfo; // size = 0x18 + +typedef struct { + /* 0x00 */ AnimationHeader* animation; + /* 0x04 */ f32 playSpeed; + /* 0x08 */ s16 startFrame; + /* 0x0A */ s16 frameCount; + /* 0x0C */ u8 mode; + /* 0x0E */ s16 morphFrames; +} AnimationInfoS; // size = 0x10 + +typedef struct AnimationSpeedInfo { + /* 0x00 */ AnimationHeader* animation; + /* 0x04 */ f32 playSpeed; /* 0x08 */ u8 mode; - /* 0x0C */ f32 transitionRate; -} struct_80B8E1A8; // size = 0x10 + /* 0x0C */ f32 morphFrames; +} AnimationSpeedInfo; // size = 0x10 #endif diff --git a/src/code/z_actor.c b/src/code/z_actor.c index d4f1def2f..2eac6470a 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -4252,7 +4252,7 @@ s16 func_800BDB6C(Actor* actor, GlobalContext* globalCtx, s16 arg2, f32 arg3) { return arg2; } -void Actor_ChangeAnimation(SkelAnime* skelAnime, ActorAnimationEntry* animation, s32 index) { +void Actor_ChangeAnimationByInfo(SkelAnime* skelAnime, AnimationInfo* animation, s32 index) { f32 frameCount; animation += index; diff --git a/src/code/z_en_hy.c b/src/code/z_en_hy.c index 4fac2c2ae..b99b77dae 100644 --- a/src/code/z_en_hy.c +++ b/src/code/z_en_hy.c @@ -11,7 +11,7 @@ #include "objects/object_boj/object_boj.h" #include "objects/object_os_anime/object_os_anime.h" -ActorAnimationEntryS sAnimations[] = { +static AnimationInfoS sAnimations[] = { { &object_aob_Anim_00007C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_boj_Anim_001494, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_boj_Anim_001494, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, @@ -49,11 +49,11 @@ s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { isChanged = true; frameCount = sAnimations[animIndex].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(&sAnimations[animIndex].animationSeg->common); + frameCount = Animation_GetLastFrame(&sAnimations[animIndex].animation->common); } - Animation_Change(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed, - sAnimations[animIndex].frame, frameCount, sAnimations[animIndex].mode, - sAnimations[animIndex].transitionRate); + Animation_Change(skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].playSpeed, + sAnimations[animIndex].startFrame, frameCount, sAnimations[animIndex].mode, + sAnimations[animIndex].morphFrames); } return isChanged; } diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 8ebb2ca67..9fc5467e0 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -8,10 +8,10 @@ s32 LinkAnimation_Once(GlobalContext* globalCtx, SkelAnime* skelAnime); s32 SkelAnime_LoopFull(SkelAnime* skelAnime); s32 SkelAnime_LoopPartial(SkelAnime* skelAnime); s32 SkelAnime_Once(SkelAnime* skelAnime); -void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animationSeg); +void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animation); void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle); -void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, - f32 playbackSpeed, f32 frame, f32 frameCount, u8 animationMode, f32 transitionRate); +void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed, + f32 frame, f32 frameCount, u8 animationMode, f32 morphFrames); void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); static AnimationEntryCallback sAnimationLoadDone[] = { @@ -1074,13 +1074,13 @@ void AnimationContext_SetCopyFalse(GlobalContext* globalCtx, s32 vecCount, Vec3s /** * Requests moving an actor according to the translation of its root limb */ -void AnimationContext_SetMoveActor(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 actor3) { +void AnimationContext_SetMoveActor(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 arg3) { AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_MOVEACTOR); if (entry != NULL) { entry->data.move.actor = actor; entry->data.move.skelAnime = skelAnime; - entry->data.move.unk08 = actor3; + entry->data.move.unk08 = arg3; } } @@ -1829,8 +1829,8 @@ void Animation_PlayOnce(SkelAnime* skelAnime, AnimationHeader* animation) { * animation. Negative morph frames start the new animation immediately, modified by the pose immediately before the * animation change. */ -void Animation_MorphToPlayOnce(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 morphFrames) { - Animation_Change(skelAnime, animationSeg, 1.0f, 0, Animation_GetLastFrame(&animationSeg->common), ANIMMODE_ONCE, +void Animation_MorphToPlayOnce(SkelAnime* skelAnime, AnimationHeader* animation, f32 morphFrames) { + Animation_Change(skelAnime, animation, 1.0f, 0, Animation_GetLastFrame(&animation->common), ANIMMODE_ONCE, morphFrames); } @@ -1862,9 +1862,9 @@ void Animation_MorphToLoop(SkelAnime* skelAnime, AnimationHeader* animation, f32 /** * Immediately changes to an animation that loops at the specified speed. */ -void Animation_PlayLoopSetSpeed(SkelAnime* skelAnime, AnimationHeader* animation, f32 playbackSpeed) { - Animation_Change(skelAnime, animation, playbackSpeed, 0.0f, Animation_GetLastFrame(&animation->common), - ANIMMODE_LOOP, 0.0f); +void Animation_PlayLoopSetSpeed(SkelAnime* skelAnime, AnimationHeader* animation, f32 playSpeed) { + Animation_Change(skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(&animation->common), ANIMMODE_LOOP, + 0.0f); } /** diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 764b3525f..2ce355d47 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -205,7 +205,26 @@ Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCat return closestActor; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BC6C.s") +s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index) { + s32 endFrame; + s32 startFrame; + + animations += index; + endFrame = animations->frameCount; + if (animations->frameCount < 0) { + endFrame = Animation_GetLastFrame(&animations->animation->common); + } + startFrame = animations->startFrame; + if (startFrame >= endFrame || startFrame < 0) { + return false; + } + if (animations->playSpeed < 0.0f) { + SWAP(s32, endFrame, startFrame); + } + Animation_Change(skelAnime, animations->animation, animations->playSpeed, startFrame, endFrame, animations->mode, + animations->morphFrames); + return true; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BD40.s") @@ -262,7 +281,17 @@ Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorC return actor; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D9C8.s") +s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 limbRotTableLen) { + s32 i; + u32 frames = globalCtx->gameplayFrames; + + for (i = 0; i < limbRotTableLen; i++) { + limbRotTableY[i] = (i * 50 + 0x814) * frames; + limbRotTableZ[i] = (i * 50 + 0x940) * frames; + } + + return true; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DB90.s") @@ -282,7 +311,34 @@ Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorC #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E0A4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E1C8.s") +void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, + s32* curIndex) { + AnimationSpeedInfo* animation = &animations[nextIndex]; + f32 startFrame = skelAnime->curFrame; + f32 endFrame; + f32 morphFrames; + + if ((*curIndex < 0) || (nextIndex == *curIndex)) { + morphFrames = 0.0f; + if (*curIndex < 0) { + startFrame = 0.0f; + } + } else { + morphFrames = animation->morphFrames; + if (nextIndex != *curIndex) { + startFrame = 0.0f; + } + } + if (animation->playSpeed >= 0.0f) { + endFrame = Animation_GetLastFrame(&animation->animation->common); + } else { + startFrame = Animation_GetLastFrame(&animation->animation->common); + endFrame = 0.0f; + } + Animation_Change(skelAnime, animation->animation, animation->playSpeed, startFrame, endFrame, animation->mode, + morphFrames); + *curIndex = nextIndex; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E2D4.s") diff --git a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c index b30a63fe2..5258a0f1e 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c @@ -47,16 +47,16 @@ const ActorInit Dm_Char05_InitVars = { (ActorFunc)DmChar05_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_dmask_Anim_001090, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_dmask_Anim_004288, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_dmask_Anim_0001A8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_dmask_Anim_00017C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_dmask_Anim_0011A0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_dmask_Anim_0013A4, 1.0f, 0.0f, -1.0f, 0, 0.0f }, +static AnimationInfo sAnimations[] = { + { &object_dmask_Anim_001090, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dmask_Anim_004288, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dmask_Anim_0001A8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dmask_Anim_00017C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dmask_Anim_0011A0, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dmask_Anim_0013A4, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, }; -void func_80AAC5A0(SkelAnime* skelAnime, ActorAnimationEntry* animation, u16 arg2) { +void func_80AAC5A0(SkelAnime* skelAnime, AnimationInfo* animation, u16 arg2) { f32 phi_f2; animation += arg2; diff --git a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c index 871cc0cf2..e72691395 100644 --- a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c +++ b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c @@ -28,14 +28,14 @@ const ActorInit Dm_Nb_InitVars = { (ActorFunc)DmNb_Draw, }; -static ActorAnimationEntryS D_80C1E200[] = { &object_nb_Anim_000990, 1.0f, 0, -1, 0, 0 }; +static AnimationInfoS D_80C1E200[] = { &object_nb_Anim_000990, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }; s32 func_80C1DED0(DmNb* this, s32 arg1) { - s32 ret = 0; + s32 ret = false; if (arg1 != this->unk1F0) { this->unk1F0 = arg1; - ret = func_8013BC6C(&this->skelAnime, D_80C1E200, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80C1E200, arg1); } return ret; } diff --git a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c index 53e0fec63..7f3d3d63c 100644 --- a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c +++ b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c @@ -30,12 +30,12 @@ const ActorInit Dm_Sa_InitVars = { (ActorFunc)DmSa_Draw, }; -static ActorAnimationEntry D_80A2ED00[] = { { &object_stk_Anim_00CC94, 1.0f, 0, -1.0f, 0, 0 } }; +static AnimationInfo D_80A2ED00[] = { { &object_stk_Anim_00CC94, 1.0f, 0, -1.0f, ANIMMODE_LOOP, 0 } }; -void func_80A2E960(SkelAnime* arg0, ActorAnimationEntry* animations, u16 index) { +void func_80A2E960(SkelAnime* arg0, AnimationInfo* animations, u16 index) { f32 frameCount; - animations += index; + animations += index; if (animations->frameCount < 0.0f) { frameCount = Animation_GetLastFrame(animations->animation); } else { diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index 5f4f6461b..ec46e86d6 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -102,43 +102,79 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -static ActorAnimationEntry sAnimations[] = { - { &object_stk_Anim_01C21C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &object_stk_Anim_01D3D0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk_Anim_001030, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk_Anim_01D008, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk_Anim_01D008, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &object_stk_Anim_015C14, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_0070DC, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &object_stk2_Anim_00D830, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_00055C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_00130C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_00C270, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_00CBB8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_01AA80, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_01D07C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_016910, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_018ED0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_01DDE0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_01EF50, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_02DC64, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_02E9A0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_02DC64, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_02E9A0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_0035C8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_0049C8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_0259F4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_0266C8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_026CF4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_01C114, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_stk2_Anim_004580, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_020CAC, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_02200C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_02336C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk_Anim_002774, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk_Anim_003068, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_0101A4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_010B60, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_02A2D8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_01F9E4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_stk2_Anim_029A04, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &object_stk2_Anim_02AD54, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_stk_Anim_00BB2C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk_Anim_00C964, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_0110B4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_011FB0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_012A58, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_0141E4, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_00E6EC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_00EEC0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_027CF4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_028F28, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_03323C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &object_stk2_Anim_031210, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_0322FC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_032AE0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_03021C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &object_stk2_Anim_036964, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_stk_Anim_016508, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk_Anim_015028, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk_Anim_014920, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_02FA70, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_037B94, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_03967C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_stk2_Anim_03967C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_03A8F8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_034FD8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk3_Anim_005F44, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk3_Anim_002CD8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk3_Anim_0039F0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk3_Anim_004554, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk3_Anim_0051C0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk3_Anim_001374, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk3_Anim_001EDC, 1.0f, 0.0f, -1.0f, 0, 0.0f }, +static AnimationInfo sAnimations[] = { + { &object_stk_Anim_01C21C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk_Anim_01D3D0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk_Anim_001030, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk_Anim_01D008, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk_Anim_01D008, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk_Anim_015C14, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_0070DC, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_00D830, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_00055C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_00130C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_00C270, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_00CBB8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_01AA80, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_01D07C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_016910, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_018ED0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_01DDE0, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_01EF50, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_02DC64, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_02E9A0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_02DC64, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_02E9A0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_0035C8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_0049C8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_0259F4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_0266C8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_026CF4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_01C114, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_004580, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_020CAC, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_02200C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_02336C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk_Anim_002774, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk_Anim_003068, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_0101A4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_010B60, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_02A2D8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_01F9E4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_029A04, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_02AD54, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk_Anim_00BB2C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk_Anim_00C964, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_0110B4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_011FB0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_012A58, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_0141E4, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_00E6EC, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_00EEC0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_027CF4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_028F28, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_03323C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_031210, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_0322FC, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_032AE0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_03021C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_036964, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk_Anim_016508, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk_Anim_015028, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk_Anim_014920, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_02FA70, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_037B94, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_03967C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_03967C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_03A8F8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_034FD8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk3_Anim_005F44, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk3_Anim_002CD8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk3_Anim_0039F0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk3_Anim_004554, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk3_Anim_0051C0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk3_Anim_001374, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk3_Anim_001EDC, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, }; void func_80A9FDB0(DmStk* this, GlobalContext* globalCtx) { @@ -158,8 +194,7 @@ void func_80A9FDB0(DmStk* this, GlobalContext* globalCtx) { } } -void func_80A9FE3C(DmStk* this, GlobalContext* globalCtx, SkelAnime* skelAnime, ActorAnimationEntry* animation, - u16 index) { +void func_80A9FE3C(DmStk* this, GlobalContext* globalCtx, SkelAnime* skelAnime, AnimationInfo* animation, u16 index) { func_80A9FDB0(this, globalCtx); animation += index; diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c index d00c5ead9..ccbfae14f 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -62,19 +62,30 @@ static ColliderCylinderInitType1 sCylinderInit = { { 27, 32, 0, { 0, 0, 0 } }, }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dnt_Anim_005488, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_00B0B4, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_004AA0, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_004E38, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_0029E8, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_005CA8, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_0038CC, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_003CC0, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_0012F4, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_004700, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001BC8, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_003438, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001E2C, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_000994, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_002268, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_002F08, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_00577C, 1.0f, 0, -1, 0, -4 }, { &object_dnt_Anim_0029E8, 1.0f, 8, -1, 2, 0 }, - { &object_dnt_Anim_0029E8, 1.0f, 4, -1, 2, -4 }, { &object_dnt_Anim_0029E8, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001BC8, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_0012F4, -1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_002670, 1.0f, 0, -1, 2, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_dnt_Anim_005488, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_00B0B4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_004AA0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_004E38, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0029E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_005CA8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0038CC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_003CC0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_0012F4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_004700, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001BC8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_003438, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001E2C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_000994, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_002268, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_002F08, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_00577C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnt_Anim_0029E8, 1.0f, 8, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0029E8, 1.0f, 4, -1, ANIMMODE_ONCE, -4 }, + { &object_dnt_Anim_0029E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001BC8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_0012F4, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_002670, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; static u16 D_80BF048C[] = { @@ -1143,7 +1154,7 @@ void func_80BEE938(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { s16 sp26 = this->skelAnime.curFrame; - s16 sp24 = Animation_GetLastFrame(&sAnimations[this->unk_338].animationSeg->common); + s16 sp24 = Animation_GetLastFrame(&sAnimations[this->unk_338].animation->common); s16 phi_v0; Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); @@ -1166,7 +1177,7 @@ void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80BEEDC0; this->unk_338 = 3; this->collider.dim.height = 64; - func_8013BC6C(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); return; } } @@ -1176,19 +1187,19 @@ void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { this->unk_338 = 17; this->collider.dim.height = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); - func_8013BC6C(&this->skelAnime, sAnimations, 17); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 17); } else if (this->unk_338 == 2) { this->unk_338 = 16; this->collider.dim.height = 32; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); - func_8013BC6C(&this->skelAnime, sAnimations, 16); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 16); } else if (this->unk_338 == 17) { phi_v0 = DECR(this->unk_33A); if (phi_v0 == 0) { this->unk_33A = Rand_ZeroOne() * 10.0f; this->unk_338 = 2; this->collider.dim.height = 32; - func_8013BC6C(&this->skelAnime, sAnimations, 2); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 2); } } else if (this->unk_338 == 16) { phi_v0 = DECR(this->unk_33A); @@ -1196,7 +1207,7 @@ void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { this->unk_33A = Rand_S16Offset(40, 40); this->unk_338 = 18; this->collider.dim.height = 32; - func_8013BC6C(&this->skelAnime, sAnimations, 18); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 18); } } } @@ -1205,7 +1216,7 @@ void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BEEDC0(EnAkindonuts* this, GlobalContext* globalCtx) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { this->actionFunc = func_80BEEE10; - func_8013BC6C(&this->skelAnime, sAnimations, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 0); } } @@ -1223,7 +1234,7 @@ void func_80BEEE10(EnAkindonuts* this, GlobalContext* globalCtx) { } else if (!(((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false) || !((this->actor.xzDistToPlayer < 200.0f) ? true : false)) { this->unk_338 = 4; - func_8013BC6C(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); this->actionFunc = func_80BEEB20; } } @@ -1247,7 +1258,7 @@ void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx) { globalCtx->msgCtx.unk12023 = 4; this->unk_338 = 8; this->unk_33C = 0; - func_8013BC6C(&this->skelAnime, sAnimations, this->unk_338); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_338); this->actionFunc = func_80BEF518; } else { this->unk_2DC(this, globalCtx); @@ -1285,18 +1296,18 @@ void func_80BEF18C(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BEF20C(EnAkindonuts* this, GlobalContext* globalCtx) { u8 sp27 = Message_GetState(&globalCtx->msgCtx); s16 sp24 = this->skelAnime.curFrame; - s16 sp22 = Animation_GetLastFrame(&sAnimations[this->unk_338].animationSeg->common); + s16 sp22 = Animation_GetLastFrame(&sAnimations[this->unk_338].animation->common); if (this->unk_356 == 40) { this->unk_338 = 5; - func_8013BC6C(&this->skelAnime, sAnimations, 5); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 5); } this->unk_356++; if ((sp24 == sp22) && (this->unk_338 == 5)) { this->unk_338 = 6; - func_8013BC6C(&this->skelAnime, sAnimations, 6); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 6); } if ((sp27 == 5) && func_80147624(globalCtx)) { @@ -1347,7 +1358,7 @@ void func_80BEF4B8(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BEF518(EnAkindonuts* this, GlobalContext* globalCtx) { s16 sp26 = this->skelAnime.curFrame; - s16 sp24 = Animation_GetLastFrame(&sAnimations[this->unk_338].animationSeg->common); + s16 sp24 = Animation_GetLastFrame(&sAnimations[this->unk_338].animation->common); switch (sp26) { case 10: @@ -1421,7 +1432,7 @@ void func_80BEF518(EnAkindonuts* this, GlobalContext* globalCtx) { if (sp26 == sp24) { this->unk_33E = 3; this->unk_338 = 19; - func_8013BC6C(&this->skelAnime, sAnimations, this->unk_338); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_338); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->unk_32C &= ~2; this->unk_32C |= 0x80; @@ -1454,7 +1465,7 @@ void func_80BEF770(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BEF83C(EnAkindonuts* this, GlobalContext* globalCtx) { Vec3f sp34; s16 sp32 = this->skelAnime.curFrame; - s16 sp30 = Animation_GetLastFrame(&sAnimations[this->unk_338].animationSeg->common); + s16 sp30 = Animation_GetLastFrame(&sAnimations[this->unk_338].animation->common); if (sp32 == sp30) { Math_SmoothStepToS(&this->unk_362, 0x1C71, 3, 0x100, 0); @@ -1480,7 +1491,7 @@ void func_80BEF83C(EnAkindonuts* this, GlobalContext* globalCtx) { if ((this->actor.home.pos.y + 22.5f) < this->actor.world.pos.y) { this->unk_34C = 0.3f; this->unk_338 = 9; - func_8013BC6C(&this->skelAnime, sAnimations, this->unk_338); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_338); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80BEF9F0; } @@ -1499,7 +1510,7 @@ void func_80BEF9F0(EnAkindonuts* this, GlobalContext* globalCtx) { if ((this->actor.home.pos.y + 200.0f) < this->actor.world.pos.y) { Math_ApproachF(&this->actor.velocity.y, 0.0f, 0.2f, 1.0f); this->unk_338 = 10; - func_8013BC6C(&this->skelAnime, sAnimations, this->unk_338); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_338); if (ENAKINDONUTS_GET_3(&this->actor) == ENAKINDONUTS_3_2) { this->unk_32C |= 0x2; } @@ -1602,7 +1613,7 @@ void EnAkindonuts_Init(Actor* thisx, GlobalContext* globalCtx) { } } - func_8013BC6C(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); this->unk_32C |= 0x2; this->unk_32C |= 0x4; this->unk_338 = 4; diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index d9213e75c..38b9c3ece 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -45,10 +45,13 @@ const ActorInit En_Aob_01_InitVars = { (ActorFunc)EnAob01_Draw, }; -static ActorAnimationEntry D_809C3790[6] = { - { &object_aob_Anim_007758, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_aob_Anim_0068B4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_aob_Anim_00700C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_aob_Anim_0058EC, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_aob_Anim_006040, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_aob_Anim_007758, 1.0f, 0.0f, 0.0f, 0, -6.0f }, +static AnimationInfo D_809C3790[6] = { + { &object_aob_Anim_007758, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_aob_Anim_0068B4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_aob_Anim_00700C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_aob_Anim_0058EC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_aob_Anim_006040, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_aob_Anim_007758, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -150,7 +153,7 @@ s32 func_809C1424(EnAob01* this) { if (this->unk_43C == 1) { if (curFrame == lastFrame) { this->unk_43C = 2; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 2); return true; } } else if (this->unk_43C == 2) { @@ -166,13 +169,13 @@ s32 func_809C14D0(EnAob01* this) { if ((this->unk_43C == 0) || (this->unk_43C == 5)) { if (curFrame == lastFrame) { this->unk_43C = 3; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 3); return true; } } else if (this->unk_43C == 3) { if (curFrame == lastFrame) { this->unk_43C = 4; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 4); return true; } } else if (this->unk_43C == 4) { @@ -188,7 +191,7 @@ s32 func_809C15BC(EnAob01* this) { if ((this->unk_43C != 0) && (this->unk_43C != 5)) { if (curFrame == lastFrame) { this->unk_43C = 5; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 5); return true; } } else { @@ -330,7 +333,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x40; this->unk_2D2 |= 0x10; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); break; case 0x3525: @@ -345,7 +348,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x40; this->unk_2D2 |= 0x10; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); break; } @@ -360,7 +363,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 4; this->unk_2D2 |= 0x10; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); break; case 0x3527: @@ -372,7 +375,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_210 = 0x3536; this->unk_2D2 |= 0x40; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); break; } @@ -380,7 +383,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_210 = 0x3537; this->unk_2D2 |= 0x40; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); break; } @@ -483,7 +486,7 @@ void func_809C1EC8(EnAob01* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->unk_2E0.y, 0, 4, 1000, 1); } func_809C10B0(this, 3); - func_8013D9C8(globalCtx, this->unk_2F8, this->unk_318, 0x10); + SubS_FillLimbRotTables(globalCtx, this->unk_2F8, this->unk_318, ARRAY_COUNT(this->unk_2F8)); func_809C165C(this, globalCtx); if (player->stateFlags1 & 0x20) { func_809C1124(); @@ -552,7 +555,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x10; this->unk_2D2 |= 0x40; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); func_801518B0(globalCtx, 0x354B, &this->actor); } this->unk_2D2 &= ~8; @@ -731,7 +734,7 @@ void func_809C28B8(EnAob01* this, GlobalContext* globalCtx) { this->unk_210 = 0x352D; this->unk_2D2 |= 0x40; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); break; } @@ -927,7 +930,7 @@ void EnAob01_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->unk_43C = 0; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 0); Actor_SetScale(&this->actor, 0.01f); switch (gSaveContext.eventInf[0] & 7) { diff --git a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c index b9ae56f28..f052362ac 100644 --- a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c +++ b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c @@ -59,7 +59,7 @@ static u16 sTextIds[] = { 0x2ABD, 0x2ABB, 0x2AD5, 0x2AD6, 0x2AD7, 0x2AD8, 0x2AC6 static AnimationHeader* D_80BE8E4C[] = { &object_bai_Anim_0011C0, &object_bai_Anim_0008B4, &object_bai_Anim_008198 }; -static u8 animModes[] = { 0, 0 }; +static u8 animModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP }; void EnBaisen_Init(Actor* thisx, GlobalContext* globalCtx) { EnBaisen* this = THIS; diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 030a2f9e0..145dc2311 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -64,11 +64,11 @@ static ColliderCylinderInit sCylinderInit = { }; /* Animations struct */ -static struct_80B8E1A8 D_809CDC7C[] = { - { &object_bji_Anim_000FDC, 1.0f, 0, 0.0f }, /* Looking through telescope */ - { &object_bji_Anim_005B58, 1.0f, 0, 10.0f }, /* Breathing? Unused? */ - { &object_bji_Anim_000AB0, 1.0f, 0, 0.0f }, /* Talking */ - { &object_bji_Anim_00066C, 1.0f, 2, -5.0f }, /* Scratching chin? */ +static AnimationSpeedInfo D_809CDC7C[] = { + { &object_bji_Anim_000FDC, 1.0f, ANIMMODE_LOOP, 0.0f }, /* Looking through telescope */ + { &object_bji_Anim_005B58, 1.0f, ANIMMODE_LOOP, 10.0f }, /* Breathing? Unused? */ + { &object_bji_Anim_000AB0, 1.0f, ANIMMODE_LOOP, 0.0f }, /* Talking */ + { &object_bji_Anim_00066C, 1.0f, ANIMMODE_ONCE, -5.0f }, /* Scratching chin? */ }; void func_809CCDE0(EnBji01* this, GlobalContext* globalCtx) { @@ -84,7 +84,7 @@ void func_809CCDE0(EnBji01* this, GlobalContext* globalCtx) { } void func_809CCE98(EnBji01* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, D_809CDC7C, 0, &this->animationIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 0, &this->animationIndex); this->actor.textId = 0; this->actionFunc = func_809CCEE8; } @@ -193,7 +193,7 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { } break; } - func_8013E1C8(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); this->actionFunc = EnBji01_DialogueHandler; } @@ -239,7 +239,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { this->actor.flags &= ~0x10000; switch (globalCtx->msgCtx.unk11F04) { case 0x5DE: - func_8013E1C8(&this->skelAnime, D_809CDC7C, 3, &this->animationIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 3, &this->animationIndex); func_80151938(globalCtx, 0x5DF); break; case 0x5E4: @@ -290,7 +290,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { break; } if ((this->animationIndex == 3) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); } } @@ -308,7 +308,7 @@ void EnBji01_DoNothing(EnBji01* this, GlobalContext* globalCtx) { } void func_809CD6C0(EnBji01* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); this->actionFunc = func_809CD70C; } diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index 8b47025e4..77cb0cca8 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -112,7 +112,8 @@ void EnCne01_UpdateModel(EnCne01* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->enHy.torsoRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.torsoRot.y, 0, 4, 0x3E8, 1); } - func_8013D9C8(globalCtx, this->enHy.limbRotTableY, this->enHy.limbRotTableZ, ARRAY_COUNT(this->enHy.limbRotTableY)); + SubS_FillLimbRotTables(globalCtx, this->enHy.limbRotTableY, this->enHy.limbRotTableZ, + ARRAY_COUNT(this->enHy.limbRotTableY)); EnHy_UpdateCollider(&this->enHy, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index b622dab8e..fe13b6757 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -130,16 +130,20 @@ s32 func_80B3E5B4(EnDai* this, GlobalContext* globalCtx) { } s32 func_80B3E5DC(EnDai* this, s32 arg1) { - static ActorAnimationEntryS D_80B3FBFC[] = { - { &object_dai_Anim_0079E4, 1.0f, 0, -1, 0, 0 }, { &object_dai_Anim_0079E4, 1.0f, 0, -1, 0, -4 }, - { &object_dai_Anim_007354, 1.0f, 0, -1, 2, -4 }, { &object_dai_Anim_000CEC, 1.0f, 0, -1, 2, -4 }, - { &object_dai_Anim_0069DC, 1.0f, 0, -1, 2, -4 }, { &object_dai_Anim_00563C, 1.0f, 0, -1, 2, 0 }, - { &object_dai_Anim_00563C, 1.0f, 0, -1, 2, -4 }, { &object_dai_Anim_002E58, 1.0f, 0, -1, 0, -4 }, - { &object_dai_Anim_006590, 1.0f, 0, -1, 2, -4 }, + static AnimationInfoS D_80B3FBFC[] = { + { &object_dai_Anim_0079E4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dai_Anim_0079E4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dai_Anim_007354, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dai_Anim_000CEC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dai_Anim_0069DC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dai_Anim_00563C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dai_Anim_00563C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dai_Anim_002E58, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dai_Anim_006590, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, }; s32 phi_v1 = false; - s32 ret = 0; + s32 ret = false; switch (arg1) { case 0: @@ -165,7 +169,7 @@ s32 func_80B3E5DC(EnDai* this, s32 arg1) { if (phi_v1) { this->unk_A70 = arg1; - ret = func_8013BC6C(&this->skelAnime, D_80B3FBFC, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80B3FBFC, arg1); } return ret; diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index 040dd4c57..b852ff0a4 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -129,33 +129,41 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dog_Anim_0021C8, 1.0f, 0, -1, 0, 0 }, { &object_dog_Anim_0021C8, 1.0f, 0, -1, 0, -6 }, - { &object_dog_Anim_001BD8, 1.0f, 0, -1, 0, 0 }, { &object_dog_Anim_000998, 1.0f, 0, -1, 0, -6 }, - { &object_dog_Anim_001FB0, 1.0f, 0, -1, 2, -6 }, { &object_dog_Anim_001FB0, 1.0f, 0, -1, 4, -6 }, - { &object_dog_Anim_001048, 1.0f, 0, -1, 2, -6 }, { &object_dog_Anim_001348, 1.0f, 0, -1, 0, -6 }, - { &object_dog_Anim_001048, 1.0f, 0, 27, 2, -6 }, { &object_dog_Anim_001048, 1.0f, 28, -1, 2, -6 }, - { &object_dog_Anim_001048, 1.0f, 54, 54, 2, -6 }, { &object_dog_Anim_0021C8, -1.5f, -1, 0, 0, -6 }, - { &object_dog_Anim_001560, 1.0f, 0, -1, 2, 0 }, { &object_dog_Anim_001A84, 1.2f, 0, -1, 2, 0 }, - { &object_dog_Anim_0017C0, 1.2f, 0, -1, 2, 0 }, { &object_dog_Anim_0021C8, 0.5f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_dog_Anim_0021C8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dog_Anim_0021C8, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &object_dog_Anim_001BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dog_Anim_000998, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &object_dog_Anim_001FB0, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, + { &object_dog_Anim_001FB0, 1.0f, 0, -1, ANIMMODE_LOOP_PARTIAL, -6 }, + { &object_dog_Anim_001048, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, + { &object_dog_Anim_001348, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &object_dog_Anim_001048, 1.0f, 0, 27, ANIMMODE_ONCE, -6 }, + { &object_dog_Anim_001048, 1.0f, 28, -1, ANIMMODE_ONCE, -6 }, + { &object_dog_Anim_001048, 1.0f, 54, 54, ANIMMODE_ONCE, -6 }, + { &object_dog_Anim_0021C8, -1.5f, -1, 0, ANIMMODE_LOOP, -6 }, + { &object_dog_Anim_001560, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dog_Anim_001A84, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dog_Anim_0017C0, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dog_Anim_0021C8, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, }; static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -void func_80989140(SkelAnime* skelAnime, ActorAnimationEntryS arg1[], s32 arg2) { +void func_80989140(SkelAnime* skelAnime, AnimationInfoS arg1[], s32 arg2) { f32 frameCount; arg1 += arg2; if (arg1->frameCount < 0) { - frameCount = Animation_GetLastFrame(arg1->animationSeg); + frameCount = Animation_GetLastFrame(arg1->animation); } else { frameCount = arg1->frameCount; } - Animation_Change(skelAnime, arg1->animationSeg, arg1->playbackSpeed + (BREG(88) * 0.1f), arg1->frame, frameCount, - arg1->mode, arg1->transitionRate); + Animation_Change(skelAnime, arg1->animation, arg1->playSpeed + (BREG(88) * 0.1f), arg1->startFrame, frameCount, + arg1->mode, arg1->morphFrames); } void func_80989204(EnDg* this, GlobalContext* globalCtx) { @@ -690,7 +698,7 @@ void func_8098A938(EnDg* this, GlobalContext* globalCtx) { this->actionFunc = func_8098AC34; } else { func_80989140(&this->skelAnime, sAnimations, 11); - sAnimations[11].playbackSpeed = -1.0f; + sAnimations[11].playSpeed = -1.0f; this->actionFunc = func_8098B198; } } @@ -765,7 +773,7 @@ void func_8098AC34(EnDg* this, GlobalContext* globalCtx) { if (sp26 < 9) { if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - sAnimations[14].playbackSpeed = randPlusMinusPoint5Scaled(1.0f) + 3.0f; + sAnimations[14].playSpeed = randPlusMinusPoint5Scaled(1.0f) + 3.0f; } func_80989864(this, globalCtx); } else { @@ -773,7 +781,7 @@ void func_8098AC34(EnDg* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 9.0f)) { f32 rand = randPlusMinusPoint5Scaled(1.5f); - sAnimations[14].playbackSpeed = 1.2f; + sAnimations[14].playSpeed = 1.2f; this->actor.velocity.y = 2.0f * rand + 3.0f; this->actor.speedXZ = 8.0f + rand; } else if (sp26 >= 0x15) { diff --git a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c index 933381034..4225c3225 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -93,25 +93,43 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dnk_Anim_000B70, 1.0f, 0, -1, 2, 0 }, { &object_dnk_Anim_000B70, 1.0f, 0, -1, 2, -4 }, - { &object_dnk_Anim_002A08, 1.0f, 0, -1, 0, -4 }, { &object_dnk_Anim_00031C, 1.0f, 0, -1, 0, -4 }, - { &object_dnk_Anim_000430, 1.0f, -1, -1, 2, 0 }, { &object_dnk_Anim_000430, 1.0f, 0, -1, 2, -4 }, - { &object_dnk_Anim_000894, 1.0f, 0, -1, 2, -4 }, { &object_dnk_Anim_002B6C, 1.0f, 0, -1, 0, 0 }, - { &object_dnk_Anim_002B6C, 1.0f, 0, -1, 0, -4 }, { &object_dnk_Anim_0006CC, 1.0f, 0, -1, 0, -4 }, - { &object_hintnuts_Anim_000168, 1.0f, 0, -1, 2, -4 }, { &object_hintnuts_Anim_0024CC, 1.0f, -1, -1, 2, 0 }, - { &object_hintnuts_Anim_0024CC, 1.0f, 0, -1, 2, -4 }, { &object_hintnuts_Anim_0026C4, 1.0f, 0, -1, 2, -4 }, - { &object_hintnuts_Anim_002894, 1.0f, 0, -1, 2, -4 }, { &object_hintnuts_Anim_002B90, 1.0f, 0, -1, 2, -4 }, - { &object_hintnuts_Anim_002F7C, 1.0f, 0, -1, 0, 0 }, { &object_hintnuts_Anim_002F7C, 1.0f, 0, -1, 0, -4 }, - { &object_hintnuts_Anim_003128, 1.0f, 0, -1, 0, 0 }, { &object_hintnuts_Anim_003128, 1.0f, 0, -1, 0, -4 }, - { &object_hintnuts_Anim_0029BC, 1.0f, 0, -1, 0, -4 }, { &object_hintnuts_Anim_002E84, 1.0f, 0, -1, 0, -4 }, - { &object_dekunuts_Anim_000168, 1.0f, 0, -1, 0, -4 }, { &object_dekunuts_Anim_00259C, 1.0f, 0, -1, 2, -4 }, - { &object_dekunuts_Anim_002A5C, 1.0f, 0, -1, 2, 0 }, { &object_dekunuts_Anim_002A5C, 1.0f, 0, -1, 2, -4 }, - { &object_dekunuts_Anim_002BD4, 1.0f, 0, -1, 2, -4 }, { &object_dekunuts_Anim_002DD4, 1.0f, 0, -1, 2, -4 }, - { &object_dekunuts_Anim_002FA4, 1.0f, 0, -1, 0, -4 }, { &object_dekunuts_Anim_003180, 1.0f, 0, -1, 2, -4 }, - { &object_dekunuts_Anim_00326C, 1.0f, 0, -1, 0, 0 }, { &object_dekunuts_Anim_00326C, 1.0f, 0, -1, 0, -4 }, - { &object_dekunuts_Anim_0033E4, 1.0f, 0, -1, 0, -4 }, { &object_dekunuts_Anim_003780, 1.0f, 0, -1, 0, 0 }, - { &object_dekunuts_Anim_003780, 1.0f, 0, -1, 0, -4 }, { &object_dekunuts_Anim_002950, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_dnk_Anim_000B70, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnk_Anim_000B70, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnk_Anim_002A08, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnk_Anim_00031C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnk_Anim_000430, 1.0f, -1, -1, ANIMMODE_ONCE, 0 }, + { &object_dnk_Anim_000430, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnk_Anim_000894, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnk_Anim_002B6C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnk_Anim_002B6C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnk_Anim_0006CC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_hintnuts_Anim_000168, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_hintnuts_Anim_0024CC, 1.0f, -1, -1, ANIMMODE_ONCE, 0 }, + { &object_hintnuts_Anim_0024CC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_hintnuts_Anim_0026C4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_hintnuts_Anim_002894, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_hintnuts_Anim_002B90, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_hintnuts_Anim_002F7C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_hintnuts_Anim_002F7C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_hintnuts_Anim_003128, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_hintnuts_Anim_003128, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_hintnuts_Anim_0029BC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_hintnuts_Anim_002E84, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dekunuts_Anim_000168, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dekunuts_Anim_00259C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dekunuts_Anim_002A5C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dekunuts_Anim_002A5C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dekunuts_Anim_002BD4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dekunuts_Anim_002DD4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dekunuts_Anim_002FA4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dekunuts_Anim_003180, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dekunuts_Anim_00326C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dekunuts_Anim_00326C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dekunuts_Anim_0033E4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dekunuts_Anim_003780, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dekunuts_Anim_003780, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dekunuts_Anim_002950, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; s32 func_80A514F0(SkelAnime* skelAnime, s16 animIndex) { @@ -124,14 +142,14 @@ s32 func_80A514F0(SkelAnime* skelAnime, s16 animIndex) { sp30 = true; frameCount = sAnimations[animIndex].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(sAnimations[animIndex].animationSeg); + frameCount = Animation_GetLastFrame(sAnimations[animIndex].animation); } - frame = sAnimations[animIndex].frame; + frame = sAnimations[animIndex].startFrame; if (frame < 0) { frame = frameCount; } - Animation_Change(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed, - frame, frameCount, sAnimations[animIndex].mode, sAnimations[animIndex].transitionRate); + Animation_Change(skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].playSpeed, frame, + frameCount, sAnimations[animIndex].mode, sAnimations[animIndex].morphFrames); } } return sp30; diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.c b/src/overlays/actors/ovl_En_Dno/z_en_dno.c index 4f8fe5b7a..67bbd22d0 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -42,17 +42,17 @@ void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve extern u8 D_801C20C0; -static struct_80B8E1A8 sAnimations[] = { - { &object_dno_Anim_000470, 1.0f, 2, 0.0f }, { &object_dno_Anim_0008F0, 1.0f, 2, 0.0f }, - { &object_dno_Anim_000F6C, 1.0f, 0, 0.0f }, { &object_dno_Anim_001A50, 1.0f, 2, 0.0f }, - { &object_dno_Anim_002530, 1.0f, 2, 0.0f }, { &object_dno_Anim_003320, 1.0f, 2, 0.0f }, - { &object_dno_Anim_0036D0, 1.0f, 0, 0.0f }, { &object_dno_Anim_0041CC, 1.0f, 2, 0.0f }, - { &object_dno_Anim_004DD8, 1.0f, 2, 0.0f }, { &object_dno_Anim_005F98, 1.0f, 0, 0.0f }, - { &object_dno_Anim_006488, 1.0f, 2, 0.0f }, { &object_dno_Anim_0073E4, 1.0f, 0, 0.0f }, - { &object_dno_Anim_0077A8, 1.0f, 0, 0.0f }, { &object_dno_Anim_007CA4, 1.0f, 0, 0.0f }, - { &object_dno_Anim_008324, 1.0f, 0, 0.0f }, { &object_dno_Anim_008AE4, 1.0f, 2, 0.0f }, - { &object_dno_Anim_009100, 1.0f, 2, 0.0f }, { &object_dno_Anim_0051E4, 1.0f, 2, 0.0f }, - { &object_dno_Anim_005E20, 1.0f, 0, 0.0f }, { &object_dno_Anim_006F84, 1.0f, 0, 0.0f }, +static AnimationSpeedInfo sAnimations[] = { + { &object_dno_Anim_000470, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_0008F0, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dno_Anim_000F6C, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_001A50, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dno_Anim_002530, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_003320, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dno_Anim_0036D0, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_0041CC, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dno_Anim_004DD8, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_005F98, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_dno_Anim_006488, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_0073E4, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_dno_Anim_0077A8, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_007CA4, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_dno_Anim_008324, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_008AE4, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dno_Anim_009100, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_0051E4, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dno_Anim_005E20, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_006F84, 1.0f, ANIMMODE_LOOP, 0.0f }, }; const ActorInit En_Dno_InitVars = { @@ -201,9 +201,9 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); Actor_UpdateBgCheckInfo(globalCtx, thisx, 0.0f, 0.0f, 0.0f, 4); - Animation_Change(&this->skelAnime, sAnimations[14].animationSeg, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimations[14].animationSeg), sAnimations[14].mode, - sAnimations[14].transitionRate); + Animation_Change(&this->skelAnime, sAnimations[14].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimations[14].animation), sAnimations[14].mode, + sAnimations[14].morphFrames); this->unk_3BE = 0x3E93; this->unk_3C0 = 60.0f; this->unk_3B0 = 0; @@ -216,7 +216,7 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { if (!(gSaveContext.weekEventReg[23] & 0x20) || (gSaveContext.weekEventReg[93] & 2)) { Actor_MarkForDeath(thisx); } else { - func_8013E1C8(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); thisx->room = -1; gSaveContext.unk_3DD0[1] = 5; this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); @@ -230,7 +230,7 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.weekEventReg[23] & 0x20) { Actor_MarkForDeath(thisx); } else { - func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); this->unk_460 = SubS_FindActor(globalCtx, NULL, ACTORCAT_NPC, ACTOR_EN_DNQ); if (this->unk_460 == NULL) { Actor_MarkForDeath(thisx); @@ -258,7 +258,7 @@ void EnDno_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80A71B04(EnDno* this, GlobalContext* globalCtx) { this->unk_452 = 0; - func_8013E1C8(&this->skelAnime, sAnimations, 19, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 19, &this->unk_32C); this->actionFunc = EnDno_DoNothing; } @@ -271,14 +271,14 @@ void func_80A71B68(EnDno* this, GlobalContext* globalCtx) { if (CHECK_QUEST_ITEM(QUEST_SONG_SONATA)) { if (gSaveContext.weekEventReg[27] & 1) { if (!(this->unk_3B0 & 0x20)) { - func_8013E1C8(&this->skelAnime, sAnimations, 6, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->unk_460); } } else { - func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); } } else { - func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); } this->actionFunc = func_80A71C3C; } @@ -287,23 +287,23 @@ void func_80A71C3C(EnDno* this, GlobalContext* globalCtx) { switch (this->unk_32C) { case 9: case 16: - func_8013E1C8(&this->skelAnime, sAnimations, 10, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 10, &this->unk_32C); break; case 3: case 10: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); } break; case 11: - func_8013E1C8(&this->skelAnime, sAnimations, 15, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 15, &this->unk_32C); break; case 15: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_8013E1C8(&this->skelAnime, sAnimations, 6, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); } case 6: @@ -363,7 +363,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xE38)) { switch (this->unk_464) { case 0x80B: - func_8013E1C8(&this->skelAnime, sAnimations, 16, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 16, &this->unk_32C); case 0x811: func_801518B0(globalCtx, this->unk_464, &this->actor); @@ -372,9 +372,9 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { case 0x80C: case 0x80F: if (this->unk_32C == 13) { - func_8013E1C8(&this->skelAnime, sAnimations, 4, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 4, &this->unk_32C); } else if ((this->unk_32C == 4) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, sAnimations, 11, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 11, &this->unk_32C); func_801518B0(globalCtx, this->unk_464, &this->actor); } break; @@ -387,7 +387,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { switch (this->unk_32C) { case 16: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_8013E1C8(&this->skelAnime, sAnimations, 9, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 9, &this->unk_32C); } Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->unk_460), 0x71C); @@ -396,7 +396,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { case 10: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { func_801477B4(globalCtx); - func_8013E1C8(&this->skelAnime, sAnimations, 0xD, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); func_80A71B68(this, globalCtx); } break; @@ -412,13 +412,13 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { switch (this->unk_32C) { case 16: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_8013E1C8(&this->skelAnime, sAnimations, 9, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 9, &this->unk_32C); } break; case 9: if (func_80147624(globalCtx)) { - func_8013E1C8(&this->skelAnime, sAnimations, 10, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 10, &this->unk_32C); globalCtx->msgCtx.msgMode = 0x44; } break; @@ -426,7 +426,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { case 10: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { func_801477B4(globalCtx); - func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); func_80A71B68(this, globalCtx); } break; @@ -447,10 +447,10 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { case 0x80E: if (this->unk_32C == 11) { - func_8013E1C8(&this->skelAnime, sAnimations, 3, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 3, &this->unk_32C); } else if (this->unk_32C == 3) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); } } else if ((this->unk_32C == 13) && func_80147624(globalCtx)) { func_801477B4(globalCtx); @@ -474,12 +474,12 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { switch (this->unk_32C) { case 11: - func_8013E1C8(&this->skelAnime, sAnimations, 15, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 15, &this->unk_32C); break; case 15: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_8013E1C8(&this->skelAnime, sAnimations, 6, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); } break; } @@ -498,7 +498,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { void func_80A72438(EnDno* this, GlobalContext* globalCtx) { this->unk_452 = 1; - func_8013E1C8(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); this->actor.textId = 0; if (Flags_GetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor))) { this->unk_454 = 1.0f; @@ -544,7 +544,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { case 0: if (this->unk_32C == 14) { if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2D8)) { - func_8013E1C8(&this->skelAnime, sAnimations, 5, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 5, &this->unk_32C); } } else if ((this->unk_32C == 5) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Flags_GetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor))) { @@ -554,7 +554,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { } else { func_801518B0(globalCtx, 0x800, &this->actor); } - func_8013E1C8(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); } break; @@ -589,7 +589,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, sAnimations, 12, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 12, &this->unk_32C); func_801518B0(globalCtx, 0x803, &this->actor); } } @@ -605,7 +605,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { globalCtx->msgCtx.msgMode = 0x44; this->unk_452 = 1; this->unk_454 = 0.0f; - func_8013E1C8(&this->skelAnime, sAnimations, 8, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 8, &this->unk_32C); } break; @@ -631,7 +631,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { case 0x804: if (this->unk_32C == 14) { if (func_80147624(globalCtx)) { - func_8013E1C8(&this->skelAnime, sAnimations, 5, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 5, &this->unk_32C); if (!(this->unk_3B0 & 0x40)) { func_80A72CF8(this, globalCtx); this->unk_3B0 |= 0x40; @@ -658,7 +658,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { } void func_80A72AE4(EnDno* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->unk_32C); func_80A714B4(this, globalCtx); this->actionFunc = func_80A72B3C; } @@ -685,7 +685,7 @@ void func_80A72BA4(EnDno* this, GlobalContext* globalCtx) { } void func_80A72C04(EnDno* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->unk_32C); this->actor.flags |= 0x8000000; this->actor.flags &= ~(8 | 1); Math_Vec3f_Copy(&this->unk_334, &this->actor.world.pos); @@ -784,7 +784,7 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { } if (phi_a2 >= 0) { - func_8013E1C8(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); } } @@ -829,11 +829,11 @@ void func_80A732C8(EnDno* this, GlobalContext* globalCtx) { if (Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x71C)) { this->unk_3B0 |= 4; this->unk_44E = 3; - func_8013E1C8(&this->skelAnime, sAnimations, 7, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 7, &this->unk_32C); } } else if (this->unk_44E == 3) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); func_80A72438(this, globalCtx); } else { if (this->skelAnime.curFrame >= 20.0f) { @@ -875,7 +875,7 @@ void func_80A73408(EnDno* this, GlobalContext* globalCtx) { } if (sp33) { - func_8013E1C8(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); } } func_800EDF24(&this->actor, globalCtx, temp_v0); @@ -883,7 +883,7 @@ void func_80A73408(EnDno* this, GlobalContext* globalCtx) { if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && (this->unk_32C == 17)) { if (0) {}; - func_8013E1C8(&this->skelAnime, sAnimations, 18, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 18, &this->unk_32C); } } diff --git a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c index 9a2d6099c..e29711737 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -56,20 +56,33 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dnp_Anim_0007D8, 1.0f, 0, -1, 2, -4 }, { &object_dnp_Anim_0021DC, 1.0f, 0, -1, 0, 0 }, - { &object_dnp_Anim_0021DC, 1.0f, 0, -1, 0, -4 }, { &object_dnp_Anim_0026B8, 1.0f, 0, -1, 2, -4 }, - { &object_dnp_Anim_004D08, 1.0f, 0, -1, 2, -4 }, { &object_dnp_Anim_0071F4, 1.0f, 0, -1, 2, -4 }, - { &object_dnp_Anim_007960, 1.0f, 0, -1, 0, -4 }, { &object_dnp_Anim_008588, 1.0f, 0, -1, 2, 0 }, - { &object_dnp_Anim_00A900, 1.0f, 0, -1, 0, -4 }, { &object_dnp_Anim_00AEB8, 1.0f, 0, -1, 0, -4 }, - { &object_dnp_Anim_00B754, 1.0f, 0, -1, 2, -4 }, { &object_dnp_Anim_00674C, 1.0f, 0, -1, 0, -4 }, - { &object_dnp_Anim_00BAD8, 1.0f, 0, -1, 2, -4 }, { &object_dnp_Anim_006B74, 1.0f, 0, -1, 0, -4 }, - { &object_dnp_Anim_012428, 1.0f, 0, -1, 0, -4 }, { &object_dnp_Anim_00B324, 1.0f, 0, -1, 0, 0 }, - { &object_dnp_Anim_00B324, 1.0f, 0, -1, 0, -4 }, { &object_dnp_Anim_0115B8, 1.0f, 0, -1, 0, -4 }, - { &object_dnp_Anim_0115B8, 1.0f, 0, -1, 0, 0 }, { &object_dnp_Anim_00923C, 1.0f, 0, -1, 2, -4 }, - { &object_dnp_Anim_009AA0, 1.0f, 0, -1, 0, -4 }, { &object_dnp_Anim_00125C, 1.0f, 0, -1, 2, -4 }, - { &object_dnp_Anim_0017F8, 1.0f, 0, -1, 2, 0 }, { &object_dnp_Anim_001C1C, 1.0f, 0, -1, 0, -4 }, - { &object_dnp_Anim_0057AC, 1.0f, 0, -1, 2, 0 }, { &object_dnp_Anim_00625C, 1.0f, 0, -1, 0, -4 }, +static AnimationInfoS sAnimations[] = { + { &object_dnp_Anim_0007D8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_0021DC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnp_Anim_0021DC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_0026B8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_004D08, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_0071F4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_007960, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_008588, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnp_Anim_00A900, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_00AEB8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_00B754, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_00674C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_00BAD8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_006B74, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_012428, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_00B324, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnp_Anim_00B324, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_0115B8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_0115B8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnp_Anim_00923C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_009AA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_00125C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_0017F8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnp_Anim_001C1C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_0057AC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnp_Anim_00625C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; static s32 D_80B3DE58[] = { @@ -122,7 +135,7 @@ s32 func_80B3CC38(EnDnp* this, s32 arg1) { if (arg1 != this->unk_340) { this->unk_340 = arg1; - ret = func_8013BC6C(&this->skelAnime, sAnimations, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); } return ret; diff --git a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c index 667d205fc..3a9027b76 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -57,17 +57,27 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS D_80A5349C[] = { - { &object_dnq_Anim_008328, 1.0f, 0, -1, 0, 0 }, { &object_dnq_Anim_008328, 1.0f, 0, -1, 0, -4 }, - { &object_dnq_Anim_007528, 1.0f, 0, -1, 2, -4 }, { &object_dnq_Anim_0006F0, 1.0f, 0, -1, 2, 0 }, - { &object_dnq_Anim_000BF8, 1.0f, 0, -1, 0, -4 }, { &object_dnq_Anim_002690, 0.0f, 0, -1, 2, 0 }, - { &object_dnq_Anim_002690, 1.0f, 0, -1, 2, -4 }, { &object_dnq_Anim_003408, 1.0f, 0, -1, 0, -4 }, - { &object_dnq_Anim_006984, 1.0f, 0, -1, 2, -4 }, { &object_dnq_Anim_005E18, 1.0f, 0, -1, 2, -4 }, - { &object_dnq_Anim_005A14, 1.0f, 0, -1, 2, -4 }, { &object_dnq_Anim_005284, 1.0f, 0, -1, 2, -4 }, - { &object_dnq_Anim_001AEC, 1.0f, 0, -1, 2, 0 }, { &object_dnq_Anim_001100, 1.0f, 0, -1, 2, 0 }, - { &object_dnq_Anim_004EA0, 1.0f, 0, -1, 0, -4 }, { &object_dnq_Anim_00F504, 1.0f, 0, -1, 0, -4 }, - { &object_dnq_Anim_0047B8, 1.0f, 0, -1, 0, -4 }, { &object_dnq_Anim_003DBC, 1.0f, 0, -1, 2, -4 }, - { &object_dnq_Anim_005A14, 1.0f, 0, -1, 0, -4 }, { &object_dnq_Anim_003DBC, 1.0f, 0, -1, 0, -4 }, +static AnimationInfoS D_80A5349C[] = { + { &object_dnq_Anim_008328, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnq_Anim_008328, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_007528, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_0006F0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnq_Anim_000BF8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_002690, 0.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnq_Anim_002690, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_003408, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_006984, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_005E18, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_005A14, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_005284, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_001AEC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnq_Anim_001100, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnq_Anim_004EA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_00F504, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_0047B8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_003DBC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_005A14, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_003DBC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; void func_80A52530(GlobalContext* globalCtx, EnDnq* this) { @@ -94,7 +104,7 @@ s32 func_80A5257C(EnDnq* this, s32 arg1) { if (phi_v1) { this->unk_398 = arg1; - ret = func_8013BC6C(&this->skelAnime, D_80A5349C, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80A5349C, arg1); } return ret; diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c index f9b3bdceb..378db036d 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -60,12 +60,17 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dns_Anim_003310, 1.0f, 0, -1, 0, 0 }, { &object_dns_Anim_003310, 1.0f, 0, -1, 0, -4 }, - { &object_dns_Anim_0034EC, 1.0f, 0, -1, 0, 0 }, { &object_dns_Anim_0034EC, 1.0f, 0, -1, 0, -4 }, - { &object_dns_Anim_0008F4, 1.0f, 0, -1, 2, 0 }, { &object_dns_Anim_000BD8, 1.0f, 0, -1, 0, 0 }, - { &object_dns_Anim_000D58, 1.0f, 0, -1, 2, 0 }, { &object_dns_Anim_000FEC, 1.0f, 0, -1, 0, 0 }, - { &object_dns_Anim_0002A8, 1.0f, 0, -1, 2, 0 }, { &object_dns_Anim_000734, 1.0f, 0, -1, 2, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_dns_Anim_003310, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dns_Anim_003310, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dns_Anim_0034EC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dns_Anim_0034EC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dns_Anim_0008F4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dns_Anim_000BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dns_Anim_000D58, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dns_Anim_000FEC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dns_Anim_0002A8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dns_Anim_000734, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; void func_8092C5C0(EnDns* this) { @@ -79,7 +84,7 @@ void func_8092C5C0(EnDns* this) { s32 func_8092C63C(EnDns* this, s32 arg1) { s32 phi_v1 = false; - s32 ret = 0; + s32 ret = false; switch (arg1) { case 0: @@ -104,7 +109,7 @@ s32 func_8092C63C(EnDns* this, s32 arg1) { if (phi_v1) { this->unk_2F8 = arg1; - ret = func_8013BC6C(&this->skelAnime, sAnimations, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); } return ret; diff --git a/src/overlays/actors/ovl_En_Fg/z_en_fg.c b/src/overlays/actors/ovl_En_Fg/z_en_fg.c index ea0c82027..18a63fff2 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.c +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.c @@ -95,11 +95,11 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_fr_Anim_001534, 1.0f, 0, -1, 0, 0 }, - { &object_fr_Anim_001534, 1.0f, 0, -1, 0, -4 }, - { &object_fr_Anim_0011C0, 1.0f, 0, -1, 0, -4 }, - { &object_fr_Anim_0007BC, 1.0f, 0, -1, 2, -4 }, +static AnimationInfoS sAnimations[] = { + { &object_fr_Anim_001534, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_fr_Anim_001534, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_fr_Anim_0011C0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_fr_Anim_0007BC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, }; s32 EnFg_UpdateAnimation(SkelAnime* skelAnime, s16 animIndex) { @@ -111,11 +111,11 @@ s32 EnFg_UpdateAnimation(SkelAnime* skelAnime, s16 animIndex) { ret = true; frameCount = sAnimations[animIndex].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(sAnimations[animIndex].animationSeg); + frameCount = Animation_GetLastFrame(sAnimations[animIndex].animation); } - Animation_Change(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed, - sAnimations[animIndex].frame, frameCount, sAnimations[animIndex].mode, - sAnimations[animIndex].transitionRate); + Animation_Change(skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].playSpeed, + sAnimations[animIndex].startFrame, frameCount, sAnimations[animIndex].mode, + sAnimations[animIndex].morphFrames); } return ret; } diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index 4b6210dd0..a59f775ce 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -59,14 +59,20 @@ const ActorInit En_Fsn_InitVars = { (ActorFunc)EnFsn_Draw, }; -static ActorAnimationEntryS sAnimations[] = { - { &object_fsn_Anim_012C34, 1.0f, 0, -1, 0, 0 }, { &object_fsn_Anim_0131FC, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00C58C, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00C58C, -1.0f, 0, -1, 2, 0 }, - { &object_fsn_Anim_00E3EC, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00F00C, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00CB3C, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00D354, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_0138B0, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_01430C, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00B9D8, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00C26C, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00DE34, 1.0f, 0, -1, 2, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_fsn_Anim_012C34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_fsn_Anim_0131FC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_fsn_Anim_00C58C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_fsn_Anim_00C58C, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_fsn_Anim_00E3EC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_fsn_Anim_00F00C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_fsn_Anim_00CB3C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_fsn_Anim_00D354, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_fsn_Anim_0138B0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_fsn_Anim_01430C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_fsn_Anim_00B9D8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_fsn_Anim_00C26C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_fsn_Anim_00DE34, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; static ColliderCylinderInit sCylinderInit = { @@ -687,7 +693,7 @@ void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { this->blinkTimer = 20; this->animationIdx = 4; this->eyeTextureIdx = 0; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); this->actionFunc = EnFsn_Idle; } @@ -696,10 +702,10 @@ void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { if (this->animationIdx == 4) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animationSeg); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); if (curFrame == frameCount) { this->animationIdx = 5; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); } return; } @@ -732,12 +738,12 @@ void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animationSeg); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); if (this->flags & ENFSN_ANGRY) { this->flags &= ~ENFSN_ANGRY; this->animationIdx = 11; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); } else { if (this->animationIdx == 11 && Animation_OnFrame(&this->skelAnime, 18.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); @@ -745,16 +751,16 @@ void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx) { if (this->flags & ENFSN_CALM_DOWN) { this->flags &= ~ENFSN_CALM_DOWN; this->animationIdx = 5; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); } else if (this->flags & ENFSN_OFFER_FINAL_PRICE) { this->flags &= ~ENFSN_OFFER_FINAL_PRICE; this->animationIdx = 12; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); } else { if (this->animationIdx == 12) { if (curFrame == frameCount) { this->animationIdx = 5; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); } else { if (Animation_OnFrame(&this->skelAnime, 28.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); @@ -1403,7 +1409,7 @@ void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags |= 1; this->actor.targetMode = 0; this->animationIdx = 0; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); this->actionFunc = EnFsn_IdleBackroom; } } @@ -1420,7 +1426,7 @@ void EnFsn_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); Actor_MoveWithGravity(&this->actor); func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unk27A, this->actor.focus.pos); - func_8013D9C8(globalCtx, this->limbRotYTable, this->limbRotZTable, 19); + SubS_FillLimbRotTables(globalCtx, this->limbRotYTable, this->limbRotZTable, ARRAY_COUNT(this->limbRotYTable)); EnFsn_Blink(this); if (ENFSN_IS_SHOP(&this->actor) && EnFsn_HasItemsToSell()) { EnFsn_UpdateJoystickInputState(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index 3ffd64097..19360748a 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -74,11 +74,14 @@ static Vec3f D_80964B0C = { 0.0f, 60.0f, -8.0f }; static Vec3f D_80964B18 = { 0.0f, 55.0f, 12.0f }; static Vec3f D_80964B24 = { 0.0f, 60.0f, 0.0f }; -static ActorAnimationEntry sAnimations[] = { - { &object_mu_Anim_0053E0, 1.0f, 0.0f, 0.0f, 0, -4.0f }, { &object_mu_Anim_001F74, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_mu_Anim_002F64, 1.0f, 0.0f, 0.0f, 0, -4.0f }, { &object_mu_Anim_004904, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_mu_Anim_005304, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_mu_Anim_005304, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_mu_Anim_00BAC4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, +static AnimationInfo sAnimations[] = { + { &object_mu_Anim_0053E0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_mu_Anim_001F74, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_mu_Anim_002F64, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_mu_Anim_004904, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_mu_Anim_005304, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_mu_Anim_005304, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_mu_Anim_00BAC4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -369,7 +372,7 @@ void func_8096209C(EnFu* this, GlobalContext* globalCtx) { } void func_809622FC(EnFu* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80962340; } @@ -534,7 +537,7 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { func_801477B4(globalCtx); player->stateFlags1 |= 0x20; this->unk_53C = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_801A2BB8(NA_BGM_MINI_GAME_2); if (this->unk_542 == 0) { if (this->unk_546 == 1) { @@ -1211,7 +1214,7 @@ void func_80964190(EnFu* this, GlobalContext* globalCtx) { case 0x2842: case 0x2844: case 0x2848: - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); break; case 0x2840: @@ -1237,21 +1240,21 @@ void func_80964190(EnFu* this, GlobalContext* globalCtx) { case 0x286B: case 0x286D: case 0x2871: - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); break; case 0x2860: - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); break; case 0x285F: - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); break; case 0x287E: case 0x2880: case 0x2883: - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); break; } } 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 2c13764b9..3207a1d12 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -125,18 +125,28 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, 0, 0 }, { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, 0, -4 }, - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, 0 }, { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, -4 }, - { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, 2, -4 }, { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, 0, 0 }, - { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, 0, -4 }, { &object_oF1d_map_Anim_0039D8, 1.0f, 0, -1, 2, -4 }, - { &object_taisou_Anim_0016C8, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_004DD4, 1.0f, 0, -1, 0, 0 }, - { &object_taisou_Anim_00283C, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_007764, 1.0f, 0, -1, 0, 0 }, - { &object_taisou_Anim_005EE0, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_002C48, 1.0f, 0, -1, 0, 0 }, - { &object_taisou_Anim_0031D8, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_005790, 1.0f, 0, -1, 0, 0 }, - { &object_oF1d_map_Anim_003650, 1.0f, 0, -1, 0, 0 }, { &object_hakugin_demo_Anim_002704, 1.0f, 0, -1, 2, 0 }, - { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, 0, -4 }, { &object_oF1d_map_Anim_0135E8, 1.0f, 0, -1, 2, 0 }, - { &object_oF1d_map_Anim_014CE0, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_oF1d_map_Anim_0039D8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_taisou_Anim_0016C8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_004DD4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_00283C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_007764, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_005EE0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_002C48, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_0031D8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_005790, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_oF1d_map_Anim_003650, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_hakugin_demo_Anim_002704, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_oF1d_map_Anim_0135E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_oF1d_map_Anim_014CE0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; u16 func_80BB16D0(EnGeg* this) { @@ -368,7 +378,7 @@ void func_80BB1FCC(EnGeg* this, GlobalContext* globalCtx) { void func_80BB2020(EnGeg* this, GlobalContext* globalCtx) { gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[this->unk_248].segment); - func_8013BC6C(&this->skelAnime, sAnimations, this->unk_4AC); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_4AC); } s32 func_80BB2088(EnGeg* this, GlobalContext* globalCtx) { @@ -598,7 +608,7 @@ void func_80BB27D4(EnGeg* this, GlobalContext* globalCtx) { void func_80BB2944(EnGeg* this, GlobalContext* globalCtx) { u8 sp27 = Message_GetState(&globalCtx->msgCtx); s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_4AC].animationSeg); + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_4AC].animation); if (this->unk_4AC == 19) { if (curFrame == lastFrame) { @@ -694,7 +704,7 @@ void func_80BB2B1C(EnGeg* this, GlobalContext* globalCtx) { void func_80BB2E00(EnGeg* this, GlobalContext* globalCtx) { s16 sp2E = this->skelAnime.curFrame; - s16 sp2C = Animation_GetLastFrame(sAnimations[this->unk_4AC].animationSeg); + s16 sp2C = Animation_GetLastFrame(sAnimations[this->unk_4AC].animation); if (this->unk_4AC == 2) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); @@ -894,7 +904,7 @@ void EnGeg_Update(Actor* thisx, GlobalContext* globalCtx) { func_80BB1FCC(this, globalCtx); func_80BB2088(this, globalCtx); func_80BB1C8C(this); - func_8013D9C8(globalCtx, &this->unk_238, &this->unk_232, 3); + SubS_FillLimbRotTables(globalCtx, this->unk_238, this->unk_232, ARRAY_COUNT(this->unk_238)); func_80BB1D04(this); func_80BB178C(this, globalCtx); } 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 c846f447b..f5e9ad34d 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.h +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.h @@ -14,10 +14,8 @@ typedef struct EnGeg { /* 0x18C */ ColliderCylinder colliderCylinder; /* 0x1D8 */ ColliderSphere colliderSphere; /* 0x230 */ u16 unk_230; - /* 0x232 */ s16 unk_232; - /* 0x234 */ UNK_TYPE1 unk234[4]; - /* 0x238 */ s16 unk_238; - /* 0x23A */ UNK_TYPE1 unk23A[0x4]; + /* 0x232 */ s16 unk_232[3]; + /* 0x238 */ s16 unk_238[3]; /* 0x23E */ s16 unk_23E; /* 0x240 */ s16 unk_240; /* 0x242 */ s16 unk_242; 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 9ade835fc..d4190d1db 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 @@ -42,12 +42,12 @@ const ActorInit En_Ginko_Man_InitVars = { (ActorFunc)EnGinkoMan_Draw, }; -ActorAnimationEntry animations[] = { - { &object_boj_Anim_0008C0, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_boj_Anim_0043F0, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_boj_Anim_004F40, 1.0f, 0.0f, 0.0f, 2, -4.0f }, - { &object_boj_Anim_000AC4, 1.0f, 0.0f, 0.0f, 0, -4.0f }, // looking around for customers - { &object_boj_Anim_004A7C, 1.0f, 0.0f, 0.0f, 0, -4.0f }, +static AnimationInfo sAnimations[] = { + { &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 }, }; void EnGinkoMan_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -72,7 +72,7 @@ void EnGinkoMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnGinkoMan_SetupIdle(EnGinkoMan* this) { this->actor.flags |= 1; // targetable - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); this->actionFunc = EnGinkoMan_Idle; } @@ -82,11 +82,11 @@ void EnGinkoMan_Idle(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_SwitchAnimation(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if ((gSaveContext.bankRupees & 0xFFFF) == 0) { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); func_801518B0(globalCtx, 0x44C, &this->actor); this->curTextId = 0x44C; // would you like to make an account } else { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); if ((CURRENT_DAY == 3) && (gSaveContext.isNight == 1)) { func_801518B0(globalCtx, 0x467, &this->actor); this->curTextId = 0x467; // "What's this? You need somethin' on a day like this? @@ -109,7 +109,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { switch (this->curTextId) { case 0x44C: // "Hey there, little guy! Won't you deposit some Rupees? (first dialogue) - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); if (gSaveContext.weekEventReg[10] & 8) { func_801518B0(globalCtx, 0x44E, &this->actor); this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" @@ -124,7 +124,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" break; case 0x44F: // "...So, what'll it be? Deposit Rupees Don't deposit Rupees" - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); func_801518B0(globalCtx, 0x450, &this->actor); this->curTextId = 0x450; // "How much? How much? [rupee prompt] break; @@ -135,14 +135,14 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { if (this->isNewAccount == true) { this->isNewAccount = false; if (this->curTextId != 0x453) { // "That's it? That ain't nothing at all, big spender! - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); } func_801518B0(globalCtx, 0x461, &this->actor); this->curTextId = 0x461; // So, little guy, what's your name? } else { if (this->curTextId == 0x453) { // "That's it? That ain't nothing at all, big spender! - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); } globalCtx->msgCtx.bankRupees = gSaveContext.bankRupees & 0xFFFF; @@ -172,17 +172,17 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { func_801518B0(globalCtx, 0x45D, &this->actor); this->curTextId = 0x45D; // "What's this? You've already saved up 5000 Rupees?! } else if (this->previousBankValue < (s16)(gSaveContext.bankRupees & 0xFFFF)) { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); func_801518B0(globalCtx, 0x45E, &this->actor); this->curTextId = 0x45E; // "...Hang on there, little guy. I can't take any more deposits. Sorry..." } else { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); func_801518B0(globalCtx, 0x460, &this->actor); this->curTextId = 0x460; // "Come back and deposit some after you save up a bunch!" } } else { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); func_801518B0(globalCtx, 0x460, &this->actor); this->curTextId = 0x460; // "Come back and deposit some after you save up a bunch!" } @@ -212,7 +212,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_SetupStamp(this); // stamp player break; case 0x465: // "There! Now I'll know you when I see you!" - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); globalCtx->msgCtx.bankRupees = gSaveContext.bankRupees & 0xFFFF; func_801518B0(globalCtx, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" @@ -269,7 +269,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { break; case 0x476: // "...You haven't deposited that many Rupees, so that much isn't available for withdrawal. Do the // math! - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); case 0x475: // "What's this? Look, little guy, you can't hold this many rupees! You got that?" case 0x47C: // "Is that so? Think it over, little guy! So what are you gonna do?" case 0x47D: // duplicate of 48 @@ -336,7 +336,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { if (gSaveContext.rupees < globalCtx->msgCtx.bankRupeesSelected) { play_sound(NA_SE_SY_ERROR); - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); func_801518B0(globalCtx, 0x459, &this->actor); this->curTextId = 0x459; // HEY you dont have that much } else { @@ -348,7 +348,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) func_801518B0(globalCtx, 0x454, &this->actor); this->curTextId = 0x454; // Seriously? that's a lot. A lot! } else { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); func_801518B0(globalCtx, 0x453, &this->actor); this->curTextId = 0x453; // That's it? That aint nothing at all } @@ -365,7 +365,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) } } else { // GINKOMAN_CHOICE_NO func_8019F230(); - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); if ((gSaveContext.bankRupees & 0xFFFF) == 0) { func_801518B0(globalCtx, 0x456, &this->actor); this->curTextId = 0x456; // Is that so? think about it @@ -398,7 +398,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) if ((s32)((gSaveContext.bankRupees & 0xFFFF)) < ((s32)(globalCtx->msgCtx.bankRupeesSelected + this->serviceFee))) { play_sound(NA_SE_SY_ERROR); - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); func_801518B0(globalCtx, 0x476, &this->actor); this->curTextId = 0x476; // you dont have enough deposited to withdrawl } else if (CUR_CAPACITY(UPG_WALLET) < (globalCtx->msgCtx.bankRupeesSelected + gSaveContext.rupees)) { @@ -440,7 +440,7 @@ void EnGinkoMan_WaitForRupeeCount(EnGinkoMan* this, GlobalContext* globalCtx) { switch (this->curTextId) { case 0x450: // "How much? How much?" [rupee prompt] Set the amount with [Control Stick] and if (globalCtx->msgCtx.bankRupeesSelected == 0) { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); func_801518B0(globalCtx, 0x457, &this->actor); this->curTextId = 0x457; // Zero Rupees? Cruel joke! } else { @@ -539,7 +539,7 @@ void EnGinkoMan_BankAward2(EnGinkoMan* this, GlobalContext* globalCtx) { func_801518B0(globalCtx, 0x47A, &this->actor); this->curTextId = 0x47A; // Message after receiving reward for depositing 200 rupees. } else { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); func_801518B0(globalCtx, 0x47B, &this->actor); this->curTextId = 0x47B; // Message after receiving reward for depositing 1000 rupees. } @@ -558,7 +558,7 @@ void EnGinkoMan_BankAward2(EnGinkoMan* this, GlobalContext* globalCtx) { } void EnGinkoMan_SetupStamp(EnGinkoMan* this) { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_REACHING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_REACHING); this->actionFunc = EnGinkoMan_Stamp; } @@ -571,12 +571,12 @@ void EnGinkoMan_Stamp(EnGinkoMan* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { switch (this->curTextId) { case 0x464: // "Hey, relax! It doesn't leave any marks, and it's not gonna hurt." - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); func_801518B0(globalCtx, 0x465, &this->actor); this->curTextId = 0x465; // "There! Now I'll know you when I see you!" break; case 0x469: // "Excuse me, but let me take a look at you..." - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); globalCtx->msgCtx.bankRupees = (gSaveContext.bankRupees & 0xFFFF); if ((CURRENT_DAY == 3) && (gSaveContext.isNight == 1)) { func_801518B0(globalCtx, 0x46C, &this->actor); @@ -597,12 +597,12 @@ void EnGinkoMan_SwitchAnimation(EnGinkoMan* this, GlobalContext* globalCtx) { if (this->animTimer == 0) { if (this->skelAnime.animation != &object_boj_Anim_004A7C) { this->animTimer = 40; - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_ADVERTISING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_ADVERTISING); } } } else if ((this->animTimer == 0) && (this->skelAnime.animation != &object_boj_Anim_000AC4)) { this->animTimer = 40; - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_AMAZED); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_AMAZED); } DECR(this->animTimer); 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 b3a84c672..e8e8d5b0a 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -128,14 +128,20 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS D_80951CC0[13] = { - { &object_in2_Anim_009CDC, 1.0f, 0, -1, 0, 0 }, { &object_in2_Anim_009CDC, 1.0f, 0, -1, 0, -4 }, - { &object_in2_Anim_00A5E0, 1.0f, 0, -1, 0, 0 }, { &object_in2_Anim_00A70C, 1.0f, 0, 1, 0, 0 }, - { &object_in2_Anim_008090, 1.0f, 0, -1, 0, 0 }, { &object_in2_Anim_00898C, 1.0f, 0, -1, 2, -4 }, - { &object_in2_Anim_009450, 1.0f, 0, -1, 2, -4 }, { &object_in2_Anim_00AD18, 1.0f, 0, -1, 0, 0 }, - { &object_in2_Anim_00AD18, 1.0f, 0, -1, 0, -4 }, { &object_in2_Anim_00B8B0, 1.0f, 0, -1, 2, 0 }, - { &object_in2_Anim_00BA80, 1.0f, 0, -1, 0, -4 }, { &object_in2_Anim_00C03C, 1.0f, 0, -1, 0, -4 }, - { &object_in2_Anim_00B990, 1.0f, 0, -1, 0, -4 }, +static AnimationInfoS D_80951CC0[] = { + { &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 }, }; Actor* func_8094DEE0(EnGm* this, GlobalContext* globalCtx, u8 arg2, s16 arg3) { @@ -230,7 +236,7 @@ s32 func_8094E054(EnGm* this, GlobalContext* globalCtx, s32 arg2) { if (phi_v1) { if (tmp >= 0) { this->unk_3E8 = arg2; - ret = func_8013BC6C(&this->skelAnime, D_80951CC0, arg2); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80951CC0, arg2); this->unk_3A8 = this->skelAnime.playSpeed; } } @@ -1344,7 +1350,7 @@ s32 func_80950690(EnGm* this, GlobalContext* globalCtx) { break; } - func_8013D9C8(globalCtx, this->unk_3D8, this->unk_3D2, ARRAY_COUNT(this->unk_3D2)); + SubS_FillLimbRotTables(globalCtx, this->unk_3D8, this->unk_3D2, ARRAY_COUNT(this->unk_3D8)); return false; } @@ -1532,16 +1538,11 @@ void func_80950DB8(EnGm* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp34, &sp40), 4, 0x2AA8); } } - func_8013D9C8(globalCtx, this->unk_3D8, this->unk_3D2, 3); + SubS_FillLimbRotTables(globalCtx, this->unk_3D8, this->unk_3D2, ARRAY_COUNT(this->unk_3D8)); } void func_80950F2C(EnGm* this, GlobalContext* globalCtx) { - s32 sp50[] = { - 0, - 0, - 3, - 2, - }; + s32 sp50[] = { 0, 0, 3, 2 }; Player* player = GET_PLAYER(globalCtx); s32 pad; Vec3f sp3C; 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 156651ee2..1d6d192ac 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -186,20 +186,31 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, 0, 0 }, { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, 0, -4 }, - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, 0 }, { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, -4 }, - { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, 2, 0 }, { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, 0, 0 }, - { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, 0, -4 }, { &object_oF1d_map_Anim_0039D8, 1.0f, 0, -1, 2, -4 }, - { &object_oF1d_map_Anim_003650, 1.0f, 0, -1, 0, 0 }, { &object_oF1d_map_Anim_0135E8, 1.0f, 0, -1, 2, -4 }, +static AnimationInfoS sAnimations[] = { + { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_oF1d_map_Anim_0039D8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_oF1d_map_Anim_003650, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_oF1d_map_Anim_0135E8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_taisou_Anim_004DD4, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_0016C8, 1.0f, 0, -1, 0, 0 }, - { &object_taisou_Anim_00283C, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_007764, 1.0f, 0, -1, 0, 0 }, - { &object_taisou_Anim_005EE0, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_002C48, 1.0f, 0, -1, 0, 0 }, - { &object_taisou_Anim_0031D8, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_005790, 1.0f, 0, -1, 0, 0 }, + { &object_taisou_Anim_004DD4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_0016C8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_00283C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_007764, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_005EE0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_002C48, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_0031D8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_005790, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_hakugin_demo_Anim_001420, 1.0f, 0, -1, 2, 0 }, { &object_hakugin_demo_Anim_001A4C, 1.0f, 0, -1, 0, -4 }, - { &object_hakugin_demo_Anim_002704, 1.0f, 0, -1, 2, 0 }, { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, 0, -4 }, + { &object_hakugin_demo_Anim_001420, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_hakugin_demo_Anim_001A4C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_hakugin_demo_Anim_002704, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; EnGoStruct* func_80A10FD0(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6) { @@ -768,7 +779,7 @@ s32 func_80A12B78(EnGo* this, GlobalContext* globalCtx) { s32 func_80A12C48(EnGo* this, GlobalContext* globalCtx, s32 arg2) { s8 objIdx = this->actor.objBankIndex; s8 objIdx2 = -1; - s32 ret = 0; + s32 ret = false; if ((arg2 >= 18) && (this->unk_289 >= 0)) { objIdx2 = this->unk_289; @@ -781,7 +792,7 @@ s32 func_80A12C48(EnGo* this, GlobalContext* globalCtx, s32 arg2) { if (objIdx2 >= 0) { gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objIdx2].segment); this->unk_3DC = arg2; - ret = func_8013BC6C(&this->skelAnime, sAnimations, arg2); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg2); this->unk_398 = this->skelAnime.playSpeed; gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objIdx].segment); } @@ -1579,7 +1590,7 @@ void func_80A14B30(EnGo* this, GlobalContext* globalCtx) { this->actor.shape.yOffset = 0.0f; } - func_8013D9C8(globalCtx, &this->unk_3CE[0], &this->unk_3C8[0], 3); + SubS_FillLimbRotTables(globalCtx, this->unk_3CE, this->unk_3C8, ARRAY_COUNT(this->unk_3CE)); Math_ApproachS(&this->actor.shape.rot.y, sp26, 4, 0x2AA8); } @@ -1733,7 +1744,7 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { } } - func_8013D9C8(globalCtx, this->unk_3CE, this->unk_3C8, 3); + SubS_FillLimbRotTables(globalCtx, this->unk_3CE, this->unk_3C8, ARRAY_COUNT(this->unk_3CE)); func_800EDF24(&this->actor, globalCtx, sp2C); } } @@ -1853,7 +1864,7 @@ void func_80A157C4(EnGo* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp34, &this->actor.world.pos); Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp34, &sp40), 4, 0x2AA8); } - func_8013D9C8(globalCtx, this->unk_3CE, this->unk_3C8, 3); + SubS_FillLimbRotTables(globalCtx, this->unk_3CE, this->unk_3C8, ARRAY_COUNT(this->unk_3CE)); return; } 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 2ad64ef94..708c79828 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -102,15 +102,15 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { 0, 0, 0, 0, 0x80, }; -static ActorAnimationEntry sAnimations[] = { - { &object_harfgibud_Anim_00260C, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_harfgibud_Anim_009D44, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_harfgibud_Anim_00A164, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_harfgibud_Anim_000370, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_harfgibud_Anim_001138, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_harfgibud_Anim_0015D4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_harfgibud_Anim_001960, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_harfgibud_Anim_00AE1C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, +static AnimationInfo sAnimations[] = { + { &object_harfgibud_Anim_00260C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_harfgibud_Anim_009D44, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_harfgibud_Anim_00A164, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_harfgibud_Anim_000370, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_harfgibud_Anim_001138, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_harfgibud_Anim_0015D4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_harfgibud_Anim_001960, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_harfgibud_Anim_00AE1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, }; static u32 D_80BD00C8 = false; @@ -149,7 +149,7 @@ void EnHg_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80BCF354(EnHg* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BCF398; } @@ -167,7 +167,7 @@ void func_80BCF398(EnHg* this, GlobalContext* globalCtx) { } void func_80BCF468(EnHg* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80BCF4AC; } @@ -191,7 +191,7 @@ void func_80BCF4AC(EnHg* this, GlobalContext* globalCtx) { } void func_80BCF5F0(EnHg* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BCF634; } @@ -204,7 +204,7 @@ void func_80BCF634(EnHg* this, GlobalContext* globalCtx) { } void func_80BCF68C(EnHg* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->actionFunc = func_80BCF6D0; } @@ -278,17 +278,17 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { case 1: this->currentAnimation = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); break; case 2: this->cutscenes[2] = 0; this->currentAnimation = 3; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); break; case 3: this->cutscenes[2] = 0; this->currentAnimation = 5; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); break; case 4: this->cutscenes[2] = 0; @@ -296,11 +296,11 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { if ((this->unk218 == 1) || (this->unk218 == 3)) { func_8019F128(NA_SE_EN_HALF_REDEAD_TRANS); } - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); break; case 5: this->currentAnimation = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); break; case 6: gSaveContext.weekEventReg[0x4B] |= 0x20; @@ -312,11 +312,11 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { switch (this->currentAnimation) { case 3: this->currentAnimation = 4; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); break; case 5: this->currentAnimation = 6; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); break; } } 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 2e2b6a84b..38f25f954 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -40,14 +40,14 @@ const ActorInit En_Hgo_InitVars = { (ActorFunc)EnHgo_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_harfgibud_Anim_00B644, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_harfgibud_Anim_013684, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_harfgibud_Anim_0152EC, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_harfgibud_Anim_015C70, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_harfgibud_Anim_0165F0, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_harfgibud_Anim_014220, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_harfgibud_Anim_014A9C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, +static AnimationInfo sAnimations[] = { + { &object_harfgibud_Anim_00B644, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_harfgibud_Anim_013684, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_harfgibud_Anim_0152EC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_harfgibud_Anim_015C70, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_harfgibud_Anim_0165F0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_harfgibud_Anim_014220, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_harfgibud_Anim_014A9C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -128,7 +128,7 @@ void func_80BD0434(EnHgo* this, GlobalContext* globalCtx) { } void func_80BD049C(EnHgo* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BD04E0; } @@ -255,28 +255,28 @@ s32 func_80BD0898(EnHgo* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { case 1: this->unk_218 = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); break; case 2: this->actor.draw = EnHgo_Draw; this->unk_218 = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); break; case 3: this->unk_218 = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); break; case 4: this->unk_218 = 3; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); break; case 5: this->unk_218 = 4; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); break; case 6: this->unk_218 = 5; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); break; } } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -292,11 +292,11 @@ s32 func_80BD0898(EnHgo* this, GlobalContext* globalCtx) { break; case 2: this->unk_218 = 3; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); break; case 5: this->unk_218 = 6; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); } } 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 28225d2f6..de73118da 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 @@ -125,14 +125,20 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -static ActorAnimationEntry sAnimations[] = { - { &object_skb_Anim_0064E0, 0.96f, 0.0f, 0.0f, 0, -4.0f }, { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -1.0f }, - { &object_skb_Anim_002190, 0.6f, 0.0f, 0.0f, 3, 4.0f }, { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, 2, -4.0f }, - { &object_skb_Anim_00270C, 1.0f, 0.0f, 0.0f, 2, -4.0f }, { &object_skb_Anim_00697C, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_skb_Anim_006D90, 1.0f, 0.0f, 0.0f, 0, -4.0f }, { &object_skb_Anim_001D1C, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -16.0f }, - { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_skb_Anim_0015EC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_skb_Anim_0009E4, 1.0f, 0.0f, 0.0f, 0, -8.0f }, +static AnimationInfo sAnimations[] = { + { &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 }, }; static InitChainEntry sInitChain[] = { @@ -174,7 +180,7 @@ void func_80C1FE20(EnHintSkb* this, GlobalContext* globalCtx) { } void func_80C1FE30(EnHintSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actor.speedXZ = 1.6f; this->actionFunc = func_80C1FE80; } @@ -193,7 +199,7 @@ void func_80C1FE80(EnHintSkb* this, GlobalContext* globalCtx) { void func_80C1FF30(EnHintSkb* this) { this->collider.base.atFlags &= ~AT_BOUNCED; this->actor.speedXZ = 0.0f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->actionFunc = func_80C1FF88; } @@ -266,12 +272,12 @@ void func_80C2016C(EnHintSkb* this, GlobalContext* globalCtx) { void func_80C20274(EnHintSkb* this) { if (this->skelAnime.animation == &object_skb_Anim_00697C) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); this->actor.gravity = -1.0f; this->actor.speedXZ = 1.0f; } else { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -4.0f; } @@ -308,7 +314,7 @@ void func_80C20334(EnHintSkb* this, GlobalContext* globalCtx) { } void func_80C20484(EnHintSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); this->unk_3E8 |= 4; if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -6.0f; @@ -340,7 +346,7 @@ void func_80C20590(EnHintSkb* this, GlobalContext* globalCtx) { this->unk_2D4 = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3E8 |= 1; func_80C20274(this); @@ -367,7 +373,7 @@ void func_80C2069C(EnHintSkb* this, GlobalContext* globalCtx) { this->unk_2D4 = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3E8 |= 1; func_80C20274(this); @@ -396,10 +402,10 @@ void func_80C2077C(EnHintSkb* this, GlobalContext* globalCtx) { this->actor.speedXZ = 2.4f; this->actor.gravity = -1.0f; this->actor.velocity.y = 3.0f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); } } else { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); func_801518B0(globalCtx, 0x1148, &this->actor); this->unk_3E6 = 0x1148; } @@ -458,7 +464,7 @@ void func_80C208D0(EnHintSkb* this, GlobalContext* globalCtx) { Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_801518B0(globalCtx, 0x1147, &this->actor); this->unk_3E6 = 0x1147; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); } } @@ -533,7 +539,7 @@ void func_80C20C24(EnHintSkb* this, GlobalContext* globalCtx) { case 0x1147: func_801518B0(globalCtx, 0x1148, &this->actor); this->unk_3E6 = 0x1148; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); break; case 0x1148: @@ -582,7 +588,7 @@ void func_80C20D64(EnHintSkb* this, GlobalContext* globalCtx) { this->actor.hintId = 255; this->actor.textId = 0; if (this->actionFunc == func_80C1FE80) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); } func_80C2075C(this); } @@ -692,7 +698,7 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { this->unk_2D8 = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_80C2066C(this); break; @@ -709,7 +715,7 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { case 13: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_80C20274(this); break; 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 383ef2cd4..6539128c3 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -112,12 +112,17 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dai_Anim_0048B4, 1.0f, 0, -1, 0, 0 }, { &object_dai_Anim_0048B4, 1.0f, 0, -1, 0, -4 }, - { &object_dai_Anim_005100, 1.0f, 0, -1, 0, 0 }, { &object_dai_Anim_005100, 1.0f, 0, -1, 0, -4 }, - { &object_dai_Anim_0010F8, 1.0f, 0, -1, 2, 0 }, { &object_dai_Anim_001E44, 1.0f, 0, -1, 0, -4 }, - { &object_dai_Anim_0014BC, 1.0f, 0, -1, 2, 0 }, { &object_dai_Anim_003CAC, 1.0f, 0, -1, 2, -4 }, - { &object_dai_Anim_0040E0, 1.0f, 0, -1, 0, 0 }, { &object_dai_Anim_0040E0, 1.0f, 0, -1, 0, -4 }, +static AnimationInfoS sAnimations[] = { + { &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 }, }; Actor* func_80BF1150(EnIg* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { @@ -201,7 +206,7 @@ s32 func_80BF1284(EnIg* this, s32 arg1) { if (phi_v1) { this->unk_3FC = arg1; - ret = func_8013BC6C(&this->skelAnime, sAnimations, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); this->unk_3D4 = this->skelAnime.playSpeed; } 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 d74946294..bc4d3a89b 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -131,16 +131,25 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_in_Anim_001D10, 1.0f, 0, -1, 0, 0 }, { &object_in_Anim_001D10, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_014F8C, 1.0f, 0, -1, 0, 0 }, { &object_in_Anim_014F8C, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_000CB0, 1.0f, 0, -1, 0, -4 }, { &object_in_Anim_0003B4, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_001BE0, 1.0f, 0, -1, 0, -4 }, { &object_in_Anim_015918, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_01C0B0, 1.0f, 0, -1, 0, 0 }, { &object_in_Anim_01C0B0, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_01A140, 1.0f, 0, -1, 0, 0 }, { &object_in_Anim_01A140, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_01B904, 1.0f, 0, -1, 0, 0 }, { &object_in_Anim_01B904, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_01B3C4, 1.0f, 0, -1, 0, 0 }, { &object_in_Anim_01B3C4, 0.0f, 0, -1, 2, 0 }, - { &object_in_Anim_01B3C4, 1.0f, 0, -1, 0, -4 }, { &object_in_Anim_019EB4, 1.0f, 0, -1, 2, -4 }, +static AnimationInfoS sAnimations[] = { + { &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 u16 D_808F6C0C[] = { @@ -155,11 +164,11 @@ s32 func_808F30B0(SkelAnime* skelAnime, s16 animIndex) { ret = true; frameCount = sAnimations[animIndex].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(sAnimations[animIndex].animationSeg); + frameCount = Animation_GetLastFrame(sAnimations[animIndex].animation); } - Animation_Change(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed, - sAnimations[animIndex].frame, frameCount, sAnimations[animIndex].mode, - sAnimations[animIndex].transitionRate); + Animation_Change(skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].playSpeed, + sAnimations[animIndex].startFrame, frameCount, sAnimations[animIndex].mode, + sAnimations[animIndex].morphFrames); } return ret; } @@ -254,7 +263,7 @@ void func_808F3414(EnIn* this, GlobalContext* globalCtx) { } func_808F322C(this, 3); func_808F3178(this, globalCtx); - func_8013D9C8(globalCtx, this->unk376, this->unk39E, 20); + SubS_FillLimbRotTables(globalCtx, this->unk376, this->unk39E, ARRAY_COUNT(this->unk376)); } void func_808F35AC(EnIn* this, GlobalContext* globalCtx) { 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 0dc1d5df5..461384295 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -133,17 +133,26 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &gGoronElderIdleAnim, 1.0f, 0, -1, 0, -10 }, { &gGoronElderWalkAnim, 1.0f, 0, -1, 0, -10 }, - { &gGoronElderWavingAnim, 1.0f, 0, -1, 0, -10 }, { &gGoronElderHeadShakeAnim, 1.0f, 0, -1, 0, -10 }, - { &gGoronElderSurpriseStartAnim, 1.0f, 0, -1, 2, -10 }, { &gGoronElderSurpriseLoopAnim, 1.0f, 0, -1, 0, -10 }, - { &gGoronElderAngryAnim, 1.0f, 0, -1, 0, -10 }, { &gGoronElderSurpriseStartAnim, 2.0f, 0, -1, 2, 0 }, - { &gGoronElderSurpriseStartAnim, -2.0f, 0, -1, 2, 0 }, { &gGoronElderWalkAnim, -1.0f, 0, -1, 0, -10 }, - { &gGoronElderTakeOutDrumAnim, 1.0f, 0, -1, 2, 0 }, { &gGoronElderDrumIdleAnim, 1.0f, 0, -1, 0, 0 }, - { &gGoronElderPlayingDrumAnim, 1.0f, 1, 44, 2, 0 }, { &gGoronElderThinkingAnim, 1.0f, 0, -1, 0, 0 }, - { &gGoronElderRememberingAnim, 1.0f, 0, -1, 2, 0 }, { &gGoronElderStrongRememberingAnim, 1.0f, 0, -1, 2, 0 }, - { &gGoronElderDepressedAnim, 1.0f, 0, -1, 0, 0 }, { &gGoronElderIdleAnim, 1.0f, 0, -1, 0, 0 }, - { &gGoronElderCradleAnim, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &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 }, }; static Vec3f sSfxPos = { 0.0f, 0.0f, 0.0f }; @@ -288,19 +297,19 @@ void EnJg_SetupTalk(EnJg* this, GlobalContext* globalCtx) { switch (this->textId) { case 0xDAC: // What was I doing? this->animationIndex = EN_JG_ANIMATION_SHAKING_HEAD; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnJg_Talk; break; case 0xDAD: // I must hurry! this->animationIndex = EN_JG_ANIMATION_SURPRISE_START; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnJg_AlternateTalkOrWalkInPlace; break; case 0xDB7: // You're Darmani! this->animationIndex = EN_JG_ANIMATION_SURPRISE_START; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnJg_Talk; break; @@ -311,7 +320,7 @@ void EnJg_SetupTalk(EnJg* this, GlobalContext* globalCtx) { case 0xDBD: // "...What?" case 0xDC4: // It's so cold I can't play this->animationIndex = EN_JG_ANIMATION_IDLE; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnJg_Talk; break; @@ -320,14 +329,14 @@ void EnJg_SetupTalk(EnJg* this, GlobalContext* globalCtx) { case 0xDBC: // Following me won't do you any good case 0xDC6: // I am counting on you this->animationIndex = EN_JG_ANIMATION_ANGRY; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnJg_Talk; break; case 0xDB4: // This is our problem (first) case 0xDB5: // This is our problem (repeat) this->animationIndex = EN_JG_ANIMATION_WAVING; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnJg_Talk; break; } @@ -408,12 +417,12 @@ void EnJg_GoronShrineCheer(EnJg* this, GlobalContext* globalCtx) { void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, GlobalContext* globalCtx) { u8 messageState = Message_GetState(&globalCtx->msgCtx); s16 currentFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animationSeg); + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (this->animationIndex == EN_JG_ANIMATION_SURPRISE_START) { if (currentFrame == lastFrame) { this->animationIndex = EN_JG_ANIMATION_SURPRISE_LOOP; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } } else if (this->animationIndex == EN_JG_ANIMATION_SURPRISE_LOOP) { if ((messageState == 5) && (func_80147624(globalCtx))) { @@ -421,7 +430,7 @@ void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, GlobalContext* globalCtx) { globalCtx->msgCtx.unk12023 = 4; this->flags &= ~FLAG_LOOKING_AT_PLAYER; this->animationIndex = EN_JG_ANIMATION_WALK; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnJg_Walk; } } else if (this->animationIndex == EN_JG_ANIMATION_WALK) { @@ -463,12 +472,12 @@ void EnJg_Walk(EnJg* this, GlobalContext* globalCtx) { void EnJg_Talk(EnJg* this, GlobalContext* globalCtx) { u8 messageState = Message_GetState(&globalCtx->msgCtx); s16 currentFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animationSeg); + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); u16 temp; if ((this->animationIndex == EN_JG_ANIMATION_SURPRISE_START) && (currentFrame == lastFrame)) { this->animationIndex = EN_JG_ANIMATION_SURPRISE_LOOP; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } if ((messageState == 5) && (func_80147624(globalCtx))) { @@ -523,7 +532,7 @@ void EnJg_SetupWalk(EnJg* this, GlobalContext* globalCtx) { if (this->animationIndex != EN_JG_ANIMATION_WALK) { this->animationIndex = EN_JG_ANIMATION_WALK; this->freezeTimer = 1000; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnJg_Walk; } else { this->freezeTimer = 1000; @@ -533,7 +542,7 @@ void EnJg_SetupWalk(EnJg* this, GlobalContext* globalCtx) { void EnJg_Freeze(EnJg* this, GlobalContext* globalCtx) { s16 currentFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animationSeg); + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (this->action == EN_JG_ACTION_SPAWNING) { this->action = EN_JG_ACTION_FROZEN_OR_NON_FIRST_THAW; @@ -543,7 +552,7 @@ void EnJg_Freeze(EnJg* this, GlobalContext* globalCtx) { 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); this->animationIndex = EN_JG_ANIMATION_FROZEN_LOOP; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnJg_FrozenIdle; } else if (this->animationIndex == EN_JG_ANIMATION_FROZEN_START) { this->action = EN_JG_ACTION_FROZEN_OR_NON_FIRST_THAW; @@ -553,7 +562,7 @@ void EnJg_Freeze(EnJg* this, GlobalContext* globalCtx) { 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); this->animationIndex = EN_JG_ANIMATION_FROZEN_LOOP; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnJg_FrozenIdle; } } @@ -571,11 +580,11 @@ void EnJg_FrozenIdle(EnJg* this, GlobalContext* globalCtx) { // Otherwise, he immediately begins walking after being // thawed out. if (this->textId == 0xDAC) { - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnJg_Idle; } else { this->freezeTimer = 1000; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnJg_Walk; } } @@ -665,7 +674,7 @@ void EnJg_LullabyIntroCutsceneAction(EnJg* this, GlobalContext* globalCtx) { break; } - func_8013BC6C(&this->skelAnime, sAnimations, this->cutsceneAnimationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->cutsceneAnimationIndex); } if ((!(this->flags & FLAG_DRUM_SPAWNED)) && @@ -890,7 +899,7 @@ void EnJg_SpawnBreath(EnJg* this, GlobalContext* globalCtx) { */ void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, GlobalContext* globalCtx) { s16 currentFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animationSeg); + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->flags |= FLAG_LOOKING_AT_PLAYER; @@ -917,7 +926,7 @@ void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, GlobalContext* this->freezeTimer--; if ((this->freezeTimer <= 0) && (currentFrame == lastFrame)) { this->animationIndex = EN_JG_ANIMATION_FROZEN_START; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); Audio_PlaySfxAtPos(&sSfxPos, NA_SE_EV_FREEZE_S); this->actionFunc = EnJg_Freeze; } @@ -944,7 +953,7 @@ void EnJg_Init(Actor* thisx, GlobalContext* globalCtx) { // This is the elder that appears in the cutscene for learning the full Goron Lullaby. this->animationIndex = EN_JG_ANIMATION_IDLE; this->action = EN_JG_ACTION_LULLABY_INTRO_CS; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnJg_LullabyIntroCutsceneAction; } else { // This is the elder that appears in Mountain Village or the Path to Goron Village in winter. @@ -953,14 +962,14 @@ void EnJg_Init(Actor* thisx, GlobalContext* globalCtx) { this->action = EN_JG_ACTION_SPAWNING; this->freezeTimer = 1000; this->textId = 0xDAC; // What was I doing? - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnJg_Freeze; } } else { // This is the elder that appears in Goron Shrine in spring. this->animationIndex = EN_JG_ANIMATION_IDLE; this->cutscene = this->actor.cutscene; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnJg_GoronShrineIdle; } } 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 040d13859..bd750edae 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -132,8 +132,10 @@ static AnimationHeader* kakasiAnimations[] = { &object_ka_Anim_00686C, &object_ka_Anim_0081A4, &object_ka_Anim_000214, }; -static u8 sAnimModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, - ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE }; +static u8 sAnimModes[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, + ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, +}; void EnKakasi_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnKakasi* this = THIS; diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index 7b53287fd..d28ec4622 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -112,33 +112,33 @@ void EnMa4_UpdateEyes(EnMa4* this) { } } -static struct_80B8E1A8 sAnimationInfo[] = { - { &object_ma1_Anim_009E58, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_009E58, 1.0f, 0, -6.0f }, // Idle anim - { &object_ma1_Anim_002A8C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_002A8C, 1.0f, 0, -6.0f }, // Looking around anim - { &object_ma1_Anim_018948, 1.0f, 2, 0.0f }, - { &object_ma1_Anim_018948, 1.0f, 2, -6.0f }, // Starts holding hands anim - { &object_ma1_Anim_01B76C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_01B76C, 1.0f, 0, -6.0f }, // Holnding hands anim - { &object_ma1_Anim_007328, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_007328, 1.0f, 0, -6.0f }, // Walking anim - { &object_ma1_Anim_014088, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_014088, 1.0f, 0, -6.0f }, // - { &object_ma1_Anim_015B7C, 1.0f, 2, 0.0f }, - { &object_ma1_Anim_015B7C, 1.0f, 2, -6.0f }, // Shoot arrow anim - { &object_ma1_Anim_007D98, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_007D98, 1.0f, 0, -6.0f }, // Sitting anim - { &object_ma1_Anim_00852C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_00852C, 1.0f, 0, -6.0f }, // Sitting traumatized anim - { &object_ma1_Anim_008F6C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_008F6C, 1.0f, 0, -6.0f }, // Sitting sad anim +static AnimationSpeedInfo sAnimationInfo[] = { + { &object_ma1_Anim_009E58, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_009E58, 1.0f, ANIMMODE_LOOP, -6.0f }, // Idle anim + { &object_ma1_Anim_002A8C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_002A8C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Looking around anim + { &object_ma1_Anim_018948, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_ma1_Anim_018948, 1.0f, ANIMMODE_ONCE, -6.0f }, // Starts holding hands anim + { &object_ma1_Anim_01B76C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_01B76C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Holnding hands anim + { &object_ma1_Anim_007328, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_007328, 1.0f, ANIMMODE_LOOP, -6.0f }, // Walking anim + { &object_ma1_Anim_014088, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_014088, 1.0f, ANIMMODE_LOOP, -6.0f }, // + { &object_ma1_Anim_015B7C, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_ma1_Anim_015B7C, 1.0f, ANIMMODE_ONCE, -6.0f }, // Shoot arrow anim + { &object_ma1_Anim_007D98, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_007D98, 1.0f, ANIMMODE_LOOP, -6.0f }, // Sitting anim + { &object_ma1_Anim_00852C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_00852C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Sitting traumatized anim + { &object_ma1_Anim_008F6C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_008F6C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Sitting sad anim }; void EnMa4_ChangeAnim(EnMa4* this, s32 index) { - Animation_Change(&this->skelAnime, sAnimationInfo[index].animationSeg, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationInfo[index].animationSeg), sAnimationInfo[index].mode, - sAnimationInfo[index].transitionRate); + Animation_Change(&this->skelAnime, sAnimationInfo[index].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationInfo[index].animation), sAnimationInfo[index].mode, + sAnimationInfo[index].morphFrames); } void func_80ABDD9C(EnMa4* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c index 67d44caff..69948f426 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -109,19 +109,19 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { 0, 0, 0, 0, MASS_IMMOVABLE, }; -static struct_80B8E1A8 sAnimationInfo[] = { - { &object_ma2_Anim_00A174, 1.0f, 0, 0.0f }, { &object_ma2_Anim_00A174, 1.0f, 0, -6.0f }, // - { &object_ma2_Anim_00AF7C, 1.0f, 2, 0.0f }, { &object_ma2_Anim_00AF7C, 1.0f, 2, -6.0f }, // - { &object_ma2_Anim_000CC0, 1.0f, 0, 0.0f }, { &object_ma2_Anim_000CC0, 1.0f, 0, -6.0f }, // - { &object_ma2_Anim_016720, 1.0f, 0, 0.0f }, { &object_ma2_Anim_016720, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_005314, 1.0f, 0, 0.0f }, { &object_ma2_Anim_005314, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_0093E8, 1.0f, 0, 0.0f }, { &object_ma2_Anim_0093E8, 1.0f, 0, -10.0f }, // - { &object_ma2_Anim_007E28, 1.0f, 0, 0.0f }, { &object_ma2_Anim_007E28, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_0070EC, 1.0f, 0, 0.0f }, { &object_ma2_Anim_0070EC, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_003D54, 1.0f, 0, 0.0f }, { &object_ma2_Anim_003D54, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_001FD0, 1.0f, 0, 0.0f }, { &object_ma2_Anim_001FD0, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_0030B4, 1.0f, 0, 0.0f }, { &object_ma2_Anim_0030B4, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_004370, 1.0f, 0, 0.0f }, { &object_ma2_Anim_004370, 1.0f, 0, -8.0f }, // +static AnimationSpeedInfo sAnimationInfo[] = { + { &object_ma2_Anim_00A174, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_00A174, 1.0f, ANIMMODE_LOOP, -6.0f }, // + { &object_ma2_Anim_00AF7C, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_ma2_Anim_00AF7C, 1.0f, ANIMMODE_ONCE, -6.0f }, // + { &object_ma2_Anim_000CC0, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_000CC0, 1.0f, ANIMMODE_LOOP, -6.0f }, // + { &object_ma2_Anim_016720, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_016720, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_005314, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_005314, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_0093E8, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_0093E8, 1.0f, ANIMMODE_LOOP, -10.0f }, // + { &object_ma2_Anim_007E28, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_007E28, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_0070EC, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_0070EC, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_003D54, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_003D54, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_001FD0, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_001FD0, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_0030B4, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_0030B4, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_004370, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_004370, 1.0f, ANIMMODE_LOOP, -8.0f }, // }; static TexturePtr sMouthTextures[] = { @@ -1265,9 +1265,9 @@ void EnMaYto_BarnStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_ChangeAnim(EnMaYto* this, s32 index) { - Animation_Change(&this->skelAnime, sAnimationInfo[index].animationSeg, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationInfo[index].animationSeg), sAnimationInfo[index].mode, - sAnimationInfo[index].transitionRate); + Animation_Change(&this->skelAnime, sAnimationInfo[index].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationInfo[index].animation), sAnimationInfo[index].mode, + sAnimationInfo[index].morphFrames); } void func_80B90C78(EnMaYto* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c index ee186086c..dc1129e07 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c @@ -78,29 +78,29 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { 0, 0, 0, 0, MASS_IMMOVABLE, }; -static struct_80B8E1A8 sAnimationInfo[] = { - { &object_ma1_Anim_009E58, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_009E58, 1.0f, 0, -6.0f }, // Idle anim - { &object_ma1_Anim_018948, 1.0f, 2, 0.0f }, - { &object_ma1_Anim_018948, 1.0f, 2, -6.0f }, // Starts holding hands anim - { &object_ma1_Anim_01B76C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_01B76C, 1.0f, 0, -6.0f }, // Holnding hands anim - { &object_ma1_Anim_007328, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_007328, 1.0f, 0, -6.0f }, // Walking anim - { &object_ma1_Anim_014088, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_014088, 1.0f, 0, -6.0f }, // - { &object_ma1_Anim_002A8C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_002A8C, 1.0f, 0, -6.0f }, // Looking around anim - { &object_ma1_Anim_015B7C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_015B7C, 1.0f, 0, -6.0f }, // Shoot arrow anim - { &object_ma1_Anim_007D98, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_007D98, 1.0f, 0, -6.0f }, // Sitting anim - { &object_ma1_Anim_00852C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_00852C, 1.0f, 0, -6.0f }, // Sitting traumatized anim - { &object_ma1_Anim_008F6C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_008F6C, 1.0f, 0, -6.0f }, // Sitting sad anim - { &object_ma1_Anim_0180DC, 1.0f, 2, 0.0f }, - { &object_ma1_Anim_0180DC, 1.0f, 2, -6.0f }, // Turns around anim +static AnimationSpeedInfo sAnimationInfo[] = { + { &object_ma1_Anim_009E58, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_009E58, 1.0f, ANIMMODE_LOOP, -6.0f }, // Idle anim + { &object_ma1_Anim_018948, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_ma1_Anim_018948, 1.0f, ANIMMODE_ONCE, -6.0f }, // Starts holding hands anim + { &object_ma1_Anim_01B76C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_01B76C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Holnding hands anim + { &object_ma1_Anim_007328, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_007328, 1.0f, ANIMMODE_LOOP, -6.0f }, // Walking anim + { &object_ma1_Anim_014088, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_014088, 1.0f, ANIMMODE_LOOP, -6.0f }, // + { &object_ma1_Anim_002A8C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_002A8C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Looking around anim + { &object_ma1_Anim_015B7C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_015B7C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Shoot arrow anim + { &object_ma1_Anim_007D98, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_007D98, 1.0f, ANIMMODE_LOOP, -6.0f }, // Sitting anim + { &object_ma1_Anim_00852C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_00852C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Sitting traumatized anim + { &object_ma1_Anim_008F6C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_008F6C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Sitting sad anim + { &object_ma1_Anim_0180DC, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_ma1_Anim_0180DC, 1.0f, ANIMMODE_ONCE, -6.0f }, // Turns around anim }; static TexturePtr sMouthTextures[] = { @@ -115,9 +115,9 @@ static TexturePtr sEyeTextures[] = { }; void EnMaYts_ChangeAnim(EnMaYts* this, s32 index) { - Animation_Change(&this->skelAnime, sAnimationInfo[index].animationSeg, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationInfo[index].animationSeg), sAnimationInfo[index].mode, - sAnimationInfo[index].transitionRate); + Animation_Change(&this->skelAnime, sAnimationInfo[index].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationInfo[index].animation), sAnimationInfo[index].mode, + sAnimationInfo[index].morphFrames); } void func_80B8D12C(EnMaYts* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Muto/z_en_muto.c b/src/overlays/actors/ovl_En_Muto/z_en_muto.c index ed752ea1c..10214b609 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.c +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.c @@ -101,7 +101,7 @@ void EnMuto_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnMuto_ChangeAnim(EnMuto* this, s32 animIndex) { static AnimationHeader* sAnimations[] = { &object_toryo_Anim_000E50, &object_toryo_Anim_000E50 }; - static u8 sAnimationModes[] = { 0, 2 }; + static u8 sAnimationModes[] = { ANIMMODE_LOOP, ANIMMODE_ONCE }; this->animIndex = animIndex; this->frameIndex = Animation_GetLastFrame(&sAnimations[animIndex]->common); diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index 1e0b4e495..9bf1abcfe 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -65,28 +65,40 @@ const ActorInit En_Ossan_InitVars = { (ActorFunc)NULL, }; -static ActorAnimationEntryS sAnimationsCuriosityShopMan[] = { - { &object_fsn_Anim_012C34, 1.0f, 0, -1, 0, 0 }, { &object_fsn_Anim_0131FC, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00C58C, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00C58C, -1.0f, 0, -1, 2, 0 }, - { &object_fsn_Anim_00E3EC, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00F00C, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00CB3C, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00D354, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_0138B0, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_01430C, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00B9D8, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00C26C, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00DE34, 1.0f, 0, -1, 2, 0 }, +static AnimationInfoS sAnimationsCuriosityShopMan[] = { + { &object_fsn_Anim_012C34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_fsn_Anim_0131FC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_fsn_Anim_00C58C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_fsn_Anim_00C58C, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_fsn_Anim_00E3EC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_fsn_Anim_00F00C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_fsn_Anim_00CB3C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_fsn_Anim_00D354, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_fsn_Anim_0138B0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_fsn_Anim_01430C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_fsn_Anim_00B9D8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_fsn_Anim_00C26C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_fsn_Anim_00DE34, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; -static ActorAnimationEntryS sAnimationsPartTimeWorker[] = { - { &object_ani_Anim_009D34, 1.0f, 0, -1, 0, -10 }, { &object_ani_Anim_009D34, 1.0f, 0, -1, 0, -10 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, 2, 0 }, { &object_ani_Anim_009D34, -1.0f, 0, -1, 2, 0 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, 2, 0 }, { &object_ani_Anim_009D34, 1.0f, 0, -1, 0, 0 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, 2, 0 }, { &object_ani_Anim_009D34, 1.0f, 0, -1, 0, 0 }, - { &object_ani_Anim_00A460, 1.0f, 0, -1, 2, -5 }, { &object_ani_Anim_00A460, 1.0f, 0, -1, 0, -5 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, 2, 0 }, { &object_ani_Anim_009D34, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimationsPartTimeWorker[] = { + { &object_ani_Anim_009D34, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &object_ani_Anim_009D34, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &object_ani_Anim_009D34, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_ani_Anim_009D34, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_ani_Anim_009D34, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_ani_Anim_009D34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_ani_Anim_009D34, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_ani_Anim_009D34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_ani_Anim_00A460, 1.0f, 0, -1, ANIMMODE_ONCE, -5 }, + { &object_ani_Anim_00A460, 1.0f, 0, -1, ANIMMODE_LOOP, -5 }, + { &object_ani_Anim_009D34, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_ani_Anim_009D34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; static s16 sObjectIds[] = { OBJECT_FSN, OBJECT_ANI }; -static ActorAnimationEntryS* sAnimations[] = { sAnimationsCuriosityShopMan, sAnimationsPartTimeWorker }; +static AnimationInfoS* sAnimations[] = { sAnimationsCuriosityShopMan, sAnimationsPartTimeWorker }; static f32 sActorScales[] = { 0.01f, 0.01f }; @@ -313,7 +325,7 @@ void EnOssan_SetupLookToShopkeeperFromShelf(GlobalContext* globalCtx, EnOssan* t void EnOssan_Idle(EnOssan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - func_8013D9C8(globalCtx, this->limbRotTableY, this->limbRotTableZ, 19); + SubS_FillLimbRotTables(globalCtx, this->limbRotTableY, this->limbRotTableZ, ARRAY_COUNT(this->limbRotTableY)); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { player->stateFlags2 |= 0x20000000; EnOssan_SetupAction(this, EnOssan_BeginInteraction); @@ -338,9 +350,9 @@ void EnOssan_Idle(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx) { - ActorAnimationEntryS* animations = sAnimations[this->actor.params]; + AnimationInfoS* animations = sAnimations[this->actor.params]; s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(animations[this->animationIdx].animationSeg); + s16 frameCount = Animation_GetLastFrame(animations[this->animationIdx].animation); if (this->animationIdx == 3) { frameCount = 0; @@ -358,19 +370,19 @@ void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx) { switch (this->animationIdx) { case 1: this->animationIdx = 2; - func_8013BC6C(&this->skelAnime, animations, 2); + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 2); break; case 2: EnOssan_SetHaveMet(this); this->textId = EnOssan_GetWelcomeCuriosityShopMan(this, globalCtx); - func_8013BC6C(&this->skelAnime, animations, this->animationIdx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, this->animationIdx); break; case 4: case 6: case 8: case 10: this->animationIdx++; - func_8013BC6C(&this->skelAnime, animations, this->animationIdx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, this->animationIdx); func_801518B0(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, false); break; @@ -379,16 +391,16 @@ void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx) { case 9: case 11: this->animationIdx = 3; - func_8013BC6C(&this->skelAnime, animations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 3); break; case 3: this->animationIdx = 1; - func_8013BC6C(&this->skelAnime, animations, 1); + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); EnOssan_SetupAction(this, EnOssan_Idle); break; default: this->animationIdx = 1; - func_8013BC6C(&this->skelAnime, animations, 1); + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); EnOssan_SetupAction(this, EnOssan_Idle); break; } @@ -506,7 +518,7 @@ u8 EnOssan_CursorLeft(EnOssan* this, u8 cursorIdx, u8 shelfSlotMax) { } void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { - ActorAnimationEntryS* animations = sAnimations[this->actor.params]; + AnimationInfoS* animations = sAnimations[this->actor.params]; u8 talkState = Message_GetState(&globalCtx->msgCtx); s32 pad; Player* player = GET_PLAYER(globalCtx); @@ -515,7 +527,7 @@ void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { if (talkState == 5 && func_80147624(globalCtx)) { if (this->animationIdx == 9 && this->actor.params == ENOSSAN_PART_TIME_WORKER) { this->animationIdx = 1; - func_8013BC6C(&this->skelAnime, animations, 1); + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); } this->flags &= ~LOOKED_AT_PLAYER; if (player->transformation == PLAYER_FORM_DEKU) { @@ -532,7 +544,7 @@ void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { if (talkState == 10 && this->actor.params == ENOSSAN_PART_TIME_WORKER && player->transformation == PLAYER_FORM_ZORA && func_80147624(globalCtx)) { this->animationIdx = 9; - func_8013BC6C(&this->skelAnime, animations, 9); + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 9); } if (this->animationIdx == 11 && Animation_OnFrame(&this->skelAnime, 18.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); @@ -540,7 +552,7 @@ void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { } s32 EnOssan_FacingShopkeeperDialogResult(EnOssan* this, GlobalContext* globalCtx) { - ActorAnimationEntryS* animations = sAnimations[this->actor.params]; + AnimationInfoS* animations = sAnimations[this->actor.params]; Player* player = GET_PLAYER(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -548,7 +560,7 @@ s32 EnOssan_FacingShopkeeperDialogResult(EnOssan* this, GlobalContext* globalCtx func_8019F208(); if (this->actor.params == ENOSSAN_PART_TIME_WORKER && player->transformation == PLAYER_FORM_ZORA) { this->animationIdx = 9; - func_8013BC6C(&this->skelAnime, animations, 9); + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 9); } EnOssan_SetupAction(this, EnOssan_TalkToShopkeeper); func_80151938(globalCtx, sTalkOptionTextIds[this->actor.params]); @@ -612,12 +624,12 @@ void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_TalkToShopkeeper(EnOssan* this, GlobalContext* globalCtx) { - ActorAnimationEntryS* animations = sAnimations[this->actor.params]; + AnimationInfoS* animations = sAnimations[this->actor.params]; if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { if (this->animationIdx == 9 && this->actor.params == ENOSSAN_PART_TIME_WORKER) { this->animationIdx = 1; - func_8013BC6C(&this->skelAnime, animations, 1); + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); } EnOssan_StartShopping(globalCtx, this); } @@ -1476,7 +1488,7 @@ void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx) { this->shopItemSelectedTween = 0.0f; Actor_SetScale(&this->actor, sActorScales[this->actor.params]); this->animationIdx = 1; - func_8013BC6C(&this->skelAnime, sAnimations[this->actor.params], 1); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations[this->actor.params], 1); EnOssan_SpawnShopItems(this, globalCtx, shopItems); this->blinkTimer = 20; this->eyeTexIndex = 0; diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index 83538be6d..7dc501cfe 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -95,10 +95,10 @@ static ColliderCylinderInit sCylinderInit = { { 5, 33, -20, { 0, 0, 0 } }, }; -static struct_80B8E1A8 sAnimations[] = { - { &object_ot_Anim_004B30, 1.0f, 0, -5.0f }, - { &object_ot_Anim_0008D8, 1.0f, 0, -5.0f }, - { &object_ot_Anim_000420, 1.0f, 0, 0.0f }, +static AnimationSpeedInfo sAnimations[] = { + { &object_ot_Anim_004B30, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &object_ot_Anim_0008D8, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &object_ot_Anim_000420, 1.0f, ANIMMODE_LOOP, 0.0f }, }; static InitChainEntry sInitChain[] = { @@ -152,10 +152,10 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ot_Skel_004800, &object_ot_Anim_0008D8, this->jointTable, this->morphTable, 19); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - Animation_Change(&this->skelAnime, sAnimations[0].animationSeg, 1.0f, - Animation_GetLastFrame(&sAnimations[0].animationSeg->common) * Rand_ZeroOne(), - Animation_GetLastFrame(&sAnimations[0].animationSeg->common), sAnimations[0].mode, - sAnimations[0].transitionRate); + Animation_Change(&this->skelAnime, sAnimations[0].animation, 1.0f, + Animation_GetLastFrame(&sAnimations[0].animation->common) * Rand_ZeroOne(), + Animation_GetLastFrame(&sAnimations[0].animation->common), sAnimations[0].mode, + sAnimations[0].morphFrames); this->unk_346 = ENOT_GET_7F(&this->actor); this->unk_344 = this->actor.world.rot.z; this->actor.world.rot.z = 0; @@ -163,7 +163,7 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.gravity = 0.0f; func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->skelAnime.curFrame = Rand_ZeroOne() * this->skelAnime.endFrame; this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); this->unk_744.r = 255; @@ -300,7 +300,7 @@ void func_80B5BB38(Color_RGB8* arg0, Color_RGB8* arg1, f32 arg2) { } void func_80B5BDA8(EnOt* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, sAnimations, 1, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIdx); func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); this->actionFunc = func_80B5BE04; } @@ -322,7 +322,7 @@ void func_80B5BE04(EnOt* this, GlobalContext* globalCtx) { } void func_80B5BE88(EnOt* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, sAnimations, 1, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIdx); this->actionFunc = func_80B5BED4; } @@ -337,7 +337,7 @@ void func_80B5BED4(EnOt* this, GlobalContext* globalCtx) { void func_80B5BF60(EnOt* this, GlobalContext* globalCtx) { this->unk_32C |= 0x40; - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->actionFunc = func_80B5BFB8; } @@ -410,8 +410,8 @@ void func_80B5C25C(EnOt* this, GlobalContext* globalCtx) { if ((this->unk_33C == 2) && (this->unk_32C & 0x80) && (this->unk_360->unk_32C & 0x80)) { this->unk_32C |= 0x100; this->unk_360->unk_32C |= 0x100; - func_8013E1C8(&this->skelAnime, sAnimations, 2, &this->animIdx); - func_8013E1C8(&this->unk_360->skelAnime, sAnimations, 2, &this->unk_360->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 2, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->unk_360->skelAnime, sAnimations, 2, &this->unk_360->animIdx); this->actor.flags |= 0x8000000; this->actor.flags &= ~(0x8 | 0x1); this->unk_360->actor.flags |= 0x8000000; @@ -489,7 +489,7 @@ void func_80B5C64C(EnOt* this, GlobalContext* globalCtx) { void func_80B5C684(EnOt* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->actionFunc = func_80B5C6DC; } @@ -635,7 +635,7 @@ void func_80B5CCA0(EnOt* this, GlobalContext* globalCtx) { } void func_80B5CCF4(EnOt* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->actionFunc = func_80B5CD40; } @@ -676,7 +676,7 @@ void func_80B5CD40(EnOt* this, GlobalContext* globalCtx) { void func_80B5CE6C(EnOt* this, GlobalContext* globalCtx) { this->unk_384 = 0; this->unk_32C |= 0x20; - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->actionFunc = func_80B5CEC8; } @@ -731,7 +731,7 @@ void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx) { } void func_80B5D114(EnOt* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->actionFunc = func_80B5D160; } @@ -891,7 +891,7 @@ void func_80B5D648(EnOt* this, GlobalContext* globalCtx) { this->unk_2C0.unk_2C.z = 0.0f; this->actor.gravity = 0.0f; this->actor.speedXZ = 0.0f; - func_8013E1C8(&this->skelAnime, sAnimations, 1, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIdx); this->actor.flags |= 0x8000000; this->actor.flags &= ~(0x8 | 0x1); Flags_SetSwitch(globalCtx, ENOT_GET_3F80(&this->actor)); diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index 1b6059607..644c0d5e9 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -41,7 +41,7 @@ void func_8095C484(EnOwl* this); void func_8095CCF4(Actor* thisx, GlobalContext* globalCtx); void func_8095D074(Actor* thisx, GlobalContext* globalCtx); void EnOwl_ChangeMode(EnOwl* this, EnOwlActionFunc actionFunc, EnOwlFunc unkFunc, SkelAnime* skelAnime, - AnimationHeader* animationSeg, f32 transitionRate); + AnimationHeader* animation, f32 morphFrames); typedef enum { /* 0x00 */ OWL_REPEAT, @@ -1191,10 +1191,9 @@ void func_8095D074(Actor* thisx, GlobalContext* globalCtx) { } void EnOwl_ChangeMode(EnOwl* this, EnOwlActionFunc actionFunc, EnOwlFunc unkFunc, SkelAnime* skelAnime, - AnimationHeader* animationSeg, f32 transitionRate) { + AnimationHeader* animation, f32 morphFrames) { this->skelAnime3 = skelAnime; - Animation_Change(this->skelAnime3, animationSeg, 1.0f, 0.0f, Animation_GetLastFrame(animationSeg), 2, - transitionRate); + Animation_Change(this->skelAnime3, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), 2, morphFrames); this->actionFunc = actionFunc; this->unk_414 = unkFunc; } diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index d445b962d..371386f58 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -106,14 +106,20 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { 0, 0, 0, 0, MASS_IMMOVABLE, }; -static ActorAnimationEntry sAnimations[] = { - { &object_pamera_Anim_0005BC, 1.0f, 0, 0.0f, 0, -4.0f }, { &object_pamera_Anim_008AE0, 1.0f, 0, 0.0f, 0, -4.0f }, - { &object_pamera_Anim_008E38, 1.0f, 0, 0.0f, 0, -4.0f }, { &object_pamera_Anim_00A844, 1.0f, 0, 0.0f, 0, -4.0f }, - { &object_pamera_Anim_00B0C4, 1.0f, 0, 0.0f, 0, -4.0f }, { &object_pamera_Anim_009870, 1.0f, 0, 0.0f, 0, 0.0f }, - { &object_pamera_Anim_009F54, 1.0f, 0, 0.0f, 0, 0.0f }, { &object_pamera_Anim_00B5B0, 1.0f, 0, 0.0f, 0, 0.0f }, - { &object_pamera_Anim_00BCC4, 1.0f, 0, 0.0f, 0, 0.0f }, { &object_pamera_Anim_00D9DC, 1.0f, 0, 0.0f, 0, 0.0f }, - { &object_pamera_Anim_00E16C, 1.0f, 0, 0.0f, 0, 0.0f }, { &object_pamera_Anim_00C9F4, 1.0f, 0, 0.0f, 2, 0.0f }, - { &object_pamera_Anim_00D0F0, 1.0f, 0, 0.0f, 0, 0.0f }, +static AnimationInfo sAnimations[] = { + { &object_pamera_Anim_0005BC, 1.0f, 0, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_pamera_Anim_008AE0, 1.0f, 0, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_pamera_Anim_008E38, 1.0f, 0, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_pamera_Anim_00A844, 1.0f, 0, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_pamera_Anim_00B0C4, 1.0f, 0, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_pamera_Anim_009870, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_pamera_Anim_009F54, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_pamera_Anim_00B5B0, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_pamera_Anim_00BCC4, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_pamera_Anim_00D9DC, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_pamera_Anim_00E16C, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_pamera_Anim_00C9F4, 1.0f, 0, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_pamera_Anim_00D0F0, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, }; static Vec3f D_80BDA5F0 = { 1000.0f, 0.0f, 0.0f }; @@ -227,7 +233,7 @@ void EnPamera_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80BD8700(EnPamera* this) { this->hideInisdeTimer = 0; this->actor.flags &= ~1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BD8758; } @@ -237,7 +243,7 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[0], &this->actor); func_800E02AC(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->cutscenes[0])), &this->actor); this->actor.speedXZ = 1.5f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actor.shape.rot.y = this->actor.home.rot.y; this->actor.world.rot.y = this->actor.home.rot.y; func_80BD9338(this, globalCtx); @@ -246,7 +252,7 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscenes[0]); } else { this->actor.speedXZ = 1.5f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actor.shape.rot.y = this->actor.home.rot.y; this->actor.world.rot.y = this->actor.home.rot.y; func_80BD9338(this, globalCtx); @@ -268,7 +274,7 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { void func_80BD8908(EnPamera* this) { this->actor.draw = EnPamera_Draw; this->actor.flags |= 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80BD8964; } @@ -281,14 +287,14 @@ void func_80BD8964(EnPamera* this, GlobalContext* globalCtx) { if (Math_Vec3f_StepTo(&this->actor.world.pos, &vec, 1.0f) < 5.0f) { this->actor.speedXZ = 1.5f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); gSaveContext.weekEventReg[59] |= 1; func_80BD8B50(this); } } void func_80BD8A38(EnPamera* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80BD8A7C; } @@ -335,14 +341,14 @@ void func_80BD8B70(EnPamera* this, GlobalContext* globalCtx) { void func_80BD8CCC(EnPamera* this) { this->hideInisdeTimer = 0; this->actor.speedXZ = 0.0f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); this->actionFunc = func_80BD8D1C; } void func_80BD8D1C(EnPamera* this, GlobalContext* globalCtx) { if (this->hideInisdeTimer++ > 200) { this->actor.speedXZ = 1.5f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); func_80BD8D80(this); } } @@ -378,14 +384,14 @@ void func_80BD8DB0(EnPamera* this, GlobalContext* globalCtx) { void EnPamera_LookDownWell(EnPamera* this) { func_80BD93CC(this, 1, 1); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); this->actionFunc = func_80BD8F60; } void func_80BD8F60(EnPamera* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x3000, 0x1000); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->actor.speedXZ = 3.0f; func_80BD93CC(this, 0, 0); func_80BD8D80(this); @@ -402,7 +408,7 @@ void func_80BD8FF0(EnPamera* this) { pameraYaw = Math_Vec3f_Yaw(&pameraPos, &this->actor.world.pos); this->actor.shape.rot.y = pameraYaw; this->actor.world.rot.y = pameraYaw; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); this->actionFunc = func_80BD909C; } @@ -738,7 +744,7 @@ void func_80BD9E78(EnPamera* this, GlobalContext* globalCtx) { } void func_80BD9E88(EnPamera* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->unk_31E = 0; this->setupFunc = func_80BD9ED0; } @@ -747,7 +753,7 @@ void func_80BD9ED0(EnPamera* this, GlobalContext* globalCtx) { } void func_80BD9EE0(EnPamera* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); func_80BD93CC(this, 1, 0); this->unk_31E = 1; this->setupFunc = func_80BD9F3C; @@ -764,14 +770,14 @@ void func_80BD9F3C(EnPamera* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); } } } void func_80BDA038(EnPamera* this) { func_80BD93CC(this, 0, 1); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); this->unk_31E = 0; this->setupFunc = func_80BDA090; } @@ -781,7 +787,7 @@ void func_80BDA090(EnPamera* this, GlobalContext* globalCtx) { void func_80BDA0A0(EnPamera* this) { func_80BD93CC(this, 0, 1); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); this->unk_31E = 1; this->setupFunc = func_80BDA0FC; } @@ -791,7 +797,7 @@ void func_80BDA0FC(EnPamera* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); } } } @@ -799,7 +805,7 @@ void func_80BDA0FC(EnPamera* this, GlobalContext* globalCtx) { void func_80BDA170(EnPamera* this) { this->unk_31E = 1; func_80BD93CC(this, 0, 1); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); this->setupFunc = func_80BDA1C8; } @@ -812,7 +818,7 @@ void func_80BDA1C8(EnPamera* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); } } } @@ -820,7 +826,7 @@ void func_80BDA1C8(EnPamera* this, GlobalContext* globalCtx) { void func_80BDA288(EnPamera* this) { this->unk_31E = 1; func_80BD93CC(this, 0, 0); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); this->setupFunc = func_80BDA2E0; } @@ -828,7 +834,7 @@ void func_80BDA2E0(EnPamera* this, GlobalContext* globalCtx) { if (this->unk_31E == 1) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); } } } diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 6b3940665..ad008c3e9 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -230,14 +230,21 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS sAnimations[] = { - { &object_mm_Anim_002238, 1.0f, 0, -1, 0, 0 }, { &object_mm_Anim_002238, 1.0f, 0, -1, 0, -4 }, - { &object_mm_Anim_00A4E0, 1.0f, 0, -1, 2, 0 }, { &object_mm_Anim_00B09C, 1.0f, 0, -1, 0, 0 }, - { &object_mm_Anim_00B09C, 1.0f, 0, -1, 0, -4 }, { &object_mm_Anim_00BA78, 1.0f, 0, -1, 2, 0 }, - { &object_mm_Anim_00C32C, 1.0f, 0, -1, 0, -4 }, { &object_mm_Anim_0099B4, 1.0f, 0, -1, 0, 0 }, - { &object_mm_Anim_000FC4, 1.0f, 0, -1, 0, 0 }, { &object_mm_Anim_00A8D8, 1.0f, 0, -1, 0, 0 }, - { &object_mm_Anim_00099C, 1.0f, 0, -1, 0, 0 }, { &object_mm_Anim_001F84, 1.0f, 0, -1, 2, 0 }, - { &object_mm_Anim_000468, 1.0f, 0, -1, 0, 0 }, { &object_mm_Anim_00C640, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_mm_Anim_002238, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_002238, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_mm_Anim_00A4E0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_mm_Anim_00B09C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_00B09C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_mm_Anim_00BA78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_mm_Anim_00C32C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_mm_Anim_0099B4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_000FC4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_00A8D8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_00099C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_001F84, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_mm_Anim_000468, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_00C640, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; s32 func_80AF7B40(void) { @@ -415,7 +422,7 @@ s32 func_80AF7E98(EnPm* this, s32 arg1) { if (phi_v1) { this->unk_384 = arg1; - ret = func_8013BC6C(&this->skelAnime, sAnimations, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); this->unk_35C = this->skelAnime.playSpeed; } diff --git a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c index 8f1500810..0c18be89a 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c @@ -62,14 +62,20 @@ const ActorInit En_Rail_Skb_InitVars = { (ActorFunc)EnRailSkb_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_skb_Anim_0064E0, 0.96f, 0.0f, 0.0f, 0, -4.0f }, { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -1.0f }, - { &object_skb_Anim_002190, 0.6f, 0.0f, 0.0f, 3, 4.0f }, { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, 2, -4.0f }, - { &object_skb_Anim_00270C, 1.0f, 0.0f, 0.0f, 2, -4.0f }, { &object_skb_Anim_00697C, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_skb_Anim_006D90, 1.0f, 0.0f, 0.0f, 0, -4.0f }, { &object_skb_Anim_001D1C, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -16.0f }, - { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_skb_Anim_0015EC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_skb_Anim_0009E4, 1.0f, 0.0f, 0.0f, 0, -8.0f }, +static AnimationInfo sAnimations[] = { + { &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 }, }; static ColliderJntSphElementInit sJntSphElementsInit[2] = { @@ -306,7 +312,7 @@ void EnRailSkb_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80B70FA0(EnRailSkb* this) { this->unk_3F2 = 0; if (this->actionFunc != func_80B716A8) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); } this->actionFunc = func_80B70FF8; } @@ -350,7 +356,7 @@ void func_80B7114C(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_2EC = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_402 |= 1; func_80B712FC(this); @@ -374,7 +380,7 @@ void func_80B7123C(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_2EC = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_402 |= 1; func_80B712FC(this); @@ -400,7 +406,7 @@ void func_80B71314(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71354(EnRailSkb* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->actionFunc = func_80B713A4; } @@ -409,7 +415,7 @@ void func_80B713A4(EnRailSkb* this, GlobalContext* globalCtx) { if ((this->actor.xzDistToPlayer > 65.0f) || (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN)) { func_80B70FA0(this); } else { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); } } @@ -450,7 +456,7 @@ void func_80B7151C(EnRailSkb* this) { this->actor.draw = EnRailSkb_Draw; this->actor.shape.shadowAlpha = 0; this->actor.shape.rot.y = this->actor.world.rot.y; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80B715AC; } @@ -473,7 +479,7 @@ void func_80B715AC(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71650(EnRailSkb* this) { this->unk_3FE = 0; if (this->actionFunc != func_80B70FF8) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); } this->actionFunc = func_80B716A8; } @@ -490,7 +496,7 @@ void func_80B716A8(EnRailSkb* this, GlobalContext* globalCtx) { func_801518B0(globalCtx, 0x13F5, &this->actor); this->unk_400 = 0x13F5; } - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); func_80B717C8(this); } else if ((this->actor.xzDistToPlayer < 100.0f) && !(this->collider.base.acFlags & AC_HIT)) { func_800B8614(&this->actor, globalCtx, 100.0f); @@ -552,7 +558,7 @@ void func_80B718C4(EnRailSkb* this, GlobalContext* globalCtx) { } void func_80B71910(EnRailSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80B71954; } @@ -570,7 +576,7 @@ void func_80B71954(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71A08(EnRailSkb* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->actionFunc = func_80B71A58; } @@ -579,7 +585,7 @@ void func_80B71A58(EnRailSkb* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); if (this->unk_2E8 < this->unk_22C->actor.colChkInfo.health) { this->unk_22C->actor.colChkInfo.health--; } else { @@ -602,7 +608,7 @@ void func_80B71A58(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71B6C(EnRailSkb* this) { this->unk_3F2 = 10; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80B71BB8; } @@ -635,7 +641,7 @@ void func_80B71BB8(EnRailSkb* this, GlobalContext* globalCtx) { if ((sp34 < 50.0f) && (this->actor.bgCheckFlags & 1)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); this->actor.velocity.y = 10.0f; for (i = 0; i < 4; i++) { @@ -668,7 +674,7 @@ void func_80B71DF0(EnRailSkb* this) { this->unk_3F0 = 0; } - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); this->actionFunc = func_80B71EA8; } @@ -994,7 +1000,7 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_2F0 = 0.0f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); this->unk_402 |= 1; func_80B712FC(this); break; @@ -1020,7 +1026,7 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_2F0 = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_80B71228(this); break; @@ -1037,7 +1043,7 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { case 13: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_80B712FC(this); break; 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 37d1d120e..6738c44ab 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -60,17 +60,27 @@ const ActorInit En_Railgibud_InitVars = { (ActorFunc)EnRailgibud_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_rd_Anim_006678, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_rd_Anim_006B08, 0.5f, 0.0f, 0.0f, 3, 0.0f }, - { &object_rd_Anim_006EEC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_0073A4, 0.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_rd_Anim_007BBC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_0081A8, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_009298, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_009900, 1.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_rd_Anim_00A450, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_00ABE0, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_0113EC, 0.4f, 0.0f, 0.0f, 1, -8.0f }, { &object_rd_Anim_01216C, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_0118D8, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_rd_Anim_011DB8, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_00A450, 3.0f, 0.0f, 0.0f, 2, -6.0f }, { &object_rd_Anim_005DF4, 1.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_rd_Anim_0061E4, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_rd_Anim_001600, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_0009C4, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_000F1C, 1.0f, 0.0f, 0.0f, 0, -8.0f }, +static AnimationInfo sAnimations[] = { + { &object_rd_Anim_006678, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_rd_Anim_006B08, 0.5f, 0.0f, 0.0f, ANIMMODE_ONCE_INTERP, 0.0f }, + { &object_rd_Anim_006EEC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_rd_Anim_0073A4, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_rd_Anim_007BBC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_rd_Anim_0081A8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_rd_Anim_009298, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_rd_Anim_009900, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_rd_Anim_00A450, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_rd_Anim_00ABE0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_rd_Anim_0113EC, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -8.0f }, + { &object_rd_Anim_01216C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_rd_Anim_0118D8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_rd_Anim_011DB8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_rd_Anim_00A450, 3.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -6.0f }, + { &object_rd_Anim_005DF4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_rd_Anim_0061E4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_rd_Anim_001600, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_rd_Anim_0009C4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_rd_Anim_000F1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -219,7 +229,7 @@ void EnRailgibud_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80BA57A8(EnRailgibud* this) { this->actor.speedXZ = 0.6f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); this->actionFunc = func_80BA57F8; } @@ -267,7 +277,7 @@ void func_80BA57F8(EnRailgibud* this, GlobalContext* globalCtx) { } void func_80BA59F0(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); this->actionFunc = func_80BA5A34; } @@ -287,7 +297,7 @@ void func_80BA5A34(EnRailgibud* this, GlobalContext* globalCtx) { } void func_80BA5AF0(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); this->actor.speedXZ = 0.4f; if (this->actionFunc == func_80BA5A34) { this->unk_3F2 = 80; @@ -342,7 +352,7 @@ void func_80BA5B64(EnRailgibud* this, GlobalContext* globalCtx) { } void func_80BA5DBC(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->actor.flags &= ~1; this->unk_3F2 = 0; this->unk_3F0 = 0; @@ -360,9 +370,9 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { sp34 = func_80BA7088(this, globalCtx); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (sp34 == 1)) { this->unk_3F0 = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); } else if (!(player->stateFlags2 & 0x80)) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actor.flags |= 1; this->unk_3F0 = 2; this->unk_3F2 = 0; @@ -391,7 +401,7 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { player->stateFlags2 &= ~0x80; player->unk_AE8 = 100; } - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actor.flags |= 1; this->unk_3F0 = 2; this->unk_3F2 = 0; @@ -411,7 +421,7 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { } void func_80BA6054(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->actor.speedXZ = -2.0f; this->actionFunc = func_80BA60B0; @@ -433,7 +443,7 @@ void func_80BA60B0(EnRailgibud* this, GlobalContext* globalCtx) { void func_80BA6158(EnRailgibud* this) { this->unk_3F2 = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); this->actionFunc = func_80BA61A0; } @@ -450,7 +460,7 @@ void func_80BA61A0(EnRailgibud* this, GlobalContext* globalCtx) { } void func_80BA6284(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); this->actor.speedXZ = 0.4f; this->actionFunc = func_80BA62D4; } @@ -482,7 +492,7 @@ void func_80BA62D4(EnRailgibud* this, GlobalContext* globalCtx) { } void func_80BA6440(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->unk_3F2 = 0; this->unk_3F4 = 0; @@ -535,7 +545,7 @@ void func_80BA6604(EnRailgibud* this, GlobalContext* globalCtx) { } void func_80BA6664(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); this->actor.flags &= ~1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); this->unk_3F2 = 0; @@ -1050,37 +1060,37 @@ s32 func_80BA7DC8(EnRailgibud* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.npcActions[sp2C]->unk0) { case 1: this->unk_3F0 = 9; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); break; case 2: this->unk_3F0 = 15; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_WEAKENED2); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 15); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 15); break; case 3: this->unk_3F0 = 17; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 17); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 17); break; case 4: this->unk_3F0 = 18; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 18); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 18); break; case 5: this->unk_3F0 = 10; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); break; } } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (this->unk_3F0 == 15) { this->unk_3F0 = 16; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 16); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 16); } else if (this->unk_3F0 == 18) { this->unk_3F0 = 19; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 19); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 19); func_80BA7D14(this); } } diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index b2c9c9c61..97f4fd3a5 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -118,9 +118,9 @@ s32 D_80BF57E4[][4] = { { 56, 34, 44, 41 }, { 60, 38, 50, 45 }, { 67, 42, 55, 49 }, { 74, 47, 61, 54 }, }; -ActorAnimationEntryS D_80BF5914[] = { - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, 0 }, - { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, 2, 0 }, +AnimationInfoS D_80BF5914[] = { + { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; TexturePtr D_80BF5934[] = { @@ -303,7 +303,7 @@ s32 func_80BF409C(EnRg* this, s32 arg1) { if (arg1 != this->unk_334) { this->unk_334 = arg1; - ret = func_8013BC6C(&this->skelAnime, D_80BF5914, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80BF5914, arg1); this->unk_314 = this->skelAnime.playSpeed; } return ret; @@ -677,7 +677,7 @@ void func_80BF4EBC(EnRg* this, GlobalContext* globalCtx) { this->unk_318 = Rand_S16Offset(0, 20); } } - func_8013D9C8(globalCtx, this->unk_32E, this->unk_328, ARRAY_COUNT(this->unk_328)); + SubS_FillLimbRotTables(globalCtx, this->unk_32E, this->unk_328, ARRAY_COUNT(this->unk_328)); } void func_80BF4FC4(EnRg* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c index cd7bcf6fa..0dc71d3df 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c @@ -30,10 +30,10 @@ const ActorInit En_Rsn_InitVars = { (ActorFunc)EnRsn_Draw, }; -static ActorAnimationEntry animations[] = { { &object_rs_Anim_00788C, 1.0f, 0.0f, 0.0f, 0, 0.0f } }; +static AnimationInfo sAnimations[] = { { &object_rs_Anim_00788C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f } }; void func_80C25D40(EnRsn* this) { - Actor_ChangeAnimation(&this->skelAnime, animations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80C25D84; } diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c index 2b45e7304..eecf3c8ff 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -64,19 +64,30 @@ static ColliderCylinderInitType1 sCylinderInit = { { 27, 32, 0, { 0, 0, 0 } }, }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dnt_Anim_005488, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_00B0B4, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_004AA0, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_004E38, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_0029E8, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_005CA8, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_0038CC, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_003CC0, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_0012F4, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_004700, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001BC8, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_003438, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001E2C, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_000994, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_002268, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_002F08, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_00577C, 1.0f, 0, -1, 0, -4 }, { &object_dnt_Anim_0029E8, 1.0f, 8, -1, 2, 0 }, - { &object_dnt_Anim_0029E8, 1.0f, 4, -1, 2, -4 }, { &object_dnt_Anim_0029E8, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001BC8, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_0012F4, -1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_002670, 1.0f, 0, -1, 2, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_dnt_Anim_005488, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_00B0B4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_004AA0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_004E38, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0029E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_005CA8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0038CC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_003CC0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_0012F4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_004700, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001BC8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_003438, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001E2C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_000994, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_002268, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_002F08, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_00577C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnt_Anim_0029E8, 1.0f, 8, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0029E8, 1.0f, 4, -1, ANIMMODE_ONCE, -4 }, + { &object_dnt_Anim_0029E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001BC8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_0012F4, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_002670, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; Gfx* D_80BCCCDC[] = { gameplay_keep_DL_0527F0, gameplay_keep_DL_0528B0 }; @@ -186,7 +197,7 @@ void func_80BCAFA8(EnScopenuts* this, GlobalContext* globalCtx) { if (sp1C.y < 150.0f) { this->actor.draw = EnScopenuts_Draw; this->unk_348 = 10; - func_8013BC6C(&this->skelAnime, sAnimations, 10); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 10); this->actionFunc = func_80BCB078; } } @@ -235,7 +246,7 @@ void func_80BCB1C8(EnScopenuts* this, GlobalContext* globalCtx) { void func_80BCB230(EnScopenuts* this, GlobalContext* globalCtx) { s16 sp26 = this->skelAnime.curFrame; - s16 sp24 = Animation_GetLastFrame(sAnimations[this->unk_348].animationSeg); + s16 sp24 = Animation_GetLastFrame(sAnimations[this->unk_348].animation); Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); @@ -246,30 +257,30 @@ void func_80BCB230(EnScopenuts* this, GlobalContext* globalCtx) { this->unk_348 = 3; this->collider.dim.height = 64; func_80BCAC40(this, globalCtx); - func_8013BC6C(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); } else if (sp26 == sp24) { if ((this->unk_348 == 4) || (this->unk_348 == 18)) { this->unk_348 = 17; this->collider.dim.height = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); - func_8013BC6C(&this->skelAnime, sAnimations, 17); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 17); } else if (this->unk_348 == 2) { this->unk_348 = 16; this->collider.dim.height = 32; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); - func_8013BC6C(&this->skelAnime, sAnimations, 16); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 16); } else if (this->unk_348 == 17) { if (DECR(this->unk_34E) == 0) { this->unk_34E = Rand_ZeroOne() * 10.0f; this->unk_348 = 2; this->collider.dim.height = 32; - func_8013BC6C(&this->skelAnime, sAnimations, 2); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 2); } } else if ((this->unk_348 == 16) && (DECR(this->unk_34E) == 0)) { this->unk_34E = Rand_S16Offset(40, 40); this->unk_348 = 18; this->collider.dim.height = 32; - func_8013BC6C(&this->skelAnime, sAnimations, 18); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 18); } } } @@ -277,7 +288,7 @@ void func_80BCB230(EnScopenuts* this, GlobalContext* globalCtx) { void func_80BCB4DC(EnScopenuts* this, GlobalContext* globalCtx) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { this->actionFunc = func_80BCB52C; - func_8013BC6C(&this->skelAnime, sAnimations, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 0); } } @@ -295,7 +306,7 @@ void func_80BCB52C(EnScopenuts* this, GlobalContext* globalCtx) { } else if (!(((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false) || !((this->actor.xzDistToPlayer < 200.0f) ? true : false)) { this->unk_348 = 4; - func_8013BC6C(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); this->actionFunc = func_80BCB230; } } @@ -312,7 +323,7 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; this->unk_328 &= ~4; this->unk_348 = 8; - func_8013BC6C(&this->skelAnime, sAnimations, 8); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 8); this->actionFunc = func_80BCBA00; } else { this->unk_33C = func_80BCAF0C(this); @@ -377,7 +388,7 @@ void func_80BCB980(EnScopenuts* this, GlobalContext* globalCtx) { void func_80BCBA00(EnScopenuts* this, GlobalContext* globalCtx) { s16 sp26 = this->skelAnime.curFrame; - s16 sp24 = Animation_GetLastFrame(sAnimations[this->unk_348].animationSeg); + s16 sp24 = Animation_GetLastFrame(sAnimations[this->unk_348].animation); switch (sp26) { case 10: @@ -452,7 +463,7 @@ void func_80BCBA00(EnScopenuts* this, GlobalContext* globalCtx) { if (sp26 == sp24) { this->unk_35A = 3; this->unk_348 = 19; - func_8013BC6C(&this->skelAnime, sAnimations, 19); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 19); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->unk_328 &= ~2; this->unk_34E = 50; @@ -487,7 +498,7 @@ void func_80BCBC60(EnScopenuts* this, GlobalContext* globalCtx) { void func_80BCBD28(EnScopenuts* this, GlobalContext* globalCtx) { Vec3f sp44; s16 sp42 = this->skelAnime.curFrame; - s16 sp40 = Animation_GetLastFrame(sAnimations[this->unk_348].animationSeg); + s16 sp40 = Animation_GetLastFrame(sAnimations[this->unk_348].animation); Vec3s sp38; func_80BCC448(this->path, this->unk_334, &this->actor.world.pos, &sp38); @@ -516,7 +527,7 @@ void func_80BCBD28(EnScopenuts* this, GlobalContext* globalCtx) { if ((this->actor.home.pos.y + 22.5f) < this->actor.world.pos.y) { this->unk_368 = 0.3f; this->unk_348 = 9; - func_8013BC6C(&this->skelAnime, sAnimations, 9); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 9); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); func_80BCAC40(this, globalCtx); this->actionFunc = func_80BCBF0C; @@ -536,7 +547,7 @@ void func_80BCBF0C(EnScopenuts* this, GlobalContext* globalCtx) { if ((this->actor.home.pos.y + 50.0f) < this->actor.world.pos.y) { Math_ApproachF(&this->actor.velocity.y, 0.0f, 0.2f, 1.0f); this->unk_348 = 10; - func_8013BC6C(&this->skelAnime, sAnimations, 10); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 10); this->unk_328 |= 2; this->unk_36E = 0; this->actionFunc = func_80BCBFFC; @@ -716,7 +727,7 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_358 = 150; this->unk_348 = 4; this->unk_35A = 0; - func_8013BC6C(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); this->actionFunc = func_80BCB230; } } else { diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c index 0c2483ac9..588aedf3d 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -35,11 +35,7 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx); s32 func_80ADCE4C(EnSellnuts* this, Path* path, s32 arg2); f32 func_80ADCFE8(Path* path, s32 arg1, Vec3f* pos, Vec3s* arg3); -static u16 D_80ADD910[] = { - 0x0614, - 0x060E, - 0x0628, -}; +static u16 D_80ADD910[] = { 0x0614, 0x060E, 0x0628 }; static u16 D_80ADD918[] = { 0x0616, 0x0610, 0x0629 }; @@ -84,19 +80,30 @@ static ColliderCylinderInitType1 sCylinderInit = { { 27, 32, 0, { 0, 0, 0 } }, }; -static ActorAnimationEntryS D_80ADD990[] = { - { &object_dnt_Anim_005488, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_00B0B4, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_004AA0, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_004E38, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_0029E8, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_005CA8, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_0038CC, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_003CC0, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_0012F4, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_004700, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001BC8, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_003438, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001E2C, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_000994, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_002268, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_002F08, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_00577C, 1.0f, 0, -1, 0, -4 }, { &object_dnt_Anim_0029E8, 1.0f, 8, -1, 2, 0 }, - { &object_dnt_Anim_0029E8, 1.0f, 4, -1, 2, -4 }, { &object_dnt_Anim_0029E8, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001BC8, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_0012F4, -1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_002670, 1.0f, 0, -1, 2, 0 }, +static AnimationInfoS D_80ADD990[] = { + { &object_dnt_Anim_005488, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_00B0B4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_004AA0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_004E38, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0029E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_005CA8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0038CC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_003CC0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_0012F4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_004700, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001BC8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_003438, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001E2C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_000994, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_002268, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_002F08, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_00577C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnt_Anim_0029E8, 1.0f, 8, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0029E8, 1.0f, 4, -1, ANIMMODE_ONCE, -4 }, + { &object_dnt_Anim_0029E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001BC8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_0012F4, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_002670, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; static InitChainEntry sInitChain[] = { @@ -228,25 +235,25 @@ f32 func_80ADB08C(GlobalContext* globalCtx) { void func_80ADB0D8(EnSellnuts* this, GlobalContext* globalCtx) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); if (currentFrame == frameCount) { switch (this->unk_340) { case 0x611: case 0x62A: this->unk_34C = 0; - func_8013BC6C(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); this->actionFunc = func_80ADBFA0; break; case 0x618: if (this->unk_34C == 1) { this->unk_34C = 0; - func_8013BC6C(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); this->actionFunc = func_80ADB544; } else { this->unk_34C = 1; - func_8013BC6C(&this->skelAnime, D_80ADD990, 1); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 1); this->actionFunc = func_80ADBFA0; } break; @@ -257,7 +264,7 @@ void func_80ADB0D8(EnSellnuts* this, GlobalContext* globalCtx) { case 0x614: case 0x628: this->unk_34C = 0; - func_8013BC6C(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); this->actionFunc = func_80ADB924; break; @@ -266,14 +273,14 @@ void func_80ADB0D8(EnSellnuts* this, GlobalContext* globalCtx) { case 0x616: case 0x629: this->unk_34C = 1; - func_8013BC6C(&this->skelAnime, D_80ADD990, 1); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 1); this->actionFunc = func_80ADB924; break; case 0x613: case 0x619: this->unk_34C = 7; - func_8013BC6C(&this->skelAnime, D_80ADD990, 7); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 7); this->actionFunc = func_80ADBD64; break; } @@ -282,7 +289,7 @@ void func_80ADB0D8(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADB254(EnSellnuts* this, GlobalContext* globalCtx) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); if (((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f) ? true : false) && @@ -291,31 +298,31 @@ void func_80ADB254(EnSellnuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80ADB4F4; this->unk_34C = 3; this->collider.dim.height = 64; - func_8013BC6C(&this->skelAnime, D_80ADD990, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 3); } else if (currentFrame == frameCount) { if ((this->unk_34C == 4) || (this->unk_34C == 18)) { this->unk_34C = 17; this->collider.dim.height = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); - func_8013BC6C(&this->skelAnime, D_80ADD990, 17); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 17); } else if (this->unk_34C == 2) { this->unk_34C = 16; this->collider.dim.height = 32; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); - func_8013BC6C(&this->skelAnime, D_80ADD990, 16); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 16); } else if (this->unk_34C == 17) { if (DECR(this->unk_34E) == 0) { this->unk_34E = Rand_ZeroOne() * 10.0f; this->unk_34C = 2; this->collider.dim.height = 32; - func_8013BC6C(&this->skelAnime, D_80ADD990, 2); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 2); } } else if (this->unk_34C == 16) { if (DECR(this->unk_34E) == 0) { this->unk_34E = Rand_S16Offset(40, 40); this->unk_34C = 18; this->collider.dim.height = 32; - func_8013BC6C(&this->skelAnime, D_80ADD990, 18); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 18); } } } @@ -324,7 +331,7 @@ void func_80ADB254(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADB4F4(EnSellnuts* this, GlobalContext* globalCtx) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { this->actionFunc = func_80ADB544; - func_8013BC6C(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); } } @@ -402,7 +409,7 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { if (!(((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false) || !((this->actor.xzDistToPlayer < 200.0f) ? true : false)) { this->unk_34C = 4; - func_8013BC6C(&this->skelAnime, D_80ADD990, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 4); this->actionFunc = func_80ADB254; } } @@ -447,18 +454,18 @@ void func_80ADB924(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADBAB8(EnSellnuts* this, GlobalContext* globalCtx) { u8 sp27 = Message_GetState(&globalCtx->msgCtx); s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); if (this->unk_368 == 0x28) { this->unk_34C = 5; - func_8013BC6C(&this->skelAnime, D_80ADD990, 5); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 5); } this->unk_368++; if ((currentFrame == frameCount) && (this->unk_34C == 5)) { this->unk_34C = 6; - func_8013BC6C(&this->skelAnime, D_80ADD990, 6); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 6); } if ((sp27 == 5) && func_80147624(globalCtx)) { @@ -500,11 +507,11 @@ void func_80ADBCE4(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADBD64(EnSellnuts* this, GlobalContext* globalCtx) { u8 sp27 = Message_GetState(&globalCtx->msgCtx); s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); if ((currentFrame == frameCount) && (this->unk_34C == 7)) { this->unk_34C = 0; - func_8013BC6C(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); } if ((sp27 == 5) && func_80147624(globalCtx)) { @@ -513,14 +520,14 @@ void func_80ADBD64(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_338 &= ~2; this->actor.flags &= ~1; this->unk_34C = 8; - func_8013BC6C(&this->skelAnime, D_80ADD990, 8); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 8); this->actionFunc = func_80ADBE80; } } void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); func_80ADAE64(this); if (this->unk_366 == 0) { @@ -539,7 +546,7 @@ void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx) { if (currentFrame == frameCount) { this->unk_350 = 4; this->unk_34C = 19; - func_8013BC6C(&this->skelAnime, D_80ADD990, 19); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 19); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->unk_338 &= ~1; this->unk_338 |= 8; @@ -573,7 +580,7 @@ void func_80ADC034(EnSellnuts* this, GlobalContext* globalCtx) { if ((this->actor.home.pos.y + 200.0f) < this->actor.world.pos.y) { Math_ApproachF(&this->actor.velocity.y, 0.0f, 0.2f, 1.0f); this->unk_34C = 10; - func_8013BC6C(&this->skelAnime, D_80ADD990, 10); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 10); this->unk_368 = 0; this->actionFunc = func_80ADC37C; } @@ -582,7 +589,7 @@ void func_80ADC034(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADC118(EnSellnuts* this, GlobalContext* globalCtx) { Vec3f sp34; s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); if (currentFrame == frameCount) { Math_SmoothStepToS(&this->unk_364, 0x1C71, 3, 0x100, 0); @@ -608,7 +615,7 @@ void func_80ADC118(EnSellnuts* this, GlobalContext* globalCtx) { if ((this->actor.home.pos.y + 22.5f) < this->actor.world.pos.y) { this->unk_34C = 9; this->unk_360 = 0.3f; - func_8013BC6C(&this->skelAnime, D_80ADD990, 9); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 9); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80ADC034; } @@ -786,7 +793,7 @@ void func_80ADC8C4(EnSellnuts* this, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; this->actor.velocity.y = -1.0f; this->actor.speedXZ = 0.0f; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); this->unk_338 &= ~1; this->unk_338 &= ~2; this->actionFunc = func_80ADCA64; @@ -801,7 +808,7 @@ void func_80ADC8C4(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); if (this->unk_34C == 22) { Math_SmoothStepToS(&this->unk_364, 0, 3, 0x100, 0); @@ -814,7 +821,7 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_350 = 4; this->unk_34C = 19; this->actor.velocity.y = 0.0f; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); } return; @@ -825,7 +832,7 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { if (this->unk_34C == 19) { this->unk_34C = 17; this->collider.dim.height = 0; - func_8013BC6C(&this->skelAnime, D_80ADD990, 17); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 17); } else if (this->unk_34C == 17) { ActorCutscene_Stop(this->cutscene); gSaveContext.weekEventReg[73] |= 4; @@ -836,7 +843,7 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADCC04(EnSellnuts* this, GlobalContext* globalCtx) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); if (this->unk_34C == 3) { if (currentFrame == frameCount) { @@ -845,7 +852,7 @@ void func_80ADCC04(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_354 = 1.0f; this->unk_358 = 1.0f; this->unk_35C = 1.0f; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); } } else if (this->unk_34C == 21) { func_80ADAFC0(this); @@ -856,7 +863,7 @@ void func_80ADCC04(EnSellnuts* this, GlobalContext* globalCtx) { } this->unk_340 = 0x626; this->unk_34C = 0; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); this->actionFunc = func_80ADC5A4; } } @@ -877,7 +884,7 @@ void func_80ADCD3C(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_34C = 3; this->unk_350 = 4; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); this->actionFunc = func_80ADCC04; } else if (D_80ADD940 != 0) { this->collider.dim.height = 64; @@ -982,7 +989,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; this->unk_34A = 50; this->unk_34C = 4; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); this->actionFunc = func_80ADB254; return; } @@ -1000,7 +1007,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_358 = 1.0f; this->unk_354 = 1.0f; this->unk_360 = 1.0f; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); this->actionFunc = func_80ADC5A4; } else { this->unk_338 |= 2; @@ -1011,7 +1018,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_34C = 4; this->unk_34E = 20; this->collider.dim.height = 64; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); this->actionFunc = func_80ADCD3C; } } diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index fb0f3d28c..bfa9cf782 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -49,14 +49,20 @@ void func_809964A0(EnSkb* this, GlobalContext* globalCtx); s32 func_80996594(EnSkb* this, GlobalContext* globalCtx); void func_80996BEC(EnSkb* this, GlobalContext* globalCtx); -static ActorAnimationEntry sAnimations[] = { - { &object_skb_Anim_0064E0, 1.0f, 0.0f, 0.0f, 0, -4.0 }, { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -1.0f }, - { &object_skb_Anim_002190, 0.6f, 0.0f, 0.0f, 3, 4.0f }, { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, 2, -4.0 }, - { &object_skb_Anim_00270C, 1.0f, 0.0f, 0.0f, 2, -4.0 }, { &object_skb_Anim_00697C, 1.0f, 0.0f, 0.0f, 0, -4.0 }, - { &object_skb_Anim_006D90, 1.0f, 0.0f, 0.0f, 0, -4.0 }, { &object_skb_Anim_001D1C, 1.0f, 0.0f, 0.0f, 0, -4.0 }, - { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -16.0f }, - { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_skb_Anim_0015EC, 1.0f, 0.0f, 0.0f, 2, -4.0 }, - { &object_skb_Anim_0009E4, 1.0f, 0.0f, 0.0f, 0, -4.0 }, +static AnimationInfo sAnimations[] = { + { &object_skb_Anim_0064E0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0 }, + { &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.0 }, + { &object_skb_Anim_00270C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0 }, + { &object_skb_Anim_00697C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0 }, + { &object_skb_Anim_006D90, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0 }, + { &object_skb_Anim_001D1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0 }, + { &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, -4.0 }, + { &object_skb_Anim_0009E4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0 }, }; static Vec3f D_80997468[] = { @@ -281,7 +287,7 @@ void func_80994DA8(EnSkb* this, GlobalContext* globalCtx) { } void func_80994E2C(EnSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actor.flags &= ~1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_APPEAR); this->unk_3D0 = 0; @@ -336,7 +342,7 @@ void func_80995068(EnSkb* this, GlobalContext* globalCtx) { if (this->unk_3E0 == 1) { func_801518B0(globalCtx, 0x13F8, &this->actor); if (this->unk_3DE == 2) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); } } else { func_801518B0(globalCtx, 0x13F6, &this->actor); @@ -368,7 +374,7 @@ void func_80995190(EnSkb* this, GlobalContext* globalCtx) { if (func_80147624(globalCtx)) { func_801518B0(globalCtx, 0x13F7, &this->actor); if (this->unk_3DE == 2) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); } } break; @@ -406,7 +412,7 @@ void func_80995244(EnSkb* this, GlobalContext* globalCtx) { } void func_809952D8(EnSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_3DE = 9; this->actionFunc = func_8099533C; @@ -428,7 +434,7 @@ void func_8099533C(EnSkb* this, GlobalContext* globalCtx) { } void func_809953E8(EnSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_3DE = 10; this->actionFunc = func_8099544C; @@ -450,7 +456,7 @@ void func_8099544C(EnSkb* this, GlobalContext* globalCtx) { } void func_809954F8(EnSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_3DE = 11; this->actionFunc = func_8099556C; @@ -493,14 +499,14 @@ void func_8099571C(EnSkb* this) { this->unk_3DC = 0; this->actor.shape.shadowScale = 0.0f; if (this->unk_3DE == 9) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); this->actor.speedXZ = 2.4f; this->actor.gravity = -1.0f; this->actor.velocity.y = 3.0f; } else if (this->unk_3DE == 0xA) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); } else if (this->unk_3DE == 0xB) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); this->actor.speedXZ = 3.2f; this->actor.gravity = -1.0f; this->actor.velocity.y = 2.0f; @@ -554,7 +560,7 @@ void func_8099599C(EnSkb* this, GlobalContext* globalCtx) { } void func_80995A30(EnSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actor.speedXZ = 1.6f; this->unk_3DA = 0; this->unk_3DE = 2; @@ -567,7 +573,7 @@ void func_80995A8C(EnSkb* this, GlobalContext* globalCtx) { this->actor.flags |= (0x8 | 0x1); this->actor.hintId = 0xFF; this->actor.colChkInfo.mass = MASS_HEAVY; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); func_8099504C(this); return; } @@ -590,7 +596,7 @@ void func_80995A8C(EnSkb* this, GlobalContext* globalCtx) { } void func_80995C24(EnSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->collider.base.atFlags &= ~AT_BOUNCED; this->actor.speedXZ = 0.0f; this->unk_3DE = 3; @@ -675,17 +681,17 @@ void func_80995E64(EnSkb* this, GlobalContext* globalCtx) { void func_80995F98(EnSkb* this) { if ((this->unk_3DE == 9) || (this->unk_3DE == 0xA)) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); this->actor.gravity = -1.0f; this->actor.speedXZ = 1.0f; } else if (this->unk_3DE == 0xB) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); this->actor.speedXZ = 3.2f; this->actor.velocity.y = 2.0f; this->actor.gravity = -1.0f; } else { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -4.0f; } @@ -721,7 +727,7 @@ void func_809960AC(EnSkb* this, GlobalContext* globalCtx) { } void func_809961E4(EnSkb* this, GlobalContext* globalCtx) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); this->unk_3D8 |= 0x40; if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -6.0f; @@ -753,7 +759,7 @@ void func_8099630C(EnSkb* this, GlobalContext* globalCtx) { this->unk_22C = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); this->unk_3D8 |= 1; func_80995F98(this); } else { @@ -775,7 +781,7 @@ void func_809963D8(EnSkb* this, GlobalContext* globalCtx) { this->unk_22C = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); this->unk_3D8 |= 1; func_80995F98(this); } else { @@ -946,7 +952,7 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { this->unk_230 = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_809963C4(this); break; @@ -962,7 +968,7 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { case 13: Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_80995F98(this); break; } diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index 22c2557b4..7ddbbf06b 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -54,10 +54,10 @@ s32 EnSob1_TakeItemOffShelf(EnSob1* this); s32 EnSob1_ReturnItemToShelf(EnSob1* this); s16 EnSob1_GetXZAngleAndDistanceSqToPoint(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); -static ActorAnimationEntryS sAnimationsBombShopkeeper[] = { - { &object_rs_Anim_009120, 2.0f, 0, -1, 0, 20 }, - { &object_rs_Anim_008268, 1.0f, 0, -1, 2, 0 }, - { &object_rs_Anim_0087BC, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimationsBombShopkeeper[] = { + { &object_rs_Anim_009120, 2.0f, 0, -1, ANIMMODE_LOOP, 20 }, + { &object_rs_Anim_008268, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_rs_Anim_0087BC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; const ActorInit En_Sob1_InitVars = { @@ -152,17 +152,17 @@ static Vec3f sPosOffset[] = { { 0.0f, -4.0f, 0.0f }, }; -void EnSob1_ChangeAnim(SkelAnime* skelAnime, ActorAnimationEntryS* animations, s32 idx) { +void EnSob1_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animations, s32 idx) { f32 frameCount; animations += idx; if (animations->frameCount < 0) { - frameCount = Animation_GetLastFrame(animations->animationSeg); + frameCount = Animation_GetLastFrame(animations->animation); } else { frameCount = animations->frameCount; } - Animation_Change(skelAnime, animations->animationSeg, animations->playbackSpeed, animations->frame, frameCount, - animations->mode, animations->transitionRate); + Animation_Change(skelAnime, animations->animation, animations->playSpeed, animations->startFrame, frameCount, + animations->mode, animations->morphFrames); } void EnSob1_SetupAction(EnSob1* this, EnSob1ActionFunc action) { diff --git a/src/overlays/actors/ovl_En_St/z_en_st.c b/src/overlays/actors/ovl_En_St/z_en_st.c index e3116fb3c..adeae463a 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -152,11 +152,15 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_st_Anim_000304, 1.0f, 0, -1, 0, 0 }, { &object_st_Anim_005B98, 1.0f, 0, -1, 2, -4 }, - { &object_st_Anim_000304, 4.0f, 0, -1, 2, -4 }, { &object_st_Anim_000304, 1.0f, 0, -1, 0, -4 }, - { &object_st_Anim_0055A8, 1.0f, 0, -1, 2, -4 }, { &object_st_Anim_000304, 8.0f, 0, -1, 0, -4 }, - { &object_st_Anim_000304, 6.0f, 0, -1, 2, -4 }, { &object_st_Anim_005B98, 2.0f, 0, -1, 0, -4 }, +static AnimationInfoS sAnimations[] = { + { &object_st_Anim_000304, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_st_Anim_005B98, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_st_Anim_000304, 4.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_st_Anim_000304, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_st_Anim_0055A8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_st_Anim_000304, 8.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_st_Anim_000304, 6.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_st_Anim_005B98, 2.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; void func_808A5050(EnSt* this, GlobalContext* globalCtx) { @@ -452,7 +456,7 @@ void func_808A60E0(EnSt* this) { sp1C = this->skelAnime.curFrame / (this->skelAnime.animLength - 1.0f); if (sp1C == 1.0f) { - func_8013BC6C(&this->skelAnime, sAnimations, idx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, idx); Actor_PlaySfxAtPos(&this->actor, sfxId); } @@ -504,7 +508,7 @@ void func_808A6220(EnSt* this, GlobalContext* globalCtx) { } void func_808A63E8(EnSt* this) { - func_8013BC6C(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); this->unk_2C8 = 1.0f; func_808A5D7C(this); this->unk_30C = 0; @@ -517,7 +521,7 @@ void func_808A63E8(EnSt* this) { void func_808A6468(EnSt* this, GlobalContext* globalCtx) { func_808A5050(this, globalCtx); - func_8013BC6C(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); this->unk_18C |= (0x8 | 0x4); this->unk_18C &= ~(0x10 | 0x2); this->unk_2C8 = -1.0f; @@ -534,7 +538,7 @@ void func_808A6468(EnSt* this, GlobalContext* globalCtx) { void func_808A650C(EnSt* this) { s32 idx = (this->unk_2C8 > 0.0f) ? 2 : 6; - func_8013BC6C(&this->skelAnime, sAnimations, idx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, idx); this->unk_2CC = 0.0f; this->unk_2D4 = 0.0f; this->unk_2D8 = 0.0f; @@ -601,7 +605,7 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { this->unk_314 = 20; this->unk_312 = 0; Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, this->unk_314); - func_8013BC6C(&this->skelAnime, sAnimations, 1); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 1); this->unk_18C |= 8; this->actionFunc = func_808A6D84; this->unk_2C8 = -1.0f; @@ -642,7 +646,7 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { } if (this->unk_18E != 10) { - func_8013BC6C(&this->skelAnime, sAnimations, 7); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 7); this->unk_2CC = 0.0f; this->unk_2D4 = 0.0f; this->actor.gravity = -1.0f; @@ -688,7 +692,7 @@ void func_808A6A78(EnSt* this, GlobalContext* globalCtx) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 8.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &object_st_Skel_005298, NULL, this->jointTable, this->morphTable, 30); - func_8013BC6C(&this->skelAnime, sAnimations, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 0); Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); @@ -719,7 +723,7 @@ void func_808A6C04(EnSt* this, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); if ((this->unk_18C & 8) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013BC6C(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); this->unk_18C &= ~8; } else if ((this->unk_310 == 0) && func_808A5F28(this, globalCtx) && !func_808A6064(this)) { func_808A650C(this); @@ -761,7 +765,7 @@ void func_808A6E24(EnSt* this, GlobalContext* globalCtx) { } if (count == ARRAY_COUNT(this->unk_31C)) { - func_8013BC6C(&this->skelAnime, sAnimations, 7); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 7); this->unk_18E = 1; this->unk_2CC = 0.0f; this->unk_2D4 = 0.0f; diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index efebc9430..e73766059 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -49,12 +49,16 @@ const ActorInit En_Suttari_InitVars = { (ActorFunc)EnSuttari_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_boj_Anim_00071C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_boj_Anim_0128F4, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_boj_Anim_011F84, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_boj_Anim_012E84, 1.0f, 0.0f, 0.0f, 0, -6.0f }, - { &object_boj_Anim_01139C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_boj_Anim_00071C, 2.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_boj_Anim_011F84, 2.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_boj_Anim_011C38, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_boj_Anim_010BDC, 1.0f, 0.0f, 0.0f, 0, 0.0f }, +static AnimationInfo sAnimations[] = { + { &object_boj_Anim_00071C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_boj_Anim_0128F4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_boj_Anim_011F84, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_boj_Anim_012E84, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, + { &object_boj_Anim_01139C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_boj_Anim_00071C, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_boj_Anim_011F84, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_boj_Anim_011C38, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_boj_Anim_010BDC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -219,13 +223,13 @@ void func_80BAA9B4(EnSuttari* this) { case 0x145B: if ((this->animationIdx != 8) && (curFrame == frameCount)) { this->animationIdx = 8; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); } break; default: if ((this->animationIdx != 1) && (curFrame == frameCount)) { this->animationIdx = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); } } } @@ -234,7 +238,7 @@ void func_80BAAA94(EnSuttari* this) { switch (this->textId) { case 0x29E5: this->animationIdx = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); break; case 0x29E9: this->enFsn->flags |= ENFSN_ANGRY; @@ -247,11 +251,11 @@ void func_80BAAA94(EnSuttari* this) { break; case 0x29EC: this->animationIdx = 7; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); break; case 0x29ED: this->animationIdx = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); break; } } @@ -377,10 +381,10 @@ void func_80BAAF1C(EnSuttari* this) { if (this->animationIdx == 5) { this->animationIdx = 3; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); } else if ((this->animationIdx == 3) && (curFrame == frameCount)) { this->animationIdx = 6; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); this->flags1 &= ~0x100; } } @@ -497,7 +501,7 @@ void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->unk2E2.y, 0, 4, 0x3E8, 1); } } - func_8013D9C8(globalCtx, this->unk2FA, this->unk31A, 16); + SubS_FillLimbRotTables(globalCtx, this->unk2FA, this->unk31A, ARRAY_COUNT(this->unk2FA)); } s16 func_80BAB698(Path* path, s32 idx, Vec3f* pos, f32* distSQ) { @@ -813,7 +817,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { case 15: if ((this->animationIdx == 1) && (curFrame == frameCount)) { this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); } if (!(gSaveContext.weekEventReg[0x53] & 4) && !(this->flags1 & 0x1000)) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[0])) { @@ -846,7 +850,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { this->enFsn->flags &= ~ENFSN_HAGGLE; if (this->animationIdx != 2) { this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); } func_80BAC220(this, globalCtx); break; @@ -877,7 +881,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { if (!(gSaveContext.weekEventReg[0x21] & 8)) { if (this->animationIdx == 2 || this->animationIdx == 1) { this->animationIdx = 5; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); } this->flags1 |= 0x10; if (this->flags2 & 2) { @@ -906,7 +910,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { this->flags1 |= 1; if (gSaveContext.day == 1 || gSaveContext.day == 2) { this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); this->flags1 |= 0x80; this->actionFunc = func_80BACA14; return; @@ -914,7 +918,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { !(gSaveContext.weekEventReg[0x3D] & 8) && !(gSaveContext.weekEventReg[0x21] & 8) && (gSaveContext.weekEventReg[0x33] & 8)) { this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); this->actionFunc = func_80BACEE0; return; } @@ -930,7 +934,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { this->flags1 |= 0x80; this->flags1 |= 8; this->animationIdx = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); this->actionFunc = func_80BAD004; return; } else if (globalCtx->sceneNum == SCENE_ICHIBA) { @@ -939,7 +943,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { return; } this->animationIdx = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); this->flags1 |= 2; this->actionFunc = func_80BAD5F8; return; @@ -949,7 +953,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { return; } this->animationIdx = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); this->cutscenes[0] = this->actor.cutscene; this->cutscenes[1] = ActorCutscene_GetAdditionalCutscene(this->cutscenes[0]); this->flags1 |= 4; @@ -969,7 +973,7 @@ void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { if (this->animationIdx == 1 || this->animationIdx == 8) { this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); } func_80BABA90(this, 0, 0); func_80BAB434(this); @@ -1211,7 +1215,7 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { if ((curFrame == frameCount) && (this->animationIdx == 0) && (this->flags1 & 0x20)) { this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); } this->unk42A = REG(15) + *unk_14; if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || @@ -1250,7 +1254,7 @@ void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { } else { if ((this->flags1 & 0x2000) && (this->animationIdx == 1) && (curFrame == frameCount)) { this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); } this->unk42A = REG(15) + *unk_14; if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || @@ -1299,7 +1303,7 @@ void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { func_80BAA9B4(this); } else if ((this->animationIdx == 7) && (curFrame == frameCount)) { this->animationIdx = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); } if (talkstate == 5) { if (func_80147624(globalCtx)) { diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index bc863b9d0..f187562e2 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -134,11 +134,11 @@ static DamageTable sDamageTable2 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_st_Anim_000304, 1.0f, 0, -1, 3, 0 }, - { &object_st_Anim_000304, 1.0f, 0, -1, 3, -4 }, - { &object_st_Anim_0055A8, 1.0f, 0, -1, 1, -4 }, - { &object_st_Anim_005B98, 1.0f, 0, -1, 1, -4 }, +static AnimationInfoS sAnimations[] = { + { &object_st_Anim_000304, 1.0f, 0, -1, ANIMMODE_ONCE_INTERP, 0 }, + { &object_st_Anim_000304, 1.0f, 0, -1, ANIMMODE_ONCE_INTERP, -4 }, + { &object_st_Anim_0055A8, 1.0f, 0, -1, ANIMMODE_LOOP_INTERP, -4 }, + { &object_st_Anim_005B98, 1.0f, 0, -1, ANIMMODE_LOOP_INTERP, -4 }, }; void func_808D8940(EnSw* this, GlobalContext* globalCtx) { @@ -676,7 +676,7 @@ s32 func_808DA08C(EnSw* this, GlobalContext* globalCtx) { Enemy_StartFinishingBlow(globalCtx, &this->actor); this->actor.flags &= ~1; if (!ENSW_GET_3(&this->actor)) { - func_8013BC6C(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); } switch (this->actor.colChkInfo.damageEffect) { @@ -1159,7 +1159,7 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &object_st_Skel_005298, NULL, this->jointTable, this->morphTable, 30); - func_8013BC6C(&this->skelAnime, sAnimations, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 0); this->skelAnime.playSpeed = 4.0f; Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 493aae9d7..a097c354a 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -47,10 +47,10 @@ const ActorInit En_Syateki_Man_InitVars = { (ActorFunc)EnSyatekiMan_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_shn_Anim_00D9D0, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_shn_Anim_00DFEC, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_shn_Anim_00D2F8, 1.0f, 0.0f, 0.0f, 2, -8.0f }, +static AnimationInfo sAnimations[] = { + { &object_shn_Anim_00D9D0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_shn_Anim_00DFEC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_shn_Anim_00D2F8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, }; static s16 D_809C91C8[] = { @@ -207,7 +207,7 @@ void func_809C6848(EnSyatekiMan* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { u16 sp22; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); sp22 = Text_GetFaceReaction(globalCtx, 0x31); if (sp22 != 0) { func_801518B0(globalCtx, sp22, &this->actor); @@ -410,7 +410,7 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { if (this->skelAnime.animation == &object_shn_Anim_00D2F8) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); } } } diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c index ae8bfa48a..9d19c68bf 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c @@ -103,14 +103,21 @@ const ActorInit En_Talk_Gibud_InitVars = { (ActorFunc)EnTalkGibud_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_rd_Anim_006678, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_rd_Anim_006B08, 0.5f, 0.0f, 0.0f, 3, 0.0f }, - { &object_rd_Anim_006EEC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_0073A4, 0.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_rd_Anim_007BBC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_0081A8, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_009298, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_009900, 1.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_rd_Anim_00A450, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_00ABE0, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_0113EC, 0.4f, 0.0f, 0.0f, 1, -8.0f }, { &object_rd_Anim_01216C, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_0118D8, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_rd_Anim_011DB8, 1.0f, 0.0f, 0.0f, 0, -8.0f }, +static AnimationInfo sAnimations[] = { + { &object_rd_Anim_006678, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_rd_Anim_006B08, 0.5f, 0.0f, 0.0f, ANIMMODE_ONCE_INTERP, 0.0f }, + { &object_rd_Anim_006EEC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_rd_Anim_0073A4, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_rd_Anim_007BBC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_rd_Anim_0081A8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_rd_Anim_009298, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_rd_Anim_009900, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_rd_Anim_00A450, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_rd_Anim_00ABE0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_rd_Anim_0113EC, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -8.0f }, + { &object_rd_Anim_01216C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_rd_Anim_0118D8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_rd_Anim_011DB8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -260,7 +267,7 @@ void EnTalkGibud_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnTalkGibud_SetupIdle(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); this->actionFunc = EnTalkGibud_Idle; } @@ -277,7 +284,7 @@ void EnTalkGibud_Idle(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupAttemptPlayerStun(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); this->actionFunc = EnTalkGibud_AttemptPlayerStun; } @@ -297,7 +304,7 @@ void EnTalkGibud_AttemptPlayerStun(EnTalkGibud* this, GlobalContext* globalCtx) } void EnTalkGibud_SetupWalkToPlayer(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); this->actor.speedXZ = 0.4f; if (this->actionFunc == EnTalkGibud_AttemptPlayerStun) { this->playerStunWaitTimer = 80; @@ -353,7 +360,7 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupGrab(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_START); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_START); this->grabDamageTimer = 0; this->actor.flags &= ~1; this->grabState = EN_TALK_GIBUD_GRAB_START; @@ -375,7 +382,7 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { inPositionToAttack = EnTalkGibud_MoveToIdealGrabPositionAndRotation(this, globalCtx); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && inPositionToAttack == true) { this->grabState = EN_TALK_GIBUD_GRAB_ATTACK; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_ATTACK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_ATTACK); } break; @@ -401,7 +408,7 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { player->stateFlags2 &= ~0x80; player->unk_AE8 = 100; } - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_END); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_END); this->actor.flags |= 1; this->grabState = EN_TALK_GIBUD_GRAB_RELEASE; this->grabDamageTimer = 0; @@ -421,7 +428,7 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupGrabFail(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->actionFunc = EnTalkGibud_GrabFail; this->actor.speedXZ = -2.0f; @@ -442,7 +449,7 @@ void EnTalkGibud_GrabFail(EnTalkGibud* this, GlobalContext* globalCtx) { void EnTalkGibud_SetupTurnAwayAndShakeHead(EnTalkGibud* this) { this->headShakeTimer = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); this->actionFunc = EnTalkGibud_TurnAwayAndShakeHead; } @@ -460,7 +467,7 @@ void EnTalkGibud_TurnAwayAndShakeHead(EnTalkGibud* this, GlobalContext* globalCt } void EnTalkGibud_SetupWalkToHome(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); this->actor.speedXZ = 0.4f; this->actionFunc = EnTalkGibud_WalkToHome; } @@ -517,7 +524,7 @@ void EnTalkGibud_Stunned(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupDamage(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->stunTimer = 0; this->grabWaitTimer = 0; @@ -550,7 +557,7 @@ void EnTalkGibud_Damage(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupDead(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DEATH); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DEATH); this->actor.flags &= ~1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); this->deathTimer = 0; @@ -714,7 +721,7 @@ void EnTalkGibud_CheckPresentedItem(EnTalkGibud* this, GlobalContext* globalCtx) void EnTalkGibud_SetupPassiveIdle(EnTalkGibud* this) { this->isTalking = false; if (this->actionFunc != EnTalkGibud_Talk) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); } this->actionFunc = EnTalkGibud_PassiveIdle; } @@ -792,7 +799,7 @@ void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupDisappear(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); this->actor.flags &= ~1; this->disappearanceTimer = 40; this->actionFunc = EnTalkGibud_Disappear; diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index df59b09e4..6ccb2b5d2 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -108,11 +108,11 @@ static u32 D_80AEF85C[] = { 0xFF000000, }; -static struct_80B8E1A8 D_80AEF868[] = { - { &object_tk_Anim_001FA8, 1.0f, 0, -10.0f }, { &object_tk_Anim_001FA8, 2.0f, 0, -10.0f }, - { &object_tk_Anim_0030A4, 1.0f, 0, -10.0f }, { &object_tk_Anim_001144, 1.0f, 2, -10.0f }, - { &object_tk_Anim_003724, 1.0f, 2, -10.0f }, { &object_tk_Anim_003FB8, 1.0f, 0, -10.0f }, - { &object_tk_Anim_0020C8, 1.0f, 0, -10.0f }, { &object_tk_Anim_003B10, 1.0f, 0, -10.0f }, +static AnimationSpeedInfo D_80AEF868[] = { + { &object_tk_Anim_001FA8, 1.0f, ANIMMODE_LOOP, -10.0f }, { &object_tk_Anim_001FA8, 2.0f, ANIMMODE_LOOP, -10.0f }, + { &object_tk_Anim_0030A4, 1.0f, ANIMMODE_LOOP, -10.0f }, { &object_tk_Anim_001144, 1.0f, ANIMMODE_ONCE, -10.0f }, + { &object_tk_Anim_003724, 1.0f, ANIMMODE_ONCE, -10.0f }, { &object_tk_Anim_003FB8, 1.0f, ANIMMODE_LOOP, -10.0f }, + { &object_tk_Anim_0020C8, 1.0f, ANIMMODE_LOOP, -10.0f }, { &object_tk_Anim_003B10, 1.0f, ANIMMODE_LOOP, -10.0f }, }; static s32 D_80AEF8E8[2] = { 0, 0 }; @@ -247,7 +247,7 @@ void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.flags |= 0x10; - func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); switch (this->unk_2B0) { @@ -285,7 +285,7 @@ void EnTk_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80AECA3C(EnTk* this, GlobalContext* globalCtx) { this->unk_316 = 0; - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->actionFunc = func_80AECA90; } @@ -303,7 +303,7 @@ void func_80AECB0C(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; this->unk_3CC = 0xFF; this->unk_2DC = 0.0f; - func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); this->actionFunc = func_80AECB6C; } @@ -331,7 +331,7 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { } if (this->unk_2CA & 0x10) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 5, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 5, &this->unk_2D4); sp48 = 1.0f; sp44 = 22.0f; } else { @@ -529,7 +529,7 @@ s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } void func_80AED4F8(EnTk* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->actionFunc = func_80AED610; } @@ -550,14 +550,14 @@ void func_80AED544(EnTk* this, GlobalContext* globalCtx) { void func_80AED610(EnTk* this, GlobalContext* globalCtx) { if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); } switch (Message_GetState(&globalCtx->msgCtx)) { case 0: if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer - 0x1555, 0x71C)) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); func_801518B0(globalCtx, 0x13FD, &this->actor); } else if (CURRENT_DAY != 2) { func_80AED544(this, globalCtx); @@ -583,7 +583,7 @@ void func_80AED610(EnTk* this, GlobalContext* globalCtx) { switch (globalCtx->msgCtx.unk11F04) { case 0x13FD: this->unk_2CA |= 0x10; - func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); this->skelAnime.playSpeed = 10.0f; this->actionFunc = func_80AECB6C; break; @@ -619,7 +619,7 @@ void func_80AED610(EnTk* this, GlobalContext* globalCtx) { case 0x1411: case 0x1412: default: - func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); this->actionFunc = func_80AECB6C; break; } @@ -633,10 +633,10 @@ void func_80AED898(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; if (this->unk_2CA & 0x1000) { if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); } } else { - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); } this->actionFunc = func_80AED940; } @@ -666,7 +666,7 @@ void func_80AED940(EnTk* this, GlobalContext* globalCtx) { } if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); } if (!(this->unk_2CA & 0x40)) { @@ -706,7 +706,7 @@ void func_80AEDBEC(EnTk* this, GlobalContext* globalCtx) { this->actor.params = -1; this->unk_2E8 = 0; this->actor.speedXZ = 0.0f; - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->actionFunc = func_80AEDC4C; } @@ -720,7 +720,7 @@ void func_80AEDC4C(EnTk* this, GlobalContext* globalCtx) { void func_80AEDCBC(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 10.0f; - func_8013E1C8(&this->skelAnime, D_80AEF868, 5, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 5, &this->unk_2D4); Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_2EC); Math_Vec3f_Copy(&this->actor.prevPos, &this->unk_2EC); Math_Vec3s_Copy(&this->actor.world.rot, &this->unk_2F8); @@ -739,7 +739,7 @@ void func_80AEDD4C(EnTk* this, GlobalContext* globalCtx) { void func_80AEDDA0(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->actor.flags |= 0x10000; this->unk_2CA |= 0x80; this->actionFunc = func_80AED940; @@ -769,12 +769,12 @@ void func_80AEDE10(EnTk* this, GlobalContext* globalCtx) { case 4: func_801518B0(globalCtx, 0x140F, &this->actor); - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); break; case 3: func_801518B0(globalCtx, 0x1410, &this->actor); - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); break; } break; @@ -789,7 +789,7 @@ void func_80AEDE10(EnTk* this, GlobalContext* globalCtx) { void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); } switch (Message_GetState(&globalCtx->msgCtx)) { @@ -805,9 +805,9 @@ void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { !Math_SmoothStepToS(&this->unk_31C, 0, 3, 0x71C, 10) && (this->actor.shape.rot.y == (s16)(this->actor.yawTowardsPlayer - 0x1555))) { if (this->unk_2E6 == 0x1404) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); } else { - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); } func_801518B0(globalCtx, this->unk_2E6, &this->actor); } @@ -943,7 +943,7 @@ void func_80AEE414(EnTk* this, GlobalContext* globalCtx) { void func_80AEE478(EnTk* this, GlobalContext* globalCtx) { this->unk_310 = 2; - func_8013E1C8(&this->skelAnime, D_80AEF868, 3, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 3, &this->unk_2D4); this->actionFunc = func_80AEE4D0; } @@ -1136,7 +1136,7 @@ void func_80AEEB88(EnTk* this, GlobalContext* globalCtx) { } this->unk_2C6 = 100; - func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); this->unk_30C = func_80AEED38; } @@ -1177,9 +1177,9 @@ void func_80AEED38(EnTk* this, GlobalContext* globalCtx) { } if (this->unk_2CA & 0x200) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); } else { - func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); func_80AEC658(&this->skelAnime, this->unk_320, 1.0f, &this->actor.speedXZ, &sp64); } @@ -1196,7 +1196,7 @@ void func_80AEED38(EnTk* this, GlobalContext* globalCtx) { } void func_80AEF048(EnTk* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); this->unk_30C = func_80AEF094; } @@ -1204,9 +1204,9 @@ void func_80AEF094(EnTk* this, GlobalContext* globalCtx) { f32 sp2C; if (this->unk_2CA & 0x200) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); } else { - func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); func_80AEC658(&this->skelAnime, this->unk_320, 1.0f, &this->actor.speedXZ, &sp2C); } @@ -1218,7 +1218,7 @@ void func_80AEF094(EnTk* this, GlobalContext* globalCtx) { void func_80AEF15C(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->unk_30C = func_80AEF1B4; } @@ -1226,7 +1226,7 @@ void func_80AEF1B4(EnTk* this, GlobalContext* globalCtx) { } void func_80AEF1C4(EnTk* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->unk_30C = func_80AEF210; } @@ -1235,7 +1235,7 @@ void func_80AEF210(EnTk* this, GlobalContext* globalCtx) { void func_80AEF220(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->unk_30C = func_80AEF278; } diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.c b/src/overlays/actors/ovl_En_Trt/z_en_trt.c index 06529d03a..1372be93d 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -64,12 +64,17 @@ void EnTrt_Blink(EnTrt* this); void EnTrt_OpenEyes2(EnTrt* this); void EnTrt_NodOff(EnTrt* this); -static ActorAnimationEntryS sAnimations[] = { - { &object_trt_Anim_00DE68, 1.0f, 0, -1, 2, 0 }, { &object_trt_Anim_00EE98, 1.0f, 0, -1, 2, 0 }, - { &object_trt_Anim_00FD34, 1.0f, 0, -1, 0, 0 }, { &object_trt_Anim_0030EC, 1.0f, 0, -1, 2, 0 }, - { &object_trt_Anim_003D78, 1.0f, 0, -1, 2, 0 }, { &object_trt_Anim_00D52C, 1.0f, 0, -1, 0, 0 }, - { &object_trt_Anim_000A44, 1.0f, 0, -1, 0, 0 }, { &object_trt_Anim_001EF4, 1.0f, 0, -1, 0, 0 }, - { &object_trt_Anim_002224, 1.0f, 0, -1, 0, 0 }, { &object_trt_Anim_002CB0, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_trt_Anim_00DE68, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_00EE98, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_00FD34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_0030EC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_003D78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_00D52C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_000A44, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_001EF4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_002224, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_002CB0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; const ActorInit En_Trt_InitVars = { @@ -92,17 +97,17 @@ static ShopItem sShop[] = { { SI_POTION_BLUE, { -12, 32, -36 } }, }; -void EnTrt_ChangeAnim(SkelAnime* skelAnime, ActorAnimationEntryS* animations, s32 idx) { +void EnTrt_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animations, s32 idx) { f32 frameCount; animations += idx; if (animations->frameCount < 0) { - frameCount = Animation_GetLastFrame(animations->animationSeg); + frameCount = Animation_GetLastFrame(animations->animation); } else { frameCount = animations->frameCount; } - Animation_Change(skelAnime, animations->animationSeg, animations->playbackSpeed, animations->frame, frameCount, - animations->mode, animations->transitionRate); + Animation_Change(skelAnime, animations->animation, animations->playSpeed, animations->startFrame, frameCount, + animations->mode, animations->morphFrames); } s32 EnTrt_TestItemSelected(GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c index 03b7d31c4..cef309815 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -26,12 +26,17 @@ void func_80AD4FE4(EnTrt2* this, GlobalContext* globalCtx); void func_80AD5234(EnTrt2* this, GlobalContext* globalCtx); void func_80AD56E8(Actor* thisx, GlobalContext* globalCtx); -static ActorAnimationEntryS sAnimations[] = { - { &object_trt_Anim_00DE68, 1.0f, 0, -1, 2, 0 }, { &object_trt_Anim_00EE98, 1.0f, 0, -1, 2, 0 }, - { &object_trt_Anim_00FD34, 1.0f, 0, -1, 0, 0 }, { &object_trt_Anim_0030EC, 1.0f, 0, -1, 2, 0 }, - { &object_trt_Anim_003D78, 1.0f, 0, -1, 2, 0 }, { &object_trt_Anim_00D52C, 1.0f, 0, -1, 0, 0 }, - { &object_trt_Anim_000A44, 1.0f, 0, -1, 0, 0 }, { &object_trt_Anim_001EF4, 1.0f, 0, -1, 0, 0 }, - { &object_trt_Anim_002224, 1.0f, 0, -1, 0, 0 }, { &object_trt_Anim_002CB0, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_trt_Anim_00DE68, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_00EE98, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_00FD34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_0030EC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_003D78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_00D52C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_000A44, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_001EF4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_002224, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_002CB0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; const ActorInit En_Trt2_InitVars = { @@ -103,18 +108,18 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -void func_80AD3380(SkelAnime* skelAnime, ActorAnimationEntryS* animation, s32 arg2) { +void func_80AD3380(SkelAnime* skelAnime, AnimationInfoS* animation, s32 arg2) { f32 phi_f0; animation += arg2; if (animation->frameCount < 0) { - phi_f0 = Animation_GetLastFrame(animation->animationSeg); + phi_f0 = Animation_GetLastFrame(animation->animation); } else { phi_f0 = animation->frameCount; } - Animation_Change(skelAnime, animation->animationSeg, animation->playbackSpeed, animation->frame, phi_f0, - animation->mode, animation->transitionRate); + Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, phi_f0, + animation->mode, animation->morphFrames); } void func_80AD341C(EnTrt2* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index 56d570e5b..767bfdae2 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -106,15 +106,23 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 20, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS D_80A8B2D8[] = { - { &object_tru_Anim_00F9A0, 1.0f, 0, -1, 0, 0 }, { &object_tru_Anim_00F9A0, 1.0f, 0, -1, 0, -4 }, - { &object_tru_Anim_0108AC, 1.0f, 0, -1, 2, -4 }, { &object_tru_Anim_009348, 1.0f, 0, -1, 2, 0 }, - { &object_tru_Anim_00EEDC, 1.0f, 0, -1, 0, -4 }, { &object_tru_Anim_015CA0, 1.0f, 0, -1, 0, 0 }, - { &object_tru_Anim_015CA0, 1.0f, 0, -1, 0, -4 }, { &object_tru_Anim_014728, 1.0f, 0, -1, 2, 0 }, - { &object_tru_Anim_01B5C4, 1.0f, 0, -1, 2, 0 }, { &object_tru_Anim_007FA0, 1.0f, 0, -1, 2, -4 }, - { &object_tru_Anim_016B4C, 1.0f, 0, -1, 0, -4 }, { &object_tru_Anim_011F88, 1.0f, 0, -1, 2, -4 }, - { &object_tru_Anim_00446C, 1.0f, 0, -1, 0, 0 }, { &object_tru_Anim_003698, 1.0f, 0, -1, 2, -4 }, - { &object_tru_Anim_002BD8, 1.0f, 0, -1, 0, 0 }, { &object_tru_Anim_00446C, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS D_80A8B2D8[] = { + { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_0108AC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_009348, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_tru_Anim_00EEDC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_014728, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_tru_Anim_01B5C4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_tru_Anim_007FA0, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_016B4C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_011F88, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_003698, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_002BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; static Vec3f D_80A8B3D8 = { 0.0f, 24.0f, 16.0f }; @@ -418,7 +426,7 @@ s32 func_80A86924(EnTru* this, s32 arg1) { if (arg1 != this->unk_37C) { this->unk_37C = arg1; - ret = func_8013BC6C(&this->skelAnime, D_80A8B2D8, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80A8B2D8, arg1); this->unk_358 = this->skelAnime.playSpeed; } diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 432fbec9d..b547f5a8c 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -91,11 +91,14 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), }; -static ActorAnimationEntryS sAnimations[] = { - { &gZoraIdleAnim, 1.0f, 0, -1, 0, 0 }, { &gZoraIdleAnim, 1.0f, 0, -1, 0, -4 }, - { &gZoraSurfacingAnim, 1.0f, 0, -1, 0, -4 }, { &gZoraHandsOnHipsTappingFootAnim, 1.0f, 0, -1, 0, -4 }, - { &gZoraArmsOpenAnim, 1.0f, 0, -1, 0, -4 }, { &gZoraThrowRupeeAnim, 1.0f, 0, -1, 0, -4 }, - { &gZoraWalkAnim, 1.0f, 0, -1, 0, -4 }, +static AnimationInfoS sAnimations[] = { + { &gZoraIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gZoraIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gZoraSurfacingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gZoraHandsOnHipsTappingFootAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gZoraArmsOpenAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gZoraThrowRupeeAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gZoraWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; s8 D_8099F578[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2, -1, -1, -1, -1 }; @@ -110,11 +113,11 @@ s32 EnZo_SetAnimation(SkelAnime* skelAnime, s16 index) { didChange = true; frameCount = sAnimations[index].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(sAnimations[index].animationSeg); + frameCount = Animation_GetLastFrame(sAnimations[index].animation); } - Animation_Change(skelAnime, sAnimations[index].animationSeg, sAnimations[index].playbackSpeed, - sAnimations[index].frame, frameCount, sAnimations[index].mode, - sAnimations[index].transitionRate); + Animation_Change(skelAnime, sAnimations[index].animation, sAnimations[index].playSpeed, + sAnimations[index].startFrame, frameCount, sAnimations[index].mode, + sAnimations[index].morphFrames); } return didChange; } @@ -196,7 +199,7 @@ void EnZo_LookAtPlayer(EnZo* this, GlobalContext* globalCtx) { } EnZo_Blink(this, 3); - func_8013D9C8(globalCtx, this->limbRotY, this->limbRotZ, 20); + SubS_FillLimbRotTables(globalCtx, this->limbRotY, this->limbRotZ, 20); } void EnZo_Walk(EnZo* this, GlobalContext* globalCtx) { diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 990d67251..d81c578ba 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -213,7 +213,8 @@ animdict = { "func_800BE2B8": "Actor_SetDropFlagJntSph", "Actor_TitleCardCreate": "TitleCard_InitBossName", "func_800B867C": "Actor_TextboxIsClosing", - "func_800BDC5C": "Actor_ChangeAnimation", + "func_800BDC5C": "Actor_ChangeAnimationByInfo", + "Actor_ChangeAnimation(": "Actor_ChangeAnimationByInfo(", "func_80152498": "Message_GetState", "func_800B8898": "Actor_GetScreenPos", "Audio_PlayActorSound2": "Actor_PlaySfxAtPos", @@ -389,7 +390,9 @@ animdict = { "func_80134148": "SkelAnime_DrawTransformFlexLimbOpa", "func_8013AB00": "SubS_DrawTransformFlex", "func_8013A860": "SubS_DrawTransformFlexLimb", - + "func_8013BC6C": "SubS_ChangeAnimationByInfoS", + "func_8013E1C8": "SubS_ChangeAnimationBySpeedInfo", + "func_8013D9C8": "SubS_FillLimbRotTables", # Structs members "skelAnime.unk03": "skelAnime.taper", @@ -430,6 +433,11 @@ animdict = { "D_801D1DE0": "gIdentityMtx", "D_801D1E20": "gIdentityMtxF", + # Structs + "ActorAnimationEntry": "AnimationInfo", + "ActorAnimationEntryS": "AnimationInfoS", + "struct_80B8E1A8": "AnimationSpeedInfo", + "ICHAIN_F32_DIV1000(minVelocityY,": "ICHAIN_F32_DIV1000(terminalVelocity,", "ICHAIN_F32(minVelocityY,": "ICHAIN_F32(terminalVelocity,", } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index b008d3340..3f1a4541c 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -877,7 +877,7 @@ 0x800BD9E0:("func_800BD9E0",), 0x800BDAA0:("func_800BDAA0",), 0x800BDB6C:("func_800BDB6C",), - 0x800BDC5C:("Actor_ChangeAnimation",), + 0x800BDC5C:("Actor_ChangeAnimationByInfo",), 0x800BDCF4:("func_800BDCF4",), 0x800BDFB0:("Actor_Noop",), 0x800BDFC0:("Gfx_DrawDListOpa",), @@ -2669,7 +2669,7 @@ 0x8013B878:("func_8013B878",), 0x8013BB34:("func_8013BB34",), 0x8013BB7C:("SubS_FindNearestActor",), - 0x8013BC6C:("func_8013BC6C",), + 0x8013BC6C:("SubS_ChangeAnimationByInfoS",), 0x8013BD40:("func_8013BD40",), 0x8013BEDC:("func_8013BEDC",), 0x8013C068:("func_8013C068",), @@ -2690,7 +2690,7 @@ 0x8013D8DC:("func_8013D8DC",), 0x8013D924:("func_8013D924",), 0x8013D960:("SubS_FindActor",), - 0x8013D9C8:("func_8013D9C8",), + 0x8013D9C8:("SubS_FillLimbRotTables",), 0x8013DB90:("func_8013DB90",), 0x8013DC40:("func_8013DC40",), 0x8013DCCC:("func_8013DCCC",), @@ -2700,7 +2700,7 @@ 0x8013E054:("func_8013E054",), 0x8013E07C:("func_8013E07C",), 0x8013E0A4:("func_8013E0A4",), - 0x8013E1C8:("func_8013E1C8",), + 0x8013E1C8:("SubS_ChangeAnimationBySpeedInfo",), 0x8013E2D4:("func_8013E2D4",), 0x8013E3B8:("func_8013E3B8",), 0x8013E4B0:("func_8013E4B0",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index da2ea51f5..aeea6d9ae 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -391,7 +391,7 @@ asm/non_matchings/code/z_actor/func_800BD9A0.s,func_800BD9A0,0x800BD9A0,0x10 asm/non_matchings/code/z_actor/func_800BD9E0.s,func_800BD9E0,0x800BD9E0,0x30 asm/non_matchings/code/z_actor/func_800BDAA0.s,func_800BDAA0,0x800BDAA0,0x33 asm/non_matchings/code/z_actor/func_800BDB6C.s,func_800BDB6C,0x800BDB6C,0x3C -asm/non_matchings/code/z_actor/Actor_ChangeAnimation.s,Actor_ChangeAnimation,0x800BDC5C,0x26 +asm/non_matchings/code/z_actor/Actor_ChangeAnimationByInfo.s,Actor_ChangeAnimationByInfo,0x800BDC5C,0x26 asm/non_matchings/code/z_actor/func_800BDCF4.s,func_800BDCF4,0x800BDCF4,0xAF asm/non_matchings/code/z_actor/Actor_Noop.s,Actor_Noop,0x800BDFB0,0x4 asm/non_matchings/code/z_actor/Gfx_DrawDListOpa.s,Gfx_DrawDListOpa,0x800BDFC0,0x1F @@ -2183,7 +2183,7 @@ asm/non_matchings/code/z_sub_s/func_8013B6B0.s,func_8013B6B0,0x8013B6B0,0x72 asm/non_matchings/code/z_sub_s/func_8013B878.s,func_8013B878,0x8013B878,0xAF asm/non_matchings/code/z_sub_s/func_8013BB34.s,func_8013BB34,0x8013BB34,0x12 asm/non_matchings/code/z_sub_s/SubS_FindNearestActor.s,SubS_FindNearestActor,0x8013BB7C,0x3C -asm/non_matchings/code/z_sub_s/func_8013BC6C.s,func_8013BC6C,0x8013BC6C,0x35 +asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationByInfoS.s,SubS_ChangeAnimationByInfoS,0x8013BC6C,0x35 asm/non_matchings/code/z_sub_s/func_8013BD40.s,func_8013BD40,0x8013BD40,0x67 asm/non_matchings/code/z_sub_s/func_8013BEDC.s,func_8013BEDC,0x8013BEDC,0x63 asm/non_matchings/code/z_sub_s/func_8013C068.s,func_8013C068,0x8013C068,0x16F @@ -2204,7 +2204,7 @@ asm/non_matchings/code/z_sub_s/func_8013D83C.s,func_8013D83C,0x8013D83C,0x28 asm/non_matchings/code/z_sub_s/func_8013D8DC.s,func_8013D8DC,0x8013D8DC,0x12 asm/non_matchings/code/z_sub_s/func_8013D924.s,func_8013D924,0x8013D924,0xF asm/non_matchings/code/z_sub_s/SubS_FindActor.s,SubS_FindActor,0x8013D960,0x1A -asm/non_matchings/code/z_sub_s/func_8013D9C8.s,func_8013D9C8,0x8013D9C8,0x72 +asm/non_matchings/code/z_sub_s/SubS_FillLimbRotTables.s,SubS_FillLimbRotTables,0x8013D9C8,0x72 asm/non_matchings/code/z_sub_s/func_8013DB90.s,func_8013DB90,0x8013DB90,0x2C asm/non_matchings/code/z_sub_s/func_8013DC40.s,func_8013DC40,0x8013DC40,0x23 asm/non_matchings/code/z_sub_s/func_8013DCCC.s,func_8013DCCC,0x8013DCCC,0x5 @@ -2214,7 +2214,7 @@ asm/non_matchings/code/z_sub_s/func_8013DF3C.s,func_8013DF3C,0x8013DF3C,0x46 asm/non_matchings/code/z_sub_s/func_8013E054.s,func_8013E054,0x8013E054,0xA asm/non_matchings/code/z_sub_s/func_8013E07C.s,func_8013E07C,0x8013E07C,0xA asm/non_matchings/code/z_sub_s/func_8013E0A4.s,func_8013E0A4,0x8013E0A4,0x49 -asm/non_matchings/code/z_sub_s/func_8013E1C8.s,func_8013E1C8,0x8013E1C8,0x43 +asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationBySpeedInfo.s,SubS_ChangeAnimationBySpeedInfo,0x8013E1C8,0x43 asm/non_matchings/code/z_sub_s/func_8013E2D4.s,func_8013E2D4,0x8013E2D4,0x39 asm/non_matchings/code/z_sub_s/func_8013E3B8.s,func_8013E3B8,0x8013E3B8,0x3E asm/non_matchings/code/z_sub_s/func_8013E4B0.s,func_8013E4B0,0x8013E4B0,0x47 From a9a97e217cda46e7de2266daa4643bde79db12a0 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Mon, 14 Feb 2022 16:25:22 +0000 Subject: [PATCH 018/257] Fix fix (#663) --- tools/actorfixer.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/actorfixer.py b/tools/actorfixer.py index d81c578ba..0a3f72941 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -393,6 +393,9 @@ animdict = { "func_8013BC6C": "SubS_ChangeAnimationByInfoS", "func_8013E1C8": "SubS_ChangeAnimationBySpeedInfo", "func_8013D9C8": "SubS_FillLimbRotTables", + "func_80114E90": "Interface_HasEmptyBottle", + "func_80114F2C": "Interface_HasItemInBottle", + "func_80123C90": "Player_SetEquipmentData", # Structs members "skelAnime.unk03": "skelAnime.taper", @@ -425,6 +428,9 @@ animdict = { "player->unk_394": "player->csMode", "player->unk_A87": "player->exchangeItemId", "globalCtx->actorCtx.actorList[": "globalCtx->actorCtx.actorLists[", + "globalCtx->msgCtx.unk1202A": "globalCtx->msgCtx.ocarinaMode", + "globalCtx->msgCtx.unk1202C": "globalCtx->msgCtx.ocarinaAction", + "globalCtx->msgCtx.unk11F22": "globalCtx->msgCtx.msgMode", # Variables "D_0407D590": "gGameplayKeepDrawFlameDL", From 26d1982f1991ea82ff9b75b445d0a51bbd6b7a80 Mon Sep 17 00:00:00 2001 From: Isghj <42048411+isghj5@users.noreply.github.com> Date: Sat, 19 Feb 2022 06:57:09 -0800 Subject: [PATCH 019/257] EnYb OK (Kamaro, the dancing ghost) (#562) * EnYb: start * EnYb: ah I broke it * EnYb: well at least the draw function matched... * EnYb: back to semi-matching * EnYb: Back to OK, workable again * EnYb: init matches now, ugly as it is for dma padding * EnYb: probably not progress * EnYb: fixes to master merge, back to OK * EnYb: custom shadow function matches * EnYb: more docs, this last function sucks * EnYb: OK thanks to Anon and myxrules * EnYb: docs * EnYb: more docs * EnYb: formatter pass * EnYb: removed unused symbols * Requested changes part 1 * EnYb: Minor changes * EnYb: forgot the spec * EnYb: some display lists documented based on limbs, but two remain because their limbs dont highlight in z64Utils * EnYb:one wrong entry * EnYb: maybe better object documentation * EnYb: fix warnings * EnYb: flag docs * EnYb: changed function * EnYb: more documentation * EnYb: flags enum at top * Update src/overlays/actors/ovl_En_Yb/z_en_yb.c Co-authored-by: Anghelo Carvajal * Update src/overlays/actors/ovl_En_Yb/z_en_yb.c Co-authored-by: Anghelo Carvajal * EnYb: PR fixes * EnYb: formater is picky * EnYb: jenkins bait * EnYb: correct array access * EnYb: formater pass * Apply suggestions from code review Co-authored-by: Derek Hensley * EnYb: fixes * EnYb: more requested changes, formater pass * EnYb: renamed padding * EnYb: object xml name updates * EnYb: merge fix * EnYb: limb enum and small changes * EnYb: scale float fraction found * EnYb: better object limb naming * EnYb: formater pls * EnYb: flipped actor flags to match OOT * Apply suggestions from code review Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * EnYb: more requested changes * EnYb: more animMode enum found * EnYb: doc player playing ocarina Co-authored-by: isghj8 Co-authored-by: Anghelo Carvajal Co-authored-by: Derek Hensley Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> --- assets/xml/objects/object_yb.xml | 104 +++--- spec | 3 +- src/overlays/actors/ovl_En_Yb/z_en_yb.c | 465 ++++++++++++++++++++++-- src/overlays/actors/ovl_En_Yb/z_en_yb.h | 21 +- tools/disasm/functions.txt | 34 +- undefined_syms.txt | 5 - 6 files changed, 514 insertions(+), 118 deletions(-) diff --git a/assets/xml/objects/object_yb.xml b/assets/xml/objects/object_yb.xml index 8cf61e347..1a8503a6e 100644 --- a/assets/xml/objects/object_yb.xml +++ b/assets/xml/objects/object_yb.xml @@ -1,57 +1,61 @@  + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index a5c9e3876..084c06895 100644 --- a/spec +++ b/spec @@ -5042,8 +5042,7 @@ beginseg name "ovl_En_Yb" compress include "build/src/overlays/actors/ovl_En_Yb/z_en_yb.o" - include "build/data/ovl_En_Yb/ovl_En_Yb.data.o" - include "build/data/ovl_En_Yb/ovl_En_Yb.reloc.o" + include "build/src/overlays/actors/ovl_En_Yb/ovl_En_Yb_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.c b/src/overlays/actors/ovl_En_Yb/z_en_yb.c index bb3f81576..73ae77f67 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -5,8 +5,9 @@ */ #include "z_en_yb.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnYb*)thisx) @@ -15,16 +16,22 @@ void EnYb_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnYb_Update(Actor* thisx, GlobalContext* globalCtx); void EnYb_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BFA730(EnYb* this, GlobalContext* globalCtx); -void func_80BFA868(EnYb* this, GlobalContext* globalCtx); -void func_80BFA91C(EnYb* this, GlobalContext* globalCtx); -void func_80BFA9D4(EnYb* this, GlobalContext* globalCtx); -void func_80BFAB4C(EnYb* this, GlobalContext* globalCtx); -void func_80BFABF0(EnYb* this, GlobalContext* globalCtx); -void func_80BFAC88(EnYb* this, GlobalContext* globalCtx); -void func_80BFAE80(EnYb* this, GlobalContext* globalCtx); +void EnYb_Idle(EnYb* this, GlobalContext* globalCtx); +void EnYb_TeachingDanceFinish(EnYb* this, GlobalContext* globalCtx); +void EnYb_SetupLeaving(EnYb* this, GlobalContext* globalCtx); + +void EnYb_UpdateAnimation(EnYb* this, GlobalContext* globalCtx); +void EnYb_FinishTeachingCutscene(EnYb* this); +void EnYb_Disappear(EnYb* this, GlobalContext* globalCtx); +void EnYb_ReceiveMask(EnYb* this, GlobalContext* globalCtx); +void EnYb_Talk(EnYb* this, GlobalContext* globalCtx); +void EnYb_TeachingDance(EnYb* this, GlobalContext* globalCtx); +void EnYb_WaitForMidnight(EnYb* this, GlobalContext* globalCtx); + +void EnYb_ActorShadowFunc(Actor* thisx, Lights* mapper, GlobalContext* globalCtx); +void EnYb_SetAnimation(GlobalContext*, EnYb*, s16, u8, f32); +s32 EnYb_CanTalk(EnYb* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Yb_InitVars = { ACTOR_EN_YB, ACTORCAT_NPC, @@ -37,59 +44,439 @@ const ActorInit En_Yb_InitVars = { (ActorFunc)EnYb_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BFB2B0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 40, 0, { 0, 0, 0 } }, }; -#endif +// crashes if I try to mod it in to look at it +// assumption: draw uses two different skeleton functions, might be incompatible +static AnimationHeader* gYbUnusedAnimations[] = { &object_yb_Anim_000200 }; -extern ColliderCylinderInit D_80BFB2B0; +static LinkAnimationHeader* gLinkAnimations[] = { &gameplay_keep_Linkanim_00DF28, &gameplay_keep_Linkanim_00CF98 }; -extern UNK_TYPE D_06000200; +static Vec3f D_80BFB2E8 = { 0.0f, 0.5f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/EnYb_Init.s") +static Vec3f D_80BFB2F4 = { 500.0f, -500.0, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/EnYb_Destroy.s") +static Vec3f D_80BFB300 = { 500.0f, -500.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA2FC.s") +void EnYb_Init(Actor* thisx, GlobalContext* globalCtx) { + EnYb* this = THIS; + s16 tempCutscene; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA350.s") + Actor_SetScale(&this->actor, 0.01f); + ActorShape_Init(&this->actor.shape, 0.0f, EnYb_ActorShadowFunc, 20.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA444.s") + // @Bug this alignment is because of player animations, but should be using ALIGN16 + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gYbSkeleton, &object_yb_Anim_000200, + (uintptr_t)this->jointTable & ~0xF, (uintptr_t)this->morphTable & ~0xF, YB_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA5CC.s") + Animation_PlayLoop(&this->skelAnime, &object_yb_Anim_000200); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA634.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actionFunc = EnYb_Idle; + this->currentAnimIndex = 3; // gets overwritten to 2 in EnYb_SetAnimation later + this->actor.terminalVelocity = -9.0f; + this->actor.gravity = -1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA67C.s") + EnYb_SetAnimation(globalCtx, this, 2, ANIMMODE_LOOP, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA6E0.s") + tempCutscene = this->actor.cutscene; + for (i = 0; i < ARRAY_COUNT(this->cutscenes); i++) { + this->cutscenes[i] = tempCutscene; + if (tempCutscene != -1) { + this->actor.cutscene = tempCutscene; + tempCutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA710.s") + this->cutsceneIndex = -1; + this->actor.cutscene = this->cutscenes[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA730.s") + // between midnight and morning start spawned + if (gSaveContext.time < CLOCK_TIME(6, 0)) { + this->alpha = 255; + } else { // else (night 6pm to midnight): wait to appear + this->alpha = 0; + this->actionFunc = EnYb_WaitForMidnight; + this->actor.flags &= ~ACTOR_FLAG_1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA868.s") + // check if already healed + if (gSaveContext.weekEventReg[82] & 4) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA91C.s") +void EnYb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnYb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA9D4.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFAB4C.s") +void func_80BFA2FC(GlobalContext* globalCtx) { + if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) { + func_80151BB4(globalCtx, 0x34); + } + func_80151BB4(globalCtx, 0xF); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFABF0.s") +/** + * Custom shadow draw function of type ActorShadowFunc. + */ +void EnYb_ActorShadowFunc(Actor* thisx, Lights* mapper, GlobalContext* globalCtx) { + Vec3f oldPos; + EnYb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFAC88.s") + if (this->alpha > 0) { + if (this->currentAnimIndex == 2) { + f32 tempScale = (((27.0f - this->shadowPos.y) + this->actor.world.pos.y) * ((1 / 2.25f) * 0.001f)) + 0.01f; + this->actor.scale.x = tempScale; + } + Math_Vec3f_Copy(&oldPos, &this->actor.world.pos); + Math_Vec3f_Copy(&this->actor.world.pos, &this->shadowPos); + func_800B4AEC(globalCtx, &this->actor, 50.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFAE80.s") + if (oldPos.y < this->actor.floorHeight) { + this->actor.world.pos.y = this->actor.floorHeight; + } else { + this->actor.world.pos.y = oldPos.y; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/EnYb_Update.s") + ActorShadow_DrawCircle(&this->actor, mapper, globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &oldPos); + this->actor.scale.x = 0.01f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFB074.s") +void EnYb_SetAnimation(GlobalContext* globalCtx, EnYb* this, s16 animIndex, u8 animMode, f32 transitionRate) { + if (animIndex >= 0 && animIndex < 3) { + if (animIndex != this->currentAnimIndex || animMode != ANIMMODE_LOOP) { + if (animIndex > 0) { + if (animMode == ANIMMODE_LOOP) { + LinkAnimation_Change(globalCtx, &this->skelAnime, gLinkAnimations[animIndex - 1], 1.0f, 0.0f, + Animation_GetLastFrame(gLinkAnimations[animIndex - 1]), ANIMMODE_LOOP, + transitionRate); + } else { + // unused case, (only called once with animMode = ANIMMODE_LOOP) + LinkAnimation_Change(globalCtx, &this->skelAnime, gLinkAnimations[animIndex - 1], 1.0f, 0.0f, + Animation_GetLastFrame(gLinkAnimations[animIndex - 1]), ANIMMODE_LOOP, + transitionRate); + } + } else { + // unused case, (only called once with animIndex = 2) + AnimationHeader* animationPtr = gYbUnusedAnimations[animIndex]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFB0E0.s") + if (1) {} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/EnYb_Draw.s") + Animation_Change(&this->skelAnime, gYbUnusedAnimations[animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(animationPtr), animMode, transitionRate); + } + this->currentAnimIndex = animIndex; + } + } +} + +s32 EnYb_CanTalk(EnYb* this, GlobalContext* globalCtx) { + if (this->actor.xzDistToPlayer < 100.0f && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsFacingPlayer(&this->actor, 0x3000)) { + return true; + } else { + return false; + } +} + +void EnYb_UpdateAnimation(EnYb* this, GlobalContext* globalCtx) { + if (this->currentAnimIndex <= 0) { + SkelAnime_Update(&this->skelAnime); + } else { + LinkAnimation_Update(globalCtx, &this->skelAnime); + } +} + +void EnYb_FinishTeachingCutscene(EnYb* this) { + if (this->cutsceneIndex != -1) { + if (ActorCutscene_GetCurrentIndex() == this->cutscenes[this->cutsceneIndex]) { + ActorCutscene_Stop(this->cutscenes[this->cutsceneIndex]); + } + this->cutsceneIndex = -1; + } +} + +void EnYb_ChangeCutscene(EnYb* this, s16 cutsceneId) { + EnYb_FinishTeachingCutscene(this); + this->cutsceneIndex = cutsceneId; +} + +/** + * Sets a flag that enables the Kamaro dancing proximity music at night. + */ +void EnYb_EnableProximityMusic(EnYb* this) { + func_800B9084(&this->actor); +} + +void EnYb_Disappear(EnYb* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp60; + s32 i; + + EnYb_UpdateAnimation(this, globalCtx); + for (i = 3; i >= 0; i--) { + sp60.x = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.x; + sp60.z = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.z; + sp60.y = randPlusMinusPoint5Scaled(50.0f) + (this->actor.world.pos.y + 20.0f); + func_800B3030(globalCtx, &sp60, &D_80BFB2E8, &D_80BFB2E8, 100, 0, 2); + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EN_EXTINCT); + if (this->alpha > 10) { + this->alpha -= 10; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void EnYb_SetupLeaving(EnYb* this, GlobalContext* globalCtx) { + EnYb_UpdateAnimation(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + this->actionFunc = EnYb_Talk; + // I am counting on you + func_801518B0(globalCtx, 0x147D, &this->actor); + func_80BFA2FC(globalCtx); + } else { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } + EnYb_EnableProximityMusic(this); +} + +void EnYb_ReceiveMask(EnYb* this, GlobalContext* globalCtx) { + EnYb_UpdateAnimation(this, globalCtx); + // Player is parent: receiving the Kamaro mask + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = EnYb_SetupLeaving; + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_MASK_KAMARO, 10000.0f, 100.0f); + } + EnYb_EnableProximityMusic(this); +} + +void EnYb_Talk(EnYb* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); + this->actor.world.rot.y = this->actor.shape.rot.y; + EnYb_UpdateAnimation(this, globalCtx); + + if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x147D: // I am counting on you + func_801477B4(globalCtx); + this->actionFunc = EnYb_Disappear; + gSaveContext.weekEventReg[82] |= 0x4; + break; + case 0x147C: // Spread my dance across the world + if (Player_GetMask(globalCtx) == PLAYER_MASK_KAMARO) { + func_801477B4(globalCtx); + this->actionFunc = EnYb_Idle; + + } else if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) { + func_80151938(globalCtx, 0x147D); // I am counting on you + func_80BFA2FC(globalCtx); + + } else { + func_801477B4(globalCtx); + this->actionFunc = EnYb_ReceiveMask; + EnYb_ReceiveMask(this, globalCtx); + } + break; + default: + func_801477B4(globalCtx); + this->actionFunc = EnYb_Idle; + break; + } + } + EnYb_EnableProximityMusic(this); +} + +void EnYb_TeachingDanceFinish(EnYb* this, GlobalContext* globalCtx) { + EnYb_UpdateAnimation(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = EnYb_Talk; + // Spread my dance across the world + func_801518B0(globalCtx, 0x147C, &this->actor); + this->actor.flags &= ~ACTOR_FLAG_10000; + } else { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } + EnYb_EnableProximityMusic(this); +} + +// dancing countdown +void EnYb_TeachingDance(EnYb* this, GlobalContext* globalCtx) { + EnYb_UpdateAnimation(this, globalCtx); + + if (this->teachingCutsceneTimer > 0) { + this->teachingCutsceneTimer--; + } else { + EnYb_FinishTeachingCutscene(this); + this->actionFunc = EnYb_TeachingDanceFinish; + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } + EnYb_EnableProximityMusic(this); +} + +void EnYb_Idle(EnYb* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + EnYb_UpdateAnimation(this, globalCtx); + if (this->actor.xzDistToPlayer < 180.0f && fabsf(this->actor.playerHeightRel) < 50.0f && + globalCtx->msgCtx.ocarinaMode == 3 && globalCtx->msgCtx.unk1202E == 7 && + gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + this->actionFunc = EnYb_TeachingDance; + this->teachingCutsceneTimer = 200; + EnYb_ChangeCutscene(this, 0); + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80BFA2FC(globalCtx); + this->actionFunc = EnYb_Talk; + if (Player_GetMask(globalCtx) == PLAYER_MASK_KAMARO) { + // I have taught you, go use it + func_801518B0(globalCtx, 0x147C, &this->actor); + } else { + // regular talk to him first dialogue + func_801518B0(globalCtx, 0x147B, &this->actor); + } + } else if (EnYb_CanTalk(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } + + if (this->playerOcarinaOut & 1) { + if (!(player->stateFlags2 & 0x8000000)) { + this->playerOcarinaOut &= ~1; + } + } else if ((player->stateFlags2 & 0x8000000) && this->actor.xzDistToPlayer < 180.0f && + fabsf(this->actor.playerHeightRel) < 50.0f) { + this->playerOcarinaOut |= 1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + } + + EnYb_EnableProximityMusic(this); +} + +void EnYb_WaitForMidnight(EnYb* this, GlobalContext* globalCtx) { + if (gSaveContext.time < CLOCK_TIME(6, 0)) { + EnYb_UpdateAnimation(this, globalCtx); + this->alpha += 5; + if (this->alpha > 250) { + this->alpha = 255; + this->actor.flags |= ACTOR_FLAG_1; + this->actionFunc = EnYb_Idle; + } + EnYb_EnableProximityMusic(this); + } +} + +void EnYb_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnYb* this = THIS; + + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_1)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_1)) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 25.0f, 40.0f, 5); + } + + this->actionFunc(this, globalCtx); + + if (this->cutsceneIndex != -1 && ActorCutscene_GetCurrentIndex() != this->cutscenes[this->cutsceneIndex]) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->cutscenes[this->cutsceneIndex]); + } else if (ActorCutscene_GetCanPlayNext(this->cutscenes[this->cutsceneIndex])) { + if (this->cutsceneIndex == 0) { + ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[this->cutsceneIndex], &this->actor); + } + } else { + ActorCutscene_SetIntentToPlay(this->cutscenes[this->cutsceneIndex]); + } + } +} + +void EnYb_PostLimbDrawOpa(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnYb* this = THIS; + + if (limbIndex == YB_LIMB_HEAD) { + Matrix_MultiplyVector3fByState(&D_80BFB2F4, &this->actor.focus.pos); + } + if (limbIndex == YB_LIMB_LEGS_ROOT) { + Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->shadowPos); + } +} + +void EnYb_PostLimbDrawXlu(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnYb* this = THIS; + + if (limbIndex == YB_LIMB_HEAD) { + Matrix_MultiplyVector3fByState(&D_80BFB300, &this->actor.focus.pos); + } + if (limbIndex == YB_LIMB_LEGS_ROOT) { + Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->shadowPos); + } +} + +void EnYb_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnYb* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->alpha != 0) { + if (this->alpha < 255) { + if (this->alpha > 128) { + func_8012C2B4(POLY_XLU_DISP++); + Scene_SetRenderModeXlu(globalCtx, 2, 2); + } else { + func_8012C304(POLY_XLU_DISP++); + Scene_SetRenderModeXlu(globalCtx, 1, 2); + } + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); + + if (1) {} + + POLY_XLU_DISP = + SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, EnYb_PostLimbDrawXlu, &this->actor, POLY_XLU_DISP); + + } else { + func_8012C28C(globalCtx->state.gfxCtx); + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, EnYb_PostLimbDrawOpa, &this->actor); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.h b/src/overlays/actors/ovl_En_Yb/z_en_yb.h index ca8a59d93..1b4c898a2 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.h +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.h @@ -2,17 +2,28 @@ #define Z_EN_YB_H #include "global.h" +#include "objects/object_yb/object_yb.h" struct EnYb; typedef void (*EnYbActionFunc)(struct EnYb*, GlobalContext*); typedef struct EnYb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x2DC]; - /* 0x0420 */ EnYbActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[YB_LIMB_MAX]; + /* 0x20C */ UNK_TYPE1 unkPadding20C[0x94]; + /* 0x2A0 */ Vec3s morphTable[YB_LIMB_MAX]; + /* 0x324 */ UNK_TYPE1 unkPadding324[0x94]; + /* 0x3B8 */ ColliderCylinder collider; + /* 0x404 */ Vec3f shadowPos; + /* 0x410 */ u16 playerOcarinaOut; + /* 0x412 */ s16 currentAnimIndex; + /* 0x414 */ s16 alpha; + /* 0x416 */ s16 cutscenes[2]; + /* 0x41A */ s16 cutsceneIndex; + /* 0x41C */ s16 teachingCutsceneTimer; + /* 0x420 */ EnYbActionFunc actionFunc; } EnYb; // size = 0x424 -extern const ActorInit En_Yb_InitVars; - #endif // Z_EN_YB_H diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 3f1a4541c..8e58c7435 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16379,24 +16379,24 @@ 0x80BFA100:("EnYb_Init",), 0x80BFA2D0:("EnYb_Destroy",), 0x80BFA2FC:("func_80BFA2FC",), - 0x80BFA350:("func_80BFA350",), - 0x80BFA444:("func_80BFA444",), - 0x80BFA5CC:("func_80BFA5CC",), - 0x80BFA634:("func_80BFA634",), - 0x80BFA67C:("func_80BFA67C",), - 0x80BFA6E0:("func_80BFA6E0",), - 0x80BFA710:("func_80BFA710",), - 0x80BFA730:("func_80BFA730",), - 0x80BFA868:("func_80BFA868",), - 0x80BFA91C:("func_80BFA91C",), - 0x80BFA9D4:("func_80BFA9D4",), - 0x80BFAB4C:("func_80BFAB4C",), - 0x80BFABF0:("func_80BFABF0",), - 0x80BFAC88:("func_80BFAC88",), - 0x80BFAE80:("func_80BFAE80",), + 0x80BFA350:("EnYb_ActorShadowFunc",), + 0x80BFA444:("EnYb_SetAnimation",), + 0x80BFA5CC:("EnYb_CanTalk",), + 0x80BFA634:("EnYb_UpdateAnimation",), + 0x80BFA67C:("EnYb_FinishTeachingCutscene",), + 0x80BFA6E0:("EnYb_ChangeCutscene",), + 0x80BFA710:("EnYb_EnableProximityMusic",), + 0x80BFA730:("EnYb_Disappear",), + 0x80BFA868:("EnYb_SetupLeaving",), + 0x80BFA91C:("EnYb_ReceiveMask",), + 0x80BFA9D4:("EnYb_Talk",), + 0x80BFAB4C:("EnYb_TeachingDanceFinish",), + 0x80BFABF0:("EnYb_TeachingDance",), + 0x80BFAC88:("EnYb_Idle",), + 0x80BFAE80:("EnYb_WaitForMidnight",), 0x80BFAEFC:("EnYb_Update",), - 0x80BFB074:("func_80BFB074",), - 0x80BFB0E0:("func_80BFB0E0",), + 0x80BFB074:("EnYb_PostLimbDrawOpa",), + 0x80BFB0E0:("EnYb_PostLimbDrawXlu",), 0x80BFB14C:("EnYb_Draw",), 0x80BFB480:("EnRz_Init",), 0x80BFB780:("func_80BFB780",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 38b0953cc..3aa77e775 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2049,11 +2049,6 @@ D_06005C64 = 0x06005C64; D_06000700 = 0x06000700; -// ovl_En_Yb - -D_06000200 = 0x06000200; -D_06005F48 = 0x06005F48; - // ovl_En_Zl4 D_06013328 = 0x06013328; From 926b575d13c8734bee95b99b79d8ec7ccb94b765 Mon Sep 17 00:00:00 2001 From: Isghj <42048411+isghj5@users.noreply.github.com> Date: Sat, 19 Feb 2022 10:59:43 -0800 Subject: [PATCH 020/257] EnAni OK (Man in Tree in South Termina Field) (#566) * EnAni:Start * EnAni: done with matching * EnAni: docs * EnAni: forgot the display lists, they wouldnt load in z64utils, had to use limb->DL to name them * EnAni: forgot the spec, so rusty * Apply suggestions from code review Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * EnAni: more requested changes * EnAni: format pass * EnAni: remove typedef warning * EnAni: typdef attempt * Apply suggestions from code review Co-authored-by: Anghelo Carvajal * EnAni: changed ani state flags from enum to defines * EnAni: formatter no * EnAni: undefined behavior * EnAni: chest rot discovered * EnAni: fixes after merging * EnAni: flags docs * EnAni: flags at top using enum * EnAni: jenkins bait * EnAni: revert bgcheck flag * EnAni: single doc * EnOssan: format after fix to EnAni * EnAni: requested changes, some documentation changes * EnAni: forgot to re-extract * EnAni: better object naming * EnAni: changed STATE_SUFFERING to STATE_WRITHING to match object docs, removed extra whitespace from defines * EnAni: removed object comment about z64util not rendering them * EnAni: flipped actor flag to match OOT * EnAni: formater pls * EnAni: Animatation Enum values in Animation_change calls Co-authored-by: Isghj8 Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Co-authored-by: Anghelo Carvajal --- assets/xml/objects/object_ani.xml | 121 ++++--- spec | 3 +- src/overlays/actors/ovl_En_Ani/z_en_ani.c | 335 ++++++++++++++++-- src/overlays/actors/ovl_En_Ani/z_en_ani.h | 29 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 28 +- tools/disasm/functions.txt | 28 +- 6 files changed, 416 insertions(+), 128 deletions(-) diff --git a/assets/xml/objects/object_ani.xml b/assets/xml/objects/object_ani.xml index f9915c880..f039e0114 100644 --- a/assets/xml/objects/object_ani.xml +++ b/assets/xml/objects/object_ani.xml @@ -1,62 +1,67 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index 084c06895..20f30c61f 100644 --- a/spec +++ b/spec @@ -1729,8 +1729,7 @@ beginseg name "ovl_En_Ani" compress include "build/src/overlays/actors/ovl_En_Ani/z_en_ani.o" - include "build/data/ovl_En_Ani/ovl_En_Ani.data.o" - include "build/data/ovl_En_Ani/ovl_En_Ani.reloc.o" + include "build/src/overlays/actors/ovl_En_Ani/ovl_En_Ani_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.c b/src/overlays/actors/ovl_En_Ani/z_en_ani.c index c12578420..d2320bfd6 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -1,21 +1,44 @@ /* * File: z_en_ani.c * Overlay: ovl_En_Ani - * Description: Part-time worker + * Description: Man in Tree in South Termina Field + * version in shop at night is EnOssan actor using object_ani */ #include "z_en_ani.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnAni*)thisx) +// clang-format off +#define ANI_STATE_STANDING (0) +#define ANI_STATE_UNK (1 << 0) +#define ANI_STATE_WRITHING (1 << 1) +#define ANI_STATE_CLIMBING (1 << 2) +#define ANI_STATE_FALLING (1 << 3) +// clang-format on + void EnAni_Init(Actor* thisx, GlobalContext* globalCtx); void EnAni_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnAni_Update(Actor* thisx, GlobalContext* globalCtx); void EnAni_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnAni_DefaultBlink(EnAni* this); +void EnAni_WaitForEyeClose(EnAni* this); +void EnAni_WaitForEyeOpen(EnAni* this); + +void EnAni_SetText(EnAni* this, GlobalContext* globalCtx, u16 textId); + +void EnAni_HangInTree(EnAni* this, GlobalContext* globalCtx); +void EnAni_LoseBalance(EnAni* this, GlobalContext* globalCtx); +void EnAni_FallToGround(EnAni* this, GlobalContext* globalCtx); +void EnAni_LandOnFoot(EnAni* this, GlobalContext* globalCtx); +void EnAni_FallOverInPain(EnAni* this, GlobalContext* globalCtx); +void EnAni_IdleInPain(EnAni* this, GlobalContext* globalCtx); +void EnAni_Talk(EnAni* this, GlobalContext* globalCtx); +void EnAni_IdleStanding(EnAni* this, GlobalContext* globalCtx); + const ActorInit En_Ani_InitVars = { ACTOR_EN_ANI, ACTORCAT_NPC, @@ -28,62 +51,304 @@ const ActorInit En_Ani_InitVars = { (ActorFunc)EnAni_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80968670 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +// two different colliders, but only one init for both +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8096869C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 850, ICHAIN_STOP), }; -#endif +void EnAni_DefaultBlink(EnAni* this) { + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(60, 60); + } -extern ColliderCylinderInit D_80968670; -extern InitChainEntry D_8096869C[]; + this->eyeState = this->blinkTimer; + if (this->eyeState >= 3) { + this->eyeState = 0; + } +} -extern UNK_TYPE D_06000C14; -extern UNK_TYPE D_060011CC; -extern UNK_TYPE D_060027A0; -extern UNK_TYPE D_06009220; -extern UNK_TYPE D_06009D34; +void EnAni_WaitForEyeClose(EnAni* this) { + if (this->blinkTimer > 0) { + this->blinkTimer--; + } else if (this->eyeState < 2) { + this->eyeState++; + } else { + this->blinkFunc = EnAni_WaitForEyeOpen; + this->blinkTimer = Rand_S16Offset(20, 20); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_809679D0.s") +void EnAni_WaitForEyeOpen(EnAni* this) { + if (this->blinkTimer > 0) { + this->blinkTimer--; + } else if (this->eyeState > 0) { + this->eyeState--; + } else { + this->blinkFunc = EnAni_WaitForEyeClose; + this->blinkTimer = Rand_S16Offset(10, 10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967A48.s") +void EnAni_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnAni* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967AB4.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gAniSkeleton, &gAniStandingNormalAnim, this->jointTable, + this->morphTable, ANI_LIMB_MAX); + Animation_PlayOnce(&this->skelAnime, &gAniStandingNormalAnim); + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider2); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->stateFlags = ANI_STATE_STANDING; + this->unk2EE = 0; + this->treeReachTimer = 0; + this->blinkFunc = EnAni_DefaultBlink; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/EnAni_Init.s") + if (GET_ANI_TYPE(thisx) == ANI_TYPE_TREE_HANGING) { + Animation_Change(&this->skelAnime, &gAniTreeHangingAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gAniTreeHangingAnim), ANIMMODE_ONCE, 0.0f); + this->actionFunc = EnAni_HangInTree; + this->actor.velocity.y = 0.0f; + this->actor.terminalVelocity = 0.0f; + this->actor.gravity = 0.0f; + this->actor.flags |= ACTOR_FLAG_10; + this->stateFlags |= ANI_STATE_CLIMBING; + gSaveContext.eventInf[1] &= (u8)~0x10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/EnAni_Destroy.s") + } else { // ANI_TYPE_STANDING + // ( unused code ) + // for some reason standing he has a large collider + // possibly he was meant to be a blocking npc like bomber + this->collider2.dim.radius = 60; + this->actionFunc = EnAni_IdleStanding; + this->actor.velocity.y = -25.0f; + this->actor.terminalVelocity = -25.0f; + this->actor.gravity = -5.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967D20.s") +void EnAni_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAni* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967DA0.s") + Collider_DestroyCylinder(globalCtx, &this->collider1); + Collider_DestroyCylinder(globalCtx, &this->collider2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967DCC.s") +void EnAni_SetText(EnAni* this, GlobalContext* globalCtx, u16 textId) { + s16 diffAngle = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967E34.s") + this->actor.textId = textId; + if ((this->stateFlags & ANI_STATE_WRITHING) || ABS_ALT(diffAngle) <= 0x4300) { + if (this->actor.xzDistToPlayer < 100.0f) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967E90.s") +void EnAni_IdleStanding(EnAni* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967F20.s") +void EnAni_Talk(EnAni* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (Message_GetState(&globalCtx->msgCtx) == 2 && globalCtx->msgCtx.unk11F04 == 0x6DE) { + this->actionFunc = EnAni_IdleInPain; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967FA4.s") +void EnAni_IdleInPain(EnAni* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = EnAni_Talk; + } else { + // telling you not to take his rupees you knocked from the tree + EnAni_SetText(this, globalCtx, 0x6DE); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_809680B0.s") +void EnAni_FallOverInPain(EnAni* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + this->blinkFunc = EnAni_WaitForEyeOpen; + this->actionFunc = EnAni_IdleInPain; + Animation_Change(&this->skelAnime, &gAniHoldingFootWrithingInPainAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gAniHoldingFootWrithingInPainAnim), ANIMMODE_LOOP, 0.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80968164.s") +void EnAni_LandOnFoot(EnAni* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + this->actionFunc = EnAni_FallOverInPain; + Animation_Change(&this->skelAnime, &gAniFallOverHoldingFootAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gAniFallOverHoldingFootAnim), ANIMMODE_ONCE, 0.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/EnAni_Update.s") +void EnAni_FallToGround(EnAni* this, GlobalContext* globalCtx) { + s32 pad; + s16 quakeValue; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80968504.s") + if (this->actor.bgCheckFlags & 1) { // hit the ground + this->actor.flags &= ~ACTOR_FLAG_10; + this->actionFunc = EnAni_LandOnFoot; + this->actor.velocity.x = 0.0f; + this->actor.velocity.z = 0.0f; + // the animation gets cut short, (first 16 frames only) only the landing part is seen + Animation_Change(&this->skelAnime, &gAniLandingThenStandingUpAnim, 1.0f, 0.0f, 16.0f, ANIMMODE_ONCE, 0.0f); + this->stateFlags |= ANI_STATE_WRITHING; + quakeValue = Quake_Add(globalCtx->cameraPtrs[0], 3); + Quake_SetSpeed(quakeValue, 0x6978); + Quake_SetQuakeValues(quakeValue, 7, 0, 0, 0); + Quake_SetCountdown(quakeValue, 0x14); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_HAMMER_HIT); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_8096854C.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2, 0x7D0, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/EnAni_Draw.s") +void EnAni_LoseBalance(EnAni* this, GlobalContext* globalCtx) { + s32 pad; + + if (SkelAnime_Update(&this->skelAnime)) { + this->actor.terminalVelocity = -20.0f; + this->actor.gravity = -5.0f; + this->actor.velocity.y = 0.0f; + this->actor.velocity.z = -4.0f; + // frame count : 0.0f, only first frame, rest is handled in next action func + Animation_Change(&this->skelAnime, &gAniLandingThenStandingUpAnim, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 5.0f); + this->actionFunc = EnAni_FallToGround; + gSaveContext.eventInf[1] |= 0x10; + } +} + +void EnAni_HangInTree(EnAni* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->treeReachTimer > 0) { + this->treeReachTimer--; + if (this->treeReachTimer > 0) { + Animation_PlayOnce(&this->skelAnime, &gAniTreeHangingReachAnim); + } else { + Animation_PlayOnce(&this->skelAnime, &gAniTreeHangingAnim); + } + } else if (Rand_ZeroFloat(1.0f) < 0.4f) { + Animation_PlayOnce(&this->skelAnime, &gAniTreeHangingReachAnim); + this->treeReachTimer = 2; + } else { + Animation_PlayOnce(&this->skelAnime, &gAniTreeHangingAnim); + } + } + + // his bonk detection is based on his tilt, neat + if (this->actor.home.rot.x != 0) { + this->stateFlags |= ANI_STATE_FALLING; + this->actionFunc = EnAni_LoseBalance; + Animation_Change(&this->skelAnime, &gAniTreeHangLosingBalanceAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gAniTreeHangLosingBalanceAnim), ANIMMODE_ONCE, -5.0f); + } +} + +void EnAni_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAni* this = THIS; + f32 minVelocity; + + Collider_UpdateCylinder(&this->actor, &this->collider1); + Collider_UpdateCylinder(&this->actor, &this->collider2); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + if (!(this->stateFlags & ANI_STATE_UNK)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } + + this->actor.velocity.y += this->actor.gravity; + minVelocity = this->actor.terminalVelocity; + if (this->actor.velocity.y < minVelocity) { + this->actor.velocity.y = minVelocity; + } + + Actor_UpdatePos(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + this->actionFunc(this, globalCtx); + if (this->actor.xzDistToPlayer < 100.0f && !(this->stateFlags & ANI_STATE_CLIMBING)) { + func_800E9250(globalCtx, &this->actor, &this->headRot, &this->chestRot, this->actor.focus.pos); + this->chestRot.x = this->chestRot.y = this->chestRot.z = 0; + } else { + Math_SmoothStepToS(&this->headRot.x, 0, 0x6, 0x1838, 0x64); + Math_SmoothStepToS(&this->headRot.y, 0, 0x6, 0x1838, 0x64); + Math_SmoothStepToS(&this->chestRot.x, 0, 0x6, 0x1838, 0x64); + Math_SmoothStepToS(&this->chestRot.y, 0, 0x6, 0x1838, 0x64); + } + + this->blinkFunc(this); + if (this->stateFlags & ANI_STATE_FALLING) { + if (this->actor.cutscene == -1) { + this->stateFlags &= ~ANI_STATE_FALLING; + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + func_800E02AC(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->actor.cutscene)), + &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} + +s32 EnAni_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnAni* this = THIS; + + if (limbIndex == ANI_LIMB_HEAD) { + rot->x += this->headRot.y; + rot->z += this->headRot.x; + } + + return false; +} + +void EnAni_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_809686A4 = { 800.0f, 500.0f, 0.0f }; + + if (limbIndex == ANI_LIMB_HEAD) { + Matrix_MultiplyVector3fByState(&D_809686A4, &thisx->focus.pos); + } +} + +void EnAni_Draw(Actor* thisx, GlobalContext* globalCtx) { + static TexturePtr sEyeTextures[] = { gAniOpenEyeTex, gAniClosingEyeTex, gAniClosedEyeTex }; + s32 pad; + EnAni* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(0.0f, 0.0f, -1000.0f, MTXMODE_APPLY); + func_8012C5B0(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeState])); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnAni_OverrideLimbDraw, EnAni_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.h b/src/overlays/actors/ovl_En_Ani/z_en_ani.h index 554c1bc8a..21dced2c1 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.h +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.h @@ -2,18 +2,37 @@ #define Z_EN_ANI_H #include "global.h" +#include "objects/object_ani/object_ani.h" struct EnAni; typedef void (*EnAniActionFunc)(struct EnAni*, GlobalContext*); +typedef void (*EnAniBlinkFunc)(struct EnAni*); + typedef struct EnAni { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1B0]; - /* 0x02F4 */ EnAniActionFunc actionFunc; - /* 0x02F8 */ char unk_2F8[0x8]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider1; + /* 0x190 */ ColliderCylinder collider2; + /* 0x1DC */ SkelAnime skelAnime; + /* 0x220 */ Vec3s jointTable[ANI_LIMB_MAX]; + /* 0x280 */ Vec3s morphTable[ANI_LIMB_MAX]; + /* 0x2E0 */ Vec3s headRot; + /* 0x2E6 */ Vec3s chestRot; // unused + /* 0x2EC */ u16 stateFlags; + /* 0x2EE */ s16 unk2EE; // assigned to zero in init, never used after + /* 0x2F0 */ s16 treeReachTimer; + /* 0x2F4 */ EnAniBlinkFunc blinkFunc; + /* 0x2F8 */ s16 eyeState; + /* 0x2FA */ s16 blinkTimer; + /* 0x2FC */ EnAniActionFunc actionFunc; } EnAni; // size = 0x300 -extern const ActorInit En_Ani_InitVars; +enum EnAniType { + /* else */ ANI_TYPE_STANDING, // unfinshed and unused + /* 1 */ ANI_TYPE_TREE_HANGING = 1, +}; + +#define GET_ANI_TYPE(thisx) (thisx->params & 0xFF) #endif // Z_EN_ANI_H diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index 9bf1abcfe..eb82a0fdd 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -82,18 +82,18 @@ static AnimationInfoS sAnimationsCuriosityShopMan[] = { }; static AnimationInfoS sAnimationsPartTimeWorker[] = { - { &object_ani_Anim_009D34, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_ani_Anim_009D34, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_ani_Anim_00A460, 1.0f, 0, -1, ANIMMODE_ONCE, -5 }, - { &object_ani_Anim_00A460, 1.0f, 0, -1, ANIMMODE_LOOP, -5 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gAniStandingNormalAnim, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gAniHandBehindHeadApologyAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -5 }, + { &gAniHandBehindHeadApologyAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -5 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; static s16 sObjectIds[] = { OBJECT_FSN, OBJECT_ANI }; @@ -1331,7 +1331,7 @@ void EnOssan_InitCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_InitPartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ani_Skel_0028A0, &object_ani_Anim_009D34, this->jointTable, + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gAniSkeleton, &gAniStandingNormalAnim, this->jointTable, this->morphTable, 16); this->actor.draw = EnOssan_DrawPartTimeWorker; } @@ -1690,7 +1690,7 @@ void EnOssan_DrawCuriosityShopMan(Actor* thisx, GlobalContext* globalCtx) { } void EnOssan_DrawPartTimeWorker(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr sEyeTextures[] = { object_ani_Tex_006498, object_ani_Tex_006B18, object_ani_Tex_006F18 }; + static TexturePtr sEyeTextures[] = { gAniOpenEyeTex, gAniClosingEyeTex, gAniClosedEyeTex }; EnOssan* this = THIS; s32 pad; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 8e58c7435..e7b722168 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -7929,23 +7929,23 @@ 0x80967608:("func_80967608",), 0x809676A4:("EnWeatherTag_Update",), 0x80967784:("EnWeatherTag_Draw",), - 0x809679D0:("func_809679D0",), - 0x80967A48:("func_80967A48",), - 0x80967AB4:("func_80967AB4",), + 0x809679D0:("EnAni_DefaultBlink",), + 0x80967A48:("EnAni_WaitForEyeClose",), + 0x80967AB4:("EnAni_WaitForEyeOpen",), 0x80967B1C:("EnAni_Init",), 0x80967CE0:("EnAni_Destroy",), - 0x80967D20:("func_80967D20",), - 0x80967DA0:("func_80967DA0",), - 0x80967DCC:("func_80967DCC",), - 0x80967E34:("func_80967E34",), - 0x80967E90:("func_80967E90",), - 0x80967F20:("func_80967F20",), - 0x80967FA4:("func_80967FA4",), - 0x809680B0:("func_809680B0",), - 0x80968164:("func_80968164",), + 0x80967D20:("EnAni_SetText",), + 0x80967DA0:("EnAni_IdleStanding",), + 0x80967DCC:("EnAni_Talk",), + 0x80967E34:("EnAni_IdleInPain",), + 0x80967E90:("EnAni_FallOverInPain",), + 0x80967F20:("EnAni_LandOnFoot",), + 0x80967FA4:("EnAni_FallToGround",), + 0x809680B0:("EnAni_LoseBalance",), + 0x80968164:("EnAni_HangInTree",), 0x809682A8:("EnAni_Update",), - 0x80968504:("func_80968504",), - 0x8096854C:("func_8096854C",), + 0x80968504:("EnAni_OverrideLimbDraw",), + 0x8096854C:("EnAni_PostLimbDraw",), 0x8096858C:("EnAni_Draw",), 0x809687B0:("EnJs_Init",), 0x809689D4:("EnJs_Destroy",), From 30865434983978aa6e4b01b789b21b21bf6d3970 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 19 Feb 2022 19:04:34 +0000 Subject: [PATCH 021/257] En_Ja (#581) * En_Ja * Fix a problem * Merge * Merge * TrasnformDraw * Need static data * PR --- assets/xml/objects/object_boj.xml | 4 +- spec | 3 +- src/overlays/actors/ovl_En_Ja/z_en_ja.c | 738 ++++++++++++++++++++++-- src/overlays/actors/ovl_En_Ja/z_en_ja.h | 50 +- tools/disasm/functions.txt | 6 +- undefined_syms.txt | 6 - 6 files changed, 749 insertions(+), 58 deletions(-) diff --git a/assets/xml/objects/object_boj.xml b/assets/xml/objects/object_boj.xml index f0272cdc0..e59c72027 100644 --- a/assets/xml/objects/object_boj.xml +++ b/assets/xml/objects/object_boj.xml @@ -20,7 +20,9 @@ - + + + diff --git a/spec b/spec index 20f30c61f..54ac468bd 100644 --- a/spec +++ b/spec @@ -4625,8 +4625,7 @@ beginseg name "ovl_En_Ja" compress include "build/src/overlays/actors/ovl_En_Ja/z_en_ja.o" - include "build/data/ovl_En_Ja/ovl_En_Ja.data.o" - include "build/data/ovl_En_Ja/ovl_En_Ja.reloc.o" + include "build/src/overlays/actors/ovl_En_Ja/ovl_En_Ja_reloc.o" endseg beginseg 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 7d8099dbd..a0160fd08 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -5,8 +5,9 @@ */ #include "z_en_ja.h" +#include "objects/object_boj/object_boj.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnJa*)thisx) @@ -17,8 +18,30 @@ void EnJa_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BC21A8(EnJa* this, GlobalContext* globalCtx); void func_80BC22F4(EnJa* this, GlobalContext* globalCtx); +void func_80BC2EA4(EnJa* this); +void func_80BC32D8(EnJa* this, GlobalContext* globalCtx); +void func_80BC3594(EnJa* this, GlobalContext* globalCtx); + +s32 D_80BC35F0[] = { + 0x0C000301, 0x05020600, 0x1200080A, 0x00610304, 0x0002050A, 0x006C0304, 0x00010500, +}; + +s32 D_80BC360C[] = { + 0x0E29370C, 0x170E2938, 0x0C180E29, 0x390C170E, 0x293A0C09, 0x0000180E, 0x293B0C09, 0x00001000, +}; + +s32 D_80BC362C[] = { + 0x0E29400C, 0x170E2941, 0x0C180E29, 0x420C170E, 0x29430C09, 0x0000180E, 0x293B0C09, 0x00001000, +}; + +s32 D_80BC364C[] = { + 0x0E293C0C, 0x170E293D, 0x0C180E29, 0x3E0C170E, 0x293F0C09, 0x0000180E, 0x293B0C09, 0x00001000, +}; + +s32 D_80BC366C[] = { + 0x0E29440C, 0x170E2945, 0x0C180E29, 0x460C170E, 0x29470C09, 0x0000180E, 0x293B0C09, 0x00001000, +}; -#if 0 const ActorInit En_Ja_InitVars = { ACTOR_EN_JA, ACTORCAT_NPC, @@ -31,81 +54,708 @@ const ActorInit En_Ja_InitVars = { (ActorFunc)EnJa_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BC36DC = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +Vec3f D_80BC36AC = { -10.0f, 56.0f, 25.0f }; +Vec3f D_80BC36B8 = { 0.0f, 60.0f, 20.0f }; +Vec3f D_80BC36C4 = { 10.0f, 60.0f, 25.0f }; +Vec3f D_80BC36D0 = { 0.0f, 58.0f, 20.0f }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 12, 64, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BC3708 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfoS sAnimations[] = { + { &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 }, +}; -extern ColliderCylinderInit D_80BC36DC; -extern CollisionCheckInfoInit2 D_80BC3708; +void func_80BC1900(EnJa* this) { + this->skelAnime.playSpeed = this->unk_344; + SkelAnime_Update(&this->skelAnime); +} -extern UNK_TYPE D_0600BA30; -extern UNK_TYPE D_0600BCC8; -extern UNK_TYPE D_0600C240; +s32 func_80BC192C(EnJa* this, s32 arg1) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1900.s") + if (arg1 != this->unk_36C) { + this->unk_36C = arg1; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + this->unk_344 = this->skelAnime.playSpeed; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC192C.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1984.s") +void func_80BC1984(EnJa* this, GlobalContext* globalCtx) { + s32 pad[2]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC19FC.s") + Collider_UpdateCylinder(&this->actor, &this->collider); + this->collider.dim.height = (s16)fabsf(this->actor.focus.pos.y - this->actor.world.pos.y) + 5; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1A68.s") +s32 func_80BC19FC(EnJa* this, GlobalContext* globalCtx) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1AE0.s") + if ((this->unk_340 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_8013AED4(&this->unk_340, 0, 7); + this->actionFunc = func_80BC22F4; + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1B50.s") +void func_80BC1A68(EnJa* this) { + if (DECR(this->unk_360) == 0) { + this->unk_362++; + if (this->unk_362 >= 4) { + this->unk_360 = Rand_S16Offset(30, 30); + this->unk_362 = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1B60.s") +s32 func_80BC1AE0(EnJa* this, GlobalContext* globalCtx) { + Actor* ja = SubS_FindNearestActor(&this->actor, globalCtx, ACTORCAT_NPC, ACTOR_EN_JA); + Vec3f sp30; + Vec3f sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1D70.s") + if (ja != NULL) { + this->actor.child = ja; + Math_Vec3f_Copy(&sp24, &ja->world.pos); + Math_Vec3f_Copy(&sp30, &this->actor.world.pos); + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp30, &sp24); + } else { + this->actor.child = NULL; + } + return this->actor.child; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1E40.s") +Player* func_80BC1B50(EnJa* this, GlobalContext* globalCtx) { + return GET_PLAYER(globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1FC8.s") +s32 func_80BC1B60(EnJa* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC203C.s") + Math_Vec3f_Copy(&sp40, &this->unk_1D8.player->actor.world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); + Math_ApproachS(&this->unk_356, (sp32 - this->unk_35A) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_356 = CLAMP(this->unk_356, -0x1FFE, 0x1FFE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC20D0.s") + Math_ApproachS(&this->unk_35A, (sp32 - this->unk_356) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_35A = CLAMP(this->unk_35A, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC213C.s") + if (this->unk_1D8.player->actor.id == ACTOR_PLAYER) { + sp40.y = this->unk_1D8.player->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_1D8.player->actor.focus.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC2150.s") + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + Math_ApproachS(&this->unk_354, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_358, 4, 0x2AA8); + this->unk_354 = CLAMP(this->unk_354, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC21A8.s") + Math_ApproachS(&this->unk_358, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_354, 4, 0x2AA8); + this->unk_358 = CLAMP(this->unk_358, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC2274.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC22F4.s") +s32 func_80BC1D70(EnJa* this, GlobalContext* globalCtx) { + if (this->unk_340 & 8) { + this->unk_1D8.player = func_80BC1B50(this, globalCtx); + if (this->unk_1D8.player != NULL) { + func_80BC1B60(this, globalCtx); + } + this->unk_340 &= ~0x10; + this->unk_340 |= 0x20; + } else if (this->unk_340 & 0x20) { + this->unk_340 &= ~0x20; + this->unk_354 = 0; + this->unk_356 = 0; + this->unk_358 = 0; + this->unk_35A = 0; + this->unk_35E = 20; + } else if (DECR(this->unk_35E) == 0) { + this->unk_340 |= 0x10; + this->unk_35E = 20; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/EnJa_Init.s") +void func_80BC1E40(EnJa* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp20 = Message_GetState(&globalCtx->msgCtx); + f32 phi_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/EnJa_Destroy.s") + if (((globalCtx->msgCtx.unk11F04 < 0xFF) || (globalCtx->msgCtx.unk11F04 > 0x200)) && (sp20 == 3) && + (this->unk_374 == 3) && (&this->actor == player->targetActor)) { + if ((globalCtx->state.frames % 2) == 0) { + if (this->unk_348 != 0.0f) { + this->unk_348 = 0.0f; + } else { + this->unk_348 = 1.0f; + } + } + } else { + this->unk_348 = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/EnJa_Update.s") + this->unk_34C += (this->unk_348 != 0.0f) ? 60.0f : -60.0f; + this->unk_34C = CLAMP(this->unk_34C, 0.0f, 120.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC25E0.s") + Matrix_InsertTranslation(this->unk_34C, 0.0f, 0.0f, MTXMODE_APPLY); + this->unk_374 = sp20; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC2620.s") +s32 func_80BC1FC8(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC2B30.s") + if (func_80BC1AE0(this, globalCtx)) { + func_8013AED4(&this->unk_340, 3, 7); + this->unk_340 |= 0x10; + func_80BC192C(this, 5); + func_80BC2EA4(this); + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/EnJa_Draw.s") +s32 func_80BC203C(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC2EA4.s") + if (func_80BC1AE0(this, globalCtx)) { + if (ENJA_GET_3(&this->actor) == 0) { + func_80BC192C(this, 1); + } else { + func_80BC192C(this, 4); + } + func_8013AED4(&this->unk_340, 3, 7); + this->actor.shape.shadowDraw = NULL; + this->unk_340 |= 0x50; + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC3154.s") +s32 func_80BC20D0(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC32D8.s") + this->unk_340 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC33C0.s") + switch (arg2->unk0) { + case 1: + ret = func_80BC1FC8(this, globalCtx, arg2); + if (ret == 1) {} + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC3594.s") + case 2: + ret = func_80BC203C(this, globalCtx, arg2); + break; + } + return ret; +} + +s32 func_80BC213C(EnJa* this, GlobalContext* globalCtx) { + return true; +} + +void func_80BC2150(EnJa* this, GlobalContext* globalCtx) { + if ((this->unk_1D8.unk_00 == 1) || (this->unk_1D8.unk_00 == 2)) { + func_80BC213C(this, globalCtx); + } + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 4, 0x1554); +} + +void func_80BC21A8(EnJa* this, GlobalContext* globalCtx) { + u32* unk_14 = &gSaveContext.unk_14; + struct_80133038_arg2 sp18; + + this->unk_35C = REG(15) + *unk_14; + if (!func_80133038(globalCtx, D_80BC35F0, &sp18) || + ((this->unk_1D8.unk_00 != sp18.unk0) && !func_80BC20D0(this, globalCtx, &sp18))) { + this->actor.shape.shadowDraw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + sp18.unk0 = 0; + } else { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.flags |= ACTOR_FLAG_1; + } + this->unk_1D8.unk_00 = sp18.unk0; + func_80BC2150(this, globalCtx); +} + +s32* func_80BC2274(EnJa* this, GlobalContext* globalCtx) { + switch (this->unk_1D8.unk_00) { + case 1: + if (ENJA_GET_3(&this->actor) == 0) { + return D_80BC360C; + } + return D_80BC364C; + + case 2: + if (ENJA_GET_3(&this->actor) == 0) { + return D_80BC362C; + } + return D_80BC366C; + } + return D_80BC360C; +} + +void func_80BC22F4(EnJa* this, GlobalContext* globalCtx) { + if (func_8010BF58(&this->actor, globalCtx, func_80BC2274(this, globalCtx), this->unk_368, &this->unk_1D8.unk_04)) { + this->unk_340 &= ~8; + func_8013AED4(&this->unk_340, 3, 7); + this->unk_1D8.unk_04 = 0; + this->unk_340 |= 0x10; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc = func_80BC21A8; + } +} + +void EnJa_Init(Actor* thisx, GlobalContext* globalCtx) { + EnJa* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_boj_Skel_00C240, NULL, this->jointTable, this->morphTable, + 16); + this->unk_36C = -1; + func_80BC192C(this, 0); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + Actor_SetScale(&this->actor, 0.01f); + this->actor.targetMode = 0; + this->actor.uncullZoneForward = 800.0f; + this->actor.gravity = 0.0f; + func_8013AED4(&this->unk_340, 0, 7); + this->unk_340 |= 0x10; + this->unk_1D8.unk_00 = 0; + this->unk_368 = NULL; + this->actionFunc = func_80BC21A8; +} + +void EnJa_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnJa* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnJa_Update(Actor* thisx, GlobalContext* globalCtx) { + EnJa* this = THIS; + f32 height; + f32 radius; + + func_80BC19FC(this, globalCtx); + + this->actionFunc(this, globalCtx); + + if (this->unk_1D8.unk_00 != 0) { + func_80BC1900(this); + func_80BC1A68(this); + func_80BC1D70(this, globalCtx); + + radius = this->collider.dim.radius + 30; + height = this->collider.dim.height + 10; + func_8013C964(&this->actor, globalCtx, radius, height, 0, this->unk_340 & 7); + + if (this->unk_1D8.unk_00 != 2) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + } + func_80BC1984(this, globalCtx); + } + + if (this->unk_1D8.unk_00 == 1) { + func_80BC32D8(this, globalCtx); + } +} + +s32 EnJa_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnJa* this = THIS; + + if (limbIndex == 15) { + func_80BC1E40(this, globalCtx); + } + return false; +} + +void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80BC3774 = { -87.0f, 444.0f, -49.0f }; + static Vec3f D_80BC3780 = { 600.0f, 0.0f, 0.0f }; + static Vec3f D_80BC378C = { 400.0f, 0.0f, -400.0f }; + static Vec3f D_80BC3798 = { 400.0, 0.0f, 400.0f }; + static Vec3s D_80BC37A4 = { 0x7770, -0x4BC, -0x251C }; + s32 pad; + EnJa* this = THIS; + s32 pad2; + + if (limbIndex == 15) { + Matrix_MultiplyVector3fByState(&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)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + Matrix_JointPosition(&D_80BC3774, &D_80BC37A4); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BA30); + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + 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)))) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + Matrix_InsertTranslation(D_80BC378C.x, D_80BC378C.y, D_80BC378C.z, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gDPPipeSync(POLY_OPA_DISP++); + + switch (this->unk_364) { + case 0: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 255, 255); + break; + + case 1: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 0, 0, 255); + break; + + case 2: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 255, 255); + break; + + case 3: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 0, 255); + break; + + default: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + break; + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BCC8); + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else if (limbIndex == 14) { + if ((this->skelAnime.curFrame >= 0.0f) && (this->skelAnime.curFrame <= 18.0f)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + + Matrix_InsertTranslation(D_80BC3798.x, D_80BC3798.y, D_80BC3798.z, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gDPPipeSync(POLY_OPA_DISP++); + + switch (this->unk_366) { + case 0: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 255, 255); + break; + + case 1: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 0, 0, 255); + break; + + case 2: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 255, 255); + break; + + case 3: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 0, 255); + break; + + default: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + break; + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BCC8); + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } + } +} + +void EnJa_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnJa* this = THIS; + s32 phi_v1; + s32 phi_v0; + + if (this->unk_340 & 0x10) { + phi_v1 = false; + } else { + phi_v1 = true; + } + + if (this->unk_340 & 0x20) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if (!phi_v1) { + phi_v0 = false; + } + + if (limbIndex != 8) { + if (limbIndex == 15) { + func_8013AD9C(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, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_1EC.x, this->unk_1EC.y, this->unk_1EC.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_274.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_274.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_274.z, MTXMODE_APPLY); + Matrix_StatePush(); + } + } else { + func_8013AD9C(this->unk_358 + 0x4000, this->unk_35A + this->actor.shape.rot.y + 0x4000, &this->unk_1F8, + &this->unk_27A, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(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_RotateY(this->unk_27A.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_27A.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_27A.z, MTXMODE_APPLY); + Matrix_StatePush(); + } +} + +void EnJa_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Color_RGBA8 D_80BC37AC[] = { + { 200, 0, 80, 0 }, + { 0, 130, 220, 0 }, + }; + static Color_RGBA8 D_80BC37B4[] = { + { 255, 255, 255, 0 }, + { 255, 255, 255, 0 }, + }; + static TexturePtr D_80BC37BC[] = { + object_boj_Tex_0062B0, + object_boj_Tex_0063B0, + object_boj_Tex_0064B0, + object_boj_Tex_0063B0, + }; + s32 pad; + EnJa* this = THIS; + s32 phi_t2; + + if (ENJA_GET_3(&this->actor) == 0) { + phi_t2 = 0; + } else { + phi_t2 = 1; + } + + if (this->unk_1D8.unk_00 != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_EnvColor(globalCtx->state.gfxCtx, D_80BC37AC[phi_t2].r, D_80BC37AC[phi_t2].g, + D_80BC37AC[phi_t2].b, D_80BC37AC[phi_t2].a)); + gSPSegment(POLY_OPA_DISP++, 0x09, + Gfx_EnvColor(globalCtx->state.gfxCtx, D_80BC37B4[phi_t2].r, D_80BC37B4[phi_t2].g, + D_80BC37B4[phi_t2].b, D_80BC37B4[phi_t2].a)); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(D_80BC37BC[this->unk_362])); + gDPPipeSync(POLY_OPA_DISP++); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnJa_OverrideLimbDraw, EnJa_PostLimbDraw, + EnJa_TransformDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (this->unk_1D8.unk_00 == 1) { + func_80BC3594(this, globalCtx); + } +} + +void func_80BC2EA4(EnJa* this) { + f32 sp44; + f32 sp40; + f32 sp3C; + f32 sp38; + s32 i; + Vec3f sp28; + + sp44 = Math_SinS(this->actor.shape.rot.y); + sp40 = Math_CosS(this->actor.shape.rot.y); + sp3C = Math_SinS(this->actor.child->shape.rot.y); + sp38 = Math_CosS(this->actor.child->shape.rot.y); + + for (i = 0; i < ARRAY_COUNT(this->unk_234); i++) { + this->unk_234[i].unk_0E = i * 0x30; + this->unk_234[i].unk_0C = i; + } + + sp28 = this->actor.world.pos; + this->unk_210 = sp28; + this->unk_204 = sp28; + + sp28 = this->actor.child->world.pos; + this->unk_228 = sp28; + this->unk_21C = sp28; + + this->unk_204.x += (D_80BC36AC.z * sp44) + (D_80BC36AC.x * sp40); + this->unk_204.y += D_80BC36AC.y; + this->unk_204.z += (D_80BC36AC.z * sp40) - (D_80BC36AC.x * sp44); + + this->unk_210.x += (D_80BC36B8.z * sp44) + (D_80BC36B8.x * sp40); + this->unk_210.y += D_80BC36B8.y; + this->unk_210.z += (D_80BC36B8.z * sp40) - (D_80BC36B8.x * sp44); + + this->unk_21C.x += (D_80BC36C4.z * sp3C) + (D_80BC36C4.x * sp38); + this->unk_21C.y += D_80BC36C4.y; + this->unk_21C.z += (D_80BC36C4.z * sp38) - (D_80BC36C4.x * sp3C); + + this->unk_228.x += (D_80BC36D0.z * sp3C) + (D_80BC36D0.x * sp38); + this->unk_228.y += D_80BC36D0.y; + this->unk_228.z += (D_80BC36D0.z * sp38) - (D_80BC36D0.x * sp3C); + + this->unk_364 = 2; + this->unk_366 = 0; +} + +void func_80BC3154(EnJa* this, EnJaStruct* ptr) { + if ((ptr->unk_0E >= 18) && (ptr->unk_0E < 83)) { + f32 temp_f0 = ptr->unk_0E - 18; + + ptr->unk_00.x = (((65.0f - temp_f0) * this->unk_204.x) + (temp_f0 * this->unk_228.x)) / 65.0f; + ptr->unk_00.y = (((65.0f - temp_f0) * this->unk_204.y) + (temp_f0 * this->unk_228.y)) / 65.0f; + ptr->unk_00.z = (((65.0f - temp_f0) * this->unk_204.z) + (temp_f0 * this->unk_228.z)) / 65.0f; + + temp_f0 -= 32.5f; + temp_f0 = SQ(temp_f0); + + ptr->unk_00.y += -0.11360947f * temp_f0 + 120.0f; + } else if ((ptr->unk_0E >= 102) && (ptr->unk_0E < 191)) { + f32 temp_f0 = ptr->unk_0E - 102; + + ptr->unk_00.x = (((89.0f - temp_f0) * this->unk_21C.x) + (temp_f0 * this->unk_210.x)) / 89.0f; + ptr->unk_00.y = (((89.0f - temp_f0) * this->unk_21C.y) + (temp_f0 * this->unk_210.y)) / 89.0f; + ptr->unk_00.z = (((89.0f - temp_f0) * this->unk_21C.z) + (temp_f0 * this->unk_210.z)) / 89.0f; + + temp_f0 -= 44.5f; + temp_f0 = SQ(temp_f0); + + ptr->unk_00.y += -0.08079788f * temp_f0 + 160.0f; + } +} + +void func_80BC32D8(EnJa* this, GlobalContext* globalCtx) { + EnJaStruct* phi_s0 = &this->unk_234[0]; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_234); i++, phi_s0++) { + func_80BC3154(this, phi_s0); + if (phi_s0->unk_0E != 191) { + phi_s0->unk_0E++; + } else { + phi_s0->unk_0E = 0; + } + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (this->unk_366 > 0) { + this->unk_366--; + } else { + this->unk_366 = 3; + } + } else if (Animation_OnFrame(&this->skelAnime, 34.0f)) { + if (this->unk_364 > 0) { + this->unk_364--; + } else { + this->unk_364 = 3; + } + } +} + +void func_80BC33C0(EnJaStruct* ptr, GlobalContext* globalCtx) { + s32 pad; + + if (((ptr->unk_0E < 0) || (ptr->unk_0E >= 19)) && ((ptr->unk_0E < 83) || (ptr->unk_0E >= 103))) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + + switch (ptr->unk_0C) { + case 0: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 255, 255); + break; + + case 1: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 0, 0, 255); + break; + + case 2: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 255, 255); + break; + + case 3: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 0, 255); + break; + + default: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + break; + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BCC8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_80BC3594(EnJa* this, GlobalContext* globalCtx) { + EnJaStruct* phi_s0 = this->unk_234; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_234); i++, phi_s0++) { + func_80BC33C0(phi_s0, globalCtx); + } +} 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 1df6d8962..561f76f55 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.h +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.h @@ -7,11 +7,57 @@ struct EnJa; typedef void (*EnJaActionFunc)(struct EnJa*, GlobalContext*); +#define ENJA_GET_3(thisx) (((thisx)->params & 3) & 0xFF) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ s16 unk_0E; +} EnJaStruct; // size = 0x10 + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x04 */ s32 unk_04; + /* 0x08 */ Player* player; +} EnJaStruct2; // size = 0x10 + typedef struct EnJa { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnJaActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x1EC]; + /* 0x018C */ ColliderCylinder collider; + /* 0x01D8 */ EnJaStruct2 unk_1D8; + /* 0x01E4 */ Vec3s unk_1E4; + /* 0x01EC */ Vec3f unk_1EC; + /* 0x01F8 */ Vec3f unk_1F8; + /* 0x0204 */ Vec3f unk_204; + /* 0x0210 */ Vec3f unk_210; + /* 0x021C */ Vec3f unk_21C; + /* 0x0228 */ Vec3f unk_228; + /* 0x0234 */ EnJaStruct unk_234[4]; + /* 0x0274 */ Vec3s unk_274; + /* 0x027A */ Vec3s unk_27A; + /* 0x0280 */ Vec3s jointTable[16]; + /* 0x02E0 */ Vec3s morphTable[16]; + /* 0x0340 */ u16 unk_340; + /* 0x0344 */ f32 unk_344; + /* 0x0348 */ f32 unk_348; + /* 0x034C */ f32 unk_34C; + /* 0x0350 */ UNK_TYPE1 unk350[0x4]; + /* 0x0354 */ s16 unk_354; + /* 0x0356 */ s16 unk_356; + /* 0x0358 */ s16 unk_358; + /* 0x035A */ s16 unk_35A; + /* 0x035C */ s16 unk_35C; + /* 0x035E */ s16 unk_35E; + /* 0x0360 */ s16 unk_360; + /* 0x0362 */ s16 unk_362; + /* 0x0364 */ s16 unk_364; + /* 0x0366 */ s16 unk_366; + /* 0x0368 */ void* unk_368; + /* 0x036C */ s32 unk_36C; + /* 0x0370 */ UNK_TYPE1 unk370[4]; + /* 0x0374 */ s32 unk_374; } EnJa; // size = 0x378 extern const ActorInit En_Ja_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e7b722168..e203f9bf6 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -15503,9 +15503,9 @@ 0x80BC2388:("EnJa_Init",), 0x80BC2498:("EnJa_Destroy",), 0x80BC24C4:("EnJa_Update",), - 0x80BC25E0:("func_80BC25E0",), - 0x80BC2620:("func_80BC2620",), - 0x80BC2B30:("func_80BC2B30",), + 0x80BC25E0:("EnJa_OverrideLimbDraw",), + 0x80BC2620:("EnJa_PostLimbDraw",), + 0x80BC2B30:("EnJa_TransformDraw",), 0x80BC2CE4:("EnJa_Draw",), 0x80BC2EA4:("func_80BC2EA4",), 0x80BC3154:("func_80BC3154",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 3aa77e775..94d7d8d34 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1535,12 +1535,6 @@ D_06012FC8 = 0x06012FC8; D_06013928 = 0x06013928; D_06016588 = 0x06016588; -// ovl_En_Ja - -D_0600BA30 = 0x0600BA30; -D_0600BCC8 = 0x0600BCC8; -D_0600C240 = 0x0600C240; - // ovl_En_Jgame_Tsn D_06008AB8 = 0x06008AB8; From 2d6a74c0aacbf652341fc66873240d93d497d73a Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 19 Feb 2022 19:11:13 +0000 Subject: [PATCH 022/257] Dm_Char01 (#589) * Dm_Char01 * Merge * Extract verts * PR --- assets/xml/objects/object_mtoride.xml | 4 +- assets/xml/overlays/ovl_Dm_Char01.xml | 7 + spec | 4 +- .../actors/ovl_Dm_Char01/z_dm_char01.c | 520 +++++++++++++++++- .../actors/ovl_Dm_Char01/z_dm_char01.h | 20 +- undefined_syms.txt | 23 - 6 files changed, 524 insertions(+), 54 deletions(-) create mode 100644 assets/xml/overlays/ovl_Dm_Char01.xml diff --git a/assets/xml/objects/object_mtoride.xml b/assets/xml/objects/object_mtoride.xml index ab0792839..a79547730 100644 --- a/assets/xml/objects/object_mtoride.xml +++ b/assets/xml/objects/object_mtoride.xml @@ -31,7 +31,7 @@ - + @@ -40,7 +40,7 @@ - + diff --git a/assets/xml/overlays/ovl_Dm_Char01.xml b/assets/xml/overlays/ovl_Dm_Char01.xml new file mode 100644 index 000000000..3f855c376 --- /dev/null +++ b/assets/xml/overlays/ovl_Dm_Char01.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spec b/spec index 54ac468bd..f03b20aa6 100644 --- a/spec +++ b/spec @@ -3267,9 +3267,7 @@ beginseg name "ovl_Dm_Char01" compress include "build/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.o" - include "build/data/ovl_Dm_Char01/ovl_Dm_Char01.data.o" - include "build/data/ovl_Dm_Char01/ovl_Dm_Char01.bss.o" - include "build/data/ovl_Dm_Char01/ovl_Dm_Char01.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Char01/ovl_Dm_Char01_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c index cf2d8b03b..1bc42f32b 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -5,8 +5,9 @@ */ #include "z_dm_char01.h" +#include "objects/object_mtoride/object_mtoride.h" -#define FLAGS 0x02000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((DmChar01*)thisx) @@ -15,7 +16,24 @@ void DmChar01_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmChar01_Update(Actor* thisx, GlobalContext* globalCtx); void DmChar01_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80AA8698(DmChar01* this, GlobalContext* globalCtx); +void func_80AA884C(DmChar01* this, GlobalContext* globalCtx); +void func_80AA88A8(DmChar01* this, GlobalContext* globalCtx); +void func_80AA892C(DmChar01* this, GlobalContext* globalCtx); +void func_80AA8C28(DmChar01* this, GlobalContext* globalCtx); +void func_80AA8F1C(DmChar01* this, GlobalContext* globalCtx); +void func_80AA8F2C(DmChar01* this, GlobalContext* globalCtx); +void func_80AA9020(DmChar01* this, GlobalContext* globalCtx); +void func_80AA90AC(DmChar01* this, GlobalContext* globalCtx); +void func_80AA90F4(DmChar01* this, GlobalContext* globalCtx); + +s16 D_80AAAE20; +s16 D_80AAAE22; +s16 D_80AAAE24; +s16 D_80AAAE26; + +#include "overlays/ovl_Dm_Char01/ovl_Dm_Char01.c" + const ActorInit Dm_Char01_InitVars = { ACTOR_DM_CHAR01, ACTORCAT_ITEMACTION, @@ -28,44 +46,500 @@ const ActorInit Dm_Char01_InitVars = { (ActorFunc)DmChar01_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AAAAB0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 300, ICHAIN_STOP), }; -#endif +s16 D_80AAAAB4 = false; -extern InitChainEntry D_80AAAAB0[]; +void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { + DmChar01* this = THIS; + s32 i; -extern UNK_TYPE D_06009E4C; -extern UNK_TYPE D_0600AA50; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_SetScale(&this->dyna.actor, 1.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/DmChar01_Init.s") + this->unk_346 = 0; + this->unk_34D = false; + D_80AAAE24 = 0; + D_80AAAE26 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/DmChar01_Destroy.s") + switch (DMCHAR01_GET(&this->dyna.actor)) { + case DMCHAR01_0: + if (gSaveContext.weekEventReg[20] & 2) { + this->unk_34C = 2; + this->actionFunc = func_80AA8F1C; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA8698.s") + if (gSaveContext.sceneSetupIndex == 0) { + globalCtx->envCtx.unk_1F = 5; + globalCtx->envCtx.unk_20 = 5; + } + this->unk_348 = 255.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA884C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_1AC); i++) { + this->unk_1AC[i] = ovl_dm_char01_Vtx_1BE0[i].v.ob[1] * 409.6f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA88A8.s") + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_mtoride_Colheader_009E4C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA892C.s") + this->unk_34D = true; + if (gSaveContext.sceneSetupIndex == 1) { + this->unk_34C = 1; + this->actionFunc = func_80AA8C28; + } else { + this->unk_34C = 0; + this->actionFunc = func_80AA892C; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA8C28.s") + case DMCHAR01_1: + if ((gSaveContext.weekEventReg[20] & 2) || (gSaveContext.sceneSetupIndex == 1)) { + this->unk_34C = 1; + this->actionFunc = func_80AA8F1C; + } else { + this->actionFunc = func_80AA8698; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA8F0C.s") + case DMCHAR01_2: + this->unk_34C = 0; + if (!(gSaveContext.weekEventReg[20] & 1)) { + this->unk_34C = 1; + this->dyna.actor.world.pos.y -= 400.0f; + } + this->dyna.actor.world.rot.y += 0x8000; + this->dyna.actor.shape.rot.y += 0x8000; + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_mtoride_Colheader_010C3C); + this->unk_34D = true; + this->unk_348 = 200.0f; + this->actionFunc = func_80AA8F2C; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA8F1C.s") + case DMCHAR01_3: + this->dyna.actor.world.rot.y += 0x8000; + this->dyna.actor.shape.rot.y += 0x8000; + if (!(gSaveContext.weekEventReg[20] & 1)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA8F2C.s") + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_ETCETERA, 5.0f, 202.0f, 294.0f, 0, 0, 0, 0x80); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_mtoride_Colheader_00FE5C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA9020.s") + this->unk_34D = true; + if (!(gSaveContext.weekEventReg[20] & 2)) { + this->actionFunc = func_80AA9020; + this->dyna.actor.world.pos.y -= 120.0f; + } else { + this->actionFunc = func_80AA8F1C; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA90AC.s") + default: + this->actionFunc = func_80AA88A8; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA90F4.s") +void DmChar01_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DmChar01* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/DmChar01_Update.s") + if (this->unk_34D) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/DmChar01_Draw.s") +void func_80AA8698(DmChar01* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Player* player2 = GET_PLAYER(globalCtx); + + if (gSaveContext.weekEventReg[20] & 1) { + return; + } + + if ((player->stateFlags2 & 0x8000000) && (player2->actor.world.pos.x > -40.0f) && + (player2->actor.world.pos.x < 40.0f) && (player2->actor.world.pos.z > 1000.0f) && + (player2->actor.world.pos.z < 1078.0f)) { + if (!D_80AAAAB4) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + D_80AAAAB4 = true; + } + } else { + D_80AAAAB4 = false; + } + + if ((player->transformation == PLAYER_FORM_DEKU) && (globalCtx->msgCtx.ocarinaMode == 3) && + (globalCtx->msgCtx.unk1202E == 0)) { + + if ((player2->actor.world.pos.x > -40.0f) && (player2->actor.world.pos.x < 40.0f) && + (player2->actor.world.pos.z > 1000.0f) && (player2->actor.world.pos.z < 1078.0f)) { + gSaveContext.weekEventReg[20] |= 1; + this->actionFunc = func_80AA884C; + } + } +} + +void func_80AA884C(DmChar01* this, GlobalContext* globalCtx) { + s16 sp1E = this->dyna.actor.cutscene; + + if (ActorCutscene_GetCanPlayNext(sp1E)) { + ActorCutscene_Start(sp1E, &this->dyna.actor); + this->actionFunc = func_80AA88A8; + } else { + ActorCutscene_SetIntentToPlay(sp1E); + } +} + +void func_80AA88A8(DmChar01* this, GlobalContext* globalCtx) { + if (func_800EE29C(globalCtx, 0x87)) { + if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x87)]->startFrame) { + D_80AAAE24 = 1; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FORT_RISING); + } + } else { + D_80AAAE24 = 0; + } +} + +void func_80AA892C(DmChar01* this, GlobalContext* globalCtx) { + f32 temp_f18; + s32 temp_v0_4; + s32 i; + + switch (this->unk_346) { + case 0: + D_80AAAE22 = -2200; + D_80AAAE20 = 380; + this->unk_346++; + break; + + case 1: + if (D_80AAAE24 != 0) { + this->unk_34C = 1; + if (D_80AAAE22 > -2000) { + D_80AAAE26 = 1; + } + + D_80AAAE22 += 40; + if (D_80AAAE22 > 3400) { + if (D_80AAAE20 > 100) { + D_80AAAE20 -= 230; + } + this->unk_346++; + } + } + break; + + case 2: + D_80AAAE22 -= 40; + if (D_80AAAE22 <= -2200) { + if (D_80AAAE20 > 100) { + D_80AAAE20 -= 70; + } + this->unk_346--; + } + break; + } + + if (D_80AAAE24 == 0) { + this->unk_34C = 0; + } + + for (i = 0; i < ARRAY_COUNT(ovl_dm_char01_Vtx_1BE0); i++) { + s32 temp_s2 = sqrtf(SQ((f32)ovl_dm_char01_Vtx_1BE0[i].v.ob[2]) + SQ((f32)ovl_dm_char01_Vtx_1BE0[i].v.ob[0])); + f32 cos = Math_CosS((temp_s2 / 1892.0f) * 0x4000); + f32 temp_f20 = (1.0f - (ABS_ALT(temp_s2 - D_80AAAE22) / 1892.0f)) * D_80AAAE20 * cos; + + if (temp_f20 < 0.0f) { + temp_f20 = 0.0f; + } + + temp_f18 = Math_SinS(this->unk_1AC[i]) * 15.0f; + temp_f20 += temp_f18; + + this->unk_1AC[i] += 1600; + ovl_dm_char01_Vtx_1BE0[i].v.ob[1] = temp_f20; + } +} + +void func_80AA8C28(DmChar01* this, GlobalContext* globalCtx) { + f32 temp_f18; + s32 temp_v0_4; + s32 i; + + switch (this->unk_346) { + case 0: + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WATER_PURIFICATION); + D_80AAAE22 = -2200; + D_80AAAE20 = 100; + this->unk_346++; + break; + + case 1: + D_80AAAE22 += 40; + if (D_80AAAE22 > 3400) { + this->unk_346++; + } + break; + + case 2: + D_80AAAE22 -= 40; + if (D_80AAAE22 <= -2200) { + this->unk_346--; + } + break; + } + + for (i = 0; i < ARRAY_COUNT(ovl_dm_char01_Vtx_1BE0); i++) { + s32 temp_s2 = sqrtf(SQ((f32)ovl_dm_char01_Vtx_1BE0[i].v.ob[2]) + SQ((f32)ovl_dm_char01_Vtx_1BE0[i].v.ob[0])); + f32 cos = Math_CosS((temp_s2 / 1892.0f) * 0x4000); + f32 temp_f20 = (1.0f - (ABS_ALT(temp_s2 - D_80AAAE22) / 1892.0f)) * D_80AAAE20 * cos; + + if (temp_f20 < 0.0f) { + temp_f20 = 0.0f; + } + + temp_f18 = Math_SinS(this->unk_1AC[i]) * 15.0f; + temp_f20 += temp_f18; + + this->unk_1AC[i] += 1600; + ovl_dm_char01_Vtx_1BE0[i].v.ob[1] = temp_f20; + } + + Math_SmoothStepToF(&this->unk_348, 0.0f, 0.02f, 0.6f, 0.4f); + + if (this->unk_348 < 0.01f) { + this->unk_34C = 2; + this->actionFunc = func_80AA8F1C; + } +} + +void func_80AA8F0C(DmChar01* this, GlobalContext* globalCtx) { +} + +void func_80AA8F1C(DmChar01* this, GlobalContext* globalCtx) { +} + +void func_80AA8F2C(DmChar01* this, GlobalContext* globalCtx) { + if (D_80AAAE26 != 0) { + Math_SmoothStepToF(&this->dyna.actor.world.pos.y, 0.0f, 0.05f, 6.0f, 0.001f); + Math_SmoothStepToF(&this->unk_348, 0.0f, 0.01f, 0.5f, 0.4f); + if ((s32)this->dyna.actor.world.pos.y >= 0) { + D_80AAAE26 = 2; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_ETCETERA, 5.0f, 202.0f, 294.0f, 0, 0, 0, 0x80); + this->actionFunc = func_80AA90F4; + } + } + func_80AA8F0C(this, globalCtx); +} + +void func_80AA9020(DmChar01* this, GlobalContext* globalCtx) { + if (func_800EE29C(globalCtx, 0x87)) { + CsCmdActorAction* temp_v1 = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x87)]; + + if ((temp_v1->startFrame == globalCtx->csCtx.frames) && (temp_v1->unk0 == 2)) { + gSaveContext.weekEventReg[20] |= 2; + this->actionFunc = func_80AA90AC; + } + } +} + +void func_80AA90AC(DmChar01* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->dyna.actor.world.pos.y, 0.0f, 0.05f, 2.0f, 0.001f); +} + +void func_80AA90F4(DmChar01* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->unk_348, 0.0f, 0.02f, 0.8f, 0.4f); +} + +void DmChar01_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + DmChar01* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->unk_34D) { + if (DMCHAR01_GET(&this->dyna.actor) == DMCHAR01_0) { + Player* player = GET_PLAYER(globalCtx); + + if (player->actor.world.pos.y > 5.0f) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } else { + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } + } + + if (DMCHAR01_GET(&this->dyna.actor) == DMCHAR01_2) { + if (this->dyna.actor.xzDistToPlayer > 600.0f) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } else { + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } + } + } +} + +void DmChar01_Draw(Actor* thisx, GlobalContext* globalCtx) { + static f32 D_80AAAAB8 = 0.0f; + static f32 D_80AAAABC = 0.0f; + static s16 D_80AAAAC0 = 0; + static s16 D_80AAAAC4 = 0; + static s16 D_80AAAAC8 = 0; + static s16 D_80AAAACC = 0; + DmChar01* this = THIS; + f32 temp_f12; + f32 spBC; + s32 i; + u8 spB7 = false; + + switch (DMCHAR01_GET(thisx)) { + case DMCHAR01_0: + switch (this->unk_34C) { + case 0: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00AA50)); + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00A8F8); + break; + + case 1: + if (gSaveContext.sceneSetupIndex == 1) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_0110B8)); + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_010FD8); + Gfx_DrawDListXlu(globalCtx, object_mtoride_DL_010EF0); + Matrix_InsertTranslation(0.0f, 10.0f, 0.0f, MTXMODE_APPLY); + } + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_009D70)); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((u8)this->unk_348 == 255) { + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x96, 255, 255, 255, 255); + gSPSegment(POLY_OPA_DISP++, 0x0B, Lib_SegmentedToVirtual(ovl_dm_char01_Vtx_1BE0)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_mtoride_DL_009928); + } else { + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, (u8)this->unk_348); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x96, 255, 255, 255, (u8)this->unk_348); + gSPSegment(POLY_XLU_DISP++, 0x0B, Lib_SegmentedToVirtual(ovl_dm_char01_Vtx_1BE0)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_mtoride_DL_009928); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + break; + + case 2: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_0110B8)); + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_010FD8); + Gfx_DrawDListXlu(globalCtx, object_mtoride_DL_010EF0); + break; + } + break; + + case DMCHAR01_1: + switch (this->unk_34C) { + case 0: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00A5C0)); + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00A398); + break; + + case 1: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00B1A0)); + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00AF98); + break; + } + break; + + case DMCHAR01_2: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00FE90)); + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00DF18); + + if ((this->unk_34C != 0) && ((u8)this->unk_348 != 0)) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00F768)); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, (u8)this->unk_348); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, (u8)this->unk_348); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_mtoride_DL_00F3C0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (D_80AAAE24 != 0) { + if ((D_80AAAE22 > -1800) && (D_80AAAE22 < 3000)) { + temp_f12 = D_80AAAE22 - 640.0f; + if ((D_80AAAE20 == 380) && (D_80AAAE22 > 640)) { + D_80AAAAC0 = 2; + D_80AAAAC4 = 0; + D_80AAAAC8 = 900; + D_80AAAACC = 700; + spB7 = true; + if (D_80AAAE22 < 1350) { + f32 temp_f0 = temp_f12 / 2000.0f; + + D_80AAAAB8 = 420.0f - (420.0f * temp_f0); + D_80AAAABC = (200.0f * temp_f0) + 200.0f; + } else { + f32 temp_f0 = temp_f12 / 2000.0f; + + D_80AAAAB8 = 420.0f - (420.0f * temp_f0); + D_80AAAABC = 400.0f; + } + } + } + + if (spB7) { + for (i = 0; i < D_80AAAAC0 * 2; i++) { + Vec3f sp44; + f32 phi_f2 = D_80AAAABC; + s16 temp; + + spBC = Rand_ZeroOne() * D_80AAAAC8; + if ((globalCtx->state.frames % 2) != 0) { + sp44.x = (Rand_ZeroOne() - 0.5f) * (2.0f * phi_f2); + sp44.y = D_80AAAAB8; + sp44.z = (Rand_ZeroOne() * D_80AAAAC4) + phi_f2; + temp = (s16)spBC + D_80AAAACC; + EffectSsGSplash_Spawn(globalCtx, &sp44, NULL, NULL, 0, temp); + } else { + sp44.x = -phi_f2 - (Rand_ZeroOne() * D_80AAAAC4); + sp44.y = D_80AAAAB8; + sp44.z = (Rand_ZeroOne() - 0.5f) * (2.0f * phi_f2); + temp = (s16)spBC + D_80AAAACC; + EffectSsGSplash_Spawn(globalCtx, &sp44, NULL, NULL, 0, temp); + } + } + } + } + + Gfx_DrawDListXlu(globalCtx, object_mtoride_DL_00DE50); + break; + + case DMCHAR01_3: + if (thisx->world.pos.y > -120.0f) { + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00FAE8); + } + break; + } +} diff --git a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.h b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.h index a0d4fb336..b2c235f56 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.h +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.h @@ -7,11 +7,25 @@ struct DmChar01; typedef void (*DmChar01ActionFunc)(struct DmChar01*, GlobalContext*); +#define DMCHAR01_GET(thisx) ((thisx)->params) + +enum { + /* 0 */ DMCHAR01_0, + /* 1 */ DMCHAR01_1, + /* 2 */ DMCHAR01_2, + /* 3 */ DMCHAR01_3, +}; + typedef struct DmChar01 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x5C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ UNK_TYPE1 unk15C[0x44]; /* 0x01A0 */ DmChar01ActionFunc actionFunc; - /* 0x01A4 */ char unk_1A4[0x1AC]; + /* 0x01A4 */ UNK_TYPE1 unk1A4[0x8]; + /* 0x01AC */ s16 unk_1AC[205]; + /* 0x0346 */ s16 unk_346; + /* 0x0348 */ f32 unk_348; + /* 0x034C */ u8 unk_34C; + /* 0x034D */ u8 unk_34D; } DmChar01; // size = 0x350 extern const ActorInit Dm_Char01_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 94d7d8d34..cbbcc21ce 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -984,29 +984,6 @@ D_060005FC = 0x060005FC; D_06001804 = 0x06001804; D_0600A6D0 = 0x0600A6D0; -// ovl_Dm_Char01 - -D_06009928 = 0x06009928; -D_06009D70 = 0x06009D70; -D_06009E4C = 0x06009E4C; -D_0600A398 = 0x0600A398; -D_0600A5C0 = 0x0600A5C0; -D_0600A8F8 = 0x0600A8F8; -D_0600AA50 = 0x0600AA50; -D_0600AF98 = 0x0600AF98; -D_0600B1A0 = 0x0600B1A0; -D_0600DE50 = 0x0600DE50; -D_0600DF18 = 0x0600DF18; -D_0600F3C0 = 0x0600F3C0; -D_0600F768 = 0x0600F768; -D_0600FAE8 = 0x0600FAE8; -D_0600FE5C = 0x0600FE5C; -D_0600FE90 = 0x0600FE90; -D_06010C3C = 0x06010C3C; -D_06010EF0 = 0x06010EF0; -D_06010FD8 = 0x06010FD8; -D_060110B8 = 0x060110B8; - // ovl_Dm_Char02 D_0600AD68 = 0x0600AD68; From 9ddf530f9b0b5809194a43ab948d39fc2e2182bb Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 19 Feb 2022 19:17:20 +0000 Subject: [PATCH 023/257] En_Karebaba (#590) * En_Karebaba * merge * Merge * PR --- spec | 3 +- .../actors/ovl_En_Karebaba/z_en_karebaba.c | 678 ++++++++++++++++-- .../actors/ovl_En_Karebaba/z_en_karebaba.h | 20 +- undefined_syms.txt | 8 - 4 files changed, 643 insertions(+), 66 deletions(-) diff --git a/spec b/spec index f03b20aa6..a3f051d32 100644 --- a/spec +++ b/spec @@ -1279,8 +1279,7 @@ beginseg name "ovl_En_Karebaba" compress include "build/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.o" - include "build/data/ovl_En_Karebaba/ovl_En_Karebaba.data.o" - include "build/data/ovl_En_Karebaba/ovl_En_Karebaba.reloc.o" + include "build/src/overlays/actors/ovl_En_Karebaba/ovl_En_Karebaba_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c index dd2233e4c..f6b1f7b40 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c @@ -5,8 +5,10 @@ */ #include "z_en_karebaba.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_dekubaba/object_dekubaba.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnKarebaba*)thisx) @@ -15,19 +17,28 @@ void EnKarebaba_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKarebaba_Update(Actor* thisx, GlobalContext* globalCtx); void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_808F155C(EnKarebaba* this); void func_808F15B0(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F1648(EnKarebaba* this); void func_808F169C(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F16FC(EnKarebaba* this); void func_808F1778(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F1878(EnKarebaba* this); void func_808F190C(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F1A3C(EnKarebaba* this); void func_808F1A58(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F1BF8(EnKarebaba* this); void func_808F1C84(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F1FAC(EnKarebaba* this); void func_808F200C(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F20FC(EnKarebaba* this, GlobalContext* globalCtx); void func_808F21A4(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F220C(EnKarebaba* this); void func_808F228C(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F238C(EnKarebaba* this); void func_808F241C(EnKarebaba* this, GlobalContext* globalCtx); void func_808F254C(EnKarebaba* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Karebaba_InitVars = { ACTOR_EN_KAREBABA, ACTORCAT_ENEMY, @@ -40,25 +51,49 @@ const ActorInit En_Karebaba_InitVars = { (ActorFunc)EnKarebaba_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808F2DA0 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 7, 25, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808F2DCC = { - { COLTYPE_HARD, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_WOOD, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HARD, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_WOOD, + BUMP_NONE, + OCELEM_ON, + }, { 4, 25, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808F2DF8 = { 1, 15, 80, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 80, MASS_HEAVY }; -// static DamageTable sDamageTable = { -static DamageTable D_808F2E00 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(3, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -93,79 +128,614 @@ static DamageTable D_808F2E00 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808F2E20[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2500, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 1, ICHAIN_STOP), }; -#endif +Color_RGBA8 D_808F2E28 = { 0, 0, 0, 0 }; -extern ColliderCylinderInit D_808F2DA0; -extern ColliderCylinderInit D_808F2DCC; -extern CollisionCheckInfoInit D_808F2DF8; -extern DamageTable D_808F2E00; -extern InitChainEntry D_808F2E20[]; +Gfx* D_808F2E2C[] = { object_dekubaba_DL_001330, object_dekubaba_DL_001628, object_dekubaba_DL_001828 }; -extern UNK_TYPE D_060002B8; -extern UNK_TYPE D_06003070; +void EnKarebaba_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKarebaba* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/EnKarebaba_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 22.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_dekubaba_Skel_002A40, &object_dekubaba_Anim_0002B8, + this->jointTable, this->morphTable, 8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/EnKarebaba_Destroy.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit1); + Collider_UpdateCylinder(&this->actor, &this->collider2); + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit2); + Collider_UpdateCylinder(&this->actor, &this->collider1); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1374.s") + this->unk_22C = NULL; + if (this->actor.params == ENKAREBABA_2) { + this->actor.hintId = 2; + } else { + this->actor.hintId = 9; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F13FC.s") + if (this->actor.params == ENKAREBABA_0) { + func_808F155C(this); + } else { + func_808F1648(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F152C.s") +void EnKarebaba_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKarebaba* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F155C.s") + Collider_DestroyCylinder(globalCtx, &this->collider2); + Collider_DestroyCylinder(globalCtx, &this->collider1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F15B0.s") +void func_808F1374(EnKarebaba* this, GlobalContext* globalCtx) { + s32 phi_a3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1648.s") + if (this->unk_1EC == 10) { + this->unk_1EC = 0; + this->unk_1F0 = 0.0f; + if (this->actor.params == ENKAREBABA_2) { + phi_a3 = 1; + } else { + phi_a3 = 4; + } + Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_1FC, phi_a3, 4, 0.3f, 0.2f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F169C.s") +void func_808F13FC(EnKarebaba* this, GlobalContext* globalCtx) { + if (this->actor.colChkInfo.damageEffect == 2) { + this->unk_1EC = 0; + this->unk_1F4 = 0.75f; + this->unk_1F0 = 3.0f; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->unk_1F4 = 0.75f; + this->unk_1EC = 20; + this->unk_1F0 = 3.0f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider2.info.bumper.hitPos.x, + this->collider2.info.bumper.hitPos.y, this->collider2.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_SMALL_LIGHT_RAYS); + } else if (this->actor.colChkInfo.damageEffect == 3) { + this->unk_1EC = 10; + this->unk_1F4 = 0.75f; + this->unk_1F0 = 1.0f; + this->unk_1F8 = 1.125f; + } else if (this->actor.colChkInfo.damageEffect == 5) { + this->unk_1EC = 31; + this->unk_1F4 = 0.75f; + this->unk_1F0 = 3.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F16FC.s") +void func_808F152C(EnKarebaba* this) { + this->collider2.dim.radius = 7; + this->collider2.dim.height = 25; + this->collider2.base.colType = COLTYPE_HARD; + this->collider2.base.acFlags |= AC_HARD; + this->collider1.dim.height = 25; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1778.s") +void func_808F155C(EnKarebaba* this) { + Actor_SetScale(&this->actor, 0.0f); + this->actor.shape.rot.x = -0x4000; + this->unk_1EE = 0; + this->actor.world.pos.y = this->actor.home.pos.y + 14.0f; + this->actionFunc = func_808F15B0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1878.s") +void func_808F15B0(EnKarebaba* this, GlobalContext* globalCtx) { + f32 sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F190C.s") + this->unk_1EE++; + sp1C = this->unk_1EE * 0.05f; + Actor_SetScale(&this->actor, 0.005f * sp1C); + this->actor.world.pos.y = this->actor.home.pos.y + (14.0f * sp1C); + if (this->unk_1EE == 20) { + func_808F1648(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1A3C.s") +void func_808F1648(EnKarebaba* this) { + Actor_SetScale(&this->actor, 0.005f); + this->actor.shape.rot.x = -0x4000; + this->actor.world.pos.y = this->actor.home.pos.y + 14.0f; + this->actionFunc = func_808F169C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1A58.s") +void func_808F169C(EnKarebaba* this, GlobalContext* globalCtx) { + if ((this->actor.xzDistToPlayer < 200.0f) && (fabsf(this->actor.playerHeightRel) < 30.0f)) { + func_808F16FC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1BF8.s") +void func_808F16FC(EnKarebaba* this) { + Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, 4.0f, 0.0f, + Animation_GetLastFrame(&object_dekubaba_Anim_0002B8), 0, -3.0f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKU_WAKEUP); + this->actionFunc = func_808F1778; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1C84.s") +void func_808F1778(EnKarebaba* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1FAC.s") + if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.0005f) && (this->actor.params == ENKAREBABA_2)) { + func_808F1878(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F200C.s") + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = this->actor.scale.x; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F20FC.s") + if ((this->actor.params == ENKAREBABA_1) && + Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 60.0f, 5.0f)) { + func_808F1878(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F21A4.s") + this->actor.shape.rot.y += 0x1999; + EffectSsHahen_SpawnBurst(globalCtx, &this->actor.home.pos, 3.0f, 0, 12, 5, 1, -1, 10, NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F220C.s") +void func_808F1878(EnKarebaba* this) { + if (this->actionFunc != func_808F1A58) { + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F228C.s") + this->collider2.base.colType = COLTYPE_HIT6; + this->collider2.base.acFlags &= ~AC_HARD; + this->collider2.dim.radius = 15; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F238C.s") + if (this->actor.params == ENKAREBABA_1) { + this->collider2.dim.height = 80; + this->collider1.dim.height = 80; + } else { + this->collider2.dim.height = 35; + this->collider1.dim.height = 35; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F241C.s") + this->unk_1EE = 40; + this->actionFunc = func_808F190C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F24F8.s") +void func_808F190C(EnKarebaba* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F254C.s") + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/EnKarebaba_Update.s") + if (this->unk_1EE != 0) { + this->unk_1EE--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F280C.s") + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MIZUBABA1_MOUTH); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/EnKarebaba_Draw.s") + if (this->collider2.base.acFlags & AC_HIT) { + func_808F13FC(this, globalCtx); + if (this->actor.params == ENKAREBABA_1) { + func_808F1BF8(this); + } else { + func_808F1FAC(this); + } + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } else if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) > 240.0f) { + func_808F220C(this); + } else if ((this->unk_1EE == 0) && (this->actor.params == ENKAREBABA_1)) { + func_808F1A3C(this); + } +} + +void func_808F1A3C(EnKarebaba* this) { + this->unk_1EE = 40; + this->actionFunc = func_808F1A58; +} + +void func_808F1A58(EnKarebaba* this, GlobalContext* globalCtx) { + s32 phi_v0; + f32 sp28; + + if (this->unk_1EE != 0) { + this->unk_1EE--; + } + + SkelAnime_Update(&this->skelAnime); + + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MIZUBABA1_MOUTH); + } + + phi_v0 = 20 - this->unk_1EE; + phi_v0 = 20 - ABS_ALT(phi_v0); + if (phi_v0 > 10) { + phi_v0 = 10; + } + + this->collider1.dim.radius = sCylinderInit2.dim.radius + (phi_v0 * 2); + this->actor.shape.rot.x = 0xC000 - (phi_v0 << 8); + this->actor.shape.rot.y += phi_v0 * 0x2C0; + this->actor.world.pos.y = (Math_SinS(this->actor.shape.rot.x) * -60.0f) + this->actor.home.pos.y; + + sp28 = Math_CosS(this->actor.shape.rot.x) * 60.0f; + this->actor.world.pos.x = (Math_SinS(this->actor.shape.rot.y) * sp28) + this->actor.home.pos.x; + this->actor.world.pos.z = (Math_CosS(this->actor.shape.rot.y) * sp28) + this->actor.home.pos.z; + + if (this->collider2.base.acFlags & AC_HIT) { + func_808F13FC(this, globalCtx); + func_808F1BF8(this); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } else if (this->unk_1EE == 0) { + func_808F1878(this); + } +} + +void func_808F1BF8(EnKarebaba* this) { + if (this->unk_1EC != 10) { + this->unk_1EE = 0; + this->actor.gravity = -0.8f; + this->actor.velocity.y = 4.0f; + this->actor.world.rot.y = BINANG_ROT180(this->actor.shape.rot.y); + this->actor.speedXZ = 3.0f; + } else { + this->unk_1EE = 3; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKU_JR_DEAD); + this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); + this->actionFunc = func_808F1C84; +} + +void func_808F1C84(EnKarebaba* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp78; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + + if (this->unk_1EC == 10) { + this->unk_1EE--; + if (this->unk_1EE == 0) { + this->actor.gravity = -0.8f; + this->actor.speedXZ = 3.0f; + this->actor.velocity.y = 4.0f; + this->actor.world.rot.y = BINANG_ROT180(this->actor.shape.rot.y); + func_808F1374(this, globalCtx); + } + } else { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.1f); + + if (this->unk_1EE == 0) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4800, 0x71C); + EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 3.0f, 0, 12, 5, 1, -1, 10, NULL); + + if ((this->actor.scale.x > 0.005f) && ((this->actor.bgCheckFlags & 2) || (this->actor.bgCheckFlags & 8))) { + this->actor.scale.z = 0.0f; + this->actor.scale.y = 0.0f; + this->actor.scale.x = 0.0f; + this->actor.speedXZ = 0.0f; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 3.0f, 0, 12, 5, 15, -1, 10, NULL); + } + + if (this->actor.bgCheckFlags & 2) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + this->unk_1EE = 1; + } + } else if (this->unk_1EE == 1) { + Math_Vec3f_Copy(&sp78, &this->actor.world.pos); + + temp_f24 = Math_SinS(this->actor.shape.rot.x) * 20.0f; + temp_f20 = (-20.0f * Math_CosS(this->actor.shape.rot.x)) * Math_SinS(this->actor.shape.rot.y); + temp_f22 = (-20.0f * Math_CosS(this->actor.shape.rot.x)) * Math_CosS(this->actor.shape.rot.y); + + for (i = 0; i < 4; i++) { + func_800B1210(globalCtx, &sp78, &gZeroVec3f, &gZeroVec3f, 500, 50); + sp78.x += temp_f20; + sp78.y += temp_f24; + sp78.z += temp_f22; + } + + func_800B1210(globalCtx, &this->actor.home.pos, &gZeroVec3f, &gZeroVec3f, 500, 100); + func_808F20FC(this, globalCtx); + } + } +} + +void func_808F1FAC(EnKarebaba* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKU_JR_DEAD); + this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); + this->actor.flags &= ~ACTOR_FLAG_1; + if (this->unk_1EC == 10) { + this->unk_1EE = 3; + } + this->actionFunc = func_808F200C; +} + +void func_808F200C(EnKarebaba* this, GlobalContext* globalCtx) { + if (this->unk_1EC == 10) { + this->unk_1EE--; + if (this->unk_1EE == 0) { + func_808F1374(this, globalCtx); + } + } else { + if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.0005f)) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_NUTS_1); + func_808F238C(this); + } else { + EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 3.0f, 0, 12, 5, 1, -1, 10, NULL); + Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 1.0f); + } + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; + } +} + +void func_808F20FC(EnKarebaba* this, GlobalContext* globalCtx) { + Actor_SetScale(&this->actor, 0.03f); + this->actor.shape.rot.x -= 0x4000; + this->actor.shape.yOffset = 1000.0f; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.shape.shadowScale = 3.0f; + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 8); + this->unk_1EE = 200; + this->actor.flags &= ~ACTOR_FLAG_20; + this->unk_1F0 = 0.0f; + this->actionFunc = func_808F21A4; +} + +void func_808F21A4(EnKarebaba* this, GlobalContext* globalCtx) { + if (this->unk_1EE != 0) { + this->unk_1EE--; + } + + if (Actor_HasParent(&this->actor, globalCtx) || (this->unk_1EE == 0)) { + func_808F238C(this); + } else { + Actor_PickUpNearby(&this->actor, globalCtx, GI_STICKS_1); + } +} + +void func_808F220C(EnKarebaba* this) { + Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, -3.0f, + Animation_GetLastFrame(&object_dekubaba_Anim_0002B8), 0.0f, 2, -3.0f); + func_808F152C(this); + this->actionFunc = func_808F228C; +} + +void func_808F228C(EnKarebaba* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Math_StepToF(&this->actor.scale.x, 0.005f, 0.0005f) && (this->actor.params == ENKAREBABA_2)) { + func_808F1648(this); + } + + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = this->actor.scale.x; + + if ((this->actor.params == ENKAREBABA_1) && + Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 14.0f, 5.0f)) { + func_808F1648(this); + } + + this->actor.shape.rot.y += 0x1999; + EffectSsHahen_SpawnBurst(globalCtx, &this->actor.home.pos, 3.0f, 0, 12, 5, 1, -1, 10, NULL); +} + +void func_808F238C(EnKarebaba* this) { + Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, 0.0f, 0.0f, 0.0f, 2, 0.0f); + func_808F152C(this); + this->actor.shape.rot.x = -0x4000; + this->unk_1EE = 200; + this->actor.parent = NULL; + this->actor.shape.shadowScale = 0.0f; + this->unk_1F0 = 0.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actionFunc = func_808F254C; +} + +void func_808F241C(EnKarebaba* this, GlobalContext* globalCtx) { + f32 sp1C; + + this->unk_1EE++; + sp1C = this->unk_1EE * 0.05f; + Actor_SetScale(&this->actor, 0.005f * sp1C); + this->actor.world.pos.y = this->actor.home.pos.y + (14.0f * sp1C); + + if (this->unk_1EE == 20) { + this->actor.flags &= ~ACTOR_FLAG_10; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); + if (this->actor.params == ENKAREBABA_1) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 5); + } + func_808F1648(this); + } +} + +void func_808F24F8(EnKarebaba* this) { + this->actor.shape.yOffset = 0.0f; + this->actor.shape.shadowScale = 22.0f; + this->collider1.dim.radius = sCylinderInit2.dim.radius; + Actor_SetScale(&this->actor, 0.0f); + this->actionFunc = func_808F241C; +} + +void func_808F254C(EnKarebaba* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (this->unk_1EE != 0) { + this->unk_1EE--; + } + + if (this->unk_1EE == 0) { + func_808F24F8(this); + } +} + +void EnKarebaba_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnKarebaba* this = THIS; + f32 max; + + this->actionFunc(this, globalCtx); + + if (this->unk_1F0 > 0.0f) { + if (this->unk_1EC != 10) { + Math_StepToF(&this->unk_1F0, 0.0f, 0.05f); + this->unk_1F4 = (this->unk_1F0 + 1.0f) * 0.375f; + if (this->unk_1F4 > 0.75f) { + this->unk_1F4 = 0.75f; + } else { + this->unk_1F4 = this->unk_1F4; + } + } else if (!Math_StepToF(&this->unk_1F8, 0.75f, 0.01875f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + + if (this->actionFunc != func_808F254C) { + if (this->actionFunc == func_808F1C84) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 15.0f, 10.0f, 5); + } else { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + if (this->unk_22C == 0) { + this->unk_22C = this->actor.floorPoly; + } + } + + if ((this->actionFunc != func_808F1C84) && (this->actionFunc != func_808F200C) && + (this->actionFunc != func_808F21A4)) { + if ((this->actionFunc != func_808F241C) && (this->actionFunc != func_808F15B0)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + Actor_SetFocus(&this->actor, (this->actor.scale.x * 10.0f) / 0.01f); + + max = this->actor.home.pos.y + 40.0f; + this->actor.focus.pos.x = this->actor.home.pos.x; + this->actor.focus.pos.y = CLAMP_MAX(this->actor.focus.pos.y, max); + this->actor.focus.pos.z = this->actor.home.pos.z; + } + } +} + +void func_808F280C(EnKarebaba* this, GlobalContext* globalCtx) { + MtxF sp40; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C448(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); + + func_800C0094(this->unk_22C, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, &sp40); + Matrix_InsertMatrix(&sp40, MTXMODE_NEW); + Matrix_Scale(0.15f, 1.0f, 0.15f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKarebaba* this = THIS; + s32 i; + s32 sp94; + s16 phi_a3; + f32 sp8C = 0.01f; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Math_Vec3f_Copy(this->unk_1FC, &this->actor.world.pos); + + if (this->actionFunc == func_808F21A4) { + if ((this->unk_1EE > 40) || (this->unk_1EE & 1)) { + Matrix_InsertTranslation(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_003070); + } + } else if (this->actionFunc != func_808F254C) { + func_800AE2A0(globalCtx, &D_808F2E28, 1, 2); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + + if ((this->actionFunc == func_808F241C) || (this->actionFunc == func_808F200C) || + (this->actionFunc == func_808F15B0)) { + sp8C = this->unk_1EE * 0.0005f; + } + + Matrix_Scale(sp8C, sp8C, sp8C, MTXMODE_APPLY); + Matrix_InsertRotation(this->actor.shape.rot.x, this->actor.shape.rot.y, 0, MTXMODE_APPLY); + + if (this->actor.params == ENKAREBABA_2) { + sp94 = 1; + } else if (this->actionFunc == func_808F1C84) { + sp94 = 2; + } else { + sp94 = 3; + } + + for (i = 0; i < sp94; i++) { + Matrix_InsertTranslation(0.0f, 0.0f, -2000.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_808F2E2C[i]); + + Matrix_GetStateTranslation(&this->unk_1FC[1 + i]); + if ((i == 0) && (this->actionFunc == func_808F1C84)) { + Matrix_GetStateTranslation(&this->actor.focus.pos); + } + } + + func_800AE5A0(globalCtx); + } + + func_800AE2A0(globalCtx, &D_808F2E28, 1, 2); + Matrix_InsertTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, MTXMODE_NEW); + + if (this->actionFunc != func_808F15B0) { + sp8C = 0.01f; + } + + Matrix_Scale(sp8C, sp8C, sp8C, MTXMODE_APPLY); + Matrix_RotateY(this->actor.home.rot.y, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_0010F0); + + if (this->actionFunc == func_808F1C84) { + Matrix_InsertRotation(-0x4000, this->actor.shape.rot.y - this->actor.home.rot.y, 0, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_001828); + + Matrix_GetStateTranslation(&this->unk_1FC[3]); + } + + func_800AE5A0(globalCtx); + + if (this->actor.params == ENKAREBABA_2) { + phi_a3 = 1; + } else { + phi_a3 = 4; + } + + func_800BE680(globalCtx, &this->actor, this->unk_1FC, phi_a3, this->unk_1F4, this->unk_1F8, this->unk_1F0, + this->unk_1EC); + + if (this->unk_22C != 0) { + func_808F280C(this, globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h index 094876643..9fd021e5f 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h @@ -7,11 +7,27 @@ struct EnKarebaba; typedef void (*EnKarebabaActionFunc)(struct EnKarebaba*, GlobalContext*); +enum { + /* 0 */ ENKAREBABA_0, + /* 1 */ ENKAREBABA_1, + /* 2 */ ENKAREBABA_2, +}; + typedef struct EnKarebaba { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnKarebabaActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x13C]; + /* 0x018C */ Vec3s jointTable[8]; + /* 0x01BC */ Vec3s morphTable[8]; + /* 0x01EC */ u8 unk_1EC; + /* 0x01EE */ s16 unk_1EE; + /* 0x01F0 */ f32 unk_1F0; + /* 0x01F4 */ f32 unk_1F4; + /* 0x01F8 */ f32 unk_1F8; + /* 0x01FC */ Vec3f unk_1FC[4]; + /* 0x022C */ CollisionPoly* unk_22C; + /* 0x0230 */ ColliderCylinder collider1; + /* 0x027C */ ColliderCylinder collider2; } EnKarebaba; // size = 0x2C8 extern const ActorInit En_Karebaba_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index cbbcc21ce..5acf9e551 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1547,14 +1547,6 @@ D_0600D828 = 0x0600D828; D_06000C30 = 0x06000C30; D_06001630 = 0x06001630; -// ovl_En_Karebaba - -D_060002B8 = 0x060002B8; -D_060010F0 = 0x060010F0; -D_06001828 = 0x06001828; -D_06002A40 = 0x06002A40; -D_06003070 = 0x06003070; - // ovl_En_Kbt D_06004274 = 0x06004274; From 5d3ddfac00d490ba7413831ea775bfcd3f5caa0b Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 19 Feb 2022 19:34:09 +0000 Subject: [PATCH 024/257] En_Al (#595) * En_Al * Merge * Merge * PR * Names * PR --- spec | 3 +- src/overlays/actors/ovl_En_Al/z_en_al.c | 888 ++++++++++++++++++++++-- src/overlays/actors/ovl_En_Al/z_en_al.h | 35 +- tools/disasm/functions.txt | 6 +- undefined_syms.txt | 4 - 5 files changed, 879 insertions(+), 57 deletions(-) diff --git a/spec b/spec index a3f051d32..839ec5578 100644 --- a/spec +++ b/spec @@ -4852,8 +4852,7 @@ beginseg name "ovl_En_Al" compress include "build/src/overlays/actors/ovl_En_Al/z_en_al.o" - include "build/data/ovl_En_Al/ovl_En_Al.data.o" - include "build/data/ovl_En_Al/ovl_En_Al.reloc.o" + include "build/src/overlays/actors/ovl_En_Al/ovl_En_Al_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index 26961e4c7..a984af2fa 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -5,8 +5,9 @@ */ #include "z_en_al.h" +#include "objects/object_al/object_al.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnAl*)thisx) @@ -18,7 +19,60 @@ void EnAl_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BDF5E8(EnAl* this, GlobalContext* globalCtx); void func_80BDF6C4(EnAl* this, GlobalContext* globalCtx); -#if 0 +s32 D_80BDFC70[] = { + 0x0C00030D, 0x02120006, 0x0001050E, 0x12000600, 0x02020800, 0x0A002F02, 0x0A000A37, + 0x23020A37, 0x0B2D0D02, 0x0B2D1400, 0x01050E0B, 0x2D140001, 0x0C000206, 0x0E0A370B, + 0x2D010E0A, 0x370B2D03, 0x0E0A000A, 0x37010400, 0x01000000, +}; + +s32 D_80BDFCBC[] = { + 0x09000017, 0x0E27A50C, 0x09000018, 0x0E27A60C, 0x09000017, 0x0E27A70C, 0x09000018, 0x0E27A80C, + 0x09000017, 0x0E27A90C, 0x09000018, 0x0E27AA0C, 0x09000017, 0x0E27AB0C, 0x09000018, 0x0E27AC0C, + 0x09000017, 0x0E27AD2D, 0x000B2D00, 0x080C1159, 0x08090000, 0x10000000, +}; + +s32 D_80BDFD14[] = { + 0x00562000, 0xA2090000, 0x170E2AA6, 0x0C090000, 0x180E2AA7, 0x0C090000, 0x170E2AA8, 0x0C090000, + 0x180E2AA9, 0x0C090000, 0x170E2AAA, 0x0C090000, 0x180E2AAB, 0x0C090000, 0x170E2AAC, 0x0C090000, + 0x170E2AAD, 0x0C0F2AAE, 0x0C090000, 0x180E2AAF, 0x0C090000, 0x170E2AB0, 0x0C090000, 0x170E2AB1, + 0x0C090000, 0x180E2AB2, 0x0C090000, 0x170E2AB3, 0x0C090000, 0x180E2AB4, 0x0C090000, 0x170E2AB5, + 0x0C090000, 0x180E2AB6, 0x0C090000, 0x170E2AB7, 0x0C090000, 0x180E2AB8, 0x2D00082D, 0x00092D00, + 0x0A0C1156, 0x20121009, 0x0000170E, 0x2AEA0C09, 0x0000180E, 0x2AEB0C09, 0x00001210, +}; + +s32 D_80BDFDD0[] = { 0x005C0800, 0x0B0E2AE5, 0x2D000811, 0x5C080C10, 0x0E2AE62D, 0x00080C10 }; + +s32 D_80BDFDE8[] = { 0x0900000E, 0x2B192D00, 0x080C1509, 0x00001210 }; + +s32 D_80BDFDF8[] = { + 0x09000000, 0x39040071, 0x0E2B1A0C, 0x0F00FF1E, 0x00330018, 0x000D0000, 0x0E2B1B2D, 0x00080C15, 0x09000012, + 0x102C2B1C, 0x0C2F0000, 0x0C19FFDC, 0x2C2B1D0C, 0x2F00000C, 0x0F2B1E0C, 0x0F2B1F0C, 0x122A002E, 0x00390800, + 0x1306006F, 0x00001300, 0x6F2F0000, 0x2E2D0023, 0x0C07000C, 0x06000500, 0x00130005, 0x0C070000, 0x0E2B202D, + 0x00080C16, 0x11390411, 0x390819FF, 0xA60E2B3C, 0x2D00080C, 0x19FF9C00, +}; + +s32 D_80BDFE7C[] = { 0x0E2A9C2D, 0x00080C10 }; + +s32 D_80BDFE84[] = { 0x0E2A9D2D, 0x00080C10 }; + +s32 D_80BDFE8C[] = { + 0x00390200, 0x0F0E2A9E, 0x0C0F2A9F, 0x0C0F2AA0, 0x0C190004, 0x0E2AA00C, 0x05000000, 0x1A001A30, 0x0E2AA20C, + 0x1206008F, 0x00001300, 0x8F2F0000, 0x2E2D002C, 0x2D00080C, 0x10310E2A, 0xA12D0008, 0x0C113902, 0x10000000, +}; + +s32 D_80BDFED4[] = { + 0x0900002C, 0x2B1D0C2F, 0x00000C0F, 0x2B1E0C0F, 0x2B1F0C12, 0x2A002E00, 0x39080013, + 0x06006F00, 0x0013006F, 0x2F00002E, 0x2D00230C, 0x07000C06, 0x00050000, 0x1300050C, + 0x0700000E, 0x2B202D00, 0x080C1611, 0x39041139, 0x08150900, 0x00121000, +}; + +s32 D_80BDFF24[] = { + 0x0900002C, 0x2B1C0C0F, 0x00FF1E00, 0x33000DFF, 0xF000000E, 0x2B1B2D00, 0x080C1509, 0x00001210, + 0x2C2B1D0C, 0x2F00000C, 0x0F2B1E0C, 0x0F2B1F0C, 0x122A002E, 0x00390800, 0x1306006F, 0x00001300, + 0x6F2F0000, 0x2E2D0023, 0x0C07000C, 0x06000500, 0x00130005, 0x0C070000, 0x0E2B202D, 0x00080C16, + 0x11390411, 0x390819FF, 0xB10E2B3C, 0x2D00080C, 0x19FFA700, +}; + const ActorInit En_Al_InitVars = { ACTOR_EN_AL, ACTORCAT_NPC, @@ -31,87 +85,829 @@ const ActorInit En_Al_InitVars = { (ActorFunc)EnAl_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BDFFB8 = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 14, 62, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BDFFE4 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_al_Anim_000C54, 1.0f, 0, -1, 0, -4 }, { &object_al_Anim_00DBE0, 1.0f, 0, -1, 0, 0 }, + { &object_al_Anim_00DBE0, 1.0f, 0, -1, 0, -4 }, { &object_al_Anim_00ACA0, 1.0f, 0, -1, 2, 0 }, + { &object_al_Anim_00ACA0, -1.0f, 0, -1, 2, 0 }, { &object_al_Anim_00CA28, 1.0f, 0, -1, 0, -4 }, + { &object_al_Anim_00BCA4, 1.0f, 0, -1, 2, 0 }, { &object_al_Anim_00A764, 1.0f, 0, -1, 0, -4 }, +}; -extern ColliderCylinderInit D_80BDFFB8; -extern CollisionCheckInfoInit2 D_80BDFFE4; +Vec3f D_80BE0070 = { 1000.0f, 0.0f, 0.0f }; -extern UNK_TYPE D_0600A0D8; +Gfx* D_80BE007C[] = { + object_al_DL_006598, object_al_DL_005920, object_al_DL_005878, + object_al_DL_0057D0, object_al_DL_005728, object_al_DL_005680, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE1A0.s") +Actor* func_80BDE1A0(EnAl* this, GlobalContext* globalCtx, u8 arg0, s16 arg1) { + Actor* foundActor = NULL; + Actor* temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE250.s") + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, arg0, arg1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE27C.s") + if (foundActor == NULL) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE318.s") + if ((this != (EnAl*)foundActor) && (foundActor->update != NULL)) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE384.s") + temp = foundActor->next; + if (temp == NULL) { + foundActor = NULL; + break; + } + foundActor = temp; + } + return foundActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE408.s") +void func_80BDE250(EnAl* this) { + this->skelAnime.playSpeed = this->unk_4C8; + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE484.s") +s32 func_80BDE27C(EnAl* this, s32 arg1) { + s32 phi_v1 = false; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE4E0.s") + if ((arg1 == 1) || (arg1 == 2)) { + if ((this->unk_4F8 != 1) && (this->unk_4F8 != 2)) { + phi_v1 = true; + } + } else if (arg1 != this->unk_4F8) { + phi_v1 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE678.s") + if (phi_v1) { + this->unk_4F8 = arg1; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + this->unk_4C8 = this->skelAnime.playSpeed; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE7FC.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE92C.s") +void func_80BDE318(EnAl* this, GlobalContext* globalCtx) { + s32 pad; + f32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDEA14.s") + Collider_UpdateCylinder(&this->actor, &this->unk_310); + temp = this->actor.focus.pos.y - this->actor.world.pos.y; + this->unk_310.dim.height = temp; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->unk_310.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDEABC.s") +Actor* func_80BDE384(EnAl* this, GlobalContext* globalCtx) { + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDEC2C.s") + switch (this->unk_35C) { + case 2: + if (!(gSaveContext.weekEventReg[89] & 8) && (gSaveContext.weekEventReg[85] & 0x80)) { + actor = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_PM); + } else { + actor = &GET_PLAYER(globalCtx)->actor; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDED20.s") + case 3: + actor = this->unk_368; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDEE5C.s") + default: + actor = &GET_PLAYER(globalCtx)->actor; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDEF3C.s") + return actor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDEFE4.s") +s32 func_80BDE408(EnAl* this, s16 arg1) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF064.s") + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(arg1); + } else if (ActorCutscene_GetCanPlayNext(arg1)) { + ActorCutscene_StartAndSetUnkLinkFields(arg1, &this->actor); + ret = true; + } else { + ActorCutscene_SetIntentToPlay(arg1); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF244.s") +s16 func_80BDE484(EnAl* this, s32 arg1) { + s16 cs = this->actor.cutscene; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF308.s") + for (i = 0; i < arg1; i++) { + cs = ActorCutscene_GetAdditionalCutscene(cs); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF390.s") + return cs; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF414.s") +s32 func_80BDE4E0(EnAl* this, s16* arg1, s16 arg2) { + s32 ret = false; + s16 sp42; + Vec3f sp34; + Vec3f sp28; + s32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF568.s") + if ((this->unk_368 == NULL) || (this->unk_368->update == NULL)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF578.s") + if (arg2 == *arg1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); + func_80BDE27C(this, 3); + this->unk_4E8 = 0; + (*arg1)++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF5E8.s") + if ((arg2 + 1) == *arg1) { + Math_Vec3f_Copy(&sp28, &this->unk_368->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp42 = Math_Vec3f_Yaw(&sp34, &sp28); + temp = sp42 / 364; + this->unk_4E8++; + if ((temp != (this->actor.world.rot.y / 364)) && (this->unk_4E8 < 20)) { + Math_ApproachS(&this->actor.world.rot.y, sp42, 3, 0x2AA8); + } else { + func_80BDE27C(this, 5); + this->actor.world.rot.y = sp42; + this->unk_4E8 = 0; + (*arg1)++; + ret = true; + } + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF6C4.s") +s32 func_80BDE678(EnAl* this, s16* arg1, s16 arg2) { + s32 ret = false; + s16 sp22; + s32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/EnAl_Init.s") + if ((this->unk_368 == NULL) || (this->unk_368->update == NULL)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/EnAl_Destroy.s") + if (arg2 == *arg1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); + func_80BDE27C(this, 4); + this->unk_4E8 = 0; + (*arg1)++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/EnAl_Update.s") + if ((arg2 + 1) == *arg1) { + sp22 = this->actor.home.rot.y; + temp = sp22 / 364; + this->unk_4E8++; + if ((temp != (this->actor.world.rot.y / 364)) && (this->unk_4E8 < 20)) { + Math_ApproachS(&this->actor.world.rot.y, sp22, 3, 0x2AA8); + } else { + func_80BDE27C(this, 2); + this->actor.world.rot.y = sp22; + this->unk_4E8 = 0; + (*arg1)++; + ret = true; + } + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF914.s") +s32 func_80BDE7FC(EnAl* this, GlobalContext* globalCtx) { + s32 pad; + s16 sp2A = func_80BDE484(this, 0); + s32 pad2; + s32 sp20 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF950.s") + switch (this->unk_4E6) { + case 0: + if (!func_80BDE408(this, sp2A)) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDFA34.s") + case 2: + case 4: + case 6: + case 8: + if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { + func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), this->actor.child); + } + this->unk_4E6++; + sp20 = true; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/EnAl_Draw.s") + case 1: + case 3: + case 5: + case 7: + func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + this->unk_4E6++; + sp20 = true; + break; + + case 9: + ActorCutscene_Stop(sp2A); + this->unk_4E6++; + sp20 = true; + break; + } + return sp20; +} + +s32 func_80BDE92C(EnAl* this, GlobalContext* globalCtx) { + s32 pad[2]; + Actor* sp1C = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_GM); + Actor* temp_v0 = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TOTO); + + if ((sp1C == NULL) || (sp1C->update == NULL) || (temp_v0 == NULL) || (temp_v0->update == NULL)) { + this->unk_4E6++; + return true; + } + + switch (this->unk_4E6) { + case 0: + case 1: + case 3: + case 5: + case 8: + case 10: + case 11: + case 13: + case 15: + case 17: + this->actor.child = sp1C; + this->unk_4E6++; + break; + + case 7: + case 9: + case 12: + this->actor.child = temp_v0; + this->unk_4E6++; + break; + + case 2: + case 4: + case 6: + case 14: + case 16: + this->unk_4E6++; + break; + + default: + this->unk_4E6++; + break; + } + return true; +} + +s32 func_80BDEA14(EnAl* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp18 = false; + + switch (this->unk_4E6) { + case 0: + case 1: + if ((gSaveContext.weekEventReg[75] & 2)) { + sp18 = true; + } else if (func_80BDE4E0(this, &this->unk_4E6, 0)) { + sp18 = true; + } + break; + + case 2: + case 3: + if (func_80BDE678(this, &this->unk_4E6, 2)) { + sp18 = true; + } + break; + } + return sp18; +} + +s32* func_80BDEABC(EnAl* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_35C == 3) { + this->unk_4EC = func_80BDE92C; + return D_80BDFD14; + } + + switch (this->unk_35C) { + case 1: + if (player->transformation == PLAYER_FORM_DEKU) { + return D_80BDFDD0; + } + + if (INV_CONTENT(ITEM_MASK_KAFEIS_MASK) != ITEM_MASK_KAFEIS_MASK) { + return D_80BDFE8C; + } + + if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { + return D_80BDFE7C; + } + return D_80BDFE84; + + case 2: + if (!(gSaveContext.weekEventReg[89] & 8) && (gSaveContext.weekEventReg[85] & 0x80)) { + this->unk_4EC = func_80BDE7FC; + return D_80BDFCBC; + } + + this->unk_4EC = func_80BDEA14; + if (Player_GetMask(globalCtx) != PLAYER_MASK_KAFEIS_MASK) { + return D_80BDFDE8; + } + + if (this->unk_4C2 & 0x800) { + return D_80BDFED4; + } + + if (this->unk_4C2 & 0x1000) { + return D_80BDFF24; + } + return D_80BDFDF8; + } + return NULL; +} + +s32 func_80BDEC2C(EnAl* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 ret = false; + + if ((this->unk_4C2 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_4C2 &= ~0x1800; + if (player->exchangeItemId == 0x33) { + this->unk_4C2 |= 0x800; + this->unk_4F4 = player->exchangeItemId; + } else if (player->exchangeItemId != 0) { + this->unk_4C2 |= 0x1000; + this->unk_4F4 = player->exchangeItemId; + } + func_8013AED4(&this->unk_4C2, 0, 7); + this->unk_4E6 = 0; + this->unk_4EC = 0; + this->actor.child = this->unk_368; + this->unk_360 = func_80BDEABC(this, globalCtx); + this->unk_4C2 |= 0x20; + this->actionFunc = func_80BDF6C4; + ret = true; + } + + return ret; +} + +void func_80BDED20(EnAl* this) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s32 pad2; + + Math_Vec3f_Copy(&sp40, &this->unk_368->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + + Math_ApproachS(&this->unk_4DE, Math_Vec3f_Yaw(&sp34, &sp40) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_4DE = CLAMP(this->unk_4DE, -0x1FFE, 0x1FFE); + + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + + if (this->unk_368->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_368)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_368->focus.pos); + } + + Math_ApproachS(&this->unk_4DC, Math_Vec3f_Pitch(&sp34, &sp40), 4, 0x2AA8); + this->unk_4DC = CLAMP(this->unk_4DC, -0x1554, 0x1554); +} + +void func_80BDEE5C(EnAl* this) { + if (this->unk_4C2 & 0x20) { + if ((this->unk_368 != NULL) && (this->unk_368->update != NULL)) { + if (DECR(this->unk_4E2) == 0) { + func_80BDED20(this); + this->unk_4C2 &= ~0x200; + this->unk_4C2 |= 0x80; + return; + } + } + } + + if (this->unk_4C2 & 0x80) { + this->unk_4C2 &= ~0x80; + this->unk_4DC = 0; + this->unk_4DE = 0; + this->unk_4E2 = 0x14; + } else if (DECR(this->unk_4E2) == 0) { + this->unk_4C2 |= 0x200; + } +} + +void func_80BDEF3C(EnAl* this, GlobalContext* globalCtx) { + if (this->unk_4E4 == 0) { + func_80BDE27C(this, 7); + this->unk_4C2 &= ~0x20; + this->unk_4C2 |= 0x200; + this->unk_4E4++; + } else if ((this->unk_4E4 == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80BDE27C(this, 0); + this->unk_4C2 &= ~0x200; + this->unk_4C2 |= 0x20; + this->unk_4E4++; + } +} + +void func_80BDEFE4(EnAl* this, GlobalContext* globalCtx) { + if (this->unk_4E4 == 0) { + func_80BDE27C(this, 6); + this->unk_4E4 += 1; + } else if ((this->unk_4E4 == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80BDE27C(this, 5); + this->unk_4E4 += 1; + } +} + +s32 func_80BDF064(EnAl* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u16 sp22 = globalCtx->msgCtx.unk11F04; + Actor* sp1C = func_80BDE1A0(this, globalCtx, 4, 0xA4); + Actor* temp_v0 = func_80BDE1A0(this, globalCtx, 4, 0x234); + + if (player->stateFlags1 & 0x40) { + this->unk_4C2 |= 0x400; + if (this->unk_4C4 != sp22) { + switch (sp22) { + case 0x2AA6: + case 0x2AAF: + case 0x2AB4: + if ((sp1C != NULL) && (sp1C->update != NULL)) { + this->unk_368 = sp1C; + } + break; + + case 0x2AAD: + case 0x2AB0: + if ((temp_v0 != NULL) && (temp_v0->update != NULL)) { + this->unk_368 = temp_v0; + } + break; + } + + switch (sp22) { + case 0x2AA1: + case 0x2AA2: + case 0x2AA7: + case 0x2AE6: + case 0x2AE8: + case 0x2AE9: + case 0x2AB4: + this->unk_18C = func_80BDEF3C; + this->unk_4E4 = 0; + break; + + case 0x27A6: + case 0x27A8: + case 0x27AA: + case 0x2B1E: + this->unk_18C = func_80BDEFE4; + this->unk_4E4 = 0; + break; + + case 0x2B19: + case 0x2B20: + case 0x2B3C: + func_80BDE27C(this, 5); + break; + } + } + this->unk_4C4 = sp22; + } else if (this->unk_4C2 & 0x400) { + this->unk_4C4 = 0; + this->unk_4C2 &= ~0x400; + } + + if (this->unk_18C != NULL) { + this->unk_18C(this, globalCtx); + } + + return false; +} + +s32 func_80BDF244(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret = false; + Actor* sp20 = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_GM); + Actor* temp_v0 = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TOTO); + + if ((sp20 != NULL) && (sp20->update != NULL) && (temp_v0 != NULL) && (temp_v0->update != NULL)) { + func_80BDE27C(this, 0); + func_8013AED4(&this->unk_4C2, 3, 7); + this->unk_368 = sp20; + this->unk_4C2 |= 0x20; + ret = true; + } + return ret; +} + +s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + func_8013AED4(&this->unk_4C2, 3, 7); + + switch (arg2->unk0) { + case 1: + func_80BDE27C(this, 0); + break; + + case 2: + this->unk_4F0 = 0; + this->unk_4EA = 0; + func_80BDE27C(this, 2); + break; + } + return true; +} + +s32 func_80BDF390(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret; + + this->actor.flags |= ACTOR_FLAG_1; + this->actor.targetMode = 0; + this->unk_4F0 = 0; + this->unk_4C2 = 0; + this->unk_4D4 = 40.0f; + + switch (arg2->unk0) { + case 3: + ret = func_80BDF244(this, globalCtx, arg2); + break; + + case 1: + case 2: + ret = func_80BDF308(this, globalCtx, arg2); + break; + + default: + ret = false; + break; + } + return ret; +} + +void func_80BDF414(EnAl* this, GlobalContext* globalCtx) { + s16 temp_v0; + + switch (this->unk_4EA) { + case 0: + case 1: + if (!(gSaveContext.weekEventReg[89] & 8)) { + if (gSaveContext.weekEventReg[85] & 0x80) { + func_80BDE4E0(this, &this->unk_4EA, 0); + } + } + break; + + case 2: + if (gSaveContext.weekEventReg[89] & 8) { + this->unk_4EA++; + } + break; + + case 3: + case 4: + func_80BDE678(this, &this->unk_4EA, 3); + break; + } + + temp_v0 = this->actor.world.rot.y - this->actor.yawTowardsPlayer; + if (((this->unk_4EA == 0) && (ABS_ALT(temp_v0) >= 0x5800)) || + ((this->unk_4EA == 5) && (ABS_ALT(temp_v0) >= 0x5800)) || (this->unk_4EA == 2)) { + func_8013AED4(&this->unk_4C2, 3, 7); + } else { + func_8013AED4(&this->unk_4C2, 0, 7); + } +} + +void func_80BDF568(EnAl* this, GlobalContext* globalCtx) { +} + +void func_80BDF578(EnAl* this, GlobalContext* globalCtx) { + switch (this->unk_35C) { + case 1: + case 3: + func_80BDF568(this, globalCtx); + break; + + case 2: + func_80BDF414(this, globalCtx); + break; + } + + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); +} + +void func_80BDF5E8(EnAl* this, GlobalContext* globalCtx) { + u32* unk14 = &gSaveContext.unk_14; + struct_80133038_arg2 sp20; + + this->unk_4E0 = REG(15) + *unk14; + if (!func_80133038(globalCtx, D_80BDFC70, &sp20) || + ((this->unk_35C != sp20.unk0) && !func_80BDF390(this, globalCtx, &sp20))) { + this->actor.shape.shadowDraw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + sp20.unk0 = 0; + } else { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.flags |= ACTOR_FLAG_1; + } + this->unk_35C = sp20.unk0; + this->unk_368 = func_80BDE384(this, globalCtx); + func_80BDF578(this, globalCtx); +} + +void func_80BDF6C4(EnAl* this, GlobalContext* globalCtx) { + if (func_8010BF58(&this->actor, globalCtx, this->unk_360, this->unk_4EC, &this->unk_364)) { + func_8013AED4(&this->unk_4C2, 3, 7); + this->unk_4C2 &= ~0x20; + this->unk_4C2 |= 0x200; + this->actor.child = NULL; + this->unk_4E2 = 20; + this->unk_364 = 0; + this->actionFunc = func_80BDF5E8; + } else { + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); + } +} + +void EnAl_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAl* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_al_Skel_00A0D8, NULL, this->jointTable, this->morphTable, + 27); + this->unk_4F8 = -1; + func_80BDE27C(this, 1); + Collider_InitAndSetCylinder(globalCtx, &this->unk_310, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + Actor_SetScale(&this->actor, 0.01f); + this->unk_35C = 0; + this->actionFunc = func_80BDF5E8; + + this->actionFunc(this, globalCtx); +} + +void EnAl_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAl* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->unk_310); +} + +void EnAl_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAl* this = THIS; + + func_80BDEC2C(this, globalCtx); + + this->actionFunc(this, globalCtx); + + func_80BDF064(this, globalCtx); + + if (this->unk_35C != 0) { + func_80BDE250(this); + func_80BDEE5C(this); + func_8013C964(&this->actor, globalCtx, this->unk_4D4, 30.0f, this->unk_4F0, this->unk_4C2 & 7); + func_80BDE318(this, globalCtx); + } +} + +s32 EnAl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + switch (limbIndex) { + case 3: + case 11: + case 12: + case 13: + case 14: + case 15: + *dList = NULL; + break; + + case 16: + break; + } + return false; +} + +void EnAl_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnAl* this = THIS; + + switch (limbIndex) { + case 3: + Matrix_CopyCurrentState(&this->unk_190[0]); + break; + + case 11: + Matrix_CopyCurrentState(&this->unk_190[1]); + break; + + case 12: + Matrix_CopyCurrentState(&this->unk_190[2]); + break; + + case 13: + Matrix_CopyCurrentState(&this->unk_190[3]); + break; + + case 14: + Matrix_CopyCurrentState(&this->unk_190[4]); + break; + + case 15: + Matrix_CopyCurrentState(&this->unk_190[5]); + break; + + case 16: + Matrix_MultiplyVector3fByState(&D_80BE0070, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + break; + } +} + +void EnAl_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnAl* this = THIS; + s32 phi_v0; + s32 phi_v1; + + if (!(this->unk_4C2 & 0x200)) { + if (this->unk_4C2 & 0x80) { + phi_v1 = 1; + } else { + phi_v1 = 0; + } + phi_v0 = 1; + } else { + phi_v1 = 0; + phi_v0 = 0; + } + + if (limbIndex == 16) { + func_8013AD9C(this->unk_4DC + 0x4000, this->unk_4DE + this->actor.shape.rot.y + 0x4000, &this->unk_36C, + &this->unk_378, phi_v0, phi_v1); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_36C.x, this->unk_36C.y, this->unk_36C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_378.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_378.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_378.z, MTXMODE_APPLY); + Matrix_StatePush(); + } +} + +void EnAl_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnAl* this = THIS; + s32 i; + + if (this->unk_35C != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(0.0f, 0.0f, 850.0f, MTXMODE_APPLY); + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnAl_OverrideLimbDraw, EnAl_PostLimbDraw, + EnAl_TransformLimbDraw, &this->actor); + + for (i = 0; i < ARRAY_COUNT(this->unk_190); i++) { + Matrix_SetCurrentState(&this->unk_190[i]); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_80BE007C[i]); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.h b/src/overlays/actors/ovl_En_Al/z_en_al.h index a4a8cf999..9e5ee8872 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.h +++ b/src/overlays/actors/ovl_En_Al/z_en_al.h @@ -6,12 +6,43 @@ struct EnAl; typedef void (*EnAlActionFunc)(struct EnAl*, GlobalContext*); +typedef s32 (*EnAlUnkFunc)(struct EnAl*, GlobalContext*); +typedef void (*EnAlUnkFunc2)(struct EnAl*, GlobalContext*); typedef struct EnAl { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnAlActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x374]; + /* 0x018C */ EnAlUnkFunc2 unk_18C; + /* 0x0190 */ MtxF unk_190[6]; + /* 0x0310 */ ColliderCylinder unk_310; + /* 0x035C */ u8 unk_35C; + /* 0x0360 */ s32* unk_360; + /* 0x0364 */ s32 unk_364; + /* 0x0368 */ Actor* unk_368; + /* 0x036C */ Vec3f unk_36C; + /* 0x0378 */ Vec3s unk_378; + /* 0x037E */ Vec3s jointTable[27]; + /* 0x0420 */ Vec3s morphTable[27]; + /* 0x04C2 */ u16 unk_4C2; + /* 0x04C4 */ u16 unk_4C4; + /* 0x04C8 */ f32 unk_4C8; + /* 0x04CC */ UNK_TYPE1 unk4CC[8]; + /* 0x04D4 */ f32 unk_4D4; + /* 0x04D8 */ UNK_TYPE1 unk4D8[4]; + /* 0x04DC */ s16 unk_4DC; + /* 0x04DE */ s16 unk_4DE; + /* 0x04E0 */ s16 unk_4E0; + /* 0x04E2 */ s16 unk_4E2; + /* 0x04E4 */ s16 unk_4E4; + /* 0x04E6 */ s16 unk_4E6; + /* 0x04E8 */ s16 unk_4E8; + /* 0x04EA */ s16 unk_4EA; + /* 0x04EC */ EnAlUnkFunc unk_4EC; + /* 0x04F0 */ s32 unk_4F0; + /* 0x04F4 */ s32 unk_4F4; + /* 0x04F8 */ s32 unk_4F8; + /* 0x04FC */ UNK_TYPE1 unk4FC[4]; } EnAl; // size = 0x500 extern const ActorInit En_Al_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e203f9bf6..21d895d40 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16029,9 +16029,9 @@ 0x80BDF75C:("EnAl_Init",), 0x80BDF840:("EnAl_Destroy",), 0x80BDF86C:("EnAl_Update",), - 0x80BDF914:("func_80BDF914",), - 0x80BDF950:("func_80BDF950",), - 0x80BDFA34:("func_80BDFA34",), + 0x80BDF914:("EnAl_OverrideLimbDraw",), + 0x80BDF950:("EnAl_PostLimbDraw",), + 0x80BDFA34:("EnAl_TransformLimbDraw",), 0x80BDFB30:("EnAl_Draw",), 0x80BE04E0:("func_80BE04E0",), 0x80BE0590:("func_80BE0590",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 5acf9e551..6222fe24f 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1091,10 +1091,6 @@ D_06000F38 = 0x06000F38; D_06009E70 = 0x06009E70; -// ovl_En_Al - -D_0600A0D8 = 0x0600A0D8; - // ovl_En_An D_06000308 = 0x06000308; From 271cf4de70d8cbce25777d7ae2e0d35283454278 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 19 Feb 2022 19:41:46 +0000 Subject: [PATCH 025/257] Obj_Snowball2 (#596) * Obj_Snowball2 * Merge * merge * PR --- spec | 3 +- .../ovl_Obj_Snowball2/z_obj_snowball2.c | 607 ++++++++++++++++-- .../ovl_Obj_Snowball2/z_obj_snowball2.h | 14 +- undefined_syms.txt | 4 - 4 files changed, 574 insertions(+), 54 deletions(-) diff --git a/spec b/spec index 839ec5578..2ac30b32e 100644 --- a/spec +++ b/spec @@ -4054,8 +4054,7 @@ beginseg name "ovl_Obj_Snowball2" compress include "build/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.o" - include "build/data/ovl_Obj_Snowball2/ovl_Obj_Snowball2.data.o" - include "build/data/ovl_Obj_Snowball2/ovl_Obj_Snowball2.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Snowball2/ovl_Obj_Snowball2_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c index d21acc8b5..76111148a 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c @@ -5,8 +5,9 @@ */ #include "z_obj_snowball2.h" +#include "objects/object_goroiwa/object_goroiwa.h" -#define FLAGS 0x00800000 +#define FLAGS (ACTOR_FLAG_800000) #define THIS ((ObjSnowball2*)thisx) @@ -15,7 +16,16 @@ void ObjSnowball2_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSnowball2_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSnowball2_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B38E20(ObjSnowball2* this); +void func_80B39C78(ObjSnowball2* this); +void func_80B39C9C(ObjSnowball2* this, GlobalContext* globalCtx); +void func_80B39F60(ObjSnowball2* this); +void func_80B39FA8(ObjSnowball2* this, GlobalContext* globalCtx); +void func_80B3A0D8(ObjSnowball2* this); +void func_80B3A13C(ObjSnowball2* this, GlobalContext* globalCtx); +void func_80B3A498(ObjSnowball2* this); +void func_80B3A500(ObjSnowball2* this, GlobalContext* globalCtx); + const ActorInit Obj_Snowball2_InitVars = { ACTOR_OBJ_SNOWBALL2, ACTORCAT_PROP, @@ -28,82 +38,587 @@ const ActorInit Obj_Snowball2_InitVars = { (ActorFunc)ObjSnowball2_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80B3A8E0[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x0583FFBE, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x0583FFBE, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 15 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B3A904 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, D_80B3A8E0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B3A93C[] = { - ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 25, ICHAIN_STOP), +Color_RGBA8 D_80B3A914 = { 250, 250, 250, 255 }; + +Color_RGBA8 D_80B3A918 = { 180, 180, 180, 255 }; + +Gfx* D_80B3A91C[] = { + object_goroiwa_DL_0072F0, + object_goroiwa_DL_0077D0, + object_goroiwa_DL_007C60, + object_goroiwa_DL_007C60, }; -#endif +Vec3f D_80B3A92C = { 0.0f, 0.3f, 0.0f }; -extern ColliderJntSphElementInit D_80B3A8E0[1]; -extern ColliderJntSphInit D_80B3A904; -extern InitChainEntry D_80B3A93C[]; +void func_80B38E20(ObjSnowball2* this) { + Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, + this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), + this->actor.world.pos.z, &this->actor.shape.rot); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Collider_UpdateSpheres(0, &this->collider); +} -extern UNK_TYPE D_06008B90; +void func_80B38E88(ObjSnowball2* this, GlobalContext* globalCtx) { + s32 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B38E20.s") + if (this->unk_1AE == 0) { + temp_v0 = func_800A8150(ENOBJSNOWBALL2_GET_3F(&this->actor)); + if (temp_v0 >= 0) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, + (ENOBJSNOWBALL2_GET_7F00(&this->actor) << 8) | temp_v0); + this->unk_1AE = 1; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B38E88.s") +void func_80B38EFC(ObjSnowball2* this, GlobalContext* globalCtx) { + s32 pad; + s32 i; + Vec3f spA4; + Vec3f sp98; + Vec3f sp8C; + f32 sp88 = this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B38EFC.s") + for (i = 0; i < 2; i++) { + sp8C.x = ((Rand_ZeroOne() * 30.0f) - 15.0f) + this->actor.world.pos.x; + sp8C.y = ((Rand_ZeroOne() * 20.0f) - 10.0f) + sp88; + sp8C.z = ((Rand_ZeroOne() * 30.0f) - 15.0f) + this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39108.s") + sp98.x = (Rand_ZeroOne() - 0.5f) * 1.6f; + sp98.y = -1.5f; + sp98.z = (Rand_ZeroOne() - 0.5f) * 1.6f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39470.s") + spA4.x = sp98.x * -0.06f; + spA4.y = sp98.y * -0.06f; + spA4.z = sp98.z * -0.06f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B395C4.s") + func_800B0E48(globalCtx, &sp8C, &sp98, &spA4, &D_80B3A914, &D_80B3A918, (s32)(Rand_ZeroOne() * 40.0f) + 10, + (s32)(Rand_ZeroOne() * 30.0f) + 10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B395EC.s") +void func_80B39108(ObjSnowball2* this, GlobalContext* globalCtx) { + s32 phi_s5; + s16 phi_s1; + s32 phi_v0; + s32 i; + u32 temp; + s32 temp_s3; + Vec3f spDC; + Vec3f spD0; + f32 temp_f2; + f32 spC8 = this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y); + f32 temp_f0; + f32 temp_f12; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39638.s") + for (i = 0, phi_s5 = 0; i < 11; i++, phi_s5 += (0x10000 / 11)) { + temp_s3 = (s32)(Rand_ZeroOne() * 5957.0f) + phi_s5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39834.s") + if (((u32)Rand_Next() >> 0x1E) == 0) { + phi_s1 = 0x20; + } else { + phi_s1 = 0x40; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39908.s") + if ((i & 3) == 0) { + phi_s1 |= 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39B28.s") + temp_f0 = Rand_ZeroOne(); + temp_f20 = (1.0f - SQ(temp_f0)) * 12.0f; + temp_f22 = Math_SinS(temp_s3); + temp_f24 = Math_CosS(temp_s3); + temp_f12 = (Rand_ZeroOne() * 1.6f) - 0.8f; + temp_f2 = fabsf(temp_f12) * temp_f12; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39B5C.s") + spDC.x = temp_f22 * 4.0f; + spDC.y = (temp_f2 * 6.0f) + 9.0f; + spDC.z = temp_f24 * 4.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/ObjSnowball2_Init.s") + spD0.x = (temp_f22 * temp_f20) + this->actor.world.pos.x; + spD0.y = (temp_f2 * temp_f20) + spC8; + spD0.z = (temp_f24 * temp_f20) + this->actor.world.pos.z; + temp = Rand_Next(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/ObjSnowball2_Destroy.s") + if ((i & 3) == 0) { + phi_v0 = 1; + } else { + phi_v0 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39C78.s") + EffectSsKakera_Spawn(globalCtx, &spD0, &spDC, &spD0, -300, phi_s1, 30, 0, 0, (temp >> 0x1D) + 8, phi_v0, 0, 50, + -1, 0xEF, D_80B3A91C[i & 3]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39C9C.s") + spD0.x += (Rand_ZeroOne() - 0.5f) * 40.0f; + spD0.y += (Rand_ZeroOne() - 0.3f) * 45.0f; + spD0.z += (Rand_ZeroOne() - 0.5f) * 40.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39F60.s") + func_800B0E48(globalCtx, &spD0, &gZeroVec3f, &D_80B3A92C, &D_80B3A914, &D_80B3A918, + (s32)(Rand_ZeroOne() * 70.0f) + 10, (s32)(Rand_ZeroOne() * 100.0f) + 10); + } + spD0.y = (temp_f2 * temp_f20) + spC8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39FA8.s") +void func_80B39470(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + Vec3f sp58; + s32 phi_s0; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B3A0D8.s") + sp58.y = this->actor.world.pos.y + this->actor.depthInWater; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B3A13C.s") + for (phi_s0 = 0, i = 0; i < 5; i++, phi_s0 += (0x10000 / 5)) { + sp58.x = (Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.x; + sp58.z = (Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp58, NULL, NULL, 0, 200); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B3A498.s") + sp58.x = this->actor.world.pos.x; + sp58.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp58, NULL, NULL, 0, 300); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B3A500.s") +void func_80B395C4(GlobalContext* this, Vec3f* arg1) { + EffectSsGRipple_Spawn(this, arg1, 200, 700, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/ObjSnowball2_Update.s") +void func_80B395EC(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + Vec3f sp18; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/ObjSnowball2_Draw.s") + sp18.x = this->actor.world.pos.x; + sp18.y = this->actor.world.pos.y + this->actor.depthInWater; + sp18.z = this->actor.world.pos.z; + func_80B395C4(globalCtx, &sp18); +} + +void func_80B39638(GlobalContext* globalCtx, Vec3f* arg1) { + static s16 D_80B3A938 = 0; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + Vec3f sp98; + Vec3f sp8C; + Vec3f sp80; + f32 temp_f2; + s32 i; + + D_80B3A938 += (s16)((u32)Rand_Next() >> 0x11); + + for (i = 0; i < 2; i++) { + D_80B3A938 += 0x8000; + temp_f20 = Rand_ZeroOne(); + temp_f22 = Math_SinS(D_80B3A938) * temp_f20; + temp_f24 = Rand_ZeroOne(); + temp_f2 = Math_CosS(D_80B3A938) * temp_f20; + + sp98.x = arg1->x + (temp_f22 * 5.0f); + sp98.y = arg1->y + (temp_f24 * 25.0f); + sp98.z = arg1->z + (temp_f2 * 5.0f); + + sp8C.x = temp_f22 * 1.55f; + sp8C.y = temp_f24 * -0.7f; + sp8C.z = temp_f2 * 1.55f; + + sp80.x = sp8C.x * -0.02f; + sp80.y = sp8C.y * -0.025f; + sp80.z = sp8C.z * -0.02f; + + EffectSsIceSmoke_Spawn(globalCtx, &sp98, &sp8C, &sp80, (s32)(Rand_ZeroOne() * 30.0f) + 68); + } +} + +void func_80B39834(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + s32 i; + + for (i = 0; i < 3; i++) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 20.0f, 30.0f, (Rand_ZeroOne() * 0.11f) + 0.03f); + } +} + +void func_80B39908(ObjSnowball2* this, GlobalContext* globalCtx) { + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + s32 i; + + if (this->collider.elements[0].info.bumperFlags & BUMP_HIT) { + Vec3s* hitPos = &this->collider.elements[0].info.bumper.hitPos; + + for (i = 0; i < 4; i++) { + sp94.x = ((Rand_ZeroOne() * 14.0f) - 7.0f) + hitPos->x; + sp94.y = ((Rand_ZeroOne() * 14.0f) - 7.0f) + hitPos->y; + sp94.z = ((Rand_ZeroOne() * 14.0f) - 7.0f) + hitPos->z; + + spA0.x = (Rand_ZeroOne() - 0.5f) * 1.6f; + spA0.y = -0.8f; + spA0.z = (Rand_ZeroOne() - 0.5f) * 1.6f; + + spAC.x = spA0.x * -0.06f; + spAC.y = spA0.y * -0.06f; + spAC.z = spA0.z * -0.06f; + + func_800B0E48(globalCtx, &sp94, &spA0, &spAC, &D_80B3A914, &D_80B3A918, (s32)(Rand_ZeroOne() * 40.0f) + 10, + (s32)(Rand_ZeroOne() * 30.0f) + 10); + } + } +} + +void func_80B39B28(ObjSnowball2* this, GlobalContext* globalCtx) { + if ((this->unk_1AE == 0) && (globalCtx->roomCtx.currRoom.num != this->unk_1AF)) { + this->unk_1AE = 1; + } +} + +void func_80B39B5C(ObjSnowball2* this, GlobalContext* globalCtx) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_SMALL_SNOWBALL_BROKEN); +} + +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 25, ICHAIN_STOP), +}; + +void ObjSnowball2_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitJntSph(globalCtx, &this->collider); + this->actor.shape.rot.x = 0; + this->actor.shape.rot.z = 0; + this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + ActorShape_Init(&this->actor.shape, 200.0f, NULL, 12.5f); + this->actor.shape.shadowAlpha = 130; + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + func_80B38E20(this); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->unk_1AF = this->actor.room; + func_80B39C78(this); +} + +void ObjSnowball2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + + Collider_DestroyJntSph(globalCtx, &this->collider); +} + +void func_80B39C78(ObjSnowball2* this) { + this->actor.flags |= ACTOR_FLAG_10; + this->unk_1AD = 0; + this->actionFunc = func_80B39C9C; +} + +void func_80B39C9C(ObjSnowball2* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp38 = (this->collider.base.acFlags & AC_HIT) != 0; + s32 pad2; + + if (sp38) { + this->collider.base.acFlags &= ~AC_HIT; + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.room = -1; + this->actor.flags |= ACTOR_FLAG_10; + if (func_800A817C(ENOBJSNOWBALL2_GET_3F(&this->actor))) { + func_80B38E88(this, globalCtx); + } + func_80B38EFC(this, globalCtx); + func_800B8E58(GET_PLAYER(globalCtx), NA_SE_PL_PULL_UP_SNOWBALL); + func_80B39F60(this); + } else if ((this->actor.bgCheckFlags & 0x20) && + ((this->actor.shape.yOffset * this->actor.scale.y) < this->actor.depthInWater)) { + func_80B3A498(this); + } else if (sp38 && (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x0583FFBC)) { + func_80B38E88(this, globalCtx); + func_80B39108(this, globalCtx); + func_80B39B5C(this, globalCtx); + Actor_MarkForDeath(&this->actor); + return; + } else { + if (sp38 && (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 2)) { + func_80B39908(this, globalCtx); + } + + if (this->unk_1AD == 0) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 15.0f, 0.0f, 0x44); + if ((this->actor.bgCheckFlags & 1) && + (DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId) == NULL)) { + this->unk_1AD = 1; + this->actor.flags &= ~ACTOR_FLAG_10; + } + } + + if (this->actor.xzDistToPlayer < 800.0f) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->actor.xzDistToPlayer < 150.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->actor.xzDistToPlayer < 100.0f) { + if (ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, GET_PLAYER(globalCtx)->actor.world.rot.y)) >= + 0x5556) { + Actor_PickUp(&this->actor, globalCtx, GI_NONE, 36.0f, 30.0f); + } + } + } + } + } +} + +void func_80B39F60(ObjSnowball2* this) { + this->actor.world.pos.y += (600.0f - this->actor.shape.yOffset) * this->actor.scale.y; + this->unk_1AC = 4; + this->actor.shape.yOffset = 600.0f; + this->actionFunc = func_80B39FA8; +} + +void func_80B39FA8(ObjSnowball2* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + s32 sp2C; + + func_80B39B28(this, globalCtx); + + if (this->unk_1AC > 0) { + this->unk_1AC--; + func_80B38EFC(this, globalCtx); + } + + if (Actor_HasNoParent(&this->actor, globalCtx)) { + this->actor.room = globalCtx->roomCtx.currRoom.num; + this->actor.speedXZ *= 3.8f; + this->actor.velocity.y *= 0.4f; + this->actor.gravity = -2.8f; + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 15.0f, 0.0f, 0x45); + func_80B3A0D8(this); + } else { + sp30.x = this->actor.world.pos.x; + sp30.y = this->actor.world.pos.y + 20.0f; + sp30.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); + } +} + +void func_80B3A0D8(ObjSnowball2* this) { + this->unk_1AC = 60; + this->actor.colChkInfo.mass = 180; + this->unk_1A8 = Rand_S16Offset(-5000, 4000); + this->unk_1AA = Rand_S16Offset(-800, 1600); + this->actionFunc = func_80B3A13C; +} + +void func_80B3A13C(ObjSnowball2* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp38 = (this->collider.base.atFlags & AT_HIT) != 0; + s32 sp34 = (this->collider.base.ocFlags1 & OC1_HIT) != 0; + s32 sp30; + + if (sp38) { + this->collider.base.atFlags &= ~AT_HIT; + } + + if (sp34) { + this->collider.base.ocFlags1 &= ~OC1_HIT; + } + + if (this->unk_1AC > 0) { + this->unk_1AC--; + } + + func_80B39B28(this, globalCtx); + + if ((((this->actor.bgCheckFlags & 9) || sp38) && !(this->actor.bgCheckFlags & 0x20)) || (this->unk_1AC <= 0)) { + func_80B38E88(this, globalCtx); + func_80B39108(this, globalCtx); + func_80B39B5C(this, globalCtx); + Actor_MarkForDeath(&this->actor); + return; + } + + sp30 = false; + if (this->actor.bgCheckFlags & 0x60) { + if ((this->actor.bgCheckFlags & 0x40) || (this->actor.speedXZ > 3.0f)) { + if (this->actor.depthInWater < (1200.0f * this->actor.scale.y)) { + func_80B39470(&this->actor, globalCtx); + func_80B395EC(&this->actor, globalCtx); + } + if (this->actor.bgCheckFlags & 0x40) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); + } + } else if ((((globalCtx->gameplayFrames % 16) == 0) || (((u32)Rand_Next() >> 0x10) == 0)) && + (this->actor.depthInWater < (1200.0f * this->actor.scale.y))) { + func_80B395EC(&this->actor, globalCtx); + } + + func_80B39834(&this->actor, globalCtx); + this->unk_1A8 >>= 1; + this->unk_1AA >>= 1; + + if (sp34) { + this->actor.speedXZ *= 0.8f; + } else { + this->actor.speedXZ *= 0.65f; + } + this->actor.velocity.y *= 0.27f; + this->actor.gravity *= 0.27f; + if (this->actor.speedXZ < 0.4f) { + sp30 = true; + } + } else { + if (sp34) { + this->actor.speedXZ *= 0.8f; + } else { + this->actor.speedXZ *= 0.96f; + } + this->actor.velocity.y *= 0.96f; + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 15.0f, 0.0f, 0x45); + this->actor.shape.rot.x += this->unk_1A8; + this->actor.shape.rot.y += this->unk_1AA; + func_80B38E20(this); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (sp30) { + func_80B3A498(this); + } else { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80B3A498(ObjSnowball2* this) { + this->actor.home.pos.x = this->actor.world.pos.x; + this->unk_1AC = 46; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.home.pos.y = this->actor.world.pos.y + this->actor.depthInWater; + this->actor.home.pos.z = this->actor.world.pos.z; + this->actor.world.pos.y = this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y); + this->actor.shape.yOffset = 0.0f; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80B3A500; +} + +void func_80B3A500(ObjSnowball2* this, GlobalContext* globalCtx) { + f32 phi_f0; + s32 pad; + f32 temp_f14 = this->actor.home.pos.y - this->actor.world.pos.y; + f32 temp_f12 = this->actor.scale.y * 600.0f; + + this->unk_1AC--; + + this->actor.speedXZ *= 0.7f; + + this->unk_1A8 >>= 1; + this->unk_1AA >>= 1; + + this->actor.shape.rot.x += this->unk_1A8; + this->actor.shape.rot.y += this->unk_1AA; + + if (temp_f14 < -temp_f12) { + this->actor.gravity = this->actor.scale.y * -40.0f; + phi_f0 = 0.94f; + } else if (temp_f12 < temp_f14) { + this->actor.gravity = this->actor.scale.y * 24.0f; + phi_f0 = 0.8f; + } else if (temp_f12 > 0.001f) { + this->actor.gravity = (((1.6f * temp_f14) / temp_f12) + -1.0f + 0.6f) * 0.5f * 40.0f * this->actor.scale.y; + phi_f0 = (((-0.13999999f * temp_f14) / temp_f12) + 0.94f + 0.8f) * 0.5f; + } else { + this->actor.gravity = 0.0f; + phi_f0 = 1.0f; + } + + this->actor.velocity.y *= phi_f0; + this->actor.velocity.y += this->actor.gravity; + this->actor.world.pos.y += this->actor.velocity.y; + + if (((globalCtx->gameplayFrames % 16) == 0) || (((u32)Rand_Next() >> 0x10) == 0)) { + func_80B395C4(globalCtx, &this->actor.home.pos); + } + + if (this->unk_1AC <= 0) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (this->unk_1AC < 20) { + this->actor.scale.x -= 0.00125f; + if (this) {} + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; + + if ((this->unk_1AC >= 6) && (temp_f14 < temp_f12)) { + func_80B39638(globalCtx, &this->actor.home.pos); + } + + if (this->unk_1AC == 10) { + func_80B38E88(this, globalCtx); + } + + func_800B9010(&this->actor, NA_SE_EV_ICE_MELT_LEVEL - SFX_FLAG); + } else { + func_80B38E20(this); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void ObjSnowball2_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->actor.projectedPos.z < 460.0f) { + if (this->actor.projectedPos.z > 200.0f) { + this->actor.shape.shadowAlpha = (460 - (s32)this->actor.projectedPos.z) >> 1; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } else if (this->actor.projectedPos.z > -10.0f) { + this->actor.shape.shadowAlpha = 130; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } else { + this->actor.shape.shadowDraw = NULL; + } + } else { + this->actor.shape.shadowDraw = NULL; + } +} + +void ObjSnowball2_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + + Gfx_DrawDListOpa(globalCtx, object_goroiwa_DL_008B90); +} diff --git a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h index cbffe01f2..120358a80 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h @@ -7,11 +7,21 @@ struct ObjSnowball2; typedef void (*ObjSnowball2ActionFunc)(struct ObjSnowball2*, GlobalContext*); +#define ENOBJSNOWBALL2_GET_3F(thisx) ((thisx)->params & 0x3F) +#define ENOBJSNOWBALL2_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) + typedef struct ObjSnowball2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x60]; + /* 0x0144 */ ColliderJntSph collider; + /* 0x0164 */ ColliderJntSphElement colliderElements[1]; /* 0x01A4 */ ObjSnowball2ActionFunc actionFunc; - /* 0x01A8 */ char unk_1A8[0xC]; + /* 0x01A8 */ s16 unk_1A8; + /* 0x01AA */ s16 unk_1AA; + /* 0x01AC */ s8 unk_1AC; + /* 0x01AD */ u8 unk_1AD; + /* 0x01AE */ s8 unk_1AE; + /* 0x01AF */ s8 unk_1AF; + /* 0x01B0 */ UNK_TYPE1 unk1B0[4]; } ObjSnowball2; // size = 0x1B4 extern const ActorInit Obj_Snowball2_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 6222fe24f..943116324 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2183,10 +2183,6 @@ D_060011E0 = 0x060011E0; D_06001C00 = 0x06001C00; -// ovl_Obj_Snowball2 - -D_06008B90 = 0x06008B90; - // ovl_Obj_Spinyroll D_06000460 = 0x06000460; From 557825636fa2e69fa27e75c1b4292145784fe989 Mon Sep 17 00:00:00 2001 From: retro <43223593+retro-git@users.noreply.github.com> Date: Sat, 19 Feb 2022 19:48:05 +0000 Subject: [PATCH 026/257] EnOsn OK (#603) * start working on struct * init matching * destroy matched * func_80AD0830 and update matching * func_80AD1634 matching * idle matching * func_80AD16A8 matching * cleanup * func_80AD0A24 matching * cleanup * func_80AD144C matching * func_80AD14C8 almost matchign * func_80AD14C8 matching * func_80AD19A0 matching * func_80AD0AB0 matching * func_80AD0998 matching * func_80AD1398 matchign * cleanup * func_80AD0B38 matching * func_80AD0E10 matching * func_80AD08B0 matching * func_80AD10FC matching * EnOsn_Draw matching * func_80AD1DA8 matching * func_80AD1E28 matching * document * update kafei mask * import data * actorfixer * fix warnings * cleanup * format and cleanup * use unk_type * most feedback done * format * change unks to vec3s * treat as bool * use CHECK_QUEST_ITEM macro * use CHECK_QUEST_ITEM macro * some documentation * format * some feedback done * fix fallthrough spacing in switch * split up func_80AD1398 * format * more feedback * param macro * use param macro * replace returns with break * remove padding * fix for upstream merge * feedback * move some data inline * feedback * fetch upstream Co-authored-by: retro Co-authored-by: retro Co-authored-by: retro --- spec | 3 +- src/overlays/actors/ovl_En_Osn/z_en_osn.c | 872 +++++++++++++++++++++- src/overlays/actors/ovl_En_Osn/z_en_osn.h | 20 +- tools/disasm/functions.txt | 6 +- 4 files changed, 853 insertions(+), 48 deletions(-) diff --git a/spec b/spec index 2ac30b32e..21237ae08 100644 --- a/spec +++ b/spec @@ -3561,8 +3561,7 @@ beginseg name "ovl_En_Osn" compress include "build/src/overlays/actors/ovl_En_Osn/z_en_osn.o" - include "build/data/ovl_En_Osn/ovl_En_Osn.data.o" - include "build/data/ovl_En_Osn/ovl_En_Osn.reloc.o" + include "build/src/overlays/actors/ovl_En_Osn/ovl_En_Osn_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.c b/src/overlays/actors/ovl_En_Osn/z_en_osn.c index 758da16f4..36bdcef8e 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -5,8 +5,9 @@ */ #include "z_en_osn.h" +#include "objects/object_osn/object_osn.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_8 | ACTOR_FLAG_1) #define THIS ((EnOsn*)thisx) @@ -15,7 +16,6 @@ void EnOsn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnOsn_Update(Actor* thisx, GlobalContext* globalCtx); void EnOsn_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Osn_InitVars = { ACTOR_EN_OSN, ACTORCAT_NPC, @@ -28,18 +28,45 @@ const ActorInit En_Osn_InitVars = { (ActorFunc)EnOsn_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AD2518 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static AnimationInfo sAnimations[] = { + { &object_osn_Anim_0201BC, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_002F74, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_0037C4, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_004320, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_004C8C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_0094E4, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_009BB8, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_00AC60, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_001614, 1.0f, 1.0f, 39.0f, 0, 0.0f }, { &object_osn_Anim_001034, 1.0f, 1.0f, 70.0f, 0, 0.0f }, + { &object_osn_Anim_00AE9C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_003A1C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_0055F8, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_007220, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_00A444, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_0000C4, 0.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_osn_Anim_0000C4, 0.0f, 1.0f, 1.0f, 2, 0.0f }, { &object_osn_Anim_006D48, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_001D6C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_osn_Anim_002634, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_008D80, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_osn_Anim_005D78, 1.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_osn_Anim_006564, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_00A444, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_008D80, 0.0f, 77.0f, 0.0f, 2, 0.0f }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80AD2544 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80AD2550 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -74,59 +101,824 @@ static DamageTable D_80AD2550 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AD2570[] = { +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 0, ICHAIN_STOP), }; -#endif +void func_80AD1634(EnOsn*, GlobalContext*); +void func_80AD16A8(EnOsn*, GlobalContext*); +void func_80AD14C8(EnOsn*, GlobalContext*); +void func_80AD19A0(EnOsn* this, GlobalContext* globalCtx); -extern ColliderCylinderInit D_80AD2518; -extern CollisionCheckInfoInit2 D_80AD2544; -extern DamageTable D_80AD2550; -extern InitChainEntry D_80AD2570[]; +void func_80AD0830(EnOsn* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -extern UNK_TYPE D_060192A0; -extern UNK_TYPE D_060201BC; +s32 func_80AD08B0(GlobalContext* globalCtx) { + switch (Player_GetMask(globalCtx)) { + case PLAYER_MASK_GREAT_FAIRY: + return 0x1FD6; + case PLAYER_MASK_GIBDO: + return 0x1FD8; + case PLAYER_MASK_TRUTH: + return 0x1FDA; + case PLAYER_MASK_GIANT: + return 0x1FDC; + case PLAYER_MASK_KAFEIS_MASK: + return 0x1FDE; + case PLAYER_MASK_DON_GERO: + return 0x1FE0; + case PLAYER_MASK_BLAST: + return 0x1FE2; + case PLAYER_MASK_COUPLE: + return 0x1FE4; + case PLAYER_MASK_SCENTS: + return 0x1FE6; + case PLAYER_MASK_KAMARO: + return 0x1FE8; + case PLAYER_MASK_STONE: + return 0x1FEA; + case PLAYER_MASK_POSTMAN: + return 0x1FEC; + case PLAYER_MASK_BUNNY: + return 0x1FEE; + case PLAYER_MASK_CAPTAIN: + return 0x1FF0; + case PLAYER_MASK_BREMEN: + return 0x1FF2; + case PLAYER_MASK_CIRCUS_LEADER: + return 0x1FF4; + case PLAYER_MASK_KEATON: + return 0x1FF6; + case PLAYER_MASK_GARO: + return 0x1FF8; + case PLAYER_MASK_ALL_NIGHT: + return 0x1FFA; + case PLAYER_MASK_ROMANI: + return 0x1FFC; + default: + return 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD0830.s") +void func_80AD0998(EnOsn* this) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_1EC].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD08B0.s") + if (this->unk_1EC == 0x12 && curFrame == lastFrame) { + this->unk_1EC = 0x13; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0x13); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD0998.s") +void func_80AD0A24(EnOsn* this) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_1EC].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD0A24.s") + if (this->unk_1EC == 0x15 && curFrame == lastFrame) { + this->unk_1EC = 0x16; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0x16); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD0AB0.s") +void func_80AD0AB0(EnOsn* this) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_1EC].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD0B38.s") + if (curFrame == lastFrame) { + this->unk_1FA -= 8; + if (this->unk_1FA < 8) { + this->unk_1FA = 0; + Actor_MarkForDeath(&this->actor); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD0E10.s") +s32 func_80AD0B38(EnOsn* this, GlobalContext* globalCtx) { + switch (Player_GetMask(globalCtx)) { + case PLAYER_MASK_GREAT_FAIRY: + if (!(this->unk_1F6 & 1)) { + this->unk_1F6 |= 1; + return 0x1FD1; + } + break; + case PLAYER_MASK_GIBDO: + if (!(this->unk_1F6 & 2)) { + this->unk_1F6 |= 2; + return 0x1FD1; + } + break; + case PLAYER_MASK_TRUTH: + if (!(this->unk_1F6 & 4)) { + this->unk_1F6 |= 4; + return 0x1FD1; + } + break; + case PLAYER_MASK_GIANT: + if (!(this->unk_1F6 & 8)) { + this->unk_1F6 |= 8; + return 0x1FD1; + } + break; + case PLAYER_MASK_KAFEIS_MASK: + if (!(this->unk_1F6 & 0x10)) { + this->unk_1F6 |= 0x10; + return 0x1FD1; + } + break; + case PLAYER_MASK_DON_GERO: + if (!(this->unk_1F6 & 0x20)) { + this->unk_1F6 |= 0x20; + return 0x1FD1; + } + break; + case PLAYER_MASK_BLAST: + if (!(this->unk_1F6 & 0x40)) { + this->unk_1F6 |= 0x40; + return 0x1FD1; + } + break; + case PLAYER_MASK_COUPLE: + if (!(this->unk_1F6 & 0x80)) { + this->unk_1F6 |= 0x80; + return 0x1FD1; + } + break; + case PLAYER_MASK_SCENTS: + if (!(this->unk_1F6 & 0x100)) { + this->unk_1F6 |= 0x100; + return 0x1FD1; + } + break; + case PLAYER_MASK_KAMARO: + if (!(this->unk_1F6 & 0x200)) { + this->unk_1F6 |= 0x200; + return 0x1FD1; + } + break; + case PLAYER_MASK_STONE: + if (!(this->unk_1F6 & 0x400)) { + this->unk_1F6 |= 0x400; + return 0x1FD1; + } + break; + case PLAYER_MASK_POSTMAN: + if (!(this->unk_1F6 & 0x800)) { + this->unk_1F6 |= 0x800; + return 0x1FD2; + } + break; + case PLAYER_MASK_BUNNY: + if (!(this->unk_1F6 & 0x1000)) { + this->unk_1F6 |= 0x1000; + return 0x1FD2; + } + break; + case PLAYER_MASK_CAPTAIN: + if (!(this->unk_1F6 & 0x2000)) { + this->unk_1F6 |= 0x2000; + return 0x1FD1; + } + break; + case PLAYER_MASK_BREMEN: + if (!(this->unk_1F6 & 0x4000)) { + this->unk_1F6 |= 0x4000; + return 0x1FD1; + } + break; + case PLAYER_MASK_CIRCUS_LEADER: + if (!(this->unk_1F6 & 0x8000)) { + this->unk_1F6 |= 0x8000; + return 0x1FD1; + } + break; + case PLAYER_MASK_KEATON: + if (!(this->unk_1F6 & 0x10000)) { + this->unk_1F6 |= 0x10000; + return 0x1FD1; + } + break; + case PLAYER_MASK_GARO: + if (!(this->unk_1F6 & 0x20000)) { + this->unk_1F6 |= 0x20000; + return 0x1FD1; + } + break; + case PLAYER_MASK_ALL_NIGHT: + if (!(this->unk_1F6 & 0x40000)) { + this->unk_1F6 |= 0x40000; + return 0x1FD1; + } + break; + case PLAYER_MASK_ROMANI: + if (!(this->unk_1F6 & 0x80000)) { + this->unk_1F6 |= 0x80000; + return 0x1FD1; + } + break; + default: + break; + } + this->unk_1EA |= 0x20; + if (gSaveContext.day == 3 && gSaveContext.time >= CLOCK_TIME(5, 0) && gSaveContext.time < CLOCK_TIME(6, 0)) { + return 0x2006; + } + return 0x1FCD; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD10FC.s") +s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD1398.s") + if ((gSaveContext.inventory.items[SLOT_OCARINA] != ITEM_NONE) && CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { + if (this->unk_1EA & 1) { + this->unk_1EA |= 0x20; + if ((gSaveContext.inventory.items[SLOT_OCARINA] != ITEM_NONE) && + (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { + if ((gSaveContext.day == 3) && (gSaveContext.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.time < CLOCK_TIME(6, 0))) { + return 0x2006; + } + return 0x1FCD; + } + return 0x1FAF; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD144C.s") + if (player->transformation == PLAYER_FORM_DEKU) { + if (this->unk_1EA & 4) { + this->unk_1EA |= 0x20; + if ((gSaveContext.day == 3) && (gSaveContext.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.time < CLOCK_TIME(6, 0))) { + return 0x2006; + } + return 0x1FCD; + } + this->unk_1EA |= 4; + return 0x1FC8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD14C8.s") + if (player->transformation == PLAYER_FORM_GORON) { + if (this->unk_1EA & 8) { + this->unk_1EA |= 0x20; + if ((gSaveContext.day == 3) && (gSaveContext.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.time < CLOCK_TIME(6, 0))) { + return 0x2006; + } + return 0x1FCD; + } + this->unk_1EA |= 8; + if (gSaveContext.weekEventReg[0x4C] & 0x20) { + return 0x1FC8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD1634.s") + gSaveContext.weekEventReg[0x4C] |= 0x20; + return 0x1FCE; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD16A8.s") + if (player->transformation == PLAYER_FORM_ZORA) { + if (this->unk_1EA & 0x10) { + this->unk_1EA |= 0x20; + if ((gSaveContext.day == 3) && (gSaveContext.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.time < CLOCK_TIME(6, 0))) { + return 0x2006; + } + return 0x1FCD; + } + this->unk_1EA |= 0x10; + if (gSaveContext.weekEventReg[0x4C] & 0x40) { + return 0x1FC8; + } + gSaveContext.weekEventReg[0x4C] |= 0x40; + return 0x1FD0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD19A0.s") + if (Player_GetMask(globalCtx) == PLAYER_MASK_NONE) { + if (this->unk_1EA & 2) { + this->unk_1EA |= 0x20; + if ((gSaveContext.day == 3) && (gSaveContext.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.time < CLOCK_TIME(6, 0))) { + return 0x2006; + } + return 0x1FCD; + } + this->unk_1EA |= 2; + return 0x1FC8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD1A4C.s") + return func_80AD0B38(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/EnOsn_Init.s") + this->unk_1EA |= 0x20; + if ((gSaveContext.day == 3) && (gSaveContext.time >= CLOCK_TIME(5, 0)) && (gSaveContext.time < CLOCK_TIME(6, 0))) { + return 0x2004; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/EnOsn_Destroy.s") + return 0x1FAE; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/EnOsn_Update.s") +void func_80AD10FC(EnOsn* this, GlobalContext* globalCtx) { + switch (this->unk_1F4) { + case 0x1FC8: + this->unk_1F4 = 0x1FC9; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD1DA8.s") + case 0x1FC9: + this->unk_1F4 = 0x1FCA; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD1E28.s") + case 0x1FCA: + if ((gSaveContext.day == 3 && gSaveContext.time >= CLOCK_TIME(5, 0)) && + gSaveContext.time < CLOCK_TIME(6, 0)) { + this->unk_1F4 = 0x2007; + } else { + this->unk_1F4 = 0x1FCB; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/EnOsn_Draw.s") + case 0x1FCB: + case 0x2007: + this->unk_1F4 = 0x1FCC; + this->unk_1EA |= 0x20; + break; + + case 0x1FCE: + case 0x1FD0: + this->unk_1F4 = 0x1FCF; + break; + + case 0x1FCF: + this->unk_1F4 = 0x1FCA; + break; + + case 0x1FD1: + case 0x1FD2: + this->unk_1F4 = func_80AD08B0(globalCtx); + break; + + case 0x1FD6: + this->unk_1F4 = 0x1FD7; + break; + + case 0x1FD8: + this->unk_1F4 = 0x1FD9; + break; + + case 0x1FDA: + this->unk_1F4 = 0x1FDB; + break; + + case 0x1FDC: + this->unk_1F4 = 0x1FDD; + break; + + case 0x1FDE: + this->unk_1F4 = 0x1FDF; + break; + + case 0x1FE0: + this->unk_1F4 = 0x1FE1; + break; + + case 0x1FE2: + this->unk_1F4 = 0x1FE3; + break; + + case 0x1FE4: + this->unk_1F4 = 0x1FE5; + break; + + case 0x1FE6: + this->unk_1F4 = 0x1FE7; + break; + + case 0x1FE8: + this->unk_1F4 = 0x1FE9; + break; + + case 0x1FEA: + this->unk_1F4 = 0x1FEB; + break; + + case 0x1FEC: + this->unk_1F4 = 0x1FED; + break; + + case 0x1FEE: + this->unk_1F4 = 0x1FEF; + break; + + case 0x1FF0: + this->unk_1F4 = 0x1FF1; + break; + + case 0x1FF2: + this->unk_1F4 = 0x1FF3; + break; + + case 0x1FF4: + this->unk_1F4 = 0x1FF5; + break; + + case 0x1FF6: + this->unk_1F4 = 0x1FF7; + break; + + case 0x1FF8: + this->unk_1F4 = 0x1FF9; + break; + + case 0x1FFA: + this->unk_1F4 = 0x1FFB; + break; + + case 0x1FFC: + this->unk_1F4 = 0x1FFD; + break; + + case 0x1FD7: + case 0x1FDB: + case 0x1FDD: + case 0x1FDF: + case 0x1FE1: + case 0x1FE7: + case 0x1FF1: + case 0x1FF3: + case 0x1FF7: + case 0x1FF9: + case 0x1FFB: + this->unk_1F4 = 0x1FD3; + break; + + case 0x1FD9: + case 0x1FE3: + case 0x1FE9: + case 0x1FEB: + case 0x1FED: + case 0x1FEF: + case 0x1FF5: + case 0x1FFD: + this->unk_1F4 = 0x1FD4; + break; + + case 0x1FE5: + this->unk_1F4 = 0x1FFE; + break; + + case 0x1FD3: + case 0x1FD4: + case 0x1FFE: + this->unk_1F4 = 0x1FD5; + this->unk_1EA |= 0x20; + } + + func_801518B0(globalCtx, this->unk_1F4, &this->actor); +} + +void func_80AD1398(EnOsn* this) { + this->cutscene = this->actor.cutscene; + if ((gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) || (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { + this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); + + if ((gSaveContext.inventory.items[SLOT_OCARINA] != ITEM_NONE) || + (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { + this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); + } + } +} + +void func_80AD144C(EnOsn* this, GlobalContext* globalCtx) { + u32 sp1C = Flags_GetSwitch(globalCtx, 0); + this->cutscene = this->actor.cutscene; + + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + if (sp1C == 0) { + this->actionFunc = func_80AD16A8; + } else { + this->actionFunc = func_80AD14C8; + } +} + +void func_80AD14C8(EnOsn* this, GlobalContext* globalCtx) { + s16 temp_v1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + + if (gSaveContext.inventory.items[SLOT_OCARINA] != ITEM_NONE && !CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80AD1634; + } else if ((((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && (temp_v1 < 0x4000)) && + (temp_v1 > -0x4000)) { + func_800B863C(&this->actor, globalCtx); + this->actor.textId = 0xFFFF; + } + } else { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_1F4 = func_80AD0E10(this, globalCtx); + func_801518B0(globalCtx, this->unk_1F4, &this->actor); + this->actionFunc = func_80AD19A0; + } else if ((((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && (temp_v1 < 0x4000)) && + (temp_v1 > -0x4000)) { + func_800B863C(&this->actor, globalCtx); + } + } +} + +void func_80AD1634(EnOsn* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->cutscene)) { + ActorCutscene_Start(this->cutscene, &this->actor); + this->actionFunc = func_80AD16A8; + return; + } + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->cutscene); +} + +void func_80AD16A8(EnOsn* this, GlobalContext* globalCtx) { + u8 pad; + u32 temp_v0; + + if (func_800EE29C(globalCtx, 0x82)) { + temp_v0 = func_800EE200(globalCtx, 0x82); + this->unk_1F0 = 0; + if (this->unk_1ED != globalCtx->csCtx.npcActions[temp_v0]->unk0) { + this->unk_1ED = globalCtx->csCtx.npcActions[temp_v0]->unk0; + switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + case 1: + this->unk_1EC = 2; + break; + case 2: + this->unk_1EC = 1; + break; + case 3: + this->unk_1EC = 7; + break; + case 4: + this->unk_1EC = 3; + break; + case 5: + this->unk_1EC = 6; + break; + case 6: + this->unk_1EC = 5; + break; + case 7: + this->unk_1EC = 4; + break; + case 8: + this->unk_1EC = 0; + break; + case 10: + this->unk_1EC = 8; + break; + case 11: + this->unk_1EC = 9; + break; + case 13: + this->unk_1EC = 0xA; + break; + case 15: + this->unk_1EC = 0xB; + break; + case 16: + this->unk_1EC = 0xC; + break; + case 17: + this->unk_1EC = 0xD; + break; + case 18: + this->unk_1EC = 0xE; + break; + case 19: + this->unk_1EC = 0x11; + break; + case 20: + this->unk_1EC = 0x12; + break; + case 21: + this->unk_1EC = 0x14; + break; + case 22: + this->unk_1EC = 0x15; + break; + case 23: + this->unk_1EC = 0x17; + break; + case 24: + this->unk_1EC = 0x18; + break; + default: + this->unk_1EC = 0; + break; + } + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_1EC); + } + + if ((this->unk_1EC == 5) && (globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0xB) && + (globalCtx->csCtx.frames == 400)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_OMVO00); + } + if (this->unk_1EC == 0x12) { + func_80AD0998(this); + } + if (this->unk_1EC == 0x15) { + func_80AD0A24(this); + } + if (this->unk_1EC == 0x18) { + func_80AD0AB0(this); + } + if ((this->unk_1EC == 0x14) && + (((Animation_OnFrame(&this->skelAnime, 17.0f))) || (Animation_OnFrame(&this->skelAnime, 27.0f)) || + (Animation_OnFrame(&this->skelAnime, 37.0f)) || (Animation_OnFrame(&this->skelAnime, 47.0f)) || + (Animation_OnFrame(&this->skelAnime, 57.0f)) || (Animation_OnFrame(&this->skelAnime, 67.0f)))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OMENYA_WALK); + } + func_800EDF24(&this->actor, globalCtx, temp_v0); + } else { + this->unk_1F0 = 1; + this->unk_1ED = 0x63; + func_80AD144C(this, globalCtx); + } +} + +void func_80AD19A0(EnOsn* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if ((temp_v0 == 6 || temp_v0 == 5) && func_80147624(globalCtx)) { + if (this->unk_1EA & 0x20) { + this->unk_1EA &= ~0x20; + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_80AD14C8; + } else { + func_80AD10FC(this, globalCtx); + } + } +} + +void EnOsn_Idle(EnOsn* this, GlobalContext* globalCtx) { +} + +void EnOsn_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnOsn* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_osn_Skel_0202F0, &object_osn_Anim_0201BC, 0, 0, 0); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->unk_1FA = 255; + switch (ENOSN_GET_3(&this->actor)) { + case 0: + if (((gSaveContext.entranceIndex == 0xC020) || (gSaveContext.entranceIndex == 0xC030)) || + (gSaveContext.entranceIndex == 0xC060)) { + this->unk_1EA |= 1; + } + this->unk_1F0 = 1; + if (globalCtx->sceneNum == SCENE_INSIDETOWER) { + if ((gSaveContext.entranceIndex == 0xC020) || (gSaveContext.entranceIndex == 0xC060)) { + this->actionFunc = func_80AD16A8; + return; + } + if (gSaveContext.entranceIndex == 0xC030) { + func_80AD1398(this); + this->actionFunc = func_80AD1634; + return; + } + func_80AD144C(this, globalCtx); + return; + } + func_80AD144C(this, globalCtx); + break; + + case 1: + this->unk_1EC = 0xF; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_1EC); + this->actionFunc = EnOsn_Idle; + break; + + case 2: + this->unk_1EC = 0x10; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_1EC); + this->actionFunc = EnOsn_Idle; + break; + + case 3: + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = func_80AD16A8; + break; + + default: + Actor_MarkForDeath(&this->actor); + } +} + +void EnOsn_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnOsn* this = THIS; + + SkelAnime_Free(&this->skelAnime, globalCtx); + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnOsn_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnOsn* this = THIS; + u32 sp34; + + sp34 = Flags_GetSwitch(globalCtx, 0); + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + SkelAnime_Update(&this->skelAnime); + if (!(ENOSN_GET_3(&this->actor))) { + if (sp34 != 0) { + this->actor.flags |= ACTOR_FLAG_1; + func_80AD0830(this, globalCtx); + this->actor.draw = EnOsn_Draw; + } else { + this->actor.draw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + } + } + func_800E9250(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); +} + +s32 EnOsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnOsn* this = (EnOsn*)thisx; + + if (this->unk_1F0 && limbIndex == 11) { + Matrix_InsertXRotation_s(this->unk_1D8.y, MTXMODE_APPLY); + } + if ((this->unk_1EC == 9 || this->unk_1EC == 8) && limbIndex == 10) { + *dList = NULL; + } + return false; +} + +void EnOsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnOsn* this = (EnOsn*)thisx; + Vec3f sp30 = { 0.0f, 0.0f, 0.0f }; + Vec3s sp28 = { 0x9920, -0x384, -0x320 }; + + if (limbIndex == 11) { + Matrix_MultiplyVector3fByState(&sp30, &thisx->focus.pos); + } + if (((this->unk_1EC == 17) || (this->unk_1EC == 21) || (this->unk_1EC == 22)) && (limbIndex == 6)) { + Matrix_StatePush(); + Matrix_InsertTranslation(-400.0f, 1100.0f, -200.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(sp28.x, MTXMODE_APPLY); + Matrix_RotateY(sp28.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(sp28.z, MTXMODE_APPLY); + + gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList((*gfx)++, &object_osn_DL_0192A0); + Matrix_StatePop(); + } +} + +void EnOsn_Draw(Actor* thisx, GlobalContext* globalCtx) { + static TexturePtr D_80AD2588 = object_osn_Tex_0166F8; + static TexturePtr D_80AD258C = object_osn_Tex_016EF8; + static TexturePtr D_80AD2590 = object_osn_Tex_0176F8; + static TexturePtr D_80AD2594 = object_osn_Tex_017EF8; + static TexturePtr D_80AD2598 = object_osn_Tex_0182F8; + s32 pad; + EnOsn* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_1FA == 0xFF) { + func_8012C28C(globalCtx->state.gfxCtx); + if ((this->unk_1EC == 0xB) || (this->unk_1EC == 0xC) || (this->unk_1EC == 0x17) || + (globalCtx->msgCtx.unk11F04 == 0x1FCA)) { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD258C)); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2594)); + } else if ((this->unk_1EC == 7) || (this->unk_1EC == 3) || (this->unk_1EC == 0xD)) { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD2590)); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2598)); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD2588)); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2594)); + } + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + Scene_SetRenderModeXlu(globalCtx, 0, 1); + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnOsn_OverrideLimbDraw, EnOsn_PostLimbDraw, + &this->actor, POLY_OPA_DISP); + } else { + func_8012C2DC(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD2588)); + gSPSegment(POLY_XLU_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2594)); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->unk_1FA); + Scene_SetRenderModeXlu(globalCtx, 1, 2); + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnOsn_OverrideLimbDraw, EnOsn_PostLimbDraw, + &this->actor, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.h b/src/overlays/actors/ovl_En_Osn/z_en_osn.h index 112a73e47..4cb99b925 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.h +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.h @@ -9,11 +9,25 @@ typedef void (*EnOsnActionFunc)(struct EnOsn*, GlobalContext*); typedef struct EnOsn { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0X0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnOsnActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x28]; -} EnOsn; // size = 0x200 + /* 0x01D8 */ Vec3s unk_1D8; + /* 0x01DE */ Vec3s unk_1DE; + /* 0x01E4 */ UNK_TYPE1 unk_1E4[0x6]; + /* 0x01EA */ u16 unk_1EA; + /* 0x01EC */ u8 unk_1EC; + /* 0x01ED */ u8 unk_1ED; + /* 0x01EE */ s16 cutscene; + /* 0x01F0 */ u8 unk_1F0; + /* 0x01F1 */ UNK_TYPE1 unk_1F1[0x3]; + /* 0x01F4 */ u16 unk_1F4; + /* 0x01F6 */ s32 unk_1F6; + /* 0x01FA */ u8 unk_1FA; +} EnOsn; // size = 0x1FB extern const ActorInit En_Osn_InitVars; +#define ENOSN_GET_3(this) ((thisx)->params & 3) + #endif // Z_EN_OSN_H diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 21d895d40..7a918900b 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -12149,12 +12149,12 @@ 0x80AD1634:("func_80AD1634",), 0x80AD16A8:("func_80AD16A8",), 0x80AD19A0:("func_80AD19A0",), - 0x80AD1A4C:("func_80AD1A4C",), + 0x80AD1A4C:("EnOsn_Idle",), 0x80AD1A5C:("EnOsn_Init",), 0x80AD1C88:("EnOsn_Destroy",), 0x80AD1CC8:("EnOsn_Update",), - 0x80AD1DA8:("func_80AD1DA8",), - 0x80AD1E28:("func_80AD1E28",), + 0x80AD1DA8:("EnOsn_OverrideLimbDraw",), + 0x80AD1E28:("EnOsn_PostLimbDraw",), 0x80AD1F88:("EnOsn_Draw",), 0x80AD2B70:("BgCtowerGear_Splash",), 0x80AD2E84:("BgCtowerGear_Init",), From e353f3bb96aa1cb23f27649f992999a210700326 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 19 Feb 2022 11:58:31 -0800 Subject: [PATCH 027/257] Document object_rd, document En_Rd and En_Railgibud, and clean up En_Talk_Gibud (#604) * Document object_rd + use it in rd and railgibud * Move limb enum to rd.h, share it across all redead actors * Copy over head/body rotation and effect documentation from Talk_Gibud to the other two * Minor spacing things in Talk_Gibud * Import tons of symbols from Talk_Gibud into Railgibud * Always set actionFunc last in Setup functions * Document the isInvincible struct var (thanks kz) * More railgibud struct documentation * Cutscene-related struct names * Damage effect enum for Railgibud * Damage effect enum for Rd * Use the UpdateDamage name that everyone else uses * Grab/Type enums in Railgibud * Document EnRailgibud_MoveGrabbedPlayerAwayFromWall * Document EnRailgibud_PlayerInRangeWithCorrectState * Document EnRailgibud_PlayerOutOfRange * Document path stuff in Railgibud * More Railgibud junk * Enum for animations * Minor documentation on effect stuff * Document Railgibud sink into ground * Document most of Railgibud that was left * Clarify one function name * Use player2, since I guess func_800B8E58 takes Player* now * Make Talk_Gibud/Railgibud consistent with each other in style * Name a few Rd functions * Name some dancing functions * Make define for is Redead * Define for if the Redead is frozen * Make most params access use TYPE * Document some Rd types * Document grab fail functions * Port a few more names from other Gibdo actors * More Rd documentation * Document alpha * Document walk to home functions * Document deathTimer in Rd * Some more timers documented * Document damageEffect struct var * Name all functions in Rd * Document unk_3E4 * Document grab stuff * Document mourning state * Document action states * Name all remaining variables * Document remaining EnRdType * Document all types of Redead * Use ACTOR_FLAGs * Verbose player stateflags * CheckCollision -> UpdateCollision * Try to explain what makes Rd different from the others better * Last changes before PR * Move the limb enum to the object * Remove unnecessary includes from the .c files * Format after sync --- assets/xml/objects/object_rd.xml | 220 ++-- .../actors/ovl_En_Railgibud/z_en_railgibud.c | 1070 +++++++++------- .../actors/ovl_En_Railgibud/z_en_railgibud.h | 68 +- src/overlays/actors/ovl_En_Rd/z_en_rd.c | 1132 +++++++++-------- src/overlays/actors/ovl_En_Rd/z_en_rd.h | 96 +- .../ovl_En_Talk_Gibud/z_en_talk_gibud.c | 269 ++-- .../ovl_En_Talk_Gibud/z_en_talk_gibud.h | 60 +- tools/disasm/functions.txt | 186 +-- 8 files changed, 1680 insertions(+), 1421 deletions(-) diff --git a/assets/xml/objects/object_rd.xml b/assets/xml/objects/object_rd.xml index d9087282a..854ded388 100644 --- a/assets/xml/objects/object_rd.xml +++ b/assets/xml/objects/object_rd.xml @@ -1,114 +1,114 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 6738c44ab..afff2ddb0 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -7,7 +7,7 @@ #include "z_en_railgibud.h" #include "objects/object_rd/object_rd.h" -#define FLAGS 0x00000415 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnRailgibud*)thisx) @@ -16,37 +16,71 @@ void EnRailgibud_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRailgibud_Update(Actor* thisx, GlobalContext* globalCtx); void EnRailgibud_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BA57A8(EnRailgibud* this); -void func_80BA57F8(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA59F0(EnRailgibud* this); -void func_80BA5A34(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA5AF0(EnRailgibud* this); -void func_80BA5B64(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA5DBC(EnRailgibud* this); -void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA6054(EnRailgibud* this); -void func_80BA60B0(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA6158(EnRailgibud* this); -void func_80BA61A0(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA6284(EnRailgibud* this); -void func_80BA62D4(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA64AC(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA6604(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA6664(EnRailgibud* this); -void func_80BA66C8(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA6974(GlobalContext* globalCtx, Vec3f* vec, f32 arg2, s32 arg3, s16 arg4, s16 arg5); -void func_80BA6B9C(EnRailgibud* this, GlobalContext* globalCtx); -s32 func_80BA6D10(EnRailgibud* this, GlobalContext* globalCtx); -s32 func_80BA6DAC(EnRailgibud* this, GlobalContext* globalCtx); -s32 func_80BA7088(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA7578(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA7878(Actor* thisx, GlobalContext* globalCtx); -void func_80BA7B6C(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA7C78(EnRailgibud* this); -void func_80BA7CF0(EnRailgibud* this); -void func_80BA7D04(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA7D30(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA8050(Actor* thisx, GlobalContext* globalCtx); +void EnRailgibud_SetupWalkInCircles(EnRailgibud* this); +void EnRailgibud_WalkInCircles(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupAttemptPlayerFreeze(EnRailgibud* this); +void EnRailgibud_AttemptPlayerFreeze(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupWalkToPlayer(EnRailgibud* this); +void EnRailgibud_WalkToPlayer(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupGrab(EnRailgibud* this); +void EnRailgibud_Grab(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupGrabFail(EnRailgibud* this); +void EnRailgibud_GrabFail(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupTurnAwayAndShakeHead(EnRailgibud* this); +void EnRailgibud_TurnAwayAndShakeHead(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupWalkToHome(EnRailgibud* this); +void EnRailgibud_WalkToHome(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_Damage(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_Stunned(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupDead(EnRailgibud* this); +void EnRailgibud_Dead(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SpawnDust(GlobalContext* globalCtx, Vec3f* vec, f32 arg2, s32 arg3, s16 arg4, s16 arg5); +void EnRailgibud_TurnTowardsPlayer(EnRailgibud* this, GlobalContext* globalCtx); +s32 EnRailgibud_PlayerInRangeWithCorrectState(EnRailgibud* this, GlobalContext* globalCtx); +s32 EnRailgibud_PlayerOutOfRange(EnRailgibud* this, GlobalContext* globalCtx); +s32 EnRailgibud_MoveToIdealGrabPositionAndRotation(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_MainGibdo_DeadUpdate(Actor* thisx, GlobalContext* globalCtx); +void EnRailgibud_InitCutsceneGibdo(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_InitActorActionCommand(EnRailgibud* this); +void EnRailgibud_SetupDoNothing(EnRailgibud* this); +void EnRailgibud_DoNothing(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SinkIntoGround(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_Cutscene_Update(Actor* thisx, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ EN_RAILGIBUD_ANIMATION_GRAB_ATTACK, + /* 1 */ EN_RAILGIBUD_ANIMATION_GRAB_END, + /* 2 */ EN_RAILGIBUD_ANIMATION_GRAB_START, + /* 3 */ EN_RAILGIBUD_ANIMATION_LOOK_BACK, + /* 4 */ EN_RAILGIBUD_ANIMATION_CROUCH_WIPING_TEARS, + /* 5 */ EN_RAILGIBUD_ANIMATION_CROUCH_CRYING, + /* 6 */ EN_RAILGIBUD_ANIMATION_DEATH, + /* 7 */ EN_RAILGIBUD_ANIMATION_DAMAGE, + /* 8 */ EN_RAILGIBUD_ANIMATION_CROUCH_END, + /* 9 */ EN_RAILGIBUD_ANIMATION_IDLE, + /* 10 */ EN_RAILGIBUD_ANIMATION_WALK, + /* 11 */ EN_RAILGIBUD_ANIMATION_DANCE_SQUAT, + /* 12 */ EN_RAILGIBUD_ANIMATION_DANCE_PIROUETTE, + /* 13 */ EN_RAILGIBUD_ANIMATION_DANCE_CLAP, + /* 14 */ EN_RAILGIBUD_ANIMATION_CROUCH_END_2, + /* 15 */ EN_RAILGIBUD_ANIMATION_SLUMP_START, + /* 16 */ EN_RAILGIBUD_ANIMATION_SLUMP_LOOP, + /* 17 */ EN_RAILGIBUD_ANIMATION_CONVULSION, + /* 18 */ EN_RAILGIBUD_ANIMATION_ARMS_UP_START, + /* 19 */ EN_RAILGIBUD_ANIMATION_ARMS_UP_LOOP, +} EnRailgibudAnimations; + +typedef enum { + /* 0 */ EN_RAILGIBUD_TYPE_GIBDO, + /* 1 */ EN_RAILGIBUD_TYPE_REDEAD, +} EnRailgibudType; + +typedef enum { + /* 0 */ EN_RAILGIBUD_GRAB_START, + /* 1 */ EN_RAILGIBUD_GRAB_ATTACK, + /* 2 */ EN_RAILGIBUD_GRAB_RELEASE, +} EnRailgibudGrabState; const ActorInit En_Railgibud_InitVars = { ACTOR_EN_RAILGIBUD, @@ -61,26 +95,26 @@ const ActorInit En_Railgibud_InitVars = { }; static AnimationInfo sAnimations[] = { - { &object_rd_Anim_006678, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_rd_Anim_006B08, 0.5f, 0.0f, 0.0f, ANIMMODE_ONCE_INTERP, 0.0f }, - { &object_rd_Anim_006EEC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, - { &object_rd_Anim_0073A4, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, - { &object_rd_Anim_007BBC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, - { &object_rd_Anim_0081A8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_rd_Anim_009298, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, - { &object_rd_Anim_009900, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, - { &object_rd_Anim_00A450, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, - { &object_rd_Anim_00ABE0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_rd_Anim_0113EC, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -8.0f }, - { &object_rd_Anim_01216C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_rd_Anim_0118D8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_rd_Anim_011DB8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_rd_Anim_00A450, 3.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -6.0f }, - { &object_rd_Anim_005DF4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, - { &object_rd_Anim_0061E4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_rd_Anim_001600, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_rd_Anim_0009C4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, - { &object_rd_Anim_000F1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadGrabAttackAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadGrabEndAnim, 0.5f, 0.0f, 0.0f, ANIMMODE_ONCE_INTERP, 0.0f }, + { &gGibdoRedeadGrabStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadWipingTearsAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadSobbingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadDeathAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadDamageAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadStandUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadWalkAnim, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -8.0f }, + { &gGibdoRedeadSquattingDanceAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadPirouetteAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadClappingDanceAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadStandUpAnim, 3.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -6.0f }, + { &gGibdoRedeadSlumpStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadSlumpLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadConvulsionAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadArmsUpStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadArmsUpLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -103,76 +137,98 @@ static ColliderCylinderInit sCylinderInit = { { 20, 70, 0, { 0, 0, 0 } }, }; +typedef enum { + /* 0x0 */ EN_RAILGIBUD_DMGEFF_NONE, // Does not interact with the Gibdo/Redead at all + /* 0x1 */ EN_RAILGIBUD_DMGEFF_STUN, // Stuns without applying any effect + /* 0x2 */ EN_RAILGIBUD_DMGEFF_FIRE_ARROW, // Damages, applies a fire effect, and changes a Gibdo into a Redead + /* 0x4 */ EN_RAILGIBUD_DMGEFF_LIGHT_ARROW = 0x4, // Damages and applies a light effect + /* 0xC */ EN_RAILGIBUD_DMGEFF_ZORA_MAGIC = 0xC, // Stuns and applies an electric effect + /* 0xD */ EN_RAILGIBUD_DMGEFF_RECOIL, // Deals no damage, but displays hit mark and recoil animation + /* 0xE */ EN_RAILGIBUD_DMGEFF_LIGHT_RAY, // Instantly kills a Redead on contact + /* 0xF */ EN_RAILGIBUD_DMGEFF_DAMAGE, // Deals damage and plays the damage animation +} EnRailgibudDamageEffect; + static DamageTable sDamageTable = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(2, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(0, 0xD), - /* Normal arrow */ DMG_ENTRY(0, 0xD), - /* UNK_DMG_0x06 */ DMG_ENTRY(2, 0xF), - /* Hookshot */ DMG_ENTRY(0, 0xD), - /* Goron punch */ DMG_ENTRY(1, 0xF), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(1, 0xF), - /* Fire arrow */ DMG_ENTRY(1, 0x2), - /* Ice arrow */ DMG_ENTRY(0, 0xD), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(0, 0xD), - /* Deku launch */ DMG_ENTRY(2, 0xF), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0xC), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0xE), - /* Thrown object */ DMG_ENTRY(1, 0xF), - /* Zora punch */ DMG_ENTRY(1, 0xF), - /* Spin attack */ DMG_ENTRY(1, 0xF), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0xF), + /* Deku Nut */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(2, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Horse trample */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Zora boomerang */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_RECOIL), + /* Normal arrow */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_RECOIL), + /* UNK_DMG_0x06 */ DMG_ENTRY(2, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Hookshot */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_RECOIL), + /* Goron punch */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Sword */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Goron pound */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Fire arrow */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_FIRE_ARROW), + /* Ice arrow */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_RECOIL), + /* Light arrow */ DMG_ENTRY(2, EN_RAILGIBUD_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Deku spin */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_RECOIL), + /* Deku launch */ DMG_ENTRY(2, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_LIGHT_RAY), + /* Thrown object */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Zora punch */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Spin attack */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Sword beam */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), }; static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_IMMOVABLE }; -void func_80BA5400(EnRailgibud* this, GlobalContext* globalCtx) { - static s32 D_80BA82F8 = 0; - s32 phi_a3; - Vec3f sp70; - Path* path = &globalCtx->setupPathList[ENRAILGIBUD_GET_FF00(&this->actor)]; +/** + * The design behind this actor is that scene files should only spawn a single "main" Gibdo + * who then spawns all the other Gibdos. It spawns enough Gibdos for one to exist on every + * point along the path up to a maximum of nine additional Gibdos (not counting itself). + */ +void EnRailgibud_SpawnOtherGibdosAndSetPositionAndRotation(EnRailgibud* this, GlobalContext* globalCtx) { + static s32 currentGibdoIndex = 0; + s32 nextPoint; + Vec3f targetPos; + Path* path = &globalCtx->setupPathList[ENRAILGIBUD_GET_PATH(&this->actor)]; - this->unk_294 = Lib_SegmentedToVirtual(path->points); - this->unk_298 = D_80BA82F8; - this->unk_29C = path->count; - if (D_80BA82F8 == 0) { + this->points = Lib_SegmentedToVirtual(path->points); + this->currentPoint = currentGibdoIndex; + this->pathCount = path->count; + + // This branch will only be taken for the first, "main" Gibdo. The subsequent + // Gibdos created by Actor_SpawnAsChild will go through this function to set + // their position and rotation, but they will not be able to spawn any more + // Gibdos themselves because currentGibdoIndex will be non-zero. + if (currentGibdoIndex == 0) { s32 i; - for (i = 1; i < this->unk_29C && i < 10; i++) { - D_80BA82F8++; + for (i = 1; i < this->pathCount && i < 10; i++) { + currentGibdoIndex++; Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_RAILGIBUD, 0.0f, 0.0f, 0.0f, 0, 0, 0, this->actor.params); } - D_80BA82F8 = 0; + + currentGibdoIndex = 0; } - this->actor.world.pos.x = this->unk_294[this->unk_298].x; - this->actor.world.pos.y = this->unk_294[this->unk_298].y; - this->actor.world.pos.z = this->unk_294[this->unk_298].z; - if (this->unk_298 < (this->unk_29C - 1)) { - phi_a3 = this->unk_298 + 1; + this->actor.world.pos.x = this->points[this->currentPoint].x; + this->actor.world.pos.y = this->points[this->currentPoint].y; + this->actor.world.pos.z = this->points[this->currentPoint].z; + if (this->currentPoint < (this->pathCount - 1)) { + nextPoint = this->currentPoint + 1; } else { - phi_a3 = 0; + nextPoint = 0; } - sp70.x = this->unk_294[phi_a3].x; - sp70.y = this->unk_294[phi_a3].y; - sp70.z = this->unk_294[phi_a3].z; - this->actor.world.rot.y = this->actor.shape.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &sp70); + targetPos.x = this->points[nextPoint].x; + targetPos.y = this->points[nextPoint].y; + targetPos.z = this->points[nextPoint].z; + this->actor.world.rot.y = this->actor.shape.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &targetPos); this->actor.home = this->actor.world; } @@ -191,26 +247,26 @@ void EnRailgibud_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 0; this->actor.hintId = 0x2D; this->actor.textId = 0; - if (ENRAILGIBUD_GET_80(&this->actor)) { - func_80BA7B6C(this, globalCtx); + if (ENRAILGIBUD_IS_CUTSCENE_TYPE(&this->actor)) { + EnRailgibud_InitCutsceneGibdo(this, globalCtx); return; } - func_80BA5400(this, globalCtx); - this->unk_3F2 = 0; - this->unk_402 = gSaveContext.time; - this->unk_404 = 0; - this->unk_3F8 = 0; + EnRailgibud_SpawnOtherGibdosAndSetPositionAndRotation(this, globalCtx); + this->playerStunWaitTimer = 0; + this->timeInitialized = gSaveContext.time; + this->effectType = 0; + this->type = EN_RAILGIBUD_TYPE_GIBDO; this->textId = 0; - this->unk_3FA = 0; + this->isInvincible = false; if (this->actor.parent == NULL) { - this->unk_3EC = 1; - this->unk_3EE = 1; + this->shouldWalkForward = true; + this->shouldWalkForwardNextFrame = true; } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_0053E8, &object_rd_Anim_00ABE0, this->jointTable, - this->morphTable, 26); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGibdoSkel, &gGibdoRedeadIdleAnim, this->jointTable, + this->morphTable, GIBDO_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -218,7 +274,7 @@ void EnRailgibud_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } - func_80BA57A8(this); + EnRailgibud_SetupWalkInCircles(this); } void EnRailgibud_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -227,63 +283,66 @@ void EnRailgibud_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } -void func_80BA57A8(EnRailgibud* this) { +void EnRailgibud_SetupWalkInCircles(EnRailgibud* this) { this->actor.speedXZ = 0.6f; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); - this->actionFunc = func_80BA57F8; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); + this->actionFunc = EnRailgibud_WalkInCircles; } -void func_80BA57F8(EnRailgibud* this, GlobalContext* globalCtx) { - Vec3f sp3C; +void EnRailgibud_WalkInCircles(EnRailgibud* this, GlobalContext* globalCtx) { + Vec3f targetPos; s32 pad; - s16 sp36; + s16 yRotation; - sp3C.x = this->unk_294[this->unk_298].x; - sp3C.y = this->unk_294[this->unk_298].y; - sp3C.z = this->unk_294[this->unk_298].z; + targetPos.x = this->points[this->currentPoint].x; + targetPos.y = this->points[this->currentPoint].y; + targetPos.z = this->points[this->currentPoint].z; if ((this->actor.xzDistToPlayer <= 100.0f) && func_800B715C(globalCtx) && (Player_GetMask(globalCtx) != PLAYER_MASK_GIBDO)) { this->actor.home = this->actor.world; - func_80BA59F0(this); + EnRailgibud_SetupAttemptPlayerFreeze(this); } - Math_SmoothStepToS(&this->unk_3E2, 0, 1, 0x64, 0); - Math_SmoothStepToS(&this->unk_3E8, 0, 1, 0x64, 0); + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x64, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x64, 0); + // If we're not supposed to walk forward, then stop here; + // don't rotate the Gibdo or move it around. if (this->actor.parent == NULL) { - if (this->unk_3EC != 0) { + if (this->shouldWalkForward) { } else { return; } } else { EnRailgibud* parent = (EnRailgibud*)this->actor.parent; - if (parent->unk_3EC == 0) { + if (!parent->shouldWalkForward) { return; } } - sp36 = Math_Vec3f_Yaw(&this->actor.world.pos, &sp3C); - if (Math_Vec3f_DistXZ(&this->actor.world.pos, &sp3C) > 60.0f) { - Math_SmoothStepToS(&this->actor.world.rot.y, sp36, 1, 0x190, 0xA); + yRotation = Math_Vec3f_Yaw(&this->actor.world.pos, &targetPos); + if (Math_Vec3f_DistXZ(&this->actor.world.pos, &targetPos) > 60.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 1, 0x190, 0xA); this->actor.shape.rot.y = this->actor.world.rot.y; - } else if (this->unk_298 < (this->unk_29C - 1)) { - this->unk_298++; + } else if (this->currentPoint < (this->pathCount - 1)) { + this->currentPoint++; } else { - this->unk_298 = 0; + this->currentPoint = 0; } + Actor_MoveWithGravity(&this->actor); } -void func_80BA59F0(EnRailgibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); - this->actionFunc = func_80BA5A34; +void EnRailgibud_SetupAttemptPlayerFreeze(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_IDLE); + this->actionFunc = EnRailgibud_AttemptPlayerFreeze; } -void func_80BA5A34(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_AttemptPlayerFreeze(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s16 rot = this->actor.shape.rot.y + this->unk_3E2 + this->unk_3E8; + s16 rot = this->actor.shape.rot.y + this->headRotation.y + this->upperBodyRotation.y; s16 yaw = BINANG_SUB(this->actor.yawTowardsPlayer, rot); if (ABS_ALT(yaw) < 0x2008) { @@ -291,105 +350,111 @@ void func_80BA5A34(EnRailgibud* this, GlobalContext* globalCtx) { func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(globalCtx, &this->actor); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); - func_80BA5AF0(this); + EnRailgibud_SetupWalkToPlayer(this); } - func_80BA6B9C(this, globalCtx); + + EnRailgibud_TurnTowardsPlayer(this, globalCtx); } -void func_80BA5AF0(EnRailgibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); +void EnRailgibud_SetupWalkToPlayer(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); this->actor.speedXZ = 0.4f; - if (this->actionFunc == func_80BA5A34) { - this->unk_3F2 = 80; + + if (this->actionFunc == EnRailgibud_AttemptPlayerFreeze) { + this->playerStunWaitTimer = 80; } else { - this->unk_3F2 = 20; + this->playerStunWaitTimer = 20; } - this->actionFunc = func_80BA5B64; + + this->actionFunc = EnRailgibud_WalkToPlayer; } -void func_80BA5B64(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_WalkToPlayer(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad; Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xFA); this->actor.world.rot = this->actor.shape.rot; - Math_SmoothStepToS(&this->unk_3E2, 0, 1, 0x64, 0); - Math_SmoothStepToS(&this->unk_3E8, 0, 1, 0x64, 0); - if (func_80BA6D10(this, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { - if ((this->unk_3F4 == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x64, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x64, 0); + + if (EnRailgibud_PlayerInRangeWithCorrectState(this, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { + if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { player->actor.freezeTimer = 0; if ((gSaveContext.playerForm == PLAYER_FORM_GORON) || (gSaveContext.playerForm == PLAYER_FORM_DEKU)) { - func_80BA6054(this); + // If the Gibdo/Redead tries to grab Goron or Deku Link, it will fail to + // do so. It will appear to take damage and shake its head side-to-side. + EnRailgibud_SetupGrabFail(this); } else if (globalCtx->grabPlayer(globalCtx, player)) { - func_80BA5DBC(this); + EnRailgibud_SetupGrab(this); } } else { - if (this->unk_3F2 == 0) { + if (this->playerStunWaitTimer == 0) { player->actor.freezeTimer = 40; - this->unk_3F2 = 60; + this->playerStunWaitTimer = 60; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(globalCtx, &this->actor); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); } else { - this->unk_3F2--; + this->playerStunWaitTimer--; } } - } else if ((this->unk_3F4 == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { - func_80BA6284(this); - } else if (func_80BA6DAC(this, globalCtx)) { - func_80BA6284(this); + } else if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { + EnRailgibud_SetupWalkToHome(this); + } else if (EnRailgibud_PlayerOutOfRange(this, globalCtx)) { + EnRailgibud_SetupWalkToHome(this); } - if (this->unk_3F4 > 0) { - this->unk_3F4--; + if (this->grabWaitTimer > 0) { + this->grabWaitTimer--; } if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); - } else if ((globalCtx->gameplayFrames & 95) == 0) { + } else if (!(globalCtx->gameplayFrames & 95)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } -void func_80BA5DBC(EnRailgibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - this->actor.flags &= ~1; - this->unk_3F2 = 0; - this->unk_3F0 = 0; - this->actionFunc = func_80BA5E18; +void EnRailgibud_SetupGrab(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_GRAB_START); + this->grabDamageTimer = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + this->grabState = EN_RAILGIBUD_GRAB_START; + this->actionFunc = EnRailgibud_Grab; } -void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_Grab(EnRailgibud* this, GlobalContext* globalCtx) { Player* player2 = GET_PLAYER(globalCtx); Player* player = player2; - s32 sp34; - u16 sp32; + s32 inPositionToAttack; + u16 damageSfxId; - switch (this->unk_3F0) { - case 0: - sp34 = func_80BA7088(this, globalCtx); - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (sp34 == 1)) { - this->unk_3F0 = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + switch (this->grabState) { + case EN_RAILGIBUD_GRAB_START: + inPositionToAttack = EnRailgibud_MoveToIdealGrabPositionAndRotation(this, globalCtx); + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (inPositionToAttack == true)) { + this->grabState = EN_RAILGIBUD_GRAB_ATTACK; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_GRAB_ATTACK); } else if (!(player->stateFlags2 & 0x80)) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); - this->actor.flags |= 1; - this->unk_3F0 = 2; - this->unk_3F2 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_GRAB_END); + this->actor.flags |= ACTOR_FLAG_1; + this->grabState = EN_RAILGIBUD_GRAB_RELEASE; + this->grabDamageTimer = 0; } break; - case 1: - if (this->unk_3F2 == 20) { + case EN_RAILGIBUD_GRAB_ATTACK: + if (this->grabDamageTimer == 20) { s16 requiredScopeTemp; - sp32 = player->ageProperties->unk_92 + 0x6805; + damageSfxId = player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S; globalCtx->damagePlayer(globalCtx, -8); - func_800B8E58(player, sp32); + func_800B8E58(player, damageSfxId); func_8013ECE0(this->actor.xzDistToPlayer, 240, 1, 12); - this->unk_3F2 = 0; + this->grabDamageTimer = 0; } else { - this->unk_3F2++; + this->grabDamageTimer++; } if (Animation_OnFrame(&this->skelAnime, 0.0f)) { @@ -401,18 +466,19 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { player->stateFlags2 &= ~0x80; player->unk_AE8 = 100; } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); - this->actor.flags |= 1; - this->unk_3F0 = 2; - this->unk_3F2 = 0; + + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_GRAB_END); + this->actor.flags |= ACTOR_FLAG_1; + this->grabState = EN_RAILGIBUD_GRAB_RELEASE; + this->grabDamageTimer = 0; } break; - case 2: + case EN_RAILGIBUD_GRAB_RELEASE: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->unk_3F4 = 40; + this->grabWaitTimer = 40; this->actor.shape.yOffset = 0.0f; - func_80BA5AF0(this); + EnRailgibud_SetupWalkToPlayer(this); } else { Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 1.0f, 400.0f, 0.0f); } @@ -420,88 +486,90 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { } } -void func_80BA6054(EnRailgibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); +void EnRailgibud_SetupGrabFail(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->actor.speedXZ = -2.0f; - this->actionFunc = func_80BA60B0; + this->actionFunc = EnRailgibud_GrabFail; } -void func_80BA60B0(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_GrabFail(EnRailgibud* this, GlobalContext* globalCtx) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Math_SmoothStepToS(&this->unk_3E2, 0, 1, 0x12C, 0); - Math_SmoothStepToS(&this->unk_3E8, 0, 1, 0x12C, 0); + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x12C, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x12C, 0); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->actor.world.rot.y = this->actor.shape.rot.y; - func_80BA6158(this); + EnRailgibud_SetupTurnAwayAndShakeHead(this); } } -void func_80BA6158(EnRailgibud* this) { - this->unk_3F2 = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); - this->actionFunc = func_80BA61A0; +void EnRailgibud_SetupTurnAwayAndShakeHead(EnRailgibud* this) { + this->headShakeTimer = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); + this->actionFunc = EnRailgibud_TurnAwayAndShakeHead; } -void func_80BA61A0(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_TurnAwayAndShakeHead(EnRailgibud* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 5, 3500, 200); this->actor.shape.rot.y = this->actor.world.rot.y; - if (this->unk_3F2 > 60) { - func_80BA6284(this); - this->unk_3F2 = 0; + if (this->headShakeTimer > 60) { + EnRailgibud_SetupWalkToHome(this); + this->playerStunWaitTimer = 0; } else { - this->unk_3E2 = Math_SinS(this->unk_3F2 * 0xFA0) * (0x256F * ((60 - this->unk_3F2) / 60.0f)); - this->unk_3F2++; + this->headRotation.y = + Math_SinS(this->headShakeTimer * 4000) * (0x256F * ((60 - this->headShakeTimer) / 60.0f)); + this->headShakeTimer++; } } -void func_80BA6284(EnRailgibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); +void EnRailgibud_SetupWalkToHome(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); this->actor.speedXZ = 0.4f; - this->actionFunc = func_80BA62D4; + this->actionFunc = EnRailgibud_WalkToHome; } -void func_80BA62D4(EnRailgibud* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->unk_3E2, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3E8, 0, 1, 100, 0); +void EnRailgibud_WalkToHome(EnRailgibud* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 100, 0); if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 5.0f) { if (this->actor.speedXZ > 0.2f) { this->actor.speedXZ -= 0.2f; } else { this->actor.speedXZ = 0.0f; } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 200, 10); this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.world.rot.y == this->actor.home.rot.y) { - func_80BA57A8(this); + EnRailgibud_SetupWalkInCircles(this); } } else { Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 450); this->actor.world.rot = this->actor.shape.rot; } - if (func_80BA6D10(this, globalCtx)) { + if (EnRailgibud_PlayerInRangeWithCorrectState(this, globalCtx)) { if ((gSaveContext.playerForm != PLAYER_FORM_GORON) && (gSaveContext.playerForm != PLAYER_FORM_DEKU) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { - func_80BA5AF0(this); + EnRailgibud_SetupWalkToPlayer(this); } } } -void func_80BA6440(EnRailgibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); +void EnRailgibud_SetupDamage(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); - this->unk_3F2 = 0; - this->unk_3F4 = 0; + this->stunTimer = 0; + this->grabWaitTimer = 0; this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.speedXZ = -2.0f; - this->actionFunc = func_80BA64AC; + this->actionFunc = EnRailgibud_Damage; } -void func_80BA64AC(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_Damage(EnRailgibud* this, GlobalContext* globalCtx) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } @@ -509,58 +577,65 @@ void func_80BA64AC(EnRailgibud* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_405 = -1; this->actor.world.rot.y = this->actor.shape.rot.y; - if ((this->unk_3F6 > 0) && (this->unk_404 == 0) && (this->unk_3F8 == 0)) { + if ((this->effectTimer > 0) && (this->effectType == 0) && (this->type == EN_RAILGIBUD_TYPE_GIBDO)) { this->actor.hintId = 0x2A; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_010B88, NULL, this->jointTable, - this->morphTable, 26); - this->unk_3F8 = 1; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, + GIBDO_LIMB_MAX); + this->type = EN_RAILGIBUD_TYPE_REDEAD; } - func_80BA6284(this); + + EnRailgibud_SetupWalkToHome(this); } } -void func_80BA6584(EnRailgibud* this) { +void EnRailgibud_SetupStunned(EnRailgibud* this) { this->actor.world.rot.y = this->actor.shape.rot.y; - this->unk_3F2 = 10; - if (this->unk_3F6 != 0) { + this->stunTimer = 10; + + if (this->effectTimer != 0) { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } else { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } - this->actionFunc = func_80BA6604; + + this->actionFunc = EnRailgibud_Stunned; } -void func_80BA6604(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_Stunned(EnRailgibud* this, GlobalContext* globalCtx) { if (this->actor.colorFilterTimer == 0) { if (this->actor.colChkInfo.health == 0) { - func_80BA6664(this); + EnRailgibud_SetupDead(this); } else { - func_80BA6440(this); + EnRailgibud_SetupDamage(this); } } - if (this->unk_3F2 != 0) { - this->unk_3F2--; + if (this->stunTimer != 0) { + this->stunTimer--; } } -void func_80BA6664(EnRailgibud* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); - this->actor.flags &= ~1; +void EnRailgibud_SetupDead(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_DEATH); + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); - this->unk_3F2 = 0; - this->actionFunc = func_80BA66C8; + this->deathTimer = 0; + this->actionFunc = EnRailgibud_Dead; } -void func_80BA66C8(EnRailgibud* this, GlobalContext* globalCtx) { - if (this->unk_3F2 > 300) { +void EnRailgibud_Dead(EnRailgibud* this, GlobalContext* globalCtx) { + if (this->deathTimer > 300) { if (this->actor.shape.shadowAlpha == 0) { if (this->actor.parent != NULL) { Actor_MarkForDeath(&this->actor); } else { + // Don't delete the "main" Gibdo, since that will break the surviving + // Gibdos' ability to start and stop walking forward. Instead, just + // stop drawing it, and make its Update function only check to see if + // the Gibdos should move forward. this->actor.draw = NULL; - this->actor.flags &= ~1; - this->actor.update = func_80BA7878; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.update = EnRailgibud_MainGibdo_DeadUpdate; } } else { this->actor.shape.shadowAlpha -= 5; @@ -569,107 +644,124 @@ void func_80BA66C8(EnRailgibud* this, GlobalContext* globalCtx) { } } } else { - Math_SmoothStepToS(&this->unk_3E2, 0, 1, 250, 0); - Math_SmoothStepToS(&this->unk_3E8, 0, 1, 250, 0); - this->unk_3F2++; + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 250, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 250, 0); + this->deathTimer++; } - if ((this->unk_3F2 == 20) && (this->unk_3F6 > 0) && (this->unk_404 == 0) && (this->unk_3F8 == 0)) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_010B88, NULL, this->jointTable, - this->morphTable, 26); - this->unk_3F8 = 1; + if ((this->deathTimer == 20) && (this->effectTimer > 0) && (this->effectType == 0) && + (this->type == EN_RAILGIBUD_TYPE_GIBDO)) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, + GIBDO_LIMB_MAX); + this->type = EN_RAILGIBUD_TYPE_REDEAD; } } -void func_80BA6800(EnRailgibud* this, GlobalContext* globalCtx, s32 arg2) { - Vec3f sp5C = this->actor.world.pos; - Vec3f sp50 = { 0.0f, 8.0f, 0.0f }; - Vec3f sp44 = { 0.0f, -1.5f, 0.0f }; +void EnRailgibud_SpawnEffectsForSinkingIntoTheGround(EnRailgibud* this, GlobalContext* globalCtx, s32 arg2) { + Vec3f rockFragmentPos = this->actor.world.pos; + Vec3f rockFragmentVelocity = { 0.0f, 8.0f, 0.0f }; + Vec3f rockFragmentAccel = { 0.0f, -1.5f, 0.0f }; s16 rand; s32 pad; if ((globalCtx->gameplayFrames & arg2) == 0) { rand = Rand_Next(); - sp5C.x += 15.0f * Math_SinS(rand); - sp5C.z += 15.0f * Math_CosS(rand); - sp44.x = Rand_Centered(); - sp44.z = Rand_Centered(); - sp50.y += Rand_Centered() * 4.0f; - EffectSsHahen_Spawn(globalCtx, &sp5C, &sp50, &sp44, 0, (Rand_Next() & 7) + 10, -1, 10, NULL); - func_80BA6974(globalCtx, &sp5C, 10.0f, 10, 150, 0); + rockFragmentPos.x += 15.0f * Math_SinS(rand); + rockFragmentPos.z += 15.0f * Math_CosS(rand); + rockFragmentAccel.x = Rand_Centered(); + rockFragmentAccel.z = Rand_Centered(); + rockFragmentVelocity.y += Rand_Centered() * 4.0f; + EffectSsHahen_Spawn(globalCtx, &rockFragmentPos, &rockFragmentVelocity, &rockFragmentAccel, 0, + (Rand_Next() & 7) + 10, -1, 10, NULL); + EnRailgibud_SpawnDust(globalCtx, &rockFragmentPos, 10.0f, 10, 150, 0); } } -void func_80BA6974(GlobalContext* globalCtx, Vec3f* vec, f32 arg2, s32 arg3, s16 arg4, s16 arg5) { - Vec3f sp8C; - Vec3f sp80 = { 0.0f, 0.3f, 0.0f }; - Vec3f sp74 = gZeroVec3f; +void EnRailgibud_SpawnDust(GlobalContext* globalCtx, Vec3f* basePos, f32 randomnessScale, s32 dustCount, s16 dustScale, + s16 scaleStep) { + Vec3f dustPos; + Vec3f dustAccel = { 0.0f, 0.3f, 0.0f }; + Vec3f dustVelocity = gZeroVec3f; s32 i; s32 pad; - sp74.y = 2.5f; + dustVelocity.y = 2.5f; - for (i = arg3; i >= 0; i--) { - sp74.x = (Rand_ZeroOne() - 0.5f) * arg2; - sp74.z = (Rand_ZeroOne() - 0.5f) * arg2; + for (i = dustCount; i >= 0; i--) { + dustVelocity.x = (Rand_ZeroOne() - 0.5f) * randomnessScale; + dustVelocity.z = (Rand_ZeroOne() - 0.5f) * randomnessScale; - sp8C.x = vec->x + sp74.x; - sp8C.y = ((Rand_ZeroOne() - 0.5f) * arg2) + vec->y; - sp8C.z = vec->z + sp74.z; + dustPos.x = basePos->x + dustVelocity.x; + dustPos.y = ((Rand_ZeroOne() - 0.5f) * randomnessScale) + basePos->y; + dustPos.z = basePos->z + dustVelocity.z; - sp74.x *= 0.5f; - sp74.z *= 0.5f; - func_800B1210(globalCtx, &sp8C, &sp74, &sp80, (s16)(Rand_ZeroOne() * arg4 * 0.2f) + arg4, arg5); + dustVelocity.x *= 0.5f; + dustVelocity.z *= 0.5f; + func_800B1210(globalCtx, &dustPos, &dustVelocity, &dustAccel, + (s16)(Rand_ZeroOne() * dustScale * 0.2f) + dustScale, scaleStep); } } -void func_80BA6B30(EnRailgibud* this) { +/** + * If any Gibdo in the ring of Gibdos is doing any other action besides walking in + * circles or being dead, then this function will update the "main" Gibdo's + * walking forward variables such that all Gibdos in the ring will stop moving. + * Similarly, this will make all Gibdos in the ring start walking forward again + * if the Gibdos are all performing the appropriate action. + */ +void EnRailgibud_UpdateWalkForwardState(EnRailgibud* this) { if (this->actor.parent == NULL) { - this->unk_3EC = this->unk_3EE; - this->unk_3EE = 1; - if ((this->actionFunc != func_80BA57F8) && (this->actionFunc != func_80BA66C8)) { - this->unk_3EE = 0; + this->shouldWalkForward = this->shouldWalkForwardNextFrame; + this->shouldWalkForwardNextFrame = true; + if ((this->actionFunc != EnRailgibud_WalkInCircles) && (this->actionFunc != EnRailgibud_Dead)) { + this->shouldWalkForwardNextFrame = false; } - } else if ((this->actionFunc != func_80BA57F8) && (this->actionFunc != func_80BA66C8)) { - ((EnRailgibud*)this->actor.parent)->unk_3EE = 0; + } else if ((this->actionFunc != EnRailgibud_WalkInCircles) && (this->actionFunc != EnRailgibud_Dead)) { + ((EnRailgibud*)this->actor.parent)->shouldWalkForwardNextFrame = false; } } -void func_80BA6B9C(EnRailgibud* this, GlobalContext* globalCtx) { - s16 temp_v0 = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_3E8; - s16 phi_a2 = CLAMP(temp_v0, -500, 500); +void EnRailgibud_TurnTowardsPlayer(EnRailgibud* this, GlobalContext* globalCtx) { + s16 headAngle = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->upperBodyRotation.y; + s16 upperBodyAngle = CLAMP(headAngle, -500, 500); - temp_v0 -= this->unk_3E2; - temp_v0 = CLAMP(temp_v0, -500, 500); + headAngle -= this->headRotation.y; + headAngle = CLAMP(headAngle, -500, 500); if (BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y) >= 0) { - this->unk_3E8 += ABS_ALT(phi_a2); - this->unk_3E2 += ABS_ALT(temp_v0); + this->upperBodyRotation.y += ABS_ALT(upperBodyAngle); + this->headRotation.y += ABS_ALT(headAngle); } else { - this->unk_3E8 -= ABS_ALT(phi_a2); - this->unk_3E2 -= ABS_ALT(temp_v0); + this->upperBodyRotation.y -= ABS_ALT(upperBodyAngle); + this->headRotation.y -= ABS_ALT(headAngle); } - this->unk_3E8 = CLAMP(this->unk_3E8, -0x495F, 0x495F); - this->unk_3E2 = CLAMP(this->unk_3E2, -0x256F, 0x256F); + this->upperBodyRotation.y = CLAMP(this->upperBodyRotation.y, -0x495F, 0x495F); + this->headRotation.y = CLAMP(this->headRotation.y, -0x256F, 0x256F); } -s32 func_80BA6D10(EnRailgibud* this, GlobalContext* globalCtx) { +s32 EnRailgibud_PlayerInRangeWithCorrectState(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { return false; } - if ((Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 100.0f) && !(player->stateFlags1 & 0x2C6080) && - !(player->stateFlags2 & 0x4080)) { + if ((Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 100.0f) && + !(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && + !(player->stateFlags2 & (0x4000 | 0x80))) { return true; } return false; } -s32 func_80BA6DAC(EnRailgibud* this, GlobalContext* globalCtx) { +/** + * Gibdos/Redeads have a very short range around their home where they will + * engage with the player. If the player is out of this range, they will simply + * walk back to their home. + */ +s32 EnRailgibud_PlayerOutOfRange(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 100.0f) { @@ -679,181 +771,197 @@ s32 func_80BA6DAC(EnRailgibud* this, GlobalContext* globalCtx) { return false; } -void func_80BA6DF8(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_UpdateDamage(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((this->unk_3FA != 1) && (this->collider.base.acFlags & AC_HIT)) { - if (this->actionFunc == func_80BA57F8) { + if ((this->isInvincible != true) && (this->collider.base.acFlags & AC_HIT)) { + if (this->actionFunc == EnRailgibud_WalkInCircles) { this->actor.home = this->actor.world; } this->collider.base.acFlags &= ~AC_HIT; Actor_ApplyDamage(&this->actor); switch (this->actor.colChkInfo.damageEffect) { - case 15: + case EN_RAILGIBUD_DMGEFF_DAMAGE: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (player->unk_ADC != 0) { this->unk_405 = player->unk_ADD; } this->actor.shape.yOffset = 0.0f; if (this->actor.colChkInfo.health == 0) { - func_80BA6664(this); + EnRailgibud_SetupDead(this); } else { - func_80BA6440(this); + EnRailgibud_SetupDamage(this); } break; - case 14: - if (this->unk_3F8 == 1) { + case EN_RAILGIBUD_DMGEFF_LIGHT_RAY: + if (this->type == EN_RAILGIBUD_TYPE_REDEAD) { this->actor.colChkInfo.health = 0; this->actor.shape.yOffset = 0.0f; - func_80BA6664(this); + EnRailgibud_SetupDead(this); } break; - case 2: + case EN_RAILGIBUD_DMGEFF_FIRE_ARROW: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (this->actor.colChkInfo.health == 0) { - func_80BA6664(this); + EnRailgibud_SetupDead(this); } else { - func_80BA6440(this); + EnRailgibud_SetupDamage(this); } - this->unk_404 = 0; - this->unk_3F6 = 180; - this->unk_2A0 = 1.0f; + this->effectType = 0; + this->effectTimer = 180; + this->effectAlpha = 1.0f; break; - case 4: + case EN_RAILGIBUD_DMGEFF_LIGHT_ARROW: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (this->actor.colChkInfo.health == 0) { - func_80BA6664(this); + EnRailgibud_SetupDead(this); } else { - func_80BA6440(this); + EnRailgibud_SetupDamage(this); } - this->unk_404 = 20; - this->unk_3F6 = 60; - this->unk_2A0 = 1.0f; + this->effectType = 20; + this->effectTimer = 60; + this->effectAlpha = 1.0f; break; - case 12: - if ((this->actionFunc != func_80BA5E18) && - ((this->actionFunc != func_80BA6604) || (this->unk_3F2 == 0))) { - this->unk_404 = 30; - this->unk_3F6 = 40; - this->unk_2A0 = 1.0f; - func_80BA6584(this); + case EN_RAILGIBUD_DMGEFF_ZORA_MAGIC: + if ((this->actionFunc != EnRailgibud_Grab) && + ((this->actionFunc != EnRailgibud_Stunned) || (this->stunTimer == 0))) { + this->effectType = 30; + this->effectTimer = 40; + this->effectAlpha = 1.0f; + EnRailgibud_SetupStunned(this); } break; - case 1: - if ((this->actionFunc != func_80BA6604) || (this->unk_3F2 == 0)) { - func_80BA6584(this); + case EN_RAILGIBUD_DMGEFF_STUN: + if ((this->actionFunc != EnRailgibud_Stunned) || (this->stunTimer == 0)) { + EnRailgibud_SetupStunned(this); } break; } } } -s32 func_80BA7088(EnRailgibud* this, GlobalContext* globalCtx) { +/** + * Returns true if the Gibdo is in the correct position and rotation to start + * performing its grab attack. Regardless of what this returns, the Gibdo is + * moved closer to this ideal position and rotation. + */ +s32 EnRailgibud_MoveToIdealGrabPositionAndRotation(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f sp40; - f32 sp3C; - f32 sp38 = 0.0f; - s16 temp_s0_2; + Vec3f targetPos; + f32 distanceFromTargetPos; + f32 distanceFromTargetYOffset = 0.0f; + s16 distanceFromTargetAngle; - sp40 = player->actor.world.pos; - - sp40.x -= 25.0f * Math_SinS(player->actor.shape.rot.y); - sp40.z -= 25.0f * Math_CosS(player->actor.shape.rot.y); - sp3C = Math_Vec3f_StepTo(&this->actor.world.pos, &sp40, 10.0f); - temp_s0_2 = Math_SmoothStepToS(&this->actor.shape.rot.y, player->actor.shape.rot.y, 1, 0x1770, 0x64); + targetPos = player->actor.world.pos; + targetPos.x -= 25.0f * Math_SinS(player->actor.shape.rot.y); + targetPos.z -= 25.0f * Math_CosS(player->actor.shape.rot.y); + distanceFromTargetPos = Math_Vec3f_StepTo(&this->actor.world.pos, &targetPos, 10.0f); + distanceFromTargetAngle = Math_SmoothStepToS(&this->actor.shape.rot.y, player->actor.shape.rot.y, 1, 0x1770, 0x64); this->actor.world.rot.y = this->actor.shape.rot.y; if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { - sp38 = Math_SmoothStepToF(&this->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); + distanceFromTargetYOffset = Math_SmoothStepToF(&this->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); } - if ((sp3C == 0.0f) && (ABS_ALT(temp_s0_2) < 100) && (sp38 == 0.0f)) { + if ((distanceFromTargetPos == 0.0f) && (ABS_ALT(distanceFromTargetAngle) < 100) && + (distanceFromTargetYOffset == 0.0f)) { return true; } return false; } -void func_80BA71E4(EnRailgibud* this, GlobalContext* globalCtx) { - if ((this->actionFunc == func_80BA5B64) || (this->actionFunc == func_80BA62D4) || - (this->actionFunc == func_80BA64AC)) { +void EnRailgibud_MoveWithGravity(EnRailgibud* this, GlobalContext* globalCtx) { + if ((this->actionFunc == EnRailgibud_WalkToPlayer) || (this->actionFunc == EnRailgibud_WalkToHome) || + (this->actionFunc == EnRailgibud_Damage)) { Actor_MoveWithGravity(&this->actor); } } -void func_80BA7234(EnRailgibud* this, GlobalContext* globalCtx) { +/** + * If the Gibdo is starting a grab and is touching a wall, the player is moved + * away from that wall with this function. This can happen when the player's + * back is close to a wall before being grabbed. The Gibdo changes its own + * position to match the player's position at the start of a grab, so moving + * the player like this will help prevent the Gibdo from looking like it's + * clipping into the wall as it grabs onto the player. + */ +void EnRailgibud_MoveGrabbedPlayerAwayFromWall(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f sp30; + Vec3f targetPos; - if ((this->actionFunc == func_80BA5E18) && (this->unk_3F0 != 2)) { + if ((this->actionFunc == EnRailgibud_Grab) && (this->grabState != EN_RAILGIBUD_GRAB_RELEASE)) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 35.0f, 1); } else { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 35.0f, 0x1D); } - if ((this->actionFunc == func_80BA5E18) && (this->unk_3F0 == 0) && (this->actor.bgCheckFlags & 8)) { - sp30 = player->actor.world.pos; - sp30.x += 10.0f * Math_SinS(this->actor.wallYaw); - sp30.z += 10.0f * Math_CosS(this->actor.wallYaw); - Math_Vec3f_StepTo(&player->actor.world.pos, &sp30, 5.0f); + if ((this->actionFunc == EnRailgibud_Grab) && (this->grabState == EN_RAILGIBUD_GRAB_START) && + (this->actor.bgCheckFlags & 8)) { + targetPos = player->actor.world.pos; + targetPos.x += 10.0f * Math_SinS(this->actor.wallYaw); + targetPos.z += 10.0f * Math_CosS(this->actor.wallYaw); + Math_Vec3f_StepTo(&player->actor.world.pos, &targetPos, 5.0f); } } -void func_80BA7388(EnRailgibud* this, GlobalContext* globalCtx) { - if (this->unk_3F6 > 0) { - this->unk_3F6--; +void EnRailgibud_UpdateEffect(EnRailgibud* this, GlobalContext* globalCtx) { + if (this->effectTimer > 0) { + this->effectTimer--; } - if (this->unk_3F6 < 20) { - Math_SmoothStepToF(&this->unk_2A4, 0.0f, 0.5f, 0.03f, 0.0f); - this->unk_2A0 = this->unk_3F6 * 0.05f; + if (this->effectTimer < 20) { + Math_SmoothStepToF(&this->effectScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->effectAlpha = this->effectTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_2A4, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->effectScale, 0.5f, 0.1f, 0.02f, 0.0f); } } -void func_80BA7434(EnRailgibud* this, GlobalContext* globalCtx) { - if ((this->actionFunc != func_80BA5E18) && (this->actionFunc != func_80BA64AC) && - (this->actionFunc != func_80BA60B0) && (this->actionFunc != func_80BA61A0) && - (this->actionFunc != func_80BA66C8)) { - if ((this->actor.flags & 5) == 5) { +void EnRailgibud_CheckForGibdoMask(EnRailgibud* this, GlobalContext* globalCtx) { + if ((this->actionFunc != EnRailgibud_Grab) && (this->actionFunc != EnRailgibud_Damage) && + (this->actionFunc != EnRailgibud_GrabFail) && (this->actionFunc != EnRailgibud_TurnAwayAndShakeHead) && + (this->actionFunc != EnRailgibud_Dead)) { + if ((this->actor.flags & (ACTOR_FLAG_4 | ACTOR_FLAG_1)) == 5) { if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { - this->actor.flags &= ~5; - this->actor.flags |= 9; + this->actor.flags &= ~(ACTOR_FLAG_4 | ACTOR_FLAG_1); + this->actor.flags |= (ACTOR_FLAG_8 | ACTOR_FLAG_1); this->actor.hintId = 0xFF; this->actor.textId = 0; - if ((this->actionFunc != func_80BA57F8) && (this->actionFunc != func_80BA62D4)) { - func_80BA6284(this); + if ((this->actionFunc != EnRailgibud_WalkInCircles) && (this->actionFunc != EnRailgibud_WalkToHome)) { + EnRailgibud_SetupWalkToHome(this); } } } else if (Player_GetMask(globalCtx) != PLAYER_MASK_GIBDO) { - this->actor.flags &= ~(0x8 | 0x1); - this->actor.flags |= (0x4 | 0x1); - if (this->unk_3F8 == 1) { + this->actor.flags &= ~(ACTOR_FLAG_8 | ACTOR_FLAG_1); + this->actor.flags |= (ACTOR_FLAG_4 | ACTOR_FLAG_1); + if (this->type == EN_RAILGIBUD_TYPE_REDEAD) { this->actor.hintId = 0x2A; } else { this->actor.hintId = 0x2D; } this->actor.textId = 0; } - func_80BA7578(this, globalCtx); + + EnRailgibud_CheckIfTalkingToPlayer(this, globalCtx); } } -void func_80BA7578(EnRailgibud* this, GlobalContext* globalCtx) { - if ((this->textId == 0) && (this->unk_3F8 == 0)) { +void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, GlobalContext* globalCtx) { + if ((this->textId == 0) && (this->type == EN_RAILGIBUD_TYPE_GIBDO)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->unk_3FA = 1; + this->isInvincible = true; func_801518B0(globalCtx, 0x13B2, &this->actor); this->textId = 0x13B2; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); this->actor.speedXZ = 0.0f; - } else if (((this->actor.flags & 9) == 9) && !(this->collider.base.acFlags & AC_HIT)) { + } else if (((this->actor.flags & (ACTOR_FLAG_8 | ACTOR_FLAG_1)) == 9) && + !(this->collider.base.acFlags & AC_HIT)) { func_800B8614(&this->actor, globalCtx, 100.0f); } } else { @@ -868,7 +976,7 @@ void func_80BA7578(EnRailgibud* this, GlobalContext* globalCtx) { case 6: if (func_80147624(globalCtx)) { this->textId = 0; - this->unk_3FA = 0; + this->isInvincible = false; this->actor.speedXZ = 0.6f; } break; @@ -883,14 +991,16 @@ void func_80BA7578(EnRailgibud* this, GlobalContext* globalCtx) { } } -void func_80BA76C4(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_UpdateCollision(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((this->actionFunc != func_80BA66C8) && ((this->actionFunc != func_80BA5E18) || (this->unk_3F0 == 2))) { + if ((this->actionFunc != EnRailgibud_Dead) && + ((this->actionFunc != EnRailgibud_Grab) || (this->grabState == EN_RAILGIBUD_GRAB_RELEASE))) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (((this->actionFunc != func_80BA64AC) || ((player->unk_ADC != 0) && (player->unk_ADD != this->unk_405))) && - ((this->actionFunc != func_80BA6604) || (this->unk_3F2 == 0))) { + if (((this->actionFunc != EnRailgibud_Damage) || + ((player->unk_ADC != 0) && (player->unk_ADD != this->unk_405))) && + ((this->actionFunc != EnRailgibud_Stunned) || (this->stunTimer == 0))) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } } @@ -899,35 +1009,38 @@ void func_80BA76C4(EnRailgibud* this, GlobalContext* globalCtx) { void EnRailgibud_Update(Actor* thisx, GlobalContext* globalCtx) { EnRailgibud* this = THIS; - func_80BA6B30(this); - func_80BA7434(this, globalCtx); - func_80BA6DF8(this, globalCtx); + EnRailgibud_UpdateWalkForwardState(this); + EnRailgibud_CheckForGibdoMask(this, globalCtx); + EnRailgibud_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); - if (this->actionFunc != func_80BA6604) { + if (this->actionFunc != EnRailgibud_Stunned) { SkelAnime_Update(&this->skelAnime); } - func_80BA71E4(this, globalCtx); - func_80BA76C4(this, globalCtx); - func_80BA7234(this, globalCtx); - func_80BA7388(this, globalCtx); + + EnRailgibud_MoveWithGravity(this, globalCtx); + EnRailgibud_UpdateCollision(this, globalCtx); + EnRailgibud_MoveGrabbedPlayerAwayFromWall(this, globalCtx); + EnRailgibud_UpdateEffect(this, globalCtx); + this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 50.0f; } -void func_80BA7878(Actor* thisx, GlobalContext* globalCtx) { +void EnRailgibud_MainGibdo_DeadUpdate(Actor* thisx, GlobalContext* globalCtx) { EnRailgibud* this = THIS; - func_80BA6B30(this); + EnRailgibud_UpdateWalkForwardState(this); } s32 EnRailgibud_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnRailgibud* this = THIS; - if (limbIndex == 12) { - rot->y += this->unk_3E8; - } else if (limbIndex == 23) { - rot->y += this->unk_3E2; + if (limbIndex == GIBDO_LIMB_UPPER_BODY_ROOT) { + rot->y += this->upperBodyRotation.y; + } else if (limbIndex == GIBDO_LIMB_HEAD_ROOT) { + rot->y += this->headRotation.y; } return false; @@ -937,12 +1050,16 @@ void EnRailgibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi Gfx** gfx) { EnRailgibud* this = THIS; - if ((this->unk_3F6 != 0) && - ((limbIndex == 3) || (limbIndex == 4) || (limbIndex == 6) || (limbIndex == 8) || (limbIndex == 9) || - (limbIndex == 11) || (limbIndex == 14) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18) || - (limbIndex == 20) || (limbIndex == 21) || (limbIndex == 22) || (limbIndex == 24) || (limbIndex == 25))) { - Matrix_GetStateTranslation(&this->unk_1D8[this->unk_28C]); - this->unk_28C++; + if ((this->effectTimer != 0) && + ((limbIndex == GIBDO_LIMB_LEFT_THIGH) || (limbIndex == GIBDO_LIMB_LEFT_SHIN) || + (limbIndex == GIBDO_LIMB_LEFT_FOOT) || (limbIndex == GIBDO_LIMB_RIGHT_THIGH) || + (limbIndex == GIBDO_LIMB_RIGHT_SHIN) || (limbIndex == GIBDO_LIMB_RIGHT_FOOT) || + (limbIndex == GIBDO_LIMB_TORSO) || (limbIndex == GIBDO_LIMB_LEFT_SHOULDER_AND_UPPER_ARM) || + (limbIndex == GIBDO_LIMB_LEFT_FOREARM) || (limbIndex == GIBDO_LIMB_LEFT_HAND) || + (limbIndex == GIBDO_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || (limbIndex == GIBDO_LIMB_RIGHT_FOREARM) || + (limbIndex == GIBDO_LIMB_RIGHT_HAND) || (limbIndex == GIBDO_LIMB_HEAD) || (limbIndex == GIBDO_LIMB_PELVIS))) { + Matrix_GetStateTranslation(&this->limbPos[this->limbIndex]); + this->limbIndex++; } } @@ -951,7 +1068,7 @@ void EnRailgibud_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - this->unk_28C = 0; + this->limbIndex = 0; if (this->actor.shape.shadowAlpha == 255) { func_8012C28C(globalCtx->state.gfxCtx); @@ -972,133 +1089,136 @@ void EnRailgibud_Draw(Actor* thisx, GlobalContext* globalCtx) { EnRailgibud_PostLimbDraw, &this->actor, POLY_XLU_DISP); } - if (this->unk_3F6 > 0) { - func_800BE680(globalCtx, &this->actor, this->unk_1D8, ARRAY_COUNT(this->unk_1D8), this->unk_2A4, 0.5f, - this->unk_2A0, this->unk_404); + if (this->effectTimer > 0) { + func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->effectScale, 0.5f, + this->effectAlpha, this->effectType); } CLOSE_DISPS(globalCtx->state.gfxCtx); } -void func_80BA7B6C(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_InitCutsceneGibdo(EnRailgibud* this, GlobalContext* globalCtx) { s32 pad[2]; - func_80BA7C78(this); - this->unk_3FE = 99; - this->actor.flags |= 0x100000; - this->actor.flags |= 0x10; + EnRailgibud_InitActorActionCommand(this); + this->csAction = 99; + this->actor.flags |= ACTOR_FLAG_100000; + this->actor.flags |= ACTOR_FLAG_10; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_0053E8, &object_rd_Anim_00ABE0, this->jointTable, - this->morphTable, 26); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGibdoSkel, &gGibdoRedeadIdleAnim, this->jointTable, + this->morphTable, GIBDO_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + if (gSaveContext.entranceIndex != 0x2090) { // NOT Cutscene: Music Box House Opens Actor_MarkForDeath(&this->actor); } - func_80BA7CF0(this); - this->actor.update = func_80BA8050; + + EnRailgibud_SetupDoNothing(this); + this->actor.update = EnRailgibud_Cutscene_Update; } -void func_80BA7C78(EnRailgibud* this) { - switch (ENRAILGIBUD_GET_7F(&this->actor)) { +void EnRailgibud_InitActorActionCommand(EnRailgibud* this) { + switch (ENRAILGIBUD_GET_CUTSCENE_TYPE(&this->actor)) { case 1: - this->unk_3FC = 0x207; + this->actorActionCommand = 0x207; break; case 2: - this->unk_3FC = 0x208; + this->actorActionCommand = 0x208; break; case 3: - this->unk_3FC = 0x209; + this->actorActionCommand = 0x209; break; case 4: - this->unk_3FC = 0x20A; + this->actorActionCommand = 0x20A; break; case 5: - this->unk_3FC = 0x20B; + this->actorActionCommand = 0x20B; break; default: - this->unk_3FC = 0x207; + this->actorActionCommand = 0x207; break; } } -void func_80BA7CF0(EnRailgibud* this) { - this->actionFunc = func_80BA7D04; +void EnRailgibud_SetupDoNothing(EnRailgibud* this) { + this->actionFunc = EnRailgibud_DoNothing; } -void func_80BA7D04(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_DoNothing(EnRailgibud* this, GlobalContext* globalCtx) { } -void func_80BA7D14(EnRailgibud* this) { - this->unk_3F2 = 30; - this->actionFunc = func_80BA7D30; +void EnRailgibud_SetupSinkIntoGround(EnRailgibud* this) { + this->sinkTimer = 30; + this->actionFunc = EnRailgibud_SinkIntoGround; } -void func_80BA7D30(EnRailgibud* this, GlobalContext* globalCtx) { - if (this->unk_3F2 != 0) { - this->unk_3F2--; +void EnRailgibud_SinkIntoGround(EnRailgibud* this, GlobalContext* globalCtx) { + if (this->sinkTimer != 0) { + this->sinkTimer--; } else if (Math_SmoothStepToF(&this->actor.shape.yOffset, -9500.0f, 0.5f, 200.0f, 10.0f) < 10.0f) { Actor_MarkForDeath(&this->actor); } else { - func_80BA6800(this, globalCtx, 0); + EnRailgibud_SpawnEffectsForSinkingIntoTheGround(this, globalCtx, 0); } } -s32 func_80BA7DC8(EnRailgibud* this, GlobalContext* globalCtx) { - u32 sp2C; +s32 EnRailgibud_PerformCutsceneActions(EnRailgibud* this, GlobalContext* globalCtx) { + u32 actionIndex; - if (func_800EE29C(globalCtx, this->unk_3FC)) { - sp2C = func_800EE200(globalCtx, this->unk_3FC); - if (this->unk_3FE != globalCtx->csCtx.npcActions[sp2C]->unk0) { - this->unk_3FE = globalCtx->csCtx.npcActions[sp2C]->unk0; - switch (globalCtx->csCtx.npcActions[sp2C]->unk0) { + if (func_800EE29C(globalCtx, this->actorActionCommand)) { + actionIndex = func_800EE200(globalCtx, this->actorActionCommand); + if (this->csAction != globalCtx->csCtx.npcActions[actionIndex]->unk0) { + this->csAction = globalCtx->csCtx.npcActions[actionIndex]->unk0; + switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { case 1: - this->unk_3F0 = 9; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_IDLE; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_IDLE); break; case 2: - this->unk_3F0 = 15; + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_SLUMP_START; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_WEAKENED2); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 15); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_SLUMP_START); break; case 3: - this->unk_3F0 = 17; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 17); + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_CONVULSION; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_CONVULSION); break; case 4: - this->unk_3F0 = 18; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 18); + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_ARMS_UP_START; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_ARMS_UP_START); break; case 5: - this->unk_3F0 = 10; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_WALK; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); break; } } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - if (this->unk_3F0 == 15) { - this->unk_3F0 = 16; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 16); - } else if (this->unk_3F0 == 18) { - this->unk_3F0 = 19; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 19); - func_80BA7D14(this); + if (this->cutsceneAnimationIndex == EN_RAILGIBUD_ANIMATION_SLUMP_START) { + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_SLUMP_LOOP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_SLUMP_LOOP); + } else if (this->cutsceneAnimationIndex == EN_RAILGIBUD_ANIMATION_ARMS_UP_START) { + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_ARMS_UP_LOOP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_ARMS_UP_LOOP); + EnRailgibud_SetupSinkIntoGround(this); } } - switch (this->unk_3FE) { + switch (this->csAction) { case 3: case 4: - if (this->actionFunc == func_80BA7D30) { + if (this->actionFunc == EnRailgibud_SinkIntoGround) { func_800B9010(&this->actor, NA_SE_EN_REDEAD_WEAKENED_L2 - SFX_FLAG); } else { func_800B9010(&this->actor, NA_SE_EN_REDEAD_WEAKENED_L1 - SFX_FLAG); @@ -1116,18 +1236,18 @@ s32 func_80BA7DC8(EnRailgibud* this, GlobalContext* globalCtx) { break; } - func_800EDF24(&this->actor, globalCtx, sp2C); + func_800EDF24(&this->actor, globalCtx, actionIndex); return true; } - this->unk_3FE = 99; + this->csAction = 99; return false; } -void func_80BA8050(Actor* thisx, GlobalContext* globalCtx) { +void EnRailgibud_Cutscene_Update(Actor* thisx, GlobalContext* globalCtx) { EnRailgibud* this = THIS; this->actionFunc(this, globalCtx); - func_80BA7DC8(this, globalCtx); + EnRailgibud_PerformCutsceneActions(this, globalCtx); SkelAnime_Update(&this->skelAnime); } 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 546a885b5..0ca4ec0b8 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h @@ -2,49 +2,57 @@ #define Z_EN_RAILGIBUD_H #include "global.h" +#include "objects/object_rd/object_rd.h" struct EnRailgibud; typedef void (*EnRailgibudActionFunc)(struct EnRailgibud*, GlobalContext*); -#define ENRAILGIBUD_GET_7F(thisx) ((thisx)->params & 0x7F) -#define ENRAILGIBUD_GET_80(thisx) ((thisx)->params & 0x80) -#define ENRAILGIBUD_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) +#define ENRAILGIBUD_GET_CUTSCENE_TYPE(thisx) ((thisx)->params & 0x7F) +#define ENRAILGIBUD_IS_CUTSCENE_TYPE(thisx) ((thisx)->params & 0x80) +#define ENRAILGIBUD_GET_PATH(thisx) (((thisx)->params & 0xFF00) >> 8) typedef struct EnRailgibud { /* 0x0000 */ Actor actor; /* 0x0144 */ ColliderCylinder collider; /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnRailgibudActionFunc actionFunc; - /* 0x01D8 */ Vec3f unk_1D8[15]; - /* 0x028C */ s32 unk_28C; + /* 0x01D8 */ Vec3f limbPos[15]; + /* 0x028C */ s32 limbIndex; /* 0x0290 */ UNK_TYPE1 unk290[0x4]; - /* 0x0294 */ Vec3s* unk_294; - /* 0x0298 */ s32 unk_298; - /* 0x029C */ s32 unk_29C; - /* 0x02A0 */ f32 unk_2A0; - /* 0x02A4 */ f32 unk_2A4; - /* 0x02A8 */ Vec3s jointTable[26]; - /* 0x0344 */ Vec3s morphTable[26]; - /* 0x03E0 */ UNK_TYPE1 unk3E0[0x2]; - /* 0x03E2 */ s16 unk_3E2; - /* 0x03E4 */ UNK_TYPE1 unk3E4[0x4]; - /* 0x03E8 */ s16 unk_3E8; - /* 0x03EA */ UNK_TYPE1 unk3EA[0x2]; - /* 0x03EC */ s16 unk_3EC; - /* 0x03EE */ s16 unk_3EE; - /* 0x03F0 */ s16 unk_3F0; - /* 0x03F2 */ s16 unk_3F2; - /* 0x03F4 */ s16 unk_3F4; - /* 0x03F6 */ s16 unk_3F6; - /* 0x03F8 */ s16 unk_3F8; - /* 0x03FA */ s16 unk_3FA; - /* 0x03FC */ u16 unk_3FC; - /* 0x03FE */ u16 unk_3FE; + /* 0x0294 */ Vec3s* points; + /* 0x0298 */ s32 currentPoint; + /* 0x029C */ s32 pathCount; + /* 0x02A0 */ f32 effectAlpha; + /* 0x02A4 */ f32 effectScale; + /* 0x02A8 */ Vec3s jointTable[GIBDO_LIMB_MAX]; + /* 0x0344 */ Vec3s morphTable[GIBDO_LIMB_MAX]; + /* 0x03E0 */ Vec3s headRotation; + /* 0x03E6 */ Vec3s upperBodyRotation; + /* 0x03EC */ s16 shouldWalkForward; // Only used by the "main" Gibdo + /* 0x03EE */ s16 shouldWalkForwardNextFrame; // Only used by the "main" Gibdo + /* 0x03F0 */ union { + s16 grabState; + s16 cutsceneAnimationIndex; + }; + /* 0x03F2 */ union { + s16 playerStunWaitTimer; // Cannot stun the player if this is non-zero + s16 grabDamageTimer; + s16 headShakeTimer; + s16 stunTimer; + s16 deathTimer; + s16 sinkTimer; + }; + /* 0x03F4 */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero + /* 0x03F6 */ s16 effectTimer; + /* 0x03F8 */ s16 type; + /* 0x03FA */ s16 isInvincible; + /* 0x03FC */ u16 actorActionCommand; + /* 0x03FE */ u16 csAction; /* 0x0400 */ u16 textId; - /* 0x0402 */ s16 unk_402; - /* 0x0404 */ u8 unk_404; - /* 0x0405 */ s8 unk_405; + /* 0x0402 */ s16 timeInitialized; // unused other than setting it + /* 0x0404 */ u8 effectType; + /* 0x0405 */ s8 unk_405; // related to player->unk_ADD } EnRailgibud; // size = 0x408 extern const ActorInit En_Railgibud_InitVars; diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c index 4b942f03f..454836494 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -1,13 +1,31 @@ /* * File: z_en_rd.c * Overlay: ovl_En_Rd - * Description: Redead/Gibdo (able to dance) + * Description: Redead/Gibdo that cannot talk to the player. + * + * A variety of different Redeads/Gibdos are represented by this actor; + * one of the few things they all have in common is that none of them + * can talk with the player, which separates them from Talk_Gibud and + * Railgibud. Some of the different kinds of Redeads/Gibdos that this + * actor controls are: + * - Three different types of dancing Redeads. These are the only + * Redead/Gidbo variations that are actually used in the final game. + * - A Redead frozen in a block of ice. + * - An invisible Redead. + * - A crying Redead. + * - A Gidbo that rises out of a "coffin"; this is leftover from OoT. + * + * Another thing that separates this actor from Talk_Gibud and Railgibud + * is that most Redead variations will "mourn" other fallen Redeads in + * the same area by walking over to their corpse. Note that some Redeads, + * depending on their params, will refuse to mourn under certain + * circumstances, and all Gibdo variations will refuse to mourn as well. */ #include "z_en_rd.h" #include "objects/object_rd/object_rd.h" -#define FLAGS 0x00000415 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnRd*)thisx) @@ -16,39 +34,67 @@ void EnRd_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRd_Update(Actor* thisx, GlobalContext* globalCtx); void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx); -s32 func_808D41FC(GlobalContext* globalCtx); -void func_808D4308(EnRd* this); -void func_808D43AC(EnRd* this, GlobalContext* globalCtx); -void func_808D45D4(EnRd* this); -void func_808D4660(EnRd* this, GlobalContext* globalCtx); -void func_808D47DC(EnRd* this); -void func_808D4868(EnRd* this, GlobalContext* globalCtx); -void func_808D49E4(EnRd* this, GlobalContext* globalCtx); -void func_808D4A90(EnRd* this); -void func_808D4B20(EnRd* this, GlobalContext* globalCtx); -void func_808D4CA8(EnRd* this, GlobalContext* globalCtx); -void func_808D4DC4(EnRd* this); -void func_808D4E60(EnRd* this, GlobalContext* globalCtx); -void func_808D506C(EnRd* this, GlobalContext* globalCtx); -void func_808D53C0(EnRd* this, GlobalContext* globalCtx); -void func_808D5440(EnRd* this, GlobalContext* globalCtx); -void func_808D5660(EnRd* this); -void func_808D56E4(EnRd* this, GlobalContext* globalCtx); -void func_808D586C(EnRd* this); -void func_808D58CC(EnRd* this, GlobalContext* globalCtx); -void func_808D5C54(EnRd* this); -void func_808D5CCC(EnRd* this, GlobalContext* globalCtx); -void func_808D5D88(EnRd* this); -void func_808D5DF4(EnRd* this, GlobalContext* globalCtx); -void func_808D5E98(EnRd* this); -void func_808D5F18(EnRd* this, GlobalContext* globalCtx); -void func_808D6008(EnRd* this); -void func_808D6054(EnRd* this, GlobalContext* globalCtx); -void func_808D60B0(EnRd* this); -void func_808D6130(EnRd* this, GlobalContext* globalCtx); -void func_808D6200(EnRd* this, GlobalContext* globalCtx); -void func_808D6388(EnRd* this, GlobalContext* globalCtx); -void func_808D65BC(EnRd* this, GlobalContext* globalCtx); +s32 EnRd_ShouldNotDance(GlobalContext* globalCtx); +void EnRd_SetupIdle(EnRd* this); +void EnRd_Idle(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupSquattingDance(EnRd* this); +void EnRd_SquattingDance(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupClappingDance(EnRd* this); +void EnRd_ClappingDance(EnRd* this, GlobalContext* globalCtx); +void EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupPirouette(EnRd* this); +void EnRd_Pirouette(EnRd* this, GlobalContext* globalCtx); +void EnRd_EndPirouetteWhenPlayerIsClose(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupRiseFromCoffin(EnRd* this); +void EnRd_RiseFromCoffin(EnRd* this, GlobalContext* globalCtx); +void EnRd_WalkToPlayer(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupWalkToHome(EnRd* this, GlobalContext* globalCtx); +void EnRd_WalkToHome(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupWalkToParent(EnRd* this); +void EnRd_WalkToParent(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupGrab(EnRd* this); +void EnRd_Grab(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupAttemptPlayerFreeze(EnRd* this); +void EnRd_AttemptPlayerFreeze(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupGrabFail(EnRd* this); +void EnRd_GrabFail(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupTurnAwayAndShakeHead(EnRd* this); +void EnRd_TurnAwayAndShakeHead(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupStandUp(EnRd* this); +void EnRd_StandUp(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupCrouch(EnRd* this); +void EnRd_Crouch(EnRd* this, GlobalContext* globalCtx); +void EnRd_Damage(EnRd* this, GlobalContext* globalCtx); +void EnRd_Dead(EnRd* this, GlobalContext* globalCtx); +void EnRd_Stunned(EnRd* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ EN_RD_ACTION_IDLE, + /* 1 */ EN_RD_ACTION_STUNNED, + /* 2 */ EN_RD_ACTION_WALKING_TO_HOME, + /* 3 */ EN_RD_ACTION_WALKING_TO_PARENT, + /* 4 */ EN_RD_ACTION_WALKING_TO_PLAYER_OR_RELEASING_GRAB, + /* 5 */ EN_RD_ACTION_STANDING_UP, + /* 6 */ EN_RD_ACTION_CROUCHING, + /* 7 */ EN_RD_ACTION_ATTEMPTING_PLAYER_STUN, + /* 8 */ EN_RD_ACTION_FAILING_GRAB, + /* 9 */ EN_RD_ACTION_TURNING_AWAY_AND_SHAKING_HEAD, + /* 10 */ EN_RD_ACTION_GRABBING, + /* 11 */ EN_RD_ACTION_DAMAGE, + /* 12 */ EN_RD_ACTION_DEAD, + /* 13 */ EN_RD_ACTION_RISING_FROM_COFFIN, + /* 14 */ EN_RD_ACTION_SQUATTING_DANCE, + /* 15 */ EN_RD_ACTION_CLAPPING_DANCE, + /* 16 */ EN_RD_ACTION_PIROUETTE +} EnRdAction; + +typedef enum { + /* 0 */ EN_RD_GRAB_START, + /* 1 */ EN_RD_GRAB_INITIAL_DAMAGE, + /* 2 */ EN_RD_GRAB_ATTACK, + /* 3 */ EN_RD_GRAB_RELEASE, + /* 4 */ EN_RD_GRAB_END, +} EnRdGrabState; const ActorInit En_Rd_InitVars = { ACTOR_EN_RD, @@ -82,39 +128,52 @@ static ColliderCylinderInit sCylinderInit = { { 20, 70, 0, { 0, 0, 0 } }, }; +typedef enum { + /* 0x0 */ EN_RD_DMGEFF_NONE, // Does not interact with the Gibdo/Redead at all + /* 0x1 */ EN_RD_DMGEFF_STUN, // Stuns without applying any effect + /* 0x2 */ EN_RD_DMGEFF_FIRE_ARROW, // Damages and applies a fire effect + /* 0x4 */ EN_RD_DMGEFF_LIGHT_ARROW = 0x4, // Damages and applies a light effect + /* 0x6 */ EN_RD_DMGEFF_UNUSED_6 = 0x6, // Referenced in EnRd_Update, but no attack uses this damage effect. + // Likely to have originally been used for Ice Arrows like OoT. + /* 0xC */ EN_RD_DMGEFF_ZORA_MAGIC = 0xC, // Stuns and applies an electric effect + /* 0xD */ EN_RD_DMGEFF_RECOIL, // Deals no damage, but displays hit mark and recoil animation + /* 0xE */ EN_RD_DMGEFF_LIGHT_RAY, // Instantly kills on contact + /* 0xF */ EN_RD_DMGEFF_DAMAGE, // Deals damage and plays the damage animation +} EnRdDamageEffect; + static DamageTable sDamageTable = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(2, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(0, 0xD), - /* Normal arrow */ DMG_ENTRY(0, 0xD), - /* UNK_DMG_0x06 */ DMG_ENTRY(2, 0xF), - /* Hookshot */ DMG_ENTRY(0, 0xD), - /* Goron punch */ DMG_ENTRY(1, 0xF), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(1, 0xF), - /* Fire arrow */ DMG_ENTRY(1, 0x2), - /* Ice arrow */ DMG_ENTRY(0, 0xD), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(0, 0xD), - /* Deku launch */ DMG_ENTRY(2, 0xF), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0xC), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0xE), - /* Thrown object */ DMG_ENTRY(1, 0xF), - /* Zora punch */ DMG_ENTRY(1, 0xF), - /* Spin attack */ DMG_ENTRY(1, 0xF), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0xF), + /* Deku Nut */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(2, EN_RD_DMGEFF_DAMAGE), + /* Horse trample */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Zora boomerang */ DMG_ENTRY(0, EN_RD_DMGEFF_RECOIL), + /* Normal arrow */ DMG_ENTRY(0, EN_RD_DMGEFF_RECOIL), + /* UNK_DMG_0x06 */ DMG_ENTRY(2, EN_RD_DMGEFF_DAMAGE), + /* Hookshot */ DMG_ENTRY(0, EN_RD_DMGEFF_RECOIL), + /* Goron punch */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Sword */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Goron pound */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Fire arrow */ DMG_ENTRY(1, EN_RD_DMGEFF_FIRE_ARROW), + /* Ice arrow */ DMG_ENTRY(0, EN_RD_DMGEFF_RECOIL), + /* Light arrow */ DMG_ENTRY(2, EN_RD_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Deku spin */ DMG_ENTRY(0, EN_RD_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(0, EN_RD_DMGEFF_RECOIL), + /* Deku launch */ DMG_ENTRY(2, EN_RD_DMGEFF_DAMAGE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(0, EN_RD_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_RD_DMGEFF_LIGHT_RAY), + /* Thrown object */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Zora punch */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Spin attack */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Sword beam */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), }; static InitChainEntry sInitChain[] = { @@ -131,86 +190,86 @@ void EnRd_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 0; this->actor.colChkInfo.damageTable = &sDamageTable; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - this->unk_3DA = this->unk_3D8 = 0; + this->upperBodyYRotation = this->headYRotation = 0; this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 50.0f; this->actor.colChkInfo.mass = MASS_HEAVY; this->actor.colChkInfo.health = 8; - this->unk_3DE = 255; + this->alpha = 255; this->unk_3F1 = -1; - this->unk_3DC = ENRD_GET_FF00(thisx); + this->flags = EN_RD_GET_FLAGS(thisx); - if (ENRD_GET_80(&this->actor)) { + if (EN_RD_GET_80(&this->actor)) { this->actor.params |= 0xFF00; } else { this->actor.params &= 0xFF; } - if (this->actor.params >= ENRD_GET_MINUS_1) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_010B88, &object_rd_Anim_00ABE0, - this->jointTable, this->morphTable, 26); + if (EN_RD_GET_TYPE(&this->actor) > EN_RD_TYPE_GIBDO) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, &gGibdoRedeadIdleAnim, this->jointTable, + this->morphTable, REDEAD_LIMB_MAX); } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_0053E8, &object_rd_Anim_00ABE0, - this->jointTable, this->morphTable, 26); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGibdoSkel, &gGibdoRedeadIdleAnim, this->jointTable, + this->morphTable, REDEAD_LIMB_MAX); } Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - if (this->actor.params >= ENRD_GET_MINUS_2) { - switch (this->actor.params) { - case 5: - if (!func_808D41FC(globalCtx)) { - func_808D45D4(this); + if (EN_RD_GET_TYPE(&this->actor) >= EN_RD_TYPE_GIBDO) { + switch (EN_RD_GET_TYPE(&this->actor)) { + case EN_RD_TYPE_SQUATTING_DANCE: + if (!EnRd_ShouldNotDance(globalCtx)) { + EnRd_SetupSquattingDance(this); } else { this->actor.hintId = 0x2A; - func_808D4308(this); + EnRd_SetupIdle(this); } - this->unkFunc = func_808D45D4; + this->setupDanceFunc = EnRd_SetupSquattingDance; break; - case 6: - if (!func_808D41FC(globalCtx)) { - func_808D47DC(this); + case EN_RD_TYPE_CLAPPING_DANCE: + if (!EnRd_ShouldNotDance(globalCtx)) { + EnRd_SetupClappingDance(this); } else { this->actor.hintId = 0x2A; - func_808D4308(this); + EnRd_SetupIdle(this); } - this->unkFunc = func_808D47DC; + this->setupDanceFunc = EnRd_SetupClappingDance; break; - case 7: - if (!func_808D41FC(globalCtx)) { - func_808D4A90(this); + case EN_RD_TYPE_PIROUETTE: + if (!EnRd_ShouldNotDance(globalCtx)) { + EnRd_SetupPirouette(this); } else { this->actor.hintId = 0x2A; - func_808D4308(this); + EnRd_SetupIdle(this); } - this->unkFunc = func_808D4A90; + this->setupDanceFunc = EnRd_SetupPirouette; break; default: - if (this->actor.params == ENRD_GET_MINUS_2) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - func_808D4308(this); - this->unkFunc = func_808D4308; + EnRd_SetupIdle(this); + this->setupDanceFunc = EnRd_SetupIdle; break; } } else { - func_808D4DC4(this); + EnRd_SetupRiseFromCoffin(this); } SkelAnime_Update(&this->skelAnime); - if (this->actor.params == ENRD_GET_3) { - this->actor.flags |= 0x80; + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_INVISIBLE) { + this->actor.flags |= ACTOR_FLAG_80; } - if (this->actor.params == ENRD_GET_4) { - s32 pad2; + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_FROZEN) { + s32 requiredScopeTemp; Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, this->actor.world.rot.x, @@ -227,96 +286,124 @@ void EnRd_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } -void func_808D4190(GlobalContext* globalCtx, EnRd* this, s32 arg2) { - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; +/** + * This function does two things depending on whether setParent is true or false. + * - If setParent is true, this function sets thisx to be the parent for all Redeads + * in the area that are capable of mourning. This is used right when thisx first + * dies to make the other Redeads mourn it. + * - If setParent is false, this function nulls out the parent for all Redeads in the + * are whose parents is thisx. This is used when thisx is fading away to make the + * other Redeads stop mourning over it. + */ +void EnRd_UpdateParentForOtherRedeads(GlobalContext* globalCtx, Actor* thisx, s32 setParent) { + Actor* enemyIterator = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; - while (actor != NULL) { - if ((actor->id != ACTOR_EN_RD) || (this == (EnRd*)actor) || (actor->params < ENRD_GET_0)) { - actor = actor->next; + while (enemyIterator != NULL) { + if ((enemyIterator->id != ACTOR_EN_RD) || (enemyIterator == thisx) || + (EN_RD_GET_TYPE(enemyIterator) < EN_RD_TYPE_DOES_NOT_MOURN_IF_WALKING)) { + enemyIterator = enemyIterator->next; continue; - } else if (arg2 != 0) { - actor->parent = &this->actor; - } else if (this == (EnRd*)actor->parent) { - actor->parent = NULL; } - actor = actor->next; + + if (setParent) { + enemyIterator->parent = thisx; + } else if (thisx == enemyIterator->parent) { + enemyIterator->parent = NULL; + } + + enemyIterator = enemyIterator->next; } } -s32 func_808D41FC(GlobalContext* globalCtx) { +/** + * Returns true if the various dancing Redead types *should not* be dancing + * and returns false if they *should* be dancing. The non-dancing Redeads + * do not call this function in the final game and thus don't care about + * what mask the player has equipped. + */ +s32 EnRd_ShouldNotDance(GlobalContext* globalCtx) { if ((Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) || (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) || (Player_GetMask(globalCtx) == PLAYER_MASK_GARO)) { return false; } + return true; } -void func_808D4260(EnRd* this, GlobalContext* globalCtx) { - if ((this->actor.params >= ENRD_GET_5) && (this->actionFunc != func_808D4660) && - (this->actionFunc != func_808D4868) && (this->actionFunc != func_808D4B20) && - (this->actionFunc != func_808D65BC) && (this->actionFunc != func_808D58CC) && - (this->actionFunc != func_808D6200) && (this->actionFunc != func_808D6388)) { - if (!func_808D41FC(globalCtx)) { - this->unkFunc(this); +/** + * If the Redead/Gibdo is a dancing Redead; if it isn't already dancing; if it isn't stunned, + * taking damage, dead, or currently grabbing the player; and if the player is wearing the + * appropriate mask, this function will make the Redead start dancing. + */ +void EnRd_SetupDanceIfConditionsMet(EnRd* this, GlobalContext* globalCtx) { + if ((EN_RD_GET_TYPE(&this->actor) >= EN_RD_TYPE_SQUATTING_DANCE) && (this->actionFunc != EnRd_SquattingDance) && + (this->actionFunc != EnRd_ClappingDance) && (this->actionFunc != EnRd_Pirouette) && + (this->actionFunc != EnRd_Stunned) && (this->actionFunc != EnRd_Grab) && (this->actionFunc != EnRd_Damage) && + (this->actionFunc != EnRd_Dead)) { + if (!EnRd_ShouldNotDance(globalCtx)) { + this->setupDanceFunc(this); } } } -void func_808D4308(EnRd* this) { - if (this->actor.params != ENRD_GET_2) { - Animation_MorphToLoop(&this->skelAnime, &object_rd_Anim_00ABE0, -6.0f); +void EnRd_SetupIdle(EnRd* this) { + if (EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) { + Animation_MorphToLoop(&this->skelAnime, &gGibdoRedeadIdleAnim, -6.0f); } else { - Animation_PlayLoop(&this->skelAnime, &object_rd_Anim_0081A8); + Animation_PlayLoop(&this->skelAnime, &gGibdoRedeadSobbingAnim); } - this->unk_3EF = 0; - this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; + this->action = EN_RD_ACTION_IDLE; + this->animationJudderTimer = (Rand_ZeroOne() * 10.0f) + 5.0f; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - this->actionFunc = func_808D43AC; + this->actionFunc = EnRd_Idle; } -void func_808D43AC(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Idle(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); - if ((this->actor.params == ENRD_GET_2) && Animation_OnFrame(&this->skelAnime, 0.0f)) { + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); + + if ((EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_CRYING) && Animation_OnFrame(&this->skelAnime, 0.0f)) { if (Rand_ZeroOne() >= 0.5f) { - Animation_PlayLoop(&this->skelAnime, &object_rd_Anim_0081A8); + Animation_PlayLoop(&this->skelAnime, &gGibdoRedeadSobbingAnim); } else { - Animation_PlayLoop(&this->skelAnime, &object_rd_Anim_007BBC); + Animation_PlayLoop(&this->skelAnime, &gGibdoRedeadWipingTearsAnim); } } else { - this->unk_3D6--; - if (this->unk_3D6 == 0) { - this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 10.0f; + this->animationJudderTimer--; + if (this->animationJudderTimer == 0) { + // This resets the idle animation back to its first frame, making the + // Redead/Gibdo appear to "judder" in place. + this->animationJudderTimer = (Rand_ZeroOne() * 10.0f) + 10.0f; this->skelAnime.curFrame = 0.0f; } } if (this->actor.parent != NULL) { - if (this->unk_3EC == 0) { - if (this->actor.params != ENRD_GET_2) { - func_808D5660(this); + if (!this->isMourning) { + if (EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) { + EnRd_SetupWalkToParent(this); } else { - func_808D6008(this); + EnRd_SetupStandUp(this); } } } else { - if (this->unk_3EC != 0) { - if (this->actor.params != ENRD_GET_2) { - func_808D5C54(this); + if (this->isMourning) { + if (EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) { + EnRd_SetupAttemptPlayerFreeze(this); } else { - func_808D6008(this); + EnRd_SetupStandUp(this); } } - this->unk_3EC = 0; + this->isMourning = false; if ((this->actor.xzDistToPlayer <= 150.0f) && func_800B715C(globalCtx)) { - if ((this->actor.params != ENRD_GET_2) && (this->unk_3EC == 0)) { - func_808D5C54(this); + if ((EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) && (!this->isMourning)) { + EnRd_SetupAttemptPlayerFreeze(this); } else { - func_808D6008(this); + EnRd_SetupStandUp(this); } } } @@ -326,42 +413,43 @@ void func_808D43AC(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D45D4(EnRd* this) { - Animation_MorphToLoop(&this->skelAnime, &object_rd_Anim_01216C, -6.0f); - this->unk_3EF = 14; - this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; - this->unk_3E4 = 0; +void EnRd_SetupSquattingDance(EnRd* this) { + Animation_MorphToLoop(&this->skelAnime, &gGibdoRedeadSquattingDanceAnim, -6.0f); + this->action = EN_RD_ACTION_SQUATTING_DANCE; + this->animationJudderTimer = (Rand_ZeroOne() * 10.0f) + 5.0f; + this->danceEndTimer = 0; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - this->actionFunc = func_808D4660; + this->actionFunc = EnRd_SquattingDance; } -void func_808D4660(EnRd* this, GlobalContext* globalCtx) { +void EnRd_SquattingDance(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); - if (this->unk_3EC != 0) { - func_808D5C54(this); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); + + if (this->isMourning) { + EnRd_SetupAttemptPlayerFreeze(this); } - this->unk_3EC = 0; - if ((this->actor.xzDistToPlayer <= 150.0f) && func_808D41FC(globalCtx) && func_800B715C(globalCtx)) { - if (this->actor.params == ENRD_GET_MINUS_2) { + this->isMourning = false; + if ((this->actor.xzDistToPlayer <= 150.0f) && EnRd_ShouldNotDance(globalCtx) && func_800B715C(globalCtx)) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - Animation_Change(&this->skelAnime, &object_rd_Anim_0073A4, 0.0f, 0.0f, 19.0f, 2, -10.0f); - this->actionFunc = func_808D49E4; + Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, 2, -10.0f); + this->actionFunc = EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose; } - if (func_808D41FC(globalCtx)) { - if (this->actor.params == ENRD_GET_MINUS_2) { + if (EnRd_ShouldNotDance(globalCtx)) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - func_808D4308(this); + EnRd_SetupIdle(this); } if ((globalCtx->gameplayFrames & 0x5F) == 0) { @@ -369,42 +457,43 @@ void func_808D4660(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D47DC(EnRd* this) { - Animation_MorphToLoop(&this->skelAnime, &object_rd_Anim_011DB8, -6.0f); - this->unk_3EF = 15; - this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; - this->unk_3E4 = 0; +void EnRd_SetupClappingDance(EnRd* this) { + Animation_MorphToLoop(&this->skelAnime, &gGibdoRedeadClappingDanceAnim, -6.0f); + this->action = EN_RD_ACTION_CLAPPING_DANCE; + this->animationJudderTimer = (Rand_ZeroOne() * 10.0f) + 5.0f; + this->danceEndTimer = 0; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - this->actionFunc = func_808D4868; + this->actionFunc = EnRd_ClappingDance; } -void func_808D4868(EnRd* this, GlobalContext* globalCtx) { +void EnRd_ClappingDance(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); - if (this->unk_3EC != 0) { - func_808D5C54(this); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); + + if (this->isMourning) { + EnRd_SetupAttemptPlayerFreeze(this); } - this->unk_3EC = 0; - if ((this->actor.xzDistToPlayer <= 150.0f) && func_808D41FC(globalCtx) && func_800B715C(globalCtx)) { - if (this->actor.params == ENRD_GET_MINUS_2) { + this->isMourning = false; + if ((this->actor.xzDistToPlayer <= 150.0f) && EnRd_ShouldNotDance(globalCtx) && func_800B715C(globalCtx)) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - Animation_Change(&this->skelAnime, &object_rd_Anim_0073A4, 0.0f, 0.0f, 19.0f, 2, -10.0f); - this->actionFunc = func_808D49E4; + Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, 2, -10.0f); + this->actionFunc = EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose; } - if (func_808D41FC(globalCtx)) { - if (this->actor.params == ENRD_GET_MINUS_2) { + if (EnRd_ShouldNotDance(globalCtx)) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - func_808D4308(this); + EnRd_SetupIdle(this); } if ((globalCtx->gameplayFrames & 0x5F) == 0) { @@ -412,58 +501,59 @@ void func_808D4868(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D49E4(EnRd* this, GlobalContext* globalCtx) { +void EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if ((globalCtx->gameplayFrames & 0x5F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } - this->unk_3E4++; - if (this->unk_3E4 > 10) { - if ((this->actor.params != ENRD_GET_2) && (this->unk_3EC == 0)) { - func_808D5C54(this); + this->danceEndTimer++; + if (this->danceEndTimer > 10) { + if ((EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) && (!this->isMourning)) { + EnRd_SetupAttemptPlayerFreeze(this); } else { - func_808D6008(this); + EnRd_SetupStandUp(this); } - this->unk_3E4 = 0; + this->danceEndTimer = 0; } } -void func_808D4A90(EnRd* this) { - Animation_MorphToLoop(&this->skelAnime, &object_rd_Anim_0118D8, -6.0f); - this->unk_3EF = 16; - this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; - this->unk_3E4 = 4370; +void EnRd_SetupPirouette(EnRd* this) { + Animation_MorphToLoop(&this->skelAnime, &gGibdoRedeadPirouetteAnim, -6.0f); + this->action = EN_RD_ACTION_PIROUETTE; + this->animationJudderTimer = (Rand_ZeroOne() * 10.0f) + 5.0f; + this->pirouetteRotationalVelocity = 0x1112; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - this->actionFunc = func_808D4B20; + this->actionFunc = EnRd_Pirouette; } -void func_808D4B20(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Pirouette(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); - if (this->unk_3EC != 0) { - func_808D5C54(this); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); + + if (this->isMourning) { + EnRd_SetupAttemptPlayerFreeze(this); } - this->unk_3EC = 0; - if ((this->actor.xzDistToPlayer <= 150.0f) && func_808D41FC(globalCtx) && func_800B715C(globalCtx)) { - if (this->actor.params == ENRD_GET_MINUS_2) { + this->isMourning = false; + if ((this->actor.xzDistToPlayer <= 150.0f) && EnRd_ShouldNotDance(globalCtx) && func_800B715C(globalCtx)) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - this->actionFunc = func_808D4CA8; + this->actionFunc = EnRd_EndPirouetteWhenPlayerIsClose; } - if (func_808D41FC(globalCtx)) { - if (this->actor.params == ENRD_GET_MINUS_2) { + if (EnRd_ShouldNotDance(globalCtx)) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - func_808D4308(this); + EnRd_SetupIdle(this); } if ((globalCtx->gameplayFrames & 0x5F) == 0) { @@ -471,54 +561,54 @@ void func_808D4B20(EnRd* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->unk_3E4 = 4370; + this->pirouetteRotationalVelocity = 0x1112; } else if (Animation_OnFrame(&this->skelAnime, 15.0f)) { - this->unk_3E4 = 6554; + this->pirouetteRotationalVelocity = 0x199A; } - this->actor.world.rot.y -= this->unk_3E4; + this->actor.world.rot.y -= this->pirouetteRotationalVelocity; this->actor.shape.rot.y = this->actor.world.rot.y; } -void func_808D4CA8(EnRd* this, GlobalContext* globalCtx) { +void EnRd_EndPirouetteWhenPlayerIsClose(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if ((globalCtx->gameplayFrames & 0x5F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } - this->actor.world.rot.y -= this->unk_3E4; + this->actor.world.rot.y -= this->pirouetteRotationalVelocity; this->actor.shape.rot.y = this->actor.world.rot.y; - this->unk_3E4 -= 100; - if ((this->unk_3E4 < 2100) && (this->unk_3E4 >= 2000)) { - Animation_Change(&this->skelAnime, &object_rd_Anim_0073A4, 0.0f, 0.0f, 19.0f, 2, -10.0f); - } else if (this->unk_3E4 < 1000) { - if ((this->actor.params != ENRD_GET_2) && (this->unk_3EC == 0)) { - func_808D5C54(this); + this->pirouetteRotationalVelocity -= 0x64; + if ((this->pirouetteRotationalVelocity < 0x834) && (this->pirouetteRotationalVelocity >= 0x7D0)) { + Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, 2, -10.0f); + } else if (this->pirouetteRotationalVelocity < 0x3E8) { + if ((EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) && (!this->isMourning)) { + EnRd_SetupAttemptPlayerFreeze(this); } else { - func_808D6008(this); + EnRd_SetupStandUp(this); } } } -void func_808D4DC4(EnRd* this) { - Animation_Change(&this->skelAnime, &object_rd_Anim_00ABE0, 0.0f, 0.0f, - Animation_GetLastFrame(&object_rd_Anim_00ABE0), 0, -6.0f); - this->unk_3EF = 13; - this->unk_3D6 = 6; +void EnRd_SetupRiseFromCoffin(EnRd* this) { + Animation_Change(&this->skelAnime, &gGibdoRedeadIdleAnim, 0.0f, 0.0f, Animation_GetLastFrame(&gGibdoRedeadIdleAnim), + 0, -6.0f); + this->action = EN_RD_ACTION_RISING_FROM_COFFIN; + this->coffinRiseForwardAccelTimer = 6; this->actor.shape.rot.x = -0x4000; this->actor.gravity = 0.0f; this->actor.shape.yOffset = 0.0f; this->actor.speedXZ = 0.0f; - this->actionFunc = func_808D4E60; + this->actionFunc = EnRd_RiseFromCoffin; } -void func_808D4E60(EnRd* this, GlobalContext* globalCtx) { +void EnRd_RiseFromCoffin(EnRd* this, GlobalContext* globalCtx) { if (this->actor.shape.rot.x != -0x4000) { Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 0x7D0, 0); if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.3f, 2.0f, 0.3f) == 0.0f) { this->actor.gravity = -3.5f; - func_808D4308(this); + EnRd_SetupIdle(this); } } else { if (this->actor.world.pos.y == this->actor.home.pos.y) { @@ -526,8 +616,8 @@ void func_808D4E60(EnRd* this, GlobalContext* globalCtx) { } if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 50.0f, 0.3f, 2.0f, 0.3f) == 0.0f) { - if (this->unk_3D6 != 0) { - this->unk_3D6--; + if (this->coffinRiseForwardAccelTimer != 0) { + this->coffinRiseForwardAccelTimer--; Math_SmoothStepToF(&this->actor.speedXZ, 6.0f, 0.3f, 1.0f, 0.3f); } else if (Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.3f, 1.0f, 0.3f) == 0.0f) { Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 0x7D0, 0); @@ -536,71 +626,74 @@ void func_808D4E60(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D4FE0(EnRd* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&object_rd_Anim_0113EC); +void EnRd_SetupWalkToPlayer(EnRd* this, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gGibdoRedeadWalkAnim); - Animation_Change(&this->skelAnime, &object_rd_Anim_0113EC, 1.0f, 4.0f, frameCount, 1, -4.0f); + Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 1.0f, 4.0f, frameCount, 1, -4.0f); this->actor.speedXZ = 0.4f; - this->unk_3EF = 4; - this->actionFunc = func_808D506C; + this->action = EN_RD_ACTION_WALKING_TO_PLAYER_OR_RELEASING_GRAB; + this->actionFunc = EnRd_WalkToPlayer; } -void func_808D506C(EnRd* this, GlobalContext* globalCtx) { +void EnRd_WalkToPlayer(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad; - s16 sp36 = ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_3D8) - this->unk_3DA; + s16 yaw = + ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->headYRotation) - this->upperBodyYRotation; this->skelAnime.playSpeed = this->actor.speedXZ; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 250, 0); - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); this->actor.world.rot.y = this->actor.shape.rot.y; SkelAnime_Update(&this->skelAnime); if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { - func_808D53C0(this, globalCtx); + EnRd_SetupWalkToHome(this, globalCtx); } - if ((ABS_ALT(sp36) < 0x1554) && (Actor_DistanceBetweenActors(&this->actor, &player->actor) <= 150.0f)) { + if ((ABS_ALT(yaw) < 0x1554) && (Actor_DistanceBetweenActors(&this->actor, &player->actor) <= 150.0f)) { if (!(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && - !(player->stateFlags2 & 0x4080)) { - if (this->unk_3ED == 0) { - if (!(this->unk_3DC & 0x80)) { + !(player->stateFlags2 & (0x4000 | 0x80))) { + if (this->playerStunWaitTimer == 0) { + if (!(this->flags & EN_RD_FLAG_CANNOT_FREEZE_PLAYER)) { player->actor.freezeTimer = 40; func_80123E90(globalCtx, &this->actor); GET_PLAYER(globalCtx)->unk_A78 = &this->actor; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); } - this->unk_3ED = 60; + this->playerStunWaitTimer = 60; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); } } else { - func_808D53C0(this, globalCtx); + EnRd_SetupWalkToHome(this, globalCtx); } } - if (this->unk_3EE != 0) { - this->unk_3EE--; + if (this->grabWaitTimer != 0) { + this->grabWaitTimer--; } - if (!this->unk_3EE && (Actor_DistanceBetweenActors(&this->actor, &player->actor) <= 45.0f) && + if (!this->grabWaitTimer && (Actor_DistanceBetweenActors(&this->actor, &player->actor) <= 45.0f) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { player->actor.freezeTimer = 0; if ((player->transformation == PLAYER_FORM_GORON) || (player->transformation == PLAYER_FORM_DEKU)) { if (Actor_DistanceToPoint(&this->actor, &this->actor.home.pos) < 150.0f) { - func_808D5D88(this); + // If the Gibdo/Redead tries to grab Goron or Deku Link, it will fail to + // do so. It will appear to take damage and shake its head side-to-side. + EnRd_SetupGrabFail(this); } else { - func_808D53C0(this, globalCtx); + EnRd_SetupWalkToHome(this, globalCtx); } } else if (globalCtx->grabPlayer(globalCtx, player)) { - this->actor.flags &= ~1; - func_808D586C(this); + this->actor.flags &= ~ACTOR_FLAG_1; + EnRd_SetupGrab(this); } - } else if (this->actor.params > ENRD_GET_0) { + } else if (EN_RD_GET_TYPE(&this->actor) > EN_RD_TYPE_DOES_NOT_MOURN_IF_WALKING) { if (this->actor.parent != NULL) { - func_808D5660(this); + EnRd_SetupWalkToParent(this); } else { - this->unk_3EC = 0; + this->isMourning = false; } } @@ -611,14 +704,14 @@ void func_808D506C(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D53C0(EnRd* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &object_rd_Anim_0113EC, 0.5f, 0.0f, - Animation_GetLastFrame(&object_rd_Anim_0113EC), 1, -4.0f); - this->unk_3EF = 2; - this->actionFunc = func_808D5440; +void EnRd_SetupWalkToHome(EnRd* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, Animation_GetLastFrame(&gGibdoRedeadWalkAnim), + 1, -4.0f); + this->action = EN_RD_ACTION_WALKING_TO_HOME; + this->actionFunc = EnRd_WalkToHome; } -void func_808D5440(EnRd* this, GlobalContext* globalCtx) { +void EnRd_WalkToHome(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad; s16 sp36 = Actor_YawToPoint(&this->actor, &this->actor.home.pos); @@ -628,30 +721,30 @@ void func_808D5440(EnRd* this, GlobalContext* globalCtx) { } else { this->actor.speedXZ = 0.0f; if (!Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 450, 0)) { - if (this->actor.params != ENRD_GET_2) { - func_808D4308(this); + if (EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) { + EnRd_SetupIdle(this); } else { - func_808D60B0(this); + EnRd_SetupCrouch(this); } } } - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); this->actor.world.rot.y = this->actor.shape.rot.y; SkelAnime_Update(&this->skelAnime); if (!(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && - !(player->stateFlags2 & 0x4080) && (player->transformation != PLAYER_FORM_GORON) && + !(player->stateFlags2 & (0x4000 | 0x80)) && (player->transformation != PLAYER_FORM_GORON) && (player->transformation != PLAYER_FORM_DEKU) && (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 150.0f)) { this->actor.targetMode = 0; - func_808D4FE0(this, globalCtx); - } else if (this->actor.params > ENRD_GET_0) { + EnRd_SetupWalkToPlayer(this, globalCtx); + } else if (EN_RD_GET_TYPE(&this->actor) > EN_RD_TYPE_DOES_NOT_MOURN_IF_WALKING) { if (this->actor.parent != NULL) { - func_808D5660(this); + EnRd_SetupWalkToParent(this); } else { - this->unk_3EC = 0; + this->isMourning = false; } } @@ -662,39 +755,45 @@ void func_808D5440(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D5660(EnRd* this) { - f32 frameCount = Animation_GetLastFrame(&object_rd_Anim_0113EC); +void EnRd_SetupWalkToParent(EnRd* this) { + f32 frameCount = Animation_GetLastFrame(&gGibdoRedeadWalkAnim); - Animation_Change(&this->skelAnime, &object_rd_Anim_0113EC, 0.5f, 0.0f, frameCount, 1, -4.0f); - this->unk_3EF = 3; - this->unk_3EC = 1; - this->actionFunc = func_808D56E4; + Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, frameCount, 1, -4.0f); + this->action = EN_RD_ACTION_WALKING_TO_PARENT; + this->isMourning = true; + this->actionFunc = EnRd_WalkToParent; } -void func_808D56E4(EnRd* this, GlobalContext* globalCtx) { +/** + * When a Redead or Gibdo dies, it sets itself to be the parent for all other + * Redeads in the area that are capable of mourning. This function will make + * these Redeads walk over to the corpse and stand near until it begins to + * fade away. + */ +void EnRd_WalkToParent(EnRd* this, GlobalContext* globalCtx) { s32 pad; s16 yaw; - Vec3f sp2C; + Vec3f parentPos; if (this->actor.parent != NULL) { - sp2C = this->actor.parent->world.pos; - yaw = Actor_YawToPoint(&this->actor, &sp2C); + parentPos = this->actor.parent->world.pos; + yaw = Actor_YawToPoint(&this->actor, &parentPos); Math_SmoothStepToS(&this->actor.shape.rot.y, yaw, 1, 250, 0); - if (Actor_DistanceToPoint(&this->actor, &sp2C) >= 45.0f) { + if (Actor_DistanceToPoint(&this->actor, &parentPos) >= 45.0f) { this->actor.speedXZ = 0.4f; } else { this->actor.speedXZ = 0.0f; - if (this->actor.params != ENRD_GET_2) { - func_808D4308(this); + if (EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) { + EnRd_SetupIdle(this); } else { - func_808D60B0(this); + EnRd_SetupCrouch(this); } } - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); } else { - func_808D4FE0(this, globalCtx); + EnRd_SetupWalkToPlayer(this, globalCtx); } this->actor.world.rot.y = this->actor.shape.rot.y; @@ -707,57 +806,57 @@ void func_808D56E4(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D586C(EnRd* this) { - Animation_PlayOnce(&this->skelAnime, &object_rd_Anim_006EEC); - this->unk_3D6 = 0; - this->unk_3EB = 0; - this->unk_3EA = 200; - this->unk_3EF = 10; +void EnRd_SetupGrab(EnRd* this) { + Animation_PlayOnce(&this->skelAnime, &gGibdoRedeadGrabStartAnim); + this->animationJudderTimer = 0; + this->grabState = 0; + this->grabDamageTimer = 200; + this->action = EN_RD_ACTION_GRABBING; this->actor.speedXZ = 0.0f; - this->actionFunc = func_808D58CC; + this->actionFunc = EnRd_Grab; } -void func_808D58CC(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Grab(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad; if (SkelAnime_Update(&this->skelAnime)) { - this->unk_3EB++; + this->grabState++; } - switch (this->unk_3EB) { - case 1: - Animation_PlayLoop(&this->skelAnime, &object_rd_Anim_006678); - this->unk_3EB++; + switch (this->grabState) { + case EN_RD_GRAB_INITIAL_DAMAGE: + Animation_PlayLoop(&this->skelAnime, &gGibdoRedeadGrabAttackAnim); + this->grabState++; globalCtx->damagePlayer(globalCtx, -8); func_8013ECE0(this->actor.xzDistToPlayer, 255, 1, 12); - this->unk_3EA = 20; + this->grabDamageTimer = 20; - case 0: - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 1500, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 1500, 0); + case EN_RD_GRAB_START: + Math_SmoothStepToS(&this->headYRotation, 0, 1, 1500, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 1500, 0); - case 2: + case EN_RD_GRAB_ATTACK: if (!(player->stateFlags2 & 0x80) || (player->unk_B62 != 0)) { if ((player->unk_B62 != 0) && (player->stateFlags2 & 0x80)) { player->stateFlags2 &= ~0x80; player->unk_AE8 = 100; } - Animation_Change(&this->skelAnime, &object_rd_Anim_006B08, 0.5f, 0.0f, - Animation_GetLastFrame(&object_rd_Anim_006B08), 3, 0.0f); - this->unk_3EB++; - this->unk_3EF = 4; + Animation_Change(&this->skelAnime, &gGibdoRedeadGrabEndAnim, 0.5f, 0.0f, + Animation_GetLastFrame(&gGibdoRedeadGrabEndAnim), 3, 0.0f); + this->grabState++; + this->action = EN_RD_ACTION_WALKING_TO_PLAYER_OR_RELEASING_GRAB; break; } switch (player->transformation) { - case 0: - case 1: - case 2: - case 3: + case PLAYER_FORM_FIERCE_DEITY: + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + case PLAYER_FORM_DEKU: break; - case 4: + case PLAYER_FORM_HUMAN: Math_SmoothStepToF(&this->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); break; } @@ -775,144 +874,145 @@ void func_808D58CC(EnRd* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_ATTACK); } - this->unk_3EA--; - if (this->unk_3EA == 0) { + this->grabDamageTimer--; + if (this->grabDamageTimer == 0) { globalCtx->damagePlayer(globalCtx, -8); func_8013ECE0(this->actor.xzDistToPlayer, 240, 1, 12); - this->unk_3EA = 20; - func_800B8E58(player, player->ageProperties->unk_92 + 0x6805); + this->grabDamageTimer = 20; + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); } break; - case 3: + case EN_RD_GRAB_RELEASE: if (player->transformation != PLAYER_FORM_FIERCE_DEITY) { Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 1.0f, 400.0f, 0.0f); } break; - case 4: + case EN_RD_GRAB_END: if (player->transformation != PLAYER_FORM_FIERCE_DEITY) { Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 1.0f, 400.0f, 0.0f); } this->actor.targetMode = 0; - this->actor.flags |= 1; - this->unk_3ED = 10; - this->unk_3EE = 15; - func_808D4FE0(this, globalCtx); + this->actor.flags |= ACTOR_FLAG_1; + this->playerStunWaitTimer = 10; + this->grabWaitTimer = 15; + EnRd_SetupWalkToPlayer(this, globalCtx); break; } } -void func_808D5C54(EnRd* this) { - Animation_Change(&this->skelAnime, &object_rd_Anim_0073A4, 0.0f, 0.0f, - Animation_GetLastFrame(&object_rd_Anim_0073A4), 2, 0.0f); - this->unk_3EF = 7; - this->actionFunc = func_808D5CCC; +void EnRd_SetupAttemptPlayerFreeze(EnRd* this) { + Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, + Animation_GetLastFrame(&gGibdoRedeadLookBackAnim), 2, 0.0f); + this->action = EN_RD_ACTION_ATTEMPTING_PLAYER_STUN; + this->actionFunc = EnRd_AttemptPlayerFreeze; } -void func_808D5CCC(EnRd* this, GlobalContext* globalCtx) { +void EnRd_AttemptPlayerFreeze(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s16 temp_v0 = ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_3D8) - this->unk_3DA; + s16 yaw = + ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->headYRotation) - this->upperBodyYRotation; - if (ABS_ALT(temp_v0) < 0x2008) { - if (!(this->unk_3DC & 0x80)) { + if (ABS_ALT(yaw) < 0x2008) { + if (!(this->flags & EN_RD_FLAG_CANNOT_FREEZE_PLAYER)) { player->actor.freezeTimer = 60; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(globalCtx, &this->actor); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); - func_808D4FE0(this, globalCtx); + EnRd_SetupWalkToPlayer(this, globalCtx); } } -void func_808D5D88(EnRd* this) { - this->unk_3EF = 8; - Animation_MorphToPlayOnce(&this->skelAnime, &object_rd_Anim_009900, -6.0f); +void EnRd_SetupGrabFail(EnRd* this) { + this->action = EN_RD_ACTION_FAILING_GRAB; + Animation_MorphToPlayOnce(&this->skelAnime, &gGibdoRedeadDamageAnim, -6.0f); this->actor.speedXZ = -2.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); - this->unk_3EF = 8; - this->actionFunc = func_808D5DF4; + this->action = EN_RD_ACTION_FAILING_GRAB; + this->actionFunc = EnRd_GrabFail; } -void func_808D5DF4(EnRd* this, GlobalContext* globalCtx) { +void EnRd_GrabFail(EnRd* this, GlobalContext* globalCtx) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 300, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 300, 0); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 300, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 300, 0); if (SkelAnime_Update(&this->skelAnime)) { this->actor.world.rot.y = this->actor.shape.rot.y; - func_808D5E98(this); + EnRd_SetupTurnAwayAndShakeHead(this); } } -void func_808D5E98(EnRd* this) { - f32 frameCount = Animation_GetLastFrame(&object_rd_Anim_0113EC); +void EnRd_SetupTurnAwayAndShakeHead(EnRd* this) { + f32 frameCount = Animation_GetLastFrame(&gGibdoRedeadWalkAnim); - Animation_Change(&this->skelAnime, &object_rd_Anim_0113EC, 0.5f, 0.0f, frameCount, 1, -4.0f); - this->unk_3EF = 9; - this->unk_3D4 = 0; - this->actionFunc = func_808D5F18; + Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, frameCount, 1, -4.0f); + this->action = EN_RD_ACTION_TURNING_AWAY_AND_SHAKING_HEAD; + this->headShakeTimer = 0; + this->actionFunc = EnRd_TurnAwayAndShakeHead; } -void func_808D5F18(EnRd* this, GlobalContext* globalCtx) { +void EnRd_TurnAwayAndShakeHead(EnRd* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 5, 3500, 200); this->actor.shape.rot.y = this->actor.world.rot.y; - if (this->unk_3D4 > 60) { - func_808D53C0(this, globalCtx); - this->unk_3D4 = 0; + if (this->headShakeTimer > 60) { + EnRd_SetupWalkToHome(this, globalCtx); + this->headShakeTimer = 0; } else { - this->unk_3D8 = Math_SinS(this->unk_3D4 * 4000) * (9583.0f * ((60 - this->unk_3D4) / 60.0f)); + this->headYRotation = Math_SinS(this->headShakeTimer * 4000) * (0x256F * ((60 - this->headShakeTimer) / 60.0f)); SkelAnime_Update(&this->skelAnime); - this->unk_3D4++; + this->headShakeTimer++; } } -void func_808D6008(EnRd* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_rd_Anim_00A450, -4.0f); - this->unk_3EF = 5; - this->actionFunc = func_808D6054; +void EnRd_SetupStandUp(EnRd* this) { + Animation_MorphToPlayOnce(&this->skelAnime, &gGibdoRedeadStandUpAnim, -4.0f); + this->action = EN_RD_ACTION_STANDING_UP; + this->actionFunc = EnRd_StandUp; } -void func_808D6054(EnRd* this, GlobalContext* globalCtx) { +void EnRd_StandUp(EnRd* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { if (this->actor.parent != NULL) { - func_808D5660(this); + EnRd_SetupWalkToParent(this); } else { - func_808D5C54(this); + EnRd_SetupAttemptPlayerFreeze(this); } } } -void func_808D60B0(EnRd* this) { - Animation_Change(&this->skelAnime, &object_rd_Anim_00A450, -1.0f, Animation_GetLastFrame(&object_rd_Anim_00A450), - 0.0f, 2, -4.0f); - this->unk_3EF = 6; - this->actionFunc = func_808D6130; +void EnRd_SetupCrouch(EnRd* this) { + Animation_Change(&this->skelAnime, &gGibdoRedeadStandUpAnim, -1.0f, + Animation_GetLastFrame(&gGibdoRedeadStandUpAnim), 0.0f, 2, -4.0f); + this->action = EN_RD_ACTION_CROUCHING; + this->actionFunc = EnRd_Crouch; } -void func_808D6130(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Crouch(EnRd* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { - func_808D4308(this); + EnRd_SetupIdle(this); } } -void func_808D616C(EnRd* this) { +void EnRd_SetupDamage(EnRd* this) { this->actor.shape.yOffset = 0.0f; - Animation_MorphToPlayOnce(&this->skelAnime, &object_rd_Anim_009900, -6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gGibdoRedeadDamageAnim, -6.0f); if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -2.0f; } - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); - this->unk_3EF = 11; - this->actionFunc = func_808D6200; + this->action = EN_RD_ACTION_DAMAGE; + this->actionFunc = EnRd_Damage; } -void func_808D6200(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Damage(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (this->actor.speedXZ < 0.0f) { @@ -920,95 +1020,95 @@ void func_808D6200(EnRd* this, GlobalContext* globalCtx) { } this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 300, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 300, 0); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 300, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 300, 0); if (SkelAnime_Update(&this->skelAnime)) { this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.parent != NULL) { - func_808D5660(this); + EnRd_SetupWalkToParent(this); } else if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { - func_808D53C0(this, globalCtx); + EnRd_SetupWalkToHome(this, globalCtx); } else { - func_808D4FE0(this, globalCtx); + EnRd_SetupWalkToPlayer(this, globalCtx); } this->unk_3F1 = -1; } } -void func_808D6310(EnRd* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_rd_Anim_009298, -1.0f); - this->unk_3EF = 12; - this->unk_3D6 = 300; - this->actor.flags &= ~1; +void EnRd_SetupDead(EnRd* this) { + Animation_MorphToPlayOnce(&this->skelAnime, &gGibdoRedeadDeathAnim, -1.0f); + this->action = EN_RD_ACTION_DEAD; + this->deathTimer = 300; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); - this->actionFunc = func_808D6388; + this->actionFunc = EnRd_Dead; } -void func_808D6388(EnRd* this, GlobalContext* globalCtx) { - if (this->actor.category != 6) { - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 6); +void EnRd_Dead(EnRd* this, GlobalContext* globalCtx) { + if (this->actor.category != ACTORCAT_PROP) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); } - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 2000, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 2000, 0); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 2000, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 2000, 0); if (SkelAnime_Update(&this->skelAnime)) { - if (this->unk_3D6 == 0) { - if (!Flags_GetSwitch(globalCtx, this->unk_3DC & 0x7F)) { - Flags_SetSwitch(globalCtx, this->unk_3DC & 0x7F); + if (this->deathTimer == 0) { + if (!Flags_GetSwitch(globalCtx, EN_RD_GET_SWITCH_FLAG(this))) { + Flags_SetSwitch(globalCtx, EN_RD_GET_SWITCH_FLAG(this)); } - if (this->unk_3DE != 0) { - if (this->unk_3DE == 180) { - func_808D4190(globalCtx, this, 0); + if (this->alpha != 0) { + if (this->alpha == 180) { + EnRd_UpdateParentForOtherRedeads(globalCtx, &this->actor, false); } this->actor.scale.y -= (75.0f / 1000000.0f); - this->unk_3DE -= 5; + this->alpha -= 5; } else { Actor_MarkForDeath(&this->actor); } } else { - this->unk_3D6--; + this->deathTimer--; } } else if (Animation_OnFrame(&this->skelAnime, 33.0f) || Animation_OnFrame(&this->skelAnime, 40.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); } } -void func_808D64D0(EnRd* this) { - this->unk_3EF = 1; - this->unk_3D6 = 0xA; +void EnRd_SetupStunned(EnRd* this) { + this->action = EN_RD_ACTION_STUNNED; + this->stunTimer = 10; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; if (gSaveContext.sunsSongState != SUNSSONG_INACTIVE) { - this->unk_3E9 = 1; - this->unk_3E0 = 600; + this->stunnedBySunsSong = true; + this->sunsSongStunTimer = 600; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIGHT_ARROW_HIT); Actor_SetColorFilter(&this->actor, 0x8000, 0x80C8, 0, 255); - } else if (this->unk_3F0 == 1) { + } else if (this->damageEffect == EN_RD_DMGEFF_STUN) { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 40); - } else if (this->unk_3F0 == 12) { + } else if (this->damageEffect == EN_RD_DMGEFF_ZORA_MAGIC) { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 40); } - this->actionFunc = func_808D65BC; + this->actionFunc = EnRd_Stunned; } -void func_808D65BC(EnRd* this, GlobalContext* globalCtx) { - if (this->unk_3D6 > 0) { - this->unk_3D6--; +void EnRd_Stunned(EnRd* this, GlobalContext* globalCtx) { + if (this->stunTimer > 0) { + this->stunTimer--; } - if (this->unk_3E9 != 0) { - if (this->unk_3E0 != 0) { - this->unk_3E0--; - if (this->unk_3E0 >= 255) { + if (this->stunnedBySunsSong) { + if (this->sunsSongStunTimer != 0) { + this->sunsSongStunTimer--; + if (this->sunsSongStunTimer >= 255) { Actor_SetColorFilter(&this->actor, 0x8000, 0x80C8, 0, 255); } - if (this->unk_3E0 == 0) { - this->unk_3E9 = 0; + if (this->sunsSongStunTimer == 0) { + this->stunnedBySunsSong = false; gSaveContext.sunsSongState = SUNSSONG_INACTIVE; } } @@ -1016,49 +1116,50 @@ void func_808D65BC(EnRd* this, GlobalContext* globalCtx) { if (this->actor.colorFilterTimer == 0) { if (this->actor.colChkInfo.health == 0) { - func_808D4190(globalCtx, this, 1); - func_808D6310(this); + EnRd_UpdateParentForOtherRedeads(globalCtx, &this->actor, true); + EnRd_SetupDead(this); Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); } else { - func_808D616C(this); + EnRd_SetupDamage(this); } } } -void func_808D66A0(EnRd* this, GlobalContext* globalCtx) { - s16 phi_v0 = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_3DA; - s16 temp_v0 = CLAMP(phi_v0, -0x1F4, 0x1F4); +void EnRd_TurnTowardsPlayer(EnRd* this, GlobalContext* globalCtx) { + s16 headAngle = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->upperBodyYRotation; + s16 upperBodyAngle = CLAMP(headAngle, -500, 500); - phi_v0 -= this->unk_3D8; - phi_v0 = CLAMP(phi_v0, -0x1F4, 0x1F4); + headAngle -= this->headYRotation; + headAngle = CLAMP(headAngle, -500, 500); if (BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y) >= 0) { - this->unk_3DA += ABS_ALT(temp_v0); - this->unk_3D8 += ABS_ALT(phi_v0); + this->upperBodyYRotation += ABS_ALT(upperBodyAngle); + this->headYRotation += ABS_ALT(headAngle); } else { - this->unk_3DA -= ABS_ALT(temp_v0); - this->unk_3D8 -= ABS_ALT(phi_v0); + this->upperBodyYRotation -= ABS_ALT(upperBodyAngle); + this->headYRotation -= ABS_ALT(headAngle); } - this->unk_3DA = CLAMP(this->unk_3DA, -0x495F, 0x495F); - this->unk_3D8 = CLAMP(this->unk_3D8, -0x256F, 0x256F); + this->upperBodyYRotation = CLAMP(this->upperBodyYRotation, -0x495F, 0x495F); + this->headYRotation = CLAMP(this->headYRotation, -0x256F, 0x256F); } -void func_808D6814(EnRd* this, GlobalContext* globalCtx) { +void EnRd_UpdateDamage(EnRd* this, GlobalContext* globalCtx) { s32 pad; Player* player = GET_PLAYER(globalCtx); - if ((gSaveContext.sunsSongState != SUNSSONG_INACTIVE) && (this->actor.shape.rot.x == 0) && (this->unk_3E9 == 0) && - (this->unk_3EF != 11) && (this->unk_3EF != 12) && (this->unk_3EF != 1)) { - func_808D64D0(this); + if ((gSaveContext.sunsSongState != SUNSSONG_INACTIVE) && (this->actor.shape.rot.x == 0) && + (!this->stunnedBySunsSong) && (this->action != EN_RD_ACTION_DAMAGE) && (this->action != EN_RD_ACTION_DEAD) && + (this->action != EN_RD_ACTION_STUNNED)) { + EnRd_SetupStunned(this); return; } if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - this->unk_3F0 = this->actor.colChkInfo.damageEffect; + this->damageEffect = this->actor.colChkInfo.damageEffect; - if (this->unk_3EF == 13) { + if (this->action == EN_RD_ACTION_RISING_FROM_COFFIN) { return; } @@ -1068,49 +1169,48 @@ void func_808D6814(EnRd* this, GlobalContext* globalCtx) { this->unk_3F1 = player->unk_ADD; } - switch (this->unk_3F0) { - case 12: - if ((this->actionFunc != func_808D58CC) && - ((this->actionFunc != func_808D65BC) || (this->unk_3D6 == 0))) { - this->unk_3E6 = 40; - this->unk_3E8 = 30; - this->unk_294 = 1.0f; - func_808D64D0(this); + switch (this->damageEffect) { + case EN_RD_DMGEFF_ZORA_MAGIC: + if ((this->actionFunc != EnRd_Grab) && ((this->actionFunc != EnRd_Stunned) || (this->stunTimer == 0))) { + this->effectTimer = 40; + this->effectType = 30; + this->effectAlpha = 1.0f; + EnRd_SetupStunned(this); } return; - case 1: - func_808D64D0(this); + case EN_RD_DMGEFF_STUN: + EnRd_SetupStunned(this); return; - case 2: + case EN_RD_DMGEFF_FIRE_ARROW: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); - this->unk_3E6 = 180; - this->unk_3E8 = 0; - this->unk_3E9 = 0; - this->unk_3E0 = 0; - this->unk_294 = 1.0f; + this->effectTimer = 180; + this->effectType = 0; + this->stunnedBySunsSong = false; + this->sunsSongStunTimer = 0; + this->effectAlpha = 1.0f; break; - case 4: + case EN_RD_DMGEFF_LIGHT_ARROW: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); - this->unk_3E6 = 60; - this->unk_3E8 = 20; - this->unk_3E9 = 0; - this->unk_3E0 = 0; - this->unk_294 = 1.0f; + this->effectTimer = 60; + this->effectType = 20; + this->stunnedBySunsSong = false; + this->sunsSongStunTimer = 0; + this->effectAlpha = 1.0f; break; - case 15: + case EN_RD_DMGEFF_DAMAGE: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - this->unk_3E9 = 0; - this->unk_3E0 = 0; + this->stunnedBySunsSong = false; + this->sunsSongStunTimer = 0; break; - case 14: + case EN_RD_DMGEFF_LIGHT_RAY: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - this->unk_3E9 = 0; - this->unk_3E0 = 0; + this->stunnedBySunsSong = false; + this->sunsSongStunTimer = 0; this->actor.colChkInfo.health = 0; break; @@ -1120,84 +1220,87 @@ void func_808D6814(EnRd* this, GlobalContext* globalCtx) { Actor_ApplyDamage(&this->actor); if (this->actor.colChkInfo.health == 0) { - func_808D4190(globalCtx, this, 1); - func_808D6310(this); + EnRd_UpdateParentForOtherRedeads(globalCtx, &this->actor, true); + EnRd_SetupDead(this); Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0x90); } else { - func_808D616C(this); + EnRd_SetupDamage(this); } } } -void func_808D6A94(EnRd* this, GlobalContext* globalCtx) { +void EnRd_UpdateCollision(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((this->actor.colChkInfo.health > 0) && (this->unk_3EF != 10)) { + if ((this->actor.colChkInfo.health > 0) && (this->action != EN_RD_ACTION_GRABBING)) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (((this->unk_3EF != 11) || ((player->unk_ADC != 0) && (player->unk_ADD != this->unk_3F1))) && - ((this->actionFunc != func_808D65BC) || (this->unk_3D6 == 0))) { + if (((this->action != EN_RD_ACTION_DAMAGE) || ((player->unk_ADC != 0) && (player->unk_ADD != this->unk_3F1))) && + ((this->actionFunc != EnRd_Stunned) || (this->stunTimer == 0))) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } } } -void func_808D6B64(EnRd* this, GlobalContext* globalCtx) { - if (this->unk_3E6 > 0) { - this->unk_3E6--; +void EnRd_UpdateEffect(EnRd* this, GlobalContext* globalCtx) { + if (this->effectTimer > 0) { + this->effectTimer--; } - if (this->unk_3E6 < 20) { - Math_SmoothStepToF(&this->unk_298, 0.0f, 0.5f, 0.03f, 0.0f); - this->unk_294 = this->unk_3E6 * 0.05f; + if (this->effectTimer < 20) { + Math_SmoothStepToF(&this->effectScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->effectAlpha = this->effectTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_298, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->effectScale, 0.5f, 0.1f, 0.02f, 0.0f); } } void EnRd_Update(Actor* thisx, GlobalContext* globalCtx) { EnRd* this = THIS; - func_808D6814(this, globalCtx); - if ((gSaveContext.sunsSongState != SUNSSONG_INACTIVE) && (this->unk_3E9 == 0)) { + EnRd_UpdateDamage(this, globalCtx); + if ((gSaveContext.sunsSongState != SUNSSONG_INACTIVE) && (!this->stunnedBySunsSong)) { gSaveContext.sunsSongState = SUNSSONG_INACTIVE; } - if ((this->unk_3F0 != 6) && ((this->unk_3EF != 13) || (this->unk_3F0 != 2))) { - if (this->unk_3ED != 0) { - this->unk_3ED--; + if ((this->damageEffect != EN_RD_DMGEFF_UNUSED_6) && + ((this->action != EN_RD_ACTION_RISING_FROM_COFFIN) || (this->damageEffect != EN_RD_DMGEFF_FIRE_ARROW))) { + if (this->playerStunWaitTimer != 0) { + this->playerStunWaitTimer--; } this->actionFunc(this, globalCtx); - if ((this->unk_3EF != 10) && (this->actor.speedXZ != 0.0f)) { + if ((this->action != EN_RD_ACTION_GRABBING) && (this->actor.speedXZ != 0.0f)) { Actor_MoveWithGravity(&this->actor); } - if ((this->actor.shape.rot.x == 0) && (this->unk_3EF != 10) && (this->actor.speedXZ != 0.0f)) { + if ((this->actor.shape.rot.x == 0) && (this->action != EN_RD_ACTION_GRABBING) && + (this->actor.speedXZ != 0.0f)) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 35.0f, 0x1D); } - if (this->unk_3EF == 7) { - func_808D66A0(this, globalCtx); + if (this->action == EN_RD_ACTION_ATTEMPTING_PLAYER_STUN) { + EnRd_TurnTowardsPlayer(this, globalCtx); } } this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 50.0f; - func_808D6A94(this, globalCtx); - func_808D4260(this, globalCtx); - func_808D6B64(this, globalCtx); + + EnRd_UpdateCollision(this, globalCtx); + EnRd_SetupDanceIfConditionsMet(this, globalCtx); + EnRd_UpdateEffect(this, globalCtx); } s32 EnRd_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnRd* this = THIS; - if (limbIndex == 23) { - rot->y += this->unk_3D8; - } else if (limbIndex == 12) { - rot->y += this->unk_3DA; + if (limbIndex == REDEAD_LIMB_HEAD_ROOT) { + rot->y += this->headYRotation; + } else if (limbIndex == REDEAD_LIMB_UPPER_BODY_ROOT) { + rot->y += this->upperBodyYRotation; } return false; } @@ -1205,12 +1308,17 @@ s32 EnRd_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnRd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnRd* this = THIS; - if ((this->unk_3E6 != 0) && - ((limbIndex == 3) || (limbIndex == 4) || (limbIndex == 6) || (limbIndex == 8) || (limbIndex == 9) || - (limbIndex == 11) || (limbIndex == 14) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18) || - (limbIndex == 20) || (limbIndex == 21) || (limbIndex == 22) || (limbIndex == 24) || (limbIndex == 25))) { - Matrix_GetStateTranslation(&this->unk_1DC[this->unk_290]); - this->unk_290++; + if ((this->effectTimer != 0) && + ((limbIndex == REDEAD_LIMB_LEFT_THIGH) || (limbIndex == REDEAD_LIMB_LEFT_SHIN) || + (limbIndex == REDEAD_LIMB_LEFT_FOOT) || (limbIndex == REDEAD_LIMB_RIGHT_THIGH) || + (limbIndex == REDEAD_LIMB_RIGHT_SHIN) || (limbIndex == REDEAD_LIMB_RIGHT_FOOT) || + (limbIndex == REDEAD_LIMB_TORSO) || (limbIndex == REDEAD_LIMB_LEFT_SHOULDER_AND_UPPER_ARM) || + (limbIndex == REDEAD_LIMB_LEFT_FOREARM) || (limbIndex == REDEAD_LIMB_LEFT_HAND) || + (limbIndex == REDEAD_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || (limbIndex == REDEAD_LIMB_RIGHT_FOREARM) || + (limbIndex == REDEAD_LIMB_RIGHT_HAND) || (limbIndex == REDEAD_LIMB_HEAD) || + (limbIndex == REDEAD_LIMB_PELVIS))) { + Matrix_GetStateTranslation(&this->limbPos[this->limbIndex]); + this->limbIndex++; } } @@ -1222,12 +1330,12 @@ void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - this->unk_290 = 0; + this->limbIndex = 0; - if (this->unk_3DE == 255) { + if (this->alpha == 255) { func_8012C28C(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->unk_3DE); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->alpha); gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, @@ -1238,19 +1346,19 @@ void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx) { } else { func_8012C2DC(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_3DE); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnRd_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); - func_800BC620(&sp54, &D_808D7138, this->unk_3DE, globalCtx); + func_800BC620(&sp54, &D_808D7138, this->alpha, globalCtx); } CLOSE_DISPS(globalCtx->state.gfxCtx); - if (this->unk_3E6 > 0) { - func_800BE680(globalCtx, &this->actor, this->unk_1DC, ARRAY_COUNT(this->unk_1DC), this->unk_298, 0.5f, - this->unk_294, this->unk_3E8); + if (this->effectTimer > 0) { + func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->effectScale, 0.5f, + this->effectAlpha, this->effectType); } } diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.h b/src/overlays/actors/ovl_En_Rd/z_en_rd.h index 2c6637d76..0340c7833 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.h +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.h @@ -2,58 +2,74 @@ #define Z_EN_RD_H #include "global.h" +#include "objects/object_rd/object_rd.h" struct EnRd; typedef void (*EnRdActionFunc)(struct EnRd*, GlobalContext*); -typedef void (*EnRdFunc)(struct EnRd*); +typedef void (*EnRdSetupDanceFunc)(struct EnRd*); -#define ENRD_GET_80(thisx) ((thisx)->params & 0x80) -#define ENRD_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) +#define EN_RD_GET_80(thisx) ((thisx)->params & 0x80) +#define EN_RD_GET_FLAGS(thisx) (((thisx)->params & 0xFF00) >> 8) +#define EN_RD_GET_TYPE(thisx) ((thisx)->params) +#define EN_RD_GET_SWITCH_FLAG(this) ((this)->flags & 0x7F) -enum { - /* -2 */ ENRD_GET_MINUS_2 = -2, - /* -1 */ ENRD_GET_MINUS_1 = -1, - /* 0x00 */ ENRD_GET_0 = 0, - /* 0x01 */ ENRD_GET_1, - /* 0x02 */ ENRD_GET_2, - /* 0x03 */ ENRD_GET_3, - /* 0x04 */ ENRD_GET_4, - /* 0x05 */ ENRD_GET_5, -}; +#define EN_RD_FLAG_CANNOT_FREEZE_PLAYER (1 << 7) + +typedef enum { + /* -3 */ EN_RD_TYPE_GIBDO_RISING_OUT_OF_COFFIN = -3, // Unused OoT leftover + /* -2 */ EN_RD_TYPE_GIBDO = -2, // Unused OoT leftover + /* -1 */ EN_RD_TYPE_DOES_NOT_MOURN = -1, // Unused OoT leftover + /* 0 */ EN_RD_TYPE_DOES_NOT_MOURN_IF_WALKING = 0, // Unused OoT leftover. Still mourns, but it must come to a complete stop first + /* 1 */ EN_RD_TYPE_REGULAR, // Unused OoT leftover + /* 2 */ EN_RD_TYPE_CRYING, // Unused in the final game + /* 3 */ EN_RD_TYPE_INVISIBLE, // Unused OoT leftover + /* 4 */ EN_RD_TYPE_FROZEN, // Unused in the final game + /* 5 */ EN_RD_TYPE_SQUATTING_DANCE, + /* 6 */ EN_RD_TYPE_CLAPPING_DANCE, + /* 7 */ EN_RD_TYPE_PIROUETTE, +} EnRdType; typedef struct EnRd { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnRdActionFunc actionFunc; - /* 0x018C */ EnRdFunc unkFunc; + /* 0x018C */ EnRdSetupDanceFunc setupDanceFunc; /* 0x0190 */ ColliderCylinder collider; - /* 0x01DC */ Vec3f unk_1DC[15]; - /* 0x0290 */ s32 unk_290; - /* 0x0294 */ f32 unk_294; - /* 0x0298 */ f32 unk_298; - /* 0x029C */ Vec3s jointTable[26]; - /* 0x0338 */ Vec3s morphTable[26]; - /* 0x03D4 */ s16 unk_3D4; - /* 0x03D6 */ s16 unk_3D6; - /* 0x03D8 */ s16 unk_3D8; - /* 0x03DA */ s16 unk_3DA; - /* 0x03DC */ s16 unk_3DC; - /* 0x03DE */ s16 unk_3DE; - /* 0x03E0 */ s16 unk_3E0; - /* 0x03E2 */ s16 unk_3E2; - /* 0x03E4 */ s16 unk_3E4; - /* 0x03E6 */ s16 unk_3E6; - /* 0x03E8 */ u8 unk_3E8; - /* 0x03E9 */ u8 unk_3E9; - /* 0x03EA */ u8 unk_3EA; - /* 0x03EB */ u8 unk_3EB; - /* 0x03EC */ u8 unk_3EC; - /* 0x03ED */ u8 unk_3ED; - /* 0x03EE */ u8 unk_3EE; - /* 0x03EF */ u8 unk_3EF; - /* 0x03F0 */ u8 unk_3F0; - /* 0x03F1 */ s8 unk_3F1; + /* 0x01DC */ Vec3f limbPos[15]; + /* 0x0290 */ s32 limbIndex; + /* 0x0294 */ f32 effectAlpha; + /* 0x0298 */ f32 effectScale; + /* 0x029C */ Vec3s jointTable[REDEAD_LIMB_MAX]; + /* 0x0338 */ Vec3s morphTable[REDEAD_LIMB_MAX]; + /* 0x03D4 */ s16 headShakeTimer; + /* 0x03D6 */ union { + s16 animationJudderTimer; + s16 stunTimer; + s16 deathTimer; + s16 coffinRiseForwardAccelTimer; + }; + /* 0x03D8 */ s16 headYRotation; + /* 0x03DA */ s16 upperBodyYRotation; + /* 0x03DC */ s16 flags; + /* 0x03DE */ s16 alpha; + /* 0x03E0 */ s16 sunsSongStunTimer; + /* 0x03E2 */ UNK_TYPE1 unk3E2[0x2]; + /* 0x03E4 */ union { + s16 danceEndTimer; + s16 pirouetteRotationalVelocity; + }; + /* 0x03E6 */ s16 effectTimer; + /* 0x03E8 */ u8 effectType; + /* 0x03E9 */ u8 stunnedBySunsSong; + /* 0x03EA */ u8 grabDamageTimer; + /* 0x03EB */ u8 grabState; + /* 0x03EC */ u8 isMourning; + /* 0x03ED */ u8 playerStunWaitTimer; // Cannot stun the player if this is non-zero + /* 0x03EE */ u8 grabWaitTimer; // Cannot grab the player if this is non-zero + /* 0x03EF */ u8 action; + /* 0x03F0 */ u8 damageEffect; + /* 0x03F1 */ s8 unk_3F1; // related to player->unk_ADD } EnRd; // size = 0x3F4 extern const ActorInit En_Rd_InitVars; diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c index 9d19c68bf..eca7a621e 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c @@ -5,9 +5,8 @@ */ #include "z_en_talk_gibud.h" -#include "objects/object_rd/object_rd.h" -#define FLAGS 0x00000415 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnTalkGibud*)thisx) @@ -18,8 +17,8 @@ void EnTalkGibud_Draw(Actor* thisx, GlobalContext* globalCtx); void EnTalkGibud_SetupIdle(EnTalkGibud* this); void EnTalkGibud_Idle(EnTalkGibud* this, GlobalContext* globalCtx); -void EnTalkGibud_SetupAttemptPlayerStun(EnTalkGibud* this); -void EnTalkGibud_AttemptPlayerStun(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_SetupAttemptPlayerFreeze(EnTalkGibud* this); +void EnTalkGibud_AttemptPlayerFreeze(EnTalkGibud* this, GlobalContext* globalCtx); void EnTalkGibud_SetupWalkToPlayer(EnTalkGibud* this); void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx); void EnTalkGibud_SetupGrab(EnTalkGibud* this); @@ -55,23 +54,6 @@ typedef struct { /* 0xC */ s16 isBottledItem; } EnTalkGibudRequestedItem; -typedef enum { - /* 0 */ EN_TALK_GIBUD_ANIMATION_GRAB_ATTACK, - /* 1 */ EN_TALK_GIBUD_ANIMATION_GRAB_END, - /* 2 */ EN_TALK_GIBUD_ANIMATION_GRAB_START, - /* 3 */ EN_TALK_GIBUD_ANIMATION_LOOK_AWAY, - /* 4 */ EN_TALK_GIBUD_ANIMATION_CROUCH_WIPING_TEARS, - /* 5 */ EN_TALK_GIBUD_ANIMATION_CROUCH_CRYING, - /* 6 */ EN_TALK_GIBUD_ANIMATION_DEATH, - /* 7 */ EN_TALK_GIBUD_ANIMATION_DAMAGE, - /* 8 */ EN_TALK_GIBUD_ANIMATION_CROUCH_END, - /* 9 */ EN_TALK_GIBUD_ANIMATION_IDLE, - /* 10 */ EN_TALK_GIBUD_ANIMATION_WALK, - /* 11 */ EN_TALK_GIBUD_ANIMATION_DANCE_SQUAT, - /* 12 */ EN_TALK_GIBUD_ANIMATION_DANCE_PIROUETTE, - /* 13 */ EN_TALK_GIBUD_ANIMATION_DANCE_CLAP, -} EnTalkGibudAnimations; - typedef enum { /* 0 */ EN_TALK_GIBUD_REQUESTED_ITEM_MET, /* 1 */ EN_TALK_GIBUD_REQUESTED_ITEM_NOT_ENOUGH_AMMO, @@ -91,6 +73,34 @@ typedef enum { /* 9 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_MILK, } EnTalkGibudRequestedItemIndex; +typedef enum { + /* 0 */ EN_TALK_GIBUD_ANIMATION_GRAB_ATTACK, + /* 1 */ EN_TALK_GIBUD_ANIMATION_GRAB_END, + /* 2 */ EN_TALK_GIBUD_ANIMATION_GRAB_START, + /* 3 */ EN_TALK_GIBUD_ANIMATION_LOOK_BACK, + /* 4 */ EN_TALK_GIBUD_ANIMATION_CROUCH_WIPING_TEARS, + /* 5 */ EN_TALK_GIBUD_ANIMATION_CROUCH_CRYING, + /* 6 */ EN_TALK_GIBUD_ANIMATION_DEATH, + /* 7 */ EN_TALK_GIBUD_ANIMATION_DAMAGE, + /* 8 */ EN_TALK_GIBUD_ANIMATION_CROUCH_END, + /* 9 */ EN_TALK_GIBUD_ANIMATION_IDLE, + /* 10 */ EN_TALK_GIBUD_ANIMATION_WALK, + /* 11 */ EN_TALK_GIBUD_ANIMATION_DANCE_SQUAT, + /* 12 */ EN_TALK_GIBUD_ANIMATION_DANCE_PIROUETTE, + /* 13 */ EN_TALK_GIBUD_ANIMATION_DANCE_CLAP, +} EnTalkGibudAnimations; + +typedef enum { + /* 0 */ EN_TALK_GIBUD_TYPE_GIBDO, + /* 1 */ EN_TALK_GIBUD_TYPE_REDEAD, +} EnTalkGibudType; + +typedef enum { + /* 0 */ EN_TALK_GIBUD_GRAB_START, + /* 1 */ EN_TALK_GIBUD_GRAB_ATTACK, + /* 2 */ EN_TALK_GIBUD_GRAB_RELEASE, +} EnTalkGibudGrabState; + const ActorInit En_Talk_Gibud_InitVars = { ACTOR_EN_TALK_GIBUD, ACTORCAT_ENEMY, @@ -104,20 +114,20 @@ const ActorInit En_Talk_Gibud_InitVars = { }; static AnimationInfo sAnimations[] = { - { &object_rd_Anim_006678, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_rd_Anim_006B08, 0.5f, 0.0f, 0.0f, ANIMMODE_ONCE_INTERP, 0.0f }, - { &object_rd_Anim_006EEC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, - { &object_rd_Anim_0073A4, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, - { &object_rd_Anim_007BBC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, - { &object_rd_Anim_0081A8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_rd_Anim_009298, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, - { &object_rd_Anim_009900, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, - { &object_rd_Anim_00A450, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, - { &object_rd_Anim_00ABE0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_rd_Anim_0113EC, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -8.0f }, - { &object_rd_Anim_01216C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_rd_Anim_0118D8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_rd_Anim_011DB8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadGrabAttackAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadGrabEndAnim, 0.5f, 0.0f, 0.0f, ANIMMODE_ONCE_INTERP, 0.0f }, + { &gGibdoRedeadGrabStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadWipingTearsAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadSobbingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadDeathAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadDamageAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadStandUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadWalkAnim, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -8.0f }, + { &gGibdoRedeadSquattingDanceAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadPirouetteAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadClappingDanceAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -141,9 +151,9 @@ static ColliderCylinderInit sCylinderInit = { }; typedef enum { - /* 0x0 */ EN_TALK_GIBUD_DMGEFF_NONE, // Does not interact with the Gibdo/Redead at all - /* 0x1 */ EN_TALK_GIBUD_DMGEFF_STUN, // Stuns without applying any effect - /* 0x2 */ EN_TALK_GIBUD_DMGEFF_FIRE_ARROW, // Damages and changes a Gibdo into a Redead + /* 0x0 */ EN_TALK_GIBUD_DMGEFF_NONE, // Does not interact with the Gibdo/Redead at all + /* 0x1 */ EN_TALK_GIBUD_DMGEFF_STUN, // Stuns without applying any effect + /* 0x2 */ EN_TALK_GIBUD_DMGEFF_FIRE_ARROW, // Damages, applies a fire effect, and changes a Gibdo into a Redead /* 0x4 */ EN_TALK_GIBUD_DMGEFF_LIGHT_ARROW = 0x4, // Damages and applies a light effect /* 0xC */ EN_TALK_GIBUD_DMGEFF_ZORA_MAGIC = 0xC, // Stuns and applies an electric effect /* 0xD */ EN_TALK_GIBUD_DMGEFF_RECOIL, // Deals no damage, but displays hit mark and recoil animation @@ -220,12 +230,14 @@ void EnTalkGibud_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 0; this->actor.hintId = 0x2D; this->actor.textId = 0; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_0053E8, &object_rd_Anim_00ABE0, this->jointTable, - this->morphTable, EN_TALK_GIBUD_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGibdoSkel, &gGibdoRedeadIdleAnim, this->jointTable, + this->morphTable, GIBDO_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->playerStunWaitTimer = 0; this->grabState = EN_TALK_GIBUD_GRAB_START; this->grabWaitTimer = 0; @@ -246,6 +258,7 @@ void EnTalkGibud_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->requestedItemIndex < EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BLUE_POTION) { this->requestedItemIndex = EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BLUE_POTION; } + if (this->requestedItemIndex > EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_MILK) { this->requestedItemIndex = EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_MILK; } @@ -253,6 +266,7 @@ void EnTalkGibud_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->switchFlag == 0xFF) { this->switchFlag = -1; } + if (this->switchFlag != -1 && Flags_GetSwitch(globalCtx, this->switchFlag)) { Actor_MarkForDeath(&this->actor); } @@ -277,18 +291,19 @@ void EnTalkGibud_SetupIdle(EnTalkGibud* this) { */ void EnTalkGibud_Idle(EnTalkGibud* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer <= 150.0f && func_800B715C(globalCtx)) { - EnTalkGibud_SetupAttemptPlayerStun(this); + EnTalkGibud_SetupAttemptPlayerFreeze(this); } + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x64, 0); Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x64, 0); } -void EnTalkGibud_SetupAttemptPlayerStun(EnTalkGibud* this) { +void EnTalkGibud_SetupAttemptPlayerFreeze(EnTalkGibud* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); - this->actionFunc = EnTalkGibud_AttemptPlayerStun; + this->actionFunc = EnTalkGibud_AttemptPlayerFreeze; } -void EnTalkGibud_AttemptPlayerStun(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_AttemptPlayerFreeze(EnTalkGibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 rot = this->actor.shape.rot.y + this->headRotation.y + this->upperBodyRotation.y; s16 yaw = BINANG_SUB(this->actor.yawTowardsPlayer, rot); @@ -300,17 +315,20 @@ void EnTalkGibud_AttemptPlayerStun(EnTalkGibud* this, GlobalContext* globalCtx) Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); EnTalkGibud_SetupWalkToPlayer(this); } + EnTalkGibud_TurnTowardsPlayer(this, globalCtx); } void EnTalkGibud_SetupWalkToPlayer(EnTalkGibud* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); this->actor.speedXZ = 0.4f; - if (this->actionFunc == EnTalkGibud_AttemptPlayerStun) { + + if (this->actionFunc == EnTalkGibud_AttemptPlayerFreeze) { this->playerStunWaitTimer = 80; } else { this->playerStunWaitTimer = 20; } + this->actionFunc = EnTalkGibud_WalkToPlayer; } @@ -320,12 +338,13 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xFA); this->actor.world.rot = this->actor.shape.rot; - Math_SmoothStepToS(&this->headRotation.y, 0, 1, 100, 0); - Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 100, 0); + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x64, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x64, 0); + if (EnTalkGibud_PlayerInRangeWithCorrectState(this, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { - if (this->grabWaitTimer == 0 && this->actor.xzDistToPlayer <= 45.0f) { + if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { player->actor.freezeTimer = 0; - if (gSaveContext.playerForm == PLAYER_FORM_GORON || gSaveContext.playerForm == PLAYER_FORM_DEKU) { + if ((gSaveContext.playerForm == PLAYER_FORM_GORON) || (gSaveContext.playerForm == PLAYER_FORM_DEKU)) { // If the Gibdo/Redead tries to grab Goron or Deku Link, it will fail to // do so. It will appear to take damage and shake its head side-to-side. EnTalkGibud_SetupGrabFail(this); @@ -343,18 +362,19 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { this->playerStunWaitTimer--; } } - } else if (this->grabWaitTimer == 0 && this->actor.xzDistToPlayer <= 45.0f) { + } else if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { EnTalkGibud_SetupWalkToHome(this); } else if (EnTalkGibud_PlayerOutOfRange(this, globalCtx)) { EnTalkGibud_SetupWalkToHome(this); } + if (this->grabWaitTimer > 0) { this->grabWaitTimer--; } if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); - } else if (!(globalCtx->gameplayFrames & 0x5F)) { + } else if (!(globalCtx->gameplayFrames & 95)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } @@ -362,25 +382,21 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { void EnTalkGibud_SetupGrab(EnTalkGibud* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_START); this->grabDamageTimer = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->grabState = EN_TALK_GIBUD_GRAB_START; this->actionFunc = EnTalkGibud_Grab; } void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { - // This function needs to have two different temps for Player to match, - // but you don't have to necessarily use them both. This is just the most - // likely scenario; they got an Actor* pointer in the first temp, then - // casted it to Player* in the second temp. - Actor* playerActor = &GET_PLAYER(globalCtx)->actor; - Player* player = (Player*)playerActor; + Player* player2 = GET_PLAYER(globalCtx); + Player* player = player2; s32 inPositionToAttack; u16 damageSfxId; switch (this->grabState) { case EN_TALK_GIBUD_GRAB_START: inPositionToAttack = EnTalkGibud_MoveToIdealGrabPositionAndRotation(this, globalCtx); - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && inPositionToAttack == true) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (inPositionToAttack == true)) { this->grabState = EN_TALK_GIBUD_GRAB_ATTACK; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_ATTACK); } @@ -403,13 +419,14 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_ATTACK); } - if (!(player->stateFlags2 & 0x80) || player->unk_B62 != 0) { - if (player->unk_B62 != 0 && (player->stateFlags2 & 0x80)) { + if (!(player->stateFlags2 & 0x80) || (player->unk_B62 != 0)) { + if ((player->unk_B62 != 0) && (player->stateFlags2 & 0x80)) { player->stateFlags2 &= ~0x80; player->unk_AE8 = 100; } + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_END); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->grabState = EN_TALK_GIBUD_GRAB_RELEASE; this->grabDamageTimer = 0; } @@ -430,14 +447,15 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { void EnTalkGibud_SetupGrabFail(EnTalkGibud* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); - this->actionFunc = EnTalkGibud_GrabFail; this->actor.speedXZ = -2.0f; + this->actionFunc = EnTalkGibud_GrabFail; } void EnTalkGibud_GrabFail(EnTalkGibud* this, GlobalContext* globalCtx) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } + this->actor.world.rot.y = this->actor.yawTowardsPlayer; Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x12C, 0); Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x12C, 0); @@ -481,6 +499,7 @@ void EnTalkGibud_WalkToHome(EnTalkGibud* this, GlobalContext* globalCtx) { } else { this->actor.speedXZ = 0.0f; } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 200, 10); this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.world.rot.y == this->actor.home.rot.y) { @@ -491,7 +510,7 @@ void EnTalkGibud_WalkToHome(EnTalkGibud* this, GlobalContext* globalCtx) { this->actor.world.rot = this->actor.shape.rot; } if (EnTalkGibud_PlayerInRangeWithCorrectState(this, globalCtx)) { - if (gSaveContext.playerForm != PLAYER_FORM_GORON && gSaveContext.playerForm != PLAYER_FORM_DEKU && + if ((gSaveContext.playerForm != PLAYER_FORM_GORON) && (gSaveContext.playerForm != PLAYER_FORM_DEKU) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { EnTalkGibud_SetupWalkToPlayer(this); } @@ -502,11 +521,13 @@ void EnTalkGibud_SetupStunned(EnTalkGibud* this) { this->stunTimer = 10; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; + if (this->effectTimer != 0) { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } else { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } + this->actionFunc = EnTalkGibud_Stunned; } @@ -518,6 +539,7 @@ void EnTalkGibud_Stunned(EnTalkGibud* this, GlobalContext* globalCtx) { EnTalkGibud_SetupDamage(this); } } + if (this->stunTimer != 0) { this->stunTimer--; } @@ -529,25 +551,27 @@ void EnTalkGibud_SetupDamage(EnTalkGibud* this) { this->stunTimer = 0; this->grabWaitTimer = 0; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actionFunc = EnTalkGibud_Damage; this->actor.speedXZ = -2.0f; + this->actionFunc = EnTalkGibud_Damage; } void EnTalkGibud_Damage(EnTalkGibud* this, GlobalContext* globalCtx) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_3F7 = -1; this->actor.world.rot.y = this->actor.shape.rot.y; - if (this->effectTimer > 0 && this->effectType == 0 && this->type == EN_TALK_GIBUD_TYPE_GIBDO) { + if ((this->effectTimer > 0) && (this->effectType == 0) && (this->type == EN_TALK_GIBUD_TYPE_GIBDO)) { this->actor.hintId = 0x2A; - this->actor.flags &= ~(0x8 | 0x1); - this->actor.flags |= (0x4 | 0x1); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_010B88, NULL, this->jointTable, - this->morphTable, EN_TALK_GIBUD_LIMB_MAX); + this->actor.flags &= ~(ACTOR_FLAG_8 | ACTOR_FLAG_1); + this->actor.flags |= (ACTOR_FLAG_4 | ACTOR_FLAG_1); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, + GIBDO_LIMB_MAX); this->type = EN_TALK_GIBUD_TYPE_REDEAD; } + if (EnTalkGibud_PlayerOutOfRange(this, globalCtx)) { EnTalkGibud_SetupWalkToHome(this); } else { @@ -558,7 +582,7 @@ void EnTalkGibud_Damage(EnTalkGibud* this, GlobalContext* globalCtx) { void EnTalkGibud_SetupDead(EnTalkGibud* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DEATH); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); this->deathTimer = 0; this->actionFunc = EnTalkGibud_Dead; @@ -572,18 +596,19 @@ void EnTalkGibud_Dead(EnTalkGibud* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 250, 0); this->deathTimer++; } - if (this->deathTimer == 20 && this->effectTimer > 0 && this->effectType == 0 && - this->type == EN_TALK_GIBUD_TYPE_GIBDO) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_010B88, NULL, this->jointTable, - this->morphTable, EN_TALK_GIBUD_LIMB_MAX); + + if ((this->deathTimer == 20) && (this->effectTimer > 0) && (this->effectType == 0) && + (this->type == EN_TALK_GIBUD_TYPE_GIBDO)) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, + GIBDO_LIMB_MAX); this->type = EN_TALK_GIBUD_TYPE_REDEAD; } } void EnTalkGibud_SetupRevive(EnTalkGibud* this) { - Animation_Change(&this->skelAnime, &object_rd_Anim_009298, -1.0f, Animation_GetLastFrame(&object_rd_Anim_009298), + Animation_Change(&this->skelAnime, &gGibdoRedeadDeathAnim, -1.0f, Animation_GetLastFrame(&gGibdoRedeadDeathAnim), 0.0f, 2, -8.0f); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_REVERSE); this->deathTimer = 0; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -603,38 +628,47 @@ void EnTalkGibud_GetTextIdForRequestedItem(EnTalkGibud* this, GlobalContext* glo func_801518B0(globalCtx, 0x138C, &this->actor); this->textId = 0x138C; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BEANS: func_801518B0(globalCtx, 0x138D, &this->actor); this->textId = 0x138D; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_SPRING_WATER: func_801518B0(globalCtx, 0x138E, &this->actor); this->textId = 0x138E; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_FISH: func_801518B0(globalCtx, 0x138F, &this->actor); this->textId = 0x138F; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BUGS: func_801518B0(globalCtx, 0x1390, &this->actor); this->textId = 0x1390; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_DEKU_NUTS: func_801518B0(globalCtx, 0x1391, &this->actor); this->textId = 0x1391; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BOMBS: func_801518B0(globalCtx, 0x1392, &this->actor); this->textId = 0x1392; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_HOT_SPRING_WATER: func_801518B0(globalCtx, 0x1393, &this->actor); this->textId = 0x1393; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BIG_POE: func_801518B0(globalCtx, 0x1394, &this->actor); this->textId = 0x1394; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_MILK: func_801518B0(globalCtx, 0x1395, &this->actor); this->textId = 0x1395; @@ -648,6 +682,7 @@ void EnTalkGibud_GetNextTextBoxId(EnTalkGibud* this, GlobalContext* globalCtx) { case 0x1388: EnTalkGibud_GetTextIdForRequestedItem(this, globalCtx); break; + case 0x138C: case 0x138D: case 0x138E: @@ -699,14 +734,17 @@ void EnTalkGibud_CheckPresentedItem(EnTalkGibud* this, GlobalContext* globalCtx) player->actor.textId = 0x138A; this->textId = 0x138A; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_NOT_ENOUGH_AMMO: player->actor.textId = 0x138B; this->textId = 0x138B; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_NOT_MET: player->actor.textId = 0x1389; this->textId = 0x1389; break; + default: break; } @@ -769,9 +807,11 @@ void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx) { case 12: case 13: break; + case 5: EnTalkGibud_GetNextTextBoxId(this, globalCtx); break; + case 6: if (func_80147624(globalCtx)) { if (this->textId == 0x138A) { @@ -784,13 +824,14 @@ void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx) { } player->stateFlags1 |= 0x20; player->stateFlags1 |= 0x20000000; - this->actor.flags |= 0x100000; + this->actor.flags |= ACTOR_FLAG_100000; EnTalkGibud_SetupDisappear(this); } else { EnTalkGibud_SetupPassiveIdle(this); } } break; + case 16: EnTalkGibud_CheckPresentedItem(this, globalCtx); break; @@ -800,7 +841,7 @@ void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx) { void EnTalkGibud_SetupDisappear(EnTalkGibud* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->disappearanceTimer = 40; this->actionFunc = EnTalkGibud_Disappear; } @@ -851,8 +892,9 @@ void EnTalkGibud_FacePlayerWhenTalking(EnTalkGibud* this, GlobalContext* globalC s32 EnTalkGibud_PlayerInRangeWithCorrectState(EnTalkGibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 150.0f) && !(player->stateFlags1 & 0x2C6080) && - !(player->stateFlags2 & 0x4080)) { + if ((Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 150.0f) && + !(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && + !(player->stateFlags2 & (0x4000 | 0x80))) { return true; } @@ -875,20 +917,20 @@ s32 EnTalkGibud_PlayerOutOfRange(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_CheckForGibdoMask(EnTalkGibud* this, GlobalContext* globalCtx) { - if (this->actionFunc != EnTalkGibud_Grab && this->actionFunc != EnTalkGibud_Dead && - this->actionFunc != EnTalkGibud_Disappear && this->actionFunc != EnTalkGibud_Revive && - this->actionFunc != EnTalkGibud_Damage && this->actionFunc != EnTalkGibud_Talk) { + if ((this->actionFunc != EnTalkGibud_Grab) && (this->actionFunc != EnTalkGibud_Dead) && + (this->actionFunc != EnTalkGibud_Disappear) && (this->actionFunc != EnTalkGibud_Revive) && + (this->actionFunc != EnTalkGibud_Damage) && (this->actionFunc != EnTalkGibud_Talk)) { if (this->actionFunc != EnTalkGibud_PassiveIdle) { if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { - this->actor.flags &= ~(0x4 | 0x1); - this->actor.flags |= (0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_4 | ACTOR_FLAG_1); + this->actor.flags |= (ACTOR_FLAG_8 | ACTOR_FLAG_1); this->actor.hintId = 0xFF; this->actor.textId = 0; EnTalkGibud_SetupPassiveIdle(this); } } else if (Player_GetMask(globalCtx) != PLAYER_MASK_GIBDO) { - this->actor.flags &= ~(0x8 | 0x1); - this->actor.flags |= (0x4 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_8 | ACTOR_FLAG_1); + this->actor.flags |= (ACTOR_FLAG_4 | ACTOR_FLAG_1); if (this->type == EN_TALK_GIBUD_TYPE_REDEAD) { this->actor.hintId = 0x2A; } else { @@ -941,7 +983,8 @@ s32 EnTalkGibud_MoveToIdealGrabPositionAndRotation(EnTalkGibud* this, GlobalCont distanceFromTargetYOffset = Math_SmoothStepToF(&this->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); } - if (distanceFromTargetPos == 0.0f && ABS_ALT(distanceFromTargetAngle) < 100 && distanceFromTargetYOffset == 0.0f) { + if ((distanceFromTargetPos == 0.0f) && (ABS_ALT(distanceFromTargetAngle) < 100) && + (distanceFromTargetYOffset == 0.0f)) { return true; } @@ -955,13 +998,13 @@ void EnTalkGibud_PlayAnimation(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_MoveWithGravity(EnTalkGibud* this, GlobalContext* globalCtx) { - if (this->actionFunc == EnTalkGibud_WalkToPlayer || this->actionFunc == EnTalkGibud_WalkToHome || - this->actionFunc == EnTalkGibud_Damage) { + if ((this->actionFunc == EnTalkGibud_WalkToPlayer) || (this->actionFunc == EnTalkGibud_WalkToHome) || + (this->actionFunc == EnTalkGibud_Damage)) { Actor_MoveWithGravity(&this->actor); } } -void EnTalkGibud_CheckDamageEffect(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_UpdateDamage(EnTalkGibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (this->collider.base.acFlags & AC_HIT) { @@ -1033,18 +1076,18 @@ void EnTalkGibud_CheckDamageEffect(EnTalkGibud* this, GlobalContext* globalCtx) } } -void EnTalkGibud_CheckCollision(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_UpdateCollision(EnTalkGibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->actionFunc != EnTalkGibud_Dead && this->actionFunc != EnTalkGibud_Disappear && - this->actionFunc != EnTalkGibud_Revive && - (this->actionFunc != EnTalkGibud_Grab || this->grabState == EN_TALK_GIBUD_GRAB_RELEASE)) { + if ((this->actionFunc != EnTalkGibud_Dead) && (this->actionFunc != EnTalkGibud_Disappear) && + (this->actionFunc != EnTalkGibud_Revive) && + ((this->actionFunc != EnTalkGibud_Grab) || (this->grabState == EN_TALK_GIBUD_GRAB_RELEASE))) { if (this->isTalking != true) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if ((this->actionFunc != EnTalkGibud_Damage || - (player->unk_ADC != 0 && player->unk_ADD != this->unk_3F7)) && - (this->actionFunc != EnTalkGibud_Stunned || this->stunTimer == 0)) { + if (((this->actionFunc != EnTalkGibud_Damage) || + ((player->unk_ADC != 0) && (player->unk_ADD != this->unk_3F7))) && + ((this->actionFunc != EnTalkGibud_Stunned) || (this->stunTimer == 0))) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } } @@ -1077,6 +1120,7 @@ void EnTalkGibud_UpdateEffect(EnTalkGibud* this, GlobalContext* globalCtx) { if (this->effectTimer > 0) { this->effectTimer--; } + if (this->effectTimer < 20) { Math_SmoothStepToF(&this->effectScale, 0.0f, 0.5f, 0.03f, 0.0f); this->effectAlpha = this->effectTimer * 0.05f; @@ -1089,13 +1133,16 @@ void EnTalkGibud_Update(Actor* thisx, GlobalContext* globalCtx) { EnTalkGibud* this = THIS; EnTalkGibud_CheckForGibdoMask(this, globalCtx); - EnTalkGibud_CheckDamageEffect(this, globalCtx); + EnTalkGibud_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + EnTalkGibud_PlayAnimation(this, globalCtx); EnTalkGibud_MoveWithGravity(this, globalCtx); - EnTalkGibud_CheckCollision(this, globalCtx); + EnTalkGibud_UpdateCollision(this, globalCtx); EnTalkGibud_MoveGrabbedPlayerAwayFromWall(this, globalCtx); EnTalkGibud_UpdateEffect(this, globalCtx); + this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 50.0f; } @@ -1104,9 +1151,9 @@ s32 EnTalkGibud_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** Actor* thisx, Gfx** gfx) { EnTalkGibud* this = THIS; - if (limbIndex == EN_TALK_GIBUD_LIMB_UPPER_BODY_ROOT) { + if (limbIndex == GIBDO_LIMB_UPPER_BODY_ROOT) { rot->y += this->upperBodyRotation.y; - } else if (limbIndex == EN_TALK_GIBUD_LIMB_HEAD_ROOT) { + } else if (limbIndex == GIBDO_LIMB_HEAD_ROOT) { rot->y += this->headRotation.y; } @@ -1118,14 +1165,13 @@ void EnTalkGibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi EnTalkGibud* this = THIS; if ((this->effectTimer != 0) && - ((limbIndex == EN_TALK_GIBUD_LIMB_LEFT_THIGH) || (limbIndex == EN_TALK_GIBUD_LIMB_LEFT_LOWER_LEG) || - (limbIndex == EN_TALK_GIBUD_LIMB_LEFT_FOOT) || (limbIndex == EN_TALK_GIBUD_LIMB_RIGHT_THIGH) || - (limbIndex == EN_TALK_GIBUD_LIMB_RIGHT_LOWER_LEG) || (limbIndex == EN_TALK_GIBUD_LIMB_RIGHT_FOOT) || - (limbIndex == EN_TALK_GIBUD_LIMB_TORSO) || (limbIndex == EN_TALK_GIBUD_LIMB_LEFT_SHOULDER_AND_UPPER_ARM) || - (limbIndex == EN_TALK_GIBUD_LIMB_LEFT_FOREARM) || (limbIndex == EN_TALK_GIBUD_LIMB_LEFT_HAND) || - (limbIndex == EN_TALK_GIBUD_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || - (limbIndex == EN_TALK_GIBUD_LIMB_RIGHT_FOREARM) || (limbIndex == EN_TALK_GIBUD_LIMB_RIGHT_HAND) || - (limbIndex == EN_TALK_GIBUD_LIMB_HEAD) || (limbIndex == EN_TALK_GIBUD_LIMB_PELVIS))) { + ((limbIndex == GIBDO_LIMB_LEFT_THIGH) || (limbIndex == GIBDO_LIMB_LEFT_SHIN) || + (limbIndex == GIBDO_LIMB_LEFT_FOOT) || (limbIndex == GIBDO_LIMB_RIGHT_THIGH) || + (limbIndex == GIBDO_LIMB_RIGHT_SHIN) || (limbIndex == GIBDO_LIMB_RIGHT_FOOT) || + (limbIndex == GIBDO_LIMB_TORSO) || (limbIndex == GIBDO_LIMB_LEFT_SHOULDER_AND_UPPER_ARM) || + (limbIndex == GIBDO_LIMB_LEFT_FOREARM) || (limbIndex == GIBDO_LIMB_LEFT_HAND) || + (limbIndex == GIBDO_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || (limbIndex == GIBDO_LIMB_RIGHT_FOREARM) || + (limbIndex == GIBDO_LIMB_RIGHT_HAND) || (limbIndex == GIBDO_LIMB_HEAD) || (limbIndex == GIBDO_LIMB_PELVIS))) { Matrix_GetStateTranslation(&this->limbPos[this->limbIndex]); this->limbIndex++; } @@ -1156,6 +1202,7 @@ void EnTalkGibud_Draw(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.dListCount, EnTalkGibud_OverrideLimbDraw, EnTalkGibud_PostLimbDraw, &this->actor, POLY_XLU_DISP); } + if (this->effectTimer > 0) { func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->effectScale, 0.5f, this->effectAlpha, this->effectType); diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h index 2c154ea89..ae3afab49 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h @@ -2,51 +2,11 @@ #define Z_EN_TALK_GIBUD_H #include "global.h" +#include "objects/object_rd/object_rd.h" #define EN_TALK_GIBUD_REQUESTED_ITEM_INDEX(thisx) ((thisx)->params & 0xF) #define EN_TALK_GIBUD_SWITCH_FLAG(thisx) (((thisx)->params & 0xFF0) >> 4) -typedef enum { - /* 0 */ EN_TALK_GIBUD_TYPE_GIBDO, - /* 1 */ EN_TALK_GIBUD_TYPE_REDEAD, -} EnTalkGibudType; - -typedef enum { - /* 0 */ EN_TALK_GIBUD_GRAB_START, - /* 1 */ EN_TALK_GIBUD_GRAB_ATTACK, - /* 2 */ EN_TALK_GIBUD_GRAB_RELEASE, -} EnTalkGibudGrabState; - -typedef enum { - /* 0 */ EN_TALK_GIBUD_LIMB_NONE, - /* 1 */ EN_TALK_GIBUD_LIMB_ROOT, // Root of Left Leg Root, Right Leg Root, Upper Body Root, and Pelvis - /* 2 */ EN_TALK_GIBUD_LIMB_LEFT_LEG_ROOT, - /* 3 */ EN_TALK_GIBUD_LIMB_LEFT_THIGH, - /* 4 */ EN_TALK_GIBUD_LIMB_LEFT_LOWER_LEG, - /* 5 */ EN_TALK_GIBUD_LIMB_LEFT_FOOT_ROOT, - /* 6 */ EN_TALK_GIBUD_LIMB_LEFT_FOOT, - /* 7 */ EN_TALK_GIBUD_LIMB_RIGHT_LEG_ROOT, - /* 8 */ EN_TALK_GIBUD_LIMB_RIGHT_THIGH, - /* 9 */ EN_TALK_GIBUD_LIMB_RIGHT_LOWER_LEG, - /* 10 */ EN_TALK_GIBUD_LIMB_RIGHT_FOOT_ROOT, - /* 11 */ EN_TALK_GIBUD_LIMB_RIGHT_FOOT, - /* 12 */ EN_TALK_GIBUD_LIMB_UPPER_BODY_ROOT, - /* 13 */ EN_TALK_GIBUD_LIMB_UPPER_BODY, // Root of Torso - /* 14 */ EN_TALK_GIBUD_LIMB_TORSO, // Root of Left Arm Root, Right Arm Root, and Head Root - /* 15 */ EN_TALK_GIBUD_LIMB_LEFT_ARM_ROOT, - /* 16 */ EN_TALK_GIBUD_LIMB_LEFT_SHOULDER_AND_UPPER_ARM, - /* 17 */ EN_TALK_GIBUD_LIMB_LEFT_FOREARM, - /* 18 */ EN_TALK_GIBUD_LIMB_LEFT_HAND, - /* 19 */ EN_TALK_GIBUD_LIMB_RIGHT_ARM_ROOT, - /* 20 */ EN_TALK_GIBUD_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM, - /* 21 */ EN_TALK_GIBUD_LIMB_RIGHT_FOREARM, - /* 22 */ EN_TALK_GIBUD_LIMB_RIGHT_HAND, - /* 23 */ EN_TALK_GIBUD_LIMB_HEAD_ROOT, - /* 24 */ EN_TALK_GIBUD_LIMB_HEAD, - /* 25 */ EN_TALK_GIBUD_LIMB_PELVIS, - /* 26 */ EN_TALK_GIBUD_LIMB_MAX, -} EnTalkGibudLimbs; - struct EnTalkGibud; typedef void (*EnTalkGibudActionFunc)(struct EnTalkGibud*, GlobalContext*); @@ -63,19 +23,19 @@ typedef struct EnTalkGibud { /* 0x298 */ s32 switchFlag; /* 0x29C */ f32 effectAlpha; /* 0x2A0 */ f32 effectScale; - /* 0x2A4 */ Vec3s jointTable[EN_TALK_GIBUD_LIMB_MAX]; - /* 0x340 */ Vec3s morphTable[EN_TALK_GIBUD_LIMB_MAX]; + /* 0x2A4 */ Vec3s jointTable[GIBDO_LIMB_MAX]; + /* 0x340 */ Vec3s morphTable[GIBDO_LIMB_MAX]; /* 0x3DC */ s16 textId; /* 0x3DE */ Vec3s headRotation; /* 0x3E4 */ Vec3s upperBodyRotation; /* 0x3EA */ union { - s16 playerStunWaitTimer; // Cannot stun the player if this is non-zero - s16 grabDamageTimer; - s16 headShakeTimer; - s16 stunTimer; - s16 deathTimer; - s16 disappearanceTimer; - }; + s16 playerStunWaitTimer; // Cannot stun the player if this is non-zero + s16 grabDamageTimer; + s16 headShakeTimer; + s16 stunTimer; + s16 deathTimer; + s16 disappearanceTimer; + }; /* 0x3EC */ s16 grabState; /* 0x3EE */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero /* 0x3F0 */ s16 effectTimer; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 7a918900b..15e27b685 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -6344,49 +6344,49 @@ 0x808D3754:("func_808D3754",), 0x808D3E20:("EnRd_Init",), 0x808D414C:("EnRd_Destroy",), - 0x808D4190:("func_808D4190",), - 0x808D41FC:("func_808D41FC",), - 0x808D4260:("func_808D4260",), - 0x808D4308:("func_808D4308",), - 0x808D43AC:("func_808D43AC",), - 0x808D45D4:("func_808D45D4",), - 0x808D4660:("func_808D4660",), - 0x808D47DC:("func_808D47DC",), - 0x808D4868:("func_808D4868",), - 0x808D49E4:("func_808D49E4",), - 0x808D4A90:("func_808D4A90",), - 0x808D4B20:("func_808D4B20",), - 0x808D4CA8:("func_808D4CA8",), - 0x808D4DC4:("func_808D4DC4",), - 0x808D4E60:("func_808D4E60",), - 0x808D4FE0:("func_808D4FE0",), - 0x808D506C:("func_808D506C",), - 0x808D53C0:("func_808D53C0",), - 0x808D5440:("func_808D5440",), - 0x808D5660:("func_808D5660",), - 0x808D56E4:("func_808D56E4",), - 0x808D586C:("func_808D586C",), - 0x808D58CC:("func_808D58CC",), - 0x808D5C54:("func_808D5C54",), - 0x808D5CCC:("func_808D5CCC",), - 0x808D5D88:("func_808D5D88",), - 0x808D5DF4:("func_808D5DF4",), - 0x808D5E98:("func_808D5E98",), - 0x808D5F18:("func_808D5F18",), - 0x808D6008:("func_808D6008",), - 0x808D6054:("func_808D6054",), - 0x808D60B0:("func_808D60B0",), - 0x808D6130:("func_808D6130",), - 0x808D616C:("func_808D616C",), - 0x808D6200:("func_808D6200",), - 0x808D6310:("func_808D6310",), - 0x808D6388:("func_808D6388",), - 0x808D64D0:("func_808D64D0",), - 0x808D65BC:("func_808D65BC",), - 0x808D66A0:("func_808D66A0",), - 0x808D6814:("func_808D6814",), - 0x808D6A94:("func_808D6A94",), - 0x808D6B64:("func_808D6B64",), + 0x808D4190:("EnRd_UpdateParentForOtherRedeads",), + 0x808D41FC:("EnRd_ShouldNotDance",), + 0x808D4260:("EnRd_SetupDanceIfConditionsMet",), + 0x808D4308:("EnRd_SetupIdle",), + 0x808D43AC:("EnRd_Idle",), + 0x808D45D4:("EnRd_SetupSquattingDance",), + 0x808D4660:("EnRd_SquattingDance",), + 0x808D47DC:("EnRd_SetupClappingDance",), + 0x808D4868:("EnRd_ClappingDance",), + 0x808D49E4:("EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose",), + 0x808D4A90:("EnRd_SetupPirouette",), + 0x808D4B20:("EnRd_Pirouette",), + 0x808D4CA8:("EnRd_EndPirouetteWhenPlayerIsClose",), + 0x808D4DC4:("EnRd_SetupRiseFromCoffin",), + 0x808D4E60:("EnRd_RiseFromCoffin",), + 0x808D4FE0:("EnRd_SetupWalkToPlayer",), + 0x808D506C:("EnRd_WalkToPlayer",), + 0x808D53C0:("EnRd_SetupWalkToHome",), + 0x808D5440:("EnRd_WalkToHome",), + 0x808D5660:("EnRd_SetupWalkToParent",), + 0x808D56E4:("EnRd_WalkToParent",), + 0x808D586C:("EnRd_SetupGrab",), + 0x808D58CC:("EnRd_Grab",), + 0x808D5C54:("EnRd_SetupAttemptPlayerFreeze",), + 0x808D5CCC:("EnRd_AttemptPlayerFreeze",), + 0x808D5D88:("EnRd_SetupGrabFail",), + 0x808D5DF4:("EnRd_GrabFail",), + 0x808D5E98:("EnRd_SetupTurnAwayAndShakeHead",), + 0x808D5F18:("EnRd_TurnAwayAndShakeHead",), + 0x808D6008:("EnRd_SetupStandUp",), + 0x808D6054:("EnRd_StandUp",), + 0x808D60B0:("EnRd_SetupCrouch",), + 0x808D6130:("EnRd_Crouch",), + 0x808D616C:("EnRd_SetupDamage",), + 0x808D6200:("EnRd_Damage",), + 0x808D6310:("EnRd_SetupDead",), + 0x808D6388:("EnRd_Dead",), + 0x808D64D0:("EnRd_SetupStunned",), + 0x808D65BC:("EnRd_Stunned",), + 0x808D66A0:("EnRd_TurnTowardsPlayer",), + 0x808D6814:("EnRd_UpdateDamage",), + 0x808D6A94:("EnRd_UpdateCollision",), + 0x808D6B64:("EnRd_UpdateEffect",), 0x808D6C10:("EnRd_Update",), 0x808D6DA0:("EnRd_OverrideLimbDraw",), 0x808D6DFC:("EnRd_PostLimbDraw",), @@ -12819,8 +12819,8 @@ 0x80AFEB0C:("EnTalkGibud_Destroy",), 0x80AFEB38:("EnTalkGibud_SetupIdle",), 0x80AFEB7C:("EnTalkGibud_Idle",), - 0x80AFEC08:("EnTalkGibud_SetupAttemptPlayerStun",), - 0x80AFEC4C:("EnTalkGibud_AttemptStun",), + 0x80AFEC08:("EnTalkGibud_SetupAttemptPlayerFreeze",), + 0x80AFEC4C:("EnTalkGibud_AttemptPlayerFreeze",), 0x80AFED08:("EnTalkGibud_SetupWalkToPlayer",), 0x80AFED7C:("EnTalkGibud_WalkToPlayer",), 0x80AFEFD4:("EnTalkGibud_SetupGrab",), @@ -12857,8 +12857,8 @@ 0x80B00760:("EnTalkGibud_MoveToIdealGrabPositionAndRotation",), 0x80B008BC:("EnTalkGibud_PlayAnimation",), 0x80B008FC:("EnTalkGibud_MoveWithGravity",), - 0x80B0094C:("EnTalkGibud_CheckDamageEffect",), - 0x80B00B8C:("EnTalkGibud_CheckCollision",), + 0x80B0094C:("EnTalkGibud_UpdateDamage",), + 0x80B00B8C:("EnTalkGibud_UpdateCollision",), 0x80B00C94:("EnTalkGibud_MoveGrabbedPlayerAwayFromWall",), 0x80B00D9C:("EnTalkGibud_UpdateEffect",), 0x80B00E48:("EnTalkGibud_Update",), @@ -15118,56 +15118,56 @@ 0x80BA4CB4:("func_80BA4CB4",), 0x80BA4E2C:("EnToto_Update",), 0x80BA4EFC:("EnToto_Draw",), - 0x80BA5400:("func_80BA5400",), + 0x80BA5400:("EnRailgibud_SpawnOtherGibdosAndSetPositionAndRotation",), 0x80BA5620:("EnRailgibud_Init",), 0x80BA577C:("EnRailgibud_Destroy",), - 0x80BA57A8:("func_80BA57A8",), - 0x80BA57F8:("func_80BA57F8",), - 0x80BA59F0:("func_80BA59F0",), - 0x80BA5A34:("func_80BA5A34",), - 0x80BA5AF0:("func_80BA5AF0",), - 0x80BA5B64:("func_80BA5B64",), - 0x80BA5DBC:("func_80BA5DBC",), - 0x80BA5E18:("func_80BA5E18",), - 0x80BA6054:("func_80BA6054",), - 0x80BA60B0:("func_80BA60B0",), - 0x80BA6158:("func_80BA6158",), - 0x80BA61A0:("func_80BA61A0",), - 0x80BA6284:("func_80BA6284",), - 0x80BA62D4:("func_80BA62D4",), - 0x80BA6440:("func_80BA6440",), - 0x80BA64AC:("func_80BA64AC",), - 0x80BA6584:("func_80BA6584",), - 0x80BA6604:("func_80BA6604",), - 0x80BA6664:("func_80BA6664",), - 0x80BA66C8:("func_80BA66C8",), - 0x80BA6800:("func_80BA6800",), - 0x80BA6974:("func_80BA6974",), - 0x80BA6B30:("func_80BA6B30",), - 0x80BA6B9C:("func_80BA6B9C",), - 0x80BA6D10:("func_80BA6D10",), - 0x80BA6DAC:("func_80BA6DAC",), - 0x80BA6DF8:("func_80BA6DF8",), - 0x80BA7088:("func_80BA7088",), - 0x80BA71E4:("func_80BA71E4",), - 0x80BA7234:("func_80BA7234",), - 0x80BA7388:("func_80BA7388",), - 0x80BA7434:("func_80BA7434",), - 0x80BA7578:("func_80BA7578",), - 0x80BA76C4:("func_80BA76C4",), + 0x80BA57A8:("EnRailgibud_SetupWalkInCircles",), + 0x80BA57F8:("EnRailgibud_WalkInCircles",), + 0x80BA59F0:("EnRailgibud_SetupAttemptPlayerFreeze",), + 0x80BA5A34:("EnRailgibud_AttemptPlayerFreeze",), + 0x80BA5AF0:("EnRailgibud_SetupWalkToPlayer",), + 0x80BA5B64:("EnRailgibud_WalkToPlayer",), + 0x80BA5DBC:("EnRailgibud_SetupGrab",), + 0x80BA5E18:("EnRailgibud_Grab",), + 0x80BA6054:("EnRailgibud_SetupGrabFail",), + 0x80BA60B0:("EnRailgibud_GrabFail",), + 0x80BA6158:("EnRailgibud_SetupTurnAwayAndShakeHead",), + 0x80BA61A0:("EnRailgibud_TurnAwayAndShakeHead",), + 0x80BA6284:("EnRailgibud_SetupWalkToHome",), + 0x80BA62D4:("EnRailgibud_WalkToHome",), + 0x80BA6440:("EnRailgibud_SetupDamage",), + 0x80BA64AC:("EnRailgibud_Damage",), + 0x80BA6584:("EnRailgibud_SetupStunned",), + 0x80BA6604:("EnRailgibud_Stunned",), + 0x80BA6664:("EnRailgibud_SetupDead",), + 0x80BA66C8:("EnRailgibud_Dead",), + 0x80BA6800:("EnRailgibud_SpawnEffectsForSinkingIntoTheGround",), + 0x80BA6974:("EnRailgibud_SpawnDust",), + 0x80BA6B30:("EnRailgibud_UpdateWalkForwardState",), + 0x80BA6B9C:("EnRailgibud_TurnTowardsPlayer",), + 0x80BA6D10:("EnRailgibud_PlayerInRangeWithCorrectState",), + 0x80BA6DAC:("EnRailgibud_PlayerOutOfRange",), + 0x80BA6DF8:("EnRailgibud_UpdateDamage",), + 0x80BA7088:("EnRailgibud_MoveToIdealGrabPositionAndRotation",), + 0x80BA71E4:("EnRailgibud_MoveWithGravity",), + 0x80BA7234:("EnRailgibud_MoveGrabbedPlayerAwayFromWall",), + 0x80BA7388:("EnRailgibud_UpdateEffect",), + 0x80BA7434:("EnRailgibud_CheckForGibdoMask",), + 0x80BA7578:("EnRailgibud_CheckIfTalkingToPlayer",), + 0x80BA76C4:("EnRailgibud_UpdateCollision",), 0x80BA77A0:("EnRailgibud_Update",), - 0x80BA7878:("func_80BA7878",), - 0x80BA789C:("func_80BA789C",), - 0x80BA78F8:("func_80BA78F8",), + 0x80BA7878:("EnRailgibud_MainGibdo_DeadUpdate",), + 0x80BA789C:("EnRailgibud_OverrideLimbDraw",), + 0x80BA78F8:("EnRailgibud_PostLimbDraw",), 0x80BA79D4:("EnRailgibud_Draw",), - 0x80BA7B6C:("func_80BA7B6C",), - 0x80BA7C78:("func_80BA7C78",), - 0x80BA7CF0:("func_80BA7CF0",), - 0x80BA7D04:("func_80BA7D04",), - 0x80BA7D14:("func_80BA7D14",), - 0x80BA7D30:("func_80BA7D30",), - 0x80BA7DC8:("func_80BA7DC8",), - 0x80BA8050:("func_80BA8050",), + 0x80BA7B6C:("EnRailgibud_InitCutsceneGibdo",), + 0x80BA7C78:("EnRailgibud_InitActorActionCommand",), + 0x80BA7CF0:("EnRailgibud_SetupDoNothing",), + 0x80BA7D04:("EnRailgibud_DoNothing",), + 0x80BA7D14:("EnRailgibud_SetupSinkIntoGround",), + 0x80BA7D30:("EnRailgibud_SinkIntoGround",), + 0x80BA7DC8:("EnRailgibud_PerformCutsceneActions",), + 0x80BA8050:("EnRailgibud_Cutscene_Update",), 0x80BA8820:("func_80BA8820",), 0x80BA886C:("func_80BA886C",), 0x80BA8C4C:("func_80BA8C4C",), From 08acf4220422adeb96933a157f3d1cec14466559 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 19 Feb 2022 20:09:27 +0000 Subject: [PATCH 028/257] En_Kendo_Js (#606) * En_Kendo_Js * PR * PR * PR --- include/functions.h | 6 +- include/z64.h | 3 +- spec | 3 +- .../actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c | 2 +- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 4 +- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 2 +- src/overlays/actors/ovl_En_Fish/z_en_fish.c | 2 +- src/overlays/actors/ovl_En_In/z_en_in.c | 12 +- src/overlays/actors/ovl_En_Ishi/z_en_ishi.c | 4 +- .../actors/ovl_En_Kendo_Js/z_en_kendo_js.c | 745 ++++++++++++++++-- .../actors/ovl_En_Kendo_Js/z_en_kendo_js.h | 22 +- .../actors/ovl_En_Maruta/z_en_maruta.h | 3 +- src/overlays/actors/ovl_En_Zog/z_en_zog.c | 2 +- .../ovl_Obj_Flowerpot/z_obj_flowerpot.c | 2 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 7 - 16 files changed, 744 insertions(+), 79 deletions(-) diff --git a/include/functions.h b/include/functions.h index 5b7da53e4..2b42ce87e 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2021,8 +2021,8 @@ void func_801229A0(GlobalContext* globalCtx, Player* player); // void func_80122ED8(void); // void func_80122EEC(void); void func_80122F28(Player* player, GlobalContext* globalCtx, Actor* actor); -// void func_80122F9C(void); -// void func_80122FCC(void); +s32 func_80122F9C(GlobalContext* globalCtx); +s32 func_80122FCC(GlobalContext* globalCtx); // void func_8012300C(void); void func_8012301C(s32 iParm1, GlobalContext* globalCtx); void func_80123140(GlobalContext* globalCtx, Player* param_2); @@ -2058,7 +2058,7 @@ s32 func_801240C8(Player* player); // void func_80124110(void); // void func_80124148(void); // void func_80124168(void); -// void func_80124190(void); +s32 func_80124190(Player* player); // void func_801241B4(void); // void func_801241E0(void); // void func_8012420C(void); diff --git a/include/z64.h b/include/z64.h index 83d3a47da..1daaeb30f 100644 --- a/include/z64.h +++ b/include/z64.h @@ -879,7 +879,8 @@ typedef struct { /* 0x1205A */ UNK_TYPE1 pad1205A[0x10]; /* 0x1206A */ s16 unk1206A; /* 0x1206C */ s32 unk1206C; - /* 0x12070 */ UNK_TYPE1 pad12070[0x8]; + /* 0x12070 */ s32 unk12070; + /* 0x12074 */ UNK_TYPE1 pad12074[0x4]; /* 0x12078 */ s32 bankRupeesSelected; /* 0x1207C */ s32 bankRupees; /* 0x12080 */ UNK_TYPE1 pad12080[0x31]; diff --git a/spec b/spec index 21237ae08..ad4088108 100644 --- a/spec +++ b/spec @@ -3975,8 +3975,7 @@ beginseg name "ovl_En_Kendo_Js" compress include "build/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.o" - include "build/data/ovl_En_Kendo_Js/ovl_En_Kendo_Js.data.o" - include "build/data/ovl_En_Kendo_Js/ovl_En_Kendo_Js.reloc.o" + include "build/src/overlays/actors/ovl_En_Kendo_Js/ovl_En_Kendo_Js_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c index dee311742..648b4ff7d 100644 --- a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c +++ b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c @@ -91,7 +91,7 @@ void func_80B401F8(BgGoronOyu* this, GlobalContext* globalCtx) { if (dist.x >= 0.0f && dist.x <= this->waterBoxXLength && dist.z >= 0.0f && dist.z <= this->waterBoxZLength && fabsf(dist.y) < 100.0f && player->actor.depthInWater > 12.0f) { - Actor_PickUp(&this->dyna.actor, globalCtx, 0xBA, this->dyna.actor.xzDistToPlayer, + Actor_PickUp(&this->dyna.actor, globalCtx, GI_MAX, this->dyna.actor.xzDistToPlayer, fabsf(this->dyna.actor.playerHeightRel)); } } diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index 38b9c3ece..f988cfa76 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -768,9 +768,9 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { this->actionFunc = func_809C2BE4; } } else if (gSaveContext.weekEventReg[8] & 0x20) { - Actor_PickUp(&this->actor, globalCtx, 4, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 300.0f, 300.0f); } else { - Actor_PickUp(&this->actor, globalCtx, 12, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 300.0f, 300.0f); } } } diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index 136cecf4b..5047b54ce 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -700,7 +700,7 @@ void func_8088DD34(EnElf* this, GlobalContext* globalCtx) { } if (this->fairyFlags & 0x2000) { - Actor_PickUp(&this->actor, globalCtx, 0xBA, 80.0f, 60.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MAX, 80.0f, 60.0f); } } diff --git a/src/overlays/actors/ovl_En_Fish/z_en_fish.c b/src/overlays/actors/ovl_En_Fish/z_en_fish.c index 24d8efb58..419e9edd4 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.c +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.c @@ -882,7 +882,7 @@ void func_8091F5A4(Actor* thisx, GlobalContext* globalCtx) { func_8091D904(this); } } else if (func_8091DDF4(this, globalCtx)) { - Actor_PickUp(&this->actor, globalCtx, 0xBA, 80.0f, 25.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MAX, 80.0f, 25.0f); } } } 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 bc4d3a89b..52b4e46f7 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -411,7 +411,7 @@ void func_808F3B40(EnIn* this, GlobalContext* globalCtx) { textId = gSaveContext.day != 3 ? 0x3481 : 0x34A4; this->actor.textId = textId; } else { - Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); } } @@ -435,7 +435,7 @@ void func_808F3C40(EnIn* this, GlobalContext* globalCtx) { textId = gSaveContext.day != 3 ? 0x346A : 0x3492; this->actor.textId = textId; } else { - Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); } } @@ -759,7 +759,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { if (Interface_HasEmptyBottle()) { this->actionFunc = func_808F3C40; - Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); func_801159EC(-globalCtx->msgCtx.unk1206C); ret = true; } else { @@ -905,7 +905,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_808F35D8(this, globalCtx); if (Interface_HasEmptyBottle()) { this->actionFunc = func_808F3B40; - Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); ret = true; } else { func_800E8EA0(globalCtx, &this->actor, 0x347F); @@ -1011,7 +1011,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { if (Interface_HasEmptyBottle()) { this->actionFunc = func_808F3C40; - Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); func_801159EC(-globalCtx->msgCtx.unk1206C); ret = true; } else { @@ -1109,7 +1109,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_808F35D8(this, globalCtx); if (Interface_HasEmptyBottle()) { this->actionFunc = func_808F3B40; - Actor_PickUp(&this->actor, globalCtx, 0x92, 500.0f, 100.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); ret = true; } else { func_800E8EA0(globalCtx, &this->actor, 0x34A2); diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c index 971f8eb70..5e7292df5 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -511,9 +511,9 @@ void func_8095E660(EnIshi* this, GlobalContext* globalCtx) { if ((this->actor.xzDistToPlayer < 90.0f) && (sp30 == 0)) { if (sp38 == 1) { - Actor_PickUp(&this->actor, globalCtx, 0, 80.0f, 20.0f); + Actor_PickUp(&this->actor, globalCtx, GI_NONE, 80.0f, 20.0f); } else { - Actor_PickUp(&this->actor, globalCtx, 0, 50.0f, 10.0f); + Actor_PickUp(&this->actor, globalCtx, GI_NONE, 50.0f, 10.0f); } } } 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 2cd8dd5e9..4eb4ffdc9 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 @@ -5,8 +5,10 @@ */ #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 0x0A000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000) #define THIS ((EnKendoJs*)thisx) @@ -15,7 +17,26 @@ void EnKendoJs_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKendoJs_Update(Actor* thisx, GlobalContext* globalCtx); void EnKendoJs_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B26538(EnKendoJs* this); +void func_80B2654C(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B26AE8(EnKendoJs* this); +void func_80B26AFC(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B2701C(EnKendoJs* this); +void func_80B27030(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B2714C(EnKendoJs* this); +void func_80B27188(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B273D0(EnKendoJs* this); +void func_80B2740C(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B274BC(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B276C4(EnKendoJs* this); +void func_80B276D8(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B27760(EnKendoJs* this); +void func_80B27774(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B2783C(EnKendoJs* this, GlobalContext* globalCtx); +s32 func_80B278C4(GlobalContext* globalCtx, Vec3f arg1); +void func_80B279F0(EnKendoJs* this, GlobalContext* globalCtx, s32 arg2); +void func_80B27A90(EnKendoJs* this, GlobalContext* globalCtx); + const ActorInit En_Kendo_Js_InitVars = { ACTOR_EN_KENDO_JS, ACTORCAT_NPC, @@ -28,86 +49,718 @@ const ActorInit En_Kendo_Js_InitVars = { (ActorFunc)EnKendoJs_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B27C30 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 18, 30, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B27C5C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfo sAnimations[] = { + { &object_js_Anim_000C7C, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_js_Anim_000F4C, 1.0f, 0.0f, 0.0f, 0, -8.0f }, + { &object_js_Anim_00016C, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_js_Anim_0003DC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, + { &object_js_Anim_000AD4, 1.0f, 0.0f, 0.0f, 0, -8.0f }, +}; -extern ColliderCylinderInit D_80B27C30; -extern CollisionCheckInfoInit2 D_80B27C5C; +s16 D_80B27CE0[][3] = { + { 0x2731, 0x2732, 0x2733 }, + { 0x2734, 0x2735, 0x2736 }, + { 0x2737, 0x2738, 0x2739 }, +}; -extern UNK_TYPE D_0600016C; -extern UNK_TYPE D_06000F4C; +s16 D_80B27CF4[][3] = { + { 0x2710, 0x2712, 0x2714 }, + { 0x2711, 0x2713, 0x2715 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/EnKendoJs_Init.s") +s16 D_80B27D00[] = { + 0x271C, 0x271E, 0x2720, 0x2722, 0x2724, 0x2726, 0x2728, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/EnKendoJs_Destroy.s") +s16 D_80B27D10[] = { + 0x271B, 0x271D, 0x271F, 0x2721, 0x2723, 0x2725, 0x2727, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26538.s") +void EnKendoJs_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnKendoJs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B2654C.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26758.s") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B269A4.s") + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_js_Skel_006990, &object_js_Anim_000F4C, this->jointTable, + this->morphTable, 13); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26AE8.s") + if ((CURRENT_DAY == 3) && !((gSaveContext.time <= CLOCK_TIME(23, 0)) && (gSaveContext.time >= CLOCK_TIME(6, 0)))) { + if (ENKENDOJS_GET_FF(&this->actor) != ENKENDOJS_FF_1) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_KANBAN, this->actor.home.pos.x, + this->actor.home.pos.y, this->actor.home.pos.z - 10.0f, this->actor.home.rot.x, + this->actor.home.rot.y, this->actor.home.rot.z, 0x10); + Actor_MarkForDeath(&this->actor); + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + } + } else if (ENKENDOJS_GET_FF(&this->actor) == ENKENDOJS_FF_1) { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26AFC.s") + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26BF8.s") + if (ENKENDOJS_GET_FF(&this->actor) != ENKENDOJS_FF_1) { + Path* path = &globalCtx->setupPathList[ENKENDOJS_GET_FF00(&this->actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26EB4.s") + this->unk_274 = Lib_SegmentedToVirtual(path->points); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26F14.s") + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 30.0f; + this->actor.child = NULL; + this->unk_28A = 0; + this->unk_28C = 0; + this->unk_28E = 0; + this->unk_286 = 0; + func_80B26538(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26F6C.s") +void EnKendoJs_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKendoJs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B2701C.s") + Collider_DestroyCylinder(globalCtx, &this->collider); + gSaveContext.weekEventReg[82] &= (u8)~8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27030.s") +void func_80B26538(EnKendoJs* this) { + this->actionFunc = func_80B2654C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B2714C.s") +void func_80B2654C(EnKendoJs* this, GlobalContext* globalCtx) { + s32 phi_v0; + s32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27188.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { + if (CURRENT_DAY != 0) { + sp30 = CURRENT_DAY - 1; + } else { + sp30 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B273D0.s") + if (ENKENDOJS_GET_FF(&this->actor) == ENKENDOJS_FF_1) { + func_801518B0(globalCtx, 0x273C, &this->actor); + this->unk_288 = 0x273C; + } else if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { + switch (gSaveContext.playerForm) { + case PLAYER_FORM_DEKU: + phi_v0 = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B2740C.s") + case PLAYER_FORM_GORON: + phi_v0 = 1; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B274BC.s") + case PLAYER_FORM_ZORA: + phi_v0 = 2; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B276C4.s") + default: + phi_v0 = 0; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B276D8.s") + func_801518B0(globalCtx, D_80B27CE0[phi_v0][sp30], &this->actor); + this->unk_288 = D_80B27CE0[phi_v0][sp30]; + } else if ((Player_GetMask(globalCtx) != PLAYER_MASK_NONE) && (Player_GetMask(globalCtx) < PLAYER_MASK_GIANT)) { + u16 sp2E = Player_GetMask(globalCtx) + 0x273C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27760.s") + if (0) {} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27774.s") + func_801518B0(globalCtx, sp2E, &this->actor); + this->unk_288 = sp2E; + } else { + if (this->unk_28A == 0) { + this->unk_28A = 1; + phi_v0 = 0; + } else { + phi_v0 = 1; + } + func_801518B0(globalCtx, D_80B27CF4[phi_v0][sp30], &this->actor); + this->unk_288 = D_80B27CF4[phi_v0][sp30]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B2783C.s") + func_80B26AE8(this); + } else { + func_800B8614(&this->actor, globalCtx, 100.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27880.s") +void func_80B26758(EnKendoJs* this, GlobalContext* globalCtx) { + if (func_80147624(globalCtx) && (this->unk_288 == 0x2716)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (CUR_EQUIP_VALUE_VOID(EQUIP_SWORD) == EQUIP_SWORD) { + play_sound(NA_SE_SY_ERROR); + func_801518B0(globalCtx, 0x272C, &this->actor); + this->unk_288 = 0x272C; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + } else if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + play_sound(NA_SE_SY_ERROR); + func_801518B0(globalCtx, 0x2718, &this->actor); + this->unk_288 = 0x2718; + } else { + func_8019F208(); + func_801159EC(-globalCtx->msgCtx.unk1206C); + func_801518B0(globalCtx, 0x2719, &this->actor); + this->unk_288 = 0x2719; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B278C4.s") + case 1: + if (CUR_EQUIP_VALUE_VOID(EQUIP_SWORD) == EQUIP_SWORD) { + play_sound(NA_SE_SY_ERROR); + func_801518B0(globalCtx, 0x272C, &this->actor); + this->unk_288 = 0x272C; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + } else if (gSaveContext.rupees < globalCtx->msgCtx.unk12070) { + play_sound(NA_SE_SY_ERROR); + func_801518B0(globalCtx, 0x2718, &this->actor); + this->unk_288 = 0x2718; + } else { + func_8019F208(); + func_801159EC(-globalCtx->msgCtx.unk12070); + func_801518B0(globalCtx, 0x273A, &this->actor); + this->unk_288 = 0x273A; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B279AC.s") + case 2: + func_8019F230(); + func_801518B0(globalCtx, 0x2717, &this->actor); + this->unk_288 = 0x2717; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B279F0.s") +void func_80B269A4(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27A90.s") + if (!func_80147624(globalCtx)) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/EnKendoJs_Update.s") + switch (this->unk_288) { + case 0x2710: + case 0x2711: + case 0x2712: + case 0x2713: + case 0x2714: + case 0x2715: + func_801518B0(globalCtx, 0x2716, &this->actor); + this->unk_288 = 0x2716; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27B54.s") + case 0x2719: + func_801477B4(globalCtx); + player->stateFlags1 |= 0x20; + func_80B2701C(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27B8C.s") + case 0x271A: + func_801477B4(globalCtx); + func_80B2714C(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/EnKendoJs_Draw.s") + case 0x273A: + func_801518B0(globalCtx, 0x273B, &this->actor); + this->unk_288 = 0x273B; + break; + + case 0x273B: + func_801477B4(globalCtx); + func_80112AFC(globalCtx); + player->stateFlags1 |= 0x20; + func_80B273D0(this); + break; + + case 0x272D: + func_801477B4(globalCtx); + gSaveContext.minigameState = 3; + func_80B276C4(this); + func_80B276D8(this, globalCtx); + break; + } +} + +void func_80B26AE8(EnKendoJs* this) { + this->actionFunc = func_80B26AFC; +} + +void func_80B26AFC(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 4: + func_80B26758(this, globalCtx); + break; + + case 5: + func_80B269A4(this, globalCtx); + break; + + case 6: + if (func_80147624(globalCtx)) { + if (this->unk_288 == 0x272C) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + } + + if ((this->unk_288 == 0x272E) || (this->unk_288 == 0x272F) || (this->unk_288 == 0x2730)) { + gSaveContext.minigameState = 3; + } + + player->stateFlags1 &= ~0x20; + func_80B26538(this); + } + + case 0: + case 1: + case 2: + case 3: + break; + } +} + +s32 func_80B26BF8(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (this->unk_284) { + case 0: + if (func_80122FCC(globalCtx)) { + return 0; + } + + if ((player->swordState != 0) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + return 1; + } + break; + + case 1: + if ((player->stateFlags3 & 0x8000000)) { + return 0; + } + + if ((player->swordState != 0) || (player->stateFlags2 & 0x80000)) { + return 1; + } + break; + + case 2: + if (func_80122F9C(globalCtx)) { + return 0; + } + + if ((player->swordState != 0) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + return 1; + } + this->unk_28E = 0; + break; + + case 3: + if ((this->unk_28E == 1) && ((player->swordAnimation == 4) || (player->swordAnimation == 6))) { + this->unk_28E = 0; + return 0; + } + + if ((this->unk_28E == 1) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + this->unk_28E = 0; + return 1; + } + break; + + case 4: + if ((this->unk_28E == 1) && ((player->swordAnimation == 0) || (player->swordAnimation == 2))) { + this->unk_28E = 0; + return 0; + } + + if ((this->unk_28E == 1) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + this->unk_28E = 0; + return 1; + } + break; + + case 5: + if ((this->unk_28E == 1) && (player->swordAnimation == 12)) { + this->unk_28E = 0; + return 0; + } + + if ((this->unk_28E == 1) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + this->unk_28E = 0; + return 1; + } + break; + + case 6: + if ((this->unk_28E == 1) && ((player->swordAnimation == 17) || (player->swordAnimation == 20))) { + this->unk_28E = 0; + return 0; + } + + if ((this->unk_28E == 1) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + this->unk_28E = 0; + return 1; + } + break; + } + return 2; +} + +void func_80B26EB4(EnKendoJs* this, GlobalContext* globalCtx) { + func_801518B0(globalCtx, D_80B27D00[this->unk_284], &this->actor); + this->unk_288 = D_80B27D00[this->unk_284]; + this->unk_284++; +} + +void func_80B26F14(EnKendoJs* this, GlobalContext* globalCtx) { + func_801518B0(globalCtx, D_80B27D10[this->unk_284], &this->actor); + this->unk_288 = D_80B27D10[this->unk_284]; +} + +s32 func_80B26F6C(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (this->unk_288) { + case 0x271D: + if (func_80124190(player)) { + func_801518B0(globalCtx, 0x272A, &this->actor); + this->unk_288 = 0x272A; + return true; + } + break; + + case 0x2721: + if (this->unk_292 != 0) { + func_801518B0(globalCtx, 0x272B, &this->actor); + this->unk_288 = 0x272B; + return true; + } + break; + } + return false; +} + +void func_80B2701C(EnKendoJs* this) { + this->actionFunc = func_80B27030; +} + +void func_80B27030(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp20 = this->actor.world.pos; + + sp20.z += 200.0f; + + if (func_80B278C4(globalCtx, sp20)) { + this->actor.flags |= ACTOR_FLAG_10000; + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + player->stateFlags1 &= ~0x20; + func_80B279F0(this, globalCtx, 0); + func_801518B0(globalCtx, 0x271A, &this->actor); + this->unk_288 = 0x271A; + func_80B26AE8(this); + } else { + func_800B8614(&this->actor, globalCtx, 800.0f); + } + } +} + +void func_80B2714C(EnKendoJs* this) { + gSaveContext.weekEventReg[82] |= 8; + this->unk_28C = 1; + this->unk_290 = 0; + this->unk_284 = 0; + this->unk_286 = 1; + this->actionFunc = func_80B27188; +} + +void func_80B27188(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if (this->unk_288 == 0x2729) { + func_80B26F14(this, globalCtx); + } else if (!func_80B26F6C(this, globalCtx)) { + if (this->skelAnime.animation == &object_js_Anim_00016C) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + } + this->unk_286 = 2; + func_801477B4(globalCtx); + player->stateFlags1 &= ~0x20; + } + } else if (this->unk_286 == 2) { + this->unk_286 = 1; + } + + if (this->unk_286 == 1) { + switch (func_80B26BF8(this, globalCtx)) { + case 0: + this->unk_286 = 0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + player->stateFlags1 |= 0x20; + func_80B26EB4(this, globalCtx); + break; + + case 1: + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + this->unk_286 = 0; + player->stateFlags1 |= 0x20; + func_801518B0(globalCtx, 0x2729, &this->actor); + this->unk_288 = 0x2729; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + break; + + default: + if (this->unk_28C == 0) { + this->unk_290++; + if (this->unk_290 == 30) { + this->unk_290 = 0; + func_80B279F0(this, globalCtx, 0); + } + } + break; + } + + if ((this->skelAnime.animation == &object_js_Anim_0003DC) && + Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + } + + if (this->unk_284 == 7) { + gSaveContext.weekEventReg[82] &= (u8)~8; + func_80B26AE8(this); + } + } +} + +void func_80B273D0(EnKendoJs* this) { + gSaveContext.weekEventReg[82] |= 8; + this->unk_290 = 120; + this->unk_284 = 0; + this->unk_286 = 1; + this->actionFunc = func_80B2740C; +} + +void func_80B2740C(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp18 = this->actor.world.pos; + + sp18.z += 300.0f; + + if (func_80B278C4(globalCtx, sp18)) { + this->unk_28C = 0; + player->stateFlags1 &= ~0x20; + this->actionFunc = func_80B274BC; + } +} + +void func_80B274BC(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_290 >= 140) { + if (this->unk_284 == 5) { + if (gSaveContext.minigameScore == 30) { + func_801518B0(globalCtx, 0x272D, &this->actor); + this->unk_288 = 0x272D; + } else { + func_801518B0(globalCtx, 0x272E, &this->actor); + this->unk_288 = 0x272E; + } + player->stateFlags1 |= 0x20; + gSaveContext.weekEventReg[82] &= (u8)~8; + func_80B26AE8(this); + return; + } + + play_sound(NA_SE_SY_FOUND); + func_80B279F0(this, globalCtx, ((Rand_Next() & 0xFF) % 3) + 1); + func_80B279F0(this, globalCtx, ((Rand_Next() & 0xFF) % 3) + 4); + this->unk_290 = 0; + this->unk_284++; + } else if (this->unk_290 == 120) { + func_80B27A90(this, globalCtx); + this->unk_290++; + } else { + this->unk_290++; + } + + if (this->unk_28E == 1) { + if ((player->swordAnimation == 17) || (player->swordAnimation == 20)) { + globalCtx->interfaceCtx.unk_25C = 3; + if (gSaveContext.minigameScore >= 27) { + player->stateFlags1 |= 0x20; + } + } else if (player->swordAnimation == 12) { + globalCtx->interfaceCtx.unk_25C = 2; + } else { + globalCtx->interfaceCtx.unk_25C = 1; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + this->unk_28E = 0; + } + func_80B2783C(this, globalCtx); +} + +void func_80B276C4(EnKendoJs* this) { + this->actionFunc = func_80B276D8; +} + +void func_80B276D8(EnKendoJs* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + func_80B27760(this); + } else if (!(gSaveContext.weekEventReg[63] & 0x20)) { + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 800.0f, 100.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 800.0f, 100.0f); + } +} + +void func_80B27760(EnKendoJs* this) { + this->actionFunc = func_80B27774; +} + +void func_80B27774(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (!(gSaveContext.weekEventReg[63] & 0x20)) { + gSaveContext.weekEventReg[63] |= 0x20; + func_801518B0(globalCtx, 0x272F, &this->actor); + this->unk_288 = 0x272F; + } else { + func_801518B0(globalCtx, 0x2730, &this->actor); + this->unk_288 = 0x2730; + } + func_80B26AE8(this); + player->stateFlags1 &= ~0x20; + } else { + func_800B85E0(&this->actor, globalCtx, 1000.0f, -1); + } +} + +void func_80B2783C(EnKendoJs* this, GlobalContext* globalCtx) { + if (this->actor.cutscene != -1) { + func_800DFB14(globalCtx->cameraPtrs[MAIN_CAM], ActorCutscene_GetCutscene(this->actor.cutscene)->unk4); + } +} + +void func_80B27880(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp_f0 = this->actor.world.pos.z + 70.0f; + + if ((ENKENDOJS_GET_FF(&this->actor) != ENKENDOJS_FF_1) && (player->actor.world.pos.z < temp_f0)) { + player->actor.world.pos.z = temp_f0; + } +} + +s32 func_80B278C4(GlobalContext* globalCtx, Vec3f arg1) { + Player* player = GET_PLAYER(globalCtx); + f32 temp_f0; + f32 sp28; + s16 sp22 = Math_Vec3f_Yaw(&player->actor.world.pos, &arg1); + + temp_f0 = Math_Vec3f_DistXZ(&player->actor.world.pos, &arg1); + + if (temp_f0 < 20.0f) { + sp28 = 10.0f; + } else if (temp_f0 < 40.0f) { + sp28 = 40.0f; + } else { + sp28 = 80.0f; + } + + globalCtx->actorCtx.unk268 = 1; + func_800B6F20(globalCtx, &globalCtx->actorCtx.unk_26C, sp28, sp22); + + if (temp_f0 < 20.0f) { + return true; + } else { + return false; + } +} + +void func_80B279AC(EnKendoJs* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_80B279F0(EnKendoJs* this, GlobalContext* globalCtx, s32 arg2) { + f32 x = this->unk_274[arg2].x; + f32 y = this->unk_274[arg2].y; + f32 z = this->unk_274[arg2].z; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_MARUTA, x, y, z, 0, 0, 0, 0); + this->unk_28C++; +} + +void func_80B27A90(EnKendoJs* this, GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; + + while (actor != NULL) { + if (actor->id == ACTOR_EN_MARUTA) { + ((EnMaruta*)actor)->unk_220 = 1; + } + actor = actor->next; + } + + this->unk_28C = 0; +} + +void EnKendoJs_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKendoJs* this = THIS; + + this->actionFunc(this, globalCtx); + + SkelAnime_Update(&this->skelAnime); + func_800E9250(globalCtx, &this->actor, &this->unk_278, &this->unk_27E, this->actor.focus.pos); + func_80B279AC(this, globalCtx); + func_80B27880(this, globalCtx); +} + +s32 EnKendoJs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnKendoJs* this = THIS; + + if (limbIndex == 12) { + rot->y -= this->unk_278.y; + } + return false; +} + +void EnKendoJs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +} + +void EnKendoJs_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKendoJs* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnKendoJs_OverrideLimbDraw, EnKendoJs_PostLimbDraw, &this->actor); +} 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 33da3ea09..2820aac21 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 @@ -7,11 +7,29 @@ struct EnKendoJs; typedef void (*EnKendoJsActionFunc)(struct EnKendoJs*, GlobalContext*); +#define ENKENDOJS_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ENKENDOJS_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + +#define ENKENDOJS_FF_1 1 + typedef struct EnKendoJs { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnKendoJsActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0xBC]; + /* 0x01D8 */ Vec3s jointTable[13]; + /* 0x0226 */ Vec3s morphTable[13]; + /* 0x0274 */ Vec3s* unk_274; + /* 0x0278 */ Vec3s unk_278; + /* 0x027E */ Vec3s unk_27E; + /* 0x0284 */ s16 unk_284; + /* 0x0286 */ s16 unk_286; + /* 0x0288 */ s16 unk_288; + /* 0x028A */ s16 unk_28A; + /* 0x028C */ s16 unk_28C; + /* 0x028E */ s16 unk_28E; + /* 0x0290 */ s16 unk_290; + /* 0x0292 */ u8 unk_292; } EnKendoJs; // size = 0x294 extern const ActorInit En_Kendo_Js_InitVars; diff --git a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h index df53fbe49..0fc546e4d 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h @@ -10,7 +10,8 @@ typedef void (*EnMarutaActionFunc)(struct EnMaruta*, GlobalContext*); typedef struct EnMaruta { /* 0x0000 */ Actor actor; /* 0x0144 */ EnMarutaActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xDC]; + /* 0x0148 */ char unk_148[0xD8]; + /* 0x0220 */ s16 unk_220; } EnMaruta; // size = 0x224 extern const ActorInit En_Maruta_InitVars; diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.c b/src/overlays/actors/ovl_En_Zog/z_en_zog.c index edc5ad595..3fd7f24b8 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -882,7 +882,7 @@ void func_80B94E34(EnZog* this, GlobalContext* globalCtx) { } if (ABS_ALT(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0x5000) { - Actor_PickUp(&this->actor, globalCtx, 0, 60.0f, 40.0f); + Actor_PickUp(&this->actor, globalCtx, GI_NONE, 60.0f, 40.0f); } if (this->unk_324 > 0) { diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c index acebaef13..0365f3420 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -518,7 +518,7 @@ void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { s16 temp_v0_3 = this->actor.yawTowardsPlayer - GET_PLAYER(globalCtx)->actor.world.rot.y; if (ABS_ALT(temp_v0_3) >= 0x5556) { - Actor_PickUp(&this->actor, globalCtx, 0, 36.0f, 30.0f); + Actor_PickUp(&this->actor, globalCtx, GI_NONE, 36.0f, 30.0f); } } } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 15e27b685..6ba5842ed 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -13330,8 +13330,8 @@ 0x80B279F0:("func_80B279F0",), 0x80B27A90:("func_80B27A90",), 0x80B27ACC:("EnKendoJs_Update",), - 0x80B27B54:("func_80B27B54",), - 0x80B27B8C:("func_80B27B8C",), + 0x80B27B54:("EnKendoJs_OverrideLimbDraw",), + 0x80B27B8C:("EnKendoJs_PostLimbDraw",), 0x80B27BA4:("EnKendoJs_Draw",), 0x80B28080:("BgBotihasira_Init",), 0x80B28124:("BgBotihasira_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 943116324..413b7d051 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1548,13 +1548,6 @@ D_06001630 = 0x06001630; D_06004274 = 0x06004274; D_0600DEE8 = 0x0600DEE8; -// ovl_En_Kendo_Js - -D_0600016C = 0x0600016C; -D_060003DC = 0x060003DC; -D_06000F4C = 0x06000F4C; -D_06006990 = 0x06006990; - // ovl_En_Kitan D_06000CE8 = 0x06000CE8; From 9f5217c81f9d0c83d184c984906107b6edadf53e Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 19 Feb 2022 20:16:21 +0000 Subject: [PATCH 029/257] En_Zow (#607) * En_Zow * Matching * PR --- spec | 3 +- src/overlays/actors/ovl_En_Zow/z_en_zow.c | 623 ++++++++++++++++++++-- src/overlays/actors/ovl_En_Zow/z_en_zow.h | 28 +- tools/disasm/variables.txt | 4 +- undefined_syms.txt | 12 - 5 files changed, 613 insertions(+), 57 deletions(-) diff --git a/spec b/spec index ad4088108..9e891a30c 100644 --- a/spec +++ b/spec @@ -4834,8 +4834,7 @@ beginseg name "ovl_En_Zow" compress include "build/src/overlays/actors/ovl_En_Zow/z_en_zow.o" - include "build/data/ovl_En_Zow/ovl_En_Zow.data.o" - include "build/data/ovl_En_Zow/ovl_En_Zow.reloc.o" + include "build/src/overlays/actors/ovl_En_Zow/ovl_En_Zow_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.c b/src/overlays/actors/ovl_En_Zow/z_en_zow.c index 2147bc5f4..3ada9fc10 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -5,8 +5,9 @@ */ #include "z_en_zow.h" +#include "objects/object_zo/object_zo.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnZow*)thisx) @@ -21,7 +22,6 @@ void func_80BDD634(EnZow* this, GlobalContext* globalCtx); void func_80BDD6BC(EnZow* this, GlobalContext* globalCtx); void func_80BDD79C(EnZow* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Zow_InitVars = { ACTOR_EN_ZOW, ACTORCAT_NPC, @@ -34,72 +34,617 @@ const ActorInit En_Zow_InitVars = { (ActorFunc)EnZow_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BDDCF0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +Vec3f D_80BDDD1C = { 0.0f, 1.0f, 0.0f }; -extern ColliderCylinderInit D_80BDDCF0; +Vec3f D_80BDDD28 = { 0.0f, -1.0f, 0.0f }; -extern UNK_TYPE D_06002A50; -extern UNK_TYPE D_06002C10; -extern UNK_TYPE D_06004248; -extern UNK_TYPE D_0600D288; +void func_80BDC270(EnZowStruct* ptr, Vec3f* arg1, f32 arg2, f32 arg3, u8 arg4) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC270.s") + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_00 = 1; + ptr->unk_14 = *arg1; + ptr->unk_04 = arg2; + ptr->unk_08 = arg3; + ptr->unk_0F = arg4; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC2D8.s") +void func_80BDC2D8(EnZow* this, EnZowStruct* ptr, Vec3f* arg2) { + s16 i; + f32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC3C0.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++, ptr++) { + if (ptr->unk_00 == 0) { + temp = this->actor.world.pos.y + this->actor.depthInWater; + if (temp <= arg2->y) { + continue; + } + ptr->unk_00 = 3; + ptr->unk_14 = *arg2; + ptr->unk_20 = *arg2; + ptr->unk_2C = D_80BDDD1C; + ptr->unk_04 = ((Rand_ZeroOne() - 0.5f) * 0.02f) + 0.12f; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC50C.s") +void func_80BDC3C0(EnZowStruct* ptr, Vec3f* arg1, Vec3f* arg2, f32 arg3) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC5C8.s") + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 != 2) { + ptr->unk_00 = 2; + ptr->unk_14 = *arg1; + ptr->unk_20 = D_80BDDD28; + ptr->unk_2C = *arg2; + ptr->unk_0F = (Rand_ZeroOne() * 100.0f) + 100.0f; + ptr->unk_04 = arg3; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC6F8.s") +void func_80BDC50C(EnZowStruct* ptr) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC830.s") + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 1) { + Math_ApproachF(&ptr->unk_04, ptr->unk_08, 0.2f, 0.8f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC9DC.s") + if (ptr->unk_0F > 20) { + ptr->unk_0F -= 20; + } else { + ptr->unk_0F = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDCB84.s") + if (ptr->unk_0F == 0) { + ptr->unk_00 = 0; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDCD38.s") +void func_80BDC5C8(EnZow* this, EnZowStruct* ptr) { + f32 temp_f2; + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDCDA8.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++, ptr++) { + if (ptr->unk_00 == 3) { + ptr->unk_14.x = ((Rand_ZeroOne() * 0.5f) - 0.25f) + ptr->unk_20.x; + ptr->unk_14.z = ((Rand_ZeroOne() * 0.5f) - 0.25f) + ptr->unk_20.z; + ptr->unk_14.y += ptr->unk_2C.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/EnZow_Init.s") + temp_f2 = this->actor.world.pos.y + this->actor.depthInWater; + if (temp_f2 <= ptr->unk_14.y) { + ptr->unk_00 = 0; + ptr->unk_14.y = temp_f2; + func_80BDC270(ptr, &ptr->unk_14, 0.06f, 0.12f, 200); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/EnZow_Destroy.s") +void func_80BDC6F8(EnZow* this, EnZowStruct* ptr) { + s16 i; + f32 temp_f0_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD04C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++, ptr++) { + if (ptr->unk_00 == 2) { + ptr->unk_14.x += ptr->unk_2C.x; + ptr->unk_14.y += ptr->unk_2C.y; + ptr->unk_14.z += ptr->unk_2C.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD154.s") + if (ptr->unk_2C.y >= -20.0f) { + ptr->unk_2C.y += ptr->unk_20.y; + } else { + ptr->unk_2C.y = -20.0f; + ptr->unk_20.y = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD1E0.s") + temp_f0_2 = this->actor.world.pos.y + this->actor.depthInWater; + if (ptr->unk_14.y < temp_f0_2) { + ptr->unk_00 = 0; + ptr->unk_14.y = temp_f0_2; + func_80BDC270(ptr, &ptr->unk_14, 0.06f, 0.12f, 200); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD350.s") +void func_80BDC830(EnZowStruct* ptr, GlobalContext* globalCtx) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD490.s") + OPEN_DISPS(globalCtx->state.gfxCtx); + u8 flag = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD570.s") + func_8012C2DC(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD634.s") + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 1) { + if (!flag) { + gDPPipeSync(POLY_XLU_DISP++); + gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_00D220); + gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 155, 0); + if (1) {} + flag = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD6BC.s") + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, ptr->unk_0F); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD79C.s") + Matrix_InsertTranslation(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_Scale(ptr->unk_04, 1.0f, ptr->unk_04, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/EnZow_Update.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_00D288); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDDA7C.s") + CLOSE_DISPS(globalCtx->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDDAA0.s") +void func_80BDC9DC(EnZowStruct* ptr, GlobalContext* globalCtx) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDDAE0.s") + OPEN_DISPS(globalCtx->state.gfxCtx); + u8 flag = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/EnZow_Draw.s") + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 3) { + if (!flag) { + gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_0029F0); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 150, 150, 150, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + if (1) {} + flag = true; + } + + Matrix_InsertTranslation(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(ptr->unk_04, ptr->unk_04, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_002A50); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80BDCB84(EnZowStruct* ptr, GlobalContext* globalCtx) { + s16 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + u8 flag = false; + + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 2) { + if (!flag) { + gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_002BA0); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, 0); + if (1) {} + flag = true; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 180, 180, 180, ptr->unk_0F); + + Matrix_InsertTranslation(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(ptr->unk_04, ptr->unk_04, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_002C10); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80BDCD38(EnZow* this, EnZowStruct* ptr, f32 arg2, f32 arg3, u8 arg4) { + static Vec3f D_80BDDD34 = { 0.0f, 0.0f, 0.0f }; + + D_80BDDD34.x = this->actor.world.pos.x; + D_80BDDD34.y = this->actor.world.pos.y + this->actor.depthInWater; + D_80BDDD34.z = this->actor.world.pos.z; + func_80BDC270(ptr, &D_80BDDD34, arg2, arg3, arg4); +} + +void func_80BDCDA8(EnZow* this, EnZowStruct* ptr) { + Vec3f sp84; + Vec3f sp78; + f32 temp_f20; + f32 temp_f22; + s32 i; + + for (i = 0; i < 10; i++) { + temp_f20 = (Rand_ZeroOne() * 1.5f) + 0.5f; + temp_f22 = Rand_ZeroOne() * 6.28f; + + sp78.y = (Rand_ZeroOne() * 3.0f) + 3.0f; + sp78.x = __sinf(temp_f22) * temp_f20; + sp78.z = __cosf(temp_f22) * temp_f20; + + sp84 = this->actor.world.pos; + sp84.x += sp78.x * 6.0f; + sp84.z += sp78.z * 6.0f; + sp84.y += this->actor.depthInWater; + + func_80BDC3C0(ptr, &sp84, &sp78, 0.08f); + } +} + +void EnZow_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZow* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_80BDD79C; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, &gZoraIdleAnim, this->jointTable, this->morphTable, 20); + Animation_PlayOnce(&this->skelAnime, &gZoraSurfacingAnim); + this->unk_2C8 = 1; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.shape.rot.z = 0; + this->unk_2CA = 0; + this->unk_2CC = 0; + this->unk_2CE = 0; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.textId = 0; + this->actor.world.rot.z = this->actor.shape.rot.z; + this->actor.flags &= ~ACTOR_FLAG_1; +} + +void EnZow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnZow* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +AnimationHeader* sAnimations[] = { &object_zo_Anim_004168, &gZoraSurfacingAnim, &gZoraSurfacingAnim }; + +void func_80BDD04C(EnZow* this, s16 arg1, u8 arg2) { + if ((arg1 >= 0) && (arg1 < 3)) { + if (arg1 < 2) { + Animation_Change(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[arg1]), + arg2, -5.0f); + } else { + Animation_Change(&this->skelAnime, sAnimations[arg1], -1.0f, Animation_GetLastFrame(sAnimations[arg1]), + 0.0f, arg2, 0.0f); + } + this->unk_2C8 = arg1; + } +} + +s32 func_80BDD154(EnZow* this, GlobalContext* globalCtx) { + if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x3000) && + (this->actor.xzDistToPlayer < 170.0f) && (fabsf(this->actor.playerHeightRel) < 100.0f)) { + return true; + } + return false; +} + +void func_80BDD1E0(EnZow* this, GlobalContext* globalCtx) { + u16 phi_a1; + + if (ENZOW_GET_F(&this->actor) == ENZOW_F_1) { + if (gSaveContext.weekEventReg[55] & 0x80) { + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.weekEventReg[78] & 4) { + phi_a1 = 0x12FD; + } else { + phi_a1 = 0x12FA; + gSaveContext.weekEventReg[78] |= 4; + } + } else if (gSaveContext.weekEventReg[78] & 0x10) { + phi_a1 = 0x1301; + } else { + gSaveContext.weekEventReg[78] |= 0x10; + phi_a1 = 0x12FF; + } + } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.weekEventReg[78] & 8) { + phi_a1 = 0x12F8; + } else { + phi_a1 = 0x12F3; + gSaveContext.weekEventReg[78] |= 8; + } + } else if (gSaveContext.weekEventReg[78] & 0x10) { + phi_a1 = 0x1301; + } else { + gSaveContext.weekEventReg[78] |= 0x10; + phi_a1 = 0x12FF; + } + } else if (gSaveContext.weekEventReg[55] & 0x80) { + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + phi_a1 = 0x12EC; + } else { + phi_a1 = 0x12F1; + } + } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.weekEventReg[78] & 2) { + phi_a1 = 0x12EB; + } else { + phi_a1 = 0x12E8; + gSaveContext.weekEventReg[78] |= 2; + } + } else { + phi_a1 = 0x12EF; + } + func_801518B0(globalCtx, phi_a1, &this->actor); +} + +void func_80BDD350(EnZow* this, GlobalContext* globalCtx) { + if (this->unk_2CA & 2) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_WATER); + func_80BDCDA8(this, this->unk_2D0); + this->actor.flags &= ~ACTOR_FLAG_1; + this->skelAnime.playSpeed = 0.0f; + this->actor.velocity.y = -4.0f; + } + + if (this->actor.depthInWater > 120.0f) { + Math_ApproachF(&this->actor.velocity.y, 0.0f, 0.4f, 0.6f); + if (this->actor.velocity.y > -0.1f) { + this->actor.velocity.y = 0.0f; + this->actionFunc = func_80BDD79C; + } + } + + if ((this->actor.bgCheckFlags & 1) || (this->actor.depthInWater > 180.0f)) { + this->actor.velocity.y = 0.0f; + this->actionFunc = func_80BDD79C; + } + + if (this->skelAnime.playSpeed <= 0.0f) { + if (this->unk_2CE >= 6) { + this->unk_2CE -= 5; + return; + } else { + this->unk_2CE = 0; + } + } +} + +void func_80BDD490(EnZow* this, GlobalContext* globalCtx) { + this->actor.velocity.y = 0.0f; + if (this->actor.xzDistToPlayer > 440.0f) { + this->actionFunc = func_80BDD350; + func_80BDD04C(this, 2, 2); + } else if (this->unk_2CA & 2) { + func_80BDD04C(this, 0, 0); + } + + if ((globalCtx->gameplayFrames & 7) == 0) { + func_80BDCD38(this, this->unk_2D0, 0.2f, 1.0f, 200); + } + + if (this->unk_2CE < 245) { + this->unk_2CE += 10; + } else { + this->unk_2CE = 255; + } +} + +void func_80BDD570(EnZow* this, GlobalContext* globalCtx) { + func_80BDD490(this, globalCtx); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 5: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x12E8: + case 0x12E9: + case 0x12EC: + case 0x12ED: + case 0x12EF: + case 0x12F1: + case 0x12F3: + case 0x12F4: + case 0x12F5: + case 0x12F6: + case 0x12F8: + case 0x12FA: + case 0x12FB: + case 0x12FD: + case 0x12FF: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + default: + func_801477B4(globalCtx); + break; + } + } + break; + + case 2: + this->actionFunc = func_80BDD634; + break; + } +} + +void func_80BDD634(EnZow* this, GlobalContext* globalCtx) { + func_80BDD490(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80BDD570; + func_80BDD1E0(this, globalCtx); + } else if (func_80BDD154(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 180.0f); + } +} + +void func_80BDD6BC(EnZow* this, GlobalContext* globalCtx) { + if (this->unk_2CE < 245) { + this->unk_2CE += 10; + } else { + this->unk_2CE = 255; + } + + if (this->actor.depthInWater < 54.0f) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); + func_80BDCDA8(this, this->unk_2D0); + func_80BDD04C(this, 1, 2); + this->actor.flags |= ACTOR_FLAG_1; + this->actor.velocity.y = 0.0f; + this->actionFunc = func_80BDD634; + } else if (this->actor.depthInWater < 80.0f) { + Math_ApproachF(&this->actor.velocity.y, 2.0f, 0.4f, 0.6f); + } +} + +void func_80BDD79C(EnZow* this, GlobalContext* globalCtx) { + if (this->actor.xzDistToPlayer < 400.0f) { + this->actor.velocity.y = 4.0f; + this->actionFunc = func_80BDD6BC; + } + + if (this->unk_2CE >= 6) { + this->unk_2CE -= 5; + } else { + this->unk_2CE = 0; + } + + if (this->actor.depthInWater > 180.0f) { + this->actor.world.pos.y = this->actor.world.pos.y + -180.0f + this->actor.depthInWater; + } +} + +void EnZow_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZow* this = THIS; + Vec3f sp34; + + Actor_MoveWithGravity(&this->actor); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 15.0f, 30.0f, 5); + + if (this->unk_2CE != 0) { + this->unk_2CA &= ~2; + if (SkelAnime_Update(&this->skelAnime)) { + this->unk_2CA |= 2; + } + } else { + this->unk_2CA |= 2; + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + + this->actionFunc(this, globalCtx); + + if (this->unk_2CE != 0) { + if ((globalCtx->state.frames & 8) != 0) { + sp34 = this->actor.world.pos; + sp34.y += ((Rand_ZeroOne() - 0.5f) * 10.0f) + 18.0f; + sp34.x += (Rand_ZeroOne() - 0.5f) * 28.0f; + sp34.z += (Rand_ZeroOne() - 0.5f) * 28.0f; + func_80BDC2D8(this, this->unk_2D0, &sp34); + } + + if (DECR(this->unk_2C6) == 0) { + this->unk_2C6 = Rand_S16Offset(60, 60); + } + + this->unk_2C4 = this->unk_2C6; + if (this->unk_2C4 >= 3) { + this->unk_2C4 = 0; + } + } + + this->actor.shape.shadowAlpha = this->unk_2CE; + func_80BDC50C(this->unk_2D0); + func_80BDC5C8(this, this->unk_2D0); + func_80BDC6F8(this, this->unk_2D0); +} + +Gfx* func_80BDDA7C(GraphicsContext* gfxCtx) { + Gfx* gfx = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + + gSPEndDisplayList(gfx); + + return gfx; +} + +Vec3f D_80BDDD4C = { 400.0f, 0.0f, 0.0f }; + +void func_80BDDAA0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + if (limbIndex == 15) { + Matrix_MultiplyVector3fByState(&D_80BDDD4C, &thisx->focus.pos); + } +} + +void func_80BDDAE0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + func_80BDDAA0(globalCtx, limbIndex, dList, rot, thisx); +} + +void EnZow_Draw(Actor* thisx, GlobalContext* globalCtx) { + TexturePtr sp54[] = { + gZoraEyeOpenTex, + gZoraEyeHalfTex, + gZoraEyeClosedTex, + }; + EnZow* this = THIS; + + Matrix_StatePush(); + + func_80BDC830(this->unk_2D0, globalCtx); + func_80BDC9DC(this->unk_2D0, globalCtx); + func_80BDCB84(this->unk_2D0, globalCtx); + + Matrix_StatePop(); + + if (this->unk_2CE != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_2CE >= 255) { + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp54[this->unk_2C4])); + gSPSegment(POLY_OPA_DISP++, 0x0C, func_80BDDA7C(globalCtx->state.gfxCtx)); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, func_80BDDAA0, &this->actor); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sp54[this->unk_2C4])); + + func_800BDAA0(globalCtx, &this->skelAnime, NULL, func_80BDDAE0, &this->actor, this->unk_2CE); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.h b/src/overlays/actors/ovl_En_Zow/z_en_zow.h index 976e4e29b..e169e2816 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.h +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.h @@ -7,9 +7,35 @@ struct EnZow; typedef void (*EnZowActionFunc)(struct EnZow*, GlobalContext*); +#define ENZOW_GET_F(thisx) ((thisx)->params & 0xF) + +#define ENZOW_F_1 1 + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ UNK_TYPE1 unk_0C[0x3]; + /* 0x0F */ u8 unk_0F; + /* 0x10 */ UNK_TYPE1 unk_10[0x4]; + /* 0x14 */ Vec3f unk_14; + /* 0x20 */ Vec3f unk_20; + /* 0x2C */ Vec3f unk_2C; +} EnZowStruct; // size = 0x38 + typedef struct EnZow { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4D4]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ ColliderCylinder collider; + /* 0x01D4 */ Vec3s jointTable[20]; + /* 0x024C */ Vec3s morphTable[20]; + /* 0x02C4 */ s16 unk_2C4; + /* 0x02C6 */ s16 unk_2C6; + /* 0x02C8 */ s16 unk_2C8; + /* 0x02CA */ u16 unk_2CA; + /* 0x02CC */ s16 unk_2CC; + /* 0x02CE */ s16 unk_2CE; + /* 0x02D0 */ EnZowStruct unk_2D0[15]; /* 0x0618 */ EnZowActionFunc actionFunc; } EnZow; // size = 0x61C diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index d82b93e99..2ccca1ea7 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -16049,9 +16049,7 @@ 0x80BDDCF0:("D_80BDDCF0","UNK_TYPE1","",0x1), 0x80BDDD1C:("D_80BDDD1C","UNK_TYPE4","",0x4), 0x80BDDD28:("D_80BDDD28","UNK_TYPE4","",0x4), - 0x80BDDD34:("D_80BDDD34","f32","",0x4), - 0x80BDDD38:("D_80BDDD38","f32","",0x4), - 0x80BDDD3C:("D_80BDDD3C","f32","",0x4), + 0x80BDDD34:("D_80BDDD34","Vec3f","",0xC), 0x80BDDD40:("D_80BDDD40","UNK_TYPE1","",0x1), 0x80BDDD4C:("D_80BDDD4C","UNK_TYPE1","",0x1), 0x80BDDD58:("D_80BDDD58","UNK_TYPE4","",0x4), diff --git a/undefined_syms.txt b/undefined_syms.txt index 413b7d051..61a474f46 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2027,18 +2027,6 @@ D_06004FE4 = 0x06004FE4; D_06005098 = 0x06005098; D_06005250 = 0x06005250; -// ovl_En_Zow - -D_060029F0 = 0x060029F0; -D_06002A50 = 0x06002A50; -D_06002BA0 = 0x06002BA0; -D_06002C10 = 0x06002C10; -D_06003610 = 0x06003610; -D_06004248 = 0x06004248; -D_0600D208 = 0x0600D208; -D_0600D220 = 0x0600D220; -D_0600D288 = 0x0600D288; - // ovl_Mir_Ray D_06000168 = 0x06000168; From 320a1a30303e84b6b9e493d2ddf55056dae025af Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 19 Feb 2022 20:22:45 +0000 Subject: [PATCH 030/257] Dm_Char00 (#611) * Dm_Char00 * Replace other macros * PR --- include/PR/gbi.h | 3 + spec | 3 +- src/code/z_lights.c | 3 +- .../actors/ovl_Dm_Char00/z_dm_char00.c | 926 +++++++++++++++++- .../actors/ovl_Dm_Char00/z_dm_char00.h | 25 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 2 +- src/overlays/actors/ovl_En_Ot/z_en_ot.c | 2 +- tools/disasm/functions.txt | 2 +- 8 files changed, 928 insertions(+), 38 deletions(-) diff --git a/include/PR/gbi.h b/include/PR/gbi.h index 2c04e570f..ace2cd2e8 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -2899,6 +2899,9 @@ _DW({ \ gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 2, mode) #endif + #define gDPSetDither(pkt, mode) \ + gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 4, mode) + /* 'blendmask' is not supported anymore. * The bits are reserved for future use. * Fri May 26 13:45:55 PDT 1995 diff --git a/spec b/spec index 9e891a30c..313ff62d6 100644 --- a/spec +++ b/spec @@ -3258,8 +3258,7 @@ beginseg name "ovl_Dm_Char00" compress include "build/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.o" - include "build/data/ovl_Dm_Char00/ovl_Dm_Char00.data.o" - include "build/data/ovl_Dm_Char00/ovl_Dm_Char00.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Char00/ovl_Dm_Char00_reloc.o" endseg beginseg diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 858a7186e..615e11e69 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -413,8 +413,7 @@ void Lights_DrawGlow(GlobalContext* globalCtx) { dl = func_8012C7FC(POLY_XLU_DISP); - gSPSetOtherMode(dl++, G_SETOTHERMODE_H, 4, 4, - 0x00000080); //! This doesn't resolve to any of the macros in gdi.h + gDPSetDither(dl++, G_CD_NOISE); gDPSetCombineLERP(dl++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); diff --git a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c index 596945272..df179cf86 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c @@ -5,8 +5,10 @@ */ #include "z_dm_char00.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_delf/object_delf.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar00*)thisx) @@ -15,7 +17,9 @@ void DmChar00_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmChar00_Update(Actor* thisx, GlobalContext* globalCtx); void DmChar00_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80AA67F8(DmChar00* this, GlobalContext* globalCtx); +void func_80AA695C(DmChar00* this, GlobalContext* globalCtx); + const ActorInit Dm_Char00_InitVars = { ACTOR_DM_CHAR00, ACTORCAT_ITEMACTION, @@ -28,56 +32,920 @@ const ActorInit Dm_Char00_InitVars = { (ActorFunc)DmChar00_Draw, }; -#endif +static AnimationInfo sAnimations[] = { + { &gameplay_keep_Anim_02B2E8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &gameplay_keep_Anim_029140, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_004FF4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_0053A4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_005B68, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_006328, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00FB30, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_010590, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_005B68, 1.0f, 37.0f, 56.0f, 4, 0.0f }, + { &object_delf_Anim_006328, 1.0f, 37.0f, 56.0f, 4, 0.0f }, + { &object_delf_Anim_00E024, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00F0D0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_011C70, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_011FE0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_011088, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_0118FC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_012388, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_012738, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_013BE0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_013E80, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_007B04, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_0080A4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00859C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_008A44, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00EB18, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00EBB0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00EE30, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_012BBC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_012EF8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00C248, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00C588, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00BDFC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00C0BC, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_013040, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_013378, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_0091BC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_0094B0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_009C4C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_009F40, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_009010, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_0097C4, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00A7B4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00C588, 1.0f, 0.0f, -1.0f, 0, -10.0f }, + { &object_delf_Anim_004FF4, 1.0f, 0.0f, -1.0f, 2, -10.0f }, + { &object_delf_Anim_011C70, 1.0f, 0.0f, -1.0f, 0, -10.0f }, + { &object_delf_Anim_006B28, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_014190, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_01447C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_003FAC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_004798, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_0042E8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_004C44, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_01088C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_01498C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_014E9C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00CEE0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00D260, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00C690, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00C790, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00AF78, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00B2B8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00BCD8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_006D74, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00706C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_0072B0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_007570, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00A2A4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00A4B4, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_006614, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_015114, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00CCD4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00046C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00065C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00377C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_003148, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_001410, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_0010F8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00199C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_003BB4, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_001754, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_0008E0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_000A94, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_001ED4, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_001B28, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_000E44, 1.0f, 0.0f, -1.0f, 0, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5580.s") +DmChar00Struct D_80AA77A8[] = { + { 250.0f, 255.0f, 230.0f, 255.0f }, + { 63.0f, 18.0f, 93.0f, 255.0f }, + { 255.0f, 235.0f, 220.0f, 255.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA561C.s") +DmChar00Struct D_80AA77D8[] = { + { 220.0f, 160.0f, 80.0f, 255.0f }, + { 250.0f, 40.0f, 10.0f, 255.0f }, + { 255.0f, 235.0f, 220.0f, 255.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5720.s") +Vec3f D_80AA7808 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA575C.s") +void func_80AA5580(SkelAnime* skelAnime, AnimationInfo* animation, u16 idx) { + f32 phi_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5890.s") + animation += idx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA58CC.s") + if (animation->frameCount < 0.0f) { + phi_f2 = Animation_GetLastFrame(animation->animation); + } else { + phi_f2 = animation->frameCount; + } + Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, phi_f2, + animation->mode, animation->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5950.s") +void func_80AA561C(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames + 20) { + case 503: + case 926: + case 979: + case 1222: + case 1682: + case 2194: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5960.s") + case 1858: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_ATTACK); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA59E4.s") + case 2043: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + break; + } + } else { + switch (globalCtx->csCtx.frames + 20) { + case 503: + case 926: + case 979: + case 1234: + case 1687: + case 2194: + case 2210: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5A6C.s") + case 2043: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONDO_SURPRISE); + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5AF4.s") +void func_80AA5720(DmChar00* this, GlobalContext* globalCtx) { + if ((DMCHAR00_GET(&this->actor) == DMCHAR00_0) && (globalCtx->csCtx.frames == 505)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SPOT_LIGHT_OPEN); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5BF8.s") +void func_80AA575C(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 474: + case 489: + case 495: + case 505: + case 854: + case 860: + case 866: + case 872: + case 877: + case 882: + case 887: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_ATTACK); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5CD4.s") + case 520: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_SPIT); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5D10.s") + case 774: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5D6C.s") + case 904: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_SIGH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5DC8.s") + case 813: + case 972: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_BRAKE); + break; + } + } else if (globalCtx->csCtx.frames == 660) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONDO_SURPRISE); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5E2C.s") +void func_80AA5890(DmChar00* this, GlobalContext* globalCtx) { + if ((DMCHAR00_GET(&this->actor) == DMCHAR00_0) && (globalCtx->csCtx.frames == 20)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5EBC.s") +void func_80AA58CC(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + if (globalCtx->csCtx.frames == 568) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + } + } else { + switch (globalCtx->csCtx.frames) { + case 375: + case 479: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/DmChar00_Init.s") + case 534: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_ATTACK); + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/DmChar00_Destroy.s") +void func_80AA5950(DmChar00* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA62FC.s") +void func_80AA5960(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + if (globalCtx->csCtx.frames == 280) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + } + } else { + switch (globalCtx->csCtx.frames) { + case 87: + case 190: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA67F8.s") + case 244: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_ATTACK); + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA695C.s") +void func_80AA59E4(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 125: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/DmChar00_Update.s") + case 1832: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_WHITE_OUT_INTO_MOON); + break; + } + } else if (globalCtx->csCtx.frames == 125) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA6A6C.s") +void func_80AA5A6C(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 44: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/DmChar00_Draw.s") + case 891: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_WHITE_OUT_INTO_MOON); + break; + } + } else if (globalCtx->csCtx.frames == 44) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + } +} + +void func_80AA5AF4(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 352: + case 401: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; + + case 440: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; + + case 550: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_BRAKE); + break; + } + } else { + switch (globalCtx->csCtx.frames) { + case 362: + case 401: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; + + case 454: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; + } + + if ((globalCtx->csCtx.frames >= 500) && (globalCtx->csCtx.frames < 602)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SHIVER - SFX_FLAG); + } + } +} + +void func_80AA5BF8(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 762: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_SHOT_DASH); + break; + case 797: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; + } + } else { + switch (globalCtx->csCtx.frames) { + case 762: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_SHOT_DASH); + break; + + case 797: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; + } + } + + if ((this->unk_261 == 53) && Animation_OnFrame(&this->skelAnime, 16.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + } +} + +void func_80AA5CD4(DmChar00* this, GlobalContext* globalCtx) { + if ((DMCHAR00_GET(&this->actor) != DMCHAR00_0) && (globalCtx->csCtx.frames == 467)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + } +} + +void func_80AA5D10(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 8: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + break; + + case 130: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_NAVY_VANISH); + break; + } + } +} + +void func_80AA5D6C(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 2: + case 166: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; + + case 31: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + break; + } + } +} + +void func_80AA5DC8(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 233: + case 415: + case 593: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; + + case 130: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_NAVY_VANISH); + break; + } + } +} + +void func_80AA5E2C(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_1) { + switch (globalCtx->csCtx.frames) { + case 32: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; + + case 42: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; + + case 192: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_BRAKE); + break; + + case 215: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WEED); + break; + } + } +} + +void func_80AA5EBC(DmChar00* this, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != 0) { + switch (globalCtx->sceneNum) { + case SCENE_LOST_WOODS: + if (gSaveContext.sceneSetupIndex == 1) { + func_80AA561C(this, globalCtx); + } + break; + + case SCENE_OPENINGDAN: + if (gSaveContext.sceneSetupIndex == 0) { + if (globalCtx->csCtx.unk_12 == 0) { + func_80AA5720(this, globalCtx); + } else if (globalCtx->csCtx.unk_12 == 1) { + func_80AA575C(this, globalCtx); + } else if (globalCtx->csCtx.unk_12 == 2) { + func_80AA5890(this, globalCtx); + } + } + break; + + case SCENE_OKUJOU: + if (gSaveContext.sceneSetupIndex == 0) { + if (globalCtx->csCtx.unk_12 == 0) { + func_80AA58CC(this, globalCtx); + } else if (globalCtx->csCtx.unk_12 == 1) { + func_80AA5950(this, globalCtx); + } else if (globalCtx->csCtx.unk_12 == 2) { + func_80AA5960(this, globalCtx); + } + } else if (gSaveContext.sceneSetupIndex == 2) { + if (globalCtx->csCtx.unk_12 == 0) { + func_80AA59E4(this, globalCtx); + } else if (globalCtx->csCtx.unk_12 == 1) { + func_80AA5A6C(this, globalCtx); + } + } + break; + + case SCENE_00KEIKOKU: + if (gSaveContext.sceneSetupIndex == 3) { + if (globalCtx->csCtx.unk_12 == 0) { + func_80AA5AF4(this, globalCtx); + } else if (globalCtx->csCtx.unk_12 == 2) { + func_80AA5E2C(this, globalCtx); + } + } else if (gSaveContext.sceneSetupIndex == 7) { + if (globalCtx->csCtx.unk_12 == 0) { + func_80AA5BF8(this, globalCtx); + } else if (globalCtx->csCtx.unk_12 == 1) { + func_80AA5CD4(this, globalCtx); + } + } + break; + + case SCENE_MITURIN: + if ((gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.unk_12 == 1)) { + func_80AA5DC8(this, globalCtx); + } + break; + + case SCENE_INSIDETOWER: + if ((gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.unk_12 == 0)) { + func_80AA5D10(this, globalCtx); + } + break; + + case SCENE_PIRATE: + if ((gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.unk_12 == 0)) { + func_80AA5D6C(this, globalCtx); + } + break; + } + } +} + +void DmChar00_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DmChar00* this = THIS; + + if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !func_800EE2F4(globalCtx)) { + Actor_MarkForDeath(thisx); + } + + this->unk_240 = D_80AA77A8[DMCHAR00_GET(thisx)]; + this->unk_250 = D_80AA77D8[DMCHAR00_GET(thisx)]; + + thisx->targetArrowOffset = 3000.0f; + this->unk_260 = 99; + this->unk_262 = DMCHAR00_GET_F800(thisx); + + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gameplay_keep_Skel_02AF58.sh, &gameplay_keep_Anim_029140, + this->jointTable, this->morphTable, 7); + ActorShape_Init(&thisx->shape, 0.0f, NULL, 15.0f); + func_80AA5580(&this->skelAnime, sAnimations, 0); + Actor_SetScale(thisx, 0.01f); + this->actionFunc = func_80AA67F8; +} + +void DmChar00_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void func_80AA62FC(DmChar00* this, GlobalContext* globalCtx) { + u16 sp26 = DMCHAR00_GET(&this->actor) + 0x71; + u32 temp_v0; + s32 pad; + + if (func_800EE29C(globalCtx, sp26)) { + temp_v0 = func_800EE200(globalCtx, sp26); + + if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[temp_v0]->startFrame) { + if (this->unk_260 != globalCtx->csCtx.npcActions[temp_v0]->unk0) { + this->unk_260 = globalCtx->csCtx.npcActions[temp_v0]->unk0; + + switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + case 0x1: + this->unk_261 = 0; + break; + + case 0x2: + this->unk_261 = 2; + break; + + case 0x3: + this->unk_261 = 3; + break; + + case 0x4: + this->unk_261 = 4; + break; + + case 0x5: + this->unk_261 = 5; + break; + + case 0x6: + this->unk_261 = 6; + break; + + case 0x7: + this->unk_261 = 7; + break; + + case 0x8: + this->unk_261 = 20; + break; + + case 0x9: + this->unk_261 = 21; + break; + + case 0xA: + this->unk_261 = 14; + break; + + case 0xB: + this->unk_261 = 15; + break; + + case 0xC: + this->unk_261 = 18; + break; + + case 0xD: + this->unk_261 = 25; + break; + + case 0xE: + this->unk_261 = 27; + break; + + case 0xF: + this->unk_261 = 24; + break; + + case 0x10: + this->unk_261 = 10; + break; + + case 0x11: + this->unk_261 = 12; + break; + + case 0x12: + this->unk_261 = 13; + break; + + case 0x13: + this->unk_261 = 29; + break; + + case 0x14: + this->unk_261 = 31; + break; + + case 0x15: + this->unk_261 = 33; + break; + + case 0x16: + Actor_MarkForDeath(&this->actor); + break; + + case 0x17: + this->unk_261 = 35; + break; + + case 0x18: + this->unk_261 = 37; + break; + + case 0x19: + this->unk_261 = 39; + break; + + case 0x1A: + this->unk_261 = 41; + break; + + case 0x1B: + this->unk_261 = 45; + break; + + case 0x1C: + this->unk_261 = 46; + break; + + case 0x1E: + this->unk_261 = 48; + break; + + case 0x1F: + this->unk_261 = 50; + break; + + case 0x20: + this->unk_261 = 52; + break; + + case 0x21: + this->unk_261 = 53; + break; + + case 0x23: + this->unk_261 = 55; + break; + + case 0x24: + this->unk_261 = 57; + break; + + case 0x25: + this->unk_261 = 58; + break; + + case 0x26: + this->unk_261 = 59; + break; + + case 0x27: + this->unk_261 = 61; + break; + + case 0x28: + this->unk_261 = 62; + break; + + case 0x29: + this->unk_261 = 64; + break; + + case 0x2A: + this->unk_261 = 66; + break; + + case 0x2B: + this->unk_261 = 68; + break; + + case 0x2C: + this->unk_261 = 69; + break; + + case 0x2D: + this->unk_261 = 70; + break; + + case 0x2E: + this->unk_261 = 67; + break; + + case 0x2F: + this->unk_261 = 71; + break; + + case 0x30: + this->unk_261 = 73; + break; + + case 0x31: + this->unk_261 = 74; + break; + + case 0x32: + this->unk_261 = 75; + break; + + case 0x33: + this->unk_261 = 77; + break; + + case 0x34: + this->unk_261 = 78; + break; + + case 0x35: + this->unk_261 = 79; + break; + + case 0x36: + this->unk_261 = 80; + break; + + case 0x37: + this->unk_261 = 82; + break; + + case 0x38: + this->unk_261 = 83; + break; + + default: + this->unk_261 = 0; + break; + } + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + } + } + func_800EDF24(&this->actor, globalCtx, temp_v0); + } else { + this->unk_260 = 99; + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + switch (this->unk_261) { + case 0x4: + case 0x5: + this->unk_261 += 4; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + this->skelAnime.curFrame = 37.0f; + break; + + case 0xE: + case 0xF: + case 0x14: + case 0x15: + this->unk_261 += 2; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + break; + + case 0xA: + case 0x12: + case 0x19: + case 0x1B: + case 0x1D: + case 0x1F: + case 0x21: + case 0x23: + case 0x25: + case 0x27: + case 0x2B: + case 0x2E: + case 0x30: + case 0x32: + case 0x35: + case 0x37: + case 0x3B: + case 0x3E: + case 0x40: + case 0x42: + case 0x47: + case 0x4B: + case 0x50: + case 0x53: + this->unk_261 += 1; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + break; + + case 0x2D: + this->unk_261 = 19; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + break; + + case 0x46: + case 0x4D: + this->unk_261 = 0; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + break; + } + } +} + +void func_80AA67F8(DmChar00* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((globalCtx->csCtx.state == 0) && (gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.unk_12 == 1)) { + if (this->unk_261 != 42) { + this->unk_261 = 42; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + } + + Math_SmoothStepToF(&this->actor.world.pos.x, 0.0f, 0.5f, 0.5f, 0.001f); + Math_SmoothStepToF(&this->actor.world.pos.y, 30.0f, 0.5f, 0.5f, 0.001f); + Math_SmoothStepToF(&this->actor.world.pos.z, -560.0f, 0.5f, 20.0f, 0.001f); + + if (player->actor.world.pos.z < -625.0f) { + this->unk_261 = 43; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + this->actionFunc = func_80AA695C; + this->skelAnime.playSpeed = 1.5f; + } + } +} + +void func_80AA695C(DmChar00* this, GlobalContext* globalCtx) { + if (this->unk_261 == 44) { + Math_SmoothStepToF(&this->actor.world.pos.x, 0.0f, 0.5f, 0.5f, 0.001f); + Math_SmoothStepToF(&this->actor.world.pos.y, 30.0f, 0.5f, 0.5f, 0.001f); + Math_SmoothStepToF(&this->actor.world.pos.z, -680.0f, 0.5f, 10.0f, 0.001f); + } +} + +void DmChar00_Update(Actor* thisx, GlobalContext* globalCtx) { + DmChar00* this = THIS; + + SkelAnime_Update(&this->skelAnime); + + this->actionFunc(this, globalCtx); + + this->unk_262++; + func_80AA5EBC(this, globalCtx); + func_80AA62FC(this, globalCtx); +} + +s32 DmChar00_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx, Gfx** gfx) { + DmChar00* this = THIS; + f32 sp28; + Vec3f sp1C; + + if (limbIndex == 6) { + sp28 = ((Math_SinS(this->unk_262 * 0x1000) * 0.1f) + 1.0f) * 0.012f * (this->actor.scale.x * 124.99999f); + Matrix_MultiplyVector3fByState(&D_80AA7808, &sp1C); + Matrix_InsertTranslation(sp1C.x, sp1C.y, sp1C.z, MTXMODE_NEW); + Matrix_Scale(sp28, sp28, sp28, MTXMODE_APPLY); + } + return false; +} + +void DmChar00_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + DmChar00* this = THIS; + s32 phi_a0; + s32 pad; + Gfx* gfx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); + + if ((globalCtx->csCtx.state == 0) && + ((globalCtx->sceneNum != SCENE_OPENINGDAN) || (gSaveContext.sceneSetupIndex != 0) || + (globalCtx->roomCtx.currRoom.num != 0) || (globalCtx->csCtx.unk_12 != 1) || + (DMCHAR00_GET(&this->actor) != DMCHAR00_0))) { + return; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C94C(globalCtx->state.gfxCtx); + + do { + phi_a0 = (this->unk_262 * 50) & 511; + if (phi_a0 >= 256) { + phi_a0 = 511 - phi_a0; + } + } while (0); + + gSPSegment(POLY_XLU_DISP++, 0x08, &gfx[0]); + + gDPPipeSync(gfx++); + gDPSetPrimColor(gfx++, 0, 0x01, (u8)this->unk_240.unk_00, (u8)this->unk_240.unk_04, (u8)this->unk_240.unk_08, + (u8)(this->unk_240.unk_0C * 1)); + gDPSetRenderMode(gfx++, G_RM_PASS, G_RM_ZB_CLD_SURF2); + gSPEndDisplayList(gfx); + + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(s8)this->unk_250.unk_00, (u8)(s8)this->unk_250.unk_04, + (u8)(s8)this->unk_250.unk_08, (u8)(s8)((f32)phi_a0 * 1)); + gDPSetDither(POLY_XLU_DISP++, G_CD_BAYER); + + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + DmChar00_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h index 0bc9b9d0a..52adfe794 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h @@ -7,11 +7,32 @@ struct DmChar00; typedef void (*DmChar00ActionFunc)(struct DmChar00*, GlobalContext*); +#define DMCHAR00_GET(thisx) ((thisx)->params) +#define DMCHAR00_GET_F800(thisx) ((thisx)->params << 0xB) + +#define DMCHAR00_0 0 +#define DMCHAR00_1 1 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; +} DmChar00Struct; // size = 0x10 + typedef struct DmChar00 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xF8]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[7]; + /* 0x01B2 */ UNK_TYPE1 unk_1B2[0x30]; + /* 0x01E2 */ Vec3s morphTable[7]; + /* 0x020C */ UNK_TYPE1 unk_20C[0x30]; /* 0x023C */ DmChar00ActionFunc actionFunc; - /* 0x0240 */ char unk_240[0x24]; + /* 0x0240 */ DmChar00Struct unk_240; + /* 0x0250 */ DmChar00Struct unk_250; + /* 0x0260 */ u8 unk_260; + /* 0x0261 */ u8 unk_261; + /* 0x0262 */ u16 unk_262; } DmChar00; // size = 0x264 extern const ActorInit Dm_Char00_InitVars; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 0df7e2a27..d9d61ea9f 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -4433,7 +4433,7 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { gfx = sp6C->polyXlu.p; gfx = func_8012C868(gfx); - gSPSetOtherMode(gfx++, G_SETOTHERMODE_H, 4, 4, 0x00000080); + gDPSetDither(gfx++, G_CD_NOISE); gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_NEW); diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index 7dc501cfe..d9af2acd1 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -1048,7 +1048,7 @@ void EnOt_Draw(Actor* thisx, GlobalContext* globalCtx) { gfx = func_8012C7FC(POLY_XLU_DISP); - gSPSetOtherMode(&gfx[0], G_SETOTHERMODE_H, 4, 4, 0x00000080); + gDPSetDither(&gfx[0], G_CD_NOISE); gDPSetCombineLERP(&gfx[1], 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); gSPDisplayList(&gfx[2], gameplay_keep_DL_029CB0); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 6ba5842ed..ea7081a9f 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -11530,7 +11530,7 @@ 0x80AA67F8:("func_80AA67F8",), 0x80AA695C:("func_80AA695C",), 0x80AA6A04:("DmChar00_Update",), - 0x80AA6A6C:("func_80AA6A6C",), + 0x80AA6A6C:("DmChar00_OverrideLimbDraw",), 0x80AA6B34:("DmChar00_Draw",), 0x80AA81E0:("DmChar01_Init",), 0x80AA8660:("DmChar01_Destroy",), From 2b5fe949fe817557c8f1223a1bed0c4d20769b8d Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 19 Feb 2022 20:27:21 +0000 Subject: [PATCH 031/257] En_Tanron2 (#615) * En_Tanron2 * Format * PR --- spec | 4 +- src/overlays/actors/ovl_Boss_04/z_boss_04.h | 2 +- .../actors/ovl_En_Tanron2/z_en_tanron2.c | 625 +++++++++++++++++- .../actors/ovl_En_Tanron2/z_en_tanron2.h | 17 +- tools/disasm/variables.txt | 4 +- 5 files changed, 612 insertions(+), 40 deletions(-) diff --git a/spec b/spec index 313ff62d6..37afbec35 100644 --- a/spec +++ b/spec @@ -4570,9 +4570,7 @@ beginseg name "ovl_En_Tanron2" compress include "build/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.o" - include "build/data/ovl_En_Tanron2/ovl_En_Tanron2.data.o" - include "build/data/ovl_En_Tanron2/ovl_En_Tanron2.bss.o" - include "build/data/ovl_En_Tanron2/ovl_En_Tanron2.reloc.o" + include "build/src/overlays/actors/ovl_En_Tanron2/ovl_En_Tanron2_reloc.o" endseg beginseg 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 f4542cf3a..267688ab0 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.h +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.h @@ -13,7 +13,7 @@ typedef struct Boss04 { /* 0x0188 */ Vec3s jointTable[9]; /* 0x01BE */ Vec3s morphtable[9]; /* 0x01F4 */ s16 unk_1F4; - /* 0x01F6 */ s8 unk_1F6; + /* 0x01F6 */ u8 unk_1F6; /* 0x01F7 */ u8 unk_1F7; /* 0x01F8 */ s16 unk_1F8; /* 0x01FA */ s16 unk_1FA; diff --git a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c index be89681f1..e391669e5 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c @@ -5,8 +5,11 @@ */ #include "z_en_tanron2.h" +#include "overlays/actors/ovl_Boss_04/z_boss_04.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_boss04/object_boss04.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTanron2*)thisx) @@ -15,12 +18,18 @@ void EnTanron2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTanron2_Update(Actor* thisx, GlobalContext* globalCtx); void EnTanron2_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80BB69C0(EnTanron2* this); void func_80BB69FC(EnTanron2* this, GlobalContext* globalCtx); void func_80BB6BD8(EnTanron2* this, GlobalContext* globalCtx); +void func_80BB6F64(EnTanron2* this); void func_80BB6F78(EnTanron2* this, GlobalContext* globalCtx); void func_80BB7408(EnTanron2* this, GlobalContext* globalCtx); +void func_80BB7B90(Actor* thisx, GlobalContext* globalCtx); + +Boss04* D_80BB8450; +f32 D_80BB8454; +EnTanron2* D_80BB8458[82]; -#if 0 const ActorInit En_Tanron2_InitVars = { ACTOR_EN_TANRON2, ACTORCAT_BOSS, @@ -33,8 +42,7 @@ const ActorInit En_Tanron2_InitVars = { (ActorFunc)EnTanron2_Draw, }; -// static DamageTable sDamageTable = { -static DamageTable D_80BB8170 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0xF), /* Deku Stick */ DMG_ENTRY(1, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -69,54 +77,607 @@ static DamageTable D_80BB8170 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BB8190 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xFFFFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xFFFFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 30, 50, -25, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BB81BC = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xF7FFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xF7FFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 22, 42, -21, { 0, 0, 0 } }, }; -#endif +Color_RGBA8 D_80BB81E8 = { 255, 255, 255, 255 }; +Color_RGBA8 D_80BB81EC = { 255, 100, 100, 255 }; -extern DamageTable D_80BB8170; -extern ColliderCylinderInit D_80BB8190; -extern ColliderCylinderInit D_80BB81BC; +void EnTanron2_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTanron2* this = THIS; -extern UNK_TYPE D_06003450; + D_80BB8450 = (Boss04*)this->actor.parent; + this->actor.flags &= ~ACTOR_FLAG_1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/EnTanron2_Init.s") + if (this->actor.params == 100) { + this->actor.update = func_80BB7B90; + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 5); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/EnTanron2_Destroy.s") + this->actor.flags |= ACTOR_FLAG_200; + Actor_SetScale(&this->actor, 1.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB69C0.s") + this->actor.draw = NULL; + this->actor.colChkInfo.health = 1; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.targetMode = 5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB69FC.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB6B80.s") + if ((KREG(64) != 0) || (gSaveContext.eventInf[6] & 1)) { + func_80BB69C0(this); + } else { + func_80BB6F64(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB6BD8.s") + this->unk_14A = Rand_ZeroFloat(0x10000); + this->unk_14C = Rand_ZeroFloat(800.0f) + 1400.0f; + if (Rand_ZeroOne() < 0.5f) { + this->unk_14C = -this->unk_14C; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB6F64.s") + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 35.0f, 60.0f, 60.0f, 4); + this->actor.floorHeight += 20.0f; + this->unk_148 = Rand_ZeroFloat(32.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB6F78.s") +void EnTanron2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB71C8.s") +void func_80BB69C0(EnTanron2* this) { + this->actionFunc = func_80BB69FC; + this->unk_160 = 0.0f; + this->unk_15C = 0.0f; + this->collider1.dim.radius = 25; + this->collider1.dim.height = 46; + this->collider1.dim.yShift = -23; + this->unk_158 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB7398.s") +void func_80BB69FC(EnTanron2* this, GlobalContext* globalCtx) { + f32 sp34; + f32 sp30; + f32 sp2C; + Vec3f* temp_s1 = &D_80BB8450->unk_2E4[this->actor.params]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB7408.s") + if (this->unk_15C == 1.0f) { + Math_Vec3f_Copy(&this->actor.world.pos, temp_s1); + } else { + sp34 = Math_SmoothStepToF(&this->actor.world.pos.x, temp_s1->x, this->unk_15C, this->unk_160, 0.0f); + sp30 = Math_SmoothStepToF(&this->actor.world.pos.y, temp_s1->y, this->unk_15C, this->unk_160, 0.0f); + sp2C = Math_SmoothStepToF(&this->actor.world.pos.z, temp_s1->z, this->unk_15C, this->unk_160, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB7578.s") + if ((this->unk_158 == 0) && ((sp34 + sp30 + sp2C) < 2.0f)) { + this->unk_158 = 1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_EAT); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/EnTanron2_Update.s") + Math_ApproachF(&this->unk_15C, 1.0f, 1.0f, 0.02f); + Math_ApproachF(&this->unk_160, 20.0f, 1.0f, 1.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB7B90.s") + Math_ApproachF(&this->actor.scale.x, 1.0f, 0.1f, 0.2f); + Math_ApproachF(&this->actor.scale.y, 1.0f, 0.1f, 0.2f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/EnTanron2_Draw.s") +void func_80BB6B80(EnTanron2* this) { + this->actionFunc = func_80BB6BD8; + this->actor.speedXZ = 0.0f; + this->actor.velocity.z = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.velocity.x = 0.0f; + this->unk_158 = 0; + this->unk_159 = 1; + this->actor.flags |= ACTOR_FLAG_1; + this->collider1.dim.radius = 30; + this->collider1.dim.height = 50; + this->collider1.dim.yShift = -25; +} + +void func_80BB6BD8(EnTanron2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp32; + f32 sp2C; + f32 sp28; + + if (this->unk_14E == 0) { + this->actor.world.pos.x += this->actor.velocity.x; + this->actor.world.pos.y += this->actor.velocity.y; + this->actor.world.pos.z += this->actor.velocity.z; + this->actor.velocity.y = this->actor.velocity.y - 2.0f; + + if (this->actor.world.pos.y <= this->actor.floorHeight) { + this->actor.world.pos.y = this->actor.floorHeight; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_JUMP2); + + sp2C = D_80BB8450->unk_6BC.x - this->actor.world.pos.x; + sp28 = D_80BB8450->unk_6BC.z - this->actor.world.pos.z; + + switch (this->unk_158) { + case 0: + if (Rand_ZeroOne() > 0.2f) { + sp32 = Rand_ZeroFloat(65536.0f); + } else { + sp32 = Math_Atan2S(sp2C, sp28); + } + this->actor.speedXZ = Rand_ZeroFloat(5.0f) + 5.0f; + break; + + case 1: + sp32 = Math_Atan2S(sp2C, sp28); + this->actor.speedXZ += 2.0f; + if (this->actor.speedXZ > 10.0f) { + this->actor.speedXZ = 10.0f; + } + break; + + case 2: + sp32 = Math_Atan2S(player->actor.world.pos.x - this->actor.world.pos.x, + player->actor.world.pos.z - this->actor.world.pos.z) + + (s16)Rand_ZeroFloat(20000.0f); + this->actor.speedXZ = Rand_ZeroFloat(7.0f) + 7.0f; + if ((this->unk_152 == 0) && (D_80BB8450->unk_1F6 == 0)) { + this->unk_158 = 1; + } + break; + } + Matrix_RotateY(sp32, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(this->actor.speedXZ, &this->actor.velocity); + this->actor.velocity.y = Rand_ZeroFloat(5.0f) + 12.0f; + this->unk_14E = 5; + } + + if (this->unk_150 != 0) { + Math_ApproachF(&this->actor.scale.x, 0.75f, 0.5f, 1.0f); + Math_ApproachF(&this->actor.scale.y, 1.2f, 0.5f, 1.0f); + } else { + Math_ApproachF(&this->actor.scale.x, 1.0f, 0.1f, 0.2f); + Math_ApproachF(&this->actor.scale.y, 1.0f, 0.1f, 0.2f); + } + } else { + Math_ApproachF(&this->actor.scale.x, 1.2f, 0.75f, 1.5f); + Math_ApproachF(&this->actor.scale.y, 0.75f, 0.75f, 1.5f); + if (this->unk_14E == 1) { + sp2C = D_80BB8450->unk_6BC.x - this->actor.world.pos.x; + sp28 = D_80BB8450->unk_6BC.z - this->actor.world.pos.z; + + if ((this->unk_158 != 0) && ((SQ(sp2C) + SQ(sp28)) < 14400.0f)) { + func_80BB69C0(this); + } else { + this->unk_150 = 10; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_JUMP1); + } + } + } +} + +void func_80BB6F64(EnTanron2* this) { + this->actionFunc = func_80BB6F78; +} + +void func_80BB6F78(EnTanron2* this, GlobalContext* globalCtx) { + switch (this->unk_158) { + case 0: + if (D_80BB8450->unk_708 == 13) { + this->unk_158 = 10; + this->unk_14E = Rand_ZeroFloat(50.0f); + } + break; + + case 10: + if (this->unk_14E == 0) { + this->unk_150 = 10; + this->unk_158 = 1; + } + break; + + case 1: + if (this->unk_14E == 0) { + this->actor.world.pos.y += this->actor.velocity.y; + this->actor.velocity.y = this->actor.velocity.y - 2.0f; + + if (this->actor.world.pos.y <= this->actor.floorHeight) { + this->actor.world.pos.y = this->actor.floorHeight; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_JUMP2); + if (D_80BB8450->unk_6F8 > 0.1f) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER_L); + } + this->actor.velocity.y = Rand_ZeroFloat(5.0f) + 12.0f; + this->unk_14E = 5; + } + + if (this->unk_150 != 0) { + Math_ApproachF(&this->actor.scale.x, 0.75f, 0.5f, 1.0f); + Math_ApproachF(&this->actor.scale.y, 1.2f, 0.5f, 1.0f); + } else { + Math_ApproachF(&this->actor.scale.x, 1.0f, 0.1f, 0.2f); + Math_ApproachF(&this->actor.scale.y, 1.0f, 0.1f, 0.2f); + } + } else { + Math_ApproachF(&this->actor.scale.x, 1.2f, 0.75f, 1.5f); + Math_ApproachF(&this->actor.scale.y, 0.75f, 0.75f, 1.5f); + + if (this->unk_14E == 1) { + if (D_80BB8450->unk_708 == 3) { + func_80BB6B80(this); + this->unk_158 = 1; + this->unk_159 = 0; + } else { + this->unk_150 = 0xA; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_JUMP1); + } + } + } + break; + } +} + +void func_80BB71C8(EnTanron2* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spA8; + Vec3f sp9C; + Vec3f sp90; + + for (i = 0; i < 15; i++) { + Matrix_InsertYRotation_f(Rand_ZeroFloat(6.2831855f), MTXMODE_NEW); + Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(6.2831855f)); + Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(10.0f) + 5.0f, &spA8); + sp90.x = this->actor.world.pos.x + spA8.x; + sp90.y = this->actor.world.pos.y + spA8.y; + sp90.z = this->actor.world.pos.z + spA8.z; + + sp9C.x = spA8.x * -0.03f; + sp9C.y = spA8.y * -0.03f; + sp9C.z = spA8.z * -0.03f; + + EffectSsDtBubble_SpawnCustomColor(globalCtx, &sp90, &spA8, &sp9C, &D_80BB81E8, &D_80BB81EC, + Rand_ZeroFloat(100.0f) + 200.0f, Rand_ZeroFloat(5.0f) + 15.0f, 0); + } +} + +void func_80BB7398(EnTanron2* this, GlobalContext* globalCtx) { + this->actionFunc = func_80BB7408; + if ((s8)this->actor.colChkInfo.health <= 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_IKURA_DEAD); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_DAMAGE); + } +} + +void func_80BB7408(EnTanron2* this, GlobalContext* globalCtx) { + this->actor.world.pos.x += this->actor.velocity.x; + this->actor.world.pos.y += this->actor.velocity.y; + this->actor.world.pos.z += this->actor.velocity.z; + this->actor.velocity.y -= 2.0f; + + if (this->actor.world.pos.y <= this->actor.floorHeight) { + this->actor.world.pos.y = this->actor.floorHeight; + if ((s8)this->actor.colChkInfo.health <= 0) { + Actor_MarkForDeath(&this->actor); + func_80BB71C8(this, globalCtx); + D_80BB8450->unk_6F6--; + D_80BB8450->unk_2E2 += 4; + D_80BB8450->unk_2E0 += 4; + } else { + this->actor.velocity.x *= 0.5f; + this->actor.velocity.z *= 0.5f; + Math_ApproachF(&this->actor.scale.x, 1.2f, 0.75f, 1.5f); + Math_ApproachF(&this->actor.scale.y, 0.75f, 0.75f, 1.5f); + if ((this->actor.velocity.x < 0.1f) && (this->actor.velocity.z < 0.1f)) { + func_80BB6B80(this); + this->unk_158 = 1; + } + } + } +} + +void func_80BB7578(EnTanron2* this, GlobalContext* globalCtx) { + ColliderInfo* acHitInfo; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + s32 pad2; + s32 pad3; + u8 damage; + + if (this->unk_154 == 0) { + if (this->collider1.base.acFlags & AC_HIT) { + this->collider1.base.acFlags &= ~AC_HIT; + acHitInfo = this->collider1.info.acHitInfo; + if (acHitInfo->toucher.dmgFlags & 0x80) { + func_80BB6B80(this); + this->unk_158 = 1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_DAMAGE); + if ((player->unk_730 != 0) && (&this->actor != player->unk_730)) { + player->unk_730 = &this->actor; + globalCtx->actorCtx.targetContext.arrowPointedActor = &this->actor; + globalCtx->actorCtx.targetContext.targetedActor = &this->actor; + } + } else { + this->unk_154 = 15; + if (this->actionFunc != func_80BB69FC) { + Matrix_RotateY(this->actor.yawTowardsPlayer, MTXMODE_NEW); + if ((acHitInfo->toucher.dmgFlags & 0x300000) != 0) { + this->unk_154 = 10; + Matrix_GetStateTranslationAndScaledZ(-10.0f, &this->actor.velocity); + } else { + this->unk_156 = 15; + Matrix_GetStateTranslationAndScaledZ(-20.0f, &this->actor.velocity); + damage = this->actor.colChkInfo.damage; + this->actor.colChkInfo.health -= damage; + func_80BB7398(this, globalCtx); + } + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_DAMAGE); + goto block_18; + } + } + } + } + + if ((this->actionFunc == func_80BB69FC) && + ((D_80BB8450->unk_1F6 == 1) || ((D_80BB8450->unk_1F7 != 0) && (Rand_ZeroOne() < 0.1f)))) { + if (D_80BB8450->unk_1F7 != 0) { + D_80BB8450->unk_1F7--; + } + + block_18: + func_80BB6B80(this); + this->unk_158 = 2; + Matrix_RotateY(Math_Atan2S(this->actor.world.pos.x - D_80BB8450->unk_6BC.x, + this->actor.world.pos.z - D_80BB8450->unk_6BC.z), + MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(10.0f, &this->actor.velocity); + this->unk_152 = Rand_ZeroFloat(100.0f) + 200.0f; + } else if (D_80BB8450->unk_1F6 == 10) { + Actor_MarkForDeath(&this->actor); + func_80BB71C8(this, globalCtx); + } +} + +void EnTanron2_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTanron2* this = THIS; + s32 pad2[2]; + Input* input; + + this->unk_148++; + Actor_SetFocus(&this->actor, 0.0f); + + if (this->unk_14E != 0) { + this->unk_14E--; + } + + if (this->unk_150 != 0) { + this->unk_150--; + } + + if (this->unk_152 != 0) { + this->unk_152--; + } + + if (this->unk_154 != 0) { + this->unk_154--; + } + + if (this->unk_156 != 0) { + this->unk_156--; + } + + this->actionFunc(this, globalCtx); + + if (this->actionFunc != func_80BB69FC) { + if ((this->actor.world.pos.x < (D_80BB8450->unk_6D8 + 20.0f)) || + ((D_80BB8450->unk_6DC - 20.0f) < this->actor.world.pos.x)) { + this->actor.world.pos.x = this->actor.prevPos.x; + this->actor.velocity.x *= -1.0f; + } + + if ((this->actor.world.pos.z < (D_80BB8450->unk_6E0 + 20.0f)) || + ((D_80BB8450->unk_6E4 - 20.0f) < this->actor.world.pos.z)) { + this->actor.world.pos.z = this->actor.prevPos.z; + this->actor.velocity.z *= -1.0f; + } + } + + this->unk_14A += this->unk_14C; + func_80BB7578(this, globalCtx); + + if (this->unk_159 != 0) { + if (this->actor.xzDistToPlayer < 100.0f) { + if (this->unk_15A == 0) { + Collider_UpdateCylinder(&this->actor, &this->collider2); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } else { + this->unk_15A--; + } + } + + Collider_UpdateCylinder(&this->actor, &this->collider1); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + } + + if (!(this->unk_148 & 0x1F)) { + if ((this->actionFunc != func_80BB69FC) && (this->actor.xyzDistToPlayerSq < SQ(200.0f))) { + this->unk_15B = 1; + } else { + this->unk_15B = 0; + } + + if (this->actionFunc == func_80BB69FC) { + s16 atan = Math_Atan2S(this->actor.world.pos.x - D_80BB8450->unk_6BC.x, + this->actor.world.pos.z - D_80BB8450->unk_6BC.z); + + if (ABS_ALT(BINANG_SUB(D_80BB8450->actor.yawTowardsPlayer, atan)) > 0x3000) { + this->unk_159 = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + } else { + this->unk_159 = 1; + this->actor.flags |= ACTOR_FLAG_1; + } + } + } + + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000) && (this->actor.xzDistToPlayer < 80.0f)) { + this->actor.flags &= ~ACTOR_FLAG_2000; + this->unk_15A = 25; + this->unk_159 = 1; + } + + input = CONTROLLER3(globalCtx); + if (CHECK_BTN_ALL(input->press.button, BTN_L)) { + this->unk_158 = 1; + } + + if (CHECK_BTN_ALL(input->press.button, BTN_R)) { + func_80BB6B80(this); + } +} + +void func_80BB7B90(Actor* thisx, GlobalContext* globalCtx) { + EnTanron2* this = THIS; + + D_80BB8454 = (Math_SinS(globalCtx->gameplayFrames * 0x3000) * 0.1f) + 1.0f; + if (D_80BB8450->unk_1F6 == 11) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnTanron2_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + s32 i; + s32 j; + s32 found; + Actor* tanron2; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_003450); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 150); + + tanron2 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; + + for (i = 0; i < ARRAY_COUNT(D_80BB8458); i++) { + D_80BB8458[i] = NULL; + } + + found = 0; + while (tanron2 != NULL) { + if (tanron2->params < 100) { + D_80BB8458[found] = (EnTanron2*)tanron2; + found++; + } + tanron2 = tanron2->next; + } + + for (j = 0; j < found - 1; j++) { + for (i = 0; i < found - 1; i++) { + if (D_80BB8458[i + 1] != NULL) { + if (D_80BB8458[i]->actor.projectedPos.z < D_80BB8458[i + 1]->actor.projectedPos.z) { + SWAP(EnTanron2*, D_80BB8458[i], D_80BB8458[i + 1]); + } + } + } + } + + for (i = 0; i < ARRAY_COUNT(D_80BB8458); i++) { + if (D_80BB8458[i] != NULL) { + Matrix_InsertTranslation(D_80BB8458[i]->actor.world.pos.x, D_80BB8458[i]->actor.world.pos.y, + D_80BB8458[i]->actor.world.pos.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(D_80BB8458[i]->actor.scale.x, D_80BB8458[i]->actor.scale.y, 0.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(D_80BB8458[i]->unk_14A, MTXMODE_APPLY); + Matrix_Scale(0.13f, 0.14299999f, 0.13f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-D_80BB8458[i]->unk_14A, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_0034C8); + } + } + + func_8012C448(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 150); + gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004510); + + tanron2 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; + while (tanron2 != NULL) { + if ((tanron2->params < 100) && (((EnTanron2*)tanron2)->unk_15B != 0)) { + Matrix_InsertTranslation(tanron2->world.pos.x, D_80BB8450->actor.floorHeight, tanron2->world.pos.z, + MTXMODE_NEW); + Matrix_Scale(0.6f, 0.0f, 0.6f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004550); + } + tanron2 = tanron2->next; + } + + func_8012C974(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 255); + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); + + tanron2 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; + while (tanron2 != NULL) { + if ((tanron2->params < 100) && (((EnTanron2*)tanron2)->unk_15B != 0) && + (tanron2->world.pos.y <= tanron2->floorHeight)) { + Matrix_InsertTranslation(tanron2->world.pos.x, D_80BB8450->actor.floorHeight + 2.0f, tanron2->world.pos.z, + MTXMODE_NEW); + Matrix_Scale(D_80BB8454, 0.0f, D_80BB8454, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0377B0); + } + tanron2 = tanron2->next; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h index 5e9512c7c..755bb4ff4 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h @@ -10,7 +10,22 @@ typedef void (*EnTanron2ActionFunc)(struct EnTanron2*, GlobalContext*); typedef struct EnTanron2 { /* 0x0000 */ Actor actor; /* 0x0144 */ EnTanron2ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xB4]; + /* 0x0148 */ s16 unk_148; + /* 0x014A */ s16 unk_14A; + /* 0x014C */ s16 unk_14C; + /* 0x014E */ s16 unk_14E; + /* 0x0150 */ s16 unk_150; + /* 0x0152 */ s16 unk_152; + /* 0x0154 */ s16 unk_154; + /* 0x0156 */ s16 unk_156; + /* 0x0158 */ u8 unk_158; + /* 0x0159 */ u8 unk_159; + /* 0x015A */ u8 unk_15A; + /* 0x015B */ u8 unk_15B; + /* 0x015C */ f32 unk_15C; + /* 0x0160 */ f32 unk_160; + /* 0x0164 */ ColliderCylinder collider1; + /* 0x01B0 */ ColliderCylinder collider2; } EnTanron2; // size = 0x1FC extern const ActorInit En_Tanron2_InitVars; diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 2ccca1ea7..d0678cc71 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -15683,9 +15683,7 @@ 0x80BB821C:("D_80BB821C","f32","",0x4), 0x80BB8450:("D_80BB8450","UNK_TYPE4","",0x4), 0x80BB8454:("D_80BB8454","f32","",0x4), - 0x80BB8458:("D_80BB8458","UNK_TYPE4","",0x4), - 0x80BB845C:("D_80BB845C","UNK_TYPE4","",0x4), - 0x80BB8460:("D_80BB8460","UNK_TYPE4","",0x4), + 0x80BB8458:("D_80BB8458","EnTanron2*","[82]",0x148), 0x80BB9720:("D_80BB9720","UNK_TYPE4","",0x4), 0x80BB972C:("D_80BB972C","UNK_TYPE4","",0x4), 0x80BB9730:("En_Tanron3_InitVars","UNK_TYPE1","",0x1), From c91423abae279be5d7483fa881fb2e046960138c Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 19 Feb 2022 20:38:52 +0000 Subject: [PATCH 032/257] En_Baba (#592) * En_Baba * Merge * Merge * PR * PR * Apply suggestions from code review Co-authored-by: Isghj <42048411+isghj5@users.noreply.github.com> * Update src/overlays/actors/ovl_En_Baba/z_en_baba.c * format Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Co-authored-by: Isghj <42048411+isghj5@users.noreply.github.com> Co-authored-by: angie --- spec | 3 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 702 ++++++++++++++++++-- src/overlays/actors/ovl_En_Baba/z_en_baba.h | 46 +- tools/disasm/functions.txt | 6 +- undefined_syms.txt | 6 - 5 files changed, 706 insertions(+), 57 deletions(-) diff --git a/spec b/spec index 37afbec35..47dc5f772 100644 --- a/spec +++ b/spec @@ -4508,8 +4508,7 @@ beginseg name "ovl_En_Baba" compress include "build/src/overlays/actors/ovl_En_Baba/z_en_baba.o" - include "build/data/ovl_En_Baba/ovl_En_Baba.data.o" - include "build/data/ovl_En_Baba/ovl_En_Baba.reloc.o" + include "build/src/overlays/actors/ovl_En_Baba/ovl_En_Baba_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index 4593ec4b0..96864a395 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -5,8 +5,10 @@ */ #include "z_en_baba.h" +#include "overlays/actors/ovl_En_Ossan/z_en_ossan.h" +#include "objects/object_bba/object_bba.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBaba*)thisx) @@ -27,7 +29,6 @@ void func_80BA9E00(EnBaba* this, GlobalContext* globalCtx); void func_80BA9E10(EnBaba* this, GlobalContext* globalCtx); void func_80BA9E48(EnBaba* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Baba_InitVars = { ACTOR_EN_BABA, ACTORCAT_NPC, @@ -40,18 +41,38 @@ const ActorInit En_Baba_InitVars = { (ActorFunc)EnBaba_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BAA430 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static AnimationInfo sAnimations[] = { + { &object_bba_Anim_005DC4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_bba_Anim_006550, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_bba_Anim_006B10, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_bba_Anim_005154, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_bba_Anim_0058B8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_bba_Anim_004910, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 64, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BAA45C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80BAA468 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -86,67 +107,660 @@ static DamageTable D_80BAA468 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -#endif +s32 D_80BAA488[] = { + 0x0C000119, 0x0A006E14, 0x02000000, 0x1E080F00, 0x1E030400, 0x01050E00, 0x00001E02, 0x05050000, +}; -extern ColliderCylinderInit D_80BAA430; -extern CollisionCheckInfoInit2 D_80BAA45C; -extern DamageTable D_80BAA468; +s32 D_80BAA4A8[] = { -1, -1, 0 }; -extern UNK_TYPE D_06006B10; -extern UNK_TYPE D_060092A0; +u16 D_80BAA4B4[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA8820.s") +s32 func_80BA8820(EnBaba* this, GlobalContext* globalCtx) { + this->unk_144 = (EnOssan*)SubS_FindActor(globalCtx, &this->unk_144->actor, ACTORCAT_NPC, ACTOR_EN_OSSAN); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA886C.s") + if (this->unk_144 != NULL) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA8C4C.s") +void func_80BA886C(EnBaba* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA8C90.s") + switch (this->unk_1E0) { + case 0: + if (this->unk_40A & 8) { + if (gSaveContext.weekEventReg[33] & 8) { + this->unk_1E0 = 0x2A34; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA8D2C.s") + if (gSaveContext.weekEventReg[79] & 0x40) { + this->unk_40A |= 1; + this->unk_1E0 = 0x2A33; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA8DF4.s") + this->unk_40A |= 1; + this->unk_1E0 = 0x2A32; + break; + } else if (player->transformation == PLAYER_FORM_DEKU) { + if (!(gSaveContext.weekEventReg[79] & 0x20)) { + gSaveContext.weekEventReg[79] |= 0x20; + this->unk_40A |= 1; + this->unk_1E0 = 0x2A37; + break; + } else { + this->unk_40A |= 1; + this->unk_1E0 = 0x2A38; + } + break; + } else if (!(gSaveContext.weekEventReg[33] & 8)) { + if (!(gSaveContext.weekEventReg[73] & 1)) { + this->unk_1E0 = 0x660; + break; + } + this->unk_1E0 = 0x662; + break; + } else { + if (!(gSaveContext.weekEventReg[73] & 2)) { + this->unk_1E0 = 0x65A; + break; + } + this->unk_1E0 = 0x65E; + break; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA8F88.s") + case 0x660: + Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); + this->unk_1E0 = 0x661; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9110.s") + case 0x661: + Actor_ChangeFocus(&this->unk_144->actor, globalCtx, &this->actor); + this->unk_1E0 = 0x662; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9160.s") + case 0x662: + Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); + this->unk_1E0 = 0x663; + gSaveContext.weekEventReg[73] |= 1; + this->unk_40A |= 1; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA93AC.s") + case 0x65A: + Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); + this->unk_1E0 = 0x65B; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9480.s") + case 0x65B: + Actor_ChangeFocus(&this->unk_144->actor, globalCtx, &this->actor); + this->unk_1E0 = 0x65C; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9758.s") + case 0x65C: + Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); + this->unk_1E0 = 0x65D; + gSaveContext.weekEventReg[73] |= 2; + this->unk_40A |= 1; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9848.s") + case 0x65E: + Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); + this->unk_1E0 = 0x65F; + this->unk_40A |= 1; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA98EC.s") + case 0x2A34: + if (INV_CONTENT(ITEM_MASK_BLAST) == ITEM_MASK_BLAST) { + this->unk_40A |= 1; + this->unk_1E0 = 0x2A36; + break; + } + this->unk_40A |= 0x20; + this->unk_1E0 = 0x2A35; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9AB8.s") + case 0x2A35: + this->unk_40A |= 1; + this->unk_1E0 = 0x2A36; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9B24.s") + case 0x2A30: + case 0x2A31: + this->unk_40A |= 1; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9B80.s") + func_801518B0(globalCtx, this->unk_1E0, &this->actor); + if (this->unk_40A & 1) { + if (this->unk_40A & 0x40) { + this->unk_40A &= ~0x40; + func_80151BB4(globalCtx, 0x33); + } + func_80151BB4(globalCtx, 4); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9CD4.s") +void func_80BA8C4C(GlobalContext* globalCtx, u16 nextEntrance) { + globalCtx->nextEntranceIndex = nextEntrance; + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 0x40; + globalCtx->sceneLoadFlag = 0x14; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9E00.s") +void func_80BA8C90(EnBaba* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x + 5.0f; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z + 22.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9E10.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9E48.s") +s32 func_80BA8D2C(EnBaba* this, f32 arg1) { + s16 sp3E; + s32 ret = false; + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/EnBaba_Init.s") + Math_SmoothStepToF(&this->actor.speedXZ, arg1, 0.4f, 1000.0f, 0.0f); + sp3E = this->actor.speedXZ * 400.0f; + if (func_8013D68C(this->path, this->unk_1E8, &sp2C) && func_8013D768(&this->actor, &sp2C, sp3E)) { + this->unk_1E8++; + if (this->unk_1E8 >= this->path->count) { + ret = true; + } + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/EnBaba_Destroy.s") +void func_80BA8DF4(EnBaba* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/EnBaba_Update.s") + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9FB0.s") + if (func_8013D5E8(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer) && !(this->unk_40A & 4)) { + sp30.x = player->actor.world.pos.x; + sp30.y = player->bodyPartsPos[7].y + 3.0f; + sp30.z = player->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BAA198.s") + func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk_2DE, &this->unk_2E4, + &this->unk_2EA, D_80BAA4B4); + } else { + Math_SmoothStepToS(&this->unk_2DE.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2DE.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2E4.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2E4.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2EA.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2EA.y, 0, 4, 1000, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BAA20C.s") + SubS_FillLimbRotTables(globalCtx, this->unk_302, this->unk_326, ARRAY_COUNT(this->unk_302)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/EnBaba_Draw.s") + if (this->unk_40A & 2) { + func_80BA8C90(this, globalCtx); + } +} + +s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + u16 sp26 = (u16)(gSaveContext.time - 0x3FFC); + u16 temp; + u8 sp23 = ENBABA_GET_3F00(&this->actor); + + if (D_80BAA4A8[arg2->unk0] >= 0) { + this->unk_410 = func_8013BB34(globalCtx, sp23, D_80BAA4A8[arg2->unk0]); + } + + if (this->unk_410 == NULL) { + return false; + } + + if ((this->unk_434 != 0) && (this->unk_436 >= 0)) { + temp = sp26; + } else { + temp = arg2->unk4; + } + + if (arg2->unk8 < temp) { + this->unk_424 = (temp - arg2->unk8) + 0xFFFF; + } else { + this->unk_424 = arg2->unk8 - temp; + } + + this->unk_430 = sp26 - temp; + temp = this->unk_410->count - 2; + this->unk_428 = this->unk_424 / temp; + this->unk_438 = 0; + this->unk_42C = (this->unk_430 / this->unk_428) + 2; + this->unk_43C = 0; + return true; +} + +s32 func_80BA9110(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret; + + switch (arg2->unk0) { + default: + ret = false; + break; + + case 2: + ret = func_80BA8F88(this, globalCtx, arg2); + break; + + case 1: + ret = true; + break; + } + return ret; +} + +s32 func_80BA9160(EnBaba* this, GlobalContext* globalCtx) { + f32 sp7C[265]; + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + s32 sp54 = 0; + s32 sp50 = 0; + s32 pad; + + func_8013AF00(sp7C, 3, this->unk_410->count + 3); + + if (this->unk_438 == 0) { + sp58 = gZeroVec3f; + + func_8013B6B0(this->unk_410, &this->unk_420, &this->unk_430, this->unk_428, this->unk_424, &this->unk_42C, sp7C, + &sp58, this->unk_436); + func_8013B878(globalCtx, this->unk_410, this->unk_42C, &sp58); + this->actor.world.pos.y = sp58.y; + this->unk_438 = 1; + } else { + sp58 = this->unk_414; + } + + this->actor.world.pos.x = sp58.x; + this->actor.world.pos.z = sp58.z; + + if (func_8013AD6C(globalCtx)) { + sp54 = this->unk_430; + sp50 = this->unk_42C; + sp58 = this->actor.world.pos; + } + + this->unk_414 = gZeroVec3f; + + if (func_8013B6B0(this->unk_410, &this->unk_420, &this->unk_430, this->unk_428, this->unk_424, &this->unk_42C, sp7C, + &this->unk_414, this->unk_436)) { + this->unk_43C = 1; + } else { + sp70 = this->actor.world.pos; + sp64 = this->unk_414; + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); + } + + if (func_8013AD6C(globalCtx)) { + this->unk_430 = sp54; + this->unk_42C = sp50; + this->unk_414 = sp58; + } + + return false; +} + +void func_80BA93AC(EnBaba* this, GlobalContext* globalCtx) { + if (this->unk_434 != 1) { + if (this->unk_434 == 2) { + gSaveContext.weekEventReg[58] |= 0x40; + this->unk_40A |= 2; + func_80BA9160(this, globalCtx); + } + } else { + this->unk_40C = 3; + this->unk_1E0 = 10800; + this->actor.speedXZ = 0.0f; + Enemy_StartFinishingBlow(globalCtx, &this->actor); + this->unk_40A |= 4; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_40C); + this->actionFunc = func_80BA9CD4; + } + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 4, 0x1554); +} + +void func_80BA9480(EnBaba* this, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_bba_Skel_005EF0, &object_bba_Anim_006B10, this->jointTable, + this->morphTable, 0x12); + + this->actor.draw = EnBaba_Draw; + this->unk_40A |= 0x80; + this->actor.flags |= ACTOR_FLAG_1; + + if (globalCtx->sceneNum == SCENE_BOMYA) { + this->unk_40A |= 2; + this->unk_40C = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actionFunc = func_80BA9758; + } else if (globalCtx->sceneNum == SCENE_BACKTOWN) { + if ((ENBABA_GET_C000(&this->actor) == ENBABA_C000_0) && (gSaveContext.entranceIndex != 0xD670) && + ((ENBABA_GET_3F00(&this->actor)) != ENBABA_3F00_3F)) { + if ((gSaveContext.weekEventReg[58] & 0x40) || + (!(gSaveContext.time < CLOCK_TIME(0, 20)) && (gSaveContext.time < CLOCK_TIME(6, 0)))) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->unk_404 = 50; + this->unk_40C = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + this->actionFunc = func_80BA9B80; + } else if ((ENBABA_GET_C000(&this->actor) == ENBABA_C000_1) && (gSaveContext.entranceIndex == 0xD670)) { + if (gSaveContext.weekEventReg[81] & 2) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->unk_40A |= 2; + if (gSaveContext.weekEventReg[33] & 8) { + this->unk_40C = 0; + } else { + this->unk_40C = 1; + } + + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_40C); + this->unk_40A |= 8; + this->actionFunc = func_80BA9758; + } else { + Actor_MarkForDeath(&this->actor); + return; + } + } else { + this->unk_40A |= 2; + if (ENBABA_GET_C000(&this->actor) == ENBABA_C000_2) { + this->actor.flags &= ~ACTOR_FLAG_1; + this->unk_40C = 5; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + this->actionFunc = func_80BA9E00; + } else if ((ENBABA_GET_3F00(&this->actor)) != ENBABA_3F00_3F) { + this->unk_40C = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + this->actionFunc = func_80BA9E10; + } else { + this->unk_40C = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actionFunc = func_80BA9E48; + } + } +} + +void func_80BA9758(EnBaba* this, GlobalContext* globalCtx) { + if ((this->unk_40A & 8) || (this->unk_144 != NULL) || func_80BA8820(this, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80BA886C(this, globalCtx); + if (this->unk_40A & 8) { + this->actor.flags &= ~ACTOR_FLAG_10000; + } + this->actionFunc = func_80BA98EC; + } else if (this->actor.xzDistToPlayer < 100.0f) { + if (this->unk_40A & 8) { + this->actor.flags |= ACTOR_FLAG_10000; + } + func_800B8614(&this->actor, globalCtx, 100.0f); + } + } +} + +void func_80BA9848(EnBaba* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if (((temp_v0 == 5) || (temp_v0 == 6)) && func_80147624(globalCtx)) { + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_80BA9B80; + } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); +} + +void func_80BA98EC(EnBaba* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if (temp_v0 == 5) { + if (func_80147624(globalCtx)) { + if (this->unk_40A & 1) { + this->unk_40A &= ~1; + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + if (this->unk_40A & 8) { + if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { + if (globalCtx->msgCtx.unk120B1 == 0) { + gSaveContext.weekEventReg[81] |= 2; + func_80BA8C4C(globalCtx, 0xD670); + return; + } + } else { + gSaveContext.weekEventReg[81] |= 2; + func_80BA8C4C(globalCtx, 0xD670); + } + } else { + this->unk_1E0 = 0; + this->actionFunc = func_80BA9758; + } + } else if (this->unk_40A & 0x20) { + this->unk_40A &= ~0x20; + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_80BA9AB8; + } else { + func_80BA886C(this, globalCtx); + } + } + } else if (temp_v0 == 6) { + if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk120B1 == 0)) { + gSaveContext.weekEventReg[81] |= 2; + func_80BA8C4C(globalCtx, 0xD670); + } + } +} + +void func_80BA9AB8(EnBaba* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->unk_40A |= 0x40; + this->actionFunc = func_80BA9B24; + } else { + Actor_PickUp(&this->actor, globalCtx, GI_MASK_BLAST, 300.0f, 300.0f); + } +} + +void func_80BA9B24(EnBaba* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80BA886C(this, globalCtx); + this->actionFunc = func_80BA98EC; + } else { + func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + } +} + +void func_80BA9B80(EnBaba* this, GlobalContext* globalCtx) { + u32* unk14 = &gSaveContext.unk_14; + struct_80133038_arg2 sp20; + + this->unk_436 = REG(15) + *unk14; + + if (!func_80133038(globalCtx, D_80BAA488, &sp20) || + ((this->unk_434 != sp20.unk0) && !func_80BA9110(this, globalCtx, &sp20))) { + this->unk_40A &= ~0x80; + this->actor.flags &= ~ACTOR_FLAG_1; + sp20.unk0 = false; + } else { + this->unk_40A |= 0x80; + this->actor.flags |= ACTOR_FLAG_1; + } + this->unk_434 = sp20.unk0; + + func_80BA93AC(this, globalCtx); + + if (this->unk_40A & 2) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_801518B0(globalCtx, 0x2A39, &this->actor); // "I'm sorry" + this->actionFunc = func_80BA9848; + } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { + func_800B863C(&this->actor, globalCtx); + } + } + Actor_MoveWithGravity(&this->actor); +} + +void func_80BA9CD4(EnBaba* this, GlobalContext* globalCtx) { + s16 sp2E = this->skelAnime.curFrame; + s16 sp2C = Animation_GetLastFrame(sAnimations[this->unk_40C].animation); + + this->collider.dim.height = 37; + this->collider.dim.radius = 23; + + if (this->unk_40C == 3) { + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_BBVO00); + } + + if (sp2E == sp2C) { + this->unk_40C = 4; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + } + } else { + if ((gSaveContext.weekEventReg[79] & 0x40) && (DECR(this->unk_404) == 0)) { + Audio_QueueSeqCmd(0x101400FF); + func_80BA8C4C(globalCtx, 0xD670); + } else { + Actor_MoveWithGravity(&this->actor); + } + } +} + +void func_80BA9E00(EnBaba* this, GlobalContext* globalCtx) { +} + +void func_80BA9E10(EnBaba* this, GlobalContext* globalCtx) { + if (func_80BA8D2C(this, 1.0f)) { + this->unk_1E8 = 0; + } +} + +void func_80BA9E48(EnBaba* this, GlobalContext* globalCtx) { + this->actor.shape.rot = this->actor.world.rot; +} + +void EnBaba_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBaba* this = THIS; + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + this->path = func_8013D648(globalCtx, ENBABA_GET_3F00(&this->actor), ENBABA_3F00_3F); + + Actor_SetScale(&this->actor, 0.01f); + + this->actor.targetMode = 0; + this->actor.gravity = -4.0f; + this->actionFunc = func_80BA9480; +} + +void EnBaba_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBaba* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnBaba_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBaba* this = THIS; + + this->actionFunc(this, globalCtx); + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + func_80BA8DF4(this, globalCtx); +} + +s32 EnBaba_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBaba* this = THIS; + + if (limbIndex == 6) { + Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_2E4.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->unk_2E4.x, MTXMODE_APPLY); + Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if (limbIndex == 5) { + Matrix_InsertXRotation_s(-this->unk_2EA.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->unk_2EA.x, MTXMODE_APPLY); + } + + if ((limbIndex == 6) && (this->unk_1E2 != 0) && ((globalCtx->state.frames % 2) == 0)) { + Matrix_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if ((limbIndex == 5) || (limbIndex == 10) || (limbIndex == 14)) { + rot->y += (s16)(Math_SinS(this->unk_302[limbIndex]) * 200.0f); + rot->z += (s16)(Math_CosS(this->unk_326[limbIndex]) * 200.0f); + } + + if (((this->unk_40C == 1) || (this->unk_40C == 3) || (this->unk_40C == 4) || + (ENBABA_GET_C000(&this->actor) == ENBABA_C000_2)) && + (limbIndex == 8)) { + *dList = NULL; + } + return 0; +} + +void EnBaba_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnBaba* this = THIS; + Vec3f sp18 = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == 7) { + this->actor.focus.pos.x = this->actor.world.pos.x; + this->actor.focus.pos.y = this->actor.world.pos.y; + this->actor.focus.pos.z = this->actor.world.pos.z; + Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + } +} + +void EnBaba_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +} + +void EnBaba_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBaba* this = THIS; + Vec3f sp4C; + Vec3f sp40; + + if (this->unk_40A & 2) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C5B0(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(&object_bba_Tex_0092A0)); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnBaba_OverrideLimbDraw, EnBaba_PostLimbDraw, + EnBaba_TransformLimbDraw, &this->actor); + + if (this->unk_40A & 0x80) { + if ((this->unk_40C == 3) || (this->unk_40C == 4)) { + func_8012C2DC(globalCtx->state.gfxCtx); + sp4C.x = this->actor.world.pos.x + 20.0f; + sp4C.y = this->actor.world.pos.y; + sp4C.z = this->actor.world.pos.z + 20.0f; + } else { + sp4C = this->actor.world.pos; + } + + sp40.x = sp40.y = sp40.z = 0.3f; + func_800BC620(&sp4C, &sp40, 255, globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.h b/src/overlays/actors/ovl_En_Baba/z_en_baba.h index fdc0648b9..d26e68625 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.h +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.h @@ -7,11 +7,53 @@ struct EnBaba; typedef void (*EnBabaActionFunc)(struct EnBaba*, GlobalContext*); +#define ENBABA_GET_3F00(thisx) (((thisx)->params & 0x3F00) >> 8) +#define ENBABA_GET_C000(thisx) (((thisx)->params & 0xC000) >> 0xE) + +#define ENBABA_3F00_3F 0x3F + +enum { + /* 0 */ ENBABA_C000_0, + /* 1 */ ENBABA_C000_1, + /* 2 */ ENBABA_C000_2, +}; + typedef struct EnBaba { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4]; + /* 0x0144 */ struct EnOssan* unk_144; /* 0x0148 */ EnBabaActionFunc actionFunc; - /* 0x014C */ char unk_14C[0x2F4]; + /* 0x014C */ UNK_TYPE1 unk14C[4]; + /* 0x0150 */ SkelAnime skelAnime; + /* 0x0194 */ ColliderCylinder collider; + /* 0x01E0 */ u16 unk_1E0; + /* 0x01E2 */ u8 unk_1E2; + /* 0x01E4 */ Path* path; + /* 0x01E8 */ s16 unk_1E8; + /* 0x01EA */ UNK_TYPE1 unk1EA[0x1C]; + /* 0x0206 */ Vec3s jointTable[18]; + /* 0x0272 */ Vec3s morphTable[18]; + /* 0x02DE */ Vec3s unk_2DE; + /* 0x02E4 */ Vec3s unk_2E4; + /* 0x02EA */ Vec3s unk_2EA; + /* 0x02F0 */ UNK_TYPE1 unk2F0[0x12]; + /* 0x0302 */ s16 unk_302[18]; + /* 0x0326 */ s16 unk_326[18]; + /* 0x034A */ UNK_TYPE1 unk34A[0xBA]; + /* 0x0404 */ s16 unk_404; + /* 0x0406 */ UNK_TYPE1 unk406[4]; + /* 0x040A */ u16 unk_40A; + /* 0x040C */ s32 unk_40C; + /* 0x0410 */ Path* unk_410; + /* 0x0414 */ Vec3f unk_414; + /* 0x0420 */ f32 unk_420; + /* 0x0424 */ s32 unk_424; + /* 0x0428 */ s32 unk_428; + /* 0x042C */ s32 unk_42C; + /* 0x0430 */ s32 unk_430; + /* 0x0434 */ u8 unk_434; + /* 0x0436 */ s16 unk_436; + /* 0x0438 */ s32 unk_438; + /* 0x043C */ s32 unk_43C; } EnBaba; // size = 0x440 extern const ActorInit En_Baba_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index ea7081a9f..8766dec90 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -15192,9 +15192,9 @@ 0x80BA9E6C:("EnBaba_Init",), 0x80BA9F24:("EnBaba_Destroy",), 0x80BA9F50:("EnBaba_Update",), - 0x80BA9FB0:("func_80BA9FB0",), - 0x80BAA198:("func_80BAA198",), - 0x80BAA20C:("func_80BAA20C",), + 0x80BA9FB0:("EnBaba_OverrideLimbDraw",), + 0x80BAA198:("EnBaba_PostLimbDraw",), + 0x80BAA20C:("EnBaba_TransformDraw",), 0x80BAA220:("EnBaba_Draw",), 0x80BAA6D0:("EnSuttari_UpdateCollider",), 0x80BAA848:("EnSuttari_GetActorById",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 61a474f46..a3426f577 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1128,12 +1128,6 @@ D_06017990 = 0x06017990; D_0601ABF0 = 0x0601ABF0; D_0601AD00 = 0x0601AD00; -// ovl_En_Baba - -D_06005EF0 = 0x06005EF0; -D_06006B10 = 0x06006B10; -D_060092A0 = 0x060092A0; - // ovl_En_Bal D_060005FC = 0x060005FC; From e2d546c8f0a30da75f2f36afd7d721b07ae1d9c3 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 19 Feb 2022 20:45:21 +0000 Subject: [PATCH 033/257] En_Bom_Bowl_Man (#616) * En_Bom_Bowl_Man * sAnimations * Fixup data * PR --- assets/xml/overlays/ovl_En_Bom_Bowl_Man.xml | 6 + include/z64item.h | 1 + spec | 3 +- .../ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c | 656 +++++++++++++++++- .../ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h | 47 +- tools/disasm/functions.txt | 2 +- undefined_syms.txt | 5 - 7 files changed, 681 insertions(+), 39 deletions(-) create mode 100644 assets/xml/overlays/ovl_En_Bom_Bowl_Man.xml diff --git a/assets/xml/overlays/ovl_En_Bom_Bowl_Man.xml b/assets/xml/overlays/ovl_En_Bom_Bowl_Man.xml new file mode 100644 index 000000000..7e0b6d08b --- /dev/null +++ b/assets/xml/overlays/ovl_En_Bom_Bowl_Man.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/include/z64item.h b/include/z64item.h index ab0a236fa..191e5c8de 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -299,6 +299,7 @@ typedef enum { /* 0x3C */ GI_KEY_SMALL = 0x3C, /* 0x3E */ GI_MAP = 0x3E, /* 0x3F */ GI_COMPASS, + /* 0x50 */ GI_50 = 0x50, /* 0x52 */ GI_SCALE_GOLD = 0x52, // Assumed, used in En_Fishing /* 0x59 */ GI_BOTTLE_POTION_RED = 0x59, /* 0x5B */ GI_POTION_RED = 0x5B, diff --git a/spec b/spec index 47dc5f772..cdd379ee1 100644 --- a/spec +++ b/spec @@ -2435,8 +2435,7 @@ beginseg name "ovl_En_Bom_Bowl_Man" compress include "build/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.o" - include "build/data/ovl_En_Bom_Bowl_Man/ovl_En_Bom_Bowl_Man.data.o" - include "build/data/ovl_En_Bom_Bowl_Man/ovl_En_Bom_Bowl_Man.reloc.o" + include "build/src/overlays/actors/ovl_En_Bom_Bowl_Man/ovl_En_Bom_Bowl_Man_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c index 4ec8ae2b6..c0379f33c 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c @@ -5,8 +5,9 @@ */ #include "z_en_bom_bowl_man.h" +#include "objects/object_cs/object_cs.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnBomBowlMan*)thisx) @@ -15,18 +16,27 @@ void EnBomBowlMan_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBomBowlMan_Update(Actor* thisx, GlobalContext* globalCtx); void EnBomBowlMan_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_809C4BC4(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C4DA4(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C51B4(EnBomBowlMan* this, GlobalContext* globalCtx); +void func_809C52B4(EnBomBowlMan* this); void func_809C5310(EnBomBowlMan* this, GlobalContext* globalCtx); +void func_809C53A4(EnBomBowlMan* this); void func_809C5408(EnBomBowlMan* this, GlobalContext* globalCtx); +void func_809C5524(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C5598(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C5738(EnBomBowlMan* this, GlobalContext* globalCtx); +void func_809C59A4(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C59F0(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C5AA4(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C5B1C(EnBomBowlMan* this, GlobalContext* globalCtx); +void func_809C5BA0(EnBomBowlMan* this); void func_809C5BF4(EnBomBowlMan* this, GlobalContext* globalCtx); -#if 0 +s32 D_809C6100 = 0; + +s32 D_809C6104 = 0; + const ActorInit En_Bom_Bowl_Man_InitVars = { ACTOR_EN_BOM_BOWL_MAN, ACTORCAT_NPC, @@ -39,56 +49,644 @@ const ActorInit En_Bom_Bowl_Man_InitVars = { (ActorFunc)EnBomBowlMan_Draw, }; -#endif +static AnimationHeader* sAnimations[] = { + &object_cs_Anim_0064B8, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, + &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, + &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_001A1C, &object_cs_Anim_003EE4, + &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, &object_cs_Anim_001708, + &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, &object_cs_Anim_0036B0, &object_cs_Anim_0031C4, +}; -extern UNK_TYPE D_060064B8; +u8 D_809C6178[] = { + 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/EnBomBowlMan_Init.s") +u16 D_809C618C[] = { 0x710, 0x711, 0x715, 0x716, 0x717, 0x718 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/EnBomBowlMan_Destroy.s") +u16 D_809C6198[] = { 0x74F, 0x750, 0x751, 0x752 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C493C.s") +Vec3f D_809C61A0[] = { + { -730.0f, 200.0f, -2350.0f }, { -690.0f, 200.0f, -2350.0f }, { -650.0f, 200.0f, -2350.0f }, + { -610.0f, 200.0f, -2350.0f }, { -570.0f, 200.0f, -2350.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C49CC.s") +void EnBomBowlMan_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBomBowlMan* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C4B50.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + this->actor.gravity = -3.0f; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &object_cs_Anim_0064B8, this->jointTable, + this->morphTable, 21); + this->unk_2F6 = ENBOMBOWLMAN_GET_F0(&this->actor); + this->unk_2F4 = ENBOMBOWLMAN_GET_F(&this->actor); + this->actor.targetMode = 6; + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C4B6C.s") + if (this->unk_2F6 == ENBOMBOWLMAN_F0_0) { + if (this->unk_2F4 == 0) { + func_809C4BC4(this, globalCtx); + } else { + this->unk_2F4--; + func_809C5BA0(this); + } + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C4BC4.s") + this->unk_29A = ENBOMBOWLMAN_GET_FF00(&this->actor); + this->path = func_8013D648(globalCtx, this->unk_29A, 0x3F); + this->unk_2C8 = 80.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C4DA4.s") + if ((gSaveContext.entranceIndex == 0xD220) && (gSaveContext.weekEventReg[73] & 0x80) && + !CHECK_QUEST_ITEM(ITEM_BOTTLE)) { + this->unk_2D6 = this->actor.cutscene; + if (this->unk_2D6 == 0) { + Actor_MarkForDeath(&this->actor); + } + func_809C52B4(this); + } else { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C51B4.s") +void EnBomBowlMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C52B4.s") +void func_809C493C(EnBomBowlMan* this, s32 arg1, f32 arg2) { + this->unk_2F8 = arg1; + this->unk_2C4 = Animation_GetLastFrame(sAnimations[arg1]); + Animation_Change(&this->skelAnime, sAnimations[this->unk_2F8], arg2, 0.0f, this->unk_2C4, D_809C6178[this->unk_2F8], + -4.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5310.s") +void func_809C49CC(EnBomBowlMan* this) { + if ((this->unk_2F8 == 5) && + (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 10.0f) || + Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 18.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C53A4.s") + if ((this->unk_2F8 == 0xB) && + (Animation_OnFrame(&this->skelAnime, 4.0f) || Animation_OnFrame(&this->skelAnime, 8.0f) || + Animation_OnFrame(&this->skelAnime, 12.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5408.s") + if ((this->unk_2F8 == 0x12) && + (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 2.0f) || + Animation_OnFrame(&this->skelAnime, 4.0f) || Animation_OnFrame(&this->skelAnime, 6.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5524.s") + if ((this->unk_2F8 == 0xF) && Animation_OnFrame(&this->skelAnime, 15.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5598.s") + if ((this->unk_2F8 == 6) && Animation_OnFrame(&this->skelAnime, 8.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5738.s") +void func_809C4B50(EnBomBowlMan* this) { + this->unk_2B8 = 0; + this->unk_2BC = 0; + this->unk_2BA = 0; + this->unk_29E = 0; + this->unk_290 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C59A4.s") +void func_809C4B6C(EnBomBowlMan* this) { + if ((this->unk_29A != ENBOMBOWLMAN_FF00_MINUS1) && (this->path != NULL)) { + if (!func_8013D68C(this->path, this->unk_298, &this->unk_2A0)) { + Actor_MarkForDeath(&this->actor); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C59F0.s") +void func_809C4BC4(EnBomBowlMan* this, GlobalContext* globalCtx) { + s32 pad; + s32 i; + Vec3f sp7C; + EnBomBowlMan* bomBowlMan; + s8 code; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5AA4.s") + func_809C4B50(this); + func_809C493C(this, 0, 1.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5B1C.s") + for (i = 0; i < ARRAY_COUNT(gSaveContext.bomberCode); i++) { + Math_Vec3f_Copy(&sp7C, &this->actor.home.pos); + code = gSaveContext.bomberCode[i]; + if (code == 1) { + Math_Vec3f_Copy(&this->actor.world.pos, &D_809C61A0[i]); + this->unk_2D8[code] = this; + } else { + Math_Vec3f_Copy(&sp7C, &D_809C61A0[i]); + bomBowlMan = + (EnBomBowlMan*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_BOM_BOWL_MAN, + sp7C.x, sp7C.y, sp7C.z, 0, this->actor.world.rot.y, 0, code); + if (bomBowlMan != NULL) { + if (i == 2) { + this->unk_2D8[0] = bomBowlMan; + } + this->unk_2D8[code] = bomBowlMan; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5BA0.s") + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D0); + } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D0)) { + ActorCutscene_SetIntentToPlay(this->unk_2D0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5BF4.s") + func_809C493C(this, 3, 1.0f); + this->unk_2D4 = this->actor.yawTowardsPlayer; + this->unk_290 = this->actor.yawTowardsPlayer; + gSaveContext.weekEventReg[73] &= (u8)~0x10; + gSaveContext.weekEventReg[85] &= (u8)~2; + this->unk_29C = 0; + this->actionFunc = func_809C4DA4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/EnBomBowlMan_Update.s") +void func_809C4DA4(EnBomBowlMan* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->unk_290, this->unk_2D4, 1, 5000, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5F44.s") + if (this->unk_2B8 == 0) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/EnBomBowlMan_Draw.s") + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D0); + return; + } + + if (!ActorCutscene_GetCanPlayNext(this->unk_2D0)) { + ActorCutscene_SetIntentToPlay(this->unk_2D0); + return; + } + + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D0, &this->actor); + this->unk_2B8 = 1; + this->unk_2C0 = 0; + this->unk_2D4 = this->actor.yawTowardsPlayer; + this->unk_290 = this->actor.yawTowardsPlayer; + if (player->transformation == PLAYER_FORM_HUMAN) { + func_801518B0(globalCtx, D_809C618C[0], &this->actor); + } else { + func_801518B0(globalCtx, D_809C6198[0], &this->actor); + } + } + + if ((this->unk_2BC == 0) && (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + s32 sp28 = false; + + func_801477B4(globalCtx); + + switch (this->unk_2C0) { + case 0: + this->unk_2C0 = 1; + D_809C6104 = 1; + func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->unk_2D0)), + &this->unk_2D8[0]->actor); + this->unk_2D4 = 0; + this->unk_2BC = 10; + func_809C493C(this, 17, 1.0f); + break; + + case 1: + D_809C6104 = 0; + func_809C493C(this, 3, 1.0f); + this->unk_2D4 = this->actor.yawTowardsPlayer; + this->unk_2C0 = 2; + if ((player->transformation == PLAYER_FORM_HUMAN) && CHECK_QUEST_ITEM(ITEM_BOTTLE)) { + this->unk_2C0 = 4; + } + break; + + case 2: + if (player->transformation == PLAYER_FORM_HUMAN) { + this->unk_2B8 = 2; + ActorCutscene_Stop(this->unk_2D0); + func_809C59A4(this, globalCtx); + sp28 = true; + } else { + this->unk_2C0 = 3; + globalCtx->msgCtx.unk11F10 = 0; + func_809C493C(this, 1, 1.0f); + D_809C6100 = 1; + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D2); + } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D2)) { + ActorCutscene_SetIntentToPlay(this->unk_2D2); + } + ActorCutscene_Stop(this->unk_2D0); + this->actionFunc = func_809C5B1C; + sp28 = true; + } + break; + + case 3: + if (player->transformation == PLAYER_FORM_HUMAN) { + this->unk_2C0 = 4; + } else { + this->actionFunc = func_809C51B4; + return; + } + break; + + case 4: + if (this->unk_2B8 != 2) { + ActorCutscene_Stop(this->unk_2D0); + } + globalCtx->msgCtx.unk11F10 = 0; + func_809C493C(this, 1, 1.0f); + D_809C6100 = 1; + this->actionFunc = func_809C5B1C; + sp28 = true; + break; + + case 5: + func_80151BB4(globalCtx, 0x24); + func_80151BB4(globalCtx, 0x25); + func_80151BB4(globalCtx, 0); + this->actionFunc = func_809C51B4; + sp28 = true; + break; + } + + if (!sp28) { + if (player->transformation == PLAYER_FORM_HUMAN) { + func_80151938(globalCtx, D_809C618C[this->unk_2C0]); + } else { + func_80151938(globalCtx, D_809C6198[this->unk_2C0]); + } + } + } +} + +void func_809C51B4(EnBomBowlMan* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((globalCtx->msgCtx.unk120B1 == 0) && + ((globalCtx->msgCtx.msgMode == 0) || (Message_GetState(&globalCtx->msgCtx) == 6))) { + globalCtx->nextEntranceIndex = Entrance_CreateIndexFromSpawn(6); + gSaveContext.nextCutsceneIndex = 0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 0x56; + gSaveContext.nextTransition = 3; + gSaveContext.weekEventReg[75] &= (u8)~0x40; + if (player->transformation == PLAYER_FORM_HUMAN) { + gSaveContext.weekEventReg[84] |= 0x80; + gSaveContext.weekEventReg[77] &= (u8)~2; + } else { + gSaveContext.weekEventReg[73] |= 0x20; + gSaveContext.weekEventReg[85] &= (u8)~1; + } + } +} + +void func_809C52B4(EnBomBowlMan* this) { + this->actor.draw = NULL; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.world.pos.x = 1340.0f; + this->actor.world.pos.z = -1795.0f; + this->unk_29C = 3; + this->actionFunc = func_809C5310; +} + +void func_809C5310(EnBomBowlMan* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (player->actor.world.pos.x < 1510.0f) { + if (player->transformation != PLAYER_FORM_DEKU) { + if (this->actor.xzDistToPlayer < this->unk_2C8) { + func_800B7298(globalCtx, &this->actor, 7); + func_809C53A4(this); + } + } else { + Actor_MarkForDeath(&this->actor); + } + } +} + +void func_809C53A4(EnBomBowlMan* this) { + this->actor.draw = EnBomBowlMan_Draw; + this->actor.world.pos.x = 1360.0f; + this->actor.world.pos.z = -1870.0f; + func_809C493C(this, 18, 1.0f); + this->unk_29C = 3; + this->actionFunc = func_809C5408; +} + +void func_809C5408(EnBomBowlMan* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player = GET_PLAYER(globalCtx); + + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &player->actor.world.pos), 1, + 0x1388, 0); + Math_SmoothStepToS(&player->actor.shape.rot.y, Math_Vec3f_Yaw(&player->actor.world.pos, &this->actor.world.pos), 1, + 0x1388, 0); + player->actor.world.rot.y = player->actor.shape.rot.y; + Math_ApproachF(&this->actor.world.pos.x, 1350.0f, 0.3f, 2.0f); + Math_ApproachF(&this->actor.world.pos.z, -1800.0f, 0.3f, 2.0f); + if (sqrtf(SQ(this->actor.world.pos.x - 1350.0f) + SQ(this->actor.world.pos.z + 1800.0f)) < 4.0f) { + func_809C5524(this, globalCtx); + } +} + +void func_809C5524(EnBomBowlMan* this, GlobalContext* globalCtx) { + this->actor.textId = 0x730; + if (!(gSaveContext.weekEventReg[85] & 2)) { + this->actor.textId = 0x72F; + } + func_809C493C(this, 3, 1.0f); + func_801518B0(globalCtx, this->actor.textId, &this->actor); + this->actionFunc = func_809C5598; +} + +void func_809C5598(EnBomBowlMan* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + if ((this->actor.textId == 0x72F) || (this->actor.textId == 0x730)) { + this->actor.textId = 0x731; + } else if (this->actor.textId == 0x731) { + this->actor.textId = 0x732; + } else if (this->actor.textId == 0x732) { + this->actor.textId = 0x733; + } else if (this->actor.textId == 0x733) { + this->actor.textId = 0x734; + } else if (this->actor.textId == 0x734) { + this->actor.textId = 0x715; + } else if (this->actor.textId == 0x715) { + func_800B7298(globalCtx, &this->actor, 6); + func_809C493C(this, 17, 1.0f); + func_809C59A4(this, globalCtx); + return; + } else if (this->actor.textId == 0x716) { + this->actor.textId = 0x735; + } else if (this->actor.textId == 0x735) { + this->unk_2C2 = 0; + func_809C493C(this, 17, 1.0f); + func_80151BB4(globalCtx, 0x24); + func_80151BB4(globalCtx, 0x25); + func_80151BB4(globalCtx, 0); + func_800B7298(globalCtx, &this->actor, 7); + this->actionFunc = func_809C5738; + return; + } + func_80151938(globalCtx, this->actor.textId); + } +} + +void func_809C5738(EnBomBowlMan* this, GlobalContext* globalCtx) { + s32 pad[3]; + s16 yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2A0); + + if (this->unk_2C2 == 0) { + if ((globalCtx->msgCtx.unk120B1 == 0) && + ((globalCtx->msgCtx.msgMode == 0) || (Message_GetState(&globalCtx->msgCtx) == 6))) { + this->unk_2C2 = 1; + func_809C4B6C(this); + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D6); + } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D6)) { + ActorCutscene_SetIntentToPlay(this->unk_2D6); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D6, &this->actor); + this->unk_2C2 = 2; + func_809C493C(this, 18, 1.0f); + } + } + } else if (this->unk_2C2 == 1) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D6); + } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D6)) { + ActorCutscene_SetIntentToPlay(this->unk_2D6); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D6, &this->actor); + this->unk_2C2 = 2; + func_809C493C(this, 18, 1.0f); + } + } else { + Math_SmoothStepToS(&this->actor.world.rot.y, yaw, 1, 2000, 10); + Math_ApproachF(&this->actor.world.pos.x, this->unk_2A0.x, 0.5f, 6.0f); + Math_ApproachF(&this->actor.world.pos.z, this->unk_2A0.z, 0.5f, 6.0f); + if ((sqrtf(SQ(this->actor.world.pos.x - this->unk_2A0.x) + SQ(this->actor.world.pos.z - this->unk_2A0.z)) < + 4.0f) && + (this->path != NULL)) { + this->unk_298++; + if (this->unk_298 >= this->path->count) { + gSaveContext.weekEventReg[84] |= 0x80; + gSaveContext.weekEventReg[83] &= (u8)~4; + ActorCutscene_Stop(this->unk_2D6); + Actor_MarkForDeath(&this->actor); + } else { + func_809C4B6C(this); + } + } + } +} + +void func_809C59A4(EnBomBowlMan* this, GlobalContext* globalCtx) { + Actor_PickUp(&this->actor, globalCtx, GI_50, 300.0f, 300.0f); + this->unk_29C = 1; + this->actionFunc = func_809C59F0; +} + +void func_809C59F0(EnBomBowlMan* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + if (this->unk_2F6 == ENBOMBOWLMAN_F0_0) { + this->unk_2C0 = 3; + this->actor.textId = D_809C618C[this->unk_2C0]; + } else { + this->actor.textId = 0x716; + } + func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, -1); + this->actionFunc = func_809C5AA4; + } else { + Actor_PickUp(&this->actor, globalCtx, GI_50, 300.0f, 300.0f); + } +} + +void func_809C5AA4(EnBomBowlMan* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (this->unk_2F6 == ENBOMBOWLMAN_F0_0) { + this->actionFunc = func_809C4DA4; + } else { + this->actionFunc = func_809C5598; + } + } else { + func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, -1); + } +} + +void func_809C5B1C(EnBomBowlMan* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D2); + } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D2)) { + ActorCutscene_SetIntentToPlay(this->unk_2D2); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D2, &this->actor); + func_809C5BA0(this); + } +} + +void func_809C5BA0(EnBomBowlMan* this) { + if (this->unk_2F4 != 0) { + func_809C493C(this, 0, 1.0f); + } else { + this->unk_2F8 = 0; + } + this->unk_29C = 2; + this->actionFunc = func_809C5BF4; +} + +void func_809C5BF4(EnBomBowlMan* this, GlobalContext* globalCtx) { + f32 sp2C = this->skelAnime.curFrame; + s32 sp28; + + if ((D_809C6104 != 0) && (this->unk_2F8 != 15)) { + func_809C493C(this, 15, 1.0f); + } + + if ((this->unk_2F8 == 15) && (this->unk_2C4 <= sp2C)) { + func_809C493C(this, 0, 1.0f); + } + + if (D_809C6100 != 0) { + if ((this->unk_2F8 == 0) && (D_809C6100 == (this->unk_2F4 + 1))) { + func_809C493C(this, 11, 1.0f); + } + + if ((this->unk_2F8 == 11) && (this->unk_2C4 <= sp2C)) { + func_809C493C(this, 12, 1.0f); + D_809C6100++; + } + + if (this->unk_2F4 == 0) { + sp28 = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->unk_2D2)); + + if (D_809C6100 > 5) { + Player* player = GET_PLAYER(globalCtx); + + func_801477B4(globalCtx); + func_800E0308(sp28, &this->unk_2D8[0]->actor); + func_809C493C(this, 13, 1.0f); + D_809C6100 = 0; + if (player->transformation == PLAYER_FORM_HUMAN) { + this->unk_2C0 = 5; + func_801518B0(globalCtx, D_809C618C[this->unk_2C0], &this->actor); + } else { + this->unk_2C0 = 3; + func_801518B0(globalCtx, D_809C6198[this->unk_2C0], &this->actor); + } + this->unk_29C = 0; + this->actionFunc = func_809C4DA4; + } else { + s32 idx = D_809C6100 - 1; + + func_800E0308(sp28, &this->unk_2D8[1 + idx]->actor); + } + } + } +} + +void EnBomBowlMan_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBomBowlMan* this = THIS; + + if (this->unk_2BA != 0) { + this->unk_2BA--; + } + + if (this->unk_2BC != 0) { + this->unk_2BC--; + } + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y = this->actor.world.rot.y; + func_809C49CC(this); + Actor_SetFocus(&this->actor, 20.0f); + + this->actionFunc(this, globalCtx); + + Actor_MoveWithGravity(&this->actor); + Math_SmoothStepToS(&this->unk_28A, this->unk_290, 1, 0x1388, 0); + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x3E8, 0); + + if (this->unk_2F2 == 0) { + this->unk_2F0++; + if (this->unk_2F0 >= 3) { + this->unk_2F0 = 0; + this->unk_2F2 = (s32)Rand_ZeroFloat(60.0f) + 20; + } + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); +} + +s32 EnBomBowlMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBomBowlMan* this = THIS; + + if (limbIndex == 15) { + *dList = NULL; + } + + if (limbIndex == 17) { + rot->x += this->unk_28A; + } + + if ((limbIndex == 19) && (this->unk_2F6 == ENBOMBOWLMAN_F0_2)) { + *dList = NULL; + } + + if ((limbIndex == 20) && (this->unk_2F6 == ENBOMBOWLMAN_F0_0)) { + *dList = NULL; + } + return false; +} + +#include "overlays/ovl_En_Bom_Bowl_Man/ovl_En_Bom_Bowl_Man.c" + +TexturePtr D_809C6200[] = { + gEnBomBowlMan_D_809C61E0, gEnBomBowlMan_D_809C61F0, gEnBomBowlMan_D_809C61F0, + gEnBomBowlMan_D_809C61F0, gEnBomBowlMan_D_809C61F0, +}; + +TexturePtr D_809C6214[] = { + object_cs_Tex_00C520, + object_cs_Tex_00CD20, + object_cs_Tex_00D520, +}; + +TexturePtr D_809C6220[] = { + object_cs_Tex_00E620, object_cs_Tex_00EA20, object_cs_Tex_00EE20, object_cs_Tex_00DD20, object_cs_Tex_00F220, +}; + +void EnBomBowlMan_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBomBowlMan* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_809C6214[this->unk_2F0])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_809C6220[this->unk_2F4])); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(D_809C6200[this->unk_2F4])); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnBomBowlMan_OverrideLimbDraw, NULL, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h index ba90b19c9..21e25b19d 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h @@ -7,11 +7,54 @@ struct EnBomBowlMan; typedef void (*EnBomBowlManActionFunc)(struct EnBomBowlMan*, GlobalContext*); +#define ENBOMBOWLMAN_GET_F(thisx) ((thisx)->params & 0xF) +#define ENBOMBOWLMAN_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) +#define ENBOMBOWLMAN_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + +#define ENBOMBOWLMAN_F0_0 0 +#define ENBOMBOWLMAN_F0_2 2 + +#define ENBOMBOWLMAN_FF00_MINUS1 -1 + typedef struct EnBomBowlMan { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x140]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[21]; + /* 0x0206 */ Vec3s morphTable[21]; /* 0x0284 */ EnBomBowlManActionFunc actionFunc; - /* 0x0288 */ char unk_288[0x74]; + /* 0x0288 */ s16 unk_288; + /* 0x028A */ s16 unk_28A; + /* 0x028C */ UNK_TYPE1 unk28C[2]; + /* 0x028E */ s16 unk_28E; + /* 0x0290 */ s16 unk_290; + /* 0x0292 */ UNK_TYPE1 unk292[2]; + /* 0x0294 */ Path* path; + /* 0x0298 */ s16 unk_298; + /* 0x029A */ s16 unk_29A; + /* 0x029C */ s16 unk_29C; + /* 0x029E */ s16 unk_29E; + /* 0x02A0 */ Vec3f unk_2A0; + /* 0x02AC */ UNK_TYPE1 unk2AC[0xC]; + /* 0x02B8 */ s16 unk_2B8; + /* 0x02BA */ s16 unk_2BA; + /* 0x02BC */ s16 unk_2BC; + /* 0x02BE */ UNK_TYPE1 unk2BE[2]; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C2 */ s16 unk_2C2; + /* 0x02C4 */ f32 unk_2C4; + /* 0x02C8 */ f32 unk_2C8; + /* 0x02CC */ UNK_TYPE1 unk2CC[4]; + /* 0x02D0 */ s16 unk_2D0; + /* 0x02D2 */ s16 unk_2D2; + /* 0x02D4 */ s16 unk_2D4; + /* 0x02D6 */ s16 unk_2D6; + /* 0x02D8 */ struct EnBomBowlMan* unk_2D8[5]; + /* 0x02EC */ UNK_TYPE1 unk2EC[0x4]; + /* 0x02F0 */ s16 unk_2F0; + /* 0x02F2 */ s16 unk_2F2; + /* 0x02F4 */ s16 unk_2F4; + /* 0x02F6 */ s16 unk_2F6; + /* 0x02F8 */ s32 unk_2F8; } EnBomBowlMan; // size = 0x2FC extern const ActorInit En_Bom_Bowl_Man_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 8766dec90..58bfc428f 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -9078,7 +9078,7 @@ 0x809C5BA0:("func_809C5BA0",), 0x809C5BF4:("func_809C5BF4",), 0x809C5E14:("EnBomBowlMan_Update",), - 0x809C5F44:("func_809C5F44",), + 0x809C5F44:("EnBomBowlMan_OverrideLimbDraw",), 0x809C5FC4:("EnBomBowlMan_Draw",), 0x809C64C0:("func_809C64C0",), 0x809C6578:("EnSyatekiMan_Init",), diff --git a/undefined_syms.txt b/undefined_syms.txt index a3426f577..9958b0ea4 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1210,11 +1210,6 @@ D_06000530 = 0x06000530; D_060064B8 = 0x060064B8; D_0600F82C = 0x0600F82C; -// ovl_En_Bom_Bowl_Man - -D_060064B8 = 0x060064B8; -D_0600F82C = 0x0600F82C; - // ovl_En_Box D_0600043C = 0x0600043C; From 717adf8ed8019f54297c78b6a62bab2770ce0976 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 19 Feb 2022 20:49:57 +0000 Subject: [PATCH 034/257] En_Sth (#625) * En_Sth * Skull tokens * PR --- assets/xml/overlays/ovl_En_Sth.xml | 14 + spec | 3 +- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 691 ++++++++++++++++++++-- src/overlays/actors/ovl_En_Sth/z_en_sth.h | 24 +- tools/actorfixer.py | 1 + undefined_syms.txt | 5 - 6 files changed, 694 insertions(+), 44 deletions(-) create mode 100644 assets/xml/overlays/ovl_En_Sth.xml diff --git a/assets/xml/overlays/ovl_En_Sth.xml b/assets/xml/overlays/ovl_En_Sth.xml new file mode 100644 index 000000000..80393fc2d --- /dev/null +++ b/assets/xml/overlays/ovl_En_Sth.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/spec b/spec index cdd379ee1..b94e5000b 100644 --- a/spec +++ b/spec @@ -4177,8 +4177,7 @@ beginseg name "ovl_En_Sth" compress include "build/src/overlays/actors/ovl_En_Sth/z_en_sth.o" - include "build/data/ovl_En_Sth/ovl_En_Sth.data.o" - include "build/data/ovl_En_Sth/ovl_En_Sth.reloc.o" + include "build/src/overlays/actors/ovl_En_Sth/ovl_En_Sth_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index 9b6d621a0..b65b1ef40 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -5,8 +5,11 @@ */ #include "z_en_sth.h" +#include "objects/object_sth/object_sth.h" +#include "objects/object_ahg/object_ahg.h" +#include "objects/object_mask_truth/object_mask_truth.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnSth*)thisx) @@ -14,7 +17,16 @@ void EnSth_Init(Actor* thisx, GlobalContext* globalCtx); void EnSth_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSth_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B67208(EnSth* this, GlobalContext* globalCtx); +void func_80B67540(EnSth* this, GlobalContext* globalCtx); +void func_80B677BC(EnSth* this, GlobalContext* globalCtx); +void func_80B678A8(EnSth* this, GlobalContext* globalCtx); +void func_80B67958(EnSth* this, GlobalContext* globalCtx); +void func_80B67C1C(EnSth* this, GlobalContext* globalCtx); +void func_80B67DA0(EnSth* this, GlobalContext* globalCtx); +void func_80B680A8(Actor* thisx, GlobalContext* globalCtx); +void func_80B6849C(Actor* thisx, GlobalContext* globalCtx); + const ActorInit En_Sth_InitVars = { ACTOR_EN_STH, ACTORCAT_NPC, @@ -27,68 +39,675 @@ const ActorInit En_Sth_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B6D19C = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +#include "overlays/ovl_En_Sth/ovl_En_Sth.c" + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +AnimationHeader* D_80B6D1C8[] = { + &ovl_En_Sth_Anim_003F50, &ovl_En_Sth_Anim_0045B4, &ovl_En_Sth_Anim_004CC0, &ovl_En_Sth_Anim_00533C, + &ovl_En_Sth_Anim_0059B8, &ovl_En_Sth_Anim_005E40, &ovl_En_Sth_Anim_006354, &ovl_En_Sth_Anim_00645C, +}; -extern ColliderCylinderInit D_80B6D19C; +u16 D_80B6D1E8[] = { 0x1144, 0x1145, 0x1146 }; -extern UNK_TYPE D_06005998; -extern UNK_TYPE D_0A0001A0; +u16 D_80B6D1F0[] = { 0x1139, 0x113E, 0x1143 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/EnSth_Init.s") +u16 D_80B6D1F8[] = { 0x1132, 0x113A, 0x113F }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/EnSth_Destroy.s") +Vec3f D_80B6D200 = { 700.0f, 400.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B6703C.s") +Color_RGB8 D_80B6D20C[] = { + { 190, 110, 0 }, { 0, 180, 110 }, { 0, 255, 0x50 }, { 255, 160, 60 }, { 190, 230, 250 }, { 240, 230, 120 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B670A4.s") +void EnSth_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSth* this = THIS; + s32 objectId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67148.s") + if (ENSTH_GET_100(&this->actor)) { + objectId = Object_GetIndex(&globalCtx->objectCtx, OBJECT_AHG); + } else { + objectId = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STH); + } + this->unk_29E = objectId; + this->unk_29F = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MASK_TRUTH); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B671A0.s") + Actor_SetScale(&this->actor, 0.01f); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67208.s") + this->unk_29C = 0; + this->unk_29A = 8; + this->actor.terminalVelocity = -9.0f; + this->actor.gravity = -1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B672A4.s") + switch (ENSTH_GET_F(&this->actor)) { + case ENSTH_F_1: + if (globalCtx->actorCtx.unk5 & 2) { + this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); + this->actionFunc = func_80B67958; + } else { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67348.s") + case ENSTH_F_2: + if (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30) { + this->actionFunc = func_80B67DA0; + } else { + Actor_MarkForDeath(&this->actor); + } + this->actor.textId = 0; + if (!(gSaveContext.weekEventReg[34] & 0x40) || !(gSaveContext.weekEventReg[34] & 8)) { + this->unk_29C |= 1; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67458.s") + case ENSTH_F_3: + if ((gSaveContext.skullTokenCount & 0xFFFF) >= 30) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc = func_80B678A8; + this->unk_29C |= 8; + this->actor.targetMode = 3; + this->actor.uncullZoneForward = 800.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67540.s") + case ENSTH_F_4: + if (gSaveContext.weekEventReg[13] & 0x20) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.textId = 0; + this->actionFunc = func_80B677BC; + if (gSaveContext.weekEventReg[13] & 0x80) { + this->unk_29C |= 2; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B677BC.s") + case ENSTH_F_5: + if (!(gSaveContext.weekEventReg[13] & 0x20) || (Inventory_GetSkullTokenCount(globalCtx->sceneNum) < 30)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc = func_80B67208; + this->actor.textId = 0; + this->unk_29C |= 8; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67838.s") + default: + this->actionFunc = func_80B67958; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B678A8.s") +void EnSth_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSth* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67958.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67984.s") +s32 func_80B6703C(EnSth* this, GlobalContext* globalCtx) { + if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsFacingPlayer(&this->actor, 0x2000)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67AB4.s") +void func_80B670A4(EnSth* this, s16 arg1) { + if ((arg1 >= 0) && (arg1 < ARRAY_COUNT(D_80B6D1C8)) && (arg1 != this->unk_29A)) { + Animation_Change(&this->skelAnime, D_80B6D1C8[arg1], 1.0f, 0.0f, Animation_GetLastFrame(D_80B6D1C8[arg1]), 0, + -5.0f); + this->unk_29A = arg1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67B50.s") +void func_80B67148(EnSth* this, GlobalContext* globalCtx) { + s32 day = CURRENT_DAY - 1; + u16 val; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67C1C.s") + if (day < 0) { + day = 0; + } + val = D_80B6D1E8[day]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67DA0.s") + func_801518B0(globalCtx, val, &this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67E20.s") +void func_80B671A0(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/EnSth_Update.s") + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + this->actionFunc = func_80B67208; + func_801477B4(globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B680A8.s") +void func_80B67208(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B681E8.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80B67148(this, globalCtx); + this->actionFunc = func_80B671A0; + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 110.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B68310.s") +void func_80B672A4(EnSth* this, GlobalContext* globalCtx) { + u16 sp1E; + s32 day = CURRENT_DAY - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B6849C.s") + if (day < 0) { + day = 0; + } + + if (this->unk_29C & 2) { + s32 pad; + + sp1E = D_80B6D1F0[day]; + if (day == 2) { + func_80B670A4(this, 5); + } + } else { + sp1E = D_80B6D1F8[day]; + } + func_801518B0(globalCtx, sp1E, &this->actor); +} + +void func_80B67348(EnSth* this, GlobalContext* globalCtx) { + u16 phi_a1; + + SkelAnime_Update(&this->skelAnime); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + this->actionFunc = func_80B67540; + + switch (this->actor.home.rot.z) { + case 8: + case 9: + phi_a1 = 0x1137; + break; + + case 6: + phi_a1 = 0x1138; + break; + + case 5: + if (gSaveContext.weekEventReg[13] & 0x40) { + phi_a1 = 0x113D; + } else { + phi_a1 = 0x113C; + } + break; + + default: + if (gSaveContext.weekEventReg[13] & 0x40) { + phi_a1 = 0x1142; + } else { + phi_a1 = 0x1141; + } + break; + } + func_801518B0(globalCtx, phi_a1, &this->actor); + } else { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } +} + +void func_80B67458(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = func_80B67348; + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + if (CURRENT_DAY == 3) { + func_80B670A4(this, 6); + } else { + func_80B670A4(this, 3); + } + } else { + Actor_PickUp(&this->actor, globalCtx, this->actor.home.rot.z, 10000.0f, 500.0f); + } +} + +void func_80B67540(EnSth* this, GlobalContext* globalCtx) { + s32 sp2C = CURRENT_DAY - 1; + + if (sp2C < 0) { + sp2C = 0; + } + + if (this->unk_29A == 6) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + SkelAnime_Update(&this->skelAnime); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 5: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x1134: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x1132: + case 0x113A: + case 0x113F: + func_80151938(globalCtx, 0x1133); + break; + + case 0x1133: + func_80151938(globalCtx, 0x1136); + func_80B670A4(this, 6); + break; + + case 0x1136: + gSaveContext.weekEventReg[13] |= 0x80; + + switch (sp2C) { + case 0: + if (gSaveContext.weekEventReg[13] & 0x40) { + this->actor.home.rot.z = 6; + } else { + gSaveContext.weekEventReg[13] |= 0x40; + switch (CUR_UPG_VALUE(UPG_WALLET)) { + case 0: + this->actor.home.rot.z = 8; + break; + + case 1: + this->actor.home.rot.z = 9; + break; + } + } + break; + + case 1: + this->actor.home.rot.z = 5; + break; + + default: + this->actor.home.rot.z = 4; + break; + } + func_801477B4(globalCtx); + this->actionFunc = func_80B67458; + func_80B67458(this, globalCtx); + break; + + case 0x113C: + func_80151938(globalCtx, 0x113B); + break; + + case 0x1141: + func_80151938(globalCtx, 0x1140); + func_80B670A4(this, 3); + break; + + default: + this->actionFunc = func_80B677BC; + func_801477B4(globalCtx); + this->unk_29C |= 2; + break; + } + } + break; + + case 2: + this->actionFunc = func_80B677BC; + this->unk_29C |= 2; + break; + } +} + +void func_80B677BC(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80B672A4(this, globalCtx); + this->actionFunc = func_80B67540; + } else if (func_80B6703C(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 110.0f); + } +} + +void func_80B67838(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + this->actionFunc = func_80B678A8; + func_801477B4(globalCtx); + } + this->unk_294.x = -0x1388; +} + +void func_80B678A8(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80B67838; + } else if (func_80B6703C(this, globalCtx) || this->actor.isTargeted) { + if ((gSaveContext.time >= CLOCK_TIME(6, 0)) && (gSaveContext.time <= CLOCK_TIME(18, 0))) { + this->actor.textId = 0x1130; + } else { + this->actor.textId = 0x1131; + } + func_800B8614(&this->actor, globalCtx, 110.0f); + } + this->unk_294.x = -0x1388; +} + +void func_80B67958(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); +} + +void func_80B67984(EnSth* this, GlobalContext* globalCtx) { + u16 sp1E; + + if (gSaveContext.weekEventReg[34] & 0x10) { + sp1E = 0x903; + func_80B670A4(this, 2); + } else if (gSaveContext.weekEventReg[34] & 0x20) { + sp1E = 0x90F; + func_80B670A4(this, 2); + } else if (gSaveContext.weekEventReg[34] & 0x40) { + if (!(gSaveContext.weekEventReg[34] & 8)) { + sp1E = 0x91B; + } else { + sp1E = 0x918; + } + func_80B670A4(this, 2); + } else if (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30) { + if (INV_CONTENT(ITEM_MASK_TRUTH) == ITEM_MASK_TRUTH) { + this->unk_29C |= 4; + sp1E = 0x919; + } else { + sp1E = 0x916; + } + } else if (gSaveContext.weekEventReg[34] & 2) { + sp1E = 0x8FF; + } else { + sp1E = 0x8FC; + gSaveContext.weekEventReg[34] |= 2; + } + func_801518B0(globalCtx, sp1E, &this->actor); +} + +void func_80B67AB4(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80B67C1C; + gSaveContext.weekEventReg[34] |= 0x40; + func_801518B0(globalCtx, 0x918, &this->actor); + } else { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } +} + +void func_80B67B50(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = func_80B67AB4; + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } else { + this->unk_29C &= ~1; + gSaveContext.weekEventReg[34] |= 8; + Actor_PickUp(&this->actor, globalCtx, GI_MASK_CAPTAIN, 10000.0f, 50.0f); + } +} + +void func_80B67C1C(EnSth* this, GlobalContext* globalCtx) { + s32 pad; + + SkelAnime_Update(&this->skelAnime); + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x90C: + func_80B670A4(this, 2); + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x916: + case 0x919: + func_80B670A4(this, 3); + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x8FC: + case 0x8FD: + case 0x900: + case 0x90A: + case 0x90D: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x901: + case 0x90B: + case 0x917: + func_801477B4(globalCtx); + this->actionFunc = func_80B67B50; + func_80B67B50(this, globalCtx); + break; + + case 0x91A: + gSaveContext.weekEventReg[34] |= 0x40; + gSaveContext.weekEventReg[34] &= (u8)~8; + + case 0x902: + case 0x903: + case 0x90E: + case 0x90F: + case 0x918: + case 0x91B: + func_80B670A4(this, 3); + + default: + this->actor.flags &= ~ACTOR_FLAG_10000; + func_801477B4(globalCtx); + this->actionFunc = func_80B67DA0; + break; + } + } +} + +void func_80B67DA0(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80B67984(this, globalCtx); + this->actionFunc = func_80B67C1C; + } else if (func_80B6703C(this, globalCtx)) { + this->actor.textId = 0; + func_800B8614(&this->actor, globalCtx, 110.0f); + } +} + +void func_80B67E20(Actor* thisx, GlobalContext* globalCtx) { + EnSth* this = THIS; + + if (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30) { + this->actor.update = func_80B680A8; + this->actor.draw = func_80B6849C; + this->actor.flags |= ACTOR_FLAG_1; + } +} + +void EnSth_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSth* this = THIS; + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_29E)) { + this->actor.objBankIndex = this->unk_29E; + Actor_SetObjectDependency(globalCtx, &this->actor); + + if (ENSTH_GET_100(&this->actor)) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ahg_Skel_005998, &ovl_En_Sth_Anim_0045B4, + this->jointTable, this->morphTable, 16); + Animation_PlayLoop(&this->skelAnime, &ovl_En_Sth_Anim_0045B4); + this->unk_29A = 1; + if ((gSaveContext.weekEventReg[34] & 0x10) || (gSaveContext.weekEventReg[34] & 0x20) || + (gSaveContext.weekEventReg[34] & 0x40) || (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30)) { + func_80B670A4(this, 3); + } + } else { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_sth_Skel_0031F8, &ovl_En_Sth_Anim_003F50, + this->jointTable, this->morphTable, 16); + Animation_PlayLoop(&this->skelAnime, &ovl_En_Sth_Anim_003F50); + } + + this->actor.update = func_80B680A8; + this->actor.draw = func_80B6849C; + + switch (ENSTH_GET_F(&this->actor)) { + case ENSTH_F_3: + func_80B670A4(this, 4); + break; + + case ENSTH_F_4: + if (gSaveContext.weekEventReg[13] & 0x80) { + func_80B670A4(this, 5); + } else { + func_80B670A4(this, 5); + } + break; + + case ENSTH_F_5: + func_80B670A4(this, 7); + break; + } + + if ((ENSTH_GET_F(&this->actor) == ENSTH_F_4) && (Inventory_GetSkullTokenCount(globalCtx->sceneNum) < 30)) { + this->actor.update = func_80B67E20; + this->actor.draw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + } + } +} + +void func_80B680A8(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSth* this = THIS; + Vec3s sp38; + + Actor_MoveWithGravity(&this->actor); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + this->actionFunc(this, globalCtx); + + if (func_80B6703C(this, globalCtx) && !(this->unk_29C & 8) && (this->unk_29A != 5)) { + sp38.x = sp38.y = sp38.z = 0; + + func_800E9250(globalCtx, &this->actor, &this->unk_294, &sp38, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_294.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_294.y, 0, 6, 6200, 100); + } +} + +s32 func_80B681E8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + s32 pad; + EnSth* this = THIS; + + if (limbIndex == 15) { + rot->x += this->unk_294.y; + rot->z += this->unk_294.x; + *dList = ovl_En_Sth_DL_0034A0; + } + + if ((limbIndex == 8) || (limbIndex == 10) || (limbIndex == 13)) { + rot->y += (s16)(Math_SinS(globalCtx->state.frames * ((limbIndex * 50) + 0x814)) * 200.0f); + rot->z += (s16)(Math_CosS(globalCtx->state.frames * ((limbIndex * 50) + 0x940)) * 200.0f); + } + return false; +} + +void func_80B68310(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnSth* this = THIS; + + if (limbIndex == 15) { + s32 pad; + + Matrix_MultiplyVector3fByState(&D_80B6D200, &this->actor.focus.pos); + + if (!ENSTH_GET_100(&this->actor)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Sth_DL_0037C0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_29C & 1) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_29F)) { + Matrix_StatePush(); + Matrix_InsertZRotation_s(0x3A98, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 190.0f, 0.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x0A, globalCtx->objectCtx.status[this->unk_29F].segment); + gSPDisplayList(POLY_OPA_DISP++, object_mask_truth_DL_0001A0); + + Matrix_StatePop(); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} + +void func_80B6849C(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSth* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_EnvColor(globalCtx->state.gfxCtx, D_80B6D20C[1].r, D_80B6D20C[1].g, D_80B6D20C[1].b, 255)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(globalCtx->state.gfxCtx, 90, 110, 130, 255)); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80B681E8, func_80B68310, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.h b/src/overlays/actors/ovl_En_Sth/z_en_sth.h index fcd6042aa..422a92c34 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.h +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.h @@ -5,9 +5,31 @@ struct EnSth; +typedef void (*EnSthActionFunc)(struct EnSth*, GlobalContext*); + +#define ENSTH_GET_F(thisx) ((thisx)->params & 0xF) +#define ENSTH_GET_100(thisx) ((thisx)->params & 0x100) + +enum { + /* 1 */ ENSTH_F_1 = 1, + /* 2 */ ENSTH_F_2, + /* 3 */ ENSTH_F_3, + /* 4 */ ENSTH_F_4, + /* 5 */ ENSTH_F_5, +}; + typedef struct EnSth { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x160]; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ Vec3s jointTable[16]; + /* 0x234 */ Vec3s morphTable[16]; + /* 0x294 */ Vec3s unk_294; + /* 0x29A */ s16 unk_29A; + /* 0x29C */ u16 unk_29C; + /* 0x29E */ u8 unk_29E; + /* 0x29F */ u8 unk_29F; + /* 0x2A0 */ EnSthActionFunc actionFunc; } EnSth; // size = 0x2A4 extern const ActorInit En_Sth_InitVars; diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 0a3f72941..fc71f78bf 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -396,6 +396,7 @@ animdict = { "func_80114E90": "Interface_HasEmptyBottle", "func_80114F2C": "Interface_HasItemInBottle", "func_80123C90": "Player_SetEquipmentData", + "func_8012F22C": "Inventory_GetSkullTokenCount", # Structs members "skelAnime.unk03": "skelAnime.taper", diff --git a/undefined_syms.txt b/undefined_syms.txt index 9958b0ea4..89b5b10c7 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1822,11 +1822,6 @@ D_06001AA0 = 0x06001AA0; D_06000304 = 0x06000304; -// ovl_En_Sth - -D_060031F8 = 0x060031F8; -D_06005998 = 0x06005998; - // ovl_En_Sth2 D_060031F8 = 0x060031F8; From 0e6cf608d24211335469327b38467130b97d919d Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 19 Feb 2022 20:59:15 +0000 Subject: [PATCH 035/257] En_Pr (#631) --- spec | 3 +- src/overlays/actors/ovl_En_Pr/z_en_pr.c | 561 ++++++++++++++++++++-- src/overlays/actors/ovl_En_Pr/z_en_pr.h | 44 +- src/overlays/actors/ovl_En_Prz/z_en_prz.h | 4 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 5 - 6 files changed, 573 insertions(+), 48 deletions(-) diff --git a/spec b/spec index b94e5000b..bcb58fecd 100644 --- a/spec +++ b/spec @@ -2752,8 +2752,7 @@ beginseg name "ovl_En_Pr" compress include "build/src/overlays/actors/ovl_En_Pr/z_en_pr.o" - include "build/data/ovl_En_Pr/ovl_En_Pr.data.o" - include "build/data/ovl_En_Pr/ovl_En_Pr.reloc.o" + include "build/src/overlays/actors/ovl_En_Pr/ovl_En_Pr_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.c b/src/overlays/actors/ovl_En_Pr/z_en_pr.c index 696abb358..cbc26c8b7 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.c +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.c @@ -5,8 +5,10 @@ */ #include "z_en_pr.h" +#include "overlays/actors/ovl_En_Prz/z_en_prz.h" +#include "objects/object_pr/object_pr.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnPr*)thisx) @@ -15,18 +17,21 @@ void EnPr_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnPr_Update(Actor* thisx, GlobalContext* globalCtx); void EnPr_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A326F0(EnPr* this); void func_80A32740(EnPr* this, GlobalContext* globalCtx); +void func_80A32854(EnPr* this); void func_80A3289C(EnPr* this, GlobalContext* globalCtx); +void func_80A3295C(EnPr* this); void func_80A32984(EnPr* this, GlobalContext* globalCtx); void func_80A32A40(EnPr* this, GlobalContext* globalCtx); +void func_80A32AF8(EnPr* this); void func_80A32B20(EnPr* this, GlobalContext* globalCtx); +void func_80A32CDC(EnPr* this); void func_80A32D28(EnPr* this, GlobalContext* globalCtx); void func_80A32EA4(EnPr* this, GlobalContext* globalCtx); void func_80A32F48(EnPr* this, GlobalContext* globalCtx); -#if 0 -// static DamageTable sDamageTable = { -static DamageTable D_80A338A0 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -61,6 +66,8 @@ static DamageTable D_80A338A0 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; +f32 D_80A338C0[PLAYER_FORM_MAX] = { 30.0f, 30.0f, 30.0f, 15.0f, 15.0f }; + const ActorInit En_Pr_InitVars = { ACTOR_EN_PR, ACTORCAT_ENEMY, @@ -73,64 +80,546 @@ const ActorInit En_Pr_InitVars = { (ActorFunc)EnPr_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A338F4 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK4, { 0x20000000, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK4, + { 0x20000000, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 18, 20, 5, { 0, 0, 0 } }, }; -#endif +static AnimationHeader* sAnimations[] = { + &object_pr_Anim_0021E8, &object_pr_Anim_001E10, &object_pr_Anim_0021E8, + &object_pr_Anim_000740, &object_pr_Anim_000268, +}; -extern DamageTable D_80A338A0; -extern ColliderCylinderInit D_80A338F4; +u8 D_80A33934[] = { + 0, 2, 0, 0, 2, +}; -extern UNK_TYPE D_060021E8; +void EnPr_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnPr* this = THIS; + EnPrz* prz; + s32 i; + s32 temp_s4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/EnPr_Init.s") + this->actor.colChkInfo.health = 3; + this->actor.colChkInfo.mass = 50; + this->actor.hintId = 0x5C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/EnPr_Destroy.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A3242C.s") + this->unk_208 = 255; + this->unk_2CC = 0.01f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A324E0.s") + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A325E4.s") + this->actor.targetMode = 3; + this->unk_2B8 = this->actor.world.pos.y; + this->actor.shape.yOffset = 1500.0f; + this->actor.colChkInfo.damageTable = &sDamageTable; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A326F0.s") + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_pr_Skel_0038B8, &object_pr_Anim_0021E8, this->jointTable, + this->morphTable, 10); + this->unk_2C8 = this->actor.world.rot.z * 20.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32740.s") + if (this->unk_2C8 < 80.0f) { + this->unk_2C8 = 80.0f; + } + this->actor.world.rot.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32854.s") + temp_s4 = ENPR_GET_FF00(&this->actor); + if (temp_s4 > ENPR_FF00_MAX) { + temp_s4 = ENPR_FF00_MAX; + } else if (temp_s4 < ENPR_FF00_MIN) { + temp_s4 = ENPR_FF00_MIN; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A3289C.s") + this->unk_2F8 = &this->actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A3295C.s") + for (i = 0; i < temp_s4; i++) { + prz = (EnPrz*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PRZ, + this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, + this->actor.world.rot.y, 0, i + 1); + if (prz != NULL) { + prz->unk_220 = this->unk_2F8; + this->unk_2F8 = &prz->actor; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32984.s") + this->unk_2D0 = 255; + this->unk_20E = 30; + this->unk_216 = this->actor.world.rot.y; + this->unk_214 = this->actor.world.rot.y; + this->unk_2B4 = this->actor.world.pos.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32A40.s") + func_80A326F0(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32AF8.s") +void EnPr_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnPr* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32B20.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32CDC.s") +void func_80A3242C(EnPr* this, s32 arg0) { + f32 sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32D28.s") + this->unk_21C = arg0; + sp34 = 1.0f; + this->unk_2BC = Animation_GetLastFrame(sAnimations[arg0]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32E60.s") + if (this->unk_21C == 2) { + sp34 = 2.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32EA4.s") + Animation_Change(&this->skelAnime, sAnimations[this->unk_21C], sp34, 0.0f, this->unk_2BC, D_80A33934[this->unk_21C], + -2.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32F48.s") +s32 func_80A324E0(EnPr* this, GlobalContext* globalCtx) { + CollisionPoly* sp54; + Vec3f sp48; + s32 sp44; + WaterBox* sp40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A33098.s") + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &this->unk_2E0, &sp48, &sp54, 1, 0, 0, 1, + &sp44)) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/EnPr_Update.s") + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_2B4, &sp40)) { + if ((this->unk_2B4 - 30.0f) < this->actor.world.pos.y) { + this->unk_2B8 = this->unk_2B4 - 30.0f; + return 2; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A3357C.s") + if (this->actor.world.pos.y < (this->actor.floorHeight + 20.0f)) { + this->unk_2B8 = this->actor.floorHeight + 20.0f; + return 2; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A335B4.s") +s32 func_80A325E4(EnPr* this) { + s16 temp = this->unk_214 * 0.2f; + s32 abs = ABS_ALT(temp) & 0xFFFF; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/EnPr_Draw.s") + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_22C, 1, abs + 1, 0); + this->unk_216 = this->actor.world.rot.y - this->unk_22C; + + if (this->unk_216 > 10000) { + this->unk_216 = 10000; + } else if (this->unk_216 < -10000) { + this->unk_216 = -10000; + } + + if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, this->unk_22C)) > 0x100) { + return true; + } + this->unk_216 = 0; + return false; +} + +void func_80A326F0(EnPr* this) { + if (this->unk_21C != 0) { + func_80A3242C(this, 0); + } + this->unk_206 = 0; + this->actor.speedXZ = 1.0f; + this->actionFunc = func_80A32740; +} + +void func_80A32740(EnPr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (func_80A324E0(this, globalCtx)) { + case 1: + func_80A3295C(this); + return; + + case 2: + this->unk_206 = 3; + this->actionFunc = func_80A32A40; + break; + } + + if (this->unk_2C8 < sqrtf(SQ(this->actor.world.pos.x - this->actor.home.pos.x) + + SQ(this->actor.world.pos.z - this->actor.home.pos.z))) { + func_80A32854(this); + } else if ((this->unk_20E == 0) && (player->stateFlags1 & 0x8000000)) { + if (sqrtf(SQ(player->actor.world.pos.x - this->actor.home.pos.x) + + SQ(player->actor.world.pos.z - this->actor.home.pos.z)) < this->unk_2C8) { + func_80A32AF8(this); + } + } +} + +void func_80A32854(EnPr* this) { + if (this->unk_21C != 0) { + func_80A3242C(this, 0); + } + this->unk_206 = 1; + this->actionFunc = func_80A3289C; +} + +void func_80A3289C(EnPr* this, GlobalContext* globalCtx) { + this->unk_22C = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); + func_80A325E4(this); + + if (sqrtf(SQ(this->actor.world.pos.x - this->actor.home.pos.x) + + SQ(this->actor.world.pos.z - this->actor.home.pos.z)) < (((BREG(53) * 0.1f) + 0.5f) * this->unk_2C8)) { + this->unk_206 = 3; + this->actionFunc = func_80A32A40; + } +} + +void func_80A3295C(EnPr* this) { + this->unk_22C = BINANG_ADD(this->actor.world.rot.y, 0x4000); + this->unk_206 = 2; + this->actionFunc = func_80A32984; +} + +void func_80A32984(EnPr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags1 & 0x8000000) && (this->unk_20E == 0)) { + this->unk_22C = this->actor.world.rot.y; + func_80A32AF8(this); + } else if (!func_80A325E4(this)) { + if (func_80A324E0(this, globalCtx)) { + this->unk_22C += 0x1000; + } else { + if (this->unk_21C != 0) { + func_80A3242C(this, 0); + } + this->unk_206 = 3; + this->actionFunc = func_80A32A40; + } + } +} + +void func_80A32A40(EnPr* this, GlobalContext* globalCtx) { + Vec3f sp34; + WaterBox* sp30; + + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp34.y = randPlusMinusPoint5Scaled(50.0f) + this->actor.home.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_2B4, &sp30)) { + if (sp34.y < (this->unk_2B4 - 30.0f)) { + this->unk_2B8 = sp34.y; + } else { + this->unk_2B8 = this->unk_2B4 - 30.0f; + } + } + + this->unk_206 = 0; + this->actionFunc = func_80A32740; +} + +void func_80A32AF8(EnPr* this) { + this->unk_206 = 4; + this->skelAnime.playSpeed = 2.0f; + this->actionFunc = func_80A32B20; +} + +void func_80A32B20(EnPr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->actor.speedXZ = BREG(57) + 3.0f; + Math_SmoothStepToS(&this->unk_22C, this->actor.yawTowardsPlayer, BREG(49) + 1, BREG(50) + 1000, BREG(51)); + this->unk_2B8 = D_80A338C0[(void)0, gSaveContext.playerForm] + player->actor.world.pos.y; + func_80A324E0(this, globalCtx); + + if (!(player->stateFlags1 & 0x8000000)) { + this->skelAnime.playSpeed = 1.0f; + this->actor.speedXZ = 1.0f; + func_80A32854(this); + } else if (this->unk_2C8 < sqrtf(SQ(player->actor.world.pos.x - this->actor.home.pos.x) + + SQ(player->actor.world.pos.z - this->actor.home.pos.z))) { + this->skelAnime.playSpeed = 1.0f; + this->actor.speedXZ = 1.0f; + func_80A32854(this); + } else if (!func_80A325E4(this) && (this->actor.xzDistToPlayer < 200.0f) && + (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 80.0f)) { + this->skelAnime.playSpeed = 1.0f; + func_80A32CDC(this); + } +} + +void func_80A32CDC(EnPr* this) { + func_80A3242C(this, 3); + this->unk_206 = 5; + this->unk_20A = 400; + this->unk_2C0 = 0.0f; + this->actionFunc = func_80A32D28; +} + +void func_80A32D28(EnPr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (!(player->stateFlags1 & 0x8000000)) { + this->skelAnime.playSpeed = 1.0f; + this->actor.speedXZ = 1.0f; + func_80A32854(this); + } else { + Math_SmoothStepToS(&this->unk_22C, this->actor.yawTowardsPlayer, BREG(49) + 1, BREG(50) + 1000, BREG(51)); + func_80A325E4(this); + this->unk_2B8 = D_80A338C0[(void)0, gSaveContext.playerForm] + player->actor.world.pos.y; + func_80A324E0(this, globalCtx); + if (this->unk_2C8 < sqrtf(SQ(player->actor.world.pos.x - this->actor.home.pos.x) + + SQ(player->actor.world.pos.z - this->actor.home.pos.z))) { + this->skelAnime.playSpeed = 1.0f; + this->actor.speedXZ = 1.0f; + func_80A32854(this); + } + } +} + +void func_80A32E60(EnPr* this) { + func_80A3242C(this, 4); + this->unk_206 = 6; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80A32EA4; +} + +void func_80A32EA4(EnPr* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->unk_2BC <= curFrame) { + if (this->actor.colChkInfo.health <= 0) { + this->unk_206 = 7; + this->unk_20A = 50; + this->actor.flags |= ACTOR_FLAG_8000000; + this->unk_2C4 = 0.0f; + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLEWALK_DEAD); + this->unk_216 = 0; + this->actionFunc = func_80A32F48; + } else { + func_80A326F0(this); + } + } +} + +void func_80A32F48(EnPr* this, GlobalContext* globalCtx) { + WaterBox* sp2C; + + if (this->unk_208 > 0) { + this->unk_208 -= 2; + } else { + this->unk_208 = 0; + } + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_2B4, &sp2C)) { + if ((this->unk_2B4 - 100.0f) < this->actor.world.pos.y) { + this->unk_212 += 0xBB8; + this->unk_2C4 = 2.0f * Math_SinS(this->unk_212); + } + Math_ApproachF(&this->actor.world.pos.y, (this->unk_2B4 - 16.0f) + this->unk_2C4, 0.5f, 2.0f); + Math_SmoothStepToS(&this->actor.world.rot.z, 0x7700, 0x12C, 0x3E8, 0x3E8); + } + + if ((this->unk_20A == 0) && (this->unk_208 == 0)) { + this->unk_2D2 = 1; + } + + if (this->unk_2D2 != 0) { + Math_SmoothStepToS(&this->unk_2D0, 0, 1, 15, 50); + if (this->unk_2D0 < 2) { + Actor_MarkForDeath(&this->actor); + } + } +} + +void func_80A33098(EnPr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((this->unk_206 != 7) && (this->unk_206 != 6)) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + if (this->actor.colChkInfo.damageEffect == 4) { + this->unk_22E = 40; + this->unk_230 = 20; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.focus.pos.x, + this->actor.focus.pos.y, this->actor.focus.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + + if ((player->stateFlags1 & 0x8000000) && (this->actor.colChkInfo.damageEffect == 5)) { + this->unk_22E = 40; + this->unk_230 = 31; + } + + if ((this->unk_206 != 6) && (this->unk_206 != 7)) { + Actor_ApplyDamage(&this->actor); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLEWALK_DAMAGE); + func_80A32E60(this); + } + } + } +} + +void EnPr_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnPr* this = THIS; + s32 i; + + SkelAnime_Update(&this->skelAnime); + + if (this->unk_20A != 0) { + this->unk_20A--; + } + + if (this->unk_20E != 0) { + this->unk_20E--; + } + + if (this->unk_20C != 0) { + this->unk_20C--; + } + + if (this->unk_210 != 0) { + this->unk_210--; + } + + this->actionFunc(this, globalCtx); + + Actor_SetFocus(&this->actor, 20.0f); + func_80A33098(this, globalCtx); + Math_Vec3f_Copy(&this->unk_2E0, &this->actor.world.pos); + + this->unk_2E0.x += (Math_SinS(this->actor.world.rot.y) * 70.0f); + this->unk_2E0.y = this->unk_2D4.y - 10.0f; + this->unk_2E0.z += Math_CosS(this->actor.world.rot.y) * 70.0f; + + Math_SmoothStepToS(&this->unk_214, this->unk_216, 1, 0x7D0, 0); + + if (this->unk_210 == 0) { + this->unk_210 = Rand_S16Offset(10, 30); + this->unk_204 = 1; + } + + Actor_MoveWithGravity(&this->actor); + + if (this->unk_206 != 7) { + Vec3f sp50; + s16 pitch; + + Math_ApproachF(&this->actor.world.pos.y, this->unk_2B8, 0.3f, BREG(11) + 1.0f); + Math_Vec3f_Copy(&sp50, &this->actor.world.pos); + sp50.y = this->unk_2B8; + pitch = Math_Vec3f_Pitch(&this->actor.world.pos, &sp50) * 0.3f; + + if (fabsf(this->actor.world.pos.y - this->unk_2B8) > 8.0f) { + Math_SmoothStepToS(&this->actor.world.rot.x, pitch, 1, BREG(48) + 500, 0); + } else { + Math_SmoothStepToS(&this->actor.world.rot.x, 0, 1, BREG(52) + 500, 0); + } + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 30.0f, 20.0f, 0x1D); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + + if (this->unk_206 != 7) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->unk_204 != 0) { + Vec3f sp40; + + Math_Vec3f_Copy(&sp40, &this->unk_2D4); + this->unk_204 = 0; + sp40.x += randPlusMinusPoint5Scaled(20.0f); + sp40.y += randPlusMinusPoint5Scaled(5.0f); + sp40.z += randPlusMinusPoint5Scaled(20.0f); + + for (i = 0; i < (s32)Rand_ZeroFloat(5.0f) + 5; i++) { + EffectSsBubble_Spawn(globalCtx, &sp40, 0.0f, 5.0f, 5.0f, Rand_ZeroFloat(0.03f) + 0.07f); + } + } + } +} + +s32 EnPr_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnPr* this = THIS; + + if (limbIndex == 2) { + rot->y += this->unk_214; + } + return false; +} + +void EnPr_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + Vec3f sp24 = { 0.0f, 0.0f, 0.0f }; + EnPr* this = THIS; + + if (limbIndex == 2) { + Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&sp24, &this->unk_2D4); + } + + if ((limbIndex == 0) || (limbIndex == 1) || (limbIndex == 2) || (limbIndex == 3) || (limbIndex == 4) || + (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9)) { + Matrix_GetStateTranslation(&this->unk_23C[this->unk_228]); + this->unk_228++; + if (this->unk_228 >= ARRAY_COUNT(this->unk_23C)) { + this->unk_228 = 0; + } + } +} + +void EnPr_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnPr* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + if (this->unk_2D2 == 0) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->unk_208, this->unk_208, this->unk_208, this->unk_2D0); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->unk_2D0); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnPr_OverrideLimbDraw, EnPr_PostLimbDraw, &this->actor); + } else { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_2D0); + + Scene_SetRenderModeXlu(globalCtx, 1, 2); + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, NULL, &this->actor, POLY_XLU_DISP); + } + + if (this->unk_22E != 0) { + f32 temp = this->unk_22E * 0.05f; + + this->unk_238 = 0.8f; + this->unk_234 = 0.8f; + func_800BE680(globalCtx, &this->actor, this->unk_23C, 10, 0.8f, 0.8f, temp, this->unk_230); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.h b/src/overlays/actors/ovl_En_Pr/z_en_pr.h index fb2a1c8a2..6506c0d74 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.h +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.h @@ -7,11 +7,51 @@ struct EnPr; typedef void (*EnPrActionFunc)(struct EnPr*, GlobalContext*); +#define ENPR_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + +#define ENPR_FF00_MAX 20 +#define ENPR_FF00_MIN 0 + typedef struct EnPr { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xBC]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[10]; + /* 0x01C4 */ Vec3s morphTable[10]; /* 0x0200 */ EnPrActionFunc actionFunc; - /* 0x0204 */ char unk_204[0x144]; + /* 0x0204 */ u8 unk_204; + /* 0x0206 */ s16 unk_206; + /* 0x0208 */ s16 unk_208; + /* 0x020A */ s16 unk_20A; + /* 0x020C */ s16 unk_20C; + /* 0x020E */ s16 unk_20E; + /* 0x0210 */ s16 unk_210; + /* 0x0212 */ s16 unk_212; + /* 0x0214 */ s16 unk_214; + /* 0x0216 */ s16 unk_216; + /* 0x0218 */ UNK_TYPE1 unk218[4]; + /* 0x021C */ s32 unk_21C; + /* 0x0220 */ UNK_TYPE1 unk220[0x8]; + /* 0x0228 */ s32 unk_228; + /* 0x022C */ s16 unk_22C; + /* 0x022E */ s16 unk_22E; + /* 0x0230 */ s16 unk_230; + /* 0x0234 */ f32 unk_234; + /* 0x0238 */ f32 unk_238; + /* 0x023C */ Vec3f unk_23C[10]; + /* 0x02B4 */ f32 unk_2B4; + /* 0x02B8 */ f32 unk_2B8; + /* 0x02BC */ f32 unk_2BC; + /* 0x02C0 */ f32 unk_2C0; + /* 0x02C4 */ f32 unk_2C4; + /* 0x02C8 */ f32 unk_2C8; + /* 0x02CC */ f32 unk_2CC; + /* 0x02D0 */ s16 unk_2D0; + /* 0x02D2 */ s16 unk_2D2; + /* 0x02D4 */ Vec3f unk_2D4; + /* 0x02E0 */ Vec3f unk_2E0; + /* 0x02EC */ UNK_TYPE1 unk2EC[0xC]; + /* 0x02F8 */ Actor* unk_2F8; + /* 0x02FC */ ColliderCylinder collider; } EnPr; // size = 0x348 extern const ActorInit En_Pr_InitVars; diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.h b/src/overlays/actors/ovl_En_Prz/z_en_prz.h index 396ed84aa..a4e584090 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.h +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.h @@ -11,7 +11,9 @@ typedef struct EnPrz { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_144[0x80]; /* 0x01C4 */ EnPrzActionFunc actionFunc; - /* 0x01C8 */ char unk_1C8[0xA8]; + /* 0x01C8 */ char unk_1C8[0x58]; + /* 0x0220 */ Actor* unk_220; + /* 0x0224 */ char unk_224[0x4C]; } EnPrz; // size = 0x270 extern const ActorInit En_Prz_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 58bfc428f..cd1f5bf74 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10186,8 +10186,8 @@ 0x80A32F48:("func_80A32F48",), 0x80A33098:("func_80A33098",), 0x80A331C4:("EnPr_Update",), - 0x80A3357C:("func_80A3357C",), - 0x80A335B4:("func_80A335B4",), + 0x80A3357C:("EnPr_OverrideLimbDraw",), + 0x80A335B4:("EnPr_PostLimbDraw",), 0x80A336C0:("EnPr_Draw",), 0x80A33B00:("func_80A33B00",), 0x80A33BB4:("func_80A33BB4",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 89b5b10c7..a74cedb84 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1732,11 +1732,6 @@ D_06009930 = 0x06009930; D_0600A844 = 0x0600A844; D_06012768 = 0x06012768; -// ovl_En_Pr - -D_060021E8 = 0x060021E8; -D_060038B8 = 0x060038B8; - // ovl_En_Pr2 D_06003904 = 0x06003904; From 249871642fba88082ff033f500319f08d4986265 Mon Sep 17 00:00:00 2001 From: Parker Burnett Date: Sat, 19 Feb 2022 16:12:22 -0500 Subject: [PATCH 036/257] Obj_kinoko OK (#646) * z_obj_kinoko OK * fixing DL and changing to thisx * naming display list * minor fix * fixing PR suggestions * addressing PR * reverting name and leaving a comment --- assets/xml/objects/gameplay_keep.xml | 2 +- spec | 3 +- .../actors/ovl_Obj_Kinoko/z_obj_kinoko.c | 65 +++++++++++++++++-- .../actors/ovl_Obj_Kinoko/z_obj_kinoko.h | 2 + 4 files changed, 62 insertions(+), 10 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index ebbd02808..a6504f2f3 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -935,7 +935,7 @@ - + diff --git a/spec b/spec index bcb58fecd..12750b73f 100644 --- a/spec +++ b/spec @@ -4542,8 +4542,7 @@ beginseg name "ovl_Obj_Kinoko" compress include "build/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.o" - include "build/data/ovl_Obj_Kinoko/ovl_Obj_Kinoko.data.o" - include "build/data/ovl_Obj_Kinoko/ovl_Obj_Kinoko.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Kinoko/ovl_Obj_Kinoko_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c index 8d4b2f582..d580c5e8a 100644 --- a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c +++ b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c @@ -5,8 +5,9 @@ */ #include "z_obj_kinoko.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjKinoko*)thisx) @@ -15,7 +16,6 @@ void ObjKinoko_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjKinoko_Update(Actor* thisx, GlobalContext* globalCtx); void ObjKinoko_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Kinoko_InitVars = { ACTOR_OBJ_KINOKO, ACTORCAT_ITEMACTION, @@ -28,12 +28,63 @@ const ActorInit Obj_Kinoko_InitVars = { (ActorFunc)ObjKinoko_Draw, }; -#endif +void ObjKinoko_Init(Actor* thisx, GlobalContext* globalCtx) { + thisx->world.pos.y += 4.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kinoko/ObjKinoko_Init.s") +void ObjKinoko_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kinoko/ObjKinoko_Destroy.s") +void ObjKinoko_Update(Actor* thisx, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kinoko/ObjKinoko_Update.s") + if (player->currentMask != PLAYER_MASK_SCENTS) { + thisx->draw = NULL; + thisx->hintId = 0xFF; + thisx->flags &= ~ACTOR_FLAG_1; + } else { + thisx->draw = ObjKinoko_Draw; + thisx->hintId = 0x64; + thisx->flags |= ACTOR_FLAG_1; + if (Actor_HasParent(thisx, globalCtx)) { + Flags_SetCollectible(globalCtx, OBJ_KINOKO_GET_FLAG(thisx)); + Actor_MarkForDeath(thisx); + return; + } + Actor_PickUp(thisx, globalCtx, GI_MAX, 20.0f, 10.0f); + if (Math_SmoothStepToF(&thisx->speedXZ, 0.0f, 0.04f, 2.0f, 0.5f) < 0.5f) { + thisx->scale.x = 0.0f; + thisx->speedXZ = 110.0f; + thisx->velocity.x = 0.2f; + } + if (Math_SmoothStepToF(&thisx->scale.x, thisx->velocity.x, 0.04f, 0.004f, 0.001f) < + ((thisx->velocity.x == 0.0f) ? 0.0f : 0.05f)) { + thisx->velocity.x = 0.0f; + } + thisx->scale.y = thisx->scale.x; + thisx->scale.z = thisx->scale.x; + thisx->shape.rot.y = func_800DFCDC(globalCtx->cameraPtrs[globalCtx->activeCamera]) + 0x8000; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kinoko/ObjKinoko_Draw.s") +void ObjKinoko_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gfx = POLY_XLU_DISP; + gDPSetPrimColor(&gfx[0], 0, 0, 169, 63, 186, (u8)thisx->speedXZ); + gDPSetEnvColor(&gfx[1], 110, 44, 200, 100); + gDPSetRenderMode(&gfx[2], G_RM_PASS, G_RM_ZB_CLD_SURF2); + gSPMatrix(&gfx[3], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[4], &gameplay_keep_DL_029D10[2]); + Matrix_InsertXRotation_s(-0x4000, 1); + gSPMatrix(&gfx[5], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[6], &gameplay_keep_DL_029D10[2]); + POLY_XLU_DISP = &gfx[7]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.h b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.h index 9ae26adf9..9073e3e14 100644 --- a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.h +++ b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.h @@ -11,4 +11,6 @@ typedef struct ObjKinoko { extern const ActorInit Obj_Kinoko_InitVars; +#define OBJ_KINOKO_GET_FLAG(thisx) ((thisx)->params & 0x7F) + #endif // Z_OBJ_KINOKO_H From debcfa3d722194eed3793e7e1f9a6e88ac4ad0fe Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 19 Feb 2022 13:18:15 -0800 Subject: [PATCH 037/257] Bg_Numa_Hana (Wooden Flower in Woodfall Temple) OK and documented, partial documentation of object_numa_obj (#666) * Import data to C * BgNumaHana_Init OK * BgNumaHana_Destroy OK * BgNumaHana_Update OK * func_80A1A500 OK * func_80A1AE08 and func_80A1AE1C OK * func_80A1AA14 and func_80A1AA28 OK * func_80A1AA38 and func_80A1AA4C OK * A few more functions * Finish most functions * func_80A1A56C OK * BgNumaHana_Draw OK * Use generated reloc * Use object symbols * Actor flags * Minor cleanup * Some initial documentation * More documentation * Document flower petal struct * Some more struct vars * Name everything else * Finish documenting the object for the flower * Final doc pass * UNK_TYPE * Respond to review and fix build --- assets/xml/objects/object_numa_obj.xml | 34 +- spec | 3 +- .../actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c | 399 ++++++++++++++++-- .../actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.h | 34 +- tools/disasm/functions.txt | 30 +- undefined_syms.txt | 9 - 6 files changed, 426 insertions(+), 83 deletions(-) diff --git a/assets/xml/objects/object_numa_obj.xml b/assets/xml/objects/object_numa_obj.xml index cc36fa1b8..e8035b3e8 100644 --- a/assets/xml/objects/object_numa_obj.xml +++ b/assets/xml/objects/object_numa_obj.xml @@ -1,4 +1,5 @@  + @@ -17,21 +18,24 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index 12750b73f..17a9ecc8d 100644 --- a/spec +++ b/spec @@ -2629,8 +2629,7 @@ beginseg name "ovl_Bg_Numa_Hana" compress include "build/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.o" - include "build/data/ovl_Bg_Numa_Hana/ovl_Bg_Numa_Hana.data.o" - include "build/data/ovl_Bg_Numa_Hana/ovl_Bg_Numa_Hana.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Numa_Hana/ovl_Bg_Numa_Hana_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c index 62ae7ab8a..bf556345f 100644 --- a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c +++ b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c @@ -5,8 +5,10 @@ */ #include "z_bg_numa_hana.h" +#include "objects/object_numa_obj/object_numa_obj.h" +#include "objects/object_syokudai/object_syokudai.h" -#define FLAGS 0x00000410 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((BgNumaHana*)thisx) @@ -15,14 +17,19 @@ void BgNumaHana_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgNumaHana_Update(Actor* thisx, GlobalContext* globalCtx); void BgNumaHana_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A1AA28(BgNumaHana* this, GlobalContext* globalCtx); -void func_80A1AA4C(BgNumaHana* this, GlobalContext* globalCtx); -void func_80A1AB00(BgNumaHana* this, GlobalContext* globalCtx); -void func_80A1ABF0(BgNumaHana* this, GlobalContext* globalCtx); -void func_80A1ACE0(BgNumaHana* this, GlobalContext* globalCtx); -void func_80A1AE1C(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_SetupDoNothing(BgNumaHana* this); +void BgNumaHana_DoNothing(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_SetupClosedIdle(BgNumaHana* this); +void BgNumaHana_ClosedIdle(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_SetupUnfoldInnerPetals(BgNumaHana* this); +void BgNumaHana_UnfoldInnerPetals(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_SetupUnfoldOuterPetals(BgNumaHana* this); +void BgNumaHana_UnfoldOuterPetals(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_SetupRaiseFlower(BgNumaHana* this); +void BgNumaHana_RaiseFlower(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_SetupOpenedIdle(BgNumaHana* this); +void BgNumaHana_OpenedIdle(BgNumaHana* this, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Numa_Hana_InitVars = { ACTOR_BG_NUMA_HANA, ACTORCAT_BG, @@ -35,63 +42,379 @@ const ActorInit Bg_Numa_Hana_InitVars = { (ActorFunc)BgNumaHana_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A1B260 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x00000000, 0x00, 0x00 }, { 0x01CBFBB6, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0x01CBFBB6, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 18, 16, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A1B2A8[] = { +static FireObjInitParams sFireObjInit = { + 0.00405000010505f, 0.0500000007451f, 3, 1, 0, 0, 0, +}; + +static s16 sInitialAnglePerPetal[] = { 0x0000, 0x2AAA, 0x5555, 0x8000, 0xAAAA, 0xD555 }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 800, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 600, ICHAIN_STOP), }; -#endif +/** + * Spawns another wooden flower instance that handles the opened flower's collision. + * Returns true if this wooden flower instance was succesfully spawned. + */ +s32 BgNumaHana_SpawnOpenFlowerCollisionChild(BgNumaHana* this, GlobalContext* globalCtx) { + Actor* child; -extern ColliderCylinderInit D_80A1B260; -extern InitChainEntry D_80A1B2A8[]; + child = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_BG_NUMA_HANA, + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, + BG_NUMA_HANA_TYPE_OPEN_FLOWER_COLLISION); -extern UNK_TYPE D_06009FE0; -extern UNK_TYPE D_0600B928; + return child != NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1A500.s") +void BgNumaHana_UpdatePetalPosRots(BgNumaHana* this) { + f32 outerPetalPosScale; + f32 innerPetalYPos; + f32 outerPetalYPos; + s16 angle; + WoodenFlowerPetalPosRot* innerPetalPosRot; + WoodenFlowerPetalPosRot* outerPetalPosRot; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1A56C.s") + innerPetalYPos = this->dyna.actor.world.pos.y + -10.0f; + angle = this->petalZRotation - 0x2000; + outerPetalPosScale = (Math_CosS(angle) * 77.42784f) + 74.95192f; + outerPetalYPos = (Math_SinS(this->petalZRotation) * 77.42784f) + this->dyna.actor.world.pos.y + -64.74976f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1A750.s") + for (i = 0; i < ARRAY_COUNT(this->innerPetalPosRot); i++) { + innerPetalPosRot = &this->innerPetalPosRot[i]; + outerPetalPosRot = &this->outerPetalPosRot[i]; + angle = sInitialAnglePerPetal[i] + this->dyna.actor.shape.rot.y + 0x1555; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/BgNumaHana_Init.s") + innerPetalPosRot->pos.x = (Math_SinS(angle) * 74.95192f) + this->dyna.actor.world.pos.x; + innerPetalPosRot->pos.y = innerPetalYPos; + innerPetalPosRot->pos.z = (Math_CosS(angle) * 74.95192f) + this->dyna.actor.world.pos.z; + innerPetalPosRot->rot.x = this->dyna.actor.shape.rot.x; + innerPetalPosRot->rot.y = angle - 0x4000; + innerPetalPosRot->rot.z = this->dyna.actor.shape.rot.z + this->petalZRotation; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/BgNumaHana_Destroy.s") + outerPetalPosRot->pos.x = (Math_SinS(angle) * outerPetalPosScale) + this->dyna.actor.world.pos.x; + outerPetalPosRot->pos.y = outerPetalYPos; + outerPetalPosRot->pos.z = (Math_CosS(angle) * outerPetalPosScale) + this->dyna.actor.world.pos.z; + outerPetalPosRot->rot.x = innerPetalPosRot->rot.x; + outerPetalPosRot->rot.y = innerPetalPosRot->rot.y; + outerPetalPosRot->rot.z = innerPetalPosRot->rot.z + this->outerPetalZRotation; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AA14.s") +/** + * As the pieces of the petals finish unfolding, they shake to appear + * as if they are "settling" into place. This function is responsible + * for computing the extra rotation for this "settling". + */ +void BgNumaHana_UpdateSettleRotation(s16* settleZRotation, s16* settleAngle, f32* settleScale, f32 scaleStep) { + *settleAngle += 0x32C8; + Math_StepToF(settleScale, 0.0f, scaleStep); + *settleZRotation += (s16)(Math_SinS(*settleAngle) * *settleScale); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AA28.s") +void BgNumaHana_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DynaPolyActor* child; + s32 type; + BgNumaHana* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AA38.s") + type = BG_NUMA_HANA_GET_TYPE(&this->dyna.actor); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 3); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AA4C.s") + if (type == BG_NUMA_HANA_TYPE_OPEN_FLOWER_COLLISION) { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gWoodenFlowerOpenedFlowerCol); + BgNumaHana_SetupDoNothing(this); + this->dyna.actor.draw = NULL; + } else { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gWoodenFlowerClosedFlowerCol); + FireObj_Init(globalCtx, &this->fire, &sFireObjInit, &this->dyna.actor); + Collider_InitCylinder(globalCtx, &this->torchCollider); + Collider_SetCylinder(globalCtx, &this->torchCollider, &this->dyna.actor, &sCylinderInit); + this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + if (!BgNumaHana_SpawnOpenFlowerCollisionChild(this, globalCtx)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AAE8.s") + if (gSaveContext.weekEventReg[12] & 1) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AB00.s") + this->petalZRotation = 0x2000; + this->innerPetalZRotation = 0x2000; + this->innerPetalZRotationalVelocity = 0; + this->settleZRotation = 0; + this->settleAngle = 0; + this->settleScale = 0.0f; + this->outerPetalZRotation = -0x4000; + this->outerPetalZRotationalVelocity = 0; + this->flowerRotationalVelocity = 0x147; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1ABD8.s") + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 210.0f; + FireObj_SetState2(&this->fire, 0.05f, 2); + Flags_SetSwitch(globalCtx, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor)); + BgNumaHana_SetupOpenedIdle(this); + } else { + child = (DynaPolyActor*)this->dyna.actor.child; + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, child->bgId); + Flags_UnsetSwitch(globalCtx, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor)); + BgNumaHana_SetupClosedIdle(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1ABF0.s") + BgNumaHana_UpdatePetalPosRots(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1ACCC.s") +void BgNumaHana_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgNumaHana* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1ACE0.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if (BG_NUMA_HANA_GET_TYPE(&this->dyna.actor) == BG_NUMA_HANA_TYPE_NORMAL) { + FireObj_Destroy(globalCtx, &this->fire); + Collider_DestroyCylinder(globalCtx, &this->torchCollider); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AE08.s") +void BgNumaHana_SetupDoNothing(BgNumaHana* this) { + this->actionFunc = BgNumaHana_DoNothing; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AE1C.s") +void BgNumaHana_DoNothing(BgNumaHana* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/BgNumaHana_Update.s") +void BgNumaHana_SetupClosedIdle(BgNumaHana* this) { + this->actionFunc = BgNumaHana_ClosedIdle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/BgNumaHana_Draw.s") +/** + * This function waits for the torch to be lit. Once it is, it starts + * the cutscene where the petals unfold. + */ +void BgNumaHana_ClosedIdle(BgNumaHana* this, GlobalContext* globalCtx) { + if (this->fire.state != 3) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FLAME_IGNITION); + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + gSaveContext.weekEventReg[12] |= 1; + Flags_SetSwitch(globalCtx, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor)); + BgNumaHana_SetupUnfoldInnerPetals(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } + } +} + +void BgNumaHana_SetupUnfoldInnerPetals(BgNumaHana* this) { + this->actionFunc = BgNumaHana_UnfoldInnerPetals; + this->transitionTimer = 0; +} + +/** + * Partially moves the flower to the "open" position by raising the "inner" + * parts of the petals that are closest to the stalk. + */ +void BgNumaHana_UnfoldInnerPetals(BgNumaHana* this, GlobalContext* globalCtx) { + Math_StepToS(&this->innerPetalZRotationalVelocity, 240, 14); + if (Math_ScaledStepToS(&this->innerPetalZRotation, 0x2000, this->innerPetalZRotationalVelocity)) { + if (this->transitionTimer >= 11) { + BgNumaHana_SetupUnfoldOuterPetals(this); + } else { + if (this->transitionTimer <= 0) { + this->settleZRotation = 0; + this->settleAngle = 0; + this->settleScale = 420.0f; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_STOP); + } + this->transitionTimer++; + } + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_MOVE - SFX_FLAG); + } + + BgNumaHana_UpdateSettleRotation(&this->settleZRotation, &this->settleAngle, &this->settleScale, 20.0f); + this->petalZRotation = this->innerPetalZRotation + this->settleZRotation; + BgNumaHana_UpdatePetalPosRots(this); +} + +void BgNumaHana_SetupUnfoldOuterPetals(BgNumaHana* this) { + this->actionFunc = BgNumaHana_UnfoldOuterPetals; + this->transitionTimer = 0; +} + +/** + * Partially moves the flower to the "open" position by lowering the "outer" + * parts of the petals that are furthest to the stalk. + */ +void BgNumaHana_UnfoldOuterPetals(BgNumaHana* this, GlobalContext* globalCtx) { + Math_StepToS(&this->outerPetalZRotationalVelocity, 240, 14); + if (Math_ScaledStepToS(&this->outerPetalZRotation, -0x4000, this->outerPetalZRotationalVelocity)) { + if (this->transitionTimer >= 11) { + BgNumaHana_SetupRaiseFlower(this); + } else { + if (this->transitionTimer <= 0) { + this->settleZRotation = 0; + this->settleAngle = 0x5120; + this->settleScale = 130.0f; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_STOP); + } + this->transitionTimer++; + } + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_MOVE - SFX_FLAG); + } + + BgNumaHana_UpdateSettleRotation(&this->settleZRotation, &this->settleAngle, &this->settleScale, 7.0f); + this->petalZRotation = this->innerPetalZRotation + this->settleZRotation; + BgNumaHana_UpdatePetalPosRots(this); +} + +void BgNumaHana_SetupRaiseFlower(BgNumaHana* this) { + this->actionFunc = BgNumaHana_RaiseFlower; +} + +/** + * This function slowly raises the flower to its final height and makes it start spinning. + */ +void BgNumaHana_RaiseFlower(BgNumaHana* this, GlobalContext* globalCtx) { + s32 pad; + DynaPolyActor* child; + + BgNumaHana_UpdateSettleRotation(&this->settleZRotation, &this->settleAngle, &this->settleScale, 10.0f); + this->petalZRotation = this->innerPetalZRotation + this->settleZRotation; + Math_StepToS(&this->flowerRotationalVelocity, 0x111, 0xA); + this->dyna.actor.shape.rot.y += this->flowerRotationalVelocity; + Math_StepToF(&this->dyna.actor.velocity.y, 3.0f, 0.3f); + + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 210.0f, + this->dyna.actor.velocity.y)) { + child = (DynaPolyActor*)this->dyna.actor.child; + + // Swaps out the "closed" flower collision for the "opened" collision. + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, child->bgId); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + + this->petalZRotation = 0x2000; + this->innerPetalZRotation = 0x2000; + this->innerPetalZRotationalVelocity = 0; + this->settleZRotation = 0; + this->settleAngle = 0; + this->outerPetalZRotation = -0x4000; + this->outerPetalZRotationalVelocity = 0; + this->flowerRotationalVelocity = 0x147; + this->settleScale = 0.0f; + + ActorCutscene_Stop(this->dyna.actor.cutscene); + BgNumaHana_SetupOpenedIdle(this); + } + + BgNumaHana_UpdatePetalPosRots(this); + func_800B9010(&this->dyna.actor, NA_SE_EV_FLOWER_ROLLING - SFX_FLAG); +} + +void BgNumaHana_SetupOpenedIdle(BgNumaHana* this) { + this->actionFunc = BgNumaHana_OpenedIdle; +} + +/** + * Spins the "opened" flower around the y-axis. + */ +void BgNumaHana_OpenedIdle(BgNumaHana* this, GlobalContext* globalCtx) { + this->dyna.actor.shape.rot.y += this->flowerRotationalVelocity; + this->petalZRotation = this->innerPetalZRotation + this->settleZRotation; + BgNumaHana_UpdatePetalPosRots(this); + func_800B9010(&this->dyna.actor, NA_SE_EV_FLOWER_ROLLING - SFX_FLAG); +} + +void BgNumaHana_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgNumaHana* this = THIS; + s32 type = BG_NUMA_HANA_GET_TYPE(&this->dyna.actor); + Vec3f firePos; + + if (type == BG_NUMA_HANA_TYPE_NORMAL) { + firePos.x = this->dyna.actor.world.pos.x; + firePos.y = this->dyna.actor.world.pos.y + 10.5f; + firePos.z = this->dyna.actor.world.pos.z; + FireObj_SetPosition(&this->fire, &firePos); + FireObj_Update(globalCtx, &this->fire, &this->dyna.actor); + } + + this->actionFunc(this, globalCtx); + + if (type == BG_NUMA_HANA_TYPE_NORMAL) { + this->dyna.actor.child->shape.rot = this->dyna.actor.shape.rot; + Collider_UpdateCylinder(&this->dyna.actor, &this->torchCollider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->torchCollider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->torchCollider.base); + } +} + +void BgNumaHana_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BgNumaHana* this = THIS; + WoodenFlowerPetalPosRot* innerPetalPosRot; + WoodenFlowerPetalPosRot* outerPetalPosRot; + s32 objectIndex; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerStalkDL); + + for (i = 0; i < ARRAY_COUNT(this->innerPetalPosRot); i++) { + innerPetalPosRot = &this->innerPetalPosRot[i]; + outerPetalPosRot = &this->outerPetalPosRot[i]; + + Matrix_SetStateRotationAndTranslation(innerPetalPosRot->pos.x, innerPetalPosRot->pos.y, innerPetalPosRot->pos.z, + &innerPetalPosRot->rot); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerInnerPetalDL); + + Matrix_SetStateRotationAndTranslation(outerPetalPosRot->pos.x, outerPetalPosRot->pos.y, outerPetalPosRot->pos.z, + &outerPetalPosRot->rot); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerOuterPetalDL); + } + + objectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_SYOKUDAI); + if ((objectIndex >= 0) && (Object_IsLoaded(&globalCtx->objectCtx, objectIndex))) { + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 64.5f, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Scale(1.5f, 1.5f, 1.5f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[objectIndex].segment); + gSPDisplayList(POLY_OPA_DISP++, gObjectSyokudaiTypeNoSwitchDL); + } + + FireObj_Draw(globalCtx, &this->fire); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.h b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.h index f4974860a..19d30a34f 100644 --- a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.h +++ b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.h @@ -3,15 +3,41 @@ #include "global.h" +#define BG_NUMA_HANA_GET_TYPE(thisx) ((thisx)->params & 1) +#define BG_NUMA_HANA_SWITCH_FLAG(thisx) (((thisx)->params >> 8) & 0x7F) + +typedef enum { + /* 0 */ BG_NUMA_HANA_TYPE_NORMAL, + /* 1 */ BG_NUMA_HANA_TYPE_OPEN_FLOWER_COLLISION, +} BgNumaHanaType; + struct BgNumaHana; typedef void (*BgNumaHanaActionFunc)(struct BgNumaHana*, GlobalContext*); +typedef struct { + /* 0x00 */ Vec3f pos; + /* 0x0C */ Vec3s rot; + /* 0x12 */ UNK_TYPE1 unk_12[0x2]; +} WoodenFlowerPetalPosRot; // size = 0x14 + typedef struct BgNumaHana { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xF0]; - /* 0x0234 */ BgNumaHanaActionFunc actionFunc; - /* 0x0238 */ char unk_238[0x108]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ FireObj fire; + /* 0x1E8 */ ColliderCylinder torchCollider; + /* 0x234 */ BgNumaHanaActionFunc actionFunc; + /* 0x238 */ WoodenFlowerPetalPosRot innerPetalPosRot[6]; + /* 0x2B0 */ WoodenFlowerPetalPosRot outerPetalPosRot[6]; + /* 0x328 */ s16 petalZRotation; + /* 0x32A */ s16 innerPetalZRotation; + /* 0x32C */ s16 innerPetalZRotationalVelocity; + /* 0x32E */ s16 settleZRotation; + /* 0x330 */ s16 settleAngle; + /* 0x334 */ f32 settleScale; + /* 0x338 */ s16 outerPetalZRotation; + /* 0x33A */ s16 outerPetalZRotationalVelocity; + /* 0x33C */ s16 flowerRotationalVelocity; + /* 0x33E */ s16 transitionTimer; } BgNumaHana; // size = 0x340 extern const ActorInit Bg_Numa_Hana_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index cd1f5bf74..560e9ee24 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -9787,23 +9787,23 @@ 0x80A1A220:("ObjRaillift_Draw",), 0x80A1A330:("ObjRaillift_DrawDekuFlowerPlatform",), 0x80A1A360:("ObjRaillift_DrawDekuFlowerPlatformColorful",), - 0x80A1A500:("func_80A1A500",), - 0x80A1A56C:("func_80A1A56C",), - 0x80A1A750:("func_80A1A750",), + 0x80A1A500:("BgNumaHana_SpawnOpenFlowerCollisionChild",), + 0x80A1A56C:("BgNumaHana_UpdatePetalPosRots",), + 0x80A1A750:("BgNumaHana_UpdateSettleRotation",), 0x80A1A7CC:("BgNumaHana_Init",), 0x80A1A9AC:("BgNumaHana_Destroy",), - 0x80A1AA14:("func_80A1AA14",), - 0x80A1AA28:("func_80A1AA28",), - 0x80A1AA38:("func_80A1AA38",), - 0x80A1AA4C:("func_80A1AA4C",), - 0x80A1AAE8:("func_80A1AAE8",), - 0x80A1AB00:("func_80A1AB00",), - 0x80A1ABD8:("func_80A1ABD8",), - 0x80A1ABF0:("func_80A1ABF0",), - 0x80A1ACCC:("func_80A1ACCC",), - 0x80A1ACE0:("func_80A1ACE0",), - 0x80A1AE08:("func_80A1AE08",), - 0x80A1AE1C:("func_80A1AE1C",), + 0x80A1AA14:("BgNumaHana_SetupDoNothing",), + 0x80A1AA28:("BgNumaHana_DoNothing",), + 0x80A1AA38:("BgNumaHana_SetupClosedIdle",), + 0x80A1AA4C:("BgNumaHana_ClosedIdle",), + 0x80A1AAE8:("BgNumaHana_SetupUnfoldInnerPetals",), + 0x80A1AB00:("BgNumaHana_UnfoldInnerPetals",), + 0x80A1ABD8:("BgNumaHana_SetupUnfoldOuterPetals",), + 0x80A1ABF0:("BgNumaHana_UnfoldOuterPetals",), + 0x80A1ACCC:("BgNumaHana_SetupRaiseFlower",), + 0x80A1ACE0:("BgNumaHana_RaiseFlower",), + 0x80A1AE08:("BgNumaHana_SetupOpenedIdle",), + 0x80A1AE1C:("BgNumaHana_OpenedIdle",), 0x80A1AE6C:("BgNumaHana_Update",), 0x80A1AF68:("BgNumaHana_Draw",), 0x80A1B3D0:("func_80A1B3D0",), diff --git a/undefined_syms.txt b/undefined_syms.txt index a74cedb84..3615fb295 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -725,15 +725,6 @@ D_06000798 = 0x06000798; D_06000098 = 0x06000098; -// ovl_Bg_Numa_Hana - -D_06000870 = 0x06000870; -D_06009FE0 = 0x06009FE0; -D_0600A740 = 0x0600A740; -D_0600AB88 = 0x0600AB88; -D_0600B928 = 0x0600B928; -D_0600BE58 = 0x0600BE58; - // ovl_Bg_Open_Shutter D_060003E8 = 0x060003E8; From 8e3d28b536a8d7d8ea9d48793f6ad7525c986c8f Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 19 Feb 2022 13:26:04 -0800 Subject: [PATCH 038/257] En_Syateki_Wf (Shooting Gallery Wolfos) OK (#673) * EnSyatekiWf_Init and EnSyatekiWf_Destroy OK * func_80A201CC OK * func_80A20284 OK * func_80A2030C and func_80A20320 OK * func_80A20378 OK * func_80A200E0 OK * func_80A203DC OK * func_80A20670 OK * func_80A206DC and func_80A20710 OK * func_80A2075C OK * func_80A2079C and func_80A20800 OK * func_80A208F8 OK * Import data to C * func_80A20858 OK * EnSyatekiWf_Update OK * Draw functions OK * Use generated reloc * Delete struct padding * Use object symbols * Name the statics * ANIMMODE enum * Misc cleanup * Format * Respond to review * Change do-while loops to just be while loops * Decimal counter --- include/functions.h | 2 +- spec | 3 +- .../ovl_En_Syateki_Wf/z_en_syateki_wf.c | 462 ++++++++++++++++-- .../ovl_En_Syateki_Wf/z_en_syateki_wf.h | 27 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 5 - 6 files changed, 439 insertions(+), 64 deletions(-) diff --git a/include/functions.h b/include/functions.h index 2b42ce87e..3a224a57d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -595,7 +595,7 @@ void EffectSsEnIce_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec3f* // void EffectSsFireTail_SpawnFlameOnPlayer(void); void EffectSsEnFire_SpawnVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s16 scale, s16 arg4, s16 flags, s16 bodyPart); // void EffectSsEnFire_SpawnVec3s(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); -// void EffectSsExtra_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6); +void EffectSsExtra_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scoreIdx); void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s32 unk); void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s32 colorIndex); // void EffectSsDeadDd_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE1* param_5, UNK_TYPE1* param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE4 param_10); diff --git a/spec b/spec index 17a9ecc8d..2935b24cb 100644 --- a/spec +++ b/spec @@ -2659,8 +2659,7 @@ beginseg name "ovl_En_Syateki_Wf" compress include "build/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.o" - include "build/data/ovl_En_Syateki_Wf/ovl_En_Syateki_Wf.data.o" - include "build/data/ovl_En_Syateki_Wf/ovl_En_Syateki_Wf.reloc.o" + include "build/src/overlays/actors/ovl_En_Syateki_Wf/ovl_En_Syateki_Wf_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c index 952861c83..6e53877a3 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c @@ -5,8 +5,10 @@ */ #include "z_en_syateki_wf.h" +#include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" +#include "objects/object_wf/object_wf.h" -#define FLAGS 0x08000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) #define THIS ((EnSyatekiWf*)thisx) @@ -15,43 +17,91 @@ void EnSyatekiWf_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiWf_Update(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiWf_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A201CC(EnSyatekiWf* this); void func_80A20284(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A2030C(EnSyatekiWf* this); void func_80A20320(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A20378(EnSyatekiWf* this); void func_80A203DC(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A20670(EnSyatekiWf* this); void func_80A206DC(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A20710(EnSyatekiWf* this); void func_80A2075C(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A2079C(EnSyatekiWf* this); void func_80A20800(EnSyatekiWf* this, GlobalContext* globalCtx); void func_80A208F8(EnSyatekiWf* this, GlobalContext* globalCtx); -#if 0 -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A20E74 = { - { COLTYPE_HIT5, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 40, 60, 0, { 0, 0, 0 } }, -}; - -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80A20E50[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 17, { { 800, 0, 0 }, 25 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80A20EA0 = { - { COLTYPE_HIT5, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80A20E50, // sJntSphElementsInit, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HIT5, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { 40, 60, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A20EB0 = { - { COLTYPE_HIT5, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT5, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HIT5, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 15, 20, -15, { 0, 0, 0 } }, }; +static Vec3f D_80A20EDC = { 0.0f, 20.0f, 0.0f }; + +static Vec3f D_80A20EE8 = { 0.0f, 0.0f, 0.0f }; + const ActorInit En_Syateki_Wf_InitVars = { ACTOR_EN_SYATEKI_WF, ACTORCAT_ENEMY, @@ -64,60 +114,372 @@ const ActorInit En_Syateki_Wf_InitVars = { (ActorFunc)EnSyatekiWf_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A20FBC[] = { +static AnimationInfo sAnimations[] = { + { &object_wf_Anim_00A3CC, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &object_wf_Anim_005700, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_wf_Anim_005700, 1.0f, 0.0f, 4.0f, ANIMMODE_ONCE, 1.0f }, + { &object_wf_Anim_005700, 1.0f, 4.0f, 8.0f, ANIMMODE_ONCE, 1.0f }, + { &object_wf_Anim_004A90, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_wf_Anim_009A50, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 8.0f }, + { &object_wf_Anim_0053D0, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_STOP), }; -#endif +static Vec3f D_80A20FC4 = { 0.0f, 0.5f, 0.0f }; -extern ColliderCylinderInit D_80A20E74; -extern ColliderJntSphElementInit D_80A20E50[1]; -extern ColliderJntSphInit D_80A20EA0; -extern ColliderCylinderInit D_80A20EB0; -extern InitChainEntry D_80A20FBC[]; +static Vec3f D_80A20FD0 = { 1200.0f, 0.0f, 0.0f }; -extern UNK_TYPE D_0600A3CC; +static TexturePtr sEyeTextures[] = { + object_wf_Tex_007AA8, + object_wf_Tex_0082A8, + object_wf_Tex_0084A8, + object_wf_Tex_0082A8, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/EnSyatekiWf_Init.s") +void EnSyatekiWf_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSyatekiWf* this = THIS; + Path* path; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + s32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/EnSyatekiWf_Destroy.s") + path = syatekiMan->path; + while (path->unk2 != 2) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A200E0.s") + temp = 0; + while (temp < EN_SYATEKI_WF_GET_PARAM_FF00(&this->actor)) { + temp++; + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A201CC.s") + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20284.s") + this->unk_2A0 = Lib_SegmentedToVirtual(path->points); + this->unk_2A4 = 1; + this->unk_2A6 = path->count; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A2030C.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->unk_29C = 0; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); + this->actor.focus.pos = this->actor.world.pos; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.colChkInfo.health = 2; + this->actor.colChkInfo.cylRadius = 50; + this->actor.colChkInfo.cylHeight = 100; + this->eyeIndex = 0; + this->unk_2AC = 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20320.s") + Collider_InitCylinder(globalCtx, &this->unk_2B4); + Collider_SetCylinder(globalCtx, &this->unk_2B4, &this->actor, &sCylinderInit1); + Collider_InitCylinder(globalCtx, &this->unk_300); + Collider_SetCylinder(globalCtx, &this->unk_300, &this->actor, &sCylinderInit2); + Collider_InitJntSph(globalCtx, &this->unk_34C); + Collider_SetJntSph(globalCtx, &this->unk_34C, &this->actor, &sJntSphInit, &this->unk_36C); + this->unk_34C.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20378.s") + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_wf_Skel_0095D0, &object_wf_Anim_00A3CC, this->jointTable, + this->morphTable, 22); + Actor_SetScale(&this->actor, 0.01f); + this->actor.hintId = 0x4C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A203DC.s") + func_80A201CC(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20670.s") +void EnSyatekiWf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiWf* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A206DC.s") + Collider_DestroyCylinder(globalCtx, &this->unk_2B4); + Collider_DestroyCylinder(globalCtx, &this->unk_300); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20710.s") +void func_80A200E0(EnSyatekiWf* this) { + Vec3f sp24; + s16 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A2075C.s") + this->actor.world.pos.x = this->unk_2A0[0].x; + this->actor.world.pos.y = this->unk_2A0[0].y; + this->actor.world.pos.z = this->unk_2A0[0].z; + sp24.x = this->unk_2A0[this->unk_2A4].x; + sp24.y = this->unk_2A0[this->unk_2A4].y; + sp24.z = this->unk_2A0[this->unk_2A4].z; + temp = Math_Vec3f_Yaw(&this->actor.world.pos, &sp24); + this->actor.shape.rot.y = temp; + this->actor.world.rot.y = temp; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A2079C.s") +void func_80A201CC(EnSyatekiWf* this) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20800.s") + this->actor.speedXZ = 0.0f; + this->actor.world = this->actor.home; + this->actor.prevPos = this->actor.home.pos; + this->actor.shape.rot = this->actor.world.rot; + this->actor.colChkInfo.health = 2; + this->actor.draw = NULL; + this->unk_2A4 = 1; + this->unk_298 = 0; + syatekiMan->unk_276 &= ~(1 << EN_SYATEKI_WF_GET_PARAM_FF00(&this->actor)); + this->actionFunc = func_80A20284; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20858.s") +void func_80A20284(EnSyatekiWf* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A208F8.s") + if (this->actor.parent != NULL) { + syatekiMan = (EnSyatekiMan*)this->actor.parent; + if ((syatekiMan->unk_26A == 1) && (this->unk_298 == 1)) { + func_80A200E0(this); + func_80A2030C(this); + } else if (syatekiMan->unk_276 & (1 << EN_SYATEKI_WF_GET_PARAM_FF00(&this->actor))) { + this->unk_298 = 1; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/EnSyatekiWf_Update.s") +void func_80A2030C(EnSyatekiWf* this) { + this->actionFunc = func_80A20320; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20CF4.s") +void func_80A20320(EnSyatekiWf* this, GlobalContext* globalCtx) { + if (this->unk_29C >= 11) { + Actor_PlaySfxAtPos(this->actor.parent, NA_SE_EN_WOLFOS_APPEAR); + this->unk_29C = 0; + func_80A20378(this); + } else { + this->unk_29C++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20D10.s") +void func_80A20378(EnSyatekiWf* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actor.speedXZ = 10.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.draw = EnSyatekiWf_Draw; + this->actionFunc = func_80A203DC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/EnSyatekiWf_Draw.s") +void func_80A203DC(EnSyatekiWf* this, GlobalContext* globalCtx) { + Vec3f sp54; + f32 sp50; + s16 temp_v0; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (syatekiMan->unk_26A != 1) { + func_80A201CC(this); + } + + sp54.x = this->unk_2A0[this->unk_2A4].x; + sp54.y = this->unk_2A0[this->unk_2A4].y; + sp54.z = this->unk_2A0[this->unk_2A4].z; + temp_v0 = (this->actor.wallYaw - this->actor.world.rot.y) + 0x8000; + + if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & 8) { + if ((ABS(temp_v0) < 0x1555) && (this->actor.wallPoly != this->actor.floorPoly)) { + func_80A20670(this); + return; + } + } + + if (this->actor.bgCheckFlags & 4) { + this->actor.velocity.y = 2.0f; + } + + sp50 = Math_Vec3f_DistXZ(&this->actor.world.pos, &sp54); + this->unk_2A8 = Math_Vec3f_Yaw(&this->actor.world.pos, &sp54); + + if (sp50 > 15.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2A8, 5, 0x3000, 0x100); + this->actor.shape.rot.y = this->actor.world.rot.y; + if (sp50 < 50.0f) { + if (this->actor.speedXZ > 3.0f) { + this->actor.speedXZ = this->actor.speedXZ - 0.5f; + } else { + this->actor.speedXZ = this->actor.speedXZ; + } + } + } else { + if (this->unk_2A4 < (this->unk_2A6 - 1)) { + if (this->unk_2A4 == EN_SYATEKI_WF_GET_PARAM_F0(&this->actor)) { + func_80A2079C(this); + } + + this->unk_2A4++; + } else { + this->unk_298 = 0; + this->unk_2A4 = 1; + func_80A201CC(this); + } + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 10.0f, 3, 2.0f, 0, 0, 0); + } + } +} + +void func_80A20670(EnSyatekiWf* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP); + this->actor.velocity.y = 20.0f; + this->actor.speedXZ = 5.0f; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + this->actionFunc = func_80A206DC; +} + +void func_80A206DC(EnSyatekiWf* this, GlobalContext* globalCtx) { + if (this->actor.bgCheckFlags & 2) { + func_80A20710(this); + } +} + +void func_80A20710(EnSyatekiWf* this) { + this->actor.speedXZ = 0.0f; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + this->actionFunc = func_80A2075C; +} + +void func_80A2075C(EnSyatekiWf* this, GlobalContext* globalCtx) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A20378(this); + } +} + +void func_80A2079C(EnSyatekiWf* this) { + this->unk_29A = 40; + this->actor.speedXZ = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_APPEAR); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + this->actionFunc = func_80A20800; +} + +void func_80A20800(EnSyatekiWf* this, GlobalContext* globalCtx) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->unk_29A--; + if (this->unk_29A == 0) { + func_80A20378(this); + } + } +} + +void func_80A20858(EnSyatekiWf* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + this->unk_298 = 0; + this->actor.speedXZ = 0.0f; + EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_80A20EDC, &D_80A20EE8, 5, 2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_DEAD); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); + syatekiMan->unk_280 += 100; + this->actionFunc = func_80A208F8; +} + +void func_80A208F8(EnSyatekiWf* this, GlobalContext* globalCtx) { + s32 pad; + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A201CC(this); + } else { + Vec3f sp68; + Vec3f sp5C = D_80A20FC4; + s32 i; + + for (i = (s32)this->skelAnime.animLength - (s32)this->skelAnime.curFrame; i >= 0; i--) { + sp68.x = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.x; + sp68.z = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.z; + sp68.y = randPlusMinusPoint5Scaled(50.0f) + (this->actor.world.pos.y + 20.0f); + func_800B3030(globalCtx, &sp68, &sp5C, &sp5C, 0x64, 0, 2); + } + } +} + +void EnSyatekiWf_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnSyatekiWf* this = THIS; + + if (this->actionFunc != func_80A20284) { + SkelAnime_Update(&this->skelAnime); + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 32.0f, 30.0f, 60.0f, 5); + this->actionFunc(this, globalCtx); + + if (this->actor.bgCheckFlags & 3) { + func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); + } else { + Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 0x3E8, 0); + Math_SmoothStepToS(&this->actor.shape.rot.z, 0, 1, 0x3E8, 0); + } + + if ((this->unk_2B4.base.acFlags & AC_HIT) || (this->unk_300.base.acFlags & AC_HIT) || + (this->unk_34C.base.acFlags & AC_HIT)) { + this->unk_2B4.base.acFlags &= ~AC_HIT; + this->unk_300.base.acFlags &= ~AC_HIT; + this->unk_34C.base.acFlags &= ~AC_HIT; + this->actor.colChkInfo.health -= 2; + if (this->actor.colChkInfo.health == 0) { + func_801A3098(NA_BGM_GET_ITEM | 0x900); + func_80A20858(this, globalCtx); + } else { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_80A20EDC, &D_80A20EE8, 3, 0); + } + } + + Collider_UpdateCylinder(&this->actor, &this->unk_2B4); + if ((this->actionFunc != func_80A20284) && (this->actionFunc != func_80A208F8) && (this->actor.draw != NULL)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->unk_300.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->unk_2B4.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->unk_34C.base); + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 25.0f; + } + + if (this->eyeIndex == 0) { + if ((Rand_ZeroOne() < 0.2f) && ((globalCtx->gameplayFrames & 3) == 0) && (this->actor.colorFilterTimer == 0)) { + this->eyeIndex++; + } + } else { + this->eyeIndex = (this->eyeIndex + 1) & 3; + } +} + +s32 EnSyatekiWf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + return false; +} + +void EnSyatekiWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnSyatekiWf* this = THIS; + Vec3f sp18; + + Collider_UpdateSpheres(limbIndex, &this->unk_34C); + if (limbIndex == 6) { + Matrix_MultiplyVector3fByState(&D_80A20FD0, &sp18); + this->unk_300.dim.pos.x = sp18.x; + this->unk_300.dim.pos.y = sp18.y; + this->unk_300.dim.pos.z = sp18.z; + } +} + +void EnSyatekiWf_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiWf* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnSyatekiWf_OverrideLimbDraw, EnSyatekiWf_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h index ff552ed19..23977fa02 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h @@ -3,15 +3,34 @@ #include "global.h" +#define EN_SYATEKI_WF_GET_PARAM_F0(thisx) (((thisx)->params & 0xF0) >> 4) +#define EN_SYATEKI_WF_GET_PARAM_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + struct EnSyatekiWf; typedef void (*EnSyatekiWfActionFunc)(struct EnSyatekiWf*, GlobalContext*); typedef struct EnSyatekiWf { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x150]; - /* 0x0294 */ EnSyatekiWfActionFunc actionFunc; - /* 0x0298 */ char unk_298[0x134]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[22]; + /* 0x20C */ Vec3s morphTable[22]; + /* 0x290 */ UNK_TYPE1 unk_290[0x4]; + /* 0x294 */ EnSyatekiWfActionFunc actionFunc; + /* 0x298 */ s16 unk_298; + /* 0x29A */ s16 unk_29A; + /* 0x29C */ s16 unk_29C; + /* 0x2A0 */ Vec3s* unk_2A0; + /* 0x2A4 */ s16 unk_2A4; + /* 0x2A6 */ s16 unk_2A6; + /* 0x2A8 */ s16 unk_2A8; + /* 0x2AC */ f32 unk_2AC; + /* 0x2B0 */ u8 eyeIndex; + /* 0x2B4 */ ColliderCylinder unk_2B4; + /* 0x300 */ ColliderCylinder unk_300; + /* 0x34C */ ColliderJntSph unk_34C; + /* 0x36C */ ColliderJntSphElement unk_36C; + /* 0x3AC */ UNK_TYPE1 unk_3AC[0x20]; } EnSyatekiWf; // size = 0x3CC extern const ActorInit En_Syateki_Wf_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 560e9ee24..8f47ab411 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -9892,8 +9892,8 @@ 0x80A20858:("func_80A20858",), 0x80A208F8:("func_80A208F8",), 0x80A20A50:("EnSyatekiWf_Update",), - 0x80A20CF4:("func_80A20CF4",), - 0x80A20D10:("func_80A20D10",), + 0x80A20CF4:("EnSyatekiWf_OverrideLimbDraw",), + 0x80A20D10:("EnSyatekiWf_PostLimbDraw",), 0x80A20DA4:("EnSyatekiWf_Draw",), 0x80A21150:("func_80A21150",), 0x80A211F4:("func_80A211F4",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 3615fb295..74718ed44 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1841,11 +1841,6 @@ D_06003180 = 0x06003180; D_060033D0 = 0x060033D0; D_0600466C = 0x0600466C; -// ovl_En_Syateki_Wf - -D_060095D0 = 0x060095D0; -D_0600A3CC = 0x0600A3CC; - // ovl_En_S_Goro D_060091A8 = 0x060091A8; From fed9dc991d8176c4a6e32bc250d76d3f39f8f141 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 19 Feb 2022 13:30:31 -0800 Subject: [PATCH 039/257] Tutorial on decompiling objects (and also object_dns documented) (#647) * Fix existing documentation * Fill out object_decomp.md * First part of object decomp example * Document animations * Tutorial for identifying blob * Naming everything else referenced in the actor * Name all limb display lists * Finish example * Some tips and tricks * Remove TODO * Make merging.md consistent with everything else * Name limbs properly * Rename "bouncing idle" to "walk", since they use that animation to walk towards you if they catch you * Run formatter again * Purge hylian toolbox * Be a bit more precise about vertex naming * Also -> Further * Correct description of how extract_assets works * Format types of data * Add note about palette * Update text about object's C file * Fix typo * one more time -> in more detail * Format render error as code * explain what texture animations are * Standardize on bullet points * Use anon's sugestion for the "How we work with objects" section * Trailing commas for better formatting * Delete undefined_syms reference in object decomp * Add note about root limbs * Remove undefined_syms reference in object_decomp_example * Remove "since" * Explain *how* I changed the texture * Explain what to do if the limb doesn't render anything * Fix some extremely tiny incorrect enum name thing * Explain the object symbol stuff bettter * Add link to ZAPD documentation * Also update documentation * Update actor flags for Dns --- assets/xml/objects/object_dns.xml | 81 +++--- docs/tutorial/beginning_decomp.md | 6 +- docs/tutorial/contents.md | 4 +- docs/tutorial/data.md | 42 ++- docs/tutorial/documenting.md | 100 +++---- docs/tutorial/draw_functions.md | 4 +- docs/tutorial/images/broken_texture.png | Bin 0 -> 2602 bytes .../images/custom_texture_in_game.png | Bin 0 -> 235272 bytes docs/tutorial/images/dns_custom_texture.png | Bin 0 -> 169 bytes .../images/z64utils_dns_deku_flower.png | Bin 0 -> 137323 bytes .../images/z64utils_dns_display_list.png | Bin 0 -> 56612 bytes .../images/z64utils_dns_head_limb.png | Bin 0 -> 58917 bytes .../images/z64utils_dns_limb_dlist.png | Bin 0 -> 34836 bytes .../images/z64utils_dns_skeletonheader.png | Bin 0 -> 34826 bytes docs/tutorial/images/z64utils_open_dns.png | Bin 0 -> 11627 bytes .../images/z64utils_set_segment_8.png | Bin 0 -> 13182 bytes docs/tutorial/merging.md | 4 +- docs/tutorial/object_decomp.md | 156 ++++++++++- docs/tutorial/object_decomp_example.md | 258 ++++++++++++++++++ docs/tutorial/other_functions.md | 4 +- src/overlays/actors/ovl_En_Dns/z_en_dns.c | 117 +++++--- src/overlays/actors/ovl_En_Dns/z_en_dns.h | 11 +- 22 files changed, 599 insertions(+), 188 deletions(-) create mode 100644 docs/tutorial/images/broken_texture.png create mode 100644 docs/tutorial/images/custom_texture_in_game.png create mode 100644 docs/tutorial/images/dns_custom_texture.png create mode 100644 docs/tutorial/images/z64utils_dns_deku_flower.png create mode 100644 docs/tutorial/images/z64utils_dns_display_list.png create mode 100644 docs/tutorial/images/z64utils_dns_head_limb.png create mode 100644 docs/tutorial/images/z64utils_dns_limb_dlist.png create mode 100644 docs/tutorial/images/z64utils_dns_skeletonheader.png create mode 100644 docs/tutorial/images/z64utils_open_dns.png create mode 100644 docs/tutorial/images/z64utils_set_segment_8.png create mode 100644 docs/tutorial/object_decomp_example.md diff --git a/assets/xml/objects/object_dns.xml b/assets/xml/objects/object_dns.xml index 135dc6ab6..d42f68f54 100644 --- a/assets/xml/objects/object_dns.xml +++ b/assets/xml/objects/object_dns.xml @@ -1,44 +1,45 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + " Format="rgba16" Width="8" Height="8" Offset="0x28E8" /> + + + + + + + + + + + + + + + + + + diff --git a/docs/tutorial/beginning_decomp.md b/docs/tutorial/beginning_decomp.md index b46bd219a..13e5941fc 100644 --- a/docs/tutorial/beginning_decomp.md +++ b/docs/tutorial/beginning_decomp.md @@ -1,6 +1,6 @@ # Beginning decompilation: the Init function and the Actor struct -Up: [Contents](contents.md) +- Up: [Contents](contents.md) Open the C file and the H file with your actor's name from the appropriate directory in `src/overlays/actors/`. These will be the main files we work with. We will be using EnRecepgirl (the rather forward Mayor's receptionist in the Mayor's residence in East Clock Town) as our example: it is a nice simple NPC with most of the common features of an NPC. @@ -96,9 +96,9 @@ It is currently divided into six sections as follows: 3. These are prototypes for the "main four" functions that almost every actor has. You add more functions here if they need to be declared above their first use. -5. `if`'d-out section containing the `InitVars` and a few other common pieces of data. This can be ignored until we import the data. +4. `if`'d-out section containing the `InitVars` and a few other common pieces of data. This can be ignored until we import the data. -4. A set of `extern`s. These refer to the data in the previous section, and, data that comes from other files, usually in the actor's corresponding object file. The latter point to addresses in the ROM where assets are stored (usually collision data, animations or display lists). Once the corresponding object files have been decompiled, these will simply be replaced by including the object file (see [Object Decompilation](object_decomp.md) for how this process works). These symbols have been automatically extracted from the MIPS code. There may turn out to be some that were not caught by the script, in which case they need to be placed in the file called `undefined_syms.txt` in the root directory of the project. Ask in Discord for how to do this: it is simple, but rare enough to not be worth covering here. +5. A set of `extern`s. These refer to the data in the previous section, and, data that comes from other files, usually in the actor's corresponding object file. The latter point to addresses in the ROM where assets are stored (usually collision data, animations or display lists). These can simply be replaced by including the object file (see [Object Decompilation](object_decomp.md) for how this process works). 6. List of functions. Each `#pragma GLOBAL_ASM` is letting the compiler use the corresponding assembly file while we do not have decompiled C code for that function. The majority of the decompilation work is converting these functions into C that it looks like a human wrote. diff --git a/docs/tutorial/contents.md b/docs/tutorial/contents.md index 227f4fc7d..0435becb4 100644 --- a/docs/tutorial/contents.md +++ b/docs/tutorial/contents.md @@ -32,7 +32,9 @@ - Fake symbols - Inlining -## [Object Decompilation](object_decomp.md) (TODO) +- [Documenting a decompiled file](documenting.md) + +## [Object Decompilation](object_decomp.md) - Object files - How we decompile objects diff --git a/docs/tutorial/data.md b/docs/tutorial/data.md index ae856123e..972451b07 100644 --- a/docs/tutorial/data.md +++ b/docs/tutorial/data.md @@ -1,13 +1,13 @@ # Data -Up: [Contents](contents.md) -Previous: [Draw functions](draw_functions.md) +- Up: [Contents](contents.md) +- Previous: [Draw functions](draw_functions.md) ## Table of Contents - [Data first](#data-first) - [Extern and data last](#extern-and-data-last) -- [Segmented pointers](#segmented-pointers) +- [Segmented pointers and object symbols](#segmented-pointers-and-object-symbols) - [Fake symbols](#fake-symbols) - [Inlining](#inlining) @@ -114,7 +114,7 @@ static s32 D_80C106C8 = 0; That should be everything, and we should now be able to `make` without the data file with no issues. -## Segmented pointers +## Segmented pointers and object symbols The game has a convenient system that allows it to sometimes effectively use offsets into a file instead of raw memory addresses to reference things. This is done by setting a file address to a *segment*. A segmented address is of the form `0x0XYYYYYY`, where `X` is the segment number. There are 16 available segments, and actors always set segment 6 to their object file, which is a file containing assets (skeleton, animations, textures, etc.) that they use. This is what all those `D_06...` are, and it is also what the entries in `D_80C106B0` are: they are currently raw numbers instead of symbols, though, and we would like to replace them. @@ -124,29 +124,23 @@ mips-linux-gnu-ld: build/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.o:( ```` As we'd expect, of course: we didn't fulfil our promise that they were defined elsewhere.) -This is mitigated by use of the file `undefined_syms.txt`, which feeds the linker the raw addresses to use as the symbol definitions. If you find a segmented address that is not in already externed, `extern` it at the top of the file and add it to the actor's section in undefined_syms: -```C -extern void* D_0600F8F0; -extern void* D_0600FCF0; -extern void* D_060100F0; -extern void* D_0600FCF0; +For actors which have yet to be decompiled, this is mitigated by use of the file `undefined_syms.txt`, which feeds the linker the raw addresses to use as the symbol definitions. However, we want to replace these segmented addresses with proper object symbols whenever possible. In `En_Recepgirl_InitVars`, we can see that this actor uses the object `OBJECT_BG`: +```c +const ActorInit En_Recepgirl_InitVars = { + ACTOR_EN_RECEPGIRL, + ACTORCAT_NPC, + FLAGS, + OBJECT_BG, +}; +``` -static void* D_80C106B0[4] = { &D_0600F8F0, &D_0600FCF0, &D_060100F0, &D_0600FCF0 }; -``` -and in undefined_syms.txt: -``` -// ovl_En_Recepgirl -D_06000968 = 0x06000968; -D_06001384 = 0x06001384; -D_06009890 = 0x06009890; -D_0600A280 = 0x0600A280; -D_0600AD98 = 0x0600AD98; -D_0600F8F0 = 0x0600F8F0; -D_0600FCF0 = 0x0600FCF0; -D_060100F0 = 0x060100F0; -D_06011B60 = 0x06011B60; +If we open up `assets/objects/object_bg.h`, we can see a bunch of different names corresponding to every asset in the object. You may notice that some of these names look a bit familiar; `object_bg_Tex_00F8F0` seems very close to the segmented address `(void*)0x600F8F0`. This is the proper object symbol for this segmented address, so we should `#include` this header in our actor and use these object symbols like so: +```c +static void* D_80C106B0[4] = { object_bg_Tex_00F8F0, object_bg_Tex_00FCF0, object_bg_Tex_0100F0, object_bg_Tex_00FCF0 }; ``` +After replacing every segmented pointer with an object symbol, you should go ahead and delete every segmented pointer associated with this actor from `undefined_syms`. + We will come back and name these later when we do the object. diff --git a/docs/tutorial/documenting.md b/docs/tutorial/documenting.md index bdfe49dc2..b064b3e3b 100644 --- a/docs/tutorial/documenting.md +++ b/docs/tutorial/documenting.md @@ -1,7 +1,7 @@ # Documenting -Up: [Contents](contents.md) -Previous: [Data](data.md) +- Up: [Contents](contents.md) +- Previous: [Data](data.md) Decompilation is only the first step: since the point of this project is to understand the game better than ever before, the code needs documentation. In this document, we will go through the basic stuff that it's good to do for any actor: we will not try to understand every single thing the actor does in full detail, but try to name the functions and variables usefully for a full documentation pass later to take advantage of. @@ -62,11 +62,7 @@ const ActorInit En_Recepgirl_InitVars = { (ActorFunc)EnRecepgirl_Draw, }; -extern void* D_0600F8F0; -extern void* D_0600FCF0; -extern void* D_060100F0; - -static void* D_80C106B0[4] = { &D_0600F8F0, &D_0600FCF0, &D_060100F0, &D_0600FCF0 }; +static void* D_80C106B0[4] = { object_bg_Tex_00F8F0, object_bg_Tex_00FCF0, object_bg_Tex_0100F0, object_bg_Tex_00FCF0 }; // static InitChainEntry sInitChain[] = { static InitChainEntry D_80C106C0[] = { @@ -76,14 +72,6 @@ static InitChainEntry D_80C106C0[] = { static s32 D_80C106C8 = 0; -extern AnimationHeader D_06000968; -extern AnimationHeader D_06001384; -extern AnimationHeader D_06009890; -extern AnimationHeader D_0600A280; -extern AnimationHeader D_0600AD98; -extern FlexSkeletonHeader D_06011B60; - - // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Init.s") void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx) { EnRecepgirl* this = THIS; @@ -91,7 +79,7 @@ void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, D_80C106C0); ActorShape_Init(&this->actor.shape, -60.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06011B60, &D_06009890, this->jointTable, this->morphTable, 24); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_bg_Skel_011B60, &object_bg_Anim_009890, this->jointTable, this->morphTable, 24); if (D_80C106C8 == 0) { for (i = 0; i < 4; i++) { @@ -132,8 +120,8 @@ void func_80C100DC(EnRecepgirl *this) { // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10148.s") void func_80C10148(EnRecepgirl *this) { - if (this->skelAnime.animation == &D_06001384) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 5.0f); + if (this->skelAnime.animation == &object_bg_Anim_001384) { + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 5.0f); } this->actionFunc = func_80C1019C; } @@ -141,10 +129,10 @@ void func_80C10148(EnRecepgirl *this) { // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C1019C.s") void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime) != 0) { - if (this->skelAnime.animation == &D_0600A280) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 5.0f); + if (this->skelAnime.animation == &object_bg_Anim_00A280) { + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 5.0f); } else { - Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, -4.0f); + Animation_ChangeTransitionRepeat(&this->skelAnime, &object_bg_Anim_009890, -4.0f); } } @@ -164,7 +152,7 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10290.s") void func_80C10290(EnRecepgirl *this) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600A280, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00A280, -4.0f); this->actionFunc = func_80C102D4; } @@ -173,18 +161,18 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { u8 temp_v0_2; if (SkelAnime_Update(&this->skelAnime) != 0) { - if (this->skelAnime.animation == &D_0600A280) { - Animation_ChangeDefaultRepeat(&this->skelAnime, &D_06001384); - } else if (this->skelAnime.animation == &D_0600AD98) { + if (this->skelAnime.animation == &object_bg_Anim_00A280) { + Animation_ChangeDefaultRepeat(&this->skelAnime, &object_bg_Anim_001384); + } else if (this->skelAnime.animation == &object_bg_Anim_00AD98) { if (this->actor.textId == 0x2ADA) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_06000968, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_000968, 10.0f); } else { - Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, 10.0f); + Animation_ChangeTransitionRepeat(&this->skelAnime, &object_bg_Anim_009890, 10.0f); } } else if (this->actor.textId == 0x2ADA) { - Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, 10.0f); + Animation_ChangeTransitionRepeat(&this->skelAnime, &object_bg_Anim_009890, 10.0f); } else { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600A280, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00A280, -4.0f); } } @@ -198,17 +186,17 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { Flags_SetSwitch(globalCtx, this->actor.params); - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); if ((gSaveContext.weekEventReg[63] & 0x80)) { this->actor.textId = 0x2ADF; } else { this->actor.textId = 0x2ADA; } } else if (this->actor.textId == 0x2ADC) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); this->actor.textId = 0x2ADD; } else { - Animation_MorphToPlayOnce(&this->skelAnime, &D_06000968, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_000968, 10.0f); if (this->actor.textId == 0x2ADD) { this->actor.textId = 0x2ADE; } else if (this->actor.textId == 0x2ADA) { @@ -349,11 +337,9 @@ Go to "Analysis -> Find Dlists" and press OK (the defaults are usually fine). Th We will talk about what all these types of data are next time, but for now, all we want to know is what ```C -extern void* D_0600F8F0; -extern void* D_0600FCF0; -extern void* D_060100F0; +static void* D_80C106B0[4] = { object_bg_Tex_00F8F0, object_bg_Tex_00FCF0, object_bg_Tex_0100F0, object_bg_Tex_00FCF0 }; ``` -actually are. We know they are set on segment 8, so we need to find where the skeleton uses them. We know from `extern FlexSkeletonHeader D_06011B60;` that this is at `0x06011B60`, so scroll down to it, right-click on it, and choose "Open in Skeleton Viewer". Pick an animation that we know it uses (sometimes Z64Utils misidentifies other things for animations), such as `extern AnimationHeader D_06000968;`, and you will get this error: +actually are. We know they are set on segment 8, so we need to find where the skeleton uses them. We know from `object_bg_Skel_011B60` that this is at `0x06011B60`, so scroll down to it, right-click on it, and choose "Open in Skeleton Viewer". Pick an animation that we know it uses (sometimes Z64Utils misidentifies other things for animations), such as `object_bg_Anim_000968`, and you will get this error: ![Z64Utils, error when viewing skeleton](images/z64utils_skeleton_error.png) @@ -389,11 +375,7 @@ But what sort of textures? This is an NPC, so what textures on the model would i **N.B.** static data should not be renamed in the assembly or `variables.txt`, since assembly has no notion of file locality and there can be symbol clashes. Therefore it should only be renamed in its respective file, not globally. ```C -extern void* D_0600F8F0; -extern void* D_0600FCF0; -extern void* D_060100F0; - -static TexturePtr sEyeTextures[] = { &D_0600F8F0, &D_0600FCF0, &D_060100F0, &D_0600FCF0 }; +static TexturePtr sEyeTextures[] = { object_bg_Tex_00F8F0, object_bg_Tex_00FCF0, object_bg_Tex_0100F0, object_bg_Tex_00FCF0 }; ``` And now it's rather more obvious what @@ -461,18 +443,18 @@ Finally, we have to name the rest of the functions. Setup functions are usually ```C void func_80C10148(EnRecepgirl* this) { - if (this->skelAnime.animation == &D_06001384) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 5.0f); + if (this->skelAnime.animation == &object_bg_Anim_001384) { + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 5.0f); } this->actionFunc = func_80C1019C; } void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime) != 0) { - if (this->skelAnime.animation == &D_0600A280) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 5.0f); + if (this->skelAnime.animation == &object_bg_Anim_00A280) { + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 5.0f); } else { - Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, -4.0f); + Animation_ChangeTransitionRepeat(&this->skelAnime, &object_bg_Anim_009890, -4.0f); } } @@ -491,7 +473,7 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { } void func_80C10290(EnRecepgirl* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600A280, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00A280, -4.0f); this->actionFunc = func_80C102D4; } @@ -499,18 +481,18 @@ void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) { u8 temp_v0_2; if (SkelAnime_Update(&this->skelAnime)) { - if (this->skelAnime.animation == &D_0600A280) { - Animation_ChangeDefaultRepeat(&this->skelAnime, &D_06001384); - } else if (this->skelAnime.animation == &D_0600AD98) { + if (this->skelAnime.animation == &object_bg_Anim_00A280) { + Animation_ChangeDefaultRepeat(&this->skelAnime, &object_bg_Anim_001384); + } else if (this->skelAnime.animation == &object_bg_Anim_00AD98) { if (this->actor.textId == 0x2ADA) { // Mayor's office is on the left (meeting ongoing) - Animation_MorphToPlayOnce(&this->skelAnime, &D_06000968, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_000968, 10.0f); } else { - Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, 10.0f); + Animation_ChangeTransitionRepeat(&this->skelAnime, &object_bg_Anim_009890, 10.0f); } } else if (this->actor.textId == 0x2ADA) { // Mayor's office is on the left (meeting ongoing) - Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, 10.0f); + Animation_ChangeTransitionRepeat(&this->skelAnime, &object_bg_Anim_009890, 10.0f); } else { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600A280, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00A280, -4.0f); } } @@ -521,17 +503,17 @@ void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) { } else if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { // "Welcome..." Flags_SetSwitch(globalCtx, this->actor.params); - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); if (gSaveContext.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended) } else { this->actor.textId = 0x2ADA; // Mayor's office is on the left (meeting ongoing) } } else if (this->actor.textId == 0x2ADC) { // hear directions again? - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); this->actor.textId = 0x2ADD; // "So..." } else { - Animation_MorphToPlayOnce(&this->skelAnime, &D_06000968, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_000968, 10.0f); if (this->actor.textId == 0x2ADD) { // "So..." this->actor.textId = 0x2ADE; // Mayor's office is on the left, drawing room on the right @@ -568,7 +550,7 @@ We like to make macros for reading an actor's `params` (indeed, this is required } else { Actor_SetScale(&this->dyna.actor, 0.1f); DynaPolyActor_Init(&this->dyna, 1); - CollisionHeader_GetVirtual(&D_06001B2C, &colHeader); + CollisionHeader_GetVirtual(&object_tree_Colheader_001B2C, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); } ``` @@ -588,7 +570,7 @@ Notice that we use `thisx`: this makes the form of every one of these macros the } else { Actor_SetScale(&this->dyna.actor, 0.1f); DynaPolyActor_Init(&this->dyna, 1); - CollisionHeader_GetVirtual(&D_06001B2C, &colHeader); + CollisionHeader_GetVirtual(&object_tree_Colheader_001B2C, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); } ``` diff --git a/docs/tutorial/draw_functions.md b/docs/tutorial/draw_functions.md index 5f9aa551d..eae1c121e 100644 --- a/docs/tutorial/draw_functions.md +++ b/docs/tutorial/draw_functions.md @@ -1,7 +1,7 @@ # Draw functions -Up: [Contents](contents.md) -Previous: [The rest of the functions in the actor](other_functions.md) +- Up: [Contents](contents.md) +- Previous: [The rest of the functions in the actor](other_functions.md) Draw functions behave completely differently from the other functions in an actor. They often use a lot of macros. diff --git a/docs/tutorial/images/broken_texture.png b/docs/tutorial/images/broken_texture.png new file mode 100644 index 0000000000000000000000000000000000000000..6f79f18725237e70731c6a8740f9fbee6f27b743 GIT binary patch literal 2602 zcmeAS@N?(olHy`uVBq!ia0y~yU{GLSU~u4IW?*3O322?ez`)E9;1lA?z`(%B$jHRR z#LUdh!otGJ%F4#Z#?H>p!NI}F$;rjV#m&vl!^6YN%ge{d$Is6%ARr(pC@3T(BrGf} zA|fIxDk>%>CN3^6At50tDJdl-B`qy2BO}AWz#u0lCoeCrpa8O0Nl8grSy@FzMO9Um zfq_9?U0p*%LsL^zOG`^zTU$p*M^{%@Pfw45fx*DQz|hc;fq}u;*x1Cxgn@y<%*@Q( z+}y&#!qU>x%F2p?fx*Vc#@5!>&d!bj2ArInU`z%#H#c{8cMlH_xCor#@9!TF5CG?f zgoH3KFocDLg@=bnL`1;F85kI1V`Jmu;^O1ukp)vyQWzK*($dlx7#K1#GLWSh7#Q;M z@)#Hx3JMAe3k%Vt%FD|uDk>@~Dz}Teoig`t``-TefUL=I-3N6T;oIXV2cfdl?uQ_V3?+;J|@{2M-=P zbclh0;mDCAM~@zbsKF%9ojV5?ymaXj0|UdAD_0m87_MEr#=yXE(`V0~K}24@e96GT@cQ-ZH*elRMBcxD|KY<22>bKr z&kzQj{Q2`I0|UeF-@h3c82&<9C#Sfsvsk$S?RmKEUw*|9=pM5FnKdU;(fg zSdf8%;Xerf2a#X~hyclhtO99=@WHA;YM~0jG9UtE3RoO$GDs6h1K70xAWcvLO#-Bb z0jvXT23R>r35WsG0X7xH0UH5Q!vGcnX#oj=^@9{LWSN<#G|t{)IZ~P zn#lGy&nB-mo&T@GFJ--pa(7_v>ceSn-bdaX=IhHlt5~t`#NM9%Imb#av2|uwm<7f4}Ot-O9JC?El|;zxVsgy&}9IwbOr^HFHDbi$R1v-vg>)nR^Q12?-z6$IIWzbvdY8jbFIFC z?DbN%a}9fau5VoJ-ZhE2q0eH=L&+_+v+dvP+Rx9n&iMVV!*3VfytOJ!_`r4P+QV~r zcilaha3Rg`PF}f1!QF|Ow|Nc}-n;!V!=jyG@kHU71+qKy%HQ$LnK;?&q|)|}KWeVY z%{ph&cjkzaagm$Pg#?C3kuT*BC4ML|t&{i?-{|)F+nu@0&W_vOWZ3lPd_Lvmv_gK? z#VybIcJ(kynrsp_Z>>Kh@G<*vhq8yXgiGh^*+rDf;q zd>$V;y@jRG@kNPd(Ch6ymtHZNZ#?Uw^!DhL@0uK?3-1ana$UFLz|+#^M4bL6IXm)^rGbNs@eW5`~Hqop~~v3jCDS5Z(YE#?|!^?%6>UP$(yLlS^ z?JhXx;`Q}|*P}~08Gl5AK3Q`n1Z&Am5X)v*;>Ip#-)}Fh1Wke_do|sf#pvwmbgEr9 z>FViO*Ity^oHt%$HO*_0!h-G27J;ggAI;b?q{xxE@!PjY%1$VG z`*F&TFyYsm7?M53j&53d@VNB1?%STTyy~*+c^)6i&Jtx*i#yz}Ij!}}seJ$WYRjWe zihaL-W>>E97kwRz^f!Aln?BsV&zZ1!fwt?@)oXtr7QbueEpV*cdF!S4|Lgv2KFgrG z!r8F;@5z0(W%7p-jGjOKtR-~*+=a99+vnT+x@g_mI<;5*_FMut2e0k!UA$P<_f*Fs1Hk}`ntv|@wM|cnZr1+&{Co6O*_Oh{ zbqT8(gMTGdRp-C2=2%$NaXQXkhX3x$R0-Kv!k5-(r_VC~m8{RXaFNOR&-M4pcdfg; zTilgz>u>I#Jkrh2tE;OGJW^XGOuBEm&t7_4VovX|=k44oey67W{OssZRF%P#|zl&k;>a|z1)`+wAT#-5N zEHdx7P22aRz=sLyP7(|$DJugWTzVNJ$ISYp>%dX%$`FBsc)uHKrg3S#@F=#Je!6hO z@lPGzuVtK8>7BMR$>!}_&X+jh)XO=2C9#tXrfuj^jXl7la42hP;?`HIR(Tbqsjg&L z9oDp%_hRD4G_^%L*k*Q~wB0d9!Q{>R&~2NJ`e>Q1JZL1|$R?v&As*fu>KJj_=K#yL dJNC){nX^tie|G5YJ_)KGJYD@<);T3K0RYMq1H1qL literal 0 HcmV?d00001 diff --git a/docs/tutorial/images/custom_texture_in_game.png b/docs/tutorial/images/custom_texture_in_game.png new file mode 100644 index 0000000000000000000000000000000000000000..92fa538117c9f9cda17dbdf5a9987a86c2b74a67 GIT binary patch literal 235272 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 JxyYj^?@?`Z*rWi~ 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

@h_xleEJySeVCz_A&t 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 literal 0 HcmV?d00001 diff --git a/docs/tutorial/images/z64utils_dns_deku_flower.png b/docs/tutorial/images/z64utils_dns_deku_flower.png new file mode 100644 index 0000000000000000000000000000000000000000..66b40a3fd31736117113dc5e91fbea564ab0f7e5 GIT binary patch literal 137323 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 zϢef?MSD{kGJ^>oUOwVvAwHzrl(`t`7YkJ-OYN8 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 literal 0 HcmV?d00001 diff --git a/docs/tutorial/images/z64utils_dns_display_list.png b/docs/tutorial/images/z64utils_dns_display_list.png new file mode 100644 index 0000000000000000000000000000000000000000..31cbd579464368f97a6212c0b61078c9b15f320e GIT binary patch literal 56612 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 PCq6$Q^&=GeRgL13Khll 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 A9RL6T literal 0 HcmV?d00001 diff --git a/docs/tutorial/images/z64utils_dns_head_limb.png b/docs/tutorial/images/z64utils_dns_head_limb.png new file mode 100644 index 0000000000000000000000000000000000000000..dcb658fe80240f69b735768af23e3b3b5b7f015e GIT binary patch literal 58917 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%0D?*uF;d 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 literal 0 HcmV?d00001 diff --git a/docs/tutorial/images/z64utils_dns_limb_dlist.png b/docs/tutorial/images/z64utils_dns_limb_dlist.png new file mode 100644 index 0000000000000000000000000000000000000000..0f24d02250424793ab3eb33f953ed70efaaeb32e GIT binary patch literal 34836 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 literal 0 HcmV?d00001 diff --git a/docs/tutorial/images/z64utils_open_dns.png b/docs/tutorial/images/z64utils_open_dns.png new file mode 100644 index 0000000000000000000000000000000000000000..84533270e62b191da7c867333d52699232e738b8 GIT binary patch literal 11627 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 rg9A6bL7!G}qvv%Y-is3=9mOu6{1-oD!M<8jVn+ literal 0 HcmV?d00001 diff --git a/docs/tutorial/images/z64utils_set_segment_8.png b/docs/tutorial/images/z64utils_set_segment_8.png new file mode 100644 index 0000000000000000000000000000000000000000..46b2f1cff5edb70c375c737d94af3404f0df74af GIT binary patch literal 13182 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 ^rA$Uxrm^mEGqP2iO)Y zht_omg6IF610GXxlsQ!l8vd0_2RGtntv%ldi zKt=PVyEdSK5a<#%=7s$`Kts`Q?yH~AdeAr<)QmsKvu6Fir)i7~3>)(6|MNjseL=>U z7lI4^vrG&O4-_)M9gYi~#_8v5bf$XcZLI$QA4QJ;_cZ?9`<7RjGioWv-9D=d*0*jD_J@rGuq|FG^wIa- z!L;D@p;=nDS~5>A@%PQjUZt`~s;Ils9nwEIbo0E;a&U`e`;D29j=~SAF13)z+hMi^ zYa_(Vu86!ndAKs!`W&h0O5E zt&ZO%PwRbOGL7p^_{s&INYva zZt<%vyiKX8vDb5p?&;iqcgrO#Rb1uySw3z^r7-Jpc9h-`6WJU4L}j!)1AX;xJudUy z=yYedK)&l8ORgibHhufj`5rs_tO(nZ!1rsSgS-A=wiU|?d77Ig@0vY)wTm;Z>TBP1 z5&Q31S88uq!Rrdt0hTA*J{C7~#?`IQi4b?Yy6JUUaFFuGrfIn;t94fkaKHFrA*26L zQ?xtS>lU;1oGVW+is?RcbOKMomFg};bP*y_K9{U~nieX#SLRQ1-SLRFHRsmfzvLTx zb?N828&;LCwzTctS+{ZX%e}KFDI1FVq^#BrZ??7Ly0nZa!;8SYxS7v zz8Cm#aG`qqh3;7wv$y}9$n|>rort!57k9nfySA5c!Q)FopWi-%jjD7ZjjDXOvS^yg zYx(0JBQ1)tXScY%-JY_w-KfJXojE&S&NTSF;rxNL{A{`Nw~t@= zQGVZK^Ig4PSu=nCJs@V~=aSD>81e&H|K$pL>AIYZ-7CgBobqb7f=9(AhoeLpyl zfq|i48L|QwR3KRuK07nBed#3G1J~n;EkYrsFQh2b0TpFUVxWN?KAY-qnP8LsYF<2^ z4_PIA!oS`D+)3$Vx3BSM1`m-5GB7Z(J91-mNE)}_uj~hp*#twZfE4impYq?o^nKrR zuUUT|?Z15C_^V&%{{OkZPNBnYq5oX#wd()Rmw&nYd)*4<=3h(C|C#gerS<)**UoPJ zQO;KHIsa$t_pk5%R|YNrf7U%VaWnsy{`ddN|6cumH>tly>DT+xUx(knw4NP*=8wJ2 z+VA`i?|=KpX8+ya_y4yr>;1P6+G6Z0VP>$ATk@a3PNenk_iK8fWg85hu6{1-oD!M< D$Zqmx literal 0 HcmV?d00001 diff --git a/docs/tutorial/merging.md b/docs/tutorial/merging.md index 1d8c6ad1c..79e1386cc 100644 --- a/docs/tutorial/merging.md +++ b/docs/tutorial/merging.md @@ -1,7 +1,7 @@ # The merging process -Up: [Contents](contents.md) -Previous: [Documenting](documenting.md) +- Up: [Contents](contents.md) +- Previous: [Documenting](documenting.md) ## Preparing to PR diff --git a/docs/tutorial/object_decomp.md b/docs/tutorial/object_decomp.md index 88fe89eca..f210dd446 100644 --- a/docs/tutorial/object_decomp.md +++ b/docs/tutorial/object_decomp.md @@ -1,14 +1,160 @@ -# Analysing object files +# Object Decompilation -Up: [Contents](contents.md) -Previous: [Documenting](documenting.md) +- Up: [Contents](contents.md) +- Previous: [Documenting](documenting.md) -TODO: To be written once automated objects are present. +Object decompilation is the process of taking an object file and writing instructions to extract the various assets from it in the correct format, with appropriate labelling to distinguish their nature and/or use. -## Useful tools +## What is an object file? + +An object file is generally where most of the information used by overlays is stored. Its contents can include + +- Vertices (positional/normal/color data used by displaylists) +- Textures +- DisplayLists (instructions to the graphics processor on how to put together textures and vertices) +- Skeleton (The underlying structure of an actor's shape, that can be manipulated to change its "pose") +- Animations +- Texture Animations (instructions to scroll/cycle textures or change colors) + +## How we work with objects + +These objects are considered assets so they are not included in the repository directly. Instead we use the Zelda Asset Processor for Decompilation (ZAPD) to extract them from the ROM. As input, ZAPD takes an XML file that describes what and how to extract. Each object already has an autogenerated XML created in the `assets/xml/objects` directory, though they are incomplete with just autogenerated names. The goal of object decompilation is to complete these files by identifying any remaining blobs and giving everything proper names. + +## How to decomp an object + +Choose an object to decomp. As usual, some will be easier than others. For reasons explained shortly, it is much easier to decomp an object if all actors that use it are decompiled. + +### Files and folders + +Select the XML file of your selected object, which should be in `assets/xml/objects/object_name.xml`. + +The ZAPD output will go in the folder `assets/objects/object_name/`. You'll want this folder open later to check the output is correct. + +### Examining actor files + +All objects have had their XML generated in an automated way, so most constituent parts of each object are already identified, but will still need to be named and documented properly. Further, these objects usually have some blobs unreferenced by the object's own contents and hence not automatically extracted; most of the time these can be identified by looking at references in the actor which uses said object. + +### Extracting assets + +You can run `extract_assets.py` to extract the object's assets. Running it with no arguments extracts all files that have been updated since the last time it was run. You can also run it with `-s` (for single file), and give it the location of the object you want to extract relative to `assets`, i.e. + +```bash +./extract_assets.py -s objects/object_name +``` + +This should populate the folder you created earlier. ZAPD produces a C file containing the extracted object data, which will be `assets/objects/object_name/object_name.c`. Any data that you have not specified the type of, or is not referenced elsewhere in the object, is extracted as unknown blobs (usually named `unaccounted_XXXXXX`). Open the C file to see if there are any such blobs. (Some are just padding with 0s and can be ignored.) + +You now have to try and decipher these blobs using the [list of tools given below](#tools) to work out what they might be. In the case of unused parts of the object, this can be very difficult. + +### Naming + +You'll want to name everything that exists in the XML, but it helps to break it down into separate steps. After each step, extract the single asset again. + +1. First, name every piece of data that is directly accessed by another part of the repo (generally, but not always, actors). For most objects, this includes several of a skeleton, animations, some textures, and collision information. + +2. Then, name the limbs associated with each skeleton. This is usually straightforward, providing Z64Utils can show the skeleton properly. Note that when naming limbs, you should name them *from the object's perspective*, so the "left arm" is the one that is to the *object's* left. As part of this step, you should also replace the autogenerated enum values associated with each limb with an appropriate name. Another thing to note is that some limbs are considered "Root" limbs that are simply parents to other limbs and don't actually render anything themselves. In these cases, you can simply add `Root` to the limb name, e.g., `gGibdoRightLegRootLimb`. + +3. Next, name the display lists that are associated to limbs in the skeleton. Z64Utils can show you which display list is associated with a given limb. + +4. If any non-limb display lists still lack a name, try naming them now. + +5. Lastly, try to name every texture in the object. This can be a bit tricky just by looking at the textures, so it helps to see how they're used in the display lists. You can also try manipulating the textures, recompiling the game, and loading up the resulting ROM to see what your changes look like in-game. + +You'll notice that we didn't mention vertices in this list. This is because, for the most part, vertices are not used outside the object itself, and so are not required to have names. However, some actors have code that manipulates or otherwise interacts with vertices; in these cases, the vertices should be added to the XML and named. + +Current naming practice is to name each item in the xml using camelCase as usual, with the `g` prefix (for "global"), and the type of data last (`Skel`, `Anim`, `DL`, `Tex`, `TLUT`, `Vtx`, `TexAnim`, etc.), while output texture files are named in `snake_case`. TLUTs (texture look-up tables) should always have their output file end in `tlut`. For more info on which suffixes to use, check out the [ZAPD documentation on extraction XML](https://github.com/zeldaret/mm/blob/master/tools/ZAPD/docs/zapd_extraction_xml_reference.md). + +### Textures + +Since all objects have an autogenerated XML, most textures in the game already have an entry in an XML file. However, some did not get automatically detected, and textures can be especially troublesome due to the abundance of formats they can be in. Some are simple RGBA textures, while others use external palettes, and can look meaningless without. If the texture is used in a displaylist, it will tell you the format, but if not, you have to use your best judgement based on anything you know about its context. + +The order of operations is that palettes are loaded first, then the texture, and then the vertices to which it is applied. + +The first argument of `gsDPLoadTextureBlock` tells you the offset, the second the format, the third the bit depth, fourth the width and fifth the height + +The following is a list of the texture formats the Nintendo 64 supports, with their gfxdis names and ZAPD format names. + + +| Format name | Typing in `gsDPLoadTextureBlock` | "Format" in xml | +| ----------------------------------------------- | -------------------------------- | --------------- | +| 4-bit intensity (I) | `G_IM_FMT_I, G_IM_SIZ_4b` | i4 | +| 4-bit intensity with alpha (I/A) (3/1) | `G_IM_FMT_IA, G_IM_SIZ_4b` | ia4 | +| 4-bit color index (CI) | `G_IM_FMT_CI, G_IM_SIZ_4b` | ci4 | +| 8-bit I | `G_IM_FMT_I, G_IM_SIZ_8b` | i8 | +| 8-bit IA (4/4) | `G_IM_FMT_IA, G_IM_SIZ_8b` | ia8 | +| 8-bit CI | `G_IM_FMT_CI, G_IM_SIZ_8b` | ci8 | +| 16-bit red, green, blue, alpha (RGBA) (5/5/5/1) | `G_IM_FMT_RGBA, G_IM_SIZ_16b` | rgba16 | +| 16-bit IA (8/8) | `G_IM_FMT_IA, G_IM_SIZ_16b` | ia16 | +| 16-bit YUV (Luminance, Blue-Y, Red-Y) | `G_IM_FMT_YUV, G_IM_SIZ_16b` | (not used) | +| 32-bit RGBA (8/8/8/8) | `G_IM_FMT_RGBA, G_IM_SIZ_32b` | rgba32 | + +The 4-bit formats are loaded using `gDPLoadTextureBlock_4b`. The others use `gDPLoadTextureBlock`. + +For example, + +```c +gsDPLoadTextureBlock(D_06006110, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 16, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 4, 4, 0, 0), +``` + +says that there is a texture at offset `0x6110`, its Format is `rgba16`, Width is `16` and Height is `16`, so we can declare + +```XML + +``` + +See [this web page](http://n64devkit.square7.ch/tutorial/graphics/3/3_3.htm) for more information about these formats, and [gSP functions](http://n64devkit.square7.ch/n64man/gsp/gSP_INDEX.htm) and [gDP functions](http://n64devkit.square7.ch/n64man/gdp/gDP_INDEX.htm) for more about the graphics functions used. + +The `ci` formats use palettes, which are declared separately. The shape you give the palette does not matter, but to avoid overlap errors it needs to fit into a rectangle; choose the one you think looks best, and if in doubt, just do height 1 and appropriate width. + +If in doubt, look at completed objects in the repo, and if still in doubt, ask. + +## Tools We are very fortunate that several nice tools have been written recently that are excellent for documenting asset files: - [Z64Utils](https://github.com/Random06457/Z64Utils/releases), for looking at displaylists, textures they reference, the skeleton, animations, etc. - [Texture64](https://github.com/queueRAM/Texture64/releases), for looking at textures in all the common N64 formats (needed since Z64Utils cannot interpret textures not explicitly referenced in displaylists currently) +## Building and investigative modding + +Thankfully it is not necessary to do a full make from clean to check that a particular object file has been decompiled successfully. + +- With a valid xml file, run `extract_assets.py -s` on its object. +- `make` + +If you want to change a texture, for example to see precisely where it is used, the following steps ensure it will be used in the build + +- Change and save the texture. You can simply open the texture's PNG file in most image editors (e.g., Photoshop, GIMP, Paint, etc.) and edit it to your liking, though you'll need to keep the original palette in mind for palettized textures. +- Touch the object's main C file (in the same directory) +- make +- Ironically, ERROR 1 implies success (your new texture has changed the checksum). + +If you'd rather not have it tell you about the checksum, you can run `make COMPARE=0` instead. + +--- + +To revert to the original texture, you can just run `extract_assets.py -s` on the object again. + +N.B. doing this will overwrite every custom texture, as will running `make setup`. + +## Example + +An example of decompiling a particular object is given [here](object_decomp_example.md). + +## Tips and Tricks + +### Fixing improper-looking textures + +For CI4 and CI8 textures, you might see improper-looking textures like so: + +![An improper-looking CI8 texture](images/broken_texture.png) + +The reason this happens is because ZAPD couldn't determine the TLUT for the texture, so it couldn't use the proper palette. To fix this, you can supply a `TlutOffset` to the texture like so: +```xml + +``` + +### Understanding texture animations + +Texture animations are new to Majora's Mask, and they can be pretty tricky to understand. Luckily, there's some extensive documentation on how they're structured [here](https://github.com/zeldaret/mm/blob/master/tools/ZAPD/ZAPD/ZTextureAnimation.cpp). One useful thing to remember is that empty texture animations take the form of `00 00 00 06 00 00 00 00`. The process that automatically generated all the object XMLs sometimes failed to recognize this as an empty texture animation, so it puts it in various blobs or fails to account for it at all. + Next: [The merging process](merging.md) \ No newline at end of file diff --git a/docs/tutorial/object_decomp_example.md b/docs/tutorial/object_decomp_example.md new file mode 100644 index 000000000..798167e68 --- /dev/null +++ b/docs/tutorial/object_decomp_example.md @@ -0,0 +1,258 @@ +# Object Decompilation Example + +- Previous: [Object Decompilation](object_decomp.md) + +Let's take a look at `object_dns`, which is a pretty typical NPC object. It's used by one actor: `ovl_En_Dns`. + +## Step 1: Naming the skeleton and limbs + +We already went through the steps of opening an object file in Z64Utils in the [documenting step](documenting.md#z64utils), but we'll do it in more detail here. First, search for the object file, then right-click and select "Open in Object Analyzer". It will ask you to choose a segment: this is the segment that the file is put on, and allows Z64Utils to resolve the segmented addresses it references into symbols. The json already knows it should be segment 6, so just click OK. + +![Opening object_dns in Z64Utils](images/z64utils_open_dns.png) + +In the resulting window, go to "Analysis -> Find Dlists" and press OK (the defaults are usually fine). This will only find display lists, so to find everything else in the obect, do "Analysis -> Analyze Dlists". We're looking for the skeleton, so scroll down to the SkeletonHeader, right-click it, and select "Open in Skeleton Viewer": + +![Finding object_dns's SkeletonHeader in Z64Utils](images/z64utils_dns_skeletonheader.png) + +When you open the Skeleton Viewer, you'll see a list of animations off to the side. Selecting one of them will display an error that says something like `RENDER ERROR AT 0x06001A98! (Could not read 0x80 bytes at address 08000000)`. This is because one of the display lists in the skeleton is expecting something to be set at segment 8. From the actor, we know that it's expecting the eye textures to be loaded into segment 8 like so: +```c +static TexturePtr D_8092DE1C[] = { &D_060028E8, &D_06002968, &D_060029E8, &D_06002968 }; +[...] +gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); +``` + +Let's set segment 8 to be one of the eye textures listed here. Click on "Segments", then for segment 08, click "Edit" and select "Address" as the source. Input "060028E8" as the address, then hit OK. This should result in the window looking as follows: + +![Setting segment 8 to one of the eye textures in Z64Utils](images/z64utils_set_segment_8.png) + +Now that we've gotten around the error, we can see what each limb in the skeleton corresponds to by clicking on it in the Hierarchy. Clicking on any given limb will highlight what part of the model it represents in red. In the below example, this limb is clearly the head: + +![Showing the head limb in Z64Utils](images/z64utils_dns_head_limb.png) + +Note that some limbs don't actually render anything, so sometimes clicking on a limb will not turn anything red; this may indicate a "Root" limb that has no associated display list, or it may indicate something like an eye limb that doesn't have the right textures loaded to display anything in Z64Utils. It may be useful to skip ahead to [Step #5](#step-5-naming-limb-display-lists) to learn how to check if the limb has a display list. If it doesn't have a display list, then it's a "Root" limb that will never be highlighted. + +We can now start naming the skeleton and individual limbs. Since we know this particular skeleton is the King's Chamber Deku Guard, we can name the skeleton `gKingsChamberDekuGuardSkel`. For the LimbNone name, we can call it something like `KINGS_CHAMBER_DEKU_GUARD_LIMB_NONE`, and we can name the LimbMax similarly. For the EnumName, we can name it `KingsChamberDekuGuardLimbs`. For each individual limb, we can name them based on what we see in Z64Utils; just make sure to update both the Name and the EnumName. After naming everything, we have something that looks like this: +```xml + + + + + + + + + + + + + +``` + +Now we can run `./extract_assets.py -s objects/object_dns` to extract the object again, this time with our new names. What can we do with this? Quite a bit actually. In `z_en_dns.h`, we can add this to the top of the file to start using these new names in our code: +```c +#include "objects/object_dns/object_dns.h" +``` + +Now, we can redefine the `jointTable` and `morphTable` in terms of the limb enum we defined before, like so: +```c +/* 0x22A */ Vec3s jointTable[KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX]; +/* 0x278 */ Vec3s morphTable[KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX]; +``` + +We can also use our new skeleton name and limb enum when initialization the skeleton like so: +```c +SkelAnime_Init(globalCtx, &this->skelAnime, &gKingsChamberDekuGuardSkel, NULL, this->jointTable, this->morphTable, KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX); +``` + +Lastly, we can use our limb enum in `EnDns_PostLimbDraw`. Where the code originally had: +```c +if (limbIndex == 2) { + [...] +} +``` + +We can instead write: +```c +if (limbIndex == KINGS_CHAMBER_DEKU_GUARD_LIMB_HEAD) { + [...] +} +``` + +## Step 2: Naming the animations + +Now that we have the skeleton figured out, it's time to name all the animations. In the Skeleton Viewer, you can hit the "play" button on any animation to see what it looks like. Note that some objects have multiple skeletons, and selecting an animation that is associated with a different skeleton than the one you're looking at can cause odd behavior. Try to give each animation a descriptive name based on what it looks like. If you're struggling; +- Try viewing the animation in game. In what contexts does this animation play? +- Try analyzing the code for the actor to see when the animation is used. Is this animation ever referenced? +- If you're still really struggling, Majora's Mask 3D contains the original animation names for the majority of animations in the game. These original names can help you figure out what the developers were originally intending. Explaining how to find these animations in MM3D is outside of the scope of this document, so just ask in Discord if you want to try this. + +After naming the animations, the end result will look something like this: +```xml + + + + + + +[...] + + +``` + +Once again, we can run `./extract_assets.py -s objects/object_dns` to extract the object, and we can update the animation names in `z_en_dns.c` to use our new names like so: +```c +static AnimationInfoS sAnimations[] = { + { &gKingsChamberDekuGuardIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKingsChamberDekuGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKingsChamberDekuGuardSurpriseStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardSurpriseLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardRunStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardRunLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardDanceAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardFlipAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, +}; +``` + +## Step 3: Identifying the blob + +In the XML, you may notice undefined blobs like this: +```xml + +``` + +You might already have an idea as to what this is based on what you've seen before. Recall that the eye textures are referenced in the actor's code like this: +```c +static TexturePtr D_8092DE1C[] = { &D_060028E8, &D_06002968, &D_060029E8, &D_06002968 }; +``` + +Do you notice how the "28E8" in `D_060028E8` also appears as the Offset in that blob? That's because the blob is just the eye textures; the process for automatically creating the XML wasn't able to figure it out on its own, so we'll need to do it ourselves. But how should we define these textures in the XML? Recall that the eye textures were loaded into segment 8; let's take a look in `object_dns.c` and see if we can find something that uses this segment. This display list has the answer: +```c +Gfx object_dns_DL_001A50[] = { + [...] + gsDPLoadTextureBlock(0x08000000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 8, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | + G_TX_CLAMP, 3, 3, G_TX_NOLOD, G_TX_NOLOD), + [...] +}; +``` + +Using `0x08000000` with `gsDPLoadTextureBlock` signals that this display list is expecting a texture in segment 8. What kind of texture is it expecting? We can look at the arguments after the `0x08000000`. It's looking for an RBGA16 texture with dimensions of 8x8, so we can define these textures in the XML like so: +```xml + + + +``` + +Now, we just have to name them. In [Step #1](#step-1-naming-the-skeleton-and-limbs), we set segment 8 to one of the eye textures; we can use that same technique with the other two eye textures to see what they are. Like most NPCs, these various eye textures are used for handling blinking, so we can name them based on how open the eye is: +```xml + + + +``` + +Like with previous steps, we can run `./extract_assets.py -s objects/object_dns` and then update `z_en_dns.c` with our new names: +```c +static TexturePtr sEyeTextures[] = { + gKingsChamberDekuGuardEyeOpenTex, + gKingsChamberDekuGuardEyeHalfTex, + gKingsChamberDekuGuardEyeClosedTex, + gKingsChamberDekuGuardEyeHalfTex, +}; +``` + +Note that this step might be tricky to do if multiple things in the actor use the same segment. It's okay to wait to do this until you've named all the display lists in the actor, since that will make it easier to find the display list associated with a given texture. + +## Step #4: Naming anything else in the actor + +For some actors, there may be a few other things left to name that are directly referenced in the actor's code. In our case, there is one display list that we still need to name: +```c +gSPDisplayList(POLY_OPA_DISP++, &D_06002C48); +``` + +In Z64Utils, scroll to find this display list, then right-click and select "Open in Dlist Viewer": + +![Opening dlist_00002C48 in Z64Utils](images/z64utils_dns_display_list.png) + +We can see this is the guard's Deku Flower: + +![Showing the guard's Deku Flower in Z64Utils](images/z64utils_dns_deku_flower.png) + +We can name the display list as such in the XML: +```xml + +``` + +Then, like all steps before, we can run `./extract_assets.py -s objects/object_dns` and then update `z_en_dns.c` with our new name: +```c +gSPDisplayList(POLY_OPA_DISP++, gKingsChamberDekuGuardDekuFlower); +``` + +## Step #5: Naming limb display lists + +Now that we've named everything that's used externally by the actor, we just need to clean up the rest of the unnamed stuff in the XML. Let's start by naming the display lists for each limb. There are two ways you can determine which display list is associated with a given limb. One way is to click on the limb in Z64Utils; it will tell you what display list is used for that limb: + +![Showing the head limb's display list in Z64Utils](images/z64utils_dns_limb_dlist.png) + +Another way is to simply check `object_dns.c`. Each limb lists its own display list like this: +```c +StandardLimb gKingsChamberDekuGuardHeadLimb = { + { 0, 1300, 0 }, KINGS_CHAMBER_DEKU_GUARD_LIMB_STALK - 1, KINGS_CHAMBER_DEKU_GUARD_LIMB_LEFT_FOOT - 1, + object_dns_DL_0018B8 +}; +``` + +Either way you go about it, you should be able to name all the limb display lists like so: +```xml + + + + + + + + + + + + +``` + +Run `./extract_assets.py -s objects/object_dns` once again, since it will help in the next step to have all of our display lists named. + +### Step #6: Naming remaining textures + +With every display list named, it's now a lot easier to name the remaining textures. In the `assets/objects/object_dns/` folder, you can see all the textures in the object as various PNG files. For some of the textures, just looking at them will give you a good idea as to what they should be named. For other textures, it may help to see how the texture is used in the object's display lists. Let's take a look at `object_dns_Tex_002868`, which is only used in one display list: +```c +Gfx gKingsChamberDekuGuardSnoutDL[] = { + [...] + gsDPLoadTextureBlock(object_dns_Tex_002868, G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 8, 0, G_TX_MIRROR | G_TX_CLAMP, + G_TX_MIRROR | G_TX_CLAMP, 3, 3, G_TX_NOLOD, G_TX_NOLOD), + [...] +}; +``` + +Since `tex_002868.rgba16.png` looks like the inside of the Deku Guard's mouth, and it's *only* used in the snout display list, you can probably name this something like `gKingsChamberDekuGuardMouthTex`. But rather than guessing, we can confirm it by editing the texture ourselves and then viewing it in-game. Using an image editor, let's change `tex_002868.rgba16.png` to this: + +![Our custom mouth texture](images/dns_custom_texture.png) + +Now, rebuild the game using [the steps described here](object_decomp.md#building-and-investigative-modding) and look at the guard in-game. You should see something like this: + +![Our custom mouth texture being shown in-game](images/custom_texture_in_game.png) + +This confirms our suspicion that this is indeed the mouth texture, so we can name it as such. We can use similar strategies to name all the other textures like so: +```xml + + + +``` + +### Step #7: Finishing up + +If you have any other unnamed assets, now's the time to identify them. Otherwise, finish up the file by putting a comment at the top above the `` node: +```xml + + + +``` + +And we're done! Hopefully, you found this example helpful when decompiling your own objects. \ No newline at end of file diff --git a/docs/tutorial/other_functions.md b/docs/tutorial/other_functions.md index 870b490ea..b0350a838 100644 --- a/docs/tutorial/other_functions.md +++ b/docs/tutorial/other_functions.md @@ -1,7 +1,7 @@ # The rest of the functions in the actor -Up: [Contents](contents.md) -Previous: [Beginning decompilation: the Init function and the Actor struct](beginning_decomp.md) +- Up: [Contents](contents.md) +- Previous: [Beginning decompilation: the Init function and the Actor struct](beginning_decomp.md) ## Now what? diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c index 378db036d..ba01959bc 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -5,9 +5,8 @@ */ #include "z_en_dns.h" -#include "objects/object_dns/object_dns.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnDns*)thisx) @@ -20,6 +19,20 @@ void func_8092D330(EnDns* this, GlobalContext* globalCtx); void EnDns_DoNothing(EnDns* this, GlobalContext* globalCtx); void func_8092D4D8(EnDns* this, GlobalContext* globalCtx); +typedef enum { + /* 0 */ EN_DNS_ANIMATION_IDLE_1, + /* 1 */ EN_DNS_ANIMATION_IDLE_2, + /* 2 */ EN_DNS_ANIMATION_WALK_1, + /* 3 */ EN_DNS_ANIMATION_WALK_2, + /* 4 */ EN_DNS_ANIMATION_SURPRISE_START, + /* 5 */ EN_DNS_ANIMATION_SURPRISE_LOOP, + /* 6 */ EN_DNS_ANIMATION_RUN_START, + /* 7 */ EN_DNS_ANIMATION_RUN_LOOP, + /* 8 */ EN_DNS_ANIMATION_DANCE, + /* 9 */ EN_DNS_ANIMATION_FLIP, + /* 10 */ EN_DNS_ANIMATION_MAX, +} EnDnsAnimationIndex; + static s32 D_8092DCB0[] = { 0x00172000, 0x050E082F, 0x0C100E08, 0x200C1000, 0x00172000, 0x050E0830, 0x0C100E08, 0x210C1000, 0x00172000, 0x050E0831, 0x0C100E08, 0x220C1000, 0x00172000, 0x050E0832, 0x0C100E08, 0x230C1000, @@ -61,22 +74,23 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; static AnimationInfoS sAnimations[] = { - { &object_dns_Anim_003310, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dns_Anim_003310, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dns_Anim_0034EC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dns_Anim_0034EC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dns_Anim_0008F4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dns_Anim_000BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dns_Anim_000D58, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dns_Anim_000FEC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dns_Anim_0002A8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dns_Anim_000734, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKingsChamberDekuGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKingsChamberDekuGuardSurpriseStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardSurpriseLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardRunStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardRunLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardDanceAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardFlipAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; void func_8092C5C0(EnDns* this) { s32 pad; - if (((this->unk_2F8 == 2) || (this->unk_2F8 == 3) || (this->unk_2F8 == 6) || (this->unk_2F8 == 7)) && + if (((this->animationIndex == EN_DNS_ANIMATION_WALK_1) || (this->animationIndex == EN_DNS_ANIMATION_WALK_2) || + (this->animationIndex == EN_DNS_ANIMATION_RUN_START) || (this->animationIndex == EN_DNS_ANIMATION_RUN_LOOP)) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 3.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); } @@ -87,28 +101,30 @@ s32 func_8092C63C(EnDns* this, s32 arg1) { s32 ret = false; switch (arg1) { - case 0: - case 1: - if ((this->unk_2F8 != 0) && (this->unk_2F8 != 1)) { + case EN_DNS_ANIMATION_IDLE_1: + case EN_DNS_ANIMATION_IDLE_2: + if ((this->animationIndex != EN_DNS_ANIMATION_IDLE_1) && + (this->animationIndex != EN_DNS_ANIMATION_IDLE_2)) { phi_v1 = true; } break; - case 2: - case 3: - if ((this->unk_2F8 != 2) && (this->unk_2F8 != 3)) { + case EN_DNS_ANIMATION_WALK_1: + case EN_DNS_ANIMATION_WALK_2: + if ((this->animationIndex != EN_DNS_ANIMATION_WALK_1) && + (this->animationIndex != EN_DNS_ANIMATION_WALK_2)) { phi_v1 = true; } break; default: - if (this->unk_2F8 != arg1) { + if (this->animationIndex != arg1) { phi_v1 = true; } } if (phi_v1) { - this->unk_2F8 = arg1; + this->animationIndex = arg1; ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); } @@ -154,11 +170,11 @@ void func_8092C86C(EnDns* this, GlobalContext* globalCtx) { } void func_8092C934(EnDns* this) { - if ((this->unk_2C6 & 0x40) && (DECR(this->unk_2DE) == 0)) { - this->unk_2E0++; - if (this->unk_2E0 >= 4) { - this->unk_2DE = Rand_S16Offset(30, 30); - this->unk_2E0 = 0; + if ((this->unk_2C6 & 0x40) && (DECR(this->blinkTimer) == 0)) { + this->eyeIndex++; + if (this->eyeIndex >= 4) { + this->blinkTimer = Rand_S16Offset(30, 30); + this->eyeIndex = 0; } } } @@ -220,7 +236,7 @@ s32 func_8092CAD0(EnDns* this, GlobalContext* globalCtx) { this->unk_2F0 = 0.0f; if (this->unk_2D2 != 0) { this->unk_2F0 = this->skelAnime.curFrame; - func_8092C63C(this, 2); + func_8092C63C(this, EN_DNS_ANIMATION_WALK_1); } this->unk_2DA = this->actor.world.rot.y; } @@ -238,14 +254,14 @@ s32 func_8092CB98(EnDns* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state != 0) { if (!(this->unk_2C6 & 0x80)) { this->unk_2C8 = func_8092CA74(this); - this->actor.flags &= ~0x1; + this->actor.flags &= ~ACTOR_FLAG_1; func_8013AED4(&this->unk_2C6, 0, 7); this->unk_2C6 |= 0x80; this->unk_1D8 = 0xFF; } phi_v1 = 1; } else if (this->unk_2C6 & 0x80) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; func_8013AED4(&this->unk_2C6, 3, 7); this->unk_2C6 &= ~0x80; } @@ -290,7 +306,7 @@ s32 func_8092CCEC(EnDns* this, GlobalContext* globalCtx) { } s32 func_8092CE38(EnDns* this) { - static s32 D_8092DE00[] = { 8, 8, 9 }; + static s32 D_8092DE00[] = { EN_DNS_ANIMATION_DANCE, EN_DNS_ANIMATION_DANCE, EN_DNS_ANIMATION_FLIP }; s16 frame; s32 pad; Vec3f sp2C; @@ -369,7 +385,7 @@ void func_8092D108(EnDns* this, GlobalContext* globalCtx) { Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_dns_DL_002C48); + gSPDisplayList(POLY_OPA_DISP++, gKingsChamberDekuGuardDekuFlower); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -390,11 +406,11 @@ void func_8092D1B8(EnDns* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_FOUND); gSaveContext.eventInf[1] |= 0x20; this->unk_2F4 = func_8092CCEC; - func_8092C63C(this, 2); + func_8092C63C(this, EN_DNS_ANIMATION_WALK_1); this->actionFunc = EnDns_DoNothing; } else if (gSaveContext.eventInf[1] & 0x40) { func_8092CCEC(this, globalCtx); - func_8092C63C(this, 2); + func_8092C63C(this, EN_DNS_ANIMATION_WALK_1); this->actionFunc = func_8092D330; } Math_ApproachS(&this->actor.shape.rot.y, sp22, 3, 0x2AA8); @@ -436,7 +452,7 @@ void func_8092D4D8(EnDns* this, GlobalContext* globalCtx) { if (ENDNS_GET_4000(&this->actor) && (this->unk_2D2 == 0)) { if (func_8092CE38(this)) { - func_8092C63C(this, 2); + func_8092C63C(this, EN_DNS_ANIMATION_WALK_1); } } else if (func_8010BF58(&this->actor, globalCtx, this->unk_1E0, this->unk_2F4, &this->unk_1DC)) { func_8013AED4(&this->unk_2C6, 3, 7); @@ -445,7 +461,7 @@ void func_8092D4D8(EnDns* this, GlobalContext* globalCtx) { if (!(gSaveContext.eventInf[1] & 0x20)) { this->skelAnime.curFrame = this->unk_2F0; this->actor.world.rot.y = this->unk_2DA; - func_8092C63C(this, 8); + func_8092C63C(this, EN_DNS_ANIMATION_DANCE); } this->unk_2CC = 0; this->unk_2CE = 0; @@ -458,7 +474,12 @@ void func_8092D4D8(EnDns* this, GlobalContext* globalCtx) { } void func_8092D5E8(EnDns* this, GlobalContext* globalCtx) { - static s32 D_8092DE0C[] = { 0, 0, 4, 6 }; + static s32 D_8092DE0C[] = { + EN_DNS_ANIMATION_IDLE_1, + EN_DNS_ANIMATION_IDLE_1, + EN_DNS_ANIMATION_SURPRISE_START, + EN_DNS_ANIMATION_RUN_START, + }; u32 temp_v0; u32 temp_v1; @@ -470,9 +491,10 @@ void func_8092D5E8(EnDns* this, GlobalContext* globalCtx) { this->unk_1D8 = temp_v1; } - if (((this->unk_2F8 == 4) || (this->unk_2F8 == 6)) && + if (((this->animationIndex == EN_DNS_ANIMATION_SURPRISE_START) || + (this->animationIndex == EN_DNS_ANIMATION_RUN_START)) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8092C63C(this, this->unk_2F8 + 1); + func_8092C63C(this, this->animationIndex + 1); } func_800EDF24(&this->actor, globalCtx, temp_v0); @@ -488,9 +510,10 @@ void EnDns_Init(Actor* thisx, GlobalContext* globalCtx) { } ActorShape_Init(&this->actor.shape, 0.0f, NULL, 18.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dns_Skel_002DD8, NULL, this->jointTable, this->morphTable, 13); - this->unk_2F8 = -1; - func_8092C63C(this, 2); + SkelAnime_Init(globalCtx, &this->skelAnime, &gKingsChamberDekuGuardSkel, NULL, this->jointTable, this->morphTable, + KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX); + this->animationIndex = -1; + func_8092C63C(this, EN_DNS_ANIMATION_WALK_1); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); Actor_SetScale(&this->actor, 0.01f); @@ -590,7 +613,7 @@ void EnDns_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } } - if (limbIndex == 2) { + if (limbIndex == KINGS_CHAMBER_DEKU_GUARD_LIMB_HEAD) { func_8092D954(this->unk_2CC, this->unk_2CE + this->actor.shape.rot.y, &this->unk_218, &this->unk_224, phi_v1, phi_v0); Matrix_InsertTranslation(this->unk_218.x, this->unk_218.y, this->unk_218.z, MTXMODE_NEW); @@ -609,15 +632,19 @@ void EnDns_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } void EnDns_Draw(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr D_8092DE1C[] = { object_dns_Tex_0028E8, object_dns_Tex_002968, object_dns_Tex_0029E8, - object_dns_Tex_002968 }; + static TexturePtr sEyeTextures[] = { + gKingsChamberDekuGuardEyeOpenTex, + gKingsChamberDekuGuardEyeHalfTex, + gKingsChamberDekuGuardEyeClosedTex, + gKingsChamberDekuGuardEyeHalfTex, + }; EnDns* this = THIS; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_8092DE1C[this->unk_2E0])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); gDPPipeSync(POLY_OPA_DISP++); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDns_OverrideLimbDraw, diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.h b/src/overlays/actors/ovl_En_Dns/z_en_dns.h index 598dfff3b..257717502 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.h +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.h @@ -2,6 +2,7 @@ #define Z_EN_DNS_H #include "global.h" +#include "objects/object_dns/object_dns.h" struct EnDns; @@ -31,8 +32,8 @@ typedef struct EnDns { /* 0x1E4 */ Gfx* unk_1E4[13]; /* 0x218 */ Vec3f unk_218; /* 0x224 */ Vec3s unk_224; - /* 0x22A */ Vec3s jointTable[13]; - /* 0x278 */ Vec3s morphTable[13]; + /* 0x22A */ Vec3s jointTable[KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX]; + /* 0x278 */ Vec3s morphTable[KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX]; /* 0x2C6 */ u16 unk_2C6; /* 0x2C8 */ u16 unk_2C8; /* 0x2CA */ UNK_TYPE1 unk_2CA[0x2]; @@ -45,14 +46,14 @@ typedef struct EnDns { /* 0x2D8 */ s16 unk_2D8; /* 0x2DA */ s16 unk_2DA; /* 0x2DC */ s16 unk_2DC; - /* 0x2DE */ s16 unk_2DE; - /* 0x2E0 */ s16 unk_2E0; + /* 0x2DE */ s16 blinkTimer; + /* 0x2E0 */ s16 eyeIndex; /* 0x2E4 */ f32 unk_2E4; /* 0x2E8 */ UNK_TYPE1 unk_2E8[0x4]; /* 0x2EC */ f32 unk_2EC; /* 0x2F0 */ f32 unk_2F0; /* 0x2F4 */ EnDnsFunc unk_2F4; - /* 0x2F8 */ s32 unk_2F8; + /* 0x2F8 */ s32 animationIndex; /* 0x2FC */ s32 unk_2FC; } EnDns; // size = 0x300 From 3f15c0017ab7a33673f3ba9a9b2d731f86bcf659 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 19 Feb 2022 21:36:16 +0000 Subject: [PATCH 040/257] En_Zoraegg (#630) * En_Zoraegg * Revert bgCheckFlags * roomInf Co-authored-by: Anghelo Carvajal --- assets/xml/objects/object_zoraegg.xml | 5 +- include/functions.h | 2 +- spec | 3 +- .../actors/ovl_En_Zoraegg/z_en_zoraegg.c | 862 +++++++++++++++++- .../actors/ovl_En_Zoraegg/z_en_zoraegg.h | 48 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 11 - 7 files changed, 870 insertions(+), 65 deletions(-) diff --git a/assets/xml/objects/object_zoraegg.xml b/assets/xml/objects/object_zoraegg.xml index c527fe618..0835e2698 100644 --- a/assets/xml/objects/object_zoraegg.xml +++ b/assets/xml/objects/object_zoraegg.xml @@ -11,10 +11,11 @@ - + - + + diff --git a/include/functions.h b/include/functions.h index 3a224a57d..45872f8e6 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2023,7 +2023,7 @@ void func_801229A0(GlobalContext* globalCtx, Player* player); void func_80122F28(Player* player, GlobalContext* globalCtx, Actor* actor); s32 func_80122F9C(GlobalContext* globalCtx); s32 func_80122FCC(GlobalContext* globalCtx); -// void func_8012300C(void); +void func_8012300C(GlobalContext* globalCtx, s32 arg1); void func_8012301C(s32 iParm1, GlobalContext* globalCtx); void func_80123140(GlobalContext* globalCtx, Player* param_2); u32 func_80123358(GlobalContext* globalCtx, Player* player); diff --git a/spec b/spec index 2935b24cb..c27254528 100644 --- a/spec +++ b/spec @@ -4015,8 +4015,7 @@ beginseg name "ovl_En_Zoraegg" compress include "build/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.o" - include "build/data/ovl_En_Zoraegg/ovl_En_Zoraegg.data.o" - include "build/data/ovl_En_Zoraegg/ovl_En_Zoraegg.reloc.o" + include "build/src/overlays/actors/ovl_En_Zoraegg/ovl_En_Zoraegg_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c index d5dc7fda0..7d962dcdc 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c @@ -5,8 +5,10 @@ */ #include "z_en_zoraegg.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_zoraegg/object_zoraegg.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnZoraegg*)thisx) @@ -15,7 +17,27 @@ void EnZoraegg_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnZoraegg_Update(Actor* thisx, GlobalContext* globalCtx); void EnZoraegg_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +s32 func_80B319A8(GlobalContext* globalCtx); +void func_80B32084(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32094(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B320E0(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B321D0(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32228(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B322BC(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32390(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B324B0(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32644(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B326F4(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32820(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32928(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32A88(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32B10(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32B3C(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32B70(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32BB8(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32C34(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32D08(EnZoraegg* this, GlobalContext* globalCtx); + const ActorInit En_Zoraegg_InitVars = { ACTOR_EN_ZORAEGG, ACTORCAT_ITEMACTION, @@ -28,86 +50,834 @@ const ActorInit En_Zoraegg_InitVars = { (ActorFunc)EnZoraegg_Draw, }; -#endif +void func_80B31590(EnZoraegg* this) { + this->actor.shape.yOffset = 0.0f; -extern UNK_TYPE D_060005D4; -extern UNK_TYPE D_06004D20; -extern UNK_TYPE D_06004FE4; -extern UNK_TYPE D_06005098; -extern UNK_TYPE D_06005250; + if (this->actor.home.rot.x == 0) { + this->actor.scale.x = 0.4f; + } else { + this->actor.scale.x = this->actor.home.rot.x * 0.04f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31590.s") + if (this->actor.home.rot.z == 0) { + this->actor.scale.z = 0.4f; + } else { + this->actor.scale.z = this->actor.home.rot.z * 0.04f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/EnZoraegg_Init.s") + this->actor.shape.rot.z = 0; + this->actor.scale.y = 0.4f; + this->actor.draw = NULL; + this->actor.shape.rot.y = this->actor.shape.rot.z; + this->actor.shape.rot.x = this->actor.shape.rot.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/EnZoraegg_Destroy.s") +void EnZoraegg_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZoraegg* this = THIS; + u16 sp40[] = { 0x01C9, 0x01CA, 0x01CB, 0x01CC, 0x01CD, 0x01CE, 0x01D0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B319A8.s") + Actor_SetScale(&this->actor, 0.006f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_zoraegg_Skel_004C90, &object_zoraegg_Anim_005098, + this->jointTable, this->morphTable, 7); + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_005098); + ActorShape_Init(&this->actor.shape, 1100.0f, NULL, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B319D0.s") + this->actionFunc = func_80B32084; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31A34.s") + this->unk_1ED = 255; + this->unk_1EC = 0; + this->unk_1EA = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31C40.s") + this->unk_1E0 = 1.0f; + this->unk_1E4 = 0.0f; + this->actor.velocity.y = -10.0f; + this->actor.terminalVelocity = -10.0f; + this->actor.gravity = -5.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31CB4.s") + switch (ENZORAEGG_GET_1F(&this->actor)) { + case ENZORAEGG_1F_0: + if (Flags_GetSwitch(globalCtx, ENZORAEGG_GET_FE00(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31D14.s") + case ENZORAEGG_1F_17: + if (func_80B319A8(globalCtx) >= 7) { + Actor_MarkForDeath(&this->actor); + this->actor.home.rot.z = 1; + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31D64.s") + case ENZORAEGG_1F_3: + case ENZORAEGG_1F_4: + case ENZORAEGG_1F_5: + case ENZORAEGG_1F_6: + case ENZORAEGG_1F_7: + case ENZORAEGG_1F_8: + case ENZORAEGG_1F_9: + if (gSaveContext.weekEventReg[19] & 0x40) { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31E00.s") + case ENZORAEGG_1F_10: + case ENZORAEGG_1F_11: + case ENZORAEGG_1F_12: + case ENZORAEGG_1F_13: + case ENZORAEGG_1F_14: + case ENZORAEGG_1F_15: + case ENZORAEGG_1F_16: + if (!(gSaveContext.weekEventReg[19] & 0x40)) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32084.s") + switch (ENZORAEGG_GET_1F(&this->actor)) { + case ENZORAEGG_1F_0: + this->actionFunc = func_80B320E0; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.targetMode = 3; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32094.s") + case ENZORAEGG_1F_1: + this->actionFunc = func_80B322BC; + func_80B31590(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B320E0.s") + case ENZORAEGG_1F_2: + this->actionFunc = func_80B32390; + func_80B31590(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B321D0.s") + case ENZORAEGG_1F_3: + case ENZORAEGG_1F_4: + case ENZORAEGG_1F_5: + case ENZORAEGG_1F_6: + case ENZORAEGG_1F_7: + case ENZORAEGG_1F_8: + case ENZORAEGG_1F_9: + this->unk_1F0 = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_3]; + Animation_PlayOnce(&this->skelAnime, &object_zoraegg_Anim_001E08); + this->unk_1EC = 1; + this->unk_1EE = 0; + this->unk_1EF = 0; + this->actionFunc = func_80B32B10; + if (((ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_3) >= func_80B319A8(globalCtx)) { + this->actionFunc = func_80B32B3C; + this->actor.draw = NULL; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32228.s") + case ENZORAEGG_1F_10: + case ENZORAEGG_1F_11: + case ENZORAEGG_1F_12: + case ENZORAEGG_1F_13: + case ENZORAEGG_1F_14: + case ENZORAEGG_1F_15: + case ENZORAEGG_1F_16: + this->unk_1F0 = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_10]; + this->unk_1EC = 2; + this->actionFunc = func_80B324B0; + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004FE4); + this->unk_1EE = 0; + this->unk_1ED = 0; + this->unk_1EA |= 3; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B322BC.s") + case ENZORAEGG_1F_17: + Actor_SetScale(&this->actor, 0.0006f); + this->actionFunc = func_80B32D08; + this->actor.world.pos.y -= this->actor.shape.yOffset * this->actor.scale.y; + this->actor.shape.rot.x = 0; + this->actor.velocity.y = 0.0f; + this->actor.terminalVelocity = -10.0f; + this->actor.gravity = -1.0f; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32390.s") +void EnZoraegg_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B324B0.s") +s32 func_80B319A8(GlobalContext* globalCtx) { + return gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 7; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32644.s") +void func_80B319D0(GlobalContext* globalCtx, s32 arg1) { + if ((arg1 < 8) && (arg1 >= 0)) { + gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~7; + gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= arg1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B326F4.s") +void func_80B31A34(EnZoraegg* this) { + s32 curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32820.s") + if (this->unk_1EA & 1) { + this->unk_1EE = this->unk_1EF = 100; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32928.s") + curFrame = this->skelAnime.curFrame; + if (curFrame < 6) { + this->unk_1EE = 0; + this->unk_1EF = 0; + } else if (curFrame < 93) { + this->unk_1EE = Math_SinS((curFrame * 0xBC) - 0x468) * 100.0f; + if (curFrame >= 89) { + this->unk_1EF = Math_SinS((curFrame * 0x1000) - (0x59 * 0x1000)) * 100.0f; + } else { + this->unk_1EF = 0; + } + } else { + this->unk_1EE = this->unk_1EF = 100; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32A88.s") +void func_80B31C40(EnZoraegg* this, GlobalContext* globalCtx) { + Actor_MoveWithGravity(&this->actor); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); + this->actor.focus.pos.y += 10.0f; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32B10.s") +Actor* func_80B31CB4(GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32B3C.s") + while (actor != NULL) { + if ((actor->id == ACTOR_EN_ZORAEGG) && (ENZORAEGG_GET_1F(actor) == ENZORAEGG_1F_17) && + (actor->home.rot.z == 0)) { + actor->home.rot.z = 1; + return actor; + } + actor = actor->next; + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32B70.s") +Actor* func_80B31D14(GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32BB8.s") + while (actor != NULL) { + if ((actor->id == ACTOR_EN_ZORAEGG) && (ENZORAEGG_GET_1F(actor) == ENZORAEGG_1F_3)) { + return actor; + } + actor = actor->next; + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32C34.s") +void func_80B31D64(EnZoraegg* this, GlobalContext* globalCtx, s32 arg2, f32 arg3) { + Vec3f sp24 = this->actor.world.pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32D08.s") + sp24.y += arg3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/EnZoraegg_Update.s") + if ((globalCtx->gameplayFrames & arg2) == 0) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 0.0f, 10.0f, 0.13f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32F04.s") +void func_80B31E00(EnZoraegg* this) { + f32 sp20[] = { + 1.0f, + 1.075f, + 1.15f, + 1.075f, + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B331C8.s") + if (this->unk_1E8 < 112) { + if (this->unk_1E8 > 10) { + this->unk_1ED = (s32)((112.0f - this->unk_1E8) * 2.5f) & 0xFF; + } + } else { + this->unk_1ED = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B3336C.s") + if (this->unk_1E8 < 10) { + this->unk_1E0 = sp20[this->unk_1E8 & 3]; + } else if (this->unk_1E8 < 22) { + this->unk_1E0 = (Math_SinS((this->unk_1E8 - 10.0f) * (4096.0f / 3)) * 0.8f) + 1.0f; + } else if (this->unk_1E8 < 26) { + this->unk_1E0 = (Math_CosS((this->unk_1E8 - 22.0f) * 4096.0f) * 0.8f) + 1.0f; + } else if (this->unk_1E8 < 32) { + this->unk_1E0 = sp20[(this->unk_1E8 - 1) & 3]; + } else if (this->unk_1E8 < 47) { + this->unk_1E0 = 1.0f; + } else if (this->unk_1E8 < 53) { + this->unk_1E0 = sp20[(this->unk_1E8 - 2) & 3]; + } else if (this->unk_1E8 < 74) { + this->unk_1E0 = 1.0f - ((this->unk_1E8 - 53.0f) * (1.0f / 105)); + } else if (this->unk_1E8 < 112) { + this->unk_1E0 = (this->unk_1E0 * 0.9f) + 0.15f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B333DC.s") + if ((this->unk_1E8 == 111) || (this->unk_1E8 == 32)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_BORN); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B33480.s") +void func_80B32084(EnZoraegg* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B33818.s") +void func_80B32094(EnZoraegg* this, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 2) { + this->actionFunc = func_80B320E0; + } + func_80B31C40(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/EnZoraegg_Draw.s") +void func_80B320E0(EnZoraegg* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + Flags_SetSwitch(globalCtx, ENZORAEGG_GET_FE00(&this->actor)); + Actor_MarkForDeath(&this->actor); + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80B32094; + func_801518B0(globalCtx, 0x24B, &this->actor); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_MAX, 80.0f, 60.0f); + if (this->actor.isTargeted) { + func_800B8614(&this->actor, globalCtx, 110.0f); + } + } + + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.targetMode = 3; + func_80B31C40(this, globalCtx); +} + +void func_80B321D0(EnZoraegg* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { + this->actionFunc = func_80B322BC; + func_80B319D0(globalCtx, func_80B319A8(globalCtx) + 1); + } +} + +void func_80B32228(EnZoraegg* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, this->unk_1DC); + this->actionFunc = func_80B321D0; + } else { + if (this->unk_1E8 > 0) { + this->unk_1E8--; + } else if (this->unk_1E8 == 0) { + ActorCutscene_Stop(player->unk_A86); + player->unk_A86 = -1; + this->unk_1E8 = -1; + } + + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80B322BC(EnZoraegg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->actor.cutscene != -1) { + this->unk_1DC = func_80B31CB4(globalCtx); + if (this->unk_1DC != NULL) { + this->unk_1E8 = 3; + this->actionFunc = func_80B32228; + return; + } + } + + if ((fabsf(player->actor.world.pos.x - this->actor.world.pos.x) < (100.0f * this->actor.scale.x)) && + (fabsf(player->actor.world.pos.z - this->actor.world.pos.z) < (100.0f * this->actor.scale.z))) { + func_8012300C(globalCtx, 25); + } +} + +void func_80B32390(EnZoraegg* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + Actor* temp_v0 = func_80B31D14(globalCtx); + + if (temp_v0 != NULL) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, temp_v0); + gSaveContext.eventInf[3] |= 8; + Actor_MarkForDeath(&this->actor); + } + } else if ((func_80B319A8(globalCtx) >= 7) && + (fabsf(player->actor.world.pos.x - this->actor.world.pos.x) < (100.0f * this->actor.scale.x)) && + (fabsf(player->actor.world.pos.z - this->actor.world.pos.z) < (100.0f * this->actor.scale.z)) && + (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 30.0f)) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80B324B0(EnZoraegg* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (func_800EE29C(globalCtx, this->unk_1F0)) { + if (this->unk_1EA & 4) { + if (func_800EE29C(globalCtx, this->unk_1F0) && + (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_1F0)]->unk0 == 3)) { + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004FE4); + this->unk_1EA &= ~4; + } + } else if (func_800EE29C(globalCtx, this->unk_1F0) && + (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_1F0)]->unk0 == 4)) { + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004E04); + this->unk_1EA |= 4; + } + + func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->unk_1F0)); + + if ((this->unk_1EA & 4) && Animation_OnFrame(&this->skelAnime, this->unk_1E4)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_1); + this->unk_1E4 = Rand_ZeroFloat(5.0f); + } + } else if (this->unk_1EA & 4) { + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004FE4); + this->unk_1EA &= ~4; + } +} + +void func_80B32644(EnZoraegg* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004FE4); + this->unk_1EE = 0; + this->unk_1EA |= 2; + } + + if (!func_800EE29C(globalCtx, this->unk_1F0)) { + this->actionFunc = func_80B324B0; + } else { + func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->unk_1F0)); + + if (this->unk_1EE > 25) { + this->unk_1EE -= 25; + } else { + this->unk_1EE = 0; + } + } +} + +void func_80B326F4(EnZoraegg* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (func_800EE29C(globalCtx, this->unk_1F0) && + (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_1F0)]->unk0 == 3)) { + Animation_Change(&this->skelAnime, &object_zoraegg_Anim_004D20, 1.0f, 0.0f, + Animation_GetLastFrame(&object_zoraegg_Anim_004D20), 2, 5.0f); + this->unk_1E8 = 0; + this->actionFunc = func_80B32644; + gSaveContext.weekEventReg[19] |= 0x40; + this->unk_1EC = 2; + this->unk_1EE = 100; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_2); + } + + func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->unk_1F0)); + + if (Animation_OnFrame(&this->skelAnime, 4.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_1); + } +} + +void func_80B32820(EnZoraegg* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_1E8 >= 2) { + this->actionFunc = func_80B326F4; + Animation_Change(&this->skelAnime, &object_zoraegg_Anim_005098, 1.0f, 0.0f, + Animation_GetLastFrame(&object_zoraegg_Anim_005098), 0, 10.0f); + this->unk_1E8 = 0; + SkelAnime_Update(&this->skelAnime); + return; + } + + Animation_PlayOnce(&this->skelAnime, &object_zoraegg_Anim_0005D4); + this->unk_1E8 += 1; + SkelAnime_Update(&this->skelAnime); + } + + func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->unk_1F0)); + + if (Animation_OnFrame(&this->skelAnime, 16.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_0); + } +} + +void func_80B32928(EnZoraegg* this, GlobalContext* globalCtx) { + if (this->unk_1E8 < 112) { + this->unk_1E8++; + } + + if (SkelAnime_Update(&this->skelAnime)) { + Animation_PlayOnce(&this->skelAnime, &object_zoraegg_Anim_0005D4); + this->unk_1EA |= 1; + this->actionFunc = func_80B32820; + this->unk_1E8 = 0; + this->actor.velocity.y = 0.0f; + return; + } + + func_80B31A34(this); + func_80B31E00(this); + + if (this->unk_1E8 < 112) { + if ((this->unk_1E8 >= 69) && (this->unk_1E8 < 72)) { + func_80B31D64(this, globalCtx, 0, 0.0f); + func_80B31D64(this, globalCtx, 0, 0.0f); + func_80B31D64(this, globalCtx, 0, 0.0f); + } else { + func_80B31D64(this, globalCtx, 0xD, 0.0f); + } + } + + func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->unk_1F0)); + + if (Animation_OnFrame(&this->skelAnime, 97.0f) || Animation_OnFrame(&this->skelAnime, 101.0f) || + Animation_OnFrame(&this->skelAnime, 105.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_1); + } +} + +void func_80B32A88(EnZoraegg* this, GlobalContext* globalCtx) { + if (func_800EE29C(globalCtx, this->unk_1F0) && + (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_1F0)]->unk0 == 2)) { + this->unk_1E8 = 0; + this->actionFunc = func_80B32928; + } + func_80B31D64(this, globalCtx, 13, 0.0f); +} + +void func_80B32B10(EnZoraegg* this, GlobalContext* globalCtx) { + if (gSaveContext.eventInf[3] & 8) { + this->actionFunc = func_80B32A88; + } +} + +void func_80B32B3C(EnZoraegg* this, GlobalContext* globalCtx) { + if (gSaveContext.eventInf[3] & 8) { + this->actionFunc = func_80B32A88; + this->actor.draw = EnZoraegg_Draw; + } +} + +void func_80B32B70(EnZoraegg* this, GlobalContext* globalCtx) { + func_80B31C40(this, globalCtx); + if (func_800EE29C(globalCtx, 0x1C9)) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80B32BB8(EnZoraegg* this, GlobalContext* globalCtx) { + func_80B31C40(this, globalCtx); + func_80B31D64(this, globalCtx, 13, 0.0f); + + if (this->actor.bgCheckFlags & 0x1) { + this->actionFunc = func_80B32B70; + } + + if (func_800EE29C(globalCtx, 0x1C9)) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80B32C34(EnZoraegg* this, GlobalContext* globalCtx) { + WaterBox* sp34; + f32 sp30; + s32 pad; + + Actor_MoveWithGravity(&this->actor); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); + this->actor.focus.pos.y += 10.0f; + sp30 = this->actor.world.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp30, + &sp34)) { + if ((this->actor.world.pos.y + 50.0f) < sp30) { + this->actionFunc = func_80B32BB8; + } + + func_80B31D64(this, globalCtx, 0, -20.0f); + func_80B31D64(this, globalCtx, 0, -20.0f); + } +} + +void func_80B32D08(EnZoraegg* this, GlobalContext* globalCtx) { + WaterBox* sp44; + f32 sp40; + Vec3f sp34; + s32 pad; + + Actor_MoveWithGravity(&this->actor); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); + this->actor.focus.pos.y += 10.0f; + sp40 = this->actor.world.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp40, + &sp44)) { + if (this->actor.world.pos.y < sp40) { + sp34.x = this->actor.world.pos.x; + sp34.y = sp40; + sp34.z = this->actor.world.pos.z; + + EffectSsGRipple_Spawn(globalCtx, &sp34, 150, 500, 0); + EffectSsGSplash_Spawn(globalCtx, &sp34, NULL, NULL, 0, 200); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); + + this->actionFunc = func_80B32C34; + this->actor.velocity.y = -1.0f; + this->actor.terminalVelocity = -1.0f; + this->actor.gravity = -1.0f; + } + } + + if (this->actor.scale.x < 0.006f) { + Actor_SetScale(&this->actor, this->actor.scale.x + 0.0012f); + } + + if (this->actor.scale.x > 0.006f) { + Actor_SetScale(&this->actor, 0.006f); + } +} + +void EnZoraegg_Update(Actor* thisx, GlobalContext* globalCtx) { + EnZoraegg* this = THIS; + + this->actionFunc(this, globalCtx); + + if (DECR(this->unk_1F4) == 0) { + this->unk_1F4 = Rand_S16Offset(60, 60); + } + + this->unk_1F2 = this->unk_1F4; + if (this->unk_1F2 >= 3) { + this->unk_1F2 = 0; + } +} + +void func_80B32F04(Actor* thisx, GlobalContext* globalCtx) { + f32 sp7C; + f32 sp78; + f32 sp74; + EnZoraegg* this = THIS; + s32 pad[3]; + s16 sp62; + s16 sp60; + f32 temp_f2; + Gfx* gfx; + Vec3f sp4C; + s32 pad2; + + Matrix_StatePush(); + + sp4C = GET_ACTIVE_CAM(globalCtx)->eye; + + sp62 = Math_Vec3f_Yaw(&sp4C, &this->actor.focus.pos); + sp60 = -Math_Vec3f_Pitch(&sp4C, &this->actor.focus.pos); + + sp74 = -((15.0f * Math_SinS(sp62)) * Math_CosS(sp60)); + sp78 = -(15.0f * Math_SinS(sp60)); + sp7C = -((15.0f * Math_CosS(sp62)) * Math_CosS(sp60)); + + Matrix_InsertTranslation(this->actor.world.pos.x + sp74, this->actor.world.pos.y + sp78 + 6.0f, + temp_f2 = this->actor.world.pos.z + sp7C, 0); + + sp7C = Math_SinS(globalCtx->gameplayFrames * 0x4000); + + Matrix_Scale(this->actor.scale.x * (((sp7C + 1.0f) * 0.1f) + 9.0f), + this->actor.scale.y * (((sp7C + 1.0f) * 0.1f) + 9.0f), + this->actor.scale.z * (((sp7C + 1.0f) * 0.1f) + 9.0f), 1); + + OPEN_DISPS(globalCtx->state.gfxCtx); + gfx = POLY_XLU_DISP; + gfx = func_8012C868(gfx); + + gSPSetOtherMode(gfx++, G_SETOTHERMODE_H, 4, 4, 0x00000080); + gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); + gSPDisplayList(gfx++, gameplay_keep_DL_029CB0); + + gDPSetPrimColor(gfx++, 0, 0, 120, 180, 200, (s32)(this->unk_1ED * (20.0f / 51))); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, gameplay_keep_DL_029CF0); + + POLY_XLU_DISP = gfx; + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80B331C8(Actor* thisx, GlobalContext* globalCtx) { + EnZoraegg* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + + Matrix_Scale(this->unk_1E0, this->unk_1E0, this->unk_1E0, MTXMODE_APPLY); + + if (this->unk_1ED >= 254) { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPDisplayList(POLY_OPA_DISP++, object_zoraegg_DL_005250); + } else { + func_8012C304(POLY_XLU_DISP++); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_1ED); + gSPDisplayList(POLY_XLU_DISP++, object_zoraegg_DL_005250); + } + + Matrix_StatePop(); + + func_80B32F04(thisx, globalCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +s32 EnZoraegg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnZoraegg* this = THIS; + + switch (this->unk_1EC) { + case 1: + if ((limbIndex != 1) && (limbIndex != 3) && (limbIndex != 4)) { + *dList = NULL; + } + break; + + case 2: + if ((limbIndex != 1) && (limbIndex != 3)) { + *dList = NULL; + } + break; + } + return false; +} + +void func_80B333DC(GlobalContext* globalCtx, Gfx** dList, f32 arg2) { + Matrix_StatePush(); + Matrix_Scale(arg2, arg2, arg2, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnZoraegg* this = THIS; + f32 temp_f20; + f32 temp_f2; + + switch (this->unk_1EC) { + case 1: + switch (limbIndex) { + case 2: + temp_f20 = this->unk_1EE * 0.01f; + Matrix_StatePush(); + Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + break; + + case 4: + Matrix_StatePop(); + break; + + case 5: + case 6: + temp_f20 = this->unk_1EF * 0.01f; + func_80B333DC(globalCtx, dList, temp_f20); + break; + } + break; + + case 2: + switch (limbIndex) { + case 2: + temp_f20 = (this->unk_1EE * 0.005f) + 0.5f; + Matrix_StatePush(); + Matrix_Scale(1.0f, temp_f20, temp_f20, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + break; + + case 4: + temp_f2 = 1.0f / ((this->unk_1EE * 0.005f) + 0.5f); + temp_f20 = (this->unk_1EE * 0.0035f) + 0.65f; + Matrix_Scale(1.0f, temp_f20 * temp_f2, temp_f2, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePop(); + break; + + case 5: + case 6: + temp_f20 = this->unk_1EE * 0.01f; + func_80B333DC(globalCtx, dList, temp_f20); + break; + } + break; + } +} + +TexturePtr D_80B33950[] = { object_zoraegg_Tex_003430, object_zoraegg_Tex_004430, object_zoraegg_Tex_004830 }; + +void func_80B33818(Actor* thisx, GlobalContext* globalCtx) { + EnZoraegg* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B33950[this->unk_1F2])); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnZoraegg_OverrideLimbDraw, EnZoraegg_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnZoraegg_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnZoraegg* this = THIS; + + if (this->unk_1ED > 0) { + func_80B331C8(thisx, globalCtx); + } + + if (this->unk_1ED != 255) { + func_80B33818(thisx, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h index 8c458c46e..152d656ef 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h @@ -7,9 +7,55 @@ struct EnZoraegg; typedef void (*EnZoraeggActionFunc)(struct EnZoraegg*, GlobalContext*); +#define ENZORAEGG_GET_1F(thisx) ((thisx)->params & 0x1F) +#define ENZORAEGG_GET_FE00(thisx) (((thisx)->params & 0xFE00) >> 9) + +enum { + /* 0 */ ENZORAEGG_1F_0, + /* 1 */ ENZORAEGG_1F_1, + /* 2 */ ENZORAEGG_1F_2, + /* 3 */ ENZORAEGG_1F_3, + /* 4 */ ENZORAEGG_1F_4, + /* 5 */ ENZORAEGG_1F_5, + /* 6 */ ENZORAEGG_1F_6, + /* 7 */ ENZORAEGG_1F_7, + /* 8 */ ENZORAEGG_1F_8, + /* 9 */ ENZORAEGG_1F_9, + /* 10 */ ENZORAEGG_1F_10, + /* 11 */ ENZORAEGG_1F_11, + /* 12 */ ENZORAEGG_1F_12, + /* 13 */ ENZORAEGG_1F_13, + /* 14 */ ENZORAEGG_1F_14, + /* 15 */ ENZORAEGG_1F_15, + /* 16 */ ENZORAEGG_1F_16, + /* 17 */ ENZORAEGG_1F_17, + /* 18 */ ENZORAEGG_1F_18, + /* 19 */ ENZORAEGG_1F_19, + /* 20 */ ENZORAEGG_1F_20, + /* 21 */ ENZORAEGG_1F_21, + /* 22 */ ENZORAEGG_1F_22, + /* 23 */ ENZORAEGG_1F_23, + /* 24 */ ENZORAEGG_1F_24, + /* 25 */ ENZORAEGG_1F_25, +}; + typedef struct EnZoraegg { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xB4]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[7]; + /* 0x01B2 */ Vec3s morphTable[7]; + /* 0x01DC */ Actor* unk_1DC; + /* 0x01E0 */ f32 unk_1E0; + /* 0x01E4 */ f32 unk_1E4; + /* 0x01E8 */ s16 unk_1E8; + /* 0x01EA */ u16 unk_1EA; + /* 0x01EC */ u8 unk_1EC; + /* 0x01ED */ u8 unk_1ED; + /* 0x01EE */ u8 unk_1EE; + /* 0x01EF */ u8 unk_1EF; + /* 0x01F0 */ u16 unk_1F0; + /* 0x01F2 */ s16 unk_1F2; + /* 0x01F4 */ s16 unk_1F4; /* 0x01F8 */ EnZoraeggActionFunc actionFunc; } EnZoraegg; // size = 0x1FC diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 8f47ab411..fcbc1b9c9 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -13484,9 +13484,9 @@ 0x80B32E74:("EnZoraegg_Update",), 0x80B32F04:("func_80B32F04",), 0x80B331C8:("func_80B331C8",), - 0x80B3336C:("func_80B3336C",), + 0x80B3336C:("EnZoraegg_OverrideLimbDraw",), 0x80B333DC:("func_80B333DC",), - 0x80B33480:("func_80B33480",), + 0x80B33480:("EnZoraegg_PostLimbDraw",), 0x80B33818:("func_80B33818",), 0x80B338C0:("EnZoraegg_Draw",), 0x80B33D30:("EnKbt_Init",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 74718ed44..034ab6cf0 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1981,17 +1981,6 @@ D_06000D94 = 0x06000D94; D_06007650 = 0x06007650; D_0600D658 = 0x0600D658; -// ovl_En_Zoraegg - -D_060005D4 = 0x060005D4; -D_06001E08 = 0x06001E08; -D_06004C90 = 0x06004C90; -D_06004D20 = 0x06004D20; -D_06004E04 = 0x06004E04; -D_06004FE4 = 0x06004FE4; -D_06005098 = 0x06005098; -D_06005250 = 0x06005250; - // ovl_Mir_Ray D_06000168 = 0x06000168; From c98184f8e33a9315e8df93bcf554eede02861447 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 19 Feb 2022 21:42:05 +0000 Subject: [PATCH 041/257] Cleanup various enums (#612) * PR * Add SQ and GI enums Co-authored-by: Anghelo Carvajal --- src/code/z_actor.c | 7 +- src/code/z_eff_shield_particle.c | 2 +- src/code/z_en_item00.c | 2 +- src/code/z_fireobj.c | 4 +- .../actors/ovl_Arms_Hook/z_arms_hook.c | 4 +- .../actors/ovl_Arrow_Fire/z_arrow_fire.c | 2 +- .../actors/ovl_Arrow_Ice/z_arrow_ice.c | 2 +- .../actors/ovl_Arrow_Light/z_arrow_light.c | 2 +- .../actors/ovl_Bg_Breakwall/z_bg_breakwall.c | 2 +- .../ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c | 2 +- .../ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c | 2 +- .../ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c | 2 +- .../ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c | 2 +- .../z_bg_dblue_elevator.c | 2 +- .../z_bg_dblue_waterfall.c | 2 +- .../ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c | 2 +- .../actors/ovl_Bg_F40_Block/z_bg_f40_block.c | 2 +- .../actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c | 2 +- .../ovl_Bg_F40_Switch/z_bg_f40_switch.c | 2 +- .../ovl_Bg_F40_Swlift/z_bg_f40_swlift.c | 2 +- .../actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c | 2 +- .../actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c | 2 +- .../actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c | 2 +- .../ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c | 2 +- .../actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c | 6 +- .../z_bg_hakugin_elvpole.c | 2 +- .../ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c | 2 +- .../z_bg_hakugin_switch.c | 2 +- .../actors/ovl_Bg_Icefloe/z_bg_icefloe.c | 2 +- .../ovl_Bg_Ikana_Block/z_bg_ikana_block.c | 2 +- .../z_bg_ikana_bombwall.c | 2 +- .../ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c | 2 +- .../ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c | 2 +- .../actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c | 4 +- .../ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c | 2 +- .../ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c | 2 +- .../actors/ovl_Bg_Ikninside/z_bg_ikninside.c | 2 +- .../ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c | 2 +- .../actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c | 8 +- .../actors/ovl_Bg_Ingate/z_bg_ingate.c | 2 +- .../ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c | 2 +- .../ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c | 2 +- .../ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c | 10 +- .../actors/ovl_Bg_Ladder/z_bg_ladder.c | 6 +- src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c | 4 +- .../ovl_Bg_Market_Step/z_bg_market_step.c | 2 +- .../ovl_Bg_Open_Shutter/z_bg_open_shutter.c | 2 +- .../actors/ovl_Bg_Open_Spot/z_bg_open_spot.c | 2 +- .../ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c | 2 +- .../actors/ovl_Bg_Tobira01/z_bg_tobira01.c | 2 +- src/overlays/actors/ovl_Boss_01/z_boss_01.c | 2 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 16 +-- src/overlays/actors/ovl_Boss_03/z_boss_03.c | 2 +- src/overlays/actors/ovl_Boss_04/z_boss_04.c | 12 +- src/overlays/actors/ovl_Boss_05/z_boss_05.c | 2 +- src/overlays/actors/ovl_Boss_07/z_boss_07.c | 2 +- .../actors/ovl_Boss_Hakugin/z_boss_hakugin.c | 2 +- .../actors/ovl_Demo_Effect/z_demo_effect.c | 2 +- .../actors/ovl_Demo_Getitem/z_demo_getitem.c | 2 +- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 2 +- .../actors/ovl_Demo_Moonend/z_demo_moonend.c | 2 +- src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c | 2 +- .../actors/ovl_Demo_Syoten/z_demo_syoten.c | 2 +- .../actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c | 2 +- src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c | 2 +- src/overlays/actors/ovl_Dm_Al/z_dm_al.c | 2 +- src/overlays/actors/ovl_Dm_An/z_dm_an.c | 2 +- src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c | 2 +- .../actors/ovl_Dm_Char02/z_dm_char02.c | 2 +- .../actors/ovl_Dm_Char03/z_dm_char03.c | 2 +- .../actors/ovl_Dm_Char04/z_dm_char04.c | 2 +- .../actors/ovl_Dm_Char05/z_dm_char05.c | 2 +- .../actors/ovl_Dm_Char06/z_dm_char06.c | 2 +- .../actors/ovl_Dm_Char07/z_dm_char07.c | 2 +- .../actors/ovl_Dm_Char08/z_dm_char08.c | 2 +- .../actors/ovl_Dm_Char09/z_dm_char09.c | 2 +- src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c | 2 +- src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c | 2 +- src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c | 4 +- .../actors/ovl_Dm_Opstage/z_dm_opstage.c | 2 +- .../actors/ovl_Dm_Ravine/z_dm_ravine.c | 2 +- src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c | 2 +- .../actors/ovl_Dm_Statue/z_dm_statue.c | 2 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 6 +- src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c | 2 +- src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c | 2 +- src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c | 2 +- src/overlays/actors/ovl_Door_Ana/z_door_ana.c | 8 +- .../actors/ovl_Door_Shutter/z_door_shutter.c | 2 +- .../actors/ovl_Door_Spiral/z_door_spiral.c | 4 +- .../actors/ovl_Eff_Change/z_eff_change.c | 2 +- src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c | 2 +- .../z_eff_kamejima_wave.c | 2 +- .../actors/ovl_Eff_Lastday/z_eff_lastday.c | 2 +- src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c | 2 +- .../actors/ovl_Eff_Zoraband/z_eff_zoraband.c | 2 +- src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c | 2 +- src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c | 2 +- src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c | 2 +- src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c | 2 +- src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c | 2 +- src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c | 2 +- src/overlays/actors/ovl_En_Ah/z_en_ah.c | 2 +- .../ovl_En_Akindonuts/z_en_akindonuts.c | 24 ++-- src/overlays/actors/ovl_En_An/z_en_an.c | 2 +- src/overlays/actors/ovl_En_And/z_en_and.c | 2 +- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 18 +-- .../ovl_En_Attack_Niw/z_en_attack_niw.c | 2 +- src/overlays/actors/ovl_En_Az/z_en_az.c | 2 +- src/overlays/actors/ovl_En_Baguo/z_en_baguo.c | 18 +-- .../actors/ovl_En_Baisen/z_en_baisen.c | 2 +- src/overlays/actors/ovl_En_Bal/z_en_bal.c | 2 +- src/overlays/actors/ovl_En_Bat/z_en_bat.c | 2 +- src/overlays/actors/ovl_En_Bb/z_en_bb.c | 2 +- .../actors/ovl_En_Bba_01/z_en_bba_01.c | 2 +- .../actors/ovl_En_Bbfall/z_en_bbfall.c | 2 +- src/overlays/actors/ovl_En_Bee/z_en_bee.c | 2 +- .../actors/ovl_En_Bigokuta/z_en_bigokuta.c | 2 +- .../actors/ovl_En_Bigpamet/z_en_bigpamet.c | 2 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 24 ++-- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 24 ++-- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 16 +-- src/overlays/actors/ovl_En_Bjt/z_en_bjt.c | 2 +- .../actors/ovl_En_Boj_01/z_en_boj_01.c | 2 +- .../actors/ovl_En_Boj_02/z_en_boj_02.c | 2 +- .../actors/ovl_En_Boj_03/z_en_boj_03.c | 2 +- .../actors/ovl_En_Boj_04/z_en_boj_04.c | 2 +- .../actors/ovl_En_Boj_05/z_en_boj_05.c | 2 +- src/overlays/actors/ovl_En_Bom/z_en_bom.c | 8 +- .../actors/ovl_En_Bom_Chu/z_en_bom_chu.c | 2 +- .../actors/ovl_En_Bombal/z_en_bombal.c | 2 +- .../actors/ovl_En_Bombers/z_en_bombers.c | 2 +- .../actors/ovl_En_Bombers2/z_en_bombers2.c | 2 +- src/overlays/actors/ovl_En_Bombf/z_en_bombf.c | 2 +- .../actors/ovl_En_Bomjima/z_en_bomjima.c | 4 +- .../actors/ovl_En_Bomjimb/z_en_bomjimb.c | 2 +- src/overlays/actors/ovl_En_Boom/z_en_boom.c | 2 +- src/overlays/actors/ovl_En_Bsb/z_en_bsb.c | 2 +- src/overlays/actors/ovl_En_Bu/z_en_bu.c | 2 +- .../actors/ovl_En_Bubble/z_en_bubble.c | 2 +- src/overlays/actors/ovl_En_Cha/z_en_cha.c | 6 +- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.c | 4 +- .../actors/ovl_En_Col_Man/z_en_col_man.c | 6 +- src/overlays/actors/ovl_En_Crow/z_en_crow.c | 2 +- src/overlays/actors/ovl_En_Dai/z_en_dai.c | 4 +- src/overlays/actors/ovl_En_Daiku/z_en_daiku.c | 4 +- .../actors/ovl_En_Daiku2/z_en_daiku2.c | 2 +- src/overlays/actors/ovl_En_Death/z_en_death.c | 2 +- .../actors/ovl_En_Dekubaba/z_en_dekubaba.c | 2 +- .../actors/ovl_En_Dekunuts/z_en_dekunuts.c | 8 +- .../ovl_En_Demo_heishi/z_en_demo_heishi.c | 2 +- src/overlays/actors/ovl_En_Dg/z_en_dg.c | 25 ++-- .../actors/ovl_En_Dinofos/z_en_dinofos.c | 12 +- src/overlays/actors/ovl_En_Dnb/z_en_dnb.c | 2 +- src/overlays/actors/ovl_En_Dnh/z_en_dnh.c | 2 +- src/overlays/actors/ovl_En_Dnk/z_en_dnk.c | 8 +- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 12 +- src/overlays/actors/ovl_En_Dnp/z_en_dnp.c | 10 +- src/overlays/actors/ovl_En_Dnq/z_en_dnq.c | 6 +- .../actors/ovl_En_Dodongo/z_en_dodongo.c | 14 +- src/overlays/actors/ovl_En_Door/z_en_door.c | 2 +- .../actors/ovl_En_Door_Etc/z_en_door_etc.c | 2 +- .../actors/ovl_En_Dragon/z_en_dragon.c | 2 +- src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c | 2 +- src/overlays/actors/ovl_En_Dt/z_en_dt.c | 2 +- .../actors/ovl_En_Dy_Extra/z_en_dy_extra.c | 2 +- .../actors/ovl_En_Egblock/z_en_egblock.c | 2 +- src/overlays/actors/ovl_En_Egol/z_en_egol.c | 2 +- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 8 +- .../actors/ovl_En_Elfbub/z_en_elfbub.c | 4 +- .../actors/ovl_En_Elfgrp/z_en_elfgrp.c | 2 +- .../actors/ovl_En_Elforg/z_en_elforg.c | 2 +- .../actors/ovl_En_Encount1/z_en_encount1.c | 2 +- .../actors/ovl_En_Encount2/z_en_encount2.c | 2 +- .../actors/ovl_En_Encount3/z_en_encount3.c | 2 +- .../actors/ovl_En_Encount4/z_en_encount4.c | 2 +- .../ovl_En_Ending_Hero/z_en_ending_hero.c | 4 +- .../ovl_En_Ending_Hero2/z_en_ending_hero2.c | 4 +- .../ovl_En_Ending_Hero3/z_en_ending_hero3.c | 4 +- .../ovl_En_Ending_Hero4/z_en_ending_hero4.c | 4 +- .../ovl_En_Ending_Hero5/z_en_ending_hero5.c | 4 +- .../ovl_En_Ending_Hero6/z_en_ending_hero6.c | 2 +- .../actors/ovl_En_Estone/z_en_estone.c | 2 +- src/overlays/actors/ovl_En_Fall/z_en_fall.c | 14 +- src/overlays/actors/ovl_En_Fall2/z_en_fall2.c | 2 +- src/overlays/actors/ovl_En_Famos/z_en_famos.c | 2 +- src/overlays/actors/ovl_En_Fg/z_en_fg.c | 14 +- .../actors/ovl_En_Fire_Rock/z_en_fire_rock.c | 2 +- .../actors/ovl_En_Firefly/z_en_firefly.c | 14 +- .../actors/ovl_En_Firefly2/z_en_firefly2.c | 2 +- src/overlays/actors/ovl_En_Fish/z_en_fish.c | 6 +- src/overlays/actors/ovl_En_Fish2/z_en_fish2.c | 8 +- .../actors/ovl_En_Fishing/z_en_fishing.c | 22 +-- .../actors/ovl_En_Floormas/z_en_floormas.c | 38 ++--- src/overlays/actors/ovl_En_Fr/z_en_fr.c | 6 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 30 ++-- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 28 ++-- .../actors/ovl_En_Fu_Kago/z_en_fu_kago.c | 2 +- .../actors/ovl_En_Fu_Mato/z_en_fu_mato.c | 2 +- src/overlays/actors/ovl_En_Fz/z_en_fz.c | 16 +-- .../actors/ovl_En_Gakufu/z_en_gakufu.c | 2 +- .../actors/ovl_En_Gamelupy/z_en_gamelupy.c | 2 +- src/overlays/actors/ovl_En_Gb2/z_en_gb2.c | 24 ++-- src/overlays/actors/ovl_En_Ge1/z_en_ge1.c | 2 +- src/overlays/actors/ovl_En_Ge2/z_en_ge2.c | 2 +- src/overlays/actors/ovl_En_Ge3/z_en_ge3.c | 2 +- src/overlays/actors/ovl_En_Geg/z_en_geg.c | 14 +- src/overlays/actors/ovl_En_Gg/z_en_gg.c | 2 +- src/overlays/actors/ovl_En_Gg2/z_en_gg2.c | 2 +- src/overlays/actors/ovl_En_Giant/z_en_giant.c | 4 +- .../actors/ovl_En_Ginko_Man/z_en_ginko_man.c | 4 +- src/overlays/actors/ovl_En_GirlA/z_en_girla.c | 6 +- src/overlays/actors/ovl_En_Gk/z_en_gk.c | 2 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 10 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 18 +-- .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 14 +- .../ovl_En_Grasshopper/z_en_grasshopper.c | 2 +- src/overlays/actors/ovl_En_Gs/z_en_gs.c | 4 +- .../ovl_En_Guard_Nuts/z_en_guard_nuts.c | 2 +- .../actors/ovl_En_Guruguru/z_en_guruguru.c | 6 +- .../actors/ovl_En_Hakurock/z_en_hakurock.c | 2 +- .../actors/ovl_En_Hanabi/z_en_hanabi.c | 2 +- .../actors/ovl_En_Heishi/z_en_heishi.c | 2 +- src/overlays/actors/ovl_En_Hg/z_en_hg.c | 12 +- src/overlays/actors/ovl_En_Hgo/z_en_hgo.c | 4 +- .../ovl_En_Hidden_Nuts/z_en_hidden_nuts.c | 2 +- .../actors/ovl_En_Hit_Tag/z_en_hit_tag.c | 2 +- src/overlays/actors/ovl_En_Holl/z_en_holl.c | 2 +- .../actors/ovl_En_Honotrap/z_en_honotrap.c | 2 +- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 2 +- .../z_en_horse_game_check.c | 2 +- .../z_en_horse_link_child.c | 2 +- src/overlays/actors/ovl_En_Hs/z_en_hs.c | 2 +- src/overlays/actors/ovl_En_Hs2/z_en_hs2.c | 2 +- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 10 +- src/overlays/actors/ovl_En_Ik/z_en_ik.c | 2 +- src/overlays/actors/ovl_En_In/z_en_in.c | 22 +-- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 132 +++++++++--------- .../z_en_invadepoh_demo.c | 2 +- src/overlays/actors/ovl_En_Ishi/z_en_ishi.c | 14 +- .../actors/ovl_En_Jc_Mato/z_en_jc_mato.c | 2 +- .../actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c | 2 +- src/overlays/actors/ovl_En_Js/z_en_js.c | 2 +- src/overlays/actors/ovl_En_Jso/z_en_jso.c | 2 +- src/overlays/actors/ovl_En_Jso2/z_en_jso2.c | 2 +- .../actors/ovl_En_Kaizoku/z_en_kaizoku.c | 2 +- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 22 +-- src/overlays/actors/ovl_En_Kame/z_en_kame.c | 18 +-- .../actors/ovl_En_Kanban/z_en_kanban.c | 14 +- src/overlays/actors/ovl_En_Kbt/z_en_kbt.c | 2 +- src/overlays/actors/ovl_En_Kgy/z_en_kgy.c | 20 +-- src/overlays/actors/ovl_En_Kitan/z_en_kitan.c | 2 +- .../actors/ovl_En_Knight/z_en_knight.c | 2 +- .../actors/ovl_En_Kujiya/z_en_kujiya.c | 2 +- src/overlays/actors/ovl_En_Kusa/z_en_kusa.c | 2 +- src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c | 8 +- .../actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c | 2 +- .../actors/ovl_En_Look_Nuts/z_en_look_nuts.c | 2 +- .../actors/ovl_En_M_Thunder/z_en_m_thunder.c | 2 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 42 +++--- .../actors/ovl_En_Ma_Yto/z_en_ma_yto.c | 76 +++++----- .../actors/ovl_En_Ma_Yts/z_en_ma_yts.c | 32 ++--- src/overlays/actors/ovl_En_Mag/z_en_mag.c | 2 +- .../actors/ovl_En_Maruta/z_en_maruta.c | 2 +- .../actors/ovl_En_Minideath/z_en_minideath.c | 2 +- .../actors/ovl_En_Minifrog/z_en_minifrog.c | 15 +- .../actors/ovl_En_Minislime/z_en_minislime.c | 18 +-- src/overlays/actors/ovl_En_Mk/z_en_mk.c | 2 +- src/overlays/actors/ovl_En_Mkk/z_en_mkk.c | 2 +- src/overlays/actors/ovl_En_Mm/z_en_mm.c | 2 +- src/overlays/actors/ovl_En_Mm2/z_en_mm2.c | 2 +- src/overlays/actors/ovl_En_Mm3/z_en_mm3.c | 2 +- src/overlays/actors/ovl_En_Mnk/z_en_mnk.c | 2 +- src/overlays/actors/ovl_En_Ms/z_en_ms.c | 2 +- .../actors/ovl_En_Mt_tag/z_en_mt_tag.c | 2 +- .../actors/ovl_En_Mushi2/z_en_mushi2.c | 12 +- src/overlays/actors/ovl_En_Muto/z_en_muto.c | 6 +- src/overlays/actors/ovl_En_Nb/z_en_nb.c | 2 +- .../actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c | 2 +- .../actors/ovl_En_Nimotsu/z_en_nimotsu.c | 2 +- src/overlays/actors/ovl_En_Niw/z_en_niw.c | 16 +-- src/overlays/actors/ovl_En_Nnh/z_en_nnh.c | 2 +- .../actors/ovl_En_Nutsball/z_en_nutsball.c | 4 +- src/overlays/actors/ovl_En_Nwc/z_en_nwc.c | 2 +- .../z_en_okarina_effect.c | 2 +- .../ovl_En_Okarina_Tag/z_en_okarina_tag.c | 2 +- src/overlays/actors/ovl_En_Okuta/z_en_okuta.c | 2 +- .../actors/ovl_En_Onpuman/z_en_onpuman.c | 2 +- src/overlays/actors/ovl_En_Osk/z_en_osk.c | 2 +- src/overlays/actors/ovl_En_Osn/z_en_osn.c | 2 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 30 ++-- src/overlays/actors/ovl_En_Ot/z_en_ot.c | 36 ++--- src/overlays/actors/ovl_En_Owl/z_en_owl.c | 28 ++-- .../actors/ovl_En_Pamera/z_en_pamera.c | 14 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 10 +- src/overlays/actors/ovl_En_Paper/z_en_paper.c | 2 +- src/overlays/actors/ovl_En_Part/z_en_part.c | 2 +- .../actors/ovl_En_Peehat/z_en_peehat.c | 6 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 14 +- .../ovl_En_Po_Composer/z_en_po_composer.c | 2 +- .../actors/ovl_En_Po_Fusen/z_en_po_fusen.c | 2 +- .../ovl_En_Po_Sisters/z_en_po_sisters.c | 16 +-- src/overlays/actors/ovl_En_Poh/z_en_poh.c | 16 +-- src/overlays/actors/ovl_En_Pp/z_en_pp.c | 2 +- src/overlays/actors/ovl_En_Pr2/z_en_pr2.c | 2 +- src/overlays/actors/ovl_En_Prz/z_en_prz.c | 2 +- src/overlays/actors/ovl_En_Pst/z_en_pst.c | 2 +- .../actors/ovl_En_Racedog/z_en_racedog.c | 2 +- src/overlays/actors/ovl_En_Raf/z_en_raf.c | 2 +- .../actors/ovl_En_Rail_Skb/z_en_rail_skb.c | 28 ++-- .../actors/ovl_En_Railgibud/z_en_railgibud.c | 4 +- src/overlays/actors/ovl_En_Rat/z_en_rat.c | 2 +- .../actors/ovl_En_Recepgirl/z_en_recepgirl.c | 2 +- .../ovl_En_River_Sound/z_en_river_sound.c | 2 +- src/overlays/actors/ovl_En_Rr/z_en_rr.c | 12 +- src/overlays/actors/ovl_En_Rsn/z_en_rsn.c | 4 +- src/overlays/actors/ovl_En_Ru/z_en_ru.c | 2 +- .../actors/ovl_En_Ruppecrow/z_en_ruppecrow.c | 20 +-- src/overlays/actors/ovl_En_Rz/z_en_rz.c | 2 +- .../actors/ovl_En_S_Goro/z_en_s_goro.c | 2 +- src/overlays/actors/ovl_En_Sb/z_en_sb.c | 6 +- .../actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c | 2 +- .../actors/ovl_En_Scopecoin/z_en_scopecoin.c | 2 +- .../actors/ovl_En_Scopecrow/z_en_scopecrow.c | 2 +- src/overlays/actors/ovl_En_Sda/z_en_sda.c | 2 +- .../actors/ovl_En_Sekihi/z_en_sekihi.c | 2 +- .../actors/ovl_En_Sellnuts/z_en_sellnuts.c | 16 +-- src/overlays/actors/ovl_En_Shn/z_en_shn.c | 2 +- src/overlays/actors/ovl_En_Si/z_en_si.c | 2 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 42 +++--- src/overlays/actors/ovl_En_Slime/z_en_slime.c | 2 +- .../actors/ovl_En_Snowman/z_en_snowman.c | 2 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 44 +++--- src/overlays/actors/ovl_En_Ssh/z_en_ssh.c | 2 +- src/overlays/actors/ovl_En_St/z_en_st.c | 12 +- src/overlays/actors/ovl_En_Sth2/z_en_sth2.c | 2 +- .../ovl_En_Stone_heishi/z_en_stone_heishi.c | 2 +- .../ovl_En_Stop_heishi/z_en_stop_heishi.c | 2 +- .../actors/ovl_En_Stream/z_en_stream.c | 2 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 68 ++++----- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 12 +- .../ovl_En_Syateki_Crow/z_en_syateki_crow.c | 2 +- .../z_en_syateki_dekunuts.c | 2 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 6 +- .../ovl_En_Syateki_Okuta/z_en_syateki_okuta.c | 2 +- src/overlays/actors/ovl_En_Tab/z_en_tab.c | 2 +- .../actors/ovl_En_Takaraya/z_en_takaraya.c | 2 +- src/overlays/actors/ovl_En_Talk/z_en_talk.c | 2 +- .../actors/ovl_En_Tanron1/z_en_tanron1.c | 2 +- .../actors/ovl_En_Tanron3/z_en_tanron3.c | 4 +- .../actors/ovl_En_Tanron4/z_en_tanron4.c | 2 +- .../actors/ovl_En_Tanron5/z_en_tanron5.c | 2 +- .../actors/ovl_En_Tanron6/z_en_tanron6.c | 2 +- src/overlays/actors/ovl_En_Test/z_en_test.c | 2 +- src/overlays/actors/ovl_En_Test2/z_en_test2.c | 2 +- src/overlays/actors/ovl_En_Test3/z_en_test3.c | 2 +- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 2 +- src/overlays/actors/ovl_En_Test5/z_en_test5.c | 2 +- src/overlays/actors/ovl_En_Test6/z_en_test6.c | 2 +- src/overlays/actors/ovl_En_Test7/z_en_test7.c | 2 +- src/overlays/actors/ovl_En_Tg/z_en_tg.c | 2 +- .../actors/ovl_En_Thiefbird/z_en_thiefbird.c | 20 +-- .../actors/ovl_En_Time_Tag/z_en_time_tag.c | 2 +- src/overlays/actors/ovl_En_Tite/z_en_tite.c | 22 +-- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 16 +-- .../actors/ovl_En_Torch2/z_en_torch2.c | 6 +- src/overlays/actors/ovl_En_Toto/z_en_toto.c | 22 +-- src/overlays/actors/ovl_En_Trt/z_en_trt.c | 54 +++---- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 6 +- .../actors/ovl_En_Tru_Mt/z_en_tru_mt.c | 2 +- src/overlays/actors/ovl_En_Tsn/z_en_tsn.c | 2 +- .../actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c | 2 +- src/overlays/actors/ovl_En_Twig/z_en_twig.c | 2 +- .../actors/ovl_En_Viewer/z_en_viewer.c | 2 +- src/overlays/actors/ovl_En_Vm/z_en_vm.c | 2 +- .../actors/ovl_En_Wallmas/z_en_wallmas.c | 2 +- .../actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c | 2 +- .../actors/ovl_En_Warp_tag/z_en_warp_tag.c | 2 +- .../ovl_En_Water_Effect/z_en_water_effect.c | 4 +- .../actors/ovl_En_Wdhand/z_en_wdhand.c | 2 +- .../ovl_En_Weather_Tag/z_en_weather_tag.c | 6 +- src/overlays/actors/ovl_En_Wf/z_en_wf.c | 12 +- src/overlays/actors/ovl_En_Wiz/z_en_wiz.c | 4 +- .../actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c | 2 +- .../actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c | 7 +- src/overlays/actors/ovl_En_Zl1/z_en_zl1.c | 2 +- src/overlays/actors/ovl_En_Zl4/z_en_zl4.c | 2 +- src/overlays/actors/ovl_En_Zo/z_en_zo.c | 2 +- src/overlays/actors/ovl_En_Zob/z_en_zob.c | 2 +- src/overlays/actors/ovl_En_Zod/z_en_zod.c | 2 +- src/overlays/actors/ovl_En_Zog/z_en_zog.c | 14 +- src/overlays/actors/ovl_En_Zot/z_en_zot.c | 16 +-- .../ovl_Item_Etcetera/z_item_etcetera.c | 2 +- .../actors/ovl_Item_Inbox/z_item_inbox.c | 2 +- src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c | 2 +- src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c | 2 +- src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c | 2 +- src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c | 2 +- .../actors/ovl_Obj_Armos/z_obj_armos.c | 2 +- src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c | 2 +- .../ovl_Obj_Blockstop/z_obj_blockstop.c | 2 +- src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c | 2 +- src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c | 2 +- src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c | 2 +- .../actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c | 2 +- .../ovl_Obj_Danpeilift/z_obj_danpeilift.c | 2 +- src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c | 2 +- .../actors/ovl_Obj_Dinner/z_obj_dinner.c | 4 +- src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c | 2 +- .../actors/ovl_Obj_Dowsing/z_obj_dowsing.c | 2 +- .../actors/ovl_Obj_Ending/z_obj_ending.c | 2 +- .../actors/ovl_Obj_Entotu/z_obj_entotu.c | 2 +- .../actors/ovl_Obj_Etcetera/z_obj_etcetera.c | 2 +- .../ovl_Obj_Fireshield/z_obj_fireshield.c | 2 +- .../ovl_Obj_Flowerpot/z_obj_flowerpot.c | 10 +- .../actors/ovl_Obj_Funen/z_obj_funen.c | 2 +- .../actors/ovl_Obj_Ghaka/z_obj_ghaka.c | 2 +- .../actors/ovl_Obj_Grass/z_obj_grass.c | 2 +- .../ovl_Obj_Grass_Carry/z_obj_grass_carry.c | 2 +- .../actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c | 2 +- .../actors/ovl_Obj_Hamishi/z_obj_hamishi.c | 2 +- .../actors/ovl_Obj_Hariko/z_obj_hariko.c | 2 +- .../actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c | 2 +- .../actors/ovl_Obj_HsStump/z_obj_hsstump.c | 2 +- .../ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c | 6 +- .../actors/ovl_Obj_Hunsui/z_obj_hunsui.c | 2 +- .../actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c | 2 +- .../actors/ovl_Obj_Iceblock/z_obj_iceblock.c | 18 +-- .../actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c | 2 +- .../ovl_Obj_Jgame_Light/z_obj_jgame_light.c | 2 +- .../actors/ovl_Obj_Kibako/z_obj_kibako.c | 6 +- .../actors/ovl_Obj_Kibako2/z_obj_kibako2.c | 4 +- .../actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c | 2 +- src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c | 2 +- .../ovl_Obj_Lightswitch/z_obj_lightswitch.c | 2 +- .../ovl_Obj_Lupygamelift/z_obj_lupygamelift.c | 2 +- .../ovl_Obj_Makekinsuta/z_obj_makekinsuta.c | 2 +- .../ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c | 2 +- .../actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c | 6 +- .../ovl_Obj_Moon_Stone/z_obj_moon_stone.c | 6 +- .../actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c | 2 +- src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c | 4 +- .../actors/ovl_Obj_Nozoki/z_obj_nozoki.c | 2 +- .../ovl_Obj_Ocarinalift/z_obj_ocarinalift.c | 2 +- .../actors/ovl_Obj_Purify/z_obj_purify.c | 2 +- .../actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c | 2 +- .../actors/ovl_Obj_Raillift/z_obj_raillift.c | 2 +- .../ovl_Obj_Roomtimer/z_obj_roomtimer.c | 2 +- .../actors/ovl_Obj_Shutter/z_obj_shutter.c | 2 +- .../ovl_Obj_Skateblock/z_obj_skateblock.c | 2 +- .../actors/ovl_Obj_Smork/z_obj_smork.c | 2 +- .../actors/ovl_Obj_Snowball/z_obj_snowball.c | 10 +- .../actors/ovl_Obj_Sound/z_obj_sound.c | 2 +- .../ovl_Obj_Spidertent/z_obj_spidertent.c | 2 +- .../ovl_Obj_Spinyroll/z_obj_spinyroll.c | 2 +- .../actors/ovl_Obj_Switch/z_obj_switch.c | 2 +- .../actors/ovl_Obj_Swprize/z_obj_swprize.c | 2 +- .../actors/ovl_Obj_Syokudai/z_obj_syokudai.c | 2 +- .../z_obj_takaraya_wall.c | 2 +- src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c | 2 +- .../ovl_Obj_Tokei_Step/z_obj_tokei_step.c | 4 +- .../actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c | 2 +- .../actors/ovl_Obj_Toudai/z_obj_toudai.c | 2 +- src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c | 2 +- .../actors/ovl_Obj_Tsubo/z_obj_tsubo.c | 2 +- src/overlays/actors/ovl_Obj_Um/z_obj_um.c | 2 +- .../actors/ovl_Obj_Usiyane/z_obj_usiyane.c | 2 +- .../ovl_Obj_Visiblock/z_obj_visiblock.c | 2 +- .../ovl_Obj_Vspinyroll/z_obj_vspinyroll.c | 2 +- .../ovl_Obj_Warpstone/z_obj_warpstone.c | 2 +- src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c | 2 +- .../actors/ovl_Obj_Wturn/z_obj_wturn.c | 2 +- .../actors/ovl_Obj_Y2lift/z_obj_y2lift.c | 2 +- .../ovl_Obj_Y2shutter/z_obj_y2shutter.c | 2 +- src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c | 2 +- .../ovl_Object_Kankyo/z_object_kankyo.c | 2 +- .../actors/ovl_Oceff_Spot/z_oceff_spot.c | 2 +- .../actors/ovl_Oceff_Storm/z_oceff_storm.c | 2 +- .../actors/ovl_Oceff_Wipe/z_oceff_wipe.c | 2 +- .../actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c | 2 +- .../actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c | 2 +- .../actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c | 2 +- .../actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c | 2 +- .../actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c | 2 +- .../actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c | 2 +- src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c | 2 +- src/overlays/actors/ovl_TG_Sw/z_tg_sw.c | 2 +- 487 files changed, 1319 insertions(+), 1313 deletions(-) diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 2eac6470a..308fc9c1b 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -4575,7 +4575,8 @@ void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 } Matrix_SetCurrentState(&globalCtx->billboardMtxF); - Matrix_Scale((effectScale * 0.005f) * 1.35f, (effectScale * 0.005f), (effectScale * 0.005f) * 1.35f, 1); + Matrix_Scale((effectScale * 0.005f) * 1.35f, (effectScale * 0.005f), (effectScale * 0.005f) * 1.35f, + MTXMODE_APPLY); sp74 = effectAlpha * 255.0f; @@ -4674,7 +4675,7 @@ void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 for (i = 0; i < arg3; i++) { Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), 1); + Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); temp_s3->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; temp_s3->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; temp_s3->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; @@ -4685,7 +4686,7 @@ void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0234F0); Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), 1); + Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); temp_s3->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; temp_s3->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; temp_s3->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; diff --git a/src/code/z_eff_shield_particle.c b/src/code/z_eff_shield_particle.c index 112f7fe73..e3a051fb4 100644 --- a/src/code/z_eff_shield_particle.c +++ b/src/code/z_eff_shield_particle.c @@ -184,7 +184,7 @@ void EffectShieldParticle_Draw(void* thisx, GraphicsContext* gfxCtx) { } SkinMatrix_SetTranslate(&spC4, this->position.x, this->position.y, this->position.z); - SkinMatrix_SetRotateRPY(&sp104, 0, elem->yaw, 0); + SkinMatrix_SetRotateRPY(&sp104, 0, elem->yaw, MTXMODE_NEW); SkinMatrix_MtxFMtxFMult(&spC4, &sp104, &sp84); SkinMatrix_SetRotateRPY(&sp104, 0, 0, elem->pitch); SkinMatrix_MtxFMtxFMult(&sp84, &sp104, &spC4); diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 970a70458..5dc1f92a2 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -1130,7 +1130,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 spawnedActor->actor.world.rot.y = Rand_ZeroOne() * 40000.0f; Actor_SetScale(&spawnedActor->actor, 0.0f); spawnedActor->actionFunc = func_800A6780; - spawnedActor->actor.flags = spawnedActor->actor.flags | 0x10; + spawnedActor->actor.flags = spawnedActor->actor.flags | ACTOR_FLAG_10; if ((spawnedActor->actor.params != ITEM00_SMALL_KEY) && (spawnedActor->actor.params != ITEM00_HEART_PIECE) && (spawnedActor->actor.params != ITEM00_HEART_CONTAINER)) { diff --git a/src/code/z_fireobj.c b/src/code/z_fireobj.c index 9cc126cf8..02644818f 100644 --- a/src/code/z_fireobj.c +++ b/src/code/z_fireobj.c @@ -236,10 +236,10 @@ void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor) { FireObj_UpdateStateTransitions(globalCtx, fire); if (fire->state == 3) { - if ((fire->collision.base.acFlags & 2) && (fire->collision.info.acHitInfo->toucher.dmgFlags & 0x800)) { + if ((fire->collision.base.acFlags & AC_HIT) && (fire->collision.info.acHitInfo->toucher.dmgFlags & 0x800)) { FireObj_SetState(fire, fire->dynamicSizeStep, 0); } - } else if ((fire->collision.base.acFlags & 2) && (arrow->actor.update != NULL) && + } else if ((fire->collision.base.acFlags & AC_HIT) && (arrow->actor.update != NULL) && (arrow->actor.id == ACTOR_EN_ARROW)) { arrow->actor.params = 0; arrow->collider.info.toucher.dmgFlags = 0x800; diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index 1b60a4147..9c6bae33b 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -8,7 +8,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_link_child/object_link_child.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ArmsHook*)thisx) @@ -108,7 +108,7 @@ void ArmsHook_DetachHookFromActor(ArmsHook* this) { s32 ArmsHook_CheckForCancel(ArmsHook* this) { Player* player = (Player*)this->actor.parent; if (func_801240C8(player)) { - if ((player->heldItemActionParam != player->itemActionParam) || ((player->actor.flags & 0x100)) || + if ((player->heldItemActionParam != player->itemActionParam) || ((player->actor.flags & ACTOR_FLAG_100)) || ((player->stateFlags1 & 0x4000080))) { this->timer = 0; ArmsHook_DetachHookFromActor(this); diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c index a0f11082c..e85e3791a 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -6,7 +6,7 @@ #include "z_arrow_fire.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((ArrowFire*)thisx) diff --git a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c index f9c4fc178..8f1d75dde 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -7,7 +7,7 @@ #include "z_arrow_ice.h" #include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((ArrowIce*)thisx) diff --git a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c index b31185726..7d81b05a5 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c @@ -6,7 +6,7 @@ #include "z_arrow_light.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((ArrowLight*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c index c67eece3d..63a9e69dc 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c @@ -6,7 +6,7 @@ #include "z_bg_breakwall.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgBreakwall*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c index 82e9c8a15..c5613248a 100644 --- a/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c +++ b/src/overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.c @@ -6,7 +6,7 @@ #include "z_bg_crace_movebg.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgCraceMovebg*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c index a504db3f9..25b01a098 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c @@ -7,7 +7,7 @@ #include "z_bg_ctower_gear.h" #include "objects/object_ctower_rot/object_ctower_rot.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgCtowerGear*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c index d12c26b8a..f63442b1e 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c @@ -7,7 +7,7 @@ #include "z_bg_ctower_rot.h" #include "objects/object_ctower_rot/object_ctower_rot.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgCtowerRot*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c index 00219105b..1aada9272 100644 --- a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c +++ b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c @@ -6,7 +6,7 @@ #include "z_bg_danpei_movebg.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgDanpeiMovebg*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c b/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c index 977c3ed8b..af6ed5fa2 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c @@ -6,7 +6,7 @@ #include "z_bg_dblue_elevator.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgDblueElevator*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c index fac369ac6..0c124dc07 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c @@ -6,7 +6,7 @@ #include "z_bg_dblue_waterfall.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgDblueWaterfall*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c index 1423328a1..4e9bf5c63 100644 --- a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c +++ b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c @@ -6,7 +6,7 @@ #include "z_bg_dy_yoseizo.h" -#define FLAGS 0x02000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((BgDyYoseizo*)thisx) diff --git a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c index e916d005c..769118e69 100644 --- a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c +++ b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c @@ -6,7 +6,7 @@ #include "z_bg_f40_block.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgF40Block*)thisx) diff --git a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c index fb8736181..7805a6e54 100644 --- a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c +++ b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c @@ -6,7 +6,7 @@ #include "z_bg_f40_flift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgF40Flift*)thisx) diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c index 45cfbf74c..8bb351a97 100644 --- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c +++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c @@ -6,7 +6,7 @@ #include "z_bg_f40_switch.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgF40Switch*)thisx) diff --git a/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c b/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c index 672ba1f46..9d84f191c 100644 --- a/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c +++ b/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c @@ -6,7 +6,7 @@ #include "z_bg_f40_swlift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgF40Swlift*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c b/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c index 8bfdc7a2f..307d0fd0a 100644 --- a/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c +++ b/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.c @@ -7,7 +7,7 @@ #include "z_bg_fu_kaiten.h" #include "objects/object_fu_kaiten/object_fu_kaiten.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgFuKaiten*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c index 15ac358ca..a8d54222d 100644 --- a/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c +++ b/src/overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.c @@ -6,7 +6,7 @@ #include "z_bg_fu_mizu.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgFuMizu*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c index 648b4ff7d..d064a3cb4 100644 --- a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c +++ b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c @@ -7,7 +7,7 @@ #include "z_bg_goron_oyu.h" #include "objects/object_oyu/object_oyu.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgGoronOyu*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c index 1f39ce6ba..dc97a2151 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c +++ b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c @@ -7,7 +7,7 @@ #include "z_bg_haka_curtain.h" #include "objects/object_haka_obj/object_haka_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgHakaCurtain*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c index 862cf1611..06ac0520f 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c +++ b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c @@ -83,15 +83,15 @@ void func_80BD66AC(BgHakaTomb* this, GlobalContext* globalCtx) { s16 temp; if (Flags_GetClear(globalCtx, this->dyna.actor.room)) { - this->dyna.actor.flags |= 9; + this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); } if (!func_80BD6638(&temp, this->cutscenes, 1) && (temp < 0) && Flags_GetClear(globalCtx, this->dyna.actor.room)) { - this->dyna.actor.flags |= 1; + this->dyna.actor.flags |= ACTOR_FLAG_1; if (this->dyna.actor.isTargeted) { func_80BD6754(this); } } else { - this->dyna.actor.flags &= ~1; + this->dyna.actor.flags &= ~ACTOR_FLAG_1; } } diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.c b/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.c index 52e1e5614..b61f66bb6 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.c @@ -6,7 +6,7 @@ #include "z_bg_hakugin_elvpole.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgHakuginElvpole*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index 77e2aa660..6abaaf72c 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -7,7 +7,7 @@ #include "z_bg_hakugin_post.h" #include "objects/object_hakugin_obj/object_hakugin_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgHakuginPost*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c index f4ca155bd..d16c6c0db 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c @@ -6,7 +6,7 @@ #include "z_bg_hakugin_switch.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgHakuginSwitch*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c index 8ad7b2905..e3270fb6e 100644 --- a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c +++ b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c @@ -6,7 +6,7 @@ #include "z_bg_icefloe.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIcefloe*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c index 360e8b897..9d2fd67d9 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c @@ -6,7 +6,7 @@ #include "z_bg_ikana_block.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkanaBlock*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c index b1a0a19c1..f183a7164 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c @@ -6,7 +6,7 @@ #include "z_bg_ikana_bombwall.h" -#define FLAGS 0x10000000 +#define FLAGS (ACTOR_FLAG_10000000) #define THIS ((BgIkanaBombwall*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c index 1b222a2f8..2fb508c79 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c @@ -6,7 +6,7 @@ #include "z_bg_ikana_dharma.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkanaDharma*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c b/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c index 6b72aba38..de45de35b 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c @@ -6,7 +6,7 @@ #include "z_bg_ikana_mirror.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkanaMirror*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c index 55c87bafa..95e33a2ef 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c @@ -87,7 +87,7 @@ void BgIkanaRay_Destroy(Actor* thisx, GlobalContext* globalCtx) { void BgIkanaRay_SetDeactivated(BgIkanaRay* this) { this->actor.draw = NULL; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->update = BgIkanaRay_UpdateCheckForActivation; } @@ -99,7 +99,7 @@ void BgIkanaRay_UpdateCheckForActivation(BgIkanaRay* this, GlobalContext* global void BgIkanaRay_SetActivated(BgIkanaRay* this) { this->actor.draw = BgIkanaRay_Draw; - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; this->update = BgIkanaRay_UpdateActivated; } diff --git a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c index d37d09abf..16060bbd2 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Shutter/z_bg_ikana_shutter.c @@ -7,7 +7,7 @@ #include "z_bg_ikana_shutter.h" #include "objects/object_ikana_obj/object_ikana_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkanaShutter*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c index 2145a3a27..4a49be53c 100644 --- a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c +++ b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c @@ -7,7 +7,7 @@ #include "z_bg_iknin_susceil.h" #include "objects/object_ikninside_obj/object_ikninside_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgIkninSusceil*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c index 3b3b21172..a09bcba87 100644 --- a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c +++ b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c @@ -6,7 +6,7 @@ #include "z_bg_ikninside.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkninside*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c b/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c index 67d95a2e4..92a109925 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c +++ b/src/overlays/actors/ovl_Bg_Iknv_Doukutu/z_bg_iknv_doukutu.c @@ -6,7 +6,7 @@ #include "z_bg_iknv_doukutu.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgIknvDoukutu*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c index 515be1029..3707221dd 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c +++ b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c @@ -7,7 +7,7 @@ #include "z_bg_iknv_obj.h" #include "objects/object_iknv_obj/object_iknv_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIknvObj*)thisx) @@ -64,8 +64,8 @@ void BgIknvObj_Init(Actor* thisx, GlobalContext* globalCtx) { case IKNV_OBJ_WATERWHEEL: this->displayListPtr = object_iknv_obj_DL_013058; this->actionFunc = BgIknvObj_UpdateWaterwheel; - this->dyna.actor.flags |= 0x100000; - this->dyna.actor.flags |= 0x10; + this->dyna.actor.flags |= ACTOR_FLAG_100000; + this->dyna.actor.flags |= ACTOR_FLAG_10; break; case IKNV_OBJ_RAISED_DOOR: this->displayListPtr = object_iknv_obj_DL_011880; @@ -132,7 +132,7 @@ void BgIknvObj_UpdateWaterwheel(BgIknvObj* this, GlobalContext* globalCtx) { } if ((globalCtx->csCtx.state != 0) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.unk_12 == 4) && - (globalCtx->csCtx.frames == 0x5D7)) { + (globalCtx->csCtx.frames == 1495)) { func_8019F128(NA_SE_EV_DOOR_UNLOCK); } } diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index 152240528..d120c451e 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -6,7 +6,7 @@ #include "z_bg_ingate.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgIngate*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c b/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c index 620d55d38..9ae16fb1c 100644 --- a/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c +++ b/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.c @@ -7,7 +7,7 @@ #include "z_bg_inibs_movebg.h" #include "objects/object_inibs_object/object_inibs_object.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgInibsMovebg*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c b/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c index 5abeab5f0..5630bdd8f 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Bombwall/z_bg_kin2_bombwall.c @@ -6,7 +6,7 @@ #include "z_bg_kin2_bombwall.h" -#define FLAGS 0x10000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_10000000) #define THIS ((BgKin2Bombwall*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c index 4c832a775..d169be6de 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c @@ -7,7 +7,7 @@ #include "z_bg_kin2_fence.h" #include "objects/object_kin2_obj/object_kin2_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgKin2Fence*)thisx) @@ -122,16 +122,16 @@ static InitChainEntry sInitChain[] = { s32 BgKin2Fence_CheckHitMask(BgKin2Fence* this) { ColliderJntSphElement* elements = this->collider.elements; - if (elements[0].info.bumperFlags & 2) { + if (elements[0].info.bumperFlags & BUMP_HIT) { return 0; } - if (elements[1].info.bumperFlags & 2) { + if (elements[1].info.bumperFlags & BUMP_HIT) { return 1; } - if (elements[2].info.bumperFlags & 2) { + if (elements[2].info.bumperFlags & BUMP_HIT) { return 2; } - if (elements[3].info.bumperFlags & 2) { + if (elements[3].info.bumperFlags & BUMP_HIT) { return 3; } return -1; diff --git a/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c b/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c index 6fec6820a..de9b891ac 100644 --- a/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c +++ b/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c @@ -7,7 +7,7 @@ #include "z_bg_ladder.h" #include "objects/object_ladder/object_ladder.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgLadder*)thisx) @@ -71,7 +71,7 @@ void BgLadder_Init(Actor* thisx, GlobalContext* globalCtx) { if (Flags_GetSwitch(globalCtx, this->switchFlag)) { // If the flag is set, then the ladder draws immediately this->alpha = 255; - this->dyna.actor.flags &= ~0x10; // always update = off + this->dyna.actor.flags &= ~ACTOR_FLAG_10; // always update = off this->action = BgLadder_ActionIdle; } else { // Otherwise, the ladder doesn't draw; wait for the flag to be set @@ -115,7 +115,7 @@ void BgLadder_ActionFadeIn(BgLadder* this, GlobalContext* globalCtx) { this->alpha = 255; ActorCutscene_Stop(this->dyna.actor.cutscene); func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->dyna.actor.flags &= ~0x10; // always update = off + this->dyna.actor.flags &= ~ACTOR_FLAG_10; // always update = off this->action = BgLadder_ActionIdle; } } diff --git a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c index 7c1a086a2..5c2a972b5 100644 --- a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c +++ b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c @@ -99,7 +99,7 @@ void BgLotus_Wait(BgLotus* this, GlobalContext* globalCtx) { } if (gSaveContext.playerForm != PLAYER_FORM_DEKU) { this->timer = 40; - this->dyna.actor.flags |= 0x10; + this->dyna.actor.flags |= ACTOR_FLAG_10; this->actionFunc = BgLotus_Sink; return; } @@ -152,7 +152,7 @@ void BgLotus_WaitToAppear(BgLotus* this, GlobalContext* globalCtx) { func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); Actor_SetScale(&this->dyna.actor, 0.1f); this->dyna.actor.world.pos.y = CLAMP_MIN(this->height, this->dyna.actor.floorHeight); - this->dyna.actor.flags &= ~0x10; + this->dyna.actor.flags &= ~ACTOR_FLAG_10; this->timer2 = 96; this->actionFunc = BgLotus_Wait; this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x; diff --git a/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c b/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c index db363498c..e25aeaf67 100644 --- a/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c +++ b/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c @@ -7,7 +7,7 @@ #include "z_bg_market_step.h" #include "objects/object_market_obj/object_market_obj.h" -#define FLAGS 0x10000020 +#define FLAGS (ACTOR_FLAG_20 | ACTOR_FLAG_10000000) #define THIS ((BgMarketStep*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c index ecfc8ad02..f1fa69810 100644 --- a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c +++ b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c @@ -6,7 +6,7 @@ #include "z_bg_open_shutter.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgOpenShutter*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c index 8657a40db..b776253e6 100644 --- a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c +++ b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c @@ -6,7 +6,7 @@ #include "z_bg_open_spot.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgOpenSpot*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c index 8e443f529..15bac4d13 100644 --- a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c +++ b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c @@ -6,7 +6,7 @@ #include "z_bg_sinkai_kabe.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgSinkaiKabe*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c index 1e2f02112..3adec0ce4 100644 --- a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c +++ b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c @@ -7,7 +7,7 @@ #include "z_bg_tobira01.h" #include "objects/object_spot11_obj/object_spot11_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgTobira01*)thisx) diff --git a/src/overlays/actors/ovl_Boss_01/z_boss_01.c b/src/overlays/actors/ovl_Boss_01/z_boss_01.c index 467911ca9..4a6ef6e66 100644 --- a/src/overlays/actors/ovl_Boss_01/z_boss_01.c +++ b/src/overlays/actors/ovl_Boss_01/z_boss_01.c @@ -6,7 +6,7 @@ #include "z_boss_01.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss01*)thisx) diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index 7323a8630..d861e1cb1 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -10,7 +10,7 @@ #include "objects/object_boss02/object_boss02.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss02*)thisx) @@ -563,7 +563,7 @@ void Boss02_Init(Actor* thisx, GlobalContext* globalCtx) { globalCtx->specialEffects = (void*)D_809E0438; this->actor.update = func_809DC78C; this->actor.draw = func_809DD0A8; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_1D70 = 0.00999999977648f; if ((KREG(64) != 0) || (gSaveContext.eventInf[5] & 0x20) || (D_809E0434 != NULL)) { this->unk_1D20 = 0; @@ -732,7 +732,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_ROAR_OLD); } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; if (this->unk_0195 != 0) { this->actor.world.rot.z = Math_SinS(this->unk_014C * 0x1200) * 0xE00; } else { @@ -1152,9 +1152,9 @@ void func_809DC218(Actor* thisx, GlobalContext* globalCtx) { if ((this->actor.focus.pos.y < BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp20, &sp24)) || (D_809E0422 != 0)) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } } } @@ -1771,7 +1771,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { func_80169AFC(globalCtx, this->unk_1D22, 0); this->unk_1D22 = 0; func_800EA0EC(globalCtx, &globalCtx->csCtx); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; player->stateFlags1 &= ~0x100; this->unk_1D70 = 0.01f; func_80165690(); @@ -2165,7 +2165,7 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { this->unk_1D22 = 0; func_800EA0EC(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_1D20 = 0; D_809E0424->unk_0144 = D_809E0428->unk_0144 = 3; D_809E0424->unk_0146[0] = D_809E0428->unk_0146[0] = 60; @@ -2227,7 +2227,7 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { func_800EA0EC(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); this->unk_1D20 = 0; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; sp68->unk_0144 = 10; if ((D_809E0424->unk_0144 >= 10) && (D_809E0428->unk_0144 >= 10)) { f32 phi_f0; diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.c b/src/overlays/actors/ovl_Boss_03/z_boss_03.c index ce8551aa7..70a6405bc 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -6,7 +6,7 @@ #include "z_boss_03.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss03*)thisx) 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 67ea1702e..eb7b02ada 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -7,7 +7,7 @@ #include "z_boss_04.h" #include "objects/object_boss04/object_boss04.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss04*)thisx) @@ -231,7 +231,7 @@ void Boss04_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_809EC544(Boss04* this) { this->actionFunc = func_809EC568; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } void func_809EC568(Boss04* this, GlobalContext* globalCtx) { @@ -521,7 +521,7 @@ void func_809ED224(Boss04* this) { this->unk_2D0 = 10000.0f; this->unk_2C8 = 200; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_DEAD); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; func_801A2ED8(); this->unk_1F6 = 10; } @@ -542,7 +542,7 @@ void func_809ED2A0(Boss04* this, GlobalContext* globalCtx) { } if (this->unk_1F8 == 3) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_700 = 0.0f; this->unk_6FC = 0.0f; this->unk_6F8 = 0.0f; @@ -747,9 +747,9 @@ void Boss04_Update(Actor* thisx, GlobalContext* globalCtx2) { func_809ED45C(this, globalCtx); if (this->unk_2CC > 3000.0f) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } else { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); diff --git a/src/overlays/actors/ovl_Boss_05/z_boss_05.c b/src/overlays/actors/ovl_Boss_05/z_boss_05.c index a8122fdaa..a88ad8008 100644 --- a/src/overlays/actors/ovl_Boss_05/z_boss_05.c +++ b/src/overlays/actors/ovl_Boss_05/z_boss_05.c @@ -6,7 +6,7 @@ #include "z_boss_05.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((Boss05*)thisx) diff --git a/src/overlays/actors/ovl_Boss_07/z_boss_07.c b/src/overlays/actors/ovl_Boss_07/z_boss_07.c index d5e0e22ed..9e8841034 100644 --- a/src/overlays/actors/ovl_Boss_07/z_boss_07.c +++ b/src/overlays/actors/ovl_Boss_07/z_boss_07.c @@ -6,7 +6,7 @@ #include "z_boss_07.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss07*)thisx) diff --git a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c index 333d2a89f..d8ebaf7eb 100644 --- a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c +++ b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c @@ -6,7 +6,7 @@ #include "z_boss_hakugin.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BossHakugin*)thisx) diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c index 94bbef096..18be6991c 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c @@ -6,7 +6,7 @@ #include "z_demo_effect.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoEffect*)thisx) diff --git a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c index 71f0d9204..9e6661fd0 100644 --- a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c +++ b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c @@ -6,7 +6,7 @@ #include "z_demo_getitem.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoGetitem*)thisx) diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index c0e1781e5..028daa2ec 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -8,7 +8,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_bubble/object_bubble.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoKankyo*)thisx) diff --git a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c index ab3cf474f..9ed7a0c27 100644 --- a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c +++ b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c @@ -6,7 +6,7 @@ #include "z_demo_moonend.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoMoonend*)thisx) diff --git a/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c b/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c index f7001b489..faedc1b74 100644 --- a/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c +++ b/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c @@ -6,7 +6,7 @@ #include "z_demo_shd.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoShd*)thisx) diff --git a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c index a22d0f8c6..a4c9b9dc3 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c @@ -6,7 +6,7 @@ #include "z_demo_syoten.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoSyoten*)thisx) diff --git a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c index d4ce73419..060a201d7 100644 --- a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c +++ b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c @@ -6,7 +6,7 @@ #include "z_demo_tre_lgt.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((DemoTreLgt*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c index 3a84e6b39..ede7baa1d 100644 --- a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c +++ b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c @@ -6,7 +6,7 @@ #include "z_dm_ah.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((DmAh*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Al/z_dm_al.c b/src/overlays/actors/ovl_Dm_Al/z_dm_al.c index f61a8f74e..d289b99ec 100644 --- a/src/overlays/actors/ovl_Dm_Al/z_dm_al.c +++ b/src/overlays/actors/ovl_Dm_Al/z_dm_al.c @@ -6,7 +6,7 @@ #include "z_dm_al.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((DmAl*)thisx) diff --git a/src/overlays/actors/ovl_Dm_An/z_dm_an.c b/src/overlays/actors/ovl_Dm_An/z_dm_an.c index 865cbeef0..e6175bfd9 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.c +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.c @@ -6,7 +6,7 @@ #include "z_dm_an.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((DmAn*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c index 4394c6109..aa4abb91d 100644 --- a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c +++ b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c @@ -6,7 +6,7 @@ #include "z_dm_bal.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((DmBal*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c index 116b2732d..72258b70b 100644 --- a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c +++ b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c @@ -6,7 +6,7 @@ #include "z_dm_char02.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar02*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c index b5e6c8742..1508f95a2 100644 --- a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c +++ b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c @@ -6,7 +6,7 @@ #include "z_dm_char03.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar03*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c index e2c72238e..eff96b7e5 100644 --- a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c +++ b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c @@ -6,7 +6,7 @@ #include "z_dm_char04.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar04*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c index 5258a0f1e..bcf593de9 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c @@ -7,7 +7,7 @@ #include "z_dm_char05.h" #include "objects/object_dmask/object_dmask.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar05*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c index 1518cd4b4..e35328af0 100644 --- a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c +++ b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c @@ -6,7 +6,7 @@ #include "z_dm_char06.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar06*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c b/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c index 290f5a797..d2aac5a7c 100644 --- a/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c +++ b/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c @@ -7,7 +7,7 @@ #include "z_dm_char07.h" #include "objects/object_milkbar/object_milkbar.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar07*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c b/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c index aa0357ef2..f944c9c63 100644 --- a/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c +++ b/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c @@ -6,7 +6,7 @@ #include "z_dm_char08.h" -#define FLAGS 0x02000000 +#define FLAGS (ACTOR_FLAG_2000000) #define THIS ((DmChar08*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c index 490800ea9..7fb20d1a0 100644 --- a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c +++ b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c @@ -6,7 +6,7 @@ #include "z_dm_char09.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar09*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c index c6499f0ee..c2edb33a0 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c @@ -6,7 +6,7 @@ #include "z_dm_gm.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((DmGm*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c b/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c index 187e93514..a30e83620 100644 --- a/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c +++ b/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c @@ -6,7 +6,7 @@ #include "z_dm_hina.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmHina*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c index e72691395..5603df165 100644 --- a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c +++ b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c @@ -7,7 +7,7 @@ #include "z_dm_nb.h" #include "objects/object_nb/object_nb.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((DmNb*)thisx) @@ -74,7 +74,7 @@ void DmNb_Init(Actor* thisx, GlobalContext* globalCtx) { 8); this->unk1F0 = -1; func_80C1DED0(this, 0); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_80C1DF18; } diff --git a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c index 6f22be2ff..ef81bc467 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c @@ -6,7 +6,7 @@ #include "z_dm_opstage.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmOpstage*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c index fca8d1452..4c39ddd54 100644 --- a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c +++ b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c @@ -6,7 +6,7 @@ #include "z_dm_ravine.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmRavine*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c index 7f3d3d63c..4d5a20114 100644 --- a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c +++ b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c @@ -7,7 +7,7 @@ #include "z_dm_sa.h" #include "objects/object_stk/object_stk.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmSa*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c b/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c index d4ca48e11..6c9d11170 100644 --- a/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c +++ b/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c @@ -7,7 +7,7 @@ #include "z_dm_statue.h" #include "objects/object_smtower/object_smtower.h" -#define FLAGS 0x04000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_4000000) #define THIS ((DmStatue*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index ec46e86d6..359efcf56 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -9,7 +9,7 @@ #include "objects/object_stk2/object_stk2.h" #include "objects/object_stk3/object_stk3.h" -#define FLAGS 0x02000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((DmStk*)thisx) @@ -1477,7 +1477,7 @@ void func_80AA2720(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state == 0) { func_80AA1AF8(this, globalCtx); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_328++; if (this->unk_328 > 800) { this->unk_328 = 0; @@ -1495,7 +1495,7 @@ void func_80AA2720(DmStk* this, GlobalContext* globalCtx) { void func_80AA27EC(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state == 0) { func_80AA1AF8(this, globalCtx); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; if (this->unk_2E0 == 33) { this->actor.targetArrowOffset = 3100.0f; diff --git a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c index 80eb930fd..6290b41e0 100644 --- a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c +++ b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c @@ -6,7 +6,7 @@ #include "z_dm_tag.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((DmTag*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c b/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c index b3c11b83e..9ed86ba2c 100644 --- a/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c +++ b/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c @@ -6,7 +6,7 @@ #include "z_dm_tsg.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmTsg*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c index 993dbc320..fc9d21b3d 100644 --- a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c +++ b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c @@ -6,7 +6,7 @@ #include "z_dm_zl.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((DmZl*)thisx) diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c index 05b79fb63..70bd7e1c0 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -7,7 +7,7 @@ #include "z_door_ana.h" #include "objects/gameplay_field_keep/gameplay_field_keep.h" -#define FLAGS 0x02000000 +#define FLAGS (ACTOR_FLAG_2000000) #define THIS ((DoorAna*)thisx) @@ -71,7 +71,7 @@ void DoorAna_Init(Actor* thisx, GlobalContext* globalCtx) { if (grottoType == DOORANA_TYPE_HIDDEN) { Collider_InitAndSetCylinder(globalCtx, &this->bombCollider, &this->actor, &sCylinderInit); } else { - this->actor.flags |= 0x10; // always update + this->actor.flags |= ACTOR_FLAG_10; // always update } Actor_SetScale(&this->actor, 0); @@ -99,9 +99,9 @@ void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { if (grottoType == DOORANA_TYPE_UNK) { // in OOT decomp its marked as open with storms, but does not seem to open with storms in MM - if ((this->actor.xyzDistToPlayerSq < 40000.0f) && (EnvFlags_Get(globalCtx, 5))) { + if ((this->actor.xyzDistToPlayerSq < SQ(200.0f)) && (EnvFlags_Get(globalCtx, 5))) { grottoIsOpen = 1; - this->actor.flags &= ~0x10; // always update OFF + this->actor.flags &= ~ACTOR_FLAG_10; // always update OFF } } else { diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index 44f699298..44b7d0bbd 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -6,7 +6,7 @@ #include "z_door_shutter.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((DoorShutter*)thisx) diff --git a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c index 27d8bd211..5f0dbc6b0 100644 --- a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c +++ b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c @@ -12,7 +12,7 @@ #include "objects/object_ikninside_obj/object_ikninside_obj.h" #include "objects/object_danpei_object/object_danpei_object.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((DoorSpiral*)thisx) @@ -125,7 +125,7 @@ s32 DoorSpiral_SetSpiralType(DoorSpiral* this, GlobalContext* globalCtx) { this->spiralType = SPIRAL_WOODFALL_TEMPLE_ALT; } - this->actor.flags |= 0x10000000; + this->actor.flags |= ACTOR_FLAG_10000000; } DoorSpiral_SetupAction(this, DoorSpiral_Wait); diff --git a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c index 45a62ed72..d7bd601f0 100644 --- a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c +++ b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c @@ -6,7 +6,7 @@ #include "z_eff_change.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EffChange*)thisx) diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c index 7582a378a..e53635603 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -8,7 +8,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "system_malloc.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EffDust*)thisx) diff --git a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c index faea4c4e4..687ae1b96 100644 --- a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c +++ b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c @@ -6,7 +6,7 @@ #include "z_eff_kamejima_wave.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EffKamejimaWave*)thisx) diff --git a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c index 4f9138aa7..3901c0179 100644 --- a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c +++ b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c @@ -6,7 +6,7 @@ #include "z_eff_lastday.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EffLastday*)thisx) diff --git a/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c b/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c index b02e52e57..b54bba577 100644 --- a/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c +++ b/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c @@ -6,7 +6,7 @@ #include "z_eff_stk.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EffStk*)thisx) diff --git a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c index 6da3885be..8ed8c6db4 100644 --- a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c +++ b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c @@ -6,7 +6,7 @@ #include "z_eff_zoraband.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EffZoraband*)thisx) diff --git a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c index d3d0317ae..372a21d11 100644 --- a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c +++ b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c @@ -6,7 +6,7 @@ #include "z_elf_msg.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg*)thisx) diff --git a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c index ece5b9a5c..5397ca5d6 100644 --- a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c +++ b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c @@ -6,7 +6,7 @@ #include "z_elf_msg2.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg2*)thisx) diff --git a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c index 95942b815..dc0e5eb72 100644 --- a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c +++ b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c @@ -6,7 +6,7 @@ #include "z_elf_msg3.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg3*)thisx) diff --git a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c index c55591fba..ca7981362 100644 --- a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c +++ b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c @@ -6,7 +6,7 @@ #include "z_elf_msg4.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg4*)thisx) diff --git a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c index 3fc56c89b..aceb36807 100644 --- a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c +++ b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c @@ -6,7 +6,7 @@ #include "z_elf_msg5.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg5*)thisx) diff --git a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c index ecd927765..e7daab294 100644 --- a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c +++ b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c @@ -6,7 +6,7 @@ #include "z_elf_msg6.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg6*)thisx) diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index 19a2aaf2d..b7bec3f69 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -6,7 +6,7 @@ #include "z_en_ah.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnAh*)thisx) diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c index ccbfae14f..e8e78d650 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -7,7 +7,7 @@ #include "z_en_akindonuts.h" #include "objects/object_dnt/object_dnt.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnAkindonuts*)thisx) @@ -257,16 +257,16 @@ void func_80BED090(GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (player->transformation == PLAYER_FORM_DEKU) { - gSaveContext.weekEventReg[63] |= 0x8; + gSaveContext.weekEventReg[63] |= 8; gSaveContext.weekEventReg[63] &= (u8)~0x10; } else if (player->transformation == PLAYER_FORM_ZORA) { - gSaveContext.weekEventReg[63] &= (u8)~0x8; + gSaveContext.weekEventReg[63] &= (u8)~8; gSaveContext.weekEventReg[63] |= 0x10; } else if (player->transformation == PLAYER_FORM_GORON) { - gSaveContext.weekEventReg[63] |= 0x8; + gSaveContext.weekEventReg[63] |= 8; gSaveContext.weekEventReg[63] |= 0x10; } else if (player->transformation == PLAYER_FORM_HUMAN) { - gSaveContext.weekEventReg[63] &= (u8)~0x8; + gSaveContext.weekEventReg[63] &= (u8)~8; gSaveContext.weekEventReg[63] &= (u8)~0x10; } } @@ -275,19 +275,19 @@ s32 func_80BED140(GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (player->transformation == PLAYER_FORM_DEKU) { - if ((gSaveContext.weekEventReg[63] & 0x8) && !(gSaveContext.weekEventReg[63] & 0x10)) { + if ((gSaveContext.weekEventReg[63] & 8) && !(gSaveContext.weekEventReg[63] & 0x10)) { return true; } } else if (player->transformation == PLAYER_FORM_ZORA) { - if (!(gSaveContext.weekEventReg[63] & 0x8) && (gSaveContext.weekEventReg[63] & 0x10)) { + if (!(gSaveContext.weekEventReg[63] & 8) && (gSaveContext.weekEventReg[63] & 0x10)) { return true; } } else if (player->transformation == PLAYER_FORM_GORON) { - if ((gSaveContext.weekEventReg[63] & 0x8) && (gSaveContext.weekEventReg[63] & 0x10)) { + if ((gSaveContext.weekEventReg[63] & 8) && (gSaveContext.weekEventReg[63] & 0x10)) { return true; } } else if (player->transformation == PLAYER_FORM_HUMAN) { - if (!(gSaveContext.weekEventReg[63] & 0x8) && !(gSaveContext.weekEventReg[63] & 0x10)) { + if (!(gSaveContext.weekEventReg[63] & 8) && !(gSaveContext.weekEventReg[63] & 0x10)) { return true; } } @@ -641,7 +641,7 @@ void func_80BEDB88(EnAkindonuts* this, GlobalContext* globalCtx) { switch (this->unk_33C) { case 0: if ((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.weekEventReg[62] & 2)) { - gSaveContext.weekEventReg[62] |= 0x2; + gSaveContext.weekEventReg[62] |= 2; this->unk_33C = 0x15F0; break; } @@ -796,7 +796,7 @@ void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x15FA: this->unk_33C = 0x160D; - gSaveContext.weekEventReg[62] |= 0x4; + gSaveContext.weekEventReg[62] |= 4; this->unk_32C |= 0x20; break; @@ -1252,7 +1252,7 @@ void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80BEEE10; } else if (this->unk_32C & 0x20) { this->unk_32C &= ~0x20; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_32C &= ~0x4; globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; diff --git a/src/overlays/actors/ovl_En_An/z_en_an.c b/src/overlays/actors/ovl_En_An/z_en_an.c index 43ea5744a..9144d34fa 100644 --- a/src/overlays/actors/ovl_En_An/z_en_an.c +++ b/src/overlays/actors/ovl_En_An/z_en_an.c @@ -6,7 +6,7 @@ #include "z_en_an.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnAn*)thisx) diff --git a/src/overlays/actors/ovl_En_And/z_en_and.c b/src/overlays/actors/ovl_En_And/z_en_and.c index ad0291e7d..437bd1750 100644 --- a/src/overlays/actors/ovl_En_And/z_en_and.c +++ b/src/overlays/actors/ovl_En_And/z_en_and.c @@ -6,7 +6,7 @@ #include "z_en_and.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnAnd*)thisx) diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index f988cfa76..89ed13d96 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Dg/z_en_dg.h" #include "objects/object_aob/object_aob.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnAob01*)thisx) @@ -497,7 +497,7 @@ void func_809C2060(EnAob01* this, GlobalContext* globalCtx) { if (func_809C15BC(this)) { if (func_809C2EC4(this, globalCtx) && !(this->unk_2D2 & 0x100)) { if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 100.0f); this->unk_2D2 |= 8; this->actionFunc = func_809C21E0; @@ -531,7 +531,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { } this->actor.textId = 0; this->unk_2D2 &= ~8; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = func_809C2060; return; } @@ -546,7 +546,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { if (this->unk_2D2 & 8) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_80123E90(globalCtx, &this->actor); if (this->unk_2D2 & 4) { func_809C16DC(this, globalCtx); @@ -703,7 +703,7 @@ void func_809C2824(EnAob01* this, GlobalContext* globalCtx) { void func_809C28B8(EnAob01* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_80123E90(globalCtx, &this->actor); this->unk_434 = gSaveContext.unk_3F5C; switch ((gSaveContext.eventInf[0] & 0xF8) >> 3) { @@ -937,7 +937,7 @@ void EnAob01_Init(Actor* thisx, GlobalContext* globalCtx) { case 0: func_809C2FA0(); func_809C11EC(this, globalCtx); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_809C2060; break; @@ -948,7 +948,7 @@ void EnAob01_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_430 = this->actor.cutscene; func_809C2594(this, globalCtx); ActorCutscene_SetIntentToPlay(this->unk_430); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; func_809C2F34(this, globalCtx); this->actionFunc = func_809C2824; break; @@ -956,8 +956,8 @@ void EnAob01_Init(Actor* thisx, GlobalContext* globalCtx) { case 3: func_809C2FA0(); func_809C11EC(this, globalCtx); - this->actor.flags |= 1; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_809C28B8; break; } diff --git a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c index 5eca6c796..90e99b5ea 100644 --- a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c +++ b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c @@ -6,7 +6,7 @@ #include "z_en_attack_niw.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnAttackNiw*)thisx) diff --git a/src/overlays/actors/ovl_En_Az/z_en_az.c b/src/overlays/actors/ovl_En_Az/z_en_az.c index c5f687498..f815991c1 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.c +++ b/src/overlays/actors/ovl_En_Az/z_en_az.c @@ -6,7 +6,7 @@ #include "z_en_az.h" -#define FLAGS 0x80000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) #define THIS ((EnAz*)thisx) diff --git a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c index f6a2895aa..8e70d5d6b 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c @@ -7,7 +7,7 @@ #include "z_en_baguo.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnBaguo*)thisx) @@ -146,8 +146,8 @@ void EnBaguo_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = -3000.0f; this->actor.gravity = -3.0f; this->actor.colChkInfo.damageTable = &sDamageTable; - this->actor.flags |= 0x8000000; - this->actor.flags &= ~1; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; this->collider.base.acFlags |= AC_HARD; this->actionFunc = EnBaguo_UndergroundIdle; } @@ -165,8 +165,8 @@ void EnBaguo_UndergroundIdle(EnBaguo* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_APPEAR); this->actor.world.rot.z = 0; this->actor.world.rot.x = this->actor.world.rot.z; - this->actor.flags &= ~0x8000000; - this->actor.flags |= 1; + this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = EnBaguo_EmergeFromUnderground; } this->actor.shape.rot.y = this->actor.world.rot.y; @@ -293,8 +293,8 @@ void EnBaguo_RetreatUnderground(EnBaguo* this, GlobalContext* globalCtx) { this->actor.draw = EnBaguo_DrawBody; Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_APPEAR); - this->actor.flags |= 0x8000000; - this->actor.flags &= ~1; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = EnBaguo_UndergroundIdle; } } @@ -352,8 +352,8 @@ void EnBaguo_CheckForDetonation(EnBaguo* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_DEAD); this->timer = 30; - this->actor.flags |= 0x8000000; - this->actor.flags &= ~1; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, 0.0f); this->collider.elements->dim.scale = 3.0f; this->collider.elements->info.toucher.damage = 8; diff --git a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c index f052362ac..dc7bca14c 100644 --- a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c +++ b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c @@ -7,7 +7,7 @@ #include "z_en_baisen.h" #include "objects/object_bai/object_bai.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnBaisen*)thisx) diff --git a/src/overlays/actors/ovl_En_Bal/z_en_bal.c b/src/overlays/actors/ovl_En_Bal/z_en_bal.c index dbfa561c6..2f57c2804 100644 --- a/src/overlays/actors/ovl_En_Bal/z_en_bal.c +++ b/src/overlays/actors/ovl_En_Bal/z_en_bal.c @@ -6,7 +6,7 @@ #include "z_en_bal.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBal*)thisx) diff --git a/src/overlays/actors/ovl_En_Bat/z_en_bat.c b/src/overlays/actors/ovl_En_Bat/z_en_bat.c index a419d2901..ab76d88c8 100644 --- a/src/overlays/actors/ovl_En_Bat/z_en_bat.c +++ b/src/overlays/actors/ovl_En_Bat/z_en_bat.c @@ -6,7 +6,7 @@ #include "z_en_bat.h" -#define FLAGS 0x00005005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) #define THIS ((EnBat*)thisx) diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index cd8c7cac8..1ce821f66 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -6,7 +6,7 @@ #include "z_en_bb.h" -#define FLAGS 0x00000205 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200) #define THIS ((EnBb*)thisx) diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index 0ee8d32e3..963290504 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -6,7 +6,7 @@ #include "z_en_bba_01.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBba01*)thisx) diff --git a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c index 080579156..8af8e650a 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c @@ -6,7 +6,7 @@ #include "z_en_bbfall.h" -#define FLAGS 0x00000215 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_200) #define THIS ((EnBbfall*)thisx) diff --git a/src/overlays/actors/ovl_En_Bee/z_en_bee.c b/src/overlays/actors/ovl_En_Bee/z_en_bee.c index 1bf4d8d8c..ecb64cb91 100644 --- a/src/overlays/actors/ovl_En_Bee/z_en_bee.c +++ b/src/overlays/actors/ovl_En_Bee/z_en_bee.c @@ -6,7 +6,7 @@ #include "z_en_bee.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnBee*)thisx) diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c index 1ecc3d380..019332000 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -7,7 +7,7 @@ #include "z_en_bigokuta.h" #include "assets/objects/object_bigokuta/object_bigokuta.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnBigokuta*)thisx) diff --git a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c index 7608bed53..2fbd60927 100644 --- a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c +++ b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c @@ -6,7 +6,7 @@ #include "z_en_bigpamet.h" -#define FLAGS 0x00000435 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_400) #define THIS ((EnBigpamet*)thisx) diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index a2ba96654..2ce46e1ed 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -8,7 +8,7 @@ #include "objects/object_bigpo/object_bigpo.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00001215 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_200 | ACTOR_FLAG_1000) #define THIS ((EnBigpo*)thisx) @@ -283,7 +283,7 @@ void EnBigpo_LowerCutsceneSubCamera(EnBigpo* this, GlobalContext* globalContext) } void EnBigpo_InitWellBigpo(EnBigpo* this) { - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->actionFunc = EnBigpo_WellWaitForProximity; this->fireRadius = 200.0f; } @@ -483,7 +483,7 @@ void EnBigpo_SetupWarpOut(EnBigpo* this) { this->collider.base.ocFlags1 &= ~OC1_ON; this->rotVelocity = 0x2000; this->idleTimer = 32; - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->actor.speedXZ = 0.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DISAPPEAR); this->actionFunc = EnBigpo_WarpingOut; @@ -544,7 +544,7 @@ void EnBigpo_SetupIdleFlying(EnBigpo* this) { this->actor.world.rot.y = this->actor.shape.rot.y; this->collider.base.acFlags |= AC_ON; this->collider.base.ocFlags1 |= OC1_ON; - this->actor.flags |= 0x1; // targetable ON + this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnBigpo_IdleFlying; } @@ -745,7 +745,7 @@ void EnBigpo_SetupLanternDrop(EnBigpo* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; this->actor.world.pos.y -= 15.0f; func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_MISC); - this->actor.flags &= ~(0x1 | 0x4); // targetable OFF, enemy music OFF + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); // targetable OFF, enemy music OFF this->actor.bgCheckFlags &= ~0x400; this->actionFunc = EnBigpo_LanternFalling; } @@ -813,8 +813,8 @@ void EnBigpo_ScoopSoulAppearing(EnBigpo* this, GlobalContext* globalCtx) { void EnBigpo_SetupScoopSoulIdle(EnBigpo* this) { this->savedHeight = this->actor.world.pos.y; Actor_SetFocus(&this->actor, -10.0f); - this->idleTimer = 400; // 20 seconds - this->actor.flags |= 0x1; // targetable ON + this->idleTimer = 400; // 20 seconds + this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnBigpo_ScoopSoulIdle; } @@ -833,7 +833,7 @@ void EnBigpo_ScoopSoulIdle(EnBigpo* this, GlobalContext* globalCtx) { } void EnBigpo_SetupScoopSoulLeaving(EnBigpo* this) { - this->actor.flags &= ~(0x1 | 0x10000); // targetable OFF and unknown OFF + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_10000); // targetable OFF and unknown OFF this->actionFunc = EnBigpo_ScoopSoulFadingAway; } @@ -845,7 +845,7 @@ void EnBigpo_ScoopSoulFadingAway(EnBigpo* this, GlobalContext* globalCtx) { } void EnBigpo_InitDampeMainPo(EnBigpo* this) { - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->actionFunc = EnBigpo_SelectRandomFireLocations; } @@ -891,7 +891,7 @@ void EnBigpo_SelectRandomFireLocations(EnBigpo* this, GlobalContext* globalCtx) randomFirePo->actor.update = EnBigpo_UpdateFire; func_800BC154(globalCtx, &globalCtx->actorCtx, &randomFirePo->actor, ACTORCAT_PROP); randomFirePo->unk20C = fireIndex; - randomFirePo->actor.flags &= ~0x1; // targetable OFF + randomFirePo->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF // make invisible by size: 0 Actor_SetScale(&randomFirePo->actor, 0); @@ -1124,7 +1124,7 @@ s32 EnBigpo_ApplyDamage(EnBigpo* this, GlobalContext* globalCtx) { } if (Actor_ApplyDamage(&this->actor) == 0) { - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DEAD); Enemy_StartFinishingBlow(globalCtx, &this->actor); if (this->actor.params == ENBIGPO_SUMMONED) { // dampe type @@ -1153,7 +1153,7 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; ColliderCylinder* thisCollider; - if ((this->actor.flags & 0x2000) == 0x2000) { + if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { this->hoverHeightCycleTimer = 0; this->savedHeight = this->actor.world.pos.y; } diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index ad55a9df7..97f687dad 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -9,7 +9,7 @@ #include "objects/object_bigslime/object_bigslime.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000235 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200) #define THIS ((EnBigslime*)thisx) @@ -371,7 +371,7 @@ void EnBigslime_Init(Actor* thisx, GlobalContext* globalCtx2) { this->bigslimeFrozenTexAnim = Lib_SegmentedToVirtual(&gBigslimeFrozenTexAnim); this->iceShardTexAnim = Lib_SegmentedToVirtual(&gBigslimeIceShardTexAnim); this->actor.world.pos.y = GBT_ROOM_5_MIN_Y; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.shape.shadowAlpha = 255; this->gekkoScale = 0.007f; this->actor.shape.rot.y = 0; @@ -763,8 +763,8 @@ void EnBigslime_BreakIntoMinislime(EnBigslime* this, GlobalContext* globalCtx) { EnBigslime_SetPlayerParams(this, globalCtx); EnBigslime_EndCutscene(this, globalCtx); this->actor.colChkInfo.mass = 50; - this->actor.flags &= ~(0x1 | 0x400); - this->actor.flags |= 0x200; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_400); + this->actor.flags |= ACTOR_FLAG_200; this->actor.hintId = 95; this->gekkoRot.x = 0; this->gekkoRot.y = 0; @@ -913,7 +913,7 @@ void EnBigslime_GekkoFreeze(EnBigslime* this) { this->unk_38C = 0.75f; this->unk_390 = 1.125f; this->unk_388 = 1.0f; - this->actor.flags &= ~0x200; + this->actor.flags &= ~ACTOR_FLAG_200; } void EnBigslime_GekkoThaw(EnBigslime* this, GlobalContext* globalCtx) { @@ -923,7 +923,7 @@ void EnBigslime_GekkoThaw(EnBigslime* this, GlobalContext* globalCtx) { this->gekkoCollider.info.elemType = ELEMTYPE_UNK1; this->unk_388 = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); - this->actor.flags |= 0x200; + this->actor.flags |= ACTOR_FLAG_200; } } @@ -1000,7 +1000,7 @@ void EnBigslime_CallMinislime(EnBigslime* this, GlobalContext* globalCtx) { if (this->callTimer == 0) { EnBigslime_EndCutscene(this, globalCtx); this->formBigslimeTimer = 2; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; EnBigslime_SetupIdleNoticePlayer(this); } } else if (this->isAnimUpdate) { @@ -1030,7 +1030,7 @@ void EnBigslime_SetupMoveOnCeiling(EnBigslime* this) { this->wavySurfaceTimer = 0; this->bigslimeCollider[0].base.acFlags |= AC_ON; this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.flags &= ~0x200; + this->actor.flags &= ~ACTOR_FLAG_200; this->actionFunc = EnBigslime_MoveOnCeiling; } @@ -2039,7 +2039,7 @@ void EnBigslime_JumpGekko(EnBigslime* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { this->gekkoCollider.base.acFlags |= AC_ON; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } this->jumpTimer--; @@ -2176,8 +2176,8 @@ void EnBigslime_SetupDamageGekko(EnBigslime* this, s32 isNotFrozen) { } EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_DAMAGE); - if ((this->actor.flags & 0x2000) == 0x2000) { - this->actor.flags &= ~0x2000; + if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + this->actor.flags &= ~ACTOR_FLAG_2000; } this->actionFunc = EnBigslime_DamageGekko; @@ -2350,7 +2350,7 @@ void EnBigslime_SetupCutsceneDefeat(EnBigslime* this, GlobalContext* globalCtx) this->minislime[i]->actor.params = MINISLIME_DEFEAT_IDLE; } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; EnBigslime_GekkoThaw(this, globalCtx); this->actionFunc = EnBigslime_CutsceneDefeat; } diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 145dc2311..42e50ea62 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -7,7 +7,7 @@ #include "z_en_bji_01.h" #include "objects/object_bji/object_bji.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBji01*)thisx) @@ -93,9 +93,9 @@ void func_809CCEE8(EnBji01* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 0x444); if (this->actor.params == ENBJI01_PARAMS_DEFAULT) { if ((this->actor.xzDistToPlayer <= 60.0f) && (this->actor.playerHeightRel <= 10.0f)) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; } else { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { @@ -208,7 +208,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { break; case 4: if (func_80147624(globalCtx) != 0) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.params = ENBJI01_PARAMS_FINISHED_CONVERSATION; switch (globalCtx->msgCtx.choiceIndex) { case 0: @@ -236,7 +236,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { break; case 5: if (func_80147624(globalCtx) != 0) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; switch (globalCtx->msgCtx.unk11F04) { case 0x5DE: SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 3, &this->animationIndex); @@ -276,7 +276,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { case 0x5F7: case 0x5F8: func_801477B4(globalCtx); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.params = ENBJI01_PARAMS_FINISHED_CONVERSATION; func_809CCE98(this, globalCtx); break; @@ -285,7 +285,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { break; case 6: this->actor.params = ENBJI01_PARAMS_FINISHED_CONVERSATION; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_809CCE98(this, globalCtx); break; } @@ -352,7 +352,7 @@ void EnBji01_Init(Actor* thisx, GlobalContext* globalCtx) { func_809CCE98(this, globalCtx); break; case 0x4C20: /* Observatory from Termina Field telescope */ - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_801A5BD0(0); Audio_QueueSeqCmd(0xE0000100); this->actor.params = ENBJI01_PARAMS_LOOKED_THROUGH_TELESCOPE; diff --git a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c index f4814fac2..dedb09d4c 100644 --- a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c +++ b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c @@ -6,7 +6,7 @@ #include "z_en_bjt.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnBjt*)thisx) diff --git a/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c b/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c index e070bea5e..5d827f4da 100644 --- a/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c +++ b/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c @@ -6,7 +6,7 @@ #include "z_en_boj_01.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBoj01*)thisx) diff --git a/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c b/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c index 9899a15e0..8e26fa09c 100644 --- a/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c +++ b/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c @@ -6,7 +6,7 @@ #include "z_en_boj_02.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBoj02*)thisx) diff --git a/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c b/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c index 019f80538..4f9325e9d 100644 --- a/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c +++ b/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c @@ -6,7 +6,7 @@ #include "z_en_boj_03.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBoj03*)thisx) diff --git a/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c b/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c index 9952f706d..09eed96c7 100644 --- a/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c +++ b/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c @@ -6,7 +6,7 @@ #include "z_en_boj_04.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBoj04*)thisx) diff --git a/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c b/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c index a3a9dcff8..d6ccba734 100644 --- a/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c +++ b/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c @@ -6,7 +6,7 @@ #include "z_en_boj_05.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBoj05*)thisx) diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/src/overlays/actors/ovl_En_Bom/z_en_bom.c index ad3d37973..7d9b0a6b3 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -7,7 +7,7 @@ #include "z_en_bom.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnBom*)thisx) @@ -169,7 +169,7 @@ void EnBom_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider2.elements[0].dim.worldSphere.center.y = this->actor.world.pos.y; this->collider2.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; - this->actor.flags |= 0x100000; + this->actor.flags |= ACTOR_FLAG_100000; if (Actor_HasParent(&this->actor, globalCtx)) { this->actionFunc = func_808714D4; @@ -301,7 +301,7 @@ void func_808714D4(EnBom* this, GlobalContext* globalCtx) { if (Actor_HasNoParent(&this->actor, globalCtx)) { this->actionFunc = func_80871058; this->actor.room = globalCtx->roomCtx.currRoom.num; - this->actor.flags &= ~0x100000; + this->actor.flags &= ~ACTOR_FLAG_100000; this->actor.bgCheckFlags &= ~1; Math_Vec3s_ToVec3f(&this->actor.prevPos, &this->actor.home.rot); if (this->isPowderKeg) { @@ -337,7 +337,7 @@ void func_808715B8(EnBom* this, GlobalContext* globalCtx) { Color_RGBA8 sp80; if (this->collider2.elements->dim.modelSphere.radius == 0) { - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_20; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); } diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c index f02ab4ec6..47c25941d 100644 --- a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c +++ b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c @@ -6,7 +6,7 @@ #include "z_en_bom_chu.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnBomChu*)thisx) diff --git a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c index 09d0880c6..479df5cd7 100644 --- a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c +++ b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c @@ -6,7 +6,7 @@ #include "z_en_bombal.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnBombal*)thisx) 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 2ef45e65d..c20759cb6 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c @@ -6,7 +6,7 @@ #include "z_en_bombers.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnBombers*)thisx) diff --git a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c index 18aa562e7..bcd76ab9d 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c @@ -6,7 +6,7 @@ #include "z_en_bombers2.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnBombers2*)thisx) diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c index 292469236..4362997e6 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -6,7 +6,7 @@ #include "z_en_bombf.h" -#define FLAGS 0x00000011 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_10) #define THIS ((EnBombf*)thisx) diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c index 5c0a2bad6..ab9f8534f 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -8,7 +8,7 @@ #include "z_en_bomjima.h" #include "objects/object_cs/object_cs.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBomjima*)thisx) @@ -125,7 +125,7 @@ void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &object_cs_Anim_0064B8, this->jointTable, this->morphTable, 21); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - gSaveContext.weekEventReg[83] &= (u8)~0x4; + gSaveContext.weekEventReg[83] &= (u8)~4; this->actor.targetMode = 0; this->unk_2E6 = ENBOMJIMA_GET_F0(&this->actor); this->unk_2E4 = ENBOMJIMA_GET_F(&this->actor); diff --git a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c index a33b55577..77f3ad96b 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Niw/z_en_niw.h" #include "objects/object_cs/object_cs.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnBomjimb*)thisx) diff --git a/src/overlays/actors/ovl_En_Boom/z_en_boom.c b/src/overlays/actors/ovl_En_Boom/z_en_boom.c index b6115a897..930b1b597 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -6,7 +6,7 @@ #include "z_en_boom.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnBoom*)thisx) diff --git a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c index 2e6b31a35..e80004a92 100644 --- a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c +++ b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c @@ -6,7 +6,7 @@ #include "z_en_bsb.h" -#define FLAGS 0x02000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((EnBsb*)thisx) diff --git a/src/overlays/actors/ovl_En_Bu/z_en_bu.c b/src/overlays/actors/ovl_En_Bu/z_en_bu.c index 6dab7f307..937759ff6 100644 --- a/src/overlays/actors/ovl_En_Bu/z_en_bu.c +++ b/src/overlays/actors/ovl_En_Bu/z_en_bu.c @@ -6,7 +6,7 @@ #include "z_en_bu.h" -#define FLAGS 0x00000001 +#define FLAGS (ACTOR_FLAG_1) #define THIS ((EnBu*)thisx) diff --git a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c index e6ff6864a..0f54995be 100644 --- a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c +++ b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c @@ -6,7 +6,7 @@ #include "z_en_bubble.h" -#define FLAGS 0x00000001 +#define FLAGS (ACTOR_FLAG_1) #define THIS ((EnBubble*)thisx) diff --git a/src/overlays/actors/ovl_En_Cha/z_en_cha.c b/src/overlays/actors/ovl_En_Cha/z_en_cha.c index 7373fde75..129045a6c 100644 --- a/src/overlays/actors/ovl_En_Cha/z_en_cha.c +++ b/src/overlays/actors/ovl_En_Cha/z_en_cha.c @@ -55,13 +55,13 @@ void EnCha_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.colChkInfo.mass = 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Collider_UpdateCylinder(&this->actor, &this->collider); Actor_SetScale(&this->actor, 0.01f); this->actor.home.rot.z = 0; this->actionFunc = EnCha_Idle; this->actor.home.rot.x = this->actor.home.rot.z; - gSaveContext.weekEventReg[60] &= 0xFB; + gSaveContext.weekEventReg[60] &= (u8)~4; } void EnCha_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -85,7 +85,7 @@ void EnCha_Ring(EnCha* this, GlobalContext* globalCtx) { void EnCha_Idle(EnCha* this, GlobalContext* globalCtx) { if (gSaveContext.weekEventReg[60] & 4) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DOOR_BELL); - gSaveContext.weekEventReg[60] &= 0xFB; + gSaveContext.weekEventReg[60] &= (u8)~4; this->actor.home.rot.z = 0x7D0; } if (this->collider.base.acFlags & AC_HIT) { diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index 4b7156ad4..612420995 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -7,7 +7,7 @@ #include "z_en_clear_tag.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnClearTag*)thisx) @@ -410,7 +410,7 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { Vec3f vel; Vec3f accel; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; if (thisx->params >= 0) { this->activeTimer = 70; Math_Vec3f_Copy(&pos, &this->actor.world.pos); diff --git a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c index 017c8ae2b..5b5cf5133 100644 --- a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c +++ b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00100000 +#define FLAGS (ACTOR_FLAG_100000) #define THIS ((EnColMan*)thisx) @@ -146,8 +146,8 @@ void EnColMan_SetHeartPieceCollectedAndKill(EnColMan* this, GlobalContext* globa void func_80AFDF60(EnColMan* this) { this->actor.draw = func_80AFE584; - this->actor.flags |= 0x10; - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_20; this->type = EN_COL_MAN_FALLING_ROCK; this->actionFunc = func_80AFDFB4; this->actor.shape.shadowScale = 5.0f; diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.c b/src/overlays/actors/ovl_En_Crow/z_en_crow.c index be24037bf..8293ddd94 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.c +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.c @@ -6,7 +6,7 @@ #include "z_en_crow.h" -#define FLAGS 0x00005005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) #define THIS ((EnCrow*)thisx) diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index fe13b6757..5bc75eb8f 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -7,7 +7,7 @@ #include "z_en_dai.h" #include "objects/object_dai/object_dai.h" -#define FLAGS 0x02000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((EnDai*)thisx) @@ -540,7 +540,7 @@ void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { } this->unk_1CD = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_1CE |= (0x100 | 0x20); this->unk_1CE |= 0x80; this->actionFunc = func_80B3EEDC; diff --git a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c index 40ea3c72c..011c0ebbd 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -7,7 +7,7 @@ #include "z_en_daiku.h" #include "objects/object_daiku/object_daiku.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDaiku*)thisx) @@ -76,7 +76,7 @@ void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.radius = 30; this->collider.dim.height = 60; this->collider.dim.yShift = 0; - this->actor.flags |= 0x8000000; + this->actor.flags |= ACTOR_FLAG_8000000; if ((gSaveContext.weekEventReg[63] & 0x80) || ((gSaveContext.day == 3) && gSaveContext.isNight)) { Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c index 1719951d8..434e1c79f 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -9,7 +9,7 @@ #include "objects/object_daiku/object_daiku.h" #include "objects/object_bombiwa/object_bombiwa.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDaiku2*)thisx) diff --git a/src/overlays/actors/ovl_En_Death/z_en_death.c b/src/overlays/actors/ovl_En_Death/z_en_death.c index ec6d57bbf..6292103ee 100644 --- a/src/overlays/actors/ovl_En_Death/z_en_death.c +++ b/src/overlays/actors/ovl_En_Death/z_en_death.c @@ -6,7 +6,7 @@ #include "z_en_death.h" -#define FLAGS 0x00001035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_1000) #define THIS ((EnDeath*)thisx) diff --git a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c index 288ce89a3..1939a5bcc 100644 --- a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c +++ b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c @@ -6,7 +6,7 @@ #include "z_en_dekubaba.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnDekubaba*)thisx) diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c index 1d6863400..9a6b678fc 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -8,7 +8,7 @@ #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_dekunuts/object_dekunuts.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnDekunuts*)thisx) @@ -130,7 +130,7 @@ void EnDekunuts_Init(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.params == ENDEKUNUTS_GET_FF00_1) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->collider.base.colType = COLTYPE_NONE; this->collider.info.bumperFlags |= (BUMP_NO_HITMARK | BUMP_NO_SWORD_SFX | BUMP_NO_DAMAGE | BUMP_NO_AT_INFO); } else if (this->actor.params == ENDEKUNUTS_GET_FF00_2) { @@ -372,7 +372,7 @@ void func_808BDE7C(EnDekunuts* this) { this->actor.colChkInfo.mass = 50; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); this->actor.world.rot.x = 0; - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_20; this->collider.base.acFlags &= ~AC_ON; this->actionFunc = func_808BDEF8; } @@ -435,7 +435,7 @@ void func_808BDFB8(EnDekunuts* this, GlobalContext* globalCtx) { if ((this->unk_18D == 0) && (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 20.0f) && (fabsf(this->actor.world.pos.y - this->actor.home.pos.y) < 2.0f)) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.flags &= ~0x20; + this->actor.flags &= ~ACTOR_FLAG_20; this->actor.speedXZ = 0.0f; func_808BDC9C(this); } else if (this->unk_190 == 0) { diff --git a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c index d38727322..65aad6461 100644 --- a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c +++ b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c @@ -7,7 +7,7 @@ #include "z_en_demo_heishi.h" #include "objects/object_sdn/object_sdn.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDemoheishi*)thisx) diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index b852ff0a4..3c247f447 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -7,7 +7,7 @@ #include "z_en_dg.h" #include "objects/object_dog/object_dog.h" -#define FLAGS 0x00800019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_800000) #define THIS ((EnDg*)thisx) @@ -357,9 +357,10 @@ void func_80989BF8(EnDg* this) { if (this->unk_286 < 14) { if (this->unk_286 % 2) { D_8098C2A8[this->unk_286].unk_04 = - 0x3538 + ((gSaveContext.weekEventReg[42 + (this->unk_286 / 2)] & 0xF0) >> 4); + 0x3538 + ((gSaveContext.weekEventReg[42 + (this->unk_286 / 2)] & (0x10 | 0x20 | 0x40 | 0x80)) >> 4); } else { - D_8098C2A8[this->unk_286].unk_04 = 0x3538 + (gSaveContext.weekEventReg[42 + (this->unk_286 / 2)] & 0xF); + D_8098C2A8[this->unk_286].unk_04 = + 0x3538 + (gSaveContext.weekEventReg[42 + (this->unk_286 / 2)] & (1 | 2 | 4 | 8)); } } else { Actor_MarkForDeath(&this->actor); @@ -394,10 +395,10 @@ void func_80989E18(EnDg* this, GlobalContext* globalCtx) { D_8098C2A8_s* temp; if ((D_8098C2A0 != 0) && !(this->unk_280 & 1)) { - this->actor.flags |= 0x8000000; + this->actor.flags |= ACTOR_FLAG_8000000; this->unk_280 |= 1; } else if ((D_8098C2A0 == 0) && (this->unk_280 & 1)) { - this->actor.flags &= ~0x8000000; + this->actor.flags &= ~ACTOR_FLAG_8000000; this->unk_280 &= ~1; } @@ -406,16 +407,16 @@ void func_80989E18(EnDg* this, GlobalContext* globalCtx) { this->unk_290 = 1; D_8098C2FC = D_8098C2A8[this->unk_286]; if (D_8098C2A0 == 0) { - this->actor.flags |= 0x8000000; + this->actor.flags |= ACTOR_FLAG_8000000; D_8098C2A0 = 1; this->unk_280 |= 1; } func_80989140(&this->skelAnime, sAnimations, 5); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; if (Player_GetMask(globalCtx) == PLAYER_MASK_TRUTH) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 100.0f); this->actionFunc = func_8098BBEC; } else { @@ -838,7 +839,7 @@ void func_8098B004(EnDg* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; this->actor.gravity = -3.0f; - if ((this->actor.xzDistToPlayer < 60.0f) && (this->collider.base.ocFlags1 & 2)) { + if ((this->actor.xzDistToPlayer < 60.0f) && (this->collider.base.ocFlags1 & OC1_HIT)) { this->actor.shape.rot.y += 0x71C; } else { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xC00); @@ -1054,9 +1055,9 @@ void func_8098B88C(EnDg* this, GlobalContext* globalCtx) { void func_8098BA64(EnDg* this, GlobalContext* globalCtx) { if (Actor_HasNoParent(&this->actor, globalCtx)) { this->unk_290 = 2; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; if (D_8098C2A0 != 0) { - this->actor.flags &= ~0x8000000; + this->actor.flags &= ~ACTOR_FLAG_8000000; D_8098C2A0 = 0; this->unk_280 &= ~1; } @@ -1096,7 +1097,7 @@ void func_8098BB10(EnDg* this, GlobalContext* globalCtx) { void func_8098BBEC(EnDg* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_80989D38(this, globalCtx); this->actionFunc = func_8098BC54; } else { diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index 33a65bb9c..16474e92a 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -7,7 +7,7 @@ #include "z_en_dinofos.h" #include "objects/object_dinofos/object_dinofos.h" -#define FLAGS 0x00000435 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_400) #define THIS ((EnDinofos*)thisx) @@ -295,7 +295,7 @@ void EnDinofos_Init(Actor* thisx, GlobalContext* globalCtx) { if (thisx->cutscene == -1) { func_8089B7B0(this); } else { - this->actor.flags |= 0x100000; + this->actor.flags |= ACTOR_FLAG_100000; this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; D_8089E34C = thisx->cutscene; @@ -382,7 +382,7 @@ void func_8089AC70(EnDinofos* this) { this->unk_2B8 = 0.82500005f; this->unk_2B0 = 1.0f; this->unk_290 = 80; - this->actor.flags &= ~0x400; + this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } @@ -392,7 +392,7 @@ void func_8089ACEC(EnDinofos* this, GlobalContext* globalCtx) { this->colliderJntSph.base.colType = COLTYPE_HIT0; this->unk_2B0 = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D4, 12, 2, 0.3f, 0.2f); - this->actor.flags |= 0x400; + this->actor.flags |= ACTOR_FLAG_400; } } @@ -584,7 +584,7 @@ void func_8089B72C(EnDinofos* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { func_8089ABF4(this, globalCtx); - this->actor.flags &= ~0x00100000; + this->actor.flags &= ~ACTOR_FLAG_100000; this->actor.cutscene = -1; func_8089B7B0(this); } @@ -1128,7 +1128,7 @@ void func_8089CF70(EnDinofos* this, GlobalContext* globalCtx) { void func_8089CFAC(EnDinofos* this) { Animation_PlayOnce(&this->skelAnime, &object_dinofos_Anim_00ABD0); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_DEAD); this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; diff --git a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c index 05da2a9b4..a637174bf 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c @@ -8,7 +8,7 @@ #include "objects/object_hanareyama_obj/object_hanareyama_obj.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x000000B0 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_80) #define THIS ((EnDnb*)thisx) diff --git a/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c b/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c index ecd6e8ffc..25fbaefac 100644 --- a/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c +++ b/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c @@ -6,7 +6,7 @@ #include "z_en_dnh.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDnh*)thisx) diff --git a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c index 4225c3225..f144d64c0 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -9,7 +9,7 @@ #include "objects/object_hintnuts/object_hintnuts.h" #include "objects/object_dekunuts/object_dekunuts.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDnk*)thisx) @@ -200,12 +200,12 @@ void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if (ENDNK_GET_3C(&this->actor) == 4) { - this->actor.flags &= ~1; - this->actor.flags |= (0x10 | 0x20); + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); this->actionFunc = func_80A51890; Actor_SetScale(&this->actor, 0.1f); } else { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = EnDnk_DoNothing; Actor_SetScale(&this->actor, 0.01f); } diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.c b/src/overlays/actors/ovl_En_Dno/z_en_dno.c index 67bbd22d0..03925cbe5 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -9,7 +9,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_dno/object_dno.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnDno*)thisx) @@ -686,8 +686,8 @@ void func_80A72BA4(EnDno* this, GlobalContext* globalCtx) { void func_80A72C04(EnDno* this, GlobalContext* globalCtx) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->unk_32C); - this->actor.flags |= 0x8000000; - this->actor.flags &= ~(8 | 1); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Math_Vec3f_Copy(&this->unk_334, &this->actor.world.pos); func_8013DCE0(globalCtx, &this->unk_334, &this->actor, &this->unk_340, globalCtx->setupPathList, ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); @@ -800,7 +800,7 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { this->unk_3AE += 1000; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; func_80A715DC(this, globalCtx); - func_800B9010(&this->actor, 0x2153); + func_800B9010(&this->actor, NA_SE_EV_BUTLER_FRY - SFX_FLAG); if (this->unk_340.unk_1C & 0x20) { Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_340.unk_20); this->actor.speedXZ = 0.0f; @@ -812,8 +812,8 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { } void func_80A73244(EnDno* this, GlobalContext* globalCtx) { - this->actor.flags &= ~0x8000000; - this->actor.flags |= (8 | 1); + this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->unk_328 = 2; this->actor.speedXZ = 0.0f; Flags_UnsetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor)); diff --git a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c index e29711737..118c984f9 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -7,7 +7,7 @@ #include "z_en_dnp.h" #include "objects/object_dnp/object_dnp.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnDnp*)thisx) @@ -224,14 +224,14 @@ s32 func_80B3D044(EnDnp* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state != 0) { if (!(this->unk_322 & 0x200)) { this->unk_322 |= (0x200 | 0x10); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_324 = 0xFF; } func_8013AED4(&this->unk_322, 0, 7); this->actionFunc = func_80B3D11C; ret = true; } else if (this->unk_322 & 0x200) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; func_8013AED4(&this->unk_322, 3, 7); this->unk_322 &= ~(0x200 | 0x10); this->actionFunc = func_80B3D2D4; @@ -323,7 +323,7 @@ void func_80B3D47C(EnDnp* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { Math_SmoothStepToF(&this->actor.scale.x, 0.0085f, 0.1f, 0.01f, 0.001f); if ((s32)(this->actor.scale.x * 10000.0f) >= 85) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; func_8013AED4(&this->unk_322, 3, 7); this->unk_322 &= ~0x10; this->unk_322 |= 0x400; @@ -358,7 +358,7 @@ void EnDnp_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_322 |= (0x100 | 0x80 | 0x10); this->actor.gravity = -1.0f; if (ENDNP_GET_7(&this->actor) == ENDNP_GET_7_1) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, 0.00085000007f); func_8013AED4(&this->unk_322, 0, 7); this->actor.shape.rot.x = 0; diff --git a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c index 3a9027b76..3e0606388 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -7,7 +7,7 @@ #include "z_en_dnq.h" #include "objects/object_dnq/object_dnq.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDnq*)thisx) @@ -120,7 +120,7 @@ s32 func_80A52648(EnDnq* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state != 0) { if (!(this->unk_37C & 0x20)) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_1DC = 0xFF; this->unk_37C |= 0x20; } @@ -128,7 +128,7 @@ s32 func_80A52648(EnDnq* this, GlobalContext* globalCtx) { ret = true; } else { if (this->unk_37C & 0x20) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_1DC = 0xFF; this->unk_37C &= ~0x20; func_8013AED4(&this->unk_37C, 3, 7); diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c index 6b198106b..8432b632a 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Bombf/z_en_bombf.h" #include "objects/object_dodongo/object_dodongo.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnDodongo*)thisx) @@ -420,7 +420,7 @@ void func_80876CAC(EnDodongo* this) { this->unk_344 = 1.125f; this->unk_33C = 1.0f; this->timer = 80; - this->actor.flags &= ~0x400; + this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 80); } @@ -433,7 +433,7 @@ void func_80876D28(EnDodongo* this, GlobalContext* globalCtx) { this->unk_33C = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, &this->unk_348[0], 9, 2, this->unk_334 * 0.3f, this->unk_334 * 0.2f); - this->actor.flags |= 0x400; + this->actor.flags |= ACTOR_FLAG_400; } } @@ -694,7 +694,7 @@ void func_80877D90(EnDodongo* this, GlobalContext* globalCtx) { void func_80877DE0(EnDodongo* this) { Animation_Change(&this->skelAnime, &object_dodongo_Anim_0028F0, -1.0f, 35.0f, 0.0f, 2, -4.0f); - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->timer = 25; this->actionFunc = func_80877E60; this->actor.speedXZ = 0.0f; @@ -734,7 +734,7 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { Actor_MarkForDeath(this->actor.child); this->actor.child = NULL; } - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; } else if (this->skelAnime.playSpeed > -0.5f) { this->timer--; if (this->timer == 10) { @@ -845,7 +845,7 @@ void func_80878424(EnDodongo* this, GlobalContext* globalCtx) { sp20.z = this->collider1Elements[2].dim.worldSphere.center.z; func_80876930(this, globalCtx, &sp20); CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; } void func_80878594(EnDodongo* this) { @@ -895,7 +895,7 @@ void func_80878724(EnDodongo* this) { this->timer = 0; this->unk_304 = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_DEAD); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); this->actionFunc = func_808787B0; diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.c b/src/overlays/actors/ovl_En_Door/z_en_door.c index a410aabdd..f907ae421 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -6,7 +6,7 @@ #include "z_en_door.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnDoor*)thisx) diff --git a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c index 688aa7a42..9b53c36d2 100644 --- a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c +++ b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c @@ -6,7 +6,7 @@ #include "z_en_door_etc.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnDoorEtc*)thisx) diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c index 2068ca8ff..604be5441 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c @@ -6,7 +6,7 @@ #include "z_en_dragon.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnDragon*)thisx) diff --git a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c index 1ca8d69fc..c47961a6d 100644 --- a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c +++ b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c @@ -6,7 +6,7 @@ #include "z_en_ds2n.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnDs2n*)thisx) diff --git a/src/overlays/actors/ovl_En_Dt/z_en_dt.c b/src/overlays/actors/ovl_En_Dt/z_en_dt.c index d76c0c919..0501b728c 100644 --- a/src/overlays/actors/ovl_En_Dt/z_en_dt.c +++ b/src/overlays/actors/ovl_En_Dt/z_en_dt.c @@ -6,7 +6,7 @@ #include "z_en_dt.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDt*)thisx) diff --git a/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c b/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c index 69eb19f58..40e06787c 100644 --- a/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c +++ b/src/overlays/actors/ovl_En_Dy_Extra/z_en_dy_extra.c @@ -7,7 +7,7 @@ #include "z_en_dy_extra.h" #include "objects/object_dy_obj/object_dy_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnDyExtra*)thisx) diff --git a/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c b/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c index 8d72af042..bea655d9a 100644 --- a/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c +++ b/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c @@ -6,7 +6,7 @@ #include "z_en_egblock.h" -#define FLAGS 0x08000000 +#define FLAGS (ACTOR_FLAG_8000000) #define THIS ((EnEgblock*)thisx) 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 fe3e0e09e..0111c6cd7 100644 --- a/src/overlays/actors/ovl_En_Egol/z_en_egol.c +++ b/src/overlays/actors/ovl_En_Egol/z_en_egol.c @@ -6,7 +6,7 @@ #include "z_en_egol.h" -#define FLAGS 0x80000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_80000000) #define THIS ((EnEgol*)thisx) diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index 5047b54ce..2c0fcc116 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -7,7 +7,7 @@ #include "z_en_elf.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((EnElf*)thisx) @@ -905,13 +905,13 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { if ((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.unk_12 == 0) && - ((globalCtx->csCtx.frames == 0x95) || (globalCtx->csCtx.frames == 0x17D) || - (globalCtx->csCtx.frames == 0x24F))) { + ((globalCtx->csCtx.frames == 149) || (globalCtx->csCtx.frames == 381) || + (globalCtx->csCtx.frames == 591))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } if ((globalCtx->sceneNum == SCENE_SECOM) && (gSaveContext.sceneSetupIndex == 0) && - (globalCtx->csCtx.unk_12 == 4) && (globalCtx->csCtx.frames == 0x5F)) { + (globalCtx->csCtx.unk_12 == 4) && (globalCtx->csCtx.frames == 95)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } } else { diff --git a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c index 264efc2b2..3693b258b 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Elforg/z_en_elforg.h" #include "objects/object_bubble/object_bubble.h" -#define FLAGS 0x00000001 +#define FLAGS (ACTOR_FLAG_1) #define THIS ((EnElfbub*)thisx) @@ -82,7 +82,7 @@ void EnElfbub_Init(Actor* thisx, GlobalContext* globalCtx) { } this->oscillationAngle = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } void EnElfbub_Destroy(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c index bb19fa61a..9ff716318 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c @@ -6,7 +6,7 @@ #include "z_en_elfgrp.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnElfgrp*)thisx) diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index 65863f546..9f58e4d9b 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -7,7 +7,7 @@ #include "z_en_elforg.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnElforg*)thisx) diff --git a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c index 2672c209f..b9a186057 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c @@ -6,7 +6,7 @@ #include "z_en_encount1.h" -#define FLAGS 0x08100010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_8000000) #define THIS ((EnEncount1*)thisx) diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index c4094adde..83f04b013 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -8,7 +8,7 @@ #include "objects/object_fusen/object_fusen.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnEncount2*)thisx) diff --git a/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c b/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c index 184eb8728..b9681b5e1 100644 --- a/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c +++ b/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c @@ -6,7 +6,7 @@ #include "z_en_encount3.h" -#define FLAGS 0x08000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) #define THIS ((EnEncount3*)thisx) diff --git a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c index d4f6c4487..eaadd8133 100644 --- a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c +++ b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c @@ -6,7 +6,7 @@ #include "z_en_encount4.h" -#define FLAGS 0x08000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_8000000) #define THIS ((EnEncount4*)thisx) diff --git a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c index 34fa659a8..b366a4dec 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c +++ b/src/overlays/actors/ovl_En_Ending_Hero/z_en_ending_hero.c @@ -7,7 +7,7 @@ #include "z_en_ending_hero.h" #include "objects/object_dt/object_dt.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnEndingHero*)thisx) @@ -34,7 +34,7 @@ const ActorInit En_Ending_Hero_InitVars = { void EnEndingHero_Init(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero* this = THIS; - this->actor.colChkInfo.mass = 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; diff --git a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c index ddb5535a7..f3515787c 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c +++ b/src/overlays/actors/ovl_En_Ending_Hero2/z_en_ending_hero2.c @@ -7,7 +7,7 @@ #include "z_en_ending_hero2.h" #include "objects/object_bai/object_bai.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnEndingHero2*)thisx) @@ -34,7 +34,7 @@ const ActorInit En_Ending_Hero2_InitVars = { void EnEndingHero2_Init(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero2* this = THIS; - this->actor.colChkInfo.mass = 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; diff --git a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c index 9cb297c5c..91c44e741 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c +++ b/src/overlays/actors/ovl_En_Ending_Hero3/z_en_ending_hero3.c @@ -7,7 +7,7 @@ #include "z_en_ending_hero3.h" #include "objects/object_toryo/object_toryo.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnEndingHero3*)thisx) @@ -34,7 +34,7 @@ const ActorInit En_Ending_Hero3_InitVars = { void EnEndingHero3_Init(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero3* this = THIS; - this->actor.colChkInfo.mass = 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; diff --git a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c index 82070a2fa..1e54ee8b9 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c +++ b/src/overlays/actors/ovl_En_Ending_Hero4/z_en_ending_hero4.c @@ -7,7 +7,7 @@ #include "z_en_ending_hero4.h" #include "objects/object_sdn/object_sdn.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnEndingHero4*)thisx) @@ -34,7 +34,7 @@ const ActorInit En_Ending_Hero4_InitVars = { void EnEndingHero4_Init(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero4* this = THIS; - this->actor.colChkInfo.mass = 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; diff --git a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c index ba77613bd..23ac531f3 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c +++ b/src/overlays/actors/ovl_En_Ending_Hero5/z_en_ending_hero5.c @@ -7,7 +7,7 @@ #include "z_en_ending_hero5.h" #include "objects/object_daiku/object_daiku.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnEndingHero5*)thisx) @@ -34,7 +34,7 @@ const ActorInit En_Ending_Hero5_InitVars = { void EnEndingHero5_Init(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero5* this = THIS; - this->actor.colChkInfo.mass = 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; diff --git a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c index b2c592494..82df507c2 100644 --- a/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c +++ b/src/overlays/actors/ovl_En_Ending_Hero6/z_en_ending_hero6.c @@ -11,7 +11,7 @@ #include "objects/object_toryo/object_toryo.h" #include "objects/object_sdn/object_sdn.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnEndingHero6*)thisx) diff --git a/src/overlays/actors/ovl_En_Estone/z_en_estone.c b/src/overlays/actors/ovl_En_Estone/z_en_estone.c index 7cc45bb5a..b1ac6673a 100644 --- a/src/overlays/actors/ovl_En_Estone/z_en_estone.c +++ b/src/overlays/actors/ovl_En_Estone/z_en_estone.c @@ -6,7 +6,7 @@ #include "z_en_estone.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnEstone*)thisx) diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.c b/src/overlays/actors/ovl_En_Fall/z_en_fall.c index e2b420c6e..ef954baaf 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -21,7 +21,7 @@ #include "objects/object_lodmoon/object_lodmoon.h" #include "objects/object_moonston/object_moonston.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnFall*)thisx) @@ -218,7 +218,7 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actor.draw = EnFall_Moon_Draw; this->actionFunc = EnFall_StoppedClosedMouthMoon_PerformCutsceneActions; Actor_SetScale(&this->actor, this->scale * 3.0f); - if (!(gSaveContext.weekEventReg[0x19] & 2)) { + if (!(gSaveContext.weekEventReg[25] & 2)) { Actor_MarkForDeath(&this->actor); } break; @@ -227,7 +227,7 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actionFunc = EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions; Actor_SetScale(&this->actor, this->scale * 3.0f); this->actor.draw = EnFall_Moon_Draw; - if (gSaveContext.weekEventReg[0x19] & 2) { + if (gSaveContext.weekEventReg[25] & 2) { Actor_MarkForDeath(&this->actor); } break; @@ -324,7 +324,7 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globa case 2: if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { - if (gSaveContext.weekEventReg[0x5D] & 4) { + if (gSaveContext.weekEventReg[93] & 4) { if (ActorCutscene_GetCanPlayNext(0xC)) { ActorCutscene_Start(0xC, &this->actor); sGiantsCutsceneState++; @@ -333,7 +333,7 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globa } } else if (ActorCutscene_GetCanPlayNext(0xB)) { ActorCutscene_Start(0xB, &this->actor); - gSaveContext.weekEventReg[0x5D] |= 4; + gSaveContext.weekEventReg[93] |= 4; sGiantsCutsceneState++; } else { ActorCutscene_SetIntentToPlay(0xB); @@ -514,8 +514,8 @@ void EnFall_MoonsTear_Fall(EnFall* this, GlobalContext* globalCtx) { if (this->actor.draw != NULL) { if (Math_Vec3f_StepTo(&this->actor.world.pos, &this->actor.home.pos, this->actor.speedXZ) <= 0.0f) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_BOUND_1); - gSaveContext.weekEventReg[0x4A] |= 0x80; - gSaveContext.weekEventReg[0x4A] |= 0x20; + gSaveContext.weekEventReg[74] |= 0x80; + gSaveContext.weekEventReg[74] |= 0x20; Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TEST, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, -2); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, diff --git a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c index a9e27fec7..46c365cd3 100644 --- a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c +++ b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c @@ -6,7 +6,7 @@ #include "z_en_fall2.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnFall2*)thisx) diff --git a/src/overlays/actors/ovl_En_Famos/z_en_famos.c b/src/overlays/actors/ovl_En_Famos/z_en_famos.c index de24735c7..23da2fb30 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.c +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.c @@ -6,7 +6,7 @@ #include "z_en_famos.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnFamos*)thisx) diff --git a/src/overlays/actors/ovl_En_Fg/z_en_fg.c b/src/overlays/actors/ovl_En_Fg/z_en_fg.c index 18a63fff2..060678506 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.c +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.c @@ -8,7 +8,7 @@ #include "objects/object_fr/object_fr.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00004209 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_200 | ACTOR_FLAG_4000) #define THIS ((EnFg*)thisx) @@ -177,7 +177,7 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { switch (EnFg_GetDamageEffect(this)) { case FG_DMGEFFECT_DEKUSTICK: - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_1); this->skelAnime.playSpeed = 0.0f; this->actor.shape.shadowDraw = NULL; @@ -190,7 +190,7 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { case FG_DMGEFFECT_HOOKSHOT: break; case FG_DMGEFFECT_ARROW: - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->skelAnime.playSpeed = 0.0f; rotY = this->collider.base.ac->world.rot.y; rotX = this->collider.base.ac->world.rot.x; @@ -203,7 +203,7 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { this->actionFunc = EnFg_DoNothing; break; case FG_DMGEFFECT_EXPLOSION: - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_0); if (1) {} this->actor.params = FG_BLACK; @@ -238,7 +238,7 @@ void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { switch (EnFg_GetDamageEffect(this)) { case FG_DMGEFFECT_ARROW: - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->skelAnime.playSpeed = 0.0f; ac = this->collider.base.ac; rotY = ac->world.rot.y; @@ -254,7 +254,7 @@ void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { case FG_DMGEFFECT_HOOKSHOT: break; case FG_DMGEFFECT_EXPLOSION: - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_0); EnFg_UpdateAnimation(&this->skelAnime, 0); this->actor.params = FG_BLACK; @@ -321,7 +321,7 @@ void EnFg_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); - this->actor.flags |= 0x4000; + this->actor.flags |= ACTOR_FLAG_4000; Actor_SetScale(&this->actor, 0.01f); this->actor.gravity = -1.6f; this->actionFunc = EnFg_Idle; diff --git a/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c b/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c index 765e69488..77909d2ee 100644 --- a/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c +++ b/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c @@ -6,7 +6,7 @@ #include "z_en_fire_rock.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnFireRock*)thisx) diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c index af00d0344..664c7ce37 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.h" #include "objects/object_firefly/object_firefly.h" -#define FLAGS 0x00005005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) #define THIS ((EnFirefly*)thisx) @@ -131,7 +131,7 @@ void EnFirefly_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if (this->actor.params & KEESE_INVISIBLE) { - this->actor.flags |= 0x80; + this->actor.flags |= ACTOR_FLAG_80; this->actor.params = KEESE_GET_MAIN_TYPE(thisx); this->isInvisible = true; } @@ -331,7 +331,7 @@ void EnFirefly_SetupFall(EnFirefly* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; Animation_Change(&this->skelAnime, &object_firefly_Anim_00017C, 0.0f, 6.0f, 6.0f, 2, 0.0f); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_DEAD); - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; if (this->isInvisible) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0x2000, 40); @@ -361,7 +361,7 @@ void EnFirefly_SetupFall(EnFirefly* this, GlobalContext* globalCtx) { this->auraType = KEESE_AURA_NONE; } - if (this->actor.flags & 0x8000) { + if (this->actor.flags & ACTOR_FLAG_8000) { this->actor.speedXZ = 0.0f; } @@ -373,7 +373,7 @@ void EnFirefly_Fall(EnFirefly* this, GlobalContext* globalCtx) { this->actor.colorFilterTimer = 40; Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); - if (!(this->actor.flags & 0x8000)) { + if (!(this->actor.flags & ACTOR_FLAG_8000)) { if (this->unk_18F != 0xA) { Math_ScaledStepToS(&this->actor.shape.rot.x, 0x6800, 0x200); this->actor.shape.rot.y -= 0x300; @@ -645,7 +645,7 @@ void EnFirefly_UpdateDamage(EnFirefly* this, GlobalContext* globalCtx) { } else { Enemy_StartFinishingBlow(globalCtx, &this->actor); this->actor.colChkInfo.health = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; // Negate effects of fire on Fire Keese and Ice on Ice Keese if (((this->currentType == KEESE_FIRE) && (this->actor.colChkInfo.damageEffect == 2)) || @@ -678,7 +678,7 @@ void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { EnFirefly_UpdateDamage(this, globalCtx); this->actionFunc(this, globalCtx); - if (!(this->actor.flags & 0x8000)) { + if (!(this->actor.flags & ACTOR_FLAG_8000)) { if ((this->actor.colChkInfo.health == 0) || (this->actionFunc == EnFirefly_Stunned)) { Actor_MoveWithGravity(&this->actor); } else { diff --git a/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c b/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c index 62417b95e..b076e2885 100644 --- a/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c +++ b/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c @@ -6,7 +6,7 @@ #include "z_en_firefly2.h" -#define FLAGS 0x00005015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) #define THIS ((EnFirefly2*)thisx) diff --git a/src/overlays/actors/ovl_En_Fish/z_en_fish.c b/src/overlays/actors/ovl_En_Fish/z_en_fish.c index 419e9edd4..6c9f813fd 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.c +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.c @@ -214,7 +214,7 @@ void EnFish_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_246 = (u32)Rand_Next() >> 0x10; if (sp36 == ENFISH_0) { - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 8.0f); func_8091E810(this); } else if (sp36 == ENFISH_1) { @@ -605,7 +605,7 @@ void func_8091ECF4(EnFish* this) { this->actor.gravity = 0.0f; this->actor.terminalVelocity = 0.0f; this->actor.shape.yOffset = 0.0f; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->unk_240 = 200; func_8091D660(this); this->unkFunc = func_8091ED70; @@ -666,7 +666,7 @@ void func_8091EF30(EnFish* this) { if (this->actor.velocity.y < -1.0f) { this->actor.velocity.y = -1.0f; } - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->actor.home.pos.x = this->actor.world.pos.x; this->actor.home.pos.y = this->actor.world.pos.y - 20.0f; this->actor.home.pos.z = this->actor.world.pos.z; diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c index db2cae901..21b42c4a4 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -10,7 +10,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_fb/object_fb.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnFish2*)thisx) @@ -209,7 +209,7 @@ void EnFish2_Init(Actor* thisx, GlobalContext* globalCtx) { } else if (this->actor.params != 0) { this->unk_2B4 = 10; this->actor.draw = NULL; - this->actor.flags |= 0x8000000; + this->actor.flags |= ACTOR_FLAG_8000000; this->actionFunc = func_80B2A01C; } } @@ -894,8 +894,8 @@ void func_80B2A498(EnFish2* this, GlobalContext* globalCtx) { gSaveContext.weekEventReg[81] &= (u8)~0x20; gSaveContext.weekEventReg[81] &= (u8)~0x40; gSaveContext.weekEventReg[81] &= (u8)~0x80; - gSaveContext.weekEventReg[82] &= (u8)~0x1; - gSaveContext.weekEventReg[82] &= (u8)~0x2; + gSaveContext.weekEventReg[82] &= (u8)~1; + gSaveContext.weekEventReg[82] &= (u8)~2; } } 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 5959fa859..699c862a8 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -8,7 +8,7 @@ #include "objects/object_fish/object_fish.h" #include "overlays/actors/ovl_En_Kanban/z_en_kanban.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnFishing*)thisx) @@ -2833,7 +2833,7 @@ void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { if (this->unk_1CB == 0) { if (this->unk_1CC == 0) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { D_8090CCF8 = D_809171CC; @@ -2843,7 +2843,7 @@ void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { } } else { this->unk_1CC--; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } } else if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { this->unk_1CB = 0; @@ -2900,9 +2900,9 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { if ((D_80917200 != 0) || (sCameraId != MAIN_CAM) || ((player->actor.world.pos.z > 1150.0f) && (this->unk_150 != 100))) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; if (D_8090CD14 != 0) { if (D_80917202 == 0) { this->actor.focus.pos = sLurePos; @@ -3112,7 +3112,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { if (D_80917206 == 2) { func_809038A4(this, input); } else { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } break; @@ -3149,7 +3149,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { if (D_80917206 == 2) { func_809038A4(this, input); } else { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } } break; @@ -3192,7 +3192,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_1AC.z = Rand_ZeroFloat(50.0f); } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; break; case -2: @@ -3231,7 +3231,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } Math_ApproachF(&this->unk_1A8, 2048.0f, 1.0f, 128.0f); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } break; @@ -5084,9 +5084,9 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { SkelAnime_Update(&this->skelAnime); if ((D_8090CD04 != 0) || Message_GetState(&globalCtx->msgCtx)) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } else { - this->actor.flags |= 0x21; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_20); } if ((this->actor.xzDistToPlayer < 120.0f) || Message_GetState(&globalCtx->msgCtx)) { diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index ae6fc99b7..3ce216f7f 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -7,7 +7,7 @@ #include "z_en_floormas.h" #include "objects/object_wallmaster/object_wallmaster.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnFloormas*)thisx) @@ -164,13 +164,13 @@ void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actor.params = ENFLOORMAS_GET_7FFF(&this->actor); if (params != 0) { - this->actor.flags |= 0x80; + this->actor.flags |= ACTOR_FLAG_80; this->actor.draw = func_808D3754; } if (this->actor.params == ENFLOORMAS_GET_7FFF_10) { this->actor.draw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_808D2AA8; return; } @@ -239,7 +239,7 @@ void func_808D09CC(EnFloormas* this) { this->unk_2C4 = 1.0f; this->collider.base.colType = COLTYPE_HIT3; this->unk_18E = 80; - this->actor.flags &= ~(0x400 | 0x200); + this->actor.flags &= ~(ACTOR_FLAG_200 | ACTOR_FLAG_400); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } @@ -251,9 +251,9 @@ void func_808D0A48(EnFloormas* this, GlobalContext* globalCtx) { Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), 2, this->actor.scale.x * 30.000002f, this->actor.scale.x * 20.0f); if (this->actor.scale.x > 0.009f) { - this->actor.flags |= 0x400; + this->actor.flags |= ACTOR_FLAG_400; } else { - this->actor.flags |= 0x200; + this->actor.flags |= ACTOR_FLAG_200; } } } @@ -558,8 +558,8 @@ void func_808D19D4(EnFloormas* this) { this->actor.colorFilterTimer = 0; this->unk_2C4 = 0.0f; Actor_SetScale(&this->actor, 0.004f); - this->actor.flags |= 0x10; - if ((this->actor.flags & 0x80) == 0x80) { + this->actor.flags |= ACTOR_FLAG_10; + if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_80) { this->actor.draw = func_808D3754; } else { this->actor.draw = EnFloormas_Draw; @@ -573,8 +573,8 @@ void func_808D19D4(EnFloormas* this) { Animation_GetLastFrame(&object_wallmaster_Anim_0019CC.common), 2, 0.0f); this->collider.dim.radius = sCylinderInit.dim.radius * 0.6f; this->collider.dim.height = sCylinderInit.dim.height * 0.6f; - this->actor.flags &= ~0x400; - this->actor.flags |= 0x200; + this->actor.flags &= ~ACTOR_FLAG_400; + this->actor.flags |= ACTOR_FLAG_200; this->actor.colChkInfo.health = 1; this->actor.speedXZ = 4.0f; this->actor.velocity.y = 7.0f; @@ -584,7 +584,7 @@ void func_808D19D4(EnFloormas* this) { void func_808D1B44(EnFloormas* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { if (SkelAnime_Update(&this->skelAnime)) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_194 = 50; func_808D0C14(this); } @@ -717,7 +717,7 @@ void func_808D217C(EnFloormas* this, Player* player) { u8 playerForm; Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 1.0f, 36.0f, 45.0f, 2, -3.0f); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; func_808D08D0(this); @@ -761,7 +761,7 @@ void func_808D22C8(EnFloormas* this, GlobalContext* globalCtx) { this->actor.shape.rot.x = 0; this->actor.velocity.y = 6.0f; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.speedXZ = -3.0f; func_808D1740(this); } else if ((this->unk_190 % 20) == 0) { @@ -873,11 +873,11 @@ void func_808D2764(EnFloormas* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { if (this->actor.scale.x >= 0.01f) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; func_808D0908(this); this->actor.params = ENFLOORMAS_GET_7FFF_0; - this->actor.flags &= ~0x200; - this->actor.flags |= 0x400; + this->actor.flags &= ~ACTOR_FLAG_200; + this->actor.flags |= ACTOR_FLAG_400; this->actor.colChkInfo.health = sColChkInfoInit.health; func_808D0C14(this); } else if (this->unk_18E == 0) { @@ -904,7 +904,7 @@ void func_808D2A20(EnFloormas* this) { Actor_MarkForDeath(&this->actor); } else { this->actor.draw = NULL; - this->actor.flags &= ~(0x10 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_10); this->actionFunc = func_808D2AA8; } } @@ -1029,7 +1029,7 @@ void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_DEAD); } Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } else if (this->actor.colChkInfo.damage != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_DAMAGE); } @@ -1107,7 +1107,7 @@ void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, this->actor.scale.x * 3000.0f, 0.0f, 0x1D); Collider_UpdateCylinder(&this->actor, &this->collider); if (this->actionFunc == func_808D1650) { - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } diff --git a/src/overlays/actors/ovl_En_Fr/z_en_fr.c b/src/overlays/actors/ovl_En_Fr/z_en_fr.c index fb5b56451..34b43ef66 100644 --- a/src/overlays/actors/ovl_En_Fr/z_en_fr.c +++ b/src/overlays/actors/ovl_En_Fr/z_en_fr.c @@ -6,7 +6,7 @@ #include "z_en_fr.h" -#define FLAGS 0x40000000 +#define FLAGS (ACTOR_FLAG_40000000) #define THIS ((EnFr*)thisx) @@ -45,8 +45,8 @@ void EnFr_Update(Actor* thisx, GlobalContext* globalCtx) { if (Flags_GetSwitch(globalCtx, ENFR_GET_SWITCHFLAG(&this->actor))) { Actor_MarkForDeath(&this->actor); } else if (this->actor.xyzDistToPlayerSq < SQ(IREG(29))) { - this->actor.flags &= ~0x40000000; + this->actor.flags &= ~ACTOR_FLAG_40000000; } else { - this->actor.flags |= 0x40000000; + this->actor.flags |= ACTOR_FLAG_40000000; } } diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index a59f775ce..8b77518d3 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -8,7 +8,7 @@ #include "objects/object_fsn/object_fsn.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnFsn*)thisx) @@ -131,7 +131,7 @@ u16 EnFsn_GetWelcome(GlobalContext* globalCtx) { void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { switch (this->textId) { case 0: - if (!(gSaveContext.weekEventReg[0x50] & 0x10)) { + if (!(gSaveContext.weekEventReg[80] & 0x10)) { this->textId = 0x29E0; break; } else { @@ -144,7 +144,7 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { this->flags |= ENFSN_GIVE_ITEM; this->flags |= ENFSN_GAVE_LETTER_TO_MAMA; this->getItemId = GI_LETTER_TO_MAMA; - gSaveContext.weekEventReg[0x50] |= 0x10; + gSaveContext.weekEventReg[80] |= 0x10; this->textId = 0x29F1; break; } else { @@ -164,7 +164,7 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { this->flags |= ENFSN_GIVE_ITEM; this->flags |= ENFSN_GAVE_LETTER_TO_MAMA; this->getItemId = GI_LETTER_TO_MAMA; - gSaveContext.weekEventReg[0x50] |= 0x10; + gSaveContext.weekEventReg[80] |= 0x10; this->textId = 0x29F1; break; case 0x29F1: @@ -278,8 +278,8 @@ void EnFsn_CursorLeftRight(EnFsn* this) { } s16 EnFsn_GetThirdDayItemId(void) { - if (!(gSaveContext.weekEventReg[0x21] & 4) && CURRENT_DAY == 3) { - if (!(gSaveContext.weekEventReg[0x21] & 8) && !(gSaveContext.weekEventReg[0x4F] & 0x40)) { + if (!(gSaveContext.weekEventReg[33] & 4) && CURRENT_DAY == 3) { + if (!(gSaveContext.weekEventReg[33] & 8) && !(gSaveContext.weekEventReg[79] & 0x40)) { return SI_BOMB_BAG_30_1; } return SI_MASK_ALL_NIGHT; @@ -311,7 +311,7 @@ s32 EnFsn_HasItemsToSell(void) { return false; } else { if (((gSaveContext.stolenItems & 0xFF000000) >> 0x18) || ((gSaveContext.stolenItems & 0xFF0000) >> 0x10) || - !(gSaveContext.weekEventReg[0x21] & 4)) { + !(gSaveContext.weekEventReg[33] & 4)) { return true; } return false; @@ -417,9 +417,9 @@ s32 EnFsn_FacingShopkeeperDialogResult(EnFsn* this, GlobalContext* globalCtx) { func_8019F208(); if (CURRENT_DAY != 3) { this->actor.textId = 0x29FB; - } else if (gSaveContext.weekEventReg[0x21] & 4) { + } else if (gSaveContext.weekEventReg[33] & 4) { this->actor.textId = 0x29FF; - } else if (!(gSaveContext.weekEventReg[0x21] & 8) && !(gSaveContext.weekEventReg[0x4F] & 0x40)) { + } else if (!(gSaveContext.weekEventReg[33] & 8) && !(gSaveContext.weekEventReg[79] & 0x40)) { this->actor.textId = 0x29D7; } else { this->actor.textId = 0x29D8; @@ -841,9 +841,9 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { func_801518B0(globalCtx, this->actor.textId, &this->actor); break; case 0x29D2: - if (gSaveContext.weekEventReg[0x21] & 4) { + if (gSaveContext.weekEventReg[33] & 4) { this->actor.textId = 0x2A01; - } else if (!(gSaveContext.weekEventReg[0x21] & 8) && !(gSaveContext.weekEventReg[0x4F] & 0x40)) { + } else if (!(gSaveContext.weekEventReg[33] & 8) && !(gSaveContext.weekEventReg[79] & 0x40)) { this->actor.textId = 0x29D3; } else { this->actor.textId = 0x29D4; @@ -1129,7 +1129,7 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { switch (item->canBuyFunc(globalCtx, item)) { case CANBUY_RESULT_SUCCESS_2: func_8019F208(); - gSaveContext.weekEventReg[0x21] |= 4; + gSaveContext.weekEventReg[33] |= 4; case CANBUY_RESULT_SUCCESS_1: if (this->cutsceneState == 2) { ActorCutscene_Stop(this->cutscene); @@ -1394,11 +1394,11 @@ void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx) { this->morphTable, 19); if (ENFSN_IS_SHOP(&this->actor)) { this->actor.shape.rot.y = BINANG_ROT180(this->actor.shape.rot.y); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; EnFsn_GetCutscenes(this); EnFsn_InitShop(this, globalCtx); } else { - if ((gSaveContext.weekEventReg[0x21] & 8) || (gSaveContext.weekEventReg[0x4F] & 0x40)) { + if ((gSaveContext.weekEventReg[33] & 8) || (gSaveContext.weekEventReg[79] & 0x40)) { Actor_MarkForDeath(&this->actor); return; } @@ -1406,7 +1406,7 @@ void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->blinkTimer = 20; this->eyeTextureIdx = 0; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; this->animationIdx = 0; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index 19360748a..039fdfa9a 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -13,7 +13,7 @@ #include "objects/object_mu/object_mu.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x0A000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000) #define THIS ((EnFu*)thisx) @@ -201,7 +201,7 @@ void EnFu_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.gravity = -0.2f; this->actor.shape.rot.y += 0x4000; this->actor.world.rot = this->actor.shape.rot; @@ -230,8 +230,8 @@ void EnFu_Init(Actor* thisx, GlobalContext* globalCtx) { void EnFu_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnFu* this = THIS; - gSaveContext.weekEventReg[63] &= (u8)~0x1; - gSaveContext.weekEventReg[8] &= (u8)~0x1; + gSaveContext.weekEventReg[63] &= (u8)~1; + gSaveContext.weekEventReg[8] &= (u8)~1; Collider_DestroyCylinder(globalCtx, &this->collider); } @@ -380,7 +380,7 @@ void func_80962340(EnFu* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (this->unk_54A == 2) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { @@ -409,7 +409,7 @@ void func_80962340(EnFu* this, GlobalContext* globalCtx) { func_801518B0(globalCtx, 0x2889, &this->actor); this->unk_552 = 0x2889; } - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; player->stateFlags1 &= ~0x20; this->unk_54A = 1; } else { @@ -532,8 +532,8 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { break; case 0x287D: - gSaveContext.weekEventReg[63] |= 0x1; - gSaveContext.weekEventReg[63] &= (u8)~0x2; + gSaveContext.weekEventReg[63] |= 1; + gSaveContext.weekEventReg[63] &= (u8)~2; func_801477B4(globalCtx); player->stateFlags1 |= 0x20; this->unk_53C = 0; @@ -605,8 +605,8 @@ void func_809628D0(EnFu* this, GlobalContext* globalCtx) { case 0x2884: case 0x2887: case 0x288A: - gSaveContext.weekEventReg[63] &= (u8)~0x1; - gSaveContext.weekEventReg[63] &= (u8)~0x2; + gSaveContext.weekEventReg[63] &= (u8)~1; + gSaveContext.weekEventReg[63] &= (u8)~2; func_809622FC(this); break; @@ -737,7 +737,7 @@ void func_80962EBC(EnFu* this, GlobalContext* globalCtx) { void func_80962F10(EnFu* this) { this->unk_548 = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; gSaveContext.weekEventReg[8] |= 1; this->actionFunc = func_80962F4C; } @@ -825,7 +825,7 @@ void func_809632D0(EnFu* this) { Interface_ChangeAlpha(50); } - gSaveContext.weekEventReg[8] &= (u8)~0x1; + gSaveContext.weekEventReg[8] &= (u8)~1; if (this->unk_2D4 != NULL) { BgFuMizu* mizu = this->unk_2D4; @@ -833,7 +833,7 @@ void func_809632D0(EnFu* this) { mizu->unk_160 = 0; } - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80963350; } @@ -913,7 +913,7 @@ void func_80963630(EnFu* this, GlobalContext* globalCtx) { this->unk_552 = 0x287F; } - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.child->freezeTimer = 0; func_809628BC(this); diff --git a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c index ec03de695..3cc50bbec 100644 --- a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c +++ b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c @@ -6,7 +6,7 @@ #include "z_en_fu_kago.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnFuKago*)thisx) diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c index 400bd6d67..fb4fc2a45 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c @@ -6,7 +6,7 @@ #include "z_en_fu_mato.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnFuMato*)thisx) diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.c b/src/overlays/actors/ovl_En_Fz/z_en_fz.c index be2382ef0..8bd7e128b 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -9,7 +9,7 @@ #include "objects/object_fz/object_fz.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnFz*)thisx) @@ -180,7 +180,7 @@ void EnFz_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_BC8 = 0; this->unk_BCF = 0; this->unk_BCC = 1; @@ -472,7 +472,7 @@ void func_80933014(EnFz* this) { void func_809330D4(EnFz* this) { this->unk_BD6 = 2; this->unk_BCE = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80933104; } @@ -543,7 +543,7 @@ void func_80933324(EnFz* this) { this->unk_BCA = 40; this->unk_BCC = 1; this->unk_BCE = 1; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.gravity = -1.0f; this->actionFunc = func_80933368; } @@ -653,7 +653,7 @@ void func_809336C0(EnFz* this, GlobalContext* globalCtx) { this->unk_BCC = 1; this->unk_BCE = 0; this->unk_BD8 = 1; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_BD7 = 0; this->unk_BCA = 60; func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); @@ -671,7 +671,7 @@ void func_80933790(EnFz* this) { this->unk_BD6 = 3; this->unk_BCE = 0; this->unk_BD8 = 1; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; this->unk_BBC = 0.0f; this->actionFunc = func_809337D4; @@ -702,7 +702,7 @@ void func_8093389C(EnFz* this) { this->unk_BCA = 40; this->unk_BCC = 1; this->unk_BCE = 1; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.gravity = -1.0f; this->actionFunc = func_809338E0; } @@ -763,7 +763,7 @@ void func_80933AF4(EnFz* this) { this->unk_BCA = 40; this->unk_BCC = 1; this->unk_BCE = 1; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.gravity = -1.0f; this->actionFunc = func_80933B38; } diff --git a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c index c5f663108..024c857ea 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c @@ -6,7 +6,7 @@ #include "z_en_gakufu.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnGakufu*)thisx) diff --git a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c index a27c5bdc4..16547c112 100644 --- a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c +++ b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c @@ -6,7 +6,7 @@ #include "z_en_gamelupy.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnGamelupy*)thisx) 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 f3d0b7bdf..714432f27 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -7,7 +7,7 @@ #include "z_en_gb2.h" #include "objects/object_ps/object_ps.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnGb2*)thisx) @@ -539,10 +539,10 @@ void func_80B10344(EnGb2* this, GlobalContext* globalCtx) { void func_80B10584(EnGb2* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_801518B0(globalCtx, this->unk_26E, &this->actor); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = func_80B10634; } else if (this->actor.xzDistToPlayer < 300.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 300.0f); } } @@ -668,7 +668,7 @@ void func_80B10A48(EnGb2* this, GlobalContext* globalCtx) { } else { this->actor.draw = NULL; this->unk_26C |= 0x100; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80B111AC; } break; @@ -703,7 +703,7 @@ void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx) { } else { this->unk_26C &= ~0x40; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_26C & 0x20)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_801518B0(globalCtx, this->unk_26E, &this->actor); if (this->unk_26E == 0x14EB) { gSaveContext.weekEventReg[80] |= 0x40; @@ -716,7 +716,7 @@ void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx) { this->actionFunc = func_80B10DAC; } else if (this->actor.xzDistToPlayer < 300.0f) { if (!(this->unk_26C & 0x80)) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->unk_26C |= 0x20; func_800B8614(&this->actor, globalCtx, 300.0f); } @@ -780,11 +780,11 @@ void func_80B10E98(EnGb2* this, GlobalContext* globalCtx) { void func_80B11048(EnGb2* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_801518B0(globalCtx, this->unk_26E, &this->actor); this->actionFunc = func_80B10DAC; } else if (this->actor.xzDistToPlayer < 300.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 200.0f); } } @@ -844,7 +844,7 @@ void func_80B11268(EnGb2* this, GlobalContext* globalCtx) { Flags_GetClear(globalCtx, 5)) { this->unk_28A = 0xFF; this->unk_26C &= ~0x100; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.draw = EnGb2_Draw; this->unk_26E = 0x14F9; this->actionFunc = func_80B11048; @@ -898,8 +898,8 @@ void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { } this->unk_28A = 255; - this->actor.flags |= 0x10; - this->actor.flags |= 0x2000000; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_2000000; if (gSaveContext.eventInf[4] & 0x40) { func_80B0F728(this, globalCtx); @@ -943,7 +943,7 @@ void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.weekEventReg[76] & 0x80) { this->actor.draw = NULL; this->unk_26C |= 0x100; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80B111AC; } else { this->unk_28A = 255; 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 2f3209e97..935eacb8c 100644 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c @@ -6,7 +6,7 @@ #include "z_en_ge1.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnGe1*)thisx) 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 d511788ab..b8522c2c6 100644 --- a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c +++ b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c @@ -6,7 +6,7 @@ #include "z_en_ge2.h" -#define FLAGS 0x80000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_80000000) #define THIS ((EnGe2*)thisx) 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 7c0bcd71f..593c57a5a 100644 --- a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c +++ b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c @@ -6,7 +6,7 @@ #include "z_en_ge3.h" -#define FLAGS 0x80000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_80000000) #define THIS ((EnGe3*)thisx) 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 3207a1d12..e9a83fa06 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -11,7 +11,7 @@ #include "objects/object_hakugin_demo/object_hakugin_demo.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnGeg*)thisx) @@ -444,10 +444,10 @@ void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { } func_801518B0(globalCtx, this->unk_496, &this->actor); this->actionFunc = func_80BB2520; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->actor.xzDistToPlayer < 300.0f) { this->unk_230 |= 4; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 300.0f); } } else { @@ -469,9 +469,9 @@ void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { func_801518B0(globalCtx, this->unk_496, &this->actor); this->actionFunc = func_80BB2520; this->unk_230 &= ~8; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->actor.xzDistToPlayer < 300.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 300.0f); this->unk_230 |= 8; } @@ -773,9 +773,9 @@ void func_80BB30B4(EnGeg* this, GlobalContext* globalCtx) { } func_801518B0(globalCtx, this->unk_496, &this->actor); this->actionFunc = func_80BB27D4; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->actor.xzDistToPlayer < 150.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 150.0f); } } 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 4eb259e50..bac0b52ae 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,7 @@ #include "z_en_gg.h" -#define FLAGS 0x00000089 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_80) #define THIS ((EnGg*)thisx) 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 e415165ac..e06655c69 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -6,7 +6,7 @@ #include "z_en_gg2.h" -#define FLAGS 0x00000089 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_80) #define THIS ((EnGg2*)thisx) 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 4338988b8..937f46460 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -6,7 +6,7 @@ #include "z_en_giant.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnGiant*)thisx) @@ -183,7 +183,7 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { } if (GIANT_TYPE_IS_CLOCK_TOWER_SUCCESS(type)) { - if (!(gSaveContext.weekEventReg[0x19] & 2)) { + if (!(gSaveContext.weekEventReg[25] & 2)) { Actor_MarkForDeath(&this->actor); return; } 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 d4190d1db..eb21f3586 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 @@ -7,7 +7,7 @@ #include "z_en_ginko_man.h" #include "objects/object_boj/object_boj.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnGinkoMan*)thisx) @@ -71,7 +71,7 @@ void EnGinkoMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnGinkoMan_SetupIdle(EnGinkoMan* this) { - this->actor.flags |= 1; // targetable + this->actor.flags |= ACTOR_FLAG_1; // targetable Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); this->actionFunc = EnGinkoMan_Idle; } diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c index 10cc9a120..317c64412 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -6,7 +6,7 @@ #include "z_en_girla.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnGirlA*)thisx) @@ -538,7 +538,7 @@ void EnGirlA_InitalUpdate(EnGirlA* this, GlobalContext* globalCtx) { ShopItemEntry* shopItem = &sShopItemEntries[params]; if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; this->actor.objBankIndex = this->objIndex; this->actor.textId = shopItem->descriptionTextId; this->choiceTextId = shopItem->choiceTextId; @@ -558,7 +558,7 @@ void EnGirlA_InitalUpdate(EnGirlA* this, GlobalContext* globalCtx) { this->itemParams = shopItem->params; this->drawFunc = shopItem->drawFunc; this->getItemDrawId = shopItem->getItemDrawId; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, 0.25f); this->actor.shape.yOffset = 24.0f; this->actor.shape.shadowScale = 4.0f; 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 acc972053..f16276ea2 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -6,7 +6,7 @@ #include "z_en_gk.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnGk*)thisx) 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 e8e8d5b0a..93ca5b2cb 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/object_in2/object_in2.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnGm*)thisx) @@ -953,7 +953,7 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_3B8 = arg2->unk8 - arg2->unk4; this->unk_3BA = sp56 - arg2->unk4; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; func_8094E054(this, globalCtx, 7); @@ -1159,7 +1159,7 @@ s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 func_80950280(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { s32 phi_v1; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; this->unk_3A4 = 0; this->unk_3C8 = 0; @@ -1500,11 +1500,11 @@ void func_80950CDC(EnGm* this, GlobalContext* globalCtx) { if (!func_80133038(globalCtx, (void*)&D_80951820, &sp20) || ((this->unk_258 != sp20.unk0) && !func_80950280(this, globalCtx, &sp20))) { this->actor.shape.shadowDraw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; sp20.unk0 = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } this->unk_258 = sp20.unk0; this->unk_268 = func_8094F074(this, globalCtx); 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 1d6d192ac..67dea2e9d 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -10,7 +10,7 @@ #include "objects/object_taisou/object_taisou.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnGo*)thisx) @@ -712,7 +712,7 @@ s32 func_80A12954(EnGo* this, GlobalContext* globalCtx) { (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.unk_12 == 0)) { if (this->unk_3F0 == 0) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_394 = 255; this->unk_3F0 = 1; this->unk_18C = this->actionFunc; @@ -720,7 +720,7 @@ s32 func_80A12954(EnGo* this, GlobalContext* globalCtx) { func_8013AED4(&this->unk_390, 0, 7); this->actionFunc = func_80A14FC8; } else if (this->unk_3F0 != 0) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_394 = 255; this->unk_3F0 = 0; func_8013AED4(&this->unk_390, 3, 7); @@ -1286,7 +1286,7 @@ void func_80A14018(EnGo* this, GlobalContext* globalCtx) { Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &D_80A166B0, &sp2C); Math_Vec3f_Copy(&this->actor.world.pos, &sp2C); } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, this->unk_3A4); this->unk_3EC = 0; this->unk_390 = 0; @@ -1301,7 +1301,7 @@ void func_80A14104(EnGo* this, GlobalContext* globalCtx) { func_80A12C48(this, globalCtx, D_80A166D4[ENGO_GET_70(&this->actor) % 2]); temp = Rand_ZeroOne() * this->skelAnime.endFrame; this->skelAnime.curFrame = temp; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, this->unk_3A4); this->unk_3EC = 0; this->unk_390 = 0; @@ -1331,7 +1331,7 @@ void func_80A1428C(EnGo* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp30, &this->actor.world.pos); if (this->unk_284 != NULL) { - this->actor.flags &= ~0x2000000; + this->actor.flags &= ~ACTOR_FLAG_2000000; func_8013C8B8(this->unk_284, 0, &sp24); temp = Math_Vec3f_Yaw(&sp30, &sp24); this->actor.shape.rot.y = temp; @@ -1437,7 +1437,7 @@ void func_80A146CC(EnGo* this, GlobalContext* globalCtx) { func_80A12C48(this, globalCtx, 0); this->unk_3A4 *= 5.0f; Actor_SetScale(&this->actor, this->unk_3A4); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.targetMode = 3; this->unk_390 = 0; this->actor.gravity = -1.0f; @@ -1758,8 +1758,8 @@ void func_80A153FC(EnGo* this, GlobalContext* globalCtx) { if ((this->unk_390 & 0x1000) && (this->actor.colChkInfo.damageEffect == 0xF)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SNOWBALL_BROKEN); - this->actor.flags &= ~0x10; - this->actor.flags |= 0x2000000; + this->actor.flags &= ~ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_2000000; func_80A118F8(this->unk_3F8, this->actor.world.pos); this->actor.shape.rot.x = 0; 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 3d046f073..704167822 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -8,7 +8,7 @@ #include "objects/object_goroiwa/object_goroiwa.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x80000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) #define THIS ((EnGoroiwa*)thisx) @@ -474,7 +474,7 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { temp_f2 = temp_f14 - this->actor.world.pos.y; if (fabsf(temp_f2) < (fabsf(this->actor.velocity.y) + 0.01f)) { - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { sp48.x = this->actor.world.pos.x; sp48.y = temp_f14 + 10.0f; sp48.z = this->actor.world.pos.z; @@ -506,7 +506,7 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { if ((this->actor.world.pos.y + this->unk_1DC) <= sp40) { this->unk_1E5 |= 0x20; if (sp40 < (this->unk_1DC + sp78)) { - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { Vec3f sp34; sp34.x = this->actor.world.pos.x; @@ -672,7 +672,7 @@ void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { f32 temp_f20; s32 pad3; - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { spEC = (this->actor.scale.x + 0.1f) * 0.5f; sp10C.x = this->actor.world.pos.x; sp10C.y = this->actor.world.pos.y + this->unk_1DC; @@ -901,7 +901,7 @@ void func_80940E38(EnGoroiwa* this, GlobalContext* globalCtx) { s16 sp46; s16 temp_a0; - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { if (this->actor.xzDistToPlayer < 1000.0f) { sp5C = (1000.0f - this->actor.xzDistToPlayer) * 0.0012f * (this->actor.speedXZ * 0.1f); if (Rand_ZeroOne() < sp5C) { @@ -1458,7 +1458,7 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { func_8093E91C(this); sp5C = true; - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { if (this->actor.floorPoly != NULL) { u32 temp_v0_2 = func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); @@ -1517,7 +1517,7 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { func_8093FAA4(this, globalCtx); - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { s32 params = ENGOROIWA_GET_C000(&this->actor); func_8093E938(this); 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 1a877457f..e19d2fa37 100644 --- a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c +++ b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c @@ -6,7 +6,7 @@ #include "z_en_grasshopper.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnGrasshopper*)thisx) 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 94565e3c0..a7d0d397f 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -8,7 +8,7 @@ #include "objects/object_gs/object_gs.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnGs*)thisx) @@ -1021,7 +1021,7 @@ void EnGs_Update(Actor* thisx, GlobalContext* globalCtx) { s16 sp2E; s16 sp2C; - if ((this->actor.flags & 0x40) || (this->unk_19A & 0x100) || (this->unk_19A & 0x200)) { + if ((this->actor.flags & ACTOR_FLAG_40) || (this->unk_19A & 0x100) || (this->unk_19A & 0x200)) { func_80999BC8(&this->actor, globalCtx); Actor_GetScreenPos(globalCtx, &this->actor, &sp2E, &sp2C); if ((this->actor.xyzDistToPlayerSq > SQ(400.0f)) || (sp2E < 0) || (sp2E > 320) || (sp2C < 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 8f7fa4f4a..eefabdb3b 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 @@ -6,7 +6,7 @@ #include "z_en_guard_nuts.h" -#define FLAGS 0x80100009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_100000 | ACTOR_FLAG_80000000) #define THIS ((EnGuardNuts*)thisx) 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 dd02a3e40..f3ba53251 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -7,7 +7,7 @@ #include "z_en_guruguru.h" #include "objects/object_fu/object_fu.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnGuruguru*)thisx) @@ -83,9 +83,9 @@ void EnGuruguru_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == 0) { func_80BC6E10(this); } else if (this->actor.params == 2) { - this->actor.flags |= 0x8000000; + this->actor.flags |= ACTOR_FLAG_8000000; this->actor.draw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = EnGuruguru_DoNothing; } else { Actor_MarkForDeath(&this->actor); diff --git a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c index 1e4da23ea..108d62afd 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -9,7 +9,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_boss_hakugin/object_boss_hakugin.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnHakurock*)thisx) 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 ce1f2a0f0..2b15971bf 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -6,7 +6,7 @@ #include "z_en_hanabi.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnHanabi*)thisx) 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 229c1b65d..c05a06a56 100644 --- a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c +++ b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c @@ -6,7 +6,7 @@ #include "z_en_heishi.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnHeishi*)thisx) 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 708c79828..e984eb40f 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -7,7 +7,7 @@ #include "z_en_hg.h" #include "objects/object_harfgibud/object_harfgibud.h" -#define FLAGS 0x02100019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnHg*)thisx) @@ -126,7 +126,7 @@ void EnHg_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); - if ((gSaveContext.weekEventReg[0x4B] & 0x20) || (gSaveContext.weekEventReg[0x34] & 0x20)) { + if ((gSaveContext.weekEventReg[75] & 0x20) || (gSaveContext.weekEventReg[52] & 0x20)) { Actor_MarkForDeath(&this->actor); } this->actor.targetMode = 1; @@ -228,7 +228,7 @@ void func_80BCF778(EnHg* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.health == 1) { if (this->actionFunc == func_80BCF4AC || this->actionFunc == func_80BCF6D0 || this->actionFunc == func_80BCF634) { - func_800B9010(&this->actor, 0x32B7); + func_800B9010(&this->actor, NA_SE_EN_HALF_REDEAD_LOOP - SFX_FLAG); } } } @@ -303,7 +303,7 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); break; case 6: - gSaveContext.weekEventReg[0x4B] |= 0x20; + gSaveContext.weekEventReg[75] |= 0x20; Actor_MarkForDeath(&this->actor); break; } @@ -368,8 +368,8 @@ void func_80BCFC0C(EnHg* this, GlobalContext* globalCtx) { } else { if (this->actor.xzDistToPlayer < 60.0f && fabsf(this->actor.playerHeightRel) < 40.0f) { if ((this->actionFunc != func_80BCF8A0) && (this->actionFunc != func_80BCF95C)) { - if (!(gSaveContext.weekEventReg[0x3D] & 2)) { - gSaveContext.weekEventReg[0x3D] |= 2; + if (!(gSaveContext.weekEventReg[61] & 2)) { + gSaveContext.weekEventReg[61] |= 2; this->unk218 = 0; } else { this->unk218 = 2; 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 38f25f954..0049205d9 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -7,7 +7,7 @@ #include "z_en_hgo.h" #include "objects/object_harfgibud/object_harfgibud.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnHgo*)thisx) @@ -109,7 +109,7 @@ void EnHgo_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80BD03EC(EnHgo* this) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80BD0410; } 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 2dc819719..c19e596ac 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,7 @@ #include "z_en_hidden_nuts.h" -#define FLAGS 0x02000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_2000000) #define THIS ((EnHiddenNuts*)thisx) diff --git a/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c b/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c index 3c7eac5ae..78cfa14a0 100644 --- a/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c +++ b/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c @@ -6,7 +6,7 @@ #include "z_en_hit_tag.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnHitTag*)thisx) diff --git a/src/overlays/actors/ovl_En_Holl/z_en_holl.c b/src/overlays/actors/ovl_En_Holl/z_en_holl.c index ff418b579..8d5816c16 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -39,7 +39,7 @@ #include "z_en_holl.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnHoll*)thisx) diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c index 3edd916d2..aaea88252 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -6,7 +6,7 @@ #include "z_en_honotrap.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnHonotrap*)thisx) 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 e03114ea8..ad9089df6 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -6,7 +6,7 @@ #include "z_en_horse.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnHorse*)thisx) diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c index 423acc7bf..ff3465a0a 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c @@ -6,7 +6,7 @@ #include "z_en_horse_game_check.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnHorseGameCheck*)thisx) 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 fca05f277..da62a57e0 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 @@ -6,7 +6,7 @@ #include "z_en_horse_link_child.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnHorseLinkChild*)thisx) 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 abf9966ff..70c021d0e 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -6,7 +6,7 @@ #include "z_en_hs.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnHs*)thisx) diff --git a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c index 7efec2c4d..02625ff9e 100644 --- a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c +++ b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c @@ -6,7 +6,7 @@ #include "z_en_hs2.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnHs2*)thisx) 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 6539128c3..a2a185f3f 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/object_dai/object_dai.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnIg*)thisx) @@ -543,7 +543,7 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_3E0 = arg2->unk8 - arg2->unk4; this->unk_3E2 = sp56 - arg2->unk4; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3D0 |= 0x100; func_80BF1284(this, 3); this->actor.gravity = 0.0f; @@ -652,7 +652,7 @@ s32 func_80BF2368(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->actor.targetMode = 0; this->unk_3D0 = 0; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; switch (arg2->unk0) { case 5: @@ -848,11 +848,11 @@ void func_80BF2AF8(EnIg* this, GlobalContext* globalCtx) { if (!func_80133038(globalCtx, D_80BF3260, &sp20) || ((this->unk_298.unk0 != sp20.unk0) && !func_80BF2368(this, globalCtx, &sp20))) { this->actor.shape.shadowDraw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; sp20.unk0 = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } this->unk_2A8 = func_80BF146C(this, globalCtx); this->unk_298.unk0 = sp20.unk0; 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 59cd63487..b782b82a3 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.c @@ -6,7 +6,7 @@ #include "z_en_ik.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnIk*)thisx) 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 52b4e46f7..25d015cfa 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -7,7 +7,7 @@ #include "z_en_in.h" #include "objects/object_in/object_in.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnIn*)thisx) @@ -224,7 +224,7 @@ s32 func_808F3334(EnIn* this, GlobalContext* globalCtx) { if (this->colliderJntSph.base.atFlags & AT_BOUNCED) { return 0; } - Actor_PlaySfxAtPos(&player->actor, 0x83E); + Actor_PlaySfxAtPos(&player->actor, NA_SE_PL_BODY_HIT); func_800B8D98(globalCtx, &this->actor, 3.0f, this->actor.yawTowardsPlayer, 6.0f); } return 1; @@ -349,7 +349,7 @@ void func_808F395C(EnIn* this, GlobalContext* globalCtx) { this->actionFunc = func_808F5A94; } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = func_808F5A34; this->unk48C = 1; } else { @@ -381,7 +381,7 @@ void func_808F39DC(EnIn* this, GlobalContext* globalCtx) { } SET_FLAGS_FINISH_RACE; } - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->actor.textId = textId; this->actionFunc = func_808F395C; if (this->unk4B0 == 2) { @@ -393,7 +393,7 @@ void func_808F39DC(EnIn* this, GlobalContext* globalCtx) { void func_808F3AD4(EnIn* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->unk48C = 1; this->actionFunc = func_808F5A94; } else { @@ -406,7 +406,7 @@ void func_808F3B40(EnIn* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_808F3AD4; textId = gSaveContext.day != 3 ? 0x3481 : 0x34A4; this->actor.textId = textId; @@ -417,7 +417,7 @@ void func_808F3B40(EnIn* this, GlobalContext* globalCtx) { void func_808F3BD4(EnIn* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->unk48C = 1; this->actionFunc = func_808F5A94; } else { @@ -430,7 +430,7 @@ void func_808F3C40(EnIn* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_808F3BD4; textId = gSaveContext.day != 3 ? 0x346A : 0x3492; this->actor.textId = textId; @@ -441,7 +441,7 @@ void func_808F3C40(EnIn* this, GlobalContext* globalCtx) { void func_808F3CD4(EnIn* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->unk48C = 1; this->actionFunc = func_808F5A94; } else { @@ -457,7 +457,7 @@ void func_808F3D40(EnIn* this, GlobalContext* globalCtx) { this->actionFunc = func_808F3CD4; textId = gSaveContext.day != 3 ? 0x347D : 0x34A0; this->actor.textId = textId; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; } else { Actor_PickUp(&this->actor, globalCtx, GI_MASK_GARO, 500.0f, 100.0f); } @@ -741,7 +741,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 1: switch (textId) { case 0x3463: - gSaveContext.weekEventReg[15] |= 16; + gSaveContext.weekEventReg[15] |= 0x10; func_800E8EA0(globalCtx, &this->actor, 0x3464); ret = false; break; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index d9d61ea9f..d36644b4a 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -12,7 +12,7 @@ #include "objects/object_cow/object_cow.h" #include "objects/object_uch/object_uch.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnInvadepoh*)thisx) @@ -1629,7 +1629,7 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { s32 invadepohType; s32 i; - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_20; invadepohType = (this->actor.params >> 8) & 0x7F; for (i = 1; i < 8; i++) { @@ -1677,14 +1677,14 @@ void EnInvadepoh_InitAlien(EnInvadepoh* this, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); ActorShape_Init(&this->actor.shape, 6800.0f, ActorShadow_DrawWhiteCircle, 150.0f); this->actor.shape.shadowAlpha = 140; - this->actor.flags = 0x80001010; + this->actor.flags = (ACTOR_FLAG_10 | ACTOR_FLAG_1000 | ACTOR_FLAG_80000000); if (INVADEPOH_TYPE(this) == TYPE_ALIEN1) { this->actor.update = func_80B4D670; this->actor.world.pos.y = this->actor.home.pos.y + 150.0f; } else { this->actor.update = func_80B47BAC; Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitAlien); - this->actor.colChkInfo.mass = 0x28; + this->actor.colChkInfo.mass = 40; } this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_UCH); if (this->bankIndex < 0) { @@ -1731,7 +1731,7 @@ void EnInvadepoh_InitRomani(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.update = func_80B48620; } else if (temp == 5) { this->actor.update = func_80B48FB0; - this->actor.flags = 0x19; + this->actor.flags = (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10); } else if (temp == 7) { this->actor.update = func_80B49F88; } else if (temp == 8) { @@ -1747,7 +1747,7 @@ void EnInvadepoh_InitRomani(EnInvadepoh* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } if (temp == 5) { - if (gSaveContext.weekEventReg[22] & 0x1) { + if (gSaveContext.weekEventReg[22] & 1) { Actor_MarkForDeath(&this->actor); return; } @@ -1763,7 +1763,7 @@ void EnInvadepoh_InitRomani(EnInvadepoh* this, GlobalContext* globalCtx) { return; } } else if (temp == 0xC) { - if (!(gSaveContext.weekEventReg[22] & 0x1)) { + if (!(gSaveContext.weekEventReg[22] & 1)) { Actor_MarkForDeath(&this->actor); } D_80B503F4 = this; @@ -1796,7 +1796,7 @@ void EnInvadepoh_InitDog(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.update = func_80B4B8BC; Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitDog); - this->actor.colChkInfo.mass = 0x50; + this->actor.colChkInfo.mass = 80; ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 24.0f); this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_DOG); if (this->bankIndex < 0) { @@ -1818,7 +1818,7 @@ void EnInvadepoh_InitCremia(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->bankIndex < 0) { Actor_MarkForDeath(&this->actor); } - if (!(gSaveContext.weekEventReg[0x16] & 1)) { + if (!(gSaveContext.weekEventReg[22] & 1)) { Actor_MarkForDeath(&this->actor); } D_80B503F8 = this; @@ -2064,10 +2064,10 @@ void EnInvadepoh_Update(Actor* thisx, GlobalContext* globalCtx) { } void func_80B47380(EnInvadepoh* this) { - this->collider.base.atFlags &= ~1; - this->collider.base.acFlags &= ~1; - this->collider.base.ocFlags1 &= ~1; - this->actor.flags &= ~0x80000000; + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.ocFlags1 &= ~OC1_ON; + this->actor.flags &= ~ACTOR_FLAG_80000000; this->alienAlpha = 0; this->actor.draw = NULL; this->drawAlien = false; @@ -2089,10 +2089,10 @@ void func_80B473E4(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B47478(EnInvadepoh* this) { - this->collider.base.atFlags &= ~1; - this->collider.base.acFlags &= ~1; - this->collider.base.ocFlags1 &= ~1; - this->actor.flags &= ~0x80000000; + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.ocFlags1 &= ~OC1_ON; + this->actor.flags &= ~ACTOR_FLAG_80000000; this->alienAlpha = 0; this->actor.draw = NULL; this->drawAlien = false; @@ -2115,15 +2115,15 @@ void func_80B474DC(EnInvadepoh* this, GlobalContext* globalCtx) { void func_80B47568(EnInvadepoh* this) { Animation_MorphToLoop(&this->skelAnime, &object_uch_Anim_001D80, -6.0f); - this->collider.base.atFlags &= ~0x1; - this->collider.base.acFlags &= ~0x1; - this->collider.base.ocFlags1 &= ~0x1; + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.ocFlags1 &= ~OC1_ON; this->alienAlpha = 0; this->actor.draw = func_80B4DB14; this->drawAlien = true; this->drawAlienDeathEffect = false; this->alienBeamAlpha = 0; - this->actor.flags |= 0x80000000; + this->actor.flags |= ACTOR_FLAG_80000000; this->actionFunc = func_80B47600; } @@ -2141,9 +2141,9 @@ void func_80B47600(EnInvadepoh* this, GlobalContext* globalCtx) { this->alienAlpha += 6; } if (this->alienAlpha > 128) { - this->collider.base.atFlags |= 1; - this->collider.base.acFlags |= 1; - this->collider.base.ocFlags1 |= 1; + this->collider.base.atFlags |= AT_ON; + this->collider.base.acFlags |= AC_ON; + this->collider.base.ocFlags1 |= OC1_ON; } if (this->alienAlpha == 255) { if (this->alienBeamAlpha >= 245) { @@ -2159,15 +2159,15 @@ void func_80B4770C(EnInvadepoh* this) { if (this->skelAnime.animation != &object_uch_Anim_001D80) { Animation_MorphToLoop(&this->skelAnime, &object_uch_Anim_001D80, -6.0f); } - this->collider.base.atFlags |= 1; - this->collider.base.acFlags |= 1; - this->collider.base.ocFlags1 |= 1; + this->collider.base.atFlags |= AT_ON; + this->collider.base.acFlags |= AC_ON; + this->collider.base.ocFlags1 |= OC1_ON; this->alienAlpha = 255; this->actor.draw = func_80B4DB14; this->drawAlien = true; this->drawAlienDeathEffect = false; this->alienBeamAlpha = 255; - this->actor.flags |= 0x80000000; + this->actor.flags |= ACTOR_FLAG_80000000; this->actionFunc = func_80B477B4; } @@ -2182,9 +2182,9 @@ void func_80B477B4(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B47830(EnInvadepoh* this) { - this->collider.base.atFlags &= ~1; - this->collider.base.acFlags &= ~1; - this->collider.base.ocFlags1 |= 1; + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.ocFlags1 |= OC1_ON; Animation_PlayLoop(&this->skelAnime, &object_uch_Anim_0006C8); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); this->alienAlpha = 255; @@ -2194,7 +2194,7 @@ void func_80B47830(EnInvadepoh* this) { this->alienBeamAlpha = 0; this->actionTimer = 8; this->counter = 0; - this->actor.flags |= 0x80000000; + this->actor.flags |= ACTOR_FLAG_80000000; this->actionFunc = func_80B478F4; } @@ -2207,18 +2207,18 @@ void func_80B478F4(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B47938(EnInvadepoh* this) { - this->collider.base.atFlags &= ~1; - this->collider.base.acFlags &= ~1; - this->collider.base.ocFlags1 &= ~1; + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.ocFlags1 &= ~OC1_ON; Animation_PlayLoop(&this->skelAnime, &object_uch_Anim_000608); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionTimer = 10; this->alienAlpha = 255; this->actor.draw = func_80B4DB14; this->drawAlien = true; this->drawAlienDeathEffect = false; this->alienBeamAlpha = 255; - this->actor.flags |= 0x80000000; + this->actor.flags |= ACTOR_FLAG_80000000; this->actionFunc = func_80B479E8; } @@ -2317,7 +2317,7 @@ void func_80B47D30(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); return; } - } else if (this->collider.base.acFlags & 2) { + } else if (this->collider.base.acFlags & AC_HIT) { Actor* acAttached = this->collider.base.ac; thisx->speedXZ = acAttached->speedXZ * 0.5f; @@ -2574,7 +2574,7 @@ void func_80B48848(EnInvadepoh* this, GlobalContext* globalCtx) { Math_StepToS(&this->behaviorInfo.unk4C, 0x7D0, 0x46); } func_80B43E6C(this, 6, this->behaviorInfo.unk4C, 0x46); - if (((this->actor.flags & 0x40) == 0x40) && + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } @@ -2740,7 +2740,7 @@ void func_80B48FB0(Actor* thisx, GlobalContext* globalCtx) { void func_80B490F0(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; - s32 sp2C = (this->actor.flags & 0x40) == 0x40; + s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { @@ -3021,13 +3021,13 @@ void func_80B49C38(EnInvadepoh* this, GlobalContext* globalCtx) { this->unk378 = func_80B45550(this, globalCtx, SQ(80.0f), temp_v0_2); } } - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); } else { this->unk378 = 0; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); } - if (((this->actor.flags & 0x40) == 0x40) && + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } @@ -3123,7 +3123,7 @@ void func_80B4A168(Actor* thisx, GlobalContext* globalCtx) { void func_80B4A1B8(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; - s32 sp2C = (this->actor.flags & 0x40) == 0x40; + s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { @@ -3153,7 +3153,7 @@ void func_80B4A2C0(EnInvadepoh* this) { substruct->unk2C = 1500; this->actionTimer = Rand_S16Offset(200, 200); this->unk304 = this->actor.shape.rot.y; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actionFunc = func_80B4A350; } @@ -3210,7 +3210,7 @@ void func_80B4A570(EnInvadepoh* this) { substruct->unk26.z = 0; substruct->unk30 = 0.1f; substruct->unk2C = 800; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actionFunc = func_80B4A5E4; } @@ -3248,12 +3248,12 @@ void func_80B4A67C(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->unk378 == 0) { this->unk378 = func_80B45550(this, globalCtx, SQ(80.0f), -0xF); } - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); } else { this->unk378 = 0; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); } - if (((this->actor.flags & 0x40) == 0x40) && + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } @@ -3352,7 +3352,7 @@ void func_80B4AB8C(Actor* thisx, GlobalContext* globalCtx) { void func_80B4ABDC(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; - s32 sp2C = (this->actor.flags & 0x40) == 0x40; + s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { @@ -3378,13 +3378,13 @@ void func_80B4ACDC(EnInvadepoh* this) { void func_80B4ACF0(EnInvadepoh* this, GlobalContext* globalCtx) { if (gSaveContext.weekEventReg[22] & 1) { this->actor.draw = func_80B4E324; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80B4AD3C(this); } } void func_80B4AD3C(EnInvadepoh* this) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_80B4AD60; } @@ -3460,7 +3460,7 @@ void func_80B4AF94(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4B024(EnInvadepoh* this) { - this->actor.flags &= ~9; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actionFunc = func_80B4B048; } @@ -3501,7 +3501,7 @@ void func_80B4B218(Actor* thisx, GlobalContext* globalCtx) { s16 diff; EnInvadepoh* this = THIS; s16 temp_v1; - s32 sp38 = (this->actor.flags & 0x40) == 0x40; + s32 sp38 = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); Player* player; AlienBehaviorInfo* substruct = &this->behaviorInfo; @@ -3650,7 +3650,7 @@ void func_80B4B8BC(Actor* thisx, GlobalContext* globalCtx) { if (D_80B4E940 == 2) { this->actor.update = func_80B4BA84; this->actor.draw = func_80B4E660; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; func_80B4B430(this); } else if (D_80B4E940 == 1) { this->actor.update = func_80B4BA30; @@ -3667,7 +3667,7 @@ void func_80B4BA30(Actor* thisx, GlobalContext* globalCtx) { if (D_80B4E940 == 2) { this->actor.update = func_80B4BA84; this->actor.draw = func_80B4E660; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; func_80B4B430(this); } } @@ -3675,7 +3675,7 @@ void func_80B4BA30(Actor* thisx, GlobalContext* globalCtx) { void func_80B4BA84(Actor* thisx, GlobalContext* globalCtx) { EnInvadepoh* this = THIS; s32 temp_v0_3; - s32 sp34 = (this->actor.flags & 0x40) == 0x40; + s32 sp34 = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); s32 temp_v1_2; s32 sp2C; s32 temp_v0_2; @@ -3746,16 +3746,16 @@ void func_80B4BC4C(EnInvadepoh* this, GlobalContext* globalCtx) { if (temp_v0 == 0) { this->xzPosAdjFactor = 40.0f; this->unk304 = -0x8000; - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); } else if (temp_v0 < (temp_t6->endPoint - 1)) { this->xzPosAdjFactor = 40.0f; Math_ScaledStepToS(&this->unk304, -0x4800, 0xC8); - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); } else { Math_StepToF(&this->xzPosAdjFactor, 5.0f, 3.0f); Math_ScaledStepToS(&this->unk304, -0x8000, 0x12C); - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); } temp_a0 = this->unk304 + temp_t6->actor.world.rot.y; this->actor.world.pos.x = (Math_SinS(temp_a0) * this->xzPosAdjFactor) + temp_t6->actor.world.pos.x; @@ -3787,7 +3787,7 @@ void func_80B4BC4C(EnInvadepoh* this, GlobalContext* globalCtx) { } } - if (((this->actor.flags & 0x40) == 0x40) && + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } @@ -3914,7 +3914,7 @@ void func_80B4C568(Actor* thisx, GlobalContext* globalCtx) { void func_80B4C5C0(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; - s32 sp2C = (this->actor.flags & 0x40) == 0x40; + s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { @@ -3983,10 +3983,10 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { } } - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); } else { this->unk378 = 0; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); } temp_v1_3 = globalCtx->gameplayFrames % 128; @@ -4008,7 +4008,7 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { substruct->unk26.y = CLAMP(temp_v1_4, -8000, 8000); } - if (((this->actor.flags & 0x40) == 0x40) && + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 7.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } @@ -4130,7 +4130,7 @@ void func_80B4CFFC(Actor* thisx, GlobalContext* globalCtx) { void func_80B4D054(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; - s32 sp2C = (this->actor.flags & 0x40) == 0x40; + s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { diff --git a/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c b/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c index ff1f9b6ca..5696764dd 100644 --- a/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c +++ b/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c @@ -6,7 +6,7 @@ #include "z_en_invadepoh_demo.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnInvadepohDemo*)thisx) diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c index 5e7292df5..99d19a1cf 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -9,7 +9,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_ishi/object_ishi.h" -#define FLAGS 0x00800010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000) #define THIS ((EnIshi*)thisx) @@ -310,9 +310,9 @@ void func_8095DFF0(EnIshi* this, GlobalContext* globalCtx) { sp3C = Item_DropCollectible(globalCtx, &this->actor.world.pos, temp | (ENISHI_GET_FE00(&this->actor) << 8)); if (sp3C != NULL) { Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, 0); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, 1); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, 1); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); Matrix_GetStateTranslationAndScaledY(1.0f, &sp30); sp2C = Math3D_Parallel(&sp30, &D_8095F778); if (sp2C < 0.707f) { @@ -444,7 +444,7 @@ void func_8095E5AC(EnIshi* this) { void func_8095E5C0(EnIshi* this, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_196)) { this->actor.objBankIndex = this->unk_196; - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; if (!ENISHI_GET_8(&this->actor)) { this->actor.draw = func_8095F61C; } else { @@ -522,7 +522,7 @@ void func_8095E660(EnIshi* this, GlobalContext* globalCtx) { void func_8095E934(EnIshi* this) { this->actionFunc = func_8095E95C; this->actor.room = -1; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; } void func_8095E95C(EnIshi* this, GlobalContext* globalCtx) { @@ -652,7 +652,7 @@ void func_8095EBDC(EnIshi* this, GlobalContext* globalCtx) { } void func_8095F060(EnIshi* this) { - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; ActorCutscene_SetIntentToPlay(this->actor.cutscene); this->actionFunc = func_8095F0A4; } 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 46122b537..8051f71f4 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 @@ -7,7 +7,7 @@ #include "z_en_jc_mato.h" #include "objects/object_tru/object_tru.h" -#define FLAGS 0x00004030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_4000) #define THIS ((EnJcMato*)thisx) 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 46f9ec21d..8218d7c63 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 @@ -6,7 +6,7 @@ #include "z_en_jgame_tsn.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnJgameTsn*)thisx) 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 ecd2fafa1..15426db82 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.c +++ b/src/overlays/actors/ovl_En_Js/z_en_js.c @@ -6,7 +6,7 @@ #include "z_en_js.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnJs*)thisx) diff --git a/src/overlays/actors/ovl_En_Jso/z_en_jso.c b/src/overlays/actors/ovl_En_Jso/z_en_jso.c index e20a4de3a..3c7e5ce75 100644 --- a/src/overlays/actors/ovl_En_Jso/z_en_jso.c +++ b/src/overlays/actors/ovl_En_Jso/z_en_jso.c @@ -6,7 +6,7 @@ #include "z_en_jso.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnJso*)thisx) diff --git a/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c b/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c index ad00e6d87..8d29b9383 100644 --- a/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c +++ b/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c @@ -6,7 +6,7 @@ #include "z_en_jso2.h" -#define FLAGS 0x80100035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_100000 | ACTOR_FLAG_80000000) #define THIS ((EnJso2*)thisx) 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 eef75acf9..721e8c1a4 100644 --- a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c +++ b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c @@ -6,7 +6,7 @@ #include "z_en_kaizoku.h" -#define FLAGS 0x00100015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_100000) #define THIS ((EnKaizoku*)thisx) 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 bd750edae..a11af566a 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -7,7 +7,7 @@ #include "z_en_kakasi.h" #include "objects/object_ka/object_ka.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnKakasi*)thisx) @@ -166,7 +166,7 @@ void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx) { this->aboveGroundStatus = GET_KAKASI_ABOVE_GROUND(this); this->actor.world.rot.x = 0; - this->actor.flags |= 0x400; + this->actor.flags |= ACTOR_FLAG_400; this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); @@ -179,14 +179,14 @@ void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx) { } if (this->aboveGroundStatus) { - if (gSaveContext.weekEventReg[79] & 0x8) { + if (gSaveContext.weekEventReg[79] & 8) { this->aboveGroundStatus = ENKAKASI_ABOVE_GROUND_TYPE; this->songSummonDist = 80.0f; EnKakasi_SetupIdleUnderground(this); } else { Actor_SetFocus(&this->actor, 60.0f); this->unkFunc = EnKakasi_8096F88C; - if (gSaveContext.weekEventReg[83] & 0x1) { + if (gSaveContext.weekEventReg[83] & 1) { EnKakasi_InitTimeSkipDialogue(this); } else { EnKakasi_SetupIdleStanding(this); @@ -311,16 +311,16 @@ void EnKakasi_TimeSkipDialogue(EnKakasi* this, GlobalContext* globalCtx) { if (this->actor.textId == 0) { // dialogue after skipped time 'did you feel that? went by in an instant' this->actor.textId = 0x1653; - gSaveContext.weekEventReg[0x53] &= (u8)~1; + gSaveContext.weekEventReg[83] &= (u8)~1; this->unkMsgState1AC = 5; player->stateFlags1 |= 0x20; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { player->stateFlags1 &= ~0x20; this->unkState196 = 2; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = EnKakasi_RegularDialogue; } else { func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, -1); @@ -947,7 +947,7 @@ void EnKakasi_DancingNightAway(EnKakasi* this, GlobalContext* globalCtx) { gSaveContext.time = CLOCK_TIME(18, 0); gSaveContext.respawnFlag = -8; } - gSaveContext.weekEventReg[0x53] |= 1; + gSaveContext.weekEventReg[83] |= 1; this->unk190 = 0; this->actionFunc = EnKakasi_DoNothing; } @@ -1028,15 +1028,15 @@ void EnKakasi_DiggingAway(EnKakasi* this, GlobalContext* globalCtx) { void EnKakasi_SetupIdleUnderground(EnKakasi* this) { this->actor.shape.yOffset = -7000.0; this->actor.draw = NULL; - this->actor.flags |= 0x8000000; + this->actor.flags |= ACTOR_FLAG_8000000; this->unkState196 = 5; this->actionFunc = EnKakasi_IdleUnderground; } void EnKakasi_IdleUnderground(EnKakasi* this, GlobalContext* globalCtx) { - if ((gSaveContext.weekEventReg[79] & 0x8) && this->actor.xzDistToPlayer < this->songSummonDist && + if ((gSaveContext.weekEventReg[79] & 8) && this->actor.xzDistToPlayer < this->songSummonDist && (BREG(1) != 0 || globalCtx->msgCtx.ocarinaMode == 0xD)) { - this->actor.flags &= ~0x8000000; + this->actor.flags &= ~ACTOR_FLAG_8000000; globalCtx->msgCtx.ocarinaMode = 4; this->actionFunc = EnKakasi_SetupRiseOutOfGround; } 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 86c924298..1ec39194d 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -7,7 +7,7 @@ #include "z_en_kame.h" #include "objects/object_tl/object_tl.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnKame*)thisx) @@ -169,7 +169,7 @@ void func_80AD6F9C(EnKame* this) { this->unk_2B0 = 1.0f; this->collider.base.colType = COLTYPE_HIT3; this->unk_2A2 = 80; - this->actor.flags &= ~0x400; + this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } @@ -179,7 +179,7 @@ void func_80AD7018(EnKame* this, GlobalContext* globalCtx) { this->collider.base.colType = COLTYPE_HIT6; this->unk_2B0 = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2C8, 10, 2, 0.3f, 0.2f); - this->actor.flags |= 0x400; + this->actor.flags |= ACTOR_FLAG_400; } } @@ -320,7 +320,7 @@ void func_80AD76CC(EnKame* this) { Math_Vec3f_Copy(&this->unk_2BC, &this->actor.home.pos); this->unk_29E = 0; } - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->actionFunc = func_80AD7798; } @@ -388,7 +388,7 @@ void func_80AD7948(EnKame* this, GlobalContext* globalCtx) { this->unk_2AC -= 0.1f; this->collider.base.atFlags &= ~AT_ON; if (this->unk_2AC < 0.5f) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; func_80AD7B18(this); } } else { @@ -438,7 +438,7 @@ void func_80AD7C54(EnKame* this) { this->collider.base.acFlags &= ~AC_ON; this->collider.base.atFlags &= ~AT_ON; this->collider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; this->actor.shape.rot.z = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_REVERSE); this->actionFunc = func_80AD7D40; @@ -555,8 +555,8 @@ void func_80AD8148(EnKame* this, GlobalContext* globalCtx) { } } this->actor.bgCheckFlags &= ~0x1; - this->actor.flags &= ~0x1; - this->actor.flags |= 0x10; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_DEAD); this->unk_29E = 0; this->actionFunc = func_80AD825C; @@ -683,7 +683,7 @@ void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { } } - if ((globalCtx->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < 40000.0f) && + if ((globalCtx->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < SQ(200.0f)) && (this->collider.base.acFlags & AC_ON)) { func_80AD7018(this, globalCtx); func_80AD7C54(this); diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c index 270b7007d..e3edc7311 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -8,7 +8,7 @@ #include "objects/object_kanban/object_kanban.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnKanban*)thisx) @@ -146,7 +146,7 @@ void EnKanban_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); if (this->actor.params != ENKANBAN_PIECE) { this->actor.targetMode = 0; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_19A = Rand_ZeroFloat(1.9f); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -230,7 +230,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->zTargetTimer == 1) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } if (this->partFlags == 0xFFFF) { @@ -381,8 +381,8 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { piece->direction = -1; } piece->airTimer = 100; - piece->actor.flags &= ~1; - piece->actor.flags |= 0x2000000; + piece->actor.flags &= ~ACTOR_FLAG_1; + piece->actor.flags |= ACTOR_FLAG_2000000; this->cutMarkTimer = 5; Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SWORD_STRIKE); } @@ -397,7 +397,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); if (this->actor.xzDistToPlayer > 500.0f) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->partFlags = 0xFFFF; } @@ -875,7 +875,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { ((pDiff + yDiff + rDiff + this->spinRot.x + this->spinRot.z) == 0) && (this->floorRot.x == 0.0f) && (this->floorRot.z == 0.0f)) { signpost->partFlags |= this->partFlags; - signpost->actor.flags |= 1; + signpost->actor.flags |= ACTOR_FLAG_1; Actor_MarkForDeath(&this->actor); return; } 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 a937dbcd6..deedb3e78 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c @@ -6,7 +6,7 @@ #include "z_en_kbt.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnKbt*)thisx) 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 7bd97a99f..50c83422f 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -10,7 +10,7 @@ #include "objects/object_kgy/object_kgy.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnKgy*)thisx) @@ -101,7 +101,7 @@ void EnKgy_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.z, 255, 64, 64, -1); this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); this->unk_300 = -1; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } void EnKgy_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -460,7 +460,7 @@ void func_80B417B8(EnKgy* this, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_801477B4(globalCtx); func_80B413C8(this); - this->actor.flags &= ~0x100; + this->actor.flags &= ~ACTOR_FLAG_100; this->actionFunc = func_80B419B0; func_80B40E18(this, 7); } @@ -488,7 +488,7 @@ void func_80B418C4(EnKgy* this, GlobalContext* globalCtx) { func_80B413C8(this); ActorCutscene_SetIntentToPlay(this->unk_2D4[5]); this->actionFunc = func_80B41858; - this->actor.flags &= ~0x100; + this->actor.flags &= ~ACTOR_FLAG_100; } func_80B40EE8(this, globalCtx); } @@ -575,7 +575,7 @@ void func_80B41C54(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { this->actionFunc = func_80B41C30; - this->actor.flags &= ~0x100; + this->actor.flags &= ~ACTOR_FLAG_100; } func_80B40EE8(this, globalCtx); } @@ -583,7 +583,7 @@ void func_80B41C54(EnKgy* this, GlobalContext* globalCtx) { void func_80B41CBC(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_80B40E18(this, this->actor.textId); this->actionFunc = func_80B41E18; func_80B411DC(this, globalCtx, 4); @@ -596,7 +596,7 @@ void func_80B41D64(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Actor_HasParent(&this->actor, globalCtx)) { this->actionFunc = func_80B41CBC; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); } else { Actor_PickUp(&this->actor, globalCtx, this->unk_2EA, 2000.0f, 1000.0f); @@ -859,7 +859,7 @@ void func_80B42660(EnKgy* this, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { func_801477B4(globalCtx); func_80B413C8(this); - this->actor.flags &= ~0x100; + this->actor.flags &= ~ACTOR_FLAG_100; this->actionFunc = func_80B42714; func_80B40E18(this, 7); } @@ -947,9 +947,9 @@ void func_80B4296C(EnKgy* this, GlobalContext* globalCtx) { } func_80B411DC(this, globalCtx, 0); func_80B40E18(this, this->actor.textId); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } else { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_NONE); } } diff --git a/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c b/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c index 3ad020f92..5a83ecad4 100644 --- a/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c +++ b/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c @@ -6,7 +6,7 @@ #include "z_en_kitan.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnKitan*)thisx) diff --git a/src/overlays/actors/ovl_En_Knight/z_en_knight.c b/src/overlays/actors/ovl_En_Knight/z_en_knight.c index 3c71d5a40..8f6464411 100644 --- a/src/overlays/actors/ovl_En_Knight/z_en_knight.c +++ b/src/overlays/actors/ovl_En_Knight/z_en_knight.c @@ -6,7 +6,7 @@ #include "z_en_knight.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnKnight*)thisx) 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 b7abdebdf..cde905653 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c @@ -6,7 +6,7 @@ #include "z_en_kujiya.h" -#define FLAGS 0x08000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_8000000) #define THIS ((EnKujiya*)thisx) 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 194b99b7a..9b8b86969 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -6,7 +6,7 @@ #include "z_en_kusa.h" -#define FLAGS 0x00800010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000) #define THIS ((EnKusa*)thisx) diff --git a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c index 12ce6eecf..1d37f0fa9 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -8,7 +8,7 @@ #include "objects/gameplay_field_keep/gameplay_field_keep.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00800010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000) #define THIS ((EnKusa2*)thisx) @@ -282,7 +282,7 @@ void func_80A5BB40(EnKusa2* this, GlobalContext* globalCtx, s32 arg2) { f32 temp_f24; s16 temp_s0; - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { for (i = 0; i <= arg2; i++) { temp_s0 = Rand_S16Offset(-16000, 32000) + this->actor.world.rot.y; temp_f20 = Math_SinS(temp_s0); @@ -372,7 +372,7 @@ void func_80A5BF84(EnKusa2* this, GlobalContext* globalCtx) { } s32 func_80A5BFD8(EnKusa2* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & 2) { + if (this->collider.base.acFlags & AC_HIT) { s32 pad; func_80A5CF44(this); @@ -860,7 +860,7 @@ void EnKusa2_Init(Actor* thisx, GlobalContext* globalCtx) { if (!ENKUSA2_GET_1(&this->actor)) { this->actor.update = func_80A5E604; this->actor.draw = NULL; - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_20; func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 1); this->unk_1BE = 0; if (D_80A5EAEC != 0) { diff --git a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c index bfe535600..8669a3544 100644 --- a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c +++ b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c @@ -6,7 +6,7 @@ #include "z_en_lift_nuts.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnLiftNuts*)thisx) diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c index 22a1f73cc..c38faff3e 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c @@ -6,7 +6,7 @@ #include "z_en_look_nuts.h" -#define FLAGS 0x80000000 +#define FLAGS (ACTOR_FLAG_80000000) #define THIS ((EnLookNuts*)thisx) diff --git a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c index 4a21cdefd..a7f83a42c 100644 --- a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c +++ b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c @@ -6,7 +6,7 @@ #include "z_en_m_thunder.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnMThunder*)thisx) diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index d28ec4622..447749566 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -7,7 +7,7 @@ #include "z_en_ma4.h" #include "objects/object_ma1/object_ma1.h" -#define FLAGS 0x02000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((EnMa4*)thisx) @@ -202,7 +202,7 @@ void EnMa4_Init(Actor* thisx, GlobalContext* globalCtx) { if (CURRENT_DAY == 1) { this->type = MA4_TYPE_DAY1; - } else if (gSaveContext.weekEventReg[0x16] & 1) { // Aliens defeated + } else if (gSaveContext.weekEventReg[22] & 1) { // Aliens defeated this->type = MA4_TYPE_ALIENS_DEFEATED; } else { this->type = MA4_TYPE_ALIENS_WON; @@ -240,7 +240,7 @@ void EnMa4_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnMa4* this = THIS; Collider_DestroyCylinder(globalCtx, &this->collider); - gSaveContext.weekEventReg[0x8] &= (u8)~0x01; + gSaveContext.weekEventReg[8] &= (u8)~1; } // Running in circles in the ranch @@ -332,7 +332,7 @@ void EnMa4_Wait(EnMa4* this, GlobalContext* globalCtx) { s16 yaw = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; if ((this->state == MA4_STATE_AFTERHORSEBACKGAME) || (this->state == MA4_STATE_AFTERDESCRIBETHEMCS)) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; } else if (this->type != MA4_TYPE_ALIENS_WON) { EnMa4_RunInCircles(this, globalCtx); } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -374,7 +374,7 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3341: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - gSaveContext.weekEventReg[0x15] |= 0x20; + gSaveContext.weekEventReg[21] |= 0x20; func_801518B0(globalCtx, 0x3343, &this->actor); this->textId = 0x3343; } else { @@ -390,7 +390,7 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3346: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - gSaveContext.weekEventReg[0x15] |= 0x20; + gSaveContext.weekEventReg[21] |= 0x20; func_801518B0(globalCtx, 0x3343, &this->actor); this->textId = 0x3343; } else { @@ -694,7 +694,7 @@ void EnMa4_InitHorsebackGame(EnMa4* this, GlobalContext* globalCtx) { globalCtx->interfaceCtx.unk_280 = 1; func_8010E9F0(4, 0); - gSaveContext.weekEventReg[0x8] |= 0x01; + gSaveContext.weekEventReg[8] |= 1; func_80112AFC(globalCtx); player->stateFlags1 |= 0x20; this->actionFunc = EnMa4_SetupHorsebackGameWait; @@ -730,7 +730,7 @@ void EnMa4_HorsebackGameWait(EnMa4* this, GlobalContext* globalCtx) { } void EnMa4_SetupHorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { - gSaveContext.weekEventReg[0x8] &= (u8)~0x01; + gSaveContext.weekEventReg[8] &= (u8)~1; this->actionFunc = EnMa4_HorsebackGameEnd; Audio_QueueSeqCmd(NA_BGM_STOP); Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000); @@ -846,12 +846,12 @@ void EnMa4_SetupEndEponasSongCs(EnMa4* this) { void EnMa4_EndEponasSongCs(EnMa4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { player->stateFlags1 &= ~0x20; func_801518B0(globalCtx, 0x334C, &this->actor); this->textId = 0x334C; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; EnMa4_SetupDialogueHandler(this); } else { func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); @@ -877,7 +877,7 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { switch (this->type) { case MA4_TYPE_DAY1: if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - if ((gSaveContext.weekEventReg[0x15] & 0x80)) { + if ((gSaveContext.weekEventReg[21] & 0x80)) { EnMa4_SetFaceExpression(this, 3, 3); func_801518B0(globalCtx, 0x3337, &this->actor); this->textId = 0x3337; @@ -885,11 +885,11 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { } else { func_801518B0(globalCtx, 0x3335, &this->actor); this->textId = 0x3335; - gSaveContext.weekEventReg[0x15] |= 0x80; + gSaveContext.weekEventReg[21] |= 0x80; } } else if (this->state == MA4_STATE_DEFAULT) { - if ((gSaveContext.weekEventReg[0x15] & 0x40)) { - if (!(gSaveContext.weekEventReg[0x15] & 0x20)) { + if ((gSaveContext.weekEventReg[21] & 0x40)) { + if (!(gSaveContext.weekEventReg[21] & 0x20)) { func_801518B0(globalCtx, 0x3346, &this->actor); this->textId = 0x3346; } else { @@ -899,7 +899,7 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { } else { func_801518B0(globalCtx, 0x3338, &this->actor); this->textId = 0x3338; - gSaveContext.weekEventReg[0x15] |= 0x40; + gSaveContext.weekEventReg[21] |= 0x40; } } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { @@ -922,18 +922,18 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { } } this->state = MA4_STATE_DEFAULT; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->state == MA4_STATE_AFTERDESCRIBETHEMCS) { // "Cremia doesn't believe me..." func_801518B0(globalCtx, 0x3340, &this->actor); this->textId = 0x3340; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } break; case MA4_TYPE_ALIENS_DEFEATED: if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - if ((gSaveContext.weekEventReg[0x15] & 0x80)) { + if ((gSaveContext.weekEventReg[21] & 0x80)) { EnMa4_SetFaceExpression(this, 3, 3); func_801518B0(globalCtx, 0x3337, &this->actor); this->textId = 0x3337; @@ -941,7 +941,7 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { } else { func_801518B0(globalCtx, 0x3335, &this->actor); this->textId = 0x3335; - gSaveContext.weekEventReg[0x15] |= 0x80; + gSaveContext.weekEventReg[21] |= 0x80; } } else if (this->state == MA4_STATE_DEFAULT) { func_801518B0(globalCtx, 0x3354, &this->actor); @@ -964,7 +964,7 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { } } this->state = MA4_STATE_DEFAULT; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } break; @@ -992,7 +992,7 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { } } this->state = MA4_STATE_DEFAULT; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } break; diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c index 69948f426..9fbf4427d 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -7,7 +7,7 @@ #include "z_en_ma_yto.h" #include "objects/object_ma2/object_ma2.h" -#define FLAGS 0x02100009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnMaYto*)thisx) @@ -146,7 +146,7 @@ void EnMaYto_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk320 = 0; this->eyeTexIndex = 0; - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { EnMaYto_SetFaceExpression(this, 0, 1); } else { EnMaYto_SetFaceExpression(this, 5, 2); @@ -180,19 +180,19 @@ void EnMaYto_Init(Actor* thisx, GlobalContext* globalCtx) { s32 EnMaYto_CheckValidSpawn(EnMaYto* this, GlobalContext* globalCtx) { switch (this->type) { case MA_YTO_TYPE_DEFAULT: - if (CURRENT_DAY == 3 && !(gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 3 && !(gSaveContext.weekEventReg[22] & 1)) { return false; } break; case MA_YTO_TYPE_DINNER: - if (CURRENT_DAY != 1 && (gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY != 1 && (gSaveContext.weekEventReg[22] & 1)) { return false; } break; case MA_YTO_TYPE_BARN: - if (gSaveContext.weekEventReg[0x16] & 1) { + if (gSaveContext.weekEventReg[22] & 1) { if (((this->actor.params & 0x0F00) >> 8) != 0) { return false; } @@ -205,9 +205,9 @@ s32 EnMaYto_CheckValidSpawn(EnMaYto* this, GlobalContext* globalCtx) { break; case MA_YTO_TYPE_AFTERMILKRUN: - // if (!(ProtectedCremia) && !(gSaveContext.weekEventReg[0x34] & 2)) || (PlayedMilkMinigame)) - if ((!(gSaveContext.weekEventReg[0x34] & 1) && !(gSaveContext.weekEventReg[0x34] & 2)) || - (gSaveContext.weekEventReg[0xE] & 1)) { + // if (!(ProtectedCremia) && !(gSaveContext.weekEventReg[52] & 2)) || (PlayedMilkMinigame)) + if ((!(gSaveContext.weekEventReg[52] & 1) && !(gSaveContext.weekEventReg[52] & 2)) || + (gSaveContext.weekEventReg[14] & 1)) { return false; } break; @@ -235,7 +235,7 @@ void EnMaYto_InitAnimation(EnMaYto* this, GlobalContext* globalCtx) { case MA_YTO_TYPE_BARN: // if (AliensDefeated) - if (gSaveContext.weekEventReg[0x16] & 1) { + if (gSaveContext.weekEventReg[22] & 1) { EnMaYto_ChangeAnim(this, 12); } else { EnMaYto_ChangeAnim(this, 8); @@ -273,7 +273,7 @@ void EnMaYto_ChooseAction(EnMaYto* this, GlobalContext* globalCtx) { case MA_YTO_TYPE_AFTERMILKRUN: this->unk310 = 0; - if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI && (gSaveContext.weekEventReg[0x34] & 1) && + if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI && (gSaveContext.weekEventReg[52] & 1) && (Rand_Next() & 0x80)) { EnMaYto_SetupBeginWarmFuzzyFeelingCs(this); } else { @@ -282,7 +282,7 @@ void EnMaYto_ChooseAction(EnMaYto* this, GlobalContext* globalCtx) { break; case MA_YTO_TYPE_4: - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; EnMaYto_SetupWarmFuzzyFeelingCs(this); break; @@ -328,7 +328,7 @@ s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx) { return 0; case MA_YTO_TYPE_DINNER: - if (!(gSaveContext.weekEventReg[0x16] & 1) && CURRENT_DAY == 2) { + if (!(gSaveContext.weekEventReg[22] & 1) && CURRENT_DAY == 2) { return 0; } if (EnMaYto_SearchRomani(this, globalCtx)) { @@ -338,7 +338,7 @@ s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx) { case MA_YTO_TYPE_BARN: // if (AliensDefeated) - if (gSaveContext.weekEventReg[0x16] & 1) { + if (gSaveContext.weekEventReg[22] & 1) { if (EnMaYto_SearchRomani(this, globalCtx)) { return 2; } @@ -492,7 +492,7 @@ void EnMaYto_DefaultChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) } void EnMaYto_SetupDinnerWait(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { func_80B90E50(this, 0); this->unk31E = 0; } else { @@ -533,7 +533,7 @@ void EnMaYto_DinnerWait(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupDinnerDialogueHandler(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { func_80B90E50(this, 1); } else { func_80B90E50(this, 2); @@ -684,7 +684,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupBarnWait(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { EnMaYto_ChangeAnim(this, 13); func_80B90E50(this, 0); this->unk31E = 0; @@ -712,7 +712,7 @@ void EnMaYto_BarnWait(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_BarnStartDialogue(this, globalCtx); EnMaYto_SetupBarnDialogueHandler(this); - } else if (!(gSaveContext.weekEventReg[0x16] & 1) || ABS_ALT(direction) < 0x2000) { + } else if (!(gSaveContext.weekEventReg[22] & 1) || ABS_ALT(direction) < 0x2000) { func_800B8614(&this->actor, globalCtx, 100.0f); child = this->actor.child; @@ -724,7 +724,7 @@ void EnMaYto_BarnWait(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupBarnDialogueHandler(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { func_80B90E50(this, 1); } else { func_80B90E50(this, 2); @@ -872,7 +872,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this) { - if (gSaveContext.weekEventReg[0x34] & 1) { // if (ProtectedCremia) + if (gSaveContext.weekEventReg[52] & 1) { // if (ProtectedCremia) EnMaYto_SetFaceExpression(this, 3, 1); } else { func_801A3098(NA_BGM_FAILURE_1); @@ -882,12 +882,12 @@ void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this) { } void EnMaYto_AfterMilkRunInit(EnMaYto* this, GlobalContext* globalCtx) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; - if (gSaveContext.weekEventReg[0x34] & 1) { // if (ProtectedCremia) + if (gSaveContext.weekEventReg[52] & 1) { // if (ProtectedCremia) func_801518B0(globalCtx, 0x33C1, &this->actor); this->textId = 0x33C1; } else { @@ -896,7 +896,7 @@ void EnMaYto_AfterMilkRunInit(EnMaYto* this, GlobalContext* globalCtx) { func_801518B0(globalCtx, 0x33C0, &this->actor); this->textId = 0x33C0; // Attempted Cremia Cart Ride - gSaveContext.weekEventReg[0xE] |= 0x1; + gSaveContext.weekEventReg[14] |= 1; this->unk310 = 4; EnMaYto_SetupPostMilkRunWaitDialogueEnd(this); func_80151BB4(globalCtx, 6); @@ -978,7 +978,7 @@ void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx) { func_801518B0(globalCtx, 0x33C3, &this->actor); this->textId = 0x33C3; // Attempted Cremia Cart Ride - gSaveContext.weekEventReg[0xE] |= 0x1; + gSaveContext.weekEventReg[14] |= 1; this->unk310 = 3; func_80151BB4(globalCtx, 0x20); func_80151BB4(globalCtx, 0x1F); @@ -990,7 +990,7 @@ void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx) { func_801518B0(globalCtx, 0x33D0, &this->actor); this->textId = 0x33D0; // Attempted Cremia Cart Ride - gSaveContext.weekEventReg[0xE] |= 0x1; + gSaveContext.weekEventReg[14] |= 1; this->unk310 = 3; func_80151BB4(globalCtx, 6); EnMaYto_SetupPostMilkRunWaitDialogueEnd(this); @@ -1041,7 +1041,7 @@ void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx) { case 2: // Attempted Cremia Cart Ride - gSaveContext.weekEventReg[0xE] |= 1; + gSaveContext.weekEventReg[14] |= 1; EnMaYto_ChangeAnim(this, 18); break; @@ -1225,7 +1225,7 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { void EnMaYto_BarnStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { // if (AliensDefeated) - if (gSaveContext.weekEventReg[0x16] & 1) { + if (gSaveContext.weekEventReg[22] & 1) { if (CURRENT_DAY == 2) { if (this->unk310 == 1) { func_801518B0(globalCtx, 0x33AE, &this->actor); @@ -1348,7 +1348,7 @@ void EnMaYto_SetFaceExpression(EnMaYto* this, s16 overrideEyeTexIndex, s16 mouth } void EnMaYto_InitFaceExpression(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { EnMaYto_SetFaceExpression(this, 0, 1); EnMaYto_SetRomaniFaceExpression(this, 0, 0); } else { @@ -1360,19 +1360,19 @@ void EnMaYto_InitFaceExpression(EnMaYto* this) { s32 EnMaYto_HasSpokeToPlayerToday(void) { switch (CURRENT_DAY) { case 1: - if (gSaveContext.weekEventReg[0xD] & 0x4) { + if (gSaveContext.weekEventReg[13] & 4) { return true; } break; case 2: - if (gSaveContext.weekEventReg[0xD] & 0x8) { + if (gSaveContext.weekEventReg[13] & 8) { return true; } break; case 3: - if (gSaveContext.weekEventReg[0xD] & 0x10) { + if (gSaveContext.weekEventReg[13] & 0x10) { return true; } break; @@ -1384,17 +1384,17 @@ s32 EnMaYto_HasSpokeToPlayer(void) { // Please note each case doesn't have their respective `break`s. switch (CURRENT_DAY) { case 3: - if (gSaveContext.weekEventReg[0xD] & 0x10) { + if (gSaveContext.weekEventReg[13] & 0x10) { return true; } case 2: - if (gSaveContext.weekEventReg[0xD] & 0x8) { + if (gSaveContext.weekEventReg[13] & 8) { return true; } case 1: - if (gSaveContext.weekEventReg[0xD] & 0x4) { + if (gSaveContext.weekEventReg[13] & 4) { return true; } } @@ -1404,15 +1404,15 @@ s32 EnMaYto_HasSpokeToPlayer(void) { void EnMaYto_SetTalkedFlag(void) { switch (CURRENT_DAY) { case 1: - gSaveContext.weekEventReg[0xD] |= 0x4; + gSaveContext.weekEventReg[13] |= 4; break; case 2: - gSaveContext.weekEventReg[0xD] |= 0x8; + gSaveContext.weekEventReg[13] |= 8; break; case 3: - gSaveContext.weekEventReg[0xD] |= 0x10; + gSaveContext.weekEventReg[13] |= 0x10; break; } } @@ -1464,7 +1464,7 @@ void EnMaYto_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx); - if (this->type == MA_YTO_TYPE_BARN && (gSaveContext.weekEventReg[0x16] & 1)) { // Alieans defeated + if (this->type == MA_YTO_TYPE_BARN && (gSaveContext.weekEventReg[22] & 1)) { // Alieans defeated gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gCremiaWoodenBox); } diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c index dc1129e07..1dd02ecc9 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c @@ -7,7 +7,7 @@ #include "z_en_ma_yts.h" #include "objects/object_ma1/object_ma1.h" -#define FLAGS 0x02100009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnMaYts*)thisx) @@ -145,7 +145,7 @@ void EnMaYts_InitAnimation(EnMaYts* this, GlobalContext* globalCtx) { case MA_YTS_TYPE_SITTING: this->actor.targetMode = 6; // Day 1 or "Winning" the alien invasion - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { EnMaYts_ChangeAnim(this, 14); } else { EnMaYts_ChangeAnim(this, 18); @@ -178,14 +178,14 @@ s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { case 2: // Failing the alien invasion - if (!(gSaveContext.weekEventReg[0x16] & 1)) { + if (!(gSaveContext.weekEventReg[22] & 1)) { return false; } break; case 3: // "Winning" the alien invasion - if (gSaveContext.weekEventReg[0x16] & 1) { + if (gSaveContext.weekEventReg[22] & 1) { return false; } break; @@ -194,7 +194,7 @@ s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { case MA_YTS_TYPE_BARN: // Failing the alien invasion - if (!(gSaveContext.weekEventReg[0x16] & 1)) { + if (!(gSaveContext.weekEventReg[22] & 1)) { return false; } else if (gSaveContext.time >= CLOCK_TIME(20, 0) && CURRENT_DAY == 3) { return false; @@ -203,7 +203,7 @@ s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { case MA_YTS_TYPE_SLEEPING: // "Winning" the alien invasion - if (gSaveContext.weekEventReg[0x16] & 1) { + if (gSaveContext.weekEventReg[22] & 1) { return false; } break; @@ -250,7 +250,7 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { this->hasBow = false; } - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { this->overrideEyeTexIndex = 0; this->eyeTexIndex = 0; this->mouthTexIndex = 0; @@ -268,7 +268,7 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { this->mouthTexIndex = 0; this->unk_32C = 2; EnMaYts_SetupEndCreditsHandler(this); - } else if (CURRENT_DAY == 2 && gSaveContext.isNight == 1 && (gSaveContext.weekEventReg[0x16] & 1)) { + } else if (CURRENT_DAY == 2 && gSaveContext.isNight == 1 && (gSaveContext.weekEventReg[22] & 1)) { EnMaYts_SetupStartDialogue(this); } else { EnMaYts_SetupDoNothing(this); @@ -298,9 +298,9 @@ void EnMaYts_StartDialogue(EnMaYts* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (!(gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { - if (!(gSaveContext.weekEventReg[0x41] & 0x80)) { + if (!(gSaveContext.weekEventReg[65] & 0x80)) { // Saying to non-human Link: "Cremia went to town." - gSaveContext.weekEventReg[0x41] |= 0x80; + gSaveContext.weekEventReg[65] |= 0x80; EnMaYts_SetFaceExpression(this, 0, 0); func_801518B0(globalCtx, 0x335F, &this->actor); this->textId = 0x335F; @@ -312,8 +312,8 @@ void EnMaYts_StartDialogue(EnMaYts* this, GlobalContext* globalCtx) { func_80151BB4(globalCtx, 5); } } else if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE) { - if (!(gSaveContext.weekEventReg[0x41] & 0x40)) { - gSaveContext.weekEventReg[0x41] |= 0x40; + if (!(gSaveContext.weekEventReg[65] & 0x40)) { + gSaveContext.weekEventReg[65] |= 0x40; EnMaYts_SetFaceExpression(this, 0, 0); func_801518B0(globalCtx, 0x3363, &this->actor); this->textId = 0x3363; @@ -323,14 +323,14 @@ void EnMaYts_StartDialogue(EnMaYts* this, GlobalContext* globalCtx) { this->textId = 0x3366; func_80151BB4(globalCtx, 5); } - } else if (!(gSaveContext.weekEventReg[0x15] & 0x20)) { + } else if (!(gSaveContext.weekEventReg[21] & 0x20)) { EnMaYts_SetFaceExpression(this, 0, 0); func_801518B0(globalCtx, 0x3367, &this->actor); this->textId = 0x3367; } else { - if (!(gSaveContext.weekEventReg[0x41] & 0x20)) { + if (!(gSaveContext.weekEventReg[65] & 0x20)) { // Saying to Grasshopper: "Cremia went to town." - gSaveContext.weekEventReg[0x41] |= 0x20; + gSaveContext.weekEventReg[65] |= 0x20; EnMaYts_SetFaceExpression(this, 4, 2); func_801518B0(globalCtx, 0x3369, &this->actor); this->textId = 0x3369; @@ -374,7 +374,7 @@ void EnMaYts_DialogueHandler(EnMaYts* this, GlobalContext* globalCtx) { } void EnMaYts_SetupEndCreditsHandler(EnMaYts* this) { - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; EnMaYts_SetFaceExpression(this, 0, 0); this->actionFunc = EnMaYts_EndCreditsHandler; } diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c index 6f2591952..81687965c 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -7,7 +7,7 @@ #include "z_en_mag.h" #include "objects/object_mag/object_mag.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnMag*)thisx) diff --git a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c index 7d379c08d..0c736886e 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c @@ -6,7 +6,7 @@ #include "z_en_maruta.h" -#define FLAGS 0x00000011 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_10) #define THIS ((EnMaruta*)thisx) diff --git a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c index 6750c81da..d5e15c04d 100644 --- a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c +++ b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c @@ -6,7 +6,7 @@ #include "z_en_minideath.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnMinideath*)thisx) diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index ea3b7a45e..69145c95f 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -8,7 +8,7 @@ #include "objects/object_fr/object_fr.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnMinifrog*)thisx) @@ -130,14 +130,14 @@ void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx) { // Not spoken to MINIFROG_YELLOW if (!(gSaveContext.weekEventReg[34] & 1)) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; } this->actor.home.rot.x = this->actor.home.rot.z = 0; this->frog = NULL; } else { this->frog = EnMinifrog_GetFrog(globalCtx); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; // Frog has been returned if ((gSaveContext.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] & @@ -484,7 +484,7 @@ void EnMinifrog_GetFrogHP(EnMinifrog* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; this->actionFunc = EnMinifrog_EndChoir; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_NONE); } else { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 50.0f); @@ -517,7 +517,7 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { case 0xD76: // "I have been waiting for you, Don Gero. Forgive me if I'm mistaken, but it looks like // you've lost a little weight..." func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; gSaveContext.weekEventReg[34] |= 1; // Spoken to MINIFROG_YELLOW break; case 0xD78: // "Unfortunately, it seems not all of our members have gathered." @@ -549,7 +549,7 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { default: func_801477B4(globalCtx); this->actionFunc = EnMinifrog_SetupYellowFrogDialog; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; break; } } @@ -572,7 +572,8 @@ void EnMinifrog_SetupYellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx func_801518B0(globalCtx, 0xD7F, &this->actor); // "Well, if it isn't the great Don Gero." } } else if ((this->actor.xzDistToPlayer < 150.0f) && - (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) || ((this->actor.flags & 0x10000) == 0x10000)) && + (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) || + CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_10000)) && Player_GetMask(globalCtx) == PLAYER_MASK_DON_GERO) { func_800B8614(&this->actor, globalCtx, 160.0f); } diff --git a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c index b2b8dd5ba..ea4389917 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -7,7 +7,7 @@ #include "z_en_minislime.h" #include "overlays/actors/ovl_En_Bigslime/z_en_bigslime.h" -#define FLAGS 0x00000235 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200) #define THIS ((EnMinislime*)thisx) @@ -121,7 +121,7 @@ static DamageTable sDamageTable = { void EnMinislime_Init(Actor* thisx, GlobalContext* globalCtx) { EnMinislime* this = THIS; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->id = this->actor.params; @@ -506,8 +506,8 @@ void EnMinislime_SetupMoveToBigslime(EnMinislime* this) { } this->frozenAlpha = 0; - if ((this->actor.flags & 0x2000) == 0x2000) { - this->actor.flags &= ~0x2000; + if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + this->actor.flags &= ~ACTOR_FLAG_2000; } this->actionFunc = EnMinislime_MoveToBigslime; } @@ -562,8 +562,8 @@ void EnMinislime_SetupDefeatIdle(EnMinislime* this) { } this->frozenAlpha = 0; - if ((this->actor.flags & 0x2000) == 0x2000) { - this->actor.flags &= ~0x2000; + if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + this->actor.flags &= ~ACTOR_FLAG_2000; } this->actor.shape.rot.x = 0; @@ -630,8 +630,8 @@ void EnMinislime_SetupMoveToGekko(EnMinislime* this) { this->actor.velocity.y = 0.0f; this->collider.base.acFlags &= ~AC_ON; this->collider.base.ocFlags1 &= ~OC1_ON; - if ((this->actor.flags & 0x2000) == 0x2000) { - this->actor.flags &= ~0x2000; + if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + this->actor.flags &= ~ACTOR_FLAG_2000; } this->actionFunc = EnMinislime_MoveToGekko; @@ -720,7 +720,7 @@ void EnMinislime_Update(Actor* thisx, GlobalContext* globalCtx) { } else if ((this->actor.params == MINISLIME_FORM_BIGSLIME) && (this->actionFunc != EnMinislime_MoveToBigslime)) { EnMinislime_SetupMoveToBigslime(this); } else { - if ((this->actor.flags & 0x2000) == 0x2000) { + if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { this->collider.base.acFlags &= ~AC_HIT; return; } 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 514816f10..1cc0cffce 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -6,7 +6,7 @@ #include "z_en_mk.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnMk*)thisx) diff --git a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c index 019e7a848..45eff8050 100644 --- a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c +++ b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c @@ -6,7 +6,7 @@ #include "z_en_mkk.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnMkk*)thisx) diff --git a/src/overlays/actors/ovl_En_Mm/z_en_mm.c b/src/overlays/actors/ovl_En_Mm/z_en_mm.c index 86b9810c5..dfb69be0f 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -7,7 +7,7 @@ #include "z_en_mm.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnMm*)thisx) diff --git a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c index 94507b001..078edb840 100644 --- a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c +++ b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c @@ -6,7 +6,7 @@ #include "z_en_mm2.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnMm2*)thisx) diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index 3c9719008..8ff09e32b 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -6,7 +6,7 @@ #include "z_en_mm3.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnMm3*)thisx) 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 cf9d23cb0..85996fe6c 100644 --- a/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c +++ b/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c @@ -6,7 +6,7 @@ #include "z_en_mnk.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnMnk*)thisx) diff --git a/src/overlays/actors/ovl_En_Ms/z_en_ms.c b/src/overlays/actors/ovl_En_Ms/z_en_ms.c index 8e17adbaf..59aa5a22b 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.c @@ -7,7 +7,7 @@ #include "z_en_ms.h" #include "objects/object_ms/object_ms.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnMs*)thisx) diff --git a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c index 789f308ca..d74f32926 100644 --- a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c +++ b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c @@ -6,7 +6,7 @@ #include "z_en_mt_tag.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnMttag*)thisx) diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c index afb1a80c7..60de87422 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -8,7 +8,7 @@ #include "z_en_mushi2.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnMushi2*)thisx) @@ -991,7 +991,7 @@ void func_80A6AB08(EnMushi2* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.world.rot.z, 0, 0xBB8); this->actor.shape.rot.z = this->actor.world.rot.z; - if ((this->actor.flags & 0x40) && (Rand_ZeroOne() < 0.03f)) { + if ((this->actor.flags & ACTOR_FLAG_40) && (Rand_ZeroOne() < 0.03f)) { Vec3f sp3C; sp3C.x = this->actor.world.pos.x; @@ -1033,8 +1033,8 @@ void func_80A6AE7C(EnMushi2* this, GlobalContext* globalCtx) { func_80A69424(this, globalCtx); temp_f2 = this->actor.scale.x - (1.0f / 20000.0f); Actor_SetScale(&this->actor, CLAMP_MIN(temp_f2, 0.001f)); - if ((this->actor.flags & 0x40) && (this->actor.depthInWater > 5.0f) && (this->actor.depthInWater < 30.0f) && - ((Rand_Next() & 0x1FF) < this->unk_368)) { + if ((this->actor.flags & ACTOR_FLAG_40) && (this->actor.depthInWater > 5.0f) && + (this->actor.depthInWater < 30.0f) && ((Rand_Next() & 0x1FF) < this->unk_368)) { EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, -5.0f, 5.0f, 5.0f, ((Rand_ZeroOne() * 4.0f) + 2.0f) * this->actor.scale.x); } @@ -1082,7 +1082,7 @@ void func_80A6B0D8(EnMushi2* this, GlobalContext* globalCtx) { this->actor.velocity.z = (this->actor.speedXZ * this->unk_328.z) + (-0.01f * this->unk_31C.z) + (this->unk_310.z * temp_f2); - if ((this->actor.flags & 0x40) && (this->unk_368 > 20) && (Rand_ZeroOne() < 0.15f)) { + if ((this->actor.flags & ACTOR_FLAG_40) && (this->unk_368 > 20) && (Rand_ZeroOne() < 0.15f)) { Vec3f sp48; s32 sp44 = 0; @@ -1195,7 +1195,7 @@ void EnMushi2_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { if ((this->actionFunc != func_80A6AE7C) && (this->actionFunc != func_80A6B0D8) && ((this->actionFunc != func_80A6A36C) || (this->unk_36A < 0xDD)) && (((this->actionFunc != func_80A6A5C0) && (this->actionFunc != func_80A6A824) && diff --git a/src/overlays/actors/ovl_En_Muto/z_en_muto.c b/src/overlays/actors/ovl_En_Muto/z_en_muto.c index 10214b609..0e3cbded4 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.c +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.c @@ -7,7 +7,7 @@ #include "z_en_muto.h" #include "objects/object_toryo/object_toryo.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnMuto*)thisx) @@ -134,7 +134,7 @@ void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { this->actor.textId = sTextIds[this->textIdIndex]; if (!this->isInMayorsRoom && (player = GET_PLAYER(globalCtx))->transformation == PLAYER_FORM_DEKU) { - if (!(gSaveContext.weekEventReg[0x58] & 8)) { + if (!(gSaveContext.weekEventReg[88] & 8)) { this->actor.textId = 0x62C; } else { this->actor.textId = 0x62B; @@ -161,7 +161,7 @@ void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { } } else { this->textIdIndex = 0; - if (gSaveContext.weekEventReg[0x3C] & 8) { + if (gSaveContext.weekEventReg[60] & 8) { this->textIdIndex = 1; } if (Player_GetMask(globalCtx) == PLAYER_MASK_COUPLE) { diff --git a/src/overlays/actors/ovl_En_Nb/z_en_nb.c b/src/overlays/actors/ovl_En_Nb/z_en_nb.c index ffd002a40..5f24e5b01 100644 --- a/src/overlays/actors/ovl_En_Nb/z_en_nb.c +++ b/src/overlays/actors/ovl_En_Nb/z_en_nb.c @@ -6,7 +6,7 @@ #include "z_en_nb.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnNb*)thisx) diff --git a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c index 4c3859efd..5e288df38 100644 --- a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c +++ b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c @@ -6,7 +6,7 @@ #include "z_en_neo_reeba.h" -#define FLAGS 0x00000205 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200) #define THIS ((EnNeoReeba*)thisx) diff --git a/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c b/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c index 050d22dac..779de0b8a 100644 --- a/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c +++ b/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c @@ -6,7 +6,7 @@ #include "z_en_nimotsu.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnNimotsu*)thisx) diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index fa560f013..4927031e4 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -7,7 +7,7 @@ #include "z_en_niw.h" #include "objects/object_niw/object_niw.h" -#define FLAGS 0x00800010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000) #define THIS ((EnNiw*)thisx) @@ -118,7 +118,7 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { this->niwType = this->actor.params; Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.flags |= 0x1; // targetable ON + this->actor.flags |= ACTOR_FLAG_1; // targetable ON ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 25.0f); @@ -146,7 +146,7 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; this->unkTimer250 = 30; - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->unknownState28E = 4; this->actionFunc = EnNiw_Held; this->actor.speedXZ = 0.0f; @@ -342,7 +342,7 @@ void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; this->unkTimer250 = 30; - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->unknownState28E = 4; this->actor.speedXZ = 0.0f; this->actionFunc = EnNiw_Held; @@ -438,7 +438,7 @@ void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx) { this->actor.shape.rot.z = 0; rotZ = this->actor.shape.rot.z; this->unknownState28E = 5; - this->actor.flags |= 0x1; // targetable ON + this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnNiw_Thrown; this->actor.shape.rot.y = rotZ; this->actor.shape.rot.x = rotZ; @@ -456,7 +456,7 @@ void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx) { this->actor.shape.rot.x = rotZ; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); Math_Vec3f_Copy(&this->unk2BC, &vec3fcopy); - this->actor.flags |= 0x1; // targetable ON + this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnNiw_Thrown; } func_80891320(this, globalCtx, 2); @@ -494,7 +494,7 @@ void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx) { this->sfxTimer1 = 30; this->unk2EC = 0; this->unkTimer250 = 30; - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->unknownState28E = 4; this->actionFunc = EnNiw_Held; this->actor.speedXZ = 0.0f; @@ -605,7 +605,7 @@ void EnNiw_SetupCuccoStorm(EnNiw* this, GlobalContext* globalCtx) { if (this->unkTimer252 == 0) { this->unkTimer252 = 10; this->yawTowardsPlayer = this->actor.yawTowardsPlayer; - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->unknownState28E = 3; this->actionFunc = EnNiw_CuccoStorm; } diff --git a/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c b/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c index c7e0d5dac..af0722d91 100644 --- a/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c +++ b/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c @@ -7,7 +7,7 @@ #include "z_en_nnh.h" #include "objects/object_nnh/object_nnh.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnNnh*)thisx) diff --git a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c index 4c2cec3fa..3eed47b71 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -8,7 +8,7 @@ #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnNutsball*)thisx) @@ -155,7 +155,7 @@ void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx2) { } Collider_UpdateCylinder(&this->actor, &this->collider); - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); diff --git a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c index 53c38ab6b..4c0fdce1e 100644 --- a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c +++ b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c @@ -6,7 +6,7 @@ #include "z_en_nwc.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnNwc*)thisx) diff --git a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c index 9b0d89cdd..8ce550773 100644 --- a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c +++ b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c @@ -6,7 +6,7 @@ #include "z_en_okarina_effect.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnOkarinaEffect*)thisx) diff --git a/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c b/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c index 096fd9421..5a54da7b1 100644 --- a/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c +++ b/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c @@ -6,7 +6,7 @@ #include "z_en_okarina_tag.h" -#define FLAGS 0x0A000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000) #define THIS ((EnOkarinaTag*)thisx) diff --git a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c index 251f23a30..b11997b82 100644 --- a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c +++ b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c @@ -6,7 +6,7 @@ #include "z_en_okuta.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnOkuta*)thisx) diff --git a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c index 1f93a9786..c904cdd42 100644 --- a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c +++ b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c @@ -6,7 +6,7 @@ #include "z_en_onpuman.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnOnpuman*)thisx) diff --git a/src/overlays/actors/ovl_En_Osk/z_en_osk.c b/src/overlays/actors/ovl_En_Osk/z_en_osk.c index c71650ef1..2faed6abb 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.c +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.c @@ -6,7 +6,7 @@ #include "z_en_osk.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnOsk*)thisx) diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.c b/src/overlays/actors/ovl_En_Osn/z_en_osn.c index 36bdcef8e..7914d0fed 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -7,7 +7,7 @@ #include "z_en_osn.h" #include "objects/object_osn/object_osn.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_8 | ACTOR_FLAG_1) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnOsn*)thisx) diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index eb82a0fdd..e3942aaf3 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -9,7 +9,7 @@ #include "objects/object_fsn/object_fsn.h" #include "objects/object_ani/object_ani.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnOssan*)thisx) @@ -1348,19 +1348,19 @@ u16 EnOssan_GetWelcomeCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx) switch (player->transformation) { case PLAYER_FORM_DEKU: this->animationIdx = 10; - if (gSaveContext.weekEventReg[0x12] & 0x10) { + if (gSaveContext.weekEventReg[18] & 0x10) { return sWelcomeDekuTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeDekuFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; case PLAYER_FORM_ZORA: this->animationIdx = 8; - if (gSaveContext.weekEventReg[0x12] & 8) { + if (gSaveContext.weekEventReg[18] & 8) { return sWelcomeZoraTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeZoraFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; case PLAYER_FORM_GORON: this->animationIdx = 6; - if (gSaveContext.weekEventReg[0x12] & 4) { + if (gSaveContext.weekEventReg[18] & 4) { return sWelcomeGoronTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeGoronFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; @@ -1379,17 +1379,17 @@ u16 EnOssan_GetWelcomePartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { } switch (player->transformation) { case PLAYER_FORM_DEKU: - if (gSaveContext.weekEventReg[0x37] & 0x10) { + if (gSaveContext.weekEventReg[55] & 0x10) { return sWelcomeDekuTextIds[ENOSSAN_PART_TIME_WORKER]; } return sWelcomeDekuFirstTimeTextIds[ENOSSAN_PART_TIME_WORKER]; case PLAYER_FORM_ZORA: - if (gSaveContext.weekEventReg[0x37] & 8) { + if (gSaveContext.weekEventReg[55] & 8) { return sWelcomeZoraTextIds[ENOSSAN_PART_TIME_WORKER]; } return sWelcomeZoraFirstTimeTextIds[ENOSSAN_PART_TIME_WORKER]; case PLAYER_FORM_GORON: - if (gSaveContext.weekEventReg[0x37] & 4) { + if (gSaveContext.weekEventReg[55] & 4) { return sWelcomeGoronTextIds[ENOSSAN_PART_TIME_WORKER]; } return sWelcomeGoronFirstTimeTextIds[ENOSSAN_PART_TIME_WORKER]; @@ -1400,22 +1400,22 @@ u16 EnOssan_GetWelcomePartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { void EnOssan_SetHaveMet(EnOssan* this) { switch (this->textId) { case 0x06A9: - gSaveContext.weekEventReg[0x12] |= 0x10; + gSaveContext.weekEventReg[18] |= 0x10; break; case 0x06C6: - gSaveContext.weekEventReg[0x37] |= 0x10; + gSaveContext.weekEventReg[55] |= 0x10; break; case 0x06A7: - gSaveContext.weekEventReg[0x12] |= 8; + gSaveContext.weekEventReg[18] |= 8; break; case 0x06C4: - gSaveContext.weekEventReg[0x37] |= 8; + gSaveContext.weekEventReg[55] |= 8; break; case 0x06A5: - gSaveContext.weekEventReg[0x12] |= 4; + gSaveContext.weekEventReg[18] |= 4; break; case 0x06C2: - gSaveContext.weekEventReg[0x37] |= 4; + gSaveContext.weekEventReg[55] |= 4; break; } } @@ -1425,7 +1425,7 @@ void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx) { ShopItem* shopItems; if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; this->actor.objBankIndex = this->objIndex; Actor_SetObjectDependency(globalCtx, &this->actor); shopItems = sShops[this->actor.params]; @@ -1493,7 +1493,7 @@ void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx) { this->blinkTimer = 20; this->eyeTexIndex = 0; this->blinkFunc = EnOssan_WaitForBlink; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; EnOssan_SetupAction(this, EnOssan_Idle); } } diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index d9af2acd1..ea58ac8e0 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -9,7 +9,7 @@ #include "objects/object_ot/object_ot.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnOt*)thisx) @@ -141,8 +141,8 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_33C = ENOT_GET_C000(&this->actor); if (this->unk_33C == 0) { D_80B5E880 = this; - this->actor.flags |= 0x8000000; - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.update = func_80B5DB6C; this->actor.draw = NULL; return; @@ -265,8 +265,8 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { case 3: if (!(gSaveContext.weekEventReg[26] & 8)) { - this->actor.flags |= 0x8000000; - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Actor_SetScale(&this->actor, 0.0064999997f); this->collider.dim.radius *= 0.5f; this->collider.dim.height *= 0.5f; @@ -412,10 +412,10 @@ void func_80B5C25C(EnOt* this, GlobalContext* globalCtx) { this->unk_360->unk_32C |= 0x100; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 2, &this->animIdx); SubS_ChangeAnimationBySpeedInfo(&this->unk_360->skelAnime, sAnimations, 2, &this->unk_360->animIdx); - this->actor.flags |= 0x8000000; - this->actor.flags &= ~(0x8 | 0x1); - this->unk_360->actor.flags |= 0x8000000; - this->unk_360->actor.flags &= ~(0x8 | 0x1); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->unk_360->actor.flags |= ACTOR_FLAG_8000000; + this->unk_360->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80B5C9A8(this->unk_360, globalCtx); func_80B5C3B8(this, globalCtx); } @@ -605,14 +605,14 @@ void func_80B5CB0C(EnOt* this, GlobalContext* globalCtx) { } void func_80B5CBA0(EnOt* this, GlobalContext* globalCtx) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); this->actionFunc = func_80B5CBEC; } void func_80B5CBEC(EnOt* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_80B5CC88(this, globalCtx); } else { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); @@ -692,10 +692,10 @@ void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); if (this->unk_32C & 0x800) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); } else { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; if ((player->actor.bgCheckFlags & 1) && !func_801242B4(player) && (this->actor.xzDistToPlayer < 130.0f)) { func_800B8614(&this->actor, globalCtx, 130.0f); } @@ -892,8 +892,8 @@ void func_80B5D648(EnOt* this, GlobalContext* globalCtx) { this->actor.gravity = 0.0f; this->actor.speedXZ = 0.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIdx); - this->actor.flags |= 0x8000000; - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Flags_SetSwitch(globalCtx, ENOT_GET_3F80(&this->actor)); this->actionFunc = func_80B5D750; } @@ -918,8 +918,8 @@ void func_80B5D750(EnOt* this, GlobalContext* globalCtx) { } if ((this->unk_32C & 1) && (this->actor.xzDistToPlayer <= 180.0f)) { - this->actor.flags &= ~0x8000000; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); if (D_80B5E884 != 0) { func_80B5C9A8(this, globalCtx); } else { @@ -939,7 +939,7 @@ void EnOt_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if (this->actor.bgCheckFlags & 0x20) { if (DECR(this->unk_354) == 0) { - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { s32 i; for (i = 0; i < 2; i++) { diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index 644c0d5e9..ceacff185 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -7,7 +7,7 @@ #include "z_en_owl.h" #include "objects/object_owl/object_owl.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnOwl*)thisx) @@ -120,7 +120,7 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.1f); this->actor.update = func_8095CCF4; this->actor.draw = func_8095D074; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3D8 = 0; this->unk_3DA = 0x320; this->unk_3DC = 0x12C; @@ -228,7 +228,7 @@ s32 func_8095A978(EnOwl* this, GlobalContext* globalCtx, u16 textId, f32 targetD this->actor.textId = textId; if (this->actor.xzDistToPlayer < targetDist) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, targetDist, arg4, EXCH_ITEM_NONE); } @@ -294,7 +294,7 @@ void func_8095ABF0(EnOwl* this, GlobalContext* globalCtx) { if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { Audio_QueueSeqCmd(0x110000FF); func_8095AAD0(this, globalCtx); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } } @@ -309,7 +309,7 @@ void func_8095AC50(EnOwl* this, GlobalContext* globalCtx) { func_8095ABA8(this); this->actionFunc = func_8095AB1C; } - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } } @@ -441,7 +441,7 @@ void func_8095B254(EnOwl* this, GlobalContext* globalCtx) { if (this->actionFlags & 1) { EnOwl_ChangeMode(this, func_8095B1E4, func_8095C328, &this->skelAnime1, &object_owl_Anim_001ADC, 0.0f); this->unk_3EA = 6; - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_20; } func_8095B158(this); @@ -504,10 +504,10 @@ void func_8095B574(EnOwl* this, GlobalContext* globalCtx) { this->actionFlags |= 0x40; this->unk_406 = 2; } else if (this->actor.xzDistToPlayer < 200.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 200.0f, 400.0f, EXCH_ITEM_NONE); } else { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } func_8095B480(this, globalCtx); } @@ -671,7 +671,7 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { this->eyeTexIndex = 0; this->blinkTimer = Rand_S16Offset(60, 60); this->actionFlags |= 8; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.home.rot.x = 0; func_8095ACEC(this); this->unk_406 = 0; @@ -683,7 +683,7 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { func_801477B4(globalCtx); Audio_QueueSeqCmd(0x110000FF); func_8095ACEC(this); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.textId = 0xBF0; this->actionFunc = func_8095BE0C; break; @@ -695,7 +695,7 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { case 0xBF5: func_801477B4(globalCtx); Audio_QueueSeqCmd(0x110000FF); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; EnOwl_ChangeMode(this, func_8095B3DC, func_8095C484, &this->skelAnime1, &object_owl_Anim_00CB94, 0.0f); this->eyeTexIndex = 0; @@ -721,10 +721,10 @@ void func_8095BE0C(EnOwl* this, GlobalContext* globalCtx) { func_800B8500(&this->actor, globalCtx, 200.0f, 200.0f, EXCH_ITEM_NONE); } } else if (this->actor.xzDistToPlayer < 200.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 200.0f, 200.0f, EXCH_ITEM_NONE); } else { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } } @@ -738,7 +738,7 @@ void func_8095BF58(EnOwl* this, GlobalContext* globalCtx) { } void func_8095BF78(EnOwl* this, GlobalContext* globalCtx) { - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_20; if (this->actor.xzDistToPlayer > 6000.0f) { Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index 371386f58..4bbe6fa60 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -9,7 +9,7 @@ #include "../ovl_En_Door/z_en_door.h" #include "objects/object_pamera/object_pamera.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnPamera*)thisx) @@ -232,7 +232,7 @@ void EnPamera_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80BD8700(EnPamera* this) { this->hideInisdeTimer = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BD8758; } @@ -273,7 +273,7 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { void func_80BD8908(EnPamera* this) { this->actor.draw = EnPamera_Draw; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80BD8964; } @@ -563,8 +563,8 @@ void EnPamera_Draw(Actor* thisx, GlobalContext* globalCtx) { void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { this->actor.update = func_80BDA344; - this->actor.flags |= 0x2000000; - this->actor.flags |= 0x100000; + this->actor.flags |= ACTOR_FLAG_2000000; + this->actor.flags |= ACTOR_FLAG_100000; if ((gSaveContext.weekEventReg[75] & 0x20) || (gSaveContext.weekEventReg[52] & 0x20)) { func_80BD9E60(this); func_80BD9938(this); @@ -581,7 +581,7 @@ void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { } void func_80BD9904(EnPamera* this) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = &func_80BD9928; } @@ -702,7 +702,7 @@ s32 func_80BD9CB8(EnPamera* this, GlobalContext* globalCtx) { case 2: if (this->actor.draw == NULL) { this->actor.draw = EnPamera_Draw; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } func_80BD9EE0(this); break; diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c index 0849e8cec..963eabe4b 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -9,7 +9,7 @@ #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_bigslime/object_bigslime.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnPametfrog*)thisx) @@ -426,7 +426,7 @@ void EnPametfrog_SetupRearOnSnapper(EnPametfrog* this) { Animation_PlayOnce(&this->skelAnime, &gGekkoStandingIdleAnim); } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.params = GEKKO_ON_SNAPPER; this->actionFunc = EnPametfrog_RearOnSnapper; } @@ -503,7 +503,7 @@ void EnPametfrog_SetupFallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx this->actor.velocity.y = 15.0f; this->actor.world.rot.y = BINANG_ROT180(this->actor.child->world.rot.y); this->actor.shape.rot.y = this->actor.world.rot.y; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->timer = 30; this->collider.base.ocFlags1 |= OC1_ON; yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); @@ -1172,7 +1172,7 @@ void EnPametfrog_SetupCallSnapper(EnPametfrog* this, GlobalContext* globalCtx) { Animation_MorphToPlayOnce(&this->skelAnime, &gGekkoCallAnim, 3.0f); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_GREET); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.colChkInfo.health = 6; this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; @@ -1305,7 +1305,7 @@ void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, GlobalContext* globalCtx) this->collider.base.acFlags &= ~AC_ON; EnPametfrog_ApplyMagicArrowEffects(this, globalCtx); Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; func_801A2ED8(); EnPametfrog_SetupCutscene(this); } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_ZORA_BARRIER) { diff --git a/src/overlays/actors/ovl_En_Paper/z_en_paper.c b/src/overlays/actors/ovl_En_Paper/z_en_paper.c index e629ebf9a..50e364529 100644 --- a/src/overlays/actors/ovl_En_Paper/z_en_paper.c +++ b/src/overlays/actors/ovl_En_Paper/z_en_paper.c @@ -6,7 +6,7 @@ #include "z_en_paper.h" -#define FLAGS 0x02100010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnPaper*)thisx) diff --git a/src/overlays/actors/ovl_En_Part/z_en_part.c b/src/overlays/actors/ovl_En_Part/z_en_part.c index 4f9a7e64f..bbf098c92 100644 --- a/src/overlays/actors/ovl_En_Part/z_en_part.c +++ b/src/overlays/actors/ovl_En_Part/z_en_part.c @@ -6,7 +6,7 @@ #include "z_en_part.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnPart*)thisx) diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c index c47f67c27..4f6f5ceb3 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "objects/object_ph/object_ph.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnPeehat*)thisx) @@ -297,7 +297,7 @@ void func_80897498(EnPeehat* this) { void func_80897520(EnPeehat* this, GlobalContext* globalCtx) { if (!gSaveContext.isNight) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->colliderSphere.base.acFlags |= AC_ON; if (this->actor.xzDistToPlayer < 740.0f) { func_80897648(this); @@ -305,7 +305,7 @@ void func_80897520(EnPeehat* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.shape.yOffset, -1000.0f, 10.0f); } } else { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->colliderSphere.base.acFlags &= ~AC_ON; Math_StepToF(&this->actor.shape.yOffset, -1000.0f, 50.0f); if (this->unk_2B0 != 0) { diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index ad008c3e9..00fbaa2b2 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/object_mm/object_mm.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnPm*)thisx) @@ -815,7 +815,7 @@ void func_80AF8BA8(s32 arg0) { s32 temp; if (!(gSaveContext.weekEventReg[88] & 2)) { - if (gSaveContext.weekEventReg[D_80AFB8D4[arg0] >> 8] & (D_80AFB8D4[arg0] & 0xFF)) { + if (gSaveContext.weekEventReg[D_80AFB8D4[arg0] >> 8] & (D_80AFB8D4[arg0] & (1 | 2 | 4 | 0x38 | 0x40 | 0x80))) { switch (gSaveContext.day) { case 2: gSaveContext.weekEventReg[28] |= 8; @@ -831,7 +831,7 @@ void func_80AF8BA8(s32 arg0) { } temp = gSaveContext.weekEventReg[D_80AFB8E0[arg0] >> 8]; - gSaveContext.weekEventReg[D_80AFB8E0[arg0] >> 8] = temp | (D_80AFB8E0[arg0] & 0xFF); + gSaveContext.weekEventReg[D_80AFB8E0[arg0] >> 8] = temp | (D_80AFB8E0[arg0] & (1 | 2 | 4 | 0x38 | 0x40 | 0x80)); } void func_80AF8C68(EnPm* this, GlobalContext* globalCtx) { @@ -964,7 +964,7 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_36C = arg2->unk8 - arg2->unk4; this->unk_36E = sp56 - arg2->unk4; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; if (gSaveContext.weekEventReg[90] & 8) { this->unk_356 |= 0x800; } @@ -1268,7 +1268,7 @@ s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { s32 ret; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; this->unk_394 = 0; this->unk_356 = 0; @@ -1702,11 +1702,11 @@ void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { if (!func_80133038(globalCtx, D_80AFB900[this->unk_38C], &sp2C) || ((this->unk_258 != sp2C.unk0) && !func_80AF9BF8(this, globalCtx, &sp2C))) { this->actor.shape.shadowDraw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; sp2C.unk0 = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } this->unk_258 = sp2C.unk0; diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c index dce3a55fd..744644e58 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c @@ -6,7 +6,7 @@ #include "z_en_po_composer.h" -#define FLAGS 0x02100019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnPoComposer*)thisx) diff --git a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c index 5641c83e7..52223aaae 100644 --- a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c +++ b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Ma4/z_en_ma4.h" #include "objects/object_po_fusen/object_po_fusen.h" -#define FLAGS 0x80100030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_100000 | ACTOR_FLAG_80000000) #define THIS ((EnPoFusen*)thisx) diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index af8e0f11b..fde3009e6 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c @@ -8,7 +8,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_po_sisters/object_po_sisters.h" -#define FLAGS 0x00005015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) #define THIS ((EnPoSisters*)thisx) @@ -173,7 +173,7 @@ void EnPoSisters_Init(Actor* thisx, GlobalContext* globalCtx) { func_80B1BCF0(this, globalCtx); func_80B1C2E8(this); } else { - this->actor.flags &= ~(0x4000 | 0x200); + this->actor.flags &= ~(ACTOR_FLAG_200 | ACTOR_FLAG_4000); this->collider.info.elemType = ELEMTYPE_UNK4; this->collider.info.bumper.dmgFlags |= (0x40000 | 0x1); this->collider.base.ocFlags1 = OC1_NONE; @@ -481,7 +481,7 @@ void func_80B1B3A8(EnPoSisters* this) { void func_80B1B444(EnPoSisters* this, GlobalContext* globalCtx) { s32 temp_f18; - if (SkelAnime_Update(&this->skelAnime) && !(this->actor.flags & 0x8000)) { + if (SkelAnime_Update(&this->skelAnime) && !(this->actor.flags & ACTOR_FLAG_8000)) { if (this->actor.colChkInfo.health != 0) { if (this->unk_18C != 0) { func_80B1B5B4(this); @@ -611,7 +611,7 @@ void func_80B1BA3C(EnPoSisters* this) { this->actor.speedXZ = 0.0f; this->actor.world.pos.y += 42.0f; this->actor.shape.yOffset = -6000.0f; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_191 = 0; this->actionFunc = func_80B1BA90; } @@ -703,7 +703,7 @@ void func_80B1BE4C(EnPoSisters* this, s32 arg1) { Vec3f sp34; this->actor.draw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_194 = 100; this->unk_191 = 0x20; this->collider.base.colType = COLTYPE_HIT3; @@ -749,7 +749,7 @@ void func_80B1C030(EnPoSisters* this) { this->unk_192 = 300; this->unk_194 = 3; this->unk_191 |= (0x8 | 0x1); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80B1C0A4; } @@ -821,7 +821,7 @@ void func_80B1C2E8(EnPoSisters* this) { void func_80B1C340(EnPoSisters* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { this->unk_229 = 255; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_191 |= (0x10 | 0x8); if (this->unk_18C == 0) { func_80B1BE4C(this, globalCtx); @@ -945,7 +945,7 @@ void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->actionFunc == func_80B1B168) { - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.c b/src/overlays/actors/ovl_En_Poh/z_en_poh.c index a5b377ecb..1c524d78f 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -7,7 +7,7 @@ #include "z_en_poh.h" #include "objects/object_po/object_po.h" -#define FLAGS 0x00001205 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200 | ACTOR_FLAG_1000) #define THIS ((EnPoh*)thisx) @@ -363,7 +363,7 @@ void func_80B2D07C(EnPoh* this, GlobalContext* globalCtx) { void func_80B2D0E8(EnPoh* this) { this->unk_197 = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Animation_PlayOnceSetSpeed(&this->skelAnime, &object_po_Anim_0011C4, 0.0f); this->actionFunc = func_80B2D140; } @@ -372,7 +372,7 @@ void func_80B2D140(EnPoh* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { this->unk_197 = 255; this->unk_190 = Rand_S16Offset(700, 300); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; func_80B2CB60(this); } else if (this->skelAnime.curFrame > 10.0f) { this->unk_197 = (this->skelAnime.curFrame - 10.0f) * 0.05f * 255.0f; @@ -389,7 +389,7 @@ void func_80B2D2C0(EnPoh* this) { this->actor.world.rot.y = this->actor.shape.rot.y; this->unk_18E = 0; this->actor.hintId = 0xFF; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80B2D300; } @@ -571,13 +571,13 @@ void func_80B2DC50(EnPoh* this, GlobalContext* globalCtx) { this->actor.world.pos.y = this->unk_3D8.wy; this->actor.world.pos.z = this->unk_3D8.wz; Actor_SetScale(&this->actor, 0.01f); - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->actor.gravity = -1.0f; this->actor.shape.yOffset = 1500.0f; this->actor.world.pos.y -= 15.0f; this->actor.shape.rot.x = -0x8000; func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 8); - this->actor.flags &= ~(0x4 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actionFunc = func_80B2DD2C; } @@ -647,7 +647,7 @@ void func_80B2E1D8(EnPoh* this) { Actor_SetFocus(&this->actor, -10.0f); this->unk_18E = 200; this->unk_18D = 32; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80B2E230; } @@ -811,7 +811,7 @@ void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx2) { this->actionFunc(this, globalCtx); Actor_MoveWithGravity(&this->actor); if ((this->actionFunc == func_80B2CF28) && (this->unk_18E < 10)) { - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); } diff --git a/src/overlays/actors/ovl_En_Pp/z_en_pp.c b/src/overlays/actors/ovl_En_Pp/z_en_pp.c index 0fb1e08d0..67f951299 100644 --- a/src/overlays/actors/ovl_En_Pp/z_en_pp.c +++ b/src/overlays/actors/ovl_En_Pp/z_en_pp.c @@ -6,7 +6,7 @@ #include "z_en_pp.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnPp*)thisx) 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 b1ef7eaca..045d7cc3e 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c @@ -6,7 +6,7 @@ #include "z_en_pr2.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnPr2*)thisx) diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.c b/src/overlays/actors/ovl_En_Prz/z_en_prz.c index 960340d7e..f89204a15 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.c +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.c @@ -6,7 +6,7 @@ #include "z_en_prz.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnPrz*)thisx) diff --git a/src/overlays/actors/ovl_En_Pst/z_en_pst.c b/src/overlays/actors/ovl_En_Pst/z_en_pst.c index df0355ce9..02a9ea743 100644 --- a/src/overlays/actors/ovl_En_Pst/z_en_pst.c +++ b/src/overlays/actors/ovl_En_Pst/z_en_pst.c @@ -6,7 +6,7 @@ #include "z_en_pst.h" -#define FLAGS 0x00000001 +#define FLAGS (ACTOR_FLAG_1) #define THIS ((EnPst*)thisx) diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index 489fe63df..34ba30652 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -6,7 +6,7 @@ #include "z_en_racedog.h" -#define FLAGS 0x80000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) #define THIS ((EnRacedog*)thisx) diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.c b/src/overlays/actors/ovl_En_Raf/z_en_raf.c index 38fb9e965..a32811620 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.c +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.c @@ -6,7 +6,7 @@ #include "z_en_raf.h" -#define FLAGS 0x08000000 +#define FLAGS (ACTOR_FLAG_8000000) #define THIS ((EnRaf*)thisx) diff --git a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c index 0c18be89a..ce4d00838 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c @@ -8,7 +8,7 @@ #include "z_en_rail_skb.h" #include "objects/object_skb/object_skb.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnRailSkb*)thisx) @@ -297,7 +297,7 @@ void EnRailSkb_Init(Actor* thisx, GlobalContext* globalCtx) { } if ((globalCtx->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.unk_12 == 0)) { - this->actor.flags |= 0x100000; + this->actor.flags |= ACTOR_FLAG_100000; } func_80B70FA0(this); @@ -428,7 +428,7 @@ void func_80B713A4(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71488(EnRailSkb* this) { this->unk_402 |= 0x40; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; if (this->unk_2E0 != 0) { this->unk_2E4 = this->unk_2E0 - 1; } else { @@ -451,7 +451,7 @@ void func_80B7151C(EnRailSkb* this) { this->actor.shape.yOffset = -5000.0f; this->actor.colChkInfo.health = 2; this->unk_402 = 0; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_APPEAR); this->actor.draw = EnRailSkb_Draw; this->actor.shape.shadowAlpha = 0; @@ -666,7 +666,7 @@ void func_80B71DF0(EnRailSkb* this) { this->actor.shape.yOffset = -5000.0f; this->actor.colChkInfo.health = 2; this->unk_402 = 0; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.draw = EnRailSkb_Draw; this->actor.shape.shadowAlpha = 0; this->actor.shape.rot.y = this->actor.world.rot.y; @@ -822,9 +822,9 @@ void func_80B72190(EnRailSkb* this, GlobalContext* globalCtx) { } void func_80B723F8(EnRailSkb* this) { - this->actor.flags &= ~(4 | 1); - this->actor.flags |= (8 | 1); - this->actor.flags |= 0x100000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.flags |= ACTOR_FLAG_100000; this->actor.hintId = 0xFF; this->actor.textId = 0; } @@ -923,17 +923,17 @@ void func_80B72880(EnRailSkb* this, GlobalContext* globalCtx) { if ((this->actionFunc == func_80B70FF8) || (this->actionFunc == func_80B716A8)) { if (this->actionFunc != func_80B716A8) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { - this->actor.flags &= ~(4 | 1); - this->actor.flags |= (8 | 1); - this->actor.flags |= 0x100000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.flags |= ACTOR_FLAG_100000; this->actor.hintId = 0xFF; this->actor.textId = 0; func_80B71650(this); } } else if (Player_GetMask(globalCtx) != PLAYER_MASK_CAPTAIN) { - this->actor.flags &= ~(8 | 1); - this->actor.flags &= ~0x100000; - this->actor.flags |= 5; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.flags &= ~ACTOR_FLAG_100000; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actor.hintId = 0x55; this->actor.textId = 0; func_80B70FA0(this); 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 afff2ddb0..b26650690 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -927,7 +927,7 @@ void EnRailgibud_CheckForGibdoMask(EnRailgibud* this, GlobalContext* globalCtx) if ((this->actionFunc != EnRailgibud_Grab) && (this->actionFunc != EnRailgibud_Damage) && (this->actionFunc != EnRailgibud_GrabFail) && (this->actionFunc != EnRailgibud_TurnAwayAndShakeHead) && (this->actionFunc != EnRailgibud_Dead)) { - if ((this->actor.flags & (ACTOR_FLAG_4 | ACTOR_FLAG_1)) == 5) { + if (CHECK_FLAG_ALL(this->actor.flags, (ACTOR_FLAG_1 | ACTOR_FLAG_4))) { if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { this->actor.flags &= ~(ACTOR_FLAG_4 | ACTOR_FLAG_1); this->actor.flags |= (ACTOR_FLAG_8 | ACTOR_FLAG_1); @@ -960,7 +960,7 @@ void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, GlobalContext* global this->textId = 0x13B2; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); this->actor.speedXZ = 0.0f; - } else if (((this->actor.flags & (ACTOR_FLAG_8 | ACTOR_FLAG_1)) == 9) && + } else if (CHECK_FLAG_ALL(this->actor.flags, (ACTOR_FLAG_1 | ACTOR_FLAG_8)) && !(this->collider.base.acFlags & AC_HIT)) { func_800B8614(&this->actor, globalCtx, 100.0f); } diff --git a/src/overlays/actors/ovl_En_Rat/z_en_rat.c b/src/overlays/actors/ovl_En_Rat/z_en_rat.c index 5160203b2..583d3637c 100644 --- a/src/overlays/actors/ovl_En_Rat/z_en_rat.c +++ b/src/overlays/actors/ovl_En_Rat/z_en_rat.c @@ -6,7 +6,7 @@ #include "z_en_rat.h" -#define FLAGS 0x00000205 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200) #define THIS ((EnRat*)thisx) diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c index 2cc5970bf..226cc821d 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -7,7 +7,7 @@ #include "z_en_recepgirl.h" #include "objects/object_bg/object_bg.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnRecepgirl*)thisx) diff --git a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c index 2dc6842c9..db20137b1 100644 --- a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c +++ b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c @@ -6,7 +6,7 @@ #include "z_en_river_sound.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnRiverSound*)thisx) diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.c b/src/overlays/actors/ovl_En_Rr/z_en_rr.c index b50f4df58..75e958458 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -7,7 +7,7 @@ #include "z_en_rr.h" #include "objects/object_rr/object_rr.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnRr*)thisx) @@ -195,7 +195,7 @@ void func_808FA11C(EnRr* this) { this->unk_220 = 0.85f; this->unk_224 = 1.2750001f; this->unk_21C = 1.0f; - this->actor.flags &= ~0x400; + this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } @@ -208,7 +208,7 @@ void func_808FA19C(EnRr* this, GlobalContext* globalCtx) { this->unk_21C = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_234, 20, 2, this->actor.scale.y * 23.333334f, this->actor.scale.y * 20.000002f); - this->actor.flags |= 0x400; + this->actor.flags |= ACTOR_FLAG_400; } } @@ -267,7 +267,7 @@ void func_808FA3F8(EnRr* this, Player* player) { this->unk_1EA = 100; this->unk_1FC = 20; this->collider1.base.ocFlags1 &= ~OC1_TYPE_PLAYER; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_1F0 = 8; this->unk_1E1 = 0; this->actor.speedXZ = 0.0f; @@ -298,7 +298,7 @@ void func_808FA4F4(EnRr* this, GlobalContext* globalCtx) { if (player->stateFlags2 & 0x80) { player->actor.parent = NULL; player->unk_AE8 = 100; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_1F0 = 110; this->unk_1F6 = 2500; this->unk_210 = 0.0f; @@ -415,7 +415,7 @@ void func_808FA910(EnRr* this) { this->actionFunc = func_808FB42C; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIKE_DEAD); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } void func_808FA9CC(EnRr* this) { diff --git a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c index 0dc71d3df..cb110f780 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c @@ -7,7 +7,7 @@ #include "z_en_rsn.h" #include "objects/object_rs/object_rs.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnRsn*)thisx) @@ -45,7 +45,7 @@ void EnRsn_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rs_Skel_009220, &object_rs_Anim_009120, NULL, NULL, 0); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; func_80C25D40(this); } diff --git a/src/overlays/actors/ovl_En_Ru/z_en_ru.c b/src/overlays/actors/ovl_En_Ru/z_en_ru.c index f3edfa7c3..3e9538f61 100644 --- a/src/overlays/actors/ovl_En_Ru/z_en_ru.c +++ b/src/overlays/actors/ovl_En_Ru/z_en_ru.c @@ -6,7 +6,7 @@ #include "z_en_ru.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnRu*)thisx) diff --git a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c index 43b5bc9db..7cfefa59c 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c @@ -7,7 +7,7 @@ #include "z_en_ruppecrow.h" #include "objects/object_crow/object_crow.h" -#define FLAGS 0x00004030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_4000) #define THIS ((EnRuppecrow*)thisx) @@ -285,7 +285,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); rupee = this->rupees[rupeeIndex]; rupee->unk152 = 60; - this->rupees[rupeeIndex]->actor.flags |= 0x10; + this->rupees[rupeeIndex]->actor.flags |= ACTOR_FLAG_10; } else { rupee = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, this->actor.world.pos.x + xOffset, this->actor.world.pos.y, @@ -296,7 +296,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); rupee = this->rupees[rupeeIndex]; rupee->unk152 = 60; - this->rupees[rupeeIndex]->actor.flags |= 0x10; + this->rupees[rupeeIndex]->actor.flags |= ACTOR_FLAG_10; } } else if (this->rupeeIndex == 19) { rupee = @@ -308,7 +308,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); rupee = this->rupees[rupeeIndex]; rupee->unk152 = 60; - this->rupees[rupeeIndex]->actor.flags |= 0x10; + this->rupees[rupeeIndex]->actor.flags |= ACTOR_FLAG_10; } else { rupee = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, this->actor.world.pos.x + xOffset, @@ -319,7 +319,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); rupee = this->rupees[rupeeIndex]; rupee->unk152 = 60; - this->rupees[rupeeIndex]->actor.flags |= 0x10; + this->rupees[rupeeIndex]->actor.flags |= ACTOR_FLAG_10; } this->rupeeIndex++; @@ -465,12 +465,12 @@ void EnRuppecrow_HandleDeath(EnRuppecrow* this) { } Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x0, 0x28); - if (this->actor.flags & 0x8000) { + if (this->actor.flags & ACTOR_FLAG_8000) { this->actor.speedXZ = 0.0f; } this->collider.base.acFlags &= ~AC_ON; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->actionFunc = EnRuppecrow_FallToDespawn; } @@ -481,7 +481,7 @@ void EnRuppecrow_UpdateDamage(EnRuppecrow* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect != 0x1) { this->actor.colChkInfo.health = 0; - this->actor.flags &= ~0x1; + this->actor.flags &= ~ACTOR_FLAG_1; Enemy_StartFinishingBlow(globalCtx, &this->actor); EnRuppecrow_HandleDeath(this); } @@ -602,7 +602,7 @@ void EnRuppecrow_FallToDespawn(EnRuppecrow* this, GlobalContext* globalCtx) { } this->actor.colorFilterTimer = 40; - if (!(this->actor.flags & 0x8000)) { + if (!(this->actor.flags & ACTOR_FLAG_8000)) { if (this->currentEffect != ENRUPPECROW_EFFECT_ICE) { Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x200); this->actor.shape.rot.z += 0x1780; @@ -637,7 +637,7 @@ void EnRuppecrow_Init(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_SetScale(&this->actor, 0.01f); - this->actor.flags |= 0x2000000; + this->actor.flags |= ACTOR_FLAG_2000000; this->path = func_8013D648(globalCtx, ENRUPPECROW_GET_PATH(&this->actor), 0x3F); if (this->path != NULL) { diff --git a/src/overlays/actors/ovl_En_Rz/z_en_rz.c b/src/overlays/actors/ovl_En_Rz/z_en_rz.c index 26551895a..57f679803 100644 --- a/src/overlays/actors/ovl_En_Rz/z_en_rz.c +++ b/src/overlays/actors/ovl_En_Rz/z_en_rz.c @@ -6,7 +6,7 @@ #include "z_en_rz.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnRz*)thisx) 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 394ac5b05..99e92b017 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 @@ -6,7 +6,7 @@ #include "z_en_s_goro.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnSGoro*)thisx) diff --git a/src/overlays/actors/ovl_En_Sb/z_en_sb.c b/src/overlays/actors/ovl_En_Sb/z_en_sb.c index b264a068b..7ffeb543b 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.c +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.c @@ -7,7 +7,7 @@ #include "z_en_sb.h" #include "objects/object_sb/object_sb.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnSb*)thisx) @@ -109,14 +109,14 @@ void EnSb_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.colChkInfo.damageTable = &sDamageTable; - this->actor.colChkInfo.mass = 0xA; + this->actor.colChkInfo.mass = 10; this->actor.colChkInfo.health = 2; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_sb_Skel_002BF0, &object_sb_Anim_000194, this->jointTable, this->morphTable, 9); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->isDead = false; - this->actor.colChkInfo.mass = 0x5A; + this->actor.colChkInfo.mass = 90; this->actor.shape.rot.y = 0; this->actor.speedXZ = 0.0f; this->actor.gravity = -0.35f; diff --git a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c index c813759cb..357d41ba7 100644 --- a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c +++ b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c @@ -6,7 +6,7 @@ #include "z_en_sc_ruppe.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnScRuppe*)thisx) diff --git a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c index 136586072..dd6453773 100644 --- a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c +++ b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c @@ -7,7 +7,7 @@ #include "z_en_scopecoin.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnScopecoin*)thisx) diff --git a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c index 76665f67a..bf0b6a839 100644 --- a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c +++ b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c @@ -6,7 +6,7 @@ #include "z_en_scopecrow.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnScopecrow*)thisx) diff --git a/src/overlays/actors/ovl_En_Sda/z_en_sda.c b/src/overlays/actors/ovl_En_Sda/z_en_sda.c index e423a2046..3a355b361 100644 --- a/src/overlays/actors/ovl_En_Sda/z_en_sda.c +++ b/src/overlays/actors/ovl_En_Sda/z_en_sda.c @@ -6,7 +6,7 @@ #include "z_en_sda.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnSda*)thisx) diff --git a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c index 29b673760..5ce4184a6 100644 --- a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c +++ b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c @@ -6,7 +6,7 @@ #include "z_en_sekihi.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnSekihi*)thisx) diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c index 588aedf3d..1aaedc075 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -7,7 +7,7 @@ #include "z_en_sellnuts.h" #include "objects/object_dnt/object_dnt.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnSellnuts*)thisx) @@ -518,7 +518,7 @@ void func_80ADBD64(EnSellnuts* this, GlobalContext* globalCtx) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_338 &= ~2; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_34C = 8; SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 8); this->actionFunc = func_80ADBE80; @@ -698,7 +698,7 @@ void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { player->linearVelocity = 0.0f; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_801518B0(globalCtx, this->unk_340, &this->actor); if (this->unk_340 == 0x625) { this->unk_338 |= 1; @@ -711,7 +711,7 @@ void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80ADC6D0; } } else if (func_80ADB08C(globalCtx) < 80.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, this->actor.xzDistToPlayer); } } @@ -858,7 +858,7 @@ void func_80ADCC04(EnSellnuts* this, GlobalContext* globalCtx) { func_80ADAFC0(this); if (currentFrame == 0) { if (func_80ADB08C(globalCtx) < 9999.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 9999.0f); } this->unk_340 = 0x626; @@ -875,7 +875,7 @@ void func_80ADCD3C(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_338 |= 2; this->unk_338 |= 1; this->unk_340 = 0x626; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.gravity = -1.0f; this->actor.draw = EnSellnuts_Draw; this->unk_34A = 50; @@ -1002,7 +1002,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = 0.0f; this->actor.draw = NULL; this->unk_34C = 20; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_35C = 1.0f; this->unk_358 = 1.0f; this->unk_354 = 1.0f; @@ -1012,7 +1012,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { } else { this->unk_338 |= 2; this->unk_338 &= ~1; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.gravity = 0.0f; this->actor.draw = NULL; this->unk_34C = 4; diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.c b/src/overlays/actors/ovl_En_Shn/z_en_shn.c index c93402fbc..c47c8fb67 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.c +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.c @@ -6,7 +6,7 @@ #include "z_en_shn.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnShn*)thisx) diff --git a/src/overlays/actors/ovl_En_Si/z_en_si.c b/src/overlays/actors/ovl_En_Si/z_en_si.c index 35eddf10b..8933d5305 100644 --- a/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -6,7 +6,7 @@ #include "z_en_si.h" -#define FLAGS 0x00000201 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_200) #define THIS ((EnSi*)thisx) diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index bfa9cf782..126bf8e3f 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Encount4/z_en_encount4.h" #include "objects/object_skb/object_skb.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnSkb*)thisx) @@ -231,7 +231,7 @@ void EnSkb_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.floorHeight = this->actor.world.pos.y; if ((globalCtx->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.unk_12 == 0)) { - this->actor.flags |= 0x100000; + this->actor.flags |= ACTOR_FLAG_100000; } switch (this->unk_3D6) { @@ -248,7 +248,7 @@ void EnSkb_Init(Actor* thisx, GlobalContext* globalCtx) { break; default: - this->actor.flags &= ~0x100000; + this->actor.flags &= ~ACTOR_FLAG_100000; this->actor.hintId = 0x55; func_8099495C(this, globalCtx); break; @@ -288,7 +288,7 @@ void func_80994DA8(EnSkb* this, GlobalContext* globalCtx) { void func_80994E2C(EnSkb* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_APPEAR); this->unk_3D0 = 0; this->unk_3DE = 0; @@ -300,7 +300,7 @@ void func_80994E94(EnSkb* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } Math_ApproachZeroF(&this->actor.shape.yOffset, 1.0f, 800.0f); @@ -351,8 +351,8 @@ void func_80995068(EnSkb* this, GlobalContext* globalCtx) { this->actionFunc = func_80995190; this->actor.speedXZ = 0.0f; } else if (Player_GetMask(globalCtx) != PLAYER_MASK_CAPTAIN) { - this->actor.flags |= (0x4 | 0x1); - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.hintId = 0x55; this->actor.colChkInfo.mass = MASS_HEAVY; func_80995A30(this); @@ -388,8 +388,8 @@ void func_80995190(EnSkb* this, GlobalContext* globalCtx) { } void func_80995244(EnSkb* this, GlobalContext* globalCtx) { - this->actor.flags &= ~(0x8 | 0x1); - this->actor.flags |= (0x4 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); this->unk_3E2 = 0; switch (this->unk_3DE) { @@ -423,8 +423,8 @@ void func_809952D8(EnSkb* this) { void func_8099533C(EnSkb* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { - this->actor.flags &= ~(0x4 | 0x1); - this->actor.flags |= (0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80994F7C(this, globalCtx); } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f)) { this->actor.hintId = 0x55; @@ -445,8 +445,8 @@ void func_809953E8(EnSkb* this) { void func_8099544C(EnSkb* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { - this->actor.flags &= ~(0x4 | 0x1); - this->actor.flags |= (0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80994F7C(this, globalCtx); } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f)) { this->actor.hintId = 0x55; @@ -482,8 +482,8 @@ void func_8099556C(EnSkb* this, GlobalContext* globalCtx) { this->actor.shape.rot.x = Math_SinS(this->unk_3D4 * sp26) * 20000.0f; if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { - this->actor.flags &= ~(0x4 | 0x1); - this->actor.flags |= (0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80994F7C(this, globalCtx); } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f) && (this->skelAnime.curFrame > 24.0f) && (this->skelAnime.curFrame < 28.0f)) { @@ -538,7 +538,7 @@ void func_809958F4(EnSkb* this) { Animation_Change(&this->skelAnime, &object_skb_Anim_003584, -1.0f, Animation_GetLastFrame(&object_skb_Anim_003584), 0.0f, 2, -4.0f); this->unk_3E4 = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->unk_3DE = 1; @@ -569,8 +569,8 @@ void func_80995A30(EnSkb* this) { void func_80995A8C(EnSkb* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { - this->actor.flags &= ~(0x4 | 0x1); - this->actor.flags |= (0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.hintId = 0xFF; this->actor.colChkInfo.mass = MASS_HEAVY; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); @@ -585,7 +585,7 @@ void func_80995A8C(EnSkb* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + this->unk_3DA, 1, 0x2EE, 0); this->actor.world.rot.y = this->actor.shape.rot.y; if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { - Actor_PlaySfxAtPos(&this->actor, 0x3830); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_WALK); } if ((this->actor.xzDistToPlayer > 800.0f) || func_80996594(this, globalCtx)) { @@ -733,7 +733,7 @@ void func_809961E4(EnSkb* this, GlobalContext* globalCtx) { this->actor.speedXZ = -6.0f; } this->unk_3E4 = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); this->unk_3DE = 7; this->actionFunc = func_80996284; @@ -793,7 +793,7 @@ void func_809963D8(EnSkb* this, GlobalContext* globalCtx) { void func_80996474(EnSkb* this) { this->unk_3D0 = 0; this->actor.draw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_809964A0; } diff --git a/src/overlays/actors/ovl_En_Slime/z_en_slime.c b/src/overlays/actors/ovl_En_Slime/z_en_slime.c index d313450f5..539d458ad 100644 --- a/src/overlays/actors/ovl_En_Slime/z_en_slime.c +++ b/src/overlays/actors/ovl_En_Slime/z_en_slime.c @@ -6,7 +6,7 @@ #include "z_en_slime.h" -#define FLAGS 0x00000215 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_200) #define THIS ((EnSlime*)thisx) diff --git a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c index 8f28748b7..32d38ecb9 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c @@ -6,7 +6,7 @@ #include "z_en_snowman.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnSnowman*)thisx) diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index 7ddbbf06b..3e237b51c 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -12,7 +12,7 @@ #include "objects/object_oF1d_map/object_oF1d_map.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnSob1*)thisx) @@ -186,7 +186,7 @@ u16 EnSob1_GetTalkOption(EnSob1* this, GlobalContext* globalCtx) { if (this->shopType == BOMB_SHOP) { if (gSaveContext.day == 1 && gSaveContext.time >= CLOCK_TIME(6, 00)) { return 0x648; - } else if (gSaveContext.weekEventReg[0x21] & 8) { + } else if (gSaveContext.weekEventReg[33] & 8) { return 0x649; } else { return 0x64A; @@ -256,58 +256,58 @@ u16 EnSob1_GetWelcome(EnSob1* this, GlobalContext* globalCtx) { } else if (this->shopType == ZORA_SHOP) { switch (player->transformation) { case PLAYER_FORM_HUMAN: - if (gSaveContext.weekEventReg[0x39] & 0x10) { + if (gSaveContext.weekEventReg[57] & 0x10) { return 0x12CF; } - gSaveContext.weekEventReg[0x39] |= 0x10; + gSaveContext.weekEventReg[57] |= 0x10; return 0x12CE; case PLAYER_FORM_DEKU: - if (gSaveContext.weekEventReg[0x39] & 0x20) { + if (gSaveContext.weekEventReg[57] & 0x20) { return 0x12D1; } - gSaveContext.weekEventReg[0x39] |= 0x20; + gSaveContext.weekEventReg[57] |= 0x20; return 0x12D0; case PLAYER_FORM_GORON: - if (gSaveContext.weekEventReg[0x39] & 0x40) { + if (gSaveContext.weekEventReg[57] & 0x40) { return 0x12D3; } - gSaveContext.weekEventReg[0x39] |= 0x40; + gSaveContext.weekEventReg[57] |= 0x40; return 0x12D2; case PLAYER_FORM_ZORA: - if (gSaveContext.weekEventReg[0x39] & 0x80) { + if (gSaveContext.weekEventReg[57] & 0x80) { return 0x12D5; } - gSaveContext.weekEventReg[0x39] |= 0x80; + gSaveContext.weekEventReg[57] |= 0x80; return 0x12D4; default: return 0x12CE; } } else if (this->shopType == GORON_SHOP) { if (player->transformation != PLAYER_FORM_GORON) { - if (gSaveContext.weekEventReg[0x3A] & 4) { + if (gSaveContext.weekEventReg[58] & 4) { return 0xBB9; } - gSaveContext.weekEventReg[0x3A] |= 4; + gSaveContext.weekEventReg[58] |= 4; return 0xBB8; } else { - if (gSaveContext.weekEventReg[0x3A] & 8) { + if (gSaveContext.weekEventReg[58] & 8) { return 0xBBB; } - gSaveContext.weekEventReg[0x3A] |= 8; + gSaveContext.weekEventReg[58] |= 8; return 0xBBA; } } else if (this->shopType == GORON_SHOP_SPRING) { if (player->transformation != PLAYER_FORM_GORON) { - if (gSaveContext.weekEventReg[0x3A] & 0x10) { + if (gSaveContext.weekEventReg[58] & 0x10) { return 0xBBD; } - gSaveContext.weekEventReg[0x3A] |= 0x10; + gSaveContext.weekEventReg[58] |= 0x10; return 0xBBC; } else { - if (gSaveContext.weekEventReg[0x3A] & 0x20) { + if (gSaveContext.weekEventReg[58] & 0x20) { return 0xBBF; } - gSaveContext.weekEventReg[0x3A] |= 0x20; + gSaveContext.weekEventReg[58] |= 0x20; return 0xBBE; } } @@ -382,7 +382,7 @@ void EnSob1_Init(Actor* thisx, GlobalContext* globalCtx) { this->shopType = ZORA_SHOP; break; case GORON_SHOP: - if (gSaveContext.weekEventReg[0x21] & 0x80) { + if (gSaveContext.weekEventReg[33] & 0x80) { this->shopType = GORON_SHOP_SPRING; } else { this->shopType = GORON_SHOP; @@ -1356,7 +1356,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { u32 maxColor = 255; if (EnSob1_AreObjectsLoaded(this, globalCtx)) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; this->actor.objBankIndex = this->objIndices[0]; Actor_SetObjectDependency(globalCtx, &this->actor); posOffset = &sPosOffset[this->shopType]; @@ -1364,7 +1364,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { this->actor.world.pos.y += posOffset->y; this->actor.world.pos.z += posOffset->z; shopItems = sShops[this->shopType]; - if ((this->shopType == BOMB_SHOP) && (gSaveContext.weekEventReg[0x21] & 8)) { + if ((this->shopType == BOMB_SHOP) && (gSaveContext.weekEventReg[33] & 8)) { sShops[this->shopType][0].shopItemId = SI_BOMB_BAG_30_2; } @@ -1447,7 +1447,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { this2->blinkTimer = 20; this2->eyeTexIndex = 0; this->blinkFunc = EnSob1_WaitForBlink; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } } 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 8dbe19724..5508fa646 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -7,7 +7,7 @@ #include "z_en_ssh.h" #include "objects/object_ssh/object_ssh.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnSsh*)thisx) diff --git a/src/overlays/actors/ovl_En_St/z_en_st.c b/src/overlays/actors/ovl_En_St/z_en_st.c index adeae463a..0bd9a6125 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -8,7 +8,7 @@ #include "objects/object_st/object_st.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x01004035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_4000 | ACTOR_FLAG_1000000) #define THIS ((EnSt*)thisx) @@ -618,7 +618,7 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALTU_DEAD); Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; switch (this->actor.colChkInfo.damageEffect) { case 4: @@ -701,7 +701,7 @@ void func_808A6A78(EnSt* this, GlobalContext* globalCtx) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if (ENST_GET_1C0(&this->actor) == ENST_1C0_1) { - this->actor.flags |= 0x80; + this->actor.flags |= ACTOR_FLAG_80; } Actor_SetScale(&this->actor, 0.04f); @@ -859,14 +859,14 @@ void EnSt_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnSt_Update(Actor* thisx, GlobalContext* globalCtx) { EnSt* this = THIS; - if (this->actor.flags & 0x8000) { + if (this->actor.flags & ACTOR_FLAG_8000) { SkelAnime_Update(&this->skelAnime); this->unk_18C |= 0x80; return; } - if (!(this->actor.flags & 0x80) && func_808A6A3C(this)) { - this->actor.flags |= 0x80; + if (!(this->actor.flags & ACTOR_FLAG_80) && func_808A6A3C(this)) { + this->actor.flags |= ACTOR_FLAG_80; } if (func_808A6580(this, globalCtx)) { diff --git a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c index 97b463567..0bf0ae73c 100644 --- a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c +++ b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c @@ -6,7 +6,7 @@ #include "z_en_sth2.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnSth2*)thisx) diff --git a/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c b/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c index 387afd7e9..54a1f84a8 100644 --- a/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c +++ b/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.c @@ -6,7 +6,7 @@ #include "z_en_stone_heishi.h" -#define FLAGS 0x00000089 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_80) #define THIS ((EnStoneheishi*)thisx) diff --git a/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c b/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c index c5746771c..3ca829630 100644 --- a/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c +++ b/src/overlays/actors/ovl_En_Stop_heishi/z_en_stop_heishi.c @@ -6,7 +6,7 @@ #include "z_en_stop_heishi.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnStopheishi*)thisx) diff --git a/src/overlays/actors/ovl_En_Stream/z_en_stream.c b/src/overlays/actors/ovl_En_Stream/z_en_stream.c index 9ce7ac906..abf58da86 100644 --- a/src/overlays/actors/ovl_En_Stream/z_en_stream.c +++ b/src/overlays/actors/ovl_En_Stream/z_en_stream.c @@ -7,7 +7,7 @@ #include "z_en_stream.h" #include "objects/object_stream/object_stream.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnStream*)thisx) diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index e73766059..4d928a79a 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/object_boj/object_boj.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnSuttari*)thisx) @@ -323,7 +323,7 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { } else if (this->flags1 & 1) { switch (this->textId) { case 0: - if (gSaveContext.weekEventReg[0x51] & 1) { + if (gSaveContext.weekEventReg[81] & 1) { this->textId = 0x1455; ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 8; this->flags2 |= 1; @@ -341,12 +341,12 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { } else { this->flags1 |= 0x400; this->textId = 0x1452; - gSaveContext.weekEventReg[0x51] |= 1; + gSaveContext.weekEventReg[81] |= 1; } break; case 0x1453: this->flags1 |= 0x400; - gSaveContext.weekEventReg[0x51] |= 1; + gSaveContext.weekEventReg[81] |= 1; ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 8; this->flags2 |= 1; this->textId = 0x1454; @@ -414,7 +414,7 @@ void func_80BAAFDC(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[0] != 0) { this->unk1F4[0]--; } - gSaveContext.weekEventReg[0x3D] |= 8; + gSaveContext.weekEventReg[61] |= 8; this->unk3F6 = 20; this->actionFunc = func_80BADE8C; } @@ -446,7 +446,7 @@ void func_80BAB1A0(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[0] != 0) { this->unk1F4[0]--; } - gSaveContext.weekEventReg[0x3D] |= 8; + gSaveContext.weekEventReg[61] |= 8; this->unk3F6 = 20; this->actionFunc = func_80BADE8C; } else { @@ -819,7 +819,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { this->animationIdx = 2; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); } - if (!(gSaveContext.weekEventReg[0x53] & 4) && !(this->flags1 & 0x1000)) { + if (!(gSaveContext.weekEventReg[83] & 4) && !(this->flags1 & 0x1000)) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[0])) { ActorCutscene_Start(this->cutscenes[0], &this->actor); if (!(player->stateFlags1 & 0x10000000)) { @@ -868,7 +868,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); break; case 2: - if (!(gSaveContext.weekEventReg[0x51] & 4)) { + if (!(gSaveContext.weekEventReg[81] & 4)) { this->flags1 |= 0x80; this->actor.world.pos.x = -16.0f; this->actor.world.pos.z = -16.0f; @@ -878,7 +878,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { } break; case 4: - if (!(gSaveContext.weekEventReg[0x21] & 8)) { + if (!(gSaveContext.weekEventReg[33] & 8)) { if (this->animationIdx == 2 || this->animationIdx == 1) { this->animationIdx = 5; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); @@ -905,7 +905,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_boj_Skel_00C240, &object_boj_Anim_00071C, this->jointTable, this->morphTable, 16); this->actor.draw = EnSuttari_Draw; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; if (globalCtx->sceneNum == SCENE_IKANA) { this->flags1 |= 1; if (gSaveContext.day == 1 || gSaveContext.day == 2) { @@ -915,8 +915,8 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { this->actionFunc = func_80BACA14; return; } else if ((gSaveContext.day == 3) && (gSaveContext.time <= CLOCK_TIME(19, 00)) && - !(gSaveContext.weekEventReg[0x3D] & 8) && !(gSaveContext.weekEventReg[0x21] & 8) && - (gSaveContext.weekEventReg[0x33] & 8)) { + !(gSaveContext.weekEventReg[61] & 8) && !(gSaveContext.weekEventReg[33] & 8) && + (gSaveContext.weekEventReg[51] & 8)) { this->animationIdx = 2; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); this->actionFunc = func_80BACEE0; @@ -926,7 +926,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { if (gSaveContext.time >= CLOCK_TIME(0, 20) && gSaveContext.time < CLOCK_TIME(6, 00)) { Actor_MarkForDeath(&this->actor); } - if ((gSaveContext.entranceIndex == 0xD670) || (gSaveContext.weekEventReg[0x3A] & 0x40)) { + if ((gSaveContext.entranceIndex == 0xD670) || (gSaveContext.weekEventReg[58] & 0x40)) { Actor_MarkForDeath(&this->actor); } this->cutscenes[0] = this->actor.cutscene; @@ -938,7 +938,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { this->actionFunc = func_80BAD004; return; } else if (globalCtx->sceneNum == SCENE_ICHIBA) { - if (gSaveContext.weekEventReg[0x21] & 8) { + if (gSaveContext.weekEventReg[33] & 8) { Actor_MarkForDeath(&this->actor); return; } @@ -948,7 +948,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { this->actionFunc = func_80BAD5F8; return; } else if (globalCtx->sceneNum == SCENE_AYASHIISHOP) { - if (gSaveContext.weekEventReg[0x21] & 8) { + if (gSaveContext.weekEventReg[33] & 8) { Actor_MarkForDeath(&this->actor); return; } @@ -1067,16 +1067,16 @@ void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { this->unk42A = REG(15) + *unk_14; if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; unkStruct.unk0 = 0; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } this->unk428 = unkStruct.unk0; func_80BAC2FC(this, globalCtx); func_80BAB434(this); if (this->unk428 == 5) { - gSaveContext.weekEventReg[0x3A] |= 0x80; + gSaveContext.weekEventReg[58] |= 0x80; this->actionFunc = func_80BADDB4; this->actor.speedXZ = 0.0f; } else if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) { @@ -1092,10 +1092,10 @@ void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { this->unk42A = REG(15) + *unk_14; if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; unkStruct.unk0 = 0; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } this->unk428 = unkStruct.unk0; func_80BAC2FC(this, globalCtx); @@ -1181,7 +1181,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { this->flags2 |= 8; func_80BAAF1C(this); } else if (this->flags1 & 0x200) { - gSaveContext.weekEventReg[0x4F] |= 0x40; + gSaveContext.weekEventReg[79] |= 0x40; this->flags2 |= 4; this->actor.speedXZ = 0.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, @@ -1192,7 +1192,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { } if (this->unk1F4[1] == -0x63) { if (this->flags2 & 8) { - gSaveContext.weekEventReg[0x21] |= 8; + gSaveContext.weekEventReg[33] |= 8; } this->actor.speedXZ = 0.0f; Audio_QueueSeqCmd(0x101400FF); @@ -1220,10 +1220,10 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { this->unk42A = REG(15) + *unk_14; if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; unkStruct.unk0 = 0; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } this->unk428 = unkStruct.unk0; func_80BAC2FC(this, globalCtx); @@ -1259,10 +1259,10 @@ void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { this->unk42A = REG(15) + *unk_14; if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; unkStruct.unk0 = 0; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } this->unk428 = unkStruct.unk0; func_80BAC2FC(this, globalCtx); @@ -1284,11 +1284,11 @@ void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { void func_80BADA08(EnSuttari* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_80BAAB78(this, globalCtx); - gSaveContext.weekEventReg[0x51] |= 4; + gSaveContext.weekEventReg[81] |= 4; } else if (this->actor.xzDistToPlayer < 500.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 500.0f); } } @@ -1364,7 +1364,7 @@ void func_80BADD0C(EnSuttari* this, GlobalContext* globalCtx) { void func_80BADDB4(EnSuttari* this, GlobalContext* globalCtx) { func_80BABA90(this, 1, 1); func_80BAB434(this); - if (gSaveContext.weekEventReg[0x33] & 0x10) { + if (gSaveContext.weekEventReg[51] & 0x10) { this->actionFunc = func_80BADE14; } Actor_MoveWithGravity(&this->actor); @@ -1385,11 +1385,11 @@ void func_80BADE8C(EnSuttari* this, GlobalContext* globalCtx) { this->unk3F2 = this->unk2DC.y; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_801518B0(globalCtx, 0x2A3A, &this->actor); this->actionFunc = func_80BAD130; } else { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 500.0f); } } @@ -1410,14 +1410,14 @@ void EnSuttari_Init(Actor* thisx, GlobalContext* globalCtx) { EnSuttari* this = THIS; s32 pad; - if (gSaveContext.weekEventReg[0x4F] & 0x40) { + if (gSaveContext.weekEventReg[79] & 0x40) { Actor_MarkForDeath(&this->actor); return; } Collider_InitCylinder(globalCtx, &this->collider); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; EnSuttari_GetPaths(this, globalCtx); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_80BAC6E8; diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index f187562e2..abf7b3a40 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -7,7 +7,7 @@ #include "z_en_sw.h" #include "objects/object_st/object_st.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnSw*)thisx) @@ -674,7 +674,7 @@ s32 func_808DA08C(EnSw* this, GlobalContext* globalCtx) { } else if (!func_808D90C4(this)) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALTU_DEAD); Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; if (!ENSW_GET_3(&this->actor)) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); } @@ -1185,8 +1185,8 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { break; case 1: - this->actor.flags &= ~1; - this->actor.flags |= 0x10; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10; if (this->actor.world.rot.z < 0) { this->unk_460 = -thisx->world.rot.z; @@ -1206,8 +1206,8 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { case 2: case 3: - this->actor.flags &= ~1; - this->actor.flags |= 0x10; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10; if (this->actor.world.rot.z < 0) { this->unk_460 = -thisx->world.rot.z; diff --git a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c index 4b6d4a5d6..ca3e3d694 100644 --- a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c +++ b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c @@ -6,7 +6,7 @@ #include "z_en_syateki_crow.h" -#define FLAGS 0x08000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) #define THIS ((EnSyatekiCrow*)thisx) diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c index 6d606f8b7..65849b7e5 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c @@ -6,7 +6,7 @@ #include "z_en_syateki_dekunuts.h" -#define FLAGS 0x08000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) #define THIS ((EnSyatekiDekunuts*)thisx) diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index a097c354a..8c359eda1 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -7,7 +7,7 @@ #include "z_en_syateki_man.h" #include "objects/object_shn/object_shn.h" -#define FLAGS 0x08000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_8000000) #define THIS ((EnSyatekiMan*)thisx) @@ -782,7 +782,7 @@ void func_809C7C14(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_284 = 0xA37; } player->stateFlags1 &= ~0x20; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->unk_280 = 0; this->unk_26A = 0; this->actionFunc = func_809C6E30; @@ -844,7 +844,7 @@ void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx) { func_801518B0(globalCtx, 0x408, &this->actor); this->unk_284 = 0x408; player->stateFlags1 &= ~0x20; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->unk_280 = 0; this->unk_26A = 0; this->actionFunc = func_809C7990; diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c index 6360f0f39..cffef2fc9 100644 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c +++ b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c @@ -6,7 +6,7 @@ #include "z_en_syateki_okuta.h" -#define FLAGS 0x08000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) #define THIS ((EnSyatekiOkuta*)thisx) diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index d39849ee6..4dfaa44d0 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -6,7 +6,7 @@ #include "z_en_tab.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTab*)thisx) diff --git a/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c b/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c index f579719d2..35dc1ba30 100644 --- a/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c +++ b/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c @@ -6,7 +6,7 @@ #include "z_en_takaraya.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTakaraya*)thisx) diff --git a/src/overlays/actors/ovl_En_Talk/z_en_talk.c b/src/overlays/actors/ovl_En_Talk/z_en_talk.c index fcfa36a4d..4cf4ca407 100644 --- a/src/overlays/actors/ovl_En_Talk/z_en_talk.c +++ b/src/overlays/actors/ovl_En_Talk/z_en_talk.c @@ -6,7 +6,7 @@ #include "z_en_talk.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnTalk*)thisx) diff --git a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c index 1b2e04472..5985e77f9 100644 --- a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c +++ b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c @@ -6,7 +6,7 @@ #include "z_en_tanron1.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTanron1*)thisx) diff --git a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c index ba49ab93e..f845d9fa2 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_Boss_03/z_boss_03.h" #include "objects/object_boss03/object_boss03.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTanron3*)thisx) @@ -117,7 +117,7 @@ void EnTanron3_Init(Actor* thisx, GlobalContext* globalCtx) { this->morphTable, GYORG_SMALL_FISH_LIMB_MAX); Actor_SetScale(&this->actor, 0.02f); EnTanron3_SetupLive(this, globalCtx); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->currentRotationAngle = Rand_ZeroFloat(500000.0f); this->waterSurfaceYPos = 430.0f; sGyorg = (Boss03*)this->actor.parent; diff --git a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c index 45330247d..9912baf60 100644 --- a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c +++ b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c @@ -6,7 +6,7 @@ #include "z_en_tanron4.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnTanron4*)thisx) diff --git a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c index f79aea937..36f507327 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c @@ -6,7 +6,7 @@ #include "z_en_tanron5.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTanron5*)thisx) diff --git a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c index c34d2e5b5..bb57ff92f 100644 --- a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c +++ b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c @@ -6,7 +6,7 @@ #include "z_en_tanron6.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnTanron6*)thisx) diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.c b/src/overlays/actors/ovl_En_Test/z_en_test.c index 2f13b6640..0a0b86ea1 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -6,7 +6,7 @@ #include "z_en_test.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnTest*)thisx) diff --git a/src/overlays/actors/ovl_En_Test2/z_en_test2.c b/src/overlays/actors/ovl_En_Test2/z_en_test2.c index 9beb86263..c16a4133d 100644 --- a/src/overlays/actors/ovl_En_Test2/z_en_test2.c +++ b/src/overlays/actors/ovl_En_Test2/z_en_test2.c @@ -6,7 +6,7 @@ #include "z_en_test2.h" -#define FLAGS 0x00000090 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80) #define THIS ((EnTest2*)thisx) diff --git a/src/overlays/actors/ovl_En_Test3/z_en_test3.c b/src/overlays/actors/ovl_En_Test3/z_en_test3.c index 63d0cf954..ce9a8f3c9 100644 --- a/src/overlays/actors/ovl_En_Test3/z_en_test3.c +++ b/src/overlays/actors/ovl_En_Test3/z_en_test3.c @@ -6,7 +6,7 @@ #include "z_en_test3.h" -#define FLAGS 0x04000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_4000000) #define THIS ((EnTest3*)thisx) diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index 9e1417c84..791323123 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -8,7 +8,7 @@ #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" #include "overlays/actors/ovl_En_Horse/z_en_horse.h" -#define FLAGS 0x00100030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_100000) #define THIS ((EnTest4*)thisx) diff --git a/src/overlays/actors/ovl_En_Test5/z_en_test5.c b/src/overlays/actors/ovl_En_Test5/z_en_test5.c index 81e92103b..4a93cf5e8 100644 --- a/src/overlays/actors/ovl_En_Test5/z_en_test5.c +++ b/src/overlays/actors/ovl_En_Test5/z_en_test5.c @@ -6,7 +6,7 @@ #include "z_en_test5.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnTest5*)thisx) diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index 04365b5dd..3305d4c04 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -6,7 +6,7 @@ #include "z_en_test6.h" -#define FLAGS 0x02200030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200000 | ACTOR_FLAG_2000000) #define THIS ((EnTest6*)thisx) diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.c b/src/overlays/actors/ovl_En_Test7/z_en_test7.c index 81ab55e27..e84e2d3fd 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -6,7 +6,7 @@ #include "z_en_test7.h" -#define FLAGS 0x02300030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_100000 | ACTOR_FLAG_200000 | ACTOR_FLAG_2000000) #define THIS ((EnTest7*)thisx) diff --git a/src/overlays/actors/ovl_En_Tg/z_en_tg.c b/src/overlays/actors/ovl_En_Tg/z_en_tg.c index c53e096f0..fe3aadc7b 100644 --- a/src/overlays/actors/ovl_En_Tg/z_en_tg.c +++ b/src/overlays/actors/ovl_En_Tg/z_en_tg.c @@ -6,7 +6,7 @@ #include "z_en_tg.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnTg*)thisx) diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index 692fbc28a..dcc134dbd 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -7,7 +7,7 @@ #include "z_en_thiefbird.h" #include "objects/object_thiefbird/object_thiefbird.h" -#define FLAGS 0x80001205 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200 | ACTOR_FLAG_1000 | ACTOR_FLAG_80000000) #define THIS ((EnThiefbird*)thisx) @@ -447,7 +447,7 @@ void func_80C11454(EnThiefbird* this) { this->unk_3D8 = 0.5f; this->unk_3DC = 0.75f; this->unk_3D4 = 1.0f; - this->actor.flags &= ~0x200; + this->actor.flags &= ~ACTOR_FLAG_200; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } @@ -456,7 +456,7 @@ void func_80C114C0(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_18C = 0; this->unk_3D4 = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_350, 11, 2, 0.2f, 0.2f); - this->actor.flags |= 0x200; + this->actor.flags |= ACTOR_FLAG_200; } } @@ -600,7 +600,7 @@ void func_80C11C60(EnThiefbird* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_DEAD); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); this->collider.base.acFlags &= ~AC_ON; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->unk_192 = 0x1C00; this->actionFunc = func_80C11D14; } @@ -631,7 +631,7 @@ void func_80C11D14(EnThiefbird* this, GlobalContext* globalCtx) { } void func_80C11DC0(EnThiefbird* this) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80C11DF0; this->actor.gravity = -0.5f; } @@ -778,7 +778,7 @@ void func_80C12378(EnThiefbird* this, GlobalContext* globalCtx) { void func_80C1242C(EnThiefbird* this) { Animation_Change(&this->skelAnime, &object_thiefbird_Anim_000278, 2.0f, 0.0f, 0.0f, 0, -4.0f); - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->collider.base.acFlags |= AC_ON; this->actionFunc = func_80C124B0; this->actor.speedXZ = 12.0f; @@ -823,7 +823,7 @@ void func_80C124B0(EnThiefbird* this, GlobalContext* globalCtx) { } void func_80C126A8(EnThiefbird* this) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->collider.base.acFlags &= ~AC_ON; this->actionFunc = func_80C126D8; } @@ -841,7 +841,7 @@ void func_80C12744(EnThiefbird* this) { Animation_Change(&this->skelAnime, &object_thiefbird_Anim_000604, 1.0f, 0.0f, 0.0f, 1, -4.0f); this->unk_190 = 0; this->collider.base.acFlags |= AC_ON; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->actionFunc = func_80C127F4; this->actor.speedXZ = 4.0f; this->skelAnime.playSpeed = 3.0f; @@ -907,7 +907,7 @@ void func_80C127F4(EnThiefbird* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.x, -0x800, 4, 0x800, 0x80); if (this->unk_194 == 0) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; func_80C11538(this); } } @@ -925,7 +925,7 @@ void func_80C12B1C(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_194 = 0; for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { - if (this->collider.elements[i].info.bumperFlags & 2) { + if (this->collider.elements[i].info.bumperFlags & BUMP_HIT) { break; } } diff --git a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c index db71ae58d..cd0403c71 100644 --- a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c +++ b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c @@ -6,7 +6,7 @@ #include "z_en_time_tag.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnTimeTag*)thisx) diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.c b/src/overlays/actors/ovl_En_Tite/z_en_tite.c index ba37818aa..3665cdfde 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -7,7 +7,7 @@ #include "z_en_tite.h" #include "objects/object_tite/object_tite.h" -#define FLAGS 0x00000205 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200) #define THIS ((EnTite*)thisx) @@ -161,7 +161,7 @@ void EnTite_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == ENTITE_MINUS_3) { this->actor.params = ENTITE_MINUS_2; this->unk_2BE = 240; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.shape.yOffset = -3000.0f; this->actor.shape.shadowDraw = NULL; func_80895A10(this); @@ -271,7 +271,7 @@ void func_80893DD4(EnTite* this) { this->unk_2CC = 0.75f; this->unk_2C4 = 1.0f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); - this->actor.flags &= ~0x200; + this->actor.flags &= ~ACTOR_FLAG_200; } void func_80893E54(EnTite* this, GlobalContext* globalCtx) { @@ -280,7 +280,7 @@ void func_80893E54(EnTite* this, GlobalContext* globalCtx) { this->collider.base.colType = COLTYPE_HIT6; this->unk_2C4 = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D0, 9, 2, 0.2f, 0.2f); - this->actor.flags |= 0x200; + this->actor.flags |= ACTOR_FLAG_200; } } @@ -350,7 +350,7 @@ void func_8089408C(EnTite* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.velocity.y = 10.0f; } else { this->actor.velocity.y = 8.0f; @@ -382,7 +382,7 @@ void func_808942B4(EnTite* this, GlobalContext* globalCtx) { } } } else if (!(this->collider.base.atFlags & AT_HIT)) { - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } else { this->collider.base.atFlags &= ~AT_HIT; @@ -633,8 +633,8 @@ void func_80895020(EnTite* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_ON; this->actor.colorFilterTimer = 0; SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_TEKU_DEAD); - this->actor.flags &= ~1; - this->actor.flags |= 0x10; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10; this->unk_2BA = 1; Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, this->unk_2BE); this->unk_2BC = 25; @@ -778,7 +778,7 @@ void func_80895738(EnTite* this, GlobalContext* globalCtx) { } else if (this->unk_2BC > 0) { this->unk_2BC--; Math_StepToF(&this->actor.speedXZ, 10.0f, 0.3f); - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); if (!func_80893A34(this, globalCtx)) { this->unk_2BC = 0; @@ -921,7 +921,7 @@ void func_80895E28(EnTite* this, GlobalContext* globalCtx) { func_800B0DE0(globalCtx, &sp44, &sp38, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); if (Math_StepToF(&this->actor.shape.yOffset, 0.0f, 200.0f)) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.world.rot.y = this->actor.shape.rot.y; this->collider.base.acFlags |= AC_ON; func_808945EC(this); @@ -1013,7 +1013,7 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { } else if ((this->actor.bgCheckFlags & 1) && (this->collider.base.acFlags & AC_ON) && (this->actor.colChkInfo.health != 0) && (globalCtx->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < SQ(200.0f))) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; if (this->actor.shape.yOffset < 0.0f) { this->actor.shape.yOffset = 0.0f; this->actor.shape.shadowDraw = ActorShadow_DrawCircle; diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 6ccb2b5d2..b4982b400 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/object_tk/object_tk.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnTk*)thisx) @@ -218,7 +218,7 @@ void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { } if ((this->unk_2B0 == 1) || (this->unk_2B0 == 3)) { - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.update = func_80AEF2C8; this->actor.draw = NULL; return; @@ -246,7 +246,7 @@ void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.gravity = -1.0f; this->actor.shape.rot.y = this->actor.world.rot.y; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); @@ -359,9 +359,9 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { if (!temp4 && (this->unk_3CC != 0)) { this->actor.draw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } else if (temp4 && (this->unk_3CC == 0)) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.draw = EnTk_Draw; } @@ -369,7 +369,7 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { func_80AECE0C(this, globalCtx); if (this->unk_3CE & 8) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.draw = NULL; } } @@ -689,7 +689,7 @@ void func_80AED940(EnTk* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_2CA &= ~0x80; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; globalCtx->msgCtx.msgMode = 0; globalCtx->msgCtx.unk11F10 = 0; func_80AEDE10(this, globalCtx); @@ -740,7 +740,7 @@ void func_80AEDD4C(EnTk* this, GlobalContext* globalCtx) { void func_80AEDDA0(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->unk_2CA |= 0x80; this->actionFunc = func_80AED940; } diff --git a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c index 50ff93937..98ea88f83 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -7,7 +7,7 @@ #include "z_en_torch2.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnTorch2*)thisx) @@ -62,9 +62,9 @@ void EnTorch2_Init(Actor* thisx, GlobalContext* globalCtx) { // params: which form Link is in (e.g. human, deku, etc.) params = this->actor.params; if (params != TORCH2_PARAM_DEKU) { - this->actor.flags |= 0x4000000; // Can press switch + this->actor.flags |= ACTOR_FLAG_4000000; // Can press switch if (params == TORCH2_PARAM_GORON) { - this->actor.flags |= 0x20000; // Can press heavy switches + this->actor.flags |= ACTOR_FLAG_20000; // Can press heavy switches } } this->framesUntilNextState = 20; diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index 1c301a9da..64ff521c6 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -7,7 +7,7 @@ #include "z_en_toto.h" #include "objects/object_zm/object_zm.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnToto*)thisx) @@ -184,14 +184,14 @@ void EnToto_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - if (globalCtx->sceneNum == 0x15 && (gSaveContext.time >= 0x4000 && gSaveContext.time < 0xE555)) { + if (globalCtx->sceneNum == SCENE_MILK_BAR && (gSaveContext.time >= 0x4000 && gSaveContext.time < 0xE555)) { Actor_MarkForDeath(&this->actor); return; } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); this->actor.bgCheckFlags |= 0x400; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_zm_Skel_00A978, - ((globalCtx->sceneNum == 0x12) ? &object_zm_Anim_003AA8 : &object_zm_Anim_00C880), + ((globalCtx->sceneNum == SCENE_SONCHONOIE) ? &object_zm_Anim_003AA8 : &object_zm_Anim_00C880), this->jointTable, this->morphTable, 18); func_80BA36C0(this, globalCtx, 0); this->actor.shape.rot.x = 0; @@ -219,7 +219,7 @@ void func_80BA383C(EnToto* this, GlobalContext* globalCtx) { void func_80BA3930(EnToto* this, GlobalContext* globalCtx) { AnimationHeader* animationHeader = &object_zm_Anim_00C880; - if (globalCtx->sceneNum == 0x12) { + if (globalCtx->sceneNum == SCENE_SONCHONOIE) { animationHeader = &object_zm_Anim_003AA8; } Animation_MorphToLoop(&this->skelAnime, animationHeader, -4.0f); @@ -241,7 +241,7 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { func_80BA383C(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80BA36C0(this, globalCtx, 1); - if (globalCtx->sceneNum != 0x12) { + if (globalCtx->sceneNum != SCENE_SONCHONOIE) { Flags_SetSwitch(globalCtx, this->actor.params & 0x7F); } else if (player->transformation == PLAYER_FORM_DEKU) { Flags_SetSwitch(globalCtx, this->actor.home.rot.x); @@ -250,16 +250,16 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { return; } - if ((globalCtx->sceneNum == 0x15 && !(gSaveContext.time >= 0x4000 && gSaveContext.time < 0xED02)) || - (globalCtx->sceneNum != 0x15 && func_80BA397C(this, 0x2000))) { + if ((globalCtx->sceneNum == SCENE_MILK_BAR && !(gSaveContext.time >= 0x4000 && gSaveContext.time < 0xED02)) || + (globalCtx->sceneNum != SCENE_MILK_BAR && func_80BA397C(this, 0x2000))) { if (this->unk2B6 != 0) { this->text = D_80BA5044; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, EXCH_ITEM_NONE); } else { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 50.0f); - if (globalCtx->sceneNum == 0x12) { + if (globalCtx->sceneNum == SCENE_SONCHONOIE) { if (player->transformation == PLAYER_FORM_DEKU) { if (!Flags_GetSwitch(globalCtx, this->actor.home.rot.x)) { this->text = D_80BA5068; @@ -283,7 +283,7 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { } void func_80BA3BFC(EnToto* this, GlobalContext* globalCtx) { - if (globalCtx->sceneNum == 0x12) { + if (globalCtx->sceneNum == SCENE_SONCHONOIE) { Animation_MorphToPlayOnce(&this->skelAnime, &object_zm_Anim_000C80, -4.0f); this->unk2B4 = 0; } else { diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.c b/src/overlays/actors/ovl_En_Trt/z_en_trt.c index 1372be93d..c3898cdce 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -8,7 +8,7 @@ #include "objects/object_trt/object_trt.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnTrt*)thisx) @@ -189,7 +189,7 @@ u16 EnTrt_GetItemTextId(EnTrt* this) { u16 EnTrt_GetItemChoiceTextId(EnTrt* this) { EnGirlA* item = this->items[this->cursorIdx]; - if (item->actor.params == SI_POTION_BLUE && !(gSaveContext.weekEventReg[0x35] & 0x10)) { + if (item->actor.params == SI_POTION_BLUE && !(gSaveContext.weekEventReg[53] & 0x10)) { this->textId = 0x881; return 0x881; } @@ -335,7 +335,7 @@ void EnTrt_GetMushroom(EnTrt* this, GlobalContext* globalCtx) { case 0x883: this->textId = 0x884; func_801518B0(globalCtx, this->textId, &this->actor); - gSaveContext.weekEventReg[0x35] |= 8; + gSaveContext.weekEventReg[53] |= 8; func_80123D50(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); break; case 0x888: @@ -387,7 +387,7 @@ void EnTrt_Goodbye(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { if (this->textId == 0x88F) { - if (Interface_HasEmptyBottle() || !(gSaveContext.weekEventReg[0xC] & 0x10)) { + if (Interface_HasEmptyBottle() || !(gSaveContext.weekEventReg[12] & 0x10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; @@ -398,28 +398,28 @@ void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { } else { this->tmpTextId = this->textId; this->textId = 0x88E; - gSaveContext.weekEventReg[0x55] |= 8; + gSaveContext.weekEventReg[85] |= 8; func_801518B0(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } } else { - if (gSaveContext.weekEventReg[0xC] & 8) { + if (gSaveContext.weekEventReg[12] & 8) { this->textId = 0x83D; EnTrt_SetupStartShopping(globalCtx, this, 0); - } else if (gSaveContext.weekEventReg[0x54] & 0x40) { + } else if (gSaveContext.weekEventReg[84] & 0x40) { this->textId = 0x83B; if (Interface_HasItemInBottle(ITEM_POTION_RED)) { EnTrt_SetupStartShopping(globalCtx, this, false); } else { this->actionFunc = EnTrt_TryToGiveRedPotion; } - } else if (gSaveContext.weekEventReg[0x10] & 0x10) { + } else if (gSaveContext.weekEventReg[16] & 0x10) { this->timer = 30; this->textId = 0x838; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING_SPECIAL; this->actionFunc = EnTrt_Surprised; return; - } else if (gSaveContext.weekEventReg[0x11] & 1) { + } else if (gSaveContext.weekEventReg[17] & 1) { this->textId = 0x835; EnTrt_SetupStartShopping(globalCtx, this, false); } @@ -433,13 +433,13 @@ void EnTrt_GiveRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - if (!(gSaveContext.weekEventReg[0xC] & 0x10)) { - gSaveContext.weekEventReg[0xC] |= 0x10; + if (!(gSaveContext.weekEventReg[12] & 0x10)) { + gSaveContext.weekEventReg[12] |= 0x10; } - gSaveContext.weekEventReg[0x54] |= 0x40; + gSaveContext.weekEventReg[84] |= 0x40; player->stateFlags2 &= ~0x20000000; this->actionFunc = EnTrt_GivenRedPotionForKoume; - } else if (gSaveContext.weekEventReg[0xC] & 0x10) { + } else if (gSaveContext.weekEventReg[12] & 0x10) { Actor_PickUp(&this->actor, globalCtx, GI_POTION_RED, 300.0f, 300.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_BOTTLE_POTION_RED, 300.0f, 300.0f); @@ -732,7 +732,7 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { this->drawCursor = 0; this->shopItemSelectedTween = 0.0f; item->boughtFunc(globalCtx, item); - gSaveContext.weekEventReg[0x35] |= 0x10; + gSaveContext.weekEventReg[53] |= 0x10; } } } @@ -741,14 +741,14 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((gSaveContext.weekEventReg[0x55] & 8) && !(gSaveContext.weekEventReg[0x54] & 0x40)) { + if ((gSaveContext.weekEventReg[85] & 8) && !(gSaveContext.weekEventReg[84] & 0x40)) { this->textId = 0x88F; } else if (!(this->flags & ENTRT_MET)) { this->textId = 0x834; } else { this->textId = 0x83E; } - if (!(gSaveContext.weekEventReg[0x35] & 8)) { + if (!(gSaveContext.weekEventReg[53] & 8)) { this->talkOptionTextId = 0x845; } else if (this->flags & ENTRT_GIVEN_MUSHROOM) { this->talkOptionTextId = 0x882; @@ -873,8 +873,8 @@ void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { this->animationIdx = 5; switch (this->textId) { case 0x834: - if (!(gSaveContext.weekEventReg[0xC] & 8) && !(gSaveContext.weekEventReg[0x54] & 0x40) && - !(gSaveContext.weekEventReg[0x10] & 0x10) && !(gSaveContext.weekEventReg[0x11] & 1)) { + if (!(gSaveContext.weekEventReg[12] & 8) && !(gSaveContext.weekEventReg[84] & 0x40) && + !(gSaveContext.weekEventReg[16] & 0x10) && !(gSaveContext.weekEventReg[17] & 1)) { func_8011552C(globalCtx, 6); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; @@ -931,7 +931,7 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCt this->blinkFunc = EnTrt_Blink; if (talkState == 6 && func_80147624(globalCtx)) { - if (Interface_HasEmptyBottle() || !(gSaveContext.weekEventReg[0xC] & 0x10)) { + if (Interface_HasEmptyBottle() || !(gSaveContext.weekEventReg[12] & 0x10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; @@ -940,7 +940,7 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCt } else { this->tmpTextId = this->textId; this->textId = 0x88E; - gSaveContext.weekEventReg[0x55] |= 8; + gSaveContext.weekEventReg[85] |= 8; func_801518B0(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } @@ -961,7 +961,7 @@ void EnTrt_TryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { } else { this->tmpTextId = this->textId; this->textId = 0x88E; - gSaveContext.weekEventReg[0x55] |= 8; + gSaveContext.weekEventReg[85] |= 8; func_801518B0(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } @@ -1033,7 +1033,7 @@ void EnTrt_ShopkeeperGone(EnTrt* this, GlobalContext* globalCtx) { } } if (talkState == 6 && func_80147624(globalCtx)) { - if (gSaveContext.weekEventReg[0x14] & 2) { + if (gSaveContext.weekEventReg[20] & 2) { globalCtx->nextEntranceIndex = 0xC50; } else { globalCtx->nextEntranceIndex = 0x8450; @@ -1374,7 +1374,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { itemGiven = func_80123810(globalCtx); if (itemGiven > EXCH_ITEM_NONE) { if (itemGiven == EXCH_ITEM_1E) { - if (gSaveContext.weekEventReg[0x35] & 8) { + if (gSaveContext.weekEventReg[53] & 8) { player->actor.textId = 0x888; } else { player->actor.textId = 0x883; @@ -1443,7 +1443,7 @@ void EnTrt_LookToShopkeeperFromShelf(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_InitShopkeeper(EnTrt* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_trt_Skel_00FEF0, &object_trt_Anim_00FD34, NULL, NULL, 0); - if (!(gSaveContext.weekEventReg[0xC] & 8) && !(gSaveContext.weekEventReg[0x54] & 0x40) && gSaveContext.day >= 2) { + if (!(gSaveContext.weekEventReg[12] & 8) && !(gSaveContext.weekEventReg[84] & 0x40) && gSaveContext.day >= 2) { this->actor.draw = NULL; } else { this->actor.draw = EnTrt_Draw; @@ -1461,7 +1461,7 @@ void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.colChkInfo.cylRadius = 50; this->timer = Rand_S16Offset(40, 20); - if (!(gSaveContext.weekEventReg[0xC] & 8) && !(gSaveContext.weekEventReg[0x54] & 0x40) && gSaveContext.day >= 2) { + if (!(gSaveContext.weekEventReg[12] & 8) && !(gSaveContext.weekEventReg[84] & 0x40) && gSaveContext.day >= 2) { this->textId = 0x84A; this->actionFunc = EnTrt_ShopkeeperGone; } else { @@ -1529,11 +1529,11 @@ void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { this->blinkTimer = 20; this->eyeTextureIdx = 0; this->blinkFunc = EnTrt_EyesClosed; - if (gSaveContext.weekEventReg[0x35] & 8) { + if (gSaveContext.weekEventReg[53] & 8) { this->flags |= ENTRT_GIVEN_MUSHROOM; } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } void EnTrt_GetCutscenes(EnTrt* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index 767bfdae2..24b3e21ed 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -7,7 +7,7 @@ #include "z_en_tru.h" #include "objects/object_tru/object_tru.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTru*)thisx) @@ -1035,7 +1035,7 @@ s32 func_80A87DC0(Actor* thisx, GlobalContext* globalCtx) { } if (ret == true) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.draw = NULL; this->unk_378 = NULL; this->unk_34E = 0; @@ -1106,7 +1106,7 @@ void func_80A881E0(EnTru* this, GlobalContext* globalCtx) { this->unk_34E &= ~(0x1000 | 0x8); this->unk_34E |= 0x10; this->actor.shape.rot.y = this->actor.world.rot.y; - this->actor.flags &= ~0x100; + this->actor.flags &= ~ACTOR_FLAG_100; this->unk_1E8 = 0; this->actionFunc = func_80A87FD0; } diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c index 2d956d494..2cb79a8c1 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c @@ -6,7 +6,7 @@ #include "z_en_tru_mt.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTruMt*)thisx) diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c index 4205bf035..022aa44bc 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c @@ -6,7 +6,7 @@ #include "z_en_tsn.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnTsn*)thisx) diff --git a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c index c2d9e8d64..18476aa4e 100644 --- a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c +++ b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c @@ -238,7 +238,7 @@ void EnTuboTrap_Idle(EnTuboTrap* this, GlobalContext* globalCtx) { if ((startingRotation == 0) || (this->actor.playerHeightRel <= (startingRotation * 10.0f))) { func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ENEMY); currentHeight = this->actor.world.pos.y; - this->actor.flags |= 0x11; // always update and can target + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_10); // always update and can target transformationHeight = sTransformationHeight[player->transformation]; diff --git a/src/overlays/actors/ovl_En_Twig/z_en_twig.c b/src/overlays/actors/ovl_En_Twig/z_en_twig.c index aa1b3e1d4..c2cae36c3 100644 --- a/src/overlays/actors/ovl_En_Twig/z_en_twig.c +++ b/src/overlays/actors/ovl_En_Twig/z_en_twig.c @@ -6,7 +6,7 @@ #include "z_en_twig.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnTwig*)thisx) diff --git a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c index 84d9a8356..170cc6edb 100644 --- a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c +++ b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c @@ -6,7 +6,7 @@ #include "z_en_viewer.h" -#define FLAGS 0x00200030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200000) #define THIS ((EnViewer*)thisx) diff --git a/src/overlays/actors/ovl_En_Vm/z_en_vm.c b/src/overlays/actors/ovl_En_Vm/z_en_vm.c index b1fcfad5e..81ef8312b 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.c +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.c @@ -6,7 +6,7 @@ #include "z_en_vm.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnVm*)thisx) diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c index 05078f541..0bdb51729 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c @@ -6,7 +6,7 @@ #include "z_en_wallmas.h" -#define FLAGS 0x00000415 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnWallmas*)thisx) diff --git a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c index 2a38c9042..3c19559af 100644 --- a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c +++ b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c @@ -7,7 +7,7 @@ #include "z_en_warp_uzu.h" #include "objects/object_warp_uzu/object_warp_uzu.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnWarpUzu*)thisx) diff --git a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c index 1f376ace3..ce6367b87 100644 --- a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c +++ b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c @@ -6,7 +6,7 @@ #include "z_en_warp_tag.h" -#define FLAGS 0x0A000011 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000) #define THIS ((EnWarptag*)thisx) diff --git a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c index 3d2f837a0..41af7bce8 100644 --- a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c +++ b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c @@ -8,7 +8,7 @@ #include "objects/object_water_effect/object_water_effect.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnWaterEffect*)thisx) @@ -82,7 +82,7 @@ void EnWaterEffect_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnWaterEffect* this = THIS; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_DC4 = Rand_ZeroFloat(100.0f); if (this->actor.params == ENWATEREFFECT_1) { diff --git a/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c b/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c index b04de536b..b21e2f0b8 100644 --- a/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c +++ b/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c @@ -6,7 +6,7 @@ #include "z_en_wdhand.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnWdhand*)thisx) diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index bc969e694..46ef1d90a 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -6,7 +6,7 @@ #include "z_en_weather_tag.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnWeatherTag*)thisx) @@ -67,7 +67,7 @@ void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pathID; // flag: is targetable. Should do nothing as not set by default above - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; switch (WEATHER_TAG_TYPE(this)) { case WEATHERTAG_TYPE_UNK0: @@ -77,7 +77,7 @@ void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx) { EnWeatherTag_SetupAction(this, func_80966A08); break; case WEATHERTAG_TYPE_UNK1: - if (gSaveContext.weekEventReg[0x34] & 0x20) { // if cleared STT + if (gSaveContext.weekEventReg[52] & 0x20) { // if cleared STT Actor_MarkForDeath(&this->actor); } EnWeatherTag_SetupAction(this, func_80966B08); diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.c b/src/overlays/actors/ovl_En_Wf/z_en_wf.c index 12bed5ca1..9f109b1cd 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h" #include "objects/object_wf/object_wf.h" -#define FLAGS 0x00000415 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnWf*)thisx) @@ -367,7 +367,7 @@ void func_809907D4(EnWf* this) { this->collider2.base.colType = COLTYPE_HIT3; this->collider3.base.colType = COLTYPE_HIT3; this->unk_2A0 = 80; - this->actor.flags &= ~0x400; + this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 80); } @@ -378,7 +378,7 @@ void func_80990854(EnWf* this, GlobalContext* globalCtx) { this->collider3.base.colType = COLTYPE_HIT5; this->unk_2AC = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2B8, 10, 2, 0.3f, 0.2f); - this->actor.flags |= 0x400; + this->actor.flags |= ACTOR_FLAG_400; } } @@ -526,7 +526,7 @@ void func_80990F0C(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; this->actor.shape.shadowScale = 0.0f; this->actor.scale.y = 0.0f; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_2A0 = 60; this->actionFunc = func_80990F50; } @@ -552,7 +552,7 @@ void func_80990F50(EnWf* this, GlobalContext* globalCtx) { void func_80990FC8(EnWf* this) { Animation_Change(&this->skelAnime, &object_wf_Anim_0053D0, 0.5f, 0.0f, 7.0f, 3, 0.0f); this->unk_2A0 = 5; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80991040; } @@ -1158,7 +1158,7 @@ void func_80992D6C(EnWf* this) { if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -6.0f; } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_2A0 = 25; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_DEAD); this->actionFunc = func_80992E0C; diff --git a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c index 9264f42fb..7279650e7 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c @@ -6,7 +6,9 @@ #include "z_en_wiz.h" -#define FLAGS 0x88101035 +#define FLAGS \ + (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_1000 | ACTOR_FLAG_100000 | \ + ACTOR_FLAG_8000000 | ACTOR_FLAG_80000000) #define THIS ((EnWiz*)thisx) diff --git a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c index 1fa6bd35b..d6ae08331 100644 --- a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c +++ b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c @@ -6,7 +6,7 @@ #include "z_en_wiz_brock.h" -#define FLAGS 0x08000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_8000000) #define THIS ((EnWizBrock*)thisx) diff --git a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c index 0bdbf8679..ba6c1364b 100644 --- a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c +++ b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Wiz/z_en_wiz.h" #include "objects/object_wiz/object_wiz.h" -#define FLAGS 0x08000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_8000000) #define THIS ((EnWizFire*)thisx) @@ -70,7 +70,7 @@ void EnWizFire_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 3; this->unk_172 = 10; this->unk_1FC = 255.0f; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; if (!func_8012405C(globalCtx)) { this->collider.info.toucher.dmgFlags = 0x20000000; @@ -699,7 +699,8 @@ void func_80A4B33C(EnWizFire* this, GlobalContext* globalCtx2) { gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003640); Matrix_StatePop(); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, 0); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, + MTXMODE_NEW); Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); gSPSegment(POLY_XLU_DISP++, 0x08, diff --git a/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c b/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c index 0ef9f83af..004907003 100644 --- a/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c +++ b/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c @@ -6,7 +6,7 @@ #include "z_en_zl1.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnZl1*)thisx) diff --git a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c index d2b5e0378..731af3772 100644 --- a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c +++ b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c @@ -6,7 +6,7 @@ #include "z_en_zl4.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnZl4*)thisx) diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index b547f5a8c..65696bb00 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -7,7 +7,7 @@ #include "z_en_zo.h" #include "objects/object_zo/object_zo.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnZo*)thisx) diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.c b/src/overlays/actors/ovl_En_Zob/z_en_zob.c index 51fcf53bc..f1d987f2b 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.c +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.c @@ -6,7 +6,7 @@ #include "z_en_zob.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnZob*)thisx) diff --git a/src/overlays/actors/ovl_En_Zod/z_en_zod.c b/src/overlays/actors/ovl_En_Zod/z_en_zod.c index f8a38bd52..f908ceafa 100644 --- a/src/overlays/actors/ovl_En_Zod/z_en_zod.c +++ b/src/overlays/actors/ovl_En_Zod/z_en_zod.c @@ -6,7 +6,7 @@ #include "z_en_zod.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnZod*)thisx) diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.c b/src/overlays/actors/ovl_En_Zog/z_en_zog.c index 3fd7f24b8..b46878a19 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -7,7 +7,7 @@ #include "z_en_zog.h" #include "objects/object_zog/object_zog.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnZog*)thisx) @@ -256,7 +256,7 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { } } - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->actor.home.rot.z = 0; if (ENZOG_GET_F(&this->actor) != ENZOG_F_2) { for (i = 0; i < 5; i++) { @@ -268,8 +268,8 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && (gSaveContext.weekEventReg[88] & 0x10)) { this->unk_302 = this->unk_300 = 0; this->unk_2FC = this->unk_2FE = 3; - this->actor.flags |= 0x2000000; - this->actor.flags &= ~0x10000; + this->actor.flags |= ACTOR_FLAG_2000000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->unk_31C = 2; this->unk_31E = 0; @@ -644,7 +644,7 @@ void func_80B9461C(EnZog* this, GlobalContext* globalCtx) { if (!func_80B93EA0(this, globalCtx)) { this->actor.textId = 0x103C; this->actionFunc = func_80B9451C; - this->actor.flags |= 0x2000000; + this->actor.flags |= ACTOR_FLAG_2000000; gSaveContext.weekEventReg[91] |= 2; } @@ -746,7 +746,7 @@ void func_80B94A00(EnZog* this, GlobalContext* globalCtx) { if (func_80B93BE0(this, globalCtx)) { this->actionFunc = func_80B948A8; - this->actor.flags |= 0x2000000; + this->actor.flags |= ACTOR_FLAG_2000000; if (gSaveContext.weekEventReg[29] & 0x20) { this->actor.textId = 0x1009; } else { @@ -937,7 +937,7 @@ void func_80B95128(EnZog* this, GlobalContext* globalCtx) { break; } - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; gSaveContext.weekEventReg[91] |= 1; } else { func_800B8614(&this->actor, globalCtx, 150.0f); diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index 80f5d9992..88314d496 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -7,7 +7,7 @@ #include "z_en_zot.h" #include "objects/object_zo/object_zo.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnZot*)thisx) @@ -154,7 +154,7 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { break; case 8: - this->actor.flags |= 0x2000000; + this->actor.flags |= ACTOR_FLAG_2000000; this->actionFunc = func_80B98CA8; func_80B96BEC(this, 5, 0); break; @@ -484,7 +484,7 @@ void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { case 0x1279: func_801477B4(globalCtx); func_80B965D0(this, globalCtx); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.textId = 0; this->actionFunc = func_80B97708; if ((this->actor.cutscene != -1) && !(this->unk_2F2 & 1)) { @@ -559,7 +559,7 @@ void func_80B97708(EnZot* this, GlobalContext* globalCtx) { if (phi_v1 != 0) { gSaveContext.weekEventReg[29] |= 0x10; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; if (phi_v1 == 5) { if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { this->actor.textId = 0x126E; @@ -939,7 +939,7 @@ void func_80B9854C(EnZot* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; this->actionFunc = func_80B9849C; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); } else { Actor_PickUp(&this->actor, globalCtx, this->unk_2D4, 10000.0f, 50.0f); @@ -1051,7 +1051,7 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { default: func_801477B4(globalCtx); this->actionFunc = func_80B98998; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; break; } } @@ -1123,7 +1123,7 @@ void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { void func_80B98BF4(EnZot* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; if (gSaveContext.weekEventReg[41] & 0x20) { func_801518B0(globalCtx, 0x12B7, &this->actor); this->actionFunc = func_80B98AD0; @@ -1141,7 +1141,7 @@ void func_80B98CA8(EnZot* this, GlobalContext* globalCtx) { globalCtx->msgCtx.ocarinaMode = 4; func_8019B544(0xFFFF); this->actionFunc = func_80B98BF4; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 120.0f); } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B98AD0; diff --git a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c index c5c0c16ea..82b29e716 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c @@ -6,7 +6,7 @@ #include "z_item_etcetera.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ItemEtcetera*)thisx) diff --git a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c index a006270f3..7017dfcec 100644 --- a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c +++ b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c @@ -6,7 +6,7 @@ #include "z_item_inbox.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((ItemInbox*)thisx) diff --git a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c index 7d0068a52..f542b7086 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c @@ -6,7 +6,7 @@ #include "z_mir_ray.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((MirRay*)thisx) diff --git a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c index d9eb30b4f..f6e8750cb 100644 --- a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c +++ b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c @@ -6,7 +6,7 @@ #include "z_mir_ray2.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((MirRay2*)thisx) diff --git a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c index d68880f2d..1da636c1d 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c @@ -6,7 +6,7 @@ #include "z_mir_ray3.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((MirRay3*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c index 8e168cba8..2b6b332f4 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c @@ -7,7 +7,7 @@ #include "z_obj_aqua.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjAqua*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c index d4ae2b79f..2d7db7644 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c @@ -6,7 +6,7 @@ #include "z_obj_armos.h" -#define FLAGS 0x04000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_4000000) #define THIS ((ObjArmos*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c index 3b00578a2..dd57b99e4 100644 --- a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c +++ b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c @@ -7,7 +7,7 @@ #include "z_obj_bell.h" #include "objects/object_f52_obj/object_f52_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjBell*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c index 176f961be..0d937d1c0 100644 --- a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c +++ b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c @@ -6,7 +6,7 @@ #include "z_obj_blockstop.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjBlockstop*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c index 341dc5c56..880d72b3f 100644 --- a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c +++ b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c @@ -6,7 +6,7 @@ #include "z_obj_boat.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjBoat*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c index c4af83d59..b8da1a9f6 100644 --- a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c +++ b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "objects/object_boyo/object_boyo.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjBoyo*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c index 4dd0a78b1..465c660c6 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -6,7 +6,7 @@ #include "z_obj_chan.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjChan*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c index c1e74ce53..7de79a2be 100644 --- a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c +++ b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c @@ -6,7 +6,7 @@ #include "z_obj_chikuwa.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjChikuwa*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c index 6e14ea096..aa72f3052 100644 --- a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c +++ b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c @@ -6,7 +6,7 @@ #include "z_obj_danpeilift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjDanpeilift*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c index a51a7e8d2..2fba4b96a 100644 --- a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c +++ b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c @@ -6,7 +6,7 @@ #include "z_obj_demo.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjDemo*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c b/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c index cec3720d2..03e73043f 100644 --- a/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c +++ b/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c @@ -7,7 +7,7 @@ #include "z_obj_dinner.h" #include "objects/object_obj_dinner/object_obj_dinner.h" -#define FLAGS 0x00000020 +#define FLAGS (ACTOR_FLAG_20) #define THIS ((ObjDinner*)thisx) @@ -31,7 +31,7 @@ const ActorInit Obj_Dinner_InitVars = { void ObjDinner_Init(Actor* thisx, GlobalContext* globalCtx) { ObjDinner* this = THIS; - if (gSaveContext.isNight != true || (CURRENT_DAY == 3 && gSaveContext.weekEventReg[0x16] & 1)) { + if (gSaveContext.isNight != true || (CURRENT_DAY == 3 && gSaveContext.weekEventReg[22] & 1)) { Actor_MarkForDeath(&this->actor); } Actor_SetScale(&this->actor, 0.1f); diff --git a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c index 77285cdfd..1d77cc257 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c @@ -6,7 +6,7 @@ #include "z_obj_dora.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjDora*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c index a75bc0a3b..dbc945109 100644 --- a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c +++ b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c @@ -6,7 +6,7 @@ #include "z_obj_dowsing.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjDowsing*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c b/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c index be348ef1c..0de07e013 100644 --- a/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c +++ b/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c @@ -7,7 +7,7 @@ #include "z_obj_ending.h" #include "objects/object_ending_obj/object_ending_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjEnding*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c index 0d4432ddd..72f0a8015 100644 --- a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c +++ b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c @@ -6,7 +6,7 @@ #include "z_obj_entotu.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjEntotu*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c index 23d2dfa7f..eb91a93d4 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c @@ -7,7 +7,7 @@ #include "z_obj_etcetera.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjEtcetera*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c index eaa085f49..00810af23 100644 --- a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c +++ b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c @@ -6,7 +6,7 @@ #include "z_obj_fireshield.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjFireshield*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c index 0365f3420..16ac7e8e9 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -447,7 +447,7 @@ void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { func_80A1CBF8(this); this->actor.room = -1; this->actor.colChkInfo.mass = 180; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; if (func_800A817C(ENOBJFLOWERPOT_GET_3F(&this->actor))) { func_80A1B914(this, globalCtx); } @@ -465,7 +465,7 @@ void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { func_80A1BD80(this, globalCtx); func_80A1B994(this, globalCtx); Actor_MarkForDeath(&this->actor); - } else if ((this->collider.elements[0].info.bumperFlags & 2) && + } else if ((this->collider.elements[0].info.bumperFlags & BUMP_HIT) && (this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0x058BFFBC)) { if (!(this->unk_1EA & 2)) { func_80A1B914(this, globalCtx); @@ -477,10 +477,10 @@ void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { func_80A1B994(this, globalCtx); Actor_MarkForDeath(&this->actor); } else { - if (this->collider.elements[1].info.bumperFlags & 2) { + if (this->collider.elements[1].info.bumperFlags & BUMP_HIT) { if (!(this->unk_1EA & 2)) { this->unk_1EA |= 2; - this->collider.elements[1].info.bumperFlags &= ~0x1; + this->collider.elements[1].info.bumperFlags &= ~BUMP_ON; func_80A1C0FC(this, globalCtx); func_80A1B914(this, globalCtx); func_80A1B9CC(this, globalCtx); @@ -493,7 +493,7 @@ void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { if (this->actor.colChkInfo.mass == MASS_IMMOVABLE) { if (DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId) == NULL) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; this->unk_1EA &= ~0x1; } } else if (Math3D_Vec3fDistSq(&this->actor.world.pos, &this->actor.prevPos) < 0.01f) { diff --git a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c index 5dac29b65..dfd4ec65a 100644 --- a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c +++ b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c @@ -7,7 +7,7 @@ #include "z_obj_funen.h" #include "objects/object_funen/object_funen.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjFunen*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c index 0a7c5b524..3a83c47f7 100644 --- a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c +++ b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c @@ -7,7 +7,7 @@ #include "z_obj_ghaka.h" #include "objects/object_ghaka/object_ghaka.h" -#define FLAGS 0x00000029 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_20) #define THIS ((ObjGhaka*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c index 8dc01d386..ae70ba013 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c @@ -6,7 +6,7 @@ #include "z_obj_grass.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjGrass*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c index 4d717fabd..0a703c965 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c +++ b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c @@ -6,7 +6,7 @@ #include "z_obj_grass_carry.h" -#define FLAGS 0x00800030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_800000) #define THIS ((ObjGrassCarry*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c index 978f2cd13..f347b6a6d 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c @@ -6,7 +6,7 @@ #include "z_obj_hakaisi.h" -#define FLAGS 0x00000029 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_20) #define THIS ((ObjHakaisi*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c index 9784e212c..b887f7a1b 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c @@ -6,7 +6,7 @@ #include "z_obj_hamishi.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjHamishi*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c index 286080631..0caec6ea4 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c @@ -6,7 +6,7 @@ #include "z_obj_hariko.h" -#define FLAGS 0x02000020 +#define FLAGS (ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((ObjHariko*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c index b8bef84a8..3f47e321f 100644 --- a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c +++ b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c @@ -7,7 +7,7 @@ #include "z_obj_hgdoor.h" #include "objects/object_hgdoor/object_hgdoor.h" -#define FLAGS 0x00100000 +#define FLAGS (ACTOR_FLAG_100000) #define THIS ((ObjHgdoor*)thisx) diff --git a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c index c1a308bae..c06543f07 100644 --- a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c +++ b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c @@ -7,7 +7,7 @@ #include "z_obj_hsstump.h" #include "objects/object_hsstump/object_hsstump.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjHsStump*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c index f3be22f7f..74e00403c 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -7,7 +7,7 @@ #include "z_obj_hugebombiwa.h" #include "objects/object_bombiwa/object_bombiwa.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjHugebombiwa*)thisx) @@ -440,7 +440,7 @@ void func_80A54E10(ObjHugebombiwa* this) { Vec3f sp84; Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, 0); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); for (i = 0, phi_s2 = 0x1000; i < 20; i++, phi_s2 += 0x4000) { ptr = &this->unk_190[i]; @@ -535,7 +535,7 @@ void func_80A55310(ObjHugebombiwa* this) { Vec3f sp84; Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, 0); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); for (i = 0, phi_s2 = 0x1000; i < ARRAY_COUNT(this->unk_190); i++, phi_s2 += 0x4000) { ptr = &this->unk_190[i]; diff --git a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c index ff90f2e3e..869acdb43 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c @@ -6,7 +6,7 @@ #include "z_obj_hunsui.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjHunsui*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c index 38b53b23c..f122dca41 100644 --- a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c +++ b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_Obj_Aqua/z_obj_aqua.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS ACTOR_FLAG_10 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjIcePoly*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c index 6ccc8217d..627338400 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -7,7 +7,7 @@ #include "z_obj_iceblock.h" #include "objects/object_ice_block/object_ice_block.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjIceblock*)thisx) @@ -670,7 +670,7 @@ void func_80A24B74(ObjIceblock* this, GlobalContext* globalCtx) { s32 pad; Vec3f sp20; - if (this->dyna.actor.flags & 0x40) { + if (this->dyna.actor.flags & ACTOR_FLAG_40) { if (1) {} sp20.x = this->dyna.actor.world.pos.x; sp20.y = this->unk_244; @@ -687,7 +687,7 @@ void func_80A24BDC(ObjIceblock* this, GlobalContext* globalCtx, f32 arg2, f32 ar s16 phi_s0; s32 phi_s1 = 0; - if (this->dyna.actor.flags & 0x40) { + if (this->dyna.actor.flags & ACTOR_FLAG_40) { sp88.y = this->unk_244; temp_f22 = 0x10000 / arg4; @@ -723,7 +723,7 @@ void func_80A24DD0(ObjIceblock* this, GlobalContext* globalCtx) { } this->unk_2A2++; - if (this->dyna.actor.flags & 0x40) { + if (this->dyna.actor.flags & ACTOR_FLAG_40) { if (this->unk_2A2 >= 0x2E) { phi_f22 = 1.0f; } else { @@ -764,7 +764,7 @@ void func_80A2508C(ObjIceblock* this, GlobalContext* globalCtx) { f32 temp_f0; s32 temp_v0; - if (this->dyna.actor.flags & 0x40) { + if (this->dyna.actor.flags & ACTOR_FLAG_40) { temp_v0 = (s32)(this->dyna.actor.scale.y * 130.0f) - 3; if (temp_v0 > 0) { this->unk_2AC += temp_v0; @@ -1008,7 +1008,7 @@ void func_80A2586C(ObjIceblock* this, GlobalContext* globalCtx) { func_80A2319C(this, this->dyna.actor.scale.x); - if (this->dyna.actor.flags & 0x40) { + if (this->dyna.actor.flags & ACTOR_FLAG_40) { func_80A2339C(globalCtx, &this->dyna.actor.world.pos, (this->dyna.actor.scale.x + 0.05f) * 0.6666666f, 1.0f, 3); } } @@ -1028,7 +1028,7 @@ void func_80A25994(ObjIceblock* this, GlobalContext* globalCtx) { return; } - if (this->dyna.actor.flags & 0x40) { + if (this->dyna.actor.flags & ACTOR_FLAG_40) { func_80A2339C(globalCtx, &this->dyna.actor.world.pos, this->dyna.actor.scale.x, 1.2f, 15); if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { sp30.x = this->dyna.actor.world.pos.x; @@ -1180,7 +1180,7 @@ void func_80A25E50(ObjIceblock* this, GlobalContext* globalCtx) { func_80A2541C(this, globalCtx); func_80A25CF4(this); } else { - func_800B9010(&this->dyna.actor, 0xDF); + func_800B9010(&this->dyna.actor, NA_SE_PL_SLIP_ICE_LEVEL - SFX_FLAG); } } @@ -1266,7 +1266,7 @@ void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { func_80A23B88(this); func_80A25FA0(this); } else { - func_800B9010(&this->dyna.actor, 0xDF); + func_800B9010(&this->dyna.actor, NA_SE_PL_SLIP_ICE_LEVEL - SFX_FLAG); } func_80A24DD0(this, globalCtx); diff --git a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c index b8a1406d7..06c59bd7d 100644 --- a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c +++ b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c @@ -7,7 +7,7 @@ #include "z_obj_jg_gakki.h" #include "objects/object_jg/object_jg.h" -#define FLAGS 0x00000020 +#define FLAGS (ACTOR_FLAG_20) #define THIS ((ObjJgGakki*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c index 6c8cb3722..68e7717c1 100644 --- a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c +++ b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c @@ -6,7 +6,7 @@ #include "z_obj_jgame_light.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjJgameLight*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c index 9a31d39f5..979848c3b 100644 --- a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c +++ b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c @@ -8,7 +8,7 @@ #include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #include "objects/object_kibako/object_kibako.h" -#define FLAGS 0x04000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_4000000) #define THIS ((ObjKibako*)thisx) @@ -271,7 +271,7 @@ void ObjKibako_Idle(ObjKibako* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { ObjKibako_SetupHeld(this); this->actor.room = -1; - this->actor.colChkInfo.mass = 0x78; + this->actor.colChkInfo.mass = 120; if (func_800A817C(KIBAKO_COLLECTIBLE_ID(&this->actor))) { ObjKibako_SpawnCollectible(this, globalCtx); } @@ -347,7 +347,7 @@ void ObjKibako_Held(ObjKibako* this, GlobalContext* globalCtx) { } else { Actor_MoveWithGravity(&this->actor); ObjKibako_SetupThrown(this); - this->actor.flags &= ~0x4000000; + this->actor.flags &= ~ACTOR_FLAG_4000000; } Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); } else { diff --git a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c index dd8029eca..c0e5d8b4b 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c @@ -161,7 +161,7 @@ void ObjKibako2_Init(Actor* thisx, GlobalContext* globalCtx) { if (func_800A81A4(globalCtx, KIBAKO2_COLLECTIBLE_ID(&this->dyna.actor), KIBAKO2_COLLECTIBLE_FLAG(&this->dyna.actor))) { this->unk_1AC = 1; - this->dyna.actor.flags |= 0x10; + this->dyna.actor.flags |= ACTOR_FLAG_10; } } if ((contents != CONTENTS_SKULLTULA) || !ObjKibako2_ContainsSkulltula(this, globalCtx)) { @@ -210,7 +210,7 @@ void ObjKibako2_Idle(ObjKibako2* this, GlobalContext* globalCtx) { if (ObjKibako2_ShouldBreak(this)) { ObjKibako2_Break(this, globalCtx); SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); - this->dyna.actor.flags |= 0x10; + this->dyna.actor.flags |= ACTOR_FLAG_10; func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = NULL; this->actionFunc = ObjKibako2_Kill; diff --git a/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c b/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c index 1f9548839..5080c19e6 100644 --- a/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c +++ b/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c @@ -7,7 +7,7 @@ #include "z_obj_kzsaku.h" #include "objects/object_kzsaku/object_kzsaku.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjKzsaku*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c index 481cc22f6..300e299aa 100644 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c @@ -6,7 +6,7 @@ #include "z_obj_lift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjLift*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c index ae7b508bd..e9456bac1 100644 --- a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c +++ b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c @@ -7,7 +7,7 @@ #include "z_obj_lightswitch.h" #include "objects/object_lightswitch/object_lightswitch.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjLightswitch*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c index 57db84b12..d804f6b63 100644 --- a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c +++ b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c @@ -6,7 +6,7 @@ #include "z_obj_lupygamelift.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjLupygamelift*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c index 19c078792..a5aaefd4f 100644 --- a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c +++ b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c @@ -6,7 +6,7 @@ #include "z_obj_makekinsuta.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjMakekinsuta*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c index c7f49d683..1645f8469 100644 --- a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c +++ b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c @@ -6,7 +6,7 @@ #include "z_obj_makeoshihiki.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjMakeoshihiki*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c index 353faa6d3..6d06195d1 100644 --- a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c +++ b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c @@ -60,7 +60,7 @@ void ObjMilkBin_Init(Actor* thisx, GlobalContext* globalCtx) { this->disableDraw = 0; this->type = thisx->params; - if ((this->type == OBJ_MILK_BIN_TYPE_2) && !(gSaveContext.weekEventReg[0x34] & 1)) { + if ((this->type == OBJ_MILK_BIN_TYPE_2) && !(gSaveContext.weekEventReg[52] & 1)) { this->disableDraw |= 1; } } @@ -76,14 +76,14 @@ void ObjMilkBin_Update(Actor* thisx, GlobalContext* globalCtx2) { ObjMilkBin* this = THIS; if (this->type == OBJ_MILK_BIN_TYPE_1) { - if (gSaveContext.weekEventReg[0x16] & 1) { + if (gSaveContext.weekEventReg[22] & 1) { if (((gSaveContext.day == 2) && (gSaveContext.isNight == 1)) || (gSaveContext.day >= 3)) { Actor_MarkForDeath(&this->actor); return; } } } else if (this->type == OBJ_MILK_BIN_TYPE_2) { - if (gSaveContext.weekEventReg[0x34] & 1) { + if (gSaveContext.weekEventReg[52] & 1) { this->disableDraw &= ~1; } else { this->disableDraw |= 1; diff --git a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c index c44fdad34..bb7eb2343 100644 --- a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c +++ b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c @@ -7,7 +7,7 @@ #include "z_obj_moon_stone.h" #include "objects/object_gi_reserve00/object_gi_reserve00.h" -#define FLAGS 0x00100010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_100000) #define THIS ((ObjMoonStone*)thisx) @@ -47,7 +47,7 @@ void ObjMoonStone_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.focus.pos.y += 10.0f; if (this->unk194 == 0) { this->actor.colChkInfo.health = 0; - this->actor.flags |= 9; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80C0662C(this); } else { if ((gSaveContext.weekEventReg[74] & 0x40) == 0) { @@ -55,7 +55,7 @@ void ObjMoonStone_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, 1, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, -1); } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; func_80C0673C(this); } else { Actor_MarkForDeath(&this->actor); diff --git a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c index 04fe44991..6b6923838 100644 --- a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c +++ b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c @@ -6,7 +6,7 @@ #include "z_obj_mu_pict.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((ObjMuPict*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c index f41e577b4..b24354482 100644 --- a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c +++ b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c @@ -259,7 +259,7 @@ void ObjMure_InitialAction(ObjMure* this, GlobalContext* globalCtx) { void ObjMure_CulledState(ObjMure* this, GlobalContext* globalCtx) { if (fabsf(this->actor.projectedPos.z) < sZClip[this->type]) { this->actionFunc = ObjMure_ActiveState; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; ObjMure_SpawnActors(this, globalCtx); } } @@ -382,7 +382,7 @@ void ObjMure_ActiveState(ObjMure* this, GlobalContext* globalCtx) { ObjMure_CheckChildren(this, globalCtx); if (sZClip[this->type] + 40.0f <= fabsf(this->actor.projectedPos.z)) { this->actionFunc = ObjMure_CulledState; - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; ObjMure_KillActors(this, globalCtx); } else if (sTypeGroupBehaviorFunc[this->type] != NULL) { sTypeGroupBehaviorFunc[this->type](this, globalCtx); diff --git a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c index d2cd9f7fa..ba5b62151 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c @@ -6,7 +6,7 @@ #include "z_obj_nozoki.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjNozoki*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c index 66dbd49fb..731bc4328 100644 --- a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c +++ b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c @@ -6,7 +6,7 @@ #include "z_obj_ocarinalift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjOcarinalift*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c b/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c index 1c8f0a132..0f594f1e1 100644 --- a/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c +++ b/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c @@ -6,7 +6,7 @@ #include "z_obj_purify.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjPurify*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c index b89a0b1c3..d6f35c491 100644 --- a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c +++ b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c @@ -6,7 +6,7 @@ #include "z_obj_pzlblock.h" -#define FLAGS 0x04000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_4000000) #define THIS ((ObjPzlblock*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c index 17490112f..0acdf1bca 100644 --- a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c +++ b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c @@ -7,7 +7,7 @@ #include "z_obj_raillift.h" #include "objects/object_raillift/object_raillift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjRaillift*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c index d7f15477a..a1cc93b9f 100644 --- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c +++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c @@ -6,7 +6,7 @@ #include "z_obj_roomtimer.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjRoomtimer*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c index 61bc5570c..f6f744d15 100644 --- a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c +++ b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c @@ -6,7 +6,7 @@ #include "z_obj_shutter.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjShutter*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c index 7bd1dfc1e..8219bc581 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c @@ -6,7 +6,7 @@ #include "z_obj_skateblock.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjSkateblock*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c index f928acc0e..badd4318e 100644 --- a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c +++ b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c @@ -6,7 +6,7 @@ #include "z_obj_smork.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjSmork*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c index 9eb0ae99f..632d1b8c6 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c @@ -482,7 +482,7 @@ void ObjSnowball_Init(Actor* thisx, GlobalContext* globalCtx) { if (sp34) { this->actor.textId = 0x238; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.targetArrowOffset = 1400.0f / 3.0f; Actor_SetFocus(&this->actor, 24.0f); this->actor.targetMode = 3; @@ -539,9 +539,9 @@ void func_80B04350(ObjSnowball* this, GlobalContext* globalCtx) { if (flag && (this->unk_211 == 0) && (this->collider.elements->info.acHitInfo->toucher.dmgFlags & (0x80000000 | 0x4000 | 0x800 | 0x400 | 0x100 | 0x8))) { - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; if (this->actor.home.rot.y == 1) { - this->actor.flags &= ~(8 | 1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); } if (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x4000) { @@ -761,11 +761,11 @@ void ObjSnowball_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.home.rot.y == 1) { if (this->unk_211 != 0) { if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; this->unk_211 = 0; } } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->unk_211 = 1; } else if (this->actor.isTargeted) { sp24 = true; diff --git a/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c b/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c index 6b59eeb16..231dd99f3 100644 --- a/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c +++ b/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c @@ -6,7 +6,7 @@ #include "z_obj_sound.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjSound*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c index 90fa1f42f..20e262298 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c @@ -6,7 +6,7 @@ #include "z_obj_spidertent.h" -#define FLAGS 0x10000000 +#define FLAGS (ACTOR_FLAG_10000000) #define THIS ((ObjSpidertent*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c index cf7c48431..9547aa04f 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c @@ -6,7 +6,7 @@ #include "z_obj_spinyroll.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjSpinyroll*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c index b8e576e39..4a69fc1eb 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -6,7 +6,7 @@ #include "z_obj_switch.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjSwitch*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c index 3d94f31b6..cea97efe9 100644 --- a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c +++ b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c @@ -6,7 +6,7 @@ #include "z_obj_swprize.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjSwprize*)thisx) 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 3a15f845b..a6e3782bc 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" #include "objects/object_syokudai/object_syokudai.h" -#define FLAGS 0x00000410 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((ObjSyokudai*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.c b/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.c index d1e168447..65c984981 100644 --- a/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.c +++ b/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.c @@ -6,7 +6,7 @@ #include "z_obj_takaraya_wall.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjTakarayaWall*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c index bf535300b..0471b6bd7 100644 --- a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c +++ b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c @@ -6,7 +6,7 @@ #include "z_obj_toge.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjToge*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c index 50f879aec..65ba62f3c 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c @@ -7,7 +7,7 @@ #include "z_obj_tokei_step.h" #include "objects/object_tokei_step/object_tokei_step.h" -#define FLAGS 0x00400010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_400000) #define THIS ((ObjTokeiStep*)thisx) @@ -250,7 +250,7 @@ void ObjTokeiStep_Open(ObjTokeiStep* this, GlobalContext* globalCtx) { } void ObjTokeiStep_SetupDoNothingOpen(ObjTokeiStep* this) { - this->dyna.actor.flags &= ~0x10; + this->dyna.actor.flags &= ~ACTOR_FLAG_10; this->actionFunc = ObjTokeiStep_DoNothingOpen; } diff --git a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c index ae43514c7..1e9029067 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -32,7 +32,7 @@ #include "z_obj_tokeidai.h" #include "objects/object_obj_tokeidai/object_obj_tokeidai.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjTokeidai*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c index 325bd3f3e..b91cbcf7e 100644 --- a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c +++ b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c @@ -6,7 +6,7 @@ #include "z_obj_toudai.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjToudai*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c index d767e8b3b..e19edead3 100644 --- a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c +++ b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c @@ -7,7 +7,7 @@ #include "z_obj_tree.h" #include "objects/object_tree/object_tree.h" -#define FLAGS 0x02000000 +#define FLAGS (ACTOR_FLAG_2000000) #define THIS ((ObjTree*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c index e91c3387f..af00e5c64 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c @@ -6,7 +6,7 @@ #include "z_obj_tsubo.h" -#define FLAGS 0x04800010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000 | ACTOR_FLAG_4000000) #define THIS ((ObjTsubo*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c index ee5222543..324d13e4b 100644 --- a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c +++ b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c @@ -6,7 +6,7 @@ #include "z_obj_um.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjUm*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c index 8ed03a8ef..35371b605 100644 --- a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c +++ b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c @@ -6,7 +6,7 @@ #include "z_obj_usiyane.h" -#define FLAGS 0x00000020 +#define FLAGS (ACTOR_FLAG_20) #define THIS ((ObjUsiyane*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c b/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c index 4fc6200c5..8741fc01b 100644 --- a/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c +++ b/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c @@ -7,7 +7,7 @@ #include "z_obj_visiblock.h" #include "objects/object_visiblock/object_visiblock.h" -#define FLAGS 0x00000080 +#define FLAGS (ACTOR_FLAG_80) #define THIS ((ObjVisiblock*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c index c830c29d9..10d87e6bc 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c @@ -6,7 +6,7 @@ #include "z_obj_vspinyroll.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjVspinyroll*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c index cb2af735c..37a141264 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c @@ -8,7 +8,7 @@ #include "objects/object_sek/object_sek.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((ObjWarpstone*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c b/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c index 02fc51e13..f72645e49 100644 --- a/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c +++ b/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c @@ -6,7 +6,7 @@ #include "z_obj_wind.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjWind*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c index 94f73d2a2..225587cdc 100644 --- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c +++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c @@ -6,7 +6,7 @@ #include "z_obj_wturn.h" -#define FLAGS 0x02100010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((ObjWturn*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c index 3c0fce631..7e9f6cb29 100644 --- a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c +++ b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c @@ -6,7 +6,7 @@ #include "z_obj_y2lift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjY2lift*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c b/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c index c9850690d..4bfced35c 100644 --- a/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c +++ b/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c @@ -6,7 +6,7 @@ #include "z_obj_y2shutter.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjY2shutter*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c index 321274049..70bb72454 100644 --- a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c +++ b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c @@ -7,7 +7,7 @@ #include "z_obj_yado.h" #include "objects/object_yado_obj/object_yado_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjYado*)thisx) diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index 3195c7877..2444b5010 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -7,7 +7,7 @@ #include "z_object_kankyo.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((ObjectKankyo*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c index 4b1e1d8ba..18d28f8c7 100644 --- a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c +++ b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c @@ -6,7 +6,7 @@ #include "z_oceff_spot.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffSpot*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c index 781e50605..1939b1ef0 100644 --- a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c +++ b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c @@ -6,7 +6,7 @@ #include "z_oceff_storm.h" -#define FLAGS 0x02000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((OceffStorm*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c index b5dd2f290..1179f5ba2 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c +++ b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c index aee5dd446..61a1ae549 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c +++ b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe2.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe2*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c index 0ef0a25e8..a8745c015 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c +++ b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe3.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe3*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c index b9a89614b..b985aadad 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c +++ b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe4.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe4*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c index 8cac4317d..e39a4aa4c 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c +++ b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe5.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe5*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c index c14a59e9f..6bde6902c 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c +++ b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe6.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe6*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c b/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c index f03130343..da295b768 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c +++ b/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe7.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe7*)thisx) diff --git a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c index 8072d9f44..38acb813e 100644 --- a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c +++ b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c @@ -6,7 +6,7 @@ #include "z_shot_sun.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((ShotSun*)thisx) diff --git a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c index 9dcf3ab15..51a2fa695 100644 --- a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c +++ b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c @@ -6,7 +6,7 @@ #include "z_tg_sw.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((TGSw*)thisx) From fc270e338e25faad21b9179e00b4780c4b862890 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 19 Feb 2022 14:39:55 -0800 Subject: [PATCH 042/257] Change all hex weekEventReg accesses into decimal (#660) * Change all hex weekEventReg accesses into decimal * Remove hex from Osn --- include/z64ocarina.h | 2 +- src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c | 2 +- src/overlays/actors/ovl_En_Osn/z_en_osn.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/z64ocarina.h b/include/z64ocarina.h index bcff0a3f2..cc1662fbd 100644 --- a/include/z64ocarina.h +++ b/include/z64ocarina.h @@ -81,7 +81,7 @@ typedef enum { /* 13 */ OCARINA_INSTRUMENT_PIANO, /* 14 */ OCARINA_INSTRUMENT_BASS_GUITAR, /* 15 */ OCARINA_INSTRUMENT_BABY_SINGING, - /* 16 */ OCARINA_INSTRUMENT_AMPLIFIED_GUITAR, // Related to (gSaveContext.weekEventReg[0x29] & 0x20) + /* 16 */ OCARINA_INSTRUMENT_AMPLIFIED_GUITAR, // Related to (gSaveContext.weekEventReg[41] & 0x20) } OcarinaInstrumentId; typedef enum { diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c index 9fbf4427d..7ec514801 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -1464,7 +1464,7 @@ void EnMaYto_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx); - if (this->type == MA_YTO_TYPE_BARN && (gSaveContext.weekEventReg[22] & 1)) { // Alieans defeated + if (this->type == MA_YTO_TYPE_BARN && (gSaveContext.weekEventReg[22] & 1)) { // Aliens defeated gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gCremiaWoodenBox); } diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.c b/src/overlays/actors/ovl_En_Osn/z_en_osn.c index 7914d0fed..fd0e8b6bc 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -370,11 +370,11 @@ s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { return 0x1FCD; } this->unk_1EA |= 8; - if (gSaveContext.weekEventReg[0x4C] & 0x20) { + if (gSaveContext.weekEventReg[76] & 0x20) { return 0x1FC8; } - gSaveContext.weekEventReg[0x4C] |= 0x20; + gSaveContext.weekEventReg[76] |= 0x20; return 0x1FCE; } @@ -388,10 +388,10 @@ s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { return 0x1FCD; } this->unk_1EA |= 0x10; - if (gSaveContext.weekEventReg[0x4C] & 0x40) { + if (gSaveContext.weekEventReg[76] & 0x40) { return 0x1FC8; } - gSaveContext.weekEventReg[0x4C] |= 0x40; + gSaveContext.weekEventReg[76] |= 0x40; return 0x1FD0; } From b9496691319640dfa8071a128263d26e9e8bce80 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 19 Feb 2022 23:05:22 +0000 Subject: [PATCH 043/257] Door_Shutter (#623) * Door_Shutter * PR * Fix macro * PR Co-authored-by: angie --- assets/xml/objects/object_bdoor.xml | 2 +- include/functions.h | 8 +- include/macros.h | 2 + spec | 3 +- src/code/z_room.c | 9 +- .../actors/ovl_Door_Shutter/z_door_shutter.c | 689 +++++++++++++++++- .../actors/ovl_Door_Shutter/z_door_shutter.h | 17 +- .../actors/ovl_Door_Spiral/z_door_spiral.c | 2 +- tools/disasm/functions.txt | 8 +- 9 files changed, 690 insertions(+), 50 deletions(-) diff --git a/assets/xml/objects/object_bdoor.xml b/assets/xml/objects/object_bdoor.xml index d74f4aa57..a57339f3b 100644 --- a/assets/xml/objects/object_bdoor.xml +++ b/assets/xml/objects/object_bdoor.xml @@ -3,7 +3,7 @@ - + diff --git a/include/functions.h b/include/functions.h index 45872f8e6..c12a4cc37 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1155,7 +1155,7 @@ void func_800DFD04(Camera* camera, s32 arg1, s32 arg2, s32 arg3); // UNK_TYPE4 func_800DFF44(void); s16 Camera_SetFlags(Camera* iParm1, s16 flags); s16 Camera_ClearFlags(Camera* camera, s16 flags); -// void func_800DFFAC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); +s32 func_800DFFAC(Camera* camera, Actor* doorActor, s16 bgCamDataId, f32 arg3, s16 timer1, s16 timer2, s16 timer3); // UNK_TYPE4 func_800E007C(Camera* param_1, Camera* param_2); // UNK_TYPE4 func_800E01AC(void); // void func_800E01B8(void); @@ -2008,7 +2008,7 @@ f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw); void Path_CopyLastPoint(Path* path, Vec3f* dest); void FrameAdvance_Init(FrameAdvanceContext* frameAdvCtx); s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, Input* input); -// void func_801226E0(void); +void func_801226E0(GlobalContext* globalCtx, s8 arg1); void func_80122744(GlobalContext* globalCtx, UNK_PTR arg1, u32 arg2, Vec3s* arg3); s32 func_80122760(GlobalContext* globalCtx, UNK_PTR arg1, f32 arg2); void func_80122868(GlobalContext* globalCtx, Player* player); @@ -2020,12 +2020,12 @@ void func_801229A0(GlobalContext* globalCtx, Player* player); // void func_80122D44(void); // void func_80122ED8(void); // void func_80122EEC(void); -void func_80122F28(Player* player, GlobalContext* globalCtx, Actor* actor); +void func_80122F28(Player* player); s32 func_80122F9C(GlobalContext* globalCtx); s32 func_80122FCC(GlobalContext* globalCtx); void func_8012300C(GlobalContext* globalCtx, s32 arg1); void func_8012301C(s32 iParm1, GlobalContext* globalCtx); -void func_80123140(GlobalContext* globalCtx, Player* param_2); +void func_80123140(GlobalContext* globalCtx, Player* player); u32 func_80123358(GlobalContext* globalCtx, Player* player); s32 Player_InCsMode(GameState* gameState); // void func_80123420(void); diff --git a/include/macros.h b/include/macros.h index 93923236e..081f6a487 100644 --- a/include/macros.h +++ b/include/macros.h @@ -74,6 +74,8 @@ #define CUR_FORM_EQUIP(button) (gSaveContext.equips.buttonItems[CUR_FORM][button]) #define CHECK_QUEST_ITEM(item) (((void)0, gSaveContext.inventory.questItems) & gBitFlags[item]) #define REMOVE_QUEST_ITEM(item) (gSaveContext.inventory.questItems = (((void)0, gSaveContext.inventory.questItems) & (-1 - gBitFlags[item]))) +#define CHECK_DUNGEON_ITEM(item, dungeonIndex) (gSaveContext.inventory.dungeonItems[(void)0, dungeonIndex] & gBitFlags[item]) +#define DUNGEON_KEY_COUNT(dungeonIndex) (gSaveContext.inventory.dungeonKeys[(void)0, dungeonIndex]) #define CAPACITY(upg, value) gUpgradeCapacities[upg][value] #define CUR_CAPACITY(upg) CAPACITY(upg, CUR_UPG_VALUE(upg)) diff --git a/spec b/spec index c27254528..cb2b988d7 100644 --- a/spec +++ b/spec @@ -929,8 +929,7 @@ beginseg name "ovl_Door_Shutter" compress include "build/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.o" - include "build/data/ovl_Door_Shutter/ovl_Door_Shutter.data.o" - include "build/data/ovl_Door_Shutter/ovl_Door_Shutter.reloc.o" + include "build/src/overlays/actors/ovl_Door_Shutter/ovl_Door_Shutter_reloc.o" endseg beginseg diff --git a/src/code/z_room.c b/src/code/z_room.c index 1685acc80..f54882fd6 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -75,12 +75,10 @@ void Room_Init(GlobalContext* globalCtx, RoomContext* roomCtx) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_room/Room_AllocateAndLoad.s") -#ifdef NON_MATCHING s32 Room_StartRoomTransition(GlobalContext* globalCtx, RoomContext* roomCtx, s32 index) { - size_t size; - - // XXX: this should use a branch-likely if (roomCtx->unk31 == 0) { + s32 size; + roomCtx->prevRoom = roomCtx->currRoom; roomCtx->currRoom.num = index; roomCtx->currRoom.segment = NULL; @@ -101,9 +99,6 @@ s32 Room_StartRoomTransition(GlobalContext* globalCtx, RoomContext* roomCtx, s32 return 0; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/Room_StartRoomTransition.s") -#endif s32 Room_HandleLoadCallbacks(GlobalContext* globalCtx, RoomContext* roomCtx) { if (roomCtx->unk31 == 1) { diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index 44b7d0bbd..630b90bdf 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -5,6 +5,18 @@ */ #include "z_door_shutter.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_bdoor/object_bdoor.h" +#include "objects/object_numa_obj/object_numa_obj.h" +#include "objects/object_hakugin_obj/object_hakugin_obj.h" +#include "objects/object_dblue_object/object_dblue_object.h" +#include "objects/object_ikana_obj/object_ikana_obj.h" +#include "objects/object_redead_obj/object_redead_obj.h" +#include "objects/object_ikninside_obj/object_ikninside_obj.h" +#include "objects/object_random_obj/object_random_obj.h" +#include "objects/object_kinsta1_obj/object_kinsta1_obj.h" +#include "objects/object_kaizoku_obj/object_kaizoku_obj.h" +#include "objects/object_last_obj/object_last_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -14,7 +26,18 @@ void DoorShutter_Init(Actor* thisx, GlobalContext* globalCtx); void DoorShutter_Destroy(Actor* thisx, GlobalContext* globalCtx); void DoorShutter_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void DoorShutter_SetupType(DoorShutter* this, GlobalContext* globalCtx); +void func_808A0F88(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1080(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1090(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1548(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1618(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1684(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1784(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1B48(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1C50(DoorShutter* this, GlobalContext* globalCtx); +void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Door_Shutter_InitVars = { ACTOR_DOOR_SHUTTER, ACTORCAT_DOOR, @@ -27,64 +50,670 @@ const ActorInit Door_Shutter_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808A2248[] = { +typedef struct { + /* 0x0 */ s16 objectId; + /* 0x2 */ u8 index1; + /* 0x3 */ u8 index2; +} ShutterObjectInfo; // size = 0x4 + +ShutterObjectInfo D_808A2180[] = { + { OBJECT_BDOOR, 0, 0 }, { GAMEPLAY_KEEP, 1, 1 }, { OBJECT_NUMA_OBJ, 2, 2 }, + { OBJECT_HAKUGIN_OBJ, 3, 3 }, { OBJECT_DBLUE_OBJECT, 4, 4 }, { OBJECT_IKANA_OBJ, 5, 5 }, + { OBJECT_REDEAD_OBJ, 6, 6 }, { OBJECT_IKNINSIDE_OBJ, 7, 7 }, { OBJECT_LAST_OBJ, 11, 11 }, + { OBJECT_RANDOM_OBJ, 8, 8 }, { OBJECT_KINSTA1_OBJ, 9, 9 }, { OBJECT_KAIZOKU_OBJ, 10, 10 }, +}; + +typedef struct { + /* 0x0 */ Gfx* unk_00; + /* 0x4 */ Gfx* unk_04; + /* 0x8 */ u8 unk_08; + /* 0x9 */ u8 translateZ; + /* 0xA */ u8 unk_0A; + /* 0xB */ u8 unk_0B; +} ShutterInfo; // size = 0xC + +ShutterInfo D_808A21B0[] = { + { object_bdoor_DL_0000C0, NULL, 130, 12, 50, 15 }, + { gameplay_keep_DL_077990, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_numa_obj_DL_007150, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_hakugin_obj_DL_000128, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_dblue_object_DL_017D00, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_ikana_obj_DL_014A40, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_redead_obj_DL_0001A0, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_ikninside_obj_DL_004440, object_ikninside_obj_DL_005260, 130, 0, 20, 15 }, + { object_random_obj_DL_000190, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_kinsta1_obj_DL_000198, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_kaizoku_obj_DL_0001A0, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_last_obj_DL_0039C0, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, +}; + +s8 D_808A2240[] = { + -1, -1, -1, -1, -1, 0, -1, -1, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F(scale, 1, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), }; -#endif +typedef struct { + /* 0x00 */ s16 sceneNum; + /* 0x02 */ u8 index; +} ShutterSceneInfo; // size = 0x4 -extern InitChainEntry D_808A2248[]; +ShutterSceneInfo D_808A2258[] = { + { SCENE_MITURIN, 2 }, { SCENE_HAKUGIN, 3 }, { SCENE_SEA, 4 }, + { SCENE_INISIE_N, 5 }, { SCENE_INISIE_R, 5 }, { SCENE_REDEAD, 6 }, + { SCENE_IKNINSIDE, 7 }, { SCENE_CASTLE, 7 }, { SCENE_RANDOM, 9 }, + { SCENE_KINSTA1, 10 }, { SCENE_KAIZOKU, 11 }, { SCENE_PIRATE, 11 }, + { SCENE_TORIDE, 11 }, { SCENE_LAST_DEKU, 8 }, { SCENE_LAST_GORON, 8 }, + { SCENE_LAST_ZORA, 8 }, { SCENE_LAST_LINK, 8 }, { -1, 1 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A08F0.s") +typedef struct { + /* 0x00 */ s16 dungeonScene; + /* 0x02 */ s16 bossScene; + /* 0x04 */ u8 index; +} BossDoorInfo; // size = 0x6 -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A0900.s") +BossDoorInfo D_808A22A0[] = { + { SCENE_MITURIN, SCENE_MITURIN_BS, 1 }, { SCENE_HAKUGIN, SCENE_HAKUGIN_BS, 2 }, { SCENE_SEA, SCENE_SEA_BS, 3 }, + { SCENE_INISIE_N, SCENE_INISIE_BS, 4 }, { SCENE_INISIE_R, SCENE_INISIE_BS, 4 }, { -1, -1, 0 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A0974.s") +Vec3f D_808A22C4 = { 120.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/DoorShutter_Init.s") +Vec3f D_808A22D0 = { -90.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/DoorShutter_Destroy.s") +TexturePtr D_808A22DC[] = { + object_bdoor_Tex_006BA0, object_bdoor_Tex_005BA0, object_bdoor_Tex_0005C0, + object_bdoor_Tex_004BA0, object_bdoor_Tex_003BA0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A0D0C.s") +void DoorShutter_SetupAction(DoorShutter* this, DoorShutterActionFunc actionFunc) { + this->actionFunc = actionFunc; + this->unk_167 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A0D90.s") +s32 func_808A0900(DoorShutter* this, GlobalContext* globalCtx) { + TransitionActorEntry* transitionEntry = &globalCtx->doorCtx.transitionActorList[DOORSHUTTER_GET_FC00(&this->actor)]; + s8 frontRoom = transitionEntry->sides[0].room; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A0E28.s") + if (frontRoom == transitionEntry->sides[1].room) { + if (ABS_ALT(BINANG_SUB(this->actor.shape.rot.y, this->actor.yawTowardsPlayer)) < 0x4000) { + frontRoom = -1; + } + } + return frontRoom == this->actor.room; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A0F88.s") +s32 DoorShutter_SetupDoor(DoorShutter* this, GlobalContext* globalCtx) { + ShutterObjectInfo* sp24 = &D_808A2180[this->unk_163]; + s32 doorType = this->doorType; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1080.s") + if (doorType != 4) { + if (func_808A0900(this, globalCtx)) { + if ((doorType == 7) || (doorType == 6)) { + doorType = 1; + } else if (doorType == 5) { + doorType = 3; + } else { + doorType = 0; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1090.s") + if (doorType == 0) { + this->unk_164 = sp24->index1; + } else { + this->unk_164 = sp24->index2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1288.s") + if (doorType == 1) { + if (!Flags_GetClear(globalCtx, this->actor.room)) { + DoorShutter_SetupAction(this, func_808A0F88); + this->unk_168 = 1.0f; + return true; + } + } else if ((doorType == 2) || (doorType == 7)) { + if (!Flags_GetSwitch(globalCtx, DOORSHUTTER_GET_7F(&this->actor))) { + DoorShutter_SetupAction(this, func_808A1548); + this->unk_168 = 1.0f; + return true; + } + DoorShutter_SetupAction(this, func_808A1618); + return false; + } else if (doorType == 3) { + DoorShutter_SetupAction(this, func_808A1080); + this->unk_168 = 1.0f; + return false; + } + DoorShutter_SetupAction(this, func_808A1090); + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1340.s") +void DoorShutter_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + DoorShutter* this = THIS; + s32 sp24; + s32 i; + s8 objId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1478.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->doorType = DOORSHUTTER_GET_380(&this->actor); + sp24 = D_808A2240[this->doorType]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1548.s") + if (sp24 < 0) { + ShutterSceneInfo* shutterSceneInfo = &D_808A2258[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1618.s") + for (i = 0; i < ARRAY_COUNT(D_808A2258) - 1; i++, shutterSceneInfo++) { + if (globalCtx->sceneNum == shutterSceneInfo->sceneNum) { + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1684.s") + sp24 = shutterSceneInfo->index; + if (sp24 == 6) { + this->actor.flags |= ACTOR_FLAG_10000000; + } + } else if (sp24 == 0) { + BossDoorInfo* bossDoorInfo = &D_808A22A0[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1784.s") + for (i = 0; i < ARRAY_COUNT(D_808A22A0) - 1; i++, bossDoorInfo++) { + if ((globalCtx->sceneNum == bossDoorInfo->dungeonScene) || + (globalCtx->sceneNum == bossDoorInfo->bossScene)) { + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1884.s") + this->unk_15E = bossDoorInfo->index; + } else { + this->actor.room = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1A70.s") + // clang-format off + objId = Object_GetIndex(&globalCtx->objectCtx, D_808A2180[sp24].objectId); this->requiredObjBankIndex = objId; if (objId < 0) { Actor_MarkForDeath(&this->actor); return; } + // clang-format on -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1B48.s") + DoorShutter_SetupAction(this, DoorShutter_SetupType); + this->unk_163 = sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1C50.s") + if ((this->doorType == 4) || (this->doorType == 5)) { + if (!Flags_GetSwitch(globalCtx, DOORSHUTTER_GET_7F(&this->actor))) { + this->unk_166 = 10; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/DoorShutter_Update.s") + Actor_SetFocus(&this->actor, 60.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1D68.s") +void DoorShutter_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DoorShutter* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1E14.s") + if (this->actor.room >= 0) { + s32 transitionActorId = DOORSHUTTER_GET_FC00(&this->actor); + + globalCtx->doorCtx.transitionActorList[transitionActorId].id = + -globalCtx->doorCtx.transitionActorList[transitionActorId].id; + } +} + +void DoorShutter_SetupType(DoorShutter* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->requiredObjBankIndex) && ((MREG(64) == 0) || (MREG(68) == 0))) { + this->actor.objBankIndex = this->requiredObjBankIndex; + this->actor.draw = DoorShutter_Draw; + DoorShutter_SetupDoor(this, globalCtx); + } +} + +f32 func_808A0D90(GlobalContext* globalCtx, DoorShutter* this, f32 arg2, f32 arg3, f32 arg4) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp28; + Vec3f sp1C; + + sp28.x = player->actor.world.pos.x; + sp28.y = player->actor.world.pos.y + arg2; + sp28.z = player->actor.world.pos.z; + + Actor_OffsetOfPointInActorCoords(&this->actor, &sp1C, &sp28); + + if ((arg3 < fabsf(sp1C.x)) || (arg4 < fabsf(sp1C.y))) { + return FLT_MAX; + } + return sp1C.z; +} + +s32 func_808A0E28(DoorShutter* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (!Player_InCsMode(&globalCtx->state)) { + ShutterInfo* shutterInfo = &D_808A21B0[this->unk_164]; + f32 temp_f0 = func_808A0D90(globalCtx, this, 0.0f, shutterInfo->unk_0A, shutterInfo->unk_0B); + + if (fabsf(temp_f0) < 50.0f) { + s16 temp_v0_2 = BINANG_SUB(player->actor.shape.rot.y, this->actor.shape.rot.y); + + if (temp_f0 > 0.0f) { + temp_v0_2 = 0x8000 - temp_v0_2; + } + + if (ABS_ALT(temp_v0_2) < 0x3000) { + return (temp_f0 >= 0.0f) ? 1.0f : -1.0f; + } + } + } + return false; +} + +void func_808A0F88(DoorShutter* this, GlobalContext* globalCtx) { + if (Flags_GetClear(globalCtx, this->actor.room) || Flags_GetClearTemp(globalCtx, this->actor.room)) { + this->unk_160 = this->actor.cutscene; + if (this->doorType == 7) { + if (this->unk_160 != -1) { + this->unk_160 = ActorCutscene_GetAdditionalCutscene(this->unk_160); + } + } + + if (ActorCutscene_GetCanPlayNext(this->unk_160)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_160, &this->actor); + Flags_SetClear(globalCtx, this->actor.room); + DoorShutter_SetupAction(this, func_808A1784); + this->unk_167 = -1; + } else { + ActorCutscene_SetIntentToPlay(this->unk_160); + } + } else if (func_808A0E28(this, globalCtx)) { + Player* player = GET_PLAYER(globalCtx); + + player->doorType = -1; + player->doorActor = &this->actor; + this->actor.textId = 0x1801; + func_80122F28(player); + } +} + +void func_808A1080(DoorShutter* this, GlobalContext* globalCtx) { +} + +void func_808A1090(DoorShutter* this, GlobalContext* globalCtx) { + if (this->unk_15C != 0) { + DoorShutter_SetupAction(this, func_808A1684); + this->actor.velocity.y = 0.0f; + if (this->unk_166 != 0) { + Flags_SetSwitch(globalCtx, DOORSHUTTER_GET_7F(&this->actor)); + if (this->doorType != 5) { + gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex]--; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK_B); + } + } + } else { + s32 doorDirection = func_808A0E28(this, globalCtx); + + if (doorDirection != 0) { + Player* player = GET_PLAYER(globalCtx); + + player->doorType = 2; + player->doorDirection = doorDirection; + player->doorActor = &this->actor; + + if (this->unk_163 == 7) { + player->doorTimer = 12; + } else { + player->doorTimer = 0; + } + + if (this->doorType == 6) { + if (gSaveContext.healthCapacity < (DOORSHUTTER_GET_1F(&this->actor) * 0x10)) { + player->doorType = -1; + this->actor.textId = 0x14FC; + } + } else if (this->unk_166 != 0) { + if (this->doorType == 5) { + if (!CHECK_DUNGEON_ITEM(0, gSaveContext.mapIndex)) { + player->doorType = -1; + this->actor.textId = 0x1803; + } + player->doorTimer += 10; + } else if (DUNGEON_KEY_COUNT(gSaveContext.mapIndex) <= 0) { + player->doorType = -1; + this->actor.textId = 0x1802; + } else { + player->doorTimer += 10; + } + } + func_80122F28(player); + } + } +} + +void func_808A1288(DoorShutter* this, GlobalContext* globalCtx) { + if (this->actor.category == ACTORCAT_DOOR) { + Player* player = GET_PLAYER(globalCtx); + s32 sp38 = this->unk_164; + s32 sp34 = 0xF; + + if (DoorShutter_SetupDoor(this, globalCtx)) { + sp34 = 0x20; + } + + DoorShutter_SetupAction(this, func_808A1684); + + this->unk_164 = sp38; + this->unk_168 = 0.0f; + + func_800DFFAC(globalCtx->cameraPtrs[MAIN_CAM], &this->actor, player->unk_3BA, this->unk_168, 12, sp34, 10); + } +} + +s32 func_808A1340(DoorShutter* this, GlobalContext* globalCtx) { + Vec3f sp2C; + + if (this->actor.velocity.y == 0.0f) { + func_808A1288(this, globalCtx); + if (this->unk_163 != 7) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SLIDE_DOOR_OPEN); + } + } + + if (this->unk_163 == 7) { + s32 pad; + + if (this->unk_163 == 7) { + func_800B9010(&this->actor, NA_SE_EV_IKANA_DOOR_OPEN - SFX_FLAG); + } + + Lib_Vec3f_TranslateAndRotateY(&this->actor.home.pos, this->actor.shape.rot.y, + (this->unk_163 == 7) ? &D_808A22C4 : &D_808A22D0, &sp2C); + Math_StepToF(&this->actor.velocity.y, 5.0f, 0.5f); + + if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &sp2C, this->actor.velocity.y) == 0.0f) { + return true; + } + } else { + Math_StepToF(&this->actor.velocity.y, 15.0f, 3.0f); + + if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 200.0f, this->actor.velocity.y)) { + return true; + } + } + return false; +} + +s32 func_808A1478(DoorShutter* this, GlobalContext* globalCtx, f32 arg2) { + f32 temp = 1.0f - arg2; + + if (temp == this->unk_168) { + if (arg2 == 1.0f) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_METALDOOR_CLOSE); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_METALDOOR_OPEN); + } + + if ((this->unk_160 != -1) && (ActorCutscene_GetCurrentIndex() == this->unk_160)) { + func_800B724C(globalCtx, &this->actor, 1); + } + } + + if (Math_StepToF(&this->unk_168, arg2, 0.2f)) { + return true; + } + return false; +} + +void func_808A1548(DoorShutter* this, GlobalContext* globalCtx) { + if (func_808A1478(this, globalCtx, 1.0f)) { + if (Flags_GetSwitch(globalCtx, DOORSHUTTER_GET_7F(&this->actor))) { + this->unk_160 = this->actor.cutscene; + if (ActorCutscene_GetCanPlayNext(this->unk_160)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_160, &this->actor); + DoorShutter_SetupAction(this, func_808A1784); + this->unk_167 = -1; + } else { + ActorCutscene_SetIntentToPlay(this->unk_160); + } + } else if (func_808A0E28(this, globalCtx)) { + Player* player = GET_PLAYER(globalCtx); + + player->doorType = -1; + player->doorActor = &this->actor; + this->actor.textId = 0x1800; + func_80122F28(player); + } + } +} + +void func_808A1618(DoorShutter* this, GlobalContext* globalCtx) { + if ((this->unk_15C == 0) && !Flags_GetSwitch(globalCtx, DOORSHUTTER_GET_7F(&this->actor))) { + DoorShutter_SetupAction(this, func_808A1548); + } else { + func_808A1090(this, globalCtx); + } +} + +void func_808A1684(DoorShutter* this, GlobalContext* globalCtx) { + f32 phi_f0; + + if ((DECR(this->unk_166) == 0) && (globalCtx->roomCtx.unk31 == 0) && func_808A1340(this, globalCtx)) { + if (this->doorType == 5) { + phi_f0 = 20.0f; + } else { + phi_f0 = 50.0f; + } + + if (phi_f0 < this->actor.xzDistToPlayer) { + if (this->unk_163 == 7) { + this->actor.velocity.y = 0.0f; + } else { + if (DoorShutter_SetupDoor(this, globalCtx)) { + this->actor.velocity.y = 30.0f; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + } + DoorShutter_SetupAction(this, func_808A1B48); + } + } +} + +void func_808A1784(DoorShutter* this, GlobalContext* globalCtx) { + if (this->unk_167 != 0) { + if (func_800F22C4(this->unk_160, &this->actor)) { + if (this->unk_167 < 0) { + if ((globalCtx->state.frames % 2) != 0) { + this->unk_167++; + } + } else { + this->unk_167--; + } + } + } else if (func_808A1478(this, globalCtx, 0.0f)) { + u8 doorType = this->doorType; + + if ((doorType != 0) && (doorType != 1) && + (((doorType != 7) && (doorType != 6)) || !func_808A0900(this, globalCtx))) { + DoorShutter_SetupAction(this, func_808A1618); + } else { + DoorShutter_SetupAction(this, func_808A1090); + } + func_801A2ED8(); + } +} + +void func_808A1884(DoorShutter* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s8 room = this->actor.room; + Vec3f sp44; + + if (this->actor.room >= 0) { + Actor_OffsetOfPointInActorCoords(&this->actor, &sp44, &player->actor.world.pos); + + this->actor.room = globalCtx->doorCtx.transitionActorList[DOORSHUTTER_GET_FC00(&this->actor)] + .sides[(sp44.z < 0.0f) ? 0 : 1] + .room; + + if (room != this->actor.room) { + Room temp = globalCtx->roomCtx.currRoom; + + globalCtx->roomCtx.currRoom = globalCtx->roomCtx.prevRoom; + globalCtx->roomCtx.prevRoom = temp; + globalCtx->roomCtx.activeMemPage ^= 1; + } + func_8012EBF8(globalCtx, &globalCtx->roomCtx); + } + + this->unk_15C = 0; + this->actor.velocity.y = 0.0f; + + if (DoorShutter_SetupDoor(this, globalCtx) && !(player->stateFlags1 & 0x800)) { + DoorShutter_SetupAction(this, func_808A1C50); + if (ActorCutscene_GetCurrentIndex() == 0x7D) { + s8 data = gSaveContext.respawn[0].data; + + func_801226E0(globalCtx, data); + player->unk_A86 = -1; + func_800B7298(globalCtx, NULL, 0x73); + } + } +} + +s32 func_808A1A70(DoorShutter* this) { + if (this->unk_163 == 7) { + if (this->unk_163 == 7) { + func_800B9010(&this->actor, NA_SE_EV_IKANA_DOOR_CLOSE - SFX_FLAG); + } + + Math_StepToF(&this->actor.velocity.y, 5.0f, 0.5f); + + if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->actor.home.pos, this->actor.velocity.y) == 0.0f) { + return true; + } + } else { + if (this->actor.velocity.y < 20.0f) { + Math_StepToF(&this->actor.velocity.y, 20.0f, 8.0f); + } + + if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, this->actor.velocity.y)) { + return true; + } + } + return false; +} + +void func_808A1B48(DoorShutter* this, GlobalContext* globalCtx) { + s16 quake; + + if (func_808A1A70(this)) { + if (this->actor.velocity.y > 20.0f) { + this->actor.floorHeight = this->actor.home.pos.y; + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 45.0f, 10, 8.0f, 500, 10, 0); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BIGWALL_BOUND); + quake = Quake_Add(Play_GetCamera(globalCtx, 0), 3); + Quake_SetSpeed(quake, -32536); + Quake_SetQuakeValues(quake, 2, 0, 0, 0); + Quake_SetCountdown(quake, 10); + func_8013ECE0(this->actor.xyzDistToPlayerSq, 180, 20, 100); + func_808A1884(this, globalCtx); + } +} + +void func_808A1C50(DoorShutter* this, GlobalContext* globalCtx) { + if (this->unk_167++ > 30) { + if (GET_PLAYER(globalCtx)->csMode == 0x73) { + func_800B7298(globalCtx, NULL, 6); + } + DoorShutter_SetupDoor(this, globalCtx); + } +} + +void DoorShutter_Update(Actor* thisx, GlobalContext* globalCtx) { + DoorShutter* this = THIS; + Player* player = GET_PLAYER(globalCtx); + + if (!(player->stateFlags1 & 0x100004C0) || (this->actionFunc == DoorShutter_SetupType)) { + this->actionFunc(this, globalCtx); + + if (this->unk_163 == 7) { + this->actor.home.rot.z = Math_Vec3f_DistXZ(&this->actor.home.pos, &this->actor.world.pos) * -100.0f; + } + } +} + +s32 func_808A1D68(DoorShutter* this, GlobalContext* globalCtx) { + s32 temp_a0; + s32 temp_a1; + + if (Player_InCsMode(&globalCtx->state)) { + return true; + } + + temp_a0 = BINANG_SUB(Actor_YawToPoint(&this->actor, &globalCtx->view.eye), this->actor.shape.rot.y); + temp_a1 = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); + + temp_a0 = ABS_ALT(temp_a0); + temp_a1 = ABS_ALT(temp_a1); + + if (((temp_a1 < 0x4000) && (temp_a0 > 0x4000)) || ((temp_a1 > 0x4000) && (temp_a0 < 0x4000))) { + return false; + } + return true; +} + +void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DoorShutter* this = THIS; + ShutterInfo* sp44; + + if (func_808A1D68(this, globalCtx)) { + sp44 = &D_808A21B0[this->unk_164]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_164 == 7) { + Matrix_InsertTranslation(0.0f, 64.96f, 0.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.home.rot.z, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -64.96f, 0.0f, MTXMODE_APPLY); + } + + if (sp44->unk_04 != 0) { + TransitionActorEntry* transitionEntry = + &globalCtx->doorCtx.transitionActorList[DOORSHUTTER_GET_FC00(&this->actor)]; + + if ((globalCtx->roomCtx.prevRoom.num >= 0) || + (transitionEntry->sides[0].room == transitionEntry->sides[1].room)) { + s16 yaw = this->actor.shape.rot.y - Math_Vec3f_Yaw(&globalCtx->view.eye, &this->actor.world.pos); + + if (ABS_ALT(yaw) < 0x4000) { + Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + } + } else if (this->actor.room == transitionEntry->sides[0].room) { + Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + } + } else if (this->doorType == 5) { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_808A22DC[this->unk_15E])); + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sp44->unk_00); + + if ((this->unk_168 != 0.0f) && (sp44->unk_04 != 0)) { + Matrix_InsertTranslation(0.0f, sp44->unk_08 * (1.0f - this->unk_168), sp44->translateZ, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sp44->unk_04); + } + + if (this->unk_166 != 0) { + Matrix_Scale(0.01f, 0.01f, 0.025f, MTXMODE_APPLY); + Actor_DrawDoorLock(globalCtx, this->unk_166, (this->doorType == 5) ? DOORLOCK_BOSS : DOORLOCK_NORMAL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h index e9da6684b..0b796d442 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h @@ -7,9 +7,24 @@ struct DoorShutter; typedef void (*DoorShutterActionFunc)(struct DoorShutter*, GlobalContext*); +#define DOORSHUTTER_GET_1F(thisx) ((thisx)->params & 0x1F) +#define DOORSHUTTER_GET_7F(thisx) ((thisx)->params & 0x7F) +#define DOORSHUTTER_GET_380(thisx) (((thisx)->params >> 7) & 7) +#define DOORSHUTTER_GET_FC00(thisx) (((u16)(thisx)->params >> 0xA)) + typedef struct DoorShutter { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x28]; + /* 0x0144 */ UNK_TYPE1 unk144[0x18]; + /* 0x015C */ s16 unk_15C; + /* 0x015E */ s16 unk_15E; + /* 0x0160 */ s16 unk_160; + /* 0x0162 */ u8 doorType; + /* 0x0163 */ u8 unk_163; + /* 0x0164 */ u8 unk_164; + /* 0x0165 */ s8 requiredObjBankIndex; + /* 0x0166 */ s8 unk_166; + /* 0x0167 */ s8 unk_167; + /* 0x0168 */ f32 unk_168; /* 0x016C */ DoorShutterActionFunc actionFunc; } DoorShutter; // size = 0x170 diff --git a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c index 5f0dbc6b0..a2bc8a0be 100644 --- a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c +++ b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c @@ -286,7 +286,7 @@ void DoorSpiral_Wait(DoorSpiral* this, GlobalContext* globalCtx) { transition = GET_TRANSITION_ID_PARAM(this); player->doorNext = ((u16)globalCtx->doorCtx.transitionActorList[transition].params) >> 10; - func_80122F28(player, globalCtx, &this->actor); + func_80122F28(player); } } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index fcbc1b9c9..35fa705d9 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -5642,12 +5642,12 @@ 0x808A03E8:("func_808A03E8",), 0x808A0458:("EnBubble_Update",), 0x808A04D4:("EnBubble_Draw",), - 0x808A08F0:("func_808A08F0",), + 0x808A08F0:("DoorShutter_SetupAction",), 0x808A0900:("func_808A0900",), - 0x808A0974:("func_808A0974",), + 0x808A0974:("DoorShutter_SetupDoor",), 0x808A0B10:("DoorShutter_Init",), 0x808A0CD0:("DoorShutter_Destroy",), - 0x808A0D0C:("func_808A0D0C",), + 0x808A0D0C:("DoorShutter_SetupType",), 0x808A0D90:("func_808A0D90",), 0x808A0E28:("func_808A0E28",), 0x808A0F88:("func_808A0F88",), @@ -5666,7 +5666,7 @@ 0x808A1C50:("func_808A1C50",), 0x808A1CC4:("DoorShutter_Update",), 0x808A1D68:("func_808A1D68",), - 0x808A1E14:("func_808A1E14",), + 0x808A1E14:("DoorShutter_Draw",), 0x808A24D0:("EnBoom_SetupAction",), 0x808A24DC:("func_808A24DC",), 0x808A2700:("EnBoom_Init",), From f67ecbc3c222197cfdd9e63e8cc78506db06f0d4 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 19 Feb 2022 15:27:15 -0800 Subject: [PATCH 044/257] EnBba01 Ok and Documented (#667) * Decomp Bba_01 * Doc bba01 * Document object_bba * Remove new line * Cleanup/rename EnHy to help differentiate it from overlays * Adjust xml comment * PR suggestions * English is hard * English is hard 2 * Add note about invalid textIds * typo * Fix merge * Remove 0 defines --- assets/xml/objects/object_bba.xml | 130 ++++--- assets/xml/objects/object_cne.xml | 2 +- include/{z_en_hy.h => z_en_hy_code.h} | 12 +- spec | 5 +- src/code/{z_en_hy.c => z_en_hy_code.c} | 4 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 16 +- .../actors/ovl_En_Bba_01/z_en_bba_01.c | 347 ++++++++++++++---- .../actors/ovl_En_Bba_01/z_en_bba_01.h | 10 +- .../actors/ovl_En_Cne_01/z_en_cne_01.c | 80 ++-- .../actors/ovl_En_Cne_01/z_en_cne_01.h | 2 +- src/overlays/actors/ovl_En_Zo/z_en_zo.c | 66 ++-- tools/disasm/functions.txt | 20 +- undefined_syms.txt | 4 - 13 files changed, 469 insertions(+), 229 deletions(-) rename include/{z_en_hy.h => z_en_hy_code.h} (90%) rename src/code/{z_en_hy.c => z_en_hy_code.c} (99%) diff --git a/assets/xml/objects/object_bba.xml b/assets/xml/objects/object_bba.xml index b172e9f77..144c685e4 100644 --- a/assets/xml/objects/object_bba.xml +++ b/assets/xml/objects/object_bba.xml @@ -1,56 +1,82 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_cne.xml b/assets/xml/objects/object_cne.xml index acddaee86..fccbf539f 100644 --- a/assets/xml/objects/object_cne.xml +++ b/assets/xml/objects/object_cne.xml @@ -24,7 +24,7 @@ - + diff --git a/include/z_en_hy.h b/include/z_en_hy_code.h similarity index 90% rename from include/z_en_hy.h rename to include/z_en_hy_code.h index df94df171..997a41233 100644 --- a/include/z_en_hy.h +++ b/include/z_en_hy_code.h @@ -1,12 +1,14 @@ -#ifndef Z_EN_HY_H -#define Z_EN_HY_H +#ifndef Z_EN_HY_CODE_H +#define Z_EN_HY_CODE_H #include "global.h" +#include "overlays/actors/ovl_En_Door/z_en_door.h" struct EnHy; #define ENHY_LIMB_MAX 16 +//! TODO: Better animaion enum names when animations are documented typedef enum { /* 0 */ ENHY_ANIMATION_AOB_0, /* 1 */ ENHY_ANIMATION_BOJ_1, @@ -74,12 +76,12 @@ extern s8 gEnHyBodyPartsIndex[]; extern u8 gEnHyShadowSize[]; s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex); -struct EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx); +EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx); void EnHy_ChangeObjectAndAnim(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex); s32 EnHy_UpdateSkelAnime(EnHy* enHy, GlobalContext* globalCtx); void EnHy_Blink(EnHy* enHy, s32 arg1); s32 EnHy_Init(EnHy* enHy, GlobalContext* globalCtx, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex); -void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, struct EnDoor* door, s16 arg3, s16 arg4); +void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, EnDoor* door, s16 arg3, s16 arg4); s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5); s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3); s32 EnHy_SetPointFowards(EnHy* enHy, GlobalContext* globalCtx, f32 gravity, s16 animIndex); @@ -89,4 +91,4 @@ s32 EnHy_MoveBackwards(EnHy* enHy, f32 speedTarget); void EnHy_UpdateCollider(EnHy* enHy, GlobalContext* globalCtx); s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThreshold); -#endif // Z_EN_HY_H +#endif // Z_EN_HY_CODE_H diff --git a/spec b/spec index cb2b988d7..12c9d6e3c 100644 --- a/spec +++ b/spec @@ -467,7 +467,7 @@ beginseg include "build/data/code/z_eff_footmark.data.o" include "build/src/code/z_sound_source.o" include "build/src/code/z_elf_message.o" - include "build/src/code/z_en_hy.o" + include "build/src/code/z_en_hy_code.o" include "build/src/code/z_face_reaction.o" include "build/src/code/z_env_flags.o" include "build/src/code/z_eventmgr.o" @@ -2477,8 +2477,7 @@ beginseg name "ovl_En_Bba_01" compress include "build/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.o" - include "build/data/ovl_En_Bba_01/ovl_En_Bba_01.data.o" - include "build/data/ovl_En_Bba_01/ovl_En_Bba_01.reloc.o" + include "build/src/overlays/actors/ovl_En_Bba_01/ovl_En_Bba_01_reloc.o" endseg beginseg diff --git a/src/code/z_en_hy.c b/src/code/z_en_hy_code.c similarity index 99% rename from src/code/z_en_hy.c rename to src/code/z_en_hy_code.c index b99b77dae..7b17f78f2 100644 --- a/src/code/z_en_hy.c +++ b/src/code/z_en_hy_code.c @@ -3,7 +3,7 @@ * Description: Unused System for NPCs (includes animation, door interaction, blinking, pathing, and collider helpers) */ -#include "z_en_hy.h" +#include "z_en_hy_code.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/object_aob/object_aob.h" #include "objects/object_bba/object_bba.h" @@ -18,7 +18,7 @@ static AnimationInfoS sAnimations[] = { { &object_boj_Anim_001908, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_boj_Anim_001908, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, { &object_boj_Anim_0008C0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_bba_Anim_005DC4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gBbaIdleHoldingBagAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_bji_Anim_000FDC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_bji_Anim_000AB0, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, { &object_bji_Anim_00066C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index 96864a395..149bd29ae 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -42,12 +42,12 @@ const ActorInit En_Baba_InitVars = { }; static AnimationInfo sAnimations[] = { - { &object_bba_Anim_005DC4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_bba_Anim_006550, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_bba_Anim_006B10, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_bba_Anim_005154, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &object_bba_Anim_0058B8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_bba_Anim_004910, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gBbaIdleHoldingBagAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gBbaIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gBbaWalkingHoldingBagAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gBbaKnockedOverAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gBbaLyingDownAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gBbaWalkingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -429,7 +429,7 @@ void func_80BA93AC(EnBaba* this, GlobalContext* globalCtx) { } void func_80BA9480(EnBaba* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_bba_Skel_005EF0, &object_bba_Anim_006B10, this->jointTable, + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBbaSkel, &gBbaWalkingHoldingBagAnim, this->jointTable, this->morphTable, 0x12); this->actor.draw = EnBaba_Draw; @@ -741,7 +741,7 @@ void EnBaba_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C5B0(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(&object_bba_Tex_0092A0)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gBbaEyeTex)); SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnBaba_OverrideLimbDraw, EnBaba_PostLimbDraw, diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index 963290504..5df543b06 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -2,9 +2,18 @@ * File: z_en_bba_01.c * Overlay: ovl_En_Bba_01 * Description: Unused Bomb Shop Lady NPC + * + * Note: This actor was probably written with OOT's object_bba's skeleton in mind, and so this actor is very bugged. + * + * The main offender is that gBbaSkel has 18 limbs, while the system used (EnHy) expects 16 (see @bug in FinishInit + * below). + * + * The draw functions also use different limbs than expected, which results in, for example, EnBba01's right arm and bag + * following the player instead of her head and torso. */ #include "z_en_bba_01.h" +#include "objects/object_bba/object_bba.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) @@ -15,12 +24,10 @@ void EnBba01_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBba01_Update(Actor* thisx, GlobalContext* globalCtx); void EnBba01_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809CC2F0(EnBba01* this, GlobalContext* globalCtx); -void func_809CC370(EnBba01* this, GlobalContext* globalCtx); -void func_809CC3A8(EnBba01* this, GlobalContext* globalCtx); -void func_809CC3CC(EnBba01* this, GlobalContext* globalCtx); +void EnBba01_Walk(EnHy* this, GlobalContext* globalCtx); +void EnBba01_FaceFoward(EnHy* this, GlobalContext* globalCtx); +void EnBba01_Talk(EnHy* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Bba_01_InitVars = { ACTOR_EN_BBA_01, ACTORCAT_NPC, @@ -33,84 +40,296 @@ const ActorInit En_Bba_01_InitVars = { (ActorFunc)EnBba01_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809CCC80 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 64, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_809CCCAC = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_809CCCB8 = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(0, 0x0), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(0, 0x0), - /* Zora boomerang */ DMG_ENTRY(0, 0x0), - /* Normal arrow */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x0), - /* Goron punch */ DMG_ENTRY(0, 0x0), - /* Sword */ DMG_ENTRY(0, 0x0), - /* Goron pound */ DMG_ENTRY(0, 0x0), - /* Fire arrow */ DMG_ENTRY(0, 0x0), - /* Ice arrow */ DMG_ENTRY(0, 0x0), - /* Light arrow */ DMG_ENTRY(0, 0x0), - /* Goron spikes */ DMG_ENTRY(0, 0x0), - /* Deku spin */ DMG_ENTRY(0, 0x0), - /* Deku bubble */ DMG_ENTRY(0, 0x0), - /* Deku launch */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(0, 0x0), - /* Zora punch */ DMG_ENTRY(0, 0x0), - /* Spin attack */ DMG_ENTRY(0, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(0, 0x0), +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, 0), + /* Deku Stick */ DMG_ENTRY(0, 0), + /* Horse trample */ DMG_ENTRY(0, 0), + /* Explosives */ DMG_ENTRY(0, 0), + /* Zora boomerang */ DMG_ENTRY(0, 0), + /* Normal arrow */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0), + /* Hookshot */ DMG_ENTRY(0, 0), + /* Goron punch */ DMG_ENTRY(0, 0), + /* Sword */ DMG_ENTRY(0, 0), + /* Goron pound */ DMG_ENTRY(0, 0), + /* Fire arrow */ DMG_ENTRY(0, 0), + /* Ice arrow */ DMG_ENTRY(0, 0), + /* Light arrow */ DMG_ENTRY(0, 0), + /* Goron spikes */ DMG_ENTRY(0, 0), + /* Deku spin */ DMG_ENTRY(0, 0), + /* Deku bubble */ DMG_ENTRY(0, 0), + /* Deku launch */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0), + /* Zora barrier */ DMG_ENTRY(0, 0), + /* Normal shield */ DMG_ENTRY(0, 0), + /* Light ray */ DMG_ENTRY(0, 0), + /* Thrown object */ DMG_ENTRY(0, 0), + /* Zora punch */ DMG_ENTRY(0, 0), + /* Spin attack */ DMG_ENTRY(0, 0), + /* Sword beam */ DMG_ENTRY(0, 0), + /* Normal Roll */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0), + /* Unblockable */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0), + /* Powder Keg */ DMG_ENTRY(0, 0), }; -#endif +u16 D_809CCCD8[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; -extern ColliderCylinderInit D_809CCC80; -extern CollisionCheckInfoInit2 D_809CCCAC; -extern DamageTable D_809CCCB8; +void EnBba01_UpdateModel(EnBba01* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f focus; -extern UNK_TYPE D_06005EF0; + EnHy_UpdateSkelAnime(&this->enHy, globalCtx); + if (func_8013D5E8(this->enHy.actor.shape.rot.y, 0x36B0, this->enHy.actor.yawTowardsPlayer)) { + focus.x = player->actor.world.pos.x; + focus.y = player->bodyPartsPos[7].y + 3.0f; + focus.z = player->actor.world.pos.z; + func_8013D2E0(&focus, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.focusTarget, + &this->enHy.headRot, &this->enHy.torsoRot, D_809CCCD8); + } else { + Math_SmoothStepToS(&this->enHy.focusTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.focusTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.headRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.headRot.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.torsoRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.torsoRot.y, 0, 4, 0x3E8, 1); + } + SubS_FillLimbRotTables(globalCtx, this->enHy.limbRotTableY, this->enHy.limbRotTableZ, + ARRAY_COUNT(this->enHy.limbRotTableY)); + EnHy_UpdateCollider(&this->enHy, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC060.s") +s32 EnBba01_TestIsTalking(EnBba01* this, GlobalContext* globalCtx) { + s32 isTalking = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC1D4.s") + if (Actor_ProcessTalkRequest(&this->enHy.actor, &globalCtx->state)) { + isTalking = true; + this->enHy.textId = 0x10B9; // Invalid textId, produces empty textbox + this->enHy.tmpFocusTarget = this->enHy.focusTarget; + this->enHy.tmpHeadRot = this->enHy.headRot; + this->enHy.tmpTorsoRot = this->enHy.torsoRot; + this->enHy.tmpActionFunc = this->enHy.actionFunc; + this->enHy.actionFunc = EnBba01_Talk; + } + return isTalking; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC270.s") +s32 func_809CC270(EnBba01* this, GlobalContext* globalCtx) { + s16 x; + s16 y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC2F0.s") + Actor_GetScreenPos(globalCtx, &this->enHy.actor, &x, &y); + //! @bug: Both x and y conditionals are always true, || should be an && + if (!this->enHy.waitingOnInit && ((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT))) { + func_800B85E0(&this->enHy.actor, globalCtx, 30.0f, EXCH_ITEM_2E); + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC370.s") +void EnBba01_FinishInit(EnHy* this, GlobalContext* globalCtx) { + //! @bug: gBbaSkel does not match EnHy's skeleton assumptions. + //! Since gBbaSkel has more limbs than expected, joint and morph tables will overflow + if (EnHy_Init(this, globalCtx, &gBbaSkel, ENHY_ANIMATION_BBA_6)) { + this->actor.flags |= ACTOR_FLAG_1; + this->actor.draw = EnBba01_Draw; + this->waitingOnInit = false; + if (ENBBA01_GET_PATH(&this->actor) == ENBBA01_NO_PATH) { + this->actionFunc = EnBba01_FaceFoward; + } else { + this->actionFunc = EnBba01_Walk; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC3A8.s") +void EnBba01_Walk(EnHy* this, GlobalContext* globalCtx) { + if (EnHy_MoveForwards(this, 1.0f)) { + this->curPoint = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC3CC.s") +void EnBba01_FaceFoward(EnHy* this, GlobalContext* globalCtx) { + this->actor.shape.rot = this->actor.world.rot; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/EnBba01_Init.s") +void EnBba01_Talk(EnHy* this, GlobalContext* globalCtx) { + s16 yaw; + u8 talkState; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/EnBba01_Destroy.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xFA0, 1); + talkState = Message_GetState(&globalCtx->msgCtx); + this->inMsgState3 = (talkState == 3) ? true : false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/EnBba01_Update.s") + switch (talkState) { + case 0: + yaw = ABS_ALT(this->actor.shape.rot.y - this->actor.yawTowardsPlayer); + if (yaw < 0x64) { + func_801518B0(globalCtx, this->textId, NULL); + } + break; + case 2: + this->actor.textId = 0; + this->focusTarget = this->tmpFocusTarget; + this->headRot = this->tmpHeadRot; + this->torsoRot = this->tmpTorsoRot; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc = this->tmpActionFunc; + this->tmpActionFunc = NULL; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC6F0.s") +void EnBba01_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBba01* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC984.s") + this->enHy.animObjIndex = func_8013D924(OBJECT_BBA, globalCtx); + this->enHy.headObjIndex = func_8013D924(OBJECT_BBA, globalCtx); + this->enHy.skelUpperObjIndex = func_8013D924(OBJECT_BBA, globalCtx); + this->enHy.skelLowerObjIndex = func_8013D924(OBJECT_BBA, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CCA5C.s") + if ((this->enHy.animObjIndex < 0) || (this->enHy.headObjIndex < 0) || (this->enHy.skelUpperObjIndex < 0) || + (this->enHy.skelLowerObjIndex < 0)) { + Actor_MarkForDeath(&this->enHy.actor); + } + this->enHy.actor.draw = NULL; + Collider_InitCylinder(globalCtx, &this->enHy.collider); + Collider_SetCylinder(globalCtx, &this->enHy.collider, &this->enHy.actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->enHy.actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->enHy.actor.flags &= ~ACTOR_FLAG_1; + this->enHy.path = func_8013D648(globalCtx, ENBBA01_GET_PATH(&this->enHy.actor), ENBBA01_NO_PATH); + this->enHy.waitingOnInit = true; + Actor_SetScale(&this->enHy.actor, 0.01f); + this->enHy.actionFunc = EnBba01_FinishInit; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/EnBba01_Draw.s") +void EnBba01_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBba01* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->enHy.collider); +} + +void EnBba01_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBba01* this = THIS; + + EnBba01_TestIsTalking(this, globalCtx); + this->enHy.actionFunc(&this->enHy, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, &this->enHy.actor, 0.0f, 0.0f, 0.0f, 4); + EnBba01_UpdateModel(this, globalCtx); + func_809CC270(this, globalCtx); +} + +s32 EnBba01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBba01* this = THIS; + s8 bodyPart; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + bodyPart = gEnHyBodyParts[limbIndex]; + if (bodyPart >= 0) { + Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.bodyPartsPos[bodyPart]); + } + + if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->enHy.headObjIndex].segment); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->enHy.headObjIndex].segment); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->enHy.skelLowerObjIndex].segment); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { + Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->enHy.headRot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->enHy.headRot.x, MTXMODE_APPLY); + Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if (limbIndex == BBA_LIMB_BAG) { + Matrix_InsertXRotation_s(-this->enHy.torsoRot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->enHy.torsoRot.x, MTXMODE_APPLY); + } + + if ((limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) && this->enHy.inMsgState3 && + ((globalCtx->state.frames % 2) == 0)) { + Matrix_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if ((limbIndex == BBA_LIMB_BAG) || (limbIndex == BBA_LIMB_TORSO) || (limbIndex == BBA_LIMB_LEFT_FOREARM)) { + rot->y += (s16)(Math_SinS(this->enHy.limbRotTableY[limbIndex]) * 200.0f); + rot->z += (s16)(Math_CosS(this->enHy.limbRotTableZ[limbIndex]) * 200.0f); + } + + return false; +} + +void EnBba01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnBba01* this = THIS; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == BBA_LIMB_HEAD) { + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { + Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.actor.focus.pos); + } +} + +void EnBba01_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +} + +void EnBba01_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBba01* this = THIS; + s32 i; + u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(u8[64][64])); + u8* shadowTexIter; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(globalCtx->state.gfxCtx, 255, 255, 255, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(globalCtx->state.gfxCtx, 55, 55, 255, 0)); + gDPPipeSync(POLY_OPA_DISP++); + SkelAnime_DrawTransformFlexOpa(globalCtx, this->enHy.skelAnime.skeleton, this->enHy.skelAnime.jointTable, + this->enHy.skelAnime.dListCount, EnBba01_OverrideLimbDraw, EnBba01_PostLimbDraw, + EnBba01_TransformLimbDraw, &this->enHy.actor); + Matrix_InsertXRotation_s(0, MTXMODE_NEW); + + for (i = 0, shadowTexIter = shadowTex; i < (s32)sizeof(u8[64][64]); i++) { + *shadowTexIter++ = 0; + } + for (i = 0; i < 5; i++) { + func_8013CD64(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, + ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSize, gEnHyBodyPartsIndex); + } + func_8013CF04(&this->enHy.actor, &globalCtx->state.gfxCtx, shadowTex); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.h b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.h index 20416b4f9..b670dea01 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.h +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.h @@ -1,16 +1,18 @@ #ifndef Z_EN_BBA_01_H #define Z_EN_BBA_01_H -#include "global.h" +#include "z_en_hy_code.h" struct EnBba01; typedef void (*EnBba01ActionFunc)(struct EnBba01*, GlobalContext*); +#define ENBBA01_GET_PATH(thisx) (((thisx)->params & 0x7E00) >> 9) +#define ENBBA01_NO_PATH 0x3F + typedef struct EnBba01 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnBba01ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4D4]; + /* 0x000 */ EnHy enHy; + /* 0x3EC */ UNK_TYPE1 unk_3EC[0x230]; } EnBba01; // size = 0x61C extern const ActorInit En_Bba_01_InitVars; diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index 77cb0cca8..9e4ae1159 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -7,7 +7,7 @@ #include "z_en_cne_01.h" #include "objects/object_cne/object_cne.h" -#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_8 | ACTOR_FLAG_1) +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnCne01*)thisx) @@ -20,8 +20,6 @@ void EnCne01_Walk(EnHy* this, GlobalContext* globalCtx); void EnCne01_FaceForward(EnHy* this, GlobalContext* globalCtx); void EnCne01_Talk(EnHy* this, GlobalContext* globalCtx); -typedef enum { CNE01_DMG_EFF_NONE } EnCne01DamageEffect; - const ActorInit En_Cne_01_InitVars = { ACTOR_EN_CNE_01, ACTORCAT_NPC, @@ -57,41 +55,41 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; static DamageTable sDamageTable = { - /* Deku Nut */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Deku Stick */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Horse trample */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Explosives */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Zora boomerang */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Normal arrow */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Hookshot */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Goron punch */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Sword */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Goron pound */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Fire arrow */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Ice arrow */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Light arrow */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Goron spikes */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Deku spin */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Deku bubble */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Deku launch */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Zora barrier */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Normal shield */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Light ray */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Thrown object */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Zora punch */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Spin attack */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Sword beam */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Normal Roll */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Unblockable */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), - /* Powder Keg */ DMG_ENTRY(0, CNE01_DMG_EFF_NONE), + /* Deku Nut */ DMG_ENTRY(0, 0), + /* Deku Stick */ DMG_ENTRY(0, 0), + /* Horse trample */ DMG_ENTRY(0, 0), + /* Explosives */ DMG_ENTRY(0, 0), + /* Zora boomerang */ DMG_ENTRY(0, 0), + /* Normal arrow */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0), + /* Hookshot */ DMG_ENTRY(0, 0), + /* Goron punch */ DMG_ENTRY(0, 0), + /* Sword */ DMG_ENTRY(0, 0), + /* Goron pound */ DMG_ENTRY(0, 0), + /* Fire arrow */ DMG_ENTRY(0, 0), + /* Ice arrow */ DMG_ENTRY(0, 0), + /* Light arrow */ DMG_ENTRY(0, 0), + /* Goron spikes */ DMG_ENTRY(0, 0), + /* Deku spin */ DMG_ENTRY(0, 0), + /* Deku bubble */ DMG_ENTRY(0, 0), + /* Deku launch */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0), + /* Zora barrier */ DMG_ENTRY(0, 0), + /* Normal shield */ DMG_ENTRY(0, 0), + /* Light ray */ DMG_ENTRY(0, 0), + /* Thrown object */ DMG_ENTRY(0, 0), + /* Zora punch */ DMG_ENTRY(0, 0), + /* Spin attack */ DMG_ENTRY(0, 0), + /* Sword beam */ DMG_ENTRY(0, 0), + /* Normal Roll */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0), + /* Unblockable */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0), + /* Powder Keg */ DMG_ENTRY(0, 0), }; -static u16 D_809CBF58[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; +u16 D_809CBF58[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; void EnCne01_UpdateModel(EnCne01* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); @@ -122,7 +120,7 @@ s32 EnCne01_TestIsTalking(EnCne01* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->enHy.actor, &globalCtx->state)) { isTalking = true; - this->enHy.textId = 0x10B9; + this->enHy.textId = 0x10B9; // Invalid textId, produces empty textbox this->enHy.tmpFocusTarget = this->enHy.focusTarget; this->enHy.tmpHeadRot = this->enHy.headRot; this->enHy.tmpTorsoRot = this->enHy.torsoRot; @@ -169,13 +167,13 @@ void EnCne01_FaceForward(EnHy* this, GlobalContext* globalCtx) { void EnCne01_Talk(EnHy* this, GlobalContext* globalCtx) { s16 yaw; - u8 talkstate; + u8 talkState; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xFA0, 1); - talkstate = Message_GetState(&globalCtx->msgCtx); - this->inMsgState3 = (talkstate == 3) ? true : false; + talkState = Message_GetState(&globalCtx->msgCtx); + this->inMsgState3 = (talkState == 3) ? true : false; - switch (talkstate) { + switch (talkState) { case 0: yaw = ABS_ALT(this->actor.shape.rot.y - this->actor.yawTowardsPlayer); if (yaw < 0x64) { diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h index 98e7021cf..840d1cf60 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h @@ -1,7 +1,7 @@ #ifndef Z_EN_CNE_01_H #define Z_EN_CNE_01_H -#include "z_en_hy.h" +#include "z_en_hy_code.h" struct EnCne01; diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 65696bb00..34bff63c2 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -20,8 +20,6 @@ void EnZo_FollowPath(EnZo* this, GlobalContext* globalCtx); void EnZo_TreadWater(EnZo* this, GlobalContext* globalCtx); void EnZo_DoNothing(EnZo* this, GlobalContext* globalCtx); -typedef enum { ZO_DMG_EFF_NONE } EnZoDamageEffect; - const ActorInit En_Zo_InitVars = { ACTOR_EN_ZO, ACTORCAT_NPC, @@ -57,38 +55,38 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; static DamageTable sDamageTable = { - /* Deku Nut */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Deku Stick */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Horse trample */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Explosives */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Zora boomerang */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Normal arrow */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Hookshot */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Goron punch */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Sword */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Goron pound */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Fire arrow */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Ice arrow */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Light arrow */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Goron spikes */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Deku spin */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Deku bubble */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Deku launch */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Zora barrier */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Normal shield */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Light ray */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Thrown object */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Zora punch */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Spin attack */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Sword beam */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Normal Roll */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Unblockable */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Powder Keg */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), + /* Deku Nut */ DMG_ENTRY(0, 0), + /* Deku Stick */ DMG_ENTRY(0, 0), + /* Horse trample */ DMG_ENTRY(0, 0), + /* Explosives */ DMG_ENTRY(0, 0), + /* Zora boomerang */ DMG_ENTRY(0, 0), + /* Normal arrow */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0), + /* Hookshot */ DMG_ENTRY(0, 0), + /* Goron punch */ DMG_ENTRY(0, 0), + /* Sword */ DMG_ENTRY(0, 0), + /* Goron pound */ DMG_ENTRY(0, 0), + /* Fire arrow */ DMG_ENTRY(0, 0), + /* Ice arrow */ DMG_ENTRY(0, 0), + /* Light arrow */ DMG_ENTRY(0, 0), + /* Goron spikes */ DMG_ENTRY(0, 0), + /* Deku spin */ DMG_ENTRY(0, 0), + /* Deku bubble */ DMG_ENTRY(0, 0), + /* Deku launch */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0), + /* Zora barrier */ DMG_ENTRY(0, 0), + /* Normal shield */ DMG_ENTRY(0, 0), + /* Light ray */ DMG_ENTRY(0, 0), + /* Thrown object */ DMG_ENTRY(0, 0), + /* Zora punch */ DMG_ENTRY(0, 0), + /* Spin attack */ DMG_ENTRY(0, 0), + /* Sword beam */ DMG_ENTRY(0, 0), + /* Normal Roll */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0), + /* Unblockable */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0), + /* Powder Keg */ DMG_ENTRY(0, 0), }; static AnimationInfoS sAnimations[] = { diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 35fa705d9..6e5820303 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -9155,19 +9155,19 @@ 0x809CBBC8:("EnCne01_PostLimbDraw",), 0x809CBCA0:("EnCne01_TransformLimbDraw",), 0x809CBCB4:("EnCne01_Draw",), - 0x809CC060:("func_809CC060",), - 0x809CC1D4:("func_809CC1D4",), + 0x809CC060:("EnBba01_UpdateModel",), + 0x809CC1D4:("EnBba01_TestIsTalking",), 0x809CC270:("func_809CC270",), - 0x809CC2F0:("func_809CC2F0",), - 0x809CC370:("func_809CC370",), - 0x809CC3A8:("func_809CC3A8",), - 0x809CC3CC:("func_809CC3CC",), + 0x809CC2F0:("EnBba01_FinishInit",), + 0x809CC370:("EnBba01_Walk",), + 0x809CC3A8:("EnBba01_FaceFoward",), + 0x809CC3CC:("EnBba01_Talk",), 0x809CC4FC:("EnBba01_Init",), 0x809CC63C:("EnBba01_Destroy",), 0x809CC668:("EnBba01_Update",), - 0x809CC6F0:("func_809CC6F0",), - 0x809CC984:("func_809CC984",), - 0x809CCA5C:("func_809CCA5C",), + 0x809CC6F0:("EnBba01_OverrideLimbDraw",), + 0x809CC984:("EnBba01_PostLimbDraw",), + 0x809CCA5C:("EnBba01_TransformLimbDraw",), 0x809CCA70:("EnBba01_Draw",), 0x809CCDE0:("func_809CCDE0",), 0x809CCE98:("func_809CCE98",), @@ -15194,7 +15194,7 @@ 0x80BA9F50:("EnBaba_Update",), 0x80BA9FB0:("EnBaba_OverrideLimbDraw",), 0x80BAA198:("EnBaba_PostLimbDraw",), - 0x80BAA20C:("EnBaba_TransformDraw",), + 0x80BAA20C:("EnBaba_TransformLimbDraw",), 0x80BAA220:("EnBaba_Draw",), 0x80BAA6D0:("EnSuttari_UpdateCollider",), 0x80BAA848:("EnSuttari_GetActorById",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 034ab6cf0..c3647b915 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1139,10 +1139,6 @@ D_06000184 = 0x06000184; D_06000444 = 0x06000444; D_06001A30 = 0x06001A30; -// ovl_En_Bba_01 - -D_06005EF0 = 0x06005EF0; - // ovl_En_Bbfall D_06000184 = 0x06000184; From 71c0120fbd7191a6c543b547946573a347bad749 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 19 Feb 2022 15:49:36 -0800 Subject: [PATCH 045/257] SubS Cutscenes, Flags, Objects, and Angles (#665) * Bring cutscene code over * Document cutscene functions * Bring over flags code * Document flags * Bring Object code over * Document object functions * Better infinite loop comment * Remove Effect_add correction * Bring func_8013D5E8 code over * Document angle helper * ActorFixer * Rename angle helper * Missed gs * Should probably test before commiting * Better angle helper name as well as typo fix * English is hard * Len to num * Fix merge * Fix merge * Format Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> --- include/functions.h | 14 ++-- include/z64.h | 7 ++ src/code/z_en_hy_code.c | 8 +-- src/code/z_sub_s.c | 69 ++++++++++++++++--- .../ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c | 4 +- .../actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c | 4 +- src/overlays/actors/ovl_En_Al/z_en_al.c | 12 ++-- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 2 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 3 +- .../actors/ovl_En_Bba_01/z_en_bba_01.c | 10 +-- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 3 +- .../actors/ovl_En_Cne_01/z_en_cne_01.c | 10 +-- src/overlays/actors/ovl_En_Dai/z_en_dai.c | 6 +- src/overlays/actors/ovl_En_Dnk/z_en_dnk.c | 8 +-- src/overlays/actors/ovl_En_Dnp/z_en_dnp.c | 16 ++--- src/overlays/actors/ovl_En_Dnq/z_en_dnq.c | 14 ++-- src/overlays/actors/ovl_En_Dns/z_en_dns.c | 12 ++-- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 28 ++++---- src/overlays/actors/ovl_En_Go/z_en_go.c | 42 +++++------ src/overlays/actors/ovl_En_Gs/z_en_gs.c | 8 +-- src/overlays/actors/ovl_En_Gs/z_en_gs.h | 3 +- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 14 ++-- src/overlays/actors/ovl_En_In/z_en_in.c | 2 +- src/overlays/actors/ovl_En_Ja/z_en_ja.c | 10 +-- src/overlays/actors/ovl_En_Ot/z_en_ot.c | 12 ++-- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 22 +++--- src/overlays/actors/ovl_En_Rg/z_en_rg.c | 2 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 2 +- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 11 +-- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 18 ++--- src/overlays/actors/ovl_En_Zo/z_en_zo.c | 2 +- tools/actorfixer.py | 6 ++ tools/disasm/functions.txt | 12 ++-- tools/sizes/code_functions.csv | 12 ++-- 34 files changed, 237 insertions(+), 171 deletions(-) diff --git a/include/functions.h b/include/functions.h index c12a4cc37..ba72e093f 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2494,7 +2494,7 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 idx, void** skelet Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx); s32 func_8013AD6C(GlobalContext* globalCtx); s32 func_8013AD9C(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5); -void func_8013AED4(u16* arg0, u16 arg1, u16 arg2); +void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits); void func_8013AF00(f32* arg0, s32 arg1, s32 arg2); s32 func_8013B010(f32* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, f32* arg6); void func_8013B0C8(s32 arg0, f32 arg1, s32 arg2, f32* arg3, f32* arg4); @@ -2515,16 +2515,16 @@ void func_8013CD64(Vec3f* arg0, Vec3f* arg1, u8* arg2, f32 arg3, u8 arg4, u8* ar void func_8013CF04(Actor* actor, GraphicsContext** gfxCtxPtr, u8* arg2); s16 func_8013D0E0(s16* arg0, s16 arg1, s16 arg2, f32 arg3, f32 arg4, f32 arg5); s32 func_8013D2E0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Vec3s* arg3, Vec3s* arg4, Vec3s* arg5, u16* arg6); -s32 func_8013D5E8(s16 arg0, s16 arg1, s16 arg2); +s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); Path* func_8013D648(GlobalContext* globalCtx, s16 arg1, s16 arg2); s32 func_8013D68C(Path* path, s32 arg1, Vec3f* arg2); s16 func_8013D720(Vec3f* arg0, Vec3f* arg1, f32* arg2); s32 func_8013D768(Actor* actor, Vec3f* arg1, s16 arg2); s16 func_8013D83C(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); -s8 func_8013D8DC(s8 arg0, GlobalContext* globalCtx); -s8 func_8013D924(s16 arg0, GlobalContext* globalCtx); +s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx); +s8 SubS_GetObjectIndex(s16 id, GlobalContext* globalCtx); Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); -s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 limbRotTableLen); +s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs); s32 func_8013DB90(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2); s32 func_8013DC40(Path* arg0, s32 arg1, s32 arg2, Vec3f* arg3); void func_8013DCE0(GlobalContext* globalCtx, Vec3f* arg1, Actor* arg2, struct_8013DF3C_arg1* arg3, Path* arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, u8 arg9); @@ -2534,8 +2534,8 @@ s32 func_8013E054(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); s32 func_8013E07C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); s32 func_8013E0A4(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, s32* curIndex); -s32 func_8013E2D4(Actor* actor, s16 arg1, s16 arg2, s32 arg3); -s32 func_8013E3B8(Actor* actor, s16 cutscenes[], s16 len); +s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type); +s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes); void func_8013E4B0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Plane* plane); s32 func_8013E5CC(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2, Vec3f* arg3, Vec3f* arg4, Vec3f* arg5); Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor); diff --git a/include/z64.h b/include/z64.h index 1daaeb30f..610b03d13 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1381,6 +1381,13 @@ typedef struct { /* 0x8 */ s32 unk8; // game script pointer? } struct_80133038_arg2; // size = 0xC + +typedef enum { + /* 0 */ SUBS_CUTSCENE_SET_UNK_LINK_FIELDS, + /* 1 */ SUBS_CUTSCENE_NORMAL, + /* 2 */ SUBS_CUTSCENE_SET_FLAG +} SubSCutsceneType; + typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, Vec3s*); typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); diff --git a/src/code/z_en_hy_code.c b/src/code/z_en_hy_code.c index 7b17f78f2..b803b291c 100644 --- a/src/code/z_en_hy_code.c +++ b/src/code/z_en_hy_code.c @@ -112,10 +112,10 @@ void EnHy_Blink(EnHy* enHy, s32 eyeTexMaxIndex) { s32 EnHy_Init(EnHy* enHy, GlobalContext* globalCtx, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex) { s32 isInitialized = false; - if ((func_8013D8DC(enHy->animObjIndex, globalCtx) == true) && - (func_8013D8DC(enHy->headObjIndex, globalCtx) == true) && - (func_8013D8DC(enHy->skelUpperObjIndex, globalCtx) == true) && - (func_8013D8DC(enHy->skelLowerObjIndex, globalCtx) == true)) { + if ((SubS_IsObjectLoaded(enHy->animObjIndex, globalCtx) == true) && + (SubS_IsObjectLoaded(enHy->headObjIndex, globalCtx) == true) && + (SubS_IsObjectLoaded(enHy->skelUpperObjIndex, globalCtx) == true) && + (SubS_IsObjectLoaded(enHy->skelLowerObjIndex, globalCtx) == true)) { enHy->actor.objBankIndex = enHy->skelLowerObjIndex; isInitialized = true; ActorShape_Init(&enHy->actor.shape, 0.0f, NULL, 0.0f); diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 2ce355d47..eda973125 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -154,7 +154,9 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AD9C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AED4.s") +void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits) { + *flags = (*flags & ~unsetBits) | setBits; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AF00.s") @@ -248,7 +250,9 @@ s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D2E0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D5E8.s") +s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB) { + return (ABS_ALT(BINANG_SUB(angleB, angleA)) <= threshold) ? true : false; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D648.s") @@ -260,9 +264,13 @@ s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D83C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D8DC.s") +s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx) { + return !Object_IsLoaded(&globalCtx->objectCtx, index) ? false : true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D924.s") +s8 SubS_GetObjectIndex(s16 id, GlobalContext* globalCtx) { + return Object_GetIndex(&globalCtx->objectCtx, id); +} /** * Finds the first actor instance of a specified Id and category. @@ -281,11 +289,11 @@ Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorC return actor; } -s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 limbRotTableLen) { +s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs) { s32 i; u32 frames = globalCtx->gameplayFrames; - for (i = 0; i < limbRotTableLen; i++) { + for (i = 0; i < numLimbs; i++) { limbRotTableY[i] = (i * 50 + 0x814) * frames; limbRotTableZ[i] = (i * 50 + 0x940) * frames; } @@ -340,9 +348,54 @@ void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* a *curIndex = nextIndex; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E2D4.s") +s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type) { + s32 isStarted = false; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E3B8.s") + if ((curCutscene != -1) && (ActorCutscene_GetCurrentIndex() == curCutscene)) { + ActorCutscene_Stop(curCutscene); + ActorCutscene_SetIntentToPlay(nextCutscene); + } else if (ActorCutscene_GetCanPlayNext(nextCutscene)) { + switch (type) { + case SUBS_CUTSCENE_SET_UNK_LINK_FIELDS: + ActorCutscene_StartAndSetUnkLinkFields(nextCutscene, actor); + break; + case SUBS_CUTSCENE_NORMAL: + ActorCutscene_Start(nextCutscene, actor); + break; + case SUBS_CUTSCENE_SET_FLAG: + ActorCutscene_StartAndSetFlag(nextCutscene, actor); + break; + } + isStarted = true; + } else { + ActorCutscene_SetIntentToPlay(nextCutscene); + } + + return isStarted; +} + +s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes) { + s16 cs; + s32 i; + + for (i = 0; i < numCutscenes; i++) { + cutscenes[i] = -1; + } + + cs = actor->cutscene; + i = 0; + + while (cs != -1) { + // Note: Infinite loop if numCutscenes is less than possible additional cutscenes + if (i < numCutscenes) { + cutscenes[i] = cs; + cs = ActorCutscene_GetAdditionalCutscene(cs); + i++; + } + } + + return i; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E4B0.s") diff --git a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c index b241ae6b9..3a12f286d 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c @@ -196,7 +196,7 @@ void BgDblueMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_168 = D_80A2B8DC[this->unk_160]; this->unk_16C = D_80A2B93C[this->unk_160]; - func_8013E3B8(&this->dyna.actor, this->unk_1B6, ARRAY_COUNT(this->unk_1B6)); + SubS_FillCutscenesList(&this->dyna.actor, this->unk_1B6, ARRAY_COUNT(this->unk_1B6)); switch (this->unk_160) { case 1: @@ -723,7 +723,7 @@ void BgDblueMovebg_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if (this->unk_172 & 8) { - if (func_8013E2D4(&this->dyna.actor, this->unk_1D2, -1, 0)) { + if (SubS_StartActorCutscene(&this->dyna.actor, this->unk_1D2, -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { this->unk_172 &= ~8; } } diff --git a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c index 06ac0520f..7cb4aab5e 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c +++ b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c @@ -47,7 +47,7 @@ void BgHakaTomb_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 1); DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_haka_obj_Colheader_000EE8); - func_8013E3B8(&this->dyna.actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + SubS_FillCutscenesList(&this->dyna.actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); func_80BD6624(this); } @@ -100,7 +100,7 @@ void func_80BD6754(BgHakaTomb* this) { } void func_80BD6768(BgHakaTomb* this, GlobalContext* globalCtx) { - if (func_8013E2D4(&this->dyna.actor, this->cutscenes[0], -1, 0)) { + if (SubS_StartActorCutscene(&this->dyna.actor, this->cutscenes[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { BgHakaTomb_SetupDoNothing(this); } } diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index a984af2fa..6d1d65db2 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -473,7 +473,7 @@ s32 func_80BDEC2C(EnAl* this, GlobalContext* globalCtx) { this->unk_4C2 |= 0x1000; this->unk_4F4 = player->exchangeItemId; } - func_8013AED4(&this->unk_4C2, 0, 7); + SubS_UpdateFlags(&this->unk_4C2, 0, 7); this->unk_4E6 = 0; this->unk_4EC = 0; this->actor.child = this->unk_368; @@ -629,7 +629,7 @@ s32 func_80BDF244(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if ((sp20 != NULL) && (sp20->update != NULL) && (temp_v0 != NULL) && (temp_v0->update != NULL)) { func_80BDE27C(this, 0); - func_8013AED4(&this->unk_4C2, 3, 7); + SubS_UpdateFlags(&this->unk_4C2, 3, 7); this->unk_368 = sp20; this->unk_4C2 |= 0x20; ret = true; @@ -638,7 +638,7 @@ s32 func_80BDF244(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - func_8013AED4(&this->unk_4C2, 3, 7); + SubS_UpdateFlags(&this->unk_4C2, 3, 7); switch (arg2->unk0) { case 1: @@ -708,9 +708,9 @@ void func_80BDF414(EnAl* this, GlobalContext* globalCtx) { temp_v0 = this->actor.world.rot.y - this->actor.yawTowardsPlayer; if (((this->unk_4EA == 0) && (ABS_ALT(temp_v0) >= 0x5800)) || ((this->unk_4EA == 5) && (ABS_ALT(temp_v0) >= 0x5800)) || (this->unk_4EA == 2)) { - func_8013AED4(&this->unk_4C2, 3, 7); + SubS_UpdateFlags(&this->unk_4C2, 3, 7); } else { - func_8013AED4(&this->unk_4C2, 0, 7); + SubS_UpdateFlags(&this->unk_4C2, 0, 7); } } @@ -753,7 +753,7 @@ void func_80BDF5E8(EnAl* this, GlobalContext* globalCtx) { void func_80BDF6C4(EnAl* this, GlobalContext* globalCtx) { if (func_8010BF58(&this->actor, globalCtx, this->unk_360, this->unk_4EC, &this->unk_364)) { - func_8013AED4(&this->unk_4C2, 3, 7); + SubS_UpdateFlags(&this->unk_4C2, 3, 7); this->unk_4C2 &= ~0x20; this->unk_4C2 |= 0x200; this->actor.child = NULL; diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index 89ed13d96..e3e9b35ff 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -471,7 +471,7 @@ void func_809C1EC8(EnAob01* this, GlobalContext* globalCtx) { Vec3f sp30; SkelAnime_Update(&this->skelAnime); - if (func_8013D5E8(this->actor.shape.rot.y, 14000, this->actor.yawTowardsPlayer)) { + if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer)) { sp30.x = player->actor.world.pos.x; sp30.y = player->bodyPartsPos[7].y + 3.0f; sp30.z = player->actor.world.pos.z; diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index 149bd29ae..1afcf5109 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -281,7 +281,8 @@ void func_80BA8DF4(EnBaba* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (func_8013D5E8(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer) && !(this->unk_40A & 4)) { + if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer) && + !(this->unk_40A & 4)) { sp30.x = player->actor.world.pos.x; sp30.y = player->bodyPartsPos[7].y + 3.0f; sp30.z = player->actor.world.pos.z; diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index 5df543b06..092595bdc 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -104,7 +104,7 @@ void EnBba01_UpdateModel(EnBba01* this, GlobalContext* globalCtx) { Vec3f focus; EnHy_UpdateSkelAnime(&this->enHy, globalCtx); - if (func_8013D5E8(this->enHy.actor.shape.rot.y, 0x36B0, this->enHy.actor.yawTowardsPlayer)) { + if (SubS_AngleDiffLessEqual(this->enHy.actor.shape.rot.y, 0x36B0, this->enHy.actor.yawTowardsPlayer)) { focus.x = player->actor.world.pos.x; focus.y = player->bodyPartsPos[7].y + 3.0f; focus.z = player->actor.world.pos.z; @@ -206,10 +206,10 @@ void EnBba01_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnBba01* this = THIS; - this->enHy.animObjIndex = func_8013D924(OBJECT_BBA, globalCtx); - this->enHy.headObjIndex = func_8013D924(OBJECT_BBA, globalCtx); - this->enHy.skelUpperObjIndex = func_8013D924(OBJECT_BBA, globalCtx); - this->enHy.skelLowerObjIndex = func_8013D924(OBJECT_BBA, globalCtx); + this->enHy.animObjIndex = SubS_GetObjectIndex(OBJECT_BBA, globalCtx); + this->enHy.headObjIndex = SubS_GetObjectIndex(OBJECT_BBA, globalCtx); + this->enHy.skelUpperObjIndex = SubS_GetObjectIndex(OBJECT_BBA, globalCtx); + this->enHy.skelLowerObjIndex = SubS_GetObjectIndex(OBJECT_BBA, globalCtx); if ((this->enHy.animObjIndex < 0) || (this->enHy.headObjIndex < 0) || (this->enHy.skelUpperObjIndex < 0) || (this->enHy.skelLowerObjIndex < 0)) { diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 42e50ea62..fd6c8aae7 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -341,8 +341,7 @@ void EnBji01_Init(Actor* thisx, GlobalContext* globalCtx) { this->animationIndex = -1; Actor_SetScale(&this->actor, 0.01f); - func_8013E3B8(&this->actor, this->cutscenes, - ARRAY_COUNT(this->cutscenes)); /* initializes all elements of cutscenes to -1 */ + SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); this->moonsTear = (ObjMoonStone*)SubS_FindActor(globalCtx, NULL, ACTORCAT_PROP, ACTOR_OBJ_MOON_STONE); switch (gSaveContext.entranceIndex) { diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index 9e4ae1159..1d61df5bc 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -96,7 +96,7 @@ void EnCne01_UpdateModel(EnCne01* this, GlobalContext* globalCtx) { Vec3f focus; EnHy_UpdateSkelAnime(&this->enHy, globalCtx); - if (func_8013D5E8(this->enHy.actor.shape.rot.y, 0x36B0, this->enHy.actor.yawTowardsPlayer)) { + if (SubS_AngleDiffLessEqual(this->enHy.actor.shape.rot.y, 0x36B0, this->enHy.actor.yawTowardsPlayer)) { focus.x = player->actor.world.pos.x; focus.y = player->bodyPartsPos[7].y + 3.0f; focus.z = player->actor.world.pos.z; @@ -196,10 +196,10 @@ void EnCne01_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnCne01* this = THIS; - this->enHy.animObjIndex = func_8013D924(OBJECT_OS_ANIME, globalCtx); - this->enHy.headObjIndex = func_8013D924(OBJECT_CNE, globalCtx); - this->enHy.skelUpperObjIndex = func_8013D924(OBJECT_CNE, globalCtx); - this->enHy.skelLowerObjIndex = func_8013D924(OBJECT_CNE, globalCtx); + this->enHy.animObjIndex = SubS_GetObjectIndex(OBJECT_OS_ANIME, globalCtx); + this->enHy.headObjIndex = SubS_GetObjectIndex(OBJECT_CNE, globalCtx); + this->enHy.skelUpperObjIndex = SubS_GetObjectIndex(OBJECT_CNE, globalCtx); + this->enHy.skelLowerObjIndex = SubS_GetObjectIndex(OBJECT_CNE, globalCtx); if ((this->enHy.animObjIndex < 0) || (this->enHy.headObjIndex < 0) || (this->enHy.skelUpperObjIndex < 0) || (this->enHy.skelLowerObjIndex < 0)) { diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index 5bc75eb8f..82562d45c 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -206,7 +206,7 @@ s32 func_80B3E7C8(EnDai* this, GlobalContext* globalCtx) { if (this->unk_1CE & 7) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_1CE, 0, 7); + SubS_UpdateFlags(&this->unk_1CE, 0, 7); this->actionFunc = func_80B3EF90; ret = true; } @@ -428,7 +428,7 @@ void func_80B3EEDC(EnDai* this, GlobalContext* globalCtx) { void func_80B3EF90(EnDai* this, GlobalContext* globalCtx) { if (func_8010BF58(&this->actor, globalCtx, D_80B3FC8C, NULL, &this->unk_1D0)) { - func_8013AED4(&this->unk_1CE, 3, 7); + SubS_UpdateFlags(&this->unk_1CE, 3, 7); this->unk_1D0 = 0; this->actionFunc = func_80B3F00C; } else { @@ -527,7 +527,7 @@ void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_1D6 = 0; if (gSaveContext.weekEventReg[33] & 0x80) { - func_8013AED4(&this->unk_1CE, 3, 7); + SubS_UpdateFlags(&this->unk_1CE, 3, 7); this->unk_1CE |= 0x80; this->unk_1CD = 0xFF; this->actionFunc = func_80B3F00C; diff --git a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c index f144d64c0..3692f4a4a 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -170,7 +170,7 @@ s32 func_80A515C4(EnDnk* this) { } void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { - if (func_8013D8DC(this->unk_28E, globalCtx) == 1) { + if (SubS_IsObjectLoaded(this->unk_28E, globalCtx) == true) { gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_28E].segment); this->actor.draw = func_80A52018; this->actor.objBankIndex = this->unk_28E; @@ -227,15 +227,15 @@ void EnDnk_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_28E = -1; switch (ENDNK_GET_3(&this->actor)) { case ENDNK_GET_3_1: - this->unk_28E = func_8013D924(0x12B, globalCtx); + this->unk_28E = SubS_GetObjectIndex(OBJECT_HINTNUTS, globalCtx); break; case ENDNK_GET_3_0: - this->unk_28E = func_8013D924(0x135, globalCtx); + this->unk_28E = SubS_GetObjectIndex(OBJECT_DNK, globalCtx); break; case ENDNK_GET_3_2: - this->unk_28E = func_8013D924(0x40, globalCtx); + this->unk_28E = SubS_GetObjectIndex(OBJECT_DEKUNUTS, globalCtx); break; } diff --git a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c index 118c984f9..fa3448e04 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -202,12 +202,12 @@ s32 func_80B3CF60(EnDnp* this, GlobalContext* globalCtx) { s32 ret = false; if ((this->unk_322 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_322, 0, 7); + SubS_UpdateFlags(&this->unk_322, 0, 7); this->unk_322 |= 8; this->actionFunc = func_80B3D3F8; ret = true; } else if (!(gSaveContext.weekEventReg[23] & 0x20) && Actor_HasParent(&this->actor, globalCtx)) { - func_8013AED4(&this->unk_322, 0, 7); + SubS_UpdateFlags(&this->unk_322, 0, 7); this->unk_322 &= ~0x500; this->actor.parent = NULL; this->unk_32E = 0; @@ -227,12 +227,12 @@ s32 func_80B3D044(EnDnp* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; this->unk_324 = 0xFF; } - func_8013AED4(&this->unk_322, 0, 7); + SubS_UpdateFlags(&this->unk_322, 0, 7); this->actionFunc = func_80B3D11C; ret = true; } else if (this->unk_322 & 0x200) { this->actor.flags |= ACTOR_FLAG_1; - func_8013AED4(&this->unk_322, 3, 7); + SubS_UpdateFlags(&this->unk_322, 3, 7); this->unk_322 &= ~(0x200 | 0x10); this->actionFunc = func_80B3D2D4; } @@ -311,7 +311,7 @@ void func_80B3D338(EnDnp* this, GlobalContext* globalCtx) { void func_80B3D3F8(EnDnp* this, GlobalContext* globalCtx) { if (func_8010BF58(&this->actor, globalCtx, D_80B3DE58, NULL, &this->unk_328)) { - func_8013AED4(&this->unk_322, 3, 7); + SubS_UpdateFlags(&this->unk_322, 3, 7); this->unk_322 &= ~8; this->actionFunc = func_80B3D2D4; } else { @@ -324,7 +324,7 @@ void func_80B3D47C(EnDnp* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.scale.x, 0.0085f, 0.1f, 0.01f, 0.001f); if ((s32)(this->actor.scale.x * 10000.0f) >= 85) { this->actor.flags |= ACTOR_FLAG_1; - func_8013AED4(&this->unk_322, 3, 7); + SubS_UpdateFlags(&this->unk_322, 3, 7); this->unk_322 &= ~0x10; this->unk_322 |= 0x400; this->actor.scale.x = 0.0085f; @@ -360,7 +360,7 @@ void EnDnp_Init(Actor* thisx, GlobalContext* globalCtx) { if (ENDNP_GET_7(&this->actor) == ENDNP_GET_7_1) { this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, 0.00085000007f); - func_8013AED4(&this->unk_322, 0, 7); + SubS_UpdateFlags(&this->unk_322, 0, 7); this->actor.shape.rot.x = 0; this->actor.world.rot.x = this->actor.shape.rot.x; this->actor.cutscene = 0x10; @@ -369,7 +369,7 @@ void EnDnp_Init(Actor* thisx, GlobalContext* globalCtx) { !(gSaveContext.weekEventReg[23] & 0x20)) || ((ENDNP_GET_7(&this->actor) == ENDNP_GET_7_2) && (gSaveContext.weekEventReg[23] & 0x20))) { Actor_SetScale(&this->actor, 0.0085f); - func_8013AED4(&this->unk_322, 3, 7); + SubS_UpdateFlags(&this->unk_322, 3, 7); this->unk_322 |= 0x400; if ((globalCtx->sceneNum == SCENE_MITURIN) && (gSaveContext.weekEventReg[29] & 0x40)) { this->unk_322 |= 0x20; diff --git a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c index 3e0606388..85df3499b 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -124,14 +124,14 @@ s32 func_80A52648(EnDnq* this, GlobalContext* globalCtx) { this->unk_1DC = 0xFF; this->unk_37C |= 0x20; } - func_8013AED4(&this->unk_37C, 0, 7); + SubS_UpdateFlags(&this->unk_37C, 0, 7); ret = true; } else { if (this->unk_37C & 0x20) { this->actor.flags |= ACTOR_FLAG_1; this->unk_1DC = 0xFF; this->unk_37C &= ~0x20; - func_8013AED4(&this->unk_37C, 3, 7); + SubS_UpdateFlags(&this->unk_37C, 3, 7); } } @@ -321,7 +321,7 @@ s32 func_80A52D44(EnDnq* this, GlobalContext* globalCtx) { s32 ret = false; if ((this->unk_37C & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_37C, 0, 7); + SubS_UpdateFlags(&this->unk_37C, 0, 7); this->unk_380 = func_80A52CF8(this, globalCtx); this->actionFunc = func_80A52FB8; ret = true; @@ -335,9 +335,9 @@ void func_80A52DC8(EnDnq* this, GlobalContext* globalCtx) { s16 yaw = this->actor.yawTowardsPlayer - this->actor.world.rot.y; if (yaw <= 0x3800) { - func_8013AED4(&this->unk_37C, 3, 7); + SubS_UpdateFlags(&this->unk_37C, 3, 7); } else { - func_8013AED4(&this->unk_37C, 0, 7); + SubS_UpdateFlags(&this->unk_37C, 0, 7); } if (!(gSaveContext.weekEventReg[23] & 0x20)) { @@ -376,7 +376,7 @@ void func_80A52FB8(EnDnq* this, GlobalContext* globalCtx) { s16 sp2E = this->actor.yawTowardsPlayer; if (func_8010BF58(&this->actor, globalCtx, this->unk_380, NULL, &this->unk_1E0)) { - func_8013AED4(&this->unk_37C, 3, 7); + SubS_UpdateFlags(&this->unk_37C, 3, 7); this->unk_386 = 0; this->actionFunc = func_80A52DC8; } else { @@ -426,7 +426,7 @@ void EnDnq_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 1; this->unk_386 = 0; this->unk_37C = 0; - func_8013AED4(&this->unk_37C, 3, 7); + SubS_UpdateFlags(&this->unk_37C, 3, 7); if (gSaveContext.weekEventReg[9] & 0x80) { this->unk_3A4 = 1; } else { diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c index ba01959bc..9a4562ae2 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -230,7 +230,7 @@ s32 func_8092CAD0(EnDns* this, GlobalContext* globalCtx) { if (this->unk_2C6 & 7) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_2C6, 0, 7); + SubS_UpdateFlags(&this->unk_2C6, 0, 7); this->unk_2C6 &= ~0x10; if (ENDNS_GET_4000(&this->actor)) { this->unk_2F0 = 0.0f; @@ -255,14 +255,14 @@ s32 func_8092CB98(EnDns* this, GlobalContext* globalCtx) { if (!(this->unk_2C6 & 0x80)) { this->unk_2C8 = func_8092CA74(this); this->actor.flags &= ~ACTOR_FLAG_1; - func_8013AED4(&this->unk_2C6, 0, 7); + SubS_UpdateFlags(&this->unk_2C6, 0, 7); this->unk_2C6 |= 0x80; this->unk_1D8 = 0xFF; } phi_v1 = 1; } else if (this->unk_2C6 & 0x80) { this->actor.flags |= ACTOR_FLAG_1; - func_8013AED4(&this->unk_2C6, 3, 7); + SubS_UpdateFlags(&this->unk_2C6, 3, 7); this->unk_2C6 &= ~0x80; } return phi_v1; @@ -402,7 +402,7 @@ void func_8092D1B8(EnDns* this, GlobalContext* globalCtx) { if (!(gSaveContext.weekEventReg[23] & 0x20) && !(gSaveContext.eventInf[1] & 0x20) && func_8092CC68(globalCtx)) { player->stateFlags1 |= 0x20; this->unk_2C6 |= 0x100; - func_8013AED4(&this->unk_2C6, 4, 7); + SubS_UpdateFlags(&this->unk_2C6, 4, 7); play_sound(NA_SE_SY_FOUND); gSaveContext.eventInf[1] |= 0x20; this->unk_2F4 = func_8092CCEC; @@ -455,7 +455,7 @@ void func_8092D4D8(EnDns* this, GlobalContext* globalCtx) { func_8092C63C(this, EN_DNS_ANIMATION_WALK_1); } } else if (func_8010BF58(&this->actor, globalCtx, this->unk_1E0, this->unk_2F4, &this->unk_1DC)) { - func_8013AED4(&this->unk_2C6, 3, 7); + SubS_UpdateFlags(&this->unk_2C6, 3, 7); this->unk_2F4 = NULL; if (ENDNS_GET_4000(&this->actor)) { if (!(gSaveContext.eventInf[1] & 0x20)) { @@ -521,7 +521,7 @@ void EnDns_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -0.8f; this->unk_2D2 = 0; this->unk_2C6 = 0; - func_8013AED4(&this->unk_2C6, 3, 7); + SubS_UpdateFlags(&this->unk_2C6, 3, 7); this->unk_2C6 |= (0x40 | 0x10); this->unk_2C6 |= 0x200; if (gSaveContext.weekEventReg[9] & 0x80) { 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 93ca5b2cb..6d5c2db3f 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -249,7 +249,7 @@ s32 func_8094E0F8(EnGm* this, GlobalContext* globalCtx) { if ((this->unk_260 != globalCtx->roomCtx.currRoom.num) && (globalCtx->roomCtx.unk31 == 0)) { this->unk_260 = globalCtx->roomCtx.currRoom.num; - this->unk_262 = func_8013D924(0x248, globalCtx); + this->unk_262 = SubS_GetObjectIndex(OBJECT_IN2, globalCtx); this->actor.draw = NULL; this->unk_3FC = 1; } @@ -258,7 +258,7 @@ s32 func_8094E0F8(EnGm* this, GlobalContext* globalCtx) { return false; } - if ((this->unk_262 < 0) || !func_8013D8DC(this->unk_262, globalCtx)) { + if ((this->unk_262 < 0) || !SubS_IsObjectLoaded(this->unk_262, globalCtx)) { ret = true; } else { this->actor.draw = EnGm_Draw; @@ -652,7 +652,7 @@ s32 func_8094EE84(EnGm* this, GlobalContext* globalCtx) { if (this->unk_3A4 & 7) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_3A4, 0, 7); + SubS_UpdateFlags(&this->unk_3A4, 0, 7); this->unk_3E0 = 0; this->unk_3E4 = NULL; this->actor.child = this->unk_268; @@ -999,7 +999,7 @@ s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_250 = (this->unk_254 / this->unk_24C) + 2; this->unk_3A4 &= ~0x8; this->unk_3A4 &= ~0x10; - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; func_8094E054(this, globalCtx, 7); @@ -1016,7 +1016,7 @@ s32 func_8094FCC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if (func_8094F7D0(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_TAB)) { if (this->unk_258 == 0) { Math_Vec3f_Copy(&this->actor.world.pos, &D_80951D90); - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); func_8094E054(this, globalCtx, 0); } else { func_8094E054(this, globalCtx, 9); @@ -1034,7 +1034,7 @@ s32 func_8094FD88(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if (func_8094F7D0(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_RECEPGIRL)) { func_8094E054(this, globalCtx, 11); - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; ret = true; @@ -1049,7 +1049,7 @@ s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar al = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); if (func_8094F7D0(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_TOTO) && (al != NULL) && (al->update != NULL)) { func_8094E054(this, globalCtx, 11); - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_268 = al; if (!(gSaveContext.weekEventReg[86] & 0x20)) { this->unk_3C8 = 2; @@ -1086,7 +1086,7 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); if (this->unk_258 == 0) { Math_Vec3f_Copy(&this->actor.world.pos, &D_80951D9C); - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3C8 = 4; this->unk_3CA = 4; this->unk_3CC = 8; @@ -1113,7 +1113,7 @@ s32 func_80950088(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->actor.world.pos, &D_80951DA8); Math_Vec3s_Copy(&this->actor.world.rot, &D_80951DB4); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= (0x2000 | 0x100); this->unk_3A4 |= 0x200; func_8094E054(this, globalCtx, 12); @@ -1128,7 +1128,7 @@ s32 func_80950120(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->actor.world.pos, &D_80951DBC); Math_Vec3s_Copy(&this->actor.world.rot, &D_80951DC8); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= (0x800 | 0x100); this->unk_3A4 |= 0x200; func_8094E054(this, globalCtx, 4); @@ -1144,7 +1144,7 @@ s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3s_Copy(&this->actor.world.rot, &D_80951DDC); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); this->actor.targetMode = 6; - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= (0x1000 | 0x100); this->unk_3A4 |= 0x200; this->unk_3C8 = 3; @@ -1251,7 +1251,7 @@ s32 func_809503F8(EnGm* this, GlobalContext* globalCtx) { if (this->unk_3E8 == 9) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); func_8094E054(this, globalCtx, 0); } else { AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, 1.0f); @@ -1283,7 +1283,7 @@ s32 func_80950490(EnGm* this, GlobalContext* globalCtx) { case 9: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3C8 = 4; this->unk_3CA = 4; this->unk_3CC = 8; @@ -1518,7 +1518,7 @@ void func_80950DB8(EnGm* this, GlobalContext* globalCtx) { Actor* al; if (func_8010BF58(&this->actor, globalCtx, this->unk_264, this->unk_3E4, &this->unk_25C)) { - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); al = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); if ((this->unk_258 == 2) && (al != NULL) && (al->update != NULL)) { this->unk_268 = al; 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 67dea2e9d..000f5649c 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -672,7 +672,7 @@ s32 func_80A12774(EnGo* this, GlobalContext* globalCtx) { this->unk_390 |= 0x20; } - func_8013AED4(&this->unk_390, 0, 7); + SubS_UpdateFlags(&this->unk_390, 0, 7); this->unk_3C0 = 0; this->unk_3C4 = 0; this->unk_18C = this->actionFunc; @@ -717,13 +717,13 @@ s32 func_80A12954(EnGo* this, GlobalContext* globalCtx) { this->unk_3F0 = 1; this->unk_18C = this->actionFunc; } - func_8013AED4(&this->unk_390, 0, 7); + SubS_UpdateFlags(&this->unk_390, 0, 7); this->actionFunc = func_80A14FC8; } else if (this->unk_3F0 != 0) { this->actor.flags |= ACTOR_FLAG_1; this->unk_394 = 255; this->unk_3F0 = 0; - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); this->actionFunc = this->unk_18C; } @@ -941,20 +941,20 @@ void func_80A132C8(EnGo* this, GlobalContext* globalCtx) { s16 temp_v1 = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); if ((fabsf(this->actor.playerHeightRel) > 20.0f) || (this->actor.xzDistToPlayer > 300.0f)) { - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); } else if ((player->transformation != PLAYER_FORM_GORON) || (ABS_ALT(temp_v1) >= 0x1C70) || (gSaveContext.weekEventReg[21] & 4) || (gSaveContext.weekEventReg[21] & 8)) { - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); } else { - func_8013AED4(&this->unk_390, 4, 7); + SubS_UpdateFlags(&this->unk_390, 4, 7); } } void func_80A133A8(EnGo* this, GlobalContext* globalCtx) { if (gSaveContext.weekEventReg[21] & 8) { - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); } else { - func_8013AED4(&this->unk_390, 4, 7); + SubS_UpdateFlags(&this->unk_390, 4, 7); } } @@ -1348,7 +1348,7 @@ void func_80A14324(EnGo* this, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, this->unk_3A4); this->unk_390 = 0; this->actor.gravity = -1.0f; - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); this->unk_3EC = 0; this->unk_390 |= 0x40; this->unk_3BC = 0; @@ -1362,7 +1362,7 @@ void func_80A143A8(EnGo* this, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, this->unk_3A4); this->unk_390 = 0; this->actor.gravity = -1.0f; - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); this->unk_3EC = 0; this->unk_390 |= 0x40; this->unk_390 |= 0x20; @@ -1441,7 +1441,7 @@ void func_80A146CC(EnGo* this, GlobalContext* globalCtx) { this->actor.targetMode = 3; this->unk_390 = 0; this->actor.gravity = -1.0f; - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); this->unk_390 |= 0x40; this->unk_390 |= 0x20; this->unk_3D8 = func_80A13E80; @@ -1451,8 +1451,8 @@ void func_80A146CC(EnGo* this, GlobalContext* globalCtx) { void func_80A14798(EnGo* this, GlobalContext* globalCtx) { s32 sp38[2] = { 0x0000003E, 0x00000F64 }; - if ((this->unk_288 < 0) || func_8013D8DC(this->unk_288, globalCtx) || (this->unk_289 < 0) || - func_8013D8DC(this->unk_289, globalCtx)) { + if ((this->unk_288 < 0) || SubS_IsObjectLoaded(this->unk_288, globalCtx) || (this->unk_289 < 0) || + SubS_IsObjectLoaded(this->unk_289, globalCtx)) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, this->morphTable, 18); @@ -1511,7 +1511,7 @@ void func_80A149B0(EnGo* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_CHEER - SFX_FLAG); } else if (ENGO_GET_F(&this->actor) != ENGO_F_8) { if (func_80A1222C(this, globalCtx)) { - func_8013AED4(&this->unk_390, 0, 7); + SubS_UpdateFlags(&this->unk_390, 0, 7); this->unk_3EC = 1; this->actionFunc = func_80A14B30; } else if (ENGO_GET_F(&this->actor) == ENGO_F_4) { @@ -1526,9 +1526,9 @@ void func_80A149B0(EnGo* this, GlobalContext* globalCtx) { } } else if (ENGO_GET_F(&this->actor) == ENGO_F_1) { if (ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)) < 0x3FFC) { - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); } else { - func_8013AED4(&this->unk_390, 0, 7); + SubS_UpdateFlags(&this->unk_390, 0, 7); } } } @@ -1579,7 +1579,7 @@ void func_80A14B30(EnGo* this, GlobalContext* globalCtx) { } this->unk_3AE += 0x400; this->actor.shape.yOffset = (this->actor.scale.y / this->unk_3A4) * 14.0f; - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); } } else if ((this->actor.xzDistToPlayer >= 240.0f) || (this->actor.playerHeightRel >= 20.0f) || (this->unk_3EC != 0)) { @@ -1621,7 +1621,7 @@ void func_80A14EB0(EnGo* this, GlobalContext* globalCtx) { ActorCutscene_Stop(this->actor.cutscene); func_80A143A8(this, globalCtx); if ((ENGO_GET_F(&this->actor) == ENGO_F_4) && (ENGO_GET_70(&this->actor) == ENGO_70_1)) { - func_8013AED4(&this->unk_390, 4, 7); + SubS_UpdateFlags(&this->unk_390, 4, 7); func_80A143A8(sp24, globalCtx); sp24->actionFunc = func_80A149B0; } @@ -1876,7 +1876,7 @@ void func_80A157C4(EnGo* this, GlobalContext* globalCtx) { } this->unk_390 &= ~0x8; - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); this->unk_28C = 0; this->unk_390 |= 0x40; this->actionFunc = this->unk_18C; @@ -1885,8 +1885,8 @@ void func_80A157C4(EnGo* this, GlobalContext* globalCtx) { void EnGo_Init(Actor* thisx, GlobalContext* globalCtx) { EnGo* this = THIS; - this->unk_288 = func_8013D924(OBJECT_TAISOU, globalCtx); - this->unk_289 = func_8013D924(OBJECT_HAKUGIN_DEMO, globalCtx); + this->unk_288 = SubS_GetObjectIndex(OBJECT_TAISOU, globalCtx); + this->unk_289 = SubS_GetObjectIndex(OBJECT_HAKUGIN_DEMO, globalCtx); this->actionFunc = func_80A14798; } 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 a7d0d397f..7bae831cf 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -156,7 +156,7 @@ void EnGs_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_1F4 = this->unk_1FA; Math_Vec3f_Copy(&this->unk_1B0[0], &D_801C5DB0); Math_Vec3f_Copy(&this->unk_1B0[1], &D_801C5DB0); - func_8013E3B8(&this->actor, &this->unk_212, 2); + SubS_FillCutscenesList(&this->actor, this->unk_212, ARRAY_COUNT(this->unk_212)); func_801A5080(0); if (this->actor.params == ENGS_1) { Actor_SetScale(&this->actor, 0.15f); @@ -262,7 +262,7 @@ void func_80997E4C(EnGs* this, GlobalContext* globalCtx) { } void func_80997FF0(EnGs* this, GlobalContext* globalCtx) { - if (func_8013E2D4(&this->actor, globalCtx->unk_1879C[0], -1, 1)) { + if (SubS_StartActorCutscene(&this->actor, globalCtx->unk_1879C[0], -1, SUBS_CUTSCENE_NORMAL)) { func_80998040(this, globalCtx); } } @@ -380,7 +380,7 @@ void func_809985B8(EnGs* this, GlobalContext* globalCtx) { EnGs* gossipStone; Vec3f sp38; - if (func_8013E2D4(&this->actor, this->unk_212, -1, 0)) { + if (SubS_StartActorCutscene(&this->actor, this->unk_212[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { Player* player = GET_PLAYER(globalCtx); Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); @@ -446,7 +446,7 @@ void func_8099874C(EnGs* this, GlobalContext* globalCtx) { if ((this->unk_19C == 5) && (this->unk_194 != 0)) { s32 i; - ActorCutscene_Stop(this->unk_212); + ActorCutscene_Stop(this->unk_212[0]); phi_v0 = 1; for (i = 0; i < 4; i++) { diff --git a/src/overlays/actors/ovl_En_Gs/z_en_gs.h b/src/overlays/actors/ovl_En_Gs/z_en_gs.h index 8b10cb68d..c76a0c346 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.h +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.h @@ -49,8 +49,7 @@ typedef struct EnGs { /* 0x208 */ s32 unk_208; /* 0x20C */ s32 unk_20C; /* 0x210 */ u16 unk_210; - /* 0x212 */ s16 unk_212; - /* 0x214 */ UNK_TYPE1 unk214[2]; + /* 0x212 */ s16 unk_212[2]; /* 0x216 */ s16 unk_216; /* 0x218 */ s16 unk_218; /* 0x21A */ s16 unk_21A; 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 a2a185f3f..ecb47f383 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -391,7 +391,7 @@ s32 func_80BF19A0(EnIg* this, GlobalContext* globalCtx) { if (this->unk_3D0 & 7) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_3D0, 0, 7); + SubS_UpdateFlags(&this->unk_3D0, 0, 7); this->unk_3F6 = 0; this->unk_3F8 = NULL; this->actor.child = this->unk_2A8; @@ -500,7 +500,7 @@ s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if (func_80BF1C44(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AN)) { func_80BF1284(this, 0); - func_8013AED4(&this->unk_3D0, 3, 7); + SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 |= 0x20; this->unk_3D0 |= 0x100; sp2C = true; @@ -593,7 +593,7 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_3D0 &= ~0x8; this->unk_3D0 &= ~0x10; - func_8013AED4(&this->unk_3D0, 3, 7); + SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 |= 0x100; func_80BF1284(this, 2); this->actor.gravity = -1.0f; @@ -629,7 +629,7 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar case 2: this->actor.home.rot.y = this->actor.world.rot.y; this->actor.home.rot.y += 0x8000; - func_8013AED4(&this->unk_3D0, 3, 7); + SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 |= 0x100; func_80BF1284(this, 1); break; @@ -637,7 +637,7 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar case 4: this->actor.world.rot.y += 0x8000; this->actor.shape.rot.y = this->actor.world.rot.y; - func_8013AED4(&this->unk_3D0, 3, 7); + SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 |= 0x100; func_80BF1284(this, 8); break; @@ -800,7 +800,7 @@ s32 func_80BF293C(EnIg* this, GlobalContext* globalCtx) { func_80BF1284(this, 7); } } else if ((this->unk_3FC == 7) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013AED4(&this->unk_3D0, 3, 7); + SubS_UpdateFlags(&this->unk_3D0, 3, 7); func_80BF1284(this, 9); } return true; @@ -865,7 +865,7 @@ void func_80BF2BD4(EnIg* this, GlobalContext* globalCtx) { Vec3f sp2C; if (func_8010BF58(&this->actor, globalCtx, this->unk_298.unk4, this->unk_3F8, &this->unk_298.unk8)) { - func_8013AED4(&this->unk_3D0, 3, 7); + SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 &= ~0x20; this->unk_3D0 |= 0x200; this->unk_3EE = 20; 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 25d015cfa..a7dfc26ac 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -247,7 +247,7 @@ void func_808F3414(EnIn* this, GlobalContext* globalCtx) { if (this->unk23D == 0) { this->unk494 = SkelAnime_Update(&this->skelAnime); } - if (func_8013D5E8(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { + if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { sp30.x = player->actor.world.pos.x; sp30.y = player->bodyPartsPos[7].y + 3.0f; sp30.z = player->actor.world.pos.z; 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 a0160fd08..340c186ef 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -116,7 +116,7 @@ s32 func_80BC19FC(EnJa* this, GlobalContext* globalCtx) { s32 ret = false; if ((this->unk_340 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_340, 0, 7); + SubS_UpdateFlags(&this->unk_340, 0, 7); this->actionFunc = func_80BC22F4; ret = true; } @@ -235,7 +235,7 @@ s32 func_80BC1FC8(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; if (func_80BC1AE0(this, globalCtx)) { - func_8013AED4(&this->unk_340, 3, 7); + SubS_UpdateFlags(&this->unk_340, 3, 7); this->unk_340 |= 0x10; func_80BC192C(this, 5); func_80BC2EA4(this); @@ -253,7 +253,7 @@ s32 func_80BC203C(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } else { func_80BC192C(this, 4); } - func_8013AED4(&this->unk_340, 3, 7); + SubS_UpdateFlags(&this->unk_340, 3, 7); this->actor.shape.shadowDraw = NULL; this->unk_340 |= 0x50; ret = true; @@ -328,7 +328,7 @@ s32* func_80BC2274(EnJa* this, GlobalContext* globalCtx) { void func_80BC22F4(EnJa* this, GlobalContext* globalCtx) { if (func_8010BF58(&this->actor, globalCtx, func_80BC2274(this, globalCtx), this->unk_368, &this->unk_1D8.unk_04)) { this->unk_340 &= ~8; - func_8013AED4(&this->unk_340, 3, 7); + SubS_UpdateFlags(&this->unk_340, 3, 7); this->unk_1D8.unk_04 = 0; this->unk_340 |= 0x10; this->actor.shape.rot.y = this->actor.world.rot.y; @@ -350,7 +350,7 @@ void EnJa_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 0; this->actor.uncullZoneForward = 800.0f; this->actor.gravity = 0.0f; - func_8013AED4(&this->unk_340, 0, 7); + SubS_UpdateFlags(&this->unk_340, 0, 7); this->unk_340 |= 0x10; this->unk_1D8.unk_00 = 0; this->unk_368 = NULL; diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index ea58ac8e0..4781f8828 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -162,7 +162,7 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.rot.z = 0; this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.gravity = 0.0f; - func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->skelAnime.curFrame = Rand_ZeroOne() * this->skelAnime.endFrame; this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); @@ -301,20 +301,20 @@ void func_80B5BB38(Color_RGB8* arg0, Color_RGB8* arg1, f32 arg2) { void func_80B5BDA8(EnOt* this, GlobalContext* globalCtx) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIdx); - func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); this->actionFunc = func_80B5BE04; } void func_80B5BE04(EnOt* this, GlobalContext* globalCtx) { switch (this->unk_388) { case 0: - if (func_8013E2D4(&this->actor, this->cutscenes[2], -1, 0)) { + if (SubS_StartActorCutscene(&this->actor, this->cutscenes[2], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { func_80B5BF60(this, globalCtx); } break; case 1: - if (func_8013E2D4(&this->actor, this->cutscenes[3], -1, 0)) { + if (SubS_StartActorCutscene(&this->actor, this->cutscenes[3], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { func_80B5BF60(this, globalCtx); } break; @@ -591,7 +591,7 @@ void func_80B5CA30(EnOt* this, GlobalContext* globalCtx) { } void func_80B5CAD0(EnOt* this, GlobalContext* globalCtx) { - func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes) / 2); + SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes) / 2); this->actionFunc = func_80B5CB0C; } @@ -626,7 +626,7 @@ void func_80B5CC88(EnOt* this, GlobalContext* globalCtx) { } void func_80B5CCA0(EnOt* this, GlobalContext* globalCtx) { - if (func_8013E2D4(&this->actor, this->cutscenes[0], 0x7C, 1)) { + if (SubS_StartActorCutscene(&this->actor, this->cutscenes[0], 0x7C, SUBS_CUTSCENE_NORMAL)) { Player* player = GET_PLAYER(globalCtx); player->stateFlags2 |= 0x20000000; diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 00fbaa2b2..eeec68405 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -702,7 +702,7 @@ s32 func_80AF86F0(EnPm* this, GlobalContext* globalCtx) { s32 ret = false; if ((this->unk_356 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_356, 0, 7); + SubS_UpdateFlags(&this->unk_356, 0, 7); this->unk_398 = 0; this->unk_378 = 0; this->unk_37C = NULL; @@ -1041,7 +1041,7 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar break; default: - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); func_80AF7E98(this, 0); if (gSaveContext.weekEventReg[90] & 8) { this->unk_356 |= 0x800; @@ -1138,7 +1138,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROOM_CARTAIN); Flags_SetSwitch(globalCtx, 0); this->unk_36C = 20; - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); func_80AF7E98(this, 3); break; @@ -1168,7 +1168,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if (arg2->unk0 == 0x1D) { this->actor.world.rot.y = BINANG_ROT180(this->actor.world.rot.y); } - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 |= 0x9000; func_80AF7E98(this, 3); break; @@ -1197,7 +1197,7 @@ s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->actor.world.pos, &D_80AFB8EC); Math_Vec3s_Copy(&this->actor.world.rot, &D_80AFB8F8); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); this->actor.targetMode = 6; this->actor.gravity = -1.0f; this->unk_368 = 80.0f; @@ -1215,7 +1215,7 @@ s32 func_80AF9A0C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AN)) { - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 |= 0x20; this->unk_356 |= 0x9000; if (this->unk_258 != 0) { @@ -1233,7 +1233,7 @@ s32 func_80AF9AB0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_TEST3)) { - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 |= 0x20; this->unk_356 |= 0x9000; if (this->unk_258 != 0) { @@ -1251,7 +1251,7 @@ s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AL)) { - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 |= 0x9000; this->unk_356 |= 0x20; if (this->unk_258 != 0) { @@ -1552,9 +1552,9 @@ s32 func_80AFA334(EnPm* this, GlobalContext* globalCtx) { case 24: temp_v0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; if (ABS_ALT(temp_v0) < 0x4000) { - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); } else { - func_8013AED4(&this->unk_356, 0, 7); + SubS_UpdateFlags(&this->unk_356, 0, 7); } break; @@ -1723,7 +1723,7 @@ void func_80AFA5FC(EnPm* this, GlobalContext* globalCtx) { Vec3f sp2C; if (func_8010BF58(&this->actor, globalCtx, this->unk_25C, this->unk_37C, &this->unk_264)) { - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 &= ~0x20; this->unk_356 |= 0x200; this->actor.child = NULL; diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index 97f4fd3a5..f8fd33a27 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -757,7 +757,7 @@ void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; this->unk_310 = 8; this->actor.gravity = -1.0f; - func_8013AED4(&this->unk_310, 3, 7); + SubS_UpdateFlags(&this->unk_310, 3, 7); if (!(gSaveContext.weekEventReg[12] & 2)) { this->unk_318 = Rand_S16Offset(30, 30); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 4d928a79a..8dfd6dd35 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -486,7 +486,7 @@ void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { } SkelAnime_Update(&this->skelAnime); if (!(this->flags1 & 4) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { - if (func_8013D5E8(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer) != 0) { + if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer)) { sp30.x = player->actor.world.pos.x; sp30.y = player->bodyPartsPos[7].y + 3.0f; sp30.z = player->actor.world.pos.z; diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index b4982b400..1e7e8f0d1 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -248,7 +248,7 @@ void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.flags |= ACTOR_FLAG_10; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); - func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); switch (this->unk_2B0) { case 4: @@ -711,7 +711,8 @@ void func_80AEDBEC(EnTk* this, GlobalContext* globalCtx) { } void func_80AEDC4C(EnTk* this, GlobalContext* globalCtx) { - if ((this->actor.params >= 0) && func_8013E2D4(&this->actor, this->cutscenes[1], this->actor.params, 0)) { + if ((this->actor.params >= 0) && SubS_StartActorCutscene(&this->actor, this->cutscenes[1], this->actor.params, + SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { this->unk_2E8 = ActorCutscene_GetLength(this->cutscenes[1]); func_80151938(globalCtx, 0x1411); func_80AEDCBC(this, globalCtx); @@ -899,7 +900,7 @@ void func_80AEE2A8(EnTk* this, GlobalContext* globalCtx) { } void func_80AEE2C0(EnTk* this, GlobalContext* globalCtx) { - if (func_8013E2D4(&this->actor, this->cutscenes[0], 0x7C, 0)) { + if (SubS_StartActorCutscene(&this->actor, this->cutscenes[0], 0x7C, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { func_80AEE374(this, globalCtx); } } @@ -995,12 +996,12 @@ void func_80AEE6B8(EnTk* this, GlobalContext* globalCtx) { ActorCutscene_Stop(this->cutscenes[0]); func_801477B4(globalCtx); func_80AEDBEC(this, globalCtx); - } else if (func_8013E2D4(&this->actor, 0x7C, this->cutscenes[0], 0)) { + } else if (SubS_StartActorCutscene(&this->actor, 0x7C, this->cutscenes[0], SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { this->unk_310 = 3; func_80AEDE10(this, globalCtx); this->unk_2CA &= ~0x20; } - } else if (func_8013E2D4(&this->actor, 0x7C, this->cutscenes[0], 0)) { + } else if (SubS_StartActorCutscene(&this->actor, 0x7C, this->cutscenes[0], SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { this->unk_310 = 4; func_80AEDE10(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index 24b3e21ed..a7658263f 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -687,7 +687,7 @@ s32 func_80A872AC(EnTru* this, GlobalContext* globalCtx) { this->unk_390 = 0; this->unk_364 = 0; this->unk_354 = func_80A871E0(this, globalCtx); - func_8013AED4(&this->unk_34E, 0, 7); + SubS_UpdateFlags(&this->unk_34E, 0, 7); this->actionFunc = func_80A881E0; ret = true; } @@ -1048,15 +1048,15 @@ void func_80A87FD0(EnTru* this, GlobalContext* globalCtx) { if (this->actor.draw != NULL) { if ((this->unk_34E & 0x80) || (gSaveContext.weekEventReg[16] & 0x10)) { if (func_80A873B8(this)) { - func_8013AED4(&this->unk_34E, 3, 7); + SubS_UpdateFlags(&this->unk_34E, 3, 7); } else { - func_8013AED4(&this->unk_34E, 0, 7); + SubS_UpdateFlags(&this->unk_34E, 0, 7); } } else if (this->unk_34E & 0x40) { if (func_80A873B8(this)) { - func_8013AED4(&this->unk_34E, 3, 7); + SubS_UpdateFlags(&this->unk_34E, 3, 7); } else { - func_8013AED4(&this->unk_34E, 0, 7); + SubS_UpdateFlags(&this->unk_34E, 0, 7); } if ((this->unk_37C == 2) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -1070,13 +1070,13 @@ void func_80A87FD0(EnTru* this, GlobalContext* globalCtx) { } } else if (!(gSaveContext.weekEventReg[16] & 0x10) && (fabsf(this->actor.playerHeightRel) < 10.0f) && (this->actor.xzDistToPlayer < 140.0f)) { - func_8013AED4(&this->unk_34E, 4, 7); + SubS_UpdateFlags(&this->unk_34E, 4, 7); this->unk_34E |= 0x1040; this->unk_362 = Rand_S16Offset(40, 20); } else if (func_80A873B8(this)) { - func_8013AED4(&this->unk_34E, 3, 7); + SubS_UpdateFlags(&this->unk_34E, 3, 7); } else { - func_8013AED4(&this->unk_34E, 0, 7); + SubS_UpdateFlags(&this->unk_34E, 0, 7); } } } @@ -1102,7 +1102,7 @@ void func_80A881E0(EnTru* this, GlobalContext* globalCtx) { func_80A86924(this, 6); } - func_8013AED4(&this->unk_34E, 0, 7); + SubS_UpdateFlags(&this->unk_34E, 0, 7); this->unk_34E &= ~(0x1000 | 0x8); this->unk_34E |= 0x10; this->actor.shape.rot.y = this->actor.world.rot.y; diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 34bff63c2..3a9872406 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -179,7 +179,7 @@ void EnZo_LookAtPlayer(EnZo* this, GlobalContext* globalCtx) { Vec3f focus; SkelAnime_Update(&this->skelAnime); - if (func_8013D5E8(this->actor.shape.rot.y, 10000, this->actor.yawTowardsPlayer)) { + if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { focus.x = player->actor.world.pos.x; focus.y = player->bodyPartsPos[7].y + 3.0f; focus.z = player->actor.world.pos.z; diff --git a/tools/actorfixer.py b/tools/actorfixer.py index fc71f78bf..a94f2b941 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -396,6 +396,12 @@ animdict = { "func_80114E90": "Interface_HasEmptyBottle", "func_80114F2C": "Interface_HasItemInBottle", "func_80123C90": "Player_SetEquipmentData", + "func_8013E2D4": "SubS_StartActorCutscene", + "func_8013E3B8": "SubS_FillCutscenesList", + "func_8013AED4": "SubS_UpdateFlags", + "func_8013D8DC": "SubS_IsObjectLoaded", + "func_8013D924": "SubS_GetObjectIndex", + "func_8013D5E8": "SubS_AngleDiffLessEqual", "func_8012F22C": "Inventory_GetSkullTokenCount", # Structs members diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 6e5820303..73e654dfe 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2660,7 +2660,7 @@ 0x8013AB00:("SubS_DrawTransformFlex",), 0x8013AD6C:("func_8013AD6C",), 0x8013AD9C:("func_8013AD9C",), - 0x8013AED4:("func_8013AED4",), + 0x8013AED4:("SubS_UpdateFlags",), 0x8013AF00:("func_8013AF00",), 0x8013B010:("func_8013B010",), 0x8013B0C8:("func_8013B0C8",), @@ -2681,14 +2681,14 @@ 0x8013CF04:("func_8013CF04",), 0x8013D0E0:("func_8013D0E0",), 0x8013D2E0:("func_8013D2E0",), - 0x8013D5E8:("func_8013D5E8",), + 0x8013D5E8:("SubS_AngleDiffLessEqual",), 0x8013D648:("func_8013D648",), 0x8013D68C:("func_8013D68C",), 0x8013D720:("func_8013D720",), 0x8013D768:("func_8013D768",), 0x8013D83C:("func_8013D83C",), - 0x8013D8DC:("func_8013D8DC",), - 0x8013D924:("func_8013D924",), + 0x8013D8DC:("SubS_IsObjectLoaded",), + 0x8013D924:("SubS_GetObjectIndex",), 0x8013D960:("SubS_FindActor",), 0x8013D9C8:("SubS_FillLimbRotTables",), 0x8013DB90:("func_8013DB90",), @@ -2701,8 +2701,8 @@ 0x8013E07C:("func_8013E07C",), 0x8013E0A4:("func_8013E0A4",), 0x8013E1C8:("SubS_ChangeAnimationBySpeedInfo",), - 0x8013E2D4:("func_8013E2D4",), - 0x8013E3B8:("func_8013E3B8",), + 0x8013E2D4:("SubS_StartActorCutscene",), + 0x8013E3B8:("SubS_FillCutscenesList",), 0x8013E4B0:("func_8013E4B0",), 0x8013E5CC:("func_8013E5CC",), 0x8013E640:("SubS_FindActorCustom",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index aeea6d9ae..df41d4829 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2174,7 +2174,7 @@ asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlexLimb.s,SubS_DrawTransformFl asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlex.s,SubS_DrawTransformFlex,0x8013AB00,0x9B asm/non_matchings/code/z_sub_s/func_8013AD6C.s,func_8013AD6C,0x8013AD6C,0xC asm/non_matchings/code/z_sub_s/func_8013AD9C.s,func_8013AD9C,0x8013AD9C,0x4E -asm/non_matchings/code/z_sub_s/func_8013AED4.s,func_8013AED4,0x8013AED4,0xB +asm/non_matchings/code/z_sub_s/SubS_UpdateFlags.s,SubS_UpdateFlags,0x8013AED4,0xB asm/non_matchings/code/z_sub_s/func_8013AF00.s,func_8013AF00,0x8013AF00,0x44 asm/non_matchings/code/z_sub_s/func_8013B010.s,func_8013B010,0x8013B010,0x2E asm/non_matchings/code/z_sub_s/func_8013B0C8.s,func_8013B0C8,0x8013B0C8,0xA2 @@ -2195,14 +2195,14 @@ asm/non_matchings/code/z_sub_s/func_8013CD64.s,func_8013CD64,0x8013CD64,0x68 asm/non_matchings/code/z_sub_s/func_8013CF04.s,func_8013CF04,0x8013CF04,0x77 asm/non_matchings/code/z_sub_s/func_8013D0E0.s,func_8013D0E0,0x8013D0E0,0x80 asm/non_matchings/code/z_sub_s/func_8013D2E0.s,func_8013D2E0,0x8013D2E0,0xC2 -asm/non_matchings/code/z_sub_s/func_8013D5E8.s,func_8013D5E8,0x8013D5E8,0x18 +asm/non_matchings/code/z_sub_s/SubS_AngleDiffLessEqual.s,SubS_AngleDiffLessEqual,0x8013D5E8,0x18 asm/non_matchings/code/z_sub_s/func_8013D648.s,func_8013D648,0x8013D648,0x11 asm/non_matchings/code/z_sub_s/func_8013D68C.s,func_8013D68C,0x8013D68C,0x25 asm/non_matchings/code/z_sub_s/func_8013D720.s,func_8013D720,0x8013D720,0x12 asm/non_matchings/code/z_sub_s/func_8013D768.s,func_8013D768,0x8013D768,0x35 asm/non_matchings/code/z_sub_s/func_8013D83C.s,func_8013D83C,0x8013D83C,0x28 -asm/non_matchings/code/z_sub_s/func_8013D8DC.s,func_8013D8DC,0x8013D8DC,0x12 -asm/non_matchings/code/z_sub_s/func_8013D924.s,func_8013D924,0x8013D924,0xF +asm/non_matchings/code/z_sub_s/SubS_IsObjectLoaded.s,SubS_IsObjectLoaded,0x8013D8DC,0x12 +asm/non_matchings/code/z_sub_s/SubS_GetObjectIndex.s,SubS_GetObjectIndex,0x8013D924,0xF asm/non_matchings/code/z_sub_s/SubS_FindActor.s,SubS_FindActor,0x8013D960,0x1A asm/non_matchings/code/z_sub_s/SubS_FillLimbRotTables.s,SubS_FillLimbRotTables,0x8013D9C8,0x72 asm/non_matchings/code/z_sub_s/func_8013DB90.s,func_8013DB90,0x8013DB90,0x2C @@ -2215,8 +2215,8 @@ asm/non_matchings/code/z_sub_s/func_8013E054.s,func_8013E054,0x8013E054,0xA asm/non_matchings/code/z_sub_s/func_8013E07C.s,func_8013E07C,0x8013E07C,0xA asm/non_matchings/code/z_sub_s/func_8013E0A4.s,func_8013E0A4,0x8013E0A4,0x49 asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationBySpeedInfo.s,SubS_ChangeAnimationBySpeedInfo,0x8013E1C8,0x43 -asm/non_matchings/code/z_sub_s/func_8013E2D4.s,func_8013E2D4,0x8013E2D4,0x39 -asm/non_matchings/code/z_sub_s/func_8013E3B8.s,func_8013E3B8,0x8013E3B8,0x3E +asm/non_matchings/code/z_sub_s/SubS_StartActorCutscene.s,SubS_StartActorCutscene,0x8013E2D4,0x39 +asm/non_matchings/code/z_sub_s/SubS_FillCutscenesList.s,SubS_FillCutscenesList,0x8013E3B8,0x3E asm/non_matchings/code/z_sub_s/func_8013E4B0.s,func_8013E4B0,0x8013E4B0,0x47 asm/non_matchings/code/z_sub_s/func_8013E5CC.s,func_8013E5CC,0x8013E5CC,0x1D asm/non_matchings/code/z_sub_s/SubS_FindActorCustom.s,SubS_FindActorCustom,0x8013E640,0x42 From fa069535d0fe06966dec592c592b8a292aef0628 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sun, 20 Feb 2022 11:33:47 +1100 Subject: [PATCH 046/257] Camera Preparation (#644) * Copy progress from z_camera * cleanup functions.h * Oops * Revert `SUB16` and `ADD16` back to original names * PR Suggestions * PR Suggestions * Fix merge with master --- include/functions.h | 39 +++--- include/macros.h | 3 +- include/z64.h | 16 +-- include/z64bgcheck.h | 8 +- include/z64scene.h | 12 +- src/code/sys_math3d.c | 2 +- src/code/z_actor.c | 6 +- src/code/z_bgcheck.c | 12 +- src/code/z_camera.c | 14 +-- src/code/z_effect_soft_sprite.c | 9 +- src/code/z_fireobj.c | 2 +- src/code/z_kaleido_scope_call.c | 1 + src/code/z_lib.c | 2 +- src/code/z_olib.c | 2 +- src/code/z_play.c | 26 ++-- src/code/z_quake.c | 6 +- src/code/z_scene.c | 6 +- src/code/z_shrink_window.c | 1 + src/code/z_snap.c | 8 +- .../actors/ovl_Arms_Hook/z_arms_hook.c | 6 +- .../ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c | 2 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 22 ++-- src/overlays/actors/ovl_Boss_04/z_boss_04.c | 10 +- src/overlays/actors/ovl_Boss_06/z_boss_06.c | 6 +- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 2 +- src/overlays/actors/ovl_Door_Ana/z_door_ana.c | 2 +- .../actors/ovl_Door_Shutter/z_door_shutter.c | 2 +- src/overlays/actors/ovl_En_Al/z_en_al.c | 5 +- src/overlays/actors/ovl_En_Ani/z_en_ani.c | 4 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 28 ++--- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 16 +-- .../ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c | 8 +- .../actors/ovl_En_Bomjima/z_en_bomjima.c | 4 +- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.c | 38 +++--- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.h | 6 +- .../actors/ovl_En_Dinofos/z_en_dinofos.c | 62 +++++----- .../actors/ovl_En_Dinofos/z_en_dinofos.h | 2 +- .../actors/ovl_En_Fishing/z_en_fishing.c | 46 +++---- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 11 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 9 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 2 +- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 6 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 4 +- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 16 +-- .../actors/ovl_En_Kendo_Js/z_en_kendo_js.c | 3 +- .../actors/ovl_En_Minifrog/z_en_minifrog.c | 8 +- src/overlays/actors/ovl_En_Niw/z_en_niw.c | 18 +-- src/overlays/actors/ovl_En_Ot/z_en_ot.c | 10 +- .../actors/ovl_En_Pamera/z_en_pamera.c | 6 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 114 +++++++++--------- .../actors/ovl_En_Pametfrog/z_en_pametfrog.h | 2 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 10 +- .../ovl_En_Po_Sisters/z_en_po_sisters.c | 2 +- src/overlays/actors/ovl_En_Poh/z_en_poh.c | 5 +- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 2 +- .../ovl_En_Water_Effect/z_en_water_effect.c | 4 +- src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c | 2 +- .../actors/ovl_Obj_Funen/z_obj_funen.c | 2 +- .../actors/ovl_Obj_Kinoko/z_obj_kinoko.c | 2 +- .../actors/ovl_Obj_Syokudai/z_obj_syokudai.c | 3 +- .../ovl_Object_Kankyo/z_object_kankyo.c | 10 +- tools/actorfixer.py | 25 ++++ tools/disasm/functions.txt | 44 +++---- tools/sizes/code_functions.csv | 42 +++---- 64 files changed, 424 insertions(+), 384 deletions(-) diff --git a/include/functions.h b/include/functions.h index ba72e093f..f65278671 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1140,13 +1140,13 @@ s32 Camera_ChangeMode(Camera* camera, s16 mode); // void func_800DF86C(void); // void func_800DF8EC(void); s32 func_800DFAC8(Camera* camera, s16 param_2); -u32 func_800DFB14(Camera* camera, u32 param_2); +u32 Camera_ChangeDataIdx(Camera* camera, u32 camDataIdx); // void func_800DFC1C(void); // void func_800DFC40(void); -s32 func_800DFC68(Camera* camera); +s32 Camera_GetInputDirYaw(Camera* camera); // void func_800DFC90(void); -s16 func_800DFCB4(Camera* camera); -s16 func_800DFCDC(Camera* camera); +s16 Camera_GetCamDirPitch(Camera* camera); +s16 Camera_GetCamDirYaw(Camera* camera); void func_800DFD04(Camera* camera, s32 arg1, s32 arg2, s32 arg3); // void func_800DFD78(void); // UNK_TYPE4 func_800DFEF0(s32 param_1, u16 param_2); @@ -1162,9 +1162,9 @@ s32 func_800DFFAC(Camera* camera, Actor* doorActor, s16 bgCamDataId, f32 arg3, s // void func_800E01DC(s32 param_1, u32 param_2, UNK_TYPE4 param_3, UNK_TYPE4 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6); // UNK_TYPE4 func_800E0228(void); // void func_800E0238(void); -void func_800E02AC(Camera* camera, Actor* actor); -void func_800E0308(Camera* camera, Actor* actor); -f32 func_800E031C(Camera* camera); +void Camera_SetToTrackActor(Camera* camera, Actor* actor); +void Camera_SetTargetActor(Camera* camera, Actor* actor); +f32 Camera_GetWaterYPos(Camera* camera); void func_800E0348(Camera* camera); DamageTable* DamageTable_Get(s32 index); void DamageTable_Clear(DamageTable* damageTable); @@ -2838,22 +2838,21 @@ void func_8016927C(GlobalContext* globalCtx, s16 sParm2); // void func_801692C4(GlobalContext* globalCtx, UNK_TYPE1 uParm2); // void Play_SceneInit(GlobalContext* globalCtx, s32 sceneIndex, UNK_TYPE1 param_3); UNK_RET func_80169474(GlobalContext* globalCtx, Vec3f* v1, Vec3f* v2); -s32 func_801694DC(GlobalContext* globalCtx); -s32 Play_GetActiveCameraIndex(GlobalContext* globalCtx); -void func_80169590(GlobalContext* globalCtx, s16 param_2, s16 param_3); -void func_80169600(GlobalContext* globalCtx, s16 param_2); -// void func_80169668(void); +s32 Play_CreateSubCamera(GlobalContext* globalCtx); +s32 Play_GetActiveCamId(GlobalContext* globalCtx); +void Play_CameraChangeStatus(GlobalContext* globalCtx, s16 camId, s16 status); +void Play_ClearCamera(GlobalContext* globalCtx, s16 camId); Camera* Play_GetCamera(GlobalContext* globalCtx, s16 index); s32 Play_CameraSetAtEye(GlobalContext* globalCtx, s16 camId, Vec3f* at, Vec3f* eye); -void func_8016981C(GlobalContext* globalCtx, s16 arg1, Vec3f* arg2, Vec3f* arg3, Vec3f* arg4); -void func_80169940(GlobalContext* globalCtx, s16 camId, f32 arg2); -// void func_80169988(void); -void func_801699D4(GlobalContext* globalCtx, s16 arg1, s16 arg2); +void Play_CameraSetAtEyeUp(GlobalContext* globalCtx, s16 camId, Vec3f* at, Vec3f* eye, Vec3f* up); +void Play_CameraSetFov(GlobalContext* globalCtx, s16 camId, f32 fov); +void Play_CameraSetRoll(GlobalContext* globalCtx, s16 camId, s16 roll); +void Play_CopyCamera(GlobalContext* globalCtx, s16 dstCamId, s16 srcCamId); // void func_80169A50(void); -// void func_80169AC0(void); +void Play_CameraChangeSetting(GlobalContext* globalCtx, s16 camId, s16 setting); void func_80169AFC(GlobalContext* globalCtx, s16 camId, s16 arg2); -// void func_80169C64(void); -// void func_80169C84(void); +s16 Play_GetCsCamDataSetting(GlobalContext* globalCtx, s32 camId); +Vec3s* Play_GetCsCamDataVec3s(GlobalContext* globalCtx, s32 camId); s16 convert_scene_number_among_shared_scenes(s16 arg0); void func_80169D40(GlobalContext* globalCtx); void func_80169DCC(GlobalContext* globalCtx, s32 arg1, u16 arg2, s32 arg3, s32 arg4, Vec3f* arg5, s16 arg6); @@ -3149,7 +3148,7 @@ s32 Math3D_TriChkPointParaZIntersect(Vec3f* a, Vec3f* b, Vec3f* c, f32 nx, f32 n s32 Math3D_TriChkLineSegParaZIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 x, f32 y, f32* zIntersect, f32 z0, f32 z1); // void func_8017D1AC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); // void func_8017D220(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8017D2FC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); +s32 Math3D_LineSegVsPlane(f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersect, s32 fromFront); // void func_8017D404(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); void Math3D_TriSetCoords(TriNorm* tri, Vec3f* pointA, Vec3f* pointB, Vec3f* pointC); u32 Math3D_IsPointInSphere(Sphere16* sphere, Vec3f* point); diff --git a/include/macros.h b/include/macros.h index 081f6a487..c5a3a061d 100644 --- a/include/macros.h +++ b/include/macros.h @@ -21,8 +21,7 @@ #define SEGMENTED_TO_VIRTUAL(addr) (void*)(PHYSICAL_TO_VIRTUAL(gSegments[SEGMENT_NUMBER(addr)]) + SEGMENT_OFFSET(addr)) #define GET_ACTIVE_CAM(globalCtx) ((globalCtx)->cameraPtrs[(globalCtx)->activeCamera]) -#define MAIN_CAM 0 -#define SUBCAM_FREE 0 +#define CAM_ID_MAIN 0 #define SET_NEXT_GAMESTATE(curState, newInit, newStruct) \ (curState)->nextGameStateInit = (GameStateFunc)newInit; \ diff --git a/include/z64.h b/include/z64.h index 610b03d13..44d4f6ab4 100644 --- a/include/z64.h +++ b/include/z64.h @@ -67,7 +67,7 @@ typedef struct { /* 0x0 */ s16 priority; // Lower means higher priority. -1 means it ignores priority /* 0x2 */ s16 length; - /* 0x4 */ s16 unk4; + /* 0x4 */ s16 csCamSceneDataId; // Index of CsCameraEntry to use. Negative indices use sGlobalCamDataSettings. Indices 0 and above use CsCameraEntry from scene /* 0x6 */ s16 unk6; /* 0x8 */ s16 additionalCutscene; /* 0xA */ u8 sound; @@ -119,8 +119,8 @@ typedef struct { /* 0x18 */ u16 unk_18; /* 0x1A */ u8 unk_1A; /* 0x1B */ u8 unk_1B; - /* 0x1C */ CutsceneCameraPoint* cameraFocus; - /* 0x20 */ CutsceneCameraPoint* cameraPosition; + /* 0x1C */ CutsceneCameraPoint* atPoints; + /* 0x20 */ CutsceneCameraPoint* eyePoints; /* 0x24 */ CsCmdActorAction* linkAction; /* 0x28 */ CsCmdActorAction* npcActions[10]; // "npcdemopnt" /* 0x50 */ CutsceneEntry* sceneCsList; @@ -718,8 +718,8 @@ typedef struct { /* 0x12 */ u8 unk_12; /* 0x13 */ u8 unk_13; /* 0x14 */ u8 unk_14; - /* 0x15 */ u8 unk_15; - /* 0x16 */ u8 unk_16; + /* 0x15 */ u8 skyboxDisabled; + /* 0x16 */ u8 sunMoonDisabled; /* 0x17 */ u8 unk_17; /* 0x18 */ u8 unk_18; /* 0x19 */ u8 unk_19; @@ -1071,7 +1071,7 @@ typedef struct Camera { /* 0x15E */ s16 animState; /* 0x160 */ s16 unk160; /* 0x162 */ s16 timer; - /* 0x164 */ s16 thisIdx; + /* 0x164 */ s16 camId; /* 0x166 */ s16 prevCamDataIdx; /* 0x168 */ s16 unk168; /* 0x16A */ s16 unk16A; @@ -1100,7 +1100,7 @@ typedef struct { /* 0x1A */ s16 speed; /* 0x1C */ s16 isShakePerpendicular; /* 0x1E */ s16 countdown; - /* 0x20 */ s16 cameraPtrsIdx; + /* 0x20 */ s16 camId; } QuakeRequest; // size = 0x24 typedef struct { @@ -1324,7 +1324,7 @@ struct GlobalContext { /* 0x1884C */ RomFile* roomList; /* 0x18850 */ ActorEntry* linkActorEntry; /* 0x18854 */ ActorEntry* setupActorList; - /* 0x18858 */ void* unk_18858; + /* 0x18858 */ CsCamData* csCamData; /* 0x1885C */ EntranceEntry* setupEntranceList; /* 0x18860 */ u16* setupExitList; /* 0x18864 */ Path* setupPathList; diff --git a/include/z64bgcheck.h b/include/z64bgcheck.h index 55429a433..0a5afb3d9 100644 --- a/include/z64bgcheck.h +++ b/include/z64bgcheck.h @@ -89,10 +89,10 @@ typedef struct CollisionPoly { } CollisionPoly; // size = 0x10 typedef struct { - /* 0x00 */ u16 cameraSType; - /* 0x02 */ s16 unk_02; - /* 0x04 */ Vec3s* camPosData; -} CamData; + /* 0x0 */ u16 setting; + /* 0x2 */ s16 numData; + /* 0x4 */ Vec3s* data; +} CamData; // size = 0x8 (BgCamData) typedef struct { /* 0x0 */ Vec3s minPos; diff --git a/include/z64scene.h b/include/z64scene.h index 8d301d1d1..c2836c548 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -290,7 +290,7 @@ typedef struct { typedef struct { struct { s8 room; // Room to switch to - s8 effects; // How the camera reacts during the transition + s8 bgCamDataId; // How the camera reacts during the transition. -2 for spiral staircase. -1 for generic door. 0+ will index scene CamData } /* 0x00 */ sides[2]; // 0 = front, 1 = back /* 0x04 */ s16 id; /* 0x06 */ Vec3s pos; @@ -496,10 +496,12 @@ typedef struct { } MinimapChest; // size = 0xA typedef struct { - /* 0x00 */ s16 type; - /* 0x00 */ s16 numPoints; - /* 0x00 */ Vec3s* points; -} CsCameraEntry; + /* 0x0 */ s16 setting; + /* 0x2 */ s16 numData; + /* 0x4 */ Vec3s* data; +} CsCamData; // size = 0x8 + +typedef CsCamData CsCameraEntry; // TODO: Remove once ZAPD updates its structs typedef union { /* Command: N/A */ SCmdBase base; diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c index d676a437c..45b94d569 100644 --- a/src/code/sys_math3d.c +++ b/src/code/sys_math3d.c @@ -130,7 +130,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017D220.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017D2FC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_LineSegVsPlane.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017D404.s") diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 308fc9c1b..064ee0a88 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1279,7 +1279,7 @@ f32 Actor_HeightDiff(Actor* actor1, Actor* actor2) { * Sets the current and new inputs. */ void func_800B6F20(GlobalContext* globalCtx, Input* input, f32 magnitude, s16 baseYaw) { - s16 relativeYaw = baseYaw - func_800DFC68(GET_ACTIVE_CAM(globalCtx)); + s16 relativeYaw = baseYaw - Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); input->cur.stick_x = -Math_SinS(relativeYaw) * magnitude; input->rel.stick_x = input->cur.stick_x; @@ -1341,7 +1341,7 @@ void Actor_SetCameraHorseSetting(GlobalContext* globalCtx, Player* player) { EnHorse* rideActor = (EnHorse*)player->rideActor; if ((rideActor != NULL) && !(rideActor->unk_1EC & 0x10)) { - func_800DFAC8(Play_GetCamera(globalCtx, MAIN_CAM), 4); + func_800DFAC8(Play_GetCamera(globalCtx, CAM_ID_MAIN), 4); } } } @@ -3329,7 +3329,7 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalC if ((player != NULL) && (actor == player->unk_730)) { func_80123DA4(player); - Camera_ChangeMode(Play_GetCamera(globalCtx, Play_GetActiveCameraIndex(globalCtx)), 0); + Camera_ChangeMode(Play_GetCamera(globalCtx, Play_GetActiveCamId(globalCtx)), 0); } if (actor == actorCtx->targetContext.arrowPointedActor) { diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 7fa1b755b..3f5583f79 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -4047,7 +4047,7 @@ u16 func_800C9728(CollisionContext* colCtx, u32 camId, s32 bgId) { return 0; } camData = colHeader->cameraDataList; - result = camData[camId].cameraSType; + result = camData[camId].setting; return result; } @@ -4088,7 +4088,7 @@ u16 func_800C97F8(CollisionContext* colCtx, u32 camId, s32 bgId) { if (camData == NULL) { return 0; } - return camData[camId].unk_02; + return camData[camId].numData; } /** @@ -4114,7 +4114,7 @@ u16 func_800C9844(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { } /** - * CamData get camPosData + * CamData get data */ Vec3s* func_800C98CC(CollisionContext* colCtx, s32 camId, s32 bgId) { CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); @@ -4127,11 +4127,11 @@ Vec3s* func_800C98CC(CollisionContext* colCtx, s32 camId, s32 bgId) { if (cameraDataList == NULL) { return NULL; } - return Lib_SegmentedToVirtual(cameraDataList[camId].camPosData); + return Lib_SegmentedToVirtual(cameraDataList[camId].data); } /** - * SurfaceType Get camPosData + * SurfaceType Get data */ Vec3s* SurfaceType_GetCamPosData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); @@ -4573,7 +4573,7 @@ u16 WaterBox_GetCameraSetting(CollisionContext* colCtx, WaterBox* waterBox, s32 return result; } - result = camData[camId].cameraSType; + result = camData[camId].setting; return result; } diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 1e983c954..9aef846e0 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -320,19 +320,19 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFAC8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFB14.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ChangeDataIdx.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFC1C.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFC40.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFC68.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetInputDirYaw.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFC90.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFCB4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetCamDirPitch.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFCDC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetCamDirYaw.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFD04.s") @@ -364,10 +364,10 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E0238.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E02AC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_SetToTrackActor.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E0308.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_SetTargetActor.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E031C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetWaterYPos.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E0348.s") diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index 11545da01..43307bbc8 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -255,9 +255,12 @@ void EffectSS_DrawAllParticles(GlobalContext* globalCtx) { for (i = 0; i < sEffectSsInfo.size; i++) { if (sEffectSsInfo.data_table[i].life > -1) { - if ((sEffectSsInfo.data_table[i].pos.x > 32000.0f) || (sEffectSsInfo.data_table[i].pos.x < -32000.0f) || - (sEffectSsInfo.data_table[i].pos.y > 32000.0f) || (sEffectSsInfo.data_table[i].pos.y < -32000.0f) || - (sEffectSsInfo.data_table[i].pos.z > 32000.0f) || (sEffectSsInfo.data_table[i].pos.z < -32000.0f)) { + if ((sEffectSsInfo.data_table[i].pos.x > BGCHECK_Y_MAX) || + (sEffectSsInfo.data_table[i].pos.x < BGCHECK_Y_MIN) || + (sEffectSsInfo.data_table[i].pos.y > BGCHECK_Y_MAX) || + (sEffectSsInfo.data_table[i].pos.y < BGCHECK_Y_MIN) || + (sEffectSsInfo.data_table[i].pos.z > BGCHECK_Y_MAX) || + (sEffectSsInfo.data_table[i].pos.z < BGCHECK_Y_MIN)) { EffectSS_Delete(&sEffectSsInfo.data_table[i]); } else { EffectSS_DrawParticle(globalCtx, i); diff --git a/src/code/z_fireobj.c b/src/code/z_fireobj.c index 02644818f..c6b6a3f9c 100644 --- a/src/code/z_fireobj.c +++ b/src/code/z_fireobj.c @@ -157,7 +157,7 @@ void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { gDPSetEnvColor(POLY_XLU_DISP++, lightParams->envColor.r, lightParams->envColor.g, lightParams->envColor.b, 0); vec.x = 0; - vec.y = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x8000; + vec.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000; vec.z = 0; Matrix_SetStateRotationAndTranslation(fire->position.x, fire->position.y, fire->position.z, &vec); Matrix_Scale(fire->xScale, fire->yScale, 1.0f, MTXMODE_APPLY); diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index b6d46eba1..c3c616669 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" void (*sKaleidoScopeUpdateFunc)(GlobalContext* globalCtx); diff --git a/src/code/z_lib.c b/src/code/z_lib.c index 84eb8c051..d9300deda 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -371,7 +371,7 @@ void Math_Vec3f_DistXYZAndStoreNormDiff(Vec3f* a, Vec3f* b, f32 scale, Vec3f* de f32 Math_Vec3f_DistXYZ(Vec3f* a, Vec3f* b) { Vec3f diff; Math_Vec3f_Diff(b, a, &diff); - return sqrtf(SQ(diff.x) + SQ(diff.y) + SQ(diff.z)); + return sqrtf(SQXYZ(diff)); } f32 Math_Vec3f_DistXYZAndStoreDiff(Vec3f* a, Vec3f* b, Vec3f* dest) { diff --git a/src/code/z_olib.c b/src/code/z_olib.c index c44fac276..6f1cdbc55 100644 --- a/src/code/z_olib.c +++ b/src/code/z_olib.c @@ -66,7 +66,7 @@ Vec3f* OLib_Vec3fDistNormalize(Vec3f* dest, Vec3f* a, Vec3f* b) { v1.y = b->y - a->y; v1.z = b->z - a->z; - dist = OLib_ClampMinDist(sqrtf(SQ(v1.x) + SQ(v1.y) + SQ(v1.z)), 0.01f); + dist = OLib_ClampMinDist(sqrtf(SQXYZ(v1)), 0.01f); v2.x = v1.x / dist; v2.y = v1.y / dist; diff --git a/src/code/z_play.c b/src/code/z_play.c index 7e0e018c7..a14359be7 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -74,41 +74,41 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169474.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_801694DC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CreateSubCamera.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetActiveCameraIndex.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetActiveCamId.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169590.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraChangeStatus.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169600.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_ClearCamera.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169668.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_ClearAllSubCameras.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetCamera.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraSetAtEye.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016981C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraSetAtEyeUp.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169940.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraSetFov.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169988.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraSetRoll.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_801699D4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CopyCamera.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169A50.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169AC0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraChangeSetting.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169AFC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169BC4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraGetUID.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169BF8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169C64.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetCsCamDataSetting.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169C84.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetCsCamDataVec3s.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/convert_scene_number_among_shared_scenes.s") diff --git a/src/code/z_quake.c b/src/code/z_quake.c index d38746bf4..ee4fa3a6d 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -137,7 +137,7 @@ QuakeRequest* Quake_AddImpl(Camera* camera, u32 callbackIdx) { __osMemset(req, 0, sizeof(QuakeRequest)); req->camera = camera; - req->cameraPtrsIdx = camera->thisIdx; + req->camId = camera->camId; req->callbackIdx = callbackIdx; req->isShakePerpendicular = true; req->randIdx = ((s16)(Rand_ZeroOne() * (f32)0x10000) & ~3) + idx; @@ -326,10 +326,10 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { for (idx = 0; idx < ARRAY_COUNT(sQuakeRequest); idx++) { req = &sQuakeRequest[idx]; if (req->callbackIdx != 0) { - if (globalCtx->cameraPtrs[req->cameraPtrsIdx] == NULL) { + if (globalCtx->cameraPtrs[req->camId] == NULL) { Quake_Remove(req); } else { - eq = (camera->thisIdx != req->camera->thisIdx); + eq = (camera->camId != req->camera->camId); absSpeedDiv = ABS(req->speed) / (f32)0x8000; if (sQuakeCallbacks[req->callbackIdx](req, &shake) == 0) { Quake_Remove(req); diff --git a/src/code/z_scene.c b/src/code/z_scene.c index ce75624d3..6e4793661 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -179,7 +179,7 @@ void Scene_HeaderCmdActorList(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x02: List of cameras for actor cutscenes void Scene_HeaderCmdActorCutsceneCamList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->unk_18858 = (UNK_PTR)Lib_SegmentedToVirtual(cmd->csCameraList.segment); + globalCtx->csCamData = Lib_SegmentedToVirtual(cmd->csCameraList.segment); } // SceneTableEntry Header Command 0x03: Collision Header @@ -374,8 +374,8 @@ void Scene_HeaderCmdSkyboxSettings(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x12: Skybox Disables void Scene_HeaderCmdSkyboxDisables(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->envCtx.unk_15 = cmd->skyboxDisables.unk4; - globalCtx->envCtx.unk_16 = cmd->skyboxDisables.unk5; + globalCtx->envCtx.skyboxDisabled = cmd->skyboxDisables.unk4; + globalCtx->envCtx.sunMoonDisabled = cmd->skyboxDisables.unk5; } // SceneTableEntry Header Command 0x10: Time Settings diff --git a/src/code/z_shrink_window.c b/src/code/z_shrink_window.c index 194ee5083..5bfca86d9 100644 --- a/src/code/z_shrink_window.c +++ b/src/code/z_shrink_window.c @@ -2,6 +2,7 @@ * File: z_shrink_window.c * Description: Draws black top/bottom/side borders on the viewing window (e.g. Z-targeting, talking to NPC) */ +#include "prevent_bss_reordering.h" #include "global.h" ShrinkWindowContext gShrinkWindowContext; diff --git a/src/code/z_snap.c b/src/code/z_snap.c index 639505aec..bce1f67d7 100644 --- a/src/code/z_snap.c +++ b/src/code/z_snap.c @@ -114,21 +114,19 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, s16 y; f32 distance; CollisionPoly* poly; - Camera* camera; + Camera* camera = GET_ACTIVE_CAM(globalCtx); Actor* actors[2]; s32 ret = 0; s32 bgId; - camera = GET_ACTIVE_CAM(globalCtx); - distance = OLib_Vec3fDist(pos, &camera->eye); if ((distance < distanceMin) || (distanceMax < distance)) { func_8013A41C(0x3F); ret = 0x3F; } - x = func_8013A504(func_800DFCB4(camera) + rot->x); - y = func_8013A504(func_800DFCDC(camera) - (s16)(rot->y - 0x7FFF)); + x = func_8013A504(Camera_GetCamDirPitch(camera) + rot->x); + y = func_8013A504(Camera_GetCamDirYaw(camera) - BINANG_SUB(rot->y, 0x7FFF)); if ((0 < angleError) && ((angleError < x) || (angleError < y))) { func_8013A41C(0x3E); ret |= 0x3E; diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index 9c6bae33b..009405238 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -170,7 +170,8 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { } else { if (this->actor.child != NULL) { f32 sp94 = Actor_DistanceBetweenActors(&this->actor, grabbed); - f32 sp90 = sqrtf(SQ(this->unk1FC.x) + SQ(this->unk1FC.y) + SQ(this->unk1FC.z)); + f32 sp90 = sqrtf(SQXYZ(this->unk1FC)); + Math_Vec3f_Diff(&grabbed->world.pos, &this->unk1FC, &this->actor.world.pos); if (50.0f < (sp94 - sp90)) { ArmsHook_DetachHookFromActor(this); @@ -217,8 +218,7 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { } } else { Math_Vec3f_Diff(&bodyDistDiffVec, &newPos, &player->actor.velocity); - player->actor.world.rot.x = - Math_FAtan2F(sqrtf(SQ(bodyDistDiffVec.x) + SQ(bodyDistDiffVec.z)), -bodyDistDiffVec.y); + player->actor.world.rot.x = Math_FAtan2F(sqrtf(SQXZ(bodyDistDiffVec)), -bodyDistDiffVec.y); } if (phi_f16 < 50.0f) { ArmsHook_DetachHookFromActor(this); diff --git a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c index f63442b1e..53ddd7b81 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c @@ -91,7 +91,7 @@ void BgCtowerRot_CorridorRotate(BgCtowerRot* this, GlobalContext* globalCtx) { rotZtmp = CLAMP_MAX(1100.0f - offset.z, 1000.0f); rotZ = rotZtmp; } - func_800DFAC8(globalCtx->cameraPtrs[MAIN_CAM], 17); + func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 17); this->dyna.actor.shape.rot.z = rotZ * 16.384f; if (globalCtx->csCtx.frames == 132) { play_sound(NA_SE_SY_SPIRAL_DASH); diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index d861e1cb1..9a519eb6e 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -1651,9 +1651,9 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { case 0: if (player->stateFlags1 & 0x100) { func_800EA0D4(globalCtx, &globalCtx->csCtx); - this->unk_1D22 = func_801694DC(globalCtx); - func_80169590(globalCtx, 0, 1); - func_80169590(globalCtx, this->unk_1D22, 7); + this->unk_1D22 = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->unk_1D22, 7); func_8016566C(150); this->unk_1D14 = 0; this->unk_1D5C = 0.0f; @@ -2048,7 +2048,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { this->unk_1D54 = Math_SinS(this->unk_1D14 * 1512) * this->unk_1D58; Matrix_InsertZRotation_f(this->unk_1D54, MTXMODE_APPLY); Matrix_GetStateTranslationAndScaledY(1.0f, &this->unk_1D3C); - func_8016981C(globalCtx, this->unk_1D22, &this->unk_1D30, &this->unk_1D24, &this->unk_1D3C); + Play_CameraSetAtEyeUp(globalCtx, this->unk_1D22, &this->unk_1D30, &this->unk_1D24, &this->unk_1D3C); ShrinkWindow_SetLetterboxTarget(0x1B); } } @@ -2078,9 +2078,9 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { break; } func_800EA0D4(globalCtx, &globalCtx->csCtx); - this->unk_1D22 = func_801694DC(globalCtx); - func_80169590(globalCtx, 0, 1); - func_80169590(globalCtx, this->unk_1D22, 7); + this->unk_1D22 = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->unk_1D22, 7); this->unk_1D20 = 2; this->unk_1D1C = 0; @@ -2176,9 +2176,9 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { case 100: if (ActorCutscene_GetCurrentIndex() == -1) { func_800EA0D4(globalCtx, &globalCtx->csCtx); - this->unk_1D22 = func_801694DC(globalCtx); - func_80169590(globalCtx, 0, 1); - func_80169590(globalCtx, this->unk_1D22, 7); + this->unk_1D22 = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->unk_1D22, 7); this->unk_1D20 = 101; this->unk_1D1C = 0; this->unk_1D5C = 1.0f; @@ -2260,7 +2260,7 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { if ((this->unk_1D20 != 0) && (this->unk_1D22 != 0)) { sp5C = this->unk_1D24; sp5C.y += sp58 * D_809DF5B0; - func_8016981C(globalCtx, this->unk_1D22, &this->unk_1D30, &sp5C, &this->unk_1D3C); + Play_CameraSetAtEyeUp(globalCtx, this->unk_1D22, &this->unk_1D30, &sp5C, &this->unk_1D3C); this->unk_1D3C.z = this->unk_1D3C.x = 0.0f; this->unk_1D3C.y = 1.0f; ShrinkWindow_SetLetterboxTarget(0x1B); 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 eb7b02ada..72a397d06 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -260,9 +260,9 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { this->unk_708 = 10; this->unk_704 = 0; func_800EA0D4(globalCtx, &globalCtx->csCtx); - this->unk_70A = func_801694DC(globalCtx); - func_80169590(globalCtx, 0, 1); - func_80169590(globalCtx, this->unk_70A, 7); + this->unk_70A = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->unk_70A, 7); func_800B7298(globalCtx, &this->actor, 7); player->actor.world.pos.x = this->unk_6E8; player->actor.world.pos.z = this->unk_6F0 + 410.0f; @@ -380,7 +380,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { } if (this->unk_704 > 140) { - Camera* sp5C = Play_GetCamera(globalCtx, MAIN_CAM); + Camera* sp5C = Play_GetCamera(globalCtx, CAM_ID_MAIN); this->unk_708 = 0; func_809ECD00(this, globalCtx); @@ -407,7 +407,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp50, &this->unk_718); sp50.y += Math_SinS(this->unk_748 * 0x4000) * this->unk_748 * 1.5f; Play_CameraSetAtEye(globalCtx, this->unk_70A, &sp50, &this->unk_70C); - func_80169940(globalCtx, this->unk_70A, this->unk_744); + Play_CameraSetFov(globalCtx, this->unk_70A, this->unk_744); Math_ApproachF(&this->unk_744, 60.0f, 0.1f, 1.0f); } this->actor.shape.rot.y = this->actor.yawTowardsPlayer; diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index 9461dbeb0..0040f26fa 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -199,9 +199,9 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { func_800EA0D4(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 7); - this->unk_A00 = func_801694DC(globalCtx); - func_80169590(globalCtx, 0, 1); - func_80169590(globalCtx, this->unk_A00, 7); + this->unk_A00 = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->unk_A00, 7); D_809F4970->unk_151 = 1; this->unk_1C9 = 1; this->unk_1C8 = 1; diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index 028daa2ec..629ec5668 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -518,7 +518,7 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, GlobalContext* globalCtx2) { Vec3f screenPos; // if not underwater - if (!(globalCtx->cameraPtrs[MAIN_CAM]->flags2 & 0x100)) { + if (!(globalCtx->cameraPtrs[CAM_ID_MAIN]->flags2 & 0x100)) { OPEN_DISPS(globalCtx->state.gfxCtx); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c index 70bd7e1c0..85a7a9bc8 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -205,7 +205,7 @@ void DoorAna_Update(Actor* thisx, GlobalContext* globalCtx) { DoorAna* this = THIS; this->actionFunc(this, globalCtx); - this->actor.shape.rot.y = BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); } void DoorAna_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index 630b90bdf..e28e05a16 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -405,7 +405,7 @@ void func_808A1288(DoorShutter* this, GlobalContext* globalCtx) { this->unk_164 = sp38; this->unk_168 = 0.0f; - func_800DFFAC(globalCtx->cameraPtrs[MAIN_CAM], &this->actor, player->unk_3BA, this->unk_168, 12, sp34, 10); + func_800DFFAC(globalCtx->cameraPtrs[CAM_ID_MAIN], &this->actor, player->unk_3BA, this->unk_168, 12, sp34, 10); } } diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index 6d1d65db2..98ba1c91f 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -319,7 +319,8 @@ s32 func_80BDE7FC(EnAl* this, GlobalContext* globalCtx) { case 6: case 8: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), this->actor.child); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), + this->actor.child); } this->unk_4E6++; sp20 = true; @@ -329,7 +330,7 @@ s32 func_80BDE7FC(EnAl* this, GlobalContext* globalCtx) { case 3: case 5: case 7: - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); this->unk_4E6++; sp20 = true; break; diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.c b/src/overlays/actors/ovl_En_Ani/z_en_ani.c index d2320bfd6..00bf05461 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -308,8 +308,8 @@ void EnAni_Update(Actor* thisx, GlobalContext* globalCtx) { } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); - func_800E02AC(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->actor.cutscene)), - &this->actor); + Camera_SetToTrackActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->actor.cutscene)), + &this->actor); } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); } diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index 2ce46e1ed..4eeeb3894 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -271,7 +271,7 @@ void EnBigpo_UpdateSpin(EnBigpo* this) { void EnBigpo_LowerCutsceneSubCamera(EnBigpo* this, GlobalContext* globalContext) { Camera* subCam; - if (this->cutsceneSubCamId != SUBCAM_FREE) { + if (this->cutsceneSubCamId != CAM_ID_MAIN) { subCam = Play_GetCamera(globalContext, this->cutsceneSubCamId); subCam->eye.y -= this->actor.velocity.y; if (this->actor.velocity.y > 0.0f) { @@ -332,7 +332,7 @@ void EnBigpo_SpawnCutsceneStage1(EnBigpo* this, GlobalContext* globalCtx) { this->actor.scale.y = 0.015f; this->actor.scale.z = 0.0f; - if (this->cutsceneSubCamId != SUBCAM_FREE) { + if (this->cutsceneSubCamId != CAM_ID_MAIN) { Vec3f subCamEye; subCamEye.x = ((this->actor.world.pos.x - this->fires[0].pos.x) * 1.8f) + this->actor.world.pos.x; @@ -460,8 +460,8 @@ void EnBigpo_SpawnCutsceneStage8(EnBigpo* this, GlobalContext* globalCtx) { this->idleTimer--; if (this->idleTimer == 0) { subCam = Play_GetCamera(globalCtx, this->cutsceneSubCamId); - Play_CameraSetAtEye(globalCtx, MAIN_CAM, &subCam->at, &subCam->eye); - this->cutsceneSubCamId = SUBCAM_FREE; + Play_CameraSetAtEye(globalCtx, CAM_ID_MAIN, &subCam->at, &subCam->eye); + this->cutsceneSubCamId = CAM_ID_MAIN; if (this->actor.params == ENBIGPO_SUMMONED) { dampe = SubS_FindActor(globalCtx, NULL, ACTORCAT_NPC, ACTOR_EN_TK); if (dampe != NULL) { @@ -683,25 +683,25 @@ void EnBigpo_SetupDeath(EnBigpo* this) { void EnBigpo_BurnAwayDeath(EnBigpo* this, GlobalContext* globalCtx) { Vec3f tempVec; f32 unkTemp2; // dont really know what these unktemps are doing - s16 cam; + s16 camYaw; s16 unkTemp; s16 modifiedTimer; this->idleTimer++; if (this->idleTimer < 8) { - cam = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x4800; + camYaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800; if (this->idleTimer < 5) { unkTemp = (this->idleTimer << 0xC) - 0x4000; // 1.4.0...1 is NOT 1.4, the rodata demands it tempVec.y = (((Math_SinS(unkTemp) * 23.0f) + 40.0f) * 1.4000001f) + this->actor.world.pos.y; unkTemp2 = Math_CosS(unkTemp) * 32.2f; - tempVec.x = (Math_SinS(cam) * unkTemp2) + this->actor.world.pos.x; - tempVec.z = (Math_CosS(cam) * unkTemp2) + this->actor.world.pos.z; + tempVec.x = (Math_SinS(camYaw) * unkTemp2) + this->actor.world.pos.x; + tempVec.z = (Math_CosS(camYaw) * unkTemp2) + this->actor.world.pos.z; } else { tempVec.y = this->actor.world.pos.y + ((40.0f + (15.0f * (this->idleTimer - 5))) * 1.4000001f); - tempVec.x = (Math_SinS(cam) * 32.2f) + this->actor.world.pos.x; - tempVec.z = (Math_CosS(cam) * 32.2f) + this->actor.world.pos.z; + tempVec.x = (Math_SinS(camYaw) * 32.2f) + this->actor.world.pos.x; + tempVec.z = (Math_CosS(camYaw) * 32.2f) + this->actor.world.pos.z; } // not sure what we're turning this into, but its based on the timer @@ -955,7 +955,7 @@ void EnBigpo_SetupFlameCirclePositions(EnBigpo* this, GlobalContext* globalCtx) } // Setup sub camera - if (this->cutsceneSubCamId != SUBCAM_FREE) { + if (this->cutsceneSubCamId != CAM_ID_MAIN) { subCamEye.x = (Math_SinS(this->actor.yawTowardsPlayer) * 360.0f) + this->actor.world.pos.x; subCamEye.y = this->actor.world.pos.y + 150.0f; subCamEye.z = (Math_CosS(this->actor.yawTowardsPlayer) * 360.0f) + this->actor.world.pos.z; @@ -1219,7 +1219,7 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { void EnBigpo_UpdateFire(Actor* thisx, GlobalContext* globalCtx) { EnBigpo* this = THIS; - this->actor.shape.rot.y = BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); this->actionFunc(this, globalCtx); } @@ -1350,7 +1350,7 @@ void EnBigpo_DrawScoopSoul(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.z, this->mainColor.r, this->mainColor.g, this->mainColor.b, this->mainColor.a * 2); - Matrix_RotateY(BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1430,7 +1430,7 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY(BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), MTXMODE_NEW); + Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_NEW); if (this->actionFunc == EnBigpo_SpawnCutsceneStage6) { Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); fireRadius = 500; diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index 97f687dad..8c72d369c 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -843,10 +843,10 @@ void EnBigslime_UpdateCameraFormingBigslime(EnBigslime* this, GlobalContext* glo void EnBigslime_EndCutscene(EnBigslime* this, GlobalContext* globalCtx) { Camera* subCam; - if (this->subCamId != MAIN_CAM) { + if (this->subCamId != CAM_ID_MAIN) { subCam = Play_GetCamera(globalCtx, this->subCamId); - Play_CameraSetAtEye(globalCtx, MAIN_CAM, &subCam->at, &subCam->eye); - this->subCamId = MAIN_CAM; + Play_CameraSetAtEye(globalCtx, CAM_ID_MAIN, &subCam->at, &subCam->eye); + this->subCamId = CAM_ID_MAIN; ActorCutscene_Stop(this->cutscene); this->cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); func_800B724C(globalCtx, &this->actor, 6); @@ -1019,7 +1019,7 @@ void EnBigslime_SetupMoveOnCeiling(EnBigslime* this) { this->actor.gravity = 0.0f; this->actor.velocity.y = 20.0f; - if (this->subCamId != MAIN_CAM) { + if (this->subCamId != CAM_ID_MAIN) { this->actor.speedXZ = 0.0f; this->ceilingMoveTimer = 20; } else { @@ -1043,7 +1043,7 @@ void EnBigslime_MoveOnCeiling(EnBigslime* this, GlobalContext* globalCtx) { EnBigslime_Scale(this, pitch, 0.04f, 0.04f); EnBigslime_UpdateWavySurface(this); - if (this->subCamId != MAIN_CAM) { + if (this->subCamId != CAM_ID_MAIN) { if (this->ceilingMoveTimer == 0) { EnBigslime_EndCutscene(this, globalCtx); this->ceilingMoveTimer = 320; @@ -1493,7 +1493,7 @@ void EnBigslime_Rise(EnBigslime* this, GlobalContext* globalCtx) { } void EnBigslime_SetupCutsceneGrabPlayer(EnBigslime* this, GlobalContext* globalCtx) { - Camera* mainCam = Play_GetCamera(globalCtx, MAIN_CAM); + Camera* mainCam = Play_GetCamera(globalCtx, CAM_ID_MAIN); s16 yaw; Play_CameraSetAtEye(globalCtx, this->subCamId, &mainCam->at, &mainCam->eye); @@ -1501,7 +1501,7 @@ void EnBigslime_SetupCutsceneGrabPlayer(EnBigslime* this, GlobalContext* globalC this->wavySurfaceTimer = 0; this->bigslimeCollider[0].base.atFlags &= ~AT_ON; this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); - yaw = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) - this->actor.world.rot.y; + yaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.world.rot.y; if (yaw > 0x4000) { this->subCamYawGrabPlayer = -0x2000; @@ -2423,7 +2423,7 @@ void EnBigslime_SetupFrogSpawn(EnBigslime* this, GlobalContext* globalCtx) { Vec3f* worldPos; Vec3f dustPos; Vec3f hahenVel; - s16 yaw = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)); + s16 yaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); s16 yawReverse = yaw + 0x8000; s32 i; diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c index c0379f33c..7bd4fa89f 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c @@ -249,8 +249,8 @@ void func_809C4DA4(EnBomBowlMan* this, GlobalContext* globalCtx) { case 0: this->unk_2C0 = 1; D_809C6104 = 1; - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->unk_2D0)), - &this->unk_2D8[0]->actor); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->unk_2D0)), + &this->unk_2D8[0]->actor); this->unk_2D4 = 0; this->unk_2BC = 10; func_809C493C(this, 17, 1.0f); @@ -580,7 +580,7 @@ void func_809C5BF4(EnBomBowlMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); func_801477B4(globalCtx); - func_800E0308(sp28, &this->unk_2D8[0]->actor); + Camera_SetTargetActor(sp28, &this->unk_2D8[0]->actor); func_809C493C(this, 13, 1.0f); D_809C6100 = 0; if (player->transformation == PLAYER_FORM_HUMAN) { @@ -595,7 +595,7 @@ void func_809C5BF4(EnBomBowlMan* this, GlobalContext* globalCtx) { } else { s32 idx = D_809C6100 - 1; - func_800E0308(sp28, &this->unk_2D8[1 + idx]->actor); + Camera_SetTargetActor(sp28, &this->unk_2D8[1 + idx]->actor); } } } diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c index ab9f8534f..6bb4827ae 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -469,8 +469,8 @@ void func_80BFF03C(EnBomjima* this, GlobalContext* globalCtx) { } else { player->stateFlags1 &= ~0x20; gSaveContext.weekEventReg[83] &= (u8)~4; - this->actor.world.rot.y = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)); - this->unk_2DC = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)); + this->actor.world.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); + this->unk_2DC = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[0], &this->actor); func_80BFF120(this); } diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index 612420995..2992f356e 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -521,7 +521,7 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Camera* camera; + Camera* mainCam; s32 pad; switch (this->cameraState) { @@ -545,17 +545,17 @@ void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { break; case 1: func_800EA0D4(globalCtx, &globalCtx->csCtx); - this->camId = func_801694DC(globalCtx); - func_80169590(globalCtx, 0, 1); - func_80169590(globalCtx, this->camId, 7); + this->subCamId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->subCamId, 7); func_800B7298(globalCtx, &this->actor, 4); - camera = Play_GetCamera(globalCtx, MAIN_CAM); - this->eye.x = camera->eye.x; - this->eye.y = camera->eye.y; - this->eye.z = camera->eye.z; - this->at.x = camera->at.x; - this->at.y = camera->at.y; - this->at.z = camera->at.z; + mainCam = Play_GetCamera(globalCtx, CAM_ID_MAIN); + this->subCamEye.x = mainCam->eye.x; + this->subCamEye.y = mainCam->eye.y; + this->subCamEye.z = mainCam->eye.z; + this->subCamAt.x = mainCam->at.x; + this->subCamAt.y = mainCam->at.y; + this->subCamAt.z = mainCam->at.z; func_801518B0(globalCtx, 0xF, NULL); this->cameraState = 2; func_8019FDC8(&D_801DB4A4, NA_SE_VO_NA_LISTEN, 0x20); @@ -568,22 +568,22 @@ void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { player->actor.speedXZ = 0.0f; if (Message_GetState(&globalCtx->msgCtx) == 0) { - camera = Play_GetCamera(globalCtx, MAIN_CAM); - camera->eye = this->eye; - camera->eyeNext = this->eye; - camera->at = this->at; - func_80169AFC(globalCtx, this->camId, 0); + mainCam = Play_GetCamera(globalCtx, CAM_ID_MAIN); + mainCam->eye = this->subCamEye; + mainCam->eyeNext = this->subCamEye; + mainCam->at = this->subCamAt; + func_80169AFC(globalCtx, this->subCamId, 0); func_800EA0EC(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); this->cameraState = 0; - this->camId = 0; + this->subCamId = CAM_ID_MAIN; this->activeTimer = 20; } break; } - if (this->camId != 0) { - Play_CameraSetAtEye(globalCtx, this->camId, &this->at, &this->eye); + if (this->subCamId != CAM_ID_MAIN) { + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->subCamAt, &this->subCamEye); } } diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h index 453e6c0ac..61c4a638b 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h @@ -45,10 +45,10 @@ typedef struct EnClearTag { /* 0x2E54 */ u8 cameraState; /* 0x2E56 */ s16 activeTimer; // Actor Marked for Death when timer runs out /* 0x2E58 */ UNK_TYPE1 unk2E58[0xC]; - /* 0x2E64 */ s16 camId; + /* 0x2E64 */ s16 subCamId; /* 0x2E66 */ Color_RGBA8 flashEnvColor; - /* 0x2E6C */ Vec3f eye; // Camera eye - /* 0x2E78 */ Vec3f at; // Camera lookAt + /* 0x2E6C */ Vec3f subCamEye; + /* 0x2E78 */ Vec3f subCamAt; } EnClearTag; // size = 0x2E84 extern const ActorInit En_Clear_Tag_InitVars; diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index 16474e92a..dcb3b9853 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -363,11 +363,11 @@ void func_8089A9B0(EnDinofos* this, GlobalContext* globalCtx) { } void func_8089ABF4(EnDinofos* this, GlobalContext* globalCtx) { - if (this->camId != 0) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); + if (this->subCamId != CAM_ID_MAIN) { + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); - Play_CameraSetAtEye(globalCtx, 0, &camera->at, &camera->eye); - this->camId = 0; + Play_CameraSetAtEye(globalCtx, CAM_ID_MAIN, &subCam->at, &subCam->eye); + this->subCamId = CAM_ID_MAIN; ActorCutscene_Stop(this->actor.cutscene); if (this->actor.colChkInfo.health == 0) { func_800B724C(globalCtx, &this->actor, 6); @@ -462,14 +462,14 @@ s32 func_8089AE00(EnDinofos* this, GlobalContext* globalCtx) { } void func_8089B100(EnDinofos* this, GlobalContext* globalCtx) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); Player* player = GET_PLAYER(globalCtx); Vec3f sp3C; Animation_Change(&this->skelAnime, &object_dinofos_Anim_001CCC, 1.0f, Animation_GetLastFrame(&object_dinofos_Anim_001CCC), Animation_GetLastFrame(&object_dinofos_Anim_001CCC), 2, 0.0f); - func_800BE33C(&camera->eye, &camera->at, &this->unk_29A, true); + func_800BE33C(&subCam->eye, &subCam->at, &this->unk_29A, true); Math_Vec3f_Diff(&this->actor.world.pos, &player->actor.world.pos, &sp3C); this->unk_2BC.x = player->actor.world.pos.x + (0.4f * sp3C.x); this->unk_2BC.y = player->actor.world.pos.y + 5.0f; @@ -477,19 +477,19 @@ void func_8089B100(EnDinofos* this, GlobalContext* globalCtx) { this->unk_2C8.x = this->actor.world.pos.x; this->unk_2C8.y = this->actor.focus.pos.y - 400.0f; this->unk_2C8.z = this->actor.world.pos.z; - this->unk_2AC = Math_Vec3f_DistXYZ(&camera->eye, &this->unk_2BC) * 0.05f; - this->unk_2A8 = Math_Vec3f_DistXYZ(&camera->at, &this->unk_2C8) * 0.05f; + this->unk_2AC = Math_Vec3f_DistXYZ(&subCam->eye, &this->unk_2BC) * 0.05f; + this->unk_2A8 = Math_Vec3f_DistXYZ(&subCam->at, &this->unk_2C8) * 0.05f; this->unk_290 = 20; this->actionFunc = func_8089B288; } void func_8089B288(EnDinofos* this, GlobalContext* globalCtx) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); this->unk_290--; - Math_Vec3f_StepTo(&camera->eye, &this->unk_2BC, this->unk_2AC); - Math_Vec3f_StepTo(&camera->at, &this->unk_2C8, this->unk_2A8); - Play_CameraSetAtEye(globalCtx, this->camId, &camera->at, &camera->eye); + Math_Vec3f_StepTo(&subCam->eye, &this->unk_2BC, this->unk_2AC); + Math_Vec3f_StepTo(&subCam->at, &this->unk_2C8, this->unk_2A8); + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCam->at, &subCam->eye); if (this->unk_290 == 0) { func_8089B320(this); } @@ -506,24 +506,24 @@ void func_8089B320(EnDinofos* this) { } void func_8089B3D4(EnDinofos* this, GlobalContext* globalCtx) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); - Vec3f sp28; + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); + Vec3f subCamAt; - Math_Vec3f_StepTo(&camera->eye, &this->unk_2BC, 10.0f); + Math_Vec3f_StepTo(&subCam->eye, &this->unk_2BC, 10.0f); this->unk_290++; if (this->unk_290 == 10) { func_801A2E54(NA_BGM_MINI_BOSS); } - sp28.x = this->actor.world.pos.x; - sp28.z = this->actor.world.pos.z; - if (this->actor.focus.pos.y <= camera->at.y) { - sp28.y = this->actor.focus.pos.y; + subCamAt.x = this->actor.world.pos.x; + subCamAt.z = this->actor.world.pos.z; + if (this->actor.focus.pos.y <= subCam->at.y) { + subCamAt.y = this->actor.focus.pos.y; } else { - sp28.y = camera->at.y; + subCamAt.y = subCam->at.y; } - Play_CameraSetAtEye(globalCtx, this->camId, &sp28, &camera->eye); + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCam->eye); if (this->actor.bgCheckFlags & 1) { func_8089B4A4(this); } @@ -544,11 +544,11 @@ void func_8089B4A4(EnDinofos* this) { } void func_8089B580(EnDinofos* this, GlobalContext* globalCtx) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); this->unk_290++; if (this->unk_290 < 8) { - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.focus.pos, &camera->eye); + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.focus.pos, &subCam->eye); } if (this->skelAnime.curFrame > 35.0f) { @@ -556,8 +556,8 @@ void func_8089B580(EnDinofos* this, GlobalContext* globalCtx) { globalCtx->envCtx.unk_C3 = 11; } - Math_Vec3f_StepTo(&camera->eye, &this->unk_2BC, 10.0f); - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.focus.pos, &camera->eye); + Math_Vec3f_StepTo(&subCam->eye, &this->unk_2BC, 10.0f); + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.focus.pos, &subCam->eye); if (this->skelAnime.curFrame <= 55.0f) { func_800B9010(&this->actor, NA_SE_EN_DODO_J_FIRE - SFX_FLAG); } @@ -1201,7 +1201,7 @@ void func_8089D2E0(EnDinofos* this) { } void func_8089D318(EnDinofos* this, GlobalContext* globalCtx) { - Vec3f sp24; + Vec3f subCamEye; if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { if (this->actor.colChkInfo.health == 0) { @@ -1210,12 +1210,12 @@ void func_8089D318(EnDinofos* this, GlobalContext* globalCtx) { } else { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); } - this->camId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + this->subCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); if (this->actor.colChkInfo.health == 0) { - sp24.x = (Math_SinS(this->actor.shape.rot.y) * 150.0f) + this->actor.focus.pos.x; - sp24.y = this->actor.focus.pos.y; - sp24.z = (Math_CosS(this->actor.shape.rot.y) * 150.0f) + this->actor.focus.pos.z; - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.focus.pos, &sp24); + subCamEye.x = (Math_SinS(this->actor.shape.rot.y) * 150.0f) + this->actor.focus.pos.x; + subCamEye.y = this->actor.focus.pos.y; + subCamEye.z = (Math_CosS(this->actor.shape.rot.y) * 150.0f) + this->actor.focus.pos.z; + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.focus.pos, &subCamEye); func_8089CFAC(this); } else { func_8089B100(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h index e6a00853e..961780b94 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h @@ -22,7 +22,7 @@ typedef struct EnDinofos { /* 0x290 */ s16 unk_290; /* 0x292 */ s16 unk_292; /* 0x294 */ UNK_TYPE1 unk_294[4]; - /* 0x298 */ s16 camId; + /* 0x298 */ s16 subCamId; /* 0x29A */ Vec3s unk_29A; /* 0x2A0 */ s32 unk_2A0; /* 0x2A4 */ f32 unk_2A4; 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 699c862a8..1eb5838ca 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -2898,7 +2898,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { sp118 = (player->actor.speedXZ * 0.3f) + 0.25f; } - if ((D_80917200 != 0) || (sCameraId != MAIN_CAM) || + if ((D_80917200 != 0) || (sCameraId != CAM_ID_MAIN) || ((player->actor.world.pos.z > 1150.0f) && (this->unk_150 != 100))) { this->actor.flags &= ~ACTOR_FLAG_1; } else { @@ -4359,7 +4359,7 @@ void EnFishing_UpdatePondProps(GlobalContext* globalCtx) { prop++; } - if (sCameraId == MAIN_CAM) { + if (sCameraId == CAM_ID_MAIN) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &sFishingMain->collider.base); } } @@ -5185,10 +5185,10 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { break; case 1: - sCameraId = func_801694DC(globalCtx); - func_80169590(globalCtx, MAIN_CAM, 1); - func_80169590(globalCtx, sCameraId, 7); - camera = Play_GetCamera(globalCtx, MAIN_CAM); + sCameraId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, sCameraId, 7); + camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); sCameraEye.x = camera->eye.x; sCameraEye.y = camera->eye.y; sCameraEye.z = camera->eye.z; @@ -5295,7 +5295,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { break; case 3: { - Camera* camera = Play_GetCamera(globalCtx, MAIN_CAM); + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); camera->eye = sCameraEye; camera->eyeNext = sCameraEye; @@ -5304,7 +5304,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { func_80169AFC(globalCtx, sCameraId, 0); func_800EA0EC(globalCtx, &globalCtx->csCtx); D_8090CD4C = 0; - sCameraId = MAIN_CAM; + sCameraId = CAM_ID_MAIN; func_800F6834(globalCtx, 0); globalCtx->envCtx.unk_8C.fogNear = 0; player->unk_B28 = -5; @@ -5313,11 +5313,11 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { case 10: func_800EA0D4(globalCtx, &globalCtx->csCtx); - sCameraId = func_801694DC(globalCtx); - func_80169590(globalCtx, MAIN_CAM, 1); - func_80169590(globalCtx, sCameraId, 7); + sCameraId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, sCameraId, 7); func_800B7298(globalCtx, &this->actor, 4); - camera = Play_GetCamera(globalCtx, MAIN_CAM); + camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); sCameraEye.x = camera->eye.x; sCameraEye.y = camera->eye.y; sCameraEye.z = camera->eye.z; @@ -5334,7 +5334,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { player->actor.speedXZ = 0.0f; if (!Message_GetState(&globalCtx->msgCtx)) { - camera = Play_GetCamera(globalCtx, MAIN_CAM); + camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); camera->eye = sCameraEye; camera->eyeNext = sCameraEye; @@ -5343,7 +5343,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { func_800EA0EC(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); D_8090CD4C = 0; - sCameraId = MAIN_CAM; + sCameraId = CAM_ID_MAIN; D_8090CD50 = 30; func_800F6834(globalCtx, 0); globalCtx->envCtx.unk_8C.fogNear = 0; @@ -5352,11 +5352,11 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { case 20: func_800EA0D4(globalCtx, &globalCtx->csCtx); - sCameraId = func_801694DC(globalCtx); - func_80169590(globalCtx, MAIN_CAM, 1); - func_80169590(globalCtx, sCameraId, 7); + sCameraId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, sCameraId, 7); func_800B7298(globalCtx, &this->actor, 4); - camera = Play_GetCamera(globalCtx, MAIN_CAM); + camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); sCameraEye.x = camera->eye.x; sCameraEye.y = camera->eye.y; sCameraEye.z = camera->eye.z; @@ -5428,7 +5428,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { if (D_8090CD50 == 0) { if ((Message_GetState(&globalCtx->msgCtx) == 4) || !Message_GetState(&globalCtx->msgCtx)) { if (func_80147624(globalCtx)) { - Camera* camera = Play_GetCamera(globalCtx, MAIN_CAM); + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex == 0) { @@ -5443,7 +5443,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { func_800EA0EC(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); // arg2 changed from 7 to 6 in MM D_8090CD4C = 0; - sCameraId = MAIN_CAM; + sCameraId = CAM_ID_MAIN; player->unk_B28 = -5; D_80917200 = 5; D_8090CD54 = 0; @@ -5459,7 +5459,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { break; } - if (sCameraId != MAIN_CAM) { + if (sCameraId != CAM_ID_MAIN) { Play_CameraSetAtEye(globalCtx, sCameraId, &sCameraAt, &sCameraEye); Math_ApproachF(&D_80911F4C, 1.0f, 1.0f, 0.02f); @@ -5561,7 +5561,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { if ((u8)D_8090CCD0 > 0) { s32 pad; - Camera* camera = Play_GetCamera(globalCtx, MAIN_CAM); + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); s16 i; s32 pad1; Vec3f pos; @@ -5571,7 +5571,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { rot.x = 1.6707964f; rot.y = 1.0f; - rot.z = (func_800DFC68(camera) * -(M_PI / 32768)) + rot.y; + rot.z = (Camera_GetInputDirYaw(camera) * -(M_PI / 32768)) + rot.y; for (i = 0; i < (u8)D_8090CCD0; i++) { pos.x = randPlusMinusPoint5Scaled(700.0f) + globalCtx->view.eye.x; diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index 039fdfa9a..063d01608 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -730,7 +730,8 @@ void func_80962D60(EnFu* this, GlobalContext* globalCtx) { void func_80962EBC(EnFu* this, GlobalContext* globalCtx) { if (this->unk_542 != 0) { if (this->actor.cutscene != -1) { - func_800DFB14(globalCtx->cameraPtrs[MAIN_CAM], ActorCutscene_GetCutscene(this->actor.cutscene)->unk4); + Camera_ChangeDataIdx(globalCtx->cameraPtrs[CAM_ID_MAIN], + ActorCutscene_GetCutscene(this->actor.cutscene)->csCamSceneDataId); } } } @@ -1163,11 +1164,11 @@ void func_80963F44(EnFu* this, GlobalContext* globalCtx) { void func_80963F88(EnFu* this, GlobalContext* globalCtx) { if (this->unk_542 == 1) { - func_800DFAC8(globalCtx->cameraPtrs[MAIN_CAM], 75); + func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 75); globalCtx->unk_1887E = 0; } else if (this->unk_542 == 2) { globalCtx->unk_1887D = 0; - func_800DFAC8(globalCtx->cameraPtrs[MAIN_CAM], 75); + func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 75); } } @@ -1421,7 +1422,7 @@ void func_80964694(EnFu* this, EnFuUnkStruct* ptr, Vec3f* arg2, s32 len) { void func_809647EC(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { Vec3f sp44 = { 0.0f, 0.0f, 0.0f }; - s16 activeCam = func_800DFC68(GET_ACTIVE_CAM(globalCtx)); + s16 yaw = Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); s32 i; for (i = 0; i < len; i++, ptr++) { @@ -1434,7 +1435,7 @@ void func_809647EC(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { ptr->unk_08.z += 2.0f * Math_CosS(ptr->unk_2C); Matrix_StatePush(); Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); - Matrix_RotateY(activeCam, MTXMODE_APPLY); + Matrix_RotateY(yaw, MTXMODE_APPLY); Matrix_MultiplyVector3fByState(&sp44, &ptr->unk_08); Matrix_StatePop(); ptr->unk_2C += 6000; 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 6d5c2db3f..9be7b1a00 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -385,7 +385,7 @@ s32 func_8094E52C(EnGm* this, GlobalContext* globalCtx) { if (!(gSaveContext.weekEventReg[86] & 0x40) && (this->unk_3E0 == 2)) { ActorCutscene_Stop(sp2A); } else { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); } this->unk_3E0++; ret = true; @@ -393,7 +393,8 @@ s32 func_8094E52C(EnGm* this, GlobalContext* globalCtx) { case 1: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), this->actor.child); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), + this->actor.child); } this->unk_3E0++; ret = true; @@ -453,7 +454,7 @@ s32 func_8094E69C(EnGm* this, GlobalContext* globalCtx) { case 4: case 6: camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp4A)); - func_800E0308(camera, &this->actor); + Camera_SetTargetActor(camera, &this->actor); this->unk_3E0++; ret = true; } @@ -464,7 +465,7 @@ s32 func_8094E69C(EnGm* this, GlobalContext* globalCtx) { case 7: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp4A)); - func_800E0308(camera, this->actor.child); + Camera_SetTargetActor(camera, this->actor.child); } this->unk_3E0++; ret = true; 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 000f5649c..6d7f97630 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -1045,7 +1045,7 @@ s32 func_80A13564(EnGo* this, f32 arg1, f32 arg2, s32 arg3) { } void func_80A136B8(GlobalContext* globalCtx, s16 arg1, s16 arg2, s16 arg3) { - s16 sp26 = Quake_Add(Play_GetCamera(globalCtx, MAIN_CAM), 3); + s16 sp26 = Quake_Add(Play_GetCamera(globalCtx, CAM_ID_MAIN), 3); Quake_SetCountdown(sp26, arg3); Quake_SetSpeed(sp26, arg1); 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 ecb47f383..15ef372bd 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -331,8 +331,8 @@ s32 func_80BF17BC(EnIg* this, GlobalContext* globalCtx) { case 2: case 4: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), - this->actor.child); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), + this->actor.child); } this->unk_3F6++; ret = true; @@ -345,7 +345,7 @@ s32 func_80BF17BC(EnIg* this, GlobalContext* globalCtx) { ActorCutscene_Stop(sp2A); this->unk_3F6 = 5; } else { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); } this->unk_3F6++; ret = true; 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 461384295..8f9b3fb44 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -383,13 +383,13 @@ void EnJg_GoronShrineCheer(EnJg* this, GlobalContext* globalCtx) { // Focus on a specifc Goron for these lines this->shrineGoron = EnJg_GetShrineGoronToFocusOn(globalCtx, this->focusedShrineGoronParam); ActorCutscene_Start(this->cutscene, this->shrineGoron); - func_800E0308(globalCtx->cameraPtrs[0], this->shrineGoron); + Camera_SetTargetActor(globalCtx->cameraPtrs[CAM_ID_MAIN], this->shrineGoron); break; default: // Focus on the whole group for these lines ActorCutscene_Start(this->cutscene, &this->actor); - func_800E0308(globalCtx->cameraPtrs[0], this->shrineGoron); + Camera_SetTargetActor(globalCtx->cameraPtrs[CAM_ID_MAIN], this->shrineGoron); break; } this->actionFunc = EnJg_GoronShrineTalk; 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 a11af566a..3fca0129d 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -259,7 +259,7 @@ void EnKakasi_CheckPlayerPosition(EnKakasi* this, GlobalContext* globalCtx) { * something to do with cutscene camera? */ void func_8096FAAC(EnKakasi* this, GlobalContext* globalCtx) { - if (this->cutsceneCamId != MAIN_CAM) { + if (this->cutsceneCamId != CAM_ID_MAIN) { Math_ApproachF(&this->unk214.x, this->unk238.x, 0.4f, 4.0f); Math_ApproachF(&this->unk214.y, this->unk238.y, 0.4f, 4.0f); Math_ApproachF(&this->unk214.z, this->unk238.z, 0.4f, 4.0f); @@ -271,7 +271,7 @@ void func_8096FAAC(EnKakasi* this, GlobalContext* globalCtx) { Math_ApproachF(&this->unk20C, this->unk210, 0.3f, 10.0f); Play_CameraSetAtEye(globalCtx, this->cutsceneCamId, &this->unk220, &this->unk214); - func_80169940(globalCtx, this->cutsceneCamId, this->unk20C); + Play_CameraSetFov(globalCtx, this->cutsceneCamId, this->unk20C); } } @@ -550,7 +550,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx) { this->actor.textId = 0x1646; func_801518B0(globalCtx, this->actor.textId, &this->actor); - this->cutsceneCamId = MAIN_CAM; + this->cutsceneCamId = CAM_ID_MAIN; this->unk20C = 0.0f; this->unk210 = 60.0f; EnKakasi_SetAnimation(this, ENKAKASI_ANIM_TWIRL); @@ -628,7 +628,7 @@ void EnKakasi_TeachingSong(EnKakasi* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YASE_DEAD); if (this) {} this->unkState196 = 2; - this->cutsceneCamId = MAIN_CAM; + this->cutsceneCamId = CAM_ID_MAIN; this->actor.textId = 0x1647; this->unkState1A8 = 2; this->unkMsgState1AC = 5; @@ -662,7 +662,7 @@ void EnKakasi_SetupPostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCt this->unk190 = 0; this->unkCounter1A4 = 0; EnKakasi_SetAnimation(this, ENKAKASI_ANIM_HOPPING_REGULAR); - this->cutsceneCamId = MAIN_CAM; + this->cutsceneCamId = CAM_ID_MAIN; this->unkMsgState1AC = 5; this->unkState1A8 = 1; this->actionFunc = EnKakasi_PostSongLearnDialogue; @@ -720,7 +720,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { this->unkState1A8 = 1; } - if (this->cutsceneCamId != MAIN_CAM) { + if (this->cutsceneCamId != CAM_ID_MAIN) { this->unk22C.y = this->actor.home.pos.y + 50.0f; EnKakasi_CheckPlayerPosition(this, globalCtx); this->unk238.x = D_80971FA0[this->unk190].x; @@ -974,7 +974,7 @@ void EnKakasi_DiggingAway(EnKakasi* this, GlobalContext* globalCtx) { Vec3f tempunk238; Vec3f tempWorldPos; - if (this->cutsceneCamId != MAIN_CAM) { + if (this->cutsceneCamId != CAM_ID_MAIN) { this->unk22C.y = this->actor.home.pos.y + 50.0f; this->unk238.x = D_80972030.x; this->unk238.y = D_80972030.y; @@ -1127,7 +1127,7 @@ void EnKakasi_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->unk1BC.x != 0.0f || this->unk1BC.z != 0.0f) { Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk1BC); this->actor.focus.pos.y += 10.0f; - if (this->cutsceneCamId == MAIN_CAM) { + if (this->cutsceneCamId == CAM_ID_MAIN) { Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } else { Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.home.rot); 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 4eb4ffdc9..d42d75bb1 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 @@ -667,7 +667,8 @@ void func_80B27774(EnKendoJs* this, GlobalContext* globalCtx) { void func_80B2783C(EnKendoJs* this, GlobalContext* globalCtx) { if (this->actor.cutscene != -1) { - func_800DFB14(globalCtx->cameraPtrs[MAIN_CAM], ActorCutscene_GetCutscene(this->actor.cutscene)->unk4); + Camera_ChangeDataIdx(globalCtx->cameraPtrs[CAM_ID_MAIN], + ActorCutscene_GetCutscene(this->actor.cutscene)->csCamSceneDataId); } } diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index 69145c95f..227c4316d 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -224,22 +224,22 @@ void EnMinifrog_TurnToMissingFrog(EnMinifrog* this) { static Color_RGBA8 sPrimColor = { 255, 255, 255, 255 }; static Color_RGBA8 sEnvColor = { 80, 80, 80, 255 }; -void EnMinifrog_SetCamera(EnMinifrog* this, GlobalContext* globalCtx) { +void EnMinifrog_SpawnDust(EnMinifrog* this, GlobalContext* globalCtx) { Vec3f pos; Vec3f vec5; Vec3f vel; Vec3f accel; s16 yaw; s16 pitch; - Vec3f eye; + Vec3f eye = GET_ACTIVE_CAM(globalCtx)->eye; s32 i; - eye = GET_ACTIVE_CAM(globalCtx)->eye; yaw = Math_Vec3f_Yaw(&eye, &this->actor.world.pos); pitch = -Math_Vec3f_Pitch(&eye, &this->actor.world.pos); vec5.x = this->actor.world.pos.x - (5.0f * Math_SinS(yaw) * Math_CosS(pitch)); vec5.y = this->actor.world.pos.y - (5.0f * Math_SinS(pitch)); vec5.z = this->actor.world.pos.z - (5.0f * Math_CosS(yaw) * Math_CosS(pitch)); + for (i = 0; i < 5; i++) { vel.x = randPlusMinusPoint5Scaled(4.0f); vel.y = randPlusMinusPoint5Scaled(4.0f); @@ -284,7 +284,7 @@ void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, GlobalContext* globalCtx) { case 0xD85: // "I understand. I shall head for the mountains immediately." default: func_801477B4(globalCtx); - EnMinifrog_SetCamera(this, globalCtx); + EnMinifrog_SpawnDust(this, globalCtx); SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_NPC_FADEAWAY); if (this->actor.cutscene != -1) { if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index 4927031e4..f6e398a33 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -742,7 +742,7 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad2[9]; s16 temp29C; f32 featherScale; - f32 camResult; + f32 viewAtToEyeNormY; f32 floorHeight; f32 dist = 20.0f; s32 pad3; @@ -808,17 +808,19 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1F); + // if cucco is off the map? if (this->actor.floorHeight <= BGCHECK_Y_MIN || this->actor.floorHeight >= BGCHECK_Y_MAX) { - // if cucco is off the map? - Vec3f camera; - camera.x = globalCtx->view.at.x - globalCtx->view.eye.x; - camera.y = globalCtx->view.at.y - globalCtx->view.eye.y; - camera.z = globalCtx->view.at.z - globalCtx->view.eye.z; - camResult = camera.y / sqrtf(SQXYZ(camera)); + Vec3f viewAtToEye; + + // Direction vector for the direction the camera is facing + viewAtToEye.x = globalCtx->view.at.x - globalCtx->view.eye.x; + viewAtToEye.y = globalCtx->view.at.y - globalCtx->view.eye.y; + viewAtToEye.z = globalCtx->view.at.z - globalCtx->view.eye.z; + viewAtToEyeNormY = viewAtToEye.y / sqrtf(SQXYZ(viewAtToEye)); this->actor.world.pos.x = this->actor.home.pos.x; this->actor.world.pos.z = this->actor.home.pos.z; - this->actor.world.pos.y = (this->actor.home.pos.y + globalCtx->view.eye.y) + (camResult * 160.0f); + this->actor.world.pos.y = (this->actor.home.pos.y + globalCtx->view.eye.y) + (viewAtToEyeNormY * 160.0f); if (this->actor.world.pos.y < this->actor.home.pos.y) { this->actor.world.pos.y = this->actor.home.pos.y + 300.0f; diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index 4781f8828..b210e76cd 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -461,7 +461,7 @@ void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 12.0f)) { - Matrix_RotateY(func_800DFCDC(GET_ACTIVE_CAM(globalCtx)), MTXMODE_NEW); + Matrix_RotateY(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_NEW); sp38.x = 1.0f; sp38.y = 8.1f; sp38.z = 0.0f; @@ -645,8 +645,8 @@ void func_80B5CD40(EnOt* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 0: - temp = Math_SmoothStepToS(&this->actor.shape.rot.y, BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), - 3, 0xE38, 0x38E); + temp = Math_SmoothStepToS(&this->actor.shape.rot.y, + BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), 3, 0xE38, 0x38E); this->actor.world.rot.y = this->actor.shape.rot.y; if (1) {} if (!temp) { @@ -1112,7 +1112,7 @@ EnOtUnkStruct* func_80B5DF58(EnOtUnkStruct* arg0, u8 arg1, Vec3f* arg2, Vec3s* a void func_80B5E078(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2) { Vec3f sp54; s32 i; - s16 temp = func_800DFC68(GET_ACTIVE_CAM(globalCtx)); + s16 temp = Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); for (i = 0; i < arg2; i++, arg1++) { if ((arg1->unk_00 == 1) || (arg1->unk_00 == 2)) { @@ -1152,7 +1152,7 @@ void func_80B5E1D8(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2) { } Matrix_InsertTranslation(arg1->unk_0C.x, arg1->unk_0C.y, arg1->unk_0C.z, MTXMODE_NEW); - Matrix_RotateY(BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); Matrix_Scale(arg1->unk_04, arg1->unk_04, arg1->unk_04, MTXMODE_APPLY); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_05E6F0)); diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index 4bbe6fa60..4b15bde77 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -241,7 +241,8 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { if (this->hideInisdeTimer++ > 1800) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[0]) && (this->cutscenes[0] != -1)) { ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[0], &this->actor); - func_800E02AC(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->cutscenes[0])), &this->actor); + Camera_SetToTrackActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->cutscenes[0])), + &this->actor); this->actor.speedXZ = 1.5f; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actor.shape.rot.y = this->actor.home.rot.y; @@ -427,7 +428,8 @@ void func_80BD90AC(EnPamera* this, GlobalContext* globalCtx) { (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 200.0f)))) { if ((ActorCutscene_GetCanPlayNext(this->cutscenes[1])) && ((this->cutscenes[1] != -1))) { ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[1], &this->actor); - func_800E02AC(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->cutscenes[1])), &this->actor); + Camera_SetToTrackActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->cutscenes[1])), + &this->actor); EnPamera_LookDownWell(this); } else if (this->cutscenes[1] != -1) { ActorCutscene_SetIntentToPlay(this->cutscenes[1]); diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c index 963eabe4b..bab9aee20 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -325,24 +325,24 @@ s32 func_8086A2CC(EnPametfrog* this, CollisionPoly* floorPoly) { } void EnPametfrog_ShakeCamera(EnPametfrog* this, GlobalContext* globalCtx, f32 magShakeXZ, f32 magShakeY) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); - s16 y; - Vec3f eye; + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); + s16 subCamYaw; + Vec3f subCamEye; - y = BINANG_ROT180(func_800DFCDC(camera)); - eye.x = (Math_SinS(y) * magShakeXZ) + camera->at.x; - eye.y = camera->at.y + magShakeY; - eye.z = (Math_CosS(y) * magShakeXZ) + camera->at.z; - Play_CameraSetAtEye(globalCtx, this->camId, &camera->at, &eye); + subCamYaw = BINANG_ROT180(Camera_GetCamDirYaw(subCam)); + subCamEye.x = (Math_SinS(subCamYaw) * magShakeXZ) + subCam->at.x; + subCamEye.y = subCam->at.y + magShakeY; + subCamEye.z = (Math_CosS(subCamYaw) * magShakeXZ) + subCam->at.z; + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCam->at, &subCamEye); } void EnPametfrog_StopCutscene(EnPametfrog* this, GlobalContext* globalCtx) { - Camera* camera; + Camera* subCam; - if (this->camId != 0) { - camera = Play_GetCamera(globalCtx, this->camId); - Play_CameraSetAtEye(globalCtx, 0, &camera->at, &camera->eye); - this->camId = 0; + if (this->subCamId != CAM_ID_MAIN) { + subCam = Play_GetCamera(globalCtx, this->subCamId); + Play_CameraSetAtEye(globalCtx, CAM_ID_MAIN, &subCam->at, &subCam->eye); + this->subCamId = CAM_ID_MAIN; ActorCutscene_Stop(this->cutscene); func_800B724C(globalCtx, &this->actor, 6); } @@ -494,7 +494,7 @@ void EnPametfrog_RearOnSnapperRise(EnPametfrog* this, GlobalContext* globalCtx) } void EnPametfrog_SetupFallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx) { - Vec3f eye; + Vec3f subCamEye; s16 yaw; Animation_PlayOnce(&this->skelAnime, &gGekkoFallInAirAnim); @@ -507,10 +507,10 @@ void EnPametfrog_SetupFallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx this->timer = 30; this->collider.base.ocFlags1 |= OC1_ON; yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); - eye.x = (Math_SinS(yaw) * 300.0f) + this->actor.focus.pos.x; - eye.y = this->actor.focus.pos.y + 100.0f; - eye.z = (Math_CosS(yaw) * 300.0f) + this->actor.focus.pos.z; - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.focus.pos, &eye); + subCamEye.x = (Math_SinS(yaw) * 300.0f) + this->actor.focus.pos.x; + subCamEye.y = this->actor.focus.pos.y + 100.0f; + subCamEye.z = (Math_CosS(yaw) * 300.0f) + this->actor.focus.pos.z; + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.focus.pos, &subCamEye); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_DAMAGE); this->actionFunc = EnPametfrog_FallOffSnapper; } @@ -806,7 +806,7 @@ void EnPametfrog_LandOnSnapper(EnPametfrog* this, GlobalContext* globalCtx) { void EnPametfrog_SetupFallInAir(EnPametfrog* this, GlobalContext* globalCtx) { s16 yaw; - Vec3f eye; + Vec3f subCamEye; f32 xzDist; Animation_PlayOnce(&this->skelAnime, &gGekkoFallInAirAnim); @@ -828,7 +828,7 @@ void EnPametfrog_SetupFallInAir(EnPametfrog* this, GlobalContext* globalCtx) { yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); this->actor.world.pos.x += 30.0f * Math_SinS(yaw); this->actor.world.pos.z += 30.0f * Math_CosS(yaw); - if (this->camId != 0) { + if (this->subCamId != CAM_ID_MAIN) { xzDist = sqrtf(SQXZ(this->unk_2DC)); if (xzDist > 0.001f) { xzDist = 200.0f / xzDist; @@ -838,10 +838,10 @@ void EnPametfrog_SetupFallInAir(EnPametfrog* this, GlobalContext* globalCtx) { this->unk_2DC.z = 0.0f; } - eye.x = this->actor.world.pos.x + (xzDist * this->unk_2DC.x); - eye.y = (this->actor.world.pos.y + this->actor.home.pos.y) * 0.5f; - eye.z = this->actor.world.pos.z + (xzDist * this->unk_2DC.z); - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.world.pos, &eye); + subCamEye.x = this->actor.world.pos.x + (xzDist * this->unk_2DC.x); + subCamEye.y = (this->actor.world.pos.y + this->actor.home.pos.y) * 0.5f; + subCamEye.z = this->actor.world.pos.z + (xzDist * this->unk_2DC.z); + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.world.pos, &subCamEye); } this->actionFunc = EnPametfrog_FallInAir; @@ -858,9 +858,9 @@ void EnPametfrog_FallInAir(EnPametfrog* this, GlobalContext* globalCtx) { } } else { this->spinYaw += 0xF00; - if (this->camId != 0) { - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.world.pos, - &Play_GetCamera(globalCtx, this->camId)->eye); + if (this->subCamId != CAM_ID_MAIN) { + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.world.pos, + &Play_GetCamera(globalCtx, this->subCamId)->eye); } if (this->actor.bgCheckFlags & 1) { @@ -900,15 +900,15 @@ void EnPametfrog_FallOnGround(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupDefeatGekko(EnPametfrog* this, GlobalContext* globalCtx) { - Vec3f eye; + Vec3f subCamEye; s16 yaw = Actor_YawToPoint(this->actor.child, &this->actor.home.pos); s16 yawDiff = this->actor.yawTowardsPlayer - yaw; yaw = yawDiff > 0 ? yaw - 0x2000 : yaw + 0x2000; - eye.x = this->actor.child->focus.pos.x + 150.0f * Math_SinS(yaw); - eye.y = this->actor.child->focus.pos.y + 20.0f; - eye.z = this->actor.child->focus.pos.z + 150.0f * Math_CosS(yaw); - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.child->focus.pos, &eye); + subCamEye.x = this->actor.child->focus.pos.x + 150.0f * Math_SinS(yaw); + subCamEye.y = this->actor.child->focus.pos.y + 20.0f; + subCamEye.z = this->actor.child->focus.pos.z + 150.0f * Math_CosS(yaw); + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.child->focus.pos, &subCamEye); this->actor.params = GEKKO_DEFEAT; this->timer = 38; this->actionFunc = EnPametfrog_DefeatGekko; @@ -925,15 +925,15 @@ void EnPametfrog_DefeatGekko(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupDefeatSnapper(EnPametfrog* this, GlobalContext* globalCtx) { - Vec3f eye; + Vec3f subCamEye; s16 yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); s16 yawDiff = this->actor.yawTowardsPlayer - yaw; yaw = yawDiff > 0 ? yaw - 0x2000 : yaw + 0x2000; - eye.x = this->actor.world.pos.x + Math_SinS(yaw) * 150.0f; - eye.y = this->actor.world.pos.y + 20.0f; - eye.z = this->actor.world.pos.z + Math_CosS(yaw) * 150.0f; - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.world.pos, &eye); + subCamEye.x = this->actor.world.pos.x + Math_SinS(yaw) * 150.0f; + subCamEye.y = this->actor.world.pos.y + 20.0f; + subCamEye.z = this->actor.world.pos.z + Math_CosS(yaw) * 150.0f; + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.world.pos, &subCamEye); this->timer = 20; this->actionFunc = EnPametfrog_DefeatSnapper; } @@ -952,7 +952,7 @@ void EnPametfrog_SetupSpawnFrog(EnPametfrog* this, GlobalContext* globalCtx) { static Vec3f sAccel = { 0.0f, -0.5f, 0.0f }; static Color_RGBA8 primColor = { 250, 250, 250, 255 }; static Color_RGBA8 envColor = { 180, 180, 180, 255 }; - s16 yaw = BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))); + s16 yaw = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); Vec3f vec1; Vec3f vel; s32 i; @@ -1007,7 +1007,7 @@ void EnPametfrog_SetupCutscene(EnPametfrog* this) { void EnPametfrog_PlayCutscene(EnPametfrog* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_Start(this->cutscene, &this->actor); - this->camId = ActorCutscene_GetCurrentCamera(this->cutscene); + this->subCamId = ActorCutscene_GetCurrentCamera(this->cutscene); func_800B724C(globalCtx, &this->actor, 7); if (this->actor.colChkInfo.health == 0) { if (this->actor.params == GEKKO_PRE_SNAPPER) { @@ -1166,8 +1166,8 @@ void EnPametfrog_Stun(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupCallSnapper(EnPametfrog* this, GlobalContext* globalCtx) { - Vec3f eye; - Vec3f at; + Vec3f subCamEye; + Vec3f subCamAt; s16 yawDiff; Animation_MorphToPlayOnce(&this->skelAnime, &gGekkoCallAnim, 3.0f); @@ -1183,15 +1183,15 @@ void EnPametfrog_SetupCallSnapper(EnPametfrog* this, GlobalContext* globalCtx) { } this->actor.shape.rot.y = this->actor.world.rot.y; - at.x = this->actor.world.pos.x; - at.z = this->actor.world.pos.z; - at.y = this->actor.world.pos.y + 45.0f; - eye.x = (Math_SinS(this->actor.shape.rot.y) * 90.0f) + at.x; - eye.z = (Math_CosS(this->actor.shape.rot.y) * 90.0f) + at.z; - eye.y = at.y + 4.0f; + subCamAt.x = this->actor.world.pos.x; + subCamAt.z = this->actor.world.pos.z; + subCamAt.y = this->actor.world.pos.y + 45.0f; + subCamEye.x = (Math_SinS(this->actor.shape.rot.y) * 90.0f) + subCamAt.x; + subCamEye.z = (Math_CosS(this->actor.shape.rot.y) * 90.0f) + subCamAt.z; + subCamEye.y = subCamAt.y + 4.0f; // Zooms in on Gekko - Play_CameraSetAtEye(globalCtx, this->camId, &at, &eye); + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCamEye); this->timer = 0; this->actor.hintId = 0x5F; this->actionFunc = EnPametfrog_CallSnapper; @@ -1204,26 +1204,26 @@ void EnPametfrog_CallSnapper(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupSnapperSpawn(EnPametfrog* this, GlobalContext* globalCtx) { - Vec3f at; - Vec3f eye; + Vec3f subCamAt; + Vec3f subCamEye; s16 yaw; EnPametfrog_PlaceSnapper(this, globalCtx); - at.x = this->actor.child->world.pos.x; - at.z = this->actor.child->world.pos.z; - at.y = this->actor.child->floorHeight + 50.0f; + subCamAt.x = this->actor.child->world.pos.x; + subCamAt.z = this->actor.child->world.pos.z; + subCamAt.y = this->actor.child->floorHeight + 50.0f; if ((s16)(Actor_YawToPoint(&this->actor, &this->actor.home.pos) - this->actor.shape.rot.y) > 0) { yaw = this->actor.child->shape.rot.y - 0x1000; } else { yaw = this->actor.child->shape.rot.y + 0x1000; } - eye.x = (Math_SinS(yaw) * 500.0f) + at.x; - eye.y = at.y + 55.0f; - eye.z = (Math_CosS(yaw) * 500.0f) + at.z; + subCamEye.x = (Math_SinS(yaw) * 500.0f) + subCamAt.x; + subCamEye.y = subCamAt.y + 55.0f; + subCamEye.z = (Math_CosS(yaw) * 500.0f) + subCamAt.z; // Zooms in on Snapper spawn point - Play_CameraSetAtEye(globalCtx, this->camId, &at, &eye); + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCamEye); this->quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6); Quake_SetSpeed(this->quake, 18000); Quake_SetQuakeValues(this->quake, 2, 0, 0, 0); diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h index 957a46cfc..97a682825 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h @@ -69,7 +69,7 @@ typedef struct EnPametfrog { /* 0x2B4 */ s16 quake; /* 0x2B6 */ s16 timer; /* 0x2B8 */ s16 spinYaw; - /* 0x2BA */ s16 camId; + /* 0x2BA */ s16 subCamId; /* 0x2BC */ s16 freezeTimer; /* 0x2C0 */ f32 wallRotation; /* 0x2C4 */ f32 unk_2C4; diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index eeec68405..fe043938a 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -537,7 +537,8 @@ s32 func_80AF81E8(EnPm* this, GlobalContext* globalCtx) { case 4: case 6: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), this->actor.child); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), + this->actor.child); } this->unk_378++; ret = true; @@ -549,7 +550,7 @@ s32 func_80AF81E8(EnPm* this, GlobalContext* globalCtx) { if ((gSaveContext.weekEventReg[86] & 8) && (this->unk_378 == 3)) { ActorCutscene_Stop(sp2A); } else { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); } this->unk_378++; ret = true; @@ -579,7 +580,7 @@ s32 func_80AF8348(EnPm* this, GlobalContext* globalCtx) { case 4: case 6: case 8: - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); this->unk_378++; ret = true; break; @@ -589,7 +590,8 @@ s32 func_80AF8348(EnPm* this, GlobalContext* globalCtx) { case 5: case 7: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), this->actor.child); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), + this->actor.child); } this->unk_378++; ret = true; diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index fde3009e6..b5a3655ac 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c @@ -1164,7 +1164,7 @@ void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, temp_s7->r, temp_s7->g, temp_s7->b, phi_s5); Matrix_InsertTranslation(this->unk_22C[i].x, this->unk_22C[i].y, this->unk_22C[i].z, MTXMODE_NEW); - Matrix_InsertRotation(0, BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), 0, MTXMODE_APPLY); + Matrix_InsertRotation(0, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), 0, MTXMODE_APPLY); if (this->actionFunc == func_80B1BA90) { f32 phi_f0; diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.c b/src/overlays/actors/ovl_En_Poh/z_en_poh.c index 1c524d78f..e3a5d30be 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -404,7 +404,7 @@ void func_80B2D300(EnPoh* this, GlobalContext* globalCtx) { this->unk_18E++; if (this->unk_18E < 8) { - sp38 = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x4800; + sp38 = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800; if (this->unk_18E < 5) { sp3A = (this->unk_18E * 0x1000) - 0x4000; sp44.y = (Math_SinS(sp3A) * 23.0f) + (this->actor.world.pos.y + 40.0f); @@ -1006,7 +1006,8 @@ void func_80B2F37C(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 170, 255, this->unk_197); gDPSetEnvColor(POLY_XLU_DISP++, this->unk_194, this->unk_195, this->unk_196, 255); - Matrix_InsertYRotation_f((func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 32768), MTXMODE_APPLY); + Matrix_InsertYRotation_f((Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 32768), + MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_po_DL_003850); diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index a7658263f..db7b7a1fc 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -939,7 +939,7 @@ s32 func_80A87B48(Actor* thisx, GlobalContext* globalCtx) { case 1: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - sp3E = BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))); + sp3E = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); Math_Vec3f_Copy(&sp4C, &gZeroVec3f); sp4C.z = 40.0f; Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, sp3E, &sp4C, &sp40); diff --git a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c index 41af7bce8..314d168cc 100644 --- a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c +++ b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c @@ -296,7 +296,7 @@ void EnWaterEffect_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); if (ptr->unk_00 == 1) { - Matrix_RotateY(func_800DFC68(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); + Matrix_RotateY(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); } else { Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); } @@ -535,7 +535,7 @@ void func_80A5A184(Actor* thisx, GlobalContext* globalCtx2) { if (ptr->unk_2A >= 2) { Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); } else { - Matrix_RotateY(func_800DFC68(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); + Matrix_RotateY(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); } Matrix_Scale(ptr->unk_2C.x, ptr->unk_2C.y, 1.0f, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c index 2b6b332f4..5237d9021 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c @@ -268,7 +268,7 @@ void ObjAqua_Draw(Actor* thisx, GlobalContext* globalCtx) { ObjAqua* this = THIS; s32 framesTemp; s32 pad; - s16 yaw = func_800DFCDC(globalCtx->cameraPtrs[globalCtx->activeCamera]) + 0x8000; + s16 yaw = Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) + 0x8000; s32 actionFuncTemp = this->actionFunc == func_80ACBDFC; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c index dfd4ec65a..2ec24e73e 100644 --- a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c +++ b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c @@ -35,7 +35,7 @@ void ObjFunen_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY((s16)(func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) - 0x8000), MTXMODE_APPLY); + Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - 0x8000), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH); diff --git a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c index d580c5e8a..740439ead 100644 --- a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c +++ b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c @@ -64,7 +64,7 @@ void ObjKinoko_Update(Actor* thisx, GlobalContext* globalCtx) { } thisx->scale.y = thisx->scale.x; thisx->scale.z = thisx->scale.x; - thisx->shape.rot.y = func_800DFCDC(globalCtx->cameraPtrs[globalCtx->activeCamera]) + 0x8000; + thisx->shape.rot.y = Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) + 0x8000; } } 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 a6e3782bc..2996ce5ae 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -313,7 +313,8 @@ void ObjSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); Matrix_InsertTranslation(0.0f, OBJ_SYOKUDAI_FLAME_HEIGHT, 0.0f, MTXMODE_APPLY); - Matrix_RotateY(BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) - thisx->shape.rot.y), MTXMODE_APPLY); + Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - thisx->shape.rot.y), + MTXMODE_APPLY); Matrix_Scale(flameScale, flameScale, flameScale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index 2444b5010..5b0a5d433 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -222,7 +222,7 @@ void func_808DC454(ObjectKankyo* this, GlobalContext* globalCtx) { this->unk_14C[i].unk_08 = globalCtx->view.eye.z + (spC8 * 120.0f); this->unk_14C[i].unk_0C = (Rand_ZeroOne() - 0.5f) * (2.0f * temp_120); - temp_f22 = (func_800DFCB4(GET_ACTIVE_CAM(globalCtx)) * 0.004f) + 60.0f; + temp_f22 = (Camera_GetCamDirPitch(GET_ACTIVE_CAM(globalCtx)) * 0.004f) + 60.0f; if (temp_f22 < 20.0f) { temp_f22 = 20.0f; } @@ -273,7 +273,7 @@ void func_808DC454(ObjectKankyo* this, GlobalContext* globalCtx) { this->unk_14C[i].unk_10 -= this->unk_14C[i].unk_18 - (spC0 * 3.0f * (globalCtx->envCtx.windSpeed / 100.0f)); - temp_f22 = (-func_800DFCB4(GET_ACTIVE_CAM(globalCtx)) * 0.012f) + 40.0f; + temp_f22 = (-Camera_GetCamDirPitch(GET_ACTIVE_CAM(globalCtx)) * 0.012f) + 40.0f; if (temp_f22 < -40.0f) { temp_f22 = -40.0f; } @@ -514,7 +514,7 @@ void func_808DD3C8(Actor* thisx, GlobalContext* globalCtx2) { f32 temp_f2; f32 tempf; - if ((globalCtx->cameraPtrs[MAIN_CAM]->flags2 & 0x100) || ((u8)globalCtx->envCtx.unk_E2 == 0)) { + if ((globalCtx->cameraPtrs[CAM_ID_MAIN]->flags2 & 0x100) || ((u8)globalCtx->envCtx.unk_E2 == 0)) { return; } @@ -592,7 +592,7 @@ void func_808DD970(Actor* thisx, GlobalContext* globalCtx2) { if (globalCtx->sceneNum == SCENE_KYOJINNOMA) { phi_f26 = 1.0f; } else { - tempA = func_800E031C(GET_ACTIVE_CAM(globalCtx)); + tempA = Camera_GetWaterYPos(GET_ACTIVE_CAM(globalCtx)); if (tempA != BGCHECK_Y_MIN) { tempA -= globalCtx->view.eye.y; phi_f26 = tempA / 4000.0f; @@ -602,7 +602,7 @@ void func_808DD970(Actor* thisx, GlobalContext* globalCtx2) { phi_f26 = CLAMP_MAX(phi_f26, 1.0f); - if (!(globalCtx->cameraPtrs[MAIN_CAM]->flags2 & 0x100) || (phi_f26 == 0.0f)) { + if (!(globalCtx->cameraPtrs[CAM_ID_MAIN]->flags2 & 0x100) || (phi_f26 == 0.0f)) { return; } } diff --git a/tools/actorfixer.py b/tools/actorfixer.py index a94f2b941..c54a72422 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -379,6 +379,31 @@ animdict = { "func_8017F9C0": "Math3D_XZInSphere", "func_8017FA34": "Math3D_XYInSphere", "func_8017FAA8": "Math3D_YZInSphere", + + "func_800DFB14": "Camera_ChangeDataIdx", + "func_800DFC68": "Camera_GetInputDirYaw", + "func_800DFCB4": "Camera_GetCamDirPitch", + "func_800DFCDC": "Camera_GetCamDirYaw", + "func_800E0308": "Camera_SetTargetActor", + "func_800E031C": "Camera_GetWaterYPos", + "func_800E02AC": "Camera_SetToTrackActor", + + "func_801694DC": "Play_CreateSubCamera", + "Play_GetActiveCameraIndex": "Play_GetActiveCamId", + "func_80169590": "Play_CameraChangeStatus", + "func_80169600": "Play_ClearCamera", + "func_80169668": "Play_ClearAllSubCameras", + "func_8016981C": "Play_CameraSetAtEyeUp", + "func_80169940": "Play_CameraSetFov", + "func_80169988": "Play_CameraSetRoll", + "func_801699D4": "Play_CopyCamera", + "func_80169AC0": "Play_CameraChangeSetting", + "func_80169BC4": "Play_CameraGetUID", + "func_80169C64": "Play_GetCsCamDataSetting", + "func_80169C84": "Play_GetCsCamDataVec3s", + + "func_8017D2FC": "Math3D_LineSegVsPlane", + "func_8013A7C0": "SubS_FindDoor", "func_8013E640": "SubS_FindActorCustom", "func_ActorCategoryIterateById": "SubS_FindActor", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 73e654dfe..1f4d019f0 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1272,13 +1272,13 @@ 0x800DF86C:("func_800DF86C",), 0x800DF8EC:("func_800DF8EC",), 0x800DFAC8:("func_800DFAC8",), - 0x800DFB14:("func_800DFB14",), + 0x800DFB14:("Camera_ChangeDataIdx",), 0x800DFC1C:("func_800DFC1C",), 0x800DFC40:("func_800DFC40",), - 0x800DFC68:("func_800DFC68",), + 0x800DFC68:("Camera_GetInputDirYaw",), 0x800DFC90:("func_800DFC90",), - 0x800DFCB4:("func_800DFCB4",), - 0x800DFCDC:("func_800DFCDC",), + 0x800DFCB4:("Camera_GetCamDirPitch",), + 0x800DFCDC:("Camera_GetCamDirYaw",), 0x800DFD04:("func_800DFD04",), 0x800DFD78:("func_800DFD78",), 0x800DFEF0:("func_800DFEF0",), @@ -1294,9 +1294,9 @@ 0x800E01DC:("func_800E01DC",), 0x800E0228:("func_800E0228",), 0x800E0238:("func_800E0238",), - 0x800E02AC:("func_800E02AC",), - 0x800E0308:("func_800E0308",), - 0x800E031C:("func_800E031C",), + 0x800E02AC:("Camera_SetToTrackActor",), + 0x800E0308:("Camera_SetTargetActor",), + 0x800E031C:("Camera_GetWaterYPos",), 0x800E0348:("func_800E0348",), 0x800E03A0:("DamageTable_Get",), 0x800E03CC:("DamageTable_Clear",), @@ -3006,24 +3006,24 @@ 0x801692C4:("func_801692C4",), 0x801693D4:("Play_SceneInit",), 0x80169474:("func_80169474",), - 0x801694DC:("func_801694DC",), - 0x80169584:("Play_GetActiveCameraIndex",), - 0x80169590:("func_80169590",), - 0x80169600:("func_80169600",), - 0x80169668:("func_80169668",), + 0x801694DC:("Play_CreateSubCamera",), + 0x80169584:("Play_GetActiveCamId",), + 0x80169590:("Play_CameraChangeStatus",), + 0x80169600:("Play_ClearCamera",), + 0x80169668:("Play_ClearAllSubCameras",), 0x801696D4:("Play_GetCamera",), 0x8016970C:("Play_CameraSetAtEye",), - 0x8016981C:("func_8016981C",), - 0x80169940:("func_80169940",), - 0x80169988:("func_80169988",), - 0x801699D4:("func_801699D4",), + 0x8016981C:("Play_CameraSetAtEyeUp",), + 0x80169940:("Play_CameraSetFov",), + 0x80169988:("Play_CameraSetRoll",), + 0x801699D4:("Play_CopyCamera",), 0x80169A50:("func_80169A50",), - 0x80169AC0:("func_80169AC0",), + 0x80169AC0:("Play_CameraChangeSetting",), 0x80169AFC:("func_80169AFC",), - 0x80169BC4:("func_80169BC4",), + 0x80169BC4:("Play_CameraGetUID",), 0x80169BF8:("func_80169BF8",), - 0x80169C64:("func_80169C64",), - 0x80169C84:("func_80169C84",), + 0x80169C64:("Play_GetCsCamDataSetting",), + 0x80169C84:("Play_GetCsCamDataVec3s",), 0x80169CBC:("convert_scene_number_among_shared_scenes",), 0x80169D40:("func_80169D40",), 0x80169DCC:("func_80169DCC",), @@ -3320,7 +3320,7 @@ 0x8017D020:("Math3D_TriChkLineSegParaZIntersect",), 0x8017D1AC:("func_8017D1AC",), 0x8017D220:("func_8017D220",), - 0x8017D2FC:("func_8017D2FC",), + 0x8017D2FC:("Math3D_LineSegVsPlane",), 0x8017D404:("func_8017D404",), 0x8017D568:("Math3D_TriSetCoords",), 0x8017D618:("Math3D_IsPointInSphere",), @@ -5688,7 +5688,7 @@ 0x808A3A44:("EnMinifrog_Jump",), 0x808A3B04:("EnMinifrog_TurnToPlayer",), 0x808A3B3C:("EnMinifrog_TurnToMissingFrog",), - 0x808A3B74:("EnMinifrog_SetCamera",), + 0x808A3B74:("EnMinifrog_SpawnDust",), 0x808A3DA8:("EnMinifrog_ReturnFrogCutscene",), 0x808A3F88:("EnMinifrog_SpawnGrowAndShrink",), 0x808A4040:("EnMinifrog_Idle",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index df41d4829..f14ca7307 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -786,13 +786,13 @@ asm/non_matchings/code/z_camera/Camera_ChangeMode.s,Camera_ChangeMode,0x800DF840 asm/non_matchings/code/z_camera/func_800DF86C.s,func_800DF86C,0x800DF86C,0x20 asm/non_matchings/code/z_camera/func_800DF8EC.s,func_800DF8EC,0x800DF8EC,0x77 asm/non_matchings/code/z_camera/func_800DFAC8.s,func_800DFAC8,0x800DFAC8,0x13 -asm/non_matchings/code/z_camera/func_800DFB14.s,func_800DFB14,0x800DFB14,0x42 +asm/non_matchings/code/z_camera/Camera_ChangeDataIdx.s,Camera_ChangeDataIdx,0x800DFB14,0x42 asm/non_matchings/code/z_camera/func_800DFC1C.s,func_800DFC1C,0x800DFC1C,0x9 asm/non_matchings/code/z_camera/func_800DFC40.s,func_800DFC40,0x800DFC40,0xA -asm/non_matchings/code/z_camera/func_800DFC68.s,func_800DFC68,0x800DFC68,0xA +asm/non_matchings/code/z_camera/Camera_GetInputDirYaw.s,Camera_GetInputDirYaw,0x800DFC68,0xA asm/non_matchings/code/z_camera/func_800DFC90.s,func_800DFC90,0x800DFC90,0x9 -asm/non_matchings/code/z_camera/func_800DFCB4.s,func_800DFCB4,0x800DFCB4,0xA -asm/non_matchings/code/z_camera/func_800DFCDC.s,func_800DFCDC,0x800DFCDC,0xA +asm/non_matchings/code/z_camera/Camera_GetCamDirPitch.s,Camera_GetCamDirPitch,0x800DFCB4,0xA +asm/non_matchings/code/z_camera/Camera_GetCamDirYaw.s,Camera_GetCamDirYaw,0x800DFCDC,0xA asm/non_matchings/code/z_camera/func_800DFD04.s,func_800DFD04,0x800DFD04,0x1D asm/non_matchings/code/z_camera/func_800DFD78.s,func_800DFD78,0x800DFD78,0x5E asm/non_matchings/code/z_camera/func_800DFEF0.s,func_800DFEF0,0x800DFEF0,0xA @@ -808,9 +808,9 @@ asm/non_matchings/code/z_camera/func_800E01B8.s,func_800E01B8,0x800E01B8,0x9 asm/non_matchings/code/z_camera/func_800E01DC.s,func_800E01DC,0x800E01DC,0x13 asm/non_matchings/code/z_camera/func_800E0228.s,func_800E0228,0x800E0228,0x4 asm/non_matchings/code/z_camera/func_800E0238.s,func_800E0238,0x800E0238,0x1D -asm/non_matchings/code/z_camera/func_800E02AC.s,func_800E02AC,0x800E02AC,0x17 -asm/non_matchings/code/z_camera/func_800E0308.s,func_800E0308,0x800E0308,0x5 -asm/non_matchings/code/z_camera/func_800E031C.s,func_800E031C,0x800E031C,0xB +asm/non_matchings/code/z_camera/Camera_SetToTrackActor.s,Camera_SetToTrackActor,0x800E02AC,0x17 +asm/non_matchings/code/z_camera/Camera_SetTargetActor.s,Camera_SetTargetActor,0x800E0308,0x5 +asm/non_matchings/code/z_camera/Camera_GetWaterYPos.s,Camera_GetWaterYPos,0x800E031C,0xB asm/non_matchings/code/z_camera/func_800E0348.s,func_800E0348,0x800E0348,0x16 asm/non_matchings/code/z_collision_btltbls/DamageTable_Get.s,DamageTable_Get,0x800E03A0,0xB asm/non_matchings/code/z_collision_btltbls/DamageTable_Clear.s,DamageTable_Clear,0x800E03CC,0xD @@ -2520,24 +2520,24 @@ asm/non_matchings/code/z_play/func_8016927C.s,func_8016927C,0x8016927C,0x12 asm/non_matchings/code/z_play/func_801692C4.s,func_801692C4,0x801692C4,0x44 asm/non_matchings/code/z_play/Play_SceneInit.s,Play_SceneInit,0x801693D4,0x28 asm/non_matchings/code/z_play/func_80169474.s,func_80169474,0x80169474,0x1A -asm/non_matchings/code/z_play/func_801694DC.s,func_801694DC,0x801694DC,0x2A -asm/non_matchings/code/z_play/Play_GetActiveCameraIndex.s,Play_GetActiveCameraIndex,0x80169584,0x3 -asm/non_matchings/code/z_play/func_80169590.s,func_80169590,0x80169590,0x1C -asm/non_matchings/code/z_play/func_80169600.s,func_80169600,0x80169600,0x1A -asm/non_matchings/code/z_play/func_80169668.s,func_80169668,0x80169668,0x1B +asm/non_matchings/code/z_play/Play_CreateSubCamera.s,Play_CreateSubCamera,0x801694DC,0x2A +asm/non_matchings/code/z_play/Play_GetActiveCamId.s,Play_GetActiveCamId,0x80169584,0x3 +asm/non_matchings/code/z_play/Play_CameraChangeStatus.s,Play_CameraChangeStatus,0x80169590,0x1C +asm/non_matchings/code/z_play/Play_ClearCamera.s,Play_ClearCamera,0x80169600,0x1A +asm/non_matchings/code/z_play/Play_ClearAllSubCameras.s,Play_ClearAllSubCameras,0x80169668,0x1B asm/non_matchings/code/z_play/Play_GetCamera.s,Play_GetCamera,0x801696D4,0xE asm/non_matchings/code/z_play/Play_CameraSetAtEye.s,Play_CameraSetAtEye,0x8016970C,0x44 -asm/non_matchings/code/z_play/func_8016981C.s,func_8016981C,0x8016981C,0x49 -asm/non_matchings/code/z_play/func_80169940.s,func_80169940,0x80169940,0x12 -asm/non_matchings/code/z_play/func_80169988.s,func_80169988,0x80169988,0x13 -asm/non_matchings/code/z_play/func_801699D4.s,func_801699D4,0x801699D4,0x1F +asm/non_matchings/code/z_play/Play_CameraSetAtEyeUp.s,Play_CameraSetAtEyeUp,0x8016981C,0x49 +asm/non_matchings/code/z_play/Play_CameraSetFov.s,Play_CameraSetFov,0x80169940,0x12 +asm/non_matchings/code/z_play/Play_CameraSetRoll.s,Play_CameraSetRoll,0x80169988,0x13 +asm/non_matchings/code/z_play/Play_CopyCamera.s,Play_CopyCamera,0x801699D4,0x1F asm/non_matchings/code/z_play/func_80169A50.s,func_80169A50,0x80169A50,0x1C -asm/non_matchings/code/z_play/func_80169AC0.s,func_80169AC0,0x80169AC0,0xF +asm/non_matchings/code/z_play/Play_CameraChangeSetting.s,Play_CameraChangeSetting,0x80169AC0,0xF asm/non_matchings/code/z_play/func_80169AFC.s,func_80169AFC,0x80169AFC,0x32 -asm/non_matchings/code/z_play/func_80169BC4.s,func_80169BC4,0x80169BC4,0xD +asm/non_matchings/code/z_play/Play_CameraGetUID.s,Play_CameraGetUID,0x80169BC4,0xD asm/non_matchings/code/z_play/func_80169BF8.s,func_80169BF8,0x80169BF8,0x1B -asm/non_matchings/code/z_play/func_80169C64.s,func_80169C64,0x80169C64,0x8 -asm/non_matchings/code/z_play/func_80169C84.s,func_80169C84,0x80169C84,0xE +asm/non_matchings/code/z_play/Play_GetCsCamDataSetting.s,Play_GetCsCamDataSetting,0x80169C64,0x8 +asm/non_matchings/code/z_play/Play_GetCsCamDataVec3s.s,Play_GetCsCamDataVec3s,0x80169C84,0xE asm/non_matchings/code/z_play/convert_scene_number_among_shared_scenes.s,convert_scene_number_among_shared_scenes,0x80169CBC,0x21 asm/non_matchings/code/z_play/func_80169D40.s,func_80169D40,0x80169D40,0x23 asm/non_matchings/code/z_play/func_80169DCC.s,func_80169DCC,0x80169DCC,0x28 @@ -2834,7 +2834,7 @@ asm/non_matchings/code/sys_math3d/func_8017CFA4.s,func_8017CFA4,0x8017CFA4,0x1F asm/non_matchings/code/sys_math3d/Math3D_TriChkLineSegParaZIntersect.s,Math3D_TriChkLineSegParaZIntersect,0x8017D020,0x63 asm/non_matchings/code/sys_math3d/func_8017D1AC.s,func_8017D1AC,0x8017D1AC,0x1D asm/non_matchings/code/sys_math3d/func_8017D220.s,func_8017D220,0x8017D220,0x37 -asm/non_matchings/code/sys_math3d/func_8017D2FC.s,func_8017D2FC,0x8017D2FC,0x42 +asm/non_matchings/code/sys_math3d/Math3D_LineSegVsPlane.s,Math3D_LineSegVsPlane,0x8017D2FC,0x42 asm/non_matchings/code/sys_math3d/func_8017D404.s,func_8017D404,0x8017D404,0x59 asm/non_matchings/code/sys_math3d/Math3D_TriSetCoords.s,Math3D_TriSetCoords,0x8017D568,0x2C asm/non_matchings/code/sys_math3d/Math3D_IsPointInSphere.s,Math3D_IsPointInSphere,0x8017D618,0x14 From 91b983776e33948ebe0f14eb358bc1595c2c2251 Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Sun, 20 Feb 2022 12:53:05 -0500 Subject: [PATCH 047/257] Set up AnsiColor Jenkins plugin (#682) * Set up AnsiColor Jenkins plugin * deliberate error * Update z_en_firefly.c --- Jenkinsfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index cf5d8f3b6..50cd88908 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,6 +3,10 @@ pipeline { label 'mm' } + options { + ansiColor('xterm') + } + stages { stage('Check formatting') { steps { From 684df37ebca2552463f449d1d3d9115de5cf8ed0 Mon Sep 17 00:00:00 2001 From: louist103 <35883445+louist103@users.noreply.github.com> Date: Sun, 27 Feb 2022 17:37:24 -0500 Subject: [PATCH 048/257] En_Door (#571) * progress * it matches mostly * symbols * done for now * fix warnings and stuff * formatter * NON_EQUIVALENT * pr fixes * formatter and actorfixer * fix pm * more fixes * PR fixes * it actually builds again * matching function Co-authored-by: Louis --- assets/xml/objects/gameplay_field_keep.xml | 8 +- assets/xml/objects/gameplay_keep.xml | 8 +- assets/xml/objects/object_dor02.xml | 6 +- assets/xml/objects/object_dor03.xml | 4 +- assets/xml/objects/object_dor04.xml | 6 +- assets/xml/objects/object_kaizoku_obj.xml | 4 +- assets/xml/objects/object_numa_obj.xml | 2 +- assets/xml/objects/object_wdor04.xml | 6 +- assets/xml/objects/object_wdor05.xml | 6 +- spec | 2 - src/code/z_en_hy_code.c | 20 +- src/code/z_sub_s.c | 2 +- src/overlays/actors/ovl_En_Door/z_en_door.c | 513 +++++++++++++++++++- src/overlays/actors/ovl_En_Door/z_en_door.h | 23 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 18 +- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 16 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 16 +- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 18 +- tools/actorfixer.py | 23 +- tools/disasm/functions.txt | 2 +- tools/disasm/variables.txt | 12 +- undefined_syms.txt | 2 - 22 files changed, 600 insertions(+), 117 deletions(-) diff --git a/assets/xml/objects/gameplay_field_keep.xml b/assets/xml/objects/gameplay_field_keep.xml index 537d596a6..a73a2f28d 100644 --- a/assets/xml/objects/gameplay_field_keep.xml +++ b/assets/xml/objects/gameplay_field_keep.xml @@ -26,12 +26,12 @@ - - - + + + - + diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index a6504f2f3..265f1d560 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -882,8 +882,8 @@ - - + + @@ -892,14 +892,14 @@ - + - + diff --git a/assets/xml/objects/object_dor02.xml b/assets/xml/objects/object_dor02.xml index 0b64a9b1b..c60fa9ba9 100644 --- a/assets/xml/objects/object_dor02.xml +++ b/assets/xml/objects/object_dor02.xml @@ -1,7 +1,7 @@  - - - + + + diff --git a/assets/xml/objects/object_dor03.xml b/assets/xml/objects/object_dor03.xml index c374837ea..941fa6fcc 100644 --- a/assets/xml/objects/object_dor03.xml +++ b/assets/xml/objects/object_dor03.xml @@ -1,6 +1,6 @@  - - + + diff --git a/assets/xml/objects/object_dor04.xml b/assets/xml/objects/object_dor04.xml index 2d1ac5611..394f5a6fe 100644 --- a/assets/xml/objects/object_dor04.xml +++ b/assets/xml/objects/object_dor04.xml @@ -1,7 +1,7 @@  - - - + + + diff --git a/assets/xml/objects/object_kaizoku_obj.xml b/assets/xml/objects/object_kaizoku_obj.xml index a38d16827..8dd96770a 100644 --- a/assets/xml/objects/object_kaizoku_obj.xml +++ b/assets/xml/objects/object_kaizoku_obj.xml @@ -28,8 +28,8 @@ - - + + diff --git a/assets/xml/objects/object_numa_obj.xml b/assets/xml/objects/object_numa_obj.xml index e8035b3e8..a450cf11a 100644 --- a/assets/xml/objects/object_numa_obj.xml +++ b/assets/xml/objects/object_numa_obj.xml @@ -12,7 +12,7 @@ - + diff --git a/assets/xml/objects/object_wdor04.xml b/assets/xml/objects/object_wdor04.xml index 040df1598..07ad601dd 100644 --- a/assets/xml/objects/object_wdor04.xml +++ b/assets/xml/objects/object_wdor04.xml @@ -1,7 +1,7 @@  - - - + + + diff --git a/assets/xml/objects/object_wdor05.xml b/assets/xml/objects/object_wdor05.xml index f8fda2322..6eb0f4ed0 100644 --- a/assets/xml/objects/object_wdor05.xml +++ b/assets/xml/objects/object_wdor05.xml @@ -1,7 +1,7 @@  - - - + + + diff --git a/spec b/spec index 12c9d6e3c..ec0af718e 100644 --- a/spec +++ b/spec @@ -775,8 +775,6 @@ beginseg name "ovl_En_Door" compress include "build/src/overlays/actors/ovl_En_Door/z_en_door.o" - include "build/data/ovl_En_Door/ovl_En_Door.data.o" - include "build/data/ovl_En_Door/ovl_En_Door.bss.o" include "build/data/ovl_En_Door/ovl_En_Door.reloc.o" endseg diff --git a/src/code/z_en_hy_code.c b/src/code/z_en_hy_code.c index b803b291c..915687125 100644 --- a/src/code/z_en_hy_code.c +++ b/src/code/z_en_hy_code.c @@ -61,21 +61,21 @@ s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) { EnDoor* nearestDoor = NULL; Actor* doorIter = NULL; - EnDoor* door; f32 dist; + EnDoor* door; s32 isSetup = false; f32 minDist = 0.0f; do { doorIter = SubS_FindActor(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); door = (EnDoor*)doorIter; - dist = Actor_DistanceBetweenActors(actor, &door->actor); + dist = Actor_DistanceBetweenActors(actor, &door->dyna.actor); if (!isSetup || (dist < minDist)) { nearestDoor = door; minDist = dist; isSetup = true; } - doorIter = door->actor.next; + doorIter = door->dyna.actor.next; } while (doorIter != NULL); if (1) {} @@ -130,20 +130,20 @@ s32 EnHy_Init(EnHy* enHy, GlobalContext* globalCtx, FlexSkeletonHeader* skeleton void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, EnDoor* door, s16 arg3, s16 arg4) { s32 pad; - s8 sp3B; + s8 animIndex; Vec3f offset; f32 phi_f0; - Actor_OffsetOfPointInActorCoords(&door->actor, &offset, &enHy->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&door->dyna.actor, &offset, &enHy->actor.world.pos); phi_f0 = (offset.z >= 0.0f) ? 1.0f : -1.0f; - sp3B = ((s8)phi_f0 < 0) ? 0 : 2; - EnHy_ChangeObjectAndAnim(enHy, globalCtx, (sp3B == 0) ? arg3 : arg4); + animIndex = ((s8)phi_f0 < 0) ? 0 : 2; + EnHy_ChangeObjectAndAnim(enHy, globalCtx, (animIndex == 0) ? arg3 : arg4); enHy->skelAnime.baseTransl = *enHy->skelAnime.jointTable; enHy->skelAnime.prevTransl = *enHy->skelAnime.jointTable; enHy->skelAnime.moveFlags |= 3; AnimationContext_SetMoveActor(globalCtx, &enHy->actor, &enHy->skelAnime, 1.0f); door->unk_1A1 = 1; - door->unk_1A0 = sp3B; + door->animIndex = animIndex; } s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5) { @@ -157,7 +157,7 @@ s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3 if (door != NULL) { ret = true; func_800F0BB4(enHy, globalCtx, door, arg3, arg4); - yaw = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->actor.world.pos); + yaw = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->dyna.actor.world.pos); enHy->actor.world.pos.x += arg5 * Math_SinS(yaw); enHy->actor.world.pos.z += arg5 * Math_CosS(yaw); enHy->actor.world.rot.y = -yaw; @@ -179,7 +179,7 @@ s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3) { if (door != NULL) { ret = true; func_800F0BB4(enHy, globalCtx, door, arg2, arg3); - enHy->actor.shape.rot.y = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->actor.world.pos); + enHy->actor.shape.rot.y = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->dyna.actor.world.pos); enHy->actor.world.rot.y = enHy->actor.shape.rot.y; enHy->actor.gravity = 0.0f; enHy->actor.flags &= ~ACTOR_FLAG_1; diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index eda973125..52a5b07da 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -21,7 +21,7 @@ EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5) { break; } - if ((door->unk_1A4 == 5) && (door->unk_1A5 == (u8)unk_1A5)) { + if ((door->unk_1A4 == 5) && (door->switchFlag == (u8)unk_1A5)) { break; } diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.c b/src/overlays/actors/ovl_En_Door/z_en_door.c index f907ae421..e5733c2b1 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -5,6 +5,20 @@ */ #include "z_en_door.h" +#include "objects/object_mkk/object_mkk.h" +#include "objects/object_dor01/object_dor01.h" +#include "objects/object_dor02/object_dor02.h" +#include "objects/object_dor03/object_dor03.h" +#include "objects/object_dor04/object_dor04.h" +#include "objects/object_wdor01/object_wdor01.h" +#include "objects/object_wdor02/object_wdor02.h" +#include "objects/object_wdor03/object_wdor03.h" +#include "objects/object_wdor04/object_wdor04.h" +#include "objects/object_wdor05/object_wdor05.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_numa_obj/object_numa_obj.h" +#include "objects/object_kaizoku_obj/object_kaizoku_obj.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +29,115 @@ void EnDoor_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDoor_Update(Actor* thisx, GlobalContext* globalCtx); void EnDoor_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80866B20(EnDoor*, GlobalContext*); +void func_8086704C(EnDoor*, GlobalContext*); +void func_80866F94(EnDoor*, GlobalContext*); +void func_80867080(EnDoor*, GlobalContext*); +void func_80867144(EnDoor*, GlobalContext*); +void func_808670F0(EnDoor*, GlobalContext*); +void func_80866A5C(EnDoor*, GlobalContext*); + +u8 D_808675D0[] = { + 0x0C, 0x00, 0x03, 0x0E, 0x02, 0x06, 0x00, 0x17, 0x00, 0x08, + 0x02, 0x00, 0x00, 0x06, 0x00, 0x02, 0x09, 0x07, 0x05, 0x00, +}; + +u8 D_808675E4[] = { + 0x0F, 0x09, 0x00, 0x47, 0x0F, 0x0C, 0x00, 0x15, 0x0C, 0x00, 0x01, 0x13, 0x11, 0x00, 0x0F, 0x0D, + 0x00, 0x0A, 0x0F, 0x0F, 0x00, 0x07, 0x0F, 0x00, 0x00, 0x02, 0x09, 0x09, 0x05, 0x09, 0x08, 0x0C, + 0x00, 0x02, 0x19, 0x00, 0x1C, 0x08, 0x07, 0x0F, 0x0D, 0x00, 0x02, 0x09, 0x09, 0x05, 0x0F, 0x0D, + 0x00, 0xEA, 0x0F, 0x11, 0x00, 0xE7, 0x0F, 0x00, 0x00, 0xE2, 0x09, 0x09, 0x0F, 0x0D, 0x00, 0xDC, + 0x0F, 0x0D, 0x00, 0xD9, 0x0F, 0x12, 0x00, 0x01, 0x05, 0x09, 0x09, 0x09, 0x09, 0x00, 0x00, 0x00, +}; + +u8 D_80867634[] = { + 0x02, 0x06, 0x00, 0x17, 0x00, 0x02, 0x09, 0x1C, 0x05, 0x00, 0x00, 0x00, +}; + +u8 D_80867640[] = { + 0x02, 0x15, 0x00, 0x16, 0x00, 0x01, 0x05, 0x09, 0x0B, 0x00, 0x00, 0x00, +}; +u8 D_8086764C[] = { + 0x02, 0x16, 0x00, 0x05, 0x00, 0x02, 0x09, 0x0A, 0x05, 0x00, 0x00, 0x00, +}; +u8 D_80867658[] = { + 0x0C, 0x00, 0x02, 0x0F, 0x00, 0x1C, 0x08, 0x02, 0x09, 0x0C, 0x02, 0x0F, 0x0A, 0x16, 0x00, + 0x02, 0x09, 0x0C, 0x05, 0x0C, 0x00, 0x03, 0x11, 0x0F, 0x0D, 0x00, 0x0D, 0x00, 0x33, 0x08, + 0x02, 0x09, 0x0C, 0x0F, 0x16, 0x00, 0x02, 0x09, 0x0C, 0x05, 0x09, 0x0C, 0x00, 0x00, +}; + +u8 D_80867684[] = { 0x05, 0x00, 0x00, 0x00 }; + +u8 D_80867688[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x0F, 0x05, 0x00 }; + +u8 D_80867690[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x10, 0x05, 0x00 }; + +u8 D_80867698[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x11, 0x05, 0x00 }; + +u8 D_808676A0[] = { + 0x02, 0x0A, 0x00, 0x15, 0x00, 0x0F, 0x02, 0x16, 0x00, 0x05, 0x00, 0x02, + 0x09, 0x12, 0x08, 0x02, 0x02, 0x09, 0x22, 0x09, 0x21, 0x05, 0x00, 0x00, +}; + +u8 D_808676B8[] = { + 0x08, 0x00, 0x14, 0x0C, 0x00, 0x03, 0x07, 0x0F, 0x08, 0x00, 0x01, 0x05, + 0x09, 0x13, 0x02, 0x08, 0x00, 0x14, 0x1E, 0x02, 0x09, 0x13, 0x05, 0x05, +}; + +u8 D_808676D0[] = { 0x05, 0x00, 0x00, 0x00 }; + +u8 D_808676D4[] = { 0x05, 0x00, 0x00, 0x00 }; + +u8 D_808676D8[] = { 0x0C, 0x00, 0x03, 0x05, 0x0F, 0x12, 0x00, 0x01, 0x05, 0x09, 0x14, 0x00 }; + +u8 D_808676E4[] = { 0x08, 0x00, 0x02, 0x09, 0x16, 0x05, 0x00, 0x00 }; + +u8 D_808676EC[] = { 0x05, 0x00, 0x00, 0x00 }; + +u8 D_808676F0[] = { + 0x0C, 0x00, 0x03, 0x05, 0x0F, 0x0A, 0x00, 0x07, 0x05, 0x02, + 0x0A, 0x00, 0x14, 0x00, 0xF9, 0x09, 0x15, 0x00, 0x00, 0x00, +}; + +u8 D_80867704[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_80867708[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_8086770C[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_80867710[] = { 0x05, 0x00, 0x00, 0x00 }; + +u8 D_80867714[] = { 0x0F, 0x14, 0x00, 0x02, 0x09, 0x17, 0x05, 0x00 }; + +u8 D_8086771C[] = { + 0x0C, 0x00, 0x01, 0x07, 0x0F, 0x02, 0x1E, 0x02, 0x09, 0x18, 0x05, 0x0C, + 0x00, 0x03, 0xFB, 0x0F, 0x14, 0x00, 0xF7, 0x09, 0x0C, 0x00, 0x00, 0x00, +}; + +u8 D_80867734[] = { 0x0F, 0x14, 0x00, 0x02, 0x09, 0x19, 0x05, 0x00 }; + +u8 D_8086773C[] = { 0x0F, 0x14, 0x00, 0x02, 0x09, 0x1A, 0x05, 0x00 }; + +u8 D_80867744[] = { + 0x0C, 0x00, 0x02, 0x04, 0x00, 0x63, 0x80, 0x06, 0x0F, 0x14, 0x00, 0x08, + 0x09, 0x1B, 0x0F, 0x12, 0x00, 0x02, 0x09, 0x1B, 0x05, 0x00, 0x00, 0x00, +}; + +u8 D_8086775C[] = { + 0x00, 0x34, 0x20, 0x17, 0x00, 0x4B, 0x20, 0x13, 0x00, 0x0E, 0x04, 0x02, 0x09, 0x1D, + 0x00, 0x3B, 0x01, 0x08, 0x00, 0x3D, 0x02, 0x02, 0x09, 0x1E, 0x09, 0x1F, 0x05, 0x05, +}; + +u8 D_80867778[] = { 0x09, 0x20, 0x00, 0x00 }; +u8 D_8086777C[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_80867780[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_80867784[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x23, 0x05, 0x00 }; + +// void* seems to keep the compiler happy. +void* D_8086778C[] = { + &D_808675D0, &D_808675E4, &D_80867634, &D_80867640, &D_8086764C, &D_80867658, &D_80867684, &D_80867688, + &D_80867690, &D_80867698, &D_808676A0, &D_808676B8, &D_808676D0, &D_808676D4, &D_808676D8, &D_808676E4, + &D_808676EC, &D_808676F0, &D_80867704, &D_80867708, &D_8086770C, &D_80867710, &D_80867714, &D_8086771C, + &D_80867734, &D_8086773C, &D_80867744, &D_8086775C, &D_80867778, &D_8086777C, &D_80867780, &D_80867784, +}; + const ActorInit En_Door_InitVars = { ACTOR_EN_DOOR, ACTORCAT_DOOR, @@ -28,38 +150,395 @@ const ActorInit En_Door_InitVars = { (ActorFunc)EnDoor_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80867954[] = { +typedef struct { + /* 0x00 */ s16 sceneNum; + /* 0x02 */ u8 dListIndex; + /* 0x04 */ s16 objectId; +} EnDoorInfo; + +static EnDoorInfo sObjInfo[] = { + { SCENE_MITURIN, 0x01, OBJECT_NUMA_OBJ }, + { SCENE_TENMON_DAI, 0x02, OBJECT_DOR01 }, + { SCENE_00KEIKOKU, 0x02, OBJECT_DOR01 }, + { SCENE_30GYOSON, 0x02, OBJECT_DOR01 }, + { SCENE_LABO, 0x02, OBJECT_DOR01 }, + { SCENE_33ZORACITY, 0x03, OBJECT_DOR02 }, + { SCENE_UNSET_31, 0x03, OBJECT_DOR02 }, + { SCENE_BANDROOM, 0x03, OBJECT_DOR02 }, + { SCENE_20SICHITAI, 0x04, OBJECT_DOR03 }, + { SCENE_20SICHITAI2, 0x04, OBJECT_DOR03 }, + { SCENE_MAP_SHOP, 0x04, OBJECT_DOR03 }, + { SCENE_KAIZOKU, 0x0B, OBJECT_KAIZOKU_OBJ }, + { SCENE_PIRATE, 0x0B, OBJECT_KAIZOKU_OBJ }, + { SCENE_TORIDE, 0x0B, OBJECT_KAIZOKU_OBJ }, + { SCENE_KINDAN2, 0x0C, OBJECT_KINSTA2_OBJ }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x08, OBJECT_WDOR03 }, + { -1, 0x07, OBJECT_WDOR02 }, + { -1, 0x06, OBJECT_WDOR01 }, + { -1, 0x07, OBJECT_WDOR02 }, + { -1, 0x06, OBJECT_WDOR01 }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x09, OBJECT_WDOR04 }, + { -1, 0x08, OBJECT_WDOR03 }, + { -1, 0x08, OBJECT_WDOR03 }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x06, OBJECT_WDOR01 }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x0A, OBJECT_WDOR05 }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x05, OBJECT_DOR04 }, + { -1, 0x09, OBJECT_WDOR04 }, + { -1, 0x04, OBJECT_DOR03 }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_U16(shape.rot.x, 0, ICHAIN_CONTINUE), ICHAIN_U16(shape.rot.z, 0, ICHAIN_STOP), }; -#endif +static AnimationHeader* sAnimations[] = { + &gameplay_keep_Anim_020658, &gameplay_keep_Anim_022CA8, &gameplay_keep_Anim_020658, &gameplay_keep_Anim_022E68, + &gameplay_keep_Anim_0204B4, &gameplay_keep_Anim_022BE8, &gameplay_keep_Anim_022D90, &gameplay_keep_Anim_022BE8, + &gameplay_keep_Anim_022FF0, &gameplay_keep_Anim_0205A0, +}; +static u8 sAnimOpenFrames[10] = { + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +}; -extern InitChainEntry D_80867954[]; +static u8 sAnimCloseFrames[10] = { + 60, 60, 60, 70, 70, 60, 60, 60, 60, 70, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/EnDoor_Init.s") +static Gfx* D_808679A4[14][2] = { + { gDoorLeftDL, gDoorRightDL }, + { gWoodfallDoorDL, gWoodfallDoorDL }, + { object_dor01_DL_000448, object_dor01_DL_000448 }, + { gZoraHallDoorDL, gZoraHallDoorDL }, + { gSwampDoorDL, gSwampDoorDL }, + { gMagicHagPotionShopDoorDL, gMagicHagPotionShopDoorDL }, + { object_wdor01_DL_000548, object_wdor01_DL_000548 }, // Lottery Shop / Curiosity Shop / Mayor's House Door + { object_wdor02_DL_000548, object_wdor02_DL_000548 }, // Trading Post / Post Office Door + { object_wdor03_DL_000548, object_wdor03_DL_000548 }, // Stockpot Inn & Swordsman's School Door + { gMilkBarDoorDL, gMilkBarDoorDL }, + { gMusicBoxHouseDoorDL, gMusicBoxHouseDoorDL }, + { gPiratesFortressDoorDL, gPiratesFortressDoorDL }, + { object_mkk_DL_000310, object_mkk_DL_000310 }, + { gFieldWoodDoorLeftDL, gFieldWoodDoorRightDL }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/EnDoor_Destroy.s") +void EnDoor_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + s32 objectBankIndex; + EnDoorInfo* objectInfo = sObjInfo; + EnDoor* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_80866A5C.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_80866B20.s") + this->unk_1A4 = ENDOOR_GET_PARAMS_7(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_80866F94.s") + this->switchFlag = ENDOOR_GET_PARAMS_7F(thisx); + if ((this->unk_1A4 == 7) && (this->switchFlag == 0)) { + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gDoorCol); + } + SkelAnime_Init(globalCtx, &this->skelAnime, &gDoorSkel, &gameplay_keep_Anim_020658, this->limbTable, + this->limbTable, 5); + if (this->unk_1A4 == 5) { + objectInfo = &sObjInfo[17 + this->switchFlag]; + } else { + for (i = 0; i < ARRAY_COUNT(sObjInfo) - 34; i++, objectInfo++) { + if (globalCtx->sceneNum == objectInfo->sceneNum) { + break; + } + } + if ((i >= ARRAY_COUNT(sObjInfo) - 34) && (Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_FIELD_KEEP) >= 0)) { + objectInfo++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_8086704C.s") + this->dlIndex = objectInfo->dListIndex; + objectBankIndex = Object_GetIndex(&globalCtx->objectCtx, objectInfo->objectId); + if (objectBankIndex < 0) { + objectInfo = &sObjInfo[15]; + objectBankIndex = Object_GetIndex(&globalCtx->objectCtx, objectInfo->objectId); + if (objectBankIndex != 0) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + } + this->requiredObjBankIndex = objectBankIndex; + this->dlIndex = objectInfo->dListIndex; // Set twice? + if (this->dyna.actor.objBankIndex == this->requiredObjBankIndex) { + func_80866A5C(this, globalCtx); + } else { + this->actionFunc = func_80866A5C; + } + Actor_SetFocus(&this->dyna.actor, 35.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_80867080.s") +void EnDoor_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDoor* this = (EnDoor*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_808670F0.s") + if (this->unk_1A4 != 7) { + TransitionActorEntry* transitionEntry = + &globalCtx->doorCtx.transitionActorList[(u16)this->dyna.actor.params >> 0xA]; + if (transitionEntry->id < 0) { + transitionEntry->id = -transitionEntry->id; + } + } else if (this->switchFlag == 0) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_80867144.s") +void func_80866A5C(EnDoor* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->requiredObjBankIndex)) { + this->dyna.actor.objBankIndex = this->requiredObjBankIndex; + this->actionFunc = func_80866B20; + this->dyna.actor.world.rot.y = 0; + if (this->unk_1A4 == 1) { + if (!Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->unk_1A6 = 10; + } + } else if ((this->unk_1A4 == 4) && + (Actor_XZDistanceBetweenActors(&this->dyna.actor, &GET_PLAYER(globalCtx)->actor) > 120.0f)) { + this->actionFunc = func_8086704C; + this->dyna.actor.world.rot.y = -0x1800; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/EnDoor_Update.s") +void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { + static s32 D_80867BC0[4]; + Player* player = GET_PLAYER(globalCtx); + Vec3f playerPosRelToDoor; + s16 temp_a2; + s16 yawDiff; + s32 temp_a1_2; + s32 temp_t0; + u8 temp_a1; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_80867350.s") + if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state) && (this->dyna.actor.textId == 0x1821)) { + D_80867BC0[0] = 1; + } + if (this->unk_1A1 != 0) { + this->actionFunc = func_80867144; + Animation_PlayOnceSetSpeed(&this->skelAnime, sAnimations[this->animIndex], + (player->stateFlags1 & 0x8000000) ? 0.75f : 1.5f); + if (this->unk_1A6 != 0) { + gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex]--; + Flags_SetSwitch(globalCtx, this->switchFlag); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CHAIN_KEY_UNLOCK); + } + } else if (this->unk_1A7 != 0) { + this->actionFunc = func_80866F94; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DOOR_OPEN); + } else if (!Player_InCsMode(&globalCtx->state)) { + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &playerPosRelToDoor, &player->actor.world.pos); + if ((D_80867BC0[0] != 0) || ((fabsf(playerPosRelToDoor.y) < 20.0f) && (fabsf(playerPosRelToDoor.x) < 20.0f) && + (fabsf(playerPosRelToDoor.z) < 50.0f))) { + yawDiff = player->actor.shape.rot.y - this->dyna.actor.shape.rot.y; + if (playerPosRelToDoor.z > 0.0f) { + yawDiff = (0x8000 - yawDiff); + } + if (ABS_ALT(yawDiff) < 0x3000) { + player->doorType = 1; + player->doorDirection = playerPosRelToDoor.z >= 0.0f ? 1.0f : -1.0f; + player->doorActor = &this->dyna.actor; + if (this->unk_1A6 != 0) { + if (gSaveContext.inventory.dungeonKeys[((void)0, gSaveContext.mapIndex)] <= 0) { + player->doorType = -1; + this->dyna.actor.textId = 0x1802; + } else { + player->doorTimer = 10; + } + } else if (this->unk_1A4 == 4) { + player->doorType = -1; + this->dyna.actor.textId = 0x1800; + } else if ((this->unk_1A4 == 0) || (this->unk_1A4 == 2) || (this->unk_1A4 == 3)) { + s32 textIdOffset; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/EnDoor_Draw.s") + temp_t0 = (globalCtx->actorCtx.unkC & 0x2AA) >> 1; + temp_a2 = D_801AED48[this->switchFlag & 7]; + temp_a1_2 = globalCtx->actorCtx.unkC & 0x155; + textIdOffset = (this->switchFlag >> 3) & 0xF; + if (((this->unk_1A4 == 0) && (((temp_t0 | temp_a1_2) & temp_a2) == 0)) || + ((this->unk_1A4 == 2) && ((temp_a2 & temp_a1_2) == 0)) || + ((this->unk_1A4 == 3) && ((temp_a2 & temp_t0) == 0))) { + s16 baseTextId = 0x182D; + + if (this->unk_1A4 == 3) { + baseTextId = 0x180D; + } else if (this->unk_1A4 == 2) { + baseTextId = 0x181D; + } + player->doorType = -1; + this->dyna.actor.textId = baseTextId + textIdOffset; + } + } else if ((this->unk_1A4 == 5) && (playerPosRelToDoor.z > 0.0f)) { + struct_80133038_arg2 sp30; + + if (func_80133038(globalCtx, D_8086778C[this->switchFlag], &sp30) != 0) { + this->dyna.actor.textId = sp30.unk0 + 0x1800; + + player->doorType = ((this->dyna.actor.textId == 0x1821) && (D_80867BC0[0] != 0)) ? 5 : -1; + } + } + func_80122F28(player); + } + } else if ((this->unk_1A4 == 4) && (this->dyna.actor.xzDistToPlayer > 240.0f)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DOOR_OPEN); + this->actionFunc = func_80867080; + } + } +} + +void func_80866F94(EnDoor* this, GlobalContext* globalCtx) { + s32 direction; + + if (this->unk_1A7 != 0) { + if (this->unk_1A7 >= 0) { + direction = 1; + } else { + direction = -1; + } + if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, direction * 0x3E80, 0x7D0)) { + Math_StepToC(&this->unk_1A7, 0, 1); + } + } else { + if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, 0, 0x7D0)) { + this->actionFunc = func_80866B20; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_AUTO_DOOR_CLOSE); + } + } +} + +void func_8086704C(EnDoor* this, GlobalContext* globalCtx) { + if (this->dyna.actor.xzDistToPlayer < 120.0f) { + this->actionFunc = func_808670F0; + } +} + +void func_80867080(EnDoor* this, GlobalContext* globalCtx) { + if (this->dyna.actor.xzDistToPlayer < 120.0f) { + this->actionFunc = func_808670F0; + } else if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, -0x1800, 0x100)) { + this->actionFunc = func_8086704C; + } +} + +void func_808670F0(EnDoor* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, 0, 0x700)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DOOR_CLOSE); + this->actionFunc = func_80866B20; + } +} + +void func_80867144(EnDoor* this, GlobalContext* globalCtx) { + s32 numEffects; + s32 i; + + if (DECR(this->unk_1A6) == 0) { + if (SkelAnime_Update(&this->skelAnime) != 0) { + this->actionFunc = func_80866B20; + this->unk_1A1 = 0; + } else if (Animation_OnFrame(&this->skelAnime, sAnimOpenFrames[this->animIndex])) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_OC_DOOR_OPEN); + if (this->skelAnime.playSpeed < 1.5f) { + numEffects = (s32)(Rand_ZeroOne() * 30.0f) + 50; + for (i = 0; i < numEffects; i++) { + EffectSsBubble_Spawn(globalCtx, &this->dyna.actor.world.pos, 60.0, 100.0f, 50.0f, 0.15f); + } + } + } else if (Animation_OnFrame(&this->skelAnime, sAnimCloseFrames[this->animIndex])) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DOOR_CLOSE); + } + } +} + +void EnDoor_Update(Actor* thisx, GlobalContext* globalCtx) { + EnDoor* this = THIS; + + this->actionFunc(this, globalCtx); +} + +s32 EnDoor_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + TransitionActorEntry* transitionEntry; + EnDoor* this = THIS; + + if (limbIndex == 4) { + Gfx** dl = D_808679A4[this->dlIndex]; + s16 temp; + s32 dlIndex; + + transitionEntry = NULL; + + if (this->unk_1A4 != 7) { + transitionEntry = &globalCtx->doorCtx.transitionActorList[(u16)this->dyna.actor.params >> 0xA]; + } + rot->z += this->dyna.actor.world.rot.y; + if ((this->unk_1A4 == 7) || (globalCtx->roomCtx.prevRoom.num >= 0) || + (transitionEntry->sides[0].room == transitionEntry->sides[1].room)) { + s32 pad; + + temp = (this->dyna.actor.shape.rot.y + this->skelAnime.jointTable[3].z + rot->z) - + Math_Vec3f_Yaw(&globalCtx->view.eye, &this->dyna.actor.world.pos); + *dList = (ABS_ALT(temp) < 0x4000) ? dl[0] : dl[1]; + + } else { + dlIndex = 0; + if (transitionEntry->sides[0].room != this->dyna.actor.room) { + dlIndex = 1; + } + *dList = dl[dlIndex]; + } + } + return 0; +} + +void EnDoor_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDoor* this = THIS; + + if (this->dyna.actor.objBankIndex == this->requiredObjBankIndex) { + OPEN_DISPS(globalCtx->state.gfxCtx); + if ((this->unk_1A4 == 7) && (this->switchFlag == 0)) { + Gfx_DrawDListOpa(globalCtx, gameplay_keep_DL_0221B8); + } else { + func_8012C28C(globalCtx->state.gfxCtx); + } + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDoor_OverrideLimbDraw, + NULL, &this->dyna.actor); + if (this->dyna.actor.world.rot.y != 0) { + if (this->dyna.actor.world.rot.y > 0) { + gSPDisplayList(POLY_OPA_DISP++, gDoorRightDL); + } else { + gSPDisplayList(POLY_OPA_DISP++, gDoorLeftDL); + } + } + if (this->unk_1A6) { + Actor_DrawDoorLock(globalCtx, this->unk_1A6, 0); + } + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.h b/src/overlays/actors/ovl_En_Door/z_en_door.h index 6ed5aac15..bc94e150e 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.h +++ b/src/overlays/actors/ovl_En_Door/z_en_door.h @@ -7,19 +7,24 @@ struct EnDoor; typedef void (*EnDoorActionFunc)(struct EnDoor*, GlobalContext*); +#define ENDOOR_GET_PARAMS_7(thisx) (((thisx)->params >> 7) & 7) +#define ENDOOR_GET_PARAMS_7F(thisx) (((thisx)->params) & 0x7F) + + typedef struct EnDoor { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x5C]; - /* 0x1A0 */ s8 unk_1A0; - /* 0x1A1 */ s8 unk_1A1; - /* 0x1A2 */ char unk_1A2[0x2]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ u8 animIndex; + /* 0x1A1 */ u8 unk_1A1; + /* 0x1A2 */ s8 requiredObjBankIndex; + /* 0x1A3 */ s8 dlIndex; /* 0x1A4 */ u8 unk_1A4; - /* 0x1A5 */ u8 unk_1A5; - /* 0x1A6 */ s8 unk_1A6; + /* 0x1A5 */ u8 switchFlag; + /* 0x1A6 */ u8 unk_1A6; /* 0x1A7 */ s8 unk_1A7; - /* 0x1A8 */ char unk_1A8[0x20]; + /* 0x1A8 */ Vec3s limbTable[5]; /* 0x1C8 */ EnDoorActionFunc actionFunc; -} EnDoor; // size = 0x1CC +} EnDoor; extern const ActorInit En_Door_InitVars; 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 9be7b1a00..cdfda5ba9 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -922,7 +922,7 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { u16 sp56 = gSaveContext.time - 0x3FFC; u8 sp55 = ENGM_GET_FF(&this->actor); - EnDoor* sp50; + EnDoor* door; Vec3s* sp4C; Vec3f sp40; Vec3f sp34; @@ -930,13 +930,13 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; this->unk_234 = NULL; - sp50 = func_8094DF90(globalCtx, arg2->unk0); + door = func_8094DF90(globalCtx, arg2->unk0); if (D_80951A0C[arg2->unk0] >= 0) { this->unk_234 = func_8013BB34(globalCtx, sp55, D_80951A0C[arg2->unk0]); } - if ((sp50 != NULL) && (sp50->actor.update != NULL)) { + if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (this->unk_234 != NULL) { sp4C = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); @@ -946,7 +946,7 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); - if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, sp50->actor.shape.rot.y)) <= 0x4000) { + if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, door->dyna.actor.shape.rot.y)) <= 0x4000) { this->unk_261 = -75; } else { this->unk_261 = 75; @@ -1357,18 +1357,18 @@ s32 func_80950690(EnGm* this, GlobalContext* globalCtx) { } s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { - EnDoor* sp44; + EnDoor* door; Vec3f sp38; s32 pad; f32 temp_f0; - sp44 = func_8094DF90(globalCtx, this->unk_258); + door = func_8094DF90(globalCtx, this->unk_258); if (!func_8013AD6C(globalCtx) && (this->unk_3C4 != 0)) { - if ((sp44 != NULL) && (sp44->actor.update != NULL)) { + if ((door != NULL) && (door->dyna.actor.update != NULL)) { if ((this->unk_3BA / (f32)this->unk_3B8) <= 0.9f) { - sp44->unk_1A7 = this->unk_261; + door->unk_1A7 = this->unk_261; } else { - sp44->unk_1A7 = 0; + door->unk_1A7 = 0; } } 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 15ef372bd..c43f065dc 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -511,7 +511,7 @@ s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { u16 sp56 = gSaveContext.time - 0x3FFC; u8 sp55 = ENIG_GET_FF(&this->actor); - EnDoor* sp50; + EnDoor* door; Vec3s* sp4C; Vec3f sp40; Vec3f sp34; @@ -519,13 +519,13 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; this->unk_274 = NULL; - sp50 = func_80BF1200(globalCtx, arg2->unk0); + door = func_80BF1200(globalCtx, arg2->unk0); if (D_80BF3318[arg2->unk0] >= 0) { this->unk_274 = func_8013BB34(globalCtx, sp55, D_80BF3318[arg2->unk0]); } - if ((sp50 != NULL) && (sp50->actor.update != NULL)) { + if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (this->unk_274 != NULL) { sp4C = Lib_SegmentedToVirtual(this->unk_274->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); @@ -535,7 +535,7 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); - if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, sp50->actor.shape.rot.y)) <= 0x4000) { + if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, door->dyna.actor.shape.rot.y)) <= 0x4000) { this->unk_2A4 = -75; } else { this->unk_2A4 = 75; @@ -697,17 +697,17 @@ s32 func_80BF2400(EnIg* this, GlobalContext* globalCtx) { } s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { - EnDoor* sp44 = func_80BF1200(globalCtx, this->unk_298.unk0); + EnDoor* door = func_80BF1200(globalCtx, this->unk_298.unk0); Vec3f sp38; f32 temp; s32 pad; if (!func_8013AD6C(globalCtx) && (this->unk_3EC != 0)) { - if ((sp44 != NULL) && (sp44->actor.update != NULL)) { + if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_3E2 / this->unk_3E0) <= 0.9f) { - sp44->unk_1A7 = this->unk_2A4; + door->unk_1A7 = this->unk_2A4; } else { - sp44->unk_1A7 = 0; + door->unk_1A7 = 0; } } this->unk_3E2 = CLAMP(this->unk_3E2, 0, this->unk_3E0); diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index fe043938a..10648fa3f 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -935,7 +935,7 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { u16 sp56 = gSaveContext.time - 0x3FFC; u8 sp55 = this->actor.params & 0xFF; - EnDoor* sp50; + EnDoor* door; Vec3s* sp4C; Vec3f sp40; Vec3f sp34; @@ -943,12 +943,12 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; this->unk_234 = NULL; - sp50 = func_80AF7D60(globalCtx, arg2->unk0); + door = func_80AF7D60(globalCtx, arg2->unk0); if (D_80AFB430[arg2->unk0] >= 0) { this->unk_234 = func_8013BB34(globalCtx, sp55, D_80AFB430[arg2->unk0]); } - if ((sp50 != NULL) && (sp50->actor.update != NULL)) { + if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (this->unk_234 != 0) { sp4C = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); @@ -957,7 +957,7 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->unk_278, &sp34); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); - temp = this->actor.world.rot.y - sp50->actor.shape.rot.y; + temp = this->actor.world.rot.y - door->dyna.actor.shape.rot.y; if (ABS_ALT(temp) <= 0x4000) { this->unk_260 = -0x4B; } else { @@ -1402,17 +1402,17 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { - EnDoor* sp44 = func_80AF7D60(globalCtx, this->unk_258); + EnDoor* door = (EnDoor*)func_80AF7D60(globalCtx, this->unk_258); Vec3f sp38; Vec3f* sp28; f32 temp; if (!func_8013AD6C(globalCtx) && (this->unk_374 != 0)) { - if ((sp44 != NULL) && (sp44->actor.update != NULL)) { + if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_36E / this->unk_36C) <= 0.9f) { - sp44->unk_1A7 = this->unk_260; + door->unk_1A7 = this->unk_260; } else { - sp44->unk_1A7 = 0; + door->unk_1A7 = 0; } } this->unk_36E = CLAMP(this->unk_36E, 0, this->unk_36C); diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 1e7e8f0d1..f7b5a339e 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -383,7 +383,7 @@ void func_80AECE0C(EnTk* this, GlobalContext* globalCtx) { } s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { - EnDoor* sp4C4; + EnDoor* door; f32 spA0[265]; Vec3f sp94; Vec3f sp88; @@ -436,7 +436,7 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { this->unk_3D4 = sp7C; } - sp4C4 = NULL; + door = NULL; if (!(this->unk_2CA & 0xC00)) { door1 = NULL; label: @@ -447,7 +447,7 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { if (ABS(BINANG_SUB(Actor_YawToPoint(&this->actor, &door1->world.pos), this->actor.shape.rot.y)) <= 0x2000) { this->unk_2CA |= 0x400; - sp4C4 = (EnDoor*)door1; + door = (EnDoor*)door1; break; } } @@ -460,7 +460,7 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { door2 = SubS_FindActor(globalCtx, door2, ACTORCAT_DOOR, ACTOR_EN_DOOR); if (door2 != NULL) { if (Actor_XZDistanceBetweenActors(&this->actor, door2) <= 160.0f) { - sp4C4 = (EnDoor*)door2; + door = (EnDoor*)door2; break; } door2 = door2->next; @@ -468,19 +468,19 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { } while (door2 != NULL); } - if ((sp4C4 != NULL) && (this->unk_2CA & 0x400)) { + if ((door != NULL) && (this->unk_2CA & 0x400)) { Vec3f sp5C; - Actor_OffsetOfPointInActorCoords(&this->actor, &sp5C, &sp4C4->actor.world.pos); - sp4C4->unk_1A7 = 2; + Actor_OffsetOfPointInActorCoords(&this->actor, &sp5C, &door->dyna.actor.world.pos); + door->unk_1A7 = 2; if (sp5C.z < -20.0f) { this->unk_2CA &= ~0x400; this->unk_2CA |= 0x800; } } - if (sp4C4 != NULL) { - if ((this->unk_2CA & 0x800) && (sp4C4->unk_1A7 == 0)) { + if (door != NULL) { + if ((this->unk_2CA & 0x800) && (door->unk_1A7 == 0)) { this->unk_2CA &= ~0x800; } } diff --git a/tools/actorfixer.py b/tools/actorfixer.py index c54a72422..5eae310c4 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -247,6 +247,8 @@ animdict = { "BgCheck_CreateVertexFromVec3f": "BgCheck_Vec3fToVec3s", "BgCheck_PolygonGetMinY": "CollisionPoly_GetMinY", "BgCheck_PolygonGetNormal": "CollisionPoly_GetNormalF", + "BcCheck3_BgActorInit": "DynaPolyActor_Init", + "BgCheck3_LoadMesh": "DynaPolyActor_LoadMesh", "func_800C01B8": "CollisionPoly_GetPointDistanceFromPlane", "BgCheck_CreateTriNormFromPolygon": "CollisionPoly_GetVertices", "func_800C02C0": "CollisionPoly_GetVerticesByBgId", @@ -411,6 +413,7 @@ animdict = { "func_800A81F0": "EffectBlure_AddVertex", "func_800A8514": "EffectBlure_AddSpace", "Effect_GetParams": "Effect_GetByIndex", + "func_801343C0": "SkelAnime_DrawTransformFlexOpa", "func_80134148": "SkelAnime_DrawTransformFlexLimbOpa", "func_8013AB00": "SubS_DrawTransformFlex", @@ -446,6 +449,7 @@ animdict = { "skelAnime.prevFrameRot": "skelAnime.prevRot", "skelAnime.prevFramePos": "skelAnime.prevTransl", "skelAnime.unk3E": "skelAnime.baseTransl", + "actor.minVelocityY": "actor.terminalVelocity", "actor.yDistToWater": "actor.depthInWater", "actor.yDistToPlayer": "actor.playerHeightRel", @@ -464,12 +468,13 @@ animdict = { "globalCtx->msgCtx.unk1202C": "globalCtx->msgCtx.ocarinaAction", "globalCtx->msgCtx.unk11F22": "globalCtx->msgCtx.msgMode", - # Variables - "D_0407D590": "gGameplayKeepDrawFlameDL", - "D_801D15B0": "gZeroVec3f", - "D_801D15BC": "gZeroVec3s", - "D_801D1DE0": "gIdentityMtx", - "D_801D1E20": "gIdentityMtxF", + "D_801D15B0" : "gZeroVec3f", + "D_801D15BC" : "gZeroVec3s", + "D_801D1DE0" : "gIdentityMtx", + "D_801D1E20" : "gIdentityMtxF", + "D_04020658" : "gameplay_keep_Anim_020658", + "D_04022B28" : "gDoorSkel", + "D_04023100" : "gDoorCol", # Structs "ActorAnimationEntry": "AnimationInfo", @@ -513,20 +518,20 @@ def replace_anim_all(repo): for filename in files: if(filename.endswith('.s')): file = subdir + os.sep + filename - replace_anim(file) + replace_anim(file) for subdir, dirs, files in os.walk(repo + os.sep + 'data'): for filename in files: if(filename.endswith('.s')): file = subdir + os.sep + filename replace_anim(file) - + for subdir, dirs, files in os.walk(repo + os.sep + 'docs'): for filename in files: if(filename.endswith('.md')): file = subdir + os.sep + filename replace_anim(file) - + for subdir, dirs, files in os.walk(repo + os.sep + 'tools' + os.sep + 'sizes'): for filename in files: if(filename.endswith('.csv')): diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 1f4d019f0..e1bf5f807 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -4960,7 +4960,7 @@ 0x808670F0:("func_808670F0",), 0x80867144:("func_80867144",), 0x8086732C:("EnDoor_Update",), - 0x80867350:("func_80867350",), + 0x80867350:("EnDoor_OverrideLimbDraw",), 0x808674B0:("EnDoor_Draw",), 0x80867BD0:("func_80867BD0",), 0x80867BDC:("func_80867BDC",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index d0678cc71..3af06baa5 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -5618,13 +5618,11 @@ 0x80867784:("D_80867784","UNK_TYPE1","",0x1), 0x8086778C:("D_8086778C","UNK_PTR","",0x4), 0x8086780C:("En_Door_InitVars","UNK_TYPE1","",0x1), - 0x8086782C:("D_8086782C","UNK_TYPE2","",0x2), - 0x80867886:("D_80867886","UNK_TYPE1","",0x1), - 0x8086788A:("D_8086788A","UNK_TYPE2","",0x2), - 0x80867954:("D_80867954","UNK_TYPE1","",0x1), - 0x80867964:("D_80867964","UNK_TYPE1","",0x1), - 0x8086798C:("D_8086798C","UNK_TYPE1","",0x1), - 0x80867998:("D_80867998","UNK_TYPE1","",0x1), + 0x8086782C:("sObjInfo","UNK_TYPE2","",0x126), + 0x80867954:("sInitChain","UNK_TYPE1","",0x1), + 0x80867964:("sAnimations","AnimationHeader","[10]",0x28), + 0x8086798C:("sAnimOpenFrames","u8","[10]",0x10), + 0x80867998:("sAnimCloseFrames","u8","[10]",0x10), 0x808679A4:("D_808679A4","UNK_TYPE1","",0x1), 0x80867A20:("D_80867A20","f32","",0x4), 0x80867BC0:("D_80867BC0","UNK_TYPE1","",0x1), diff --git a/undefined_syms.txt b/undefined_syms.txt index c3647b915..d30baf787 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -396,8 +396,6 @@ D_04020658 = 0x04020658; D_04020BB8 = 0x04020BB8; D_04020D00 = 0x04020D00; D_040221B8 = 0x040221B8; -D_04022B28 = 0x04022B28; -D_04023100 = 0x04023100; D_04023130 = 0x04023130; D_04023210 = 0x04023210; D_04023288 = 0x04023288; From 484263dedc2e30afe9e536d01c7c8424f734dbc9 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Mon, 28 Feb 2022 02:11:06 +0000 Subject: [PATCH 049/257] Obj_Bombiwa (#637) * Obj_Bombiwa * PR --- spec | 3 +- .../actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c | 505 ++++++++++++++++-- .../actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h | 21 +- undefined_syms.txt | 8 - 4 files changed, 489 insertions(+), 48 deletions(-) diff --git a/spec b/spec index ec0af718e..18c9e5a6b 100644 --- a/spec +++ b/spec @@ -1498,8 +1498,7 @@ beginseg name "ovl_Obj_Bombiwa" compress include "build/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.o" - include "build/data/ovl_Obj_Bombiwa/ovl_Obj_Bombiwa.data.o" - include "build/data/ovl_Obj_Bombiwa/ovl_Obj_Bombiwa.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Bombiwa/ovl_Obj_Bombiwa_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c index 0b91f6f5f..8a09c6f01 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c @@ -5,6 +5,7 @@ */ #include "z_obj_bombiwa.h" +#include "objects/object_bombiwa/object_bombiwa.h" #define FLAGS 0x00000000 @@ -14,10 +15,15 @@ void ObjBombiwa_Init(Actor* thisx, GlobalContext* globalCtx); void ObjBombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjBombiwa_Update(Actor* thisx, GlobalContext* globalCtx); +s32 func_809393B0(Actor* thisx); +s32 func_80939470(Actor* thisx); +void func_80939EE0(ObjBombiwa* this); void func_80939EF4(ObjBombiwa* this, GlobalContext* globalCtx); +void func_8093A080(ObjBombiwa* this); void func_8093A1F0(ObjBombiwa* this, GlobalContext* globalCtx); +void func_8093A418(Actor* thisx, GlobalContext* globalCtx); +void func_8093A608(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Bombiwa_InitVars = { ACTOR_OBJ_BOMBIWA, ACTORCAT_PROP, @@ -30,70 +36,495 @@ const ActorInit Obj_Bombiwa_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8093A940 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x81C37FBE, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x81C37FBE, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 55, 70, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8093A96C = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x81C37BBE, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x81C37BBE, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 75, 130, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_8093A9B8 = { 0, 12, 60, MASS_IMMOVABLE }; +typedef struct { + /* 0x00 */ ColliderCylinderInit* collider; + /* 0x04 */ ActorShadowFunc unk_04; + /* 0x08 */ ActorFunc unk_08; + /* 0x0C */ s32 (*unk_0C)(Actor*); +} ObjBombiwaStruct2; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8093A9C0[] = { +static ObjBombiwaStruct2 D_8093A998[] = { + { &sCylinderInit1, ActorShadow_DrawCircle, func_8093A418, func_809393B0 }, + { &sCylinderInit2, NULL, func_8093A608, func_80939470 }, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_IMMOVABLE }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_STOP), }; -#endif +static s16 D_8093A9D0[] = { + 17, 14, 10, 8, 7, 5, 3, 2, +}; -extern ColliderCylinderInit D_8093A940; -extern ColliderCylinderInit D_8093A96C; -extern CollisionCheckInfoInit D_8093A9B8; -extern InitChainEntry D_8093A9C0[]; +static s16 D_8093A9E0[] = { + 16, 12, 8, 6, 5, 4, 3, 2, +}; -extern UNK_TYPE D_060009E0; -extern UNK_TYPE D_06004560; -extern UNK_TYPE D_06005990; +s32 func_809393B0(Actor* thisx) { + ObjBombiwa* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_809393B0.s") + if (this->collider.base.acFlags & AC_HIT) { + Actor* ac = this->collider.base.ac; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939470.s") + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000000) { + if ((ac != NULL) && (Math3D_Vec3fDistSq(&this->actor.world.pos, &ac->world.pos) < SQ(150.0f))) { + return true; + } + } else if (this->collider.info.acHitInfo->toucher.dmgFlags & 8) { + if ((ac != NULL) && (Math3D_Vec3fDistSq(&this->actor.world.pos, &ac->world.pos) < SQ(95.0f))) { + return true; + } + } else if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x500) { + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_8093951C.s") +s32 func_80939470(Actor* thisx) { + ObjBombiwa* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939594.s") + if (this->collider.base.acFlags & AC_HIT) { + Actor* temp_v0 = this->collider.base.ac; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/ObjBombiwa_Init.s") + if (temp_v0 != NULL) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000000) { + if (Math3D_Vec3fDistSq(&this->actor.world.pos, &temp_v0->world.pos) < SQ(175.0f)) { + return true; + } + } else if ((this->collider.info.acHitInfo->toucher.dmgFlags & 8) && + (Math3D_Vec3fDistSq(&this->actor.world.pos, &temp_v0->world.pos) < SQ(115.0f))) { + return true; + } + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/ObjBombiwa_Destroy.s") +s32 func_8093951C(ObjBombiwa* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* sp30; + f32 sp2C; + s32 sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939794.s") + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp2C, + &sp30, &sp28) && + (this->actor.world.pos.y < sp2C)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939994.s") +void func_80939594(ObjBombiwa* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp28; + s32 sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939C50.s") + sp28.x = this->actor.world.pos.x; + sp28.y = this->actor.world.pos.y + 30.0f; + sp28.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939EE0.s") + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp24, &this->actor, &sp28); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939EF4.s") +void ObjBombiwa_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjBombiwa* this = THIS; + s32 sp34 = OBJBOMBIWA_GET_100(&this->actor); + s32 pad2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_8093A080.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_8093A1F0.s") + if (Flags_GetSwitch(globalCtx, OBJBOMBIWA_GET_7F(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/ObjBombiwa_Update.s") + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, D_8093A998[sp34].collider); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_8093A418.s") + if (sp34 == OBJBOMBIWA_100_0) { + if (this->actor.shape.rot.y == 0) { + this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + } + func_80939594(this, globalCtx); + } + ActorShape_Init(&this->actor.shape, -200.0f, D_8093A998[sp34].unk_04, 9.8f); + this->actor.world.pos.y = this->actor.home.pos.y + 20.0f; + this->actor.draw = D_8093A998[sp34].unk_08; + if (func_8093951C(this, globalCtx)) { + this->unk_203 |= 1; + } + func_80939EE0(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_8093A608.s") +void ObjBombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyCylinder(globalCtx, &THIS->collider); +} + +void func_80939794(ObjBombiwa* this, GlobalContext* globalCtx) { + Vec3f spB4; + Vec3f spA8; + s32 phi_v1; + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_8093A9D0); i++) { + spB4.x = ((Rand_ZeroOne() - 0.5f) * 10.0f) + this->actor.home.pos.x; + spB4.y = (Rand_ZeroOne() * 5.0f) + this->actor.home.pos.y + 8.0f; + spB4.z = ((Rand_ZeroOne() - 0.5f) * 10.0f) + this->actor.home.pos.z; + + spA8.x = (Rand_ZeroOne() - 0.5f) * 15.0f; + spA8.y = (Rand_ZeroOne() * 16.0f) + 5.0f; + spA8.z = (Rand_ZeroOne() - 0.5f) * 15.0f; + + if (D_8093A9D0[i] > 10) { + phi_v1 = 0x25; + } else { + phi_v1 = 0x21; + } + EffectSsKakera_Spawn(globalCtx, &spB4, &spA8, &spB4, -400, phi_v1, 10, 2, 0, D_8093A9D0[i], 1, 0, 60, -1, + OBJECT_BOMBIWA, object_bombiwa_DL_0009E0); + } + + func_800BBFB0(globalCtx, &this->actor.world.pos, 60.0f, 8, 80, 140, 1); +} + +void func_80939994(GlobalContext* globalCtx, Vec3f* arg1) { + Vec3f spAC; + Vec3f spA0; + s16 phi_v0; + s16 life; + s32 i; + + for (i = 0; i < 16; i++) { + spAC.x = (Rand_ZeroOne() - 0.5f) * 80.0f; + spAC.y = Rand_ZeroOne() * 120.0f; + spAC.z = (Rand_ZeroOne() - 0.5f) * 80.0f; + + spA0.x = ((Rand_ZeroOne() - 0.5f) * 3.0f) + (spAC.x * 0.2f); + spA0.y = (Rand_ZeroOne() * 16.0f) + 5.0f; + spA0.z = ((Rand_ZeroOne() - 0.5f) * 3.0f) + (spAC.z * 0.2f); + + spAC.x += arg1->x; + spAC.y += arg1->y; + spAC.z += arg1->z; + + if (i >= 14) { + phi_v0 = 33; + life = 60; + } else if (i >= 12) { + phi_v0 = 65; + life = 60; + } else { + life = 40; + if (Rand_ZeroOne() < 0.7f) { + phi_v0 = 64; + } else { + phi_v0 = 32; + } + } + EffectSsKakera_Spawn(globalCtx, &spAC, &spA0, &spAC, -450, phi_v0, 15, 0, 0, i, 1, 0, life, -1, OBJECT_BOMBIWA, + object_bombiwa_DL_005990); + } + + func_800BBFB0(globalCtx, arg1, 120.0f, 3, 80, 140, 1); + + spAC.x = arg1->x; + spAC.y = arg1->y + 70.0f; + spAC.z = arg1->z; + + func_800BBFB0(globalCtx, &spAC, 120.0f, 3, 80, 140, 1); +} + +void func_80939C50(GlobalContext* globalCtx, Vec3f* arg1) { + Vec3f spBC; + Vec3f spB0; + s32 phi_v0; + s32 phi_s0; + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_8093A9E0); i++) { + spBC.x = (Rand_ZeroOne() - 0.5f) * 15.0f; + spBC.y = (Rand_ZeroOne() - 0.2f) * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 15.0f; + + spB0.x = ((Rand_ZeroOne() - 0.5f) * 3.0f) + (spBC.x * 0.85f); + spB0.y = (Rand_ZeroOne() * 15.0f) + 8.0f; + spB0.z = ((Rand_ZeroOne() - 0.5f) * 3.0f) + (spBC.z * 0.85f); + + spBC.x += arg1->x; + spBC.y += arg1->y; + spBC.z += arg1->z; + + if (i == 0) { + phi_v0 = 33; + phi_s0 = 60; + } else if (i == 1) { + phi_v0 = 65; + phi_s0 = 60; + } else { + phi_s0 = 40; + if (Rand_ZeroOne() < 0.7f) { + phi_v0 = 64; + } else { + phi_v0 = 32; + } + } + EffectSsKakera_Spawn(globalCtx, &spBC, &spB0, &spBC, -450, phi_v0, 15, 0, 0, D_8093A9E0[i], 1, 0, phi_s0, -1, + OBJECT_BOMBIWA, object_bombiwa_DL_005990); + } + + func_800BBFB0(globalCtx, arg1, 60.0f, 4, 80, 140, 1); +} + +void func_80939EE0(ObjBombiwa* this) { + this->actionFunc = func_80939EF4; +} + +void func_80939EF4(ObjBombiwa* this, GlobalContext* globalCtx) { + s32 pad; + s32 params = OBJBOMBIWA_GET_100(&this->actor); + ObjBombiwaStruct2* sp28 = &D_8093A998[params]; + + if (this->collider.base.acFlags & AC_HIT) { + this->unk_202 = 5; + } + + if (sp28->unk_0C(&this->actor)) { + Flags_SetSwitch(globalCtx, OBJBOMBIWA_GET_7F(&this->actor)); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 80, NA_SE_EV_WALL_BROKEN); + if (OBJBOMBIWA_GET_8000(&this->actor)) { + play_sound(NA_SE_SY_CORRECT_CHIME); + } + + if (params == OBJBOMBIWA_100_0) { + func_80939794(this, globalCtx); + Actor_MarkForDeath(&this->actor); + } else { + func_80939994(globalCtx, &this->actor.world.pos); + this->actor.flags |= ACTOR_FLAG_10; + func_8093A080(this); + } + } else { + this->collider.base.acFlags &= ~AC_HIT; + + if (this->actor.xzDistToPlayer < 1400.0f) { + if (this->unk_202 > 0) { + this->unk_202--; + if (this->unk_202 == 0) { + this->collider.base.colType = COLTYPE_HARD; + } else { + this->collider.base.colType = COLTYPE_NONE; + } + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void func_8093A080(ObjBombiwa* this) { + ObjBombiwaStruct* ptr; + s16 phi_s2; + s32 i; + + for (i = 0, phi_s2 = 0; i < ARRAY_COUNT(this->unk_190); i++, phi_s2 += 0x4000) { + ptr = &this->unk_190[i]; + + ptr->unk_00 = (Rand_ZeroOne() * 0.1f) + 0.05f; + + ptr->unk_04.x = (Math_SinS(phi_s2) * 50.0f) + this->actor.world.pos.x; + ptr->unk_04.y = ((i + 1) * 31.0f) + this->actor.world.pos.y; + ptr->unk_04.z = (Math_CosS(phi_s2) * 50.0f) + this->actor.world.pos.z; + + ptr->unk_10 = i + 3.0f; + ptr->unk_14.x = phi_s2; + ptr->unk_14.y = (u32)Rand_Next() >> 0x10; + ptr->unk_14.z = 0; + ptr->unk_1A = 0; + } + + this->unk_200 = 0; + this->unk_201 = 80; + this->actionFunc = func_8093A1F0; +} + +void func_8093A1F0(ObjBombiwa* this, GlobalContext* globalCtx) { + s32 pad; + s32 i; + Vec3f sp9C; + ObjBombiwaStruct* ptr; + CollisionPoly* sp94; + s32 sp90; + f32 temp_f0; + s16 phi_s1; + + for (i = 0, phi_s1 = 0; i < ARRAY_COUNT(this->unk_190); i++, phi_s1 += 0x4000) { + ptr = &this->unk_190[i]; + + if (ptr->unk_1A != 0) { + continue; + } + + ptr->unk_10 -= 3.0f; + + ptr->unk_04.x += Math_SinS(phi_s1) * 1.5f; + ptr->unk_04.y += ptr->unk_10; + ptr->unk_04.z += Math_CosS(phi_s1) * 1.5f; + + ptr->unk_14.x += 0x5DC; + + sp9C.x = ptr->unk_04.x; + sp9C.y = ptr->unk_04.y + 30.0f; + sp9C.z = ptr->unk_04.z; + + temp_f0 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp94, &sp90, &this->actor, &sp9C); + if ((temp_f0 <= (BGCHECK_Y_MIN + 10.0f)) || ((ptr->unk_04.y - (200.0f * ptr->unk_00)) < temp_f0)) { + this->unk_200++; + ptr->unk_1A = 1; + func_80939C50(globalCtx, &ptr->unk_04); + } + } + + this->unk_201--; + if ((this->unk_200 >= 4) || (this->unk_201 <= 0)) { + Actor_MarkForDeath(&this->actor); + } +} + +void ObjBombiwa_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjBombiwa* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void func_8093A418(Actor* thisx, GlobalContext* globalCtx) { + ObjBombiwa* this = THIS; + f32 sp28; + + if ((this->actor.projectedPos.z <= 2200.0f) || ((this->unk_203 & 1) && (this->actor.projectedPos.z < 2300.0f))) { + this->actor.shape.shadowAlpha = 160; + Gfx_DrawDListOpa(globalCtx, object_bombiwa_DL_0009E0); + return; + } + + if (this->actor.projectedPos.z < 2300.0f) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + sp28 = (2300.0f - this->actor.projectedPos.z) * 2.55f; + + this->actor.shape.shadowAlpha = sp28 * (32.0f / 51); + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s32)sp28); + gSPDisplayList(POLY_XLU_DISP++, object_bombiwa_DL_000AF0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + this->actor.shape.shadowAlpha = 0; + } +} + +void func_8093A608(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[8]; + ObjBombiwa* this = THIS; + f32 sp38; + s32 i; + ObjBombiwaStruct* ptr; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->actionFunc == func_80939EF4) { + if ((this->actor.projectedPos.z <= 2200.0f) || + ((this->unk_203 & 1) && (this->actor.projectedPos.z < 2300.0f))) { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x9B, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, object_bombiwa_DL_004560); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_bombiwa_DL_004688); + } else if (this->actor.projectedPos.z < 2300.0f) { + sp38 = (2300.0f - this->actor.projectedPos.z) * 2.55f; + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x9B, 255, 255, 255, (s32)sp38); + gSPDisplayList(POLY_XLU_DISP++, object_bombiwa_DL_004560); + } + } else { + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_190); i++) { + ptr = &this->unk_190[i]; + + if (ptr->unk_1A == 0) { + Matrix_SetStateRotationAndTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, &ptr->unk_14); + Matrix_Scale(ptr->unk_00, ptr->unk_00, ptr->unk_00, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_bombiwa_DL_005990); + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h index 36fafc7e6..54d4024e9 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h @@ -7,9 +7,28 @@ struct ObjBombiwa; typedef void (*ObjBombiwaActionFunc)(struct ObjBombiwa*, GlobalContext*); +#define OBJBOMBIWA_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJBOMBIWA_GET_100(thisx) (((thisx)->params >> 8) & 1) +#define OBJBOMBIWA_GET_8000(thisx) (((thisx)->params >> 0xF) & 1) + +#define OBJBOMBIWA_100_0 0 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ Vec3f unk_04; + /* 0x10 */ f32 unk_10; + /* 0x14 */ Vec3s unk_14; + /* 0x1A */ s16 unk_1A; +} ObjBombiwaStruct; // size = 0x1C + typedef struct ObjBombiwa { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC0]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ ObjBombiwaStruct unk_190[4]; + /* 0x0200 */ s8 unk_200; + /* 0x0201 */ s8 unk_201; + /* 0x0202 */ s8 unk_202; + /* 0x0203 */ u8 unk_203; /* 0x0204 */ ObjBombiwaActionFunc actionFunc; } ObjBombiwa; // size = 0x208 diff --git a/undefined_syms.txt b/undefined_syms.txt index d30baf787..8182801cc 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2003,14 +2003,6 @@ D_060014F0 = 0x060014F0; D_06007630 = 0x06007630; D_06009A88 = 0x06009A88; -// ovl_Obj_Bombiwa - -D_060009E0 = 0x060009E0; -D_06000AF0 = 0x06000AF0; -D_06004560 = 0x06004560; -D_06004688 = 0x06004688; -D_06005990 = 0x06005990; - // ovl_Obj_Chan D_06000A10 = 0x06000A10; From bb6b580a6bb0cf328141f65616bedc6ac78c9362 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Mon, 28 Feb 2022 02:18:40 +0000 Subject: [PATCH 050/257] Mir_Ray (1 non-matching) (#634) * Mir_Ray * PR * fmt --- include/functions.h | 2 +- spec | 5 +- src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c | 692 +++++++++++++++++++- src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h | 34 +- tools/disasm/functions.txt | 14 +- undefined_syms.txt | 6 - 6 files changed, 705 insertions(+), 48 deletions(-) diff --git a/include/functions.h b/include/functions.h index f65278671..3223aa624 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2052,7 +2052,7 @@ s32 func_80124020(void); u8 Player_GetMask(GlobalContext* globalCtx); void Player_RemoveMask(GlobalContext* globalCtx); s32 func_8012405C(GlobalContext* globalCtx); -// void func_80124088(void); +s32 func_80124088(GlobalContext* globalCtx); s32 func_801240C8(Player* player); // void func_801240DC(void); // void func_80124110(void); diff --git a/spec b/spec index 18c9e5a6b..f6871e38b 100644 --- a/spec +++ b/spec @@ -1254,8 +1254,11 @@ beginseg name "ovl_Mir_Ray" compress include "build/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.o" - include "build/data/ovl_Mir_Ray/ovl_Mir_Ray.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Mir_Ray/ovl_Mir_Ray_reloc.o" +#else include "build/data/ovl_Mir_Ray/ovl_Mir_Ray.reloc.o" +#endif endseg beginseg diff --git a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c index f542b7086..18aafc07a 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c @@ -2,9 +2,11 @@ * File: z_mir_ray.c * Overlay: ovl_Mir_Ray * Description: Reflectible light ray (unused, somewhat broken) + * Note: This actor is unchanged from OoT, and will not work correctly */ #include "z_mir_ray.h" +#include "objects/object_mir_ray/object_mir_ray.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +17,30 @@ void MirRay_Destroy(Actor* thisx, GlobalContext* globalCtx); void MirRay_Update(Actor* thisx, GlobalContext* globalCtx); void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +s32 MirRay_CheckInFrustum(Vec3f* vecA, Vec3f* vecB, f32 pointx, f32 pointy, f32 pointz, s16 radiusA, s16 radiusB); + +typedef struct { + /* 0x00 */ Vec3f pos; + /* 0x0C */ MtxF mtx; + /* 0x4C */ CollisionPoly* reflectionPoly; + /* 0x50 */ u8 opacity; +} MirRayShieldReflection; // size = 0x54 + +typedef struct { + /* 0x00 */ Vec3s sourcePoint; + /* 0x06 */ Vec3s poolPoint; // point at center of light pool on floor for windows and BigMirror, same as source + // point for Cobra Mirror + /* 0x0C */ s16 sourceEndRadius; // Radius of beam frustum at the source end + /* 0x0E */ s16 poolEndRadius; // Radius of beam frustum at the pool end + /* 0x10 */ f32 unk_10; // placement of collider center along beam + /* 0x14 */ s16 unk_14; // collider radius before scaled + /* 0x16 */ s16 lgtPtMaxRad; // light point max radius + /* 0x18 */ f32 unk_18; // placement of light point between source and reflection point (pool point for windows, + // player for mirrors) + /* 0x1C */ Color_RGB8 color; + /* 0x1F */ u8 params; +} MirRayDataEntry; // size = 0x20 + const ActorInit Mir_Ray_InitVars = { ACTOR_MIR_RAY, ACTORCAT_ITEMACTION, @@ -28,64 +53,669 @@ const ActorInit Mir_Ray_InitVars = { (ActorFunc)MirRay_Draw, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_808E3BF4 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK0, { 0x00200000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, +u8 D_808E3BF0 = false; + +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x00200000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_808E3C44[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00200000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00200000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 0, { { 0, 0, 0 }, 50 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808E3C68 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_JNTSPH, }, - 1, D_808E3C44, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808E3DB8[] = { +// Note: this data is unchanged from OoT and hardcoded for Spirit Temple, so the actor will not work at all without +// modification. + +MirRayDataEntry sMirRayData[] = { + { + { -0x488, 0x2AE, -0x370 }, + { -0x398, 0x1E0, -0x379 }, + 30, + 50, + 1.0f, + 50, + 150, + 0.8f, + { 255, 255, 255 }, + 2, + }, + { + { -0x740, 0x444, -0xBE }, + { -0x6A7, 0x349, -0xBA }, + 30, + 70, + 0.88f, + 0x36, + 150, + 0.8f, + { 255, 255, 255 }, + 2, + }, + { + { 0x557, 0x2E2, -0x35C }, + { 0x443, 0x1DC, -0x35C }, + 30, + 0x55, + 0.0f, + 0, + 150, + 0.8f, + { 255, 255, 255 }, + 0, + }, + { + { 0x898, 0x44F, -0xDC }, + { 0x7F8, 0x34B, -0xDC }, + 30, + 60, + 0.0f, + 0, + 150, + 0.8f, + { 255, 255, 255 }, + 1, + }, + { + { -0x230, 0x879, -0x136 }, + { -0x230, 0x6CF, -0x136 }, + 30, + 70, + 0.0f, + 0, + 150, + 0.8f, + { 255, 255, 255 }, + 0, + }, + { + { 0x3C, 0x70A, -0x442 }, + { 0x3C, 0x3CD, -0x442 }, + 30, + 70, + 0.0f, + 0, + 150, + 0.9f, + { 255, 255, 255 }, + 13, + }, + { + { 0x474, 0x1E0, -0x35C }, + { 0x474, 0x1E0, -0x35C }, + 30, + 30, + 1.0f, + 10, + 100, + 0.9f, + { 255, 255, 255 }, + 14, + }, + { + { -0x230, 0x6CF, -0x136 }, + { + -0x230, + 0x6CF, + -0x136, + }, + 30, + 30, + 0.0f, + 0, + 100, + 0.94f, + { 255, 255, 255 }, + 12, + }, + { + { 0x3C, 0x6CF, -0x136 }, + { 0x3C, 0x6CF, -0x136 }, + 30, + 30, + 0.0f, + 0, + 100, + 0.94f, + { 255, 255, 255 }, + 12, + }, + { + { -0x496, 0x1C0, 0x4AA }, + { -0x496, 0x94, 0x4AA }, + 50, + 100, + 1.0f, + 50, + 150, + 0.8f, + { 255, 255, 255 }, + 3, + }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), }; +const char D_808E3DD0[] = "反射光 発生失敗"; + +void MirRay_SetupCollider(MirRay* this) { + MirRayDataEntry* dataEntry = &sMirRayData[MIRRAY_LOCATION(&this->actor)]; + f32 x = (this->poolPt.x - this->sourcePt.x) * dataEntry->unk_10; + f32 y = (this->poolPt.y - this->sourcePt.y) * dataEntry->unk_10; + f32 z = (this->poolPt.z - this->sourcePt.z) * dataEntry->unk_10; + + this->collider1.elements[0].dim.worldSphere.center.x = this->sourcePt.x + x; + this->collider1.elements[0].dim.worldSphere.center.y = this->sourcePt.y + y; + this->collider1.elements[0].dim.worldSphere.center.z = this->sourcePt.z + z; + + this->collider1.elements[0].dim.worldSphere.radius = dataEntry->unk_14 * this->collider1.elements->dim.scale; +} + +// Set up a light point between source point and reflection point. Reflection point is the pool point (for windows) or +// at the player position (for mirrors) +void MirRay_MakeShieldLight(MirRay* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + MirRayDataEntry* dataEntry = &sMirRayData[MIRRAY_LOCATION(&this->actor)]; + Vec3f reflectionPt; + Vec3s lightPt; + + if (MirRay_CheckInFrustum(&this->sourcePt, &this->poolPt, player->actor.world.pos.x, + player->actor.world.pos.y + 30.0f, player->actor.world.pos.z, this->sourceEndRad, + this->poolEndRad)) { + if (dataEntry->params & 8) { + Math_Vec3f_Diff(&player->actor.world.pos, &this->sourcePt, &reflectionPt); + } else { + Math_Vec3f_Diff(&this->poolPt, &this->sourcePt, &reflectionPt); + } + + lightPt.x = (dataEntry->unk_18 * reflectionPt.x) + this->sourcePt.x; + lightPt.y = (dataEntry->unk_18 * reflectionPt.y) + this->sourcePt.y; + lightPt.z = (dataEntry->unk_18 * reflectionPt.z) + this->sourcePt.z; + + // Fade up + Math_StepToS(&this->lightPointRad, dataEntry->lgtPtMaxRad, 6); + Lights_PointNoGlowSetInfo(&this->lightInfo, lightPt.x, lightPt.y, lightPt.z, dataEntry->color.r, + dataEntry->color.g, dataEntry->color.b, this->lightPointRad); + } else { + // Fade down + Math_StepToS(&this->lightPointRad, 0, 6); + Lights_PointSetColorAndRadius(&this->lightInfo, dataEntry->color.r, dataEntry->color.g, dataEntry->color.b, + this->lightPointRad); + } +} + +void MirRay_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + MirRay* this = THIS; + MirRayDataEntry* dataEntry = &sMirRayData[MIRRAY_LOCATION(&this->actor)]; + + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + + if (MIRRAY_LOCATION(&this->actor) >= MIRRAY_MAX) { + Actor_MarkForDeath(&this->actor); + } + + this->sourcePt.x = dataEntry->sourcePoint.x; + this->sourcePt.y = dataEntry->sourcePoint.y; + this->sourcePt.z = dataEntry->sourcePoint.z; + this->sourceEndRad = dataEntry->sourceEndRadius; + + this->poolPt.x = dataEntry->poolPoint.x; + this->poolPt.y = dataEntry->poolPoint.y; + this->poolPt.z = dataEntry->poolPoint.z; + this->poolEndRad = dataEntry->poolEndRadius; + + Lights_PointNoGlowSetInfo(&this->lightInfo, this->sourcePt.x, this->sourcePt.y, this->sourcePt.z, 255, 255, 255, + 100); + this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + + this->shieldCorners[0].x = -536.0f; + this->shieldCorners[0].y = -939.0f; + + this->shieldCorners[1].x = -1690.0f; + this->shieldCorners[1].y = 0.0f; + + this->shieldCorners[2].x = -536.0f; + this->shieldCorners[2].y = 938.0f; + + this->shieldCorners[3].x = 921.0f; + this->shieldCorners[3].y = 0.0f; + + this->shieldCorners[4].x = 758.0f; + this->shieldCorners[4].y = 800.0f; + + this->shieldCorners[5].x = 758.0f; + this->shieldCorners[5].y = -800.0f; + + if (dataEntry->params & 2) { + Collider_InitJntSph(globalCtx, &this->collider1); + Collider_SetJntSph(globalCtx, &this->collider1, &this->actor, &sJntSphInit, this->collider1Elements); + if (!(dataEntry->params & 4)) { // Beams not from mirrors + MirRay_SetupCollider(this); + } + } + + Collider_InitQuad(globalCtx, &this->collider2); + Collider_SetQuad(globalCtx, &this->collider2, &this->actor, &sQuadInit); + + if ((MIRRAY_LOCATION(&this->actor) == MIRRAY_SPIRIT_TOPROOM_CEILINGMIRROR) || + (MIRRAY_LOCATION(&this->actor) == MIRRAY_SPIRIT_TOPROOM_COBRA1) || + (MIRRAY_LOCATION(&this->actor) == MIRRAY_SPIRIT_TOPROOM_COBRA2)) { + this->actor.room = -1; + } +} + +void MirRay_Destroy(Actor* thisx, GlobalContext* globalCtx) { + MirRay* this = THIS; + + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + + if (sMirRayData[MIRRAY_LOCATION(&this->actor)].params & 2) { + Collider_DestroyJntSph(globalCtx, &this->collider1); + } + + Collider_DestroyQuad(globalCtx, &this->collider2); +} + +void MirRay_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + MirRay* this = THIS; + Player* player = GET_PLAYER(globalCtx); + + D_808E3BF0 = false; + + if (!this->unLit) { + if (sMirRayData[MIRRAY_LOCATION(&this->actor)].params & 2) { + if (sMirRayData[MIRRAY_LOCATION(&this->actor)].params & 4) { + MirRay_SetupCollider(this); + } + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + } + + if (this->reflectIntensity > 0.0f) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } + + MirRay_MakeShieldLight(this, globalCtx); + + if (this->reflectIntensity > 0.0f) { + func_800B8F98(&player->actor, NA_SE_IT_SHIELD_BEAM - SFX_FLAG); + } + } +} + +void MirRay_SetIntensity(MirRay* this, GlobalContext* globalCtx) { + f32 sp4C[3]; + s32 pad[4]; + Player* player = GET_PLAYER(globalCtx); + MtxF* shieldMtx = &player->shieldMf; + f32 temp_f0; + f32 temp_f0_2; + f32 temp_f2; + + this->reflectIntensity = 0.0f; + + if (MirRay_CheckInFrustum(&this->sourcePt, &this->poolPt, shieldMtx->wx, shieldMtx->wy, shieldMtx->wz, + this->sourceEndRad, this->poolEndRad)) { + temp_f0 = sqrtf(SQ(shieldMtx->zz) + (SQ(shieldMtx->zx) + SQ(shieldMtx->zy))); + if (temp_f0 == 0.0f) { + this->reflectRange = 1.0f; + } else { + this->reflectRange = 1.0f / temp_f0; + } + + if (sMirRayData[MIRRAY_LOCATION(&this->actor)].params & 1) { + this->reflectIntensity = 1.0f; + } else { + sp4C[0] = this->poolPt.x - this->sourcePt.x; + sp4C[1] = this->poolPt.y - this->sourcePt.y; + sp4C[2] = this->poolPt.z - this->sourcePt.z; + + temp_f2 = (-shieldMtx->zx * sp4C[0]) - (shieldMtx->zy * sp4C[1]) - (shieldMtx->zz * sp4C[2]); + + if (temp_f2 < 0.0f) { + temp_f0_2 = sqrtf(SQ(sp4C[0]) + SQ(sp4C[1]) + SQ(sp4C[2])); + if ((temp_f0 != 0.0f) && (temp_f0_2 != 0.0f)) { + this->reflectIntensity = -temp_f2 / (temp_f0 * temp_f0_2); + } + } + } + } +} + +// Draws six images, one for each corner of the shield, by finding the intersection of a line segment from the corner +// perpendicular to the shield with the nearest collision (if any). +void MirRay_SetupReflectionPolys(MirRay* this, GlobalContext* globalCtx, MirRayShieldReflection* reflection) { + s32 i; + Player* player = GET_PLAYER(globalCtx); + MtxF* shieldMtx = &player->shieldMf; + Vec3f posA; + Vec3f posB; + Vec3f sp70; + CollisionPoly* outPoly; + f32 sp60[3]; + + sp60[0] = -(shieldMtx->zx * this->reflectRange) * this->reflectIntensity * 400.0f; + sp60[1] = -(shieldMtx->zy * this->reflectRange) * this->reflectIntensity * 400.0f; + sp60[2] = -(shieldMtx->zz * this->reflectRange) * this->reflectIntensity * 400.0f; + + for (i = 0; i < ARRAY_COUNT(this->shieldCorners); i++) { + posA.x = + (shieldMtx->wx + (this->shieldCorners[i].x * shieldMtx->xx)) + (this->shieldCorners[i].y * (*shieldMtx).yx); + posA.y = + (shieldMtx->wy + (this->shieldCorners[i].x * shieldMtx->xy)) + (this->shieldCorners[i].y * (*shieldMtx).yy); + posA.z = + (shieldMtx->wz + (this->shieldCorners[i].x * shieldMtx->xz)) + (this->shieldCorners[i].y * (*shieldMtx).yz); + + posB.x = sp60[0] + posA.x; + posB.y = sp60[1] + posA.y; + posB.z = sp60[2] + posA.z; + + if (BgCheck_AnyLineTest1(&globalCtx->colCtx, &posA, &posB, &sp70, &outPoly, 1)) { + reflection[i].reflectionPoly = outPoly; + } else { + reflection[i].reflectionPoly = NULL; + } + } +} + +// Remove reflections that are in the same position and are sufficiently near to the same plane +void MirRay_RemoveSimilarReflections(MirRayShieldReflection* reflection) { + s32 i, j; + + for (i = 0; i < 6; i++) { + for (j = i + 1; j < 6; j++) { + if ((reflection[i].reflectionPoly != NULL) && (reflection[j].reflectionPoly != NULL)) { + if ((ABS(reflection[i].reflectionPoly->normal.x - reflection[j].reflectionPoly->normal.x) < 100) && + (ABS(reflection[i].reflectionPoly->normal.y - reflection[j].reflectionPoly->normal.y) < 100) && + (ABS(reflection[i].reflectionPoly->normal.z - reflection[j].reflectionPoly->normal.z) < 100) && + (reflection[i].reflectionPoly->dist == reflection[j].reflectionPoly->dist)) { + reflection[j].reflectionPoly = NULL; + } + } + } + } +} + +// Creates the reflected beam's collider (to interact with objects) and places and orients the shield images +#ifdef NON_MATCHING +// Beginning block re-ordered +void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldReflection* reflection) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + f32 temp_f0; + Vec3f vecB; + Vec3f vecD; + Vec3f sp118; + Vec3f sp10C; + Vec3f sp100; + Vec3f intersection; + f32 spE8[3]; + f32 normalVec[3]; + MtxF* shieldMtx = &player->shieldMf; + Vec3f vecA; + Vec3f vecC; + + spE8[0] = -(shieldMtx->zx * this->reflectRange) * this->reflectIntensity * 400.0f; + spE8[1] = -(shieldMtx->zy * this->reflectRange) * this->reflectIntensity * 400.0f; + spE8[2] = -(shieldMtx->zz * this->reflectRange) * this->reflectIntensity * 400.0f; + + vecB.x = shieldMtx->wx; + vecB.y = shieldMtx->wy; + vecB.z = shieldMtx->wz; + + vecD.x = spE8[0] + vecB.x; + vecD.y = spE8[1] + vecB.y; + vecD.z = spE8[2] + vecB.z; + + vecA.x = vecB.x + (shieldMtx->xx * 300.0f); + vecA.y = vecB.y + (shieldMtx->xy * 300.0f); + vecA.z = vecB.z + (shieldMtx->xz * 300.0f); + + vecC.x = vecD.x + (shieldMtx->xx * 300.0f); + vecC.y = vecD.y + (shieldMtx->xy * 300.0f); + vecC.z = vecD.z + (shieldMtx->xz * 300.0f); + + Collider_SetQuadVertices(&this->collider2, &vecA, &vecB, &vecC, &vecD); + + for (i = 0; i < 6; i++) { + if (reflection[i].reflectionPoly != NULL) { + normalVec[0] = COLPOLY_GET_NORMAL(reflection[i].reflectionPoly->normal.x); + normalVec[1] = COLPOLY_GET_NORMAL(reflection[i].reflectionPoly->normal.y); + normalVec[2] = COLPOLY_GET_NORMAL(reflection[i].reflectionPoly->normal.z); + + if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], reflection[i].reflectionPoly->dist, + &vecB, &vecD, &sp118, 1)) { + + reflection[i].pos.x = sp118.x; + reflection[i].pos.y = sp118.y; + reflection[i].pos.z = sp118.z; + + temp_f0 = sqrtf(SQ(sp118.x - vecB.x) + SQ(sp118.y - vecB.y) + SQ(sp118.z - vecB.z)); + + if (temp_f0 < (this->reflectIntensity * 600.0f)) { + reflection[i].opacity = 200; + } else { + reflection[i].opacity = (s32)(800.0f - temp_f0); + } + + reflection[i].opacity = (s32)(reflection[i].opacity * 1.275f); + + sp10C.x = (shieldMtx->xx * 100.0f) + vecB.x; + sp10C.y = (shieldMtx->xy * 100.0f) + vecB.y; + sp10C.z = (shieldMtx->xz * 100.0f) + vecB.z; + + sp100.x = (spE8[0] * 4.0f) + sp10C.x; + sp100.y = (spE8[1] * 4.0f) + sp10C.y; + sp100.z = (spE8[2] * 4.0f) + sp10C.z; + + reflection[i].mtx.xx = reflection[i].mtx.yy = reflection[i].mtx.zz = reflection[i].mtx.ww = 1.0f; + + reflection[i].mtx.xy = reflection[i].mtx.xz = reflection[i].mtx.xw = reflection[i].mtx.yx = + reflection[i].mtx.yz = reflection[i].mtx.yw = reflection[i].mtx.zx = reflection[i].mtx.zy = + reflection[i].mtx.zw = reflection[i].mtx.wx = reflection[i].mtx.wy = reflection[i].mtx.wz = + 0.0f; + + if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], reflection[i].reflectionPoly->dist, + &sp10C, &sp100, &intersection, 1)) { + reflection[i].mtx.xx = intersection.x - sp118.x; + reflection[i].mtx.xy = intersection.y - sp118.y; + reflection[i].mtx.xz = intersection.z - sp118.z; + } + + sp10C.x = (shieldMtx->yx * 100.0f) + vecB.x; + sp10C.y = (shieldMtx->yy * 100.0f) + vecB.y; + sp10C.z = (shieldMtx->yz * 100.0f) + vecB.z; + + sp100.x = (spE8[0] * 4.0f) + sp10C.x; + sp100.y = (spE8[1] * 4.0f) + sp10C.y; + sp100.z = (spE8[2] * 4.0f) + sp10C.z; + + if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], reflection[i].reflectionPoly->dist, + &sp10C, &sp100, &intersection, 1)) { + reflection[i].mtx.yx = intersection.x - sp118.x; + reflection[i].mtx.yy = intersection.y - sp118.y; + reflection[i].mtx.yz = intersection.z - sp118.z; + } + } else { + reflection[i].reflectionPoly = NULL; + } + } + } +} +#else +void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldReflection* reflection); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/MirRay_ReflectedBeam.s") #endif -extern ColliderQuadInit D_808E3BF4; -extern ColliderJntSphElementInit D_808E3C44[1]; -extern ColliderJntSphInit D_808E3C68; -extern InitChainEntry D_808E3DB8[]; +void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + MirRay* this = THIS; + Player* player = GET_PLAYER(globalCtx); + MirRayShieldReflection reflection[6]; + s32 i; -extern UNK_TYPE D_060003F8; + this->reflectIntensity = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/D_808E3DD0.s") + if (!D_808E3BF0 && !this->unLit && func_80124088(globalCtx)) { + Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); + MirRay_SetIntensity(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E2600.s") + if (this->reflectIntensity <= 0.0f) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E26C8.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/MirRay_Init.s") + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Scale(1.0f, 1.0f, this->reflectIntensity, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/MirRay_Destroy.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)(s8)(this->reflectIntensity * 100.0f)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/MirRay_Update.s") + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_mir_ray_Matanimheader_0003F8)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E2C68.s") + gSPDisplayList(POLY_XLU_DISP++, object_mir_ray_DL_000168); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E2E1C.s") + MirRay_SetupReflectionPolys(this, globalCtx, reflection); + MirRay_RemoveSimilarReflections(reflection); + MirRay_ReflectedBeam(this, globalCtx, reflection); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E2FF8.s") + if (reflection[0].reflectionPoly == NULL) { + reflection[0].opacity = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E30FC.s") + for (i = 1; i < ARRAY_COUNT(reflection); i++) { + if (reflection[i].reflectionPoly != NULL) { + if (reflection[0].opacity < reflection[i].opacity) { + reflection[0].opacity = reflection[i].opacity; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/MirRay_Draw.s") + for (i = 0; i < ARRAY_COUNT(reflection); i++) { + if (reflection[i].reflectionPoly != NULL) { + Matrix_InsertTranslation(reflection[i].pos.x, reflection[i].pos.y, reflection[i].pos.z, MTXMODE_NEW); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + Matrix_InsertMatrix(&reflection[i].mtx, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E3984.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_DECAL2); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, reflection[0].opacity); + gSPDisplayList(POLY_XLU_DISP++, object_mir_ray_DL_0004B0); + } + } + + D_808E3BF0 = true; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +// Computes if the Point (pointx, pointy, pointz) lies within the right conical frustum with one end centred at vecA +// with radius radiusA, the other at vecB with radius radiusB +s32 MirRay_CheckInFrustum(Vec3f* vecA, Vec3f* vecB, f32 pointx, f32 pointy, f32 pointz, s16 radiusA, s16 radiusB) { + f32 coneRadius; + f32 closestPtx; + f32 closestPty; + f32 closestPtz; + Vec3f vecdiff; + f32 dist; + Vec3f sp5C; + Vec3f sp50; + Vec3f sp44; + + vecdiff.x = vecB->x - vecA->x; + vecdiff.y = vecB->y - vecA->y; + vecdiff.z = vecB->z - vecA->z; + if (1) {} + + dist = SQ(vecdiff.x) + SQ(vecdiff.y) + SQ(vecdiff.z); + + if (dist == 0.0f) { + return false; + } + + dist = + (((pointx - vecA->x) * vecdiff.x) + ((pointy - vecA->y) * vecdiff.y) + ((pointz - vecA->z) * vecdiff.z)) / dist; + + // Closest point on line A-B to Point + closestPtx = (vecdiff.x * dist) + vecA->x; + closestPty = (vecdiff.y * dist) + vecA->y; + closestPtz = (vecdiff.z * dist) + vecA->z; + + // Diameter of the double cone on the perpendicular plane through the closest point + coneRadius = ((radiusB - radiusA) * dist) + radiusA; + + // If the Point is within the bounding double cone, check if it is in the frustum by checking whether it is between + // the bounding planes + if ((SQ(closestPtx - pointx) + SQ(closestPty - pointy) + SQ(closestPtz - pointz)) <= SQ(coneRadius)) { + if (1) {} + + // Stores the vector difference again + Math_Vec3f_Diff(vecB, vecA, &sp5C); + + sp50.x = pointx - vecA->x; + sp50.y = pointy - vecA->y; + sp50.z = pointz - vecA->z; + + if (Math3D_Parallel(&sp5C, &sp50) < 0.0f) { + return false; + } + + sp44.x = pointx - vecB->x; + sp44.y = pointy - vecB->y; + sp44.z = pointz - vecB->z; + + if (Math3D_Parallel(&sp5C, &sp44) > 0.0f) { + return false; + } + return true; + } + return false; +} diff --git a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h index c03b48c6b..4d748e3b5 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h @@ -5,9 +5,39 @@ struct MirRay; +#define MIRRAY_LOCATION(thisx) ((thisx)->params) + +// Locations of light beams in sMirRayData +typedef enum { + /* 0 */ MIRRAY_SPIRIT_BOMBCHUIWAROOM_DOWNLIGHT, + /* 1 */ MIRRAY_SPIRIT_SUNBLOCKROOM_DOWNLIGHT, + /* 2 */ MIRRAY_SPIRIT_SINGLECOBRAROOM_DOWNLIGHT, + /* 3 */ MIRRAY_SPIRIT_ARMOSROOM_DOWNLIGHT, + /* 4 */ MIRRAY_SPIRIT_TOPROOM_DOWNLIGHT, + /* 5 */ MIRRAY_SPIRIT_TOPROOM_CEILINGMIRROR, + /* 6 */ MIRRAY_SPIRIT_SINGLECOBRAROOM_COBRA, + /* 7 */ MIRRAY_SPIRIT_TOPROOM_COBRA1, + /* 8 */ MIRRAY_SPIRIT_TOPROOM_COBRA2, + /* 9 */ MIRRAY_GANONSCASTLE_SPIRITTRIAL_DOWNLIGHT, + /* 10 */ MIRRAY_MAX, +} MirRayBeamLocations; + typedef struct MirRay { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x164]; + /* 0x0000 */ Actor actor; + /* 0x0144 */ ColliderJntSph collider1; + /* 0x0164 */ ColliderJntSphElement collider1Elements[1]; + /* 0x01A4 */ ColliderQuad collider2; + /* 0x0224 */ f32 reflectIntensity; // Reflection occurs if it is positive, brightness depends on it + /* 0x0228 */ Vec3f shieldCorners[6]; + /* 0x0270 */ f32 reflectRange; + /* 0x0274 */ Vec3f sourcePt; + /* 0x0280 */ Vec3f poolPt; + /* 0x028C */ s16 sourceEndRad; + /* 0x028E */ s16 poolEndRad; + /* 0x0290 */ s16 lightPointRad; + /* 0x0294 */ LightNode* lightNode; + /* 0x0298 */ LightInfo lightInfo; + /* 0x02A6 */ u8 unLit; // Conditioned on. set in Cobra? } MirRay; // size = 0x2A8 extern const ActorInit Mir_Ray_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e1bf5f807..8be41c5c1 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -6539,17 +6539,17 @@ 0x808E2444:("func_808E2444",), 0x808E24B4:("BgCtowerRot_Update",), 0x808E24D8:("BgCtowerRot_Draw",), - 0x808E2600:("func_808E2600",), - 0x808E26C8:("func_808E26C8",), + 0x808E2600:("MirRay_SetupCollider",), + 0x808E26C8:("MirRay_MakeShieldLight",), 0x808E286C:("MirRay_Init",), 0x808E2B04:("MirRay_Destroy",), 0x808E2B7C:("MirRay_Update",), - 0x808E2C68:("func_808E2C68",), - 0x808E2E1C:("func_808E2E1C",), - 0x808E2FF8:("func_808E2FF8",), - 0x808E30FC:("func_808E30FC",), + 0x808E2C68:("MirRay_SetIntensity",), + 0x808E2E1C:("MirRay_SetupReflectionPolys",), + 0x808E2FF8:("MirRay_RemoveSimilarReflections",), + 0x808E30FC:("MirRay_ReflectedBeam",), 0x808E36A4:("MirRay_Draw",), - 0x808E3984:("func_808E3984",), + 0x808E3984:("MirRay_CheckInFrustum",), 0x808E3EF0:("EnSb_Init",), 0x808E3FF0:("EnSb_Destroy",), 0x808E401C:("EnSb_SpawnBubbles",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 8182801cc..4a386640d 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1975,12 +1975,6 @@ D_06000D94 = 0x06000D94; D_06007650 = 0x06007650; D_0600D658 = 0x0600D658; -// ovl_Mir_Ray - -D_06000168 = 0x06000168; -D_060003F8 = 0x060003F8; -D_060004B0 = 0x060004B0; - // ovl_Mir_Ray3 D_06000168 = 0x06000168; From 84e13ff2a09ba9a08ec466ebb634a2cf5acf7c75 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Mon, 28 Feb 2022 02:29:56 +0000 Subject: [PATCH 051/257] Obj_Comb (#632) * Obj_Comb * PR --- include/functions.h | 2 +- spec | 3 +- src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c | 539 ++++++++++++++++-- src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h | 23 +- undefined_syms.txt | 5 - 5 files changed, 528 insertions(+), 44 deletions(-) diff --git a/include/functions.h b/include/functions.h index 3223aa624..aff556e4c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1503,7 +1503,7 @@ s16 ActorCutscene_GetCurrentIndex(void); ActorCutscene* ActorCutscene_GetCutscene(s16 index); s16 ActorCutscene_GetAdditionalCutscene(s16 index); s16 ActorCutscene_GetLength(s16 index); -// void func_800F2138(void); +s32 func_800F2138(s8 arg0); s32 func_800F2178(s16 arg0); s16 ActorCutscene_GetCurrentCamera(s16 index); // void func_800F21CC(void); diff --git a/spec b/spec index f6871e38b..0909055e8 100644 --- a/spec +++ b/spec @@ -2126,8 +2126,7 @@ beginseg name "ovl_Obj_Comb" compress include "build/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.o" - include "build/data/ovl_Obj_Comb/ovl_Obj_Comb.data.o" - include "build/data/ovl_Obj_Comb/ovl_Obj_Comb.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Comb/ovl_Obj_Comb_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c index 4a82c7609..f40634044 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c @@ -5,6 +5,7 @@ */ #include "z_obj_comb.h" +#include "objects/object_comb/object_comb.h" #define FLAGS 0x00000000 @@ -15,11 +16,12 @@ void ObjComb_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjComb_Update(Actor* thisx, GlobalContext* globalCtx); void ObjComb_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_8098DC44(ObjComb* this); void func_8098DC60(ObjComb* this, GlobalContext* globalCtx); void func_8098DEA0(ObjComb* this, GlobalContext* globalCtx); +void func_8098E098(ObjComb* this); void func_8098E0B8(ObjComb* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Comb_InitVars = { ACTOR_OBJ_COMB, ACTORCAT_PROP, @@ -32,71 +34,538 @@ const ActorInit Obj_Comb_InitVars = { (ActorFunc)ObjComb_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8098E440[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x05CBFFBE, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x05CBFFBE, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 15 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8098E464 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, D_8098E440, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8098E474[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), }; -#endif +s32 func_8098CE40(ObjComb* this, GlobalContext* globalCtx) { + s32 phi_a2 = -1; + s32 temp_v0 = (OBJCOMB_GET_1F(&this->actor) << 2) | 0xFF01; -extern ColliderJntSphElementInit D_8098E440[1]; -extern ColliderJntSphInit D_8098E464; -extern InitChainEntry D_8098E474[]; + if ((u8)temp_v0 & 3) { + phi_a2 = ((temp_v0 & 0x3FC) >> 2) & 0xFF; + } -extern UNK_TYPE D_06000CB0; -extern UNK_TYPE D_06001040; + return ((phi_a2 < 0) == 1) || !Flags_GetTreasure(globalCtx, phi_a2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098CE40.s") +void func_8098CEAC(ObjComb* this, GlobalContext* globalCtx) { + Vec3f spDC; + Vec3f spD0; + Vec3f spC4; + s32 i; + f32 temp_f20; + s16 temp_s2 = 0; + s16 temp_f10; + s32 phi_s0; + s32 phi_v0; + s32 phi_s1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098CEAC.s") + for (i = 0; i < 31; i++) { + temp_s2 += 0x4E20; + temp_f20 = Rand_ZeroOne() * 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098D19C.s") + spDC.x = Math_SinS(temp_s2) * temp_f20; + spDC.y = (i - 15) * 0.7f; + spDC.z = Math_CosS(temp_s2) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098D47C.s") + Math_Vec3f_Sum(&spDC, &this->actor.world.pos, &spD0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098D6E0.s") + spC4.x = (Rand_ZeroOne() - 0.5f) + (spDC.x * 0.5f); + spC4.y = (Rand_ZeroOne() - 0.5f) + (spDC.y * 0.6f); + spC4.z = (Rand_ZeroOne() - 0.5f) + (spDC.z * 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098D870.s") + temp_f10 = (Rand_ZeroOne() * 72.0f) + 25.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098D8C8.s") + if (temp_f10 < 40) { + phi_s0 = -200; + phi_s1 = 40; + } else if (temp_f10 < 70) { + phi_s0 = -280; + phi_s1 = 30; + } else { + phi_s0 = -340; + phi_s1 = 20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098D99C.s") + temp_f20 = Rand_ZeroOne(); + if (temp_f20 < 0.1f) { + phi_v0 = 0x60; + } else if (temp_f20 < 0.8f) { + phi_v0 = 0x40; + } else { + phi_v0 = 0x20; + } + EffectSsKakera_Spawn(globalCtx, &spD0, &spC4, &spD0, phi_s0, phi_v0, phi_s1, 4, 0, temp_f10, 0, 0, 60, -1, + OBJECT_COMB, object_comb_DL_001040); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098DA74.s") + spD0.x = this->actor.world.pos.x; + spD0.y = this->actor.world.pos.y - 10.0f; + spD0.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/ObjComb_Init.s") + func_800BBFB0(globalCtx, &spD0, 40.0f, 6, 70, 60, 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/ObjComb_Destroy.s") +void func_8098D19C(ObjComb* this, GlobalContext* globalCtx) { + Vec3f spDC; + Vec3f spD0; + Vec3f spC4; + f32 temp_f20; + s16 temp_s2 = 0; + s16 temp_f8; + s32 phi_s0; + s32 phi_v0; + s32 phi_s1; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098DC44.s") + for (i = 0; i < 31; i++) { + temp_s2 += 0x4E20; + temp_f20 = Rand_ZeroOne() * 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098DC60.s") + spDC.x = Math_SinS(temp_s2) * temp_f20; + spDC.y = i * 0.7f; + spDC.z = Math_CosS(temp_s2) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098DE58.s") + Math_Vec3f_Sum(&spDC, &this->actor.world.pos, &spD0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098DEA0.s") + spC4.x = (Rand_ZeroOne() - 0.5f) + (spDC.x * 0.5f); + spC4.y = (Rand_ZeroOne() * 0.5f) + (spDC.y * 0.5f); + spC4.z = (Rand_ZeroOne() - 0.5f) + (spDC.z * 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098E098.s") + temp_f8 = (Rand_ZeroOne() * 72.0f) + 25.0f; + if (temp_f8 < 40) { + phi_s0 = -200; + phi_s1 = 40; + } else if (temp_f8 < 70) { + phi_s0 = -280; + phi_s1 = 30; + } else { + phi_s0 = -340; + phi_s1 = 20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098E0B8.s") + temp_f20 = Rand_ZeroOne(); + if (temp_f20 < 0.1f) { + phi_v0 = 0x60; + } else if (temp_f20 < 0.8f) { + phi_v0 = 0x40; + } else { + phi_v0 = 0x20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/ObjComb_Update.s") + EffectSsKakera_Spawn(globalCtx, &spD0, &spC4, &spD0, phi_s0, phi_v0, phi_s1, 4, 0, temp_f8, 0, 0, 60, -1, + OBJECT_COMB, object_comb_DL_001040); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/ObjComb_Draw.s") + spD0.x = this->actor.world.pos.x; + spD0.y = this->actor.world.pos.y + 20.0f; + spD0.z = this->actor.world.pos.z; + + func_800BBFB0(globalCtx, &spD0, 40.0f, 6, 70, 60, 1); +} + +void func_8098D47C(ObjComb* this, GlobalContext* globalCtx) { + Vec3f spD4; + Vec3f spC8; + Vec3f spBC; + f32 temp_f20; + s16 temp_s1 = 0; + s16 temp_f10; + s32 phi_s0; + s32 phi_v0; + s32 i; + + for (i = 0; i < 21; i++) { + temp_s1 += 0x4E20; + temp_f20 = Rand_ZeroOne() * 10.0f; + + spD4.x = Math_SinS(temp_s1) * temp_f20; + spD4.y = i * 0.25f; + spD4.z = Math_CosS(temp_s1) * temp_f20; + + Math_Vec3f_Sum(&spD4, &this->actor.world.pos, &spC8); + + spBC.x = (Rand_ZeroOne() - 0.5f) + (spD4.x * 0.5f); + spBC.y = Rand_ZeroOne() + (spD4.y * 0.6f) + 6.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) + (spD4.z * 0.5f); + + temp_f10 = (Rand_ZeroOne() * 72.0f) + 25.0f; + if (temp_f10 < 40) { + phi_s0 = -100; + } else if (temp_f10 < 70) { + phi_s0 = -180; + } else { + phi_s0 = -240; + } + + if (Rand_ZeroOne() < 0.2f) { + phi_v0 = 0x40; + } else { + phi_v0 = 0x20; + } + + EffectSsKakera_Spawn(globalCtx, &spC8, &spBC, &spC8, phi_s0, phi_v0, 40, 0, 0, temp_f10, 0, 0, 80, -1, + OBJECT_COMB, object_comb_DL_001040); + } +} + +void func_8098D6E0(ObjComb* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp70; + f32 temp_f0; + f32 temp_f20; + s32 temp; + + sp70.y = this->actor.world.pos.y + this->actor.depthInWater; + + for (temp = 0, i = 0; i < 8; i++, temp += 0x2000) { + temp_f0 = Rand_ZeroOne(); + temp_f20 = ((1.0f - SQ(temp_f0)) * 14.0f) + 4.0f; + sp70.x = (Math_SinS((s32)(Rand_ZeroOne() * 8000.0f) + temp) * temp_f20) + this->actor.world.pos.x; + sp70.z = (Math_CosS((s32)(Rand_ZeroOne() * 8000.0f) + temp) * temp_f20) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp70, NULL, NULL, 0, 200); + } + + sp70.x = this->actor.world.pos.x; + sp70.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp70, NULL, NULL, 0, 300); +} + +void func_8098D870(ObjComb* this, GlobalContext* globalCtx) { + s32 temp_v0 = func_800A8150(OBJCOMB_GET_3F(&this->actor)); + + if (temp_v0 >= 0) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, ((OBJCOMB_GET_7F00(&this->actor)) << 8) | temp_v0); + } +} + +void func_8098D8C8(ObjComb* this, GlobalContext* globalCtx) { + s32 params = OBJCOMB_GET_F(&this->actor); + s32 i; + s32 phi_s5; + + if (this->actionFunc == func_8098DC60) { + phi_s5 = 2; + } else { + phi_s5 = 1; + } + this->unk_1B6 = 0; + + for (i = 0; i < params; i++) { + if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BEE, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, phi_s5)) { + this->unk_1B6 = 1; + } + } +} + +void func_8098D99C(ObjComb* this, GlobalContext* globalCtx) { + s32 params; + Actor* temp_v0; + + if (func_8098CE40(this, globalCtx)) { + params = (OBJCOMB_GET_1F(&this->actor) << 2) | 0xFF01; + temp_v0 = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SW, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.home.rot.y, 0, params); + + if (temp_v0 != NULL) { + temp_v0->parent = &this->actor; + if (this->actionFunc == func_8098DC60) { + temp_v0->velocity.y = 8.0f; + temp_v0->speedXZ = 2.0f; + } else { + temp_v0->velocity.y = 10.0f; + temp_v0->speedXZ = 2.0f; + } + this->unk_1B6 = 1; + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + } +} + +void func_8098DA74(ObjComb* this, GlobalContext* globalCtx) { + s32 temp_v0 = OBJCOMB_GET_8000(&this->actor) | OBJCOMB_GET_80(&this->actor); + + if (temp_v0 == 0) { + func_8098D870(this, globalCtx); + } else if (temp_v0 == 1) { + func_8098D8C8(this, globalCtx); + } else { + func_8098D99C(this, globalCtx); + } +} + +void ObjComb_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjComb* this = THIS; + s32 sp2C = OBJCOMB_GET_8000(&this->actor) | OBJCOMB_GET_80(&this->actor); + + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitJntSph(globalCtx, &this->collider); + + if ((sp2C == 1) && OBJCOMB_GET_10(&this->actor) && (gSaveContext.weekEventReg[83] & 2)) { + Actor_MarkForDeath(&this->actor); + return; + } + + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, &this->colliderElement); + + if ((sp2C == 0) && func_800A81A4(globalCtx, OBJCOMB_GET_3F(&this->actor), OBJCOMB_GET_7F00(&this->actor))) { + this->unk_1B7 = 1; + this->actor.flags |= ACTOR_FLAG_10; + } + + if ((sp2C != 2) || !func_8098CE40(this, globalCtx)) { + this->unk_1B8 = -1; + } + func_8098DC44(this); +} + +void ObjComb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyJntSph(globalCtx, &THIS->collider); +} + +void func_8098DC44(ObjComb* this) { + this->unk_1AC = 0x2EE0; + this->actionFunc = func_8098DC60; +} + +void func_8098DC60(ObjComb* this, GlobalContext* globalCtx) { + s32 temp_a0; + s8 temp_v0; + u32 temp_v1; + + this->unk_1AA += this->unk_1AC; + if (this->unk_1B3) { + this->collider.base.acFlags &= ~AC_HIT; + } + + this->unk_1A8 -= 0x32; + if (this->unk_1A8 < 0) { + this->unk_1A8 = 0; + } + + if (this->unk_1B3) { + if (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x0182C29C) { + func_8098CEAC(this, globalCtx); + func_8098DA74(this, globalCtx); + Actor_MarkForDeath(&this->actor); + } else { + s32 dmgFlags = this->collider.elements->info.acHitInfo->toucher.dmgFlags; + + if (dmgFlags & 0x13820) { + this->unk_1A8 = 0xDAC; + this->unk_1AC = 0x36B0; + } else { + this->unk_1A8 = 0x5DC; + this->unk_1AC = 0x2EE0; + } + + if ((this->unk_1B2 <= 0) && (dmgFlags & 0x13820)) { + if (this->unk_1B5 == 0) { + this->unk_1B5 = 1; + this->actor.flags |= ACTOR_FLAG_10; + } + this->unk_1B2 = 20; + } + } + } else { + if (this->unk_1B8 >= 0) { + if (this->unk_1B8 == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); + if (Rand_ZeroOne() < 0.1f) { + this->unk_1B8 = Rand_S16Offset(40, 80); + } else { + this->unk_1B8 = 8; + } + } else { + this->unk_1B8--; + } + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->actor.update != NULL) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + this->actor.shape.rot.x = (s32)(Math_SinS(this->unk_1AA) * this->unk_1A8) + this->actor.home.rot.x; +} + +void func_8098DE58(ObjComb* this) { + this->actor.flags |= ACTOR_FLAG_10; + this->unk_1B4 = 100; + this->actor.terminalVelocity = -20.0f; + this->actor.gravity = -1.5f; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_8098DEA0; +} + +void func_8098DEA0(ObjComb* this, GlobalContext* globalCtx) { + this->unk_1B4--; + if ((this->actor.bgCheckFlags & 1) || (this->unk_1B4 <= 0)) { + func_8098DA74(this, globalCtx); + if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 30.0f)) { + func_8098D47C(this, globalCtx); + } else { + func_8098D19C(this, globalCtx); + } + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_HONEYCOMB_BROKEN); + func_8098E098(this); + } else { + if (this->actor.bgCheckFlags & 0x40) { + func_8098D6E0(this, globalCtx); + } + + if (this->actor.bgCheckFlags & 0x20) { + this->actor.gravity = -0.5f; + this->actor.velocity.y *= 0.8f; + this->unk_1AE >>= 1; + this->unk_1B0 >>= 1; + } else { + this->actor.gravity = -1.5f; + this->actor.velocity.y *= 0.96f; + + this->unk_1AE += 0x1F4; + if (this->unk_1AE > 0x7D0) { + this->unk_1AE = 0x7D0; + } + + this->unk_1B0 += 0xC8; + if (this->unk_1B0 > 0x258) { + this->unk_1B0 = 0x258; + } + func_800B9010(&this->actor, NA_SE_EV_HONEYCOMB_FALL - SFX_FLAG); + } + + Actor_MoveWithGravity(&this->actor); + this->actor.shape.rot.x += this->unk_1AE; + this->actor.shape.rot.y += this->unk_1B0; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 12.0f, 0.0f, 5); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_8098E098(ObjComb* this) { + this->actor.draw = NULL; + this->unk_1B4 = 20; + this->actionFunc = func_8098E0B8; +} + +void func_8098E0B8(ObjComb* this, GlobalContext* globalCtx) { + this->unk_1B4--; + if (this->unk_1B4 <= 0) { + Actor_MarkForDeath(&this->actor); + return; + } + + if ((this->unk_1B4 == 10) && (this->unk_1B6 != 0) && (this->unk_1B5 == 2) && (this->actor.cutscene >= 0)) { + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + func_800B7298(globalCtx, &this->actor, 4); + } + } +} + +void ObjComb_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjComb* this = THIS; + + this->unk_1B3 = (this->collider.base.acFlags & AC_HIT) != 0; + if (this->unk_1B3) { + this->collider.base.acFlags &= ~AC_HIT; + } + + if (this->unk_1B2 > 0) { + this->unk_1B2--; + if (this->unk_1B2 == 0) { + func_8098DE58(this); + } + } + + this->actionFunc(this, globalCtx); + + if (this->actor.update == NULL) { + if ((this->unk_1B5 == 2) && (func_800F2138(this->actor.cutscene) == -1)) { + ActorCutscene_Stop(this->actor.cutscene); + this->unk_1B5 = 0; + } + } else { + if (this->unk_1B5 != 0) { + Actor_SetFocus(&this->actor, 0.0f); + if (this->unk_1B5 == 1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + if (this->actor.cutscene >= 0) { + func_800B7298(globalCtx, &this->actor, 1); + } + + if (((OBJCOMB_GET_8000(&this->actor) | OBJCOMB_GET_80(&this->actor)) == 1) && + OBJCOMB_GET_10(&this->actor)) { + gSaveContext.weekEventReg[83] |= 2; + } + + this->unk_1B5 = 2; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + } + + if (this->unk_1B7 != 0) { + globalCtx->actorCtx.unk5 |= 8; + this->actor.flags |= ACTOR_FLAG_10; + } + } +} + +void ObjComb_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjComb* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + (118.0f * this->actor.scale.y), + this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -(this->actor.scale.y * 118.0f), 0.0f, MTXMODE_APPLY); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_comb_DL_000CB0); + + Collider_UpdateSpheres(0, &this->collider); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h index 303a3ed5e..fc47df429 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h @@ -7,10 +7,31 @@ struct ObjComb; typedef void (*ObjCombActionFunc)(struct ObjComb*, GlobalContext*); +#define OBJCOMB_GET_F(thisx) ((thisx)->params & 0xF) +#define OBJCOMB_GET_10(thisx) (((thisx)->params >> 4) & 0x1) +#define OBJCOMB_GET_1F(thisx) ((thisx)->params & 0x1F) +#define OBJCOMB_GET_3F(thisx) ((thisx)->params & 0x3F) +#define OBJCOMB_GET_80(thisx) (((thisx)->params >> 7) & 0x1) +#define OBJCOMB_GET_7F00(thisx) (((thisx)->params >> 0x8) & 0x7F) +#define OBJCOMB_GET_8000(thisx) (((thisx)->params >> 0xE) & 2) + typedef struct ObjComb { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjCombActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x74]; + /* 0x0148 */ ColliderJntSph collider; + /* 0x0168 */ ColliderJntSphElement colliderElement; + /* 0x01A8 */ s16 unk_1A8; + /* 0x01AA */ s16 unk_1AA; + /* 0x01AC */ s16 unk_1AC; + /* 0x01AE */ s16 unk_1AE; + /* 0x01B0 */ s16 unk_1B0; + /* 0x01B2 */ s8 unk_1B2; + /* 0x01B3 */ s8 unk_1B3; + /* 0x01B4 */ s8 unk_1B4; + /* 0x01B5 */ s8 unk_1B5; + /* 0x01B6 */ s8 unk_1B6; + /* 0x01B7 */ s8 unk_1B7; + /* 0x01B8 */ s8 unk_1B8; } ObjComb; // size = 0x1BC extern const ActorInit Obj_Comb_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 4a386640d..90419cbce 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2009,11 +2009,6 @@ D_06002358 = 0x06002358; D_06000D10 = 0x06000D10; D_06000F00 = 0x06000F00; -// ovl_Obj_Comb - -D_06000CB0 = 0x06000CB0; -D_06001040 = 0x06001040; - // ovl_Obj_Danpeilift D_06000180 = 0x06000180; From c9f64d334457a2108b56151ca658064236dc0a6d Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Mon, 28 Feb 2022 02:38:36 +0000 Subject: [PATCH 052/257] Obj_Hunsui (#626) * Obj_Hunsui * PR * Merge * Merge --- spec | 4 +- .../ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h | 2 + .../actors/ovl_Obj_Hunsui/z_obj_hunsui.c | 654 +++++++++++++++++- .../actors/ovl_Obj_Hunsui/z_obj_hunsui.h | 44 +- undefined_syms.txt | 8 - 5 files changed, 676 insertions(+), 36 deletions(-) diff --git a/spec b/spec index 0909055e8..d9b75d9f9 100644 --- a/spec +++ b/spec @@ -4436,9 +4436,7 @@ beginseg name "ovl_Obj_Hunsui" compress include "build/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.o" - include "build/data/ovl_Obj_Hunsui/ovl_Obj_Hunsui.data.o" - include "build/data/ovl_Obj_Hunsui/ovl_Obj_Hunsui.bss.o" - include "build/data/ovl_Obj_Hunsui/ovl_Obj_Hunsui.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hunsui/ovl_Obj_Hunsui_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h index 01d11886a..b48776238 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h +++ b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h @@ -11,6 +11,8 @@ typedef void (*BgDblueMovebgActionFunc)(struct BgDblueMovebg*, GlobalContext*); #define BGDBLUEMOVEBG_GET_FF0(thisx) (((thisx)->params >> 4) & 0xFF) #define BGDBLUEMOVEBG_GET_F000(thisx) (((thisx)->params >> 0xC) & 0xF) +#define BGDBLUEMOVEBG_F_8 8 + typedef struct BgDblueMovebg { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ BgDblueMovebgActionFunc actionFunc; diff --git a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c index 869acdb43..05f6b212d 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c @@ -5,6 +5,7 @@ */ #include "z_obj_hunsui.h" +#include "objects/object_hunsui/object_hunsui.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +16,36 @@ void ObjHunsui_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHunsui_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHunsui_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B9CE64(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9D0FC(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9D120(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9D2BC(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9D4D0(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9D508(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9D714(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9DA60(Actor* thisx, GlobalContext* globalCtx); + +AnimatedMaterial* D_80B9DED0; +AnimatedMaterial* D_80B9DED4; + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 unk_01; + /* 0x02 */ u8 unk_02; +} ObjHansuiBssStruct; // size = 0x3 + +ObjHansuiBssStruct D_80B9DED8; + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 unk_01; +} ObjHansuiStruct; // size = 0x2 + +ObjHansuiStruct D_80B9DC70[] = { + { 1, 1 }, { 1, 0 }, { 2, 3 }, { 2, 1 }, { 2, 2 }, { 2, 0 }, { 3, 7 }, + { 3, 3 }, { 3, 5 }, { 3, 1 }, { 3, 6 }, { 3, 2 }, { 3, 4 }, { 3, 0 }, +}; + const ActorInit Obj_Hunsui_InitVars = { ACTOR_OBJ_HUNSUI, ACTORCAT_BG, @@ -28,42 +58,622 @@ const ActorInit Obj_Hunsui_InitVars = { (ActorFunc)ObjHunsui_Draw, }; -#endif +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_STOP), +}; -extern UNK_TYPE D_06000220; -extern UNK_TYPE D_06000C74; -extern UNK_TYPE D_06000EC0; +s32 func_80B9C450(GlobalContext* globalCtx, s32 arg1, s32 arg2) { + s32 sp2C = 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9C450.s") + if (arg2 < ARRAY_COUNT(D_80B9DC70)) { + s32 val = D_80B9DC70[arg2].unk_00; + s32 val3 = D_80B9DC70[arg2].unk_01; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9C5E8.s") + while (val--) { + if ((1 << val) & val3) { + if (!Flags_GetSwitch(globalCtx, arg1 + val)) { + sp2C = 0; + break; + } + } else if (Flags_GetSwitch(globalCtx, arg1 + val)) { + sp2C = 0; + break; + } + } + } else { + sp2C = 0; + switch (arg2) { + case 14: + if (!Flags_GetSwitch(globalCtx, arg1)) { + sp2C = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/ObjHunsui_Init.s") + if (Flags_GetSwitch(globalCtx, arg1 + 1) && Flags_GetSwitch(globalCtx, arg1 + 2) && + Flags_GetSwitch(globalCtx, arg1 + 3)) { + sp2C += 2; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/ObjHunsui_Destroy.s") + case 15: + if (!Flags_GetSwitch(globalCtx, arg1) || + (Flags_GetSwitch(globalCtx, arg1 + 1) && Flags_GetSwitch(globalCtx, arg1 + 2) && + Flags_GetSwitch(globalCtx, arg1 + 3))) { + sp2C = 1; + } + break; + } + } + return sp2C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/ObjHunsui_Update.s") +void func_80B9C5E8(ObjHunsui* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp_f10; + f32 temp_f16; + Vec3f sp40; + s16 sp3E; + f32 sp38; + f32 sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9CE64.s") + if ((this->dyna.actor.xzDistToPlayer < (45.0f * this->dyna.actor.scale.x * 10.0f)) && + (this->dyna.actor.playerHeightRel < -21.0f)) { + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + this->unk_172 &= ~8; + this->unk_19C = 0.0f; + this->unk_1A0 = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D094.s") + this->unk_18C++; + if (this->unk_18C >= 3) { + this->unk_18C = 0; + Math_Vec3f_Copy(&sp40, &player->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D0FC.s") + sp40.x += randPlusMinusPoint5Scaled(10.0f); + sp40.z += randPlusMinusPoint5Scaled(10.0f); + sp40.y += Rand_ZeroFloat(2.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D120.s") + EffectSsGSplash_Spawn(globalCtx, &sp40, NULL, NULL, 2.0f * Rand_ZeroOne(), 1); + } + } else { + this->unk_172 |= 8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D288.s") + this->unk_18C++; + if (this->unk_18C >= 3) { + Math_Vec3f_Copy(&sp40, &player->actor.world.pos); + this->unk_18C = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D2BC.s") + sp40.x += randPlusMinusPoint5Scaled(10.0f); + sp40.z += randPlusMinusPoint5Scaled(10.0f); + sp40.y += Rand_ZeroFloat(45.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D334.s") + EffectSsGSplash_Spawn(globalCtx, &sp40, NULL, NULL, 1, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D4D0.s") + sp3E = BINANG_ROT180(player->actor.world.rot.y - this->dyna.actor.yawTowardsPlayer); + player->actor.gravity = 0.0f; + player->actor.velocity.y = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D508.s") + if ((this->unk_160 != OBJHUNSUI_F000_5) && (this->unk_160 != OBJHUNSUI_F000_6)) { + Math_SmoothStepToF(&player->actor.world.pos.y, this->dyna.actor.world.pos.y, 0.5f, 4.0f, 1.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D714.s") + if ((sp3E < 0x4000) && (sp3E > -0x4000)) { + this->unk_1A4 = BINANG_ROT180(player->actor.world.rot.y); + sp34 = this->dyna.actor.xzDistToPlayer / (45.0f * this->dyna.actor.scale.x * 10.0f); + if (1) {} + sp38 = this->dyna.actor.xzDistToPlayer / (45.0f * this->dyna.actor.scale.x * 10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/ObjHunsui_Draw.s") + if (sp38 > 1.0f) { + sp38 = sp34; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9DA60.s") + player->linearVelocity *= sp38; + + if ((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) { + Math_ApproachF(&this->unk_1A0, 4.5f, 2.0f, 1.0f); + Math_ApproachF(&this->unk_19C, this->unk_1A0, 2.0f, 0.3f * sp38); + } else { + Math_ApproachF(&this->unk_1A0, 3.0f, 1.0f, 1.0f); + Math_ApproachF(&this->unk_19C, this->unk_1A0, 1.0f, 0.3f * sp38); + } + } else { + this->unk_1A4 = player->actor.world.rot.y; + player->linearVelocity *= 0.5f; + Math_ApproachF(&this->unk_1A0, 3.0f, 1.0f, 1.0f); + Math_ApproachF(&this->unk_19C, this->unk_1A0, 1.0f, 0.1f); + } + player->unk_B84 = this->unk_1A4; + player->unk_B80 = this->unk_19C; + } + } else { + if (this->unk_172 & 8) { + player->linearVelocity = this->unk_19C + player->linearVelocity; + player->currentYaw = this->unk_1A4; + } + this->unk_1A0 = 0.0f; + this->unk_19C = 0.0f; + this->unk_172 &= ~8; + } +} + +void ObjHunsui_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjHunsui* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->unk_160 = OBJHUNSUI_GET_F000(thisx); + this->unk_164 = OBJHUNSUI_GET_F80(thisx); + this->unk_168 = OBJHUNSUI_GET_7F(thisx); + DynaPolyActor_Init(&this->dyna, 1); + + if ((this->unk_160 != OBJHUNSUI_F000_5) && (this->unk_160 != OBJHUNSUI_F000_6)) { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_hunsui_Colheader_000C74); + } + + D_80B9DED0 = Lib_SegmentedToVirtual(object_hunsui_Matanimheader_000BF0); + D_80B9DED4 = Lib_SegmentedToVirtual(object_hunsui_Matanimheader_001888); + SubS_FillCutscenesList(&this->dyna.actor, &this->unk_170, 1); + this->unk_18C = 0; + + switch (this->unk_160) { + case OBJHUNSUI_F000_1: + case OBJHUNSUI_F000_2: + case OBJHUNSUI_F000_3: + case OBJHUNSUI_F000_4: + case OBJHUNSUI_F000_5: + case OBJHUNSUI_F000_6: + this->dyna.actor.uncullZoneScale = 900.0f; + this->dyna.actor.uncullZoneDownward = 90.0f; + this->dyna.actor.uncullZoneForward = 4000.0f; + break; + } + + switch (this->unk_160) { + case OBJHUNSUI_F000_5: + if (D_80B9DED8.unk_01 == 0) { + D_80B9DED8.unk_01 = 1; + this->unk_16C = this->dyna.actor.room; + this->unk_16D = this->dyna.actor.world.rot.z; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.room = -1; + } else { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + break; + + case OBJHUNSUI_F000_6: + if (D_80B9DED8.unk_02 == 0) { + D_80B9DED8.unk_02 = 1; + this->unk_16C = this->dyna.actor.room; + this->unk_16D = this->dyna.actor.world.rot.z; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.room = -1; + } else { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + break; + } + + switch (this->unk_160) { + case OBJHUNSUI_F000_0: + if (D_80B9DED8.unk_00 == 0) { + D_80B9DED8.unk_00 = 1; + this->unk_16C = this->dyna.actor.room; + this->unk_16D = this->unk_164; + // clang-format off + this->dyna.actor.room = -1; this->actionFunc = func_80B9D714; + // clang-format on + } else { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + break; + + case OBJHUNSUI_F000_2: + this->unk_172 |= 1; + + case OBJHUNSUI_F000_1: + this->dyna.actor.draw = func_80B9DA60; + if ((this->unk_172 & 1) && func_80B9C450(globalCtx, this->unk_168, this->unk_164)) { + this->unk_174 = 240.0f; + this->unk_172 |= 4; + this->unk_184 = 0xFF0; + } else { + this->unk_174 = -30.0f; + this->unk_172 |= 2; + this->unk_184 = 0; + } + this->unk_178 = this->unk_174; + this->unk_180 = func_80B9C450(globalCtx, this->unk_168, this->unk_164); + this->actionFunc = func_80B9CE64; + break; + + case OBJHUNSUI_F000_4: + this->unk_172 |= 1; + + case OBJHUNSUI_F000_3: + case OBJHUNSUI_F000_5: + case OBJHUNSUI_F000_6: + this->dyna.actor.draw = func_80B9DA60; + if ((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) { + func_80B9D2BC(this, globalCtx); + this->unk_178 = this->unk_174; + } else { + if ((this->unk_172 & 1) || func_80B9C450(globalCtx, this->unk_168, this->unk_164)) { + func_80B9D4D0(this, globalCtx); + } else { + func_80B9D0FC(this, globalCtx); + } + this->unk_178 = this->unk_174; + } + break; + } +} + +void ObjHunsui_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjHunsui* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void ObjHunsui_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjHunsui* this = THIS; + + this->actionFunc(this, globalCtx); + + if ((this->unk_172 & 0x40) && SubS_StartActorCutscene(&this->dyna.actor, this->unk_17C, -1, 0)) { + this->unk_172 &= ~0x40; + } + + if (this->unk_1AC > 1024.0f) { + this->unk_1AC -= 1024.0f; + } + + if (this->unk_1AC <= 0.0f) { + this->unk_1AC += 1024.0f; + } +} + +void func_80B9CE64(ObjHunsui* this, GlobalContext* globalCtx) { + s32 sp2C; + f32 sins; + + if (!(this->unk_172 & 2)) { + func_80B9C5E8(this, globalCtx); + } + + this->unk_18A += 0x71C; + Math_SmoothStepToF(&this->unk_190, this->unk_194, 1.0f, 0.2f, 0.01f); + + sp2C = func_80B9C450(globalCtx, this->unk_168, this->unk_164); + + if (!(this->unk_172 & 1)) { + if (sp2C != this->unk_180) { + this->unk_17C = this->unk_170; + this->unk_172 |= 0x40; + } + } + + if ((this->unk_172 & 1) || (sp2C != 0)) { + this->unk_172 &= ~2; + if (this->unk_186 == 0) { + this->unk_172 |= 0x10; + this->unk_174 = 240.0f; + if (this->unk_178 == 240.0f) { + if (this->unk_188++ > 40) { + this->unk_188 = 0; + this->unk_186 = 1; + this->unk_194 = 0.0f; + } else { + this->unk_194 = 8.0f; + } + } + } else { + this->unk_174 = 30.0f; + if (this->unk_178 == 30.0f) { + if (this->unk_188++ > 40) { + this->unk_188 = 0; + this->unk_186 = 0; + this->unk_194 = 0.0f; + } else { + this->unk_194 = 8.0f; + } + } + } + } else { + this->unk_174 = -30.0f; + if (this->unk_178 == -30.0f) { + this->unk_172 &= ~0x10; + this->unk_172 |= 2; + } + } + + sins = Math_SinS(this->unk_18A); + this->unk_198 = sins * this->unk_190; + if (!(this->unk_172 & 0x40)) { + Math_SmoothStepToF(&this->unk_178, this->unk_174, 0.6f, 10.5f, 0.05f); + } + + this->dyna.actor.world.pos.y = this->unk_198 + (this->dyna.actor.home.pos.y + this->unk_178); + this->unk_180 = sp2C; +} + +void func_80B9D094(ObjHunsui* this, GlobalContext* globalCtx) { + f32 sins; + + this->unk_18A += 0x71C; + Math_SmoothStepToF(&this->unk_190, this->unk_194, 1.0f, 0.2f, 0.01f); + sins = Math_SinS(this->unk_18A); + this->unk_198 = sins * this->unk_190; +} + +void func_80B9D0FC(ObjHunsui* this, GlobalContext* globalCtx) { + this->unk_174 = -30.0f; + this->actionFunc = func_80B9D120; +} + +void func_80B9D120(ObjHunsui* this, GlobalContext* globalCtx) { + if (((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) && + (this->unk_16C != globalCtx->roomCtx.currRoom.num) && (this->unk_16C != globalCtx->roomCtx.prevRoom.num) && + ((this->unk_16D != globalCtx->roomCtx.currRoom.num) && (this->unk_16D != globalCtx->roomCtx.prevRoom.num))) { + switch (this->unk_160) { + case OBJHUNSUI_F000_5: + D_80B9DED8.unk_01 = 0; + break; + + case OBJHUNSUI_F000_6: + D_80B9DED8.unk_02 = 0; + break; + } + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + func_80B9D094(this, globalCtx); + if (!(this->unk_172 & 0x40)) { + Math_SmoothStepToF(&this->unk_178, this->unk_174, 0.6f, 10.5f, 0.05f); + } + + this->dyna.actor.world.pos.y = this->unk_198 + (this->dyna.actor.home.pos.y + this->unk_178); + if (this->unk_178 == this->unk_174) { + this->unk_172 &= ~0x10; + this->unk_172 |= 2; + } + + if (func_80B9C450(globalCtx, this->unk_168, this->unk_164)) { + this->unk_17C = this->unk_170; + this->unk_172 |= 0x40; + func_80B9D4D0(this, globalCtx); + } +} + +s32 func_80B9D288(GlobalContext* globalCtx, Actor* thisx, Actor* iter, void* verifyData) { + s32 ret = false; + + if (BGDBLUEMOVEBG_GET_F(iter) == BGDBLUEMOVEBG_F_8) { + ret = true; + } + return ret; +} + +void func_80B9D2BC(ObjHunsui* this, GlobalContext* globalCtx) { + if ((this->unk_172 & 1) || func_80B9C450(globalCtx, this->unk_168, this->unk_164)) { + func_80B9D4D0(this, globalCtx); + } else { + this->unk_172 |= 2; + func_80B9D0FC(this, globalCtx); + } +} + +void func_80B9D334(ObjHunsui* this, GlobalContext* globalCtx) { + Vec3f sp74; + s32 i; + s32 phi_s2 = 0; + s32 phi_s3; + + switch (this->unk_160) { + case OBJHUNSUI_F000_5: + phi_s2 = 1; + break; + + case OBJHUNSUI_F000_6: + break; + } + + if (this->unk_1B4 != NULL) { + phi_s3 = false; + for (i = 0; i < 8; i++) { + if (this->unk_1B4->unk_300[phi_s2][i] == (phi_s2 + 1)) { + phi_s3 = true; + Math_Vec3f_Copy(&sp74, &this->unk_1B4->unk_238[phi_s2][i]); + this->unk_174 = sp74.y - this->dyna.actor.home.pos.y; + if (this->unk_174 > 240.0f) { + this->unk_174 = 240.0f; + } + this->unk_190 = 0.0f; + this->unk_198 = 0.0f; + this->unk_18A = 0; + } + } + + if (!phi_s3) { + this->unk_174 = 240; + } + } else { + Actor* dblueMovebg = SubS_FindActorCustom(globalCtx, &this->dyna.actor, NULL, ACTORCAT_BG, + ACTOR_BG_DBLUE_MOVEBG, NULL, func_80B9D288); + + if (dblueMovebg != NULL) { + this->unk_1B4 = (BgDblueMovebg*)dblueMovebg; + func_80B9D2BC(this, globalCtx); + } + } +} + +void func_80B9D4D0(ObjHunsui* this, GlobalContext* globalCtx) { + this->unk_172 &= ~2; + this->unk_172 |= 0x10; + this->unk_174 = 240.0f; + this->actionFunc = func_80B9D508; +} + +void func_80B9D508(ObjHunsui* this, GlobalContext* globalCtx) { + if (((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) && + (this->unk_16C != globalCtx->roomCtx.currRoom.num) && (this->unk_16C != globalCtx->roomCtx.prevRoom.num) && + (this->unk_16D != globalCtx->roomCtx.currRoom.num) && (this->unk_16D != globalCtx->roomCtx.prevRoom.num)) { + switch (this->unk_160) { + case OBJHUNSUI_F000_5: + D_80B9DED8.unk_01 = 0; + break; + + case OBJHUNSUI_F000_6: + D_80B9DED8.unk_02 = 0; + break; + } + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + func_80B9C5E8(this, globalCtx); + func_80B9D094(this, globalCtx); + + if (((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) && + (globalCtx->roomCtx.currRoom.num == 8)) { + func_80B9D334(this, globalCtx); + } + + if (!(this->unk_172 & 0x40)) { + Math_SmoothStepToF(&this->unk_178, this->unk_174, 0.6f, 10.5f, 0.05f); + } + + this->dyna.actor.world.pos.y = this->unk_198 + (this->dyna.actor.home.pos.y + this->unk_178); + + if ((this->unk_160 == OBJHUNSUI_F000_6) || (this->unk_160 == OBJHUNSUI_F000_5)) { + this->unk_1AC += -10.0f + (1.8f * (this->dyna.actor.world.pos.y - this->dyna.actor.prevPos.y)); + this->unk_1B0 += -8.0f + (0.9f * (this->dyna.actor.world.pos.y - this->dyna.actor.prevPos.y)); + } + + if (!(this->unk_172 & 1) && !func_80B9C450(globalCtx, this->unk_168, this->unk_164)) { + this->unk_17C = this->unk_170; + this->unk_172 |= 0x40; + func_80B9D0FC(this, globalCtx); + } +} + +void func_80B9D714(ObjHunsui* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + s16 cs; + f32 sp28; + + if ((this->unk_16C != globalCtx->roomCtx.currRoom.num) && (this->unk_16C != globalCtx->roomCtx.prevRoom.num) && + (this->unk_16D != globalCtx->roomCtx.currRoom.num) && (this->unk_16D != globalCtx->roomCtx.prevRoom.num)) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + if (Flags_GetSwitch(globalCtx, this->unk_168)) { + this->unk_172 &= ~2; + this->unk_172 |= 0x10; + cs = this->dyna.actor.cutscene; + + if (this->unk_16E == 0) { + if ((cs >= 0) && !ActorCutscene_GetCanPlayNext(cs)) { + ActorCutscene_SetIntentToPlay(cs); + } else if (cs >= 0) { + ActorCutscene_StartAndSetUnkLinkFields(cs, &this->dyna.actor); + this->unk_16E = -1; + } else { + this->unk_16E = 40; + } + } else if (this->unk_16E < 0) { + if (func_800F22C4(cs, &this->dyna.actor)) { + this->unk_16E = 40; + } + } else { + s32 pad; + + if (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 800.0f, 0.1f, 8.0f, + 1.0f) < 0.5f) { + if (DECR(this->unk_16E) == 0) { + Flags_UnsetSwitch(globalCtx, this->unk_168); + } + } + this->dyna.actor.velocity.y = this->dyna.actor.world.pos.y - this->dyna.actor.prevPos.y; + } + } else { + Math_StepToF(&this->dyna.actor.velocity.y, -10.0f, 4.0f); + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; + if (this->dyna.actor.world.pos.y < this->dyna.actor.home.pos.y) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + this->unk_172 &= ~0x10; + this->unk_172 |= 2; + } + } + } + + if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (this->dyna.actor.xzDistToPlayer < 45.0f) { + if ((this->dyna.actor.playerHeightRel < -this->dyna.actor.velocity.y) && + (this->dyna.actor.playerHeightRel >= -800.0f)) { + sp28 = (45.0f - this->dyna.actor.xzDistToPlayer) * 0.5f; + player->actor.world.pos.x += sp28 * Math_SinS(this->dyna.actor.yawTowardsPlayer); + player->actor.world.pos.z += sp28 * Math_CosS(this->dyna.actor.yawTowardsPlayer); + } + } + } +} + +void ObjHunsui_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjHunsui* this = THIS; + + if (this->unk_172 & 0x10) { + f32 temp_f8 = (this->dyna.actor.world.pos.y - this->dyna.actor.home.pos.y) / 800.0f; + + func_8019FAD8(&this->dyna.actor.projectedPos, NA_SE_EV_WATER_PILLAR - SFX_FLAG, 1.0f + temp_f8); + } + + if (!(this->unk_172 & 2)) { + AnimatedMat_Draw(globalCtx, D_80B9DED0); + Gfx_DrawDListXlu(globalCtx, object_hunsui_DL_000220); + } +} + +void func_80B9DA60(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjHunsui* this = THIS; + f32 temp; + + if (this->unk_172 & 0x10) { + temp = 1.0f + ((this->unk_178 - 240.0f) / 270.0f); + func_8019FAD8(&this->dyna.actor.projectedPos, NA_SE_EV_WATER_PILLAR - SFX_FLAG, 1.0f + temp); + } + + if ((this->dyna.actor.flags & ACTOR_FLAG_40) && !(this->unk_172 & 2)) { + if ((this->unk_160 == OBJHUNSUI_F000_6) || (this->unk_160 == OBJHUNSUI_F000_5)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (globalCtx->gameplayFrames % 128) * -9, 0x20, + 0x20, 1, 0, (globalCtx->gameplayFrames % 128) * -8, 0x20, 0x20)); + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (s32)this->unk_1AC, 0x20, 0x20, 1, 0, + (s32)this->unk_1B0, 0x20, 0x20)); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + AnimatedMat_DrawXlu(globalCtx, D_80B9DED4); + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x7F, 255, 255, 255, 127); + + Gfx_DrawDListXlu(globalCtx, object_hunsui_DL_000EC0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h index c71a8a3d1..cbf1e4f13 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h @@ -2,18 +2,56 @@ #define Z_OBJ_HUNSUI_H #include "global.h" +#include "overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h" struct ObjHunsui; typedef void (*ObjHunsuiActionFunc)(struct ObjHunsui*, GlobalContext*); +#define OBJHUNSUI_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJHUNSUI_GET_F80(thisx) (((thisx)->params >> 7) & 0x1F) #define OBJHUNSUI_GET_F000(thisx) (((thisx)->params >> 0xC) & 0xF) +enum { + /* 0 */ OBJHUNSUI_F000_0, + /* 1 */ OBJHUNSUI_F000_1, + /* 2 */ OBJHUNSUI_F000_2, + /* 3 */ OBJHUNSUI_F000_3, + /* 4 */ OBJHUNSUI_F000_4, + /* 5 */ OBJHUNSUI_F000_5, + /* 6 */ OBJHUNSUI_F000_6, +}; + typedef struct ObjHunsui { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjHunsuiActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x58]; + /* 0x0160 */ s16 unk_160; + /* 0x0164 */ s32 unk_164; + /* 0x0168 */ s32 unk_168; + /* 0x016C */ s8 unk_16C; + /* 0x016D */ s8 unk_16D; + /* 0x016E */ s8 unk_16E; + /* 0x0170 */ s16 unk_170; + /* 0x0172 */ u16 unk_172; + /* 0x0174 */ f32 unk_174; + /* 0x0178 */ f32 unk_178; + /* 0x017C */ s16 unk_17C; + /* 0x0180 */ s32 unk_180; + /* 0x0184 */ s16 unk_184; + /* 0x0186 */ s16 unk_186; + /* 0x0188 */ s16 unk_188; + /* 0x018A */ s16 unk_18A; + /* 0x018C */ s16 unk_18C; + /* 0x0190 */ f32 unk_190; + /* 0x0194 */ f32 unk_194; + /* 0x0198 */ f32 unk_198; + /* 0x019C */ f32 unk_19C; + /* 0x01A0 */ f32 unk_1A0; + /* 0x01A4 */ s16 unk_1A4; + /* 0x0196 */ UNK_TYPE1 unk1A6[0x6]; + /* 0x01AC */ f32 unk_1AC; + /* 0x01B0 */ f32 unk_1B0; + /* 0x01B4 */ BgDblueMovebg* unk_1B4; } ObjHunsui; // size = 0x1B8 extern const ActorInit Obj_Hunsui_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 90419cbce..161c34f49 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2043,14 +2043,6 @@ D_06002FC4 = 0x06002FC4; D_06000080 = 0x06000080; D_06000110 = 0x06000110; -// ovl_Obj_Hunsui - -D_06000220 = 0x06000220; -D_06000BF0 = 0x06000BF0; -D_06000C74 = 0x06000C74; -D_06000EC0 = 0x06000EC0; -D_06001888 = 0x06001888; - // ovl_Obj_Jgame_Light D_060003A0 = 0x060003A0; From 6f4b349020705886ee09b80095a71b6b27d6a6a5 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Mon, 28 Feb 2022 02:44:29 +0000 Subject: [PATCH 053/257] En_Zob (#593) * En_Zob * Merge * Merge * Merge * PR * fixer --- spec | 3 +- src/overlays/actors/ovl_En_Zob/z_en_zob.c | 730 ++++++++++++++++++++-- src/overlays/actors/ovl_En_Zob/z_en_zob.h | 21 +- undefined_syms.txt | 5 - 4 files changed, 711 insertions(+), 48 deletions(-) diff --git a/spec b/spec index d9b75d9f9..87df24261 100644 --- a/spec +++ b/spec @@ -4458,8 +4458,7 @@ beginseg name "ovl_En_Zob" compress include "build/src/overlays/actors/ovl_En_Zob/z_en_zob.o" - include "build/data/ovl_En_Zob/ovl_En_Zob.data.o" - include "build/data/ovl_En_Zob/ovl_En_Zob.reloc.o" + include "build/src/overlays/actors/ovl_En_Zob/ovl_En_Zob_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.c b/src/overlays/actors/ovl_En_Zob/z_en_zob.c index f1d987f2b..4c03fd9cf 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.c +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.c @@ -5,6 +5,7 @@ */ #include "z_en_zob.h" +#include "objects/object_zob/object_zob.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -15,10 +16,13 @@ void EnZob_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnZob_Update(Actor* thisx, GlobalContext* globalCtx); void EnZob_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B9F7E4(EnZob* this, s16 arg1, u8 arg2); void func_80B9FD24(EnZob* this, GlobalContext* globalCtx); void func_80B9FDDC(EnZob* this, GlobalContext* globalCtx); void func_80B9FE1C(EnZob* this, GlobalContext* globalCtx); +void func_80B9FE5C(EnZob* this, GlobalContext* globalCtx); void func_80B9FF20(EnZob* this, GlobalContext* globalCtx); +void func_80B9FF80(EnZob* this, GlobalContext* globalCtx); void func_80BA005C(EnZob* this, GlobalContext* globalCtx); void func_80BA00BC(EnZob* this, GlobalContext* globalCtx); void func_80BA0318(EnZob* this, GlobalContext* globalCtx); @@ -33,7 +37,6 @@ void func_80BA0BB4(EnZob* this, GlobalContext* globalCtx); void func_80BA0C14(EnZob* this, GlobalContext* globalCtx); void func_80BA0CF4(EnZob* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Zob_InitVars = { ACTOR_EN_ZOB, ACTORCAT_NPC, @@ -46,79 +49,726 @@ const ActorInit En_Zob_InitVars = { (ActorFunc)EnZob_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BA10D0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +static AnimationHeader* sAnimations[] = { + &object_zob_Anim_0027D0, &object_zob_Anim_002B38, &object_zob_Anim_0037A0, + &object_zob_Anim_0043C4, &object_zob_Anim_005224, &object_zob_Anim_005E90, + &object_zob_Anim_006998, &object_zob_Anim_011144, &object_zob_Anim_001FD4, +}; -extern ColliderCylinderInit D_80BA10D0; +Vec3f D_80BA1120 = { 300.0f, 900.0f, 0.0f }; -extern UNK_TYPE D_06006998; +void EnZob_Init(Actor* thisx, GlobalContext* globalCtx) { + EnZob* this = THIS; + s32 i; + s16 cs; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/EnZob_Init.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->actor, 0.0115f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_zob_Skel_010810, &object_zob_Anim_006998, this->jointTable, + this->morphTable, 24); + Animation_PlayLoop(&this->skelAnime, &object_zob_Anim_006998); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->unk_2F4 = 0; + this->unk_30E = -1; + this->unk_310 = 0; + this->unk_302 = 9; + this->unk_304 = 0; + this->actor.terminalVelocity = -4.0f; + this->actor.gravity = -4.0f; + func_80B9F7E4(this, 6, 2); + this->actionFunc = func_80BA0728; + this->actor.textId = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/EnZob_Destroy.s") + cs = this->actor.cutscene; + for (i = 0; i < ARRAY_COUNT(this->unk_306); i++) { + this->unk_306[i] = cs; + if (cs != -1) { + this->actor.cutscene = cs; + cs = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9F7E4.s") + this->actor.cutscene = this->unk_306[0]; + this->actor.flags |= ACTOR_FLAG_2000000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9F86C.s") + switch (ENZOB_GET_F(&this->actor)) { + case ENZOB_F_1: + if (gSaveContext.weekEventReg[78] & 1) { + this->actionFunc = func_80BA0BB4; + } else { + this->actionFunc = func_80BA0AD8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FA3C.s") + if (!(gSaveContext.weekEventReg[55] & 0x80)) { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FC0C.s") + case ENZOB_F_2: + this->actionFunc = func_80BA0CF4; + this->unk_2F4 |= 0x20; + this->unk_312 = -1; + func_80B9F7E4(this, 0, 2); + this->unk_304 = 5; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FC70.s") + default: + if (gSaveContext.weekEventReg[55] & 0x80) { + Actor_MarkForDeath(&this->actor); + } + this->actor.flags |= ACTOR_FLAG_10; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FCA0.s") +void EnZob_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnZob* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FD24.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FDDC.s") +void func_80B9F7E4(EnZob* this, s16 arg1, u8 arg2) { + Animation_Change(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[arg1]), arg2, + -5.0f); + this->unk_302 = arg1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FE1C.s") +void func_80B9F86C(EnZob* this) { + if (SkelAnime_Update(&this->skelAnime)) { + switch (this->unk_304) { + case 0: + if (Rand_ZeroFloat(1.0f) > 0.7f) { + if (this->unk_302 == 6) { + func_80B9F7E4(this, 7, 2); + } else { + func_80B9F7E4(this, 6, 2); + } + } else { + func_80B9F7E4(this, this->unk_302, 2); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FE5C.s") + case 1: + func_80B9F7E4(this, 3, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FF20.s") + case 2: + func_80B9F7E4(this, 4, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FF80.s") + case 3: + func_80B9F7E4(this, 5, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA005C.s") + case 4: + if (this->unk_302 == 3) { + func_80B9F7E4(this, 0, 0); + } else { + func_80B9F7E4(this, 3, 2); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA00BC.s") + case 5: + if (Rand_ZeroFloat(1.0f) < 0.8f) { + func_80B9F7E4(this, this->unk_302, 2); + } else if (this->unk_302 == 0) { + func_80B9F7E4(this, 1, 2); + } else { + func_80B9F7E4(this, 0, 2); + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0318.s") + SkelAnime_Update(&this->skelAnime); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0374.s") +void func_80B9FA3C(EnZob* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0610.s") + this->unk_2F4 |= 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA06BC.s") + if (gSaveContext.playerForm != PLAYER_FORM_ZORA) { + if (gSaveContext.weekEventReg[30] & 2) { + textId = 0x11F9; + } else { + textId = 0x11F8; + } + this->unk_304 = 3; + func_80B9F7E4(this, 5, 0); + } else if (this->unk_2F4 & 0x10) { + textId = 0x1210; + this->unk_304 = 3; + func_80B9F7E4(this, 5, 2); + } else if (gSaveContext.weekEventReg[31] & 8) { + textId = 0x1205; + this->unk_304 = 1; + func_80B9F7E4(this, 3, 0); + } else if (this->unk_2F4 & 8) { + textId = 0x1215; + this->unk_304 = 3; + func_80B9F7E4(this, 5, 2); + } else if (this->unk_2F4 & 2) { + textId = 0x1203; + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + } else if (gSaveContext.weekEventReg[30] & 8) { + textId = 0x11FA; + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + } else if (!(gSaveContext.weekEventReg[30] & 4)) { + gSaveContext.weekEventReg[30] |= 4; + textId = 0x11FB; + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + } else { + textId = 0x1201; + this->unk_304 = 3; + func_80B9F7E4(this, 4, 2); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0728.s") + func_801518B0(globalCtx, textId, &this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA08E8.s") +void func_80B9FC0C(EnZob* this) { + if (this->unk_30E != -1) { + if (ActorCutscene_GetCurrentIndex() == this->unk_306[this->unk_30E]) { + ActorCutscene_Stop(this->unk_306[this->unk_30E]); + } + this->unk_30E = -1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA09E0.s") +void func_80B9FC70(EnZob* this, s16 arg1) { + func_80B9FC0C(this); + this->unk_30E = arg1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0A04.s") +void func_80B9FCA0(EnZob* this, GlobalContext* globalCtx) { + func_801477B4(globalCtx); + globalCtx->msgCtx.ocarinaMode = 4; + func_80B9FC0C(this); + this->unk_2F4 &= ~1; + this->actionFunc = func_80BA0728; + this->unk_304 = 0; + func_80B9F7E4(this, 6, 2); + func_800B8718(&this->actor, &globalCtx->state); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0AD8.s") +void func_80B9FD24(EnZob* this, GlobalContext* globalCtx) { + u32 temp_v0; + s16 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0BB4.s") + func_80B9F86C(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0C14.s") + if (func_800EE29C(globalCtx, 500)) { + this->unk_30E = -1; + temp_v0 = func_800EE200(globalCtx, 500); + temp = globalCtx->csCtx.npcActions[temp_v0]->unk0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0CF4.s") + if (temp != this->unk_310) { + this->unk_310 = temp; + switch (temp) { + case 1: + func_80B9F7E4(this, 8, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/EnZob_Update.s") + case 2: + func_80B9F7E4(this, 7, 0); + break; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0F64.s") +void func_80B9FDDC(EnZob* this, GlobalContext* globalCtx) { + func_801518B0(globalCtx, 0x120C, &this->actor); + this->actionFunc = func_80BA00BC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0FAC.s") +void func_80B9FE1C(EnZob* this, GlobalContext* globalCtx) { + func_801518B0(globalCtx, 0x1211, &this->actor); + this->actionFunc = func_80BA00BC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/EnZob_Draw.s") +void func_80B9FE5C(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (globalCtx->msgCtx.ocarinaMode == 3) { + globalCtx->msgCtx.unk11F10 = 0; + this->actionFunc = func_80B9FDDC; + func_80B9FC70(this, 0); + } else if (Message_GetState(&globalCtx->msgCtx) == 11) { + globalCtx->msgCtx.unk11F10 = 0; + this->actionFunc = func_80B9FE1C; + this->unk_304 = 3; + func_80B9F7E4(this, 5, 2); + func_80B9FC70(this, 0); + } +} + +void func_80B9FF20(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (Message_GetState(&globalCtx->msgCtx) == 7) { + func_80152434(globalCtx, 0x42); + this->actionFunc = func_80B9FE5C; + func_80B9FC70(this, 2); + } +} + +void func_80B9FF80(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (globalCtx->msgCtx.ocarinaMode == 3) { + this->actionFunc = func_80B9FF20; + this->unk_304 = 6; + func_80B9F7E4(this, 1, 0); + func_80152434(globalCtx, 0x3E); + func_80B9FC70(this, 1); + } else if (Message_GetState(&globalCtx->msgCtx) == 11) { + globalCtx->msgCtx.unk11F10 = 0; + this->actionFunc = func_80B9FE1C; + this->unk_304 = 3; + func_80B9F7E4(this, 5, 2); + func_80B9FC70(this, 0); + } +} + +void func_80BA005C(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (Message_GetState(&globalCtx->msgCtx) == 7) { + func_80152434(globalCtx, 0x41); + this->actionFunc = func_80B9FF80; + func_80B9FC70(this, 2); + } +} + +void func_80BA00BC(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 4: + if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1212)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 1: + func_8019F208(); + func_80151938(globalCtx, 0x1209); + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + break; + + case 0: + func_8019F230(); + func_80151938(globalCtx, 0x1213); + break; + } + } + break; + + case 5: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x1208: + case 0x120E: + case 0x1216: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x120C: + globalCtx->msgCtx.unk11F10 = 0; + this->actionFunc = func_80B9FD24; + func_80B9F7E4(this, 8, 0); + func_80B9FC70(this, 3); + break; + + case 0x120D: + case 0x1211: + case 0x1213: + case 0x1217: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + this->unk_304 = 3; + func_80B9F7E4(this, 4, 2); + break; + + case 0x1218: + func_80B9FCA0(this, globalCtx); + break; + + case 0x1214: + this->unk_2F4 |= 8; + func_80B9FCA0(this, globalCtx); + break; + + case 0x120F: + gSaveContext.weekEventReg[31] |= 8; + this->unk_2F4 |= 0x10; + func_80B9FCA0(this, globalCtx); + break; + + case 0x1209: + func_80152434(globalCtx, 0x3D); + this->unk_304 = 4; + func_80B9F7E4(this, 0, 0); + this->actionFunc = func_80BA005C; + func_80B9FC70(this, 1); + break; + } + } + break; + } +} + +void func_80BA0318(EnZob* this, GlobalContext* globalCtx) { + func_80152434(globalCtx, 0x3D); + this->unk_304 = 4; + func_80B9F7E4(this, 0, 0); + this->actionFunc = func_80BA005C; + func_80B9FC70(this, 1); +} + +void func_80BA0374(EnZob* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + func_80B9F86C(this); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 4: + if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1205)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + func_80151938(globalCtx, 0x1207); + func_80B9F7E4(this, 2, 2); + break; + + case 1: + func_8019F230(); + func_80151938(globalCtx, 0x1206); + break; + } + } + break; + + case 5: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x11F8: + gSaveContext.weekEventReg[30] |= 2; + func_80151938(globalCtx, 0x11F9); + break; + + case 0x11F9: + func_801477B4(globalCtx); + this->actionFunc = func_80BA0728; + this->unk_304 = 0; + func_80B9F7E4(this, 6, 2); + this->unk_2F4 &= ~1; + break; + + case 0x11FB: + case 0x11FC: + case 0x11FF: + case 0x1201: + case 0x1203: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x11FD: + this->unk_304 = 3; + func_80B9F7E4(this, 4, 2); + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x11FE: + this->unk_304 = 1; + func_80B9F7E4(this, 3, 0); + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x11FA: + case 0x1200: + case 0x1202: + case 0x1204: + case 0x1206: + case 0x120F: + case 0x1210: + case 0x1215: + func_801477B4(globalCtx); + this->actionFunc = func_80BA0728; + this->unk_304 = 0; + func_80B9F7E4(this, 6, 2); + this->unk_2F4 &= ~1; + this->unk_2F4 |= 2; + break; + + case 0x1207: + func_801477B4(globalCtx); + this->actionFunc = func_80BA0318; + player->unk_A90 = &this->actor; + player->stateFlags3 |= 0x20; + break; + } + } + break; + } +} + +void func_80BA0610(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + func_801518B0(globalCtx, 0x120D, &this->actor); + this->unk_304 = 3; + func_80B9F7E4(this, 5, 2); + func_80B9FC70(this, 0); + this->actionFunc = func_80BA00BC; + } else { + func_800B8614(&this->actor, globalCtx, 500.0f); + } +} + +void func_80BA06BC(EnZob* this, GlobalContext* globalCtx) { + func_80B9FD24(this, globalCtx); + if (!func_800EE29C(globalCtx, 500)) { + this->actionFunc = func_80BA0610; + this->actor.flags |= ACTOR_FLAG_10000; + func_80BA0610(this, globalCtx); + } +} + +void func_80BA0728(EnZob* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp28; + + func_80B9F86C(this); + + if (func_800B8718(&this->actor, &globalCtx->state)) { + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + func_801518B0(globalCtx, 0x1208, NULL); + gSaveContext.weekEventReg[30] |= 8; + } else { + func_801518B0(globalCtx, 0x1216, NULL); + } + this->actionFunc = func_80BA00BC; + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + this->unk_30E = 0; + this->unk_2F4 |= 1; + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80BA0374; + func_80B9FA3C(this, globalCtx); + } else if (func_800EE29C(globalCtx, 500)) { + this->actionFunc = func_80BA06BC; + } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.xzDistToPlayer > 60.0f) && + Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x3000)) { + func_800B8614(&this->actor, globalCtx, 150.0f); + func_800B874C(&this->actor, globalCtx, 200.0f, 150.0f); + } + + sp28.x = this->actor.projectedPos.x; + sp28.y = this->actor.projectedPos.y; + sp28.z = this->actor.projectedPos.z; + func_801A1FB4(3, &sp28, 0x6C, 1000.0f); +} + +void func_80BA08E8(EnZob* this, GlobalContext* globalCtx) { + s32 textId; + + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.weekEventReg[79] & 1) { + textId = 0x1257; + this->unk_304 = 3; + func_80B9F7E4(this, 4, 2); + } else if (gSaveContext.weekEventReg[78] & 0x40) { + textId = 0x1256; + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + } else { + textId = 0x1255; + gSaveContext.weekEventReg[78] |= 0x40; + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + } + } else { + textId = 0x1254; + this->unk_304 = 3; + func_80B9F7E4(this, 5, 2); + } + + func_801518B0(globalCtx, textId, &this->actor); +} + +void func_80BA09E0(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); +} + +void func_80BA0A04(EnZob* this, GlobalContext* globalCtx) { + u8 temp_v0; + + func_80B9F86C(this); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); + this->actor.world.rot.y = this->actor.shape.rot.y; + + temp_v0 = Message_GetState(&globalCtx->msgCtx); + if (temp_v0 != 2) { + if ((temp_v0 == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = func_80BA0AD8; + this->unk_304 = 0; + func_80B9F7E4(this, 6, 2); + } + } else { + this->actionFunc = func_80BA0AD8; + this->unk_304 = 0; + func_80B9F7E4(this, 6, 2); + } +} + +void func_80BA0AD8(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + + if (this->actor.home.rot.y != this->actor.shape.rot.y) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x1000, 0x200); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80BA0A04; + func_80BA08E8(this, globalCtx); + } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsFacingPlayer(&this->actor, 0x3000)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void func_80BA0BB4(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (gSaveContext.weekEventReg[79] & 1) { + this->actionFunc = func_80BA09E0; + func_80B9F7E4(this, 0, 2); + this->unk_304 = 5; + } +} + +void func_80BA0C14(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + + if (this->unk_312 < 799) { + this->unk_312 += 200; + } else { + this->unk_312 += 30; + } + + if (this->unk_312 > 999) { + this->unk_312 = 999; + } + + if (func_800EE29C(globalCtx, 0x203)) { + if (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x203)]->unk0 == 1) { + this->actionFunc = func_80BA0CF4; + this->unk_312 = -1; + } + } else { + this->actionFunc = func_80BA0CF4; + this->unk_312 = -1; + } +} + +void func_80BA0CF4(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (func_800EE29C(globalCtx, 0x203) && (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x203)]->unk0 == 2)) { + this->actionFunc = func_80BA0C14; + } +} + +void EnZob_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZob* this = THIS; + + Actor_MoveWithGravity(&this->actor); + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 4); + + this->actionFunc(this, globalCtx); + + if ((this->unk_30E != -1) && (ActorCutscene_GetCurrentIndex() != this->unk_306[this->unk_30E])) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_306[this->unk_30E]); + } else if (ActorCutscene_GetCanPlayNext(this->unk_306[this->unk_30E])) { + ActorCutscene_Start(this->unk_306[this->unk_30E], &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->unk_306[this->unk_30E]); + } + } + + if (this->unk_2F4 & 1) { + func_800E9250(globalCtx, &this->actor, &this->unk_2F6, &this->unk_2FC, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_2F6.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2F6.y, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2FC.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2FC.y, 0, 6, 6200, 100); + } +} + +s32 func_80BA0F64(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnZob* this = THIS; + + if (limbIndex == 9) { + rot->x += this->unk_2F6.y; + rot->y += this->unk_2F6.x; + } + return false; +} + +void func_80BA0FAC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnZob* this = THIS; + + if (limbIndex == 9) { + Matrix_MultiplyVector3fByState(&D_80BA1120, &this->actor.focus.pos); + } +} + +void EnZob_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnZob* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_2F4 & 0x20) { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 0, 0, 0, 0, this->unk_312, 1000); + } + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80BA0F64, func_80BA0FAC, &this->actor); + + if (this->unk_2F4 & 0x20) { + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.h b/src/overlays/actors/ovl_En_Zob/z_en_zob.h index 233842303..18834f17e 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.h +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.h @@ -7,9 +7,28 @@ struct EnZob; typedef void (*EnZobActionFunc)(struct EnZob*, GlobalContext*); +#define ENZOB_GET_F(thisx) ((thisx)->params & 0xF) + +enum { + /* 1 */ ENZOB_F_1 = 1, + /* 2 */ ENZOB_F_2, +}; + typedef struct EnZob { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1D0]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[24]; + /* 0x0218 */ Vec3s morphTable[24]; + /* 0x02A8 */ ColliderCylinder collider; + /* 0x02F4 */ u16 unk_2F4; + /* 0x02F6 */ Vec3s unk_2F6; + /* 0x02FC */ Vec3s unk_2FC; + /* 0x0302 */ s16 unk_302; + /* 0x0304 */ u16 unk_304; + /* 0x0306 */ s16 unk_306[4]; + /* 0x030E */ s16 unk_30E; + /* 0x0310 */ s16 unk_310; + /* 0x0312 */ s16 unk_312; /* 0x0314 */ EnZobActionFunc actionFunc; } EnZob; // size = 0x318 diff --git a/undefined_syms.txt b/undefined_syms.txt index 161c34f49..6902e8091 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1964,11 +1964,6 @@ D_06000700 = 0x06000700; D_06013328 = 0x06013328; -// ovl_En_Zob - -D_06006998 = 0x06006998; -D_06010810 = 0x06010810; - // ovl_En_Zod D_06000D94 = 0x06000D94; From e127ee650a88ad128a83e564e975eb63badc0873 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Mon, 28 Feb 2022 02:52:39 +0000 Subject: [PATCH 054/257] En_Pr2 (#587) * En_Pr2 * Cringe * Merge * PR * Revert EnEncount1 * PR --- spec | 3 +- .../actors/ovl_En_Encount1/z_en_encount1.h | 6 +- src/overlays/actors/ovl_En_Pr2/z_en_pr2.c | 704 +++++++++++++++++- src/overlays/actors/ovl_En_Pr2/z_en_pr2.h | 41 +- undefined_syms.txt | 6 - 5 files changed, 718 insertions(+), 42 deletions(-) diff --git a/spec b/spec index 87df24261..5728d9ddd 100644 --- a/spec +++ b/spec @@ -3122,8 +3122,7 @@ beginseg name "ovl_En_Pr2" compress include "build/src/overlays/actors/ovl_En_Pr2/z_en_pr2.o" - include "build/data/ovl_En_Pr2/ovl_En_Pr2.data.o" - include "build/data/ovl_En_Pr2/ovl_En_Pr2.reloc.o" + include "build/src/overlays/actors/ovl_En_Pr2/ovl_En_Pr2_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h index 72638d9a6..3cf01bd8a 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h @@ -10,7 +10,11 @@ typedef void (*EnEncount1ActionFunc)(struct EnEncount1*, GlobalContext*); typedef struct EnEncount1 { /* 0x0000 */ Actor actor; /* 0x0144 */ EnEncount1ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x1C]; + /* 0x0148 */ char unk_148[0x6]; + /* 0x014E */ s16 unk_14E; + /* 0x0150 */ char unk_150[0xA]; + /* 0x015A */ s16 unk_15A; + /* 0x015C */ char unk_15C[0x8]; } EnEncount1; // size = 0x164 extern const ActorInit En_Encount1_InitVars; 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 045d7cc3e..6fa76d817 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c @@ -5,6 +5,8 @@ */ #include "z_en_pr2.h" +#include "objects/object_pr/object_pr.h" +#include "overlays/actors/ovl_En_Encount1/z_en_encount1.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) @@ -15,9 +17,16 @@ void EnPr2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnPr2_Update(Actor* thisx, GlobalContext* globalCtx); void EnPr2_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 -// static DamageTable sDamageTable = { -static DamageTable D_80A75BC0 = { +void func_80A745C4(EnPr2* this); +void func_80A745FC(EnPr2* this, GlobalContext* globalCtx); +void func_80A74888(EnPr2* this); +void func_80A748E8(EnPr2* this, GlobalContext* globalCtx); +void func_80A74DEC(EnPr2* this, GlobalContext* globalCtx); +void func_80A74E90(EnPr2* this, GlobalContext* globalCtx); +void func_80A751B4(EnPr2* this); +void func_80A75310(EnPr2* this, GlobalContext* globalCtx); + +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -52,10 +61,23 @@ static DamageTable D_80A75BC0 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A75BE0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x08, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_1, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x08, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 17, 32, -10, { 0, 0, 0 } }, }; @@ -71,48 +93,668 @@ const ActorInit En_Pr2_InitVars = { (ActorFunc)EnPr2_Draw, }; -#endif +static AnimationHeader* sAnimations[] = { + &object_pr_Anim_004340, + &object_pr_Anim_004274, + &object_pr_Anim_003904, +}; -extern DamageTable D_80A75BC0; -extern ColliderCylinderInit D_80A75BE0; +u8 D_80A75C38[] = { 0, 0, 2, 0 }; -extern UNK_TYPE D_06003904; -extern UNK_TYPE D_06004340; +s16 D_80A75C3C[] = { + 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/EnPr2_Init.s") +void EnPr2_Init(Actor* thisx, GlobalContext* globalCtx) { + EnPr2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/EnPr2_Destroy.s") + this->actor.targetMode = 3; + this->actor.hintId = 0x5B; + this->unk_1EC = 255; + this->actor.colChkInfo.health = 1; + this->actor.colChkInfo.damageTable = &sDamageTable; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A7429C.s") + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_pr_Skel_004188, &object_pr_Anim_004340, this->jointTable, + 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); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A7436C.s") + if (this->unk_1E0 == 2) { + this->unk_208 = ENPR2_GET_FF0(&this->actor) * 20.0f; + } + this->unk_1F4 = 255; + this->actor.shape.yOffset = 500.0f; + this->actor.shape.shadowScale = 12.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A74510.s") + if (this->unk_1E0 < 10) { + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->unk_218 = -1; + this->unk_204 = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A745C4.s") + if (this->actor.parent != NULL) { + Actor* parent = this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A745FC.s") + if (parent->update != NULL) { + if (parent->world.rot.y != 0) { + this->unk_218 = parent->world.rot.y - 1; + } + } + } else if (this->actor.world.rot.z != 0) { + this->unk_218 = this->actor.world.rot.z - 1; + this->actor.world.rot.z = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A74888.s") + if (this->unk_1E0 == 3) { + if (this->actor.parent != NULL) { + Actor* parent = this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A748E8.s") + if (parent->update != NULL) { + this->unk_1C8 = ((EnEncount1*)parent)->unk_15A; + this->path = func_8013D648(globalCtx, this->unk_1C8, 0x3F); + this->unk_208 = parent->world.rot.z * 20.0f; + if (this->unk_208 < 20.0f) { + this->unk_208 = 20.0f; + } + } + func_80A745C4(this); + } else { + Actor_MarkForDeath(&this->actor); + return; + } + } else { + func_80A74888(this); + } + } else { + this->unk_204 = 0.02f; + func_80A751B4(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A74DEC.s") + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 20.0f, 20.0f, 0x1D); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A74E90.s") + if (!(this->actor.bgCheckFlags & 0x60)) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A751B4.s") +void EnPr2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnPr2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A75310.s") + if (this->unk_1E0 < 10) { + Collider_DestroyCylinder(globalCtx, &this->collider); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A755D8.s") + if (this->actor.parent != NULL) { + Actor* parent = this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/EnPr2_Update.s") + if ((parent->update != NULL) && (((EnEncount1*)parent)->unk_14E > 0)) { + ((EnEncount1*)parent)->unk_14E--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A758E8.s") +s32 func_80A7429C(EnPr2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp1A; + s16 sp18; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A75950.s") + Actor_GetScreenPos(globalCtx, &this->actor, &sp1A, &sp18); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A759D8.s") + if ((fabsf(player->actor.world.pos.y - this->actor.world.pos.y) > 160.0f) || + (this->actor.projectedPos.z < -40.0f) || (sp1A < 0) || (sp1A > 320) || (sp18 < 0) || (sp18 > 240)) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/EnPr2_Draw.s") + if (!(player->stateFlags1 & 0x8000000)) { + return false; + } else { + return true; + } +} + +void func_80A7436C(EnPr2* this, s16 arg1) { + s16 sp2E = arg1 - this->actor.world.rot.y; + + if (sp2E > 10000) { + sp2E = 10000; + } else if (sp2E < -10000) { + sp2E = -10000; + } + + Math_ApproachF(&this->actor.world.pos.y, this->unk_21C.y, 0.3f, 5.0f); + + if (fabsf(this->actor.world.pos.y - this->unk_21C.y) > 10.0f) { + Math_SmoothStepToS(&this->actor.world.rot.x, Math_Vec3f_Pitch(&this->actor.world.pos, &this->unk_21C) * 0.3f, + 20, 5000, 500); + } else { + Math_SmoothStepToS(&this->actor.world.rot.x, 0, 20, 5000, 500); + } + + if (fabsf(this->actor.world.rot.y - arg1) < 30.0f) { + Math_ApproachZeroF(&this->unk_1FC, 0.5f, 20.0f); + } else { + Math_ApproachF(&this->unk_1FC, sp2E, 0.5f, 3000.0f); + } + + Math_SmoothStepToS(&this->actor.world.rot.y, arg1, 1, 2000, 300); +} + +void func_80A74510(EnPr2* this, s32 arg0) { + f32 sp34 = 1.0f; + + this->unk_210 = arg0; + this->unk_1F8 = Animation_GetLastFrame(sAnimations[arg0]); + if (this->unk_210 == 3) { + sp34 = 0.0f; + } + Animation_Change(&this->skelAnime, sAnimations[arg0], sp34, 0.0f, this->unk_1F8, D_80A75C38[arg0], 0.0f); +} + +void func_80A745C4(EnPr2* this) { + func_80A74510(this, 0); + this->unk_1D4 = 0; + this->actionFunc = func_80A745FC; +} + +void func_80A745FC(EnPr2* this, GlobalContext* globalCtx) { + f32 x; + f32 y; + f32 z; + f32 sqrtXYZ; + + if (fabsf(this->actor.world.rot.y - this->unk_1EE) < 200.0f) { + SkelAnime_Update(&this->skelAnime); + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIRANHA_EXIST - SFX_FLAG); + Math_ApproachF(&this->unk_204, 0.02f, 0.1f, 0.005f); + + if (this->path->unk2 < this->unk_1D0) { + Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.3f, 1.0f); + } else { + Math_ApproachF(&this->actor.speedXZ, 10.0f, 0.3f, 1.0f); + } + + if ((this->path != NULL) && !func_8013D68C(this->path, this->unk_1D0, &this->unk_21C)) { + Actor_MarkForDeath(&this->actor); + } + + Math_ApproachF(&this->actor.world.pos.y, this->unk_21C.y, 0.3f, 5.0f); + + if (fabsf(this->actor.world.pos.y - this->unk_21C.y) > 10.0f) { + Math_SmoothStepToS(&this->actor.world.rot.x, Math_Vec3f_Pitch(&this->actor.world.pos, &this->unk_21C) * 0.3f, + 20, 5000, 500); + } else { + Math_SmoothStepToS(&this->actor.world.rot.x, 0, 20, 5000, 500); + } + + x = this->actor.world.pos.x - this->unk_21C.x; + y = this->actor.world.pos.y - this->unk_21C.y; + z = this->actor.world.pos.z - this->unk_21C.z; + sqrtXYZ = sqrtf(SQ(x) + SQ(y) + SQ(z)); + + if (sqrtXYZ < (Rand_ZeroFloat(20.0f) + 15.0f)) { + this->unk_1D0++; + Math_Vec3f_Copy(&this->unk_228, &this->actor.world.pos); + if (this->unk_1D0 >= this->path->count) { + this->unk_1E0 = 2; + func_80A74888(this); + } + } + + this->unk_1EE = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_21C); + func_80A7436C(this, this->unk_1EE); +} + +void func_80A74888(EnPr2* this) { + func_80A74510(this, 0); + this->unk_1DA = 2; + this->unk_1D8 = 0; + Math_Vec3f_Copy(&this->unk_21C, &this->unk_228); + this->unk_1D4 = 1; + this->actionFunc = func_80A748E8; +} + +void func_80A748E8(EnPr2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp_f12; + f32 temp_f2; + f32 sqrtXZ; + s32 sp4C = false; + s32 sp48 = false; + Vec3f sp3C; + + Math_ApproachF(&this->unk_204, 0.02f, 0.1f, 0.005f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIRANHA_EXIST - SFX_FLAG); + + if (fabsf(this->actor.world.rot.y - this->unk_1EE) < 200.0f) { + sp48 = true; + SkelAnime_Update(&this->skelAnime); + } + + if (this->unk_1F4 != 255) { + this->actor.speedXZ = 0.0f; + Math_SmoothStepToS(&this->unk_1F4, 0, 1, 30, 100); + if (this->unk_1F4 < 2) { + Actor_MarkForDeath(&this->actor); + } + } else { + switch (this->unk_1E0) { + case 1: + if (this->unk_1DC == 0) { + sp4C = true; + func_80A74DEC(this, globalCtx); + } else if (!func_80A7429C(this, globalCtx) && (this->unk_1F4 == 255)) { + this->unk_1F4 = 254; + } + break; + + case 2: + if (this->unk_1DE == 0) { + temp_f2 = player->actor.world.pos.x - this->unk_228.x; + temp_f12 = player->actor.world.pos.z - this->unk_228.z; + sqrtXZ = sqrtf(SQ(temp_f2) + SQ(temp_f12)); + + if (sp48 && (player->stateFlags1 & 0x8000000) && (sqrtXZ < this->unk_208)) { + sp4C = true; + func_80A74DEC(this, globalCtx); + } + } else { + temp_f2 = this->actor.world.pos.x - this->unk_228.x; + temp_f12 = this->actor.world.pos.z - this->unk_228.z; + sqrtXZ = sqrtf(SQ(temp_f2) + SQ(temp_f12)); + + if (sqrtXZ > 20.0f) { + this->unk_1DE = 5; + sp4C = true; + this->unk_1DC = 0; + Math_Vec3f_Copy(&this->unk_21C, &this->unk_228); + Math_ApproachF(&this->actor.speedXZ, 3.0f, 0.3f, 0.2f); + } + } + break; + } + + if (!sp4C) { + this->unk_21C.y = this->actor.world.pos.y; + if (this->unk_1DA != 0) { + if ((Rand_ZeroOne() < 0.3f) && !this->unk_1D6) { + this->unk_1D6 = true; + } + + Math_ApproachZeroF(&this->actor.speedXZ, 0.1f, 0.2f); + + if (this->unk_1DA == 1) { + this->unk_1D8 = Rand_S16Offset(100, 100); + Math_Vec3f_Copy(&sp3C, &this->unk_228); + sp3C.x += randPlusMinusPoint5Scaled(300.0f); + sp3C.z += randPlusMinusPoint5Scaled(300.0f); + Math_Vec3f_Copy(&this->unk_21C, &sp3C); + } + } else { + Math_ApproachF(&this->actor.speedXZ, 2.0f, 0.3f, 0.2f); + Math_Vec3f_Copy(&sp3C, &this->actor.world.pos); + sp3C.x += Math_SinS(this->actor.world.rot.y) * 20.0f; + sp3C.z += Math_CosS(this->actor.world.rot.y) * 20.0f; + if (fabsf(this->actor.world.rot.y - this->unk_1EE) < 100.0f) { + if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &sp3C, 20.0f) || (this->actor.bgCheckFlags & 8)) { + this->unk_1DC = 0; + this->unk_1F2++; + Math_Vec3f_Copy(&this->unk_21C, &this->unk_228); + if (this->unk_1F2 > 10) { + this->unk_1F0 += 0x2000; + } + } else { + Math_SmoothStepToS(&this->unk_1F0, 0, 1, 1000, 100); + this->unk_1F2 = 0; + } + } + + if ((this->unk_1D8 == 0) || ((fabsf(this->unk_21C.x - this->actor.world.pos.x) < 10.0f) && + (fabsf(this->unk_21C.z - this->actor.world.pos.z) < 10.0f))) { + this->unk_1DA = Rand_S16Offset(20, 30); + } + } + } + + if (this->unk_1DA == 0) { + this->unk_1EE = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_21C) + this->unk_1F0; + func_80A7436C(this, this->unk_1EE); + } + } +} + +void func_80A74DEC(EnPr2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_1F0 = 0; + func_80A74510(this, 1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIRANHA_ATTACK); + Math_Vec3f_Copy(&this->unk_21C, &player->actor.world.pos); + + this->unk_1EE = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_21C); + this->unk_20C = Rand_ZeroFloat(30.0f); + this->unk_1DC = 0; + this->unk_1D8 = 70; + this->unk_1D4 = 2; + this->actionFunc = func_80A74E90; +} + +void func_80A74E90(EnPr2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + WaterBox* sp40; + + Math_ApproachF(&this->unk_204, 0.02f, 0.1f, 0.005f); + if ((this->unk_1D8 == 0) || !(player->stateFlags1 & 0x8000000) || (this->unk_1E0 == 0)) { + func_80A74888(this); + return; + } + + if (this->unk_1F4 != 255) { + this->actor.speedXZ = 0.0f; + Math_SmoothStepToS(&this->unk_1F4, 0, 1, 30, 100); + if (this->unk_1F4 < 2) { + Actor_MarkForDeath(&this->actor); + } + } else { + SkelAnime_Update(&this->skelAnime); + + if ((this->unk_1DC == 0) && (fabsf(this->actor.world.rot.y - this->unk_1EE) < 200.0f)) { + Math_Vec3f_Copy(&this->unk_21C, &player->actor.world.pos); + } + + if ((Rand_ZeroOne() < 0.3f) && !this->unk_1D6) { + this->unk_1D6 = true; + this->unk_20C = Rand_ZeroFloat(30.0f); + } + + this->unk_21C.y = player->actor.world.pos.y + 30.0f + this->unk_20C; + Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.3f, 1.0f); + this->unk_1F0 = 0; + + if (this->unk_1E0 == 2) { + f32 temp_f2 = this->actor.world.pos.x - this->unk_228.x; + f32 temp_f12 = this->actor.world.pos.z - this->unk_228.z; + f32 sqrtXZ = sqrtf(SQ(temp_f2) + SQ(temp_f12)); + + if (this->unk_208 < sqrtXZ) { + this->unk_1DE = 20; + func_80A74888(this); + return; + } + } else { + Math_Vec3f_Copy(&this->unk_228, &this->actor.world.pos); + } + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_200, &sp40)) { + if ((this->unk_200 - 40.0f) < this->unk_21C.y) { + this->unk_21C.y = this->unk_200 - 40.0f; + } + } + + if ((this->unk_1E0 == 1) && !func_80A7429C(this, globalCtx)) { + if (this->unk_1F4 == 255) { + this->unk_1F4 = 254; + } + } else { + if (this->collider.base.atFlags & AT_HIT) { + this->unk_1DC = Rand_S16Offset(30, 30); + this->unk_1D8 = 100; + if (this->unk_1E0 != 2) { + func_80A74888(this); + } + } + this->unk_1EE = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_21C); + func_80A7436C(this, this->unk_1EE); + } + } +} + +void func_80A751B4(EnPr2* this) { + this->unk_1EC = 0; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; + if (this->unk_1E0 < 10) { + func_80A74510(this, 2); + } else { + this->unk_1F8 = Animation_GetLastFrame(&object_pr_Anim_003904); + Animation_Change(&this->skelAnime, &object_pr_Anim_003904, 1.0f, this->unk_1F8, this->unk_1F8, 2, 0.0f); + this->unk_1D8 = Rand_S16Offset(20, 30); + this->unk_1E4 = 0x4000; + if (Rand_ZeroOne() < 0.5f) { + this->unk_1E4 = -0x4000; + } + this->unk_1E6 = this->actor.world.rot.y; + this->actor.shape.rot.x = this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + this->unk_1D8 = 30; + this->actor.speedXZ = Rand_ZeroFloat(0.5f); + this->actor.world.rot.y = randPlusMinusPoint5Scaled(0x8000); + } + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 10); + this->unk_1D4 = 3; + this->actionFunc = func_80A75310; +} + +void func_80A75310(EnPr2* this, GlobalContext* globalCtx) { + s32 temp; + f32 frame; + WaterBox* sp74; + + SkelAnime_Update(&this->skelAnime); + if (this->unk_1E0 < 10) { + s32 i; + + frame = this->skelAnime.curFrame; + + if (this->unk_1F8 <= frame) { + for (i = 0; i < ARRAY_COUNT(this->unk_234); i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PR2, this->unk_234[i].x, this->unk_234[i].y, + this->unk_234[i].z, this->actor.world.rot.x, this->actor.world.rot.y, + this->actor.world.rot.z, i + 10); + } + + Actor_MarkForDeath(&this->actor); + return; + } + } else { + Vec3f sp64; + + temp = false; + Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 5, 10000, 1000); + Math_SmoothStepToS(&this->actor.shape.rot.z, this->unk_1E4, 5, 10000, 1000); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_1E6, 5, 10000, 1000); + + if ((Rand_ZeroOne() < 0.3f) && !this->unk_1D6) { + this->unk_1D6 = true; + } + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_200, &sp74)) { + frame = this->unk_200 - 15.0f; + + if (frame <= this->actor.world.pos.y) { + temp = true; + } else { + Math_ApproachF(&this->actor.world.pos.y, frame, 0.3f, 1.0f); + } + } + + if ((this->unk_1D8 == 0) || temp) { + s32 i; + + Math_SmoothStepToS(&this->unk_1F4, 0, 1, 15, 50); + + if (this->unk_1F4 < 2) { + for (i = 0; i < 10; i++) { + Math_Vec3f_Copy(&sp64, &this->actor.world.pos); + + sp64.x += randPlusMinusPoint5Scaled(20.0f); + sp64.y += randPlusMinusPoint5Scaled(5.0f); + sp64.z += randPlusMinusPoint5Scaled(20.0f); + frame = Rand_ZeroFloat(0.03f) + 0.07f; + + EffectSsBubble_Spawn(globalCtx, &sp64, 0.0f, 5.0f, 5.0f, frame); + } + + Actor_MarkForDeath(&this->actor); + } + } + } +} + +void func_80A755D8(EnPr2* this, GlobalContext* globalCtx) { + s32 temp_v0; + + if (this->collider.base.acFlags & AC_HIT) { + Actor_ApplyDamage(&this->actor); + if ((this->actor.colChkInfo.health <= 0) && (this->unk_1D4 != 3)) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + this->actor.speedXZ = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIRANHA_DEAD); + + if (this->unk_218 >= 0) { + Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, D_80A75C3C[this->unk_218]); + } + + this->actor.colChkInfo.health = 0; + func_80A751B4(this); + } + } + + if (this->collider.base.atFlags & AT_BOUNCED) { + this->actor.speedXZ = -10.0f; + } +} + +void EnPr2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnPr2* this = THIS; + f32 rand; + + if (thisx) {} + + Actor_SetScale(&this->actor, this->unk_204); + + this->actionFunc(this, globalCtx); + + if (this->unk_1DA != 0) { + this->unk_1DA--; + } + + if (this->unk_1D8 != 0) { + this->unk_1D8--; + } + + if (this->unk_1DC != 0) { + this->unk_1DC--; + } + + if (this->unk_1DE != 0) { + this->unk_1DE--; + } + + Actor_SetFocus(&this->actor, 10.0f); + func_80A755D8(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0, 10.0f, 20.0f, 0x1F); + + if (this->unk_1D6) { + s32 i; + Vec3f sp58; + f32 rand; + + Math_Vec3f_Copy(&sp58, &this->unk_270); + this->unk_1D6 = false; + + sp58.x += randPlusMinusPoint5Scaled(20.0f); + sp58.y += randPlusMinusPoint5Scaled(5.0f); + sp58.z += randPlusMinusPoint5Scaled(20.0f); + + for (i = 0; i < 2; i++) { + rand = Rand_ZeroFloat(0.03f) + 0.07f; + EffectSsBubble_Spawn(globalCtx, &sp58, 0, 5.0f, 5.0f, rand); + } + } + + if ((this->unk_1F4 == 255) && (this->unk_1E0 < 10)) { + this->actor.shape.rot.x = this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + if (this->unk_1D4 != 3) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +s32 func_80A758E8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnPr2* this = THIS; + + if (this->unk_1E0 < 10) { + if (limbIndex == 2) { + rot->y += (s16)this->unk_1FC * -1; + } + } else if ((limbIndex + 10) != this->unk_1E0) { + *dList = NULL; + } + return false; +} + +void func_80A75950(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnPr2* this = THIS; + + if (this->unk_1E0 < 10) { + if (limbIndex == 2) { + Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_GetStateTranslation(&this->unk_270); + } + Matrix_GetStateTranslation(&this->unk_234[limbIndex]); + } +} + +s32 func_80A759D8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnPr2* this = THIS; + + if (this->unk_1E0 < 10) { + if (limbIndex == 2) { + rot->y += (s16)this->unk_1FC * -1; + } + } else if ((limbIndex + 10) != this->unk_1E0) { + *dList = NULL; + } + return false; +} + +void EnPr2_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnPr2* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_1F4 == 255) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->unk_1EC, this->unk_1EC, this->unk_1EC, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->unk_1F4); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, func_80A758E8, func_80A75950, &this->actor); + } else { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_1F4); + + Scene_SetRenderModeXlu(globalCtx, 1, 2); + POLY_XLU_DISP = + SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, func_80A759D8, NULL, &this->actor, POLY_XLU_DISP); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 68fb09b82..4ae14db77 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h @@ -7,11 +7,48 @@ struct EnPr2; typedef void (*EnPr2ActionFunc)(struct EnPr2*, GlobalContext*); +#define ENPR2_GET_F(thisx) ((thisx)->params & 0xF) +#define ENPR2_GET_FF0(thisx) (((thisx)->params >> 4) & 0xFF) + typedef struct EnPr2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x80]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[5]; + /* 0x01A6 */ Vec3s morphtable[5]; /* 0x01C4 */ EnPr2ActionFunc actionFunc; - /* 0x01C8 */ char unk_1C8[0x100]; + /* 0x01C8 */ s16 unk_1C8; + /* 0x01CC */ Path* path; + /* 0x01D0 */ s32 unk_1D0; + /* 0x01D4 */ s16 unk_1D4; + /* 0x01D6 */ s16 unk_1D6; + /* 0x01D8 */ s16 unk_1D8; + /* 0x01DA */ s16 unk_1DA; + /* 0x01DC */ s16 unk_1DC; + /* 0x01DE */ s16 unk_1DE; + /* 0x01E0 */ s16 unk_1E0; + /* 0x01E2 */ UNK_TYPE1 unk1E2[2]; + /* 0x01E4 */ s16 unk_1E4; + /* 0x01E6 */ s16 unk_1E6; + /* 0x01E8 */ UNK_TYPE1 unk1E8[4]; + /* 0x01EC */ s16 unk_1EC; + /* 0x01EE */ s16 unk_1EE; + /* 0x01F0 */ s16 unk_1F0; + /* 0x01F2 */ s16 unk_1F2; + /* 0x01F4 */ s16 unk_1F4; + /* 0x01F8 */ f32 unk_1F8; + /* 0x01FC */ f32 unk_1FC; + /* 0x0200 */ f32 unk_200; + /* 0x0204 */ f32 unk_204; + /* 0x0208 */ f32 unk_208; + /* 0x020C */ f32 unk_20C; + /* 0x0210 */ s32 unk_210; + /* 0x0214 */ UNK_TYPE1 unk214[4]; + /* 0x0218 */ s32 unk_218; + /* 0x021C */ Vec3f unk_21C; + /* 0x0228 */ Vec3f unk_228; + /* 0x0234 */ Vec3f unk_234[5]; + /* 0x0270 */ Vec3f unk_270; + /* 0x027C */ ColliderCylinder collider; } EnPr2; // size = 0x2C8 extern const ActorInit En_Pr2_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 6902e8091..d0b2536cf 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1717,12 +1717,6 @@ D_06009930 = 0x06009930; D_0600A844 = 0x0600A844; D_06012768 = 0x06012768; -// ovl_En_Pr2 - -D_06003904 = 0x06003904; -D_06004188 = 0x06004188; -D_06004340 = 0x06004340; - // ovl_En_Prz D_06004188 = 0x06004188; From d60f3fcf2c595e4ed0776d6e5fdf4177480adf19 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Mon, 28 Feb 2022 02:59:07 +0000 Subject: [PATCH 055/257] En_Gg (#585) * En_Gg * remove syms * merge * Merge * PR * PR --- spec | 3 +- src/overlays/actors/ovl_En_Gg/z_en_gg.c | 758 ++++++++++++++++++++++-- src/overlays/actors/ovl_En_Gg/z_en_gg.h | 47 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 5 - 5 files changed, 766 insertions(+), 51 deletions(-) diff --git a/spec b/spec index 5728d9ddd..de1adce6a 100644 --- a/spec +++ b/spec @@ -4026,8 +4026,7 @@ beginseg name "ovl_En_Gg" compress include "build/src/overlays/actors/ovl_En_Gg/z_en_gg.o" - include "build/data/ovl_En_Gg/ovl_En_Gg.data.o" - include "build/data/ovl_En_Gg/ovl_En_Gg.reloc.o" + include "build/src/overlays/actors/ovl_En_Gg/ovl_En_Gg_reloc.o" endseg beginseg 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 bac0b52ae..fbce4e2e7 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -5,6 +5,8 @@ */ #include "z_en_gg.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_gg/object_gg.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_80) @@ -15,7 +17,15 @@ void EnGg_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGg_Update(Actor* thisx, GlobalContext* globalCtx); void EnGg_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B352A4(EnGg* this, GlobalContext* globalCtx); +void func_80B35450(EnGg* this, GlobalContext* globalCtx); +void func_80B3556C(EnGg* this, GlobalContext* globalCtx); +u16 func_80B357F0(EnGg* this); +void func_80B358D8(EnGg* this, GlobalContext* globalCtx); +void func_80B359DC(EnGg* this, GlobalContext* globalCtx); +void func_80B363E8(EnGgStruct* ptr, GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3); +void func_80B364D4(EnGgStruct* ptr, GlobalContext* globalCtx); + const ActorInit En_Gg_InitVars = { ACTOR_EN_GG, ACTORCAT_NPC, @@ -28,18 +38,29 @@ const ActorInit En_Gg_InitVars = { (ActorFunc)EnGg_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B36C00 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 24, 72, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B36C2C = { 0, 24, 72, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 24, 72, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80B36C38 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -74,62 +95,719 @@ static DamageTable D_80B36C38 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -#endif +static AnimationInfo sAnimations[] = { + { &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 }, +}; -extern ColliderCylinderInit D_80B36C00; -extern CollisionCheckInfoInit2 D_80B36C2C; -extern DamageTable D_80B36C38; +void func_80B34F70(EnGg* this) { + this->actor.focus.pos.x = this->actor.world.pos.x; + this->actor.focus.pos.y = this->actor.world.pos.y + 80.0f; + this->actor.focus.pos.z = this->actor.world.pos.z; -extern UNK_TYPE D_0600F578; + this->actor.focus.rot.x = this->actor.world.rot.x; + this->actor.focus.rot.y = this->actor.world.rot.y; + this->actor.focus.rot.z = this->actor.world.rot.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B34F70.s") +s32 func_80B34FB4(EnGg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + Vec3f sp34; + s16 pitch; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B34FB4.s") + sp40 = player->actor.world.pos; + sp40.y = player->bodyPartsPos[7].y + 3.0f; + sp34 = this->actor.world.pos; + sp34.y += 70.0f; + pitch = Math_Vec3f_Pitch(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35108.s") + if ((this->actor.xzDistToPlayer < 250.0f) && (this->actor.xzDistToPlayer > 50.0f) && + (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (gSaveContext.weekEventReg[19] & 0x80))) { + Math_SmoothStepToS(&this->unk_2E8, pitch, 4, 0x2AA8, 1); + } else { + Math_SmoothStepToS(&this->unk_2E8, 0, 4, 0x2AA8, 1); + } + this->unk_2E8 = CLAMP(this->unk_2E8, 0, 0x1C70); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B351A4.s") +void func_80B35108(EnGg* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35250.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 30.0f, 30.0f, 7); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B352A4.s") +void func_80B351A4(EnGg* this) { + if ((this->unk_2E6 == 2) || (this->unk_2E6 == 3)) { + this->unk_2E2 = 3; + } else { + s16 temp = this->unk_2E4 - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35450.s") + if (temp >= 3) { + this->unk_2E2 = 0; + this->unk_2E4 = temp; + } else if (temp == 0) { + this->unk_2E2 = 2; + this->unk_2E4 = (s32)(Rand_ZeroOne() * 60.0f) + 20; + } else { + this->unk_2E2 = 1; + this->unk_2E4 = temp; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B3556C.s") +void func_80B35250(EnGg* this) { + this->unk_2E4 = 20; + this->unk_2E2 = 0; + this->unk_2E6 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actionFunc = func_80B35450; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35634.s") +void func_80B352A4(EnGg* this, GlobalContext* globalCtx) { + s16 sp26 = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E6].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B357F0.s") + if (sp26 == lastFrame) { + switch (this->actor.textId) { + case 0xCE5: + this->unk_2E6 = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B3584C.s") + case 0xCE6: + case 0xCEC: + this->unk_2E6 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B358D8.s") + case 0xCE8: + this->unk_2E6 = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35968.s") + case 0xCE9: + this->unk_2E6 = 3; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B359DC.s") + case 0xCED: + case 0xCEE: + this->unk_2E6 = 4; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35B24.s") + default: + this->unk_2E6 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + break; + } + gSaveContext.weekEventReg[19] |= 0x80; + this->actionFunc = func_80B3556C; + } else if ((this->unk_2E6 == 0) && ((this->actor.textId == 0xCED) || (this->actor.textId == 0xCEE))) { + if (sp26 < (lastFrame - 1)) { + this->skelAnime.playSpeed = 2.0f; + } else { + this->unk_2E6 = 4; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35B44.s") +void func_80B35450(EnGg* this, GlobalContext* globalCtx) { + if ((gSaveContext.weekEventReg[91] & 0x10) && (globalCtx->csCtx.state == 0)) { + func_80B359DC(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35C84.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_80) { + func_800B90F4(globalCtx); + } + this->unk_308 = 1; + this->actionFunc = func_80B352A4; + } else if ((this->actor.xzDistToPlayer < 200.0f) && (this->actor.xzDistToPlayer > 50.0f)) { + if (gSaveContext.weekEventReg[19] & 0x80) { + func_800B863C(&this->actor, globalCtx); + this->actor.textId = 0xCEE; + } else if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_80) { + func_800B863C(&this->actor, globalCtx); + this->actor.textId = 0xCE5; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B3610C.s") +void func_80B3556C(EnGg* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if (this->unk_2E6 == 4) { + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_308 = 0; + this->actor.flags &= ~ACTOR_FLAG_80; + func_80B35250(this); + } else { + this->actor.textId = func_80B357F0(this); + func_801518B0(globalCtx, this->actor.textId, &this->actor); + this->actionFunc = func_80B352A4; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B363E8.s") +void func_80B35634(EnGg* this, GlobalContext* globalCtx) { + s32 pad; + u32 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B364D4.s") + if (func_800EE29C(globalCtx, 0x77)) { + temp_v0 = func_800EE200(globalCtx, 0x77); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/EnGg_Init.s") + if (this->unk_2DB != globalCtx->csCtx.npcActions[temp_v0]->unk0) { + this->unk_2DB = globalCtx->csCtx.npcActions[temp_v0]->unk0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/EnGg_Destroy.s") + switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + case 1: + this->unk_2DA = 0; + this->unk_2E6 = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/EnGg_Update.s") + case 2: + this->unk_2DA = 9; + this->unk_2E6 = 9; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B368B0.s") + case 3: + this->unk_2DA = 10; + this->unk_2E6 = 10; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B368F0.s") + case 4: + do { + this->unk_344.unk_30 = this->unk_2DA = 11; + } while (0); + this->unk_2E6 = 11; + func_80B364D4(&this->unk_344, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/EnGg_Draw.s") + case 5: + do { + this->unk_344.unk_30 = this->unk_2DA = 12; + } while (0); + this->unk_2E6 = 12; + break; + + case 6: + do { + this->unk_344.unk_30 = this->unk_2DA = 13; + } while (0); + this->unk_2E6 = 13; + break; + + case 7: + do { + this->unk_344.unk_30 = this->unk_2DA = 14; + } while (0); + this->unk_2E6 = 14; + func_80B364D4(&this->unk_344, globalCtx); + break; + + case 8: + Actor_MarkForDeath(&this->actor); + return; + + default: + this->unk_2DA = 0; + break; + } + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_2DA); + } + + if (this->unk_2DA == 14) { + func_80B358D8(this, globalCtx); + } + + func_800EDF24(&this->actor, globalCtx, temp_v0); + this->actor.shape.yOffset = 0.0f; + } else { + this->unk_2DB = 99; + } +} + +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; + } + return 0; +} + +void func_80B3584C(EnGg* this) { + this->unk_30A += 0x72C; + this->actor.shape.yOffset = Math_SinS(this->unk_30A) * 100.0f; + this->actor.shape.shadowScale = 30.0f - (Math_SinS(this->unk_30A) * 5.0f); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void func_80B358D8(EnGg* this, GlobalContext* globalCtx) { + s16 sp1E = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2DA].animation); + + if ((this->unk_2E6 == 14) && (sp1E == lastFrame)) { + this->unk_2E6 = 15; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 15); + } +} + +void func_80B35968(EnGg* this, GlobalContext* globalCtx) { + if (this->unk_344.unk_34 != NULL) { + this->unk_344.unk_34(&this->unk_344, globalCtx); + } else { + if ((this->unk_2DA == 11) || (this->unk_2DA == 14)) { + this->unk_344.unk_30 = this->unk_2DA; + } + func_80B363E8(&this->unk_344, globalCtx, &this->unk_320, &this->unk_32C, &this->unk_338); + } +} + +void func_80B359DC(EnGg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->actor.xzDistToPlayer < 200.0f) { + if (this->unk_306 == 0) { + if (player->stateFlags2 & 0x8000000) { + this->unk_306 = 1; + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + } else if (!(player->stateFlags2 & 0x8000000)) { + this->unk_306 = 0; + } + + if ((player->transformation == PLAYER_FORM_HUMAN) && (globalCtx->msgCtx.ocarinaMode == 3) && + (globalCtx->msgCtx.unk1202E == 7)) { + if (!(gSaveContext.weekEventReg[19] & 0x80)) { + gSaveContext.weekEventReg[19] |= 0x80; + } + this->unk_307 = true; + } + + if (ActorCutscene_GetCanPlayNext(this->unk_2DC)) { + ActorCutscene_Start(this->unk_2DC, &this->actor); + this->unk_307 = false; + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + + if (this->unk_307) { + ActorCutscene_SetIntentToPlay(this->unk_2DC); + } + } + } else { + this->unk_307 = false; + } +} + +void func_80B35B24(EnGgStruct* ptr, GlobalContext* globalCtx) { + ptr->unk_34 = NULL; + ptr->unk_38 = NULL; + ptr->unk_3C = 0; + ptr->unk_40 = 0; + ptr->unk_44 = 0; +} + +void func_80B35B44(EnGgStruct* ptr, GlobalContext* globalCtx) { + if (ptr->unk_30 == 0xE) { + ptr->unk_40++; + if (ptr->unk_40 > 0x46) { + ptr->unk_48 = 1; + ptr->unk_40 = 0; + } + + if (ptr->unk_40 != 0x46) { + if (ptr->unk_48 != 0) { + ptr->unk_44 = 0x37; + } else { + ptr->unk_44 = ptr->unk_40 - 15; + if (ptr->unk_44 < 0) { + ptr->unk_44 = 0; + } + } + } else { + ptr->unk_44++; + if (ptr->unk_44 > 0x37) { + ptr->unk_44 = 0x37; + } + } + } else if ((ptr->unk_30 == 11) || (ptr->unk_30 == 12)) { + ptr->unk_40++; + if (ptr->unk_40 > 0x46) { + ptr->unk_48 = 1; + ptr->unk_40 = 0; + } + } else if (ptr->unk_30 == 0xD) { + ptr->unk_48 = 0; + ptr->unk_40++; + if (ptr->unk_40 > 0x46) { + ptr->unk_40 = 0x46; + } + + if (ptr->unk_40 != 0x46) { + ptr->unk_44 = ptr->unk_40 - 15; + if (ptr->unk_44 < 0) { + ptr->unk_44 = 0; + } + } else { + ptr->unk_44++; + if (ptr->unk_44 > 0x37) { + func_80B364D4(ptr, globalCtx); + } + } + } +} + +void func_80B35C84(EnGgStruct* ptr, GlobalContext* globalCtx) { + s32 sp74; + s32 phi_s7; + f32 temp_f22; + f32 temp_f24; + f32 temp_f26; + f32 temp_f20; + s32 i; + s32 temp = 10; + + if (ptr->unk_48 != 0) { + sp74 = ptr->unk_40 % temp; + ptr->unk_40 = sp74; + phi_s7 = 0x46; + } else if (ptr->unk_30 == 0xD) { + sp74 = ptr->unk_40; + phi_s7 = 0x46; + } else { + phi_s7 = ptr->unk_40 - ptr->unk_44; + sp74 = ptr->unk_40 % temp; + } + + if (phi_s7 <= 0) { + return; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + + for (i = sp74; i < phi_s7; i += temp) { + temp_f20 = i * 0.14f; + temp_f22 = ptr->unk_00.x + (ptr->unk_18.x * temp_f20) + (0.5f * ptr->unk_24.x * temp_f20 * temp_f20); + temp_f24 = ptr->unk_00.y - Math_SinS((i * 0x27FFB) / 70); + 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; + + if (1) {} + + Matrix_InsertTranslation(temp_f22, temp_f24, temp_f26, MTXMODE_NEW); + Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + } + + Matrix_StatePop(); + + Matrix_StatePush(); + + for (i = sp74; i < phi_s7; i += temp) { + temp_f20 = i * 0.14f; + temp_f22 = ptr->unk_0C.x + ((ptr->unk_18.x * temp_f20) + (0.5f * ptr->unk_24.x * temp_f20 * temp_f20)); + temp_f24 = ptr->unk_0C.y - Math_SinS((i * 0x27FFB) / 70); + temp_f26 = ptr->unk_0C.z + (ptr->unk_18.z * temp_f20) + (0.5f * ptr->unk_24.z * temp_f20 * temp_f20); + temp_f20 = Rand_ZeroOne() * 0.003f; + + Matrix_InsertTranslation(temp_f22, temp_f24, temp_f26, MTXMODE_NEW); + Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + } + + Matrix_StatePop(); + + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80B3610C(EnGgStruct* ptr, GlobalContext* globalCtx) { + f32 temp_f20; + f32 temp_f24; + f32 temp_f26; + f32 temp_f28; + f32 temp_f30; + s32 phi_s4; + f32 phi_f22; + s32 i; + + if (ptr->unk_48 != 0) { + phi_s4 = 0x46; + } else { + phi_s4 = ptr->unk_40; + } + + if (phi_s4 > 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + + for (i = 0; i < phi_s4; i++) { + if (ptr->unk_48 != 0) { + phi_f22 = phi_s4 / 70.0f; + } else { + phi_f22 = i / 70.0f; + } + temp_f24 = ptr->unk_0C.x + (ptr->unk_18.x * i) + (0.5f * ptr->unk_24.x * i * i); + temp_f26 = ptr->unk_0C.y + (ptr->unk_18.y * i) + (0.5f * ptr->unk_24.y * i * i); + temp_f28 = ptr->unk_0C.z + (ptr->unk_18.z * i) + (0.5f * ptr->unk_24.z * i * i); + temp_f20 = Rand_ZeroOne() * 0.003f; + + Matrix_InsertTranslation((Rand_Centered() * (100.0f * phi_f22)) + temp_f24, temp_f26, + ((30.0f * phi_f22) * Rand_Centered()) + temp_f28, MTXMODE_NEW); + Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + } + + Matrix_StatePop(); + + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_80B363E8(EnGgStruct* ptr, GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3) { + ptr->unk_34 = func_80B35B44; + ptr->unk_00 = *arg1; + ptr->unk_0C = *arg1; + ptr->unk_18 = *arg2; + ptr->unk_24 = *arg3; + ptr->unk_48 = 0; + + 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)) { + ptr->unk_38 = func_80B35C84; + } else if (ptr->unk_30 == 14) { + ptr->unk_38 = func_80B3610C; + } +} + +void func_80B364D4(EnGgStruct* ptr, GlobalContext* globalCtx) { + ptr->unk_34 = NULL; + ptr->unk_38 = NULL; + func_80B35B24(ptr, globalCtx); +} + +void EnGg_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGg* this = THIS; + + if (INV_CONTENT(ITEM_MASK_GORON) == ITEM_MASK_GORON) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + this->actor.bgCheckFlags |= 0x400; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_gg_Skel_00F6C0, &object_gg_Anim_00F578, this->jointTable, + this->morphTable, 20); + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + gSaveContext.weekEventReg[20] &= (u8)~4; + gSaveContext.weekEventReg[20] &= (u8)~8; + gSaveContext.weekEventReg[20] &= (u8)~0x10; + this->actor.flags &= ~ACTOR_FLAG_80; + this->unk_310 = this->actor.home.pos.y; + this->unk_2DC = this->actor.cutscene; + this->actor.flags |= ACTOR_FLAG_2000000; + this->unk_308 = 0; + this->unk_309 = 0; + this->unk_304 = 0; + this->unk_30A = 0; + this->actor.flags |= ACTOR_FLAG_10; + func_80B35B24(&this->unk_344, globalCtx); + func_80B35250(this); +} + +void EnGg_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnGg_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGg* this = THIS; + + if (globalCtx->actorCtx.unk4 == 100) { + this->actor.flags |= ACTOR_FLAG_80; + this->actor.flags |= ACTOR_FLAG_1; + } else { + this->actor.flags &= ~ACTOR_FLAG_80; + this->actor.flags &= ~ACTOR_FLAG_1; + } + + if (gSaveContext.weekEventReg[19] & 0x80) { + if (globalCtx->csCtx.state == 0) { + this->actor.flags |= ACTOR_FLAG_1; + } else { + this->actor.flags &= ~ACTOR_FLAG_1; + } + } + + if ((globalCtx->csCtx.state == 0) && + ((this->unk_2DA != 14) && (this->unk_2DA != 11) && (this->unk_2DA != 12) && (this->unk_2DA != 13))) { + func_80B364D4(&this->unk_344, globalCtx); + } + + if (((this->unk_2DA == 14) || (this->unk_2DA == 11) || (this->unk_2DA == 12) || (this->unk_2DA == 13)) && + (this->unk_309 == 1)) { + func_80B35968(this, globalCtx); + } + + if (!(gSaveContext.weekEventReg[91] & 0x10) && + ((gSaveContext.weekEventReg[19] & 0x80) || CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || + (this->unk_308 == 1))) { + gSaveContext.weekEventReg[91] |= 0x10; + } + + this->actionFunc(this, globalCtx); + + func_80B34F70(this); + func_80B35108(this, globalCtx); + func_80B34FB4(this, globalCtx); + Actor_MoveWithoutGravity(&this->actor); + SkelAnime_Update(&this->skelAnime); + + if (globalCtx->csCtx.state == 0) { + func_80B3584C(this); + } else { + this->unk_2E8 = 0; + } + + func_80B35634(this, globalCtx); + func_800E9250(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); + func_80B351A4(this); +} + +s32 EnGg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnGg* this = THIS; + + if (limbIndex == 2) { + Matrix_InsertZRotation_s(this->unk_2E8, MTXMODE_APPLY); + } + return false; +} + +void EnGg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + static Vec3f D_80B36DF0 = { 1800.0f, 300.0f, 200.0f }; + EnGg* this = THIS; + Vec3f sp30 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp24 = { 0.0f, 0.0f, 0.0f }; + + if (this->unk_2DA == 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)) { + sp30.x = 3.0f; + sp24.x = 0.5f; + this->unk_309 = 1; + } else { + this->unk_309 = 0; + } + + if (limbIndex == 4) { + Matrix_MultiplyVector3fByState(&D_80B36DF0, &this->unk_320); + Matrix_StatePush(); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp30, &this->unk_32C); + Matrix_MultiplyVector3fByState(&sp24, &this->unk_338); + Matrix_StatePop(); + } +} + +TexturePtr D_80B36DFC[] = { + object_gg_Tex_009260, + object_gg_Tex_009660, + object_gg_Tex_009A60, + object_gg_Tex_009E60, +}; + +void EnGg_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGg* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_344.unk_38 != 0) { + this->unk_344.unk_38(&this->unk_344, globalCtx); + } + + if (gSaveContext.weekEventReg[19] & 0x80) { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B36DFC[this->unk_2E2])); + + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnGg_OverrideLimbDraw, EnGg_PostLimbDraw, + &this->actor, POLY_OPA_DISP); + } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (this->unk_308 == 1)) { + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B36DFC[this->unk_2E2])); + + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnGg_OverrideLimbDraw, EnGg_PostLimbDraw, + &this->actor, POLY_XLU_DISP); + } + func_8012C2DC(globalCtx->state.gfxCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 f96a59548..eeb83cbbd 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.h +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.h @@ -4,14 +4,57 @@ #include "global.h" struct EnGg; +struct EnGgStruct; typedef void (*EnGgActionFunc)(struct EnGg*, GlobalContext*); +typedef void (*EnGgUnkFunc)(struct EnGgStruct*, GlobalContext*); + +typedef struct EnGgStruct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ Vec3f unk_24; + /* 0x30 */ u8 unk_30; + /* 0x34 */ EnGgUnkFunc unk_34; + /* 0x38 */ EnGgUnkFunc unk_38; + /* 0x3C */ s32 unk_3C; + /* 0x40 */ s32 unk_40; + /* 0x44 */ s32 unk_44; + /* 0x48 */ u8 unk_48; +} EnGgStruct; // size == 0x4C typedef struct EnGg { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnGgActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x1B8]; + /* 0x01D8 */ Vec3s unk_1D8; + /* 0x01DE */ Vec3s unk_1DE; + /* 0x01E4 */ Vec3s jointTable[20]; + /* 0x025C */ Vec3s morphTable[20]; + /* 0x02D4 */ UNK_TYPE1 unk_2D4[0x6]; + /* 0x02DA */ u8 unk_2DA; + /* 0x02DB */ u8 unk_2DB; + /* 0x02DC */ s16 unk_2DC; + /* 0x02DE */ UNK_TYPE1 unk2DE[4]; + /* 0x02E2 */ s16 unk_2E2; + /* 0x02E4 */ s16 unk_2E4; + /* 0x02E6 */ s16 unk_2E6; + /* 0x02E8 */ s16 unk_2E8; + /* 0x02EA */ UNK_TYPE1 unk2EA[0x1A]; + /* 0x0304 */ s16 unk_304; + /* 0x0306 */ u8 unk_306; + /* 0x0307 */ u8 unk_307; + /* 0x0308 */ u8 unk_308; + /* 0x0309 */ u8 unk_309; + /* 0x030A */ s16 unk_30A; + /* 0x030C */ UNK_TYPE1 unk30C[4]; + /* 0x0310 */ f32 unk_310; + /* 0x0314 */ UNK_TYPE1 unk314[0xC]; + /* 0x0320 */ Vec3f unk_320; + /* 0x032C */ Vec3f unk_32C; + /* 0x0338 */ Vec3f unk_338; + /* 0x0344 */ EnGgStruct unk_344; } EnGg; // size = 0x390 extern const ActorInit En_Gg_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 8be41c5c1..fd1eea743 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -13527,8 +13527,8 @@ 0x80B364F8:("EnGg_Init",), 0x80B36660:("EnGg_Destroy",), 0x80B36670:("EnGg_Update",), - 0x80B368B0:("func_80B368B0",), - 0x80B368F0:("func_80B368F0",), + 0x80B368B0:("EnGg_OverrideLimbDraw",), + 0x80B368F0:("EnGg_PostLimbDraw",), 0x80B36A34:("EnGg_Draw",), 0x80B37080:("EnMaruta_Init",), 0x80B37280:("EnMaruta_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index d0b2536cf..d7ca4b661 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1367,11 +1367,6 @@ D_0600A344 = 0x0600A344; D_06001EFC = 0x06001EFC; D_0600A808 = 0x0600A808; -// ovl_En_Gg - -D_0600F578 = 0x0600F578; -D_0600F6C0 = 0x0600F6C0; - // ovl_En_Gg2 D_0600F578 = 0x0600F578; From 8b7cbb1273ccccd505d10757c72b46d293329414 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Mon, 28 Feb 2022 03:03:03 +0000 Subject: [PATCH 056/257] En_Gk (#580) * En_Gk * Merge * Merge * TrasnformDraw * PR * a * Ok * PR --- include/functions.h | 2 +- spec | 3 +- src/overlays/actors/ovl_En_Gk/z_en_gk.c | 1231 ++++++++++++++++++++++- src/overlays/actors/ovl_En_Gk/z_en_gk.h | 46 +- tools/disasm/functions.txt | 6 +- undefined_syms.txt | 7 - 6 files changed, 1226 insertions(+), 69 deletions(-) diff --git a/include/functions.h b/include/functions.h index aff556e4c..542a753bb 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3753,7 +3753,7 @@ void Audio_PreNMI(void); // void func_801A44C4(void); // void func_801A44D4(void); s32 func_801A46F8(void); -// void func_801A4748(void); +void func_801A4748(Vec3f* pos, u16 sfxId); void func_801A479C(Vec3f* arg0, u16 sfxId, s32 arg2); // void func_801A47DC(void); // void func_801A48E0(void); diff --git a/spec b/spec index de1adce6a..7910aa455 100644 --- a/spec +++ b/spec @@ -4098,8 +4098,7 @@ beginseg name "ovl_En_Gk" compress include "build/src/overlays/actors/ovl_En_Gk/z_en_gk.o" - include "build/data/ovl_En_Gk/ovl_En_Gk.data.o" - include "build/data/ovl_En_Gk/ovl_En_Gk.reloc.o" + include "build/src/overlays/actors/ovl_En_Gk/ovl_En_Gk_reloc.o" endseg beginseg 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 f16276ea2..c78c96bd9 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -5,6 +5,7 @@ */ #include "z_en_gk.h" +#include "objects/object_gk/object_gk.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -15,7 +16,23 @@ void EnGk_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGk_Update(Actor* thisx, GlobalContext* globalCtx); void EnGk_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B51698(EnGk* this, GlobalContext* globalCtx); +void func_80B51760(EnGk* this, GlobalContext* globalCtx); +void func_80B51970(EnGk* this, GlobalContext* globalCtx); +void func_80B51B40(EnGk* this, GlobalContext* globalCtx); +void func_80B51D9C(EnGk* this, GlobalContext* globalCtx); +void func_80B51EA4(EnGk* this, GlobalContext* globalCtx); +void func_80B51FD0(EnGk* this, GlobalContext* globalCtx); +void func_80B5202C(EnGk* this, GlobalContext* globalCtx); +void func_80B5216C(EnGk* this, GlobalContext* globalCtx); +void func_80B521E8(EnGk* this, GlobalContext* globalCtx); +void func_80B5227C(EnGk* this, GlobalContext* globalCtx); +void func_80B52340(EnGk* this, GlobalContext* globalCtx); +void func_80B52430(EnGk* this, GlobalContext* globalCtx); +void func_80B5253C(EnGk* this, GlobalContext* globalCtx); +void func_80B525E0(EnGk* this, GlobalContext* globalCtx); +void func_80B52654(EnGk* this, GlobalContext* globalCtx); + const ActorInit En_Gk_InitVars = { ACTOR_EN_GK, ACTORCAT_NPC, @@ -28,18 +45,29 @@ const ActorInit En_Gk_InitVars = { (ActorFunc)EnGk_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B53210 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 24, 32, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B5323C = { 0, 24, 32, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 24, 32, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80B53248 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -74,89 +102,1184 @@ static DamageTable D_80B53248 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -#endif +static AnimationInfo sAnimations[] = { + { &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 }, +}; -extern ColliderCylinderInit D_80B53210; -extern CollisionCheckInfoInit2 D_80B5323C; -extern DamageTable D_80B53248; +Color_RGBA8 D_80B533A0 = { 255, 255, 255, 255 }; +Color_RGBA8 D_80B533A4 = { 50, 150, 150, 0 }; -extern UNK_TYPE D_06006688; -extern UNK_TYPE D_0600787C; +u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50410.s") + if (globalCtx->sceneNum == SCENE_17SETUGEN2) { + if (player->transformation == PLAYER_FORM_GORON) { + if (!(gSaveContext.weekEventReg[40] & 0x80)) { + 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: + gSaveContext.weekEventReg[40] |= 0x80; + this->unk_1E4 |= 1; + return 0xE80; + default: + return 0xE7A; + } + } else { + this->unk_1E4 |= 1; + return 0xE81; + } + } else if (!(gSaveContext.weekEventReg[41] & 1)) { + switch (this->unk_31C) { + case 0xE82: + return 0xE83; + case 0xE83: + return 0xE7D; + case 0xE7D: + return 0xE7E; + case 0xE7E: + return 0xE7F; + case 0xE7F: + gSaveContext.weekEventReg[41] |= 1; + this->unk_1E4 |= 1; + return 0xE80; + default: + return 0xE82; + } + } else { + this->unk_1E4 |= 1; + return 0xE81; + } + } else if (globalCtx->sceneNum == SCENE_GORONRACE) { + if (player->transformation == PLAYER_FORM_GORON) { + if (!(gSaveContext.weekEventReg[41] & 4)) { + if (this->unk_31C == 0xE88) { + if (!(gSaveContext.weekEventReg[41] & 8) || Interface_HasEmptyBottle()) { + return 0xE89; + } + gSaveContext.weekEventReg[41] |= 4; + this->unk_1E4 |= 1; + return 0xE94; + } + return 0xE88; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50710.s") + if ((this->unk_31C == 0xE8D) || (this->unk_31C == 0xE98)) { + if (!(gSaveContext.weekEventReg[41] & 8) || Interface_HasEmptyBottle()) { + return 0xE89; + } + gSaveContext.weekEventReg[41] |= 4; + this->unk_1E4 |= 1; + return 0xE94; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B507A0.s") + if (this->unk_1E4 & 0x10) { + return 0xE8D; + } + return 0xE98; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50854.s") + if (!(gSaveContext.weekEventReg[41] & 2)) { + switch (this->unk_31C) { + case 0xE85: + return 0xE86; + case 0xE86: + gSaveContext.weekEventReg[41] |= 2; + this->unk_1E4 |= 1; + return 0xE87; + default: + return 0xE85; + } + } else { + this->unk_1E4 |= 1; + return 0xE87; + } + } else { + return 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50954.s") +u16 func_80B50710(EnGk* this) { + switch (this->unk_31C) { + case 0xE8E: + gSaveContext.weekEventReg[41] |= 4; + this->unk_1E4 &= ~0x10; + this->unk_1E4 |= 1; + return 0xE8F; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B509A8.s") + case 0xE8A: + return 0xE8B; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50B38.s") + case 0xE8B: + gSaveContext.weekEventReg[41] |= 4; + this->unk_1E4 |= 0x10; + this->unk_1E4 |= 1; + return 0xE8C; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50C78.s") +void func_80B507A0(EnGk* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50E14.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 30.0f, 30.0f, 7); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50ED4.s") +s32 func_80B50854(EnGk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B5100C.s") + if (!(this->unk_1E4 & 0x40)) { + if (player->stateFlags2 & 0x8000000) { + this->unk_1E4 |= 0x40; + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + } else if (!(player->stateFlags2 & 0x8000000)) { + this->unk_1E4 &= ~0x40; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B5123C.s") + if ((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.ocarinaMode == 3) && + (globalCtx->msgCtx.unk1202E == 1)) { + Flags_SetSwitch(globalCtx, ENGK_GET_3F00(&this->actor)); + this->unk_2E4 = 3; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + this->actionFunc = func_80B521E8; + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51308.s") +void func_80B50954(EnGk* this) { + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 4.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLONKID_WALK); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51398.s") +void func_80B509A8(EnGk* this, GlobalContext* globalCtx) { + Vec3f sp4C; + s16 phi_s1 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51410.s") + this->unk_300.x += 2.0f * Rand_Centered(); + this->unk_300.y += Rand_ZeroOne(); + this->unk_300.z += 2.0f * Rand_Centered(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51510.s") + this->unk_30C.x += 2.0f * Rand_Centered(); + this->unk_30C.y += Rand_ZeroOne(); + this->unk_30C.z += 2.0f * Rand_Centered(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51698.s") + if (this->unk_2E4 == 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)) { + sp4C.x = 0.0f; + sp4C.z = 0.0f; + sp4C.y = -0.5f; + phi_s1 = 10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51760.s") + EffectSsDtBubble_SpawnCustomColor(globalCtx, &this->unk_2E8, &this->unk_300, &sp4C, &D_80B533A0, &D_80B533A4, + Rand_S16Offset(15, 15), phi_s1, 0); + EffectSsDtBubble_SpawnCustomColor(globalCtx, &this->unk_2F4, &this->unk_30C, &sp4C, &D_80B533A0, &D_80B533A4, + Rand_S16Offset(15, 15), phi_s1, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51970.s") +void func_80B50B38(EnGk* this, GlobalContext* globalCtx) { + s16 i; + s16 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51B40.s") + switch (this->unk_2E4) { + case 0: + this->unk_2E0 = 3; + for (i = 0; i < 2; i++) { + func_80B509A8(this, globalCtx); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51D9C.s") + case 2: + this->unk_2E0 = 3; + func_80B509A8(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51EA4.s") + case 1: + case 3: + case 12: + this->unk_2E0 = 2; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51FD0.s") + case 9: + case 10: + case 11: + this->unk_2E0 = 3; + func_80B509A8(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B5202C.s") + default: + temp = this->unk_2E2; + temp--; + if (temp >= 3) { + this->unk_2E0 = 0; + this->unk_2E2 = temp; + } else if (temp == 0) { + this->unk_2E0 = 2; + this->unk_2E2 = (s32)(Rand_ZeroOne() * 60.0f) + 20; + } else { + this->unk_2E0 = 1; + this->unk_2E2 = temp; + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B5216C.s") +s32 func_80B50C78(EnGk* this, Path* path, s32 arg2_) { + Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); + s32 sp58 = path->count; + s32 arg2 = arg2_; + s32 ret = false; + f32 phi_f12; + f32 phi_f14; + f32 sp44; + f32 sp40; + f32 sp3C; + Vec3f sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B521E8.s") + Math_Vec3s_ToVec3f(&sp30, &sp5C[arg2]); + if (arg2 == 0) { + phi_f12 = sp5C[1].x - sp5C[0].x; + phi_f14 = sp5C[1].z - sp5C[0].z; + } else if ((sp58 - 1) == arg2) { + phi_f12 = sp5C[sp58 - 1].x - sp5C[sp58 - 2].x; + phi_f14 = sp5C[sp58 - 1].z - sp5C[sp58 - 2].z; + } else { + phi_f12 = sp5C[arg2 + 1].x - sp5C[arg2 - 1].x; + phi_f14 = sp5C[arg2 + 1].z - sp5C[arg2 - 1].z; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B5227C.s") + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B52340.s") + if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B52430.s") +f32 func_80B50E14(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3) { + Vec3s* points; + Vec3f sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B5253C.s") + if (path != NULL) { + points = Lib_SegmentedToVirtual(path->points); + points = &points[arg1]; + sp20.x = points[0].x; + sp20.y = points[0].y; + sp20.z = points[0].z; + } + arg3->y = Math_Vec3f_Yaw(arg2, &sp20); + arg3->x = Math_Vec3f_Pitch(arg2, &sp20); + return sp20.y - arg2->y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B525E0.s") +s32 func_80B50ED4(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5) { + Vec3f sp7C; + Vec3f sp70 = gZeroVec3f; + Vec3s sp68; + MtxF sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B52654.s") + Matrix_MultiplyVector3fByState(&sp70, &sp7C); + Matrix_CopyCurrentState(&sp28); + func_8018219C(&sp28, &sp68, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/EnGk_Init.s") + *arg2 = sp7C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/EnGk_Destroy.s") + if (!arg4 && !arg5) { + arg3->x = sp68.x; + arg3->y = sp68.y; + arg3->z = sp68.z; + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/EnGk_Update.s") + if (arg5) { + sp68.z = arg0; + sp68.y = arg1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B52AD4.s") + Math_SmoothStepToS(&arg3->x, sp68.x, 3, 0x2AA8, 0xB6); + Math_SmoothStepToS(&arg3->y, sp68.y, 3, 0x2AA8, 0xB6); + Math_SmoothStepToS(&arg3->z, sp68.z, 3, 0x2AA8, 0xB6); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B52AF0.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B52D8C.s") +s32 func_80B5100C(EnGk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + Vec3f sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/EnGk_Draw.s") + Math_SmoothStepToS(&this->unk_320, (this->actor.yawTowardsPlayer - this->unk_324) - this->actor.shape.rot.y, 4, + 0x2AA8, 1); + this->unk_320 = CLAMP(this->unk_320, -0x1FFE, 0x1FFE); + + Math_SmoothStepToS(&this->unk_324, (this->actor.yawTowardsPlayer - this->unk_320) - this->actor.shape.rot.y, 4, + 0x2AA8, 1); + this->unk_324 = CLAMP(this->unk_324, -0x1C70, 0x1C70); + + sp40 = player->actor.world.pos; + sp40.y = player->bodyPartsPos[7].y + 3.0f; + + sp34 = this->actor.world.pos; + sp34.y += 70.0f; + + Math_SmoothStepToS(&this->unk_31E, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_322, 4, 0x2AA8, 1); + this->unk_31E = CLAMP(this->unk_31E, -0x1C70, 0x1C70); + + Math_SmoothStepToS(&this->unk_322, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_31E, 4, 0x2AA8, 1); + this->unk_322 = CLAMP(this->unk_322, -0x1C70, 0x1C70); + return true; +} + +s32 func_80B5123C(EnGk* this, GlobalContext* globalCtx) { + s16 temp_v0; + s16 phi_v1; + + if (DECR(this->unk_34E) != 0) { + this->unk_31E = 0; + this->unk_320 = 0; + this->unk_1E4 &= ~8; + this->unk_322 = 0; + this->unk_324 = 0; + return true; + } + + if (Actor_IsFacingAndNearPlayer(&this->actor, 300.0f, 0x7FF8)) { + this->unk_1E4 |= 8; + func_80B5100C(this, globalCtx); + } else { + if (this->unk_1E4 & 8) { + this->unk_34E = 20; + } + this->unk_1E4 &= ~8; + this->unk_31E = 0; + this->unk_320 = 0; + this->unk_322 = 0; + this->unk_324 = 0; + } + return true; +} + +void func_80B51308(EnGk* this, GlobalContext* globalCtx) { + s16 sp1E = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_31A].animation); + + if ((this->unk_2E4 == 7) && (sp1E == lastFrame)) { + this->unk_2E4 = 8; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); + } +} + +void func_80B51398(EnGk* this, GlobalContext* globalCtx) { + s16 sp1E = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[9].animation); + + if ((this->unk_2E4 == 9) && (sp1E == lastFrame)) { + this->unk_2E4 = 10; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); + } +} + +void func_80B51410(EnGk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->actor.xzDistToPlayer < 100.0f) { + if ((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.ocarinaMode == 3) && + (globalCtx->msgCtx.unk1202E == 0xE)) { + this->unk_1E4 |= 0x20; + } + + if (ActorCutscene_GetCanPlayNext(this->unk_318)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLONKID_SOB_TALK); + ActorCutscene_Start(this->unk_318, &this->actor); + this->unk_1E4 &= ~0x20; + return; + } + + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + + if (this->unk_1E4 & 0x20) { + ActorCutscene_SetIntentToPlay(this->unk_318); + } + } else { + this->unk_1E4 &= ~0x20; + } +} + +void func_80B51510(EnGk* this, GlobalContext* globalCtx) { + s32 pad; + u32 temp_v0; + + if (this) {} + + if (func_800EE29C(globalCtx, 0x1DF)) { + temp_v0 = func_800EE200(globalCtx, 0x1DF); + + if (globalCtx->csCtx.npcActions[temp_v0]->unk0 != this->unk_31B) { + this->unk_31B = globalCtx->csCtx.npcActions[temp_v0]->unk0; + switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + case 1: + this->unk_31A = 0; + this->unk_2E4 = 0; + break; + + case 2: + this->unk_31A = 2; + this->unk_2E4 = 2; + break; + + case 3: + this->unk_31A = 7; + this->unk_2E4 = 7; + break; + + case 4: + this->unk_31A = 3; + this->unk_2E4 = 3; + break; + + case 5: + this->unk_31A = 1; + this->unk_2E4 = 1; + this->unk_1E4 |= 0x80; + this->actionFunc = func_80B5227C; + break; + + case 6: + this->unk_31A = 12; + this->unk_2E4 = 12; + break; + + case 7: + Flags_SetSwitch(globalCtx, ENGK_GET_3F00(&this->actor)); + break; + } + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_31A); + } + + if (this->unk_31A == 7) { + func_80B51308(this, globalCtx); + } + + func_800EDF24(&this->actor, globalCtx, temp_v0); + this->actor.shape.yOffset = 0.0f; + } else { + this->unk_31B = 0x63; + } +} + +void func_80B51698(EnGk* this, GlobalContext* globalCtx) { + s16 sp26 = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + + if (sp26 == lastFrame) { + switch (this->unk_2E4) { + case 0: + this->unk_2E4 = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + this->actionFunc = func_80B5216C; + break; + + case 2: + this->unk_2E4 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actionFunc = func_80B5202C; + break; + } + } +} + +void func_80B51760(EnGk* this, GlobalContext* globalCtx) { + s16 sp2E = this->skelAnime.curFrame; + s16 lastFrame; + + if (this->unk_2E4 == 11) { + lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + if (sp2E == lastFrame) { + this->unk_2E4 = 5; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_2E4); + } + } else if (this->unk_2E4 == 10) { + lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + if (sp2E == lastFrame) { + this->unk_2E4 = 11; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_2E4); + } + } else { + if (Flags_GetSwitch(globalCtx, ENGK_GET_3F00(&this->actor))) { + gSaveContext.weekEventReg[40] |= 0x40; + this->actionFunc = func_80B51D9C; + return; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_1E4 |= 4; + this->unk_31C = func_80B50410(this, globalCtx); + func_801518B0(globalCtx, this->unk_31C, &this->actor); + this->actionFunc = func_80B51970; + if (this->unk_31C == 0xE81) { + this->unk_2E4 = 0; + this->unk_1E4 |= 2; + } + } else if (((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && + (gSaveContext.entranceIndex != 0xD010)) { + func_800B863C(&this->actor, globalCtx); + } + + if (this->unk_1E4 & 4) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + } +} + +void func_80B51970(EnGk* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if (((temp_v0 == 6) || (temp_v0 == 5)) && func_80147624(globalCtx)) { + if ((this->unk_31C == 0xE84) || (this->unk_31C == 0xE99)) { + ActorCutscene_Stop(this->unk_318); + this->unk_318 = ActorCutscene_GetAdditionalCutscene(this->unk_318); + ActorCutscene_SetIntentToPlay(this->unk_318); + this->actionFunc = func_80B51D9C; + return; + } + + if (this->unk_1E4 & 1) { + this->unk_1E4 &= ~1; + this->unk_1E4 &= ~4; + if (this->unk_2E4 == 10) { + this->unk_1E4 &= ~2; + } + this->actionFunc = func_80B51760; + return; + } + + this->unk_31C = func_80B50410(this, globalCtx); + func_801518B0(globalCtx, this->unk_31C, &this->actor); + if (this->unk_31C == 0xE80) { + this->unk_1E4 |= 2; + } else if (this->unk_31C == 0xE89) { + this->actionFunc = func_80B51B40; + } + } + + if (this->unk_1E4 & 2) { + func_801A4748(&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, sAnimations, 9); + } else { + func_80B51398(this, globalCtx); + } + } + } + + 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) { + func_80B50954(this); + } +} + +void func_80B51B40(EnGk* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if (temp_v0 == 6) { + if (func_80147624(globalCtx)) { + if (this->unk_1E4 & 1) { + this->unk_1E4 &= ~1; + this->unk_1E4 &= ~4; + + if (this->unk_2E4 == 10) { + this->unk_1E4 &= ~2; + } + + if (this->unk_31C == 0xE8F) { + globalCtx->nextEntranceIndex = 0xD010; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 3; + Parameter_AddMagic(globalCtx, + ((void)0, gSaveContext.unk_3F30) + (gSaveContext.doubleMagic * 0x30) + 0x30); + } else { + this->actionFunc = func_80B51760; + } + return; + } + + this->unk_31C = func_80B50710(this); + func_801518B0(globalCtx, this->unk_31C, &this->actor); + if (this->unk_31C == 0xE8C) { + this->unk_1E4 |= 2; + } + } + } else if ((temp_v0 == 4) && (func_80147624(globalCtx) != 0)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + this->unk_31C = 0xE8E; + func_801518B0(globalCtx, this->unk_31C, &this->actor); + break; + + case 1: + func_8019F230(); + this->unk_31C = 0xE8A; + func_801518B0(globalCtx, this->unk_31C, &this->actor); + break; + } + } + + if (this->unk_1E4 & 2) { + func_801A4748(&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, sAnimations, 9); + } else { + func_80B51398(this, globalCtx); + } + } + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void func_80B51D9C(EnGk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (ActorCutscene_GetCanPlayNext(this->unk_318)) { + ActorCutscene_StartAndSetFlag(this->unk_318, &this->actor); + if (this->unk_1E4 & 4) { + this->unk_1E4 &= ~4; + this->unk_2E4 = 6; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); + this->actionFunc = func_80B51EA4; + } else { + this->unk_1E4 |= 4; + if (player->transformation == PLAYER_FORM_GORON) { + this->unk_31C = 0xE84; + } else { + this->unk_31C = 0xE99; + } + func_801518B0(globalCtx, this->unk_31C, &this->actor); + this->actionFunc = func_80B51970; + } + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->unk_318); + } + func_80B50954(this); +} + +void func_80B51EA4(EnGk* this, GlobalContext* globalCtx) { + Vec3s sp38; + s16 sp36; + + if (this->path != NULL) { + func_80B50E14(this->path, this->unk_1EC, &this->actor.world.pos, &sp38); + Math_SmoothStepToS(&this->actor.world.rot.y, sp38.y, 5, 0x1000, 0x100); + this->actor.shape.rot.y = this->actor.world.rot.y; + sp36 = this->actor.shape.rot.y - sp38.y; + if (func_80B50C78(this, this->path, this->unk_1EC)) { + if (this->unk_1EC >= (this->path->count - 1)) { + ActorCutscene_Stop(this->unk_318); + Actor_MarkForDeath(&this->actor); + } else { + this->unk_1EC++; + } + } + + if (this->actor.bgCheckFlags & 8) { + sp38.y = this->actor.wallYaw; + } + + if (ABS_ALT(sp36) < 0x2AAA) { + Math_ApproachF(&this->actor.speedXZ, 3.0f, 0.2f, 0.5f); + } + Actor_MoveWithGravity(&this->actor); + } + func_80B50954(this); +} + +void func_80B51FD0(EnGk* this, GlobalContext* globalCtx) { + if (!(gSaveContext.weekEventReg[22] & 4)) { + if (this->unk_1E4 & 2) { + func_801A4748(&this->actor.projectedPos, NA_SE_EN_GOLON_KID_CRY - SFX_FLAG); + } else { + this->unk_1E4 |= 2; + } + } +} + +void func_80B5202C(EnGk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (globalCtx->csCtx.state == 0) { + func_80B51410(this, globalCtx); + } + + if (!func_80B50854(this, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + gSaveContext.weekEventReg[24] |= 0x80; + this->actionFunc = func_80B51698; + } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { + func_800B863C(&this->actor, globalCtx); + if (player->transformation == PLAYER_FORM_GORON) { + this->actor.textId = 0xE74; + } else { + this->actor.textId = 0xE76; + } + } + + if (this->unk_1E4 & 2) { + if ((globalCtx->msgCtx.ocarinaMode != 1) && (globalCtx->msgCtx.ocarinaMode != 3) && + (globalCtx->csCtx.state == 0)) { + func_801A4748(&this->actor.projectedPos, NA_SE_EN_GOLON_KID_CRY - SFX_FLAG); + } + } else { + this->unk_1E4 |= 2; + } + } +} + +void func_80B5216C(EnGk* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_80B51698; + } +} + +void func_80B521E8(EnGk* this, GlobalContext* globalCtx) { + s16 sp1E = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + + if (sp1E == lastFrame) { + this->unk_2E4 = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actionFunc = func_80B5227C; + } +} + +void func_80B5227C(EnGk* this, GlobalContext* globalCtx) { + s16 sp26 = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + + if ((sp26 + 1) == lastFrame) { + func_800B14D4(globalCtx, 20.0f, &this->actor.home.pos); + this->unk_350 = 60; + if (!(this->unk_1E4 & 0x80)) { + gSaveContext.weekEventReg[22] |= 4; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SIT_IMT); + this->unk_350 = 0x4000; + this->actionFunc = func_80B52654; + } +} + +void func_80B52340(EnGk* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_1E4 |= 4; + if (gSaveContext.eventInf[1] & 2) { + this->unk_31C = 0xE90; + this->actionFunc = func_80B52430; + } else { + this->unk_31C = 0xE93; + this->actionFunc = func_80B52430; + } + func_801518B0(globalCtx, this->unk_31C, &this->actor); + this->actor.flags &= ~ACTOR_FLAG_10000; + } else { + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8614(&this->actor, globalCtx, 100.0f); + } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void func_80B52430(EnGk* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + switch (this->unk_31C) { + case 0xE93: + this->unk_31C = 0xE89; + func_801518B0(globalCtx, this->unk_31C, &this->actor); + this->actionFunc = func_80B51B40; + return; + + case 0xE90: + this->unk_31C = 0xE91; + func_801518B0(globalCtx, this->unk_31C, &this->actor); + return; + + case 0xE91: + this->actionFunc = func_80B5253C; + return; + + case 0xE92: + this->unk_1E4 &= ~4; + this->actionFunc = func_80B51760; + return; + } + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void func_80B5253C(EnGk* this, GlobalContext* globalCtx) { + s32 sp24; + + if (gSaveContext.weekEventReg[41] & 8) { + sp24 = 0x93; + } else { + sp24 = 0x6A; + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + if (sp24 == 0x6A) { + gSaveContext.weekEventReg[41] |= 8; + } + this->actionFunc = func_80B525E0; + } else { + Actor_PickUp(&this->actor, globalCtx, sp24, 300.0f, 300.0f); + } +} + +void func_80B525E0(EnGk* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_31C = 0xE92; + func_801518B0(globalCtx, this->unk_31C, &this->actor); + this->actionFunc = func_80B52430; + } else { + func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + } +} + +void func_80B52654(EnGk* this, GlobalContext* globalCtx) { + this->unk_350 += 0x400; + if ((this->unk_1E4 & 0x80) && (globalCtx->csCtx.frames == 250)) { + gSaveContext.weekEventReg[22] |= 4; + } + + this->unk_354 = Math_SinS(this->unk_350) * 0.006f * 0.06f; + this->actor.scale.y = 0.006f - this->unk_354; + this->actor.scale.z = 0.006f - this->unk_354; + this->actor.scale.x = 0.006f + this->unk_354; + if (this->unk_350 == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLONKID_SNORE); + } +} + +void EnGk_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGk* this = THIS; + + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_gk_Skel_0079C0, &object_gk_Anim_00787C, this->jointTable, + this->morphTable, 20); + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + this->unk_2E2 = 20; + this->unk_2E0 = 0; + this->unk_1E4 = 0; + this->unk_354 = 0.006f; + Actor_SetScale(&this->actor, 0.006f); + this->actor.gravity = -1.0f; + + if (ENGK_GET_F(&this->actor) == ENGK_F_1) { + this->unk_2E4 = 5; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + if (globalCtx->sceneNum == SCENE_17SETUGEN2) { + if (Flags_GetSwitch(globalCtx, ENGK_GET_3F00(&this->actor))) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_318 = this->actor.cutscene; + this->path = func_8013D648(globalCtx, ENGK_GET_F0(&this->actor), 15); + this->actionFunc = func_80B51760; + } + } else if (globalCtx->sceneNum == SCENE_GORONRACE) { + if (gSaveContext.weekEventReg[33] & 0x80) { + if (gSaveContext.entranceIndex == 0xD010) { + this->actionFunc = func_80B51760; + } else if (gSaveContext.entranceIndex == 0xD020) { + this->actionFunc = func_80B52340; + } else { + this->actionFunc = func_80B51760; + } + } else { + Actor_MarkForDeath(&this->actor); + } + } else { + Actor_MarkForDeath(&this->actor); + } + } else if (ENGK_GET_F(&this->actor) == ENGK_F_2) { + if (!(gSaveContext.weekEventReg[22] & 4)) { + this->actionFunc = func_80B51FD0; + this->actor.draw = NULL; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags &= ~ACTOR_FLAG_1; + } else { + Actor_MarkForDeath(&this->actor); + } + } else if (!(gSaveContext.weekEventReg[22] & 4)) { + this->unk_2E4 = 0; + this->unk_318 = this->actor.cutscene; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_2000000; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actionFunc = func_80B5202C; + } else { + this->actionFunc = func_80B52654; + } +} + +void EnGk_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGk* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnGk_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGk* this = THIS; + + this->actionFunc(this, globalCtx); + + if ((ENGK_GET_F(&this->actor) == ENGK_F_1) || + ((ENGK_GET_F(&this->actor) == ENGK_F_0) && !(gSaveContext.weekEventReg[22] & 4))) { + func_80B507A0(this, globalCtx); + SkelAnime_Update(&this->skelAnime); + func_800E9250(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); + if (ENGK_GET_F(&this->actor) == ENGK_F_1) { + func_80B5123C(this, globalCtx); + } + func_80B50B38(this, globalCtx); + } + + if (ENGK_GET_F(&this->actor) == ENGK_F_0) { + func_80B51510(this, globalCtx); + } +} + +s32 EnGk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + return false; +} + +void EnGk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnGk* this = THIS; + Vec3f sp58 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp4C = { 0.0f, 0.0f, 0.0f }; + Vec3f sp40 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp34 = { 1100.0f, -100.0f, 0.0f }; + Vec3f sp28 = { 1100.0f, -100.0f, 0.0f }; + f32 phi_f0; + + sp34.x = 1100.0f; + sp34.z = 500.0f; + + sp28.x = 1100.0f; + sp28.z = -500.0f; + + if (this->unk_2E4 == 0) { + sp34.y = -100.0f; + sp28.y = -100.0f; + + sp40.x = 2.0f; + sp40.y = 5.8f; + sp40.z = 0.0f; + + sp4C = sp40; + sp4C.x *= -1.0f; + } else if ((this->unk_2E4 == 2) || (this->unk_2E4 == 9) || (this->unk_2E4 == 10) || (this->unk_2E4 == 11)) { + sp34.y = 400.0f; + sp28.y = 400.0f; + + sp40.x = 1.0f; + sp40.y = 0.8f; + sp40.z = 0.0f; + + sp4C = sp40; + sp4C.x *= -1.0f; + } + + if (limbIndex == 17) { + if (ENGK_GET_F(&this->actor) == ENGK_F_1) { + phi_f0 = 100.0f; + } else { + phi_f0 = 50.0f; + } + + this->actor.focus.pos.x = this->actor.world.pos.x; + this->actor.focus.pos.y = this->actor.world.pos.y + phi_f0; + this->actor.focus.pos.z = this->actor.world.pos.z; + + Matrix_MultiplyVector3fByState(&sp58, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&sp34, &this->unk_2E8); + Matrix_MultiplyVector3fByState(&sp28, &this->unk_2F4); + + Matrix_StatePush(); + + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp4C, &this->unk_30C); + Matrix_MultiplyVector3fByState(&sp40, &this->unk_300); + + Matrix_StatePop(); + } +} + +void EnGk_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnGk* this = THIS; + s32 phi_v0; + s32 phi_v1; + + switch (limbIndex) { + case 18: + if (this->unk_1E4 & 8) { + phi_v1 = true; + } else { + phi_v1 = false; + } + + if (this->unk_34E != 0) { + phi_v0 = true; + } else { + phi_v0 = false; + } + func_80B50ED4(this->unk_31E + this->unk_322 + 0x4000, + this->unk_320 + this->unk_324 + this->actor.shape.rot.y + 0x4000, &this->unk_328, + &this->unk_334, phi_v0, phi_v1); + + Matrix_StatePop(); + + Matrix_InsertTranslation(this->unk_328.x, this->unk_328.y, this->unk_328.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_334.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_334.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_334.z, MTXMODE_APPLY); + + Matrix_StatePush(); + break; + + case 9: + if (this->unk_1E4 & 8) { + phi_v1 = true; + } else { + phi_v1 = false; + } + + if (this->unk_34E != 0) { + phi_v0 = true; + } else { + phi_v0 = false; + } + func_80B50ED4(this->unk_322 + 0x4000, this->unk_324 + this->actor.shape.rot.y + 0x4000, &this->unk_33C, + &this->unk_348, phi_v0, phi_v1); + + Matrix_StatePop(); + + Matrix_InsertTranslation(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_348.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_348.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_348.z, MTXMODE_APPLY); + + Matrix_StatePush(); + break; + } +} + +TexturePtr D_80B533E4[] = { + object_gk_Tex_00F720, + object_gk_Tex_00FF20, + object_gk_Tex_010720, + object_gk_Tex_010F20, +}; + +void EnGk_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGk* this = THIS; + Vec3f sp5C; + Vec3f sp50; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if ((ENGK_GET_F(&this->actor) == ENGK_F_0) && (gSaveContext.weekEventReg[22] & 4)) { + Matrix_InsertXRotation_s(-0x4000, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_gk_DL_006688); + gSPDisplayList(POLY_OPA_DISP++, object_gk_DL_006680); + + func_8012C2DC(globalCtx->state.gfxCtx); + + sp5C = this->actor.world.pos; + sp50.x = 0.2f; + sp50.y = 0.2f; + sp50.z = 0.2f; + + func_800BC620(&sp5C, &sp50, 255, globalCtx); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B533E4[this->unk_2E0])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnGk_OverrideLimbDraw, EnGk_PostLimbDraw, + EnGk_TransformDraw, &this->actor); + + if (ENGK_GET_F(&this->actor) != ENGK_F_2) { + func_8012C2DC(globalCtx->state.gfxCtx); + if ((this->unk_2E4 == 0) || (this->unk_2E4 == 1) || (this->unk_2E4 == 2) || (this->unk_2E4 == 3) || + (this->unk_2E4 == 4)) { + sp5C.x = this->actor.world.pos.x - 15.0f; + sp5C.y = this->actor.world.pos.y; + sp5C.z = this->actor.world.pos.z; + + sp50.x = 0.2f; + sp50.y = 0.2f; + sp50.z = 0.2f; + } else { + sp5C = this->actor.world.pos; + sp50.x = 0.2f; + sp50.y = 0.2f; + sp50.z = 0.2f; + } + func_800BC620(&sp5C, &sp50, 255, globalCtx); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 88a71cb16..21863c66f 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.h +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.h @@ -7,11 +7,53 @@ struct EnGk; typedef void (*EnGkActionFunc)(struct EnGk*, GlobalContext*); +#define ENGK_GET_F(thisx) ((thisx)->params & 0xF) +#define ENGK_GET_F0(thisx) (((thisx)->params & 0xF0) >> 4) +#define ENGK_GET_3F00(thisx) (((thisx)->params & 0x3F00) >> 8) + +enum { + /* 0 */ ENGK_F_0, + /* 1 */ ENGK_F_1, + /* 2 */ ENGK_F_2, + /* 3 */ ENGK_F_3, + /* 4 */ ENGK_F_4, + /* 5 */ ENGK_F_5, +}; + typedef struct EnGk { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnGkActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x180]; + /* 0x01D8 */ Vec3s unk_1D8; + /* 0x01DE */ Vec3s unk_1DE; + /* 0x01E4 */ u16 unk_1E4; + /* 0x01E8 */ Path* path; + /* 0x01EC */ s32 unk_1EC; + /* 0x01F0 */ Vec3s jointTable[20]; + /* 0x01F0 */ Vec3s morphTable[20]; + /* 0x02E0 */ s16 unk_2E0; + /* 0x02E2 */ s16 unk_2E2; + /* 0x02E4 */ s16 unk_2E4; + /* 0x02E8 */ Vec3f unk_2E8; + /* 0x02F4 */ Vec3f unk_2F4; + /* 0x0300 */ Vec3f unk_300; + /* 0x030C */ Vec3f unk_30C; + /* 0x0318 */ s16 unk_318; + /* 0x031A */ u8 unk_31A; + /* 0x031B */ u8 unk_31B; + /* 0x031C */ u16 unk_31C; + /* 0x031E */ s16 unk_31E; + /* 0x0320 */ s16 unk_320; + /* 0x0322 */ s16 unk_322; + /* 0x0324 */ s16 unk_324; + /* 0x0328 */ Vec3f unk_328; + /* 0x0334 */ Vec3s unk_334; + /* 0x033C */ Vec3f unk_33C; + /* 0x0348 */ Vec3s unk_348; + /* 0x034E */ s16 unk_34E; + /* 0x0350 */ s16 unk_350; + /* 0x0354 */ f32 unk_354; } EnGk; // size = 0x358 extern const ActorInit En_Gk_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index fd1eea743..e378be114 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -14003,9 +14003,9 @@ 0x80B526FC:("EnGk_Init",), 0x80B529B8:("EnGk_Destroy",), 0x80B529E4:("EnGk_Update",), - 0x80B52AD4:("func_80B52AD4",), - 0x80B52AF0:("func_80B52AF0",), - 0x80B52D8C:("func_80B52D8C",), + 0x80B52AD4:("EnGk_OverrideLimbDraw",), + 0x80B52AF0:("EnGk_PostLimbDraw",), + 0x80B52D8C:("EnGk_TransformDraw",), 0x80B52F74:("EnGk_Draw",), 0x80B53840:("func_80B53840",), 0x80B539CC:("func_80B539CC",), diff --git a/undefined_syms.txt b/undefined_syms.txt index d7ca4b661..d0ef176fd 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1372,13 +1372,6 @@ D_0600A808 = 0x0600A808; D_0600F578 = 0x0600F578; D_0600F6C0 = 0x0600F6C0; -// ovl_En_Gk - -D_06006680 = 0x06006680; -D_06006688 = 0x06006688; -D_0600787C = 0x0600787C; -D_060079C0 = 0x060079C0; - // ovl_En_Goron_Oyu D_06000988 = 0x06000988; From 77cfd399d0dc4124c72b53f6385f063e601145ed Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Fri, 4 Mar 2022 21:14:52 -0300 Subject: [PATCH 057/257] `z_demo` with 4 NON_MATCHINGs (#514) * starting * a bunch * and another bunch * a bunch * Match func_800EB1DC * func_800EB4B4 * func_800EB6F8 * 2 more * fix prototype of a random kankyo function * func_800EBD60 non matching * func_800EC678 matched? * func_800EC6D4 * break * func_800ECD7C * A bunch of functions * func_800EE200 * func_800EDF78 and func_800EE0CC * func_800EDBE0 NON_MATCHING * Cutscene_Init NON_MATCHING * func_800EA324 NON_EQUIVALENT * Fix warnings * func_800EC924 NON_EQUIVALENT * Cutscene_ProcessCommands NON_EQUIVALENT * Format * Split z_demo data and import it * Import bss * Match func_800EB364 * Rename Cutscene_Command_SetTime * Improve Cutscene_ProcessCommands a bit (still not equivalent, probably) * Improve Cutscene_ProcessCommands thanks to engineer and anon * Cutscene_ProcessCommands NON_MATCHING * Name some commands * Fix * Renames based on Engineer knowledge of Audio stuff * More command names * Cutscene_Command_GiveTatlToPlayer * Some cutscene commands macros * more command macros * Macros for unknown commands * Improve Cutscene_Command_Textbox a bit * Rename stuff * Name Terminator and Camera * MOTIONBLUR * Macros for textbox commands * CS_PLAYER_ACTION_LIST * A few macro renames * Small cleaning * A bit more of cleanup * Rumble * Entrance comments in func_800EB6F8 * Some var renames * CS_CMD_FADESCREEN * More clean up * Clean functions protos * Move CutsceneStateHandler out of z64.h * Cutscene_DoNothing * Cutscene_IsPlayingCs & Cutscene_GetSceneSetupIndex * And more renames * name some stuff in the cutscenecontext struct * npcActionIndex->actorActionIndex * Undo names of CS_STATE_ enum * Name Cutscene_ActorTranslate family of functions * small docs pass * sfxconvert and format * Hopefully last cleanup * Add some missing functions to actorfixer * Fix merge issues and remove trailing commas * Cutscene commands fix * Cutscene_Command_Misc improved by engineer * Update src/code/z_demo.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Address review * bss * Match Cutscene_Command_Textbox by anon58 * Fix merge issues * Match Cutscene_Command_Misc by @hensldm * review * float time macros * fix merge issues * format * Fix building assets * fix merge issues * format * Fix * format * fix merge issues * fix * fix * format * fix issues and run format * bss * Fix conflicts, bss and formatter * Update include/functions.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update include/functions.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update include/z64.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update include/z64cutscene.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update include/z64cutscene.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update include/z64cutscene.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_demo.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_demo.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_demo.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_demo.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_demo.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * address review and fix some stuff * fix merge problems * more fixes and format * Fixes * Update include/functions.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update include/functions.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_demo.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_demo.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_demo.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_demo.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Engineer suggestions * format * Elliptic review * Use dec for ShrinkWindow_SetLetterboxTarget * add a few comments * Cutscene_Command_ChooseCreditsScenes * Update src/code/z_demo.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * format * some cleanups and some comments * change actorActionCmd from hex to dec in the codebase * minor comment on textboxcmd * ahhhh * Update src/code/z_demo.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * brackets * minor comments * rewording * im dumb * brackets * another bracket * Dawn of the New Day * Update src/code/z_demo.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * fixes * Cutscene_Command_TransitionFX by Anon Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> --- Makefile | 8 +- .../scenes/Z2_LOST_WOODS/Z2_LOST_WOODS.xml | 2 +- include/command_macros_base.h | 4 +- include/functions.h | 109 +- include/macros.h | 13 +- include/regs.h | 4 +- include/unk.h | 4 +- include/variables.h | 23 +- include/z64.h | 59 +- include/z64actor.h | 2 +- include/z64cutscene.h | 128 +- include/z64cutscene_commands.h | 568 +++++- include/z64item.h | 2 +- include/z64light.h | 2 +- include/z64scene.h | 16 +- spec | 1 - src/boot_O2_g3/CIC6105.c | 1 - src/boot_O2_g3/boot_main.c | 1 - src/boot_O2_g3/idle.c | 1 - src/code/audio/code_8019AF00.c | 2 +- src/code/z_demo.c | 1677 ++++++++++++++++- src/code/z_kankyo.c | 4 +- src/code/z_message.c | 2 +- src/code/z_room.c | 2 +- src/code/z_scene_proc.c | 1 - src/libultra/flash/osFlash.c | 15 +- .../ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c | 4 +- .../ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c | 6 +- .../actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c | 4 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 26 +- src/overlays/actors/ovl_Boss_04/z_boss_04.c | 6 +- src/overlays/actors/ovl_Boss_06/z_boss_06.c | 18 +- .../actors/ovl_Dm_Char00/z_dm_char00.c | 55 +- .../actors/ovl_Dm_Char01/z_dm_char01.c | 11 +- .../actors/ovl_Dm_Char05/z_dm_char05.c | 157 +- src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c | 10 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 57 +- .../actors/ovl_Door_Warp1/z_door_warp1.c | 43 +- .../ovl_En_Akindonuts/z_en_akindonuts.c | 16 +- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 16 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 4 +- .../actors/ovl_En_Bba_01/z_en_bba_01.c | 2 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 18 +- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 4 +- src/overlays/actors/ovl_En_Bom/z_en_bom.c | 32 +- .../ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c | 10 +- .../actors/ovl_En_Bomjimb/z_en_bomjimb.c | 6 +- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.c | 6 +- .../actors/ovl_En_Cne_01/z_en_cne_01.c | 2 +- src/overlays/actors/ovl_En_Dai/z_en_dai.c | 11 +- src/overlays/actors/ovl_En_Dg/z_en_dg.c | 10 +- .../actors/ovl_En_Dinofos/z_en_dinofos.c | 10 +- src/overlays/actors/ovl_En_Dnk/z_en_dnk.c | 4 +- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 40 +- src/overlays/actors/ovl_En_Dno/z_en_dno.h | 2 +- src/overlays/actors/ovl_En_Dnp/z_en_dnp.c | 12 +- src/overlays/actors/ovl_En_Dnq/z_en_dnq.c | 12 +- src/overlays/actors/ovl_En_Dns/z_en_dns.c | 18 +- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 44 +- .../actors/ovl_En_Elforg/z_en_elforg.c | 4 +- src/overlays/actors/ovl_En_Fall/z_en_fall.c | 60 +- .../actors/ovl_En_Fishing/z_en_fishing.c | 62 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 42 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 134 +- src/overlays/actors/ovl_En_Gb2/z_en_gb2.c | 32 +- src/overlays/actors/ovl_En_Geg/z_en_geg.c | 16 +- src/overlays/actors/ovl_En_Gg/z_en_gg.c | 16 +- src/overlays/actors/ovl_En_Giant/z_en_giant.c | 39 +- .../actors/ovl_En_Ginko_Man/z_en_ginko_man.c | 124 +- src/overlays/actors/ovl_En_GirlA/z_en_girla.h | 2 +- src/overlays/actors/ovl_En_Gk/z_en_gk.c | 34 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 4 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 28 +- src/overlays/actors/ovl_En_Gs/z_en_gs.c | 7 +- src/overlays/actors/ovl_En_Hg/z_en_hg.c | 21 +- src/overlays/actors/ovl_En_Hgo/z_en_hgo.c | 48 +- .../actors/ovl_En_Hint_Skb/z_en_hint_skb.c | 32 +- src/overlays/actors/ovl_En_In/z_en_in.c | 2 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 2 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 24 +- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 4 +- .../actors/ovl_En_Kendo_Js/z_en_kendo_js.c | 46 +- src/overlays/actors/ovl_En_Kgy/z_en_kgy.c | 2 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 130 +- .../actors/ovl_En_Ma_Yto/z_en_ma_yto.c | 140 +- .../actors/ovl_En_Ma_Yts/z_en_ma_yts.c | 44 +- src/overlays/actors/ovl_En_Mag/z_en_mag.c | 2 +- .../actors/ovl_En_Minifrog/z_en_minifrog.c | 10 +- src/overlays/actors/ovl_En_Mm2/z_en_mm2.c | 2 +- src/overlays/actors/ovl_En_Nnh/z_en_nnh.c | 2 +- src/overlays/actors/ovl_En_Osn/z_en_osn.c | 18 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 8 +- src/overlays/actors/ovl_En_Ot/z_en_ot.c | 6 +- .../actors/ovl_En_Pamera/z_en_pamera.c | 32 +- .../actors/ovl_En_Rail_Skb/z_en_rail_skb.c | 25 +- .../actors/ovl_En_Railgibud/z_en_railgibud.c | 30 +- src/overlays/actors/ovl_En_Rr/z_en_rr.c | 2 +- .../actors/ovl_En_Scopenuts/z_en_scopenuts.c | 10 +- .../actors/ovl_En_Sellnuts/z_en_sellnuts.c | 12 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 13 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 8 +- src/overlays/actors/ovl_En_Ssh/z_en_ssh.c | 2 +- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 10 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 14 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 132 +- .../ovl_En_Talk_Gibud/z_en_talk_gibud.c | 26 +- .../actors/ovl_En_Thiefbird/z_en_thiefbird.c | 8 +- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 28 +- src/overlays/actors/ovl_En_Toto/z_en_toto.c | 15 +- src/overlays/actors/ovl_En_Trt/z_en_trt.c | 24 +- src/overlays/actors/ovl_En_Trt2/z_en_trt2.c | 10 +- .../ovl_En_Weather_Tag/z_en_weather_tag.c | 20 +- .../actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c | 52 +- src/overlays/actors/ovl_En_Yb/z_en_yb.c | 8 +- src/overlays/actors/ovl_En_Zob/z_en_zob.c | 41 +- src/overlays/actors/ovl_En_Zog/z_en_zog.c | 10 +- .../actors/ovl_En_Zoraegg/z_en_zoraegg.c | 55 +- .../actors/ovl_En_Zoraegg/z_en_zoraegg.h | 2 +- src/overlays/actors/ovl_En_Zos/z_en_zos.c | 35 +- src/overlays/actors/ovl_En_Zot/z_en_zot.c | 26 +- src/overlays/actors/ovl_En_Zov/z_en_zov.c | 21 +- src/overlays/actors/ovl_En_Zow/z_en_zow.c | 2 +- .../actors/ovl_Obj_Ghaka/z_obj_ghaka.c | 4 +- .../actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c | 12 +- .../actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c | 2 +- .../ovl_Obj_Moon_Stone/z_obj_moon_stone.c | 2 +- .../actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c | 22 +- .../ovl_Obj_Tokei_Step/z_obj_tokei_step.c | 9 +- .../actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c | 36 +- .../ovl_Object_Kankyo/z_object_kankyo.c | 4 +- .../gamestates/ovl_daytelop/z_daytelop.h | 4 +- tools/actorfixer.py | 28 +- tools/disasm/files.txt | 1 + tools/disasm/functions.txt | 76 +- tools/disasm/variables.txt | 12 +- tools/sizes/code_functions.csv | 76 +- tools/warnings_count/.gitignore | 1 + 137 files changed, 3837 insertions(+), 1599 deletions(-) diff --git a/Makefile b/Makefile index 98aa5b1b4..c0569cbe1 100644 --- a/Makefile +++ b/Makefile @@ -133,6 +133,8 @@ ASM_DIRS := $(shell find asm -type d -not -path "asm/non_matchings*") $(shell fi ## Assets binaries (PNGs, JPGs, etc) ASSET_BIN_DIRS := $(shell find assets/* -type d -not -path "assets/xml*") +# Prevents building C files that will be #include'd +ASSET_BIN_DIRS_C_FILES := $(shell find assets/* -type d -not -path "assets/xml*" -not -path "assets/code*" -not -path "assets/overlays*") ASSET_FILES_XML := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.xml)) ASSET_FILES_BIN := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.bin)) @@ -144,7 +146,7 @@ TEXTURE_FILES_JPG := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.jpg)) TEXTURE_FILES_OUT := $(foreach f,$(TEXTURE_FILES_PNG:.png=.inc.c),build/$f) \ $(foreach f,$(TEXTURE_FILES_JPG:.jpg=.jpg.inc.c),build/$f) \ -C_FILES := $(foreach dir,$(SRC_DIRS) $(ASSET_BIN_DIRS),$(wildcard $(dir)/*.c)) +C_FILES := $(foreach dir,$(SRC_DIRS) $(ASSET_BIN_DIRS_C_FILES),$(wildcard $(dir)/*.c)) S_FILES := $(shell grep -F "build/asm" spec | sed 's/.*build\/// ; s/\.o\".*/.s/') \ $(shell grep -F "build/data" spec | sed 's/.*build\/// ; s/\.o\".*/.s/') BASEROM_FILES := $(shell grep -F "build/baserom" spec | sed 's/.*build\/// ; s/\.o\".*//') @@ -174,7 +176,7 @@ build/src/libultra/flash/%.o: MIPS_VERSION := -mips1 build/src/code/audio/%.o: OPTFLAGS := -O2 -build/assets/%.o: OPTFLAGS := +build/assets/%.o: OPTFLAGS := -O1 # file flags build/src/boot_O2_g3/fault.o: CFLAGS += -trapuv @@ -205,6 +207,8 @@ build/src/overlays/fbdemos/%.o: CC := python3 tools/asm-processor/build.py $(CC) build/src/overlays/gamestates/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- build/src/overlays/kaleido_scope/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/assets/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- + #### Main Targets ### uncompressed: $(ROM) diff --git a/assets/xml/scenes/Z2_LOST_WOODS/Z2_LOST_WOODS.xml b/assets/xml/scenes/Z2_LOST_WOODS/Z2_LOST_WOODS.xml index 066cbe10e..0c41a1b29 100644 --- a/assets/xml/scenes/Z2_LOST_WOODS/Z2_LOST_WOODS.xml +++ b/assets/xml/scenes/Z2_LOST_WOODS/Z2_LOST_WOODS.xml @@ -1,5 +1,5 @@ - + diff --git a/include/command_macros_base.h b/include/command_macros_base.h index bb5ce1648..4a866c29e 100644 --- a/include/command_macros_base.h +++ b/include/command_macros_base.h @@ -17,9 +17,9 @@ #define CMD_W(a) (a) #ifdef __GNUC__ -#define CMD_F(a) {.f = (a)} +#define CMD_F(a) .f = (a) #else -#define CMD_F(a) {(a)} +#define CMD_F(a) (a) #endif #define CMD_PTR(a) (uintptr_t)(a) diff --git a/include/functions.h b/include/functions.h index 542a753bb..40ec3c1de 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1396,55 +1396,24 @@ DebugDispObject* DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, // void func_800E9DBC(void); // void func_800E9E94(void); void func_800E9F78(GraphicsContext* gfxCtx); + void Cutscene_Init(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_800EA0D4(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_800EA0EC(GlobalContext* globalCtx, CutsceneContext* csCtx); -void Cutscene_StepCutscene1(GlobalContext* globalCtx, CutsceneContext* csCtx); -void Cutscene_StepCutscene2(GlobalContext* globalCtx, CutsceneContext* csCtx); -void Cutscene_Nop800EA210(GlobalContext* globalCtx, CutsceneContext* csCtx); -s32 func_800EA220(GlobalContext* globalCtx, CutsceneContext* csCtx, f32 target); -void func_800EA258(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_800EA2B8(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_800EA324(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EABAC(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdEnvLighting* cmd); -void func_800EAC08(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdMusicChange* cmd); -void func_800EAC44(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdMusicChange* cmd); -void func_800EAC94(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdMusicFade* cmd); -void func_800EAD14(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EAD48(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EAD7C(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EADB0(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EAECC(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EAF20(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdUnk190* cmd); -void func_800EAFE0(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdUnk9B* cmd); -void func_800EB1DC(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdDayTime* cmd); -void func_800EB364(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EB4B4(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EB6F8(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EBB68(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EBCD0(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EBD60(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -s32 func_800EC678(GlobalContext* globalCtx, CsCmdUnk5A* cmd); -// u32 func_800EC6D4(void); -void func_800EC924(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdTextbox* cmd); -void func_800ECD7C(CutsceneContext* csCtx, u8** cutscenePtr, s16 index); -void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cutscenePtr, u16* commandReadHead); -void func_800ED980(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_800ED9C4(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_800EDA04(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_800EDA84(GlobalContext* globalCtx, CutsceneContext* csCtx); +void Cutscene_Start(GlobalContext* globalCtx, CutsceneContext* csCtx); +void Cutscene_End(GlobalContext* globalCtx, CutsceneContext* csCtx); +void Cutscene_Update1(GlobalContext* globalCtx, CutsceneContext* csCtx); +void Cutscene_Update2(GlobalContext* globalCtx, CutsceneContext* csCtx); void func_800EDBE0(GlobalContext* globalCtx); -void nop_800EDDB0(GlobalContext* globalCtx); -// void func_800EDDBC(void); -void func_800EDDCC(GlobalContext* globalCtx, u32 uParm2); -void func_800EDE34(Actor* actor, GlobalContext* globalCtx, s32 param_3); -void func_800EDF24(Actor* actor, GlobalContext* globalCtx, u32 arg2); -void func_800EDF78(Actor* actor, GlobalContext* globalCtx, s32 iParm3); -void func_800EE0CC(Actor* actor, GlobalContext* globalCtx, s32 iParm3); -s32 func_800EE1D8(GlobalContext* globalCtx); -u32 func_800EE200(GlobalContext* globalCtx, u16 uParm2); -u32 func_800EE29C(GlobalContext* globalCtx, u16 uParm2); -u32 func_800EE2F4(GlobalContext* globalCtx); +void func_800EDDB0(GlobalContext* globalCtx); +void Cutscene_LoadCutsceneData(GlobalContext* globalCtx, u8 csIndex); +void Cutscene_ActorTranslate(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex); +void Cutscene_ActorTranslateAndYaw(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex); +void Cutscene_ActorTranslateAndYawSmooth(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex); +void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex); +s32 Cutscene_GetSceneSetupIndex(GlobalContext* globalCtx); +s32 Cutscene_GetActorActionIndex(GlobalContext* globalCtx, u16 actorActionCmd); +s32 Cutscene_CheckActorAction(GlobalContext* globalCtx, u16 actorActionCmd); +u8 Cutscene_IsPlaying(GlobalContext* globalCtx); + void GetItem_Draw(GlobalContext* globalCtx, s16 index); void func_800EE364(GlobalContext* globalCtx, s16 index); void func_800EE400(GlobalContext* globalCtx, s16 index); @@ -1506,7 +1475,7 @@ s16 ActorCutscene_GetLength(s16 index); s32 func_800F2138(s8 arg0); s32 func_800F2178(s16 arg0); s16 ActorCutscene_GetCurrentCamera(s16 index); -// void func_800F21CC(void); +s16 func_800F21CC(void); s32 func_800F22C4(s16 param_1, Actor* actor); void ActorCutscene_SetReturnCamera(s16 index); // void func_800F23E0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); @@ -1546,7 +1515,7 @@ void Font_LoadOrderedFont(Font* font); // void func_800F50D4(void); void Kankyo_Init(GlobalContext* globalCtx, EnvironmentContext* envCtx); u32 func_800F5954(u8* param_1, u32 param_2, u32 param_3, u8 param_4, u8 param_5); -f32 func_800F5A8C(u16 arg0, u16 arg1, u16 arg2, GlobalContext* globalContext); +f32 Environment_LerpWeight(u16 max, u16 min, u16 val); // void func_800F5B10(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); // void func_800F5CD0(void); void func_800F6834(GlobalContext* globalCtx, s32 waterLightsIndex); @@ -1574,7 +1543,7 @@ void func_800FAAB4(GlobalContext* globalCtx, u8 arg1); // void func_800FAC20(void); // void func_800FAF74(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); // void func_800FB010(void); -void func_800FB320(GlobalContext* globalCtx, u8 param_2); +void Environment_AddLightningBolts(GlobalContext* globalCtx, u8 num); // void func_800FB388(void); void func_800FB758(GlobalContext* globalCtx); // void func_800FB9B4(void); @@ -2630,7 +2599,7 @@ u32 Sram_CalcChecksum(u8* data, u32 length); // void Sram_GenerateRandomSaveFields(void); void func_80144890(void); void Sram_InitDebugSave(void); -// void func_80144A94(void); +void func_80144A94(SramContext* sramCtx); // void func_80144E78(void); // void func_8014546C(void); // void func_80145698(void); @@ -2642,8 +2611,8 @@ void func_80146580(s32 param_1, SramContext* param_2, s32 param_3); void func_80146E40(GameState* gameState, SramContext* sramCtx); void Sram_Alloc(GameState* gameState, SramContext* sramCtx); // void func_80146EBC(SramContext* param_1, UNK_TYPE4 param_2, UNK_TYPE4 param_3); -// void func_80146EE8(void); -// void func_80146F5C(void); +void func_80146EE8(GlobalContext* globalCtx); +void func_80146F5C(GlobalContext* globalCtx); // void func_80147008(void); void func_80147020(SramContext* param_1); void func_80147068(SramContext* param_1); @@ -2655,8 +2624,8 @@ void func_80147198(SramContext* param_1); // void Sram_nop8014750C(UNK_TYPE4 param_1); // void func_80147520(void); void func_80147564(GlobalContext* globalCtx); -u32 func_80147624(GlobalContext* globalCtx); -u32 func_80147734(GlobalContext* globalCtx); +s32 func_80147624(GlobalContext* globalCtx); +s32 func_80147734(GlobalContext* globalCtx); void func_801477B4(GlobalContext* globalCtx); // void func_80147818(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); // void func_80147F18(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); @@ -2685,7 +2654,7 @@ void func_8014ADBC(GlobalContext* globalCtx, UNK_PTR puParm2); // void func_80150A84(void); void func_80150D08(GlobalContext* globalCtx, u32 uParm2); // void func_801514B0(void); -void func_801518B0(GlobalContext* globalCtx, u16 textId, Actor* Actor); +void Message_StartTextbox(GlobalContext* globalCtx, u16 textId, Actor* Actor); void func_80151938(GlobalContext* globalCtx, u16 textId); void func_80151A68(GlobalContext* globalCtx, u16 textId); void func_80151BB4(GlobalContext* globalCtx, u32 uParm2); @@ -2739,13 +2708,13 @@ void ShrinkWindow_Destroy(void); void ShrinkWindow_Update(s32 framerateDivisor); void ShrinkWindow_Draw(GraphicsContext* gfxCtx); // void func_80161180(void); -// void func_8016119C(void); +void func_8016119C(Camera* camera, struct_801F4D48* arg1); // void func_8016122C(void); // void func_801612B8(void); -// void func_80161998(void); +s32 func_80161998(UNK_PTR arg0, struct_801F4D48* arg1); // s32 func_80161BAC(void); -// void func_80161BE0(void); -// void func_80161C0C(void); +void func_80161BE0(s16 arg0); +void func_80161C0C(void); // void func_80161C20(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_80161E4C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_801620CC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); @@ -2808,7 +2777,7 @@ void func_80165438(UNK_PTR param_1); // void func_80165608(void); // void func_80165630(void); void func_80165658(u32 arg0); -void func_8016566C(u32 arg0); +void func_8016566C(s32 arg0); void func_80165690(void); // void func_801656A4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); // void func_80165DCC(void); @@ -3616,7 +3585,7 @@ void func_8019C300(s32 arg0); // void func_8019D488(void); // void func_8019D4F8(void); // void func_8019D600(void); -// void func_8019D758(void); +void func_8019D758(void); // void func_8019D864(void); // void func_8019D8B4(void); // void func_8019D8E4(void); @@ -3700,7 +3669,7 @@ void func_801A1FB4(u8 playerIdx, Vec3f* pos, u16 seqId, f32 maxDist); void func_801A246C(u8 param_1, u8 param_2); // void func_801A2544(void); // void func_801A257C(void); -// void func_801A25E4(void); +void func_801A25E4(u16 seqId, u8 dayMinusOne); // void func_801A2670(void); // void func_801A2778(void); // void func_801A27E8(void); @@ -3709,8 +3678,8 @@ void func_801A29D4(UNK_TYPE arg0, f32 arg1, UNK_TYPE arg2); void func_801A2BB8(s32 seqId); void func_801A2C20(void); // void func_801A2C44(void); -// void func_801A2C88(void); -// void func_801A2D54(void); +void func_801A2C88(u16 seqId); +void func_801A2D54(u16 seqId); s32 Audio_IsSequencePlaying(u8 seqId); void func_801A2E54(s32 param_1); void func_801A2ED8(void); @@ -3723,7 +3692,7 @@ void func_801A31EC(u16 seqId, s8 arg1, u8 arg2); // void func_801A3238(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); // void func_801A32CC(void); // void func_801A3590(void); -// void func_801A3950(void); +u8 func_801A3950(s32 playerIndex, s32 isChannelIOSet); u8 func_801A39F8(void); // void func_801A3A7C(void); // void func_801A3AC0(void); @@ -3735,7 +3704,7 @@ void func_801A3CD8(s8 param_1); // void func_801A3D98(void); // void func_801A3E38(void); // void func_801A3EC0(void); -void func_801A3F54(u8 flag); +void Audio_SetCutsceneFlag(u8 flag); // void func_801A3F6C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_801A3FB4(void); // void func_801A3FFC(UNK_TYPE1 param_1); @@ -3748,16 +3717,16 @@ void audio_setBGM(u32 bgmID); // void func_801A4324(void); // void func_801A4348(void); // void func_801A4380(void); -// void func_801A4428(void); +void func_801A4428(u8 reverbIndex); void Audio_PreNMI(void); // void func_801A44C4(void); // void func_801A44D4(void); s32 func_801A46F8(void); void func_801A4748(Vec3f* pos, u16 sfxId); void func_801A479C(Vec3f* arg0, u16 sfxId, s32 arg2); -// void func_801A47DC(void); +void func_801A47DC(u8 channelIndexRange, u8 port, u8 val); // void func_801A48E0(void); -void func_801A4A28(s32 arg0); +void func_801A4A28(u8 natureSeqId); // void func_801A4B80(void); void func_801A4C30(void); // void func_801A4C54(void); diff --git a/include/macros.h b/include/macros.h index c5a3a061d..d986dd78e 100644 --- a/include/macros.h +++ b/include/macros.h @@ -1,5 +1,5 @@ -#ifndef _MACROS_H_ -#define _MACROS_H_ +#ifndef MACROS_H +#define MACROS_H #include "libc/stdint.h" #include "ultra64/convert.h" @@ -49,9 +49,16 @@ #define CURRENT_DAY (((void)0, gSaveContext.day) % 5) -#define CLOCK_TIME(hr, min) ((s32)(((hr) * 60 + (min)) * 0x10000 / (24 * 60))) +#define TIME_TO_MINUTES(time) (s32)((time) * ((24 * 60) / 0x10000)) +#define CLOCK_TIME(hr, min) (s32)(((hr) * 60 + (min)) * 0x10000 / (24 * 60)) #define CLOCK_TIME_MINUTE (CLOCK_TIME(0, 1)) +#define TIME_TO_MINUTES_F(time) ((time) * ((24.0f * 60.0f) / 0x10000)) +#define CLOCK_TIME_F(hr, min) (((hr) * 60.0f + (min)) * (0x10000 / (24.0f * 60.0f))) + +#define TIME_TO_MINUTES_ALT_F(time) ((time) / (24.0f * 60.0f / 0x10000)) +#define CLOCK_TIME_ALT_F(hr, min) (((hr) * 60.0f + (min)) / (24.0f * 60.0f / 0x10000)) + #define SLOT(item) gItemSlots[item] #define AMMO(item) gSaveContext.inventory.ammo[SLOT(item)] #define INV_CONTENT(item) gSaveContext.inventory.items[SLOT(item)] diff --git a/include/regs.h b/include/regs.h index e39e53d69..9942242a7 100644 --- a/include/regs.h +++ b/include/regs.h @@ -1,8 +1,8 @@ /* Header taken as placeholder from OoT sister project */ /* Confirm as needed */ -#ifndef _REGS_H_ -#define _REGS_H_ +#ifndef REGS_H +#define REGS_H #define REG_GROUPS 29 // number of REG groups, i.e. REG, SREG, OREG, etc. #define REG_PAGES 6 diff --git a/include/unk.h b/include/unk.h index eb31a3874..0510fcd6a 100644 --- a/include/unk.h +++ b/include/unk.h @@ -1,5 +1,5 @@ -#ifndef _UNK_H_ -#define _UNK_H_ +#ifndef UNK_H +#define UNK_H #include "PR/ultratypes.h" diff --git a/include/variables.h b/include/variables.h index adbc8eb10..9ddad27f9 100644 --- a/include/variables.h +++ b/include/variables.h @@ -869,14 +869,9 @@ extern EffectShieldParticleInit shieldParticleInitWood; // extern UNK_TYPE1 D_801BB0DC; // extern UNK_TYPE2 D_801BB0FC; // extern UNK_TYPE1 D_801BB100; -// extern UNK_TYPE2 D_801BB124; -// extern UNK_TYPE2 D_801BB128; + extern u8 D_801BB12C; -// extern UNK_TYPE1 D_801BB130; -extern cutscene_update_func sCsStateHandlers1[5]; -extern cutscene_update_func sCsStateHandlers2[5]; -// extern UNK_TYPE2 D_801BB15C; -// extern UNK_TYPE4 D_801BB160; + extern s801BB170 D_801BB170[118]; // extern UNK_TYPE1 D_801BC210; extern Gfx D_801BC240[9]; @@ -3193,15 +3188,11 @@ extern GameInfo* gGameInfo; // extern UNK_TYPE1 D_801F3F80; // extern UNK_TYPE1 D_801F3F83; // extern UNK_TYPE1 D_801F48C8; -// extern UNK_TYPE1 D_801F4D40; -// extern UNK_TYPE2 D_801F4D42; -// extern UNK_TYPE1 D_801F4D48; -// extern UNK_TYPE1 D_801F4DC8; -// extern UNK_TYPE1 D_801F4DCA; -// extern UNK_TYPE2 D_801F4DCC[8]; -// extern UNK_TYPE1 D_801F4DDC; -// extern UNK_TYPE1 D_801F4DE0; + +extern UNK_TYPE D_801F4DDC; +extern u8 D_801F4DE0; extern s16 D_801F4DE2; + extern ActorCutscene* actorCutscenes; extern s16 actorCutsceneCount; extern u8 actorCutsceneWaiting[16]; @@ -3220,7 +3211,7 @@ extern Vec3f D_801F4E50; extern f32 D_801F4E5C; extern f32 D_801F4E60; extern s16 D_801F4E64; -// extern UNK_TYPE1 D_801F4E68; +extern u8 D_801F4E68; extern f32 D_801F4E70; // extern UNK_TYPE1 D_801F4E74; extern u16 D_801F4E78; diff --git a/include/z64.h b/include/z64.h index 44d4f6ab4..4c875ca7e 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1,5 +1,5 @@ -#ifndef _Z64_H_ -#define _Z64_H_ +#ifndef Z64_H +#define Z64_H #include "libc/math.h" #include "libc/stdarg.h" @@ -108,24 +108,6 @@ typedef struct { /* 0x8 */ CameraModeParams* modes; } CameraStateParams; // size = 0xC -typedef struct { - /* 0x00 */ u8 sceneCsCount; - /* 0x04 */ void* segment; - /* 0x08 */ u8 state; - /* 0x0C */ f32 unk_0C; - /* 0x10 */ u16 frames; - /* 0x12 */ u16 unk_12; - /* 0x14 */ s32 unk_14; - /* 0x18 */ u16 unk_18; - /* 0x1A */ u8 unk_1A; - /* 0x1B */ u8 unk_1B; - /* 0x1C */ CutsceneCameraPoint* atPoints; - /* 0x20 */ CutsceneCameraPoint* eyePoints; - /* 0x24 */ CsCmdActorAction* linkAction; - /* 0x28 */ CsCmdActorAction* npcActions[10]; // "npcdemopnt" - /* 0x50 */ CutsceneEntry* sceneCsList; -} CutsceneContext; // size = 0x54 - typedef struct { /* 0x0 */ s16 x; /* 0x2 */ s16 y; @@ -740,7 +722,7 @@ typedef struct { /* 0x80 */ OSMesg unk_80; /* 0x84 */ f32 unk_84; /* 0x88 */ f32 unk_88; - /* 0x8C */ LightSettings2 unk_8C; + /* 0x8C */ EnvLightSettings lightSettings; /* 0xA8 */ f32 unk_A8; /* 0xAC */ Vec3s windDir; /* 0xB4 */ f32 windSpeed; @@ -749,18 +731,18 @@ typedef struct { /* 0xC0 */ u8 unk_C0; /* 0xC1 */ u8 unk_C1; /* 0xC2 */ u8 unk_C2; - /* 0xC3 */ u8 unk_C3; + /* 0xC3 */ u8 lightSettingOverride; /* 0xC4 */ LightSettings unk_C4; /* 0xDA */ u16 unk_DA; - /* 0xDC */ f32 unk_DC; + /* 0xDC */ f32 lightBlend; /* 0xE0 */ u8 unk_E0; /* 0xE1 */ u8 unk_E1; /* 0xE2 */ s8 unk_E2; /* 0xE3 */ u8 unk_E3; // modified by unused func in EnWeatherTag /* 0xE4 */ u8 unk_E4; - /* 0xE5 */ u8 unk_E5; - /* 0xE6 */ u8 unk_E6[4]; - /* 0xEA */ u8 unk_EA; + /* 0xE5 */ u8 fillScreen; + /* 0xE6 */ u8 screenFillColor[4]; + /* 0xEA */ u8 sandstormState; /* 0xEB */ u8 unk_EB; /* 0xEC */ u8 unk_EC; /* 0xED */ u8 unk_ED; @@ -995,8 +977,6 @@ typedef void (*ColChkApplyFunc)(GlobalContext*, CollisionCheckContext*, Collider typedef void (*ColChkVsFunc)(GlobalContext*, CollisionCheckContext*, Collider*, Collider*); typedef s32 (*ColChkLineFunc)(GlobalContext*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*); -typedef void(*cutscene_update_func)(GlobalContext* globalCtx, CutsceneContext* cCtxt); - typedef void(*draw_func)(GlobalContext* globalCtx, s16 index); typedef void(*room_draw_func)(GlobalContext* globalCtx, Room* room, u32 flags); @@ -1512,4 +1492,27 @@ enum fram_mode { FRAM_MODE_STATUS }; +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; + /* 0x04 */ s16 unk_04; + /* 0x06 */ s16 unk_06; + /* 0x08 */ s16 unk_08; + /* 0x0A */ s16 unk_0A; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ UNK_TYPE1 unk_0E[0x02]; + /* 0x10 */ UNK_TYPE1 unk_10[0x2C]; + /* 0x3C */ UNK_TYPE1 unk_3C[0x01]; + /* 0x3D */ u8 unk_3D; + /* 0x3E */ UNK_TYPE1 unk_3E[0x02]; + /* 0x40 */ UNK_TYPE1 unk_40[0x2C]; + /* 0x6C */ UNK_TYPE1 unk_6C[0x01]; + /* 0x6D */ u8 unk_6D; + /* 0x6E */ UNK_TYPE1 unk_6E[0x02]; + /* 0x70 */ UNK_PTR unk_70; + /* 0x74 */ UNK_PTR unk_74; + /* 0x78 */ UNK_PTR unk_78; + /* 0x7C */ Camera* camera; +} struct_801F4D48; // size = 0x80 + #endif diff --git a/include/z64actor.h b/include/z64actor.h index 9c0aa7e7d..7a7556ed0 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -1160,7 +1160,7 @@ typedef enum { /* 0x03 */ CLEAR_TAG_SMALL_LIGHT_RAYS, /* 0x04 */ CLEAR_TAG_LARGE_LIGHT_RAYS, /* 0x23 */ CLEAR_TAG_SPLASH = 35, - /* 0xC8 */ CLEAR_TAG_SMOKE = 200, + /* 0xC8 */ CLEAR_TAG_SMOKE = 200 } ClearTagType; #endif diff --git a/include/z64cutscene.h b/include/z64cutscene.h index 0f2a6e678..84150a527 100644 --- a/include/z64cutscene.h +++ b/include/z64cutscene.h @@ -1,5 +1,5 @@ -#ifndef _Z64CUTSCENE_H_ -#define _Z64CUTSCENE_H_ +#ifndef Z64CUTSCENE_H +#define Z64CUTSCENE_H #include "ultra64.h" #include "unk.h" @@ -26,21 +26,24 @@ typedef struct { } CutsceneCameraMove; // size = 0xC typedef struct { - /* 0x00 */ u16 unk0; // action; // "dousa" + /* 0x00 */ u16 action; // "dousa" /* 0x02 */ u16 startFrame; /* 0x04 */ u16 endFrame; - /* 0x06 */ u16 unk6; - /* 0x08 */ u16 unk8; - /* 0x0C */ Vec3i unk0C; - /* 0x18 */ Vec3i unk18; - /* 0x24 */ UNK_TYPE1 unk24[0xC]; + union { + /* 0x06 */ Vec3s rot; + /* 0x06 */ Vec3us urot; + }; + /* 0x0C */ Vec3i startPos; + /* 0x18 */ Vec3i endPos; + /* 0x24 */ Vec3f normal; } CsCmdActorAction; // size = 0x30 typedef struct { /* 0x0 */ u16 base; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; -} CsCmdBase; // size = 0x6 + /* 0x6 */ u16 unk_06; +} CsCmdBase; // size = 0x8 typedef struct { /* 0x0 */ u16 unk0; @@ -48,25 +51,30 @@ typedef struct { /* 0x4 */ u16 endFrame; /* 0x6 */ u8 hour; /* 0x7 */ u8 minute; -} CsCmdDayTime; // size = 0x8 + /* 0x8 */ UNK_TYPE1 unk_08[0x04]; +} CsCmdDayTime; // size = 0xC typedef struct { /* 0x0 */ u16 setting; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; -} CsCmdEnvLighting; // size = 0x6 + /* 0x6 */ u16 unk_06; +} CsCmdEnvLighting; // size = 0x8 typedef struct { /* 0x0 */ u16 sequence; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; -} CsCmdMusicChange; // size = 0x6 + /* 0x6 */ u16 unk_06; +} CsCmdSequenceChange; // size = 0x8 typedef struct { /* 0x0 */ u16 type; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; -} CsCmdMusicFade; // size = 0x6 + /* 0x6 */ u16 unk_06; + /* 0x8 */ u32 unk_08; +} CsCmdSequenceFade; // size = 0xC typedef struct { /* 0x0 */ u16 base; @@ -77,30 +85,77 @@ typedef struct { /* 0xA */ u16 textId2; } CsCmdTextbox; // size = 0xC +typedef enum { + /* 0 */ CS_TEXTBOX_TYPE_DEFAULT, + /* 1 */ CS_TEXTBOX_TYPE_1, + /* 2 */ CS_TEXTBOX_TYPE_LEARN_SONG, + /* 3 */ CS_TEXTBOX_TYPE_3, + /* 4 */ CS_TEXTBOX_TYPE_BOSSES_REMAINS, + /* 5 */ CS_TEXTBOX_TYPE_ALL_NORMAL_MASKS, + /* 0xFFFF */ CS_TEXTBOX_TYPE_NONE = 0xFFFF +} CutsceneTextboxType; + typedef struct { - /* 0x0 */ u16 unk0; + /* 0x0 */ u16 type; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; /* 0x6 */ u8 unk6; /* 0x7 */ u8 unk7; /* 0x8 */ u8 unk8; /* 0x9 */ UNK_TYPE1 pad9[0x3]; -} CsCmdUnk190; // size = 0xC - -typedef struct { - /* 0x0 */ UNK_TYPE4 unk0; - /* 0x4 */ UNK_TYPE4 unk4; -} CsCmdUnk5A; // size = 0x8 +} CsCmdRumble; // size = 0xC typedef struct { /* 0x0 */ u16 unk0; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; - /* 0x6 */ u8 unk6; - /* 0x7 */ u8 unk7; - /* 0x8 */ u8 unk8; + /* 0x6 */ Color_RGB8 color; /* 0x9 */ UNK_TYPE1 pad9[0x3]; -} CsCmdUnk9B; // size = 0xC +} CsCmdFadeScreen; // size = 0xC + +typedef enum { + /* 0 */ CS_STATE_0, + /* 1 */ CS_STATE_1, + /* 2 */ CS_STATE_2, + /* 3 */ CS_STATE_3, + /* 4 */ CS_STATE_4 +} CutsceneState; + +typedef enum { + /* 0x00A */ CS_CMD_TEXTBOX = 0xA, + /* 0x05A */ CS_CMD_CAMERA = 0x5A, + /* 0x096 */ CS_CMD_MISC = 0x96, + /* 0x097 */ CS_CMD_SET_LIGHTING, + /* 0x098 */ CS_CMD_SCENE_TRANS_FX, + /* 0x099 */ CS_CMD_MOTIONBLUR, + /* 0x09A */ CS_CMD_GIVETATL, + /* 0x09B */ CS_CMD_FADESCREEN, + /* 0x09C */ CS_CMD_FADESEQ, + /* 0x09D */ CS_CMD_SETTIME, + /* 0x0C8 */ CS_CMD_SET_PLAYER_ACTION = 0xC8, + /* 0x0FA */ CS_CMD_UNK_FA = 0xFA, + /* 0x0FE */ CS_CMD_UNK_FE = 0xFE, + /* 0x0FF */ CS_CMD_UNK_FF, + /* 0x100 */ CS_CMD_UNK_100, + /* 0x101 */ CS_CMD_UNK_101, + /* 0x102 */ CS_CMD_UNK_102, + /* 0x103 */ CS_CMD_UNK_103, + /* 0x104 */ CS_CMD_UNK_104, + /* 0x105 */ CS_CMD_UNK_105, + /* 0x108 */ CS_CMD_UNK_108 = 0x108, + /* 0x109 */ CS_CMD_UNK_109, + /* 0x12C */ CS_CMD_PLAYSEQ = 0x12C, + /* 0x12D */ CS_CMD_UNK_12D, + /* 0x130 */ CS_CMD_130 = 0x130, + /* 0x131 */ CS_CMD_131, + /* 0x132 */ CS_CMD_132, + /* 0x133 */ CS_CMD_STOPSEQ, + /* 0x134 */ CS_CMD_PLAYAMBIENCE, + /* 0x135 */ CS_CMD_FADEAMBIENCE, + /* 0x15E */ CS_CMD_TERMINATOR = 0x15E, + /* 0x15F */ CS_CMD_CHOOSE_CREDITS_SCENES, + /* 0x190 */ CS_CMD_RUMBLE = 0x190 +} CutsceneCmd; typedef union CutsceneData { s32 i; @@ -109,4 +164,29 @@ typedef union CutsceneData { s8 b[4]; } CutsceneData; +typedef struct { + /* 0x0 */ CutsceneData* segmentedData; + /* 0x4 */ s16 nextEntranceIndex; + /* 0x6 */ u8 unk6; + /* 0x7 */ u8 unk7; // a weekEventReg bitpack? +} CutsceneEntry; // size = 0x8 + +typedef struct { + /* 0x00 */ u8 sceneCsCount; + /* 0x04 */ CutsceneData* csData; + /* 0x08 */ u8 state; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ u16 frames; + /* 0x12 */ u16 currentCsIndex; + /* 0x14 */ s32 csCamId; + /* 0x18 */ u16 unk_18; + /* 0x1A */ u8 unk_1A; + /* 0x1B */ u8 unk_1B; + /* 0x1C */ CutsceneCameraPoint* atPoints; + /* 0x20 */ CutsceneCameraPoint* eyePoints; + /* 0x24 */ CsCmdActorAction* playerAction; + /* 0x28 */ CsCmdActorAction* actorActions[10]; // "npcdemopnt" + /* 0x50 */ CutsceneEntry* sceneCsList; +} CutsceneContext; // size = 0x54 + #endif diff --git a/include/z64cutscene_commands.h b/include/z64cutscene_commands.h index 99000eec2..b487b49b1 100644 --- a/include/z64cutscene_commands.h +++ b/include/z64cutscene_commands.h @@ -1,5 +1,5 @@ -#ifndef _Z64CUTSCENE_COMMANDS_H_ -#define _Z64CUTSCENE_COMMANDS_H_ +#ifndef Z64CUTSCENE_COMMANDS_H +#define Z64CUTSCENE_COMMANDS_H #include "command_macros_base.h" #include "z64cutscene.h" @@ -11,11 +11,571 @@ * eeeeeeee nnnnnnnn * size = 0x8 */ -#define CS_BEGIN_CUTSCENE(totalEntries, endFrame) CMD_W(totalEntries), CMD_W(endFrame) +#define CS_BEGIN_CUTSCENE(totalEntries, endFrame) { CMD_W(totalEntries) }, { CMD_W(endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000000A eeeeeeee + * size = 0x8 + */ +#define CS_TEXT_LIST(entries) { CS_CMD_TEXTBOX }, { CMD_W(entries) } + +/** + * ARGS + * s16 messageId (i), s16 startFrame (s), s16 endFrame (e), s16 type (o), + * s16 topOptionBranch (y), s16 bottomOptionBranch (n) + * FORMAT + * iiiissss eeeeoooo yyyynnnn + * size = 0xC + */ +#define CS_TEXT_DISPLAY_TEXTBOX(messageId, startFrame, endFrame, type, topOptionBranch, bottomOptionBranch) \ + { CMD_HH(messageId, startFrame) }, { CMD_HH(endFrame, type) }, { CMD_HH(topOptionBranch, bottomOptionBranch) } + +/** + * ARGS + * s16 messageId (i), s16 startFrame (s), s16 endFrame (e), + * s16 topOptionBranch (y), s16 bottomOptionBranch (n) + * FORMAT + * iiiissss eeee0000 yyyynnnn + * size = 0xC + */ +#define CS_TEXT_DEFAULT(messageId, startFrame, endFrame, topOptionBranch, bottomOptionBranch) \ + CS_TEXT_DISPLAY_TEXTBOX(messageId, startFrame, endFrame, CS_TEXTBOX_TYPE_DEFAULT, topOptionBranch, bottomOptionBranch) + +/** + * ARGS + * s16 messageId (i), s16 startFrame (s), s16 endFrame (e), + * s16 topOptionBranch (y), s16 bottomOptionBranch (n) + * FORMAT + * iiiissss eeee0001 yyyynnnn + * size = 0xC + */ +#define CS_TEXT_TYPE_1(messageId, startFrame, endFrame, topOptionBranch, bottomOptionBranch) \ + CS_TEXT_DISPLAY_TEXTBOX(messageId, startFrame, endFrame, CS_TEXTBOX_TYPE_1, topOptionBranch, bottomOptionBranch) + +/** + * ARGS + * s16 ocarinaSongAction (o), s16 startFrame (s), s16 endFrame (e), s16 messageId (i) + * FORMAT + * oooossss eeee0002 iiiiFFFF + * size = 0xC + */ +#define CS_TEXT_LEARN_SONG(ocarinaSongAction, startFrame, endFrame, messageId) \ + CS_TEXT_DISPLAY_TEXTBOX(ocarinaSongAction, startFrame, endFrame, CS_TEXTBOX_TYPE_LEARN_SONG, messageId, 0xFFFF) + +/** + * ARGS + * s16 messageId (i), s16 startFrame (s), s16 endFrame (e), + * s16 topOptionBranch (y), s16 bottomOptionBranch (n) + * FORMAT + * iiiissss eeee0003 yyyynnnn + * size = 0xC + */ +#define CS_TEXT_TYPE_3(messageId, startFrame, endFrame, topOptionBranch, bottomOptionBranch) \ + CS_TEXT_DISPLAY_TEXTBOX(messageId, startFrame, endFrame, CS_TEXTBOX_TYPE_3, topOptionBranch, bottomOptionBranch) + +/** + * If Player has all 4 bosses' remains then alternativeMessageId is used, otherwise defaultMessageId is used + * ARGS + * s16 defaultMessageId (d), s16 startFrame (s), s16 endFrame (e), s16 alternativeMessageId (a) + * FORMAT + * ddddssss eeee0004 aaaaFFFF + * size = 0xC + */ +#define CS_TEXT_BOSSES_REMAINS(defaultMessageId, startFrame, endFrame, alternativeMessageId) \ + CS_TEXT_DISPLAY_TEXTBOX(defaultMessageId, startFrame, endFrame, CS_TEXTBOX_TYPE_BOSSES_REMAINS, alternativeMessageId, 0xFFFF) + +/** + * If Player has every non-transformation mask then alternativeMessageId is used, otherwise defaultMessageId is used + * ARGS + * s16 defaultMessageId (d), s16 startFrame (s), s16 endFrame (e), s16 alternativeMessageId (a) + * FORMAT + * ddddssss eeee0005 aaaaFFFF + * size = 0xC + */ +#define CS_TEXT_ALL_NORMAL_MASKS(defaultMessageId, startFrame, endFrame, alternativeMessageId) \ + CS_TEXT_DISPLAY_TEXTBOX(defaultMessageId, startFrame, endFrame, CS_TEXTBOX_TYPE_ALL_NORMAL_MASKS, alternativeMessageId, 0xFFFF) + +/** + * ARGS + * s16 startFrame (s), s16 endFrame (e) + * FORMAT + * FFFFssss eeeeFFFF FFFFFFFF + * size = 0xC + */ +#define CS_TEXT_NONE(startFrame, endFrame) \ + CS_TEXT_DISPLAY_TEXTBOX(0xFFFF, startFrame, endFrame, CS_TEXTBOX_TYPE_NONE, 0xFFFF, 0xFFFF) + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000005A eeeeeeee + * size = 0x8 + */ +#define CS_CAMERA_LIST(entries) { CS_CMD_CAMERA }, { CMD_W(entries) } + +// TODO: Camera command macros. Requieres func_80161998 being decomped + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000096 eeeeeeee + * size = 0x8 + */ +#define CS_MISC_LIST(entries) { CS_CMD_MISC }, { CMD_W(entries) } + +/** + * ARGS + * s16 unk (u), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * uuuussss eeeeUUUU + * size = 0x08 + */ +#define CS_MISC(unk, startFrame, endFrame, unk_06) \ + { CMD_HH(unk, startFrame) }, { CMD_HH(endFrame, unk_06) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000097 eeeeeeee + * size = 0x8 + */ +#define CS_LIGHTING_LIST(entries) { CS_CMD_SET_LIGHTING }, { CMD_W(entries) } + +/** + * ARGS + * s16 setting (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_LIGHTING(setting, startFrame, endFrame) \ + { CMD_HH(setting, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000098 eeeeeeee + * size = 0x8 + */ +#define CS_SCENE_TRANS_FX_LIST(entries) { CS_CMD_SCENE_TRANS_FX }, { CMD_W(entries) } + +/** + * ARGS + * s16 transitionType (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_SCENE_TRANS_FX(transitionType, startFrame, endFrame) \ + { CMD_HH(transitionType, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000099 eeeeeeee + * size = 0x08 + */ +#define CS_MOTIONBLUR_LIST(entries) { CS_CMD_MOTIONBLUR }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_MOTIONBLUR(base, startFrame, endFrame) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000009A eeeeeeee + * size = 0x8 + */ +#define CS_GIVETATL_LIST(entries) { CS_CMD_GIVETATL }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_GIVETATL(base, startFrame, endFrame) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000009B eeeeeeee + * size = 0x8 + */ +#define CS_FADESCREEN_LIST(entries) { CS_CMD_FADESCREEN }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e), + * u8 red (r), u8 green (g), blue (b) + * FORMAT + * Capital U is Unused + * mmmmssss eeeerrgg bbUUUUUU + * size = 0x0C + */ +#define CS_FADESCREEN(base, startFrame, endFrame, red, green, blue) \ + { CMD_HH(base, startFrame) }, { CMD_HBB(endFrame, red, green) }, { CMD_BBBB(blue, 0, 0, 0) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000009C eeeeeeee + * size = 0x8 + */ +#define CS_FADESEQ_LIST(entries) { CS_CMD_FADESEQ }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU UUUUUUUU + * size = 0x0C + */ +#define CS_FADESEQ(base, startFrame, endFrame) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, 0) }, { CMD_W(0) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000009D eeeeeeee + * size = 0x8 + */ +#define CS_TIME_LIST(entries) { CS_CMD_SETTIME }, { CMD_W(entries) } + +/** + * ARGS + * s16 unk (u), s16 startFrame (s), s16 endFrame (e), s8 hour (h), s8 min (m) + * FORMAT + * Capital U is Unused + * uuuussss eeeehhmm UUUUUUUU + * size = 0xC + */ +#define CS_TIME(unk, startFrame, endFrame, hour, min, unused) \ + { CMD_HH(unk, startFrame) }, { CMD_HBB(endFrame, hour, min) }, { CMD_W(unused) } + + +/** + * ARGS + * s32 cmdType (c), s32 entries (e) + * FORMAT + * cccccccc eeeeeeee + * size = 0x8 + */ +#define CS_ACTOR_ACTION_LIST(cmdType, entries) { CMD_W(cmdType) }, { CMD_W(entries) } + +/** + * ARGS + * s16 npcAction (a), s16 startFrame (s), s16 endFrame (e), + * s16 rotX (u), s16 rotY (v), s16 rotZ (w), + * s32 startX (i), s32 startY (j), s32 startZ (k), + * s32 endX (l), s32 endY (m), s32 endZ (n), + * f32 normX (x), f32 normY (y), f32 normZ (z), + * FORMAT + * aaaassss eeeeuuuu vvvvwwww iiiiiiii jjjjjjjj kkkkkkkk llllllll mmmmmmmm nnnnnnnn xxxxxxxx yyyyyyyy zzzzzzzz + * size = 0x30 + */ +#define CS_ACTOR_ACTION(npcAction, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ) \ + { CMD_HH(npcAction, startFrame) }, { CMD_HH(endFrame, rotX) }, { CMD_HH(rotY, rotZ) }, \ + { CMD_W(startX) }, { CMD_W(startY) }, { CMD_W(startZ) }, \ + { CMD_W(endX) }, { CMD_W(endY) }, { CMD_W(endZ) }, \ + { CMD_F(normX) }, { CMD_F(normY) }, { CMD_F(normZ) } + + +/** + * ARGS + * s32 cmdType (c), s32 entries (e) + * FORMAT + * 000000C8 eeeeeeee + * size = 0x8 + */ +#define CS_PLAYER_ACTION_LIST(entries) { CS_CMD_SET_PLAYER_ACTION }, { CMD_W(entries) } + +/** + * ARGS + * s16 playerAction (a), s16 startFrame (s), s16 endFrame (e), + * s16 rotX (u), s16 rotY (v), s16 rotZ (w), + * s32 startX (i), s32 startY (j), s32 startZ (k), + * s32 endX (l), s32 endY (m), s32 endZ (n), + * f32 normX (x), f32 normY (y), f32 normZ (z), + * FORMAT + * aaaassss eeeeuuuu vvvvwwww iiiiiiii jjjjjjjj kkkkkkkk llllllll mmmmmmmm nnnnnnnn xxxxxxxx yyyyyyyy zzzzzzzz + * size = 0x30 + */ +#define CS_PLAYER_ACTION(playerAction, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ) \ + CS_ACTOR_ACTION(playerAction, startFrame, endFrame, rotX, rotY, rotZ, startX, startY, startZ, endX, endY, endZ, normX, normY, normZ) + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000012C eeeeeeee + * size = 0x8 + */ +#define CS_PLAYSEQ_LIST(entries) { CS_CMD_PLAYSEQ }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_PLAYSEQ(sequence, startFrame, endFrame) \ + { CMD_HH(sequence, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000130 eeeeeeee + * size = 0x8 + */ +#define CS_SCENE_UNK_130_LIST(entries) { CS_CMD_130 }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x30 + */ +#define CS_SCENE_UNK_130(base, startFrame, endFrame, unk_06) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000131 eeeeeeee + * size = 0x8 + */ +#define CS_SCENE_UNK_131_LIST(entries) { CS_CMD_131 }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_SCENE_UNK_131(base, startFrame, endFrame, unk_06) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000132 eeeeeeee + * size = 0x8 + */ +#define CS_SCENE_UNK_132_LIST(entries) { CS_CMD_132 }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_SCENE_UNK_132(base, startFrame, endFrame) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000133 eeeeeeee + * size = 0x8 + */ +#define CS_STOPSEQ_LIST(entries) { CS_CMD_STOPSEQ }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_STOPSEQ(base, startFrame, endFrame, unk_06) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000134 eeeeeeee + * size = 0x8 + */ +#define CS_PLAYAMBIENCE_LIST(entries) { CS_CMD_PLAYAMBIENCE }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_PLAYAMBIENCE(base, startFrame, endFrame, unk_06) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000135 eeeeeeee + * size = 0x8 + */ +#define CS_FADEAMBIENCE_LIST(entries) { CS_CMD_FADEAMBIENCE }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_FADEAMBIENCE(base, startFrame, endFrame, unk_06) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000015E eeeeeeee + * size = 0x8 + */ +#define CS_TERMINATOR_LIST(entries) { CS_CMD_TERMINATOR }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_TERMINATOR(base, startFrame, endFrame) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000015F eeeeeeee + * size = 0x8 + */ +#define CS_CHOOSE_CREDITS_SCENES_LIST(entries) { CS_CMD_CHOOSE_CREDITS_SCENES }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_CHOOSE_CREDITS_SCENES(base, startFrame, endFrame) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000004 eeeeeeee + * size = 0x8 + */ +#define CS_RUMBLE_LIST(entries) { CS_CMD_RUMBLE }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_RUMBLE(base, startFrame, endFrame, unk6, unk7, unk8) \ + { CMD_HH(base, startFrame) }, { CMD_HBB(endFrame, unk6, unk7) }, { CMD_BBBB(unk8, 0, 0, 0) } + + +/** + * ARGS + * s32 cmd (c), s32 entries (e) + * FORMAT + * cccccccc eeeeeeee + * size = 0x8 + */ +#define CS_UNK_DATA_LIST(cmd, entries) { CMD_W(cmd) }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_UNK_DATA(base, startFrame, endFrame, unk_06) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } + /** * Marks the end of a cutscene */ -#define CS_END() 0xFFFFFFFF +#define CS_END() { CMD_W(0xFFFFFFFF) } #endif diff --git a/include/z64item.h b/include/z64item.h index 191e5c8de..ebb2a617d 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -43,7 +43,7 @@ typedef enum { /* 0x11 */ QUEST_SONG_SUN, /* 0x12 */ QUEST_BOMBERS_NOTEBOOK, /* 0x18 */ QUEST_SONG_LULLABY_INTRO = 0x18, - /* 0x19 */ QUEST_UNK_19, // Related to PictoBox + /* 0x19 */ QUEST_UNK_19 // Related to PictoBox } QuestItem; typedef enum { diff --git a/include/z64light.h b/include/z64light.h index 90ee01fb0..8e8508579 100644 --- a/include/z64light.h +++ b/include/z64light.h @@ -23,7 +23,7 @@ typedef struct { /* 0x12 */ s16 fogColor[3]; /* 0x18 */ s16 fogNear; /* 0x1A */ s16 fogFar; -} LightSettings2; // size = 0x1C +} EnvLightSettings; // size = 0x1C typedef struct { /* 0x0 */ s16 x; diff --git a/include/z64scene.h b/include/z64scene.h index c2836c548..b20313198 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -1,15 +1,16 @@ -#ifndef _Z64SCENE_H_ -#define _Z64SCENE_H_ +#ifndef Z64SCENE_H +#define Z64SCENE_H #include "ultra64.h" #include "z64dma.h" +#include "z64cutscene.h" #include "unk.h" #define SPAWN_ROT_FLAGS(rotation, flags) (((rotation) << 7) | (flags)) typedef struct { - /* 0x00 */ u32 vromStart; - /* 0x04 */ u32 vromEnd; + /* 0x00 */ uintptr_t vromStart; + /* 0x04 */ uintptr_t vromEnd; } RomFile; // size = 0x8 typedef struct { @@ -310,13 +311,6 @@ typedef struct { /* 0xE */ s16 params; } ActorEntry; // size = 0x10 -typedef struct { - /* 0x0 */ u32 data; - /* 0x4 */ s16 unk4; - /* 0x6 */ u8 unk6; - /* 0x7 */ u8 unk7; -} CutsceneEntry; // size = 0x8 - typedef struct { /* 0x0 */ u8 spawn; /* 0x1 */ u8 room; diff --git a/spec b/spec index 7910aa455..5578d5a4d 100644 --- a/spec +++ b/spec @@ -460,7 +460,6 @@ beginseg include "build/data/code/z_debug_mode.data.o" include "build/data/code/z_debug_mode.bss.o" include "build/src/code/z_demo.o" - include "build/data/code/z_demo.bss.o" include "build/src/code/z_draw.o" include "build/data/code/z_draw.data.o" include "build/src/code/z_eff_footmark.o" diff --git a/src/boot_O2_g3/CIC6105.c b/src/boot_O2_g3/CIC6105.c index 4745ad5c8..78eed1a77 100644 --- a/src/boot_O2_g3/CIC6105.c +++ b/src/boot_O2_g3/CIC6105.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" UNK_TYPE4 D_8009BE30; diff --git a/src/boot_O2_g3/boot_main.c b/src/boot_O2_g3/boot_main.c index 87bee5da4..04bb9a33a 100644 --- a/src/boot_O2_g3/boot_main.c +++ b/src/boot_O2_g3/boot_main.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" StackEntry sBootThreadInfo; diff --git a/src/boot_O2_g3/idle.c b/src/boot_O2_g3/idle.c index da93f13fd..942435fa7 100644 --- a/src/boot_O2_g3/idle.c +++ b/src/boot_O2_g3/idle.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" u8 D_80096B20 = 1; diff --git a/src/code/audio/code_8019AF00.c b/src/code/audio/code_8019AF00.c index 3a498178c..17404280b 100644 --- a/src/code/audio/code_8019AF00.c +++ b/src/code/audio/code_8019AF00.c @@ -2233,7 +2233,7 @@ const char sAudioOcarinaUnusedText7[] = "check is over!!! %d %d %d\n"; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3EC0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3F54.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SetCutsceneFlag.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3F6C.s") diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 72eeb742e..fb6f8687c 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,99 +1,1684 @@ #include "global.h" +#include "overlays/gamestates/ovl_daytelop/z_daytelop.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_Init.s") +void Cutscene_DoNothing(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_800EA258(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_800ED9C4(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_800EA2B8(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_800ED980(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_800EDA04(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_800EDA84(GlobalContext* globalCtx, CutsceneContext* csCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EA0D4.s") +// Unused +UNK_TYPE4 D_801BB120 = 0; +u16 D_801BB124 = 0; +u16 D_801BB128 = 0; +u8 D_801BB12C = 0; +u8 sCutsceneStoredPlayerForm = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EA0EC.s") +// bss +#ifndef NON_MATCHING +static u16 seqId; +#endif +s16 sCutsceneQuakeIndex; +struct_801F4D48 sCutsceneCameraInfo; +u16 D_801F4DC8[10]; +UNK_TYPE D_801F4DDC; +u8 D_801F4DE0; +s16 D_801F4DE2; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_StepCutscene1.s") +void Cutscene_Init(GlobalContext* globalCtx, CutsceneContext* csCtx) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_StepCutscene2.s") + csCtx->state = CS_STATE_0; + csCtx->frames = 0; + csCtx->unk_0C = 0.0f; + globalCtx->csCtx.sceneCsCount = 0; + globalCtx->csCtx.currentCsIndex = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_Nop800EA210.s") + for (i = 0; i < ARRAY_COUNT(D_801F4DC8); i++) { + D_801F4DC8[i] = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EA220.s") + D_801F4DE0 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EA258.s") + Audio_SetCutsceneFlag(false); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EA2B8.s") +void Cutscene_Start(GlobalContext* globalCtx, CutsceneContext* csCtx) { + csCtx->state = CS_STATE_1; + csCtx->playerAction = NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EA324.s") +void Cutscene_End(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if (csCtx->state != CS_STATE_4) { + csCtx->state = CS_STATE_3; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EABAC.s") +typedef void (*CutsceneStateHandler)(GlobalContext* globalCtx, CutsceneContext* csCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAC08.s") +CutsceneStateHandler sCsStateHandlers1[] = { + Cutscene_DoNothing, // CS_STATE_0 + func_800EA258, // CS_STATE_1 + Cutscene_DoNothing, // CS_STATE_2 + func_800ED9C4, // CS_STATE_3 + Cutscene_DoNothing, // CS_STATE_4 +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAC44.s") +void Cutscene_Update1(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if (gSaveContext.cutscene < 0xFFF0) { + sCsStateHandlers1[csCtx->state](globalCtx, csCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAC94.s") +CutsceneStateHandler sCsStateHandlers2[] = { + Cutscene_DoNothing, // CS_STATE_0 + func_800EA2B8, // CS_STATE_1 + func_800ED980, // CS_STATE_2 + func_800EDA04, // CS_STATE_3 + func_800ED980, // CS_STATE_4 +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAD14.s") +void Cutscene_Update2(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if ((gSaveContext.cutsceneTrigger != 0) && (globalCtx->sceneLoadFlag == 0x14)) { + gSaveContext.cutsceneTrigger = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAD48.s") + if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_0)) { + gSaveContext.cutscene = 0xFFFD; + gSaveContext.cutsceneTrigger = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAD7C.s") + if (gSaveContext.cutscene >= 0xFFF0) { + func_800EDA84(globalCtx, csCtx); + sCsStateHandlers2[csCtx->state](globalCtx, csCtx); + } +} +void Cutscene_DoNothing(GlobalContext* globalCtx, CutsceneContext* csCtx) { +} + +s32 func_800EA220(GlobalContext* globalCtx, CutsceneContext* csCtx, f32 target) { + return Math_StepToF(&csCtx->unk_0C, target, 0.1f); +} + +void func_800EA258(GlobalContext* globalCtx, CutsceneContext* csCtx) { + Interface_ChangeAlpha(1); + ShrinkWindow_SetLetterboxTarget(32); + if (func_800EA220(globalCtx, csCtx, 1.0f)) { + Audio_SetCutsceneFlag(true); + csCtx->state++; + } +} + +void func_800EA2B8(GlobalContext* globalCtx, CutsceneContext* csCtx) { + func_800ED980(globalCtx, csCtx); + Interface_ChangeAlpha(1); + ShrinkWindow_SetLetterboxTarget(32); + if (func_800EA220(globalCtx, csCtx, 1.0f)) { + Audio_SetCutsceneFlag(true); + csCtx->state++; + } +} + +/* Start of command handling section */ + +// Command 0x96: Miscellaneous commands. +void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, CsCmdBase* cmd) { + static u16 D_801BB15C = 0xFFFF; + Player* player = GET_PLAYER(globalCtx2); + GlobalContext* globalCtx = globalCtx2; + u8 isStartFrame = false; + f32 progress; + SceneTableEntry* loadedScene; + u16 time; + + if ((csCtx->frames < cmd->startFrame) || ((csCtx->frames >= cmd->endFrame) && (cmd->endFrame != cmd->startFrame))) { + return; + } + + progress = Environment_LerpWeight(cmd->endFrame - 1, cmd->startFrame, csCtx->frames); + if (csCtx->frames == cmd->startFrame) { + isStartFrame = true; + } + + // TODO: consider creating an enum for this when we understand what each value does + switch (cmd->base) { + case 0x1: + if (isStartFrame) { + func_800FD78C(globalCtx); + globalCtx->envCtx.unk_F2[0] = 0x3C; + } + break; + case 0x2: + if (isStartFrame) { + func_801A47DC(NATURE_CHANNEL_LIGHTNING, CHANNEL_IO_PORT_0, 0); + Environment_AddLightningBolts(globalCtx, 3); + D_801F4E68 = 1; + } + break; + case 0x3: + if (globalCtx->envCtx.lightSettings.fogFar < 12800) { + globalCtx->envCtx.lightSettings.fogFar += 35; + } + break; + case 0x4: + if (isStartFrame) { + globalCtx->envCtx.unk_19 = 1; + globalCtx->envCtx.unk_17 = 1; + globalCtx->envCtx.unk_18 = 0; + globalCtx->envCtx.unk_1A = 0x3C; + globalCtx->envCtx.unk_21 = 1; + globalCtx->envCtx.unk_1F = 0; + globalCtx->envCtx.unk_20 = 1; + globalCtx->envCtx.unk_24 = 0x3C; + globalCtx->envCtx.unk_22 = globalCtx->envCtx.unk_24; + } + break; + case 0x5: + if (isStartFrame && (csCtx->state != CS_STATE_4)) { + csCtx->state = CS_STATE_3; + } + break; + case 0x7: + if (isStartFrame) { + loadedScene = globalCtx->loadedScene; + if (loadedScene->titleTextId != 0) { + func_80151A68(globalCtx, loadedScene->titleTextId); + } + } + break; + case 0x8: + func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); + if (isStartFrame) { + sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6); + Quake_SetSpeed(sCutsceneQuakeIndex, 22000); + Quake_SetQuakeValues(sCutsceneQuakeIndex, 6, 4, 0, 0); + Quake_SetCountdown(sCutsceneQuakeIndex, 800); + } + break; + case 0x9: + if (isStartFrame) { + Quake_Init(); + } + break; + case 0xA: + D_801F6D30.r = 255; + D_801F6D30.g = 255; + D_801F6D30.b = 255; + D_801F6D30.a = 255 * progress; + break; + case 0xB: + D_801F6D30.r = 255; + D_801F6D30.g = 180; + D_801F6D30.b = 100; + D_801F6D30.a = 255 * progress; + break; + case 0xC: + globalCtx->roomCtx.currRoom.segment = NULL; + break; + case 0xD: + if (globalCtx->state.frames & 8) { + if (globalCtx->envCtx.lightSettings.ambientColor[0] < 40) { + globalCtx->envCtx.lightSettings.ambientColor[0] += 2; + globalCtx->envCtx.lightSettings.diffuseColor1[1] -= 3; + globalCtx->envCtx.lightSettings.diffuseColor1[2] -= 3; + } + } else { + if (globalCtx->envCtx.lightSettings.ambientColor[0] > 2) { + globalCtx->envCtx.lightSettings.ambientColor[0] -= 2; + globalCtx->envCtx.lightSettings.diffuseColor1[1] += 3; + globalCtx->envCtx.lightSettings.diffuseColor1[2] += 3; + } + } + break; + case 0xE: + globalCtx->unk_18845 = 1; + break; + case 0xF: + globalCtx->unk_18845 = 0; + break; + case 0x10: + if (isStartFrame) { + globalCtx->envCtx.sandstormState = 1; + } + func_8019F128(NA_SE_EV_SAND_STORM - SFX_FLAG); + break; + case 0x11: + gSaveContext.sunsSongState = SUNSSONG_START; + break; + case 0x12: + if (!gSaveContext.isNight) { + time = gSaveContext.time; + gSaveContext.time = time - (u16)REG(15); + } else { + time = gSaveContext.time; + gSaveContext.time = time - (u16)(2 * REG(15)); + } + break; + case 0x13: + // AudioOcarina_PlayLongScarecrowAfterCredits + func_8019D758(); + csCtx->frames = cmd->startFrame - 1; + break; + case 0x14: + EnvFlags_Set(globalCtx, 3); + break; + case 0x15: + EnvFlags_Set(globalCtx, 4); + break; + case 0x16: + gSaveContext.playerForm = PLAYER_FORM_DEKU; + break; + case 0x17: + player->stateFlags2 |= 0x4000000; + break; + case 0x18: + player->stateFlags2 &= ~0x4000000; + break; + case 0x19: + sCutsceneStoredPlayerForm = gSaveContext.playerForm; + gSaveContext.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.equippedMask = PLAYER_MASK_NONE; + break; + case 0x1A: + func_8019F128(NA_SE_EV_EARTHQUAKE_LAST2 - SFX_FLAG); + if (isStartFrame) { + sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6); + Quake_SetSpeed(sCutsceneQuakeIndex, 30000); + Quake_SetQuakeValues(sCutsceneQuakeIndex, 20, 10, 0, 0); + Quake_SetCountdown(sCutsceneQuakeIndex, 800); + } + break; + case 0x1B: + if (isStartFrame) { + globalCtx->nextEntranceIndex = 0x1C00; + gSaveContext.nextCutsceneIndex = 0xFFF8; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + } + break; + case 0x1C: + if (isStartFrame) { + globalCtx->envCtx.unk_17 = 0xD; + } + break; + case 0x1D: + gSaveContext.playerForm = sCutsceneStoredPlayerForm; + break; + case 0x1E: + D_801F4DE0 = true; + break; + case 0x1F: + D_801F4DE0 = false; + break; + case 0x21: + if (isStartFrame) { + func_80146EE8(globalCtx); + } + break; + case 0x22: + if (isStartFrame) { + func_80144A94(&globalCtx->sramCtx); + } + break; + case 0x23: + if (csCtx->frames != D_801BB15C) { + D_801BB15C = csCtx->frames; + + if (REG(15) != 0) { + time = gSaveContext.time; + gSaveContext.time = (u16)REG(15) + time; + time = gSaveContext.time; + gSaveContext.time = (u16)gSaveContext.unk_14 + time; + } + } + break; + case 0x24: + func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); + if (isStartFrame) { + sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6); + Quake_SetSpeed(sCutsceneQuakeIndex, 22000); + Quake_SetQuakeValues(sCutsceneQuakeIndex, 2, 1, 0, 0); + Quake_SetCountdown(sCutsceneQuakeIndex, 800); + } + break; + + case 0x26: + // Seems to be used to trigger "Dawn of A New Day" + + gSaveContext.day = 9; + + { + GameState* gameState = &globalCtx->state; + gameState->running = false; + } + SET_NEXT_GAMESTATE(&globalCtx->state, Daytelop_Init, DaytelopContext); + + func_80146F5C(globalCtx); + break; + + case 0x27: + gSaveContext.playerForm = PLAYER_FORM_ZORA; + break; + + case 0x28: + csCtx->frames = cmd->startFrame - 1; + break; + } +} + +// Command 0x97: Set Environment Lighting +void Cutscene_Command_SetLighting(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdEnvLighting* cmd) { + if (csCtx->frames == cmd->startFrame) { + if (cmd->setting != 0x20) { + globalCtx->envCtx.lightSettingOverride = cmd->setting - 1; + globalCtx->envCtx.lightBlend = 1.0f; + } else { + globalCtx->envCtx.lightSettingOverride = 0xFF; + } + } +} + +// Command 0x12C: Plays a sequence (Background music or Fanfare) +void Cutscene_Command_PlaySequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdSequenceChange* cmd) { + if (csCtx->frames == cmd->startFrame) { + func_801A2C88(cmd->sequence - 1); + } +} + +// Command 0x12D: Stops a sequence (Background music or Fanfare) +void Cutscene_Command_StopSequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdSequenceChange* cmd) { + if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { + func_801A2D54(cmd->sequence - 1); + } +} + +// Command 0x9C: Fade a sequence (Background music or Fanfare) over duration +void Cutscene_Command_FadeSequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdSequenceFade* cmd) { + if ((csCtx->frames == cmd->startFrame) && (csCtx->frames < cmd->endFrame)) { + u8 fadeTimer = cmd->endFrame - cmd->startFrame; + + if (cmd->type == 2) { + Audio_QueueSeqCmd((fadeTimer << 0x10) | 0x110000FF); + } else { + Audio_QueueSeqCmd((fadeTimer << 0x10) | NA_BGM_STOP); + } + } +} + +// Command 0x12E: Play Ambience sequence +void Cutscene_Command_PlayAmbienceSequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if (csCtx->frames == cmd->startFrame) { + // Audio_PlayNatureAmbienceSequence + // nightSeqIndex is natureAmbienceId + func_801A4A28(globalCtx->soundCtx.nightSeqIndex); + } +} + +// Command 0x130: +void func_800EAD48(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if (csCtx->frames == cmd->startFrame) { + // Audio_SetSfxReverbIndexExceptOcarinaBank + func_801A4428(2); + } +} + +// Command 0x131: +void func_800EAD7C(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if (csCtx->frames == cmd->startFrame) { + // Audio_SetSfxReverbIndexExceptOcarinaBank + func_801A4428(1); + } +} + +#ifdef NON_MATCHING +// needs in-function static bss +// audio related +void func_800EADB0(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + static u16 seqId; + u8 dayMinusOne; + + if (csCtx->frames == cmd->startFrame) { + dayMinusOne = (gSaveContext.day - 1); + if (dayMinusOne >= 3) { + dayMinusOne = 0; + } + + switch (cmd->base) { + case 1: + // func_801A246C(SEQ_PLAYER_BGM_MAIN, TYPE_1); + func_801A246C(SEQ_PLAYER_BGM_MAIN, 1); + break; + + case 2: + // func_801A246C(SEQ_PLAYER_BGM_MAIN, TYPE_0); + func_801A246C(SEQ_PLAYER_BGM_MAIN, 0); + break; + + case 3: + // func_801A246C(SEQ_PLAYER_BGM_MAIN, TYPE_2); + func_801A246C(SEQ_PLAYER_BGM_MAIN, 2); + break; + + case 4: + // func_801A246C(SEQ_PLAYER_NATURE, TYPE_1); + func_801A246C(SEQ_PLAYER_NATURE, 1); + break; + + case 5: + // func_801A246C(SEQ_PLAYER_NATURE, TYPE_0); + func_801A246C(SEQ_PLAYER_NATURE, 0); + break; + + case 6: + // func_801A246C(SEQ_PLAYER_NATURE, TYPE_2); + func_801A246C(SEQ_PLAYER_NATURE, 2); + break; + + case 7: + // Audio_GetActiveSequence + seqId = func_801A8A50(0); + break; + + case 8: + if (seqId != NA_BGM_DISABLED) { + // Audio_PlayBgmForDayScene + func_801A25E4(seqId, dayMinusOne); + } + break; + } + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EADB0.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAECC.s") +// Command 0x12F: Fade Ambience sequence +void Cutscene_Command_FadeAmbienceSequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if (csCtx->frames == cmd->startFrame && csCtx->frames < cmd->endFrame) { + u8 fadeTimer = cmd->endFrame - cmd->startFrame; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAF20.s") + Audio_QueueSeqCmd((fadeTimer << 0x10) | 0x140000FF); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAFE0.s") +// Command 0x190: Rumble +void Cutscene_Command_Rumble(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdRumble* cmd) { + switch (cmd->type) { + case 1: + if (csCtx->frames == cmd->startFrame) { + func_8013ECE0(0.0f, cmd->unk6, cmd->unk7, cmd->unk8); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EB1DC.s") + case 2: + if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { + if ((csCtx->frames == cmd->startFrame) || (globalCtx->state.frames % 64 == 0)) { + func_8013ECE0(0.0f, cmd->unk6, cmd->unk7, cmd->unk8); + } + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EB364.s") +// Command 0x9B: +void Cutscene_Command_FadeColorScreen(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdFadeScreen* cmd) { + if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { + f32 alpha; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EB4B4.s") + globalCtx->envCtx.fillScreen = true; + alpha = Environment_LerpWeight(cmd->endFrame, cmd->startFrame, csCtx->frames); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EB6F8.s") + if (((cmd->unk0 == 1)) || (cmd->unk0 == 2)) { + globalCtx->envCtx.screenFillColor[0] = cmd->color.r; + globalCtx->envCtx.screenFillColor[1] = cmd->color.g; + globalCtx->envCtx.screenFillColor[2] = cmd->color.b; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EBB68.s") + if (cmd->unk0 == 2) { + globalCtx->envCtx.screenFillColor[3] = (1.0f - alpha) * 255.0f; + } else { + globalCtx->envCtx.screenFillColor[3] = 255.0f * alpha; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EBCD0.s") +// Command 0x9D: Set Time of Day & Environment Time +void Cutscene_Command_SetTime(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdDayTime* cmd) { + u16 nextTime; + u16 hourAsMinutes; + u16 minutes; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EBD60.s") + if (csCtx->frames == cmd->startFrame) { + hourAsMinutes = CLOCK_TIME_ALT_F(cmd->hour, 0); + minutes = CLOCK_TIME_ALT_F(0, cmd->minute + 1); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EC678.s") + nextTime = hourAsMinutes + minutes; + gSaveContext.time = nextTime; + gSaveContext.environmentTime = nextTime; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EC6D4.s") +void Cutscene_TerminatorImpl(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + csCtx->state = CS_STATE_4; + func_80165690(); + Audio_SetCutsceneFlag(false); + gSaveContext.unk_3F48 = 1; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EC924.s") + if ((gSaveContext.gameMode != 0) && (csCtx->frames != cmd->startFrame)) { + gSaveContext.unk_3F1E = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800ECD7C.s") + gSaveContext.cutscene = 0; + if (cmd->base == 1) { + globalCtx->nextEntranceIndex = globalCtx->csCtx.sceneCsList[globalCtx->csCtx.currentCsIndex].nextEntranceIndex; + gSaveContext.nextCutsceneIndex = 0; + globalCtx->sceneLoadFlag = 0x14; + if (gSaveContext.gameMode != 1) { + Scene_SetExitFade(globalCtx); + } else { + D_801BB12C++; + if (D_801BB12C >= 2) { + D_801BB12C = 0; + } + globalCtx->unk_1887F = 4; + } + if ((globalCtx->nextEntranceIndex & 0xF) > 0) { + gSaveContext.nextCutsceneIndex = (globalCtx->nextEntranceIndex & 0xF) + 0xFFEF; + } + + globalCtx->nextEntranceIndex &= ~0xF; + } +} + +// Command 0x15E +void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if (cmd->base == 1) { + if (csCtx->frames == cmd->startFrame) { + Cutscene_TerminatorImpl(globalCtx, csCtx, cmd); + } + } else if (cmd->base == 2) { + if (csCtx->frames == cmd->startFrame) { + func_80165690(); + + switch (D_801F4DE2) { + case 0x1F: + if (gSaveContext.weekEventReg[0x14] & 2) { + globalCtx->nextEntranceIndex = 0x3010; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + } else { + globalCtx->nextEntranceIndex = 0x8600; + gSaveContext.nextCutsceneIndex = 0xFFF0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + } + break; + + case 0x44: + if (gSaveContext.weekEventReg[0x21] & 0x80) { + globalCtx->nextEntranceIndex = 0xAE70; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + } else { + globalCtx->nextEntranceIndex = 0xAE00; + gSaveContext.nextCutsceneIndex = 0xFFF0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + } + break; + + case 0x5F: + gSaveContext.weekEventReg[0x37] |= 0x80; + globalCtx->nextEntranceIndex = 0x6A80; + gSaveContext.nextCutsceneIndex = 0xFFF0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + break; + + case 0x36: + gSaveContext.weekEventReg[0x34] |= 0x20; + globalCtx->nextEntranceIndex = 0x2000; + gSaveContext.nextCutsceneIndex = 0xFFF1; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + break; + } + } + } +} + +// Command 0x15F: Chooses between a cutscene or a rotating mask depending on whether the player has the corresponding +// mask +void Cutscene_Command_ChooseCreditsScenes(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if ((csCtx->frames >= cmd->startFrame) && (func_801A3950(0, true) != 0xFF)) { + switch (cmd->base) { + case 1: + Cutscene_TerminatorImpl(globalCtx, csCtx, cmd); + break; + + case 2: + if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) { + // Milk bar + globalCtx->nextEntranceIndex = 0x2400; + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C00; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 3: + if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) { + // Fairy's fountain + globalCtx->nextEntranceIndex = 0x4600; + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C10; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 4: + if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI) { + // Romani ranch + globalCtx->nextEntranceIndex = 0x6400; + gSaveContext.nextCutsceneIndex = 0xFFF1; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C20; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 5: + if (INV_CONTENT(ITEM_MASK_BLAST) == ITEM_MASK_BLAST) { + // West clock town + globalCtx->nextEntranceIndex = 0xD400; + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C30; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 6: + if (INV_CONTENT(ITEM_MASK_CIRCUS_LEADER) == ITEM_MASK_CIRCUS_LEADER) { + // Milk bar + globalCtx->nextEntranceIndex = 0x2400; + gSaveContext.nextCutsceneIndex = 0xFFF1; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C50; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 7: + if (INV_CONTENT(ITEM_MASK_BREMEN) == ITEM_MASK_BREMEN) { + // Milk bar + globalCtx->nextEntranceIndex = 0x2400; + gSaveContext.nextCutsceneIndex = 0xFFF3; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C60; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 8: + // Ikana canyon + globalCtx->nextEntranceIndex = 0x2000; + gSaveContext.nextCutsceneIndex = 0xFFF3; + globalCtx->sceneLoadFlag = 0x14; + break; + + case 9: + if (INV_CONTENT(ITEM_MASK_COUPLE) == ITEM_MASK_COUPLE) { + // Termina field + globalCtx->nextEntranceIndex = 0x5400; + gSaveContext.nextCutsceneIndex = 0xFFF8; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C70; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 10: + if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { + // Cucco shack + globalCtx->nextEntranceIndex = 0x7E00; + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C40; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 11: + if (INV_CONTENT(ITEM_MASK_POSTMAN) == ITEM_MASK_POSTMAN) { + // Termina field + globalCtx->nextEntranceIndex = 0x5410; + gSaveContext.nextCutsceneIndex = 0xFFF8; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C80; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + } + } +} + +// Command 0x99: Motion blur +void Cutscene_Command_MotionBlur(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { + if ((csCtx->frames == cmd->startFrame) && (cmd->base == 1)) { + func_8016566C(180); + } + + if (cmd->base == 2) { + f32 progress = Environment_LerpWeight(cmd->endFrame, cmd->startFrame, csCtx->frames); + + if (progress >= 0.9f) { + func_80165690(); + } else { + func_80165658((1.0f - progress) * 180.0f); + } + } + } +} + +// Command 0x9A: Gives Tatl to the player +void Cutscene_Command_GiveTatlToPlayer(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + Player* player = GET_PLAYER(globalCtx); + + if (csCtx->frames == cmd->startFrame) { + if (cmd->base == 1) { + gSaveContext.hasTatl = true; + if (player->tatlActor != NULL) { + return; + } + player->tatlActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, player->actor.world.pos.x, + player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, 0); + } + } +} + +// Command 0x98 +void Cutscene_Command_TransitionFX(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { + f32 temp_f0; + + globalCtx->envCtx.fillScreen = true; + temp_f0 = Environment_LerpWeight(cmd->endFrame, cmd->startFrame, csCtx->frames); + + switch (cmd->base) { + case 1: + case 5: + globalCtx->envCtx.screenFillColor[0] = 160; + globalCtx->envCtx.screenFillColor[1] = 160; + globalCtx->envCtx.screenFillColor[2] = 160; + if (cmd->base == 1) { + globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + if (temp_f0 == 0.0f) { + func_8019F128(NA_SE_EV_S_STONE_FLASH); + } + } else { + globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + } + break; + + case 2: + case 6: + globalCtx->envCtx.screenFillColor[0] = 0; + globalCtx->envCtx.screenFillColor[1] = 0; + globalCtx->envCtx.screenFillColor[2] = 255; + if (cmd->base == 2) { + globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + } else { + globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + } + break; + + case 3: + case 7: + globalCtx->envCtx.screenFillColor[0] = 255; + globalCtx->envCtx.screenFillColor[1] = 0; + globalCtx->envCtx.screenFillColor[2] = 0; + if (cmd->base == 3) { + globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + } else { + globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + } + break; + + case 4: + case 8: + globalCtx->envCtx.screenFillColor[0] = 0; + globalCtx->envCtx.screenFillColor[1] = 255; + globalCtx->envCtx.screenFillColor[2] = 0; + if (cmd->base == 4) { + globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + } else { + globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + } + break; + + case 9: + gSaveContext.unk_3F48 = 1; + break; + + case 10: + case 11: + globalCtx->envCtx.screenFillColor[0] = 0; + globalCtx->envCtx.screenFillColor[1] = 0; + globalCtx->envCtx.screenFillColor[2] = 0; + if (cmd->base == 10) { + globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + } else { + globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + } + break; + + case 12: + globalCtx->envCtx.screenFillColor[0] = (160.0f * (1.0f - temp_f0)); + globalCtx->envCtx.screenFillColor[1] = globalCtx->envCtx.screenFillColor[0]; + globalCtx->envCtx.screenFillColor[2] = globalCtx->envCtx.screenFillColor[0]; + globalCtx->envCtx.screenFillColor[3] = 255; + break; + + case 13: + globalCtx->envCtx.screenFillColor[0] = (160.0f * temp_f0); + globalCtx->envCtx.screenFillColor[1] = globalCtx->envCtx.screenFillColor[0]; + globalCtx->envCtx.screenFillColor[2] = globalCtx->envCtx.screenFillColor[0]; + globalCtx->envCtx.screenFillColor[3] = 255; + break; + } + } +} + +// Command 0x5A: Camera +s32 Cutscene_Command_Camera(GlobalContext* globalCtx, u8* cmd) { + s32 sp1C = 0; + + bcopy(cmd, &sp1C, sizeof(s32)); + cmd += sizeof(s32); + if (func_8016A168() == 0) { + func_80161998(cmd, &sCutsceneCameraInfo); + } + return sp1C + sizeof(s32); +} + +/** + * Counts how many masks the player has + * The count doesn't include transformation masks + */ +s32 Cutscene_CountNormalMasks(void) { + s32 count = 0; + + if (INV_CONTENT(ITEM_MASK_TRUTH) == ITEM_MASK_TRUTH) { + count++; + } + if (INV_CONTENT(ITEM_MASK_KAFEIS_MASK) == ITEM_MASK_KAFEIS_MASK) { + count++; + } + if (INV_CONTENT(ITEM_MASK_ALL_NIGHT) == ITEM_MASK_ALL_NIGHT) { + count++; + } + if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { + count++; + } + if (INV_CONTENT(ITEM_MASK_KEATON) == ITEM_MASK_KEATON) { + count++; + } + if (INV_CONTENT(ITEM_MASK_GARO) == ITEM_MASK_GARO) { + count++; + } + if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI) { + count++; + } + if (INV_CONTENT(ITEM_MASK_CIRCUS_LEADER) == ITEM_MASK_CIRCUS_LEADER) { + count++; + } + if (INV_CONTENT(ITEM_MASK_POSTMAN) == ITEM_MASK_POSTMAN) { + count++; + } + if (INV_CONTENT(ITEM_MASK_COUPLE) == ITEM_MASK_COUPLE) { + count++; + } + if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) { + count++; + } + if (INV_CONTENT(ITEM_MASK_GIBDO) == ITEM_MASK_GIBDO) { + count++; + } + if (INV_CONTENT(ITEM_MASK_DON_GERO) == ITEM_MASK_DON_GERO) { + count++; + } + if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) { + count++; + } + if (INV_CONTENT(ITEM_MASK_CAPTAIN) == ITEM_MASK_CAPTAIN) { + count++; + } + if (INV_CONTENT(ITEM_MASK_STONE) == ITEM_MASK_STONE) { + count++; + } + if (INV_CONTENT(ITEM_MASK_BREMEN) == ITEM_MASK_BREMEN) { + count++; + } + if (INV_CONTENT(ITEM_MASK_BLAST) == ITEM_MASK_BLAST) { + count++; + } + if (INV_CONTENT(ITEM_MASK_SCENTS) == ITEM_MASK_SCENTS) { + count++; + } + if (INV_CONTENT(ITEM_MASK_GIANT) == ITEM_MASK_GIANT) { + count++; + } + + return count; +} + +// Command 0xA: Textbox +void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdTextbox* cmd) { + static s32 D_801BB160 = CS_TEXTBOX_TYPE_DEFAULT; + u8 dialogState; + s32 pad; + u16 originalCsFrames; + s32 pad2; + + if ((cmd->startFrame >= csCtx->frames) || ((cmd->endFrame < csCtx->frames))) { + return; + } + + if (cmd->type != CS_TEXTBOX_TYPE_LEARN_SONG) { + if (D_801BB124 != cmd->base) { + if (D_801BB160 == CS_TEXTBOX_TYPE_3) { + csCtx->frames--; + } + D_801BB160 = CS_TEXTBOX_TYPE_1; + D_801BB124 = cmd->base; + if (cmd->type == CS_TEXTBOX_TYPE_BOSSES_REMAINS) { + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && + CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { + if (cmd->textId1 != 0xFFFF) { + Message_StartTextbox(globalCtx, cmd->textId1, NULL); + } + } else { + Message_StartTextbox(globalCtx, cmd->base, NULL); + } + } else if (cmd->type == CS_TEXTBOX_TYPE_ALL_NORMAL_MASKS) { + if (Cutscene_CountNormalMasks() == 20) { + if (cmd->textId1 != 0xFFFF) { + Message_StartTextbox(globalCtx, cmd->textId1, NULL); + } + } else { + Message_StartTextbox(globalCtx, cmd->base, NULL); + } + } else { + Message_StartTextbox(globalCtx, cmd->base, NULL); + } + } else { + goto else_label; + } + } else if (D_801BB128 != cmd->base) { + D_801BB160 = CS_TEXTBOX_TYPE_LEARN_SONG; + D_801BB128 = cmd->base; + func_80152434(globalCtx, cmd->base); + } else { + else_label: + if (csCtx->frames >= cmd->endFrame) { + // The Textbox command can change the current cutscene frame, mainly to prevent advancing the cutscene when + // a textbox that is expected to be closed by the user is still open. + + originalCsFrames = csCtx->frames; + dialogState = Message_GetState(&globalCtx->msgCtx); + if ((dialogState != 2) && (dialogState != 0) && (dialogState != 7) && (dialogState != 8)) { + csCtx->frames--; + if ((dialogState == 4) && func_80147624(globalCtx)) { + if (globalCtx->msgCtx.choiceIndex == 0) { + if (cmd->base == 0x33BD) { + func_8019F230(); + } + + if (cmd->textId1 != 0xFFFF) { + func_80151938(globalCtx, cmd->textId1); + if (cmd->type == CS_TEXTBOX_TYPE_3) { + D_801BB160 = CS_TEXTBOX_TYPE_3; + if (cmd->textId2 != 0xFFFF) { + csCtx->frames++; + } + } + } else { + func_801477B4(globalCtx); + csCtx->frames++; + } + } else { + if (cmd->base == 0x33BD) { + func_8019F208(); + } + + if (cmd->textId2 != 0xFFFF) { + func_80151938(globalCtx, cmd->textId2); + if (cmd->type == CS_TEXTBOX_TYPE_3) { + D_801BB160 = CS_TEXTBOX_TYPE_3; + if (cmd->textId1 != 0xFFFF) { + csCtx->frames++; + } + } + } else { + func_801477B4(globalCtx); + csCtx->frames++; + } + } + } + + if (dialogState == 5 && func_80147624(globalCtx) != 0) { + func_80152434(globalCtx, cmd->base); + } + } + + if ((dialogState == 2) && (D_801BB160 == CS_TEXTBOX_TYPE_3)) { + csCtx->frames--; + D_801BB124++; + } + + if (originalCsFrames == csCtx->frames) { + Interface_ChangeAlpha(1); + D_801BB124 = 0; + D_801BB128 = 0; + func_80161C0C(); + } else { + func_80161BE0(1); + } + } + } +} + +// Related to actorActions. Maybe a generic actorAction setter? +void func_800ECD7C(CutsceneContext* csCtx, u8** cutscenePtr, s16 index) { + s32 i; + s32 count; + + bcopy(*cutscenePtr, &count, sizeof(s32)); + *cutscenePtr += sizeof(s32); + + for (i = 0; i < count; i++) { + CsCmdActorAction* actorAction = *(CsCmdActorAction**)cutscenePtr; + + if ((csCtx->frames >= actorAction->startFrame) && (csCtx->frames < actorAction->endFrame)) { + csCtx->actorActions[index] = actorAction; + } + + *cutscenePtr += sizeof(CsCmdActorAction); + } +} + +#ifdef NON_MATCHING +// Some stack issues, and a few instructions in the "wrong" places +/** + * Loops over the cutscene data itself (`cutscenePtr`), applying the effects of each command instantaneously (for most + * commands). + * + * The cutscene data is an irregularly-structured array of words, which is made up of + * - A beginning, which contains the number of command lists of this cutscene and the ending frame (see + * `CS_BEGIN_CUTSCENE`). + * - Any number of cutscene command lists (which should be the number specified in the beginning), each one of which + * contains commands of the corresponding category. + * - A end marker (see `CS_END`). + * + * This function iterates over each command list until either it has processed the number of command lists stated on + * `CS_BEGIN_CUTSCENE` or until it finds a end marker. + * + * A command list starts with a pair of words containing the command category and a count of how many commands this list + * has (N). This is followed by N commands of the said category. (The exception is Camera, which has the length of the + * list in bytes instead of the number of commands). + * + * For most command lists categories (all but the actorActions and Camera commands): + * - For each command list found, read the number of commands and loop over them, passing each one to the corresponding + * function which handles the command, applying its effects and checking the frame range stored in the command. + * + * This function is invoked once per frame that a cutscene is active. + * + * TODO: consider changing the type of `cutscenePtr` to `uintptr_t` when this function matches. + */ +void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cutscenePtr) { + s32 i; + s16 phi_s0; + s32 totalEntries; + s32 j; + u32 cmdType; // sp5C + s32 pad; + s32 cmdEntries; // sp58 + s32 cutsceneEndFrame; // sp50 + s16 phi_s0_23; + CsCmdBase* cmd; + + // Read the command list count and the ending frame for this cutscene + bcopy(cutscenePtr, &totalEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + bcopy(cutscenePtr, &cutsceneEndFrame, sizeof(s32)); + cutscenePtr += sizeof(s32); + + if (((u16)cutsceneEndFrame < csCtx->frames) && (globalCtx->sceneLoadFlag != 0x14) && (csCtx->state != CS_STATE_4)) { + csCtx->state = CS_STATE_3; + return; + } + + // Loop over every command list + for (i = 0; i < totalEntries; i++) { + // Read the command type of the current command list. + bcopy(cutscenePtr, &cmdType, sizeof(u32)); + cutscenePtr += sizeof(u32); + + // TODO: This should probably be added to the CutsceneCmd enum. Consider doing it when this function matches. + if (cmdType == 0xFFFFFFFF) { + break; + } + + // Check special cases of command types. This are generic ActorActions + // Ranges: [0x64, 0x96), 0xC9, [0x1C2, 0x258) + if (((cmdType >= 100) && (cmdType < 150)) || (cmdType == 201) || ((cmdType >= 450) && (cmdType < 600))) { + for (phi_s0 = 0; phi_s0 < ARRAY_COUNT(D_801F4DC8); phi_s0++) { + if ((u16)cmdType == D_801F4DC8[phi_s0]) { + func_800ECD7C(csCtx, &cutscenePtr, phi_s0); + cmdType = -2; + break; + } else if (D_801F4DC8[phi_s0] == 0) { + D_801F4DC8[phi_s0] = cmdType; + func_800ECD7C(csCtx, &cutscenePtr, phi_s0); + cmdType = -2; + break; + } + } + } + + switch (cmdType) { + case CS_CMD_MISC: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_Misc(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_SET_LIGHTING: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_SetLighting(globalCtx, csCtx, (CsCmdEnvLighting*)cutscenePtr); + cutscenePtr += sizeof(CsCmdEnvLighting); + } + break; + + case CS_CMD_PLAYSEQ: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_PlaySequence(globalCtx, csCtx, (CsCmdSequenceChange*)cutscenePtr); + cutscenePtr += sizeof(CsCmdSequenceChange); + } + break; + + case CS_CMD_STOPSEQ: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_StopSequence(globalCtx, csCtx, (CsCmdSequenceChange*)cutscenePtr); + cutscenePtr += sizeof(CsCmdSequenceChange); + } + break; + + case CS_CMD_FADESEQ: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_FadeSequence(globalCtx, csCtx, (CsCmdSequenceFade*)cutscenePtr); + cutscenePtr += sizeof(CsCmdSequenceFade); + } + break; + + case CS_CMD_PLAYAMBIENCE: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_PlayAmbienceSequence(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_FADEAMBIENCE: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_FadeAmbienceSequence(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_130: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + func_800EAD48(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_131: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + func_800EAD7C(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_132: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + func_800EADB0(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_RUMBLE: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_Rumble(globalCtx, csCtx, (CsCmdRumble*)cutscenePtr); + cutscenePtr += sizeof(CsCmdRumble); + } + break; + + case CS_CMD_FADESCREEN: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_FadeColorScreen(globalCtx, csCtx, (CsCmdFadeScreen*)cutscenePtr); + cutscenePtr += sizeof(CsCmdFadeScreen); + } + break; + + case CS_CMD_SETTIME: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_SetTime(globalCtx, csCtx, (CsCmdDayTime*)cutscenePtr); + cutscenePtr += sizeof(CsCmdDayTime); + } + break; + + case CS_CMD_SET_PLAYER_ACTION: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + cmd = (CsCmdBase*)cutscenePtr; + if ((csCtx->frames >= cmd->startFrame) && (csCtx->frames < cmd->endFrame)) { + csCtx->playerAction = (CsCmdActorAction*)cutscenePtr; + } + cutscenePtr += sizeof(CsCmdActorAction); + } + break; + + case CS_CMD_CAMERA: + cutscenePtr = &cutscenePtr[Cutscene_Command_Camera(globalCtx, cutscenePtr)]; + break; + + case CS_CMD_TERMINATOR: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_Terminator(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_CHOOSE_CREDITS_SCENES: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_ChooseCreditsScenes(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_TEXTBOX: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + cmd = (CsCmdBase*)cutscenePtr; + if (cmd->base != 0xFFFF) { + Cutscene_Command_Textbox(globalCtx, csCtx, (CsCmdTextbox*)cutscenePtr); + } + cutscenePtr += sizeof(CsCmdTextbox); + } + break; + + case CS_CMD_SCENE_TRANS_FX: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_TransitionFX(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_MOTIONBLUR: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_MotionBlur(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_GIVETATL: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_GiveTatlToPlayer(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case -2: + break; + + default: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + cutscenePtr += sizeof(CsCmdBase); + } + break; + } + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_ProcessCommands.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800ED980.s") +/* End of command handling section */ -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800ED9C4.s") +void func_800ED980(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if (gSaveContext.cutscene >= 0xFFF0) { + csCtx->frames++; + Cutscene_ProcessCommands(globalCtx, csCtx, (u8*)globalCtx->csCtx.csData); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDA04.s") +void func_800ED9C4(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if (func_800EA220(globalCtx, csCtx, 0.0f)) { + Audio_SetCutsceneFlag(false); + csCtx->state = CS_STATE_0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDA84.s") +// unused +void func_800EDA04(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if (func_800EA220(globalCtx, csCtx, 0.0f)) { + s16 i; + csCtx->playerAction = NULL; + + for (i = 0; i < ARRAY_COUNT(csCtx->actorActions); i++) { + csCtx->actorActions[i] = NULL; + } + + gSaveContext.cutscene = 0; + gSaveContext.gameMode = 0; + ActorCutscene_Stop(0x7F); + Audio_SetCutsceneFlag(false); + csCtx->state = CS_STATE_0; + } +} + +void func_800EDA84(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_0) && !Player_InCsMode(&globalCtx->state)) { + gSaveContext.cutscene = 0xFFFD; + } + + if ((gSaveContext.cutscene >= 0xFFF0) && (csCtx->state == CS_STATE_0)) { + s16 i; + + D_801BB124 = 0; + D_801BB128 = 0; + csCtx->playerAction = NULL; + + for (i = 0; i < ARRAY_COUNT(csCtx->actorActions); i++) { + csCtx->actorActions[i] = NULL; + } + + csCtx->state++; + if (csCtx->state == CS_STATE_1) { + Audio_SetCutsceneFlag(true); + + csCtx->frames = 0xFFFF; + csCtx->csCamId = ActorCutscene_GetCurrentCamera(0x7F); + func_8016119C(Play_GetCamera(globalCtx, csCtx->csCamId), &sCutsceneCameraInfo); + csCtx->unk_18 = 0xFFFF; + + if (gSaveContext.cutsceneTrigger == 0) { + Interface_ChangeAlpha(1); + ShrinkWindow_SetLetterboxTarget(32); + ShrinkWindow_SetLetterboxMagnitude(0x20); + csCtx->state++; + } + + func_800ED980(globalCtx, csCtx); + } + + gSaveContext.cutsceneTrigger = 0; + } +} + +#ifdef NON_MATCHING +// HandleFlags? +// regalloc +void func_800EDBE0(GlobalContext* globalCtx) { + CutsceneEntry* temp_a3; + s16 sp2A; + SceneTableEntry* sp24; + s32 temp_v0_3; + + if (((gSaveContext.gameMode == 0) || (gSaveContext.gameMode == 1)) && (gSaveContext.respawnFlag <= 0)) { + sp2A = func_800F21CC(); + if (sp2A != -1) { + temp_v0_3 = func_800F2138(sp2A); + if (temp_v0_3 != -1) { + temp_a3 = ((void)0, globalCtx->csCtx.sceneCsList); + if ((temp_a3[temp_v0_3].unk7 != 0xFF) && (gSaveContext.respawnFlag == 0)) { + if (temp_a3[temp_v0_3].unk7 == 0xFE) { + ActorCutscene_Start(sp2A, NULL); + gSaveContext.showTitleCard = false; + } else if (!((1 << (temp_a3[temp_v0_3].unk7 % 8)) & + gSaveContext.weekEventReg[temp_a3[temp_v0_3].unk7 / 8])) { + gSaveContext.weekEventReg[(temp_a3[temp_v0_3].unk7 / 8)] |= 1 << (temp_a3[temp_v0_3].unk7 % 8); + ActorCutscene_Start(sp2A, NULL); + gSaveContext.showTitleCard = false; + } + } + } else { + ActorCutscene_StartAndSetUnkLinkFields(sp2A, NULL); + } + } + } + + if ((gSaveContext.respawnFlag == 0) || (gSaveContext.respawnFlag == -2)) { + sp24 = globalCtx->loadedScene; + if ((sp24->titleTextId != 0) && gSaveContext.showTitleCard) { + if ((Entrance_GetTransitionFlags(gSaveContext.sceneSetupIndex + gSaveContext.entranceIndex) & 0x4000) != + 0) { + func_80151A68(globalCtx, sp24->titleTextId); + } + } + + gSaveContext.showTitleCard = true; + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDBE0.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/nop_800EDDB0.s") +void func_800EDDB0(GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDDBC.s") +void func_800EDDBC(UNK_TYPE arg0, UNK_TYPE arg1) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDDCC.s") +void Cutscene_LoadCutsceneData(GlobalContext* globalCtx, u8 csIndex) { + if (dREG(95) == 0) { + globalCtx->csCtx.currentCsIndex = csIndex; + globalCtx->csCtx.csData = Lib_SegmentedToVirtual(globalCtx->csCtx.sceneCsList[csIndex].segmentedData); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDE34.s") + gSaveContext.cutsceneTrigger = 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDF24.s") +/* Start of actor utilities section */ -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDF78.s") +/** + * Interpolates the actor's position based on the corresponding actor action's position + * and the current cutscene frame + */ +void Cutscene_ActorTranslate(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex) { + Vec3f start; + Vec3f end; + CsCmdActorAction* entry = globalCtx->csCtx.actorActions[actorActionIndex]; + f32 progress; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EE0CC.s") + start.x = entry->startPos.x; + start.y = entry->startPos.y; + start.z = entry->startPos.z; + end.x = entry->endPos.x; + end.y = entry->endPos.y; + end.z = entry->endPos.z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EE1D8.s") + progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, globalCtx->csCtx.frames); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EE200.s") + VEC3F_LERPIMPDST(&actor->world.pos, &start, &end, progress); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EE29C.s") +/** + * Interpolates the actor's position based on the corresponding actor action's position + * and the current cutscene frame, and sets the actor's yaw using the actor action yaw + */ +void Cutscene_ActorTranslateAndYaw(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex) { + Cutscene_ActorTranslate(actor, globalCtx, actorActionIndex); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EE2F4.s") + actor->world.rot.y = globalCtx->csCtx.actorActions[actorActionIndex]->urot.y; + actor->shape.rot.y = actor->world.rot.y; +} + +/** + * Interpolates the actor's position and yaw based on the corresponding actor action's + * position and the current cutscene frame + */ +void Cutscene_ActorTranslateAndYawSmooth(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex) { + Vec3f start; + Vec3f end; + CsCmdActorAction* entry; + f32 progress; + + start.x = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.x; + start.y = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.y; + start.z = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.z; + end.x = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.x; + end.y = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.y; + end.z = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.z; + + entry = globalCtx->csCtx.actorActions[actorActionIndex]; + progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, globalCtx->csCtx.frames); + + VEC3F_LERPIMPDST(&actor->world.pos, &start, &end, progress); + + Math_SmoothStepToS(&actor->world.rot.y, Math_Vec3f_Yaw(&start, &end), 10, 1000, 1); + actor->shape.rot.y = actor->world.rot.y; +} + +/** + * Interpolates the actor's XZ position and yaw based on the corresponding actor action's + * position and the current cutscene frame + */ +void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex) { + Vec3f start; + Vec3f end; + CsCmdActorAction* entry; + f32 progress; + + start.x = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.x; + start.z = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.z; + end.x = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.x; + end.z = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.z; + + entry = globalCtx->csCtx.actorActions[actorActionIndex]; + progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, globalCtx->csCtx.frames); + + actor->world.pos.x = start.x + (end.x - start.x) * progress; + actor->world.pos.z = start.z + (end.z - start.z) * progress; + + Math_SmoothStepToS(&actor->world.rot.y, Math_Vec3f_Yaw(&start, &end), 10, 1000, 1); + actor->shape.rot.y = actor->world.rot.y; +} + +s32 Cutscene_GetSceneSetupIndex(GlobalContext* globalCtx) { + s32 sceneSetupIndex = 0; + + if (gSaveContext.sceneSetupIndex > 0) { + sceneSetupIndex = gSaveContext.sceneSetupIndex; + } + return sceneSetupIndex; +} + +s32 Cutscene_GetActorActionIndex(GlobalContext* globalCtx, u16 actorActionCmd) { + s32 i; + s32 index = -1; + + for (i = 0; i < ARRAY_COUNT(D_801F4DC8); i++) { + if (actorActionCmd == D_801F4DC8[i]) { + index = i; + } + } + + return index; +} + +s32 Cutscene_CheckActorAction(GlobalContext* globalCtx, u16 actorActionCmd) { + if (globalCtx->csCtx.state != CS_STATE_0) { + s32 index = Cutscene_GetActorActionIndex(globalCtx, actorActionCmd); + + if (index != -1) { + return globalCtx->csCtx.actorActions[index] != NULL; + } + } + + return false; +} + +u8 Cutscene_IsPlaying(GlobalContext* globalCtx) { + return (gSaveContext.cutsceneTrigger != 0) || (globalCtx->csCtx.state != CS_STATE_0); +} + +/* End of actor utilities section */ diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 6221e0910..ad66fe4a1 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -8,7 +8,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F5954.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F5A8C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_LerpWeight.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F5B10.s") @@ -64,7 +64,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FB010.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FB320.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_AddLightningBolts.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FB388.s") diff --git a/src/code/z_message.c b/src/code/z_message.c index 84f2ab951..0eceeee30 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -64,7 +64,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801514B0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801518B0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_StartTextbox.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151938.s") diff --git a/src/code/z_room.c b/src/code/z_room.c index f54882fd6..67c6c6158 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -114,7 +114,7 @@ s32 Room_HandleLoadCallbacks(GlobalContext* globalCtx, RoomContext* roomCtx) { if (((globalCtx->sceneNum != SCENE_IKANA) || (roomCtx->currRoom.num != 1)) && (globalCtx->sceneNum != SCENE_IKNINSIDE)) { - globalCtx->envCtx.unk_C3 = 0xff; + globalCtx->envCtx.lightSettingOverride = 0xff; globalCtx->envCtx.unk_E0 = 0; } func_800FEAB0(); diff --git a/src/code/z_scene_proc.c b/src/code/z_scene_proc.c index 57e2930a2..b04b79bb4 100644 --- a/src/code/z_scene_proc.c +++ b/src/code/z_scene_proc.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" s32 sMatAnimStep; diff --git a/src/libultra/flash/osFlash.c b/src/libultra/flash/osFlash.c index cf90bc75b..edba06fc2 100644 --- a/src/libultra/flash/osFlash.c +++ b/src/libultra/flash/osFlash.c @@ -1,14 +1,13 @@ -#include "prevent_bss_reordering.h" #include "ultra64.h" #include "global.h" -static s32 framDeviceInfo[4]; -static OSIoMesg framDeviceInfoQuery; -static OSMesgQueue __osFlashMessageQ; -static OSPiHandle __osFlashHandler; -static OSMesg __osFlashMsgBuf; -static s32 __osFlashVersion; -static UNK_TYPE1 D_801FD0FC[0x14]; +s32 framDeviceInfo[4]; +OSIoMesg framDeviceInfoQuery; +OSMesgQueue __osFlashMessageQ; +OSPiHandle __osFlashHandler; +OSMesg __osFlashMsgBuf; +s32 __osFlashVersion; +UNK_TYPE1 D_801FD0FC[0x14]; typedef enum { FLASH_OLD, diff --git a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c index 25b01a098..09876c350 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c @@ -163,8 +163,8 @@ void BgCtowerGear_Update(Actor* thisx, GlobalContext* globalCtx) { void BgCtowerGear_UpdateOrgan(Actor* thisx, GlobalContext* globalCtx) { BgCtowerGear* this = THIS; - if (func_800EE29C(globalCtx, 0x68)) { - switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x68)]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 104)) { + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 104)]->action) { case 1: this->dyna.actor.draw = NULL; func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); diff --git a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c index dc97a2151..576388d5c 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c +++ b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c @@ -125,9 +125,9 @@ void BgHakaCurtain_Update(Actor* thisx, GlobalContext* globalCtx) { BgHakaCurtain* this = THIS; CsCmdActorAction* actorAction; - if (func_800EE29C(globalCtx, 0x1D5)) { - actorAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1D5)]; - if (actorAction->startFrame == globalCtx->csCtx.frames && actorAction->unk0 == 2) { + if (Cutscene_CheckActorAction(globalCtx, 469)) { + actorAction = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 469)]; + if (actorAction->startFrame == globalCtx->csCtx.frames && actorAction->action == 2) { func_80B6DD80(this); } } diff --git a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c index 3707221dd..a9bf94256 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c +++ b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c @@ -131,8 +131,8 @@ void BgIknvObj_UpdateWaterwheel(BgIknvObj* this, GlobalContext* globalCtx) { func_800B9010(&this->dyna.actor, NA_SE_EV_WOOD_WATER_WHEEL - SFX_FLAG); } - if ((globalCtx->csCtx.state != 0) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.unk_12 == 4) && - (globalCtx->csCtx.frames == 1495)) { + if ((globalCtx->csCtx.state != 0) && (gSaveContext.sceneSetupIndex == 1) && + (globalCtx->csCtx.currentCsIndex == 4) && (globalCtx->csCtx.frames == 1495)) { func_8019F128(NA_SE_EV_DOOR_UNLOCK); } } diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index 9a519eb6e..e2c8c079e 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -1281,22 +1281,22 @@ void func_809DC78C(Actor* thisx, GlobalContext* globalCtx) { Boss02* this = THIS; this->unk_01AC = D_809DF5B0; - globalCtx->envCtx.unk_EA = 0xD; + globalCtx->envCtx.sandstormState = 0xD; if (D_809E0434 != NULL) { this->unk_1D74 = KREG(23) + -15.0f; D_801F4E30 = 0; - globalCtx->envCtx.unk_C3 = 1; + globalCtx->envCtx.lightSettingOverride = 1; globalCtx->skyboxId = 1; } else if (D_809E0422 == 0) { this->unk_1D74 = 0.0f; D_801F4E30 = this->unk_1D7C; - globalCtx->envCtx.unk_C3 = 0; + globalCtx->envCtx.lightSettingOverride = 0; globalCtx->skyboxId = 2; } else { this->unk_1D74 = KREG(23) + -15.0f; D_801F4E30 = ((KREG(24) * 0.1f) + 1.0f) * this->unk_1D7C; - globalCtx->envCtx.unk_C3 = 1; + globalCtx->envCtx.lightSettingOverride = 1; globalCtx->skyboxId = 1; } @@ -1650,7 +1650,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { switch (this->unk_1D18) { case 0: if (player->stateFlags1 & 0x100) { - func_800EA0D4(globalCtx, &globalCtx->csCtx); + Cutscene_Start(globalCtx, &globalCtx->csCtx); this->unk_1D22 = Play_CreateSubCamera(globalCtx); Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); Play_CameraChangeStatus(globalCtx, this->unk_1D22, 7); @@ -1770,7 +1770,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { this->unk_1D18 = 0; func_80169AFC(globalCtx, this->unk_1D22, 0); this->unk_1D22 = 0; - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); this->actor.flags |= ACTOR_FLAG_1; player->stateFlags1 &= ~0x100; this->unk_1D70 = 0.01f; @@ -1784,7 +1784,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { Actor_SetScale(&player->actor, this->unk_1D70); } - globalCtx->envCtx.unk_8C.fogNear = this->unk_1D74; + globalCtx->envCtx.lightSettings.fogNear = this->unk_1D74; if (sp57) { D_809E0422 = 1 - D_809E0422; @@ -2049,7 +2049,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { Matrix_InsertZRotation_f(this->unk_1D54, MTXMODE_APPLY); Matrix_GetStateTranslationAndScaledY(1.0f, &this->unk_1D3C); Play_CameraSetAtEyeUp(globalCtx, this->unk_1D22, &this->unk_1D30, &this->unk_1D24, &this->unk_1D3C); - ShrinkWindow_SetLetterboxTarget(0x1B); + ShrinkWindow_SetLetterboxTarget(27); } } #else @@ -2077,7 +2077,7 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { if ((gSaveContext.weekEventReg[52] & 0x20) || ((u32)(KREG(13) + 15) >= this->unk_1D1C)) { break; } - func_800EA0D4(globalCtx, &globalCtx->csCtx); + Cutscene_Start(globalCtx, &globalCtx->csCtx); this->unk_1D22 = Play_CreateSubCamera(globalCtx); Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); Play_CameraChangeStatus(globalCtx, this->unk_1D22, 7); @@ -2163,7 +2163,7 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { if (this->unk_1D1C == (u32)(BREG(27) + 335)) { func_80169AFC(globalCtx, this->unk_1D22, 0); this->unk_1D22 = 0; - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); this->actor.flags |= ACTOR_FLAG_1; this->unk_1D20 = 0; @@ -2175,7 +2175,7 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { case 100: if (ActorCutscene_GetCurrentIndex() == -1) { - func_800EA0D4(globalCtx, &globalCtx->csCtx); + Cutscene_Start(globalCtx, &globalCtx->csCtx); this->unk_1D22 = Play_CreateSubCamera(globalCtx); Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); Play_CameraChangeStatus(globalCtx, this->unk_1D22, 7); @@ -2224,7 +2224,7 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { if (this->unk_1D1C == 30) { func_80169AFC(globalCtx, this->unk_1D22, 0); this->unk_1D22 = 0; - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); this->unk_1D20 = 0; this->actor.flags |= ACTOR_FLAG_1; @@ -2263,6 +2263,6 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { Play_CameraSetAtEyeUp(globalCtx, this->unk_1D22, &this->unk_1D30, &sp5C, &this->unk_1D3C); this->unk_1D3C.z = this->unk_1D3C.x = 0.0f; this->unk_1D3C.y = 1.0f; - ShrinkWindow_SetLetterboxTarget(0x1B); + ShrinkWindow_SetLetterboxTarget(27); } } 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 72a397d06..b4106527b 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -259,7 +259,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { this->unk_708 = 10; this->unk_704 = 0; - func_800EA0D4(globalCtx, &globalCtx->csCtx); + Cutscene_Start(globalCtx, &globalCtx->csCtx); this->unk_70A = Play_CreateSubCamera(globalCtx); Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); Play_CameraChangeStatus(globalCtx, this->unk_70A, 7); @@ -389,7 +389,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { sp5C->at = this->unk_718; func_80169AFC(globalCtx, this->unk_70A, 0); this->unk_70A = 0; - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); func_80165690(); gSaveContext.eventInf[6] |= 1; @@ -400,7 +400,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { if (this->unk_70A != 0) { Vec3f sp50; - ShrinkWindow_SetLetterboxTarget(0x1B); + ShrinkWindow_SetLetterboxTarget(27); if (this->unk_748 != 0) { this->unk_748--; } diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index 0040f26fa..262bc1979 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -197,7 +197,7 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { break; } - func_800EA0D4(globalCtx, &globalCtx->csCtx); + Cutscene_Start(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 7); this->unk_A00 = Play_CreateSubCamera(globalCtx); Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); @@ -219,11 +219,11 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { case 1: if (this->unk_1CA >= 10) { Math_ApproachF(&this->unk_1E4, 30.0f, 0.2f, 1.0f); - globalCtx->envCtx.unk_E5 = 1; - globalCtx->envCtx.unk_E6[2] = 0; - globalCtx->envCtx.unk_E6[1] = 0; - globalCtx->envCtx.unk_E6[0] = 0; - globalCtx->envCtx.unk_E6[3] = this->unk_A2C; + globalCtx->envCtx.fillScreen = 1; + globalCtx->envCtx.screenFillColor[2] = 0; + globalCtx->envCtx.screenFillColor[1] = 0; + globalCtx->envCtx.screenFillColor[0] = 0; + globalCtx->envCtx.screenFillColor[3] = this->unk_A2C; Math_ApproachF(&this->unk_A2C, 75.0f, 1.0f, 3.0f); } @@ -232,7 +232,7 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { } if (this->unk_1CA >= 60) { - globalCtx->envCtx.unk_E5 = 0; + globalCtx->envCtx.fillScreen = 0; this->unk_1C8 = 0; this->unk_1DC = 0.0f; this->unk_1D8 = 0.0f; @@ -331,7 +331,7 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { func_809F2ED0(this, globalCtx); func_80169AFC(globalCtx, this->unk_A00, 0); this->unk_A00 = 0; - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); D_809F4970->unk_151 = 0; } @@ -339,7 +339,7 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { } if (this->unk_A00 != 0) { - ShrinkWindow_SetLetterboxTarget(0x1B); + ShrinkWindow_SetLetterboxTarget(27); Play_CameraSetAtEye(globalCtx, this->unk_A00, &this->unk_A10, &this->unk_A04); } } diff --git a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c index df179cf86..c72634216 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c @@ -458,11 +458,11 @@ void func_80AA5EBC(DmChar00* this, GlobalContext* globalCtx) { case SCENE_OPENINGDAN: if (gSaveContext.sceneSetupIndex == 0) { - if (globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { func_80AA5720(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 1) { + } else if (globalCtx->csCtx.currentCsIndex == 1) { func_80AA575C(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 2) { + } else if (globalCtx->csCtx.currentCsIndex == 2) { func_80AA5890(this, globalCtx); } } @@ -470,17 +470,17 @@ void func_80AA5EBC(DmChar00* this, GlobalContext* globalCtx) { case SCENE_OKUJOU: if (gSaveContext.sceneSetupIndex == 0) { - if (globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { func_80AA58CC(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 1) { + } else if (globalCtx->csCtx.currentCsIndex == 1) { func_80AA5950(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 2) { + } else if (globalCtx->csCtx.currentCsIndex == 2) { func_80AA5960(this, globalCtx); } } else if (gSaveContext.sceneSetupIndex == 2) { - if (globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { func_80AA59E4(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 1) { + } else if (globalCtx->csCtx.currentCsIndex == 1) { func_80AA5A6C(this, globalCtx); } } @@ -488,34 +488,34 @@ void func_80AA5EBC(DmChar00* this, GlobalContext* globalCtx) { case SCENE_00KEIKOKU: if (gSaveContext.sceneSetupIndex == 3) { - if (globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { func_80AA5AF4(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 2) { + } else if (globalCtx->csCtx.currentCsIndex == 2) { func_80AA5E2C(this, globalCtx); } } else if (gSaveContext.sceneSetupIndex == 7) { - if (globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { func_80AA5BF8(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 1) { + } else if (globalCtx->csCtx.currentCsIndex == 1) { func_80AA5CD4(this, globalCtx); } } break; case SCENE_MITURIN: - if ((gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.unk_12 == 1)) { + if ((gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.currentCsIndex == 1)) { func_80AA5DC8(this, globalCtx); } break; case SCENE_INSIDETOWER: - if ((gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.unk_12 == 0)) { + if ((gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.currentCsIndex == 0)) { func_80AA5D10(this, globalCtx); } break; case SCENE_PIRATE: - if ((gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.unk_12 == 0)) { + if ((gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.currentCsIndex == 0)) { func_80AA5D6C(this, globalCtx); } break; @@ -527,7 +527,7 @@ void DmChar00_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; DmChar00* this = THIS; - if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !func_800EE2F4(globalCtx)) { + if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(globalCtx)) { Actor_MarkForDeath(thisx); } @@ -551,18 +551,18 @@ void DmChar00_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80AA62FC(DmChar00* this, GlobalContext* globalCtx) { - u16 sp26 = DMCHAR00_GET(&this->actor) + 0x71; - u32 temp_v0; + u16 sp26 = DMCHAR00_GET(&this->actor) + 113; + s32 temp_v0; s32 pad; - if (func_800EE29C(globalCtx, sp26)) { - temp_v0 = func_800EE200(globalCtx, sp26); + if (Cutscene_CheckActorAction(globalCtx, sp26)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, sp26); - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[temp_v0]->startFrame) { - if (this->unk_260 != globalCtx->csCtx.npcActions[temp_v0]->unk0) { - this->unk_260 = globalCtx->csCtx.npcActions[temp_v0]->unk0; + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[temp_v0]->startFrame) { + if (this->unk_260 != globalCtx->csCtx.actorActions[temp_v0]->action) { + this->unk_260 = globalCtx->csCtx.actorActions[temp_v0]->action; - switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + switch (globalCtx->csCtx.actorActions[temp_v0]->action) { case 0x1: this->unk_261 = 0; break; @@ -786,7 +786,7 @@ void func_80AA62FC(DmChar00* this, GlobalContext* globalCtx) { func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); } } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); } else { this->unk_260 = 99; } @@ -853,7 +853,8 @@ void func_80AA62FC(DmChar00* this, GlobalContext* globalCtx) { void func_80AA67F8(DmChar00* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((globalCtx->csCtx.state == 0) && (gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.unk_12 == 1)) { + if ((globalCtx->csCtx.state == 0) && (gSaveContext.sceneSetupIndex == 0) && + (globalCtx->csCtx.currentCsIndex == 1)) { if (this->unk_261 != 42) { this->unk_261 = 42; func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); @@ -916,7 +917,7 @@ void DmChar00_Draw(Actor* thisx, GlobalContext* globalCtx2) { if ((globalCtx->csCtx.state == 0) && ((globalCtx->sceneNum != SCENE_OPENINGDAN) || (gSaveContext.sceneSetupIndex != 0) || - (globalCtx->roomCtx.currRoom.num != 0) || (globalCtx->csCtx.unk_12 != 1) || + (globalCtx->roomCtx.currRoom.num != 0) || (globalCtx->csCtx.currentCsIndex != 1) || (DMCHAR00_GET(&this->actor) != DMCHAR00_0))) { return; } diff --git a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c index 1bc42f32b..959207b8d 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -196,8 +196,9 @@ void func_80AA884C(DmChar01* this, GlobalContext* globalCtx) { } void func_80AA88A8(DmChar01* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x87)) { - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x87)]->startFrame) { + if (Cutscene_CheckActorAction(globalCtx, 135)) { + if (globalCtx->csCtx.frames == + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 135)]->startFrame) { D_80AAAE24 = 1; Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FORT_RISING); } @@ -339,10 +340,10 @@ void func_80AA8F2C(DmChar01* this, GlobalContext* globalCtx) { } void func_80AA9020(DmChar01* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x87)) { - CsCmdActorAction* temp_v1 = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x87)]; + if (Cutscene_CheckActorAction(globalCtx, 135)) { + CsCmdActorAction* temp_v1 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 135)]; - if ((temp_v1->startFrame == globalCtx->csCtx.frames) && (temp_v1->unk0 == 2)) { + if ((temp_v1->startFrame == globalCtx->csCtx.frames) && (temp_v1->action == 2)) { gSaveContext.weekEventReg[20] |= 2; this->actionFunc = func_80AA90AC; } diff --git a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c index bcf593de9..956f7317c 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c @@ -177,15 +177,14 @@ void func_80AAC990(DmChar05* this, GlobalContext* globalCtx) { } void func_80AAC9DC(DmChar05* this, GlobalContext* globalCtx) { - u32 temp_v0; + if (Cutscene_CheckActorAction(globalCtx, 109) != 0) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 109); - if (func_800EE29C(globalCtx, 0x6D) != 0) { - temp_v0 = func_800EE200(globalCtx, 0x6D); - if (globalCtx->csCtx.npcActions[temp_v0]->unk0 == 4) { + if (globalCtx->csCtx.actorActions[actionIndex]->action == 4) { this->unk_18E = 1; - this->unk_190.x = globalCtx->csCtx.npcActions[temp_v0]->unk0C.x; - this->unk_190.y = globalCtx->csCtx.npcActions[temp_v0]->unk0C.y; - this->unk_190.z = globalCtx->csCtx.npcActions[temp_v0]->unk0C.z; + this->unk_190.x = globalCtx->csCtx.actorActions[actionIndex]->startPos.x; + this->unk_190.y = globalCtx->csCtx.actorActions[actionIndex]->startPos.y; + this->unk_190.z = globalCtx->csCtx.actorActions[actionIndex]->startPos.z; } } } @@ -200,18 +199,17 @@ void func_80AACA98(DmChar05* this, GlobalContext* globalCtx) { } void func_80AACAE4(DmChar05* this, GlobalContext* globalCtx) { - u32 sp24; + if (Cutscene_CheckActorAction(globalCtx, 564)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 564); - if (func_800EE29C(globalCtx, 0x234)) { - sp24 = func_800EE200(globalCtx, 0x234); - if (globalCtx->csCtx.npcActions[sp24]->unk0 == 2) { - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[sp24]->startFrame) { + if (globalCtx->csCtx.actorActions[actionIndex]->action == 2) { + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { Item_Give(globalCtx, ITEM_MASK_COUPLE); } this->unk_18E = 1; - this->unk_190.x = globalCtx->csCtx.npcActions[sp24]->unk0C.x; - this->unk_190.y = globalCtx->csCtx.npcActions[sp24]->unk0C.y; - this->unk_190.z = globalCtx->csCtx.npcActions[sp24]->unk0C.z; + this->unk_190.x = globalCtx->csCtx.actorActions[actionIndex]->startPos.x; + this->unk_190.y = globalCtx->csCtx.actorActions[actionIndex]->startPos.y; + this->unk_190.z = globalCtx->csCtx.actorActions[actionIndex]->startPos.z; } else { this->unk_18E = 0; } @@ -279,14 +277,13 @@ void func_80AACD1C(DmChar05* this, GlobalContext* globalCtx) { } void func_80AACD68(DmChar05* this, GlobalContext* globalCtx) { - u32 temp_v0; + if (Cutscene_CheckActorAction(globalCtx, 473)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 473); - if (func_800EE29C(globalCtx, 0x1D9)) { - temp_v0 = func_800EE200(globalCtx, 0x1D9); this->unk_18E = 1; - this->unk_190.x = globalCtx->csCtx.npcActions[temp_v0]->unk0C.x; - this->unk_190.y = globalCtx->csCtx.npcActions[temp_v0]->unk0C.y; - this->unk_190.z = globalCtx->csCtx.npcActions[temp_v0]->unk0C.z; + this->unk_190.x = globalCtx->csCtx.actorActions[actionIndex]->startPos.x; + this->unk_190.y = globalCtx->csCtx.actorActions[actionIndex]->startPos.y; + this->unk_190.z = globalCtx->csCtx.actorActions[actionIndex]->startPos.z; } } @@ -300,28 +297,27 @@ void func_80AACE10(DmChar05* this, GlobalContext* globalCtx) { } void func_80AACE5C(DmChar05* this, GlobalContext* globalCtx) { - u32 temp_v0; + if (Cutscene_CheckActorAction(globalCtx, 518)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 518); - if (func_800EE29C(globalCtx, 0x206)) { - temp_v0 = func_800EE200(globalCtx, 0x206); this->unk_18E = 1; - this->unk_190.x = globalCtx->csCtx.npcActions[temp_v0]->unk0C.x; - this->unk_190.y = globalCtx->csCtx.npcActions[temp_v0]->unk0C.y; - this->unk_190.z = globalCtx->csCtx.npcActions[temp_v0]->unk0C.z; + this->unk_190.x = globalCtx->csCtx.actorActions[actionIndex]->startPos.x; + this->unk_190.y = globalCtx->csCtx.actorActions[actionIndex]->startPos.y; + this->unk_190.z = globalCtx->csCtx.actorActions[actionIndex]->startPos.z; } } void func_80AACF04(DmChar05* this, GlobalContext* globalCtx) { u8 sp2F = true; - u32 temp_v0; + s32 actionIndex; switch (DMCHAR05_GET(&this->actor)) { case DMCHAR05_0: - if (func_800EE29C(globalCtx, 0x6D)) { - temp_v0 = func_800EE200(globalCtx, 0x6D); + if (Cutscene_CheckActorAction(globalCtx, 109)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 109); - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[temp_v0]->startFrame) { - switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: sp2F = false; break; @@ -355,16 +351,16 @@ void func_80AACF04(DmChar05* this, GlobalContext* globalCtx) { } } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); } break; case DMCHAR05_1: - if (func_800EE29C(globalCtx, 0x1D9)) { - temp_v0 = func_800EE200(globalCtx, 0x1D9); + if (Cutscene_CheckActorAction(globalCtx, 473)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 473); - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[temp_v0]->startFrame) { - switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: sp2F = false; break; @@ -399,16 +395,16 @@ void func_80AACF04(DmChar05* this, GlobalContext* globalCtx) { } } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); } break; case DMCHAR05_2: - if (func_800EE29C(globalCtx, 0x206)) { - temp_v0 = func_800EE200(globalCtx, 0x206); + if (Cutscene_CheckActorAction(globalCtx, 518)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 518); - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[temp_v0]->startFrame) { - switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: sp2F = false; break; @@ -442,16 +438,16 @@ void func_80AACF04(DmChar05* this, GlobalContext* globalCtx) { } } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); } break; case DMCHAR05_3: - if (func_800EE29C(globalCtx, 0x22F)) { - temp_v0 = func_800EE200(globalCtx, 0x22F); + if (Cutscene_CheckActorAction(globalCtx, 559)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 559); - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[temp_v0]->startFrame) { - switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { default: sp2F = false; break; @@ -478,10 +474,10 @@ void func_80AACF04(DmChar05* this, GlobalContext* globalCtx) { } } - if (globalCtx->csCtx.npcActions[temp_v0]->unk0 != 4) { - func_800EDF24(&this->actor, globalCtx, temp_v0); + if (globalCtx->csCtx.actorActions[actionIndex]->action != 4) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); } else { - func_800EDE34(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslate(&this->actor, globalCtx, actionIndex); } } @@ -517,8 +513,8 @@ void func_80AAD450(DmChar05* this, GlobalContext* globalCtx) { void func_80AAD4A8(DmChar05* this, GlobalContext* globalCtx) { if (DMCHAR05_GET(&this->actor) == DMCHAR05_0) { - if (func_800EE29C(globalCtx, 0x6D) && - (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x6D)]->unk0 == 3)) { + if (Cutscene_CheckActorAction(globalCtx, 109) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 109)]->action == 3)) { if (Animation_OnFrame(&this->skelAnime, 14.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_0); } else if (Animation_OnFrame(&this->skelAnime, 19.0f)) { @@ -526,15 +522,15 @@ void func_80AAD4A8(DmChar05* this, GlobalContext* globalCtx) { } } } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_1) { - if (func_800EE29C(globalCtx, 0x1D9)) { - if ((globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1D9)]->unk0 == 3) && + if (Cutscene_CheckActorAction(globalCtx, 473)) { + if ((globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 473)]->action == 3) && Animation_OnFrame(&this->skelAnime, 5.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_SAND); } } } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_2) { - if (func_800EE29C(globalCtx, 0x206) && - (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x206)]->unk0 == 2)) { + if (Cutscene_CheckActorAction(globalCtx, 518) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 518)]->action == 2)) { if (Animation_OnFrame(&this->skelAnime, 7.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_0); } @@ -550,15 +546,15 @@ void func_80AAD4A8(DmChar05* this, GlobalContext* globalCtx) { } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_3) { if (globalCtx->sceneNum == SCENE_OKUJOU) { if (gSaveContext.sceneSetupIndex == 2) { - if (globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { func_80AAD3F8(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 1) { + } else if (globalCtx->csCtx.currentCsIndex == 1) { func_80AAD450(this, globalCtx); } } } else if (globalCtx->sceneNum == SCENE_SPOT00) { if (gSaveContext.sceneSetupIndex == 9) { - if ((globalCtx->csCtx.unk_12 == 0) && (globalCtx->csCtx.frames == 255)) { + if ((globalCtx->csCtx.currentCsIndex == 0) && (globalCtx->csCtx.frames == 255)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); } } else if ((gSaveContext.sceneSetupIndex == 0xB) && (globalCtx->csCtx.frames == 115)) { @@ -572,25 +568,25 @@ void DmChar05_Update(Actor* thisx, GlobalContext* globalCtx) { DmChar05* this = THIS; func_80AACF04(this, globalCtx); - if (func_800EE29C(globalCtx, 0x6D)) { - if (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x6D)]->unk0 == 3) { + if (Cutscene_CheckActorAction(globalCtx, 109)) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 109)]->action == 3) { SkelAnime_Update(&this->skelAnime); } - } else if (func_800EE29C(globalCtx, 0x1D9)) { - if (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1D9)]->unk0 == 3) { + } else if (Cutscene_CheckActorAction(globalCtx, 473)) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 473)]->action == 3) { SkelAnime_Update(&this->skelAnime); } - } else if (func_800EE29C(globalCtx, 0x206)) { - if (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x206)]->unk0 == 2) { + } else if (Cutscene_CheckActorAction(globalCtx, 518)) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 518)]->action == 2) { SkelAnime_Update(&this->skelAnime); } - } else if (func_800EE29C(globalCtx, 0x22F)) { - if ((globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x22F)]->unk0 == 2) || - (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x22F)]->unk0 == 3)) { + } else if (Cutscene_CheckActorAction(globalCtx, 559)) { + if ((globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 559)]->action == 2) || + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 559)]->action == 3)) { SkelAnime_Update(&this->skelAnime); } - if (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x22F)]->unk0 == 4) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 559)]->action == 4) { this->actor.world.rot.y += 0x258; this->actor.shape.rot.y += 0x258; } @@ -612,8 +608,8 @@ void func_80AAD998(Actor* thisx, GlobalContext* globalCtx) { s32 pad[2]; if (this->unk_18E == 0) { - if (func_800EE29C(globalCtx, 0x6D) && - (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x6D)]->unk0 != 1)) { + if (Cutscene_CheckActorAction(globalCtx, 109) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 109)]->action != 1)) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); @@ -633,8 +629,8 @@ void func_80AADA90(Actor* thisx, GlobalContext* globalCtx) { DmChar05* this = THIS; if (this->unk_18E == 0) { - if (func_800EE29C(globalCtx, 0x1D9) && - (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1D9)]->unk0 != 1)) { + if (Cutscene_CheckActorAction(globalCtx, 473) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 473)]->action != 1)) { func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, DmChar05_OverrideLimbDraw, DmChar05_PostLimbDraw, &this->actor); @@ -648,8 +644,8 @@ void func_80AADB4C(Actor* thisx, GlobalContext* globalCtx) { DmChar05* this = THIS; if (this->unk_18E == 0) { - if (func_800EE29C(globalCtx, 0x206) && - (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x206)]->unk0 != 1)) { + if (Cutscene_CheckActorAction(globalCtx, 518) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 518)]->action != 1)) { func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, NULL, &this->actor); @@ -662,18 +658,19 @@ void func_80AADB4C(Actor* thisx, GlobalContext* globalCtx) { void func_80AADC00(Actor* thisx, GlobalContext* globalCtx) { s32 pad; DmChar05* this = THIS; - u32 temp_v0; + s32 actionIndex; - if (func_800EE29C(globalCtx, 0x22F)) { - temp_v0 = func_800EE200(globalCtx, 0x22F); + if (Cutscene_CheckActorAction(globalCtx, 559)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 559); - if ((globalCtx->csCtx.npcActions[temp_v0]->unk0 != 1) && (globalCtx->csCtx.npcActions[temp_v0]->unk0 != 4)) { + if ((globalCtx->csCtx.actorActions[actionIndex]->action != 1) && + (globalCtx->csCtx.actorActions[actionIndex]->action != 4)) { func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, DmChar05_OverrideLimbDraw, DmChar05_PostLimbDraw, &this->actor); } - if (globalCtx->csCtx.npcActions[temp_v0]->unk0 == 4) { + if (globalCtx->csCtx.actorActions[actionIndex]->action == 4) { Matrix_InsertTranslation(-600.0f, 0.0f, 0.0f, MTXMODE_APPLY); Gfx_DrawDListOpa(globalCtx, object_dmask_DL_001E70); } diff --git a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c index 5603df165..4dd75d843 100644 --- a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c +++ b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c @@ -43,7 +43,7 @@ s32 func_80C1DED0(DmNb* this, s32 arg1) { void func_80C1DF18(DmNb* this, GlobalContext* globalCtx) { s32 sp2C[] = { 0, 0, 0, 0, 0 }; u16 actionUnk0; - u32 actionIndex; + s32 actionIndex; if (globalCtx->csCtx.state != 0) { if (this->unk1F8 == 0) { @@ -51,14 +51,14 @@ void func_80C1DF18(DmNb* this, GlobalContext* globalCtx) { this->unk1F8 = 1; this->unk1F4 = this->unk1F0; } - if (func_800EE29C(globalCtx, 0x232)) { - actionIndex = func_800EE200(globalCtx, 0x232); - actionUnk0 = globalCtx->csCtx.npcActions[actionIndex]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 562)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 562); + actionUnk0 = globalCtx->csCtx.actorActions[actionIndex]->action; if (this->unk1EC != (actionUnk0 & 0xFF)) { this->unk1EC = actionUnk0; func_80C1DED0(this, sp2C[actionUnk0]); } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); } } else if (this->unk1F8 != 0) { this->unk1F8 = 0; diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index 359efcf56..2017e960b 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -721,7 +721,7 @@ void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { func_80A9FED8(this, globalCtx); } else if (gSaveContext.sceneSetupIndex == 0) { func_80AA0100(this, globalCtx); - } else if ((gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.unk_12 == 0)) { + } else if ((gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.currentCsIndex == 0)) { func_80AA0158(this, globalCtx); } break; @@ -734,9 +734,9 @@ void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { case SCENE_OPENINGDAN: if (gSaveContext.sceneSetupIndex == 0) { - if (globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { func_80AA01C0(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 1) { + } else if (globalCtx->csCtx.currentCsIndex == 1) { func_80AA0264(this, globalCtx); } } @@ -744,19 +744,19 @@ void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { case SCENE_OKUJOU: if (gSaveContext.sceneSetupIndex == 0) { - if (globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { func_80AA0420(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 1) { + } else if (globalCtx->csCtx.currentCsIndex == 1) { func_80AA05F0(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 2) { + } else if (globalCtx->csCtx.currentCsIndex == 2) { func_80AA09DC(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 3) { + } else if (globalCtx->csCtx.currentCsIndex == 3) { func_80AA0B08(this, globalCtx); } } else if (gSaveContext.sceneSetupIndex == 2) { - if (globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { func_80AA0DA8(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 1) { + } else if (globalCtx->csCtx.currentCsIndex == 1) { func_80AA0E1C(this, globalCtx); } } @@ -764,15 +764,15 @@ void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { case SCENE_00KEIKOKU: if (gSaveContext.sceneSetupIndex == 3) { - if (globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { func_80AA0634(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 2) { + } else if (globalCtx->csCtx.currentCsIndex == 2) { func_80AA066C(this, globalCtx); } } else if (gSaveContext.sceneSetupIndex == 7) { - if (globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { func_80AA071C(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 1) { + } else if (globalCtx->csCtx.currentCsIndex == 1) { func_80AA076C(this, globalCtx); } } @@ -894,7 +894,7 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2E0 = 5; this->actionFunc = func_80AA1714; } else { - if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !func_800EE2F4(globalCtx)) { + if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(globalCtx)) { Actor_MarkForDeath(&this->actor); } this->unk_32C = 2; @@ -920,7 +920,7 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); if ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && - (globalCtx->csCtx.unk_12 > 0)) { + (globalCtx->csCtx.currentCsIndex > 0)) { globalCtx->envCtx.unk_17 = 15; globalCtx->envCtx.unk_18 = 15; } @@ -1051,7 +1051,7 @@ void func_80AA1B9C(DmStk* this, GlobalContext* globalCtx) { if (this->unk_339 >= 3) { this->unk_339 = 0; if (!(player->stateFlags2 & 0x8000000)) { - func_801518B0(globalCtx, 0x2013, &this->actor); + Message_StartTextbox(globalCtx, 0x2013, &this->actor); } } @@ -1076,21 +1076,21 @@ void func_80AA1C64(DmStk* this, GlobalContext* globalCtx) { void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { s32 pad; - u32 temp_v0; + s32 temp_v0; - if (func_800EE29C(globalCtx, 0x6B)) { - temp_v0 = func_800EE200(globalCtx, 0x6B); + if (Cutscene_CheckActorAction(globalCtx, 107)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 107); - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[temp_v0]->startFrame) { - if (this->unk_334 != globalCtx->csCtx.npcActions[temp_v0]->unk0) { - this->unk_334 = globalCtx->csCtx.npcActions[temp_v0]->unk0; + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[temp_v0]->startFrame) { + if (this->unk_334 != globalCtx->csCtx.actorActions[temp_v0]->action) { + this->unk_334 = globalCtx->csCtx.actorActions[temp_v0]->action; if (globalCtx->sceneNum == SCENE_CLOCKTOWER) { this->unk_32D = 6; } else { this->unk_32D = 9; } - switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + switch (globalCtx->csCtx.actorActions[temp_v0]->action) { case 0: case 1: this->unk_2E0 = 3; @@ -1350,7 +1350,7 @@ void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { } } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); } else { this->unk_334 = 99; } @@ -1482,7 +1482,7 @@ void func_80AA2720(DmStk* this, GlobalContext* globalCtx) { if (this->unk_328 > 800) { this->unk_328 = 0; if (!(player->stateFlags2 & 0x8000000)) { - func_801518B0(globalCtx, 0x2014, &this->actor); + Message_StartTextbox(globalCtx, 0x2014, &this->actor); } } if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { @@ -1579,7 +1579,7 @@ void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { } if ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && - (globalCtx->csCtx.unk_12 > 0)) { + (globalCtx->csCtx.currentCsIndex > 0)) { globalCtx->envCtx.unk_17 = 15; globalCtx->envCtx.unk_18 = 15; } @@ -1658,8 +1658,9 @@ void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_006BB0); gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_005870); - if (func_800EE29C(globalCtx, 0x201) && - (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x201)]->unk0 == 2) && (this->unk_337 >= 0)) { + if (Cutscene_CheckActorAction(globalCtx, 513) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 513)]->action == 2) && + (this->unk_337 >= 0)) { Matrix_StatePush(); Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_337].segment); diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index e28495538..a1a738fee 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -177,10 +177,10 @@ void DoorWarp1_Destroy(Actor* thisx, GlobalContext* globalCtx) { LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->unk_1DC); LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->unk_1F0); - for (i = 0; i < ARRAY_COUNT(globalCtx->envCtx.unk_8C.diffuseColor1); i++) { - globalCtx->envCtx.unk_8C.diffuseColor1[i] = 0; - globalCtx->envCtx.unk_8C.fogColor[i] = globalCtx->envCtx.unk_8C.diffuseColor1[i]; - globalCtx->envCtx.unk_8C.ambientColor[i] = globalCtx->envCtx.unk_8C.diffuseColor1[i]; + for (i = 0; i < ARRAY_COUNT(globalCtx->envCtx.lightSettings.diffuseColor1); i++) { + globalCtx->envCtx.lightSettings.diffuseColor1[i] = 0; + globalCtx->envCtx.lightSettings.fogColor[i] = globalCtx->envCtx.lightSettings.diffuseColor1[i]; + globalCtx->envCtx.lightSettings.ambientColor[i] = globalCtx->envCtx.lightSettings.diffuseColor1[i]; } if (this->unk_1D3 != 0) { @@ -279,14 +279,15 @@ void func_808B8E78(DoorWarp1* this, GlobalContext* globalCtx) { } s32 func_808B900C(DoorWarp1* this, GlobalContext* globalCtx) { - u32 index; + s32 index; u8 ret = false; - if (func_800EE29C(globalCtx, 0x239)) { - index = func_800EE200(globalCtx, 0x239); - if (this->unk_208 != globalCtx->csCtx.npcActions[index]->unk0) { - this->unk_208 = globalCtx->csCtx.npcActions[index]->unk0; - if (globalCtx->csCtx.npcActions[index]->unk0 == 2) { + if (Cutscene_CheckActorAction(globalCtx, 569)) { + index = Cutscene_GetActorActionIndex(globalCtx, 569); + + if (this->unk_208 != globalCtx->csCtx.actorActions[index]->action) { + this->unk_208 = globalCtx->csCtx.actorActions[index]->action; + if (globalCtx->csCtx.actorActions[index]->action == 2) { ret = true; } } @@ -344,7 +345,7 @@ void func_808B921C(DoorWarp1* this, GlobalContext* globalCtx) { if (func_808B866C(this, globalCtx) && !func_801690CC(globalCtx)) { func_800B7298(globalCtx, &this->dyna.actor, 7); - func_801518B0(globalCtx, 0xF2, &this->dyna.actor); + Message_StartTextbox(globalCtx, 0xF2, &this->dyna.actor); DoorWarp1_SetupAction(this, func_808B93A0); } @@ -831,15 +832,15 @@ void func_808BA550(DoorWarp1* this, GlobalContext* globalCtx) { } if (this->unk_1D0 > 140) { - globalCtx->envCtx.unk_E5 = 1; + globalCtx->envCtx.fillScreen = 1; temp_f0 = (this->unk_1D0 - 140) / 20.0f; if (temp_f0 > 1.0f) { temp_f0 = 1.0f; } - globalCtx->envCtx.unk_E6[0] = 160; - globalCtx->envCtx.unk_E6[1] = 160; - globalCtx->envCtx.unk_E6[2] = 160; - globalCtx->envCtx.unk_E6[3] = 255.0f * temp_f0; + globalCtx->envCtx.screenFillColor[0] = 160; + globalCtx->envCtx.screenFillColor[1] = 160; + globalCtx->envCtx.screenFillColor[2] = 160; + globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; } Lights_PointNoGlowSetInfo(&this->unk_1E0, player->actor.world.pos.x + 10.0f, player->actor.world.pos.y + 10.0f, @@ -862,13 +863,13 @@ void func_808BA550(DoorWarp1* this, GlobalContext* globalCtx) { temp_f16 = -255.0f * temp_f0; for (i = 0; i < 3; i++) { - globalCtx->envCtx.unk_8C.diffuseColor1[i] = temp_f16; - globalCtx->envCtx.unk_8C.fogColor[i] = temp_f16; - globalCtx->envCtx.unk_8C.ambientColor[i] = temp_f16; + globalCtx->envCtx.lightSettings.diffuseColor1[i] = temp_f16; + globalCtx->envCtx.lightSettings.fogColor[i] = temp_f16; + globalCtx->envCtx.lightSettings.ambientColor[i] = temp_f16; } - globalCtx->envCtx.unk_8C.fogNear = -500.0f * temp_f0; - if (globalCtx->envCtx.unk_8C.fogNear < -300) { + globalCtx->envCtx.lightSettings.fogNear = -500.0f * temp_f0; + if (globalCtx->envCtx.lightSettings.fogNear < -300) { globalCtx->roomCtx.currRoom.segment = NULL; } } diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c index e8e78d650..7f540f3b6 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -455,7 +455,7 @@ void func_80BED3BC(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BED680(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -526,7 +526,7 @@ void func_80BED680(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BED8A4(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -632,7 +632,7 @@ void func_80BED8A4(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BEDB88(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -704,7 +704,7 @@ void func_80BEDB88(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -805,7 +805,7 @@ void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BEE070(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -872,7 +872,7 @@ void func_80BEE070(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BEE274(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -966,7 +966,7 @@ void func_80BEE274(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BEE530(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -1033,7 +1033,7 @@ void func_80BEE530(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BEE73C(EnAkindonuts* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index e3e9b35ff..26cde7e4c 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -411,7 +411,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); } void func_809C1C9C(EnAob01* this, GlobalContext* globalCtx) { @@ -439,13 +439,13 @@ void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { if (gSaveContext.rupees < 10) { play_sound(NA_SE_SY_ERROR); this->unk_210 = 0x3524; - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); } else { func_8019F208(); this->unk_2D2 |= 4; this->unk_2D2 |= 0x10; this->unk_210 = 0x3522; - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); this->actionFunc = func_809C21E0; } break; @@ -453,7 +453,7 @@ void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { case 1: func_8019F230(); this->unk_210 = 0x3535; - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); break; } } @@ -556,7 +556,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x40; this->unk_43C = 1; Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); - func_801518B0(globalCtx, 0x354B, &this->actor); + Message_StartTextbox(globalCtx, 0x354B, &this->actor); } this->unk_2D2 &= ~8; } @@ -738,7 +738,7 @@ void func_809C28B8(EnAob01* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); this->actionFunc = func_809C2D0C; } else if (this->actor.xzDistToPlayer < 100.0f) { func_800B8614(&this->actor, globalCtx, 100.0f); @@ -824,7 +824,7 @@ void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 &= ~0x80; if (this->unk_434 >= 150) { this->unk_210 = 0x352E; - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); this->actionFunc = func_809C2A64; } else { this->unk_2D4 = this->unk_2E6; @@ -842,7 +842,7 @@ void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { } this->unk_210 = 0x354C; - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); this->actionFunc = func_809C1D64; gSaveContext.eventInf[0] &= (u8)~7; } diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index 1afcf5109..25cf5e6e4 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -233,7 +233,7 @@ void func_80BA886C(EnBaba* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_1E0, &this->actor); + Message_StartTextbox(globalCtx, this->unk_1E0, &this->actor); if (this->unk_40A & 1) { if (this->unk_40A & 0x40) { this->unk_40A &= ~0x40; @@ -603,7 +603,7 @@ void func_80BA9B80(EnBaba* this, GlobalContext* globalCtx) { if (this->unk_40A & 2) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x2A39, &this->actor); // "I'm sorry" + Message_StartTextbox(globalCtx, 0x2A39, &this->actor); // "I'm sorry" this->actionFunc = func_80BA9848; } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index 092595bdc..00f4be6e8 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -187,7 +187,7 @@ void EnBba01_Talk(EnHy* this, GlobalContext* globalCtx) { case 0: yaw = ABS_ALT(this->actor.shape.rot.y - this->actor.yawTowardsPlayer); if (yaw < 0x64) { - func_801518B0(globalCtx, this->textId, NULL); + Message_StartTextbox(globalCtx, this->textId, NULL); } break; case 2: diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index 8c72d369c..f305684ed 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -863,7 +863,7 @@ void EnBigslime_Scale(EnBigslime* this, s16 pitch, f32 xzScale, f32 yScale) { * Set the params used by the floor shockwave when bigslime shatters into minislime */ void EnBigslime_InitShockwave(EnBigslime* this, GlobalContext* globalCtx) { - globalCtx->envCtx.unk_C3 = 3; + globalCtx->envCtx.lightSettingOverride = 3; Math_Vec3f_Copy(&this->frozenPos, &this->actor.world.pos); this->frozenPos.y = GBT_ROOM_5_MIN_Y; this->shockwaveAlpha = 235; @@ -931,7 +931,7 @@ void EnBigslime_SetupCutsceneStartBattle(EnBigslime* this, GlobalContext* global Player* player = GET_PLAYER(globalCtx); Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); - globalCtx->envCtx.unk_C3 = 4; + globalCtx->envCtx.lightSettingOverride = 4; Animation_PlayLoop(&this->skelAnime, &gGekkoLookAroundAnim); this->bigslimeCollider[0].base.atFlags &= ~AT_ON; @@ -1008,7 +1008,7 @@ void EnBigslime_CallMinislime(EnBigslime* this, GlobalContext* globalCtx) { EnBigslime_UpdateCameraIntroCs(this, globalCtx, 25); func_801A2E54(0x38); EnBigslime_InitFallMinislime(this); - globalCtx->envCtx.unk_C3 = 0xFF; + globalCtx->envCtx.lightSettingOverride = 0xFF; this->callTimer = 35; func_800B7298(globalCtx, &this->actor, 4); } @@ -1988,7 +1988,7 @@ void EnBigslime_Melt(EnBigslime* this, GlobalContext* globalCtx) { if (this->meltCounter == 100) { EnBigslime_SetTargetVtxFromPreFrozen(this); } else if (this->meltCounter == 50) { - globalCtx->envCtx.unk_C3 = 0xFF; + globalCtx->envCtx.lightSettingOverride = 0xFF; } } @@ -2582,7 +2582,7 @@ void EnBigslime_ApplyDamageEffectBigslime(EnBigslime* this, GlobalContext* globa if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_ICE) { EnMinislime* minislime; - globalCtx->envCtx.unk_C3 = 2; + globalCtx->envCtx.lightSettingOverride = 2; EnBigslime_SetPlayerParams(this, globalCtx); this->rotation = 0; EnBigslime_SetupFreeze(this); @@ -2772,8 +2772,8 @@ void EnBigslime_UpdateBigslime(Actor* thisx, GlobalContext* globalCtx) { Vec3f vtxMax; Vec3f vtxMin; - if (globalCtx->envCtx.unk_C3 == 3) { - globalCtx->envCtx.unk_C3 = 0xFF; + if (globalCtx->envCtx.lightSettingOverride == 3) { + globalCtx->envCtx.lightSettingOverride = 0xFF; } func_8019F540(1); @@ -2817,8 +2817,8 @@ void EnBigslime_UpdateGekko(Actor* thisx, GlobalContext* globalCtx) { Player* player; s32 pad; - if (globalCtx->envCtx.unk_C3 == 3) { - globalCtx->envCtx.unk_C3 = 0xFF; + if (globalCtx->envCtx.lightSettingOverride == 3) { + globalCtx->envCtx.lightSettingOverride = 0xFF; } func_8019F540(0); diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index fd6c8aae7..53bdc0995 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -183,7 +183,7 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { tempDay = gSaveContext.day; tempTimeBeforeMoonCrash = ((-(tempDay % 5 << 0x10) - ((u16)(gSaveContext.time - 0x4000))) + 0x40000); - if (tempTimeBeforeMoonCrash < 2730.6667f) { /* 1 hr */ + if (tempTimeBeforeMoonCrash < CLOCK_TIME_F(1, 0)) { /* 1 hr */ this->textId = 0x5E8; } else { this->textId = 0x5EB; @@ -203,7 +203,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x444); func_809CCDE0(this, globalCtx); if (this->actor.shape.rot.y == this->actor.yawTowardsPlayer) { - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } break; case 4: diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/src/overlays/actors/ovl_En_Bom/z_en_bom.c index 7d9b0a6b3..57a88bcef 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -350,28 +350,28 @@ void func_808715B8(EnBom* this, GlobalContext* globalCtx) { CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); } - if (globalCtx->envCtx.unk_8C.diffuseColor1[0] != 0) { - globalCtx->envCtx.unk_8C.diffuseColor1[0] -= 25; + if (globalCtx->envCtx.lightSettings.diffuseColor1[0] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[0] -= 25; } - if (globalCtx->envCtx.unk_8C.diffuseColor1[1] != 0) { - globalCtx->envCtx.unk_8C.diffuseColor1[1] -= 25; + if (globalCtx->envCtx.lightSettings.diffuseColor1[1] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[1] -= 25; } - if (globalCtx->envCtx.unk_8C.diffuseColor1[2] != 0) { - globalCtx->envCtx.unk_8C.diffuseColor1[2] -= 25; + if (globalCtx->envCtx.lightSettings.diffuseColor1[2] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[2] -= 25; } - if (globalCtx->envCtx.unk_8C.ambientColor[0] != 0) { - globalCtx->envCtx.unk_8C.ambientColor[0] -= 25; + if (globalCtx->envCtx.lightSettings.ambientColor[0] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[0] -= 25; } - if (globalCtx->envCtx.unk_8C.ambientColor[1] != 0) { - globalCtx->envCtx.unk_8C.ambientColor[1] -= 25; + if (globalCtx->envCtx.lightSettings.ambientColor[1] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[1] -= 25; } - if (globalCtx->envCtx.unk_8C.ambientColor[2] != 0) { - globalCtx->envCtx.unk_8C.ambientColor[2] -= 25; + if (globalCtx->envCtx.lightSettings.ambientColor[2] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[2] -= 25; } if (this->timer == 0) { @@ -533,10 +533,10 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, sp80.x, sp80.y - 10.0f, sp80.z, 0, 0, 0, this->isPowderKeg); func_800BC848(thisx, globalCtx, D_80872E98[this->isPowderKeg], D_80872E9C[this->isPowderKeg]); - globalCtx->envCtx.unk_8C.diffuseColor1[0] = globalCtx->envCtx.unk_8C.diffuseColor1[1] = - globalCtx->envCtx.unk_8C.diffuseColor1[2] = 250; - globalCtx->envCtx.unk_8C.ambientColor[0] = globalCtx->envCtx.unk_8C.ambientColor[1] = - globalCtx->envCtx.unk_8C.ambientColor[2] = 250; + globalCtx->envCtx.lightSettings.diffuseColor1[0] = globalCtx->envCtx.lightSettings.diffuseColor1[1] = + globalCtx->envCtx.lightSettings.diffuseColor1[2] = 250; + globalCtx->envCtx.lightSettings.ambientColor[0] = globalCtx->envCtx.lightSettings.ambientColor[1] = + globalCtx->envCtx.lightSettings.ambientColor[2] = 250; func_800DFD04(&globalCtx->mainCamera, 2, 11, 8); thisx->params = ENBOM_1; this->timer = 10; diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c index 7bd4fa89f..397f23068 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c @@ -232,9 +232,9 @@ void func_809C4DA4(EnBomBowlMan* this, GlobalContext* globalCtx) { this->unk_2D4 = this->actor.yawTowardsPlayer; this->unk_290 = this->actor.yawTowardsPlayer; if (player->transformation == PLAYER_FORM_HUMAN) { - func_801518B0(globalCtx, D_809C618C[0], &this->actor); + Message_StartTextbox(globalCtx, D_809C618C[0], &this->actor); } else { - func_801518B0(globalCtx, D_809C6198[0], &this->actor); + Message_StartTextbox(globalCtx, D_809C6198[0], &this->actor); } } @@ -406,7 +406,7 @@ void func_809C5524(EnBomBowlMan* this, GlobalContext* globalCtx) { this->actor.textId = 0x72F; } func_809C493C(this, 3, 1.0f); - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = func_809C5598; } @@ -585,10 +585,10 @@ void func_809C5BF4(EnBomBowlMan* this, GlobalContext* globalCtx) { D_809C6100 = 0; if (player->transformation == PLAYER_FORM_HUMAN) { this->unk_2C0 = 5; - func_801518B0(globalCtx, D_809C618C[this->unk_2C0], &this->actor); + Message_StartTextbox(globalCtx, D_809C618C[this->unk_2C0], &this->actor); } else { this->unk_2C0 = 3; - func_801518B0(globalCtx, D_809C6198[this->unk_2C0], &this->actor); + Message_StartTextbox(globalCtx, D_809C6198[this->unk_2C0], &this->actor); } this->unk_29C = 0; this->actionFunc = func_809C4DA4; diff --git a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c index 77f3ad96b..26e9291d1 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -661,7 +661,7 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { func_80C0113C(this, 21, 1.0f); if ((player->transformation != PLAYER_FORM_DEKU) && (player->transformation != PLAYER_FORM_HUMAN)) { func_80C0113C(this, 17, 1.0f); - func_801518B0(globalCtx, 0x72E, &this->actor); + Message_StartTextbox(globalCtx, 0x72E, &this->actor); player->stateFlags1 |= 0x10000000; player->actor.freezeTimer = 3; func_80C012E0(this); @@ -673,7 +673,7 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { if (((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.weekEventReg[73] & 0x10)) || ((player->transformation == PLAYER_FORM_HUMAN) && !(gSaveContext.weekEventReg[85] & 2))) { func_80C0113C(this, 17, 1.0f); - func_801518B0(globalCtx, 0x72E, &this->actor); + Message_StartTextbox(globalCtx, 0x72E, &this->actor); player->stateFlags1 |= 0x10000000; player->actor.freezeTimer = 3; func_80C012E0(this); @@ -683,7 +683,7 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { } idx = gSaveContext.unk_FE6; - func_801518B0(globalCtx, D_80C03230[idx], &this->actor); + Message_StartTextbox(globalCtx, D_80C03230[idx], &this->actor); idx = gSaveContext.unk_FE6; gSaveContext.unk_FE7[idx] = this->unk_2C8 + 1; gSaveContext.unk_FE6++; diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index 2992f356e..cddff71cc 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -544,7 +544,7 @@ void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { } break; case 1: - func_800EA0D4(globalCtx, &globalCtx->csCtx); + Cutscene_Start(globalCtx, &globalCtx->csCtx); this->subCamId = Play_CreateSubCamera(globalCtx); Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); Play_CameraChangeStatus(globalCtx, this->subCamId, 7); @@ -556,7 +556,7 @@ void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { this->subCamAt.x = mainCam->at.x; this->subCamAt.y = mainCam->at.y; this->subCamAt.z = mainCam->at.z; - func_801518B0(globalCtx, 0xF, NULL); + Message_StartTextbox(globalCtx, 0xF, NULL); this->cameraState = 2; func_8019FDC8(&D_801DB4A4, NA_SE_VO_NA_LISTEN, 0x20); case 2: @@ -573,7 +573,7 @@ void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { mainCam->eyeNext = this->subCamEye; mainCam->at = this->subCamAt; func_80169AFC(globalCtx, this->subCamId, 0); - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); this->cameraState = 0; this->subCamId = CAM_ID_MAIN; diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index 1d61df5bc..3d8623e7a 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -177,7 +177,7 @@ void EnCne01_Talk(EnHy* this, GlobalContext* globalCtx) { case 0: yaw = ABS_ALT(this->actor.shape.rot.y - this->actor.yawTowardsPlayer); if (yaw < 0x64) { - func_801518B0(globalCtx, this->textId, NULL); + Message_StartTextbox(globalCtx, this->textId, NULL); } break; case 2: diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index 82562d45c..3b96d1b4d 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -179,7 +179,7 @@ s32 func_80B3E69C(EnDai* this, GlobalContext* globalCtx) { s32 ret = false; if ((globalCtx->csCtx.state != 0) && (globalCtx->sceneNum == SCENE_12HAKUGINMAE) && - (globalCtx->csCtx.unk_12 == 0) && !(gSaveContext.weekEventReg[30] & 1)) { + (globalCtx->csCtx.currentCsIndex == 0) && !(gSaveContext.weekEventReg[30] & 1)) { if (!(this->unk_1CE & 0x10)) { Flags_SetSwitch(globalCtx, 20); this->unk_1CE |= (0x80 | 0x10); @@ -444,13 +444,12 @@ void func_80B3F044(EnDai* this, GlobalContext* globalCtx) { static s32 D_80B3FE38[] = { 0, 0, 6, 7, 8, }; - s32 sp2C = 0; s32 sp28; - if (func_800EE29C(globalCtx, 0x1D8)) { - sp2C = func_800EE200(globalCtx, 0x1D8); - sp28 = globalCtx->csCtx.npcActions[sp2C]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 472)) { + sp2C = Cutscene_GetActorActionIndex(globalCtx, 472); + sp28 = globalCtx->csCtx.actorActions[sp2C]->action; if (this->unk_1CC != (u8)sp28) { func_80B3E5DC(this, D_80B3FE38[sp28]); switch (sp28) { @@ -508,7 +507,7 @@ void func_80B3F044(EnDai* this, GlobalContext* globalCtx) { break; } - func_800EDF24(&this->actor, globalCtx, sp2C); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, sp2C); } void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index 3c247f447..263469dac 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -378,16 +378,16 @@ void func_80989BF8(EnDg* this) { void func_80989D38(EnDg* this, GlobalContext* globalCtx) { if (this->unk_286 == 21) { if (CURRENT_DAY == 1) { - func_801518B0(globalCtx, 0x91C, NULL); + Message_StartTextbox(globalCtx, 0x91C, NULL); } else { - func_801518B0(globalCtx, 0x91E, NULL); + Message_StartTextbox(globalCtx, 0x91E, NULL); } } else if ((this->unk_286 >= 0) && (this->unk_286 < 14)) { - func_801518B0(globalCtx, D_8098C2A8[this->unk_286].unk_04, NULL); + Message_StartTextbox(globalCtx, D_8098C2A8[this->unk_286].unk_04, NULL); } else if (this->unk_286 == 20) { - func_801518B0(globalCtx, 0x353D, NULL); + Message_StartTextbox(globalCtx, 0x353D, NULL); } else { - func_801518B0(globalCtx, 0x627, NULL); + Message_StartTextbox(globalCtx, 0x627, NULL); } } diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index dcb3b9853..079abb641 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -553,7 +553,7 @@ void func_8089B580(EnDinofos* this, GlobalContext* globalCtx) { if (this->skelAnime.curFrame > 35.0f) { if ((globalCtx->sceneNum == SCENE_MITURIN) && Animation_OnFrame(&this->skelAnime, 38.0f)) { - globalCtx->envCtx.unk_C3 = 11; + globalCtx->envCtx.lightSettingOverride = 11; } Math_Vec3f_StepTo(&subCam->eye, &this->unk_2BC, 10.0f); @@ -564,7 +564,7 @@ void func_8089B580(EnDinofos* this, GlobalContext* globalCtx) { } if ((globalCtx->sceneNum == SCENE_MITURIN) && Animation_OnFrame(&this->skelAnime, 55.0f)) { - globalCtx->envCtx.unk_C3 = 0xFF; + globalCtx->envCtx.lightSettingOverride = 0xFF; } if (SkelAnime_Update(&this->skelAnime)) { @@ -1054,7 +1054,7 @@ void func_8089CB10(EnDinofos* this, GlobalContext* globalCtx) { } if (globalCtx->sceneNum == SCENE_MITURIN) { - globalCtx->envCtx.unk_C3 = 11; + globalCtx->envCtx.lightSettingOverride = 11; } this->actionFunc = func_8089CBEC; @@ -1115,7 +1115,7 @@ void func_8089CF00(EnDinofos* this, GlobalContext* globalCtx) { Animation_PlayOnce(&this->skelAnime, &object_dinofos_Anim_0017B8); this->colliderJntSph.base.atFlags &= ~AT_ON; if (globalCtx->sceneNum == SCENE_MITURIN) { - globalCtx->envCtx.unk_C3 = 255; + globalCtx->envCtx.lightSettingOverride = 255; } this->actionFunc = func_8089CF70; } @@ -1285,7 +1285,7 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { func_8089ACEC(this, globalCtx); func_8089AD70(this); if (globalCtx->sceneNum == SCENE_MITURIN) { - globalCtx->envCtx.unk_C3 = 255; + globalCtx->envCtx.lightSettingOverride = 255; } this->colliderQuad.base.atFlags &= ~(AT_ON | AT_BOUNCED); diff --git a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c index 3692f4a4a..d04ed3ee1 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -213,8 +213,8 @@ void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { } void func_80A51890(EnDnk* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x7E)) { - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x7E)); + if (Cutscene_CheckActorAction(globalCtx, 126)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 126)); } } diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.c b/src/overlays/actors/ovl_En_Dno/z_en_dno.c index 03925cbe5..f05817282 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -334,19 +334,19 @@ void func_80A71C3C(EnDno* this, GlobalContext* globalCtx) { void func_80A71E54(EnDno* this, GlobalContext* globalCtx) { if (CHECK_QUEST_ITEM(QUEST_SONG_SONATA)) { if (gSaveContext.weekEventReg[27] & 1) { - this->unk_464 = 0x811; + this->textId = 0x811; } else { - this->unk_464 = 0x80F; + this->textId = 0x80F; gSaveContext.weekEventReg[27] |= 1; } } else if (gSaveContext.weekEventReg[26] & 0x80) { - this->unk_464 = 0x80B; + this->textId = 0x80B; } else { - this->unk_464 = 0x80C; + this->textId = 0x80C; gSaveContext.weekEventReg[26] |= 0x80; } - if (this->unk_464 != 0x811) { + if (this->textId != 0x811) { this->unk_3B0 |= 0x10; } else { this->unk_3B0 &= ~0x10; @@ -361,12 +361,12 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { case 0: if (!(this->unk_3B0 & 0x10) || Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xE38)) { - switch (this->unk_464) { + switch (this->textId) { case 0x80B: SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 16, &this->unk_32C); case 0x811: - func_801518B0(globalCtx, this->unk_464, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); break; case 0x80C: @@ -375,7 +375,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 4, &this->unk_32C); } else if ((this->unk_32C == 4) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 11, &this->unk_32C); - func_801518B0(globalCtx, this->unk_464, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } break; } @@ -548,11 +548,11 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { } } else if ((this->unk_32C == 5) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Flags_GetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor))) { - func_801518B0(globalCtx, 0x801, &this->actor); + Message_StartTextbox(globalCtx, 0x801, &this->actor); } else if (Player_GetMask(globalCtx) == PLAYER_MASK_SCENTS) { - func_801518B0(globalCtx, 0x806, &this->actor); + Message_StartTextbox(globalCtx, 0x806, &this->actor); } else { - func_801518B0(globalCtx, 0x800, &this->actor); + Message_StartTextbox(globalCtx, 0x800, &this->actor); } SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); } @@ -561,12 +561,12 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { case 2: if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2D8)) { gSaveContext.weekEventReg[93] |= 2; - func_801518B0(globalCtx, 0x802, &this->actor); + Message_StartTextbox(globalCtx, 0x802, &this->actor); } break; case 3: - func_801518B0(globalCtx, 0x804, &this->actor); + Message_StartTextbox(globalCtx, 0x804, &this->actor); break; } break; @@ -590,7 +590,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 12, &this->unk_32C); - func_801518B0(globalCtx, 0x803, &this->actor); + Message_StartTextbox(globalCtx, 0x803, &this->actor); } } break; @@ -854,12 +854,12 @@ void func_80A732C8(EnDno* this, GlobalContext* globalCtx) { void func_80A73408(EnDno* this, GlobalContext* globalCtx) { s32 phi_a2; u8 sp33 = true; - u32 temp_v0; + s32 temp_v0; - if (func_800EE29C(globalCtx, 0x1DB)) { - temp_v0 = func_800EE200(globalCtx, 0x1DB); - if (this->unk_468 != globalCtx->csCtx.npcActions[temp_v0]->unk0) { - switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 475)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 475); + if (this->unk_468 != globalCtx->csCtx.actorActions[temp_v0]->action) { + switch (globalCtx->csCtx.actorActions[temp_v0]->action) { case 1: phi_a2 = 13; break; @@ -878,7 +878,7 @@ void func_80A73408(EnDno* this, GlobalContext* globalCtx) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); } } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); } if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && (this->unk_32C == 17)) { diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.h b/src/overlays/actors/ovl_En_Dno/z_en_dno.h index ed9ee52c6..350e0c004 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.h +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.h @@ -51,7 +51,7 @@ typedef struct EnDno { /* 0x458 */ s32 unk_458; /* 0x45C */ s16 unk_45C; /* 0x460 */ Actor* unk_460; - /* 0x464 */ u16 unk_464; + /* 0x464 */ u16 textId; /* 0x466 */ s16 unk_466; /* 0x468 */ u8 unk_468; } EnDno; // size = 0x46C diff --git a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c index fa3448e04..d7274837c 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -244,18 +244,18 @@ void func_80B3D11C(EnDnp* this, GlobalContext* globalCtx) { static s32 D_80B3DE74[] = { 0, 16, 14, 10, 18, 12, 5, 7, 2, 19, 21, 22, 24, 8, }; - u32 temp_v0; + s32 temp_v0; s32 val; if (!(gSaveContext.weekEventReg[29] & 0x40) && (globalCtx->sceneNum == SCENE_MITURIN) && - (globalCtx->csCtx.unk_12 == 0)) { + (globalCtx->csCtx.currentCsIndex == 0)) { this->unk_322 |= 0x20; gSaveContext.weekEventReg[29] |= 0x40; } - if (func_800EE29C(globalCtx, 0x65)) { - temp_v0 = func_800EE200(globalCtx, 0x65); - val = globalCtx->csCtx.npcActions[temp_v0]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 101)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 101); + val = globalCtx->csCtx.actorActions[temp_v0]->action; if (this->unk_324 != (u8)val) { func_80B3CC38(this, D_80B3DE74[val]); if (this->unk_340 == 16) { @@ -281,7 +281,7 @@ void func_80B3D11C(EnDnp* this, GlobalContext* globalCtx) { Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_80B3CC38(this, this->unk_340 + 1); } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); } } diff --git a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c index 85df3499b..f25abc6a4 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -345,7 +345,7 @@ void func_80A52DC8(EnDnq* this, GlobalContext* globalCtx) { if (Interface_HasItemInBottle(ITEM_DEKU_PRINCESS) && !func_801690CC(globalCtx) && (Message_GetState(&globalCtx->msgCtx) == 0) && (ActorCutscene_GetCurrentIndex() == -1)) { if ((DECR(this->unk_384) == 0) && (gSaveContext.weekEventReg[29] & 0x40)) { - func_801518B0(globalCtx, 0x969, NULL); + Message_StartTextbox(globalCtx, 0x969, NULL); this->unk_384 = 200; } } @@ -388,12 +388,12 @@ void func_80A53038(EnDnq* this, GlobalContext* globalCtx) { static s32 D_80A535FC[] = { 0, 1, 2, 3, 5, 6, }; - u32 temp_v0; + s32 temp_v0; u32 temp_v1; - if (func_800EE29C(globalCtx, 0x69)) { - temp_v0 = func_800EE200(globalCtx, 0x69); - temp_v1 = globalCtx->csCtx.npcActions[temp_v0]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 105)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 105); + temp_v1 = globalCtx->csCtx.actorActions[temp_v0]->action; if (this->unk_1DC != (u8)temp_v1) { func_80A5257C(this, D_80A535FC[temp_v1]); this->unk_1DC = temp_v1; @@ -408,7 +408,7 @@ void func_80A53038(EnDnq* this, GlobalContext* globalCtx) { func_80A5257C(this, this->unk_398 + 1); } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); } } diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c index 9a4562ae2..b9f1605f9 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -210,16 +210,16 @@ s32* func_8092C9BC(EnDns* this, GlobalContext* globalCtx) { s32 func_8092CA74(EnDns* this) { switch (ENDNS_GET_7(&this->actor)) { case ENDNS_GET_7_0: - return 0x1D1; + return 465; case ENDNS_GET_7_1: - return 0x1D2; + return 466; case ENDNS_GET_7_2: - return 0x1D3; + return 467; case ENDNS_GET_7_3: - return 0x1D4; + return 468; } return 0; @@ -480,12 +480,12 @@ void func_8092D5E8(EnDns* this, GlobalContext* globalCtx) { EN_DNS_ANIMATION_SURPRISE_START, EN_DNS_ANIMATION_RUN_START, }; - u32 temp_v0; + s32 temp_v0; u32 temp_v1; - if (func_800EE29C(globalCtx, this->unk_2C8)) { - temp_v0 = func_800EE200(globalCtx, this->unk_2C8); - temp_v1 = globalCtx->csCtx.npcActions[temp_v0]->unk0; + if (Cutscene_CheckActorAction(globalCtx, this->unk_2C8)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, this->unk_2C8); + temp_v1 = globalCtx->csCtx.actorActions[temp_v0]->action; if (this->unk_1D8 != (u8)temp_v1) { func_8092C63C(this, D_8092DE0C[temp_v1]); this->unk_1D8 = temp_v1; @@ -497,7 +497,7 @@ void func_8092D5E8(EnDns* this, GlobalContext* globalCtx) { func_8092C63C(this, this->animationIndex + 1); } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); } } diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index 2c0fcc116..134a7080e 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -854,8 +854,8 @@ void func_8088E60C(EnElf* this, GlobalContext* globalCtx) { glowLightRadius = 0; } - if (func_800EE29C(globalCtx, 0xC9)) { - if (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0xC9)]->unk0 == 6) { + if (Cutscene_CheckActorAction(globalCtx, 201)) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 201)]->action == 6) { glowLightRadius = 0; } } @@ -888,12 +888,12 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { func_8088E5A8(this, globalCtx); xScale = 0.0f; - if (func_800EE29C(globalCtx, 0xC9)) { - sp38 = func_800EE200(globalCtx, 0xC9); + if (Cutscene_CheckActorAction(globalCtx, 201)) { + sp38 = Cutscene_GetActorActionIndex(globalCtx, 201); func_808908D0(&nextPos, globalCtx, sp38); - this->actor.shape.rot.y = globalCtx->csCtx.npcActions[sp38]->unk8; - this->actor.shape.rot.x = globalCtx->csCtx.npcActions[sp38]->unk6; - if (globalCtx->csCtx.npcActions[sp38]->unk0 == 5) { + this->actor.shape.rot.y = globalCtx->csCtx.actorActions[sp38]->urot.y; + this->actor.shape.rot.x = globalCtx->csCtx.actorActions[sp38]->urot.x; + if (globalCtx->csCtx.actorActions[sp38]->action == 5) { func_8088F5F4(this, globalCtx, 16); } @@ -904,14 +904,14 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { } if ((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 0) && - (globalCtx->csCtx.unk_12 == 0) && + (globalCtx->csCtx.currentCsIndex == 0) && ((globalCtx->csCtx.frames == 149) || (globalCtx->csCtx.frames == 381) || (globalCtx->csCtx.frames == 591))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } if ((globalCtx->sceneNum == SCENE_SECOM) && (gSaveContext.sceneSetupIndex == 0) && - (globalCtx->csCtx.unk_12 == 4) && (globalCtx->csCtx.frames == 95)) { + (globalCtx->csCtx.currentCsIndex == 4) && (globalCtx->csCtx.frames == 95)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } } else { @@ -1016,7 +1016,7 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { func_8088E60C(this, globalCtx); - if (!func_800EE29C(globalCtx, 0xC9)) { + if (!Cutscene_CheckActorAction(globalCtx, 0xC9)) { this->actor.shape.rot.y = this->unk_258; } } @@ -1107,8 +1107,8 @@ void func_8088F214(EnElf* this, GlobalContext* globalCtx) { s32 pad; if (globalCtx->csCtx.state != 0) { - if (func_800EE29C(globalCtx, 0xC9)) { - switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0xC9)]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 201)) { + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 201)]->action) { case 4: sp34 = 7; break; @@ -1577,8 +1577,8 @@ void EnElf_Draw(Actor* thisx, GlobalContext* globalCtx) { if (player->currentMask != PLAYER_MASK_GIANT) { if (!(this->fairyFlags & 8) && - (!func_800EE29C(globalCtx, 0xC9) || - (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0xC9)]->unk0 != 6)) && + (!Cutscene_CheckActorAction(globalCtx, 201) || + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 201)]->action != 6)) && (!(player->stateFlags1 & 0x100000) || (kREG(90) < this->actor.projectedPos.z))) { Gfx* dListHead = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); f32 alphaScale; @@ -1621,17 +1621,17 @@ void EnElf_Draw(Actor* thisx, GlobalContext* globalCtx) { void func_808908D0(Vec3f* vec, GlobalContext* globalCtx, u32 action) { Vec3f startPos; Vec3f endPos; - CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[action]; + CsCmdActorAction* npcAction = globalCtx->csCtx.actorActions[action]; f32 lerp; - startPos.x = npcAction->unk0C.x; - startPos.y = npcAction->unk0C.y; - startPos.z = npcAction->unk0C.z; + startPos.x = npcAction->startPos.x; + startPos.y = npcAction->startPos.y; + startPos.z = npcAction->startPos.z; - endPos.x = npcAction->unk18.x; - endPos.y = npcAction->unk18.y; - endPos.z = npcAction->unk18.z; + endPos.x = npcAction->endPos.x; + endPos.y = npcAction->endPos.y; + endPos.z = npcAction->endPos.z; - lerp = func_800F5A8C(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames, globalCtx); + lerp = Environment_LerpWeight(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames); VEC3F_LERPIMPDST(vec, &startPos, &endPos, lerp); } diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index 9f58e4d9b..3c263c018 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -456,7 +456,7 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { if (STRAY_FAIRY_TYPE(&this->actor) == STRAY_FAIRY_TYPE_CLOCK_TOWN) { player->actor.freezeTimer = 100; player->stateFlags1 |= 0x20000000; - func_801518B0(globalCtx, 0x579, NULL); + Message_StartTextbox(globalCtx, 0x579, NULL); this->actionFunc = EnElforg_ClockTownFairyCollected; ActorCutscene_SetIntentToPlay(0x7C); return; @@ -464,7 +464,7 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { if (func_8010A074(globalCtx)) { gSaveContext.inventory.strayFairies[gSaveContext.unk_48C8]++; - func_801518B0(globalCtx, 0x11, NULL); + Message_StartTextbox(globalCtx, 0x11, NULL); if (gSaveContext.inventory.strayFairies[(void)0, gSaveContext.unk_48C8] >= 15) { func_801A3098(NA_BGM_GET_ITEM | 0x900); } diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.c b/src/overlays/actors/ovl_En_Fall/z_en_fall.c index ef954baaf..8c7f291ce 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -313,7 +313,8 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globalCtx) { static s32 sGiantsCutsceneState = 0; - if (globalCtx->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 1 && globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 1 && + globalCtx->csCtx.currentCsIndex == 0) { switch (sGiantsCutsceneState) { case 0: if (globalCtx->csCtx.state != 0) { @@ -357,14 +358,15 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globa void EnFall_CrashingMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx) { EnFall_CrashingMoon_HandleGiantsCutscene(this, globalCtx); - if (func_800EE29C(globalCtx, 0x85)) { - if (func_800EE29C(globalCtx, 0x85) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0 == 1) { + if (Cutscene_CheckActorAction(globalCtx, 0x85)) { + if (Cutscene_CheckActorAction(globalCtx, 133) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action == 1) { this->actor.draw = NULL; } else { this->actor.draw = EnFall_Moon_Draw; - if (func_800EE29C(globalCtx, 0x85) && - globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0 == 2) { - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x85)); + if (Cutscene_CheckActorAction(globalCtx, 133) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action == 2) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 133)); } } } else { @@ -373,8 +375,8 @@ void EnFall_CrashingMoon_PerformCutsceneActions(EnFall* this, GlobalContext* glo } void EnFall_StoppedOpenMouthMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x85)) { - switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 133)) { + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action) { case 3: if (this->eyeGlowIntensity == 0.0f) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MOON_EYE_FLASH); @@ -393,10 +395,10 @@ void EnFall_StoppedOpenMouthMoon_PerformCutsceneActions(EnFall* this, GlobalCont } void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x85)) { - switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 133)) { + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action) { case 2: - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x85)); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 133)); break; case 4: @@ -406,7 +408,7 @@ void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, GlobalCo } if (globalCtx->sceneNum == SCENE_OKUJOU && gSaveContext.sceneSetupIndex == 2) { - switch (globalCtx->csCtx.unk_12) { + switch (globalCtx->csCtx.currentCsIndex) { case 0: switch (globalCtx->csCtx.frames) { case 1060: @@ -460,15 +462,16 @@ void EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions(EnFall* this, Glo void EnFall_Moon_PerformDefaultActions(EnFall* this, GlobalContext* globalCtx) { u16 currentDay; - if (func_800EE29C(globalCtx, 0x85)) { - if (func_800EE29C(globalCtx, 0x85) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0 == 1) { + if (Cutscene_CheckActorAction(globalCtx, 133)) { + if (Cutscene_CheckActorAction(globalCtx, 133) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action == 1) { this->actor.draw = NULL; } else { Actor_SetScale(&this->actor, this->scale * 3.6f); this->actor.draw = EnFall_Moon_Draw; - if (func_800EE29C(globalCtx, 0x85) && - globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0 == 2) { - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x85)); + if (Cutscene_CheckActorAction(globalCtx, 133) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action == 2) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 133)); } } } else { @@ -506,7 +509,8 @@ void EnFall_MoonsTear_DoNothing(EnFall* this, GlobalContext* globalCtx) { void EnFall_MoonsTear_Fall(EnFall* this, GlobalContext* globalCtx) { s32 pad; - if (func_800EE29C(globalCtx, 0x205) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x205)]->unk0 == 2 && + if (Cutscene_CheckActorAction(globalCtx, 517) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 517)]->action == 2 && this->actor.draw == NULL) { EnFall_MoonsTear_Initialize(this); } @@ -569,11 +573,12 @@ void EnFall_Fireball_SetPerVertexAlpha(f32 fireballAlpha) { void EnFall_Fireball_Update(Actor* thisx, GlobalContext* globalCtx) { EnFall* this = THIS; - if (globalCtx->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 0 && globalCtx->csCtx.unk_12 == 2) { + if (globalCtx->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 0 && + globalCtx->csCtx.currentCsIndex == 2) { globalCtx->skyboxCtx.rotY -= 0.05f; } - if (func_800EE29C(globalCtx, 0x1C2)) { + if (Cutscene_CheckActorAction(globalCtx, 450)) { this->actor.draw = EnFall_Fireball_Draw; if (this->flags & FLAG_FIRE_BALL_INTENSIFIES) { this->fireballIntensity += 0.01f; @@ -581,9 +586,9 @@ void EnFall_Fireball_Update(Actor* thisx, GlobalContext* globalCtx) { this->fireballIntensity = 1.0f; } } - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x1C2)); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 450)); - switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1C2)]->unk0) { + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 450)]->action) { default: this->actor.draw = NULL; this->fireballAlpha = 0; @@ -620,7 +625,7 @@ void EnFall_Fireball_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.draw = NULL; } - if (func_800EE29C(globalCtx, 0x1C2) && this->fireballAlpha > 0) { + if (Cutscene_CheckActorAction(globalCtx, 0x1C2) && this->fireballAlpha > 0) { func_8019F128(NA_SE_EV_MOON_FALL_LAST - SFX_FLAG); } Actor_SetScale(&this->actor, this->scale * 1.74f); @@ -677,9 +682,9 @@ s32 EnFall_RisingDebris_InitializeParticles(EnFall* this) { void EnFall_RisingDebris_Update(Actor* thisx, GlobalContext* globalCtx) { EnFall* this = THIS; - if (func_800EE29C(globalCtx, 0x1C3)) { - if (func_800EE29C(globalCtx, 0x1C3) && - globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1C3)]->unk0 == 2) { + if (Cutscene_CheckActorAction(globalCtx, 451)) { + if (Cutscene_CheckActorAction(globalCtx, 451) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 451)]->action == 2) { EnFall_RisingDebris_UpdateParticles(this); EnFall_RisingDebris_InitializeParticles(this); } else if (this->activeDebrisParticleCount != 0) { @@ -694,7 +699,8 @@ void EnFall_RisingDebris_Update(Actor* thisx, GlobalContext* globalCtx) { void EnFall_FireRing_Update(Actor* thisx, GlobalContext* globalCtx) { EnFall* this = THIS; - if (func_800EE29C(globalCtx, 0x1C2) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1C2)]->unk0 == 5) { + if (Cutscene_CheckActorAction(globalCtx, 450) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 450)]->action == 5) { if (!(this->flags & FLAG_FIRE_RING_APPEARS)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_DM_RING_EXPLOSION); } 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 1eb5838ca..14e364d56 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -1123,11 +1123,11 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { } if (effect->unk_2C == 30) { - func_801518B0(globalCtx, 0x40B3, NULL); + Message_StartTextbox(globalCtx, 0x40B3, NULL); } if ((effect->unk_2C >= 100) && (Message_GetState(&globalCtx->msgCtx) == 5)) { - if (func_80147624(globalCtx) || !Message_GetState(&globalCtx->msgCtx)) { + if (func_80147624(globalCtx) || Message_GetState(&globalCtx->msgCtx) == 0) { func_801477B4(globalCtx); func_801159EC(-50); effect->unk_2C = -1; @@ -3079,7 +3079,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_172[1] = 50; } - if (!Message_GetState(&globalCtx->msgCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 0) { if ((gSaveContext.time >= 0xC000) && (gSaveContext.time <= 0xC01B)) { this->unk_150 = 7; this->unk_172[3] = Rand_ZeroFloat(150.0f) + 200.0f; @@ -3793,7 +3793,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { player->unk_B28 = 3; func_8013EC44(0.0f, 1, 3, 1); D_809171D8++; - func_800EA0D4(globalCtx, &globalCtx->csCtx); + Cutscene_Start(globalCtx, &globalCtx->csCtx); D_8090CD4C = 100; D_80911F48 = 45.0f; D_8090CD14 = 5; @@ -3875,7 +3875,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { if (this->unk_172[0] <= 50) { switch (this->unk_1CD) { case 0: - if ((Message_GetState(&globalCtx->msgCtx) == 4) || !Message_GetState(&globalCtx->msgCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) || Message_GetState(&globalCtx->msgCtx) == 0) { if (func_80147624(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex == 0) { @@ -3888,7 +3888,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { ((s16)this->unk_1A4 < (s16)D_8090CCF0)) { this->unk_1CD = 1; this->unk_172[0] = 0x3C; - func_801518B0(globalCtx, 0x4098, NULL); + Message_StartTextbox(globalCtx, 0x4098, NULL); } else { f32 temp1 = D_8090CCF0; s16 temp2 = D_809171D0; @@ -3906,7 +3906,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } break; case 1: - if ((Message_GetState(&globalCtx->msgCtx) == 4) || !Message_GetState(&globalCtx->msgCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) || Message_GetState(&globalCtx->msgCtx) == 0) { if (func_80147624(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex != 0) { @@ -4904,7 +4904,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 11: - if (((Message_GetState(&globalCtx->msgCtx) == 5) || !Message_GetState(&globalCtx->msgCtx)) && + if (((Message_GetState(&globalCtx->msgCtx) == 5) || Message_GetState(&globalCtx->msgCtx) == 0) && func_80147624(globalCtx)) { s32 getItemId; @@ -5008,7 +5008,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 22: - if (!Message_GetState(&globalCtx->msgCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 0) { this->unk_154 = 0; if (D_8090CD0C != 0) { D_8090CD08 = 1; @@ -5034,7 +5034,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { if (D_809171D0 == 0) { this->unk_154 = 0; } else { - func_801518B0(globalCtx, 0x409C, NULL); + Message_StartTextbox(globalCtx, 0x409C, NULL); this->unk_154 = 20; } } @@ -5125,7 +5125,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { if ((sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 25.0f)) { D_8090CD08 = 0; D_8090CD0C = 1; - func_801518B0(globalCtx, 0x4087, NULL); + Message_StartTextbox(globalCtx, 0x4087, NULL); } } @@ -5138,7 +5138,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { if (D_8090CCFC != 0) { D_8090CCFC--; if (D_8090CCFC == 0) { - func_801518B0(globalCtx, D_809171DA, NULL); + Message_StartTextbox(globalCtx, D_809171DA, NULL); } } @@ -5201,7 +5201,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { // fallthrough case 2: - ShrinkWindow_SetLetterboxTarget(0x1B); + ShrinkWindow_SetLetterboxTarget(27); spFC.x = sLurePos.x - player->actor.world.pos.x; spFC.z = sLurePos.z - player->actor.world.pos.z; @@ -5302,17 +5302,17 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { camera->at = sCameraAt; } func_80169AFC(globalCtx, sCameraId, 0); - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); D_8090CD4C = 0; sCameraId = CAM_ID_MAIN; func_800F6834(globalCtx, 0); - globalCtx->envCtx.unk_8C.fogNear = 0; + globalCtx->envCtx.lightSettings.fogNear = 0; player->unk_B28 = -5; D_80917200 = 5; break; case 10: - func_800EA0D4(globalCtx, &globalCtx->csCtx); + Cutscene_Start(globalCtx, &globalCtx->csCtx); sCameraId = Play_CreateSubCamera(globalCtx); Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); Play_CameraChangeStatus(globalCtx, sCameraId, 7); @@ -5324,7 +5324,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { sCameraAt.x = camera->at.x; sCameraAt.y = camera->at.y; sCameraAt.z = camera->at.z; - func_801518B0(globalCtx, 0x409E, NULL); + Message_StartTextbox(globalCtx, 0x409E, NULL); D_8090CD4C = 11; func_8013EC44(0.0f, 150, 10, 10); // fallthrough @@ -5333,25 +5333,25 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { player->actor.world.pos.z = 1360.0f; player->actor.speedXZ = 0.0f; - if (!Message_GetState(&globalCtx->msgCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 0) { camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); camera->eye = sCameraEye; camera->eyeNext = sCameraEye; camera->at = sCameraAt; func_80169AFC(globalCtx, sCameraId, 0); - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); D_8090CD4C = 0; sCameraId = CAM_ID_MAIN; D_8090CD50 = 30; func_800F6834(globalCtx, 0); - globalCtx->envCtx.unk_8C.fogNear = 0; + globalCtx->envCtx.lightSettings.fogNear = 0; } break; case 20: - func_800EA0D4(globalCtx, &globalCtx->csCtx); + Cutscene_Start(globalCtx, &globalCtx->csCtx); sCameraId = Play_CreateSubCamera(globalCtx); Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); Play_CameraChangeStatus(globalCtx, sCameraId, 7); @@ -5363,7 +5363,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { sCameraAt.x = camera->at.x; sCameraAt.y = camera->at.y; sCameraAt.z = camera->at.z; - func_801518B0(globalCtx, 0x409A, NULL); + Message_StartTextbox(globalCtx, 0x409A, NULL); D_8090CD4C = 21; D_80911F48 = 45.0f; D_8090CD50 = 10; @@ -5426,7 +5426,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { } if (D_8090CD50 == 0) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) || !Message_GetState(&globalCtx->msgCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) || Message_GetState(&globalCtx->msgCtx) == 0) { if (func_80147624(globalCtx)) { Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); @@ -5440,7 +5440,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { camera->eyeNext = sCameraEye; camera->at = sCameraAt; func_80169AFC(globalCtx, sCameraId, 0); - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); // arg2 changed from 7 to 6 in MM D_8090CD4C = 0; sCameraId = CAM_ID_MAIN; @@ -5449,7 +5449,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { D_8090CD54 = 0; D_809171F6 = 20; func_800F6834(globalCtx, 0); - globalCtx->envCtx.unk_8C.fogNear = 0; + globalCtx->envCtx.lightSettings.fogNear = 0; } } } @@ -5466,13 +5466,13 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { if (sCameraEye.y <= (WATER_SURFACE_Y(globalCtx) + 1.0f)) { func_800F6834(globalCtx, 1); if (D_809171CA != 0) { - globalCtx->envCtx.unk_8C.fogNear = -0xB2; + globalCtx->envCtx.lightSettings.fogNear = -0xB2; } else { - globalCtx->envCtx.unk_8C.fogNear = -0x2E; + globalCtx->envCtx.lightSettings.fogNear = -0x2E; } } else { func_800F6834(globalCtx, 0); - globalCtx->envCtx.unk_8C.fogNear = 0; + globalCtx->envCtx.lightSettings.fogNear = 0; } } @@ -5518,7 +5518,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { D_809171CB--; } - if ((D_809171CB == 1) && !Message_GetState(&globalCtx->msgCtx) && ((D_8090CD00 & 0xFFF) == 0xFFF)) { + if ((D_809171CB == 1) && Message_GetState(&globalCtx->msgCtx) == 0 && ((D_8090CD00 & 0xFFF) == 0xFFF)) { D_809171CB = 200; if (Rand_ZeroOne() < 0.5f) { @@ -5556,8 +5556,8 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { Math_ApproachZeroF(&D_8090CCD8, 1.0f, 2.0f); } - globalCtx->envCtx.unk_8C.diffuseColor1[0] = globalCtx->envCtx.unk_8C.diffuseColor1[1] = - globalCtx->envCtx.unk_8C.diffuseColor1[2] = D_8090CCD8; + globalCtx->envCtx.lightSettings.diffuseColor1[0] = globalCtx->envCtx.lightSettings.diffuseColor1[1] = + globalCtx->envCtx.lightSettings.diffuseColor1[2] = D_8090CCD8; if ((u8)D_8090CCD0 > 0) { s32 pad; diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index 8b77518d3..31a7046cb 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -172,7 +172,7 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { this->flags |= ENFSN_END_CONVERSATION; break; } - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); if (this->flags & ENFSN_END_CONVERSATION) { if (this->flags & ENFSN_GAVE_LETTER_TO_MAMA) { this->flags &= ~ENFSN_GAVE_LETTER_TO_MAMA; @@ -382,7 +382,7 @@ void EnFsn_EndInteraction(EnFsn* this, GlobalContext* globalCtx) { s32 EnFsn_TestEndInteraction(EnFsn* this, GlobalContext* globalCtx, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { this->actor.textId = (CURRENT_DAY == 3) ? 0x29DF : 0x29D1; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); func_80151BB4(globalCtx, 3); this->actionFunc = EnFsn_SetupEndInteraction; return true; @@ -424,12 +424,12 @@ s32 EnFsn_FacingShopkeeperDialogResult(EnFsn* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x29D8; } - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); return true; case 1: func_8019F230(); this->actor.textId = (CURRENT_DAY == 3) ? 0x29DF : 0x29D1; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); func_80151BB4(globalCtx, 3); this->actionFunc = EnFsn_SetupEndInteraction; return true; @@ -725,7 +725,7 @@ void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { this->cutsceneState = 1; } this->actor.textId = EnFsn_GetWelcome(globalCtx); - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); player->actor.world.pos.x = 1.0f; player->actor.world.pos.z = -34.0f; this->actionFunc = EnFsn_BeginInteraction; @@ -806,16 +806,16 @@ void EnFsn_StartBuying(EnFsn* this, GlobalContext* globalCtx) { switch (this->actor.textId) { case 0x29CC: this->actor.textId = 0x29CD; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); break; case 0x29CD: this->actor.textId = 0x29CE; EnFsn_HandleLookToShopkeeperBuyingCutscene(this); - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); break; case 0x29CE: this->actor.textId = 0xFF; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_DeterminePrice; break; case 0x29CF: @@ -838,7 +838,7 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x29D2; } - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); break; case 0x29D2: if (gSaveContext.weekEventReg[33] & 4) { @@ -848,14 +848,14 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x29D4; } - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); break; case 0x29D3: case 0x29D4: case 0x29FA: case 0x2A01: this->actor.textId = 0x29D5; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); break; } } @@ -870,7 +870,7 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = trueTmp; this->actor.textId = 0x29D6; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_FaceShopkeeperSelling; break; case 1: @@ -878,7 +878,7 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { this->isSelling = false; this->actor.textId = 0x29CE; EnFsn_HandleLookToShopkeeperBuyingCutscene(this); - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_StartBuying; break; } @@ -889,7 +889,7 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_SetupDeterminePrice(EnFsn* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.textId = 0xFF; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_DeterminePrice; } } @@ -924,7 +924,7 @@ void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x29D1; } - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); func_80151BB4(globalCtx, 3); this->actionFunc = EnFsn_SetupEndInteraction; } @@ -1011,7 +1011,7 @@ void EnFsn_ResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { this->cutscene = this->lookToShopkeeperCutscene; this->actor.textId = (this->numSellingItems <= 0) ? 0x29DE : 0x29D6; } - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } @@ -1232,13 +1232,13 @@ void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { case 0: func_8019F208(); this->actor.textId = 0xFF; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_DeterminePrice; break; case 1: func_8019F230(); this->actor.textId = (CURRENT_DAY == 3) ? 0x29DF : 0x29D1; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); func_80151BB4(globalCtx, 3); break; } @@ -1279,13 +1279,13 @@ void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx) func_8019F208(); this->isSelling = false; this->actor.textId = 0x29CE; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_StartBuying; break; case 1: func_8019F230(); this->actor.textId = (CURRENT_DAY == 3) ? 0x29DF : 0x29D1; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); func_80151BB4(globalCtx, 3); break; } @@ -1324,7 +1324,7 @@ void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx) { } } else if (talkState == 5 && func_80147624(globalCtx)) { this->actor.textId = 0x29D6; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); if (globalCtx) {} } } diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index 063d01608..e2519c7c5 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -387,33 +387,33 @@ void func_80962340(EnFu* this, GlobalContext* globalCtx) { if (this->unk_54A == 2) { if (this->unk_552 == 0x287D) { if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { - func_801518B0(globalCtx, 0x287E, &this->actor); + Message_StartTextbox(globalCtx, 0x287E, &this->actor); this->unk_552 = 0x287E; } else if ((CURRENT_DAY == 3) && (gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20)) { if ((gSaveContext.weekEventReg[22] & 0x40)) { - func_801518B0(globalCtx, 0x2883, &this->actor); + Message_StartTextbox(globalCtx, 0x2883, &this->actor); this->unk_552 = 0x2883; } else { - func_801518B0(globalCtx, 0x2880, &this->actor); + Message_StartTextbox(globalCtx, 0x2880, &this->actor); this->unk_552 = 0x2880; } } else { - func_801518B0(globalCtx, 0x287E, &this->actor); + Message_StartTextbox(globalCtx, 0x287E, &this->actor); this->unk_552 = 0x287E; } } else if ((gSaveContext.unk_3DE0[4] == 0) && (this->unk_552 != 0x2888)) { - func_801518B0(globalCtx, 0x2886, &this->actor); + Message_StartTextbox(globalCtx, 0x2886, &this->actor); this->unk_552 = 0x2886; } else { - func_801518B0(globalCtx, 0x2889, &this->actor); + Message_StartTextbox(globalCtx, 0x2889, &this->actor); this->unk_552 = 0x2889; } this->actor.flags &= ~ACTOR_FLAG_10000; player->stateFlags1 &= ~0x20; this->unk_54A = 1; } else { - func_801518B0(globalCtx, 0x283C, &this->actor); + Message_StartTextbox(globalCtx, 0x283C, &this->actor); this->unk_552 = 0x283C; } func_809628BC(this); @@ -435,12 +435,12 @@ void func_80962588(EnFu* this, GlobalContext* globalCtx) { func_80963DE4(this, globalCtx); } else { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0x2873, &this->actor); + Message_StartTextbox(globalCtx, 0x2873, &this->actor); this->unk_552 = 0x2873; } } else { func_8019F230(); - func_801518B0(globalCtx, 0x2872, &this->actor); + Message_StartTextbox(globalCtx, 0x2872, &this->actor); this->unk_552 = 0x2872; } } @@ -468,7 +468,7 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { break; case 0x2846: - func_801518B0(globalCtx, 0x2849, &this->actor); + Message_StartTextbox(globalCtx, 0x2849, &this->actor); this->unk_552 = 0x2849; break; @@ -519,7 +519,7 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { case 0x286A: case 0x286C: case 0x286E: - func_801518B0(globalCtx, 0x2871, &this->actor); + Message_StartTextbox(globalCtx, 0x2871, &this->actor); this->unk_552 = 0x2871; break; @@ -527,7 +527,7 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { case 0x2878: case 0x287A: case 0x287C: - func_801518B0(globalCtx, 0x287D, &this->actor); + Message_StartTextbox(globalCtx, 0x287D, &this->actor); this->unk_552 = 0x287D; break; @@ -774,7 +774,7 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { } if (func_80961D10(this)) { - func_801518B0(globalCtx, 0x288B, &this->actor); + Message_StartTextbox(globalCtx, 0x288B, &this->actor); } if ((!DynaPolyActor_IsInRidingRotatingState((DynaPolyActor*)this->actor.child) && @@ -785,10 +785,10 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x20; if (this->unk_548 < this->unk_54C) { if (gSaveContext.unk_3DE0[4] == 0) { - func_801518B0(globalCtx, 0x2885, &this->actor); + Message_StartTextbox(globalCtx, 0x2885, &this->actor); this->unk_552 = 0x2885; } else { - func_801518B0(globalCtx, 0x2888, &this->actor); + Message_StartTextbox(globalCtx, 0x2888, &this->actor); this->unk_552 = 0x2888; } func_801A2C20(); @@ -899,18 +899,18 @@ void func_80963630(EnFu* this, GlobalContext* globalCtx) { if ((gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20) && (CURRENT_DAY == 3) && (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { if (gSaveContext.weekEventReg[22] & 0x40) { - func_801518B0(globalCtx, 0x2884, &this->actor); + Message_StartTextbox(globalCtx, 0x2884, &this->actor); this->unk_552 = 0x2884; } else if (!(gSaveContext.weekEventReg[22] & 0x80)) { gSaveContext.weekEventReg[22] |= 0x80; - func_801518B0(globalCtx, 0x2882, &this->actor); + Message_StartTextbox(globalCtx, 0x2882, &this->actor); this->unk_552 = 0x2882; } else { - func_801518B0(globalCtx, 0x2881, &this->actor); + Message_StartTextbox(globalCtx, 0x2881, &this->actor); this->unk_552 = 0x2881; } } else { - func_801518B0(globalCtx, 0x287F, &this->actor); + Message_StartTextbox(globalCtx, 0x287F, &this->actor); this->unk_552 = 0x287F; } @@ -969,46 +969,46 @@ s32 func_80963810(GlobalContext* globalCtx, Vec3f pos) { s32 func_809638F8(GlobalContext* globalCtx) { s32 ret = true; - if (globalCtx->envCtx.unk_8C.diffuseColor1[0] > 25) { - globalCtx->envCtx.unk_8C.diffuseColor1[0] -= 25; + if (globalCtx->envCtx.lightSettings.diffuseColor1[0] > 25) { + globalCtx->envCtx.lightSettings.diffuseColor1[0] -= 25; ret = false; } else { - globalCtx->envCtx.unk_8C.diffuseColor1[0] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[0] = 0; } - if (globalCtx->envCtx.unk_8C.diffuseColor1[1] > 25) { - globalCtx->envCtx.unk_8C.diffuseColor1[1] -= 25; + if (globalCtx->envCtx.lightSettings.diffuseColor1[1] > 25) { + globalCtx->envCtx.lightSettings.diffuseColor1[1] -= 25; ret = false; } else { - globalCtx->envCtx.unk_8C.diffuseColor1[1] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[1] = 0; } - if (globalCtx->envCtx.unk_8C.diffuseColor1[2] > 25) { - globalCtx->envCtx.unk_8C.diffuseColor1[2] -= 25; + if (globalCtx->envCtx.lightSettings.diffuseColor1[2] > 25) { + globalCtx->envCtx.lightSettings.diffuseColor1[2] -= 25; ret = false; } else { - globalCtx->envCtx.unk_8C.diffuseColor1[2] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[2] = 0; } - if (globalCtx->envCtx.unk_8C.ambientColor[0] > 25) { - globalCtx->envCtx.unk_8C.ambientColor[0] -= 25; + if (globalCtx->envCtx.lightSettings.ambientColor[0] > 25) { + globalCtx->envCtx.lightSettings.ambientColor[0] -= 25; ret = false; } else { - globalCtx->envCtx.unk_8C.ambientColor[0] = 0; + globalCtx->envCtx.lightSettings.ambientColor[0] = 0; } - if (globalCtx->envCtx.unk_8C.ambientColor[1] > 25) { - globalCtx->envCtx.unk_8C.ambientColor[1] -= 25; + if (globalCtx->envCtx.lightSettings.ambientColor[1] > 25) { + globalCtx->envCtx.lightSettings.ambientColor[1] -= 25; ret = false; } else { - globalCtx->envCtx.unk_8C.ambientColor[1] = 0; + globalCtx->envCtx.lightSettings.ambientColor[1] = 0; } - if (globalCtx->envCtx.unk_8C.ambientColor[2] > 25) { - globalCtx->envCtx.unk_8C.ambientColor[2] -= 25; + if (globalCtx->envCtx.lightSettings.ambientColor[2] > 25) { + globalCtx->envCtx.lightSettings.ambientColor[2] -= 25; ret = false; } else { - globalCtx->envCtx.unk_8C.ambientColor[2] = 0; + globalCtx->envCtx.lightSettings.ambientColor[2] = 0; } return ret; } @@ -1018,50 +1018,50 @@ void func_809639D0(EnFu* this, GlobalContext* globalCtx) { case 1: if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { - func_801518B0(globalCtx, 0x2853, &this->actor); + Message_StartTextbox(globalCtx, 0x2853, &this->actor); this->unk_552 = 0x2853; } else if (gSaveContext.weekEventReg[22] & 0x10) { - func_801518B0(globalCtx, 0x284D, &this->actor); + Message_StartTextbox(globalCtx, 0x284D, &this->actor); this->unk_552 = 0x284D; } else if (this->unk_53E == 1) { - func_801518B0(globalCtx, 0x284F, &this->actor); + Message_StartTextbox(globalCtx, 0x284F, &this->actor); this->unk_552 = 0x284F; } else { this->unk_53E = 1; - func_801518B0(globalCtx, 0x2851, &this->actor); + Message_StartTextbox(globalCtx, 0x2851, &this->actor); this->unk_552 = 0x2851; } } else { - func_801518B0(globalCtx, 0x286F, &this->actor); + Message_StartTextbox(globalCtx, 0x286F, &this->actor); this->unk_552 = 0x286F; } break; case 2: if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - func_801518B0(globalCtx, 0x286F, &this->actor); + Message_StartTextbox(globalCtx, 0x286F, &this->actor); this->unk_552 = 0x286F; } else if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { - func_801518B0(globalCtx, 0x2853, &this->actor); + Message_StartTextbox(globalCtx, 0x2853, &this->actor); this->unk_552 = 0x2853; } else if (!(gSaveContext.weekEventReg[22] & 0x10)) { if (this->unk_53E == 1) { - func_801518B0(globalCtx, 0x285B, &this->actor); + Message_StartTextbox(globalCtx, 0x285B, &this->actor); this->unk_552 = 0x285B; } else { this->unk_53E = 1; - func_801518B0(globalCtx, 0x285D, &this->actor); + Message_StartTextbox(globalCtx, 0x285D, &this->actor); this->unk_552 = 0x285D; } } else if (gSaveContext.weekEventReg[22] & 0x20) { - func_801518B0(globalCtx, 0x2855, &this->actor); + Message_StartTextbox(globalCtx, 0x2855, &this->actor); this->unk_552 = 0x2855; } else if (this->unk_53E == 1) { - func_801518B0(globalCtx, 0x2857, &this->actor); + Message_StartTextbox(globalCtx, 0x2857, &this->actor); this->unk_552 = 0x2857; } else { this->unk_53E = 1; - func_801518B0(globalCtx, 0x2859, &this->actor); + Message_StartTextbox(globalCtx, 0x2859, &this->actor); this->unk_552 = 0x2859; } break; @@ -1071,44 +1071,44 @@ void func_809639D0(EnFu* this, GlobalContext* globalCtx) { if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { func_80963EAC(this, globalCtx); } else { - func_801518B0(globalCtx, 0x2841, &this->actor); + Message_StartTextbox(globalCtx, 0x2841, &this->actor); this->unk_552 = 0x2841; } } else if (CUR_UPG_VALUE(UPG_QUIVER) == 0) { - func_801518B0(globalCtx, 0x284B, &this->actor); + Message_StartTextbox(globalCtx, 0x284B, &this->actor); this->unk_552 = 0x284B; } else if (gSaveContext.weekEventReg[22] & 0x40) { if ((gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20)) { - func_801518B0(globalCtx, 0x285F, &this->actor); + Message_StartTextbox(globalCtx, 0x285F, &this->actor); this->unk_552 = 0x285F; } else { - func_801518B0(globalCtx, 0x2861, &this->actor); + Message_StartTextbox(globalCtx, 0x2861, &this->actor); this->unk_552 = 0x2861; } } else if ((gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20)) { if (this->unk_53E == 1) { - func_801518B0(globalCtx, 0x2863, &this->actor); + Message_StartTextbox(globalCtx, 0x2863, &this->actor); this->unk_552 = 0x2863; } else { this->unk_53E = 1; - func_801518B0(globalCtx, 0x2865, &this->actor); + Message_StartTextbox(globalCtx, 0x2865, &this->actor); this->unk_552 = 0x2865; } } else if ((gSaveContext.weekEventReg[22] & 0x10) || (gSaveContext.weekEventReg[22] & 0x20)) { if (this->unk_53E == 1) { - func_801518B0(globalCtx, 0x2867, &this->actor); + Message_StartTextbox(globalCtx, 0x2867, &this->actor); this->unk_552 = 0x2867; } else { this->unk_53E = 1; - func_801518B0(globalCtx, 0x2869, &this->actor); + Message_StartTextbox(globalCtx, 0x2869, &this->actor); this->unk_552 = 0x2869; } } else if (this->unk_53E == 1) { - func_801518B0(globalCtx, 0x286B, &this->actor); + Message_StartTextbox(globalCtx, 0x286B, &this->actor); this->unk_552 = 0x286B; } else { this->unk_53E = 1; - func_801518B0(globalCtx, 0x286D, &this->actor); + Message_StartTextbox(globalCtx, 0x286D, &this->actor); this->unk_552 = 0x286D; } break; @@ -1119,21 +1119,21 @@ void func_80963DE4(EnFu* this, GlobalContext* globalCtx) { switch (this->unk_542) { case 0: if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - func_801518B0(globalCtx, 0x2875, &this->actor); + Message_StartTextbox(globalCtx, 0x2875, &this->actor); this->unk_552 = 0x2875; } else { - func_801518B0(globalCtx, 0x2877, &this->actor); + Message_StartTextbox(globalCtx, 0x2877, &this->actor); this->unk_552 = 0x2877; } break; case 1: - func_801518B0(globalCtx, 0x2879, &this->actor); + Message_StartTextbox(globalCtx, 0x2879, &this->actor); this->unk_552 = 0x2879; break; case 2: - func_801518B0(globalCtx, 0x287B, &this->actor); + Message_StartTextbox(globalCtx, 0x287B, &this->actor); this->unk_552 = 0x287B; break; } @@ -1142,15 +1142,15 @@ void func_80963DE4(EnFu* this, GlobalContext* globalCtx) { void func_80963EAC(EnFu* this, GlobalContext* globalCtx) { if (gSaveContext.magicAcquired) { if (this->unk_540 == 1) { - func_801518B0(globalCtx, 0x2847, &this->actor); + Message_StartTextbox(globalCtx, 0x2847, &this->actor); this->unk_552 = 0x2847; } else { this->unk_540 = 1; - func_801518B0(globalCtx, 0x2845, &this->actor); + Message_StartTextbox(globalCtx, 0x2845, &this->actor); this->unk_552 = 0x2845; } } else { - func_801518B0(globalCtx, 0x2843, &this->actor); + Message_StartTextbox(globalCtx, 0x2843, &this->actor); this->unk_552 = 0x2843; } } @@ -1158,7 +1158,7 @@ void func_80963EAC(EnFu* this, GlobalContext* globalCtx) { void func_80963F44(EnFu* this, GlobalContext* globalCtx) { u16 sp1E = this->unk_552 + 1; - func_801518B0(globalCtx, sp1E, &this->actor); + Message_StartTextbox(globalCtx, sp1E, &this->actor); this->unk_552 = sp1E; } 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 714432f27..4427bd3b1 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -378,7 +378,7 @@ void func_80B0FEBC(EnGb2* this, GlobalContext* globalCtx) { } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); this->actionFunc = func_80B0FFA8; } else if ((this->actor.xzDistToPlayer < 300.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); @@ -400,7 +400,7 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { this->actionFunc = func_80B0FEBC; } else { this->unk_26E = func_80B0F7FC(this); - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } } } else if ((temp_v0 == 4) && func_80147624(globalCtx)) { @@ -411,11 +411,11 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_ERROR); this->unk_26E = 0x14D7; this->unk_26C |= 2; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } else { func_8019F208(); this->unk_26E = 0x14D8; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } break; @@ -423,7 +423,7 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { func_8019F230(); this->unk_26E = 0x14D6; this->unk_26C |= 2; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); break; } } else if (this->unk_26E == 0x14DA) { @@ -441,7 +441,7 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { func_8019F230(); this->unk_26E = 0x14DB; this->unk_26C |= 2; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); break; } } @@ -538,7 +538,7 @@ void func_80B10344(EnGb2* this, GlobalContext* globalCtx) { void func_80B10584(EnGb2* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = func_80B10634; } else if (this->actor.xzDistToPlayer < 300.0f) { @@ -569,7 +569,7 @@ void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { } } else { this->unk_26E = func_80B0F8F8(this); - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } } } else if ((temp_v0 == 4) && func_80147624(globalCtx)) { @@ -579,7 +579,7 @@ void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_ERROR); this->unk_26E = 0x14D7; this->unk_26C |= 2; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } else { func_8019F208(); func_801159EC(-this->unk_288); @@ -594,7 +594,7 @@ void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { func_8019F230(); this->unk_26E = 0x14E3; this->unk_26C |= 2; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); break; } } @@ -638,7 +638,7 @@ void func_80B10924(EnGb2* this, GlobalContext* globalCtx) { void func_80B109DC(EnGb2* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); this->actionFunc = func_80B10634; } else { func_800B85E0(&this->actor, globalCtx, 300.0f, -1); @@ -692,7 +692,7 @@ void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx) { if ((this->unk_26E == 0x14EE) || (this->unk_26E == 0x14F4)) { this->unk_26C |= 2; } - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); this->unk_290 = 1; this->unk_26C &= ~0x40; this->actionFunc = func_80B10DAC; @@ -704,7 +704,7 @@ void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx) { this->unk_26C &= ~0x40; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_26C & 0x20)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); if (this->unk_26E == 0x14EB) { gSaveContext.weekEventReg[80] |= 0x40; } else if (this->unk_26E == 0x14EF) { @@ -766,7 +766,7 @@ void func_80B10E98(EnGb2* this, GlobalContext* globalCtx) { s32 temp; this->unk_26E = func_80B0FB24(this); - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); temp = this->unk_26E; if ((temp == 0x14E7) || (temp == 0x14E9) || (temp == 0x14EC) || (temp == 0x14F0)) { ActorCutscene_Stop(this->unk_282[this->unk_290]); @@ -781,7 +781,7 @@ void func_80B10E98(EnGb2* this, GlobalContext* globalCtx) { void func_80B11048(EnGb2* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); this->actionFunc = func_80B10DAC; } else if (this->actor.xzDistToPlayer < 300.0f) { this->actor.flags |= ACTOR_FLAG_10000; @@ -798,7 +798,7 @@ void func_80B110F8(EnGb2* this, GlobalContext* globalCtx) { this->actionFunc = func_80B10A48; } else { this->unk_26E = func_80B0F97C(this); - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } } } 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 e9a83fa06..60c5ebdb6 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -442,7 +442,7 @@ void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { this->unk_49A = this->unk_49C[2]; this->unk_230 &= ~4; } - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); this->actionFunc = func_80BB2520; this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->actor.xzDistToPlayer < 300.0f) { @@ -455,7 +455,7 @@ void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { if (gSaveContext.weekEventReg[35] & 0x40) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_230 & 8)) { this->unk_496 = 0xD62; - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); this->unk_230 &= ~8; this->actionFunc = func_80BB27D4; } else if ((this->actor.xzDistToPlayer < 300.0f) && this->actor.isTargeted) { @@ -466,7 +466,7 @@ void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { gSaveContext.weekEventReg[35] |= 0x40; this->unk_496 = 0xD5E; this->unk_49A = this->unk_49C[0]; - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); this->actionFunc = func_80BB2520; this->unk_230 &= ~8; this->actor.flags &= ~ACTOR_FLAG_10000; @@ -559,7 +559,7 @@ void func_80BB26EC(EnGeg* this, GlobalContext* globalCtx) { } this->unk_496 = func_80BB16D0(this); - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); } } @@ -599,7 +599,7 @@ void func_80BB27D4(EnGeg* this, GlobalContext* globalCtx) { default: this->unk_496 = func_80BB16D0(this); - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); break; } } @@ -639,7 +639,7 @@ void func_80BB2A54(EnGeg* this, GlobalContext* globalCtx) { this->actionFunc = func_80BB347C; } else { this->unk_496 = func_80BB16D0(this); - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); } } } @@ -771,7 +771,7 @@ void func_80BB30B4(EnGeg* this, GlobalContext* globalCtx) { } else { this->unk_496 = 0xD6E; } - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); this->actionFunc = func_80BB27D4; this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->actor.xzDistToPlayer < 150.0f) { @@ -809,7 +809,7 @@ void func_80BB31B8(EnGeg* this, GlobalContext* globalCtx) { void func_80BB32AC(EnGeg* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); this->actionFunc = func_80BB27D4; } else { func_800B85E0(&this->actor, globalCtx, 400.0f, -1); 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 fbce4e2e7..c9b6435f5 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -256,7 +256,7 @@ void func_80B3556C(EnGg* this, GlobalContext* globalCtx) { func_80B35250(this); } else { this->actor.textId = func_80B357F0(this); - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = func_80B352A4; } } @@ -264,15 +264,15 @@ void func_80B3556C(EnGg* this, GlobalContext* globalCtx) { void func_80B35634(EnGg* this, GlobalContext* globalCtx) { s32 pad; - u32 temp_v0; + s32 actionIndex; - if (func_800EE29C(globalCtx, 0x77)) { - temp_v0 = func_800EE200(globalCtx, 0x77); + if (Cutscene_CheckActorAction(globalCtx, 119)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 119); - if (this->unk_2DB != globalCtx->csCtx.npcActions[temp_v0]->unk0) { - this->unk_2DB = globalCtx->csCtx.npcActions[temp_v0]->unk0; + if (this->unk_2DB != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->unk_2DB = globalCtx->csCtx.actorActions[actionIndex]->action; - switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: this->unk_2DA = 0; this->unk_2E6 = 0; @@ -333,7 +333,7 @@ void func_80B35634(EnGg* this, GlobalContext* globalCtx) { func_80B358D8(this, globalCtx); } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); this->actor.shape.yOffset = 0.0f; } else { this->unk_2DB = 99; 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 937f46460..c509db2b8 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -165,20 +165,20 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { case GIANT_TYPE_CANYON_TERMINA_FIELD: case GIANT_TYPE_CANYON_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_CANYON_GIANTS_CHAMBER_AND_ENDING: - this->actorActionCommand = 0x1C6; + this->actorActionCommand = 454; break; case GIANT_TYPE_SWAMP_TERMINA_FIELD: case GIANT_TYPE_SWAMP_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_SWAMP_GIANTS_CHAMBER_AND_ENDING: - this->actorActionCommand = 0x1C7; + this->actorActionCommand = 455; break; case GIANT_TYPE_OCEAN_TERMINA_FIELD: case GIANT_TYPE_OCEAN_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_OCEAN_GIANTS_CHAMBER_AND_ENDING: - this->actorActionCommand = 0x1C8; + this->actorActionCommand = 456; break; default: - this->actorActionCommand = 0x1C5; + this->actorActionCommand = 453; break; } @@ -388,20 +388,23 @@ void EnGiant_PlaySound(EnGiant* this) { } void EnGiant_UpdatePosition(EnGiant* this, GlobalContext* globalCtx, u32 actionIndex) { - CsCmdActorAction* actorAction = globalCtx->csCtx.npcActions[actionIndex]; - f32 startPosY = actorAction->unk0C.y; + CsCmdActorAction* actorAction = globalCtx->csCtx.actorActions[actionIndex]; + f32 startPosY = actorAction->startPos.y; s32 pad[2]; - f32 endPosY = actorAction->unk18.y; - f32 scale = func_800F5A8C(actorAction->endFrame, actorAction->startFrame, globalCtx->csCtx.frames, globalCtx); + f32 endPosY = actorAction->endPos.y; + f32 scale = Environment_LerpWeight(actorAction->endFrame, actorAction->startFrame, globalCtx->csCtx.frames); this->actor.world.pos.y = ((endPosY - startPosY) * scale) + startPosY; } void EnGiant_PerformClockTowerSuccessActions(EnGiant* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, this->actorActionCommand)) { - EnGiant_UpdatePosition(this, globalCtx, func_800EE200(globalCtx, this->actorActionCommand)); - if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0) { - this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0; + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCommand)) { + EnGiant_UpdatePosition(this, globalCtx, Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)); + if (this->csAction != + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)]->action) { + this->csAction = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)] + ->action; EnGiant_ChangeAnimationBasedOnCsAction(this); } EnGiant_UpdateAlpha(this); @@ -421,10 +424,14 @@ void EnGiant_PlayClockTowerFailureAnimation(EnGiant* this, GlobalContext* global void EnGiant_PerformCutsceneActions(EnGiant* this, GlobalContext* globalCtx) { this->actor.draw = EnGiant_Draw; - if (func_800EE29C(globalCtx, this->actorActionCommand)) { - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->actorActionCommand)); - if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0) { - this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0; + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCommand)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)); + if (this->csAction != + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)]->action) { + this->csAction = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)] + ->action; EnGiant_ChangeAnimationBasedOnCsAction(this); } EnGiant_UpdateAlpha(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 eb21f3586..fe480fb14 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 @@ -83,15 +83,15 @@ void EnGinkoMan_Idle(EnGinkoMan* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if ((gSaveContext.bankRupees & 0xFFFF) == 0) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); - func_801518B0(globalCtx, 0x44C, &this->actor); + Message_StartTextbox(globalCtx, 0x44C, &this->actor); this->curTextId = 0x44C; // would you like to make an account } else { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); if ((CURRENT_DAY == 3) && (gSaveContext.isNight == 1)) { - func_801518B0(globalCtx, 0x467, &this->actor); + Message_StartTextbox(globalCtx, 0x467, &this->actor); this->curTextId = 0x467; // "What's this? You need somethin' on a day like this? } else { - func_801518B0(globalCtx, 0x466, &this->actor); + Message_StartTextbox(globalCtx, 0x466, &this->actor); this->curTextId = 0x466; // What's this? You need somethin'? } } @@ -111,21 +111,21 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { case 0x44C: // "Hey there, little guy! Won't you deposit some Rupees? (first dialogue) Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); if (gSaveContext.weekEventReg[10] & 8) { - func_801518B0(globalCtx, 0x44E, &this->actor); + Message_StartTextbox(globalCtx, 0x44E, &this->actor); this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" } else { - func_801518B0(globalCtx, 0x44D, &this->actor); + Message_StartTextbox(globalCtx, 0x44D, &this->actor); this->curTextId = 0x44D; // "For example, if you deposit 200 Rupees, you'll get an item that holds a lot of Rupees." } break; case 0x44D: // "For example, if you deposit 200 Rupees, you'll get an item that holds a lot of Rupees." - func_801518B0(globalCtx, 0x44E, &this->actor); + Message_StartTextbox(globalCtx, 0x44E, &this->actor); this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" break; case 0x44F: // "...So, what'll it be? Deposit Rupees Don't deposit Rupees" Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); - func_801518B0(globalCtx, 0x450, &this->actor); + Message_StartTextbox(globalCtx, 0x450, &this->actor); this->curTextId = 0x450; // "How much? How much? [rupee prompt] break; @@ -138,7 +138,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); } - func_801518B0(globalCtx, 0x461, &this->actor); + Message_StartTextbox(globalCtx, 0x461, &this->actor); this->curTextId = 0x461; // So, little guy, what's your name? } else { if (this->curTextId == 0x453) { // "That's it? That ain't nothing at all, big spender! @@ -146,44 +146,44 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { } globalCtx->msgCtx.bankRupees = gSaveContext.bankRupees & 0xFFFF; - func_801518B0(globalCtx, 0x45A, &this->actor); + Message_StartTextbox(globalCtx, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" } break; case 0x456: // "Is that so? Think about it, little guy!" case 0x459: // "Heyyy! You don't have that much! - func_801518B0(globalCtx, 0x44E, &this->actor); + Message_StartTextbox(globalCtx, 0x44E, &this->actor); this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" break; case 0x45A: // "All right, little guy, now I've got a total of [rupees] from you!" if (((gSaveContext.bankRupees & 0xFFFF) >= 200) && (this->previousBankValue < 200) && !(gSaveContext.weekEventReg[59] & 0x40)) { gSaveContext.weekEventReg[59] |= 0x40; - func_801518B0(globalCtx, 0x45B, &this->actor); + Message_StartTextbox(globalCtx, 0x45B, &this->actor); this->curTextId = 0x45B; // "What's this? You've already saved up 200 Rupees!?! } else if (((gSaveContext.bankRupees & 0xFFFF) >= 1000) && ((this->previousBankValue) < 1000) && !(gSaveContext.weekEventReg[59] & 0x80)) { gSaveContext.weekEventReg[59] |= 0x80; - func_801518B0(globalCtx, 0x45C, &this->actor); + Message_StartTextbox(globalCtx, 0x45C, &this->actor); this->curTextId = 0x45C; // "What's this? You've already saved up 1000 Rupees!?! } else if ((gSaveContext.bankRupees & 0xFFFF) >= 5000) { if ((this->previousBankValue < 5000) && !(gSaveContext.weekEventReg[60] & 1)) { gSaveContext.weekEventReg[60] |= 1; - func_801518B0(globalCtx, 0x45D, &this->actor); + Message_StartTextbox(globalCtx, 0x45D, &this->actor); this->curTextId = 0x45D; // "What's this? You've already saved up 5000 Rupees?! } else if (this->previousBankValue < (s16)(gSaveContext.bankRupees & 0xFFFF)) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - func_801518B0(globalCtx, 0x45E, &this->actor); + Message_StartTextbox(globalCtx, 0x45E, &this->actor); this->curTextId = 0x45E; // "...Hang on there, little guy. I can't take any more deposits. Sorry..." } else { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); - func_801518B0(globalCtx, 0x460, &this->actor); + Message_StartTextbox(globalCtx, 0x460, &this->actor); this->curTextId = 0x460; // "Come back and deposit some after you save up a bunch!" } } else { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); - func_801518B0(globalCtx, 0x460, &this->actor); + Message_StartTextbox(globalCtx, 0x460, &this->actor); this->curTextId = 0x460; // "Come back and deposit some after you save up a bunch!" } break; @@ -196,15 +196,15 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_BankAward(this, globalCtx); break; case 0x461: // So, little guy, what's your name? - func_801518B0(globalCtx, 0x462, &this->actor); + Message_StartTextbox(globalCtx, 0x462, &this->actor); this->curTextId = 0x462; // Hmm... Link is it? break; case 0x462: // Hmm.. Link is it? - func_801518B0(globalCtx, 0x463, &this->actor); + Message_StartTextbox(globalCtx, 0x463, &this->actor); this->curTextId = 0x463; // Got it... I won't forget your deposits. Let me stamp you break; case 0x463: // Got it... I won't forget your deposits. Let me stamp you - func_801518B0(globalCtx, 0x464, &this->actor); + Message_StartTextbox(globalCtx, 0x464, &this->actor); this->curTextId = 0x464; // Hey, relax! It doesn't leave any marks break; case 0x464: // Hey, relax! It doesn't leave any marks @@ -214,12 +214,12 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { case 0x465: // "There! Now I'll know you when I see you!" Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); globalCtx->msgCtx.bankRupees = gSaveContext.bankRupees & 0xFFFF; - func_801518B0(globalCtx, 0x45A, &this->actor); + Message_StartTextbox(globalCtx, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" break; case 0x466: // What's this? You need somethin'? case 0x467: // "What's this? You need somethin' on a day like this? You haven't evacuated yet? - func_801518B0(globalCtx, 0x468, &this->actor); + Message_StartTextbox(globalCtx, 0x468, &this->actor); this->curTextId = 0x468; // " Deposit Rupees Withdraw Rupees Nothing really" break; case 0x469: // "Excuse me, but let me take a look at you..." @@ -230,34 +230,34 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { case 0x47E: // "Your deposits total [rupees]." if (this->choiceDepositWithdrawl == GINKOMAN_CHOICE_DEPOSIT) { if ((u32)(gSaveContext.bankRupees & 0xFFFF) >= 5000) { - func_801518B0(globalCtx, 0x45F, &this->actor); + Message_StartTextbox(globalCtx, 0x45F, &this->actor); this->curTextId = 0x45F; // "Excuuuse me! But I can't take anymore deposits! } else if (gSaveContext.rupees == 0) { - func_801518B0(globalCtx, 0x458, &this->actor); + Message_StartTextbox(globalCtx, 0x458, &this->actor); this->curTextId = 0x458; // "Hmm...You play mean jokes, little guy! You haven't even got a single Rupee! } else { - func_801518B0(globalCtx, 0x479, &this->actor); + Message_StartTextbox(globalCtx, 0x479, &this->actor); this->curTextId = 0x479; // "Well, are you gonna make a deposit?" } } else if ((CURRENT_DAY == 3) && (gSaveContext.isNight == 1)) { - func_801518B0(globalCtx, 0x46D, &this->actor); + Message_StartTextbox(globalCtx, 0x46D, &this->actor); // "Look, little guy, if it's 'cause of the bad rumors going around, forget it! They're just rumors!" this->curTextId = 0x46D; } else { // GINKOMAN_CHOICE_WITHDRAWL - func_801518B0(globalCtx, 0x46B, &this->actor); + Message_StartTextbox(globalCtx, 0x46B, &this->actor); this->curTextId = 0x46B; // "So..." } this->choiceDepositWithdrawl = GINKOMAN_CHOICE_RESET; break; case 0x46B: // So... - func_801518B0(globalCtx, 0x46E, &this->actor); + Message_StartTextbox(globalCtx, 0x46E, &this->actor); this->curTextId = 0x46E; // "How much do you want? [rupee prompt] break; case 0x46D: // "Look, little guy, if it's 'cause of the bad rumors going around, forget it! They're just // rumors!" - func_801518B0(globalCtx, 0x46B, &this->actor); + Message_StartTextbox(globalCtx, 0x46B, &this->actor); this->curTextId = 0x46B; // So... break; case 0x470: // "Is that so? Come back and deposit some after saving up a bunch!" @@ -273,7 +273,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { case 0x475: // "What's this? Look, little guy, you can't hold this many rupees! You got that?" case 0x47C: // "Is that so? Think it over, little guy! So what are you gonna do?" case 0x47D: // duplicate of 48 - func_801518B0(globalCtx, 0x468, &this->actor); + Message_StartTextbox(globalCtx, 0x468, &this->actor); this->curTextId = 0x468; // " Deposit Rupees Withdraw Rupees Nothing really" break; case 0x472: // "What's this? It's a waste to take out such a tiny bit! ...But if you say so!" @@ -281,22 +281,22 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { case 0x474: // "Aw, you're taking out all that? If you spend it like that, it'll all be gone before you know // it!" if ((gSaveContext.bankRupees & 0xFFFF) == 0) { - func_801518B0(globalCtx, 0x478, &this->actor); + Message_StartTextbox(globalCtx, 0x478, &this->actor); // "Look, little guy, all the Rupees you deposited are gone, so you can't use that stamp anymore." this->curTextId = 0x478; } else { globalCtx->msgCtx.bankRupees = gSaveContext.bankRupees & 0xFFFF; - func_801518B0(globalCtx, 0x45A, &this->actor); + Message_StartTextbox(globalCtx, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" } break; case 0x477: // "...You know, at this time of day there's a 4 Rupee service charge on withdrawals!" - func_801518B0(globalCtx, 0x471, &this->actor); + Message_StartTextbox(globalCtx, 0x471, &this->actor); this->curTextId = 0x471; // "Are you really withdrawing [rupees selected]? Y/n" this->serviceFee = globalCtx->msgCtx.unk1206C; break; case 0x479: // Well, are you gonna make a deposit? - func_801518B0(globalCtx, 0x44F, &this->actor); + Message_StartTextbox(globalCtx, 0x44F, &this->actor); this->curTextId = 0x44F; // "All right! So..." break; } @@ -313,22 +313,22 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { if ((gSaveContext.bankRupees & 0xFFFF) >= 5000) { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0x45F, &this->actor); + Message_StartTextbox(globalCtx, 0x45F, &this->actor); this->curTextId = 0x45F; // bank full, cannot accept more } else { if (gSaveContext.rupees > 0) { func_8019F208(); - func_801518B0(globalCtx, 0x44F, &this->actor); + Message_StartTextbox(globalCtx, 0x44F, &this->actor); this->curTextId = 0x44F; // "All right! so..." } else { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0x458, &this->actor); + Message_StartTextbox(globalCtx, 0x458, &this->actor); this->curTextId = 0x458; // you haven't even gotten a single rup } } } else { // GINKOMAN_CHOICE_NO func_8019F230(); - func_801518B0(globalCtx, 0x451, &this->actor); + Message_StartTextbox(globalCtx, 0x451, &this->actor); this->curTextId = 0x451; // dont say that, come on, trust me! } break; @@ -337,19 +337,19 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) if (gSaveContext.rupees < globalCtx->msgCtx.bankRupeesSelected) { play_sound(NA_SE_SY_ERROR); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - func_801518B0(globalCtx, 0x459, &this->actor); + Message_StartTextbox(globalCtx, 0x459, &this->actor); this->curTextId = 0x459; // HEY you dont have that much } else { func_8019F208(); if (globalCtx->msgCtx.bankRupeesSelected >= 100) { - func_801518B0(globalCtx, 0x455, &this->actor); + Message_StartTextbox(globalCtx, 0x455, &this->actor); this->curTextId = 0x455; // You're really going to be give me that much? Rich little guy! } else if (globalCtx->msgCtx.bankRupeesSelected >= 10) { - func_801518B0(globalCtx, 0x454, &this->actor); + Message_StartTextbox(globalCtx, 0x454, &this->actor); this->curTextId = 0x454; // Seriously? that's a lot. A lot! } else { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - func_801518B0(globalCtx, 0x453, &this->actor); + Message_StartTextbox(globalCtx, 0x453, &this->actor); this->curTextId = 0x453; // That's it? That aint nothing at all } @@ -367,10 +367,10 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) func_8019F230(); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); if ((gSaveContext.bankRupees & 0xFFFF) == 0) { - func_801518B0(globalCtx, 0x456, &this->actor); + Message_StartTextbox(globalCtx, 0x456, &this->actor); this->curTextId = 0x456; // Is that so? think about it } else { - func_801518B0(globalCtx, 0x47D, &this->actor); + Message_StartTextbox(globalCtx, 0x47D, &this->actor); this->curTextId = 0x47D; // is that so? think it over } } @@ -378,17 +378,17 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) case 0x468: // Deposit OR withdrawl OR cancel screen if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_CANCEL) { func_8019F230(); - func_801518B0(globalCtx, 0x470, &this->actor); + Message_StartTextbox(globalCtx, 0x470, &this->actor); this->curTextId = 0x470; // "Is that so? Come back and deposit some after saving up a bunch!" } else { func_8019F208(); this->choiceDepositWithdrawl = globalCtx->msgCtx.choiceIndex; if (!this->isStampChecked) { this->isStampChecked = true; - func_801518B0(globalCtx, 0x469, &this->actor); + Message_StartTextbox(globalCtx, 0x469, &this->actor); this->curTextId = 0x469; // "Excuse me, but let me take a look at you..." } else { - func_801518B0(globalCtx, 0x47E, &this->actor); + Message_StartTextbox(globalCtx, 0x47E, &this->actor); this->curTextId = 0x47E; // "Your deposits total [rupees]." } } @@ -399,23 +399,23 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) ((s32)(globalCtx->msgCtx.bankRupeesSelected + this->serviceFee))) { play_sound(NA_SE_SY_ERROR); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); - func_801518B0(globalCtx, 0x476, &this->actor); + Message_StartTextbox(globalCtx, 0x476, &this->actor); this->curTextId = 0x476; // you dont have enough deposited to withdrawl } else if (CUR_CAPACITY(UPG_WALLET) < (globalCtx->msgCtx.bankRupeesSelected + gSaveContext.rupees)) { // check if wallet is big enough play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0x475, &this->actor); + Message_StartTextbox(globalCtx, 0x475, &this->actor); this->curTextId = 0x475; // You can't hold that many in your wallet } else { func_8019F208(); if (globalCtx->msgCtx.bankRupeesSelected >= 100) { - func_801518B0(globalCtx, 0x474, &this->actor); + Message_StartTextbox(globalCtx, 0x474, &this->actor); this->curTextId = 0x474; // Aw, you're taking out all that? } else if (globalCtx->msgCtx.bankRupeesSelected >= 10) { - func_801518B0(globalCtx, 0x473, &this->actor); + Message_StartTextbox(globalCtx, 0x473, &this->actor); this->curTextId = 0x473; // use it wisely } else { - func_801518B0(globalCtx, 0x472, &this->actor); + Message_StartTextbox(globalCtx, 0x472, &this->actor); this->curTextId = 0x472; // It's a waste to take out such a tiny bit } @@ -428,7 +428,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) } } else { func_8019F230(); - func_801518B0(globalCtx, 0x47C, &this->actor); + Message_StartTextbox(globalCtx, 0x47C, &this->actor); this->curTextId = 0x47C; // "Is that so? Think it over, little guy! So what are you gonna do?" } break; @@ -441,22 +441,22 @@ void EnGinkoMan_WaitForRupeeCount(EnGinkoMan* this, GlobalContext* globalCtx) { case 0x450: // "How much? How much?" [rupee prompt] Set the amount with [Control Stick] and if (globalCtx->msgCtx.bankRupeesSelected == 0) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - func_801518B0(globalCtx, 0x457, &this->actor); + Message_StartTextbox(globalCtx, 0x457, &this->actor); this->curTextId = 0x457; // Zero Rupees? Cruel joke! } else { - func_801518B0(globalCtx, 0x452, &this->actor); + Message_StartTextbox(globalCtx, 0x452, &this->actor); this->curTextId = 0x452; // Really? are you really depositing [x]? Y/n } break; case 0x46E: // "How much do you want?" [rupee prompt] Set the amount with [Control Stick] if (globalCtx->msgCtx.bankRupeesSelected == 0) { - func_801518B0(globalCtx, 0x46F, &this->actor); + Message_StartTextbox(globalCtx, 0x46F, &this->actor); this->curTextId = 0x46F; // "Zero Rupees?!? That's a cruel joke!" } else if (gSaveContext.isNight == 1) { - func_801518B0(globalCtx, 0x477, &this->actor); + Message_StartTextbox(globalCtx, 0x477, &this->actor); this->curTextId = 0x477; // "...You know, at this time of day there's a 4 Rupee service charge... } else { - func_801518B0(globalCtx, 0x471, &this->actor); + Message_StartTextbox(globalCtx, 0x471, &this->actor); this->curTextId = 0x471; // "Are you really withdrawing [rupees selected]? Y/n this->serviceFee = 0; } @@ -536,11 +536,11 @@ void EnGinkoMan_BankAward2(EnGinkoMan* this, GlobalContext* globalCtx) { // "What's this? You've already saved up 200 Rupees!?! Well, little guy, here's your special gift. Take // it!" gSaveContext.weekEventReg[10] |= 8; - func_801518B0(globalCtx, 0x47A, &this->actor); + Message_StartTextbox(globalCtx, 0x47A, &this->actor); this->curTextId = 0x47A; // Message after receiving reward for depositing 200 rupees. } else { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - func_801518B0(globalCtx, 0x47B, &this->actor); + Message_StartTextbox(globalCtx, 0x47B, &this->actor); this->curTextId = 0x47B; // Message after receiving reward for depositing 1000 rupees. } @@ -572,17 +572,17 @@ void EnGinkoMan_Stamp(EnGinkoMan* this, GlobalContext* globalCtx) { switch (this->curTextId) { case 0x464: // "Hey, relax! It doesn't leave any marks, and it's not gonna hurt." Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - func_801518B0(globalCtx, 0x465, &this->actor); + Message_StartTextbox(globalCtx, 0x465, &this->actor); this->curTextId = 0x465; // "There! Now I'll know you when I see you!" break; case 0x469: // "Excuse me, but let me take a look at you..." Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); globalCtx->msgCtx.bankRupees = (gSaveContext.bankRupees & 0xFFFF); if ((CURRENT_DAY == 3) && (gSaveContext.isNight == 1)) { - func_801518B0(globalCtx, 0x46C, &this->actor); + Message_StartTextbox(globalCtx, 0x46C, &this->actor); this->curTextId = 0x46C; // "Ah, yes...[Link], right? } else { - func_801518B0(globalCtx, 0x46A, &this->actor); + Message_StartTextbox(globalCtx, 0x46A, &this->actor); this->curTextId = 0x46A; // "Ah, yes...[Link]. } break; diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.h b/src/overlays/actors/ovl_En_GirlA/z_en_girla.h index 5e3d1b136..fa2711501 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.h +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.h @@ -103,7 +103,7 @@ typedef enum { /* 39 */ SI_SWORD_RAZOR, /* 40 */ SI_SWORD_GILDED, /* 41 */ SI_SHIELD_HERO_4, - /* 42 */ SI_SHIELD_MIRROR, + /* 42 */ SI_SHIELD_MIRROR } EnGirlAShopItemId; extern const ActorInit En_GirlA_InitVars; 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 c78c96bd9..4f2d77498 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -534,16 +534,16 @@ void func_80B51410(EnGk* this, GlobalContext* globalCtx) { void func_80B51510(EnGk* this, GlobalContext* globalCtx) { s32 pad; - u32 temp_v0; + s32 actionIndex; if (this) {} - if (func_800EE29C(globalCtx, 0x1DF)) { - temp_v0 = func_800EE200(globalCtx, 0x1DF); + if (Cutscene_CheckActorAction(globalCtx, 479)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 479); - if (globalCtx->csCtx.npcActions[temp_v0]->unk0 != this->unk_31B) { - this->unk_31B = globalCtx->csCtx.npcActions[temp_v0]->unk0; - switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + if (globalCtx->csCtx.actorActions[actionIndex]->action != this->unk_31B) { + this->unk_31B = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: this->unk_31A = 0; this->unk_2E4 = 0; @@ -587,7 +587,7 @@ void func_80B51510(EnGk* this, GlobalContext* globalCtx) { func_80B51308(this, globalCtx); } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); this->actor.shape.yOffset = 0.0f; } else { this->unk_31B = 0x63; @@ -641,7 +641,7 @@ void func_80B51760(EnGk* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_1E4 |= 4; this->unk_31C = func_80B50410(this, globalCtx); - func_801518B0(globalCtx, this->unk_31C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); this->actionFunc = func_80B51970; if (this->unk_31C == 0xE81) { this->unk_2E4 = 0; @@ -682,7 +682,7 @@ void func_80B51970(EnGk* this, GlobalContext* globalCtx) { } this->unk_31C = func_80B50410(this, globalCtx); - func_801518B0(globalCtx, this->unk_31C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); if (this->unk_31C == 0xE80) { this->unk_1E4 |= 2; } else if (this->unk_31C == 0xE89) { @@ -736,7 +736,7 @@ void func_80B51B40(EnGk* this, GlobalContext* globalCtx) { } this->unk_31C = func_80B50710(this); - func_801518B0(globalCtx, this->unk_31C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); if (this->unk_31C == 0xE8C) { this->unk_1E4 |= 2; } @@ -746,13 +746,13 @@ void func_80B51B40(EnGk* this, GlobalContext* globalCtx) { case 0: func_8019F208(); this->unk_31C = 0xE8E; - func_801518B0(globalCtx, this->unk_31C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); break; case 1: func_8019F230(); this->unk_31C = 0xE8A; - func_801518B0(globalCtx, this->unk_31C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); break; } } @@ -790,7 +790,7 @@ void func_80B51D9C(EnGk* this, GlobalContext* globalCtx) { } else { this->unk_31C = 0xE99; } - func_801518B0(globalCtx, this->unk_31C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); this->actionFunc = func_80B51970; } } else { @@ -918,7 +918,7 @@ void func_80B52340(EnGk* this, GlobalContext* globalCtx) { this->unk_31C = 0xE93; this->actionFunc = func_80B52430; } - func_801518B0(globalCtx, this->unk_31C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); this->actor.flags &= ~ACTOR_FLAG_10000; } else { this->actor.flags |= ACTOR_FLAG_10000; @@ -933,13 +933,13 @@ void func_80B52430(EnGk* this, GlobalContext* globalCtx) { switch (this->unk_31C) { case 0xE93: this->unk_31C = 0xE89; - func_801518B0(globalCtx, this->unk_31C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); this->actionFunc = func_80B51B40; return; case 0xE90: this->unk_31C = 0xE91; - func_801518B0(globalCtx, this->unk_31C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); return; case 0xE91: @@ -980,7 +980,7 @@ void func_80B5253C(EnGk* this, GlobalContext* globalCtx) { void func_80B525E0(EnGk* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_31C = 0xE92; - func_801518B0(globalCtx, this->unk_31C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); this->actionFunc = func_80B52430; } else { func_800B85E0(&this->actor, globalCtx, 400.0f, -1); 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 cdfda5ba9..dc063bd35 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -1551,8 +1551,8 @@ void func_80950F2C(EnGm* this, GlobalContext* globalCtx) { s32 sp2C; s16 yaw; - if (func_800EE29C(globalCtx, 0x20E)) { - sp2C = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x20E)]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 526)) { + sp2C = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 526)]->action; if (this->unk_259 != (sp2C & 0xFF)) { if (sp2C == 3) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); 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 6d7f97630..771f0ab83 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -537,7 +537,7 @@ s32 func_80A1222C(EnGo* this, GlobalContext* globalCtx) { if (((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.ocarinaMode == 3) && (globalCtx->msgCtx.unk1202E == 1) && (this->unk_3EC == 0) && (this->actor.xzDistToPlayer < 400.0f)) || (!(gSaveContext.weekEventReg[22] & 4) && (globalCtx->sceneNum == SCENE_16GORON_HOUSE) && - (gSaveContext.sceneSetupIndex == 0) && (this->unk_3EC == 0) && (globalCtx->csCtx.unk_12 == 1))) { + (gSaveContext.sceneSetupIndex == 0) && (this->unk_3EC == 0) && (globalCtx->csCtx.currentCsIndex == 1))) { ret = true; } return ret; @@ -710,7 +710,7 @@ s32 func_80A12868(EnGo* this, GlobalContext* globalCtx) { s32 func_80A12954(EnGo* this, GlobalContext* globalCtx) { if ((ENGO_GET_F(&this->actor) == ENGO_F_4) && (globalCtx->csCtx.state != 0) && (this->actor.draw != NULL) && (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && - (globalCtx->csCtx.unk_12 == 0)) { + (globalCtx->csCtx.currentCsIndex == 0)) { if (this->unk_3F0 == 0) { this->actor.flags &= ~ACTOR_FLAG_1; this->unk_394 = 255; @@ -1410,7 +1410,7 @@ void func_80A144F4(EnGo* this, GlobalContext* globalCtx) { void func_80A145AC(EnGo* this, GlobalContext* globalCtx) { if ((ENGO_GET_70(&this->actor) == ENGO_70_1) && (((globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && - (globalCtx->csCtx.unk_12 == 0)) || + (globalCtx->csCtx.currentCsIndex == 0)) || !(gSaveContext.weekEventReg[21] & 8))) { this->actor.child = func_80A13400(this, globalCtx); this->actor.child->child = &this->actor; @@ -1633,24 +1633,24 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { s32 sp38[] = { 0, 2, 6, 20, 18, 5, 5, 15, }; - u16 sp36 = 0; + u16 actorActionCmd = 0; s32 sp30; - u32 sp2C; + s32 actionIndex; switch (ENGO_GET_70(&this->actor)) { case ENGO_70_0: - sp36 = 0x80; + actorActionCmd = 128; break; case ENGO_70_1: - sp36 = 0x81; + actorActionCmd = 129; break; } - if ((sp36 == 0x80) || (sp36 == 0x81)) { - if (func_800EE29C(globalCtx, sp36)) { - sp2C = func_800EE200(globalCtx, sp36); - sp30 = globalCtx->csCtx.npcActions[sp2C]->unk0; + if ((actorActionCmd == 128) || (actorActionCmd == 129)) { + if (Cutscene_CheckActorAction(globalCtx, actorActionCmd)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, actorActionCmd); + sp30 = globalCtx->csCtx.actorActions[actionIndex]->action; if (this->unk_394 != (u8)sp30) { this->unk_394 = sp30; @@ -1699,7 +1699,7 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { break; } - if (sp36 == 0x80) { + if (actorActionCmd == 128) { switch (globalCtx->csCtx.frames) { case 55: case 100: @@ -1723,7 +1723,7 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_VOICE_EATFULL); break; } - } else if (sp36 == 0x81) { + } else if (actorActionCmd == 129) { switch (globalCtx->csCtx.frames) { case 360: case 390: @@ -1745,7 +1745,7 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { } SubS_FillLimbRotTables(globalCtx, this->unk_3CE, this->unk_3C8, ARRAY_COUNT(this->unk_3CE)); - func_800EDF24(&this->actor, globalCtx, sp2C); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); } } } 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 7bae831cf..9f4bdb728 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -206,7 +206,7 @@ void func_80997DEC(EnGs* this, GlobalContext* globalCtx) { void func_80997E4C(EnGs* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 0: - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); break; case 1: @@ -533,10 +533,11 @@ s32 func_80998A48(EnGs* this, GlobalContext* globalCtx) { } else if (this->unk_19D == 1) { if (func_80998334(this, globalCtx, &this->unk_1DC, &this->unk_1E0, &this->unk_1D4, 0.8f, 0.007f, 0.001f, 7, 0) == 0.0f) { - if ((this->actor.params != ENGS_0) && !func_801690CC(globalCtx) && !Message_GetState(&globalCtx->msgCtx)) { + if ((this->actor.params != ENGS_0) && !func_801690CC(globalCtx) && + Message_GetState(&globalCtx->msgCtx) == 0) { this->unk_216 = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIVE_LUPY_COUNT); - func_801518B0(globalCtx, 0x20D2, NULL); + Message_StartTextbox(globalCtx, 0x20D2, NULL); } this->unk_19A &= ~1; sp3C = 0; 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 e984eb40f..2af301e13 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -156,10 +156,10 @@ void func_80BCF354(EnHg* this) { void func_80BCF398(EnHg* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.health == 1) { if ((this->actor.xzDistToPlayer < 200.0f && this->actor.playerHeightRel < 40.0f) && - !func_800EE29C(globalCtx, 0x1E3)) { + !Cutscene_CheckActorAction(globalCtx, 0x1E3)) { func_80BCF468(this); } - if ((gSaveContext.sceneSetupIndex == 0 && globalCtx->csCtx.unk_12 == 0) && + if ((gSaveContext.sceneSetupIndex == 0 && globalCtx->csCtx.currentCsIndex == 0) && (globalCtx->csCtx.frames == 20 || globalCtx->csCtx.frames == 60)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HALF_REDEAD_SURPRISE); } @@ -176,7 +176,7 @@ void func_80BCF4AC(EnHg* this, GlobalContext* globalCtx) { s32 pad; this->actor.speedXZ = 1.6f; - if (!(player->stateFlags2 & 0x08000000) && !Message_GetState(&globalCtx->msgCtx)) { + if (!(player->stateFlags2 & 0x08000000) && Message_GetState(&globalCtx->msgCtx) == 0) { 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); @@ -217,7 +217,7 @@ void func_80BCF6D0(EnHg* this, GlobalContext* globalCtx) { void func_80BCF710(EnHg* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 0) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x24F, &this->actor); + Message_StartTextbox(globalCtx, 0x24F, &this->actor); } else { func_800B8614(&this->actor, globalCtx, 80.0f); } @@ -271,11 +271,12 @@ void func_80BCF93C(EnHg* this) { } void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x1E4)) { - u32 actionIndex = func_800EE200(globalCtx, 0x1E4); - if (this->cutscenes[3] != globalCtx->csCtx.npcActions[actionIndex]->unk0) { - this->cutscenes[3] = globalCtx->csCtx.npcActions[actionIndex]->unk0; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 484)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 484); + + if (this->cutscenes[3] != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->cutscenes[3] = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: this->currentAnimation = 0; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); @@ -336,7 +337,7 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { } break; } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); return; } else if (globalCtx->csCtx.state == 0) { func_80BCF354(this); 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 0049205d9..d089de0da 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -137,29 +137,29 @@ void func_80BD04E0(EnHgo* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { if (!(this->unk_310 & 4)) { this->unk_310 |= 4; - func_801518B0(globalCtx, 0x15A5, &this->actor); + Message_StartTextbox(globalCtx, 0x15A5, &this->actor); this->unk_314 = 0x15A5; // That mask is a gibdo } else { - func_801518B0(globalCtx, 0x15A7, &this->actor); + Message_StartTextbox(globalCtx, 0x15A7, &this->actor); this->unk_314 = 0x15A7; // can I research that mask } } else if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { if (!(this->unk_310 & 1)) { this->unk_310 |= 1; - func_801518B0(globalCtx, 0x158F, &this->actor); + Message_StartTextbox(globalCtx, 0x158F, &this->actor); this->unk_314 = 0x158F; // Isn't this a fairy } else { - func_801518B0(globalCtx, 0x1593, &this->actor); + Message_StartTextbox(globalCtx, 0x1593, &this->actor); this->unk_314 = 0x1593; // Never seen a fairy this lively } } else { if (!(this->unk_310 & 2)) { this->unk_310 |= 2; - func_801518B0(globalCtx, 0x1595, &this->actor); + Message_StartTextbox(globalCtx, 0x1595, &this->actor); this->unk_314 = 0x1595; // ghost radar is reacting } else { - func_801518B0(globalCtx, 0x1598, &this->actor); + Message_StartTextbox(globalCtx, 0x1598, &this->actor); this->unk_314 = 0x1598; // you seem to be similar to a ghost } } @@ -197,44 +197,44 @@ void func_80BD06FC(EnHgo* this, GlobalContext* globalCtx) { if (func_80147624(globalCtx)) { switch (this->unk_314) { case 0x158F: - func_801518B0(globalCtx, 0x1590, &this->actor); + Message_StartTextbox(globalCtx, 0x1590, &this->actor); this->unk_314 = 0x1590; break; case 0x1590: if (gSaveContext.weekEventReg[14] & 4) { - func_801518B0(globalCtx, 0x1591, &this->actor); + Message_StartTextbox(globalCtx, 0x1591, &this->actor); this->unk_314 = 0x1591; break; } - func_801518B0(globalCtx, 0x1592, &this->actor); + Message_StartTextbox(globalCtx, 0x1592, &this->actor); this->unk_314 = 0x1592; break; case 0x1591: - func_801518B0(globalCtx, 0x1592, &this->actor); + Message_StartTextbox(globalCtx, 0x1592, &this->actor); this->unk_314 = 0x1592; break; case 0x1593: - func_801518B0(globalCtx, 0x1594, &this->actor); + Message_StartTextbox(globalCtx, 0x1594, &this->actor); this->unk_314 = 0x1594; break; case 0x1595: - func_801518B0(globalCtx, 0x1596, &this->actor); + Message_StartTextbox(globalCtx, 0x1596, &this->actor); this->unk_314 = 0x1596; break; case 0x1596: - func_801518B0(globalCtx, 0x1597, &this->actor); + Message_StartTextbox(globalCtx, 0x1597, &this->actor); this->unk_314 = 0x1597; break; case 0x1598: - func_801518B0(globalCtx, 0x1599, &this->actor); + Message_StartTextbox(globalCtx, 0x1599, &this->actor); this->unk_314 = 0x1599; break; case 0x15A5: - func_801518B0(globalCtx, 0x15A6, &this->actor); + Message_StartTextbox(globalCtx, 0x15A6, &this->actor); this->unk_314 = 0x15A6; break; case 0x15A6: - func_801518B0(globalCtx, 0x15A7, &this->actor); + Message_StartTextbox(globalCtx, 0x15A7, &this->actor); this->unk_314 = 0x15A7; break; case 0x15A7: @@ -246,13 +246,13 @@ void func_80BD06FC(EnHgo* this, GlobalContext* globalCtx) { } s32 func_80BD0898(EnHgo* this, GlobalContext* globalCtx) { - u32 actionIndex; + s32 actionIndex; - if (func_800EE29C(globalCtx, 0x1E6)) { - actionIndex = func_800EE200(globalCtx, 0x1E6); - if (this->unk_316 != globalCtx->csCtx.npcActions[actionIndex]->unk0) { - this->unk_316 = globalCtx->csCtx.npcActions[actionIndex]->unk0; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 486)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 486); + if (this->unk_316 != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->unk_316 = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: this->unk_218 = 0; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); @@ -285,7 +285,7 @@ s32 func_80BD0898(EnHgo* this, GlobalContext* globalCtx) { if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && (this->unk_312 == 0)) { this->unk_312 = 1; if ((gSaveContext.sceneSetupIndex == 0) && - ((globalCtx->csCtx.unk_12 == 2) || (globalCtx->csCtx.unk_12 == 4))) { + ((globalCtx->csCtx.currentCsIndex == 2) || (globalCtx->csCtx.currentCsIndex == 4))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_GBVO02); } } @@ -300,7 +300,7 @@ s32 func_80BD0898(EnHgo* this, GlobalContext* globalCtx) { } } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); return true; } if ((globalCtx->csCtx.state == 0) && (((gSaveContext.weekEventReg[75]) & 0x20)) && 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 de73118da..fa5b8e190 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 @@ -395,7 +395,7 @@ void func_80C2077C(EnHintSkb* this, GlobalContext* globalCtx) { this->unk_3E0 = 1; if (this->unk_3DC == 0) { this->unk_3DC = 1; - func_801518B0(globalCtx, 0x1147, &this->actor); + Message_StartTextbox(globalCtx, 0x1147, &this->actor); this->unk_3E6 = 0x1147; if (this->skelAnime.animation == &object_skb_Anim_00697C) { globalCtx->msgCtx.msgMode = 0x44; @@ -406,7 +406,7 @@ void func_80C2077C(EnHintSkb* this, GlobalContext* globalCtx) { } } else { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); - func_801518B0(globalCtx, 0x1148, &this->actor); + Message_StartTextbox(globalCtx, 0x1148, &this->actor); this->unk_3E6 = 0x1148; } func_80C208BC(this); @@ -462,7 +462,7 @@ void func_80C208D0(EnHintSkb* this, GlobalContext* globalCtx) { if ((this->skelAnime.animation == &object_skb_Anim_003584) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_801518B0(globalCtx, 0x1147, &this->actor); + Message_StartTextbox(globalCtx, 0x1147, &this->actor); this->unk_3E6 = 0x1147; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); } @@ -479,37 +479,37 @@ void func_80C20A74(EnHintSkb* this, GlobalContext* globalCtx) { switch (params) { case 1: - func_801518B0(globalCtx, 0x1149, &this->actor); + Message_StartTextbox(globalCtx, 0x1149, &this->actor); this->unk_3E6 = 0x1149; break; case 2: - func_801518B0(globalCtx, 0x114A, &this->actor); + Message_StartTextbox(globalCtx, 0x114A, &this->actor); this->unk_3E6 = 0x114A; break; case 3: - func_801518B0(globalCtx, 0x114B, &this->actor); + Message_StartTextbox(globalCtx, 0x114B, &this->actor); this->unk_3E6 = 0x114B; break; case 4: - func_801518B0(globalCtx, 0x114C, &this->actor); + Message_StartTextbox(globalCtx, 0x114C, &this->actor); this->unk_3E6 = 0x114C; break; case 5: - func_801518B0(globalCtx, 0x114D, &this->actor); + Message_StartTextbox(globalCtx, 0x114D, &this->actor); this->unk_3E6 = 0x114D; break; case 6: - func_801518B0(globalCtx, 0x114E, &this->actor); + Message_StartTextbox(globalCtx, 0x114E, &this->actor); this->unk_3E6 = 0x114E; break; default: - func_801518B0(globalCtx, 0x1149, &this->actor); + Message_StartTextbox(globalCtx, 0x1149, &this->actor); this->unk_3E6 = 0x1149; break; } @@ -520,11 +520,11 @@ void func_80C20B88(EnHintSkb* this, GlobalContext* globalCtx) { if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); this->unk_3E8 |= 0x10; - func_801518B0(globalCtx, 0x1150, &this->actor); + Message_StartTextbox(globalCtx, 0x1150, &this->actor); this->unk_3E6 = 0x1150; } else { func_8019F230(); - func_801518B0(globalCtx, 0x1152, &this->actor); + Message_StartTextbox(globalCtx, 0x1152, &this->actor); this->unk_3E6 = 0x1152; } } @@ -537,7 +537,7 @@ void func_80C20C24(EnHintSkb* this, GlobalContext* globalCtx) { switch (this->unk_3E6) { case 0x1147: - func_801518B0(globalCtx, 0x1148, &this->actor); + Message_StartTextbox(globalCtx, 0x1148, &this->actor); this->unk_3E6 = 0x1148; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); break; @@ -552,17 +552,17 @@ void func_80C20C24(EnHintSkb* this, GlobalContext* globalCtx) { case 0x114C: case 0x114D: case 0x114E: - func_801518B0(globalCtx, 0x114F, &this->actor); + Message_StartTextbox(globalCtx, 0x114F, &this->actor); this->unk_3E6 = 0x114F; break; case 0x1152: - func_801518B0(globalCtx, 0x1151, &this->actor); + Message_StartTextbox(globalCtx, 0x1151, &this->actor); this->unk_3E6 = 0x1151; break; case 0x1150: - func_801518B0(globalCtx, 0x1151, &this->actor); + Message_StartTextbox(globalCtx, 0x1151, &this->actor); this->unk_3E6 = 0x1151; break; 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 a7dfc26ac..e84a18bef 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -1215,7 +1215,7 @@ s32 func_808F5728(GlobalContext* globalCtx, EnIn* this, s32 arg2, s32* arg3) { return 0; } if (*arg3 == 2) { - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); *arg3 = 1; return 0; } diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index d36644b4a..667f66a51 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -1350,7 +1350,7 @@ s32 func_80B45550(EnInvadepoh* this, GlobalContext* globalCtx, f32 range, s32 ar void EnInvadepoh_SetTextID(EnInvadepoh* this, GlobalContext* globalCtx, u16 arg2) { this->textId = arg2; - func_801518B0(globalCtx, arg2, &this->actor); + Message_StartTextbox(globalCtx, arg2, &this->actor); } void func_80B45648(EnInvadepoh* this) { 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 8f9b3fb44..7797f2ad4 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -349,7 +349,7 @@ void EnJg_Idle(EnJg* this, GlobalContext* globalCtx) { void EnJg_GoronShrineIdle(EnJg* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->flags |= FLAG_LOOKING_AT_PLAYER; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnJg_GoronShrineTalk; } else if ((this->actor.xzDistToPlayer < 100.0f) || (this->actor.isTargeted)) { func_800B863C(&this->actor, globalCtx); @@ -367,7 +367,7 @@ void EnJg_GoronShrineTalk(EnJg* this, GlobalContext* globalCtx) { this->actionFunc = EnJg_GoronShrineIdle; } else { this->textId = EnJg_GetNextTextId(this); - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } } } @@ -504,7 +504,7 @@ void EnJg_Talk(EnJg* this, GlobalContext* globalCtx) { (CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO))) { // The player already has the Lullaby or Lullaby Intro, so say "I'm counting on you" this->textId = EnJg_GetNextTextId(this); - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnJg_SetupTalk; } else { // To get to this point, the player *has* talked to the Goron Child, but doesn't @@ -522,7 +522,7 @@ void EnJg_Talk(EnJg* this, GlobalContext* globalCtx) { } } else { this->textId = EnJg_GetNextTextId(this); - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnJg_SetupTalk; } } @@ -591,7 +591,7 @@ void EnJg_FrozenIdle(EnJg* this, GlobalContext* globalCtx) { } } else { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x236, &this->actor); // The old Goron is frozen solid! + Message_StartTextbox(globalCtx, 0x236, &this->actor); // The old Goron is frozen solid! this->actionFunc = EnJg_EndFrozenInteraction; } else if (this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); @@ -622,13 +622,13 @@ void EnJg_TeachLullabyIntro(EnJg* this, GlobalContext* globalCtx) { void EnJg_LullabyIntroCutsceneAction(EnJg* this, GlobalContext* globalCtx) { s32 pad; - if (func_800EE29C(globalCtx, 0x1D6)) { - u32 actionIndex = func_800EE200(globalCtx, 0x1D6); + if (Cutscene_CheckActorAction(globalCtx, 470)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 470); - if (this->csAction != globalCtx->csCtx.npcActions[actionIndex]->unk0) { - this->csAction = globalCtx->csCtx.npcActions[actionIndex]->unk0; + if (this->csAction != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->csAction = globalCtx->csCtx.actorActions[actionIndex]->action; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: this->cutsceneAnimationIndex = EN_JG_ANIMATION_CUTSCENE_IDLE; if (this->drum != NULL) { @@ -913,7 +913,7 @@ void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, GlobalContext* gSaveContext.weekEventReg[24] |= 0x10; } - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnJg_SetupTalk; } else { if ((this->actor.xzDistToPlayer < 100.0f) || (this->actor.isTargeted)) { @@ -949,7 +949,7 @@ void EnJg_Init(Actor* thisx, GlobalContext* globalCtx) { if (!EN_JG_IS_IN_GORON_SHRINE(thisx)) { if ((globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7) && - (globalCtx->csCtx.unk_12 == 0)) { + (globalCtx->csCtx.currentCsIndex == 0)) { // This is the elder that appears in the cutscene for learning the full Goron Lullaby. this->animationIndex = EN_JG_ANIMATION_IDLE; this->action = EN_JG_ACTION_LULLABY_INTRO_CS; 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 3fca0129d..f1d1737e4 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -549,7 +549,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx) { this->actor.textId = 0x1646; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->cutsceneCamId = CAM_ID_MAIN; this->unk20C = 0.0f; this->unk210 = 60.0f; @@ -682,7 +682,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { func_801477B4(globalCtx); func_800B7298(globalCtx, &this->actor, 0x56); this->actor.textId = 0x1648; - func_801518B0(globalCtx, (this->actor.textId), &this->actor); + Message_StartTextbox(globalCtx, (this->actor.textId), &this->actor); this->unkState1A8 = 0; this->unk190 = 1; } 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 d42d75bb1..eee97c5f7 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 @@ -164,7 +164,7 @@ void func_80B2654C(EnKendoJs* this, GlobalContext* globalCtx) { } if (ENKENDOJS_GET_FF(&this->actor) == ENKENDOJS_FF_1) { - func_801518B0(globalCtx, 0x273C, &this->actor); + Message_StartTextbox(globalCtx, 0x273C, &this->actor); this->unk_288 = 0x273C; } else if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { switch (gSaveContext.playerForm) { @@ -185,14 +185,14 @@ void func_80B2654C(EnKendoJs* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, D_80B27CE0[phi_v0][sp30], &this->actor); + Message_StartTextbox(globalCtx, D_80B27CE0[phi_v0][sp30], &this->actor); this->unk_288 = D_80B27CE0[phi_v0][sp30]; } else if ((Player_GetMask(globalCtx) != PLAYER_MASK_NONE) && (Player_GetMask(globalCtx) < PLAYER_MASK_GIANT)) { u16 sp2E = Player_GetMask(globalCtx) + 0x273C; if (0) {} - func_801518B0(globalCtx, sp2E, &this->actor); + Message_StartTextbox(globalCtx, sp2E, &this->actor); this->unk_288 = sp2E; } else { if (this->unk_28A == 0) { @@ -201,7 +201,7 @@ void func_80B2654C(EnKendoJs* this, GlobalContext* globalCtx) { } else { phi_v0 = 1; } - func_801518B0(globalCtx, D_80B27CF4[phi_v0][sp30], &this->actor); + Message_StartTextbox(globalCtx, D_80B27CF4[phi_v0][sp30], &this->actor); this->unk_288 = D_80B27CF4[phi_v0][sp30]; } @@ -217,17 +217,17 @@ void func_80B26758(EnKendoJs* this, GlobalContext* globalCtx) { case 0: if (CUR_EQUIP_VALUE_VOID(EQUIP_SWORD) == EQUIP_SWORD) { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0x272C, &this->actor); + Message_StartTextbox(globalCtx, 0x272C, &this->actor); this->unk_288 = 0x272C; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); } else if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0x2718, &this->actor); + Message_StartTextbox(globalCtx, 0x2718, &this->actor); this->unk_288 = 0x2718; } else { func_8019F208(); func_801159EC(-globalCtx->msgCtx.unk1206C); - func_801518B0(globalCtx, 0x2719, &this->actor); + Message_StartTextbox(globalCtx, 0x2719, &this->actor); this->unk_288 = 0x2719; } break; @@ -235,24 +235,24 @@ void func_80B26758(EnKendoJs* this, GlobalContext* globalCtx) { case 1: if (CUR_EQUIP_VALUE_VOID(EQUIP_SWORD) == EQUIP_SWORD) { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0x272C, &this->actor); + Message_StartTextbox(globalCtx, 0x272C, &this->actor); this->unk_288 = 0x272C; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); } else if (gSaveContext.rupees < globalCtx->msgCtx.unk12070) { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0x2718, &this->actor); + Message_StartTextbox(globalCtx, 0x2718, &this->actor); this->unk_288 = 0x2718; } else { func_8019F208(); func_801159EC(-globalCtx->msgCtx.unk12070); - func_801518B0(globalCtx, 0x273A, &this->actor); + Message_StartTextbox(globalCtx, 0x273A, &this->actor); this->unk_288 = 0x273A; } break; case 2: func_8019F230(); - func_801518B0(globalCtx, 0x2717, &this->actor); + Message_StartTextbox(globalCtx, 0x2717, &this->actor); this->unk_288 = 0x2717; } } @@ -272,7 +272,7 @@ void func_80B269A4(EnKendoJs* this, GlobalContext* globalCtx) { case 0x2713: case 0x2714: case 0x2715: - func_801518B0(globalCtx, 0x2716, &this->actor); + Message_StartTextbox(globalCtx, 0x2716, &this->actor); this->unk_288 = 0x2716; break; @@ -288,7 +288,7 @@ void func_80B269A4(EnKendoJs* this, GlobalContext* globalCtx) { break; case 0x273A: - func_801518B0(globalCtx, 0x273B, &this->actor); + Message_StartTextbox(globalCtx, 0x273B, &this->actor); this->unk_288 = 0x273B; break; @@ -433,13 +433,13 @@ s32 func_80B26BF8(EnKendoJs* this, GlobalContext* globalCtx) { } void func_80B26EB4(EnKendoJs* this, GlobalContext* globalCtx) { - func_801518B0(globalCtx, D_80B27D00[this->unk_284], &this->actor); + Message_StartTextbox(globalCtx, D_80B27D00[this->unk_284], &this->actor); this->unk_288 = D_80B27D00[this->unk_284]; this->unk_284++; } void func_80B26F14(EnKendoJs* this, GlobalContext* globalCtx) { - func_801518B0(globalCtx, D_80B27D10[this->unk_284], &this->actor); + Message_StartTextbox(globalCtx, D_80B27D10[this->unk_284], &this->actor); this->unk_288 = D_80B27D10[this->unk_284]; } @@ -449,7 +449,7 @@ s32 func_80B26F6C(EnKendoJs* this, GlobalContext* globalCtx) { switch (this->unk_288) { case 0x271D: if (func_80124190(player)) { - func_801518B0(globalCtx, 0x272A, &this->actor); + Message_StartTextbox(globalCtx, 0x272A, &this->actor); this->unk_288 = 0x272A; return true; } @@ -457,7 +457,7 @@ s32 func_80B26F6C(EnKendoJs* this, GlobalContext* globalCtx) { case 0x2721: if (this->unk_292 != 0) { - func_801518B0(globalCtx, 0x272B, &this->actor); + Message_StartTextbox(globalCtx, 0x272B, &this->actor); this->unk_288 = 0x272B; return true; } @@ -482,7 +482,7 @@ void func_80B27030(EnKendoJs* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_10000; player->stateFlags1 &= ~0x20; func_80B279F0(this, globalCtx, 0); - func_801518B0(globalCtx, 0x271A, &this->actor); + Message_StartTextbox(globalCtx, 0x271A, &this->actor); this->unk_288 = 0x271A; func_80B26AE8(this); } else { @@ -531,7 +531,7 @@ void func_80B27188(EnKendoJs* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); this->unk_286 = 0; player->stateFlags1 |= 0x20; - func_801518B0(globalCtx, 0x2729, &this->actor); + Message_StartTextbox(globalCtx, 0x2729, &this->actor); this->unk_288 = 0x2729; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); break; @@ -586,10 +586,10 @@ void func_80B274BC(EnKendoJs* this, GlobalContext* globalCtx) { if (this->unk_290 >= 140) { if (this->unk_284 == 5) { if (gSaveContext.minigameScore == 30) { - func_801518B0(globalCtx, 0x272D, &this->actor); + Message_StartTextbox(globalCtx, 0x272D, &this->actor); this->unk_288 = 0x272D; } else { - func_801518B0(globalCtx, 0x272E, &this->actor); + Message_StartTextbox(globalCtx, 0x272E, &this->actor); this->unk_288 = 0x272E; } player->stateFlags1 |= 0x20; @@ -652,10 +652,10 @@ void func_80B27774(EnKendoJs* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (!(gSaveContext.weekEventReg[63] & 0x20)) { gSaveContext.weekEventReg[63] |= 0x20; - func_801518B0(globalCtx, 0x272F, &this->actor); + Message_StartTextbox(globalCtx, 0x272F, &this->actor); this->unk_288 = 0x272F; } else { - func_801518B0(globalCtx, 0x2730, &this->actor); + Message_StartTextbox(globalCtx, 0x2730, &this->actor); this->unk_288 = 0x2730; } func_80B26AE8(this); 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 50c83422f..0099ff967 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -62,7 +62,7 @@ void EnKgy_Init(Actor* thisx, GlobalContext* globalCtx) { Flags_UnsetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); if (Flags_GetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor)) || (gSaveContext.weekEventReg[33] & 0x80)) { Flags_SetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); - globalCtx->envCtx.unk_C3 = 1; + globalCtx->envCtx.lightSettingOverride = 1; gSaveContext.weekEventReg[21] |= 1; if (!func_80B40D64(globalCtx)) { EnKgy_ChangeAnim(this, 4, 0, 0); diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index 447749566..b5080ec79 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -209,7 +209,7 @@ void EnMa4_Init(Actor* thisx, GlobalContext* globalCtx) { this->hasBow = false; } - if (func_800EE1D8(globalCtx) != 0) { // if (sceneSetupIndex != 0) + if (Cutscene_GetSceneSetupIndex(globalCtx) != 0) { // if (sceneSetupIndex != 0) EnMa4_ChangeAnim(this, 0); this->state = MA4_STATE_HORSEBACKGAME; EnMa4_InitHorsebackGame(this, globalCtx); @@ -362,11 +362,11 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3339: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - func_801518B0(globalCtx, 0x333A, &this->actor); + Message_StartTextbox(globalCtx, 0x333A, &this->actor); this->textId = 0x333A; } else { func_8019F208(); - func_801518B0(globalCtx, 0x333B, &this->actor); + Message_StartTextbox(globalCtx, 0x333B, &this->actor); this->textId = 0x333B; } break; @@ -375,12 +375,12 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); gSaveContext.weekEventReg[21] |= 0x20; - func_801518B0(globalCtx, 0x3343, &this->actor); + Message_StartTextbox(globalCtx, 0x3343, &this->actor); this->textId = 0x3343; } else { func_8019F230(); EnMa4_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x3342, &this->actor); + Message_StartTextbox(globalCtx, 0x3342, &this->actor); this->textId = 0x3342; this->state = MA4_STATE_DEFAULT; func_80151BB4(globalCtx, 5); @@ -391,12 +391,12 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); gSaveContext.weekEventReg[21] |= 0x20; - func_801518B0(globalCtx, 0x3343, &this->actor); + Message_StartTextbox(globalCtx, 0x3343, &this->actor); this->textId = 0x3343; } else { func_8019F230(); EnMa4_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x3342, &this->actor); + Message_StartTextbox(globalCtx, 0x3342, &this->actor); this->textId = 0x3342; } break; @@ -404,11 +404,11 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3347: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - func_801518B0(globalCtx, 0x3349, &this->actor); + Message_StartTextbox(globalCtx, 0x3349, &this->actor); this->textId = 0x3349; } else { func_8019F230(); - func_801518B0(globalCtx, 0x3348, &this->actor); + Message_StartTextbox(globalCtx, 0x3348, &this->actor); this->textId = 0x3348; func_80151BB4(globalCtx, 5); } @@ -419,7 +419,7 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { s32 aux; func_8019F208(); - func_801518B0(globalCtx, 0x334E, &this->actor); + Message_StartTextbox(globalCtx, 0x334E, &this->actor); this->textId = 0x334E; if (CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { func_80151BB4(globalCtx, 0x1C); @@ -428,7 +428,7 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { } else { // No. func_8019F230(); EnMa4_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x334C, &this->actor); + Message_StartTextbox(globalCtx, 0x334C, &this->actor); this->textId = 0x334C; } break; @@ -436,12 +436,12 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3354: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - func_801518B0(globalCtx, 0x3349, &this->actor); + Message_StartTextbox(globalCtx, 0x3349, &this->actor); this->textId = 0x3349; } else { func_8019F230(); EnMa4_SetFaceExpression(this, 1, 0); - func_801518B0(globalCtx, 0x3355, &this->actor); + Message_StartTextbox(globalCtx, 0x3355, &this->actor); this->textId = 0x3355; func_80151BB4(globalCtx, 5); } @@ -457,13 +457,13 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { if (this->type == MA4_TYPE_ALIENS_DEFEATED) { func_8019F230(); EnMa4_SetFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x3357, &this->actor); + Message_StartTextbox(globalCtx, 0x3357, &this->actor); this->textId = 0x3357; func_80151BB4(globalCtx, 5); } else { func_8019F230(); EnMa4_SetFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x335B, &this->actor); + Message_StartTextbox(globalCtx, 0x335B, &this->actor); this->textId = 0x335B; func_80151BB4(globalCtx, 5); } @@ -473,12 +473,12 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3359: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - func_801518B0(globalCtx, 0x3349, &this->actor); + Message_StartTextbox(globalCtx, 0x3349, &this->actor); this->textId = 0x3349; } else { func_8019F230(); EnMa4_SetFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x335A, &this->actor); + Message_StartTextbox(globalCtx, 0x335A, &this->actor); this->textId = 0x335A; func_80151BB4(globalCtx, 5); } @@ -500,31 +500,31 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { case 0x3335: EnMa4_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x3336, &this->actor); + Message_StartTextbox(globalCtx, 0x3336, &this->actor); this->textId = 0x3336; func_80151BB4(globalCtx, 5); break; case 0x3338: - func_801518B0(globalCtx, 0x3339, &this->actor); + Message_StartTextbox(globalCtx, 0x3339, &this->actor); this->textId = 0x3339; break; case 0x333A: case 0x333B: EnMa4_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x333C, &this->actor); + Message_StartTextbox(globalCtx, 0x333C, &this->actor); this->textId = 0x333C; break; case 0x333C: EnMa4_SetFaceExpression(this, 0, 2); - func_801518B0(globalCtx, 0x333D, &this->actor); + Message_StartTextbox(globalCtx, 0x333D, &this->actor); this->textId = 0x333D; break; case 0x333D: - func_801518B0(globalCtx, 0x333E, &this->actor); + Message_StartTextbox(globalCtx, 0x333E, &this->actor); this->textId = 0x333E; break; @@ -534,34 +534,34 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { break; case 0x333F: - func_801518B0(globalCtx, 0x3340, &this->actor); + Message_StartTextbox(globalCtx, 0x3340, &this->actor); this->textId = 0x3340; break; case 0x3340: EnMa4_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x3341, &this->actor); + Message_StartTextbox(globalCtx, 0x3341, &this->actor); this->textId = 0x3341; break; case 0x3343: EnMa4_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x3344, &this->actor); + Message_StartTextbox(globalCtx, 0x3344, &this->actor); this->textId = 0x3344; break; case 0x3344: - func_801518B0(globalCtx, 0x3345, &this->actor); + Message_StartTextbox(globalCtx, 0x3345, &this->actor); this->textId = 0x3345; break; case 0x3345: - func_801518B0(globalCtx, 0x3349, &this->actor); + Message_StartTextbox(globalCtx, 0x3349, &this->actor); this->textId = 0x3349; break; case 0x3349: - func_801518B0(globalCtx, 0x334A, &this->actor); + Message_StartTextbox(globalCtx, 0x334A, &this->actor); this->textId = 0x334A; break; @@ -571,7 +571,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { break; case 0x334C: - func_801518B0(globalCtx, 0x334D, &this->actor); + Message_StartTextbox(globalCtx, 0x334D, &this->actor); this->textId = 0x334D; break; @@ -580,10 +580,10 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { case 0x335D: case 0x335E: if (this->type == MA4_TYPE_DAY1) { - func_801518B0(globalCtx, 0x3352, &this->actor); + Message_StartTextbox(globalCtx, 0x3352, &this->actor); this->textId = 0x3352; } else { - func_801518B0(globalCtx, 0x3356, &this->actor); + Message_StartTextbox(globalCtx, 0x3356, &this->actor); this->textId = 0x3356; } break; @@ -594,7 +594,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { // Check if player has Epona's song if (CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { - func_801518B0(globalCtx, 0x334C, &this->actor); + Message_StartTextbox(globalCtx, 0x334C, &this->actor); this->textId = 0x334C; } else { func_801477B4(globalCtx); @@ -606,11 +606,11 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { case 0x3358: if ((gSaveContext.playerForm != PLAYER_FORM_HUMAN) || !(CHECK_QUEST_ITEM(QUEST_SONG_EPONA))) { - func_801518B0(globalCtx, 0x335C, &this->actor); + Message_StartTextbox(globalCtx, 0x335C, &this->actor); this->textId = 0x335C; func_80151BB4(globalCtx, 5); } else { - func_801518B0(globalCtx, 0x3359, &this->actor); + Message_StartTextbox(globalCtx, 0x3359, &this->actor); this->textId = 0x3359; } break; @@ -676,7 +676,7 @@ void EnMa4_BeginHorsebackGame(EnMa4* this, GlobalContext* globalCtx) { void EnMa4_HorsebackGameCheckPlayerInteractions(EnMa4* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { // "You're feeling confident" - func_801518B0(globalCtx, 0x336E, &this->actor); + Message_StartTextbox(globalCtx, 0x336E, &this->actor); this->actionFunc = EnMa4_HorsebackGameTalking; } else if ((gSaveContext.unk_3DE0[4] < 115 * 100)) { // timer < 115 seconds func_800B8614(&this->actor, globalCtx, 100.0f); @@ -749,10 +749,10 @@ void EnMa4_HorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { if (sFrameCounter == 25) { if (this->poppedBalloonCounter == 10) { - func_801518B0(globalCtx, 0x334F, &this->actor); + Message_StartTextbox(globalCtx, 0x334F, &this->actor); this->textId = 0x334F; } else { - func_801518B0(globalCtx, 0x334B, &this->actor); + Message_StartTextbox(globalCtx, 0x334B, &this->actor); this->textId = 0x334B; } } else if (sFrameCounter == 50) { @@ -802,15 +802,15 @@ void EnMa4_SetupEponasSongCs(EnMa4* this) { static u16 D_80AC0260 = 99; void EnMa4_EponasSongCs(EnMa4* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x78) != 0) { - u32 actionIndex = func_800EE200(globalCtx, 0x78); + if (Cutscene_CheckActorAction(globalCtx, 120)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 120); - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[actionIndex]->startFrame) { - if (globalCtx->csCtx.npcActions[actionIndex]->unk0 != D_80AC0260) { - D_80AC0260 = globalCtx->csCtx.npcActions[actionIndex]->unk0; + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + if (globalCtx->csCtx.actorActions[actionIndex]->action != D_80AC0260) { + D_80AC0260 = globalCtx->csCtx.actorActions[actionIndex]->action; this->animTimer = 0; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: this->hasBow = true; EnMa4_ChangeAnim(this, 1); @@ -824,7 +824,7 @@ void EnMa4_EponasSongCs(EnMa4* this, GlobalContext* globalCtx) { } } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); if (D_80AC0260 == 2 && this->animTimer == 0 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { EnMa4_ChangeAnim(this, 7); } @@ -849,7 +849,7 @@ void EnMa4_EndEponasSongCs(EnMa4* this, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_10000; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { player->stateFlags1 &= ~0x20; - func_801518B0(globalCtx, 0x334C, &this->actor); + Message_StartTextbox(globalCtx, 0x334C, &this->actor); this->textId = 0x334C; this->actor.flags &= ~ACTOR_FLAG_10000; EnMa4_SetupDialogueHandler(this); @@ -879,25 +879,25 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { if ((gSaveContext.weekEventReg[21] & 0x80)) { EnMa4_SetFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x3337, &this->actor); + Message_StartTextbox(globalCtx, 0x3337, &this->actor); this->textId = 0x3337; func_80151BB4(globalCtx, 5); } else { - func_801518B0(globalCtx, 0x3335, &this->actor); + Message_StartTextbox(globalCtx, 0x3335, &this->actor); this->textId = 0x3335; gSaveContext.weekEventReg[21] |= 0x80; } } else if (this->state == MA4_STATE_DEFAULT) { if ((gSaveContext.weekEventReg[21] & 0x40)) { if (!(gSaveContext.weekEventReg[21] & 0x20)) { - func_801518B0(globalCtx, 0x3346, &this->actor); + Message_StartTextbox(globalCtx, 0x3346, &this->actor); this->textId = 0x3346; } else { - func_801518B0(globalCtx, 0x3347, &this->actor); + Message_StartTextbox(globalCtx, 0x3347, &this->actor); this->textId = 0x3347; } } else { - func_801518B0(globalCtx, 0x3338, &this->actor); + Message_StartTextbox(globalCtx, 0x3338, &this->actor); this->textId = 0x3338; gSaveContext.weekEventReg[21] |= 0x40; } @@ -905,7 +905,7 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { // "Too bad Grasshopper" EnMa4_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x336D, &this->actor); + Message_StartTextbox(globalCtx, 0x336D, &this->actor); this->textId = 0x336D; } else { time = gSaveContext.unk_3DE0[4]; @@ -913,11 +913,11 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { // [Score] New record! gSaveContext.horseBackBalloonHighScore = time; EnMa4_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x3350, &this->actor); + Message_StartTextbox(globalCtx, 0x3350, &this->actor); this->textId = 0x3350; } else { // [Score] Great. - func_801518B0(globalCtx, 0x3351, &this->actor); + Message_StartTextbox(globalCtx, 0x3351, &this->actor); this->textId = 0x3351; } } @@ -925,7 +925,7 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->state == MA4_STATE_AFTERDESCRIBETHEMCS) { // "Cremia doesn't believe me..." - func_801518B0(globalCtx, 0x3340, &this->actor); + Message_StartTextbox(globalCtx, 0x3340, &this->actor); this->textId = 0x3340; this->actor.flags &= ~ACTOR_FLAG_10000; } @@ -935,31 +935,31 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { if ((gSaveContext.weekEventReg[21] & 0x80)) { EnMa4_SetFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x3337, &this->actor); + Message_StartTextbox(globalCtx, 0x3337, &this->actor); this->textId = 0x3337; func_80151BB4(globalCtx, 5); } else { - func_801518B0(globalCtx, 0x3335, &this->actor); + Message_StartTextbox(globalCtx, 0x3335, &this->actor); this->textId = 0x3335; gSaveContext.weekEventReg[21] |= 0x80; } } else if (this->state == MA4_STATE_DEFAULT) { - func_801518B0(globalCtx, 0x3354, &this->actor); + Message_StartTextbox(globalCtx, 0x3354, &this->actor); this->textId = 0x3354; } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { // "Try again?" - func_801518B0(globalCtx, 0x3356, &this->actor); + Message_StartTextbox(globalCtx, 0x3356, &this->actor); this->textId = 0x3356; } else { time = gSaveContext.unk_3DE0[4]; if ((s32)time < (s32)gSaveContext.horseBackBalloonHighScore) { gSaveContext.horseBackBalloonHighScore = time; EnMa4_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x3350, &this->actor); + Message_StartTextbox(globalCtx, 0x3350, &this->actor); this->textId = 0x3350; } else { - func_801518B0(globalCtx, 0x3351, &this->actor); + Message_StartTextbox(globalCtx, 0x3351, &this->actor); this->textId = 0x3351; } } @@ -971,23 +971,23 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { case MA4_TYPE_ALIENS_WON: if (this->state == MA4_STATE_DEFAULT) { // "Huh... You?" - func_801518B0(globalCtx, 0x3358, &this->actor); + Message_StartTextbox(globalCtx, 0x3358, &this->actor); this->textId = 0x3358; } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { // "Try again?" - func_801518B0(globalCtx, 0x3356, &this->actor); + Message_StartTextbox(globalCtx, 0x3356, &this->actor); this->textId = 0x3356; } else { time = gSaveContext.unk_3DE0[4]; if ((s32)time < (s32)gSaveContext.horseBackBalloonHighScore) { // New record gSaveContext.horseBackBalloonHighScore = time; - func_801518B0(globalCtx, 0x335D, &this->actor); + Message_StartTextbox(globalCtx, 0x335D, &this->actor); this->textId = 0x335D; } else { // "Old record was: [record]" - func_801518B0(globalCtx, 0x335E, &this->actor); + Message_StartTextbox(globalCtx, 0x335E, &this->actor); this->textId = 0x335E; } } @@ -998,7 +998,7 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { default: // Dead code - func_801518B0(globalCtx, 0x3335, &this->actor); + Message_StartTextbox(globalCtx, 0x3335, &this->actor); this->textId = 0x3335; break; } diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c index 7ec514801..9294a6a71 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -448,12 +448,12 @@ void EnMaYto_DefaultHandlePlayerChoice(EnMaYto* this, GlobalContext* globalCtx) func_8019F208(); EnMaYto_SetFaceExpression(this, 0, 3); // "Milk Road is fixed!" - func_801518B0(globalCtx, 0x3392, &this->actor); + Message_StartTextbox(globalCtx, 0x3392, &this->actor); this->textId = 0x3392; } else { // No func_8019F230(); // "Don't lie!" - func_801518B0(globalCtx, 0x3391, &this->actor); + Message_StartTextbox(globalCtx, 0x3391, &this->actor); this->textId = 0x3391; } } @@ -464,26 +464,26 @@ void EnMaYto_DefaultChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) switch (this->textId) { case 0x3391: EnMaYto_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x3392, &this->actor); + Message_StartTextbox(globalCtx, 0x3392, &this->actor); this->textId = 0x3392; break; case 0x3392: EnMaYto_SetFaceExpression(this, 3, 1); - func_801518B0(globalCtx, 0x3393, &this->actor); + Message_StartTextbox(globalCtx, 0x3393, &this->actor); this->textId = 0x3393; func_80151BB4(globalCtx, 6); break; case 0x3394: EnMaYto_ChangeAnim(this, 2); - func_801518B0(globalCtx, 0x3395, &this->actor); + Message_StartTextbox(globalCtx, 0x3395, &this->actor); this->textId = 0x3395; break; case 0x3395: EnMaYto_ChangeAnim(this, 1); - func_801518B0(globalCtx, 0x3396, &this->actor); + Message_StartTextbox(globalCtx, 0x3396, &this->actor); this->textId = 0x3396; func_80151BB4(globalCtx, 6); break; @@ -573,12 +573,12 @@ void EnMaYto_DinnerHandlePlayerChoice(EnMaYto* this, GlobalContext* globalCtx) { func_8019F208(); EnMaYto_SetFaceExpression(this, 0, 3); // "Milk Road is fixed!" - func_801518B0(globalCtx, 0x3399, &this->actor); + Message_StartTextbox(globalCtx, 0x3399, &this->actor); this->textId = 0x3399; } else { // No func_8019F230(); // "Don't lie!" - func_801518B0(globalCtx, 0x3398, &this->actor); + Message_StartTextbox(globalCtx, 0x3398, &this->actor); this->textId = 0x3398; } } @@ -589,20 +589,20 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { switch (this->textId) { case 0x3398: EnMaYto_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x3399, &this->actor); + Message_StartTextbox(globalCtx, 0x3399, &this->actor); this->textId = 0x3399; break; case 0x3399: EnMaYto_SetFaceExpression(this, 3, 1); - func_801518B0(globalCtx, 0x339A, &this->actor); + Message_StartTextbox(globalCtx, 0x339A, &this->actor); this->textId = 0x339A; break; case 0x339A: this->unk31E = 1; EnMaYto_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x339B, &this->actor); + Message_StartTextbox(globalCtx, 0x339B, &this->actor); this->textId = 0x339B; break; @@ -610,7 +610,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); func_80B90E50(this, 0); EnMaYto_SetRomaniFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x339C, &this->actor); + Message_StartTextbox(globalCtx, 0x339C, &this->actor); this->textId = 0x339C; break; @@ -618,7 +618,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { this->unk31E = 1; Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_SetFaceExpression(this, 0, 2); - func_801518B0(globalCtx, 0x339D, &this->actor); + Message_StartTextbox(globalCtx, 0x339D, &this->actor); this->textId = 0x339D; break; @@ -626,7 +626,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { func_80B90E50(this, 1); Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x339E, &this->actor); + Message_StartTextbox(globalCtx, 0x339E, &this->actor); this->textId = 0x339E; func_80151BB4(globalCtx, 6); func_80151BB4(globalCtx, 5); @@ -634,12 +634,12 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x339F: this->unk31E = 0; - func_801518B0(globalCtx, 0x33A0, &this->actor); + Message_StartTextbox(globalCtx, 0x33A0, &this->actor); this->textId = 0x33A0; break; case 0x33A0: - func_801518B0(globalCtx, 0x33A1, &this->actor); + Message_StartTextbox(globalCtx, 0x33A1, &this->actor); this->textId = 0x33A1; break; @@ -647,7 +647,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { func_80B90E50(this, 1); Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 2); - func_801518B0(globalCtx, 0x33A2, &this->actor); + Message_StartTextbox(globalCtx, 0x33A2, &this->actor); this->textId = 0x33A2; break; @@ -655,27 +655,27 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { this->unk31E = 1; Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_SetFaceExpression(this, 4, 3); - func_801518B0(globalCtx, 0x33A3, &this->actor); + Message_StartTextbox(globalCtx, 0x33A3, &this->actor); this->textId = 0x33A3; break; case 0x33A3: this->unk31E = 0; EnMaYto_SetFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x33A4, &this->actor); + Message_StartTextbox(globalCtx, 0x33A4, &this->actor); this->textId = 0x33A4; func_80151BB4(globalCtx, 6); func_80151BB4(globalCtx, 5); break; case 0x33A5: - func_801518B0(globalCtx, 0x33A6, &this->actor); + Message_StartTextbox(globalCtx, 0x33A6, &this->actor); this->textId = 0x33A6; func_80151BB4(globalCtx, 6); break; case 0x33A7: - func_801518B0(globalCtx, 0x33A8, &this->actor); + Message_StartTextbox(globalCtx, 0x33A8, &this->actor); this->textId = 0x33A8; func_80151BB4(globalCtx, 6); break; @@ -762,14 +762,14 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { func_80B90E50(this, 0); Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x33AA, &this->actor); + Message_StartTextbox(globalCtx, 0x33AA, &this->actor); this->textId = 0x33AA; break; case 0x33AA: Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); this->unk31E = 1; - func_801518B0(globalCtx, 0x33AB, &this->actor); + Message_StartTextbox(globalCtx, 0x33AB, &this->actor); this->textId = 0x33AB; break; @@ -777,14 +777,14 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { func_80B90E50(this, 1); Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x33AC, &this->actor); + Message_StartTextbox(globalCtx, 0x33AC, &this->actor); this->textId = 0x33AC; break; case 0x33AC: this->unk31E = 0; Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); - func_801518B0(globalCtx, 0x33AD, &this->actor); + Message_StartTextbox(globalCtx, 0x33AD, &this->actor); this->textId = 0x33AD; func_80151BB4(globalCtx, 6); func_80151BB4(globalCtx, 5); @@ -794,7 +794,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { func_80B90E50(this, 1); Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x33AF, &this->actor); + Message_StartTextbox(globalCtx, 0x33AF, &this->actor); this->textId = 0x33AF; break; @@ -802,7 +802,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { this->unk31E = 1; Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_SetFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x33B0, &this->actor); + Message_StartTextbox(globalCtx, 0x33B0, &this->actor); this->textId = 0x33B0; func_80151BB4(globalCtx, 6); func_80151BB4(globalCtx, 5); @@ -812,7 +812,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { this->unk31E = 2; EnMaYto_SetFaceExpression(this, 5, 3); // "I should had believed what Romani said" - func_801518B0(globalCtx, 0x33B2, &this->actor); + Message_StartTextbox(globalCtx, 0x33B2, &this->actor); this->textId = 0x33B2; func_80151BB4(globalCtx, 6); break; @@ -821,7 +821,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); this->unk31E = 0; EnMaYto_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x33C7, &this->actor); + Message_StartTextbox(globalCtx, 0x33C7, &this->actor); this->textId = 0x33C7; break; @@ -829,7 +829,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); this->unk31E = 1; EnMaYto_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x33C8, &this->actor); + Message_StartTextbox(globalCtx, 0x33C8, &this->actor); this->textId = 0x33C8; break; @@ -837,7 +837,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); func_80B90E50(this, 1); EnMaYto_SetRomaniFaceExpression(this, 0, 2); - func_801518B0(globalCtx, 0x33C9, &this->actor); + Message_StartTextbox(globalCtx, 0x33C9, &this->actor); this->textId = 0x33C9; break; @@ -845,13 +845,13 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); this->unk31E = 1; EnMaYto_SetFaceExpression(this, 3, 1); - func_801518B0(globalCtx, 0x33CA, &this->actor); + Message_StartTextbox(globalCtx, 0x33CA, &this->actor); this->textId = 0x33CA; break; case 0x33CA: this->unk31E = 1; - func_801518B0(globalCtx, 0x33CB, &this->actor); + Message_StartTextbox(globalCtx, 0x33CB, &this->actor); this->textId = 0x33CB; break; @@ -859,7 +859,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); func_80B90E50(this, 1); EnMaYto_SetRomaniFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x33CC, &this->actor); + Message_StartTextbox(globalCtx, 0x33CC, &this->actor); this->textId = 0x33CC; func_80151BB4(globalCtx, 6); func_80151BB4(globalCtx, 5); @@ -888,12 +888,12 @@ void EnMaYto_AfterMilkRunInit(EnMaYto* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_10000; if (gSaveContext.weekEventReg[52] & 1) { // if (ProtectedCremia) - func_801518B0(globalCtx, 0x33C1, &this->actor); + Message_StartTextbox(globalCtx, 0x33C1, &this->actor); this->textId = 0x33C1; } else { // Fails milk minigame EnMaYto_SetFaceExpression(this, 5, 2); - func_801518B0(globalCtx, 0x33C0, &this->actor); + Message_StartTextbox(globalCtx, 0x33C0, &this->actor); this->textId = 0x33C0; // Attempted Cremia Cart Ride gSaveContext.weekEventReg[14] |= 1; @@ -937,7 +937,7 @@ void EnMaYto_AfterMilkRunChooseNextDialogue(EnMaYto* this, GlobalContext* global case 0x33C1: EnMaYto_SetFaceExpression(this, 3, 1); // "Thank you. You were cool back there." - func_801518B0(globalCtx, 0x33C2, &this->actor); + Message_StartTextbox(globalCtx, 0x33C2, &this->actor); this->textId = 0x33C2; break; @@ -975,7 +975,7 @@ void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx) { if (this->unk310 == 1) { // Romani's mask explanation EnMaYto_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x33C3, &this->actor); + Message_StartTextbox(globalCtx, 0x33C3, &this->actor); this->textId = 0x33C3; // Attempted Cremia Cart Ride gSaveContext.weekEventReg[14] |= 1; @@ -987,7 +987,7 @@ void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx) { } else { // You already have the mask EnMaYto_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x33D0, &this->actor); + Message_StartTextbox(globalCtx, 0x33D0, &this->actor); this->textId = 0x33D0; // Attempted Cremia Cart Ride gSaveContext.weekEventReg[14] |= 1; @@ -1024,11 +1024,11 @@ void EnMaYto_SetupWarmFuzzyFeelingCs(EnMaYto* this) { static u16 D_80B915F0 = 99; void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x22C) != 0) { - u32 csActionIndex = func_800EE200(globalCtx, 0x22C); + if (Cutscene_CheckActorAction(globalCtx, 556)) { + s32 csActionIndex = Cutscene_GetActorActionIndex(globalCtx, 556); - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[csActionIndex]->startFrame) { - u16 action = globalCtx->csCtx.npcActions[csActionIndex]->unk0; + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[csActionIndex]->startFrame) { + u16 action = globalCtx->csCtx.actorActions[csActionIndex]->action; if (1) {} @@ -1052,7 +1052,7 @@ void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx) { } } - func_800EDF24(&this->actor, globalCtx, csActionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, csActionIndex); if (D_80B915F0 == 2 && this->skelAnime.animation == &object_ma2_Anim_001FD0 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { EnMaYto_ChangeAnim(this, 20); @@ -1102,53 +1102,53 @@ void EnMaYto_DefaultStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE && gSaveContext.playerForm == PLAYER_FORM_HUMAN) { switch (Player_GetMask(globalCtx)) { case PLAYER_MASK_ROMANI: - func_801518B0(globalCtx, 0x235D, &this->actor); + Message_StartTextbox(globalCtx, 0x235D, &this->actor); this->textId = 0x235D; break; case PLAYER_MASK_CIRCUS_LEADER: EnMaYto_SetFaceExpression(this, 1, 3); - func_801518B0(globalCtx, 0x235E, &this->actor); + Message_StartTextbox(globalCtx, 0x235E, &this->actor); this->textId = 0x235E; break; case PLAYER_MASK_KAFEIS_MASK: EnMaYto_SetFaceExpression(this, 1, 2); - func_801518B0(globalCtx, 0x235F, &this->actor); + Message_StartTextbox(globalCtx, 0x235F, &this->actor); this->textId = 0x235F; break; case PLAYER_MASK_COUPLE: - func_801518B0(globalCtx, 0x2360, &this->actor); + Message_StartTextbox(globalCtx, 0x2360, &this->actor); this->textId = 0x2360; break; default: - func_801518B0(globalCtx, 0x2361, &this->actor); + Message_StartTextbox(globalCtx, 0x2361, &this->actor); this->textId = 0x2361; break; } } else { if (EnMaYto_HasSpokeToPlayer()) { - func_801518B0(globalCtx, 0x3394, &this->actor); + Message_StartTextbox(globalCtx, 0x3394, &this->actor); this->textId = 0x3394; } else { EnMaYto_SetTalkedFlag(); // Asks the player if he came from town. - func_801518B0(globalCtx, 0x3390, &this->actor); + Message_StartTextbox(globalCtx, 0x3390, &this->actor); this->textId = 0x3390; } } } else if (CURRENT_DAY == 3) { if (EnMaYto_HasSpokeToPlayerToday()) { EnMaYto_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x33C5, &this->actor); + Message_StartTextbox(globalCtx, 0x33C5, &this->actor); this->textId = 0x33C5; func_80151BB4(globalCtx, 6); } else { EnMaYto_SetTalkedFlag(); EnMaYto_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x33C4, &this->actor); + Message_StartTextbox(globalCtx, 0x33C4, &this->actor); this->textId = 0x33C4; func_80151BB4(globalCtx, 6); } @@ -1161,37 +1161,37 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE && gSaveContext.playerForm == PLAYER_FORM_HUMAN) { switch (Player_GetMask(globalCtx)) { case PLAYER_MASK_ROMANI: - func_801518B0(globalCtx, 0x235D, &this->actor); + Message_StartTextbox(globalCtx, 0x235D, &this->actor); this->textId = 0x235D; break; case PLAYER_MASK_CIRCUS_LEADER: - func_801518B0(globalCtx, 0x235E, &this->actor); + Message_StartTextbox(globalCtx, 0x235E, &this->actor); this->textId = 0x235E; break; case PLAYER_MASK_KAFEIS_MASK: - func_801518B0(globalCtx, 0x235F, &this->actor); + Message_StartTextbox(globalCtx, 0x235F, &this->actor); this->textId = 0x235F; break; case PLAYER_MASK_COUPLE: - func_801518B0(globalCtx, 0x2360, &this->actor); + Message_StartTextbox(globalCtx, 0x2360, &this->actor); this->textId = 0x2360; break; default: - func_801518B0(globalCtx, 0x2361, &this->actor); + Message_StartTextbox(globalCtx, 0x2361, &this->actor); this->textId = 0x2361; break; } } else { if (EnMaYto_HasSpokeToPlayer()) { - func_801518B0(globalCtx, 0x339F, &this->actor); + Message_StartTextbox(globalCtx, 0x339F, &this->actor); this->textId = 0x339F; } else { EnMaYto_SetTalkedFlag(); - func_801518B0(globalCtx, 0x3397, &this->actor); + Message_StartTextbox(globalCtx, 0x3397, &this->actor); this->textId = 0x3397; } } @@ -1199,24 +1199,24 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 2: if (EnMaYto_HasSpokeToPlayer()) { - func_801518B0(globalCtx, 0x33A6, &this->actor); + Message_StartTextbox(globalCtx, 0x33A6, &this->actor); this->textId = 0x33A6; func_80151BB4(globalCtx, 6); } else { EnMaYto_SetTalkedFlag(); - func_801518B0(globalCtx, 0x33A5, &this->actor); + Message_StartTextbox(globalCtx, 0x33A5, &this->actor); this->textId = 0x33A5; } break; case 3: if (EnMaYto_HasSpokeToPlayer()) { - func_801518B0(globalCtx, 0x33A8, &this->actor); + Message_StartTextbox(globalCtx, 0x33A8, &this->actor); this->textId = 0x33A8; func_80151BB4(globalCtx, 6); } else { EnMaYto_SetTalkedFlag(); - func_801518B0(globalCtx, 0x33A7, &this->actor); + Message_StartTextbox(globalCtx, 0x33A7, &this->actor); this->textId = 0x33A7; } break; @@ -1228,23 +1228,23 @@ void EnMaYto_BarnStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { if (gSaveContext.weekEventReg[22] & 1) { if (CURRENT_DAY == 2) { if (this->unk310 == 1) { - func_801518B0(globalCtx, 0x33AE, &this->actor); + Message_StartTextbox(globalCtx, 0x33AE, &this->actor); this->textId = 0x33AE; } else { this->unk310 = 1; EnMaYto_SetTalkedFlag(); - func_801518B0(globalCtx, 0x33A9, &this->actor); + Message_StartTextbox(globalCtx, 0x33A9, &this->actor); this->textId = 0x33A9; } } else if (CURRENT_DAY == 3) { if (this->unk310 == 1) { - func_801518B0(globalCtx, 0x33CB, &this->actor); + Message_StartTextbox(globalCtx, 0x33CB, &this->actor); this->textId = 0x33CB; } else { this->unk310 = 1; EnMaYto_SetTalkedFlag(); EnMaYto_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x33C6, &this->actor); + Message_StartTextbox(globalCtx, 0x33C6, &this->actor); this->textId = 0x33C6; } } @@ -1252,13 +1252,13 @@ void EnMaYto_BarnStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { if (EnMaYto_HasSpokeToPlayer()) { this->unk31E = 2; EnMaYto_SetFaceExpression(this, 5, 3); - func_801518B0(globalCtx, 0x33B3, &this->actor); + Message_StartTextbox(globalCtx, 0x33B3, &this->actor); this->textId = 0x33B3; func_80151BB4(globalCtx, 6); } else { EnMaYto_SetTalkedFlag(); EnMaYto_SetFaceExpression(this, 5, 3); - func_801518B0(globalCtx, 0x33B1, &this->actor); + Message_StartTextbox(globalCtx, 0x33B1, &this->actor); this->textId = 0x33B1; } } diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c index 1dd02ecc9..bb88e4435 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c @@ -302,12 +302,12 @@ void EnMaYts_StartDialogue(EnMaYts* this, GlobalContext* globalCtx) { // Saying to non-human Link: "Cremia went to town." gSaveContext.weekEventReg[65] |= 0x80; EnMaYts_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x335F, &this->actor); + Message_StartTextbox(globalCtx, 0x335F, &this->actor); this->textId = 0x335F; } else { // Saying to non-human Link: "Pretend you did not hear that." EnMaYts_SetFaceExpression(this, 4, 3); - func_801518B0(globalCtx, 0x3362, &this->actor); + Message_StartTextbox(globalCtx, 0x3362, &this->actor); this->textId = 0x3362; func_80151BB4(globalCtx, 5); } @@ -315,29 +315,29 @@ void EnMaYts_StartDialogue(EnMaYts* this, GlobalContext* globalCtx) { if (!(gSaveContext.weekEventReg[65] & 0x40)) { gSaveContext.weekEventReg[65] |= 0x40; EnMaYts_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x3363, &this->actor); + Message_StartTextbox(globalCtx, 0x3363, &this->actor); this->textId = 0x3363; } else { EnMaYts_SetFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x3366, &this->actor); + Message_StartTextbox(globalCtx, 0x3366, &this->actor); this->textId = 0x3366; func_80151BB4(globalCtx, 5); } } else if (!(gSaveContext.weekEventReg[21] & 0x20)) { EnMaYts_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x3367, &this->actor); + Message_StartTextbox(globalCtx, 0x3367, &this->actor); this->textId = 0x3367; } else { if (!(gSaveContext.weekEventReg[65] & 0x20)) { // Saying to Grasshopper: "Cremia went to town." gSaveContext.weekEventReg[65] |= 0x20; EnMaYts_SetFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x3369, &this->actor); + Message_StartTextbox(globalCtx, 0x3369, &this->actor); this->textId = 0x3369; } else { // Saying to Grasshopper: "You're our bodyguard." EnMaYts_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x336C, &this->actor); + Message_StartTextbox(globalCtx, 0x336C, &this->actor); this->textId = 0x336C; func_80151BB4(globalCtx, 5); } @@ -381,14 +381,14 @@ void EnMaYts_SetupEndCreditsHandler(EnMaYts* this) { static u16 D_80B8E32C = 99; void EnMaYts_EndCreditsHandler(EnMaYts* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x78) != 0) { - u32 actionIndex = func_800EE200(globalCtx, 0x78); + if (Cutscene_CheckActorAction(globalCtx, 120)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 120); - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[actionIndex]->startFrame) { - if (globalCtx->csCtx.npcActions[actionIndex]->unk0 != D_80B8E32C) { - D_80B8E32C = globalCtx->csCtx.npcActions[actionIndex]->unk0; + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + if (globalCtx->csCtx.actorActions[actionIndex]->action != D_80B8E32C) { + D_80B8E32C = globalCtx->csCtx.actorActions[actionIndex]->action; this->endCreditsFlag = 0; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: this->hasBow = true; EnMaYts_ChangeAnim(this, 0); @@ -412,9 +412,9 @@ void EnMaYts_EndCreditsHandler(EnMaYts* this, GlobalContext* globalCtx) { } } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); if ((D_80B8E32C == 2) && (this->endCreditsFlag == 0) && - (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) != 0)) { + Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->endCreditsFlag++; EnMaYts_ChangeAnim(this, 5); } @@ -430,46 +430,46 @@ void EnMaYts_ChooseNextDialogue(EnMaYts* this, GlobalContext* globalCtx) { switch (this->textId) { case 0x335F: EnMaYts_SetFaceExpression(this, 0, 2); - func_801518B0(globalCtx, 0x3360, &this->actor); + Message_StartTextbox(globalCtx, 0x3360, &this->actor); this->textId = 0x3360; break; case 0x3360: EnMaYts_SetFaceExpression(this, 4, 3); - func_801518B0(globalCtx, 0x3361, &this->actor); + Message_StartTextbox(globalCtx, 0x3361, &this->actor); this->textId = 0x3361; func_80151BB4(globalCtx, 5); break; case 0x3363: EnMaYts_SetFaceExpression(this, 1, 1); - func_801518B0(globalCtx, 0x3364, &this->actor); + Message_StartTextbox(globalCtx, 0x3364, &this->actor); this->textId = 0x3364; break; case 0x3364: EnMaYts_SetFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x3365, &this->actor); + Message_StartTextbox(globalCtx, 0x3365, &this->actor); this->textId = 0x3365; func_80151BB4(globalCtx, 5); break; case 0x3367: EnMaYts_SetFaceExpression(this, 4, 3); - func_801518B0(globalCtx, 0x3368, &this->actor); + Message_StartTextbox(globalCtx, 0x3368, &this->actor); this->textId = 0x3368; func_80151BB4(globalCtx, 5); break; case 0x3369: EnMaYts_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x336A, &this->actor); + Message_StartTextbox(globalCtx, 0x336A, &this->actor); this->textId = 0x336A; break; case 0x336A: EnMaYts_SetFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x336B, &this->actor); + Message_StartTextbox(globalCtx, 0x336B, &this->actor); this->textId = 0x336B; func_80151BB4(globalCtx, 5); break; diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c index 81687965c..9e6b3e9e9 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -382,7 +382,7 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B)) { if (globalCtx->sceneLoadFlag != 0x14) { - func_801A3F54(false); + Audio_SetCutsceneFlag(false); D_801BB12C++; if (D_801BB12C >= 2) { D_801BB12C = 0; diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index 227c4316d..806ffe71a 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -471,7 +471,7 @@ void EnMinifrog_EndChoir(EnMinifrog* this, GlobalContext* globalCtx) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0xD7E, &this->actor); // "Let us do it again sometime." + Message_StartTextbox(globalCtx, 0xD7E, &this->actor); // "Let us do it again sometime." this->actionFunc = EnMinifrog_YellowFrogDialog; } else { func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); @@ -565,11 +565,11 @@ void EnMinifrog_SetupYellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = EnMinifrog_YellowFrogDialog; if (!(gSaveContext.weekEventReg[34] & 1)) { // Not spoken with MINIFROG_YELLOW - func_801518B0(globalCtx, 0xD76, - &this->actor); // "I have been waiting for you, Don Gero. Forgive me if I'm mistaken, but it - // looks like you've lost a little weight..." + Message_StartTextbox(globalCtx, 0xD76, + &this->actor); // "I have been waiting for you, Don Gero. Forgive me if I'm mistaken, + // but it looks like you've lost a little weight..." } else { - func_801518B0(globalCtx, 0xD7F, &this->actor); // "Well, if it isn't the great Don Gero." + Message_StartTextbox(globalCtx, 0xD7F, &this->actor); // "Well, if it isn't the great Don Gero." } } else if ((this->actor.xzDistToPlayer < 150.0f) && (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) || diff --git a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c index 078edb840..718f384f3 100644 --- a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c +++ b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c @@ -64,7 +64,7 @@ void EnMm2_Reading(EnMm2* this, GlobalContext* globalCtx) { */ void EnMm2_WaitForRead(EnMm2* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x277B, &this->actor); + Message_StartTextbox(globalCtx, 0x277B, &this->actor); this->actionFunc = EnMm2_Reading; } else if ((this->actor.xzDistToPlayer < 60.0f) && (Player_IsFacingActor(&this->actor, 0x3000, globalCtx))) { func_800B8614(&this->actor, globalCtx, 110.0f); diff --git a/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c b/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c index af0722d91..1400e3c06 100644 --- a/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c +++ b/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c @@ -77,7 +77,7 @@ void func_80C08828(EnNnh* this) { void func_80C0883C(EnNnh* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x228U, &this->actor); + Message_StartTextbox(globalCtx, 0x228U, &this->actor); func_80C088A4(this); return; } diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.c b/src/overlays/actors/ovl_En_Osn/z_en_osn.c index fd0e8b6bc..620d4450a 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -574,7 +574,7 @@ void func_80AD10FC(EnOsn* this, GlobalContext* globalCtx) { this->unk_1EA |= 0x20; } - func_801518B0(globalCtx, this->unk_1F4, &this->actor); + Message_StartTextbox(globalCtx, this->unk_1F4, &this->actor); } void func_80AD1398(EnOsn* this) { @@ -615,7 +615,7 @@ void func_80AD14C8(EnOsn* this, GlobalContext* globalCtx) { } else { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_1F4 = func_80AD0E10(this, globalCtx); - func_801518B0(globalCtx, this->unk_1F4, &this->actor); + Message_StartTextbox(globalCtx, this->unk_1F4, &this->actor); this->actionFunc = func_80AD19A0; } else if ((((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && (temp_v1 < 0x4000)) && (temp_v1 > -0x4000)) { @@ -638,14 +638,14 @@ void func_80AD1634(EnOsn* this, GlobalContext* globalCtx) { void func_80AD16A8(EnOsn* this, GlobalContext* globalCtx) { u8 pad; - u32 temp_v0; + s32 actionIndex; - if (func_800EE29C(globalCtx, 0x82)) { - temp_v0 = func_800EE200(globalCtx, 0x82); + if (Cutscene_CheckActorAction(globalCtx, 130)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 130); this->unk_1F0 = 0; - if (this->unk_1ED != globalCtx->csCtx.npcActions[temp_v0]->unk0) { - this->unk_1ED = globalCtx->csCtx.npcActions[temp_v0]->unk0; - switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + if (this->unk_1ED != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->unk_1ED = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: this->unk_1EC = 2; break; @@ -735,7 +735,7 @@ void func_80AD16A8(EnOsn* this, GlobalContext* globalCtx) { (Animation_OnFrame(&this->skelAnime, 57.0f)) || (Animation_OnFrame(&this->skelAnime, 67.0f)))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OMENYA_WALK); } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); } else { this->unk_1F0 = 1; this->unk_1ED = 0x63; diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index e3942aaf3..7e3276263 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -383,7 +383,7 @@ void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx) { case 10: this->animationIdx++; SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, this->animationIdx); - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, false); break; case 5: @@ -408,7 +408,7 @@ void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx) { } else { EnOssan_SetHaveMet(this); this->textId = EnOssan_GetWelcomePartTimeWorker(this, globalCtx); - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, false); } } @@ -1091,7 +1091,7 @@ void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { func_8019F208(); player->actor.shape.rot.y = BINANG_ROT180(player->actor.shape.rot.y); player->stateFlags2 |= 0x20000000; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, true); func_800B85E0(&this->actor, globalCtx, 100.0f, EXCH_ITEM_MINUS1); break; @@ -1109,7 +1109,7 @@ void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { item->restockFunc(globalCtx, item); player->actor.shape.rot.y = BINANG_ROT180(player->actor.shape.rot.y); player->stateFlags2 |= 0x20000000; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, true); func_800B85E0(&this->actor, globalCtx, 100.0f, EXCH_ITEM_MINUS1); } diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index b210e76cd..f7f41a2c1 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -651,7 +651,7 @@ void func_80B5CD40(EnOt* this, GlobalContext* globalCtx) { if (1) {} if (!temp) { gSaveContext.weekEventReg[23] |= 0x10; - func_801518B0(globalCtx, 0x1069, NULL); + Message_StartTextbox(globalCtx, 0x1069, NULL); } break; @@ -765,12 +765,12 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { } else { phi_a1 = 0x10A5; } - func_801518B0(globalCtx, phi_a1, &this->actor); + Message_StartTextbox(globalCtx, phi_a1, &this->actor); func_80B5D114(this, globalCtx); break; case 1: - func_801518B0(globalCtx, 0x106D, &this->actor); + Message_StartTextbox(globalCtx, 0x106D, &this->actor); func_80B5D114(this, globalCtx); break; } diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index 4b15bde77..467ef3901 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -599,21 +599,21 @@ void func_80BD994C(EnPamera* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { if (1) {} func_80BD93CC(this, 0, 1); - func_801518B0(globalCtx, 0x15A8, &this->actor); + Message_StartTextbox(globalCtx, 0x15A8, &this->actor); this->unk_324 = 0x15A8; } else if ((gSaveContext.playerForm != PLAYER_FORM_HUMAN) || ((gSaveContext.weekEventReg[52] & 0x20) && (!(gSaveContext.weekEventReg[75] & 0x20)))) { func_80BD93CC(this, 1, 0); - func_801518B0(globalCtx, 0x158E, &this->actor); + Message_StartTextbox(globalCtx, 0x158E, &this->actor); this->unk_324 = 0x158E; } else { if (!(this->unk_322 & 1)) { this->unk_322 |= 1; - func_801518B0(globalCtx, 0x1587, &this->actor); + Message_StartTextbox(globalCtx, 0x1587, &this->actor); this->unk_324 = 0x1587; } else { - func_801518B0(globalCtx, 0x158C, &this->actor); + Message_StartTextbox(globalCtx, 0x158C, &this->actor); this->unk_324 = 0x158C; } } @@ -654,23 +654,23 @@ void func_80BD9B4C(EnPamera* this, GlobalContext* globalCtx) { if (func_80147624(globalCtx)) { switch (this->unk_324) { case 0x1587: - func_801518B0(globalCtx, 0x1588, &this->actor); + Message_StartTextbox(globalCtx, 0x1588, &this->actor); this->unk_324 = 0x1588; break; case 0x1588: - func_801518B0(globalCtx, 0x1589, &this->actor); + Message_StartTextbox(globalCtx, 0x1589, &this->actor); this->unk_324 = 0x1589; break; case 0x1589: - func_801518B0(globalCtx, 0x158A, &this->actor); + Message_StartTextbox(globalCtx, 0x158A, &this->actor); this->unk_324 = 0x158A; break; case 0x158A: - func_801518B0(globalCtx, 0x158B, &this->actor); + Message_StartTextbox(globalCtx, 0x158B, &this->actor); this->unk_324 = 0x158B; break; case 0x158C: - func_801518B0(globalCtx, 0x158D, &this->actor); + Message_StartTextbox(globalCtx, 0x158D, &this->actor); this->unk_324 = 0x158D; break; case 0x158E: @@ -690,14 +690,14 @@ void func_80BD9C70(EnPamera* this, GlobalContext* globalCtx) { } s32 func_80BD9CB8(EnPamera* this, GlobalContext* globalCtx) { - u32 actionIndex; + s32 actionIndex; - if (func_800EE29C(globalCtx, 0x1E5)) { - actionIndex = func_800EE200(globalCtx, 0x1E5); - if (this->unk_326 != globalCtx->csCtx.npcActions[actionIndex]->unk0) { - this->unk_326 = globalCtx->csCtx.npcActions[actionIndex]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 0x1E5)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 0x1E5); + if (this->unk_326 != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->unk_326 = globalCtx->csCtx.actorActions[actionIndex]->action; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: func_80BD9E88(this); break; @@ -722,7 +722,7 @@ s32 func_80BD9CB8(EnPamera* this, GlobalContext* globalCtx) { break; } } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); this->setupFunc(this, globalCtx); return 1; } diff --git a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c index ce4d00838..b2850d7d1 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c @@ -296,7 +296,8 @@ void EnRailSkb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_3F8 = 0; } - if ((globalCtx->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.unk_12 == 0)) { + if ((globalCtx->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && + (globalCtx->csCtx.currentCsIndex == 0)) { this->actor.flags |= ACTOR_FLAG_100000; } @@ -489,11 +490,11 @@ void func_80B716A8(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_3FE = 1; func_80B71D8C(this, globalCtx, func_80B723F8); if (!func_80B7285C(this)) { - func_801518B0(globalCtx, 0x13EC, &this->actor); + Message_StartTextbox(globalCtx, 0x13EC, &this->actor); this->unk_400 = 0x13EC; func_80B72830(this, 1); } else { - func_801518B0(globalCtx, 0x13F5, &this->actor); + Message_StartTextbox(globalCtx, 0x13F5, &this->actor); this->unk_400 = 0x13F5; } Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); @@ -702,34 +703,34 @@ void func_80B71F3C(EnRailSkb* this, GlobalContext* globalCtx) { if (func_80147624(globalCtx)) { switch (this->unk_400) { case 0x13EC: - func_801518B0(globalCtx, 0x13ED, &this->actor); + Message_StartTextbox(globalCtx, 0x13ED, &this->actor); this->unk_400 = 0x13ED; break; case 0x13ED: - func_801518B0(globalCtx, 0x13EE, &this->actor); + Message_StartTextbox(globalCtx, 0x13EE, &this->actor); this->unk_400 = 0x13EE; break; case 0x13EE: - func_801518B0(globalCtx, 0x13EF, &this->actor); + Message_StartTextbox(globalCtx, 0x13EF, &this->actor); this->unk_400 = 0x13EF; break; case 0x13EF: case 0x13F5: - func_801518B0(globalCtx, 0x13F0, &this->actor); + Message_StartTextbox(globalCtx, 0x13F0, &this->actor); this->unk_400 = 0x13F0; break; case 0x13F1: - func_801518B0(globalCtx, 0x13F2, &this->actor); + Message_StartTextbox(globalCtx, 0x13F2, &this->actor); this->unk_400 = 0x13F2; break; case 0x13F2: if (this->unk_3FC == 1) { - func_801518B0(globalCtx, 0x13F4, &this->actor); + Message_StartTextbox(globalCtx, 0x13F4, &this->actor); this->unk_400 = 0x13F4; } else { func_801477B4(globalCtx); @@ -738,7 +739,7 @@ void func_80B71F3C(EnRailSkb* this, GlobalContext* globalCtx) { break; case 0x13F3: - func_801518B0(globalCtx, 0x13F2, &this->actor); + Message_StartTextbox(globalCtx, 0x13F2, &this->actor); this->unk_400 = 0x13F2; this->unk_3FC = 1; break; @@ -755,11 +756,11 @@ void func_80B72100(EnRailSkb* this, GlobalContext* globalCtx) { if (func_80147624(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - func_801518B0(globalCtx, 0x13F1, &this->actor); + Message_StartTextbox(globalCtx, 0x13F1, &this->actor); this->unk_400 = 0x13F1; } else { func_8019F208(); - func_801518B0(globalCtx, 0x13F3, &this->actor); + Message_StartTextbox(globalCtx, 0x13F3, &this->actor); this->unk_400 = 0x13F3; } } 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 b26650690..39232befa 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -956,7 +956,7 @@ void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, GlobalContext* global if ((this->textId == 0) && (this->type == EN_RAILGIBUD_TYPE_GIBDO)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->isInvincible = true; - func_801518B0(globalCtx, 0x13B2, &this->actor); + Message_StartTextbox(globalCtx, 0x13B2, &this->actor); this->textId = 0x13B2; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); this->actor.speedXZ = 0.0f; @@ -968,7 +968,7 @@ void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, GlobalContext* global switch (Message_GetState(&globalCtx->msgCtx)) { case 5: if (func_80147624(globalCtx)) { - func_801518B0(globalCtx, 0x13B3, &this->actor); + Message_StartTextbox(globalCtx, 0x13B3, &this->actor); this->textId = 0x13B3; } break; @@ -1123,27 +1123,27 @@ void EnRailgibud_InitCutsceneGibdo(EnRailgibud* this, GlobalContext* globalCtx) void EnRailgibud_InitActorActionCommand(EnRailgibud* this) { switch (ENRAILGIBUD_GET_CUTSCENE_TYPE(&this->actor)) { case 1: - this->actorActionCommand = 0x207; + this->actorActionCommand = 519; break; case 2: - this->actorActionCommand = 0x208; + this->actorActionCommand = 520; break; case 3: - this->actorActionCommand = 0x209; + this->actorActionCommand = 521; break; case 4: - this->actorActionCommand = 0x20A; + this->actorActionCommand = 522; break; case 5: - this->actorActionCommand = 0x20B; + this->actorActionCommand = 523; break; default: - this->actorActionCommand = 0x207; + this->actorActionCommand = 519; break; } } @@ -1171,13 +1171,13 @@ void EnRailgibud_SinkIntoGround(EnRailgibud* this, GlobalContext* globalCtx) { } s32 EnRailgibud_PerformCutsceneActions(EnRailgibud* this, GlobalContext* globalCtx) { - u32 actionIndex; + s32 actionIndex; - if (func_800EE29C(globalCtx, this->actorActionCommand)) { - actionIndex = func_800EE200(globalCtx, this->actorActionCommand); - if (this->csAction != globalCtx->csCtx.npcActions[actionIndex]->unk0) { - this->csAction = globalCtx->csCtx.npcActions[actionIndex]->unk0; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCommand)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand); + if (this->csAction != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->csAction = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_IDLE; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_IDLE); @@ -1236,7 +1236,7 @@ s32 EnRailgibud_PerformCutsceneActions(EnRailgibud* this, GlobalContext* globalC break; } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); return true; } diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.c b/src/overlays/actors/ovl_En_Rr/z_en_rr.c index 75e958458..71d08787e 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -313,7 +313,7 @@ void func_808FA4F4(EnRr* this, GlobalContext* globalCtx) { } if (sp34 && (Message_GetState(&globalCtx->msgCtx) == 0)) { - func_801518B0(globalCtx, 0xF6, NULL); + Message_StartTextbox(globalCtx, 0xF6, NULL); } if (this->actor.params == ENRR_0) { diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c index eecf3c8ff..0eabcd80f 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -297,7 +297,7 @@ void func_80BCB52C(EnScopenuts* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_33C = func_80BCAF0C(this); - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); this->actionFunc = func_80BCB6D0; } else if (((this->actor.xzDistToPlayer < 100.0f) && (((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false)) || @@ -327,7 +327,7 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80BCBA00; } else { this->unk_33C = func_80BCAF0C(this); - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } } } else if (temp_v0 == 4) { @@ -338,7 +338,7 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_ERROR); this->unk_33C = 0x1636; this->unk_328 |= 1; - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } else { func_8019F208(); globalCtx->msgCtx.msgMode = 0x43; @@ -355,7 +355,7 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { this->unk_33C = 0x1635; this->unk_328 |= 1; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); break; } } @@ -379,7 +379,7 @@ void func_80BCB980(EnScopenuts* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_33C = 0x1637; this->unk_328 |= 1; - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); this->actionFunc = func_80BCB6D0; } else { func_800B85E0(&this->actor, globalCtx, 400.0f, -1); diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c index 1aaedc075..6b299ae9a 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -350,27 +350,27 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { case 0x60E: gSaveContext.weekEventReg[17] |= 0x20; gSaveContext.weekEventReg[86] |= 4; - func_801518B0(globalCtx, this->unk_340, &this->actor); + Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; case 0x628: gSaveContext.weekEventReg[77] |= 0x40; gSaveContext.weekEventReg[86] |= 4; - func_801518B0(globalCtx, this->unk_340, &this->actor); + Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; case 0x614: gSaveContext.weekEventReg[17] |= 0x40; - func_801518B0(globalCtx, this->unk_340, &this->actor); + Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; case 0x610: case 0x616: case 0x629: - func_801518B0(globalCtx, this->unk_340, &this->actor); + Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; @@ -488,7 +488,7 @@ void func_80ADBBEC(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADBC60(EnSellnuts* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, this->unk_340, &this->actor); + Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; } else { func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); @@ -699,7 +699,7 @@ void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { player->linearVelocity = 0.0f; this->actor.flags &= ~ACTOR_FLAG_10000; - func_801518B0(globalCtx, this->unk_340, &this->actor); + Message_StartTextbox(globalCtx, this->unk_340, &this->actor); if (this->unk_340 == 0x625) { this->unk_338 |= 1; this->actor.draw = EnSellnuts_Draw; diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index 126bf8e3f..166f0377e 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -230,7 +230,8 @@ void EnSkb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_3D6 = ENSKB_GET_F0(&this->actor); this->actor.floorHeight = this->actor.world.pos.y; - if ((globalCtx->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.unk_12 == 0)) { + if ((globalCtx->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && + (globalCtx->csCtx.currentCsIndex == 0)) { this->actor.flags |= ACTOR_FLAG_100000; } @@ -319,9 +320,9 @@ void func_80994F7C(EnSkb* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_3E2 = 1; if (this->unk_3E0 == 1) { - func_801518B0(globalCtx, 0x13F8, &this->actor); + Message_StartTextbox(globalCtx, 0x13F8, &this->actor); } else { - func_801518B0(globalCtx, 0x13F6, &this->actor); + Message_StartTextbox(globalCtx, 0x13F6, &this->actor); this->unk_3E0 = 1; } this->actionFunc = func_80995190; @@ -340,12 +341,12 @@ void func_80995068(EnSkb* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_3E2 = 1; if (this->unk_3E0 == 1) { - func_801518B0(globalCtx, 0x13F8, &this->actor); + Message_StartTextbox(globalCtx, 0x13F8, &this->actor); if (this->unk_3DE == 2) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); } } else { - func_801518B0(globalCtx, 0x13F6, &this->actor); + Message_StartTextbox(globalCtx, 0x13F6, &this->actor); this->unk_3E0 = 1; } this->actionFunc = func_80995190; @@ -372,7 +373,7 @@ void func_80995190(EnSkb* this, GlobalContext* globalCtx) { case 5: if (func_80147624(globalCtx)) { - func_801518B0(globalCtx, 0x13F7, &this->actor); + Message_StartTextbox(globalCtx, 0x13F7, &this->actor); if (this->unk_3DE == 2) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); } diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index 3e237b51c..c05c589be 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -334,7 +334,7 @@ void EnSob1_EndInteractionBombShop(EnSob1* this, GlobalContext* globalCtx) { this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; this->goodbyeTextId = EnSob1_GetGoodbye(this); - func_801518B0(globalCtx, this->goodbyeTextId, &this->actor); + Message_StartTextbox(globalCtx, this->goodbyeTextId, &this->actor); EnSob1_SetupAction(this, EnSob1_EndingInteraction); } @@ -531,7 +531,7 @@ void EnSob1_Idle(EnSob1* this, GlobalContext* globalCtx) { } player->stateFlags2 |= 0x20000000; this->welcomeTextId = EnSob1_GetWelcome(this, globalCtx); - func_801518B0(globalCtx, this->welcomeTextId, &this->actor); + Message_StartTextbox(globalCtx, this->welcomeTextId, &this->actor); if (ENSOB1_GET_SHOPTYPE(&this->actor) == BOMB_SHOP) { this->headRotTarget = -0x2000; } @@ -789,7 +789,7 @@ void EnSob1_Walking(EnSob1* this, GlobalContext* globalCtx) { } player->stateFlags2 |= 0x20000000; this->welcomeTextId = EnSob1_GetWelcome(this, globalCtx); - func_801518B0(globalCtx, this->welcomeTextId, &this->actor); + Message_StartTextbox(globalCtx, this->welcomeTextId, &this->actor); this->wasTalkedToWhileWalking = true; } else { if ((player->actor.world.pos.x >= this->posXZRange.xMin && @@ -1091,7 +1091,7 @@ void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx) { item->restockFunc(globalCtx, item); player->actor.shape.rot.y += 0x8000; player->stateFlags2 |= 0x20000000; - func_801518B0(globalCtx, this->welcomeTextId, &this->actor); + Message_StartTextbox(globalCtx, this->welcomeTextId, &this->actor); EnSob1_SetupStartShopping(globalCtx, this, true); func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); } 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 5508fa646..fbd391f32 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -713,7 +713,7 @@ void func_809756D0(EnSsh* this, GlobalContext* globalCtx) { phi_a1 = 0x910; gSaveContext.weekEventReg[34] |= 8; } - func_801518B0(globalCtx, phi_a1, &this->actor); + Message_StartTextbox(globalCtx, phi_a1, &this->actor); } void EnSsh_Idle(EnSsh* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index b65b1ef40..746c0e92d 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -194,7 +194,7 @@ void func_80B67148(EnSth* this, GlobalContext* globalCtx) { } val = D_80B6D1E8[day]; - func_801518B0(globalCtx, val, &this->actor); + Message_StartTextbox(globalCtx, val, &this->actor); } void func_80B671A0(EnSth* this, GlobalContext* globalCtx) { @@ -235,7 +235,7 @@ void func_80B672A4(EnSth* this, GlobalContext* globalCtx) { } else { sp1E = D_80B6D1F8[day]; } - func_801518B0(globalCtx, sp1E, &this->actor); + Message_StartTextbox(globalCtx, sp1E, &this->actor); } void func_80B67348(EnSth* this, GlobalContext* globalCtx) { @@ -273,7 +273,7 @@ void func_80B67348(EnSth* this, GlobalContext* globalCtx) { } break; } - func_801518B0(globalCtx, phi_a1, &this->actor); + Message_StartTextbox(globalCtx, phi_a1, &this->actor); } else { func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); } @@ -459,7 +459,7 @@ void func_80B67984(EnSth* this, GlobalContext* globalCtx) { sp1E = 0x8FC; gSaveContext.weekEventReg[34] |= 2; } - func_801518B0(globalCtx, sp1E, &this->actor); + Message_StartTextbox(globalCtx, sp1E, &this->actor); } void func_80B67AB4(EnSth* this, GlobalContext* globalCtx) { @@ -468,7 +468,7 @@ void func_80B67AB4(EnSth* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B67C1C; gSaveContext.weekEventReg[34] |= 0x40; - func_801518B0(globalCtx, 0x918, &this->actor); + Message_StartTextbox(globalCtx, 0x918, &this->actor); } else { func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); } diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 8dfd6dd35..07b1df03f 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -372,7 +372,7 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { break; } } - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } void func_80BAAF1C(EnSuttari* this) { @@ -892,7 +892,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x10000000; } this->textId = 0x2A30; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = func_80BAD2B4; } break; @@ -1100,7 +1100,7 @@ void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { this->unk428 = unkStruct.unk0; func_80BAC2FC(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x2A3A, &this->actor); + Message_StartTextbox(globalCtx, 0x2A3A, &this->actor); this->actionFunc = func_80BAD130; } else if ((this->actor.xzDistToPlayer < 200.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); @@ -1132,7 +1132,7 @@ void func_80BAD230(EnSuttari* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[1])) { ActorCutscene_Start(this->cutscenes[1], &this->actor); this->textId = 0x2A31; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->flags1 |= 0x4000; Audio_QueueSeqCmd(NA_BGM_CHASE | 0x8000); this->actionFunc = func_80BAD380; @@ -1234,7 +1234,7 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { func_80BAB434(this); if ((this->flags1 & 0x20) && (this->unk430 == 0) && (unkStruct.unk0 != 7)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x2A02, &this->actor); + Message_StartTextbox(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); @@ -1272,7 +1272,7 @@ void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { } if ((this->flags1 & 0x20) && (unkStruct.unk0 != 9)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x2A02, &this->actor); + Message_StartTextbox(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); @@ -1386,7 +1386,7 @@ void func_80BADE8C(EnSuttari* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_801518B0(globalCtx, 0x2A3A, &this->actor); + Message_StartTextbox(globalCtx, 0x2A3A, &this->actor); this->actionFunc = func_80BAD130; } else { this->actor.flags |= ACTOR_FLAG_10000; diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 8c359eda1..d461712e2 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -210,31 +210,31 @@ void func_809C6848(EnSyatekiMan* this, GlobalContext* globalCtx) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); sp22 = Text_GetFaceReaction(globalCtx, 0x31); if (sp22 != 0) { - func_801518B0(globalCtx, sp22, &this->actor); + Message_StartTextbox(globalCtx, sp22, &this->actor); this->unk_284 = sp22; } else if (player->transformation == PLAYER_FORM_HUMAN) { if (this->unk_282 == 0) { this->unk_282 = 1; - func_801518B0(globalCtx, 0xA28, &this->actor); + Message_StartTextbox(globalCtx, 0xA28, &this->actor); this->unk_284 = 0xA28; } else { - func_801518B0(globalCtx, 0xA29, &this->actor); + Message_StartTextbox(globalCtx, 0xA29, &this->actor); this->unk_284 = 0xA29; } } else { switch (CURRENT_DAY) { case 1: - func_801518B0(globalCtx, 0xA38, &this->actor); + Message_StartTextbox(globalCtx, 0xA38, &this->actor); this->unk_284 = 0xA38; break; case 2: - func_801518B0(globalCtx, 0xA39, &this->actor); + Message_StartTextbox(globalCtx, 0xA39, &this->actor); this->unk_284 = 0xA39; break; case 3: - func_801518B0(globalCtx, 0xA3A, &this->actor); + Message_StartTextbox(globalCtx, 0xA3A, &this->actor); this->unk_284 = 0xA3A; break; } @@ -256,11 +256,11 @@ void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { if (globalCtx->msgCtx.choiceIndex == 0) { if (!CUR_UPG_VALUE(UPG_QUIVER)) { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0xA30, &this->actor); + Message_StartTextbox(globalCtx, 0xA30, &this->actor); this->unk_284 = 0xA30; } else if (gSaveContext.rupees < 20) { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0xA31, &this->actor); + Message_StartTextbox(globalCtx, 0xA31, &this->actor); this->unk_284 = 0xA31; if (this->unk_26A == 4) { gSaveContext.minigameState = 3; @@ -282,17 +282,17 @@ void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { switch (CURRENT_DAY) { case 1: - func_801518B0(globalCtx, 0xA2D, &this->actor); + Message_StartTextbox(globalCtx, 0xA2D, &this->actor); this->unk_284 = 0xA2D; break; case 2: - func_801518B0(globalCtx, 0xA2E, &this->actor); + Message_StartTextbox(globalCtx, 0xA2E, &this->actor); this->unk_284 = 0xA2E; break; case 3: - func_801518B0(globalCtx, 0xA2F, &this->actor); + Message_StartTextbox(globalCtx, 0xA2F, &this->actor); this->unk_284 = 0xA2F; break; } @@ -313,7 +313,7 @@ void func_809C6C2C(EnSyatekiMan* this, GlobalContext* globalCtx) { switch (this->unk_284) { case 0xA28: case 0xA29: - func_801518B0(globalCtx, 0xA2A, &this->actor); + Message_StartTextbox(globalCtx, 0xA2A, &this->actor); this->unk_284 = 0xA2A; break; @@ -341,13 +341,13 @@ void func_809C6C2C(EnSyatekiMan* this, GlobalContext* globalCtx) { gSaveContext.minigameState = 3; this->unk_26A = 0; } else { - func_801518B0(globalCtx, 0xA33, &this->actor); + Message_StartTextbox(globalCtx, 0xA33, &this->actor); this->unk_284 = 0xA33; } break; case 0xA33: - func_801518B0(globalCtx, 0xA2A, &this->actor); + Message_StartTextbox(globalCtx, 0xA2A, &this->actor); this->unk_284 = 0xA2A; this->unk_26A = 4; break; @@ -422,18 +422,18 @@ void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { if (CURRENT_DAY != 3) { if (!(this->unk_282 & 1)) { this->unk_282 |= 1; - func_801518B0(globalCtx, 0x3E8, &this->actor); + Message_StartTextbox(globalCtx, 0x3E8, &this->actor); this->unk_284 = 0x3E8; } else { - func_801518B0(globalCtx, 0x3E9, &this->actor); + Message_StartTextbox(globalCtx, 0x3E9, &this->actor); this->unk_284 = 0x3E9; } } else if (!(this->unk_282 & 1)) { this->unk_282 |= 1; - func_801518B0(globalCtx, 0x3EA, &this->actor); + Message_StartTextbox(globalCtx, 0x3EA, &this->actor); this->unk_284 = 0x3EA; } else { - func_801518B0(globalCtx, 0x3EB, &this->actor); + Message_StartTextbox(globalCtx, 0x3EB, &this->actor); this->unk_284 = 0x3EB; } break; @@ -442,18 +442,18 @@ void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { if (CURRENT_DAY != 3) { if (!(this->unk_282 & 2)) { this->unk_282 |= 2; - func_801518B0(globalCtx, 0x3EC, &this->actor); + Message_StartTextbox(globalCtx, 0x3EC, &this->actor); this->unk_284 = 0x3EC; } else { - func_801518B0(globalCtx, 0x3ED, &this->actor); + Message_StartTextbox(globalCtx, 0x3ED, &this->actor); this->unk_284 = 0x3ED; } } else if (!(this->unk_282 & 2)) { this->unk_282 |= 2; - func_801518B0(globalCtx, 0x3EE, &this->actor); + Message_StartTextbox(globalCtx, 0x3EE, &this->actor); this->unk_284 = 0x3EE; } else { - func_801518B0(globalCtx, 0x3EF, &this->actor); + Message_StartTextbox(globalCtx, 0x3EF, &this->actor); this->unk_284 = 0x3EF; } break; @@ -462,18 +462,18 @@ void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { if (CURRENT_DAY != 3) { if (!(this->unk_282 & 8)) { this->unk_282 |= 8; - func_801518B0(globalCtx, 0x3F0, &this->actor); + Message_StartTextbox(globalCtx, 0x3F0, &this->actor); this->unk_284 = 0x3F0; } else { - func_801518B0(globalCtx, 0x3F1, &this->actor); + Message_StartTextbox(globalCtx, 0x3F1, &this->actor); this->unk_284 = 0x3F1; } } else if (!(this->unk_282 & 8)) { this->unk_282 |= 8; - func_801518B0(globalCtx, 0x3F4, &this->actor); + Message_StartTextbox(globalCtx, 0x3F4, &this->actor); this->unk_284 = 0x3F4; } else { - func_801518B0(globalCtx, 0x3F5, &this->actor); + Message_StartTextbox(globalCtx, 0x3F5, &this->actor); this->unk_284 = 0x3F5; } break; @@ -482,18 +482,18 @@ void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { if (CURRENT_DAY != 3) { if (!(this->unk_282 & 4)) { this->unk_282 |= 4; - func_801518B0(globalCtx, 0x3F2, &this->actor); + Message_StartTextbox(globalCtx, 0x3F2, &this->actor); this->unk_284 = 0x3F2; } else { - func_801518B0(globalCtx, 0x3F3, &this->actor); + Message_StartTextbox(globalCtx, 0x3F3, &this->actor); this->unk_284 = 0x3F3; } } else if (!(this->unk_282 & 4)) { this->unk_282 |= 4; - func_801518B0(globalCtx, 0x3F4, &this->actor); + Message_StartTextbox(globalCtx, 0x3F4, &this->actor); this->unk_284 = 0x3F4; } else { - func_801518B0(globalCtx, 0x3F5, &this->actor); + Message_StartTextbox(globalCtx, 0x3F5, &this->actor); this->unk_284 = 0x3F5; } break; @@ -505,7 +505,7 @@ void func_809C72D8(EnSyatekiMan* this, GlobalContext* globalCtx) { u16 sp26 = Text_GetFaceReaction(globalCtx, 0x30); if (sp26 != 0) { - func_801518B0(globalCtx, sp26, &this->actor); + Message_StartTextbox(globalCtx, sp26, &this->actor); this->unk_284 = sp26; } else { func_809C6F98(this, globalCtx); @@ -524,19 +524,19 @@ void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { if (!CUR_UPG_VALUE(UPG_QUIVER)) { play_sound(NA_SE_SY_ERROR); if (CURRENT_DAY != 3) { - func_801518B0(globalCtx, 0x3F9, &this->actor); + Message_StartTextbox(globalCtx, 0x3F9, &this->actor); this->unk_284 = 0x3F9; } else { - func_801518B0(globalCtx, 0x3FA, &this->actor); + Message_StartTextbox(globalCtx, 0x3FA, &this->actor); this->unk_284 = 0x3FA; } } else if (gSaveContext.rupees < 20) { play_sound(NA_SE_SY_ERROR); if (CURRENT_DAY != 3) { - func_801518B0(globalCtx, 0x3FB, &this->actor); + Message_StartTextbox(globalCtx, 0x3FB, &this->actor); this->unk_284 = 0x3FB; } else { - func_801518B0(globalCtx, 0x3FC, &this->actor); + Message_StartTextbox(globalCtx, 0x3FC, &this->actor); this->unk_284 = 0x3FC; } @@ -551,10 +551,10 @@ void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_26A = 2; if (!(this->unk_282 & 0x10)) { this->unk_282 |= 0x10; - func_801518B0(globalCtx, 0x3FD, &this->actor); + Message_StartTextbox(globalCtx, 0x3FD, &this->actor); this->unk_284 = 0x3FD; } else { - func_801518B0(globalCtx, 0x3FF, &this->actor); + Message_StartTextbox(globalCtx, 0x3FF, &this->actor); this->unk_284 = 0x3FF; } gSaveContext.weekEventReg[63] |= 1; @@ -563,10 +563,10 @@ void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { } else { func_8019F230(); if (CURRENT_DAY != 3) { - func_801518B0(globalCtx, 0x3F7, &this->actor); + Message_StartTextbox(globalCtx, 0x3F7, &this->actor); this->unk_284 = 0x3F7; } else { - func_801518B0(globalCtx, 0x3F8, &this->actor); + Message_StartTextbox(globalCtx, 0x3F8, &this->actor); this->unk_284 = 0x3F8; } @@ -588,32 +588,32 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { case 0x3E9: case 0x3EA: case 0x3EB: - func_801518B0(globalCtx, 0x3F6, &this->actor); + Message_StartTextbox(globalCtx, 0x3F6, &this->actor); this->unk_284 = 0x3F6; break; case 0x3EC: - func_801518B0(globalCtx, 0x3ED, &this->actor); + Message_StartTextbox(globalCtx, 0x3ED, &this->actor); this->unk_284 = 0x3ED; break; case 0x3EE: - func_801518B0(globalCtx, 0x3EF, &this->actor); + Message_StartTextbox(globalCtx, 0x3EF, &this->actor); this->unk_284 = 0x3EF; break; case 0x3F0: - func_801518B0(globalCtx, 0x3F1, &this->actor); + Message_StartTextbox(globalCtx, 0x3F1, &this->actor); this->unk_284 = 0x3F1; break; case 0x3F2: - func_801518B0(globalCtx, 0x3F3, &this->actor); + Message_StartTextbox(globalCtx, 0x3F3, &this->actor); this->unk_284 = 0x3F3; break; case 0x3F4: - func_801518B0(globalCtx, 0x3F5, &this->actor); + Message_StartTextbox(globalCtx, 0x3F5, &this->actor); this->unk_284 = 0x3F5; break; @@ -621,10 +621,10 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { case 0x3FF: if (this->unk_26A == 4) { if (this->unk_284 == 0x3FD) { - func_801518B0(globalCtx, 0x3FE, &this->actor); + Message_StartTextbox(globalCtx, 0x3FE, &this->actor); this->unk_284 = 0x3FE; } else { - func_801518B0(globalCtx, 0x400, &this->actor); + Message_StartTextbox(globalCtx, 0x400, &this->actor); this->unk_284 = 0x400; } } else { @@ -660,7 +660,7 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_26A = 0; this->actionFunc = func_809C72D8; } else { - func_801518B0(globalCtx, 0x402, &this->actor); + Message_StartTextbox(globalCtx, 0x402, &this->actor); this->unk_284 = 0x402; } break; @@ -673,14 +673,14 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_26A = 0; this->actionFunc = func_809C72D8; } else { - func_801518B0(globalCtx, 0x404, &this->actor); + Message_StartTextbox(globalCtx, 0x404, &this->actor); this->unk_284 = 0x404; } break; case 0x402: case 0x404: - func_801518B0(globalCtx, 0x3F6, &this->actor); + Message_StartTextbox(globalCtx, 0x3F6, &this->actor); this->unk_284 = 0x3F6; this->unk_26A = 4; break; @@ -775,10 +775,10 @@ void func_809C7C14(EnSyatekiMan* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if ((CURRENT_DAY == 3) && (gSaveContext.time > CLOCK_TIME(12, 00))) { - func_801518B0(globalCtx, 0xA36, &this->actor); + Message_StartTextbox(globalCtx, 0xA36, &this->actor); this->unk_284 = 0xA36; } else { - func_801518B0(globalCtx, 0xA37, &this->actor); + Message_StartTextbox(globalCtx, 0xA37, &this->actor); this->unk_284 = 0xA37; } player->stateFlags1 &= ~0x20; @@ -841,7 +841,7 @@ void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx) { this->actionFunc = func_809C6810; } } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x408, &this->actor); + Message_StartTextbox(globalCtx, 0x408, &this->actor); this->unk_284 = 0x408; player->stateFlags1 &= ~0x20; this->actor.flags &= ~ACTOR_FLAG_10000; @@ -861,10 +861,10 @@ void func_809C7FFC(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_26A = 2; if (this->unk_282 != 2) { this->unk_282 = 2; - func_801518B0(globalCtx, 0xA2B, &this->actor); + Message_StartTextbox(globalCtx, 0xA2B, &this->actor); this->unk_284 = 0xA2B; } else { - func_801518B0(globalCtx, 0xA2C, &this->actor); + Message_StartTextbox(globalCtx, 0xA2C, &this->actor); this->unk_284 = 0xA2C; } this->actionFunc = func_809C6E30; @@ -979,7 +979,7 @@ void func_809C8488(EnSyatekiMan* this, GlobalContext* globalCtx) { } this->unk_270 = 15; if (this->unk_280 >= 0x848) { - func_801518B0(globalCtx, 0xA34, &this->actor); + Message_StartTextbox(globalCtx, 0xA34, &this->actor); this->unk_284 = 0xA34; this->unk_26A = 6; } else if (this->unk_280 >= 0x7D0) { @@ -991,12 +991,12 @@ void func_809C8488(EnSyatekiMan* this, GlobalContext* globalCtx) { this->actionFunc = func_809C6848; return; } - func_801518B0(globalCtx, 0xA35, &this->actor); + Message_StartTextbox(globalCtx, 0xA35, &this->actor); this->unk_284 = 0xA35; this->unk_26A = 4; this->unk_280 = 0; } else { - func_801518B0(globalCtx, 0xA32, &this->actor); + Message_StartTextbox(globalCtx, 0xA32, &this->actor); this->unk_284 = 0xA32; this->unk_26A = 6; } @@ -1047,10 +1047,10 @@ void func_809C8710(EnSyatekiMan* this, GlobalContext* globalCtx) { if (func_809C6720(globalCtx, sp24)) { if (this->unk_284 == 0x3FD) { - func_801518B0(globalCtx, 0x3FE, &this->actor); + Message_StartTextbox(globalCtx, 0x3FE, &this->actor); this->unk_284 = 0x3FE; } else { - func_801518B0(globalCtx, 0x400, &this->actor); + Message_StartTextbox(globalCtx, 0x400, &this->actor); this->unk_284 = 0x400; } this->unk_26A = 2; @@ -1167,27 +1167,27 @@ void func_809C8BF0(EnSyatekiMan* this, GlobalContext* globalCtx) { if (((s32)(gSaveContext.unk_EF4 & 0xFFFF) < this->unk_280) || (this->unk_280 == 50)) { if ((s32)(gSaveContext.unk_EF4 & 0xFFFF) < this->unk_280) { if (!(gSaveContext.weekEventReg[59] & 0x20)) { - func_801518B0(globalCtx, 0x407, &this->actor); + Message_StartTextbox(globalCtx, 0x407, &this->actor); this->unk_284 = 0x407; } else if (this->unk_280 == 50) { - func_801518B0(globalCtx, 0x405, &this->actor); + Message_StartTextbox(globalCtx, 0x405, &this->actor); this->unk_284 = 0x405; } else { - func_801518B0(globalCtx, 0x407, &this->actor); + Message_StartTextbox(globalCtx, 0x407, &this->actor); this->unk_284 = 0x407; } } else if (this->unk_280 == 50) { - func_801518B0(globalCtx, 0x406, &this->actor); + Message_StartTextbox(globalCtx, 0x406, &this->actor); this->unk_284 = 0x406; } gSaveContext.unk_EF4 = (gSaveContext.unk_EF4 & 0xFFFF0000) | (this->unk_280 & 0xFFFF); this->unk_26A = 6; } else { if (CURRENT_DAY != 3) { - func_801518B0(globalCtx, 0x401, &this->actor); + Message_StartTextbox(globalCtx, 0x401, &this->actor); this->unk_284 = 0x401; } else { - func_801518B0(globalCtx, 0x403, &this->actor); + Message_StartTextbox(globalCtx, 0x403, &this->actor); this->unk_284 = 0x403; } this->unk_26A = 4; diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c index eca7a621e..a4822cad3 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c @@ -625,52 +625,52 @@ void EnTalkGibud_Revive(EnTalkGibud* this, GlobalContext* globalCtx) { void EnTalkGibud_GetTextIdForRequestedItem(EnTalkGibud* this, GlobalContext* globalCtx) { switch (this->requestedItemIndex) { case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BLUE_POTION: - func_801518B0(globalCtx, 0x138C, &this->actor); + Message_StartTextbox(globalCtx, 0x138C, &this->actor); this->textId = 0x138C; break; case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BEANS: - func_801518B0(globalCtx, 0x138D, &this->actor); + Message_StartTextbox(globalCtx, 0x138D, &this->actor); this->textId = 0x138D; break; case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_SPRING_WATER: - func_801518B0(globalCtx, 0x138E, &this->actor); + Message_StartTextbox(globalCtx, 0x138E, &this->actor); this->textId = 0x138E; break; case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_FISH: - func_801518B0(globalCtx, 0x138F, &this->actor); + Message_StartTextbox(globalCtx, 0x138F, &this->actor); this->textId = 0x138F; break; case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BUGS: - func_801518B0(globalCtx, 0x1390, &this->actor); + Message_StartTextbox(globalCtx, 0x1390, &this->actor); this->textId = 0x1390; break; case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_DEKU_NUTS: - func_801518B0(globalCtx, 0x1391, &this->actor); + Message_StartTextbox(globalCtx, 0x1391, &this->actor); this->textId = 0x1391; break; case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BOMBS: - func_801518B0(globalCtx, 0x1392, &this->actor); + Message_StartTextbox(globalCtx, 0x1392, &this->actor); this->textId = 0x1392; break; case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_HOT_SPRING_WATER: - func_801518B0(globalCtx, 0x1393, &this->actor); + Message_StartTextbox(globalCtx, 0x1393, &this->actor); this->textId = 0x1393; break; case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BIG_POE: - func_801518B0(globalCtx, 0x1394, &this->actor); + Message_StartTextbox(globalCtx, 0x1394, &this->actor); this->textId = 0x1394; break; case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_MILK: - func_801518B0(globalCtx, 0x1395, &this->actor); + Message_StartTextbox(globalCtx, 0x1395, &this->actor); this->textId = 0x1395; break; } @@ -694,7 +694,7 @@ void EnTalkGibud_GetNextTextBoxId(EnTalkGibud* this, GlobalContext* globalCtx) { case 0x1394: case 0x1395: // Prompts the player to choose an item - func_801518B0(globalCtx, 0xFF, &this->actor); + Message_StartTextbox(globalCtx, 0xFF, &this->actor); this->textId = 0xFF; break; } @@ -750,7 +750,7 @@ void EnTalkGibud_CheckPresentedItem(EnTalkGibud* this, GlobalContext* globalCtx) } func_801477B4(globalCtx); } else if (this->itemActionParam < PLAYER_AP_NONE) { - func_801518B0(globalCtx, 0x1389, &this->actor); + Message_StartTextbox(globalCtx, 0x1389, &this->actor); this->textId = 0x1389; } } @@ -771,7 +771,7 @@ void EnTalkGibud_SetupPassiveIdle(EnTalkGibud* this) { void EnTalkGibud_PassiveIdle(EnTalkGibud* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->isTalking = true; - func_801518B0(globalCtx, 0x1388, &this->actor); + Message_StartTextbox(globalCtx, 0x1388, &this->actor); this->textId = 0x1388; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); EnTalkGibud_SetupTalk(this); diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index dcc134dbd..5aaf7adb6 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -240,8 +240,8 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { if (isItemFound) { func_801149A0(itemId2, slotId); this->unk_3E8 = object_thiefbird_DL_0033B0; - if (!Message_GetState(&globalCtx->msgCtx)) { - func_801518B0(globalCtx, 0xF4, NULL); + if (Message_GetState(&globalCtx->msgCtx) == 0) { + Message_StartTextbox(globalCtx, 0xF4, NULL); } itemId1 = ITEM_BOTTLE; } else if (phi_a3 != 0) { @@ -264,8 +264,8 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_3E8 = D_80C13680[phi_a3 - 1]; } - if (!Message_GetState(&globalCtx->msgCtx)) { - func_801518B0(globalCtx, 0xF5, NULL); + if (Message_GetState(&globalCtx->msgCtx) == 0) { + Message_StartTextbox(globalCtx, 0xF5, NULL); } } else { return false; diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index f7b5a339e..32e4c9c81 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -535,16 +535,16 @@ void func_80AED4F8(EnTk* this, GlobalContext* globalCtx) { void func_80AED544(EnTk* this, GlobalContext* globalCtx) { if (!(gSaveContext.weekEventReg[31] & 0x10)) { - func_801518B0(globalCtx, 0x13FE, &this->actor); + Message_StartTextbox(globalCtx, 0x13FE, &this->actor); gSaveContext.weekEventReg[31] |= 0x10; } else if (gSaveContext.time < CLOCK_TIME(9, 0)) { - func_801518B0(globalCtx, 0x13FF, &this->actor); + Message_StartTextbox(globalCtx, 0x13FF, &this->actor); } else if (gSaveContext.time < CLOCK_TIME(12, 0)) { - func_801518B0(globalCtx, 0x1400, &this->actor); + Message_StartTextbox(globalCtx, 0x1400, &this->actor); } else if (gSaveContext.time < CLOCK_TIME(15, 0)) { - func_801518B0(globalCtx, 0x1401, &this->actor); + Message_StartTextbox(globalCtx, 0x1401, &this->actor); } else { - func_801518B0(globalCtx, 0x1402, &this->actor); + Message_StartTextbox(globalCtx, 0x1402, &this->actor); } } @@ -558,15 +558,15 @@ void func_80AED610(EnTk* this, GlobalContext* globalCtx) { if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer - 0x1555, 0x71C)) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); - func_801518B0(globalCtx, 0x13FD, &this->actor); + Message_StartTextbox(globalCtx, 0x13FD, &this->actor); } else if (CURRENT_DAY != 2) { func_80AED544(this, globalCtx); } else if (!Flags_GetSwitch(globalCtx, ENTK_GET_7F0(&this->actor))) { - func_801518B0(globalCtx, 0x1403, &this->actor); + Message_StartTextbox(globalCtx, 0x1403, &this->actor); } else if (gSaveContext.weekEventReg[60] & 2) { func_80AED544(this, globalCtx); } else { - func_801518B0(globalCtx, 0x1413, &this->actor); + Message_StartTextbox(globalCtx, 0x1413, &this->actor); } break; } @@ -769,12 +769,12 @@ void func_80AEDE10(EnTk* this, GlobalContext* globalCtx) { break; case 4: - func_801518B0(globalCtx, 0x140F, &this->actor); + Message_StartTextbox(globalCtx, 0x140F, &this->actor); SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); break; case 3: - func_801518B0(globalCtx, 0x1410, &this->actor); + Message_StartTextbox(globalCtx, 0x1410, &this->actor); SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); break; } @@ -810,12 +810,12 @@ void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { } else { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); } - func_801518B0(globalCtx, this->unk_2E6, &this->actor); + Message_StartTextbox(globalCtx, this->unk_2E6, &this->actor); } break; case 0x1414: - func_801518B0(globalCtx, this->unk_2E6, &this->actor); + Message_StartTextbox(globalCtx, this->unk_2E6, &this->actor); break; } break; @@ -1189,8 +1189,8 @@ void func_80AEED38(EnTk* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; } - if (!Message_GetState(&globalCtx->msgCtx) && !func_801690CC(globalCtx) && (this->unk_2C6-- <= 0)) { - func_801518B0(globalCtx, 0x140C, NULL); + if (Message_GetState(&globalCtx->msgCtx) == 0 && !func_801690CC(globalCtx) && (this->unk_2C6-- <= 0)) { + Message_StartTextbox(globalCtx, 0x140C, NULL); this->unk_2CA |= 0x4000; this->unk_2C6 = 200; } diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index 64ff521c6..746aec883 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -379,7 +379,7 @@ s32 func_80BA3FB0(EnToto* this, GlobalContext* globalCtx) { s32 func_80BA3FCC(EnToto* this, GlobalContext* globalCtx) { if (DECR(this->unk2B1) == 0) { - func_801518B0(globalCtx, this->text->textId, NULL); + Message_StartTextbox(globalCtx, this->text->textId, NULL); return 1; } return 0; @@ -436,7 +436,7 @@ s32 func_80BA4204(EnToto* this, GlobalContext* globalCtx) { if (DECR(this->unk2B1) == 0) { if (!ENTOTO_WEEK_EVENT_FLAGS) { temp_v1_2 = &D_80BA50DC[gSaveContext.playerForm - 1]; - func_801518B0(globalCtx, (this->text->unk0 == 6) ? temp_v1_2->unk0 : temp_v1_2->unk4, NULL); + Message_StartTextbox(globalCtx, (this->text->unk0 == 6) ? temp_v1_2->unk0 : temp_v1_2->unk4, NULL); } return 1; } @@ -528,7 +528,7 @@ s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { this->unk2B1++; if (this->unk2B1 >= 10) { tmp = gSaveContext.playerForm; // Needed for regalloc possible FAKE MATCH - func_801518B0(globalCtx, D_80BA50DC[tmp - 1].unk2, NULL); + Message_StartTextbox(globalCtx, D_80BA50DC[tmp - 1].unk2, NULL); } } return 0; @@ -674,11 +674,10 @@ s32 func_80BA4C44(EnToto* this, GlobalContext* globalCtx) { } void func_80BA4CB4(EnToto* this, GlobalContext* globalCtx) { - CsCmdActorAction* action; + CsCmdActorAction* action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 525)]; - action = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x20D)]; - if (this->unk2B5 != action->unk0) { - this->unk2B5 = action->unk0; + if (this->unk2B5 != action->action) { + this->unk2B5 = action->action; if (this->unk2B5 != 4) { if (this->unk2B5 == 3) { Animation_MorphToPlayOnce(&this->skelAnime, &object_zm_Anim_001DF0, -4.0f); @@ -707,7 +706,7 @@ void EnToto_Update(Actor* thisx, GlobalContext* globalCtx) { EnToto* this = THIS; s32 pad; - if (func_800EE29C(globalCtx, 0x20D)) { + if (Cutscene_CheckActorAction(globalCtx, 0x20D)) { func_80BA4CB4(this, globalCtx); } else { D_80BA51B8[this->actionFuncIndex](this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.c b/src/overlays/actors/ovl_En_Trt/z_en_trt.c index c3898cdce..075d42337 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -334,13 +334,13 @@ void EnTrt_GetMushroom(EnTrt* this, GlobalContext* globalCtx) { switch (this->textId) { case 0x883: this->textId = 0x884; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); gSaveContext.weekEventReg[53] |= 8; func_80123D50(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); break; case 0x888: this->textId = 0x889; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); break; case 0x889: if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { @@ -399,7 +399,7 @@ void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { this->tmpTextId = this->textId; this->textId = 0x88E; gSaveContext.weekEventReg[85] |= 8; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } } else { @@ -423,7 +423,7 @@ void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { this->textId = 0x835; EnTrt_SetupStartShopping(globalCtx, this, false); } - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } } } @@ -869,7 +869,7 @@ void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { } else if (DECR(this->timer) == 0) { this->timer = Rand_S16Offset(40, 20); EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 5); - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->animationIdx = 5; switch (this->textId) { case 0x834: @@ -920,7 +920,7 @@ void EnTrt_Surprised(EnTrt* this, GlobalContext* globalCtx) { } else if (DECR(this->timer) == 0) { this->timer = Rand_S16Offset(40, 20); EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 5); - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->animationIdx = 5; this->actionFunc = EnTrt_TryToGiveRedPotionAfterSurprised; } @@ -941,7 +941,7 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCt this->tmpTextId = this->textId; this->textId = 0x88E; gSaveContext.weekEventReg[85] |= 8; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } } @@ -962,12 +962,12 @@ void EnTrt_TryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { this->tmpTextId = this->textId; this->textId = 0x88E; gSaveContext.weekEventReg[85] |= 8; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } } else { this->textId = 0x83C; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } } } @@ -1025,7 +1025,7 @@ void EnTrt_ShopkeeperGone(EnTrt* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } else { if ((player->actor.world.pos.x >= -50.0f && player->actor.world.pos.x <= 50.0f) && (player->actor.world.pos.z >= -19.0f && player->actor.world.pos.z <= 30.0f)) { @@ -1104,7 +1104,7 @@ void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx) { func_8019F208(); player->actor.shape.rot.y = BINANG_ROT180(player->actor.shape.rot.y); player->stateFlags2 |= 0x20000000; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); EnTrt_SetupStartShopping(globalCtx, this, true); func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); break; @@ -1398,7 +1398,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { } else { this->textId = 0x886; } - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_Goodbye; } } diff --git a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c index cef309815..f17a6a80f 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -330,7 +330,7 @@ void func_80AD3CEC(EnTrt2* this, GlobalContext* globalCtx) { func_80AD46F8(this); if (this->unk_3D8) { - func_801518B0(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); this->unk_3D8 = false; } else if ((sp27 == 5) && func_80147624(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; @@ -342,7 +342,7 @@ void func_80AD3CEC(EnTrt2* this, GlobalContext* globalCtx) { void func_80AD3DA4(EnTrt2* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; - func_801518B0(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); if (this->unk_3A8 == 0x838) { this->unk_3B2 = 11; @@ -367,7 +367,7 @@ void func_80AD3E34(EnTrt2* this, GlobalContext* globalCtx) { } else { gSaveContext.weekEventReg[85] |= 0x10; this->unk_3A8 = 0x88E; - func_801518B0(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); this->unk_3B2 = 10; } } @@ -384,7 +384,7 @@ void func_80AD3EF0(EnTrt2* this, GlobalContext* globalCtx) { } else { gSaveContext.weekEventReg[85] |= 0x10; this->unk_3A8 = 0x88E; - func_801518B0(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); this->unk_3B2 = 10; } } @@ -441,7 +441,7 @@ void func_80AD417C(EnTrt2* this, GlobalContext* globalCtx) { this->unk_3B2 = 18; } else if (this->unk_3A8 == 0x88F) { this->unk_3A8 = 0x88E; - func_801518B0(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); } else { this->actor.textId = 0; this->unk_3B2 = 15; diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index 46ef1d90a..b15cb5119 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -191,11 +191,11 @@ void func_8096689C(EnWeatherTag* this, GlobalContext* globalCtx) { globalCtx->envCtx.windSpeed = (this->actor.world.rot.z * partialResult) + 30.0f; if (partialResult > 0.01f) { - globalCtx->envCtx.unk_EA = 8; + globalCtx->envCtx.sandstormState = 8; D_801F4E30 = 0x9B; - } else if (globalCtx->envCtx.unk_EA == 8) { + } else if (globalCtx->envCtx.sandstormState == 8) { D_801F4E30 = 0; - globalCtx->envCtx.unk_EA = 9; + globalCtx->envCtx.sandstormState = 9; } } @@ -249,9 +249,9 @@ void func_80966BF4(EnWeatherTag* this, GlobalContext* globalCtx) { u8 newUnk20; CsCmdActorAction* tmpAction; - if (func_800EE29C(globalCtx, 0x237) != 0) { - tmpAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x237)]; - if ((globalCtx->csCtx.frames >= tmpAction->startFrame) && (tmpAction->unk0 >= 2)) { + if (Cutscene_CheckActorAction(globalCtx, 567)) { + tmpAction = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 567)]; + if ((globalCtx->csCtx.frames >= tmpAction->startFrame) && (tmpAction->action >= 2)) { switch (gSaveContext.day) { case 0: case 1: @@ -429,20 +429,20 @@ void func_809672DC(EnWeatherTag* this, GlobalContext* globalCtx) { range = WEATHER_TAG_RANGE100(this); if (distance < range) { - globalCtx->envCtx.unk_EA = 6; + globalCtx->envCtx.sandstormState = 6; strength = 1.0f - (distance / range); if (0.8f < strength) { strength = 1.0f; } D_801F4E30 = (200.0f * strength); } else { - if (globalCtx->envCtx.unk_EA == 6) { + if (globalCtx->envCtx.sandstormState == 6) { D_801F4E30 = 0; - globalCtx->envCtx.unk_EA = 7; + globalCtx->envCtx.sandstormState = 7; } } - Math_SmoothStepToS(&globalCtx->envCtx.unk_8C.fogNear, (s16)(-40.0f * strength), 1, 1, 1); + Math_SmoothStepToS(&globalCtx->envCtx.lightSettings.fogNear, (s16)(-40.0f * strength), 1, 1, 1); } // WEATHERTAG_TYPE_LOCALDAY2RAIN: rain proximity as approaching rainy scene diff --git a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c index ba6c1364b..80dd47feb 100644 --- a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c +++ b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c @@ -108,19 +108,19 @@ void EnWizFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnWizFire* this = THIS; if (this->unk_162 == 0) { - globalCtx->envCtx.unk_8C.fogColor[2] = 0; - globalCtx->envCtx.unk_8C.fogColor[1] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.fogColor[0] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.diffuseColor2[2] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.diffuseColor2[1] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.diffuseColor2[0] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.diffuseColor1[2] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.diffuseColor1[1] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.diffuseColor1[0] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.ambientColor[2] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.ambientColor[1] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.ambientColor[0] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.fogNear = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.lightSettings.fogColor[2] = 0; + globalCtx->envCtx.lightSettings.fogColor[1] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.fogColor[0] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.diffuseColor2[2] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.diffuseColor2[1] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.diffuseColor2[0] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.diffuseColor1[2] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.diffuseColor1[1] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.diffuseColor1[0] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.ambientColor[2] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.ambientColor[1] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.ambientColor[0] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.fogNear = globalCtx->envCtx.lightSettings.fogColor[2]; } Collider_DestroyCylinder(globalCtx, &this->collider); } @@ -483,37 +483,37 @@ void EnWizFire_Update(Actor* thisx, GlobalContext* globalCtx2) { phi_f0 = 968.0f; } - globalCtx->envCtx.unk_8C.fogNear = (phi_f0 - (s16)globalCtx->envCtx.unk_C4.fogNear) * this->unk_204; + globalCtx->envCtx.lightSettings.fogNear = (phi_f0 - (s16)globalCtx->envCtx.unk_C4.fogNear) * this->unk_204; - globalCtx->envCtx.unk_8C.ambientColor[0] = + globalCtx->envCtx.lightSettings.ambientColor[0] = ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.ambientColor[0]) * this->unk_204; - globalCtx->envCtx.unk_8C.ambientColor[1] = + globalCtx->envCtx.lightSettings.ambientColor[1] = ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.ambientColor[1]) * this->unk_204; - globalCtx->envCtx.unk_8C.ambientColor[2] = + globalCtx->envCtx.lightSettings.ambientColor[2] = ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.ambientColor[2]) * this->unk_204; idx++; - globalCtx->envCtx.unk_8C.diffuseColor1[0] = + globalCtx->envCtx.lightSettings.diffuseColor1[0] = ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.diffuseColor1[0]) * this->unk_204; - globalCtx->envCtx.unk_8C.diffuseColor1[1] = + globalCtx->envCtx.lightSettings.diffuseColor1[1] = ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.diffuseColor1[1]) * this->unk_204; - globalCtx->envCtx.unk_8C.diffuseColor1[2] = + globalCtx->envCtx.lightSettings.diffuseColor1[2] = ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.diffuseColor1[2]) * this->unk_204; idx++; - globalCtx->envCtx.unk_8C.diffuseColor2[0] = + globalCtx->envCtx.lightSettings.diffuseColor2[0] = ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.diffuseColor[0]) * this->unk_204; - globalCtx->envCtx.unk_8C.diffuseColor2[1] = + globalCtx->envCtx.lightSettings.diffuseColor2[1] = ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.diffuseColor[1]) * this->unk_204; - globalCtx->envCtx.unk_8C.diffuseColor2[2] = + globalCtx->envCtx.lightSettings.diffuseColor2[2] = ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.diffuseColor[2]) * this->unk_204; idx++; - globalCtx->envCtx.unk_8C.fogColor[0] = + globalCtx->envCtx.lightSettings.fogColor[0] = ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.fogColor[0]) * this->unk_204; - globalCtx->envCtx.unk_8C.fogColor[1] = + globalCtx->envCtx.lightSettings.fogColor[1] = ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.fogColor[1]) * this->unk_204; - globalCtx->envCtx.unk_8C.fogColor[2] = + globalCtx->envCtx.lightSettings.fogColor[2] = ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.fogColor[2]) * this->unk_204; } } diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.c b/src/overlays/actors/ovl_En_Yb/z_en_yb.c index 73ae77f67..fec9af08f 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -260,7 +260,7 @@ void EnYb_SetupLeaving(EnYb* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = EnYb_Talk; // I am counting on you - func_801518B0(globalCtx, 0x147D, &this->actor); + Message_StartTextbox(globalCtx, 0x147D, &this->actor); func_80BFA2FC(globalCtx); } else { func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); @@ -323,7 +323,7 @@ void EnYb_TeachingDanceFinish(EnYb* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = EnYb_Talk; // Spread my dance across the world - func_801518B0(globalCtx, 0x147C, &this->actor); + Message_StartTextbox(globalCtx, 0x147C, &this->actor); this->actor.flags &= ~ACTOR_FLAG_10000; } else { func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); @@ -362,10 +362,10 @@ void EnYb_Idle(EnYb* this, GlobalContext* globalCtx) { this->actionFunc = EnYb_Talk; if (Player_GetMask(globalCtx) == PLAYER_MASK_KAMARO) { // I have taught you, go use it - func_801518B0(globalCtx, 0x147C, &this->actor); + Message_StartTextbox(globalCtx, 0x147C, &this->actor); } else { // regular talk to him first dialogue - func_801518B0(globalCtx, 0x147B, &this->actor); + Message_StartTextbox(globalCtx, 0x147B, &this->actor); } } else if (EnYb_CanTalk(this, globalCtx)) { func_800B8614(&this->actor, globalCtx, 120.0f); diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.c b/src/overlays/actors/ovl_En_Zob/z_en_zob.c index 4c03fd9cf..a3f503874 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.c +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.c @@ -249,7 +249,7 @@ void func_80B9FA3C(EnZob* this, GlobalContext* globalCtx) { func_80B9F7E4(this, 4, 2); } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B9FC0C(EnZob* this) { @@ -278,19 +278,19 @@ void func_80B9FCA0(EnZob* this, GlobalContext* globalCtx) { } void func_80B9FD24(EnZob* this, GlobalContext* globalCtx) { - u32 temp_v0; - s16 temp; + s32 actionIndex; + s16 action; func_80B9F86C(this); - if (func_800EE29C(globalCtx, 500)) { + if (Cutscene_CheckActorAction(globalCtx, 500)) { this->unk_30E = -1; - temp_v0 = func_800EE200(globalCtx, 500); - temp = globalCtx->csCtx.npcActions[temp_v0]->unk0; + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 500); + action = globalCtx->csCtx.actorActions[actionIndex]->action; - if (temp != this->unk_310) { - this->unk_310 = temp; - switch (temp) { + if (action != this->unk_310) { + this->unk_310 = action; + switch (action) { case 1: func_80B9F7E4(this, 8, 0); break; @@ -304,12 +304,12 @@ void func_80B9FD24(EnZob* this, GlobalContext* globalCtx) { } void func_80B9FDDC(EnZob* this, GlobalContext* globalCtx) { - func_801518B0(globalCtx, 0x120C, &this->actor); + Message_StartTextbox(globalCtx, 0x120C, &this->actor); this->actionFunc = func_80BA00BC; } void func_80B9FE1C(EnZob* this, GlobalContext* globalCtx) { - func_801518B0(globalCtx, 0x1211, &this->actor); + Message_StartTextbox(globalCtx, 0x1211, &this->actor); this->actionFunc = func_80BA00BC; } @@ -537,7 +537,7 @@ void func_80BA0610(EnZob* this, GlobalContext* globalCtx) { func_80B9F86C(this); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - func_801518B0(globalCtx, 0x120D, &this->actor); + Message_StartTextbox(globalCtx, 0x120D, &this->actor); this->unk_304 = 3; func_80B9F7E4(this, 5, 2); func_80B9FC70(this, 0); @@ -549,7 +549,7 @@ void func_80BA0610(EnZob* this, GlobalContext* globalCtx) { void func_80BA06BC(EnZob* this, GlobalContext* globalCtx) { func_80B9FD24(this, globalCtx); - if (!func_800EE29C(globalCtx, 500)) { + if (!Cutscene_CheckActorAction(globalCtx, 500)) { this->actionFunc = func_80BA0610; this->actor.flags |= ACTOR_FLAG_10000; func_80BA0610(this, globalCtx); @@ -564,10 +564,10 @@ void func_80BA0728(EnZob* this, GlobalContext* globalCtx) { if (func_800B8718(&this->actor, &globalCtx->state)) { if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - func_801518B0(globalCtx, 0x1208, NULL); + Message_StartTextbox(globalCtx, 0x1208, NULL); gSaveContext.weekEventReg[30] |= 8; } else { - func_801518B0(globalCtx, 0x1216, NULL); + Message_StartTextbox(globalCtx, 0x1216, NULL); } this->actionFunc = func_80BA00BC; this->unk_304 = 1; @@ -577,7 +577,7 @@ void func_80BA0728(EnZob* this, GlobalContext* globalCtx) { } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80BA0374; func_80B9FA3C(this, globalCtx); - } else if (func_800EE29C(globalCtx, 500)) { + } else if (Cutscene_CheckActorAction(globalCtx, 500)) { this->actionFunc = func_80BA06BC; } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.xzDistToPlayer > 60.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x3000)) { @@ -615,7 +615,7 @@ void func_80BA08E8(EnZob* this, GlobalContext* globalCtx) { func_80B9F7E4(this, 5, 2); } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80BA09E0(EnZob* this, GlobalContext* globalCtx) { @@ -683,8 +683,8 @@ void func_80BA0C14(EnZob* this, GlobalContext* globalCtx) { this->unk_312 = 999; } - if (func_800EE29C(globalCtx, 0x203)) { - if (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x203)]->unk0 == 1) { + if (Cutscene_CheckActorAction(globalCtx, 515)) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 515)]->action == 1) { this->actionFunc = func_80BA0CF4; this->unk_312 = -1; } @@ -696,7 +696,8 @@ void func_80BA0C14(EnZob* this, GlobalContext* globalCtx) { void func_80BA0CF4(EnZob* this, GlobalContext* globalCtx) { func_80B9F86C(this); - if (func_800EE29C(globalCtx, 0x203) && (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x203)]->unk0 == 2)) { + if (Cutscene_CheckActorAction(globalCtx, 515) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 515)]->action == 2)) { this->actionFunc = func_80BA0C14; } } diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.c b/src/overlays/actors/ovl_En_Zog/z_en_zog.c index b46878a19..5e12cba0d 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -206,7 +206,7 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA) && - ((globalCtx->csCtx.unk_12 != 2) || (gSaveContext.sceneSetupIndex != 0) || + ((globalCtx->csCtx.currentCsIndex != 2) || (gSaveContext.sceneSetupIndex != 0) || (globalCtx->sceneNum != SCENE_30GYOSON))) { Actor_MarkForDeath(&this->actor); return; @@ -459,9 +459,9 @@ s32 func_80B93EA0(EnZog* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); } - if (func_800EE29C(globalCtx, 0x1D7)) { - sp3E = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1D7)]->unk0; - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x1D7)); + if (Cutscene_CheckActorAction(globalCtx, 471)) { + sp3E = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 471)]->action; + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 471)); switch (this->unk_306) { case 2: @@ -956,7 +956,7 @@ void EnZog_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 5); - if (func_800EE29C(globalCtx, 0x1D7) && (ENZOG_GET_F(&this->actor) != ENZOG_F_2)) { + if (Cutscene_CheckActorAction(globalCtx, 0x1D7) && (ENZOG_GET_F(&this->actor) != ENZOG_F_2)) { this->actionFunc = func_80B9461C; this->actor.shape.yOffset = 0.0f; } diff --git a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c index 7d962dcdc..7250daaa8 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c @@ -75,7 +75,7 @@ void func_80B31590(EnZoraegg* this) { void EnZoraegg_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnZoraegg* this = THIS; - u16 sp40[] = { 0x01C9, 0x01CA, 0x01CB, 0x01CC, 0x01CD, 0x01CE, 0x01D0 }; + u16 sp40[] = { 457, 458, 459, 460, 461, 462, 464 }; Actor_SetScale(&this->actor, 0.006f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_zoraegg_Skel_004C90, &object_zoraegg_Anim_005098, @@ -162,7 +162,7 @@ void EnZoraegg_Init(Actor* thisx, GlobalContext* globalCtx) { case ENZORAEGG_1F_7: case ENZORAEGG_1F_8: case ENZORAEGG_1F_9: - this->unk_1F0 = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_3]; + this->actorActionCmd = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_3]; Animation_PlayOnce(&this->skelAnime, &object_zoraegg_Anim_001E08); this->unk_1EC = 1; this->unk_1EE = 0; @@ -181,7 +181,7 @@ void EnZoraegg_Init(Actor* thisx, GlobalContext* globalCtx) { case ENZORAEGG_1F_14: case ENZORAEGG_1F_15: case ENZORAEGG_1F_16: - this->unk_1F0 = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_10]; + this->actorActionCmd = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_10]; this->unk_1EC = 2; this->actionFunc = func_80B324B0; Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004FE4); @@ -338,7 +338,7 @@ void func_80B320E0(EnZoraegg* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B32094; - func_801518B0(globalCtx, 0x24B, &this->actor); + Message_StartTextbox(globalCtx, 0x24B, &this->actor); } else { Actor_PickUp(&this->actor, globalCtx, GI_MAX, 80.0f, 60.0f); if (this->actor.isTargeted) { @@ -419,20 +419,25 @@ void func_80B32390(EnZoraegg* this, GlobalContext* globalCtx) { void func_80B324B0(EnZoraegg* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (func_800EE29C(globalCtx, this->unk_1F0)) { + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd)) { if (this->unk_1EA & 4) { - if (func_800EE29C(globalCtx, this->unk_1F0) && - (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_1F0)]->unk0 == 3)) { + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)]->action == + 3)) { Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004FE4); this->unk_1EA &= ~4; } - } else if (func_800EE29C(globalCtx, this->unk_1F0) && - (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_1F0)]->unk0 == 4)) { - Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004E04); - this->unk_1EA |= 4; + } else { + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)]->action == + 4)) { + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004E04); + this->unk_1EA |= 4; + } } - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->unk_1F0)); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); if ((this->unk_1EA & 4) && Animation_OnFrame(&this->skelAnime, this->unk_1E4)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_1); @@ -451,10 +456,11 @@ void func_80B32644(EnZoraegg* this, GlobalContext* globalCtx) { this->unk_1EA |= 2; } - if (!func_800EE29C(globalCtx, this->unk_1F0)) { + if (!Cutscene_CheckActorAction(globalCtx, this->actorActionCmd)) { this->actionFunc = func_80B324B0; } else { - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->unk_1F0)); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); if (this->unk_1EE > 25) { this->unk_1EE -= 25; @@ -467,8 +473,8 @@ void func_80B32644(EnZoraegg* this, GlobalContext* globalCtx) { void func_80B326F4(EnZoraegg* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (func_800EE29C(globalCtx, this->unk_1F0) && - (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_1F0)]->unk0 == 3)) { + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)]->action == 3)) { Animation_Change(&this->skelAnime, &object_zoraegg_Anim_004D20, 1.0f, 0.0f, Animation_GetLastFrame(&object_zoraegg_Anim_004D20), 2, 5.0f); this->unk_1E8 = 0; @@ -479,7 +485,8 @@ void func_80B326F4(EnZoraegg* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_2); } - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->unk_1F0)); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); if (Animation_OnFrame(&this->skelAnime, 4.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_1); @@ -502,7 +509,8 @@ void func_80B32820(EnZoraegg* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); } - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->unk_1F0)); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); if (Animation_OnFrame(&this->skelAnime, 16.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_0); @@ -536,7 +544,8 @@ void func_80B32928(EnZoraegg* this, GlobalContext* globalCtx) { } } - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->unk_1F0)); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); if (Animation_OnFrame(&this->skelAnime, 97.0f) || Animation_OnFrame(&this->skelAnime, 101.0f) || Animation_OnFrame(&this->skelAnime, 105.0f)) { @@ -545,8 +554,8 @@ void func_80B32928(EnZoraegg* this, GlobalContext* globalCtx) { } void func_80B32A88(EnZoraegg* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, this->unk_1F0) && - (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_1F0)]->unk0 == 2)) { + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)]->action == 2)) { this->unk_1E8 = 0; this->actionFunc = func_80B32928; } @@ -568,7 +577,7 @@ void func_80B32B3C(EnZoraegg* this, GlobalContext* globalCtx) { void func_80B32B70(EnZoraegg* this, GlobalContext* globalCtx) { func_80B31C40(this, globalCtx); - if (func_800EE29C(globalCtx, 0x1C9)) { + if (Cutscene_CheckActorAction(globalCtx, 0x1C9)) { Actor_MarkForDeath(&this->actor); } } @@ -581,7 +590,7 @@ void func_80B32BB8(EnZoraegg* this, GlobalContext* globalCtx) { this->actionFunc = func_80B32B70; } - if (func_800EE29C(globalCtx, 0x1C9)) { + if (Cutscene_CheckActorAction(globalCtx, 0x1C9)) { Actor_MarkForDeath(&this->actor); } } diff --git a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h index 152d656ef..fb65579fa 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h @@ -53,7 +53,7 @@ typedef struct EnZoraegg { /* 0x01ED */ u8 unk_1ED; /* 0x01EE */ u8 unk_1EE; /* 0x01EF */ u8 unk_1EF; - /* 0x01F0 */ u16 unk_1F0; + /* 0x01F0 */ u16 actorActionCmd; /* 0x01F2 */ s16 unk_1F2; /* 0x01F4 */ s16 unk_1F4; /* 0x01F8 */ EnZoraeggActionFunc actionFunc; diff --git a/src/overlays/actors/ovl_En_Zos/z_en_zos.c b/src/overlays/actors/ovl_En_Zos/z_en_zos.c index 9ab145b9f..a69223d09 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.c +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.c @@ -218,12 +218,12 @@ void func_80BBB15C(EnZos* this, GlobalContext* globalCtx) { this->unk_2B6 |= 0x10; } } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80BBB2C4(EnZos* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x124F, &this->actor); + Message_StartTextbox(globalCtx, 0x124F, &this->actor); this->actionFunc = func_80BBB8AC; this->actor.flags &= ~ACTOR_FLAG_10000; } else { @@ -253,13 +253,13 @@ void func_80BBB354(EnZos* this, GlobalContext* globalCtx) { void func_80BBB414(EnZos* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (func_800EE29C(globalCtx, 0x1F5)) { - s16 temp = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1F5)]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 501)) { + s16 action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 501)]->action; - if (temp != this->unk_2BA) { - this->unk_2BA = temp; + if (action != this->unk_2BA) { + this->unk_2BA = action; - switch (temp) { + switch (action) { case 1: func_80BBAE84(this, 1, 0); break; @@ -471,17 +471,17 @@ void func_80BBBB84(EnZos* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - func_801518B0(globalCtx, 0x1248, &this->actor); + Message_StartTextbox(globalCtx, 0x1248, &this->actor); this->actionFunc = func_80BBB8AC; func_80BBAE84(this, 6, 0); this->unk_2B6 |= 2; } else if (gSaveContext.weekEventReg[41] & 0x10) { - func_801518B0(globalCtx, 0x124A, &this->actor); + Message_StartTextbox(globalCtx, 0x124A, &this->actor); this->actionFunc = func_80BBB8AC; func_80BBAE84(this, 6, 0); } else { gSaveContext.weekEventReg[41] |= 0x10; - func_801518B0(globalCtx, 0x124B, &this->actor); + Message_StartTextbox(globalCtx, 0x124B, &this->actor); this->actionFunc = func_80BBB574; func_80BBAE84(this, 9, 2); this->unk_2B6 |= 0x10; @@ -495,7 +495,7 @@ void func_80BBBCBC(EnZos* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; func_80BBAE84(this, 5, 0); - func_801518B0(globalCtx, 0x124D, &this->actor); + Message_StartTextbox(globalCtx, 0x124D, &this->actor); this->actionFunc = func_80BBB574; } else { func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); @@ -504,7 +504,7 @@ void func_80BBBCBC(EnZos* this, GlobalContext* globalCtx) { void func_80BBBD5C(EnZos* this, GlobalContext* globalCtx) { func_80BBB414(this, globalCtx); - if (!func_800EE29C(globalCtx, 0x1F5)) { + if (!Cutscene_CheckActorAction(globalCtx, 0x1F5)) { this->actionFunc = func_80BBBCBC; this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); @@ -537,7 +537,7 @@ void func_80BBBDE0(EnZos* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80BBB8AC; func_80BBB15C(this, globalCtx); - } else if (func_800EE29C(globalCtx, 0x1F5)) { + } else if (Cutscene_CheckActorAction(globalCtx, 0x1F5)) { this->actionFunc = func_80BBBD5C; } else if (func_80BBAF5C(this, globalCtx)) { func_800B8614(&this->actor, globalCtx, 120.0f); @@ -572,7 +572,7 @@ void func_80BBBFBC(EnZos* this, GlobalContext* globalCtx) { textId = 0x1258; func_80BBAE84(this, 6, 0); } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80BBC070(EnZos* this, GlobalContext* globalCtx) { @@ -645,8 +645,8 @@ void func_80BBC298(EnZos* this, GlobalContext* globalCtx) { this->unk_2BC = 999; } - if (func_800EE29C(globalCtx, 0x203)) { - if (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x203)]->unk0 == 1) { + if (Cutscene_CheckActorAction(globalCtx, 515)) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 515)]->action == 1) { this->actionFunc = func_80BBC37C; this->unk_2BC = -1; } @@ -658,7 +658,8 @@ void func_80BBC298(EnZos* this, GlobalContext* globalCtx) { void func_80BBC37C(EnZos* this, GlobalContext* globalCtx) { func_80BBAFFC(this, globalCtx); - if (func_800EE29C(globalCtx, 0x203) && (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x203)]->unk0 == 3)) { + if (Cutscene_CheckActorAction(globalCtx, 515) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 515)]->action == 3)) { this->actionFunc = func_80BBC298; } } diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index 88314d496..18f5f13e3 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -374,7 +374,7 @@ void func_80B97110(EnZot* this, GlobalContext* globalCtx) { gSaveContext.weekEventReg[28] |= 0x40; } } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B97194(EnZot* this, GlobalContext* globalCtx) { @@ -440,7 +440,7 @@ void func_80B972E8(EnZot* this, GlobalContext* globalCtx) { gSaveContext.weekEventReg[29] |= 8; } } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { @@ -642,7 +642,7 @@ void func_80B9787C(EnZot* this, GlobalContext* globalCtx) { break; } } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } } @@ -711,7 +711,7 @@ void func_80B97BF8(EnZot* this, GlobalContext* globalCtx) { } else { textId = 0x128B; } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B97C40(EnZot* this, GlobalContext* globalCtx) { @@ -726,7 +726,7 @@ void func_80B97C40(EnZot* this, GlobalContext* globalCtx) { void func_80B97CC8(EnZot* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B97C40; - func_801518B0(globalCtx, 0x128B, &this->actor); + Message_StartTextbox(globalCtx, 0x128B, &this->actor); } else if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { func_800B8614(&this->actor, globalCtx, 120.0f); } @@ -894,7 +894,7 @@ void func_80B98178(EnZot* this, GlobalContext* globalCtx) { } break; } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B98348(EnZot* this, GlobalContext* globalCtx) { @@ -924,9 +924,9 @@ void func_80B9849C(EnZot* this, GlobalContext* globalCtx) { func_80B98348(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->unk_2D4 == 2) { - func_801518B0(globalCtx, 0x12AD, &this->actor); + Message_StartTextbox(globalCtx, 0x12AD, &this->actor); } else { - func_801518B0(globalCtx, 0x12B0, &this->actor); + Message_StartTextbox(globalCtx, 0x12B0, &this->actor); } this->actionFunc = func_80B98728; } else { @@ -1086,7 +1086,7 @@ void func_80B98A4C(EnZot* this, GlobalContext* globalCtx) { textId = 0x12B1; gSaveContext.weekEventReg[39] |= 0x40; } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { @@ -1125,10 +1125,10 @@ void func_80B98BF4(EnZot* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; if (gSaveContext.weekEventReg[41] & 0x20) { - func_801518B0(globalCtx, 0x12B7, &this->actor); + Message_StartTextbox(globalCtx, 0x12B7, &this->actor); this->actionFunc = func_80B98AD0; } else { - func_801518B0(globalCtx, 0x12B9, &this->actor); + Message_StartTextbox(globalCtx, 0x12B9, &this->actor); this->actionFunc = func_80B98AD0; } } else { @@ -1194,7 +1194,7 @@ void func_80B98E10(EnZot* this, GlobalContext* globalCtx) { textId = 0x12BB; } } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B98F30(EnZot* this, GlobalContext* globalCtx) { @@ -1264,7 +1264,7 @@ void func_80B99160(EnZot* this, GlobalContext* globalCtx) { textId = 0x12C6; gSaveContext.weekEventReg[40] |= 8; } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B991E4(EnZot* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.c b/src/overlays/actors/ovl_En_Zov/z_en_zov.c index b1b93217f..724f074da 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.c +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.c @@ -213,7 +213,7 @@ void func_80BD160C(EnZov* this, GlobalContext* globalCtx) { this->unk_320 |= 1; if (textId != 0) { - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } } @@ -314,7 +314,7 @@ void func_80BD19FC(EnZov* this, GlobalContext* globalCtx) { this->unk_324--; } else { func_80BD13DC(this); - func_801518B0(globalCtx, 0x1021, &this->actor); + Message_StartTextbox(globalCtx, 0x1021, &this->actor); ((EnElf*)(GET_PLAYER(globalCtx)->tatlActor))->unk_264 |= 4; Actor_ChangeFocus(&this->actor, globalCtx, GET_PLAYER(globalCtx)->tatlActor); this->actionFunc = func_80BD187C; @@ -328,11 +328,11 @@ void func_80BD19FC(EnZov* this, GlobalContext* globalCtx) { s32 func_80BD1AE0(EnZov* this, GlobalContext* globalCtx) { func_80BD1764(this); - if (func_800EE29C(globalCtx, 0x1F8)) { - s16 temp_v1 = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1F8)]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 504)) { + s16 action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 504)]->action; - if (temp_v1 != this->unk_326) { - this->unk_326 = temp_v1; + if (action != this->unk_326) { + this->unk_326 = action; switch (this->unk_326) { case 1: func_80BD1570(this, 0, 0); @@ -354,6 +354,7 @@ s32 func_80BD1AE0(EnZov* this, GlobalContext* globalCtx) { } return true; } + return false; } @@ -366,7 +367,7 @@ void func_80BD1BF0(EnZov* this, GlobalContext* globalCtx) { void func_80BD1C38(EnZov* this, GlobalContext* globalCtx) { if (func_80BD1AE0(this, globalCtx)) { - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x1F8)); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 504)); } } @@ -380,7 +381,7 @@ void func_80BD1C84(EnZov* this, GlobalContext* globalCtx) { func_800B8614(&this->actor, globalCtx, 120.0f); } - if (func_800EE29C(globalCtx, 0x1F8)) { + if (Cutscene_CheckActorAction(globalCtx, 0x1F8)) { this->actionFunc = func_80BD1BF0; func_80BD1BF0(this, globalCtx); } @@ -398,7 +399,7 @@ void func_80BD1D30(EnZov* this, GlobalContext* globalCtx) { } else { textId = 0x1031; } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80BD1D94(EnZov* this, GlobalContext* globalCtx) { @@ -476,7 +477,7 @@ void EnZov_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); - if (!func_800EE29C(globalCtx, 0x1F8)) { + if (!Cutscene_CheckActorAction(globalCtx, 0x1F8)) { this->unk_320 &= ~0x10; } diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.c b/src/overlays/actors/ovl_En_Zow/z_en_zow.c index 3ada9fc10..5fd785ad1 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -403,7 +403,7 @@ void func_80BDD1E0(EnZow* this, GlobalContext* globalCtx) { } else { phi_a1 = 0x12EF; } - func_801518B0(globalCtx, phi_a1, &this->actor); + Message_StartTextbox(globalCtx, phi_a1, &this->actor); } void func_80BDD350(EnZow* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c index 3a83c47f7..cf5269fc8 100644 --- a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c +++ b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c @@ -108,12 +108,12 @@ void func_80B3C4E0(ObjGhaka* this, GlobalContext* globalCtx) { case 0: func_8019F208(); this->dyna.actor.textId = 0xCF5; - func_801518B0(globalCtx, this->dyna.actor.textId, &this->dyna.actor); + Message_StartTextbox(globalCtx, this->dyna.actor.textId, &this->dyna.actor); break; case 1: func_8019F208(); this->dyna.actor.textId = 0xCF7; - func_801518B0(globalCtx, this->dyna.actor.textId, &this->dyna.actor); + Message_StartTextbox(globalCtx, this->dyna.actor.textId, &this->dyna.actor); break; case 2: func_8019F230(); diff --git a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c index 3f47e321f..6c37e68b5 100644 --- a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c +++ b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c @@ -128,13 +128,13 @@ void func_80BD433C(ObjHgdoor* this) { } void func_80BD4358(ObjHgdoor* this, GlobalContext* globalCtx) { - u32 actionIndex; + s32 actionIndex; - if (func_800EE29C(globalCtx, 0x1E3)) { - actionIndex = func_800EE200(globalCtx, 0x1E3); - if (this->unk166 != globalCtx->csCtx.npcActions[actionIndex]->unk0) { - this->unk166 = globalCtx->csCtx.npcActions[actionIndex]->unk0; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 483)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 483); + if (this->unk166 != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->unk166 = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOOD_DOOR_OPEN_SPEEDY); if ((this->dyna.actor.parent != NULL) && (this->dyna.actor.parent->id == ACTOR_EN_HG)) { diff --git a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c index 06c59bd7d..53d1d7669 100644 --- a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c +++ b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.c @@ -37,7 +37,7 @@ void ObjJgGakki_Init(Actor* thisx, GlobalContext* globalCtx2) { SkelAnime_Init(globalCtx, &this->skelAnime, &gGoronElderDrumSkel, NULL, NULL, NULL, 0); if (((globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7)) && - (globalCtx->csCtx.unk_12 == 0)) { + (globalCtx->csCtx.currentCsIndex == 0)) { Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, frameCount, frameCount, 2, 0.0f); } else if ((globalCtx->sceneNum == SCENE_17SETUGEN) || (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA)) { Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, 0.0f, frameCount, 2, 0.0f); diff --git a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c index bb7eb2343..a0fc2eff7 100644 --- a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c +++ b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c @@ -77,7 +77,7 @@ void func_80C06640(ObjMoonStone* this, GlobalContext* globalCtx) { sp1A -= player->actor.shape.rot.y; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.colChkInfo.health = 1; - func_801518B0(globalCtx, 0x5E3U, &this->actor); + Message_StartTextbox(globalCtx, 0x5E3U, &this->actor); func_80C066F8(this); } else { s32 phi_v0 = ABS_ALT(sp1A); diff --git a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c index 6b6923838..16ca76317 100644 --- a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c +++ b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c @@ -137,18 +137,18 @@ void func_80C06DC8(ObjMuPict* this, GlobalContext* globalCtx) { if (this->unk14A == 0) { if (this->unk148 == 0) { this->unk148 = 1; - func_801518B0(globalCtx, 0x159A, &this->actor); + Message_StartTextbox(globalCtx, 0x159A, &this->actor); this->textId = 0x159A; } else { - func_801518B0(globalCtx, 0x159D, &this->actor); + Message_StartTextbox(globalCtx, 0x159D, &this->actor); this->textId = 0x159D; } } else if (this->unk148 == 0) { this->unk148 = 1; - func_801518B0(globalCtx, 0x15A0, &this->actor); + Message_StartTextbox(globalCtx, 0x15A0, &this->actor); this->textId = 0x15A0; } else { - func_801518B0(globalCtx, 0x15A3, &this->actor); + Message_StartTextbox(globalCtx, 0x15A3, &this->actor); this->textId = 0x15A3; } } @@ -157,31 +157,31 @@ void func_80C06E88(ObjMuPict* this, GlobalContext* globalCtx) { if (func_80147624(globalCtx)) { switch (this->textId) { case 0x159A: - func_801518B0(globalCtx, 0x159B, &this->actor); + Message_StartTextbox(globalCtx, 0x159B, &this->actor); this->textId = 0x159B; break; case 0x159B: - func_801518B0(globalCtx, 0x159C, &this->actor); + Message_StartTextbox(globalCtx, 0x159C, &this->actor); this->textId = 0x159C; break; case 0x159D: - func_801518B0(globalCtx, 0x159E, &this->actor); + Message_StartTextbox(globalCtx, 0x159E, &this->actor); this->textId = 0x159E; break; case 0x159E: - func_801518B0(globalCtx, 0x159F, &this->actor); + Message_StartTextbox(globalCtx, 0x159F, &this->actor); this->textId = 0x159F; break; case 0x15A0: - func_801518B0(globalCtx, 0x15A1, &this->actor); + Message_StartTextbox(globalCtx, 0x15A1, &this->actor); this->textId = 0x15A1; break; case 0x15A1: - func_801518B0(globalCtx, 0x15A2, &this->actor); + Message_StartTextbox(globalCtx, 0x15A2, &this->actor); this->textId = 0x15A2; break; case 0x15A3: - func_801518B0(globalCtx, 0x15A4, &this->actor); + Message_StartTextbox(globalCtx, 0x15A4, &this->actor); this->textId = 0x15A4; break; } diff --git a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c index 65ba62f3c..9ff5b4599 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c @@ -193,7 +193,7 @@ void ObjTokeiStep_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); if ((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0)) { + (globalCtx->csCtx.currentCsIndex == 0)) { DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClocktowerPanelCol); ObjTokeiStep_InitSteps(this); ObjTokeiStep_SetupBeginOpen(this); @@ -221,9 +221,10 @@ void ObjTokeiStep_SetupBeginOpen(ObjTokeiStep* this) { void ObjTokeiStep_BeginOpen(ObjTokeiStep* this, GlobalContext* globalCtx) { CsCmdActorAction* action; - if (func_800EE29C(globalCtx, 0x86)) { - action = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x86)]; - if ((action->startFrame == globalCtx->csCtx.frames) && (action->unk0 != 0)) { + if (Cutscene_CheckActorAction(globalCtx, 134)) { + action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 134)]; + + if ((action->startFrame == globalCtx->csCtx.frames) && (action->action != 0)) { this->dyna.actor.draw = ObjTokeiStep_DrawOpen; ObjTokeiStep_SetupOpen(this); } diff --git a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c index 1e9029067..3ecac575f 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -122,9 +122,9 @@ void ObjTokeidai_ExteriorGear_Init(ObjTokeidai* this, GlobalContext* globalCtx) ObjTokeidai_SetupClockOrExteriorGear(this); if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0)) || + (globalCtx->csCtx.currentCsIndex == 0)) || ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0))) { + (globalCtx->csCtx.currentCsIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); } else if ((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->actionFunc = ObjTokeidai_ExteriorGear_OpenedIdle; @@ -141,9 +141,9 @@ void ObjTokeidai_TowerClock_Init(ObjTokeidai* this, GlobalContext* globalCtx) { ObjTokeidai_Clock_Init(this); if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0)) || + (globalCtx->csCtx.currentCsIndex == 0)) || ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0))) { + (globalCtx->csCtx.currentCsIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); } else if ((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->actor.world.pos.y += (this->actor.scale.y * 5191.0f) - 50.0f; @@ -176,9 +176,9 @@ void ObjTokeidai_Counterweight_Init(ObjTokeidai* this, GlobalContext* globalCtx) } if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0)) || + (globalCtx->csCtx.currentCsIndex == 0)) || ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0))) { + (globalCtx->csCtx.currentCsIndex == 0))) { this->spotlightIntensity = 0; ObjTokeidai_SetupTowerOpening(this); @@ -336,7 +336,8 @@ void ObjTokeidai_ExteriorGear_Collapse(ObjTokeidai* this, GlobalContext* globalC } void ObjTokeidai_ExteriorGear_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x84) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 2) { + if (Cutscene_CheckActorAction(globalCtx, 132) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 2) { this->actionFunc = ObjTokeidai_ExteriorGear_Collapse; this->actor.speedXZ = this->actor.scale.y * 5.0f; this->actor.velocity.y = 0.0f; @@ -403,7 +404,8 @@ void ObjTokeidai_TowerClock_SlideOff(ObjTokeidai* this, GlobalContext* globalCtx } void ObjTokeidai_TowerClock_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x84) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 1) { + if (Cutscene_CheckActorAction(globalCtx, 132) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 1) { this->actionFunc = ObjTokeidai_TowerClock_SlideOff; this->slidingClockFaceAngle = 0; this->aerialClockFaceSpeed = -0xD; @@ -420,7 +422,8 @@ void ObjTokeidai_Counterweight_Collapse(ObjTokeidai* this, GlobalContext* global } void ObjTokeidai_Counterweight_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x84) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 3) { + if (Cutscene_CheckActorAction(globalCtx, 132) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 3) { this->actionFunc = ObjTokeidai_Counterweight_Collapse; this->xRotation = 0; this->actor.velocity.y = 0.0f; @@ -436,19 +439,21 @@ void ObjTokeidai_TerminaFieldWalls_Collapse(ObjTokeidai* this, GlobalContext* gl } void ObjTokeidai_TerminaFieldWalls_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x84) != 0 && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 1) { + if (Cutscene_CheckActorAction(globalCtx, 132) != 0 && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 1) { this->actionFunc = ObjTokeidai_TerminaFieldWalls_Collapse; } } void ObjTokeidai_TowerOpening_EndCutscene(ObjTokeidai* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x84) != 0 && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 5) { + if (Cutscene_CheckActorAction(globalCtx, 132) != 0 && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 5) { gSaveContext.weekEventReg[8] |= 0x40; if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0)) || + (globalCtx->csCtx.currentCsIndex == 0)) || ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0))) { - func_801A3F54(false); + (globalCtx->csCtx.currentCsIndex == 0))) { + Audio_SetCutsceneFlag(false); gSaveContext.cutscene = 0; gSaveContext.nextCutsceneIndex = 0; gSaveContext.respawnFlag = 2; @@ -588,7 +593,8 @@ void ObjTokeidai_TowerOpening_RaiseTower(ObjTokeidai* this, GlobalContext* globa } void ObjTokeidai_TowerOpening_Start(ObjTokeidai* this, GlobalContext* globalCtx) { - if ((func_800EE29C(globalCtx, 0x84) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 4) || + if ((Cutscene_CheckActorAction(globalCtx, 132) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 4) || (gSaveContext.weekEventReg[8] & 0x40)) { this->actionFunc = ObjTokeidai_TowerOpening_RaiseTower; } diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index 5b0a5d433..324e53fee 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -349,10 +349,10 @@ void func_808DCBF8(ObjectKankyo* this, GlobalContext* globalCtx) { if (temp_f0 > 0.01f) { D_801F4E30 = 155.0f * temp_f0; - globalCtx->envCtx.unk_EA = 10; + globalCtx->envCtx.sandstormState = 10; } else { D_801F4E30 = 0; - globalCtx->envCtx.unk_EA = 10; + globalCtx->envCtx.sandstormState = 10; } func_808DC454(this, globalCtx); } diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.h b/src/overlays/gamestates/ovl_daytelop/z_daytelop.h index eca743850..d77a5f334 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.h +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.h @@ -1,5 +1,5 @@ -#ifndef _Z64_DAYTELOP_H_ -#define _Z64_DAYTELOP_H_ +#ifndef Z64_DAYTELOP_H +#define Z64_DAYTELOP_H #include "global.h" diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 5eae310c4..2c18ac2d0 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -381,7 +381,6 @@ animdict = { "func_8017F9C0": "Math3D_XZInSphere", "func_8017FA34": "Math3D_XYInSphere", "func_8017FAA8": "Math3D_YZInSphere", - "func_800DFB14": "Camera_ChangeDataIdx", "func_800DFC68": "Camera_GetInputDirYaw", "func_800DFCB4": "Camera_GetCamDirPitch", @@ -389,7 +388,6 @@ animdict = { "func_800E0308": "Camera_SetTargetActor", "func_800E031C": "Camera_GetWaterYPos", "func_800E02AC": "Camera_SetToTrackActor", - "func_801694DC": "Play_CreateSubCamera", "Play_GetActiveCameraIndex": "Play_GetActiveCamId", "func_80169590": "Play_CameraChangeStatus", @@ -403,9 +401,7 @@ animdict = { "func_80169BC4": "Play_CameraGetUID", "func_80169C64": "Play_GetCsCamDataSetting", "func_80169C84": "Play_GetCsCamDataVec3s", - "func_8017D2FC": "Math3D_LineSegVsPlane", - "func_8013A7C0": "SubS_FindDoor", "func_8013E640": "SubS_FindActorCustom", "func_ActorCategoryIterateById": "SubS_FindActor", @@ -413,7 +409,19 @@ animdict = { "func_800A81F0": "EffectBlure_AddVertex", "func_800A8514": "EffectBlure_AddSpace", "Effect_GetParams": "Effect_GetByIndex", - + "func_800F5A8C": "Environment_LerpWeight", + "func_801A3F54": "Audio_SetCutsceneFlag", + "func_801518B0": "Message_StartTextbox", + "func_800EA0D4": "Cutscene_Start", + "func_800EA0EC": "Cutscene_End", + "func_800EDE34": "Cutscene_ActorTranslate", + "func_800EDF24": "Cutscene_ActorTranslateAndYaw", + "func_800EDF78": "Cutscene_ActorTranslateAndYawSmooth", + "func_800EE0CC": "Cutscene_ActorTranslateXZAndYawSmooth", + "func_800EE1D8": "Cutscene_GetSceneSetupIndex", + "func_800EE200": "Cutscene_GetActorActionIndex", + "func_800EE29C": "Cutscene_CheckActorAction", + "func_800EE2F4": "Cutscene_IsPlaying", "func_801343C0": "SkelAnime_DrawTransformFlexOpa", "func_80134148": "SkelAnime_DrawTransformFlexLimbOpa", "func_8013AB00": "SubS_DrawTransformFlex", @@ -455,6 +463,14 @@ animdict = { "actor.yDistToPlayer": "actor.playerHeightRel", "globalCtx->mf_187FC": "globalCtx->billboardMtxF", "globalCtx->projectionMatrix": "globalCtx->viewProjectionMtxF", + "csCtx.npcActions": "csCtx.actorActions", + "csCtx->npcActions": "csCtx->actorActions", + "csCtx.unk_12": "csCtx.currentCsIndex", + "globalCtx->envCtx.unk_8C": "globalCtx->envCtx.lightSettings", + "globalCtx->envCtx.unk_E5": "globalCtx->envCtx.fillScreen", + "globalCtx->envCtx.unk_E6": "globalCtx->envCtx.screenFillColor", + "globalCtx->envCtx.unk_C3": "globalCtx->envCtx.lightSettingOverride", + "globalCtx->envCtx.unk_DC": "globalCtx->envCtx.lightBlend", "player->unk_A87": "player->exchangeItemId", "player->leftHandActor": "player->heldActor", "player->unk_384": "player->getItemId", @@ -462,8 +478,8 @@ animdict = { "player->unk_388": "player->interactRangeActor", "player->unk_38C": "player->mountSide", "player->unk_394": "player->csMode", - "player->unk_A87": "player->exchangeItemId", "globalCtx->actorCtx.actorList[": "globalCtx->actorCtx.actorLists[", + "gSaveContext.unk_3F58": "gSaveContext.sunsSongState", "globalCtx->msgCtx.unk1202A": "globalCtx->msgCtx.ocarinaMode", "globalCtx->msgCtx.unk1202C": "globalCtx->msgCtx.ocarinaAction", "globalCtx->msgCtx.unk11F22": "globalCtx->msgCtx.msgMode", diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index 66e4e88f3..fc9f9fc53 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -524,6 +524,7 @@ 0x801BA200 : "z_collision_check", 0x801BA550 : "z_debug_display", 0x801BB090 : "z_debug_mode", + 0x801BB120 : "z_demo", 0x801BB170 : "z_draw", 0x801BC240 : "z_eff_footmark", 0x801BC2A0 : "", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e378be114..b0efebcdf 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1534,36 +1534,36 @@ 0x800E9E94:("func_800E9E94",), 0x800E9F78:("func_800E9F78",), 0x800EA060:("Cutscene_Init",), - 0x800EA0D4:("func_800EA0D4",), - 0x800EA0EC:("func_800EA0EC",), - 0x800EA110:("Cutscene_StepCutscene1",), - 0x800EA15C:("Cutscene_StepCutscene2",), - 0x800EA210:("Cutscene_Nop800EA210",), + 0x800EA0D4:("Cutscene_Start",), + 0x800EA0EC:("Cutscene_End",), + 0x800EA110:("Cutscene_Update1",), + 0x800EA15C:("Cutscene_Update2",), + 0x800EA210:("Cutscene_DoNothing",), 0x800EA220:("func_800EA220",), 0x800EA258:("func_800EA258",), 0x800EA2B8:("func_800EA2B8",), - 0x800EA324:("func_800EA324",), - 0x800EABAC:("func_800EABAC",), - 0x800EAC08:("func_800EAC08",), - 0x800EAC44:("func_800EAC44",), - 0x800EAC94:("func_800EAC94",), - 0x800EAD14:("func_800EAD14",), + 0x800EA324:("Cutscene_Command_Misc",), + 0x800EABAC:("Cutscene_Command_SetLighting",), + 0x800EAC08:("Cutscene_Command_PlaySequence",), + 0x800EAC44:("Cutscene_Command_StopSequence",), + 0x800EAC94:("Cutscene_Command_FadeSequence",), + 0x800EAD14:("Cutscene_Command_PlayAmbienceSequence",), 0x800EAD48:("func_800EAD48",), 0x800EAD7C:("func_800EAD7C",), 0x800EADB0:("func_800EADB0",), - 0x800EAECC:("func_800EAECC",), - 0x800EAF20:("func_800EAF20",), - 0x800EAFE0:("func_800EAFE0",), - 0x800EB1DC:("func_800EB1DC",), - 0x800EB364:("func_800EB364",), - 0x800EB4B4:("func_800EB4B4",), - 0x800EB6F8:("func_800EB6F8",), - 0x800EBB68:("func_800EBB68",), - 0x800EBCD0:("func_800EBCD0",), - 0x800EBD60:("func_800EBD60",), - 0x800EC678:("func_800EC678",), - 0x800EC6D4:("func_800EC6D4",), - 0x800EC924:("func_800EC924",), + 0x800EAECC:("Cutscene_Command_FadeAmbienceSequence",), + 0x800EAF20:("Cutscene_Command_Rumble",), + 0x800EAFE0:("Cutscene_Command_FadeColorScreen",), + 0x800EB1DC:("Cutscene_Command_SetTime",), + 0x800EB364:("Cutscene_TerminatorImpl",), + 0x800EB4B4:("Cutscene_Command_Terminator",), + 0x800EB6F8:("Cutscene_Command_ChooseCreditsScenes",), + 0x800EBB68:("Cutscene_Command_MotionBlur",), + 0x800EBCD0:("Cutscene_Command_GiveTatlToPlayer",), + 0x800EBD60:("Cutscene_Command_TransitionFX",), + 0x800EC678:("Cutscene_Command_Camera",), + 0x800EC6D4:("Cutscene_CountNormalMasks",), + 0x800EC924:("Cutscene_Command_Textbox",), 0x800ECD7C:("func_800ECD7C",), 0x800ECE40:("Cutscene_ProcessCommands",), 0x800ED980:("func_800ED980",), @@ -1571,17 +1571,17 @@ 0x800EDA04:("func_800EDA04",), 0x800EDA84:("func_800EDA84",), 0x800EDBE0:("func_800EDBE0",), - 0x800EDDB0:("nop_800EDDB0",), + 0x800EDDB0:("func_800EDDB0",), 0x800EDDBC:("func_800EDDBC",), - 0x800EDDCC:("func_800EDDCC",), - 0x800EDE34:("func_800EDE34",), - 0x800EDF24:("func_800EDF24",), - 0x800EDF78:("func_800EDF78",), - 0x800EE0CC:("func_800EE0CC",), - 0x800EE1D8:("func_800EE1D8",), - 0x800EE200:("func_800EE200",), - 0x800EE29C:("func_800EE29C",), - 0x800EE2F4:("func_800EE2F4",), + 0x800EDDCC:("Cutscene_LoadCutsceneData",), + 0x800EDE34:("Cutscene_ActorTranslate",), + 0x800EDF24:("Cutscene_ActorTranslateAndYaw",), + 0x800EDF78:("Cutscene_ActorTranslateAndYawSmooth",), + 0x800EE0CC:("Cutscene_ActorTranslateXZAndYawSmooth",), + 0x800EE1D8:("Cutscene_GetSceneSetupIndex",), + 0x800EE200:("Cutscene_GetActorActionIndex",), + 0x800EE29C:("Cutscene_CheckActorAction",), + 0x800EE2F4:("Cutscene_IsPlaying",), 0x800EE320:("GetItem_Draw",), 0x800EE364:("func_800EE364",), 0x800EE400:("func_800EE400",), @@ -1710,7 +1710,7 @@ 0x800F50D4:("func_800F50D4",), 0x800F510C:("Kankyo_Init",), 0x800F5954:("func_800F5954",), - 0x800F5A8C:("func_800F5A8C",), + 0x800F5A8C:("Environment_LerpWeight",), 0x800F5B10:("func_800F5B10",), 0x800F5CD0:("func_800F5CD0",), 0x800F6834:("func_800F6834",), @@ -1738,7 +1738,7 @@ 0x800FAC20:("func_800FAC20",), 0x800FAF74:("func_800FAF74",), 0x800FB010:("func_800FB010",), - 0x800FB320:("func_800FB320",), + 0x800FB320:("Environment_AddLightningBolts",), 0x800FB388:("func_800FB388",), 0x800FB758:("func_800FB758",), 0x800FB9B4:("func_800FB9B4",), @@ -2852,7 +2852,7 @@ 0x80150A84:("func_80150A84",), 0x80150D08:("func_80150D08",), 0x801514B0:("func_801514B0",), - 0x801518B0:("func_801518B0",), + 0x801518B0:("Message_StartTextbox",), 0x80151938:("func_80151938",), 0x80151A68:("func_80151A68",), 0x80151BB4:("func_80151BB4",), @@ -3978,7 +3978,7 @@ 0x801A3D98:("func_801A3D98",), 0x801A3E38:("func_801A3E38",), 0x801A3EC0:("func_801A3EC0",), - 0x801A3F54:("func_801A3F54",), + 0x801A3F54:("Audio_SetCutsceneFlag",), 0x801A3F6C:("func_801A3F6C",), 0x801A3FB4:("func_801A3FB4",), 0x801A3FFC:("func_801A3FFC",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 3af06baa5..de2b2a42b 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -907,7 +907,7 @@ 0x801BB124:("D_801BB124","UNK_TYPE2","",0x2), 0x801BB128:("D_801BB128","UNK_TYPE2","",0x2), 0x801BB12C:("D_801BB12C","UNK_TYPE1","",0x1), - 0x801BB130:("D_801BB130","UNK_TYPE1","",0x1), + 0x801BB130:("sCutsceneStoredPlayerForm","UNK_TYPE1","",0x1), 0x801BB134:("sCsStateHandlers1","cutscene_update_func","[5]",0x14), 0x801BB148:("sCsStateHandlers2","cutscene_update_func","[5]",0x14), 0x801BB15C:("D_801BB15C","UNK_TYPE2","",0x2), @@ -3978,12 +3978,10 @@ 0x801F3F80:("D_801F3F80","UNK_TYPE1","",0x1), 0x801F3F83:("D_801F3F83","UNK_TYPE1","",0x1), 0x801F48C8:("D_801F48C8","UNK_TYPE1","",0x1), - 0x801F4D40:("D_801F4D40","UNK_TYPE1","",0x1), - 0x801F4D42:("D_801F4D42","UNK_TYPE2","",0x2), - 0x801F4D48:("D_801F4D48","UNK_TYPE1","",0x1), - 0x801F4DC8:("D_801F4DC8","UNK_TYPE1","",0x1), - 0x801F4DCA:("D_801F4DCA","UNK_TYPE1","",0x1), - 0x801F4DCC:("D_801F4DCC","UNK_TYPE2","[8]",0x10), + 0x801F4D40:("seqId","u16","",0x2), + 0x801F4D42:("sCutsceneQuakeIndex","UNK_TYPE2","",0x2), + 0x801F4D48:("sCutsceneCameraInfo","UNK_TYPE","",0x80), + 0x801F4DC8:("D_801F4DC8","u16","[10]",0x14), 0x801F4DDC:("D_801F4DDC","UNK_TYPE1","",0x1), 0x801F4DE0:("D_801F4DE0","UNK_TYPE1","",0x1), 0x801F4DE2:("D_801F4DE2","UNK_TYPE2","",0x2), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index f14ca7307..8ec9f8ca3 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1048,36 +1048,36 @@ asm/non_matchings/code/z_debug_mode/func_800E9DBC.s,func_800E9DBC,0x800E9DBC,0x3 asm/non_matchings/code/z_debug_mode/func_800E9E94.s,func_800E9E94,0x800E9E94,0x39 asm/non_matchings/code/z_debug_mode/func_800E9F78.s,func_800E9F78,0x800E9F78,0x3A asm/non_matchings/code/z_demo/Cutscene_Init.s,Cutscene_Init,0x800EA060,0x1D -asm/non_matchings/code/z_demo/func_800EA0D4.s,func_800EA0D4,0x800EA0D4,0x6 -asm/non_matchings/code/z_demo/func_800EA0EC.s,func_800EA0EC,0x800EA0EC,0x9 -asm/non_matchings/code/z_demo/Cutscene_StepCutscene1.s,Cutscene_StepCutscene1,0x800EA110,0x13 -asm/non_matchings/code/z_demo/Cutscene_StepCutscene2.s,Cutscene_StepCutscene2,0x800EA15C,0x2D -asm/non_matchings/code/z_demo/Cutscene_Nop800EA210.s,Cutscene_Nop800EA210,0x800EA210,0x4 +asm/non_matchings/code/z_demo/Cutscene_Start.s,Cutscene_Start,0x800EA0D4,0x6 +asm/non_matchings/code/z_demo/Cutscene_End.s,Cutscene_End,0x800EA0EC,0x9 +asm/non_matchings/code/z_demo/Cutscene_Update1.s,Cutscene_Update1,0x800EA110,0x13 +asm/non_matchings/code/z_demo/Cutscene_Update2.s,Cutscene_Update2,0x800EA15C,0x2D +asm/non_matchings/code/z_demo/Cutscene_DoNothing.s,Cutscene_DoNothing,0x800EA210,0x4 asm/non_matchings/code/z_demo/func_800EA220.s,func_800EA220,0x800EA220,0xE asm/non_matchings/code/z_demo/func_800EA258.s,func_800EA258,0x800EA258,0x18 asm/non_matchings/code/z_demo/func_800EA2B8.s,func_800EA2B8,0x800EA2B8,0x1B -asm/non_matchings/code/z_demo/func_800EA324.s,func_800EA324,0x800EA324,0x222 -asm/non_matchings/code/z_demo/func_800EABAC.s,func_800EABAC,0x800EABAC,0x17 -asm/non_matchings/code/z_demo/func_800EAC08.s,func_800EAC08,0x800EAC08,0xF -asm/non_matchings/code/z_demo/func_800EAC44.s,func_800EAC44,0x800EAC44,0x14 -asm/non_matchings/code/z_demo/func_800EAC94.s,func_800EAC94,0x800EAC94,0x20 -asm/non_matchings/code/z_demo/func_800EAD14.s,func_800EAD14,0x800EAD14,0xD +asm/non_matchings/code/z_demo/Cutscene_Command_Misc.s,Cutscene_Command_Misc,0x800EA324,0x222 +asm/non_matchings/code/z_demo/Cutscene_Command_SetLighting.s,Cutscene_Command_SetLighting,0x800EABAC,0x17 +asm/non_matchings/code/z_demo/Cutscene_Command_PlaySequence.s,Cutscene_Command_PlaySequence,0x800EAC08,0xF +asm/non_matchings/code/z_demo/Cutscene_Command_StopSequence.s,Cutscene_Command_StopSequence,0x800EAC44,0x14 +asm/non_matchings/code/z_demo/Cutscene_Command_FadeSequence.s,Cutscene_Command_FadeSequence,0x800EAC94,0x20 +asm/non_matchings/code/z_demo/Cutscene_Command_PlayAmbienceSequence.s,Cutscene_Command_PlayAmbienceSequence,0x800EAD14,0xD asm/non_matchings/code/z_demo/func_800EAD48.s,func_800EAD48,0x800EAD48,0xD asm/non_matchings/code/z_demo/func_800EAD7C.s,func_800EAD7C,0x800EAD7C,0xD asm/non_matchings/code/z_demo/func_800EADB0.s,func_800EADB0,0x800EADB0,0x47 -asm/non_matchings/code/z_demo/func_800EAECC.s,func_800EAECC,0x800EAECC,0x15 -asm/non_matchings/code/z_demo/func_800EAF20.s,func_800EAF20,0x800EAF20,0x30 -asm/non_matchings/code/z_demo/func_800EAFE0.s,func_800EAFE0,0x800EAFE0,0x7F -asm/non_matchings/code/z_demo/func_800EB1DC.s,func_800EB1DC,0x800EB1DC,0x62 -asm/non_matchings/code/z_demo/func_800EB364.s,func_800EB364,0x800EB364,0x54 -asm/non_matchings/code/z_demo/func_800EB4B4.s,func_800EB4B4,0x800EB4B4,0x91 -asm/non_matchings/code/z_demo/func_800EB6F8.s,func_800EB6F8,0x800EB6F8,0x11C -asm/non_matchings/code/z_demo/func_800EBB68.s,func_800EBB68,0x800EBB68,0x5A -asm/non_matchings/code/z_demo/func_800EBCD0.s,func_800EBCD0,0x800EBCD0,0x24 -asm/non_matchings/code/z_demo/func_800EBD60.s,func_800EBD60,0x800EBD60,0x246 -asm/non_matchings/code/z_demo/func_800EC678.s,func_800EC678,0x800EC678,0x17 -asm/non_matchings/code/z_demo/func_800EC6D4.s,func_800EC6D4,0x800EC6D4,0x94 -asm/non_matchings/code/z_demo/func_800EC924.s,func_800EC924,0x800EC924,0x116 +asm/non_matchings/code/z_demo/Cutscene_Command_FadeAmbienceSequence.s,Cutscene_Command_FadeAmbienceSequence,0x800EAECC,0x15 +asm/non_matchings/code/z_demo/Cutscene_Command_Rumble.s,Cutscene_Command_Rumble,0x800EAF20,0x30 +asm/non_matchings/code/z_demo/Cutscene_Command_FadeColorScreen.s,Cutscene_Command_FadeColorScreen,0x800EAFE0,0x7F +asm/non_matchings/code/z_demo/Cutscene_Command_SetTime.s,Cutscene_Command_SetTime,0x800EB1DC,0x62 +asm/non_matchings/code/z_demo/Cutscene_TerminatorImpl.s,Cutscene_TerminatorImpl,0x800EB364,0x54 +asm/non_matchings/code/z_demo/Cutscene_Command_Terminator.s,Cutscene_Command_Terminator,0x800EB4B4,0x91 +asm/non_matchings/code/z_demo/Cutscene_Command_ChooseCreditsScenes.s,Cutscene_Command_ChooseCreditsScenes,0x800EB6F8,0x11C +asm/non_matchings/code/z_demo/Cutscene_Command_MotionBlur.s,Cutscene_Command_MotionBlur,0x800EBB68,0x5A +asm/non_matchings/code/z_demo/Cutscene_Command_GiveTatlToPlayer.s,Cutscene_Command_GiveTatlToPlayer,0x800EBCD0,0x24 +asm/non_matchings/code/z_demo/Cutscene_Command_TransitionFX.s,Cutscene_Command_TransitionFX,0x800EBD60,0x246 +asm/non_matchings/code/z_demo/Cutscene_Command_Camera.s,Cutscene_Command_Camera,0x800EC678,0x17 +asm/non_matchings/code/z_demo/Cutscene_CountNormalMasks.s,Cutscene_CountNormalMasks,0x800EC6D4,0x94 +asm/non_matchings/code/z_demo/Cutscene_Command_Textbox.s,Cutscene_Command_Textbox,0x800EC924,0x116 asm/non_matchings/code/z_demo/func_800ECD7C.s,func_800ECD7C,0x800ECD7C,0x31 asm/non_matchings/code/z_demo/Cutscene_ProcessCommands.s,Cutscene_ProcessCommands,0x800ECE40,0x2D0 asm/non_matchings/code/z_demo/func_800ED980.s,func_800ED980,0x800ED980,0x11 @@ -1085,17 +1085,17 @@ asm/non_matchings/code/z_demo/func_800ED9C4.s,func_800ED9C4,0x800ED9C4,0x10 asm/non_matchings/code/z_demo/func_800EDA04.s,func_800EDA04,0x800EDA04,0x20 asm/non_matchings/code/z_demo/func_800EDA84.s,func_800EDA84,0x800EDA84,0x57 asm/non_matchings/code/z_demo/func_800EDBE0.s,func_800EDBE0,0x800EDBE0,0x74 -asm/non_matchings/code/z_demo/nop_800EDDB0.s,nop_800EDDB0,0x800EDDB0,0x3 +asm/non_matchings/code/z_demo/func_800EDDB0.s,func_800EDDB0,0x800EDDB0,0x3 asm/non_matchings/code/z_demo/func_800EDDBC.s,func_800EDDBC,0x800EDDBC,0x4 -asm/non_matchings/code/z_demo/func_800EDDCC.s,func_800EDDCC,0x800EDDCC,0x1A -asm/non_matchings/code/z_demo/func_800EDE34.s,func_800EDE34,0x800EDE34,0x3C -asm/non_matchings/code/z_demo/func_800EDF24.s,func_800EDF24,0x800EDF24,0x15 -asm/non_matchings/code/z_demo/func_800EDF78.s,func_800EDF78,0x800EDF78,0x55 -asm/non_matchings/code/z_demo/func_800EE0CC.s,func_800EE0CC,0x800EE0CC,0x43 -asm/non_matchings/code/z_demo/func_800EE1D8.s,func_800EE1D8,0x800EE1D8,0xA -asm/non_matchings/code/z_demo/func_800EE200.s,func_800EE200,0x800EE200,0x27 -asm/non_matchings/code/z_demo/func_800EE29C.s,func_800EE29C,0x800EE29C,0x16 -asm/non_matchings/code/z_demo/func_800EE2F4.s,func_800EE2F4,0x800EE2F4,0xB +asm/non_matchings/code/z_demo/Cutscene_LoadCutsceneData.s,Cutscene_LoadCutsceneData,0x800EDDCC,0x1A +asm/non_matchings/code/z_demo/Cutscene_ActorTranslate.s,Cutscene_ActorTranslate,0x800EDE34,0x3C +asm/non_matchings/code/z_demo/Cutscene_ActorTranslateAndYaw.s,Cutscene_ActorTranslateAndYaw,0x800EDF24,0x15 +asm/non_matchings/code/z_demo/Cutscene_ActorTranslateAndYawSmooth.s,Cutscene_ActorTranslateAndYawSmooth,0x800EDF78,0x55 +asm/non_matchings/code/z_demo/Cutscene_ActorTranslateXZAndYawSmooth.s,Cutscene_ActorTranslateXZAndYawSmooth,0x800EE0CC,0x43 +asm/non_matchings/code/z_demo/Cutscene_GetSceneSetupIndex.s,Cutscene_GetSceneSetupIndex,0x800EE1D8,0xA +asm/non_matchings/code/z_demo/Cutscene_GetActorActionIndex.s,Cutscene_GetActorActionIndex,0x800EE200,0x27 +asm/non_matchings/code/z_demo/Cutscene_CheckActorAction.s,Cutscene_CheckActorAction,0x800EE29C,0x16 +asm/non_matchings/code/z_demo/Cutscene_IsPlaying.s,Cutscene_IsPlaying,0x800EE2F4,0xB asm/non_matchings/code/z_draw/GetItem_Draw.s,GetItem_Draw,0x800EE320,0x11 asm/non_matchings/code/z_draw/func_800EE364.s,func_800EE364,0x800EE364,0x27 asm/non_matchings/code/z_draw/func_800EE400.s,func_800EE400,0x800EE400,0x7F @@ -1224,7 +1224,7 @@ asm/non_matchings/code/z_kankyo/func_800F5090.s,func_800F5090,0x800F5090,0x11 asm/non_matchings/code/z_kankyo/func_800F50D4.s,func_800F50D4,0x800F50D4,0xE asm/non_matchings/code/z_kankyo/Kankyo_Init.s,Kankyo_Init,0x800F510C,0x212 asm/non_matchings/code/z_kankyo/func_800F5954.s,func_800F5954,0x800F5954,0x4E -asm/non_matchings/code/z_kankyo/func_800F5A8C.s,func_800F5A8C,0x800F5A8C,0x21 +asm/non_matchings/code/z_kankyo/Environment_LerpWeight.s,Environment_LerpWeight,0x800F5A8C,0x21 asm/non_matchings/code/z_kankyo/func_800F5B10.s,func_800F5B10,0x800F5B10,0x70 asm/non_matchings/code/z_kankyo/func_800F5CD0.s,func_800F5CD0,0x800F5CD0,0x2D9 asm/non_matchings/code/z_kankyo/func_800F6834.s,func_800F6834,0x800F6834,0x46 @@ -1252,7 +1252,7 @@ asm/non_matchings/code/z_kankyo/func_800FAAB4.s,func_800FAAB4,0x800FAAB4,0x5B asm/non_matchings/code/z_kankyo/func_800FAC20.s,func_800FAC20,0x800FAC20,0xD5 asm/non_matchings/code/z_kankyo/func_800FAF74.s,func_800FAF74,0x800FAF74,0x27 asm/non_matchings/code/z_kankyo/func_800FB010.s,func_800FB010,0x800FB010,0xC4 -asm/non_matchings/code/z_kankyo/func_800FB320.s,func_800FB320,0x800FB320,0x1A +asm/non_matchings/code/z_kankyo/Environment_AddLightningBolts.s,Environment_AddLightningBolts,0x800FB320,0x1A asm/non_matchings/code/z_kankyo/func_800FB388.s,func_800FB388,0x800FB388,0xF4 asm/non_matchings/code/z_kankyo/func_800FB758.s,func_800FB758,0x800FB758,0x97 asm/non_matchings/code/z_kankyo/func_800FB9B4.s,func_800FB9B4,0x800FB9B4,0xC2 @@ -2366,7 +2366,7 @@ asm/non_matchings/code/z_message/func_8014D7B4.s,func_8014D7B4,0x8014D7B4,0xCB4 asm/non_matchings/code/z_message/func_80150A84.s,func_80150A84,0x80150A84,0xA1 asm/non_matchings/code/z_message/func_80150D08.s,func_80150D08,0x80150D08,0x1EA asm/non_matchings/code/z_message/func_801514B0.s,func_801514B0,0x801514B0,0x100 -asm/non_matchings/code/z_message/func_801518B0.s,func_801518B0,0x801518B0,0x22 +asm/non_matchings/code/z_message/Message_StartTextbox.s,Message_StartTextbox,0x801518B0,0x22 asm/non_matchings/code/z_message/func_80151938.s,func_80151938,0x80151938,0x4C asm/non_matchings/code/z_message/func_80151A68.s,func_80151A68,0x80151A68,0x53 asm/non_matchings/code/z_message/func_80151BB4.s,func_80151BB4,0x80151BB4,0x3A @@ -3496,7 +3496,7 @@ asm/non_matchings/code/code_8019AF00/func_801A3D54.s,func_801A3D54,0x801A3D54,0x asm/non_matchings/code/code_8019AF00/func_801A3D98.s,func_801A3D98,0x801A3D98,0x28 asm/non_matchings/code/code_8019AF00/func_801A3E38.s,func_801A3E38,0x801A3E38,0x22 asm/non_matchings/code/code_8019AF00/func_801A3EC0.s,func_801A3EC0,0x801A3EC0,0x25 -asm/non_matchings/code/code_8019AF00/func_801A3F54.s,func_801A3F54,0x801A3F54,0x6 +asm/non_matchings/code/code_8019AF00/Audio_SetCutsceneFlag.s,Audio_SetCutsceneFlag,0x801A3F54,0x6 asm/non_matchings/code/code_8019AF00/func_801A3F6C.s,func_801A3F6C,0x801A3F6C,0x12 asm/non_matchings/code/code_8019AF00/func_801A3FB4.s,func_801A3FB4,0x801A3FB4,0x12 asm/non_matchings/code/code_8019AF00/func_801A3FFC.s,func_801A3FFC,0x801A3FFC,0x4 diff --git a/tools/warnings_count/.gitignore b/tools/warnings_count/.gitignore index 5606ab0ef..eaf2f58b5 100644 --- a/tools/warnings_count/.gitignore +++ b/tools/warnings_count/.gitignore @@ -2,3 +2,4 @@ warnings_setup_new.txt warnings_disasm_new.txt warnings_build_new.txt +warnings_temp.txt From cf98c4e7e82d5c2442d3bf105d232edeb867ec6f Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 5 Mar 2022 13:49:01 +0000 Subject: [PATCH 058/257] Optional file disasm (#664) * Add optional file disasm * Fix for full --- tools/disasm/disasm.py | 380 ++++++++++++++++++++++------------------- 1 file changed, 205 insertions(+), 175 deletions(-) diff --git a/tools/disasm/disasm.py b/tools/disasm/disasm.py index e0b7705ea..103860ed2 100755 --- a/tools/disasm/disasm.py +++ b/tools/disasm/disasm.py @@ -18,6 +18,14 @@ parser.add_argument( default=False, help="Decompile all files regardless of whether they are used or not", ) +parser.add_argument( + "-files", + "--files", + dest="files", + nargs="+", + required=False, + help="Optional list of files to diassemble separated by a space. This is a whitelist, all files will be skipped besides the ones listed here if used.", +) args = parser.parse_args() jobs = args.jobs @@ -26,7 +34,7 @@ ASM_OUT = "asm/" DATA_OUT = "data/" -def discard_decomped_files(files_spec): +def discard_decomped_files(files_spec, include_files): root_path = Path(__file__).parent.parent.parent with open(root_path / "spec", "r") as f: @@ -38,6 +46,12 @@ def discard_decomped_files(files_spec): for f in files_spec: name, _, type, _, file_list = f + force_include = False + if include_files: + if not any([x in name for x in include_files]): + continue + force_include = True + # Find the beginseg for this file i = 0 while i < len(spec): @@ -92,6 +106,7 @@ def discard_decomped_files(files_spec): if "GLOBAL_ASM" in f2.read(): include = True + include |= force_include if include: new_files[offset] = file included = True @@ -2191,16 +2206,23 @@ for segment in files_spec: full_file_list[segment[0]] = new if args.full: + new_spec = [] for segment in files_spec: + if args.files and not any( + [file_name in segment[0] for file_name in args.files] + ): + continue for offset, name in segment[4].items(): if name == "": name = f"{segment[2]}_{offset:08X}" segment[4][offset] = name + new_spec.append(segment) + files_spec = new_spec else: # Prune old_file_count = sum([len(f[4].keys()) for f in files_spec]) - files_spec = discard_decomped_files(files_spec) + files_spec = discard_decomped_files(files_spec, args.files) new_file_count = sum([len(f[4].keys()) for f in files_spec]) @@ -2413,193 +2435,201 @@ rodata_symbols_regex = re.compile(r"(?<=\n)glabel (.+)(?=\n)") asm_symbols_regex = re.compile(r"%(?:lo|hi)\((.+?)\)") # Split files and migrate rodata that should be migrated -for root, dirs, files in os.walk(ASM_OUT): - for f in files: - if "non_matchings" in root: - continue - asm_path = os.path.join(root, f) - rodata_path = ( - asm_path.replace(ASM_OUT + "overlays/", DATA_OUT) - .replace(ASM_OUT, DATA_OUT) - .replace(".text.s", ".rodata.s") +for file in Path(ASM_OUT).glob("**/*.s"): + asm_path = str(file) + + if "non_matchings" in asm_path: + continue + + if file.parts[1] == "overlays": + name = file.parts[2] + else: + name = file.parts[1] + + if not any([name == section[-1]["name"] for section in all_sections]): + continue + + rodata_path = ( + asm_path.replace(ASM_OUT + "overlays/", DATA_OUT) + .replace(ASM_OUT, DATA_OUT) + .replace(".text.s", ".rodata.s") + ) + + print(asm_path) + + asm = "" + with open(asm_path, "r") as infile: + asm = infile.read() + + rodata = "" + if os.path.exists(rodata_path): + # print(rodata_path) + with open(rodata_path, "r") as rodata_file: + rodata = rodata_file.read() + + rodata_info = list(zip(rodata_syms(rodata), rodata_blocks(rodata))) + + # populate rdata and late_rodata lists + first_late_rodata = find_late_rodata_start(rodata_info) + rdata_info = [] + late_rodata_info = [] + target = rdata_info # first populate rdata + for sym, block in rodata_info: + # now populate late_rodata, if there is any + if sym == first_late_rodata: + target = late_rodata_info + target.append((sym, block)) + + # print([(sym,block.split("\n")[1:]) for sym,block in zip(rdata_syms,rdata_blocks)]) + + function_info = list( + zip( + [s.replace("glabel", "").strip() for s in func_regex.findall(asm)], + func_regex.split(asm)[1:], ) + ) - print(asm_path) + rdata_map = {} + late_rodata_map = {} - asm = "" - with open(asm_path, "r") as infile: - asm = infile.read() + # pass 1 to resolve rodata splits + if rodata != "": + last_fn = None - rodata = "" - if os.path.exists(rodata_path): - # print(rodata_path) - with open(rodata_path, "r") as rodata_file: - rodata = rodata_file.read() + referenced_in = {} # key=rodata label , value=function label - rodata_info = list(zip(rodata_syms(rodata), rodata_blocks(rodata))) + for sym, _ in rodata_info: + all_refs = [ + label for label, body in function_info if "%lo(" + sym + ")" in body + ] + # ignore multiple refs, take only the first + referenced_in.update({sym: all_refs[0] if len(all_refs) != 0 else None}) - # populate rdata and late_rodata lists - first_late_rodata = find_late_rodata_start(rodata_info) - rdata_info = [] - late_rodata_info = [] - target = rdata_info # first populate rdata - for sym, block in rodata_info: - # now populate late_rodata, if there is any - if sym == first_late_rodata: - target = late_rodata_info - target.append((sym, block)) + def do_splits(out_dict, info): + first = True + last_ref = None + cr = None + for sym, block in info: + ref = referenced_in[sym] + if first: + cr = ref or sym - # print([(sym,block.split("\n")[1:]) for sym,block in zip(rdata_syms,rdata_blocks)]) + if ref is not None and not first: + if ref != last_ref: + # existing function + cr = ref + elif last_ref is not None: + # new GLOBAL_ASM + cr = sym - function_info = list( - zip( - [s.replace("glabel", "").strip() for s in func_regex.findall(asm)], - func_regex.split(asm)[1:], - ) - ) + # add to output + if cr not in out_dict.keys(): + out_dict.update({cr: []}) + out_dict[cr].append((sym, block)) - rdata_map = {} - late_rodata_map = {} + # setup next iter + last_ref = ref + first = False + + do_splits(rdata_map, rdata_info) + do_splits(late_rodata_map, late_rodata_info) + + # all output files, order is irrelevant at this point + all_output = set([label for label, _ in function_info]).union( + set(rdata_map.keys()), set(late_rodata_map.keys()) + ) + + # pass 2 to output splits + for label in all_output: + fn_body = dict(function_info).get(label, None) + + text_out = "" + rodata_out = "" + + if fn_body is not None: + text_out = "glabel " + label.strip() + "\n" + fn_body.strip() + "\n" - # pass 1 to resolve rodata splits if rodata != "": - last_fn = None + rdata = rdata_map.get(label, None) + late_rodata = late_rodata_map.get(label, None) - referenced_in = {} # key=rodata label , value=function label - - for sym, _ in rodata_info: - all_refs = [ - label for label, body in function_info if "%lo(" + sym + ")" in body - ] - # ignore multiple refs, take only the first - referenced_in.update({sym: all_refs[0] if len(all_refs) != 0 else None}) - - def do_splits(out_dict, info): - first = True - last_ref = None - cr = None - for sym, block in info: - ref = referenced_in[sym] - if first: - cr = ref or sym - - if ref is not None and not first: - if ref != last_ref: - # existing function - cr = ref - elif last_ref is not None: - # new GLOBAL_ASM - cr = sym - - # add to output - if cr not in out_dict.keys(): - out_dict.update({cr: []}) - out_dict[cr].append((sym, block)) - - # setup next iter - last_ref = ref - first = False - - do_splits(rdata_map, rdata_info) - do_splits(late_rodata_map, late_rodata_info) - - # all output files, order is irrelevant at this point - all_output = set([label for label, _ in function_info]).union( - set(rdata_map.keys()), set(late_rodata_map.keys()) - ) - - # pass 2 to output splits - for label in all_output: - fn_body = dict(function_info).get(label, None) - - text_out = "" - rodata_out = "" - - if fn_body is not None: - text_out = "glabel " + label.strip() + "\n" + fn_body.strip() + "\n" - - if rodata != "": - rdata = rdata_map.get(label, None) - late_rodata = late_rodata_map.get(label, None) - - # check for late_rodata_alignment - late_rodata_alignment = "" - if fn_body is not None and late_rodata is not None: - ratio = late_rodata_size( - [block for _, block in late_rodata] - ) / text_block_size(fn_body) - if ratio > 1.0 / 3: - # print(f"{label} : {ratio}") - # TODO hack: getting the address from a comment - first_block_split = late_rodata[0][1].split(" */ .") - vaddr = None - if first_block_split[1].startswith( - "float" - ) or first_block_split[1].startswith("double"): - vaddr = first_block_split[0].split(" ")[-2] - else: - vaddr = first_block_split[0].split(" ")[-1] - assert vaddr is not None - vaddr = int(vaddr, 16) - if vaddr not in [ - 0x801E0E28, - 0x80C1C2B0, - 0x80AA7820, - 0x80AA3CC0, - 0x80AA418C, - 0x80BE0160, - 0x80B591D8, - 0x80B59610, - 0x80B59780, - 0x80964E00, - 0x80964F10, - 0x80BB40A0, - 0x80952038, - 0x80AFB920, - 0x80AFBBFC, - 0x80AFBE28, - 0x80983320, - ]: - # hacks for especially badly behaved rodata, TODO these are ALL jumptables associated with - # comparatively tiny functions, can we swat these programmatically? - late_rodata_alignment = f".late_rodata_alignment {'8' if vaddr % 8 == 0 else '4'}\n" - - rdata_out = "" - if rdata is not None: - rdata_out = ".rdata\n" + "".join([block for _, block in rdata]) - - late_rodata_out = "" - if late_rodata is not None: - late_rodata_out = ( - ".late_rodata\n" - + late_rodata_alignment - + "".join([block for _, block in late_rodata]) - ) - - rodata_out = ( - rdata_out - + late_rodata_out - + ( - "\n.text\n" - if ( - (rdata is not None or late_rodata is not None) - and fn_body is not None + # check for late_rodata_alignment + late_rodata_alignment = "" + if fn_body is not None and late_rodata is not None: + ratio = late_rodata_size( + [block for _, block in late_rodata] + ) / text_block_size(fn_body) + if ratio > 1.0 / 3: + # print(f"{label} : {ratio}") + # TODO hack: getting the address from a comment + first_block_split = late_rodata[0][1].split(" */ .") + vaddr = None + if first_block_split[1].startswith("float") or first_block_split[ + 1 + ].startswith("double"): + vaddr = first_block_split[0].split(" ")[-2] + else: + vaddr = first_block_split[0].split(" ")[-1] + assert vaddr is not None + vaddr = int(vaddr, 16) + if vaddr not in [ + 0x801E0E28, + 0x80C1C2B0, + 0x80AA7820, + 0x80AA3CC0, + 0x80AA418C, + 0x80BE0160, + 0x80B591D8, + 0x80B59610, + 0x80B59780, + 0x80964E00, + 0x80964F10, + 0x80BB40A0, + 0x80952038, + 0x80AFB920, + 0x80AFBBFC, + 0x80AFBE28, + 0x80983320, + ]: + # hacks for especially badly behaved rodata, TODO these are ALL jumptables associated with + # comparatively tiny functions, can we swat these programmatically? + late_rodata_alignment = ( + f".late_rodata_alignment {'8' if vaddr % 8 == 0 else '4'}\n" ) - else "" - ) + + rdata_out = "" + if rdata is not None: + rdata_out = ".rdata\n" + "".join([block for _, block in rdata]) + + late_rodata_out = "" + if late_rodata is not None: + late_rodata_out = ( + ".late_rodata\n" + + late_rodata_alignment + + "".join([block for _, block in late_rodata]) ) - all_out = rodata_out + text_out - - # write it out - out_path = ( - root.replace(ASM_OUT, f"{ASM_OUT}/non_matchings/") - + "/" - + ((f.replace(".text.s", "") + "/") if "overlays" not in root else "") + rodata_out = ( + rdata_out + + late_rodata_out + + ( + "\n.text\n" + if ( + (rdata is not None or late_rodata is not None) + and fn_body is not None + ) + else "" + ) ) - os.makedirs(out_path, exist_ok=True) - with open(out_path + label + ".s", "w") as outfile: - outfile.write(all_out.strip() + "\n") - # remove rodata and unsplit file - # TODO + all_out = rodata_out + text_out + + # write it out + out_path = Path(asm_path.replace(ASM_OUT, f"{ASM_OUT}non_matchings/")).parent + if out_path.parts[2] not in ("overlays", "makerom"): + out_path /= file.name.split(".")[0] + out_path.mkdir(parents=True, exist_ok=True) + + out_path /= label + ".s" + with open(out_path, "w") as outfile: + outfile.write(all_out.strip() + "\n") From aa6c31610247d2370227ebc9917e82acfdb167f6 Mon Sep 17 00:00:00 2001 From: emilybrooks Date: Sat, 5 Mar 2022 06:54:09 -0700 Subject: [PATCH 059/257] Ovl_En_Drs OK and Documented (#669) * done * merged master, some cleanup * more cleanup * review 1 * removed the skelAnime temp * format * prototype newline * globalctx2 --- assets/xml/objects/object_drs.xml | 33 +++---- assets/xml/objects/object_msmo.xml | 11 ++- spec | 3 +- src/overlays/actors/ovl_En_Drs/z_en_drs.c | 107 +++++++++++++++++----- src/overlays/actors/ovl_En_Drs/z_en_drs.h | 15 ++- tools/disasm/functions.txt | 10 +- undefined_syms.txt | 5 - 7 files changed, 123 insertions(+), 61 deletions(-) diff --git a/assets/xml/objects/object_drs.xml b/assets/xml/objects/object_drs.xml index 35202d17b..c5f4ee726 100644 --- a/assets/xml/objects/object_drs.xml +++ b/assets/xml/objects/object_drs.xml @@ -1,20 +1,21 @@  + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_msmo.xml b/assets/xml/objects/object_msmo.xml index cb08f53ef..6bfd0e46d 100644 --- a/assets/xml/objects/object_msmo.xml +++ b/assets/xml/objects/object_msmo.xml @@ -1,9 +1,10 @@  + - - - - - + + + + + diff --git a/spec b/spec index 5578d5a4d..f28afd8bb 100644 --- a/spec +++ b/spec @@ -5308,8 +5308,7 @@ beginseg name "ovl_En_Drs" compress include "build/src/overlays/actors/ovl_En_Drs/z_en_drs.o" - include "build/data/ovl_En_Drs/ovl_En_Drs.data.o" - include "build/data/ovl_En_Drs/ovl_En_Drs.reloc.o" + include "build/src/overlays/actors/ovl_En_Drs/ovl_En_Drs_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Drs/z_en_drs.c b/src/overlays/actors/ovl_En_Drs/z_en_drs.c index 81acb58cf..8643dfa91 100644 --- a/src/overlays/actors/ovl_En_Drs/z_en_drs.c +++ b/src/overlays/actors/ovl_En_Drs/z_en_drs.c @@ -1,7 +1,7 @@ /* * File: z_en_drs.c * Overlay: ovl_En_Drs - * Description: Wedding dress manequin + * Description: Anju's Wedding Dress Mannequin */ #include "z_en_drs.h" @@ -13,11 +13,10 @@ void EnDrs_Init(Actor* thisx, GlobalContext* globalCtx); void EnDrs_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDrs_Update(Actor* thisx, GlobalContext* globalCtx); +void EnDrs_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80C1E2D4(EnDrs* this, GlobalContext* globalCtx); -void func_80C1E3DC(EnDrs* this, GlobalContext* globalCtx); +void EnDrs_Idle(EnDrs* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Drs_InitVars = { ACTOR_EN_DRS, ACTORCAT_PROP, @@ -30,36 +29,98 @@ const ActorInit En_Drs_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C1E5E0 = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 16, 62, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80C1E60C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfoS sAnimations = { &gWeddingDressMannequinIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }; -extern ColliderCylinderInit D_80C1E5E0; -extern CollisionCheckInfoInit2 D_80C1E60C; +void EnDrs_CollisionUpdate(EnDrs* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -extern UNK_TYPE D_06000E70; -extern UNK_TYPE D_06005A78; +void EnDrs_Setup(EnDrs* this, GlobalContext* globalCtx) { + s32 pad[2]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/func_80C1E290.s") + if ((this->moonMaskObjBankIndex >= 0) && SubS_IsObjectLoaded(this->moonMaskObjBankIndex, globalCtx)) { + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWeddingDressMannequinSkel, NULL, this->jointTable, + this->morphTable, WEDDING_DRESS_MANNEQUIN_LIMB_MAX); + SubS_ChangeAnimationByInfoS(&this->skelAnime, &sAnimations, 0); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + Actor_SetScale(&this->actor, 0.01f); + this->actor.draw = EnDrs_Draw; + this->actionFunc = EnDrs_Idle; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/func_80C1E2D4.s") +void EnDrs_Idle(EnDrs* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/func_80C1E3DC.s") +void EnDrs_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDrs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/EnDrs_Init.s") + this->moonMaskObjBankIndex = SubS_GetObjectIndex(OBJECT_MSMO, globalCtx); + this->actionFunc = EnDrs_Setup; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/EnDrs_Destroy.s") +void EnDrs_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDrs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/EnDrs_Update.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/func_80C1E4B0.s") +void EnDrs_Update(Actor* thisx, GlobalContext* globalCtx) { + EnDrs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/func_80C1E568.s") + this->actionFunc(this, globalCtx); + if (this->actor.draw != NULL) { + SkelAnime_Update(&this->skelAnime); + EnDrs_CollisionUpdate(this, globalCtx); + } +} + +void EnDrs_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnDrs* this = THIS; + GlobalContext* globalCtx = globalCtx2; + s8 temp = this->moonMaskObjBankIndex; + s8 temp2 = this->actor.objBankIndex; + + // Anju removes the Moon Mask at the start of the Couple's Mask cutscene + // after that it will no longer be rendered. + if (!(gSaveContext.weekEventReg[87] & 2) && (limbIndex == WEDDING_DRESS_MANNEQUIN_LIMB_MASK)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[temp].segment); + gSPDisplayList(POLY_OPA_DISP++, &gMoonMaskDL); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[temp2].segment); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnDrs_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDrs* this = THIS; + + func_8012C5B0(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnDrs_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Drs/z_en_drs.h b/src/overlays/actors/ovl_En_Drs/z_en_drs.h index 191f272d6..1f59d601b 100644 --- a/src/overlays/actors/ovl_En_Drs/z_en_drs.h +++ b/src/overlays/actors/ovl_En_Drs/z_en_drs.h @@ -2,17 +2,22 @@ #define Z_EN_DRS_H #include "global.h" +#include "objects/object_drs/object_drs.h" +#include "objects/object_msmo/object_msmo.h" struct EnDrs; typedef void (*EnDrsActionFunc)(struct EnDrs*, GlobalContext*); typedef struct EnDrs { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnDrsActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x80]; -} EnDrs; // size = 0x20C + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnDrsActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ Vec3s jointTable[WEDDING_DRESS_MANNEQUIN_LIMB_MAX]; + /* 0x1F0 */ Vec3s morphTable[WEDDING_DRESS_MANNEQUIN_LIMB_MAX]; + /* 0x208 */ s8 moonMaskObjBankIndex; +} EnDrs; // size = 0x20C */ extern const ActorInit En_Drs_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index b0efebcdf..add2c9daf 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16974,14 +16974,14 @@ 0x80C1E108:("DmNb_Update",), 0x80C1E168:("DmNb_TransformLimbDraw",), 0x80C1E17C:("DmNb_Draw",), - 0x80C1E290:("func_80C1E290",), - 0x80C1E2D4:("func_80C1E2D4",), - 0x80C1E3DC:("func_80C1E3DC",), + 0x80C1E290:("EnDrs_CollisionUpdate",), + 0x80C1E2D4:("EnDrs_Setup",), + 0x80C1E3DC:("EnDrs_Idle",), 0x80C1E3EC:("EnDrs_Init",), 0x80C1E424:("EnDrs_Destroy",), 0x80C1E450:("EnDrs_Update",), - 0x80C1E4B0:("func_80C1E4B0",), - 0x80C1E568:("func_80C1E568",), + 0x80C1E4B0:("EnDrs_PostLimbDraw",), + 0x80C1E568:("EnDrs_Draw",), 0x80C1E690:("EnEndingHero_Init",), 0x80C1E738:("EnEndingHero_Destroy",), 0x80C1E748:("func_80C1E748",), diff --git a/undefined_syms.txt b/undefined_syms.txt index d0ef176fd..52b9e239e 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1272,11 +1272,6 @@ D_801C20C0 = 0x801C20C0; D_06004398 = 0x06004398; D_060048B8 = 0x060048B8; -// ovl_En_Drs - -D_06000E70 = 0x06000E70; -D_06005A78 = 0x06005A78; - // ovl_En_Ds2n D_06008038 = 0x06008038; From 5f9e906727a5e0620679ec791a61266296b63ac8 Mon Sep 17 00:00:00 2001 From: Averane <57575687+Averane1@users.noreply.github.com> Date: Sat, 5 Mar 2022 09:58:54 -0400 Subject: [PATCH 060/257] EnHeishi OK and documented (#597) * EnHeishi first pass * fixed references to updated function names * fixed references to updated function names part 2 * removed unnecessary externs * pr fixes * fix header * fix object files to match demoheishi changes * cleanup * PR comments addressed * merge master * use actors flags with change for demoheishi too --- spec | 3 +- .../actors/ovl_En_Heishi/z_en_heishi.c | 165 ++++++++++++++++-- .../actors/ovl_En_Heishi/z_en_heishi.h | 43 ++++- tools/disasm/functions.txt | 10 +- tools/disasm/variables.txt | 6 +- undefined_syms.txt | 5 - 6 files changed, 195 insertions(+), 37 deletions(-) diff --git a/spec b/spec index f28afd8bb..2e6d4629d 100644 --- a/spec +++ b/spec @@ -4908,8 +4908,7 @@ beginseg name "ovl_En_Heishi" compress include "build/src/overlays/actors/ovl_En_Heishi/z_en_heishi.o" - include "build/data/ovl_En_Heishi/ovl_En_Heishi.data.o" - include "build/data/ovl_En_Heishi/ovl_En_Heishi.reloc.o" + include "build/src/overlays/actors/ovl_En_Heishi/ovl_En_Heishi_reloc.o" endseg beginseg 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 c05a06a56..14bbf6a99 100644 --- a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c +++ b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c @@ -5,6 +5,7 @@ */ #include "z_en_heishi.h" +#include "objects/object_sdn/object_sdn.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -15,9 +16,19 @@ void EnHeishi_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHeishi_Update(Actor* thisx, GlobalContext* globalCtx); void EnHeishi_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BE9214(EnHeishi* this, GlobalContext* globalCtx); +void EnHeishi_ChangeAnimation(EnHeishi* this, s32 animIndex); +void EnHeishi_SetHeadRotation(EnHeishi* this); +void EnHeishi_SetupIdle(EnHeishi* this); +void EnHeishi_Idle(EnHeishi* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ HEISHI_ANIMATION_STAND_HAND_ON_HIP, + /* 1 */ HEISHI_ANIMATION_CHEER_WITH_SPEAR, + /* 2 */ HEISHI_ANIMATION_WAVE, + /* 3 */ HEISHI_ANIMATION_SIT_AND_REACH, + /* 4 */ HEISHI_ANIMATION_STAND_UP +} EnHeishiAnimationIndex; -#if 0 const ActorInit En_Heishi_InitVars = { ACTOR_EN_HEISHI, ACTORCAT_NPC, @@ -30,33 +41,151 @@ const ActorInit En_Heishi_InitVars = { (ActorFunc)EnHeishi_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BE9450 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 20, 60, 0, { 0, 0, 0 } }, }; -#endif +void EnHeishi_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi* this = THIS; -extern ColliderCylinderInit D_80BE9450; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSoldierSkeleton, &gSoldierWave, this->jointTable, + this->morphTable, HEISHI_LIMB_MAX); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->paramsCopy = this->actor.params; + this->yawTowardsPlayer = this->actor.world.rot.y; -extern UNK_TYPE D_06003BFC; + if (this->paramsCopy == 0) { + this->shouldSetHeadRotation = 1; + if (!(gSaveContext.weekEventReg[63] & 0x80) && !((gSaveContext.day == 3) && gSaveContext.isNight)) { + Actor_MarkForDeath(&this->actor); + } + } else { + this->colliderCylinder.dim.radius = 30; + this->colliderCylinder.dim.height = 60; + this->colliderCylinder.dim.yShift = 0; + if ((gSaveContext.weekEventReg[63] & 0x80) || ((gSaveContext.day == 3) && gSaveContext.isNight)) { + Actor_MarkForDeath(&this->actor); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/EnHeishi_Init.s") + this->actor.targetMode = 6; + this->actor.gravity = -3.0f; + Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + this->actor.flags |= ACTOR_FLAG_8000000; + EnHeishi_SetupIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/EnHeishi_Destroy.s") +void EnHeishi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/func_80BE90BC.s") + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/func_80BE9148.s") +void EnHeishi_ChangeAnimation(EnHeishi* this, s32 animIndex) { + static AnimationHeader* sAnimations[] = { + &gSoldierStandHandOnHip, &gSoldierCheerWithSpear, &gSoldierWave, &gSoldierSitAndReach, &gSoldierStandUp, + }; + static u8 sAnimModes[] = { + 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, + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/func_80BE91DC.s") + this->animIndex = animIndex; + this->frameCount = Animation_GetLastFrame(sAnimations[this->animIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->frameCount, + sAnimModes[this->animIndex], -10.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/func_80BE9214.s") +void EnHeishi_SetHeadRotation(EnHeishi* this) { + s16 yawDiff = this->yawTowardsPlayer - this->actor.world.rot.y; + s32 absYawDiff = ABS_ALT(yawDiff); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/EnHeishi_Update.s") + this->headRotXTarget = 0; + if ((this->actor.xzDistToPlayer < 200.0f) && (absYawDiff < 0x4E20)) { + this->headRotXTarget = this->yawTowardsPlayer - this->actor.world.rot.y; + if (this->headRotXTarget > 0x2710) { + this->headRotXTarget = 0x2710; + } else if (this->headRotXTarget < -0x2710) { + this->headRotXTarget = -0x2710; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/func_80BE9380.s") +void EnHeishi_SetupIdle(EnHeishi* this) { + s8 animIndex = HEISHI_ANIMATION_STAND_HAND_ON_HIP; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/EnHeishi_Draw.s") + EnHeishi_ChangeAnimation(this, animIndex); + this->unk278 = animIndex; + this->actionFunc = EnHeishi_Idle; +} + +void EnHeishi_Idle(EnHeishi* this, GlobalContext* globalCtx) { +} + +void EnHeishi_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHeishi* this = THIS; + + SkelAnime_Update(&this->skelAnime); + if (this->timer != 0) { + this->timer--; + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + if ((this->paramsCopy != 0) && (gSaveContext.day == 3) && gSaveContext.isNight) { + Actor_MarkForDeath(&this->actor); + } else { + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 29); + Actor_SetScale(&this->actor, 0.01f); + if (this->shouldSetHeadRotation) { + EnHeishi_SetHeadRotation(this); + } + + Actor_SetFocus(&this->actor, 60.0f); + Math_SmoothStepToS(&this->headRotX, this->headRotXTarget, 1, 3000, 0); + Math_SmoothStepToS(&this->headRotY, this->headRotYTarget, 1, 1000, 0); + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } +} + +s32 EnHeishi_OverrideLimbDraw(GlobalContext* globalctx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnHeishi* this = THIS; + + if (limbIndex == HEISHI_LIMB_HEAD) { + rot->x += this->headRotX; + rot->y += this->headRotY; + rot->z += this->headRotZ; + } + + return false; +} + +void EnHeishi_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnHeishi_OverrideLimbDraw, NULL, &this->actor); +} 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 8ceb74a00..de65bac72 100644 --- a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h +++ b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h @@ -7,13 +7,48 @@ struct EnHeishi; typedef void (*EnHeishiActionFunc)(struct EnHeishi*, GlobalContext*); +typedef enum { + /* 0 */ HEISHI_LIMB_NONE, + /* 1 */ HEISHI_LIMB_ROOT, + /* 2 */ HEISHI_LIMB_PELVIS, + /* 3 */ HEISHI_LIMB_LEFT_THIGH, + /* 4 */ HEISHI_LIMB_LEFT_CALF, + /* 5 */ HEISHI_LIMB_LEFT_FOOT, + /* 6 */ HEISHI_LIMB_RIGHT_THIGH, + /* 7 */ HEISHI_LIMB_RIGHT_CALF, + /* 8 */ HEISHI_LIMB_RIGHT_FOOT, + /* 9 */ HEISHI_LIMB_TORSO, + /* 10 */ HEISHI_LIMB_LEFT_SHOULDER, + /* 11 */ HEISHI_LIMB_LEFT_FOREARM, + /* 12 */ HEISHI_LIMB_LEFT_HAND, + /* 13 */ HEISHI_LIMB_RIGHT_SHOULDER, + /* 14 */ HEISHI_LIMB_RIGHT_FOREARM, + /* 15 */ HEISHI_LIMB_RIGHT_HAND_WITH_SPEAR, + /* 16 */ HEISHI_LIMB_HEAD, + /* 17 */ HEISHI_LIMB_MAX +} EnHeishiLimbs; + typedef struct EnHeishi { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x110]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[HEISHI_LIMB_MAX]; + /* 0x01EE */ Vec3s morphTable[HEISHI_LIMB_MAX]; /* 0x0254 */ EnHeishiActionFunc actionFunc; - /* 0x0258 */ char unk_258[0x78]; + /* 0x0258 */ s16 headRotY; + /* 0x025A */ s16 headRotX; + /* 0x025C */ s16 headRotZ; + /* 0x025E */ s16 headRotYTarget; + /* 0x0260 */ s16 headRotXTarget; + /* 0x0262 */ s16 headRotZTarget; + /* 0x0264 */ s32 animIndex; + /* 0x0268 */ s32 paramsCopy; + /* 0x026C */ s32 shouldSetHeadRotation; + /* 0x0270 */ s16 timer; + /* 0x0272 */ s16 yawTowardsPlayer; + /* 0x0274 */ f32 frameCount; + /* 0x0278 */ s16 unk278; // set and not used + /* 0x027C */ UNK_TYPE1 unk_27C[0x8]; + /* 0x0284 */ ColliderCylinder colliderCylinder; } EnHeishi; // size = 0x2D0 -extern const ActorInit En_Heishi_InitVars; - #endif // Z_EN_HEISHI_H diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index add2c9daf..af671a723 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16161,12 +16161,12 @@ 0x80BE8D94:("EnBaisen_Draw",), 0x80BE8F20:("EnHeishi_Init",), 0x80BE9090:("EnHeishi_Destroy",), - 0x80BE90BC:("func_80BE90BC",), - 0x80BE9148:("func_80BE9148",), - 0x80BE91DC:("func_80BE91DC",), - 0x80BE9214:("func_80BE9214",), + 0x80BE90BC:("EnHeishi_ChangeAnimation",), + 0x80BE9148:("EnHeishi_SetHeadRotation",), + 0x80BE91DC:("EnHeishi_SetupIdle",), + 0x80BE9214:("EnHeishi_Idle",), 0x80BE9224:("EnHeishi_Update",), - 0x80BE9380:("func_80BE9380",), + 0x80BE9380:("EnHeishi_OverrideLimbDraw",), 0x80BE93D8:("EnHeishi_Draw",), 0x80BE9510:("EnDemoheishi_Init",), 0x80BE95C0:("EnDemoheishi_Destroy",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index de2b2a42b..4ecb30b80 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -16173,9 +16173,9 @@ 0x80BE8E4C:("D_80BE8E4C","UNK_TYPE1","",0x1), 0x80BE8E58:("D_80BE8E58","UNK_TYPE1","",0x1), 0x80BE9430:("En_Heishi_InitVars","UNK_TYPE1","",0x1), - 0x80BE9450:("D_80BE9450","UNK_TYPE1","",0x1), - 0x80BE947C:("D_80BE947C","UNK_TYPE1","",0x1), - 0x80BE9490:("D_80BE9490","UNK_TYPE1","",0x1), + 0x80BE9450:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80BE947C:("sAnimations","UNK_TYPE1","",0x1), + 0x80BE9490:("sAnimModes","UNK_TYPE1","",0x1), 0x80BE9A30:("En_Demo_heishi_InitVars","UNK_TYPE1","",0x1), 0x80BE9A50:("sCylinderInit","UNK_TYPE1","",0x1), 0x80BE9A7C:("sTextIds","UNK_TYPE1","",0x1), diff --git a/undefined_syms.txt b/undefined_syms.txt index 52b9e239e..d3f4c29eb 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1388,11 +1388,6 @@ D_060000C0 = 0x060000C0; D_06000444 = 0x06000444; D_06002FD0 = 0x06002FD0; -// ovl_En_Heishi - -D_06003BFC = 0x06003BFC; -D_0600D640 = 0x0600D640; - // ovl_En_Hgo D_0600B644 = 0x0600B644; From f4a9d117b159c239d63cdfe004bb1aea050e3d9b Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 5 Mar 2022 06:03:59 -0800 Subject: [PATCH 061/257] En_Syateki_Crow (Shooting Gallery Guay) OK (#694) * EnSyatekiCrow_Init OK * EnSyatekiCrow_Destroy OK * func_809CA5D4 * func_809CA67C OK * func_809CA71C OK * func_809CA840 OK * func_809CA8E4 OK * EnSyatekiCrow_Update OK * func_809CAAF8 OK * func_809CABC0 OK * func_809CACD0 OK * EnSyatekiCrow_Draw OK * func_809CAE5C OK * func_809CAF2C OK * Migrate data to C * Object symbols * Use generated reloc * Name static variables * Name LimbDraw functions * Remove struct padding * Respond to review * Respond to Elliptic's review --- spec | 3 +- .../ovl_En_Syateki_Crow/z_en_syateki_crow.c | 295 ++++++++++++++++-- .../ovl_En_Syateki_Crow/z_en_syateki_crow.h | 24 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 5 - 5 files changed, 289 insertions(+), 42 deletions(-) diff --git a/spec b/spec index 2e6d4629d..d468b1e79 100644 --- a/spec +++ b/spec @@ -2453,8 +2453,7 @@ beginseg name "ovl_En_Syateki_Crow" compress include "build/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.o" - include "build/data/ovl_En_Syateki_Crow/ovl_En_Syateki_Crow.data.o" - include "build/data/ovl_En_Syateki_Crow/ovl_En_Syateki_Crow.reloc.o" + include "build/src/overlays/actors/ovl_En_Syateki_Crow/ovl_En_Syateki_Crow_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c index ca3e3d694..1b6397f25 100644 --- a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c +++ b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c @@ -5,6 +5,8 @@ */ #include "z_en_syateki_crow.h" +#include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" +#include "objects/object_crow/object_crow.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) @@ -15,7 +17,15 @@ void EnSyatekiCrow_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiCrow_Update(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiCrow_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_809CA5D4(EnSyatekiCrow* this); +void func_809CA67C(EnSyatekiCrow* this, GlobalContext* globalCtx); +void func_809CA71C(EnSyatekiCrow* this); +void func_809CA840(EnSyatekiCrow* this, GlobalContext* globalCtx); +void func_809CA8E4(EnSyatekiCrow* this, GlobalContext* globalCtx); +void func_809CABC0(EnSyatekiCrow* this, GlobalContext* globalCtx); + +static Vec3f D_809CB050 = { 0.0f, 0.0f, 0.0f }; + const ActorInit En_Syateki_Crow_InitVars = { ACTOR_EN_SYATEKI_CROW, ACTORCAT_ENEMY, @@ -28,60 +38,287 @@ const ActorInit En_Syateki_Crow_InitVars = { (ActorFunc)EnSyatekiCrow_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_809CB07C[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 60, 0 }, 50 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809CB0A0 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809CB07C, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809CB0B0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 3000, ICHAIN_CONTINUE), ICHAIN_S8(hintId, 88, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -#endif +static Vec3f D_809CB0C0 = { 0.0f, 20.0f, 0.0f }; -extern ColliderJntSphElementInit D_809CB07C[1]; -extern ColliderJntSphInit D_809CB0A0; -extern InitChainEntry D_809CB0B0[]; +static Vec3f D_809CB0CC = { 0.0f, 0.0f, 0.0f }; -extern UNK_TYPE D_060000F0; +static Vec3f D_809CB0D8 = { 2500.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/EnSyatekiCrow_Init.s") +void EnSyatekiCrow_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnSyatekiCrow* this = THIS; + Path* path; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + s32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/EnSyatekiCrow_Destroy.s") + path = syatekiMan->path; + while (path->unk2 != 0) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CA5D4.s") + temp = 0; + while (temp < EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor)) { + temp++; + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CA67C.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_crow_Skel_0010C0, &object_crow_Anim_0000F0, + this->jointTable, this->morphTable, 9); + Collider_InitJntSph(globalCtx, &this->unk_23C); + Collider_SetJntSph(globalCtx, &this->unk_23C, &this->actor, &sJntSphInit, &this->unk_25C); + this->unk_23C.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; + ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CA71C.s") + if ((path == NULL) || (EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor) >= 0x80)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CA840.s") + this->unk_1C8 = Lib_SegmentedToVirtual(path->points); + this->unk_1CC = 1; + this->unk_1CE = path->count; + this->unk_1C4 = 0x14; + this->unk_1BC = 0; + func_809CA5D4(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CA8E4.s") +void EnSyatekiCrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiCrow* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CAAF8.s") + Collider_DestroyJntSph(globalCtx, &this->unk_23C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CABC0.s") +void func_809CA5D4(EnSyatekiCrow* this) { + Actor_SetScale(&this->actor, 0.03f); + this->actor.speedXZ = 0.0f; + this->actor.gravity = 0.0f; + this->actor.world = this->actor.home; + this->actor.prevPos = this->actor.home.pos; + this->actor.shape.rot = this->actor.world.rot; + this->unk_1CC = 1; + this->actor.draw = NULL; + this->actionFunc = func_809CA67C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CACD0.s") +void func_809CA67C(EnSyatekiCrow* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/EnSyatekiCrow_Update.s") + if ((syatekiMan->unk_26A == 1) && (this->unk_1C2 == 1) && + (syatekiMan->unk_274 & (1 << EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor)))) { + func_809CA71C(this); + } else if (syatekiMan->unk_26A != 1) { + this->unk_1C2 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CAE5C.s") + if ((syatekiMan->unk_274 == 0) && (syatekiMan->unk_274 == 0)) { + this->unk_1C2 = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CAF2C.s") +void func_809CA71C(EnSyatekiCrow* this) { + Vec3f sp24; + s16 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/EnSyatekiCrow_Draw.s") + this->actor.world.pos.x = this->unk_1C8[0].x; + this->actor.world.pos.y = this->unk_1C8[0].y; + this->actor.world.pos.z = this->unk_1C8[0].z; + sp24.x = this->unk_1C8[this->unk_1CC].x; + sp24.y = this->unk_1C8[this->unk_1CC].y; + sp24.z = this->unk_1C8[this->unk_1CC].z; + temp = Math_Vec3f_Yaw(&this->actor.world.pos, &sp24); + this->actor.world.rot.y = temp; + this->actor.shape.rot.y = temp; + temp = Math_Vec3f_Pitch(&this->actor.world.pos, &sp24); + this->actor.shape.rot.x = temp; + this->actor.world.rot.x = temp; + this->actor.draw = EnSyatekiCrow_Draw; + this->actionFunc = func_809CA840; +} + +void func_809CA840(EnSyatekiCrow* this, GlobalContext* globalCtx) { + if (((EN_SYATEKI_CROW_GET_PARAM_F(&this->actor) * 20) + 20) < this->unk_1BC) { + Actor_PlaySfxAtPos(this->actor.parent, NA_SE_EN_KAICHO_CRY); + this->unk_1BC = 0; + this->actor.speedXZ = EN_SYATEKI_CROW_GET_PARAM_F0(&this->actor) + 6.0f; + this->actor.gravity = -0.5f; + this->actionFunc = func_809CA8E4; + } else { + this->unk_1BC++; + } +} + +void func_809CA8E4(EnSyatekiCrow* this, GlobalContext* globalCtx) { + Vec3f sp34; + f32 sp30; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (syatekiMan->unk_26A != 1) { + func_809CA5D4(this); + return; + } + + sp34.x = this->unk_1C8[this->unk_1CC].x; + sp34.y = this->unk_1C8[this->unk_1CC].y; + sp34.z = this->unk_1C8[this->unk_1CC].z; + + sp30 = Math_Vec3f_DistXZ(&this->actor.world.pos, &sp34); + this->unk_1C0 = Math_Vec3f_Yaw(&this->actor.world.pos, &sp34); + this->unk_1BE = Math_Vec3f_Pitch(&this->actor.world.pos, &sp34); + + if (sp30 > 100.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_1C0, 5, 0x3000, 0x100); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->actor.shape.rot.x, this->unk_1BE, 5, 0x3000, 0x100); + this->actor.world.rot.x = -this->actor.shape.rot.x; + } else if (this->unk_1CC < (this->unk_1CE - 1)) { + this->unk_1CC++; + } else { + this->unk_1C2 = 0; + syatekiMan->unk_274 &= ~(1 << EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor)); + func_809CA5D4(this); + } + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.yOffset = (fabsf(this->skelAnime.curFrame - 3.0f) * 150.0f) + 1700.0f; + if ((syatekiMan->unk_26C % 90) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); + } +} + +void func_809CAAF8(EnSyatekiCrow* this) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + syatekiMan->unk_280 += 60; + this->unk_1C2 = 0; + this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); + this->actor.velocity.y = 0.0f; + Animation_Change(&this->skelAnime, &object_crow_Anim_0000F0, 0.4f, 0.0f, 0.0f, 1, -3.0f); + this->actor.bgCheckFlags &= ~1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_DEAD); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + this->actionFunc = func_809CABC0; +} + +void func_809CABC0(EnSyatekiCrow* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + this->actor.colorFilterTimer = 40; + + if (this->actor.colorFilterParams & 0x4000) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x200); + this->actor.shape.rot.z += 0x1780; + } + + if (this->unk_1C4 > 20) { + func_800B3030(globalCtx, &this->actor.world.pos, &D_809CB050, &D_809CB050, this->actor.scale.x * 10000.0f, 0, + 0); + syatekiMan->unk_27A++; + syatekiMan->unk_274 &= ~(1 << EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor)); + func_809CA5D4(this); + } + + this->unk_1C4++; +} + +void func_809CACD0(EnSyatekiCrow* this, GlobalContext* globalCtx) { + if (this->actionFunc == func_809CA8E4) { + if (this->unk_23C.base.acFlags & AC_HIT) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + this->unk_1C4 = 0; + this->unk_23C.base.acFlags &= ~AC_HIT; + EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_809CB0C0, &D_809CB0CC, 5, 1); + func_809CAAF8(this); + } else { + this->unk_23C.elements->dim.worldSphere.center.x = this->actor.world.pos.x; + this->unk_23C.elements->dim.worldSphere.center.y = + sJntSphInit.elements[0].dim.modelSphere.center.y + this->actor.world.pos.y; + this->unk_23C.elements->dim.worldSphere.center.z = this->actor.world.pos.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->unk_23C.base); + } + } +} + +void EnSyatekiCrow_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiCrow* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->actionFunc != func_809CABC0) { + Actor_MoveWithoutGravity(&this->actor); + } else { + Actor_MoveWithGravity(&this->actor); + } + + func_809CACD0(this, globalCtx); +} + +s32 EnSyatekiCrow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnSyatekiCrow* this = THIS; + + if (limbIndex == 7) { + rot->y += (s16)(3072.0f * sin_rad(this->skelAnime.curFrame * 0.7853982f)); + } else if (limbIndex == 8) { + rot->y += (s16)(5120.0f * sin_rad((this->skelAnime.curFrame + 2.5f) * 0.7853982f)); + } + + return false; +} + +void EnSyatekiCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnSyatekiCrow* this = THIS; + Vec3f* sp1C; + + if (limbIndex == 2) { + Matrix_MultiplyVector3fByState(&D_809CB0D8, &this->unk_144[0]); + this->unk_144[0].y -= 20.0f; + } else if ((limbIndex == 4) || (limbIndex == 6) || (limbIndex == 8)) { + sp1C = &this->unk_144[(limbIndex >> 1) - 1]; + Matrix_MultiplyVector3fByState(&D_809CB050, sp1C); + sp1C->y -= 20.0f; + } +} + +void EnSyatekiCrow_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiCrow* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnSyatekiCrow_OverrideLimbDraw, EnSyatekiCrow_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.h b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.h index 48c9305dd..8946e213f 100644 --- a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.h +++ b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.h @@ -3,15 +3,31 @@ #include "global.h" +#define EN_SYATEKI_CROW_GET_PARAM_F(thisx) ((thisx)->params & 0xF) +#define EN_SYATEKI_CROW_GET_PARAM_F0(thisx) (((thisx)->params & 0xF0) >> 4) +#define EN_SYATEKI_CROW_GET_PARAM_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + struct EnSyatekiCrow; typedef void (*EnSyatekiCrowActionFunc)(struct EnSyatekiCrow*, GlobalContext*); typedef struct EnSyatekiCrow { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x74]; - /* 0x01B8 */ EnSyatekiCrowActionFunc actionFunc; - /* 0x01BC */ char unk_1BC[0xE0]; + /* 0x000 */ Actor actor; + /* 0x144 */ Vec3f unk_144[4]; + /* 0x174 */ SkelAnime skelAnime; + /* 0x1B8 */ EnSyatekiCrowActionFunc actionFunc; + /* 0x1BC */ s16 unk_1BC; + /* 0x1BE */ s16 unk_1BE; + /* 0x1C0 */ s16 unk_1C0; + /* 0x1C2 */ s16 unk_1C2; + /* 0x1C4 */ s16 unk_1C4; + /* 0x1C8 */ Vec3s* unk_1C8; + /* 0x1CC */ s16 unk_1CC; + /* 0x1CE */ s16 unk_1CE; + /* 0x1D0 */ Vec3s jointTable[9]; + /* 0x206 */ Vec3s morphTable[9]; + /* 0x23C */ ColliderJntSph unk_23C; + /* 0x25C */ ColliderJntSphElement unk_25C; } EnSyatekiCrow; // size = 0x29C extern const ActorInit En_Syateki_Crow_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index af671a723..a98db6787 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -9134,8 +9134,8 @@ 0x809CABC0:("func_809CABC0",), 0x809CACD0:("func_809CACD0",), 0x809CADE8:("EnSyatekiCrow_Update",), - 0x809CAE5C:("func_809CAE5C",), - 0x809CAF2C:("func_809CAF2C",), + 0x809CAE5C:("EnSyatekiCrow_OverrideLimbDraw",), + 0x809CAF2C:("EnSyatekiCrow_PostLimbDraw",), 0x809CAFEC:("EnSyatekiCrow_Draw",), 0x809CB200:("EnBoj04_Init",), 0x809CB210:("EnBoj04_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index d3f4c29eb..781df3269 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1790,11 +1790,6 @@ D_0600D640 = 0x0600D640; D_06006C18 = 0x06006C18; D_0600D640 = 0x0600D640; -// ovl_En_Syateki_Crow - -D_060000F0 = 0x060000F0; -D_060010C0 = 0x060010C0; - // ovl_En_Syateki_Dekunuts D_06001E50 = 0x06001E50; From 888448decfad4920c90d2354c0303e34342659f1 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 5 Mar 2022 14:10:55 +0000 Subject: [PATCH 062/257] Obj_Hakaisi (#655) * Obj_Hakaisi * Fix * PR --- assets/xml/objects/object_hakaisi.xml | 2 +- spec | 3 +- .../actors/ovl_En_Rail_Skb/z_en_rail_skb.c | 28 +- .../actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c | 419 ++++++++++++++++-- .../actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h | 16 +- undefined_syms.txt | 10 +- 6 files changed, 418 insertions(+), 60 deletions(-) diff --git a/assets/xml/objects/object_hakaisi.xml b/assets/xml/objects/object_hakaisi.xml index 82e80242e..227fc4cf8 100644 --- a/assets/xml/objects/object_hakaisi.xml +++ b/assets/xml/objects/object_hakaisi.xml @@ -10,6 +10,6 @@ - + diff --git a/spec b/spec index d468b1e79..08ffa0543 100644 --- a/spec +++ b/spec @@ -3879,8 +3879,7 @@ beginseg name "ovl_Obj_Hakaisi" compress include "build/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.o" - include "build/data/ovl_Obj_Hakaisi/ovl_Obj_Hakaisi.data.o" - include "build/data/ovl_Obj_Hakaisi/ovl_Obj_Hakaisi.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hakaisi/ovl_Obj_Hakaisi_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c index b2850d7d1..f29f3b6a7 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c @@ -564,8 +564,8 @@ void func_80B71910(EnRailSkb* this) { } void func_80B71954(EnRailSkb* this, GlobalContext* globalCtx) { - s16 sp36 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->actor.world.pos); - f32 sp30 = Math_Vec3f_DistXZ(&this->actor.world.pos, &this->unk_22C->actor.world.pos); + s16 sp36 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->dyna.actor.world.pos); + f32 sp30 = Math_Vec3f_DistXZ(&this->actor.world.pos, &this->unk_22C->dyna.actor.world.pos); Math_SmoothStepToS(&this->actor.shape.rot.y, sp36, 1, 0x71C, 0xB6); this->actor.world.rot = this->actor.shape.rot; @@ -582,24 +582,24 @@ void func_80B71A08(EnRailSkb* this) { } void func_80B71A58(EnRailSkb* this, GlobalContext* globalCtx) { - s16 sp36 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->actor.world.pos); + s16 sp36 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->dyna.actor.world.pos); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - if (this->unk_2E8 < this->unk_22C->actor.colChkInfo.health) { - this->unk_22C->actor.colChkInfo.health--; + if (this->unk_2E8 < this->unk_22C->dyna.actor.colChkInfo.health) { + this->unk_22C->dyna.actor.colChkInfo.health--; } else { - this->unk_22C->actor.colChkInfo.health--; + this->unk_22C->dyna.actor.colChkInfo.health--; func_80B71B6C(this); } } if (Animation_OnFrame(&this->skelAnime, 3.0f)) { - if (this->unk_2E8 < this->unk_22C->actor.colChkInfo.health) { - this->unk_22C->actor.colChkInfo.health--; + if (this->unk_2E8 < this->unk_22C->dyna.actor.colChkInfo.health) { + this->unk_22C->dyna.actor.colChkInfo.health--; } else { - this->unk_22C->actor.colChkInfo.health--; + this->unk_22C->dyna.actor.colChkInfo.health--; func_80B71B6C(this); } } @@ -616,7 +616,7 @@ void func_80B71B6C(EnRailSkb* this) { void func_80B71BB8(EnRailSkb* this, GlobalContext* globalCtx) { s32 pad; s32 i; - f32 sp34 = Math_Vec3f_DistXZ(&this->actor.world.pos, &this->unk_22C->actor.world.pos); + f32 sp34 = Math_Vec3f_DistXZ(&this->actor.world.pos, &this->unk_22C->dyna.actor.world.pos); if (this->unk_3F2 > 0) { this->unk_3F2--; @@ -624,15 +624,15 @@ void func_80B71BB8(EnRailSkb* this, GlobalContext* globalCtx) { } Math_SmoothStepToS(&this->actor.shape.rot.y, - Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->actor.world.pos), 1, 0x71C, 0xB6); + Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->dyna.actor.world.pos), 1, 0x71C, 0xB6); - if ((this->actor.bgCheckFlags & 1) && (this->unk_22C->actor.colChkInfo.health == 0)) { + if ((this->actor.bgCheckFlags & 1) && (this->unk_22C->dyna.actor.colChkInfo.health == 0)) { Actor_MoveWithGravity(&this->actor); } else { this->actor.velocity.y += this->actor.gravity; this->actor.world.pos.y += this->actor.velocity.y; - Math_SmoothStepToF(&this->actor.world.pos.x, this->unk_22C->actor.world.pos.x, 0.6f, 1.6f, 0.1f); - Math_SmoothStepToF(&this->actor.world.pos.z, this->unk_22C->actor.world.pos.z, 0.6f, 1.6f, 0.1f); + Math_SmoothStepToF(&this->actor.world.pos.x, this->unk_22C->dyna.actor.world.pos.x, 0.6f, 1.6f, 0.1f); + Math_SmoothStepToF(&this->actor.world.pos.z, this->unk_22C->dyna.actor.world.pos.z, 0.6f, 1.6f, 0.1f); } if (this->actor.bgCheckFlags & 2) { diff --git a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c index f347b6a6d..4b96d3a77 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c @@ -5,6 +5,7 @@ */ #include "z_obj_hakaisi.h" +#include "objects/object_hakaisi/object_hakaisi.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_20) @@ -15,7 +16,27 @@ void ObjHakaisi_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHakaisi_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHakaisi_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B1444C(ObjHakaisi* this); +void func_80B14460(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B14510(ObjHakaisi* this); +void func_80B14524(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B14558(ObjHakaisi* this); +void func_80B1456C(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B145F4(ObjHakaisi* this); +void func_80B14648(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B149A8(ObjHakaisi* this); +void func_80B149C0(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B14A24(ObjHakaisi* this, GlobalContext* globalCtx, Vec3f vec); +void func_80B14B6C(ObjHakaisi* this, GlobalContext* globalCtx, Vec3f vec, s16 arg3); +void func_80B14CF8(GlobalContext* globalCtx, Vec3f vec, s16 arg2, s16 arg3, s32 arg4); +void func_80B14F4C(ObjHakaisi* this, GlobalContext* globalCtx, s32 arg2); +void func_80B151E0(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B15254(Actor* thisx, GlobalContext* globalCtx); +void func_80B15264(ObjHakaisi* this); +void func_80B15330(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B1544C(Actor* thisx, GlobalContext* globalCtx); +void func_80B154A0(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Obj_Hakaisi_InitVars = { ACTOR_OBJ_HAKAISI, ACTORCAT_PROP, @@ -28,57 +49,395 @@ const ActorInit Obj_Hakaisi_InitVars = { (ActorFunc)ObjHakaisi_Draw, }; -#endif +Vec3f D_80B155B0 = { 0.0f, 25.0f, 30.0f }; -extern UNK_TYPE D_06001F10; -extern UNK_TYPE D_060021B0; -extern UNK_TYPE D_06002650; -extern UNK_TYPE D_06002FC4; +Vec3f D_80B155BC[] = { { 0.0f, 65.0f, 8.0f }, { 0.0f, 35.0f, 8.0f }, { 0.0f, 15.0f, 8.0f } }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/ObjHakaisi_Init.s") +Vec3f D_80B155E0 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/ObjHakaisi_Destroy.s") +Vec3f D_80B155EC = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B1444C.s") +Color_RGBA8 D_80B155F8 = { 170, 130, 90, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14460.s") +Color_RGBA8 D_80B155FC = { 100, 60, 20, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14510.s") +Vec3f D_80B15600 = { 1.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14524.s") +void ObjHakaisi_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjHakaisi* this = THIS; + CollisionHeader* sp7C = NULL; + MtxF sp3C; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14558.s") + switch (OBJHAKAISI_GET_FF(&this->dyna.actor)) { + case 0: + this->dyna.actor.textId = 0x13F9; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B1456C.s") + case 1: + this->dyna.actor.textId = 0x13FA; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B145F4.s") + case 2: + this->dyna.actor.textId = 0x13FB; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14648.s") + case 3: + this->dyna.actor.textId = 0x13FC; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B149A8.s") + case 4: + case 5: + func_80B151E0(this, globalCtx); + return; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B149C0.s") + default: + this->dyna.actor.textId = 0x1412; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14A24.s") + Actor_SetScale(&this->dyna.actor, 1.0f); + this->dyna.actor.targetMode = 0; + this->dyna.actor.colChkInfo.health = 30; + if (OBJHAKAISI_GET_FF(&this->dyna.actor) == 3) { + this->dyna.actor.draw = NULL; + func_80B1444C(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14B6C.s") + DynaPolyActor_Init(&this->dyna, 1); + CollisionHeader_GetVirtual(&object_hakaisi_Colheader_002FC4, &sp7C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14CF8.s") + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp7C); + this->unk_19A = 0; + this->unk_198 = 0; + this->switchFlag = OBJHAKAISI_GET_SWITCHFLAG(thisx); + this->unk_196 = this->dyna.actor.cutscene; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14F4C.s") + if (this->switchFlag == 0xFF) { + this->switchFlag = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/ObjHakaisi_Update.s") + if ((this->switchFlag != -1) && Flags_GetSwitch(globalCtx, this->switchFlag)) { + Actor_MarkForDeath(&this->dyna.actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/ObjHakaisi_Draw.s") + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B151E0.s") + if (this->dyna.actor.floorPoly == NULL) { + Actor_MarkForDeath(&this->dyna.actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B15254.s") + func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, + this->dyna.actor.world.pos.z, &sp3C); + Matrix_SetCurrentState(&sp3C); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); + Matrix_CopyCurrentState(&sp3C); + func_8018219C(&sp3C, &this->dyna.actor.shape.rot, 1); + this->dyna.actor.world.rot = this->dyna.actor.shape.rot; + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&D_80B155B0, &this->dyna.actor.focus.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B15264.s") + for (i = 0; i < ARRAY_COUNT(D_80B155BC); i++) { + Matrix_MultiplyVector3fByState(&D_80B155BC[i], &this->unk_160[i]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B15330.s") + func_80B1444C(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B1544C.s") +void ObjHakaisi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjHakaisi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B154A0.s") + if (OBJHAKAISI_GET_FF(&this->dyna.actor) != 3) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} + +void func_80B1444C(ObjHakaisi* this) { + this->actionFunc = func_80B14460; +} + +void func_80B14460(ObjHakaisi* this, GlobalContext* globalCtx) { + s16 sp26 = BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.yawTowardsPlayer); + + if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state)) { + func_80B14510(this); + } else if (this->dyna.actor.textId != 0) { + if (ABS_ALT(sp26) < 0x2000) { + func_800B8614(&this->dyna.actor, globalCtx, 100.0f); + } + } + + if (this->unk_198 == 1) { + func_80B14558(this); + } +} + +void func_80B14510(ObjHakaisi* this) { + this->actionFunc = func_80B14524; +} + +void func_80B14524(ObjHakaisi* this, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { + func_80B1444C(this); + } +} + +void func_80B14558(ObjHakaisi* this) { + this->actionFunc = func_80B1456C; +} + +void func_80B1456C(ObjHakaisi* this, GlobalContext* globalCtx) { + if (this->unk_196 != -1) { + if (ActorCutscene_GetCanPlayNext(this->unk_196)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_196, &this->dyna.actor); + } else { + ActorCutscene_SetIntentToPlay(this->unk_196); + } + } + if (this->dyna.actor.colChkInfo.health < 30) { + func_80B145F4(this); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} + +void func_80B145F4(ObjHakaisi* this) { + this->unk_19A = 0; + this->dyna.actor.flags |= ACTOR_FLAG_8000000; + this->dyna.actor.flags &= ~ACTOR_FLAG_1; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); + this->actionFunc = func_80B14648; +} + +void func_80B14648(ObjHakaisi* this, GlobalContext* globalCtx) { + if (this->unk_19A < 2) { + func_80B14CF8(globalCtx, this->unk_160[this->unk_194], 100, 30, 5); + } + + this->unk_19A++; + + if (this->dyna.actor.colChkInfo.health == 0) { + func_80B14A24(this, globalCtx, this->unk_160[this->unk_194]); + func_80B14A24(this, globalCtx, this->unk_160[this->unk_194]); + func_80B14B6C(this, globalCtx, this->unk_160[this->unk_194], 70); + Flags_SetSwitch(globalCtx, this->switchFlag); + this->dyna.actor.draw = NULL; + func_80B149A8(this); + } + + if (this->unk_19E != this->dyna.actor.colChkInfo.health) { + if ((this->unk_19E > 20) && (this->dyna.actor.colChkInfo.health <= 20)) { + func_80B14A24(this, globalCtx, this->unk_160[this->unk_194]); + func_80B14A24(this, globalCtx, this->unk_160[this->unk_194]); + func_80B14F4C(this, globalCtx, 0); + func_80B14B6C(this, globalCtx, this->unk_160[this->unk_194], 40); + this->unk_194 = 1; + } else if ((this->unk_19E > 10) && (this->dyna.actor.colChkInfo.health <= 10)) { + func_80B14A24(this, globalCtx, this->unk_160[this->unk_194]); + func_80B14A24(this, globalCtx, this->unk_160[this->unk_194]); + func_80B14B6C(this, globalCtx, this->unk_160[this->unk_194], 60); + this->unk_194 = 2; + } + this->unk_19A = 0; + this->dyna.actor.shape.yOffset -= 3.0f; + } + + Math_ApproachZeroF(&this->dyna.actor.shape.yOffset, 0.8f, 100.0f); + this->unk_19E = this->dyna.actor.colChkInfo.health; +} + +void func_80B149A8(ObjHakaisi* this) { + this->unk_19A = 0; + this->actionFunc = func_80B149C0; +} + +void func_80B149C0(ObjHakaisi* this, GlobalContext* globalCtx) { + if (this->unk_19A < 60) { + this->unk_19A++; + } else if ((this->unk_196 != -1) && !ActorCutscene_GetCanPlayNext(this->unk_196)) { + ActorCutscene_Stop(this->unk_196); + } +} + +void func_80B14A24(ObjHakaisi* this, GlobalContext* globalCtx, Vec3f vec) { + s32 i; + + func_80B14CF8(globalCtx, vec, 100, 30, 5); + + for (i = 0; i < 5; i++) { + vec.x += Rand_Centered() * 20.0f; + vec.y += Rand_ZeroOne() * 5.0f; + vec.z += Rand_Centered() * 20.0f; + EffectSsHahen_SpawnBurst(globalCtx, &vec, 5.0f, 0, 20, 15, 3, OBJECT_HAKAISI, 10, object_hakaisi_DL_0021B0); + } +} + +void func_80B14B6C(ObjHakaisi* this, GlobalContext* globalCtx, Vec3f vec, s16 arg3) { + s32 i; + s16 temp_s1; + Vec3f sp6C; + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); + + for (i = 0; i < 5; i++) { + temp_s1 = Rand_Next(); + + sp6C.x = (Math_SinS(temp_s1) * 15.0f) + vec.x; + sp6C.y = (Rand_ZeroOne() * 3.0f) + vec.y; + sp6C.z = (Math_CosS(temp_s1) * 15.0f) + vec.z; + + EffectSsHahen_SpawnBurst(globalCtx, &sp6C, 10.0f, 0, arg3, 30, 2, OBJECT_HAKAISI, 15, object_hakaisi_DL_0021B0); + } + + func_80B14CF8(globalCtx, vec, 100, 50, 20); +} + +void func_80B14CF8(GlobalContext* globalCtx, Vec3f vec, s16 arg2, s16 arg3, s32 arg4) { + s32 i; + s16 temp_s0; + Vec3f spAC; + Vec3f spA0 = D_80B155E0; + Vec3f sp94 = D_80B155EC; + f32 temp_f20; + f32 temp_f22; + + for (i = 0; i < arg4; i++) { + temp_f20 = Rand_ZeroOne() * 30.0f; + temp_f22 = Rand_ZeroOne() * 1.5f; + temp_s0 = Rand_Next(); + + spAC.x = (Math_SinS(temp_s0) * temp_f20) + vec.x; + spAC.y = (Rand_Centered() * 4.0f) + vec.y; + spAC.z = (Math_CosS(temp_s0) * temp_f20) + vec.z; + + spA0.x += temp_f22 * Math_SinS(temp_s0); + spA0.y += Rand_Centered() + 0.5f; + spA0.z += temp_f22 * Math_CosS(temp_s0); + + sp94.x = -0.1f * spA0.x; + sp94.y = -0.1f * spA0.y; + sp94.z = -0.1f * spA0.z; + + func_800B0EB0(globalCtx, &spAC, &spA0, &sp94, &D_80B155F8, &D_80B155FC, arg2, arg3, 10); + } +} + +void func_80B14F4C(ObjHakaisi* this, GlobalContext* globalCtx, s32 arg2) { + if (arg2 == 0) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_HAKAISI, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y + 55.0f, this->dyna.actor.world.pos.z - 10.0f, + this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, 4); + } else { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_HAKAISI, this->dyna.actor.world.pos.x + 20.0f, + this->dyna.actor.world.pos.y + 30.0f, this->dyna.actor.world.pos.z - 10.0f, + this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, 5); + } +} + +void ObjHakaisi_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjHakaisi* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void ObjHakaisi_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjHakaisi* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_194 == 0) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_hakaisi_DL_002650); + } else if (this->unk_194 == 1) { + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_hakaisi_DL_0029C0); + } else { + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_hakaisi_DL_002CC0); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80B151E0(ObjHakaisi* this, GlobalContext* globalCtx) { + this->dyna.actor.update = func_80B1544C; + this->dyna.actor.draw = func_80B154A0; + this->dyna.actor.destroy = func_80B15254; + Actor_SetScale(&this->dyna.actor, 0.1f); + this->dyna.actor.shape.yOffset = 100.0f; + this->dyna.actor.flags &= ~ACTOR_FLAG_1; + func_80B15264(this); +} + +void func_80B15254(Actor* thisx, GlobalContext* globalCtx) { +} + +void func_80B15264(ObjHakaisi* this) { + s32 pad; + s16 sp32 = Rand_Next(); + + Matrix_InsertRotation(Rand_Next(), Rand_Next(), Rand_Next(), MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&D_80B15600, &this->unk_184); + this->dyna.actor.gravity = -1.0f; + this->unk_19C = Rand_Next() >> 0x12; + this->dyna.actor.velocity.x = Math_SinS(sp32) * 4.0f; + this->dyna.actor.velocity.z = Math_CosS(sp32) * 4.0f; + this->dyna.actor.velocity.y = 7.0f; + this->actionFunc = func_80B15330; +} + +void func_80B15330(ObjHakaisi* this, GlobalContext* globalCtx) { + s32 pad; + MtxF sp34; + + this->dyna.actor.velocity.y += this->dyna.actor.gravity; + Actor_UpdatePos(&this->dyna.actor); + + if (this->dyna.actor.bgCheckFlags & 2) { + func_80B14B6C(this, globalCtx, this->dyna.actor.world.pos, 40); + func_80B14CF8(globalCtx, this->dyna.actor.world.pos, 100, 30, 10); + Actor_MarkForDeath(&this->dyna.actor); + } + + Matrix_InsertRotationAroundUnitVector_s(this->unk_19C, &this->unk_184, MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_CopyCurrentState(&sp34); + + func_8018219C(&sp34, &this->dyna.actor.shape.rot, 0); +} + +void func_80B1544C(Actor* thisx, GlobalContext* globalCtx) { + ObjHakaisi* this = THIS; + + this->actionFunc(this, globalCtx); + + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); +} + +void func_80B154A0(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (OBJHAKAISI_GET_FF(thisx) == 4) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_hakaisi_DL_001F10); + } else { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_hakaisi_DL_0021B0); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h index 5c6f1a64a..4f1d1ada9 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h @@ -7,13 +7,21 @@ struct ObjHakaisi; typedef void (*ObjHakaisiActionFunc)(struct ObjHakaisi*, GlobalContext*); +#define OBJHAKAISI_GET_FF(thisx) ((thisx)->params & 0xFF) +#define OBJHAKAISI_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFF00) >> 8) + typedef struct ObjHakaisi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjHakaisiActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x38]; + /* 0x0160 */ Vec3f unk_160[3]; + /* 0x0184 */ Vec3f unk_184; + /* 0x0190 */ s32 switchFlag; + /* 0x0194 */ s16 unk_194; + /* 0x0196 */ s16 unk_196; /* 0x0198 */ s16 unk_198; - /* 0x019A */ char unk_19A[0x6]; + /* 0x019A */ s16 unk_19A; + /* 0x019C */ s16 unk_19C; + /* 0x019E */ u8 unk_19E; } ObjHakaisi; // size = 0x1A0 extern const ActorInit Obj_Hakaisi_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 781df3269..d19d9ed35 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1323,6 +1323,7 @@ D_06003DC8 = 0x06003DC8; // ovl_En_Fishing +D_060029C0 = 0x060029C0; D_0600007C = 0x0600007C; D_0600CFE0 = 0x0600CFE0; D_06011058 = 0x06011058; @@ -1991,15 +1992,6 @@ D_06001AA8 = 0x06001AA8; D_06000158 = 0x06000158; D_06001C00 = 0x06001C00; -// ovl_Obj_Hakaisi - -D_06001F10 = 0x06001F10; -D_060021B0 = 0x060021B0; -D_06002650 = 0x06002650; -D_060029C0 = 0x060029C0; -D_06002CC0 = 0x06002CC0; -D_06002FC4 = 0x06002FC4; - // ovl_Obj_Hariko D_06000080 = 0x06000080; From 1c955e56b06ec8353d35c9388ad873a25f7b6f94 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 5 Mar 2022 14:16:36 +0000 Subject: [PATCH 063/257] En_Tab (#657) * En_Tab * PR --- assets/xml/objects/object_tab.xml | 5 +- spec | 3 +- src/overlays/actors/ovl_En_Tab/z_en_tab.c | 592 ++++++++++++++++++++-- src/overlays/actors/ovl_En_Tab/z_en_tab.h | 35 +- tools/disasm/functions.txt | 6 +- undefined_syms.txt | 4 - 6 files changed, 593 insertions(+), 52 deletions(-) diff --git a/assets/xml/objects/object_tab.xml b/assets/xml/objects/object_tab.xml index 52c3156a3..1e741c9aa 100644 --- a/assets/xml/objects/object_tab.xml +++ b/assets/xml/objects/object_tab.xml @@ -24,9 +24,10 @@ - + - + + diff --git a/spec b/spec index 08ffa0543..42da5d33a 100644 --- a/spec +++ b/spec @@ -4832,8 +4832,7 @@ beginseg name "ovl_En_Tab" compress include "build/src/overlays/actors/ovl_En_Tab/z_en_tab.o" - include "build/data/ovl_En_Tab/ovl_En_Tab.data.o" - include "build/data/ovl_En_Tab/ovl_En_Tab.reloc.o" + include "build/src/overlays/actors/ovl_En_Tab/ovl_En_Tab_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index 4dfaa44d0..a22faeb59 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -5,6 +5,8 @@ */ #include "z_en_tab.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_tab/object_tab.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -18,7 +20,39 @@ void EnTab_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BE127C(EnTab* this, GlobalContext* globalCtx); void func_80BE1348(EnTab* this, GlobalContext* globalCtx); -#if 0 +s32 D_80BE18D0[] = { + 0x0C000320, 0x0A00151B, 0x02093212, 0x010F0212, 0x00060003, 0x0400000E, 0x12000600, 0x020E0932, 0x12010105, + 0x0A001519, 0x02093215, 0x050D0215, 0x37050501, 0x050E1537, 0x0505020E, 0x09321505, 0x01050000, +}; + +s32 D_80BE1914[] = { + 0x003A0200, 0x080E2AF9, 0x0C113A02, 0x100E2AFA, 0x0C150900, 0x000E2AFB, + 0x0C003401, 0x00090F2A, 0xFD0C0F2A, 0xFE0C100F, 0x2AFC0C10, +}; + +s32 D_80BE1940[] = { + 0x003F0400, 0x080E2B3D, 0x0C113F04, 0x100E2B3E, 0x0C0F2AFA, 0x0C150900, + 0x000E2AFB, 0x0C003401, 0x00090F2A, 0xFD0C0F2A, 0xFE0C100F, 0x2AFC0C10, +}; + +s32 D_80BE1970[] = { 0x003A0100, 0x080E2AFF, 0x0C113A01, 0x100E2B00, 0x0C100000 }; + +s32 D_80BE1984[] = { 0x00500100, 0x080E2B3F, 0x0C115001, 0x100E2B40, 0x0C100000 }; + +s32 D_80BE1998[] = { 0x0E2B090C, 0x10000000 }; + +s32 D_80BE19A0[] = { + 0x0E2B0A0C, 0x05004E00, 0x00004E30, 0x2800050E, 0x2B0E0C10, 0x0E2B0B0C, 0x05000000, 0x08001008, 0x00140026, + 0x19000E08, 0x00C8000F, 0x19000631, 0x0E2B0D0C, 0x10320E2B, 0x0C0C1030, 0x1214FF38, 0x06009100, 0x00130091, + 0x0C103012, 0x14FFEC06, 0x00920000, 0x1300920C, 0x10300034, 0x0100050E, 0x2B0F0C10, 0x0E2B110C, 0x10000000, +}; + +s32 D_80BE1A0C[] = { + 0x0E2B0A0C, 0x05004E00, 0x00004E30, 0x2800050E, 0x2B0E0C10, 0x0E2B0B0C, 0x05000000, 0x08001008, 0x00140026, + 0x19000E08, 0x00C8000F, 0x19000631, 0x0E2B0D0C, 0x10320E2B, 0x0C0C1030, 0x1214FF38, 0x06009100, 0x00130091, + 0x0C103012, 0x14FFEC06, 0x00920000, 0x1300920C, 0x10300034, 0x0100050E, 0x2B100C10, 0x0E2B110C, 0x10000000, +}; + const ActorInit En_Tab_InitVars = { ACTOR_EN_TAB, ACTORCAT_NPC, @@ -31,75 +65,555 @@ const ActorInit En_Tab_InitVars = { (ActorFunc)EnTab_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BE1A98 = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 14, 62, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BE1AC4 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +AnimationInfoS D_80BE1AD0[] = { + { &object_tab_Anim_000758, 1.0f, 0, -1, 0, 0 }, + { &object_tab_Anim_0086AC, 1.0f, 0, -1, 0, 0 }, +}; -extern ColliderCylinderInit D_80BE1A98; -extern CollisionCheckInfoInit2 D_80BE1AC4; +Vec3f D_80BE1AF0 = { -28.0f, -8.0f, -195.0f }; -extern UNK_TYPE D_06007F78; +Vec3s D_80BE1AFC = { 0, 0, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE04E0.s") +Vec3f D_80BE1B04 = { 161.0f, 0.0f, -10.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0590.s") +Vec3s D_80BE1B10 = { 0, 0xC000, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE05BC.s") +Vec3f D_80BE1B18 = { 800.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0620.s") +TexturePtr D_80BE1B24[] = { + object_tab_Tex_006428, + object_tab_Tex_006928, + object_tab_Tex_006D28, + object_tab_Tex_006928, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0664.s") +EnGm* func_80BE04E0(EnTab* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { + Actor* foundActor = NULL; + Actor* tempActor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE06DC.s") + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, actorCat, actorId); + if ((foundActor == NULL) || (((EnTab*)foundActor != this) && (foundActor->update != NULL))) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0778.s") + tempActor = foundActor->next; + if (tempActor == NULL) { + foundActor = NULL; + break; + } + foundActor = tempActor; + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE07A0.s") + return (EnGm*)foundActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE09A8.s") +void func_80BE0590(EnTab* this) { + this->skelAnime.playSpeed = this->unk_300; + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0A98.s") +s32 func_80BE05BC(EnTab* this, s32 arg1) { + s32 phi_v0 = false; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0C04.s") + if (arg1 != this->unk_32C) { + phi_v0 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0D38.s") + if (phi_v0) { + this->unk_32C = arg1; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80BE1AD0, arg1); + this->unk_300 = this->skelAnime.playSpeed; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0D60.s") +void func_80BE0620(EnTab* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0E04.s") + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0F04.s") +void func_80BE0664(EnTab* this) { + if (DECR(this->unk_31C) == 0) { + this->unk_31E++; + if (this->unk_31E > 3) { + this->unk_31C = Rand_S16Offset(30, 30); + this->unk_31E = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0FC4.s") +s32 func_80BE06DC(EnTab* this, GlobalContext* globalCtx) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE1060.s") + if (this->unk_2FC & 7) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + SubS_UpdateFlags(&this->unk_2FC, 0, 7); + ret = true; + this->unk_320 = 0; + this->unk_328 = NULL; + this->actor.child = &GET_PLAYER(globalCtx)->actor; + this->unk_2FC |= 8; + this->actionFunc = func_80BE1348; + } + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE10BC.s") +Actor* func_80BE0778(EnTab* this, GlobalContext* globalCtx) { + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE1224.s") + if (this->unk_1D8 == 1) { + actor = this->actor.child; + } else { + actor = &GET_PLAYER(globalCtx)->actor; + } + return actor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE127C.s") +void func_80BE07A0(EnTab* this) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE1348.s") + Math_Vec3f_Copy(&sp40, &this->unk_1E0->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/EnTab_Init.s") + Math_ApproachS(&this->unk_314, (sp32 - this->unk_318) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_314 = CLAMP(this->unk_314, -0x1FFE, 0x1FFE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/EnTab_Destroy.s") + Math_ApproachS(&this->unk_318, (sp32 - this->unk_314) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_318 = CLAMP(this->unk_318, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/EnTab_Update.s") + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + if (this->unk_1E0->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_1E0)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_1E0->focus.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE1648.s") + Math_ApproachS(&this->unk_312, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_316, 4, 0x2AA8); + this->unk_312 = CLAMP(this->unk_312, -0x1554, 0x1554); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE16B4.s") + Math_ApproachS(&this->unk_316, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_312, 4, 0x2AA8); + this->unk_316 = CLAMP(this->unk_316, -0xE38, 0xE38); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE1704.s") +void func_80BE09A8(EnTab* this, GlobalContext* globalCtx) { + this->unk_1E0 = func_80BE0778(this, globalCtx); + if ((this->unk_2FC & 8) && (this->unk_1E0 != 0) && (DECR(this->unk_324) == 0)) { + func_80BE07A0(this); + this->unk_316 = 0; + this->unk_318 = 0; + this->unk_2FC &= ~0x40; + this->unk_2FC |= 0x10; + } else if (this->unk_2FC & 0x10) { + this->unk_2FC &= ~0x10; + this->unk_312 = 0; + this->unk_314 = 0; + this->unk_316 = 0; + this->unk_318 = 0; + this->unk_324 = 20; + } else if (DECR(this->unk_324) == 0) { + this->unk_2FC |= 0x40; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/EnTab_Draw.s") +void func_80BE0A98(EnTab* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp20 = Message_GetState(&globalCtx->msgCtx); + + this->unk_308 += (this->unk_304 != 0.0f) ? 40.0f : -40.0f; + this->unk_308 = CLAMP(this->unk_308, 0.0f, 80.0f); + + Matrix_InsertTranslation(this->unk_308, 0.0f, 0.0f, MTXMODE_APPLY); + + if ((&this->actor == player->targetActor) && + ((globalCtx->msgCtx.unk11F04 < 0xFF) || (globalCtx->msgCtx.unk11F04 > 0x200)) && (sp20 == 3) && + (this->unk_334 == 3)) { + if ((globalCtx->state.frames % 2) == 0) { + if (this->unk_304 != 0.0f) { + this->unk_304 = 0.0f; + } else { + this->unk_304 = 1.0f; + } + } + } else { + this->unk_304 = 0.0f; + } + this->unk_334 = sp20; +} + +s32 func_80BE0C04(EnTab* this, Actor* actor, f32 arg2) { + Vec3f sp44; + Vec3f sp38; + s32 ret = false; + f32 sp30; + s16 sp2E; + + if (actor != NULL) { + Math_Vec3f_Copy(&sp38, &this->actor.world.pos); + Math_Vec3f_Copy(&sp44, &actor->world.pos); + sp2E = Math_Vec3f_Yaw(&sp38, &sp44); + + if (this->unk_338) { + sp30 = arg2; + } else { + sp30 = arg2 * 0.5f; + } + if ((Math_Vec3f_DistXZ(&sp44, &sp38) < sp30) && (ABS_ALT(BINANG_SUB(sp2E, this->actor.shape.rot.y)) < 0x38E0)) { + ret = true; + } + + if (DECR(this->unk_322) == 0) { + this->unk_338 ^= true; + this->unk_322 = Rand_S16Offset(60, 60); + } + } + return ret; +} + +s32 func_80BE0D38(EnTab* this, GlobalContext* globalCtx) { + return Interface_HasEmptyBottle(); +} + +s32 func_80BE0D60(EnTab* this, GlobalContext* globalCtx) { + s32 pad; + s32 ret = false; + + this->unk_320++; + if (this->unk_320 == 1) { + globalCtx->setPlayerTalkAnim(globalCtx, &gameplay_keep_Linkanim_00D568, 2); + } else if (this->unk_320 > 20) { + globalCtx->setPlayerTalkAnim(globalCtx, NULL, 0); + this->unk_320 = 0; + ret = true; + } + return ret; +} + +s32* func_80BE0E04(EnTab* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (player->transformation == PLAYER_FORM_DEKU) { + return D_80BE1984; + } + + switch (this->unk_1D8) { + case 2: + this->unk_328 = func_80BE0D38; + if (Player_GetMask(globalCtx) != PLAYER_MASK_ROMANI) { + return D_80BE1998; + } + + if (gSaveContext.day == 3) { + return D_80BE1A0C; + } + return D_80BE19A0; + + case 1: + this->unk_328 = func_80BE0D60; + if (Player_GetMask(globalCtx) == PLAYER_MASK_ROMANI) { + return D_80BE1940; + } + + if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { + return D_80BE1970; + } + return D_80BE1914; + } + + return NULL; +} + +s32 func_80BE0F04(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret = false; + EnGm* sp28 = func_80BE04E0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_GM); + + if (sp28) { + Math_Vec3f_Copy(&this->actor.world.pos, &D_80BE1AF0); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80BE1AFC); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + this->actor.targetMode = 0; + SubS_UpdateFlags(&this->unk_2FC, 3, 7); + this->unk_2FC |= (0x40 | 0x20); + this->unk_30C = 30; + this->unk_1E4 = sp28; + func_80BE05BC(this, 0); + ret = true; + } + return ret; +} + +s32 func_80BE0FC4(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 pad; + + Math_Vec3f_Copy(&this->actor.world.pos, &D_80BE1B04); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80BE1B10); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + this->actor.targetMode = 6; + SubS_UpdateFlags(&this->unk_2FC, 3, 7); + this->unk_2FC |= (0x40 | 0x20); + this->unk_30C = 0x50; + func_80BE05BC(this, 1); + return true; +} + +s32 func_80BE1060(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret; + + this->unk_2FC = 0; + + switch (arg2->unk0) { + case 1: + ret = func_80BE0F04(this, globalCtx, arg2); + break; + + case 2: + ret = func_80BE0FC4(this, globalCtx, arg2); + break; + + default: + ret = false; + break; + } + return ret; +} + +s32 func_80BE10BC(EnTab* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + f32 dist; + Actor* tempActor; + + switch (this->unk_1D8) { + case 1: + if ((player->stateFlags1 & 0x40) && !(globalCtx->msgCtx.unk11F04 <= 0x2B00) && + (globalCtx->msgCtx.unk11F04 < 0x2B08)) { + this->actor.child = &this->unk_1E4->actor; + this->unk_2FC |= 8; + } else { + dist = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_1E4->actor.world.pos); + + if ((gSaveContext.weekEventReg[75] & 1) || (this->unk_1E4->actor.draw == NULL) || !(dist < 160.0f)) { + tempActor = &GET_PLAYER(globalCtx)->actor; + this->actor.child = tempActor; + } else { + tempActor = &this->unk_1E4->actor; + this->actor.child = tempActor; + } + + if (func_80BE0C04(this, tempActor, 160.0f)) { + this->unk_2FC |= 8; + } else { + this->unk_2FC &= ~8; + } + } + break; + + case 2: + if (func_80BE0C04(this, &GET_PLAYER(globalCtx)->actor, 200.0f)) { + this->unk_2FC |= 8; + } else { + this->unk_2FC &= ~8; + } + break; + } + + return false; +} + +void func_80BE1224(EnTab* this, GlobalContext* globalCtx) { + if ((this->unk_1D8 == 1) || (this->unk_1D8 == 2)) { + func_80BE10BC(this, globalCtx); + } + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); +} + +void func_80BE127C(EnTab* this, GlobalContext* globalCtx) { + u32* unk_14 = &gSaveContext.unk_14; + struct_80133038_arg2 sp18; + + this->unk_31A = REG(15) + *unk_14; + + if (!func_80133038(globalCtx, D_80BE18D0, &sp18) || + ((this->unk_1D8 != sp18.unk0) && !func_80BE1060(this, globalCtx, &sp18))) { + this->actor.shape.shadowDraw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + sp18.unk0 = 0; + } else { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.flags |= ACTOR_FLAG_1; + } + this->unk_1D8 = sp18.unk0; + func_80BE1224(this, globalCtx); +} + +void func_80BE1348(EnTab* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + + if (func_8010BF58(&this->actor, globalCtx, func_80BE0E04(this, globalCtx), this->unk_328, &this->unk_1DC)) { + SubS_UpdateFlags(&this->unk_2FC, 3, 7); + this->unk_2FC &= ~8; + this->unk_2FC |= 0x40; + this->unk_324 = 20; + this->unk_1DC = 0; + this->actionFunc = func_80BE127C; + } else if (this->unk_1E0 != 0) { + Math_Vec3f_Copy(&sp40, &this->unk_1E0->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp34, &sp40), 4, 0x2AA8); + } +} + +void EnTab_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTab* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 14.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tab_Skel_007F78, NULL, this->jointTable, this->morphTable, + 20); + this->unk_32C = -1; + func_80BE05BC(this, 0); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + Actor_SetScale(&this->actor, 0.01f); + + this->unk_1D8 = 0; + this->unk_328 = NULL; + this->unk_2FC = 0; + this->unk_2FC |= 0x40; + this->actor.gravity = -1.0f; + + this->actionFunc = func_80BE127C; + this->actionFunc(this, globalCtx); +} + +void EnTab_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTab* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnTab_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTab* this = THIS; + f32 radius; + f32 height; + + func_80BE06DC(this, globalCtx); + + this->actionFunc(this, globalCtx); + + if (this->unk_1D8 != 0) { + func_80BE0590(this); + func_80BE0664(this); + func_80BE09A8(this, globalCtx); + + radius = this->collider.dim.radius + this->unk_30C; + height = this->collider.dim.height + 10; + + func_8013C964(&this->actor, globalCtx, radius, height, 0, this->unk_2FC & 7); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + func_80BE0620(this, globalCtx); + } +} + +s32 EnTab_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnTab* this = THIS; + + if (limbIndex == 9) { + func_80BE0A98(this, globalCtx); + } + + if ((this->unk_32C == 1) && (limbIndex == 18)) { + *dList = NULL; + } + return false; +} + +void EnTab_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnTab* this = THIS; + + if (limbIndex == 9) { + Matrix_MultiplyVector3fByState(&D_80BE1B18, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } +} + +void EnTab_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnTab* this = THIS; + s32 phi_v0; + s32 phi_v1; + + if (!(this->unk_2FC & 0x40)) { + if (this->unk_2FC & 0x10) { + phi_v1 = 1; + } else { + phi_v1 = 0; + } + phi_v0 = 1; + } else { + phi_v1 = 0; + phi_v0 = 0; + } + + if (limbIndex == 9) { + func_8013AD9C(BINANG_ADD(this->unk_312 + this->unk_316, 0x4000), + BINANG_ADD(this->unk_314 + this->unk_318 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, + this->unk_200, phi_v0, phi_v1); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_200[0].y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_200[0].x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_200[0].z, MTXMODE_APPLY); + Matrix_StatePush(); + } +} + +void EnTab_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTab* this = THIS; + + if (this->unk_1D8 != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BE1B24[this->unk_31E])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnTab_OverrideLimbDraw, EnTab_PostLimbDraw, + EnTab_TransformDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.h b/src/overlays/actors/ovl_En_Tab/z_en_tab.h index 45f6a057d..266949fe8 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.h +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.h @@ -2,16 +2,47 @@ #define Z_EN_TAB_H #include "global.h" +#include "overlays/actors/ovl_En_Gm/z_en_gm.h" struct EnTab; typedef void (*EnTabActionFunc)(struct EnTab*, GlobalContext*); +typedef s32 (*EnTabUnkFunc)(struct EnTab*, GlobalContext*); typedef struct EnTab { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnTabActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x1B0]; + /* 0x018C */ ColliderCylinder collider; + /* 0x01D8 */ u8 unk_1D8; + /* 0x01DC */ s32 unk_1DC; + /* 0x01E0 */ Actor* unk_1E0; + /* 0x01E4 */ EnGm* unk_1E4; + /* 0x01E8 */ Vec3f unk_1E8[2]; + /* 0x0200 */ Vec3s unk_200[2]; + /* 0x020C */ Vec3s jointTable[20]; + /* 0x0284 */ Vec3s morphTable[20]; + /* 0x02FC */ u16 unk_2FC; + /* 0x0300 */ f32 unk_300; + /* 0x0304 */ f32 unk_304; + /* 0x0308 */ f32 unk_308; + /* 0x030C */ s16 unk_30C; + /* 0x030E */ UNK_TYPE1 unk30E[4]; + /* 0x0312 */ s16 unk_312; + /* 0x0314 */ s16 unk_314; + /* 0x0316 */ s16 unk_316; + /* 0x0318 */ s16 unk_318; + /* 0x031A */ s16 unk_31A; + /* 0x031C */ s16 unk_31C; + /* 0x031E */ s16 unk_31E; + /* 0x0320 */ s16 unk_320; + /* 0x0322 */ s16 unk_322; + /* 0x0324 */ s16 unk_324; + /* 0x0328 */ EnTabUnkFunc unk_328; + /* 0x032C */ s32 unk_32C; + /* 0x0330 */ UNK_TYPE1 unk330[4]; + /* 0x0334 */ s32 unk_334; + /* 0x0338 */ s32 unk_338; } EnTab; // size = 0x33C extern const ActorInit En_Tab_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index a98db6787..099a4d472 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16057,9 +16057,9 @@ 0x80BE1424:("EnTab_Init",), 0x80BE1524:("EnTab_Destroy",), 0x80BE1550:("EnTab_Update",), - 0x80BE1648:("func_80BE1648",), - 0x80BE16B4:("func_80BE16B4",), - 0x80BE1704:("func_80BE1704",), + 0x80BE1648:("EnTab_OverrideLimbDraw",), + 0x80BE16B4:("EnTab_PostLimbDraw",), + 0x80BE1704:("EnTab_TransformDraw",), 0x80BE1810:("EnTab_Draw",), 0x80BE1C80:("func_80BE1C80",), 0x80BE1CEC:("EnNimotsu_Init",), diff --git a/undefined_syms.txt b/undefined_syms.txt index d19d9ed35..b48b5c197 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1809,10 +1809,6 @@ D_060091A8 = 0x060091A8; D_06011AC8 = 0x06011AC8; D_06012DE0 = 0x06012DE0; -// ovl_En_Tab - -D_06007F78 = 0x06007F78; - // ovl_En_Takaraya D_06000968 = 0x06000968; From 640f039cce2514f11cc0e1ec00221503db719cde Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 5 Mar 2022 14:22:16 +0000 Subject: [PATCH 064/257] En_Gg2 (#676) Co-authored-by: angie --- spec | 3 +- src/overlays/actors/ovl_En_Gg2/z_en_gg2.c | 467 ++++++++++++++++++++-- src/overlays/actors/ovl_En_Gg2/z_en_gg2.h | 25 +- undefined_syms.txt | 5 - 4 files changed, 467 insertions(+), 33 deletions(-) diff --git a/spec b/spec index 42da5d33a..5a7e765a9 100644 --- a/spec +++ b/spec @@ -4045,8 +4045,7 @@ beginseg name "ovl_En_Gg2" compress include "build/src/overlays/actors/ovl_En_Gg2/z_en_gg2.o" - include "build/data/ovl_En_Gg2/ovl_En_Gg2.data.o" - include "build/data/ovl_En_Gg2/ovl_En_Gg2.reloc.o" + include "build/src/overlays/actors/ovl_En_Gg2/ovl_En_Gg2_reloc.o" endseg beginseg 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 e06655c69..252853a24 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -5,6 +5,7 @@ */ #include "z_en_gg2.h" +#include "objects/object_gg/object_gg.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_80) @@ -15,7 +16,17 @@ void EnGg2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGg2_Update(Actor* thisx, GlobalContext* globalCtx); void EnGg2_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B3AE60(EnGg2* this, GlobalContext* globalCtx); +void func_80B3AFB0(EnGg2* this, GlobalContext* globalCtx); +void func_80B3B05C(EnGg2* this, GlobalContext* globalCtx); +void func_80B3B0A0(EnGg2* this, GlobalContext* globalCtx); +void func_80B3B120(EnGg2* this, GlobalContext* globalCtx); +void func_80B3B21C(EnGg2* this, GlobalContext* globalCtx); +void func_80B3B294(EnGg2* this, GlobalContext* globalCtx); +void func_80B3B5D4(EnGg2* this, GlobalContext* globalCtx); +s32 func_80B3B648(EnGg2* this, Path* path, s32 arg2_); +f32 func_80B3B7E4(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3); + const ActorInit En_Gg2_InitVars = { ACTOR_EN_GG2, ACTORCAT_NPC, @@ -28,48 +39,456 @@ const ActorInit En_Gg2_InitVars = { (ActorFunc)EnGg2_Draw, }; -#endif +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 }, +}; -extern UNK_TYPE D_0600F578; +Color_RGBA8 D_80B3C080 = { 255, 255, 255, 255 }; +Color_RGBA8 D_80B3C084 = { 255, 150, 0, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3AC50.s") +Vec3f D_80B3C088 = { 0.0f, 0.0f, 0.0f }; +Vec3f D_80B3C094 = { 0.0f, 0.0f, 0.0f }; +Vec3f D_80B3C0A0 = { 1000.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3AC94.s") +TexturePtr D_80B3C0AC[] = { + object_gg_Tex_009260, + object_gg_Tex_009660, + object_gg_Tex_009A60, + object_gg_Tex_009E60, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3ADD8.s") +void func_80B3AC50(EnGg2* this) { + this->actor.focus.pos.x = this->actor.world.pos.x; + this->actor.focus.pos.y = this->actor.world.pos.y + 80.0f; + this->actor.focus.pos.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3AE60.s") + this->actor.focus.rot.x = this->actor.world.rot.x; + this->actor.focus.rot.y = this->actor.world.rot.y; + this->actor.focus.rot.z = this->actor.world.rot.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3AFB0.s") +s32 func_80B3AC94(EnGg2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + Vec3f sp34; + s16 pitch; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B05C.s") + sp40 = player->actor.world.pos; + sp40.y = player->bodyPartsPos[7].y + 3.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B0A0.s") + sp34 = this->actor.world.pos; + sp34.y += 70.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B120.s") + pitch = Math_Vec3f_Pitch(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B21C.s") + if ((this->actor.xzDistToPlayer < 250.0f) && (this->actor.xzDistToPlayer > 50.0f) && + CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + Math_SmoothStepToS(&this->unk_2F4, pitch, 4, 0x2AA8, 1); + } else { + Math_SmoothStepToS(&this->unk_2F4, 0, 4, 0x2AA8, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B294.s") + this->unk_2F4 = CLAMP(this->unk_2F4, 0, 0x1C70); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B4B0.s") +void func_80B3ADD8(EnGg2* this) { + s16 temp_v0 = this->unk_2EC - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B5D4.s") + if (temp_v0 >= 3) { + this->unk_2EA = 0; + this->unk_2EC = temp_v0; + } else if (temp_v0 == 0) { + this->unk_2EA = 2; + this->unk_2EC = (s32)(Rand_ZeroOne() * 60.0f) + 20; + } else { + this->unk_2EA = 1; + this->unk_2EC = temp_v0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B648.s") +void func_80B3AE60(EnGg2* this, GlobalContext* globalCtx) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(D_80B3BF00[this->unk_2EE].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B7E4.s") + if (curFrame == lastFrame) { + switch (this->unk_2EE) { + case 0: + this->unk_2EE = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 1); + this->actionFunc = func_80B3B0A0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B8A4.s") + case 1: + case 8: + this->unk_2EE = 5; + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 5); + this->actionFunc = func_80B3B120; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/EnGg2_Init.s") + case 5: + this->unk_2EE = 6; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + this->actionFunc = func_80B3B21C; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/EnGg2_Destroy.s") + case 6: + this->unk_2EE = 7; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 5); + this->actionFunc = func_80B3B294; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/EnGg2_Update.s") + default: + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + this->actionFunc = func_80B3AFB0; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3BD44.s") +void func_80B3AFB0(EnGg2* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2F0 = 1; + this->actionFunc = func_80B3AE60; + } else if ((this->actor.xzDistToPlayer < 100.0f) && (this->actor.xzDistToPlayer > 50.0f) && + CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + func_800B863C(&this->actor, globalCtx); + this->actor.textId = 0xCE4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3BDC0.s") +void func_80B3B05C(EnGg2* this, GlobalContext* globalCtx) { + if ((this->actor.xzDistToPlayer < 100.0f) && CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + this->actionFunc = func_80B3B5D4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/EnGg2_Draw.s") +void func_80B3B0A0(EnGg2* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_2F0 = 0; + this->actionFunc = func_80B3B5D4; + } +} + +void func_80B3B120(EnGg2* this, GlobalContext* globalCtx) { + Vec3s sp30; + + if (this->unk_1D8 != NULL) { + func_80B3B7E4(this->unk_1D8, this->unk_1DC, &this->actor.world.pos, &sp30); + Math_SmoothStepToS(&this->actor.world.rot.y, sp30.y, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->actor.shape.rot.x, sp30.x, 4, 0x3E8, 1); + this->actor.world.rot.x = -this->actor.shape.rot.x; + if (func_80B3B648(this, this->unk_1D8, this->unk_1DC) != 0) { + if (this->unk_1DC >= (this->unk_1D8->count - 2)) { + this->actionFunc = func_80B3AE60; + this->actor.speedXZ = 0.0f; + } else { + this->unk_1DC++; + } + } + Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 1.0f); + } +} + +void func_80B3B21C(EnGg2* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + if ((this->actor.xzDistToPlayer < 100.0f) && CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + this->unk_2E4 = ActorCutscene_GetAdditionalCutscene(this->unk_2E4); + this->actionFunc = func_80B3B5D4; + } +} + +void func_80B3B294(EnGg2* this, GlobalContext* globalCtx) { + Vec3s sp30; + + if (this->unk_2F1 == 0) { + if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { + gSaveContext.weekEventReg[20] |= 4; + gSaveContext.weekEventReg[20] &= (u8)~8; + gSaveContext.weekEventReg[20] &= (u8)~0x10; + } else if (globalCtx->sceneNum == SCENE_17SETUGEN) { + gSaveContext.weekEventReg[20] &= (u8)~4; + gSaveContext.weekEventReg[20] |= 8; + gSaveContext.weekEventReg[20] &= (u8)~0x10; + } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { + gSaveContext.weekEventReg[20] &= (u8)~4; + gSaveContext.weekEventReg[20] &= (u8)~8; + gSaveContext.weekEventReg[20] |= 0x10; + } + + if (this->unk_1D8 != NULL) { + func_80B3B7E4(this->unk_1D8, this->unk_1DC, &this->actor.world.pos, &sp30); + Math_SmoothStepToS(&this->actor.world.rot.y, sp30.y, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->actor.shape.rot.x, sp30.x, 4, 0x3E8, 1); + this->actor.world.rot.x = -this->actor.shape.rot.x; + + if (func_80B3B648(this, this->unk_1D8, this->unk_1DC)) { + if (this->unk_1DC < (this->unk_1D8->count - 1)) { + this->unk_1DC++; + } else { + this->unk_2F1 = 1; + if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { + gSaveContext.weekEventReg[20] |= 4; + gSaveContext.weekEventReg[20] &= (u8)~8; + gSaveContext.weekEventReg[20] &= (u8)~0x10; + } else if (globalCtx->sceneNum == SCENE_17SETUGEN) { + gSaveContext.weekEventReg[20] &= (u8)~4; + gSaveContext.weekEventReg[20] |= 8; + gSaveContext.weekEventReg[20] &= (u8)~0x10; + } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { + gSaveContext.weekEventReg[20] &= (u8)~4; + gSaveContext.weekEventReg[20] &= (u8)~8; + gSaveContext.weekEventReg[20] |= 0x10; + } + } + } + } + } + Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 1.0f); +} + +void func_80B3B4B0(EnGg2* this, GlobalContext* globalCtx) { + Vec3f sp64; + Color_RGBA8 sp60 = D_80B3C080; + Color_RGBA8 sp5C = D_80B3C084; + s32 i; + + for (i = 0; i < 5; i++) { + sp64.x = (Rand_Centered() * 50.0f) + this->unk_304.x; + sp64.y = this->unk_304.y; + sp64.z = (Rand_Centered() * 50.0f) + this->unk_304.z; + EffectSsKiraKira_SpawnDispersed(globalCtx, &sp64, &D_80B3C088, &D_80B3C094, &sp60, &sp5C, 3000, 40); + } +} + +void func_80B3B5D4(EnGg2* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->unk_2E4)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2E4, &this->actor); + this->actionFunc = func_80B3AE60; + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->unk_2E4); + } +} + +s32 func_80B3B648(EnGg2* this, Path* path, s32 arg2_) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 sp58 = path->count; + s32 arg2 = arg2_; + s32 ret = false; + f32 phi_f12; + f32 phi_f14; + f32 sp44; + f32 sp40; + f32 sp3C; + Vec3f sp30; + + Math_Vec3s_ToVec3f(&sp30, &points[arg2]); + + if (arg2 == 0) { + phi_f12 = points[1].x - points[0].x; + phi_f14 = points[1].z - points[0].z; + } else if ((sp58 - 1) == arg2) { + phi_f12 = points[sp58 - 1].x - points[sp58 - 2].x; + phi_f14 = points[sp58 - 1].z - points[sp58 - 2].z; + } else { + phi_f12 = points[arg2 + 1].x - points[arg2 - 1].x; + phi_f14 = points[arg2 + 1].z - points[arg2 - 1].z; + } + + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); + + if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { + ret = true; + } + return ret; +} + +f32 func_80B3B7E4(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3) { + Vec3s* points; + Vec3f sp20; + + if (path != NULL) { + points = Lib_SegmentedToVirtual(path->points); + points = &points[arg1]; + sp20.x = points->x; + sp20.y = points->y; + sp20.z = points->z; + } + + arg3->y = Math_Vec3f_Yaw(arg2, &sp20); + arg3->x = Math_Vec3f_Pitch(arg2, &sp20); + return sp20.y - arg2->y; +} + +void func_80B3B8A4(EnGg2* this) { + f32 sp1C; + + if ((this->unk_2EE != 5) && (this->unk_2EE != 7)) { + this->unk_2F2 += 0x62C; + sp1C = 1100.0f; + } else { + this->unk_2F2 += 0x7BC; + sp1C = 950.0f; + } + + this->actor.shape.yOffset = Math_SinS(this->unk_2F2) * sp1C; + this->actor.shape.shadowScale = 30.0f - (Math_SinS(this->unk_2F2) * 5.0f); + this->unk_2F6 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; +} + +void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnGg2* this = THIS; + + if (INV_CONTENT(ITEM_MASK_GORON) == ITEM_MASK_GORON) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (gSaveContext.weekEventReg[91] & 0x10) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + this->actor.bgCheckFlags |= 0x400; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_gg_Skel_00F6C0, &object_gg_Anim_00F578, this->jointTable, + this->morphTable, 20); + this->unk_1D8 = func_8013D648(globalCtx, ENGG2_GET_FC00(&this->actor), 0x3F); + this->actor.flags &= ~ACTOR_FLAG_80; + this->unk_2F0 = 0; + this->unk_2F1 = 0; + this->unk_2F2 = 0; + this->unk_2F4 = 0; + this->unk_2F6 = 0; + this->unk_2E4 = this->actor.cutscene; + this->unk_2EC = 20; + this->unk_2EA = 0; + + if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { + gSaveContext.weekEventReg[20] &= (u8)~4; + gSaveContext.weekEventReg[20] &= (u8)~8; + gSaveContext.weekEventReg[20] &= (u8)~0x10; + this->unk_2EE = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + this->actionFunc = func_80B3AFB0; + } else if (globalCtx->sceneNum == SCENE_17SETUGEN) { + if ((gSaveContext.weekEventReg[20] & 4) && !(gSaveContext.weekEventReg[20] & 8) && + !(gSaveContext.weekEventReg[20] & 0x10)) { + gSaveContext.weekEventReg[20] &= (u8)~4; + this->unk_2EE = 8; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + this->actionFunc = func_80B3B05C; + } else { + Actor_MarkForDeath(&this->actor); + } + } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { + if (!(gSaveContext.weekEventReg[20] & 4) && (gSaveContext.weekEventReg[20] & 8) && + !(gSaveContext.weekEventReg[20] & 0x10)) { + gSaveContext.weekEventReg[20] &= (u8)~8; + this->unk_2EE = 8; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + this->actionFunc = func_80B3B05C; + } else { + Actor_MarkForDeath(&this->actor); + } + } else { + gSaveContext.weekEventReg[20] &= (u8)~4; + gSaveContext.weekEventReg[20] &= (u8)~8; + gSaveContext.weekEventReg[20] &= (u8)~0x10; + Actor_MarkForDeath(&this->actor); + } +} + +void EnGg2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnGg2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGg2* this = THIS; + + if (globalCtx->actorCtx.unk4 == 100) { + this->actor.flags |= ACTOR_FLAG_80; + this->actor.flags |= ACTOR_FLAG_1; + if ((this->unk_2EE == 5) && (this->unk_2EE == 7)) { + this->actor.flags &= ~ACTOR_FLAG_1; + } + } else { + this->actor.flags &= ~ACTOR_FLAG_80; + this->actor.flags &= ~ACTOR_FLAG_1; + } + + this->actionFunc(this, globalCtx); + + func_80B3AC50(this); + func_80B3AC94(this, globalCtx); + Actor_MoveWithoutGravity(&this->actor); + SkelAnime_Update(&this->skelAnime); + func_80B3B8A4(this); + func_800E9250(globalCtx, &this->actor, &this->unk_1E0, &this->unk_1E6, this->actor.focus.pos); + + if ((this->unk_2EE == 5) || (this->unk_2EE == 7)) { + func_800B9010(&this->actor, NA_SE_EN_SHARP_FLOAT - SFX_FLAG); + if ((globalCtx->actorCtx.unk4 == 100) && ((globalCtx->state.frames % 4) == 0)) { + func_80B3B4B0(this, globalCtx); + } + } + + func_80B3ADD8(this); +} + +s32 func_80B3BD44(GlobalContext* globalCtx, 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) { + Matrix_RotateY(this->unk_2F6, MTXMODE_APPLY); + } + + if (limbIndex == 2) { + Matrix_InsertZRotation_s(this->unk_2F4, MTXMODE_APPLY); + } + } + return false; +} + +void func_80B3BDC0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnGg2* this = THIS; + + if (limbIndex == 4) { + Matrix_MultiplyVector3fByState(&D_80B3C0A0, &this->unk_304); + } +} + +void EnGg2_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnGg2* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (this->unk_2F0 == 1)) { + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B3C0AC[this->unk_2EA])); + + POLY_XLU_DISP = + SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, func_80B3BD44, func_80B3BDC0, &this->actor, POLY_XLU_DISP); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 dc4684272..0fea44822 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h @@ -7,11 +7,32 @@ struct EnGg2; typedef void (*EnGg2ActionFunc)(struct EnGg2*, GlobalContext*); +#define ENGG2_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) + typedef struct EnGg2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ UNK_TYPE1 unk144[0x4C]; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnGg2ActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x138]; + /* 0x01D8 */ Path* unk_1D8; + /* 0x01DC */ s32 unk_1DC; + /* 0x01E0 */ Vec3s unk_1E0; + /* 0x01E6 */ Vec3s unk_1E6; + /* 0x01EC */ Vec3s jointTable[20]; + /* 0x0264 */ Vec3s morphTable[20]; + /* 0x02DC */ UNK_TYPE1 unk2DC[0x8]; + /* 0x02E4 */ s16 unk_2E4; + /* 0x02E6 */ UNK_TYPE1 unk2E6[4]; + /* 0x02EA */ s16 unk_2EA; + /* 0x02EC */ s16 unk_2EC; + /* 0x02EE */ s16 unk_2EE; + /* 0x02F0 */ u8 unk_2F0; + /* 0x02F1 */ u8 unk_2F1; + /* 0x02F2 */ s16 unk_2F2; + /* 0x02F4 */ s16 unk_2F4; + /* 0x02F6 */ s16 unk_2F6; + /* 0x02F8 */ UNK_TYPE1 unk2F8[0xC]; + /* 0x0304 */ Vec3f unk_304; } EnGg2; // size = 0x310 extern const ActorInit En_Gg2_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index b48b5c197..2f590e909 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1363,11 +1363,6 @@ D_0600A344 = 0x0600A344; D_06001EFC = 0x06001EFC; D_0600A808 = 0x0600A808; -// ovl_En_Gg2 - -D_0600F578 = 0x0600F578; -D_0600F6C0 = 0x0600F6C0; - // ovl_En_Goron_Oyu D_06000988 = 0x06000988; From f87cabbc5529d96af1e05ea6d4d65c50573c3aae Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 5 Mar 2022 14:27:33 +0000 Subject: [PATCH 065/257] En_Butte (#683) --- include/functions.h | 2 +- spec | 3 +- src/overlays/actors/ovl_En_Butte/z_en_butte.c | 419 ++++++++++++++++-- src/overlays/actors/ovl_En_Butte/z_en_butte.h | 23 +- 4 files changed, 409 insertions(+), 38 deletions(-) diff --git a/include/functions.h b/include/functions.h index 40ec3c1de..529de810a 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1144,7 +1144,7 @@ u32 Camera_ChangeDataIdx(Camera* camera, u32 camDataIdx); // void func_800DFC1C(void); // void func_800DFC40(void); s32 Camera_GetInputDirYaw(Camera* camera); -// void func_800DFC90(void); +void func_800DFC90(Vec3s* arg0, Camera* camera); s16 Camera_GetCamDirPitch(Camera* camera); s16 Camera_GetCamDirYaw(Camera* camera); void func_800DFD04(Camera* camera, s32 arg1, s32 arg2, s32 arg3); diff --git a/spec b/spec index 5a7e765a9..002ae8465 100644 --- a/spec +++ b/spec @@ -1362,8 +1362,7 @@ beginseg name "ovl_En_Butte" compress include "build/src/overlays/actors/ovl_En_Butte/z_en_butte.o" - include "build/data/ovl_En_Butte/ovl_En_Butte.data.o" - include "build/data/ovl_En_Butte/ovl_En_Butte.reloc.o" + include "build/src/overlays/actors/ovl_En_Butte/ovl_En_Butte_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.c b/src/overlays/actors/ovl_En_Butte/z_en_butte.c index 54dd34dbc..ea70a1480 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.c +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.c @@ -5,6 +5,8 @@ */ #include "z_en_butte.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000000 @@ -15,24 +17,40 @@ void EnButte_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnButte_Update(Actor* thisx, GlobalContext* globalCtx); void EnButte_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_8091C748(EnButte* this); void func_8091C794(EnButte* this, GlobalContext* globalCtx); +void func_8091CB68(EnButte* this); void func_8091CBB4(EnButte* this, GlobalContext* globalCtx); +void func_8091CF64(EnButte* this); void func_8091CFB4(EnButte* this, GlobalContext* globalCtx); +void func_8091D070(EnButte* this); void func_8091D090(EnButte* this, GlobalContext* globalCtx); -#if 0 -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8091D2D0[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 5 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8091D2F4 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_8091D2D0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; const ActorInit En_Butte_InitVars = { @@ -47,54 +65,389 @@ const ActorInit En_Butte_InitVars = { (ActorFunc)EnButte_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8091D3B0[] = { +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ s16 unk_10; +} EnButteStruct; // size = 0x14 + +EnButteStruct D_8091D324[] = { + { 5, 35, 0.0f, 0.1f, 0.5f, 0 }, + { 10, 45, 1.1f, 0.1f, 0.25f, 1000 }, + { 10, 40, 1.5f, 0.1f, 0.3f, 2000 }, +}; + +EnButteStruct D_8091D360[] = { + { 3, 3, 0.8f, 0.1f, 0.2f, 0 }, + { 10, 20, 2.0f, 0.3f, 1.0f, 0 }, + { 10, 20, 2.4f, 0.3f, 1.0f, 0 }, +}; + +f32 D_8091D39C = 0.0f; + +s16 D_8091D3A0 = 0; + +Vec3f D_8091D3A4 = { 0.0f, 0.0f, -3.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 700, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 20, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 60, ICHAIN_STOP), }; -#endif +f32 D_8091D3C0[] = { 50.0f, 80.0f, 100.0f }; -extern ColliderJntSphElementInit D_8091D2D0[1]; -extern ColliderJntSphInit D_8091D2F4; -extern InitChainEntry D_8091D3B0[]; +f32 D_8091D3CC[] = { 30.0f, 40.0f, 50.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C0A0.s") +f32 D_8091D3D8[] = { 15.0f, 20.0f, 25.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C124.s") +f32 D_8091D3E4[] = { 7.5f, 10.0f, 12.5f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C140.s") +s32 D_8091D3F0 = 1500; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C178.s") +void func_8091C0A0(EnButte* this, EnButteStruct* arg1) { + if (this->unk_24E == 0) { + if (Rand_ZeroOne() < 0.6f) { + this->unk_24E = 1; + } else { + this->unk_24E = 2; + } + } else { + this->unk_24E = 0; + } + this->unk_24C = Rand_S16Offset(arg1->unk_00, arg1->unk_02); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/EnButte_Init.s") +void func_8091C124(void) { + D_8091D39C = 0.0f; + D_8091D3A0 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/EnButte_Destroy.s") +void func_8091C140(void) { + D_8091D39C += 0.003f; + D_8091D3A0 += 0xFA0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C524.s") +void func_8091C178(EnButte* this, GlobalContext* globalCtx) { + Vec3f sp4C; + s32 sp48; + Vec3s sp40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C5EC.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C6B4.s") + func_8012C240(globalCtx->state.gfxCtx); + sp48 = Math_SinS(D_8091D3A0) * 250.0f; + sp48 = CLAMP(sp48, 0, 255); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C748.s") + func_800DFC90(&sp40, GET_ACTIVE_CAM(globalCtx)); + Matrix_RotateY(sp40.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(sp40.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(sp40.z, MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&D_8091D3A4, &sp4C); + Matrix_SetStateRotationAndTranslation(this->actor.focus.pos.x + sp4C.x, this->actor.focus.pos.y + sp4C.y, + this->actor.focus.pos.z + sp4C.z, &sp40); + Matrix_Scale(D_8091D39C, D_8091D39C, D_8091D39C, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C794.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 200, 200, 180, sp48); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 210, 255); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091CB68.s") + CLOSE_DISPS(globalCtx->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091CBB4.s") +void EnButte_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnButte* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091CF64.s") + if (ENBUTTE_GET(&this->actor) == ENBUTTE_MINUS1) { + this->actor.params = ENBUTTE_0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091CFB4.s") + this->actor.world.rot.y = Rand_Next(); + this->actor.home.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.y = this->actor.world.rot.y; + Actor_ProcessInitChain(&this->actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091D070.s") + if ((ENBUTTE_GET_1(&this->actor) & 0xFF) == ENBUTTE_1) { + this->actor.uncullZoneScale = 200.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091D090.s") + SkelAnime_Init(globalCtx, &this->skelAnime, &gameplay_field_keep_Skel_002FA0, &gameplay_field_keep_Anim_001D20, + this->jointTable, this->morphTable, 8); + Collider_InitJntSph(globalCtx, &this->collider); + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colldierElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/EnButte_Update.s") + this->collider.elements[0].dim.worldSphere.radius = + this->collider.elements[0].dim.scale * this->collider.elements[0].dim.modelSphere.radius; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/EnButte_Draw.s") + this->actor.colChkInfo.mass = 0; + this->unk_254 = Rand_ZeroOne() * 0xFFFF; + this->unk_256 = Rand_ZeroOne() * 0xFFFF; + this->unk_258 = Rand_ZeroOne() * 0xFFFF; + + Animation_Change(&this->skelAnime, &gameplay_field_keep_Anim_001D20, 1.0f, 0.0f, 0.0f, 1, 0.0f); + func_8091C748(this); + this->actor.shape.rot.x -= 0x2320; + this->unk_250 = 1; +} + +void EnButte_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyJntSph(globalCtx, &THIS->collider); +} + +void func_8091C524(EnButte* this) { + this->actor.shape.yOffset += + (Math_SinS(this->unk_254) * D_8091D3C0[this->unk_24E]) + (Math_SinS(this->unk_256) * D_8091D3CC[this->unk_24E]); + this->actor.shape.yOffset = CLAMP(this->actor.shape.yOffset, -2000.0f, 2000.0f); +} + +void func_8091C5EC(EnButte* this) { + this->actor.shape.yOffset += + (Math_SinS(this->unk_254) * D_8091D3D8[this->unk_24E]) + (Math_SinS(this->unk_256) * D_8091D3E4[this->unk_24E]); + this->actor.shape.yOffset = CLAMP(this->actor.shape.yOffset, -500.0f, 500.0f); +} + +void func_8091C6B4(EnButte* this) { + s16 temp_a1 = BINANG_ROT180(this->actor.world.rot.y); + s16 temp_v0 = temp_a1 - this->actor.shape.rot.y; + + Math_ScaledStepToS(&this->actor.shape.rot.y, temp_a1, ABS_ALT(temp_v0) >> 3); + this->actor.shape.rot.x = (s16)(Math_SinS(this->unk_258) * 600.0f) - 0x2320; +} + +void func_8091C748(EnButte* this) { + func_8091C0A0(this, &D_8091D324[this->unk_24E]); + this->actionFunc = func_8091C794; +} + +void func_8091C794(EnButte* this, GlobalContext* globalCtx) { + EnButteStruct* sp4C = &D_8091D324[this->unk_24E]; + f32 distSq; + Player* player = GET_PLAYER(globalCtx); + f32 distFromHomeSq = Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, + this->actor.home.pos.x, this->actor.home.pos.z); + f32 playSpeed; + f32 sp38; + s32 pad; + s16 sp32; + s16 yaw; + + func_8091C524(this); + Math_SmoothStepToF(&this->actor.speedXZ, sp4C->unk_04, sp4C->unk_08, sp4C->unk_0C, 0.0f); + + if (this->unk_24F == 1) { + distSq = SQ(100.0f); + sp32 = 0x3E8; + } else { + distSq = SQ(35.0f); + sp32 = 0x258; + } + + sp38 = 0.0f; + this->unk_25C = this->actor.home.pos.y; + + if ((this->unk_24E != 0) && ((distSq < distFromHomeSq) || (this->unk_24C < 4))) { + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); + if (!Math_ScaledStepToS(&this->actor.world.rot.y, yaw, sp4C->unk_10)) { + sp38 = 0.5f; + } + } else if ((this->unk_24F == 0) && (this->actor.child != NULL) && (&this->actor != this->actor.child)) { + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.child->world.pos); + if (!Math_ScaledStepToS(&this->actor.world.rot.y, yaw, sp32)) { + sp38 = 0.3f; + } + } else if (this->unk_24F == 1) { + if (!Math_ScaledStepToS(&this->actor.world.rot.y, + (s32)((Rand_ZeroOne() - 0.5f) * 0x6000) + this->actor.yawTowardsPlayer + 0x8000, + sp32)) { + sp38 = 0.4f; + } + } else { + this->actor.world.rot.y += (s16)(Math_SinS(this->unk_254) * 100.0f); + } + + func_8091C6B4(this); + + playSpeed = + (((this->actor.speedXZ * 0.5f) + (Rand_ZeroOne() * 0.2f)) + ((1.0f - Math_SinS(this->unk_258)) * 0.15f)) + + ((1.0f - Math_SinS(this->unk_256)) * 0.3f) + sp38; + this->skelAnime.playSpeed = CLAMP(playSpeed, 0.2f, 1.5f); + + SkelAnime_Update(&this->skelAnime); + + if (this->unk_24C <= 0) { + func_8091C0A0(this, &D_8091D324[this->unk_24E]); + } + + if ((ENBUTTE_GET_1(&this->actor) == ENBUTTE_1) && (player->itemActionParam == 7) && (this->unk_252 <= 0) && + ((Math3D_XZDistanceSquared(player->actor.world.pos.x, player->actor.world.pos.z, this->actor.home.pos.x, + this->actor.home.pos.z) < SQ(120.0f)) || + (this->actor.xzDistToPlayer < 60.0f))) { + func_8091CB68(this); + this->unk_24F = 2; + } else if (this->actor.xzDistToPlayer < 120.0f) { + this->unk_24F = 1; + } else { + this->unk_24F = 0; + } +} + +void func_8091CB68(EnButte* this) { + func_8091C0A0(this, &D_8091D360[this->unk_24E]); + this->actionFunc = func_8091CBB4; +} + +void func_8091CBB4(EnButte* this, GlobalContext* globalCtx) { + EnButteStruct* sp5C = &D_8091D360[this->unk_24E]; + Player* player = GET_PLAYER(globalCtx); + f32 playSpeed; + Vec3f sp48; + f32 distSq; + f32 sp40; + s32 pad; + s16 pad2; + s16 yaw; + + func_8091C5EC(this); + Math_SmoothStepToF(&this->actor.speedXZ, sp5C->unk_04, sp5C->unk_08, sp5C->unk_0C, 0.0f); + sp40 = 0.0f; + + if ((this->unk_24E != 0) && (this->unk_24C < 12)) { + sp48.x = player->swordInfo[0].tip.x + (Math_SinS(player->actor.shape.rot.y) * 10.0f); + sp48.y = player->swordInfo[0].tip.y; + sp48.z = player->swordInfo[0].tip.z + (Math_CosS(player->actor.shape.rot.y) * 10.0f); + + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &sp48); + if (Math_ScaledStepToS(&this->actor.world.rot.y, yaw + (s32)(Rand_ZeroOne() * D_8091D3F0), 0x7D0)) { + if ((globalCtx->gameplayFrames & 0x30) == 0x30) { + this->actor.world.rot.y += (s16)(Math_SinS(this->unk_254) * 60.0f); + } + } else { + sp40 = 0.3f; + } + } + + if (player->swordInfo[0].tip.y < player->actor.world.pos.y + 30.0f) { + this->unk_25C = player->actor.world.pos.y + 30.0f; + } else { + this->unk_25C = player->swordInfo[0].tip.y; + } + + func_8091C6B4(this); + + playSpeed = ((this->actor.speedXZ * 0.5f) + (Rand_ZeroOne() * 0.2f) + ((1.0f - Math_SinS(this->unk_258)) * 0.15f)) + + ((1.0f - Math_SinS(this->unk_256)) * 0.3f) + sp40; + this->skelAnime.playSpeed = CLAMP(playSpeed, 0.2f, 1.5f); + SkelAnime_Update(&this->skelAnime); + + if (this->unk_24C <= 0) { + func_8091C0A0(this, &D_8091D360[this->unk_24E]); + D_8091D3F0 = -D_8091D3F0; + } + + distSq = Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, this->actor.home.pos.x, + this->actor.home.pos.z); + if ((player->itemActionParam != 7) || !(fabsf(player->actor.speedXZ) < 1.8f) || (this->unk_252 > 0) || + !(distSq < SQ(320.0f))) { + func_8091C748(this); + } else if ((distSq > SQ(240.0f)) && + (Math3D_XZDistanceSquared(player->swordInfo[0].tip.x, player->swordInfo[0].tip.z, + this->actor.world.pos.x, this->actor.world.pos.z) < SQ(60.0f))) { + func_8091CF64(this); + } +} + +void func_8091CF64(EnButte* this) { + this->unk_24C = 9; + this->actor.flags |= ACTOR_FLAG_10; + this->skelAnime.playSpeed = 1.0f; + func_8091C124(); + this->actionFunc = func_8091CFB4; +} + +void func_8091CFB4(EnButte* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + func_8091C140(); + + if (this->unk_24C == 5) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 60, NA_SE_EV_BUTTERFRY_TO_FAIRY); + } else if (this->unk_24C == 4) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, this->actor.focus.pos.x, this->actor.focus.pos.y, + this->actor.focus.pos.z, 0, this->actor.shape.rot.y, 0, 2); + this->unk_250 = 0; + } else if (this->unk_24C <= 0) { + func_8091D070(this); + } +} + +void func_8091D070(EnButte* this) { + this->unk_24C = 64; + this->actionFunc = func_8091D090; + this->actor.draw = NULL; +} + +void func_8091D090(EnButte* this, GlobalContext* globalCtx) { + if (this->unk_24C <= 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnButte_Update(Actor* thisx, GlobalContext* globalCtx) { + EnButte* this = THIS; + + if ((this->actor.child != NULL) && (this->actor.child->update == NULL) && (&this->actor != this->actor.child)) { + this->actor.child = NULL; + } + + if (this->unk_24C > 0) { + this->unk_24C--; + } + + this->unk_254 += 0x222; + this->unk_256 += 0x1000; + this->unk_258 += 0x600; + + if (ENBUTTE_GET_1(&this->actor) == ENBUTTE_1) { + if (GET_PLAYER(globalCtx)->swordState == 0) { + if (this->unk_252 > 0) { + this->unk_252--; + } + } else { + this->unk_252 = 80; + } + } + + this->actionFunc(this, globalCtx); + + if (this->actor.update != NULL) { + Actor_MoveWithGravity(&this->actor); + Math_StepToF(&this->actor.world.pos.y, this->unk_25C, 0.6f); + if (this->actor.xyzDistToPlayerSq < 5000.0f) { + ColliderJntSphElement* element = &this->collider.elements[0]; + + element->dim.worldSphere.center.x = this->actor.world.pos.x; + element->dim.worldSphere.center.y = this->actor.world.pos.y; + element->dim.worldSphere.center.z = this->actor.world.pos.z; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + Actor_SetFocus(&this->actor, this->actor.shape.yOffset * this->actor.scale.y); + } +} + +void EnButte_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnButte* this = THIS; + + if (this->unk_250 != 0) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); + } + + if ((ENBUTTE_GET_1(&this->actor) == ENBUTTE_1) && (this->actionFunc == func_8091CFB4)) { + func_8091C178(this, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.h b/src/overlays/actors/ovl_En_Butte/z_en_butte.h index 1de720b8d..361096961 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.h +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.h @@ -7,11 +7,30 @@ struct EnButte; typedef void (*EnButteActionFunc)(struct EnButte*, GlobalContext*); +#define ENBUTTE_GET(thisx) ((thisx)->params) +#define ENBUTTE_GET_1(thisx) ((thisx)->params & 1) + +#define ENBUTTE_MINUS1 -1 +#define ENBUTTE_0 0 +#define ENBUTTE_1 1 + typedef struct EnButte { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; + /* 0x0144 */ ColliderJntSph collider; + /* 0x0164 */ ColliderJntSphElement colldierElements[1]; + /* 0x01A4 */ SkelAnime skelAnime; + /* 0x01E8 */ Vec3s jointTable[8]; + /* 0x0218 */ Vec3s morphTable[8]; /* 0x0248 */ EnButteActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x14]; + /* 0x024C */ s16 unk_24C; + /* 0x024E */ u8 unk_24E; + /* 0x024F */ u8 unk_24F; + /* 0x0250 */ u8 unk_250; + /* 0x0252 */ s16 unk_252; + /* 0x0254 */ s16 unk_254; + /* 0x0256 */ s16 unk_256; + /* 0x0258 */ s16 unk_258; + /* 0x025C */ f32 unk_25C; } EnButte; // size = 0x260 extern const ActorInit En_Butte_InitVars; From f9dac7d483a61ba5de4e12c4f10682504ea1e530 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 5 Mar 2022 06:34:26 -0800 Subject: [PATCH 066/257] En_Racedog OK (#690) * func_80B24630 OK * func_80B248B8 OK * func_80B246F4 OK * func_80B25448 OK * func_80B256BC OK * EnRacedog_Draw OK * LimbDraw functions OK * func_80B2583C OK * func_80B258D8 OK * EnRacedog_Update OK * func_80B255AC OK * func_80B2538C OK * func_80B252F8 OK * Data imported to C * Update struct to have everything Init needs * func_80B24E14 OK * EnRacedog_Destroy OK * func_80B24C14 OK * EnRacedog_Init OK * func_80B2478C OK * func_80B24CB4 OK * func_80B251EC OK * func_80B24F08 OK * func_80B25490 OK * Use generated reloc * Object symbols and other misc cleanup * More cleanup * Move data to be in-function like how Dg does it * Rename to ENRACEDOG_GET_3E0 until this actor is actually documented * Last itty bitty cleanup * Better header * Forgot to name the LimbDraw functions, whoops * Respond to reviews * Match how Dg does weekEventReg stuff * Respond to review --- spec | 3 +- .../actors/ovl_En_Racedog/z_en_racedog.c | 617 ++++++++++++++++-- .../actors/ovl_En_Racedog/z_en_racedog.h | 39 +- tools/disasm/functions.txt | 4 +- tools/disasm/variables.txt | 31 +- undefined_syms.txt | 6 - 6 files changed, 619 insertions(+), 81 deletions(-) diff --git a/spec b/spec index 002ae8465..6b09b9b21 100644 --- a/spec +++ b/spec @@ -3954,8 +3954,7 @@ beginseg name "ovl_En_Racedog" compress include "build/src/overlays/actors/ovl_En_Racedog/z_en_racedog.o" - include "build/data/ovl_En_Racedog/ovl_En_Racedog.data.o" - include "build/data/ovl_En_Racedog/ovl_En_Racedog.reloc.o" + include "build/src/overlays/actors/ovl_En_Racedog/ovl_En_Racedog_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index 34ba30652..b490d8d1d 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -1,10 +1,15 @@ /* * File: z_en_racedog.c * Overlay: ovl_En_Racedog - * Description: Racetrack Dog + * Description: The dogs that run around the racetrack during the dog race. + * + * Note that the dogs milling about the Doggy Racetrack prior to and after the + * race are actually En_Dg. This actor is solely concerned with the dogs that + * actually perform the race by running around the track. */ #include "z_en_racedog.h" +#include "objects/object_dog/object_dog.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) @@ -17,8 +22,25 @@ void EnRacedog_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80B24C14(EnRacedog* this, GlobalContext* globalCtx); void func_80B24CB4(EnRacedog* this, GlobalContext* globalCtx); +void func_80B24E14(EnRacedog* this); +void func_80B24F08(EnRacedog* this); +void func_80B251EC(EnRacedog* this); +void func_80B252F8(EnRacedog* this); +void func_80B2538C(EnRacedog* this); +void func_80B25448(EnRacedog* this); +s32 func_80B25490(EnRacedog* this, Vec2f* arg1); +void func_80B255AC(EnRacedog* this, GlobalContext* globalCtx); +void func_80B256BC(EnRacedog* this); + +typedef struct { + f32 unk_00; + f32 unk_04; + s16 unk_08; + s16 unk_0A; + s16 unk_0C; + s16 unk_0E; +} UnkRacedogStruct; -#if 0 const ActorInit En_Racedog_InitVars = { ACTOR_EN_RACEDOG, ACTORCAT_NPC, @@ -31,18 +53,60 @@ const ActorInit En_Racedog_InitVars = { (ActorFunc)EnRacedog_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B25E98 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static s16 D_80B25D40 = 0; + +static s16 D_80B25D44 = -1; + +static s16 D_80B25D48 = 0; + +static s16 D_80B25D4C = -1; + +static f32 D_80B25D50[][2] = { + { 0.0f, 0.0f }, { 5.0f, 5.5f }, { 5.0f, 5.0f }, { 5.5f, 5.0f }, { 4.5f, 5.5f }, { 6.0f, 4.0f }, { 4.0f, 6.0f }, +}; + +static UnkRacedogStruct D_80B25D88[] = { + { -1.0f, 1.20000004768f, 3, 0, 9, 0x3539 }, { -1.0f, 1.20000004768f, 1, 1, 9, 0x353A }, + { -1.0f, 1.20000004768f, 5, 2, 10, 0x353B }, { -1.0f, 1.20000004768f, 2, 3, 9, 0x353C }, + { -1.0f, 1.20000004768f, 4, 4, 8, 0x353D }, { -1.0f, 1.20000004768f, 2, 5, 9, 0x353E }, + { -1.0f, 1.20000004768f, 3, 6, 9, 0x353F }, { -1.0f, 1.20000004768f, 1, 7, 9, 0x3540 }, + { -1.0f, 1.20000004768f, 1, 8, 9, 0x3541 }, { -1.0f, 1.20000004768f, 6, 9, 8, 0x3542 }, + { -1.0f, 1.20000004768f, 2, 10, 9, 0x3543 }, { -1.0f, 1.20000004768f, 3, 11, 9, 0x3544 }, + { -1.0f, 1.20000004768f, 1, 12, 9, 0x3545 }, { -1.0f, 1.20000004768f, 4, 13, 8, 0x3546 }, +}; + +static UnkRacedogStruct D_80B25E68 = { -1.0f, 1.0, 0, -1, 0, 0x353E }; + +static Vec2f D_80B25E78[] = { + { -3914.0f, 1283.0f }, + { -3747.0f, 1104.0f }, + { -3717.0f, 1169.0f }, + { -3897.0f, 1308.0f }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 13, 19, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B25EC4 = { 0, 0, 0, 0, 1 }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, 1 }; -// static DamageTable sDamageTable = { -static DamageTable D_80B25ED0 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -77,63 +141,532 @@ static DamageTable D_80B25ED0 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B25FF0[] = { +static AnimationInfoS D_80B25EF0[] = { + { &object_dog_Anim_0021C8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dog_Anim_0021C8, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &object_dog_Anim_001BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dog_Anim_000998, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &object_dog_Anim_001FB0, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, + { &object_dog_Anim_001FB0, 1.0f, 0, -1, ANIMMODE_LOOP_PARTIAL, -6 }, + { &object_dog_Anim_001048, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, + { &object_dog_Anim_001348, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &object_dog_Anim_001048, 1.0f, 0, 27, ANIMMODE_ONCE, -6 }, + { &object_dog_Anim_001048, 1.0f, 28, -1, ANIMMODE_ONCE, -6 }, + { &object_dog_Anim_001048, 1.0f, 54, 54, ANIMMODE_ONCE, -6 }, + { &object_dog_Anim_0021C8, -1.5f, -1, 0, ANIMMODE_LOOP, -6 }, + { &object_dog_Anim_001560, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dog_Anim_001A84, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dog_Anim_0017C0, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dog_Anim_0021C8, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -#endif +void func_80B24630(SkelAnime* skelAnime, AnimationInfoS arg1[], s32 arg2) { + f32 frameCount; -extern ColliderCylinderInit D_80B25E98; -extern CollisionCheckInfoInit2 D_80B25EC4; -extern DamageTable D_80B25ED0; -extern InitChainEntry D_80B25FF0[]; + arg1 += arg2; + if (arg1->frameCount < 0) { + frameCount = Animation_GetLastFrame(arg1->animation); + } else { + frameCount = arg1->frameCount; + } -extern UNK_TYPE D_06000618; -extern UNK_TYPE D_060080F0; + Animation_Change(skelAnime, arg1->animation, arg1->playSpeed + (BREG(88) * 0.1f), arg1->startFrame, frameCount, + arg1->mode, arg1->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B24630.s") +void func_80B246F4(EnRacedog* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 26.0f, 10.0f, 0.0f, 5); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B246F4.s") +s16 func_80B2478C(Path* path, s32 arg1, Vec3f* pos, f32* arg3) { + Vec3s* point; + f32 phi_f14; + f32 sp1C; + f32 xDiff; + f32 zDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B2478C.s") + if (path != NULL) { + point = Lib_SegmentedToVirtual(path->points); + point = &point[arg1]; + phi_f14 = (randPlusMinusPoint5Scaled(100.0f) + point->x) - pos->x; + sp1C = (randPlusMinusPoint5Scaled(100.0f) + point->z) - pos->z; + xDiff = point->x - pos->x; + zDiff = point->z - pos->z; + } else { + phi_f14 = 0.0f; + sp1C = 0.0f; + xDiff = 0.0f; + zDiff = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B248B8.s") + *arg3 = SQ(xDiff) + SQ(zDiff); + return RADF_TO_BINANG(Math_Acot2F(sp1C, phi_f14)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/EnRacedog_Init.s") +void func_80B248B8(EnRacedog* this, Vec3f* arg1) { + f32 sp20; + f32 sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/EnRacedog_Destroy.s") + if (this->actor.floorPoly != NULL) { + sp20 = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); + sp1C = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B24C14.s") + arg1->x = -Math_Acot2F(1.0f, -sp1C * sp20); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B24CB4.s") +void EnRacedog_Init(Actor* thisx, GlobalContext* globalCtx) { + EnRacedog* this = THIS; + ColliderCylinder* collider = &this->collider; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B24E14.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dog_Skel_0080F0, NULL, this->jointTable, this->morphTable, + 13); + Collider_InitCylinder(globalCtx, collider); + Collider_SetCylinder(globalCtx, collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B24F08.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->unk_1E0 = func_8013D648(globalCtx, ENRACEDOG_GET_PATH(&this->actor), 0x3F); + Actor_SetScale(&this->actor, 0.0075f); + this->actor.gravity = -3.0f; + if (ENRACEDOG_GET_3E0(&this->actor) < 14) { + this->unk_290 = ENRACEDOG_GET_3E0(&this->actor); + } else { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B251EC.s") + this->unk_2BC = 0xFF; + this->unk_2C0 = 0x32; + this->unk_288 = 0xC; + this->unk_2A0.x = 0.0f; + this->unk_2A0.y = 0.0f; + this->unk_2A0.z = 0.0f; + this->unk_2C4 = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B252F8.s") + if ((D_80B25D88[this->unk_290].unk_0E >= 0x353F) && (this->unk_290 == (s16)Rand_ZeroFloat(20.0f))) { + this->unk_28C = 5; + } else { + this->unk_28C = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B2538C.s") + this->unk_28A = 60; + this->unk_28A += this->unk_28C; + this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][0]; + this->unk_29C = 0; + this->unk_2B8 = -1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B25448.s") + func_80B24E14(this); + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_20; + D_80B25E68 = D_80B25D88[(s16)((gSaveContext.eventInf[0] & 0xF8) >> 3)]; + this->unk_292 = D_80B25E68.unk_0A; + func_80B24630(&this->skelAnime, D_80B25EF0, 0); + D_80B25EF0->playSpeed = Rand_ZeroFloat(0.5f) + 1.0f; + this->actionFunc = func_80B24C14; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B25490.s") +void EnRacedog_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnRacedog* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B255AC.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B256BC.s") +void func_80B24C14(EnRacedog* this, GlobalContext* globalCtx) { + s16 phi_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/EnRacedog_Update.s") + if (this->unk_28A == 0) { + phi_v1 = 0; + } else { + this->unk_28A--; + phi_v1 = this->unk_28A; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B2583C.s") + if (phi_v1 == 0) { + this->unk_28A = Rand_S16Offset(50, 50); + if (this->unk_28C == 0) { + play_sound(NA_SE_SY_START_SHOT); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B258D8.s") + func_80B24630(&this->skelAnime, D_80B25EF0, 2); + this->actionFunc = func_80B24CB4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B25A74.s") +void func_80B24CB4(EnRacedog* this, GlobalContext* globalCtx) { + s16 phi_a1; + f32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B25A90.s") + this->collider.dim.radius = 15; + if (this->unk_1E0 != 0) { + phi_a1 = func_80B2478C(this->unk_1E0, this->unk_1E8, &this->actor.world.pos, &sp30); + if (this->actor.bgCheckFlags & 8) { + phi_a1 = this->actor.wallYaw; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/EnRacedog_Draw.s") + Math_SmoothStepToS(&this->actor.world.rot.y, phi_a1, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + + if (sp30 <= 2500.0f) { + this->unk_1E8++; + if (this->unk_1E8 >= (this->unk_1E0->count - 1)) { + this->unk_1E8 = 0; + } + } + + func_80B24F08(this); + if ((this->unk_1E8 >= ((this->unk_1E0->count / 4) * 3)) && (this->unk_290 == D_80B25D4C)) { + D_80B25D48++; + } + + func_80B252F8(this); + func_80B2538C(this); + Actor_MoveWithGravity(&this->actor); + } + + func_80B25448(this); + func_80B256BC(this); + func_80B255AC(this, globalCtx); +} + +void func_80B24E14(EnRacedog* this) { + if (this->unk_290 % 2) { + D_80B25D88[this->unk_290].unk_0E = + (((gSaveContext.weekEventReg[42 + (this->unk_290 / 2)]) & (0x10 | 0x20 | 0x40 | 0x80)) >> 4) + 0x3539; + } else { + D_80B25D88[this->unk_290].unk_0E = + ((gSaveContext.weekEventReg[42 + (this->unk_290 / 2)]) & (1 | 2 | 4 | 8)) + 0x3539; + } + + if ((D_80B25D88[this->unk_290].unk_0E >= 0x3547) || (D_80B25D88[this->unk_290].unk_0E < 0x3539)) { + D_80B25D88[this->unk_290].unk_0E = 0x353E; + } + if (D_80B25D88[this->unk_290].unk_0E == 0x3547) { + D_80B25D88[this->unk_290].unk_0E = 0x3538; + } +} + +void func_80B24F08(EnRacedog* this) { + s32 temp_a0; + s32 temp_v1 = this->unk_1E0->count; + + if (this->unk_2B8 < this->unk_1E8) { + this->unk_2B8 = this->unk_1E8; + if (this->unk_1E8 == 0) { + this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][0]; + } else { + temp_a0 = temp_v1 / 4; + if (this->unk_1E8 < temp_a0) { + if (D_80B25D88[this->unk_290].unk_08 == 5) { + this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][0] + randPlusMinusPoint5Scaled(1.0f); + } else { + this->unk_298 = 5.0f + randPlusMinusPoint5Scaled(1.0f); + } + + if ((D_80B25D88[this->unk_290].unk_0E < 0x353E) && (this->unk_290 != D_80B25D4C)) { + this->unk_298 *= D_80B25D88[this->unk_290].unk_04; + } + } else if (this->unk_1E8 < (temp_a0 * 3)) { + if (this->unk_1E8 < D_80B25D88[this->unk_290].unk_0C) { + this->unk_298 = 5.0f + randPlusMinusPoint5Scaled(1.0f); + } else { + this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][1] + randPlusMinusPoint5Scaled(1.0f); + + if ((D_80B25D88[this->unk_290].unk_0E < 0x353E) && (this->unk_290 != D_80B25D4C)) { + this->unk_298 *= D_80B25D88[this->unk_290].unk_04; + } + } + } else if (this->unk_1E8 < temp_v1) { + func_80B251EC(this); + } else { + this->unk_298 = randPlusMinusPoint5Scaled(1.0f) + 5.0f; + } + } + } + + if ((this->unk_1E8 != 0) || (this->unk_29C != 0)) { + this->actor.shape.rot.y = this->actor.world.rot.y; + } + + Math_ApproachF(&this->actor.speedXZ, this->unk_298, 0.5f, 3.0f); + + if (this->unk_290 == this->unk_292) { + if (this->actor.speedXZ > 7.5f) { + this->actor.speedXZ = 7.5f; + } + } else { + if (this->actor.speedXZ > 7.0f) { + this->actor.speedXZ = 7.0f; + } + } +} + +void func_80B251EC(EnRacedog* this) { + f32 temp; + + if (D_80B25D88[this->unk_290].unk_00 == -1.0f) { + if (D_80B25D48 < 100.0f) { + D_80B25D88[this->unk_290].unk_00 = 200.0f / (200.0f - D_80B25D48); + } else { + D_80B25D88[this->unk_290].unk_00 = 2.0f; + } + } + + if (D_80B25D88[this->unk_290].unk_0E < 0x3542) { + temp = D_80B25D88[this->unk_290].unk_00; + this->unk_298 = temp * D_80B25D50[D_80B25D88[this->unk_290].unk_08][1]; + } + + if ((D_80B25D88[this->unk_290].unk_0E < 0x353E) && (this->unk_290 != D_80B25D4C)) { + this->unk_298 *= D_80B25D88[this->unk_290].unk_04; + } +} + +void func_80B252F8(EnRacedog* this) { + if ((this->unk_1E8 >= 9) && (this->unk_29C == 0)) { + this->unk_29C = 1; + } + + if ((this->unk_1E8 >= 0xB) && (this->unk_29C == 1)) { + this->unk_29C = 2; + } + + if (((this->unk_1E8 >= D_80B25D44) || (this->unk_29C <= 0)) && (this->unk_1E8 > D_80B25D44)) { + D_80B25D44 = this->unk_1E8; + D_80B25D4C = this->unk_290; + } +} + +void func_80B2538C(EnRacedog* this) { + if (func_80B25490(this, D_80B25E78) && this->unk_29C == 2) { + D_80B25D40++; + if (D_80B25D40 == 1) { + Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000); + play_sound(NA_SE_SY_START_SHOT); + } + + this->unk_29C = 3; + if (this->unk_290 == this->unk_292) { + gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 7) | (D_80B25D40 * 8); + } + } +} + +void func_80B25448(EnRacedog* this) { + if (this->actor.speedXZ < 3.0f) { + D_80B25EF0[2].playSpeed = 0.9f; + } else { + D_80B25EF0[2].playSpeed = 1.0f; + } +} + +s32 func_80B25490(EnRacedog* this, Vec2f* arg1) { + f32 xDistToTopFront; + f32 zDistToTopFront; + f32 xDistToBottomFront; + f32 xDistToBottomBack; + f32 zDistToBottomBack; + f32 zDistToBottomFront; + f32 zDistToTopBack; + f32 xDistToTopBack; + f32 temp_f0; + f32 temp; + + xDistToTopFront = this->actor.world.pos.x - arg1[0].x; + zDistToTopFront = this->actor.world.pos.z - arg1[0].y; + xDistToBottomFront = this->actor.world.pos.x - arg1[1].x; + zDistToBottomFront = this->actor.world.pos.z - arg1[1].y; + xDistToBottomBack = this->actor.world.pos.x - arg1[2].x; + zDistToBottomBack = this->actor.world.pos.z - arg1[2].y; + xDistToTopBack = this->actor.world.pos.x - arg1[3].x; + zDistToTopBack = this->actor.world.pos.z - arg1[3].y; + + temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); + temp = (((xDistToBottomFront * zDistToBottomBack) - (xDistToBottomBack * zDistToBottomFront))); + if (temp_f0 * temp < 0.0f) { + return false; + } + + temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); + temp = ((xDistToBottomBack * zDistToTopBack) - (xDistToTopBack * zDistToBottomBack)); + if (temp_f0 * temp < 0.0f) { + return false; + } + + temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); + temp = ((xDistToTopBack * zDistToTopFront) - (xDistToTopFront * zDistToTopBack)); + if (temp_f0 * temp < 0.0f) { + return false; + } + + return true; +} + +void func_80B255AC(EnRacedog* this, GlobalContext* globalCtx) { + s16 curFrame = this->skelAnime.curFrame; + s16 mod = (this->actor.speedXZ > 6.0f) ? 2 : 3; + Vec3f sp38; + + if (((this->unk_290 + curFrame) % mod) == 0) { + sp38.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(15.0f); + sp38.y = this->actor.world.pos.y; + sp38.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(15.0f); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &sp38, 10.0f, 0, 2.0f, 300, 0, true); + } +} + +void func_80B256BC(EnRacedog* this) { + s16 curFrame = this->skelAnime.curFrame; + + if ((curFrame == 1) || (curFrame == 7)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); + } +} + +void EnRacedog_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRacedog* this = THIS; + Vec3f sp2C = { 0.0f, 0.0f, 0.0f }; + + this->unk_292 = D_80B25E68.unk_0A; + + this->actionFunc(this, globalCtx); + + func_80B246F4(this, globalCtx); + func_80B248B8(this, &sp2C); + Math_ApproachF(&this->unk_2AC.x, sp2C.x, 0.2f, 0.1f); + + if (this->unk_2A0.x > 0.0f) { + if ((this->unk_2AC.x < 0.0f) && (this->unk_2AC.x > -0.1f)) { + this->skelAnime.curFrame = 4.0f; + this->actor.velocity.y = 5.5f; + } + } + + if (!(this->actor.bgCheckFlags & 1)) { + this->skelAnime.curFrame = 0.0f; + } + + this->unk_2A0 = this->unk_2AC; + SkelAnime_Update(&this->skelAnime); +} + +void func_80B2583C(EnRacedog* this) { + s16 phi_v1; + + if (this->unk_288 >= 7) { + this->unk_2BC -= 0x10; + this->unk_2C0 += 8; + this->unk_2C4 += 0.05f; + } else { + this->unk_2BC += 0x10; + this->unk_2C0 -= 8; + this->unk_2C4 -= 0.05f; + } + + if (this->unk_288 == 0) { + phi_v1 = 0; + } else { + this->unk_288--; + phi_v1 = this->unk_288; + } + + if (phi_v1 == 0) { + this->unk_288 = 0xC; + } +} + +void func_80B258D8(EnRacedog* this, GlobalContext* globalCtx) { + Vec3s sp48 = gZeroVec3s; + s32 phi_v0 = (this->unk_290 == this->unk_292) ? true : false; + + if (phi_v0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_80B2583C(this); + Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, + this->actor.world.pos.z, &sp48); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 255, 255, this->unk_2BC, 0, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, this->unk_2C0, 0, 255); + Matrix_Scale(this->unk_2C4 * 2.0f, this->unk_2C4 * 2.0f, this->unk_2C4 * 2.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dog_DL_000618); + gSPDisplayList(POLY_OPA_DISP++, object_dog_DL_000550); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +s32 EnRacedog_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + return false; +} + +void EnRacedog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnRacedog* this = THIS; + Vec3f sp1C = { 0.0f, 20.0f, 0.0f }; + + if (limbIndex == 5) { + Matrix_MultiplyVector3fByState(&sp1C, &this->actor.focus.pos); + } + + if (limbIndex == 12) { + func_80B258D8(this, globalCtx); + } +} + +void EnRacedog_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnRacedog* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gDPPipeSync(POLY_OPA_DISP++); + + switch (D_80B25D88[this->unk_290].unk_08) { + case 3: + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); + break; + case 1: + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 0); + break; + case 5: + gDPSetEnvColor(POLY_OPA_DISP++, 79, 79, 143, 0); + break; + case 6: + gDPSetEnvColor(POLY_OPA_DISP++, 255, 207, 47, 0); + break; + case 4: + gDPSetEnvColor(POLY_OPA_DISP++, 143, 79, 47, 0); + break; + case 2: + gDPSetEnvColor(POLY_OPA_DISP++, 143, 143, 143, 0); + break; + default: + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); + break; + } + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateStateAroundXAxis(this->unk_2AC.x); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnRacedog_OverrideLimbDraw, EnRacedog_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h index 4008ba4e1..2f9f9b06b 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h @@ -3,21 +3,40 @@ #include "global.h" +#define ENRACEDOG_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) +#define ENRACEDOG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 10) + struct EnRacedog; typedef void (*EnRacedogActionFunc)(struct EnRacedog*, GlobalContext*); typedef struct EnRacedog { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnRacedogActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xA0]; - /* 0x01E8 */ s32 unk_1E8; - /* 0x01EC */ char unk_1EC[0xA4]; - /* 0x0290 */ s16 unk_290; - /* 0x0292 */ s16 unk_292; - /* 0x0294 */ char unk_294[0x8]; - /* 0x029C */ s16 unk_29C; - /* 0x029E */ char unk_29E[0x2A]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnRacedogActionFunc actionFunc; + /* 0x148 */ UNK_TYPE1 unk_148[0x4]; + /* 0x14C */ SkelAnime skelAnime; + /* 0x190 */ ColliderCylinder collider; + /* 0x1DC */ UNK_TYPE1 unk_1DC[0x4]; + /* 0x1E0 */ Path* unk_1E0; + /* 0x1E4 */ UNK_TYPE1 unk_1E4[0x4]; + /* 0x1E8 */ s32 unk_1E8; + /* 0x1EC */ Vec3s jointTable[13]; + /* 0x23A */ Vec3s morphTable[13]; + /* 0x288 */ s16 unk_288; + /* 0x28A */ s16 unk_28A; + /* 0x28C */ s16 unk_28C; + /* 0x28A */ UNK_TYPE1 unk_28E[0x2]; + /* 0x290 */ s16 unk_290; + /* 0x292 */ s16 unk_292; + /* 0x294 */ UNK_TYPE1 unk_294[0x4]; + /* 0x298 */ f32 unk_298; + /* 0x29C */ s16 unk_29C; + /* 0x2A0 */ Vec3f unk_2A0; + /* 0x2AC */ Vec3f unk_2AC; + /* 0x2B8 */ s32 unk_2B8; + /* 0x2BC */ s32 unk_2BC; + /* 0x2C0 */ s32 unk_2C0; + /* 0x2C4 */ f32 unk_2C4; } EnRacedog; // size = 0x2C8 extern const ActorInit En_Racedog_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 099a4d472..0d5a3c792 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -13297,8 +13297,8 @@ 0x80B25708:("EnRacedog_Update",), 0x80B2583C:("func_80B2583C",), 0x80B258D8:("func_80B258D8",), - 0x80B25A74:("func_80B25A74",), - 0x80B25A90:("func_80B25A90",), + 0x80B25A74:("EnRacedog_OverrideLimbDraw",), + 0x80B25A90:("EnRacedog_PostLimbDraw",), 0x80B25B14:("EnRacedog_Draw",), 0x80B262A0:("EnKendoJs_Init",), 0x80B264FC:("EnKendoJs_Destroy",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 4ecb30b80..127151888 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -14055,25 +14055,18 @@ 0x80B245CC:("D_80B245CC","UNK_TYPE4","",0x4), 0x80B245D0:("D_80B245D0","f32","",0x4), 0x80B25D20:("En_Racedog_InitVars","UNK_TYPE1","",0x1), - 0x80B25D40:("D_80B25D40","UNK_TYPE2","",0x2), - 0x80B25D44:("D_80B25D44","UNK_TYPE2","",0x2), - 0x80B25D48:("D_80B25D48","UNK_TYPE2","",0x2), - 0x80B25D4C:("D_80B25D4C","UNK_TYPE2","",0x2), - 0x80B25D50:("D_80B25D50","f32","",0x4), - 0x80B25D54:("D_80B25D54","f32","",0x4), - 0x80B25D88:("D_80B25D88","UNK_TYPE1","",0x1), - 0x80B25D90:("D_80B25D90","UNK_TYPE1","",0x1), - 0x80B25D94:("D_80B25D94","UNK_TYPE1","",0x1), - 0x80B25D96:("D_80B25D96","UNK_TYPE1","",0x1), - 0x80B25E68:("D_80B25E68","UNK_TYPE4","",0x4), - 0x80B25E72:("D_80B25E72","UNK_TYPE2","",0x2), - 0x80B25E78:("D_80B25E78","UNK_TYPE1","",0x1), - 0x80B25E98:("D_80B25E98","UNK_TYPE1","",0x1), - 0x80B25EC4:("D_80B25EC4","UNK_TYPE1","",0x1), - 0x80B25ED0:("D_80B25ED0","UNK_TYPE1","",0x1), - 0x80B25EF0:("D_80B25EF0","UNK_PTR","",0x4), - 0x80B25EF4:("D_80B25EF4","UNK_TYPE1","",0x1), - 0x80B25F14:("D_80B25F14","UNK_TYPE1","",0x1), + 0x80B25D40:("D_80B25D40","s16","",0x2), + 0x80B25D44:("D_80B25D44","s16","",0x2), + 0x80B25D48:("D_80B25D48","s16","",0x2), + 0x80B25D4C:("D_80B25D4C","s16","",0x2), + 0x80B25D50:("D_80B25D50","f32","",0x38), + 0x80B25D88:("D_80B25D88","UNK_TYPE1","",0xE0), + 0x80B25E68:("D_80B25E68","UNK_TYPE1","",0x10), + 0x80B25E78:("D_80B25E78","f32","",0x20), + 0x80B25E98:("D_80B25E98","UNK_TYPE1","",0x2C), + 0x80B25EC4:("D_80B25EC4","UNK_TYPE1","",0xC), + 0x80B25ED0:("D_80B25ED0","UNK_TYPE1","",0x20), + 0x80B25EF0:("D_80B25EF0","UNK_TYPE1","",0x100), 0x80B25FF0:("D_80B25FF0","UNK_TYPE1","",0x1), 0x80B25FF4:("D_80B25FF4","UNK_TYPE4","",0x4), 0x80B26000:("D_80B26000","UNK_TYPE4","",0x4), diff --git a/undefined_syms.txt b/undefined_syms.txt index 2f590e909..5fdcb7438 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1700,12 +1700,6 @@ D_06004340 = 0x06004340; D_06001A80 = 0x06001A80; -// ovl_En_Racedog - -D_06000550 = 0x06000550; -D_06000618 = 0x06000618; -D_060080F0 = 0x060080F0; - // ovl_En_Raf D_06000108 = 0x06000108; From d9155eb4985c9cf7e542bbe6ad25c29cd2abdbe5 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 5 Mar 2022 14:42:55 +0000 Subject: [PATCH 067/257] Bg_Hakugin_Switch (#699) --- spec | 4 +- .../z_bg_hakugin_switch.c | 506 ++++++++++++++++-- .../z_bg_hakugin_switch.h | 24 +- undefined_syms.txt | 5 - 4 files changed, 488 insertions(+), 51 deletions(-) diff --git a/spec b/spec index 6b09b9b21..4d9004e49 100644 --- a/spec +++ b/spec @@ -3885,9 +3885,7 @@ beginseg name "ovl_Bg_Hakugin_Switch" compress include "build/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.o" - include "build/data/ovl_Bg_Hakugin_Switch/ovl_Bg_Hakugin_Switch.data.o" - include "build/data/ovl_Bg_Hakugin_Switch/ovl_Bg_Hakugin_Switch.bss.o" - include "build/data/ovl_Bg_Hakugin_Switch/ovl_Bg_Hakugin_Switch.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Hakugin_Switch/ovl_Bg_Hakugin_Switch_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c index d16c6c0db..f5e035be7 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.c @@ -5,6 +5,7 @@ */ #include "z_bg_hakugin_switch.h" +#include "objects/object_goronswitch/object_goronswitch.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,27 @@ void BgHakuginSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHakuginSwitch_Update(Actor* thisx, GlobalContext* globalCtx); void BgHakuginSwitch_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B15A68(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B15B1C(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B15B74(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B15E0C(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B15E78(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B15F3C(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B15F88(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B1606C(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B160DC(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B161A0(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B16244(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B162AC(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B163C4(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B16400(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B16494(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B16520(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B165A0(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B165E0(BgHakuginSwitch* this, GlobalContext* globalCtx); + +u32 D_80B16AF0; + const ActorInit Bg_Hakugin_Switch_InitVars = { ACTOR_BG_HAKUGIN_SWITCH, ACTORCAT_SWITCH, @@ -28,84 +49,489 @@ const ActorInit Bg_Hakugin_Switch_InitVars = { (ActorFunc)BgHakuginSwitch_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B16860 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000400, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000400, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 60, 10, 180, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B16904[] = { +typedef struct { + /* 0x00 */ f32 unk_0; + /* 0x04 */ f32 unk_4; + /* 0x08 */ f32 unk_8; + /* 0x0C */ f32 unk_C; + /* 0x10 */ Gfx* unk_10; + /* 0x14 */ u8 unk_14; +} BgHakuginSwitchStruct; + +BgHakuginSwitchStruct D_80B1688C[] = { + { -156.0f, -178.0f, 6.0f, 10.0f, object_goronswitch_DL_000268, 0xB4 }, + { -60.0f, -178.0f, 6.0f, 10.0f, object_goronswitch_DL_000268, 0x32 }, + { -60.0f, -178.0f, 6.0f, 10.0f, object_goronswitch_DL_000268, 0x31 }, + { -120.0f, -178.0f, 6.0f, 10.0f, object_goronswitch_DL_0007D8, 0x3A }, + { -156.0f, -178.0f, 6.0f, 10.0f, object_goronswitch_DL_0007D8, 0xB4 }, +}; + +static InitChainEntry sInitChain1[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 130, ICHAIN_STOP), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B16910[] = { +static InitChainEntry sInitChain2[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 260, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 360, ICHAIN_STOP), }; -#endif +void func_80B15790(BgHakuginSwitch* this, u16 sfxId) { + if (this->unk_1B2 <= 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, sfxId); + } +} -extern ColliderCylinderInit D_80B16860; -extern InitChainEntry D_80B16904[]; -extern InitChainEntry D_80B16910[]; +void func_80B157C4(BgHakuginSwitch* this, u16 arg1) { + if (this->unk_1B2 <= 0) { + func_800B9010(&this->dyna.actor, arg1); + } +} -extern UNK_TYPE D_060005C8; +void BgHakuginSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgHakuginSwitch* this = THIS; + s32 sp34 = BGHAKUGINSWITCH_GET_7(&this->dyna.actor); + s32 sp30; + s32 pad2; + s32 sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15790.s") + if (Flags_GetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { + sp30 = true; + } else { + sp30 = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B157C4.s") + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_goronswitch_Colheader_0005C8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/BgHakuginSwitch_Init.s") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/BgHakuginSwitch_Destroy.s") + this->unk_1B2 = 15; + if (!BGHAKUGINSWITCH_GET_10(&this->dyna.actor)) { + Actor_ProcessInitChain(&this->dyna.actor, sInitChain1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15A4C.s") + this->dyna.actor.scale.x = 0.07f; + this->dyna.actor.scale.y = 0.016f; + this->dyna.actor.scale.z = 0.07f; + this->collider.dim.radius = 46; + this->collider.dim.yShift = 0x1D; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15A68.s") + this->unk_1A8 = object_goronswitch_DL_000268; + this->unk_1B8 = this->dyna.actor.cutscene; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15B1C.s") + if (sp34 == 0) { + this->unk_1BA = -1; + } else { + this->unk_1BA = ActorCutscene_GetAdditionalCutscene(this->unk_1B8); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15B74.s") + if (sp30) { + func_80B16494(this, globalCtx); + } else { + func_80B16244(this, globalCtx); + } + } else { + if (D_80B1688C[sp34].unk_14 & 4) { + sp28 = true; + } else { + sp28 = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15E0C.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15E78.s") + this->unk_1A8 = D_80B1688C[sp34].unk_10; + this->unk_1B8 = this->dyna.actor.cutscene; + this->unk_1BA = ActorCutscene_GetAdditionalCutscene(this->unk_1B8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15F3C.s") + if (sp30 == sp28) { + func_80B15F3C(this, globalCtx); + } else { + func_80B15B1C(this, globalCtx); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15F88.s") + this->unk_1C8 = 1.0f / this->dyna.actor.scale.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B1606C.s") +void BgHakuginSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginSwitch* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B160DC.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B16180.s") +void func_80B15A4C(BgHakuginSwitch* this, BgHakuginSwitchUnkFunc func, s32 arg2) { + this->unk_1B4 = func; + this->unk_1BC = arg2; + this->actionFunc = func_80B15A68; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B161A0.s") +void func_80B15A68(BgHakuginSwitch* this, GlobalContext* globalCtx) { + s32 pad; + BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + s32 sp18 = !(s->unk_14 & 0x40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B16244.s") + if (ActorCutscene_GetCanPlayNext(this->unk_1BC)) { + if (sp18) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_1BC, &this->dyna.actor); + this->unk_1BF = 40; + } + this->unk_1B4(this, globalCtx); + } else if (sp18) { + ActorCutscene_SetIntentToPlay(this->unk_1BC); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B162AC.s") +void func_80B15B1C(BgHakuginSwitch* this, GlobalContext* globalCtx) { + BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B163C4.s") + this->dyna.actor.world.pos.y = s->unk_0 + this->dyna.actor.home.pos.y; + this->unk_1C0 = 1; + this->unk_1B0 = 480; + this->actionFunc = func_80B15B74; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B16400.s") +void func_80B15B74(BgHakuginSwitch* this, GlobalContext* globalCtx) { + s32 pad; + BgHakuginSwitchStruct* sp38 = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + s32 sp34 = (this->collider.base.acFlags & AC_HIT) != 0; + s32 pad2; + s32 sp2C; + s32 sp28; + s32 sp24; + s32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B16494.s") + if (Flags_GetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { + sp2C = 1; + } else { + sp2C = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B16520.s") + if (sp38->unk_14 & 4) { + sp28 = 1; + } else { + sp28 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B165A0.s") + sp24 = false; + sp20 = -1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B165E0.s") + if (sp34) { + this->collider.base.acFlags &= ~AC_HIT; + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + sp24 = true; + sp20 = sp28; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/BgHakuginSwitch_Update.s") + if (this->unk_1B0 > 0) { + this->unk_1B0--; + if (sp38->unk_14 & 8) { + func_800B9038(&this->dyna.actor, this->unk_1B0); + if (this->unk_1B0 == 0) { + sp24 = true; + sp20 = sp28; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/BgHakuginSwitch_Draw.s") + if (sp2C == sp28) { + if ((sp38->unk_14 & 0xFF) & 0x10) { + if (D_80B16AF0 < globalCtx->gameplayFrames) { + sp24 = true; + } + } else { + sp24 = true; + } + } + + if (sp24) { + if (sp20 == 1) { + Flags_SetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + } else if (sp20 == 0) { + Flags_UnsetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + } + + D_80B16AF0 = globalCtx->gameplayFrames; + + if (sp38->unk_14 & 0x10) { + func_80B15A4C(this, func_80B15E0C, this->unk_1B8); + } else { + func_80B15E0C(this, globalCtx); + } + } else if (!(sp38->unk_14 & 1)) { + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80B15E0C(BgHakuginSwitch* this, GlobalContext* globalCtx) { + BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + + if ((s->unk_14 & 0x80)) { + func_80B15790(this, NA_SE_EV_STONE_SWITCH_ON); + } + this->unk_1C0 = 0; + this->actionFunc = func_80B15E78; +} + +void func_80B15E78(BgHakuginSwitch* this, GlobalContext* globalCtx) { + s32 pad; + BgHakuginSwitchStruct* sp20 = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + + if (Math_StepToF(&this->dyna.actor.world.pos.y, sp20->unk_4 + this->dyna.actor.home.pos.y, sp20->unk_C)) { + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + } + func_80B15F3C(this, globalCtx); + } else if (!(sp20->unk_14 & 0x80)) { + func_80B157C4(this, NA_SE_EV_STONE_STATUE_OPEN - SFX_FLAG); + } +} + +void func_80B15F3C(BgHakuginSwitch* this, GlobalContext* globalCtx) { + BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + + this->dyna.actor.world.pos.y = s->unk_4 + this->dyna.actor.home.pos.y; + this->unk_1C0 = 0; + this->actionFunc = func_80B15F88; +} + +void func_80B15F88(BgHakuginSwitch* this, GlobalContext* globalCtx) { + s32 phi_a0; + BgHakuginSwitchStruct* sp18 = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + s32 phi_v1; + + if (Flags_GetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { + phi_a0 = true; + } else { + phi_a0 = false; + } + + if (sp18->unk_14 & 4) { + phi_v1 = true; + } else { + phi_v1 = false; + } + + if (phi_a0 != phi_v1) { + if ((sp18->unk_14 & 0xFF) & 0x20) { + if (D_80B16AF0 < globalCtx->gameplayFrames) { + func_80B15A4C(this, func_80B1606C, this->unk_1BA); + } + } else { + func_80B1606C(this, globalCtx); + } + } +} + +void func_80B1606C(BgHakuginSwitch* this, GlobalContext* globalCtx) { + BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + + if (s->unk_14 & 0x80) { + func_80B15790(this, NA_SE_EV_STONE_SWITCH_OFF); + } + this->unk_1C0 = 1; + this->actionFunc = func_80B160DC; +} + +void func_80B160DC(BgHakuginSwitch* this, GlobalContext* globalCtx) { + s32 pad; + BgHakuginSwitchStruct* sp18 = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + + if (Math_StepToF(&this->dyna.actor.world.pos.y, sp18->unk_0 + this->dyna.actor.home.pos.y, sp18->unk_8)) { + func_80B15B1C(this, globalCtx); + } else if (!(sp18->unk_14 & 0x80)) { + func_80B157C4(this, NA_SE_EV_PILLAR_UP_FAST - SFX_FLAG); + } +} + +void func_80B16180(BgHakuginSwitch* this, BgHakuginSwitchUnkFunc func, s32 arg2, s32 arg3) { + this->unk_1B4 = func; + this->unk_1BE = arg2; + this->unk_1BC = arg3; + this->actionFunc = func_80B161A0; +} + +void func_80B161A0(BgHakuginSwitch* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->unk_1BC)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_1BC, &this->dyna.actor); + if (this->unk_1BE != 0) { + Flags_SetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + } else { + Flags_UnsetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + } + this->unk_1BF = 50; + this->unk_1B4(this, globalCtx); + } else { + ActorCutscene_SetIntentToPlay(this->unk_1BC); + } +} + +void func_80B16244(BgHakuginSwitch* this, GlobalContext* globalCtx) { + this->unk_1C0 = 1; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + if ((BGHAKUGINSWITCH_GET_7(&this->dyna.actor) == BGHAKUGINSWITCH_GET_7_1) && + (this->dyna.actor.category != ACTORCAT_SWITCH)) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, 0); + } + this->actionFunc = func_80B162AC; +} + +void func_80B162AC(BgHakuginSwitch* this, GlobalContext* globalCtx) { + s32 sp34 = (this->collider.base.acFlags & AC_HIT) != 0; + s32 sp30 = BGHAKUGINSWITCH_GET_7(&this->dyna.actor); + s32 pad; + s32 sp28 = false; + s32 sp24 = false; + + if (sp34) { + this->collider.base.acFlags &= ~AC_HIT; + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + sp24 = true; + sp28 = true; + } + } + + if (sp30 == 1) { + if (Flags_GetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { + sp24 = true; + } + } + + if (sp24) { + if (sp28) { + func_80B16180(this, func_80B163C4, 1, this->unk_1B8); + } else { + func_80B163C4(this, globalCtx); + } + } else { + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80B163C4(BgHakuginSwitch* this, GlobalContext* globalCtx) { + func_80B15790(this, NA_SE_EV_STONE_SWITCH_ON); + this->unk_1C0 = 0; + this->actionFunc = func_80B16400; +} + +void func_80B16400(BgHakuginSwitch* this, GlobalContext* globalCtx) { + if (Math_StepToF(&this->dyna.actor.world.pos.y, + (this->dyna.actor.home.pos.y + 2.0f) - (1800.0f * this->dyna.actor.scale.y), 10.0f)) { + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + } + func_80B16494(this, globalCtx); + } +} + +void func_80B16494(BgHakuginSwitch* this, GlobalContext* globalCtx) { + this->unk_1C0 = 0; + this->dyna.actor.world.pos.y = (this->dyna.actor.home.pos.y - (1800.0f * this->dyna.actor.scale.y)) + 2.0f; + if ((BGHAKUGINSWITCH_GET_7(&this->dyna.actor) == BGHAKUGINSWITCH_GET_7_1) && + (this->dyna.actor.category != ACTORCAT_PROP)) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, ACTORCAT_PROP); + } + this->actionFunc = func_80B16520; +} + +void func_80B16520(BgHakuginSwitch* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { + if (BGHAKUGINSWITCH_GET_7(&this->dyna.actor) == BGHAKUGINSWITCH_GET_7_1) { + func_80B16180(this, func_80B165A0, 0, this->unk_1BA); + } else { + func_80B165A0(this, globalCtx); + } + } +} + +void func_80B165A0(BgHakuginSwitch* this, GlobalContext* globalCtx) { + func_80B15790(this, NA_SE_EV_STONE_SWITCH_OFF); + this->unk_1C0 = 1; + this->actionFunc = func_80B165E0; +} + +void func_80B165E0(BgHakuginSwitch* this, GlobalContext* globalCtx) { + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 6.0f)) { + func_80B16244(this, globalCtx); + } +} + +void BgHakuginSwitch_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgHakuginSwitch* this = THIS; + f32 sp24; + + if (this->unk_1B2 > 0) { + this->unk_1B2--; + } + + if (this->unk_1BF > 0) { + if ((this->actionFunc != func_80B15A68) && (this->actionFunc != func_80B161A0)) { + this->unk_1BF--; + if (this->unk_1BF == 0) { + ActorCutscene_Stop(this->unk_1BC); + } + } + } + + this->actionFunc(this, globalCtx); + + sp24 = this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y; + + if (this->unk_1C0 != 0) { + f32 phi_f0; + + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + if (DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + phi_f0 = (sp24 - -10.0f) * -0.21f; + } else { + phi_f0 = (sp24 - -3.0f) * -0.08f; + } + this->unk_1C4 += phi_f0; + this->unk_1C4 *= 0.75f; + this->dyna.actor.shape.yOffset += this->unk_1C4 * this->unk_1C8; + } else { + this->unk_1C4 += sp24 * -0.11f; + this->unk_1C4 *= 0.75f; + this->dyna.actor.shape.yOffset += this->unk_1C4 * this->unk_1C8; + this->dyna.actor.shape.yOffset = CLAMP_MAX(this->dyna.actor.shape.yOffset, 0.0f); + } + } else { + Math_StepToF(&this->dyna.actor.shape.yOffset, 0.0f, 2.0f * this->unk_1C8); + this->unk_1C4 = 0.0f; + } +} + +void BgHakuginSwitch_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginSwitch* this = THIS; + + Gfx_DrawDListOpa(globalCtx, this->unk_1A8); +} diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.h b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.h index 58cbfed68..cc1363965 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.h +++ b/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.h @@ -6,12 +6,30 @@ struct BgHakuginSwitch; typedef void (*BgHakuginSwitchActionFunc)(struct BgHakuginSwitch*, GlobalContext*); +typedef void (*BgHakuginSwitchUnkFunc)(struct BgHakuginSwitch*, GlobalContext*); + +#define BGHAKUGINSWITCH_GET_7(thisx) ((thisx)->params & 7) +#define BGHAKUGINSWITCH_GET_10(thisx) (((thisx)->params >> 4) & 1) +#define BGHAKUGINSWITCH_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F) + +#define BGHAKUGINSWITCH_GET_7_1 1 typedef struct BgHakuginSwitch { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x68]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderCylinder collider; + /* 0x01A8 */ Gfx* unk_1A8; /* 0x01AC */ BgHakuginSwitchActionFunc actionFunc; - /* 0x01B0 */ char unk_1B0[0x1C]; + /* 0x01B0 */ s16 unk_1B0; + /* 0x01B2 */ s8 unk_1B2; + /* 0x01B4 */ BgHakuginSwitchUnkFunc unk_1B4; + /* 0x01B8 */ s16 unk_1B8; + /* 0x01BA */ s16 unk_1BA; + /* 0x01BC */ s16 unk_1BC; + /* 0x01BE */ s8 unk_1BE; + /* 0x01BF */ s8 unk_1BF; + /* 0x01C0 */ s8 unk_1C0; + /* 0x01C4 */ f32 unk_1C4; + /* 0x01C8 */ f32 unk_1C8; } BgHakuginSwitch; // size = 0x1CC extern const ActorInit Bg_Hakugin_Switch_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 5fdcb7438..81c46cfc6 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -649,11 +649,6 @@ D_06009830 = 0x06009830; D_0600ACB8 = 0x0600ACB8; D_0600BF40 = 0x0600BF40; -// ovl_Bg_Hakugin_Switch - -D_06000268 = 0x06000268; -D_060005C8 = 0x060005C8; - // ovl_Bg_Icefloe D_060001E0 = 0x060001E0; From 6017869b1e2f369fa2c27a17a5e1b8f29b4aaf41 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sat, 5 Mar 2022 11:51:51 -0300 Subject: [PATCH 068/257] `z_player_call` OK (#693) * Match functions * Rename functions * Import data and bss, and minor fixes * Format * Whoops * Add some protos to z_player --- include/functions.h | 6 +- include/initvars.h | 1 + include/variables.h | 5 -- spec | 2 - src/code/z_player_call.c | 59 +++++++++++++++++-- .../actors/ovl_player_actor/z_player.c | 13 ++-- tools/disasm/files.txt | 2 +- tools/disasm/functions.txt | 18 +++--- tools/disasm/variables.txt | 8 +-- tools/sizes/code_functions.csv | 10 ++-- 10 files changed, 84 insertions(+), 40 deletions(-) diff --git a/include/functions.h b/include/functions.h index 529de810a..3faf69b26 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2690,11 +2690,7 @@ void func_801588D0(GlobalContext* globalCtx, s16 param_2); // void func_8015E750(void); void func_8015E7EC(GlobalContext* globalCtx, UNK_PTR puParm2); // void func_8015F8A8(UNK_TYPE4 ctxt); -// void func_80160A90(void); -// void func_80160AF8(void); -// void func_80160B40(void); -// void func_80160B80(void); -// void func_80160BC0(void); + void ShrinkWindow_SetLetterboxTarget(s32 target); s32 ShrinkWindow_GetLetterboxTarget(void); void ShrinkWindow_SetLetterboxMagnitude(s32 magnitude); diff --git a/include/initvars.h b/include/initvars.h index 797e73876..11a6719e9 100644 --- a/include/initvars.h +++ b/include/initvars.h @@ -34,6 +34,7 @@ extern EffectSsInit Effect_Ss_Ice_Smoke_InitVars; extern EffectSsInit Effect_En_Ice_Block_InitVars; extern EffectSsInit Effect_Ss_Sbn_InitVars; +extern ActorInit Player_InitVars; extern ActorInit Arms_Hook_InitVars; extern ActorInit Arrow_Fire_InitVars; extern ActorInit Arrow_Ice_InitVars; diff --git a/include/variables.h b/include/variables.h index 9ddad27f9..7eafe0d2f 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1535,7 +1535,6 @@ extern char D_801D0714[]; // extern UNK_TYPE1 D_801D08E4; // extern UNK_TYPE1 D_801D08E8; // extern UNK_TYPE1 D_801D0900; -extern ActorInit Player_InitVars; extern KaleidoMgrOverlay gKaleidoMgrOverlayTable[2]; // extern UNK_TYPE1 D_801D0B8C; extern KaleidoMgrOverlay* gKaleidoMgrCurOvl; @@ -3294,10 +3293,6 @@ extern LightsBuffer sLightsBuffer; // extern UNK_TYPE1 D_801F6B1E; // extern UNK_TYPE1 D_801F6B20; // extern UNK_TYPE1 D_801F6B22; -// extern UNK_TYPE1 D_801F6B30; -// extern UNK_TYPE1 D_801F6B34; -// extern UNK_TYPE1 D_801F6B38; -// extern UNK_TYPE1 D_801F6B3C; extern ShrinkWindowContext gShrinkWindowContext; extern ShrinkWindowContext* gShrinkWindowContextPtr; // extern UNK_TYPE4 D_801F6B50; diff --git a/spec b/spec index 4d9004e49..cb017e135 100644 --- a/spec +++ b/spec @@ -553,11 +553,9 @@ beginseg 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/data/code/z_player_call.bss.o" include "build/src/code/z_shrink_window.o" include "build/src/code/db_camera.o" include "build/data/code/db_camera.bss.o" - include "build/data/code/code_801D0B50.data.o" include "build/src/code/z_kaleido_manager.o" include "build/src/code/z_kaleido_scope_call.o" include "build/src/code/z_fbdemo_dlftbls.o" diff --git a/src/code/z_player_call.c b/src/code/z_player_call.c index 69e2f4dae..7ed1ce5ce 100644 --- a/src/code/z_player_call.c +++ b/src/code/z_player_call.c @@ -1,11 +1,60 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_call/func_80160A90.s") +#define FLAGS \ + (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200000 | ACTOR_FLAG_2000000 | \ + ACTOR_FLAG_4000000 | ACTOR_FLAG_80000000) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_call/func_80160AF8.s") +ActorFunc sPlayerCallInitFunc; +ActorFunc sPlayerCallDestroyFunc; +ActorFunc sPlayerCallUpdateFunc; +ActorFunc sPlayerCallDrawFunc; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_call/func_80160B40.s") +void PlayerCall_Init(Actor* thisx, GlobalContext* globalCtx); +void PlayerCall_Destroy(Actor* thisx, GlobalContext* globalCtx); +void PlayerCall_Update(Actor* thisx, GlobalContext* globalCtx); +void PlayerCall_Draw(Actor* thisx, GlobalContext* globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_call/func_80160B80.s") +const ActorInit Player_InitVars = { + ACTOR_PLAYER, + ACTORCAT_PLAYER, + FLAGS, + GAMEPLAY_KEEP, + sizeof(Player), + (ActorFunc)PlayerCall_Init, + (ActorFunc)PlayerCall_Destroy, + (ActorFunc)PlayerCall_Update, + (ActorFunc)PlayerCall_Draw, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_call/func_80160BC0.s") +void Player_Init(Actor* thisx, GlobalContext* globalCtx); +void Player_Destroy(Actor* thisx, GlobalContext* globalCtx); +void Player_Update(Actor* thisx, GlobalContext* globalCtx); +void Player_Draw(Actor* thisx, GlobalContext* globalCtx); + +void PlayerCall_InitFuncPtrs(void) { + sPlayerCallInitFunc = KaleidoManager_GetRamAddr(Player_Init); + sPlayerCallDestroyFunc = KaleidoManager_GetRamAddr(Player_Destroy); + sPlayerCallUpdateFunc = KaleidoManager_GetRamAddr(Player_Update); + sPlayerCallDrawFunc = KaleidoManager_GetRamAddr(Player_Draw); +} + +void PlayerCall_Init(Actor* thisx, GlobalContext* globalCtx) { + KaleidoScopeCall_LoadPlayer(); + PlayerCall_InitFuncPtrs(); + sPlayerCallInitFunc(thisx, globalCtx); +} + +void PlayerCall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + KaleidoScopeCall_LoadPlayer(); + sPlayerCallDestroyFunc(thisx, globalCtx); +} + +void PlayerCall_Update(Actor* thisx, GlobalContext* globalCtx) { + KaleidoScopeCall_LoadPlayer(); + sPlayerCallUpdateFunc(thisx, globalCtx); +} + +void PlayerCall_Draw(Actor* thisx, GlobalContext* globalCtx) { + KaleidoScopeCall_LoadPlayer(); + sPlayerCallDrawFunc(thisx, globalCtx); +} diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 6a5fa0423..bc3e3c1e8 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -12,6 +12,11 @@ extern UNK_TYPE D_06008860; extern UNK_TYPE D_0600BDD8; extern UNK_TYPE D_060178D0; +void Player_Init(Actor* thisx, GlobalContext* globalCtx); +void Player_Destroy(Actor* thisx, GlobalContext* globalCtx); +void Player_Update(Actor* thisx, GlobalContext* globalCtx); +void Player_Draw(Actor* thisx, GlobalContext* globalCtx); + #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DA90.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DABC.s") @@ -728,7 +733,7 @@ extern UNK_TYPE D_060178D0; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80841A50.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80841AC4.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/Player_Init.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80842510.s") @@ -754,15 +759,15 @@ extern UNK_TYPE D_060178D0; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80844EF8.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808460B8.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/Player_Update.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808463C0.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80846460.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80846528.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/Player_Draw.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808470D4.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/Player_Destroy.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847190.s") diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index fc9f9fc53..a43ef93f4 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -562,7 +562,7 @@ 0x801C5E30 : "z_vr_box", 0x801C5FC0 : "z_sram_NES", 0x801D0470 : "z_message_nes", - 0x801D0B50 : "", + 0x801D0B50 : "z_player_call", 0x801D0B70 : "z_kaleido_manager", 0x801D0BB0 : "", 0x801D0C80 : "z_fbdemo", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 0d5a3c792..7236e4521 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2887,11 +2887,11 @@ 0x8015E750:("func_8015E750",), 0x8015E7EC:("func_8015E7EC",), 0x8015F8A8:("func_8015F8A8",), - 0x80160A90:("func_80160A90",), - 0x80160AF8:("func_80160AF8",), - 0x80160B40:("func_80160B40",), - 0x80160B80:("func_80160B80",), - 0x80160BC0:("func_80160BC0",), + 0x80160A90:("PlayerCall_InitFuncPtrs",), + 0x80160AF8:("PlayerCall_Init",), + 0x80160B40:("PlayerCall_Destroy",), + 0x80160B80:("PlayerCall_Update",), + 0x80160BC0:("PlayerCall_Draw",), 0x80160C00:("ShrinkWindow_SetLetterboxTarget",), 0x80160C14:("ShrinkWindow_GetLetterboxTarget",), 0x80160C28:("ShrinkWindow_SetLetterboxMagnitude",), @@ -4602,7 +4602,7 @@ 0x80841744:("func_80841744",), 0x8084182C:("func_8084182C",), 0x80841A50:("func_80841A50",), - 0x80841AC4:("func_80841AC4",), + 0x80841AC4:("Player_Init",), 0x80842510:("func_80842510",), 0x808425B4:("func_808425B4",), 0x808426F0:("func_808426F0",), @@ -4615,11 +4615,11 @@ 0x80844784:("func_80844784",), 0x80844D80:("func_80844D80",), 0x80844EF8:("func_80844EF8",), - 0x808460B8:("func_808460B8",), + 0x808460B8:("Player_Update",), 0x808463C0:("func_808463C0",), 0x80846460:("func_80846460",), - 0x80846528:("func_80846528",), - 0x808470D4:("func_808470D4",), + 0x80846528:("Player_Draw",), + 0x808470D4:("Player_Destroy",), 0x80847190:("func_80847190",), 0x8084748C:("func_8084748C",), 0x808475B4:("func_808475B4",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 127151888..b01c5729d 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4095,10 +4095,10 @@ 0x801F6B1E:("D_801F6B1E","UNK_TYPE1","",0x1), 0x801F6B20:("D_801F6B20","UNK_TYPE1","",0x1), 0x801F6B22:("D_801F6B22","UNK_TYPE1","",0x1), - 0x801F6B30:("D_801F6B30","UNK_TYPE1","",0x1), - 0x801F6B34:("D_801F6B34","UNK_TYPE1","",0x1), - 0x801F6B38:("D_801F6B38","UNK_TYPE1","",0x1), - 0x801F6B3C:("D_801F6B3C","UNK_TYPE1","",0x1), + 0x801F6B30:("sPlayerCallInitFunc","UNK_TYPE1","",0x1), + 0x801F6B34:("sPlayerCallDestroyFunc","UNK_TYPE1","",0x1), + 0x801F6B38:("sPlayerCallUpdateFunc","UNK_TYPE1","",0x1), + 0x801F6B3C:("sPlayerCallDrawFunc","UNK_TYPE1","",0x1), 0x801F6B40:("gShrinkWindowContext","ShrinkWindowContext","",0x4), 0x801F6B44:("gShrinkWindowContextPtr","ShrinkWindowContext*","",0x4), 0x801F6B50:("D_801F6B50","UNK_TYPE4","",0x4), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 8ec9f8ca3..c93719e08 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2401,11 +2401,11 @@ asm/non_matchings/code/z_message_nes/func_8015B198.s,func_8015B198,0x8015B198,0x asm/non_matchings/code/z_message_staff/func_8015E750.s,func_8015E750,0x8015E750,0x27 asm/non_matchings/code/z_message_staff/func_8015E7EC.s,func_8015E7EC,0x8015E7EC,0x42F asm/non_matchings/code/z_message_staff/func_8015F8A8.s,func_8015F8A8,0x8015F8A8,0x47A -asm/non_matchings/code/z_player_call/func_80160A90.s,func_80160A90,0x80160A90,0x1A -asm/non_matchings/code/z_player_call/func_80160AF8.s,func_80160AF8,0x80160AF8,0x12 -asm/non_matchings/code/z_player_call/func_80160B40.s,func_80160B40,0x80160B40,0x10 -asm/non_matchings/code/z_player_call/func_80160B80.s,func_80160B80,0x80160B80,0x10 -asm/non_matchings/code/z_player_call/func_80160BC0.s,func_80160BC0,0x80160BC0,0x10 +asm/non_matchings/code/z_player_call/PlayerCall_InitFuncPtrs.s,PlayerCall_InitFuncPtrs,0x80160A90,0x1A +asm/non_matchings/code/z_player_call/PlayerCall_Init.s,PlayerCall_Init,0x80160AF8,0x12 +asm/non_matchings/code/z_player_call/PlayerCall_Destroy.s,PlayerCall_Destroy,0x80160B40,0x10 +asm/non_matchings/code/z_player_call/PlayerCall_Update.s,PlayerCall_Update,0x80160B80,0x10 +asm/non_matchings/code/z_player_call/PlayerCall_Draw.s,PlayerCall_Draw,0x80160BC0,0x10 asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetLetterboxTarget.s,ShrinkWindow_SetLetterboxTarget,0x80160C00,0x5 asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetLetterboxTarget.s,ShrinkWindow_GetLetterboxTarget,0x80160C14,0x5 asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetLetterboxMagnitude.s,ShrinkWindow_SetLetterboxMagnitude,0x80160C28,0x5 From 7fcefd8d3fa60a13c1229bf4a1bdc5f2c59f0d75 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Sat, 5 Mar 2022 14:57:28 +0000 Subject: [PATCH 069/257] Decompile and partially document some functions in z_play (#582) * Decomp 10 functions in z_play, start documentation * Add numbers to enums in z_en_torch2.h * Decompile a 5 more functions (56 unattempted) * Add more details, name some more variables * Bit more Doxygen * Format * Fix arguments * Add symbols to actorfixer.py * Merge branch 'master' into play * Fix z_actor * Review * Deduplicate CycleSceneFlags * Fix warning * Fix unk4 * Review --- include/functions.h | 27 +- include/z64.h | 4 +- src/code/z_actor.c | 6 +- src/code/z_collision_check.c | 14 +- src/code/z_effect.c | 2 +- src/code/z_effect_soft_sprite.c | 2 +- src/code/z_game_over.c | 2 +- src/code/z_play.c | 250 ++++++++++++++++-- .../z_bg_ikana_rotaryroom.c | 2 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 2 +- src/overlays/actors/ovl_Door_Ana/z_door_ana.c | 2 +- .../actors/ovl_Door_Warp1/z_door_warp1.c | 24 +- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 2 +- src/overlays/actors/ovl_En_Gs/z_en_gs.c | 4 +- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 6 +- .../z_en_okarina_effect.c | 2 +- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 16 +- .../actors/ovl_En_Torch2/z_en_torch2.c | 3 +- .../actors/ovl_En_Torch2/z_en_torch2.h | 20 +- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 2 +- .../actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c | 2 +- .../ovl_En_Weather_Tag/z_en_weather_tag.c | 2 +- .../ovl_Obj_Roomtimer/z_obj_roomtimer.c | 2 +- tools/actorfixer.py | 5 + tools/disasm/functions.txt | 12 +- tools/disasm/variables.txt | 2 +- tools/sizes/code_functions.csv | 10 +- 27 files changed, 326 insertions(+), 101 deletions(-) diff --git a/include/functions.h b/include/functions.h index 3faf69b26..27ac40589 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2818,21 +2818,20 @@ void Play_CameraChangeSetting(GlobalContext* globalCtx, s16 camId, s16 setting); void func_80169AFC(GlobalContext* globalCtx, s16 camId, s16 arg2); s16 Play_GetCsCamDataSetting(GlobalContext* globalCtx, s32 camId); Vec3s* Play_GetCsCamDataVec3s(GlobalContext* globalCtx, s32 camId); -s16 convert_scene_number_among_shared_scenes(s16 arg0); -void func_80169D40(GlobalContext* globalCtx); -void func_80169DCC(GlobalContext* globalCtx, s32 arg1, u16 arg2, s32 arg3, s32 arg4, Vec3f* arg5, s16 arg6); -void func_80169E6C(GlobalContext* globalCtx, s32 param_1, s32 param_2); -// void func_80169ECC(void); -void func_80169EFC(GlobalContext* globalCtx); -void func_80169F78(GlobalContext* globalCtx); -void func_80169FDC(GlobalContext* globalCtx); -// void func_80169FFC(void); -s32 FrameAdvance_IsEnabled(GlobalContext* globalCtx); -// UNK_TYPE4 func_8016A02C(s32 param_1, s32 param_2, s16* param_3); -// void func_8016A0AC(void); +s16 Play_GetOriginalSceneNumber(s16 sceneNum); +void Play_SaveCycleSceneFlags(GameState* gameState); +void Play_SetRespawnData(GameState* gameState, s32 respawnNumber, u16 sceneSetup, s32 roomIndex, s32 playerParams, Vec3f* pos, s16 yaw); +void Play_SetupRespawnPoint(GameState* gameState, s32 respawnNumber, s32 playerParams); +void func_80169EFC(GameState* gameState); +void func_80169F78(GameState* gameState); +void func_80169FDC(GameState* gameState); +s32 func_80169FFC(GameState* gameState); +s32 FrameAdvance_IsEnabled(GameState* gameState); +s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw); +s32 Play_IsUnderwater(GlobalContext* globalCtx, Vec3f* pos); s32 func_8016A168(void); -// void func_8016A178(void); -void func_8016A268(GlobalContext* globalCtx, s32 param_2, s32 param_3, s32 param_4, s32 param_5, s32 param_6); +void Play_AssignPlayerActorCsIdsFromScene(GameState* gameState, s32 cutscene); +void func_8016A268(GameState* gameState, s16 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5); void Play_Init(GameState* gameState); // void func_8016AC10(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); // void func_8016AE1C(void); diff --git a/include/z64.h b/include/z64.h index 4c875ca7e..189937fb7 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1291,7 +1291,7 @@ struct GlobalContext { /* 0x18790 */ void (*unk_18790)(struct GlobalContext* globalCtx, s16 arg1, Actor* actor); /* 0x18794 */ void* unk_18794; //! @TODO: Determine function prototype /* 0x18798 */ s32 (*setPlayerTalkAnim)(struct GlobalContext* globalCtx, void* talkAnim, s32 arg2); - /* 0x1879C */ s16 unk_1879C[10]; + /* 0x1879C */ s16 playerActorCsIds[10]; /* 0x187B0 */ MtxF viewProjectionMtxF; /* 0x187F0 */ Vec3f unk_187F0; /* 0x187FC */ MtxF billboardMtxF; @@ -1319,7 +1319,7 @@ struct GlobalContext { /* 0x1887C */ s8 unk_1887C; /* 0x1887D */ s8 unk_1887D; /* 0x1887E */ s8 unk_1887E; - /* 0x1887F */ u8 unk_1887F; + /* 0x1887F */ u8 unk_1887F; // fadeTransition /* 0x18880 */ u8 unk_18880; /* 0x18884 */ CollisionCheckContext colChkCtx; /* 0x18B20 */ u16 envFlags[20]; diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 064ee0a88..08a230e16 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -2016,7 +2016,7 @@ s32 Actor_PickUp(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRa player->getItemDirection = absYawDiff; if ((getItemId > GI_NONE) && (getItemId < GI_MAX)) { - ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[1]); + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[1]); } return true; @@ -2237,7 +2237,7 @@ void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEn s32 i; gSaveContext.weekEventReg[92] |= 0x80; - cycleFlags = &gSaveContext.cycleSceneFlags[convert_scene_number_among_shared_scenes(globalCtx->sceneNum)]; + cycleFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(globalCtx->sceneNum)]; bzero(actorCtx, sizeof(ActorContext)); ActorOverlayTable_Init(); @@ -3037,7 +3037,7 @@ void Actor_CleanupContext(ActorContext* actorCtx, GlobalContext* globalCtx) { actorCtx->absoluteSpace = NULL; } - func_80169D40(globalCtx); + Play_SaveCycleSceneFlags(&globalCtx->state); ActorOverlayTable_Cleanup(); } diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index ddf21fe17..a08e3f822 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -1145,7 +1145,7 @@ ColChkResetFunc sATResetFuncs[] = { s32 CollisionCheck_SetAT(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } sATResetFuncs[collider->shape](globalCtx, collider); @@ -1171,7 +1171,7 @@ s32 CollisionCheck_SetAT(GlobalContext* globalCtx, CollisionCheckContext* colCtx * will be inserted into the next slot. */ s32 CollisionCheck_SetAT_SAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, s32 index) { - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } sATResetFuncs[collider->shape](globalCtx, collider); @@ -1205,7 +1205,7 @@ ColChkResetFunc sACResetFuncs[] = { s32 CollisionCheck_SetAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } sACResetFuncs[collider->shape](globalCtx, collider); @@ -1231,7 +1231,7 @@ s32 CollisionCheck_SetAC(GlobalContext* globalCtx, CollisionCheckContext* colCtx * will be inserted into the next slot */ s32 CollisionCheck_SetAC_SAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, s32 index) { - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } sACResetFuncs[collider->shape](globalCtx, collider); @@ -1265,7 +1265,7 @@ ColChkResetFunc sOCResetFuncs[] = { s32 CollisionCheck_SetOC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } sOCResetFuncs[collider->shape](globalCtx, collider); @@ -1291,7 +1291,7 @@ s32 CollisionCheck_SetOC(GlobalContext* globalCtx, CollisionCheckContext* colCtx * will be inserted into the next slot. */ s32 CollisionCheck_SetOC_SAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, s32 index) { - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } sOCResetFuncs[collider->shape](globalCtx, collider); @@ -1323,7 +1323,7 @@ s32 CollisionCheck_SetOC_SAC(GlobalContext* globalCtx, CollisionCheckContext* co s32 CollisionCheck_SetOCLine(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, OcLine* line) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } diff --git a/src/code/z_effect.c b/src/code/z_effect.c index dd696393f..4c446b650 100644 --- a/src/code/z_effect.c +++ b/src/code/z_effect.c @@ -124,7 +124,7 @@ void Effect_Add(GlobalContext* globalCtx, s32* pIndex, s32 type, u8 arg3, u8 arg *pIndex = TOTAL_EFFECT_COUNT; - if (FrameAdvance_IsEnabled(globalCtx) != true) { + if (FrameAdvance_IsEnabled(&globalCtx->state) != true) { slotFound = false; switch (type) { case EFFECT_SPARK: diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index 43307bbc8..fd1d0212c 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -152,7 +152,7 @@ s32 EffectSS_FindFreeSpace(s32 priority, s32* tableEntry) { void EffectSS_Copy(GlobalContext* globalCtx, EffectSs* effectsSs) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx) != true) { + if (FrameAdvance_IsEnabled(&globalCtx->state) != true) { if (EffectSS_FindFreeSpace(effectsSs->priority, &index) == 0) { sEffectSsInfo.searchIndex = index + 1; sEffectSsInfo.data_table[index] = *effectsSs; diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 15f3a6693..6b375ecf8 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -67,7 +67,7 @@ void GameOver_Update(GlobalContext* globalCtx) { break; case GAMEOVER_DEATH_FADE_OUT: if (func_801A8A50(1) != NA_BGM_GAME_OVER) { - func_80169F78(globalCtx); + func_80169F78(&globalCtx->state); if (gSaveContext.respawnFlag != -7) { gSaveContext.respawnFlag = -6; } diff --git a/src/code/z_play.c b/src/code/z_play.c index a14359be7..b5c2b15c8 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -110,34 +110,254 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetCsCamDataVec3s.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/convert_scene_number_among_shared_scenes.s") +/** + * Converts the number of a scene to its "original" equivalent, the default version of the area which the player first + * enters. + */ +s16 Play_GetOriginalSceneNumber(s16 sceneNum) { + // Inverted Stone Tower Temple -> Stone Tower Temple + if (sceneNum == SCENE_INISIE_R) { + return SCENE_INISIE_N; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169D40.s") + // Purified Southern Swamp -> Poisoned Sothern Swamp + if (sceneNum == SCENE_20SICHITAI2) { + return SCENE_20SICHITAI; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169DCC.s") + // Spring Mountain Village -> Winter Mountain Village + if (sceneNum == SCENE_10YUKIYAMANOMURA2) { + return SCENE_10YUKIYAMANOMURA; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169E6C.s") + // Spring Goron Village -> Winter Goron Village + if (sceneNum == SCENE_11GORONNOSATO2) { + return SCENE_11GORONNOSATO; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169ECC.s") + // Spring Path to Goron Village -> Winter Path to Goron Village + if (sceneNum == SCENE_17SETUGEN2) { + return SCENE_17SETUGEN; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169EFC.s") + // Inverted Stone Tower -> Stone Tower + if (sceneNum == SCENE_F41) { + return SCENE_F40; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169F78.s") + return sceneNum; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169FDC.s") +/** + * Copies the flags set in ActorContext over to the current scene's CycleSceneFlags, usually using the original scene + * number. Exception for Inverted Stone Tower Temple, which uses its own. + */ +void Play_SaveCycleSceneFlags(GameState* gameState) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + CycleSceneFlags* cycleSceneFlags; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169FFC.s") + cycleSceneFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(globalCtx->sceneNum)]; + cycleSceneFlags->chest = globalCtx->actorCtx.flags.chest; + cycleSceneFlags->swch0 = globalCtx->actorCtx.flags.switches[0]; + cycleSceneFlags->swch1 = globalCtx->actorCtx.flags.switches[1]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/FrameAdvance_IsEnabled.s") + if (globalCtx->sceneNum == SCENE_INISIE_R) { // Inverted Stone Tower Temple + cycleSceneFlags = &gSaveContext.cycleSceneFlags[globalCtx->sceneNum]; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A02C.s") + cycleSceneFlags->collectible = globalCtx->actorCtx.flags.collectible[0]; + cycleSceneFlags->clearedRoom = globalCtx->actorCtx.flags.clearedRoom; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A0AC.s") +void Play_SetRespawnData(GameState* gameState, s32 respawnMode, u16 entranceIndex, s32 roomIndex, s32 playerParams, + Vec3f* pos, s16 yaw) { + GlobalContext* globalCtx = (GlobalContext*)gameState; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A168.s") + gSaveContext.respawn[respawnMode].entranceIndex = Entrance_CreateIndex(entranceIndex >> 9, 0, entranceIndex & 0xF); + gSaveContext.respawn[respawnMode].roomIndex = roomIndex; + gSaveContext.respawn[respawnMode].pos = *pos; + gSaveContext.respawn[respawnMode].yaw = yaw; + gSaveContext.respawn[respawnMode].playerParams = playerParams; + gSaveContext.respawn[respawnMode].tempSwchFlags = globalCtx->actorCtx.flags.switches[2]; + gSaveContext.respawn[respawnMode].unk_18 = globalCtx->actorCtx.flags.collectible[1]; + gSaveContext.respawn[respawnMode].tempCollectFlags = globalCtx->actorCtx.flags.collectible[2]; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A178.s") +void Play_SetupRespawnPoint(GameState* gameState, s32 respawnMode, s32 playerParams) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A268.s") + if (globalCtx->sceneNum != SCENE_KAKUSIANA) { // Grottos + Play_SetRespawnData(&globalCtx->state, respawnMode, (u16)((void)0, gSaveContext.entranceIndex), + globalCtx->roomCtx.currRoom.num, playerParams, &player->actor.world.pos, + player->actor.shape.rot.y); + } +} + +// Override respawn data in Sakon's Hideout +void func_80169ECC(GlobalContext* globalCtx) { + if (globalCtx->sceneNum == SCENE_SECOM) { + globalCtx->nextEntranceIndex = 0x2060; + gSaveContext.respawnFlag = -7; + } +} + +// Gameplay_TriggerVoidOut ? +// Used by Player, Ikana_Rotaryroom, Bji01, Kakasi, LiftNuts, Test4, Warptag, WarpUzu, Roomtimer +void func_80169EFC(GameState* gameState) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + + gSaveContext.respawn[0].tempSwchFlags = globalCtx->actorCtx.flags.switches[2]; + gSaveContext.respawn[0].unk_18 = globalCtx->actorCtx.flags.collectible[1]; + gSaveContext.respawn[0].tempCollectFlags = globalCtx->actorCtx.flags.collectible[2]; + globalCtx->nextEntranceIndex = gSaveContext.respawn[0].entranceIndex; + gSaveContext.respawnFlag = 1; + func_80169ECC(globalCtx); + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 2; +} + +// Gameplay_LoadToLastEntrance ? +// Used by game_over and Test7 +void func_80169F78(GameState* gameState) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + + globalCtx->nextEntranceIndex = gSaveContext.respawn[2].entranceIndex; + gSaveContext.respawnFlag = -1; + func_80169ECC(globalCtx); + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 2; +} + +// Gameplay_TriggerRespawn ? +// Used for void by Wallmaster, Deku Shrine doors. Also used by Player, Kaleido, DoorWarp1 +void func_80169FDC(GameState* gameState) { + func_80169F78(gameState); +} + +// Used by Kankyo to determine how to change the lighting, e.g. for game over. +s32 func_80169FFC(GameState* gameState) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + + return globalCtx->roomCtx.currRoom.mesh->type0.type != 1; +} + +s32 FrameAdvance_IsEnabled(GameState* gameState) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + + return globalCtx->frameAdvCtx.enabled != 0; +} + +// Unused, unchanged from OoT, which uses it only in one Camera function. +/** + * @brief Tests if \p actor is a door and the sides are different rooms. + * + * @param[in] gameState GameState, promoted to globalCtx inside. + * @param[in] actor Actor to test. + * @param[out] yaw Facing angle of the actor, or reverse if in the back room. + * @return true if \p actor is a door and the sides are in different rooms, false otherwise + */ +s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + TransitionActorEntry* transitionActor; + s8 frontRoom; + + if (actor->category != ACTORCAT_DOOR) { + return false; + } + + transitionActor = &globalCtx->doorCtx.transitionActorList[(u16)actor->params >> 10]; + frontRoom = transitionActor->sides[0].room; + if (frontRoom == transitionActor->sides[1].room) { + return false; + } + + if (frontRoom == actor->room) { + *yaw = actor->shape.rot.y; + } else { + *yaw = actor->shape.rot.y + 0x8000; + } + + return true; +} + +// Unused +/** + * @brief Tests if \p pos is underwater. + * + * @param[in] globalCtx GlobalContext + * @param[in] pos position to test + * @return true if inside a waterbox and not above a void. + */ +s32 Play_IsUnderwater(GlobalContext* globalCtx, Vec3f* pos) { + WaterBox* waterBox; + CollisionPoly* poly; + Vec3f waterSurfacePos; + s32 bgId; + + waterSurfacePos = *pos; + + if ((WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, waterSurfacePos.x, waterSurfacePos.z, &waterSurfacePos.y, + &waterBox) == true) && + (pos->y < waterSurfacePos.y) && + (BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &poly, &bgId, &waterSurfacePos) != BGCHECK_Y_MIN)) { + return true; + } else { + return false; + } +} + +// z_demo and EnTest4 +// This data appears to be a boolean. It is only set by Play_Init. +s32 func_8016A168(void) { + return D_801D0D50; +} + +// A mapping from playerActorCsIds to sGlobalCamDataSettings indices. +extern s16 D_801D0D64[]; +// s16 D_801D0D64[] = { -3, -2, -4, -5, -7, -11, -8, -9, -6, -16 }; + +// Used by Player +/** + * Extract the common actor cutscene ids used by Player from the scene and set the actor cutscene ids in + * globalCtx->playerActorCsIds. If a playerActorCsId is not present in the scene, then that particular id is set + * to -1. Otherwise, if there is an ActorCutscene where csCamSceneDataId matches the appropriate element of D_801D0D64, + * set the corresponding playerActorCsId (and possibly change its priority for the zeroth one) + */ +void Play_AssignPlayerActorCsIdsFromScene(GameState* gameState, s32 startActorCsId) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + s32 i; + s16* curPlayerActorCsId = globalCtx->playerActorCsIds; + s16* phi_s1 = D_801D0D64; + + for (i = 0; i < ARRAY_COUNT(globalCtx->playerActorCsIds); i++, curPlayerActorCsId++, phi_s1++) { + ActorCutscene* actorCutscene; + s32 curActorCsId; + + *curPlayerActorCsId = -1; + + for (curActorCsId = startActorCsId; curActorCsId != -1; curActorCsId = actorCutscene->additionalCutscene) { + actorCutscene = ActorCutscene_GetCutscene(curActorCsId); + + if (actorCutscene->csCamSceneDataId == *phi_s1) { + if ((actorCutscene->csCamSceneDataId == -3) && + (actorCutscene->priority == 700)) { // override ocarina cs priority + actorCutscene->priority = 550; + } + *curPlayerActorCsId = curActorCsId; + break; + } + } + } +} + +// These regs are used by Gameplay_Draw, and several actors, purpose as yet unclear. +void func_8016A268(GameState* gameState, s16 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5) { + MREG(64) = arg1; + MREG(65) = arg2; + MREG(66) = arg3; + MREG(67) = arg4; + MREG(68) = arg5; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Init.s") diff --git a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c index 13d8161e2..a3b234392 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c @@ -647,7 +647,7 @@ void func_80B814B8(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCurrentIndex() == this->dyna.actor.cutscene) { if (player->actor.bgCheckFlags & 0x100) { func_800B8E58(player, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->unk_92); - func_80169EFC(globalCtx); + func_80169EFC(&globalCtx->state); func_800B8E58(player, NA_SE_VO_LI_TAKEN_AWAY + player->ageProperties->unk_92); globalCtx->unk_18845 = 1; play_sound(NA_SE_OC_ABYSS); diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index 2017e960b..b32140c83 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -1566,7 +1566,7 @@ void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { } if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && - (globalCtx->msgCtx.unk11F04 == 0x5E6) && !FrameAdvance_IsEnabled(globalCtx) && + (globalCtx->msgCtx.unk11F04 == 0x5E6) && !FrameAdvance_IsEnabled(&globalCtx->state) && (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { time = gSaveContext.time; diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c index 85a7a9bc8..73d9911f9 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -147,7 +147,7 @@ void DoorAna_WaitOpen(DoorAna* this, GlobalContext* globalCtx) { // unused in vanilla, the highest params bits can directly index an address entranceIndex = GET_DOORANA_DIRECT_ENTRANCE(this); - func_80169E6C(globalCtx, 3, 0x4FF); + Play_SetupRespawnPoint(&globalCtx->state, 3, 0x4FF); gSaveContext.respawn[3].pos.y = this->actor.world.pos.y; gSaveContext.respawn[3].yaw = this->actor.home.rot.y; diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index a1a738fee..56f39772a 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -376,7 +376,7 @@ void func_808B93A0(DoorWarp1* this, GlobalContext* globalCtx) { } void func_808B94A4(DoorWarp1* this, GlobalContext* globalCtx) { - if (!func_808B866C(this, globalCtx) && (ActorCutscene_GetCurrentIndex() != globalCtx->unk_1879C[8])) { + if (!func_808B866C(this, globalCtx) && (ActorCutscene_GetCurrentIndex() != globalCtx->playerActorCsIds[8])) { DoorWarp1_SetupAction(this, func_808B921C); } func_808BB8D4(this, globalCtx, 1); @@ -384,10 +384,10 @@ void func_808B94A4(DoorWarp1* this, GlobalContext* globalCtx) { } void func_808B9524(DoorWarp1* this, GlobalContext* globalCtx) { - if (!ActorCutscene_GetCanPlayNext(globalCtx->unk_1879C[9])) { - ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[9]); + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[9])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[9]); } else { - ActorCutscene_Start(globalCtx->unk_1879C[9], NULL); + ActorCutscene_Start(globalCtx->playerActorCsIds[9], NULL); DoorWarp1_SetupAction(this, func_808B958C); } } @@ -456,10 +456,10 @@ void func_808B977C(DoorWarp1* this, GlobalContext* globalCtx) { } void func_808B9840(DoorWarp1* this, GlobalContext* globalCtx) { - if (!ActorCutscene_GetCanPlayNext(globalCtx->unk_1879C[9])) { - ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[9]); + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[9])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[9]); } else { - ActorCutscene_Start(globalCtx->unk_1879C[9], NULL); + ActorCutscene_Start(globalCtx->playerActorCsIds[9], NULL); DoorWarp1_SetupAction(this, func_808B98A8); } } @@ -488,7 +488,7 @@ void func_808B98A8(DoorWarp1* this, GlobalContext* globalCtx) { Scene_SetExitFade(globalCtx); globalCtx->sceneLoadFlag = 0x14; } else { - func_80169FDC(globalCtx); + func_80169FDC(&globalCtx->state); } } } @@ -615,10 +615,10 @@ void func_808B9FD0(DoorWarp1* this, GlobalContext* globalCtx) { return; } - if (!ActorCutscene_GetCanPlayNext(globalCtx->unk_1879C[9])) { - ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[9]); + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[9])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[9]); } else { - ActorCutscene_Start(globalCtx->unk_1879C[9], NULL); + ActorCutscene_Start(globalCtx->playerActorCsIds[9], NULL); Audio_PlaySfxGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); Animation_ChangeImpl(&this->skelAnime, &object_warp1_Anim_001374, 1.0f, Animation_GetLastFrame(&object_warp1_Anim_001374.common), @@ -767,7 +767,7 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { Scene_SetExitFade(globalCtx); globalCtx->sceneLoadFlag = 0x14; } else { - func_80169FDC(globalCtx); + func_80169FDC(&globalCtx->state); } } diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 53bdc0995..8faf1cdba 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -299,7 +299,7 @@ void func_809CD634(EnBji01* this, GlobalContext* globalCtx) { Audio_QueueSeqCmd(0xE0000101); globalCtx->nextEntranceIndex = 0x54A0; /* Termina Field from telescope */ gSaveContext.respawn[0].entranceIndex = globalCtx->nextEntranceIndex; - func_80169EFC(globalCtx); /* Load new entrance? */ + func_80169EFC(&globalCtx->state); /* Load new entrance? */ gSaveContext.respawnFlag = -2; this->actionFunc = EnBji01_DoNothing; } 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 9f4bdb728..c04cd1e9e 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -262,7 +262,7 @@ void func_80997E4C(EnGs* this, GlobalContext* globalCtx) { } void func_80997FF0(EnGs* this, GlobalContext* globalCtx) { - if (SubS_StartActorCutscene(&this->actor, globalCtx->unk_1879C[0], -1, SUBS_CUTSCENE_NORMAL)) { + if (SubS_StartActorCutscene(&this->actor, globalCtx->playerActorCsIds[0], -1, SUBS_CUTSCENE_NORMAL)) { func_80998040(this, globalCtx); } } @@ -339,7 +339,7 @@ void func_8099807C(EnGs* this, GlobalContext* globalCtx) { void func_80998300(EnGs* this, GlobalContext* globalCtx) { if (this->actor.cutscene != -1) { - ActorCutscene_Stop(globalCtx->unk_1879C[0]); + ActorCutscene_Stop(globalCtx->playerActorCsIds[0]); } } 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 f1d1737e4..2107be0b3 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -934,9 +934,9 @@ void EnKakasi_DancingNightAway(EnKakasi* this, GlobalContext* globalCtx) { if (this->unk204 == 0) { player = GET_PLAYER(globalCtx); - func_80169DCC(globalCtx, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF, &player->unk_3C0, - player->unk_3CC); - func_80169EFC(globalCtx); + Play_SetRespawnData(&globalCtx->state, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF, + &player->unk_3C0, player->unk_3CC); + func_80169EFC(&globalCtx->state); if (0) {} if (gSaveContext.time > CLOCK_TIME(18, 0) || gSaveContext.time < CLOCK_TIME(6, 0)) { diff --git a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c index 8ce550773..c87e30329 100644 --- a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c +++ b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c @@ -58,7 +58,7 @@ void func_8096B104(EnOkarinaEffect* this, GlobalContext* globalCtx) { void func_8096B174(EnOkarinaEffect* this, GlobalContext* globalCtx) { DECR(this->unk144); if (!globalCtx->pauseCtx.state && !globalCtx->gameOverCtx.state && !globalCtx->msgCtx.unk11F10 && - !FrameAdvance_IsEnabled(globalCtx) && this->unk144 == 0) { + !FrameAdvance_IsEnabled(&globalCtx->state) && this->unk144 == 0) { EnOkarinaEffect_SetupAction(this, func_8096B1FC); } } diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index 791323123..6886d2b29 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -399,9 +399,9 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { func_80A41FA4(this, globalCtx); } else { gSaveContext.unk_3F64 = 0.0f; - func_80169DCC(globalCtx, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF, - &player->unk_3C0, player->unk_3CC); - func_80169EFC(globalCtx); + Play_SetRespawnData(&globalCtx->state, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF, + &player->unk_3C0, player->unk_3CC); + func_80169EFC(&globalCtx->state); if (player->stateFlags1 & 0x800000) { EnHorse* rideActor = (EnHorse*)player->rideActor; @@ -440,16 +440,16 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { if ((this->nextBellTime == CLOCK_TIME(0, 0)) && ((gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) || (globalCtx->sceneNum == SCENE_CLOCKTOWER))) { - s32 phi_v0; + s32 playerParams; u32 entranceIndex = gSaveContext.entranceIndex; if ((globalCtx->actorCtx.unk5 & 2)) { - phi_v0 = 0xCFF; + playerParams = 0xCFF; } else { - phi_v0 = 0xBFF; + playerParams = 0xBFF; } - func_80169DCC(globalCtx, 1, entranceIndex, player->unk_3CE, phi_v0, &player->unk_3C0, - player->unk_3CC); + Play_SetRespawnData(&globalCtx->state, 1, entranceIndex, player->unk_3CE, playerParams, + &player->unk_3C0, player->unk_3CC); if ((globalCtx->sceneNum == SCENE_TENMON_DAI) || (globalCtx->sceneNum == SCENE_00KEIKOKU)) { globalCtx->nextEntranceIndex = 0x5400; diff --git a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c index 98ea88f83..22ebc78b5 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -74,7 +74,8 @@ void EnTorch2_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnTorch2* this = THIS; Collider_DestroyCylinder(globalCtx, &this->collider); - func_80169DCC(globalCtx, this->actor.params + 3, 0xFF, 0, 0xBFF, &this->actor.world.pos, this->actor.shape.rot.y); + Play_SetRespawnData(&globalCtx->state, this->actor.params + 3, 0xFF, 0, 0xBFF, &this->actor.world.pos, + this->actor.shape.rot.y); globalCtx->actorCtx.unk254[this->actor.params] = 0; } diff --git a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h index 70e5cd7cf..744a7975c 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h @@ -14,19 +14,19 @@ typedef struct EnTorch2 { } EnTorch2; // size = 0x194 typedef enum { - TORCH2_PARAM_HUMAN, - TORCH2_PARAM_GORON, - TORCH2_PARAM_ZORA, - TORCH2_PARAM_DEKU, - TORCH2_PARAM_FIERCE_DEITY, + /* 0 */ TORCH2_PARAM_HUMAN, + /* 1 */ TORCH2_PARAM_GORON, + /* 2 */ TORCH2_PARAM_ZORA, + /* 3 */ TORCH2_PARAM_DEKU, + /* 4 */ TORCH2_PARAM_FIERCE_DEITY, } EnTorch2Param; typedef enum { - TORCH2_STATE_INITIALIZED, - TORCH2_STATE_FADING_IN, - TORCH2_STATE_SOLID, - TORCH2_STATE_IDLE, - TORCH2_STATE_DYING, + /* 0 */ TORCH2_STATE_INITIALIZED, + /* 1 */ TORCH2_STATE_FADING_IN, + /* 2 */ TORCH2_STATE_SOLID, + /* 3 */ TORCH2_STATE_IDLE, + /* 4 */ TORCH2_STATE_DYING, } EnTorch2State; extern const ActorInit En_Torch2_InitVars; diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index db7b7a1fc..7a4a22170 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -944,7 +944,7 @@ s32 func_80A87B48(Actor* thisx, GlobalContext* globalCtx) { sp4C.z = 40.0f; Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, sp3E, &sp4C, &sp40); func_80A85620(this->unk_394, &sp40, 2.0f, 0.08f, 60.0f); - func_8016A268(globalCtx, 1, 160, 160, 160, 0); + func_8016A268(&globalCtx->state, 1, 160, 160, 160, 0); this->unk_370 = 20; this->unk_372 = 10; this->unk_364++; diff --git a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c index 3c19559af..ffbb9526b 100644 --- a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c +++ b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c @@ -113,7 +113,7 @@ void func_80A66278(EnWarpUzu* this, GlobalContext* globalCtx) { void func_80A66384(EnWarpUzu* this, GlobalContext* globalCtx) { globalCtx->nextEntranceIndex = 0x22A0; gSaveContext.respawn[0].entranceIndex = globalCtx->nextEntranceIndex; - func_80169EFC(globalCtx); + func_80169EFC(&globalCtx->state); gSaveContext.respawnFlag = -2; this->actionFunc = EnWarpUzu_DoNothing; } diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index b15cb5119..3334164bc 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -485,7 +485,7 @@ void EnWeatherTag_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && (globalCtx->msgCtx.unk11F04 == 0x5E6) && - (!FrameAdvance_IsEnabled(globalCtx)) && (globalCtx->sceneLoadFlag == 0) && + (!FrameAdvance_IsEnabled(&globalCtx->state)) && (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { oldTime = gSaveContext.time; diff --git a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c index a1cc93b9f..ff0c8d270 100644 --- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c +++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c @@ -68,7 +68,7 @@ void func_80973D3C(ObjRoomtimer* this, GlobalContext* globalCtx) { this->actionFunc = func_80973DE0; } else if (this->actor.params != 0x1FF && gSaveContext.unk_3DD0[4] == 0) { play_sound(NA_SE_OC_ABYSS); - func_80169EFC(globalCtx); + func_80169EFC(&globalCtx->state); Actor_MarkForDeath(&this->actor); } } diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 2c18ac2d0..0d5045501 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -409,6 +409,11 @@ animdict = { "func_800A81F0": "EffectBlure_AddVertex", "func_800A8514": "EffectBlure_AddSpace", "Effect_GetParams": "Effect_GetByIndex", + "convert_scene_number_among_shared_scenes": "Play_GetOriginalSceneNumber", + "func_80169D40": "Play_SaveCycleSceneFlags", + "func_80169DCC": "Play_SetRespawnData", + "func_80169E6C": "Play_SetupRespawnPoint", + "func_8016A0AC": "Play_IsUnderwater", "func_800F5A8C": "Environment_LerpWeight", "func_801A3F54": "Audio_SetCutsceneFlag", "func_801518B0": "Message_StartTextbox", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 7236e4521..672d67bec 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3024,10 +3024,10 @@ 0x80169BF8:("func_80169BF8",), 0x80169C64:("Play_GetCsCamDataSetting",), 0x80169C84:("Play_GetCsCamDataVec3s",), - 0x80169CBC:("convert_scene_number_among_shared_scenes",), - 0x80169D40:("func_80169D40",), - 0x80169DCC:("func_80169DCC",), - 0x80169E6C:("func_80169E6C",), + 0x80169CBC:("Play_GetOriginalSceneNumber",), + 0x80169D40:("Play_SaveCycleSceneFlags",), + 0x80169DCC:("Play_SetRespawnData",), + 0x80169E6C:("Play_SetupRespawnPoint",), 0x80169ECC:("func_80169ECC",), 0x80169EFC:("func_80169EFC",), 0x80169F78:("func_80169F78",), @@ -3035,9 +3035,9 @@ 0x80169FFC:("func_80169FFC",), 0x8016A01C:("FrameAdvance_IsEnabled",), 0x8016A02C:("func_8016A02C",), - 0x8016A0AC:("func_8016A0AC",), + 0x8016A0AC:("Play_IsUnderwater",), 0x8016A168:("func_8016A168",), - 0x8016A178:("func_8016A178",), + 0x8016A178:("Play_AssignPlayerActorCsIdsFromScene",), 0x8016A268:("func_8016A268",), 0x8016A2C8:("Play_Init",), 0x8016AC10:("func_8016AC10",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index b01c5729d..0e5151fed 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2179,7 +2179,7 @@ 0x801D0D58:("D_801D0D58","UNK_TYPE2","",0x2), 0x801D0D5C:("D_801D0D5C","UNK_TYPE2","",0x2), 0x801D0D60:("D_801D0D60","Input*","",0x4), - 0x801D0D64:("D_801D0D64","UNK_TYPE2","",0x2), + 0x801D0D64:("D_801D0D64","s16","[10]",0x14), 0x801D0D7A:("D_801D0D7A","UNK_TYPE1","",0x1), 0x801D0D80:("D_801D0D80","UNK_TYPE1","",0x1), 0x801D11F4:("D_801D11F4","UNK_TYPE1","",0x1), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index c93719e08..109d1df8a 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2538,10 +2538,10 @@ asm/non_matchings/code/z_play/Play_CameraGetUID.s,Play_CameraGetUID,0x80169BC4,0 asm/non_matchings/code/z_play/func_80169BF8.s,func_80169BF8,0x80169BF8,0x1B asm/non_matchings/code/z_play/Play_GetCsCamDataSetting.s,Play_GetCsCamDataSetting,0x80169C64,0x8 asm/non_matchings/code/z_play/Play_GetCsCamDataVec3s.s,Play_GetCsCamDataVec3s,0x80169C84,0xE -asm/non_matchings/code/z_play/convert_scene_number_among_shared_scenes.s,convert_scene_number_among_shared_scenes,0x80169CBC,0x21 -asm/non_matchings/code/z_play/func_80169D40.s,func_80169D40,0x80169D40,0x23 -asm/non_matchings/code/z_play/func_80169DCC.s,func_80169DCC,0x80169DCC,0x28 -asm/non_matchings/code/z_play/func_80169E6C.s,func_80169E6C,0x80169E6C,0x18 +asm/non_matchings/code/z_play/Play_GetOriginalSceneNumber.s,Play_GetOriginalSceneNumber,0x80169CBC,0x21 +asm/non_matchings/code/z_play/Play_SaveCycleSceneFlags.s,Play_SaveCycleSceneFlags,0x80169D40,0x23 +asm/non_matchings/code/z_play/Play_SetRespawnData.s,Play_SetRespawnData,0x80169DCC,0x28 +asm/non_matchings/code/z_play/Play_SetupRespawnPoint.s,Play_SetupRespawnPoint,0x80169E6C,0x18 asm/non_matchings/code/z_play/func_80169ECC.s,func_80169ECC,0x80169ECC,0xC asm/non_matchings/code/z_play/func_80169EFC.s,func_80169EFC,0x80169EFC,0x1F asm/non_matchings/code/z_play/func_80169F78.s,func_80169F78,0x80169F78,0x19 @@ -2549,7 +2549,7 @@ asm/non_matchings/code/z_play/func_80169FDC.s,func_80169FDC,0x80169FDC,0x8 asm/non_matchings/code/z_play/func_80169FFC.s,func_80169FFC,0x80169FFC,0x8 asm/non_matchings/code/z_play/FrameAdvance_IsEnabled.s,FrameAdvance_IsEnabled,0x8016A01C,0x4 asm/non_matchings/code/z_play/func_8016A02C.s,func_8016A02C,0x8016A02C,0x20 -asm/non_matchings/code/z_play/func_8016A0AC.s,func_8016A0AC,0x8016A0AC,0x2F +asm/non_matchings/code/z_play/Play_IsUnderwater.s,Play_IsUnderwater,0x8016A0AC,0x2F asm/non_matchings/code/z_play/func_8016A168.s,func_8016A168,0x8016A168,0x4 asm/non_matchings/code/z_play/func_8016A178.s,func_8016A178,0x8016A178,0x3C asm/non_matchings/code/z_play/func_8016A268.s,func_8016A268,0x8016A268,0x18 From 1e4411a8716fdfb64bc34892c104a541253eac15 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 5 Mar 2022 07:03:20 -0800 Subject: [PATCH 070/257] General Cleanup 2 (#681) * cleanup * Clean up toto * More ClockTime macro * rename pad * EnGo and format * EntityLineTest booleans * Other bgcheck tests * Graph Allocs * Lib_Segmented * Fix toto comment * Remove macro comment for EnBigpo_DrawLantern * Format and remove sym from undefined_syms.txt * PR suggestions * BgIkanaRay params * One day i'll remember Co-authored-by: Anghelo Carvajal --- include/functions.h | 2 +- src/code/code_800E8EA0.c | 12 ++-- src/code/z_actor.c | 3 +- src/code/z_en_item00.c | 23 ++++-- src/code/z_fcurve_data_skelanime.c | 6 +- src/code/z_game_over.c | 2 +- src/code/z_room.c | 2 +- src/code/z_scene.c | 55 +++++++------- src/code/z_scene_proc.c | 30 ++++---- .../ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c | 2 +- .../actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c | 12 ++-- .../actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.h | 6 +- .../actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c | 2 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 2 +- src/overlays/actors/ovl_Boss_04/z_boss_04.c | 4 +- src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c | 2 +- src/overlays/actors/ovl_En_Arrow/z_en_arrow.c | 2 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 71 +++++++++---------- .../actors/ovl_En_Bomjima/z_en_bomjima.c | 6 +- .../actors/ovl_En_Bomjimb/z_en_bomjimb.c | 9 +-- src/overlays/actors/ovl_En_Cow/z_en_cow.c | 2 +- src/overlays/actors/ovl_En_Dg/z_en_dg.c | 4 +- .../actors/ovl_En_Dinofos/z_en_dinofos.c | 2 +- src/overlays/actors/ovl_En_Dnb/z_en_dnb.c | 2 +- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 4 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 2 +- src/overlays/actors/ovl_En_Fz/z_en_fz.c | 3 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 6 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 10 ++- .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 2 +- src/overlays/actors/ovl_En_Gs/z_en_gs.c | 4 +- src/overlays/actors/ovl_En_In/z_en_in.c | 6 +- src/overlays/actors/ovl_En_Ja/z_en_ja.c | 4 +- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 13 ++-- src/overlays/actors/ovl_En_Ot/z_en_ot.c | 2 +- src/overlays/actors/ovl_En_Owl/z_en_owl.c | 4 +- .../actors/ovl_En_Peehat/z_en_peehat.c | 4 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 8 +-- .../actors/ovl_En_Po_Fusen/z_en_po_fusen.c | 2 +- src/overlays/actors/ovl_En_Rr/z_en_rr.c | 2 +- .../actors/ovl_En_Sellnuts/z_en_sellnuts.c | 4 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 16 ++--- src/overlays/actors/ovl_En_Skb/z_en_skb.h | 5 -- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 2 +- src/overlays/actors/ovl_En_Ssh/z_en_ssh.c | 4 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 4 +- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 2 +- .../actors/ovl_En_Torch2/z_en_torch2.c | 24 +++++-- src/overlays/actors/ovl_En_Toto/z_en_toto.c | 12 ++-- src/overlays/actors/ovl_En_Trt2/z_en_trt2.c | 4 +- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 2 +- .../ovl_En_Weather_Tag/z_en_weather_tag.c | 3 +- src/overlays/actors/ovl_En_Zot/z_en_zot.c | 25 +++---- src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c | 4 +- .../actors/ovl_Obj_Ending/z_obj_ending.c | 2 +- .../actors/ovl_Obj_HsStump/z_obj_hsstump.c | 24 +++---- .../actors/ovl_Obj_Iceblock/z_obj_iceblock.c | 6 +- .../actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c | 2 - .../actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c | 4 +- .../actors/ovl_Obj_Raillift/z_obj_raillift.c | 2 +- src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c | 2 +- tools/disasm/functions.txt | 6 +- undefined_syms.txt | 8 --- 63 files changed, 252 insertions(+), 254 deletions(-) diff --git a/include/functions.h b/include/functions.h index 27ac40589..05fe12474 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2405,7 +2405,7 @@ void Animation_MorphToLoop(SkelAnime* skelAnime, AnimationHeader* animation, f32 void Animation_PlayLoopSetSpeed(SkelAnime* skelAnime, AnimationHeader* animation, f32 playSpeed); void Animation_EndLoop(SkelAnime* skelAnime); void Animation_Reverse(SkelAnime* skelAnime); -void SkelAnime_CopyFrameTableTrue(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* index); +void SkelAnime_CopyFrameTableTrue(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* copyFlag); void SkelAnime_CopyFrameTableFalse(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* copyFlag); void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle); s32 Animation_OnFrame(SkelAnime* skelAnime, f32 frame); diff --git a/src/code/code_800E8EA0.c b/src/code/code_800E8EA0.c index 754b8759d..d95f53269 100644 --- a/src/code/code_800E8EA0.c +++ b/src/code/code_800E8EA0.c @@ -57,15 +57,13 @@ s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* Player* player = GET_PLAYER(globalCtx); s16 sVar3; Vec3f local_14; - s16 sVar3A; actor->focus.pos = actor->world.pos; actor->focus.pos.y += param_5; if (((globalCtx->csCtx).state == 0) && (D_801D0D50 == 0)) { - sVar3 = actor->yawTowardsPlayer - actor->shape.rot.y; - sVar3A = ABS_ALT(sVar3); - if (sVar3A >= 0x4300) { + sVar3 = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); + if (sVar3 >= 0x4300) { func_800E8F08(param_3, param_4); return 0; } @@ -86,14 +84,12 @@ s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* Player* player = GET_PLAYER(globalCtx); s16 sVar3; Vec3f local_14; - s16 sVar3A; actor->focus.pos = param_5; if (((globalCtx->csCtx).state == 0) && (D_801D0D50 == 0)) { - sVar3 = actor->yawTowardsPlayer - actor->shape.rot.y; - sVar3A = ABS_ALT(sVar3); - if (sVar3A >= 0x4300) { + sVar3 = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); + if (sVar3 >= 0x4300) { func_800E8F08(param_3, param_4); return 0; } diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 08a230e16..04f24e66f 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -3405,7 +3405,8 @@ void func_800BB604(GameState* gameState, ActorContext* actorCtx, Player* player, if (((phi_s2) || (phi_s2_2)) && (func_800B83BC(actor, temp_f0_2))) { if (func_800BB59C(globalCtx, actor)) { if (((!BgCheck_CameraLineTest1(&globalCtx->colCtx, &player->actor.focus.pos, - &actor->focus.pos, &sp70, &sp80, 1, 1, 1, 1, &sp7C)) || + &actor->focus.pos, &sp70, &sp80, true, true, true, true, + &sp7C)) || (SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, sp80, sp7C)))) { if (actor->targetPriority != 0) { if ((phi_s2 != 0) && (actor->targetPriority < D_801ED8D4)) { diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 5dc1f92a2..5c8a75f98 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -30,13 +30,22 @@ const ActorInit En_Item00_InitVars = { }; static ColliderCylinderInit sCylinderInit = { - { COLTYPE_NONE, AT_NONE, AC_ON | AT_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER }, - { ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000010, 0x00, 0x00 }, - TOUCH_NONE | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_NONE }, + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AT_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000010, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 10, 30, 0, { 0, 0, 0 } }, }; diff --git a/src/code/z_fcurve_data_skelanime.c b/src/code/z_fcurve_data_skelanime.c index c6ee50d87..e22b5f351 100644 --- a/src/code/z_fcurve_data_skelanime.c +++ b/src/code/z_fcurve_data_skelanime.c @@ -14,10 +14,10 @@ void SkelCurve_Clear(SkelAnimeCurve* skelCurve) { s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, TransformUpdateIndex* transUpdIdx) { SkelCurveLimb** limbs; - SkelCurveLimbList* limbList = (SkelCurveLimbList*)Lib_SegmentedToVirtual(limbListSeg); + SkelCurveLimbList* limbList = Lib_SegmentedToVirtual(limbListSeg); skelCurve->limbCount = limbList->limbCount; - skelCurve->limbList = (SkelCurveLimb**)Lib_SegmentedToVirtual(limbList->limbs); + skelCurve->limbList = Lib_SegmentedToVirtual(limbList->limbs); skelCurve->transforms = ZeldaArena_Malloc(sizeof(*skelCurve->transforms) * skelCurve->limbCount); @@ -100,7 +100,7 @@ s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve) { void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) { - SkelCurveLimb* limb = (SkelCurveLimb*)Lib_SegmentedToVirtual(skelCurve->limbList[limbIndex]); + SkelCurveLimb* limb = Lib_SegmentedToVirtual(skelCurve->limbList[limbIndex]); OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 6b375ecf8..411cb5d00 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -74,7 +74,7 @@ void GameOver_Update(GlobalContext* globalCtx) { gSaveContext.nextTransition = 2; gSaveContext.health = 48; gameOverCtx->state++; - if (gSaveContext.inventory.items[SLOT(ITEM_MASK_DEKU)] == ITEM_MASK_DEKU) { + if (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU) { gSaveContext.playerForm = PLAYER_FORM_HUMAN; gSaveContext.equippedMask = PLAYER_MASK_NONE; } diff --git a/src/code/z_room.c b/src/code/z_room.c index 67c6c6158..7579c6200 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -29,7 +29,7 @@ void Room_DrawType0Mesh(GlobalContext* globalCtx, Room* room, u32 flags) { } mesh = &room->mesh->type0; - meshParams = (RoomMeshType0Params*)Lib_SegmentedToVirtual(mesh->paramsStart); + meshParams = Lib_SegmentedToVirtual(mesh->paramsStart); for (i = 0; i < mesh->count; i++) { if ((flags & 1) && (meshParams->opaqueDl != NULL)) { gSPDisplayList(gfxCtx->polyOpa.p++, meshParams->opaqueDl); diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 6e4793661..6ef6a6091 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -13,8 +13,7 @@ s32 Object_Spawn(ObjectContext* objectCtx, s16 id) { } if (objectCtx->num < OBJECT_EXCHANGE_BANK_MAX - 1) { - objectCtx->status[objectCtx->num + 1].segment = - (void*)ALIGN16((u32)objectCtx->status[objectCtx->num].segment + size); + objectCtx->status[objectCtx->num + 1].segment = ALIGN16((u32)objectCtx->status[objectCtx->num].segment + size); } objectCtx->num++; @@ -172,9 +171,9 @@ void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x01: Actor List void Scene_HeaderCmdActorList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->numSetupActors = (u16)cmd->actorList.num; - globalCtx->setupActorList = (ActorEntry*)Lib_SegmentedToVirtual(cmd->actorList.segment); - globalCtx->actorCtx.unkC = (u16)0; + globalCtx->numSetupActors = cmd->actorList.num; + globalCtx->setupActorList = Lib_SegmentedToVirtual(cmd->actorList.segment); + globalCtx->actorCtx.unkC = 0; } // SceneTableEntry Header Command 0x02: List of cameras for actor cutscenes @@ -187,21 +186,21 @@ void Scene_HeaderCmdColHeader(GlobalContext* globalCtx, SceneCmd* cmd) { CollisionHeader* colHeaderTemp; CollisionHeader* colHeader; - colHeaderTemp = (CollisionHeader*)Lib_SegmentedToVirtual(cmd->colHeader.segment); + colHeaderTemp = Lib_SegmentedToVirtual(cmd->colHeader.segment); colHeader = colHeaderTemp; - colHeader->vtxList = (Vec3s*)Lib_SegmentedToVirtual(colHeaderTemp->vtxList); - colHeader->polyList = (CollisionPoly*)Lib_SegmentedToVirtual(colHeader->polyList); + colHeader->vtxList = Lib_SegmentedToVirtual(colHeaderTemp->vtxList); + colHeader->polyList = Lib_SegmentedToVirtual(colHeader->polyList); if (colHeader->surfaceTypeList != NULL) { - colHeader->surfaceTypeList = (SurfaceType*)Lib_SegmentedToVirtual(colHeader->surfaceTypeList); + colHeader->surfaceTypeList = Lib_SegmentedToVirtual(colHeader->surfaceTypeList); } if (colHeader->cameraDataList != NULL) { - colHeader->cameraDataList = (void*)Lib_SegmentedToVirtual(colHeader->cameraDataList); + colHeader->cameraDataList = Lib_SegmentedToVirtual(colHeader->cameraDataList); } if (colHeader->waterBoxes != NULL) { - colHeader->waterBoxes = (WaterBox*)Lib_SegmentedToVirtual(colHeader->waterBoxes); + colHeader->waterBoxes = Lib_SegmentedToVirtual(colHeader->waterBoxes); } BgCheck_Allocate(&globalCtx->colCtx, globalCtx, colHeader); @@ -210,12 +209,12 @@ void Scene_HeaderCmdColHeader(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x04: Room List void Scene_HeaderCmdRoomList(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->numRooms = cmd->roomList.num; - globalCtx->roomList = (RomFile*)Lib_SegmentedToVirtual(cmd->roomList.segment); + globalCtx->roomList = Lib_SegmentedToVirtual(cmd->roomList.segment); } // SceneTableEntry Header Command 0x06: Entrance List void Scene_HeaderCmdEntranceList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->setupEntranceList = (EntranceEntry*)Lib_SegmentedToVirtual(cmd->entranceList.segment); + globalCtx->setupEntranceList = Lib_SegmentedToVirtual(cmd->entranceList.segment); } // SceneTableEntry Header Command 0x07: Special Files @@ -248,19 +247,21 @@ void Scene_HeaderCmdRoomBehavior(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x0A: Mesh Header void Scene_HeaderCmdMesh(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->roomCtx.currRoom.mesh = (RoomMesh*)Lib_SegmentedToVirtual(cmd->mesh.segment); + globalCtx->roomCtx.currRoom.mesh = Lib_SegmentedToVirtual(cmd->mesh.segment); } // SceneTableEntry Header Command 0x0B: Object List void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) { - s32 i, j, k; + s32 i; + s32 j; + s32 k; ObjectStatus* firstObject; ObjectStatus* status; ObjectStatus* status2; s16* objectEntry; void* nextPtr; - objectEntry = (s16*)Lib_SegmentedToVirtual(cmd->objectList.segment); + objectEntry = Lib_SegmentedToVirtual(cmd->objectList.segment); k = 0; i = globalCtx->objectCtx.spawnedObjectCount; status = &globalCtx->objectCtx.status[i]; @@ -305,7 +306,7 @@ void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x0C: Light List void Scene_HeaderCmdLightList(GlobalContext* globalCtx, SceneCmd* cmd) { s32 i; - LightInfo* lightInfo = (LightInfo*)Lib_SegmentedToVirtual(cmd->lightList.segment); + LightInfo* lightInfo = Lib_SegmentedToVirtual(cmd->lightList.segment); for (i = 0; i < cmd->lightList.num; i++) { LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, lightInfo); @@ -315,14 +316,13 @@ void Scene_HeaderCmdLightList(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x0D: Path List void Scene_HeaderCmdPathList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->setupPathList = (Path*)Lib_SegmentedToVirtual(cmd->pathList.segment); + globalCtx->setupPathList = Lib_SegmentedToVirtual(cmd->pathList.segment); } // SceneTableEntry Header Command 0x0E: Transition Actor List void Scene_HeaderCmdTransiActorList(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->doorCtx.numTransitionActors = cmd->transiActorList.num; - globalCtx->doorCtx.transitionActorList = - (TransitionActorEntry*)Lib_SegmentedToVirtual((void*)cmd->transiActorList.segment); + globalCtx->doorCtx.transitionActorList = Lib_SegmentedToVirtual(cmd->transiActorList.segment); func_80105818(globalCtx, globalCtx->doorCtx.numTransitionActors, globalCtx->doorCtx.transitionActorList); } @@ -334,7 +334,7 @@ void Door_InitContext(GameState* state, DoorContext* doorCtx) { // SceneTableEntry Header Command 0x0F: Environment Light Settings List void Scene_HeaderCmdEnvLightSettings(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->envCtx.numLightSettings = cmd->lightSettingList.num; - globalCtx->envCtx.lightSettingsList = (void*)Lib_SegmentedToVirtual(cmd->lightSettingList.segment); + globalCtx->envCtx.lightSettingsList = Lib_SegmentedToVirtual(cmd->lightSettingList.segment); } /** @@ -440,7 +440,7 @@ void Scene_HeaderCmdWindSettings(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x13: Exit List void Scene_HeaderCmdExitList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->setupExitList = (u16*)Lib_SegmentedToVirtual(cmd->exitList.segment); + globalCtx->setupExitList = Lib_SegmentedToVirtual(cmd->exitList.segment); } // SceneTableEntry Header Command 0x09: Undefined @@ -468,11 +468,11 @@ void Scene_HeaderCmdAltHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) { SceneCmd* altHeader; if (gSaveContext.sceneSetupIndex) { - altHeaderList = (SceneCmd**)Lib_SegmentedToVirtual(cmd->altHeaders.segment); + altHeaderList = Lib_SegmentedToVirtual(cmd->altHeaders.segment); altHeader = altHeaderList[gSaveContext.sceneSetupIndex - 1]; if (altHeader != NULL) { - Scene_ProcessHeader(globalCtx, (SceneCmd*)Lib_SegmentedToVirtual(altHeader)); + Scene_ProcessHeader(globalCtx, Lib_SegmentedToVirtual(altHeader)); (cmd + 1)->base.code = 0x14; } } @@ -480,14 +480,13 @@ void Scene_HeaderCmdAltHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x17: Cutscene List void Scene_HeaderCmdCutsceneList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->csCtx.sceneCsCount = (u8)cmd->base.data1; - globalCtx->csCtx.sceneCsList = (CutsceneEntry*)Lib_SegmentedToVirtual((void*)cmd->base.data2); + globalCtx->csCtx.sceneCsCount = cmd->base.data1; + globalCtx->csCtx.sceneCsList = Lib_SegmentedToVirtual(cmd->base.data2); } // SceneTableEntry Header Command 0x1B: Actor Cutscene List void Scene_HeaderCmdActorCutsceneList(GlobalContext* globalCtx, SceneCmd* cmd) { - ActorCutscene_Init(globalCtx, (ActorCutscene*)Lib_SegmentedToVirtual(cmd->cutsceneActorList.segment), - cmd->cutsceneActorList.num); + ActorCutscene_Init(globalCtx, Lib_SegmentedToVirtual(cmd->cutsceneActorList.segment), cmd->cutsceneActorList.num); } // SceneTableEntry Header Command 0x1C: Mini Maps diff --git a/src/code/z_scene_proc.c b/src/code/z_scene_proc.c index b04b79bb4..f7f71a2dd 100644 --- a/src/code/z_scene_proc.c +++ b/src/code/z_scene_proc.c @@ -114,7 +114,7 @@ void AnimatedMat_DrawTwoTexScroll(GlobalContext* globalCtx, s32 segment, void* p * Generates a displaylist that sets the prim and env color, and stores it in the provided segment ID. */ void AnimatedMat_SetColor(GlobalContext* globalCtx, s32 segment, F3DPrimColor* primColorResult, F3DEnvColor* envColor) { - Gfx* colorDList = (Gfx*)GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); + Gfx* colorDList = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -141,13 +141,10 @@ void AnimatedMat_SetColor(GlobalContext* globalCtx, s32 segment, F3DPrimColor* p */ void AnimatedMat_DrawColor(GlobalContext* globalCtx, s32 segment, void* params) { AnimatedMatColorParams* colorAnimParams = (AnimatedMatColorParams*)params; - F3DPrimColor* primColor; + F3DPrimColor* primColor = Lib_SegmentedToVirtual(colorAnimParams->primColors); F3DEnvColor* envColor; - s32 curFrame; + s32 curFrame = sMatAnimStep % colorAnimParams->keyFrameLength; - primColor = (F3DPrimColor*)Lib_SegmentedToVirtual(colorAnimParams->primColors); - - curFrame = sMatAnimStep % colorAnimParams->keyFrameLength; primColor += curFrame; envColor = (colorAnimParams->envColors != NULL) ? (F3DEnvColor*)Lib_SegmentedToVirtual(colorAnimParams->envColors) + curFrame @@ -169,10 +166,10 @@ s32 AnimatedMat_Lerp(s32 min, s32 max, f32 norm) { */ void AnimatedMat_DrawColorLerp(GlobalContext* globalCtx, s32 segment, void* params) { AnimatedMatColorParams* colorAnimParams = (AnimatedMatColorParams*)params; - F3DPrimColor* primColorMax; + F3DPrimColor* primColorMax = Lib_SegmentedToVirtual(colorAnimParams->primColors); F3DEnvColor* envColorMax; - u16* keyFrames; - s32 curFrame; + u16* keyFrames = Lib_SegmentedToVirtual(colorAnimParams->keyFrames); + s32 curFrame = sMatAnimStep % colorAnimParams->keyFrameLength; s32 endFrame; s32 relativeFrame; // relative to the start frame s32 startFrame; @@ -183,9 +180,6 @@ void AnimatedMat_DrawColorLerp(GlobalContext* globalCtx, s32 segment, void* para F3DEnvColor envColorResult; s32 i; - primColorMax = (F3DPrimColor*)Lib_SegmentedToVirtual(colorAnimParams->primColors); - keyFrames = (u16*)Lib_SegmentedToVirtual(colorAnimParams->keyFrames); - curFrame = sMatAnimStep % colorAnimParams->keyFrameLength; keyFrames++; i = 1; @@ -211,7 +205,7 @@ void AnimatedMat_DrawColorLerp(GlobalContext* globalCtx, s32 segment, void* para primColorResult.lodFrac = AnimatedMat_Lerp(primColorMin->lodFrac, primColorMax->lodFrac, norm); if (colorAnimParams->envColors) { - envColorMax = (F3DEnvColor*)Lib_SegmentedToVirtual(colorAnimParams->envColors); + envColorMax = Lib_SegmentedToVirtual(colorAnimParams->envColors); envColorMax += i; envColorMin = envColorMax - 1; envColorResult.r = AnimatedMat_Lerp(envColorMin->r, envColorMax->r, norm); @@ -370,8 +364,8 @@ void AnimatedMat_DrawColorNonLinearInterp(GlobalContext* globalCtx, s32 segment, */ void AnimatedMat_DrawTexCycle(GlobalContext* globalCtx, s32 segment, void* params) { AnimatedMatTexCycleParams* texAnimParams = params; - void** texList = (void**)Lib_SegmentedToVirtual(texAnimParams->textureList); - u8* texId = (u8*)Lib_SegmentedToVirtual(texAnimParams->textureIndexList); + void** texList = Lib_SegmentedToVirtual(texAnimParams->textureList); + u8* texId = Lib_SegmentedToVirtual(texAnimParams->textureIndexList); s32 curFrame = sMatAnimStep % texAnimParams->keyFrameLength; void* tex = Lib_SegmentedToVirtual(texList[texId[curFrame]]); @@ -408,9 +402,9 @@ void AnimatedMat_DrawMain(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f do { segment = matAnim->segment; segmentAbs = ((segment < 0) ? -segment : segment) + 7; - matAnimDrawHandlers[matAnim->type](globalCtx, segmentAbs, (void*)Lib_SegmentedToVirtual(matAnim->params)); + matAnimDrawHandlers[matAnim->type](globalCtx, segmentAbs, Lib_SegmentedToVirtual(matAnim->params)); matAnim++; - } while (segment > -1); + } while (segment >= 0); } } @@ -726,7 +720,7 @@ void Scene_DrawConfigGreatBayTemple(GlobalContext* globalCtx) { BgCheck_UnsetContextFlags(&globalCtx->colCtx, BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW); } - dList = (Gfx*)GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 18); + dList = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 18); AnimatedMat_Draw(globalCtx, globalCtx->sceneMaterialAnims); diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index 6abaaf72c..4306d5582 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -87,7 +87,7 @@ static InitChainEntry sInitChain[] = { }; void func_80A9ACD0(BgHakuginPostUnkStruct* arg0) { - bzero((void*)arg0, sizeof(BgHakuginPostUnkStruct)); + bzero(arg0, sizeof(BgHakuginPostUnkStruct)); } void func_80A9ACF0(void) { diff --git a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c index 95e33a2ef..d0ec42522 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c @@ -69,9 +69,9 @@ void BgIkanaRay_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, collision, &this->actor, &sCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collision); - this->animatedTextures = (AnimatedMaterial*)Lib_SegmentedToVirtual(object_ikana_obj_Matanimheader_001228); + this->animatedTextures = Lib_SegmentedToVirtual(object_ikana_obj_Matanimheader_001228); - if (Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { + if (Flags_GetSwitch(globalCtx, BGIKANARAY_GET_SWITCH_FLAG(&this->actor))) { BgIkanaRay_SetActivated(this); } else { BgIkanaRay_SetDeactivated(this); @@ -88,11 +88,11 @@ void BgIkanaRay_Destroy(Actor* thisx, GlobalContext* globalCtx) { void BgIkanaRay_SetDeactivated(BgIkanaRay* this) { this->actor.draw = NULL; this->actor.flags |= ACTOR_FLAG_10; - this->update = BgIkanaRay_UpdateCheckForActivation; + this->actionFunc = BgIkanaRay_UpdateCheckForActivation; } void BgIkanaRay_UpdateCheckForActivation(BgIkanaRay* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { + if (Flags_GetSwitch(globalCtx, BGIKANARAY_GET_SWITCH_FLAG(&this->actor))) { BgIkanaRay_SetActivated(this); } } @@ -100,7 +100,7 @@ void BgIkanaRay_UpdateCheckForActivation(BgIkanaRay* this, GlobalContext* global void BgIkanaRay_SetActivated(BgIkanaRay* this) { this->actor.draw = BgIkanaRay_Draw; this->actor.flags &= ~ACTOR_FLAG_10; - this->update = BgIkanaRay_UpdateActivated; + this->actionFunc = BgIkanaRay_UpdateActivated; } void BgIkanaRay_UpdateActivated(BgIkanaRay* this, GlobalContext* globalCtx) { @@ -110,7 +110,7 @@ void BgIkanaRay_UpdateActivated(BgIkanaRay* this, GlobalContext* globalCtx) { void BgIkanaRay_Update(Actor* thisx, GlobalContext* globalCtx) { BgIkanaRay* this = THIS; - this->update(this, globalCtx); + this->actionFunc(this, globalCtx); } void BgIkanaRay_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.h b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.h index d17fbeed9..7c8d8c369 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.h @@ -5,11 +5,15 @@ struct BgIkanaRay; +typedef void (*BgIkanaRayActionFunc)(struct BgIkanaRay*, GlobalContext*); + +#define BGIKANARAY_GET_SWITCH_FLAG(thisx) ((thisx)->params & 0x7F) + typedef struct BgIkanaRay { /* 0x000 */ Actor actor; /* 0x144 */ ColliderCylinder collision; /* 0x190 */ AnimatedMaterial* animatedTextures; - /* 0x194 */ void (*update)(struct BgIkanaRay*, GlobalContext*); + /* 0x194 */ BgIkanaRayActionFunc actionFunc; } BgIkanaRay; // size = 0x198 extern const ActorInit Bg_Ikana_Ray_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c index a9bf94256..7cd39251c 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c +++ b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c @@ -162,7 +162,7 @@ void func_80BD7ED8(BgIknvObj* this, GlobalContext* globalCtx) { } void func_80BD7F4C(BgIknvObj* this, GlobalContext* globalCtx) { - if (gSaveContext.time > 0xD000) { + if (gSaveContext.time > CLOCK_TIME(19, 30)) { this->actionFunc = func_80BD7ED8; } if ((this->dyna.actor.home.rot.x == 1) && !(gSaveContext.weekEventReg[58] & 0x80)) { diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index e2c8c079e..ea65880de 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -1347,7 +1347,7 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { f32 sp9C; f32 sp98; - matrix = (RSPMatrix*)GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(RSPMatrix) * 23); + matrix = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(RSPMatrix) * 23); OPEN_DISPS(globalCtx->state.gfxCtx); 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 b4106527b..b74d9c66b 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -179,8 +179,8 @@ void Boss04_Init(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < ARRAY_COUNT(D_809EE1F8); i++) { spA8.x = D_809EE1F8[i].x + this->actor.world.pos.x; spA8.z = D_809EE1F8[i].z + this->actor.world.pos.z; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &spA8, &spB4, &spC0, 1, 0, 0, 1, - &spA4)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &spA8, &spB4, &spC0, true, false, false, + true, &spA4)) { if (i == 0) { this->unk_6D8 = spB4.x; } else if (i == 1) { diff --git a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c index 4dd75d843..102ecd95e 100644 --- a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c +++ b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c @@ -28,7 +28,7 @@ const ActorInit Dm_Nb_InitVars = { (ActorFunc)DmNb_Draw, }; -static AnimationInfoS D_80C1E200[] = { &object_nb_Anim_000990, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }; +static AnimationInfoS D_80C1E200[] = { { &object_nb_Anim_000990, 1.0f, 0, -1, ANIMMODE_LOOP, 0 } }; s32 func_80C1DED0(DmNb* this, s32 arg1) { s32 ret = false; diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index adfce2f19..d3286f545 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -472,7 +472,7 @@ void func_8088ACE0(EnArrow* this, GlobalContext* globalCtx) { } this->unk_262 = BgCheck_ProjectileLineTest(&globalCtx->colCtx, &this->actor.prevPos, &this->actor.world.pos, - &sp9C, &this->actor.wallPoly, 1, 1, 1, 1, &spA8); + &sp9C, &this->actor.wallPoly, true, true, true, true, &spA8); if (this->unk_262 != 0) { func_800B90AC(globalCtx, &this->actor, this->actor.wallPoly, spA8, &sp9C); Math_Vec3f_Copy(&this->actor.world.pos, &sp9C); diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index 4eeeb3894..6e2ca4186 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -1359,10 +1359,6 @@ void EnBigpo_DrawScoopSoul(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -/* - * this matches without OPENDISPS but with it has stack issues, - * might be able to find an alternative match with the macros, so far no success - */ void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx) { EnBigpo* this = THIS; f32 magnitude; @@ -1381,42 +1377,41 @@ void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx) { Math_Vec3f_Copy(&vec1, &gZeroVec3f); } - { - GraphicsContext* gfx = globalCtx->state.gfxCtx; + OPEN_DISPS(globalCtx->state.gfxCtx); - // fully visible OR fully transparent - if ((this->mainColor.a == 255) || (this->mainColor.a == 0)) { - Scene_SetRenderModeXlu(globalCtx, 0, 1); - dispHead = gfx->polyOpa.p; - } else { - Scene_SetRenderModeXlu(globalCtx, 1, 2); - dispHead = gfx->polyXlu.p; - } - - gSPDisplayList(&dispHead[0], &sSetupDL[6 * 0x19]); - - gSPSegment(&dispHead[1], 0x0A, Gfx_EnvColor(globalCtx->state.gfxCtx, 160, 0, 255, this->mainColor.a)); - - Matrix_GetStateTranslationAndScaledY(1400.0f, &vec2); - Lights_PointGlowSetInfo(&this->fires[0].info, vec2.x + vec1.x, vec2.y + vec1.y, vec2.z + vec1.z, - this->lanternColor.r, this->lanternColor.g, this->lanternColor.b, this->lanternColor.a); - - gDPSetEnvColor(&dispHead[2], this->lanternColor.r, this->lanternColor.g, this->lanternColor.b, - this->mainColor.a); - - gSPMatrix(&dispHead[3], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - gSPDisplayList(&dispHead[4], &gBigpoDrawLanternMainDL); - - gSPDisplayList(&dispHead[5], &gBigpoDrawLanternPurpleTopDL); - - // fully transparent OR fully invisible - if ((this->mainColor.a == 255) || (this->mainColor.a == 0)) { - gfx->polyOpa.p = &dispHead[6]; - } else { - gfx->polyXlu.p = &dispHead[6]; - } + // fully visible OR fully transparent + if ((this->mainColor.a == 255) || (this->mainColor.a == 0)) { + Scene_SetRenderModeXlu(globalCtx, 0, 1); + dispHead = POLY_OPA_DISP; + } else { + Scene_SetRenderModeXlu(globalCtx, 1, 2); + dispHead = POLY_XLU_DISP; } + + gSPDisplayList(&dispHead[0], &sSetupDL[6 * 0x19]); + + gSPSegment(&dispHead[1], 0x0A, Gfx_EnvColor(globalCtx->state.gfxCtx, 160, 0, 255, this->mainColor.a)); + + Matrix_GetStateTranslationAndScaledY(1400.0f, &vec2); + Lights_PointGlowSetInfo(&this->fires[0].info, vec2.x + vec1.x, vec2.y + vec1.y, vec2.z + vec1.z, + this->lanternColor.r, this->lanternColor.g, this->lanternColor.b, this->lanternColor.a); + + gDPSetEnvColor(&dispHead[2], this->lanternColor.r, this->lanternColor.g, this->lanternColor.b, this->mainColor.a); + + gSPMatrix(&dispHead[3], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(&dispHead[4], &gBigpoDrawLanternMainDL); + + gSPDisplayList(&dispHead[5], &gBigpoDrawLanternPurpleTopDL); + + // fully transparent OR fully invisible + if ((this->mainColor.a == 255) || (this->mainColor.a == 0)) { + POLY_OPA_DISP = &dispHead[6]; + } else { + POLY_XLU_DISP = &dispHead[6]; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); } void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c index 6bb4827ae..33b7e3058 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -268,7 +268,7 @@ void func_80BFE67C(EnBomjima* this, GlobalContext* globalCtx) { abs = ABS_ALT(BINANG_SUB(this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp54))); if ((abs < 0x4000) && !BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp54, &sp6C, - &sp50, 1, 0, 0, 1, &sp4C)) { + &sp50, true, false, false, true, &sp4C)) { func_80BFE494(this, 5, 1.0f); Math_Vec3f_Copy(&this->unk_2A4, &sp54); this->unk_2BE = Rand_S16Offset(30, 50); @@ -290,8 +290,8 @@ void func_80BFE67C(EnBomjima* this, GlobalContext* globalCtx) { sp60.x += Math_SinS(this->actor.world.rot.y) * 60.0f; sp60.z += Math_CosS(this->actor.world.rot.y) * 60.0f; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp60, &sp6C, &sp50, 1, 0, 0, 1, - &sp4C)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp60, &sp6C, &sp50, true, + false, false, true, &sp4C)) { this->unk_2C0 = 0; if (Rand_ZeroOne() < 0.5f) { func_80BFE494(this, 19, 1.0f); diff --git a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c index 26e9291d1..2989bbd02 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -276,7 +276,7 @@ void func_80C014E4(EnBomjimb* this, GlobalContext* globalCtx) { abs = ABS_ALT(BINANG_SUB(this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp48))); if ((abs < 0x4000) && !BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp48, &sp60, - &colPoly, 1, 0, 0, 1, &sp44)) { + &colPoly, true, false, false, true, &sp44)) { func_80C0113C(this, 5, 1.0f); Math_Vec3f_Copy(&this->unk_294, &sp48); this->unk_2B0 = Rand_S16Offset(30, 50); @@ -295,8 +295,8 @@ void func_80C014E4(EnBomjimb* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp54, &this->actor.world.pos); sp54.x += Math_SinS(this->actor.world.rot.y) * 60.0f; sp54.z += Math_CosS(this->actor.world.rot.y) * 60.0f; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp54, &sp60, &colPoly, 1, 0, 0, - 1, &sp44)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp54, &sp60, &colPoly, true, + false, false, true, &sp44)) { this->unk_2AE = 0; if (Rand_ZeroOne() < 0.5f) { func_80C0113C(this, 20, 1.0f); @@ -556,7 +556,8 @@ void func_80C0217C(EnBomjimb* this, GlobalContext* globalCtx) { sp74.y += 20.0f; sp74.z += Math_CosS(this->actor.world.rot.y) * 50.0f; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp74, &sp64, &sp70, 1, 0, 0, 1, &sp60)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp74, &sp64, &sp70, true, false, false, + true, &sp60)) { s16 temp = BINANG_SUB((this->actor.world.rot.y - this->actor.yawTowardsPlayer), 0x8000); this->unk_2D6 = temp; diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index fd42fd3f3..73569c34b 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -269,7 +269,7 @@ void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { this->flags &= ~EN_COW_FLAG_WONT_GIVE_MILK; D_801BDAA4 = 0; } else if ((this->actor.xzDistToPlayer < 150.0f) && - ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 25000) { + ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)) < 25000) { D_801BDAA4 = 0; this->actionFunc = EnCow_Talk; this->actor.flags |= ACTOR_FLAG_10000; diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index 263469dac..0648ca4ad 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -206,7 +206,7 @@ void func_8098933C(EnDg* this, Vec3f* arg1) { } s32 func_80989418(EnDg* this, Path* arg1, s32 arg2) { - Vec3s* sp5C = (Vec3s*)Lib_SegmentedToVirtual(arg1->points); + Vec3s* sp5C = Lib_SegmentedToVirtual(arg1->points); s32 count = arg1->count; s32 idx = arg2; s32 sp50 = false; @@ -243,7 +243,7 @@ s16 func_809895B4(Path* path, s32 idx, Vec3f* pos, f32* distSQ) { f32 diffZ; if (path != NULL) { - points = (Vec3s*)Lib_SegmentedToVirtual(path->points); + points = Lib_SegmentedToVirtual(path->points); points = &points[idx]; diffX = points->x - pos->x; diffZ = points->z - pos->z; diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index 079abb641..03afec1fb 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -280,7 +280,7 @@ void EnDinofos_Init(Actor* thisx, GlobalContext* globalCtx) { if (D_8089E364 == 0) { for (i = 0; i < ARRAY_COUNT(D_8089E33C); i++) { - D_8089E33C[i] = (Gfx*)Lib_SegmentedToVirtual(D_8089E33C[i]); + D_8089E33C[i] = Lib_SegmentedToVirtual(D_8089E33C[i]); } D_8089E364 = 1; } diff --git a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c index a637174bf..d074753be 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c @@ -107,7 +107,7 @@ void EnDnb_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_Init(&this->dyna, 1); DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_hanareyama_obj_Colheader_004D8C); - alloc = (s16*)Lib_SegmentedToVirtual(object_hanareyama_obj_Vec_004710); + alloc = Lib_SegmentedToVirtual(object_hanareyama_obj_Vec_004710); for (i = 0; i < ARRAY_COUNT(this->particles); i++) { func_80A4FDD0(&this->particles[i], this, alloc, i); } diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.c b/src/overlays/actors/ovl_En_Dno/z_en_dno.c index f05817282..d51ec8a4d 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -40,8 +40,6 @@ void func_80A732C8(EnDno* this, GlobalContext* globalCtx); s32 EnDno_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); -extern u8 D_801C20C0; - static AnimationSpeedInfo sAnimations[] = { { &object_dno_Anim_000470, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_0008F0, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_000F6C, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_001A50, 1.0f, ANIMMODE_ONCE, 0.0f }, @@ -611,7 +609,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { case 0x802: if (func_80147624(globalCtx)) { - if (gSaveContext.inventory.items[D_801C20C0] == ITEM_MASK_SCENTS) { + if (INV_CONTENT(ITEM_MASK_SCENTS) == ITEM_MASK_SCENTS) { this->unk_458 = GI_RUPEE_RED; } else { this->unk_458 = GI_MASK_SCENTS; diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index e2519c7c5..aac247546 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -176,7 +176,7 @@ void func_809619D0(EnFu* this, GlobalContext* globalCtx) { } this->unk_520 = path->count; - this->unk_538 = (Vec3s*)Lib_SegmentedToVirtual(path->points); + this->unk_538 = Lib_SegmentedToVirtual(path->points); func_809616E0(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.c b/src/overlays/actors/ovl_En_Fz/z_en_fz.c index 8bd7e128b..ea225846a 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -266,7 +266,8 @@ void func_80932784(EnFz* this, GlobalContext* globalCtx) { sp44.z = 440.0f; Matrix_MultiplyVector3fByState(&sp44, &this->unk_22C); - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp5C, &this->unk_22C, &sp50, &sp3C, 1, 0, 0, 1, &sp40)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp5C, &this->unk_22C, &sp50, &sp3C, true, false, false, true, + &sp40)) { Math_Vec3f_Copy(&this->unk_22C, &sp50); } 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 dc063bd35..094de1c62 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -907,7 +907,7 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if ((actor != NULL) && (actor->update != NULL)) { if (this->unk_234 != NULL) { - sp48 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + sp48 = Lib_SegmentedToVirtual(this->unk_234->points); Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); this->actor.shape.shadowDraw = NULL; @@ -938,7 +938,7 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (this->unk_234 != NULL) { - sp4C = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + sp4C = Lib_SegmentedToVirtual(this->unk_234->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); Math_Vec3s_ToVec3f(&sp34, &sp4C[1]); Math_Vec3f_Copy(&this->unk_278, &sp40); @@ -1080,7 +1080,7 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } if (this->unk_234 != NULL) { - sp48 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + sp48 = Lib_SegmentedToVirtual(this->unk_234->points); Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); this->actor.shape.shadowDraw = NULL; 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 771f0ab83..00355cb45 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -301,7 +301,7 @@ void func_80A1143C(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg void func_80A115B4(EnGoStruct ptr[], GlobalContext* globalCtx) { static TexturePtr D_80A16644[] = { - &gDust8Tex, &gDust7Tex, &gDust6Tex, &gDust5Tex, &gDust4Tex, &gDust3Tex, &gDust2Tex, &gDust1Tex, + gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, }; static Color_RGBA8 D_80A16664[] = { { 255, 255, 255, 0 }, @@ -1449,7 +1449,11 @@ void func_80A146CC(EnGo* this, GlobalContext* globalCtx) { } void func_80A14798(EnGo* this, GlobalContext* globalCtx) { - s32 sp38[2] = { 0x0000003E, 0x00000F64 }; + EffectTireMarkInit sp38 = { + 0, + 62, + { 0, 0, 15, 100 }, + }; if ((this->unk_288 < 0) || SubS_IsObjectLoaded(this->unk_288, globalCtx) || (this->unk_289 < 0) || SubS_IsObjectLoaded(this->unk_289, globalCtx)) { @@ -1464,7 +1468,7 @@ void func_80A14798(EnGo* this, GlobalContext* globalCtx) { Collider_InitAndSetSphere(globalCtx, &this->colliderSphere, &this->actor, &sSphereInit); Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit2); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - Effect_Add(globalCtx, &this->unk_3E8, 4, 0, 0, &sp38); + Effect_Add(globalCtx, &this->unk_3E8, EFFECT_TIRE_MARK, 0, 0, &sp38); this->actor.targetMode = 1; this->unk_3A4 = 0.01f; 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 704167822..610d85b8b 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -992,7 +992,7 @@ void EnGoroiwa_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.shadowAlpha = 200; func_8093EB58(this, globalCtx); - this->unk_1D0 = (Vec3s*)Lib_SegmentedToVirtual(sp2C->points); + this->unk_1D0 = Lib_SegmentedToVirtual(sp2C->points); func_8093EE18(this, globalCtx); func_8093EE64(this, this->actor.home.rot.y); 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 c04cd1e9e..7dc4e6968 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -1025,8 +1025,8 @@ void EnGs_Update(Actor* thisx, GlobalContext* globalCtx) { if ((this->actor.flags & ACTOR_FLAG_40) || (this->unk_19A & 0x100) || (this->unk_19A & 0x200)) { func_80999BC8(&this->actor, globalCtx); Actor_GetScreenPos(globalCtx, &this->actor, &sp2E, &sp2C); - if ((this->actor.xyzDistToPlayerSq > SQ(400.0f)) || (sp2E < 0) || (sp2E > 320) || (sp2C < 0) || - (sp2C > 240)) { + if ((this->actor.xyzDistToPlayerSq > SQ(400.0f)) || (sp2E < 0) || (sp2E > SCREEN_WIDTH) || (sp2C < 0) || + (sp2C > SCREEN_HEIGHT)) { this->unk_216 = 0; } else if (this->unk_21C > 0) { func_800BC848(&this->actor, globalCtx, this->unk_21C, this->unk_21E); 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 e84a18bef..5a1ec5a18 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -1208,7 +1208,6 @@ s32 func_808F5674(GlobalContext* globalCtx, EnIn* this, s32 arg2) { s32 func_808F5728(GlobalContext* globalCtx, EnIn* this, s32 arg2, s32* arg3) { s16 rotDiff; s16 yawDiff; - s16 yawDiffA; Player* player; if (*arg3 == 4) { @@ -1253,9 +1252,8 @@ s32 func_808F5728(GlobalContext* globalCtx, EnIn* this, s32 arg2, s32* arg3) { if (!func_800B8934(globalCtx, &this->actor)) { return 0; } - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - yawDiffA = ABS_ALT(yawDiff); - if (yawDiffA >= 0x4300) { + yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)); + if (yawDiff >= 0x4300) { return 0; } if (this->actor.xyzDistToPlayerSq > SQ(160.0f) && !this->actor.isTargeted) { 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 340c186ef..b31436bb4 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -514,7 +514,7 @@ void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -void EnJa_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnJa_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnJa* this = THIS; s32 phi_v1; s32 phi_v0; @@ -602,7 +602,7 @@ void EnJa_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnJa_OverrideLimbDraw, EnJa_PostLimbDraw, - EnJa_TransformDraw, &this->actor); + EnJa_TransformLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } 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 2107be0b3..d7e113cb3 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -46,9 +46,6 @@ void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx); void EnKakasi_SetupDialogue(EnKakasi* this); -void EnKakasi_PostLimbDraw(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, - struct Actor* thisx); - static ColliderCylinderInit D_80971D80 = { { COLTYPE_NONE, @@ -336,8 +333,8 @@ void EnKakasi_SetupIdleStanding(EnKakasi* this) { void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx) { u32 saveContextDay = gSaveContext.day; - s16 passedValue1; - s16 passedValue2; + s16 x; + s16 y; // first talk to scarecrow dialogue this->actor.textId = 0x1644; @@ -352,9 +349,9 @@ void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx) { return; } if (globalCtx->actorCtx.unk5 & 0x4) { - Actor_GetScreenPos(globalCtx, &this->actor, &passedValue1, &passedValue2); - if (this->actor.projectedPos.z > -20.0f && passedValue1 > 0 && passedValue1 < 0x140 && passedValue2 > 0 && - passedValue2 < 0xF0 && this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + Actor_GetScreenPos(globalCtx, &this->actor, &x, &y); + if (this->actor.projectedPos.z > -20.0f && x > 0 && x < SCREEN_WIDTH && y > 0 && y < SCREEN_HEIGHT && + this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { // faster shaking EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); this->skelanime.playSpeed = 2.0f; diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index f7f41a2c1..6eb555ef1 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -1038,7 +1038,7 @@ void EnOt_Draw(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - AnimatedMat_Draw(globalCtx, (AnimatedMaterial*)Lib_SegmentedToVirtual(object_ot_Matanimheader_0005F8)); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_ot_Matanimheader_0005F8)); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnOt_PostLimbDraw, &this->actor); Matrix_InsertTranslation(this->unk_378.x, this->unk_378.y, this->unk_378.z, MTXMODE_NEW); diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index ceacff185..f7eb61490 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -408,7 +408,7 @@ s32 func_8095B06C(EnOwl* this) { void func_8095B0C8(EnOwl* this) { s32 pad; - Vec3s* points = (Vec3s*)Lib_SegmentedToVirtual(this->path->points); + Vec3s* points = Lib_SegmentedToVirtual(this->path->points); points += this->unk_3F8; this->unk_3EC = Math_FAtan2F(points->z - this->actor.world.pos.z, points->x - this->actor.world.pos.x); @@ -542,7 +542,7 @@ void func_8095B76C(EnOwl* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; if (sp44 < SQ(this->actor.speedXZ)) { this->actor.speedXZ = 0.0f; - points = (Vec3s*)Lib_SegmentedToVirtual(this->path->points); + points = Lib_SegmentedToVirtual(this->path->points); points += this->unk_3F8; do { diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c index 4f6f5ceb3..f6da4cba2 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -797,8 +797,8 @@ void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); for (i = 1; i >= 0; i--) { - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &thisx->world.pos, &this->unk_2D4[i], &sp74, &sp70, 1, - 1, 0, 1, &sp6C)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &thisx->world.pos, &this->unk_2D4[i], &sp74, &sp70, + true, true, false, true, &sp6C)) { func_800BBFB0(globalCtx, &sp74, 0.0f, 1, 300, 150, 1); func_80897258(globalCtx, this, &sp74, 0.0f, 1.5f); } diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 10648fa3f..7792e578f 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -919,7 +919,7 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if ((sp2C != NULL) && (sp2C->update != NULL)) { if (this->unk_234 != NULL) { - sp48 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + sp48 = Lib_SegmentedToVirtual(this->unk_234->points); Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); this->actor.shape.shadowDraw = NULL; @@ -950,7 +950,7 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (this->unk_234 != 0) { - sp4C = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + sp4C = Lib_SegmentedToVirtual(this->unk_234->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); Math_Vec3s_ToVec3f(&sp34, &sp4C[1]); Math_Vec3f_Copy(&this->unk_26C, &sp40); @@ -1074,7 +1074,7 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { - sp30 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + sp30 = Lib_SegmentedToVirtual(this->unk_234->points); Math_Vec3s_ToVec3f(&sp40, &sp30[0]); Math_Vec3s_ToVec3f(&sp34, &sp30[1]); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); @@ -1127,7 +1127,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { - sp30 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + sp30 = Lib_SegmentedToVirtual(this->unk_234->points); Math_Vec3s_ToVec3f(&sp40, &sp30[this->unk_234->count - 1]); Math_Vec3s_ToVec3f(&sp34, &sp30[this->unk_234->count - 2]); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp34, &sp40); diff --git a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c index 52223aaae..d6c9d7065 100644 --- a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c +++ b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c @@ -147,7 +147,7 @@ void EnPoFusen_Destroy(Actor* thisx, GlobalContext* globalCtx) { } u16 EnPoFusen_CheckParent(EnPoFusen* this, GlobalContext* globalCtx) { - struct Actor* actorPtr; + Actor* actorPtr; actorPtr = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; if (GET_IS_FUSE_TYPE_PARAM(this)) { diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.c b/src/overlays/actors/ovl_En_Rr/z_en_rr.c index 71d08787e..57f4b9bcd 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -875,7 +875,7 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { Vec3f spA4; f32 temp_f20; - matrix = GRAPH_ALLOC(globalCtx->state.gfxCtx, 256); + matrix = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Mtx) * 4); OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c index 6b299ae9a..a35715170 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -892,7 +892,7 @@ void func_80ADCD3C(EnSellnuts* this, GlobalContext* globalCtx) { } s32 func_80ADCE4C(EnSellnuts* this, Path* path, s32 arg2) { - Vec3s* points = (Vec3s*)Lib_SegmentedToVirtual(path->points); + Vec3s* points = Lib_SegmentedToVirtual(path->points); s32 count = path->count; s32 var = arg2; s32 ret = false; @@ -929,7 +929,7 @@ f32 func_80ADCFE8(Path* path, s32 arg1, Vec3f* pos, Vec3s* arg3) { Vec3s* points; if (path != NULL) { - points = (Vec3s*)Lib_SegmentedToVirtual(path->points); + points = Lib_SegmentedToVirtual(path->points); points = &points[arg1]; sp20.x = points->x; sp20.y = points->y; diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index 166f0377e..4984c6160 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -814,10 +814,10 @@ void func_809964DC(EnSkb* this, GlobalContext* globalCtx) { } } -s32 func_80996544(EnSkbVec2f arg0, EnSkbVec2f arg1) { +s32 func_80996544(Vec2f arg0, Vec2f arg1) { s32 ret; - if ((arg1.x * arg0.z) < (arg0.x * arg1.z)) { + if ((arg1.x * arg0.y) < (arg0.x * arg1.y)) { ret = 1; } else { ret = -1; @@ -829,8 +829,8 @@ s32 func_80996544(EnSkbVec2f arg0, EnSkbVec2f arg1) { s32 func_80996594(EnSkb* this, GlobalContext* globalCtx) { s32 temp_s2; s32 j; - EnSkbVec2f sp60; - EnSkbVec2f sp58; + Vec2f sp60; + Vec2f sp58; s32 sp54 = true; f32 worldZ; s32 i = 0; @@ -840,9 +840,9 @@ s32 func_80996594(EnSkb* this, GlobalContext* globalCtx) { worldX = this->actor.world.pos.x; sp60.x = D_80997468[0].z - worldZ; - sp60.z = D_80997468[0].x - worldX; + sp60.y = D_80997468[0].x - worldX; sp58.x = D_80997468[1].z - worldZ; - sp58.z = D_80997468[1].x - worldX; + sp58.y = D_80997468[1].x - worldX; j = 1; temp_s2 = func_80996544(sp60, sp58); @@ -856,9 +856,9 @@ s32 func_80996594(EnSkb* this, GlobalContext* globalCtx) { j = 0; } sp60.x = D_80997468[i].z - worldZ; - sp60.z = D_80997468[i].x - worldX; + sp60.y = D_80997468[i].x - worldX; sp58.x = D_80997468[j].z - worldZ; - sp58.z = D_80997468[j].x - worldX; + sp58.y = D_80997468[j].x - worldX; if (func_80996544(sp60, sp58) != temp_s2) { sp54 = false; break; diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.h b/src/overlays/actors/ovl_En_Skb/z_en_skb.h index 59186808d..0e3134561 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.h +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.h @@ -9,11 +9,6 @@ typedef void (*EnSkbActionFunc)(struct EnSkb*, GlobalContext*); #define ENSKB_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) -typedef struct { - f32 x; - f32 z; -} EnSkbVec2f; - typedef struct EnSkb { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index c05c589be..ecf1f814b 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -1255,7 +1255,7 @@ s16 EnSob1_GetXZAngleAndDistanceSqToPoint(Path* path, s32 pointIdx, Vec3f* pos, f32 diffZ; if (path != NULL) { - points = (Vec3s*)Lib_SegmentedToVirtual(path->points); + points = Lib_SegmentedToVirtual(path->points); points = &points[pointIdx]; diffX = points->x - pos->x; diffZ = points->z - pos->z; 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 fbd391f32..4c0983545 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -151,8 +151,8 @@ s32 EnSsh_CheckCeilingPos(EnSsh* this, GlobalContext* globalCtx) { posB.x = this->actor.world.pos.x; posB.y = this->actor.world.pos.y + 1000.0f; posB.z = this->actor.world.pos.z; - if (!BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &posB, &this->ceilingPos, &poly, 0, 0, 1, - 1, &bgId)) { + if (!BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &posB, &this->ceilingPos, &poly, false, + false, true, true, &bgId)) { return false; } return true; diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 07b1df03f..733ecb8a6 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -510,7 +510,7 @@ s16 func_80BAB698(Path* path, s32 idx, Vec3f* pos, f32* distSQ) { f32 diffZ; if (path != NULL) { - points = (Vec3s*)Lib_SegmentedToVirtual(path->points); + points = Lib_SegmentedToVirtual(path->points); points = &points[idx]; diffX = points->x - pos->x; diffZ = points->z - pos->z; @@ -691,7 +691,7 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg if ((sp48 == NULL) || (this->unk404 == NULL)) { return 0; } - sp28 = (Vec3s*)Lib_SegmentedToVirtual(this->unk404->points); + sp28 = Lib_SegmentedToVirtual(this->unk404->points); Math_Vec3s_ToVec3f(&sp38, &sp28[0]); Math_Vec3s_ToVec3f(&sp2C, &sp28[1]); this->unk434 = sp44 - unkStruct->unk4; diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index abf7b3a40..14e4dfc8b 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -921,7 +921,7 @@ void func_808DAA60(EnSw* this, GlobalContext* globalCtx) { Vec3f sp34; f32 temp_f16; - sp44 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_1E4->points); + sp44 = Lib_SegmentedToVirtual(this->unk_1E4->points); sp40 = 0; if (DECR(this->unk_454) == 0) { diff --git a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c index 22ebc78b5..3789bb99a 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -32,9 +32,22 @@ const ActorInit En_Torch2_InitVars = { }; static ColliderCylinderInit sCylinderInit = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1 | OC1_TYPE_2, - OC2_TYPE_2, COLSHAPE_CYLINDER }, - { ELEMTYPE_UNK2, { 0x00100000, 0, 0 }, { 0xF7CFFFFF, 0, 0 }, TOUCH_NONE, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON }, + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1 | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00100000, 0, 0 }, + { 0xF7CFFFFF, 0, 0 }, + TOUCH_NONE, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 20, 60, 0, { 0, 0, 0 } }, }; @@ -147,10 +160,9 @@ void EnTorch2_UpdateDeath(Actor* thisx, GlobalContext* globalCtx) { } } -void EnTorch2_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnTorch2_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; EnTorch2* this = THIS; - - GlobalContext* unused = globalCtx; Gfx* gfx = sShellDLists[thisx->params]; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index 746aec883..9334180cd 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -184,7 +184,8 @@ void EnToto_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - if (globalCtx->sceneNum == SCENE_MILK_BAR && (gSaveContext.time >= 0x4000 && gSaveContext.time < 0xE555)) { + if (globalCtx->sceneNum == SCENE_MILK_BAR && + (gSaveContext.time >= CLOCK_TIME(6, 0) && gSaveContext.time < CLOCK_TIME(21, 30))) { Actor_MarkForDeath(&this->actor); return; } @@ -250,7 +251,9 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { return; } - if ((globalCtx->sceneNum == SCENE_MILK_BAR && !(gSaveContext.time >= 0x4000 && gSaveContext.time < 0xED02)) || + //! @TODO: 0xED02 nor 0xED01 match CLOCK_TIME macro + if ((globalCtx->sceneNum == SCENE_MILK_BAR && + !(gSaveContext.time >= CLOCK_TIME(6, 0) && gSaveContext.time < 0xED02)) || (globalCtx->sceneNum != SCENE_MILK_BAR && func_80BA397C(this, 0x2000))) { if (this->unk2B6 != 0) { this->text = D_80BA5044; @@ -503,7 +506,6 @@ s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnTotoUnkStruct2* temp_s0; s32 i; - u16 tmp; func_80BA3C88(this); if (player->actor.world.pos.z > -270.0f) { @@ -527,8 +529,8 @@ s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { if (this->unk2B1 < 10) { this->unk2B1++; if (this->unk2B1 >= 10) { - tmp = gSaveContext.playerForm; // Needed for regalloc possible FAKE MATCH - Message_StartTextbox(globalCtx, D_80BA50DC[tmp - 1].unk2, NULL); + Message_StartTextbox(globalCtx, D_80BA50DC[((void)0, gSaveContext.playerForm) - 1].unk2, + NULL); } } return 0; diff --git a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c index f17a6a80f..9560ea842 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -904,7 +904,7 @@ void EnTrt2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V } } -void EnTrt2_UnkDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnTrt2_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnTrt2* this = THIS; if (limbIndex == 21) { @@ -934,7 +934,7 @@ void func_80AD56E8(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTrt2_OverrideLimbDraw, EnTrt2_PostLimbDraw, - EnTrt2_UnkDraw, &this->actor); + EnTrt2_TransformLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index 7a4a22170..31f87f603 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -722,7 +722,7 @@ s32 func_80A87400(EnTru* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.speedXZ, 30.0f, 0.2f, 1000.0f); if (this->path != NULL) { - sp4C = (Vec3s*)Lib_SegmentedToVirtual(this->path->points); + sp4C = Lib_SegmentedToVirtual(this->path->points); if (func_8013BD40(&this->actor, this->path, this->unk_384)) { if (this->unk_384 > this->unk_384 + 1) { this->unk_384 = this->path->count - 2; diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index 3334164bc..7e025ce43 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -452,7 +452,8 @@ void func_809674C8(EnWeatherTag* this, GlobalContext* globalCtx) { if (Actor_XZDistanceBetweenActors(&player->actor, &this->actor) < WEATHER_TAG_RANGE100(this)) { if (CURRENT_DAY == 2) { - if ((gSaveContext.time >= 0x4AAA) && (gSaveContext.time < 0xBAAA) && (globalCtx->envCtx.unk_F2[2] == 0)) { + if ((gSaveContext.time >= CLOCK_TIME(7, 0)) && (gSaveContext.time < CLOCK_TIME(17, 30)) && + (globalCtx->envCtx.unk_F2[2] == 0)) { D_801BDBB0 = 1; func_800FD78C(globalCtx); diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index 18f5f13e3..08a49d891 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -67,7 +67,7 @@ void func_80B965D0(EnZot* this, GlobalContext* globalCtx) { s32 i; if ((this->path != NULL) && (this->path->count >= 5)) { - Vec3s* points = (Vec3s*)Lib_SegmentedToVirtual(this->path->points); + Vec3s* points = Lib_SegmentedToVirtual(this->path->points); for (i = 0; i < ARRAY_COUNT(this->unk_2D8); i++, points++) { if (this->unk_2D8[i] == NULL) { @@ -520,20 +520,21 @@ void func_80B975F8(EnZot* this, GlobalContext* globalCtx) { } void func_80B9765C(EnZot* this, GlobalContext* globalCtx) { - if (1) { - do { } while (0); } - func_80B96D4C(this); if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - u16 temp = globalCtx->msgCtx.unk11F04; - u32 temp2; + s32 requiredScopeTemp; - if ((temp == 0x1262) || (temp == 0x1267) || (temp == 0x126A) || (temp == 0x126B)) { - temp2 = temp; - func_80151938(globalCtx, temp2 + 1); - } else { - func_801477B4(globalCtx); - this->actionFunc = func_80B97708; + switch (globalCtx->msgCtx.unk11F04) { + case 0x1262: + case 0x1267: + case 0x126A: + case 0x126B: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + default: + func_801477B4(globalCtx); + this->actionFunc = func_80B97708; + break; } } } diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c index d61b3f771..467a81de0 100644 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c @@ -147,8 +147,8 @@ s32 func_80936D58(ObjBean* this, GlobalContext* globalCtx) { Math_Vec3f_Sum(&this->dyna.actor.world.pos, &spAC, &spA0); Math_Vec3f_Diff(&this->dyna.actor.world.pos, &spAC, &sp94); - if (BgCheck_EntityLineTest2(&globalCtx->colCtx, &spA0, &sp94, &sp88, &this->dyna.actor.floorPoly, 1, 1, 1, 1, &spB8, - &this->dyna.actor)) { + if (BgCheck_EntityLineTest2(&globalCtx->colCtx, &spA0, &sp94, &sp88, &this->dyna.actor.floorPoly, true, true, true, + true, &spB8, &this->dyna.actor)) { this->dyna.actor.world.pos.x = (COLPOLY_GET_NORMAL(this->dyna.actor.floorPoly->normal.x) * 1.9f) + sp88.x; this->dyna.actor.world.pos.y = (COLPOLY_GET_NORMAL(this->dyna.actor.floorPoly->normal.y) * 1.9f) + sp88.y; this->dyna.actor.world.pos.z = (COLPOLY_GET_NORMAL(this->dyna.actor.floorPoly->normal.z) * 1.9f) + sp88.z; diff --git a/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c b/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c index 0de07e013..5109cf284 100644 --- a/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c +++ b/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c @@ -44,7 +44,7 @@ void ObjEnding_Init(Actor* thisx, GlobalContext* globalCtx) { this->modelInfo = &sModelInfo[thisx->params]; animMat = this->modelInfo->animMat; if (animMat != NULL) { - this->animMat = (AnimatedMaterial*)Lib_SegmentedToVirtual(animMat); + this->animMat = Lib_SegmentedToVirtual(animMat); } } diff --git a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c index c06543f07..1ce6faa7d 100644 --- a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c +++ b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c @@ -37,14 +37,14 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 180, ICHAIN_STOP), }; -static Vec3f iceSmokeAccel = { 0.0f, 0.0f, 0.0f }; +static Vec3f sIceSmokeAccel = { 0.0f, 0.0f, 0.0f }; void ObjHsStump_Init(Actor* thisx, GlobalContext* globalCtx) { ObjHsStump* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); this->isHidden = OBJHSSTUMP_GET_ISHIDDEN(thisx); - this->switchFlag = OBJHSSTUMP_GET_SWITCHFLAG(thisx); // Must be thisx to match + this->switchFlag = OBJHSSTUMP_GET_SWITCHFLAG(thisx); DynaPolyActor_Init(&this->dyna, 1); DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_hsstump_Colheader_0011B0); switch (this->isHidden) { @@ -87,43 +87,43 @@ void ObjHsStump_Appear(ObjHsStump* this, GlobalContext* globalCtx) { this->dyna.actor.shape.rot.z = (Math_SinS(this->rotAngle * 2) * this->rotFactor) + this->dyna.actor.home.rot.z; this->rotAngle += 0x2000; } - if (this->framesAppeared < 11) { + if (this->framesAppeared <= 10) { if (this->framesAppeared == 0) { s32 i; - f32 angle; + f32 angleDeg; s16 numDirections = 4; Vec3f iceSmokePosOffset; Vec3f iceSmokeVelOffset; s16 offsetAngle; Vec3f iceSmokeVel; - f32 angleBinary; + f32 angleBrad; Vec3f iceSmokePos; iceSmokePosOffset.x = 1.0f; iceSmokePosOffset.y = 0.5f; iceSmokePosOffset.z = 0.0f; + iceSmokeVelOffset.x = 1.0f; iceSmokeVelOffset.y = 0.5f; iceSmokeVelOffset.z = 0.0f; - angle = 360.0f / numDirections; - i = angle * (0x10000 / 360.0f); - angleBinary = i; + angleDeg = (360.0f / numDirections); + angleBrad = (s32)(angleDeg * (0x10000 / 360.0f)); for (i = 0; i < numDirections; i++) { - offsetAngle = i * angleBinary; + offsetAngle = i * angleBrad; Lib_Vec3f_TranslateAndRotateY(&this->dyna.actor.world.pos, offsetAngle, &iceSmokePosOffset, &iceSmokePos); Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, offsetAngle, &iceSmokeVelOffset, &iceSmokeVel); - EffectSsIceSmoke_Spawn(globalCtx, &iceSmokePos, &iceSmokeVel, &iceSmokeAccel, 100); + EffectSsIceSmoke_Spawn(globalCtx, &iceSmokePos, &iceSmokeVel, &sIceSmokeAccel, 100); } } } if (this->framesAppeared >= 10) { - Math_SmoothStepToF(&this->dyna.actor.scale.x, 0.17999999f, 1.0f, 0.01f, 0.001f); + Math_SmoothStepToF(&this->dyna.actor.scale.x, 18.0f * 0.01f, 1.0f, 0.01f, 0.001f); Actor_SetScale(&this->dyna.actor, this->dyna.actor.scale.x); } - if (this->dyna.actor.scale.x == 0.17999999f) { + if (this->dyna.actor.scale.x == 18.0f * 0.01f) { this->isHidden = false; func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); ObjHsStump_SetupIdle(this, globalCtx); diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c index 627338400..28de274f5 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -460,7 +460,7 @@ s32 func_80A24118(ObjIceblock* this, GlobalContext* globalCtx, f32 arg2, Vec3f* spD0.y = spDC.y; spD0.z = temp_f26 + spDC.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spDC, &spD0, &spB8, &spA8, 1, 0, 0, 1, &spAC, + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spDC, &spD0, &spB8, &spA8, true, false, false, true, &spAC, &this->dyna.actor, 0.0f)) { temp_f20 = Math3D_Vec3fDistSq(&spDC, &spB8); if (temp_f20 < phi_f20) { @@ -536,7 +536,7 @@ s32 func_80A243E0(ObjIceblock* this, GlobalContext* globalCtx, Vec3f* arg0) { spE0.y = spEC.y; spE0.z = temp_f30 + spEC.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spEC, &spE0, &spC8, &spB8, 1, 0, 0, 1, &spBC, + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spEC, &spE0, &spC8, &spB8, true, false, false, true, &spBC, &this->dyna.actor, 0.0f)) { temp_f12 = Math3D_Vec3fDistSq(&spEC, &spC8); if (temp_f12 < phi_f22) { @@ -600,7 +600,7 @@ s32 func_80A246D8(ObjIceblock* this, GlobalContext* globalCtx, Vec3f* arg2) { spB4.y = spC0.y; spB4.z = (Math_CosS(phi_s3) * temp_f20) + spC0.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spC0, &spB4, &sp9C, &sp94, 1, 0, 0, 1, &sp98, + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spC0, &spB4, &sp9C, &sp94, true, false, false, true, &sp98, &this->dyna.actor, 0.0f)) { ret = true; temp_v0 = (ObjIceblock*)DynaPoly_GetActor(&globalCtx->colCtx, sp98); diff --git a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c index 6d06195d1..81090139b 100644 --- a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c +++ b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c @@ -16,8 +16,6 @@ void ObjMilkBin_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjMilkBin_Update(Actor* thisx, GlobalContext* globalCtx); void ObjMilkBin_Draw(Actor* thisx, GlobalContext* globalCtx); -// gMilkBinMilkJarDL - const ActorInit Obj_Milk_Bin_InitVars = { ACTOR_OBJ_MILK_BIN, ACTORCAT_PROP, diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c index 2d1149715..359d474f1 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -345,8 +345,8 @@ s32 ObjOshihiki_CheckWall(GlobalContext* globalCtx, s16 angle, f32 direction, Ob faceVtxNext.y = faceVtx.y; faceVtxNext.z = (maxDist * cs) + faceVtx.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &faceVtx, &faceVtxNext, &posResult, &outPoly, 1, 0, 0, 1, &bgId, - &this->dyna.actor, 0.0f)) { + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &faceVtx, &faceVtxNext, &posResult, &outPoly, true, false, + false, true, &bgId, &this->dyna.actor, 0.0f)) { return true; } } diff --git a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c index 0acdf1bca..24f3fe0d6 100644 --- a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c +++ b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c @@ -89,7 +89,7 @@ void ObjRaillift_Init(Actor* thisx, GlobalContext* globalCtx) { this->curPoint = OBJRAILLIFT_GET_STARTING_POINT(thisx); this->endPoint = path->count - 1; this->direction = 1; - this->points = (Vec3s*)Lib_SegmentedToVirtual(path->points); + this->points = Lib_SegmentedToVirtual(path->points); ObjRaillift_UpdatePosition(this, this->curPoint); if (OBJRAILLIFT_HAS_FLAG(thisx) && !Flags_GetSwitch(globalCtx, OBJRAILLIFT_GET_FLAG(thisx))) { this->actionFunc = ObjRaillift_Idle; diff --git a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c index 70bb72454..91bc39495 100644 --- a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c +++ b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c @@ -38,7 +38,7 @@ void ObjYado_Init(Actor* thisx, GlobalContext* globalCtx) { ObjYado* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - D_80C16470 = (AnimatedMaterial*)Lib_SegmentedToVirtual(object_yado_obj_Matanimheader_0012E8); + D_80C16470 = Lib_SegmentedToVirtual(object_yado_obj_Matanimheader_0012E8); this->isNight = gSaveContext.isNight; } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 672d67bec..ddb79ea4f 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -12208,7 +12208,7 @@ 0x80AD5394:("func_80AD5394",), 0x80AD54C8:("EnTrt2_OverrideLimbDraw",), 0x80AD5584:("EnTrt2_PostLimbDraw",), - 0x80AD566C:("EnTrt2_UnkDraw",), + 0x80AD566C:("EnTrt2_TransformLimbDraw",), 0x80AD56E8:("func_80AD56E8",), 0x80AD5BB0:("ObjTokeiStep_SetSysMatrix",), 0x80AD5BE8:("ObjTokeiStep_AddQuake",), @@ -15505,7 +15505,7 @@ 0x80BC24C4:("EnJa_Update",), 0x80BC25E0:("EnJa_OverrideLimbDraw",), 0x80BC2620:("EnJa_PostLimbDraw",), - 0x80BC2B30:("EnJa_TransformDraw",), + 0x80BC2B30:("EnJa_TransformLimbDraw",), 0x80BC2CE4:("EnJa_Draw",), 0x80BC2EA4:("func_80BC2EA4",), 0x80BC3154:("func_80BC3154",), @@ -16317,7 +16317,7 @@ 0x80BF2E04:("EnIg_Update",), 0x80BF2EDC:("EnIg_OverrideLimbDraw",), 0x80BF2EFC:("EnIg_PostLimbDraw",), - 0x80BF302C:("EnIg_UnkDraw",), + 0x80BF302C:("EnIg_TransformLimbDraw",), 0x80BF312C:("EnIg_Draw",), 0x80BF3920:("func_80BF3920",), 0x80BF3C64:("func_80BF3C64",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 81c46cfc6..902dfb17d 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1258,10 +1258,6 @@ D_0600D640 = 0x0600D640; D_06002950 = 0x06002950; -// ovl_En_Dno - -D_801C20C0 = 0x801C20C0; - // ovl_En_Dragon D_06004398 = 0x06004398; @@ -1358,10 +1354,6 @@ D_0600A344 = 0x0600A344; D_06001EFC = 0x06001EFC; D_0600A808 = 0x0600A808; -// ovl_En_Goron_Oyu - -D_06000988 = 0x06000988; - // ovl_En_Grasshopper D_06000F9C = 0x06000F9C; From 26d71ffbf651f71312bc50f42ee369a515f21714 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 5 Mar 2022 15:09:23 +0000 Subject: [PATCH 071/257] En_Prz (#656) * En_Prz * PR Co-authored-by: Anghelo Carvajal --- spec | 3 +- src/overlays/actors/ovl_En_Prz/z_en_prz.c | 472 ++++++++++++++++++++-- src/overlays/actors/ovl_En_Prz/z_en_prz.h | 32 +- undefined_syms.txt | 3 +- 4 files changed, 475 insertions(+), 35 deletions(-) diff --git a/spec b/spec index cb017e135..d374bb86d 100644 --- a/spec +++ b/spec @@ -3124,8 +3124,7 @@ beginseg name "ovl_En_Prz" compress include "build/src/overlays/actors/ovl_En_Prz/z_en_prz.o" - include "build/data/ovl_En_Prz/ovl_En_Prz.data.o" - include "build/data/ovl_En_Prz/ovl_En_Prz.reloc.o" + include "build/src/overlays/actors/ovl_En_Prz/ovl_En_Prz_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.c b/src/overlays/actors/ovl_En_Prz/z_en_prz.c index f89204a15..2a86294dc 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.c +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.c @@ -5,6 +5,8 @@ */ #include "z_en_prz.h" +#include "objects/object_pr/object_pr.h" +#include "overlays/actors/ovl_En_Pr/z_en_pr.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) @@ -15,9 +17,15 @@ void EnPrz_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnPrz_Update(Actor* thisx, GlobalContext* globalCtx); void EnPrz_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 -// static DamageTable sDamageTable = { -static DamageTable D_80A771C0 = { +void func_80A76388(EnPrz* this); +void func_80A763E8(EnPrz* this, GlobalContext* globalCtx); +void func_80A76604(EnPrz* this, GlobalContext* globalCtx); +void func_80A76634(EnPrz* this, GlobalContext* globalCtx); +void func_80A76748(EnPrz* this); +void func_80A767A8(EnPrz* this, GlobalContext* globalCtx); +void func_80A76B14(EnPrz* this, GlobalContext* globalCtx); + +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -52,10 +60,25 @@ static DamageTable D_80A771C0 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A771F4 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK4, { 0x20000000, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +f32 D_80A771E0[] = { 40.0f, 40.0f, 40.0f, 30.0f, 30.0f }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK4, + { 0x20000000, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 10, 10, 0, { 0, 0, 0 } }, }; @@ -71,45 +94,436 @@ const ActorInit En_Prz_InitVars = { (ActorFunc)EnPrz_Draw, }; -#endif +AnimationHeader* D_80A77240[] = { &object_pr_Anim_004340, &object_pr_Anim_004274 }; -extern DamageTable D_80A771C0; -extern ColliderCylinderInit D_80A771F4; +u8 D_80A77248[] = { 0, 0 }; -extern UNK_TYPE D_06004340; +Vec3f D_80A7724C = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/EnPrz_Init.s") +void EnPrz_Init(Actor* thisx, GlobalContext* globalCtx) { + EnPrz* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/EnPrz_Destroy.s") + this->unk_20C = 0.01f; + this->unk_1E4 = this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A75F18.s") + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A75FA4.s") + this->actor.targetMode = 3; + this->unk_1E8 = 255; + this->actor.hintId = 0x5B; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.colChkInfo.health = 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76070.s") + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_pr_Skel_004188, &object_pr_Anim_004340, this->jointTable, + this->morphTable, 5); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A762C0.s") + this->unk_1E6 = ENPRZ_GET(&this->actor); + this->actor.shape.yOffset = 500.0f; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76388.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Math_Vec3f_Copy(&this->unk_1D8, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A763E8.s") + this->unk_220 = &this->actor; + this->unk_1EC = 255; + this->unk_202 = randPlusMinusPoint5Scaled((this->unk_1E6 * 100.0f) + 1000.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76604.s") + func_80A76388(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76634.s") +void EnPrz_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76748.s") +void func_80A75F18(EnPrz* this, s32 arg1) { + this->unk_204 = arg1; + Animation_Change(&this->skelAnime, D_80A77240[arg1], 1.0f, 0.0f, Animation_GetLastFrame(D_80A77240[arg1]), + D_80A77248[arg1], -2.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A767A8.s") +s32 func_80A75FA4(EnPrz* this, GlobalContext* globalCtx) { + WaterBox* sp2C; + f32 temp_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76A1C.s") + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_210, &sp2C)) { + temp_f0 = BREG(10) + (this->unk_210 - 10.0f); + if (temp_f0 < this->actor.world.pos.y) { + this->unk_1D8.y = temp_f0; + return 1; + } + } else { + temp_f0 = this->actor.floorHeight + 35.0f; + if (this->actor.world.pos.y < temp_f0) { + this->unk_1D8.y = temp_f0; + return 2; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76B14.s") + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/EnPrz_Update.s") +void func_80A76070(EnPrz* this, s16 arg1, GlobalContext* globalCtx) { + s16 temp_s0 = arg1 - this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76F70.s") + temp_s0 *= 0.01f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76FCC.s") + if (temp_s0 > 100) { + temp_s0 = 100; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/EnPrz_Draw.s") + if (temp_s0 < -100) { + temp_s0 = -100; + } + + if (fabsf(this->actor.world.rot.y - (f32)arg1) < (randPlusMinusPoint5Scaled(20.0f) + 100.0f)) { + Math_ApproachZeroF(&this->unk_218, 0.5f, 20.0f); + } else { + Math_ApproachF(&this->unk_218, temp_s0, 0.5f, 5.0f); + } + + temp_s0 = fabsf(this->unk_218) * 0.1f; + if (temp_s0 < 2) { + temp_s0 = 2; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, arg1, temp_s0, this->unk_202 + 0x1388, 0); + func_80A75FA4(this, globalCtx); + Math_ApproachF(&this->actor.world.pos.y, this->unk_1D8.y, 0.5f, 1.0f); + temp_s0 = Math_Vec3f_Pitch(&this->actor.world.pos, &this->unk_1D8) * 0.5f; + + if (fabsf(this->actor.world.pos.y - this->unk_208) > 4.0f) { + Math_SmoothStepToS(&this->actor.world.rot.x, temp_s0, 1, BREG(48) + 0x1F4, 0); + } else { + Math_SmoothStepToS(&this->actor.world.rot.x, 0, 1, BREG(52) + 0xBB8, 0); + } +} + +s32 func_80A762C0(EnPrz* this, GlobalContext* globalCtx) { + CollisionPoly* sp54; + Vec3f sp48; + s32 sp44; + Vec3f sp38; + + Math_Vec3f_Copy(&sp38, &this->actor.world.pos); + + sp38.x += Math_SinS(this->actor.world.rot.y) * 40.0f; + sp38.z += Math_CosS(this->actor.world.rot.y) * 40.0f; + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp38, &sp48, &sp54, true, false, false, + true, &sp44)) { + return true; + } + return false; +} + +void func_80A76388(EnPrz* this) { + this->actor.speedXZ = randPlusMinusPoint5Scaled(1.0f) + 4.0f; + func_80A75F18(this, 0); + this->unk_1EA = 1; + this->actionFunc = func_80A763E8; +} + +void func_80A763E8(EnPrz* this, GlobalContext* globalCtx) { + Actor* sp3C = this->actor.parent; + Player* player = GET_PLAYER(globalCtx); + s16 yaw; + s32 pad; + + if (&this->actor == this->unk_220) { + return; + } + + if ((player->stateFlags1 & 0x8000000) && (this->unk_1F2 == 0)) { + func_80A76748(this); + return; + } + + if (func_80A762C0(this, globalCtx)) { + func_80A76604(this, globalCtx); + return; + } + + if ((this->unk_220 != NULL) && (this->unk_220->update == NULL)) { + this->unk_220 = this->actor.parent; + } + + if ((this->unk_1EE == 0) && (this->unk_1F2 == 0)) { + s16 rot; + + this->unk_214 = randPlusMinusPoint5Scaled(40.0f); + + rot = BINANG_ROT180(this->unk_220->world.rot.y); + this->unk_1D8.x += Math_SinS(rot) * this->unk_214; + this->unk_1D8.y = randPlusMinusPoint5Scaled(40.0f) + (this->unk_220->world.pos.y + 40.0f); + rot = BINANG_ROT180(this->unk_220->world.rot.y); + this->unk_1D8.z += Math_CosS(rot) * this->unk_214; + + this->unk_1EE = Rand_S16Offset(20, 30); + } else if (sqrtf(SQ(this->actor.world.pos.x - sp3C->world.pos.x) + + SQ(this->actor.world.pos.z - sp3C->world.pos.z)) > 100.0f) { + Math_Vec3f_Copy(&this->unk_1D8, &sp3C->world.pos); + } + + if (1) {} + + if ((Rand_ZeroOne() < 0.1f) && (this->unk_1C8 == 0)) { + this->unk_1C8 = 1; + } + + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_1D8); + func_80A76070(this, yaw, globalCtx); +} + +void func_80A76604(EnPrz* this, GlobalContext* globalCtx) { + this->unk_1EE = 0; + this->unk_1E4 = BINANG_ADD(this->actor.world.rot.y, 0x4000); + this->unk_1EA = 2; + this->actionFunc = func_80A76634; +} + +void func_80A76634(EnPrz* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + func_80A76070(this, this->unk_1E4, globalCtx); + + if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, this->unk_1E4)) < 0x100) { + if (func_80A762C0(this, globalCtx) != 0) { + this->unk_1E4 += 0x1500; + this->unk_1E4 += (s16)Rand_ZeroFloat(5000.0f); + } else if ((player->stateFlags1 & 0x8000000) && (player->actor.floorHeight < 30.0f)) { + this->actionFunc = func_80A763E8; + } else { + this->unk_1EE = 10; + this->unk_1EA = 1; + this->actionFunc = func_80A763E8; + } + } +} + +void func_80A76748(EnPrz* this) { + this->actor.speedXZ = randPlusMinusPoint5Scaled(1.0f) + 3.0f; + this->unk_1EE = 0; + this->unk_1EA = 3; + this->skelAnime.playSpeed = 2.0f; + this->actionFunc = func_80A767A8; +} + +void func_80A767A8(EnPrz* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnPr* pr = (EnPr*)this->actor.parent; + f32 sqrt; + s32 pad[2]; + u8 playerForm; + + if (func_80A762C0(this, globalCtx)) { + func_80A75F18(this, 0); + this->actor.speedXZ = randPlusMinusPoint5Scaled(1.0f) + 4.0f; + func_80A76604(this, globalCtx); + return; + } + + sqrt = sqrtf(SQ(player->actor.world.pos.x - this->actor.parent->home.pos.x) + + SQ(player->actor.world.pos.z - this->actor.parent->home.pos.z)); + + if (!(player->stateFlags1 & 0x8000000) || (pr->unk_2C8 < sqrt)) { + this->unk_1F2 = 100; + this->skelAnime.playSpeed = 1.0f; + func_80A76388(this); + return; + } + + if ((this->actor.xzDistToPlayer < 200.0f) && (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 80.0f)) { + if (this->unk_204 != 1) { + func_80A75F18(this, 1); + } + this->skelAnime.playSpeed = 1.0f; + } else { + if (this->unk_204 != 0) { + func_80A75F18(this, 0); + } + this->skelAnime.playSpeed = 2.0f; + } + + if (this->unk_1EE == 0) { + this->unk_1EE = Rand_S16Offset(2, 3); + Math_Vec3f_Copy(&this->unk_1D8, &player->actor.world.pos); + } + + if ((Rand_ZeroOne() < 0.1f) && (this->unk_1C8 == 0)) { + this->unk_1C8 = 1; + } + + playerForm = gSaveContext.playerForm; + this->unk_1D8.y = + (player->actor.world.pos.y + D_80A771E0[playerForm]) + randPlusMinusPoint5Scaled((2.0f * this->unk_1E6) + 1.0f); + func_80A76070(this, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_1D8), globalCtx); +} + +void func_80A76A1C(EnPrz* this) { + this->unk_1E8 = 0; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLEWALK_DEAD); + + this->unk_1EE = Rand_S16Offset(100, 30); + this->unk_1FC = 0x4000; + + if (Rand_ZeroOne() < 0.5f) { + this->unk_1FC = -0x4000; + } + + this->unk_1FE = this->actor.world.rot.y; + this->actor.speedXZ = Rand_ZeroFloat(0.5f); + this->actor.world.rot.y = randPlusMinusPoint5Scaled(0x8000); + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 30); + this->unk_1EE = 50; + func_80A75F18(this, 0); + this->unk_1EA = 7; + this->actionFunc = func_80A76B14; +} + +void func_80A76B14(EnPrz* this, GlobalContext* globalCtx) { + WaterBox* sp7C; + s32 i; + Vec3f sp6C; + s32 phi_s0 = false; + + Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 5, 0x2710, 0x3E8); + Math_SmoothStepToS(&this->actor.shape.rot.z, this->unk_1FC, 5, 0x2710, 0x3E8); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_1FE, 5, 0x2710, 0x3E8); + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_210, &sp7C)) { + if ((this->unk_210 - 15.0f) <= this->actor.world.pos.y) { + phi_s0 = true; + } else { + Math_ApproachF(&this->actor.world.pos.y, this->unk_210 - 14.0f, 0.3f, 1.0f); + } + } + + if ((this->unk_1EE == 0) || phi_s0) { + Math_SmoothStepToS(&this->unk_1EC, 0, 1, 15, 50); + + if (this->unk_1EC < 2) { + for (i = 0; i < 10; i++) { + Math_Vec3f_Copy(&sp6C, &this->actor.world.pos); + + sp6C.x += randPlusMinusPoint5Scaled(20.0f); + sp6C.y += randPlusMinusPoint5Scaled(5.0f); + sp6C.z += randPlusMinusPoint5Scaled(20.0f); + + EffectSsBubble_Spawn(globalCtx, &sp6C, 0.0f, 5.0f, 5.0f, Rand_ZeroFloat(0.03f) + 0.07f); + } + Actor_MarkForDeath(&this->actor); + } + } +} + +void EnPrz_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnPrz* this = THIS; + s32 sp44 = false; + Vec3f sp38; + + if (this->unk_1EA != 7) { + SkelAnime_Update(&this->skelAnime); + } + + this->actionFunc(this, globalCtx); + + if (this->unk_1EE != 0) { + this->unk_1EE--; + } + + if (this->unk_1F2 != 0) { + this->unk_1F2--; + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 10.0f, 10.0f, 0x1D); + + if (this->unk_1EA != 7) { + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + } + + if (this->unk_1EA != 7) { + if (this->collider.base.acFlags & AC_HIT) { + Actor_ApplyDamage(&this->actor); + if (this->actor.colChkInfo.health <= 0) { + sp44 = true; + } + } + + if (sp44 || (this->actor.parent == NULL) || (this->actor.parent->colChkInfo.health <= 0)) { + this->collider.base.acFlags &= ~AC_HIT; + if (this->unk_1EA != 7) { + func_80A76A1C(this); + return; + } + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->unk_1C8 != 0) { + Math_Vec3f_Copy(&sp38, &this->unk_1CC); + this->unk_1C8 = 0; + + sp38.x += randPlusMinusPoint5Scaled(20.0f); + sp38.y += randPlusMinusPoint5Scaled(5.0f); + sp38.z += randPlusMinusPoint5Scaled(20.0f); + + EffectSsBubble_Spawn(globalCtx, &sp38, 0.0f, 5.0f, 5.0f, Rand_ZeroFloat(0.03f) + 0.07f); + } + } +} + +s32 func_80A76F70(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnPrz* this = THIS; + + if (limbIndex == 2) { + rot->y += (s16)this->unk_218 * -100; + } + return false; +} + +void func_80A76FCC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + Vec3f sp1C = D_80A7724C; + EnPrz* this = THIS; + + if (limbIndex == 2) { + Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&sp1C, &this->unk_1CC); + } +} + +void EnPrz_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnPrz* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_1EC == 255) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->unk_1E8, this->unk_1E8, this->unk_1E8, this->unk_1EC); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->unk_1EC); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, func_80A76F70, func_80A76FCC, &this->actor); + } else { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_1EC); + + Scene_SetRenderModeXlu(globalCtx, 1, 2); + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, NULL, &this->actor, POLY_XLU_DISP); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.h b/src/overlays/actors/ovl_En_Prz/z_en_prz.h index a4e584090..28f8152a8 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.h +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.h @@ -7,13 +7,39 @@ struct EnPrz; typedef void (*EnPrzActionFunc)(struct EnPrz*, GlobalContext*); +#define ENPRZ_GET(thisx) ((thisx)->params & 0xFF) + typedef struct EnPrz { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x80]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[5]; + /* 0x01A6 */ Vec3s morphTable[5]; /* 0x01C4 */ EnPrzActionFunc actionFunc; - /* 0x01C8 */ char unk_1C8[0x58]; + /* 0x01C8 */ u8 unk_1C8; + /* 0x01CC */ Vec3f unk_1CC; + /* 0x01D8 */ Vec3f unk_1D8; + /* 0x01E4 */ s16 unk_1E4; + /* 0x01E6 */ s16 unk_1E6; + /* 0x01E8 */ s16 unk_1E8; + /* 0x01EA */ s16 unk_1EA; + /* 0x01EC */ s16 unk_1EC; + /* 0x01EE */ s16 unk_1EE; + /* 0x01F0 */ UNK_TYPE1 unk1F0[2]; + /* 0x01F2 */ s16 unk_1F2; + /* 0x01F4 */ UNK_TYPE1 unk1F4[8]; + /* 0x01FC */ s16 unk_1FC; + /* 0x01FE */ s16 unk_1FE; + /* 0x0200 */ UNK_TYPE1 unk200[2]; + /* 0x0202 */ s16 unk_202; + /* 0x0204 */ s32 unk_204; + /* 0x0208 */ f32 unk_208; + /* 0x020C */ f32 unk_20C; + /* 0x0210 */ f32 unk_210; + /* 0x0214 */ f32 unk_214; + /* 0x0218 */ f32 unk_218; + /* 0x021C */ UNK_TYPE1 unk21C[4]; /* 0x0220 */ Actor* unk_220; - /* 0x0224 */ char unk_224[0x4C]; + /* 0x0224 */ ColliderCylinder collider; } EnPrz; // size = 0x270 extern const ActorInit En_Prz_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 902dfb17d..80e88df48 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1678,8 +1678,9 @@ D_06009930 = 0x06009930; D_0600A844 = 0x0600A844; D_06012768 = 0x06012768; -// ovl_En_Prz +// ovl_En_Pr2 +D_06003904 = 0x06003904; D_06004188 = 0x06004188; D_06004340 = 0x06004340; From 10a1ef8f1dd885835101ee99b537c23127096d82 Mon Sep 17 00:00:00 2001 From: Parker Burnett Date: Sat, 5 Mar 2022 10:22:43 -0500 Subject: [PATCH 072/257] Bg_ingate OK (#643) * close, 2 functions left, both close * documenting what I can * fixing things * fixing * changing weekEventReg * master fix * ran actorfixer --- assets/xml/objects/object_sichitai_obj.xml | 8 +- spec | 3 +- .../actors/ovl_Bg_Ingate/z_bg_ingate.c | 366 +++++++++++++++++- .../actors/ovl_Bg_Ingate/z_bg_ingate.h | 20 +- tools/disasm/functions.txt | 2 +- undefined_syms.txt | 5 - 6 files changed, 367 insertions(+), 37 deletions(-) diff --git a/assets/xml/objects/object_sichitai_obj.xml b/assets/xml/objects/object_sichitai_obj.xml index f093778ab..d1179beab 100644 --- a/assets/xml/objects/object_sichitai_obj.xml +++ b/assets/xml/objects/object_sichitai_obj.xml @@ -1,9 +1,9 @@  - - - - + + + + diff --git a/spec b/spec index d374bb86d..0a7bbcb92 100644 --- a/spec +++ b/spec @@ -1624,8 +1624,7 @@ beginseg name "ovl_Bg_Ingate" compress include "build/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.o" - include "build/data/ovl_Bg_Ingate/ovl_Bg_Ingate.data.o" - include "build/data/ovl_Bg_Ingate/ovl_Bg_Ingate.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ingate/ovl_Bg_Ingate_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index d120c451e..c7e39eec6 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -5,6 +5,7 @@ */ #include "z_bg_ingate.h" +#include "objects/object_sichitai_obj/object_sichitai_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +16,16 @@ void BgIngate_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgIngate_Update(Actor* thisx, GlobalContext* globalCtx); void BgIngate_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +Actor* BgIngate_FindActor(BgIngate* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId); +s32 func_80953BEC(BgIngate* this); +void func_80953B40(BgIngate* this); +void func_80953F8C(BgIngate* this, GlobalContext* globalCtx); +void func_80953F9C(BgIngate* this, GlobalContext* globalCtx); +void func_809541B8(BgIngate* this, GlobalContext* globalCtx); +void func_809542A0(BgIngate* this, GlobalContext* globalCtx); +void func_80954340(BgIngate* this, GlobalContext* globalCtx); +void func_809543D4(BgIngate* this, GlobalContext* globalCtx); + const ActorInit Bg_Ingate_InitVars = { ACTOR_BG_INGATE, ACTORCAT_BG, @@ -28,41 +38,355 @@ const ActorInit Bg_Ingate_InitVars = { (ActorFunc)BgIngate_Draw, }; -#endif +/** + * @brief Searches for an actor based on the parameters given to the function. Returns Actor* of actor found or NULL + * + * @param this + * @param globalCtx + * @param actorCat - Category of Actor + * @param actorId - ID of actor to search for + * @return Actor* + */ +Actor* BgIngate_FindActor(BgIngate* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { + Actor* foundActor = NULL; + Actor* tempActor; -extern UNK_TYPE D_060006B0; -extern UNK_TYPE D_060016DC; + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, actorCat, actorId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953A90.s") + if ((foundActor == NULL) || (((this != (BgIngate*)foundActor)) && (foundActor->update != NULL))) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953B40.s") + tempActor = foundActor->next; + if (tempActor == NULL) { + foundActor = NULL; + break; + } + foundActor = tempActor; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953BEC.s") + return foundActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953DA8.s") +void func_80953B40(BgIngate* this) { + s32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953E38.s") + if (!(gSaveContext.eventInf[3] & 0x20)) { + this->unk180 = 0xFA0; + this->unk168 = 4; + } else { + this->unk180 = 0x7D0; + this->unk168 = 1; + } + temp = this->unk164->count - 2; + this->unk184 = this->unk180 / temp; + this->unk188 = 2; + this->unk18C = 0; + this->unk160 &= ~0x1; + this->unk160 &= ~0x2; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953EA4.s") +s32 func_80953BEC(BgIngate* this) { + f32 sp74[265]; + Vec3f sp68; + Vec3f sp5C; + Vec3f unkVec; + s16 yaw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953F14.s") + func_8013AF00(sp74, 3, this->unk164->count + 3); + if (!(this->unk160 & 1)) { + unkVec = gZeroVec3f; + func_8013B6B0(this->unk164, &this->unk17C, &this->unk18C, this->unk184, this->unk180, &this->unk188, sp74, + &unkVec, this->unk168); + this->unk160 |= 1; + } else { + unkVec = this->unk170; + } + this->dyna.actor.world.pos.x = unkVec.x; + this->dyna.actor.world.pos.z = unkVec.z; + this->unk170 = gZeroVec3f; + if (func_8013B6B0(this->unk164, &this->unk17C, &this->unk18C, this->unk184, this->unk180, &this->unk188, sp74, + &this->unk170, this->unk168) != 0) { + this->unk160 |= 2; + } else { + sp68 = this->dyna.actor.world.pos; + sp5C = this->unk170; + yaw = Math_Vec3f_Yaw(&sp68, &sp5C); + this->dyna.actor.world.rot.y = yaw; + this->dyna.actor.shape.rot.y = yaw; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953F8C.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953F9C.s") +s32 func_80953DA8(BgIngate* this, GlobalContext* globalCtx) { + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_809541B8.s") + if (gSaveContext.eventInf[3] & 0x20) { + func_800B7298(globalCtx, &this->dyna.actor, 7); + } else { + gSaveContext.eventInf[4] |= 2; + } + func_800DFAC8(camera, 47); + globalCtx->unk_1887C = 0x63; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_809542A0.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80954340.s") +void func_80953E38(GlobalContext* globalCtx) { + func_800DFAC8(Play_GetCamera(globalCtx, CAM_ID_MAIN), 1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_809543D4.s") + if (!(gSaveContext.eventInf[3] & 0x20)) { + gSaveContext.eventInf[4] &= (u8)~2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/BgIngate_Init.s") + globalCtx->unk_1887C = -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/BgIngate_Destroy.s") +void func_80953EA4(BgIngate* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/BgIngate_Update.s") + func_800B7298(globalCtx, &this->dyna.actor, 0x3A); + player->unk_3A0.x = this->dyna.actor.world.pos.x; + player->unk_3A0.z = this->dyna.actor.world.pos.z; + this->unk160 &= ~0x4; + this->unk16A = 0x1E; + this->actionFunc = func_80954340; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/BgIngate_Draw.s") +void func_80953F14(BgIngate* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.shape.rot.y = this->dyna.actor.shape.rot.y; + player->actor.world.rot.y = player->actor.shape.rot.y; + player->currentYaw = player->actor.shape.rot.y; + player->actor.focus.rot.y = player->actor.shape.rot.y; + this->unk160 |= 0x10; + func_80953DA8(this, globalCtx); + if (this->unk164 != 0) { + func_80953B40(this); + } + this->unk16E = -1; + this->actionFunc = func_80953F9C; +} + +void func_80953F8C(BgIngate* this, GlobalContext* globalCtx) { +} + +void func_80953F9C(BgIngate* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + + if (!(gSaveContext.eventInf[4] & 1)) { + + if (!(gSaveContext.eventInf[3] & 0x20) && (this->unk160 & 0x10) && (this->unk16C == 0)) { + this->dyna.actor.textId = 0x9E3; + Message_StartTextbox(globalCtx, this->dyna.actor.textId, NULL); + this->unk160 &= ~0x10; + } + + if (this->unk160 & 2) { + + if (this->unk164->unk1 != 0xFF) { + func_80953E38(globalCtx); + func_800B7298(globalCtx, &this->dyna.actor, 7); + this->dyna.actor.textId = 0x9E4; + Message_StartTextbox(globalCtx, this->dyna.actor.textId, NULL); + this->unk16C += 1; + gSaveContext.weekEventReg[90] |= 0x40; + this->actionFunc = func_809543D4; + } else { + + if (!(gSaveContext.eventInf[3] & 0x20)) { + gSaveContext.eventInf[4] &= (u8)~2; + } else { + gSaveContext.eventInf[4] |= 1; + } + this->actionFunc = func_809542A0; + } + } else if ((ActorCutscene_GetCurrentIndex() == -1) && (this->unk164 != NULL)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CRUISER - SFX_FLAG); + func_80953BEC(this); + } + } + if (ActorCutscene_GetCurrentIndex() != this->unk16E) { + if (ActorCutscene_GetCurrentIndex() != -1) { + func_800DFAC8(camera, 1); + player->stateFlags1 |= 0x20; + globalCtx->actorCtx.unk5 &= ~0x4; + } else { + func_800DFAC8(camera, 47); + player->stateFlags1 &= ~0x20; + } + } + this->unk16E = ActorCutscene_GetCurrentIndex(); +} + +void func_809541B8(BgIngate* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk160 & 0x4) { + if ((player->transformation == PLAYER_FORM_HUMAN) && (player->actor.bgCheckFlags & 1) && + (this->dyna.actor.xzDistToPlayer < 40.0f)) { + if (this->dyna.actor.playerHeightRel > 15.0f) { + func_800B7298(globalCtx, &this->dyna.actor, 7); + this->dyna.actor.textId = 0x9E6; + Message_StartTextbox(globalCtx, this->dyna.actor.textId, NULL); + this->actionFunc = func_809543D4; + } + } + } else if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + this->unk160 |= 4; + } +} + +void func_809542A0(BgIngate* this, GlobalContext* globalCtx) { + if (gSaveContext.eventInf[5] & 1) { + globalCtx->nextEntranceIndex = 0xA820; + gSaveContext.eventInf[5] &= (u8)~1; + } else { + globalCtx->nextEntranceIndex = 0xA810; + } + gSaveContext.nextCutsceneIndex = 0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 3; + this->actionFunc = func_80953F8C; + gSaveContext.weekEventReg[90] &= (u8)~0x40; + func_800FE498(); +} + +void func_80954340(BgIngate* this, GlobalContext* globalCtx) { + if (!DECR(this->unk16A)) { + if (this->unk164 != 0) { + func_800B7298(globalCtx, &this->dyna.actor, 6); + this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; + func_80953F14(this, globalCtx); + func_800FE484(); + } + } +} + +void func_809543D4(BgIngate* this, GlobalContext* globalCtx) { + u8 talkState = Message_GetState(&globalCtx->msgCtx); + + if (((talkState == 4) || (talkState == 5)) && func_80147624(globalCtx)) { + switch (this->dyna.actor.textId) { + case 0x9E4: + this->dyna.actor.textId = 0x9E5; + func_80151938(globalCtx, this->dyna.actor.textId); + break; + case 0x9E5: + if (globalCtx->msgCtx.choiceIndex == 0) { + func_800B7298(globalCtx, &this->dyna.actor, 6); + this->unk160 &= ~0x4; + this->actionFunc = func_809541B8; + func_800FE498(); + func_8019F208(); + } else { + if (this->unk164 != 0) { + this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; + } + func_80953F14(this, globalCtx); + gSaveContext.weekEventReg[90] &= (u8)~0x40; + func_8019F230(); + } + func_801477B4(globalCtx); + break; + case 0x9E6: + if (globalCtx->msgCtx.choiceIndex == 0) { + func_80953EA4(this, globalCtx); + gSaveContext.weekEventReg[90] &= (u8)~0x40; + func_8019F208(); + } else { + this = this; + func_800B7298(globalCtx, &this->dyna.actor, 6); + this->unk160 &= ~0x4; + this->actionFunc = func_809541B8; + func_800FE498(); + func_8019F230(); + } + func_801477B4(globalCtx); + break; + } + } +} + +void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BgIngate* this = THIS; + s32 phi_a2; + Vec3s* sp38; + Vec3f sp2C; + Vec3f sp20; + + if (BgIngate_FindActor(this, globalCtx, ACTORCAT_BG, ACTOR_BG_INGATE) == NULL) { + DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gSichitaiBoatCol); + this->unk160 = 0; + this->unk160 |= 0x8; + this->unk160 |= 0x10; + Actor_SetScale(&this->dyna.actor, 1.0f); + this->unk164 = func_8013BB34(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + this->dyna.actor.room = -1; + if (gSaveContext.weekEventReg[20] & 2) { + gSaveContext.weekEventReg[90] &= (u8)~0x40; + } + if (!(gSaveContext.eventInf[3] & 0x20) && (gSaveContext.weekEventReg[90] & 0x40)) { + phi_a2 = 1; + this->unk16C = 1; + this->actionFunc = func_809541B8; + } else { + phi_a2 = 0; + if (globalCtx->curSpawn == 6) { + func_80953F14(this, globalCtx); + if (gSaveContext.eventInf[3] & 0x20) { + func_80112AFC(globalCtx); + } else { + gSaveContext.eventInf[4] |= 2; + } + } else { + this->actionFunc = func_80953F8C; + } + } + this->unk164 = func_8013BB34(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); + if (this->unk164 != 0) { + sp38 = Lib_SegmentedToVirtual(this->unk164->points); + Math_Vec3s_ToVec3f(&sp2C, &sp38[0]); + Math_Vec3s_ToVec3f(&sp20, &sp38[1]); + this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&sp2C, &sp20); + this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; + this->dyna.actor.world.pos.x = sp2C.x; + this->dyna.actor.world.pos.y = -15.0f; + this->dyna.actor.world.pos.z = sp2C.z; + } + this->unk164 = func_8013BB34(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + } else { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void BgIngate_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIngate* this = THIS; + + if (this->unk160 & 8) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} + +void BgIngate_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIngate* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgIngate_Draw(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gSichitaiBoat); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h index 8daa69d91..08d062e6c 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h @@ -7,11 +7,23 @@ struct BgIngate; typedef void (*BgIngateActionFunc)(struct BgIngate*, GlobalContext*); +#define BGINGATE_GET_FF(thisx) ((thisx)->params & 0xFF) + typedef struct BgIngate { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgIngateActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x30]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgIngateActionFunc actionFunc; + /* 0x160 */ u16 unk160; + /* 0x164 */ Path* unk164; + /* 0x168 */ s16 unk168; + /* 0x16A */ s16 unk16A; + /* 0x16C */ s16 unk16C; + /* 0x16E */ s16 unk16E; + /* 0x170 */ Vec3f unk170; + /* 0x17C */ f32 unk17C; + /* 0x180 */ s32 unk180; + /* 0x184 */ s32 unk184; + /* 0x188 */ s32 unk188; + /* 0x18C */ s32 unk18C; } BgIngate; // size = 0x190 extern const ActorInit Bg_Ingate_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index ddb79ea4f..45a125dce 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -7655,7 +7655,7 @@ 0x8095376C:("func_8095376C",), 0x80953848:("func_80953848",), 0x80953888:("EnHs_Draw",), - 0x80953A90:("func_80953A90",), + 0x80953A90:("BgIngate_FindActor",), 0x80953B40:("func_80953B40",), 0x80953BEC:("func_80953BEC",), 0x80953DA8:("func_80953DA8",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 80e88df48..52517baa6 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -692,11 +692,6 @@ D_06012700 = 0x06012700; D_06012728 = 0x06012728; D_06012788 = 0x06012788; -// ovl_Bg_Ingate - -D_060006B0 = 0x060006B0; -D_060016DC = 0x060016DC; - // ovl_Bg_Keikoku_Saku D_06001640 = 0x06001640; From 4a18f3ca4df5727320efd28da4bb3fc9059a94ff Mon Sep 17 00:00:00 2001 From: Parker Burnett Date: Sat, 5 Mar 2022 10:45:49 -0500 Subject: [PATCH 073/257] En_shn OK (#638) * Building on Macs * Add Mac building documentation * Review * Update for new z64compress * Review * getting some matching done * gettting some more matches * actor fixer * almost OK * Shn OK * fixing data and warnings * finishing touches * forgot to update spec * dang comments not being formatted * this should fix things * fixing feedback and other fixes * fixing things * fixing things * addressing PR * format and minor fix * actorfixer * fixing actor * fixing enum * yay format Co-authored-by: Elliptic Ellipsis Co-authored-by: Anghelo Carvajal --- assets/xml/objects/object_shn.xml | 34 +- include/z64item.h | 1 + spec | 3 +- src/overlays/actors/ovl_En_Shn/z_en_shn.c | 414 ++++++++++++++++-- src/overlays/actors/ovl_En_Shn/z_en_shn.h | 35 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 8 +- tools/disasm/functions.txt | 10 +- undefined_syms.txt | 5 - 8 files changed, 449 insertions(+), 61 deletions(-) diff --git a/assets/xml/objects/object_shn.xml b/assets/xml/objects/object_shn.xml index b322641a9..1b94600ab 100644 --- a/assets/xml/objects/object_shn.xml +++ b/assets/xml/objects/object_shn.xml @@ -50,7 +50,7 @@ - + @@ -66,22 +66,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/include/z64item.h b/include/z64item.h index ebb2a617d..0eea19008 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -391,6 +391,7 @@ typedef enum { typedef enum { /* -1 */ EXCH_ITEM_MINUS1 = -1, // Unknown usage or function /* 0x00 */ EXCH_ITEM_NONE, + /* 0x13 */ EXCH_ITEM_13 = 0x13, /* 0x1E */ EXCH_ITEM_1E = 0x1E, // BOTTLE_MUSHROOM /* 0x2A */ EXCH_ITEM_2A = 0x2A, // MOON_TEAR? /* 0x2E */ EXCH_ITEM_2E = 0x2E diff --git a/spec b/spec index 0a7bbcb92..488852c5f 100644 --- a/spec +++ b/spec @@ -3657,8 +3657,7 @@ beginseg name "ovl_En_Shn" compress include "build/src/overlays/actors/ovl_En_Shn/z_en_shn.o" - include "build/data/ovl_En_Shn/ovl_En_Shn.data.o" - include "build/data/ovl_En_Shn/ovl_En_Shn.reloc.o" + include "build/src/overlays/actors/ovl_En_Shn/ovl_En_Shn_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.c b/src/overlays/actors/ovl_En_Shn/z_en_shn.c index c47c8fb67..6d886fad3 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.c +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.c @@ -2,6 +2,7 @@ * File: z_en_shn.c * Overlay: ovl_En_Shn * Description: Swamp Tourist Center Guide + * Shashin(Shn) ~ Photo */ #include "z_en_shn.h" @@ -14,11 +15,42 @@ void EnShn_Init(Actor* thisx, GlobalContext* globalCtx); void EnShn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnShn_Update(Actor* thisx, GlobalContext* globalCtx); void EnShn_Draw(Actor* thisx, GlobalContext* globalCtx); - void func_80AE69E8(EnShn* this, GlobalContext* globalCtx); void func_80AE6A64(EnShn* this, GlobalContext* globalCtx); +s32 func_80AE6704(EnShn* this, GlobalContext* globalCtx); + +// Could be something related to text/dialogue? +static UNK_TYPE D_80AE6F00[] = { + 0x00170800, 0x0B0E09C4, 0x0C0F09C5, 0x0C111708, 0x03018C04, 0x018E1901, 0x860F00FF, 0x1E001300, 0x00011501, + 0x47280012, 0x28001928, 0x002D2800, 0x5D280093, 0x28003319, 0x00472C09, 0xE70C2F00, 0x000C1210, 0x2C09CB0C, + 0x2F00000C, 0x0F09CC0C, 0x0F09CD0C, 0x0500A500, 0xCB00CB2C, 0x09D10C2F, 0x00000C0F, 0x09D20C19, 0xFFE62C09, + 0xD30C2F00, 0x000C0F09, 0xD40C0F09, 0xD50C0500, 0x9200B200, 0xB22C09D9, 0x0C2F0000, 0x0C0F09DA, 0x0C102C09, + 0xE80C2F00, 0x000C0F09, 0xE90C0F09, 0xEA0C0057, 0x04001712, 0x06000C00, 0x0013000C, 0x0C115704, 0x0700000E, + 0x09EB0C12, 0x16101206, 0x00060000, 0x1300060C, 0x07FFEC2C, 0x09EC0C2F, 0x00000C0F, 0x09ED0C0F, 0x09EE0C00, + 0x57040017, 0x1206000C, 0x00001300, 0x0C0C1157, 0x04070000, 0x0E09EF0C, 0x12161012, 0x06000600, 0x00130006, + 0x0C07FFEC, 0x12060004, 0x00001300, 0x040C0700, 0x000E09CE, 0x0C161012, 0x06000200, 0x00130002, 0x0C070000, + 0x0E09D80C, 0x16100C0F, 0x09CF0C1C, 0x05011509, 0x0000100E, 0x09D60C19, 0xFFF10037, 0x40001C2C, 0x09DB0C2F, + 0x00000C0F, 0x09DC0C0F, 0x09DD0C0F, 0x09DE0C0F, 0x09DF0C11, 0x3740102C, 0x09E00C2F, 0x00000C0F, 0x09E10C0F, + 0x09E20C10, 0x00374000, 0x180E09DB, 0x0C0F09DC, 0x0C0F09DD, 0x0C0F09DE, 0x0C0F09DF, 0x0C113740, 0x100E09E0, + 0x0C0F09E1, 0x0C0F09E2, 0x0C100E09, 0xC90C0F09, 0xCA0C100E, 0x09C60C10, 0x001402FF, 0xED0E09C8, 0x0C19FE69 +}; + +static UNK_TYPE D_80AE70B0[] = { 0x0E09D00C, 0x16100000 }; + +static UNK_TYPE D_80AE70B8[] = { + 0x28001228, 0x00152800, 0x28280055, 0x28008A28, 0x002D1900, 0x402C09E7, 0x0C12102C, 0x09CB2F00, 0x000C0F09, + 0xCC0C0F09, 0xCD0C0500, 0xA000C600, 0xC62C09D1, 0x2F00000C, 0x0F09D20C, 0x19FFE72C, 0x09D32F00, 0x000C0F09, + 0xD40C0F09, 0xD50C0500, 0x8F00AF00, 0xAF2C09D9, 0x2F00000C, 0x0F09DA0C, 0x102C09E8, 0x2F00000C, 0x0F09E90C, + 0x0F09EA0C, 0x00570400, 0x17120600, 0x0C000013, 0x000C0C11, 0x57040700, 0x000E09EB, 0x0C121610, 0x12060006, + 0x00001300, 0x060C07FF, 0xEC2C09EC, 0x2F00000C, 0x0F09ED0C, 0x0F09EE0C, 0x00570800, 0x17120600, 0x0C000013, + 0x000C0C11, 0x57080700, 0x000E09EF, 0x0C121610, 0x12060006, 0x00001300, 0x060C07FF, 0xEC120600, 0x04000013, + 0x00040C07, 0x00000E09, 0xCE0C1610, 0x12060002, 0x00001300, 0x020C0700, 0x000E09D8, 0x0C16100C, 0x0F09CF0C, + 0x1C050115, 0x09000010, 0x0E09D60C, 0x19FFF100, +}; + +static UNK_TYPE D_80AE71C4[] = { 0x00374000, 0x1C2C09DB, 0x0C2F0000, 0x0C0F09DC, 0x0C0F09DD, 0x0C0F09DE, 0x0C0F09DF, + 0x0C113740, 0x102C09E0, 0x0C2F0000, 0x0C0F09E1, 0x0C0F09E2, 0x0C100000 }; -#if 0 const ActorInit En_Shn_InitVars = { ACTOR_EN_SHN, ACTORCAT_NPC, @@ -31,47 +63,379 @@ const ActorInit En_Shn_InitVars = { (ActorFunc)EnShn_Draw, }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_shn_Anim_00D9D0, 1.0f, 0, -1, 0, 0 }, + { &object_shn_Anim_00D9D0, 1.0f, 0, -1, 0, -4 }, + { &object_shn_Anim_00E6C4, 1.0f, 0, -1, 0, 0 }, + { &object_shn_Anim_00E6C4, 1.0f, 0, -1, 0, -4 }, +}; -extern UNK_TYPE D_0600B738; -extern UNK_TYPE D_0600E7D0; +static s32 D_80AE7258[] = { 0, 2, 3, 8, 10, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6130.s") +void func_80AE6130(EnShn* this) { + this->skelAnime.playSpeed = this->playSpeed; + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE615C.s") +s32 func_80AE615C(EnShn* this, s32 arg1) { + s32 phi_v0 = 0; + s32 phi_v1 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE61C0.s") + if (arg1 != this->unk_2E8) { + phi_v0 = 1; + } + if (phi_v0 != 0) { + this->unk_2E8 = arg1; + phi_v1 = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + this->playSpeed = this->skelAnime.playSpeed; + } + return phi_v1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE625C.s") +s32 EnShn_IsFacingPlayer(EnShn* this) { + s16 phi_v1; + f32 range; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE626C.s") + if (this->unk_2C8 == 0) { + phi_v1 = 0; + } else { + this->unk_2C8--; + phi_v1 = this->unk_2C8; + } + if (phi_v1 == 0) { + this->unk_2EC ^= 1; + this->unk_2C8 = Rand_S16Offset(0x1E, 0x1E); + } + if (this->unk_2EC != 0) { + range = 120.0f; + } else { + range = 80.0f; + } + return Actor_IsFacingAndNearPlayer(&this->actor, range, 0x238C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE63A8.s") +Player* EnShn_GetPlayer(EnShn* this, GlobalContext* globalCtx) { + return GET_PLAYER(globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6488.s") +void func_80AE626C(EnShn* this) { + s32 topPad; + Vec3f playerPos; + Vec3f shnPos; + s32 bottomPad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE65F4.s") + Math_Vec3f_Copy(&playerPos, &this->shnPlayerRef->actor.world.pos); + Math_Vec3f_Copy(&shnPos, &this->actor.world.pos); + Math_ApproachS(&this->unk_2BC, (Math_Vec3f_Yaw(&shnPos, &playerPos) - this->actor.shape.rot.y), 4, 0x2AA8); + this->unk_2BC = CLAMP(this->unk_2BC, -0x1FFE, 0x1FFE); + Math_Vec3f_Copy(&shnPos, &this->actor.focus.pos); + if (this->shnPlayerRef->actor.id == ACTOR_PLAYER) { + playerPos.y = this->shnPlayerRef->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&playerPos, &this->shnPlayerRef->actor.focus.pos); + } + Math_ApproachS(&this->unk_2BA, Math_Vec3f_Pitch(&shnPos, &playerPos), 4, 0x2AA8); + this->unk_2BA = CLAMP(this->unk_2BA, -0x1554, 0x1554); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6704.s") +void func_80AE63A8(EnShn* this, GlobalContext* globalCtx) { + s16 phi_v1; + s16 phi_v1_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6880.s") + this->shnPlayerRef = EnShn_GetPlayer(this, globalCtx); + if ((this->unk_1D8 & 8) && (this->shnPlayerRef != NULL)) { + if (this->unk_2CA == 0) { + phi_v1 = 0; + } else { + this->unk_2CA--; + phi_v1 = this->unk_2CA; + } + if (phi_v1 == 0) { + func_80AE626C(this); + this->unk_1D8 &= ~0x20; + this->unk_1D8 |= 0x10; + return; + } + } + if (this->unk_1D8 & 0x10) { + this->unk_1D8 &= ~0x10; + this->unk_2BA = 0; + this->unk_2BC = 0; + this->unk_2CA = 20; + return; + } + if (this->unk_2CA == 0) { + phi_v1_2 = 0; + } else { + this->unk_2CA--; + phi_v1_2 = this->unk_2CA; + } + if (phi_v1_2 == 0) { + this->unk_1D8 |= 0x20; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE68F0.s") +void func_80AE6488(EnShn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 tempMsgState; + f32 phi_f0_2; + f32 phi_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE69E8.s") + tempMsgState = Message_GetState(&globalCtx->msgCtx); + this->unk_2D4 += (this->unk_2D0 != 0.0f) ? 40.0f : -40.0f; + this->unk_2D4 = CLAMP(this->unk_2D4, 0.0f, 80.0f); + Matrix_InsertTranslation(this->unk_2D4, 0.0f, 0.0f, 1); + if ((&this->actor == player->targetActor) && + ((globalCtx->msgCtx.unk11F04 < 0xFF) || (globalCtx->msgCtx.unk11F04 >= 0x201)) && (tempMsgState == 3) && + (this->msgState == 3)) { + if (globalCtx->state.frames % 2 == 0) { + if (this->unk_2D0 != 0.0f) { + this->unk_2D0 = 0.0f; + } else { + this->unk_2D0 = 1.0f; + } + } + } else { + this->unk_2D0 = 0.0f; + } + this->msgState = tempMsgState; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6A64.s") +s32 func_80AE65F4(EnShn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u16 temp = globalCtx->msgCtx.unk11F04; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/EnShn_Init.s") + if (player->stateFlags1 & 0x40) { + if (this->unk_1DA != temp) { + if ((this->unk_1D8 & 0x80) || (this->unk_1D8 & 0x100)) { + this->unk_1D8 |= 8; + func_80AE615C(this, 1); + } + if (temp == 0x9C5) { + if (1) {} + this->unk_1D8 |= 8; + func_80AE615C(this, 1); + } + } + this->unk_1DA = temp; + this->unk_1D8 |= 0x40; + } else if (this->unk_1D8 & 0x40) { + if (!(gSaveContext.weekEventReg[23] & 8)) { + func_80AE615C(this, 3); + } + this->unk_1DA = 0; + this->unk_1D8 &= ~0x40; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/EnShn_Destroy.s") +s32 func_80AE6704(EnShn* thisx, GlobalContext* globalCtx) { + EnShn* this = THIS; + s32 ret = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/EnShn_Update.s") + switch (this->unk_2C6) { + case 0: + if (!CHECK_QUEST_ITEM(QUEST_UNK_19)) { + this->unk_2C6 = 6; + ret = 1; + } else { + this->unk_2C6++; + } + break; + case 1: + case 2: + case 3: + case 4: + case 5: + if (func_8013A4C4(D_80AE7258[this->unk_2C6])) { + this->unk_2C6 = 6; + ret = 1; + REMOVE_QUEST_ITEM(QUEST_UNK_19); + } else { + this->unk_2C6++; + } + break; + case 6: + gSaveContext.weekEventReg[90] &= (u8)~0x40; + func_800B7298(globalCtx, &this->actor, 7); + globalCtx->nextEntranceIndex = 0x8460; + gSaveContext.nextCutsceneIndex = 0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 7; + this->unk_2C6++; + break; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6CF0.s") +UNK_TYPE* func_80AE6880(EnShn* this, GlobalContext* globalCtx) { + if (this->unk_2BE != 0) { + return D_80AE70B0; + } + if (this->unk_1D8 & 0x80) { + this->unk_2D8 = func_80AE6704; + return D_80AE70B8; + } + if (this->unk_1D8 & 0x100) { + return D_80AE71C4; + } + this->unk_2D8 = func_80AE6704; + return D_80AE6F00; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6D40.s") +s32 func_80AE68F0(EnShn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 ret = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6D90.s") + if (this->unk_1D8 & 7) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_1D8 &= ~0x180; + if (player->exchangeItemId == EXCH_ITEM_13) { + this->unk_1D8 |= 0x80; + this->unk_2E4 = player->exchangeItemId; + } else if (player->exchangeItemId != EXCH_ITEM_NONE) { + this->unk_1D8 |= 0x100; + this->unk_2E4 = player->exchangeItemId; + } + SubS_UpdateFlags(&this->unk_1D8, 0, 7); + this->unk_1DC = func_80AE6880(this, globalCtx); + this->unk_2C6 = 0; + if (gSaveContext.weekEventReg[23] & 8) { + this->unk_1D8 |= 8; + } + this->actionFunc = func_80AE6A64; + ret = 1; + } + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/EnShn_Draw.s") +void func_80AE69E8(EnShn* this, GlobalContext* globalCtx) { + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); + if ((gSaveContext.weekEventReg[23] & 8) && EnShn_IsFacingPlayer(this)) { + this->unk_1D8 |= 8; + } else { + this->unk_1D8 &= ~0x8; + } +} + +void func_80AE6A64(EnShn* this, GlobalContext* globalCtx) { + s16 yawBetweenActors; + Vec3f playerPos; + Vec3f shnPos; + + if (func_8010BF58(&this->actor, globalCtx, this->unk_1DC, this->unk_2D8, &this->unk_1E0)) { + SubS_UpdateFlags(&this->unk_1D8, 3, 7); + this->unk_1D8 &= ~8; + this->unk_1D8 |= 0x20; + this->unk_2CA = 20; + this->unk_1E0 = 0; + this->unk_2BE = 0; + this->actionFunc = func_80AE69E8; + } else if (this->shnPlayerRef != 0) { + Math_Vec3f_Copy(&playerPos, &this->shnPlayerRef->actor.world.pos); + Math_Vec3f_Copy(&shnPos, &this->actor.world.pos); + yawBetweenActors = Math_Vec3f_Yaw(&shnPos, &playerPos); + Math_ApproachS(&this->actor.shape.rot.y, yawBetweenActors, 4, 0x2AA8); + } +} + +void EnShn_Init(Actor* thisx, GlobalContext* globalCtx) { + EnShn* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gObjectShnSkel, NULL, this->jointTable, this->morphTable, + OBJECT_SHN_LIMB_MAX); + this->unk_2E8 = -1; + if (gSaveContext.weekEventReg[23] & 8) { + func_80AE615C(this, 0); + } else { + func_80AE615C(this, 2); + } + this->actor.targetMode = 6; + Actor_SetScale(&this->actor, 0.01f); + this->unk_2E0 = 0; + this->unk_2D8 = 0; + this->unk_1D8 = 0; + if (gSaveContext.entranceIndex != 0xA820) { + SubS_UpdateFlags(&this->unk_1D8, 3, 7); + this->unk_2BE = 0; + } else { + SubS_UpdateFlags(&this->unk_1D8, 4, 7); + this->unk_2BE = 1; + } + this->actionFunc = func_80AE69E8; +} + +void EnShn_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnShn_Update(Actor* thisx, GlobalContext* globalCtx) { + EnShn* this = THIS; + + func_80AE68F0(this, globalCtx); + this->actionFunc(this, globalCtx); + func_80AE65F4(this, globalCtx); + func_80AE6130(this); + func_80AE63A8(this, globalCtx); + this->unk_2E0 = 0; + func_8013C964(&this->actor, globalCtx, 120.0f, 40.0f, 0, this->unk_1D8 & 7); +} + +s32 EnShn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnShn* this = THIS; + + if (limbIndex == OBJECT_SHN_LIMB_HEAD) { + func_80AE6488(this, globalCtx); + *dList = gObjectShnSwampGuideHead; + } + return false; +} + +Vec3f D_80AE7270 = { 1200.0f, 0.0f, 0.0f }; +void EnShn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + if (limbIndex == OBJECT_SHN_LIMB_HEAD) { + Matrix_MultiplyVector3fByState(&D_80AE7270, &thisx->focus.pos); + Math_Vec3s_Copy(&thisx->focus.rot, &thisx->world.rot); + } +} + +void EnShn_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnShn* this = THIS; + s32 phi_v0; + s32 phi_v1; + + if (!(this->unk_1D8 & 0x20)) { + if (this->unk_1D8 & 0x10) { + phi_v1 = 1; + } else { + phi_v1 = 0; + } + phi_v0 = 1; + } else { + phi_v1 = 0; + phi_v0 = 0; + } + + if (limbIndex == OBJECT_SHN_LIMB_HEAD) { + func_8013AD9C((this->unk_2BA + 0x4000), (this->unk_2BC + this->actor.shape.rot.y + 0x4000), &this->unk_1E8, + &this->unk_1F4, phi_v0, phi_v1); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_1E8.x, this->unk_1E8.y, this->unk_1E8.z, 0); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 1); + Matrix_RotateY(this->unk_1F4.y, 1); + Matrix_InsertXRotation_s(this->unk_1F4.x, 1); + Matrix_InsertZRotation_s(this->unk_1F4.z, 1); + Matrix_StatePush(); + } +} + +void EnShn_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnShn* this = THIS; + + func_8012C5B0(globalCtx->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnShn_OverrideLimbDraw, EnShn_PostLimbDraw, + EnShn_TransformLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.h b/src/overlays/actors/ovl_En_Shn/z_en_shn.h index b5d98919d..bb54a8815 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.h +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.h @@ -2,15 +2,44 @@ #define Z_EN_SHN_H #include "global.h" +#include "objects/object_shn/object_shn.h" struct EnShn; typedef void (*EnShnActionFunc)(struct EnShn*, GlobalContext*); typedef struct EnShn { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnShnActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x1A8]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnShnActionFunc actionFunc; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ UNK_TYPE1 pad_18C[0x4C]; + /* 0x1D8 */ u16 unk_1D8; + /* 0x1DA */ u16 unk_1DA; + /* 0x1DC */ UNK_TYPE* unk_1DC; + /* 0x1E0 */ s32 unk_1E0; + /* 0x1E4 */ Player* shnPlayerRef; + /* 0x1E8 */ Vec3f unk_1E8; + /* 0x1F4 */ Vec3s unk_1F4; + /* 0x1FA */ Vec3s jointTable[OBJECT_SHN_LIMB_MAX]; + /* 0x25A */ Vec3s morphTable[OBJECT_SHN_LIMB_MAX]; + /* 0x2BA */ s16 unk_2BA; + /* 0x2BC */ s16 unk_2BC; + /* 0x2BE */ s16 unk_2BE; + /* 0x2C0 */ s16 unk_2C0; + /* 0x2C2 */ s16 unk_2C2; + /* 0x2C4 */ s16 unk_2C4; + /* 0x2C6 */ s16 unk_2C6; + /* 0x2C8 */ s16 unk_2C8; + /* 0x2CA */ s16 unk_2CA; + /* 0x2CC */ f32 playSpeed; + /* 0x2D0 */ f32 unk_2D0; + /* 0x2D4 */ f32 unk_2D4; + /* 0x2D8 */ s32 unk_2D8; + /* 0x2DC */ s32 msgState; + /* 0x2E0 */ s32 unk_2E0; + /* 0x2E4 */ s32 unk_2E4; + /* 0x2E8 */ s32 unk_2E8; + /* 0x2EC */ s32 unk_2EC; } EnShn; // size = 0x2F0 extern const ActorInit En_Shn_InitVars; diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index d461712e2..ae1f01934 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -132,11 +132,11 @@ void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 1; Actor_SetScale(&this->actor, 0.01f); if (globalCtx->sceneNum == SCENE_SYATEKI_MORI) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_shn_Skel_00E7D0, &object_shn_Anim_00DFEC, - this->jointTable, this->morphTable, 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gObjectShnSkel, &object_shn_Anim_00DFEC, this->jointTable, + this->morphTable, OBJECT_SHN_LIMB_MAX); } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_shn_Skel_00E7D0, &object_shn_Anim_00D9D0, - this->jointTable, this->morphTable, 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gObjectShnSkel, &object_shn_Anim_00D9D0, this->jointTable, + this->morphTable, OBJECT_SHN_LIMB_MAX); } this->actor.colChkInfo.cylRadius = 100; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 45a125dce..76a3a3d55 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -12461,8 +12461,8 @@ 0x80AE5990:("EnFsn_Draw",), 0x80AE6130:("func_80AE6130",), 0x80AE615C:("func_80AE615C",), - 0x80AE61C0:("func_80AE61C0",), - 0x80AE625C:("func_80AE625C",), + 0x80AE61C0:("EnShn_IsFacingPlayer",), + 0x80AE625C:("EnShn_GetPlayer",), 0x80AE626C:("func_80AE626C",), 0x80AE63A8:("func_80AE63A8",), 0x80AE6488:("func_80AE6488",), @@ -12475,9 +12475,9 @@ 0x80AE6B30:("EnShn_Init",), 0x80AE6C4C:("EnShn_Destroy",), 0x80AE6C5C:("EnShn_Update",), - 0x80AE6CF0:("func_80AE6CF0",), - 0x80AE6D40:("func_80AE6D40",), - 0x80AE6D90:("func_80AE6D90",), + 0x80AE6CF0:("EnShn_OverrideLimbDraw",), + 0x80AE6D40:("EnShn_PostLimbDraw",), + 0x80AE6D90:("EnShn_TransformLimbDraw",), 0x80AE6E8C:("EnShn_Draw",), 0x80AE73A0:("EnStopheishi_Init",), 0x80AE74E0:("EnStopheishi_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 52517baa6..e212409c2 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1713,11 +1713,6 @@ D_0600D8D8 = 0x0600D8D8; D_060000F0 = 0x060000F0; D_060010C0 = 0x060010C0; -// ovl_En_Shn - -D_0600B738 = 0x0600B738; -D_0600E7D0 = 0x0600E7D0; - // ovl_En_Slime D_060004C0 = 0x060004C0; From 040db7ac407647dfe642387acd6963167e434645 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 5 Mar 2022 15:57:38 +0000 Subject: [PATCH 074/257] En_Mm3 (#671) * En_Mm3 * PR * Merge --- assets/xml/overlays/ovl_En_Mm3.xml | 6 + include/functions.h | 4 +- spec | 3 +- src/overlays/actors/ovl_En_Mm3/z_en_mm3.c | 548 ++++++++++++++++++++-- src/overlays/actors/ovl_En_Mm3/z_en_mm3.h | 15 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 5 - 7 files changed, 540 insertions(+), 45 deletions(-) create mode 100644 assets/xml/overlays/ovl_En_Mm3.xml diff --git a/assets/xml/overlays/ovl_En_Mm3.xml b/assets/xml/overlays/ovl_En_Mm3.xml new file mode 100644 index 000000000..207b5ec8f --- /dev/null +++ b/assets/xml/overlays/ovl_En_Mm3.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/include/functions.h b/include/functions.h index 05fe12474..05262d2c4 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1900,7 +1900,7 @@ void OLib_DbCameraVec3fSum(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode); // void func_8010E028(void); // void func_8010E968(void); void func_8010E9F0(s16 arg0, s16 arg1); -// void func_8010EA9C(void); +void func_8010EA9C(s32 arg0, s32 arg1); // void func_8010EB50(void); // void func_8010EBA0(void); // void func_8010EC54(void); @@ -3634,7 +3634,7 @@ void func_801A0124(Vec3f* pos, u8 arg1); // void func_801A0184(void); // void func_801A01C4(void); void func_801A0204(s8 seqId); -// void func_801A0238(void); +void func_801A0238(s32 arg0, s32 arg1); // void func_801A026C(void); // void func_801A0318(void); // void func_801A046C(void); diff --git a/spec b/spec index 488852c5f..8040fd441 100644 --- a/spec +++ b/spec @@ -3092,8 +3092,7 @@ beginseg name "ovl_En_Mm3" compress include "build/src/overlays/actors/ovl_En_Mm3/z_en_mm3.o" - include "build/data/ovl_En_Mm3/ovl_En_Mm3.data.o" - include "build/data/ovl_En_Mm3/ovl_En_Mm3.reloc.o" + include "build/src/overlays/actors/ovl_En_Mm3/ovl_En_Mm3_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index 8ff09e32b..fd676186e 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -5,6 +5,7 @@ */ #include "z_en_mm3.h" +#include "objects/object_mm/object_mm.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) @@ -15,7 +16,19 @@ void EnMm3_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMm3_Update(Actor* thisx, GlobalContext* globalCtx); void EnMm3_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A6F270(EnMm3* this); +void func_80A6F2C8(EnMm3* this, GlobalContext* globalCtx); +void func_80A6F9C8(EnMm3* this); +void func_80A6F9DC(EnMm3* this, GlobalContext* globalCtx); +void func_80A6FBA0(EnMm3* this); +void func_80A6FBFC(EnMm3* this, GlobalContext* globalCtx); +void func_80A6FE1C(EnMm3* this); +void func_80A6FE30(EnMm3* this, GlobalContext* globalCtx); +void func_80A6FED8(EnMm3* this); +void func_80A6FEEC(EnMm3* this, GlobalContext* globalCtx); +s32 func_80A6FFAC(EnMm3* this, GlobalContext* globalCtx); +void func_80A70084(EnMm3* this, GlobalContext* globalCtx); + const ActorInit En_Mm3_InitVars = { ACTOR_EN_MM3, ACTORCAT_NPC, @@ -28,61 +41,532 @@ const ActorInit En_Mm3_InitVars = { (ActorFunc)EnMm3_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A703F0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 63, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80A7041C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfo sAnimations[] = { + { &object_mm_Anim_002238, 1.0f, 0.0f, 0.0f, 0, -7.0f }, { &object_mm_Anim_00A4E0, -1.0f, 0.0f, 0.0f, 2, -7.0f }, + { &object_mm_Anim_00C640, 1.0f, 0.0f, 0.0f, 0, -7.0f }, { &object_mm_Anim_00A4E0, 1.0f, 0.0f, 0.0f, 2, -7.0f }, + { &object_mm_Anim_000468, 1.0f, 0.0f, 0.0f, 0, -7.0f }, { &object_mm_Anim_00CD90, 1.0f, 0.0f, 0.0f, 0, -12.0f }, + { &object_mm_Anim_00DA50, 1.0f, 0.0f, 0.0f, 0, -12.0f }, { &object_mm_Anim_00DA50, 1.0f, 0.0f, 10.0f, 2, -10.0f }, +}; -extern ColliderCylinderInit D_80A703F0; -extern CollisionCheckInfoInit2 D_80A7041C; +#include "overlays/ovl_En_Mm3/ovl_En_Mm3.c" -extern UNK_TYPE D_0600A4E0; +Vec3f D_80A704F0 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/EnMm3_Init.s") +TexturePtr D_80A704FC[] = { object_mm_Tex_002950, object_mm_Tex_002750 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/EnMm3_Destroy.s") +void EnMm3_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnMm3* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F22C.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 21.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_mm_Skel_0096E8, &object_mm_Anim_00A4E0, this->jointTable, + this->morphTable, 16); + Animation_Change(&this->skelAnime, &object_mm_Anim_00A4E0, -1.0f, Animation_GetLastFrame(&object_mm_Anim_00A4E0), + 0.0f, 2, 0.0f); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + this->actor.parent = NULL; + this->actor.targetMode = 0; + this->unk_1DC = 1; + this->unk_2B4 = 0; + this->unk_2AE = 0; + this->unk_2B0 &= ~1; + this->actor.world.pos.y = this->actor.floorHeight; + func_80A6F270(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F270.s") +void EnMm3_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMm3* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F2C8.s") + gSaveContext.weekEventReg[63] &= (u8)~1; + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F3B4.s") +s32 func_80A6F22C(EnMm3* this) { + s16 abs = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F5E4.s") + abs = ABS_ALT(abs); + if (abs < 0x4000) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F9C8.s") +void func_80A6F270(EnMm3* this) { + this->unk_1DC = 1; + this->unk_2B0 &= ~1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + this->actionFunc = func_80A6F2C8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F9DC.s") +void func_80A6F2C8(EnMm3* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + Message_StartTextbox(globalCtx, 0x278A, &this->actor); + this->unk_2B4 = 0x278A; + func_80A6F9C8(this); + } else if (func_80A6F22C(this)) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FBA0.s") + Math_SmoothStepToS(&this->unk_2A0.x, 0, 5, 0x1000, 0x100); + Math_SmoothStepToS(&this->unk_2A0.y, 0, 5, 0x1000, 0x100); + Math_SmoothStepToS(&this->unk_2A6.x, 0, 5, 0x1000, 0x100); + Math_SmoothStepToS(&this->unk_2A6.y, 0, 5, 0x1000, 0x100); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FBFC.s") +void func_80A6F3B4(EnMm3* this, GlobalContext* globalCtx) { + if (func_80147624(globalCtx)) { + switch (this->unk_2B4) { + case 0x278E: + if (globalCtx->msgCtx.choiceIndex == 0) { + if (this->unk_2B2 & 0x20) { + if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { + func_8019F208(); + Message_StartTextbox(globalCtx, 0x2790, &this->actor); + this->unk_2B4 = 0x2790; + func_801159EC(-globalCtx->msgCtx.unk1206C); + } else { + play_sound(NA_SE_SY_ERROR); + Message_StartTextbox(globalCtx, 0x279C, &this->actor); + this->unk_2B4 = 0x279C; + func_80151BB4(globalCtx, 0xB); + } + } else { + func_8019F208(); + Message_StartTextbox(globalCtx, 0x2790, &this->actor); + this->unk_2B4 = 0x2790; + } + } else { + func_8019F230(); + Message_StartTextbox(globalCtx, 0x278F, &this->actor); + this->unk_2B4 = 0x278F; + func_80151BB4(globalCtx, 0xB); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FE1C.s") + case 0x279A: + if (globalCtx->msgCtx.choiceIndex == 0) { + if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { + func_8019F208(); + Message_StartTextbox(globalCtx, 0x2790, &this->actor); + this->unk_2B4 = 0x2790; + func_801159EC(-globalCtx->msgCtx.unk1206C); + } else { + play_sound(NA_SE_SY_ERROR); + Message_StartTextbox(globalCtx, 0x279C, &this->actor); + this->unk_2B4 = 0x279C; + func_80151BB4(globalCtx, 0xB); + } + } else { + func_8019F230(); + Message_StartTextbox(globalCtx, 0x279B, &this->actor); + this->unk_2B4 = 0x279B; + func_80151BB4(globalCtx, 0xB); + } + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FE30.s") +void func_80A6F5E4(EnMm3* this, GlobalContext* globalCtx) { + if (((this->unk_2B4 != 0x2791) || (this->unk_2AC == 0)) && func_80147624(globalCtx)) { + switch (this->unk_2B4) { + case 0x278A: + if (func_80A6FFAC(this, globalCtx)) { + Message_StartTextbox(globalCtx, 0x279D, &this->actor); + this->unk_2B4 = 0x279D; + } else { + func_80A70084(this, globalCtx); + if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + Message_StartTextbox(globalCtx, 0x27A0, &this->actor); + this->unk_2B4 = 0x27A0; + } else { + Message_StartTextbox(globalCtx, 0x278B, &this->actor); + this->unk_2B4 = 0x278B; + } + } + this->unk_1DC = 0; + this->unk_2B0 |= 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FED8.s") + case 0x278B: + case 0x27A0: + this->unk_2AE = 0; + Message_StartTextbox(globalCtx, 0x278C, &this->actor); + this->unk_2B4 = 0x278C; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FEEC.s") + case 0x278C: + Message_StartTextbox(globalCtx, 0x278D, &this->actor); + this->unk_2B4 = 0x278D; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FFAC.s") + case 0x279D: + this->unk_2AE = 0; + Message_StartTextbox(globalCtx, 0x279E, &this->actor); + this->unk_2B4 = 0x279E; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A70084.s") + case 0x279E: + this->unk_2B2 |= 0x20; + Message_StartTextbox(globalCtx, 0x279F, &this->actor); + this->unk_2B4 = 0x279F; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/EnMm3_Update.s") + case 0x278D: + case 0x279F: + Message_StartTextbox(globalCtx, 0x278E, &this->actor); + this->unk_2B4 = 0x278E; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A701E0.s") + case 0x2791: + if (gSaveContext.unk_3DE0[0] == 1000) { + Message_StartTextbox(globalCtx, 0x2792, &this->actor); + this->unk_2B4 = 0x2792; + } else if ((gSaveContext.unk_3DE0[0] >= 1500)) { + Message_StartTextbox(globalCtx, 0x2797, &this->actor); + this->unk_2B4 = 0x2797; + } else if ((gSaveContext.unk_3DE0[0] <= 1050) && (gSaveContext.unk_3DE0[0] >= 950)) { + Message_StartTextbox(globalCtx, 0x2795, &this->actor); + this->unk_2B4 = 0x2795; + } else { + Message_StartTextbox(globalCtx, 0x2796, &this->actor); + this->unk_2B4 = 0x2796; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A702B0.s") + case 0x2792: + Message_StartTextbox(globalCtx, 0x2793, &this->actor); + this->unk_2B4 = 0x2793; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/EnMm3_Draw.s") + case 0x2793: + func_801477B4(globalCtx); + func_80A6FE1C(this); + func_80A6FE30(this, globalCtx); + break; + + case 0x2795: + case 0x2796: + case 0x2797: + if (gSaveContext.weekEventReg[63] & 2) { + Message_StartTextbox(globalCtx, 0x279B, &this->actor); + this->unk_2B4 = 0x279B; + func_80151BB4(globalCtx, 0xB); + } else { + Message_StartTextbox(globalCtx, 0x2798, &this->actor); + this->unk_2B4 = 0x2798; + } + break; + + case 0x2798: + Message_StartTextbox(globalCtx, 0x2799, &this->actor); + this->unk_2B4 = 0x2799; + break; + + case 0x2799: + Message_StartTextbox(globalCtx, 0x279A, &this->actor); + this->unk_2B4 = 0x279A; + break; + } + } else if ((this->unk_2AC > 0) && (this->unk_2B4 == 0x2791)) { + this->unk_2AC--; + if (this->unk_2AC == 0) { + if (gSaveContext.unk_3DE0[0] == 1000) { + func_801A3098(0x922); + } else { + play_sound(NA_SE_SY_ERROR); + } + } + } +} + +void func_80A6F9C8(EnMm3* this) { + this->actionFunc = func_80A6F9DC; +} + +void func_80A6F9DC(EnMm3* this, GlobalContext* globalCtx) { + this->unk_2B0 &= ~2; + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 0: + case 1: + case 2: + break; + + case 3: + this->unk_2B0 |= 2; + break; + + case 4: + func_80A6F3B4(this, globalCtx); + break; + + case 5: + func_80A6F5E4(this, globalCtx); + break; + + case 6: + if (func_80147624(globalCtx)) { + if (this->unk_2B4 == 0x2790) { + Player* player = GET_PLAYER(globalCtx); + + player->stateFlags1 |= 0x20; + if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + func_8010EA9C(0, 2); + } else { + func_8010EA9C(0, 0); + } + func_801477B4(globalCtx); + play_sound(NA_SE_SY_START_SHOT); + func_80A6FBA0(this); + } else { + gSaveContext.weekEventReg[63] &= (u8)~1; + gSaveContext.weekEventReg[63] &= (u8)~2; + func_80A6F270(this); + } + } + break; + } + + if ((this->skelAnime.mode == 2) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + } + + if (((this->unk_2B4 == 0x279D) || (this->unk_2B4 == 0x27A0) || (this->unk_2B4 == 0x278B)) && + Animation_OnFrame(&this->skelAnime, 8.0f) && (this->unk_2AE == 0)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_LIE_DOWN_ON_BED); + this->unk_2AE = 1; + } +} + +void func_80A6FBA0(EnMm3* this) { + func_801A5BD0(0x6F); + func_801A0238(0, 5); + gSaveContext.weekEventReg[63] |= 1; + gSaveContext.weekEventReg[63] &= (u8)~2; + this->actionFunc = func_80A6FBFC; +} + +void func_80A6FBFC(EnMm3* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + OSTime a; + OSTime b; + + if (gSaveContext.unk_3DD0[0] == 0x10) { + player->stateFlags1 &= ~0x20; + this->actor.flags |= ACTOR_FLAG_10000; + if (gSaveContext.unk_3DE0[0] >= 0x5DD) { + gSaveContext.unk_3DE0[0] = 0x5DC; + } else { + a = gSaveContext.unk_3DE0[0]; + if (a >= (OSTime)(995 - XREG(16))) { + b = gSaveContext.unk_3DE0[0]; + if ((OSTime)(XREG(17) + 1005) >= b) { + gSaveContext.unk_3DE0[0] = 1000; + } + } + } + } else if (gSaveContext.unk_3DE0[0] >= 0x5DD) { + gSaveContext.unk_3DD0[0] = 15; + gSaveContext.unk_3DC8 = osGetTime(); + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_801A5BD0(0); + func_801A0238(0x7F, 5); + Message_StartTextbox(globalCtx, 0x2791, &this->actor); + this->unk_2B4 = 0x2791; + this->unk_2AC = 7; + gSaveContext.unk_3DD0[0] = 0; + this->actor.flags &= ~ACTOR_FLAG_10000; + play_sound(NA_SE_SY_START_SHOT); + func_80A6F9C8(this); + } else { + func_800B8614(&this->actor, globalCtx, this->actor.xzDistToPlayer + 10.0f); + func_80123E90(globalCtx, &this->actor); + if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + play_sound(NA_SE_SY_STOPWATCH_TIMER_INF - SFX_FLAG); + } else { + play_sound(NA_SE_SY_STOPWATCH_TIMER_3 - SFX_FLAG); + } + } +} + +void func_80A6FE1C(EnMm3* this) { + this->actionFunc = func_80A6FE30; +} + +void func_80A6FE30(EnMm3* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + if (!(gSaveContext.weekEventReg[77] & 1)) { + gSaveContext.weekEventReg[77] |= 1; + } + this->actor.parent = NULL; + func_80A6FED8(this); + } else if (gSaveContext.weekEventReg[77] & 1) { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + } +} + +void func_80A6FED8(EnMm3* this) { + this->actionFunc = func_80A6FEEC; +} + +void func_80A6FEEC(EnMm3* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + player->stateFlags1 &= ~0x20; + Message_StartTextbox(globalCtx, 0x2794, &this->actor); + this->unk_2B4 = 0x2794; + func_80151BB4(globalCtx, 0xB); + func_80151BB4(globalCtx, 0x2B); + this->actor.flags &= ~ACTOR_FLAG_10000; + func_80A6F9C8(this); + } else { + func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + } +} + +s32 func_80A6FFAC(EnMm3* this, GlobalContext* globalCtx) { + switch (gSaveContext.playerForm) { + case 4: + if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + if (this->unk_2B2 & 0x10) { + return true; + } + } else if (this->unk_2B2 & 1) { + return true; + } + break; + + case 3: + if (this->unk_2B2 & 2) { + return true; + } + break; + + case 2: + if (this->unk_2B2 & 4) { + return true; + } + break; + + case 1: + if (this->unk_2B2 & 8) { + return true; + } + break; + } + + return false; +} + +void func_80A70084(EnMm3* this, GlobalContext* globalCtx) { + switch (gSaveContext.playerForm) { + case 4: + if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + this->unk_2B2 |= 0x10; + this->unk_2B2 |= 1; + } else { + this->unk_2B2 |= 1; + } + break; + + case 3: + this->unk_2B2 |= 2; + break; + + case 2: + this->unk_2B2 |= 4; + break; + + case 1: + this->unk_2B2 |= 8; + break; + } +} + +void EnMm3_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnMm3* this = THIS; + + this->actionFunc(this, globalCtx); + + SkelAnime_Update(&this->skelAnime); + + if (this->unk_2B0 & 1) { + func_800E9250(globalCtx, &this->actor, &this->unk_2A0, &this->unk_2A6, this->actor.focus.pos); + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +s32 EnMm3_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnMm3* this = THIS; + + if (limbIndex == 8) { + rot->x += this->unk_2A6.y; + rot->y -= this->unk_2A6.x; + } else if (limbIndex == 15) { + rot->x += this->unk_2A0.y; + rot->z += this->unk_2A0.x; + if ((this->unk_2B0 & 2) && ((globalCtx->gameplayFrames % 3) == 0)) { + Matrix_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + } + return false; +} + +void EnMm3_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnMm3* this = THIS; + + if (limbIndex == 15) { + Matrix_MultiplyVector3fByState(&D_80A704F0, &this->actor.focus.pos); + } +} + +void EnMm3_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMm3* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A704FC[this->unk_1DC])); + gSPSegment(POLY_OPA_DISP++, 0x0C, sEnMm3DL); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnMm3_OverrideLimbDraw, EnMm3_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h index b3a8c2893..fe2e7ba06 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h @@ -9,9 +9,20 @@ typedef void (*EnMm3ActionFunc)(struct EnMm3*, GlobalContext*); typedef struct EnMm3 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ ColliderCylinder collider; /* 0x01D4 */ EnMm3ActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0xE0]; + /* 0x01D8 */ UNK_TYPE1 unk1D8[4]; + /* 0x01DC */ s32 unk_1DC; + /* 0x01E0 */ Vec3s jointTable[16]; + /* 0x0240 */ Vec3s morphTable[16]; + /* 0x02A0 */ Vec3s unk_2A0; + /* 0x02A6 */ Vec3s unk_2A6; + /* 0x02AC */ s16 unk_2AC; + /* 0x02AE */ s16 unk_2AE; + /* 0x02B0 */ u16 unk_2B0; + /* 0x02B2 */ u16 unk_2B2; + /* 0x02B4 */ u16 unk_2B4; } EnMm3; // size = 0x2B8 extern const ActorInit En_Mm3_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 76a3a3d55..32982655d 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10956,8 +10956,8 @@ 0x80A6FFAC:("func_80A6FFAC",), 0x80A70084:("func_80A70084",), 0x80A70134:("EnMm3_Update",), - 0x80A701E0:("func_80A701E0",), - 0x80A702B0:("func_80A702B0",), + 0x80A701E0:("EnMm3_OverrideLimbDraw",), + 0x80A702B0:("EnMm3_PostLimbDraw",), 0x80A702F0:("EnMm3_Draw",), 0x80A706F0:("BgCraceMovebg_Init",), 0x80A7090C:("func_80A7090C",), diff --git a/undefined_syms.txt b/undefined_syms.txt index e212409c2..a003b1ae3 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1594,11 +1594,6 @@ D_06002EC0 = 0x06002EC0; D_06001C38 = 0x06001C38; D_06006CA0 = 0x06006CA0; -// ovl_En_Mm3 - -D_060096E8 = 0x060096E8; -D_0600A4E0 = 0x0600A4E0; - // ovl_En_Mnk D_06003584 = 0x06003584; From e7940e3bedf28dfcf3e2fafbb74516f40d240d16 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sat, 5 Mar 2022 13:06:02 -0300 Subject: [PATCH 075/257] Add autogenerated limb enum info in the object's XMLs (#633) * first pass * Fix limb enums for objects with more than one skeleton * Manually fix object_cne --- assets/xml/objects/gameplay_field_keep.xml | 16 +- assets/xml/objects/object_ah.xml | 34 ++-- assets/xml/objects/object_ahg.xml | 32 ++-- assets/xml/objects/object_al.xml | 54 +++---- assets/xml/objects/object_an1.xml | 42 ++--- assets/xml/objects/object_and.xml | 52 +++---- assets/xml/objects/object_aob.xml | 32 ++-- assets/xml/objects/object_az.xml | 96 ++++++------ assets/xml/objects/object_bai.xml | 40 ++--- assets/xml/objects/object_bal.xml | 66 ++++---- assets/xml/objects/object_bb.xml | 32 ++-- assets/xml/objects/object_bee.xml | 20 +-- assets/xml/objects/object_bg.xml | 96 ++++++------ assets/xml/objects/object_bh.xml | 12 +- assets/xml/objects/object_bigokuta.xml | 40 ++--- assets/xml/objects/object_bji.xml | 32 ++-- assets/xml/objects/object_bjt.xml | 14 +- assets/xml/objects/object_bob.xml | 32 ++-- assets/xml/objects/object_boj.xml | 32 ++-- assets/xml/objects/object_boss01.xml | 146 +++++++++--------- assets/xml/objects/object_boss02.xml | 74 ++++----- assets/xml/objects/object_boss03.xml | 30 ++-- assets/xml/objects/object_boss04.xml | 18 +-- assets/xml/objects/object_boss05.xml | 60 +++---- assets/xml/objects/object_boss07.xml | 144 ++++++++--------- assets/xml/objects/object_boss_hakugin.xml | 66 ++++---- assets/xml/objects/object_box.xml | 40 ++--- assets/xml/objects/object_bsb.xml | 42 ++--- assets/xml/objects/object_crow.xml | 18 +-- assets/xml/objects/object_cs.xml | 42 ++--- assets/xml/objects/object_dai.xml | 38 ++--- assets/xml/objects/object_daiku.xml | 34 ++-- assets/xml/objects/object_death.xml | 44 +++--- assets/xml/objects/object_dekubaba.xml | 16 +- assets/xml/objects/object_dekunuts.xml | 20 +-- assets/xml/objects/object_dinofos.xml | 42 ++--- assets/xml/objects/object_dnk.xml | 22 +-- assets/xml/objects/object_dno.xml | 56 +++---- assets/xml/objects/object_dnp.xml | 52 +++---- assets/xml/objects/object_dnq.xml | 66 ++++---- assets/xml/objects/object_dnt.xml | 56 +++---- assets/xml/objects/object_dodongo.xml | 62 ++++---- assets/xml/objects/object_dog.xml | 26 ++-- assets/xml/objects/object_ds2.xml | 18 +-- assets/xml/objects/object_ds2n.xml | 38 ++--- assets/xml/objects/object_dt.xml | 30 ++-- assets/xml/objects/object_dy_obj.xml | 56 +++---- assets/xml/objects/object_efc_tw.xml | 6 +- assets/xml/objects/object_eg.xml | 48 +++--- assets/xml/objects/object_famos.xml | 12 +- assets/xml/objects/object_fb.xml | 48 +++--- assets/xml/objects/object_firefly.xml | 56 +++---- assets/xml/objects/object_fish.xml | 74 ++++----- assets/xml/objects/object_fr.xml | 48 +++--- assets/xml/objects/object_fu.xml | 32 ++-- assets/xml/objects/object_ge1.xml | 32 ++-- assets/xml/objects/object_geldb.xml | 48 +++--- assets/xml/objects/object_gg.xml | 40 ++--- assets/xml/objects/object_gk.xml | 40 ++--- assets/xml/objects/object_gla.xml | 44 +++--- assets/xml/objects/object_grasshopper.xml | 48 +++--- assets/xml/objects/object_ha.xml | 104 ++++++------- assets/xml/objects/object_harfgibud.xml | 76 ++++----- assets/xml/objects/object_hata.xml | 42 ++--- assets/xml/objects/object_hintnuts.xml | 20 +-- .../xml/objects/object_horse_link_child.xml | 94 +++++------ assets/xml/objects/object_hs.xml | 32 ++-- assets/xml/objects/object_ik.xml | 60 +++---- assets/xml/objects/object_ikn_demo.xml | 62 ++++---- assets/xml/objects/object_in.xml | 40 ++--- assets/xml/objects/object_in2.xml | 40 ++--- assets/xml/objects/object_js.xml | 26 ++-- assets/xml/objects/object_jso.xml | 80 +++++----- assets/xml/objects/object_ka.xml | 56 +++---- assets/xml/objects/object_kamejima.xml | 48 +++--- assets/xml/objects/object_kbt.xml | 40 ++--- assets/xml/objects/object_kgy.xml | 46 +++--- assets/xml/objects/object_kitan.xml | 42 ++--- assets/xml/objects/object_knight.xml | 116 +++++++------- assets/xml/objects/object_kz.xml | 48 +++--- assets/xml/objects/object_link_boy.xml | 44 +++--- assets/xml/objects/object_link_child.xml | 44 +++--- assets/xml/objects/object_link_goron.xml | 54 +++---- assets/xml/objects/object_link_nuts.xml | 44 +++--- assets/xml/objects/object_link_zora.xml | 44 +++--- assets/xml/objects/object_ma1.xml | 46 +++--- assets/xml/objects/object_ma2.xml | 44 +++--- assets/xml/objects/object_mk.xml | 26 ++-- assets/xml/objects/object_mm.xml | 32 ++-- assets/xml/objects/object_mnk.xml | 64 ++++---- assets/xml/objects/object_ms.xml | 18 +-- assets/xml/objects/object_mu.xml | 42 ++--- assets/xml/objects/object_nb.xml | 16 +- assets/xml/objects/object_niw.xml | 32 ++-- assets/xml/objects/object_oF1d_map.xml | 36 ++--- assets/xml/objects/object_ob.xml | 36 ++--- assets/xml/objects/object_okuta.xml | 32 ++-- assets/xml/objects/object_osn.xml | 38 ++--- assets/xml/objects/object_ot.xml | 38 ++--- assets/xml/objects/object_owl.xml | 74 ++++----- assets/xml/objects/object_pamera.xml | 46 +++--- assets/xml/objects/object_ph.xml | 48 +++--- assets/xml/objects/object_po.xml | 42 ++--- assets/xml/objects/object_po_composer.xml | 24 +-- assets/xml/objects/object_po_fusen.xml | 20 +-- assets/xml/objects/object_po_sisters.xml | 24 +-- assets/xml/objects/object_pp.xml | 104 ++++++------- assets/xml/objects/object_pr.xml | 30 ++-- assets/xml/objects/object_ps.xml | 24 +-- assets/xml/objects/object_pst.xml | 6 +- assets/xml/objects/object_raf.xml | 24 +-- assets/xml/objects/object_rat.xml | 20 +-- assets/xml/objects/object_rb.xml | 36 ++--- assets/xml/objects/object_rs.xml | 32 ++-- assets/xml/objects/object_ru2.xml | 46 +++--- assets/xml/objects/object_rz.xml | 44 +++--- assets/xml/objects/object_sb.xml | 18 +-- assets/xml/objects/object_sdn.xml | 34 ++-- assets/xml/objects/object_skb.xml | 40 ++--- assets/xml/objects/object_snowman.xml | 30 ++-- assets/xml/objects/object_ssh.xml | 60 +++---- assets/xml/objects/object_st.xml | 60 +++---- assets/xml/objects/object_sth.xml | 32 ++-- assets/xml/objects/object_stk.xml | 44 +++--- assets/xml/objects/object_tab.xml | 40 ++--- assets/xml/objects/object_tanron4.xml | 22 +-- assets/xml/objects/object_test3.xml | 44 +++--- assets/xml/objects/object_thiefbird.xml | 34 ++-- assets/xml/objects/object_tite.xml | 50 +++--- assets/xml/objects/object_tk.xml | 36 ++--- assets/xml/objects/object_tl.xml | 34 ++-- assets/xml/objects/object_toryo.xml | 34 ++-- assets/xml/objects/object_trt.xml | 54 +++---- assets/xml/objects/object_tru.xml | 54 +++---- assets/xml/objects/object_tsn.xml | 34 ++-- assets/xml/objects/object_uch.xml | 28 ++-- assets/xml/objects/object_um.xml | 44 +++--- assets/xml/objects/object_utubo.xml | 32 ++-- assets/xml/objects/object_vm.xml | 22 +-- assets/xml/objects/object_wallmaster.xml | 50 +++--- assets/xml/objects/object_warp1.xml | 44 +++--- assets/xml/objects/object_wdhand.xml | 16 +- assets/xml/objects/object_wf.xml | 88 +++++------ assets/xml/objects/object_wiz.xml | 40 ++--- assets/xml/objects/object_zl1.xml | 36 ++--- assets/xml/objects/object_zl4.xml | 36 ++--- assets/xml/objects/object_zm.xml | 36 ++--- assets/xml/objects/object_zo.xml | 40 ++--- assets/xml/objects/object_zob.xml | 48 +++--- assets/xml/objects/object_zod.xml | 20 +-- assets/xml/objects/object_zog.xml | 46 +++--- assets/xml/objects/object_zoraegg.xml | 14 +- assets/xml/objects/object_zos.xml | 36 ++--- assets/xml/objects/object_zov.xml | 46 +++--- 154 files changed, 3314 insertions(+), 3314 deletions(-) diff --git a/assets/xml/objects/gameplay_field_keep.xml b/assets/xml/objects/gameplay_field_keep.xml index a73a2f28d..7a299bff7 100644 --- a/assets/xml/objects/gameplay_field_keep.xml +++ b/assets/xml/objects/gameplay_field_keep.xml @@ -12,14 +12,14 @@ - - - - - - - - + + + + + + + + diff --git a/assets/xml/objects/object_ah.xml b/assets/xml/objects/object_ah.xml index 296347dac..3644f2a90 100644 --- a/assets/xml/objects/object_ah.xml +++ b/assets/xml/objects/object_ah.xml @@ -37,22 +37,22 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ahg.xml b/assets/xml/objects/object_ahg.xml index c636f0baa..7d4c2c741 100644 --- a/assets/xml/objects/object_ahg.xml +++ b/assets/xml/objects/object_ahg.xml @@ -33,21 +33,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_al.xml b/assets/xml/objects/object_al.xml index 7a2ff1a52..d0f6a6cbb 100644 --- a/assets/xml/objects/object_al.xml +++ b/assets/xml/objects/object_al.xml @@ -39,33 +39,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_an1.xml b/assets/xml/objects/object_an1.xml index c2ae65d8b..15c38af32 100644 --- a/assets/xml/objects/object_an1.xml +++ b/assets/xml/objects/object_an1.xml @@ -54,27 +54,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_and.xml b/assets/xml/objects/object_and.xml index 269e2a73f..17cff4597 100644 --- a/assets/xml/objects/object_and.xml +++ b/assets/xml/objects/object_and.xml @@ -42,32 +42,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_aob.xml b/assets/xml/objects/object_aob.xml index dcdb75748..7c1e2e4ef 100644 --- a/assets/xml/objects/object_aob.xml +++ b/assets/xml/objects/object_aob.xml @@ -1,22 +1,22 @@  - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_az.xml b/assets/xml/objects/object_az.xml index c192f6914..d4382673f 100644 --- a/assets/xml/objects/object_az.xml +++ b/assets/xml/objects/object_az.xml @@ -27,30 +27,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -98,30 +98,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bai.xml b/assets/xml/objects/object_bai.xml index ad8d8445b..4225bec84 100644 --- a/assets/xml/objects/object_bai.xml +++ b/assets/xml/objects/object_bai.xml @@ -28,26 +28,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bal.xml b/assets/xml/objects/object_bal.xml index e564a4798..a16e2fb1f 100644 --- a/assets/xml/objects/object_bal.xml +++ b/assets/xml/objects/object_bal.xml @@ -36,39 +36,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bb.xml b/assets/xml/objects/object_bb.xml index ba3e4cb94..4f1c39dac 100644 --- a/assets/xml/objects/object_bb.xml +++ b/assets/xml/objects/object_bb.xml @@ -17,21 +17,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bee.xml b/assets/xml/objects/object_bee.xml index b2c90324b..8f1d704cf 100644 --- a/assets/xml/objects/object_bee.xml +++ b/assets/xml/objects/object_bee.xml @@ -14,15 +14,15 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_bg.xml b/assets/xml/objects/object_bg.xml index 554047b44..0602f987d 100644 --- a/assets/xml/objects/object_bg.xml +++ b/assets/xml/objects/object_bg.xml @@ -28,30 +28,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -84,29 +84,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bh.xml b/assets/xml/objects/object_bh.xml index d54e99e23..84f3050c0 100644 --- a/assets/xml/objects/object_bh.xml +++ b/assets/xml/objects/object_bh.xml @@ -8,11 +8,11 @@ - - - - - - + + + + + + diff --git a/assets/xml/objects/object_bigokuta.xml b/assets/xml/objects/object_bigokuta.xml index 653853c92..21ead0501 100644 --- a/assets/xml/objects/object_bigokuta.xml +++ b/assets/xml/objects/object_bigokuta.xml @@ -34,25 +34,25 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bji.xml b/assets/xml/objects/object_bji.xml index cd953541c..b41ac1546 100644 --- a/assets/xml/objects/object_bji.xml +++ b/assets/xml/objects/object_bji.xml @@ -36,22 +36,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bjt.xml b/assets/xml/objects/object_bjt.xml index 9f0c0edc2..6266711ab 100644 --- a/assets/xml/objects/object_bjt.xml +++ b/assets/xml/objects/object_bjt.xml @@ -12,12 +12,12 @@ - - - - - - - + + + + + + + diff --git a/assets/xml/objects/object_bob.xml b/assets/xml/objects/object_bob.xml index 968a838d2..f942c84db 100644 --- a/assets/xml/objects/object_bob.xml +++ b/assets/xml/objects/object_bob.xml @@ -1,21 +1,21 @@  - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boj.xml b/assets/xml/objects/object_boj.xml index e59c72027..ed42d9031 100644 --- a/assets/xml/objects/object_boj.xml +++ b/assets/xml/objects/object_boj.xml @@ -60,22 +60,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss01.xml b/assets/xml/objects/object_boss01.xml index a9865a096..6a10080a3 100644 --- a/assets/xml/objects/object_boss01.xml +++ b/assets/xml/objects/object_boss01.xml @@ -62,58 +62,58 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -163,27 +163,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss02.xml b/assets/xml/objects/object_boss02.xml index fee15d4a0..0370e1ae2 100644 --- a/assets/xml/objects/object_boss02.xml +++ b/assets/xml/objects/object_boss02.xml @@ -34,19 +34,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -71,29 +71,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss03.xml b/assets/xml/objects/object_boss03.xml index 5cf4ad2b8..e483cbc89 100644 --- a/assets/xml/objects/object_boss03.xml +++ b/assets/xml/objects/object_boss03.xml @@ -49,23 +49,23 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + diff --git a/assets/xml/objects/object_boss04.xml b/assets/xml/objects/object_boss04.xml index d24ad986a..d5d0f728a 100644 --- a/assets/xml/objects/object_boss04.xml +++ b/assets/xml/objects/object_boss04.xml @@ -17,14 +17,14 @@ - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_boss05.xml b/assets/xml/objects/object_boss05.xml index ec994d824..b401ae2be 100644 --- a/assets/xml/objects/object_boss05.xml +++ b/assets/xml/objects/object_boss05.xml @@ -15,16 +15,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -53,26 +53,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss07.xml b/assets/xml/objects/object_boss07.xml index aa0ef8c88..15a2e162d 100644 --- a/assets/xml/objects/object_boss07.xml +++ b/assets/xml/objects/object_boss07.xml @@ -23,31 +23,31 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -98,25 +98,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -157,34 +157,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss_hakugin.xml b/assets/xml/objects/object_boss_hakugin.xml index 52a124fec..62d6fb91f 100644 --- a/assets/xml/objects/object_boss_hakugin.xml +++ b/assets/xml/objects/object_boss_hakugin.xml @@ -41,39 +41,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_box.xml b/assets/xml/objects/object_box.xml index 39d21765f..fb1fb3fd5 100644 --- a/assets/xml/objects/object_box.xml +++ b/assets/xml/objects/object_box.xml @@ -17,11 +17,11 @@ - - - - - + + + + + @@ -29,21 +29,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bsb.xml b/assets/xml/objects/object_bsb.xml index ddaadc33d..7ccf12bce 100644 --- a/assets/xml/objects/object_bsb.xml +++ b/assets/xml/objects/object_bsb.xml @@ -52,27 +52,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_crow.xml b/assets/xml/objects/object_crow.xml index b3b004cd7..3092d91ec 100644 --- a/assets/xml/objects/object_crow.xml +++ b/assets/xml/objects/object_crow.xml @@ -11,14 +11,14 @@ - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_cs.xml b/assets/xml/objects/object_cs.xml index 65cff1d46..5ed725493 100644 --- a/assets/xml/objects/object_cs.xml +++ b/assets/xml/objects/object_cs.xml @@ -69,27 +69,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dai.xml b/assets/xml/objects/object_dai.xml index c39ef9a6d..f613a9ab8 100644 --- a/assets/xml/objects/object_dai.xml +++ b/assets/xml/objects/object_dai.xml @@ -63,24 +63,24 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_daiku.xml b/assets/xml/objects/object_daiku.xml index 0c42532ec..57124bd28 100644 --- a/assets/xml/objects/object_daiku.xml +++ b/assets/xml/objects/object_daiku.xml @@ -49,23 +49,23 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_death.xml b/assets/xml/objects/object_death.xml index 2aba9582d..7d3e1e596 100644 --- a/assets/xml/objects/object_death.xml +++ b/assets/xml/objects/object_death.xml @@ -54,28 +54,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dekubaba.xml b/assets/xml/objects/object_dekubaba.xml index bd59555c4..b82cfb94b 100644 --- a/assets/xml/objects/object_dekubaba.xml +++ b/assets/xml/objects/object_dekubaba.xml @@ -13,14 +13,14 @@ - - - - - - - - + + + + + + + + diff --git a/assets/xml/objects/object_dekunuts.xml b/assets/xml/objects/object_dekunuts.xml index 442dc756d..2e9529d4c 100644 --- a/assets/xml/objects/object_dekunuts.xml +++ b/assets/xml/objects/object_dekunuts.xml @@ -18,16 +18,16 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_dinofos.xml b/assets/xml/objects/object_dinofos.xml index 83eade0da..7b1ff8c20 100644 --- a/assets/xml/objects/object_dinofos.xml +++ b/assets/xml/objects/object_dinofos.xml @@ -41,27 +41,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dnk.xml b/assets/xml/objects/object_dnk.xml index 0d290f19d..359cdfd5d 100644 --- a/assets/xml/objects/object_dnk.xml +++ b/assets/xml/objects/object_dnk.xml @@ -33,17 +33,17 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/assets/xml/objects/object_dno.xml b/assets/xml/objects/object_dno.xml index 16fa904c5..a320be10f 100644 --- a/assets/xml/objects/object_dno.xml +++ b/assets/xml/objects/object_dno.xml @@ -54,33 +54,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dnp.xml b/assets/xml/objects/object_dnp.xml index 575ae3d69..376368578 100644 --- a/assets/xml/objects/object_dnp.xml +++ b/assets/xml/objects/object_dnp.xml @@ -56,32 +56,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dnq.xml b/assets/xml/objects/object_dnq.xml index d286082bf..830e6d8e4 100644 --- a/assets/xml/objects/object_dnq.xml +++ b/assets/xml/objects/object_dnq.xml @@ -56,39 +56,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dnt.xml b/assets/xml/objects/object_dnt.xml index d2ff328d3..6a2b0058d 100644 --- a/assets/xml/objects/object_dnt.xml +++ b/assets/xml/objects/object_dnt.xml @@ -57,34 +57,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dodongo.xml b/assets/xml/objects/object_dodongo.xml index cf0fa3725..f63a27467 100644 --- a/assets/xml/objects/object_dodongo.xml +++ b/assets/xml/objects/object_dodongo.xml @@ -28,37 +28,37 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dog.xml b/assets/xml/objects/object_dog.xml index 7e9cd3e99..f14a3d55e 100644 --- a/assets/xml/objects/object_dog.xml +++ b/assets/xml/objects/object_dog.xml @@ -36,18 +36,18 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ds2.xml b/assets/xml/objects/object_ds2.xml index 0745fad58..1f1fd9d20 100644 --- a/assets/xml/objects/object_ds2.xml +++ b/assets/xml/objects/object_ds2.xml @@ -19,14 +19,14 @@ - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_ds2n.xml b/assets/xml/objects/object_ds2n.xml index 63ccca136..8cee6b22e 100644 --- a/assets/xml/objects/object_ds2n.xml +++ b/assets/xml/objects/object_ds2n.xml @@ -31,25 +31,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dt.xml b/assets/xml/objects/object_dt.xml index a4df244ad..78ad8046e 100644 --- a/assets/xml/objects/object_dt.xml +++ b/assets/xml/objects/object_dt.xml @@ -47,21 +47,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dy_obj.xml b/assets/xml/objects/object_dy_obj.xml index 7de69f2ff..8dd90375a 100644 --- a/assets/xml/objects/object_dy_obj.xml +++ b/assets/xml/objects/object_dy_obj.xml @@ -64,33 +64,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_efc_tw.xml b/assets/xml/objects/object_efc_tw.xml index f251f9607..4d4c1029c 100644 --- a/assets/xml/objects/object_efc_tw.xml +++ b/assets/xml/objects/object_efc_tw.xml @@ -3,8 +3,8 @@ - - - + + + diff --git a/assets/xml/objects/object_eg.xml b/assets/xml/objects/object_eg.xml index 1458afaec..46d3e0089 100644 --- a/assets/xml/objects/object_eg.xml +++ b/assets/xml/objects/object_eg.xml @@ -47,30 +47,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_famos.xml b/assets/xml/objects/object_famos.xml index 7cec70be5..4466f9b30 100644 --- a/assets/xml/objects/object_famos.xml +++ b/assets/xml/objects/object_famos.xml @@ -15,12 +15,12 @@ - - - - - - + + + + + + diff --git a/assets/xml/objects/object_fb.xml b/assets/xml/objects/object_fb.xml index 101ddbc5a..f0d3b8111 100644 --- a/assets/xml/objects/object_fb.xml +++ b/assets/xml/objects/object_fb.xml @@ -32,30 +32,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_firefly.xml b/assets/xml/objects/object_firefly.xml index f6d8f1bc7..84018ddd8 100644 --- a/assets/xml/objects/object_firefly.xml +++ b/assets/xml/objects/object_firefly.xml @@ -22,33 +22,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_fish.xml b/assets/xml/objects/object_fish.xml index c0cbd54c7..9da78b6ab 100644 --- a/assets/xml/objects/object_fish.xml +++ b/assets/xml/objects/object_fish.xml @@ -20,22 +20,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -65,15 +65,15 @@ - - - - - - - - - + + + + + + + + + @@ -120,18 +120,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_fr.xml b/assets/xml/objects/object_fr.xml index cf65cc0ac..cb02087ba 100644 --- a/assets/xml/objects/object_fr.xml +++ b/assets/xml/objects/object_fr.xml @@ -39,29 +39,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_fu.xml b/assets/xml/objects/object_fu.xml index fe847642e..4094355ae 100644 --- a/assets/xml/objects/object_fu.xml +++ b/assets/xml/objects/object_fu.xml @@ -32,21 +32,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ge1.xml b/assets/xml/objects/object_ge1.xml index e401fd088..2f6aac2dd 100644 --- a/assets/xml/objects/object_ge1.xml +++ b/assets/xml/objects/object_ge1.xml @@ -9,22 +9,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_geldb.xml b/assets/xml/objects/object_geldb.xml index 357b83284..6338b48d6 100644 --- a/assets/xml/objects/object_geldb.xml +++ b/assets/xml/objects/object_geldb.xml @@ -48,30 +48,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gg.xml b/assets/xml/objects/object_gg.xml index e1ac1c779..17c21c93a 100644 --- a/assets/xml/objects/object_gg.xml +++ b/assets/xml/objects/object_gg.xml @@ -52,26 +52,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gk.xml b/assets/xml/objects/object_gk.xml index 420f544f1..3fde40f94 100644 --- a/assets/xml/objects/object_gk.xml +++ b/assets/xml/objects/object_gk.xml @@ -23,26 +23,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gla.xml b/assets/xml/objects/object_gla.xml index ee793c256..ae80c7dfc 100644 --- a/assets/xml/objects/object_gla.xml +++ b/assets/xml/objects/object_gla.xml @@ -44,28 +44,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_grasshopper.xml b/assets/xml/objects/object_grasshopper.xml index 5b8ee82af..35120e0c9 100644 --- a/assets/xml/objects/object_grasshopper.xml +++ b/assets/xml/objects/object_grasshopper.xml @@ -35,30 +35,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ha.xml b/assets/xml/objects/object_ha.xml index f3d3f1029..4f595b6be 100644 --- a/assets/xml/objects/object_ha.xml +++ b/assets/xml/objects/object_ha.xml @@ -38,32 +38,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -105,31 +105,31 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_harfgibud.xml b/assets/xml/objects/object_harfgibud.xml index 9a9bf4745..a97e42c00 100644 --- a/assets/xml/objects/object_harfgibud.xml +++ b/assets/xml/objects/object_harfgibud.xml @@ -35,25 +35,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -91,25 +91,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_hata.xml b/assets/xml/objects/object_hata.xml index 3131a6628..3f5e12a38 100644 --- a/assets/xml/objects/object_hata.xml +++ b/assets/xml/objects/object_hata.xml @@ -14,26 +14,26 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_hintnuts.xml b/assets/xml/objects/object_hintnuts.xml index 655c8ae3c..a500981a7 100644 --- a/assets/xml/objects/object_hintnuts.xml +++ b/assets/xml/objects/object_hintnuts.xml @@ -18,16 +18,16 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_horse_link_child.xml b/assets/xml/objects/object_horse_link_child.xml index f844224fa..47ceff55a 100644 --- a/assets/xml/objects/object_horse_link_child.xml +++ b/assets/xml/objects/object_horse_link_child.xml @@ -28,53 +28,53 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_hs.xml b/assets/xml/objects/object_hs.xml index 315128815..0d36c4ff1 100644 --- a/assets/xml/objects/object_hs.xml +++ b/assets/xml/objects/object_hs.xml @@ -27,21 +27,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ik.xml b/assets/xml/objects/object_ik.xml index 34dcac8f2..0b68303da 100644 --- a/assets/xml/objects/object_ik.xml +++ b/assets/xml/objects/object_ik.xml @@ -72,35 +72,35 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ikn_demo.xml b/assets/xml/objects/object_ikn_demo.xml index 69d225933..56f8fd0e9 100644 --- a/assets/xml/objects/object_ikn_demo.xml +++ b/assets/xml/objects/object_ikn_demo.xml @@ -27,23 +27,23 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + @@ -57,13 +57,13 @@ - - - - - - - + + + + + + + @@ -83,13 +83,13 @@ - - - - - - - + + + + + + + diff --git a/assets/xml/objects/object_in.xml b/assets/xml/objects/object_in.xml index 42bace14f..3874e4834 100644 --- a/assets/xml/objects/object_in.xml +++ b/assets/xml/objects/object_in.xml @@ -93,26 +93,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_in2.xml b/assets/xml/objects/object_in2.xml index a47c7613e..4457defae 100644 --- a/assets/xml/objects/object_in2.xml +++ b/assets/xml/objects/object_in2.xml @@ -47,26 +47,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_js.xml b/assets/xml/objects/object_js.xml index be9246ab6..92f14da0b 100644 --- a/assets/xml/objects/object_js.xml +++ b/assets/xml/objects/object_js.xml @@ -27,19 +27,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_jso.xml b/assets/xml/objects/object_jso.xml index 777c6e53c..33816a797 100644 --- a/assets/xml/objects/object_jso.xml +++ b/assets/xml/objects/object_jso.xml @@ -30,26 +30,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -95,26 +95,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ka.xml b/assets/xml/objects/object_ka.xml index 2944a00b2..36dceb0ca 100644 --- a/assets/xml/objects/object_ka.xml +++ b/assets/xml/objects/object_ka.xml @@ -31,34 +31,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kamejima.xml b/assets/xml/objects/object_kamejima.xml index 8bdb54d06..9b45ad478 100644 --- a/assets/xml/objects/object_kamejima.xml +++ b/assets/xml/objects/object_kamejima.xml @@ -43,30 +43,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kbt.xml b/assets/xml/objects/object_kbt.xml index b3ab0baaf..ec8dbd6ea 100644 --- a/assets/xml/objects/object_kbt.xml +++ b/assets/xml/objects/object_kbt.xml @@ -43,26 +43,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kgy.xml b/assets/xml/objects/object_kgy.xml index 856c5883d..0e2d3be2c 100644 --- a/assets/xml/objects/object_kgy.xml +++ b/assets/xml/objects/object_kgy.xml @@ -45,29 +45,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kitan.xml b/assets/xml/objects/object_kitan.xml index 3884470f9..05d090d93 100644 --- a/assets/xml/objects/object_kitan.xml +++ b/assets/xml/objects/object_kitan.xml @@ -29,26 +29,26 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_knight.xml b/assets/xml/objects/object_knight.xml index 67d87a0ff..0459cb062 100644 --- a/assets/xml/objects/object_knight.xml +++ b/assets/xml/objects/object_knight.xml @@ -143,64 +143,64 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kz.xml b/assets/xml/objects/object_kz.xml index 24c16e1fc..2b714be38 100644 --- a/assets/xml/objects/object_kz.xml +++ b/assets/xml/objects/object_kz.xml @@ -52,30 +52,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_boy.xml b/assets/xml/objects/object_link_boy.xml index 8bfd17e98..b0a85ece5 100644 --- a/assets/xml/objects/object_link_boy.xml +++ b/assets/xml/objects/object_link_boy.xml @@ -55,27 +55,27 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_child.xml b/assets/xml/objects/object_link_child.xml index 86c596909..51145033c 100644 --- a/assets/xml/objects/object_link_child.xml +++ b/assets/xml/objects/object_link_child.xml @@ -130,27 +130,27 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_goron.xml b/assets/xml/objects/object_link_goron.xml index 05336d6db..2fe3906fb 100644 --- a/assets/xml/objects/object_link_goron.xml +++ b/assets/xml/objects/object_link_goron.xml @@ -76,33 +76,33 @@ - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_nuts.xml b/assets/xml/objects/object_link_nuts.xml index 169dc848a..e3dab39da 100644 --- a/assets/xml/objects/object_link_nuts.xml +++ b/assets/xml/objects/object_link_nuts.xml @@ -53,27 +53,27 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_zora.xml b/assets/xml/objects/object_link_zora.xml index e3bbaba95..d36aaa420 100644 --- a/assets/xml/objects/object_link_zora.xml +++ b/assets/xml/objects/object_link_zora.xml @@ -63,27 +63,27 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ma1.xml b/assets/xml/objects/object_ma1.xml index 7001eb84a..3d0ea1fcc 100644 --- a/assets/xml/objects/object_ma1.xml +++ b/assets/xml/objects/object_ma1.xml @@ -63,29 +63,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ma2.xml b/assets/xml/objects/object_ma2.xml index a6554d387..a61eff4e0 100644 --- a/assets/xml/objects/object_ma2.xml +++ b/assets/xml/objects/object_ma2.xml @@ -58,28 +58,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_mk.xml b/assets/xml/objects/object_mk.xml index c927f33de..1ee3741bb 100644 --- a/assets/xml/objects/object_mk.xml +++ b/assets/xml/objects/object_mk.xml @@ -28,18 +28,18 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_mm.xml b/assets/xml/objects/object_mm.xml index 43c0e9b19..baac5425d 100644 --- a/assets/xml/objects/object_mm.xml +++ b/assets/xml/objects/object_mm.xml @@ -39,22 +39,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_mnk.xml b/assets/xml/objects/object_mnk.xml index 8f813ba00..c6e23399d 100644 --- a/assets/xml/objects/object_mnk.xml +++ b/assets/xml/objects/object_mnk.xml @@ -19,11 +19,11 @@ - - - - - + + + + + @@ -82,29 +82,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -118,9 +118,9 @@ - - - - + + + + diff --git a/assets/xml/objects/object_ms.xml b/assets/xml/objects/object_ms.xml index 9d7df53ad..a4a36e149 100644 --- a/assets/xml/objects/object_ms.xml +++ b/assets/xml/objects/object_ms.xml @@ -19,14 +19,14 @@ - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_mu.xml b/assets/xml/objects/object_mu.xml index a1c11fed2..925cb74e9 100644 --- a/assets/xml/objects/object_mu.xml +++ b/assets/xml/objects/object_mu.xml @@ -36,27 +36,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_nb.xml b/assets/xml/objects/object_nb.xml index e0f557f98..e8a695b52 100644 --- a/assets/xml/objects/object_nb.xml +++ b/assets/xml/objects/object_nb.xml @@ -34,13 +34,13 @@ - - - - - - - - + + + + + + + + diff --git a/assets/xml/objects/object_niw.xml b/assets/xml/objects/object_niw.xml index b055a2740..e49426560 100644 --- a/assets/xml/objects/object_niw.xml +++ b/assets/xml/objects/object_niw.xml @@ -18,21 +18,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_oF1d_map.xml b/assets/xml/objects/object_oF1d_map.xml index 9557dc73e..6c3af0778 100644 --- a/assets/xml/objects/object_oF1d_map.xml +++ b/assets/xml/objects/object_oF1d_map.xml @@ -78,24 +78,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ob.xml b/assets/xml/objects/object_ob.xml index 7a75a59f2..0f79703b5 100644 --- a/assets/xml/objects/object_ob.xml +++ b/assets/xml/objects/object_ob.xml @@ -59,24 +59,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_okuta.xml b/assets/xml/objects/object_okuta.xml index 0eebb587e..e71f65a1c 100644 --- a/assets/xml/objects/object_okuta.xml +++ b/assets/xml/objects/object_okuta.xml @@ -34,22 +34,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_osn.xml b/assets/xml/objects/object_osn.xml index 0994d057f..b31660e6a 100644 --- a/assets/xml/objects/object_osn.xml +++ b/assets/xml/objects/object_osn.xml @@ -92,25 +92,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ot.xml b/assets/xml/objects/object_ot.xml index 1fb04a34a..49a8d89ce 100644 --- a/assets/xml/objects/object_ot.xml +++ b/assets/xml/objects/object_ot.xml @@ -30,25 +30,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_owl.xml b/assets/xml/objects/object_owl.xml index 381c0bfd0..6c9d79883 100644 --- a/assets/xml/objects/object_owl.xml +++ b/assets/xml/objects/object_owl.xml @@ -37,27 +37,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + @@ -75,21 +75,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_pamera.xml b/assets/xml/objects/object_pamera.xml index 6ce4c5219..6b457ab8b 100644 --- a/assets/xml/objects/object_pamera.xml +++ b/assets/xml/objects/object_pamera.xml @@ -38,29 +38,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ph.xml b/assets/xml/objects/object_ph.xml index df0cff73d..2e8a8eb29 100644 --- a/assets/xml/objects/object_ph.xml +++ b/assets/xml/objects/object_ph.xml @@ -16,29 +16,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_po.xml b/assets/xml/objects/object_po.xml index 5d66d380c..2cc6e5cbd 100644 --- a/assets/xml/objects/object_po.xml +++ b/assets/xml/objects/object_po.xml @@ -28,26 +28,26 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_po_composer.xml b/assets/xml/objects/object_po_composer.xml index 288dd41c3..ae8ef56e3 100644 --- a/assets/xml/objects/object_po_composer.xml +++ b/assets/xml/objects/object_po_composer.xml @@ -42,17 +42,17 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_po_fusen.xml b/assets/xml/objects/object_po_fusen.xml index 6dd6d1f9b..5885b89a3 100644 --- a/assets/xml/objects/object_po_fusen.xml +++ b/assets/xml/objects/object_po_fusen.xml @@ -18,15 +18,15 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_po_sisters.xml b/assets/xml/objects/object_po_sisters.xml index 6004d6cbf..f42fe1664 100644 --- a/assets/xml/objects/object_po_sisters.xml +++ b/assets/xml/objects/object_po_sisters.xml @@ -37,17 +37,17 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_pp.xml b/assets/xml/objects/object_pp.xml index 63bf541cd..1ac690935 100644 --- a/assets/xml/objects/object_pp.xml +++ b/assets/xml/objects/object_pp.xml @@ -37,32 +37,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -100,32 +100,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_pr.xml b/assets/xml/objects/object_pr.xml index 27a03fdcf..95fc4743c 100644 --- a/assets/xml/objects/object_pr.xml +++ b/assets/xml/objects/object_pr.xml @@ -31,16 +31,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -51,11 +51,11 @@ - - - - - + + + + + diff --git a/assets/xml/objects/object_ps.xml b/assets/xml/objects/object_ps.xml index 9febc5660..f341e95a4 100644 --- a/assets/xml/objects/object_ps.xml +++ b/assets/xml/objects/object_ps.xml @@ -22,18 +22,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_pst.xml b/assets/xml/objects/object_pst.xml index 9d62acba7..3649877ea 100644 --- a/assets/xml/objects/object_pst.xml +++ b/assets/xml/objects/object_pst.xml @@ -7,8 +7,8 @@ - - - + + + diff --git a/assets/xml/objects/object_raf.xml b/assets/xml/objects/object_raf.xml index df3d619d1..26c0741ec 100644 --- a/assets/xml/objects/object_raf.xml +++ b/assets/xml/objects/object_raf.xml @@ -26,17 +26,17 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_rat.xml b/assets/xml/objects/object_rat.xml index 5c979b098..ce32e20cc 100644 --- a/assets/xml/objects/object_rat.xml +++ b/assets/xml/objects/object_rat.xml @@ -14,15 +14,15 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_rb.xml b/assets/xml/objects/object_rb.xml index 3898e8417..a344c5327 100644 --- a/assets/xml/objects/object_rb.xml +++ b/assets/xml/objects/object_rb.xml @@ -22,23 +22,23 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_rs.xml b/assets/xml/objects/object_rs.xml index 5019d9631..01099db47 100644 --- a/assets/xml/objects/object_rs.xml +++ b/assets/xml/objects/object_rs.xml @@ -33,21 +33,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ru2.xml b/assets/xml/objects/object_ru2.xml index 016a610e8..f2d3fd2b0 100644 --- a/assets/xml/objects/object_ru2.xml +++ b/assets/xml/objects/object_ru2.xml @@ -46,29 +46,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_rz.xml b/assets/xml/objects/object_rz.xml index 323393f87..a75e033f0 100644 --- a/assets/xml/objects/object_rz.xml +++ b/assets/xml/objects/object_rz.xml @@ -45,27 +45,27 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_sb.xml b/assets/xml/objects/object_sb.xml index 9fcd76a8f..359cff20d 100644 --- a/assets/xml/objects/object_sb.xml +++ b/assets/xml/objects/object_sb.xml @@ -16,15 +16,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_sdn.xml b/assets/xml/objects/object_sdn.xml index 691a272ee..219436b02 100644 --- a/assets/xml/objects/object_sdn.xml +++ b/assets/xml/objects/object_sdn.xml @@ -44,23 +44,23 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_skb.xml b/assets/xml/objects/object_skb.xml index cafba559e..c9935b64f 100644 --- a/assets/xml/objects/object_skb.xml +++ b/assets/xml/objects/object_skb.xml @@ -36,26 +36,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_snowman.xml b/assets/xml/objects/object_snowman.xml index f92110b3e..91b650a75 100644 --- a/assets/xml/objects/object_snowman.xml +++ b/assets/xml/objects/object_snowman.xml @@ -18,25 +18,25 @@ - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + diff --git a/assets/xml/objects/object_ssh.xml b/assets/xml/objects/object_ssh.xml index a95597ae4..57599fdce 100644 --- a/assets/xml/objects/object_ssh.xml +++ b/assets/xml/objects/object_ssh.xml @@ -29,36 +29,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_st.xml b/assets/xml/objects/object_st.xml index 011d76449..2dabce2f8 100644 --- a/assets/xml/objects/object_st.xml +++ b/assets/xml/objects/object_st.xml @@ -35,36 +35,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_sth.xml b/assets/xml/objects/object_sth.xml index 7b6947b07..c7a0ffd25 100644 --- a/assets/xml/objects/object_sth.xml +++ b/assets/xml/objects/object_sth.xml @@ -22,21 +22,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_stk.xml b/assets/xml/objects/object_stk.xml index 44a311dfb..68e8ae26b 100644 --- a/assets/xml/objects/object_stk.xml +++ b/assets/xml/objects/object_stk.xml @@ -55,28 +55,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tab.xml b/assets/xml/objects/object_tab.xml index 1e741c9aa..9a63c2ed3 100644 --- a/assets/xml/objects/object_tab.xml +++ b/assets/xml/objects/object_tab.xml @@ -38,26 +38,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tanron4.xml b/assets/xml/objects/object_tanron4.xml index 7e48cdf0e..f1002fd22 100644 --- a/assets/xml/objects/object_tanron4.xml +++ b/assets/xml/objects/object_tanron4.xml @@ -9,16 +9,16 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/assets/xml/objects/object_test3.xml b/assets/xml/objects/object_test3.xml index fc6e026a9..6b0a5349c 100644 --- a/assets/xml/objects/object_test3.xml +++ b/assets/xml/objects/object_test3.xml @@ -42,27 +42,27 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_thiefbird.xml b/assets/xml/objects/object_thiefbird.xml index 31f0213c5..e7cb3ac91 100644 --- a/assets/xml/objects/object_thiefbird.xml +++ b/assets/xml/objects/object_thiefbird.xml @@ -44,23 +44,23 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tite.xml b/assets/xml/objects/object_tite.xml index eec5b05d0..681b732e8 100644 --- a/assets/xml/objects/object_tite.xml +++ b/assets/xml/objects/object_tite.xml @@ -25,30 +25,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tk.xml b/assets/xml/objects/object_tk.xml index 813b0fb24..0c0ea3831 100644 --- a/assets/xml/objects/object_tk.xml +++ b/assets/xml/objects/object_tk.xml @@ -43,23 +43,23 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tl.xml b/assets/xml/objects/object_tl.xml index 656d70743..6397283af 100644 --- a/assets/xml/objects/object_tl.xml +++ b/assets/xml/objects/object_tl.xml @@ -7,10 +7,10 @@ - - - - + + + + @@ -43,19 +43,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_toryo.xml b/assets/xml/objects/object_toryo.xml index 101db5839..45d3da100 100644 --- a/assets/xml/objects/object_toryo.xml +++ b/assets/xml/objects/object_toryo.xml @@ -32,22 +32,22 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_trt.xml b/assets/xml/objects/object_trt.xml index ecde36e18..a0d83076e 100644 --- a/assets/xml/objects/object_trt.xml +++ b/assets/xml/objects/object_trt.xml @@ -63,32 +63,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tru.xml b/assets/xml/objects/object_tru.xml index 0ca1acff4..dd0e6d20c 100644 --- a/assets/xml/objects/object_tru.xml +++ b/assets/xml/objects/object_tru.xml @@ -76,33 +76,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tsn.xml b/assets/xml/objects/object_tsn.xml index 63c03c84c..bd83a3be5 100644 --- a/assets/xml/objects/object_tsn.xml +++ b/assets/xml/objects/object_tsn.xml @@ -31,23 +31,23 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_uch.xml b/assets/xml/objects/object_uch.xml index 86f2a4646..a58af5654 100644 --- a/assets/xml/objects/object_uch.xml +++ b/assets/xml/objects/object_uch.xml @@ -28,19 +28,19 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_um.xml b/assets/xml/objects/object_um.xml index 693c704d3..5717124a7 100644 --- a/assets/xml/objects/object_um.xml +++ b/assets/xml/objects/object_um.xml @@ -49,28 +49,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_utubo.xml b/assets/xml/objects/object_utubo.xml index 97a7095c9..68cd3e196 100644 --- a/assets/xml/objects/object_utubo.xml +++ b/assets/xml/objects/object_utubo.xml @@ -18,22 +18,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_vm.xml b/assets/xml/objects/object_vm.xml index b07534c65..b6c1cdfa2 100644 --- a/assets/xml/objects/object_vm.xml +++ b/assets/xml/objects/object_vm.xml @@ -15,16 +15,16 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/assets/xml/objects/object_wallmaster.xml b/assets/xml/objects/object_wallmaster.xml index 249af61ee..d6ab1aa02 100644 --- a/assets/xml/objects/object_wallmaster.xml +++ b/assets/xml/objects/object_wallmaster.xml @@ -30,31 +30,31 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_warp1.xml b/assets/xml/objects/object_warp1.xml index 50d4c527a..814334792 100644 --- a/assets/xml/objects/object_warp1.xml +++ b/assets/xml/objects/object_warp1.xml @@ -11,28 +11,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_wdhand.xml b/assets/xml/objects/object_wdhand.xml index 22e12cfa0..bcd5b0ce3 100644 --- a/assets/xml/objects/object_wdhand.xml +++ b/assets/xml/objects/object_wdhand.xml @@ -16,13 +16,13 @@ - - - - - - - - + + + + + + + + diff --git a/assets/xml/objects/object_wf.xml b/assets/xml/objects/object_wf.xml index 56c9e1621..4775552e2 100644 --- a/assets/xml/objects/object_wf.xml +++ b/assets/xml/objects/object_wf.xml @@ -27,28 +27,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -81,28 +81,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_wiz.xml b/assets/xml/objects/object_wiz.xml index 7f41954cf..d9c8a1589 100644 --- a/assets/xml/objects/object_wiz.xml +++ b/assets/xml/objects/object_wiz.xml @@ -78,25 +78,25 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zl1.xml b/assets/xml/objects/object_zl1.xml index 759b35867..04d4ae406 100644 --- a/assets/xml/objects/object_zl1.xml +++ b/assets/xml/objects/object_zl1.xml @@ -57,24 +57,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zl4.xml b/assets/xml/objects/object_zl4.xml index f13487f98..dafdef8cd 100644 --- a/assets/xml/objects/object_zl4.xml +++ b/assets/xml/objects/object_zl4.xml @@ -51,24 +51,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zm.xml b/assets/xml/objects/object_zm.xml index 022efcf27..f6f1b95e5 100644 --- a/assets/xml/objects/object_zm.xml +++ b/assets/xml/objects/object_zm.xml @@ -38,24 +38,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zo.xml b/assets/xml/objects/object_zo.xml index f0926dd2b..8fc22ae46 100644 --- a/assets/xml/objects/object_zo.xml +++ b/assets/xml/objects/object_zo.xml @@ -42,26 +42,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zob.xml b/assets/xml/objects/object_zob.xml index 22400d46e..bc4d61c6a 100644 --- a/assets/xml/objects/object_zob.xml +++ b/assets/xml/objects/object_zob.xml @@ -44,30 +44,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zod.xml b/assets/xml/objects/object_zod.xml index f1152e2ac..3e0b6567a 100644 --- a/assets/xml/objects/object_zod.xml +++ b/assets/xml/objects/object_zod.xml @@ -35,16 +35,16 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_zog.xml b/assets/xml/objects/object_zog.xml index 55f169ad1..627bb676a 100644 --- a/assets/xml/objects/object_zog.xml +++ b/assets/xml/objects/object_zog.xml @@ -85,28 +85,28 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zoraegg.xml b/assets/xml/objects/object_zoraegg.xml index 0835e2698..367d2df76 100644 --- a/assets/xml/objects/object_zoraegg.xml +++ b/assets/xml/objects/object_zoraegg.xml @@ -16,13 +16,13 @@ - - - - - - - + + + + + + + diff --git a/assets/xml/objects/object_zos.xml b/assets/xml/objects/object_zos.xml index 5af477773..1f5a2a542 100644 --- a/assets/xml/objects/object_zos.xml +++ b/assets/xml/objects/object_zos.xml @@ -45,24 +45,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zov.xml b/assets/xml/objects/object_zov.xml index e485291b3..abbc52268 100644 --- a/assets/xml/objects/object_zov.xml +++ b/assets/xml/objects/object_zov.xml @@ -54,28 +54,28 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + From fe32df0e8210c6a0259da3eb32775d2c57add223 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Thu, 10 Mar 2022 10:37:27 +1100 Subject: [PATCH 076/257] Document `Actor_DrawDamageEffects` (#645) * Being documenting `Actor_DrawDamageEffects` and apply to actors * More doc progress * Small cleanup * Document display lists * more cleanup * Fix Typo * PR Review * Shock -> Spark * Missed one * Missed another * Fix dust textures * Remove `_tex` from `light_orb_tex` (so that it matches convention) * electric stun -> electric spark * Fix mistake * Fix float * spark -> sparks where applicable * Missed even more shocks... * Name `drawDmgEffTimer` for consistency * Fix BSS --- assets/xml/objects/gameplay_keep.xml | 51 ++-- include/functions.h | 2 +- include/variables.h | 1 - include/z64actor.h | 12 + src/code/z_actor.c | 244 +++++++++--------- src/code/z_lifemeter.c | 1 + src/overlays/actors/ovl_Boss_02/z_boss_02.c | 4 +- src/overlays/actors/ovl_Boss_06/z_boss_06.c | 4 +- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 4 +- src/overlays/actors/ovl_En_Am/z_en_am.c | 13 +- src/overlays/actors/ovl_En_Am/z_en_am.h | 4 +- .../actors/ovl_En_Bigokuta/z_en_bigokuta.c | 46 ++-- .../actors/ovl_En_Bigokuta/z_en_bigokuta.h | 8 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 19 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h | 5 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 65 ++--- .../actors/ovl_En_Bigslime/z_en_bigslime.h | 8 +- .../actors/ovl_En_Dekunuts/z_en_dekunuts.c | 62 ++--- .../actors/ovl_En_Dekunuts/z_en_dekunuts.h | 10 +- .../actors/ovl_En_Dinofos/z_en_dinofos.c | 79 +++--- .../actors/ovl_En_Dinofos/z_en_dinofos.h | 15 +- .../actors/ovl_En_Dodongo/z_en_dodongo.c | 91 +++---- .../actors/ovl_En_Dodongo/z_en_dodongo.h | 10 +- .../actors/ovl_En_Firefly/z_en_firefly.c | 65 ++--- .../actors/ovl_En_Firefly/z_en_firefly.h | 10 +- .../actors/ovl_En_Floormas/z_en_floormas.c | 79 +++--- .../actors/ovl_En_Floormas/z_en_floormas.h | 10 +- src/overlays/actors/ovl_En_Fz/z_en_fz.c | 44 ++-- src/overlays/actors/ovl_En_Fz/z_en_fz.h | 6 +- .../actors/ovl_En_Hint_Skb/z_en_hint_skb.c | 98 +++---- .../actors/ovl_En_Hint_Skb/z_en_hint_skb.h | 12 +- src/overlays/actors/ovl_En_Kame/z_en_kame.c | 61 ++--- src/overlays/actors/ovl_En_Kame/z_en_kame.h | 10 +- .../actors/ovl_En_Karebaba/z_en_karebaba.c | 78 +++--- .../actors/ovl_En_Karebaba/z_en_karebaba.h | 10 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 65 ++--- .../actors/ovl_En_Pametfrog/z_en_pametfrog.h | 15 +- .../actors/ovl_En_Peehat/z_en_peehat.c | 77 +++--- .../actors/ovl_En_Peehat/z_en_peehat.h | 10 +- .../ovl_En_Po_Sisters/z_en_po_sisters.c | 29 ++- .../ovl_En_Po_Sisters/z_en_po_sisters.h | 6 +- src/overlays/actors/ovl_En_Poh/z_en_poh.c | 31 +-- src/overlays/actors/ovl_En_Poh/z_en_poh.h | 6 +- src/overlays/actors/ovl_En_Pr/z_en_pr.c | 19 +- src/overlays/actors/ovl_En_Pr/z_en_pr.h | 6 +- .../actors/ovl_En_Rail_Skb/z_en_rail_skb.c | 102 ++++---- .../actors/ovl_En_Rail_Skb/z_en_rail_skb.h | 12 +- .../actors/ovl_En_Railgibud/z_en_railgibud.c | 47 ++-- .../actors/ovl_En_Railgibud/z_en_railgibud.h | 8 +- src/overlays/actors/ovl_En_Rd/z_en_rd.c | 38 +-- src/overlays/actors/ovl_En_Rd/z_en_rd.h | 8 +- src/overlays/actors/ovl_En_Rr/z_en_rr.c | 58 +++-- src/overlays/actors/ovl_En_Rr/z_en_rr.h | 10 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 92 +++---- src/overlays/actors/ovl_En_Skb/z_en_skb.h | 12 +- src/overlays/actors/ovl_En_St/z_en_st.c | 61 ++--- src/overlays/actors/ovl_En_St/z_en_st.h | 4 +- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 58 +++-- src/overlays/actors/ovl_En_Sw/z_en_sw.h | 4 +- .../ovl_En_Talk_Gibud/z_en_talk_gibud.c | 53 ++-- .../ovl_En_Talk_Gibud/z_en_talk_gibud.h | 8 +- .../actors/ovl_En_Thiefbird/z_en_thiefbird.c | 68 ++--- .../actors/ovl_En_Thiefbird/z_en_thiefbird.h | 10 +- src/overlays/actors/ovl_En_Tite/z_en_tite.c | 91 +++---- src/overlays/actors/ovl_En_Tite/z_en_tite.h | 10 +- src/overlays/actors/ovl_En_Wf/z_en_wf.c | 59 ++--- src/overlays/actors/ovl_En_Wf/z_en_wf.h | 10 +- tools/actorfixer.py | 3 +- tools/disasm/functions.txt | 2 +- tools/disasm/variables.txt | 2 +- tools/sizes/code_functions.csv | 2 +- 71 files changed, 1190 insertions(+), 1147 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 265f1d560..802ac6843 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -903,12 +903,12 @@ - - - - - - + + + + + + @@ -1082,7 +1082,7 @@ - + @@ -1108,13 +1108,13 @@ - - + + - - + + @@ -1405,23 +1405,28 @@ - - - - - - - - + + + + + + + + + + + - - - - + + + + + + diff --git a/include/functions.h b/include/functions.h index 05262d2c4..766c12eea 100644 --- a/include/functions.h +++ b/include/functions.h @@ -799,7 +799,7 @@ void func_800BE504(Actor* actor, ColliderCylinder* collider); void func_800BE568(Actor* actor, ColliderSphere* collider); void func_800BE5CC(Actor* actor, ColliderJntSph* collider, s32 colliderIndex); s32 func_800BE63C(struct EnBox* chest); -void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 arg3, f32 effectScale, f32 steamScale, f32 effectAlpha, u8 mode); +void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 limbPosCount, f32 effectScale, f32 frozenSteamScale, f32 effectAlpha, u8 type); void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s32 limbPosCount, s32 effectsPerLimb, f32 scale, f32 scaleRange); void ActorOverlayTable_FaultPrint(void* arg0, void* arg1); diff --git a/include/variables.h b/include/variables.h index 7eafe0d2f..db29d0c92 100644 --- a/include/variables.h +++ b/include/variables.h @@ -428,7 +428,6 @@ extern Color_RGBA8 actorDefaultHitColor; // extern UNK_TYPE2 D_801AEE4C; extern Gfx D_801AEF88[]; extern Gfx D_801AEFA0[]; -// extern UNK_TYPE1 D_801AEFA8; // extern UNK_TYPE1 D_801AEFB8; // extern UNK_TYPE1 D_801AEFBC; // extern UNK_TYPE1 D_801AEFC0; diff --git a/include/z64actor.h b/include/z64actor.h index 7a7556ed0..ee73ae8af 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -387,6 +387,18 @@ typedef struct ActorContext { /* 0x26C */ Input unk_26C; } ActorContext; // size = 0x284 +typedef enum { + /* 00 */ ACTOR_DRAW_DMGEFF_FIRE, + /* 01 */ ACTOR_DRAW_DMGEFF_BLUE_FIRE, + /* 10 */ ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX = 10, + /* 11 */ ACTOR_DRAW_DMGEFF_FROZEN_SFX, + /* 20 */ ACTOR_DRAW_DMGEFF_LIGHT_ORBS = 20, + /* 21 */ ACTOR_DRAW_DMGEFF_BLUE_LIGHT_ORBS, + /* 30 */ ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL = 30, + /* 31 */ ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM, + /* 32 */ ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE +} ActorDrawDamageEffectType; + typedef enum { /* 0x000 */ ACTOR_PLAYER, /* 0x001 */ ACTOR_EN_TEST, diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 04f24e66f..c8e490311 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -4446,39 +4446,42 @@ s32 func_800BE63C(struct EnBox* chest) { return false; } -TexturePtr D_801AEFA8[] = { - gameplay_keep_Tex_091DE0, - gameplay_keep_Tex_091FE0, - gameplay_keep_Tex_0921E0, - gameplay_keep_Tex_0923E0, +TexturePtr sElectricSparkTextures[] = { + gElectricSpark1Tex, + gElectricSpark2Tex, + gElectricSpark3Tex, + gElectricSpark4Tex, }; -// Draw common damageEffects -void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 arg3, f32 effectScale, f32 steamScale, - f32 effectAlpha, u8 mode) { +/** + * Draw common damage effects applied to each limb provided in limbPos + */ +void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 limbPosCount, f32 effectScale, + f32 frozenSteamScale, f32 effectAlpha, u8 type) { if (effectAlpha > 0.001f) { - s32 temp_v1_3; - s16 i; - MtxF* temp_s3; + s32 twoTexScrollParam; + s16 limbIndex; + MtxF* currentMatrix; f32 alpha; - f32 sp124; - f32 sp120; - f32 sp11C; - f32 sp118; - Vec3f* limbAux = limbPos; - u32 sp110 = globalCtx->gameplayFrames; - f32 sp74; + f32 frozenScale; + f32 lightOrbsScale; + f32 electricSparksScale; + f32 steamScale; + Vec3f* limbPosStart = limbPos; + u32 gameplayFrames = globalCtx->gameplayFrames; + f32 effectAlphaScaled; - temp_s3 = Matrix_GetCurrentState(); + currentMatrix = Matrix_GetCurrentState(); + // Apply sfx along with damage effect if ((actor != NULL) && (effectAlpha > 0.05f) && (globalCtx->gameOverCtx.state == 0)) { - if (mode == 0) { + if (type == ACTOR_DRAW_DMGEFF_FIRE) { Actor_PlaySfxAtPos(actor, NA_SE_EV_BURN_OUT - SFX_FLAG); - } else if (mode == 1) { + } else if (type == ACTOR_DRAW_DMGEFF_BLUE_FIRE) { Actor_PlaySfxAtPos(actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); - } else if (mode == 0xB) { + } else if (type == ACTOR_DRAW_DMGEFF_FROZEN_SFX) { Actor_PlaySfxAtPos(actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); - } else if ((mode == 0x14) || (mode == 0x15)) { + } else if ((type == ACTOR_DRAW_DMGEFF_LIGHT_ORBS) || (type == ACTOR_DRAW_DMGEFF_BLUE_LIGHT_ORBS)) { Actor_PlaySfxAtPos(actor, NA_SE_EN_COMMON_DEADLIGHT - SFX_FLAG); } } @@ -4487,58 +4490,60 @@ void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 func_8012C2DC(globalCtx->state.gfxCtx); - switch (mode) { - case 0xA: - case 0xB: - sp124 = ((KREG(19) * 0.01f) + 2.3f) * effectScale; - sp118 = ((KREG(28) * 0.0001f) + 0.035f) * steamScale; + switch (type) { + case ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX: + case ACTOR_DRAW_DMGEFF_FROZEN_SFX: + frozenScale = ((KREG(19) * 0.01f) + 2.3f) * effectScale; + steamScale = ((KREG(28) * 0.0001f) + 0.035f) * frozenSteamScale; func_800BCC68(limbPos, globalCtx); + // Setup to draw ice over frozen actor + gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, sp110 & 0xFF, 0x20, 0x10, 1, 0, - (sp110 * 2) & 0xFF, 0x40, 0x20)); - + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, gameplayFrames & 0xFF, 32, 16, 1, 0, + (gameplayFrames * 2) & 0xFF, 64, 32)); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, 255); + gSPDisplayList(POLY_XLU_DISP++, gFrozenIceDL); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_050648); + effectAlphaScaled = effectAlpha * 255.0f; - sp74 = effectAlpha * 255.0f; - for (i = 0; i < arg3; i++) { - alpha = i & 3; - alpha = sp74 - (30.0f * alpha); - if (sp74 < (30.0f * (i & 3))) { + // Apply and draw ice over each limb of frozen actor + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + alpha = limbIndex & 3; + alpha = effectAlphaScaled - (30.0f * alpha); + if (effectAlphaScaled < (30.0f * (limbIndex & 3))) { alpha = 0.0f; } if (alpha > 255.0f) { alpha = 255.0f; } - gDPSetEnvColor(POLY_XLU_DISP++, KREG(20) + 0xC8, KREG(21) + 0xC8, KREG(22) + 0xFF, (u8)alpha); + gDPSetEnvColor(POLY_XLU_DISP++, KREG(20) + 200, KREG(21) + 200, KREG(22) + 255, (u8)alpha); Matrix_InsertTranslation(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); - Matrix_Scale(sp124, sp124, sp124, MTXMODE_APPLY); - if (i & 1) { + Matrix_Scale(frozenScale, frozenScale, frozenScale, MTXMODE_APPLY); + + if (limbIndex & 1) { Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); } - if (i & 2) { + + if (limbIndex & 2) { Matrix_InsertZRotation_f(M_PI, MTXMODE_APPLY); } gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0506E0); - - limbPos++; + gSPDisplayList(POLY_XLU_DISP++, gFrozenIceVtxDL); } - limbPos = limbAux; + limbPos = limbPosStart; // reset limbPos + + // Setup to draw steam over frozen actor gDPSetColorDither(POLY_XLU_DISP++, G_CD_BAYER); - gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_PATTERN); - - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051180); + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamDL); alpha = effectAlpha * 100.0f; if (alpha > 100.0f) { @@ -4547,158 +4552,165 @@ void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (u8)alpha); - for (i = 0; i < arg3; i++) { - temp_v1_3 = ((i * 3) + sp110); + // Apply and draw steam over each limb of frozen actor + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + twoTexScrollParam = ((limbIndex * 3) + gameplayFrames); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, temp_v1_3 * 3, temp_v1_3 * -0xC, 0x20, 0x40, - 1, 0, 0, 0x20, 0x20)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, twoTexScrollParam * 3, + twoTexScrollParam * -12, 32, 64, 1, 0, 0, 32, 32)); Matrix_InsertTranslation(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_Scale(sp118, sp118, 1.0f, MTXMODE_APPLY); + Matrix_Scale(steamScale, steamScale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051238); - - limbPos++; + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamVtxDL); } break; - case 0x0: - case 0x1: - if (mode == 0) { + case ACTOR_DRAW_DMGEFF_FIRE: + case ACTOR_DRAW_DMGEFF_BLUE_FIRE: + if (type == ACTOR_DRAW_DMGEFF_FIRE) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 0); } else { gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, 0); - mode = 0xFF; + // Reuse type for blue primitive color + type = 255; } Matrix_SetCurrentState(&globalCtx->billboardMtxF); Matrix_Scale((effectScale * 0.005f) * 1.35f, (effectScale * 0.005f), (effectScale * 0.005f) * 1.35f, MTXMODE_APPLY); - sp74 = effectAlpha * 255.0f; + effectAlphaScaled = effectAlpha * 255.0f; - for (i = 0; i < arg3; i++) { - alpha = i & 3; - alpha = sp74 - 30.0f * alpha; - if (sp74 < 30.0f * (i & 3)) { + // Apply and draw fire on every limb + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + alpha = limbIndex & 3; + alpha = effectAlphaScaled - 30.0f * alpha; + if (effectAlphaScaled < 30.0f * (limbIndex & 3)) { alpha = 0.0f; } if (alpha > 255.0f) { alpha = 255.0f; } - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, mode, (u8)alpha); + // Use type for blue primitive color + // = 0 for ACTOR_DRAW_DMGEFF_FIRE + // = 255 for ACTOR_DRAW_DMGEFF_BLUE_FIRE + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, type, (u8)alpha); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, - ((i * 10 + sp110) * -0x14) & 0x1FF, 0x20, 0x80)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + ((limbIndex * 10 + gameplayFrames) * -20) & 0x1FF, 32, 128)); Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); - temp_s3->mf[3][0] = limbPos->x; - temp_s3->mf[3][1] = limbPos->y; - temp_s3->mf[3][2] = limbPos->z; + currentMatrix->mf[3][0] = limbPos->x; + currentMatrix->mf[3][1] = limbPos->y; + currentMatrix->mf[3][2] = limbPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); - - limbPos++; } break; - case 0x14: - case 0x15: - sp120 = ((KREG(19) * 0.01f) + 4.0f) * effectScale; + case ACTOR_DRAW_DMGEFF_LIGHT_ORBS: + case ACTOR_DRAW_DMGEFF_BLUE_LIGHT_ORBS: - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023348); + // Setup to draw light orbs on actor + + lightOrbsScale = ((KREG(19) * 0.01f) + 4.0f) * effectScale; + + gSPDisplayList(POLY_XLU_DISP++, gLightOrb1DL); alpha = effectAlpha * 255.0f; if (alpha > 255.0f) { alpha = 255.0f; } - if (mode == 0x15) { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 0xFF), (u8)(sREG(17) + 0xFF), - (u8)(sREG(18) + 0xFF), (u8)alpha); + if (type == ACTOR_DRAW_DMGEFF_BLUE_LIGHT_ORBS) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 255), (u8)(sREG(17) + 255), + (u8)(sREG(18) + 255), (u8)alpha); - gDPSetEnvColor(POLY_XLU_DISP++, (u8)sREG(19), (u8)(sREG(20) + 0xFF), (u8)(sREG(21) + 0xFF), 0x80); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)sREG(19), (u8)(sREG(20) + 255), (u8)(sREG(21) + 255), 128); } else { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 100, 128); } - Matrix_SetCurrentState(&globalCtx->billboardMtxF); - Matrix_Scale(sp120, sp120, 1.0f, MTXMODE_APPLY); - for (i = 0; i < arg3; i++) { + Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Scale(lightOrbsScale, lightOrbsScale, 1.0f, MTXMODE_APPLY); + + // Apply and draw a light orb over each limb of frozen actor + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { Matrix_InsertZRotation_f(randPlusMinusPoint5Scaled(2 * M_PI), MTXMODE_APPLY); - temp_s3->mf[3][0] = limbPos->x; - temp_s3->mf[3][1] = limbPos->y; - temp_s3->mf[3][2] = limbPos->z; + currentMatrix->mf[3][0] = limbPos->x; + currentMatrix->mf[3][1] = limbPos->y; + currentMatrix->mf[3][2] = limbPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023428); - - limbPos++; + gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } break; - case 0x1E: - case 0x1F: - case 0x20: - if (mode == 0x1E) { - sp11C = (KREG(19) * 0.01f + 1.0f) * effectScale; - } else if (mode == 0x1F) { - sp11C = (KREG(19) * 0.01f + 1.5f) * effectScale; + case ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL: + case ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM: + case ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE: + if (type == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL) { + electricSparksScale = (KREG(19) * 0.01f + 1.0f) * effectScale; + } else if (type == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM) { + electricSparksScale = (KREG(19) * 0.01f + 1.5f) * effectScale; } else { - sp11C = (KREG(19) * 0.01f + 2.0f) * effectScale; + electricSparksScale = (KREG(19) * 0.01f + 2.0f) * effectScale; } - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_801AEFA8[globalCtx->gameplayFrames & 3])); + gSPSegment(POLY_XLU_DISP++, 0x08, + Lib_SegmentedToVirtual(sElectricSparkTextures[globalCtx->gameplayFrames % 4])); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023480); + gSPDisplayList(POLY_XLU_DISP++, gElectricSparkDL); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 0xFF), (u8)(sREG(17) + 0xFF), - (u8)(sREG(18) + 0x96), (u8)(sREG(19) + 0xFF)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 255), (u8)(sREG(17) + 255), (u8)(sREG(18) + 150), + (u8)(sREG(19) + 255)); - gDPSetEnvColor(POLY_XLU_DISP++, (u8)(sREG(20) + 0xFF), (u8)(sREG(21) + 0xFF), (u8)sREG(22), - (u8)sREG(23)); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(sREG(20) + 255), (u8)(sREG(21) + 255), (u8)sREG(22), (u8)sREG(23)); Matrix_SetCurrentState(&globalCtx->billboardMtxF); - Matrix_Scale(sp11C, sp11C, sp11C, MTXMODE_APPLY); + Matrix_Scale(electricSparksScale, electricSparksScale, electricSparksScale, MTXMODE_APPLY); - for (i = 0; i < arg3; i++) { + // Every limb draws two electric sparks at random orientations + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + // first electric spark Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); - temp_s3->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; - temp_s3->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; - temp_s3->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; + currentMatrix->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; + currentMatrix->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; + currentMatrix->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0234F0); + gSPDisplayList(POLY_XLU_DISP++, gElectricSparkVtxDL); + // second electric spark Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); - temp_s3->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; - temp_s3->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; - temp_s3->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; + currentMatrix->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; + currentMatrix->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; + currentMatrix->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0234F0); - - limbPos++; + gSPDisplayList(POLY_XLU_DISP++, gElectricSparkVtxDL); } + break; } diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index 386adeb13..17e73dc34 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -1,5 +1,6 @@ #include "global.h" #include "interface/parameter_static/parameter_static.h" +#include "prevent_bss_reordering.h" static s16 sHeartsPrimColors[3][3] = { { 255, 70, 50 }, { 255, 190, 0 }, { 100, 100, 255 } }; static s16 sHeartsEnvColors[3][3] = { { 50, 40, 60 }, { 255, 0, 0 }, { 0, 0, 255 } }; diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index ea65880de..6500f3ba6 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -1591,7 +1591,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { for (i = 0, flag = false; i < ARRAY_COUNT(D_809E0438); i++, effect++) { if (effect->unk_24 == 4) { if (!flag) { //! @bug - dev forgot to set flag to 1, should only apply to first entry? - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023348); + gSPDisplayList(POLY_XLU_DISP++, gLightOrb1DL); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); } @@ -1603,7 +1603,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023428); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } } diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index 262bc1979..b6cf7d2d1 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -642,7 +642,7 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { this->actor.world.pos.y + 84.0f + this->unk_1B4, (this->actor.world.pos.z - 2.0f) + spE0, MTXMODE_NEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023348); + gSPDisplayList(POLY_XLU_DISP++, gLightOrb1DL); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, (u8)((140.0f * sp68) + 115.0f), temp_s2); gDPSetEnvColor(POLY_XLU_DISP++, 255, 205, (u8)((100.0f * sp68) + 65.0f), 128); @@ -650,7 +650,7 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_InsertZRotation_s(globalCtx->gameplayFrames * 64, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023428); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index 629ec5668..e15122688 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -655,7 +655,7 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { break; } - gSPDisplayList(POLY_XLU_DISP++, &gameplay_keep_DL_023348); + gSPDisplayList(POLY_XLU_DISP++, &gLightOrb1DL); Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); @@ -667,7 +667,7 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { if (this->actor.params == DEMO_KANKYO_TYPE_GIANTS) { gSPDisplayList(POLY_XLU_DISP++, object_bubble_DL_001000); } else { - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023428); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } } } diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.c b/src/overlays/actors/ovl_En_Am/z_en_am.c index 083bcfa41..c5b9381f6 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -477,8 +477,8 @@ s32 EnAm_UpdateDamage(EnAm* this, GlobalContext* globalCtx) { } this->enemyCollider.base.atFlags &= ~AT_HIT; if (this->actor.colChkInfo.damageEffect == 0x4) { - this->effectScale = 0.7f; - this->effectAlpha = 4.0f; + this->drawDmgEffScale = 0.7f; + this->drawDmgEffAlpha = 4.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->enemyCollider.info.bumper.hitPos.x, this->enemyCollider.info.bumper.hitPos.y, this->enemyCollider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -521,9 +521,9 @@ void EnAm_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->enemyCollider.base); } - Math_StepToF(&this->effectAlpha, 0.0f, 0.05f); - this->effectScale = (this->effectAlpha + 1.0f) * 0.35f; - this->effectScale = (this->effectScale > 0.7f) ? 0.7f : this->effectScale; + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.35f; + this->drawDmgEffScale = (this->drawDmgEffScale > 0.7f) ? 0.7f : this->drawDmgEffScale; } void EnAm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { @@ -566,6 +566,7 @@ void EnAm_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = &gfx[2]; SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, EnAm_PostLimbDraw, &this->actor); - func_800BE680(globalCtx, &this->actor, this->limbPos, 13, this->effectScale, 0.0f, this->effectAlpha, 20); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + 0.0f, this->drawDmgEffAlpha, ACTOR_DRAW_DMGEFF_LIGHT_ORBS); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.h b/src/overlays/actors/ovl_En_Am/z_en_am.h index 02ba4dd4a..2199a832f 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.h +++ b/src/overlays/actors/ovl_En_Am/z_en_am.h @@ -20,8 +20,8 @@ typedef struct EnAm { /* 0x023A */ s16 unkFlag; /* 0x023C */ s16 armosYaw; // Yaw of Armos /* 0x0240 */ f32 speed; // Hopping speed of Armos - /* 0x0244 */ f32 effectAlpha; - /* 0x0248 */ f32 effectScale; + /* 0x0244 */ f32 drawDmgEffAlpha; + /* 0x0248 */ f32 drawDmgEffScale; /* 0x024C */ Vec3f limbPos[13]; /* 0x02E8 */ ColliderCylinder enemyCollider; // Collider for when Armos is Hostile /* 0x0334 */ ColliderCylinder interactCollider; // Collider for when an interactable Armos is docile diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c index 019332000..10ea3a7a2 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -43,11 +43,6 @@ const ActorInit En_Bigokuta_InitVars = { (ActorFunc)EnBigokuta_Draw, }; -typedef enum { - BIGOCTO_DRAWEFFECT_ICE = 10, - BIGOCTO_DRAWEFFECT_LIGHT_ORBS = 20, -} EnBigokutaDrawEffect; - static ColliderCylinderInit sShellCylinderInit = { { COLTYPE_HARD, @@ -373,8 +368,8 @@ void EnBigokuta_PlayDeathCutscene(EnBigokuta* this, GlobalContext* globalCtx) { if (this->timer != 0) { this->timer--; if (this->timer == 0) { - this->drawEffect = 0; - this->drawEffectAlpha = 0.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.5f, 0.35f); EnBigokuta_SetupDeathEffects(this); } @@ -388,7 +383,7 @@ void EnBigokuta_PlayDeathCutscene(EnBigokuta* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x20; } - if (this->drawEffect == BIGOCTO_DRAWEFFECT_ICE) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->timer = 3; } else { EnBigokuta_SetupDeathEffects(this); @@ -466,8 +461,8 @@ void EnBigokuta_PlayDeathEffects(EnBigokuta* this, GlobalContext* globalCtx) { } } - if (this->drawEffectAlpha > 0.0f) { - this->drawEffectAlpha = this->actor.scale.y * 30.30303f; + if (this->drawDmgEffAlpha > 0.0f) { + this->drawDmgEffAlpha = this->actor.scale.y * 30.30303f; } } } else { @@ -494,14 +489,14 @@ void EnBigokuta_CheckOneHitKill(EnBigokuta* this, GlobalContext* globalCtx) { if (this->bodyCollider.base.acFlags & AC_HIT) { if (this->bodyCollider.info.acHitInfo->toucher.dmgFlags & 0x1000) { // Ice Arrow - this->drawEffect = BIGOCTO_DRAWEFFECT_ICE; - this->drawEffectScale = 1.2f; - this->drawEffectSteamScale = 1.8000001f; - this->drawEffectAlpha = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 1.2f; + this->drawDmgEffFrozenSteamScale = 1.8000001f; + this->drawDmgEffAlpha = 1.0f; } else if (this->bodyCollider.info.acHitInfo->toucher.dmgFlags & 0x2000) { // Light Arrow - this->drawEffect = BIGOCTO_DRAWEFFECT_LIGHT_ORBS; - this->drawEffectScale = 1.2f; - this->drawEffectAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 1.2f; + this->drawDmgEffAlpha = 4.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->bodyCollider.info.bumper.hitPos.x, this->bodyCollider.info.bumper.hitPos.y, this->bodyCollider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -546,12 +541,12 @@ void EnBigokuta_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetFocus(&this->actor, 82.5f); } - if (this->drawEffectAlpha > 0.0f) { - if (this->drawEffect != BIGOCTO_DRAWEFFECT_ICE) { - Math_StepToF(&this->drawEffectAlpha, 0.0f, 0.05f); - this->drawEffectScale = (this->drawEffectAlpha + 1.0f) * 0.6f; - this->drawEffectScale = CLAMP_MAX(this->drawEffectScale, 1.2f); - } else if (!Math_StepToF(&this->drawEffectSteamScale, 1.2f, 0.030000001f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.6f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 1.2f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 1.2f, 0.030000001f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -676,7 +671,8 @@ void EnBigokuta_Draw(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.dListCount, NULL, EnBigokuta_PostLimbDraw, &this->actor, &gfx[2]); } - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawEffectScale, - this->drawEffectSteamScale, this->drawEffectAlpha, this->drawEffect); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); + CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h index ac0cb0158..0f07c4d7f 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h @@ -37,15 +37,15 @@ typedef struct EnBigokuta { /* 0x0144 */ EnBigokutaUnkFunc unkFunc; // possibly something to do with photographing /* 0x0148 */ SkelAnime skelAnime; /* 0x018C */ EnBigokutaActionFunc actionFunc; - /* 0x0190 */ u8 drawEffect; + /* 0x0190 */ u8 drawDmgEffType; /* 0x0192 */ s16 timer; /* 0x0194 */ s16 camId; /* 0x0196 */ s16 cutscene; /* 0x0198 */ Vec3s jointTable[BIGOKUTA_LIMB_MAX]; /* 0x0210 */ Vec3s morphTable[BIGOKUTA_LIMB_MAX]; - /* 0x0288 */ f32 drawEffectAlpha; - /* 0x028C */ f32 drawEffectScale; - /* 0x0290 */ f32 drawEffectSteamScale; // only affects DRAWEFFECT_ICE + /* 0x0288 */ f32 drawDmgEffAlpha; + /* 0x028C */ f32 drawDmgEffScale; + /* 0x0290 */ f32 drawDmgEffFrozenSteamScale; // only affects DRAWEFFECT_ICE /* 0x0294 */ Vec3f playerPos; /* 0x02A0 */ Vec3f playerHoldPos; /* 0x02AC */ Vec3f camAt; diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index 6e2ca4186..ac5b19ecf 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -1136,8 +1136,8 @@ s32 EnBigpo_ApplyDamage(EnBigpo* this, GlobalContext* globalCtx) { // light arrows if (this->actor.colChkInfo.damageEffect == 4) { - this->unk21C = 4.0f; - this->unk220 = 1.0f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 1.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -1201,15 +1201,15 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &thisCollider->base); } - if (this->unk21C > 0.0f) { - Math_StepToF(&this->unk21C, 0.0f, 0.05f); + if (this->drawDmgEffAlpha > 0.0f) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); if (this->mainColor.a != 255) { // NOT fully visible if (this->mainColor.a * (1.0f / 255.0f) < this->mainColor.a) { - this->unk21C = this->mainColor.a * (1.0f / 255.0f); + this->drawDmgEffAlpha = this->mainColor.a * (1.0f / 255.0f); } } - this->unk220 = ((this->unk21C + 1.0f) * 0.5f); - this->unk220 = CLAMP_MAX(this->unk220, 1.0f); + this->drawDmgEffScale = ((this->drawDmgEffAlpha + 1.0f) * 0.5f); + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 1.0f); } } @@ -1318,8 +1318,9 @@ void EnBigpo_DrawMainBigpo(Actor* thisx, GlobalContext* globalCtx) { } // 71.428566f might be 500/7 context unknown - func_800BE680(globalCtx, &this->actor, this->limbPos, 9, this->actor.scale.x * 71.428566f * this->unk220, 0, - this->unk21C, 0x14); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->actor.scale.x * 71.428566f * this->drawDmgEffScale, 0.0f, this->drawDmgEffAlpha, + ACTOR_DRAW_DMGEFF_LIGHT_ORBS); Matrix_SetCurrentState(&this->drawMtxF); EnBigpo_DrawLantern(&this->actor, globalCtx); diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h index 9ae87f9f3..c5d0bbe4c 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h @@ -40,9 +40,8 @@ typedef struct EnBigpo { /* 0x212 */ s16 hoverHeightCycleTimer; // sin wave up and down bobbing /* 0x214 */ f32 fireRadius; // distance from center during conjunction cutscene /* 0x218 */ f32 savedHeight; // actual height while flying moves as part of bobbing - // both unk21C and unk220 are passed to func_800BE680, probably need that to know what they are - /* 0x21C */ f32 unk21C; // tied to color alpha, decremented to zero - /* 0x220 */ f32 unk220; // created from unk21C + /* 0x21C */ f32 drawDmgEffAlpha; + /* 0x220 */ f32 drawDmgEffScale; /* 0x224 */ Vec3f limbPos[9]; /* 0x290 */ Color_RGBA8 mainColor; /* 0x294 */ Color_RGBA8 lanternColor; diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index f305684ed..5475650ca 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -906,22 +906,22 @@ void EnBigslime_GekkoSfxInsideBigslime(EnBigslime* this, u16 sfxId) { } void EnBigslime_GekkoFreeze(EnBigslime* this) { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_FROZEN; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->gekkoCollider.base.colType = COLTYPE_HIT3; this->gekkoCollider.info.elemType = ELEMTYPE_UNK0; this->stunTimer = 2; - this->unk_38C = 0.75f; - this->unk_390 = 1.125f; - this->unk_388 = 1.0f; + this->gekkoDrawDmgEffScale = 0.75f; + this->gekkoDrawDmgEffFrozenSteamScale = 1.125f; + this->gekkoDrawDmgEffAlpha = 1.0f; this->actor.flags &= ~ACTOR_FLAG_200; } void EnBigslime_GekkoThaw(EnBigslime* this, GlobalContext* globalCtx) { - if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_FROZEN) { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_THAW; + if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->gekkoCollider.base.colType = COLTYPE_HIT6; this->gekkoCollider.info.elemType = ELEMTYPE_UNK1; - this->unk_388 = 0.0f; + this->gekkoDrawDmgEffAlpha = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); this->actor.flags |= ACTOR_FLAG_200; } @@ -2211,7 +2211,7 @@ void EnBigslime_SetupStunGekko(EnBigslime* this) { void EnBigslime_StunGekko(EnBigslime* this, GlobalContext* globalCtx) { this->stunTimer--; if (this->stunTimer == 0) { - if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_FROZEN) { + if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { EnBigslime_GekkoThaw(this, globalCtx); EnBigslime_SetupDamageGekko(this, false); } else { @@ -2615,7 +2615,7 @@ void EnBigslime_ApplyDamageEffectBigslime(EnBigslime* this, GlobalContext* globa void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCtx) { if (this->gekkoCollider.base.acFlags & AC_HIT) { this->gekkoCollider.base.acFlags &= ~AC_HIT; - if ((this->gekkoDrawEffect != GEKKO_DRAW_EFFECT_FROZEN) || + if ((this->gekkoDrawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || !(this->gekkoCollider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { EnBigslime_EndThrowMinislime(this); if (this->actor.colChkInfo.damageEffect != BIGSLIME_DMGEFF_HOOKSHOT) { @@ -2627,12 +2627,12 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt EnBigslime_GekkoThaw(this, globalCtx); if ((this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) || (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_LIGHT)) { - this->unk_388 = 4.0f; - this->unk_38C = 0.75f; + this->gekkoDrawDmgEffAlpha = 4.0f; + this->gekkoDrawDmgEffScale = 0.75f; if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_THAW; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_LIGHT_ORBS; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->gekkoCollider.info.bumper.hitPos.x, this->gekkoCollider.info.bumper.hitPos.y, @@ -2645,9 +2645,9 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_ELECTRIC_STUN) { this->stunTimer = 40; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_ELECTRIC_STUN; - this->unk_38C = 0.75f; - this->unk_388 = 2.0f; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->gekkoDrawDmgEffScale = 0.75f; + this->gekkoDrawDmgEffAlpha = 2.0f; EnBigslime_SetupStunGekko(this); } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_STUN || this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_DEKU_STUN) { @@ -2662,12 +2662,12 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt EnBigslime_GekkoThaw(this, globalCtx); if ((this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) || (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_LIGHT)) { - this->unk_388 = 3.0f; - this->unk_38C = 0.75f; + this->gekkoDrawDmgEffAlpha = 3.0f; + this->gekkoDrawDmgEffScale = 0.75f; if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_THAW; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_LIGHT_ORBS; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->gekkoCollider.info.bumper.hitPos.x, this->gekkoCollider.info.bumper.hitPos.y, @@ -2755,12 +2755,13 @@ void EnBigslime_UpdateEffects(EnBigslime* this) { } // update actor damage draw effects - if (this->unk_388 > 0.0f) { - if ((this->gekkoDrawEffect != GEKKO_DRAW_EFFECT_FROZEN) && (this->actionFunc != EnBigslime_PlayCutscene)) { - Math_StepToF(&this->unk_388, 0.0f, 0.05f); - this->unk_38C = 0.375f * (this->unk_388 + 1.0f); - this->unk_38C = CLAMP_MAX(this->unk_38C, 0.75f); - } else if (!Math_StepToF(&this->unk_390, 0.75f, 0.01875f)) { + if (this->gekkoDrawDmgEffAlpha > 0.0f) { + if ((this->gekkoDrawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->actionFunc != EnBigslime_PlayCutscene)) { + Math_StepToF(&this->gekkoDrawDmgEffAlpha, 0.0f, 0.05f); + this->gekkoDrawDmgEffScale = 0.375f * (this->gekkoDrawDmgEffAlpha + 1.0f); + this->gekkoDrawDmgEffScale = CLAMP_MAX(this->gekkoDrawDmgEffScale, 0.75f); + } else if (!Math_StepToF(&this->gekkoDrawDmgEffFrozenSteamScale, 0.75f, 0.01875f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -3074,9 +3075,9 @@ void EnBigslime_DrawGekko(Actor* thisx, GlobalContext* globalCtx) { } else if ((this->actionFunc == EnBigslime_CutsceneDefeat) || (this->actionFunc == EnBigslime_GekkoDespawn)) { func_800AE434(globalCtx, &gekkoDamageColor, 20, 20); } else if (this->actionFunc == EnBigslime_StunGekko) { - if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_FROZEN) { + if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { func_800AE434(globalCtx, &gekkoDamageColor, this->stunTimer, 80); - } else if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_ELECTRIC_STUN) { + } else if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL) { func_800AE434(globalCtx, &gekkoStunColor, this->stunTimer, 40); } else { func_800AE434(globalCtx, &gekkoStunColor, this->stunTimer, 40); @@ -3109,10 +3110,10 @@ void EnBigslime_DrawGekko(Actor* thisx, GlobalContext* globalCtx) { EnBigslime_DrawShatteringEffects(this, globalCtx); - // Draw actor damage effects - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), - this->gekkoScale * (999.99991f / 7.0f) * this->unk_38C, this->unk_390, this->unk_388, - this->gekkoDrawEffect); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->gekkoScale * (999.99991f / 7.0f) * this->gekkoDrawDmgEffScale, + this->gekkoDrawDmgEffFrozenSteamScale, this->gekkoDrawDmgEffAlpha, + this->gekkoDrawDmgEffType); } void EnBigslime_DrawShatteringEffects(EnBigslime* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h index 3f57f1666..f59a934bc 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h @@ -64,7 +64,7 @@ typedef struct EnBigslime { u8 numGekkoMeleeAttacks; // The Gekko will melee-attack link at 1-3 times at each position while engulfed in bigslime }; /* 0x02B4 */ u8 shockwaveAlpha; - /* 0x02B5 */ u8 gekkoDrawEffect; + /* 0x02B5 */ u8 gekkoDrawDmgEffType; /* 0x02B6 */ s16 gekkoYaw; /* 0x02B8 */ s16 cutscene; /* 0x02BA */ union { // multi-use timer @@ -107,9 +107,9 @@ typedef struct EnBigslime { Vec3f subCamDistToFrog; // Used to zoom into frogs as Gekko despawns/Frog spawns }; /* 0x02F8 */ Vec3f limbPos[12]; - /* 0x0388 */ f32 unk_388; // used as arg to func_800BE680 - /* 0x038C */ f32 unk_38C; // used as arg to func_800BE680 - /* 0x0390 */ f32 unk_390; // used as arg to func_800BE680 + /* 0x0388 */ f32 gekkoDrawDmgEffAlpha; + /* 0x038C */ f32 gekkoDrawDmgEffScale; + /* 0x0390 */ f32 gekkoDrawDmgEffFrozenSteamScale; /* 0x0394 */ f32 gekkoScale; /* 0x0398 */ f32 vtxSurfacePerturbation[BIGSLIME_NUM_VTX]; /* 0x0620 */ f32 vtxScaleX; diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c index 9a6b678fc..7461239d3 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -147,21 +147,21 @@ void EnDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_808BD348(EnDekunuts* this) { - this->unk_18E = 10; - this->unk_214 = 0.55f; - this->unk_218 = 0.82500005f; - this->unk_210 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; + this->drawDmgEffAlpha = 1.0f; this->collider.base.colType = COLTYPE_HIT3; this->unk_190 = 80; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808BD3B4(EnDekunuts* this, GlobalContext* globalCtx) { - if (this->unk_18E == 10) { - this->unk_18E = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; - this->unk_210 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_21C, 8, 2, 0.2f, 0.2f); + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 8, 2, 0.2f, 0.2f); } } @@ -568,7 +568,8 @@ void func_808BE73C(EnDekunuts* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.info); - if ((this->unk_18E != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { func_808BD3B4(this, globalCtx); if ((this->actor.colChkInfo.mass == 50) || (this->actor.params != ENDEKUNUTS_GET_FF00_0)) { if ((this->actor.params != ENDEKUNUTS_GET_FF00_1) && !Actor_ApplyDamage(&this->actor)) { @@ -599,20 +600,20 @@ void func_808BE73C(EnDekunuts* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_210 = 4.0f; - this->unk_214 = 0.55f; - this->unk_18E = 0; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_210 = 4.0f; - this->unk_214 = 0.55f; - this->unk_18E = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); } else if (this->actor.colChkInfo.damageEffect == 5) { - this->unk_18E = 32; - this->unk_210 = 4.0f; - this->unk_214 = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; } func_808BE294(this, 1); @@ -649,12 +650,13 @@ void EnDekunuts_Update(Actor* thisx, GlobalContext* globalCtx) { } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_210 > 0.0f) { - if (this->unk_18E != 10) { - Math_StepToF(&this->unk_210, 0.0f, 0.05f); - this->unk_214 = (this->unk_210 + 1.0f) * 0.275f; - this->unk_214 = CLAMP_MAX(this->unk_214, 0.55f); - } else if ((this->unk_18E == 10) && !Math_StepToF(&this->unk_218, 0.55f, (33.0f / 1600.0f))) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + !Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, (33.0f / 1600.0f))) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -709,12 +711,12 @@ void EnDekunuts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis if (value != -1) { if (value < 3) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_21C[value]); + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[value]); } else { - Matrix_GetStateTranslation(&this->unk_21C[value]); + Matrix_GetStateTranslation(&this->limbPos[value]); ptr1 = &D_808BEFA4[0]; - ptr2 = &this->unk_21C[value + 1]; - for (i = value + 1; i < ARRAY_COUNT(this->unk_21C); i++) { + ptr2 = &this->limbPos[value + 1]; + for (i = value + 1; i < ARRAY_COUNT(this->limbPos); i++) { Matrix_MultiplyVector3fByState(ptr1, ptr2); ptr1++, ptr2++; } @@ -738,6 +740,6 @@ void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { func_800AE5A0(globalCtx); } Gfx_DrawDListOpa(globalCtx, object_dekunuts_DL_001E50); - func_800BE680(globalCtx, &this->actor, this->unk_21C, 8, this->unk_214, this->unk_218, this->unk_210, - this->unk_18E); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h index aa0b3e1bf..3e1af35eb 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h @@ -22,16 +22,16 @@ typedef struct EnDekunuts { /* 0x188 */ EnDekunutsActionFunc actionFunc; /* 0x18C */ u8 unk_18C; /* 0x18D */ u8 unk_18D; - /* 0x18E */ u8 unk_18E; + /* 0x18E */ u8 drawDmgEffType; /* 0x190 */ s16 unk_190; /* 0x192 */ s16 unk_192; /* 0x194 */ s16 unk_194; /* 0x196 */ Vec3s jointTable[10]; /* 0x1D2 */ Vec3s morphTable[10]; - /* 0x210 */ f32 unk_210; - /* 0x214 */ f32 unk_214; - /* 0x218 */ f32 unk_218; - /* 0x21C */ Vec3f unk_21C[8]; + /* 0x210 */ f32 drawDmgEffAlpha; + /* 0x214 */ f32 drawDmgEffScale; + /* 0x218 */ f32 drawDmgEffFrozenSteamScale; + /* 0x21C */ Vec3f limbPos[8]; /* 0x27C */ ColliderCylinder collider; } EnDekunuts; // size = 0x2C8 diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index 03afec1fb..10e3fd8b8 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -376,22 +376,22 @@ void func_8089ABF4(EnDinofos* this, GlobalContext* globalCtx) { } void func_8089AC70(EnDinofos* this) { - this->unk_28A = 10; - this->unk_2B4 = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.55f; this->colliderJntSph.base.colType = COLTYPE_HIT3; - this->unk_2B8 = 0.82500005f; - this->unk_2B0 = 1.0f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; + this->drawDmgEffAlpha = 1.0f; this->unk_290 = 80; this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_8089ACEC(EnDinofos* this, GlobalContext* globalCtx) { - if (this->unk_28A == 10) { - this->unk_28A = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->colliderJntSph.base.colType = COLTYPE_HIT0; - this->unk_2B0 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D4, 12, 2, 0.3f, 0.2f); + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 12, 2, 0.3f, 0.2f); this->actor.flags |= ACTOR_FLAG_400; } } @@ -1048,9 +1048,9 @@ void func_8089CB10(EnDinofos* this, GlobalContext* globalCtx) { for (i = 6; i < ARRAY_COUNT(this->colliderJntSphElement); i++) { worldSphere = &this->colliderJntSph.elements[i].dim.worldSphere; - worldSphere->center.x = this->unk_34C.x; - worldSphere->center.y = this->unk_34C.y; - worldSphere->center.z = this->unk_34C.z; + worldSphere->center.x = this->limbPos[10].x; + worldSphere->center.y = this->limbPos[10].y; + worldSphere->center.z = this->limbPos[10].z; } if (globalCtx->sceneNum == SCENE_MITURIN) { @@ -1086,7 +1086,7 @@ void func_8089CBEC(EnDinofos* this, GlobalContext* globalCtx) { sp7C.y = randPlusMinusPoint5Scaled(0.6f) + 1.4f; sp7C.z = 0.9f * temp_f22; func_800B9010(&this->actor, NA_SE_EN_DODO_J_FIRE - SFX_FLAG); - EffectSsDFire_Spawn(globalCtx, &this->unk_34C, &sp88, &sp7C, 30, 22, 255 - (temp_s0 * 20), 20, 3, 8); + EffectSsDFire_Spawn(globalCtx, &this->limbPos[10], &sp88, &sp7C, 30, 22, 255 - (temp_s0 * 20), 20, 3, 8); for (end = 6, i = 3; i > 0; i--) { if (this->unk_290 < (20 + -(i * 2))) { @@ -1099,9 +1099,9 @@ void func_8089CBEC(EnDinofos* this, GlobalContext* globalCtx) { dim = &this->colliderJntSph.elements[i].dim; temp_s3 = (s32)(cos_rad((this->unk_290 + ((i - 5) << 1)) * (M_PI / 20)) * 0x2C00) + this->actor.shape.rot.y; - dim->worldSphere.center.x = (s32)(Math_SinS(temp_s3) * dim->modelSphere.center.z) + (s32)this->unk_34C.x; - dim->worldSphere.center.y = (s32)this->unk_34C.y + (s32)dim->modelSphere.center.y; - dim->worldSphere.center.z = (s32)(Math_CosS(temp_s3) * dim->modelSphere.center.z) + (s32)this->unk_34C.z; + dim->worldSphere.center.x = (s32)this->limbPos[10].x + (s32)(Math_SinS(temp_s3) * dim->modelSphere.center.z); + dim->worldSphere.center.y = (s32)this->limbPos[10].y + (s32)dim->modelSphere.center.y; + dim->worldSphere.center.z = (s32)this->limbPos[10].z + (s32)(Math_CosS(temp_s3) * dim->modelSphere.center.z); } if (this->unk_290 != 0) { @@ -1151,8 +1151,8 @@ void func_8089D018(EnDinofos* this, GlobalContext* globalCtx) { this->unk_288 = temp_v0; } - if (this->unk_2B0 > 0.0f) { - this->unk_2B0 = this->unk_288 * (1.0f / 255.0f); + if (this->drawDmgEffAlpha > 0.0f) { + this->drawDmgEffAlpha = this->unk_288 * (1.0f / 255.0f); } this->actor.shape.shadowAlpha = this->unk_288; @@ -1260,7 +1260,8 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { return false; } - if ((this->unk_28A == 10) && (this->colliderJntSph.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->colliderJntSph.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { return false; } @@ -1311,22 +1312,22 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 5) { this->unk_290 = 40; Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); - this->unk_2B4 = 0.55f; - this->unk_2B0 = 2.0f; - this->unk_28A = 31; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_8089C784(this); return true; } if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2B0 = 4.0f; - this->unk_2B4 = 0.55f; - this->unk_28A = 0; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2B0 = 4.0f; - this->unk_2B4 = 0.55f; - this->unk_28A = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->colliderJntSph.elements[i].info.bumper.hitPos.x, this->colliderJntSph.elements[i].info.bumper.hitPos.y, @@ -1359,7 +1360,7 @@ void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { if (this->actionFunc != func_8089C7B8) { if ((this->actor.depthInWater > 0.0f) && (this->actor.depthInWater < 10.0f)) { if (!((globalCtx->gameplayFrames % 4) & 1)) { - Math_Vec3f_Copy(&sp30, &this->unk_2D4[1 + (globalCtx->gameplayFrames % 4)]); + Math_Vec3f_Copy(&sp30, &this->limbPos[1 + (globalCtx->gameplayFrames % 4)]); sp30.y = this->actor.world.pos.y + this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &sp30, 100, 320, 0); } @@ -1373,7 +1374,7 @@ void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { Math_ScaledStepToS(&this->unk_28E, 0, 2000); } - Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk_304); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->limbPos[4]); this->actor.focus.rot.y = this->actor.shape.rot.y + this->unk_28E; if (this->colliderJntSph.base.acFlags & AC_ON) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); @@ -1388,12 +1389,12 @@ void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderQuad.base); } - if (this->unk_2B0 > 0.0f) { - if (this->unk_28A != 10) { - Math_StepToF(&this->unk_2B0, 0.0f, 0.05f); - this->unk_2B4 = (this->unk_2B0 + 1.0f) * (11.0f / 40.0f); - this->unk_2B4 = CLAMP_MAX(this->unk_2B4, 0.55f); - } else if (!Math_StepToF(&this->unk_2B8, 0.55f, 0.01375f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * (11.0f / 40.0f); + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1428,7 +1429,7 @@ void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Collider_UpdateSpheres(limbIndex, &this->colliderJntSph); if (D_8089E3B0[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2D4[D_8089E3B0[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_8089E3B0[limbIndex]]); } if ((limbIndex == 14) && (this->unk_292 != this->unk_290) && @@ -1460,7 +1461,7 @@ void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* sp4C.x -= sp48->mf[3][0]; sp4C.y -= sp48->mf[3][1]; sp4C.z -= sp48->mf[3][2]; - EffectSsDFire_Spawn(globalCtx, &this->unk_34C, &sp4C, &gZeroVec3f, 30, 22, 255 - (sp58 * 20), 20, 3, 8); + EffectSsDFire_Spawn(globalCtx, &this->limbPos[10], &sp4C, &gZeroVec3f, 30, 22, 255 - (sp58 * 20), 20, 3, 8); this->unk_292 = this->unk_290; } } @@ -1495,8 +1496,8 @@ void EnDinofos_Draw(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.dListCount, func_8089DC4C, func_8089DC84, &this->actor, POLY_XLU_DISP); } - func_800BE680(globalCtx, &this->actor, this->unk_2D4, 12, this->unk_2B4, this->unk_2B8, this->unk_2B0, - this->unk_28A); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h index 961780b94..f5c7431f0 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h @@ -15,7 +15,7 @@ typedef struct EnDinofos { /* 0x284 */ EnDinofosActionFunc actionFunc; /* 0x288 */ u8 unk_288; /* 0x289 */ u8 unk_289; - /* 0x28A */ u8 unk_28A; + /* 0x28A */ u8 drawDmgEffType; /* 0x28B */ u8 unk_28B; /* 0x28C */ s16 unk_28C; /* 0x28E */ s16 unk_28E; @@ -28,20 +28,15 @@ typedef struct EnDinofos { /* 0x2A4 */ f32 unk_2A4; /* 0x2A8 */ f32 unk_2A8; /* 0x2AC */ f32 unk_2AC; - /* 0x2B0 */ f32 unk_2B0; - /* 0x2B4 */ f32 unk_2B4; - /* 0x2B8 */ f32 unk_2B8; + /* 0x2B0 */ f32 drawDmgEffAlpha; + /* 0x2B4 */ f32 drawDmgEffScale; + /* 0x2B8 */ f32 drawDmgEffFrozenSteamScale; /* 0x2BC */ Vec3f unk_2BC; /* 0x2C8 */ Vec3f unk_2C8; - /* 0x2D4 */ Vec3f unk_2D4[4]; - /* 0x304 */ Vec3f unk_304; - /* 0x310 */ UNK_TYPE1 unk_310[0x3C]; - /* 0x34C */ Vec3f unk_34C; - /* 0x358 */ UNK_TYPE1 unk_358[0xC]; + /* 0x2D4 */ Vec3f limbPos[12]; /* 0x364 */ ColliderJntSph colliderJntSph; /* 0x384 */ ColliderJntSphElement colliderJntSphElement[9]; /* 0x5C4 */ ColliderQuad colliderQuad; - } EnDinofos; // size = 0x644 extern const ActorInit En_Dinofos_InitVars; diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c index 8432b632a..20a44c01d 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -399,13 +399,13 @@ void func_80876B08(EnDodongo* this, GlobalContext* globalCtx) { void func_80876BD0(EnDodongo* this, GlobalContext* globalCtx, s32 arg2) { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_300 = 0; - this->unk_340 = 0.75f; - this->unk_33C = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_300 = 20; - this->unk_340 = 0.75f; - this->unk_33C = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider1.elements[arg2].info.bumper.hitPos.x, this->collider1.elements[arg2].info.bumper.hitPos.y, @@ -414,24 +414,24 @@ void func_80876BD0(EnDodongo* this, GlobalContext* globalCtx, s32 arg2) { } void func_80876CAC(EnDodongo* this) { - this->unk_300 = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider1.base.colType = COLTYPE_HIT3; - this->unk_340 = 0.75f; - this->unk_344 = 1.125f; - this->unk_33C = 1.0f; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffFrozenSteamScale = 1.125f; + this->drawDmgEffAlpha = 1.0f; this->timer = 80; this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 80); } void func_80876D28(EnDodongo* this, GlobalContext* globalCtx) { - if (this->unk_300 == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->timer = 0; this->actor.colorFilterTimer = 0; - this->unk_300 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider1.base.colType = COLTYPE_HIT0; - this->unk_33C = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, &this->unk_348[0], 9, 2, this->unk_334 * 0.3f, + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, &this->limbPos[0], 9, 2, this->unk_334 * 0.3f, this->unk_334 * 0.2f); this->actor.flags |= ACTOR_FLAG_400; } @@ -448,7 +448,7 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { f32 temp_f22; f32 temp_f20; - Math_Vec3f_Copy(&sp68, &this->unk_348[0]); + Math_Vec3f_Copy(&sp68, &this->limbPos[0]); sp66 = (Rand_Next() >> 0x12) + this->actor.shape.rot.y; temp_f20 = Math_CosS(sp66); temp_f22 = Math_SinS(sp66); @@ -496,8 +496,8 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { sp74.z = (Rand_ZeroFloat(0.1f) + 0.15f) * -temp_f22 * this->unk_334; func_800B0EB0(globalCtx, &sp68, &sp80, &sp74, &this->unk_32C, &this->unk_330, sp64, sp62, 0x14); - sp68.x = this->unk_348[0].x + (temp_f20 * 6.0f * this->unk_334); - sp68.z = this->unk_348[0].z - (temp_f22 * 6.0f * this->unk_334); + sp68.x = this->limbPos[0].x + (temp_f20 * 6.0f * this->unk_334); + sp68.z = this->limbPos[0].z - (temp_f22 * 6.0f * this->unk_334); sp80.x *= -1.0f; sp80.z = sp80.z * -1.0f; sp74.x = (Rand_ZeroFloat(0.1f) + 0.15f) * -temp_f20 * this->unk_334; @@ -622,9 +622,9 @@ void func_808777A8(EnDodongo* this) { for (i = 0; i < ARRAY_COUNT(this->collider3Elements); i++) { sph = &this->collider3.elements[i].dim.worldSphere; - sph->center.x = this->unk_348[0].x; - sph->center.y = this->unk_348[0].y; - sph->center.z = this->unk_348[0].z; + sph->center.x = this->limbPos[0].x; + sph->center.y = this->limbPos[0].y; + sph->center.z = this->limbPos[0].z; sph->radius = 0; } @@ -658,10 +658,10 @@ void func_8087784C(EnDodongo* this, GlobalContext* globalCtx) { temp_f12 = Math_CosS(this->actor.shape.rot.y) * this->unk_334; for (i = 0; i < end; i++, element++) { - element->dim.worldSphere.center.x = this->unk_348[0].x + (element->dim.modelSphere.center.z * temp_f2); + element->dim.worldSphere.center.x = this->limbPos[0].x + (element->dim.modelSphere.center.z * temp_f2); element->dim.worldSphere.center.y = - this->unk_348[0].y + (element->dim.modelSphere.center.y * this->unk_334); - element->dim.worldSphere.center.z = this->unk_348[0].z + (element->dim.modelSphere.center.z * temp_f12); + this->limbPos[0].y + (element->dim.modelSphere.center.y * this->unk_334); + element->dim.worldSphere.center.z = this->limbPos[0].z + (element->dim.modelSphere.center.z * temp_f12); element->dim.worldSphere.radius = element->dim.modelSphere.radius; } @@ -669,7 +669,7 @@ void func_8087784C(EnDodongo* this, GlobalContext* globalCtx) { D_80879348.x = 2.5f * temp_f2; D_80879348.y = this->unk_334 * 1.4f; D_80879348.z = 2.5f * temp_f12; - EffectSsDFire_Spawn(globalCtx, &this->unk_348[0], &D_80879354, &D_80879348, this->unk_334 * 100.0f, + EffectSsDFire_Spawn(globalCtx, &this->limbPos[0], &D_80879354, &D_80879348, this->unk_334 * 100.0f, this->unk_334 * 35.0f, 0xFF - (frame * 10), 5, 0, 8); } else if ((this->skelAnime.curFrame >= 2.0f) && (this->skelAnime.curFrame <= 20.0f)) { func_800B9010(&this->actor, NA_SE_EN_DODO_J_BREATH - SFX_FLAG); @@ -772,13 +772,13 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { } else { sp5E = this->unk_334 * 50.0f; sp5C = this->unk_334 * 5.0f; - Math_Vec3f_Copy(&sp64, &this->unk_348[0]); + Math_Vec3f_Copy(&sp64, &this->limbPos[0]); func_800B0DE0(globalCtx, &sp64, &gZeroVec3f, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); sp64.x -= Math_CosS(this->actor.shape.rot.y) * 6.0f * this->unk_334; sp64.z += Math_SinS(this->actor.shape.rot.y) * 6.0f * this->unk_334; func_800B0DE0(globalCtx, &sp64, &gZeroVec3f, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); - sp64.x = (2.0f * this->unk_348[0].x) - sp64.x; - sp64.z = (2.0f * this->unk_348[0].z) - sp64.z; + sp64.x = (2.0f * this->limbPos[0].x) - sp64.x; + sp64.z = (2.0f * this->limbPos[0].z) - sp64.z; func_800B0DE0(globalCtx, &sp64, &gZeroVec3f, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); } } @@ -953,7 +953,8 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { } if ((i != ARRAY_COUNT(this->collider2Elements)) && - ((this->unk_300 != 10) || !(this->collider2.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider2.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { func_80876D28(this, globalCtx); Math_Vec3s_ToVec3f(&sp3C, &this->collider2.elements[i].info.bumper.hitPos); if (this->actor.colChkInfo.damageEffect == 0xF) { @@ -976,7 +977,8 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { } if ((i != ARRAY_COUNT(this->collider1Elements)) && - ((this->unk_300 != 10) || !(this->collider1.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider1.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { func_80876D28(this, globalCtx); if (this->actor.colChkInfo.damageEffect != 0xF) { if (!Actor_ApplyDamage(&this->actor)) { @@ -1000,9 +1002,9 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { this->timer = 40; Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_300 = 30; - this->unk_340 = 0.75f; - this->unk_33C = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 2.0f; func_80878594(this); } else if (this->actor.colChkInfo.damageEffect == 3) { func_80876CAC(this); @@ -1043,12 +1045,12 @@ void EnDodongo_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider3.base); } - if (this->unk_33C > 0.0f) { - if (this->unk_300 != 10) { - Math_StepToF(&this->unk_33C, 0.0f, 0.05f); - this->unk_340 = (this->unk_33C + 1.0f) * 0.375f; - this->unk_340 = (this->unk_340 > 0.75f) ? 0.75f : this->unk_340; - } else if (!Math_StepToF(&this->unk_344, 0.75f, 0.01875f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.375f; + this->drawDmgEffScale = (this->drawDmgEffScale > 0.75f) ? 0.75f : this->drawDmgEffScale; + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, 0.01875f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1079,20 +1081,20 @@ void EnDodongo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Collider_UpdateSpheres(limbIndex, &this->collider1); Collider_UpdateSpheres(limbIndex, &this->collider2); if (D_80879388[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_348[D_80879388[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_80879388[limbIndex]]); } if (limbIndex == 7) { Matrix_MultiplyVector3fByState(&D_80879370, &this->unk_308); - Matrix_MultiplyVector3fByState(&D_8087937C, &this->unk_348[0]); + Matrix_MultiplyVector3fByState(&D_8087937C, &this->limbPos[0]); Matrix_GetStateTranslation(&this->actor.focus.pos); - Matrix_GetStateTranslationAndScaledY(-200.0f, &this->unk_348[1]); + Matrix_GetStateTranslationAndScaledY(-200.0f, &this->limbPos[1]); } else if (limbIndex == 13) { Matrix_GetStateTranslationAndScaledX(1600.0f, &this->unk_320); } if ((limbIndex == 30) && (this->actionFunc == func_80878424) && (this->timer != this->unk_304)) { - EffectBlure_AddVertex(Effect_GetByIndex(this->unk_338), &this->unk_320, &this->unk_348[4]); + EffectBlure_AddVertex(Effect_GetByIndex(this->unk_338), &this->unk_320, &this->limbPos[4]); this->unk_304 = this->timer; } } @@ -1103,6 +1105,7 @@ void EnDodongo_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDodongo_OverrideLimbDraw, EnDodongo_PostLimbDraw, &this->actor); - func_800BE680(globalCtx, &this->actor, this->unk_348, ARRAY_COUNT(this->unk_348), this->unk_340 * this->unk_334, - this->unk_344 * this->unk_334, this->unk_33C, this->unk_300); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale * this->unk_334, this->drawDmgEffFrozenSteamScale * this->unk_334, + this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h index 4a7fe8e9d..30562404f 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h @@ -13,7 +13,7 @@ typedef struct EnDodongo { /* 0x188 */ Vec3s jointTable[31]; /* 0x242 */ Vec3s morphTable[31]; /* 0x2FC */ EnDodongoActionFunc actionFunc; - /* 0x300 */ u8 unk_300; + /* 0x300 */ u8 drawDmgEffType; /* 0x302 */ s16 timer; /* 0x304 */ s16 unk_304; /* 0x306 */ s16 unk_306; @@ -24,10 +24,10 @@ typedef struct EnDodongo { /* 0x330 */ Color_RGBA8 unk_330; /* 0x334 */ f32 unk_334; /* 0x338 */ s32 unk_338; - /* 0x33C */ f32 unk_33C; - /* 0x340 */ f32 unk_340; - /* 0x344 */ f32 unk_344; - /* 0x348 */ Vec3f unk_348[9]; + /* 0x33C */ f32 drawDmgEffAlpha; + /* 0x340 */ f32 drawDmgEffScale; + /* 0x344 */ f32 drawDmgEffFrozenSteamScale; + /* 0x348 */ Vec3f limbPos[9]; /* 0x3B4 */ ColliderJntSph collider1; /* 0x3D4 */ ColliderJntSphElement collider1Elements[10]; /* 0x654 */ ColliderJntSph collider2; diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c index 664c7ce37..711b4ca6e 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -168,10 +168,10 @@ void EnFirefly_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnFirefly_SpawnIceEffects(EnFirefly* this, GlobalContext* globalCtx) { - if (this->unk_18F == 0xA) { - this->unk_18F = 0; - this->unk_2E8.x = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, &this->unk_2F8, 3, 2, 0.2f, 0.2f); + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, &this->limbPos[0], 3, 2, 0.2f, 0.2f); } } @@ -340,24 +340,24 @@ void EnFirefly_SetupFall(EnFirefly* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 3) { - this->unk_18F = 0xA; - this->unk_2E8.x = 1.0f; - this->unk_2E8.y = 0.55f; - this->unk_2E8.z = 0.82500005f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_18F = 0x14; - this->unk_2E8.x = 4.0f; - this->unk_2E8.y = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); } else if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_18F = 0; - this->unk_2E8.x = 4.0f; - this->unk_2E8.y = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; } - if (this->unk_2E8.x > 0.0f) { + if (this->drawDmgEffAlpha > 0.0f) { this->auraType = KEESE_AURA_NONE; } @@ -374,7 +374,7 @@ void EnFirefly_Fall(EnFirefly* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); if (!(this->actor.flags & ACTOR_FLAG_8000)) { - if (this->unk_18F != 0xA) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { Math_ScaledStepToS(&this->actor.shape.rot.x, 0x6800, 0x200); this->actor.shape.rot.y -= 0x300; } @@ -566,8 +566,8 @@ void EnFirefly_Stunned(EnFirefly* this, GlobalContext* globalCtx) { } else { this->actor.colorFilterTimer = 40; - if (this->unk_2E8.x > 0.0f) { - this->unk_2E8.x = 2.0f; + if (this->drawDmgEffAlpha > 0.0f) { + this->drawDmgEffAlpha = 2.0f; } } } @@ -638,9 +638,9 @@ void EnFirefly_UpdateDamage(EnFirefly* this, GlobalContext* globalCtx) { EnFirefly_SetupStunned(this); } else if (this->actor.colChkInfo.damageEffect == 5) { this->timer = 40; - this->unk_18F = 0x1F; - this->unk_2E8.x = 2.0f; - this->unk_2E8.y = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffScale = 0.55f; EnFirefly_SetupStunned(this); } else { Enemy_StartFinishingBlow(globalCtx, &this->actor); @@ -710,12 +710,12 @@ void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_2E8.x > 0.0f) { - if (this->unk_18F != 0xA) { - Math_StepToF(&this->unk_2E8.x, 0.0f, 0.05f); - this->unk_2E8.y = (this->unk_2E8.x + 1.0f) * 0.275f; - this->unk_2E8.y = CLAMP_MAX(this->unk_2E8.y, 0.55f); - } else if (!Math_StepToF(&this->unk_2E8.z, 0.55f, 0.01375f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -793,11 +793,11 @@ void EnFirefly_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } if (limbIndex == 15) { - Matrix_GetStateTranslation(&this->unk_2F8); + Matrix_GetStateTranslation(&this->limbPos[0]); } else if (limbIndex == 21) { - Matrix_GetStateTranslation(&this->unk_304); + Matrix_GetStateTranslation(&this->limbPos[1]); } else if (limbIndex == 10) { - Matrix_GetStateTranslation(&this->unk_310); + Matrix_GetStateTranslation(&this->limbPos[2]); } } @@ -830,8 +830,9 @@ void EnFirefly_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = gfx; } - func_800BE680(globalCtx, NULL, &this->unk_2F8, 3, this->unk_2E8.y * this->actor.scale.y * 200.0f, this->unk_2E8.z, - this->unk_2E8.x, this->unk_18F); + Actor_DrawDamageEffects(globalCtx, NULL, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale * this->actor.scale.y * 200.0f, this->drawDmgEffFrozenSteamScale, + this->drawDmgEffAlpha, this->drawDmgEffType); this->unk_2F4 = globalCtx->gameplayFrames; CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h index e4439ec36..c8e24aa4f 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h @@ -24,17 +24,17 @@ typedef struct EnFirefly { /* 0x18C */ u8 auraType; /* 0x18D */ u8 currentType; /* 0x18E */ u8 isInvisible; - /* 0x18F */ u8 unk_18F; + /* 0x18F */ u8 drawDmgEffType; /* 0x190 */ s16 timer; /* 0x192 */ s16 targetPitch; /* 0x194 */ Vec3s jointTable[28]; /* 0x23C */ Vec3s morphTable[28]; /* 0x2E4 */ f32 maxAltitude; - /* 0x2E8 */ Vec3f unk_2E8; + /* 0x2E8 */ f32 drawDmgEffAlpha; + /* 0x2E8 */ f32 drawDmgEffScale; + /* 0x2E8 */ f32 drawDmgEffFrozenSteamScale; /* 0x2F4 */ u32 unk_2F4; - /* 0x2F8 */ Vec3f unk_2F8; - /* 0x304 */ Vec3f unk_304; - /* 0x310 */ Vec3f unk_310; + /* 0x2F8 */ Vec3f limbPos[3]; /* 0x31C */ ColliderSphere collider; } EnFirefly; // size = 0x374 diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index 3ce216f7f..12ac7cdf4 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -233,10 +233,10 @@ void func_808D0930(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D09CC(EnFloormas* this) { - this->unk_18C = 10; - this->unk_2C8 = 0.55f; - this->unk_2CC = 0.82500005f; - this->unk_2C4 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; + this->drawDmgEffAlpha = 1.0f; this->collider.base.colType = COLTYPE_HIT3; this->unk_18E = 80; this->actor.flags &= ~(ACTOR_FLAG_200 | ACTOR_FLAG_400); @@ -244,11 +244,11 @@ void func_808D09CC(EnFloormas* this) { } void func_808D0A48(EnFloormas* this, GlobalContext* globalCtx) { - if (this->unk_18C == 10) { - this->unk_18C = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT0; - this->unk_2C4 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), 2, + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, this->actor.scale.x * 30.000002f, this->actor.scale.x * 20.0f); if (this->actor.scale.x > 0.009f) { this->actor.flags |= ACTOR_FLAG_400; @@ -556,7 +556,7 @@ void func_808D19D4(EnFloormas* this) { Actor* parent; this->actor.colorFilterTimer = 0; - this->unk_2C4 = 0.0f; + this->drawDmgEffAlpha = 0.0f; Actor_SetScale(&this->actor, 0.004f); this->actor.flags |= ACTOR_FLAG_10; if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_80) { @@ -896,7 +896,7 @@ void func_808D2A20(EnFloormas* this) { EnFloormas* parent = (EnFloormas*)this->actor.parent; EnFloormas* child = (EnFloormas*)this->actor.child; - this->unk_2C4 = 0.0f; + this->drawDmgEffAlpha = 0.0f; if ((parent->actionFunc == func_808D2AA8) && (child->actionFunc == func_808D2AA8)) { func_808D2AB8(parent); @@ -1009,16 +1009,17 @@ void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.info); - if ((this->unk_18C != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { if (this->actor.colChkInfo.damageEffect == 0xE) { func_808D0908(this); this->actor.colorFilterTimer = 0; this->actor.colChkInfo.damage = 4; this->unk_192 = -1600; this->actor.gravity = -1.0f; - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.55f; - this->unk_18C = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; } if (this->collider.base.colType != COLTYPE_HARD) { @@ -1053,19 +1054,19 @@ void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { this->unk_18E = 40; Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_2C8 = 0.55f; - this->unk_2C4 = 2.0f; - this->unk_18C = 31; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; func_808D2D6C(this); } else { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.55f; - this->unk_18C = 0; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.55f; - this->unk_18C = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, @@ -1133,12 +1134,12 @@ void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx) { } } - if (this->unk_2C4 > 0.0f) { - if (this->unk_18C != 10) { - Math_StepToF(&this->unk_2C4, 0.0f, 0.05f); - this->unk_2C8 = (this->unk_2C4 + 1.0f) * 0.275f; - this->unk_2C8 = CLAMP_MAX(this->unk_2C8, 0.55f); - } else if (!Math_StepToF(&this->unk_2CC, 0.55f, 0.01375f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1161,12 +1162,12 @@ void EnFloormas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis EnFloormas* this = THIS; if (D_808D393C[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2D0[D_808D393C[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_808D393C[limbIndex]]); } if (limbIndex == 19) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_2D0[9]); - Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->unk_2D0[10]); + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[9]); + Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->limbPos[10]); return; } @@ -1203,9 +1204,10 @@ void EnFloormas_Draw(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - func_800BE680(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), - 100.0f * (this->unk_2C8 * this->actor.scale.x), 100.0f * (this->unk_2CC * this->actor.scale.x), - this->unk_2C4, this->unk_18C); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + 100.0f * (this->drawDmgEffScale * this->actor.scale.x), + 100.0f * (this->drawDmgEffFrozenSteamScale * this->actor.scale.x), this->drawDmgEffAlpha, + this->drawDmgEffType); } void func_808D3754(Actor* thisx, GlobalContext* globalCtx) { @@ -1227,7 +1229,8 @@ void func_808D3754(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - func_800BE680(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), - this->unk_2C8 * this->actor.scale.x * 100.0f, this->unk_2CC * this->actor.scale.x * 100.0f, - this->unk_2C4, this->unk_18C); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale * this->actor.scale.x * 100.0f, + this->drawDmgEffFrozenSteamScale * this->actor.scale.x * 100.0f, this->drawDmgEffAlpha, + this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h index ebfa17777..7cf52edc3 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h @@ -21,17 +21,17 @@ typedef struct EnFloormas { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnFloormasActionFunc actionFunc; - /* 0x018C */ u8 unk_18C; + /* 0x018C */ u8 drawDmgEffType; /* 0x018E */ s16 unk_18E; /* 0x0190 */ s16 unk_190; /* 0x0192 */ s16 unk_192; /* 0x0194 */ s16 unk_194; /* 0x0196 */ Vec3s jointTable[25]; /* 0x022C */ Vec3s morphTable[25]; - /* 0x02C4 */ f32 unk_2C4; - /* 0x02C8 */ f32 unk_2C8; - /* 0x02CC */ f32 unk_2CC; - /* 0x02D0 */ Vec3f unk_2D0[11]; + /* 0x02C4 */ f32 drawDmgEffAlpha; + /* 0x02C8 */ f32 drawDmgEffScale; + /* 0x02CC */ f32 drawDmgEffFrozenSteamScale; + /* 0x02D0 */ Vec3f limbPos[11]; /* 0x0354 */ ColliderCylinder collider; } EnFloormas; // size = 0x3A0 diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.c b/src/overlays/actors/ovl_En_Fz/z_en_fz.c index ea225846a..067e8c50d 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -227,9 +227,9 @@ void EnFz_Init(Actor* thisx, GlobalContext* globalCtx) { } } - this->unk_BA4 = 0; - this->unk_BA0 = 0.0f; - this->unk_B9C = 0.0f; + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; func_80932784(this, globalCtx); } @@ -416,8 +416,8 @@ void func_80932C98(EnFz* this, GlobalContext* globalCtx) { this->collider1.base.acFlags &= ~AC_HIT; switch (this->actor.colChkInfo.damageEffect) { case 4: - this->unk_BA4 = 0x28; - this->unk_B9C = 1.0f; + this->drawDmgEffTimer = 40; + this->drawDmgEffAlpha = 1.0f; case 15: Actor_ApplyDamage(&this->actor); @@ -773,16 +773,16 @@ void func_80933B38(EnFz* this, GlobalContext* globalCtx) { } void func_80933B48(EnFz* this, GlobalContext* globalCtx) { - if (this->unk_BA4 != 0) { - if (this->unk_BA4 > 0) { - this->unk_BA4--; + if (this->drawDmgEffTimer != 0) { + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } - if (this->unk_BA4 < 20) { - Math_SmoothStepToF(&this->unk_BA0, 0.0f, 0.5f, 0.03f, 0.0f); - this->unk_B9C = this->unk_BA4 * 0.05f; + if (this->drawDmgEffTimer < 20) { + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_BA0, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } } @@ -862,17 +862,17 @@ void EnFz_Draw(Actor* thisx, GlobalContext* globalCtx) { func_80934464(this, globalCtx); - if (this->unk_BA4 > 0) { + if (this->drawDmgEffTimer > 0) { s32 pad2[6]; - Vec3f sp58; - Vec3f sp4C; + Vec3f limbPos[2]; s32 pad3; - sp4C = this->actor.world.pos; - sp58 = this->actor.world.pos; - sp4C.y += 20.0f; - sp58.y += 40.0f; - func_800BE680(globalCtx, NULL, &sp4C, 2, this->unk_BA0 * 4.0f, 0.5f, this->unk_B9C, 20); + limbPos[0] = this->actor.world.pos; + limbPos[1] = this->actor.world.pos; + limbPos[0].y += 20.0f; + limbPos[1].y += 40.0f; + Actor_DrawDamageEffects(globalCtx, NULL, limbPos, ARRAY_COUNT(limbPos), this->drawDmgEffScale * 4.0f, 0.5f, + this->drawDmgEffAlpha, ACTOR_DRAW_DMGEFF_LIGHT_ORBS); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -1004,7 +1004,7 @@ void func_80934464(EnFz* this, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); if (flag == 0) { - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051180); + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamDL); flag++; } @@ -1018,7 +1018,7 @@ void func_80934464(EnFz* this, GlobalContext* globalCtx) { Matrix_Scale(ptr->unk_30, ptr->unk_30, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051238); + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamVtxDL); } } diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.h b/src/overlays/actors/ovl_En_Fz/z_en_fz.h index 5e76eadf9..19f462d0a 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.h +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.h @@ -43,9 +43,9 @@ typedef struct EnFz { /* 0x22C */ Vec3f unk_22C; /* 0x238 */ f32 unk_238; /* 0x23C */ EnFzStruct unk_23C[40]; - /* 0xB9C */ f32 unk_B9C; - /* 0xBA0 */ f32 unk_BA0; - /* 0xBA4 */ s16 unk_BA4; + /* 0xB9C */ f32 drawDmgEffAlpha; + /* 0xBA0 */ f32 drawDmgEffScale; + /* 0xBA4 */ s16 drawDmgEffTimer; /* 0xBA8 */ f32 unk_BA8; /* 0xBAC */ f32 unk_BAC; /* 0xBB0 */ f32 unk_BB0; 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 fa5b8e190..72ab850b8 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 @@ -162,7 +162,7 @@ void EnHintSkb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_3DE = 0; this->unk_3E0 = 0; this->unk_3DC = 0; - this->unk_3E9 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; func_80C1FE0C(this); } @@ -340,10 +340,10 @@ void func_80C20540(EnHintSkb* this) { } void func_80C20590(EnHintSkb* this, GlobalContext* globalCtx) { - if (this->unk_3E2 == 0) { - this->unk_3E2 = 0; - this->unk_2D8 = 0.0f; - this->unk_2D4 = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -354,7 +354,7 @@ void func_80C20590(EnHintSkb* this, GlobalContext* globalCtx) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80C20484(this); } - } else if (this->unk_3E2 == 1) { + } else if (this->drawDmgEffTimer == 1) { func_80C21468(this, globalCtx); } } @@ -367,10 +367,10 @@ void func_80C2066C(EnHintSkb* this) { } void func_80C2069C(EnHintSkb* this, GlobalContext* globalCtx) { - if (this->unk_3E2 == 0) { - this->unk_3E2 = 0; - this->unk_2D8 = 0.0f; - this->unk_2D4 = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -636,10 +636,10 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { case 9: case 10: case 11: - if (this->unk_3E2 >= 2) { + if (this->drawDmgEffTimer > 1) { func_80C21468(this, globalCtx); } - this->unk_3E2 = 0; + this->drawDmgEffTimer = 0; break; } } @@ -655,10 +655,10 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { case 11: - this->unk_3E9 = 30; - this->unk_3E2 = 40; - this->unk_2D4 = 1.0f; - this->unk_2D8 = 0.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffTimer = 40; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0, 120, 0, 40); func_80C2011C(this); break; @@ -669,10 +669,10 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { break; case 2: - this->unk_3E2 = 80; - this->unk_3E9 = 0; - this->unk_2D4 = 1.0f; - this->unk_2D8 = 0.0f; + this->drawDmgEffTimer = 80; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3E8 |= 1; @@ -681,21 +681,21 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { case 3: if (this->actor.colChkInfo.health != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - this->unk_3E2 = 80; + this->drawDmgEffTimer = 80; } else { - this->unk_3E2 = 3; + this->drawDmgEffTimer = 3; } - this->unk_3E9 = 11; - this->unk_2D4 = 1.0f; - this->unk_2D8 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); func_80C20540(this); break; case 4: - this->unk_3E2 = 40; - this->unk_3E9 = 20; - this->unk_2D4 = 1.0f; - this->unk_2D8 = 0.5f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -747,20 +747,20 @@ void func_80C21250(EnHintSkb* this, GlobalContext* globalCtx) { } void func_80C21320(EnHintSkb* this, GlobalContext* globalCtx) { - if (this->unk_3E2 > 0) { - this->unk_3E2--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } if (this->actionFunc != func_80C20590) { - if (this->unk_3E2 < 20) { + if (this->drawDmgEffTimer < 20) { if (this->actionFunc == func_80C2069C) { - Math_SmoothStepToF(&this->unk_2D8, 0.0f, 0.5f, 0.03f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); } else { - Math_SmoothStepToF(&this->unk_2D8, 0.0f, 0.5f, 0.01f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.01f, 0.0f); } - this->unk_2D4 = this->unk_3E2 * 0.05f; + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_2D8, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } } @@ -782,21 +782,21 @@ void func_80C21468(EnHintSkb* this, GlobalContext* globalCtx) { s32 i; if (this->unk_3E8 & 2) { - phi_s4 = ARRAY_COUNT(this->unk_22C) - 1; + phi_s4 = ARRAY_COUNT(this->limbPos) - 1; } else { - phi_s4 = ARRAY_COUNT(this->unk_22C); + phi_s4 = ARRAY_COUNT(this->limbPos); } SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); for (i = 0; i < phi_s4; i++) { - temp_s1 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C[i]); + temp_s1 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->limbPos[i]); sp84.x = Math_SinS(temp_s1) * 3.0f; sp84.z = Math_CosS(temp_s1) * 3.0f; sp84.y = (Rand_ZeroOne() * 4.0f) + 4.0f; - EffectSsEnIce_Spawn(globalCtx, &this->unk_22C[i], 0.6f, &sp84, &D_80C21E4C, &D_80C21E44, &D_80C21E48, 30); + EffectSsEnIce_Spawn(globalCtx, &this->limbPos[i], 0.6f, &sp84, &D_80C21E4C, &D_80C21E44, &D_80C21E48, 30); } } @@ -879,15 +879,15 @@ void EnHintSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); } - if (this->unk_3E2 != 0) { + 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)) { - Matrix_GetStateTranslation(&this->unk_22C[this->unk_2DC]); - this->unk_2DC++; + Matrix_GetStateTranslation(&this->limbPos[this->limbCount]); + this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_3E8 & 2)) { - Matrix_MultiplyVector3fByState(&D_80C21E70, &this->unk_22C[this->unk_2DC]); - this->unk_2DC++; + Matrix_MultiplyVector3fByState(&D_80C21E70, &this->limbPos[this->limbCount]); + this->limbCount++; } } } @@ -896,13 +896,13 @@ void EnHintSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList void EnHintSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { EnHintSkb* this = THIS; - this->unk_2DC = 0; + this->limbCount = 0; func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnHintSkb_OverrideLimbDraw, EnHintSkb_PostLimbDraw, &this->actor); - if (this->unk_3E2 > 0) { - func_800BE680(globalCtx, &this->actor, this->unk_22C, this->unk_2DC, this->unk_2D8, 0.5f, this->unk_2D4, - this->unk_3E9); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, this->limbCount, this->drawDmgEffScale, 0.5f, + this->drawDmgEffAlpha, this->drawDmgEffType); } if (this->unk_3E8 & 4) { 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 e399638b7..b67e56352 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 @@ -15,21 +15,21 @@ typedef struct EnHintSkb { /* 0x0164 */ ColliderJntSphElement colliderElement[2]; /* 0x01E4 */ SkelAnime skelAnime; /* 0x0228 */ EnHintSkbActionFunc actionFunc; - /* 0x022C */ Vec3f unk_22C[14]; - /* 0x02D4 */ f32 unk_2D4; - /* 0x02D8 */ f32 unk_2D8; - /* 0x02DC */ s32 unk_2DC; + /* 0x022C */ Vec3f limbPos[14]; + /* 0x02D4 */ f32 drawDmgEffAlpha; + /* 0x02D8 */ f32 drawDmgEffScale; + /* 0x02DC */ s32 limbCount; /* 0x02E0 */ Vec3s jointTable[20]; /* 0x0358 */ Vec3s morphtable[20]; /* 0x03D0 */ UNK_TYPE1 unk3D0[0xC]; /* 0x03DC */ s16 unk_3DC; /* 0x03DE */ s16 unk_3DE; /* 0x03E0 */ s16 unk_3E0; - /* 0x03E2 */ s16 unk_3E2; + /* 0x03E2 */ s16 drawDmgEffTimer; /* 0x03E4 */ s16 unk_3E4; /* 0x03E6 */ u16 unk_3E6; /* 0x03E8 */ u8 unk_3E8; - /* 0x03E9 */ u8 unk_3E9; + /* 0x03E9 */ u8 drawDmgEffType; } EnHintSkb; // size = 0x3EC extern const ActorInit En_Hint_Skb_InitVars; 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 1ec39194d..e457ec219 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -163,10 +163,10 @@ void func_80AD6F34(EnKame* this) { } void func_80AD6F9C(EnKame* this) { - this->unk_29D = 10; - this->unk_2B4 = 0.6f; - this->unk_2B8 = 0.90000004f; - this->unk_2B0 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.6f; + this->drawDmgEffFrozenSteamScale = 0.90000004f; + this->drawDmgEffAlpha = 1.0f; this->collider.base.colType = COLTYPE_HIT3; this->unk_2A2 = 80; this->actor.flags &= ~ACTOR_FLAG_400; @@ -174,11 +174,11 @@ void func_80AD6F9C(EnKame* this) { } void func_80AD7018(EnKame* this, GlobalContext* globalCtx) { - if (this->unk_29D == 10) { - this->unk_29D = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; - this->unk_2B0 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2C8, 10, 2, 0.3f, 0.2f); + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 10, 2, 0.3f, 0.2f); this->actor.flags |= ACTOR_FLAG_400; } } @@ -617,7 +617,8 @@ void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.info); - if ((this->unk_29D == 10) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { return; } @@ -644,9 +645,9 @@ void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { this->unk_2A2 = 40; Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_2B4 = 0.6f; - this->unk_2B0 = 2.0f; - this->unk_29D = 30; + this->drawDmgEffScale = 0.6f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; func_80AD7FA4(this); } else if (this->actor.colChkInfo.damageEffect == 1) { this->unk_2A2 = 40; @@ -662,13 +663,13 @@ void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { func_80AD7FA4(this); } else { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2B4 = 0.6f; - this->unk_2B0 = 4.0f; - this->unk_29D = 0; + this->drawDmgEffScale = 0.6f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2B4 = 0.6f; - this->unk_2B0 = 4.0f; - this->unk_29D = 20; + this->drawDmgEffScale = 0.6f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -732,16 +733,16 @@ void EnKame_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_2B0 > 0.0f) { - if (this->unk_29D != 10) { - Math_StepToF(&this->unk_2B0, 0.0f, 0.05f); - this->unk_2B4 = (this->unk_2B0 + 1.0f) * 0.3f; - if (this->unk_2B4 > 0.6f) { - this->unk_2B4 = 0.6f; + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.3f; + if (this->drawDmgEffScale > 0.6f) { + this->drawDmgEffScale = 0.6f; } else { - this->unk_2B4 = this->unk_2B4; + this->drawDmgEffScale = this->drawDmgEffScale; } - } else if (!Math_StepToF(&this->unk_2B8, 0.6f, 0.015000001f)) { + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.6f, 0.015000001f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -769,7 +770,7 @@ void func_80AD8AF8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnKame* this = THIS; if (D_80AD8EA4[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2C8[D_80AD8EA4[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_80AD8EA4[limbIndex]]); } if (limbIndex == 1) { @@ -782,7 +783,7 @@ void func_80AD8AF8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } ptr2 = D_80AD8E68; - ptr = &this->unk_2C8[5]; + ptr = &this->limbPos[5]; for (i = 0; i < ARRAY_COUNT(D_80AD8E68); i++) { Matrix_MultiplyVector3fByState(ptr2, ptr); ptr2++; @@ -807,8 +808,8 @@ void EnKame_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime1.skeleton, this->skelAnime1.jointTable, this->skelAnime1.dListCount, func_80AD8A48, func_80AD8AF8, &this->actor); - func_800BE680(globalCtx, &this->actor, this->unk_2C8, 10, this->unk_2B4, this->unk_2B8, this->unk_2B0, - this->unk_29D); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); if (this->actor.shape.shadowDraw == NULL) { ActorShadow_DrawCircle(&this->actor, NULL, globalCtx); diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.h b/src/overlays/actors/ovl_En_Kame/z_en_kame.h index 115bf137f..d47e96d54 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.h +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.h @@ -17,7 +17,7 @@ typedef struct EnKame { /* 0x0280 */ Vec3s morphTable2[4]; /* 0x0298 */ EnKameActionFunc actionFunc; /* 0x029C */ u8 unk_29C; - /* 0x029D */ u8 unk_29D; + /* 0x029D */ u8 drawDmgEffType; /* 0x029E */ s16 unk_29E; /* 0x02A0 */ s16 unk_2A0; /* 0x02A2 */ s16 unk_2A2; @@ -25,11 +25,11 @@ typedef struct EnKame { /* 0x02A6 */ s16 unk_2A6; /* 0x02A8 */ f32 unk_2A8; /* 0x02AC */ f32 unk_2AC; - /* 0x02B0 */ f32 unk_2B0; - /* 0x02B4 */ f32 unk_2B4; - /* 0x02B8 */ f32 unk_2B8; + /* 0x02B0 */ f32 drawDmgEffAlpha; + /* 0x02B4 */ f32 drawDmgEffScale; + /* 0x02B8 */ f32 drawDmgEffFrozenSteamScale; /* 0x02BC */ Vec3f unk_2BC; - /* 0x02C8 */ Vec3f unk_2C8[10]; + /* 0x02C8 */ Vec3f limbPos[10]; /* 0x0340 */ ColliderCylinder collider; } EnKame; // size = 0x38C diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c index f6b1f7b40..7a59e702c 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c @@ -175,39 +175,39 @@ void EnKarebaba_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_808F1374(EnKarebaba* this, GlobalContext* globalCtx) { s32 phi_a3; - if (this->unk_1EC == 10) { - this->unk_1EC = 0; - this->unk_1F0 = 0.0f; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; if (this->actor.params == ENKAREBABA_2) { phi_a3 = 1; } else { phi_a3 = 4; } - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_1FC, phi_a3, 4, 0.3f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, phi_a3, 4, 0.3f, 0.2f); } } void func_808F13FC(EnKarebaba* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_1EC = 0; - this->unk_1F4 = 0.75f; - this->unk_1F0 = 3.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 3.0f; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_1F4 = 0.75f; - this->unk_1EC = 20; - this->unk_1F0 = 3.0f; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 3.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider2.info.bumper.hitPos.x, this->collider2.info.bumper.hitPos.y, this->collider2.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); } else if (this->actor.colChkInfo.damageEffect == 3) { - this->unk_1EC = 10; - this->unk_1F4 = 0.75f; - this->unk_1F0 = 1.0f; - this->unk_1F8 = 1.125f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffFrozenSteamScale = 1.125f; } else if (this->actor.colChkInfo.damageEffect == 5) { - this->unk_1EC = 31; - this->unk_1F4 = 0.75f; - this->unk_1F0 = 3.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 3.0f; } } @@ -371,7 +371,7 @@ void func_808F1A58(EnKarebaba* this, GlobalContext* globalCtx) { } void func_808F1BF8(EnKarebaba* this) { - if (this->unk_1EC != 10) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->unk_1EE = 0; this->actor.gravity = -0.8f; this->actor.velocity.y = 4.0f; @@ -393,7 +393,7 @@ void func_808F1C84(EnKarebaba* this, GlobalContext* globalCtx) { f32 temp_f22; f32 temp_f24; - if (this->unk_1EC == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->unk_1EE--; if (this->unk_1EE == 0) { this->actor.gravity = -0.8f; @@ -446,14 +446,14 @@ void func_808F1FAC(EnKarebaba* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKU_JR_DEAD); this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); this->actor.flags &= ~ACTOR_FLAG_1; - if (this->unk_1EC == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->unk_1EE = 3; } this->actionFunc = func_808F200C; } void func_808F200C(EnKarebaba* this, GlobalContext* globalCtx) { - if (this->unk_1EC == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->unk_1EE--; if (this->unk_1EE == 0) { func_808F1374(this, globalCtx); @@ -481,7 +481,7 @@ void func_808F20FC(EnKarebaba* this, GlobalContext* globalCtx) { func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 8); this->unk_1EE = 200; this->actor.flags &= ~ACTOR_FLAG_20; - this->unk_1F0 = 0.0f; + this->drawDmgEffAlpha = 0.0f; this->actionFunc = func_808F21A4; } @@ -530,7 +530,7 @@ void func_808F238C(EnKarebaba* this) { this->unk_1EE = 200; this->actor.parent = NULL; this->actor.shape.shadowScale = 0.0f; - this->unk_1F0 = 0.0f; + this->drawDmgEffAlpha = 0.0f; Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); this->actionFunc = func_808F254C; } @@ -580,16 +580,16 @@ void EnKarebaba_Update(Actor* thisx, GlobalContext* globalCtx2) { this->actionFunc(this, globalCtx); - if (this->unk_1F0 > 0.0f) { - if (this->unk_1EC != 10) { - Math_StepToF(&this->unk_1F0, 0.0f, 0.05f); - this->unk_1F4 = (this->unk_1F0 + 1.0f) * 0.375f; - if (this->unk_1F4 > 0.75f) { - this->unk_1F4 = 0.75f; + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.375f; + if (this->drawDmgEffScale > 0.75f) { + this->drawDmgEffScale = 0.75f; } else { - this->unk_1F4 = this->unk_1F4; + this->drawDmgEffScale = this->drawDmgEffScale; } - } else if (!Math_StepToF(&this->unk_1F8, 0.75f, 0.01875f)) { + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, 0.01875f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -646,13 +646,13 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { EnKarebaba* this = THIS; s32 i; s32 sp94; - s16 phi_a3; + s16 limbCount; f32 sp8C = 0.01f; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Math_Vec3f_Copy(this->unk_1FC, &this->actor.world.pos); + Math_Vec3f_Copy(this->limbPos, &this->actor.world.pos); if (this->actionFunc == func_808F21A4) { if ((this->unk_1EE > 40) || (this->unk_1EE & 1)) { @@ -691,7 +691,7 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_808F2E2C[i]); - Matrix_GetStateTranslation(&this->unk_1FC[1 + i]); + Matrix_GetStateTranslation(&this->limbPos[1 + i]); if ((i == 0) && (this->actionFunc == func_808F1C84)) { Matrix_GetStateTranslation(&this->actor.focus.pos); } @@ -719,19 +719,19 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_001828); - Matrix_GetStateTranslation(&this->unk_1FC[3]); + Matrix_GetStateTranslation(&this->limbPos[3]); } func_800AE5A0(globalCtx); if (this->actor.params == ENKAREBABA_2) { - phi_a3 = 1; + limbCount = 1; } else { - phi_a3 = 4; + limbCount = ARRAY_COUNT(this->limbPos); } - func_800BE680(globalCtx, &this->actor, this->unk_1FC, phi_a3, this->unk_1F4, this->unk_1F8, this->unk_1F0, - this->unk_1EC); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, limbCount, this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); if (this->unk_22C != 0) { func_808F280C(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h index 9fd021e5f..e91e151ae 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h @@ -19,12 +19,12 @@ typedef struct EnKarebaba { /* 0x0188 */ EnKarebabaActionFunc actionFunc; /* 0x018C */ Vec3s jointTable[8]; /* 0x01BC */ Vec3s morphTable[8]; - /* 0x01EC */ u8 unk_1EC; + /* 0x01EC */ u8 drawDmgEffType; /* 0x01EE */ s16 unk_1EE; - /* 0x01F0 */ f32 unk_1F0; - /* 0x01F4 */ f32 unk_1F4; - /* 0x01F8 */ f32 unk_1F8; - /* 0x01FC */ Vec3f unk_1FC[4]; + /* 0x01F0 */ f32 drawDmgEffAlpha; + /* 0x01F4 */ f32 drawDmgEffScale; + /* 0x01F8 */ f32 drawDmgEffFrozenSteamScale; + /* 0x01FC */ Vec3f limbPos[4]; /* 0x022C */ CollisionPoly* unk_22C; /* 0x0230 */ ColliderCylinder collider1; /* 0x027C */ ColliderCylinder collider2; diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c index bab9aee20..d8731cc85 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -231,21 +231,21 @@ u8 EnPametfrog_Vec3fNormalize(Vec3f* vec) { } void EnPametfrog_Freeze(EnPametfrog* this) { - this->drawEffect = GEKKO_DRAW_EFFECT_FROZEN; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider.base.colType = COLTYPE_HIT3; this->collider.elements->info.elemType = ELEMTYPE_UNK0; - this->unk_2C8 = 0.75f; - this->unk_2CC = 1.125f; - this->unk_2C4 = 1.0f; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffFrozenSteamScale = 1.125f; + this->drawDmgEffAlpha = 1.0f; } void EnPametfrog_Thaw(EnPametfrog* this, GlobalContext* globalCtx) { this->freezeTimer = 0; - if (this->drawEffect == GEKKO_DRAW_EFFECT_FROZEN) { - this->drawEffect = GEKKO_DRAW_EFFECT_THAW; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; this->collider.elements->info.elemType = ELEMTYPE_UNK1; - this->unk_2C4 = 0.0f; + this->drawDmgEffAlpha = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); } } @@ -387,13 +387,13 @@ void EnPametfrog_JumpOnGround(EnPametfrog* this, GlobalContext* globalCtx) { void EnPametfrog_ApplyMagicArrowEffects(EnPametfrog* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_FIRE) { - this->drawEffect = GEKKO_DRAW_EFFECT_THAW; - this->unk_2C4 = 3.0f; - this->unk_2C8 = 0.75f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 3.0f; + this->drawDmgEffScale = 0.75f; } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_LIGHT) { - this->drawEffect = GEKKO_DRAW_EFFECT_LIGHT_ORBS; - this->unk_2C8 = 0.75f; - this->unk_2C4 = 3.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 3.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.elements[0].info.bumper.hitPos.x, this->collider.elements[0].info.bumper.hitPos.y, this->collider.elements[0].info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -406,9 +406,9 @@ void EnPametfrog_ApplyElectricStun(EnPametfrog* this) { this->freezeTimer = 40; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); - this->drawEffect = GEKKO_DRAW_EFFECT_ELECTRIC_STUN; - this->unk_2C8 = 0.75f; - this->unk_2C4 = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 2.0f; } void EnPametfrog_ApplyStun(EnPametfrog* this) { @@ -1265,7 +1265,7 @@ void EnPametfrog_TransitionGekkoSnapper(EnPametfrog* this, GlobalContext* global void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - if ((this->drawEffect != GEKKO_DRAW_EFFECT_FROZEN) || + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || !(this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { if (this->actor.params == GEKKO_PRE_SNAPPER) { if (Actor_ApplyDamage(&this->actor) == 0) { @@ -1286,13 +1286,13 @@ void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, GlobalContext* globalCtx) } else { EnPametfrog_Thaw(this, globalCtx); if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_FIRE) { - this->drawEffect = GEKKO_DRAW_EFFECT_THAW; - this->unk_2C8 = 0.75f; - this->unk_2C4 = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_LIGHT) { - this->drawEffect = GEKKO_DRAW_EFFECT_LIGHT_ORBS; - this->unk_2C8 = 0.75f; - this->unk_2C4 = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.elements[0].info.bumper.hitPos.x, this->collider.elements[0].info.bumper.hitPos.y, @@ -1357,13 +1357,14 @@ void EnPametfrog_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } - if (this->unk_2C4 > 0.0f) { - if ((this->drawEffect != GEKKO_DRAW_EFFECT_FROZEN) && (this->actionFunc != EnPametfrog_PlayCutscene)) { - Math_StepToF(&this->unk_2C4, 0.0f, 0.05f); - unk2C4 = ((this->unk_2C4 + 1.0f) * 0.375f); - this->unk_2C8 = unk2C4; - this->unk_2C8 = unk2C4 > 0.75f ? 0.75f : this->unk_2C8; - } else if (!Math_StepToF(&this->unk_2CC, 0.75f, (3.0f / 160.0f))) { + if (this->drawDmgEffAlpha > 0.0f) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->actionFunc != EnPametfrog_PlayCutscene)) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + unk2C4 = ((this->drawDmgEffAlpha + 1.0f) * 0.375f); + this->drawDmgEffScale = unk2C4; + this->drawDmgEffScale = unk2C4 > 0.75f ? 0.75f : this->drawDmgEffScale; + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, (3.0f / 160.0f))) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1420,6 +1421,6 @@ void EnPametfrog_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_RotateY(this->spinYaw, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnPametfrog_PostLimbDraw, &this->actor); - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->unk_2C8, this->unk_2CC, - this->unk_2C4, this->drawEffect); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h index 97a682825..2b21f3ea3 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h @@ -20,13 +20,6 @@ typedef enum { /* 0x9 */ GEKKO_DEFEAT, } EnPametfrogState; -typedef enum { - /* 00 */ GEKKO_DRAW_EFFECT_THAW, - /* 10 */ GEKKO_DRAW_EFFECT_FROZEN = 10, - /* 20 */ GEKKO_DRAW_EFFECT_LIGHT_ORBS = 20, - /* 30 */ GEKKO_DRAW_EFFECT_ELECTRIC_STUN = 30, -} EnPametfrogDrawEffectType; - typedef enum { /* 0x00 */ GEKKO_LIMB_NONE, /* 0x01 */ GEKKO_LIMB_ROOT, @@ -61,7 +54,7 @@ typedef struct EnPametfrog { /* 0x188 */ Vec3s jointTable[GEKKO_LIMB_MAX]; /* 0x218 */ Vec3s morphTable[GEKKO_LIMB_MAX]; /* 0x2A8 */ EnPametfrogActionFunc actionFunc; - /* 0x2AC */ u8 drawEffect; + /* 0x2AC */ u8 drawDmgEffType; /* 0x2AD */ u8 wallPauseTimer; // Gekko stops 10 times along wall/ceiling after being blown off of Snapper /* 0x2AE */ u8 unk_2AE; // True/False /* 0x2B0 */ s16 cutscene; @@ -72,9 +65,9 @@ typedef struct EnPametfrog { /* 0x2BA */ s16 subCamId; /* 0x2BC */ s16 freezeTimer; /* 0x2C0 */ f32 wallRotation; - /* 0x2C4 */ f32 unk_2C4; - /* 0x2C8 */ f32 unk_2C8; - /* 0x2CC */ f32 unk_2CC; + /* 0x2C4 */ f32 drawDmgEffAlpha; + /* 0x2C8 */ f32 drawDmgEffScale; + /* 0x2CC */ f32 drawDmgEffFrozenSteamScale; /* 0x2D0 */ Vec3f unk_2D0; // MtxF zx/zy/zz /* 0x2DC */ Vec3f unk_2DC; // MtxF yx/yy/yz: wallNorm/floorNorm/Base of Gekko walking??? /* 0x2E8 */ Vec3f unk_2E8; // MtxF xx/xy/xz diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c index f6da4cba2..b528e60c3 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -227,21 +227,21 @@ void EnPeehat_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80897170(EnPeehat* this) { - this->unk_2AE = 10; - this->unk_2CC = 1.1f; - this->unk_2D0 = 1.6500001f; - this->unk_2C8 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 1.1f; + this->drawDmgEffFrozenSteamScale = 1.6500001f; + this->drawDmgEffAlpha = 1.0f; this->colliderSphere.base.colType = COLTYPE_HIT3; this->unk_2B0 = 80; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808971DC(EnPeehat* this, GlobalContext* globalCtx) { - if (this->unk_2AE == 10) { - this->unk_2AE = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->colliderSphere.base.colType = COLTYPE_HIT6; - this->unk_2C8 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2EC, ARRAY_COUNT(this->unk_2EC), 2, 0.5f, 0.35f); + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.5f, 0.35f); } } @@ -685,7 +685,8 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { if (this->colliderSphere.base.acFlags & AC_HIT) { this->colliderSphere.base.acFlags &= ~AC_HIT; - if ((this->unk_2AE != 10) || !(this->colliderSphere.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->colliderSphere.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { if (!Actor_ApplyDamage(&this->actor)) { Enemy_StartFinishingBlow(globalCtx, &this->actor); } @@ -698,9 +699,9 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { this->unk_2B0 = 40; Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_2CC = 1.1f; - this->unk_2C8 = 2.0f; - this->unk_2AE = 32; + this->drawDmgEffScale = 1.1f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; func_80898414(this); } else if (this->actor.colChkInfo.damageEffect == 1) { this->unk_2B0 = 40; @@ -716,13 +717,13 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { func_80898414(this); } else { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2C8 = 4.0f; - this->unk_2CC = 2.1f; - this->unk_2AE = 0; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 2.1f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2C8 = 4.0f; - this->unk_2CC = 1.1f; - this->unk_2AE = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 1.1f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->colliderSphere.info.bumper.hitPos.x, this->colliderSphere.info.bumper.hitPos.y, this->colliderSphere.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -731,8 +732,10 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { func_808984E0(this); } } - } else if ((this->unk_2AE == 10) && (this->colliderCylinder.base.acFlags & AC_HIT) && - ((this->unk_2AE != 10) || !(this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + } else if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->colliderCylinder.base.acFlags & AC_HIT) && + ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { func_808971DC(this, globalCtx); this->actor.colorFilterTimer = 0; func_80897648(this); @@ -812,17 +815,17 @@ void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx2) { Math_StepToF(&this->unk_2C4, 0.0f, 0.001f); } - if (this->unk_2C8 > 0.0f) { - if (this->unk_2AE != 10) { - Math_StepToF(&this->unk_2C8, 0.0f, 0.05f); - if (this->unk_2AE == 0) { - this->unk_2CC = (this->unk_2C8 + 1.0f) * 1.05f; - this->unk_2CC = CLAMP_MAX(this->unk_2CC, 2.1f); + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) { + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 1.05f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 2.1f); } else { - this->unk_2CC = (this->unk_2C8 + 1.0f) * 0.55f; - this->unk_2CC = CLAMP_MAX(this->unk_2CC, 1.1f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.55f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 1.1f); } - } else if (!Math_StepToF(&this->unk_2D0, 1.1f, 0.0275f)) { + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 1.1f, 0.0275f)) { func_800B9010(thisx, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -879,8 +882,8 @@ void EnPeehat_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList Gfx* gfx; if (index != -1) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_2EC[index]); - Matrix_GetStateTranslationAndScaledX(4000.0f, &this->unk_2EC[index + 1]); + Matrix_GetStateTranslationAndScaledX(2000.0f, &this->limbPos[index]); + Matrix_GetStateTranslationAndScaledX(4000.0f, &this->limbPos[index + 1]); } if (limbIndex == 4) { @@ -888,7 +891,7 @@ void EnPeehat_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList Matrix_GetStateTranslationAndScaledZ(-5500.0f, &this->unk_2D4[1]); } else if ((limbIndex == 3) && (thisx->params == 0)) { Vec3f* vec = &D_80899570[0]; - Vec3f* vec2 = &this->unk_2EC[12]; + Vec3f* vec2 = &this->limbPos[12]; for (i = 0; i < ARRAY_COUNT(D_80899570); i++, vec++, vec2++) { Matrix_MultiplyVector3fByState(vec, vec2); @@ -937,12 +940,12 @@ void EnPeehat_Draw(Actor* thisx, GlobalContext* globalCtx) { Collider_SetTrisVertices(&this->colliderTris, 1, &sp40, &sp58, &sp4C); } - if (this->unk_2AE == 0) { - for (i = 0; i < ARRAY_COUNT(this->unk_2EC); i++) { - this->unk_2EC[i].y -= 50.0f; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) { + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { + this->limbPos[i].y -= 50.0f; } } - func_800BE680(globalCtx, &this->actor, this->unk_2EC, ARRAY_COUNT(this->unk_2EC), this->unk_2CC, this->unk_2D0, - this->unk_2C8, this->unk_2AE); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h index 0aee3a742..a7bda3577 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h @@ -15,7 +15,7 @@ typedef struct EnPeehat { /* 0x2A8 */ EnPeehatActionFunc actionFunc; /* 0x2AC */ u8 unk_2AC; /* 0x2AD */ s8 unk_2AD; - /* 0x2AE */ u8 unk_2AE; + /* 0x2AE */ u8 drawDmgEffType; /* 0x2B0 */ s16 unk_2B0; /* 0x2B2 */ s16 unk_2B2; /* 0x2B4 */ s16 unk_2B4; @@ -24,11 +24,11 @@ typedef struct EnPeehat { /* 0x2BC */ f32 unk_2BC; /* 0x2C0 */ f32 unk_2C0; /* 0x2C4 */ f32 unk_2C4; - /* 0x2C8 */ f32 unk_2C8; - /* 0x2CC */ f32 unk_2CC; - /* 0x2D0 */ f32 unk_2D0; + /* 0x2C8 */ f32 drawDmgEffAlpha; + /* 0x2CC */ f32 drawDmgEffScale; + /* 0x2D0 */ f32 drawDmgEffFrozenSteamScale; /* 0x2D4 */ Vec3f unk_2D4[2]; - /* 0x2EC */ Vec3f unk_2EC[18]; + /* 0x2EC */ Vec3f limbPos[18]; /* 0x3C4 */ ColliderCylinder colliderCylinder; /* 0x410 */ ColliderSphere colliderSphere; /* 0x468 */ ColliderTris colliderTris; diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index b5a3655ac..1cd7a4f83 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c @@ -872,8 +872,8 @@ void func_80B1C408(EnPoSisters* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2F0 = 4.0f; - this->unk_2F4 = 0.5f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.5f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -922,17 +922,17 @@ void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.shadowAlpha = this->unk_229; Actor_SetFocus(&this->actor, 40.0f); - if (this->unk_2F0 > 0.0f) { - Math_StepToF(&this->unk_2F0, 0.0f, 0.05f); + if (this->drawDmgEffAlpha > 0.0f) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); if (this->unk_229 != 255) { temp_f2 = this->unk_229 * (1.0f / 255); if (temp_f2 < this->unk_229) { - this->unk_2F0 = temp_f2; + this->drawDmgEffAlpha = temp_f2; } } - this->unk_2F4 = (this->unk_2F0 + 1.0f) * 0.25f; - this->unk_2F4 = CLAMP_MAX(this->unk_2F4, 0.5f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.25f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.5f); } if (this->unk_191 & (0x10 | 0x8 | 0x4 | 0x2 | 0x1)) { @@ -1057,14 +1057,14 @@ void EnPoSisters_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi f32 temp_f2; if (D_80B1DB08[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_28C[D_80B1DB08[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_80B1DB08[limbIndex]]); } else if (limbIndex == 9) { - Matrix_GetStateTranslationAndScaledY(-2500.0f, &this->unk_28C[4]); - Matrix_GetStateTranslationAndScaledY(3000.0f, &this->unk_28C[5]); + Matrix_GetStateTranslationAndScaledY(-2500.0f, &this->limbPos[4]); + Matrix_GetStateTranslationAndScaledY(3000.0f, &this->limbPos[5]); } else if (limbIndex == 10) { - Matrix_GetStateTranslationAndScaledY(-4000.0f, &this->unk_28C[6]); + Matrix_GetStateTranslationAndScaledY(-4000.0f, &this->limbPos[6]); } else if (limbIndex == 11) { - Matrix_GetStateTranslationAndScaledX(3000.0f, &this->unk_28C[7]); + Matrix_GetStateTranslationAndScaledX(3000.0f, &this->limbPos[7]); } if ((this->actionFunc == func_80B1BA90) && (this->unk_192 >= 8) && (limbIndex == 9)) { @@ -1179,8 +1179,9 @@ void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); } - func_800BE680(globalCtx, &this->actor, this->unk_28C, ARRAY_COUNT(this->unk_28C), - this->actor.scale.x * 142.857131958f * this->unk_2F4, 0.0f, this->unk_2F0, 20); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->actor.scale.x * 142.857131958f * this->drawDmgEffScale, 0.0f, this->drawDmgEffAlpha, + ACTOR_DRAW_DMGEFF_LIGHT_ORBS); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h index 741ebbcce..3350f8f03 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h @@ -30,10 +30,10 @@ typedef struct EnPoSisters { /* 0x0228 */ u8 unk_228; /* 0x0229 */ u8 unk_229; /* 0x022C */ Vec3f unk_22C[8]; - /* 0x028C */ Vec3f unk_28C[8]; + /* 0x028C */ Vec3f limbPos[8]; /* 0x02EC */ f32 unk_2EC; - /* 0x02F0 */ f32 unk_2F0; - /* 0x02F4 */ f32 unk_2F4; + /* 0x02F0 */ f32 drawDmgEffAlpha; + /* 0x02F4 */ f32 drawDmgEffScale; /* 0x02F8 */ LightNode* lightNode; /* 0x02FC */ LightInfo lightInfo; /* 0x030C */ ColliderCylinder collider; diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.c b/src/overlays/actors/ovl_En_Poh/z_en_poh.c index e3a5d30be..22f590c44 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -707,8 +707,8 @@ void func_80B2E438(EnPoh* this, GlobalContext* globalCtx) { func_80B2D924(this); } else { if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_298 = 4.0f; - this->unk_29C = 0.45f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.45f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->colliderCylinder.info.bumper.hitPos.x, this->colliderCylinder.info.bumper.hitPos.y, @@ -834,16 +834,16 @@ void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx2) { func_80B2E8E0(this); this->actor.shape.shadowAlpha = this->unk_197; - if (this->unk_298 > 0.0f) { - Math_StepToF(&this->unk_298, 0.0f, 0.05f); + if (this->drawDmgEffAlpha > 0.0f) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); if (this->unk_197 != 255) { if (this->unk_197 * (1.0f / 255.0f) < this->unk_197) { - this->unk_298 = this->unk_197 * (1.0f / 255.0f); + this->drawDmgEffAlpha = this->unk_197 * (1.0f / 255.0f); } } - this->unk_29C = (this->unk_298 + 1.0f) * (9.0f / 40.0f); - this->unk_29C = CLAMP_MAX(this->unk_29C, 0.45f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * (9.0f / 40.0f); + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.45f); } } @@ -899,18 +899,18 @@ void EnPoh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve temp_s3 = D_80B2F71C[limbIndex]; if (temp_s3 != -1) { if (temp_s3 < 4) { - Matrix_GetStateTranslation(&this->unk_2A0[temp_s3]); + Matrix_GetStateTranslation(&this->limbPos[temp_s3]); } else if (temp_s3 == 4) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_2A0[temp_s3]); + Matrix_GetStateTranslationAndScaledX(2000.0f, &this->limbPos[temp_s3]); } else { s32 i; - Vec3f* vec = &this->unk_2A0[temp_s3 + 2]; + Vec3f* vec = &this->limbPos[temp_s3 + 2]; Vec3f* vec2 = &D_80B2F734[0]; - Matrix_GetStateTranslationAndScaledX(-2000.0f, &this->unk_2A0[temp_s3]); - Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->unk_2A0[temp_s3 + 1]); + Matrix_GetStateTranslationAndScaledX(-2000.0f, &this->limbPos[temp_s3]); + Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->limbPos[temp_s3 + 1]); - for (i = temp_s3 + 2; i < ARRAY_COUNT(this->unk_2A0); i++, vec++, vec2++) { + for (i = temp_s3 + 2; i < ARRAY_COUNT(this->limbPos); i++, vec++, vec2++) { Matrix_MultiplyVector3fByState(vec2, vec); } } @@ -958,8 +958,9 @@ void EnPoh_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(&gfx[3], object_po_DL_002D28); POLY_OPA_DISP = &gfx[4]; - func_800BE680(globalCtx, &this->actor, this->unk_2A0, 10, this->actor.scale.x * 100.0f * this->unk_29C, 0.0f, - this->unk_298, 20); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->actor.scale.x * 100.0f * this->drawDmgEffScale, 0.0f, this->drawDmgEffAlpha, + ACTOR_DRAW_DMGEFF_LIGHT_ORBS); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.h b/src/overlays/actors/ovl_En_Poh/z_en_poh.h index fe579e027..f4787b357 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.h +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.h @@ -26,9 +26,9 @@ typedef struct EnPoh { /* 0x019B */ u8 unk_19B; /* 0x019C */ Vec3s jointTable[21]; /* 0x021A */ Vec3s morphTable[21]; - /* 0x0298 */ f32 unk_298; - /* 0x029C */ f32 unk_29C; - /* 0x02A0 */ Vec3f unk_2A0[10]; + /* 0x0298 */ f32 drawDmgEffAlpha; + /* 0x029C */ f32 drawDmgEffScale; + /* 0x02A0 */ Vec3f limbPos[10]; /* 0x0318 */ LightNode* lightNode; /* 0x031C */ LightInfo lightInfo; /* 0x032C */ ColliderCylinder colliderCylinder; diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.c b/src/overlays/actors/ovl_En_Pr/z_en_pr.c index cbc26c8b7..f8c702479 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.c +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.c @@ -457,15 +457,15 @@ void func_80A33098(EnPr* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_22E = 40; - this->unk_230 = 20; + this->drawDmgEffAlpha = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } if ((player->stateFlags1 & 0x8000000) && (this->actor.colChkInfo.damageEffect == 5)) { - this->unk_22E = 40; - this->unk_230 = 31; + this->drawDmgEffAlpha = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; } if ((this->unk_206 != 6) && (this->unk_206 != 7)) { @@ -580,9 +580,9 @@ void EnPr_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if ((limbIndex == 0) || (limbIndex == 1) || (limbIndex == 2) || (limbIndex == 3) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9)) { - Matrix_GetStateTranslation(&this->unk_23C[this->unk_228]); + Matrix_GetStateTranslation(&this->limbPos[this->unk_228]); this->unk_228++; - if (this->unk_228 >= ARRAY_COUNT(this->unk_23C)) { + if (this->unk_228 >= ARRAY_COUNT(this->limbPos)) { this->unk_228 = 0; } } @@ -613,12 +613,13 @@ void EnPr_Draw(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.dListCount, NULL, NULL, &this->actor, POLY_XLU_DISP); } - if (this->unk_22E != 0) { - f32 temp = this->unk_22E * 0.05f; + if (this->drawDmgEffAlpha != 0) { + f32 drawDmgEffAlpha = this->drawDmgEffAlpha * 0.05f; this->unk_238 = 0.8f; this->unk_234 = 0.8f; - func_800BE680(globalCtx, &this->actor, this->unk_23C, 10, 0.8f, 0.8f, temp, this->unk_230); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 0.8f, 0.8f, + drawDmgEffAlpha, this->drawDmgEffType); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.h b/src/overlays/actors/ovl_En_Pr/z_en_pr.h index 6506c0d74..18123e119 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.h +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.h @@ -33,11 +33,11 @@ typedef struct EnPr { /* 0x0220 */ UNK_TYPE1 unk220[0x8]; /* 0x0228 */ s32 unk_228; /* 0x022C */ s16 unk_22C; - /* 0x022E */ s16 unk_22E; - /* 0x0230 */ s16 unk_230; + /* 0x022E */ s16 drawDmgEffAlpha; + /* 0x0230 */ s16 drawDmgEffType; /* 0x0234 */ f32 unk_234; /* 0x0238 */ f32 unk_238; - /* 0x023C */ Vec3f unk_23C[10]; + /* 0x023C */ Vec3f limbPos[10]; /* 0x02B4 */ f32 unk_2B4; /* 0x02B8 */ f32 unk_2B8; /* 0x02BC */ f32 unk_2BC; diff --git a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c index f29f3b6a7..3b000eb13 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c @@ -287,7 +287,7 @@ void EnRailSkb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2E4 = -1; this->unk_3FC = 0; this->unk_3FA = 0; - this->unk_403 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->unk_3FE = 0; if (this->actor.parent == NULL) { @@ -351,10 +351,10 @@ void func_80B71114(EnRailSkb* this) { } void func_80B7114C(EnRailSkb* this, GlobalContext* globalCtx) { - if (this->unk_3F0 == 0) { - this->unk_3F0 = 0; - this->unk_2F0 = 0.0f; - this->unk_2EC = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -365,7 +365,7 @@ void func_80B7114C(EnRailSkb* this, GlobalContext* globalCtx) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80B71488(this); } - } else if (this->unk_3F0 == 1) { + } else if (this->drawDmgEffTimer == 1) { func_80B726B4(this, globalCtx); } } @@ -375,10 +375,10 @@ void func_80B71228(EnRailSkb* this) { } void func_80B7123C(EnRailSkb* this, GlobalContext* globalCtx) { - if (this->unk_3F0 == 0) { - this->unk_3F0 = 0; - this->unk_2F0 = 0.0f; - this->unk_2EC = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -671,8 +671,8 @@ void func_80B71DF0(EnRailSkb* this) { this->actor.draw = EnRailSkb_Draw; this->actor.shape.shadowAlpha = 0; this->actor.shape.rot.y = this->actor.world.rot.y; - } else if ((this->actionFunc == func_80B7114C) && (this->unk_3F0 >= 2)) { - this->unk_3F0 = 0; + } else if ((this->actionFunc == func_80B7114C) && (this->drawDmgEffTimer > 1)) { + this->drawDmgEffTimer = 0; } Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); @@ -855,20 +855,20 @@ void func_80B72430(EnRailSkb* this, GlobalContext* globalCtx, s32 arg2) { } void func_80B725C0(EnRailSkb* this, GlobalContext* globalCtx) { - if (this->unk_3F0 > 0) { - this->unk_3F0--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } if (this->actionFunc != func_80B7114C) { - if (this->unk_3F0 < 20) { + if (this->drawDmgEffTimer < 20) { if (this->actionFunc == func_80B7123C) { - Math_SmoothStepToF(&this->unk_2F0, 0.0f, 0.5f, 0.03f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); } else { - Math_SmoothStepToF(&this->unk_2F0, 0.0f, 0.5f, 0.01f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.01f, 0.0f); } - this->unk_2EC = this->unk_3F0 * 0.05f; + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_2F0, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } } @@ -883,21 +883,21 @@ void func_80B726B4(EnRailSkb* this, GlobalContext* globalCtx) { s16 yaw; if (this->unk_402 & 2) { - end = ARRAY_COUNT(this->unk_234) - 1; + end = ARRAY_COUNT(this->limbPos) - 1; } else { - end = ARRAY_COUNT(this->unk_234); + end = ARRAY_COUNT(this->limbPos); } SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); for (i = 0; i < end; i++) { - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_234[i]); + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->limbPos[i]); sp84.x = Math_SinS(yaw) * 3.0f; sp84.z = Math_CosS(yaw) * 3.0f; sp84.y = (Rand_ZeroOne() * 4.0f) + 4.0f; - EffectSsEnIce_Spawn(globalCtx, &this->unk_234[i], 0.6f, &sp84, &D_80B734B8, &D_80B734B0, &D_80B734B4, 30); + EffectSsEnIce_Spawn(globalCtx, &this->limbPos[i], 0.6f, &sp84, &D_80B734B8, &D_80B734B0, &D_80B734B4, 30); } } @@ -964,10 +964,10 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { return; default: - if (this->unk_3F0 >= 2) { + if (this->drawDmgEffTimer >= 2) { func_80B726B4(this, globalCtx); } - this->unk_3F0 = 0; + this->drawDmgEffTimer = 0; break; } } @@ -981,10 +981,10 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { case 11: - this->unk_3F0 = 40; - this->unk_403 = 30; - this->unk_2EC = 1.0f; - this->unk_2F0 = 0.0f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0, 120, 0, 40); func_80B710AC(this); break; @@ -995,10 +995,10 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { break; case 2: - this->unk_3F0 = 80; - this->unk_403 = 0; - this->unk_2EC = 1.0f; - this->unk_2F0 = 0.0f; + this->drawDmgEffTimer = 80; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -1009,22 +1009,22 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { case 3: if (this->actor.colChkInfo.health != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - this->unk_3F0 = 80; + this->drawDmgEffTimer = 80; } else { - this->unk_3F0 = 3; + this->drawDmgEffTimer = 3; } - this->unk_403 = 11; - this->unk_2EC = 1.0f; - this->unk_2F0 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); func_80B71114(this); break; case 4: - this->unk_3F0 = 40; - this->unk_403 = 20; - this->unk_2EC = 1.0f; - this->unk_2F0 = 0.5f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -1125,15 +1125,15 @@ void EnRailSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); } - if (this->unk_3F0 != 0) { + 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)) { - Matrix_GetStateTranslation(&this->unk_234[this->unk_2DC]); - this->unk_2DC++; + Matrix_GetStateTranslation(&this->limbPos[this->limbCount]); + this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_402 & 2)) { - Matrix_MultiplyVector3fByState(&D_80B734D0, &this->unk_234[this->unk_2DC]); - this->unk_2DC++; + Matrix_MultiplyVector3fByState(&D_80B734D0, &this->limbPos[this->limbCount]); + this->limbCount++; } } } @@ -1142,13 +1142,13 @@ void EnRailSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList void EnRailSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { EnRailSkb* this = THIS; - this->unk_2DC = 0; + this->limbCount = 0; func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnRailSkb_OverrideLimbDraw, EnRailSkb_PostLimbDraw, &this->actor); - if (this->unk_3F0 > 0) { - func_800BE680(globalCtx, &this->actor, this->unk_234, this->unk_2DC, this->unk_2F0, 0.5f, this->unk_2EC, - this->unk_403); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, this->limbCount, this->drawDmgEffScale, 0.5f, + this->drawDmgEffAlpha, this->drawDmgEffType); } if ((this->unk_402 & 0x40) && !(this->unk_402 & 0x80)) { diff --git a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.h b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.h index 23202ef19..6346eebe2 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.h +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.h @@ -19,17 +19,17 @@ typedef struct EnRailSkb { /* 0x228 */ EnRailSkbActionFunc actionFunc; /* 0x22C */ ObjHakaisi* unk_22C; /* 0x230 */ Vec3s* unk_230; - /* 0x234 */ Vec3f unk_234[14]; - /* 0x2DC */ s32 unk_2DC; + /* 0x234 */ Vec3f limbPos[14]; + /* 0x2DC */ s32 limbCount; /* 0x2E0 */ s32 unk_2E0; /* 0x2E4 */ s32 unk_2E4; /* 0x2E8 */ s32 unk_2E8; - /* 0x2EC */ f32 unk_2EC; - /* 0x2F0 */ f32 unk_2F0; + /* 0x2EC */ f32 drawDmgEffAlpha; + /* 0x2F0 */ f32 drawDmgEffScale; /* 0x2F4 */ Vec3s jointTable[20]; /* 0x36C */ Vec3s morphTable[20]; /* 0x3E4 */ UNK_TYPE1 unk3E4[0xC]; - /* 0x3F0 */ s16 unk_3F0; + /* 0x3F0 */ s16 drawDmgEffTimer; /* 0x3F2 */ s16 unk_3F2; /* 0x3F4 */ s16 unk_3F4; /* 0x3F6 */ s16 unk_3F6; @@ -39,7 +39,7 @@ typedef struct EnRailSkb { /* 0x3FE */ s16 unk_3FE; /* 0x400 */ u16 unk_400; /* 0x402 */ u8 unk_402; - /* 0x403 */ u8 unk_403; + /* 0x403 */ u8 drawDmgEffType; } EnRailSkb; // size = 0x404 extern const ActorInit En_Rail_Skb_InitVars; 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 39232befa..e1266fbca 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -255,7 +255,7 @@ void EnRailgibud_Init(Actor* thisx, GlobalContext* globalCtx) { EnRailgibud_SpawnOtherGibdosAndSetPositionAndRotation(this, globalCtx); this->playerStunWaitTimer = 0; this->timeInitialized = gSaveContext.time; - this->effectType = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->type = EN_RAILGIBUD_TYPE_GIBDO; this->textId = 0; this->isInvincible = false; @@ -577,7 +577,8 @@ void EnRailgibud_Damage(EnRailgibud* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_405 = -1; this->actor.world.rot.y = this->actor.shape.rot.y; - if ((this->effectTimer > 0) && (this->effectType == 0) && (this->type == EN_RAILGIBUD_TYPE_GIBDO)) { + if ((this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && + (this->type == EN_RAILGIBUD_TYPE_GIBDO)) { this->actor.hintId = 0x2A; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, GIBDO_LIMB_MAX); @@ -592,7 +593,7 @@ void EnRailgibud_SetupStunned(EnRailgibud* this) { this->actor.world.rot.y = this->actor.shape.rot.y; this->stunTimer = 10; - if (this->effectTimer != 0) { + if (this->drawDmgEffTimer != 0) { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } else { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); @@ -649,7 +650,7 @@ void EnRailgibud_Dead(EnRailgibud* this, GlobalContext* globalCtx) { this->deathTimer++; } - if ((this->deathTimer == 20) && (this->effectTimer > 0) && (this->effectType == 0) && + if ((this->deathTimer == 20) && (this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && (this->type == EN_RAILGIBUD_TYPE_GIBDO)) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, GIBDO_LIMB_MAX); @@ -810,9 +811,9 @@ void EnRailgibud_UpdateDamage(EnRailgibud* this, GlobalContext* globalCtx) { } else { EnRailgibud_SetupDamage(this); } - this->effectType = 0; - this->effectTimer = 180; - this->effectAlpha = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffTimer = 180; + this->drawDmgEffAlpha = 1.0f; break; case EN_RAILGIBUD_DMGEFF_LIGHT_ARROW: @@ -822,17 +823,17 @@ void EnRailgibud_UpdateDamage(EnRailgibud* this, GlobalContext* globalCtx) { } else { EnRailgibud_SetupDamage(this); } - this->effectType = 20; - this->effectTimer = 60; - this->effectAlpha = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffTimer = 60; + this->drawDmgEffAlpha = 1.0f; break; case EN_RAILGIBUD_DMGEFF_ZORA_MAGIC: if ((this->actionFunc != EnRailgibud_Grab) && ((this->actionFunc != EnRailgibud_Stunned) || (this->stunTimer == 0))) { - this->effectType = 30; - this->effectTimer = 40; - this->effectAlpha = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffTimer = 40; + this->drawDmgEffAlpha = 1.0f; EnRailgibud_SetupStunned(this); } break; @@ -911,15 +912,15 @@ void EnRailgibud_MoveGrabbedPlayerAwayFromWall(EnRailgibud* this, GlobalContext* } void EnRailgibud_UpdateEffect(EnRailgibud* this, GlobalContext* globalCtx) { - if (this->effectTimer > 0) { - this->effectTimer--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } - if (this->effectTimer < 20) { - Math_SmoothStepToF(&this->effectScale, 0.0f, 0.5f, 0.03f, 0.0f); - this->effectAlpha = this->effectTimer * 0.05f; + if (this->drawDmgEffTimer < 20) { + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->effectScale, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } @@ -1050,7 +1051,7 @@ void EnRailgibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi Gfx** gfx) { EnRailgibud* this = THIS; - if ((this->effectTimer != 0) && + if ((this->drawDmgEffTimer != 0) && ((limbIndex == GIBDO_LIMB_LEFT_THIGH) || (limbIndex == GIBDO_LIMB_LEFT_SHIN) || (limbIndex == GIBDO_LIMB_LEFT_FOOT) || (limbIndex == GIBDO_LIMB_RIGHT_THIGH) || (limbIndex == GIBDO_LIMB_RIGHT_SHIN) || (limbIndex == GIBDO_LIMB_RIGHT_FOOT) || @@ -1089,9 +1090,9 @@ void EnRailgibud_Draw(Actor* thisx, GlobalContext* globalCtx) { EnRailgibud_PostLimbDraw, &this->actor, POLY_XLU_DISP); } - if (this->effectTimer > 0) { - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->effectScale, 0.5f, - this->effectAlpha, this->effectType); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); } CLOSE_DISPS(globalCtx->state.gfxCtx); 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 0ca4ec0b8..a51fd37d4 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h @@ -23,8 +23,8 @@ typedef struct EnRailgibud { /* 0x0294 */ Vec3s* points; /* 0x0298 */ s32 currentPoint; /* 0x029C */ s32 pathCount; - /* 0x02A0 */ f32 effectAlpha; - /* 0x02A4 */ f32 effectScale; + /* 0x02A0 */ f32 drawDmgEffAlpha; + /* 0x02A4 */ f32 drawDmgEffScale; /* 0x02A8 */ Vec3s jointTable[GIBDO_LIMB_MAX]; /* 0x0344 */ Vec3s morphTable[GIBDO_LIMB_MAX]; /* 0x03E0 */ Vec3s headRotation; @@ -44,14 +44,14 @@ typedef struct EnRailgibud { s16 sinkTimer; }; /* 0x03F4 */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero - /* 0x03F6 */ s16 effectTimer; + /* 0x03F6 */ s16 drawDmgEffTimer; /* 0x03F8 */ s16 type; /* 0x03FA */ s16 isInvincible; /* 0x03FC */ u16 actorActionCommand; /* 0x03FE */ u16 csAction; /* 0x0400 */ u16 textId; /* 0x0402 */ s16 timeInitialized; // unused other than setting it - /* 0x0404 */ u8 effectType; + /* 0x0404 */ u8 drawDmgEffType; /* 0x0405 */ s8 unk_405; // related to player->unk_ADD } EnRailgibud; // size = 0x408 diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c index 454836494..0326c13b7 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -1172,9 +1172,9 @@ void EnRd_UpdateDamage(EnRd* this, GlobalContext* globalCtx) { switch (this->damageEffect) { case EN_RD_DMGEFF_ZORA_MAGIC: if ((this->actionFunc != EnRd_Grab) && ((this->actionFunc != EnRd_Stunned) || (this->stunTimer == 0))) { - this->effectTimer = 40; - this->effectType = 30; - this->effectAlpha = 1.0f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffAlpha = 1.0f; EnRd_SetupStunned(this); } return; @@ -1185,20 +1185,20 @@ void EnRd_UpdateDamage(EnRd* this, GlobalContext* globalCtx) { case EN_RD_DMGEFF_FIRE_ARROW: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); - this->effectTimer = 180; - this->effectType = 0; + this->drawDmgEffTimer = 180; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->stunnedBySunsSong = false; this->sunsSongStunTimer = 0; - this->effectAlpha = 1.0f; + this->drawDmgEffAlpha = 1.0f; break; case EN_RD_DMGEFF_LIGHT_ARROW: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); - this->effectTimer = 60; - this->effectType = 20; + this->drawDmgEffTimer = 60; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; this->stunnedBySunsSong = false; this->sunsSongStunTimer = 0; - this->effectAlpha = 1.0f; + this->drawDmgEffAlpha = 1.0f; break; case EN_RD_DMGEFF_DAMAGE: @@ -1243,15 +1243,15 @@ void EnRd_UpdateCollision(EnRd* this, GlobalContext* globalCtx) { } void EnRd_UpdateEffect(EnRd* this, GlobalContext* globalCtx) { - if (this->effectTimer > 0) { - this->effectTimer--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } - if (this->effectTimer < 20) { - Math_SmoothStepToF(&this->effectScale, 0.0f, 0.5f, 0.03f, 0.0f); - this->effectAlpha = this->effectTimer * 0.05f; + if (this->drawDmgEffTimer < 20) { + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->effectScale, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } @@ -1308,7 +1308,7 @@ s32 EnRd_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnRd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnRd* this = THIS; - if ((this->effectTimer != 0) && + if ((this->drawDmgEffTimer != 0) && ((limbIndex == REDEAD_LIMB_LEFT_THIGH) || (limbIndex == REDEAD_LIMB_LEFT_SHIN) || (limbIndex == REDEAD_LIMB_LEFT_FOOT) || (limbIndex == REDEAD_LIMB_RIGHT_THIGH) || (limbIndex == REDEAD_LIMB_RIGHT_SHIN) || (limbIndex == REDEAD_LIMB_RIGHT_FOOT) || @@ -1357,8 +1357,8 @@ void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - if (this->effectTimer > 0) { - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->effectScale, 0.5f, - this->effectAlpha, this->effectType); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); } } diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.h b/src/overlays/actors/ovl_En_Rd/z_en_rd.h index 0340c7833..7bf5a6ddc 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.h +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.h @@ -38,8 +38,8 @@ typedef struct EnRd { /* 0x0190 */ ColliderCylinder collider; /* 0x01DC */ Vec3f limbPos[15]; /* 0x0290 */ s32 limbIndex; - /* 0x0294 */ f32 effectAlpha; - /* 0x0298 */ f32 effectScale; + /* 0x0294 */ f32 drawDmgEffAlpha; + /* 0x0298 */ f32 drawDmgEffScale; /* 0x029C */ Vec3s jointTable[REDEAD_LIMB_MAX]; /* 0x0338 */ Vec3s morphTable[REDEAD_LIMB_MAX]; /* 0x03D4 */ s16 headShakeTimer; @@ -59,8 +59,8 @@ typedef struct EnRd { s16 danceEndTimer; s16 pirouetteRotationalVelocity; }; - /* 0x03E6 */ s16 effectTimer; - /* 0x03E8 */ u8 effectType; + /* 0x03E6 */ s16 drawDmgEffTimer; + /* 0x03E8 */ u8 drawDmgEffType; /* 0x03E9 */ u8 stunnedBySunsSong; /* 0x03EA */ u8 grabDamageTimer; /* 0x03EB */ u8 grabState; diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.c b/src/overlays/actors/ovl_En_Rr/z_en_rr.c index 57f4b9bcd..17324a3b6 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -170,43 +170,43 @@ void EnRr_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_808FA01C(EnRr* this, GlobalContext* globalCtx, ColliderCylinder* collider) { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_220 = 0.85f; - this->unk_21C = 4.0f; - this->unk_1E0 = 0; + this->drawDmgEffScale = 0.85f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_220 = 0.85f; - this->unk_21C = 4.0f; - this->unk_1E0 = 20; + this->drawDmgEffScale = 0.85f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, collider->info.bumper.hitPos.x, collider->info.bumper.hitPos.y, collider->info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } else if (this->actor.colChkInfo.damageEffect == 5) { - this->unk_220 = 0.85f; - this->unk_21C = 4.0f; - this->unk_1E0 = 30; + this->drawDmgEffScale = 0.85f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; } } void func_808FA11C(EnRr* this) { - this->unk_1E0 = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider1.base.colType = COLTYPE_HIT3; this->collider1.info.elemType = ELEMTYPE_UNK0; this->unk_1EE = 80; - this->unk_220 = 0.85f; - this->unk_224 = 1.2750001f; - this->unk_21C = 1.0f; + this->drawDmgEffScale = 0.85f; + this->drawDmgEffFrozenSteamScale = 1.2750001f; + this->drawDmgEffAlpha = 1.0f; this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808FA19C(EnRr* this, GlobalContext* globalCtx) { this->unk_1EE = 0; - if (this->unk_1E0 == 10) { - this->unk_1E0 = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider1.base.colType = COLTYPE_HIT0; this->collider1.info.elemType = ELEMTYPE_UNK1; - this->unk_21C = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_234, 20, 2, this->actor.scale.y * 23.333334f, + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 20, 2, this->actor.scale.y * 23.333334f, this->actor.scale.y * 20.000002f); this->actor.flags |= ACTOR_FLAG_400; } @@ -456,7 +456,8 @@ s32 func_808FAA94(EnRr* this, GlobalContext* globalCtx) { this->collider1.base.acFlags &= ~AC_HIT; this->collider2.base.acFlags &= ~AC_HIT; - if ((this->unk_1E0 == 10) && (sp2C->info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (sp2C->info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { return false; } @@ -672,7 +673,7 @@ void func_808FB398(EnRr* this, GlobalContext* globalCtx) { return; } - if (this->unk_1E0 == 30) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL) { if (this->unk_1EC & 2) { phi_v1 = 1000; } else { @@ -854,12 +855,12 @@ void EnRr_Update(Actor* thisx, GlobalContext* globalCtx) { Math_StepToF(&this->unk_210, 1.0f, 0.2f); } - if (this->unk_21C > 0.0f) { - if (this->unk_1E0 != 10) { - Math_StepToF(&this->unk_21C, 0.0f, 0.05f); - this->unk_220 = (this->unk_21C + 1.0f) * 0.425f; - this->unk_220 = CLAMP_MAX(this->unk_220, 0.85f); - } else if (!Math_StepToF(&this->unk_224, 0.85f, 0.02125f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.425f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.85f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.85f, 0.02125f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -890,7 +891,7 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Scale((1.0f + this->unk_324[0].unk_10) * this->unk_324[0].unk_08, 1.0f, (1.0f + this->unk_324[0].unk_10) * this->unk_324[0].unk_08, MTXMODE_APPLY); - vecPtr = &this->unk_234[0]; + vecPtr = &this->limbPos[0]; gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -932,8 +933,9 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_OPA_DISP++, object_rr_DL_000470); - func_800BE680(globalCtx, &this->actor, this->unk_234, ARRAY_COUNT(this->unk_234), - this->actor.scale.y * 66.66667f * this->unk_220, this->unk_224, this->unk_21C, this->unk_1E0); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->actor.scale.y * 66.66667f * this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, + this->drawDmgEffAlpha, this->drawDmgEffType); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.h b/src/overlays/actors/ovl_En_Rr/z_en_rr.h index 036107477..e2c935b47 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.h +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.h @@ -31,7 +31,7 @@ typedef struct EnRr { /* 0x144 */ EnRrActionFunc actionFunc; /* 0x148 */ ColliderCylinder collider1; /* 0x194 */ ColliderCylinder collider2; - /* 0x1E0 */ u8 unk_1E0; + /* 0x1E0 */ u8 drawDmgEffType; /* 0x1E1 */ u8 unk_1E1; /* 0x1E2 */ u8 unk_1E2; /* 0x1E4 */ s16 unk_1E4; @@ -54,11 +54,11 @@ typedef struct EnRr { /* 0x210 */ f32 unk_210; /* 0x214 */ f32 unk_214; /* 0x218 */ f32 unk_218; - /* 0x21C */ f32 unk_21C; - /* 0x220 */ f32 unk_220; - /* 0x224 */ f32 unk_224; + /* 0x21C */ f32 drawDmgEffAlpha; + /* 0x220 */ f32 drawDmgEffScale; + /* 0x224 */ f32 drawDmgEffFrozenSteamScale; /* 0x228 */ Vec3f unk_228; - /* 0x234 */ Vec3f unk_234[20]; + /* 0x234 */ Vec3f limbPos[20]; /* 0x324 */ EnRrStruct unk_324[5]; } EnRr; // size = 0x3C4 diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index 4984c6160..0cac62a0d 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -754,10 +754,10 @@ void func_809962D4(EnSkb* this) { } void func_8099630C(EnSkb* this, GlobalContext* globalCtx) { - if (this->unk_3D2 == 0) { - this->unk_3D2 = 0; - this->unk_230 = 0.0f; - this->unk_22C = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -766,7 +766,7 @@ void func_8099630C(EnSkb* this, GlobalContext* globalCtx) { } else { func_809961E4(this, globalCtx); } - } else if (this->unk_3D2 == 1) { + } else if (this->drawDmgEffTimer == 1) { func_80996BEC(this, globalCtx); } } @@ -776,10 +776,10 @@ void func_809963C4(EnSkb* this) { } void func_809963D8(EnSkb* this, GlobalContext* globalCtx) { - if (this->unk_3D2 == 0) { - this->unk_3D2 = 0; - this->unk_230 = 0.0f; - this->unk_22C = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -885,10 +885,10 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { if (this->actionFunc == func_8099630C) { switch (this->actor.colChkInfo.damageEffect) { default: - if (this->unk_3D2 >= 2) { + if (this->drawDmgEffTimer > 1) { func_80996BEC(this, globalCtx); } - this->unk_3D2 = 0; + this->drawDmgEffTimer = 0; break; case 1: @@ -909,10 +909,10 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { case 11: - this->unk_3E6 = 30; - this->unk_3D2 = 40; - this->unk_22C = 1.0f; - this->unk_230 = 0.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffTimer = 40; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); func_80995E08(this); break; @@ -923,10 +923,10 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { break; case 2: - this->unk_3D2 = 0x50; - this->unk_3E6 = 0; - this->unk_22C = 1.0f; - this->unk_230 = 0.0f; + this->drawDmgEffTimer = 80; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); this->unk_3D8 |= 1; func_80995F98(this); @@ -935,22 +935,22 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { case 3: if (this->actor.colChkInfo.health != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - this->unk_3D2 = 0x50; + this->drawDmgEffTimer = 80; } else { - this->unk_3D2 = 3; + this->drawDmgEffTimer = 3; } - this->unk_3E6 = 0xB; - this->unk_22C = 1.0f; - this->unk_230 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); func_809962D4(this); break; case 4: - this->unk_3D2 = 0x28; - this->unk_3E6 = 0x14; - this->unk_22C = 1.0f; - this->unk_230 = 0.5f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); @@ -1015,29 +1015,29 @@ void func_80996BEC(EnSkb* this, GlobalContext* globalCtx) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); for (i = 0; i < end; i++) { - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_234[i]); + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->limbPos[i]); sp84.x = Math_SinS(yaw) * 3.0f; sp84.z = Math_CosS(yaw) * 3.0f; sp84.y = (Rand_ZeroOne() * 4.0f) + 4.0f; - EffectSsEnIce_Spawn(globalCtx, &this->unk_234[i], 0.6f, &sp84, &D_80997558, &D_80997550, &D_80997554, 30); + EffectSsEnIce_Spawn(globalCtx, &this->limbPos[i], 0.6f, &sp84, &D_80997558, &D_80997550, &D_80997554, 30); } } void func_80996D68(EnSkb* this, GlobalContext* globalCtx) { - if (this->unk_3D2 > 0) { - this->unk_3D2--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } if (this->actionFunc != func_8099630C) { - if (this->unk_3D2 < 20) { + if (this->drawDmgEffTimer < 20) { if (this->actionFunc == func_809963D8) { - Math_SmoothStepToF(&this->unk_230, 0.0f, 0.5f, 0.03f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); } else { - Math_SmoothStepToF(&this->unk_230, 0.0f, 0.5f, 0.01f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.01f, 0.0f); } - this->unk_22C = this->unk_3D2 * 0.05f; + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_230, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } } @@ -1108,15 +1108,15 @@ void EnSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); } - if (this->unk_3D2 != 0) { + 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)) { - Matrix_GetStateTranslation(&this->unk_234[this->unk_2DC]); - this->unk_2DC++; + Matrix_GetStateTranslation(&this->limbPos[this->limbCount]); + this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_3D8 & 2)) { - Matrix_MultiplyVector3fByState(&D_80997564, &this->unk_234[this->unk_2DC]); - this->unk_2DC++; + Matrix_MultiplyVector3fByState(&D_80997564, &this->limbPos[this->limbCount]); + this->limbCount++; } } } @@ -1124,13 +1124,13 @@ void EnSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve void EnSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { EnSkb* this = THIS; - this->unk_2DC = 0; + this->limbCount = 0; func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSkb_OverrideLimbDraw, EnSkb_PostLimbDraw, &this->actor); - if (this->unk_3D2 > 0) { - func_800BE680(globalCtx, &this->actor, this->unk_234, this->unk_2DC, this->unk_230, 0.5f, this->unk_22C, - this->unk_3E6); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, this->limbCount, this->drawDmgEffScale, 0.5f, + this->drawDmgEffAlpha, this->drawDmgEffType); } if (this->unk_3D8 & 0x40) { diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.h b/src/overlays/actors/ovl_En_Skb/z_en_skb.h index 0e3134561..fe5722e53 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.h +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.h @@ -15,14 +15,14 @@ typedef struct EnSkb { /* 0x0188 */ ColliderJntSph collider; /* 0x01A8 */ ColliderJntSphElement colliderElements[2]; /* 0x0228 */ EnSkbActionFunc actionFunc; - /* 0x022C */ f32 unk_22C; - /* 0x0230 */ f32 unk_230; - /* 0x0234 */ Vec3f unk_234[14]; - /* 0x02DC */ s32 unk_2DC; + /* 0x022C */ f32 drawDmgEffAlpha; + /* 0x0230 */ f32 drawDmgEffScale; + /* 0x0234 */ Vec3f limbPos[14]; + /* 0x02DC */ s32 limbCount; /* 0x02E0 */ Vec3s jointTable[20]; /* 0x0358 */ Vec3s morphTable[20]; /* 0x03D0 */ s16 unk_3D0; - /* 0x03D2 */ s16 unk_3D2; + /* 0x03D2 */ s16 drawDmgEffTimer; /* 0x03D4 */ s16 unk_3D4; /* 0x03D6 */ s16 unk_3D6; /* 0x03D8 */ s16 unk_3D8; @@ -33,7 +33,7 @@ typedef struct EnSkb { /* 0x03E2 */ s16 unk_3E2; /* 0x03E4 */ u8 unk_3E4; /* 0x03E5 */ u8 unk_3E5; - /* 0x03E6 */ u8 unk_3E6; + /* 0x03E6 */ u8 drawDmgEffType; } EnSkb; // size = 0x3E8 extern const ActorInit En_Skb_InitVars; diff --git a/src/overlays/actors/ovl_En_St/z_en_st.c b/src/overlays/actors/ovl_En_St/z_en_st.c index 0bd9a6125..a50bf92b4 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -274,15 +274,15 @@ s32 func_808A576C(EnSt* this) { s16 phi_s2 = (s16)((s16)(Rand_ZeroOne() * 1000.0f) % 12) * 0x1555; for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++, phi_s2 += 0x1555) { - if (this->unk_18E != 10) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->unk_31C[i] = (Rand_ZeroOne() * 16.0f) + 8.0f; } else { this->unk_31C[i] = 80; } this->unk_334[i] = this->unk_31C[i]; - this->unk_2DC[i] = 0.90000004f; + this->drawDmgEffFrozenSteamScales[i] = 0.90000004f; - if ((this->unk_18E == 0) || (this->unk_18E == 1)) { + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) || (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_BLUE_FIRE)) { this->unk_358[i].y = ((Rand_ZeroOne() - 0.5f) * 40.0f) - 10.0f; } else { this->unk_358[i].y = ((Rand_ZeroOne() - 0.5f) * 30.0f) + 10.0f; @@ -298,29 +298,30 @@ s32 func_808A576C(EnSt* this) { s32 func_808A5988(EnSt* this, GlobalContext* globalCtx, s32 arg2) { s32 ret = false; - u8 sp53; - Vec3f sp44; - f32 sp40; + u8 drawDmgEffType; + Vec3f limbPos[1]; + f32 drawDmgEffAlpha; if (arg2 < this->unk_31A) { if (this->unk_31C[arg2] != 0) { - sp40 = (f32)this->unk_31C[arg2] / this->unk_334[arg2]; - sp53 = this->unk_18E; + drawDmgEffAlpha = (f32)this->unk_31C[arg2] / this->unk_334[arg2]; + drawDmgEffType = this->drawDmgEffType; - Math_ApproachF(&this->unk_2DC[arg2], 0.6f, 0.3f, 0.5f); - Math_Vec3f_Copy(&sp44, &this->actor.world.pos); + Math_ApproachF(&this->drawDmgEffFrozenSteamScales[arg2], 0.6f, 0.3f, 0.5f); + Math_Vec3f_Copy(&limbPos[0], &this->actor.world.pos); - sp44.x += this->unk_358[arg2].x; - sp44.y += this->unk_358[arg2].y; - sp44.z += this->unk_358[arg2].z; + limbPos[0].x += this->unk_358[arg2].x; + limbPos[0].y += this->unk_358[arg2].y; + limbPos[0].z += this->unk_358[arg2].z; - if (sp53 == 10) { + if (drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if ((this->unk_334[arg2] - this->unk_31C[arg2]) < 20) { - sp53 = 11; + drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; } - sp40 = 1.0f; + drawDmgEffAlpha = 1.0f; } - func_800BE680(globalCtx, &this->actor, &sp44, 1, 0.6f, this->unk_2DC[arg2], sp40, sp53); + Actor_DrawDamageEffects(globalCtx, &this->actor, limbPos, ARRAY_COUNT(limbPos), 0.6f, + this->drawDmgEffFrozenSteamScales[arg2], drawDmgEffAlpha, drawDmgEffType); ret = true; } } @@ -556,7 +557,7 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { } if (this->collider3.base.acFlags & AC_HIT) { - if (this->unk_18E == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { // clang-format off for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { this->unk_31C[i] = 0; } // clang-format on @@ -579,7 +580,7 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } - if (this->unk_18E == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { // clang-format off for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { this->unk_31C[i] = 0; } // clang-format on @@ -594,7 +595,7 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { break; case 5: - this->unk_18E = 30; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; this->unk_312 = 40; func_808A576C(this); Actor_SetColorFilter(&this->actor, 0, 200, 0, this->unk_312); @@ -622,30 +623,30 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { case 4: - this->unk_18E = 20; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; this->unk_318 = 20; func_808A576C(this); break; case 3: - this->unk_18E = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->unk_318 = 0; func_808A576C(this); break; case 2: - this->unk_18E = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->unk_318 = 20; func_808A576C(this); break; default: - this->unk_18E = 1; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; this->unk_318 = 0; break; } - if (this->unk_18E != 10) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 7); this->unk_2CC = 0.0f; this->unk_2D4 = 0.0f; @@ -757,7 +758,7 @@ void func_808A6E24(EnSt* this, GlobalContext* globalCtx) { s32 i; s32 count = 0; - if (this->unk_18E == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { if (DECR(this->unk_31C[i]) == 0) { count++; @@ -766,7 +767,7 @@ void func_808A6E24(EnSt* this, GlobalContext* globalCtx) { if (count == ARRAY_COUNT(this->unk_31C)) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 7); - this->unk_18E = 1; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; this->unk_2CC = 0.0f; this->unk_2D4 = 0.0f; this->actor.gravity = -1.0f; @@ -828,7 +829,7 @@ void func_808A701C(EnSt* this, GlobalContext* globalCtx) { } } else if (DECR(this->unk_318) == 0) { this->unk_18C |= 0x40; - if (this->unk_18E == 1) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_BLUE_FIRE) { func_808A576C(this); this->unk_318 = 10; } @@ -873,7 +874,7 @@ void EnSt_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_808A6E24; } else if (DECR(this->unk_312) == 0) { this->actionFunc(this, globalCtx); - if (this->unk_18E != 10) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { SkelAnime_Update(&this->skelAnime); } Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 5); @@ -884,7 +885,7 @@ void EnSt_Update(Actor* thisx, GlobalContext* globalCtx) { idx += this->actor.world.rot.y; this->actor.shape.rot.y = idx; - if (this->unk_18E == 30) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL) { if (this->unk_312 == 1) { s32 i; diff --git a/src/overlays/actors/ovl_En_St/z_en_st.h b/src/overlays/actors/ovl_En_St/z_en_st.h index a82ff397b..f3a827515 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.h +++ b/src/overlays/actors/ovl_En_St/z_en_st.h @@ -18,7 +18,7 @@ typedef struct EnSt { /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnStActionFunc actionFunc; /* 0x18C */ u16 unk_18C; - /* 0x18E */ u8 unk_18E; + /* 0x18E */ u8 drawDmgEffType; /* 0x190 */ ColliderCylinder collider1; /* 0x1DC */ ColliderCylinder collider2; /* 0x228 */ ColliderCylinder collider3; @@ -30,7 +30,7 @@ typedef struct EnSt { /* 0x2D0 */ f32 unk_2D0; /* 0x2D4 */ f32 unk_2D4; /* 0x2D8 */ f32 unk_2D8; - /* 0x2DC */ f32 unk_2DC[12]; + /* 0x2DC */ f32 drawDmgEffFrozenSteamScales[12]; /* 0x30C */ s16 unk_30C; /* 0x30E */ s16 unk_30E; /* 0x310 */ s16 unk_310; diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 14e4dfc8b..3db46de49 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -176,14 +176,15 @@ s32 func_808D8B58(EnSw* this) { s32 i; for (i = 0; i < ARRAY_COUNT(this->unk_464); i++, phi_s2 += 0x1555) { - if (this->unk_412 != 10) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->unk_464[i] = (Rand_ZeroOne() * 16.0f) + 8.0f; } else { this->unk_464[i] = 80; } this->unk_47C[i] = this->unk_464[i]; - this->unk_418[i] = 0.45000002f; - if ((this->unk_412 == 0) || (this->unk_412 == 1) || (this->unk_412 == 10)) { + this->drawDmgEffFrozenSteamScales[i] = 0.45000002f; + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) || (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_BLUE_FIRE) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) { this->unk_380[i].y = (Rand_ZeroOne() - 0.5f) * 20.0f; } else { this->unk_380[i].y = ((Rand_ZeroOne() - 0.5f) * 20.0f) + 10.0f; @@ -197,26 +198,27 @@ s32 func_808D8B58(EnSw* this) { s32 func_808D8D60(EnSw* this, GlobalContext* globalCtx, s32 arg2) { s32 ret = false; - u8 sp53; - Vec3f sp44; - f32 sp40; + u8 drawDmgEffType; + Vec3f limbPos[1]; + f32 drawDmgEffAlpha; if (arg2 < this->unk_462) { if (this->unk_464[arg2] != 0) { - sp40 = (f32)this->unk_464[arg2] / this->unk_47C[arg2]; - sp53 = this->unk_412; - Math_ApproachF(&this->unk_418[arg2], 0.3f, 0.3f, 0.5f); - Math_Vec3f_Copy(&sp44, &this->actor.world.pos); - sp44.x += this->unk_380[arg2].x; - sp44.y += this->unk_380[arg2].y; - sp44.z += this->unk_380[arg2].z; - if (sp53 == 10) { + drawDmgEffAlpha = (f32)this->unk_464[arg2] / this->unk_47C[arg2]; + drawDmgEffType = this->drawDmgEffType; + Math_ApproachF(&this->drawDmgEffFrozenSteamScales[arg2], 0.3f, 0.3f, 0.5f); + Math_Vec3f_Copy(&limbPos[0], &this->actor.world.pos); + limbPos[0].x += this->unk_380[arg2].x; + limbPos[0].y += this->unk_380[arg2].y; + limbPos[0].z += this->unk_380[arg2].z; + if (drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if ((this->unk_47C[arg2] - this->unk_464[arg2]) < 20) { - sp53 = 11; + drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; } - sp40 = 1.0f; + drawDmgEffAlpha = 1.0f; } - func_800BE680(globalCtx, &this->actor, &sp44, 1, 0.3f, this->unk_418[arg2], sp40, sp53); + Actor_DrawDamageEffects(globalCtx, &this->actor, limbPos, ARRAY_COUNT(limbPos), 0.3f, + this->drawDmgEffFrozenSteamScales[arg2], drawDmgEffAlpha, drawDmgEffType); ret = true; } } @@ -665,7 +667,7 @@ s32 func_808DA08C(EnSw* this, GlobalContext* globalCtx) { this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } - if (this->unk_412 == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { // clang-format off for (i = 0; i < ARRAY_COUNT(this->unk_464); i++) { this->unk_464[i] = 0; } // clang-format on @@ -681,36 +683,36 @@ s32 func_808DA08C(EnSw* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { case 4: - this->unk_412 = 20; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; this->unk_45C = 20; func_808D8B58(this); break; case 3: - this->unk_412 = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->unk_45C = 0; func_808D8B58(this); break; case 2: - this->unk_412 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->unk_45C = 20; func_808D8B58(this); break; case 5: - this->unk_412 = 30; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; this->unk_45C = 20; func_808D8B58(this); break; default: - this->unk_412 = 1; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; this->unk_45C = 0; break; } - if (!ENSW_GET_3(&this->actor) && (this->unk_412 != 10)) { + if (!ENSW_GET_3(&this->actor) && (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) { func_808D9E44(this); } this->unk_458 = 20; @@ -856,7 +858,7 @@ void func_808DA6FC(EnSw* this, GlobalContext* globalCtx) { #endif void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { - if (this->unk_412 == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { s32 i; s32 count; s16 phi_a0; @@ -877,7 +879,7 @@ void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { if (!ENSW_GET_3(&this->actor)) { func_808D9E44(this); } - this->unk_412 = 1; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; func_808D8ED0(this, globalCtx); } return; @@ -1065,7 +1067,7 @@ void func_808DAEB4(EnSw* this, GlobalContext* globalCtx) { phi_a0 = DECR(this->unk_45C); if (phi_a0 == 0) { this->unk_410 |= 2; - if (!ENSW_GET_3(&this->actor) && (this->unk_412 == 1)) { + if (!ENSW_GET_3(&this->actor) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_BLUE_FIRE)) { func_808D8B58(this); this->unk_45C = 10; } else { @@ -1249,7 +1251,7 @@ void EnSw_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); } - if ((this->unk_412 != 10) || (this->unk_45A != 0)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || (this->unk_45A != 0)) { SkelAnime_Update(&this->skelAnime); } diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index 4c30b4965..b74062705 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -25,9 +25,9 @@ typedef struct EnSw { /* 0x0374 */ Vec3f unk_374; /* 0x0380 */ Vec3f unk_380[12]; /* 0x0410 */ u16 unk_410; - /* 0x0412 */ u8 unk_412; + /* 0x0412 */ u8 drawDmgEffType; /* 0x0414 */ f32 unk_414; - /* 0x0418 */ f32 unk_418[12]; + /* 0x0418 */ f32 drawDmgEffFrozenSteamScales[12]; /* 0x0448 */ f32 unk_448; /* 0x044C */ f32 unk_44C; /* 0x0450 */ f32 unk_450; diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c index a4822cad3..52fc6115c 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c @@ -242,14 +242,14 @@ void EnTalkGibud_Init(Actor* thisx, GlobalContext* globalCtx) { this->grabState = EN_TALK_GIBUD_GRAB_START; this->grabWaitTimer = 0; this->itemActionParam = PLAYER_AP_NONE; - this->effectTimer = 0; - this->effectType = 0; + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->isTalking = false; this->type = EN_TALK_GIBUD_TYPE_GIBDO; this->requestedItemIndex = EN_TALK_GIBUD_REQUESTED_ITEM_INDEX(thisx); this->switchFlag = EN_TALK_GIBUD_SWITCH_FLAG(thisx); - this->effectAlpha = 0.0f; - this->effectScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; + this->drawDmgEffScale = 0.0f; for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { this->limbPos[i] = gZeroVec3f; @@ -522,7 +522,7 @@ void EnTalkGibud_SetupStunned(EnTalkGibud* this) { this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - if (this->effectTimer != 0) { + if (this->drawDmgEffTimer != 0) { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } else { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); @@ -563,7 +563,8 @@ void EnTalkGibud_Damage(EnTalkGibud* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_3F7 = -1; this->actor.world.rot.y = this->actor.shape.rot.y; - if ((this->effectTimer > 0) && (this->effectType == 0) && (this->type == EN_TALK_GIBUD_TYPE_GIBDO)) { + if ((this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && + (this->type == EN_TALK_GIBUD_TYPE_GIBDO)) { this->actor.hintId = 0x2A; this->actor.flags &= ~(ACTOR_FLAG_8 | ACTOR_FLAG_1); this->actor.flags |= (ACTOR_FLAG_4 | ACTOR_FLAG_1); @@ -597,7 +598,7 @@ void EnTalkGibud_Dead(EnTalkGibud* this, GlobalContext* globalCtx) { this->deathTimer++; } - if ((this->deathTimer == 20) && (this->effectTimer > 0) && (this->effectType == 0) && + if ((this->deathTimer == 20) && (this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && (this->type == EN_TALK_GIBUD_TYPE_GIBDO)) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, GIBDO_LIMB_MAX); @@ -1040,9 +1041,9 @@ void EnTalkGibud_UpdateDamage(EnTalkGibud* this, GlobalContext* globalCtx) { } else { EnTalkGibud_SetupDamage(this); } - this->effectTimer = 180; - this->effectType = 0; - this->effectAlpha = 1.0f; + this->drawDmgEffTimer = 180; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 1.0f; break; case EN_TALK_GIBUD_DMGEFF_LIGHT_ARROW: @@ -1052,17 +1053,17 @@ void EnTalkGibud_UpdateDamage(EnTalkGibud* this, GlobalContext* globalCtx) { } else { EnTalkGibud_SetupDamage(this); } - this->effectTimer = 60; - this->effectType = 20; - this->effectAlpha = 1.0f; + this->drawDmgEffTimer = 60; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 1.0f; break; case EN_TALK_GIBUD_DMGEFF_ZORA_MAGIC: if (this->actionFunc != EnTalkGibud_Grab && (this->actionFunc != EnTalkGibud_Stunned || this->stunTimer == 0)) { - this->effectAlpha = 1.0f; - this->effectTimer = 40; - this->effectType = 30; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; EnTalkGibud_SetupStunned(this); } break; @@ -1117,15 +1118,15 @@ void EnTalkGibud_MoveGrabbedPlayerAwayFromWall(EnTalkGibud* this, GlobalContext* } void EnTalkGibud_UpdateEffect(EnTalkGibud* this, GlobalContext* globalCtx) { - if (this->effectTimer > 0) { - this->effectTimer--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } - if (this->effectTimer < 20) { - Math_SmoothStepToF(&this->effectScale, 0.0f, 0.5f, 0.03f, 0.0f); - this->effectAlpha = this->effectTimer * 0.05f; + if (this->drawDmgEffTimer < 20) { + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->effectScale, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } @@ -1164,7 +1165,7 @@ void EnTalkGibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi Gfx** gfx) { EnTalkGibud* this = THIS; - if ((this->effectTimer != 0) && + if ((this->drawDmgEffTimer != 0) && ((limbIndex == GIBDO_LIMB_LEFT_THIGH) || (limbIndex == GIBDO_LIMB_LEFT_SHIN) || (limbIndex == GIBDO_LIMB_LEFT_FOOT) || (limbIndex == GIBDO_LIMB_RIGHT_THIGH) || (limbIndex == GIBDO_LIMB_RIGHT_SHIN) || (limbIndex == GIBDO_LIMB_RIGHT_FOOT) || @@ -1203,9 +1204,9 @@ void EnTalkGibud_Draw(Actor* thisx, GlobalContext* globalCtx) { EnTalkGibud_PostLimbDraw, &this->actor, POLY_XLU_DISP); } - if (this->effectTimer > 0) { - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->effectScale, 0.5f, - this->effectAlpha, this->effectType); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h index ae3afab49..b2d5b06b8 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h @@ -21,8 +21,8 @@ typedef struct EnTalkGibud { /* 0x290 */ s32 requestedItemIndex; /* 0x294 */ s32 itemActionParam; /* 0x298 */ s32 switchFlag; - /* 0x29C */ f32 effectAlpha; - /* 0x2A0 */ f32 effectScale; + /* 0x29C */ f32 drawDmgEffAlpha; + /* 0x2A0 */ f32 drawDmgEffScale; /* 0x2A4 */ Vec3s jointTable[GIBDO_LIMB_MAX]; /* 0x340 */ Vec3s morphTable[GIBDO_LIMB_MAX]; /* 0x3DC */ s16 textId; @@ -38,10 +38,10 @@ typedef struct EnTalkGibud { }; /* 0x3EC */ s16 grabState; /* 0x3EE */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero - /* 0x3F0 */ s16 effectTimer; + /* 0x3F0 */ s16 drawDmgEffTimer; /* 0x3F2 */ s16 type; /* 0x3F4 */ s16 isTalking; - /* 0x3F6 */ u8 effectType; + /* 0x3F6 */ u8 drawDmgEffType; /* 0x3F7 */ s8 unk_3F7; // related to player->unk_ADD } EnTalkGibud; // size = 0x3F8 diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index 5aaf7adb6..c16d8c220 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -443,19 +443,19 @@ void func_80C11338(EnThiefbird* this, GlobalContext* globalCtx) { } void func_80C11454(EnThiefbird* this) { - this->unk_18C = 10; - this->unk_3D8 = 0.5f; - this->unk_3DC = 0.75f; - this->unk_3D4 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffFrozenSteamScale = 0.75f; + this->drawDmgEffAlpha = 1.0f; this->actor.flags &= ~ACTOR_FLAG_200; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_80C114C0(EnThiefbird* this, GlobalContext* globalCtx) { - if (this->unk_18C == 10) { - this->unk_18C = 0; - this->unk_3D4 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_350, 11, 2, 0.2f, 0.2f); + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 11, 2, 0.2f, 0.2f); this->actor.flags |= ACTOR_FLAG_200; } } @@ -611,7 +611,7 @@ void func_80C11D14(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_18E--; } - if (this->unk_18C == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if (this->unk_18E < 38) { func_80C114C0(this, globalCtx); this->actor.speedXZ = 4.0f; @@ -646,8 +646,8 @@ void func_80C11DF0(EnThiefbird* this, GlobalContext* globalCtx) { } if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { - for (i = 0; i < ARRAY_COUNT(this->unk_350); i++) { - func_800B3030(globalCtx, &this->unk_350[i], &gZeroVec3f, &gZeroVec3f, 0x8C, 0, 0); + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { + func_800B3030(globalCtx, &this->limbPos[i], &gZeroVec3f, &gZeroVec3f, 0x8C, 0, 0); } SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); @@ -713,7 +713,7 @@ void func_80C1215C(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_18E--; } - if (this->unk_18C == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if (this->unk_18E < 38) { func_80C114C0(this, globalCtx); this->actor.speedXZ = 4.0f; @@ -877,10 +877,10 @@ void func_80C127F4(EnThiefbird* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, &this->unk_3EC->actor), 3, 0x2000, 0x100); } - temp_v0 = Math_Vec3f_Pitch(&this->unk_350[9], &this->unk_3EC->actor.world.pos); + temp_v0 = Math_Vec3f_Pitch(&this->limbPos[9], &this->unk_3EC->actor.world.pos); temp_v0 = CLAMP(temp_v0, -0x3000, 0x3000); Math_SmoothStepToS(&this->actor.shape.rot.x, temp_v0, 4, 0x800, 0x80); - temp_f0 = Actor_DistanceToPoint(&this->unk_3EC->actor, &this->unk_350[9]); + temp_f0 = Actor_DistanceToPoint(&this->unk_3EC->actor, &this->limbPos[9]); this->actor.speedXZ = (0.02f * temp_f0) + 2.0f; this->actor.speedXZ = CLAMP_MAX(this->actor.speedXZ, 4.0f); if ((this->unk_3EC->actor.speedXZ <= 0.0f) && (temp_f0 < 40.0f)) { @@ -933,22 +933,22 @@ void func_80C12B1C(EnThiefbird* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 3) { func_80C11454(this); } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_18C = 20; - this->unk_3D8 = 0.5f; - this->unk_3D4 = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffAlpha = 4.0f; if (i != ARRAY_COUNT(this->colliderElements)) { sph = &this->collider.elements[i]; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, sph->info.bumper.hitPos.x, sph->info.bumper.hitPos.y, sph->info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } } else if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_18C = 0; - this->unk_3D8 = 0.5f; - this->unk_3D4 = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffAlpha = 4.0f; } else if (this->actor.colChkInfo.damageEffect == 5) { - this->unk_18C = 0x1E; - this->unk_3D8 = 0.5f; - this->unk_3D4 = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffAlpha = 2.0f; } if (this->unk_3E8 != 0) { @@ -1020,12 +1020,12 @@ void EnThiefbird_Update(Actor* thisx, GlobalContext* globalCtx2) { } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_3D4 > 0.0f) { - if (this->unk_18C != 10) { - Math_StepToF(&this->unk_3D4, 0.0f, 0.05f); - this->unk_3D8 = (this->unk_3D4 + 1.0f) * 0.25f; - this->unk_3D8 = CLAMP_MAX(this->unk_3D8, 0.5f); - } else if (!Math_StepToF(&this->unk_3DC, 0.5f, 0.0125f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.25f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.5f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.5f, 0.0125f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1099,11 +1099,11 @@ void EnThiefbird_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi idx = D_80C13698[limbIndex]; if (idx != -1) { if (idx == 9) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_350[idx]); + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[idx]); } else { - Matrix_GetStateTranslation(&this->unk_350[idx]); + Matrix_GetStateTranslation(&this->limbPos[idx]); if ((idx == 3) || (idx == 5)) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_350[idx + 1]); + Matrix_GetStateTranslationAndScaledX(2000.0f, &this->limbPos[idx + 1]); } } } @@ -1151,7 +1151,7 @@ void EnThiefbird_Draw(Actor* thisx, GlobalContext* globalCtx) { func_800AE5A0(globalCtx); } func_80C13354(this, globalCtx); - func_800BE680(globalCtx, &this->actor, this->unk_350, 11, this->unk_3D8, this->unk_3DC, this->unk_3D4, - this->unk_18C); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); Math_Vec3s_ToVec3f(&this->actor.focus.pos, &this->collider.elements[1].dim.worldSphere.center); } diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h index 5581f1155..990b4b2c5 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h @@ -21,7 +21,7 @@ typedef struct EnThiefbird { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnThiefbirdActionFunc actionFunc; - /* 0x018C */ u8 unk_18C; + /* 0x018C */ u8 drawDmgEffType; /* 0x018E */ s16 unk_18E; /* 0x0190 */ s16 unk_190; /* 0x0192 */ s16 unk_192; @@ -31,10 +31,10 @@ typedef struct EnThiefbird { /* 0x0208 */ Vec3s morphTable[17]; /* 0x0270 */ ColliderJntSph collider; /* 0x0290 */ ColliderJntSphElement colliderElements[3]; - /* 0x0350 */ Vec3f unk_350[11]; - /* 0x03D4 */ f32 unk_3D4; - /* 0x03D8 */ f32 unk_3D8; - /* 0x03DC */ f32 unk_3DC; + /* 0x0350 */ Vec3f limbPos[11]; + /* 0x03D4 */ f32 drawDmgEffAlpha; + /* 0x03D8 */ f32 drawDmgEffScale; + /* 0x03DC */ f32 drawDmgEffFrozenSteamScale; /* 0x03E0 */ f32 unk_3E0; /* 0x03E4 */ Gfx* unk_3E4; /* 0x03E8 */ Gfx* unk_3E8; diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.c b/src/overlays/actors/ovl_En_Tite/z_en_tite.c index 3665cdfde..7839e4585 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -242,15 +242,15 @@ void func_80893BCC(EnTite* this, GlobalContext* globalCtx) { u32 surface = func_800C9BB8(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); if ((surface == COLPOLY_SURFACE_GROUND) || (surface == COLPOLY_SURFACE_SAND)) { - for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { - func_800BBFB0(globalCtx, &this->unk_2D0[i], 1.0f, 2, 80, 15, 1); + for (i = 5; i < ARRAY_COUNT(this->limbPos); i++) { + func_800BBFB0(globalCtx, &this->limbPos[i], 1.0f, 2, 80, 15, 1); } } else if (surface == COLPOLY_SURFACE_SNOW) { Vec3f* ptr; - for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { + for (i = 5; i < ARRAY_COUNT(this->limbPos); i++) { for (j = 0; j < 2; j++) { - ptr = &this->unk_2D0[i]; + ptr = &this->limbPos[i]; sp7C.x = ptr->x + randPlusMinusPoint5Scaled(1.0f); sp7C.y = ptr->y + randPlusMinusPoint5Scaled(1.0f); sp7C.z = ptr->z + randPlusMinusPoint5Scaled(1.0f); @@ -264,22 +264,22 @@ void func_80893BCC(EnTite* this, GlobalContext* globalCtx) { } void func_80893DD4(EnTite* this) { - this->unk_2BB = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider.base.colType = COLTYPE_HIT3; this->unk_2BC = 80; - this->unk_2C8 = 0.5f; - this->unk_2CC = 0.75f; - this->unk_2C4 = 1.0f; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffFrozenSteamScale = 0.75f; + this->drawDmgEffAlpha = 1.0f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); this->actor.flags &= ~ACTOR_FLAG_200; } void func_80893E54(EnTite* this, GlobalContext* globalCtx) { - if (this->unk_2BB == 10) { - this->unk_2BB = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; - this->unk_2C4 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D0, 9, 2, 0.2f, 0.2f); + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 9, 2, 0.2f, 0.2f); this->actor.flags |= ACTOR_FLAG_200; } } @@ -643,8 +643,8 @@ void func_80895020(EnTite* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; ptr = &this->unk_33C[0]; - for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++, ptr++) { - Math_Vec3f_Diff(&this->unk_2D0[i], &this->actor.world.pos, &sp74); + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++, ptr++) { + Math_Vec3f_Diff(&this->limbPos[i], &this->actor.world.pos, &sp74); temp_f0 = Math3D_Vec3fMagnitude(&sp74); if (temp_f0 > 1.0f) { temp_f0 = 1.2f / temp_f0; @@ -664,14 +664,14 @@ void func_808951B8(EnTite* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.z, 0x4000, 4, 0x1000, 0x400); if (this->unk_2BC == 0) { - for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { - func_800B3030(globalCtx, &this->unk_2D0[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 1); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->unk_2D0[i], 11, NA_SE_EN_EXTINCT); + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { + func_800B3030(globalCtx, &this->limbPos[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 1); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->limbPos[i], 11, NA_SE_EN_EXTINCT); } Actor_MarkForDeath(&this->actor); } else { for (i = 0; i < ARRAY_COUNT(this->unk_33C); i++) { - Math_Vec3f_Sum(&this->unk_2D0[i], &this->unk_33C[i], &this->unk_2D0[i]); + Math_Vec3f_Sum(&this->limbPos[i], &this->unk_33C[i], &this->limbPos[i]); this->unk_33C[i].y += this->actor.gravity; } } @@ -940,7 +940,8 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { Actor_SetDropFlag(&this->actor, &this->collider.info); - if ((this->unk_2BB != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { func_80893E54(this, globalCtx); if (this->actor.shape.yOffset < 0.0f) { func_80895DE8(this); @@ -956,9 +957,9 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { this->unk_2BC = 40; Actor_SetColorFilter(&this->actor, 0, 200, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_2BB = 32; - this->unk_2C8 = 0.5f; - this->unk_2C4 = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffAlpha = 2.0f; func_80894DD0(this); return; } @@ -982,13 +983,13 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2BB = 0; - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.5f; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2BB = 0x14; - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.5f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -1031,8 +1032,8 @@ void func_808963B4(EnTite* this, GlobalContext* globalCtx) { Vec3f sp48; if (this->actor.bgCheckFlags & 0x40) { - for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { - Math_Vec3f_Copy(&sp48, &this->unk_2D0[i]); + for (i = 5; i < ARRAY_COUNT(this->limbPos); i++) { + Math_Vec3f_Copy(&sp48, &this->limbPos[i]); sp48.y = this->actor.world.pos.y + this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &sp48, 0, 220, 0); } @@ -1040,7 +1041,7 @@ void func_808963B4(EnTite* this, GlobalContext* globalCtx) { s32 temp = globalCtx->gameplayFrames & 7; if (!(temp & 1) && (this->actor.depthInWater < 10.0f)) { - Math_Vec3f_Copy(&sp48, &this->unk_2D0[5 + (temp >> 1)]); + Math_Vec3f_Copy(&sp48, &this->limbPos[5 + (temp >> 1)]); sp48.y = this->actor.world.pos.y + this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &sp48, 0, 220, 0); } @@ -1083,12 +1084,12 @@ void EnTite_Update(Actor* thisx, GlobalContext* globalCtx) { } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_2C4 > 0.0f) { - if (this->unk_2BB != 10) { - Math_StepToF(&this->unk_2C4, 0.0f, 0.05f); - this->unk_2C8 = (this->unk_2C4 + 1.0f) * 0.25f; - this->unk_2C8 = CLAMP_MAX(this->unk_2C8, 0.5f); - } else if (!Math_StepToF(&this->unk_2CC, 0.5f, 0.0125f)) { + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.25f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.5f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.5f, 0.0125f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1120,14 +1121,14 @@ void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V if (this->unk_2BA == 0) { idx = D_80896B70[limbIndex]; if (idx != -1) { - Matrix_GetStateTranslation(&this->unk_2D0[idx]); + Matrix_GetStateTranslation(&this->limbPos[idx]); if (idx >= 1) { - Matrix_GetStateTranslationAndScaledX(2500.0f, &this->unk_2D0[idx + 4]); + Matrix_GetStateTranslationAndScaledX(2500.0f, &this->limbPos[idx + 4]); } } } else if (this->unk_2BA > 0) { if (D_80896B8C[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2D0[D_80896B8C[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_80896B8C[limbIndex]]); } if (limbIndex == 24) { @@ -1137,9 +1138,9 @@ void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V OPEN_DISPS(globalCtx->state.gfxCtx); matrix = Matrix_GetCurrentState(); - matrix->wx = this->unk_2D0[D_80896B8C[limbIndex]].x; - matrix->wy = this->unk_2D0[D_80896B8C[limbIndex]].y; - matrix->wz = this->unk_2D0[D_80896B8C[limbIndex]].z; + matrix->wx = this->limbPos[D_80896B8C[limbIndex]].x; + matrix->wy = this->limbPos[D_80896B8C[limbIndex]].y; + matrix->wz = this->limbPos[D_80896B8C[limbIndex]].z; Matrix_InsertZRotation_s(this->actor.world.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1172,8 +1173,8 @@ void EnTite_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnTite_OverrideLimbDraw, EnTite_PostLimbDraw, &this->actor); - func_800BE680(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), this->unk_2C8, this->unk_2CC, - this->unk_2C4, this->unk_2BB); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.h b/src/overlays/actors/ovl_En_Tite/z_en_tite.h index 91bbfc7c2..24f3bd630 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.h +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.h @@ -24,14 +24,14 @@ typedef struct EnTite { /* 0x02B8 */ u8 unk_2B8; /* 0x02B9 */ u8 unk_2B9; /* 0x02BA */ s8 unk_2BA; - /* 0x02BB */ u8 unk_2BB; + /* 0x02BB */ u8 drawDmgEffType; /* 0x02BC */ s16 unk_2BC; /* 0x02BE */ s16 unk_2BE; /* 0x02C0 */ s32 unk_2C0; - /* 0x02C4 */ f32 unk_2C4; - /* 0x02C8 */ f32 unk_2C8; - /* 0x02CC */ f32 unk_2CC; - /* 0x02D0 */ Vec3f unk_2D0[9]; + /* 0x02C4 */ f32 drawDmgEffAlpha; + /* 0x02C8 */ f32 drawDmgEffScale; + /* 0x02CC */ f32 drawDmgEffFrozenSteamScale; + /* 0x02D0 */ Vec3f limbPos[9]; /* 0x033C */ Vec3f unk_33C[9]; /* 0x03A8 */ Gfx* unk_3A8; /* 0x03AC */ ColliderSphere collider; diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.c b/src/overlays/actors/ovl_En_Wf/z_en_wf.c index 9f109b1cd..3b92a8eab 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -360,10 +360,10 @@ void EnWf_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_809907D4(EnWf* this) { - this->unk_2B0 = 0.75f; - this->unk_2B4 = 1.125f; - this->unk_2AC = 1.0f; - this->unk_296 = 10; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffFrozenSteamScale = 1.125f; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider2.base.colType = COLTYPE_HIT3; this->collider3.base.colType = COLTYPE_HIT3; this->unk_2A0 = 80; @@ -372,12 +372,12 @@ void func_809907D4(EnWf* this) { } void func_80990854(EnWf* this, GlobalContext* globalCtx) { - if (this->unk_296 == 10) { - this->unk_296 = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider2.base.colType = COLTYPE_HIT5; this->collider3.base.colType = COLTYPE_HIT5; - this->unk_2AC = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2B8, 10, 2, 0.3f, 0.2f); + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 10, 2, 0.3f, 0.2f); this->actor.flags |= ACTOR_FLAG_400; } } @@ -1410,7 +1410,7 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { this->collider3.base.acFlags &= ~AC_HIT; this->collider1.base.atFlags &= ~AT_ON; - if (((this->unk_296 != 10) || + if (((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || !(collider->info.acHitInfo->toucher.dmgFlags & (0x80000 | 0x40000 | 0x10000 | 0x8000 | 0x2000 | 0x1000 | 0x80 | 0x20 | 0x10 | 0x2 | 0x1))) && (this->actor.colChkInfo.damageEffect != 0xF)) { @@ -1428,9 +1428,9 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { } else if (this->actor.colChkInfo.damageEffect == 5) { this->unk_2A0 = 40; Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 40); - this->unk_296 = 30; - this->unk_2B0 = 0.75f; - this->unk_2AC = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 2.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); func_809923B0(this); } else if (this->actor.colChkInfo.damageEffect == 3) { @@ -1442,13 +1442,13 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { func_809923B0(this); } else { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_296 = 0; - this->unk_2B0 = 0.75f; - this->unk_2AC = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_296 = 20; - this->unk_2B0 = 0.75f; - this->unk_2AC = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, collider->info.bumper.hitPos.x, collider->info.bumper.hitPos.y, collider->info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -1517,16 +1517,16 @@ void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetFocus(&this->actor, 25.0f); - if (this->unk_2AC > 0.0f) { - if (this->unk_296 != 10) { - Math_StepToF(&this->unk_2AC, 0.0f, 0.05f); - this->unk_2B0 = (this->unk_2AC + 1.0f) * 0.375f; - if (this->unk_2B0 > 0.75f) { - this->unk_2B0 = 0.75f; + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.375f; + if (this->drawDmgEffScale > 0.75f) { + this->drawDmgEffScale = 0.75f; } else { - this->unk_2B0 = this->unk_2B0; + this->drawDmgEffScale = this->drawDmgEffScale; } - } else if (!Math_StepToF(&this->unk_2B4, 0.75f, 0.01875f)) { + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, 0.01875f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1551,7 +1551,7 @@ void EnWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Collider_UpdateSpheres(limbIndex, &this->collider1); if (D_809942FC[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2B8[D_809942FC[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_809942FC[limbIndex]]); } if (limbIndex == 6) { @@ -1580,8 +1580,9 @@ void EnWf_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnWf_OverrideLimbDraw, EnWf_PostLimbDraw, &this->actor); - func_800BE680(globalCtx, &this->actor, this->unk_2B8, 10, this->unk_2B0, this->unk_2B4, this->unk_2AC, - this->unk_296); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); } } diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.h b/src/overlays/actors/ovl_En_Wf/z_en_wf.h index defd8fc79..e697ef072 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.h +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.h @@ -17,7 +17,7 @@ typedef struct EnWf { /* 0x0290 */ EnWfActionFunc actionFunc; /* 0x0294 */ u8 unk_294; /* 0x0295 */ u8 unk_295; - /* 0x0296 */ u8 unk_296; + /* 0x0296 */ u8 drawDmgEffType; /* 0x0298 */ s16 unk_298; /* 0x029A */ s16 unk_29A; /* 0x029C */ s16 unk_29C; @@ -26,10 +26,10 @@ typedef struct EnWf { /* 0x02A2 */ u16 unk_2A2; /* 0x02A4 */ f32 unk_2A4; /* 0x02A8 */ f32 unk_2A8; - /* 0x02AC */ f32 unk_2AC; - /* 0x02B0 */ f32 unk_2B0; - /* 0x02B4 */ f32 unk_2B4; - /* 0x02B8 */ Vec3f unk_2B8[10]; + /* 0x02AC */ f32 drawDmgEffAlpha; + /* 0x02B0 */ f32 drawDmgEffScale; + /* 0x02B4 */ f32 drawDmgEffFrozenSteamScale; + /* 0x02B8 */ Vec3f limbPos[10]; /* 0x0330 */ ColliderJntSph collider1; /* 0x0350 */ ColliderJntSphElement collider1Elements[4]; /* 0x0450 */ ColliderCylinder collider2; diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 0d5045501..5e7d2e3a6 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -437,6 +437,7 @@ animdict = { "func_80114E90": "Interface_HasEmptyBottle", "func_80114F2C": "Interface_HasItemInBottle", "func_80123C90": "Player_SetEquipmentData", + "func_800BE680": "Actor_DrawDamageEffects", "func_8013E2D4": "SubS_StartActorCutscene", "func_8013E3B8": "SubS_FillCutscenesList", "func_8013AED4": "SubS_UpdateFlags", @@ -445,7 +446,7 @@ animdict = { "func_8013D5E8": "SubS_AngleDiffLessEqual", "func_8012F22C": "Inventory_GetSkullTokenCount", - # Structs members + # Struct members "skelAnime.unk03": "skelAnime.taper", "skelAnime.animCurrentSeg": "skelAnime.animation", "skelAnime.initialFrame": "skelAnime.startFrame", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 32982655d..73b194c00 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -893,7 +893,7 @@ 0x800BE568:("func_800BE568",), 0x800BE5CC:("func_800BE5CC",), 0x800BE63C:("func_800BE63C",), - 0x800BE680:("func_800BE680",), + 0x800BE680:("Actor_DrawDamageEffects",), 0x800BF7CC:("Actor_SpawnIceEffects",), 0x800BF9A0:("ActorOverlayTable_FaultPrint",), 0x800BFA78:("ActorOverlayTable_FaultAddrConv",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 0e5151fed..1b594bd60 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -443,7 +443,7 @@ 0x801AEE38:("D_801AEE38","struct_801AEE38","[14]",0x150), 0x801AEF88:("D_801AEF88","UNK_TYPE1","",0x1), 0x801AEFA0:("D_801AEFA0","UNK_TYPE1","",0x1), - 0x801AEFA8:("D_801AEFA8","UNK_TYPE1","",0x1), + 0x801AEFA8:("sElectricSparkTextures","UNK_TYPE1","",0x1), 0x801AEFB8:("D_801AEFB8","UNK_TYPE1","",0x1), 0x801AEFBC:("D_801AEFBC","UNK_TYPE1","",0x1), 0x801AEFC0:("D_801AEFC0","UNK_TYPE1","",0x1), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 109d1df8a..98d408bee 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -407,7 +407,7 @@ asm/non_matchings/code/z_actor/func_800BE504.s,func_800BE504,0x800BE504,0x19 asm/non_matchings/code/z_actor/func_800BE568.s,func_800BE568,0x800BE568,0x19 asm/non_matchings/code/z_actor/func_800BE5CC.s,func_800BE5CC,0x800BE5CC,0x1C asm/non_matchings/code/z_actor/func_800BE63C.s,func_800BE63C,0x800BE63C,0x11 -asm/non_matchings/code/z_actor/func_800BE680.s,func_800BE680,0x800BE680,0x453 +asm/non_matchings/code/z_actor/Actor_DrawDamageEffects.s,Actor_DrawDamageEffects,0x800BE680,0x453 asm/non_matchings/code/z_actor/Actor_SpawnIceEffects.s,Actor_SpawnIceEffects,0x800BF7CC,0x75 asm/non_matchings/code/z_actor_dlftbls/ActorOverlayTable_FaultPrint.s,ActorOverlayTable_FaultPrint,0x800BF9A0,0x36 asm/non_matchings/code/z_actor_dlftbls/ActorOverlayTable_FaultAddrConv.s,ActorOverlayTable_FaultAddrConv,0x800BFA78,0x1C From d36b0d506d55ca499791de9c516873d23359e5a6 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 9 Mar 2022 17:02:27 -0800 Subject: [PATCH 077/257] Misc NON_MATCHINGS/NON_EQUIVALENTS (#696) * Match the rest in fireObj * Fix FireObjLightParams struct * Fix up bomjima * Match ObjSnowball * 2 functions in EnGoroiwa * Rename randMultiplier * Minor cleanup * More cleanup * Boss02 Ok * Match Boss06_Draw * format * bss * Remove static from osFlash bss * PR suggestions * Remove LightInfoPositional * 0x4000 * Format * Cleanup * Fix bombjima data * Boss02 newline * PR stuff * Change func_8012CF0C to NON_EQUIVALENT * Matched func_8012CF0C by AngheloAlf * RSPMatrix -> Mtx * Bubbles fix --- include/z64.h | 20 +++-- include/z64light.h | 5 -- spec | 14 +--- src/code/z_fireobj.c | 76 ++++++++----------- src/code/z_rcp.c | 7 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 47 ++++-------- src/overlays/actors/ovl_Boss_06/z_boss_06.c | 24 +++--- .../actors/ovl_En_Bomjima/z_en_bomjima.c | 72 +++++------------- .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 29 +++---- src/overlays/actors/ovl_En_Ishi/z_en_ishi.c | 2 +- .../actors/ovl_En_Kanban/z_en_kanban.c | 2 +- src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c | 2 +- .../actors/ovl_Obj_Snowball/z_obj_snowball.c | 23 +++--- .../ovl_Obj_Snowball2/z_obj_snowball2.c | 2 +- .../gamestates/ovl_daytelop/z_daytelop.c | 2 +- .../gamestates/ovl_opening/z_opening.c | 2 +- src/overlays/gamestates/ovl_select/z_select.c | 2 +- src/overlays/gamestates/ovl_title/z_title.c | 2 +- tools/disasm/variables.txt | 5 +- undefined_syms.txt | 5 -- 20 files changed, 129 insertions(+), 214 deletions(-) diff --git a/include/z64.h b/include/z64.h index 189937fb7..51d2bc33b 100644 --- a/include/z64.h +++ b/include/z64.h @@ -139,15 +139,21 @@ typedef struct { /* 0x4 */ f32 dynamicSizeStep; /* 0x8 */ u8 state; /* 0x9 */ u8 sizeGrowsCos2; - /* 0xA */ u8 unkA; + /* 0xA */ u8 colorsIndex; /* 0xB */ u8 flags; - /* 0xC */ u8 unkC; + /* 0xC */ u8 lightParamsIndex; } FireObjInitParams; // size = 0xD -typedef struct { +typedef struct FireObjColors { /* 0x0 */ Color_RGBA8 primColor; - /* 0x4 */ u8 unk4; + /* 0x4 */ u8 lod; /* 0x5 */ Color_RGB8 envColor; +} FireObjColors; // size = 0x8 + +typedef struct FireObjLightParams { + /* 0x0 */ s16 radius; + /* 0x2 */ Color_RGB8 color; + /* 0x5 */ Color_RGB8 maxColorAdj; } FireObjLightParams; // size = 0x8 #define FONT_CHAR_TEX_WIDTH 16 @@ -1158,8 +1164,8 @@ typedef enum { struct FireObjLight { /* 0x00 */ LightNode* light; - /* 0x04 */ LightInfoPositional lightInfo; - /* 0x12 */ u8 unk12; + /* 0x04 */ LightInfo lightInfo; + /* 0x12 */ u8 lightParamsIndex; }; // size = 0x13 #define OS_SC_RETRACE_MSG 1 @@ -1210,7 +1216,7 @@ struct FireObj { /* 0x24 */ u8 state; // 0 - growing, 1 - shrinking, 2 - fully lit, 3 - not lit /* 0x25 */ u8 sizeGrowsCos2; /* 0x26 */ u8 unk26; - /* 0x27 */ u8 unk27; + /* 0x27 */ u8 colorsIndex; /* 0x28 */ u8 flags; // bit 0 - ?, bit 1 - ? /* 0x29 */ UNK_TYPE1 pad29[0x1]; /* 0x2A */ s16 ignitionDelay; diff --git a/include/z64light.h b/include/z64light.h index 8e8508579..8154ca401 100644 --- a/include/z64light.h +++ b/include/z64light.h @@ -57,11 +57,6 @@ typedef struct Lights { /* 0x08 */ Lightsn l; } Lights; // size = 0x80 -typedef struct LightInfoPositional { - /* 0x0 */ u8 type; - /* 0x2 */ LightPoint params; -} LightInfoPositional; // size = 0xE - typedef struct LightNode { /* 0x0 */ LightInfo* info; /* 0x4 */ struct LightNode* prev; diff --git a/spec b/spec index 8040fd441..06fbe1e31 100644 --- a/spec +++ b/spec @@ -2509,11 +2509,7 @@ beginseg name "ovl_Boss_02" compress include "build/src/overlays/actors/ovl_Boss_02/z_boss_02.o" - #ifdef NON_MATCHING - include "build/src/overlays/actors/ovl_Boss_02/ovl_Boss_02_reloc.o" - #else - include "build/data/ovl_Boss_02/ovl_Boss_02.reloc.o" - #endif + include "build/src/overlays/actors/ovl_Boss_02/ovl_Boss_02_reloc.o" endseg beginseg @@ -3817,11 +3813,7 @@ beginseg name "ovl_Obj_Snowball" compress include "build/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.o" -#ifdef NON_MATCHING - include "build/src/overlays/actors/ovl_Obj_Snowball/ovl_obj_Snowball_reloc.o" -#else - include "build/data/ovl_Obj_Snowball/ovl_Obj_Snowball.reloc.o" -#endif + include "build/src/overlays/actors/ovl_Obj_Snowball/ovl_Obj_Snowball_reloc.o" endseg beginseg @@ -5026,7 +5018,7 @@ beginseg name "ovl_En_Bomjima" compress include "build/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.o" - include "build/data/ovl_En_Bomjima/ovl_En_Bomjima.reloc.o" + include "build/src/overlays/actors/ovl_En_Bomjima/ovl_En_Bomjima_reloc.o" endseg beginseg diff --git a/src/code/z_fireobj.c b/src/code/z_fireobj.c index c6b6a3f9c..379ebda1d 100644 --- a/src/code/z_fireobj.c +++ b/src/code/z_fireobj.c @@ -29,13 +29,13 @@ ColliderCylinderInit sFireObjCollisionInit = { { 18, 67, 0, { 0, 0, 0 } }, }; -FireObjLightParams sFireObjLightParams[2] = { - { 255, 255, 0, 255, 128, 255, 0, 0 }, - { 0, 200, 128, 128, 0, 127, 127, 0 }, +FireObjColors sFireObjColors[] = { + { { 255, 255, 0, 255 }, 128, { 255, 0, 0 } }, }; -void FireObj_InitLight(GlobalContext* globalCtx, FireObjLight* light, u8* param_3, Vec3f* pos); -void FireObj_UpdateLight(GlobalContext* globalCtx, FireObjLight* light, FireObj* fire); +FireObjLightParams sFireObjLightParams[] = { + { 200, { 128, 128, 0 }, { 127, 127, 0 } }, +}; void FireObj_InitWithParams(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init) { fire->size = init->size; @@ -43,7 +43,7 @@ void FireObj_InitWithParams(GlobalContext* globalCtx, FireObj* fire, FireObjInit fire->dynamicSizeStep = init->dynamicSizeStep; fire->state = init->state; fire->sizeGrowsCos2 = init->sizeGrowsCos2; - fire->unk27 = init->unkA; + fire->colorsIndex = init->colorsIndex; fire->flags = init->flags; fire->xScale = 0.0f; fire->yScale = 0.0f; @@ -53,7 +53,7 @@ void FireObj_InitWithParams(GlobalContext* globalCtx, FireObj* fire, FireObjInit } void FireObj_SetState(FireObj* fire, f32 dynamicSizeStep, u8 newState) { - fire->state = newState & 0xFF; + fire->state = newState; if (fire->state == FIRE_STATE_3) { fire->yScale = 0.0f; fire->xScale = 0.0f; @@ -75,11 +75,11 @@ void FireObj_StepSize(FireObj* fire) { FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_2); } } else if ((fire->state == FIRE_STATE_1) && (Math_StepToF(&fire->dynamicSize, 0.0f, fire->dynamicSizeStep) != 0)) { - FireObj_SetState(fire, fire->dynamicSizeStep, 3); + FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_3); } if (fire->sizeGrowsCos2 == 1) { if ((fire->state == FIRE_STATE_0) || (fire->state == FIRE_STATE_1)) { - fire->xScale = (1.0f - Math_CosS((fire->dynamicSize * fire->dynamicSize * 16384.0f))) * fire->size; + fire->xScale = (1.0f - Math_CosS(SQ(fire->dynamicSize) * 0x4000)) * fire->size; fire->yScale = fire->dynamicSize * fire->size; } else { fire->yScale = fire->dynamicSize * fire->size; @@ -96,7 +96,7 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { Player* player = GET_PLAYER(globalCtx); WaterBox* waterBox; f32 waterY; - s32 sp40 = 0; + s32 sp40 = false; u8 nextState; Vec3f dist; @@ -115,16 +115,16 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { } if ((fire->flags & 1) && (fire->state != FIRE_STATE_3) && WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, fire->position.x, fire->position.z, &waterY, &waterBox) && - ((fire->yScale * ((void)0, 6500.0f)) < (waterY - fire->position.y))) { // Fake but IDK what else + (waterY - fire->position.y > 6500.0f * fire->yScale)) { FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_3); } if ((fire->flags & 2) && (player->itemActionParam == PLAYER_AP_STICK)) { Math_Vec3f_Diff(&player->swordInfo[0].tip, &fire->position, &dist); if (Math3D_LengthSquared(&dist) < 400.0f) { - sp40 = 1; + sp40 = true; } } - if (sp40 != 0) { + if (sp40) { if (fire->state == FIRE_STATE_3) { if (player->unk_B28 > 0) { FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_0); @@ -140,7 +140,7 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { s32 pad; - FireObjLightParams* lightParams = &sFireObjLightParams[fire->unk27]; + FireObjColors* fireColors = &sFireObjColors[fire->colorsIndex]; if (fire->state != FIRE_STATE_3) { Vec3s vec; @@ -151,10 +151,10 @@ void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (fire->unk26 * -20) & 511, 32, 128)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, lightParams->unk4, lightParams->primColor.r, lightParams->primColor.g, - lightParams->primColor.b, lightParams->primColor.a); + gDPSetPrimColor(POLY_XLU_DISP++, 0, fireColors->lod, fireColors->primColor.r, fireColors->primColor.g, + fireColors->primColor.b, fireColors->primColor.a); - gDPSetEnvColor(POLY_XLU_DISP++, lightParams->envColor.r, lightParams->envColor.g, lightParams->envColor.b, 0); + gDPSetEnvColor(POLY_XLU_DISP++, fireColors->envColor.r, fireColors->envColor.g, fireColors->envColor.b, 0); vec.x = 0; vec.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000; @@ -168,45 +168,35 @@ void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { } } -#ifdef NON_EQUIVALENT -// Accesses data incorrectly -void FireObj_InitLight(GlobalContext* globalCtx, FireObjLight* light, u8* param_3, Vec3f* pos) { - FireObjLightParams* objectParams = &sFireObjLightParams[*param_3]; +void FireObj_InitLight(GlobalContext* globalCtx, FireObjLight* light, u8* paramsIndex, Vec3f* pos) { + FireObjLightParams* objectParams = &sFireObjLightParams[*paramsIndex]; - Lights_PointGlowSetInfo(&light->lightInfo, pos->x, pos->y, pos->z, objectParams->primColor.g, - objectParams->primColor.b, objectParams->primColor.a, objectParams->primColor.r); - light->light = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, (LightInfo*)&light->lightInfo); - light->unk12 = *param_3; + Lights_PointGlowSetInfo(&light->lightInfo, pos->x, pos->y, pos->z, objectParams->color.r, objectParams->color.g, + objectParams->color.b, objectParams->radius); + light->light = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &light->lightInfo); + light->lightParamsIndex = *paramsIndex; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_InitLight.s") -#endif void FireObj_DestroyLight(GlobalContext* globalCtx, FireObjLight* light) { LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, light->light); } -#ifdef NON_EQUIVALENT -// Accesses data incorrectly void FireObj_UpdateLight(GlobalContext* globalCtx, FireObjLight* light, FireObj* fire) { - FireObjLightParams* lightParams = &sFireObjLightParams[light->unk12]; + FireObjLightParams* lightParams = &sFireObjLightParams[light->lightParamsIndex]; s16 radius; if (fire->state == FIRE_STATE_3) { - Lights_PointSetColorAndRadius((LightInfo*)&light->lightInfo, 0, 0, 0, -1); + Lights_PointSetColorAndRadius(&light->lightInfo, 0, 0, 0, -1); } else { radius = ((fire->yScale * 140.0f * fire->sizeInv) + 60.0f); - Lights_PointGlowSetInfo((LightInfo*)&light->lightInfo, fire->position.x, - (fire->position.y + (fire->yScale * 6500.0f)), fire->position.z, - ((s32)(Rand_ZeroOne() * lightParams->envColor.r) + lightParams->primColor.b), - ((s32)(Rand_ZeroOne() * lightParams->envColor.g) + lightParams->primColor.a), - ((s32)(Rand_ZeroOne() * lightParams->envColor.b) + lightParams->unk4), radius); + Lights_PointGlowSetInfo(&light->lightInfo, fire->position.x, (fire->position.y + (fire->yScale * 6500.0f)), + fire->position.z, + ((s32)(Rand_ZeroOne() * lightParams->maxColorAdj.r) + lightParams->color.r), + ((s32)(Rand_ZeroOne() * lightParams->maxColorAdj.g) + lightParams->color.g), + ((s32)(Rand_ZeroOne() * lightParams->maxColorAdj.b) + lightParams->color.b), radius); } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_UpdateLight.s") -#endif void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init, Actor* actor) { FireObj* fire2 = fire; @@ -218,7 +208,7 @@ void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* in fire2->collision.dim.radius = (fire->size * 4000.0f) + 2.5f; fire2->collision.dim.height = fire->size * 16000.0f; fire->collision.dim.yShift = fire->size * -1728.0f; - FireObj_InitLight(globalCtx, &fire->light, &init->unkC, &fire->position); + FireObj_InitLight(globalCtx, &fire->light, &init->lightParamsIndex, &fire->position); } void FireObj_Destroy(GlobalContext* globalCtx, FireObj* fire) { @@ -235,9 +225,9 @@ void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor) { EnArrow* arrow = (EnArrow*)fire->collision.base.ac; FireObj_UpdateStateTransitions(globalCtx, fire); - if (fire->state == 3) { + if (fire->state == FIRE_STATE_3) { if ((fire->collision.base.acFlags & AC_HIT) && (fire->collision.info.acHitInfo->toucher.dmgFlags & 0x800)) { - FireObj_SetState(fire, fire->dynamicSizeStep, 0); + FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_0); } } else if ((fire->collision.base.acFlags & AC_HIT) && (arrow->actor.update != NULL) && (arrow->actor.id == ACTOR_EN_ARROW)) { diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index 09e026e8f..f4ffd43c1 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -1222,8 +1222,6 @@ Gfx* Gfx_PrimColor(GraphicsContext* gfxCtx, s32 lodfrac, s32 r, s32 g, s32 b, s3 return displayList; } -#ifdef NON_MATCHING -// Regalloc differences, minor reorderings void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g, u8 b) { Gfx* masterGfx; void* zbuffer; @@ -1269,7 +1267,7 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g gDPSetRenderMode(&masterGfx[3], G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(&masterGfx[4], (GPACK_RGBA5551(255, 255, 240, 0) << 16) | GPACK_RGBA5551(255, 255, 240, 0)); gSPDisplayList(&masterGfx[5], D_0E000000.clearFillRect); - gDPSetColorImage(&masterGfx[6], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, zbuffer); + gDPSetColorImage(&masterGfx[6], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, &D_0F000000); gSPEndDisplayList(&masterGfx[7]); } @@ -1328,9 +1326,6 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g CLOSE_DISPS(gfxCtx); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_rcp/func_8012CF0C.s") -#endif void func_8012D374(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b) { if ((R_PAUSE_MENU_MODE < 2) && (D_801F6D10 < 2)) { diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index 6500f3ba6..af5e4fbe1 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -1320,8 +1320,6 @@ void func_809DC78C(Actor* thisx, GlobalContext* globalCtx) { func_809DD934(this, globalCtx); } -#ifdef NON_MATCHING -// matrix stuff at the start? void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { static Gfx* D_809DFA9C[] = { object_boss02_DL_00ECF0, object_boss02_DL_00EF90, object_boss02_DL_00F310, object_boss02_DL_00F690, @@ -1332,12 +1330,12 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { object_boss02_DL_013210, object_boss02_DL_013590, }; static Vec3f D_809DFAF4 = { -10000.0f, -100000.0f, -100000.0f }; - Boss02* this = THIS; GlobalContext* globalCtx = globalCtx2; + Boss02* this = THIS; s32 i; s32 idx; - RSPMatrix* matrix; - s32 pad; + Mtx* mtx; + Mtx* mtxIter; s32 phi_v0; f32 phi_f12; f32 spAC; @@ -1347,7 +1345,7 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { f32 sp9C; f32 sp98; - matrix = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(RSPMatrix) * 23); + mtxIter = mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Mtx) * 23); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1359,7 +1357,7 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_boss02_Tex_0041A0)); } - gSPSegment(POLY_OPA_DISP++, 0x0D, matrix); + gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); if (D_809E0422 == 0) { sp98 = -500.0f; @@ -1396,11 +1394,11 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { spA4 = 0.0f; spA0 = 0.0f; - for (i = 0; i < ARRAY_COUNT(D_809DFA9C); i++) { + for (i = 0; i < ARRAY_COUNT(D_809DFA9C); i++, mtxIter++) { if (this->unk_0195 != 0) { - phi_v0 = (D_809DF5E4[i] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); + phi_v0 = (D_809DF5E4[i + 1] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); } else { - phi_v0 = (D_809DF5B4[i] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); + phi_v0 = (D_809DF5B4[i + 1] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); } if ((i == 21) && (this->unk_0144 < 20)) { @@ -1416,9 +1414,9 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Matrix_InsertYRotation_f(M_PI / 2, MTXMODE_APPLY); Matrix_RotateStateAroundXAxis(-(M_PI / 2)); - Matrix_GetStateAsRSPMatrix(&matrix[i]); + Matrix_ToMtx(mtxIter); - gSPMatrix(POLY_OPA_DISP++, &matrix[i], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, mtxIter, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if ((this->unk_0156 & 1) && (i >= this->unk_0158) && (this->unk_015A >= i)) { POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 0x384, 0x44B); @@ -1443,7 +1441,7 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { Actor* child = this->actor.child; if (child != NULL) { - Matrix_GetStateTranslationAndScaledX(500.0f, &child->world.pos); + Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.child->world.pos); } func_809DA50C(1, &this->colliderSphere2, &this->unk_147C[i + 1]); @@ -1464,18 +1462,6 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_809DA50C(21, &this->colliderSphere1, &D_809DFAF4); } } -#else -static Gfx* D_809DFA9C[] = { - object_boss02_DL_00ECF0, object_boss02_DL_00EF90, object_boss02_DL_00F310, object_boss02_DL_00F690, - object_boss02_DL_00FA10, object_boss02_DL_00FD90, object_boss02_DL_010110, object_boss02_DL_010490, - object_boss02_DL_010810, object_boss02_DL_010B90, object_boss02_DL_010F10, object_boss02_DL_011290, - object_boss02_DL_011610, object_boss02_DL_011990, object_boss02_DL_011D10, object_boss02_DL_012090, - object_boss02_DL_012410, object_boss02_DL_012790, object_boss02_DL_012B10, object_boss02_DL_012E90, - object_boss02_DL_013210, object_boss02_DL_013590, -}; -static Vec3f D_809DFAF4 = { -10000.0f, -100000.0f, -100000.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/Boss02_Draw.s") -#endif void func_809DD0A8(Actor* thisx, GlobalContext* globalCtx) { func_809DD2F8(globalCtx); @@ -1634,8 +1620,6 @@ void func_809DD2F8(GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -#ifdef NON_MATCHING -// Small ordering in the last loop void func_809DD934(Boss02* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 i; @@ -1946,9 +1930,11 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { } temp_a0_5 = temp_a0_5->next; } + { + f32 tmp = D_809E0422 ? 3150.0f : 0.0f; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_INIBS_MOVEBG, 0, D_809E0422 ? 3150.0f : 0.0f, 0, 0, 0, 0, - D_809E0422); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_INIBS_MOVEBG, 0, tmp, 0, 0, 0, 0, D_809E0422); + } temp_a0_5 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; while (temp_a0_5 != NULL) { @@ -2052,9 +2038,6 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { ShrinkWindow_SetLetterboxTarget(27); } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DD934.s") -#endif void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index b6cf7d2d1..72fc0253a 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -499,8 +499,6 @@ void Boss06_Update(Actor* thisx, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// v/a flips void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; Boss06* this = THIS; @@ -509,10 +507,11 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { s16 temp_s0; s16 temp_f10; Vtx* temp_v0_2; - u32 temp_v0; + u16 temp_v0; + u16 pad; u8 spD3; u8 spD2; - s32 pad; + s32 maxColor = 255; // Possible FAKE MATCH f32 sp68; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -521,8 +520,8 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_8012C28C(globalCtx->state.gfxCtx); temp_v0 = gSaveContext.time; - if (gSaveContext.time > 0x8000) { - temp_v0 = (0xFFFF - gSaveContext.time) & 0xFFFF; + if (temp_v0 > CLOCK_TIME(12, 0)) { + temp_v0 = 0xFFFF - temp_v0; } sp68 = (f32)temp_v0 / 0x8000; spD3 = ((10.0f * sp68) + 105.0f) * this->unk_19C; @@ -579,10 +578,12 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_InsertTranslation(0.0f, 0.0f, -1112.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x9B, 255, 255, (u8)((140.0f * sp68) + 115.0f), spD3); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 155, 255, maxColor, (u8)((140.0f * sp68) + 115.0f), spD3); gSPDisplayList(POLY_XLU_DISP++, object_knight_DL_018CF0); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, (u8)((100.0f * sp68) + 65.0f), spD2); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 255, 255, maxColor, (u8)((100.0f * sp68) + 65.0f), spD2); gSPDisplayList(POLY_XLU_DISP++, object_knight_DL_018DE0); + + if (1) {} } if (this->unk_144 & 1) { @@ -603,7 +604,7 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_809F2120(1, 0x71A5, 0x263A); gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 0); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 230); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 128, 255, 255, 0, 230); for (i = 0; i < ARRAY_COUNT(D_809F4370); i++) { if ((fabsf(D_809F4370[i].x - 32.0f) < 30.0f) && (fabsf(D_809F4370[i].y - 32.0f) < 30.0f)) { @@ -621,7 +622,7 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); } - Matrix_Scale(-0.002f, -this->unk_1D8, 1.0f, MTXMODE_APPLY); + Matrix_Scale(-0.02f / 10.0f, -this->unk_1D8, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -655,6 +656,3 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_06/Boss06_Draw.s") -#endif diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c index 33b7e3058..9acb2f9a5 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -74,32 +74,19 @@ static ColliderCylinderInit sCylinderInit = { { 10, 30, 0, { 0, 0, 0 } }, }; -static u16 D_80C00A44[] = { - 0x0719, - 0x071A, - 0x071B, - 0x0708, +u16 D_80C00A44[] = { 0x719, 0x71A, 0x71B, 0x708 }; + +u16 D_80C00A4C[] = { 0x739, 0x73A, 0x73B, 0x000 }; + +u16 D_80C00A54[] = { + 0x739, 0x73A, 0x73B, 0x714, 0x709, 0x70A, 0x70B, 0x70C, 0x70D, 0x70E, 0x70F, 0x712, 0x713, }; -static u16 D_80C00A4C[] = { - 0x0739, - 0x073A, - 0x073B, - 0x0000, +u16 D_80C00A70[] = { + 0x739, 0x73A, 0x73B, 0x759, 0x753, 0x754, 0x755, 0x756, 0x70D, 0x757, 0x758, 0x712, 0x713, }; -static u16 D_80C00A54[] = { 0x0739, 0x073A, 0x073B, 0x0714, 0x0709, 0x070A, 0x070B, - 0x070C, 0x070D, 0x070E, 0x070F, 0x0712, 0x0713 }; - -static u16 D_80C00A70[] = { 0x0739, 0x073A, 0x073B, 0x0759, 0x0753, 0x0754, 0x0755, - 0x0756, 0x070D, 0x0757, 0x0758, 0x0712, 0x0713 }; - -static u16 D_80C00A8C[] = { - 0x0736, - 0x0737, - 0x0738, - 0x074E, -}; +u16 D_80C00A8C[] = { 0x736, 0x737, 0x738, 0x74E }; static AnimationHeader* sAnimations[] = { &object_cs_Anim_0064B8, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, @@ -109,9 +96,14 @@ static AnimationHeader* sAnimations[] = { &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, &object_cs_Anim_0036B0, &object_cs_Anim_0031C4, }; -static u8 D_80C00AE4[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, - 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, +u8 D_80C00AE4[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, + ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, +}; + +s16 D_80C00AF8[] = { + 0x4000, 60, 0x4000, 30, 0xC000, 30, 0xC000, 60, }; void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -640,21 +632,7 @@ void func_80BFF6CC(EnBomjima* this, GlobalContext* globalCtx) { } } -#ifdef NON_EQUIVALENT -// Data indexing is wrong - -typedef struct { - /* 0x00 */ s16 unk_00; - /* 0x02 */ s16 unk_02; -} EnBombjimaStruct; - void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { - static EnBombjimaStruct D_80C00AF8[] = { - { 0x4000, 0x003C }, - { 0x4000, 0x001E }, - { 0xC000, 0x001E }, - { 0xC000, 0x003C }, - }; Player* player = GET_PLAYER(globalCtx); Vec3f spA0; EnBombal* temp_s3; @@ -688,13 +666,12 @@ void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { temp_s3 = (EnBombal*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_BOMJIMA, spA0.x, spA0.y, spA0.z, 0, 0, 0, i + 32); if (temp_s3 != NULL) { - s32 idx1 = (i * 2) - 1; - s32 idx2 = i * 2; + s32 index = (i * 2) - 2; Math_Vec3f_Copy(&spA0, &this->actor.world.pos); - spA0.x += Math_SinS(D_80C00AF8[idx1 - 1].unk_00 + this->actor.world.rot.y) * D_80C00AF8[idx2].unk_02; - spA0.z += Math_CosS(D_80C00AF8[idx2].unk_00 + this->actor.world.rot.y) * D_80C00AF8[idx2].unk_02; + spA0.x += Math_SinS(D_80C00AF8[(i * 2) - 2] + this->actor.world.rot.y) * D_80C00AF8[index + 1]; + spA0.z += Math_CosS(D_80C00AF8[index] + this->actor.world.rot.y) * D_80C00AF8[index + 1]; Math_Vec3f_Copy(&temp_s3->unk_2A4, &spA0); } @@ -704,15 +681,6 @@ void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[1], &this->actor); this->actionFunc = func_80BFF9B0; } -#else -static s16 D_80C00AF8[][2] = { - { 0x4000, 0x003C }, - { 0x4000, 0x001E }, - { 0xC000, 0x001E }, - { 0xC000, 0x003C }, -}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF754.s") -#endif void func_80BFF9B0(EnBomjima* this, GlobalContext* globalCtx) { if (D_80C009F0 >= 4) { 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 610d85b8b..dd8d95c23 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -528,10 +528,9 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { return false; } -#ifdef NON_MATCHING -// Stack void func_8093FAA4(EnGoroiwa* this, GlobalContext* globalCtx) { f32 temp; + f32 tmp2; f32 sp7C; Vec3f sp70; Vec3f sp64; @@ -541,7 +540,8 @@ void func_8093FAA4(EnGoroiwa* this, GlobalContext* globalCtx) { sp7C = this->unk_1C0; } else { temp = Math3D_Distance(&this->actor.world.pos, &this->actor.prevPos); - this->unk_1C0 = temp / this->unk_1DC; + tmp2 = temp / this->unk_1DC; + this->unk_1C0 = tmp2; sp7C = this->unk_1C0; } @@ -567,9 +567,6 @@ void func_8093FAA4(EnGoroiwa* this, GlobalContext* globalCtx) { Matrix_CopyCurrentState(&sp24); func_8018219C(&sp24, &this->actor.shape.rot, MTXMODE_NEW); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093FAA4.s") -#endif void func_8093FC00(EnGoroiwa* this) { s32 params = ENGOROIWA_GET_300(&this->actor); @@ -724,8 +721,8 @@ void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { Math_Vec3f_Sum(&sp100, &sp10C, &sp100); EffectSsKakera_Spawn(globalCtx, &sp100, &spF4, &sp100, phi_s2, phi_s0, 30, 0, 0, - ((Rand_ZeroOne() * 150.0f) + 300.0f) * this->actor.scale.x, phi_s3, 0, 0x32, -1, 0xEF, - phi_s1); + ((Rand_ZeroOne() * 150.0f) + 300.0f) * this->actor.scale.x, phi_s3, 0, 0x32, -1, + OBJECT_GOROIWA, phi_s1); if (this->unk_1E6 == 0) { sp100.x += ((Rand_ZeroOne() * 1200.0f) - 600.0f) * this->actor.scale.x; sp100.y += ((Rand_ZeroOne() * 1400.0f) - 600.0f) * this->actor.scale.y; @@ -807,7 +804,7 @@ void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGB } EffectSsKakera_Spawn(globalCtx, &sp100, &spF4, &sp100, phi_fp, phi_s0, 30, 0, 0, - ((Rand_ZeroOne() * 100.0f) + 170.0f) * arg5, spC8, 0, 0x36, -1, 0xEF, phi_s7); + ((Rand_ZeroOne() * 100.0f) + 170.0f) * arg5, spC8, 0, 0x36, -1, OBJECT_GOROIWA, phi_s7); for (j = 0; j < 2; j++) { spE8.x = (((Rand_ZeroOne() * 1000.0f) - 500.0f) * arg5) + sp100.x; @@ -882,7 +879,7 @@ void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA } EffectSsKakera_Spawn(globalCtx, &spE8, &spDC, &spE8, phi_s2, phi_s0, 30, 0, 0, - ((Rand_ZeroOne() * 150.0f) + 250.0f) * arg5, phi_s3, 0, 0x36, -1, 0xEF, phi_s1); + ((Rand_ZeroOne() * 150.0f) + 250.0f) * arg5, phi_s3, 0, 0x36, -1, OBJECT_GOROIWA, phi_s1); spE8.x += ((Rand_ZeroOne() * 800.0f) - 400.0f) * arg5; spE8.y += ((Rand_ZeroOne() * 800.0f) - 250.0f) * arg5; @@ -1431,8 +1428,6 @@ void func_80942604(EnGoroiwa* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// stack for params and colCtx void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnGoroiwa* this = THIS; @@ -1442,6 +1437,8 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { Vec3f sp50; f32 sp4C; s32 sp48 = true; + u32 temp_v0_2; + CollisionPoly* tmp; if (!(player->stateFlags1 & (0x30000000 | 0x80 | 0x40))) { if (this->unk_1CC > 0) { @@ -1459,8 +1456,9 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { sp5C = true; if (this->actor.flags & ACTOR_FLAG_40) { - if (this->actor.floorPoly != NULL) { - u32 temp_v0_2 = func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + tmp = this->actor.floorPoly; + if (tmp != NULL) { + temp_v0_2 = func_800C99D4(&globalCtx->colCtx, tmp, this->actor.floorBgId); if ((temp_v0_2 == 14) || (temp_v0_2 == 15)) { if (!(this->unk_1E5 & 0x40)) { @@ -1549,9 +1547,6 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/EnGoroiwa_Update.s") -#endif void func_80942B1C(EnGoroiwa* this, GlobalContext* globalCtx) { s32 pad; diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c index 99d19a1cf..ac42d0c7a 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -255,7 +255,7 @@ void func_8095DABC(Actor* thisx, GlobalContext* globalCtx) { } EffectSsKakera_Spawn(globalCtx, &spCC, &spD8, &this->actor.world.pos, phi_v1, phi_v0, 30, 5, 0, D_8095F758[i], - 5, 2, 70, 0, 2, gameplay_field_keep_DL_006420); + 5, 2, 70, 0, GAMEPLAY_FIELD_KEEP, gameplay_field_keep_DL_006420); } } diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c index e3edc7311..849e3e1d6 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -995,7 +995,7 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { f32 shadowAlpha; if (dayTime >= CLOCK_TIME(12, 0)) { - dayTime = (0xFFFF - dayTime) & 0xFFFF; + dayTime = 0xFFFF - dayTime; } shadowAlpha = (dayTime * 0.00275f) + 10.0f; diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c index 467a81de0..cbb0fcd7a 100644 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c @@ -346,7 +346,7 @@ void func_809375F4(ObjBean* this, GlobalContext* globalCtx) { phi_v0 = 0x40; } EffectSsKakera_Spawn(globalCtx, &spC4, &spB8, &spC4, phi_s3, phi_v0, 40, 3, 0, temp_s2, 0, 0, - (temp_s2 >> 3) + 40, -1, 1, D_80939024[i & 1]); + (temp_s2 >> 3) + 40, -1, GAMEPLAY_KEEP, D_80939024[i & 1]); } } diff --git a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c index 632d1b8c6..15a63746b 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c @@ -228,8 +228,8 @@ void func_80B030F8(ObjSnowball* this, GlobalContext* globalCtx) { scale = ((Rand_ZeroOne() * 15.0f) + 30.0f) * this->unk_20C; - EffectSsKakera_Spawn(globalCtx, &spFC, &spF0, &spFC, gravity, phi_s0, 30, 0, 0, scale, phi_s4, 0, 50, -1, 0xEF, - temp_s2); + EffectSsKakera_Spawn(globalCtx, &spFC, &spF0, &spFC, gravity, phi_s0, 30, 0, 0, scale, phi_s4, 0, 50, -1, + OBJECT_GOROIWA, temp_s2); if ((this->unk_210 == 0) && (temp_s7 >= 3)) { spFC.x += (Rand_ZeroOne() * 120.0f) - 60.0f; spFC.y += Rand_ZeroOne() * 80.0f; @@ -333,7 +333,6 @@ void func_80B03688(ObjSnowball* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { f32 temp_f30 = sqrtf(arg1); Vec3f spD8; @@ -341,14 +340,16 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { s32 i; Gfx* temp_s1; f32 temp_f20; - s32 phi_s5; - s32 pad; s16 phi_s2; - s32 pad2; s16 phi_s0; s16 phi_s3; + s32 phi_s5; + s32 tmp; + s32 pad; for (i = 0, phi_s5 = 0; i < 13; i++, phi_s5 += 0x1999) { + tmp = i & 3; + temp_f20 = (Rand_ZeroOne() * (40.0f * arg1)) + 20.0f; spD8.x = Math_SinS((s32)(Rand_ZeroOne() * 6553.6f) + phi_s5) * temp_f20; @@ -363,7 +364,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { spD8.y += arg2->y; spD8.z += arg2->z; - if ((i & 3) == 0) { + if (tmp == 0) { temp_s1 = D_80B04FC8[0]; phi_s2 = -400; phi_s3 = 1; @@ -372,7 +373,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { } else { phi_s0 = 0x41; } - } else if ((i & 3) == 1) { + } else if (tmp == 1) { temp_s1 = D_80B04FC8[1]; phi_s2 = -340; phi_s3 = 1; @@ -389,7 +390,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { } EffectSsKakera_Spawn(globalCtx, &spD8, &spCC, &spD8, phi_s2, phi_s0, 30, 0, 0, - ((Rand_ZeroOne() * 15.0f) + 25.0f) * arg1, phi_s3, 0, 0x36, -1, 0xEF, temp_s1); + ((Rand_ZeroOne() * 15.0f) + 25.0f) * arg1, phi_s3, 0, 0x36, -1, OBJECT_GOROIWA, temp_s1); spD8.x += (Rand_ZeroOne() * 80.0f) - 40.0f; spD8.y += Rand_ZeroOne() * 55.0f; @@ -401,10 +402,6 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { (s32)(Rand_ZeroOne() * 30.0f * temp_f30) + 60); } } -#else -void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B03A80.s") -#endif void func_80B03E2C(ObjSnowball* this, GlobalContext* globalCtx) { ObjSnowballStruct* ptr; diff --git a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c index 76111148a..229cdf516 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c @@ -178,7 +178,7 @@ void func_80B39108(ObjSnowball2* this, GlobalContext* globalCtx) { } EffectSsKakera_Spawn(globalCtx, &spD0, &spDC, &spD0, -300, phi_s1, 30, 0, 0, (temp >> 0x1D) + 8, phi_v0, 0, 50, - -1, 0xEF, D_80B3A91C[i & 3]); + -1, OBJECT_GOROIWA, D_80B3A91C[i & 3]); spD0.x += (Rand_ZeroOne() - 0.5f) * 40.0f; spD0.y += (Rand_ZeroOne() - 0.3f) * 45.0f; diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c index 1637e1978..f38818cbe 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c @@ -193,7 +193,7 @@ void Daytelop_Draw(DaytelopContext* this) { void Daytelop_Main(GameState* thisx) { DaytelopContext* this = (DaytelopContext*)thisx; - func_8012CF0C(this->state.gfxCtx, 1, 1, 0, 0, 0); + func_8012CF0C(this->state.gfxCtx, true, true, 0, 0, 0); OPEN_DISPS(this->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x09, this->daytelopStaticFile); diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index 96fe615fc..cff312816 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -37,7 +37,7 @@ void func_80803EA0(OpeningContext* this) { void Opening_Main(GameState* thisx) { OpeningContext* this = (OpeningContext*)thisx; - func_8012CF0C(this->gameState.gfxCtx, 0, 1, 0, 0, 0); + func_8012CF0C(this->gameState.gfxCtx, false, true, 0, 0, 0); Opening_SetupForTitleCutscene(this); func_80803EA0(this); } diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 1cae35a85..ccc0d434c 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -868,7 +868,7 @@ void Select_DrawLoadingScreen(SelectContext* this) { void Select_Draw(SelectContext* this) { GraphicsContext* gfxCtx = this->state.gfxCtx; - func_8012CF0C(gfxCtx, 1, 1, 0, 0, 0); + func_8012CF0C(gfxCtx, true, true, 0, 0, 0); SET_FULLSCREEN_VIEWPORT(&this->view); View_RenderView(&this->view, 0xF); diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 827c27387..79d1c19f2 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -119,7 +119,7 @@ void Title_Draw(GameState* thisx) { void Title_Main(GameState* thisx) { TitleContext* this = (TitleContext*)thisx; - func_8012CF0C(this->gameState.gfxCtx, 1, 1, 0, 0, 0); + func_8012CF0C(this->gameState.gfxCtx, true, true, 0, 0, 0); OPEN_DISPS(this->gameState.gfxCtx); diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 1b594bd60..71e653d2f 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -932,7 +932,8 @@ 0x801BD8C4:("actorCutsceneReturnCamera","s16","",0x2), 0x801BD8C6:("D_801BD8C6","s16","",0x2), 0x801BD8D0:("sFireObjCollisionInit","ColliderCylinderInit","",0x2c), - 0x801BD8FC:("sFireObjLightParams","FireObjLightParams","[2]",0x10), + 0x801BD8FC:("sFireObjColors","FireObjColors","[1]",0x08), + 0x801BD904:("sFireObjLightParams","FireObjLightParams","[1]",0x08), 0x801BD910:("gGameStateOverlayTable","GameStateOverlay","[7]",0x150), 0x801BDA60:("graphNumGameStates","UNK_TYPE4","",0x4), 0x801BDA70:("D_801BDA70","UNK_TYPE2","",0x2), @@ -9003,7 +9004,7 @@ 0x80979150:("D_80979150","f32","",0x4), 0x80979560:("Effect_Ss_D_Fire_InitVars","UNK_TYPE1","",0x1), 0x80979568:("D_80979568","UNK_TYPE1","",0x1), - 0x80979AB0:("Effect_Ss_Bubble_InitVars","UNK_TYPE1","",0x1), + 0x80979AB0:("Effect_Ss_Bubble_InitVars","UNK_TYPE1","",0x8), 0x80979AB8:("D_80979AB8","UNK_TYPE1","",0x1), 0x80979AD0:("D_80979AD0","f32","",0x4), 0x80979AD4:("D_80979AD4","f32","",0x4), diff --git a/undefined_syms.txt b/undefined_syms.txt index a003b1ae3..704a352e3 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -781,11 +781,6 @@ D_06022118 = 0x06022118; D_060222D0 = 0x060222D0; D_06022550 = 0x06022550; -// ovl_Boss_02 - -D_060003A0 = 0x060003A0; -D_060041A0 = 0x060041A0; - // ovl_Boss_03 D_06004260 = 0x06004260; From fa321be0f37747cc4980f154d20f1b387476e949 Mon Sep 17 00:00:00 2001 From: immibis Date: Thu, 10 Mar 2022 02:08:36 +0100 Subject: [PATCH 078/257] Bg_F40_Switch OK and documented (#526) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Bg_F40_Switch OK and documented * updates for Bg_F40_Switch PR * update names * formatting * func_80BC46B0 → BgF40Switch_CheckAll --- spec | 4 +- .../ovl_Bg_F40_Switch/z_bg_f40_switch.c | 167 +++++++++++++++--- .../ovl_Bg_F40_Switch/z_bg_f40_switch.h | 11 +- tools/disasm/functions.txt | 12 +- tools/disasm/variables.txt | 6 +- undefined_syms.txt | 6 - 6 files changed, 164 insertions(+), 42 deletions(-) diff --git a/spec b/spec index 06fbe1e31..bfce04399 100644 --- a/spec +++ b/spec @@ -4592,9 +4592,7 @@ beginseg name "ovl_Bg_F40_Switch" compress include "build/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.o" - include "build/data/ovl_Bg_F40_Switch/ovl_Bg_F40_Switch.data.o" - include "build/data/ovl_Bg_F40_Switch/ovl_Bg_F40_Switch.bss.o" - include "build/data/ovl_Bg_F40_Switch/ovl_Bg_F40_Switch.reloc.o" + include "build/src/overlays/actors/ovl_Bg_F40_Switch/ovl_Bg_F40_Switch_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c index 8bb351a97..e44cb89d6 100644 --- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c +++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c @@ -5,6 +5,7 @@ */ #include "z_bg_f40_switch.h" +#include "objects/object_f40_switch/object_f40_switch.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,13 +16,13 @@ void BgF40Switch_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgF40Switch_Update(Actor* thisx, GlobalContext* globalCtx); void BgF40Switch_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BC4B20(BgF40Switch* this, GlobalContext* globalCtx); -void func_80BC4B94(BgF40Switch* this, GlobalContext* globalCtx); -void func_80BC4BB8(BgF40Switch* this, GlobalContext* globalCtx); -void func_80BC4C68(BgF40Switch* this, GlobalContext* globalCtx); -void func_80BC4D30(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_CheckAll(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_Unpress(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_IdlePressed(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_Press(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_WaitToPress(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_IdleUnpressed(BgF40Switch* this, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_F40_Switch_InitVars = { ACTOR_BG_F40_SWITCH, ACTORCAT_SWITCH, @@ -34,37 +35,159 @@ const ActorInit Bg_F40_Switch_InitVars = { (ActorFunc)BgF40Switch_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BC4E04[] = { +s32 sBgF40SwitchGlobalsInitialized = false; +u32 sBgF40SwitchLastUpdateFrame; + +/* + * Updates all instances of this actor in the current room, unless it's already been called this frame. + */ +void BgF40Switch_CheckAll(BgF40Switch* this, GlobalContext* globalCtx) { + if (globalCtx->gameplayFrames != sBgF40SwitchLastUpdateFrame) { + u32 pressedSwitchFlags[4] = { 0 }; + u32 pad; + s32 switchFlag; + s32 isPressed; + Actor* actor; + BgF40Switch* actorAsSwitch; + u32 inCsMode = Player_InCsMode(&globalCtx->state); + + for (actor = globalCtx->actorCtx.actorLists[ACTORCAT_SWITCH].first; actor != NULL; actor = actor->next) { + if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->actor.actor.room && actor->update != NULL) { + actorAsSwitch = (BgF40Switch*)actor; + actorAsSwitch->wasPressed = actorAsSwitch->isPressed; + isPressed = DynaPolyActor_IsInSwitchPressedState(&actorAsSwitch->actor); + if (actorAsSwitch->isPressed && actorAsSwitch->actionFunc == BgF40Switch_IdlePressed) { + // Switch is fully pressed - if there's nothing keeping it pressed, wait a short time before + // reverting to unpressed state. + if (isPressed || inCsMode) { + actorAsSwitch->switchReleaseDelay = 6; + } else { + if (actorAsSwitch->switchReleaseDelay > 0) { + actorAsSwitch->switchReleaseDelay--; + } else { + actorAsSwitch->isPressed = isPressed; + } + } + } else { + // No delay when pressing switch, or releasing from a not-fully-pressed state. + actorAsSwitch->isPressed = isPressed; + } + if (actorAsSwitch->isPressed) { + switchFlag = BGF40SWITCH_GET_SWITCHFLAG(actorAsSwitch); + if (switchFlag >= 0 && switchFlag < 0x80) { + pressedSwitchFlags[(switchFlag & ~0x1F) >> 5] |= 1 << (switchFlag & 0x1F); + if (!actorAsSwitch->wasPressed && actorAsSwitch->actionFunc == BgF40Switch_IdleUnpressed && + !Flags_GetSwitch(globalCtx, switchFlag)) { + actorAsSwitch->isInitiator = true; + } + } + } + } + } + for (actor = globalCtx->actorCtx.actorLists[ACTORCAT_SWITCH].first; actor != NULL; actor = actor->next) { + if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->actor.actor.room && actor->update != 0) { + switchFlag = BGF40SWITCH_GET_SWITCHFLAG((BgF40Switch*)actor); + if (switchFlag >= 0 && switchFlag < 0x80 && Flags_GetSwitch(globalCtx, switchFlag) && + !(pressedSwitchFlags[(switchFlag & ~0x1F) >> 5] & (1 << (switchFlag & 0x1F)))) { + Flags_UnsetSwitch(globalCtx, switchFlag); + } + } + } + sBgF40SwitchLastUpdateFrame = globalCtx->gameplayFrames; + } +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 123, ICHAIN_STOP), }; -#endif +void BgF40Switch_Init(Actor* thisx, GlobalContext* globalCtx) { + BgF40Switch* this = THIS; -extern InitChainEntry D_80BC4E04[]; + Actor_ProcessInitChain(&this->actor.actor, sInitChain); + this->actor.actor.scale.y = 0.165f; + this->actionFunc = BgF40Switch_IdleUnpressed; + this->actor.actor.world.pos.y = this->actor.actor.home.pos.y + 1.0f; + DynaPolyActor_Init(&this->actor, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->actor, &object_f40_switch_Colheader_000118); + if (!sBgF40SwitchGlobalsInitialized) { + sBgF40SwitchLastUpdateFrame = globalCtx->gameplayFrames; + sBgF40SwitchGlobalsInitialized = true; + } +} -extern UNK_TYPE D_06000118; -extern UNK_TYPE D_06000438; +void BgF40Switch_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgF40Switch* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC47B0.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->actor.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/BgF40Switch_Init.s") +void BgF40Switch_Unpress(BgF40Switch* this, GlobalContext* globalCtx) { + this->actor.actor.scale.y += 0.0495f; + if (this->actor.actor.scale.y >= 0.165f) { + Actor_PlaySfxAtPos(&this->actor.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); + this->actionFunc = BgF40Switch_IdleUnpressed; + this->actor.actor.scale.y = 0.165f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/BgF40Switch_Destroy.s") +void BgF40Switch_IdlePressed(BgF40Switch* this, GlobalContext* globalCtx) { + if (!this->isPressed) { + this->actionFunc = BgF40Switch_Unpress; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4B20.s") +void BgF40Switch_Press(BgF40Switch* this, GlobalContext* globalCtx) { + this->actor.actor.scale.y -= 0.0495f; + if (this->actor.actor.scale.y <= 0.0165f) { + Actor_PlaySfxAtPos(&this->actor.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); + func_8013ECE0(this->actor.actor.xyzDistToPlayerSq, 120, 20, 10); + if (this->isInitiator) { + ActorCutscene_Stop(this->actor.actor.cutscene); + this->isInitiator = false; + } + this->actionFunc = BgF40Switch_IdlePressed; + this->actor.actor.scale.y = 0.0165f; + this->switchReleaseDelay = 6; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4B94.s") +void BgF40Switch_WaitToPress(BgF40Switch* this, GlobalContext* globalCtx) { + if (!this->isInitiator || this->actor.actor.cutscene == -1) { + this->actionFunc = BgF40Switch_Press; + if (this->isInitiator) { + Flags_SetSwitch(globalCtx, BGF40SWITCH_GET_SWITCHFLAG(this)); + } + } else if (ActorCutscene_GetCanPlayNext(this->actor.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.actor.cutscene, &this->actor.actor); + this->actionFunc = BgF40Switch_Press; + if (this->isInitiator) { + Flags_SetSwitch(globalCtx, BGF40SWITCH_GET_SWITCHFLAG(this)); + } + } else { + ActorCutscene_SetIntentToPlay(this->actor.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4BB8.s") +void BgF40Switch_IdleUnpressed(BgF40Switch* this, GlobalContext* globalCtx) { + if (this->isPressed) { + this->actionFunc = BgF40Switch_WaitToPress; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4C68.s") +void BgF40Switch_Update(Actor* thisx, GlobalContext* globalCtx) { + BgF40Switch* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4D30.s") + BgF40Switch_CheckAll(this, globalCtx); + this->actionFunc(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/BgF40Switch_Update.s") +void BgF40Switch_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgF40Switch* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/BgF40Switch_Draw.s") + Gfx_DrawDListOpa(globalCtx, object_f40_switch_DL_000438); + Gfx_DrawDListOpa(globalCtx, object_f40_switch_DL_000390); +} diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h index 8b4f2b679..ec2b4dfec 100644 --- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h +++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h @@ -5,11 +5,18 @@ struct BgF40Switch; +#define BGF40SWITCH_GET_SWITCHFLAG(this) (((this)->actor.actor.params & 0xFE00) >> 9) + typedef void (*BgF40SwitchActionFunc)(struct BgF40Switch*, GlobalContext*); typedef struct BgF40Switch { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x20]; + /* 0x0000 */ DynaPolyActor actor; + /* 0x015C */ s16 switchReleaseDelay; // frames until a pressed switch becomes released if nothing is still pressing it + /* 0x015E */ s8 isPressed; // Logical state of the switch (pressed or unpressed). Animation state may lag behind this slightly. + /* 0x015F */ s8 wasPressed; // used as temporary during update function + // true if this switch is the one that initiated a state change; false if this switch is changing as a result of another switch tied to the same flag. + // this is a temporary flag related to something currently happening, not a permanent property of the switch. + /* 0x0160 */ s8 isInitiator; /* 0x0164 */ BgF40SwitchActionFunc actionFunc; } BgF40Switch; // size = 0x168 diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 73b194c00..0205a8338 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -15531,14 +15531,14 @@ 0x80BC457C:("func_80BC457C",), 0x80BC458C:("BgF40Block_Update",), 0x80BC45CC:("BgF40Block_Draw",), - 0x80BC47B0:("func_80BC47B0",), + 0x80BC47B0:("BgF40Switch_CheckAll",), 0x80BC4A3C:("BgF40Switch_Init",), 0x80BC4AEC:("BgF40Switch_Destroy",), - 0x80BC4B20:("func_80BC4B20",), - 0x80BC4B94:("func_80BC4B94",), - 0x80BC4BB8:("func_80BC4BB8",), - 0x80BC4C68:("func_80BC4C68",), - 0x80BC4D30:("func_80BC4D30",), + 0x80BC4B20:("BgF40Switch_Unpress",), + 0x80BC4B94:("BgF40Switch_IdlePressed",), + 0x80BC4BB8:("BgF40Switch_Press",), + 0x80BC4C68:("BgF40Switch_WaitToPress",), + 0x80BC4D30:("BgF40Switch_IdleUnpressed",), 0x80BC4D54:("BgF40Switch_Update",), 0x80BC4D90:("BgF40Switch_Draw",), 0x80BC4F30:("EnPoComposer_Init",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 71e653d2f..83f8ac2e9 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -15771,8 +15771,8 @@ 0x80BC4668:("D_80BC4668","UNK_TYPE1","",0x1), 0x80BC4680:("jtbl_80BC4680","UNK_PTR","",0x4), 0x80BC4DD0:("Bg_F40_Switch_InitVars","UNK_TYPE1","",0x1), - 0x80BC4DF0:("D_80BC4DF0","UNK_TYPE4","",0x4), - 0x80BC4DF4:("D_80BC4DF4","UNK_TYPE4","",0x4), + 0x80BC4DF0:("sBgF40SwitchGlobalsInitialized","s32","",0x4), + 0x80BC4DF4:("sBgF40SwitchGlobalFlags","BgF40SwitchGlobalFlags","",0x10), 0x80BC4E04:("D_80BC4E04","UNK_TYPE1","",0x1), 0x80BC4E20:("D_80BC4E20","f32","",0x4), 0x80BC4E24:("D_80BC4E24","f32","",0x4), @@ -15781,7 +15781,7 @@ 0x80BC4E30:("D_80BC4E30","f32","",0x4), 0x80BC4E34:("D_80BC4E34","f32","",0x4), 0x80BC4E38:("D_80BC4E38","f32","",0x4), - 0x80BC4F20:("D_80BC4F20","UNK_TYPE1","",0x1), + 0x80BC4F20:("sBgF40SwitchLastUpdateFrame","u32","",0x4), 0x80BC6760:("En_Po_Composer_InitVars","UNK_TYPE1","",0x1), 0x80BC6780:("D_80BC6780","UNK_TYPE1","",0x1), 0x80BC67AC:("D_80BC67AC","UNK_TYPE1","",0x1), diff --git a/undefined_syms.txt b/undefined_syms.txt index 704a352e3..f05a115c6 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -613,12 +613,6 @@ D_06004640 = 0x06004640; D_06004038 = 0x06004038; D_06004240 = 0x06004240; -// ovl_Bg_F40_Switch - -D_06000118 = 0x06000118; -D_06000390 = 0x06000390; -D_06000438 = 0x06000438; - // ovl_Bg_F40_Swlift D_06003B08 = 0x06003B08; From 6ed7b0849c95323fa8bf48366de2c6041f857965 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Thu, 10 Mar 2022 02:19:00 +0000 Subject: [PATCH 079/257] En_Osk (#670) * En_Osk * PR * run actorfixer Co-authored-by: angie --- spec | 3 +- src/overlays/actors/ovl_En_Osk/z_en_osk.c | 534 +++++++++++++++++++++- src/overlays/actors/ovl_En_Osk/z_en_osk.h | 13 +- undefined_syms.txt | 9 - 4 files changed, 526 insertions(+), 33 deletions(-) diff --git a/spec b/spec index bfce04399..164776201 100644 --- a/spec +++ b/spec @@ -4970,8 +4970,7 @@ beginseg name "ovl_En_Osk" compress include "build/src/overlays/actors/ovl_En_Osk/z_en_osk.o" - include "build/data/ovl_En_Osk/ovl_En_Osk.data.o" - include "build/data/ovl_En_Osk/ovl_En_Osk.reloc.o" + include "build/src/overlays/actors/ovl_En_Osk/ovl_En_Osk_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Osk/z_en_osk.c b/src/overlays/actors/ovl_En_Osk/z_en_osk.c index 2faed6abb..62771a433 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.c +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.c @@ -5,6 +5,8 @@ */ #include "z_en_osk.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_ikn_demo/object_ikn_demo.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -20,7 +22,6 @@ void func_80BF61EC(EnOsk* this, GlobalContext* globalCtx); void func_80BF656C(EnOsk* this, GlobalContext* globalCtx); void func_80BF6A20(EnOsk* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Osk_InitVars = { ACTOR_EN_OSK, ACTORCAT_NPC, @@ -33,42 +34,533 @@ const ActorInit En_Osk_InitVars = { (ActorFunc)EnOsk_Draw, }; -#endif +AnimationHeader* D_80BF6FA0[] = { + &object_ikn_demo_Anim_003CAC, &object_ikn_demo_Anim_004208, &object_ikn_demo_Anim_004514, + &object_ikn_demo_Anim_004A58, &object_ikn_demo_Anim_0065D8, +}; -extern UNK_TYPE D_06006808; +AnimationHeader* D_80BF6FB4[] = { + &object_ikn_demo_Anim_0067B8, &object_ikn_demo_Anim_0083F4, &object_ikn_demo_Anim_0081A8, + &object_ikn_demo_Anim_008AF4, &object_ikn_demo_Anim_008724, &object_ikn_demo_Anim_008F1C, + &object_ikn_demo_Anim_008CEC, &object_ikn_demo_Anim_009254, &object_ikn_demo_Anim_009044, + &object_ikn_demo_Anim_0098E4, &object_ikn_demo_Anim_009CC8, &object_ikn_demo_Anim_009A44, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/EnOsk_Init.s") +AnimationHeader* D_80BF6FE4[] = { + &object_ikn_demo_Anim_009EA8, &object_ikn_demo_Anim_00B8C0, &object_ikn_demo_Anim_00B704, + &object_ikn_demo_Anim_00BDB4, &object_ikn_demo_Anim_00B9E4, &object_ikn_demo_Anim_00C154, + &object_ikn_demo_Anim_00BF04, &object_ikn_demo_Anim_00CA74, &object_ikn_demo_Anim_00C804, + &object_ikn_demo_Anim_00D044, &object_ikn_demo_Anim_00CD28, &object_ikn_demo_Anim_00C59C, + &object_ikn_demo_Anim_00C2C4, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/EnOsk_Destroy.s") +Vec3f D_80BF7018 = { 0.0f, 0.5f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5E00.s") +Vec3f D_80BF7024 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5E68.s") +void EnOsk_Init(Actor* thisx, GlobalContext* globalCtx) { + EnOsk* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5EBC.s") + Actor_SetScale(&this->actor, 0.013f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5F60.s") + this->actionFunc = func_80BF5F60; + this->unk_254 = -1; + this->unk_256 = -1; + this->actor.flags &= ~ACTOR_FLAG_1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5F70.s") + switch (ENOSK_GET_F(&this->actor)) { + case ENOSK_1: + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ikn_demo_Skel_007B48, &object_ikn_demo_Anim_006808, + this->jointTable, this->morphTable, 7); + Animation_PlayLoop(&this->skelAnime, &object_ikn_demo_Anim_006808); + this->actionFunc = func_80BF656C; + this->unk_258 = 0x210; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF609C.s") + case ENOSK_2: + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ikn_demo_Skel_00B490, &object_ikn_demo_Anim_009F00, + this->jointTable, this->morphTable, 7); + Animation_PlayLoop(&this->skelAnime, &object_ikn_demo_Anim_006808); + this->actionFunc = func_80BF6A20; + this->unk_258 = 0x211; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF61EC.s") + default: + Actor_SetScale(&this->actor, 0.017f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ikn_demo_Skel_0038F0, &object_ikn_demo_Anim_0000B8, + this->jointTable, this->morphTable, 17); + Animation_PlayLoop(&this->skelAnime, &object_ikn_demo_Anim_0000B8); + this->actionFunc = func_80BF61EC; + this->unk_258 = 0x212; + this->actor.home.rot.z = 0; + this->unk_25C = 0.0f; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF6314.s") +void EnOsk_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF6478.s") +void func_80BF5E00(EnOsk* this, AnimationHeader** animations, s16 index, f32 morphFrame) { + if (index == this->unk_254) { + return; + } + Animation_MorphToLoop(&this->skelAnime, animations[index], morphFrame); + this->unk_254 = index; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF656C.s") +void func_80BF5E68(EnOsk* this, AnimationHeader** animations, s16 index, f32 playSpeed) { + Animation_MorphToPlayOnce(&this->skelAnime, animations[index], playSpeed); + this->unk_254 = index; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF67A8.s") +void func_80BF5EBC(EnOsk* this, GlobalContext* globalCtx) { + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF68E0.s") + sp2C.x = randPlusMinusPoint5Scaled(30.0f) + this->actor.world.pos.x; + sp2C.z = randPlusMinusPoint5Scaled(30.0f) + this->actor.world.pos.z; + sp2C.y = randPlusMinusPoint5Scaled(30.0f) + this->actor.world.pos.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF6A20.s") + func_800B3030(globalCtx, &sp2C, &D_80BF7018, &D_80BF7018, 100, 0, 2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/EnOsk_Update.s") +void func_80BF5F60(EnOsk* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF6C54.s") +void func_80BF5F70(EnOsk* this) { + if ((this->unk_256 != 1) && (this->unk_256 != 6)) { + this->actor.draw = EnOsk_Draw; + Actor_SetScale(&this->actor, 0.017f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/EnOsk_Draw.s") + switch (this->unk_256) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + func_80BF5E00(this, D_80BF6FA0, 3, -5.0f); + break; + + case 3: + func_80BF5E00(this, D_80BF6FA0, 2, -5.0f); + break; + + case 4: + func_80BF5E00(this, D_80BF6FA0, 1, -5.0f); + break; + + case 5: + func_80BF5E00(this, D_80BF6FA0, 0, -5.0f); + break; + + case 6: + func_80BF5E00(this, D_80BF6FA0, 1, -5.0f); + break; + + case 7: + func_80BF5E00(this, D_80BF6FA0, 4, -5.0f); + this->actor.home.rot.z = 1; + break; + } +} + +void func_80BF609C(EnOsk* this, GlobalContext* globalCtx) { + if (this->actor.draw != NULL) { + if (this->actor.home.rot.z != 0) { + if (globalCtx->msgCtx.unk11F04 == 0x1531) { + this->actor.home.rot.z = 0; + } + } else { + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + this->unk_25C = Rand_ZeroFloat(3.0f); + } + + switch (this->unk_254) { + case 0: + if (Animation_OnFrame(&this->skelAnime, this->unk_25C) || + Animation_OnFrame(&this->skelAnime, this->unk_25C + 8.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOSU_TALK); + } + break; + + case 1: + if (Animation_OnFrame(&this->skelAnime, this->unk_25C)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOSU_TALK); + } + break; + + case 2: + if (Animation_OnFrame(&this->skelAnime, this->unk_25C) || + Animation_OnFrame(&this->skelAnime, this->unk_25C + 6.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BOSU_TALK); + } + break; + } + } + } +} + +void func_80BF61EC(EnOsk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Cutscene_CheckActorAction(globalCtx, this->unk_258)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, this->unk_258)); + if (this->unk_256 != + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action) { + this->unk_256 = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action; + func_80BF5F70(this); + } + func_80BF609C(this, globalCtx); + } else { + this->actor.draw = NULL; + } + + if (this->unk_256 == 6) { + if (this->actor.scale.x > 0.85f * 0.001f) { + this->actor.scale.x -= 0.85f * 0.001f; + Actor_SetScale(&this->actor, this->actor.scale.x); + func_80BF5EBC(this, globalCtx); + func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } else { + this->actor.draw = NULL; + } + } +} + +void func_80BF6314(EnOsk* this) { + if ((this->unk_256 != 1) && (this->unk_256 != 9)) { + this->actor.draw = EnOsk_Draw; + Actor_SetScale(&this->actor, 0.013f); + } + + switch (this->unk_256) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + func_80BF5E00(this, D_80BF6FB4, 9, -5.0f); + Actor_SetScale(&this->actor, 0.0f); + break; + + case 3: + func_80BF5E68(this, D_80BF6FB4, 2, -5.0f); + break; + + case 4: + func_80BF5E68(this, D_80BF6FB4, 4, 0); + break; + + case 5: + func_80BF5E68(this, D_80BF6FB4, 8, -5.0f); + break; + + case 6: + func_80BF5E68(this, D_80BF6FB4, 11, -5.0f); + break; + + case 7: + func_80BF5E68(this, D_80BF6FB4, 6, -5.0f); + break; + + case 8: + func_80BF5E00(this, D_80BF6FB4, 0, -5.0f); + break; + + case 9: + func_80BF5E00(this, D_80BF6FB4, 0, -5.0f); + break; + } +} + +void func_80BF6478(EnOsk* this) { + if (this->actor.draw != NULL) { + switch (this->unk_254) { + case 1: + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || + Animation_OnFrame(&this->skelAnime, 11.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 3: + if (Animation_OnFrame(&this->skelAnime, 11.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 4: + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 10: + case 11: + func_800B9010(&this->actor, NA_SE_EN_YASE_LAUGH_K - SFX_FLAG); + break; + } + } +} + +void func_80BF656C(EnOsk* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + switch (this->unk_254) { + case 2: + func_80BF5E00(this, D_80BF6FB4, 1, 0.0f); + break; + + case 4: + func_80BF5E00(this, D_80BF6FB4, 3, 0.0f); + break; + + case 8: + func_80BF5E00(this, D_80BF6FB4, 7, -5.0f); + break; + + case 11: + func_80BF5E00(this, D_80BF6FB4, 10, -5.0f); + break; + + case 6: + func_80BF5E00(this, D_80BF6FB4, 5, -5.0f); + break; + } + } + + if (Cutscene_CheckActorAction(globalCtx, this->unk_258)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, this->unk_258)); + if (this->unk_256 != + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action) { + this->unk_256 = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action; + func_80BF6314(this); + } + func_80BF6478(this); + } else { + this->actor.draw = NULL; + } + + if ((this->unk_256 == 2) && (this->actor.scale.x < 13.0f * 0.001f)) { + this->actor.scale.x += 0.65f * 0.001f; + Actor_SetScale(&this->actor, this->actor.scale.x); + } + + if (this->unk_256 == 9) { + if (this->actor.scale.x > 0.65f * 0.001f) { + this->actor.scale.x -= 0.65f * 0.001f; + Actor_SetScale(&this->actor, this->actor.scale.x); + func_80BF5EBC(this, globalCtx); + func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } else { + this->actor.draw = NULL; + } + } +} + +void func_80BF67A8(EnOsk* this) { + if ((this->unk_256 != 1) && (this->unk_256 != 8)) { + this->actor.draw = EnOsk_Draw; + Actor_SetScale(&this->actor, 0.013f); + } + + switch (this->unk_256) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + func_80BF5E68(this, D_80BF6FE4, 2, -5.0f); + break; + + case 3: + func_80BF5E68(this, D_80BF6FE4, 8, -5.0f); + break; + + case 4: + func_80BF5E68(this, D_80BF6FE4, 4, -5.0f); + break; + + case 5: + func_80BF5E68(this, D_80BF6FE4, 6, -5.0f); + break; + + case 6: + func_80BF5E68(this, D_80BF6FE4, 10, -5.0f); + break; + + case 7: + case 8: + func_80BF5E00(this, D_80BF6FE4, 0, -5.0f); + break; + + case 9: + func_80BF5E68(this, D_80BF6FE4, 12, -5.0f); + break; + } +} + +void func_80BF68E0(EnOsk* this) { + if (this->actor.draw != NULL) { + switch (this->unk_254) { + case 1: + case 7: + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || + Animation_OnFrame(&this->skelAnime, 11.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 2: + if (Animation_OnFrame(&this->skelAnime, 4.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 4: + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 5: + if ((Animation_OnFrame(&this->skelAnime, 6.0f)) || Animation_OnFrame(&this->skelAnime, 11.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + + case 8: + if (Animation_OnFrame(&this->skelAnime, 13.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + } + } +} + +void func_80BF6A20(EnOsk* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + switch (this->unk_254) { + case 2: + func_80BF5E00(this, D_80BF6FE4, 1, -5.0f); + break; + + case 8: + func_80BF5E00(this, D_80BF6FE4, 7, -5.0f); + break; + + case 4: + func_80BF5E00(this, D_80BF6FE4, 3, -5.0f); + break; + + case 6: + func_80BF5E00(this, D_80BF6FE4, 5, -5.0f); + break; + + case 10: + func_80BF5E00(this, D_80BF6FE4, 9, -5.0f); + break; + + case 12: + func_80BF5E00(this, D_80BF6FE4, 11, -5.0f); + break; + } + } + + if (Cutscene_CheckActorAction(globalCtx, this->unk_258)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, this->unk_258)); + if (this->unk_256 != + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action) { + this->unk_256 = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action; + func_80BF67A8(this); + } + func_80BF68E0(this); + } else { + this->actor.draw = NULL; + } + + if (this->unk_256 == 8) { + if (this->actor.scale.x > 0.65f * 0.001f) { + this->actor.scale.x -= 0.65f * 0.001f; + Actor_SetScale(&this->actor, this->actor.scale.x); + func_80BF5EBC(this, globalCtx); + func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } else { + this->actor.draw = NULL; + } + } +} + +void EnOsk_Update(Actor* thisx, GlobalContext* globalCtx) { + EnOsk* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void func_80BF6C54(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnOsk* this = THIS; + + if (limbIndex == 1) { + Matrix_MultiplyVector3fByState(&D_80BF7024, &this->actor.focus.pos); + } +} + +void EnOsk_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnOsk* this = THIS; + Gfx* gfx; + Vec3f sp80; + s32 pad2[4]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_PrimColor(globalCtx->state.gfxCtx, 0x80, 255, 255, 255, 255)); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, func_80BF6C54, &this->actor); + + { + s16 sp62; + s16 sp60; + Vec3f sp54; + + sp54 = GET_ACTIVE_CAM(globalCtx)->eye; + + sp62 = Math_Vec3f_Yaw(&sp54, &this->actor.focus.pos); + sp60 = -Math_Vec3f_Pitch(&sp54, &this->actor.focus.pos); + + sp80.x = -(15.0f * (Math_SinS(sp62)) * Math_CosS(sp60)); + sp80.y = -(Math_SinS(sp60) * 15.0f); + sp80.z = -(15.0f * (Math_CosS(sp62)) * Math_CosS(sp60)); + + Matrix_InsertTranslation(this->actor.focus.pos.x + sp80.x, this->actor.focus.pos.y + sp80.y, + sp80.z = this->actor.focus.pos.z + sp80.z, MTXMODE_NEW); + + sp80.z = Math_SinS(globalCtx->gameplayFrames << 0xE); + sp80.z = ((sp80.z + 1.0f) * 0.1f) + 2.0f; + Matrix_Scale(this->actor.scale.x * sp80.z, this->actor.scale.y * sp80.z, this->actor.scale.z * sp80.z, + MTXMODE_APPLY); + } + + gfx = func_8012C868(POLY_XLU_DISP); + + gSPSetOtherMode(gfx++, G_SETOTHERMODE_H, 4, 4, 0x00000080); + if (1) {} + if (1) {} + if (1) {} + gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); + gSPDisplayList(gfx++, gameplay_keep_DL_029CB0); + gDPSetPrimColor(gfx++, 0, 0, 130, 0, 255, 100); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, gameplay_keep_DL_029CF0); + + POLY_XLU_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Osk/z_en_osk.h b/src/overlays/actors/ovl_En_Osk/z_en_osk.h index f98437897..9515e9705 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.h +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.h @@ -7,9 +7,20 @@ struct EnOsk; typedef void (*EnOskActionFunc)(struct EnOsk*, GlobalContext*); +#define ENOSK_GET_F(thisx) ((thisx)->params & 0xF) + +#define ENOSK_1 1 +#define ENOSK_2 2 + typedef struct EnOsk { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x11C]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[17]; + /* 0x01EE */ Vec3s morphTable[17]; + /* 0x0254 */ s16 unk_254; + /* 0x0256 */ s16 unk_256; + /* 0x0258 */ u16 unk_258; + /* 0x025C */ f32 unk_25C; /* 0x0260 */ EnOskActionFunc actionFunc; } EnOsk; // size = 0x264 diff --git a/undefined_syms.txt b/undefined_syms.txt index f05a115c6..54eb83c1b 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1624,15 +1624,6 @@ D_06003EE4 = 0x06003EE4; D_06004204 = 0x06004204; D_0600466C = 0x0600466C; -// ovl_En_Osk - -D_060000B8 = 0x060000B8; -D_060038F0 = 0x060038F0; -D_06006808 = 0x06006808; -D_06007B48 = 0x06007B48; -D_06009F00 = 0x06009F00; -D_0600B490 = 0x0600B490; - // ovl_En_Osn D_060192A0 = 0x060192A0; From f1560614d6671ecee1ea067349a06ea088536edf Mon Sep 17 00:00:00 2001 From: mzxrules Date: Thu, 10 Mar 2022 05:49:11 -0500 Subject: [PATCH 080/257] z_object_switch OK (#527) * z_obj_switch all functions attempted * z_obj_switch OK * Document z_obj_switch * update gameplay_dangeon_keep references * pr changes implemented * fix warnings * pr suggestions, name all functions --- .gitignore | 1 + assets/xml/objects/gameplay_dangeon_keep.xml | 36 +- spec | 4 +- .../actors/ovl_Obj_Switch/z_obj_switch.c | 1022 +++++++++++++++-- .../actors/ovl_Obj_Switch/z_obj_switch.h | 56 +- tools/disasm/functions.txt | 106 +- undefined_syms.txt | 3 - 7 files changed, 1056 insertions(+), 172 deletions(-) diff --git a/.gitignore b/.gitignore index aa4a3a5c4..a2acf29c3 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ tags # Project-specific ignores *.z64 +*.sra *.bin *.elf archive/ diff --git a/assets/xml/objects/gameplay_dangeon_keep.xml b/assets/xml/objects/gameplay_dangeon_keep.xml index 70f9d606b..f3ad6195a 100644 --- a/assets/xml/objects/gameplay_dangeon_keep.xml +++ b/assets/xml/objects/gameplay_dangeon_keep.xml @@ -14,20 +14,20 @@ - - + + - - + + - - - - - - - + + + + + + + @@ -59,15 +59,15 @@ - + - + - - - - - + + + + + diff --git a/spec b/spec index 164776201..f719cb5a1 100644 --- a/spec +++ b/spec @@ -1504,9 +1504,7 @@ beginseg name "ovl_Obj_Switch" compress include "build/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.o" - include "build/data/ovl_Obj_Switch/ovl_Obj_Switch.data.o" - include "build/data/ovl_Obj_Switch/ovl_Obj_Switch.bss.o" - include "build/data/ovl_Obj_Switch/ovl_Obj_Switch.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Switch/ovl_Obj_Switch_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c index 4a69fc1eb..7bea97826 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -5,17 +5,71 @@ */ #include "z_obj_switch.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjSwitch*)thisx) +#define COS_OF_5_PI_DIV_8 -0.38268343f + void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx); void ObjSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSwitch_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSwitch_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void ObjSwitch_FloorSwitchUpInit(ObjSwitch* this); +void ObjSwitch_FloorSwitchPushDownInit(ObjSwitch* this); +void ObjSwitch_FloorSwitchDownInit(ObjSwitch* this); +void ObjSwitch_FloorSwitchRiseUpInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchFrozenInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchOpenInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchClosingInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchClosedInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchOpeningInit(ObjSwitch* this); +void ObjSwitch_CrystalSwitchOffInit(ObjSwitch* this); +void ObjSwitch_CrystalSwitchTurnOnInit(ObjSwitch* this); +void ObjSwitch_CrystalSwitchOnInit(ObjSwitch* this); +void ObjSwitch_CrystalSwitchTurnOffInit(ObjSwitch* this); +void ObjSwitch_LargeFloorSwitchUpInit(ObjSwitch* this); +void ObjSwitch_LargeFloorSwitchPushDownInit(ObjSwitch* this); +void ObjSwitch_LargeFloorSwitchDownInit(ObjSwitch* this); +void ObjSwitch_LargeFloorSwitchRiseUpInit(ObjSwitch* this); + +void ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_TryPlayCutscene(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_FloorSwitchUp(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_FloorSwitchPushDown(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_FloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_FloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchUnfrozen(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchOpen(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchClosing(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchClosed(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchOpening(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_CrystalSwitchOff(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_CrystalSwitchTurnOn(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_CrystalSwitchOn(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_CrystalSwitchTurnOff(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_LargeFloorSwitchUp(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_LargeFloorSwitchPushDown(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_LargeFloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_LargeFloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx); + +void ObjSwitch_DrawFloorSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawRustyFloorSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawVisibleEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawInvisibleEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawCrystalSwitch(ObjSwitch* this, GlobalContext* globalCtx); + +static TexturePtr sEyeSwitchTextures[][4] = { + { gEyeSwitchGoldOpenTex, gEyeSwitchGoldOpeningTex, gEyeSwitchGoldClosingTex, gEyeSwitchGoldClosedTex }, + { gEyeSwitchSilverOpenTex, gEyeSwitchSilverHalfTex, gEyeSwitchSilverClosedTex, gEyeSwitchSilverClosedTex }, +}; + +static s32 sIsSegmentTableInit = false; + const ActorInit Obj_Switch_InitVars = { ACTOR_OBJ_SWITCH, ACTORCAT_SWITCH, @@ -28,183 +82,969 @@ const ActorInit Obj_Switch_InitVars = { (ActorFunc)ObjSwitch_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_8093CCD4[2] = { +static f32 sHeights[] = { 10.0f, 10.0f, 0.0f, 30.0f, 30.0f, 15.0f }; + +static f32 sScale[] = { 0.123f, 0.123f, 0.1f, 0.118f, 0.118f, 0.248f }; + +static ColliderTrisElementInit sRustyFloorTrisElementsInit[2] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000400, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000400, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -20.0f, 19.0f, -20.0f }, { -20.0f, 19.0f, 20.0f }, { 20.0f, 19.0f, 20.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000400, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000400, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 20.0f, 19.0f, 20.0f }, { 20.0f, 19.0f, -20.0f }, { -20.0f, 19.0f, -20.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_8093CD4C = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 2, D_8093CCD4, // sTrisElementsInit, +static ColliderTrisInit sRustyFloorTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + ARRAY_COUNT(sRustyFloorTrisElementsInit), + sRustyFloorTrisElementsInit, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_8093CD5C[2] = { +static ColliderTrisElementInit sEyeSwitchTrisElementsInit[2] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00003820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00003820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, 23.0f, 8.5f }, { -23.0f, 0.0f, 8.5f }, { 0.0f, -23.0f, 8.5f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00003820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00003820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, 23.0f, 8.5f }, { 0.0f, -23.0f, 8.5f }, { 23.0f, 0.0f, 8.5f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_8093CDD4 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 2, D_8093CD5C, // sTrisElementsInit, +static ColliderTrisInit sEyeSwitchTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + ARRAY_COUNT(sEyeSwitchTrisElementsInit), + sEyeSwitchTrisElementsInit, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8093CDE4[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x01CBFFBE, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x01CBFFBE, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 300, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8093CE08 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, D_8093CDE4, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8093CE18[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -#endif +static Color_RGB8 sSakonHideoutColor[2] = { { 250, 90, 60 }, { 255, 255, 255 } }; -extern ColliderTrisElementInit D_8093CCD4[2]; -extern ColliderTrisInit D_8093CD4C; -extern ColliderTrisElementInit D_8093CD5C[2]; -extern ColliderTrisInit D_8093CDD4; -extern ColliderJntSphElementInit D_8093CDE4[1]; -extern ColliderJntSphInit D_8093CE08; -extern InitChainEntry D_8093CE18[]; +static Gfx* sFloorSwitchDL[] = { gFloorSwitch1DL, gFloorSwitch3DL, gFloorSwitch2DL, gFloorSwitch2DL, gFloorSwitch1DL }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093ABD0.s") +static Gfx* sEyeSwitchDL[] = { gEyeSwitchGoldDL, gEyeSwitchSilverDL }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AC6C.s") +static AnimatedMaterial* sCrystalSwitchAnimatedMat; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093ADA8.s") +void ObjSwitch_InitJntSphCollider(ObjSwitch* this, GlobalContext* globalCtx, ColliderJntSphInit* init) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AE1C.s") + Collider_InitJntSph(globalCtx, &this->colliderJntSph); + Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->dyna.actor, init, this->colliderJntSphElements); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y + + (this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y), + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); + Collider_UpdateSpheres(0, &this->colliderJntSph); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AE74.s") +void ObjSwitch_InitTrisCollider(ObjSwitch* this, GlobalContext* globalCtx, ColliderTrisInit* init) { + s32 pad; + s32 i; + s32 j; + Vec3f vtx[3]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AE88.s") + Collider_InitTris(globalCtx, &this->colliderTris); + Collider_SetTris(globalCtx, &this->colliderTris, &this->dyna.actor, init, this->colliderTrisElements); + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y + + this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AEC4.s") + for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { + if (this) {} + for (j = 0; j < ARRAY_COUNT(vtx); j++) { + Matrix_MultiplyVector3fByState(&init->elements[i].dim.vtx[j], &vtx[j]); + } + Collider_SetTrisVertices(&this->colliderTris, i, &vtx[0], &vtx[1], &vtx[2]); + } + Matrix_StatePop(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AEF0.s") +Actor* ObjSwitch_SpawnIce(ObjSwitch* this, GlobalContext* globalCtx) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_OBJ_ICE_POLY, + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 25.0f, this->dyna.actor.world.pos.z, + this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, this->dyna.actor.world.rot.z, + 0xFF32); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AF1C.s") +void ObjSwitch_SetSwitchFlagState(ObjSwitch* this, GlobalContext* globalCtx, s32 setFlag) { + if (setFlag) { + s32 flag = OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AF54.s") + Flags_SetSwitch(globalCtx, flag); + } else { + s32 flag = OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/ObjSwitch_Init.s") + Flags_UnsetSwitch(globalCtx, flag); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/ObjSwitch_Destroy.s") +void ObjSwitch_CrystalUpdateTimer(ObjSwitch* this) { + this->crystalAnimTimer++; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B648.s") +void ObjSwitch_StopCutscene(ObjSwitch* this) { + if (this->isPlayingCutscene) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->isPlayingCutscene = false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B668.s") +void ObjSwitch_PlayFootSwitchSfx(ObjSwitch* this) { + if (this->sfxTimer <= 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FOOT_SWITCH); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B6F4.s") +void ObjSwitch_PlayDiamondSwitchSfx(ObjSwitch* this) { + if (this->sfxTimer <= 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DIAMOND_SWITCH); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B710.s") +void ObjSwitch_SetFloorSwitchSnapPlayerState(ObjSwitch* this, s32 state) { + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + this->floorSwitchPlayerSnapState = state; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B92C.s") +void ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; + Player* player; + f32 centerDisplacement; + s16 yaw; + f32 cos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B940.s") + if (globalCtx->actorCtx.unk5 & 0x80) { + player = GET_PLAYER(globalCtx); + // compute yawTowardsPlayer relative to model space + yaw = BINANG_SUB(this->dyna.actor.yawTowardsPlayer, this->dyna.actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B9C0.s") + // clamps yaw to the range -45 to 45 degrees, such that 0 degrees follows along the apothem + yaw += 0x2000; + yaw &= 0x3FFF; + yaw -= 0x2000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B9E4.s") + // set centerDisplacement to the length of the apothem for the floor switch square + // only OBJSWITCH_TYPE_FLOOR and OBJSWITCH_TYPE_FLOOR_LARGE are supported + centerDisplacement = OBJ_SWITCH_GET_TYPE(&this->dyna.actor) == OBJSWITCH_TYPE_FLOOR ? 24.0f : 48.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BB5C.s") + cos = Math_CosS(yaw); + if (fabsf(cos) > 0.01f) { + // compute how far to displace the player so that the player is touching an edge + centerDisplacement /= cos; + // if the player is already inside the square, don't move them + if (centerDisplacement < this->dyna.actor.xzDistToPlayer) { + player->actor.world.pos.x = + Math_SinS(this->dyna.actor.yawTowardsPlayer) * centerDisplacement + this->dyna.actor.world.pos.x; + player->actor.world.pos.z = + Math_CosS(this->dyna.actor.yawTowardsPlayer) * centerDisplacement + this->dyna.actor.world.pos.z; + } + player->linearVelocity = 0.0f; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BB70.s") +void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + s32 type; + u32 isSwitchFlagSet; + ObjSwitch* this = THIS; + s32 pad2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BBD0.s") + isSwitchFlagSet = Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor)); + type = OBJ_SWITCH_GET_TYPE(&this->dyna.actor); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_SetScale(&this->dyna.actor, sScale[type]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BCC8.s") + if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY || type == OBJSWITCH_TYPE_FLOOR_LARGE) { + if (type == OBJSWITCH_TYPE_FLOOR_LARGE) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 1.9f; + } else { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 1.0f; + } + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gFloorSwitchCol); + } + if (type == OBJSWITCH_TYPE_FLOOR) { + if (globalCtx->sceneNum == SCENE_SECOM) { + this->floorSwitchUpScale = 33.0f / 200.0f / 3.0f; + this->floorSwitchDownScale = 33.0f / 2000.0f / 3.0f; + } else { + this->floorSwitchUpScale = 33.0f / 200.0f; + this->floorSwitchDownScale = 33.0f / 2000.0f; + } + } + if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_LARGE) { + if (globalCtx->sceneNum == SCENE_SECOM) { + Color_RGB8* color = &sSakonHideoutColor[OBJ_SWITCH_GET_COLOR_ID(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BCDC.s") + this->color.r = color->r; + this->color.g = color->g; + this->color.b = color->b; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.world.rot.z = 0; + } else { + this->color.r = 255; + this->color.g = 255; + this->color.b = 255; + } + } + Actor_SetFocus(&this->dyna.actor, sHeights[type]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BD34.s") + if (type == OBJSWITCH_TYPE_FLOOR_RUSTY) { + ObjSwitch_InitTrisCollider(this, globalCtx, &sRustyFloorTrisInit); + } else if (type == OBJSWITCH_TYPE_EYE) { + ObjSwitch_InitTrisCollider(this, globalCtx, &sEyeSwitchTrisInit); + } else if (type == OBJSWITCH_TYPE_CRYSTAL || type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { + ObjSwitch_InitJntSphCollider(this, globalCtx, &sJntSphInit); + } + if (type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { + this->dyna.actor.targetMode = 4; + this->dyna.actor.flags |= 1; + } + this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + if (OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { + if (ObjSwitch_SpawnIce(this, globalCtx) == NULL) { + OBJ_SWITCH_UNSET_FROZEN(&this->dyna.actor); + } + this->sfxTimer = 0; + } else { + this->sfxTimer = 10; + } + if (OBJ_SWITCH_IS_INVISIBLE(&this->dyna.actor)) { + this->dyna.actor.flags |= 0x80; + } + if (type == OBJSWITCH_TYPE_EYE) { + if (sIsSegmentTableInit == false) { + s32 i, j; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BD4C.s") + sIsSegmentTableInit = true; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BDAC.s") + for (i = 0; i < ARRAY_COUNT(sEyeSwitchTextures); i++) { + for (j = 0; j < ARRAY_COUNT(*sEyeSwitchTextures); j++) { + sEyeSwitchTextures[i][j] = Lib_SegmentedToVirtual(sEyeSwitchTextures[i][j]); + } + } + } + } + if (type == OBJSWITCH_TYPE_CRYSTAL) { + sCrystalSwitchAnimatedMat = Lib_SegmentedToVirtual(&gCrystalSwitchAnimatedMat); + } + if (OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { + ObjSwitch_EyeSwitchFrozenInit(this); + } else if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY) { + if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_RESET_INVERTED) { + if (isSwitchFlagSet) { + ObjSwitch_FloorSwitchUpInit(this); + } else { + ObjSwitch_FloorSwitchDownInit(this); + } + } else { + if (isSwitchFlagSet) { + ObjSwitch_FloorSwitchDownInit(this); + } else { + ObjSwitch_FloorSwitchUpInit(this); + } + } + } else if (type == OBJSWITCH_TYPE_EYE) { + if (isSwitchFlagSet) { + ObjSwitch_EyeSwitchClosedInit(this); + } else { + ObjSwitch_EyeSwitchOpenInit(this); + } + } else if (type == OBJSWITCH_TYPE_CRYSTAL || type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { + if (isSwitchFlagSet) { + ObjSwitch_CrystalSwitchOnInit(this); + } else { + ObjSwitch_CrystalSwitchOffInit(this); + } + } else if (type == OBJSWITCH_TYPE_FLOOR_LARGE) { + if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_RESET_INVERTED) { + if (isSwitchFlagSet) { + ObjSwitch_LargeFloorSwitchUpInit(this); + } else { + ObjSwitch_LargeFloorSwitchDownInit(this); + } + } else { + if (isSwitchFlagSet) { + ObjSwitch_LargeFloorSwitchDownInit(this); + } else { + ObjSwitch_LargeFloorSwitchUpInit(this); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BDC0.s") +void ObjSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSwitch* this = THIS; + s32 type = OBJ_SWITCH_GET_TYPE(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BE10.s") + if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY || type == OBJSWITCH_TYPE_FLOOR_LARGE) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } + switch (type) { + case OBJSWITCH_TYPE_FLOOR_RUSTY: + case OBJSWITCH_TYPE_EYE: + Collider_DestroyTris(globalCtx, &this->colliderTris); + break; + case OBJSWITCH_TYPE_CRYSTAL: + case OBJSWITCH_TYPE_CRYSTAL_TARGETABLE: + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BE2C.s") +void ObjSwitch_TryPlayCutsceneInit(ObjSwitch* this, GlobalContext* globalCtx, ObjSwitchSetupActionFunc actionFunc, + s32 nextSwitchFlagState) { + this->setupFunc = actionFunc; + this->nextSwitchFlagState = nextSwitchFlagState; + this->actionFunc = ObjSwitch_TryPlayCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BEF0.s") +void ObjSwitch_TryPlayCutscene(ObjSwitch* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + ObjSwitch_SetSwitchFlagState(this, globalCtx, this->nextSwitchFlagState); + if (this->floorSwitchPlayerSnapState == 1) { + this->floorSwitchPlayerSnapState = 2; + } + this->isPlayingCutscene = true; + this->setupFunc(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BF04.s") +void ObjSwitch_FloorSwitchUpInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_FloorSwitchUp; + this->dyna.actor.scale.y = this->floorSwitchUpScale; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BF50.s") +void ObjSwitch_FloorSwitchUp(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BF70.s") + if (OBJ_SWITCH_GET_TYPE(&this->dyna.actor) == OBJSWITCH_TYPE_FLOOR_RUSTY) { + if (this->colliderTris.base.acFlags & AC_HIT) { + this->colliderTris.base.acFlags &= ~AT_HIT; + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, true); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + } + } else { + switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { + case OBJSWITCH_SUBTYPE_ONCE: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, true); + } + break; + case OBJSWITCH_SUBTYPE_SYNC: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, true); + } else if (Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + ObjSwitch_FloorSwitchPushDownInit(this); + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + s32 isSwitchFlagNotSet = + Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor)) ? false : true; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C0A4.s") + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, + isSwitchFlagNotSet); + } + break; + case OBJSWITCH_SUBTYPE_RESET: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, true); + } + break; + case OBJSWITCH_SUBTYPE_RESET_INVERTED: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 2); + ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_FloorSwitchPushDownInit(this); + } + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C0B8.s") +void ObjSwitch_FloorSwitchPushDownInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_FloorSwitchPushDown; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C138.s") +void ObjSwitch_FloorSwitchPushDown(ObjSwitch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y -= 0.0495f; + if (this->dyna.actor.scale.y <= this->floorSwitchDownScale) { + ObjSwitch_PlayFootSwitchSfx(this); + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + ObjSwitch_StopCutscene(this); + ObjSwitch_FloorSwitchDownInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C15C.s") +void ObjSwitch_FloorSwitchDownInit(ObjSwitch* this) { + this->floorSwitchReleaseTimer = 6; + this->actionFunc = ObjSwitch_FloorSwitchDown; + this->dyna.actor.scale.y = this->floorSwitchDownScale; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C23C.s") +void ObjSwitch_FloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; + u32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C250.s") + switch (subType) { + case OBJSWITCH_SUBTYPE_ONCE: + case OBJSWITCH_SUBTYPE_SYNC: + if (!Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + if (globalCtx->sceneNum == SCENE_SECOM && DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetSwitchFlagState(this, globalCtx, true); + } else { + ObjSwitch_FloorSwitchRiseUpInit(this); + } + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + case OBJSWITCH_SUBTYPE_RESET: + case OBJSWITCH_SUBTYPE_RESET_INVERTED: + if (!DynaPolyActor_IsInSwitchPressedState(&this->dyna) && + (Player_InCsMode(&globalCtx->state) == 0 || globalCtx->sceneNum == SCENE_SECOM)) { + if (this->floorSwitchReleaseTimer <= 0) { + if (subType == OBJSWITCH_SUBTYPE_RESET) { + ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_FloorSwitchRiseUpInit(this); + } else if (subType == OBJSWITCH_SUBTYPE_RESET_INVERTED) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchRiseUpInit, true); + } else { + ObjSwitch_FloorSwitchRiseUpInit(this); + } + } + } else { + if (globalCtx->sceneNum == SCENE_SECOM) { + this->floorSwitchReleaseTimer = 2; + } else { + this->floorSwitchReleaseTimer = 6; + } + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C2B4.s") +void ObjSwitch_FloorSwitchRiseUpInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_FloorSwitchRiseUp; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C2D4.s") +void ObjSwitch_FloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y += 0.0495f; + if (this->floorSwitchUpScale <= this->dyna.actor.scale.y) { + ObjSwitch_PlayFootSwitchSfx(this); + ObjSwitch_StopCutscene(this); + ObjSwitch_FloorSwitchUpInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C3C8.s") +s32 ObjSwitch_IsEyeSwitchHit(ObjSwitch* this) { + Actor* acActor; + Actor* actor = &this->dyna.actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C3DC.s") + if ((this->colliderTris.base.acFlags & AC_HIT) && !(this->collisionFlags & AC_HIT)) { + acActor = this->colliderTris.base.ac; + if (acActor != NULL) { + Vec3f sp2C; + Vec3f sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C460.s") + Matrix_StatePush(); + Matrix_RotateY(acActor->world.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(acActor->world.rot.x, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(1.0f, &sp2C); + Matrix_RotateY(actor->shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(1.0f, &sp20); + Matrix_StatePop(); + if ((Math3D_Parallel(&sp2C, &sp20) < COS_OF_5_PI_DIV_8)) { + return true; + } + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C488.s") +void ObjSwitch_EyeSwitchFrozenInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchUnfrozen; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C584.s") +void ObjSwitch_EyeSwitchUnfrozen(ObjSwitch* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + ObjSwitch_EyeSwitchClosedInit(this); + } else { + ObjSwitch_EyeSwitchOpenInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C598.s") +void ObjSwitch_EyeSwitchOpenInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchOpen; + this->eyeTexIndex = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/ObjSwitch_Update.s") +void ObjSwitch_EyeSwitchOpen(ObjSwitch* this, GlobalContext* globalCtx) { + if (ObjSwitch_IsEyeSwitchHit(this) || OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { + OBJ_SWITCH_UNSET_FROZEN(&this->dyna.actor); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_EyeSwitchClosingInit, true); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C778.s") +void ObjSwitch_EyeSwitchClosingInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchClosing; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C888.s") +void ObjSwitch_EyeSwitchClosing(ObjSwitch* this, GlobalContext* globalCtx) { + this->eyeTexIndex++; + if (this->eyeTexIndex >= 3) { + ObjSwitch_StopCutscene(this); + ObjSwitch_PlayFootSwitchSfx(this); + ObjSwitch_EyeSwitchClosedInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C8B8.s") +void ObjSwitch_EyeSwitchClosedInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchClosed; + this->eyeTexIndex = 3; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C99C.s") +void ObjSwitch_EyeSwitchClosed(ObjSwitch* this, GlobalContext* globalCtx) { + switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { + case OBJSWITCH_SUBTYPE_ONCE: + if (!Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + OBJ_SWITCH_UNSET_FROZEN(&this->dyna.actor); + ObjSwitch_EyeSwitchOpeningInit(this); + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + if (ObjSwitch_IsEyeSwitchHit(this) || OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { + OBJ_SWITCH_UNSET_FROZEN(&this->dyna.actor); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_EyeSwitchOpeningInit, false); + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093CA80.s") +void ObjSwitch_EyeSwitchOpeningInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchOpening; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093CAC4.s") +void ObjSwitch_EyeSwitchOpening(ObjSwitch* this, GlobalContext* globalCtx) { + this->eyeTexIndex--; + if (this->eyeTexIndex <= 0) { + ObjSwitch_StopCutscene(this); + ObjSwitch_PlayFootSwitchSfx(this); + ObjSwitch_EyeSwitchOpenInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/ObjSwitch_Draw.s") +void ObjSwitch_CrystalSwitchOffInit(ObjSwitch* this) { + this->color.r = 0; + this->color.g = 0; + this->color.b = 0; + this->actionFunc = ObjSwitch_CrystalSwitchOff; +} + +void ObjSwitch_CrystalSwitchOff(ObjSwitch* this, GlobalContext* globalCtx) { + s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; + s32 canActivate = switchHit && !(this->collisionFlags & AC_HIT) && (this->disableCrystalSwitchTimer <= 0); + + if (switchHit) { + this->disableCrystalSwitchTimer = 10; + } + switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { + case OBJSWITCH_SUBTYPE_ONCE: + if (canActivate) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_CrystalSwitchTurnOnInit, true); + } + break; + case OBJSWITCH_SUBTYPE_SYNC: + if (canActivate) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_CrystalSwitchTurnOnInit, true); + + } else if (Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + this->disableCrystalSwitchTimer = 10; + ObjSwitch_CrystalSwitchTurnOnInit(this); + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + if (canActivate) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_CrystalSwitchTurnOnInit, true); + } + ObjSwitch_CrystalUpdateTimer(this); + break; + } +} + +void ObjSwitch_CrystalSwitchTurnOnInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_CrystalSwitchTurnOn; +} + +void ObjSwitch_CrystalSwitchTurnOn(ObjSwitch* this, GlobalContext* globalCtx) { + s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + if (switchHit) { + this->disableCrystalSwitchTimer = 10; + } + ObjSwitch_StopCutscene(this); + if (subType == OBJSWITCH_SUBTYPE_TOGGLE) { + ObjSwitch_CrystalUpdateTimer(this); + } + ObjSwitch_PlayDiamondSwitchSfx(this); + ObjSwitch_CrystalSwitchOnInit(this); +} + +void ObjSwitch_CrystalSwitchOnInit(ObjSwitch* this) { + this->color.r = 255; + this->color.g = 255; + this->color.b = 255; + this->actionFunc = ObjSwitch_CrystalSwitchOn; +} + +void ObjSwitch_CrystalSwitchOn(ObjSwitch* this, GlobalContext* globalCtx) { + s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; + s32 canActivate = switchHit && !(this->collisionFlags & AC_HIT) && (this->disableCrystalSwitchTimer <= 0); + + if (switchHit) { + this->disableCrystalSwitchTimer = 10; + } + switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { + case OBJSWITCH_SUBTYPE_ONCE: + case OBJSWITCH_SUBTYPE_SYNC: + if (!Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + this->disableCrystalSwitchTimer = 10; + ObjSwitch_CrystalSwitchTurnOffInit(this); + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + if (canActivate) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_CrystalSwitchTurnOffInit, false); + } + } + ObjSwitch_CrystalUpdateTimer(this); +} + +void ObjSwitch_CrystalSwitchTurnOffInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_CrystalSwitchTurnOff; +} + +void ObjSwitch_CrystalSwitchTurnOff(ObjSwitch* this, GlobalContext* globalCtx) { + s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; + + if (switchHit) { + this->disableCrystalSwitchTimer = 10; + } + ObjSwitch_StopCutscene(this); + ObjSwitch_CrystalUpdateTimer(this); + ObjSwitch_PlayDiamondSwitchSfx(this); + ObjSwitch_CrystalSwitchOffInit(this); +} + +void ObjSwitch_LargeFloorSwitchUpInit(ObjSwitch* this) { + this->dyna.actor.scale.y = 0.2475f; + this->actionFunc = ObjSwitch_LargeFloorSwitchUp; +} + +void ObjSwitch_LargeFloorSwitchUp(ObjSwitch* this, GlobalContext* globalCtx) { + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + if (subType == OBJSWITCH_SUBTYPE_ONCE) { + if (DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_LargeFloorSwitchPushDownInit, true); + } + } else if (subType == OBJSWITCH_SUBTYPE_RESET) { + if (DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_LargeFloorSwitchPushDownInit, true); + } + } else if (subType == OBJSWITCH_SUBTYPE_RESET_INVERTED && DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 2); + ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_LargeFloorSwitchPushDownInit(this); + } +} + +void ObjSwitch_LargeFloorSwitchPushDownInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_LargeFloorSwitchPushDown; +} + +void ObjSwitch_LargeFloorSwitchPushDown(ObjSwitch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y -= 0.074250005f; + if (this->dyna.actor.scale.y <= 33.0f / 2000.0f) { + ObjSwitch_PlayFootSwitchSfx(this); + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + ObjSwitch_StopCutscene(this); + ObjSwitch_LargeFloorSwitchDownInit(this); + } +} + +void ObjSwitch_LargeFloorSwitchDownInit(ObjSwitch* this) { + this->dyna.actor.scale.y = 33.0f / 2000.0f; + this->floorSwitchReleaseTimer = 6; + this->actionFunc = ObjSwitch_LargeFloorSwitchDown; +} + +void ObjSwitch_LargeFloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx) { + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + if (subType == OBJSWITCH_SUBTYPE_ONCE) { + if (!Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + ObjSwitch_LargeFloorSwitchRiseUpInit(this); + } + } else if (subType == OBJSWITCH_SUBTYPE_RESET || subType == OBJSWITCH_SUBTYPE_RESET_INVERTED) { + if (!DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna) && !Player_InCsMode(&globalCtx->state)) { + if (this->floorSwitchReleaseTimer <= 0) { + if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_RESET) { + ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_LargeFloorSwitchRiseUpInit(this); + } else { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_LargeFloorSwitchRiseUpInit, true); + } + } + } else { + this->floorSwitchReleaseTimer = 6; + } + } +} + +void ObjSwitch_LargeFloorSwitchRiseUpInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_LargeFloorSwitchRiseUp; +} + +void ObjSwitch_LargeFloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y += 0.074250005f; + if (this->dyna.actor.scale.y >= 0.2475f) { + ObjSwitch_PlayFootSwitchSfx(this); + ObjSwitch_StopCutscene(this); + ObjSwitch_LargeFloorSwitchUpInit(this); + } +} + +void ObjSwitch_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSwitch* this = THIS; + + if (this->floorSwitchReleaseTimer > 0) { + this->floorSwitchReleaseTimer--; + } + if (this->sfxTimer > 0) { + this->sfxTimer--; + } + this->actionFunc(this, globalCtx); + if (this->floorSwitchPlayerSnapState != 0) { + s32 pad; + + dummy: + ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge(this, globalCtx); + if (this->floorSwitchPlayerSnapState == 2) { + this->floorSwitchPlayerSnapState = 0; + } + } + switch (OBJ_SWITCH_GET_TYPE(&this->dyna.actor)) { + case OBJSWITCH_TYPE_FLOOR: + case OBJSWITCH_TYPE_FLOOR_RUSTY: + case OBJSWITCH_TYPE_FLOOR_LARGE: + this->collisionFlags = this->dyna.stateFlags; + break; + case OBJSWITCH_TYPE_EYE: + this->collisionFlags = this->colliderTris.base.acFlags; + this->colliderTris.base.acFlags &= ~AC_HIT; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + break; + case OBJSWITCH_TYPE_CRYSTAL: + case OBJSWITCH_TYPE_CRYSTAL_TARGETABLE: + if (!Player_InCsMode(&globalCtx->state)) { + if (this->disableCrystalSwitchTimer > 0) { + this->disableCrystalSwitchTimer--; + } + } + if (this->disableCrystalSwitchTimer == 0) { + this->colliderJntSph.base.colType = sJntSphInit.base.colType; + } else { + this->colliderJntSph.base.colType = COLTYPE_NONE; + } + this->collisionFlags = this->colliderJntSph.base.acFlags; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + } +} + +void ObjSwitch_DrawFloorSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad[2]; + + if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_ONCE) { + Gfx* opa; + + OPEN_DISPS(globalCtx->state.gfxCtx); + opa = POLY_OPA_DISP; + gSPDisplayList(opa++, &sSetupDL[6 * 25]); + gSPMatrix(opa++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(opa++, 0, 0x80, this->color.r, this->color.g, this->color.b, 255); + gSPDisplayList(opa++, gFloorSwitch1DL); + POLY_OPA_DISP = opa; + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + Gfx_DrawDListOpa(globalCtx, sFloorSwitchDL[OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)]); + } +} + +void ObjSwitch_DrawRustyFloorSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gRustyFloorSwitchDL); +} + +void ObjSwitch_DrawVisibleEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, sEyeSwitchTextures[subType][this->eyeTexIndex]); + gSPDisplayList(POLY_OPA_DISP++, sEyeSwitchDL[subType]); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjSwitch_DrawInvisibleEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, sEyeSwitchTextures[subType][this->eyeTexIndex]); + gSPDisplayList(POLY_XLU_DISP++, sEyeSwitchDL[subType]); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjSwitch_DrawEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + if (OBJ_SWITCH_IS_INVISIBLE(&this->dyna.actor)) { + ObjSwitch_DrawInvisibleEyeSwitch(this, globalCtx); + } else { + ObjSwitch_DrawVisibleEyeSwitch(this, globalCtx); + } +} + +void ObjSwitch_DrawCrystalSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad[2]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_800B8118(&this->dyna.actor, globalCtx, 0); + AnimatedMat_DrawStep(globalCtx, sCrystalSwitchAnimatedMat, this->crystalAnimTimer); + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gCrystalSwitchBaseDL); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, this->color.r, this->color.g, this->color.b, 255); + gSPDisplayList(POLY_OPA_DISP++, gCrystalSwitchCoreDL); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCrystalSwitchDiamondDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjSwitch_Draw(Actor* thisx, GlobalContext* globalCtx) { + static ObjSwitchDrawFunc drawFunc[] = { + ObjSwitch_DrawFloorSwitch, ObjSwitch_DrawRustyFloorSwitch, ObjSwitch_DrawEyeSwitch, + ObjSwitch_DrawCrystalSwitch, ObjSwitch_DrawCrystalSwitch, ObjSwitch_DrawFloorSwitch, + }; + ObjSwitch* this = THIS; + + drawFunc[OBJ_SWITCH_GET_TYPE(&this->dyna.actor)](this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h index 5d1134f12..42ee4207f 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h @@ -5,7 +5,26 @@ struct ObjSwitch; -typedef void (*ObjSwitchActionFunc)(struct ObjSwitch*, GlobalContext*); +typedef void (*ObjSwitchActionFunc)(struct ObjSwitch* this, GlobalContext* globalCtx); +typedef void (*ObjSwitchDrawFunc)(struct ObjSwitch* this, GlobalContext* globalCtx); +typedef void (*ObjSwitchSetupActionFunc)(struct ObjSwitch* this); + +typedef enum { + /* 0 */ OBJSWITCH_TYPE_FLOOR, + /* 1 */ OBJSWITCH_TYPE_FLOOR_RUSTY, // Unused, incomplete implementation + /* 2 */ OBJSWITCH_TYPE_EYE, + /* 3 */ OBJSWITCH_TYPE_CRYSTAL, + /* 4 */ OBJSWITCH_TYPE_CRYSTAL_TARGETABLE, + /* 5 */ OBJSWITCH_TYPE_FLOOR_LARGE +} ObjSwitchType; + +typedef enum { + /* 0 */ OBJSWITCH_SUBTYPE_ONCE, // Set Switch Flag when activated, stays activated + /* 1 */ OBJSWITCH_SUBTYPE_TOGGLE, // Toggle Switch Flag when activated + /* 2 */ OBJSWITCH_SUBTYPE_RESET, // Floor type only, set switch flag when pressed, unset when released + /* 3 */ OBJSWITCH_SUBTYPE_RESET_INVERTED, // Floor type only, set switch flag when not pressed, unset when pressed + /* 4 */ OBJSWITCH_SUBTYPE_SYNC // Crystal type only, syncronizes all crystal fl +} ObjSwitchSubType; #define OBJSWITCH_GET_33(thisx) ((thisx)->params & 0x33) #define OBJSWITCH_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) @@ -14,12 +33,41 @@ typedef void (*ObjSwitchActionFunc)(struct ObjSwitch*, GlobalContext*); #define OBJSWITCH_INVERSE_BLUE 0x30 typedef struct ObjSwitch { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjSwitchActionFunc actionFunc; - /* 0x0160 */ char unk_160[0xF8]; + /* 0x0160 */ s16 floorSwitchReleaseTimer; + /* 0x0162 */ s16 disableCrystalSwitchTimer; + /* 0x0164 */ s8 eyeTexIndex; + /* 0x0165 */ s8 sfxTimer; + /* 0x0168 */ s32 crystalAnimTimer; + /* 0x016C */ Color_RGB8 color; + /* 0x016F */ u8 collisionFlags; + /* 0x0170 */ s8 floorSwitchPlayerSnapState; + /* 0x0171 */ s8 nextSwitchFlagState; + /* 0x0172 */ s8 isPlayingCutscene; + /* 0x0174 */ ObjSwitchSetupActionFunc setupFunc; + union { + struct { + /* 0x0178 */ ColliderJntSph colliderJntSph; + /* 0x0198 */ ColliderJntSphElement colliderJntSphElements[1]; + }; + struct { + /* 0x0178 */ ColliderTris colliderTris; + /* 0x0198 */ ColliderTrisElement colliderTrisElements[2]; + }; + }; + /* 0x0250 */ f32 floorSwitchUpScale; + /* 0x0254 */ f32 floorSwitchDownScale; } ObjSwitch; // size = 0x258 extern const ActorInit Obj_Switch_InitVars; +#define OBJ_SWITCH_GET_TYPE(thisx) ((thisx)->params&7) +#define OBJ_SWITCH_GET_SUBTYPE(thisx) ((thisx)->params >> 4 & 7) +#define OBJ_SWITCH_GET_SWITCH_FLAG(thisx) ((thisx)->params >> 8 & 0x7F) +#define OBJ_SWITCH_IS_FROZEN(thisx) ((thisx)->params >> 7 & 1) +#define OBJ_SWITCH_UNSET_FROZEN(thisx) ((thisx)->params &= ~(1 << 7)) +#define OBJ_SWITCH_IS_INVISIBLE(thisx) ((thisx)->params >> 3 & 1) +#define OBJ_SWITCH_GET_COLOR_ID(thisx) ((thisx)->home.rot.z&1) + #endif // Z_OBJ_SWITCH_H diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 0205a8338..4923739ed 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -7361,62 +7361,62 @@ 0x8093A3F4:("ObjBombiwa_Update",), 0x8093A418:("func_8093A418",), 0x8093A608:("func_8093A608",), - 0x8093ABD0:("func_8093ABD0",), - 0x8093AC6C:("func_8093AC6C",), - 0x8093ADA8:("func_8093ADA8",), - 0x8093AE1C:("func_8093AE1C",), - 0x8093AE74:("func_8093AE74",), - 0x8093AE88:("func_8093AE88",), - 0x8093AEC4:("func_8093AEC4",), - 0x8093AEF0:("func_8093AEF0",), - 0x8093AF1C:("func_8093AF1C",), - 0x8093AF54:("func_8093AF54",), + 0x8093ABD0:("ObjSwitch_InitJntSphCollider",), + 0x8093AC6C:("ObjSwitch_InitTrisCollider",), + 0x8093ADA8:("ObjSwitch_SpawnIce",), + 0x8093AE1C:("ObjSwitch_SetSwitchFlagState",), + 0x8093AE74:("ObjSwitch_CrystalUpdateTimer",), + 0x8093AE88:("ObjSwitch_StopCutscene",), + 0x8093AEC4:("ObjSwitch_PlayFootSwitchSfx",), + 0x8093AEF0:("ObjSwitch_PlayDiamondSwitchSfx",), + 0x8093AF1C:("ObjSwitch_SetFloorSwitchSnapPlayerState",), + 0x8093AF54:("ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge",), 0x8093B084:("ObjSwitch_Init",), 0x8093B59C:("ObjSwitch_Destroy",), - 0x8093B648:("func_8093B648",), - 0x8093B668:("func_8093B668",), - 0x8093B6F4:("func_8093B6F4",), - 0x8093B710:("func_8093B710",), - 0x8093B92C:("func_8093B92C",), - 0x8093B940:("func_8093B940",), - 0x8093B9C0:("func_8093B9C0",), - 0x8093B9E4:("func_8093B9E4",), - 0x8093BB5C:("func_8093BB5C",), - 0x8093BB70:("func_8093BB70",), - 0x8093BBD0:("func_8093BBD0",), - 0x8093BCC8:("func_8093BCC8",), - 0x8093BCDC:("func_8093BCDC",), - 0x8093BD34:("func_8093BD34",), - 0x8093BD4C:("func_8093BD4C",), - 0x8093BDAC:("func_8093BDAC",), - 0x8093BDC0:("func_8093BDC0",), - 0x8093BE10:("func_8093BE10",), - 0x8093BE2C:("func_8093BE2C",), - 0x8093BEF0:("func_8093BEF0",), - 0x8093BF04:("func_8093BF04",), - 0x8093BF50:("func_8093BF50",), - 0x8093BF70:("func_8093BF70",), - 0x8093C0A4:("func_8093C0A4",), - 0x8093C0B8:("func_8093C0B8",), - 0x8093C138:("func_8093C138",), - 0x8093C15C:("func_8093C15C",), - 0x8093C23C:("func_8093C23C",), - 0x8093C250:("func_8093C250",), - 0x8093C2B4:("func_8093C2B4",), - 0x8093C2D4:("func_8093C2D4",), - 0x8093C3C8:("func_8093C3C8",), - 0x8093C3DC:("func_8093C3DC",), - 0x8093C460:("func_8093C460",), - 0x8093C488:("func_8093C488",), - 0x8093C584:("func_8093C584",), - 0x8093C598:("func_8093C598",), + 0x8093B648:("ObjSwitch_TryPlayCutsceneInit",), + 0x8093B668:("ObjSwitch_TryPlayCutscene",), + 0x8093B6F4:("ObjSwitch_FloorSwitchUpInit",), + 0x8093B710:("ObjSwitch_FloorSwitchUp",), + 0x8093B92C:("ObjSwitch_FloorSwitchPushDownInit",), + 0x8093B940:("ObjSwitch_FloorSwitchPushDown",), + 0x8093B9C0:("ObjSwitch_FloorSwitchDownInit",), + 0x8093B9E4:("ObjSwitch_FloorSwitchDown",), + 0x8093BB5C:("ObjSwitch_FloorSwitchRiseUpInit",), + 0x8093BB70:("ObjSwitch_FloorSwitchRiseUp",), + 0x8093BBD0:("ObjSwitch_IsEyeSwitchHit",), + 0x8093BCC8:("ObjSwitch_EyeSwitchFrozenInit",), + 0x8093BCDC:("ObjSwitch_EyeSwitchUnfrozen",), + 0x8093BD34:("ObjSwitch_EyeSwitchOpenInit",), + 0x8093BD4C:("ObjSwitch_EyeSwitchOpen",), + 0x8093BDAC:("ObjSwitch_EyeSwitchClosingInit",), + 0x8093BDC0:("ObjSwitch_EyeSwitchClosing",), + 0x8093BE10:("ObjSwitch_EyeSwitchClosedInit",), + 0x8093BE2C:("ObjSwitch_EyeSwitchClosed",), + 0x8093BEF0:("ObjSwitch_EyeSwitchOpeningInit",), + 0x8093BF04:("ObjSwitch_EyeSwitchOpening",), + 0x8093BF50:("ObjSwitch_CrystalSwitchOffInit",), + 0x8093BF70:("ObjSwitch_CrystalSwitchOff",), + 0x8093C0A4:("ObjSwitch_CrystalSwitchTurnOnInit",), + 0x8093C0B8:("ObjSwitch_CrystalSwitchTurnOn",), + 0x8093C138:("ObjSwitch_CrystalSwitchOnInit",), + 0x8093C15C:("ObjSwitch_CrystalSwitchOn",), + 0x8093C23C:("ObjSwitch_CrystalSwitchTurnOffInit",), + 0x8093C250:("ObjSwitch_CrystalSwitchTurnOff",), + 0x8093C2B4:("ObjSwitch_LargeFloorSwitchUpInit",), + 0x8093C2D4:("ObjSwitch_LargeFloorSwitchUp",), + 0x8093C3C8:("ObjSwitch_LargeFloorSwitchPushDownInit",), + 0x8093C3DC:("ObjSwitch_LargeFloorSwitchPushDown",), + 0x8093C460:("ObjSwitch_LargeFloorSwitchDownInit",), + 0x8093C488:("ObjSwitch_LargeFloorSwitchDown",), + 0x8093C584:("ObjSwitch_LargeFloorSwitchRiseUpInit",), + 0x8093C598:("ObjSwitch_LargeFloorSwitchRiseUp",), 0x8093C5FC:("ObjSwitch_Update",), - 0x8093C778:("func_8093C778",), - 0x8093C888:("func_8093C888",), - 0x8093C8B8:("func_8093C8B8",), - 0x8093C99C:("func_8093C99C",), - 0x8093CA80:("func_8093CA80",), - 0x8093CAC4:("func_8093CAC4",), + 0x8093C778:("ObjSwitch_DrawFloorSwitch",), + 0x8093C888:("ObjSwitch_DrawRustyFloorSwitch",), + 0x8093C8B8:("ObjSwitch_DrawVisibleEyeSwitch",), + 0x8093C99C:("ObjSwitch_DrawInvisibleEyeSwitch",), + 0x8093CA80:("ObjSwitch_DrawEyeSwitch",), + 0x8093CAC4:("ObjSwitch_DrawCrystalSwitch",), 0x8093CC24:("ObjSwitch_Draw",), 0x8093D3C0:("func_8093D3C0",), 0x8093D628:("ObjLift_Init",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 54eb83c1b..da4bdabc4 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -510,13 +510,10 @@ D_05006760 = 0x05006760; D_05007498 = 0x05007498; D_050078A0 = 0x050078A0; D_05007938 = 0x05007938; -D_05007E00 = 0x05007E00; -D_05008018 = 0x05008018; D_050085F0 = 0x050085F0; D_050089D0 = 0x050089D0; D_050182A8 = 0x050182A8; D_0501B370 = 0x0501B370; -D_0501B508 = 0x0501B508; D_0501BEE0 = 0x0501BEE0; D_0501BFB8 = 0x0501BFB8; D_0501C058 = 0x0501C058; From 92c4d42f446cc12c79de9b441b9afa341cf294e8 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Wed, 23 Mar 2022 18:30:34 -0300 Subject: [PATCH 081/257] `z_skin` and `z_skin_awb` OK and documented a bit (#415) * oot copypaste * func_8013859C non matching and func_80138700 * protos * the other functions * func_80138300 * progress * func_80137F58 * func_80137EBC * func_80137B34 NON_MATCHING * func_80137970 * func_8013835C * z64skin * some docs * some bits * Match func_80137B34 * Match Skin_DrawImpl * Match Skin_Init tahnks to Anon * Some docs? * AnimatedLimb * SkinVtx * more names * fix merge issue * format * another clean * trailing comma * cleanup * format * add some descriptions * Import bss * last cleanup * Update ZAPD symbol map * Reanme gIdentityMtx and gIdentityMtxF * fix merge issues * bss * review * Update include/z64skin.h Co-authored-by: Derek Hensley * bss * Port @fig02 skin docs * format and a few changes * format * Port over OoT review * fixes * Engineer's review * format * address pr * Fix bss * fix bss * Update src/code/z_skin_awb.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * bss * bss * undo * pr * Skin_Setup Co-authored-by: Derek Hensley Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --- include/functions.h | 23 +- include/variables.h | 3 - include/z64.h | 3 +- include/z64animation.h | 51 +--- include/z64skin.h | 106 +++++++ spec | 1 - src/code/z_bgcheck.c | 1 + src/code/z_demo.c | 1 + src/code/z_lifemeter.c | 17 +- src/code/z_skelanime.c | 2 +- src/code/z_skin.c | 272 +++++++++++++++++- src/code/z_skin_awb.c | 203 ++++++++++++- src/overlays/actors/ovl_En_Horse/z_en_horse.h | 1 + .../z_en_horse_link_child.h | 1 + tools/ZAPDConfigs/MM/SymbolMap_MM.txt | 2 +- tools/actorfixer.py | 2 + tools/disasm/functions.txt | 24 +- tools/disasm/variables.txt | 3 +- tools/sizes/boot_functions.csv | 2 +- tools/sizes/code_functions.csv | 26 +- 20 files changed, 618 insertions(+), 126 deletions(-) create mode 100644 include/z64skin.h diff --git a/include/functions.h b/include/functions.h index 766c12eea..16a2ea64b 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1388,7 +1388,7 @@ s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5); void SaveContext_Init(void); void GameInfo_Init(void); -// void func_800E9470(void); +// void DebugDisplay_Init(void); DebugDispObject* DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, f32 scaleX, f32 scaleY, f32 scaleZ, u8 red, u8 green, u8 blue, u8 alpha, s16 type, GraphicsContext* gfxCtx); // void func_800E9C90(void); // void func_800E9CA0(s32 param_1, UNK_TYPE1 param_2, s8* param_3); @@ -2386,7 +2386,7 @@ s32 Animation_OnFrameImpl(SkelAnime* skelAnime, f32 frame, f32 updateRate); s32 LinkAnimation_OnFrame(SkelAnime* skelAnime, f32 frame); void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); -void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation); +void SkelAnime_InitSkin(GameState* gameState, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg); void SkelAnime_SetUpdate(SkelAnime* skelAnime); s32 SkelAnime_Update(SkelAnime* skelAnime); s32 SkelAnime_Morph(SkelAnime* skelAnime); @@ -2411,23 +2411,7 @@ void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle); s32 Animation_OnFrame(SkelAnime* skelAnime, f32 frame); void SkelAnime_Free(SkelAnime* skelAnime, GlobalContext* globalCtx); void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); -// void func_80137970(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80137B34(void); -// void func_80137EBC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80137F58(void); -// void func_80138050(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_80138228(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80138258(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_8013828C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_801382C4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_80138300(void); -// void func_8013835C(void); -// void func_80138410(void); -// void func_80138424(void); -// void func_8013859C(void); -// void func_80138700(void); -// void func_801387D4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); -// void func_801388E4(void); + void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest); void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, Vec3f* src, Vec3f* dest); void SkinMatrix_MtxFMtxFMult(MtxF* mfB, MtxF* mfA, MtxF* dest); @@ -2452,6 +2436,7 @@ void SkinMatrix_MulXRotation(MtxF* mf, s16 a); void SkinMatrix_SetYRotation(MtxF* mf, s16 a); void SkinMatrix_MulYRotation(MtxF* mf, s16 a); void SkinMatrix_SetZRotation(MtxF* mf, s16 a); + s32 func_8013A240(GlobalContext* globalCtx); void func_8013A41C(s32 flag); void func_8013A46C(s32 flag); diff --git a/include/variables.h b/include/variables.h index db29d0c92..b563d15cf 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1616,8 +1616,6 @@ extern Vec3f gZeroVec3f; extern Vec3s gZeroVec3s; extern Mtx gIdentityMtx; extern MtxF gIdentityMtxF; -// extern u64* initialgspUcodeText; -// extern u64* initialgspUcodeData; // extern UNK_TYPE1 D_801D1E70; // extern UNK_TYPE1 gLowPassFilterData; // extern UNK_TYPE1 gHighPassFilterData; @@ -3268,7 +3266,6 @@ extern LightsBuffer sLightsBuffer; // extern UNK_TYPE1 D_801F59F0; // extern UNK_TYPE1 D_801F59F4; // extern UNK_TYPE1 D_801F59F8; -// extern UNK_TYPE1 D_801F5AC0; // extern UNK_TYPE1 D_801F69D0; // extern UNK_TYPE1 D_801F6A10; // extern UNK_TYPE1 D_801F6AD4; diff --git a/include/z64.h b/include/z64.h index 51d2bc33b..7d39504b8 100644 --- a/include/z64.h +++ b/include/z64.h @@ -36,8 +36,9 @@ #include "z64object.h" #include "z64ocarina.h" #include "z64player.h" -#include "z64scene.h" #include "z64save.h" +#include "z64scene.h" +#include "z64skin.h" #include "z64transition.h" #include "regs.h" diff --git a/include/z64animation.h b/include/z64animation.h index 10b145d38..0e4388dde 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -1,5 +1,5 @@ -#ifndef _Z64_ANIMATION_H -#define _Z64_ANIMATION_H +#ifndef Z64_ANIMATION_H +#define Z64_ANIMATION_H #include "PR/ultratypes.h" #include "PR/gbi.h" @@ -28,7 +28,7 @@ typedef enum { } AnimationModes; typedef enum { - /* -1 */ ANIMTAPER_DECEL = -1, + /* -1 */ ANIMTAPER_DECEL = -1, /* 0 */ ANIMTAPER_NONE, /* 1 */ ANIMTAPER_ACCEL } AnimationTapers; @@ -49,14 +49,6 @@ typedef struct { /* 0x08 */ Gfx* dLists[2]; // Near and far } LodLimb; // size = 0x10 -typedef struct { - /* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent - /* 0x06 */ u8 child; - /* 0x07 */ u8 sibling; - /* 0x08 */ s32 unk_8; // Type of data contained in segment - /* 0x0C */ void* segment; // Segment address of data. Currently unclear what. -} SkinLimb; // size = 0x10 - // Model has limbs with only rigid meshes typedef struct { /* 0x00 */ void** segment; @@ -279,43 +271,6 @@ typedef s32 (*OverrideCurveLimbDraw)(struct GlobalContext* globalCtx, SkelAnimeC typedef void (*PostCurveLimbDraw)(struct GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, struct Actor* actor); -// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes -typedef struct { - /* 0x000 */ u16 unk_0; - /* 0x002 */ s16 unk_2; - /* 0x004 */ s16 unk_4; - /* 0x006 */ s8 unk_6; - /* 0x007 */ s8 unk_7; - /* 0x008 */ s8 unk_8; - /* 0x009 */ u8 unk_9; -} Struct_800A57C0; // size = 0xA - -// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes -typedef struct { - /* 0x000 */ u8 unk_0; - /* 0x002 */ s16 x; - /* 0x004 */ s16 y; - /* 0x006 */ s16 z; - /* 0x008 */ u8 unk_8; -} Struct_800A598C_2; // size = 0xA - -// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes -typedef struct { - /* 0x000 */ u16 unk_0; - /* 0x002 */ u16 unk_2; - /* 0x004 */ u16 unk_4; - /* 0x008 */ Struct_800A57C0* unk_8; - /* 0x00C */ Struct_800A598C_2* unk_C; -} Struct_800A598C; // size = 0x10 - -// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes -typedef struct { - /* 0x000 */ u16 unk_0; - /* 0x002 */ u16 unk_2; - /* 0x004 */ Struct_800A598C* unk_4; - /* 0x008 */ Gfx* unk_8; -} Struct_800A5E28; // size = 0xC - typedef struct { /* 0x00 */ AnimationHeader* animation; /* 0x04 */ f32 playSpeed; diff --git a/include/z64skin.h b/include/z64skin.h new file mode 100644 index 000000000..adb2f9b0f --- /dev/null +++ b/include/z64skin.h @@ -0,0 +1,106 @@ +#ifndef Z64_SKIN_H +#define Z64_SKIN_H + +#include "z64animation.h" + +struct GraphicsContext; +struct GameState; +struct GlobalContext; + +/** + * Holds a compact version of a vertex used in the Skin system (doesn't has the x, y, z positions or the flag member) + * It is used to initialise the Vtx used by an animated limb + */ +typedef struct { + /* 0x0 */ u16 index; + /* 0x2 */ s16 s; // s and t are texture coordinates (also known as u and v) + /* 0x4 */ s16 t; + /* 0x6 */ s8 normX; + /* 0x7 */ s8 normY; + /* 0x8 */ s8 normZ; + /* 0x9 */ u8 alpha; +} SkinVertex; // size = 0xA + +/** + * Describes a position displacement and a scale to be applied to a limb at index `limbIndex` + */ +typedef struct { + /* 0x0 */ u8 limbIndex; + /* 0x2 */ s16 x; + /* 0x4 */ s16 y; + /* 0x6 */ s16 z; + /* 0x8 */ u8 scale; +} SkinTransformation; // size = 0xA + +typedef struct { + /* 0x00 */ u16 vtxCount; // number of vertices in this modif entry + /* 0x02 */ u16 transformCount; + /* 0x04 */ u16 unk_04; // index of limbTransformations + /* 0x08 */ SkinVertex* skinVertices; + /* 0x0C */ SkinTransformation* limbTransformations; +} SkinLimbModif; // size = 0x10 + +typedef struct { + /* 0x00 */ u16 totalVtxCount; // total vertex count for all modif entries + /* 0x02 */ u16 limbModifCount; // count of limbModifCount + /* 0x04 */ SkinLimbModif* limbModifications; + /* 0x08 */ Gfx* dlist; +} SkinAnimatedLimbData; // size = 0xC + +// ZAPD compatibility typedefs +// TODO: Remove when ZAPD adds support for them +typedef SkinVertex Struct_800A57C0; +typedef SkinTransformation Struct_800A598C_2; +typedef SkinAnimatedLimbData Struct_800A5E28; +typedef SkinLimbModif Struct_800A598C; + +#define SKIN_LIMB_TYPE_ANIMATED 4 +#define SKIN_LIMB_TYPE_NORMAL 11 + +typedef struct { + /* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent + /* 0x06 */ u8 child; + /* 0x07 */ u8 sibling; + /* 0x08 */ s32 segmentType; // Type of data contained in segment + /* 0x0C */ void* segment; // Gfx* if segmentType is SKIN_LIMB_TYPE_NORMAL, SkinAnimatedLimbData if segmentType is SKIN_LIMB_TYPE_ANIMATED, NULL otherwise +} SkinLimb; // size = 0x10 + +typedef struct { + /* 0x0 */ u8 index; // alternates every draw cycle + /* 0x4 */ Vtx* buf[2]; // number of vertices in buffer determined by `totalVtxCount` +} SkinLimbVtx; // size = 0xC + +typedef struct { + /* 0x000 */ SkeletonHeader* skeletonHeader; + /* 0x004 */ MtxF mtx; + /* 0x044 */ s32 limbCount; + /* 0x048 */ SkinLimbVtx* vtxTable; // double buffered list of vertices for each limb + /* 0x04C */ SkelAnime skelAnime; +} Skin; // size = 0x90 + +typedef void (*SkinPostDraw)(struct Actor*, struct GlobalContext*, Skin*); +typedef s32 (*SkinOverrideLimbDraw)(struct Actor*, struct GlobalContext*, s32, Skin*); + +#define SKIN_DRAW_FLAG_CUSTOM_TRANSFORMS (1 << 0) +#define SKIN_DRAW_FLAG_CUSTOM_MATRIX (1 << 1) + + +void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* modifEntry, Vtx* vtxBuf, Vec3f* pos); +void Skin_ApplyLimbModifications(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3); +void Skin_DrawAnimatedLimb(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3, s32 drawFlags); +void Skin_DrawLimb(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, Gfx* dListOverride, s32 drawFlags); +void func_80138228(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, s32 setTranslation); +void func_80138258(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation); +void func_8013828C(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6); +void func_801382C4(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags); +void Skin_GetLimbPos(Skin* skin, s32 limbIndex, Vec3f* offset, Vec3f* dst); +void Skin_GetVertexPos(Skin* skin, s32 limbIndex, s32 vtxIndex, Vec3f* dst); + +void Skin_Setup(Skin* skin); +void Skin_InitAnimatedLimb(struct GameState* gameState, Skin* skin, s32 limbIndex); +void Skin_Init(struct GameState* gameState, Skin* skin, SkeletonHeader* skeletonHeader, AnimationHeader* animationHeader); +void Skin_Free(struct GameState* gameState, Skin* skin); +s32 func_801387D4(Skin* skin, SkinLimb** skeleton, MtxF* limbMatrices, u8 parentIndex, u8 limbIndex); +s32 Skin_ApplyAnimTransformations(Skin* skin, MtxF* limbMatrices, Actor* actor, s32 setTranslation); + +#endif diff --git a/spec b/spec index f719cb5a1..e4be4114e 100644 --- a/spec +++ b/spec @@ -527,7 +527,6 @@ beginseg include "build/data/code/code_801C5C50.data.o" include "build/src/code/z_skelanime.o" include "build/src/code/z_skin.o" - include "build/data/code/z_skin.bss.o" include "build/src/code/z_skin_awb.o" include "build/src/code/z_skin_matrix.o" include "build/src/code/z_snap.o" diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 3f5583f79..910458b77 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" #include "vt.h" diff --git a/src/code/z_demo.c b/src/code/z_demo.c index fb6f8687c..785f86856 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index 17e73dc34..703b966de 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -1,15 +1,16 @@ +#include "prevent_bss_reordering.h" #include "global.h" #include "interface/parameter_static/parameter_static.h" #include "prevent_bss_reordering.h" -static s16 sHeartsPrimColors[3][3] = { { 255, 70, 50 }, { 255, 190, 0 }, { 100, 100, 255 } }; -static s16 sHeartsEnvColors[3][3] = { { 50, 40, 60 }, { 255, 0, 0 }, { 0, 0, 255 } }; -static s16 sHeartsPrimFactors[3][3] = { { 0, 0, 0 }, { 0, 120, -50 }, { -155, 30, 205 } }; -static s16 sHeartsEnvFactors[3][3] = { { 0, 0, 0 }, { 205, -40, -60 }, { -50, -40, 195 } }; -static s16 sHeartsDDPrimColors[3][3] = { { 255, 255, 255 }, { 255, 190, 0 }, { 100, 100, 255 } }; -static s16 sHeartsDDEnvColors[3][3] = { { 200, 0, 0 }, { 255, 0, 0 }, { 0, 0, 255 } }; -static s16 sHeartsDDPrimFactors[3][3] = { { 0, 0, 0 }, { 0, -65, -255 }, { -155, -155, 0 } }; -static s16 sHeartsDDEnvFactors[3][3] = { { 0, 0, 0 }, { 55, 0, 0 }, { -200, 0, 255 } }; +s16 sHeartsPrimColors[3][3] = { { 255, 70, 50 }, { 255, 190, 0 }, { 100, 100, 255 } }; +s16 sHeartsEnvColors[3][3] = { { 50, 40, 60 }, { 255, 0, 0 }, { 0, 0, 255 } }; +s16 sHeartsPrimFactors[3][3] = { { 0, 0, 0 }, { 0, 120, -50 }, { -155, 30, 205 } }; +s16 sHeartsEnvFactors[3][3] = { { 0, 0, 0 }, { 205, -40, -60 }, { -50, -40, 195 } }; +s16 sHeartsDDPrimColors[3][3] = { { 255, 255, 255 }, { 255, 190, 0 }, { 100, 100, 255 } }; +s16 sHeartsDDEnvColors[3][3] = { { 200, 0, 0 }, { 255, 0, 0 }, { 0, 0, 255 } }; +s16 sHeartsDDPrimFactors[3][3] = { { 0, 0, 0 }, { 0, -65, -255 }, { -155, -155, 0 } }; +s16 sHeartsDDEnvFactors[3][3] = { { 0, 0, 0 }, { 55, 0, 0 }, { -200, 0, 255 } }; s16 sBeatingHeartsDDPrim[3]; s16 sBeatingHeartsDDEnv[3]; diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 9fc5467e0..f0ed1f516 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1577,7 +1577,7 @@ void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkel /** * Initializes a skeleton with SkinLimbs to a looping animation, dynamically allocating the frame tables. */ -void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, +void SkelAnime_InitSkin(GameState* gameState, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation) { SkeletonHeader* skeletonHeader; diff --git a/src/code/z_skin.c b/src/code/z_skin.c index f031b007f..808a00da0 100644 --- a/src/code/z_skin.c +++ b/src/code/z_skin.c @@ -1,23 +1,273 @@ #include "global.h" +#include "z64skin.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80137970.s") +// 60 is an arbitrary number which specifies the max amount of limbs per skeleton this system supports +MtxF gSkinLimbMatrices[60]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80137B34.s") +static s32 sUnused; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80137EBC.s") +void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* modifEntry, Vtx* vtxBuf, Vec3f* pos) { + SkinVertex* vertexEntry; + Vtx* vtx; + Vec3f wTemp; + Vec3f normal; + Vec3f sp44; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80137F58.s") + wTemp.x = mtx->wx; + wTemp.y = mtx->wy; + wTemp.z = mtx->wz; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80138050.s") + mtx->wx = 0.0f; + mtx->wy = 0.0f; + mtx->wz = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80138228.s") + for (vertexEntry = skinVertices; vertexEntry < &skinVertices[modifEntry->vtxCount]; vertexEntry++) { + vtx = &vtxBuf[vertexEntry->index]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80138258.s") + vtx->n.ob[0] = pos->x; + vtx->n.ob[1] = pos->y; + vtx->n.ob[2] = pos->z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_8013828C.s") + sp44.x = vertexEntry->normX; + sp44.y = vertexEntry->normY; + sp44.z = vertexEntry->normZ; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_801382C4.s") + SkinMatrix_Vec3fMtxFMultXYZ(mtx, &sp44, &normal); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80138300.s") + vtx->n.n[0] = normal.x; + vtx->n.n[1] = normal.y; + vtx->n.n[2] = normal.z; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_8013835C.s") + mtx->wx = wTemp.x; + mtx->wy = wTemp.y; + mtx->wz = wTemp.z; +} + +void Skin_ApplyLimbModifications(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3) { + s32 modifCount; + SkinLimb** skeleton; + s32 pad; + SkinAnimatedLimbData* data; + s32 pad2[5]; + SkinLimbModif* modif; + SkinLimbVtx* vtxEntry; + s32 pad3; + s32 transformCount; + f32 scale; + SkinVertex* skinVertices; + Vec3f sp88; + Vtx* vtxBuf; + SkinTransformation* limbTransformations; + Vec3f spDC; + Vec3f spD0; + SkinTransformation* transformationEntry; + SkinLimb* limb; + SkinLimbModif* modifications; + + OPEN_DISPS(gfxCtx); + + skeleton = (SkinLimb**)Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + limb = (SkinLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]); + data = Lib_SegmentedToVirtual(limb->segment); + modifications = (SkinLimbModif*)Lib_SegmentedToVirtual(data->limbModifications); + + vtxEntry = &skin->vtxTable[limbIndex]; + + vtxBuf = vtxEntry->buf[vtxEntry->index]; + modifCount = data->limbModifCount; + + for (modif = modifications; modif < &modifications[modifCount]; modif++) { + Vec3f spAC; + Vec3f spA0; + + skinVertices = (SkinVertex*)Lib_SegmentedToVirtual(modif->skinVertices); + limbTransformations = (SkinTransformation*)Lib_SegmentedToVirtual(modif->limbTransformations); + transformCount = modif->transformCount; + + if (transformCount == 1) { + spAC.x = limbTransformations[0].x; + spAC.y = limbTransformations[0].y; + spAC.z = limbTransformations[0].z; + + SkinMatrix_Vec3fMtxFMultXYZ(&gSkinLimbMatrices[limbTransformations[0].limbIndex], &spAC, &spDC); + } else if (arg3) { + transformationEntry = &limbTransformations[modif->unk_04]; + + spA0.x = transformationEntry->x; + spA0.y = transformationEntry->y; + spA0.z = transformationEntry->z; + SkinMatrix_Vec3fMtxFMultXYZ(&gSkinLimbMatrices[transformationEntry->limbIndex], &spA0, &spDC); + } else { + spDC.x = 0.0f; + spDC.y = 0.0f; + spDC.z = 0.0f; + + for (transformationEntry = limbTransformations; transformationEntry < &limbTransformations[transformCount]; + transformationEntry++) { + scale = transformationEntry->scale * 0.01f; + + sp88.x = transformationEntry->x; + sp88.y = transformationEntry->y; + sp88.z = transformationEntry->z; + + SkinMatrix_Vec3fMtxFMultXYZ(&gSkinLimbMatrices[transformationEntry->limbIndex], &sp88, &spD0); + + spDC.x += spD0.x * scale; + spDC.y += spD0.y * scale; + spDC.z += spD0.z * scale; + } + } + + Skin_UpdateVertices(&gSkinLimbMatrices[limbTransformations[modif->unk_04].limbIndex], skinVertices, modif, + vtxBuf, &spDC); + } + + gSPSegment(POLY_OPA_DISP++, 0x08, vtxEntry->buf[vtxEntry->index]); + + vtxEntry->index = (vtxEntry->index == 0); + + CLOSE_DISPS(gfxCtx); +} + +/** + * Draw a limb of type SKIN_LIMB_TYPE_ANIMATED, of the skeleton `skin` at index `limbIndex` + * The vertices of this limb are modified dynamically + */ +void Skin_DrawAnimatedLimb(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3, s32 drawFlags) { + SkinLimb** skeleton; + s32 pad[3]; + SkinAnimatedLimbData* data; + + OPEN_DISPS(gfxCtx); + + skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + data = Lib_SegmentedToVirtual(((SkinLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]))->segment); + + if (!(drawFlags & SKIN_DRAW_FLAG_CUSTOM_TRANSFORMS)) { + Skin_ApplyLimbModifications(gfxCtx, skin, limbIndex, arg3); + } + + gSPDisplayList(POLY_OPA_DISP++, data->dlist); + + CLOSE_DISPS(gfxCtx); +} + +/** + * Draw a limb of type SKIN_LIMB_TYPE_NORMAL, of the skeleton `skin` at index `limbIndex` + */ +void Skin_DrawLimb(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, Gfx* dListOverride, s32 drawFlags) { + Gfx* gfx = dListOverride; + SkinLimb** skeleton; + + OPEN_DISPS(gfxCtx); + + skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + + if (dListOverride == NULL) { + gfx = ((SkinLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]))->segment; + } + + if (gfx != NULL) { + Mtx* mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &gSkinLimbMatrices[limbIndex]); + + if (mtx != NULL) { + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gfx); + gSPPopMatrix(POLY_OPA_DISP++, G_MTX_MODELVIEW); + gDPPipeSync(POLY_OPA_DISP++); + } + } + + CLOSE_DISPS(gfxCtx); +} + +void Skin_DrawImpl(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, + SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags) { + s32 i; + SkinLimb** skeleton; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + + if (!(drawFlags & SKIN_DRAW_FLAG_CUSTOM_TRANSFORMS)) { + Skin_ApplyAnimTransformations(skin, gSkinLimbMatrices, actor, setTranslation); + } + + skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + + if (!(drawFlags & SKIN_DRAW_FLAG_CUSTOM_MATRIX)) { + Mtx* mtx; + + gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &skin->mtx); + if (mtx == NULL) { + goto close_disps; + } + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } + + for (i = 0; i < skin->skeletonHeader->limbCount; i++) { + s32 shouldDraw = true; + s32 segmentType; + + if (overrideLimbDraw != NULL) { + shouldDraw = overrideLimbDraw(actor, globalCtx, i, skin); + } + + segmentType = ((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segmentType; + + if (segmentType == SKIN_LIMB_TYPE_ANIMATED && shouldDraw) { + Skin_DrawAnimatedLimb(gfxCtx, skin, i, arg6, drawFlags); + } else if (segmentType == SKIN_LIMB_TYPE_NORMAL && shouldDraw) { + Skin_DrawLimb(gfxCtx, skin, i, NULL, drawFlags); + } + } + + if (postDraw != NULL) { + postDraw(actor, globalCtx, skin); + } + +close_disps:; + CLOSE_DISPS(gfxCtx); +} + +// allows specifying postDraw and setTranslation +void func_80138228(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, s32 setTranslation) { + Skin_DrawImpl(actor, globalCtx, skin, postDraw, NULL, setTranslation, false, 0); +} + +// allows specifying OverrideLimbDraw, postDraw and setTranslation +void func_80138258(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, + SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation) { + Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, false, 0); +} + +// allows specifying OverrideLimbDraw, postDraw, setTranslation, and arg6 +void func_8013828C(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, + SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6) { + Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, arg6, 0); +} + +// allows specifying all variables +void func_801382C4(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, + SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags) { + Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, arg6, drawFlags); +} + +void Skin_GetLimbPos(Skin* skin, s32 limbIndex, Vec3f* offset, Vec3f* dst) { + MtxF mtxf; + + SkinMatrix_MtxFMtxFMult(&skin->mtx, &gSkinLimbMatrices[limbIndex], &mtxf); + SkinMatrix_Vec3fMtxFMultXYZ(&mtxf, offset, dst); +} + +void Skin_GetVertexPos(Skin* skin, s32 limbIndex, s32 vtxIndex, Vec3f* dst) { + Vec3f pos; + Vtx* vtx = &skin->vtxTable[limbIndex].buf[skin->vtxTable[0].index][vtxIndex]; + + pos.x = vtx->n.ob[0]; + pos.y = vtx->n.ob[1]; + pos.z = vtx->n.ob[2]; + SkinMatrix_Vec3fMtxFMultXYZ(&skin->mtx, &pos, dst); +} diff --git a/src/code/z_skin_awb.c b/src/code/z_skin_awb.c index 22a1c637f..d45b9bc25 100644 --- a/src/code/z_skin_awb.c +++ b/src/code/z_skin_awb.c @@ -1,13 +1,204 @@ #include "global.h" +#include "z64skin.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_80138410.s") +void Skin_Setup(Skin* skin) { + skin->skeletonHeader = NULL; + skin->limbCount = 0; + skin->vtxTable = NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_80138424.s") +/** + * Initialises the Vtx buffers used for limb at index `limbIndex` + */ +void Skin_InitAnimatedLimb(GameState* gameState, Skin* skin, s32 limbIndex) { + s32 i; + SkinLimb** skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + SkinAnimatedLimbData* animatedLimbData = + Lib_SegmentedToVirtual(((SkinLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]))->segment); + SkinLimbModif* limbModifications = Lib_SegmentedToVirtual(animatedLimbData->limbModifications); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_8013859C.s") + for (i = 0; i < ARRAY_COUNT(skin->vtxTable->buf); i++) { + Vtx* vertices = skin->vtxTable[limbIndex].buf[i]; + SkinLimbModif* modifEntry; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_80138700.s") + for (modifEntry = limbModifications; modifEntry < &limbModifications[animatedLimbData->limbModifCount]; + modifEntry++) { + SkinVertex* skinVertices = Lib_SegmentedToVirtual(modifEntry->skinVertices); + SkinVertex* skinVtxEntry; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_801387D4.s") + for (skinVtxEntry = skinVertices; skinVtxEntry < &skinVertices[modifEntry->vtxCount];) { + Vtx* vtx = &vertices[skinVtxEntry->index]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_801388E4.s") + skinVtxEntry++; + + vtx->n.flag = 0; + vtx->n.tc[0] = skinVtxEntry[-1].s; + vtx->n.tc[1] = skinVtxEntry[-1].t; + vtx->n.a = skinVtxEntry[-1].alpha; + } + } + } +} + +/** + * Initializes a skin skeleton to looping animation, dynamically allocating the frame tables, + * and dynamically allocating and initialising the Vtx and SkinLimbVtx buffers for its animated limbs + */ +void Skin_Init(GameState* gameState, Skin* skin, SkeletonHeader* skeletonHeader, AnimationHeader* animationHeader) { + s32 limbCount; + s32 i; + SkinLimb** skeleton; + SkeletonHeader* virtSkelHeader = Lib_SegmentedToVirtual(skeletonHeader); + + skin->limbCount = virtSkelHeader->limbCount; + skin->skeletonHeader = virtSkelHeader; + limbCount = skin->skeletonHeader->limbCount; + + skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + skin->vtxTable = ZeldaArena_Malloc(limbCount * sizeof(SkinLimbVtx)); + + for (i = 0; i < limbCount; i++) { + SkinLimbVtx* vtxEntry = &skin->vtxTable[i]; + + if ((((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segmentType != SKIN_LIMB_TYPE_ANIMATED) || + (((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segment == NULL)) { + vtxEntry->index = 0; + + vtxEntry->buf[0] = NULL; + vtxEntry->buf[1] = NULL; + } else { + SkinAnimatedLimbData* animatedLimbData = + Lib_SegmentedToVirtual((((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segment)); + + { s32 tmp; } + + vtxEntry->index = 0; + vtxEntry->buf[0] = ZeldaArena_Malloc(animatedLimbData->totalVtxCount * sizeof(Vtx)); + vtxEntry->buf[1] = ZeldaArena_Malloc(animatedLimbData->totalVtxCount * sizeof(Vtx)); + + Skin_InitAnimatedLimb(gameState, skin, i); + } + } + + SkelAnime_InitSkin(gameState, &skin->skelAnime, skeletonHeader, animationHeader); +} + +/** + * Frees the dynamically allocated Vtx and SkinLimbVtx buffers and tables + */ +void Skin_Free(GameState* gameState, Skin* skin) { + if (skin->vtxTable != NULL) { + s32 i; + + for (i = 0; i < skin->limbCount; i++) { + if (skin->vtxTable[i].buf[0] != NULL) { + ZeldaArena_Free(skin->vtxTable[i].buf[0]); + skin->vtxTable[i].buf[0] = NULL; + } + if (skin->vtxTable[i].buf[1] != NULL) { + ZeldaArena_Free(skin->vtxTable[i].buf[1]); + skin->vtxTable[i].buf[1] = NULL; + } + } + + if (skin->vtxTable != NULL) { + ZeldaArena_Free(skin->vtxTable); + } + + SkelAnime_Free(&skin->skelAnime, (GlobalContext*)gameState); + } +} + +s32 func_801387D4(Skin* skin, SkinLimb** skeleton, MtxF* limbMatrices, u8 parentIndex, u8 limbIndex) { + s32 pad; + SkinLimb* limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); + MtxF* mtx; + s32 ret; + MtxF sp28; + + if (parentIndex == LIMB_DONE) { + SkinMatrix_GetClear(&mtx); + } else { + mtx = &limbMatrices[(s32)parentIndex]; + } + + SkinMatrix_MtxFMtxFMult(mtx, &limbMatrices[limbIndex], &sp28); + SkinMatrix_MtxFCopy(&sp28, &limbMatrices[limbIndex]); + + if (limb->child != LIMB_DONE) { + ret = func_801387D4(skin, skeleton, limbMatrices, limbIndex, limb->child); + if (ret) { + return ret; + } + } + + if (limb->sibling != LIMB_DONE) { + ret = func_801387D4(skin, skeleton, limbMatrices, parentIndex, limb->sibling); + if (ret) { + return ret; + } + } + + return false; +} + +/** + * Recursively applies matrix tranformations to each limb + */ +s32 Skin_ApplyAnimTransformations(Skin* skin, MtxF* limbMatrices, Actor* actor, s32 setTranslation) { + s32 i; + s32 pad; + f32 yRot; + f32 xRot; + f32 zRot; + s32 ret; + f32 yTransl; + f32 xTransl; + f32 zTransl; + SkinLimb** skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + Vec3s* jointRot = skin->skelAnime.jointTable; + + jointRot++; + xRot = jointRot->x; + yRot = jointRot->y; + zRot = jointRot->z; + + if (setTranslation) { + jointRot--; + xTransl = jointRot->x; + yTransl = jointRot->y; + zTransl = jointRot->z; + jointRot++; + + SkinMatrix_SetRotateRPYTranslate(limbMatrices, xRot, yRot, zRot, xTransl, yTransl, zTransl); + } else { + SkinMatrix_SetRotateRPYTranslate(limbMatrices, xRot, yRot, zRot, 0.0f, 0.0f, 0.0f); + } + + jointRot++; + + for (i = 1; i < skin->skeletonHeader->limbCount; i++) { + SkinLimb* limb = Lib_SegmentedToVirtual(skeleton[i]); + + xTransl = limb->jointPos.x; + yTransl = limb->jointPos.y; + zTransl = limb->jointPos.z; + xRot = jointRot->x; + yRot = jointRot->y; + zRot = jointRot->z; + jointRot++; + SkinMatrix_SetRotateRPYTranslate(&limbMatrices[i], xRot, yRot, zRot, xTransl, yTransl, zTransl); + } + + SkinMatrix_SetScaleRotateYRPTranslate( + &skin->mtx, actor->scale.x, actor->scale.y, actor->scale.z, actor->shape.rot.x, actor->shape.rot.y, + actor->shape.rot.z, actor->world.pos.x, actor->world.pos.y + (actor->shape.yOffset * actor->scale.y), + actor->world.pos.z); + + ret = func_801387D4(skin, Lib_SegmentedToVirtual(skin->skeletonHeader->segment), limbMatrices, LIMB_DONE, 0); + if (!ret) { + return ret; + } + + return false; +} 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 787fd8b57..05a4065ff 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.h +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.h @@ -2,6 +2,7 @@ #define Z_EN_HORSE_H #include "global.h" +#include "z64skin.h" struct EnHorse; diff --git a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h index 16ac6a616..ecc816c52 100644 --- a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h +++ b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h @@ -2,6 +2,7 @@ #define Z_EN_HORSE_LINK_CHILD_H #include "global.h" +#include "z64skin.h" struct EnHorseLinkChild; diff --git a/tools/ZAPDConfigs/MM/SymbolMap_MM.txt b/tools/ZAPDConfigs/MM/SymbolMap_MM.txt index 015e7e88a..cc7b36b5e 100644 --- a/tools/ZAPDConfigs/MM/SymbolMap_MM.txt +++ b/tools/ZAPDConfigs/MM/SymbolMap_MM.txt @@ -1 +1 @@ -8012DB20 gMtxClear \ No newline at end of file +801D1DE0 gIdentityMtx diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 5e7d2e3a6..b6aba86c0 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -232,6 +232,8 @@ animdict = { "MainHeap_Init": "ZeldaArena_Init", "MainHeap_Cleanup": "ZeldaArena_Cleanup", "MainHeap_IsInitialized": "ZeldaArena_IsInitialized", + "func_80138300": "Skin_GetLimbPos", + "func_8013835C": "Skin_GetVertexPos", # "BgCheck_RelocateMeshHeader": "CollisionHeader_GetVirtual", # "BgCheck_AddActorMesh": "DynaPoly_SetBgActor", # "BgCheck_RemoveActorMesh": "DynaPoly_DeleteBgActor", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4923739ed..321bed21d 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2608,23 +2608,23 @@ 0x801378B8:("Animation_OnFrame",), 0x801378E0:("SkelAnime_Free",), 0x8013792C:("SkelAnime_CopyFrameTable",), - 0x80137970:("func_80137970",), - 0x80137B34:("func_80137B34",), - 0x80137EBC:("func_80137EBC",), - 0x80137F58:("func_80137F58",), - 0x80138050:("func_80138050",), + 0x80137970:("Skin_UpdateVertices",), + 0x80137B34:("Skin_ApplyLimbModifications",), + 0x80137EBC:("Skin_DrawAnimatedLimb",), + 0x80137F58:("Skin_DrawLimb",), + 0x80138050:("Skin_DrawImpl",), 0x80138228:("func_80138228",), 0x80138258:("func_80138258",), 0x8013828C:("func_8013828C",), 0x801382C4:("func_801382C4",), - 0x80138300:("func_80138300",), - 0x8013835C:("func_8013835C",), - 0x80138410:("func_80138410",), - 0x80138424:("func_80138424",), - 0x8013859C:("func_8013859C",), - 0x80138700:("func_80138700",), + 0x80138300:("Skin_GetLimbPos",), + 0x8013835C:("Skin_GetVertexPos",), + 0x80138410:("Skin_Setup",), + 0x80138424:("Skin_InitAnimatedLimb",), + 0x8013859C:("Skin_Init",), + 0x80138700:("Skin_Free",), 0x801387D4:("func_801387D4",), - 0x801388E4:("func_801388E4",), + 0x801388E4:("Skin_ApplyAnimTransformations",), 0x80138BA0:("SkinMatrix_Vec3fMtxFMultXYZW",), 0x80138C88:("SkinMatrix_Vec3fMtxFMultXYZ",), 0x80138D38:("SkinMatrix_MtxFMtxFMult",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 83f8ac2e9..e3d3a8485 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4072,7 +4072,8 @@ 0x801F5AA8:("sMatAnimAlphaRatio","f32","",0x4), 0x801F5AB0:("sAnimQueueFlags","UNK_TYPE1","",0x1), 0x801F5AB4:("sDisableAnimQueueFlags","UNK_TYPE1","",0x1), - 0x801F5AC0:("D_801F5AC0","UNK_TYPE1","",0x1), + 0x801F5AC0:("gSkinLimbMatrices","MtxF","[60]",0xF00), + 0x801F69C0:("D_801F69C0","UNK_TYPE1","",0x10), 0x801F69D0:("D_801F69D0","UNK_TYPE1","",0x1), 0x801F6A10:("D_801F6A10","UNK_TYPE1","",0x1), 0x801F6AD4:("D_801F6AD4","UNK_TYPE1","",0x1), diff --git a/tools/sizes/boot_functions.csv b/tools/sizes/boot_functions.csv index 3685e3fa9..8551b4fca 100644 --- a/tools/sizes/boot_functions.csv +++ b/tools/sizes/boot_functions.csv @@ -162,7 +162,7 @@ asm/non_matchings/boot/boot_800862E0/func_8008641C.s,func_8008641C,0x8008641C,0x asm/non_matchings/boot/boot_800862E0/func_800864EC.s,func_800864EC,0x800864EC,0x27 asm/non_matchings/boot/boot_800862E0/func_80086588.s,func_80086588,0x80086588,0x1C asm/non_matchings/boot/boot_800862E0/SystemArena_Init.s,SystemArena_Init,0x800865F8,0xA -asm/non_matchings/boot/padsetup/func_80086620.s,func_80086620,0x80086620,0x50 +asm/non_matchings/boot/padsetup/PadSetup_Init.s,PadSetup_Init,0x80086620,0x50 asm/non_matchings/boot/boot_80086760/func_80086760.s,func_80086760,0x80086760,0xD asm/non_matchings/boot/boot_80086760/func_80086794.s,func_80086794,0x80086794,0x8 asm/non_matchings/boot/boot_80086760/func_800867B4.s,func_800867B4,0x800867B4,0x8 diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 98d408bee..11dae40ba 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1034,7 +1034,7 @@ asm/non_matchings/code/code_800E8EA0/func_800E9138.s,func_800E9138,0x800E9138,0x asm/non_matchings/code/code_800E8EA0/func_800E9250.s,func_800E9250,0x800E9250,0x44 asm/non_matchings/code/z_common_data/func_800E9360.s,func_800E9360,0x800E9360,0x20 asm/non_matchings/code/z_debug/GameInfo_Init.s,GameInfo_Init,0x800E93E0,0x24 -asm/non_matchings/code/z_debug_display/func_800E9470.s,func_800E9470,0x800E9470,0x6 +asm/non_matchings/code/z_debug_display/DebugDisplay_Init.s,DebugDisplay_Init,0x800E9470,0x6 asm/non_matchings/code/z_debug_display/DebugDisplay_AddObject.s,DebugDisplay_AddObject,0x800E9488,0x37 asm/non_matchings/code/z_debug_display/DebugDisplay_DrawObjects.s,DebugDisplay_DrawObjects,0x800E9564,0x24 asm/non_matchings/code/z_debug_display/func_800E95F4.s,func_800E95F4,0x800E95F4,0x79 @@ -2122,23 +2122,23 @@ asm/non_matchings/code/z_skelanime/SkelAnime_UpdateTranslation.s,SkelAnime_Updat asm/non_matchings/code/z_skelanime/Animation_OnFrame.s,Animation_OnFrame,0x801378B8,0xA asm/non_matchings/code/z_skelanime/SkelAnime_Free.s,SkelAnime_Free,0x801378E0,0x13 asm/non_matchings/code/z_skelanime/SkelAnime_CopyFrameTable.s,SkelAnime_CopyFrameTable,0x8013792C,0x11 -asm/non_matchings/code/z_skin/func_80137970.s,func_80137970,0x80137970,0x71 -asm/non_matchings/code/z_skin/func_80137B34.s,func_80137B34,0x80137B34,0xE2 -asm/non_matchings/code/z_skin/func_80137EBC.s,func_80137EBC,0x80137EBC,0x27 -asm/non_matchings/code/z_skin/func_80137F58.s,func_80137F58,0x80137F58,0x3E -asm/non_matchings/code/z_skin/func_80138050.s,func_80138050,0x80138050,0x76 +asm/non_matchings/code/z_skin/Skin_UpdateVertices.s,Skin_UpdateVertices,0x80137970,0x71 +asm/non_matchings/code/z_skin/Skin_ApplyLimbModifications.s,Skin_ApplyLimbModifications,0x80137B34,0xE2 +asm/non_matchings/code/z_skin/Skin_DrawAnimatedLimb.s,Skin_DrawAnimatedLimb,0x80137EBC,0x27 +asm/non_matchings/code/z_skin/Skin_DrawLimb.s,Skin_DrawLimb,0x80137F58,0x3E +asm/non_matchings/code/z_skin/Skin_DrawImpl.s,Skin_DrawImpl,0x80138050,0x76 asm/non_matchings/code/z_skin/func_80138228.s,func_80138228,0x80138228,0xC asm/non_matchings/code/z_skin/func_80138258.s,func_80138258,0x80138258,0xD asm/non_matchings/code/z_skin/func_8013828C.s,func_8013828C,0x8013828C,0xE asm/non_matchings/code/z_skin/func_801382C4.s,func_801382C4,0x801382C4,0xF -asm/non_matchings/code/z_skin/func_80138300.s,func_80138300,0x80138300,0x17 -asm/non_matchings/code/z_skin/func_8013835C.s,func_8013835C,0x8013835C,0x2D -asm/non_matchings/code/z_skin_awb/func_80138410.s,func_80138410,0x80138410,0x5 -asm/non_matchings/code/z_skin_awb/func_80138424.s,func_80138424,0x80138424,0x5E -asm/non_matchings/code/z_skin_awb/func_8013859C.s,func_8013859C,0x8013859C,0x59 -asm/non_matchings/code/z_skin_awb/func_80138700.s,func_80138700,0x80138700,0x35 +asm/non_matchings/code/z_skin/Skin_GetLimbPos.s,Skin_GetLimbPos,0x80138300,0x17 +asm/non_matchings/code/z_skin/Skin_GetVertexPos.s,Skin_GetVertexPos,0x8013835C,0x2D +asm/non_matchings/code/z_skin_awb/Skin_Setup.s,Skin_Setup,0x80138410,0x5 +asm/non_matchings/code/z_skin_awb/Skin_InitAnimatedLimb.s,Skin_InitAnimatedLimb,0x80138424,0x5E +asm/non_matchings/code/z_skin_awb/Skin_Init.s,Skin_Init,0x8013859C,0x59 +asm/non_matchings/code/z_skin_awb/Skin_Free.s,Skin_Free,0x80138700,0x35 asm/non_matchings/code/z_skin_awb/func_801387D4.s,func_801387D4,0x801387D4,0x44 -asm/non_matchings/code/z_skin_awb/func_801388E4.s,func_801388E4,0x801388E4,0xAF +asm/non_matchings/code/z_skin_awb/Skin_ApplyAnimTransformations.s,Skin_ApplyAnimTransformations,0x801388E4,0xAF asm/non_matchings/code/z_skin_matrix/SkinMatrix_Vec3fMtxFMultXYZW.s,SkinMatrix_Vec3fMtxFMultXYZW,0x80138BA0,0x3A asm/non_matchings/code/z_skin_matrix/SkinMatrix_Vec3fMtxFMultXYZ.s,SkinMatrix_Vec3fMtxFMultXYZ,0x80138C88,0x2C asm/non_matchings/code/z_skin_matrix/SkinMatrix_MtxFMtxFMult.s,SkinMatrix_MtxFMtxFMult,0x80138D38,0xD7 From b852a9a9300c05de4e01e71a578ca355b6793f91 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Thu, 24 Mar 2022 12:22:13 +1100 Subject: [PATCH 082/257] Audio_Load OK and Documented (#620) * Copy audio_load progress from main branch * Fix warning * fix UB * cleanup WIP * Add docs, bss still broken * bss fix * bytesRemaining with size_t * PR Suggestions * PR Suggestions * Fix bss * Fix bss * PR Suggestions --- include/functions.h | 137 +- include/macros.h | 1 + include/variables.h | 18 +- include/z64audio.h | 215 +-- spec | 2 - src/boot_O2_g3/yaz0.c | 4 +- src/boot_O2_g3/z_std_dma.c | 10 +- src/code/audio/audio_heap.c | 28 +- src/code/audio/audio_load.c | 2318 ++++++++++++++++++++++++++++-- src/code/audio/audio_playback.c | 4 +- src/code/audio/audio_seqplayer.c | 2 +- src/code/audio/code_80192BE0.c | 2 +- src/code/audioMgr.c | 2 +- src/code/z_collision_check.c | 1 + tools/disasm/functions.txt | 190 +-- tools/disasm/variables.txt | 2 +- tools/sizes/boot_functions.csv | 4 +- tools/sizes/code_functions.csv | 186 +-- 18 files changed, 2558 insertions(+), 568 deletions(-) diff --git a/include/functions.h b/include/functions.h index 16a2ea64b..4dccf9a5b 100644 --- a/include/functions.h +++ b/include/functions.h @@ -7,8 +7,8 @@ void bootproc(void); void Idle_ThreadEntry(void* arg); void ViConfig_UpdateVi(u32 arg0); void ViConfig_UpdateBlack(void); -s32 DmaMgr_DMARomToRam(u32 src, void* dst, size_t size); -void DmaMgr_DmaCallback0(OSPiHandle* piHandle, OSIoMesg* mb, s32 direction); +s32 DmaMgr_DmaRomToRam(u32 src, void* dst, size_t size); +s32 DmaMgr_DmaHandler(OSPiHandle* piHandle, OSIoMesg* mb, s32 direction); DmaEntry* DmaMgr_FindDmaEntry(u32 vromAddr); u32 DmaMgr_TranslateVromToRom(u32 vromAddr); s32 DmaMgr_FindDmaIndex(u32 vromAddr); @@ -3304,27 +3304,27 @@ s32 osFlashReadArray(OSIoMesg* mb, s32 priority, u32 pageNum, void* dramAddr, u3 // void func_8018B0F0(void); // void func_8018B10C(void); // void func_8018B250(void); -// void func_8018B318(void); +void AudioHeap_DiscardFont(s32 fontId); // void func_8018B474(void); -// void func_8018B4F8(void); +void* AudioHeap_WritebackDCache(void* mem, size_t size); // void func_8018B520(void); -// void func_8018B578(void); +void* AudioHeap_AllocAttemptExternal(AudioAllocPool* pool, size_t size); void* AudioHeap_AllocDmaMemory(AudioAllocPool* pool, u32 size); // void func_8018B608(void); -// void func_8018B640(void); +void* AudioHeap_AllocZeroed(AudioAllocPool* pool, size_t size); // void func_8018B69C(void); -// void func_8018B6E8(void); -// void func_8018B740(void); +void* AudioHeap_Alloc(AudioAllocPool* pool, size_t size); +void AudioHeap_AllocPoolInit(AudioAllocPool* pool, void* mem, size_t size); // void func_8018B768(void); // void func_8018B77C(void); // void func_8018B7BC(void); -// void func_8018B8FC(void); +void AudioHeap_InitMainPool(s32 initPoolSize); // void func_8018B95C(void); // void func_8018B9E0(void); // void func_8018BA64(void); // void func_8018BB28(void); -// void func_8018BBEC(void); -// void func_8018C380(void); +void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id); +void* AudioHeap_SearchCaches(s32 tableType, s32 cache, s32 id); // void func_8018C3D8(void); // void func_8018C8E8(void); // void func_8018C93C(void); @@ -3332,11 +3332,11 @@ void* AudioHeap_AllocDmaMemory(AudioAllocPool* pool, u32 size); // void func_8018CB70(void); // void func_8018CB78(void); // void func_8018CC3C(void); -// void func_8018CCA8(void); +s32 AudioHeap_ResetStep(void); // void func_8018CFAC(void); -// void func_8018D57C(void); -// void func_8018D5D4(void); -// void func_8018D658(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); +void* AudioHeap_SearchPermanentCache(s32 tableType, s32 id); +void* AudioHeap_AllocPermanent(s32 tableType, s32 id, size_t size); +void* AudioHeap_AllocSampleCache(size_t size, s32 fontId, void* sampleAddr, s8 medium, s32 cache); // void func_8018D6C8(void); // void func_8018D760(void); // void func_8018DA50(void); @@ -3347,84 +3347,39 @@ void* AudioHeap_AllocDmaMemory(AudioAllocPool* pool, u32 size); // void func_8018DDD4(void); // void func_8018DF24(void); // void func_8018DFE0(void); -// void func_8018E00C(void); +void AudioHeap_ApplySampleBankCache(s32 sampleBankId); // void func_8018E03C(void); // void func_8018E2A8(void); // void func_8018E344(void); // void func_8018E8C8(void); -// void func_8018EB60(void); -// void func_8018EC4C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8018EF88(void); -s32 AudioLoad_IsFontLoadComplete(s32 bankId); -// void func_8018F298(void); -// void func_8018F310(void); -// void func_8018F388(void); -// void func_8018F3B8(void); -// void func_8018F3E8(void); -// void func_8018F448(void); -// void func_8018F478(void); -// void func_8018F4D8(void); -// void func_8018F588(void); -// void func_8018F604(void); -// void func_8018F6F0(void); -// void func_8018F7C0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8018F7F8(void); -// void func_8018F83C(void); -// void func_8018F880(void); -// void func_8018F8C4(void); -// void func_8018F908(void); -// void func_8018F9B8(void); -// void func_8018FA60(void); -// void func_8018FAD0(void); -// void func_8018FB20(void); -// void func_8018FB78(void); -// void func_8018FCCC(void); -// void func_8018FD20(void); -// void func_8018FD40(void); -// void func_8018FE5C(void); -// void func_8018FF60(void); -// void func_80190204(void); -// void func_80190240(void); -// void func_80190294(void); -// void func_801902D8(void); -// void func_80190544(void); -// void func_80190668(void); -// void func_8019067C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_8019075C(void); -// void func_8019077C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80190B08(void); -void func_80190B38(void* callback); -// void func_80190B50(void); -// void func_80190BB0(void); -// void func_80190F50(void); -// void func_80190F64(void); -// void func_80191134(void); -// void func_801911CC(void); -// void func_80191240(void); -// void func_801913C8(void); -// void func_8019144C(void); -// void func_80191460(void); -// void func_80191568(void); -// void func_80191598(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_8019161C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_80191740(void); -// void func_80191864(void); -// void func_80191870(void); -// void func_801919AC(void); -// void func_80191B40(void); -// void func_80191BD0(void); -// void func_80191C40(void); -// void func_80191C54(void); -// void func_80191D94(void); -// void func_8019218C(void); -// void func_80192340(void); -// void func_80192388(void); -// void func_801924BC(void); -// void func_80192514(void); -// void func_80192990(void); -// void func_80192AE8(void); -// void func_80192B54(void); -// void func_80192BAC(void); +void AudioLoad_DecreaseSampleDmaTtls(void); +void* AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium); +void AudioLoad_InitSampleDmaBuffers(s32 numNotes); +s32 AudioLoad_IsFontLoadComplete(s32 fontId); +s32 AudioLoad_IsSeqLoadComplete(s32 seqId); +void AudioLoad_SetFontLoadStatus(s32 fontId, s32 status); +void AudioLoad_SetSeqLoadStatus(s32 seqId, s32 status); +void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1, s32 arg2, OSMesgQueue* arg3); +s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId); +void AudioLoad_AsyncLoadSeq(s32 seqId, s32 arg1, s32 retData, OSMesgQueue* retQueue); +void AudioLoad_AsyncLoadSampleBank(s32 sampleBankId, s32 arg1, s32 retData, OSMesgQueue* retQueue); +void AudioLoad_AsyncLoadFont(s32 fontId, s32 arg1, s32 retData, OSMesgQueue* retQueue); +u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts); +void AudioLoad_DiscardSeqFonts(s32 seqId); +void func_8018FA60(u32 tableType, u32 id, s32 arg2, s32 arg3); +s32 AudioLoad_SyncIniPlayer(s32 playerIdx, s32 seqId, s32 arg2); +s32 AudioLoad_SyncInitSetSeqqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 skipTicks); +void AudioLoad_ProcessLoads(s32 resetStatus); +void AudioLoad_SetDmaHandler(DmaHandler callback); +void AudioLoad_Init(void* heap, u32 heapSize); +void AudioLoad_InitSlowLoads(void); +s32 AudioLoad_SlowLoadSample(s32 fontId, s32 instId, s8* isDone); +s32 AudioLoad_SlowLoadSeq(s32 seqId, u8* ramAddr, s8* isDone); +void AudioLoad_InitAsyncLoads(void); +void AudioLoad_LoadPermanentSamples(void); +void AudioLoad_ScriptLoad(s32 tableType, s32 id, s8* isDone); +void AudioLoad_ProcessScriptLoads(void); +void AudioLoad_InitScriptLoads(void); AudioTask* func_80192BE0(void); // void func_80192C00(void); // void func_8019319C(void); @@ -3459,7 +3414,7 @@ AudioTask* func_80192BE0(void); // void func_80194548(void); // void func_80194568(void); // void func_80194668(void); -// void func_801946E4(void); +void Audio_InitMesgQueues(void); void Audio_InvalDCache(void* buf, size_t size); void Audio_WritebackDCache(void* buf, size_t size); // void func_80194790(void); @@ -3520,7 +3475,7 @@ void func_80199268(s32* param_1); // void func_8019A0BC(void); // void func_8019AA3C(void); // void func_8019AAF0(void); -// void func_8019AB40(void); +void AudioSeq_ResetSequencePlayer(SequencePlayer* seqPlayer); // void func_8019AC10(void); // void func_8019ACEC(void); // void func_8019ADBC(void); diff --git a/include/macros.h b/include/macros.h index d986dd78e..8b5ec577f 100644 --- a/include/macros.h +++ b/include/macros.h @@ -153,6 +153,7 @@ extern GraphicsContext* __gfxCtx; #define ALIGN8(val) (((val) + 7) & ~7) #define ALIGN16(val) (((val) + 0xF) & ~0xF) #define ALIGN64(val) (((val) + 0x3F) & ~0x3F) +#define ALIGN256(val) (((val) + 0xFF) & ~0xFF) #define SQ(x) ((x) * (x)) #define ABS(x) ((x) >= 0 ? (x) : -(x)) diff --git a/include/variables.h b/include/variables.h index b563d15cf..1f198a15b 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1656,7 +1656,7 @@ extern f32 gDefaultPanVolume[]; // extern UNK_TYPE1 D_801D5FD4; extern UNK_PTR D_801D5FE0; // extern UNK_TYPE1 D_801D5FE4; -// extern UNK_TYPE4 D_801D5FE8; +extern s32 gAudioContextInitalized; // extern UNK_TYPE4 D_801D5FEC; // extern UNK_TYPE4 D_801D5FF0; // extern UNK_TYPE4 D_801D5FF4; @@ -3070,10 +3070,10 @@ extern const s16 gAudioTatumInit[]; extern const AudioContextInitSizes gAudioContextInitSizes; // extern UNK_TYPE4 D_801E1108; // extern UNK_TYPE4 D_801E110C; -// extern UNK_TYPE2 gSoundFontTable; -// extern UNK_TYPE1 gSequenceFontTable; -// extern UNK_TYPE2 gSequenceTable; -// extern UNK_TYPE1 gSampleBankTable; +extern u8 gSoundFontTable[]; +extern u8 gSequenceFontTable[]; +extern u8 gSequenceTable[]; +extern u8 gSampleBankTable[]; extern u64 aspMainDataStart[]; // bss @@ -3593,10 +3593,10 @@ extern SoundRequest D_801FE7C0[1]; // extern UNK_TYPE1 D_80200BCE; // extern UNK_TYPE1 D_80200BD0; extern AudioContext gAudioContext; // at 0x80200C70 -// extern UNK_TYPE4 D_80208E68; -// extern UNK_TYPE4 D_80208E6C; -// extern UNK_TYPE4 D_80208E70; -// extern UNK_TYPE4 D_80208E74; +extern void (*D_80208E68)(void); +extern u32 (*D_80208E6C)(s8 value, SequenceChannel* channel); +extern s32 (*D_80208E70)(SoundFontSample*, s32, s8, s32); +extern Acmd* (*D_80208E74)(Acmd*, s32, s32); // post-code buffers extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; diff --git a/include/z64audio.h b/include/z64audio.h index db43aad48..ec0fcd797 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -49,11 +49,10 @@ typedef enum { typedef enum { /* 0 */ MEDIUM_RAM, - /* 1 */ MEDIUM_UNK1, + /* 1 */ MEDIUM_UNK, /* 2 */ MEDIUM_CART, /* 3 */ MEDIUM_DISK_DRIVE, - /* 4 */ MEDIUM_UNK4, - /* 5 */ MEDIUM_UNK5 + /* 5 */ MEDIUM_RAM_UNLOADED = 5 } SampleMedium; typedef enum { @@ -71,6 +70,14 @@ typedef enum { /* 2 */ SAMPLE_TABLE } SampleBankTableType; +typedef enum { + /* 0 */ CACHE_LOAD_PERMANENT, + /* 1 */ CACHE_LOAD_PERSISTENT, + /* 2 */ CACHE_LOAD_TEMPORARY, + /* 3 */ CACHE_LOAD_EITHER, + /* 4 */ CACHE_LOAD_EITHER_NOSYNC +} AudioCacheLoadType; + typedef enum { /* 0 */ CACHE_TEMPORARY, /* 1 */ CACHE_PERSISTENT, @@ -78,6 +85,15 @@ typedef enum { /* 3 */ CACHE_PERMANENT } AudioCacheType; +typedef enum { + /* 0 */ LOAD_STATUS_0, + /* 1 */ LOAD_STATUS_1, + /* 2 */ LOAD_STATUS_2, // Samples/Seqplayer + /* 3 */ LOAD_STATUS_3, // Sequences + /* 4 */ LOAD_STATUS_4, // SoundFonts + /* 5 */ LOAD_STATUS_5 // Permanent +} AudioLoadStatus; + typedef s32 (*DmaHandler)(OSPiHandle* handle, OSIoMesg* mb, s32 direction); struct Note; @@ -242,9 +258,9 @@ typedef struct { } SoundFont; // size = 0x14 typedef struct { - /* 0x00 */ u8* pc; + /* 0x00 */ u8* pc; // program counter /* 0x04 */ u8* stack[4]; - /* 0x14 */ u8 remLoopIters[4]; + /* 0x14 */ u8 remLoopIters[4]; // remaining loop iterations /* 0x18 */ u8 depth; /* 0x19 */ s8 value; } SeqScriptState; // size = 0x1C @@ -399,7 +415,7 @@ typedef struct SequenceChannel { /* 0x12 */ VibratoSubStruct vibrato; /* 0x20 */ u16 delay; /* 0x22 */ u16 unk_20; - /* 0x24 */ u16 unk_22; + /* 0x24 */ u16 unk_22; // Used for indexing data /* 0x26 */ s16 instOrWave; // either 0 (none), instrument index + 1, or // 0x80..0x83 for sawtooth/triangle/sine/square waves. /* 0x28 */ s16 transposition; @@ -623,32 +639,41 @@ typedef struct { /* 0x16 */ s16 lowPassFilterCutoffRight; } ReverbSettings; // size = 0x18 +/** + * The high-level audio specifications requested when initializing or resetting the audio heap. + * Most often resets during scene transitions, but will highly depend on game play. + */ typedef struct { - /* 0x00 */ u32 frequency; + /* 0x00 */ u32 samplingFreq; // Target sampling rate in Hz /* 0x04 */ u8 unk_04; /* 0x05 */ u8 numNotes; /* 0x06 */ u8 numSequencePlayers; /* 0x07 */ u8 unk_07[0x2]; // unused, set to zero /* 0x09 */ u8 numReverbs; - /* 0x0A */ u8 unk_0A[0x2]; /* 0x0C */ ReverbSettings* reverbSettings; /* 0x10 */ u16 sampleDmaBufSize1; /* 0x12 */ u16 sampleDmaBufSize2; /* 0x14 */ u16 unk_14; - /* 0x18 */ u32 persistentSeqMem; - /* 0x1C */ u32 persistentFontMem; - /* 0x20 */ u32 persistentSampleMem; - /* 0x24 */ u32 temporarySeqMem; - /* 0x28 */ u32 temporaryFontMem; - /* 0x2C */ u32 temporarySampleMem; - /* 0x30 */ s32 persistentSampleCacheMem; - /* 0x34 */ s32 temporarySampleCacheMem; + /* 0x18 */ size_t persistentSeqCacheSize; // size of cache on audio pool to store sequences persistently + /* 0x1C */ size_t persistentFontCacheSize; // size of cache on audio pool to store soundFonts persistently + /* 0x20 */ size_t persistentSampleBankCacheSize; // size of cache on audio pool to store entire sample banks persistently + /* 0x24 */ size_t temporarySeqCacheSize; // size of cache on audio pool to store sequences temporarily + /* 0x28 */ size_t temporaryFontCacheSize; // size of cache on audio pool to store soundFonts temporarily + /* 0x2C */ size_t temporarySampleBankCacheSize; // size of cache on audio pool to store entire sample banks temporarily + /* 0x30 */ size_t persistentSampleCacheSize; // size of cache on audio pool to store individual samples persistently + /* 0x34 */ size_t temporarySampleCacheSize; // size of cache on audio pool to store individual samples temporarily } AudioSpec; // size = 0x38 +/** + * The audio buffer stores the fully processed digital audio before it is sent to the audio interface (AI), then to the + * digital-analog converter (DAC), then to play on the speakers. The audio buffer is written to by the rsp after + * processing audio commands, and the audio buffer is read by AI which sends the data to the DAC. + * This struct parameterizes that buffer. + */ typedef struct { /* 0x00 */ s16 specUnk4; - /* 0x02 */ u16 frequency; - /* 0x04 */ u16 aiFrequency; + /* 0x02 */ u16 samplingFreq; // Target sampling rate in Hz + /* 0x04 */ u16 aiSamplingFreq; // True sampling rate set to the audio interface (AI) for the audio digital-analog converter (DAC) /* 0x06 */ s16 samplesPerFrameTarget; /* 0x08 */ s16 maxAiBufferLength; /* 0x0A */ s16 minAiBufferLength; @@ -663,20 +688,29 @@ typedef struct { /* 0x24 */ f32 unk_24; } AudioBufferParameters; // size = 0x28 +/** + * Meta-data associated with a pool (contain withing the Audio Heap) + */ typedef struct { - /* 0x0 */ u8* start; - /* 0x4 */ u8* cur; - /* 0x8 */ s32 size; - /* 0xC */ s32 count; + /* 0x0 */ u8* startAddr; // start addr of the pool + /* 0x4 */ u8* curAddr; // address of the next available memory for allocation + /* 0x8 */ size_t size; // size of the pool + /* 0xC */ s32 count; // number of entries allocated to the pool } AudioAllocPool; // size = 0x10 +/** + * Audio cache entry data to store a single entry containing either a sequence, soundfont, or entire sample banks + */ typedef struct { - /* 0x0 */ u8* ptr; - /* 0x4 */ u32 size; + /* 0x0 */ u8* addr; + /* 0x4 */ size_t size; /* 0x8 */ s16 tableType; /* 0xA */ s16 id; } AudioCacheEntry; // size = 0xC +/** + * Audio cache entry data to store a single entry containing an individual sample + */ typedef struct { /* 0x00 */ s8 inUse; /* 0x01 */ s8 origMedium; @@ -684,13 +718,16 @@ typedef struct { /* 0x03 */ char unk_03[0x5]; /* 0x08 */ u8* allocatedAddr; /* 0x0C */ void* sampleAddr; - /* 0x10 */ u32 size; + /* 0x10 */ size_t size; } SampleCacheEntry; // size = 0x14 +/** + * Audio cache entry data to store individual samples + */ typedef struct { /* 0x000 */ AudioAllocPool pool; /* 0x010 */ SampleCacheEntry entries[128]; - /* 0xA10 */ s32 size; + /* 0xA10 */ s32 numEntries; } AudioSampleCache; // size = 0xA14 typedef struct { @@ -712,22 +749,21 @@ typedef struct { } AudioCache; // size = 0x110 typedef struct { - /* 0x0 */ u32 wantPersistent; - /* 0x4 */ u32 wantTemporary; -} AudioPoolSplit2; // size = 0x8 + /* 0x0 */ size_t persistentCommonPoolSize; + /* 0x4 */ size_t temporaryCommonPoolSize; +} AudioCachePoolSplit; // size = 0x8 typedef struct { - /* 0x0 */ u32 wantSeq; - /* 0x4 */ u32 wantFont; - /* 0x8 */ u32 wantSample; -} AudioPoolSplit3; // size = 0xC + /* 0x0 */ size_t seqCacheSize; + /* 0x4 */ size_t fontCacheSize; + /* 0x8 */ size_t sampleBankCacheSize; +} AudioCommonPoolSplit; // size = 0xC typedef struct { - /* 0x0 */ u32 wantSeq; - /* 0x4 */ u32 wantFont; - /* 0x8 */ u32 wantSample; - /* 0xC */ u32 wantCustom; -} AudioPoolSplit4; // size = 0x10 + /* 0x0 */ size_t miscPoolSize; + /* 0x4 */ u32 unkSizes[2]; + /* 0xC */ size_t cachePoolSize; +} AudioSessionPoolSplit; // size = 0x10 typedef struct { /* 0x00 */ u32 endAndMediumKey; @@ -763,10 +799,10 @@ typedef struct { /* 0x01 */ s8 delay; /* 0x02 */ s8 medium; /* 0x04 */ u8* ramAddr; - /* 0x08 */ u32 curDevAddr; + /* 0x08 */ uintptr_t curDevAddr; /* 0x0C */ u8* curRamAddr; - /* 0x10 */ u32 bytesRemaining; - /* 0x14 */ u32 chunkSize; + /* 0x10 */ size_t bytesRemaining; + /* 0x14 */ size_t chunkSize; /* 0x18 */ s32 unkMediumParam; /* 0x1C */ u32 retMsg; /* 0x20 */ OSMesgQueue* retQueue; @@ -780,12 +816,12 @@ typedef struct { /* 0x01 */ u8 seqOrFontId; /* 0x02 */ u16 instId; /* 0x04 */ s32 unkMediumParam; - /* 0x08 */ s32 curDevAddr; + /* 0x08 */ uintptr_t curDevAddr; /* 0x0C */ u8* curRamAddr; /* 0x10 */ u8* ramAddr; /* 0x14 */ s32 status; - /* 0x18 */ s32 bytesRemaining; - /* 0x1C */ s8* isDone; + /* 0x18 */ size_t bytesRemaining; + /* 0x1C */ s8* isDone; // TODO: rename in OoT and sync up here. This is an external status while (s32 status) is an internal status /* 0x20 */ SoundFontSample sample; /* 0x30 */ OSMesgQueue msgqueue; /* 0x48 */ OSMesg msg; @@ -793,8 +829,8 @@ typedef struct { } AudioSlowLoad; // size = 0x64 typedef struct { - /* 0x00 */ u32 romAddr; - /* 0x04 */ u32 size; + /* 0x00 */ uintptr_t romAddr; + /* 0x04 */ size_t size; /* 0x08 */ s8 medium; /* 0x09 */ s8 cachePolicy; /* 0x0A */ s16 shortData1; @@ -805,7 +841,7 @@ typedef struct { typedef struct { /* 0x00 */ s16 numEntries; /* 0x02 */ s16 unkMediumParam; - /* 0x04 */ u32 romAddr; + /* 0x04 */ uintptr_t romAddr; /* 0x08 */ char pad[0x8]; /* 0x10 */ AudioTableEntry entries[1]; // (dynamic size) } AudioTable; // size >= 0x20 @@ -819,18 +855,18 @@ typedef struct { typedef struct { /* 0x00 */ u8* ramAddr; - /* 0x04 */ u32 devAddr; + /* 0x04 */ uintptr_t devAddr; /* 0x08 */ u16 sizeUnused; /* 0x0A */ u16 size; /* 0x0C */ u8 unused; /* 0x0D */ u8 reuseIndex; // position in sSampleDmaReuseQueue1/2, if ttl == 0 - /* 0x0E */ u8 ttl; // duration after which the DMA can be discarded + /* 0x0E */ u8 ttl; // Time To Live: duration after which the DMA can be discarded } SampleDma; // size = 0x10 typedef struct { /* 0x0000 */ char unk_0000; /* 0x0001 */ s8 numSynthesisReverbs; - /* 0x0002 */ u16 unk_2; + /* 0x0002 */ u16 unk_2; // reads from audio spec unk_14, never used, always set to 0x7FFF /* 0x0004 */ u16 unk_4; /* 0x0006 */ char unk_0006[0xA]; /* 0x0010 */ s16* curLoadedBook; @@ -862,13 +898,13 @@ typedef struct { /* 0x263C */ SampleDma* sampleDmas; /* 0x2640 */ u32 sampleDmaCount; /* 0x2644 */ u32 sampleDmaListSize1; - /* 0x2648 */ s32 unused2628; + /* 0x2648 */ s32 unused2648; /* 0x264C */ u8 sampleDmaReuseQueue1[0x100]; // read pos <= write pos, wrapping mod 256 /* 0x274C */ u8 sampleDmaReuseQueue2[0x100]; - /* 0x284C */ u8 sampleDmaReuseQueue1RdPos; - /* 0x284D */ u8 sampleDmaReuseQueue2RdPos; - /* 0x284E */ u8 sampleDmaReuseQueue1WrPos; - /* 0x284F */ u8 sampleDmaReuseQueue2WrPos; + /* 0x284C */ u8 sampleDmaReuseQueue1RdPos; // Read position for dma 1 + /* 0x284D */ u8 sampleDmaReuseQueue2RdPos; // Read position for dma 2 + /* 0x284E */ u8 sampleDmaReuseQueue1WrPos; // Write position for dma 1 + /* 0x284F */ u8 sampleDmaReuseQueue2WrPos; // Write position for dma 2 /* 0x2850 */ AudioTable* sequenceTable; /* 0x2854 */ AudioTable* soundFontTable; /* 0x2858 */ AudioTable* sampleBankTable; @@ -886,52 +922,52 @@ typedef struct { /* 0x28B8 */ s32 numNotes; /* 0x2898 */ s16 tempoInternalToExternal; /* 0x28BE */ s8 soundMode; - /* 0x28C0 */ s32 totalTaskCnt; + /* 0x28C0 */ s32 totalTaskCount; // The total number of times the top-level function on the audio thread is run since the last audio reset /* 0x28C4 */ s32 curAudioFrameDmaCount; - /* 0x28C8 */ s32 rspTaskIdx; - /* 0x28CC */ s32 curAIBufIdx; - /* 0x28AC */ Acmd* abiCmdBufs[2]; + /* 0x28C8 */ s32 rspTaskIndex; + /* 0x28CC */ s32 curAiBuffferIndex; + /* 0x28AC */ Acmd* abiCmdBufs[2]; // Pointer to audio heap where the audio binary interface command lists are stored. Two lists that alternative every frame /* 0x28B4 */ Acmd* curAbiCmdBuf; - /* 0x28DC */ AudioTask* currTask; + /* 0x28DC */ AudioTask* curTask; /* 0x28C0 */ AudioTask rspTask[2]; /* 0x2980 */ f32 unk_2960; /* 0x2984*/ s32 refreshRate; - /* 0x2988 */ s16* aiBuffers[3]; - /* 0x2994 */ s16 aiBufLengths[3]; + /* 0x2988 */ s16* aiBuffers[3]; // Pointers to the audio buffer allocated on the initPool contained in the audio heap. Stores fully processed digital audio before transferring to the audio interface (AI) + /* 0x2994 */ s16 aiBufLengths[3]; // Number of bytes to transfer to the audio interface buffer /* 0x299C */ u32 audioRandom; /* 0x29A0 */ s32 audioErrorFlags; /* 0x29A4 */ volatile u32 resetTimer; /* 0x29A8 */ u32 (*unk_29A8[4])(s8 value, SequenceChannel* channel); /* 0x29B8 */ s8 unk_29B8; /* 0x29BC */ s32 unk_29BC; // sMaxAbiCmdCnt - /* 0x29C0 */ AudioAllocPool audioSessionPool; - /* 0x29D0 */ AudioAllocPool externalPool; - /* 0x29E0 */ AudioAllocPool audioInitPool; - /* 0x29F0 */ AudioAllocPool notesAndBuffersPool; + /* 0x29C0 */ AudioAllocPool audioSessionPool; // A sub-pool to main pool, contains all sub-pools and data that changes every audio reset + /* 0x29D0 */ AudioAllocPool externalPool; // pool allocated on an external device. Never used in game + /* 0x29E0 */ AudioAllocPool audioInitPool; // A sub-pool to the main pool, contains all sub-pools and data that persists every audio reset + /* 0x29F0 */ AudioAllocPool miscPool; // A sub-pool to the session pool, /* 0x2A00 */ char unk_29D0[0x20]; // probably two unused pools - /* 0x2A20 */ AudioAllocPool cachePool; - /* 0x2A30 */ AudioAllocPool persistentCommonPool; - /* 0x2A40 */ AudioAllocPool temporaryCommonPool; - /* 0x2A50 */ AudioCache seqCache; - /* 0x2B60 */ AudioCache fontCache; - /* 0x2C70 */ AudioCache sampleBankCache; - /* 0x2D80 */ AudioAllocPool permanentPool; - /* 0x2D90 */ AudioCacheEntry permanentCache[32]; - /* 0x3690 */ AudioSampleCache persistentSampleCache; - /* 0x40A4 */ AudioSampleCache temporarySampleCache; - /* 0x4338 */ AudioPoolSplit4 sessionPoolSplit; - /* 0x4348 */ AudioPoolSplit2 cachePoolSplit; - /* 0x4350 */ AudioPoolSplit3 persistentCommonPoolSplit; - /* 0x435C */ AudioPoolSplit3 temporaryCommonPoolSplit; + /* 0x2A20 */ AudioAllocPool cachePool; // The common pool for all cache entries + /* 0x2A30 */ AudioAllocPool persistentCommonPool; // A sub-pool to the cache pool, contains all caches for data stored persistently + /* 0x2A40 */ AudioAllocPool temporaryCommonPool; // A sub-pool to the cache pool, contains all caches for data stored temporarily + /* 0x2A50 */ AudioCache seqCache; // Cache to store sequences + /* 0x2B60 */ AudioCache fontCache; // Cache to store soundFonts + /* 0x2C70 */ AudioCache sampleBankCache; // Cache for loading entire sample banks + /* 0x2D80 */ AudioAllocPool permanentPool; // Pool to stores audio data that is always loaded in. Primarily used for sfxs + /* 0x2D90 */ AudioCacheEntry permanentEntries[32]; // indificual entries to the permanent pool + /* 0x3690 */ AudioSampleCache persistentSampleCache; // Stores individual samples persistently + /* 0x40A4 */ AudioSampleCache temporarySampleCache; // Stores individual samples temporarily + /* 0x4338 */ AudioSessionPoolSplit sessionPoolSplit; // splits session pool into the cache pool and misc pool + /* 0x4348 */ AudioCachePoolSplit cachePoolSplit; // splits cache pool into the persistent & temporary common pools + /* 0x4350 */ AudioCommonPoolSplit persistentCommonPoolSplit; // splits persistent common pool into caches for sequences, soundFonts, sample banks + /* 0x435C */ AudioCommonPoolSplit temporaryCommonPoolSplit; // splits temporary common pool into caches for sequences, soundFonts, sample banks /* 0x4368 */ u8 sampleFontLoadStatus[0x30]; /* 0x4398 */ u8 fontLoadStatus[0x30]; /* 0x43C8 */ u8 seqLoadStatus[0x80]; /* 0x4448 */ volatile u8 resetStatus; /* 0x4449 */ u8 audioResetSpecIdToLoad; /* 0x444C */ s32 audioResetFadeOutFramesLeft; - /* 0x4450 */ f32* unk_3520; + /* 0x4450 */ f32* unk_3520; // fadeOutVelocities for ADSR /* 0x4454 */ u8* audioHeap; - /* 0x4458 */ u32 audioHeapSize; + /* 0x4458 */ size_t audioHeapSize; /* 0x445C */ Note* notes; /* 0x4460 */ SequencePlayer seqPlayers[5]; /* 0x4B40 */ SequenceLayer sequenceLayers[80]; @@ -939,11 +975,10 @@ typedef struct { /* 0x7924 */ s32 noteSubEuOffset; /* 0x7928 */ AudioListItem layerFreeList; /* 0x7938 */ NotePool noteFreeLists; - /* 0x7978 */ u8 cmdWrPos; - /* 0x7979 */ u8 cmdRdPos; + /* 0x7978 */ u8 cmdWritePos; + /* 0x7979 */ u8 cmdReadPos; /* 0x797A */ u8 cmdQueueFinished; - /* 0x797C */ u16 unk_5BDC[4]; - /* 0x7984 */ char unk_7984[4]; + /* 0x797C */ u16 activeChannelsFlags[5]; // bitwise flag for 16 channels. Only channels with bit turned on will be processed /* 0x7988 */ OSMesgQueue* audioResetQueueP; /* 0x798C */ OSMesgQueue* taskStartQueueP; /* 0x7990 */ OSMesgQueue* cmdProcQueueP; @@ -953,7 +988,7 @@ typedef struct { /* 0x79DC */ OSMesg taskStartMsgs[1]; /* 0x79E0 */ OSMesg audioResetMesgs[1]; /* 0x79E4 */ OSMesg cmdProcMsgs[4]; - /* 0x79F4 */ AudioCmd cmdBuf[0x100]; + /* 0x79F4 */ AudioCmd cmdBuf[0x100]; // Audio commands used to transfer audio requests from the graph thread to the audio thread /* 0x81F4 */ char unk_81F4[4]; } AudioContext; // size = 0x81F8 @@ -972,9 +1007,9 @@ typedef struct { } NoteSubAttributes; // size = 0x1A typedef struct { - /* 0x0 */ u32 heapSize; - /* 0x4 */ u32 initPoolSize; - /* 0x8 */ u32 permanentPoolSize; + /* 0x0 */ size_t heapSize; // total number of bytes allocated to the audio heap. Must be <= the size of `gAudioHeap` (ideally about the same size) + /* 0x4 */ size_t mainPoolSplitSize; // The entire audio heap is split into two pools. + /* 0x8 */ size_t permanentPoolSize; } AudioContextInitSizes; // size = 0xC typedef struct { diff --git a/spec b/spec index e4be4114e..04fd18b85 100644 --- a/spec +++ b/spec @@ -623,8 +623,6 @@ beginseg include "build/src/code/audio/audio_heap.o" include "build/data/code/audio_heap.bss.o" include "build/src/code/audio/audio_load.o" - include "build/data/code/audio_load.data.o" - include "build/data/code/audio_load.bss.o" include "build/src/code/audio/code_80192BE0.o" include "build/data/code/code_80192BE0.data.o" include "build/src/code/audio/audio_dcache.o" diff --git a/src/boot_O2_g3/yaz0.c b/src/boot_O2_g3/yaz0.c index 5fb32b8ea..5f8e5a0ed 100644 --- a/src/boot_O2_g3/yaz0.c +++ b/src/boot_O2_g3/yaz0.c @@ -18,7 +18,7 @@ void* Yaz0_FirstDMA() { curSize = (u32)sYaz0CurDataEnd - (u32)sYaz0DataBuffer; dmaSize = (curSize > sYaz0CurSize) ? sYaz0CurSize : curSize; - DmaMgr_DMARomToRam(sYaz0CurRomStart, sYaz0DataBuffer, dmaSize); + DmaMgr_DmaRomToRam(sYaz0CurRomStart, sYaz0DataBuffer, dmaSize); sYaz0CurRomStart += dmaSize; sYaz0CurSize -= dmaSize; return sYaz0DataBuffer; @@ -41,7 +41,7 @@ void* Yaz0_NextDMA(void* curSrcPos) { } if (dmaSize != 0) { - DmaMgr_DMARomToRam(sYaz0CurRomStart, dst + restSize, dmaSize); + DmaMgr_DmaRomToRam(sYaz0CurRomStart, dst + restSize, dmaSize); sYaz0CurRomStart += dmaSize; sYaz0CurSize -= dmaSize; if (!sYaz0CurSize) { diff --git a/src/boot_O2_g3/z_std_dma.c b/src/boot_O2_g3/z_std_dma.c index 9edc65e52..10d84dcb0 100644 --- a/src/boot_O2_g3/z_std_dma.c +++ b/src/boot_O2_g3/z_std_dma.c @@ -10,7 +10,7 @@ OSMesg sDmaMgrMsgs[32]; OSThread sDmaMgrThread; u8 sDmaMgrStack[0x500]; -s32 DmaMgr_DMARomToRam(uintptr_t rom, void* ram, size_t size) { +s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, size_t size) { OSIoMesg ioMsg; OSMesgQueue queue; OSMesg msg[1]; @@ -56,8 +56,8 @@ END: return ret; } -void DmaMgr_DmaCallback0(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { - osEPiStartDma(pihandle, mb, direction); +s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { + return osEPiStartDma(pihandle, mb, direction); } DmaEntry* DmaMgr_FindDmaEntry(u32 vrom) { @@ -130,7 +130,7 @@ void DmaMgr_ProcessMsg(DmaRequest* req) { if (dmaEntry->vromEnd < (vrom + size)) { Fault_AddHungupAndCrash("../z_std_dma.c", 499); } - DmaMgr_DMARomToRam((dmaEntry->romStart + vrom) - dmaEntry->vromStart, (u8*)ram, size); + DmaMgr_DmaRomToRam((dmaEntry->romStart + vrom) - dmaEntry->vromStart, (u8*)ram, size); return; } @@ -211,7 +211,7 @@ s32 DmaMgr_SendRequest0(void* vramStart, uintptr_t vromStart, size_t size) { } void DmaMgr_Start(void) { - DmaMgr_DMARomToRam(SEGMENT_ROM_START(dmadata), dmadata, SEGMENT_ROM_SIZE(dmadata)); + DmaMgr_DmaRomToRam(SEGMENT_ROM_START(dmadata), dmadata, SEGMENT_ROM_SIZE(dmadata)); { DmaEntry* iter = dmadata; diff --git a/src/code/audio/audio_heap.c b/src/code/audio/audio_heap.c index b3d83c1f9..70c737930 100644 --- a/src/code/audio/audio_heap.c +++ b/src/code/audio/audio_heap.c @@ -6,29 +6,29 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B250.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B318.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_DiscardFont.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B3FC.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B474.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B4F8.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_WritebackDCache.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B520.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B578.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_AllocAttemptExternal.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemory.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B608.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B640.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_AllocZeroed.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B69C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B6E8.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_Alloc.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B740.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_AllocPoolInit.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B768.s") @@ -38,7 +38,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B7BC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B8FC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_InitMainPool.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B95C.s") @@ -48,9 +48,9 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018BB28.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018BBEC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_AllocCached.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C380.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_SearchCaches.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C3D8.s") @@ -70,15 +70,15 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CC3C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CCA8.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_ResetStep.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CFAC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D57C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_SearchPermanentCache.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D5D4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_AllocPermanent.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D658.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_AllocSampleCache.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D6C8.s") @@ -100,7 +100,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DFE0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E00C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_ApplySampleBankCache.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E03C.s") diff --git a/src/code/audio/audio_load.c b/src/code/audio/audio_load.c index 497f9d47a..b63f8192b 100644 --- a/src/code/audio/audio_load.c +++ b/src/code/audio/audio_load.c @@ -1,161 +1,2161 @@ +/** + * @file audio_load.c + * + * Implements the transfer of audio data from the cartridge to the audio heap. + * + * The audio data in ROM consists of: + * 1) Sequences stored as a midi-based script called the music-macro language (.mus files) + * 2) SoundFonts stored as various sound-font structs bundled togther in a custom way + * that is extracted through relocs (See SoundFontData, generic .o files) + * 3) Samples consisting of raw soundbytes stored using a compressed ADPCM algorithm (.aifc files) + */ + #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018EB60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018EC4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/D_801E030C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018EF88.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/AudioLoad_IsFontLoadComplete.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F298.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F310.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F388.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F3B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F3E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F448.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F478.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F4D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F588.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F604.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F6F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F7C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F7F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F83C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F880.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F8C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F908.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F9B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FA60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FAD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FB20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FB78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FCCC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FD20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FD40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FE5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FF60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190204.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190240.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190294.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801902D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190544.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190668.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019067C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190754.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019075C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019077C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190B08.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190B38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190B44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190B50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190BB0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190F50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190F64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191134.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801911C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801911CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191240.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801913C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019144C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191460.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191568.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191598.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019161C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191740.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191864.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191870.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801919AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191B40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191BD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191C40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191C54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191D94.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019218C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192340.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192388.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801924BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192514.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192990.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192AD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192AD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192AE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192AE8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192B54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192BAC.s") +/** + * SoundFont Notes: + * + */ +// opaque type for unpatched sound font data (should maybe get rid of this?) +typedef void SoundFontData; + +typedef struct { + /* 0x00 */ s32 sampleBankId1; + /* 0x04 */ s32 sampleBankId2; + /* 0x08 */ uintptr_t baseAddr1; + /* 0x0C */ uintptr_t baseAddr2; + /* 0x10 */ u32 medium1; + /* 0x14 */ u32 medium2; +} AudioRelocInfo; // size = 0x18 + +void AudioLoad_DiscardFont(s32 fontId); +s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2); +u8* AudioLoad_SyncLoadSeq(s32 seqId); +u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad); +SoundFontData* AudioLoad_SyncLoadFont(u32 fontId); +void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate); +u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id); +void* AudioLoad_SearchCaches(s32 tableType, s32 id); +AudioTable* AudioLoad_GetLoadTable(s32 tableType); +void AudioLoad_SyncDma(uintptr_t devAddr, u8* addr, size_t size, s32 medium); +void AudioLoad_SyncDmaUnkMedium(uintptr_t devAddr, u8* addr, size_t size, s32 unkMediumParam); +s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, uintptr_t devAddr, void* ramAddr, size_t size, + OSMesgQueue* reqQueue, s32 medium, const char* dmaFuncType); +void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue); +SoundFontSample* AudioLoad_GetFontSample(s32 fontId, s32 instId); +void AudioLoad_ProcessSlowLoads(s32 resetStatus); +void AudioLoad_DmaSlowCopy(AudioSlowLoad* slowLoad, size_t size); +void AudioLoad_DmaSlowCopyUnkMedium(intptr_t devAddr, intptr_t ramAddr, size_t size, s32 arg3); +AudioAsyncLoad* AudioLoad_StartAsyncLoadUnkMedium(s32 unkMediumParam, uintptr_t devAddr, void* ramAddr, size_t size, + s32 medium, s32 nChunks, OSMesgQueue* retQueue, s32 retMsg); +AudioAsyncLoad* AudioLoad_StartAsyncLoad(uintptr_t devAddr, void* ramAddr, size_t size, s32 medium, s32 nChunks, + OSMesgQueue* retQueue, s32 retMsg); +void AudioLoad_ProcessAsyncLoads(s32 resetStatus); +void AudioLoad_ProcessAsyncLoadUnkMedium(AudioAsyncLoad* asyncLoad, s32 resetStatus); +void AudioLoad_ProcessAsyncLoad(AudioAsyncLoad* asyncLoad, s32 resetStatus); +void AudioLoad_AsyncDma(AudioAsyncLoad* asyncLoad, size_t size); +void AudioLoad_AsyncDmaRamUnloaded(AudioAsyncLoad* asyncLoad, size_t size); +void AudioLoad_AsyncDmaUnkMedium(uintptr_t devAddr, void* ramAddr, size_t size, s16 arg3); +void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* fontData, AudioRelocInfo* relocInfo); +void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* fontData, AudioRelocInfo* relocInfo, s32 async); +s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus); + +#define MK_ASYNC_MSG(retData, tableType, id, loadStatus) \ + (((retData) << 24) | ((tableType) << 16) | ((id) << 8) | (loadStatus)) + +#define ASYNC_TBLTYPE(v) ((u8)(v >> 16)) +#define ASYNC_ID(v) ((u8)(v >> 8)) +#define ASYNC_STATUS(v) ((u8)(v >> 0)) + +typedef enum { + /* 0 */ LOAD_STATUS_WAITING, + /* 1 */ LOAD_STATUS_START, + /* 2 */ LOAD_STATUS_LOADING, + /* 3 */ LOAD_STATUS_DONE +} SlowLoadStatus; + +#define OS_MESG_PRI_NORMAL 0 +#define OS_MESG_PRI_HIGH 1 + +typedef struct { + u16 numInstruments; + u16 numDrums; + u16 numSfx; +} UnloadedFonts; + +OSMesgQueue sScriptLoadQueue; +OSMesg sScriptLoadMesgBuf[0x10]; +s8* sScriptLoadDonePointers[0x10]; +s32 sAudioLoadPad1[2]; // file padding +s32 D_801FD1E0; + +DmaHandler sDmaHandler = osEPiStartDma; +void* sUnusedHandler = NULL; +s32 gAudioContextInitalized = false; + +void AudioLoad_DecreaseSampleDmaTtls(void) { + u32 i; + + for (i = 0; i < gAudioContext.sampleDmaListSize1; i++) { + SampleDma* dma = &gAudioContext.sampleDmas[i]; + + if (dma->ttl != 0) { + dma->ttl--; + if (dma->ttl == 0) { + dma->reuseIndex = gAudioContext.sampleDmaReuseQueue1WrPos; + gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1WrPos] = i; + gAudioContext.sampleDmaReuseQueue1WrPos++; + } + } + } + + for (i = gAudioContext.sampleDmaListSize1; i < gAudioContext.sampleDmaCount; i++) { + SampleDma* dma = &gAudioContext.sampleDmas[i]; + + if (dma->ttl != 0) { + dma->ttl--; + if (dma->ttl == 0) { + dma->reuseIndex = gAudioContext.sampleDmaReuseQueue2WrPos; + gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2WrPos] = i; + gAudioContext.sampleDmaReuseQueue2WrPos++; + } + } + } + + gAudioContext.unused2648 = 0; +} + +void* AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium) { + s32 pad1; + SampleDma* dma; + s32 hasDma = false; + uintptr_t dmaDevAddr; + u32 pad2; + u32 dmaIndex; + u32 transfer; + s32 bufferPos; + u32 i; + + if (arg2 != 0 || *dmaIndexRef >= gAudioContext.sampleDmaListSize1) { + for (i = gAudioContext.sampleDmaListSize1; i < gAudioContext.sampleDmaCount; i++) { + dma = &gAudioContext.sampleDmas[i]; + bufferPos = devAddr - dma->devAddr; + if (0 <= bufferPos && ((u32)bufferPos <= dma->size - size)) { + // We already have a DMA request for this memory range. + if (dma->ttl == 0 && + gAudioContext.sampleDmaReuseQueue2RdPos != gAudioContext.sampleDmaReuseQueue2WrPos) { + // Move the DMA out of the reuse queue, by swapping it with the + // read pos, and then incrementing the read pos. + if (dma->reuseIndex != gAudioContext.sampleDmaReuseQueue2RdPos) { + gAudioContext.sampleDmaReuseQueue2[dma->reuseIndex] = + gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2RdPos]; + gAudioContext + .sampleDmas[gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2RdPos]] + .reuseIndex = dma->reuseIndex; + } + gAudioContext.sampleDmaReuseQueue2RdPos++; + } + dma->ttl = 32; + *dmaIndexRef = (u8)i; + return dma->ramAddr + (devAddr - dma->devAddr); + } + } + + if (arg2 == 0) { + goto search_short_lived; + } + + if (gAudioContext.sampleDmaReuseQueue2RdPos != gAudioContext.sampleDmaReuseQueue2WrPos && arg2 != 0) { + // Allocate a DMA from reuse queue 2, unless full. + dmaIndex = gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2RdPos]; + gAudioContext.sampleDmaReuseQueue2RdPos++; + dma = gAudioContext.sampleDmas + dmaIndex; + hasDma = true; + } + } else { + search_short_lived: + dma = gAudioContext.sampleDmas + *dmaIndexRef; + i = 0; + again: + bufferPos = devAddr - dma->devAddr; + if (0 <= bufferPos && (u32)bufferPos <= dma->size - size) { + // We already have DMA for this memory range. + if (dma->ttl == 0) { + // Move the DMA out of the reuse queue, by swapping it with the + // read pos, and then incrementing the read pos. + if (dma->reuseIndex != gAudioContext.sampleDmaReuseQueue1RdPos) { + gAudioContext.sampleDmaReuseQueue1[dma->reuseIndex] = + gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1RdPos]; + gAudioContext + .sampleDmas[gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1RdPos]] + .reuseIndex = dma->reuseIndex; + } + gAudioContext.sampleDmaReuseQueue1RdPos++; + } + dma->ttl = 2; + return dma->ramAddr + (devAddr - dma->devAddr); + } + dma = gAudioContext.sampleDmas + i++; + if (i <= gAudioContext.sampleDmaListSize1) { + goto again; + } + } + + if (!hasDma) { + if (gAudioContext.sampleDmaReuseQueue1RdPos == gAudioContext.sampleDmaReuseQueue1WrPos) { + return NULL; + } + // Allocate a DMA from reuse queue 1. + dmaIndex = gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1RdPos++]; + dma = gAudioContext.sampleDmas + dmaIndex; + hasDma = true; + } + + transfer = dma->size; + dmaDevAddr = devAddr & ~0xF; + dma->ttl = 3; + dma->devAddr = dmaDevAddr; + dma->sizeUnused = transfer; + AudioLoad_Dma(&gAudioContext.currAudioFrameDmaIoMesgBuf[gAudioContext.curAudioFrameDmaCount++], OS_MESG_PRI_NORMAL, + OS_READ, dmaDevAddr, dma->ramAddr, transfer, &gAudioContext.currAudioFrameDmaQueue, medium, + "SUPERDMA"); + *dmaIndexRef = dmaIndex; + return (devAddr - dmaDevAddr) + dma->ramAddr; +} + +// This string does not appear to belong in context to any function between the previous string and the next string +const char D_801E030C[] = "TYPE %d:ID %d is not External Map.\n"; + +void AudioLoad_InitSampleDmaBuffers(s32 numNotes) { + SampleDma* dma; + s32 i; + s32 t2; + s32 j; + + gAudioContext.sampleDmaBufSize = gAudioContext.sampleDmaBufSize1; + gAudioContext.sampleDmas = + AudioHeap_Alloc(&gAudioContext.miscPool, + 4 * gAudioContext.numNotes * sizeof(SampleDma) * gAudioContext.audioBufferParameters.specUnk4); + t2 = 3 * gAudioContext.numNotes * gAudioContext.audioBufferParameters.specUnk4; + + // First 3/4 sampleDmas + for (i = 0; i < t2; i++) { + dma = &gAudioContext.sampleDmas[gAudioContext.sampleDmaCount]; + dma->ramAddr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, gAudioContext.sampleDmaBufSize); + if (dma->ramAddr == NULL) { + break; + } else { + AudioHeap_WritebackDCache(dma->ramAddr, gAudioContext.sampleDmaBufSize); + dma->size = gAudioContext.sampleDmaBufSize; + dma->devAddr = 0; + dma->sizeUnused = 0; + dma->unused = 0; + dma->ttl = 0; + gAudioContext.sampleDmaCount++; + } + } + + for (i = 0; (u32)i < gAudioContext.sampleDmaCount; i++) { + gAudioContext.sampleDmaReuseQueue1[i] = i; + gAudioContext.sampleDmas[i].reuseIndex = i; + } + + for (i = gAudioContext.sampleDmaCount; i < 0x100; i++) { + gAudioContext.sampleDmaReuseQueue1[i] = 0; + } + + gAudioContext.sampleDmaReuseQueue1RdPos = 0; + gAudioContext.sampleDmaReuseQueue1WrPos = gAudioContext.sampleDmaCount; + gAudioContext.sampleDmaListSize1 = gAudioContext.sampleDmaCount; + gAudioContext.sampleDmaBufSize = gAudioContext.sampleDmaBufSize2; + + for (j = 0; j < gAudioContext.numNotes; j++) { + dma = &gAudioContext.sampleDmas[gAudioContext.sampleDmaCount]; + dma->ramAddr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, gAudioContext.sampleDmaBufSize); + if (dma->ramAddr == NULL) { + break; + } else { + AudioHeap_WritebackDCache(dma->ramAddr, gAudioContext.sampleDmaBufSize); + dma->size = gAudioContext.sampleDmaBufSize; + dma->devAddr = 0U; + dma->sizeUnused = 0; + dma->unused = 0; + dma->ttl = 0; + gAudioContext.sampleDmaCount++; + } + } + + for (i = gAudioContext.sampleDmaListSize1; (u32)i < gAudioContext.sampleDmaCount; i++) { + gAudioContext.sampleDmaReuseQueue2[i - gAudioContext.sampleDmaListSize1] = i; + gAudioContext.sampleDmas[i].reuseIndex = i - gAudioContext.sampleDmaListSize1; + } + + for (i = gAudioContext.sampleDmaCount; i < 0x100; i++) { + gAudioContext.sampleDmaReuseQueue2[i] = gAudioContext.sampleDmaListSize1; + } + + gAudioContext.sampleDmaReuseQueue2RdPos = 0; + gAudioContext.sampleDmaReuseQueue2WrPos = gAudioContext.sampleDmaCount - gAudioContext.sampleDmaListSize1; +} + +s32 AudioLoad_IsFontLoadComplete(s32 fontId) { + if (fontId == 0xFF) { + return true; + } else if (gAudioContext.fontLoadStatus[fontId] >= LOAD_STATUS_2) { + return true; + } else if (gAudioContext.fontLoadStatus[AudioLoad_GetRealTableIndex(FONT_TABLE, fontId)] >= LOAD_STATUS_2) { + return true; + } else { + return false; + } +} + +s32 AudioLoad_IsSeqLoadComplete(s32 seqId) { + if (seqId == 0xFF) { + return true; + } else if (gAudioContext.seqLoadStatus[seqId] >= LOAD_STATUS_2) { + return true; + } else if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] >= LOAD_STATUS_2) { + return true; + } else { + return false; + } +} + +s32 AudioLoad_IsSampleLoadComplete(s32 sampleBankId) { + if (sampleBankId == 0xFF) { + return true; + } else if (gAudioContext.sampleFontLoadStatus[sampleBankId] >= LOAD_STATUS_2) { + return true; + } else if (gAudioContext.sampleFontLoadStatus[AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankId)] >= + LOAD_STATUS_2) { + return true; + } else { + return false; + } +} + +void AudioLoad_SetFontLoadStatus(s32 fontId, s32 loadStatus) { + if ((fontId != 0xFF) && (gAudioContext.fontLoadStatus[fontId] != LOAD_STATUS_5)) { + gAudioContext.fontLoadStatus[fontId] = loadStatus; + } +} + +void AudioLoad_SetSeqLoadStatus(s32 seqId, s32 loadStatus) { + if ((seqId != 0xFF) && (gAudioContext.seqLoadStatus[seqId] != LOAD_STATUS_5)) { + gAudioContext.seqLoadStatus[seqId] = loadStatus; + } +} + +void AudioLoad_SetSampleFontLoadStatusAndApplyCaches(s32 sampleBankId, s32 loadStatus) { + if (sampleBankId != 0xFF) { + if (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_5) { + gAudioContext.sampleFontLoadStatus[sampleBankId] = loadStatus; + } + + if ((gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_5) || + (gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_2)) { + AudioHeap_ApplySampleBankCache(sampleBankId); + } + } +} + +void AudioLoad_SetSampleFontLoadStatus(s32 sampleBankId, s32 loadStatus) { + if ((sampleBankId != 0xFF) && (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_5)) { + gAudioContext.sampleFontLoadStatus[sampleBankId] = loadStatus; + } +} + +void AudioLoad_InitTable(AudioTable* table, uintptr_t romAddr, u16 unkMediumParam) { + s32 i; + + table->unkMediumParam = unkMediumParam; + table->romAddr = romAddr; + + for (i = 0; i < table->numEntries; i++) { + if ((table->entries[i].size != 0) && (table->entries[i].medium == MEDIUM_CART)) { + table->entries[i].romAddr += romAddr; + } + } +} + +SoundFontData* AudioLoad_SyncLoadSeqFonts(s32 seqId, u32* outDefaultFontId) { + s32 pad[2]; + s32 index; + SoundFontData* fontData; + s32 numFonts; + s32 fontId; + s32 i; + + if (seqId >= gAudioContext.numSequences) { + return NULL; + } + + fontId = 0xFF; + index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; + numFonts = gAudioContext.sequenceFontTable[index++]; + + while (numFonts > 0) { + fontId = gAudioContext.sequenceFontTable[index++]; + fontData = AudioLoad_SyncLoadFont(fontId); + numFonts--; + } + + *outDefaultFontId = fontId; + return fontData; +} + +void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1, s32 arg2, OSMesgQueue* arg3) { + s32 pad; + u32 defaultFontId; + + if (seqId < gAudioContext.numSequences) { + if (arg1 & 2) { + AudioLoad_SyncLoadSeqFonts(seqId, &defaultFontId); + } + if (arg1 & 1) { + AudioLoad_SyncLoadSeq(seqId); + } + if (arg2 != 0) { + osSendMesg(arg3, arg2 << 0x18, OS_MESG_NOBLOCK); + } + } +} + +s32 AudioLoad_SyncLoadSample(SoundFontSample* sample, s32 fontId) { + void* sampleAddr; + + if (sample->unk_bit25 == true) { + if (sample->medium != MEDIUM_RAM) { + sampleAddr = AudioHeap_AllocSampleCache(sample->size, fontId, (void*)sample->sampleAddr, sample->medium, + CACHE_PERSISTENT); + if (sampleAddr == NULL) { + return -1; + } + + if (sample->medium == MEDIUM_UNK) { + AudioLoad_SyncDmaUnkMedium(sample->sampleAddr, sampleAddr, sample->size, + gAudioContext.sampleBankTable->unkMediumParam); + } else { + AudioLoad_SyncDma(sample->sampleAddr, sampleAddr, sample->size, sample->medium); + } + sample->medium = MEDIUM_RAM; + sample->sampleAddr = sampleAddr; + } + } +} + +s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { + if (instId < 0x7F) { + Instrument* instrument = AudioPlayback_GetInstrumentInner(fontId, instId); + + if (instrument == NULL) { + return -1; + } + if (instrument->normalRangeLo != 0) { + AudioLoad_SyncLoadSample(instrument->lowNotesSound.sample, fontId); + } + AudioLoad_SyncLoadSample(instrument->normalNotesSound.sample, fontId); + if (instrument->normalRangeHi != 0x7F) { + return AudioLoad_SyncLoadSample(instrument->highNotesSound.sample, fontId); + } + } else if (instId == 0x7F) { + Drum* drum = AudioPlayback_GetDrum(fontId, drumId); + + if (drum == NULL) { + return -1; + } + AudioLoad_SyncLoadSample(drum->sound.sample, fontId); + return 0; + } +} + +void AudioLoad_AsyncLoad(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue) { + if (AudioLoad_AsyncLoadInner(tableType, id, nChunks, retData, retQueue) == NULL) { + osSendMesg(retQueue, 0xFFFFFFFF, OS_MESG_NOBLOCK); + } +} + +void AudioLoad_AsyncLoadSeq(s32 seqId, s32 arg1, s32 retData, OSMesgQueue* retQueue) { + AudioLoad_AsyncLoad(SEQUENCE_TABLE, seqId, 0, retData, retQueue); +} + +void AudioLoad_AsyncLoadSampleBank(s32 sampleBankId, s32 arg1, s32 retData, OSMesgQueue* retQueue) { + AudioLoad_AsyncLoad(SAMPLE_TABLE, sampleBankId, 0, retData, retQueue); +} + +void AudioLoad_AsyncLoadFont(s32 fontId, s32 arg1, s32 retData, OSMesgQueue* retQueue) { + AudioLoad_AsyncLoad(FONT_TABLE, fontId, 0, retData, retQueue); +} + +u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts) { + s32 index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; + + *outNumFonts = gAudioContext.sequenceFontTable[index++]; + if (*outNumFonts == 0) { + return NULL; + } + return &gAudioContext.sequenceFontTable[index]; +} + +void AudioLoad_DiscardSeqFonts(s32 seqId) { + s32 fontId; + s32 index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; + s32 numFonts = gAudioContext.sequenceFontTable[index++]; + + while (numFonts > 0) { + numFonts--; + fontId = AudioLoad_GetRealTableIndex(FONT_TABLE, gAudioContext.sequenceFontTable[index++]); + if (AudioHeap_SearchPermanentCache(FONT_TABLE, fontId) == NULL) { + AudioLoad_DiscardFont(fontId); + AudioLoad_SetFontLoadStatus(fontId, LOAD_STATUS_0); + } + } +} + +void AudioLoad_DiscardFont(s32 fontId) { + u32 i; + AudioCache* pool = &gAudioContext.fontCache; + AudioPersistentCache* persistent; + + if (fontId == pool->temporary.entries[0].id) { + pool->temporary.entries[0].id = -1; + } else if (fontId == pool->temporary.entries[1].id) { + pool->temporary.entries[1].id = -1; + } + + persistent = &pool->persistent; + for (i = 0; i < persistent->numEntries; i++) { + if (fontId == persistent->entries[i].id) { + persistent->entries[i].id = -1; + } + } + + AudioHeap_DiscardFont(fontId); +} + +void func_8018FA60(u32 tableType, u32 id, s32 type, s32 data) { + AudioTable* table = AudioLoad_GetLoadTable(tableType); + + if (table->entries[id].medium == MEDIUM_RAM_UNLOADED) { + switch (type) { + case 0: + table->entries[id].romAddr = data; + break; + case 1: + table->entries[id].size = data; + break; + default: + break; + } + } +} + +s32 AudioLoad_SyncInitSeqPlayer(s32 playerIdx, s32 seqId, s32 arg2) { + if (gAudioContext.resetTimer != 0) { + return 0; + } + + gAudioContext.seqPlayers[playerIdx].skipTicks = 0; + AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, arg2); + // Intentionally missing return. Returning the result of the above function + // call matches but is UB because it too is missing a return, and using the + // result of a non-void function that has failed to return a value is UB. + // The callers of this function do not use the return value, so it's fine. +} + +s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 skipTicks) { + if (gAudioContext.resetTimer != 0) { + return 0; + } + + gAudioContext.seqPlayers[playerIdx].skipTicks = skipTicks; + AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, 0); + // Missing return, see above. +} + +s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) { + SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[playerIdx]; + u8* seqData; + s32 index; + s32 numFonts; + s32 fontId; + + if (seqId >= gAudioContext.numSequences) { + return 0; + } + + AudioSeq_SequencePlayerDisable(seqPlayer); + + if (1) {} + fontId = 0xFF; + index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; + numFonts = gAudioContext.sequenceFontTable[index++]; + + while (numFonts > 0) { + fontId = gAudioContext.sequenceFontTable[index++]; + AudioLoad_SyncLoadFont(fontId); + numFonts--; + } + + seqData = AudioLoad_SyncLoadSeq(seqId); + if (seqData == NULL) { + return 0; + } + + AudioSeq_ResetSequencePlayer(seqPlayer); + seqPlayer->seqId = seqId; + + if (fontId != 0xFF) { + seqPlayer->defaultFont = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId); + } else { + seqPlayer->defaultFont = 0xFF; + } + + seqPlayer->seqData = seqData; + seqPlayer->enabled = true; + seqPlayer->scriptState.pc = seqData; + seqPlayer->scriptState.depth = 0; + seqPlayer->delay = 0; + seqPlayer->finished = false; + seqPlayer->playerIdx = playerIdx; + //! @bug missing return (but the return value is not used so it's not UB) +} + +u8* AudioLoad_SyncLoadSeq(s32 seqId) { + s32 pad; + s32 didAllocate; + + if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] == LOAD_STATUS_1) { + return NULL; + } + + return AudioLoad_SyncLoad(SEQUENCE_TABLE, seqId, &didAllocate); +} + +u32 AudioLoad_GetSampleBank(u32 sampleBankId, u32* outMedium) { + return AudioLoad_TrySyncLoadSampleBank(sampleBankId, outMedium, true); +} + +u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad) { + void* addr; + AudioTable* sampleBankTable; + u32 realTableId = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankId); + s8 cachePolicy; + + sampleBankTable = AudioLoad_GetLoadTable(SAMPLE_TABLE); + + addr = AudioLoad_SearchCaches(SAMPLE_TABLE, realTableId); + if (addr != NULL) { + if (gAudioContext.sampleFontLoadStatus[realTableId] != LOAD_STATUS_1) { + AudioLoad_SetSampleFontLoadStatus(realTableId, LOAD_STATUS_2); + } + + *outMedium = MEDIUM_RAM; + return addr; + } + + cachePolicy = sampleBankTable->entries[sampleBankId].cachePolicy; + + if ((cachePolicy == CACHE_LOAD_EITHER_NOSYNC) || (noLoad == true)) { + *outMedium = sampleBankTable->entries[sampleBankId].medium; + return sampleBankTable->entries[realTableId].romAddr; + } + + addr = AudioLoad_SyncLoad(SAMPLE_TABLE, sampleBankId, &noLoad); + if (addr != NULL) { + *outMedium = MEDIUM_RAM; + return addr; + } + + *outMedium = sampleBankTable->entries[sampleBankId].medium; + return sampleBankTable->entries[realTableId].romAddr; +} + +SoundFontData* AudioLoad_SyncLoadFont(u32 fontId) { + SoundFontData* fontData; + s32 sampleBankId1; + s32 sampleBankId2; + s32 didAllocate; + AudioRelocInfo relocInfo; + s32 realFontId = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId); + + if (gAudioContext.fontLoadStatus[realFontId] == LOAD_STATUS_1) { + return NULL; + } + + sampleBankId1 = gAudioContext.soundFonts[realFontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[realFontId].sampleBankId2; + + relocInfo.sampleBankId1 = sampleBankId1; + relocInfo.sampleBankId2 = sampleBankId2; + if (relocInfo.sampleBankId1 != 0xFF) { + relocInfo.baseAddr1 = AudioLoad_TrySyncLoadSampleBank(relocInfo.sampleBankId1, &relocInfo.medium1, false); + } else { + relocInfo.baseAddr1 = 0; + } + + if (sampleBankId2 != 0xFF) { + relocInfo.baseAddr2 = AudioLoad_TrySyncLoadSampleBank(sampleBankId2, &relocInfo.medium2, false); + } else { + relocInfo.baseAddr2 = 0; + } + + fontData = AudioLoad_SyncLoad(FONT_TABLE, fontId, &didAllocate); + if (fontData == NULL) { + return NULL; + } + if (didAllocate == true) { + AudioLoad_RelocateFontAndPreloadSamples(realFontId, fontData, &relocInfo, false); + } + + return fontData; +} + +void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate) { + size_t size; + AudioTable* table; + s32 medium2; + u32 medium; + s32 loadStatus; + uintptr_t romAddr; + s32 cachePolicy; + void* ramAddr; + u32 realId; + s32 mediumUnk = MEDIUM_UNK; + + realId = AudioLoad_GetRealTableIndex(tableType, id); + ramAddr = AudioLoad_SearchCaches(tableType, realId); + if (ramAddr != NULL) { + *didAllocate = false; + loadStatus = LOAD_STATUS_2; + } else { + table = AudioLoad_GetLoadTable(tableType); + size = table->entries[realId].size; + size = ALIGN16(size); + medium = table->entries[id].medium; + cachePolicy = table->entries[id].cachePolicy; + romAddr = table->entries[realId].romAddr; + switch (cachePolicy) { + case CACHE_LOAD_PERMANENT: + ramAddr = AudioHeap_AllocPermanent(tableType, realId, size); + if (ramAddr == NULL) { + return ramAddr; + } + break; + + case CACHE_LOAD_PERSISTENT: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_PERSISTENT, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + case CACHE_LOAD_TEMPORARY: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_TEMPORARY, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + + case CACHE_LOAD_EITHER: + case CACHE_LOAD_EITHER_NOSYNC: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_EITHER, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + } + + *didAllocate = true; + + medium2 = medium; + if (medium == MEDIUM_RAM_UNLOADED) { + if (romAddr == 0) { + return NULL; + } + + if (tableType == FONT_TABLE) { + SoundFont* soundFont = &gAudioContext.soundFonts[realId]; + + soundFont->numInstruments = ((UnloadedFonts*)romAddr)->numInstruments; + soundFont->numDrums = ((UnloadedFonts*)romAddr)->numDrums; + soundFont->numSfx = ((UnloadedFonts*)romAddr)->numSfx; + romAddr += 0x10; + size -= 0x10; + } + + bcopy(romAddr, ramAddr, size); + } else if (medium2 == mediumUnk) { + AudioLoad_SyncDmaUnkMedium(romAddr, ramAddr, size, (s16)table->unkMediumParam); + } else { + AudioLoad_SyncDma(romAddr, ramAddr, size, medium); + } + + loadStatus = (cachePolicy == CACHE_LOAD_PERMANENT) ? LOAD_STATUS_5 : LOAD_STATUS_2; + } + + switch (tableType) { + case SEQUENCE_TABLE: + AudioLoad_SetSeqLoadStatus(realId, loadStatus); + break; + case FONT_TABLE: + AudioLoad_SetFontLoadStatus(realId, loadStatus); + break; + case SAMPLE_TABLE: + AudioLoad_SetSampleFontLoadStatusAndApplyCaches(realId, loadStatus); + break; + default: + break; + } + + return ramAddr; +} + +u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id) { + AudioTable* table = AudioLoad_GetLoadTable(tableType); + + if (table->entries[id].size == 0) { + id = table->entries[id].romAddr; + } + + return id; +} + +void* AudioLoad_SearchCaches(s32 tableType, s32 id) { + void* addr; + + addr = AudioHeap_SearchPermanentCache(tableType, id); + if (addr != NULL) { + return addr; + } + + addr = AudioHeap_SearchCaches(tableType, CACHE_EITHER, id); + if (addr != NULL) { + return addr; + } + + return NULL; +} + +AudioTable* AudioLoad_GetLoadTable(s32 tableType) { + AudioTable* table; + + switch (tableType) { + case SEQUENCE_TABLE: + table = gAudioContext.sequenceTable; + break; + case FONT_TABLE: + table = gAudioContext.soundFontTable; + break; + default: + table = NULL; + break; + case SAMPLE_TABLE: + table = gAudioContext.sampleBankTable; + break; + } + return table; +} + +/** + * + * SoundFontData* mem -> the address of the soundFont as stored in memory + */ +void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontData, AudioRelocInfo* relocInfo) { + uintptr_t reloc; + uintptr_t reloc2; + Instrument* inst; + Drum* drum; + SoundFontSound* sfx; + s32 i; + s32 numDrums = gAudioContext.soundFonts[fontId].numDrums; + s32 numInstruments = gAudioContext.soundFonts[fontId].numInstruments; + s32 numSfx = gAudioContext.soundFonts[fontId].numSfx; + void** ptrs = (void**)fontData; + +#define BASE_OFFSET(x) (void*)((uintptr_t)(x) + (uintptr_t)(fontData)) + + // relocate drums + reloc2 = ptrs[0]; + if (1) {} + if ((reloc2 != 0) && (numDrums != 0)) { + ptrs[0] = BASE_OFFSET(reloc2); + for (i = 0; i < numDrums; i++) { + reloc = ((Drum**)ptrs[0])[i]; + if (reloc != 0) { + reloc = BASE_OFFSET(reloc); + ((Drum**)ptrs[0])[i] = drum = reloc; + if (!drum->loaded) { + AudioLoad_RelocateSample(&drum->sound, fontData, relocInfo); + reloc = drum->envelope; + drum->envelope = BASE_OFFSET(reloc); + drum->loaded = true; + } + } + } + } + + // relocate sfxs + reloc2 = ptrs[1]; + if (1) {} + if ((reloc2 != 0) && (numSfx != 0)) { + ptrs[1] = BASE_OFFSET(reloc2); + for (i = 0; i < numSfx; i++) { + reloc = (SoundFontSound*)ptrs[1] + i; + if (reloc != 0) { + sfx = reloc; + if (sfx->sample != NULL) { + AudioLoad_RelocateSample(sfx, fontData, relocInfo); + } + } + } + } + + if (numInstruments > 0x7E) { + numInstruments = 0x7E; + } + + // relocate instruments + for (i = 2; i <= 2 + numInstruments - 1; i++) { + if (ptrs[i] != NULL) { + ptrs[i] = BASE_OFFSET(ptrs[i]); + inst = ptrs[i]; + if (!inst->loaded) { + if (inst->normalRangeLo != 0) { + AudioLoad_RelocateSample(&inst->lowNotesSound, fontData, relocInfo); + } + AudioLoad_RelocateSample(&inst->normalNotesSound, fontData, relocInfo); + if (inst->normalRangeHi != 0x7F) { + AudioLoad_RelocateSample(&inst->highNotesSound, fontData, relocInfo); + } + + reloc = inst->envelope; + inst->envelope = BASE_OFFSET(reloc); + inst->loaded = true; + } + } + } + +#undef BASE_OFFSET + + gAudioContext.soundFonts[fontId].drums = ptrs[0]; + gAudioContext.soundFonts[fontId].soundEffects = ptrs[1]; + gAudioContext.soundFonts[fontId].instruments = (Instrument**)(&ptrs[2]); +} + +void AudioLoad_SyncDma(uintptr_t devAddr, u8* ramAddr, size_t size, s32 medium) { + OSMesgQueue* msgQueue = &gAudioContext.syncDmaQueue; + OSIoMesg* ioMesg = &gAudioContext.syncDmaIoMesg; + size = ALIGN16(size); + + Audio_InvalDCache(ramAddr, size); + + while (true) { + if (size < 0x400) { + break; + } + AudioLoad_Dma(ioMesg, OS_MESG_PRI_HIGH, OS_READ, devAddr, ramAddr, 0x400, msgQueue, medium, "FastCopy"); + osRecvMesg(msgQueue, NULL, OS_MESG_BLOCK); + size -= 0x400; + devAddr += 0x400; + ramAddr += 0x400; + } + + if (size != 0) { + AudioLoad_Dma(ioMesg, OS_MESG_PRI_HIGH, OS_READ, devAddr, ramAddr, size, msgQueue, medium, "FastCopy"); + osRecvMesg(msgQueue, NULL, OS_MESG_BLOCK); + } +} + +void AudioLoad_SyncDmaUnkMedium(uintptr_t devAddr, u8* ramAddr, size_t size, s32 unkMediumParam) { +} + +s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, uintptr_t devAddr, void* ramAddr, size_t size, + OSMesgQueue* reqQueue, s32 medium, const char* dmaFuncType) { + OSPiHandle* handle; + + if (gAudioContext.resetTimer > 16) { + return -1; + } + + switch (medium) { + case MEDIUM_CART: + handle = gAudioContext.cartHandle; + break; + + case MEDIUM_DISK_DRIVE: + // driveHandle is uninitialized and corresponds to stubbed-out disk drive support. + // SM64 Shindou called osDriveRomInit here. + handle = gAudioContext.driveHandle; + break; + + default: + return 0; + } + + if ((size % 0x10) != 0) { + size = ALIGN16(size); + } + + mesg->hdr.pri = priority; + mesg->hdr.retQueue = reqQueue; + mesg->dramAddr = ramAddr; + mesg->devAddr = devAddr; + mesg->size = size; + handle->transferInfo.cmdType = 2; + sDmaHandler(handle, mesg, direction); + return 0; +} + +void AudioLoad_Unused1(void) { +} + +void AudioLoad_SyncLoadSimple(u32 tableType, u32 fontId) { + s32 didAllocate; + + AudioLoad_SyncLoad(tableType, fontId, &didAllocate); +} + +void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue) { + size_t size; + AudioTable* table; + void* ramAddr; + s32 medium; + s8 cachePolicy; + uintptr_t romAddr; + s32 loadStatus; + SoundFont* soundFont; + u32 realId = AudioLoad_GetRealTableIndex(tableType, id); + u32 pad; + + switch (tableType) { + case SEQUENCE_TABLE: + if (gAudioContext.seqLoadStatus[realId] == LOAD_STATUS_1) { + return NULL; + } + break; + + case FONT_TABLE: + if (gAudioContext.fontLoadStatus[realId] == LOAD_STATUS_1) { + return NULL; + } + break; + + case SAMPLE_TABLE: + if (gAudioContext.sampleFontLoadStatus[realId] == LOAD_STATUS_1) { + return NULL; + } + break; + } + + ramAddr = AudioLoad_SearchCaches(tableType, realId); + if (ramAddr != NULL) { + loadStatus = LOAD_STATUS_2; + osSendMesg(retQueue, MK_ASYNC_MSG(retData, 0, 0, LOAD_STATUS_0), OS_MESG_NOBLOCK); + } else { + table = AudioLoad_GetLoadTable(tableType); + size = table->entries[realId].size; + size = ALIGN16(size); + medium = table->entries[id].medium; + cachePolicy = table->entries[id].cachePolicy; + romAddr = table->entries[realId].romAddr; + loadStatus = LOAD_STATUS_2; + + switch (cachePolicy) { + case CACHE_LOAD_PERMANENT: + ramAddr = AudioHeap_AllocPermanent(tableType, realId, size); + if (ramAddr == NULL) { + return ramAddr; + } + loadStatus = LOAD_STATUS_5; + break; + + case CACHE_LOAD_PERSISTENT: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_PERSISTENT, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + + case CACHE_LOAD_TEMPORARY: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_TEMPORARY, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + + case CACHE_LOAD_EITHER: + case CACHE_LOAD_EITHER_NOSYNC: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_EITHER, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + } + + if (medium == MEDIUM_RAM_UNLOADED) { + if (romAddr == 0) { + return NULL; + } + + if (tableType == FONT_TABLE) { + soundFont = &gAudioContext.soundFonts[realId]; + + soundFont->numInstruments = ((UnloadedFonts*)romAddr)->numInstruments; + soundFont->numDrums = ((UnloadedFonts*)romAddr)->numDrums; + soundFont->numSfx = ((UnloadedFonts*)romAddr)->numSfx; + romAddr += 0x10; + size += -0x10; + } + } + + if (medium == MEDIUM_UNK) { + AudioLoad_StartAsyncLoadUnkMedium((s16)table->unkMediumParam, romAddr, ramAddr, size, medium, nChunks, + retQueue, MK_ASYNC_MSG(retData, tableType, realId, loadStatus)); + } else { + AudioLoad_StartAsyncLoad(romAddr, ramAddr, size, medium, nChunks, retQueue, + MK_ASYNC_MSG(retData, tableType, realId, loadStatus)); + } + + loadStatus = LOAD_STATUS_1; + } + + switch (tableType) { + case SEQUENCE_TABLE: + AudioLoad_SetSeqLoadStatus(realId, loadStatus); + break; + case FONT_TABLE: + AudioLoad_SetFontLoadStatus(realId, loadStatus); + break; + case SAMPLE_TABLE: + AudioLoad_SetSampleFontLoadStatusAndApplyCaches(realId, loadStatus); + break; + default: + break; + } + + return ramAddr; +} + +void AudioLoad_ProcessLoads(s32 resetStatus) { + AudioLoad_ProcessSlowLoads(resetStatus); + AudioLoad_ProcessSamplePreloads(resetStatus); + AudioLoad_ProcessAsyncLoads(resetStatus); +} + +void AudioLoad_SetDmaHandler(DmaHandler callback) { + sDmaHandler = callback; +} + +void AudioLoad_SetUnusedHandler(void* callback) { + sUnusedHandler = callback; +} + +void AudioLoad_InitSoundFontMeta(s32 fontId) { + SoundFont* font = &gAudioContext.soundFonts[fontId]; + AudioTableEntry* entry = &gAudioContext.soundFontTable->entries[fontId]; + + font->sampleBankId1 = (entry->shortData1 >> 8) & 0xFF; + font->sampleBankId2 = (entry->shortData1) & 0xFF; + font->numInstruments = (entry->shortData2 >> 8) & 0xFF; + font->numDrums = entry->shortData2 & 0xFF; + font->numSfx = entry->shortData3; +} + +void AudioLoad_Init(void* heap, size_t heapSize) { + s32 pad1[9]; + s32 numFonts; + s32 pad2[2]; + u8* audioContextPtr; + void* addr; + s32 i; + s32 j; + + D_80208E68 = NULL; + D_80208E70 = NULL; + D_80208E74 = NULL; + + for (i = 0; i < ARRAY_COUNT(gAudioContext.unk_29A8); i++) { + gAudioContext.unk_29A8[i] = NULL; + } + + gAudioContext.resetTimer = 0; + gAudioContext.unk_29B8 = false; + + // Set all of gAudioContext to 0 + audioContextPtr = (u8*)&gAudioContext; + for (j = sizeof(gAudioContext); j >= 0; j--) { + *audioContextPtr++ = 0; + } + + switch (osTvType) { + case OS_TV_PAL: + gAudioContext.unk_2960 = 20.03042f; + gAudioContext.refreshRate = 50; + break; + + case OS_TV_MPAL: + gAudioContext.unk_2960 = 16.546f; + gAudioContext.refreshRate = 60; + break; + + case OS_TV_NTSC: + default: + gAudioContext.unk_2960 = 16.713f; + gAudioContext.refreshRate = 60; + } + + Audio_InitMesgQueues(); + + for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufLengths); i++) { + gAudioContext.aiBufLengths[i] = 0xA0; + } + + gAudioContext.totalTaskCount = 0; + gAudioContext.rspTaskIndex = 0; + gAudioContext.curAiBuffferIndex = 0; + gAudioContext.soundMode = AUDIO_MODE_STEREO; + gAudioContext.curTask = NULL; + gAudioContext.rspTask[0].task.t.dataSize = 0; + gAudioContext.rspTask[1].task.t.dataSize = 0; + + osCreateMesgQueue(&gAudioContext.syncDmaQueue, &gAudioContext.syncDmaMesg, 1); + osCreateMesgQueue(&gAudioContext.currAudioFrameDmaQueue, gAudioContext.currAudioFrameDmaMesgBuf, + ARRAY_COUNT(gAudioContext.currAudioFrameDmaMesgBuf)); + osCreateMesgQueue(&gAudioContext.externalLoadQueue, gAudioContext.externalLoadMesgBuf, + ARRAY_COUNT(gAudioContext.externalLoadMesgBuf)); + osCreateMesgQueue(&gAudioContext.preloadSampleQueue, gAudioContext.preloadSampleMesgBuf, + ARRAY_COUNT(gAudioContext.preloadSampleMesgBuf)); + gAudioContext.curAudioFrameDmaCount = 0; + gAudioContext.sampleDmaCount = 0; + gAudioContext.cartHandle = osCartRomInit(); + + if (heap == NULL) { + gAudioContext.audioHeap = gAudioHeap; + gAudioContext.audioHeapSize = gAudioContextInitSizes.heapSize; + } else { + void** hp = &heap; + gAudioContext.audioHeap = *hp; + gAudioContext.audioHeapSize = heapSize; + } + + for (i = 0; i < (s32)gAudioContext.audioHeapSize / 8; i++) { + ((u64*)gAudioContext.audioHeap)[i] = 0; + } + + // Main Pool Split (split entirety of audio heap into initPool and sessionPool) + AudioHeap_InitMainPool(gAudioContextInitSizes.mainPoolSplitSize); + + // Initialize the audio interface buffer + for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBuffers); i++) { + gAudioContext.aiBuffers[i] = AudioHeap_AllocZeroed(&gAudioContext.audioInitPool, AIBUF_LEN * sizeof(s16)); + } + + // Connect audio tables to their tables in memory + gAudioContext.sequenceTable = (AudioTable*)gSequenceTable; + gAudioContext.soundFontTable = (AudioTable*)gSoundFontTable; + gAudioContext.sampleBankTable = (AudioTable*)gSampleBankTable; + gAudioContext.sequenceFontTable = gSequenceFontTable; + + gAudioContext.numSequences = gAudioContext.sequenceTable->numEntries; + + gAudioContext.audioResetSpecIdToLoad = 0; + gAudioContext.resetStatus = 1; // Set reset to immediately initialize the audio heap + AudioHeap_ResetStep(); + + // Initialize audio tables + AudioLoad_InitTable(gAudioContext.sequenceTable, SEGMENT_ROM_START(Audioseq), 0); + AudioLoad_InitTable(gAudioContext.soundFontTable, SEGMENT_ROM_START(Audiobank), 0); + AudioLoad_InitTable(gAudioContext.sampleBankTable, SEGMENT_ROM_START(Audiotable), 0); + + numFonts = gAudioContext.soundFontTable->numEntries; + gAudioContext.soundFonts = AudioHeap_Alloc(&gAudioContext.audioInitPool, numFonts * sizeof(SoundFont)); + + for (i = 0; i < numFonts; i++) { + AudioLoad_InitSoundFontMeta(i); + } + + if (addr = AudioHeap_Alloc(&gAudioContext.audioInitPool, gAudioContextInitSizes.permanentPoolSize), addr == NULL) { + // cast away const from D_8014A6C4 + *((u32*)&gAudioContextInitSizes.permanentPoolSize) = 0; + } + + AudioHeap_AllocPoolInit(&gAudioContext.permanentPool, addr, gAudioContextInitSizes.permanentPoolSize); + gAudioContextInitalized = true; + osSendMesg(gAudioContext.taskStartQueueP, (void*)gAudioContext.totalTaskCount, OS_MESG_NOBLOCK); +} + +void AudioLoad_InitSlowLoads(void) { + gAudioContext.slowLoads[0].status = 0; + gAudioContext.slowLoads[1].status = 0; +} + +s32 AudioLoad_SlowLoadSample(s32 fontId, s32 instId, s8* isDone) { + SoundFontSample* sample; + AudioSlowLoad* slowLoad; + + sample = AudioLoad_GetFontSample(fontId, instId); + if (sample == NULL) { + *isDone = 0; + return -1; + } + + if (sample->medium == MEDIUM_RAM) { + *isDone = 2; + return 0; + } + + slowLoad = &gAudioContext.slowLoads[gAudioContext.slowLoadPos]; + if (slowLoad->status == LOAD_STATUS_DONE) { + slowLoad->status = LOAD_STATUS_WAITING; + } + + slowLoad->sample = *sample; + slowLoad->isDone = isDone; + slowLoad->curRamAddr = + AudioHeap_AllocSampleCache(sample->size, fontId, sample->sampleAddr, (s32)sample->medium, CACHE_TEMPORARY); + + if (slowLoad->curRamAddr == NULL) { + if (sample->medium == MEDIUM_UNK || sample->codec == CODEC_S16_INMEMORY) { + *isDone = 0; + return -1; + } else { + *isDone = 3; + return -1; + } + } + + slowLoad->status = LOAD_STATUS_START; + slowLoad->bytesRemaining = ALIGN16(sample->size); + slowLoad->ramAddr = slowLoad->curRamAddr; + slowLoad->curDevAddr = sample->sampleAddr; + slowLoad->medium = sample->medium; + slowLoad->seqOrFontId = fontId; + slowLoad->instId = instId; + + if (slowLoad->medium == MEDIUM_UNK) { + slowLoad->unkMediumParam = gAudioContext.sampleBankTable->unkMediumParam; + } + + gAudioContext.slowLoadPos ^= 1; + return 0; +} + +SoundFontSample* AudioLoad_GetFontSample(s32 fontId, s32 instId) { + SoundFontSample* sample; + + if (instId < 0x80) { + Instrument* instrument = AudioPlayback_GetInstrumentInner(fontId, instId); + + if (instrument == NULL) { + return NULL; + } + sample = instrument->normalNotesSound.sample; + } else if (instId < 0x100) { + Drum* drum = AudioPlayback_GetDrum(fontId, instId - 0x80); + + if (drum == NULL) { + return NULL; + } + sample = drum->sound.sample; + } else { + SoundFontSound* sound = AudioPlayback_GetSfx(fontId, instId - 0x100); + + if (sound == NULL) { + return NULL; + } + sample = sound->sample; + } + + return sample; +} + +void AudioLoad_Unused2(void) { +} + +void AudioLoad_FinishSlowLoad(AudioSlowLoad* slowLoad) { + SoundFontSample* sample; + + if (slowLoad->sample.sampleAddr == NULL) { + return; + } + + sample = AudioLoad_GetFontSample(slowLoad->seqOrFontId, slowLoad->instId); + if (sample == NULL) { + return; + } + + slowLoad->sample = *sample; + sample->sampleAddr = slowLoad->ramAddr; + sample->medium = MEDIUM_RAM; +} + +void AudioLoad_ProcessSlowLoads(s32 resetStatus) { + AudioSlowLoad* slowLoad; + s32 i; + + for (i = 0; i < ARRAY_COUNT(gAudioContext.slowLoads); i++) { + slowLoad = &gAudioContext.slowLoads[i]; + switch (gAudioContext.slowLoads[i].status) { + case LOAD_STATUS_LOADING: + if (slowLoad->medium != MEDIUM_UNK) { + osRecvMesg(&slowLoad->msgqueue, NULL, OS_MESG_BLOCK); + } + + if (resetStatus != 0) { + slowLoad->status = LOAD_STATUS_DONE; + continue; + } + case LOAD_STATUS_START: + slowLoad->status = LOAD_STATUS_LOADING; + if (slowLoad->bytesRemaining == 0) { + AudioLoad_FinishSlowLoad(slowLoad); + slowLoad->status = LOAD_STATUS_DONE; + *slowLoad->isDone = 1; + } else if ((s32)slowLoad->bytesRemaining < 0x400) { + if (slowLoad->medium == MEDIUM_UNK) { + size_t size = slowLoad->bytesRemaining; + + AudioLoad_DmaSlowCopyUnkMedium(slowLoad->curDevAddr, slowLoad->curRamAddr, size, + slowLoad->unkMediumParam); + } else { + AudioLoad_DmaSlowCopy(slowLoad, slowLoad->bytesRemaining); + } + slowLoad->bytesRemaining = 0; + } else { + if (slowLoad->medium == MEDIUM_UNK) { + AudioLoad_DmaSlowCopyUnkMedium(slowLoad->curDevAddr, slowLoad->curRamAddr, 0x400, + slowLoad->unkMediumParam); + } else { + AudioLoad_DmaSlowCopy(slowLoad, 0x400); + } + slowLoad->bytesRemaining -= 0x400; + slowLoad->curRamAddr += 0x400; + slowLoad->curDevAddr += 0x400; + } + break; + } + } +} + +void AudioLoad_DmaSlowCopy(AudioSlowLoad* slowLoad, size_t size) { + Audio_InvalDCache(slowLoad->curRamAddr, size); + osCreateMesgQueue(&slowLoad->msgqueue, &slowLoad->msg, 1); + AudioLoad_Dma(&slowLoad->ioMesg, OS_MESG_PRI_NORMAL, OS_READ, slowLoad->curDevAddr, slowLoad->curRamAddr, size, + &slowLoad->msgqueue, slowLoad->medium, "SLOWCOPY"); +} + +void AudioLoad_DmaSlowCopyUnkMedium(intptr_t devAddr, intptr_t ramAddr, size_t size, s32 arg3) { +} + +s32 AudioLoad_SlowLoadSeq(s32 seqId, u8* ramAddr, s8* isDone) { + AudioSlowLoad* slowLoad; + AudioTable* seqTable; + size_t size; + + if (seqId >= gAudioContext.numSequences) { + *isDone = 0; + return -1; + } + + seqId = AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId); + seqTable = AudioLoad_GetLoadTable(SEQUENCE_TABLE); + slowLoad = &gAudioContext.slowLoads[gAudioContext.slowLoadPos]; + if (slowLoad->status == LOAD_STATUS_DONE) { + slowLoad->status = LOAD_STATUS_WAITING; + } + + slowLoad->sample.sampleAddr = NULL; + slowLoad->isDone = isDone; + size = seqTable->entries[seqId].size; + size = ALIGN16(size); + slowLoad->curRamAddr = ramAddr; + slowLoad->status = LOAD_STATUS_START; + slowLoad->bytesRemaining = size; + slowLoad->ramAddr = ramAddr; + slowLoad->curDevAddr = seqTable->entries[seqId].romAddr; + slowLoad->medium = seqTable->entries[seqId].medium; + slowLoad->seqOrFontId = seqId; + + if (slowLoad->medium == MEDIUM_UNK) { + slowLoad->unkMediumParam = seqTable->unkMediumParam; + } + + gAudioContext.slowLoadPos ^= 1; + return 0; +} + +void AudioLoad_InitAsyncLoads(void) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(gAudioContext.asyncLoads); i++) { + gAudioContext.asyncLoads[i].status = 0; + } +} + +AudioAsyncLoad* AudioLoad_StartAsyncLoadUnkMedium(s32 unkMediumParam, uintptr_t devAddr, void* ramAddr, size_t size, + s32 medium, s32 nChunks, OSMesgQueue* retQueue, s32 retMsg) { + AudioAsyncLoad* asyncLoad; + + asyncLoad = AudioLoad_StartAsyncLoad(devAddr, ramAddr, size, medium, nChunks, retQueue, retMsg); + if (asyncLoad == NULL) { + return NULL; + } + + osSendMesg(&gAudioContext.asyncLoadUnkMediumQueue, asyncLoad, OS_MESG_NOBLOCK); + asyncLoad->unkMediumParam = unkMediumParam; + return asyncLoad; +} + +AudioAsyncLoad* AudioLoad_StartAsyncLoad(uintptr_t devAddr, void* ramAddr, size_t size, s32 medium, s32 nChunks, + OSMesgQueue* retQueue, s32 retMsg) { + AudioAsyncLoad* asyncLoad; + s32 i; + + for (i = 0; i < ARRAY_COUNT(gAudioContext.asyncLoads); i++) { + if (gAudioContext.asyncLoads[i].status == 0) { + asyncLoad = &gAudioContext.asyncLoads[i]; + break; + } + } + + // no more available async loads + if (i == ARRAY_COUNT(gAudioContext.asyncLoads)) { + return NULL; + } + + asyncLoad->status = LOAD_STATUS_START; + asyncLoad->curDevAddr = devAddr; + asyncLoad->ramAddr = ramAddr; + asyncLoad->curRamAddr = ramAddr; + asyncLoad->bytesRemaining = size; + + if (nChunks == 0) { + asyncLoad->chunkSize = 0x1000; + } else if (nChunks == 1) { + asyncLoad->chunkSize = size; + } else { + asyncLoad->chunkSize = ALIGN256((s32)size / nChunks); + if (asyncLoad->chunkSize < 0x100) { + asyncLoad->chunkSize = 0x100; + } + } + + asyncLoad->retQueue = retQueue; + asyncLoad->delay = 3; + asyncLoad->medium = medium; + asyncLoad->retMsg = retMsg; + osCreateMesgQueue(&asyncLoad->msgQueue, &asyncLoad->msg, 1); + return asyncLoad; +} + +void AudioLoad_ProcessAsyncLoads(s32 resetStatus) { + AudioAsyncLoad* asyncLoad; + s32 i; + + if (gAudioContext.resetTimer == 1) { + return; + } + + if (gAudioContext.curUnkMediumLoad == NULL) { + if (resetStatus != 0) { + // Clear and ignore queue if resetting. + do { + } while (osRecvMesg(&gAudioContext.asyncLoadUnkMediumQueue, (OSMesg*)&asyncLoad, OS_MESG_NOBLOCK) != -1); + } else if (osRecvMesg(&gAudioContext.asyncLoadUnkMediumQueue, (OSMesg*)&asyncLoad, OS_MESG_NOBLOCK) == -1) { + gAudioContext.curUnkMediumLoad = NULL; + } else { + gAudioContext.curUnkMediumLoad = asyncLoad; + } + } + + if (gAudioContext.curUnkMediumLoad != NULL) { + AudioLoad_ProcessAsyncLoadUnkMedium(gAudioContext.curUnkMediumLoad, resetStatus); + } + + for (i = 0; i < ARRAY_COUNT(gAudioContext.asyncLoads); i++) { + if (gAudioContext.asyncLoads[i].status == 1) { + asyncLoad = &gAudioContext.asyncLoads[i]; + if (asyncLoad->medium != MEDIUM_UNK) { + AudioLoad_ProcessAsyncLoad(asyncLoad, resetStatus); + } + } + } +} + +void AudioLoad_ProcessAsyncLoadUnkMedium(AudioAsyncLoad* asyncLoad, s32 resetStatus) { +} + +void AudioLoad_FinishAsyncLoad(AudioAsyncLoad* asyncLoad) { + u32 retMsg = asyncLoad->retMsg; + u32 fontId; + u32 pad; + OSMesg doneMsg; + u32 sampleBankId1; + u32 sampleBankId2; + AudioRelocInfo relocInfo; + + if (1) {} + switch (ASYNC_TBLTYPE(retMsg)) { + case SEQUENCE_TABLE: + AudioLoad_SetSeqLoadStatus(ASYNC_ID(retMsg), ASYNC_STATUS(retMsg)); + break; + case SAMPLE_TABLE: + AudioLoad_SetSampleFontLoadStatusAndApplyCaches(ASYNC_ID(retMsg), ASYNC_STATUS(retMsg)); + break; + case FONT_TABLE: + fontId = ASYNC_ID(retMsg); + sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + relocInfo.sampleBankId1 = sampleBankId1; + relocInfo.sampleBankId2 = sampleBankId2; + relocInfo.baseAddr1 = + sampleBankId1 != 0xFF ? AudioLoad_GetSampleBank(sampleBankId1, &relocInfo.medium1) : 0; + relocInfo.baseAddr2 = + sampleBankId2 != 0xFF ? AudioLoad_GetSampleBank(sampleBankId2, &relocInfo.medium2) : 0; + AudioLoad_SetFontLoadStatus(fontId, ASYNC_STATUS(retMsg)); + AudioLoad_RelocateFontAndPreloadSamples(fontId, asyncLoad->ramAddr, &relocInfo, true); + break; + } + + doneMsg = asyncLoad->retMsg; + if (1) {} + asyncLoad->status = LOAD_STATUS_WAITING; + osSendMesg(asyncLoad->retQueue, doneMsg, OS_MESG_NOBLOCK); +} + +void AudioLoad_ProcessAsyncLoad(AudioAsyncLoad* asyncLoad, s32 resetStatus) { + AudioTable* sampleBankTable = gAudioContext.sampleBankTable; + + if (asyncLoad->delay >= 2) { + asyncLoad->delay--; + return; + } + + if (asyncLoad->delay == 1) { + asyncLoad->delay = 0; + } else if (resetStatus != 0) { + // Await the previous DMA response synchronously, then return. + osRecvMesg(&asyncLoad->msgQueue, NULL, OS_MESG_BLOCK); + asyncLoad->status = LOAD_STATUS_WAITING; + return; + } else if (osRecvMesg(&asyncLoad->msgQueue, NULL, OS_MESG_NOBLOCK) == -1) { + // If the previous DMA step isn't done, return. + return; + } + + if (asyncLoad->bytesRemaining == 0) { + AudioLoad_FinishAsyncLoad(asyncLoad); + return; + } + + if (asyncLoad->bytesRemaining < asyncLoad->chunkSize) { + if (asyncLoad->medium == MEDIUM_UNK) { + AudioLoad_AsyncDmaUnkMedium(asyncLoad->curDevAddr, asyncLoad->curRamAddr, asyncLoad->bytesRemaining, + sampleBankTable->unkMediumParam); + } else if (asyncLoad->medium == MEDIUM_RAM_UNLOADED) { + AudioLoad_AsyncDmaRamUnloaded(asyncLoad, asyncLoad->bytesRemaining); + } else { + AudioLoad_AsyncDma(asyncLoad, asyncLoad->bytesRemaining); + } + asyncLoad->bytesRemaining = 0; + return; + } + + if (asyncLoad->medium == MEDIUM_UNK) { + AudioLoad_AsyncDmaUnkMedium(asyncLoad->curDevAddr, asyncLoad->curRamAddr, asyncLoad->chunkSize, + sampleBankTable->unkMediumParam); + } else if (asyncLoad->medium == MEDIUM_RAM_UNLOADED) { + AudioLoad_AsyncDmaRamUnloaded(asyncLoad, asyncLoad->chunkSize); + } else { + AudioLoad_AsyncDma(asyncLoad, asyncLoad->chunkSize); + } + + asyncLoad->bytesRemaining -= asyncLoad->chunkSize; + asyncLoad->curDevAddr += asyncLoad->chunkSize; + asyncLoad->curRamAddr = asyncLoad->curRamAddr + asyncLoad->chunkSize; +} + +void AudioLoad_AsyncDma(AudioAsyncLoad* asyncLoad, size_t size) { + if (size) {} + size = ALIGN16(size); + Audio_InvalDCache(asyncLoad->curRamAddr, size); + osCreateMesgQueue(&asyncLoad->msgQueue, &asyncLoad->msg, 1); + AudioLoad_Dma(&asyncLoad->ioMesg, OS_MESG_PRI_NORMAL, OS_READ, asyncLoad->curDevAddr, asyncLoad->curRamAddr, size, + &asyncLoad->msgQueue, asyncLoad->medium, "BGCOPY"); +} + +void AudioLoad_AsyncDmaRamUnloaded(AudioAsyncLoad* asyncLoad, size_t size) { + if (size) {} + size = ALIGN16(size); + Audio_InvalDCache(asyncLoad->curRamAddr, size); + osCreateMesgQueue(&asyncLoad->msgQueue, &asyncLoad->msg, 1); + bcopy(asyncLoad->curDevAddr, asyncLoad->curRamAddr, size); + osSendMesg(&asyncLoad->msgQueue, NULL, OS_MESG_NOBLOCK); +} + +void AudioLoad_AsyncDmaUnkMedium(uintptr_t devAddr, void* ramAddr, size_t size, s16 arg3) { +} + +#define RELOC(v, base) (reloc = (void*)((uintptr_t)(v) + (uintptr_t)(base))) + +void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, AudioRelocInfo* relocInfo) { + SoundFontSample* sample; + void* reloc; + + if ((uintptr_t)sound->sample <= 0x80000000) { + sample = sound->sample = RELOC(sound->sample, mem); + if (sample->size != 0 && sample->unk_bit25 != true) { + sample->loop = RELOC(sample->loop, mem); + sample->book = RELOC(sample->book, mem); + + // Resolve the sample medium 2-bit bitfield into a real value based on relocInfo. + switch (sample->medium) { + case 0: + sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr1); + sample->medium = relocInfo->medium1; + break; + case 1: + sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr2); + sample->medium = relocInfo->medium2; + break; + case 2: + case 3: + // Invalid? This leaves sample->medium as MEDIUM_CART and MEDIUM_DISK_DRIVE + // respectively, and the sampleAddr unrelocated. + break; + } + + sample->unk_bit25 = true; + if (sample->unk_bit26 && (sample->medium != MEDIUM_RAM)) { + gAudioContext.usedSamples[gAudioContext.numUsedSamples++] = sample; + } + } + } +} + +#undef RELOC + +void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, AudioRelocInfo* relocInfo, s32 async) { + AudioPreloadReq* preload; + AudioPreloadReq* topPreload; + SoundFontSample* sample; + size_t size; + s32 nChunks; + u8* sampleRamAddr; + s32 preloadInProgress; + s32 i; + + preloadInProgress = false; + if (gAudioContext.preloadSampleStackTop != 0) { + preloadInProgress = true; + } else { + D_801FD1E0 = 0; + } + + gAudioContext.numUsedSamples = 0; + AudioLoad_RelocateFont(fontId, mem, relocInfo); + + size = 0; + for (i = 0; i < gAudioContext.numUsedSamples; i++) { + size += ALIGN16(gAudioContext.usedSamples[i]->size); + } + if (size && size) {} + + for (i = 0; i < gAudioContext.numUsedSamples; i++) { + if (gAudioContext.preloadSampleStackTop == 120) { + break; + } + + sample = gAudioContext.usedSamples[i]; + sampleRamAddr = NULL; + switch (async) { + case false: + if (sample->medium == relocInfo->medium1) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, + sample->sampleAddr, sample->medium, CACHE_PERSISTENT); + } else if (sample->medium == relocInfo->medium2) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, + sample->sampleAddr, sample->medium, CACHE_PERSISTENT); + } else if (sample->medium == MEDIUM_DISK_DRIVE) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, 0xFE, sample->sampleAddr, sample->medium, + CACHE_PERSISTENT); + } + break; + + case true: + if (sample->medium == relocInfo->medium1) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, + sample->sampleAddr, sample->medium, CACHE_TEMPORARY); + } else if (sample->medium == relocInfo->medium2) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, + sample->sampleAddr, sample->medium, CACHE_TEMPORARY); + } else if (sample->medium == MEDIUM_DISK_DRIVE) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, 0xFE, sample->sampleAddr, sample->medium, + CACHE_TEMPORARY); + } + break; + } + if (sampleRamAddr == NULL) { + continue; + } + + switch (async) { + case false: + if (sample->medium == MEDIUM_UNK) { + AudioLoad_SyncDmaUnkMedium((uintptr_t)sample->sampleAddr, sampleRamAddr, sample->size, + gAudioContext.sampleBankTable->unkMediumParam); + sample->sampleAddr = sampleRamAddr; + sample->medium = MEDIUM_RAM; + } else { + AudioLoad_SyncDma((uintptr_t)sample->sampleAddr, sampleRamAddr, sample->size, sample->medium); + sample->sampleAddr = sampleRamAddr; + sample->medium = MEDIUM_RAM; + } + if (sample->medium == MEDIUM_DISK_DRIVE) {} + break; + + case true: + preload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop]; + preload->sample = sample; + preload->ramAddr = sampleRamAddr; + preload->encodedInfo = (gAudioContext.preloadSampleStackTop << 24) | 0xFFFFFF; + preload->isFree = false; + preload->endAndMediumKey = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; + gAudioContext.preloadSampleStackTop++; + break; + } + } + gAudioContext.numUsedSamples = 0; + + if (gAudioContext.preloadSampleStackTop != 0 && !preloadInProgress) { + topPreload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop - 1]; + sample = topPreload->sample; + nChunks = (sample->size >> 12) + 1; + AudioLoad_StartAsyncLoad((uintptr_t)sample->sampleAddr, topPreload->ramAddr, sample->size, sample->medium, + nChunks, &gAudioContext.preloadSampleQueue, topPreload->encodedInfo); + } +} + +s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus) { + SoundFontSample* sample; + AudioPreloadReq* preload; + u32 preloadIndex; + u32 key; + u32 nChunks; + s32 pad; + + if (gAudioContext.preloadSampleStackTop > 0) { + if (resetStatus != 0) { + // Clear result queue and preload stack and return. + osRecvMesg(&gAudioContext.preloadSampleQueue, (OSMesg*)&preloadIndex, OS_MESG_NOBLOCK); + gAudioContext.preloadSampleStackTop = 0; + return false; + } + if (osRecvMesg(&gAudioContext.preloadSampleQueue, (OSMesg*)&preloadIndex, OS_MESG_NOBLOCK) == -1) { + // Previous preload is not done yet. + return false; + } + + preloadIndex >>= 24; + preload = &gAudioContext.preloadSampleStack[preloadIndex]; + + if (preload->isFree == false) { + sample = preload->sample; + key = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; + if (key == preload->endAndMediumKey) { + // Change storage for sample to the preloaded version. + sample->sampleAddr = preload->ramAddr; + sample->medium = MEDIUM_RAM; + } + preload->isFree = true; + } + + // Pop requests with isFree = true off the stack, as far as possible, + // and dispatch the next DMA. + for (;;) { + if (gAudioContext.preloadSampleStackTop <= 0) { + break; + } + preload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop - 1]; + if (preload->isFree == true) { + gAudioContext.preloadSampleStackTop--; + continue; + } + + sample = preload->sample; + nChunks = (sample->size >> 12) + 1; + key = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; + if (key != preload->endAndMediumKey) { + preload->isFree = true; + gAudioContext.preloadSampleStackTop--; + } else { + AudioLoad_StartAsyncLoad((uintptr_t)sample->sampleAddr, preload->ramAddr, sample->size, sample->medium, + nChunks, &gAudioContext.preloadSampleQueue, preload->encodedInfo); + break; + } + } + } + return true; +} + +s32 AudioLoad_AddToSampleSet(SoundFontSample* sample, s32 numSamples, SoundFontSample** sampleSet) { + s32 i; + + for (i = 0; i < numSamples; i++) { + if (sample->sampleAddr == sampleSet[i]->sampleAddr) { + break; + } + } + + if (i == numSamples) { + sampleSet[numSamples] = sample; + numSamples++; + } + + return numSamples; +} + +s32 AudioLoad_GetSamplesForFont(s32 fontId, SoundFontSample** sampleSet) { + s32 i; + s32 numSamples = 0; + s32 numDrums = gAudioContext.soundFonts[fontId].numDrums; + s32 numInstruments = gAudioContext.soundFonts[fontId].numInstruments; + + for (i = 0; i < numDrums; i++) { + Drum* drum = AudioPlayback_GetDrum(fontId, i); + + if (1) {} + if (drum != NULL) { + numSamples = AudioLoad_AddToSampleSet(drum->sound.sample, numSamples, sampleSet); + } + } + + for (i = 0; i < numInstruments; i++) { + Instrument* instrument = AudioPlayback_GetInstrumentInner(fontId, i); + + if (instrument != NULL) { + if (instrument->normalRangeLo != 0) { + numSamples = AudioLoad_AddToSampleSet(instrument->lowNotesSound.sample, numSamples, sampleSet); + } + if (instrument->normalRangeHi != 0x7F) { + numSamples = AudioLoad_AddToSampleSet(instrument->highNotesSound.sample, numSamples, sampleSet); + } + numSamples = AudioLoad_AddToSampleSet(instrument->normalNotesSound.sample, numSamples, sampleSet); + } + } + + // Should really also process sfx, but this method is never called + return numSamples; +} + +void AudioLoad_AddUsedSample(SoundFontSound* sound) { + SoundFontSample* sample = sound->sample; + + if ((sample->size != 0) && (sample->unk_bit26) && (sample->medium != MEDIUM_RAM)) { + gAudioContext.usedSamples[gAudioContext.numUsedSamples++] = sample; + } +} + +void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, AudioRelocInfo* relocInfo) { + s32 numDrums; + s32 numInstruments; + s32 numSfx; + Drum* drum; + Instrument* instrument; + SoundFontSound* sound; + AudioPreloadReq* preload; + AudioPreloadReq* topPreload; + u8* addr; + size_t size; + s32 i; + SoundFontSample* sample; + s32 preloadInProgress; + s32 nChunks; + + preloadInProgress = false; + if (gAudioContext.preloadSampleStackTop != 0) { + preloadInProgress = true; + } + + gAudioContext.numUsedSamples = 0; + + numDrums = gAudioContext.soundFonts[fontId].numDrums; + numInstruments = gAudioContext.soundFonts[fontId].numInstruments; + numSfx = gAudioContext.soundFonts[fontId].numSfx; + + for (i = 0; i < numInstruments; i++) { + instrument = AudioPlayback_GetInstrumentInner(fontId, i); + if (instrument != NULL) { + if (instrument->normalRangeLo != 0) { + AudioLoad_AddUsedSample(&instrument->lowNotesSound); + } + if (instrument->normalRangeHi != 0x7F) { + AudioLoad_AddUsedSample(&instrument->highNotesSound); + } + AudioLoad_AddUsedSample(&instrument->normalNotesSound); + } + } + + for (i = 0; i < numDrums; i++) { + drum = AudioPlayback_GetDrum(fontId, i); + if (drum != NULL) { + AudioLoad_AddUsedSample(&drum->sound); + } + } + + for (i = 0; i < numSfx; i++) { + sound = AudioPlayback_GetSfx(fontId, i); + if (sound != NULL) { + AudioLoad_AddUsedSample(sound); + } + } + + if (gAudioContext.numUsedSamples == 0) { + return; + } + + size = 0; + for (i = 0; i < gAudioContext.numUsedSamples; i++) { + size += ALIGN16(gAudioContext.usedSamples[i]->size); + } + if (size) {} + + for (i = 0; i < gAudioContext.numUsedSamples; i++) { + if (gAudioContext.preloadSampleStackTop == 120) { + break; + } + + sample = gAudioContext.usedSamples[i]; + if (sample->medium == MEDIUM_RAM) { + continue; + } + + switch (async) { + case false: + if (sample->medium == relocInfo->medium1) { + addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, + sample->medium, CACHE_PERSISTENT); + } else if (sample->medium == relocInfo->medium2) { + addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, + sample->medium, CACHE_PERSISTENT); + } + break; + + case true: + if (sample->medium == relocInfo->medium1) { + addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, + sample->medium, CACHE_TEMPORARY); + } else if (sample->medium == relocInfo->medium2) { + addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, + sample->medium, CACHE_TEMPORARY); + } + break; + } + if (addr == NULL) { + continue; + } + + switch (async) { + case false: + if (sample->medium == MEDIUM_UNK) { + AudioLoad_SyncDmaUnkMedium((uintptr_t)sample->sampleAddr, addr, sample->size, + gAudioContext.sampleBankTable->unkMediumParam); + sample->sampleAddr = addr; + sample->medium = MEDIUM_RAM; + } else { + AudioLoad_SyncDma((uintptr_t)sample->sampleAddr, addr, sample->size, sample->medium); + sample->sampleAddr = addr; + sample->medium = MEDIUM_RAM; + } + break; + + case true: + preload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop]; + preload->sample = sample; + preload->ramAddr = addr; + preload->encodedInfo = (gAudioContext.preloadSampleStackTop << 24) | 0xFFFFFF; + preload->isFree = false; + preload->endAndMediumKey = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; + gAudioContext.preloadSampleStackTop++; + break; + } + } + gAudioContext.numUsedSamples = 0; + + if (gAudioContext.preloadSampleStackTop != 0 && !preloadInProgress) { + topPreload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop - 1]; + sample = topPreload->sample; + nChunks = (sample->size >> 12) + 1; + AudioLoad_StartAsyncLoad((uintptr_t)sample->sampleAddr, topPreload->ramAddr, sample->size, sample->medium, + nChunks, &gAudioContext.preloadSampleQueue, topPreload->encodedInfo); + } +} + +void AudioLoad_LoadPermanentSamples(void) { + s32 pad; + u32 fontId; + AudioTable* sampleBankTable; + s32 pad2; + s32 i; + + sampleBankTable = AudioLoad_GetLoadTable(SAMPLE_TABLE); + for (i = 0; i < gAudioContext.permanentPool.count; i++) { + AudioRelocInfo relocInfo; + + if (gAudioContext.permanentEntries[i].tableType == FONT_TABLE) { + fontId = AudioLoad_GetRealTableIndex(FONT_TABLE, gAudioContext.permanentEntries[i].id); + relocInfo.sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + relocInfo.sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + + if (relocInfo.sampleBankId1 != 0xFF) { + relocInfo.sampleBankId1 = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, relocInfo.sampleBankId1); + relocInfo.medium1 = sampleBankTable->entries[relocInfo.sampleBankId1].medium; + } + + if (relocInfo.sampleBankId2 != 0xFF) { + relocInfo.sampleBankId2 = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, relocInfo.sampleBankId2); + relocInfo.medium2 = sampleBankTable->entries[relocInfo.sampleBankId2].medium; + } + AudioLoad_PreloadSamplesForFont(fontId, false, &relocInfo); + } + } +} + +void AudioLoad_Unused3(void) { +} + +void AudioLoad_Unused4(void) { +} + +void AudioLoad_Unused5(void) { +} + +void AudioLoad_ScriptLoad(s32 tableType, s32 id, s8* isDone) { + static u32 sLoadIndex = 0; + + sScriptLoadDonePointers[sLoadIndex] = isDone; + AudioLoad_AsyncLoad(tableType, id, 0, sLoadIndex, &sScriptLoadQueue); + sLoadIndex++; + if (sLoadIndex == 0x10) { + sLoadIndex = 0; + } +} + +void AudioLoad_ProcessScriptLoads(void) { + u32 temp; + u32 sp20; + s8* isDone; + + if (osRecvMesg(&sScriptLoadQueue, (OSMesg*)&sp20, OS_MESG_NOBLOCK) != -1) { + temp = sp20 >> 24; + isDone = sScriptLoadDonePointers[temp]; + if (isDone != NULL) { + *isDone = false; + } + } +} + +void AudioLoad_InitScriptLoads(void) { + osCreateMesgQueue(&sScriptLoadQueue, sScriptLoadMesgBuf, ARRAY_COUNT(sScriptLoadMesgBuf)); +} diff --git a/src/code/audio/audio_playback.c b/src/code/audio/audio_playback.c index 78161943c..6ae5696f1 100644 --- a/src/code/audio/audio_playback.c +++ b/src/code/audio/audio_playback.c @@ -982,7 +982,7 @@ void AudioPlayback_NoteInitAll(void) { note->playbackState.portamento.speed = 0; note->playbackState.stereoHeadsetEffects = false; note->playbackState.unk_84 = 0; - note->synthesisState.synthesisBuffers = AudioHeap_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 0x2E0); - note->playbackState.attributes.filterBuf = AudioHeap_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 0x10); + note->synthesisState.synthesisBuffers = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x2E0); + note->playbackState.attributes.filterBuf = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); } } diff --git a/src/code/audio/audio_seqplayer.c b/src/code/audio/audio_seqplayer.c index 56d8ac951..c132ba6a6 100644 --- a/src/code/audio/audio_seqplayer.c +++ b/src/code/audio/audio_seqplayer.c @@ -64,7 +64,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019AAF0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019AB40.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_ResetSequencePlayer.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019AC10.s") diff --git a/src/code/audio/code_80192BE0.c b/src/code/audio/code_80192BE0.c index d408361c7..cd430b5ce 100644 --- a/src/code/audio/code_80192BE0.c +++ b/src/code/audio/code_80192BE0.c @@ -78,4 +78,4 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194668.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801946E4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/Audio_InitMesgQueues.s") diff --git a/src/code/audioMgr.c b/src/code/audioMgr.c index dcf540483..ee6014137 100644 --- a/src/code/audioMgr.c +++ b/src/code/audioMgr.c @@ -79,7 +79,7 @@ void AudioMgr_ThreadEntry(void* arg) { s32 exit; func_801A4C30(); - func_80190B38(DmaMgr_DmaCallback0); + AudioLoad_SetDmaHandler(DmaMgr_DmaHandler); func_801A4D00(); osSendMesg(&audioMgr->lockMsgQ, NULL, OS_MESG_BLOCK); IrqMgr_AddClient(audioMgr->irqMgr, &irqClient, &audioMgr->interruptMsgQ); diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index a08e3f822..4b7f48696 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" Vec3f D_801EDE00; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 321bed21d..4d38c0183 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -12,8 +12,8 @@ 0x80080514:("Idle_ThreadEntry",), 0x800805E0:("ViConfig_UpdateVi",), 0x80080748:("ViConfig_UpdateBlack",), - 0x80080790:("DmaMgr_DMARomToRam",), - 0x800808D4:("DmaMgr_DmaCallback0",), + 0x80080790:("DmaMgr_DmaRomToRam",), + 0x800808D4:("DmaMgr_DmaHandler",), 0x800808F4:("DmaMgr_FindDmaEntry",), 0x80080950:("DmaMgr_TranslateVromToRom",), 0x800809BC:("DmaMgr_FindDmaIndex",), @@ -3549,29 +3549,29 @@ 0x8018B0F0:("func_8018B0F0",), 0x8018B10C:("func_8018B10C",), 0x8018B250:("func_8018B250",), - 0x8018B318:("func_8018B318",), + 0x8018B318:("AudioHeap_DiscardFont",), 0x8018B3FC:("func_8018B3FC",), 0x8018B474:("func_8018B474",), - 0x8018B4F8:("func_8018B4F8",), + 0x8018B4F8:("AudioHeap_WritebackDCache",), 0x8018B520:("func_8018B520",), - 0x8018B578:("func_8018B578",), + 0x8018B578:("AudioHeap_AllocAttemptExternal",), 0x8018B5D0:("AudioHeap_AllocDmaMemory",), 0x8018B608:("func_8018B608",), - 0x8018B640:("func_8018B640",), + 0x8018B640:("AudioHeap_AllocZeroed",), 0x8018B69C:("func_8018B69C",), - 0x8018B6E8:("func_8018B6E8",), - 0x8018B740:("func_8018B740",), + 0x8018B6E8:("AudioHeap_Alloc",), + 0x8018B740:("AudioHeap_AllocPoolInit",), 0x8018B768:("func_8018B768",), 0x8018B77C:("func_8018B77C",), 0x8018B7AC:("func_8018B7AC",), 0x8018B7BC:("func_8018B7BC",), - 0x8018B8FC:("func_8018B8FC",), + 0x8018B8FC:("AudioHeap_InitMainPool",), 0x8018B95C:("func_8018B95C",), 0x8018B9E0:("func_8018B9E0",), 0x8018BA64:("func_8018BA64",), 0x8018BB28:("func_8018BB28",), - 0x8018BBEC:("func_8018BBEC",), - 0x8018C380:("func_8018C380",), + 0x8018BBEC:("AudioHeap_AllocCached",), + 0x8018C380:("AudioHeap_SearchCaches",), 0x8018C3D8:("func_8018C3D8",), 0x8018C4E4:("func_8018C4E4",), 0x8018C8B8:("func_8018C8B8",), @@ -3581,11 +3581,11 @@ 0x8018CB70:("func_8018CB70",), 0x8018CB78:("func_8018CB78",), 0x8018CC3C:("func_8018CC3C",), - 0x8018CCA8:("func_8018CCA8",), + 0x8018CCA8:("AudioHeap_ResetStep",), 0x8018CFAC:("func_8018CFAC",), - 0x8018D57C:("func_8018D57C",), - 0x8018D5D4:("func_8018D5D4",), - 0x8018D658:("func_8018D658",), + 0x8018D57C:("AudioHeap_SearchPermanentCache",), + 0x8018D5D4:("AudioHeap_AllocPermanent",), + 0x8018D658:("AudioHeap_AllocSampleCache",), 0x8018D6C8:("func_8018D6C8",), 0x8018D760:("func_8018D760",), 0x8018DA50:("func_8018DA50",), @@ -3596,90 +3596,90 @@ 0x8018DDD4:("func_8018DDD4",), 0x8018DF24:("func_8018DF24",), 0x8018DFE0:("func_8018DFE0",), - 0x8018E00C:("func_8018E00C",), + 0x8018E00C:("AudioHeap_ApplySampleBankCache",), 0x8018E03C:("func_8018E03C",), 0x8018E2A8:("func_8018E2A8",), 0x8018E344:("func_8018E344",), 0x8018E8C8:("func_8018E8C8",), - 0x8018EB60:("func_8018EB60",), - 0x8018EC4C:("func_8018EC4C",), - 0x8018EF88:("func_8018EF88",), + 0x8018EB60:("AudioLoad_DecreaseSampleDmaTtls",), + 0x8018EC4C:("AudioLoad_DmaSampleData",), + 0x8018EF88:("AudioLoad_InitSampleDmaBuffers",), 0x8018F220:("AudioLoad_IsFontLoadComplete",), - 0x8018F298:("func_8018F298",), - 0x8018F310:("func_8018F310",), - 0x8018F388:("func_8018F388",), - 0x8018F3B8:("func_8018F3B8",), - 0x8018F3E8:("func_8018F3E8",), - 0x8018F448:("func_8018F448",), - 0x8018F478:("func_8018F478",), - 0x8018F4D8:("func_8018F4D8",), - 0x8018F588:("func_8018F588",), - 0x8018F604:("func_8018F604",), - 0x8018F6F0:("func_8018F6F0",), - 0x8018F7C0:("func_8018F7C0",), - 0x8018F7F8:("func_8018F7F8",), - 0x8018F83C:("func_8018F83C",), - 0x8018F880:("func_8018F880",), - 0x8018F8C4:("func_8018F8C4",), - 0x8018F908:("func_8018F908",), - 0x8018F9B8:("func_8018F9B8",), + 0x8018F298:("AudioLoad_IsSeqLoadComplete",), + 0x8018F310:("AudioLoad_IsSampleLoadComplete",), + 0x8018F388:("AudioLoad_SetFontLoadStatus",), + 0x8018F3B8:("AudioLoad_SetSeqLoadStatus",), + 0x8018F3E8:("AudioLoad_SetSampleFontLoadStatusAndApplyCaches",), + 0x8018F448:("AudioLoad_SetSampleFontLoadStatus",), + 0x8018F478:("AudioLoad_InitTable",), + 0x8018F4D8:("AudioLoad_SyncLoadSeqFonts",), + 0x8018F588:("AudioLoad_SyncLoadSeqParts",), + 0x8018F604:("AudioLoad_SyncLoadSample",), + 0x8018F6F0:("AudioLoad_SyncLoadInstrument",), + 0x8018F7C0:("AudioLoad_AsyncLoad",), + 0x8018F7F8:("AudioLoad_AsyncLoadSeq",), + 0x8018F83C:("AudioLoad_AsyncLoadSampleBank",), + 0x8018F880:("AudioLoad_AsyncLoadFont",), + 0x8018F8C4:("AudioLoad_GetFontsForSequence",), + 0x8018F908:("AudioLoad_DiscardSeqFonts",), + 0x8018F9B8:("AudioLoad_DiscardFont",), 0x8018FA60:("func_8018FA60",), - 0x8018FAD0:("func_8018FAD0",), - 0x8018FB20:("func_8018FB20",), - 0x8018FB78:("func_8018FB78",), - 0x8018FCCC:("func_8018FCCC",), - 0x8018FD20:("func_8018FD20",), - 0x8018FD40:("func_8018FD40",), - 0x8018FE5C:("func_8018FE5C",), - 0x8018FF60:("func_8018FF60",), - 0x80190204:("func_80190204",), - 0x80190240:("func_80190240",), - 0x80190294:("func_80190294",), - 0x801902D8:("func_801902D8",), - 0x80190544:("func_80190544",), - 0x80190668:("func_80190668",), - 0x8019067C:("func_8019067C",), - 0x80190754:("func_80190754",), - 0x8019075C:("func_8019075C",), - 0x8019077C:("func_8019077C",), - 0x80190B08:("func_80190B08",), - 0x80190B38:("func_80190B38",), - 0x80190B44:("func_80190B44",), - 0x80190B50:("func_80190B50",), - 0x80190BB0:("func_80190BB0",), - 0x80190F50:("func_80190F50",), - 0x80190F64:("func_80190F64",), - 0x80191134:("func_80191134",), - 0x801911C4:("func_801911C4",), - 0x801911CC:("func_801911CC",), - 0x80191240:("func_80191240",), - 0x801913C8:("func_801913C8",), - 0x8019144C:("func_8019144C",), - 0x80191460:("func_80191460",), - 0x80191568:("func_80191568",), - 0x80191598:("func_80191598",), - 0x8019161C:("func_8019161C",), - 0x80191740:("func_80191740",), - 0x80191864:("func_80191864",), - 0x80191870:("func_80191870",), - 0x801919AC:("func_801919AC",), - 0x80191B40:("func_80191B40",), - 0x80191BD0:("func_80191BD0",), - 0x80191C40:("func_80191C40",), - 0x80191C54:("func_80191C54",), - 0x80191D94:("func_80191D94",), - 0x8019218C:("func_8019218C",), - 0x80192340:("func_80192340",), - 0x80192388:("func_80192388",), - 0x801924BC:("func_801924BC",), - 0x80192514:("func_80192514",), - 0x80192990:("func_80192990",), - 0x80192AD0:("func_80192AD0",), - 0x80192AD8:("func_80192AD8",), - 0x80192AE0:("func_80192AE0",), - 0x80192AE8:("func_80192AE8",), - 0x80192B54:("func_80192B54",), - 0x80192BAC:("func_80192BAC",), + 0x8018FAD0:("AudioLoad_SyncInitSeqPlayer",), + 0x8018FB20:("AudioLoad_SyncInitSeqPlayerSkipTicks",), + 0x8018FB78:("AudioLoad_SyncInitSeqPlayerInternal",), + 0x8018FCCC:("AudioLoad_SyncLoadSeq",), + 0x8018FD20:("AudioLoad_GetSampleBank",), + 0x8018FD40:("AudioLoad_TrySyncLoadSampleBank",), + 0x8018FE5C:("AudioLoad_SyncLoadFont",), + 0x8018FF60:("AudioLoad_SyncLoad",), + 0x80190204:("AudioLoad_GetRealTableIndex",), + 0x80190240:("AudioLoad_SearchCaches",), + 0x80190294:("AudioLoad_GetLoadTable",), + 0x801902D8:("AudioLoad_RelocateFont",), + 0x80190544:("AudioLoad_SyncDma",), + 0x80190668:("AudioLoad_SyncDmaUnkMedium",), + 0x8019067C:("AudioLoad_Dma",), + 0x80190754:("AudioLoad_Unused1",), + 0x8019075C:("AudioLoad_SyncLoadSimple",), + 0x8019077C:("AudioLoad_AsyncLoadInner",), + 0x80190B08:("AudioLoad_ProcessLoads",), + 0x80190B38:("AudioLoad_SetDmaHandler",), + 0x80190B44:("AudioLoad_SetUnusedHandler",), + 0x80190B50:("AudioLoad_InitSoundFontMeta",), + 0x80190BB0:("AudioLoad_Init",), + 0x80190F50:("AudioLoad_InitSlowLoads",), + 0x80190F64:("AudioLoad_SlowLoadSample",), + 0x80191134:("AudioLoad_GetFontSample",), + 0x801911C4:("AudioLoad_Unused2",), + 0x801911CC:("AudioLoad_FinishSlowLoad",), + 0x80191240:("AudioLoad_ProcessSlowLoads",), + 0x801913C8:("AudioLoad_DmaSlowCopy",), + 0x8019144C:("AudioLoad_DmaSlowCopyUnkMedium",), + 0x80191460:("AudioLoad_SlowLoadSeq",), + 0x80191568:("AudioLoad_InitAsyncLoads",), + 0x80191598:("AudioLoad_StartAsyncLoadUnkMedium",), + 0x8019161C:("AudioLoad_StartAsyncLoad",), + 0x80191740:("AudioLoad_ProcessAsyncLoads",), + 0x80191864:("AudioLoad_ProcessAsyncLoadUnkMedium",), + 0x80191870:("AudioLoad_FinishAsyncLoad",), + 0x801919AC:("AudioLoad_ProcessAsyncLoad",), + 0x80191B40:("AudioLoad_AsyncDma",), + 0x80191BD0:("AudioLoad_AsyncDmaRamUnloaded",), + 0x80191C40:("AudioLoad_AsyncDmaUnkMedium",), + 0x80191C54:("AudioLoad_RelocateSample",), + 0x80191D94:("AudioLoad_RelocateFontAndPreloadSamples",), + 0x8019218C:("AudioLoad_ProcessSamplePreloads",), + 0x80192340:("AudioLoad_AddToSampleSet",), + 0x80192388:("AudioLoad_GetSamplesForFont",), + 0x801924BC:("AudioLoad_AddUsedSample",), + 0x80192514:("AudioLoad_PreloadSamplesForFont",), + 0x80192990:("AudioLoad_LoadPermanentSamples",), + 0x80192AD0:("AudioLoad_Unused3",), + 0x80192AD8:("AudioLoad_Unused4",), + 0x80192AE0:("AudioLoad_Unused5",), + 0x80192AE8:("AudioLoad_ScriptLoad",), + 0x80192B54:("AudioLoad_ProcessScriptLoads",), + 0x80192BAC:("AudioLoad_InitScriptLoads",), 0x80192BE0:("func_80192BE0",), 0x80192C00:("func_80192C00",), 0x8019319C:("func_8019319C",), @@ -3719,7 +3719,7 @@ 0x80194548:("func_80194548",), 0x80194568:("func_80194568",), 0x80194668:("func_80194668",), - 0x801946E4:("func_801946E4",), + 0x801946E4:("Audio_InitMesgQueues",), 0x80194710:("Audio_InvalDCache",), 0x80194750:("Audio_WritebackDCache",), 0x80194790:("func_80194790",), @@ -3799,7 +3799,7 @@ 0x8019A0BC:("func_8019A0BC",), 0x8019AA3C:("func_8019AA3C",), 0x8019AAF0:("func_8019AAF0",), - 0x8019AB40:("func_8019AB40",), + 0x8019AB40:("AudioSeq_ResetSequencePlayer",), 0x8019AC10:("func_8019AC10",), 0x8019ACEC:("func_8019ACEC",), 0x8019ADBC:("func_8019ADBC",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index e3d3a8485..f88c541bd 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2286,7 +2286,7 @@ 0x801D5FD4:("D_801D5FD4","UNK_TYPE1","",0x1), 0x801D5FE0:("D_801D5FE0","UNK_PTR","",0x4), 0x801D5FE4:("D_801D5FE4","UNK_TYPE1","",0x1), - 0x801D5FE8:("D_801D5FE8","UNK_TYPE4","",0x4), + 0x801D5FE8:("gAudioContextInitalized","UNK_TYPE4","",0x4), 0x801D5FEC:("D_801D5FEC","UNK_TYPE4","",0x4), 0x801D5FF0:("D_801D5FF0","UNK_TYPE4","",0x4), 0x801D5FF4:("D_801D5FF4","UNK_TYPE4","",0x4), diff --git a/tools/sizes/boot_functions.csv b/tools/sizes/boot_functions.csv index 8551b4fca..f652c0d43 100644 --- a/tools/sizes/boot_functions.csv +++ b/tools/sizes/boot_functions.csv @@ -9,8 +9,8 @@ asm/non_matchings/boot/idle/Idle_InitVideo.s,Idle_InitVideo,0x8008038C,0x62 asm/non_matchings/boot/idle/Idle_ThreadEntry.s,Idle_ThreadEntry,0x80080514,0x33 asm/non_matchings/boot/viconfig/ViConfig_UpdateVi.s,ViConfig_UpdateVi,0x800805E0,0x5A asm/non_matchings/boot/viconfig/ViConfig_UpdateBlack.s,ViConfig_UpdateBlack,0x80080748,0x12 -asm/non_matchings/boot/z_std_dma/DmaMgr_DMARomToRam.s,DmaMgr_DMARomToRam,0x80080790,0x51 -asm/non_matchings/boot/z_std_dma/DmaMgr_DmaCallback0.s,DmaMgr_DmaCallback0,0x800808D4,0x8 +asm/non_matchings/boot/z_std_dma/DmaMgr_DmaRomToRam.s,DmaMgr_DmaRomToRam,0x80080790,0x51 +asm/non_matchings/boot/z_std_dma/DmaMgr_DmaHandler.s,DmaMgr_DmaHandler,0x800808D4,0x8 asm/non_matchings/boot/z_std_dma/DmaMgr_FindDmaEntry.s,DmaMgr_FindDmaEntry,0x800808F4,0x17 asm/non_matchings/boot/z_std_dma/DmaMgr_TranslateVromToRom.s,DmaMgr_TranslateVromToRom,0x80080950,0x1B asm/non_matchings/boot/z_std_dma/DmaMgr_FindDmaIndex.s,DmaMgr_FindDmaIndex,0x800809BC,0xE diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 11dae40ba..d8b33b84b 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -3067,29 +3067,29 @@ asm/non_matchings/code/audio_synthesis/func_8018AE34.s,func_8018AE34,0x8018AE34, asm/non_matchings/code/audio_heap/func_8018B0F0.s,func_8018B0F0,0x8018B0F0,0x7 asm/non_matchings/code/audio_heap/func_8018B10C.s,func_8018B10C,0x8018B10C,0x51 asm/non_matchings/code/audio_heap/func_8018B250.s,func_8018B250,0x8018B250,0x32 -asm/non_matchings/code/audio_heap/func_8018B318.s,func_8018B318,0x8018B318,0x39 +asm/non_matchings/code/audio_heap/AudioHeap_DiscardFont.s,AudioHeap_DiscardFont,0x8018B318,0x39 asm/non_matchings/code/audio_heap/func_8018B3FC.s,func_8018B3FC,0x8018B3FC,0x1E asm/non_matchings/code/audio_heap/func_8018B474.s,func_8018B474,0x8018B474,0x21 -asm/non_matchings/code/audio_heap/func_8018B4F8.s,func_8018B4F8,0x8018B4F8,0xA +asm/non_matchings/code/audio_heap/AudioHeap_WritebackDCache.s,AudioHeap_WritebackDCache,0x8018B4F8,0xA asm/non_matchings/code/audio_heap/func_8018B520.s,func_8018B520,0x8018B520,0x16 -asm/non_matchings/code/audio_heap/func_8018B578.s,func_8018B578,0x8018B578,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_AllocAttemptExternal.s,AudioHeap_AllocAttemptExternal,0x8018B578,0x16 asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemory.s,AudioHeap_AllocDmaMemory,0x8018B5D0,0xE asm/non_matchings/code/audio_heap/func_8018B608.s,func_8018B608,0x8018B608,0xE -asm/non_matchings/code/audio_heap/func_8018B640.s,func_8018B640,0x8018B640,0x17 +asm/non_matchings/code/audio_heap/AudioHeap_AllocZeroed.s,AudioHeap_AllocZeroed,0x8018B640,0x17 asm/non_matchings/code/audio_heap/func_8018B69C.s,func_8018B69C,0x8018B69C,0x13 -asm/non_matchings/code/audio_heap/func_8018B6E8.s,func_8018B6E8,0x8018B6E8,0x16 -asm/non_matchings/code/audio_heap/func_8018B740.s,func_8018B740,0x8018B740,0xA +asm/non_matchings/code/audio_heap/AudioHeap_Alloc.s,AudioHeap_Alloc,0x8018B6E8,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_AllocPoolInit.s,AudioHeap_AllocPoolInit,0x8018B740,0xA asm/non_matchings/code/audio_heap/func_8018B768.s,func_8018B768,0x8018B768,0x5 asm/non_matchings/code/audio_heap/func_8018B77C.s,func_8018B77C,0x8018B77C,0xC asm/non_matchings/code/audio_heap/func_8018B7AC.s,func_8018B7AC,0x8018B7AC,0x4 asm/non_matchings/code/audio_heap/func_8018B7BC.s,func_8018B7BC,0x8018B7BC,0x50 -asm/non_matchings/code/audio_heap/func_8018B8FC.s,func_8018B8FC,0x8018B8FC,0x18 +asm/non_matchings/code/audio_heap/AudioHeap_InitMainPool.s,AudioHeap_InitMainPool,0x8018B8FC,0x18 asm/non_matchings/code/audio_heap/func_8018B95C.s,func_8018B95C,0x8018B95C,0x21 asm/non_matchings/code/audio_heap/func_8018B9E0.s,func_8018B9E0,0x8018B9E0,0x21 asm/non_matchings/code/audio_heap/func_8018BA64.s,func_8018BA64,0x8018BA64,0x31 asm/non_matchings/code/audio_heap/func_8018BB28.s,func_8018BB28,0x8018BB28,0x31 -asm/non_matchings/code/audio_heap/func_8018BBEC.s,func_8018BBEC,0x8018BBEC,0x1E5 -asm/non_matchings/code/audio_heap/func_8018C380.s,func_8018C380,0x8018C380,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_AllocCached.s,AudioHeap_AllocCached,0x8018BBEC,0x1E5 +asm/non_matchings/code/audio_heap/AudioHeap_SearchCaches.s,AudioHeap_SearchCaches,0x8018C380,0x16 asm/non_matchings/code/audio_heap/func_8018C3D8.s,func_8018C3D8,0x8018C3D8,0x43 asm/non_matchings/code/audio_heap/func_8018C4E4.s,func_8018C4E4,0x8018C4E4,0xF5 asm/non_matchings/code/audio_heap/func_8018C8B8.s,func_8018C8B8,0x8018C8B8,0xC @@ -3099,11 +3099,11 @@ asm/non_matchings/code/audio_heap/func_8018C994.s,func_8018C994,0x8018C994,0x77 asm/non_matchings/code/audio_heap/func_8018CB70.s,func_8018CB70,0x8018CB70,0x2 asm/non_matchings/code/audio_heap/func_8018CB78.s,func_8018CB78,0x8018CB78,0x31 asm/non_matchings/code/audio_heap/func_8018CC3C.s,func_8018CC3C,0x8018CC3C,0x1B -asm/non_matchings/code/audio_heap/func_8018CCA8.s,func_8018CCA8,0x8018CCA8,0xC1 +asm/non_matchings/code/audio_heap/AudioHeap_ResetStep.s,AudioHeap_ResetStep,0x8018CCA8,0xC1 asm/non_matchings/code/audio_heap/func_8018CFAC.s,func_8018CFAC,0x8018CFAC,0x174 -asm/non_matchings/code/audio_heap/func_8018D57C.s,func_8018D57C,0x8018D57C,0x16 -asm/non_matchings/code/audio_heap/func_8018D5D4.s,func_8018D5D4,0x8018D5D4,0x21 -asm/non_matchings/code/audio_heap/func_8018D658.s,func_8018D658,0x8018D658,0x1C +asm/non_matchings/code/audio_heap/AudioHeap_SearchPermanentCache.s,AudioHeap_SearchPermanentCache,0x8018D57C,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_AllocPermanent.s,AudioHeap_AllocPermanent,0x8018D5D4,0x21 +asm/non_matchings/code/audio_heap/AudioHeap_AllocSampleCache.s,AudioHeap_AllocSampleCache,0x8018D658,0x1C asm/non_matchings/code/audio_heap/func_8018D6C8.s,func_8018D6C8,0x8018D6C8,0x26 asm/non_matchings/code/audio_heap/func_8018D760.s,func_8018D760,0x8018D760,0xBC asm/non_matchings/code/audio_heap/func_8018DA50.s,func_8018DA50,0x8018DA50,0x5D @@ -3114,90 +3114,90 @@ asm/non_matchings/code/audio_heap/func_8018DD98.s,func_8018DD98,0x8018DD98,0xF asm/non_matchings/code/audio_heap/func_8018DDD4.s,func_8018DDD4,0x8018DDD4,0x54 asm/non_matchings/code/audio_heap/func_8018DF24.s,func_8018DF24,0x8018DF24,0x2F asm/non_matchings/code/audio_heap/func_8018DFE0.s,func_8018DFE0,0x8018DFE0,0xB -asm/non_matchings/code/audio_heap/func_8018E00C.s,func_8018E00C,0x8018E00C,0xC +asm/non_matchings/code/audio_heap/AudioHeap_ApplySampleBankCache.s,AudioHeap_ApplySampleBankCache,0x8018E00C,0xC asm/non_matchings/code/audio_heap/func_8018E03C.s,func_8018E03C,0x8018E03C,0x9B asm/non_matchings/code/audio_heap/func_8018E2A8.s,func_8018E2A8,0x8018E2A8,0x27 asm/non_matchings/code/audio_heap/func_8018E344.s,func_8018E344,0x8018E344,0x161 asm/non_matchings/code/audio_heap/func_8018E8C8.s,func_8018E8C8,0x8018E8C8,0xA6 -asm/non_matchings/code/audio_load/func_8018EB60.s,func_8018EB60,0x8018EB60,0x3B -asm/non_matchings/code/audio_load/func_8018EC4C.s,func_8018EC4C,0x8018EC4C,0xCF -asm/non_matchings/code/audio_load/func_8018EF88.s,func_8018EF88,0x8018EF88,0xA6 +asm/non_matchings/code/audio_load/AudioLoad_DecreaseSampleDmaTtls.s,AudioLoad_DecreaseSampleDmaTtls,0x8018EB60,0x3B +asm/non_matchings/code/audio_load/AudioLoad_DmaSampleData.s,AudioLoad_DmaSampleData,0x8018EC4C,0xCF +asm/non_matchings/code/audio_load/AudioLoad_InitSampleDmaBuffers.s,AudioLoad_InitSampleDmaBuffers,0x8018EF88,0xA6 asm/non_matchings/code/audio_load/AudioLoad_IsFontLoadComplete.s,AudioLoad_IsFontLoadComplete,0x8018F220,0x1E -asm/non_matchings/code/audio_load/func_8018F298.s,func_8018F298,0x8018F298,0x1E -asm/non_matchings/code/audio_load/func_8018F310.s,func_8018F310,0x8018F310,0x1E -asm/non_matchings/code/audio_load/func_8018F388.s,func_8018F388,0x8018F388,0xC -asm/non_matchings/code/audio_load/func_8018F3B8.s,func_8018F3B8,0x8018F3B8,0xC -asm/non_matchings/code/audio_load/func_8018F3E8.s,func_8018F3E8,0x8018F3E8,0x18 -asm/non_matchings/code/audio_load/func_8018F448.s,func_8018F448,0x8018F448,0xC -asm/non_matchings/code/audio_load/func_8018F478.s,func_8018F478,0x8018F478,0x18 -asm/non_matchings/code/audio_load/func_8018F4D8.s,func_8018F4D8,0x8018F4D8,0x2C -asm/non_matchings/code/audio_load/func_8018F588.s,func_8018F588,0x8018F588,0x1F -asm/non_matchings/code/audio_load/func_8018F604.s,func_8018F604,0x8018F604,0x3B -asm/non_matchings/code/audio_load/func_8018F6F0.s,func_8018F6F0,0x8018F6F0,0x34 -asm/non_matchings/code/audio_load/func_8018F7C0.s,func_8018F7C0,0x8018F7C0,0xE -asm/non_matchings/code/audio_load/func_8018F7F8.s,func_8018F7F8,0x8018F7F8,0x11 -asm/non_matchings/code/audio_load/func_8018F83C.s,func_8018F83C,0x8018F83C,0x11 -asm/non_matchings/code/audio_load/func_8018F880.s,func_8018F880,0x8018F880,0x11 -asm/non_matchings/code/audio_load/func_8018F8C4.s,func_8018F8C4,0x8018F8C4,0x11 -asm/non_matchings/code/audio_load/func_8018F908.s,func_8018F908,0x8018F908,0x2C -asm/non_matchings/code/audio_load/func_8018F9B8.s,func_8018F9B8,0x8018F9B8,0x2A +asm/non_matchings/code/audio_load/AudioLoad_IsSeqLoadComplete.s,AudioLoad_IsSeqLoadComplete,0x8018F298,0x1E +asm/non_matchings/code/audio_load/AudioLoad_IsSampleLoadComplete.s,AudioLoad_IsSampleLoadComplete,0x8018F310,0x1E +asm/non_matchings/code/audio_load/AudioLoad_SetFontLoadStatus.s,AudioLoad_SetFontLoadStatus,0x8018F388,0xC +asm/non_matchings/code/audio_load/AudioLoad_SetSeqLoadStatus.s,AudioLoad_SetSeqLoadStatus,0x8018F3B8,0xC +asm/non_matchings/code/audio_load/AudioLoad_SetSampleFontLoadStatusAndApplyCaches.s,AudioLoad_SetSampleFontLoadStatusAndApplyCaches,0x8018F3E8,0x18 +asm/non_matchings/code/audio_load/AudioLoad_SetSampleFontLoadStatus.s,AudioLoad_SetSampleFontLoadStatus,0x8018F448,0xC +asm/non_matchings/code/audio_load/AudioLoad_InitTable.s,AudioLoad_InitTable,0x8018F478,0x18 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSeqFonts.s,AudioLoad_SyncLoadSeqFonts,0x8018F4D8,0x2C +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSeqParts.s,AudioLoad_SyncLoadSeqParts,0x8018F588,0x1F +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSample.s,AudioLoad_SyncLoadSample,0x8018F604,0x3B +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadInstrument.s,AudioLoad_SyncLoadInstrument,0x8018F6F0,0x34 +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoad.s,AudioLoad_AsyncLoad,0x8018F7C0,0xE +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadSeq.s,AudioLoad_AsyncLoadSeq,0x8018F7F8,0x11 +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadSampleBank.s,AudioLoad_AsyncLoadSampleBank,0x8018F83C,0x11 +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadFont.s,AudioLoad_AsyncLoadFont,0x8018F880,0x11 +asm/non_matchings/code/audio_load/AudioLoad_GetFontsForSequence.s,AudioLoad_GetFontsForSequence,0x8018F8C4,0x11 +asm/non_matchings/code/audio_load/AudioLoad_DiscardSeqFonts.s,AudioLoad_DiscardSeqFonts,0x8018F908,0x2C +asm/non_matchings/code/audio_load/AudioLoad_DiscardFont.s,AudioLoad_DiscardFont,0x8018F9B8,0x2A asm/non_matchings/code/audio_load/func_8018FA60.s,func_8018FA60,0x8018FA60,0x1C -asm/non_matchings/code/audio_load/func_8018FAD0.s,func_8018FAD0,0x8018FAD0,0x14 -asm/non_matchings/code/audio_load/func_8018FB20.s,func_8018FB20,0x8018FB20,0x16 -asm/non_matchings/code/audio_load/func_8018FB78.s,func_8018FB78,0x8018FB78,0x55 -asm/non_matchings/code/audio_load/func_8018FCCC.s,func_8018FCCC,0x8018FCCC,0x15 -asm/non_matchings/code/audio_load/func_8018FD20.s,func_8018FD20,0x8018FD20,0x8 -asm/non_matchings/code/audio_load/func_8018FD40.s,func_8018FD40,0x8018FD40,0x47 -asm/non_matchings/code/audio_load/func_8018FE5C.s,func_8018FE5C,0x8018FE5C,0x41 -asm/non_matchings/code/audio_load/func_8018FF60.s,func_8018FF60,0x8018FF60,0xA9 -asm/non_matchings/code/audio_load/func_80190204.s,func_80190204,0x80190204,0xF -asm/non_matchings/code/audio_load/func_80190240.s,func_80190240,0x80190240,0x15 -asm/non_matchings/code/audio_load/func_80190294.s,func_80190294,0x80190294,0x11 -asm/non_matchings/code/audio_load/func_801902D8.s,func_801902D8,0x801902D8,0x9B -asm/non_matchings/code/audio_load/func_80190544.s,func_80190544,0x80190544,0x49 -asm/non_matchings/code/audio_load/func_80190668.s,func_80190668,0x80190668,0x5 -asm/non_matchings/code/audio_load/func_8019067C.s,func_8019067C,0x8019067C,0x36 -asm/non_matchings/code/audio_load/func_80190754.s,func_80190754,0x80190754,0x2 -asm/non_matchings/code/audio_load/func_8019075C.s,func_8019075C,0x8019075C,0x8 -asm/non_matchings/code/audio_load/func_8019077C.s,func_8019077C,0x8019077C,0xE3 -asm/non_matchings/code/audio_load/func_80190B08.s,func_80190B08,0x80190B08,0xC -asm/non_matchings/code/audio_load/func_80190B38.s,func_80190B38,0x80190B38,0x3 -asm/non_matchings/code/audio_load/func_80190B44.s,func_80190B44,0x80190B44,0x3 -asm/non_matchings/code/audio_load/func_80190B50.s,func_80190B50,0x80190B50,0x18 -asm/non_matchings/code/audio_load/func_80190BB0.s,func_80190BB0,0x80190BB0,0xE8 -asm/non_matchings/code/audio_load/func_80190F50.s,func_80190F50,0x80190F50,0x5 -asm/non_matchings/code/audio_load/func_80190F64.s,func_80190F64,0x80190F64,0x74 -asm/non_matchings/code/audio_load/func_80191134.s,func_80191134,0x80191134,0x24 -asm/non_matchings/code/audio_load/func_801911C4.s,func_801911C4,0x801911C4,0x2 -asm/non_matchings/code/audio_load/func_801911CC.s,func_801911CC,0x801911CC,0x1D -asm/non_matchings/code/audio_load/func_80191240.s,func_80191240,0x80191240,0x62 -asm/non_matchings/code/audio_load/func_801913C8.s,func_801913C8,0x801913C8,0x21 -asm/non_matchings/code/audio_load/func_8019144C.s,func_8019144C,0x8019144C,0x5 -asm/non_matchings/code/audio_load/func_80191460.s,func_80191460,0x80191460,0x42 -asm/non_matchings/code/audio_load/func_80191568.s,func_80191568,0x80191568,0xC -asm/non_matchings/code/audio_load/func_80191598.s,func_80191598,0x80191598,0x21 -asm/non_matchings/code/audio_load/func_8019161C.s,func_8019161C,0x8019161C,0x49 -asm/non_matchings/code/audio_load/func_80191740.s,func_80191740,0x80191740,0x49 -asm/non_matchings/code/audio_load/func_80191864.s,func_80191864,0x80191864,0x3 -asm/non_matchings/code/audio_load/func_80191870.s,func_80191870,0x80191870,0x4F -asm/non_matchings/code/audio_load/func_801919AC.s,func_801919AC,0x801919AC,0x65 -asm/non_matchings/code/audio_load/func_80191B40.s,func_80191B40,0x80191B40,0x24 -asm/non_matchings/code/audio_load/func_80191BD0.s,func_80191BD0,0x80191BD0,0x1C -asm/non_matchings/code/audio_load/func_80191C40.s,func_80191C40,0x80191C40,0x5 -asm/non_matchings/code/audio_load/func_80191C54.s,func_80191C54,0x80191C54,0x50 -asm/non_matchings/code/audio_load/func_80191D94.s,func_80191D94,0x80191D94,0xFE -asm/non_matchings/code/audio_load/func_8019218C.s,func_8019218C,0x8019218C,0x6D -asm/non_matchings/code/audio_load/func_80192340.s,func_80192340,0x80192340,0x12 -asm/non_matchings/code/audio_load/func_80192388.s,func_80192388,0x80192388,0x4D -asm/non_matchings/code/audio_load/func_801924BC.s,func_801924BC,0x801924BC,0x16 -asm/non_matchings/code/audio_load/func_80192514.s,func_80192514,0x80192514,0x11F -asm/non_matchings/code/audio_load/func_80192990.s,func_80192990,0x80192990,0x50 -asm/non_matchings/code/audio_load/func_80192AD0.s,func_80192AD0,0x80192AD0,0x2 -asm/non_matchings/code/audio_load/func_80192AD8.s,func_80192AD8,0x80192AD8,0x2 -asm/non_matchings/code/audio_load/func_80192AE0.s,func_80192AE0,0x80192AE0,0x2 -asm/non_matchings/code/audio_load/func_80192AE8.s,func_80192AE8,0x80192AE8,0x1B -asm/non_matchings/code/audio_load/func_80192B54.s,func_80192B54,0x80192B54,0x16 -asm/non_matchings/code/audio_load/func_80192BAC.s,func_80192BAC,0x80192BAC,0xD +asm/non_matchings/code/audio_load/AudioLoad_SyncInitSeqPlayer.s,AudioLoad_SyncInitSeqPlayer,0x8018FAD0,0x14 +asm/non_matchings/code/audio_load/AudioLoad_SyncInitSeqPlayerSkipTicks.s,AudioLoad_SyncInitSeqPlayerSkipTicks,0x8018FB20,0x16 +asm/non_matchings/code/audio_load/AudioLoad_SyncInitSeqPlayerInternal.s,AudioLoad_SyncInitSeqPlayerInternal,0x8018FB78,0x55 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSeq.s,AudioLoad_SyncLoadSeq,0x8018FCCC,0x15 +asm/non_matchings/code/audio_load/AudioLoad_GetSampleBank.s,AudioLoad_GetSampleBank,0x8018FD20,0x8 +asm/non_matchings/code/audio_load/AudioLoad_TrySyncLoadSampleBank.s,AudioLoad_TrySyncLoadSampleBank,0x8018FD40,0x47 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadFont.s,AudioLoad_SyncLoadFont,0x8018FE5C,0x41 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoad.s,AudioLoad_SyncLoad,0x8018FF60,0xA9 +asm/non_matchings/code/audio_load/AudioLoad_GetRealTableIndex.s,AudioLoad_GetRealTableIndex,0x80190204,0xF +asm/non_matchings/code/audio_load/AudioLoad_SearchCaches.s,AudioLoad_SearchCaches,0x80190240,0x15 +asm/non_matchings/code/audio_load/AudioLoad_GetLoadTable.s,AudioLoad_GetLoadTable,0x80190294,0x11 +asm/non_matchings/code/audio_load/AudioLoad_RelocateFont.s,AudioLoad_RelocateFont,0x801902D8,0x9B +asm/non_matchings/code/audio_load/AudioLoad_SyncDma.s,AudioLoad_SyncDma,0x80190544,0x49 +asm/non_matchings/code/audio_load/AudioLoad_SyncDmaUnkMedium.s,AudioLoad_SyncDmaUnkMedium,0x80190668,0x5 +asm/non_matchings/code/audio_load/AudioLoad_Dma.s,AudioLoad_Dma,0x8019067C,0x36 +asm/non_matchings/code/audio_load/AudioLoad_Unused1.s,AudioLoad_Unused1,0x80190754,0x2 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSimple.s,AudioLoad_SyncLoadSimple,0x8019075C,0x8 +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadInner.s,AudioLoad_AsyncLoadInner,0x8019077C,0xE3 +asm/non_matchings/code/audio_load/AudioLoad_ProcessLoads.s,AudioLoad_ProcessLoads,0x80190B08,0xC +asm/non_matchings/code/audio_load/AudioLoad_SetDmaHandler.s,AudioLoad_SetDmaHandler,0x80190B38,0x3 +asm/non_matchings/code/audio_load/AudioLoad_SetUnusedHandler.s,AudioLoad_SetUnusedHandler,0x80190B44,0x3 +asm/non_matchings/code/audio_load/AudioLoad_InitSoundFontMeta.s,AudioLoad_InitSoundFontMeta,0x80190B50,0x18 +asm/non_matchings/code/audio_load/AudioLoad_Init.s,AudioLoad_Init,0x80190BB0,0xE8 +asm/non_matchings/code/audio_load/AudioLoad_InitSlowLoads.s,AudioLoad_InitSlowLoads,0x80190F50,0x5 +asm/non_matchings/code/audio_load/AudioLoad_SlowLoadSample.s,AudioLoad_SlowLoadSample,0x80190F64,0x74 +asm/non_matchings/code/audio_load/AudioLoad_GetFontSample.s,AudioLoad_GetFontSample,0x80191134,0x24 +asm/non_matchings/code/audio_load/AudioLoad_Unused2.s,AudioLoad_Unused2,0x801911C4,0x2 +asm/non_matchings/code/audio_load/AudioLoad_FinishSlowLoad.s,AudioLoad_FinishSlowLoad,0x801911CC,0x1D +asm/non_matchings/code/audio_load/AudioLoad_ProcessSlowLoads.s,AudioLoad_ProcessSlowLoads,0x80191240,0x62 +asm/non_matchings/code/audio_load/AudioLoad_DmaSlowCopy.s,AudioLoad_DmaSlowCopy,0x801913C8,0x21 +asm/non_matchings/code/audio_load/AudioLoad_DmaSlowCopyUnkMedium.s,AudioLoad_DmaSlowCopyUnkMedium,0x8019144C,0x5 +asm/non_matchings/code/audio_load/AudioLoad_SlowLoadSeq.s,AudioLoad_SlowLoadSeq,0x80191460,0x42 +asm/non_matchings/code/audio_load/AudioLoad_InitAsyncLoads.s,AudioLoad_InitAsyncLoads,0x80191568,0xC +asm/non_matchings/code/audio_load/AudioLoad_StartAsyncLoadUnkMedium.s,AudioLoad_StartAsyncLoadUnkMedium,0x80191598,0x21 +asm/non_matchings/code/audio_load/AudioLoad_StartAsyncLoad.s,AudioLoad_StartAsyncLoad,0x8019161C,0x49 +asm/non_matchings/code/audio_load/AudioLoad_ProcessAsyncLoads.s,AudioLoad_ProcessAsyncLoads,0x80191740,0x49 +asm/non_matchings/code/audio_load/AudioLoad_ProcessAsyncLoadUnkMedium.s,AudioLoad_ProcessAsyncLoadUnkMedium,0x80191864,0x3 +asm/non_matchings/code/audio_load/AudioLoad_FinishAsyncLoad.s,AudioLoad_FinishAsyncLoad,0x80191870,0x4F +asm/non_matchings/code/audio_load/AudioLoad_ProcessAsyncLoad.s,AudioLoad_ProcessAsyncLoad,0x801919AC,0x65 +asm/non_matchings/code/audio_load/AudioLoad_AsyncDma.s,AudioLoad_AsyncDma,0x80191B40,0x24 +asm/non_matchings/code/audio_load/AudioLoad_AsyncDmaRamUnloaded.s,AudioLoad_AsyncDmaRamUnloaded,0x80191BD0,0x1C +asm/non_matchings/code/audio_load/AudioLoad_AsyncDmaUnkMedium.s,AudioLoad_AsyncDmaUnkMedium,0x80191C40,0x5 +asm/non_matchings/code/audio_load/AudioLoad_RelocateSample.s,AudioLoad_RelocateSample,0x80191C54,0x50 +asm/non_matchings/code/audio_load/AudioLoad_RelocateFontAndPreloadSamples.s,AudioLoad_RelocateFontAndPreloadSamples,0x80191D94,0xFE +asm/non_matchings/code/audio_load/AudioLoad_ProcessSamplePreloads.s,AudioLoad_ProcessSamplePreloads,0x8019218C,0x6D +asm/non_matchings/code/audio_load/AudioLoad_AddToSampleSet.s,AudioLoad_AddToSampleSet,0x80192340,0x12 +asm/non_matchings/code/audio_load/AudioLoad_GetSamplesForFont.s,AudioLoad_GetSamplesForFont,0x80192388,0x4D +asm/non_matchings/code/audio_load/AudioLoad_AddUsedSample.s,AudioLoad_AddUsedSample,0x801924BC,0x16 +asm/non_matchings/code/audio_load/AudioLoad_PreloadSamplesForFont.s,AudioLoad_PreloadSamplesForFont,0x80192514,0x11F +asm/non_matchings/code/audio_load/AudioLoad_LoadPermanentSamples.s,AudioLoad_LoadPermanentSamples,0x80192990,0x50 +asm/non_matchings/code/audio_load/AudioLoad_Unused3.s,AudioLoad_Unused3,0x80192AD0,0x2 +asm/non_matchings/code/audio_load/AudioLoad_Unused4.s,AudioLoad_Unused4,0x80192AD8,0x2 +asm/non_matchings/code/audio_load/AudioLoad_Unused5.s,AudioLoad_Unused5,0x80192AE0,0x2 +asm/non_matchings/code/audio_load/AudioLoad_ScriptLoad.s,AudioLoad_ScriptLoad,0x80192AE8,0x1B +asm/non_matchings/code/audio_load/AudioLoad_ProcessScriptLoads.s,AudioLoad_ProcessScriptLoads,0x80192B54,0x16 +asm/non_matchings/code/audio_load/AudioLoad_InitScriptLoads.s,AudioLoad_InitScriptLoads,0x80192BAC,0xD asm/non_matchings/code/code_80192BE0/func_80192BE0.s,func_80192BE0,0x80192BE0,0x8 asm/non_matchings/code/code_80192BE0/func_80192C00.s,func_80192C00,0x80192C00,0x167 asm/non_matchings/code/code_80192BE0/func_8019319C.s,func_8019319C,0x8019319C,0x14F @@ -3237,7 +3237,7 @@ asm/non_matchings/code/code_80192BE0/func_80194528.s,func_80194528,0x80194528,0x asm/non_matchings/code/code_80192BE0/func_80194548.s,func_80194548,0x80194548,0x8 asm/non_matchings/code/code_80192BE0/func_80194568.s,func_80194568,0x80194568,0x40 asm/non_matchings/code/code_80192BE0/func_80194668.s,func_80194668,0x80194668,0x1F -asm/non_matchings/code/code_80192BE0/func_801946E4.s,func_801946E4,0x801946E4,0xB +asm/non_matchings/code/code_80192BE0/Audio_InitMesgQueues.s,Audio_InitMesgQueues,0x801946E4,0xB asm/non_matchings/code/code_80194710/Audio_InvalDCache.s,Audio_InvalDCache,0x80194710,0x10 asm/non_matchings/code/code_80194710/Audio_WritebackDCache.s,Audio_WritebackDCache,0x80194750,0x10 asm/non_matchings/code/code_80194710/func_80194790.s,func_80194790,0x80194790,0x1D @@ -3317,7 +3317,7 @@ asm/non_matchings/code/audio_seqplayer/func_80199268.s,func_80199268,0x80199268, asm/non_matchings/code/audio_seqplayer/func_8019A0BC.s,func_8019A0BC,0x8019A0BC,0x260 asm/non_matchings/code/audio_seqplayer/func_8019AA3C.s,func_8019AA3C,0x8019AA3C,0x2D asm/non_matchings/code/audio_seqplayer/func_8019AAF0.s,func_8019AAF0,0x8019AAF0,0x14 -asm/non_matchings/code/audio_seqplayer/func_8019AB40.s,func_8019AB40,0x8019AB40,0x34 +asm/non_matchings/code/audio_seqplayer/AudioSeq_ResetSequencePlayer.s,AudioSeq_ResetSequencePlayer,0x8019AB40,0x34 asm/non_matchings/code/audio_seqplayer/func_8019AC10.s,func_8019AC10,0x8019AC10,0x37 asm/non_matchings/code/audio_seqplayer/func_8019ACEC.s,func_8019ACEC,0x8019ACEC,0x34 asm/non_matchings/code/audio_seqplayer/func_8019ADBC.s,func_8019ADBC,0x8019ADBC,0x21 From e77a22e8a905f241d7b58889bcf4b12fb81dcf27 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Thu, 24 Mar 2022 14:40:31 +1100 Subject: [PATCH 083/257] Audio_Heap OK and Documented (#621) * copy audio_heap progress from main branch * Add filter bugs * PR Review + Docs * format * typo * Improve audio buffer notes * Add documentation * PR Feedback * PR Suggestions * Fix bss * PR Suggestions * PR typo * Fix warning --- include/functions.h | 56 +- include/variables.h | 20 +- src/code/audio/audio_heap.c | 1686 +++++++++++++++++++++++++++- src/code/audio/audio_init_params.c | 2 +- src/code/audio/audio_seqplayer.c | 6 +- tools/disasm/functions.txt | 80 +- tools/disasm/variables.txt | 2 +- tools/sizes/code_functions.csv | 84 +- 8 files changed, 1735 insertions(+), 201 deletions(-) diff --git a/include/functions.h b/include/functions.h index 4dccf9a5b..125517df2 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3301,57 +3301,25 @@ s32 osFlashReadArray(OSIoMesg* mb, s32 priority, u32 pageNum, void* dramAddr, u3 // void func_8018A808(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6); // void func_8018ACC4(void); // void func_8018AE34(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_8018B0F0(void); -// void func_8018B10C(void); -// void func_8018B250(void); void AudioHeap_DiscardFont(s32 fontId); -// void func_8018B474(void); -void* AudioHeap_WritebackDCache(void* mem, size_t size); -// void func_8018B520(void); +void* AudioHeap_WritebackDCache(void* addr, size_t size); void* AudioHeap_AllocAttemptExternal(AudioAllocPool* pool, size_t size); -void* AudioHeap_AllocDmaMemory(AudioAllocPool* pool, u32 size); -// void func_8018B608(void); +void* AudioHeap_AllocDmaMemory(AudioAllocPool* pool, size_t size); void* AudioHeap_AllocZeroed(AudioAllocPool* pool, size_t size); -// void func_8018B69C(void); void* AudioHeap_Alloc(AudioAllocPool* pool, size_t size); -void AudioHeap_AllocPoolInit(AudioAllocPool* pool, void* mem, size_t size); -// void func_8018B768(void); -// void func_8018B77C(void); -// void func_8018B7BC(void); -void AudioHeap_InitMainPool(s32 initPoolSize); -// void func_8018B95C(void); -// void func_8018B9E0(void); -// void func_8018BA64(void); -// void func_8018BB28(void); +void AudioHeap_AllocPoolInit(AudioAllocPool* pool, void* addr, size_t size); +void AudioHeap_PopCache(s32 tableType); +void AudioHeap_InitMainPool(size_t initPoolSize); void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id); void* AudioHeap_SearchCaches(s32 tableType, s32 cache, s32 id); -// void func_8018C3D8(void); -// void func_8018C8E8(void); -// void func_8018C93C(void); -// void func_8018C994(void); -// void func_8018CB70(void); -// void func_8018CB78(void); -// void func_8018CC3C(void); +void AudioHeap_LoadFilter(s16* filter, s32 lowPassCutoff, s32 highPassCutoff); s32 AudioHeap_ResetStep(void); -// void func_8018CFAC(void); +void AudioHeap_Init(void); void* AudioHeap_SearchPermanentCache(s32 tableType, s32 id); void* AudioHeap_AllocPermanent(s32 tableType, s32 id, size_t size); -void* AudioHeap_AllocSampleCache(size_t size, s32 fontId, void* sampleAddr, s8 medium, s32 cache); -// void func_8018D6C8(void); -// void func_8018D760(void); -// void func_8018DA50(void); -// void func_8018DBC4(void); -// void func_8018DCB4(void); -// void func_8018DCF8(void); -// void func_8018DD98(void); -// void func_8018DDD4(void); -// void func_8018DF24(void); -// void func_8018DFE0(void); +void* AudioHeap_AllocSampleCache(size_t size, s32 sampleBankId, void* sampleAddr, s8 medium, s32 cache); void AudioHeap_ApplySampleBankCache(s32 sampleBankId); -// void func_8018E03C(void); -// void func_8018E2A8(void); -// void func_8018E344(void); -// void func_8018E8C8(void); +void AudioHeap_SetReverbData(s32 reverbIndex, u32 dataType, s32 data, s32 flags); void AudioLoad_DecreaseSampleDmaTtls(void); void* AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium); void AudioLoad_InitSampleDmaBuffers(s32 numNotes); @@ -3453,7 +3421,7 @@ void AudioSeq_SequenceChannelDisable(SequenceChannel* channel); // void func_80197B14(void); // void func_80197C0C(void); // void func_80197C8C(void); -// void func_80197D24(void); +void AudioSeq_SequencePlayerDisableAsFinished(SequencePlayer* seqPlayer); void AudioSeq_SequencePlayerDisable(SequencePlayer* seqPlayer); void AudioSeq_AudioListPushBack(AudioListItem* list, AudioListItem* item); void* AudioSeq_AudioListPopBack(AudioListItem* list); @@ -3476,9 +3444,9 @@ void func_80199268(s32* param_1); // void func_8019AA3C(void); // void func_8019AAF0(void); void AudioSeq_ResetSequencePlayer(SequencePlayer* seqPlayer); -// void func_8019AC10(void); +void AudioSeq_InitSequencePlayerChannels(s32 playerIdx); // void func_8019ACEC(void); -// void func_8019ADBC(void); +void AudioSeq_InitSequencePlayers(void); void func_8019AE40(s32 param_1, s32 param_2, u32 param_3, s32 param_4); void func_8019AEC0(UNK_PTR param_1, UNK_PTR param_2); // void func_8019AF00(void); diff --git a/include/variables.h b/include/variables.h index 1f198a15b..1f0c54e3a 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1617,18 +1617,10 @@ extern Vec3s gZeroVec3s; extern Mtx gIdentityMtx; extern MtxF gIdentityMtxF; // extern UNK_TYPE1 D_801D1E70; -// extern UNK_TYPE1 gLowPassFilterData; -// extern UNK_TYPE1 gHighPassFilterData; -// extern UNK_TYPE1 gBandStopFilterData; -// extern UNK_TYPE1 gBandPassFilterData; -// extern UNK_TYPE1 gSawtoothWaveSample; -// extern UNK_TYPE1 gTriangleWaveSample; -// extern UNK_TYPE1 gSineWaveSample; -// extern UNK_TYPE1 gSquareWaveSample; -// extern UNK_TYPE1 gWhiteNoiseSample; -// extern UNK_TYPE1 D_801D4790; -// extern UNK_TYPE1 gEighthPulseWaveSample; -// extern UNK_TYPE1 gQuarterPulseWaveSample; +extern s16 gLowPassFilterData[]; +extern s16 gHighPassFilterData[]; +extern s16 gBandStopFilterData[]; +extern s16 gBandPassFilterData[]; extern s16* gWaveSamples[9]; extern UNK_PTR D_801D4D98; extern UNK_PTR D_801D4DB0; @@ -1837,7 +1829,7 @@ extern s8 D_801DB4B8; // extern UNK_TYPE1 D_801DB8B8; // extern UNK_TYPE1 D_801DB900; extern UNK_PTR D_801DB930; -extern AudioSpec D_801DB958[21]; +extern AudioSpec gAudioSpecs[21]; // rodata extern f32 D_801DBDF0; @@ -3466,7 +3458,7 @@ extern StackEntry sys_flashromStackEntry; extern OSThread sys_flashromOSThread; extern s80185D40 D_801FD008; extern OSMesg D_801FD034; -// extern UNK_TYPE1 D_801FD120; +extern s32 D_801FD120; // extern UNK_TYPE1 D_801FD140; // extern UNK_TYPE1 D_801FD158; // extern UNK_TYPE1 D_801FD198; diff --git a/src/code/audio/audio_heap.c b/src/code/audio/audio_heap.c index 70c737930..b06f6a577 100644 --- a/src/code/audio/audio_heap.c +++ b/src/code/audio/audio_heap.c @@ -1,111 +1,1687 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B0F0.s") +void* AudioHeap_SearchRegularCaches(s32 tableType, s32 cache, s32 id); +void AudioHeap_InitSampleCaches(size_t persistentSampleCacheSize, size_t temporarySampleCacheSize); +SampleCacheEntry* AudioHeap_AllocTemporarySampleCacheEntry(size_t size); +void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry); +void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample); +SampleCacheEntry* AudioHeap_AllocPersistentSampleCacheEntry(size_t size); +void AudioHeap_DiscardSampleCaches(void); +void AudioHeap_DiscardSampleBank(s32 sampleBankId); +void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId); +void AudioHeap_DiscardSampleBanks(void); +void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B10C.s") +#define gTatumsPerBeat (gAudioTatumInit[1]) -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B250.s") +f32 func_8018B0F0(f32 arg0) { + return 256.0f * gAudioContext.audioBufferParameters.unkUpdatesPerFrameScaled / arg0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_DiscardFont.s") +void func_8018B10C(void) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B3FC.s") + gAudioContext.unk_3520[255] = func_8018B0F0(0.25f); + gAudioContext.unk_3520[254] = func_8018B0F0(0.33f); + gAudioContext.unk_3520[253] = func_8018B0F0(0.5f); + gAudioContext.unk_3520[252] = func_8018B0F0(0.66f); + gAudioContext.unk_3520[251] = func_8018B0F0(0.75f); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B474.s") + for (i = 128; i < 251; i++) { + gAudioContext.unk_3520[i] = func_8018B0F0(251 - i); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_WritebackDCache.s") + for (i = 16; i < 128; i++) { + gAudioContext.unk_3520[i] = func_8018B0F0(4 * (143 - i)); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B520.s") + for (i = 1; i < 16; i++) { + gAudioContext.unk_3520[i] = func_8018B0F0(60 * (23 - i)); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_AllocAttemptExternal.s") + gAudioContext.unk_3520[0] = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemory.s") +void AudioHeap_ResetLoadStatus(void) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B608.s") + for (i = 0; i < ARRAY_COUNT(gAudioContext.fontLoadStatus); i++) { + if (gAudioContext.fontLoadStatus[i] != LOAD_STATUS_5) { + gAudioContext.fontLoadStatus[i] = LOAD_STATUS_0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_AllocZeroed.s") + for (i = 0; i < ARRAY_COUNT(gAudioContext.sampleFontLoadStatus); i++) { + if (gAudioContext.sampleFontLoadStatus[i] != LOAD_STATUS_5) { + gAudioContext.sampleFontLoadStatus[i] = LOAD_STATUS_0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B69C.s") + for (i = 0; i < ARRAY_COUNT(gAudioContext.seqLoadStatus); i++) { + if (gAudioContext.seqLoadStatus[i] != LOAD_STATUS_5) { + gAudioContext.seqLoadStatus[i] = LOAD_STATUS_0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_Alloc.s") +void AudioHeap_DiscardFont(s32 fontId) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_AllocPoolInit.s") + for (i = 0; i < gAudioContext.numNotes; i++) { + Note* note = &gAudioContext.notes[i]; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B768.s") + if (note->playbackState.fontId == fontId) { + if ((note->playbackState.unk_04 == 0) && (note->playbackState.priority != 0)) { + note->playbackState.parentLayer->enabled = false; + note->playbackState.parentLayer->finished = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B77C.s") + AudioPlayback_NoteDisable(note); + AudioPlayback_AudioListRemove(¬e->listItem); + AudioSeq_AudioListPushBack(&gAudioContext.noteFreeLists.disabled, ¬e->listItem); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B7AC.s") +void AudioHeap_ReleaseNotesForFont(s32 fontId) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B7BC.s") + for (i = 0; i < gAudioContext.numNotes; i++) { + Note* note = &gAudioContext.notes[i]; + NotePlaybackState* playbackState = ¬e->playbackState; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_InitMainPool.s") + if (playbackState->fontId == fontId) { + if (playbackState->priority != 0) { + playbackState->priority = 1; + playbackState->adsr.fadeOutVel = gAudioContext.audioBufferParameters.updatesPerFrameInv; + playbackState->adsr.action.s.release = true; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B95C.s") +void AudioHeap_DiscardSequence(s32 seqId) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B9E0.s") + for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + if (gAudioContext.seqPlayers[i].enabled && gAudioContext.seqPlayers[i].seqId == seqId) { + AudioSeq_SequencePlayerDisable(&gAudioContext.seqPlayers[i]); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018BA64.s") +/** + * Perform a writeback from the L1 data cache to the ram. + */ +void* AudioHeap_WritebackDCache(void* addr, size_t size) { + Audio_WritebackDCache(addr, size); + if (addr) {} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018BB28.s") + // KSEG0 to KSEG1 (ensures data is written straight to ram instead of the data cache) + return OS_PHYSICAL_TO_K1(OS_K0_TO_PHYSICAL(addr)); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_AllocCached.s") +/** + * Attempt to allocated space on an external device. If no external device is available, + * then allocate space on the pool provided in the argument. + * Afterwards, zero all data pool the new allocated space + */ +void* AudioHeap_AllocZeroedAttemptExternal(AudioAllocPool* pool, size_t size) { + void* addr = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_SearchCaches.s") + if (gAudioContext.externalPool.startAddr != NULL) { + addr = AudioHeap_AllocZeroed(&gAudioContext.externalPool, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C3D8.s") + if (addr == NULL) { + addr = AudioHeap_AllocZeroed(pool, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C4E4.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C8B8.s") +/** + * Attempt to allocated space on an external device. If no external device is available, + * then allocate space on the pool provided in the argument + */ +void* AudioHeap_AllocAttemptExternal(AudioAllocPool* pool, size_t size) { + void* addr = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C8E8.s") + if (gAudioContext.externalPool.startAddr != NULL) { + addr = AudioHeap_Alloc(&gAudioContext.externalPool, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C93C.s") + if (addr == NULL) { + addr = AudioHeap_Alloc(pool, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C994.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CB70.s") +void* AudioHeap_AllocDmaMemory(AudioAllocPool* pool, size_t size) { + void* addr = AudioHeap_Alloc(pool, size); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CB78.s") + if (addr != NULL) { + addr = AudioHeap_WritebackDCache(addr, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CC3C.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_ResetStep.s") +void* AudioHeap_AllocDmaMemoryZeroed(AudioAllocPool* pool, size_t size) { + void* addr = AudioHeap_AllocZeroed(pool, size); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CFAC.s") + if (addr != NULL) { + addr = AudioHeap_WritebackDCache(addr, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_SearchPermanentCache.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_AllocPermanent.s") +/** + * Allocates space on a pool contained withing the heap and sets all the allocated space to 0 + */ +void* AudioHeap_AllocZeroed(AudioAllocPool* pool, size_t size) { + u8* addr = AudioHeap_Alloc(pool, size); + u8* ptr; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_AllocSampleCache.s") + if (addr != NULL) { + for (ptr = addr; ptr < pool->curAddr; ptr++) { + *ptr = 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D6C8.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D760.s") +/** + * Tests the pool to see if the requested allocation would fit without actually allocating space. + * Returns NULL if there is not enough space on the pool. + * Else, return the address that would have been allocated + */ +void* AudioHeap_TestAlloc(AudioAllocPool* pool, size_t size) { + u8* oldAddr = pool->curAddr; + void* addr = AudioHeap_Alloc(pool, size); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DA50.s") + // remove allocation from pool + if (addr != NULL) { + pool->curAddr = oldAddr; + pool->count--; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DBC4.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DCB4.s") +/** + * Allocates space on the pool contained withing the heap. If there is not enough space on the pool, return NULL + */ +void* AudioHeap_Alloc(AudioAllocPool* pool, size_t size) { + size_t alignedSize = ALIGN16(size); + u8* curAddr = pool->curAddr; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DCF8.s") + if ((pool->startAddr + pool->size) >= (pool->curAddr + alignedSize)) { + pool->curAddr += alignedSize; + } else { + return NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DD98.s") + pool->count++; + return curAddr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DDD4.s") +/** + * Initialize a pool at the requested address with the requested size. + * Store the metadata of this pool in AudioAllocPool* pool + */ +void AudioHeap_AllocPoolInit(AudioAllocPool* pool, void* addr, size_t size) { + pool->curAddr = pool->startAddr = (u8*)ALIGN16((uintptr_t)addr); + pool->size = size - ((uintptr_t)addr & 0xF); + pool->count = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DF24.s") +void AudioHeap_ClearPersistentCache(AudioPersistentCache* persistent) { + persistent->pool.count = 0; + persistent->numEntries = 0; + persistent->pool.curAddr = persistent->pool.startAddr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DFE0.s") +void AudioHeap_ClearTemporaryCache(AudioTemporaryCache* temporary) { + temporary->pool.count = 0; + temporary->pool.curAddr = temporary->pool.startAddr; + temporary->nextSide = 0; + temporary->entries[0].addr = temporary->pool.startAddr; + temporary->entries[1].addr = temporary->pool.startAddr + temporary->pool.size; + temporary->entries[0].id = -1; + temporary->entries[1].id = -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_ApplySampleBankCache.s") +void AudioHeap_ResetPool(AudioAllocPool* pool) { + pool->count = 0; + pool->curAddr = pool->startAddr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E03C.s") +void AudioHeap_PopCache(s32 tableType) { + AudioCache* loadedCache; + AudioAllocPool* persistentHeap; + AudioPersistentCache* persistent; + void* entryAddr; + u8* loadStatus; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E2A8.s") + switch (tableType) { + case SEQUENCE_TABLE: + loadedCache = &gAudioContext.seqCache; + loadStatus = gAudioContext.seqLoadStatus; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E344.s") + case FONT_TABLE: + loadedCache = &gAudioContext.fontCache; + loadStatus = gAudioContext.fontLoadStatus; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E8C8.s") + case SAMPLE_TABLE: + loadedCache = &gAudioContext.sampleBankCache; + loadStatus = gAudioContext.sampleFontLoadStatus; + break; + } + + persistent = &loadedCache->persistent; + persistentHeap = &persistent->pool; + + if (persistent->numEntries == 0) { + return; + } + + entryAddr = persistent->entries[persistent->numEntries - 1].addr; + persistentHeap->curAddr = entryAddr; + persistentHeap->count--; + + if (tableType == SAMPLE_TABLE) { + AudioHeap_DiscardSampleBank(persistent->entries[persistent->numEntries - 1].id); + } + if (tableType == FONT_TABLE) { + AudioHeap_DiscardFont(persistent->entries[persistent->numEntries - 1].id); + } + + loadStatus[persistent->entries[persistent->numEntries - 1].id] = LOAD_STATUS_0; + persistent->numEntries--; +} + +void AudioHeap_InitMainPool(size_t mainPoolSplitSize) { + AudioHeap_AllocPoolInit(&gAudioContext.audioInitPool, gAudioContext.audioHeap, mainPoolSplitSize); + AudioHeap_AllocPoolInit(&gAudioContext.audioSessionPool, gAudioContext.audioHeap + mainPoolSplitSize, + gAudioContext.audioHeapSize - mainPoolSplitSize); + + gAudioContext.externalPool.startAddr = NULL; +} + +void AudioHeap_InitSessionPool(AudioSessionPoolSplit* split) { + gAudioContext.audioSessionPool.curAddr = gAudioContext.audioSessionPool.startAddr; + + AudioHeap_AllocPoolInit(&gAudioContext.miscPool, + AudioHeap_Alloc(&gAudioContext.audioSessionPool, split->miscPoolSize), split->miscPoolSize); + AudioHeap_AllocPoolInit(&gAudioContext.cachePool, + AudioHeap_Alloc(&gAudioContext.audioSessionPool, split->cachePoolSize), + split->cachePoolSize); +} + +void AudioHeap_InitCachePool(AudioCachePoolSplit* split) { + gAudioContext.cachePool.curAddr = gAudioContext.cachePool.startAddr; + + AudioHeap_AllocPoolInit(&gAudioContext.persistentCommonPool, + AudioHeap_Alloc(&gAudioContext.cachePool, split->persistentCommonPoolSize), + split->persistentCommonPoolSize); + AudioHeap_AllocPoolInit(&gAudioContext.temporaryCommonPool, + AudioHeap_Alloc(&gAudioContext.cachePool, split->temporaryCommonPoolSize), + split->temporaryCommonPoolSize); +} + +void AudioHeap_InitPersistentCache(AudioCommonPoolSplit* split) { + gAudioContext.persistentCommonPool.curAddr = gAudioContext.persistentCommonPool.startAddr; + + AudioHeap_AllocPoolInit(&gAudioContext.seqCache.persistent.pool, + AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->seqCacheSize), + split->seqCacheSize); + AudioHeap_AllocPoolInit(&gAudioContext.fontCache.persistent.pool, + AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->fontCacheSize), + split->fontCacheSize); + AudioHeap_AllocPoolInit(&gAudioContext.sampleBankCache.persistent.pool, + AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->sampleBankCacheSize), + split->sampleBankCacheSize); + + AudioHeap_ClearPersistentCache(&gAudioContext.seqCache.persistent); + AudioHeap_ClearPersistentCache(&gAudioContext.fontCache.persistent); + AudioHeap_ClearPersistentCache(&gAudioContext.sampleBankCache.persistent); +} + +void AudioHeap_InitTemporaryCache(AudioCommonPoolSplit* split) { + gAudioContext.temporaryCommonPool.curAddr = gAudioContext.temporaryCommonPool.startAddr; + + AudioHeap_AllocPoolInit(&gAudioContext.seqCache.temporary.pool, + AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->seqCacheSize), + split->seqCacheSize); + AudioHeap_AllocPoolInit(&gAudioContext.fontCache.temporary.pool, + AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->fontCacheSize), + split->fontCacheSize); + AudioHeap_AllocPoolInit(&gAudioContext.sampleBankCache.temporary.pool, + AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->sampleBankCacheSize), + split->sampleBankCacheSize); + + AudioHeap_ClearTemporaryCache(&gAudioContext.seqCache.temporary); + AudioHeap_ClearTemporaryCache(&gAudioContext.fontCache.temporary); + AudioHeap_ClearTemporaryCache(&gAudioContext.sampleBankCache.temporary); +} + +void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { + AudioCache* loadedCache; + AudioTemporaryCache* temporaryCache; + AudioAllocPool* temporaryPool; + void* persistentAddr; + void* temporaryAddr; + u8 loadStatusEntry0; + u8 loadStatusEntry1; + s32 i; + u8* loadStatus; + s32 side; + + switch (tableType) { + case SEQUENCE_TABLE: + loadedCache = &gAudioContext.seqCache; + loadStatus = gAudioContext.seqLoadStatus; + break; + + case FONT_TABLE: + loadedCache = &gAudioContext.fontCache; + loadStatus = gAudioContext.fontLoadStatus; + break; + + case SAMPLE_TABLE: + loadedCache = &gAudioContext.sampleBankCache; + loadStatus = gAudioContext.sampleFontLoadStatus; + break; + } + + if (cache == CACHE_TEMPORARY) { + temporaryCache = &loadedCache->temporary; + temporaryPool = &temporaryCache->pool; + + if ((s32)temporaryPool->size < (s32)size) { + return NULL; + } + + loadStatusEntry0 = + (temporaryCache->entries[0].id == -1) ? LOAD_STATUS_0 : loadStatus[temporaryCache->entries[0].id]; + loadStatusEntry1 = + (temporaryCache->entries[1].id == -1) ? LOAD_STATUS_0 : loadStatus[temporaryCache->entries[1].id]; + + if (tableType == FONT_TABLE) { + if (loadStatusEntry0 == LOAD_STATUS_4) { + for (i = 0; i < gAudioContext.numNotes; i++) { + if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && + gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + break; + } + } + + if (i == gAudioContext.numNotes) { + AudioLoad_SetFontLoadStatus(temporaryCache->entries[0].id, LOAD_STATUS_3); + loadStatusEntry0 = LOAD_STATUS_3; + } + } + + if (loadStatusEntry1 == LOAD_STATUS_4) { + for (i = 0; i < gAudioContext.numNotes; i++) { + if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && + gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + break; + } + } + + if (i == gAudioContext.numNotes) { + AudioLoad_SetFontLoadStatus(temporaryCache->entries[1].id, LOAD_STATUS_3); + loadStatusEntry1 = LOAD_STATUS_3; + } + } + } + + if (loadStatusEntry0 == LOAD_STATUS_0) { + temporaryCache->nextSide = 0; + } else if (loadStatusEntry1 == LOAD_STATUS_0) { + temporaryCache->nextSide = 1; + } else if ((loadStatusEntry0 == LOAD_STATUS_3) && (loadStatusEntry1 == LOAD_STATUS_3)) { + // Use the opposite side from last time. + } else if (loadStatusEntry0 == LOAD_STATUS_3) { + temporaryCache->nextSide = 0; + } else if (loadStatusEntry1 == LOAD_STATUS_3) { + temporaryCache->nextSide = 1; + } else { + // Check if there is a side which isn't in active use, if so, evict that one. + if (tableType == SEQUENCE_TABLE) { + if (loadStatusEntry0 == LOAD_STATUS_2) { + for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + if (gAudioContext.seqPlayers[i].enabled && + gAudioContext.seqPlayers[i].seqId == temporaryCache->entries[0].id) { + break; + } + } + + if (i == gAudioContext.audioBufferParameters.numSequencePlayers) { + temporaryCache->nextSide = 0; + goto done; + } + } + + if (loadStatusEntry1 == LOAD_STATUS_2) { + for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + if (gAudioContext.seqPlayers[i].enabled && + gAudioContext.seqPlayers[i].seqId == temporaryCache->entries[1].id) { + break; + } + } + + if (i == gAudioContext.audioBufferParameters.numSequencePlayers) { + temporaryCache->nextSide = 1; + goto done; + } + } + } else if (tableType == FONT_TABLE) { + if (loadStatusEntry0 == LOAD_STATUS_2) { + for (i = 0; i < gAudioContext.numNotes; i++) { + if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && + gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + break; + } + } + if (i == gAudioContext.numNotes) { + temporaryCache->nextSide = 0; + goto done; + } + } + + if (loadStatusEntry1 == LOAD_STATUS_2) { + for (i = 0; i < gAudioContext.numNotes; i++) { + if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && + gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + break; + } + } + if (i == gAudioContext.numNotes) { + temporaryCache->nextSide = 1; + goto done; + } + } + } + + // No such luck. Evict the side that wasn't chosen last time, except + // if it is being loaded into. + if (temporaryCache->nextSide == 0) { + if (loadStatusEntry0 == LOAD_STATUS_1) { + if (loadStatusEntry1 == LOAD_STATUS_1) { + goto fail; + } + temporaryCache->nextSide = 1; + } + } else { + if (loadStatusEntry1 == LOAD_STATUS_1) { + if (loadStatusEntry0 == LOAD_STATUS_1) { + goto fail; + } + temporaryCache->nextSide = 0; + } + } + + if (0) { + fail: + // Both sides are being loaded into. + return NULL; + } + } + done: + + side = temporaryCache->nextSide; + + if (temporaryCache->entries[side].id != -1) { + if (tableType == SAMPLE_TABLE) { + AudioHeap_DiscardSampleBank(temporaryCache->entries[side].id); + } + + loadStatus[temporaryCache->entries[side].id] = LOAD_STATUS_0; + + if (tableType == FONT_TABLE) { + AudioHeap_DiscardFont(temporaryCache->entries[side].id); + } + } + + switch (side) { + case 0: + temporaryCache->entries[0].addr = temporaryPool->startAddr; + temporaryCache->entries[0].id = id; + temporaryCache->entries[0].size = size; + temporaryPool->curAddr = temporaryPool->startAddr + size; + + if ((temporaryCache->entries[1].id != -1) && + (temporaryCache->entries[1].addr < temporaryPool->curAddr)) { + if (tableType == SAMPLE_TABLE) { + AudioHeap_DiscardSampleBank(temporaryCache->entries[1].id); + } + + loadStatus[temporaryCache->entries[1].id] = LOAD_STATUS_0; + + switch (tableType) { + case SEQUENCE_TABLE: + AudioHeap_DiscardSequence((s32)temporaryCache->entries[1].id); + break; + + case FONT_TABLE: + AudioHeap_DiscardFont((s32)temporaryCache->entries[1].id); + break; + } + + temporaryCache->entries[1].id = -1; + temporaryCache->entries[1].addr = temporaryPool->startAddr + temporaryPool->size; + } + + temporaryAddr = temporaryCache->entries[0].addr; + break; + + case 1: + temporaryCache->entries[1].addr = + (u8*)((uintptr_t)(temporaryPool->startAddr + temporaryPool->size - size) & ~0xF); + temporaryCache->entries[1].id = id; + temporaryCache->entries[1].size = size; + if ((temporaryCache->entries[0].id != -1) && + (temporaryCache->entries[1].addr < temporaryPool->curAddr)) { + if (tableType == SAMPLE_TABLE) { + AudioHeap_DiscardSampleBank(temporaryCache->entries[0].id); + } + + loadStatus[temporaryCache->entries[0].id] = LOAD_STATUS_0; + + switch (tableType) { + case SEQUENCE_TABLE: + AudioHeap_DiscardSequence(temporaryCache->entries[0].id); + break; + + case FONT_TABLE: + AudioHeap_DiscardFont(temporaryCache->entries[0].id); + break; + } + + temporaryCache->entries[0].id = -1; + temporaryPool->curAddr = temporaryPool->startAddr; + } + + temporaryAddr = temporaryCache->entries[1].addr; + break; + + default: + return NULL; + } + + temporaryCache->nextSide ^= 1; + return temporaryAddr; + } + + persistentAddr = AudioHeap_Alloc(&loadedCache->persistent.pool, size); + loadedCache->persistent.entries[loadedCache->persistent.numEntries].addr = persistentAddr; + + if (persistentAddr == NULL) { + switch (cache) { + case CACHE_EITHER: + return AudioHeap_AllocCached(tableType, size, CACHE_TEMPORARY, id); + + case CACHE_TEMPORARY: + case CACHE_PERSISTENT: + return NULL; + } + } + + loadedCache->persistent.entries[loadedCache->persistent.numEntries].id = id; + loadedCache->persistent.entries[loadedCache->persistent.numEntries].size = size; + + return loadedCache->persistent.entries[loadedCache->persistent.numEntries++].addr; +} + +void* AudioHeap_SearchCaches(s32 tableType, s32 cache, s32 id) { + void* addr; + + // Always search the permanent cache in addition to the regular ones. + addr = AudioHeap_SearchPermanentCache(tableType, id); + if (addr != NULL) { + return addr; + } + if (cache == CACHE_PERMANENT) { + return NULL; + } + return AudioHeap_SearchRegularCaches(tableType, cache, id); +} + +void* AudioHeap_SearchRegularCaches(s32 tableType, s32 cache, s32 id) { + u32 i; + AudioCache* loadedCache; + AudioTemporaryCache* temporary; + AudioPersistentCache* persistent; + + switch (tableType) { + case SEQUENCE_TABLE: + loadedCache = &gAudioContext.seqCache; + break; + + case FONT_TABLE: + loadedCache = &gAudioContext.fontCache; + break; + + case SAMPLE_TABLE: + loadedCache = &gAudioContext.sampleBankCache; + break; + } + + temporary = &loadedCache->temporary; + + if (cache == CACHE_TEMPORARY) { + if (temporary->entries[0].id == id) { + temporary->nextSide = 1; + return temporary->entries[0].addr; + } else if (temporary->entries[1].id == id) { + temporary->nextSide = 0; + return temporary->entries[1].addr; + } else { + return NULL; + } + } + + persistent = &loadedCache->persistent; + + for (i = 0; i < persistent->numEntries; i++) { + if (persistent->entries[i].id == id) { + return persistent->entries[i].addr; + } + } + + if (cache == CACHE_EITHER) { + return AudioHeap_SearchCaches(tableType, CACHE_TEMPORARY, id); + } + return NULL; +} + +void func_8018C4E4(f32 p, f32 q, u16* out) { + // With the bug below fixed, this mysterious unused function computes two recurrences + // out[0..7] = a_i, out[8..15] = b_i, where + // a_{-2} = b_{-1} = 262159 = 2^18 + 15 + // a_{-1} = b_{-2} = 0 + // a_i = q * a_{i-1} + p * a_{i-2} + // b_i = q * b_{i-1} + p * b_{i-2} + // These grow exponentially if p < -1 or p + |q| > 1. + s32 i; + f32 tmp[16]; + + tmp[0] = (f32)(q * 262159.0f); + tmp[8] = (f32)(p * 262159.0f); + tmp[1] = (f32)((q * p) * 262159.0f); + tmp[9] = (f32)(((p * p) + q) * 262159.0f); + + for (i = 2; i < 8; i++) { + //! @bug value should be stored to tmp[i] and tmp[8 + i], otherwise we read + //! garbage in later loop iterations. + out[i] = q * tmp[i - 2] + p * tmp[i - 1]; + out[8 + i] = q * tmp[6 + i] + p * tmp[7 + i]; + } + + for (i = 0; i < 16; i++) { + out[i] = tmp[i]; + } +} + +void AudioHeap_ClearFilter(s16* filter) { + s32 i; + + for (i = 0; i < 8; i++) { + filter[i] = 0; + } +} + +void AudioHeap_LoadLowPassFilter(s16* filter, s32 cutoff) { + s32 i; + s16* ptr = &gLowPassFilterData[8 * cutoff]; + + for (i = 0; i < 8; i++) { + filter[i] = ptr[i]; + } +} + +void AudioHeap_LoadHighPassFilter(s16* filter, s32 cutoff) { + s32 i; + s16* ptr = &gHighPassFilterData[8 * (cutoff - 1)]; + + for (i = 0; i < 8; i++) { + filter[i] = ptr[i]; + } +} + +void AudioHeap_LoadFilter(s16* filter, s32 lowPassCutoff, s32 highPassCutoff) { + s32 i; + s32 j; + s32 k; + s32 cutOff; + + //! @bug filter is never set if (lowPassCutoff == highPassCutoff) and does not equal 0 + if (lowPassCutoff == 0 && highPassCutoff == 0) { + // Identity filter + AudioHeap_LoadLowPassFilter(filter, 0); + } else if (highPassCutoff == 0) { + AudioHeap_LoadLowPassFilter(filter, lowPassCutoff); + } else if (lowPassCutoff == 0) { + AudioHeap_LoadHighPassFilter(filter, highPassCutoff); + } else { + k = 0; + j = 14; + + cutOff = lowPassCutoff; + if (lowPassCutoff < highPassCutoff) { + + for (i = 1; i < cutOff; i++) { + k += j; + j--; + } + + k += highPassCutoff - lowPassCutoff - 1; + for (i = 0; i < 8; i++) { + //! @bug should be gBandStopFilterData[8 * k + i]; + filter[i] = gBandStopFilterData[k + i]; + } + } else if (highPassCutoff < lowPassCutoff) { + + cutOff = highPassCutoff; + for (i = 1; i < cutOff; i++) { + k += j; + j--; + } + + k += lowPassCutoff - highPassCutoff - 1; + for (i = 0; i < 8; i++) { + //! @bug should be gBandPassFilterData[8 * k + i]; + filter[i] = gBandPassFilterData[k + i]; + } + } + } +} + +void AudioHeap_UpdateReverb(SynthesisReverb* reverb) { +} + +void AudioHeap_UpdateReverbs(void) { + s32 count; + s32 i; + s32 j; + + if (gAudioContext.audioBufferParameters.specUnk4 == 2) { + count = 2; + } else { + count = 1; + } + + for (i = 0; i < gAudioContext.numSynthesisReverbs; i++) { + for (j = 0; j < count; j++) { + AudioHeap_UpdateReverb(&gAudioContext.synthesisReverbs[i]); + } + } +} + +/** + * Clear the Audio Interface Buffers + */ +void AudioHeap_ClearAiBuffers(void) { + s32 curAiBuffferIndex = gAudioContext.curAiBuffferIndex; + s32 i; + + gAudioContext.aiBufLengths[curAiBuffferIndex] = gAudioContext.audioBufferParameters.minAiBufferLength; + + for (i = 0; i < AIBUF_LEN; i++) { + gAudioContext.aiBuffers[curAiBuffferIndex][i] = 0; + } +} + +s32 AudioHeap_ResetStep(void) { + s32 i; + s32 j; + s32 count; + + if (gAudioContext.audioBufferParameters.specUnk4 == 2) { + count = 2; + } else { + count = 1; + } + + switch (gAudioContext.resetStatus) { + case 5: + for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + AudioSeq_SequencePlayerDisableAsFinished(&gAudioContext.seqPlayers[i]); + } + gAudioContext.audioResetFadeOutFramesLeft = 2 / count; + gAudioContext.resetStatus--; + break; + + case 4: + if (gAudioContext.audioResetFadeOutFramesLeft != 0) { + gAudioContext.audioResetFadeOutFramesLeft--; + AudioHeap_UpdateReverbs(); + } else { + for (i = 0; i < gAudioContext.numNotes; i++) { + if (gAudioContext.notes[i].noteSubEu.bitField0.enabled && + gAudioContext.notes[i].playbackState.adsr.action.s.state != ADSR_STATE_DISABLED) { + gAudioContext.notes[i].playbackState.adsr.fadeOutVel = + gAudioContext.audioBufferParameters.updatesPerFrameInv; + gAudioContext.notes[i].playbackState.adsr.action.s.release = true; + } + } + gAudioContext.audioResetFadeOutFramesLeft = 8 / count; + gAudioContext.resetStatus--; + } + break; + + case 3: + if (gAudioContext.audioResetFadeOutFramesLeft != 0) { + gAudioContext.audioResetFadeOutFramesLeft--; + AudioHeap_UpdateReverbs(); + } else { + gAudioContext.audioResetFadeOutFramesLeft = 2 / count; + gAudioContext.resetStatus--; + } + break; + + case 2: + AudioHeap_ClearAiBuffers(); + if (gAudioContext.audioResetFadeOutFramesLeft != 0) { + gAudioContext.audioResetFadeOutFramesLeft--; + } else { + gAudioContext.resetStatus--; + AudioHeap_DiscardSampleCaches(); + AudioHeap_DiscardSampleBanks(); + } + break; + + case 1: + AudioHeap_Init(); + gAudioContext.resetStatus = 0; + for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufLengths); i++) { + gAudioContext.aiBufLengths[i] = gAudioContext.audioBufferParameters.maxAiBufferLength; + for (j = 0; j < AIBUF_LEN; j++) { + gAudioContext.aiBuffers[i][j] = 0; + } + } + break; + } + + if (gAudioContext.resetStatus < 3) { + return false; + } + + return true; +} + +void AudioHeap_Init(void) { + s32 pad1[4]; + s16* addr; + size_t persistentSize; + size_t temporarySize; + size_t cachePoolSize; + size_t miscPoolSize; + u32 intMask; + s32 i; + s32 j; + s32 pad2; + AudioSpec* spec = &gAudioSpecs[gAudioContext.audioResetSpecIdToLoad]; // Audio Specifications + + gAudioContext.sampleDmaCount = 0; + + // audio buffer parameters + gAudioContext.audioBufferParameters.samplingFreq = spec->samplingFreq; + gAudioContext.audioBufferParameters.aiSamplingFreq = + osAiSetFrequency(gAudioContext.audioBufferParameters.samplingFreq); + + gAudioContext.audioBufferParameters.samplesPerFrameTarget = + ALIGN16(gAudioContext.audioBufferParameters.samplingFreq / gAudioContext.refreshRate); + gAudioContext.audioBufferParameters.minAiBufferLength = + gAudioContext.audioBufferParameters.samplesPerFrameTarget - 0x10; + gAudioContext.audioBufferParameters.maxAiBufferLength = + gAudioContext.audioBufferParameters.samplesPerFrameTarget + 0x10; + gAudioContext.audioBufferParameters.updatesPerFrame = + ((gAudioContext.audioBufferParameters.samplesPerFrameTarget + 0x10) / 0xD0) + 1; + gAudioContext.audioBufferParameters.samplesPerUpdate = (gAudioContext.audioBufferParameters.samplesPerFrameTarget / + gAudioContext.audioBufferParameters.updatesPerFrame) & + ~7; + gAudioContext.audioBufferParameters.samplesPerUpdateMax = gAudioContext.audioBufferParameters.samplesPerUpdate + 8; + gAudioContext.audioBufferParameters.samplesPerUpdateMin = gAudioContext.audioBufferParameters.samplesPerUpdate - 8; + gAudioContext.audioBufferParameters.resampleRate = 32000.0f / (s32)gAudioContext.audioBufferParameters.samplingFreq; + gAudioContext.audioBufferParameters.unkUpdatesPerFrameScaled = + (1.0f / 256.0f) / gAudioContext.audioBufferParameters.updatesPerFrame; + gAudioContext.audioBufferParameters.unk_24 = gAudioContext.audioBufferParameters.updatesPerFrame * 0.25f; + gAudioContext.audioBufferParameters.updatesPerFrameInv = 1.0f / gAudioContext.audioBufferParameters.updatesPerFrame; + + // sample dma size + gAudioContext.sampleDmaBufSize1 = spec->sampleDmaBufSize1; + gAudioContext.sampleDmaBufSize2 = spec->sampleDmaBufSize2; + + gAudioContext.numNotes = spec->numNotes; + gAudioContext.audioBufferParameters.numSequencePlayers = spec->numSequencePlayers; + + if (gAudioContext.audioBufferParameters.numSequencePlayers > 5) { + gAudioContext.audioBufferParameters.numSequencePlayers = 5; + } + + gAudioContext.unk_29BC = 8; + gAudioContext.unk_2 = spec->unk_14; + gAudioContext.tempoInternalToExternal = (u32)(gAudioContext.audioBufferParameters.updatesPerFrame * 2880000.0f / + gTatumsPerBeat / gAudioContext.unk_2960); + + gAudioContext.unk_2870 = gAudioContext.refreshRate; + gAudioContext.unk_2870 *= gAudioContext.audioBufferParameters.updatesPerFrame; + gAudioContext.unk_2870 /= gAudioContext.audioBufferParameters.aiSamplingFreq; + gAudioContext.unk_2870 /= gAudioContext.tempoInternalToExternal; + + gAudioContext.audioBufferParameters.specUnk4 = spec->unk_04; + gAudioContext.audioBufferParameters.samplesPerFrameTarget *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.maxAiBufferLength *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.minAiBufferLength *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.updatesPerFrame *= gAudioContext.audioBufferParameters.specUnk4; + + if (gAudioContext.audioBufferParameters.specUnk4 >= 2) { + gAudioContext.audioBufferParameters.maxAiBufferLength -= 0x10; + } + + // Determine the maximum allowable number of audio command list entries for the rsp microcode + gAudioContext.maxAudioCmds = + gAudioContext.numNotes * 20 * gAudioContext.audioBufferParameters.updatesPerFrame + spec->numReverbs * 30 + 800; + + // Calculate sizes for various caches on the audio heap + persistentSize = + spec->persistentSeqCacheSize + spec->persistentFontCacheSize + spec->persistentSampleBankCacheSize + 0x10; + temporarySize = + spec->temporarySeqCacheSize + spec->temporaryFontCacheSize + spec->temporarySampleBankCacheSize + 0x10; + cachePoolSize = persistentSize + temporarySize; + miscPoolSize = gAudioContext.audioSessionPool.size - cachePoolSize - 0x100; + + if (gAudioContext.externalPool.startAddr != NULL) { + gAudioContext.externalPool.curAddr = gAudioContext.externalPool.startAddr; + } + + // Session Pool Split (split into Cache and Misc heaps) + gAudioContext.sessionPoolSplit.miscPoolSize = miscPoolSize; + gAudioContext.sessionPoolSplit.cachePoolSize = cachePoolSize; + AudioHeap_InitSessionPool(&gAudioContext.sessionPoolSplit); + + // Cache Pool Split (Split into Persistent and Temporary heaps) + gAudioContext.cachePoolSplit.persistentCommonPoolSize = persistentSize; + gAudioContext.cachePoolSplit.temporaryCommonPoolSize = temporarySize; + AudioHeap_InitCachePool(&gAudioContext.cachePoolSplit); + + // Persistent Pool Split (Split into Sequences, SoundFonts, Samples) + gAudioContext.persistentCommonPoolSplit.seqCacheSize = spec->persistentSeqCacheSize; + gAudioContext.persistentCommonPoolSplit.fontCacheSize = spec->persistentFontCacheSize; + gAudioContext.persistentCommonPoolSplit.sampleBankCacheSize = spec->persistentSampleBankCacheSize; + AudioHeap_InitPersistentCache(&gAudioContext.persistentCommonPoolSplit); + + // Temporary Pool Split (Split into Sequences, SoundFonts, Samples) + gAudioContext.temporaryCommonPoolSplit.seqCacheSize = spec->temporarySeqCacheSize; + gAudioContext.temporaryCommonPoolSplit.fontCacheSize = spec->temporaryFontCacheSize; + gAudioContext.temporaryCommonPoolSplit.sampleBankCacheSize = spec->temporarySampleBankCacheSize; + AudioHeap_InitTemporaryCache(&gAudioContext.temporaryCommonPoolSplit); + + AudioHeap_ResetLoadStatus(); + + // Initialize notes + gAudioContext.notes = AudioHeap_AllocZeroed(&gAudioContext.miscPool, gAudioContext.numNotes * sizeof(Note)); + AudioPlayback_NoteInitAll(); + AudioPlayback_InitNoteFreeList(); + gAudioContext.noteSubsEu = + AudioHeap_AllocZeroed(&gAudioContext.miscPool, gAudioContext.audioBufferParameters.updatesPerFrame * + gAudioContext.numNotes * sizeof(NoteSubEu)); + + // Initialize audio binary interface command list buffer + for (j = 0; j < ARRAY_COUNT(gAudioContext.abiCmdBufs); j++) { + gAudioContext.abiCmdBufs[j] = + AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, gAudioContext.maxAudioCmds * sizeof(u64)); + } + + // Initialize unk_3520 (fadeOutVelocities for ADSR) + gAudioContext.unk_3520 = AudioHeap_Alloc(&gAudioContext.miscPool, 0x100 * sizeof(f32)); + func_8018B10C(); + + // Initialize reverbs + for (i = 0; i < ARRAY_COUNT(gAudioContext.synthesisReverbs); i++) { + gAudioContext.synthesisReverbs[i].useReverb = 0; + } + + gAudioContext.numSynthesisReverbs = spec->numReverbs; + for (i = 0; i < gAudioContext.numSynthesisReverbs; i++) { + AudioHeap_InitReverb(i, &spec->reverbSettings[i], 1); + } + + // Initialize sequence players + AudioSeq_InitSequencePlayers(); + for (j = 0; j < gAudioContext.audioBufferParameters.numSequencePlayers; j++) { + AudioSeq_InitSequencePlayerChannels(j); + AudioSeq_ResetSequencePlayer(&gAudioContext.seqPlayers[j]); + } + + // Initialize two additional caches on the audio heap to store individual audio samples + AudioHeap_InitSampleCaches(spec->persistentSampleCacheSize, spec->temporarySampleCacheSize); + AudioLoad_InitSampleDmaBuffers(gAudioContext.numNotes); + + // Initalize Loads + gAudioContext.preloadSampleStackTop = 0; + AudioLoad_InitSlowLoads(); + AudioLoad_InitScriptLoads(); + AudioLoad_InitAsyncLoads(); + gAudioContext.unk_4 = 0x1000; + AudioLoad_LoadPermanentSamples(); + + intMask = osSetIntMask(1); + osWritebackDCacheAll(); + osSetIntMask(intMask); +} + +void* AudioHeap_SearchPermanentCache(s32 tableType, s32 id) { + s32 i; + + for (i = 0; i < gAudioContext.permanentPool.count; i++) { + if (gAudioContext.permanentEntries[i].tableType == tableType && gAudioContext.permanentEntries[i].id == id) { + return gAudioContext.permanentEntries[i].addr; + } + } + return NULL; +} + +void* AudioHeap_AllocPermanent(s32 tableType, s32 id, size_t size) { + void* addr; + s32 index = gAudioContext.permanentPool.count; + + addr = AudioHeap_Alloc(&gAudioContext.permanentPool, size); + gAudioContext.permanentEntries[index].addr = addr; + + if (addr == NULL) { + return NULL; + } + + gAudioContext.permanentEntries[index].tableType = tableType; + gAudioContext.permanentEntries[index].id = id; + gAudioContext.permanentEntries[index].size = size; + //! @bug UB: missing return. "addr" is in v0 at this point, but doing an + // explicit return uses an additional register. + // return addr; +} + +void* AudioHeap_AllocSampleCache(size_t size, s32 sampleBankId, void* sampleAddr, s8 medium, s32 cache) { + SampleCacheEntry* entry; + + if (cache == CACHE_TEMPORARY) { + entry = AudioHeap_AllocTemporarySampleCacheEntry(size); + } else { + entry = AudioHeap_AllocPersistentSampleCacheEntry(size); + } + + if (entry != NULL) { + entry->sampleBankId = sampleBankId; + entry->sampleAddr = sampleAddr; + entry->origMedium = medium; + return entry->allocatedAddr; + } + return NULL; +} + +/** + * Initializes the persistent and temporary caches used for individual samples. Will attempt to use heap space available + * on the external pool. If no external pool is provided, then default to using space on the misc heap. + */ +void AudioHeap_InitSampleCaches(size_t persistentSampleCacheSize, size_t temporarySampleCacheSize) { + void* addr; + + addr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, persistentSampleCacheSize); + if (addr == NULL) { + gAudioContext.persistentSampleCache.pool.size = 0; + } else { + AudioHeap_AllocPoolInit(&gAudioContext.persistentSampleCache.pool, addr, persistentSampleCacheSize); + } + + addr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, temporarySampleCacheSize); + if (addr == NULL) { + gAudioContext.temporarySampleCache.pool.size = 0; + } else { + AudioHeap_AllocPoolInit(&gAudioContext.temporarySampleCache.pool, addr, temporarySampleCacheSize); + } + + gAudioContext.persistentSampleCache.numEntries = 0; + gAudioContext.temporarySampleCache.numEntries = 0; +} + +SampleCacheEntry* AudioHeap_AllocTemporarySampleCacheEntry(size_t size) { + s32 pad2[2]; + void* addr; + s32 pad3[2]; + u8* allocAfter; + u8* allocBefore; + s32 pad1; + s32 index; + s32 i; + SampleCacheEntry* entry; + AudioPreloadReq* preload; + AudioSampleCache* cache; + u8* startAddr; + u8* endAddr; + + cache = &gAudioContext.temporarySampleCache; + allocBefore = cache->pool.curAddr; + addr = AudioHeap_Alloc(&cache->pool, size); + if (addr == NULL) { + // Reset the heap and try again. We still keep pointers to within the + // heap, so we have to be careful to discard existing overlapping + // allocations further down. + u8* oldAddr = cache->pool.curAddr; + + cache->pool.curAddr = cache->pool.startAddr; + addr = AudioHeap_Alloc(&cache->pool, size); + if (addr == NULL) { + cache->pool.curAddr = oldAddr; + return NULL; + } + allocBefore = cache->pool.startAddr; + } + + allocAfter = cache->pool.curAddr; + + index = -1; + for (i = 0; i < gAudioContext.preloadSampleStackTop; i++) { + preload = &gAudioContext.preloadSampleStack[i]; + if (preload->isFree == false) { + startAddr = preload->ramAddr; + endAddr = preload->ramAddr + preload->sample->size - 1; + + if ((endAddr < allocBefore) && (startAddr < allocBefore)) { + continue; + } + if ((endAddr >= allocAfter) && (startAddr >= allocAfter)) { + continue; + } + + // Overlap, skip this preload. + preload->isFree = true; + } + } + + for (i = 0; i < cache->numEntries; i++) { + if (!cache->entries[i].inUse) { + continue; + } + + startAddr = cache->entries[i].allocatedAddr; + endAddr = startAddr + cache->entries[i].size - 1; + + if ((endAddr < allocBefore) && (startAddr < allocBefore)) { + continue; + } + if ((endAddr >= allocAfter) && (startAddr >= allocAfter)) { + continue; + } + + // Overlap, discard existing entry. + AudioHeap_DiscardSampleCacheEntry(&cache->entries[i]); + cache->entries[i].inUse = false; + if (index == -1) { + index = i; + } + } + + if (index == -1) { + for (i = 0; i < cache->numEntries; i++) { + if (!cache->entries[i].inUse) { + break; + } + } + + index = i; + if (index == cache->numEntries) { + if (cache->numEntries == 128) { + return NULL; + } + cache->numEntries++; + } + } + + entry = &cache->entries[index]; + entry->inUse = 1; + entry->allocatedAddr = addr; + entry->size = size; + + return entry; +} + +void AudioHeap_UnapplySampleCacheForFont(SampleCacheEntry* entry, s32 fontId) { + Drum* drum; + Instrument* inst; + SoundFontSound* sfx; + s32 instId; + s32 drumId; + s32 sfxId; + + for (instId = 0; instId < gAudioContext.soundFonts[fontId].numInstruments; instId++) { + inst = AudioPlayback_GetInstrumentInner(fontId, instId); + if (inst != NULL) { + if (inst->normalRangeLo != 0) { + AudioHeap_UnapplySampleCache(entry, inst->lowNotesSound.sample); + } + if (inst->normalRangeHi != 0x7F) { + AudioHeap_UnapplySampleCache(entry, inst->highNotesSound.sample); + } + AudioHeap_UnapplySampleCache(entry, inst->normalNotesSound.sample); + } + } + + for (drumId = 0; drumId < gAudioContext.soundFonts[fontId].numDrums; drumId++) { + drum = AudioPlayback_GetDrum(fontId, drumId); + if (drum != NULL) { + AudioHeap_UnapplySampleCache(entry, drum->sound.sample); + } + } + + for (sfxId = 0; sfxId < gAudioContext.soundFonts[fontId].numSfx; sfxId++) { + sfx = AudioPlayback_GetSfx(fontId, sfxId); + if (sfx != NULL) { + AudioHeap_UnapplySampleCache(entry, sfx->sample); + } + } +} + +void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry) { + s32 numFonts; + s32 sampleBankId1; + s32 sampleBankId2; + s32 fontId; + + numFonts = gAudioContext.soundFontTable->numEntries; + for (fontId = 0; fontId < numFonts; fontId++) { + sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + if (((sampleBankId1 != 0xFF) && (entry->sampleBankId == sampleBankId1)) || + ((sampleBankId2 != 0xFF) && (entry->sampleBankId == sampleBankId2)) || entry->sampleBankId == 0 || + entry->sampleBankId == 0xFE) { + if (AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, fontId) != NULL) { + if (1) {} + if (AudioLoad_IsFontLoadComplete(fontId) != 0) { + AudioHeap_UnapplySampleCacheForFont(entry, fontId); + } + } + } + } +} + +void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample) { + if (sample != NULL) { + if (sample->sampleAddr == entry->allocatedAddr) { + sample->sampleAddr = entry->sampleAddr; + sample->medium = entry->origMedium; + } + } +} + +SampleCacheEntry* AudioHeap_AllocPersistentSampleCacheEntry(size_t size) { + AudioSampleCache* cache; + SampleCacheEntry* entry; + void* addr; + + cache = &gAudioContext.persistentSampleCache; + addr = AudioHeap_Alloc(&cache->pool, size); + if (addr == NULL) { + return NULL; + } + + if (cache->numEntries == 128) { + return NULL; + } + + entry = &cache->entries[cache->numEntries]; + entry->inUse = true; + entry->allocatedAddr = addr; + entry->size = size; + cache->numEntries++; + + return entry; +} + +void AudioHeap_DiscardSampleCacheForFont(SampleCacheEntry* entry, s32 sampleBankId1, s32 sampleBankId2, s32 fontId) { + if ((entry->sampleBankId == sampleBankId1) || (entry->sampleBankId == sampleBankId2) || + (entry->sampleBankId == 0)) { + AudioHeap_UnapplySampleCacheForFont(entry, fontId); + } +} + +void AudioHeap_DiscardSampleCaches(void) { + s32 numFonts; + s32 sampleBankId1; + s32 sampleBankId2; + s32 fontId; + s32 j; + + numFonts = gAudioContext.soundFontTable->numEntries; + for (fontId = 0; fontId < numFonts; fontId++) { + sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + if ((sampleBankId1 == 0xFF) && (sampleBankId2 == 0xFF)) { + continue; + } + if (AudioHeap_SearchCaches(FONT_TABLE, CACHE_PERMANENT, fontId) == NULL || + !AudioLoad_IsFontLoadComplete(fontId)) { + continue; + } + + for (j = 0; j < gAudioContext.persistentSampleCache.numEntries; j++) { + AudioHeap_DiscardSampleCacheForFont(&gAudioContext.persistentSampleCache.entries[j], sampleBankId1, + sampleBankId2, fontId); + } + for (j = 0; j < gAudioContext.temporarySampleCache.numEntries; j++) { + AudioHeap_DiscardSampleCacheForFont(&gAudioContext.temporarySampleCache.entries[j], sampleBankId1, + sampleBankId2, fontId); + } + } +} + +typedef struct { + uintptr_t oldAddr; + uintptr_t newAddr; + size_t size; + u8 newMedium; +} StorageChange; + +void AudioHeap_ChangeStorage(StorageChange* change, SoundFontSample* sample) { + if (sample != NULL && ((sample->medium == change->newMedium) || (D_801FD120 != 1)) && + ((sample->medium == MEDIUM_RAM) || (D_801FD120 != 0))) { + uintptr_t startAddr = change->oldAddr; + uintptr_t endAddr = change->oldAddr + change->size; + + if (startAddr <= (uintptr_t)sample->sampleAddr && (uintptr_t)sample->sampleAddr < endAddr) { + sample->sampleAddr = sample->sampleAddr - startAddr + change->newAddr; + if (D_801FD120 == 0) { + sample->medium = change->newMedium; + } else { + sample->medium = MEDIUM_RAM; + } + } + } +} + +void AudioHeap_DiscardSampleBank(s32 sampleBankId) { + D_801FD120 = 0; + AudioHeap_ApplySampleBankCacheInternal(false, sampleBankId); +} + +void AudioHeap_ApplySampleBankCache(s32 sampleBankId) { + D_801FD120 = 1; + AudioHeap_ApplySampleBankCacheInternal(true, sampleBankId); +} + +void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId) { + AudioTable* sampleBankTable; + AudioTableEntry* entry; + s32 numFonts; + s32 instId; + s32 drumId; + s32 sfxId; + StorageChange change; + s32 sampleBankId1; + s32 sampleBankId2; + s32 fontId; + Drum* drum; + Instrument* inst; + SoundFontSound* sfx; + uintptr_t* newAddr; + s32 pad[4]; + + sampleBankTable = gAudioContext.sampleBankTable; + numFonts = gAudioContext.soundFontTable->numEntries; + change.oldAddr = AudioHeap_SearchCaches(SAMPLE_TABLE, CACHE_EITHER, sampleBankId); + if (change.oldAddr == 0) { + return; + } + + entry = &sampleBankTable->entries[sampleBankId]; + change.size = entry->size; + change.newMedium = entry->medium; + change.newAddr = entry->romAddr; + + newAddr = &change.oldAddr; + if (apply && (apply == true)) { + uintptr_t oldAddr; + + oldAddr = change.newAddr; + + change.newAddr = *newAddr; + change.oldAddr = oldAddr; + } + + for (fontId = 0; fontId < numFonts; fontId++) { + sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + if ((sampleBankId1 != 0xFF) || (sampleBankId2 != 0xFF)) { + if (!AudioLoad_IsFontLoadComplete(fontId) || + AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, fontId) == NULL) { + continue; + } + + if (sampleBankId1 == sampleBankId) { + } else if (sampleBankId2 == sampleBankId) { + } else { + continue; + } + + for (instId = 0; instId < gAudioContext.soundFonts[fontId].numInstruments; instId++) { + inst = AudioPlayback_GetInstrumentInner(fontId, instId); + if (inst != NULL) { + if (inst->normalRangeLo != 0) { + AudioHeap_ChangeStorage(&change, inst->lowNotesSound.sample); + } + if (inst->normalRangeHi != 0x7F) { + AudioHeap_ChangeStorage(&change, inst->highNotesSound.sample); + } + AudioHeap_ChangeStorage(&change, inst->normalNotesSound.sample); + } + } + + for (drumId = 0; drumId < gAudioContext.soundFonts[fontId].numDrums; drumId++) { + drum = AudioPlayback_GetDrum(fontId, drumId); + if (drum != NULL) { + AudioHeap_ChangeStorage(&change, drum->sound.sample); + } + } + + for (sfxId = 0; sfxId < gAudioContext.soundFonts[fontId].numSfx; sfxId++) { + sfx = AudioPlayback_GetSfx(fontId, sfxId); + if (sfx != NULL) { + AudioHeap_ChangeStorage(&change, sfx->sample); + } + } + } + } +} + +void AudioHeap_DiscardSampleBanks(void) { + AudioCache* cache; + AudioPersistentCache* persistent; + AudioTemporaryCache* temporary; + u32 i; + + cache = &gAudioContext.sampleBankCache; + temporary = &cache->temporary; + + if (temporary->entries[0].id != -1) { + AudioHeap_DiscardSampleBank(temporary->entries[0].id); + } + + if (temporary->entries[1].id != -1) { + AudioHeap_DiscardSampleBank(temporary->entries[1].id); + } + + persistent = &cache->persistent; + for (i = 0; i < persistent->numEntries; i++) { + AudioHeap_DiscardSampleBank(persistent->entries[i].id); + } +} + +void AudioHeap_SetReverbData(s32 reverbIndex, u32 dataType, s32 data, s32 flags) { + s32 windowSize; + SynthesisReverb* reverb = &gAudioContext.synthesisReverbs[reverbIndex]; + + switch (dataType) { + case 0: + AudioHeap_InitReverb(reverbIndex, (ReverbSettings*)data, 0); + break; + case 1: + if (data < 4) { + data = 4; + } + + windowSize = data * 64; + if (windowSize < 0x100) { + windowSize = 0x100; + } + + windowSize /= reverb->downsampleRate; + + if (flags == 0) { + if (reverb->unk_1E >= (data / reverb->downsampleRate)) { + if ((reverb->nextRingBufPos >= windowSize) || (reverb->unk_24 >= windowSize)) { + reverb->nextRingBufPos = 0; + reverb->unk_24 = 0; + } + } else { + break; + } + } + + reverb->windowSize = windowSize; + + if ((reverb->downsampleRate != 1) || reverb->unk_18) { + reverb->unk_0E = 0x8000 / reverb->downsampleRate; + if (reverb->unk_30 == NULL) { + reverb->unk_30 = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); + reverb->unk_34 = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); + reverb->unk_38 = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); + reverb->unk_3C = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); + if (reverb->unk_3C == NULL) { + reverb->downsampleRate = 1; + } + } + } + break; + case 2: + gAudioContext.synthesisReverbs[reverbIndex].unk_0C = data; + break; + case 3: + gAudioContext.synthesisReverbs[reverbIndex].unk_16 = data; + break; + case 4: + gAudioContext.synthesisReverbs[reverbIndex].unk_0A = data; + break; + case 5: + gAudioContext.synthesisReverbs[reverbIndex].leakRtl = data; + break; + case 6: + gAudioContext.synthesisReverbs[reverbIndex].leakLtr = data; + break; + case 7: + if (data != 0) { + if ((flags != 0) || (reverb->unk_278 == 0)) { + reverb->filterLeftState = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, 0x40); + reverb->unk_278 = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); + } + + reverb->filterLeft = reverb->unk_278; + if (reverb->filterLeft != 0) { + AudioHeap_LoadLowPassFilter(reverb->filterLeft, data); + } + } else { + reverb->filterLeft = 0; + + if (flags != 0) { + reverb->unk_278 = 0; + } + } + + break; + case 8: + if (data != 0) { + if ((flags != 0) || (reverb->unk_27C == 0)) { + reverb->filterRightState = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, 0x40); + reverb->unk_27C = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); + } + reverb->filterRight = reverb->unk_27C; + if (reverb->unk_27C != 0) { + AudioHeap_LoadLowPassFilter(reverb->unk_27C, data); + } + } else { + reverb->filterRight = 0; + if (flags != 0) { + reverb->unk_27C = 0; + } + } + break; + case 9: + reverb->unk_19 = data; + if (data == 0) { + reverb->unk_18 = false; + } else { + reverb->unk_18 = true; + } + break; + default: + break; + } +} + +void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags) { + SynthesisReverb* reverb = &gAudioContext.synthesisReverbs[reverbIndex]; + + if (flags != 0) { + reverb->unk_1E = settings->windowSize / settings->downsampleRate; + reverb->unk_30 = 0; + } else if (reverb->unk_1E < (settings->windowSize / settings->downsampleRate)) { + return; + } + + reverb->downsampleRate = settings->downsampleRate; + reverb->unk_18 = false; + reverb->unk_19 = 0; + reverb->unk_1A = 0; + reverb->unk_1C = 0; + AudioHeap_SetReverbData(reverbIndex, 1, settings->windowSize, flags); + reverb->unk_0C = settings->unk_4; + reverb->unk_0A = settings->unk_A; + reverb->unk_14 = settings->unk_6 << 6; + reverb->unk_16 = settings->unk_8; + reverb->leakRtl = settings->leakRtl; + reverb->leakLtr = settings->leakLtr; + reverb->unk_05 = settings->unk_10; + reverb->unk_08 = settings->unk_12; + reverb->useReverb = 8; + + if (flags != 0) { + reverb->leftRingBuf = AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.miscPool, reverb->windowSize * 2); + reverb->rightRingBuf = AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.miscPool, reverb->windowSize * 2); + reverb->resampleFlags = 1; + reverb->nextRingBufPos = 0; + reverb->unk_24 = 0; + reverb->curFrame = 0; + reverb->framesToIgnore = 2; + } + + reverb->sound.sample = &reverb->sample; + reverb->sample.loop = &reverb->loop; + reverb->sound.tuning = 1.0f; + reverb->sample.codec = CODEC_REVERB; + reverb->sample.medium = MEDIUM_RAM; + reverb->sample.size = reverb->windowSize * 2; + reverb->sample.sampleAddr = (u8*)reverb->leftRingBuf; + reverb->loop.start = 0; + reverb->loop.count = 1; + reverb->loop.end = reverb->windowSize; + + AudioHeap_SetReverbData(reverbIndex, 7, settings->lowPassFilterCutoffLeft, flags); + AudioHeap_SetReverbData(reverbIndex, 8, settings->lowPassFilterCutoffRight, flags); +} diff --git a/src/code/audio/audio_init_params.c b/src/code/audio/audio_init_params.c index 4e6ef9dfb..b407ef7c9 100644 --- a/src/code/audio/audio_init_params.c +++ b/src/code/audio/audio_init_params.c @@ -7,6 +7,6 @@ const s16 gAudioTatumInit[] = { const AudioContextInitSizes gAudioContextInitSizes = { 0x137F00, // heapSize - 0x1C480, // initPoolSize + 0x1C480, // mainPoolSplitSize 0x1A000, // permanentPoolSize }; diff --git a/src/code/audio/audio_seqplayer.c b/src/code/audio/audio_seqplayer.c index c132ba6a6..e57ad19b5 100644 --- a/src/code/audio/audio_seqplayer.c +++ b/src/code/audio/audio_seqplayer.c @@ -20,7 +20,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197C8C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197D24.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisableAsFinished.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisable.s") @@ -66,8 +66,8 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_ResetSequencePlayer.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019AC10.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayerChannels.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019ACEC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019ADBC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayers.s") diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4d38c0183..88487c916 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3548,59 +3548,59 @@ 0x8018AE34:("func_8018AE34",), 0x8018B0F0:("func_8018B0F0",), 0x8018B10C:("func_8018B10C",), - 0x8018B250:("func_8018B250",), + 0x8018B250:("AudioHeap_ResetLoadStatus",), 0x8018B318:("AudioHeap_DiscardFont",), - 0x8018B3FC:("func_8018B3FC",), - 0x8018B474:("func_8018B474",), + 0x8018B3FC:("AudioHeap_ReleaseNotesForFont",), + 0x8018B474:("AudioHeap_DiscardSequence",), 0x8018B4F8:("AudioHeap_WritebackDCache",), - 0x8018B520:("func_8018B520",), + 0x8018B520:("AudioHeap_AllocZeroedAttemptExternal",), 0x8018B578:("AudioHeap_AllocAttemptExternal",), 0x8018B5D0:("AudioHeap_AllocDmaMemory",), - 0x8018B608:("func_8018B608",), + 0x8018B608:("AudioHeap_AllocDmaMemoryZeroed",), 0x8018B640:("AudioHeap_AllocZeroed",), - 0x8018B69C:("func_8018B69C",), + 0x8018B69C:("AudioHeap_TestAlloc",), 0x8018B6E8:("AudioHeap_Alloc",), 0x8018B740:("AudioHeap_AllocPoolInit",), - 0x8018B768:("func_8018B768",), - 0x8018B77C:("func_8018B77C",), - 0x8018B7AC:("func_8018B7AC",), - 0x8018B7BC:("func_8018B7BC",), + 0x8018B768:("AudioHeap_ClearPersistentCache",), + 0x8018B77C:("AudioHeap_ClearTemporaryCache",), + 0x8018B7AC:("AudioHeap_ResetPool",), + 0x8018B7BC:("AudioHeap_PopCache",), 0x8018B8FC:("AudioHeap_InitMainPool",), - 0x8018B95C:("func_8018B95C",), - 0x8018B9E0:("func_8018B9E0",), - 0x8018BA64:("func_8018BA64",), - 0x8018BB28:("func_8018BB28",), + 0x8018B95C:("AudioHeap_InitSessionPool",), + 0x8018B9E0:("AudioHeap_InitCachePool",), + 0x8018BA64:("AudioHeap_InitPersistentCache",), + 0x8018BB28:("AudioHeap_InitTemporaryCache",), 0x8018BBEC:("AudioHeap_AllocCached",), 0x8018C380:("AudioHeap_SearchCaches",), - 0x8018C3D8:("func_8018C3D8",), + 0x8018C3D8:("AudioHeap_SearchRegularCaches",), 0x8018C4E4:("func_8018C4E4",), - 0x8018C8B8:("func_8018C8B8",), - 0x8018C8E8:("func_8018C8E8",), - 0x8018C93C:("func_8018C93C",), - 0x8018C994:("func_8018C994",), - 0x8018CB70:("func_8018CB70",), - 0x8018CB78:("func_8018CB78",), - 0x8018CC3C:("func_8018CC3C",), + 0x8018C8B8:("AudioHeap_ClearFilter",), + 0x8018C8E8:("AudioHeap_LoadLowPassFilter",), + 0x8018C93C:("AudioHeap_LoadHighPassFilter",), + 0x8018C994:("AudioHeap_LoadFilter",), + 0x8018CB70:("AudioHeap_UpdateReverb",), + 0x8018CB78:("AudioHeap_UpdateReverbs",), + 0x8018CC3C:("AudioHeap_ClearAiBuffers",), 0x8018CCA8:("AudioHeap_ResetStep",), - 0x8018CFAC:("func_8018CFAC",), + 0x8018CFAC:("AudioHeap_Init",), 0x8018D57C:("AudioHeap_SearchPermanentCache",), 0x8018D5D4:("AudioHeap_AllocPermanent",), 0x8018D658:("AudioHeap_AllocSampleCache",), - 0x8018D6C8:("func_8018D6C8",), - 0x8018D760:("func_8018D760",), - 0x8018DA50:("func_8018DA50",), - 0x8018DBC4:("func_8018DBC4",), - 0x8018DCB4:("func_8018DCB4",), - 0x8018DCF8:("func_8018DCF8",), - 0x8018DD98:("func_8018DD98",), - 0x8018DDD4:("func_8018DDD4",), - 0x8018DF24:("func_8018DF24",), - 0x8018DFE0:("func_8018DFE0",), + 0x8018D6C8:("AudioHeap_InitSampleCaches",), + 0x8018D760:("AudioHeap_AllocTemporarySampleCacheEntry",), + 0x8018DA50:("AudioHeap_UnapplySampleCacheForFont",), + 0x8018DBC4:("AudioHeap_DiscardSampleCacheEntry",), + 0x8018DCB4:("AudioHeap_UnapplySampleCache",), + 0x8018DCF8:("AudioHeap_AllocPersistentSampleCacheEntry",), + 0x8018DD98:("AudioHeap_DiscardSampleCacheForFont",), + 0x8018DDD4:("AudioHeap_DiscardSampleCaches",), + 0x8018DF24:("AudioHeap_ChangeStorage",), + 0x8018DFE0:("AudioHeap_DiscardSampleBank",), 0x8018E00C:("AudioHeap_ApplySampleBankCache",), - 0x8018E03C:("func_8018E03C",), - 0x8018E2A8:("func_8018E2A8",), - 0x8018E344:("func_8018E344",), - 0x8018E8C8:("func_8018E8C8",), + 0x8018E03C:("AudioHeap_ApplySampleBankCacheInternal",), + 0x8018E2A8:("AudioHeap_DiscardSampleBanks",), + 0x8018E344:("AudioHeap_SetReverbData",), + 0x8018E8C8:("AudioHeap_InitReverb",), 0x8018EB60:("AudioLoad_DecreaseSampleDmaTtls",), 0x8018EC4C:("AudioLoad_DmaSampleData",), 0x8018EF88:("AudioLoad_InitSampleDmaBuffers",), @@ -3777,7 +3777,7 @@ 0x80197B14:("func_80197B14",), 0x80197C0C:("func_80197C0C",), 0x80197C8C:("func_80197C8C",), - 0x80197D24:("func_80197D24",), + 0x80197D24:("AudioSeq_SequencePlayerDisableAsFinished",), 0x80197D4C:("AudioSeq_SequencePlayerDisable",), 0x80197E08:("AudioSeq_AudioListPushBack",), 0x80197E48:("AudioSeq_AudioListPopBack",), @@ -3800,9 +3800,9 @@ 0x8019AA3C:("func_8019AA3C",), 0x8019AAF0:("func_8019AAF0",), 0x8019AB40:("AudioSeq_ResetSequencePlayer",), - 0x8019AC10:("func_8019AC10",), + 0x8019AC10:("AudioSeq_InitSequencePlayerChannels",), 0x8019ACEC:("func_8019ACEC",), - 0x8019ADBC:("func_8019ADBC",), + 0x8019ADBC:("AudioSeq_InitSequencePlayers",), 0x8019AE40:("func_8019AE40",), 0x8019AEC0:("func_8019AEC0",), 0x8019AF00:("func_8019AF00",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index f88c541bd..07e57be02 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2461,7 +2461,7 @@ 0x801DB8B8:("D_801DB8B8","UNK_TYPE1","",0x1), 0x801DB900:("D_801DB900","UNK_TYPE1","",0x1), 0x801DB930:("D_801DB930","UNK_PTR","",0x4), - 0x801DB958:("D_801DB958","AudioSpec","[21]",0x498), + 0x801DB958:("gAudioSpecs","AudioSpec","[21]",0x498), 0x801DBDF0:("D_801DBDF0","f32","",0x4), 0x801DBDF4:("jtbl_801DBDF4","UNK_PTR","",0x4), 0x801DBE68:("D_801DBE68","f32","",0x4), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index d8b33b84b..fa1f63c91 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -3064,61 +3064,59 @@ asm/non_matchings/code/audio_synthesis/func_8018A768.s,func_8018A768,0x8018A768, asm/non_matchings/code/audio_synthesis/func_8018A808.s,func_8018A808,0x8018A808,0x12F asm/non_matchings/code/audio_synthesis/func_8018ACC4.s,func_8018ACC4,0x8018ACC4,0x5C asm/non_matchings/code/audio_synthesis/func_8018AE34.s,func_8018AE34,0x8018AE34,0xAF -asm/non_matchings/code/audio_heap/func_8018B0F0.s,func_8018B0F0,0x8018B0F0,0x7 -asm/non_matchings/code/audio_heap/func_8018B10C.s,func_8018B10C,0x8018B10C,0x51 -asm/non_matchings/code/audio_heap/func_8018B250.s,func_8018B250,0x8018B250,0x32 +asm/non_matchings/code/audio_heap/AudioHeap_ResetLoadStatus.s,AudioHeap_ResetLoadStatus,0x8018B250,0x32 asm/non_matchings/code/audio_heap/AudioHeap_DiscardFont.s,AudioHeap_DiscardFont,0x8018B318,0x39 -asm/non_matchings/code/audio_heap/func_8018B3FC.s,func_8018B3FC,0x8018B3FC,0x1E -asm/non_matchings/code/audio_heap/func_8018B474.s,func_8018B474,0x8018B474,0x21 +asm/non_matchings/code/audio_heap/AudioHeap_ReleaseNotesForFont.s,AudioHeap_ReleaseNotesForFont,0x8018B3FC,0x1E +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSequence.s,AudioHeap_DiscardSequence,0x8018B474,0x21 asm/non_matchings/code/audio_heap/AudioHeap_WritebackDCache.s,AudioHeap_WritebackDCache,0x8018B4F8,0xA -asm/non_matchings/code/audio_heap/func_8018B520.s,func_8018B520,0x8018B520,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_AllocZeroedAttemptExternal.s,AudioHeap_AllocZeroedAttemptExternal,0x8018B520,0x16 asm/non_matchings/code/audio_heap/AudioHeap_AllocAttemptExternal.s,AudioHeap_AllocAttemptExternal,0x8018B578,0x16 asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemory.s,AudioHeap_AllocDmaMemory,0x8018B5D0,0xE -asm/non_matchings/code/audio_heap/func_8018B608.s,func_8018B608,0x8018B608,0xE +asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemoryZeroed.s,AudioHeap_AllocDmaMemoryZeroed,0x8018B608,0xE asm/non_matchings/code/audio_heap/AudioHeap_AllocZeroed.s,AudioHeap_AllocZeroed,0x8018B640,0x17 -asm/non_matchings/code/audio_heap/func_8018B69C.s,func_8018B69C,0x8018B69C,0x13 -asm/non_matchings/code/audio_heap/AudioHeap_Alloc.s,AudioHeap_Alloc,0x8018B6E8,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_TestAlloc.s,AudioHeap_TestAlloc,0x8018B69C,0x13 +asm/non_matchings/code/audio_heap/Audio_Alloc.s,Audio_Alloc,0x8018B6E8,0x16 asm/non_matchings/code/audio_heap/AudioHeap_AllocPoolInit.s,AudioHeap_AllocPoolInit,0x8018B740,0xA -asm/non_matchings/code/audio_heap/func_8018B768.s,func_8018B768,0x8018B768,0x5 -asm/non_matchings/code/audio_heap/func_8018B77C.s,func_8018B77C,0x8018B77C,0xC -asm/non_matchings/code/audio_heap/func_8018B7AC.s,func_8018B7AC,0x8018B7AC,0x4 -asm/non_matchings/code/audio_heap/func_8018B7BC.s,func_8018B7BC,0x8018B7BC,0x50 +asm/non_matchings/code/audio_heap/AudioHeap_ClearPersistentCache.s,AudioHeap_ClearPersistentCache,0x8018B768,0x5 +asm/non_matchings/code/audio_heap/AudioHeap_ClearTemporaryCache.s,AudioHeap_ClearTemporaryCache,0x8018B77C,0xC +asm/non_matchings/code/audio_heap/AudioHeap_ResetPool.s,AudioHeap_ResetPool,0x8018B7AC,0x4 +asm/non_matchings/code/audio_heap/AudioHeap_PopCache.s,AudioHeap_PopCache,0x8018B7BC,0x50 asm/non_matchings/code/audio_heap/AudioHeap_InitMainPool.s,AudioHeap_InitMainPool,0x8018B8FC,0x18 -asm/non_matchings/code/audio_heap/func_8018B95C.s,func_8018B95C,0x8018B95C,0x21 -asm/non_matchings/code/audio_heap/func_8018B9E0.s,func_8018B9E0,0x8018B9E0,0x21 -asm/non_matchings/code/audio_heap/func_8018BA64.s,func_8018BA64,0x8018BA64,0x31 -asm/non_matchings/code/audio_heap/func_8018BB28.s,func_8018BB28,0x8018BB28,0x31 +asm/non_matchings/code/audio_heap/AudioHeap_InitSessionPool.s,AudioHeap_InitSessionPool,0x8018B95C,0x21 +asm/non_matchings/code/audio_heap/AudioHeap_InitCachePool.s,AudioHeap_InitCachePool,0x8018B9E0,0x21 +asm/non_matchings/code/audio_heap/AudioHeap_InitPersistentCache.s,AudioHeap_InitPersistentCache,0x8018BA64,0x31 +asm/non_matchings/code/audio_heap/AudioHeap_InitTemporaryCache.s,AudioHeap_InitTemporaryCache,0x8018BB28,0x31 asm/non_matchings/code/audio_heap/AudioHeap_AllocCached.s,AudioHeap_AllocCached,0x8018BBEC,0x1E5 asm/non_matchings/code/audio_heap/AudioHeap_SearchCaches.s,AudioHeap_SearchCaches,0x8018C380,0x16 -asm/non_matchings/code/audio_heap/func_8018C3D8.s,func_8018C3D8,0x8018C3D8,0x43 +asm/non_matchings/code/audio_heap/AudioHeap_SearchRegularCaches.s,AudioHeap_SearchRegularCaches,0x8018C3D8,0x43 asm/non_matchings/code/audio_heap/func_8018C4E4.s,func_8018C4E4,0x8018C4E4,0xF5 -asm/non_matchings/code/audio_heap/func_8018C8B8.s,func_8018C8B8,0x8018C8B8,0xC -asm/non_matchings/code/audio_heap/func_8018C8E8.s,func_8018C8E8,0x8018C8E8,0x15 -asm/non_matchings/code/audio_heap/func_8018C93C.s,func_8018C93C,0x8018C93C,0x16 -asm/non_matchings/code/audio_heap/func_8018C994.s,func_8018C994,0x8018C994,0x77 -asm/non_matchings/code/audio_heap/func_8018CB70.s,func_8018CB70,0x8018CB70,0x2 -asm/non_matchings/code/audio_heap/func_8018CB78.s,func_8018CB78,0x8018CB78,0x31 -asm/non_matchings/code/audio_heap/func_8018CC3C.s,func_8018CC3C,0x8018CC3C,0x1B +asm/non_matchings/code/audio_heap/AudioHeap_ClearFilter.s,AudioHeap_ClearFilter,0x8018C8B8,0xC +asm/non_matchings/code/audio_heap/AudioHeap_LoadLowPassFilter.s,AudioHeap_LoadLowPassFilter,0x8018C8E8,0x15 +asm/non_matchings/code/audio_heap/AudioHeap_LoadHighPassFilter.s,AudioHeap_LoadHighPassFilter,0x8018C93C,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_LoadFilter.s,AudioHeap_LoadFilter,0x8018C994,0x77 +asm/non_matchings/code/audio_heap/AudioHeap_UpdateReverb.s,AudioHeap_UpdateReverb,0x8018CB70,0x2 +asm/non_matchings/code/audio_heap/AudioHeap_UpdateReverbs.s,AudioHeap_UpdateReverbs,0x8018CB78,0x31 +asm/non_matchings/code/audio_heap/AudioHeap_ClearAiBuffers.s,AudioHeap_ClearAiBuffers,0x8018CC3C,0x1B asm/non_matchings/code/audio_heap/AudioHeap_ResetStep.s,AudioHeap_ResetStep,0x8018CCA8,0xC1 -asm/non_matchings/code/audio_heap/func_8018CFAC.s,func_8018CFAC,0x8018CFAC,0x174 +asm/non_matchings/code/audio_heap/AudioHeap_Init.s,AudioHeap_Init,0x8018CFAC,0x174 asm/non_matchings/code/audio_heap/AudioHeap_SearchPermanentCache.s,AudioHeap_SearchPermanentCache,0x8018D57C,0x16 asm/non_matchings/code/audio_heap/AudioHeap_AllocPermanent.s,AudioHeap_AllocPermanent,0x8018D5D4,0x21 asm/non_matchings/code/audio_heap/AudioHeap_AllocSampleCache.s,AudioHeap_AllocSampleCache,0x8018D658,0x1C -asm/non_matchings/code/audio_heap/func_8018D6C8.s,func_8018D6C8,0x8018D6C8,0x26 -asm/non_matchings/code/audio_heap/func_8018D760.s,func_8018D760,0x8018D760,0xBC -asm/non_matchings/code/audio_heap/func_8018DA50.s,func_8018DA50,0x8018DA50,0x5D -asm/non_matchings/code/audio_heap/func_8018DBC4.s,func_8018DBC4,0x8018DBC4,0x3C -asm/non_matchings/code/audio_heap/func_8018DCB4.s,func_8018DCB4,0x8018DCB4,0x11 -asm/non_matchings/code/audio_heap/func_8018DCF8.s,func_8018DCF8,0x8018DCF8,0x28 -asm/non_matchings/code/audio_heap/func_8018DD98.s,func_8018DD98,0x8018DD98,0xF -asm/non_matchings/code/audio_heap/func_8018DDD4.s,func_8018DDD4,0x8018DDD4,0x54 -asm/non_matchings/code/audio_heap/func_8018DF24.s,func_8018DF24,0x8018DF24,0x2F -asm/non_matchings/code/audio_heap/func_8018DFE0.s,func_8018DFE0,0x8018DFE0,0xB +asm/non_matchings/code/audio_heap/AudioHeap_InitSampleCaches.s,AudioHeap_InitSampleCaches,0x8018D6C8,0x26 +asm/non_matchings/code/audio_heap/AudioHeap_AllocTemporarySampleCacheEntry.s,AudioHeap_AllocTemporarySampleCacheEntry,0x8018D760,0xBC +asm/non_matchings/code/audio_heap/AudioHeap_UnapplySampleCacheForFont.s,AudioHeap_UnapplySampleCacheForFont,0x8018DA50,0x5D +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleCacheEntry.s,AudioHeap_DiscardSampleCacheEntry,0x8018DBC4,0x3C +asm/non_matchings/code/audio_heap/AudioHeap_UnapplySampleCache.s,AudioHeap_UnapplySampleCache,0x8018DCB4,0x11 +asm/non_matchings/code/audio_heap/AudioHeap_AllocPersistentSampleCacheEntry.s,AudioHeap_AllocPersistentSampleCacheEntry,0x8018DCF8,0x28 +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleCacheForFont.s,AudioHeap_DiscardSampleCacheForFont,0x8018DD98,0xF +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleCaches.s,AudioHeap_DiscardSampleCaches,0x8018DDD4,0x54 +asm/non_matchings/code/audio_heap/AudioHeap_ChangeStorage.s,AudioHeap_ChangeStorage,0x8018DF24,0x2F +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleBank.s,AudioHeap_DiscardSampleBank,0x8018DFE0,0xB asm/non_matchings/code/audio_heap/AudioHeap_ApplySampleBankCache.s,AudioHeap_ApplySampleBankCache,0x8018E00C,0xC -asm/non_matchings/code/audio_heap/func_8018E03C.s,func_8018E03C,0x8018E03C,0x9B -asm/non_matchings/code/audio_heap/func_8018E2A8.s,func_8018E2A8,0x8018E2A8,0x27 -asm/non_matchings/code/audio_heap/func_8018E344.s,func_8018E344,0x8018E344,0x161 -asm/non_matchings/code/audio_heap/func_8018E8C8.s,func_8018E8C8,0x8018E8C8,0xA6 +asm/non_matchings/code/audio_heap/AudioHeap_ApplySampleBankCacheInternal.s,AudioHeap_ApplySampleBankCacheInternal,0x8018E03C,0x9B +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleBanks.s,AudioHeap_DiscardSampleBanks,0x8018E2A8,0x27 +asm/non_matchings/code/audio_heap/AudioHeap_SetReverbData.s,AudioHeap_SetReverbData,0x8018E344,0x161 +asm/non_matchings/code/audio_heap/AudioHeap_InitReverb.s,AudioHeap_InitReverb,0x8018E8C8,0xA6 asm/non_matchings/code/audio_load/AudioLoad_DecreaseSampleDmaTtls.s,AudioLoad_DecreaseSampleDmaTtls,0x8018EB60,0x3B asm/non_matchings/code/audio_load/AudioLoad_DmaSampleData.s,AudioLoad_DmaSampleData,0x8018EC4C,0xCF asm/non_matchings/code/audio_load/AudioLoad_InitSampleDmaBuffers.s,AudioLoad_InitSampleDmaBuffers,0x8018EF88,0xA6 @@ -3295,7 +3293,7 @@ asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelDisable.s,AudioSe asm/non_matchings/code/audio_seqplayer/func_80197B14.s,func_80197B14,0x80197B14,0x3E asm/non_matchings/code/audio_seqplayer/func_80197C0C.s,func_80197C0C,0x80197C0C,0x20 asm/non_matchings/code/audio_seqplayer/func_80197C8C.s,func_80197C8C,0x80197C8C,0x26 -asm/non_matchings/code/audio_seqplayer/func_80197D24.s,func_80197D24,0x80197D24,0xA +asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisableAsFinished.s,AudioSeq_SequencePlayerDisableAsFinished,0x80197D24,0xA asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisable.s,AudioSeq_SequencePlayerDisable,0x80197D4C,0x2F asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPushBack.s,AudioSeq_AudioListPushBack,0x80197E08,0x10 asm/non_matchings/code/audio_seqplayer/AudioSeq_AudioListPopBack.s,AudioSeq_AudioListPopBack,0x80197E48,0x10 @@ -3318,9 +3316,9 @@ asm/non_matchings/code/audio_seqplayer/func_8019A0BC.s,func_8019A0BC,0x8019A0BC, asm/non_matchings/code/audio_seqplayer/func_8019AA3C.s,func_8019AA3C,0x8019AA3C,0x2D asm/non_matchings/code/audio_seqplayer/func_8019AAF0.s,func_8019AAF0,0x8019AAF0,0x14 asm/non_matchings/code/audio_seqplayer/AudioSeq_ResetSequencePlayer.s,AudioSeq_ResetSequencePlayer,0x8019AB40,0x34 -asm/non_matchings/code/audio_seqplayer/func_8019AC10.s,func_8019AC10,0x8019AC10,0x37 +asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayerChannels.s,AudioSeq_InitSequencePlayerChannels,0x8019AC10,0x37 asm/non_matchings/code/audio_seqplayer/func_8019ACEC.s,func_8019ACEC,0x8019ACEC,0x34 -asm/non_matchings/code/audio_seqplayer/func_8019ADBC.s,func_8019ADBC,0x8019ADBC,0x21 +asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayers.s,AudioSeq_InitSequencePlayers,0x8019ADBC,0x21 asm/non_matchings/code/code_8019AE40/func_8019AE40.s,func_8019AE40,0x8019AE40,0x1C asm/non_matchings/code/code_8019AEC0/func_8019AEC0.s,func_8019AEC0,0x8019AEC0,0x10 asm/non_matchings/code/code_8019AF00/func_8019AF00.s,func_8019AF00,0x8019AF00,0x16 From 49aeece9ee786e9fff6539f0f173deb112046e21 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Fri, 25 Mar 2022 00:20:21 +0000 Subject: [PATCH 084/257] Obj_Grass (#617) * Obj_Grass * PR * PR * PR * Match (thanks Synray) --- assets/xml/overlays/ovl_Obj_Grass.xml | 7 + spec | 4 +- .../actors/ovl_Obj_Grass/z_obj_grass.c | 494 +++++++++++++++++- .../actors/ovl_Obj_Grass/z_obj_grass.h | 34 +- .../ovl_Obj_Grass_Carry/z_obj_grass_carry.h | 4 +- 5 files changed, 517 insertions(+), 26 deletions(-) create mode 100644 assets/xml/overlays/ovl_Obj_Grass.xml diff --git a/assets/xml/overlays/ovl_Obj_Grass.xml b/assets/xml/overlays/ovl_Obj_Grass.xml new file mode 100644 index 000000000..e1002b369 --- /dev/null +++ b/assets/xml/overlays/ovl_Obj_Grass.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spec b/spec index 04fd18b85..1e2684b7d 100644 --- a/spec +++ b/spec @@ -2306,9 +2306,7 @@ beginseg name "ovl_Obj_Grass" compress include "build/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.o" - include "build/data/ovl_Obj_Grass/ovl_Obj_Grass.data.o" - include "build/data/ovl_Obj_Grass/ovl_Obj_Grass.bss.o" - include "build/data/ovl_Obj_Grass/ovl_Obj_Grass.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Grass/ovl_Obj_Grass_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c index ae70ba013..4808a0d5b 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c @@ -5,6 +5,7 @@ */ #include "z_obj_grass.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +16,13 @@ void ObjGrass_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjGrass_Update(Actor* thisx, GlobalContext* globalCtx); void ObjGrass_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +ObjGrassStruct1* D_809AADA0[4]; +f32 D_809AADB0[4]; +ObjGrassStruct1_1* D_809AADC0[20]; +f32 D_809AAE10[20]; + +#include "overlays/ovl_Obj_Grass/ovl_Obj_Grass.c" + const ActorInit Obj_Grass_InitVars = { ACTOR_OBJ_GRASS, ACTORCAT_PROP, @@ -28,41 +35,486 @@ const ActorInit Obj_Grass_InitVars = { (ActorFunc)ObjGrass_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809AAB20 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x0580C71C, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x0580C71C, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 6, 44, 0, { 0, 0, 0 } }, }; -#endif +Vec3f D_809AAB4C[] = { + { 0.0f, 0.707099974155f, 0.707099974155f }, + { 0.707099974155f, 0.707099974155f, 0.0f }, + { 0.0f, 0.707099974155f, -0.707099974155f }, + { -0.707099974155f, 0.707099974155f, 0.0f }, +}; -extern ColliderCylinderInit D_809AAB20; +s16 D_809AAB7C[] = { 0x6C, 0x66, 0x60, 0x54, 0x42, 0x37, 0x2A, 0x26 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A9110.s") +s32 func_809A9110(GlobalContext* globalCtx, Vec3f* arg1) { + f32 sp2C; + Vec3f sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A91FC.s") + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg1, &sp20, &sp2C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A92D0.s") + if ((globalCtx->unk_187F0.z * -130.13191f) < sp20.z) { + if (sp2C < 1.0f) { + sp2C = 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A9314.s") + if (((fabsf(sp20.x) - (130.13191f * globalCtx->unk_187F0.x)) < sp2C) && + ((fabsf(sp20.y) - (130.13191f * globalCtx->unk_187F0.y)) < sp2C)) { + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/ObjGrass_Init.s") +void func_809A91FC(MtxF* matrix) { + s32 i; + MtxF* temp = Matrix_GetCurrentState(); + f32* tmp = &temp->xx; + f32* tmp2 = &matrix->xx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/ObjGrass_Destroy.s") + for (i = 0; i < 16; i++) { + *tmp++ += *tmp2++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A9790.s") +void func_809A92D0(ObjGrassStruct1_1* ptr, GlobalContext* globalCtx) { + if (!(ptr->unk_0E & 0x10)) { + Item_DropCollectibleRandom(globalCtx, NULL, &ptr->unk_00, ptr->unk_0E * 0x10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A983C.s") +void func_809A9314(ObjGrassStruct1_1* ptr, GlobalContext* globalCtx) { + Vec3f spBC; + Vec3f spB0; + s32 i; + Vec3f* ptr2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A9DB8.s") + for (i = 0; i < ARRAY_COUNT(D_809AAB4C); i++) { + ptr2 = &D_809AAB4C[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/ObjGrass_Update.s") + spB0.x = ptr->unk_00.x + (ptr2->x * 8.0f); + spB0.y = (ptr->unk_00.y + (ptr2->y * 8.0f)) + 10.0f; + spB0.z = ptr->unk_00.z + (ptr2->z * 8.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809AA278.s") + spBC.x = (Rand_ZeroOne() - 0.5f) * 8.0f; + spBC.y = Rand_ZeroOne() * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809AA54C.s") + EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, + D_809AAB7C[(s32)(Rand_ZeroOne() * 111.1f) & 7], 0, 0, 80, -1, 1, gameplay_keep_DL_0527F0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809AA798.s") + spB0.x = ptr->unk_00.x + (ptr2->x * 16.0f); + spB0.y = (ptr->unk_00.y + (ptr2->y * 16.0f)) + 10.0f; + spB0.z = ptr->unk_00.z + (ptr2->z * 16.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/ObjGrass_Draw.s") + spBC.x = (Rand_ZeroOne() - 0.5f) * 6.0f; + spBC.y = Rand_ZeroOne() * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 6.0f; + + EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, + D_809AAB7C[(s32)(Rand_ZeroOne() * 111.1f) % 7], 0, 0, 80, -1, 1, gameplay_keep_DL_0528B0); + } +} + +void ObjGrass_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + s32 i; + + Actor_SetScale(&this->actor, 0.4f); + + for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { + Collider_InitCylinder(globalCtx, &this->unk_2948[i].collider); + Collider_SetCylinder(globalCtx, &this->unk_2948[i].collider, &this->actor, &sCylinderInit); + } + + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->unk_3288 = (u32)Rand_Next() >> 0x10; + this->unk_328A = (u32)Rand_Next() >> 0x10; + this->unk_328C = (u32)Rand_Next() >> 0x10; + this->unk_328E = (u32)Rand_Next() >> 0x10; + this->unk_3290 = (u32)Rand_Next() >> 0x10; +} + +void ObjGrass_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { + Collider_DestroyCylinder(globalCtx, &this->unk_2948[i].collider); + } + + for (i = 0; i < ARRAY_COUNT(this->unk_3298); i++) { + ObjGrassCarry** ptr = &this->unk_3298[i]; + + if (*ptr != NULL) { + (*ptr)->unk_190 = 0; + *ptr = NULL; + } + } +} + +void func_809A9790(ObjGrass* this, GlobalContext* globalCtx) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { + ObjGrassStruct1_1* ptr = this->unk_2948[i].unk_4C; + + if ((ptr != NULL) && (this->unk_2948[i].collider.base.acFlags & AC_HIT)) { + func_809A9314(ptr, globalCtx); + func_809A92D0(ptr, globalCtx); + ptr->unk_0F |= 4; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &ptr->unk_00, 20, NA_SE_EV_PLANT_BROKEN); + } + } +} + +void func_809A983C(ObjGrass* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + s32 j; + s32 x; + s32 y; + f32 temp_f0; + ObjGrassStruct1* ptr; + ObjGrassStruct1_1* ptr2; + ObjGrassStruct2* ptr3; + s16 yaw; + + for (i = 0; i < ARRAY_COUNT(D_809AADC0); i++) { + D_809AADC0[i] = NULL; + D_809AAE10[i] = 422500.0f; + } + + for (i = 0; i < ARRAY_COUNT(D_809AADA0); i++) { + D_809AADA0[i] = NULL; + D_809AADB0[i] = 422500.0f; + } + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + + for (j = 0; j < ptr->unk_FC; j++) { + ptr->unk_0C[j].unk_0F &= (u16)~2; + } + } + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + temp_f0 = Math3D_Vec3fDistSq(&ptr->unk_00, &player->actor.world.pos); + + for (j = 0; j < ARRAY_COUNT(D_809AADB0); j++) { + if (temp_f0 < D_809AADB0[j]) { + break; + } + } + + if (j < ARRAY_COUNT(D_809AADB0)) { + for (x = 2; x >= j; x--) { + D_809AADB0[x + 1] = D_809AADB0[x]; + D_809AADA0[x + 1] = D_809AADA0[x]; + } + + D_809AADB0[j] = temp_f0; + D_809AADA0[j] = ptr; + } + } + + this->unk_3294 = NULL; + + for (i = 0; i < ARRAY_COUNT(D_809AADA0); i++) { + ptr = D_809AADA0[i]; + + if (ptr != NULL) { + for (j = 0; j < ptr->unk_FC; j++) { + if (!(ptr->unk_0C[j].unk_0F & 4)) { + temp_f0 = Math3D_Vec3fDistSq(&ptr->unk_0C[j].unk_00, &player->actor.world.pos); + + for (x = 0; x < ARRAY_COUNT(D_809AAE10); x++) { + if (temp_f0 < D_809AAE10[x]) { + break; + } + } + + if (x < ARRAY_COUNT(D_809AAE10)) { + for (y = 18; y >= x; y--) { + D_809AAE10[y + 1] = D_809AAE10[y]; + D_809AADC0[y + 1] = D_809AADC0[y]; + } + + D_809AAE10[x] = temp_f0; + D_809AADC0[x] = &ptr->unk_0C[j]; + + if (temp_f0 < 2500.0f) { + yaw = player->actor.shape.rot.y - + Math_Vec3f_Yaw(&player->actor.world.pos, &ptr->unk_0C[j].unk_00); + + if (ABS_ALT(yaw) < 0x2000) { + this->unk_3294 = &ptr->unk_0C[j].unk_00; + } + } + } + } + } + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { + ptr3 = &this->unk_2948[i]; + + ptr3->collider.base.acFlags &= (u16)~AC_HIT; + ptr3->collider.base.ocFlags1 &= (u16)~OC1_HIT; + + ptr2 = D_809AADC0[i]; + if (ptr2 != NULL) { + ptr3->collider.dim.pos.x = ptr2->unk_00.x; + ptr3->collider.dim.pos.y = ptr2->unk_00.y; + ptr3->collider.dim.pos.z = ptr2->unk_00.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &ptr3->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &ptr3->collider.base); + ptr2->unk_0F |= 2; + ptr3->unk_4C = ptr2; + } else { + ptr3->unk_4C = NULL; + } + } +} + +void func_809A9DB8(ObjGrass* this) { + s32 i; + s32 pad; + f32* ptr; + f32 temp_f28; + f32 spA4; + f32 spA0; + f32 temp_f22; + f32 temp_f24; + f32 sp94; + f32 sp90; + f32 temp_f26; + f32 sp6C[8]; + f32 tempf1; + f32 tempf2; + f32 tempf3; + f32 tempf4; + f32 tempf5; + f32 temp_f16; + f32 temp_f20; + + this->unk_3288 += 70; + this->unk_328A += 300; + this->unk_328C += 700; + this->unk_328E += 1300; + this->unk_3290 += 8900; + + temp_f24 = Math_SinS(this->unk_3288); + temp_f28 = Math_SinS(this->unk_328A); + temp_f26 = Math_SinS(this->unk_328C); + spA4 = Math_SinS(this->unk_328E) * 1.2f; + spA0 = Math_SinS(this->unk_3290) * 1.5f; + temp_f22 = Math_CosS(this->unk_3288); + temp_f20 = Math_CosS(this->unk_328A); + sp94 = Math_CosS(this->unk_328C); + sp90 = Math_CosS(this->unk_328E) * 1.3f; + temp_f16 = Math_CosS(this->unk_3290) * 1.7f; + + sp6C[0] = (temp_f24 - temp_f20) * temp_f26 * temp_f22 * temp_f24 * 0.0015f; + sp6C[1] = (temp_f28 - sp94) * spA4 * temp_f20 * temp_f24 * 0.0015f; + sp6C[2] = (temp_f26 - sp90) * sp94 * temp_f24 * temp_f22 * 0.0015f; + sp6C[3] = (spA4 - temp_f20) * sp90 * temp_f28 * temp_f22 * 0.0015f; + sp6C[4] = (temp_f24 - sp94) * temp_f24 * temp_f28 * spA0 * 0.0015f; + sp6C[5] = (temp_f28 - sp90) * temp_f26 * spA4 * spA0 * 0.0015f; + sp6C[6] = (temp_f26 - temp_f22) * temp_f22 * temp_f20 * temp_f16 * 0.0015f; + sp6C[7] = (spA4 - temp_f20) * sp94 * sp90 * temp_f16 * 0.0015f; + + for (i = 0; i < ARRAY_COUNT(this->unk_2F88); i++) { + ptr = &this->unk_2F88[i].mf[0][0]; + + tempf1 = sp6C[(i + 0) & 7]; + tempf2 = sp6C[(i + 1) & 7]; + tempf3 = sp6C[(i + 2) & 7]; + tempf4 = sp6C[(i + 3) & 7]; + tempf5 = sp6C[(i + 4) & 7]; + + ptr[0] = sp6C[1] * 0.2f; + ptr[1] = tempf1; + ptr[2] = tempf2; + ptr[3] = 0.0f; + + ptr[4] = tempf3; + ptr[5] = sp6C[0]; + ptr[6] = tempf3; + ptr[7] = 0.0f; + + ptr[8] = tempf4; + ptr[9] = tempf5; + ptr[10] = sp6C[3] * 0.2f; + ptr[11] = 0.0f; + + ptr[12] = 0.0f; + ptr[13] = 0.0f; + ptr[14] = 0.0f; + ptr[15] = 0.0f; + } +} + +void ObjGrass_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + + func_809A9790(this, globalCtx); + func_809A983C(this, globalCtx); + func_809A9DB8(this); +} + +void func_809AA278(ObjGrass* this, GlobalContext* globalCtx) { + ObjGrassStruct1* ptr; + ObjGrassStruct1_1* ptr2; + s32 i; + s32 j; + f32 distSq; + f32 temp_f22; + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + + temp_f22 = Math3D_Vec3fDistSq(&ptr->unk_00, &GET_ACTIVE_CAM(globalCtx)->eye); + + if ((temp_f22 < SQ(1280.0f)) && func_809A9110(globalCtx, &ptr->unk_00)) { + ptr->unk_FE |= 1; + + for (j = 0; j < ptr->unk_FC; j++) { + ptr2 = &ptr->unk_0C[j]; + + if (ptr2->unk_0F & 4) { + ptr2->unk_10 = 255; + ptr2->unk_0F &= ~1; + } else { + ptr2->unk_0F |= 1; + if (temp_f22 < SQ(980.0f)) { + ptr2->unk_10 = 255; + } else { + distSq = Math3D_Vec3fDistSq(&ptr2->unk_00, &GET_ACTIVE_CAM(globalCtx)->eye); + if ((distSq <= SQ(1080.0f)) || ((ptr2->unk_0F & 8) && (distSq < SQ(1180.0f)))) { + ptr2->unk_10 = 255; + } else if (distSq >= SQ(1180.0f)) { + ptr2->unk_10 = 0; + } else { + ptr2->unk_10 = (1180.0f - sqrtf(distSq)) * 2.55f; + } + } + } + } + } else { + ptr->unk_FE &= ~1; + } + } +} + +void func_809AA54C(Actor* thisx, GlobalContext* globalCtx2) { + ObjGrass* this = THIS; + GlobalContext* globalCtx = globalCtx2; + Lights* temp_s0; + ObjGrassStruct1* ptr; + s32 i; + s32 j; + Vec3s sp70 = { 0, 0, 0 }; + ObjGrassStruct1_1* ptr2; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, gObjGrass_D_809AA9F0); + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + + if (ptr->unk_FE & 1) { + temp_s0 = LightContext_NewLights(&globalCtx->lightCtx, globalCtx->state.gfxCtx); + Lights_BindAll(temp_s0, globalCtx->lightCtx.listHead, &ptr->unk_00, globalCtx); + Lights_Draw(temp_s0, globalCtx->state.gfxCtx); + + for (j = 0; j < ptr->unk_FC; j++) { + ptr2 = &ptr->unk_0C[j]; + + if ((ptr2->unk_0F & 1) && (ptr2->unk_10 == 255)) { + sp70.y = ptr2->unk_0C; + Matrix_SetStateRotationAndTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp70); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + if (ptr2->unk_0F & 2) { + func_809A91FC(&this->unk_2F88[j]); + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gObjGrass_D_809AAAE0); + } + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_809AA798(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + ObjGrassStruct1* ptr; + ObjGrassStruct1_1* ptr2; + s32 i; + s32 j; + Vec3s sp6C = { 0, 0, 0 }; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_XLU_DISP++, gObjGrass_D_809AAA68); + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + + if (ptr->unk_FE & 1) { + for (j = 0; j < ptr->unk_FC; j++) { + ptr2 = &ptr->unk_0C[j]; + + if ((ptr2->unk_0F & 1) && (ptr2->unk_10 > 0) && (ptr2->unk_10 < 255)) { + sp6C.y = ptr2->unk_0C; + Matrix_SetStateRotationAndTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp6C); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, ptr2->unk_10); + gSPDisplayList(POLY_XLU_DISP++, gObjGrass_D_809AAAE0); + } + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjGrass_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + + func_809AA278(this, globalCtx); + func_809AA54C(thisx, globalCtx); + func_809AA798(thisx, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h index e05e1618e..83c638a69 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h @@ -2,12 +2,44 @@ #define Z_OBJ_GRASS_H #include "global.h" +#include "overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h" struct ObjGrass; +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ s8 unk_0E; + /* 0x0F */ u8 unk_0F; + /* 0x10 */ u8 unk_10; + /* 0x11 */ UNK_TYPE1 unk_11[0x3]; +} ObjGrassStruct1_1; // size = 0x14 + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ ObjGrassStruct1_1 unk_0C[12]; + /* 0xFC */ s16 unk_FC; + /* 0xFE */ u8 unk_FE; +} ObjGrassStruct1; // size = 0x100 + +typedef struct { + /* 0x00 */ ColliderCylinder collider; + /* 0x4C */ ObjGrassStruct1_1* unk_4C; +} ObjGrassStruct2; // size = 0x50 + typedef struct ObjGrass { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_0144[0x315C]; + /* 0x0144 */ ObjGrassStruct1 unk_144[40]; + /* 0x2944 */ s16 unk_2944; + /* 0x2948 */ ObjGrassStruct2 unk_2948[20]; + /* 0x2F88 */ MtxF unk_2F88[12]; + /* 0x3288 */ s16 unk_3288; + /* 0x328A */ s16 unk_328A; + /* 0x328C */ s16 unk_328C; + /* 0x328E */ s16 unk_328E; + /* 0x3290 */ s16 unk_3290; + /* 0x3294 */ Vec3f* unk_3294; + /* 0x3298 */ ObjGrassCarry* unk_3298[2]; } ObjGrass; // size = 0x32A0 extern const ActorInit Obj_Grass_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h index 90ded06c5..5c0f12495 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h +++ b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h @@ -9,7 +9,9 @@ typedef void (*ObjGrassCarryActionFunc)(struct ObjGrassCarry*, GlobalContext*); typedef struct ObjGrassCarry { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x58]; + /* 0x0144 */ char unk_144[0x4C]; + /* 0x0190 */ s32 unk_190; + /* 0x0194 */ char unk_194[0x8]; /* 0x019C */ ObjGrassCarryActionFunc actionFunc; } ObjGrassCarry; // size = 0x1A0 From 1599192b85ac886b62a4db8fd1958c4346e01218 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Thu, 24 Mar 2022 21:25:41 -0300 Subject: [PATCH 085/257] Script for checking relocs correctly updated on spec (#718) * Script to check for relocs on spec * add reloc_spec_check to jenkinsfile * add colors * Use light red instead of red * Go back to red * fix EnDoor reloc --- Jenkinsfile | 6 ++ spec | 2 +- tools/reloc_spec_check.sh | 112 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 1 deletion(-) create mode 100755 tools/reloc_spec_check.sh diff --git a/Jenkinsfile b/Jenkinsfile index 50cd88908..3ebfd3614 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,6 +14,12 @@ pipeline { sh 'bash -c "tools/check_format.sh 2>&1 >(tee tools/check_format.txt)"' } } + stage('Check relocs') { + steps { + echo 'Checking relocs on spec...' + sh 'bash -c "tools/reloc_spec_check.sh"' + } + } stage('Copy ROM') { steps { echo 'Setting up ROM...' diff --git a/spec b/spec index 1e2684b7d..671fdee65 100644 --- a/spec +++ b/spec @@ -769,7 +769,7 @@ beginseg name "ovl_En_Door" compress include "build/src/overlays/actors/ovl_En_Door/z_en_door.o" - include "build/data/ovl_En_Door/ovl_En_Door.reloc.o" + include "build/src/overlays/actors/ovl_En_Door/ovl_En_Door_reloc.o" endseg beginseg diff --git a/tools/reloc_spec_check.sh b/tools/reloc_spec_check.sh new file mode 100755 index 000000000..434a49ec3 --- /dev/null +++ b/tools/reloc_spec_check.sh @@ -0,0 +1,112 @@ +#!/bin/bash + +# This script checks for overlay's relocs to be correctly used on the spec file depending on the overlay's NON_MATCHING/NON_EQUIVALENT +# and minimize possible broken NON_MATCHING builds. +# The script performs the following checks: +# - The extracted reloc isn't being used on the spec if the overlay has no other GLOBAL_ASM left (it has been matched). +# - Warn if an overlay is using both NON_MATCHING and NON_EQUIVALENT. +# - Warn if an overlay has NON_MATCHING ifdefs but some functions are still unattempted. +# - Both relocs (generated and extracted) are used on the spec on NON_MATCHING overlays. +# - The generated reloc isn't being used on NON_EQUIVALENT overlays. +# If any of those checks fails for any overlay, the script will print a warning and exit with a non-zero exit code. + +BOLD="$(tput bold)" +RED="$(tput setaf 1)" +PURPLE="$(tput setaf 5)" +WHITE="$(tput setaf 7)" +BLINK="$(tput blink)" +RST="$(tput sgr0)" + +# Run the script from the root of the project +DIR="$(dirname "$(readlink -f "$0")")" +cd "$DIR/.." + +EXIT_CODE=0 + +OVERLAYS_SUBFOLDERS="$(find src/overlays/*/* -type d)" + +while read OVL_FOLDER; do + # C files which are part of the current overlay + FILES_OF_OVERLAY="$(find "$OVL_FOLDER" -name '*.c')" + # List of files (of the current overlay) which doesn't contain GLOBAL_ASM + FILES_WITHOUT_PRAGMA="$(grep -L '#pragma GLOBAL_ASM' ${FILES_OF_OVERLAY})" + + if [ "$FILES_OF_OVERLAY" == "$FILES_WITHOUT_PRAGMA" ]; then + # This overlay is fully matched, so it should not be using the extracted reloc (use the generated one instead) + + OVL_NAME="$(cut -d '/' -f 4 <<< ${OVL_FOLDER})" + + # Parse the spec, searching for the extracted reloc of this overlay + OVL_WITH_EXTRACTED_RELOC="$(grep -F "$OVL_NAME".reloc spec)" + + if [ "$OVL_WITH_EXTRACTED_RELOC" != "" ]; then + echo "${BOLD} Matching overlay using extracted reloc on spec found: ${RED} ${OVL_FOLDER} ${RST}" + echo " Don't forget to change the extracted reloc to the generated one on the spec, otherwise the matched overlay won't be shiftable" + EXIT_CODE=1 + fi + else + # Overlay not fully matched + + # Search for files with NON_MATCHING and NON_EQUIVALENT + FILES_WITH_NON_MATCHING="$(grep -Fl '#ifdef NON_MATCHING' ${FILES_OF_OVERLAY})" + FILES_WITH_NON_EQUIVALENT="$(grep -Fl '#ifdef NON_EQUIVALENT' ${FILES_OF_OVERLAY})" + + if [ "$FILES_WITH_NON_MATCHING" != "" ] && [ "$FILES_WITH_NON_EQUIVALENT" != "" ]; then + # An overlay can't have both NON_MATCHINGs and NON_EQUIVALENTs, because relocs wouldn't be generated correctly + + echo "${BOLD} Overlay with both NON_MATCHINGs and NON_EQUIVALENTs found: ${RED} ${OVL_FOLDER} ${RST}" + echo " Overlays can't have both NON_MATCHING and NON_EQUIVALENT because it breaks NON_MATCHING builds" + echo " As an alternative you could mark NON_MATCHING functions as NON_EQUIVALENT and add a comment mentioning it is actually equivalent" + EXIT_CODE=1 + + elif [ "$FILES_WITH_NON_MATCHING" != "" ]; then + # Overlay only contains NON_MATCHINGs + + # Get the count of NON_MATCHING and GLOBAL_ASM of the current overlay + NON_MATCHINGS_COUNT_OF_OVERLAY="$(grep -F '#ifdef NON_MATCHING' ${FILES_WITH_NON_MATCHING} | wc -l)" + PRAGMAS_COUNT_OF_OVERLAY="$(grep -F '#pragma GLOBAL_ASM' ${FILES_WITH_NON_MATCHING} | wc -l)" + + if [ "$NON_MATCHINGS_COUNT_OF_OVERLAY" != "$PRAGMAS_COUNT_OF_OVERLAY" ]; then + # If an overlay uses NON_MATCHING, then every function should be either matching or marked as NON_MATCHING + + echo "${BOLD} Found an overlay with a differing number of NON_MATCHINGs and #pragma GLOBAL_ASM: ${RED} ${OVL_FOLDER} ${RST}" + echo " To use a NON_MATCHING check on an overlay, every function that does not match should verified to be equivalent" + echo " But the amount of NON_MATCHING ifdefs and GLOBAL_ASM does no match, which may suggest not every function of this overlay may have been attempted" + EXIT_CODE=1 + fi + + OVL_NAME="$(cut -d '/' -f 4 <<< ${OVL_FOLDER})" + + # Parse the spec, searching for the extracted reloc of this overlay + OVL_WITH_EXTRACTED_RELOC="$(grep -F "$OVL_NAME".reloc spec)" + + # Parse the spec, searching for the generated reloc of this overlay + OVL_WITH_GENERATED_RELOC="$(grep -F "$OVL_NAME"_reloc spec)" + + if [ "$OVL_WITH_EXTRACTED_RELOC" == "" ] || [ "$OVL_WITH_GENERATED_RELOC" == "" ]; then + # Overlays with NON_MATCHINGs should have both relocs on the spec + + echo "${BOLD} NON_MATCHING overlay missing either extracted or generated reloc on spec found: ${RED} ${OVL_FOLDER} ${RST}" + echo " Overlays with NON_MATCHING ifdefs must also add a NON_MATCHING ifdef on the spec to allow using the generated reloc on NON_MATCHING builds" + EXIT_CODE=1 + fi + elif [ "$FILES_WITH_NON_EQUIVALENT" != "" ]; then + # Overlay only contains NON_EQUIVALENTs + + OVL_NAME="$(cut -d '/' -f 4 <<< ${OVL_FOLDER})" + + # Parse the spec, searching for the generated reloc of this overlay + OVL_WITH_GENERATED_RELOC="$(grep -F "$OVL_NAME"_reloc spec)" + + if [ "$OVL_WITH_GENERATED_RELOC" != "" ]; then + # Overlays with NON_EQUIVALENTs should not use a generated reloc + + echo "${BOLD} NON_EQUIVALENT overlay with generated reloc on spec found: ${RED} ${OVL_FOLDER} ${RST}" + echo " Overlays with NON_EQUIVALENT ifdefs can't use generated relocs" + EXIT_CODE=1 + fi + fi + fi +done <<< ${OVERLAYS_SUBFOLDERS} + +exit $EXIT_CODE From 17489d9a1d108d509f019c288739b024903e5a9f Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Thu, 24 Mar 2022 17:32:24 -0700 Subject: [PATCH 086/257] En_Fishing OK (three functions matched) (#742) * EnFishing_UpdateOwner OK * EnFishing_UpdateFish OK * Respond to engineer's review * EnFishing_UpdateLure OK, thanks Synray! * Remove NON_MATCHING from spec --- spec | 4 - .../actors/ovl_En_Fishing/z_en_fishing.c | 86 +++++++------------ 2 files changed, 33 insertions(+), 57 deletions(-) diff --git a/spec b/spec index 671fdee65..750790ae4 100644 --- a/spec +++ b/spec @@ -1317,11 +1317,7 @@ beginseg name "ovl_En_Fishing" compress include "build/src/overlays/actors/ovl_En_Fishing/z_en_fishing.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_En_Fishing/ovl_En_Fishing_reloc.o" -#else - include "build/data/ovl_En_Fishing/ovl_En_Fishing.reloc.o" -#endif endseg beginseg 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 14e364d56..adde200f9 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -2058,32 +2058,23 @@ void EnFishing_DrawRod(GlobalContext* globalCtx) { static Vec3f D_8090D614 = { 0.0f, 0.0f, 0.0f }; -#ifdef NON_MATCHING -// Stack memes, the pad on line ~2410 makes stack too big, but needed for ordering void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { f32 spE4; f32 spE0; - s16 phi_v0; + s16 i; s16 spDC; f32 spD8; f32 spD4; f32 spD0; f32 phi_f16; f32 spC8; - s16 i; + f32 phi_f0; Player* player = GET_PLAYER(globalCtx); Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; Vec3f spA8; Vec3f sp9C; Vec3f sp90; Input* input = CONTROLLER1(globalCtx); - // Vec3f sp80; - - f32 phi_f0; - // f32 sp70; - // Vec3f sp64; - // Vec3f sp58; - // s32 pad; D_809171FE++; @@ -2240,8 +2231,6 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { spC8 = SQ(sLurePos.x) + SQ(sLurePos.z); if (spC8 > SQ(920.0f)) { - f32 temp; - if ((sLurePos.y > 160.0f) || (sLurePos.x < 80.0f) || (sLurePos.x > 180.0f) || (sLurePos.z > 1350.0f) || (sLurePos.z < 1100.0f) || (sLurePos.y < 45.0f)) { Vec3f sp80 = this->actor.world.pos; @@ -2266,10 +2255,9 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { } } - temp = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); - // spE4 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); - if (sLurePos.y <= temp) { - sLurePos.y = temp; + spE0 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); + if (sLurePos.y <= spE0) { + sLurePos.y = spE0; D_80917238.x = D_80917238.y = D_80917238.z = 0.0f; D_8090CD14 = 3; D_809101D0 = 0.0; @@ -2281,7 +2269,6 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { } else { f32 sp7C = WATER_SURFACE_Y(globalCtx); f32 sp78; - // spE4 = WATER_SURFACE_Y(globalCtx); if (sLurePos.y <= sp7C) { D_8090CD14 = 2; @@ -2356,7 +2343,10 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { break; case 3: { + f32 pad; f32 sp70; + Vec3f sp64; + Vec3f sp58; D_80911F20 = 0; @@ -2432,7 +2422,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { sLurePos.y += D_80917278.y; } } else if (CHECK_BTN_ALL(input->cur.button, BTN_A)) { - s32 pad; + s8 requiredScopeTemp; spDC = 0x500; D_809101B0 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; @@ -2483,7 +2473,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { Matrix_InsertYRotation_f(sLureRot.y, MTXMODE_NEW); if (D_80917206 == 2) { - Vec3f sp64; + s8 requiredScopeTemp; Matrix_MultiplyVector3fByState(&sp90, &sp64); D_80917278.x = sp64.x; @@ -2506,7 +2496,9 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { } } else if (sReelLinePos[LINE_SEG_COUNT - 1].y < (WATER_SURFACE_Y(globalCtx) + phi_f0)) { if (D_80917206 == 2) { - Vec3f sp58 = this->actor.world.pos; + s8 requiredScopeTemp; + + sp58 = this->actor.world.pos; this->actor.prevPos = this->actor.world.pos = sLurePos; Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 30.0f, 0x44); this->actor.world.pos = sp58; @@ -2579,7 +2571,8 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { if ((sLurePos.y <= (WATER_SURFACE_Y(globalCtx) + 4.0f)) && (sLurePos.y >= (WATER_SURFACE_Y(globalCtx) - 4.0f))) { - phi_v0 = 63; + s8 phi_v0 = 63; + if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (D_809101B4 > 1.0f)) { phi_v0 = 1; } @@ -2590,8 +2583,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &spA8, 30.0f, 300.0f, 150, 90); } } - break; - } + } break; // must be outside of the block case 4: if (this->unk_14F != 0) { @@ -2626,10 +2618,6 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { break; } } -#else -static Vec3f D_8090D620 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_UpdateLure.s") -#endif s32 func_809033F0(EnFishing* this, GlobalContext* globalCtx, u8 ignorePosCheck) { s16 i; @@ -2851,8 +2839,6 @@ void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// D_80917266 in case 5 around the large branching void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { s16 i; s16 sp134 = 10; @@ -2868,7 +2854,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { s16 spFE; s16 spFC; s16 spFA; - s16 phi_v0; + s16 spF8; s16 spF6; s16 spF4; s16 spF2; @@ -2883,11 +2869,9 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { f32 phi_f2; Vec3f spC4; Vec3f spB8; - u8 phi_v0_2; f32 temp_f0; f32 temp; - s32 pad; - f32 spA4; + f32 temp2; this->actor.uncullZoneForward = 700.0f; this->actor.uncullZoneScale = 50.0f; @@ -3435,6 +3419,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_188 = 1.0f; this->unk_18C = 2000.0f; } else if (sp124 < 10.0f) { + s16 phi_v0; + if (func_809033F0(this, globalCtx, false)) { func_80903C60(this, 0); } @@ -3565,15 +3551,15 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { D_809171F6 = 0; if (this->unk_148 == 1) { - spA4 = (this->unk_1A4 * 3.0f) + 120.0f; + temp2 = (this->unk_1A4 * 3.0f) + 120.0f; } else { - spA4 = (2.0f * this->unk_1A4) + 120.0f; + temp2 = (2.0f * this->unk_1A4) + 120.0f; } - if (spA4 > 255.0f) { - spA4 = 255.0f; + if (temp2 > 255.0f) { + temp2 = 255.0f; } - func_8013EC44(0.0f, spA4, 120, 5); + func_8013EC44(0.0f, temp2, 120, 5); D_809171F4 = 40; D_80911E28 = 10; play_sound(NA_SE_IT_FISHING_HIT); @@ -3581,6 +3567,9 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } if (this->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) { + u8 phi_v0_2; + f32 spA4; + if (this->unk_172[1] > 30) { phi_v0_2 = 7; } else { @@ -4181,9 +4170,6 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_UpdateFish.s") -#endif s32 EnFishing_FishOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { @@ -5053,8 +5039,6 @@ static Vec3s sSinkingLureLocationPos[] = { { 553, -48, -508 }, }; -#ifdef NON_MATCHING -// Register flip around target near the end of the function void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; EnFishing* this = THIS; @@ -5066,10 +5050,9 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { f32 target; f32 camAtFraction; f32 lureDistXZ; - s32 pad; + Camera* camera; Player* player = GET_PLAYER(globalCtx); Input* input = CONTROLLER1(globalCtx); - Camera* camera; playerShadowAlpha = player->actor.shape.shadowAlpha; @@ -5334,7 +5317,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { player->actor.speedXZ = 0.0f; if (Message_GetState(&globalCtx->msgCtx) == 0) { - camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); camera->eye = sCameraEye; camera->eyeNext = sCameraEye; @@ -5533,7 +5516,8 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { Math_ApproachF(&D_8090CCD0, D_8090CCD4, 1.0f, 0.05f); if (D_8090CCD0 > 0.0f) { - target = (D_8090CCD0 * 0.03f) + 0.8f; + f32 target = (D_8090CCD0 * 0.03f) + 0.8f; + if (target > 1.2f) { target = 1.2f; } @@ -5561,9 +5545,8 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { if ((u8)D_8090CCD0 > 0) { s32 pad; - Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); s16 i; - s32 pad1; + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); Vec3f pos; Vec3f rot; Vec3f projectedPos; @@ -5601,9 +5584,6 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { gSaveContext.minigameScore = (SQ((f32)D_8090CCF8) * 0.0036f) + 0.5f; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_UpdateOwner.s") -#endif s32 EnFishing_OwnerOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { From fb3768c40036ab4f2583ec883af09af4787b4bd9 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Thu, 24 Mar 2022 20:38:13 -0400 Subject: [PATCH 087/257] Clean up z_door_ana (#576) * Clean up z_door_ana * implement pr suggestions * improve set type macro --- src/overlays/actors/ovl_Door_Ana/z_door_ana.c | 88 ++++++++----------- src/overlays/actors/ovl_Door_Ana/z_door_ana.h | 23 +++-- 2 files changed, 49 insertions(+), 62 deletions(-) diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c index 73d9911f9..f814eeafd 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -52,8 +52,7 @@ static ColliderCylinderInit sCylinderInit = { { 50, 10, 0, { 0, 0, 0 } }, }; -// entrances grottos can link to statically, type DOORANA_TYPE_ADJACENT uses scene exit addresses instead -static u16 entrances[] = { +static u16 sEntranceIndexes[] = { 0x1A00, 0x1400, 0x1410, 0x1420, 0x1430, 0x1440, 0x1450, 0x1460, 0x1470, 0x1480, 0x1490, 0x14A0, 0x14B0, 0x14C0, 0x14D0, }; @@ -64,11 +63,12 @@ void DoorAna_SetupAction(DoorAna* this, DoorAnaActionFunc actionFunction) { void DoorAna_Init(Actor* thisx, GlobalContext* globalCtx) { DoorAna* this = THIS; - s32 grottoType = GET_DOORANA_TYPE(this); + s32 grottoType = DOORANA_GET_TYPE(&this->actor); + this->actor.shape.rot.y = this->actor.shape.rot.z = 0; - if ((grottoType == DOORANA_TYPE_UNK) || (grottoType == DOORANA_TYPE_HIDDEN)) { - if (grottoType == DOORANA_TYPE_HIDDEN) { + if (grottoType == DOORANA_TYPE_HIDDEN_STORMS || grottoType == DOORANA_TYPE_HIDDEN_BOMB) { + if (grottoType == DOORANA_TYPE_HIDDEN_BOMB) { Collider_InitAndSetCylinder(globalCtx, &this->bombCollider, &this->actor, &sCylinderInit); } else { this->actor.flags |= ACTOR_FLAG_10; // always update @@ -86,27 +86,27 @@ void DoorAna_Init(Actor* thisx, GlobalContext* globalCtx) { void DoorAna_Destroy(Actor* thisx, GlobalContext* globalCtx) { DoorAna* this = THIS; - s32 grottoType = GET_DOORANA_TYPE(this); + s32 grottoType = DOORANA_GET_TYPE(&this->actor); - if (grottoType == DOORANA_TYPE_HIDDEN) { + if (grottoType == DOORANA_TYPE_HIDDEN_BOMB) { Collider_DestroyCylinder(globalCtx, &this->bombCollider); } } void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { - s32 grottoIsOpen = 0; - u32 grottoType = GET_DOORANA_TYPE(this); + s32 grottoIsOpen = false; + u32 grottoType = DOORANA_GET_TYPE(&this->actor); - if (grottoType == DOORANA_TYPE_UNK) { - // in OOT decomp its marked as open with storms, but does not seem to open with storms in MM - if ((this->actor.xyzDistToPlayerSq < SQ(200.0f)) && (EnvFlags_Get(globalCtx, 5))) { - grottoIsOpen = 1; + if (grottoType == DOORANA_TYPE_HIDDEN_STORMS) { + //! @bug Implementation from OoT is not updated for MM, grotto does not open on Song of Storms + if (this->actor.xyzDistToPlayerSq < SQ(200.0f) && EnvFlags_Get(globalCtx, 5)) { + grottoIsOpen = true; this->actor.flags &= ~ACTOR_FLAG_10; // always update OFF } } else { if (this->bombCollider.base.acFlags & AC_HIT) { // bomb collision - grottoIsOpen = 1; + grottoIsOpen = true; Collider_DestroyCylinder(globalCtx, &this->bombCollider); } else { @@ -116,7 +116,7 @@ void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { } if (grottoIsOpen) { - this->actor.params &= ~DOORANA_TYPE_BITRANGE; + DOORANA_SET_TYPE(&this->actor, DOORANA_TYPE_VISIBLE); DoorAna_SetupAction(this, DoorAna_WaitOpen); play_sound(NA_SE_SY_CORRECT_CHIME); } @@ -126,56 +126,44 @@ void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { void DoorAna_WaitOpen(DoorAna* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s32 dooranaType = GET_DOORANA_TYPE(this); - s8 pad[4]; - s32 entranceIndex; - f32 playerHeightRel; + s32 grottoType = DOORANA_GET_TYPE(&this->actor); - if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.001f) != 0) { - if ((this->actor.targetMode != 0) && (globalCtx->sceneLoadFlag == 0) && (globalCtx->unk_18B4A == 0) && - (player->stateFlags1 & 0x80000000) && (player->unk_AE7 == 0)) { + if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.001f)) { + if (this->actor.targetMode != 0 && globalCtx->sceneLoadFlag == 0 && globalCtx->unk_18B4A == 0 && + (player->stateFlags1 & 0x80000000) && player->unk_AE7 == 0) { - if (dooranaType == DOORANA_TYPE_ADJACENT) { - s32 requiredScopeTemp; + if (grottoType == DOORANA_TYPE_VISIBLE_SCENE_EXIT) { + s32 exitIndex = DOORANA_GET_EXIT_INDEX(&this->actor); - // 300 uses scene exit addresses, not static DoorAna entrance addresses, - // eg. deku playground gets address in the NCT scene exit table - - entranceIndex = GET_DOORANA_ADJACENT_ENTRANCE(this); - globalCtx->nextEntranceIndex = globalCtx->setupExitList[entranceIndex]; + globalCtx->nextEntranceIndex = globalCtx->setupExitList[exitIndex]; } else { - // unused in vanilla, the highest params bits can directly index an address - entranceIndex = GET_DOORANA_DIRECT_ENTRANCE(this); + s32 destinationIdx = DOORANA_GET_ENTRANCE(&this->actor); Play_SetupRespawnPoint(&globalCtx->state, 3, 0x4FF); gSaveContext.respawn[3].pos.y = this->actor.world.pos.y; gSaveContext.respawn[3].yaw = this->actor.home.rot.y; - // save the params lower byte for En_Torch to decide what item to use in the grotto chest - gSaveContext.respawn[3].data = GET_DOORANA_ITEMFLAGS(this); + // Stores item and chest flag that ACTOR_EN_TORCH uses for spawning the grotto chest + gSaveContext.respawn[3].data = DOORANA_GET_ITEMFLAGS(&this->actor); - // most grottos in the game use their zrotation as their entrance index, not params - if (DOORANA_TYPE_ROTATION_ENTRANCE(entranceIndex)) { - entranceIndex = GET_DOORANA_ROTATION_ENTRANCE(this); + if (destinationIdx < 0) { + destinationIdx = DOORANA_GET_EX_ENTRANCE(&this->actor); } - globalCtx->nextEntranceIndex = entrances[entranceIndex]; + globalCtx->nextEntranceIndex = sEntranceIndexes[destinationIdx]; } DoorAna_SetupAction(this, DoorAna_GrabLink); - } else { - if ((func_801690CC(globalCtx) == 0) && ((player->stateFlags1 & 0x08800000) == 0) && - (this->actor.xzDistToPlayer <= 20.0f) && - (playerHeightRel = this->actor.playerHeightRel, (playerHeightRel >= -50.0f)) && - (playerHeightRel <= 15.0f)) { - player->stateFlags1 |= 0x80000000; - this->actor.targetMode = 1; + } else if (func_801690CC(globalCtx) == 0 && (player->stateFlags1 & 0x08800000) == 0 && + this->actor.xzDistToPlayer <= 20.0f && this->actor.playerHeightRel >= -50.0f && + this->actor.playerHeightRel <= 15.0f) { + player->stateFlags1 |= 0x80000000; + this->actor.targetMode = 1; - } else { - this->actor.targetMode = 0; - } + } else { + this->actor.targetMode = 0; } } @@ -194,10 +182,10 @@ void DoorAna_GrabLink(DoorAna* this, GlobalContext* globalCtx) { } } - if ((this->actor.playerHeightRel <= 0.0f) && (this->actor.xzDistToPlayer > 20.0f)) { + if (this->actor.playerHeightRel <= 0.0f && this->actor.xzDistToPlayer > 20.0f) { player = GET_PLAYER(globalCtx); - player->actor.world.pos.x = (Math_SinS(this->actor.yawTowardsPlayer) * 20.0f) + this->actor.world.pos.x; - player->actor.world.pos.z = (Math_CosS(this->actor.yawTowardsPlayer) * 20.0f) + this->actor.world.pos.z; + player->actor.world.pos.x = Math_SinS(this->actor.yawTowardsPlayer) * 20.0f + this->actor.world.pos.x; + player->actor.world.pos.z = Math_CosS(this->actor.yawTowardsPlayer) * 20.0f + this->actor.world.pos.z; } } diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.h b/src/overlays/actors/ovl_Door_Ana/z_door_ana.h index aec6e70be..0cff726e9 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.h +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.h @@ -15,18 +15,17 @@ typedef struct DoorAna { extern const ActorInit Door_Ana_InitVars; -#define DOORANA_TYPE_REGULAR 0x000 -#define DOORANA_TYPE_UNK 0x100 -#define DOORANA_TYPE_HIDDEN 0x200 -#define DOORANA_TYPE_ADJACENT 0x300 -#define DOORANA_TYPE_BITRANGE 0x300 +#define DOORANA_TYPE_BITMASK 0x300 +#define DOORANA_TYPE_VISIBLE 0x000 +#define DOORANA_TYPE_HIDDEN_STORMS 0x100 // Incomplete, leftover from OoT +#define DOORANA_TYPE_HIDDEN_BOMB 0x200 +#define DOORANA_TYPE_VISIBLE_SCENE_EXIT 0x300 // Destination dependent on scene exit list -#define GET_DOORANA_TYPE(this)(this->actor.params & 0x300) - -#define DOORANA_TYPE_ROTATION_ENTRANCE(directEntrance)(directEntrance < 0) -#define GET_DOORANA_DIRECT_ENTRANCE(this) ((((this)->actor.params >> 0xC) & 0x7) - 1) -#define GET_DOORANA_ADJACENT_ENTRANCE(this) ((this)->actor.params & 0x1F) -#define GET_DOORANA_ROTATION_ENTRANCE(this) (this->actor.home.rot.z + 1) -#define GET_DOORANA_ITEMFLAGS(this) ((this)->actor.params & 0xFF) +#define DOORANA_GET_TYPE(thisx) ((thisx)->params & DOORANA_TYPE_BITMASK) +#define DOORANA_GET_ENTRANCE(thisx) ((((thisx)->params >> 12) & 0x7) - 1) +#define DOORANA_GET_EX_ENTRANCE(thisx) ((thisx)->home.rot.z + 1) +#define DOORANA_GET_EXIT_INDEX(thisx) ((thisx)->params & 0x1F) +#define DOORANA_GET_ITEMFLAGS(thisx) ((thisx)->params & 0xFF) +#define DOORANA_SET_TYPE(thisx, t) ((thisx)->params = ((thisx)->params & ~DOORANA_TYPE_BITMASK) + (t)) #endif // Z_DOOR_ANA_H From ad25a1dc4758c05cdd0a8a6c6d02105d48e5754c Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Fri, 25 Mar 2022 00:44:00 +0000 Subject: [PATCH 088/257] Obj_Skateblock (#622) * Obj_Skateblock * PR * PR * PR * PR * Something weird happened --- spec | 3 +- .../ovl_Obj_Skateblock/z_obj_skateblock.c | 675 ++++++++++++++++-- .../ovl_Obj_Skateblock/z_obj_skateblock.h | 24 +- 3 files changed, 656 insertions(+), 46 deletions(-) diff --git a/spec b/spec index 750790ae4..a10aa74eb 100644 --- a/spec +++ b/spec @@ -2642,8 +2642,7 @@ beginseg name "ovl_Obj_Skateblock" compress include "build/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.o" - include "build/data/ovl_Obj_Skateblock/ovl_Obj_Skateblock.data.o" - include "build/data/ovl_Obj_Skateblock/ovl_Obj_Skateblock.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Skateblock/ovl_Obj_Skateblock_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c index 8219bc581..a953cd304 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c @@ -5,6 +5,7 @@ */ #include "z_obj_skateblock.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,17 @@ void ObjSkateblock_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSkateblock_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSkateblock_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A22308(ObjSkateblock* this); +void func_80A22334(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A2244C(ObjSkateblock* this); +void func_80A224A4(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A22628(ObjSkateblock* this); +void func_80A2264C(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A22728(ObjSkateblock* this); +void func_80A2273C(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A227A4(ObjSkateblock* this); +void func_80A227C0(ObjSkateblock* this, GlobalContext* globalCtx); + const ActorInit Obj_Skateblock_InitVars = { ACTOR_OBJ_SKATEBLOCK, ACTORCAT_BG, @@ -28,76 +39,658 @@ const ActorInit Obj_Skateblock_InitVars = { (ActorFunc)ObjSkateblock_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A22AE0[] = { - ICHAIN_F32_DIV1000(gravity, -1700, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), +s32 D_80A22A10 = 0; + +s32 D_80A22A14 = 0; + +AnimatedMaterial* D_80A22A18 = NULL; + +Vec2f D_80A22A1C[] = { + { -300.0f, 300.0f }, { 300.0f, 300.0f }, { -300.0f, -300.0f }, { 300.0f, -300.0f }, { 0.0f, 0.0f }, }; -#endif +Vec2f D_80A22A44[] = { + { 0.5f, -0.5f }, { -0.5f, -0.5f }, { 0.5f, 0.5f }, { -0.5f, 0.5f }, { 0.0f, 0.0f }, +}; -extern InitChainEntry D_80A22AE0[]; +Vec2f D_80A22A6C[] = { + { -300.0f, 0.0f }, { 300.0f, 0.0f }, { -300.0f, 600.0f }, { 300.0f, 600.0f }, { 0.0f, 300.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21150.s") +Vec2f D_80A22A94[] = { + { 1.0f, 1.0f }, { -1.0f, 1.0f }, { 1.0f, -1.0f }, { -1.0f, -1.0f }, { 0.0f, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A211F4.s") +f32 D_80A22ABC[] = { -300.0f, 300.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A212F0.s") +f32 D_80A22AC4[] = { 1.0f, -1.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21370.s") +Vec3f D_80A22ACC = { 0.0f, 0.3f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21548.s") +Color_RGBA8 D_80A22AD8 = { 250, 250, 250, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A216D4.s") +Color_RGBA8 D_80A22ADC = { 180, 180, 180, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21934.s") +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -1700, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21990.s") +f32 D_80A22AF8[] = { 14.0f, -14.0f, 14.0f, -14.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21C30.s") +Color_RGB8 D_80A22B08[] = { + { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, + { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, + { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21C88.s") +s32 func_80A21150(ObjSkateblock* this) { + s32 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21CB4.s") + if (fabsf(this->dyna.pushForce) > 0.1f) { + if (this->dyna.pushForce > 0.0f) { + temp_v0 = BINANG_ADD(this->dyna.yRotation, 0x2000); + } else { + temp_v0 = BINANG_SUB(this->dyna.yRotation, 0x6000); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21CD8.s") + if (temp_v0 < -0x4000) { + return 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21D1C.s") + if (temp_v0 < 0) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21E9C.s") + if (temp_v0 < 0x4000) { + return 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21F68.s") + return 0; + } + return -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21F74.s") +void func_80A211F4(ObjSkateblock* this, s32 arg1) { + s32 i; + s32 phi_v0 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Init.s") + if (this->dyna.pushForce > 0.0f) { + phi_v0 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Destroy.s") + for (i = 0; i < ARRAY_COUNT(this->unk_172); i++) { + if ((arg1 == i) && phi_v0) { + this->unk_172[i]++; + } else if (this->unk_172[i] > 0) { + this->unk_172[i]--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22308.s") +void func_80A212F0(Vec3f* arg0, Vec3f* arg1, s16 arg2) { + f32 sp1C = Math_SinS(arg2); + f32 temp_f0 = Math_CosS(arg2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22334.s") + arg0->x = (arg1->z * sp1C) + (arg1->x * temp_f0); + arg0->y = arg1->y; + arg0->z = (arg1->z * temp_f0) - (arg1->x * sp1C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A2244C.s") +s32 func_80A21370(ObjSkateblock* this, GlobalContext* globalCtx) { + ObjSkateblockFloor* floor; + s32 i; + s32 pad; + s32 sp98; + Vec3f sp8C; + s32 sp88; + f32 phi_f20 = BGCHECK_Y_MIN; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A224A4.s") + sp88 = false; + sp8C.y = this->dyna.actor.world.pos.y + 40.0f; + sp98 = -1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22628.s") + for (i = 0; i < ARRAY_COUNT(this->unk_184); i++) { + floor = &this->unk_184[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A2264C.s") + floor->poly = NULL; + floor->height = BGCHECK_Y_MIN; + floor->bgId = BG_ACTOR_MAX; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22728.s") + sp8C.x = this->dyna.actor.world.pos.x + ((D_80A22A1C[i].x * this->dyna.actor.scale.x) + D_80A22A44[i].x); + sp8C.z = this->dyna.actor.world.pos.z + ((D_80A22A1C[i].y * this->dyna.actor.scale.z) + D_80A22A44[i].y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A2273C.s") + floor->height = + BgCheck_EntityRaycastFloor6(&globalCtx->colCtx, &floor->poly, &floor->bgId, &this->dyna.actor, &sp8C, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A227A4.s") + if (floor->height > BGCHECK_Y_MIN + 1.0f) { + sp88 = true; + if (phi_f20 < floor->height) { + phi_f20 = floor->height; + sp98 = i; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A227C0.s") + if (sp98 >= 0) { + this->dyna.actor.floorPoly = this->unk_184[sp98].poly; + this->dyna.actor.floorHeight = this->unk_184[sp98].height; + this->dyna.actor.floorBgId = this->unk_184[sp98].bgId; + } + return sp88; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Update.s") +s32 func_80A21548(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 i; + ObjSkateblockFloor* floor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Draw.s") + this->unk_1C1 &= ~4; + + if (func_80A21370(this, globalCtx)) { + f32 maxHeight = BGCHECK_Y_MIN; + s32 phi_v1 = false; + f32 temp_f12 = this->dyna.actor.world.pos.y - 10.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_184); i++) { + floor = &this->unk_184[i]; + if ((temp_f12 < floor->height) && (floor->height > maxHeight)) { + maxHeight = floor->height; + phi_v1 = true; + } + } + + if (phi_v1) { + this->dyna.actor.world.pos.y = maxHeight; + this->unk_1C1 |= 4; + this->dyna.actor.velocity.y = 0.0f; + } + return phi_v1; + } + return false; +} + +s32 func_80A216D4(ObjSkateblock* this, GlobalContext* globalCtx, f32 arg2, Vec3f* arg3) { + s32 pad; + f32 spE8; + f32 spE4; + s32 i; + Vec3f spD4; + Vec3f spC8; + Vec3f spBC; + Vec3f spB0; + f32 temp_f20; + f32 temp_f24; + s32 spA4; + CollisionPoly* spA0; + s32 ret; + f32 temp_f26; + s16 sp96 = this->dyna.yRotation; + f32 temp_f2; + + if (this->dyna.pushForce < 0.0f) { + sp96 -= 0x8000; + } + spE8 = Math_SinS(sp96); + spE4 = Math_CosS(sp96); + + temp_f2 = Math3D_Distance(&this->dyna.actor.world.pos, &this->dyna.actor.prevPos) + + (300.0f * this->dyna.actor.scale.z) + arg2; + temp_f24 = temp_f2 * spE8; + temp_f26 = temp_f2 * spE4; + + ret = false; + temp_f20 = FLT_MAX; + + for (i = 0; i < ARRAY_COUNT(D_80A22A6C); i++) { + spBC.x = (D_80A22A6C[i].x * this->dyna.actor.scale.x) + D_80A22A94[i].x; + spBC.y = (D_80A22A6C[i].y * this->dyna.actor.scale.y) + D_80A22A94[i].y; + spBC.z = 0.0f; + + func_80A212F0(&spD4, &spBC, sp96); + + spD4.x += this->dyna.actor.prevPos.x; + spD4.y += this->dyna.actor.prevPos.y; + spD4.z += this->dyna.actor.prevPos.z; + + spC8.x = temp_f24 + spD4.x; + spC8.y = spD4.y; + spC8.z = temp_f26 + spD4.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spD4, &spC8, &spB0, &spA0, true, false, false, true, &spA4, + &this->dyna.actor, 0.0f)) { + temp_f2 = Math3D_Vec3fDistSq(&spD4, &spB0); + if (temp_f2 < temp_f20) { + temp_f20 = temp_f2; + ret = true; + Math_Vec3f_Diff(&spB0, &spC8, arg3); + } + } + } + return ret; +} + +s32 func_80A21934(ObjSkateblock* this, GlobalContext* globalCtx) { + Vec3f sp1C; + + if (func_80A216D4(this, globalCtx, 0.0f, &sp1C)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + return false; +} + +s32 func_80A21990(ObjSkateblock* this, GlobalContext* globalCtx, Vec3f* arg2) { + s32 i; + f32 sp100; + s16 phi_s6 = this->dyna.yRotation; + f32 phi_f22; + Vec3f spEC; + Vec3f spE0; + Vec3f spD4; + Vec3f spC8; + f32 temp_f0; + f32 temp_f12; + s32 spBC; + CollisionPoly* spB8; + s32 ret; + f32 temp_f26; + f32 temp_f28; + f32 temp_f30; + + if (this->dyna.pushForce < 0.0f) { + phi_s6 -= 0x8000; + } + + sp100 = Math_SinS(phi_s6); + temp_f26 = Math_CosS(phi_s6); + + temp_f12 = + (300.0f * this->dyna.actor.scale.z + Math3D_Distance(&this->dyna.actor.world.pos, &this->dyna.actor.prevPos)) + + 2.0f; + temp_f28 = -temp_f12 * sp100; + temp_f30 = -temp_f12 * temp_f26; + + ret = false; + phi_f22 = FLT_MAX; + + for (i = 0; i < ARRAY_COUNT(D_80A22ABC); i++) { + spD4.x = (D_80A22ABC[i] * this->dyna.actor.scale.x) + D_80A22AC4[i]; + spD4.y = -10.0f; + spD4.z = 0.0f; + + func_80A212F0(&spEC, &spD4, phi_s6); + + spEC.x += this->dyna.actor.world.pos.x; + spEC.y += this->dyna.actor.world.pos.y; + spEC.z += this->dyna.actor.world.pos.z; + + spE0.x = temp_f28 + spEC.x; + spE0.y = spEC.y; + spE0.z = temp_f30 + spEC.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spEC, &spE0, &spC8, &spB8, true, false, false, true, &spBC, + &this->dyna.actor, 0.0f)) { + temp_f0 = Math3D_Vec3fDistSq(&spEC, &spC8); + if (temp_f0 < phi_f22) { + ret = true; + arg2->x = (spC8.x - spEC.x) + (300.0f * this->dyna.actor.scale.z * sp100); + arg2->y = 0.0f; + arg2->z = (spC8.z - spEC.z) + (300.0f * this->dyna.actor.scale.z * temp_f26); + phi_f22 = temp_f0; + } + } + } + return ret; +} + +s32 func_80A21C30(ObjSkateblock* this, GlobalContext* globalCtx) { + Vec3f sp1C; + + if (func_80A21990(this, globalCtx, &sp1C)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + + return false; +} + +void func_80A21C88(ObjSkateblock* this, s32 arg1) { + if ((arg1 == 0) || (arg1 == 1)) { + this->unk_16C = &this->dyna.actor.world.pos.x; + } else { + this->unk_16C = &this->dyna.actor.world.pos.z; + } + this->unk_170 = arg1; +} + +void func_80A21CB4(ObjSkateblock* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; +} + +void func_80A21CD8(ObjSkateblock* this) { + this->dyna.actor.velocity.y += this->dyna.actor.gravity; + if (this->dyna.actor.velocity.y < this->dyna.actor.terminalVelocity) { + this->dyna.actor.velocity.y = this->dyna.actor.terminalVelocity; + } + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; +} + +void func_80A21D1C(ObjSkateblock* this) { + f32 sp4; + f32 temp_f14; + f32 temp_f16; + f32 temp_f6; + f32 phi_f2; + + temp_f14 = this->dyna.actor.world.pos.x - this->dyna.actor.home.pos.x; + phi_f2 = ((temp_f14 >= 0.0f) ? 0.5f : -0.5f); + sp4 = ((s32)(phi_f2 + temp_f14) / 30) * 30; + temp_f14 -= sp4; + + if (fabsf(temp_f14) < 3.0f) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + sp4; + } + + temp_f16 = this->dyna.actor.world.pos.z - this->dyna.actor.home.pos.z; + phi_f2 = ((temp_f16 >= 0.0f) ? 0.5f : -0.5f); + temp_f6 = ((s32)(phi_f2 + temp_f16) / 30) * 30; + temp_f16 -= temp_f6; + + if (fabsf(temp_f16) < 3.0f) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + temp_f6; + } +} + +void func_80A21E9C(ObjSkateblock* this, GlobalContext* globalCtx) { + DynaPolyActor* temp_v0; + s32 i; + ObjSkateblockFloor* ptr; + + if (!(this->unk_1C1 & 4)) { + return; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_184); i++) { + ptr = &this->unk_184[i]; + + temp_v0 = DynaPoly_GetActor(&globalCtx->colCtx, ptr->bgId); + if ((temp_v0 != NULL) && (temp_v0->actor.id == ACTOR_OBJ_SKATEBLOCK)) { + ObjSkateblock* skateBlock = (ObjSkateblock*)temp_v0; + f32 height = this->dyna.actor.world.pos.y - ptr->height; + + if (fabsf(height) < 0.1f) { + skateBlock->unk_1C1 |= 2; + } + } + } +} + +void func_80A21F68(ObjSkateblock* this) { + this->unk_17C = 0; +} + +void func_80A21F74(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f spA8; + Vec3f sp9C; + f32 phi_f22; + s32 i; + f32 temp; + s32 pad2; + s16 sp8A = this->dyna.yRotation; + + if (this->dyna.pushForce < 0.0f) { + sp8A -= 0x8000; + } + + this->unk_17C++; + + if (this->dyna.actor.flags & ACTOR_FLAG_40) { + if (this->unk_17C >= 46) { + phi_f22 = 1.0f; + } else { + phi_f22 = (this->unk_17C * 0.017777778f) + 0.2f; + } + sp9C.y = 12.0f; + + for (i = 0; i < 2; i++) { + if (phi_f22 < (Rand_ZeroOne() * 1.2f)) { + continue; + } + this->unk_180 += Rand_ZeroOne(); + + if (this->unk_180 > 1.0f) { + this->unk_180 -= 1.0f; + } + + sp9C.x = (this->unk_180 - 0.5f) * 600.0f * this->dyna.actor.scale.x; + sp9C.z = (this->dyna.actor.scale.z * -300.0f) + 4.0f; + + func_80A212F0(&spA8, &sp9C, sp8A); + + spA8.x += this->dyna.actor.world.pos.x; + spA8.y += this->dyna.actor.world.pos.y; + spA8.z += this->dyna.actor.world.pos.z; + + temp = ((Rand_ZeroOne() * 800.0f) + (1600.0f * this->dyna.actor.scale.x)) * phi_f22; + func_800B0E48(globalCtx, &spA8, &gZeroVec3f, &D_80A22ACC, &D_80A22AD8, &D_80A22ADC, temp, + (Rand_ZeroOne() * 20.0f) + 30.0f); + } + } +} + +void ObjSkateblock_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjSkateblock* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gameplay_dangeon_keep_Colheader_007498); + if (D_80A22A18 == NULL) { + D_80A22A18 = Lib_SegmentedToVirtual(gameplay_dangeon_keep_Matanimheader_01B370); + } + func_80A22308(this); + this->unk_1C0 = D_80A22A14; + D_80A22A14++; + D_80A22A14 &= 0x1F; +} + +void ObjSkateblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSkateblock* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80A22308(ObjSkateblock* this) { + this->actionFunc = func_80A22334; + this->unk_172[1] = 0; + this->unk_172[2] = 0; + this->unk_172[3] = 0; + this->unk_172[0] = 0; + this->dyna.actor.velocity.y = 0.0f; +} + +void func_80A22334(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp30; + s32 sp2C; + Vec3f sp20; + + func_80A21CD8(this); + func_80A21548(this, globalCtx); + sp2C = func_80A21150(this); + func_80A211F4(this, sp2C); + + sp30 = true; + + if (sp2C == -1) { + sp30 = false; + } else if (!(this->unk_1C1 & 2) && (this->unk_172[sp2C] > 10) && (D_80A22A10 == 0) && + !func_80A216D4(this, globalCtx, 2.0f, &sp20) && !Player_InCsMode(&globalCtx->state)) { + func_80A21C88(this, sp2C); + func_80A2244C(this); + sp30 = false; + func_800B7298(globalCtx, &this->dyna.actor, 7); + this->unk_1C1 |= 1; + } + + if (sp30) { + func_80A21CB4(this, globalCtx); + } +} + +void func_80A2244C(ObjSkateblock* this) { + this->actionFunc = func_80A224A4; + this->unk_168 = D_80A22AF8[this->unk_170]; + this->unk_164 = 0.0f; + this->unk_17A = 15; + this->dyna.actor.velocity.y = this->dyna.actor.gravity; + func_80A21F68(this); +} + +void func_80A224A4(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp28 = false; + s32 sp24 = false; + + Math_StepToF(&this->unk_164, this->unk_168, 0.75f); + + *this->unk_16C += this->unk_164; + + if (func_80A21934(this, globalCtx)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + func_80A21D1C(this); + sp28 = true; + } else { + func_800B9010(&this->dyna.actor, NA_SE_PL_SLIP_ICE_LEVEL - SFX_FLAG); + } + + func_80A21CD8(this); + + if (!func_80A21548(this, globalCtx)) { + func_80A21C30(this, globalCtx); + func_80A21D1C(this); + func_80A22628(this); + sp24 = true; + } else if (sp28) { + func_80A22308(this); + } + + if (this->unk_17A > 0) { + this->unk_17A--; + } + + if (sp24 || sp28 || (this->unk_17A == 1)) { + func_80A21CB4(this, globalCtx); + } + + if ((this->unk_1C1 & 1) && (sp24 || sp28 || (this->dyna.actor.xzDistToPlayer > 400.0f))) { + this->unk_1C1 &= ~1; + func_800B7298(globalCtx, &this->dyna.actor, 6); + } + + func_80A21F74(this, globalCtx); +} + +void func_80A22628(ObjSkateblock* this) { + this->actionFunc = func_80A2264C; + this->unk_160 = this->dyna.actor.world.pos.y; + this->dyna.actor.velocity.y = this->dyna.actor.gravity; +} + +void func_80A2264C(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp20; + + if (func_80A21150(this) != -1) { + func_80A21CB4(this, globalCtx); + } + func_80A21CD8(this); + + sp20 = func_80A21548(this, globalCtx); + if (sp20 || ((this->unk_160 - this->dyna.actor.world.pos.y) > 300.0f)) { + if (func_800C9B40(&globalCtx->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) == 12) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = NULL; + func_80A22728(this); + return; + } + } + + if (sp20) { + func_80A22308(this); + } +} + +void func_80A22728(ObjSkateblock* this) { + this->actionFunc = func_80A2273C; +} + +void func_80A2273C(ObjSkateblock* this, GlobalContext* globalCtx) { + if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.y = (this->dyna.actor.home.pos.y - (600.0f * this->dyna.actor.scale.y)) - 10.0f; + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z; + + func_80A227A4(this); + } +} + +void func_80A227A4(ObjSkateblock* this) { + this->actionFunc = func_80A227C0; + this->unk_17A = 40; +} + +void func_80A227C0(ObjSkateblock* this, GlobalContext* globalCtx) { + if (func_80A21150(this) != -1) { + func_80A21CB4(this, globalCtx); + } + + if (this->unk_17A > 0) { + this->unk_17A--; + return; + } + + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = ObjSkateblock_Draw; + + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 1.0f)) { + func_80A22308(this); + } + + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + D_80A22A10 |= 1 << this->unk_1C0; + } +} + +void ObjSkateblock_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSkateblock* this = THIS; + + D_80A22A10 &= ~(1 << this->unk_1C0); + this->actionFunc(this, globalCtx); + this->unk_1C1 &= ~2; +} + +void ObjSkateblock_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSkateblock* this = THIS; + Color_RGB8* sp2C = &D_80A22B08[OBJSKAEBLOCK_GET_F(&this->dyna.actor)]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + AnimatedMat_DrawStep(globalCtx, D_80A22A18, 0); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0xFF, 0xFF, sp2C->r, sp2C->g, sp2C->b, 255); + gSPDisplayList(POLY_OPA_DISP++, gameplay_dangeon_keep_DL_0182A8); + + func_80A21E9C(this, globalCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h index 00f3a0f1b..c26a93844 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h @@ -7,11 +7,29 @@ struct ObjSkateblock; typedef void (*ObjSkateblockActionFunc)(struct ObjSkateblock*, GlobalContext*); +#define OBJSKAEBLOCK_GET_F(thisx) ((thisx)->params & 0xF) + +typedef struct { + /* 0x00 */ CollisionPoly* poly; + /* 0x04 */ f32 height; + /* 0x08 */ s32 bgId; +} ObjSkateblockFloor; // size = 0xC + typedef struct ObjSkateblock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjSkateblockActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x64]; + /* 0x0160 */ f32 unk_160; + /* 0x0164 */ f32 unk_164; + /* 0x0168 */ f32 unk_168; + /* 0x016C */ f32* unk_16C; + /* 0x0170 */ s16 unk_170; + /* 0x0172 */ s16 unk_172[4]; + /* 0x017A */ s16 unk_17A; + /* 0x017C */ s16 unk_17C; + /* 0x0180 */ f32 unk_180; + /* 0x0184 */ ObjSkateblockFloor unk_184[5]; + /* 0x01C0 */ u8 unk_1C0; + /* 0x01C1 */ u8 unk_1C1; } ObjSkateblock; // size = 0x1C4 extern const ActorInit Obj_Skateblock_InitVars; From 47ef03494b903ffc4b1130da833c858e90aba0d7 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Fri, 25 Mar 2022 00:49:47 +0000 Subject: [PATCH 089/257] Obj_Spinyroll (2 non-matching) (#635) * Obj_Spinyroll * syms * PR * PR * PR --- spec | 5 +- .../ovl_Obj_Spinyroll/z_obj_spinyroll.c | 676 ++++++++++++++++-- .../ovl_Obj_Spinyroll/z_obj_spinyroll.h | 48 +- undefined_syms.txt | 5 - 4 files changed, 667 insertions(+), 67 deletions(-) diff --git a/spec b/spec index a10aa74eb..a4382c1e7 100644 --- a/spec +++ b/spec @@ -2619,8 +2619,11 @@ beginseg name "ovl_Obj_Spinyroll" compress include "build/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.o" - include "build/data/ovl_Obj_Spinyroll/ovl_Obj_Spinyroll.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Spinyroll/ovl_Obj_Spinyroll_reloc.o" +#else include "build/data/ovl_Obj_Spinyroll/ovl_Obj_Spinyroll.reloc.o" +#endif endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c index 9547aa04f..20f4a1c50 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c @@ -5,6 +5,7 @@ */ #include "z_obj_spinyroll.h" +#include "objects/object_spinyroll/object_spinyroll.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,18 @@ void ObjSpinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSpinyroll_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSpinyroll_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A1E9C4(ObjSpinyroll* this); +void func_80A1E9E0(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EA4C(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EAAC(ObjSpinyroll* this); +void func_80A1EAE0(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EB40(ObjSpinyroll* this); +void func_80A1EB54(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EC24(ObjSpinyroll* this); +void func_80A1EC38(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1ECC0(ObjSpinyroll* this); +void func_80A1ECD4(ObjSpinyroll* this, GlobalContext* globalCtx); + const ActorInit Obj_Spinyroll_InitVars = { ACTOR_OBJ_SPINYROLL, ACTORCAT_PROP, @@ -28,121 +40,669 @@ const ActorInit Obj_Spinyroll_InitVars = { (ActorFunc)ObjSpinyroll_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[6] = { -static ColliderTrisElementInit D_80A1F040[6] = { +static ColliderTrisElementInit sTrisElementsInit[] = { { - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -60.0f, 0.0f, 17.0f }, { 60.0f, 0.0f, 17.0f }, { 60.0f, 40.0f, 17.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -60.0f, 0.0f, 17.0f }, { 60.0f, 40.0f, 17.0f }, { -60.0f, 40.0f, 17.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 60.0f, 0.0f, -17.0f }, { -60.0f, 0.0f, -17.0f }, { -60.0f, 40.0f, -17.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 60.0f, 0.0f, -17.0f }, { -60.0f, 40.0f, -17.0f }, { 60.0f, 40.0f, -17.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 60.0f, 20.0f, -12.0f }, { -60.0f, 20.0f, -12.0f }, { -60.0f, 20.0f, 12.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 60.0f, 20.0f, -12.0f }, { -60.0f, 20.0f, 12.0f }, { 60.0f, 20.0f, 12.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80A1F1A8 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 6, D_80A1F040, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 6, + sTrisElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A1F204[] = { +f32 D_80A1F1B8[] = { 1.0f, 2.0f, 4.0f }; + +f32 D_80A1F1C4[] = { + 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, +}; + +s16 D_80A1F1E4[] = { + 1, 10, 20, 30, 40, 50, 60, 70, +}; + +f32 D_80A1F1F4[] = { 30.0f, -30.0f }; + +f32 D_80A1F1FC[] = { 9.0f, -9.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_STOP), }; +s16 D_80A1F20C[] = { 0xFA0, -0xFA0 }; + +void func_80A1DA50(GlobalContext* globalCtx, ObjSpinyroll* this, Vec3f* arg2, Vec3f* arg3) { + Vec3f sp1C; + + Math_Vec3f_Sum(arg2, arg3, &sp1C); + Math_Vec3f_Scale(&sp1C, 0.5f); + EffectSsHitMark_SpawnFixedScale(globalCtx, 3, &sp1C); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_SHIELD_REFLECT_SW); +} + +void func_80A1DAAC(Vec3f* arg0, Vec3f* arg1, s16 arg2) { + f32 sp1C = Math_SinS(arg2); + f32 sp18 = Math_CosS(arg2); + + arg0->x = (arg1->z * sp1C) + (arg1->x * sp18); + arg0->y = arg1->y; + arg0->z = (arg1->z * sp18) - (arg1->x * sp1C); +} + +void func_80A1DB2C(Actor* thisx) { + ObjSpinyroll* this = THIS; + s32 i; + s32 j; + s32 params = OBJSPINYROLL_GET_C000(&this->dyna.actor); + Vec3f sp7C[3]; + Vec3f sp70; + f32 temp = D_80A1F1B8[params]; + ColliderTrisElementInit* ptr; + + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + for (j = 0; j < ARRAY_COUNT(sp7C); j++) { + ptr = &sTrisInit.elements[i]; + + sp70.x = ptr->dim.vtx[j].x * temp; + sp70.y = ptr->dim.vtx[j].y; + sp70.z = ptr->dim.vtx[j].z; + + func_80A1DAAC(&sp7C[j], &sp70, this->dyna.actor.shape.rot.y); + Math_Vec3f_Sum(&sp7C[j], &this->dyna.actor.world.pos, &sp7C[j]); + } + Collider_SetTrisVertices(&this->collider, i, &sp7C[0], &sp7C[1], &sp7C[2]); + } +} + +void func_80A1DC5C(ObjSpinyroll* this) { + this->unk_4D8 += 0x5DC0; + Math_StepToF(&this->unk_4D4, 0.0f, 0.32f); + this->unk_4D0 = ((Math_SinS(this->unk_4D8) + 1.0f) * this->unk_4D4) + 24.0f; +} + +void func_80A1DCCC(ObjSpinyroll* this) { + f32 phi_f2; + + if (this->dyna.actor.speedXZ > 3.0f) { + phi_f2 = 3.0f; + } else { + phi_f2 = this->dyna.actor.speedXZ; + } + + if (this->unk_4D4 < phi_f2) { + this->unk_4D4 = phi_f2; + } +} + +void func_80A1DD18(ObjSpinyroll* this) { + f32 temp_f0; + Vec3f* sp20 = &this->unk_4AC[this->unk_4A8 ^ 1]; + + Math_Vec3f_Diff(sp20, &this->dyna.actor.world.pos, &this->unk_4C4); + + temp_f0 = Math3D_Vec3fMagnitude(&this->unk_4C4); + if (temp_f0 < 0.01f) { + Math_Vec3f_Diff(sp20, &this->unk_4AC[this->unk_4A8], &this->unk_4C4); + + temp_f0 = Math3D_Vec3fMagnitude(&this->unk_4C4); + if (temp_f0 < 0.01f) { + Math_Vec3f_Copy(&this->unk_4C4, &gZeroVec3f); + return; + } + } + Math_Vec3f_Scale(&this->unk_4C4, 1.0f / temp_f0); +} + +void func_80A1DE10(ObjSpinyroll* this) { + this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &this->unk_4AC[this->unk_4A8 ^ 1]); +} + +void func_80A1DE58(ObjSpinyroll* this) { + this->unk_4A8 = 0; + func_80A1DE10(this); + func_80A1DD18(this); +} + +void func_80A1DE84(ObjSpinyroll* this) { + this->unk_4A8 ^= 1; + func_80A1DE10(this); + func_80A1DD18(this); +} + +s32 func_80A1DEB8(ObjSpinyroll* this) { + s32 pad; + s32 sp30 = this->unk_4A8 ^ 1; + Vec3f sp24; + + Math_StepToF(&this->dyna.actor.speedXZ, this->unk_4A4, this->unk_4A4 * 0.2f); + + this->dyna.actor.world.pos.x += this->dyna.actor.speedXZ * this->unk_4C4.x; + this->dyna.actor.world.pos.y += this->dyna.actor.speedXZ * this->unk_4C4.y; + this->dyna.actor.world.pos.z += this->dyna.actor.speedXZ * this->unk_4C4.z; + + Math_Vec3f_Diff(&this->unk_4AC[sp30], &this->dyna.actor.world.pos, &sp24); + + return Math3D_LengthSquared(&sp24) < (SQ(this->dyna.actor.speedXZ) + 0.05f); +} + +void func_80A1DFA0(ObjSpinyroll* this) { + f32 temp_f0; + f32 phi_f12; + s32 i; + s32 j; + f32 temp_f2; + + this->unk_3A4.unk_F4 = (s32)(D_80A1F1B8[OBJSPINYROLL_GET_C000(&this->dyna.actor)] * 120.0f * (1.0f / 58)) + 2; + + temp_f0 = (D_80A1F1B8[OBJSPINYROLL_GET_C000(&this->dyna.actor)] * 120.0f) - 2.0f; + temp_f2 = temp_f0 / (this->unk_3A4.unk_F4 - 1); + temp_f0 *= 0.5f; + + for (i = 0; i < ARRAY_COUNT(this->unk_3A4.unk_00); i++) { + for (j = 0, phi_f12 = temp_f0; j < this->unk_3A4.unk_F4; j++, phi_f12 -= temp_f2) { + this->unk_3A4.unk_00[i].unk_00[j].unk_00 = phi_f12; + } + } +} + +#ifdef NON_MATCHING +// globalCtx not in s reg, something with ptr->unk_F0 = temp_s1; line +s32 func_80A1E074(ObjSpinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3) { + s32 i; + s32 j; + ObjSpinyrollStruct2* ptr = &this->unk_3A4; + f32 temp_f0; + f32 temp_f20; + Vec3f spC8; + Vec3f spBC; + Vec3f spB0; + ObjSpinyrollStruct* temp_s1; + f32 temp_f22; + f32 temp_f24; + f32 temp; + s32 sp98; + + spC8.y = this->dyna.actor.world.pos.y + 10.0f; + spBC.y = spC8.y; + sp98 = false; + temp_f20 = FLT_MAX; + ptr->unk_F0 = NULL; + + for (i = 0; i < ARRAY_COUNT(this->unk_3A4.unk_00); i++) { + temp = D_80A1F1F4[i]; + temp_f22 = temp * this->unk_4C4.x; + temp_f24 = temp * this->unk_4C4.z; + temp_s1 = &ptr->unk_00[i]; + + for (j = 0; j < ptr->unk_F4; j++) { + spC8.x = + (temp_s1->unk_00[j].unk_00 * Math_CosS(this->dyna.actor.world.rot.y)) + this->dyna.actor.world.pos.x; + spC8.z = + (temp_s1->unk_00[j].unk_00 * -Math_SinS(this->dyna.actor.world.rot.y)) + this->dyna.actor.world.pos.z; + + spBC.x = temp_f22 + spC8.x; + spBC.z = temp_f24 + spC8.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spC8, &spBC, &spB0, &temp_s1->unk_00[j].unk_04, 1, 0, 0, 1, + &temp_s1->unk_00[j].bgId, &this->dyna.actor, 0.0f)) { + if (arg3 && (this->dyna.actor.flags & ACTOR_FLAG_40)) { + func_80A1DA50(globalCtx, this, &spC8, &spB0); + } + + temp_f0 = Math3D_Vec3fDistSq(&spC8, &spB0); + if (temp_f0 < temp_f20) { + temp_f20 = temp_f0; + sp98 = true; + Math_Vec3f_Diff(&spB0, &spBC, arg2); + ptr->unk_F0 = temp_s1; + } + } + } + } + + return sp98; +} +#else +s32 func_80A1E074(ObjSpinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E074.s") #endif -extern ColliderTrisElementInit D_80A1F040[6]; -extern ColliderTrisInit D_80A1F1A8; -extern InitChainEntry D_80A1F204[]; +s32 func_80A1E2D8(ObjSpinyroll* this, GlobalContext* globalCtx, s32 arg2) { + Vec3f sp1C; -extern UNK_TYPE D_06000460; -extern UNK_TYPE D_06000E68; + if (func_80A1E074(this, globalCtx, &sp1C, arg2)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DA50.s") +s32 func_80A1E334(CollisionContext* colCtx, f32* arg1, CollisionPoly** polyOut, s32* bgId, Vec3f* arg4, + ObjSpinyroll* this) { + f32 temp_f0 = BgCheck_EntityRaycastFloor5(colCtx, polyOut, bgId, &this->dyna.actor, arg4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DAAC.s") + *arg1 = temp_f0; + return *arg1 > (BGCHECK_Y_MIN + 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DB2C.s") +s32 func_80A1E394(CollisionContext* colCtx, f32* arg1, CollisionPoly** polyOut, s32* bgId, Vec3f* arg4, + ObjSpinyroll* this) { + return BgCheck_EntityCheckCeiling(colCtx, arg1, arg4, 24.0f, polyOut, bgId, &this->dyna.actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DC5C.s") +#ifdef NON_MATCHING +s32 func_80A1E3D8(ObjSpinyroll* this, GlobalContext* globalCtx, f32* arg2, s32 arg3) { + f32 temp_f20; + ObjSpinyrollStruct2* spC8; + f32 phi_f22; + ObjSpinyrollColFunc spC0; + s32 i; + s32 j; + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + ObjSpinyrollStruct* temp_s0; + f32 phi_f26; + s32 sp84; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DCCC.s") + spC8 = &this->unk_3A4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DD18.s") + if (this->unk_4C4.y > 0.0f) { + spC0 = func_80A1E394; + phi_f26 = this->dyna.actor.world.pos.y + 48.0f; + } else { + spC0 = func_80A1E334; + phi_f26 = this->dyna.actor.world.pos.y; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DE10.s") + sp84 = false; + sp94.y = this->dyna.actor.world.pos.y + 24.0f; + phi_f22 = FLT_MAX; + spC8->unk_F0 = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DE58.s") + for (i = 0; i < ARRAY_COUNT(this->unk_3A4.unk_00); i++) { + sp94.z = D_80A1F1FC[i]; + temp_s0 = &spC8->unk_00[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DE84.s") + for (j = 0; j < spC8->unk_F4; j++) { + sp94.x = temp_s0->unk_00[j].unk_00; + func_80A1DAAC(&spAC, &sp94, this->dyna.actor.world.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DEB8.s") + spAC.x += this->dyna.actor.world.pos.x; + spAC.z += this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DFA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E074.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E2D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E334.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E394.s") + if (spC0(&globalCtx->colCtx, &spA0.y, &temp_s0->unk_00[j].unk_04, &temp_s0->unk_00[j].bgId, &spAC, this)) { + temp_f20 = fabsf(spA0.y - spAC.y); + if (temp_f20 <= 24.0f) { + if (arg3 && (this->dyna.actor.flags & ACTOR_FLAG_40)) { + spA0.x = spAC.x; + spA0.z = spAC.z; + func_80A1DA50(globalCtx, this, &spAC, &spA0); + } + if (temp_f20 < phi_f22) { + sp84 = true; + *arg2 = spA0.y - phi_f26; + phi_f22 = temp_f20; + spC8->unk_F0 = temp_s0; + } + } + } + } + } + return sp84; +} +#else +s32 func_80A1E3D8(ObjSpinyroll* this, GlobalContext* globalCtx, f32* arg2, s32 arg3); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E3D8.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E648.s") +s32 func_80A1E648(ObjSpinyroll* this, GlobalContext* globalCtx, s32 arg2) { + f32 sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E694.s") + if (func_80A1E3D8(this, globalCtx, &sp1C, arg2)) { + this->dyna.actor.world.pos.y += sp1C; + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E6D4.s") +DynaPolyActor* func_80A1E694(ObjSpinyroll* this, GlobalContext* globalCtx) { + if (this->unk_3A4.unk_F0 != NULL) { + return DynaPoly_GetActor(&globalCtx->colCtx, this->unk_3A4.unk_F0->unk_00[0].bgId); + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/ObjSpinyroll_Init.s") +s32 func_80A1E6D4(ObjSpinyroll* this, GlobalContext* globalCtx) { + DynaPolyActor* temp_v0 = func_80A1E694(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/ObjSpinyroll_Destroy.s") + if ((temp_v0 != NULL) && (Math3D_Vec3fDistSq(&temp_v0->actor.world.pos, &temp_v0->actor.prevPos) > SQ(0.01f))) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E9C4.s") +void ObjSpinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSpinyroll* this = THIS; + f32 sp44; + Path* path; + s32 pad2; + Vec3s* points; + Vec3s* sp34; + Vec3s* sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E9E0.s") + sp44 = D_80A1F1B8[OBJSPINYROLL_GET_C000(&this->dyna.actor)]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.world.rot.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EA10.s") + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EA4C.s") + this->dyna.actor.scale.x = 0.1f * sp44; + this->dyna.actor.scale.y = 0.1f; + this->dyna.actor.scale.z = 0.1f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EAAC.s") + this->dyna.actor.uncullZoneScale = 250.0f * sp44; + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spinyroll_Colheader_000E68); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EAE0.s") + Collider_InitTris(globalCtx, &this->collider); + Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit, this->colliderElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EB40.s") + if (OBJSPINYROLL_GET_7F(&this->dyna.actor) == OBJSPINYROLL_GET_7F_7F) { + func_80A1E9C4(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EB54.s") + this->dyna.actor.world.rot.y = 0; + func_80A1DFA0(this); + this->unk_4A4 = D_80A1F1C4[OBJSPINYROLL_GET_380(thisx)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EC24.s") + path = &globalCtx->setupPathList[OBJSPINYROLL_GET_7F(&this->dyna.actor)]; + points = Lib_SegmentedToVirtual(path->points); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EC38.s") + sp34 = &points[0]; + sp30 = &points[1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1ECC0.s") + Math_Vec3s_ToVec3f(&this->unk_4AC[0], sp34); + Math_Vec3s_ToVec3f(&this->unk_4AC[1], sp30); + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->unk_4AC[0]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1ECD4.s") + if ((sp34->x == sp30->x) && (sp34->y != sp30->y) && (sp34->z == sp30->z)) { + this->unk_49C = true; + } else if (((sp34->x != sp30->x) && (sp34->y == sp30->y) && (sp34->z == sp30->z)) || + ((sp34->x == sp30->x) && (sp34->y == sp30->y) && (sp34->z != sp30->z))) { + this->unk_49C = false; + } else { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/ObjSpinyroll_Update.s") + func_80A1DE58(this); + this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; + func_80A1EAAC(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/ObjSpinyroll_Draw.s") +void ObjSpinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSpinyroll* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(globalCtx, &this->collider); +} + +void func_80A1E9C4(ObjSpinyroll* this) { + this->dyna.actor.speedXZ = 0.0f; + this->actionFunc = func_80A1E9E0; +} + +void func_80A1E9E0(ObjSpinyroll* this, GlobalContext* globalCtx) { + this->unk_4DA += 0x6E; + if (this->unk_4DA > 0xFA0) { + this->unk_4DA = 0xFA0; + } +} + +void func_80A1EA10(ObjSpinyroll* this) { + this->actionFunc = func_80A1EA4C; + this->unk_4E2 = D_80A1F1E4[OBJSPINYROLL_GET_1C00(&this->dyna.actor)]; + this->dyna.actor.speedXZ = 0.0f; +} + +void func_80A1EA4C(ObjSpinyroll* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->unk_4DA, 0, this->unk_4DE)) { + if (this->unk_4E2 > 0) { + this->unk_4E2--; + if (this->unk_4E2 <= 0) { + func_80A1EAAC(this); + } + } + } +} + +void func_80A1EAAC(ObjSpinyroll* this) { + this->actionFunc = func_80A1EAE0; + this->unk_4DC = D_80A1F20C[this->unk_4A8]; + this->dyna.actor.speedXZ = 0.0f; +} + +void func_80A1EAE0(ObjSpinyroll* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->unk_4DA, this->unk_4DC, 0x6E)) { + if (!this->unk_49C) { + func_80A1EB40(this); + } else { + func_80A1ECC0(this); + } + } +} + +void func_80A1EB40(ObjSpinyroll* this) { + this->actionFunc = func_80A1EB54; +} + +void func_80A1EB54(ObjSpinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = func_80A1DEB8(this); + + if (func_80A1E2D8(this, globalCtx, 1)) { + if (func_80A1E694(this, globalCtx) != NULL) { + func_80A1DCCC(this); + this->unk_4DE = 0x7D0; + func_80A1EC24(this); + } else { + func_80A1DE84(this); + func_80A1DCCC(this); + this->unk_4DE = 0x7D0; + func_80A1EA10(this); + } + } else if (sp24 != 0) { + func_80A1DE84(this); + func_80A1DCCC(this); + this->unk_4DE = 0x78; + func_80A1EA10(this); + } +} + +void func_80A1EC24(ObjSpinyroll* this) { + this->actionFunc = func_80A1EC38; +} + +void func_80A1EC38(ObjSpinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = true; + + Math_ScaledStepToS(&this->unk_4DA, 0, this->unk_4DE); + + if (func_80A1E2D8(this, globalCtx, 0) && func_80A1E6D4(this, globalCtx)) { + sp24 = false; + } + + if (sp24) { + func_80A1DE84(this); + func_80A1EA10(this); + } +} + +void func_80A1ECC0(ObjSpinyroll* this) { + this->actionFunc = func_80A1ECD4; +} + +void func_80A1ECD4(ObjSpinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = func_80A1DEB8(this); + + if (func_80A1E648(this, globalCtx, 1)) { + func_80A1DE84(this); + func_80A1DCCC(this); + this->unk_4DE = 0x7D0; + func_80A1EA10(this); + } else if (sp24) { + func_80A1DE84(this); + func_80A1DCCC(this); + this->unk_4DE = 0x78; + func_80A1EA10(this); + } +} + +void ObjSpinyroll_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjSpinyroll* this = THIS; + + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + func_80A1DCCC(this); + } + + this->actionFunc(this, globalCtx); + + this->unk_4E0 += this->unk_4DA; + func_80A1DC5C(this); + func_80A1DB2C(thisx); + + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjSpinyroll_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjSpinyroll* this = THIS; + f32 temp_f26; + f32 temp_f28; + s32 temp_s1 = OBJSPINYROLL_GET_C000(&this->dyna.actor); + s32 phi_s4; + f32 phi_f22; + f32 phi_f24; + s32 i; + f32 temp_f30; + Vec3s sp84; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + temp_f26 = Math_CosS(this->dyna.actor.shape.rot.y) * 120.0f; + temp_f28 = Math_SinS(this->dyna.actor.shape.rot.y) * -120.0f; + temp_f30 = this->dyna.actor.world.pos.y + this->unk_4D0; + + if (temp_s1 == OBJSPINYROLL_GET_C000_0) { + phi_s4 = 1; + phi_f22 = this->dyna.actor.world.pos.x; + phi_f24 = this->dyna.actor.world.pos.z; + } else if (temp_s1 == OBJSPINYROLL_GET_C000_1) { + phi_s4 = 2; + phi_f22 = this->dyna.actor.world.pos.x - (temp_f26 * 0.5f); + phi_f24 = this->dyna.actor.world.pos.z - (temp_f28 * 0.5f); + } else { + phi_s4 = 4; + phi_f22 = this->dyna.actor.world.pos.x - (temp_f26 * 1.5f); + phi_f24 = this->dyna.actor.world.pos.z - (temp_f28 * 1.5f); + } + + sp84.x = this->dyna.actor.shape.rot.x + this->unk_4E0; + sp84.y = this->dyna.actor.shape.rot.y; + sp84.z = this->dyna.actor.shape.rot.z; + + for (i = 0; i < phi_s4; i++) { + Matrix_SetStateRotationAndTranslation(phi_f22, temp_f30, phi_f24, &sp84); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_spinyroll_DL_000460); + + phi_f22 += temp_f26; + phi_f24 += temp_f28; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h index b06064316..b35627b13 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h @@ -6,12 +6,54 @@ struct ObjSpinyroll; typedef void (*ObjSpinyrollActionFunc)(struct ObjSpinyroll*, GlobalContext*); +typedef s32 (*ObjSpinyrollColFunc)(CollisionContext*, f32*, CollisionPoly**, s32*, Vec3f*, struct ObjSpinyroll*); + +#define OBJSPINYROLL_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJSPINYROLL_GET_380(thisx) (((thisx)->params >> 7) & 7) +#define OBJSPINYROLL_GET_1C00(thisx) (((thisx)->params >> 0xA) & 7) +#define OBJSPINYROLL_GET_C000(thisx) (((thisx)->params >> 0xE) & 3) + +#define OBJSPINYROLL_GET_7F_7F 0x7F +#define OBJSPINYROLL_GET_C000_0 0 +#define OBJSPINYROLL_GET_C000_1 1 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ CollisionPoly* unk_04; + /* 0x08 */ s32 bgId; +} ObjSpinyrollSubStruct; // size = 0xC + +typedef struct { + /* 0x00 */ ObjSpinyrollSubStruct unk_00[10]; +} ObjSpinyrollStruct; // size = 0x78 + +typedef struct { + /* 0x00 */ ObjSpinyrollStruct unk_00[2]; + /* 0xF0 */ ObjSpinyrollStruct* unk_F0; + /* 0xF4 */ s32 unk_F4; +} ObjSpinyrollStruct2; // size = 0xF8? typedef struct ObjSpinyroll { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x35C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderTris collider; + /* 0x017C */ ColliderTrisElement colliderElements[6]; + /* 0x03A4 */ ObjSpinyrollStruct2 unk_3A4; + ///* 0x0494 */ ObjSpinyrollStruct* unk_494; // alternative testing + ///* 0x0498 */ s32 unk_498; + /* 0x049C */ s32 unk_49C; /* 0x04A0 */ ObjSpinyrollActionFunc actionFunc; - /* 0x04A4 */ char unk_4A4[0x40]; + /* 0x04A4 */ f32 unk_4A4; + /* 0x04A8 */ s32 unk_4A8; + /* 0x04AC */ Vec3f unk_4AC[2]; + /* 0x04C4 */ Vec3f unk_4C4; + /* 0x04D0 */ f32 unk_4D0; + /* 0x04D4 */ f32 unk_4D4; + /* 0x04D8 */ s16 unk_4D8; + /* 0x04DA */ s16 unk_4DA; + /* 0x04DC */ s16 unk_4DC; + /* 0x04DE */ s16 unk_4DE; + /* 0x04E0 */ s16 unk_4E0; + /* 0x04E2 */ s16 unk_4E2; } ObjSpinyroll; // size = 0x4E4 extern const ActorInit Obj_Spinyroll_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index da4bdabc4..836f19572 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1974,11 +1974,6 @@ D_060011E0 = 0x060011E0; D_06001C00 = 0x06001C00; -// ovl_Obj_Spinyroll - -D_06000460 = 0x06000460; -D_06000E68 = 0x06000E68; - // ovl_Obj_Takaraya_Wall D_06000B70 = 0x06000B70; From 7ee4615cd02b85c110f67b9ddfa7984686000de0 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Fri, 25 Mar 2022 00:56:51 +0000 Subject: [PATCH 090/257] Obj_Spidertent (1 non-matching) (#639) * Obj_Spidertent * Match func_80B2FC98 (thanks Anon58) * PR * Fix * PR * PR --- spec | 5 +- .../ovl_Obj_Spidertent/z_obj_spidertent.c | 818 ++++++++++++++++-- .../ovl_Obj_Spidertent/z_obj_spidertent.h | 18 +- tools/disasm/variables.txt | 5 +- 4 files changed, 769 insertions(+), 77 deletions(-) diff --git a/spec b/spec index a4382c1e7..d8fdc7387 100644 --- a/spec +++ b/spec @@ -3973,8 +3973,11 @@ beginseg name "ovl_Obj_Spidertent" compress include "build/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.o" - include "build/data/ovl_Obj_Spidertent/ovl_Obj_Spidertent.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Spidertent/ovl_Obj_Spidertent_reloc.o" +#else include "build/data/ovl_Obj_Spidertent/ovl_Obj_Spidertent.reloc.o" +#endif endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c index 20e262298..1bc0f57b2 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c @@ -5,6 +5,7 @@ */ #include "z_obj_spidertent.h" +#include "objects/object_spidertent/object_spidertent.h" #define FLAGS (ACTOR_FLAG_10000000) @@ -15,7 +16,13 @@ void ObjSpidertent_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSpidertent_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSpidertent_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B307E0(ObjSpidertent* this); +void func_80B30808(ObjSpidertent* this, GlobalContext* globalCtx); +void func_80B30A2C(ObjSpidertent* this); +void func_80B30A4C(ObjSpidertent* this, GlobalContext* globalCtx); +void func_80B30AD4(ObjSpidertent* this); +void func_80B30AF8(ObjSpidertent* this, GlobalContext* globalCtx); + const ActorInit Obj_Spidertent_InitVars = { ACTOR_OBJ_SPIDERTENT, ACTORCAT_BG, @@ -28,118 +35,789 @@ const ActorInit Obj_Spidertent_InitVars = { (ActorFunc)ObjSpidertent_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[6] = { -static ColliderTrisElementInit D_80B31060[6] = { +static ColliderTrisElementInit sTrisElementsInit1[] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 68.80000305175781f, 0.0f, 18.799999237060547f }, { 76.30000305175781f, 0.0f, -63.79999923706055f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 68.80000305175781f, 0.0f, 18.799999237060547f }, + { 76.30000305175781f, 0.0f, -63.79999923706055f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 76.30000305175781f, 0.0f, -63.79999923706055f }, { 23.799999237060547f, 0.0f, -116.30000305175781f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 76.30000305175781f, 0.0f, -63.79999923706055f }, + { 23.799999237060547f, 0.0f, -116.30000305175781f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 23.799999237060547f, 0.0f, -116.30000305175781f }, { -111.30000305175781f, 0.0f, -26.299999237060547f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 23.799999237060547f, 0.0f, -116.30000305175781f }, + { -111.30000305175781f, 0.0f, -26.299999237060547f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -111.30000305175781f, 0.0f, -26.299999237060547f }, { -81.30000305175781f, 0.0f, 78.80000305175781f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -111.30000305175781f, 0.0f, -26.299999237060547f }, + { -81.30000305175781f, 0.0f, 78.80000305175781f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -81.30000305175781f, 0.0f, 78.80000305175781f }, { 23.799999237060547f, 0.0f, 108.80000305175781f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -81.30000305175781f, 0.0f, 78.80000305175781f }, + { 23.799999237060547f, 0.0f, 108.80000305175781f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 23.799999237060547f, 0.0f, 108.80000305175781f }, { 68.80000305175781f, 0.0f, 18.799999237060547f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 23.799999237060547f, 0.0f, 108.80000305175781f }, + { 68.80000305175781f, 0.0f, 18.799999237060547f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B311C8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 6, D_80B31060, // sTrisElementsInit, +static ColliderTrisInit sTrisInit1 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 6, + sTrisElementsInit1, }; -// static ColliderTrisElementInit sTrisElementsInit[6] = { -static ColliderTrisElementInit D_80B311D8[6] = { +static ColliderTrisElementInit sTrisElementsInit2[] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 17.799999237060547f, 0.0f, 81.5999984741211f }, { 51.599998474121094f, 0.0f, 14.100000381469727f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 17.799999237060547f, 0.0f, 81.5999984741211f }, + { 51.599998474121094f, 0.0f, 14.100000381469727f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -60.900001525878906f, 0.0f, 59.099998474121094f }, { 17.799999237060547f, 0.0f, 81.5999984741211f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -60.900001525878906f, 0.0f, 59.099998474121094f }, + { 17.799999237060547f, 0.0f, 81.5999984741211f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -83.4000015258789f, 0.0f, -19.700000762939453f }, { -60.900001525878906f, 0.0f, 59.099998474121094f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -83.4000015258789f, 0.0f, -19.700000762939453f }, + { -60.900001525878906f, 0.0f, 59.099998474121094f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 17.799999237060547f, 0.0f, -87.19999694824219f }, { -83.4000015258789f, 0.0f, -19.700000762939453f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 17.799999237060547f, 0.0f, -87.19999694824219f }, + { -83.4000015258789f, 0.0f, -19.700000762939453f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 57.20000076293945f, 0.0f, -47.79999923706055f }, { 17.799999237060547f, 0.0f, -87.19999694824219f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 57.20000076293945f, 0.0f, -47.79999923706055f }, + { 17.799999237060547f, 0.0f, -87.19999694824219f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 51.599998474121094f, 0.0f, 14.100000381469727f }, { 57.20000076293945f, 0.0f, -47.79999923706055f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 51.599998474121094f, 0.0f, 14.100000381469727f }, + { 57.20000076293945f, 0.0f, -47.79999923706055f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B31340 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 6, D_80B311D8, // sTrisElementsInit, +static ColliderTrisInit sTrisInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 6, + sTrisElementsInit2, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B31418[] = { +typedef struct { + /* 0x00 */ Gfx* unk_00; + /* 0x04 */ CollisionHeader* unk_04; + /* 0x08 */ ColliderTrisInit* unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ f32 unk_20; + /* 0x24 */ f32 unk_24; +} ObjSpidertentStruct; + +ObjSpidertentStruct D_80B31350[] = { + { + object_spidertent_DL_000070, + &object_spidertent_Colheader_0011AC, + &sTrisInit1, + 0.9f, + 1.3f, + 40.0f, + -3.8f, + SQ(120.0f), + 240.0f, + 200.0f, + }, + { + object_spidertent_DL_001250, + &object_spidertent_Colheader_00238C, + &sTrisInit2, + 0.9f, + 0.9f, + 30.0f, + -2.8f, + SQ(88.0f), + 176.0f, + 168.0f, + }, +}; + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ s8 unk_0E; + /* 0x0F */ s8 unk_0F; + /* 0x10 */ Color_RGBA8 unk_10; + /* 0x14 */ Color_RGBA8 unk_14; +} ObjSpidertentStruct2; + +ObjSpidertentStruct2 D_80B313A0[] = { + { + -20.0f, + 6.0f, + 0.0f, + 100, + 14, + 5, + { 255, 255, 160, 160 }, + { 255, 0, 0, 0 }, + }, + { + 0.0f, + 4.0f, + 1.2f, + 80, + 9, + 3, + { 255, 255, 160, 120 }, + { 255, 0, 0, 0 }, + }, + { + 0.0f, + 4.2f, + 0.3f, + 70, + 12, + 2, + { 255, 255, 160, 100 }, + { 55, 0, 0, 0 }, + }, + { + 0.0f, + 3.0f, + 0.0f, + 20, + 6, + 2, + { 255, 100, 20, 80 }, + { 255, 0, 0, 0 }, + }, +}; + +Vec3f D_80B31400 = { 1.0f, 0.0f, 0.0f }; +Vec3f D_80B3140C = { 0.0f, 1.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; +s32 func_80B2FB10(Vec3f* arg0, Vec3f* arg1) { + f32 temp_f0 = Math3D_LengthSquared(arg0); + f32 temp_f2; + + if (temp_f0 < 9.999999e-9f) { + return false; + } + temp_f2 = 1.0f / sqrtf(temp_f0); + arg1->x = arg0->x * temp_f2; + arg1->y = arg0->y * temp_f2; + arg1->z = arg0->z * temp_f2; + return true; +} + +s32 func_80B2FB94(Vec3f* arg0, f32 arg1, TriNorm* triNorm, Vec3f* arg3, f32* arg4) { + f32 temp_f0; + f32 temp_f0_2; + f32 temp_f16; + Vec3f sp48; + Vec3f sp3C; + f32 temp_f2; + f32 temp_f2_2; + + temp_f0 = triNorm->plane.normal.x * arg1; + temp_f2 = triNorm->plane.normal.y * arg1; + temp_f16 = triNorm->plane.normal.z * arg1; + + sp48.x = arg0->x + temp_f0; + sp48.y = arg0->y + temp_f2; + sp48.z = arg0->z + temp_f16; + + sp3C.x = arg0->x - temp_f0; + sp3C.y = arg0->y - temp_f2; + sp3C.z = arg0->z - temp_f16; + + if (Math3D_LineSegVsPlane(triNorm->plane.normal.x, triNorm->plane.normal.y, triNorm->plane.normal.z, + triNorm->plane.originDist, &sp48, &sp3C, arg3, 0)) { + temp_f0_2 = Math3D_Vec3fDistSq(arg0, arg3); + temp_f2_2 = SQ(arg1) - temp_f0_2; + if (SQ(arg1) < temp_f0_2) { + return false; + } + *arg4 = sqrtf(temp_f2_2); + return true; + } + return false; +} + +s32 func_80B2FC98(TriNorm* triNorm, Vec3f* arg1) { + Vec3f sp84; + Vec3f sp78; + Vec3f* vtx; + Vec3f* vtx2; + Vec3f sp4C[3]; + s32 i; + + if (triNorm->plane.normal.x > 0.5f) { + vtx = &triNorm->vtx[0]; + vtx2 = &triNorm->vtx[2]; + + for (i = 0; i < ARRAY_COUNT(sp4C); i++, vtx = &triNorm->vtx[i]) { + sp84.x = 0.0f; + sp84.y = vtx->y - arg1->y; + sp84.z = vtx->z - arg1->z; + + sp78.x = 0.0f; + sp78.y = vtx2->y - arg1->y; + sp78.z = vtx2->z - arg1->z; + + Math3D_CrossProduct(&sp84, &sp78, &sp4C[i]); + + vtx2 = vtx; + } + + return ((sp4C[0].x >= 0.0f) && (sp4C[1].x >= 0.0f) && (sp4C[2].x >= 0.0f)) || + ((sp4C[0].x < 0.0f) && (sp4C[1].x < 0.0f) && (sp4C[2].x < 0.0f)); + } else if (triNorm->plane.normal.y > 0.5f) { + vtx = &triNorm->vtx[0]; + vtx2 = &triNorm->vtx[2]; + + for (i = 0; i < ARRAY_COUNT(sp4C); i++, vtx = &triNorm->vtx[i]) { + sp84.x = vtx->x - arg1->x; + sp84.y = 0.0f; + sp84.z = vtx->z - arg1->z; + + sp78.x = vtx2->x - arg1->x; + sp78.y = 0.0f; + sp78.z = vtx2->z - arg1->z; + + Math3D_CrossProduct(&sp84, &sp78, &sp4C[i]); + + vtx2 = vtx; + } + + return ((sp4C[0].y >= 0.0f) && (sp4C[1].y >= 0.0f) && (sp4C[2].y >= 0.0f)) || + ((sp4C[0].y < 0.0f) && (sp4C[1].y < 0.0f) && (sp4C[2].y < 0.0f)); + } else { + vtx = &triNorm->vtx[0]; + vtx2 = &triNorm->vtx[2]; + + for (i = 0; i < ARRAY_COUNT(sp4C); i++, vtx = &triNorm->vtx[i]) { + sp84.x = vtx->x - arg1->x; + sp84.y = vtx->y - arg1->y; + sp84.z = 0.0f; + + sp78.x = vtx2->x - arg1->x; + sp78.y = vtx2->y - arg1->y; + sp78.z = 0.0f; + + Math3D_CrossProduct(&sp84, &sp78, &sp4C[i]); + + vtx2 = vtx; + } + + return ((sp4C[0].z >= 0.0f) && (sp4C[1].z >= 0.0f) && (sp4C[2].z >= 0.0f)) || + ((sp4C[0].z < 0.0f) && (sp4C[1].z < 0.0f) && (sp4C[2].z < 0.0f)); + } +} + +void func_80B300F4(ObjSpidertent* thisx, GlobalContext* globalCtx, TriNorm* triNorm, Vec3f* arg3, f32 arg4, s32 arg5) { + ObjSpidertent* this = THIS; + ObjSpidertentStruct* spE0 = &D_80B31350[OBJSPIDERTENT_GET_1(&this->dyna.actor)]; + f32 temp_f24; + f32 phi_f22; + s32 i; + f32 temp_f0; + Vec3f spC4; + Vec3f spB8; + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + Vec3f sp88; + f32 temp_f2; + ObjSpidertentStruct2* sp80 = &D_80B313A0[arg5]; + + spAC.x = triNorm->plane.normal.x; + spAC.y = triNorm->plane.normal.y; + spAC.z = triNorm->plane.normal.z; + + if (triNorm->plane.normal.y < 0.5f) { + Math3D_CrossProduct(&spAC, &D_80B3140C, &sp88); + } else { + Math3D_CrossProduct(&spAC, &D_80B31400, &sp88); + } + + if (func_80B2FB10(&sp88, &spA0)) { + phi_f22 = 0.0f; + temp_f24 = (2 * M_PI) / sp80->unk_0F; + + for (i = 0; i < sp80->unk_0F; i++) { + temp_f2 = (Rand_ZeroOne() * temp_f24) + phi_f22; + Matrix_InsertRotationAroundUnitVector_f(temp_f2, &spAC, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&spA0, &sp94); + + if (arg5 == 0) { + spC4.x = (sp94.x * arg4) + arg3->x; + spC4.y = (sp94.y * arg4) + arg3->y; + spC4.z = (sp94.z * arg4) + arg3->z; + } else { + temp_f0 = Rand_ZeroOne(); + temp_f0 = (1.0f - SQ(temp_f0)) * arg4; + spC4.x = (sp94.x * temp_f0) + arg3->x; + spC4.y = (sp94.y * temp_f0) + arg3->y; + spC4.z = (sp94.z * temp_f0) + arg3->z; + } + + if ((Math3D_Vec3fDistSq(&spC4, &this->dyna.actor.world.pos) < spE0->unk_1C) && + func_80B2FC98(triNorm, &spC4)) { + spB8.x = sp80->unk_08 * sp94.x; + spB8.y = sp80->unk_08 * sp94.y; + spB8.z = sp80->unk_08 * sp94.z; + + EffectSsDeadDb_Spawn(globalCtx, &spC4, &spB8, &gZeroVec3f, &sp80->unk_10, &sp80->unk_14, sp80->unk_0C, + 0, sp80->unk_0E); + } + + phi_f22 += temp_f24; + } + } +} + +void func_80B30410(ObjSpidertent* this, Vec3f* arg1) { + s32 i; + + Math_Vec3f_Copy(&this->unk_3A4, arg1); + this->unk_3C2 = 255; + this->unk_3C3 = 255; + this->unk_3C4 = 255; + this->unk_3C5 = 255; + for (i = 0; i < ARRAY_COUNT(D_80B313A0); i++) { + this->unk_3B0[i] = D_80B313A0[i].unk_00; + } + this->unk_3C0 = 0; +} + +s32 func_80B30480(ObjSpidertent* this, GlobalContext* globalCtx, Vec3f* arg2) { + Player* player = GET_PLAYER(globalCtx); + TriNorm* triNorm; + s32 i; + Vec3f sp58; + f32 sp54; + + if (player->itemActionParam == 7) { + if (player->unk_B28 > 0) { + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + triNorm = &this->collider.elements[i].dim; + + if (func_80B2FB94(&player->swordInfo[0].tip, 6.0f, triNorm, &sp58, &sp54) && + func_80B2FC98(triNorm, &sp58)) { + break; + } + } + + if (i < ARRAY_COUNT(this->colliderElements)) { + Math_Vec3f_Copy(arg2, &player->swordInfo[0].tip); + return true; + } + } + } + return false; +} + +void ObjSpidertent_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSpidertent* this = THIS; + s32 temp_s1 = OBJSPIDERTENT_GET_1(&this->dyna.actor); + ObjSpidertentStruct* ptr = &D_80B31350[temp_s1]; + ColliderTrisElementInit* element; + Vec3f sp70[3]; + Vec3f sp64; + s32 i, j; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + Collider_InitTris(globalCtx, &this->collider); + + if (Flags_GetSwitch(globalCtx, OBJSPIDERTENT_GET_7F00(&this->dyna.actor))) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, ptr->unk_04); + Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, D_80B31350[temp_s1].unk_08, this->colliderElements); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + + sp64.x = ptr->unk_10 * 1.2f; + sp64.y = ptr->unk_10 * 1.2f; + sp64.z = ptr->unk_10 * 1.2f; + + Matrix_MultiplyVector3fByState(&sp64, &this->dyna.actor.focus.pos); + Matrix_InsertTranslation(ptr->unk_10, ptr->unk_14 + 5.0f, ptr->unk_18, MTXMODE_APPLY); + Matrix_Scale(ptr->unk_0C, ptr->unk_0C, ptr->unk_0C, MTXMODE_APPLY); + Matrix_InsertTranslation(-ptr->unk_10, -ptr->unk_14, -ptr->unk_18, MTXMODE_APPLY); + + for (i = 0; i < 6; i++) { + element = &ptr->unk_08->elements[i]; + + for (j = 0; j < ARRAY_COUNT(sp70); j++) { + Matrix_MultiplyVector3fByState(&element->dim.vtx[j], &sp70[j]); + } + + Collider_SetTrisVertices(&this->collider, i, &sp70[0], &sp70[1], &sp70[2]); + } + + func_80B307E0(this); +} + +void ObjSpidertent_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSpidertent* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(globalCtx, &this->collider); +} + +void func_80B307E0(ObjSpidertent* this) { + this->unk_3C2 = 255; + this->unk_3C3 = 255; + this->unk_3C4 = 255; + this->unk_3C5 = 255; + this->actionFunc = func_80B30808; +} + +void func_80B30808(ObjSpidertent* this, GlobalContext* globalCtx) { + s32 phi_s4; + s32 i; + ObjSpidertentStruct* ptr2 = &D_80B31350[OBJSPIDERTENT_GET_1(&this->dyna.actor)]; + Vec3f sp70; + Vec3s* hitPos; + ColliderTrisElement* ptr; + f32 temp_f0; + s32 phi_s1; + Vec3f sp54; + f32 phi_f20; + s32 phi_s0 = false; + + if (this->collider.base.acFlags & AC_HIT) { + Player* player = GET_PLAYER(globalCtx); + + this->collider.base.acFlags &= ~AC_HIT; + phi_s1 = 0; + phi_s4 = -1; + phi_f20 = FLT_MAX; + + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + ptr = &this->collider.elements[i]; + + if (ptr->info.bumperFlags & BUMP_HIT) { + sp54.x = ptr->info.bumper.hitPos.x; + sp54.y = ptr->info.bumper.hitPos.y; + sp54.z = ptr->info.bumper.hitPos.z; + + temp_f0 = Math3D_Vec3fDistSq(&sp54, &player->actor.world.pos); + if (temp_f0 < phi_f20) { + phi_f20 = temp_f0; + phi_s4 = i; + } + } + } + + if (phi_s4 >= 0) { + hitPos = &this->collider.elements[phi_s4].info.bumper.hitPos; + + sp70.x = hitPos->x; + sp70.y = hitPos->y; + sp70.z = hitPos->z; + } else { + Math_Vec3f_Copy(&sp70, &this->dyna.actor.world.pos); + } + phi_s0 = true; + } else if ((this->dyna.actor.xzDistToPlayer < ptr2->unk_24) && func_80B30480(this, globalCtx, &sp70)) { + phi_s0 = true; + } + + if (phi_s0) { + func_80B30410(this, &sp70); + func_80B30A2C(this); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80B30A2C(ObjSpidertent* this) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + this->actionFunc = func_80B30A4C; +} + +void func_80B30A4C(ObjSpidertent* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (this->dyna.actor.cutscene >= 0) { + func_800B7298(globalCtx, &this->dyna.actor, 1); + } + Flags_SetSwitch(globalCtx, OBJSPIDERTENT_GET_7F00(&this->dyna.actor)); + func_80B30AD4(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void func_80B30AD4(ObjSpidertent* this) { + this->unk_3C1 = 80; + this->unk_3C6 = 0; + this->unk_3C7 = 0; + this->actionFunc = func_80B30AF8; +} + +#ifdef NON_MATCHING +void func_80B30AF8(ObjSpidertent* this, GlobalContext* globalCtx) { + ObjSpidertentStruct* temp_s0 = &D_80B31350[OBJSPIDERTENT_GET_1(&this->dyna.actor)]; + TriNorm* triNorm; + s32 i, j; + ObjSpidertentStruct2* ptr; + Vec3f sp60; + f32 sp5C; + + this->unk_3C6++; + + if (this->unk_3C6 < 40) { + if (this->unk_3C2 > 2) { + this->unk_3C2 -= 2; + } else { + this->unk_3C2 = 0; + } + + if (this->unk_3C3 > 5) { + this->unk_3C3 -= 5; + } else { + this->unk_3C3 = 0; + } + + if (this->unk_3C4 > 5) { + this->unk_3C4 -= 5; + } else { + this->unk_3C4 = 0; + } + + if (this->unk_3C5 > 1) { + this->unk_3C5--; + } else { + this->unk_3C5 = 0; + } + } else { + if (this->unk_3C2 > 4) { + this->unk_3C2 -= 4; + } else { + this->unk_3C2 = 0; + } + + if (this->unk_3C3 < 255) { + this->unk_3C3++; + } else { + this->unk_3C3 = 255; + } + + if (this->unk_3C4 < 255) { + this->unk_3C4++; + } else { + this->unk_3C4 = 255; + } + + if (this->unk_3C5 > 10) { + this->unk_3C5 -= 10; + } else { + this->unk_3C5 = 0; + } + } + + this->unk_3C1--; + if (this->unk_3C1 == 40) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } + + if (this->unk_3C1 >= 0x20) { + if (this->unk_3C7 > 0) { + this->unk_3C7--; + } else if (this->unk_3C1 >= 0x33) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_EXTINCT); + this->unk_3C7 = Rand_S16Offset(2, 2); + } else { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 11, NA_SE_EN_EXTINCT); + this->unk_3C7 = Rand_S16Offset(2, 4); + } + + for (j = 0; j < ARRAY_COUNT(this->unk_3B0); j++) { + this->unk_3B0[j] += D_80B313A0[j].unk_04; + if (temp_s0->unk_20 < this->unk_3B0[j]) { + this->unk_3C0 |= (1 << j); + } + } + + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + triNorm = &this->collider.elements[i].dim; + + for (j = 0; j < ARRAY_COUNT(this->unk_3B0); j++) { + if (!(this->unk_3B0[j] < 5.0f) && !(this->unk_3C0 & (1 << j)) && + func_80B2FB94(&this->unk_3A4, this->unk_3B0[j], triNorm, &sp60, &sp5C)) { + func_80B300F4(this, globalCtx, triNorm, &sp60, sp5C, j); + } + } + } + } else if (this->unk_3C1 <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30AF8.s") #endif -extern ColliderTrisElementInit D_80B31060[6]; -extern ColliderTrisInit D_80B311C8; -extern ColliderTrisElementInit D_80B311D8[6]; -extern ColliderTrisInit D_80B31340; -extern InitChainEntry D_80B31418[]; +void ObjSpidertent_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSpidertent* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B2FB10.s") + this->actionFunc(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B2FB94.s") +void ObjSpidertent_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjSpidertent* this = THIS; + s32 params = OBJSPIDERTENT_GET_1(&this->dyna.actor); + s32 temp_f18 = this->unk_3C5 * (29.0f / 51); + Gfx* gfx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B2FC98.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B300F4.s") + gfx = POLY_XLU_DISP; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30410.s") + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(gfx++, 0, 0xFF, this->unk_3C2, this->unk_3C3, this->unk_3C4, temp_f18); + gSPDisplayList(gfx++, D_80B31350[params].unk_00); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30480.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/ObjSpidertent_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/ObjSpidertent_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B307E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30808.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30A2C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30A4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30AD4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30AF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/ObjSpidertent_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/ObjSpidertent_Draw.s") + POLY_XLU_DISP = gfx; + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h index a40faa86a..9289bd365 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h @@ -7,9 +7,23 @@ struct ObjSpidertent; typedef void (*ObjSpidertentActionFunc)(struct ObjSpidertent*, GlobalContext*); +#define OBJSPIDERTENT_GET_1(thisx) ((thisx)->params & 1) +#define OBJSPIDERTENT_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) + typedef struct ObjSpidertent { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x284]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderTris collider; + /* 0x017C */ ColliderTrisElement colliderElements[6]; + /* 0x03A4 */ Vec3f unk_3A4; + /* 0x03B0 */ f32 unk_3B0[4]; + /* 0x03C0 */ u8 unk_3C0; + /* 0x03C1 */ s8 unk_3C1; + /* 0x03C2 */ u8 unk_3C2; + /* 0x03C3 */ u8 unk_3C3; + /* 0x03C4 */ u8 unk_3C4; + /* 0x03C5 */ u8 unk_3C5; + /* 0x03C6 */ s8 unk_3C6; + /* 0x03C7 */ s8 unk_3C7; /* 0x03C8 */ ObjSpidertentActionFunc actionFunc; } ObjSpidertent; // size = 0x3CC diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 07e57be02..7861cff5a 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -14200,10 +14200,7 @@ 0x80B311D8:("D_80B311D8","UNK_TYPE1","",0x1), 0x80B31340:("D_80B31340","UNK_TYPE1","",0x1), 0x80B31350:("D_80B31350","UNK_TYPE1","",0x1), - 0x80B313A0:("D_80B313A0","UNK_TYPE1","",0x18), - 0x80B313B8:("D_80B313B8","UNK_TYPE1","",0x18), - 0x80B313D0:("D_80B313D0","UNK_TYPE1","",0x18), - 0x80B313E8:("D_80B313E8","UNK_TYPE1","",0x18), + 0x80B313A0:("D_80B313A0","ObjSpidertentStruct2","[4]",0x60), 0x80B31400:("D_80B31400","UNK_TYPE1","",0x1), 0x80B3140C:("D_80B3140C","UNK_TYPE1","",0x1), 0x80B31418:("D_80B31418","UNK_TYPE1","",0x1), From f87c8290c83ac281cca196e344c8638f499ba3fa Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Fri, 25 Mar 2022 01:05:40 +0000 Subject: [PATCH 091/257] En_Tsn (#651) * En_Tsn * PR * PR * Merge --- assets/xml/objects/object_tsn.xml | 4 +- include/z64item.h | 3 +- spec | 3 +- src/overlays/actors/ovl_En_Tsn/z_en_tsn.c | 611 ++++++++++++++++++++-- src/overlays/actors/ovl_En_Tsn/z_en_tsn.h | 19 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 7 - 7 files changed, 605 insertions(+), 46 deletions(-) diff --git a/assets/xml/objects/object_tsn.xml b/assets/xml/objects/object_tsn.xml index bd83a3be5..761a6e0d7 100644 --- a/assets/xml/objects/object_tsn.xml +++ b/assets/xml/objects/object_tsn.xml @@ -26,11 +26,11 @@ - + - + diff --git a/include/z64item.h b/include/z64item.h index 0eea19008..00eb0a5a8 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -332,7 +332,8 @@ typedef enum { /* 0x8E */ GI_MASK_SCENTS, /* 0x8F */ GI_MASK_GIANT, /* 0x92 */ GI_MILK = 0x92, - /* 0x96 */ GI_MOON_TEAR = 0x96, + /* 0x95 */ GI_95 = 0x95, + /* 0x96 */ GI_MOON_TEAR, /* 0x97 */ GI_DEED_LAND, /* 0x98 */ GI_DEED_SWAMP, /* 0x99 */ GI_DEED_MOUNTAIN, diff --git a/spec b/spec index d8fdc7387..9c92116dd 100644 --- a/spec +++ b/spec @@ -3620,8 +3620,7 @@ beginseg name "ovl_En_Tsn" compress include "build/src/overlays/actors/ovl_En_Tsn/z_en_tsn.o" - include "build/data/ovl_En_Tsn/ovl_En_Tsn.data.o" - include "build/data/ovl_En_Tsn/ovl_En_Tsn.reloc.o" + include "build/src/overlays/actors/ovl_En_Tsn/ovl_En_Tsn_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c index 022aa44bc..5f0309fbb 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c @@ -5,6 +5,7 @@ */ #include "z_en_tsn.h" +#include "objects/object_tsn/object_tsn.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) @@ -15,7 +16,18 @@ void EnTsn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTsn_Update(Actor* thisx, GlobalContext* globalCtx); void EnTsn_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80AE0010(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0304(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0418(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0460(EnTsn* this, GlobalContext* globalCtx); +void func_80AE04C4(EnTsn* this, GlobalContext* globalCtx); +void func_80AE04FC(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0704(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0C88(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0D10(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0D78(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0F84(Actor* thisx, GlobalContext* globalCtx); + const ActorInit En_Tsn_InitVars = { ACTOR_EN_TSN, ACTORCAT_NPC, @@ -28,58 +40,597 @@ const ActorInit En_Tsn_InitVars = { (ActorFunc)EnTsn_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AE1190 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +Vec3f D_80AE11BC = { 0.0f, 0.0f, 0.0f }; -extern ColliderCylinderInit D_80AE1190; +TexturePtr D_80AE11C8[] = { object_tsn_Tex_0073B8, object_tsn_Tex_0085B8 }; -extern UNK_TYPE D_06001198; -extern UNK_TYPE D_060092FC; +EnTsn* func_80ADFCA0(GlobalContext* globalCtx) { + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80ADFCA0.s") + while (npc != NULL) { + if ((npc->id == ACTOR_EN_TSN) && !ENTSN_GET_100(npc)) { + return (EnTsn*)npc; + } + npc = npc->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80ADFCEC.s") + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/EnTsn_Init.s") +void func_80ADFCEC(EnTsn* this, GlobalContext* globalCtx) { + this->actionFunc = func_80AE0C88; + this->actor.update = func_80AE0F84; + this->actor.destroy = NULL; + this->actor.draw = NULL; + this->actor.targetMode = 7; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/EnTsn_Destroy.s") + switch (ENTSN_GET_F(&this->actor)) { + case ENTSN_F_0: + if (gSaveContext.weekEventReg[26] & 8) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.textId = 0x106E; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80ADFF84.s") + case ENTSN_F_1: + if (gSaveContext.weekEventReg[26] & 4) { + this->actor.textId = 0x1091; + } else { + this->actor.textId = 0x108A; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0010.s") + if (gSaveContext.weekEventReg[55] & 0x80) { + if ((ENTSN_GET_F(&this->actor)) == ENTSN_F_0) { + this->actionFunc = func_80AE0D78; + } else { + Actor_MarkForDeath(&this->actor); + } + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0304.s") + this->unk_1D8 = func_80ADFCA0(globalCtx); + this->unk_220 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0418.s") + if (this->unk_1D8 == NULL) { + Actor_MarkForDeath(&this->actor); + } else if ((ENTSN_GET_F(&this->actor)) == ENTSN_F_1) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 6); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0460.s") +void EnTsn_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTsn* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE04C4.s") + if (ENTSN_GET_100(&this->actor)) { + func_80ADFCEC(this, globalCtx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE04FC.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tsn_Skel_008AB8, &object_tsn_Anim_0092FC, NULL, NULL, 0); + Animation_PlayLoop(&this->skelAnime, &object_tsn_Anim_0092FC); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0698.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->unk_220 = 0; + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + this->actor.velocity.y = 0.0f; + this->actor.terminalVelocity = -9.0f; + this->actor.gravity = -1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0704.s") + if (gSaveContext.weekEventReg[55] & 0x80) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0C88.s") +void EnTsn_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTsn* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0D10.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0D78.s") +void func_80ADFF84(EnTsn* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/EnTsn_Update.s") + if (gSaveContext.weekEventReg[26] & 8) { + textId = 0x107E; + } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.weekEventReg[25] & 0x80) { + textId = 0x1083; + } else { + textId = 0x107F; + } + } else if (gSaveContext.weekEventReg[26] & 1) { + textId = 0x1089; + } else { + textId = 0x1084; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0F84.s") + Message_StartTextbox(globalCtx, textId, &this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0FA8.s") +void func_80AE0010(EnTsn* this, GlobalContext* globalCtx) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x107F: + case 0x1080: + case 0x1081: + case 0x1082: + case 0x1083: + case 0x1084: + case 0x1085: + case 0x1086: + case 0x1087: + case 0x1088: + case 0x1089: + case 0x1093: + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 6, 0x1838, 0x64); + this->actor.shape.rot.y = this->actor.world.rot.y; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE1024.s") + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x107F: + case 0x1081: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/EnTsn_Draw.s") + case 0x1080: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_001198, -10.0f); + break; + + case 0x1082: + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + gSaveContext.weekEventReg[25] |= 0x80; + func_801477B4(globalCtx); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + break; + + case 0x1083: + gSaveContext.weekEventReg[25] |= 0x80; + func_801477B4(globalCtx); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + break; + + case 0x1084: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_000964, -10.0f); + break; + + case 0x1085: + case 0x1086: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x1089: + case 0x1093: + gSaveContext.weekEventReg[26] |= 1; + func_801477B4(globalCtx); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + break; + + case 0x1087: + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_001198, -10.0f); + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x1088: + gSaveContext.weekEventReg[26] |= 1; + if (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA) { + func_801477B4(globalCtx); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + } else { + func_80151938(globalCtx, 0x1093); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + } + break; + + case 0x107E: + func_801477B4(globalCtx); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + break; + } + } +} + +void func_80AE0304(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80AE0010; + this->unk_220 |= 1; + if (this->actor.textId == 0) { + func_80ADFF84(this, globalCtx); + } + } else if ((this->actor.xzDistToPlayer < 150.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 160.0f); + this->unk_220 |= 1; + } else { + this->unk_220 &= ~1; + } + if (ENTSN_GET_Z(&this->actor)) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 6, 0x1838, 0x64); + } else { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.home.rot.y, 6, 0x1838, 0x64); + } + this->actor.shape.rot.y = this->actor.world.rot.y; +} + +void func_80AE0418(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + Message_StartTextbox(globalCtx, 0x107D, NULL); + Actor_MarkForDeath(&this->actor); + } +} + +void func_80AE0460(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + ENTSN_SET_Z(&this->unk_1D8->actor, false); + this->actionFunc = func_80AE0418; + } else { + Actor_PickUp(&this->actor, globalCtx, GI_95, 2000.0f, 1000.0f); + } +} + +void func_80AE04C4(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + this->actionFunc = func_80AE0C88; + } +} + +void func_80AE04FC(EnTsn* this, GlobalContext* globalCtx) { + s32 sp24; + Player* player = GET_PLAYER(globalCtx); + + if (Message_GetState(&globalCtx->msgCtx) == 0x10) { + sp24 = func_80123810(globalCtx); + if (sp24 != 0) { + gSaveContext.weekEventReg[26] |= 2; + } + + if (sp24 > 0) { + func_801477B4(globalCtx); + this->actionFunc = func_80AE0704; + if (sp24 == 19) { + if (CHECK_QUEST_ITEM(QUEST_UNK_19)) { + if (func_8013A4C4(1 | 8)) { + player->actor.textId = 0x107B; + return; + } + + if (func_8013A4C4(1 | 2 | 8)) { + player->actor.textId = 0x10A9; + return; + } + + player->actor.textId = 0x1078; + this->unk_220 |= 8; + return; + } + + player->actor.textId = 0x1078; + this->unk_220 |= 8; + return; + } + + if (sp24 == 13) { + player->actor.textId = 0x1075; + return; + } + + player->actor.textId = 0x1078; + this->unk_220 |= 8; + return; + } + + if (sp24 < 0) { + func_80151938(globalCtx, 0x1078); + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_001198, -10.0f); + this->actionFunc = func_80AE0704; + } + } +} + +void func_80AE0698(EnTsn* this, GlobalContext* globalCtx) { + func_801477B4(globalCtx); + this->actionFunc = func_80AE0C88; + this->unk_220 &= ~2; + this->actor.focus.pos = this->actor.world.pos; + ActorCutscene_Stop(this->actor.cutscene); + ENTSN_SET_Z(&this->unk_1D8->actor, false); +} + +void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad[2]; + + if ((this->unk_220 & 8) && (globalCtx->msgCtx.unk11F04 == 0x1078)) { + this->unk_220 &= ~8; + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_001198, -10.0f); + } + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 2: + break; + + case 5: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0x106E: + if (gSaveContext.weekEventReg[25] & 0x40) { + func_80151938(globalCtx, 0x1074); + } else { + func_80151938(globalCtx, 0x106F); + } + this->unk_220 |= 2; + gSaveContext.weekEventReg[25] |= 0x40; + ENTSN_SET_Z(&this->unk_1D8->actor, true); + this->unk_220 |= 4; + break; + + case 0x106F: + case 0x1070: + case 0x1071: + case 0x1072: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x1076: + case 0x1079: + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_000964, -10.0f); + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x107A: + func_80151938(globalCtx, 0x10A6); + break; + + case 0x1075: + case 0x1078: + player->exchangeItemId = 0; + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + break; + + case 0x107C: + if (Interface_HasEmptyBottle()) { + gSaveContext.weekEventReg[26] |= 8; + func_801477B4(globalCtx); + this->actionFunc = func_80AE0460; + func_80AE0460(this, globalCtx); + this->unk_220 &= ~2; + this->actor.focus.pos = this->actor.world.pos; + ActorCutscene_Stop(this->actor.cutscene); + this->actor.flags &= ~ACTOR_FLAG_100; + REMOVE_QUEST_ITEM(QUEST_UNK_19); + } else { + func_80151938(globalCtx, 0x10A8); + } + break; + + case 0x1073: + case 0x1074: + func_80151938(globalCtx, 0xFF); + this->actionFunc = func_80AE04FC; + break; + + case 0x107B: + player->exchangeItemId = 0; + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + break; + + case 0x1077: + case 0x10A6: + case 0x10A8: + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + func_80AE0698(this, globalCtx); + this->actor.flags &= ~ACTOR_FLAG_100; + this->actionFunc = func_80AE04C4; + break; + + case 0x108A: + case 0x1091: + gSaveContext.weekEventReg[26] |= 4; + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + this->unk_220 |= 2; + this->actor.textId = 0x1091; + break; + + case 0x108B: + case 0x108C: + case 0x108D: + case 0x108E: + case 0x108F: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0x1092: + if (gSaveContext.weekEventReg[26] & 8) { + func_80AE0698(this, globalCtx); + } else { + func_80151938(globalCtx, 0x10A7); + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_000964, -10.0f); + } + break; + + case 0x10A7: + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + func_80AE0698(this, globalCtx); + break; + + case 0x1090: + func_80AE0698(this, globalCtx); + break; + + case 0x10A9: + func_80AE0698(this, globalCtx); + this->actor.flags &= ~ACTOR_FLAG_100; + this->actionFunc = func_80AE04C4; + break; + } + } + } + + if (this->unk_220 & 2) { + if (this->unk_1D8 != NULL) { + Math_SmoothStepToF(&this->actor.focus.pos.x, this->unk_1D8->actor.focus.pos.x, 0.8f, 100.0f, 5.0f); + Math_SmoothStepToF(&this->actor.focus.pos.y, this->unk_1D8->actor.focus.pos.y, 0.8f, 100.0f, 5.0f); + Math_SmoothStepToF(&this->actor.focus.pos.z, this->unk_1D8->actor.focus.pos.z, 0.8f, 100.0f, 5.0f); + } + } + + if (this->unk_220 & 4) { + if (this->actor.cutscene == -1) { + this->unk_220 &= ~4; + } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->unk_220 &= ~4; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} + +void func_80AE0C88(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80AE0704; + if ((this->actor.textId == 0x108A) || (this->actor.textId == 0x1091)) { + this->unk_220 |= 4; + ENTSN_SET_Z(&this->unk_1D8->actor, true); + } + } else if (this->actor.isTargeted) { + func_800B8614(&this->actor, globalCtx, 1000.0f); + } +} + +void func_80AE0D10(EnTsn* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = func_80AE0D78; + ActorCutscene_Stop(this->actor.cutscene); + } +} + +void func_80AE0D78(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80AE0D10; + this->unk_220 |= 4; + } else if (this->actor.isTargeted) { + func_800B8614(&this->actor, globalCtx, 1000.0f); + } +} + +void EnTsn_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTsn* this = THIS; + + this->actionFunc(this, globalCtx); + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 25.0f, 0.0f, 4); + SkelAnime_Update(&this->skelAnime); + + if (this->unk_220 & 1) { + func_800E9250(globalCtx, &this->actor, &this->unk_222, &this->unk_228, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_222.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_222.y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_228.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_228.y, 0, 6, 0x1838, 0x64); + } + + if (DECR(this->unk_230) == 0) { + this->unk_230 = Rand_S16Offset(60, 60); + } + + if ((this->unk_230 == 1) || (this->unk_230 == 3)) { + this->unk_22E = 1; + } else { + this->unk_22E = 0; + } +} + +void func_80AE0F84(Actor* thisx, GlobalContext* globalCtx) { + EnTsn* this = THIS; + + this->actionFunc(this, globalCtx); +} + +s32 EnTsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnTsn* this = THIS; + s16 shifted = this->unk_222.x >> 1; + + if (limbIndex == 15) { + rot->x += this->unk_222.y; + rot->z += shifted; + } + + if (limbIndex == 8) { + rot->x += this->unk_228.y; + rot->z += shifted; + } + return false; +} + +void EnTsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnTsn* this = THIS; + Vec3f sp18 = D_80AE11BC; + + if (limbIndex == 15) { + Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + } +} + +void EnTsn_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTsn* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C5B0(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AE11C8[this->unk_22E])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AE11C8[this->unk_22E])); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnTsn_OverrideLimbDraw, EnTsn_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h index 6b7810cf6..64df6ac42 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h @@ -7,11 +7,26 @@ struct EnTsn; typedef void (*EnTsnActionFunc)(struct EnTsn*, GlobalContext*); +#define ENTSN_GET_F(thisx) ((thisx)->params & 0xF) +#define ENTSN_GET_100(thisx) ((thisx)->params & 0x100) +#define ENTSN_GET_Z(thisx) ((thisx)->home.rot.z) +#define ENTSN_SET_Z(thisx, state) ((thisx)->home.rot.z = state) + +#define ENTSN_F_0 0 +#define ENTSN_F_1 1 + typedef struct EnTsn { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnTsnActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x5C]; + /* 0x01D8 */ struct EnTsn* unk_1D8; + /* 0x01DC */ UNK_TYPE1 unk1DC[0x44]; + /* 0x0220 */ u16 unk_220; + /* 0x0222 */ Vec3s unk_222; + /* 0x0228 */ Vec3s unk_228; + /* 0x022E */ s16 unk_22E; + /* 0x0230 */ s16 unk_230; } EnTsn; // size = 0x234 extern const ActorInit En_Tsn_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 88487c916..538521a08 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -12384,8 +12384,8 @@ 0x80AE0D78:("func_80AE0D78",), 0x80AE0DDC:("EnTsn_Update",), 0x80AE0F84:("func_80AE0F84",), - 0x80AE0FA8:("func_80AE0FA8",), - 0x80AE1024:("func_80AE1024",), + 0x80AE0FA8:("EnTsn_OverrideLimbDraw",), + 0x80AE1024:("EnTsn_PostLimbDraw",), 0x80AE1080:("EnTsn_Draw",), 0x80AE1650:("func_80AE1650",), 0x80AE16A0:("func_80AE16A0",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 836f19572..ed1902877 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1802,13 +1802,6 @@ D_0601A830 = 0x0601A830; D_060004C8 = 0x060004C8; D_0601AA60 = 0x0601AA60; -// ovl_En_Tsn - -D_06000964 = 0x06000964; -D_06001198 = 0x06001198; -D_06008AB8 = 0x06008AB8; -D_060092FC = 0x060092FC; - // ovl_En_Twig D_060014C8 = 0x060014C8; From 0a8fd532731f51b8a541246fb2b5259abe77c1ef Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Fri, 25 Mar 2022 01:11:43 +0000 Subject: [PATCH 092/257] En_Elfgrp (#654) * En_Elforg * PR * PR * PR --- spec | 3 +- .../actors/ovl_En_Elfgrp/z_en_elfgrp.c | 564 +++++++++++++++++- .../actors/ovl_En_Elfgrp/z_en_elfgrp.h | 17 +- 3 files changed, 554 insertions(+), 30 deletions(-) diff --git a/spec b/spec index 9c92116dd..eee98ebc5 100644 --- a/spec +++ b/spec @@ -2790,8 +2790,7 @@ beginseg name "ovl_En_Elfgrp" compress include "build/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.o" - include "build/data/ovl_En_Elfgrp/ovl_En_Elfgrp.data.o" - include "build/data/ovl_En_Elfgrp/ovl_En_Elfgrp.reloc.o" + include "build/src/overlays/actors/ovl_En_Elfgrp/ovl_En_Elfgrp_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c index 9ff716318..ee7475061 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c @@ -5,6 +5,7 @@ */ #include "z_en_elfgrp.h" +#include "overlays/actors/ovl_En_Elforg/z_en_elforg.h" #define FLAGS (ACTOR_FLAG_10) @@ -14,7 +15,24 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx); void EnElfgrp_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnElfgrp_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +s32 func_80A39BD0(GlobalContext* globalCtx, s32 arg2); +s32 func_80A39C1C(GlobalContext* globalCtx, s32 arg1); +void func_80A39DC8(EnElfgrp* this, GlobalContext* globalCtx, s32 arg2, s32 arg3); +void func_80A3A0AC(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A0F4(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A210(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A274(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A398(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A484(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A4AC(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A520(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A600(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A610(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A6F4(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A77C(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A7FC(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A8F8(EnElfgrp* this, GlobalContext* globalCtx); + const ActorInit En_Elfgrp_InitVars = { ACTOR_EN_ELFGRP, ACTORCAT_PROP, @@ -27,54 +45,546 @@ const ActorInit En_Elfgrp_InitVars = { (ActorFunc)NULL, }; -#endif +void func_80A396B0(EnElfgrp* this, s32 arg1) { + while (arg1 > 0) { + if (this->actor.cutscene == -1) { + break; + } + this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A396B0.s") + arg1--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/EnElfgrp_Init.s") +void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnElfgrp* this = THIS; + s32 sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/EnElfgrp_Destroy.s") + this->unk_147 = ENELFGRP_GET(&this->actor); + this->unk_148 = 0; + this->unk_14A = 0; + this->actor.focus.pos.y += 40.0f; + this->actor.flags &= ~ACTOR_FLAG_1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39BD0.s") + switch (this->unk_147) { + case ENELFGRP_1: + case ENELFGRP_2: + case ENELFGRP_3: + case ENELFGRP_4: + this->unk_148 = this->unk_147 - 1; + sp24 = func_80A39C1C(globalCtx, this->unk_147); + this->unk_146 = 1 << this->unk_147; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39C1C.s") + if (sp24 < 25) { + func_80A39DC8(this, globalCtx, sp24, 0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39CD4.s") + if (sp24 >= 25) { + this->actionFunc = func_80A3A520; + func_80A396B0(this, 2); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39DC8.s") + if ((func_80A39BD0(globalCtx, this->unk_147) + sp24) >= 25) { + this->actionFunc = func_80A3A398; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39F50.s") + switch (this->unk_147) { + case ENELFGRP_1: + if (gSaveContext.weekEventReg[23] & 2) { + func_80A396B0(this, 1); + } else { + this->unk_14A |= 4; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39FBC.s") + case ENELFGRP_2: + if (gSaveContext.doubleMagic == true) { + func_80A396B0(this, 1); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A044.s") + case ENELFGRP_3: + if (gSaveContext.doubleDefense) { + func_80A396B0(this, 1); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A0AC.s") + case ENELFGRP_4: + if (INV_CONTENT(ITEM_SWORD_GREAT_FAIRY) == ITEM_SWORD_GREAT_FAIRY) { + func_80A396B0(this, 1); + } else { + this->unk_14A |= 0x10; + } + break; + } + } else if (func_80A39BD0(globalCtx, this->unk_147)) { + this->actionFunc = func_80A3A7FC; + this->actor.textId = (this->unk_147 * 3) + 0x581; + } else { + this->actionFunc = func_80A3A8F8; + if ((gSaveContext.weekEventReg[9] & this->unk_146)) { + this->actor.textId = (this->unk_147 * 3) + 0x580; + } else { + this->actor.textId = (this->unk_147 * 3) + 0x57F; + } + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A0F4.s") + default: + sp24 = func_80A39C1C(globalCtx, 0); + this->unk_146 = ENELFGRP_1; + if (sp24 >= 25) { + this->actionFunc = func_80A3A520; + if ((this->actor.home.rot.z != 0) && Flags_GetSwitch(globalCtx, this->actor.home.rot.z)) { + this->actionFunc = func_80A3A600; + } else if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) { + func_80A396B0(this, 4); + } else if (INV_CONTENT(ITEM_MASK_DEKU) != ITEM_MASK_DEKU) { + func_80A396B0(this, 5); + } else { + this->unk_14A |= 2; + func_80A396B0(this, 6); + } + } else if ((gSaveContext.weekEventReg[8] & 0x80)) { + func_80A39DC8(this, globalCtx, 24, 0); + this->actionFunc = func_80A3A398; + if (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU) { + if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) { + func_80A396B0(this, 2); + } else { + func_80A396B0(this, 3); + this->unk_14A |= 2; + } + } else if (gSaveContext.magicAcquired == true) { + func_80A396B0(this, 1); + } + } else { + func_80A39DC8(this, globalCtx, 24, 0); + this->actionFunc = func_80A3A8F8; + if ((gSaveContext.weekEventReg[9] & this->unk_146)) { + this->actor.textId = 0x580; + } else { + this->actor.textId = 0x578; + } + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A210.s") +void EnElfgrp_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A274.s") +s32 func_80A39BD0(GlobalContext* globalCtx, s32 arg2) { + s8 sp1F; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A398.s") + if ((arg2 < 1) || (arg2 >= 5)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A484.s") + sp1F = gSaveContext.inventory.strayFairies[arg2 - 1]; + return (sp1F - func_80A39C1C(globalCtx, arg2)) + 10; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A4AC.s") +s32 func_80A39C1C(GlobalContext* globalCtx, s32 arg1) { + // the permanentSceneFlags access here is in the form + // struct { + // u32 clockTown : 1; + // u32 fountains[4] : 5; + // } FairyFountains; + // where arg1 is: + // 0: clocktown + // 1: woodfall, + // 2: snowhead, + // 3: great bay, + // 4: stone tower + // clocktown is handled separately, and then the fountains are looked up as array indexing -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A520.s") + s32 temp_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A600.s") + if ((arg1 < 0) || (arg1 >= 5)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A610.s") + if (arg1 == 0) { + if (gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1) { + return 25; + } + return 24; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A6F4.s") + temp_v1 = (gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 >> (((arg1 - 1) * 5) + 1)) & 0x1F; + if (temp_v1 < 10) { + temp_v1 = 10; + } else if (temp_v1 > 25) { + temp_v1 = 25; + } + return temp_v1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A77C.s") +void func_80A39CD4(GlobalContext* globalCtx, s32 arg1, s32 arg2) { + if ((arg1 < 0) || (arg1 > 4) || (arg2 < 10) || (arg2 > 25)) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A7FC.s") + if (arg1 == 0) { + if (arg2 == 25) { + gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 1; + } else { + gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~1; + } + } else { + gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~(0x1F << ((arg1 * 5) - 4)); + gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= arg2 << ((arg1 * 5) - 4); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A8F8.s") +void func_80A39DC8(EnElfgrp* this, GlobalContext* globalCtx, s32 arg2, s32 arg3) { + s32 pad; + s32 i; + Actor* elforg; + s32 temp; + Vec3f sp6C; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/EnElfgrp_Update.s") + if (arg3 == 0) { + this->unk_14A |= 8; + } + + if (arg3 == 0) { + sp6C = this->actor.world.pos; + sp6C.y += 20.0f; + temp = ((this->unk_147 & 7) << 6) | STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN; + } else { + sp6C = player->actor.world.pos; + sp6C.y += 20.0f; + temp = ((this->unk_147 & 7) << 6) | STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN; + } + + for (i = 0; i < arg2; i++) { + elforg = + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELFORG, randPlusMinusPoint5Scaled(20.0f) + sp6C.x, + sp6C.y, randPlusMinusPoint5Scaled(20.0f) + sp6C.z, 0, 0, 0, temp); + if (elforg == NULL) { + continue; + } + elforg->home.pos.x = this->actor.home.pos.x; + elforg->home.pos.y = this->actor.home.pos.y + 20.0f; + elforg->home.pos.z = this->actor.home.pos.z; + } +} + +s32 func_80A39F50(GlobalContext* globalCtx) { + Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + EnElforg* elfOrg; + + while (itemAction != NULL) { + if ((itemAction->id != ACTOR_EN_ELFORG) || + ((STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN) && + (STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN))) { + itemAction = itemAction->next; + continue; + } + + elfOrg = (EnElforg*)itemAction; + if (!(elfOrg->flags & STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME)) { + elfOrg->flags |= STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME; + } + itemAction = itemAction->next; + } + + return 0; +} + +s32 func_80A39FBC(GlobalContext* globalCtx) { + Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + EnElforg* elfOrg; + s32 phi_v1 = 30; + + while (itemAction != NULL) { + if ((itemAction->id != ACTOR_EN_ELFORG) || + ((STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN) && + (STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN))) { + itemAction = itemAction->next; + continue; + } + + elfOrg = (EnElforg*)itemAction; + if (!(elfOrg->flags & STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN)) { + elfOrg->flags |= STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN; + if (phi_v1 >= 100) { + return phi_v1; + } + elfOrg->secondaryTimer = phi_v1; + phi_v1 += 5; + } + + itemAction = itemAction->next; + } + + return phi_v1; +} + +void func_80A3A044(GlobalContext* globalCtx) { + Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + EnElforg* elfOrg; + + while (itemAction != NULL) { + if ((itemAction->id != ACTOR_EN_ELFORG) || + ((STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN) && + (STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN))) { + itemAction = itemAction->next; + continue; + } + + elfOrg = (EnElforg*)itemAction; + elfOrg->actor.home.rot.x = 0x14; + elfOrg->flags |= STRAY_FAIRY_FLAG_SPARKLES_AND_SHRINKS; + + itemAction = itemAction->next; + } +} + +void func_80A3A0AC(EnElfgrp* this, GlobalContext* globalCtx) { + if (!Cutscene_CheckActorAction(globalCtx, 0x64)) { + this->actionFunc = func_80A3A600; + ActorCutscene_Stop(this->actor.cutscene); + } +} + +void func_80A3A0F4(EnElfgrp* this, GlobalContext* globalCtx) { + if (this->unk_144 == 10) { + play_sound(NA_SE_SY_WHITE_OUT_T); + if (ENELFGRP_GET(&this->actor) < ENELFGRP_4) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->actor.world.pos.x, + this->actor.world.pos.y + 30.0f, this->actor.world.pos.z, 0, 0, 0, + ENELFGRP_GET(&this->actor) + ENELFGRP_4); + } else { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->actor.world.pos.x, + this->actor.world.pos.y + 30.0f, this->actor.world.pos.z, 0, 0, 0, 4); + } + } + + if ((this->unk_144 > 10) && (this->unk_14A & 1)) { + func_800B9010(&this->actor, NA_SE_EV_FAIRY_GROUP_FRY - SFX_FLAG); + } + + if (this->unk_144 == 0) { + this->actionFunc = func_80A3A0AC; + } +} + +void func_80A3A210(EnElfgrp* this, GlobalContext* globalCtx) { + if (this->unk_144 == 0) { + this->actionFunc = func_80A3A0F4; + func_80A3A044(globalCtx); + this->unk_144 = 30; + } + + if (this->unk_14A & 1) { + func_800B9010(&this->actor, NA_SE_EV_FAIRY_GROUP_FRY - SFX_FLAG); + } +} + +void func_80A3A274(EnElfgrp* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 0x64)) { + if (this->unk_14A & 1) { + func_800B9010(&this->actor, NA_SE_PL_CHIBI_FAIRY_HEAL - SFX_FLAG); + } + + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x64)]->action) { + case 2: + if (!(this->unk_14A & 1)) { + if (this->unk_147 == ENELFGRP_0) { + func_80A39DC8(this, globalCtx, 1, 1); + } else { + func_80A39DC8(this, globalCtx, func_80A39BD0(globalCtx, this->unk_147), 1); + } + this->unk_14A |= 1; + func_80A39CD4(globalCtx, this->unk_147, 25); + } + break; + + case 3: + func_80A39F50(globalCtx); + this->actionFunc = func_80A3A210; + this->unk_144 = 90; + break; + } + } +} + +void func_80A3A398(EnElfgrp* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actionFunc = func_80A3A274; + Flags_UnsetSwitch(globalCtx, ENELFGRP_GET_FE00(&this->actor)); + if (this->unk_14A & 2) { + Item_Give(globalCtx, ITEM_MASK_GREAT_FAIRY); + } + + if ((this->unk_14A & 4) != 0) { + gSaveContext.weekEventReg[23] |= 2; + } + + if (this->unk_14A & 0x10) { + Item_Give(globalCtx, ITEM_SWORD_GREAT_FAIRY); + } + this->unk_14A &= ~8; + } else if (this->actor.xzDistToPlayer < 350.0f) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80A3A484(EnElfgrp* this, GlobalContext* globalCtx) { + if (this->unk_144 == 0) { + this->actionFunc = func_80A3A0F4; + this->unk_144 = 30; + } +} + +void func_80A3A4AC(EnElfgrp* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 0x64)) { + s32 temp = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x64)]->action; + if (temp == 3) { + this->actionFunc = func_80A3A484; + this->unk_144 = 90; + } + } +} + +void func_80A3A520(EnElfgrp* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 0x67)) { + this->actionFunc = func_80A3A600; + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actionFunc = func_80A3A4AC; + Flags_SetSwitch(globalCtx, ENELFGRP_GET_FE00(&this->actor)); + + if (this->unk_14A & 2) { + Item_Give(globalCtx, ITEM_MASK_GREAT_FAIRY); + } + + if (this->actor.home.rot.z != 0) { + Flags_SetSwitch(globalCtx, this->actor.home.rot.z); + } + } else if (this->actor.xzDistToPlayer < 350.0f) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80A3A600(EnElfgrp* this, GlobalContext* globalCtx) { +} + +void func_80A3A610(EnElfgrp* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_144 == 60) { + Parameter_AddMagic(globalCtx, ((void)0, gSaveContext.unk_3F30) + (gSaveContext.doubleMagic * 0x30) + 0x30); + gSaveContext.healthAccumulator = 320; + } + + if (this->unk_144 > 0) { + player->actor.freezeTimer = 100; + player->stateFlags1 |= 0x20000000; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_GROUP_HEAL - SFX_FLAG); + } else { + player->actor.freezeTimer = 0; + player->stateFlags1 &= ~0x20000000; + this->actionFunc = func_80A3A600; + this->unk_14A |= 8; + } +} + +void func_80A3A6F4(EnElfgrp* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + player->actor.freezeTimer = 100; + player->stateFlags1 |= 0x20000000; + this->unk_144 = func_80A39FBC(globalCtx); + this->actionFunc = func_80A3A610; + this->unk_14A &= ~8; + } +} + +void func_80A3A77C(EnElfgrp* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.freezeTimer = 100; + player->stateFlags1 |= 0x20000000; + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + this->unk_144 = func_80A39FBC(globalCtx); + this->actionFunc = func_80A3A610; + this->unk_14A &= ~8; + } +} + +void func_80A3A7FC(EnElfgrp* this, GlobalContext* globalCtx) { + s32 temp_s0; + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + gSaveContext.weekEventReg[9] |= this->unk_146; + this->actionFunc = func_80A3A6F4; + temp_s0 = func_80A39BD0(globalCtx, this->unk_147); + func_80A39DC8(this, globalCtx, temp_s0, 1); + temp_s0 += func_80A39C1C(globalCtx, this->unk_147); + if (temp_s0 > 25) { + temp_s0 = 25; + } + func_80A39CD4(globalCtx, this->unk_147, temp_s0); + } else if (this->actor.xzDistToPlayer < 280.0f) { + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8614(&this->actor, globalCtx, 300.0f); + } +} + +void func_80A3A8F8(EnElfgrp* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + gSaveContext.weekEventReg[9] |= this->unk_146; + this->actionFunc = func_80A3A6F4; + return; + } + + if (this->unk_147 != ENELFGRP_0) { + if (func_80A39BD0(globalCtx, this->unk_147) > 0) { + this->actionFunc = func_80A3A7FC; + return; + } + } + + if (this->actor.xzDistToPlayer < 30.0f) { + if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + this->actor.flags &= ~ACTOR_FLAG_10000; + player->actor.freezeTimer = 100; + player->stateFlags1 |= 0x20000000; + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + this->actionFunc = func_80A3A77C; + gSaveContext.weekEventReg[9] |= this->unk_146; + } else { + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8614(&this->actor, globalCtx, 100.0f); + } + } else { + this->actor.flags &= ~ACTOR_FLAG_10000; + } +} + +void EnElfgrp_Update(Actor* thisx, GlobalContext* globalCtx) { + EnElfgrp* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->unk_14A & 8) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_GROUP_FRY - SFX_FLAG); + } + + if (this->unk_144 != 0) { + this->unk_144--; + } +} diff --git a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h index 7ecb7d71d..375dad55b 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h @@ -7,9 +7,24 @@ struct EnElfgrp; typedef void (*EnElfgrpActionFunc)(struct EnElfgrp*, GlobalContext*); +#define ENELFGRP_GET(thisx) ((thisx)->params & 0xF) +#define ENELFGRP_GET_FE00(thisx) (((thisx)->params & 0xFE00) >> 9) + +enum { + /* 0 */ ENELFGRP_0, + /* 2 */ ENELFGRP_1, + /* 2 */ ENELFGRP_2, + /* 3 */ ENELFGRP_3, + /* 4 */ ENELFGRP_4, +}; + typedef struct EnElfgrp { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x8]; + /* 0x0144 */ s16 unk_144; + /* 0x0146 */ u8 unk_146; + /* 0x0147 */ u8 unk_147; + /* 0x0148 */ s8 unk_148; + /* 0x014A */ u16 unk_14A; /* 0x014C */ EnElfgrpActionFunc actionFunc; } EnElfgrp; // size = 0x150 From 20fed85f679a7129ffd27fe3848f66e49df7e122 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Fri, 25 Mar 2022 01:17:07 +0000 Subject: [PATCH 093/257] En_Ah (#658) * En_Ah * PR --- spec | 3 +- src/overlays/actors/ovl_En_Ah/z_en_ah.c | 592 ++++++++++++++++++++++-- src/overlays/actors/ovl_En_Ah/z_en_ah.h | 28 +- undefined_syms.txt | 4 - 4 files changed, 580 insertions(+), 47 deletions(-) diff --git a/spec b/spec index eee98ebc5..bd3f7a941 100644 --- a/spec +++ b/spec @@ -4685,8 +4685,7 @@ beginseg name "ovl_En_Ah" compress include "build/src/overlays/actors/ovl_En_Ah/z_en_ah.o" - include "build/data/ovl_En_Ah/ovl_En_Ah.data.o" - include "build/data/ovl_En_Ah/ovl_En_Ah.reloc.o" + include "build/src/overlays/actors/ovl_En_Ah/ovl_En_Ah_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index b7bec3f69..3a3e76c24 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -5,6 +5,7 @@ */ #include "z_en_ah.h" +#include "objects/object_ah/object_ah.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -18,7 +19,19 @@ void EnAh_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BD36B8(EnAh* this, GlobalContext* globalCtx); void func_80BD3768(EnAh* this, GlobalContext* globalCtx); -#if 0 +s32 D_80BD3DB0[] = { + 0x0A00611D, 0x0C000303, 0x0400010C, 0x00021102, 0x15001700, 0x08003220, 0x03040001, + 0x05040003, 0x050A0010, 0x120C0003, 0x0D021200, 0x06000105, 0x0E120006, 0x00020505, +}; + +s32 D_80BD3DE8[] = { 0x0E28FF0C, 0x10000000 }; + +s32 D_80BD3DF0[] = { 0x0E29000C, 0x10000000 }; + +s32 D_80BD3DF8[] = { 0x00330100, 0x050E28FE, 0x0C100E28, -0x03F3F000 }; + +s32 D_80BD3E08[] = { 0x0E28FD0C, 0x0F29540C, 0x10000000 }; + const ActorInit En_Ah_InitVars = { ACTOR_EN_AH, ACTORCAT_NPC, @@ -31,75 +44,576 @@ const ActorInit En_Ah_InitVars = { (ActorFunc)EnAh_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BD3E34 = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 68, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BD3E60 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_ah_Anim_001860, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_ah_Anim_001860, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_ah_Anim_002280, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_ah_Anim_000968, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_ah_Anim_000DDC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern ColliderCylinderInit D_80BD3E34; -extern CollisionCheckInfoInit2 D_80BD3E60; +s16 D_80BD3EBC[] = { 0, 0, 1, 0 }; -extern UNK_TYPE D_06009E70; +PosRot D_80BD3EC4 = { { 100.0f, 0.0f, 67.0f }, { 0, 0x349C, 0 } }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2A30.s") +PosRot D_80BD3ED8 = { { 855.0f, 260.0f, 31.0f }, { 0, 0x7FF8, 0 } }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2AE0.s") +PosRot D_80BD3EEC = { { -395.0f, 210.0f, -162.0f }, { 0, 0xBE98, 0 } }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2B0C.s") +Vec3f D_80BD3F00 = { 1000.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2BA4.s") +TexturePtr D_80BD3F0C[] = { object_ah_Tex_008D70, object_ah_Tex_009570 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2BE8.s") +TexturePtr D_80BD3F14[] = { + object_ah_Tex_006D70, object_ah_Tex_007570, object_ah_Tex_007D70, object_ah_Tex_007570, object_ah_Tex_008570, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2C6C.s") +s32 func_80BD2A30(EnAh* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { + Actor* tempActor; + Actor* foundActor = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2DA0.s") + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, actorCat, actorId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2DC8.s") + if ((foundActor == NULL) || (((EnAh*)foundActor != this) && (foundActor->update != NULL))) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2FD0.s") + tempActor = foundActor->next; + if (tempActor == NULL) { + foundActor = NULL; + break; + } + foundActor = tempActor; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD30C0.s") + return foundActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3118.s") +void func_80BD2AE0(EnAh* this) { + this->skelAnime.playSpeed = this->unk_2DC; + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3198.s") +s32 func_80BD2B0C(EnAh* this, s32 arg1) { + s32 phi_v1 = false; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3294.s") + if ((arg1 == 0) || (arg1 == 1)) { + if ((this->unk_300 != 0) && (this->unk_300 != 1)) { + phi_v1 = true; + } + } else if (arg1 != this->unk_300) { + phi_v1 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3320.s") + if (phi_v1) { + this->unk_300 = arg1; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + this->unk_2DC = this->skelAnime.playSpeed; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3374.s") +void func_80BD2BA4(EnAh* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD33FC.s") +s32 func_80BD2BE8(EnAh* this, GlobalContext* globalCtx) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3484.s") + if (this->unk_2D8 & 7) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + SubS_UpdateFlags(&this->unk_2D8, 0, 7); + ret = true; + this->unk_2D8 |= 8; + this->actionFunc = func_80BD3768; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3548.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD35BC.s") +void func_80BD2C6C(EnAh* this) { + s32 phi_a3 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3658.s") + if (this->unk_2D8 & 0x40) { + if (DECR(this->unk_2F8) == 0) { + switch (this->unk_2F6) { + case 1: + case 2: + if ((this->unk_2FA == 4) || (this->unk_2FA == 2)) { + phi_a3 = true; + this->unk_2FA = 4; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD36B8.s") + if (!phi_a3 && (this->unk_2FA == 4)) { + this->unk_2FA = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3768.s") + if (!phi_a3) { + this->unk_2FA++; + if (this->unk_2FA >= 4) { + if (this->unk_2F6 == 0) { + this->unk_2F8 = Rand_S16Offset(30, 30); + } else { + this->unk_2F8 = 8; + } + this->unk_2FA = 0; + phi_a3 = true; + } + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/EnAh_Init.s") + if (phi_a3 == true) { + this->unk_2FC = D_80BD3EBC[this->unk_2F6]; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/EnAh_Destroy.s") +Actor* func_80BD2DA0(EnAh* this, GlobalContext* globalCtx) { + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/EnAh_Update.s") + if (this->unk_1DC == 3) { + actor = this->actor.child; + } else { + actor = &GET_PLAYER(globalCtx)->actor; + } + return actor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3AA8.s") +void func_80BD2DC8(EnAh* this) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3AF8.s") + Math_Vec3f_Copy(&sp40, &this->unk_1E4->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/EnAh_Draw.s") + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); + + Math_ApproachS(&this->unk_2EE, (sp32 - this->unk_2F2) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2EE = CLAMP(this->unk_2EE, -0x1FFE, 0x1FFE); + + Math_ApproachS(&this->unk_2F2, (sp32 - this->unk_2EE) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2F2 = CLAMP(this->unk_2F2, -0x1C70, 0x1C70); + + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + + if (this->unk_1E4->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_1E4)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_1E4->focus.pos); + } + + Math_ApproachS(&this->unk_2EC, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2F0, 4, 0x2AA8); + this->unk_2EC = CLAMP(this->unk_2EC, -0x1554, 0x1554); + + Math_ApproachS(&this->unk_2F0, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2EC, 4, 0x2AA8); + this->unk_2F0 = CLAMP(this->unk_2F0, -0xE38, 0xE38); +} + +void func_80BD2FD0(EnAh* this, GlobalContext* globalCtx) { + this->unk_1E4 = func_80BD2DA0(this, globalCtx); + + if ((this->unk_2D8 & 8) && (this->unk_1E4 != NULL)) { + if (DECR(this->unk_2F4) == 0) { + func_80BD2DC8(this); + this->unk_2F0 = 0; + this->unk_2F2 = 0; + this->unk_2D8 &= ~0x80; + this->unk_2D8 |= 0x20; + return; + } + } + + if (this->unk_2D8 & 0x20) { + this->unk_2D8 &= ~0x20; + this->unk_2EC = 0; + this->unk_2EE = 0; + this->unk_2F0 = 0; + this->unk_2F2 = 0; + this->unk_2F4 = 20; + } else if (DECR(this->unk_2F4) == 0) { + this->unk_2D8 |= 0x80; + } +} + +s32 func_80BD30C0(EnAh* this, GlobalContext* globalCtx) { + switch (this->unk_1DC) { + case 1: + func_80BD2B0C(this, 0); + break; + + case 2: + func_80BD2B0C(this, 4); + break; + } + return false; +} + +void func_80BD3118(EnAh* this, GlobalContext* globalCtx) { + if (this->unk_2FE == 0) { + func_80BD2B0C(this, 2); + this->unk_2FE++; + } else if ((this->unk_2FE == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80BD2B0C(this, 3); + this->unk_2FE++; + } +} + +s32 func_80BD3198(EnAh* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u16 temp = globalCtx->msgCtx.unk11F04; + + if (player->stateFlags1 & 0x40) { + if (this->unk_2DA != temp) { + if (temp == 0x2954) { + this->unk_18C = func_80BD3118; + this->unk_2FE = 0; + } + + switch (temp) { + case 0x28FD: + this->unk_2F6 = 1; + this->unk_2F8 = 8; + break; + + case 0x2954: + this->unk_2F6 = 2; + this->unk_2F8 = 8; + break; + } + } + this->unk_2DA = temp; + this->unk_2D8 |= 0x100; + } else if (this->unk_2D8 & 0x100) { + this->unk_18C = NULL; + this->unk_2DA = 0; + this->unk_2D8 &= ~0x100; + this->unk_2F6 = 0; + this->unk_2F8 = 4; + func_80BD30C0(this, globalCtx); + } + + if (this->unk_18C != NULL) { + this->unk_18C(this, globalCtx); + } + + return false; +} + +s32* func_80BD3294(EnAh* this, GlobalContext* globalCtx) { + s32 mask = Player_GetMask(globalCtx); + + if (PLAYER_MASK_KAFEIS_MASK == mask) { + return D_80BD3E08; + } + + switch (this->unk_1DC) { + case 1: + if (gSaveContext.day == 2) { + return D_80BD3DF0; + } + return D_80BD3DE8; + + case 2: + return D_80BD3DF8; + } + return NULL; +} + +s32 func_80BD3320(EnAh* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { + s32 pad; + s32 ret = false; + Actor* temp_v0 = func_80BD2A30(this, globalCtx, actorCat, actorId); + + if (temp_v0 != NULL) { + this->actor.child = temp_v0; + ret = true; + } + return ret; +} + +s32 func_80BD3374(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 pad; + + Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3EC4.pos); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80BD3EC4.rot); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + func_80BD2B0C(this, 0); + SubS_UpdateFlags(&this->unk_2D8, 3, 7); + this->unk_2D8 |= 0x40; + return true; +} + +s32 func_80BD33FC(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 pad; + + Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3ED8.pos); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80BD3ED8.rot); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + func_80BD2B0C(this, 4); + SubS_UpdateFlags(&this->unk_2D8, 3, 7); + this->unk_2D8 |= (0x40 | 0x10); + return true; +} + +s32 func_80BD3484(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret = false; + + if (func_80BD3320(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AN)) { + if (sREG(81) == 0) { + Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3EEC.pos); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80BD3EEC.rot); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + } + func_80BD2B0C(this, 4); + this->unk_2D8 |= (0x40 | 0x8); + this->unk_2D8 |= 0x10; + this->unk_2D8 |= 0x80; + this->actor.gravity = 0.0f; + ret = true; + } + return ret; +} + +s32 func_80BD3548(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret; + + this->unk_2D8 = 0; + + switch (arg2->unk0) { + default: + ret = false; + break; + + case 1: + ret = func_80BD3374(this, globalCtx, arg2); + break; + + case 2: + ret = func_80BD33FC(this, globalCtx, arg2); + break; + + case 3: + ret = func_80BD3484(this, globalCtx, arg2); + break; + } + return ret; +} + +s32 func_80BD35BC(EnAh* this, GlobalContext* globalCtx) { + s16 temp; + s16 temp2; + + switch (this->unk_1DC) { + default: + return false; + + case 2: + temp = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); + temp2 = ABS_ALT(temp); + if (temp2 < 0x3800) { + SubS_UpdateFlags(&this->unk_2D8, 3, 7); + } else { + SubS_UpdateFlags(&this->unk_2D8, 0, 7); + } + return false; + } +} + +void func_80BD3658(EnAh* this, GlobalContext* globalCtx) { + if ((this->unk_1DC == 1) || (this->unk_1DC == 2) || (this->unk_1DC == 3)) { + func_80BD35BC(this, globalCtx); + } + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); +} + +void func_80BD36B8(EnAh* this, GlobalContext* globalCtx) { + s32 pad; + struct_80133038_arg2 sp18; + + if (!func_80133038(globalCtx, D_80BD3DB0, &sp18) || + ((this->unk_1DC != sp18.unk0) && !func_80BD3548(this, globalCtx, &sp18))) { + this->actor.shape.shadowDraw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + sp18.unk0 = 0; + } else { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.flags |= ACTOR_FLAG_1; + } + this->unk_1DC = sp18.unk0; + func_80BD3658(this, globalCtx); +} + +void func_80BD3768(EnAh* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + + if (func_8010BF58(&this->actor, globalCtx, func_80BD3294(this, globalCtx), NULL, &this->unk_1E0)) { + SubS_UpdateFlags(&this->unk_2D8, 3, 7); + this->unk_2D8 &= ~8; + this->unk_2D8 |= 0x80; + this->unk_2F4 = 20; + this->unk_1E0 = 0; + this->actionFunc = func_80BD36B8; + } else if (this->unk_1DC != 2) { + if (this->unk_1E4 != NULL) { + Math_Vec3f_Copy(&sp40, &this->unk_1E4->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp34, &sp40), 4, 0x2AA8); + } + } +} + +void EnAh_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAh* this = THIS; + + if (func_80BD2A30(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AH)) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ah_Skel_009E70, NULL, this->jointTable, this->morphTable, + 17); + this->unk_300 = -1; + func_80BD2B0C(this, 0); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + this->actor.targetMode = 6; + Actor_SetScale(&this->actor, 0.01f); + this->unk_1DC = 0; + this->unk_2D8 = 0; + + this->actionFunc = func_80BD36B8; + this->actionFunc(this, globalCtx); +} + +void EnAh_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAh* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnAh_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAh* this = THIS; + f32 radius; + f32 height; + + func_80BD2BE8(this, globalCtx); + + this->actionFunc(this, globalCtx); + + if (this->unk_1DC != 0) { + func_80BD3198(this, globalCtx); + func_80BD2AE0(this); + func_80BD2C6C(this); + func_80BD2FD0(this, globalCtx); + radius = this->collider.dim.radius + 60; + height = this->collider.dim.height + 10; + + func_8013C964(&this->actor, globalCtx, radius, height, 0, this->unk_2D8 & 7); + if (!(this->unk_2D8 & 0x10)) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + } + func_80BD2BA4(this, globalCtx); + } +} + +void func_80BD3AA8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnAh* this = THIS; + + if (limbIndex == 7) { + Matrix_MultiplyVector3fByState(&D_80BD3F00, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } +} + +void func_80BD3AF8(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnAh* this = THIS; + s32 phi_v1; + s32 phi_v0; + + if (!(this->unk_2D8 & 0x80)) { + if (this->unk_2D8 & 0x20) { + phi_v0 = 1; + } else { + phi_v0 = 0; + } + phi_v1 = 1; + } else { + phi_v1 = 0; + phi_v0 = 0; + } + + if (limbIndex == 7) { + func_8013AD9C(BINANG_ADD(this->unk_2EC + this->unk_2F0, 0x4000), + BINANG_ADD(this->unk_2EE + this->unk_2F2 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, + this->unk_200, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_200[0].y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_200[0].x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_200[0].z, MTXMODE_APPLY); + Matrix_StatePush(); + } else if (limbIndex == 2) { + func_8013AD9C(BINANG_ADD(this->unk_2F0, 0x4000), BINANG_ADD(this->unk_2F2 + this->actor.shape.rot.y, 0x4000), + &this->unk_1E8[1], &this->unk_200[1], phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_1E8[1].x, this->unk_1E8[1].y, this->unk_1E8[1].z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_200[1].y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_200[1].x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_200[1].z, MTXMODE_APPLY); + Matrix_StatePush(); + } +} + +void EnAh_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnAh* this = THIS; + + if (this->unk_1DC != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BD3F14[this->unk_2FA])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80BD3F0C[this->unk_2FC])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, func_80BD3AA8, func_80BD3AF8, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.h b/src/overlays/actors/ovl_En_Ah/z_en_ah.h index 13dd73027..85263e04b 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.h +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.h @@ -6,12 +6,36 @@ struct EnAh; typedef void (*EnAhActionFunc)(struct EnAh*, GlobalContext*); +typedef void (*EnAhUnkFunc)(struct EnAh*, GlobalContext*); typedef struct EnAh { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnAhActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x178]; + /* 0x018C */ EnAhUnkFunc unk_18C; + /* 0x0190 */ ColliderCylinder collider; + /* 0x01DC */ u8 unk_1DC; + /* 0x01E0 */ s32 unk_1E0; + /* 0x01E4 */ Actor* unk_1E4; + /* 0x01E8 */ Vec3f unk_1E8[2]; + /* 0x0200 */ Vec3s unk_200[2]; + /* 0x020C */ Vec3s jointTable[17]; + /* 0x0272 */ Vec3s morphTable[17]; + /* 0x02D8 */ u16 unk_2D8; + /* 0x02DA */ u16 unk_2DA; + /* 0x02DC */ f32 unk_2DC; + /* 0x02E0 */ UNK_TYPE1 unk2E0[0xC]; + /* 0x02EC */ s16 unk_2EC; + /* 0x02EE */ s16 unk_2EE; + /* 0x02F0 */ s16 unk_2F0; + /* 0x02F2 */ s16 unk_2F2; + /* 0x02F4 */ s16 unk_2F4; + /* 0x02F6 */ s16 unk_2F6; + /* 0x02F8 */ s16 unk_2F8; + /* 0x02FA */ s16 unk_2FA; + /* 0x02FC */ s16 unk_2FC; + /* 0x02FE */ s16 unk_2FE; + /* 0x0300 */ s32 unk_300; } EnAh; // size = 0x304 extern const ActorInit En_Ah_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index ed1902877..a701f116e 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1052,10 +1052,6 @@ D_06000180 = 0x06000180; D_060002A8 = 0x060002A8; D_06000F38 = 0x06000F38; -// ovl_En_Ah - -D_06009E70 = 0x06009E70; - // ovl_En_An D_06000308 = 0x06000308; From 3431b542ff57b2359813578cd4a366aa40fdb273 Mon Sep 17 00:00:00 2001 From: Parker Burnett Date: Thu, 24 Mar 2022 21:22:46 -0400 Subject: [PATCH 094/257] En_look_nuts OK with docs (#674) * OK * some documenting * lgtm * format * spacing things out * one other name * PR feedback * fix enum * addressing PR * actor fixer * fixing PR --- assets/xml/objects/object_dnk.xml | 92 ++--- spec | 3 +- src/overlays/actors/ovl_En_Dnk/z_en_dnk.c | 28 +- .../actors/ovl_En_Look_Nuts/z_en_look_nuts.c | 337 ++++++++++++++++-- .../actors/ovl_En_Look_Nuts/z_en_look_nuts.h | 25 +- tools/disasm/functions.txt | 10 +- undefined_syms.txt | 6 - 7 files changed, 402 insertions(+), 99 deletions(-) diff --git a/assets/xml/objects/object_dnk.xml b/assets/xml/objects/object_dnk.xml index 359cdfd5d..4e07a455c 100644 --- a/assets/xml/objects/object_dnk.xml +++ b/assets/xml/objects/object_dnk.xml @@ -1,50 +1,50 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index bd3f7a941..c511193f4 100644 --- a/spec +++ b/spec @@ -3056,8 +3056,7 @@ beginseg name "ovl_En_Look_Nuts" compress include "build/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.o" - include "build/data/ovl_En_Look_Nuts/ovl_En_Look_Nuts.data.o" - include "build/data/ovl_En_Look_Nuts/ovl_En_Look_Nuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Look_Nuts/ovl_En_Look_Nuts_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c index d04ed3ee1..969c719fd 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -94,16 +94,16 @@ static DamageTable sDamageTable = { }; static AnimationInfoS sAnimations[] = { - { &object_dnk_Anim_000B70, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dnk_Anim_000B70, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnk_Anim_002A08, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnk_Anim_00031C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnk_Anim_000430, 1.0f, -1, -1, ANIMMODE_ONCE, 0 }, - { &object_dnk_Anim_000430, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnk_Anim_000894, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnk_Anim_002B6C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dnk_Anim_002B6C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnk_Anim_0006CC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPalaceGuardStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDekuPalaceGuardStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPalaceGuardWaitAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPalaceGuardAttackAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPalaceGuardDigAnim, 1.0f, -1, -1, ANIMMODE_ONCE, 0 }, + { &gDekuPalaceGuardDigAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPalaceGuardJumpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPalaceGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuPalaceGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPalaceGuardHappyAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, { &object_hintnuts_Anim_000168, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, { &object_hintnuts_Anim_0024CC, 1.0f, -1, -1, ANIMMODE_ONCE, 0 }, { &object_hintnuts_Anim_0024CC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, @@ -178,7 +178,7 @@ void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { switch (ENDNK_GET_3(&this->actor)) { case ENDNK_GET_3_0: - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dnk_Skel_002848, NULL, this->jointTable, + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, NULL, this->jointTable, this->morphTable, 11); func_80A514F0(&this->skelAnime, 7); break; @@ -326,9 +326,9 @@ void func_80A51AA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* void func_80A51CB8(EnDnk* this, GlobalContext* globalCtx) { static TexturePtr D_80A5245C[] = { - object_dnk_Tex_001680, - object_dnk_Tex_001700, - object_dnk_Tex_001780, + gDekuPalaceGuardEyeOpenTex, + gDekuPalaceGuardEyeHalfTex, + gDekuPalaceGuardEyeClosedTex, }; s32 pad; diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c index c38faff3e..57b441e7a 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c @@ -15,7 +15,14 @@ void EnLookNuts_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnLookNuts_Update(Actor* thisx, GlobalContext* globalCtx); void EnLookNuts_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnLookNuts_SetupPatrol(EnLookNuts* this); +void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx); +void EnLookNuts_SetupStandAndWait(EnLookNuts* this); +void EnLookNuts_StandAndWait(EnLookNuts* this, GlobalContext* globalCtx); +void EnLookNuts_RunToPlayer(EnLookNuts* this, GlobalContext* globalCtx); +void EnLookNuts_SetupSendPlayerToSpawn(EnLookNuts* this); +void EnLookNuts_SendPlayerToSpawn(EnLookNuts* this, GlobalContext* globalCtx); + const ActorInit En_Look_Nuts_InitVars = { ACTOR_EN_LOOK_NUTS, ACTORCAT_NPC, @@ -28,15 +35,29 @@ const ActorInit En_Look_Nuts_InitVars = { (ActorFunc)EnLookNuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A68600 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 20, 50, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80A68630 = { +s32 D_80A6862C = 0; + +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0xF), /* Deku Stick */ DMG_ENTRY(1, 0xF), /* Horse trample */ DMG_ENTRY(1, 0xF), @@ -71,34 +92,302 @@ static DamageTable D_80A68630 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -#endif +typedef enum { + /* 0x01 */ PALACE_GUARD_PATROLLING, + /* 0x01 */ PALACE_GUARD_WAITING, + /* 0x02 */ PALACE_GUARD_RUNNING_TO_PLAYER, + /* 0x03 */ PALACE_GUARD_CAUGHT_PLAYER +} PalaceGuardState; -extern ColliderCylinderInit D_80A68600; -extern DamageTable D_80A68630; +void EnLookNuts_Init(Actor* thisx, GlobalContext* globalCtx) { + EnLookNuts* this = THIS; -extern UNK_TYPE D_06000430; -extern UNK_TYPE D_06002B6C; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, &gDekuPalaceGuardDigAnim, this->jointTable, + this->morphTable, OBJECT_DNK_LIMB_MAX); + Actor_SetScale(&this->actor, 0.01f); + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 1; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.flags |= ACTOR_FLAG_8000000; + this->pathLocation = LOOKNUTS_GET_PATROL_LOCATION(&this->actor); + this->switchFlag = LOOKNUTS_GET_SCENE_FLAG(&this->actor); + this->spawnIndex = LOOKNUTS_GET_SPAWN_INDEX(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/EnLookNuts_Init.s") + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } + if ((this->switchFlag >= 0) && (Flags_GetSwitch(globalCtx, this->switchFlag))) { + Actor_MarkForDeath(&this->actor); + return; + } + if (this->pathLocation == 0x1F) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/EnLookNuts_Destroy.s") + this->state = PALACE_GUARD_PATROLLING; + EnLookNuts_SetupPatrol(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67A34.s") +void EnLookNuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnLookNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67AA8.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67C48.s") +void EnLookNuts_SetupPatrol(EnLookNuts* this) { + Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 0, -10.0f); + this->state = PALACE_GUARD_PATROLLING; + this->actionFunc = EnLookNuts_Patrol; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67D0C.s") +void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx) { + f32 sp34 = 0.0f; + f32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67F30.s") + SkelAnime_Update(&this->skelAnime); + if (func_801690CC(globalCtx) != 0) { + this->actor.speedXZ = 0.0f; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67FC4.s") + this->actor.speedXZ = 2.0f; + if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A68080.s") + if (D_80A6862C != 0) { + Math_ApproachZeroF(&this->actor.speedXZ, 0.3f, 1.0f); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A680FC.s") + this->path = func_8013D648(globalCtx, this->pathLocation, 0x1F); + if (this->path != NULL) { + sp34 = func_8013D83C(this->path, this->currentPathIndex, &this->actor.world.pos, &sp30); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/EnLookNuts_Update.s") + if (sp30 < 10.0f) { + if (this->path != NULL) { + this->currentPathIndex++; + if (this->currentPathIndex >= this->path->count) { + this->currentPathIndex = 0; + } + if (Rand_ZeroOne() < 0.6f) { + EnLookNuts_SetupStandAndWait(this); + return; + } + } + } + Math_SmoothStepToS(&this->actor.shape.rot.y, sp34, 1, 0x1388, 0); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/EnLookNuts_Draw.s") +void EnLookNuts_SetupStandAndWait(EnLookNuts* this) { + Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 2, -10.0f); + this->waitTimer = Rand_S16Offset(1, 3); + this->headRotTarget.y = 10000.0f; + + if (Rand_ZeroOne() < 0.5f) { + this->headRotTarget.y = -10000.0f; + } + this->eventTimer = 10; + this->state = PALACE_GUARD_WAITING; + this->actionFunc = EnLookNuts_StandAndWait; +} + +// Patrol Guards will stand in place and wait for a maximum of ~12 frames. +void EnLookNuts_StandAndWait(EnLookNuts* this, GlobalContext* globalCtx) { + s16 randOffset; + + SkelAnime_Update(&this->skelAnime); + Math_ApproachZeroF(&this->actor.speedXZ, 0.3f, 1.0f); + if ((func_801690CC(globalCtx) == 0) && (D_80A6862C == 0) && (this->eventTimer == 0)) { + this->eventTimer = 10; + switch (this->waitTimer) { + case 0: + case 1: + case 2: + case 3: + case 4: + this->waitTimer++; + this->headRotTarget.y *= -1.0f; + break; + case 5: + this->headRotTarget.y = 0.0f; + randOffset = Rand_S16Offset(1, 2); + this->eventTimer = 0; + this->waitTimer += randOffset; + break; + case 6: + if (fabsf(this->headRotTarget.y - this->headRotation.y) < 10.0f) { + this->waitTimer = 10; + this->headRotTarget.x = 4000.0f; + this->eventTimer = 5; + } + break; + case 7: + if (fabsf(this->headRotTarget.y - this->headRotation.y) < 10.0f) { + this->headRotTarget.z = 4000.0f; + this->waitTimer++; + } + break; + case 8: + this->waitTimer = 10; + this->eventTimer = 20; + this->headRotTarget.z = -8000.0f; + break; + case 10: + Math_Vec3f_Copy(&this->headRotTarget, &gZeroVec3f); + this->waitTimer = 11; + break; + case 11: + if ((fabsf(this->headRotation.x) < 30.0f) && (fabsf(this->headRotation.y) < 30.0f) && + (fabsf(this->headRotation.z) < 30.0f)) { + this->waitTimer = 12; + } + break; + } + if (this->waitTimer == 12) { + this->waitTimer = 0; + EnLookNuts_SetupPatrol(this); + } + } +} + +void EnLookNuts_DetectedPlayer(EnLookNuts* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 2.0f, 0.0f, + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 0, -10.0f); + this->state = PALACE_GUARD_RUNNING_TO_PLAYER; + this->eventTimer = 300; + Message_StartTextbox(globalCtx, 0x833, &this->actor); + this->actionFunc = EnLookNuts_RunToPlayer; +} + +void EnLookNuts_RunToPlayer(EnLookNuts* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + } + + this->actor.speedXZ = 4.0f; + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); + if ((this->actor.xzDistToPlayer < 70.0f) || (this->eventTimer == 0)) { + this->actor.speedXZ = 0.0f; + EnLookNuts_SetupSendPlayerToSpawn(this); + } +} + +void EnLookNuts_SetupSendPlayerToSpawn(EnLookNuts* this) { + Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 2, -10.0f); + this->state = PALACE_GUARD_CAUGHT_PLAYER; + this->actionFunc = EnLookNuts_SendPlayerToSpawn; +} + +void EnLookNuts_SendPlayerToSpawn(EnLookNuts* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + globalCtx->nextEntranceIndex = Entrance_CreateIndexFromSpawn(this->spawnIndex); + gSaveContext.nextCutsceneIndex = 0; + Scene_SetExitFade(globalCtx); + globalCtx->sceneLoadFlag = 0x14; + gSaveContext.weekEventReg[17] |= 4; + } +} + +static Vec3f effectVecInitialize = { 0.0f, 0.0f, 0.0f }; + +void EnLookNuts_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnLookNuts* this = THIS; + Vec3f effectVelOffset; + Vec3f effectPos; + Vec3f effectVel; + + if (this->blinkTimer == 0) { + this->eyeState++; + if (this->eyeState >= 3) { + this->eyeState = 0; + this->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + this->actionFunc(this, globalCtx); + if (this->blinkTimer != 0) { + this->blinkTimer--; + } + if (this->eventTimer != 0) { + this->eventTimer--; + } + Actor_MoveWithGravity(&this->actor); + if (D_80A6862C == 0) { + if ((this->state < 2) && (this->actor.xzDistToPlayer < 320.0f) && (this->actor.playerHeightRel < 80.0f)) { + effectVelOffset = effectVecInitialize; + Math_Vec3f_Copy(&effectPos, &this->actor.world.pos); + effectPos.x += Math_SinS((this->actor.world.rot.y + (s16)this->headRotation.y)) * 10.0f; + effectPos.y += 30.0f; + effectPos.z += Math_CosS((this->actor.world.rot.y + (s16)this->headRotation.y)) * 10.0f; + Matrix_StatePush(); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + effectVelOffset.z = 20.0f; + Matrix_MultiplyVector3fByState(&effectVelOffset, &effectVel); + Matrix_StatePop(); + if (!this->isPlayerDetected) { + s16 drawFlag = 1; + if (gSaveContext.isNight) { + drawFlag = 0; + } + if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) { + EffectSsSolderSrchBall_Spawn(globalCtx, &effectPos, &effectVel, &gZeroVec3f, 50, + &this->isPlayerDetected, drawFlag); + } + } + + if ((this->isPlayerDetected == true) || (this->actor.xzDistToPlayer < 20.0f)) { + Player* player = GET_PLAYER(globalCtx); + + if (!(player->stateFlags3 & 0x100) && !func_801690CC(globalCtx)) { + Math_Vec3f_Copy(&this->headRotTarget, &gZeroVec3f); + this->state = PALACE_GUARD_RUNNING_TO_PLAYER; + play_sound(NA_SE_SY_FOUND); + func_800B7298(globalCtx, &this->actor, 0x1A); + D_80A6862C = 1; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_10); + this->actor.gravity = 0.0f; + EnLookNuts_DetectedPlayer(this, globalCtx); + } else { + this->isPlayerDetected = false; + } + } + } + Math_ApproachF(&this->headRotation.x, this->headRotTarget.x, 1.0f, 3000.0f); + Math_ApproachF(&this->headRotation.y, this->headRotTarget.y, 1.0f, 6000.0f); + Math_ApproachF(&this->headRotation.z, this->headRotTarget.z, 1.0f, 2000.0f); + this->actor.shape.rot.y = this->actor.world.rot.y; + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +static TexturePtr sEyeTextures[] = { + gDekuPalaceGuardEyeOpenTex, + gDekuPalaceGuardEyeHalfTex, + gDekuPalaceGuardEyeClosedTex, +}; + +void EnLookNuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnLookNuts* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeState])); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h index cb011be7a..c06f0e2cd 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h @@ -2,16 +2,37 @@ #define Z_EN_LOOK_NUTS_H #include "global.h" +#include "objects/object_dnk/object_dnk.h" struct EnLookNuts; typedef void (*EnLookNutsActionFunc)(struct EnLookNuts*, GlobalContext*); +#define LOOKNUTS_GET_SPAWN_INDEX(thisx) (((thisx)->params >> 0xC) & 0xF) +#define LOOKNUTS_GET_SCENE_FLAG(thisx) ((thisx)->params & 0x7F) +#define LOOKNUTS_GET_PATROL_LOCATION(thisx) (((thisx)->params >> 0x7) & 0x1F) + typedef struct EnLookNuts { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC8]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[OBJECT_DNK_LIMB_MAX]; + /* 0x01CA */ Vec3s morphTable[OBJECT_DNK_LIMB_MAX]; /* 0x020C */ EnLookNutsActionFunc actionFunc; - /* 0x0210 */ char unk_210[0x80]; + /* 0x0210 */ Path *path; + /* 0x0214 */ s16 currentPathIndex; // Index for the point where the deku guard is in its path + /* 0x0216 */ s16 eyeState; + /* 0x0218 */ s16 blinkTimer; + /* 0x021A */ s16 eventTimer; // Timer to trigger when another event within the actor will happen + /* 0x021C */ s16 state; + /* 0x021E */ s16 switchFlag; + /* 0x0220 */ s16 pathLocation; // Determines path that a guard will patrol + /* 0x0222 */ s16 isPlayerDetected; + /* 0x0224 */ s16 waitTimer; // Timer for how long the deku guard will take a break for + /* 0x0226 */ s16 spawnIndex; + /* 0x0228 */ UNK_TYPE4 pad228; // Unused necessary padding + /* 0x022C */ Vec3f headRotation; + /* 0x0238 */ Vec3f headRotTarget; // Target value for head rotation + /* 0x0244 */ ColliderCylinder collider; } EnLookNuts; // size = 0x290 extern const ActorInit En_Look_Nuts_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 538521a08..e0322d4ad 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10845,14 +10845,14 @@ 0x80A675C4:("ObjDriftice_Draw",), 0x80A678B0:("EnLookNuts_Init",), 0x80A67A08:("EnLookNuts_Destroy",), - 0x80A67A34:("func_80A67A34",), + 0x80A67A34:("EnLookNuts_SetupPatrol",), 0x80A67AA8:("func_80A67AA8",), - 0x80A67C48:("func_80A67C48",), - 0x80A67D0C:("func_80A67D0C",), + 0x80A67C48:("EnLookNuts_SetupStandAndWait",), + 0x80A67D0C:("EnLookNuts_StandAndWait",), 0x80A67F30:("func_80A67F30",), 0x80A67FC4:("func_80A67FC4",), - 0x80A68080:("func_80A68080",), - 0x80A680FC:("func_80A680FC",), + 0x80A68080:("EnLookNuts_SetupSendPlayerToSpawn",), + 0x80A680FC:("EnLookNuts_SendPlayerToSpawn",), 0x80A681C4:("EnLookNuts_Update",), 0x80A68540:("EnLookNuts_Draw",), 0x80A687A0:("func_80A687A0",), diff --git a/undefined_syms.txt b/undefined_syms.txt index a701f116e..776e6c538 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1550,12 +1550,6 @@ D_060002E0 = 0x060002E0; D_060029E8 = 0x060029E8; D_0600AC70 = 0x0600AC70; -// ovl_En_Look_Nuts - -D_06000430 = 0x06000430; -D_06002848 = 0x06002848; -D_06002B6C = 0x06002B6C; - // ovl_En_Mag D_06000000 = 0x06000000; From cbfa42c07045a0676c84c749d6bb2462cd555077 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Thu, 24 Mar 2022 18:28:03 -0700 Subject: [PATCH 095/257] En_Mt_tag OK and documented (Goron Race Manager) (#659) * EnMttag_Init OK * EnMttag_Destroy OK * EnMttag_Update OK * func_809CF9A0 OK * Update struct * func_809CF444 OK * func_809CFA00 OK * func_809CF394 OK * func_809CF8EC OK * func_809CFA54 OK * func_809CF350 OK * func_809CF848 OK * func_809CF950 OK * func_809CFBC4 OK * func_809CFD98 OK * func_809CFE28 OK * func_809CFF94 OK * func_809CFC38 OK * Get super close on func_809CF4EC * Import data * Get a start on func_809CF67C * func_809CF4EC OK, thanks engineer! * func_809CF67C OK, thanks engineer! * Use the generated reloc * Name message functions and raceGorons array * Name some more stuff * Name more functions * Name most functions * Take a stab at trying to figure out what the data represents * Much better naming and understanding * Name more * Strip out debugging junk * Better name * Name the rest of the variables * Describe bug * Document the h*ck out of things * Simplify PlayerCheatStatus a bit * Use sCheckpointPositions as per engineer's advice * Do some really stupid naming nonsense to explain the side effect of a function * Fix Racing/RaceGoron inconsistency * Decimal weekEventReg accesses * Rename to EnMttag_UpdateCheckPoints * Capitalization consistency + update functions.txt * Respond to review * Respond to review * Respond to Elliptic's review * idk if Elliptic meant the function name or the variable so let's just do both lol * Fix function name changed by z_demo merge --- spec | 3 +- .../actors/ovl_En_Mt_tag/z_en_mt_tag.c | 493 +++++++++++++++++- .../actors/ovl_En_Mt_tag/z_en_mt_tag.h | 11 +- src/overlays/actors/ovl_En_Rg/z_en_rg.c | 8 +- src/overlays/actors/ovl_En_Rg/z_en_rg.h | 2 +- tools/disasm/functions.txt | 32 +- 6 files changed, 495 insertions(+), 54 deletions(-) diff --git a/spec b/spec index c511193f4..95e6cbee7 100644 --- a/spec +++ b/spec @@ -2481,8 +2481,7 @@ beginseg name "ovl_En_Mt_tag" compress include "build/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.o" - include "build/data/ovl_En_Mt_tag/ovl_En_Mt_tag.data.o" - include "build/data/ovl_En_Mt_tag/ovl_En_Mt_tag.reloc.o" + include "build/src/overlays/actors/ovl_En_Mt_tag/ovl_En_Mt_tag_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c index d74f32926..9bd5b084b 100644 --- a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c +++ b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c @@ -14,15 +14,20 @@ void EnMttag_Init(Actor* thisx, GlobalContext* globalCtx); void EnMttag_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMttag_Update(Actor* thisx, GlobalContext* globalCtx); -void func_809CF9A0(EnMttag* this, GlobalContext* globalCtx); -void func_809CFA00(EnMttag* this, GlobalContext* globalCtx); -void func_809CFA54(EnMttag* this, GlobalContext* globalCtx); -void func_809CFC38(EnMttag* this, GlobalContext* globalCtx); -void func_809CFD98(EnMttag* this, GlobalContext* globalCtx); -void func_809CFE28(EnMttag* this, GlobalContext* globalCtx); -void func_809CFF94(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_ShowIntroCutscene(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_WaitForIntroCutsceneToEnd(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_RaceStart(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_Race(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_RaceFinish(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_PotentiallyRestartRace(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_HandleCantWinChoice(EnMttag* this, GlobalContext* globalCtx); + +typedef enum { + GORON_RACE_CHEAT_NO_CHEATING, + GORON_RACE_CHEAT_FALSE_START, + GORON_RACE_CHEAT_TRYING_TO_REACH_GOAL_FROM_BEHIND, +} PlayerCheatStatus; -#if 0 const ActorInit En_Mt_tag_InitVars = { ACTOR_EN_MT_TAG, ACTORCAT_BG, @@ -35,42 +40,474 @@ const ActorInit En_Mt_tag_InitVars = { (ActorFunc)NULL, }; -#endif +static s32 sStartingCheckpointPerSceneExitIndex[] = { + 0, 0, 0, 0, 1, 9, 12, 16, 19, 22, 26, 29, 30, 32, 34, 36, 39, 42, 45, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF350.s") +// The Y-positions here are never used by any part of this actor. +static Vec3f sCheckpointPositions[] = { + { -105.0f, 1000.0f, -240.0f }, { -1751.0f, 1000.0f, -240.0f }, { -3138.0f, 1000.0f, -74.0f }, + { -4617.0f, 1000.0f, 277.0f }, { -5060.0f, 1000.0f, 388.0f }, { -5412.0f, 1000.0f, 573.0f }, + { -5523.0f, 1000.0f, 1035.0f }, { -5393.0f, 1000.0f, 1405.0f }, { -5060.0f, 1000.0f, 1553.0f }, + { -3933.0f, 1000.0f, 1479.0f }, { -3212.0f, 1000.0f, 1461.0f }, { -2805.0f, 1000.0f, 1645.0f }, + { -2638.0f, 1000.0f, 2071.0f }, { -2823.0f, 1000.0f, 2422.0f }, { -3212.0f, 1000.0f, 2607.0f }, + { -3785.0f, 1000.0f, 2977.0f }, { -4321.0f, 1000.0f, 3501.0f }, { -4654.0f, 1000.0f, 4185.0f }, + { -4802.0f, 1000.0f, 4779.0f }, { -4672.0f, 1000.0f, 5426.0f }, { -4339.0f, 1000.0f, 6037.0f }, + { -3748.0f, 1000.0f, 6314.0f }, { -2749.0f, 1000.0f, 6478.0f }, { -2453.0f, 1000.0f, 6922.0f }, + { -2269.0f, 1000.0f, 7754.0f }, { -2453.0f, 1000.0f, 8309.0f }, { -3008.0f, 1000.0f, 8438.0f }, + { -3304.0f, 1000.0f, 8179.0f }, { -3600.0f, 1000.0f, 7606.0f }, { -3600.0f, 1000.0f, 6885.0f }, + { -3618.0f, 1000.0f, 4392.0f }, { -3600.0f, 1000.0f, 3855.0f }, { -3396.0f, 1000.0f, 3189.0f }, + { -3396.0f, 1000.0f, 2283.0f }, { -3600.0f, 1000.0f, 818.0f }, { -3803.0f, 1000.0f, -88.0f }, + { -4543.0f, 1000.0f, -2457.0f }, { -4543.0f, 1000.0f, -2938.0f }, { -4543.0f, 1000.0f, -3530.0f }, + { -4284.0f, 1000.0f, -4333.0f }, { -3581.0f, 1000.0f, -4795.0f }, { -2805.0f, 1000.0f, -4850.0f }, + { -1825.0f, 1000.0f, -4703.0f }, { -1326.0f, 1000.0f, -4166.0f }, { -1122.0f, 1000.0f, -3186.0f }, + { -1085.0f, 1000.0f, -2059.0f }, { -1067.0f, 1000.0f, -912.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF394.s") +/** + * Returns true if the specified position is in the finish line. + * The range extends a little bit beyond the finish line's in-game visual. + */ +s32 EnMttag_IsInFinishLine(Vec3f* pos) { + return Math3D_XZBoundCheck(-1261.0f, -901.0f, -1600.0f, -1520.0f, pos->x, pos->z); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF444.s") +/** + * Returns a value in PlayerCheatStatus that indicates if the player is cheating + * and, if so, what kind of cheating the player is performing. + */ +s32 EnMttag_CheckPlayerCheatStatus(Vec3f* pos) { + if (!(gSaveContext.eventInf[1] & 1)) { + if (Math3D_XZBoundCheck(-466.0f, -386.0f, -687.0f, 193.0f, pos->x, pos->z)) { + // The race hasn't started yet, but the player is beyond the starting line. + return GORON_RACE_CHEAT_FALSE_START; + } + } else if (Math3D_XZBoundCheck(-1127.0f, -1007.0f, -867.0f, -787.0f, pos->x, pos->z)) { + // The goal is actually quite close to the start, just behind a large wall. + // This checks if the player is in an area "behind" the goal that is not accessible + // in normal play; it can only be reached by climbing the wall somehow. Perhaps they + // were worried that players would find a way to climb the wall with a glitch, or + // perhaps they just wanted to punish people using cheat codes. + return GORON_RACE_CHEAT_TRYING_TO_REACH_GOAL_FROM_BEHIND; + } + return GORON_RACE_CHEAT_NO_CHEATING; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF4EC.s") +/** + * This function tries to find all four Race Gorons present in the racetrack. + * If it finds them, it stores a pointer to each one in the actor's struct. + * Returns true if all four Race Gorons are found. + */ +s32 EnMttag_AreFourRaceGoronsPresent(EnMttag* this, GlobalContext* globalCtx) { + Actor* actor = NULL; + s32 i = 0; + s32 areGoronsPresent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF67C.s") + do { + actor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_RG); + if (actor != NULL) { + this->raceGorons[i] = (EnRg*)actor; + i++; + } else if ((actor == NULL) || (actor->next == NULL)) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF848.s") + actor = actor->next; + } while (i < ARRAY_COUNT(this->raceGorons)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF8EC.s") + if (i < ARRAY_COUNT(this->raceGorons)) { + areGoronsPresent = false; + } else { + areGoronsPresent = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF950.s") + return areGoronsPresent; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF9A0.s") +/** + * Returns the checkpoint number for the supplied actor. + * At the start of the race, all race entrants are at checkpoint 1, and their + * checkpoint number gradually increases as they move forward through the racetrack. + * The player can have a checkpoint number of -1 if they move far enough backwards + * from the starting line. + */ +s32 EnMttag_GetCurrentCheckpoint(Actor* actor, GlobalContext* globalCtx, s32* upcomingCheckpoint, + f32* outPerpendicularPointX, f32* outPerpendicularPointZ) { + s32 curentCheckpoint = -1; + s32 hasSetCurrentCheckpointOnce = false; + f32 minLineLengthSq = 0.0f; + s32 sceneExitIndex; + f32 perpendicularPointX; + f32 perpendicularPointZ; + f32 lineLenSq; + s32 checkpointIterator; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFA00.s") + // The Goron Racetrack is configured such that the sceneExitIndex for any given floor polygon + // gradually increases as you move forward through the racetrack. + sceneExitIndex = SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, actor->floorPoly, actor->floorBgId); + if ((sceneExitIndex < 4) || (sceneExitIndex >= 19)) { + //! @bug - upcomingCheckpoint is not initialized here + return -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFA54.s") + checkpointIterator = sStartingCheckpointPerSceneExitIndex[sceneExitIndex]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFBC4.s") + // Iterates through all possible checkpoints that are associated with this sceneExitIndex. + do { + if ((Math3D_PointDistToLine2D( + actor->world.pos.x, actor->world.pos.z, (&sCheckpointPositions[checkpointIterator])[-1].x, + (&sCheckpointPositions[checkpointIterator])[-1].z, (&sCheckpointPositions[checkpointIterator])[1].x, + (&sCheckpointPositions[checkpointIterator])[1].z, &perpendicularPointX, &perpendicularPointZ, + &lineLenSq)) && + (!hasSetCurrentCheckpointOnce || ((curentCheckpoint + 1) == checkpointIterator) || + (lineLenSq < minLineLengthSq))) { + minLineLengthSq = lineLenSq; + curentCheckpoint = checkpointIterator; + *outPerpendicularPointX = perpendicularPointX; + *outPerpendicularPointZ = perpendicularPointZ; + hasSetCurrentCheckpointOnce = true; + } + checkpointIterator++; + } while (checkpointIterator < sStartingCheckpointPerSceneExitIndex[sceneExitIndex + 1]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFC38.s") + *upcomingCheckpoint = curentCheckpoint + 1; + return curentCheckpoint; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFD98.s") +/** + * Returns true if the player is almost certainly going to lose the race. + * Specifically, it checks if the player's current checkpoint is 24 or more + * checkpoints behind the leading racer. This value was probably chosen because + * falling off the wooden bridge in the middle of the track can set the player + * back up to 23 checkpoints. + * + * This function also has the side effect of updating the number of checkpoints + * ahead of the player each Race Goron is. + */ +s32 EnMttag_UpdateCheckpoints(EnMttag* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnRg* rg; + s32 currentCheckpoints[5]; + s32 upcomingCheckpoints[5]; + f32 perpendicularPointsX[5]; + f32 perpendicularPointsZ[5]; + s32 highestCurrentCheckpoint; + s32 i; + s32 playerIsLikelyToLose = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFE28.s") + highestCurrentCheckpoint = -1; + currentCheckpoints[0] = EnMttag_GetCurrentCheckpoint(&player->actor, globalCtx, &upcomingCheckpoints[0], + &perpendicularPointsX[0], &perpendicularPointsZ[0]); + for (i = 1; i < ARRAY_COUNT(this->raceGorons) + 1; i++) { + currentCheckpoints[i] = + EnMttag_GetCurrentCheckpoint(&this->raceGorons[i - 1]->actor, globalCtx, &upcomingCheckpoints[i], + &perpendicularPointsX[i], &perpendicularPointsZ[i]); + if (highestCurrentCheckpoint < currentCheckpoints[i]) { + highestCurrentCheckpoint = currentCheckpoints[i]; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFF94.s") + for (i = 1; i < ARRAY_COUNT(this->raceGorons) + 1; i++) { + rg = this->raceGorons[i - 1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/EnMttag_Init.s") + // Because of the bug described in EnMttag_GetCurrentCheckpoint, these values may not be initialized. + //! @bug When initialized, this check is pointless because upcomingCheckpoint is always 0 or higher. + if ((upcomingCheckpoints[i] != -1) && (upcomingCheckpoints[0] != -1)) { + rg->numCheckpointsAheadOfPlayer = (upcomingCheckpoints[i] - upcomingCheckpoints[0]); + } else { + rg->numCheckpointsAheadOfPlayer = 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/EnMttag_Destroy.s") + if ((currentCheckpoints[0] > 0) && (currentCheckpoints[0] < highestCurrentCheckpoint) && + (player->actor.bgCheckFlags & 1) && ((highestCurrentCheckpoint - currentCheckpoints[0]) >= 24)) { + playerIsLikelyToLose = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/EnMttag_Update.s") + return playerIsLikelyToLose; +} + +/** + * Exits the race and returns the player back to "normal" gameplay. + * Whether the player won or lost the race is determined by arg1 and nextTransition. + */ +s32 EnMttag_ExitRace(GlobalContext* globalCtx, s32 arg1, s32 nextTransition) { + CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; + globalCtx->nextEntranceIndex = 0xD020; + if ((gSaveContext.weekEventReg[33] & 0x80)) { + // Spring + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // Winter + gSaveContext.nextCutsceneIndex = 0; + } + + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = arg1; + gSaveContext.nextTransition = nextTransition; + func_801477B4(globalCtx); + return 1; +} + +/** + * Displays the text which says that the player has made a false start. + */ +void EnMttag_ShowFalseStartMessage(EnMttag* this, GlobalContext* globalCtx) { + gSaveContext.unk_3DD0[4] = 0; + Message_StartTextbox(globalCtx, 0xE95, NULL); // An entrant made a false start + func_800B7298(globalCtx, &this->actor, 7); + Audio_QueueSeqCmd(0x101400FF); + this->actionFunc = EnMttag_PotentiallyRestartRace; +} + +/** + * Displays the text from the Goron Elder's child which tells the player that + * they probably can't win the race. + */ +void EnMttag_ShowCantWinMessage(EnMttag* this, GlobalContext* globalCtx) { + Message_StartTextbox(globalCtx, 0xE97, NULL); // You can't win now... + func_800B7298(globalCtx, &this->actor, 7); + this->actionFunc = EnMttag_HandleCantWinChoice; +} + +/** + * Shows the cutscene that pans over the race track and shows all five race entrants. + */ +void EnMttag_ShowIntroCutscene(EnMttag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actionFunc = EnMttag_WaitForIntroCutsceneToEnd; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +/** + * When the intro cutscene concludes, this sets the weekEventReg to prevent it + * from showing again and starts the race. + */ +void EnMttag_WaitForIntroCutsceneToEnd(EnMttag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { + gSaveContext.weekEventReg[12] |= 2; + this->actionFunc = EnMttag_RaceStart; + } +} + +/** + * Handles the race from when the Gorons are first lined up at the + * starting block to when the countdown finishes. + */ +void EnMttag_RaceStart(EnMttag* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 playerCheatStatus; + + if (this->raceInitialized == true) { + playerCheatStatus = EnMttag_CheckPlayerCheatStatus(&player->actor.world.pos); + if (playerCheatStatus != GORON_RACE_CHEAT_NO_CHEATING) { + if (playerCheatStatus == GORON_RACE_CHEAT_FALSE_START) { + this->shouldRestartRace = true; + } else { + this->shouldRestartRace = false; + } + + EnMttag_ShowFalseStartMessage(this, globalCtx); + gSaveContext.eventInf[1] |= 8; + } else { + if (DECR(this->timer) == 60) { + func_8010E9F0(4, 0); + globalCtx->interfaceCtx.unk_280 = 1; + Audio_QueueSeqCmd(NA_BGM_GORON_RACE | 0x8000); + globalCtx->envCtx.unk_E4 = 0xFE; + player->stateFlags1 &= ~0x20; + } else if ((this->timer < 60) && (globalCtx->interfaceCtx.unk_280 == 8)) { + this->timer = 0; + gSaveContext.eventInf[1] |= 1; + this->actionFunc = EnMttag_Race; + } + } + } else { + if (EnMttag_AreFourRaceGoronsPresent(this, globalCtx)) { + this->raceInitialized = true; + } + } +} + +/** + * Returns true if any Race Goron is over the finish line. + */ +s32 EnMttag_IsAnyRaceGoronOverFinishLine(EnMttag* this) { + s32 isAnyRaceGoronOverFinishLine = false; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->raceGorons); i++) { + if ((EnMttag_IsInFinishLine(&this->raceGorons[i]->actor.world.pos)) && + (this->raceGorons[i]->actor.update != NULL)) { + isAnyRaceGoronOverFinishLine = true; + break; + } + } + return isAnyRaceGoronOverFinishLine; +} + +/** + * Handles the race from when the countdown finishes to when + * any race entrant crosses the finish line. + */ +void EnMttag_Race(EnMttag* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f* playerPos = &player->actor.world.pos; + s32 playerCheatStatus; + + if (EnMttag_IsInFinishLine(playerPos)) { + gSaveContext.unk_3DD0[4] = 6; + play_sound(NA_SE_SY_START_SHOT); + Audio_QueueSeqCmd(NA_BGM_GORON_GOAL | 0x8000); + this->timer = 55; + gSaveContext.eventInf[1] |= 2; + this->actionFunc = EnMttag_RaceFinish; + } else if (EnMttag_IsAnyRaceGoronOverFinishLine(this)) { + gSaveContext.unk_3DD0[4] = 6; + play_sound(NA_SE_SY_START_SHOT); + Audio_QueueSeqCmd(NA_BGM_GORON_GOAL | 0x8000); + this->timer = 55; + gSaveContext.eventInf[1] |= 4; + this->actionFunc = EnMttag_RaceFinish; + } else { + playerCheatStatus = EnMttag_CheckPlayerCheatStatus(playerPos); + if (playerCheatStatus != GORON_RACE_CHEAT_NO_CHEATING) { + if (playerCheatStatus == GORON_RACE_CHEAT_FALSE_START) { + this->shouldRestartRace = true; + } else { + this->shouldRestartRace = false; + } + + EnMttag_ShowFalseStartMessage(this, globalCtx); + gSaveContext.eventInf[1] |= 8; + } else if ((EnMttag_UpdateCheckpoints(this, globalCtx)) && (this->timer == 0)) { + EnMttag_ShowCantWinMessage(this, globalCtx); + gSaveContext.eventInf[1] |= 8; + } + } +} + +/** + * Handles the race after any race entrant crosses the finish line. + * This function simply waits for a bit before exiting the race. + */ +void EnMttag_RaceFinish(EnMttag* this, GlobalContext* globalCtx) { + if (DECR(this->timer) == 0) { + if ((gSaveContext.eventInf[1] & 2)) { + // Player won + EnMttag_ExitRace(globalCtx, 3, 3); + } else { + // A non-player Goron won + EnMttag_ExitRace(globalCtx, 2, 2); + } + + Actor_MarkForDeath(&this->actor); + } +} + +/** + * Restarts the race if this->shouldRestartRace is true. Otherwise, it exits the race. + * In practice, the only time this exits the race is if the player tries to cheat by + * reaching the goal from behind. + */ +void EnMttag_PotentiallyRestartRace(EnMttag* this, GlobalContext* globalCtx) { + u8 talkState = Message_GetState(&globalCtx->msgCtx); + + if (((talkState == 5 && func_80147624(globalCtx)) || talkState == 2)) { + if (this->shouldRestartRace) { + globalCtx->nextEntranceIndex = 0xD010; + + if (gSaveContext.weekEventReg[33] & 0x80) { + // Spring + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // Winter + gSaveContext.nextCutsceneIndex = 0; + } + + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 2; + gSaveContext.nextTransition = 2; + func_801477B4(globalCtx); + func_800B7298(globalCtx, &this->actor, 7); + Parameter_AddMagic(globalCtx, ((void)0, gSaveContext.unk_3F30) + (gSaveContext.doubleMagic * 48) + 48); + + gSaveContext.eventInf[1] &= (u8)~1; + gSaveContext.eventInf[1] &= (u8)~2; + gSaveContext.eventInf[1] &= (u8)~4; + gSaveContext.eventInf[1] &= (u8)~8; + gSaveContext.eventInf[2] = ((gSaveContext.eventInf[2] & 0xF) + 1) | (gSaveContext.eventInf[2] & 0xF0); + } else { + EnMttag_ExitRace(globalCtx, 2, 2); + } + Actor_MarkForDeath(&this->actor); + } +} + +/** + * This function either exits the race or resumes it based on how the player + * responded to the Goron Elder's son's question. + */ +void EnMttag_HandleCantWinChoice(EnMttag* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && (func_80147624(globalCtx))) { + if (globalCtx->msgCtx.choiceIndex != 0) { + // Exit the race + func_8019F230(); + gSaveContext.unk_3DD0[4] = 0; + EnMttag_ExitRace(globalCtx, 2, 2); + gSaveContext.eventInf[1] &= (u8)~8; + gSaveContext.eventInf[1] |= 4; + Actor_MarkForDeath(&this->actor); + } else { + // Keep racing + func_8019F208(); + func_801477B4(globalCtx); + func_800B7298(globalCtx, &this->actor, 6); + gSaveContext.eventInf[1] &= (u8)~8; + this->timer = 100; + this->actionFunc = EnMttag_Race; + } + } +} + +void EnMttag_Init(Actor* thisx, GlobalContext* globalCtx) { + Player* player; + EnMttag* this = THIS; + + if (gSaveContext.entranceIndex == 0xD010) { + player = GET_PLAYER(globalCtx); + player->stateFlags1 |= 0x20; + this->raceInitialized = false; + this->timer = 100; + + gSaveContext.eventInf[1] &= (u8)~1; + gSaveContext.eventInf[1] &= (u8)~2; + gSaveContext.eventInf[1] &= (u8)~4; + gSaveContext.eventInf[1] &= (u8)~8; + + if (!(gSaveContext.weekEventReg[12] & 2)) { + this->actionFunc = EnMttag_ShowIntroCutscene; + } else { + s32 requiredScopeTemp; + + this->actionFunc = EnMttag_RaceStart; + } + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void EnMttag_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMttag* this = THIS; + if (gSaveContext.unk_3DD0[4] != 6) { + gSaveContext.unk_3DD0[4] = 5; + } +} + +void EnMttag_Update(Actor* thisx, GlobalContext* globalCtx) { + EnMttag* this = THIS; + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.h b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.h index 796482b14..796dff17a 100644 --- a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.h +++ b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.h @@ -2,15 +2,20 @@ #define Z_EN_MT_TAG_H #include "global.h" +#include "overlays/actors/ovl_En_Rg/z_en_rg.h" struct EnMttag; typedef void (*EnMttagActionFunc)(struct EnMttag*, GlobalContext*); typedef struct EnMttag { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnMttagActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x20]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnMttagActionFunc actionFunc; + /* 0x148 */ EnRg* raceGorons[4]; + /* 0x158 */ u16 raceInitialized; + /* 0x15A */ s16 timer; + /* 0x15C */ UNK_TYPE1 unk_15C[0x8]; + /* 0x164 */ s32 shouldRestartRace; } EnMttag; // size = 0x168 extern const ActorInit En_Mt_tag_InitVars; diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index f8fd33a27..b7d4f5d5d 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -477,11 +477,11 @@ s32 func_80BF47AC(EnRg* this, GlobalContext* globalCtx) { if ((this->unk_310 & 0x400) || (this->unk_310 & 0x1000)) { phi_f0 = 0.0f; - } else if (this->unk_348 >= 2) { + } else if (this->numCheckpointsAheadOfPlayer >= 2) { phi_f0 = phi_f2 * 0.5f; - } else if (this->unk_348 == 1) { + } else if (this->numCheckpointsAheadOfPlayer == 1) { phi_f0 = phi_f2 * 0.75f; - } else if (this->unk_348 == 0) { + } else if (this->numCheckpointsAheadOfPlayer == 0) { s16 temp_v0_3 = this->actor.yawTowardsPlayer - this->actor.world.rot.y; if ((ABS_ALT(temp_v0_3) > 0x4000) || (this->unk_326 > 0)) { @@ -489,7 +489,7 @@ s32 func_80BF47AC(EnRg* this, GlobalContext* globalCtx) { } else { phi_f0 = phi_f2 * 0.94f; } - } else if (this->unk_348 == -1) { + } else if (this->numCheckpointsAheadOfPlayer == -1) { phi_f0 = phi_f2 * 1.6f; } else { phi_f0 = 2.0f * phi_f2; diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.h b/src/overlays/actors/ovl_En_Rg/z_en_rg.h index 87f712fe8..9f7e60ba4 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.h +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.h @@ -48,7 +48,7 @@ typedef struct EnRg { /* 0x033C */ s32 unk_33C; /* 0x0340 */ s32 unk_340; /* 0x0344 */ s32 unk_344; - /* 0x0348 */ s32 unk_348; + /* 0x0348 */ s32 numCheckpointsAheadOfPlayer; /* 0x034C */ EnRgStruct unk_34C[32]; } EnRg; // size = 0xACC diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e0322d4ad..84ed84236 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -9198,22 +9198,22 @@ 0x809CEEAC:("func_809CEEAC",), 0x809CEF0C:("BgSpdweb_Update",), 0x809CEF30:("BgSpdweb_Draw",), - 0x809CF350:("func_809CF350",), - 0x809CF394:("func_809CF394",), - 0x809CF444:("func_809CF444",), - 0x809CF4EC:("func_809CF4EC",), - 0x809CF67C:("func_809CF67C",), - 0x809CF848:("func_809CF848",), - 0x809CF8EC:("func_809CF8EC",), - 0x809CF950:("func_809CF950",), - 0x809CF9A0:("func_809CF9A0",), - 0x809CFA00:("func_809CFA00",), - 0x809CFA54:("func_809CFA54",), - 0x809CFBC4:("func_809CFBC4",), - 0x809CFC38:("func_809CFC38",), - 0x809CFD98:("func_809CFD98",), - 0x809CFE28:("func_809CFE28",), - 0x809CFF94:("func_809CFF94",), + 0x809CF350:("EnMttag_IsInFinishLine",), + 0x809CF394:("EnMttag_CheckPlayerCheatStatus",), + 0x809CF444:("EnMttag_AreFourRaceGoronsPresent",), + 0x809CF4EC:("EnMttag_GetCurrentCheckpoint",), + 0x809CF67C:("EnMttag_UpdateCheckpoints",), + 0x809CF848:("EnMttag_ExitRace",), + 0x809CF8EC:("EnMttag_ShowFalseStartMessage",), + 0x809CF950:("EnMttag_ShowCantWinMessage",), + 0x809CF9A0:("EnMttag_ShowIntroCutscene",), + 0x809CFA00:("EnMttag_WaitForIntroCutsceneToEnd",), + 0x809CFA54:("EnMttag_RaceStart",), + 0x809CFBC4:("EnMttag_IsAnyRaceGoronOverFinishLine",), + 0x809CFC38:("EnMttag_Race",), + 0x809CFD98:("EnMttag_RaceFinish",), + 0x809CFE28:("EnMttag_PotentiallyRestartRace",), + 0x809CFF94:("EnMttag_HandleCantWinChoice",), 0x809D0090:("EnMttag_Init",), 0x809D0138:("EnMttag_Destroy",), 0x809D0168:("EnMttag_Update",), From 950f3a247e91621a4eececdcc04481faf3b46633 Mon Sep 17 00:00:00 2001 From: Parker Burnett Date: Thu, 24 Mar 2022 21:34:50 -0400 Subject: [PATCH 096/257] En_guard_nuts OK and Partially documented (#668) * guard_nuts OK * doing some documenting * more docs * more docs * minor changes * touch ups * format * pr feedback * fixing a name * ran actor_fixer --- spec | 3 +- .../ovl_En_Guard_Nuts/z_en_guard_nuts.c | 360 ++++++++++++++++-- .../ovl_En_Guard_Nuts/z_en_guard_nuts.h | 23 +- tools/disasm/functions.txt | 14 +- undefined_syms.txt | 6 - 5 files changed, 365 insertions(+), 41 deletions(-) diff --git a/spec b/spec index 95e6cbee7..f2ffda1d0 100644 --- a/spec +++ b/spec @@ -3325,8 +3325,7 @@ beginseg name "ovl_En_Guard_Nuts" compress include "build/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.o" - include "build/data/ovl_En_Guard_Nuts/ovl_En_Guard_Nuts.data.o" - include "build/data/ovl_En_Guard_Nuts/ovl_En_Guard_Nuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Guard_Nuts/ovl_En_Guard_Nuts_reloc.o" endseg beginseg 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 eefabdb3b..d1ad25092 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 @@ -15,7 +15,15 @@ void EnGuardNuts_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGuardNuts_Update(Actor* thisx, GlobalContext* globalCtx); void EnGuardNuts_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnGuardNuts_ChangeAnim(EnGuardNuts* this, s32 index); +void EnGuardNuts_SetupWait(EnGuardNuts* this); +void EnGuardNuts_Wait(EnGuardNuts* this, GlobalContext* globalCtx); +void func_80ABB540(EnGuardNuts* this); +void func_80ABB590(EnGuardNuts* this, GlobalContext* globalCtx); +void EnGuardNuts_Burrow(EnGuardNuts* this, GlobalContext* globalCtx); +void EnGuardNuts_SetupUnburrow(EnGuardNuts* this, GlobalContext* globalCtx); +void EnGuardNuts_Unburrow(EnGuardNuts* this, GlobalContext* globalCtx); + const ActorInit En_Guard_Nuts_InitVars = { ACTOR_EN_GUARD_NUTS, ACTORCAT_NPC, @@ -28,42 +36,350 @@ const ActorInit En_Guard_Nuts_InitVars = { (ActorFunc)EnGuardNuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80ABBDF0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON | OCELEM_UNK3, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON | OCELEM_UNK3, + }, { 50, 50, 0, { 0, 0, 0 } }, }; -#endif +s32 sGuardCount = 0; -extern ColliderCylinderInit D_80ABBDF0; +s32 D_80ABBE20 = 0; -extern UNK_TYPE D_06002700; -extern UNK_TYPE D_06002A08; +static u16 sTextIDs[] = { 0x0824, 0x0825, 0x0826, 0x082D, 0x0827, 0x0828, 0x0829, 0x082A, 0x082B, 0x082C }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/EnGuardNuts_Init.s") +s16 D_80ABBE38[] = { 0x0000, 0x0000, 0x0002, 0x0001, 0x0000, 0x0000, 0x0002, 0x0000, 0x0000, 0x0002 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/EnGuardNuts_Destroy.s") +static AnimationHeader* sAnimations[] = { + &gDekuPalaceGuardWaitAnim, + &gDekuPalaceGuardWalkAnim, + &gDekuPalaceGuardDigAnim, + &gDekuPalaceGuardWalkAnim, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB210.s") +static u8 sAnimModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB29C.s") +static TexturePtr sEyeTextures[] = { + gDekuPalaceGuardEyeOpenTex, + gDekuPalaceGuardEyeHalfTex, + gDekuPalaceGuardEyeClosedTex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB2D4.s") +typedef enum { + /* 0 */ WAIT_HEAD_TILT_ANIM, + /* 1 */ WALK_ANIM, + /* 2 */ DIG_ANIM, + /* 3 */ WALK_ANIM_2, +} EnGuardNutsAnim; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB540.s") +typedef enum { + /* 0 */ GUARD_NUTS_WAIT_STATE, + /* 1 */ GUARD_NUTS_TALKING_STATE, + /* 3 */ GUARD_NUTS_BURROWED_STATE = 3, + /* 4 */ GUARD_NUTS_UNK_STATE +} EnGuardNutsState; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB590.s") +void EnGuardNuts_Init(Actor* thisx, GlobalContext* globalCtx) { + EnGuardNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB854.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, &gDekuPalaceGuardWaitAnim, this->jointTable, + this->morphTable, OBJECT_DNK_LIMB_MAX); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 1; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Actor_SetScale(&this->actor, 0.015f); + Math_Vec3f_Copy(&this->guardPos, &this->actor.world.pos); + this->guardNumber = sGuardCount; + sGuardCount++; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB91C.s") + // If you have returned deku princess guards will init burrowed. + if (!(gSaveContext.weekEventReg[23] & 0x20)) { + EnGuardNuts_SetupWait(this); + } else { + EnGuardNuts_Burrow(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB990.s") +void EnGuardNuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGuardNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/EnGuardNuts_Update.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABBC60.s") +/** + * @brief Changes the animation to the provided index. Updates animIndex and animFrameCount for the animation. + * + * @param this + * @param index the index of sAnimations to change to + */ +void EnGuardNuts_ChangeAnim(EnGuardNuts* this, s32 index) { + this->animIndex = index; + this->animFrameCount = Animation_GetLastFrame(sAnimations[this->animIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->animFrameCount, + sAnimModes[this->animIndex], -2.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/EnGuardNuts_Draw.s") +void EnGuardNuts_SetupWait(EnGuardNuts* this) { + EnGuardNuts_ChangeAnim(this, WAIT_HEAD_TILT_ANIM); + this->state = GUARD_NUTS_WAIT_STATE; + this->actionFunc = EnGuardNuts_Wait; +} + +void EnGuardNuts_Wait(EnGuardNuts* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 phi_a1; + s16 yawDiff; + + SkelAnime_Update(&this->skelAnime); + yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.home.rot.y)); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80ABB540(this); + return; + } + if (yawDiff > 0x6000) { + D_80ABBE20 = 2; + } + if (player->transformation == PLAYER_FORM_DEKU) { + // this is the palace of... + this->guardTextIndex = 0; + if ((gSaveContext.weekEventReg[17] & 4) && (!this->hasCompletedConversation)) { + // I told you not to enter!! + this->guardTextIndex = 7; + } else if (gSaveContext.weekEventReg[12] & 0x40) { + // come to see the monkey again? + this->guardTextIndex = 4; + } + } else { + // No place for an outsider + this->guardTextIndex = 3; + } + this->actor.textId = sTextIDs[this->guardTextIndex]; + phi_a1 = this->actor.world.rot.y; + if (D_80ABBE20 == 2) { + EnGuardNuts_Burrow(this, globalCtx); + return; + } + if (D_80ABBE20 == 1) { + if (this->animIndex != WALK_ANIM) { + EnGuardNuts_ChangeAnim(this, WALK_ANIM); + } + 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); + } + } else { + Math_SmoothStepToS(&this->actor.shape.rot.y, phi_a1, 1, 0xBB8, 0); + } + if (this->targetHeadPos.x == 0) { + if (fabsf((f32)this->actor.world.rot.y - (f32)this->actor.yawTowardsPlayer) < 10000.0f) { + this->targetHeadPos.y = this->actor.world.rot.y - this->actor.yawTowardsPlayer; + this->targetHeadPos.y = -this->targetHeadPos.y; + } + } + func_800B8614(&this->actor, globalCtx, 70.0f); +} + +void func_80ABB540(EnGuardNuts* this) { + EnGuardNuts_ChangeAnim(this, WALK_ANIM); + this->targetHeadPos.x = this->targetHeadPos.y = 0; + this->timer = 16; + this->state = GUARD_NUTS_TALKING_STATE; + this->actionFunc = func_80ABB590; +} + +void func_80ABB590(EnGuardNuts* this, GlobalContext* globalCtx) { + s16 yaw = this->actor.yawTowardsPlayer; + f32 curFrame; + + if (D_80ABBE20 == 1) { + yaw = (this->actor.home.rot.y + 0x8000); + } + 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)) { + SkelAnime_Update(&this->skelAnime); + } + } else { + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.shape.rot.y, yaw, 1, 0xBB8, 0); + } + if (Message_GetState(&globalCtx->msgCtx) == 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 (func_80147624(globalCtx) != 0) { + if (D_80ABBE38[this->guardTextIndex] != 1) { + if (D_80ABBE38[this->guardTextIndex] == 2) { + func_801477B4(globalCtx); + D_80ABBE20 = 2; + gSaveContext.weekEventReg[12] |= 0x40; + EnGuardNuts_Burrow(this, globalCtx); + } else { + this->guardTextIndex++; + Message_StartTextbox(globalCtx, sTextIDs[this->guardTextIndex], &this->actor); + if (D_80ABBE38[this->guardTextIndex] == 2) { + D_80ABBE20 = 1; + } + this->timer = 16; + } + } else if (this->guardTextIndex != 3) { + this->targetHeadPos.x = 0; + this->targetHeadPos.y = this->targetHeadPos.x; + func_801477B4(globalCtx); + this->state = GUARD_NUTS_UNK_STATE; + this->actionFunc = EnGuardNuts_Unburrow; + } else { + func_801477B4(globalCtx); + EnGuardNuts_SetupWait(this); + } + } + } else if ((Message_GetState(&globalCtx->msgCtx) >= 3) && (D_80ABBE20 == 0)) { + if ((this->guardTextIndex == 0) || (this->guardTextIndex == 3) || (this->guardTextIndex >= 7)) { + if (this->timer == 0) { + this->timer = 2; + this->targetHeadPos.y ^= 0x2000; + } + } else if (this->timer == 0) { + this->timer = 2; + this->targetHeadPos.x ^= 0x2000; + } + } +} + +void EnGuardNuts_Burrow(EnGuardNuts* this, GlobalContext* globalCtx) { + Vec3f digPos; + + EnGuardNuts_ChangeAnim(this, DIG_ANIM); + Math_Vec3f_Copy(&digPos, &this->actor.world.pos); + digPos.y = this->actor.floorHeight; + EffectSsHahen_SpawnBurst(globalCtx, &digPos, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + this->targetHeadPos.y = 0; + this->actor.flags |= ACTOR_FLAG_8000000; + this->targetHeadPos.x = this->targetHeadPos.y; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + this->actionFunc = EnGuardNuts_SetupUnburrow; +} + +void EnGuardNuts_SetupUnburrow(EnGuardNuts* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + SkelAnime_Update(&this->skelAnime); + if (this->animFrameCount <= curFrame) { + this->state = GUARD_NUTS_BURROWED_STATE; + this->actionFunc = EnGuardNuts_Unburrow; + this->actor.world.rot.y = this->actor.home.rot.y; + this->actor.shape.rot.y = this->actor.home.rot.y; + } +} + +void EnGuardNuts_Unburrow(EnGuardNuts* this, GlobalContext* globalCtx) { + s16 yawDiff; + Vec3f digPos; + + // If you have returned Deku Princess, guards will not unburrow + if (!(gSaveContext.weekEventReg[23] & 0x20)) { + yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.home.rot.y)); + if ((yawDiff < 0x4000) && ((D_80ABBE20 == 0) || (this->actor.xzDistToPlayer > 150.0f))) { + Math_Vec3f_Copy(&digPos, &this->actor.world.pos); + digPos.y = this->actor.floorHeight; + EffectSsHahen_SpawnBurst(globalCtx, &digPos, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + D_80ABBE20 = 0; + if (this->guardTextIndex == 9) { + this->hasCompletedConversation = true; + } + this->actor.flags &= ~ACTOR_FLAG_8000000; + EnGuardNuts_SetupWait(this); + } + } +} + +void EnGuardNuts_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGuardNuts* this = THIS; + s32 pad; + + if (this->blinkTimer == 0) { + if (++(this->eyeState) >= 3) { + this->eyeState = 0; + this->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + if ((this->animIndex == WALK_ANIM) && + ((Animation_OnFrame(&this->skelAnime, 1.0f)) || (Animation_OnFrame(&this->skelAnime, 5.0f)))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + } + + this->actionFunc(this, globalCtx); + Actor_SetFocus(&this->actor, 40.0f); + Math_SmoothStepToS(&this->headRot.x, this->targetHeadPos.x, 1, 0xBB8, 0); + Math_SmoothStepToS(&this->headRot.y, this->targetHeadPos.y, 1, 0xBB8, 0); + + if (this->blinkTimer != 0) { + this->blinkTimer--; + } + if (this->timer != 0) { + this->timer--; + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); + if ((this->state != GUARD_NUTS_BURROWED_STATE) && (this->state != GUARD_NUTS_UNK_STATE)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +s32 EnGuardNuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnGuardNuts* this = THIS; + + if (limbIndex == OBJECT_DNK_LIMB_HEAD) { + rot->x += this->headRot.x; + rot->y += this->headRot.y; + rot->z += this->headRot.z; + } + return false; +} + +void EnGuardNuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnGuardNuts* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeState])); + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnGuardNuts_OverrideLimbDraw, + NULL, &this->actor); + Matrix_InsertTranslation(this->guardPos.x, this->actor.floorHeight, this->guardPos.z, MTXMODE_NEW); + Matrix_Scale(0.015f, 0.015f, 0.015f, 1); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, gDekuPalaceGuardFlower); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 13acc2237..59f885563 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 @@ -2,16 +2,31 @@ #define Z_EN_GUARD_NUTS_H #include "global.h" +#include "objects/object_dnk/object_dnk.h" struct EnGuardNuts; typedef void (*EnGuardNutsActionFunc)(struct EnGuardNuts*, GlobalContext*); typedef struct EnGuardNuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC8]; - /* 0x020C */ EnGuardNutsActionFunc actionFunc; - /* 0x0210 */ char unk_210[0x80]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[OBJECT_DNK_LIMB_MAX]; + /* 0x1CA */ Vec3s morphTable[OBJECT_DNK_LIMB_MAX]; + /* 0x20C */ EnGuardNutsActionFunc actionFunc; + /* 0x210 */ s16 eyeState; + /* 0x212 */ s16 blinkTimer; + /* 0x214 */ s16 timer; + /* 0x218 */ s32 animIndex; + /* 0x21C */ s16 state; + /* 0x21E */ s16 guardNumber; // Unused - Number used to identify guard + /* 0x220 */ s32 guardTextIndex; + /* 0x224 */ u8 hasCompletedConversation; // Flag set when player has gone through all text. + /* 0x228 */ Vec3f guardPos; + /* 0x234 */ Vec3s headRot; + /* 0x23A */ Vec3s targetHeadPos; + /* 0x240 */ f32 animFrameCount; + /* 0x244 */ ColliderCylinder collider; } EnGuardNuts; // size = 0x290 extern const ActorInit En_Guard_Nuts_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 84ed84236..59c5944e9 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -11804,16 +11804,16 @@ 0x80ABAE64:("func_80ABAE64",), 0x80ABB0E0:("EnGuardNuts_Init",), 0x80ABB1E4:("EnGuardNuts_Destroy",), - 0x80ABB210:("func_80ABB210",), - 0x80ABB29C:("func_80ABB29C",), - 0x80ABB2D4:("func_80ABB2D4",), + 0x80ABB210:("EnGuardNuts_ChangeAnim",), + 0x80ABB29C:("EnGuardNuts_SetupWait",), + 0x80ABB2D4:("EnGuardNuts_Wait",), 0x80ABB540:("func_80ABB540",), 0x80ABB590:("func_80ABB590",), - 0x80ABB854:("func_80ABB854",), - 0x80ABB91C:("func_80ABB91C",), - 0x80ABB990:("func_80ABB990",), + 0x80ABB854:("EnGuardNuts_Burrow",), + 0x80ABB91C:("EnGuardNuts_SetupUnburrow",), + 0x80ABB990:("EnGuardNuts_Unburrow",), 0x80ABBACC:("EnGuardNuts_Update",), - 0x80ABBC60:("func_80ABBC60",), + 0x80ABBC60:("EnGuardNuts_OverrideLimbDraw",), 0x80ABBCB8:("EnGuardNuts_Draw",), 0x80ABBFC0:("func_80ABBFC0",), 0x80ABC2E0:("func_80ABC2E0",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 776e6c538..5b80210a9 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1336,12 +1336,6 @@ D_0600A808 = 0x0600A808; D_06000F9C = 0x06000F9C; D_06003F00 = 0x06003F00; -// ovl_En_Guard_Nuts - -D_06002700 = 0x06002700; -D_06002848 = 0x06002848; -D_06002A08 = 0x06002A08; - // ovl_En_Hata D_060000C0 = 0x060000C0; From 0fbbde8d7da46e474cdb19599f7c87e024b9b633 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Fri, 25 Mar 2022 01:41:04 +0000 Subject: [PATCH 097/257] Demo_Syoten (#672) * Demo_Syoten * Fix build, use UNK_PTR * Use Vtx * Keyframe stuff * PR * BSS * PR * Fix fix --- assets/xml/objects/object_syoten.xml | 9 +- include/functions.h | 14 +- include/variables.h | 2 +- include/z64animation.h | 69 +++ spec | 3 +- .../actors/ovl_Demo_Syoten/z_demo_syoten.c | 551 +++++++++++++++++- .../actors/ovl_Demo_Syoten/z_demo_syoten.h | 26 +- undefined_syms.txt | 16 - 8 files changed, 638 insertions(+), 52 deletions(-) diff --git a/assets/xml/objects/object_syoten.xml b/assets/xml/objects/object_syoten.xml index 9802f7701..2e546f471 100644 --- a/assets/xml/objects/object_syoten.xml +++ b/assets/xml/objects/object_syoten.xml @@ -1,6 +1,7 @@  - + + @@ -12,12 +13,16 @@ - + + + + + diff --git a/include/functions.h b/include/functions.h index 125517df2..6230097a9 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1586,7 +1586,7 @@ void func_800FE658(f32 arg0); // void func_800FE778(void); // void func_800FE788(void); // void func_800FE798(void); -// void func_800FE7A8(void); +void func_800FE7A8(Color_RGBA8* arg0, Color_RGBA8* arg1); s32 func_800FE9B4(GlobalContext* globalCtx); // void func_800FEA50(void); void func_800FEAB0(void); @@ -3191,12 +3191,12 @@ void func_80183070(void); // void func_801832B0(void); // void func_8018332C(void); // void func_8018340C(void); -// void func_80183430(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_8018349C(void); +void func_80183430(SkeletonInfo* skeletonInfo, void* arg1, void* arg2, Vec3s* arg3, s16* arg4, UnkKeyframeCallback* callbacks); +void func_8018349C(UNK_PTR arg0); // void func_801834A8(void); // void func_80183510(void); // void func_80183580(void); -// void func_801835EC(void); +void func_801835EC(UNK_PTR arg0, UNK_PTR arg1); // void func_80183658(void); // void func_801836CC(void); // void func_8018373C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9); @@ -3206,9 +3206,11 @@ void func_80183070(void); // void func_80183A3C(void); // void func_80183B08(void); // void func_80183B68(void); -// void func_80183DE0(void); +s32 func_80183DE0(SkeletonInfo* skeletonInfo); // void func_8018410C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_8018450C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); +void func_8018450C(GlobalContext* globalCtx, SkeletonInfo* skeleton, Mtx* mtx, + OverrideKeyframeDrawScaled overrideKeyframeDraw, PostKeyframeDrawScaled postKeyframeDraw, + Actor* actor); // void func_801845A4(void); // void func_801845C8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_80184638(void); diff --git a/include/variables.h b/include/variables.h index 1f0c54e3a..11c9dca92 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3285,9 +3285,9 @@ extern ShrinkWindowContext gShrinkWindowContext; extern ShrinkWindowContext* gShrinkWindowContextPtr; // extern UNK_TYPE4 D_801F6B50; // extern UNK_TYPE1 D_801F6B58; -extern FaultAddrConvClient sKaleidoAreaFaultClient; extern void (*sKaleidoScopeUpdateFunc)(GlobalContext* globalCtx); extern void (*sKaleidoScopeDrawFunc)(GlobalContext* globalCtx); +extern FaultAddrConvClient sKaleidoAreaFaultClient; // extern UNK_TYPE1 D_801F6C10; extern Input D_801F6C18; // extern UNK_TYPE1 D_801F6C30; diff --git a/include/z64animation.h b/include/z64animation.h index 0e4388dde..974b8bea0 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -296,4 +296,73 @@ typedef struct AnimationSpeedInfo { /* 0x0C */ f32 morphFrames; } AnimationSpeedInfo; // size = 0x10 +struct SkeletonInfo; + +typedef s32 (*UnkKeyframeCallback)(struct GlobalContext* globalCtx, struct SkeletonInfo* skeletonInfo, s32* arg2, Gfx** dList, + u8* arg4, void* arg5); + +// Keyframe limb? +typedef struct { + /* 0x00 */ Gfx* dList; + /* 0x04 */ u8 unk_4; + /* 0x05 */ u8 flags; + /* 0x06 */ Vec3s root; +} Struct_801BFA14_Arg1_Field4; // size = 0xC + +// Other limb type? +typedef struct { + /* 0x00 */ Gfx* dList; + /* 0x04 */ u8 unk_4; + /* 0x05 */ u8 flags; + /* 0x06 */ u8 unk_6; // transform limb draw index +} Struct_801BFA14_Arg1_Field4_2; // size = 0x8 + +typedef struct { + /* 0x00 */ u8 limbCount; + /* 0x01 */ u8 unk_1; // non-zero in object files, number of non-null-dlist limbs? + /* 0x04 */ union { + Struct_801BFA14_Arg1_Field4* unk_4; // arrays + Struct_801BFA14_Arg1_Field4_2* unk_4_2; + }; + /* 0x08 */ s16* unk_8; + /* 0x0C */ s16* unk_C; + /* 0x0C */ char unk_10[0x2]; + /* 0x12 */ s16 unk_12; +} Struct_801BFA14_Arg1; + +typedef struct { + /* 0x00 */ u16* unk_0; + /* 0x04 */ s16* unk_4; + /* 0x08 */ s16* unk_8; + /* 0x0C */ s16* unk_C; + /* 0x0C */ char unk_10[0x2]; + /* 0x12 */ s16 unk_12; +} SkeletonInfo_1C; + +typedef struct { + /* 0x00 */ f32 unk_0; + /* 0x04 */ f32 unk_4; + /* 0x08 */ f32 unk_8; + /* 0x0C */ f32 unk_C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ s32 unk_14; +} FrameControl; + +// FlexKeyframeSkeleton ? +typedef struct SkeletonInfo { + /* 0x00 */ FrameControl frameCtrl; + /* 0x18 */ Struct_801BFA14_Arg1* unk_18; // array + /* 0x1C */ SkeletonInfo_1C* unk_1C; + /* 0x20 */ UnkKeyframeCallback* unk_20; // pointer to array of functions + /* 0x24 */ f32 unk_24; // duration? current time? + /* 0x28 */ Vec3s* frameData; // array of 3 Vec3s + /* 0x2C */ s16* unk_2C; +} SkeletonInfo; + +typedef s32 (*OverrideKeyframeDrawScaled)(struct GlobalContext* globalCtx, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList, + u8* flags, struct Actor* actor, Vec3f* scale, Vec3s* rot, Vec3f* pos); + +typedef void (*PostKeyframeDrawScaled)(struct GlobalContext* globalCtx, SkeletonInfo* skeleton, s32 limbIndex, Gfx** dList, + u8* flags, struct Actor* actor, Vec3f* scale, Vec3s* rot, Vec3f* pos); + #endif diff --git a/spec b/spec index f2ffda1d0..f38895e38 100644 --- a/spec +++ b/spec @@ -5175,8 +5175,7 @@ beginseg name "ovl_Demo_Syoten" compress include "build/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.o" - include "build/data/ovl_Demo_Syoten/ovl_Demo_Syoten.data.o" - include "build/data/ovl_Demo_Syoten/ovl_Demo_Syoten.reloc.o" + include "build/src/overlays/actors/ovl_Demo_Syoten/ovl_Demo_Syoten_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c index a4c9b9dc3..aa25fddfd 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c @@ -5,6 +5,7 @@ */ #include "z_demo_syoten.h" +#include "objects/object_syoten/object_syoten.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +16,15 @@ void DemoSyoten_Destroy(Actor* thisx, GlobalContext* globalCtx); void DemoSyoten_Update(Actor* thisx, GlobalContext* globalCtx); void DemoSyoten_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80C16A64(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C16A74(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C16BD4(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C16DD4(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C16EAC(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C17008(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C173B4(Actor* thisx, GlobalContext* globalCtx); +void func_80C17690(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Demo_Syoten_InitVars = { ACTOR_DEMO_SYOTEN, ACTORCAT_ITEMACTION, @@ -28,45 +37,539 @@ const ActorInit Demo_Syoten_InitVars = { (ActorFunc)DemoSyoten_Draw, }; -#endif +u8 D_80C177D0[] = { + 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 1, 0, 2, 2, 0, 1, 0, 2, 2, 0, 1, 0, 2, 2, 0, 1, 0, + 2, 2, 0, 1, 0, 1, 2, 2, 1, 2, 2, 0, 0, 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 1, 0, 2, 2, + 0, 1, 0, 2, 2, 0, 1, 0, 2, 2, 2, 0, 0, 2, 0, 1, 1, 0, 2, 2, 2, 0, 1, 0, 2, 2, 0, +}; -extern UNK_TYPE D_0600023C; -extern UNK_TYPE D_06001298; -extern UNK_TYPE D_060018C0; -extern UNK_TYPE D_06002880; +Color_RGBA8 D_80C17824[] = { + { 160, 100, 130, 255 }, + { 150, 120, 160, 255 }, + { 130, 90, 150, 255 }, + { 90, 70, 120, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/DemoSyoten_Init.s") +Color_RGBA8 D_80C17834[] = { + { 110, 50, 80, 255 }, + { 120, 100, 130, 255 }, + { 90, 40, 100, 255 }, + { 60, 50, 100, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/DemoSyoten_Destroy.s") +void DemoSyoten_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DemoSyoten* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16760.s") + Actor_SetScale(&this->actor, 0.3f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16818.s") + this->actionFunc = func_80C16A64; + this->unk_3E4 = 0; + this->unk_3E6 = 0; + this->unk_3DC = NULL; + this->unk_3E0 = NULL; + this->unk_3F2 = 0; + this->unk_3D8 = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C168D0.s") + switch (DEMOSYOTEN_GET_F(&this->actor)) { + case DEMOSYOTEN_F_0: + func_80183430(&this->unk_144, &object_syoten_Blob_001328, &object_syoten_Blob_00023C, this->unk_174, + this->unk_2A6, 0); + func_801835EC(&this->unk_144, &object_syoten_Blob_00023C); + this->actor.draw = NULL; + this->actionFunc = func_80C16A74; + this->actor.child = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EFF_DUST, + this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, 0); + this->unk_3F0 = 0x215; + Actor_SetScale(&this->actor, 0.05f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16974.s") + case DEMOSYOTEN_F_1: + Actor_SetScale(&this->actor, 0.1f); + this->unk_3DC = object_syoten_DL_001370; + this->unk_3E0 = Lib_SegmentedToVirtual(&object_syoten_Matanimheader_001448); + this->unk_3E4 |= 1; + this->actionFunc = func_80C16BD4; + this->unk_3F0 = 0x215; + Actor_SetScale(&this->actor, 0.05f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16A64.s") + case DEMOSYOTEN_F_2: + this->unk_3DC = object_syoten_DL_001730; + this->unk_3E0 = Lib_SegmentedToVirtual(&object_syoten_Matanimheader_0018B8); + this->unk_3F0 = 0x216; + this->actionFunc = func_80C16DD4; + this->unk_3E4 |= 2; + Actor_SetScale(&this->actor, 4.0f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16A74.s") + case DEMOSYOTEN_F_3: + this->unk_3DC = object_syoten_DL_001DD0; + this->unk_3E0 = Lib_SegmentedToVirtual(&object_syoten_Matanimheader_002B98); + this->unk_3F0 = 0x218; + this->unk_3E4 |= 8; + this->actionFunc = func_80C16EAC; + Actor_SetScale(&this->actor, 0.5f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16BD4.s") + case DEMOSYOTEN_F_4: + this->unk_3DC = object_syoten_DL_002880; + this->unk_3E0 = Lib_SegmentedToVirtual(&object_syoten_Matanimheader_002B88); + this->unk_3E4 |= 2; + this->actionFunc = func_80C17008; + this->unk_3F0 = 0x217; + this->unk_3E4 |= 1; + this->unk_3E4 |= 8; + this->actor.draw = func_80C17690; + Actor_SetScale(&this->actor, 5.0f); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16DD4.s") +void DemoSyoten_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DemoSyoten* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16EAC.s") + if (DEMOSYOTEN_GET_F(&this->actor) == DEMOSYOTEN_F_0) { + func_8018349C(&this->unk_144); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C17008.s") +void func_80C16760(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + Vec3s* points; + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/DemoSyoten_Update.s") + this->unk_3EC = 0; + if (DEMOSYOTEN_GET_7E00(&this->actor) != DEMOSYOTEN_7E00_3F) { + this->unk_3E8 = &globalCtx->setupPathList[DEMOSYOTEN_GET_7E00(&this->actor)]; + if (this->unk_3E8 != NULL) { + points = Lib_SegmentedToVirtual(this->unk_3E8->points); + Math_Vec3s_ToVec3f(&this->actor.world.pos, &points[0]); + this->unk_3EC++; + points++; + Math_Vec3s_ToVec3f(&sp2C, points); + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &sp2C); + this->actor.world.rot.x = Math_Vec3f_Pitch(&this->actor.world.pos, &sp2C); + } + } else { + this->unk_3E8 = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C170F8.s") +s32 func_80C16818(DemoSyoten* this) { + s32 pad; + Path* path = this->unk_3E8; + Vec3s* points; + Vec3f sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C173B4.s") + if (path == NULL) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C17468.s") + points = Lib_SegmentedToVirtual(this->unk_3E8->points); + points += this->unk_3EC; + Math_Vec3s_ToVec3f(&sp28, points); + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &sp28); + this->actor.world.rot.x = Math_Vec3f_Pitch(&this->actor.world.pos, &sp28); + Actor_MoveWithoutGravityReverse(&this->actor); + if (Math_Vec3f_DistXYZ(&this->actor.world.pos, &sp28) < 2.0f) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/DemoSyoten_Draw.s") +void func_80C168D0(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + Path* path = this->unk_3E8; + Vec3s* points; + Vec3f sp30; + Vec3f sp24; + f32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C17690.s") + if (path != NULL) { + points = Lib_SegmentedToVirtual(this->unk_3E8->points); + points += this->unk_3EC; + Math_Vec3s_ToVec3f(&sp30, points); + Actor_GetProjectedPos(globalCtx, &sp30, &sp24, &sp20); + Math_Vec3f_Copy(&sp30, &this->actor.projectedPos); + sp30.z = sp30.y; + sp24.z = sp24.y; + this->actor.shape.rot.z = -Math_Vec3f_Yaw(&sp24, &sp30); + } +} + +void func_80C16974(f32 arg0) { + Vtx* vtx = Lib_SegmentedToVirtual(&object_syotenVtx_0018C0); + u8 sp20[3]; + s32 i; + + arg0 = CLAMP_MAX(arg0, 1.0f); + + sp20[0] = (s8)0.0f; + sp20[1] = (s8)(152.0f * arg0); + sp20[2] = (s8)(255.0f * arg0); + + for (i = 0; i < ARRAY_COUNT(D_80C177D0); i++, vtx++) { + vtx->v.cn[3] = sp20[D_80C177D0[i]]; + } +} + +void func_80C16A64(DemoSyoten* this, GlobalContext* globalCtx) { +} + +void func_80C16A74(DemoSyoten* this, GlobalContext* globalCtx) { + u16 temp_a0; + + func_80183DE0(&this->unk_144); + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + if ((globalCtx->csCtx.frames >= 160) && (globalCtx->csCtx.frames < 322)) { + func_800B9010(&this->actor, NA_SE_EV_IKANA_SOUL_LV - SFX_FLAG); + } else if (globalCtx->csCtx.frames == 322) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_IKANA_SOUL_TRANSFORM); + } + + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + this->actor.draw = func_80C173B4; + this->unk_3D8 = 1.0f; + break; + + case 3: + break; + + case 4: + this->actor.draw = NULL; + break; + } + } + + if (temp_a0 == 3) { + if (this->unk_3D8 > 0.0125f) { + this->unk_3D8 -= 0.0125f; + if (this->actor.child != NULL) { + this->actor.child->home.rot.z = 0x14; + } + } else { + this->actor.draw = NULL; + if (this->actor.child != NULL) { + this->actor.child->home.rot.z = 0; + } + } + } + } else { + this->actor.draw = NULL; + } +} + +void func_80C16BD4(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + u16 temp_a0; + + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + default: + this->actor.draw = NULL; + break; + + case 1: + case 2: + this->actor.draw = NULL; + Actor_SetScale(&this->actor, 0.0f); + break; + + case 3: + this->actor.draw = DemoSyoten_Draw; + this->unk_3E4 &= ~4; + this->unk_3E4 |= 1; + this->actor.shape.rot.z = 0; + break; + + case 4: + this->actor.draw = DemoSyoten_Draw; + func_80C16760(this, globalCtx); + this->unk_3E4 |= 4; + this->unk_3E4 &= ~1; + break; + } + } + + switch (temp_a0) { + case 3: + if (this->actor.scale.x < 0.05f) { + this->actor.scale.x += 0.000625f; + } + Actor_SetScale(&this->actor, this->actor.scale.x); + break; + + case 4: + this->actor.speedXZ = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->urot.z * + 0.005493164f; + if (this->unk_3EC < this->unk_3E8->count) { + if (func_80C16818(this)) { + this->unk_3EC++; + } + func_80C168D0(this, globalCtx); + } + break; + } + } else { + this->actor.draw = NULL; + } +} + +void func_80C16DD4(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + u16 temp_a0; + + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + this->actor.draw = DemoSyoten_Draw; + this->unk_3E6 = -6; + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_DM_FLYING_GOD_DASH); + break; + } + } + + if ((temp_a0 == 2) && (this->unk_3E6 < 40)) { + this->unk_3E6++; + } + } else { + this->actor.draw = NULL; + } +} + +void func_80C16EAC(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + u16 temp_a0; + + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + case 1: + this->actor.draw = NULL; + this->unk_3D8 = 0.0f; + Actor_SetScale(&this->actor, 0.5f); + break; + + case 2: + this->actor.draw = DemoSyoten_Draw; + break; + } + } + + if (temp_a0 == 2) { + if (this->actor.scale.x < 8.0f) { + this->actor.scale.x += 0.1875f; + } + + Actor_SetScale(&this->actor, this->actor.scale.x); + + if (this->unk_3D8 < 1.0f) { + this->unk_3D8 += 0.025f; + } + + if (this->unk_3D8 > 1.0f) { + this->unk_3D8 = 1.0f; + } + func_800B9010(&this->actor, NA_SE_EV_IKANA_PURIFICATION - SFX_FLAG); + } + } else { + this->actor.draw = NULL; + } + func_80C16974(this->unk_3D8); +} + +void func_80C17008(DemoSyoten* this, GlobalContext* globalCtx) { + u16 temp_a0; + + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + this->actor.draw = func_80C17690; + this->unk_3E6 = -10; + break; + } + } + + if ((temp_a0 == 2) && (this->unk_3E6 < 15)) { + this->unk_3E6++; + } + } else { + this->actor.draw = NULL; + } +} + +void DemoSyoten_Update(Actor* thisx, GlobalContext* globalCtx) { + DemoSyoten* this = THIS; + + this->actionFunc(this, globalCtx); +} + +s32 func_80C170F8(GlobalContext* globalCtx, UNK_TYPE arg1, s32 arg2, UNK_TYPE arg3, UNK_TYPE arg4, Actor* thisx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + DemoSyoten* this = THIS; + + OPEN_DISPS(gfxCtx); + + switch (arg2) { + case 2: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 140, (s32)(this->unk_3D8 * 150.0f)); + break; + + case 4: + case 12: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 190, (s32)(this->unk_3D8 * 200.0f)); + break; + + case 6: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 150, (s32)(this->unk_3D8 * 150.0f)); + break; + + case 8: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 180, (s32)(this->unk_3D8 * 200.0f)); + break; + + case 10: + case 14: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 170, (s32)(this->unk_3D8 * 150.0f)); + break; + + case 16: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 160, (s32)(this->unk_3D8 * 200.0f)); + break; + } + + CLOSE_DISPS(gfxCtx); + return true; +} + +void func_80C173B4(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DemoSyoten* this = THIS; + Mtx* matrix; + + AnimatedMat_DrawXlu(globalCtx, Lib_SegmentedToVirtual(&object_syoten_Matanimheader_001298)); + + matrix = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * this->unk_144.unk_18->unk_1)); + + if (matrix != NULL) { + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + func_8018450C(globalCtx, &this->unk_144, matrix, (void*)func_80C170F8, 0, &this->actor); + } +} + +void func_80C17468(GlobalContext* globalCtx) { + Color_RGBA8 sp2C; + Color_RGBA8 sp28; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_800FE7A8(D_80C17824, &sp2C); + func_800FE7A8(D_80C17834, &sp28); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sp2C.r, sp2C.g, sp2C.b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sp28.r, sp28.g, sp28.b, 255); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void DemoSyoten_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DemoSyoten* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + if (this->unk_3E4 & 4) { + Matrix_InsertZRotation_s(-this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Scale(1.0f, 5.0f, 1.0f, MTXMODE_APPLY); + } + + if (this->unk_3E4 & 1) { + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + } + + if (this->unk_3E4 & 8) { + func_80C17468(globalCtx); + } + + if (this->unk_3E0 != NULL) { + if (this->unk_3E4 & 2) { + AnimatedMat_DrawStepXlu(globalCtx, this->unk_3E0, this->unk_3E6); + } else { + AnimatedMat_DrawXlu(globalCtx, this->unk_3E0); + } + } + + if (this->unk_3DC != NULL) { + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, this->unk_3DC); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80C17690(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DemoSyoten* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + + if (this->unk_3E4 & 8) { + func_80C17468(globalCtx); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + AnimatedMat_DrawStepXlu(globalCtx, this->unk_3E0, this->unk_3E6); + + gSPDisplayList(POLY_XLU_DISP++, object_syoten_DL_002880); + + AnimatedMat_DrawStepXlu(globalCtx, this->unk_3E0, this->unk_3E6 + 5); + + gSPDisplayList(POLY_XLU_DISP++, object_syoten_DL_002A20); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h index 26f9902eb..204243f47 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h @@ -7,9 +7,33 @@ struct DemoSyoten; typedef void (*DemoSyotenActionFunc)(struct DemoSyoten*, GlobalContext*); +#define DEMOSYOTEN_GET_F(thisx) ((thisx)->params & 0xF) +#define DEMOSYOTEN_GET_7E00(thisx) (((thisx)->params & 0x7E00) >> 9) + +#define DEMOSYOTEN_7E00_3F 0x3F + +enum { + /* 0 */ DEMOSYOTEN_F_0, + /* 1 */ DEMOSYOTEN_F_1, + /* 2 */ DEMOSYOTEN_F_2, + /* 3 */ DEMOSYOTEN_F_3, + /* 4 */ DEMOSYOTEN_F_4 +}; + typedef struct DemoSyoten { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x2B0]; + /* 0x0144 */ SkeletonInfo unk_144; + /* 0x0174 */ Vec3s unk_174[51]; + /* 0x02A6 */ s16 unk_2A6[153]; + /* 0x03D8 */ f32 unk_3D8; + /* 0x03DC */ Gfx* unk_3DC; + /* 0x03E0 */ AnimatedMaterial* unk_3E0; + /* 0x03E4 */ u16 unk_3E4; + /* 0x03E6 */ s16 unk_3E6; + /* 0x03E8 */ Path* unk_3E8; + /* 0x03EC */ s32 unk_3EC; + /* 0x03F0 */ u16 unk_3F0; + /* 0x03F2 */ u16 unk_3F2; /* 0x03F4 */ DemoSyotenActionFunc actionFunc; } DemoSyoten; // size = 0x3F8 diff --git a/undefined_syms.txt b/undefined_syms.txt index 5b80210a9..d525ea833 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -910,22 +910,6 @@ D_0600B5A0 = 0x0600B5A0; D_06010C40 = 0x06010C40; D_060129F0 = 0x060129F0; -// ovl_Demo_Syoten - -D_0600023C = 0x0600023C; -D_06001298 = 0x06001298; -D_06001328 = 0x06001328; -D_06001370 = 0x06001370; -D_06001448 = 0x06001448; -D_06001730 = 0x06001730; -D_060018B8 = 0x060018B8; -D_060018C0 = 0x060018C0; -D_06001DD0 = 0x06001DD0; -D_06002880 = 0x06002880; -D_06002A20 = 0x06002A20; -D_06002B88 = 0x06002B88; -D_06002B98 = 0x06002B98; - // ovl_Demo_Tre_Lgt D_06007D78 = 0x06007D78; From 44db1ac61a20d51b6bfa5a556b8aaab656673d17 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Fri, 25 Mar 2022 01:48:19 +0000 Subject: [PATCH 098/257] En_Bombf (#677) * En_Bombf * PR * PR --- spec | 3 +- src/overlays/actors/ovl_En_Bombf/z_en_bombf.c | 471 ++++++++++++++++-- src/overlays/actors/ovl_En_Bombf/z_en_bombf.h | 16 +- undefined_syms.txt | 6 - 4 files changed, 455 insertions(+), 41 deletions(-) diff --git a/spec b/spec index f38895e38..d26d4de79 100644 --- a/spec +++ b/spec @@ -988,8 +988,7 @@ beginseg name "ovl_En_Bombf" compress include "build/src/overlays/actors/ovl_En_Bombf/z_en_bombf.o" - include "build/data/ovl_En_Bombf/ovl_En_Bombf.data.o" - include "build/data/ovl_En_Bombf/ovl_En_Bombf.reloc.o" + include "build/src/overlays/actors/ovl_En_Bombf/ovl_En_Bombf_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c index 4362997e6..fef26002b 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -5,6 +5,7 @@ */ #include "z_en_bombf.h" +#include "objects/object_bombf/object_bombf.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_10) @@ -15,13 +16,13 @@ void EnBombf_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx); void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBombf_SetupAction(EnBombf* this, EnBombfActionFunc actionFunc); +void func_808AEAB8(EnBombf* this, s16 arg1); +void func_808AEAE0(EnBombf* this, GlobalContext* globalCtx); void func_808AEE3C(EnBombf* this, GlobalContext* globalCtx); void func_808AEF68(EnBombf* this, GlobalContext* globalCtx); void func_808AEFD4(EnBombf* this, GlobalContext* globalCtx); -void EnBombf_SetupAction(EnBombf* this, EnBombfActionFunc actionFunc); - -#if 0 const ActorInit En_Bombf_InitVars = { ACTOR_EN_BOMBF, ACTORCAT_PROP, @@ -34,53 +35,463 @@ const ActorInit En_Bombf_InitVars = { (ActorFunc)EnBombf_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808AFB20 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x00000000, 0x00, 0x00 }, { 0x00013A28, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0x00013A28, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 9, 18, 10, { 0, 0, 0 } }, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_808AFB4C[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000008, 0x00, 0x08 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000008, 0x00, 0x08 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_NONE, + }, { 0, { { 0, 0, 0 }, 0 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808AFB70 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ALL, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_JNTSPH, }, - 1, D_808AFB4C, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ALL, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -#endif +void EnBombf_SetupAction(EnBombf* this, EnBombfActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern ColliderCylinderInit D_808AFB20; -extern ColliderJntSphElementInit D_808AFB4C[1]; -extern ColliderJntSphInit D_808AFB70; +void EnBombf_Init(Actor* thisx, GlobalContext* globalCtx2) { + f32 yOffset = 0.0f; + GlobalContext* globalCtx = globalCtx2; + EnBombf* this = THIS; -extern UNK_TYPE D_06000340; + Actor_SetScale(thisx, 0.01f); + this->unk_1F8 = 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_SetupAction.s") + Collider_InitCylinder(globalCtx, &this->colliderCylinder); + Collider_InitJntSph(globalCtx, &this->colliderJntSph); + Collider_SetCylinder(globalCtx, &this->colliderCylinder, thisx, &sCylinderInit); + Collider_SetJntSph(globalCtx, &this->colliderJntSph, thisx, &sJntSphInit, this->colliderJntSphElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_Init.s") + if (ENBOMBF_GET(thisx) == ENBOMBF_0) { + yOffset = 1000.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_Destroy.s") + ActorShape_Init(&thisx->shape, yOffset, ActorShadow_DrawCircle, 12.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEAB8.s") + thisx->focus.pos = thisx->world.pos; + thisx->colChkInfo.cylRadius = 10; + thisx->colChkInfo.cylHeight = 10; + thisx->targetMode = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEAE0.s") + if (ENBOMBF_GET(thisx) == ENBOMBF_0) { + this->timer = 140; + this->unk_1FE = 15; + thisx->gravity = -1.5f; + func_800BC154(globalCtx, &globalCtx->actorCtx, thisx, 3); + thisx->colChkInfo.mass = 200; + thisx->flags &= ~ACTOR_FLAG_1; + EnBombf_SetupAction(this, func_808AEE3C); + } else { + thisx->colChkInfo.mass = MASS_IMMOVABLE; + this->unk_1FC = 1; + this->unk_204 = 1.0f; + func_808AEAB8(this, ENBOMBF_GET(thisx)); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEE3C.s") + thisx->uncullZoneScale += 31000.0f; + thisx->uncullZoneForward += 31000.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEF68.s") +void EnBombf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBombf* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEFD4.s") + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_Update.s") +void func_808AEAB8(EnBombf* this, s16 arg1) { + EnBombf_SetupAction(this, func_808AEAE0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AF86C.s") +void func_808AEAE0(EnBombf* this, GlobalContext* globalCtx) { + s32 pad; + s32 pad2; + EnBombf* bombf; + Player* player = GET_PLAYER(globalCtx); + s32 pad3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_Draw.s") + if (this->unk_204 >= 1.0f) { + if (Actor_HasParent(&this->actor, globalCtx)) { + bombf = (EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENBOMBF_0); + if (bombf != NULL) { + func_800B8C20(&this->actor, &bombf->actor, globalCtx); + this->timer = 180; + this->unk_204 = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_PULL_UP_ROCK); + this->actor.flags &= ~ACTOR_FLAG_1; + } else { + player->actor.child = NULL; + player->heldActor = NULL; + player->interactRangeActor = NULL; + this->actor.parent = NULL; + player->stateFlags1 &= ~0x800; + } + } else if ((this->colliderCylinder.base.acFlags & AC_HIT) && + ((this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0x13828) || + ((this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0x200) && + (player->transformation == PLAYER_FORM_GORON) && (player->actor.speedXZ > 15.0f)))) { + this->colliderCylinder.base.acFlags &= ~AC_HIT; + if (this->colliderCylinder.base.ac->category != ACTORCAT_BOSS) { + bombf = (EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENBOMBF_0); + if (bombf != NULL) { + bombf->unk_1F8 = 1; + bombf->timer = 0; + this->timer = 180; + this->actor.flags &= ~ACTOR_FLAG_1; + this->unk_204 = 0.0f; + } + } + } else { + if (func_80123F48(globalCtx, &this->actor.world.pos, 30.0f, 50.0f)) { + bombf = (EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENBOMBF_0); + if (bombf != NULL) { + bombf->timer = 100; + this->timer = 180; + this->actor.flags &= ~ACTOR_FLAG_1; + this->unk_204 = 0.0f; + } + } else { + if (!Actor_HasParent(&this->actor, globalCtx)) { + Actor_LiftActor(&this->actor, globalCtx); + return; + } + player->actor.child = NULL; + player->heldActor = NULL; + player->interactRangeActor = NULL; + this->actor.parent = NULL; + player->stateFlags1 &= ~0x800; + this->actor.world.pos = this->actor.home.pos; + } + } + } else { + if (this->timer == 0) { + this->unk_204 += 0.05f; + if (this->unk_204 >= 1.0f) { + this->actor.flags |= ACTOR_FLAG_1; + } + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + player->actor.child = NULL; + player->heldActor = NULL; + player->interactRangeActor = NULL; + this->actor.parent = NULL; + player->stateFlags1 &= ~0x800; + this->actor.world.pos = this->actor.home.pos; + } + } +} + +void func_808AEE3C(EnBombf* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->unk_204 = 0.0f; + EnBombf_SetupAction(this, func_808AEF68); + this->actor.room = -1; + return; + } + + this->unk_204 = 1.0f; + if (!(this->actor.bgCheckFlags & 1)) { + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.025f, 0.0f); + return; + } + + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 1.5f, 0.0f); + if (this->actor.bgCheckFlags & 2) { + func_800B8EF4(globalCtx, &this->actor); + if (this->actor.velocity.y < -6.0f) { + this->actor.velocity.y *= -0.3f; + this->actor.bgCheckFlags &= ~1; + } + } else if (this->timer >= 4) { + Actor_LiftActor(&this->actor, globalCtx); + } +} + +void func_808AEF68(EnBombf* this, GlobalContext* globalCtx) { + if (Actor_HasNoParent(&this->actor, globalCtx)) { + EnBombf_SetupAction(this, func_808AEE3C); + this->actor.bgCheckFlags &= ~1; + func_808AEE3C(this, globalCtx); + } else { + this->actor.velocity.y = 0.0f; + } +} + +void func_808AEFD4(EnBombf* this, GlobalContext* globalCtx) { + if (this->colliderJntSph.elements->dim.modelSphere.radius == 0) { + this->actor.flags |= ACTOR_FLAG_20; + func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); + } + + this->colliderJntSph.elements->dim.modelSphere.radius = 100; + this->colliderJntSph.elements->dim.worldSphere.radius = 100; + + if (ENBOMBF_GET(&this->actor) == ENBOMBF_1) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + } + + if (globalCtx->envCtx.lightSettings.diffuseColor1[0] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[0] -= 25; + } + + if (globalCtx->envCtx.lightSettings.diffuseColor1[1] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[1] -= 25; + } + + if (globalCtx->envCtx.lightSettings.diffuseColor1[2] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[2] -= 25; + } + + if (globalCtx->envCtx.lightSettings.ambientColor[0] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[0] -= 25; + } + + if (globalCtx->envCtx.lightSettings.ambientColor[1] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[1] -= 25; + } + + if (globalCtx->envCtx.lightSettings.ambientColor[2] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[2] -= 25; + } + + if (this->timer == 0) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags1 & 0x800) && (&this->actor == player->heldActor)) { + player->actor.child = NULL; + player->heldActor = NULL; + player->interactRangeActor = NULL; + player->stateFlags1 &= ~0x800; + } + Actor_MarkForDeath(&this->actor); + } +} + +void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) { + Vec3f sp8C = { 0.0f, 0.0f, 0.0f }; + Vec3f sp80 = { 0.0f, 0.1f, 0.0f }; + Vec3f sp74 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp68; + Vec3f sp5C = { 0.0f, 0.6f, 0.0f }; + Color_RGBA8 sp58 = { 255, 255, 255, 255 }; + EnBombf* this = THIS; + s32 pad; + + if ((this->unk_1F8 != 0) && (this->timer != 0)) { + this->timer--; + } + + if ((this->unk_1FC == 0) && !Actor_HasParent(&this->actor, globalCtx) && + ((this->actor.xzDistToPlayer >= 20.0f) || (fabsf(this->actor.playerHeightRel) >= 80.0f))) { + this->unk_1FC = 1; + } + + this->actionFunc(this, globalCtx); + + if (ENBOMBF_GET(&this->actor) == ENBOMBF_0) { + Actor_MoveWithGravity(&this->actor); + } + + if (this->actor.gravity != 0.0f) { + DREG(6) = 1; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 10.0f, 0.0f, 0x1F); + DREG(6) = 0; + } + + if (ENBOMBF_GET(&this->actor) == ENBOMBF_0) { + if ((this->actor.velocity.y > 0.0f) && (this->actor.bgCheckFlags & 0x10)) { + this->actor.velocity.y = -this->actor.velocity.y; + } + + if ((this->actor.speedXZ != 0.0f) && (this->actor.bgCheckFlags & 8)) { + s16 yDiff = BINANG_SUB(this->actor.wallYaw, this->actor.world.rot.y); + + if (ABS_ALT(yDiff) > 0x4000) { + this->actor.world.rot.y = + BINANG_SUB(this->actor.wallYaw - this->actor.world.rot.y + this->actor.wallYaw, 0x8000); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_BOUND); + Actor_MoveWithGravity(&this->actor); + DREG(6) = 1; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 10.0f, 0.0f, 0x1F); + DREG(6) = 0; + this->actor.speedXZ *= 0.7f; + this->actor.bgCheckFlags &= ~8; + } + + if ((this->colliderCylinder.base.acFlags & AC_HIT) || + ((this->colliderCylinder.base.ocFlags1 & OC1_HIT) && (this->colliderCylinder.base.oc->category == 5))) { + this->unk_1F8 = 1; + this->timer = 0; + } else if ((this->timer > 100) && func_80123F48(globalCtx, &this->actor.world.pos, 30.0f, 50.0f)) { + this->timer = 100; + } + + if (this->unk_1F8 != 0) { + sp5C.y = 0.2f; + sp68 = this->actor.world.pos; + sp68.y += 25.0f; + + if (this->timer < 127) { + if ((globalCtx->gameplayFrames % 2) == 0) { + EffectSsGSpk_SpawnFuse(globalCtx, &this->actor, &sp68, &sp8C, &sp74); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_IGNIT - SFX_FLAG); + sp68.y += 3.0f; + func_800B0DE0(globalCtx, &sp68, &sp8C, &sp5C, &sp58, &sp58, 0x32, 5); + } + + if ((this->timer == 3) || (this->timer == 30) || (this->timer == 50) || (this->timer == 70)) { + this->unk_1FE = this->unk_1FE >> 1; + } + + if ((this->timer < 100) && (this->timer & (this->unk_1FE + 1))) { + Math_SmoothStepToF(&this->unk_200, 150.0f, 1.0f, 150.0f / this->unk_1FE, 0.0f); + } else { + Math_SmoothStepToF(&this->unk_200, 0.0f, 1.0f, 150.0f / this->unk_1FE, 0.0f); + } + + if (this->timer < 3) { + Actor_SetScale(&this->actor, this->actor.scale.x + 0.002f); + } + + if (this->timer == 0) { + sp68 = this->actor.world.pos; + sp68.y += 10.0f; + + if (Actor_HasParent(&this->actor, globalCtx)) { + sp68.y += 30.0f; + } + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, sp68.x, sp68.y, sp68.z, 0, 0, 0, + CLEAR_TAG_SMALL_EXPLOSION); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + + globalCtx->envCtx.lightSettings.diffuseColor1[0] = globalCtx->envCtx.lightSettings.diffuseColor1[1] = + globalCtx->envCtx.lightSettings.diffuseColor1[2] = 250; + globalCtx->envCtx.lightSettings.ambientColor[0] = globalCtx->envCtx.lightSettings.ambientColor[1] = + globalCtx->envCtx.lightSettings.ambientColor[2] = 250; + + func_800DFD04(&globalCtx->mainCamera, 2, 11, 8); + + this->actor.params = ENBOMBF_1; + this->timer = 10; + this->actor.flags |= ACTOR_FLAG_20; + + EnBombf_SetupAction(this, func_808AEFD4); + } + } + } + + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 10.0f; + + if (ENBOMBF_GET(&this->actor) <= ENBOMBF_0) { + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + if ((this->unk_204 >= 1.0f) && (this->unk_1FC != 0)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } + + if ((this->actor.scale.x >= 0.01f) && (ENBOMBF_GET(&this->actor) != ENBOMBF_1)) { + if (this->actor.depthInWater >= 20.0f) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_IT_BOMB_UNEXPLOSION); + Actor_MarkForDeath(&this->actor); + } else if (this->actor.bgCheckFlags & 0x40) { + this->actor.bgCheckFlags &= ~0x40; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); + } + } +} + +Gfx* func_808AF86C(GraphicsContext* gfxCtx, GlobalContext* globalCtx) { + Gfx* head = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 6); + Gfx* gfx = head; + + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gSPMatrix(gfx++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPEndDisplayList(gfx++); + + return head; +} + +void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBombf* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (ENBOMBF_GET(&this->actor) <= ENBOMBF_0) { + func_8012C28C(globalCtx->state.gfxCtx); + + if (ENBOMBF_GET(&this->actor) != ENBOMBF_0) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_bombf_DL_000340); + gSPDisplayList(POLY_OPA_DISP++, object_bombf_DL_000530); + + Matrix_InsertTranslation(0.0f, 1000.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(this->unk_204, this->unk_204, this->unk_204, MTXMODE_APPLY); + } + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 200, 255, 200, 255); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, (s8)this->unk_200, 20, 10, 0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + { + Gfx* gfx = func_808AF86C(globalCtx->state.gfxCtx, globalCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gfx)); + } + + gSPDisplayList(POLY_OPA_DISP++, object_bombf_DL_000408); + } else { + Collider_UpdateSpheres(0, &this->colliderJntSph); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h index 723d254cb..b72edce8c 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h @@ -7,13 +7,23 @@ struct EnBombf; typedef void (*EnBombfActionFunc)(struct EnBombf*, GlobalContext*); +#define ENBOMBF_GET(thisx) ((thisx)->params) + +#define ENBOMBF_0 0 +#define ENBOMBF_1 1 + typedef struct EnBombf { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xAC]; + /* 0x0144 */ ColliderCylinder colliderCylinder; + /* 0x0190 */ ColliderJntSph colliderJntSph; + /* 0x01B0 */ ColliderJntSphElement colliderJntSphElements[1]; /* 0x01F0 */ s16 timer; - /* 0x01F2 */ char unk_1F2[0x2]; /* 0x01F4 */ EnBombfActionFunc actionFunc; - /* 0x01F8 */ char unk_1F8[0x10]; + /* 0x01F8 */ s32 unk_1F8; + /* 0x01FC */ u8 unk_1FC; + /* 0x01FE */ s16 unk_1FE; + /* 0x0200 */ f32 unk_200; + /* 0x0204 */ f32 unk_204; } EnBombf; // size = 0x208 extern const ActorInit En_Bombf_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index d525ea833..e8c4715cb 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1140,12 +1140,6 @@ D_0600F82C = 0x0600F82C; D_060064B8 = 0x060064B8; D_0600F82C = 0x0600F82C; -// ovl_En_Bombf - -D_06000340 = 0x06000340; -D_06000408 = 0x06000408; -D_06000530 = 0x06000530; - // ovl_En_Bomjimb D_060064B8 = 0x060064B8; From 5684b342b68e27bf671f087dc44b16a135e7c695 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Fri, 25 Mar 2022 01:55:58 +0000 Subject: [PATCH 099/257] En_Vm (#678) * En_Vm * Hidden funcs >: * PR * PR --- include/functions.h | 4 +- spec | 3 +- src/overlays/actors/ovl_En_Vm/z_en_vm.c | 501 +++++++++++++++++++++--- src/overlays/actors/ovl_En_Vm/z_en_vm.h | 25 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 6 - 6 files changed, 479 insertions(+), 64 deletions(-) diff --git a/include/functions.h b/include/functions.h index 6230097a9..3595508fc 100644 --- a/include/functions.h +++ b/include/functions.h @@ -598,9 +598,9 @@ void EffectSsEnFire_SpawnVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* po void EffectSsExtra_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scoreIdx); void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s32 unk); void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s32 colorIndex); -// void EffectSsDeadDd_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE1* param_5, UNK_TYPE1* param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE4 param_10); +void EffectSsDeadDd_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s16 alphaStep, s32 life); // void EffectSsDeadDs_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE4 param_8); -// void func_800B31BC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6); +void func_800B31BC(GlobalContext* globalCtx, Vec3f* pos, s16 scale, s16 scaleStep, s16 alpha, s32 life); void EffectSsIceSmoke_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale); void EffectSsIceBlock_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale); void FlagSet_Update(GameState* gameState); diff --git a/spec b/spec index d26d4de79..fcfb12e4c 100644 --- a/spec +++ b/spec @@ -1121,8 +1121,7 @@ beginseg name "ovl_En_Vm" compress include "build/src/overlays/actors/ovl_En_Vm/z_en_vm.o" - include "build/data/ovl_En_Vm/ovl_En_Vm.data.o" - include "build/data/ovl_En_Vm/ovl_En_Vm.reloc.o" + include "build/src/overlays/actors/ovl_En_Vm/ovl_En_Vm_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Vm/z_en_vm.c b/src/overlays/actors/ovl_En_Vm/z_en_vm.c index 81ef8312b..6103cb577 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.c +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.c @@ -5,6 +5,9 @@ */ #include "z_en_vm.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_vm/object_vm.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) @@ -15,7 +18,17 @@ void EnVm_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnVm_Update(Actor* thisx, GlobalContext* globalCtx); void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_808CC420(EnVm* this); +void func_808CC490(EnVm* this, GlobalContext* globalCtx); +void func_808CC5C4(EnVm* this); +void func_808CC610(EnVm* this, GlobalContext* globalCtx); +void func_808CC788(EnVm* this); +void func_808CC820(EnVm* this, GlobalContext* globalCtx); +void func_808CCAA4(EnVm* this, GlobalContext* globalCtx); +void func_808CCB08(EnVm* this); +void func_808CCB50(EnVm* this, GlobalContext* globalCtx); +void func_808CCCF0(EnVm* this, GlobalContext* globalCtx); + const ActorInit En_Vm_InitVars = { ACTOR_EN_VM, ACTORCAT_ENEMY, @@ -28,40 +41,72 @@ const ActorInit En_Vm_InitVars = { (ActorFunc)EnVm_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_808CD4C0[2] = { +static ColliderJntSphElementInit sJntSphElementsInit[] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 2, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 10, { { 0, 2300, 0 }, 33 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808CD508 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_808CD4C0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementsInit, }; -// static ColliderTrisElementInit sTrisElementsInit[1] = { -static ColliderTrisElementInit D_808CD518[1] = { +static ColliderTrisElementInit sTrisElementsInit[] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_808CD554 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 1, D_808CD518, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 1, + sTrisElementsInit, }; -// static DamageTable sDamageTable = { -static DamageTable D_808CD564 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0xF), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0xF), @@ -96,62 +141,418 @@ static DamageTable D_808CD564 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808CD584 = { 2, 25, 100, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 25, 100, MASS_IMMOVABLE }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808CD5AC[] = { +TexturePtr D_808CD58C[] = { + gameplay_keep_Tex_03F300, gameplay_keep_Tex_03FB00, gameplay_keep_Tex_040300, gameplay_keep_Tex_040B00, + gameplay_keep_Tex_041300, gameplay_keep_Tex_041B00, gameplay_keep_Tex_042300, gameplay_keep_Tex_042B00, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 14, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 1000, ICHAIN_CONTINUE), ICHAIN_S8(hintId, 57, ICHAIN_STOP), }; -#endif +s32 D_808CD5B8 = false; -extern ColliderJntSphElementInit D_808CD4C0[2]; -extern ColliderJntSphInit D_808CD508; -extern ColliderTrisElementInit D_808CD518[1]; -extern ColliderTrisInit D_808CD554; -extern DamageTable D_808CD564; -extern CollisionCheckInfoInit D_808CD584; -extern InitChainEntry D_808CD5AC[]; +Color_RGBA8 D_808CD5BC = { 0, 0, 255, 0 }; -extern UNK_TYPE D_06000068; +Color_RGBA8 D_808CD5C0 = { 255, 255, 255, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/EnVm_Init.s") +void EnVm_Init(Actor* thisx, GlobalContext* globalCtx) { + EnVm* this = THIS; + s32 i; + s32 params; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/EnVm_Destroy.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_vm_Skel_003F60, &object_vm_Anim_000068, this->jointTable, + this->morphTable, 11); + Collider_InitAndSetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTrisElements); + Collider_InitAndSetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, + this->colliderJntSphElements); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC420.s") + params = ENVM_GET_FF00(thisx); + if ((params == ENVM_FF00_FF) || (params == ENVM_FF00_0)) { + params = ENVM_FF00_5; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC490.s") + this->unk_21C = params * 40.0f; + thisx->params &= 0xFF; + this->actor.bgCheckFlags |= 0x400; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC5C4.s") + if (!D_808CD5B8) { + for (i = 0; i < ARRAY_COUNT(D_808CD58C); i++) { + D_808CD58C[i] = Lib_SegmentedToVirtual(D_808CD58C[i]); + } + D_808CD5B8 = true; + } + func_808CC420(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC610.s") +void EnVm_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnVm* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC788.s") + Collider_DestroyTris(globalCtx, &this->colliderTris); + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC820.s") +void func_808CC420(EnVm* this) { + f32 lastFrame = Animation_GetLastFrame(&object_vm_Anim_000068); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCA10.s") + Animation_Change(&this->skelAnime, &object_vm_Anim_000068, 1.0f, lastFrame, lastFrame, ANIMMODE_ONCE, 0.0f); + this->actionFunc = func_808CC490; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCAA4.s") +void func_808CC490(EnVm* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp22; + s16 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCB08.s") + Math_ApproachS(&this->unk_216, 0, 0xA, 0x5DC); + this->unk_218 -= 0x1F4; + func_800B9010(&this->actor, NA_SE_EN_BIMOS_ROLL_HEAD - SFX_FLAG); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCB50.s") + if (this->actor.xzDistToPlayer <= this->unk_21C) { + if ((this->actor.playerHeightRel <= 80.0f) && (this->actor.playerHeightRel >= -160.0f)) { + sp22 = BINANG_SUB(this->actor.yawTowardsPlayer - this->unk_218, this->actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCBE4.s") + temp_v0 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.world.pos); + if (temp_v0 > 0x1B91) { + temp_v0 = 0x1B91; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCCF0.s") + if ((ABS_ALT(sp22) <= 0x2710) && (temp_v0 >= 0xE38) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + func_808CC5C4(this); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCDE4.s") +void func_808CC5C4(EnVm* this) { + Animation_PlayLoopSetSpeed(&this->skelAnime, &object_vm_Anim_000068, 2.0f); + this->unk_214 = 10; + this->actionFunc = func_808CC610; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/EnVm_Update.s") +void func_808CC610(EnVm* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp3A; + s16 sp38; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CD020.s") + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CD08C.s") + sp38 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.world.pos); + sp38 = CLAMP_MAX(sp38, 0x1B91); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/EnVm_Draw.s") + sp3A = BINANG_ADD((s32)((this->unk_21C - this->actor.xzDistToPlayer) * 60.0f), 4000); + sp3A = CLAMP_MAX(sp3A, 0x1000); + + Math_SmoothStepToS(&this->unk_216, sp38, 10, 4000, 0); + + if ((sp38 < 0xAAA) || (sp3A <= 0)) { + func_808CC420(this); + } else if (Math_ScaledStepToS(&this->unk_218, BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y), + sp3A)) { + this->unk_214--; + if (this->unk_214 == 0) { + EffectSsDeadDd_Spawn(globalCtx, &this->unk_228, &gZeroVec3f, &gZeroVec3f, &D_808CD5BC, &D_808CD5C0, 150, + -25, 16, 20); + func_808CC788(this); + } + } +} + +void func_808CC788(EnVm* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BIMOS_AIM); + Animation_Change(&this->skelAnime, &object_vm_Anim_000068, 3.0f, 3.0f, 7.0f, ANIMMODE_ONCE, 0.0f); + this->unk_214 = 305; + this->unk_220 = 0.06f; + this->colliderTris.base.atFlags &= ~AT_HIT; + this->actionFunc = func_808CC820; +} + +void func_808CC820(EnVm* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp32; + f32 temp_f2; + + if (SkelAnime_Update(&this->skelAnime)) { + this->skelAnime.curFrame = this->skelAnime.startFrame; + } + + sp32 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.world.pos); + sp32 = CLAMP_MAX(sp32, 0x1B91); + + if (this->colliderTris.base.atFlags & AT_HIT) { + this->colliderTris.base.atFlags &= ~AT_HIT; + this->unk_214 = 0; + if (this->unk_220 > 0.01f) { + this->unk_220 = 0.01f; + } + } + + if ((this->unk_216 < 0xAAA) || (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (this->unk_214 == 0)) { + this->unk_214 = 0; + if (Math_StepToF(&this->unk_220, 0.0f, 0.003f)) { + this->unk_210 = 0; + this->unk_224 = 0.0f; + func_808CC420(this); + } + } else { + this->unk_214--; + if (this->unk_214 <= 300) { + Math_ApproachS(&this->unk_218, this->actor.yawTowardsPlayer - this->actor.shape.rot.y, 0xA, 0xDAC); + Math_ApproachS(&this->unk_216, sp32, 0xA, 0xDAC); + + temp_f2 = Math_Vec3f_DistXYZ(&this->actor.focus.pos, &player->actor.world.pos) + 40.0f; + if (this->unk_224 < temp_f2) { + Math_StepToF(&this->unk_224, temp_f2, 40.0f); + } + + Math_StepToF(&this->unk_220, 0.01f, 0.012f); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + + if (this->unk_210 == 0) { + this->unk_210 = 1; + } + } + } +} + +void func_808CCA10(EnVm* this) { + Animation_Change(&this->skelAnime, &object_vm_Anim_000068, -1.0f, Animation_GetLastFrame(&object_vm_Anim_000068), + 0.0f, ANIMMODE_ONCE, 0.0f); + this->unk_214 = 100; + this->unk_210 = 0; + this->unk_224 = 0.0f; + this->unk_220 = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->actionFunc = func_808CCAA4; +} + +void func_808CCAA4(EnVm* this, GlobalContext* globalCtx) { + Math_ApproachS(&this->unk_216, 0, 0xA, 0x5DC); + SkelAnime_Update(&this->skelAnime); + if (this->unk_214 == 0) { + func_808CCB08(this); + } else { + this->unk_214--; + } +} + +void func_808CCB08(EnVm* this) { + Animation_PlayOnce(&this->skelAnime, &object_vm_Anim_000068); + this->unk_214 = -1; + this->actionFunc = func_808CCB50; +} + +void func_808CCB50(EnVm* this, GlobalContext* globalCtx) { + Math_ApproachS(&this->unk_216, 0, 0xA, 0x5DC); + + if (this->unk_214 > 0) { + this->unk_214--; + } else if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_214 == -1) { + this->unk_214 = 10; + this->skelAnime.curFrame = 0.0f; + this->skelAnime.playSpeed = 2.0f; + } else { + func_808CC420(this); + } + } +} + +void func_808CCBE4(EnVm* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &object_vm_Anim_000068, -1.0f, Animation_GetLastFrame(&object_vm_Anim_000068), + 0.0f, ANIMMODE_ONCE, 0.0f); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 33); + this->unk_214 = 33; + this->unk_220 = 0.0f; + this->unk_224 = 0.0f; + this->actor.shape.yOffset = (this->actor.world.pos.y - this->actor.focus.pos.y) * 71.428566f; + this->actor.world.pos.y = this->actor.focus.pos.y; + this->actor.velocity.y = 8.0f; + this->actor.gravity = -0.5f; + this->actor.speedXZ = Rand_ZeroOne() + 1.0f; + this->unk_210 = 0; + this->actor.flags |= ACTOR_FLAG_10; + this->actionFunc = func_808CCCF0; +} + +void func_808CCCF0(EnVm* this, GlobalContext* globalCtx) { + this->unk_216 += 0x5DC; + this->unk_218 += 0x9C4; + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 40.0f, 7); + + this->unk_214--; + if (this->unk_214 == 1) { + EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0x6FF, 0); + + if (bomb != NULL) { + bomb->timer = 0; + } + } else if (this->unk_214 == 0) { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xB0); + Actor_MarkForDeath(&this->actor); + } +} + +void func_808CCDE4(EnVm* this, GlobalContext* globalCtx) { + s32 i; + s16 temp_v0; + + if (this->colliderJntSph.base.acFlags & AC_HIT) { + this->colliderJntSph.base.acFlags &= ~AC_HIT; + + for (i = 0; i < ARRAY_COUNT(this->colliderJntSphElements); i++) { + if (this->colliderJntSph.elements[i].info.bumperFlags & BUMP_HIT) { + break; + } + } + + if (i != ARRAY_COUNT(this->colliderJntSphElements)) { + func_800BE5CC(&this->actor, &this->colliderJntSph, i); + if (this->actor.colChkInfo.damageEffect == 0) { + func_808CCBE4(this, globalCtx); + } else if ((i == 0) && (this->actionFunc != func_808CCAA4)) { + temp_v0 = (this->actor.world.rot.y - this->actor.shape.rot.y) - this->unk_218; + if (ABS_ALT(temp_v0) > 0x6000) { + func_808CCA10(this); + } + } + } + } +} + +void EnVm_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnVm* this = THIS; + + func_808CCDE4(this, globalCtx); + + if (this->unk_210 == 2) { + func_800B31BC(globalCtx, &this->unk_234, 20, -1, 155, 10); + if ((globalCtx->gameplayFrames % 2) != 0) { + func_800BBFB0(globalCtx, &this->unk_234, 6.0f, 1, 120, 20, 1); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BIMOS_LAZER_GND - SFX_FLAG); + } + + if (this->unk_224 > 0.0f) { + func_800B9010(&this->actor, NA_SE_EN_BIMOS_LAZER - SFX_FLAG); + } + + this->actionFunc(this, globalCtx); + + this->unk_212 += 12; + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + if (this->actionFunc != func_808CCCF0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + } +} + +s32 EnVm_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnVm* this = THIS; + + if (limbIndex == OBJECT_VM_LIMB_02) { + rot->x += this->unk_216; + rot->y += this->unk_218; + } else if ((limbIndex == OBJECT_VM_LIMB_0A) && (this->actionFunc == func_808CCCF0)) { + *dList = NULL; + } + return false; +} + +void EnVm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnVm* this = THIS; + Vec3f sp5C; + Vec3f sp50; + CollisionPoly* sp4C; + s32 sp48; + + Collider_UpdateSpheres(limbIndex, &this->colliderJntSph); + + if (limbIndex == OBJECT_VM_LIMB_02) { + sp4C = NULL; + + Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_GetStateTranslationAndScaledZ(1600.0f, &this->unk_228); + Matrix_GetStateTranslationAndScaledZ(this->unk_224 * 71.428566f, &this->unk_234); + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.focus.pos, &this->unk_234, &sp5C, &sp4C, true, + true, false, true, &sp48)) { + this->unk_224 = Math_Vec3f_DistXYZ(&this->actor.focus.pos, &sp5C) - 5.0f; + this->unk_210 = 2; + Math_Vec3f_Copy(&this->unk_234, &sp5C); + } else if (this->unk_210 != 0) { + this->unk_210 = 1; + } + + sp50.x = this->unk_234.x + (Math_CosS(this->actor.shape.rot.y + this->unk_218) * 5.0f); + sp50.y = this->unk_234.y; + sp50.z = this->unk_234.z - (Math_SinS(this->actor.shape.rot.y + this->unk_218) * 5.0f); + + Collider_SetTrisVertices(&this->colliderTris, 0, &this->actor.focus.pos, &this->unk_234, &sp50); + } +} + +void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnVm* this = THIS; + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + + POLY_OPA_DISP = &gfx[1]; + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnVm_OverrideLimbDraw, + EnVm_PostLimbDraw, &this->actor); + + if (this->unk_210 == 2) { + gfx = POLY_XLU_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 60]); + gDPSetColorDither(&gfx[1], G_CD_DISABLE); + + Matrix_InsertTranslation(this->unk_234.x, this->unk_234.y + 10.0f, this->unk_234.z, MTXMODE_NEW); + Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); + + gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(&gfx[3], 0, 0, 255, 255, 255, 168); + gDPSetEnvColor(&gfx[4], 0, 0, 255, 0); + gSPSegment(&gfx[5], 0x08, D_808CD58C[globalCtx->gameplayFrames & 7]); + gSPDisplayList(&gfx[6], gameplay_keep_DL_044300); + + POLY_XLU_DISP = &gfx[7]; + } + + if (this->unk_224 > 0.0f) { + gfx = POLY_OPA_DISP; + + gSPSegment(&gfx[0], 0x08, func_8012CB28(globalCtx->state.gfxCtx, 0, this->unk_212)); + + Matrix_InsertTranslation(this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z, + MTXMODE_NEW); + Matrix_InsertRotation(this->unk_216, this->unk_218 + this->actor.shape.rot.y, 0, MTXMODE_APPLY); + Matrix_Scale(this->unk_220, this->unk_220, this->unk_224 * 0.0015f, MTXMODE_APPLY); + + gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[2], object_vm_DL_002728); + + POLY_OPA_DISP = &gfx[3]; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Vm/z_en_vm.h b/src/overlays/actors/ovl_En_Vm/z_en_vm.h index ad5c43abb..1901ac34a 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.h +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.h @@ -7,11 +7,32 @@ struct EnVm; typedef void (*EnVmActionFunc)(struct EnVm*, GlobalContext*); +#define ENVM_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + +#define ENVM_FF00_0 0 +#define ENVM_FF00_5 5 +#define ENVM_FF00_FF 0xFF + typedef struct EnVm { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC8]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[11]; + /* 0x01CA */ Vec3s morphTable[11]; /* 0x020C */ EnVmActionFunc actionFunc; - /* 0x0210 */ char unk_210[0x14C]; + /* 0x0210 */ u8 unk_210; + /* 0x0212 */ s16 unk_212; + /* 0x0214 */ s16 unk_214; + /* 0x0216 */ s16 unk_216; + /* 0x0218 */ s16 unk_218; + /* 0x021C */ f32 unk_21C; + /* 0x0220 */ f32 unk_220; + /* 0x0224 */ f32 unk_224; + /* 0x0228 */ Vec3f unk_228; + /* 0x0234 */ Vec3f unk_234; + /* 0x0240 */ ColliderJntSph colliderJntSph; + /* 0x0260 */ ColliderJntSphElement colliderJntSphElements[2]; + /* 0x02E0 */ ColliderTris colliderTris; + /* 0x0300 */ ColliderTrisElement colliderTrisElements[1]; } EnVm; // size = 0x35C extern const ActorInit En_Vm_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 59c5944e9..0cc7d3933 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -6258,8 +6258,8 @@ 0x808CCCF0:("func_808CCCF0",), 0x808CCDE4:("func_808CCDE4",), 0x808CCEE4:("EnVm_Update",), - 0x808CD020:("func_808CD020",), - 0x808CD08C:("func_808CD08C",), + 0x808CD020:("EnVm_OverrideLimbDraw",), + 0x808CD08C:("EnVm_PostLimbDraw",), 0x808CD238:("EnVm_Draw",), 0x808CD740:("DemoEffect_Init",), 0x808CD8E8:("DemoEffect_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index e8c4715cb..ae1e8f3a2 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1769,12 +1769,6 @@ D_0601AA60 = 0x0601AA60; D_060014C8 = 0x060014C8; D_06001C38 = 0x06001C38; -// ovl_En_Vm - -D_06000068 = 0x06000068; -D_06002728 = 0x06002728; -D_06003F60 = 0x06003F60; - // ovl_En_Wallmas D_06000590 = 0x06000590; From d5e692d0e109f491d3cd419dca949299ac66a50d Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Thu, 24 Mar 2022 19:07:59 -0700 Subject: [PATCH 100/257] En_Bom_Chu (Bombchu) OK and documented (#679) * EnBomChu_Init OK * EnBomChu_Destroy OK * func_808F7868 OK * func_808F79D4 OK * func_808F7E74 OK * func_808F7FA0 OK * func_808F77E4 OK * func_808F75D0 OK * func_808F7944 OK * func_808F7A84 OK * func_808F818C OK * func_808F8080 OK * func_808F7FD0 OK * EnBomChu_Update OK * EnBomChu_Draw OK * Drop unnecessary cast in Update * Import data into C * Object symbol * Use generated reloc * Port over OoT struct var names * Name all statics * Misc cleanup * Name some of the new struct vars introduced in MM * Port over most OoT function names * Name movingSpeed based on in-game observation * Name final param in EnBomChu_SpawnRipplesAndSplashes * More cleanup and OOT port * Some more names * More docs * Name last function * Final little cleanup * First round of review fixes * Change the name of that one function * More precise comment --- assets/xml/objects/gameplay_keep.xml | 7 +- spec | 3 +- .../actors/ovl_En_Bom_Chu/z_en_bom_chu.c | 549 +++++++++++++++++- .../actors/ovl_En_Bom_Chu/z_en_bom_chu.h | 18 +- tools/disasm/functions.txt | 22 +- 5 files changed, 552 insertions(+), 47 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 802ac6843..ef31ca7b7 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -838,8 +838,11 @@ - - + + + + + diff --git a/spec b/spec index fcfb12e4c..2bdf82937 100644 --- a/spec +++ b/spec @@ -1285,8 +1285,7 @@ beginseg name "ovl_En_Bom_Chu" compress include "build/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.o" - include "build/data/ovl_En_Bom_Chu/ovl_En_Bom_Chu.data.o" - include "build/data/ovl_En_Bom_Chu/ovl_En_Bom_Chu.reloc.o" + include "build/src/overlays/actors/ovl_En_Bom_Chu/ovl_En_Bom_Chu_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c index 47c25941d..fc63795de 100644 --- a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c +++ b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c @@ -5,21 +5,26 @@ */ #include "z_en_bom_chu.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) #define THIS ((EnBomChu*)thisx) +#define BOMBCHU_SCALE 0.01f + void EnBomChu_Init(Actor* thisx, GlobalContext* globalCtx); void EnBomChu_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx); void EnBomChu_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808F7868(EnBomChu* this, GlobalContext* globalCtx); -void func_808F7A84(EnBomChu* this, GlobalContext* globalCtx); -void func_808F7FA0(EnBomChu* this, GlobalContext* globalCtx); +void EnBomChu_WaitForRelease(EnBomChu* this, GlobalContext* globalCtx); +void EnBomChu_SetupMove(EnBomChu* this); +void EnBomChu_Move(EnBomChu* this, GlobalContext* globalCtx); +void EnBomChu_Explode(EnBomChu* this, GlobalContext* globalCtx); +void EnBomChu_WaitForDeath(EnBomChu* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Bom_Chu_InitVars = { ACTOR_EN_BOM_CHU, ACTORCAT_EXPLOSIVES, @@ -32,50 +37,536 @@ const ActorInit En_Bom_Chu_InitVars = { (ActorFunc)EnBomChu_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_808F88E0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_1 | OC1_TYPE_2, OC2_TYPE_2, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_1 | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 13 }, 100 }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808F890C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), + ICHAIN_VEC3F_DIV1000(scale, 1000 * BOMBCHU_SCALE, ICHAIN_STOP), }; -#endif +static EffectBlureInit2 sBlureInit = { + 0, 0, 0, { 250, 0, 0, 250 }, { 200, 0, 0, 130 }, { 150, 0, 0, 100 }, { 100, 0, 0, 50 }, 16, + 0, 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, +}; -extern ColliderSphereInit D_808F88E0; -extern InitChainEntry D_808F890C[]; +void EnBomChu_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBomChu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/EnBomChu_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + this->collider.dim.worldSphere.radius = sSphereInit.dim.modelSphere.radius; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/EnBomChu_Destroy.s") + Effect_Add(globalCtx, &this->blure1Index, EFFECT_BLURE2, 0, 0, &sBlureInit); + Effect_Add(globalCtx, &this->blure2Index, EFFECT_BLURE2, 0, 0, &sBlureInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F75D0.s") + this->timer = 120; + this->actor.room = -1; + this->shouldTimerCountDown = true; + this->unk_174 = 0.0f; + this->actionFunc = EnBomChu_WaitForRelease; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F77E4.s") +void EnBomChu_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBomChu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7868.s") + Effect_Destroy(globalCtx, this->blure1Index); + Effect_Destroy(globalCtx, this->blure2Index); + Collider_DestroySphere(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7944.s") +/** + * Returns true if floorPoly is valid for the Bombchu to move on, false otherwise. + */ +s32 EnBomChu_UpdateFloorPoly(EnBomChu* this, CollisionPoly* floorPoly, GlobalContext* globalCtx) { + Vec3f normal; + Vec3f vec; + f32 angle; + f32 magnitude; + f32 normDotUp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F79D4.s") + this->actor.floorPoly = floorPoly; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7A84.s") + // This NULL check means if the player releases a Bombchu with no collision + // below them, the game will not crash, unlike OoT. + if (floorPoly != NULL) { + normal.x = COLPOLY_GET_NORMAL(floorPoly->normal.x); + normal.y = COLPOLY_GET_NORMAL(floorPoly->normal.y); + normal.z = COLPOLY_GET_NORMAL(floorPoly->normal.z); + } else { + EnBomChu_Explode(this, globalCtx); + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7E74.s") + normDotUp = DOTXYZ(normal, this->axisUp); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7FA0.s") + if (fabsf(normDotUp) >= 0.999f) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7FD0.s") + angle = func_80086C48(normDotUp); + if (angle < 0.001f) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F8080.s") + Math3D_CrossProduct(&this->axisUp, &normal, &vec); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F818C.s") + magnitude = Math3D_Vec3fMagnitude(&vec); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/EnBomChu_Update.s") + if (magnitude < 0.001f) { + EnBomChu_Explode(this, globalCtx); + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/EnBomChu_Draw.s") + Math_Vec3f_Scale(&vec, 1.0f / magnitude); + Matrix_InsertRotationAroundUnitVector_f(angle, &vec, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&this->axisLeft, &vec); + Math_Vec3f_Copy(&this->axisLeft, &vec); + Math3D_CrossProduct(&this->axisLeft, &normal, &this->axisForwards); + + magnitude = Math3D_Vec3fMagnitude(&this->axisForwards); + if (magnitude < 0.001f) { + EnBomChu_Explode(this, globalCtx); + return false; + } + + Math_Vec3f_Scale(&this->axisForwards, 1.0f / magnitude); + Math_Vec3f_Copy(&this->axisUp, &normal); + return true; +} + +void EnBomChu_UpdateRotation(EnBomChu* this) { + MtxF mf; + + mf.xx = this->axisLeft.x; + mf.xy = this->axisLeft.y; + mf.xz = this->axisLeft.z; + + mf.yx = this->axisUp.x; + mf.yy = this->axisUp.y; + mf.yz = this->axisUp.z; + + mf.zx = this->axisForwards.x; + mf.zy = this->axisForwards.y; + mf.zz = this->axisForwards.z; + + func_8018219C(&mf, &this->actor.world.rot, 0); + this->actor.world.rot.x = -this->actor.world.rot.x; +} + +void EnBomChu_WaitForRelease(EnBomChu* this, GlobalContext* globalCtx) { + Player* player; + + if (this->timer == 0) { + EnBomChu_Explode(this, globalCtx); + } else if (Actor_HasNoParent(&this->actor, globalCtx)) { + player = GET_PLAYER(globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &player->actor.world.pos); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + this->actor.shape.rot.y = player->actor.shape.rot.y; + this->actor.flags |= ACTOR_FLAG_1; + func_800B8EF4(globalCtx, &this->actor); + + this->isMoving = true; + this->actor.speedXZ = 8.0f; + this->movingSpeed = 8.0f; + EnBomChu_SetupMove(this); + } +} + +s32 EnBomChu_IsOnCollisionPoly(GlobalContext* globalCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, + CollisionPoly** poly, s32* bgId) { + if ((BgCheck_EntityLineTest1(&globalCtx->colCtx, posA, posB, posResult, poly, true, true, true, true, bgId)) && + (!(func_800C9A4C(&globalCtx->colCtx, *poly, *bgId) & 0x30))) { + return true; + } + + return false; +} + +void EnBomChu_SetupMove(EnBomChu* this) { + func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); + + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + + Matrix_GetStateTranslationAndScaledY(1.0f, &this->axisUp); + Matrix_GetStateTranslationAndScaledZ(1.0f, &this->axisForwards); + Matrix_GetStateTranslationAndScaledX(1.0f, &this->axisLeft); + + this->actor.world.rot.x = -this->actor.shape.rot.x; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.z = this->actor.shape.rot.z; + this->actionFunc = EnBomChu_Move; +} + +void EnBomChu_Move(EnBomChu* this, GlobalContext* globalCtx) { + CollisionPoly* polySide = NULL; + CollisionPoly* polyUpDown = NULL; + s32 bgIdSide; + s32 bgIdUpDown; + s32 i; + s32 isFloorPolyValid; + f32 lineLength; + Vec3f posA; + Vec3f posB; + Vec3f posSide; + Vec3f posUpDown; + + bgIdUpDown = bgIdSide = BGCHECK_SCENE; + isFloorPolyValid = false; + + this->actor.speedXZ = this->movingSpeed; + lineLength = 2.0f * this->movingSpeed; + + if ((this->timer == 0) || (this->collider.base.acFlags & AC_HIT) || (this->collider.base.ocFlags1 & OC1_HIT)) { + EnBomChu_Explode(this, globalCtx); + return; + } + + posA.x = this->actor.world.pos.x + (this->axisUp.x * 2.0f); + posA.y = this->actor.world.pos.y + (this->axisUp.y * 2.0f); + posA.z = this->actor.world.pos.z + (this->axisUp.z * 2.0f); + + posB.x = this->actor.world.pos.x - (this->axisUp.x * 4.0f); + posB.y = this->actor.world.pos.y - (this->axisUp.y * 4.0f); + posB.z = this->actor.world.pos.z - (this->axisUp.z * 4.0f); + + if (EnBomChu_IsOnCollisionPoly(globalCtx, &posA, &posB, &posUpDown, &polyUpDown, &bgIdUpDown)) { + // forwards + posB.x = (this->axisForwards.x * lineLength) + posA.x; + posB.y = (this->axisForwards.y * lineLength) + posA.y; + posB.z = (this->axisForwards.z * lineLength) + posA.z; + + if (EnBomChu_IsOnCollisionPoly(globalCtx, &posA, &posB, &posSide, &polySide, &bgIdSide)) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, polySide, globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &posSide); + this->actor.floorBgId = bgIdSide; + this->actor.speedXZ = 0.0f; + } else { + if (this->actor.floorPoly != polyUpDown) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, polyUpDown, globalCtx); + } + + Math_Vec3f_Copy(&this->actor.world.pos, &posUpDown); + this->actor.floorBgId = bgIdUpDown; + } + } else { + this->actor.speedXZ = 0.0f; + lineLength *= 3.0f; + Math_Vec3f_Copy(&posA, &posB); + + for (i = 0; i < 3; i++) { + if (i == 0) { + // backwards + posB.x = posA.x - (this->axisForwards.x * lineLength); + posB.y = posA.y - (this->axisForwards.y * lineLength); + posB.z = posA.z - (this->axisForwards.z * lineLength); + } else if (i == 1) { + // left + posB.x = posA.x + (this->axisLeft.x * lineLength); + posB.y = posA.y + (this->axisLeft.y * lineLength); + posB.z = posA.z + (this->axisLeft.z * lineLength); + } else { + // right + posB.x = posA.x - (this->axisLeft.x * lineLength); + posB.y = posA.y - (this->axisLeft.y * lineLength); + posB.z = posA.z - (this->axisLeft.z * lineLength); + } + + if (EnBomChu_IsOnCollisionPoly(globalCtx, &posA, &posB, &posSide, &polySide, &bgIdSide)) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, polySide, globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &posSide); + this->actor.floorBgId = bgIdSide; + break; + } + } + + if (i == 3) { + // no collision nearby + EnBomChu_Explode(this, globalCtx); + } + } + + if (isFloorPolyValid) { + EnBomChu_UpdateRotation(this); + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + } + + if (this->isMoving) { + func_800B8F98(&this->actor, NA_SE_IT_BOMBCHU_MOVE - SFX_FLAG); + } + + if (this->actor.speedXZ != 0.0f) { + this->movingSpeed = this->actor.speedXZ; + } +} + +void EnBomChu_Explode(EnBomChu* this, GlobalContext* globalCtx) { + EnBom* bomb; + s32 i; + + bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + + this->shouldTimerCountDown = true; + this->isMoving = false; + + if (bomb != NULL) { + bomb->timer = 0; + } + + this->timer = 1; + this->actor.speedXZ = 0.0f; + + if (this->actor.depthInWater > 0.0f) { + for (i = 0; i < 40; i++) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 1.0f, 5.0f, 30.0f, 0.25f); + } + } + + this->actor.draw = NULL; + this->actionFunc = EnBomChu_WaitForDeath; +} + +void EnBomChu_WaitForDeath(EnBomChu* this, GlobalContext* globalCtx) { + if (this->timer == 0) { + Actor_MarkForDeath(&this->actor); + } +} + +/** + * Transform coordinates from actor coordinate space to world space, according to current orientation. + * `offset` is expected to already be at world scale. + */ +void EnBomChu_ActorCoordsToWorld(EnBomChu* this, Vec3f* offset, Vec3f* pos) { + f32 x = offset->x + this->visualJitter; + + pos->x = this->actor.world.pos.x + (this->axisLeft.x * x) + (this->axisUp.x * offset->y) + + (this->axisForwards.x * offset->z); + pos->y = this->actor.world.pos.y + (this->axisLeft.y * x) + (this->axisUp.y * offset->y) + + (this->axisForwards.y * offset->z); + pos->z = this->actor.world.pos.z + (this->axisLeft.z * x) + (this->axisUp.z * offset->y) + + (this->axisForwards.z * offset->z); +} + +void EnBomChu_SpawnRipplesAndSplashes(EnBomChu* this, GlobalContext* globalCtx, f32 y, s32 spawnExtraRipples) { + s32 pad; + Vec3f pos; + + pos.x = this->actor.world.pos.x; + pos.y = y; + pos.z = this->actor.world.pos.z; + + EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 0); + + if (spawnExtraRipples) { + EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 4); + EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 8); + } else { + pos.x -= this->axisForwards.x * 10.0f; + pos.z -= this->axisForwards.z * 10.0f; + } + + pos.y += 5.0f; + EffectSsGSplash_Spawn(globalCtx, &pos, NULL, NULL, 1, 450); +} + +void EnBomChu_HandleNonSceneCollision(EnBomChu* this, GlobalContext* globalCtx) { + Vec3f originalWorldPos; + Vec3f posA; + Vec3f posB; + Vec3f originalAxisUp; + s16 yaw; + f32 sin; + f32 cos; + f32 tempX; + CollisionPoly* poly = NULL; + s32 bgId = BGCHECK_SCENE; + s32 isFloorPolyValid; + + Math_Vec3f_Copy(&originalWorldPos, &this->actor.world.pos); + Math_Vec3f_Copy(&originalAxisUp, &this->axisUp); + yaw = this->actor.shape.rot.y; + BgCheck2_UpdateActorAttachedToMesh(&globalCtx->colCtx, this->actor.floorBgId, &this->actor); + + if (yaw != this->actor.shape.rot.y) { + yaw = this->actor.shape.rot.y - yaw; + + sin = Math_SinS(yaw); + cos = Math_CosS(yaw); + + tempX = this->axisForwards.x; + this->axisForwards.x = (sin * this->axisForwards.z) + (cos * tempX); + this->axisForwards.z = (cos * this->axisForwards.z) - (sin * tempX); + + tempX = this->axisUp.x; + this->axisUp.x = (sin * this->axisUp.z) + (cos * tempX); + this->axisUp.z = (cos * this->axisUp.z) - (sin * tempX); + + tempX = this->axisLeft.x; + this->axisLeft.x = (sin * this->axisLeft.z) + (cos * tempX); + this->axisLeft.z = (cos * this->axisLeft.z) - (sin * tempX); + } + + posA.x = originalWorldPos.x + (2.0f * originalAxisUp.x); + posA.y = originalWorldPos.y + (2.0f * originalAxisUp.y); + posA.z = originalWorldPos.z + (2.0f * originalAxisUp.z); + + posB.x = this->actor.world.pos.x + (2.0f * this->axisUp.x); + posB.y = this->actor.world.pos.y + (2.0f * this->axisUp.y); + posB.z = this->actor.world.pos.z + (2.0f * this->axisUp.z); + + if (EnBomChu_IsOnCollisionPoly(globalCtx, &posA, &posB, &originalWorldPos, &poly, &bgId)) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, poly, globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &originalWorldPos); + this->actor.floorBgId = bgId; + this->actor.speedXZ = 0.0f; + + if (isFloorPolyValid) { + EnBomChu_UpdateRotation(this); + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + } + } +} + +void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f sBlureP1Offset = { 0.0f, 7.0f, -6.0f }; + static Vec3f sBlureP2LeftOffset = { 12.0f, 0.0f, -5.0f }; + static Vec3f sBlureP2RightOffset = { -12.0f, 0.0f, -5.0f }; + s32 pad; + EnBomChu* this = THIS; + Vec3f blureP1; + Vec3f blureP2; + WaterBox* waterBox; + f32 waterY; + + if (this->actor.floorBgId != BGCHECK_SCENE) { + EnBomChu_HandleNonSceneCollision(this, globalCtx); + } + + if (this->shouldTimerCountDown) { + this->timer--; + } + + this->actionFunc(this, globalCtx); + + if ((this->actionFunc != EnBomChu_WaitForDeath) && + (SurfaceType_IsWallDamage(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId))) { + EnBomChu_Explode(this, globalCtx); + return; + } + + Actor_MoveWithoutGravity(&this->actor); + + this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->actor.world.pos.y; + this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->actionFunc != EnBomChu_WaitForRelease) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + this->actor.focus.pos.x = this->actor.world.pos.x + (20.0f * this->axisUp.x); + this->actor.focus.pos.y = this->actor.world.pos.y + (20.0f * this->axisUp.y); + this->actor.focus.pos.z = this->actor.world.pos.z + (20.0f * this->axisUp.z); + + if (this->isMoving) { + this->visualJitter = + (5.0f + (Rand_ZeroOne() * 3.0f)) * Math_SinS((((s32)(Rand_ZeroOne() * 512.0f) + 0x3000) * this->timer)); + EnBomChu_ActorCoordsToWorld(this, &sBlureP1Offset, &blureP1); + + EnBomChu_ActorCoordsToWorld(this, &sBlureP2LeftOffset, &blureP2); + EffectBlure_AddVertex(Effect_GetByIndex(this->blure1Index), &blureP1, &blureP2); + + EnBomChu_ActorCoordsToWorld(this, &sBlureP2RightOffset, &blureP2); + EffectBlure_AddVertex(Effect_GetByIndex(this->blure2Index), &blureP1, &blureP2); + + waterY = this->actor.world.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterY, &waterBox)) { + this->actor.depthInWater = waterY - this->actor.world.pos.y; + + if (this->actor.depthInWater < 0.0f) { + if (this->actor.bgCheckFlags & 0x20) { + EnBomChu_SpawnRipplesAndSplashes(this, globalCtx, waterY, true); + } + + this->actor.bgCheckFlags &= ~0x20; + return; + } + + if (!(this->actor.bgCheckFlags & 0x20) && (this->timer != 120)) { + EnBomChu_SpawnRipplesAndSplashes(this, globalCtx, waterY, true); + } else { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 3.0f, 15.0f, 0.25f); + } + + this->actor.bgCheckFlags |= 0x20; + } else { + this->actor.bgCheckFlags &= ~0x20; + this->actor.depthInWater = BGCHECK_Y_MIN; + } + } +} + +void EnBomChu_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBomChu* this = THIS; + f32 colorIntensity; + s32 blinkHalfPeriod; + s32 blinkTime; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_800B8050(&this->actor, globalCtx, 0); + + if (this->timer >= 40) { + blinkTime = this->timer % 20; + blinkHalfPeriod = 10; + } else if (this->timer >= 10) { + blinkTime = this->timer % 10; + blinkHalfPeriod = 5; + } else { + blinkTime = this->timer & 1; + blinkHalfPeriod = 1; + } + + if (blinkTime > blinkHalfPeriod) { + blinkTime = 2 * blinkHalfPeriod - blinkTime; + } + + colorIntensity = blinkTime / (f32)blinkHalfPeriod; + gDPSetEnvColor(POLY_OPA_DISP++, (s32)(colorIntensity * 209.0f) + 9, (s32)(colorIntensity * 34.0f) + 9, + (s32)(colorIntensity * -35.0f) + 35, 255); + Matrix_InsertTranslation(this->visualJitter * (1.0f / BOMBCHU_SCALE), 0.0f, 0.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gBombchuDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h index 910ad5174..30a3dab9a 100644 --- a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h +++ b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h @@ -8,9 +8,21 @@ struct EnBomChu; typedef void (*EnBomChuActionFunc)(struct EnBomChu*, GlobalContext*); typedef struct EnBomChu { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnBomChuActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x98]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnBomChuActionFunc actionFunc; + /* 0x148 */ u8 shouldTimerCountDown; // the actor always sets this to true + /* 0x149 */ u8 isMoving; + /* 0x14A */ s16 timer; + /* 0x14C */ Vec3f axisForwards; + /* 0x158 */ Vec3f axisUp; + /* 0x164 */ Vec3f axisLeft; + /* 0x170 */ f32 visualJitter; + /* 0x174 */ f32 unk_174; // set but never used + /* 0x178 */ UNK_TYPE1 unk_178[0x4]; + /* 0x17C */ f32 movingSpeed; + /* 0x180 */ s32 blure1Index; + /* 0x184 */ s32 blure2Index; + /* 0x188 */ ColliderSphere collider; } EnBomChu; // size = 0x1E0 extern const ActorInit En_Bom_Chu_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 0cc7d3933..b78680dd4 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -6749,17 +6749,17 @@ 0x808F69B4:("EnIn_Draw",), 0x808F74B0:("EnBomChu_Init",), 0x808F7580:("EnBomChu_Destroy",), - 0x808F75D0:("func_808F75D0",), - 0x808F77E4:("func_808F77E4",), - 0x808F7868:("func_808F7868",), - 0x808F7944:("func_808F7944",), - 0x808F79D4:("func_808F79D4",), - 0x808F7A84:("func_808F7A84",), - 0x808F7E74:("func_808F7E74",), - 0x808F7FA0:("func_808F7FA0",), - 0x808F7FD0:("func_808F7FD0",), - 0x808F8080:("func_808F8080",), - 0x808F818C:("func_808F818C",), + 0x808F75D0:("EnBomChu_UpdateFloorPoly",), + 0x808F77E4:("EnBomChu_UpdateRotation",), + 0x808F7868:("EnBomChu_WaitForRelease",), + 0x808F7944:("EnBomChu_IsOnCollisionPoly",), + 0x808F79D4:("EnBomChu_SetupMove",), + 0x808F7A84:("EnBomChu_Move",), + 0x808F7E74:("EnBomChu_Explode",), + 0x808F7FA0:("EnBomChu_WaitForDeath",), + 0x808F7FD0:("EnBomChu_ActorCoordsToWorld",), + 0x808F8080:("EnBomChu_SpawnRipplesAndSplashes",), + 0x808F818C:("EnBomChu_HandleNonSceneCollision",), 0x808F83B8:("EnBomChu_Update",), 0x808F8714:("EnBomChu_Draw",), 0x808F8AA0:("func_808F8AA0",), From 984a5061c2df123296e649a0fc34874c845e7e29 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Thu, 24 Mar 2022 19:14:14 -0700 Subject: [PATCH 101/257] ObjectFsn documented (#680) * Cleanup some shopkeepers * More cleanup * Document animations * General cleanup * Animation enums * Limb maxes * More Cleanup * Some more minor stuff * fsn cutscene state * Parens and postlimbdraw * Ossan Limbs * Remove ENFSN_LIMB_MAX * SI_MAX * Compound macro * Document gameplayKeep textures used by shopkeepers * Ani Limbs in Ossan * Format * PR suggestion * Remove trueTmp from EnFsn --- assets/xml/objects/gameplay_keep.xml | 6 +- assets/xml/objects/object_fsn.xml | 164 ++++++---- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 289 +++++++++-------- src/overlays/actors/ovl_En_Fsn/z_en_fsn.h | 7 +- src/overlays/actors/ovl_En_GirlA/z_en_girla.c | 28 +- src/overlays/actors/ovl_En_GirlA/z_en_girla.h | 7 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 302 ++++++++++-------- src/overlays/actors/ovl_En_Ossan/z_en_ossan.h | 17 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 231 +++++++------- .../actors/ovl_En_Suttari/z_en_suttari.c | 114 +++---- .../actors/ovl_En_Suttari/z_en_suttari.h | 2 +- src/overlays/actors/ovl_En_Trt/z_en_trt.c | 169 +++++----- src/overlays/actors/ovl_En_Trt/z_en_trt.h | 2 +- tools/disasm/functions.txt | 40 +-- 14 files changed, 726 insertions(+), 652 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index ef31ca7b7..856e3d92b 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -873,9 +873,9 @@ - - - + + + diff --git a/assets/xml/objects/object_fsn.xml b/assets/xml/objects/object_fsn.xml index 7c3d0beb2..f90bf4e4d 100644 --- a/assets/xml/objects/object_fsn.xml +++ b/assets/xml/objects/object_fsn.xml @@ -1,63 +1,111 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index 31a7046cb..cd4b3884f 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -5,7 +5,6 @@ */ #include "z_en_fsn.h" -#include "objects/object_fsn/object_fsn.h" #include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) @@ -47,6 +46,29 @@ void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx); void EnFsn_LookToShopkeeperFromShelf(EnFsn* this, GlobalContext* globalCtx); void EnFsn_PlayerCannotBuy(EnFsn* this, GlobalContext* globalCtx); +typedef enum { + /* 0 */ ENFSN_CUTSCENESTATE_STOPPED, + /* 1 */ ENFSN_CUTSCENESTATE_WAITING, + /* 2 */ ENFSN_CUTSCENESTATE_PLAYING +} EnFsnCutsceneState; + +typedef enum { + /* 00 */ FSN_ANIMATION_IDLE, + /* 01 */ FSN_ANIMATION_SCRATCH_BACK, + /* 02 */ FSN_ANIMATION_TURN_AROUND_FORWARD, + /* 03 */ FSN_ANIMATION_TURN_AROUND_REVERSE, + /* 04 */ FSN_ANIMATION_HANDS_ON_COUNTER_START, + /* 05 */ FSN_ANIMATION_HANDS_ON_COUNTER_LOOP, + /* 06 */ FSN_ANIMATION_HAND_ON_FACE_START, + /* 07 */ FSN_ANIMATION_HAND_ON_FACE_LOOP, + /* 08 */ FSN_ANIMATION_LEAN_FORWARD_START, + /* 09 */ FSN_ANIMATION_LEAN_FORWARD_LOOP, + /* 10 */ FSN_ANIMATION_SLAM_COUNTER_START, + /* 11 */ FSN_ANIMATION_SLAM_COUNTER_LOOP, + /* 12 */ FSN_ANIMATION_MAKE_OFFER, + /* 13 */ FSN_ANIMATION_MAX +} FsnAnimation; + const ActorInit En_Fsn_InitVars = { ACTOR_EN_FSN, ACTORCAT_NPC, @@ -60,19 +82,19 @@ const ActorInit En_Fsn_InitVars = { }; static AnimationInfoS sAnimations[] = { - { &object_fsn_Anim_012C34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_0131FC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_00C58C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00C58C, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00E3EC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00F00C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_00CB3C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00D354, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_0138B0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_01430C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_00B9D8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00C26C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_00DE34, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnScratchBackAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnTurnAroundAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnTurnAroundAnim, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandsOnCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandsOnCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnHandOnFaceStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandOnFaceLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnLeanForwardStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnLeanForwardLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnSlamCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnSlamCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnMakeOfferAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; static ColliderCylinderInit sCylinderInit = { @@ -187,7 +209,8 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_HandleSetupResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx) && this->cutsceneState == 0) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx) && + this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); if (ENFSN_IS_SHOP(&this->actor)) { @@ -205,19 +228,19 @@ void EnFsn_UpdateCollider(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_HandleLookToShopkeeperBuyingCutscene(EnFsn* this) { - if (this->cutsceneState == 2 && this->lookToShopkeeperBuyingCutscene != this->cutscene && - this->actor.textId == 0x29CE) { + if ((this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) && + (this->lookToShopkeeperBuyingCutscene != this->cutscene) && (this->actor.textId == 0x29CE)) { ActorCutscene_Stop(this->cutscene); if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } this->cutscene = this->lookToShopkeeperBuyingCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); - this->cutsceneState = 1; - } else if (this->cutsceneState == 1) { + this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; + } else if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_Start(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; } else { ActorCutscene_SetIntentToPlay(this->cutscene); } @@ -362,9 +385,9 @@ void EnFsn_SpawnShopItems(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_EndInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); - this->cutsceneState = 0; + this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; } Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); globalCtx->msgCtx.msgMode = 0x43; @@ -400,14 +423,14 @@ s32 EnFsn_TestCancelOption(EnFsn* this, GlobalContext* globalCtx, Input* input) } void EnFsn_UpdateCursorPos(EnFsn* this, GlobalContext* globalCtx) { - s16 sp2E; - s16 sp2C; + s16 x; + s16 y; f32 xOffset = 0.0f; f32 yOffset = 17.0f; - Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &sp2E, &sp2C); - this->cursorPos.x = sp2E + xOffset; - this->cursorPos.y = sp2C + yOffset; + Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); + this->cursorPos.x = x + xOffset; + this->cursorPos.y = y + yOffset; this->cursorPos.z = 1.2f; } @@ -579,8 +602,7 @@ void EnFsn_UpdateCursorAnim(EnFsn* this) { void EnFsn_UpdateStickDirectionPromptAnim(EnFsn* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - s32 maxColor = 255; - f32 tmp; + s32 maxColor = 255; // POSSIBLY FAKE if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -607,54 +629,51 @@ void EnFsn_UpdateStickDirectionPromptAnim(EnFsn* this) { stickAnimTween = 0.0f; this->stickAnimState = 0; } - - tmp = 155.0f * arrowAnimTween; - this->stickAnimTween = stickAnimTween; this->stickLeftPrompt.arrowColor.r = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.g = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); - this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100, arrowAnimTween); + this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowColor.r = (maxColor - ((s32)tmp)) & 0xFF; - this->stickRightPrompt.arrowColor.g = (255 - ((s32)tmp)) & 0xFF; + this->stickRightPrompt.arrowTexX = 290.0f; + + this->stickRightPrompt.arrowColor.r = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); + this->stickRightPrompt.arrowColor.g = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowTexX = 290.0f; this->stickLeftPrompt.arrowTexX = 33.0f; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexX += 8.0f * stickAnimTween; + this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexX -= 8.0f * stickAnimTween; - this->stickLeftPrompt.arrowTexY = this->stickRightPrompt.arrowTexY = 91.0f; - this->stickLeftPrompt.stickTexY = this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + + this->stickRightPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.stickTexY = 95.0f; } void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { - EnFsn* this2; - s32 maxColor = 255; - if (EnFsn_HasItemsToSell()) { EnFsn_SpawnShopItems(this, globalCtx); - this2 = this; - this2->cursorPos.x = 100.0f; - this2->cursorPos.y = 100.0f; - this2->stickAccumY = 0; - this2->stickAccumX = 0; + this->cursorPos.y = this->cursorPos.x = 100.0f; + this->stickAccumY = 0; + this->stickAccumX = 0; this->cursorPos.z = 1.2f; this->cursorColor.r = 0; this->cursorColor.g = 80; - this->cursorColor.b = maxColor; - this->cursorColor.a = maxColor; + this->cursorColor.b = 255; + this->cursorColor.a = 255; + this->cursorAnimTween = 0.0f; this->cursorAnimState = 0; this->drawCursor = 0; - this->cursorAnimTween = 0.0f; this->stickLeftPrompt.stickColor.r = 200; this->stickLeftPrompt.stickColor.g = 200; @@ -662,8 +681,8 @@ void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { this->stickLeftPrompt.stickColor.a = 180; this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexY = 95.0f; - this->stickLeftPrompt.arrowColor.r = maxColor; - this->stickLeftPrompt.arrowColor.g = maxColor; + this->stickLeftPrompt.arrowColor.r = 255; + this->stickLeftPrompt.arrowColor.g = 255; this->stickLeftPrompt.arrowColor.b = 0; this->stickLeftPrompt.arrowColor.a = 200; this->stickLeftPrompt.arrowTexX = 33.0f; @@ -677,7 +696,7 @@ void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { this->stickRightPrompt.stickColor.a = 180; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexY = 95.0f; - this->stickRightPrompt.arrowColor.r = maxColor; + this->stickRightPrompt.arrowColor.r = 255; this->stickRightPrompt.arrowColor.g = 0; this->stickRightPrompt.arrowColor.b = 0; this->stickRightPrompt.arrowColor.a = 200; @@ -691,21 +710,21 @@ void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { this->stickAnimTween = this->arrowAnimTween = 0.0f; } this->blinkTimer = 20; - this->animationIdx = 4; + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_START; this->eyeTextureIdx = 0; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnFsn_Idle; } void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->animationIdx == 4) { + if (this->animationIndex == FSN_ANIMATION_HANDS_ON_COUNTER_START) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (curFrame == frameCount) { - this->animationIdx = 5; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } return; } @@ -716,13 +735,13 @@ void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if (this->cutsceneState == 0) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } this->cutscene = this->lookToShopkeeperCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); - this->cutsceneState = 1; + this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; } this->actor.textId = EnFsn_GetWelcome(globalCtx); Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); @@ -738,29 +757,29 @@ void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (this->flags & ENFSN_ANGRY) { this->flags &= ~ENFSN_ANGRY; - this->animationIdx = 11; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_SLAM_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else { - if (this->animationIdx == 11 && Animation_OnFrame(&this->skelAnime, 18.0f)) { + if (this->animationIndex == FSN_ANIMATION_SLAM_COUNTER_LOOP && Animation_OnFrame(&this->skelAnime, 18.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } if (this->flags & ENFSN_CALM_DOWN) { this->flags &= ~ENFSN_CALM_DOWN; - this->animationIdx = 5; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else if (this->flags & ENFSN_OFFER_FINAL_PRICE) { this->flags &= ~ENFSN_OFFER_FINAL_PRICE; - this->animationIdx = 12; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_MAKE_OFFER; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else { - if (this->animationIdx == 12) { + if (this->animationIndex == FSN_ANIMATION_MAKE_OFFER) { if (curFrame == frameCount) { - this->animationIdx = 5; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else { if (Animation_OnFrame(&this->skelAnime, 28.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); @@ -776,10 +795,10 @@ void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_BeginInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 1) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; if (Player_GetMask(globalCtx) == PLAYER_MASK_NONE) { func_8011552C(globalCtx, 16); if (EnFsn_HasItemsToSell()) { @@ -862,13 +881,12 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { } else if (talkState == 4) { func_8011552C(globalCtx, 6); if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { - u32 trueTmp = true; switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); - this->isSelling = trueTmp; + this->isSelling = true; this->stickLeftPrompt.isEnabled = false; - this->stickRightPrompt.isEnabled = trueTmp; + this->stickRightPrompt.isEnabled = true; this->actor.textId = 0x29D6; Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_FaceShopkeeperSelling; @@ -941,9 +959,9 @@ void EnFsn_MakeOffer(EnFsn* this, GlobalContext* globalCtx) { func_8019F208(); globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); - this->cutsceneState = 0; + this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; } switch (this->price) { case 5: @@ -975,7 +993,7 @@ void EnFsn_MakeOffer(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_GiveItem(EnFsn* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { - if (this->isSelling == true && this->items[this->cursorIdx]->getItemId == GI_MASK_ALL_NIGHT) { + if ((this->isSelling == true) && (this->items[this->cursorIdx]->getItemId == GI_MASK_ALL_NIGHT)) { func_80151BB4(globalCtx, 45); func_80151BB4(globalCtx, 3); } @@ -1027,10 +1045,10 @@ void EnFsn_ResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_ResumeShoppingInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 0) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; if (!this->isSelling) { this->actionFunc = EnFsn_AskCanBuyMore; } else if (this->actor.textId != 0x29D6) { @@ -1052,18 +1070,18 @@ void EnFsn_ResumeShoppingInteraction(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_LookToShelf(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } this->cutscene = this->lookToShelfCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); - this->cutsceneState = 1; - } else if (this->cutsceneState == 1) { + this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; + } else if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene) != 0) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; EnFsn_UpdateCursorPos(this, globalCtx); this->actionFunc = EnFsn_BrowseShelf; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); @@ -1100,18 +1118,18 @@ void EnFsn_BrowseShelf(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_LookToShopkeeperFromShelf(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } this->cutscene = this->lookToShopkeeperFromShelfCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); - this->cutsceneState = 1; - } else if (this->cutsceneState == 1) { + this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; + } else if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; this->actor.textId = 0x29D6; @@ -1131,9 +1149,9 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { func_8019F208(); gSaveContext.weekEventReg[33] |= 4; case CANBUY_RESULT_SUCCESS_1: - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); - this->cutsceneState = 0; + this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; } func_8019F208(); item = this->items[this->cursorIdx]; @@ -1214,10 +1232,10 @@ void EnFsn_PlayerCannotBuy(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if (this->cutsceneState == 0) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; } else { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -1260,10 +1278,10 @@ void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if (this->cutsceneState == 0) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; } else { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -1386,12 +1404,12 @@ void EnFsn_Blink(EnFsn* this) { } void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx) { - EnFsn* this = THIS; s32 pad; + EnFsn* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_fsn_Skel_013320, &object_fsn_Anim_012C34, this->jointTable, - this->morphTable, 19); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFsnSkel, &gFsnIdleAnim, this->jointTable, this->morphTable, + FSN_LIMB_MAX + 1); if (ENFSN_IS_SHOP(&this->actor)) { this->actor.shape.rot.y = BINANG_ROT180(this->actor.shape.rot.y); this->actor.flags &= ~ACTOR_FLAG_1; @@ -1408,8 +1426,8 @@ void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx) { this->eyeTextureIdx = 0; this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; - this->animationIdx = 0; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_IDLE; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnFsn_IdleBackroom; } } @@ -1441,7 +1459,10 @@ void EnFsn_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnFsn_DrawCursor(EnFsn* this, GlobalContext* globalCtx, f32 x, f32 y, f32 z, u8 drawCursor) { - s32 ulx, uly, lrx, lry; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; f32 w; s32 dsdx; s32 pad; @@ -1451,8 +1472,8 @@ void EnFsn_DrawCursor(EnFsn* this, GlobalContext* globalCtx, f32 x, f32 y, f32 z func_8012C654(globalCtx->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, gameplay_keep_Tex_01F740, G_IM_FMT_IA, 16, 16, 0, - G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, + G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); w = 16.0f * z; ulx = (x - w) * 4.0f; uly = (y - w + -12.0f) * 4.0f; @@ -1467,9 +1488,14 @@ void EnFsn_DrawCursor(EnFsn* this, GlobalContext* globalCtx, f32 x, f32 y, f32 z void EnFsn_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y, f32 z, s32 s, s32 t, f32 dx, f32 dy) { f32 unk; - s32 ulx, uly, lrx, lry; - f32 w, h; - s32 dsdx, dtdy; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; + f32 w; + f32 h; + s32 dsdx; + s32 dtdy; OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); @@ -1499,15 +1525,9 @@ void EnFsn_DrawStickDirectionPrompts(EnFsn* this, GlobalContext* globalCtx) { if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(globalCtx->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F8C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 191, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 23 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnFsn_DrawTextRec(globalCtx, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, @@ -1520,15 +1540,9 @@ void EnFsn_DrawStickDirectionPrompts(EnFsn* this, GlobalContext* globalCtx) { this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F7C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 127, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 15 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnFsn_DrawTextRec(globalCtx, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, @@ -1547,21 +1561,20 @@ void EnFsn_DrawStickDirectionPrompts(EnFsn* this, GlobalContext* globalCtx) { s32 EnFsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnFsn* this = THIS; - s16 tmp; s32 limbRotTableIdx; - if (limbIndex == 16) { + if (limbIndex == FSN_LIMB_HEAD) { Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); } if (ENFSN_IS_BACKROOM(&this->actor)) { switch (limbIndex) { - case 8: + case FSN_LIMB_TORSO: limbRotTableIdx = 0; break; - case 11: + case FSN_LIMB_LEFT_HAND: limbRotTableIdx = 1; break; - case 16: + case FSN_LIMB_HEAD: limbRotTableIdx = 2; break; default: @@ -1569,13 +1582,11 @@ s32 EnFsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, break; } if (limbRotTableIdx < 9) { - tmp = (s32)(Math_SinS(this->limbRotYTable[limbRotTableIdx]) * 200.0f); - rot->y += tmp; - tmp = (s32)(Math_CosS(this->limbRotZTable[limbRotTableIdx]) * 200.0f); - rot->z += tmp; + rot->y += (s16)(Math_SinS(this->limbRotYTable[limbRotTableIdx]) * 200.0f); + rot->z += (s16)(Math_CosS(this->limbRotZTable[limbRotTableIdx]) * 200.0f); } } - if (limbIndex == 17) { + if (limbIndex == FSN_LIMB_TOUPEE) { *dList = NULL; } return false; @@ -1584,22 +1595,22 @@ s32 EnFsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnFsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnFsn* this = THIS; - if (limbIndex == 16) { + if (limbIndex == FSN_LIMB_HEAD) { this->actor.focus.pos.x = this->actor.world.pos.x; this->actor.focus.pos.y = this->actor.world.pos.y + 60.0f; this->actor.focus.pos.z = this->actor.world.pos.z; OPEN_DISPS(globalCtx->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, object_fsn_DL_00F180); - gSPDisplayList(POLY_OPA_DISP++, object_fsn_DL_00F218); + gSPDisplayList(POLY_OPA_DISP++, gFsnGlassesFrameDL); + gSPDisplayList(POLY_OPA_DISP++, gFsnGlassesLensesDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } } void EnFsn_Draw(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr sEyeTextures[] = { object_fsn_Tex_005BC0, object_fsn_Tex_006D40, object_fsn_Tex_007140 }; - EnFsn* this = THIS; + static TexturePtr sEyeTextures[] = { gFsnEyeOpenTex, gFsnEyeHalfTex, gFsnEyeClosedTex }; s32 pad; + EnFsn* this = THIS; s16 i; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h index 139e145da..5fabf59ad 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h @@ -3,6 +3,7 @@ #include "global.h" #include "overlays/actors/ovl_En_GirlA/z_en_girla.h" +#include "objects/object_fsn/object_fsn.h" #define ENFSN_IS_BACKROOM(thisx) ((thisx)->params & 1) #define ENFSN_IS_SHOP(thisx) (!((thisx)->params & 1)) @@ -27,8 +28,8 @@ typedef struct EnFsn { /* 0x24E */ s16 limbRotZTable[19]; /* 0x274 */ Vec3s headRot; /* 0x27A */ Vec3s unk27A; // Set but never used - /* 0x280 */ Vec3s jointTable[19]; - /* 0x2F2 */ Vec3s morphTable[19]; + /* 0x280 */ Vec3s jointTable[FSN_LIMB_MAX + 1]; + /* 0x2F2 */ Vec3s morphTable[FSN_LIMB_MAX + 1]; /* 0x364 */ s16 eyeTextureIdx; /* 0x366 */ s16 blinkTimer; /* 0x368 */ s16 cutsceneState; @@ -63,7 +64,7 @@ typedef struct EnFsn { /* 0x444 */ u8 arrowAnimState; /* 0x445 */ u8 stickAnimState; /* 0x448 */ f32 shopItemSelectedTween; - /* 0x44C */ s16 animationIdx; + /* 0x44C */ s16 animationIndex; /* 0x44E */ u16 flags; } EnFsn; // size = 0x450 diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c index 317c64412..df2206522 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -159,8 +159,8 @@ void EnGirlA_SetupAction(EnGirlA* this, EnGirlAActionFunc action) { void EnGirlA_InitObjIndex(EnGirlA* this, GlobalContext* globalCtx) { s16 params = this->actor.params; - //! @bug: Condition is impossible - if (params >= 43 && params < 0) { + //! @bug: Condition is impossible, && should be an || + if (params >= SI_MAX && params < SI_POTION_RED_1) { Actor_MarkForDeath(&this->actor); return; } @@ -377,24 +377,24 @@ s32 EnGirlA_CanBuyFairy(GlobalContext* globalCtx, EnGirlA* this) { void EnGirlA_BuyBottleItem(GlobalContext* globalCtx, EnGirlA* this) { switch (this->actor.params) { - case 0: - case 10: - case 18: - case 29: - case 32: - case 35: + case SI_POTION_RED_1: + case SI_POTION_RED_2: + case SI_POTION_RED_3: + case SI_POTION_RED_4: + case SI_POTION_RED_5: + case SI_POTION_RED_6: Item_Give(globalCtx, ITEM_POTION_RED); break; - case 1: - case 5: - case 14: + case SI_POTION_GREEN_1: + case SI_POTION_GREEN_2: + case SI_POTION_GREEN_3: Item_Give(globalCtx, ITEM_POTION_GREEN); break; - case 2: + case SI_POTION_BLUE: Item_Give(globalCtx, ITEM_POTION_BLUE); break; - case 3: - case 11: + case SI_FAIRY_1: + case SI_FAIRY_2: Item_Give(globalCtx, ITEM_FAIRY); break; } diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.h b/src/overlays/actors/ovl_En_GirlA/z_en_girla.h index fa2711501..a3d8e0206 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.h +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.h @@ -25,7 +25,7 @@ typedef struct ShopItemEntry { typedef struct EnGirlA { /* 0x000 */ Actor actor; - /* 0x144 */ char unk144[0x44]; + /* 0x144 */ UNK_TYPE1 unk144[0x44]; /* 0x188 */ EnGirlAActionFunc actionFunc; /* 0x18C */ s8 objIndex; /* 0x190 */ EnGirlAActionFunc mainActionFunc; @@ -103,7 +103,8 @@ typedef enum { /* 39 */ SI_SWORD_RAZOR, /* 40 */ SI_SWORD_GILDED, /* 41 */ SI_SHIELD_HERO_4, - /* 42 */ SI_SHIELD_MIRROR + /* 42 */ SI_SHIELD_MIRROR, + /* 43 */ SI_MAX } EnGirlAShopItemId; extern const ActorInit En_GirlA_InitVars; @@ -122,7 +123,7 @@ typedef struct { /* 0x28 */ f32 arrowTexX; /* 0x2C */ f32 arrowTexY; /* 0x30 */ f32 texZ; // Used for both stickTexZ and arrowTexZ - /* 0x34 */ s32 isEnabled; + /* 0x34 */ u32 isEnabled; } StickDirectionPrompt; // size = 0x38 typedef struct ShopItem { diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index 7e3276263..13c9ee276 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -6,8 +6,6 @@ #include "z_en_ossan.h" #include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_fsn/object_fsn.h" -#include "objects/object_ani/object_ani.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) @@ -20,17 +18,19 @@ void EnOssan_Init(Actor* thisx, GlobalContext* globalCtx); void EnOssan_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnOssan_Update(Actor* thisx, GlobalContext* globalCtx); -void EnOssan_DrawCuriosityShopMan(Actor* thisx, GlobalContext* globalCtx); -void EnOssan_DrawPartTimeWorker(Actor* thisx, GlobalContext* globalCtx); +void EnOssan_CuriosityShopMan_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnOssan_PartTimeWorker_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnOssan_CuriosityShopMan_Init(EnOssan* this, GlobalContext* globalCtx); +u16 EnOssan_CuriosityShopMan_GetWelcome(EnOssan* this, GlobalContext* globalCtx); + +void EnOssan_PartTimeWorker_Init(EnOssan* this, GlobalContext* globalCtx); +u16 EnOssan_PartTimerWorker_GetWelcome(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_InitCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_InitPartTimeWorker(EnOssan* this, GlobalContext* globalCtx); -u16 EnOssan_GetWelcomeCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx); void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx); void EnOssan_Idle(EnOssan* this, GlobalContext* globalCtx); void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx); void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx); -u16 EnOssan_GetWelcomePartTimeWorker(EnOssan* this, GlobalContext* globalCtx); void EnOssan_SetHaveMet(EnOssan* this); void EnOssan_StartShopping(GlobalContext* globalCtx, EnOssan* this); void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx); @@ -53,6 +53,45 @@ void EnOssan_GetCutscenes(EnOssan* this, GlobalContext* globalCtx); s32 EnOssan_ReturnItemToShelf(EnOssan* this); s32 EnOssan_TakeItemOffShelf(EnOssan* this); +typedef enum { + /* 0 */ ENOSSAN_CUTSCENESTATE_STOPPED, + /* 1 */ ENOSSAN_CUTSCENESTATE_WAITING, + /* 2 */ ENOSSAN_CUTSCENESTATE_PLAYING +} EnOssanCutsceneState; + +typedef enum { + /* 00 */ FSN_ANIMATION_IDLE, + /* 01 */ FSN_ANIMATION_SCRATCH_BACK, + /* 02 */ FSN_ANIMATION_TURN_AROUND_FORWARD, + /* 03 */ FSN_ANIMATION_TURN_AROUND_REVERSE, + /* 04 */ FSN_ANIMATION_HANDS_ON_COUNTER_START, + /* 05 */ FSN_ANIMATION_HANDS_ON_COUNTER_LOOP, + /* 06 */ FSN_ANIMATION_HAND_ON_FACE_START, + /* 07 */ FSN_ANIMATION_HAND_ON_FACE_LOOP, + /* 08 */ FSN_ANIMATION_LEAN_FORWARD_START, + /* 09 */ FSN_ANIMATION_LEAN_FORWARD_LOOP, + /* 10 */ FSN_ANIMATION_SLAM_COUNTER_START, + /* 11 */ FSN_ANIMATION_SLAM_COUNTER_LOOP, + /* 12 */ FSN_ANIMATION_MAKE_OFFER, + /* 13 */ FSN_ANIMATION_MAX +} FsnAnimation; + +typedef enum { + /* 00 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_1, + /* 01 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_2, + /* 02 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_FORWARD_1, + /* 03 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_REVERSE, + /* 04 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_FORWARD_2, + /* 05 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_3, + /* 06 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_FORWARD_3, + /* 07 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_4, + /* 08 */ ANI_ANIMATION_APOLOGY_START, + /* 09 */ ANI_ANIMATION_APOLOGY_LOOP, + /* 10 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_FORWARD_4, + /* 11 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_5, + /* 12 */ ANI_ANIMATION_MAX +} AniAnimation; + const ActorInit En_Ossan_InitVars = { ACTOR_EN_OSSAN, ACTORCAT_NPC, @@ -66,19 +105,19 @@ const ActorInit En_Ossan_InitVars = { }; static AnimationInfoS sAnimationsCuriosityShopMan[] = { - { &object_fsn_Anim_012C34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_0131FC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_00C58C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00C58C, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00E3EC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00F00C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_00CB3C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00D354, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_0138B0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_01430C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_00B9D8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_fsn_Anim_00C26C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_fsn_Anim_00DE34, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnScratchBackAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnTurnAroundAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnTurnAroundAnim, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandsOnCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandsOnCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnHandOnFaceStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandOnFaceLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnLeanForwardStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnLeanForwardLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnSlamCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnSlamCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnMakeOfferAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; static AnimationInfoS sAnimationsPartTimeWorker[] = { @@ -352,9 +391,9 @@ void EnOssan_Idle(EnOssan* this, GlobalContext* globalCtx) { void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx) { AnimationInfoS* animations = sAnimations[this->actor.params]; s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(animations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(animations[this->animationIndex].animation); - if (this->animationIdx == 3) { + if (this->animationIndex == FSN_ANIMATION_TURN_AROUND_REVERSE) { frameCount = 0; } if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_WAITING) { @@ -367,47 +406,47 @@ void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx) { } if (this->actor.params == ENOSSAN_CURIOSITY_SHOP_MAN) { if (curFrame == frameCount) { - switch (this->animationIdx) { - case 1: - this->animationIdx = 2; - SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 2); + switch (this->animationIndex) { + case FSN_ANIMATION_SCRATCH_BACK: + this->animationIndex = FSN_ANIMATION_TURN_AROUND_FORWARD; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, FSN_ANIMATION_TURN_AROUND_FORWARD); break; - case 2: + case FSN_ANIMATION_TURN_AROUND_FORWARD: EnOssan_SetHaveMet(this); - this->textId = EnOssan_GetWelcomeCuriosityShopMan(this, globalCtx); - SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, this->animationIdx); + this->textId = EnOssan_CuriosityShopMan_GetWelcome(this, globalCtx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, this->animationIndex); break; - case 4: - case 6: - case 8: - case 10: - this->animationIdx++; - SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, this->animationIdx); + case FSN_ANIMATION_HANDS_ON_COUNTER_START: + case FSN_ANIMATION_HAND_ON_FACE_START: + case FSN_ANIMATION_LEAN_FORWARD_START: + case FSN_ANIMATION_SLAM_COUNTER_START: + this->animationIndex++; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, this->animationIndex); Message_StartTextbox(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, false); break; - case 5: - case 7: - case 9: - case 11: - this->animationIdx = 3; - SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 3); + case FSN_ANIMATION_HANDS_ON_COUNTER_LOOP: + case FSN_ANIMATION_HAND_ON_FACE_LOOP: + case FSN_ANIMATION_LEAN_FORWARD_LOOP: + case FSN_ANIMATION_SLAM_COUNTER_LOOP: + this->animationIndex = FSN_ANIMATION_TURN_AROUND_REVERSE; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, FSN_ANIMATION_TURN_AROUND_REVERSE); break; - case 3: - this->animationIdx = 1; - SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); + case FSN_ANIMATION_TURN_AROUND_REVERSE: + this->animationIndex = FSN_ANIMATION_SCRATCH_BACK; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, FSN_ANIMATION_SCRATCH_BACK); EnOssan_SetupAction(this, EnOssan_Idle); break; default: - this->animationIdx = 1; - SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); + this->animationIndex = FSN_ANIMATION_SCRATCH_BACK; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, FSN_ANIMATION_SCRATCH_BACK); EnOssan_SetupAction(this, EnOssan_Idle); break; } } } else { EnOssan_SetHaveMet(this); - this->textId = EnOssan_GetWelcomePartTimeWorker(this, globalCtx); + this->textId = EnOssan_PartTimerWorker_GetWelcome(this, globalCtx); Message_StartTextbox(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, false); } @@ -525,8 +564,8 @@ void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { EnOssan_RotateHead(this, globalCtx); if (talkState == 5 && func_80147624(globalCtx)) { - if (this->animationIdx == 9 && this->actor.params == ENOSSAN_PART_TIME_WORKER) { - this->animationIdx = 1; + if ((this->animationIndex == ANI_ANIMATION_APOLOGY_LOOP) && (this->actor.params == ENOSSAN_PART_TIME_WORKER)) { + this->animationIndex = ANI_ANIMATION_STANDING_NORMAL_LOOP_2; SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); } this->flags &= ~LOOKED_AT_PLAYER; @@ -541,12 +580,12 @@ void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { return; } } - if (talkState == 10 && this->actor.params == ENOSSAN_PART_TIME_WORKER && - player->transformation == PLAYER_FORM_ZORA && func_80147624(globalCtx)) { - this->animationIdx = 9; - SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 9); + if ((talkState == 10) && (this->actor.params == ENOSSAN_PART_TIME_WORKER) && + (player->transformation == PLAYER_FORM_ZORA) && func_80147624(globalCtx)) { + this->animationIndex = ANI_ANIMATION_APOLOGY_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, ANI_ANIMATION_APOLOGY_LOOP); } - if (this->animationIdx == 11 && Animation_OnFrame(&this->skelAnime, 18.0f)) { + if ((this->animationIndex == FSN_ANIMATION_SLAM_COUNTER_LOOP) && Animation_OnFrame(&this->skelAnime, 18.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } } @@ -558,8 +597,8 @@ s32 EnOssan_FacingShopkeeperDialogResult(EnOssan* this, GlobalContext* globalCtx switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); - if (this->actor.params == ENOSSAN_PART_TIME_WORKER && player->transformation == PLAYER_FORM_ZORA) { - this->animationIdx = 9; + if ((this->actor.params == ENOSSAN_PART_TIME_WORKER) && (player->transformation == PLAYER_FORM_ZORA)) { + this->animationIndex = ANI_ANIMATION_APOLOGY_LOOP; SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 9); } EnOssan_SetupAction(this, EnOssan_TalkToShopkeeper); @@ -627,8 +666,8 @@ void EnOssan_TalkToShopkeeper(EnOssan* this, GlobalContext* globalCtx) { AnimationInfoS* animations = sAnimations[this->actor.params]; if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { - if (this->animationIdx == 9 && this->actor.params == ENOSSAN_PART_TIME_WORKER) { - this->animationIdx = 1; + if ((this->animationIndex == ANI_ANIMATION_APOLOGY_LOOP) && (this->actor.params == ENOSSAN_PART_TIME_WORKER)) { + this->animationIndex = ANI_ANIMATION_STANDING_NORMAL_LOOP_2; SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); } EnOssan_StartShopping(globalCtx, this); @@ -1238,10 +1277,7 @@ void EnOssan_UpdateCursorAnim(EnOssan* this) { void EnOssan_UpdateStickDirectionPromptAnim(EnOssan* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - - // Possibly Fake - s32 maxColor = 255; - f32 tmp; + s32 maxColor = 255; // POSSIBLY FAKE if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -1268,31 +1304,33 @@ void EnOssan_UpdateStickDirectionPromptAnim(EnOssan* this) { stickAnimTween = 0.0f; this->stickAnimState = 0; } - - tmp = 155.0f * arrowAnimTween; - this->stickAnimTween = stickAnimTween; this->stickLeftPrompt.arrowColor.r = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.g = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); - this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100, arrowAnimTween); + this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowColor.r = (maxColor - ((s32)tmp)) & 0xFF; - this->stickRightPrompt.arrowColor.g = (255 - ((s32)tmp)) & 0xFF; + this->stickRightPrompt.arrowTexX = 290.0f; + + this->stickRightPrompt.arrowColor.r = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); + this->stickRightPrompt.arrowColor.g = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowTexX = 290.0f; this->stickLeftPrompt.arrowTexX = 33.0f; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexX += 8.0f * stickAnimTween; + this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexX -= 8.0f * stickAnimTween; - this->stickLeftPrompt.arrowTexY = this->stickRightPrompt.arrowTexY = 91.0f; - this->stickLeftPrompt.stickTexY = this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + + this->stickRightPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.stickTexY = 95.0f; } void EnOssan_WaitForBlink(EnOssan* this) { @@ -1324,52 +1362,52 @@ void EnOssan_Blink(EnOssan* this) { } } -void EnOssan_InitCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_fsn_Skel_013320, &object_fsn_Anim_012C34, this->jointTable, - this->morphTable, 19); - this->actor.draw = EnOssan_DrawCuriosityShopMan; +void EnOssan_CuriosityShopMan_Init(EnOssan* this, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFsnSkel, &gFsnIdleAnim, this->jointTable, this->morphTable, + ENOSSAN_LIMB_MAX); + this->actor.draw = EnOssan_CuriosityShopMan_Draw; } -void EnOssan_InitPartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { +void EnOssan_PartTimeWorker_Init(EnOssan* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gAniSkeleton, &gAniStandingNormalAnim, this->jointTable, this->morphTable, 16); - this->actor.draw = EnOssan_DrawPartTimeWorker; + this->actor.draw = EnOssan_PartTimeWorker_Draw; } -u16 EnOssan_GetWelcomeCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx) { +u16 EnOssan_CuriosityShopMan_GetWelcome(EnOssan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); u16 textId = Text_GetFaceReaction(globalCtx, 0x2F); if (textId != 0) { - this->animationIdx = 4; + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_START; this->flags |= END_INTERACTION; return textId; } switch (player->transformation) { case PLAYER_FORM_DEKU: - this->animationIdx = 10; + this->animationIndex = FSN_ANIMATION_SLAM_COUNTER_START; if (gSaveContext.weekEventReg[18] & 0x10) { return sWelcomeDekuTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeDekuFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; case PLAYER_FORM_ZORA: - this->animationIdx = 8; + this->animationIndex = FSN_ANIMATION_LEAN_FORWARD_START; if (gSaveContext.weekEventReg[18] & 8) { return sWelcomeZoraTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeZoraFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; case PLAYER_FORM_GORON: - this->animationIdx = 6; + this->animationIndex = FSN_ANIMATION_HAND_ON_FACE_START; if (gSaveContext.weekEventReg[18] & 4) { return sWelcomeGoronTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeGoronFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } - this->animationIdx = 4; + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_START; return sWelcomeHumanTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } -u16 EnOssan_GetWelcomePartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { +u16 EnOssan_PartTimerWorker_GetWelcome(EnOssan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); u16 textId = Text_GetFaceReaction(globalCtx, 0x36); @@ -1421,7 +1459,7 @@ void EnOssan_SetHaveMet(EnOssan* this) { } void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx) { - static EnOssanActionFunc sInitFuncs[] = { EnOssan_InitCuriosityShopMan, EnOssan_InitPartTimeWorker }; + static EnOssanActionFunc sInitFuncs[] = { EnOssan_CuriosityShopMan_Init, EnOssan_PartTimeWorker_Init }; ShopItem* shopItems; if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { @@ -1486,8 +1524,9 @@ void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx) { this->arrowAnimTween = 0.0f; this->stickAnimTween = 0.0f; this->shopItemSelectedTween = 0.0f; + Actor_SetScale(&this->actor, sActorScales[this->actor.params]); - this->animationIdx = 1; + this->animationIndex = 1; // FSN_ANIMATION_SCRATCH_BACK and ANI_ANIMATION_STANDING_NORMAL_LOOP_2 SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations[this->actor.params], 1); EnOssan_SpawnShopItems(this, globalCtx, shopItems); this->blinkTimer = 20; @@ -1524,19 +1563,22 @@ void EnOssan_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnOssan_DrawCursor(GlobalContext* globalCtx, EnOssan* this, f32 x, f32 y, f32 z, u8 drawCursor) { - s32 ulx, uly, lrx, lry; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; f32 w; s32 dsdx; - ((void)"../z_en_oB1.c"); // Unreferenced + (void)"../z_en_oB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); if (drawCursor != 0) { func_8012C654(globalCtx->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, gameplay_keep_Tex_01F740, G_IM_FMT_IA, 16, 16, 0, - G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, + G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); w = 16.0f * z; ulx = (x - w) * 4.0f; uly = (y - w) * 4.0f; @@ -1551,11 +1593,16 @@ void EnOssan_DrawCursor(GlobalContext* globalCtx, EnOssan* this, f32 x, f32 y, f void EnOssan_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y, f32 z, s32 s, s32 t, f32 dx, f32 dy) { f32 unk; - s32 ulx, uly, lrx, lry; - f32 w, h; - s32 dsdx, dtdy; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; + f32 w; + f32 h; + s32 dsdx; + s32 dtdy; - ((void)"../z_en_oB1.c"); // Unreferenced + (void)"../z_en_oB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); @@ -1581,21 +1628,15 @@ void EnOssan_DrawStickDirectionPrompts(GlobalContext* globalCtx, EnOssan* this) s32 drawStickRightPrompt = this->stickLeftPrompt.isEnabled; s32 drawStickLeftPrompt = this->stickRightPrompt.isEnabled; - ((void)"../z_en_oB1.c"); // Unreferenced + (void)"../z_en_oB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(globalCtx->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F8C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 191, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 23 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnOssan_DrawTextRec(globalCtx, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, @@ -1608,15 +1649,9 @@ void EnOssan_DrawStickDirectionPrompts(GlobalContext* globalCtx, EnOssan* this) this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F7C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 127, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 15 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnOssan_DrawTextRec(globalCtx, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, @@ -1633,72 +1668,73 @@ void EnOssan_DrawStickDirectionPrompts(GlobalContext* globalCtx, EnOssan* this) CLOSE_DISPS(globalCtx->state.gfxCtx); } -s32 EnOssan_OverrideLimbDrawCuriosityShopMan(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, - Vec3s* rot, Actor* thisx) { +s32 EnOssan_CuriosityShopMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, + Vec3s* rot, Actor* thisx) { EnOssan* this = THIS; - if (limbIndex == 16) { + if (limbIndex == FSN_LIMB_HEAD) { Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); } return false; } -s32 EnOssan_OverrideLimbDrawPartTimeWorker(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnOssan_PartTimeWorker_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, + Vec3s* rot, Actor* thisx) { EnOssan* this = THIS; - if (limbIndex == 15) { + if (limbIndex == ANI_LIMB_HEAD) { Matrix_InsertXRotation_s(this->headRotPartTimeWorker.y, MTXMODE_APPLY); Matrix_InsertZRotation_s(this->headRotPartTimeWorker.x, MTXMODE_APPLY); } return false; } -void EnOssan_PostLimbDrawCuriosityShopMan(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, - Actor* thisx) { +void EnOssan_CuriosityShopMan_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, + Actor* thisx) { EnOssan* this = THIS; - if (limbIndex == 1 || limbIndex == 9 || limbIndex == 12) { + if (limbIndex == FSN_LIMB_PELVIS || limbIndex == FSN_LIMB_LEFT_UPPER_ARM || limbIndex == FSN_LIMB_RIGHT_UPPER_ARM) { rot->y += (s16)Math_SinS(this->limbRotTableY[limbIndex]) * 200; rot->z += (s16)Math_CosS(this->limbRotTableZ[limbIndex]) * 200; } } -void EnOssan_PostLimbDrawPartTimeWorker(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, - Actor* thisx) { +void EnOssan_PartTimeWorker_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, + Actor* thisx) { static Vec3f sPartTimeWorkerFocusOffset = { 800.0f, 500.0f, 0.0f }; EnOssan* this = THIS; - if (limbIndex == 15) { + if (limbIndex == ANI_LIMB_HEAD) { Matrix_MultiplyVector3fByState(&sPartTimeWorkerFocusOffset, &this->actor.focus.pos); } } -void EnOssan_DrawCuriosityShopMan(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr sEyeTextures[] = { object_fsn_Tex_005BC0, object_fsn_Tex_006D40, object_fsn_Tex_007140 }; - EnOssan* this = THIS; +void EnOssan_CuriosityShopMan_Draw(Actor* thisx, GlobalContext* globalCtx) { + static TexturePtr sEyeTextures[] = { gFsnEyeOpenTex, gFsnEyeHalfTex, gFsnEyeClosedTex }; s32 pad; + EnOssan* this = THIS; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnOssan_OverrideLimbDrawCuriosityShopMan, EnOssan_PostLimbDrawCuriosityShopMan, &this->actor); + EnOssan_CuriosityShopMan_OverrideLimbDraw, EnOssan_CuriosityShopMan_PostLimbDraw, + &this->actor); EnOssan_DrawCursor(globalCtx, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); EnOssan_DrawStickDirectionPrompts(globalCtx, this); CLOSE_DISPS(globalCtx->state.gfxCtx); } -void EnOssan_DrawPartTimeWorker(Actor* thisx, GlobalContext* globalCtx) { +void EnOssan_PartTimeWorker_Draw(Actor* thisx, GlobalContext* globalCtx) { static TexturePtr sEyeTextures[] = { gAniOpenEyeTex, gAniClosingEyeTex, gAniClosedEyeTex }; - EnOssan* this = THIS; s32 pad; + EnOssan* this = THIS; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnOssan_OverrideLimbDrawPartTimeWorker, EnOssan_PostLimbDrawPartTimeWorker, &this->actor); + EnOssan_PartTimeWorker_OverrideLimbDraw, EnOssan_PartTimeWorker_PostLimbDraw, &this->actor); EnOssan_DrawCursor(globalCtx, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); EnOssan_DrawStickDirectionPrompts(globalCtx, this); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h index 53f8b8f39..58c638d8e 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h @@ -2,8 +2,11 @@ #define Z_EN_OSSAN_H #include "global.h" - #include "overlays/actors/ovl_En_GirlA/z_en_girla.h" +#include "objects/object_ani/object_ani.h" +#include "objects/object_fsn/object_fsn.h" + +#define ENOSSAN_LIMB_MAX MAX(FSN_LIMB_MAX + 1, ANI_LIMB_MAX) struct EnOssan; @@ -50,9 +53,9 @@ typedef struct EnOssan { /* 0x2CC */ Vec3s unk2CC; // Set but never used /* 0x2D2 */ s16 limbRotTableY[19]; /* 0x2F8 */ s16 limbRotTableZ[19]; - /* 0x31E */ Vec3s jointTable[19]; - /* 0x390 */ Vec3s morphTable[19]; - /* 0x402 */ s16 animationIdx; + /* 0x31E */ Vec3s jointTable[ENOSSAN_LIMB_MAX]; + /* 0x390 */ Vec3s morphTable[ENOSSAN_LIMB_MAX]; + /* 0x402 */ s16 animationIndex; /* 0x404 */ Vec3s headRotPartTimeWorker; /* 0x40A */ u16 flags; } EnOssan; // size = 0x40C @@ -68,12 +71,6 @@ typedef enum { /* 1 */ ENOSSAN_PART_TIME_WORKER } EnOssanWorker; -typedef enum { - /* 0 */ ENOSSAN_CUTSCENESTATE_STOPPED, - /* 1 */ ENOSSAN_CUTSCENESTATE_WAITING, - /* 2 */ ENOSSAN_CUTSCENESTATE_PLAYING -} EnOssanCutsceneState; - extern const ActorInit En_Ossan_InitVars; #endif // Z_EN_OSSAN_H diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index ecf1f814b..7d63609c1 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -20,13 +20,14 @@ void EnSob1_Init(Actor* thisx, GlobalContext* globalCtx); void EnSob1_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSob1_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSob1_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx); -void EnSob1_DrawGoronShopkeeper(Actor* thisx, GlobalContext* globalCtx); -void EnSob1_DrawBombShopkeeper(Actor* thisx, GlobalContext* globalCtx); +void EnSob1_ZoraShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSob1_GoronShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSob1_BombShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnSob1_ZoraShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx); +void EnSob1_GoronShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx); +void EnSob1_BombShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_InitZoraShopkeeper(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_InitGoronShopkeeper(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_InitBombShopkeeper(EnSob1* this, GlobalContext* globalCtx); void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx); void EnSob1_Idle(EnSob1* this, GlobalContext* globalCtx); void EnSob1_Walk(EnSob1* this, GlobalContext* globalCtx); @@ -139,10 +140,10 @@ static InitChainEntry sInitChain[] = { }; static EnSob1ActionFunc sInitFuncs[] = { - EnSob1_InitZoraShopkeeper, - EnSob1_InitGoronShopkeeper, - EnSob1_InitBombShopkeeper, - EnSob1_InitGoronShopkeeper, + EnSob1_ZoraShopkeeper_Init, + EnSob1_GoronShopkeeper_Init, + EnSob1_BombShopkeeper_Init, + EnSob1_GoronShopkeeper_Init, }; static Vec3f sPosOffset[] = { @@ -329,7 +330,7 @@ u16 EnSob1_GetGoodbye(EnSob1* this) { return 0x64C; } -void EnSob1_EndInteractionBombShop(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_BombShopkeeper_EndInteraction(EnSob1* this, GlobalContext* globalCtx) { this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -451,7 +452,7 @@ void EnSob1_EndInteraction(GlobalContext* globalCtx, EnSob1* this) { s32 EnSob1_TestEndInteraction(EnSob1* this, GlobalContext* globalCtx, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { if (this->shopType == BOMB_SHOP) { - EnSob1_EndInteractionBombShop(this, globalCtx); + EnSob1_BombShopkeeper_EndInteraction(this, globalCtx); } else { EnSob1_EndInteraction(globalCtx, this); } @@ -625,7 +626,7 @@ s32 EnSob1_FacingShopkeeperDialogResult(EnSob1* this, GlobalContext* globalCtx) case 1: func_8019F230(); if (this->shopType == BOMB_SHOP) { - EnSob1_EndInteractionBombShop(this, globalCtx); + EnSob1_BombShopkeeper_EndInteraction(this, globalCtx); } else { EnSob1_EndInteraction(globalCtx, this); } @@ -1192,10 +1193,7 @@ void EnSob1_UpdateCursorAnim(EnSob1* this) { void EnSob1_UpdateStickDirectionPromptAnim(EnSob1* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - - // Possbily fake temps - s32 maxColor = 255; - f32 tmp; + s32 maxColor = 255; // POSSIBLY FAKE if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -1222,31 +1220,33 @@ void EnSob1_UpdateStickDirectionPromptAnim(EnSob1* this) { stickAnimTween = 0.0f; this->stickAnimState = 0; } - - tmp = 155.0f * arrowAnimTween; - this->stickAnimTween = stickAnimTween; this->stickLeftPrompt.arrowColor.r = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.g = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); - this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100, arrowAnimTween); + this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowColor.r = (maxColor - ((s32)tmp)) & 0xFF; - this->stickRightPrompt.arrowColor.g = (255 - ((s32)tmp)) & 0xFF; + this->stickRightPrompt.arrowTexX = 290.0f; + + this->stickRightPrompt.arrowColor.r = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); + this->stickRightPrompt.arrowColor.g = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowTexX = 290.0f; this->stickLeftPrompt.arrowTexX = 33.0f; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexX += 8.0f * stickAnimTween; + this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexX -= 8.0f * stickAnimTween; - this->stickLeftPrompt.arrowTexY = this->stickRightPrompt.arrowTexY = 91.0f; - this->stickLeftPrompt.stickTexY = this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + + this->stickRightPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.stickTexY = 95.0f; } s16 EnSob1_GetXZAngleAndDistanceSqToPoint(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq) { @@ -1319,42 +1319,38 @@ s32 EnSob1_AreObjectsLoaded(EnSob1* this, GlobalContext* globalCtx) { return false; } -void EnSob1_InitZoraShopkeeper(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_ZoraShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, 20); gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); Animation_Change(&this->skelAnime, &object_masterzoora_Anim_00078C, 1.0f, 0.0f, Animation_GetLastFrame(&object_masterzoora_Anim_00078C), 0, 0.0f); - this->actor.draw = EnSob1_DrawZoraShopkeeper; + this->actor.draw = EnSob1_ZoraShopkeeper_Draw; this->changeObjectFunc = EnSob1_ChangeObject; } -void EnSob1_InitGoronShopkeeper(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_GoronShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, this->morphTable, 18); gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); Animation_Change(&this->skelAnime, &object_mastergolon_Anim_0000FC, 1.0f, 0.0f, Animation_GetLastFrame(&object_mastergolon_Anim_0000FC), 0, 0.0f); - this->actor.draw = EnSob1_DrawGoronShopkeeper; + this->actor.draw = EnSob1_GoronShopkeeper_Draw; this->changeObjectFunc = EnSob1_ChangeObject; } -void EnSob1_InitBombShopkeeper(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_BombShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rs_Skel_009220, &object_rs_Anim_009120, this->jointTable, this->morphTable, 16); - this->actor.draw = EnSob1_DrawBombShopkeeper; + this->actor.draw = EnSob1_BombShopkeeper_Draw; this->changeObjectFunc = NULL; this->skelAnime.playSpeed = 2.0f; } void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { ShopItem* shopItems; - EnSob1XZRange* unkStruct; + EnSob1XZRange* xzRange; Vec3f* posOffset; - // Possibly fake temps - EnSob1* this2; - u32 maxColor = 255; - if (EnSob1_AreObjectsLoaded(this, globalCtx)) { this->actor.flags &= ~ACTOR_FLAG_10; this->actor.objBankIndex = this->objIndices[0]; @@ -1387,65 +1383,63 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { EnSob1_SetupAction(this, EnSob1_Idle); } - this->cursorPos.y = (this->cursorPos.x = 100.0f); - this->stickAccumX = (this->stickAccumY = 0); + this->cursorPos.y = this->cursorPos.x = 100.0f; + this->stickAccumY = 0; + this->stickAccumX = 0; + this->cursorIdx = 0; this->cursorPos.z = 1.2f; this->cursorColor.r = 0; this->cursorColor.g = 80; - this->cursorColor.b = maxColor; - this->cursorColor.a = maxColor; + this->cursorColor.b = 255; + this->cursorColor.a = 255; this->cursorAnimTween = 0.0f; this->cursorAnimState = 0; this->drawCursor = 0; - this2 = this; + this->stickLeftPrompt.stickColor.r = 200; + this->stickLeftPrompt.stickColor.g = 200; + this->stickLeftPrompt.stickColor.b = 200; + this->stickLeftPrompt.stickColor.a = 180; + this->stickLeftPrompt.stickTexX = 49.0f; + this->stickLeftPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.arrowColor.r = 255; + this->stickLeftPrompt.arrowColor.g = 255; + this->stickLeftPrompt.arrowColor.b = 0; + this->stickLeftPrompt.arrowColor.a = 200; + this->stickLeftPrompt.arrowTexX = 33.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.texZ = 1.0f; + this->stickLeftPrompt.isEnabled = false; - this2->stickLeftPrompt.stickColor.r = 200; - this2->stickLeftPrompt.stickColor.g = 200; - this2->stickLeftPrompt.stickColor.b = 200; - this2->stickLeftPrompt.stickColor.a = 180; - this2->stickLeftPrompt.stickTexX = 49.0f; - this2->stickLeftPrompt.stickTexY = 95.0f; - this2->stickLeftPrompt.arrowColor.r = maxColor; - this2->stickLeftPrompt.arrowColor.g = maxColor; - this2->stickLeftPrompt.arrowColor.b = 0; - this2->stickLeftPrompt.arrowColor.a = 200; - this2->stickLeftPrompt.arrowTexX = 33.0f; - this2->stickLeftPrompt.arrowTexY = 91.0f; - this2->stickLeftPrompt.texZ = 1.0f; - this2->stickLeftPrompt.isEnabled = 0; + this->stickRightPrompt.stickColor.r = 200; + this->stickRightPrompt.stickColor.g = 200; + this->stickRightPrompt.stickColor.b = 200; + this->stickRightPrompt.stickColor.a = 180; + this->stickRightPrompt.stickTexX = 274.0f; + this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowColor.r = 255; + this->stickRightPrompt.arrowColor.g = 0; + this->stickRightPrompt.arrowColor.b = 0; + this->stickRightPrompt.arrowColor.a = 200; + this->stickRightPrompt.arrowTexX = 290.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickRightPrompt.texZ = 1.0f; + this->stickRightPrompt.isEnabled = false; - if (1) {} + this->arrowAnimState = 0; + this->stickAnimState = 0; + this->arrowAnimTween = 0.0f; + this->stickAnimTween = 0.0f; + this->shopItemSelectedTween = 0.0f; - this2->stickRightPrompt.stickColor.r = 200; - this2->stickRightPrompt.stickColor.g = 200; - this2->stickRightPrompt.stickColor.b = 200; - this2->stickRightPrompt.stickColor.a = 180; - this2->stickRightPrompt.stickTexX = 274.0f; - this2->stickRightPrompt.stickTexY = 95.0f; - this2->stickRightPrompt.arrowColor.r = maxColor; - this2->stickRightPrompt.arrowColor.g = 0; - this2->stickRightPrompt.arrowColor.b = 0; - this2->stickRightPrompt.arrowColor.a = 200; - this2->stickRightPrompt.arrowTexX = 290.0f; - this2->stickRightPrompt.arrowTexY = 91.0f; - this2->stickRightPrompt.texZ = 1.0f; - this2->stickRightPrompt.isEnabled = 0; - - this2->arrowAnimState = 0; - this2->stickAnimState = 0; - this2->arrowAnimTween = 0.0f; - this2->stickAnimTween = 0.0f; - this2->shopItemSelectedTween = 0.0f; - - this2->actor.gravity = 0.0f; - this2->posXZRange = sPosXZRanges[this2->shopType]; - Actor_SetScale(&this2->actor, sActorScales[this2->shopType]); - EnSob1_SpawnShopItems(this2, globalCtx, shopItems); + this->actor.gravity = 0.0f; + this->posXZRange = sPosXZRanges[this->shopType]; + Actor_SetScale(&this->actor, sActorScales[this->shopType]); + EnSob1_SpawnShopItems(this, globalCtx, shopItems); this->headRot = this->headRotTarget = 0; - this2->blinkTimer = 20; - this2->eyeTexIndex = 0; + this->blinkTimer = 20; + this->eyeTexIndex = 0; this->blinkFunc = EnSob1_WaitForBlink; this->actor.flags &= ~ACTOR_FLAG_1; } @@ -1475,7 +1469,10 @@ void EnSob1_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnSob1_DrawCursor(GlobalContext* globalCtx, EnSob1* this, f32 x, f32 y, f32 z, u8 drawCursor) { - s32 ulx, uly, lrx, lry; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; f32 w; s32 dsdx; s32 pad; @@ -1485,8 +1482,8 @@ void EnSob1_DrawCursor(GlobalContext* globalCtx, EnSob1* this, f32 x, f32 y, f32 func_8012C654(globalCtx->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, gameplay_keep_Tex_01F740, G_IM_FMT_IA, 16, 16, 0, - G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, + G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); w = 16.0f * z; ulx = (x - w) * 4.0f; uly = (y - w + -12.0f) * 4.0f; @@ -1501,11 +1498,16 @@ void EnSob1_DrawCursor(GlobalContext* globalCtx, EnSob1* this, f32 x, f32 y, f32 void EnSob1_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y, f32 z, s32 s, s32 t, f32 dx, f32 dy) { f32 unk; - s32 ulx, uly, lrx, lry; - f32 w, h; - s32 dsdx, dtdy; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; + f32 w; + f32 h; + s32 dsdx; + s32 dtdy; - ((void)"../z_en_soB1.c"); // Unreferenced + (void)"../z_en_soB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); @@ -1531,21 +1533,15 @@ void EnSob1_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnSob1* this) { s32 drawStickRightPrompt = this->stickLeftPrompt.isEnabled; s32 drawStickLeftPrompt = this->stickRightPrompt.isEnabled; - ((void)"../z_en_soB1.c"); // Unreferenced + (void)"../z_en_soB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(globalCtx->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F8C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 191, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 23 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnSob1_DrawTextRec(globalCtx, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, @@ -1558,15 +1554,9 @@ void EnSob1_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnSob1* this) { this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F7C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 127, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 15 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnSob1_DrawTextRec(globalCtx, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, @@ -1583,8 +1573,8 @@ void EnSob1_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnSob1* this) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -s32 EnSob1_OverrideLimbDrawZoraShopkeeper(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnSob1_ZoraShopkeeper_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { EnSob1* this = THIS; if (limbIndex == 15) { @@ -1593,8 +1583,8 @@ s32 EnSob1_OverrideLimbDrawZoraShopkeeper(GlobalContext* globalCtx, s32 limbInde return false; } -s32 EnSob1_OverrideLimbDrawBombShopkeeper(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnSob1_BombShopkeeper_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { EnSob1* this = THIS; if (limbIndex == 15) { @@ -1603,7 +1593,8 @@ s32 EnSob1_OverrideLimbDrawBombShopkeeper(GlobalContext* globalCtx, s32 limbInde return false; } -void EnSob1_PostLimbDrawBombShopkeeper(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnSob1_BombShopkeeper_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, + Actor* thisx) { OPEN_DISPS(globalCtx->state.gfxCtx); if (limbIndex == 11) { gSPDisplayList(POLY_OPA_DISP++, object_rs_DL_000970); @@ -1621,7 +1612,7 @@ Gfx* EnSob1_EndDList(GraphicsContext* gfxCtx) { return dList; } -void EnSob1_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx) { +void EnSob1_ZoraShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { static TexturePtr sZoraShopkeeperEyeTextures[] = { gZoraEyeOpenTex, gZoraEyeHalfTex, gZoraEyeClosedTex }; EnSob1* this = THIS; s32 pad; @@ -1633,7 +1624,7 @@ void EnSob1_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x0C, EnSob1_EndDList(globalCtx->state.gfxCtx)); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sZoraShopkeeperEyeTextures[this->eyeTexIndex])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnSob1_OverrideLimbDrawZoraShopkeeper, NULL, &this->actor); + EnSob1_ZoraShopkeeper_OverrideLimbDraw, NULL, &this->actor); for (i = 0; i < ARRAY_COUNT(this->items); i++) { this->items[i]->actor.scale.x = 0.2f; this->items[i]->actor.scale.y = 0.2f; @@ -1644,7 +1635,7 @@ void EnSob1_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -void EnSob1_DrawGoronShopkeeper(Actor* thisx, GlobalContext* globalCtx) { +void EnSob1_GoronShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { static TexturePtr sGoronShopkeeperEyeTextures[] = { object_oF1d_map_Tex_010438, object_oF1d_map_Tex_010C38, object_oF1d_map_Tex_011038 }; EnSob1* this = THIS; @@ -1666,7 +1657,7 @@ void EnSob1_DrawGoronShopkeeper(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -void EnSob1_DrawBombShopkeeper(Actor* thisx, GlobalContext* globalCtx) { +void EnSob1_BombShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { EnSob1* this = THIS; s32 pad; u32 frames; @@ -1676,7 +1667,7 @@ void EnSob1_DrawBombShopkeeper(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_rs_Tex_005458)); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnSob1_OverrideLimbDrawBombShopkeeper, EnSob1_PostLimbDrawBombShopkeeper, &this->actor); + EnSob1_BombShopkeeper_OverrideLimbDraw, EnSob1_BombShopkeeper_PostLimbDraw, &this->actor); for (i = 0; i < ARRAY_COUNT(this->items); i++) { this->items[i]->actor.scale.x = 0.2f; this->items[i]->actor.scale.y = 0.2f; diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 733ecb8a6..1ef192571 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -210,7 +210,7 @@ s32 func_80BAA904(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAA9B4(EnSuttari* this) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); switch (this->textId) { case 0x1454: @@ -221,15 +221,15 @@ void func_80BAA9B4(EnSuttari* this) { case 0x1459: case 0x145A: case 0x145B: - if ((this->animationIdx != 8) && (curFrame == frameCount)) { - this->animationIdx = 8; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if ((this->animationIndex != 8) && (curFrame == frameCount)) { + this->animationIndex = 8; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } break; default: - if ((this->animationIdx != 1) && (curFrame == frameCount)) { - this->animationIdx = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if ((this->animationIndex != 1) && (curFrame == frameCount)) { + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } } } @@ -237,8 +237,8 @@ void func_80BAA9B4(EnSuttari* this) { void func_80BAAA94(EnSuttari* this) { switch (this->textId) { case 0x29E5: - this->animationIdx = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); break; case 0x29E9: this->enFsn->flags |= ENFSN_ANGRY; @@ -250,12 +250,12 @@ void func_80BAAA94(EnSuttari* this) { this->enFsn->flags |= ENFSN_OFFER_FINAL_PRICE; break; case 0x29EC: - this->animationIdx = 7; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 7; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); break; case 0x29ED: - this->animationIdx = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); break; } } @@ -377,14 +377,14 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAAF1C(EnSuttari* this) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); - if (this->animationIdx == 5) { - this->animationIdx = 3; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); - } else if ((this->animationIdx == 3) && (curFrame == frameCount)) { - this->animationIdx = 6; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if (this->animationIndex == 5) { + this->animationIndex = 3; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + } else if ((this->animationIndex == 3) && (curFrame == frameCount)) { + this->animationIndex = 6; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->flags1 &= ~0x100; } } @@ -806,7 +806,7 @@ s32 func_80BAC220(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); switch (this->unk428) { case 12: @@ -815,9 +815,9 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { func_80BABFD4(this, globalCtx); break; case 15: - if ((this->animationIdx == 1) && (curFrame == frameCount)) { - this->animationIdx = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if ((this->animationIndex == 1) && (curFrame == frameCount)) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } if (!(gSaveContext.weekEventReg[83] & 4) && !(this->flags1 & 0x1000)) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[0])) { @@ -848,9 +848,9 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { this->flags1 |= 0x80; this->flags1 |= 0x20; this->enFsn->flags &= ~ENFSN_HAGGLE; - if (this->animationIdx != 2) { - this->animationIdx = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if (this->animationIndex != 2) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } func_80BAC220(this, globalCtx); break; @@ -879,9 +879,9 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { break; case 4: if (!(gSaveContext.weekEventReg[33] & 8)) { - if (this->animationIdx == 2 || this->animationIdx == 1) { - this->animationIdx = 5; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if (this->animationIndex == 2 || this->animationIndex == 1) { + this->animationIndex = 5; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } this->flags1 |= 0x10; if (this->flags2 & 2) { @@ -909,16 +909,16 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { if (globalCtx->sceneNum == SCENE_IKANA) { this->flags1 |= 1; if (gSaveContext.day == 1 || gSaveContext.day == 2) { - this->animationIdx = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->flags1 |= 0x80; this->actionFunc = func_80BACA14; return; } else if ((gSaveContext.day == 3) && (gSaveContext.time <= CLOCK_TIME(19, 00)) && !(gSaveContext.weekEventReg[61] & 8) && !(gSaveContext.weekEventReg[33] & 8) && (gSaveContext.weekEventReg[51] & 8)) { - this->animationIdx = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = func_80BACEE0; return; } @@ -933,8 +933,8 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { this->cutscenes[1] = ActorCutscene_GetAdditionalCutscene(this->cutscenes[0]); this->flags1 |= 0x80; this->flags1 |= 8; - this->animationIdx = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = func_80BAD004; return; } else if (globalCtx->sceneNum == SCENE_ICHIBA) { @@ -942,8 +942,8 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); return; } - this->animationIdx = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->flags1 |= 2; this->actionFunc = func_80BAD5F8; return; @@ -952,8 +952,8 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); return; } - this->animationIdx = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->cutscenes[0] = this->actor.cutscene; this->cutscenes[1] = ActorCutscene_GetAdditionalCutscene(this->cutscenes[0]); this->flags1 |= 4; @@ -971,9 +971,9 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->animationIdx == 1 || this->animationIdx == 8) { - this->animationIdx = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if (this->animationIndex == 1 || this->animationIndex == 8) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } func_80BABA90(this, 0, 0); func_80BAB434(this); @@ -1211,11 +1211,11 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { u32* unk_14 = &gSaveContext.unk_14; struct_80133038_arg2 unkStruct; s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); - if ((curFrame == frameCount) && (this->animationIdx == 0) && (this->flags1 & 0x20)) { - this->animationIdx = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if ((curFrame == frameCount) && (this->animationIndex == 0) && (this->flags1 & 0x20)) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } this->unk42A = REG(15) + *unk_14; if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || @@ -1247,14 +1247,14 @@ void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { u32* unk_14 = &gSaveContext.unk_14; struct_80133038_arg2 unkStruct; s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (this->enFsn == NULL) { this->enFsn = (EnFsn*)EnSuttari_GetActorById(globalCtx, ACTOR_EN_FSN); } else { - if ((this->flags1 & 0x2000) && (this->animationIdx == 1) && (curFrame == frameCount)) { - this->animationIdx = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + if ((this->flags1 & 0x2000) && (this->animationIndex == 1) && (curFrame == frameCount)) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } this->unk42A = REG(15) + *unk_14; if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || @@ -1296,14 +1296,14 @@ void func_80BADA08(EnSuttari* this, GlobalContext* globalCtx) { void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { u8 talkstate = Message_GetState(&globalCtx->msgCtx); s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (this->flags1 & 1) { this->unk3F2 = this->unk2DC.y; func_80BAA9B4(this); - } else if ((this->animationIdx == 7) && (curFrame == frameCount)) { - this->animationIdx = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIdx); + } else if ((this->animationIndex == 7) && (curFrame == frameCount)) { + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } if (talkstate == 5) { if (func_80147624(globalCtx)) { @@ -1449,11 +1449,11 @@ void EnSuttari_Update(Actor* thisx, GlobalContext* globalCtx) { EnSuttari_UpdateTime(); } if (this->unk428 != 0) { - if (this->animationIdx == 2 || this->animationIdx == 6) { + if (this->animationIndex == 2 || this->animationIndex == 6) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 16.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } - } else if (this->animationIdx == 0 || this->animationIdx == 5) { + } else if (this->animationIndex == 0 || this->animationIndex == 5) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h index 9c62be60f..c6f8cc153 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h @@ -55,7 +55,7 @@ typedef struct EnSuttari { /* 0x436 */ s16 unk436; /* 0x438 */ Vec3f unk438; /* 0x444 */ Vec3f unk444; - /* 0x450 */ s32 animationIdx; + /* 0x450 */ s32 animationIndex; /* 0x454 */ UNK_TYPE1 unk_454[0x2]; /* 0x456 */ s16 cutscenes[2]; /* 0x45A */ s16 cutsceneIdx; diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.c b/src/overlays/actors/ovl_En_Trt/z_en_trt.c index 075d42337..b0b793211 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -22,11 +22,11 @@ void EnTrt_Update(Actor* thisx, GlobalContext* globalCtx); void EnTrt_Draw(Actor* thisx, GlobalContext* globalCtx); void EnTrt_GetCutscenes(EnTrt* this, GlobalContext* globalCtx); -s32 EnTrt_ReturnItemToShelf(EnTrt* this); void EnTrt_ResetItemPosition(EnTrt* this); +void EnTrt_UpdateHeadYawAndPitch(EnTrt* this, GlobalContext* globalCtx); +s32 EnTrt_ReturnItemToShelf(EnTrt* this); s32 EnTrt_FacingShopkeeperDialogResult(EnTrt* this, GlobalContext* globalCtx); s32 EnTrt_TakeItemOffShelf(EnTrt* this); -void EnTrt_UpdateHeadYawAndPitch(EnTrt* this, GlobalContext* globalCtx); void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx); void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx); @@ -786,7 +786,7 @@ void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx) { if (DECR(this->timer) == 0) { this->timer = 40; EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 1); - this->animationIdx = 1; + this->animationIndex = 1; this->actionFunc = EnTrt_IdleAwake; this->blinkFunc = EnTrt_OpenThenCloseEyes; } @@ -832,7 +832,7 @@ void EnTrt_IdleAwake(EnTrt* this, GlobalContext* globalCtx) { if (DECR(this->timer) == 0) { this->timer = Rand_S16Offset(150, 100); EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 2); - this->animationIdx = 2; + this->animationIndex = 2; this->sleepSoundTimer = 10; this->actor.textId = 0; this->actionFunc = EnTrt_IdleSleeping; @@ -852,10 +852,10 @@ void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } else if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { - if (this->animationIdx != 5) { + if (this->animationIndex != 5) { if (curFrame == animLastFrame) { EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 3); - this->animationIdx = 3; + this->animationIndex = 3; this->blinkFunc = EnTrt_OpenEyesThenSetToBlink; this->timer = 10; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; @@ -870,7 +870,7 @@ void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { this->timer = Rand_S16Offset(40, 20); EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 5); Message_StartTextbox(globalCtx, this->textId, &this->actor); - this->animationIdx = 5; + this->animationIndex = 5; switch (this->textId) { case 0x834: if (!(gSaveContext.weekEventReg[12] & 8) && !(gSaveContext.weekEventReg[84] & 0x40) && @@ -911,7 +911,7 @@ void EnTrt_Surprised(EnTrt* this, GlobalContext* globalCtx) { } else if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { if (DECR(this->timer) == 0) { EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 4); - this->animationIdx = 4; + this->animationIndex = 4; this->blinkFunc = EnTrt_OpenEyes2; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOTAKE_SURPRISED); this->timer = 30; @@ -921,7 +921,7 @@ void EnTrt_Surprised(EnTrt* this, GlobalContext* globalCtx) { this->timer = Rand_S16Offset(40, 20); EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 5); Message_StartTextbox(globalCtx, this->textId, &this->actor); - this->animationIdx = 5; + this->animationIndex = 5; this->actionFunc = EnTrt_TryToGiveRedPotionAfterSurprised; } } @@ -1221,10 +1221,7 @@ void EnTrt_UpdateCursorAnim(EnTrt* this) { void EnTrt_UpdateStickDirectionPromptAnim(EnTrt* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - - // Possbily fake temps - s32 maxColor = 255; - f32 tmp; + s32 maxColor = 255; // POSSIBLY FAKE if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -1251,31 +1248,33 @@ void EnTrt_UpdateStickDirectionPromptAnim(EnTrt* this) { stickAnimTween = 0.0f; this->stickAnimState = 0; } - - tmp = 155.0f * arrowAnimTween; - this->stickAnimTween = stickAnimTween; this->stickLeftPrompt.arrowColor.r = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.g = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); - this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100, arrowAnimTween); + this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowColor.r = (maxColor - ((s32)tmp)) & 0xFF; - this->stickRightPrompt.arrowColor.g = (255 - ((s32)tmp)) & 0xFF; + this->stickRightPrompt.arrowTexX = 290.0f; + + this->stickRightPrompt.arrowColor.r = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); + this->stickRightPrompt.arrowColor.g = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowTexX = 290.0f; this->stickLeftPrompt.arrowTexX = 33.0f; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexX += 8.0f * stickAnimTween; + this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexX -= 8.0f * stickAnimTween; - this->stickLeftPrompt.arrowTexY = this->stickRightPrompt.arrowTexY = 91.0f; - this->stickLeftPrompt.stickTexY = this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + + this->stickRightPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.stickTexY = 95.0f; } void EnTrt_OpenEyes(EnTrt* this) { @@ -1451,9 +1450,6 @@ void EnTrt_InitShopkeeper(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { - u32 maxcolor = 255; - EnTrt* this2; - EnTrt_GetCutscenes(this, globalCtx); this->cutscene = this->lookForwardCutscene; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); @@ -1470,58 +1466,55 @@ void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { this->actionFunc = EnTrt_IdleSleeping; } + this->cursorPos.y = this->cursorPos.x = 100.0f; this->stickAccumY = 0; this->stickAccumX = 0; + this->cursorIdx = 0; - this->cursorPos.y = this->cursorPos.x = 100.0f; this->cursorPos.z = 1.2f; this->cursorColor.r = 0; this->cursorColor.g = 80; - this->cursorColor.b = maxcolor; - this->cursorColor.a = maxcolor; + this->cursorColor.b = 255; + this->cursorColor.a = 255; this->cursorAnimTween = 0.0f; this->cursorAnimState = 0; this->drawCursor = 0; - this2 = this; - this->stickLeftPrompt.stickColor.r = 200; - this2->stickLeftPrompt.stickColor.g = 200; - this2->stickLeftPrompt.stickColor.b = 200; - this2->stickLeftPrompt.stickColor.a = 180; - this2->stickLeftPrompt.stickTexX = 49.0f; - this2->stickLeftPrompt.stickTexY = 95.0f; - this2->stickLeftPrompt.arrowColor.r = maxcolor; - this2->stickLeftPrompt.arrowColor.g = maxcolor; - this2->stickLeftPrompt.arrowColor.b = 0; - this2->stickLeftPrompt.arrowColor.a = 200; - this2->stickLeftPrompt.arrowTexX = 33.0f; - this2->stickLeftPrompt.arrowTexY = 91.0f; - this2->stickLeftPrompt.texZ = 1.0f; - this2->stickLeftPrompt.isEnabled = false; + this->stickLeftPrompt.stickColor.g = 200; + this->stickLeftPrompt.stickColor.b = 200; + this->stickLeftPrompt.stickColor.a = 180; + this->stickLeftPrompt.stickTexX = 49.0f; + this->stickLeftPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.arrowColor.r = 255; + this->stickLeftPrompt.arrowColor.g = 255; + this->stickLeftPrompt.arrowColor.b = 0; + this->stickLeftPrompt.arrowColor.a = 200; + this->stickLeftPrompt.arrowTexX = 33.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.texZ = 1.0f; + this->stickLeftPrompt.isEnabled = false; - if (1) {} + this->stickRightPrompt.stickColor.r = 200; + this->stickRightPrompt.stickColor.g = 200; + this->stickRightPrompt.stickColor.b = 200; + this->stickRightPrompt.stickColor.a = 180; + this->stickRightPrompt.stickTexX = 274.0f; + this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowColor.r = 255; + this->stickRightPrompt.arrowColor.g = 0; + this->stickRightPrompt.arrowColor.b = 0; + this->stickRightPrompt.arrowColor.a = 200; + this->stickRightPrompt.arrowTexX = 290.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickRightPrompt.texZ = 1.0f; + this->stickRightPrompt.isEnabled = false; - this2->stickRightPrompt.stickColor.r = 200; - this2->stickRightPrompt.stickColor.g = 200; - this2->stickRightPrompt.stickColor.b = 200; - this2->stickRightPrompt.stickColor.a = 180; - this2->stickRightPrompt.stickTexX = 274.0f; - this2->stickRightPrompt.stickTexY = 95.0f; - this2->stickRightPrompt.arrowColor.r = maxcolor; - this2->stickRightPrompt.arrowColor.g = 0; - this2->stickRightPrompt.arrowColor.b = 0; - this2->stickRightPrompt.arrowColor.a = 200; - this2->stickRightPrompt.arrowTexX = 290.0f; - this2->stickRightPrompt.arrowTexY = 91.0f; - this2->stickRightPrompt.texZ = 1.0f; - this2->stickRightPrompt.isEnabled = false; - - this2->arrowAnimTween = 0.0f; - this2->stickAnimTween = 0.0f; - this2->arrowAnimState = 0; - this2->stickAnimState = 0; - this2->shopItemSelectedTween = 0.0f; + this->arrowAnimTween = 0.0f; + this->stickAnimTween = 0.0f; + this->arrowAnimState = 0; + this->stickAnimState = 0; + this->shopItemSelectedTween = 0.0f; this->actor.gravity = 0.0f; Actor_SetScale(&this->actor, sActorScale); @@ -1544,7 +1537,10 @@ void EnTrt_GetCutscenes(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_DrawCursor(GlobalContext* globalCtx, EnTrt* this, f32 x, f32 y, f32 z, u8 drawCursor) { - s32 ulx, uly, lrx, lry; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; f32 w; s32 dsdx; s32 pad; @@ -1554,8 +1550,8 @@ void EnTrt_DrawCursor(GlobalContext* globalCtx, EnTrt* this, f32 x, f32 y, f32 z func_8012C654(globalCtx->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, gameplay_keep_Tex_01F740, G_IM_FMT_IA, 16, 16, 0, - G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, + G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); w = 16.0f * z; ulx = (x - w) * 4.0f; uly = (y - w + -12.0f) * 4.0f; @@ -1570,11 +1566,16 @@ void EnTrt_DrawCursor(GlobalContext* globalCtx, EnTrt* this, f32 x, f32 y, f32 z void EnTrt_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y, f32 z, s32 s, s32 t, f32 dx, f32 dy) { f32 unk; - s32 ulx, uly, lrx, lry; - f32 w, h; - s32 dsdx, dtdy; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; + f32 w; + f32 h; + s32 dsdx; + s32 dtdy; - ((void)"../z_en_trt.c"); // Unreferenced + (void)"../z_en_trt.c"; OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); @@ -1600,21 +1601,15 @@ void EnTrt_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnTrt* this) { s32 drawStickRightPrompt = this->stickLeftPrompt.isEnabled; s32 drawStickLeftPrompt = this->stickRightPrompt.isEnabled; - ((void)"../z_en_trt.c"); // Unreferenced + (void)"../z_en_trt.c"; OPEN_DISPS(globalCtx->state.gfxCtx); if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(globalCtx->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F8C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 191, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 23 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnTrt_DrawTextRec(globalCtx, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, @@ -1627,15 +1622,9 @@ void EnTrt_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnTrt* this) { this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F7C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 127, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 15 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnTrt_DrawTextRec(globalCtx, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.h b/src/overlays/actors/ovl_En_Trt/z_en_trt.h index 2df343dfc..eb243317b 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.h +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.h @@ -41,7 +41,7 @@ typedef struct EnTrt { /* 0x3F0 */ Color_RGBAu32 cursorColor; /* 0x400 */ u8 drawCursor; /* 0x402 */ s16 timer; - /* 0x404 */ s16 animationIdx; + /* 0x404 */ s16 animationIndex; /* 0x406 */ u16 textId; /* 0x408 */ u16 tmpTextId; /* 0x40A */ u16 talkOptionTextId; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index b78680dd4..e81c1e758 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -5802,10 +5802,10 @@ 0x808AAB30:("EnOssan_UpdateStickDirectionPromptAnim",), 0x808AACE0:("EnOssan_WaitForBlink",), 0x808AAD14:("EnOssan_Blink",), - 0x808AADB4:("EnOssan_InitCuriosityShopMan",), - 0x808AAE1C:("EnOssan_InitPartTimeWorker",), - 0x808AAE84:("EnOssan_GetWelcomeCuriosityShopMan",), - 0x808AAFB0:("EnOssan_GetWelcomePartTimeWorker",), + 0x808AADB4:("EnOssan_CuriosityShopMan_Init",), + 0x808AAE1C:("EnOssan_PartTimeWorker_Init",), + 0x808AAE84:("EnOssan_CuriosityShopMan_GetWelcome",), + 0x808AAFB0:("EnOssan_PartTimerWorker_GetWelcome",), 0x808AB0B0:("EnOssan_SetHaveMet",), 0x808AB16C:("EnOssan_InitShop",), 0x808AB404:("EnOssan_GetCutscenes",), @@ -5813,12 +5813,12 @@ 0x808AB52C:("EnOssan_DrawCursor",), 0x808AB78C:("EnOssan_DrawTextRec",), 0x808AB928:("EnOssan_DrawStickDirectionPrompts",), - 0x808ABCD0:("EnOssan_OverrideLimbDrawCuriosityShopMan",), - 0x808ABD10:("EnOssan_OverrideLimbDrawPartTimeWorker",), - 0x808ABD60:("EnOssan_PostLimbDrawCuriosityShopMan",), - 0x808ABE18:("EnOssan_PostLimbDrawPartTimeWorker",), - 0x808ABE58:("EnOssan_DrawCuriosityShopMan",), - 0x808ABF30:("EnOssan_DrawPartTimeWorker",), + 0x808ABCD0:("EnOssan_CuriosityShopMan_OverrideLimbDraw",), + 0x808ABD10:("EnOssan_PartTimeWorker_OverrideLimbDraw",), + 0x808ABD60:("EnOssan_CuriosityShopMan_PostLimbDraw",), + 0x808ABE18:("EnOssan_PartTimeWorker_PostLimbDraw",), + 0x808ABE58:("EnOssan_CuriosityShopMan_Draw",), + 0x808ABF30:("EnOssan_PartTimeWorker_Draw",), 0x808AC920:("EnFamos_Init",), 0x808ACB08:("EnFamos_Destroy",), 0x808ACB58:("func_808ACB58",), @@ -9605,7 +9605,7 @@ 0x80A0C938:("EnSob1_GetTalkOption",), 0x80A0CA38:("EnSob1_GetWelcome",), 0x80A0CC88:("EnSob1_GetGoodbye",), - 0x80A0CCEC:("EnSob1_EndInteractionBombShop",), + 0x80A0CCEC:("EnSob1_BombShopkeeper_EndInteraction",), 0x80A0CD48:("EnSob1_SpawnShopItems",), 0x80A0CE10:("EnSob1_GetObjIndices",), 0x80A0CED4:("EnSob1_Init",), @@ -9660,21 +9660,21 @@ 0x80A0F2FC:("EnSob1_Blink",), 0x80A0F39C:("EnSob1_ChangeObject",), 0x80A0F3D4:("EnSob1_AreObjectsLoaded",), - 0x80A0F470:("EnSob1_InitZoraShopkeeper",), - 0x80A0F554:("EnSob1_InitGoronShopkeeper",), - 0x80A0F638:("EnSob1_InitBombShopkeeper",), + 0x80A0F470:("EnSob1_ZoraShopkeeper_Init",), + 0x80A0F554:("EnSob1_GoronShopkeeper_Init",), + 0x80A0F638:("EnSob1_BombShopkeeper_Init",), 0x80A0F6B0:("EnSob1_InitShop",), 0x80A0FA0C:("EnSob1_Update",), 0x80A0FADC:("EnSob1_DrawCursor",), 0x80A0FD4C:("EnSob1_DrawTextRec",), 0x80A0FEE8:("EnSob1_DrawStickDirectionPrompt",), - 0x80A10290:("EnSob1_OverrideLimbDrawZoraShopkeeper",), - 0x80A102C8:("EnSob1_OverrideLimbDrawBombShopkeeper",), - 0x80A10308:("EnSob1_PostLimbDrawBombShopkeeper",), + 0x80A10290:("EnSob1_ZoraShopkeeper_OverrideLimbDraw",), + 0x80A102C8:("EnSob1_BombShopkeeper_OverrideLimbDraw",), + 0x80A10308:("EnSob1_BombShopkeeper_PostLimbDraw",), 0x80A10344:("EnSob1_EndDList",), - 0x80A10368:("EnSob1_DrawZoraShopkeeper",), - 0x80A104E4:("EnSob1_DrawGoronShopkeeper",), - 0x80A10608:("EnSob1_DrawBombShopkeeper",), + 0x80A10368:("EnSob1_ZoraShopkeeper_Draw",), + 0x80A104E4:("EnSob1_GoronShopkeeper_Draw",), + 0x80A10608:("EnSob1_BombShopkeeper_Draw",), 0x80A10FD0:("func_80A10FD0",), 0x80A11144:("func_80A11144",), 0x80A1143C:("func_80A1143C",), From 9a54ec9e0b20d04cff29e44be286dd61c51ec85c Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Fri, 25 Mar 2022 02:21:14 +0000 Subject: [PATCH 102/257] En_Bombers (#684) * En_Bombers * No need for this >: * Override * PR --- assets/xml/overlays/ovl_En_Bombers.xml | 6 + spec | 3 +- .../ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h | 2 +- .../actors/ovl_En_Bombers/z_en_bombers.c | 500 +++++++++++++++++- .../actors/ovl_En_Bombers/z_en_bombers.h | 40 +- .../actors/ovl_En_Bomjima/z_en_bomjima.c | 15 +- tools/disasm/functions.txt | 2 +- undefined_syms.txt | 5 - 8 files changed, 533 insertions(+), 40 deletions(-) create mode 100644 assets/xml/overlays/ovl_En_Bombers.xml diff --git a/assets/xml/overlays/ovl_En_Bombers.xml b/assets/xml/overlays/ovl_En_Bombers.xml new file mode 100644 index 000000000..c6fc64246 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Bombers.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/spec b/spec index 2bdf82937..73e16127e 100644 --- a/spec +++ b/spec @@ -5014,8 +5014,7 @@ beginseg name "ovl_En_Bombers" compress include "build/src/overlays/actors/ovl_En_Bombers/z_en_bombers.o" - include "build/data/ovl_En_Bombers/ovl_En_Bombers.data.o" - include "build/data/ovl_En_Bombers/ovl_En_Bombers.reloc.o" + include "build/src/overlays/actors/ovl_En_Bombers/ovl_En_Bombers_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h index 21e25b19d..6246a6756 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h @@ -43,7 +43,7 @@ typedef struct EnBomBowlMan { /* 0x02C2 */ s16 unk_2C2; /* 0x02C4 */ f32 unk_2C4; /* 0x02C8 */ f32 unk_2C8; - /* 0x02CC */ UNK_TYPE1 unk2CC[4]; + /* 0x02CC */ s16 unk_2CC[2]; /* 0x02D0 */ s16 unk_2D0; /* 0x02D2 */ s16 unk_2D2; /* 0x02D4 */ s16 unk_2D4; 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 c20759cb6..4024c39b0 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c @@ -5,6 +5,8 @@ */ #include "z_en_bombers.h" +#include "overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h" +#include "objects/object_cs/object_cs.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -15,12 +17,14 @@ void EnBombers_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBombers_Update(Actor* thisx, GlobalContext* globalCtx); void EnBombers_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80C03ACC(EnBombers* this); void func_80C03AF4(EnBombers* this, GlobalContext* globalCtx); +void func_80C03F64(EnBombers* this); void func_80C03FAC(EnBombers* this, GlobalContext* globalCtx); +void func_80C042F8(EnBombers* this); void func_80C04354(EnBombers* this, GlobalContext* globalCtx); void func_80C043C8(EnBombers* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Bombers_InitVars = { ACTOR_EN_BOMBERS, ACTORCAT_NPC, @@ -33,45 +37,495 @@ const ActorInit En_Bombers_InitVars = { (ActorFunc)EnBombers_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C04770 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 30, 0, { 0, 0, 0 } }, }; -#endif +AnimationHeader* D_80C0479C[] = { + &object_cs_Anim_0064B8, &object_cs_Anim_0053F4, &object_cs_Anim_01007C, &object_cs_Anim_00349C, + &object_cs_Anim_004960, &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_001A1C, + &object_cs_Anim_003EE4, &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, + &object_cs_Anim_001708, &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, &object_cs_Anim_0036B0, + &object_cs_Anim_0031C4, +}; -extern ColliderCylinderInit D_80C04770; +u8 D_80C047E0[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, + ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, +}; -extern UNK_TYPE D_060064B8; +#include "overlays/ovl_En_Bombers/ovl_En_Bombers.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/EnBombers_Init.s") +Gfx* D_80C04818[] = { + ovl_En_Bombers_DL_12C8, ovl_En_Bombers_DL_12D8, ovl_En_Bombers_DL_12D8, + ovl_En_Bombers_DL_12D8, ovl_En_Bombers_DL_12D8, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/EnBombers_Destroy.s") +TexturePtr D_80C0482C[] = { + object_cs_Tex_00C520, + object_cs_Tex_00CD20, + object_cs_Tex_00D520, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03824.s") +TexturePtr D_80C04838[] = { + object_cs_Tex_00E620, object_cs_Tex_00EA20, object_cs_Tex_00EE20, object_cs_Tex_00DD20, object_cs_Tex_00F220, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C038B4.s") +void EnBombers_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBombers* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C039A8.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + this->actor.gravity = -1.0f; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &object_cs_Anim_0064B8, this->jointTable, + this->morphtable, 21); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.targetMode = 0; + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03ACC.s") + this->unk_2BC = ENBOMBERS_GET_F0(&this->actor); + this->unk_2BE = ENBOMBERS_GET_F(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03AF4.s") + if (this->unk_2BC == ENBOMBERS_F0_0) { + if ((gSaveContext.weekEventReg[73] & 0x10) || (gSaveContext.weekEventReg[85] & 2)) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_2BE++; + func_80C03ACC(this); + } + } else if (((gSaveContext.weekEventReg[73] & 0x10) || (gSaveContext.weekEventReg[85] & 2)) && + (((this->unk_2BE == ENBOMBERS_F_0) && (gSaveContext.weekEventReg[76] & 1)) || + ((this->unk_2BE == ENBOMBERS_F_1) && (gSaveContext.weekEventReg[76] & 2)) || + ((this->unk_2BE == ENBOMBERS_F_2) && (gSaveContext.weekEventReg[76] & 4)) || + ((this->unk_2BE == ENBOMBERS_F_3) && (gSaveContext.weekEventReg[76] & 8)) || + ((this->unk_2BE == ENBOMBERS_F_4) && (gSaveContext.weekEventReg[76] & 0x10)))) { + if (gSaveContext.weekEventReg[75] & 0x40) { + if (this->unk_2BE == ENBOMBERS_F_0) { + EnBomBowlMan* bomBowlMan = (EnBomBowlMan*)Actor_Spawn( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM_BOWL_MAN, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03F64.s") + if (bomBowlMan != NULL) { + s32 cs = this->actor.cutscene; + s32 i = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03FAC.s") + // clang-format off + while (cs != -1) { bomBowlMan->unk_2CC[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); i++; } + // clang-format on -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C042F8.s") + gSaveContext.weekEventReg[76] &= (u8)~1; + gSaveContext.weekEventReg[76] &= (u8)~2; + gSaveContext.weekEventReg[76] &= (u8)~4; + gSaveContext.weekEventReg[76] &= (u8)~8; + gSaveContext.weekEventReg[76] &= (u8)~0x10; + } + } + Actor_MarkForDeath(&this->actor); + } else { + func_80C042F8(this); + } + } else { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C04354.s") +void EnBombers_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBombers* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C043C8.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/EnBombers_Update.s") +void func_80C03824(EnBombers* this, s32 arg1, f32 arg2) { + this->unk_2C4 = arg1; + this->unk_2B0 = Animation_GetLastFrame(D_80C0479C[arg1]); + Animation_Change(&this->skelAnime, D_80C0479C[this->unk_2C4], arg2, 0.0f, this->unk_2B0, D_80C047E0[this->unk_2C4], + -10.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C045B4.s") +void func_80C038B4(EnBombers* this) { + if ((this->unk_2C4 == 2) && + (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 10.0f) || + Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 18.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/EnBombers_Draw.s") + if ((this->unk_2C4 == 15) && + (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 2.0f) || + Animation_OnFrame(&this->skelAnime, 4.0f) || Animation_OnFrame(&this->skelAnime, 6.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } +} + +void func_80C039A8(EnBombers* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + this->unk_2A6 = 5; + + switch (player->transformation) { + case PLAYER_FORM_HUMAN: + this->actor.textId = 0x73D; + if (gSaveContext.weekEventReg[84] & 0x80) { + this->actor.textId = 0x74B; + } + break; + + case PLAYER_FORM_GORON: + this->actor.textId = 0x73E; + break; + + case PLAYER_FORM_ZORA: + this->actor.textId = 0x73F; + break; + + case PLAYER_FORM_DEKU: + if (gSaveContext.weekEventReg[73] & 0x20) { + this->actor.textId = 0x75A; + } else if (gSaveContext.weekEventReg[73] & 0x40) { + this->actor.textId = 0x749; + if (((this->unk_2BE == ENBOMBERS_F_1) && (gSaveContext.weekEventReg[74] & 1)) || + ((this->unk_2BE == ENBOMBERS_F_2) && (gSaveContext.weekEventReg[74] & 2)) || + ((this->unk_2BE == ENBOMBERS_F_3) && (gSaveContext.weekEventReg[74] & 4)) || + ((this->unk_2BE == ENBOMBERS_F_4) && (gSaveContext.weekEventReg[74] & 8))) { + this->actor.textId = 0x74A; + } + } else { + this->actor.textId = 0x744; + } + break; + } +} + +void func_80C03ACC(EnBombers* this) { + this->collider.dim.radius = 10; + this->collider.dim.height = 30; + this->unk_2C0 = 0; + this->actionFunc = func_80C03AF4; +} + +void func_80C03AF4(EnBombers* this, GlobalContext* globalCtx) { + CollisionPoly* colPoly; + f32 curFrame = this->skelAnime.curFrame; + Vec3f sp6C; + Vec3f sp60; + Vec3f sp54; + f32 x; + f32 z; + s32 sp48; + s16 abs; + + switch (this->unk_2A0) { + case 0: + if (this->unk_2A8 == 0) { + Math_Vec3f_Copy(&sp60, &this->actor.home.pos); + + sp60.x += randPlusMinusPoint5Scaled(150.0f); + sp60.z += randPlusMinusPoint5Scaled(150.0f); + + abs = ABS_ALT(BINANG_SUB(this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp60))); + if ((abs < 0x4000) && !BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp60, &sp6C, + &colPoly, true, false, false, true, &sp48)) { + func_80C03824(this, 2, 1.0f); + Math_Vec3f_Copy(&this->unk_294, &sp60); + this->unk_2AA = Rand_S16Offset(30, 50); + this->unk_2A0++; + } + } + break; + + case 1: + if (curFrame >= 0.0f) { + this->unk_2A4 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_294); + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2A4, 0xA, 0x7D0, 0x14); + } + + if ((s16)ABS_ALT(BINANG_SUB(this->actor.world.rot.y, this->unk_2A4)) < 0x100) { + Math_Vec3f_Copy(&sp54, &this->actor.world.pos); + sp54.x += Math_SinS(this->actor.world.rot.y) * 60.0f; + sp54.z += Math_CosS(this->actor.world.rot.y) * 60.0f; + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp54, &sp6C, &colPoly, true, + false, false, true, &sp48)) { + this->unk_2A8 = 0; + if (Rand_ZeroOne() < 0.5f) { + func_80C03824(this, 16, 1.0f); + } else { + func_80C03824(this, 0, 1.0f); + } + this->unk_2A0 = 0; + this->unk_2B4 = 0.0f; + break; + } + } + + x = this->unk_294.x - this->actor.world.pos.x; + z = this->unk_294.z - this->actor.world.pos.z; + + if ((this->unk_2AA == 0) || (sqrtf(SQ(x) + SQ(z)) < 4.0f)) { + this->unk_2A8 = Rand_S16Offset(20, 20); + if (!(this->unk_2A8 & 1)) { + func_80C03824(this, 16, 1.0f); + } else { + func_80C03824(this, 0, 1.0f); + } + this->unk_2A0 = 0; + this->unk_2B4 = 0.0f; + } else if (curFrame >= 0.0f) { + Math_ApproachF(&this->actor.world.pos.x, this->unk_294.x, 0.3f, this->unk_2B4); + Math_ApproachF(&this->actor.world.pos.z, this->unk_294.z, 0.3f, this->unk_2B4); + Math_ApproachF(&this->unk_2B4, 1.0f, 0.3f, 0.5f); + } + break; + } + + if (!Text_GetFaceReaction(globalCtx, 0x12)) { + func_80C039A8(this, globalCtx); + } else { + this->unk_2A6 = 5; + this->actor.textId = Text_GetFaceReaction(globalCtx, 0x12); + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2A4 = this->actor.yawTowardsPlayer; + this->collider.dim.radius = 20; + this->collider.dim.height = 60; + func_80C03F64(this); + } else { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} + +void func_80C03F64(EnBombers* this) { + this->unk_2A4 = this->actor.yawTowardsPlayer; + func_80C03824(this, 1, 1.0f); + this->unk_2C0 = 1; + this->actionFunc = func_80C03FAC; +} + +void func_80C03FAC(EnBombers* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp2A; + + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2A4, 1, 0x1388, 0); + + switch (player->transformation) { + case PLAYER_FORM_HUMAN: + this->unk_28E = -0xFA0; + break; + + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + this->unk_28E = -0x1770; + break; + } + + if ((this->unk_2A6 == Message_GetState(&globalCtx->msgCtx)) && func_80147624(globalCtx)) { + sp2A = 0; + func_801477B4(globalCtx); + this->unk_2A6 = 5; + + if ((this->actor.textId == 0x73D) || (this->actor.textId == 0x73E) || (this->actor.textId == 0x73F)) { + this->actor.textId = 0x740; + this->unk_2A6 = 4; + sp2A = 1; + } else if (this->actor.textId == 0x740) { + if (globalCtx->msgCtx.choiceIndex == 0) { + func_8019F208(); + this->actor.textId = 0x742; + sp2A = 1; + } else { + func_8019F230(); + this->actor.textId = 0x741; + sp2A = 1; + } + } else if (this->actor.textId == 0x742) { + this->actor.textId = 0x737; + sp2A = 1; + } else if (this->actor.textId == 0x737) { + this->actor.textId = 0x743; + sp2A = 1; + } else if (this->actor.textId == 0x74B) { + this->actor.textId = 0x74C; + this->unk_2A6 = 4; + sp2A = 1; + } else if (this->actor.textId == 0x74C) { + if (globalCtx->msgCtx.choiceIndex == 1) { + func_8019F230(); + this->actor.textId = 0x737; + sp2A = 1; + } else { + func_8019F208(); + this->actor.textId = 0x74D; + func_80C03824(this, 14, 1.0f); + sp2A = 1; + } + } else if (this->actor.textId == 0x744) { + s32 day = gSaveContext.day - 1; + + if (day == 2) { + this->actor.textId = 0x746; + sp2A = 1; + } else { + this->actor.textId = 0x745; + sp2A = 1; + } + } else if ((this->actor.textId == 0x745) || (this->actor.textId == 0x746)) { + this->actor.textId = 0x747; + sp2A = 1; + } else if (this->actor.textId == 0x747) { + this->actor.textId = 0x748; + sp2A = 1; + } else if (this->actor.textId == 0x748) { + switch (this->unk_2BE) { + case ENBOMBERS_F_1: + gSaveContext.weekEventReg[74] |= 1; + break; + + case ENBOMBERS_F_2: + gSaveContext.weekEventReg[74] |= 2; + break; + + case ENBOMBERS_F_3: + gSaveContext.weekEventReg[74] |= 4; + break; + + case ENBOMBERS_F_4: + gSaveContext.weekEventReg[74] |= 8; + break; + } + gSaveContext.weekEventReg[73] |= 0x40; + } + + switch (sp2A) { + case 0: + this->unk_28E = 0; + func_80C03ACC(this); + break; + + case 1: + func_80151938(globalCtx, this->actor.textId); + break; + } + } +} + +void func_80C042F8(EnBombers* this) { + if (this->unk_2C4 != 6) { + func_80C03824(this, 6, 1.0f); + } + this->actor.textId = 0x72D; + this->unk_28E = 0x1F40; + this->unk_2C0 = 2; + this->actionFunc = func_80C04354; +} + +void func_80C04354(EnBombers* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x3E8, 0); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_28E = 0; + this->actionFunc = func_80C043C8; + } else { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} + +void func_80C043C8(EnBombers* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x3E8, 0); + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + func_80C042F8(this); + } +} + +void EnBombers_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBombers* this = THIS; + + if (this->unk_2AA != 0) { + this->unk_2AA--; + } + + if (this->unk_2A8 != 0) { + this->unk_2A8--; + } + + if (this->unk_2AC != 0) { + this->unk_2AC--; + } + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y = this->actor.world.rot.y; + func_80C038B4(this); + Actor_SetFocus(&this->actor, 20.0f); + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Math_SmoothStepToS(&this->unk_28A, this->unk_290, 1, 0x1388, 0); + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x1388, 0); + + if (this->unk_2BA == 0) { + this->unk_2B8++; + if (this->unk_2B8 >= 3) { + this->unk_2B8 = 0; + this->unk_2BA = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + this->actor.uncullZoneForward = 500.0f; + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +s32 EnBombers_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBombers* this = THIS; + + if (limbIndex == OBJECT_CS_LIMB_0F) { + *dList = NULL; + } + + if (limbIndex == OBJECT_CS_LIMB_11) { + rot->x += this->unk_28A; + rot->z += this->unk_288; + } + + if (limbIndex == OBJECT_CS_LIMB_13) { + *dList = NULL; + } + + return false; +} + +void EnBombers_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBombers* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C0482C[this->unk_2B8])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C04838[this->unk_2BE])); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(D_80C04818[this->unk_2BE])); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnBombers_OverrideLimbDraw, NULL, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 630c26e65..c51150df8 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h @@ -7,11 +7,47 @@ struct EnBombers; typedef void (*EnBombersActionFunc)(struct EnBombers*, GlobalContext*); +#define ENBOMBERS_GET_F(thisx) ((thisx)->params & 0xF) +#define ENBOMBERS_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) + +enum { + /* 0 */ ENBOMBERS_F_0, + /* 1 */ ENBOMBERS_F_1, + /* 2 */ ENBOMBERS_F_2, + /* 3 */ ENBOMBERS_F_3, + /* 4 */ ENBOMBERS_F_4, +}; + +#define ENBOMBERS_F0_0 0 + typedef struct EnBombers { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x140]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[21]; + /* 0x0206 */ Vec3s morphtable[21]; /* 0x0284 */ EnBombersActionFunc actionFunc; - /* 0x0288 */ char unk_288[0x8C]; + /* 0x0288 */ s16 unk_288; + /* 0x028A */ s16 unk_28A; + /* 0x028C */ UNK_TYPE1 unk28C[2]; + /* 0x028E */ s16 unk_28E; + /* 0x0290 */ s16 unk_290; + /* 0x0294 */ Vec3f unk_294; + /* 0x02A0 */ s16 unk_2A0; + /* 0x02A2 */ UNK_TYPE1 unk2A2[2]; + /* 0x02A4 */ s16 unk_2A4; + /* 0x02A6 */ s16 unk_2A6; + /* 0x02A8 */ s16 unk_2A8; + /* 0x02AA */ s16 unk_2AA; + /* 0x02AC */ s16 unk_2AC; + /* 0x02B0 */ f32 unk_2B0; + /* 0x02B4 */ f32 unk_2B4; + /* 0x02B8 */ s16 unk_2B8; + /* 0x02BA */ s16 unk_2BA; + /* 0x02BC */ s16 unk_2BC; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C4 */ s32 unk_2C4; + /* 0x02C8 */ ColliderCylinder collider; } EnBombers; // size = 0x314 extern const ActorInit En_Bombers_InitVars; diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c index 9acb2f9a5..b803b454c 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -905,12 +905,15 @@ void func_80C00284(EnBomjima* this, GlobalContext* globalCtx) { this->unk_2BC &= 1; } - if ((player->transformation != PLAYER_FORM_GORON) && (player->transformation != PLAYER_FORM_ZORA)) { - if (player->transformation == PLAYER_FORM_HUMAN) { - this->unk_28E = -4000; - } - } else { - this->unk_28E = -6000; + switch (player->transformation) { + case PLAYER_FORM_HUMAN: + this->unk_28E = -0xFA0; + break; + + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + this->unk_28E = -0x1770; + break; } if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e81c1e758..7cdf982e6 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16530,7 +16530,7 @@ 0x80C04354:("func_80C04354",), 0x80C043C8:("func_80C043C8",), 0x80C0443C:("EnBombers_Update",), - 0x80C045B4:("func_80C045B4",), + 0x80C045B4:("EnBombers_OverrideLimbDraw",), 0x80C04614:("EnBombers_Draw",), 0x80C04930:("EnBombers2_Init",), 0x80C04A80:("EnBombers2_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index ae1e8f3a2..8892918ae 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1130,11 +1130,6 @@ D_06002390 = 0x06002390; D_06000A00 = 0x06000A00; D_06000D78 = 0x06000D78; -// ovl_En_Bombers - -D_060064B8 = 0x060064B8; -D_0600F82C = 0x0600F82C; - // ovl_En_Bombers2 D_060064B8 = 0x060064B8; From ecb4afd8226112343b9537a470ebf454b2af1052 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Fri, 25 Mar 2022 02:30:02 +0000 Subject: [PATCH 103/257] Bg_Spdweb (1 non-matching) (#685) * Bg_Spdweb * PR --- spec | 5 +- .../actors/ovl_Bg_Spdweb/z_bg_spdweb.c | 492 ++++++++++++++++-- .../actors/ovl_Bg_Spdweb/z_bg_spdweb.h | 16 +- undefined_syms.txt | 7 - 4 files changed, 468 insertions(+), 52 deletions(-) diff --git a/spec b/spec index 73e16127e..d67962a93 100644 --- a/spec +++ b/spec @@ -2470,8 +2470,11 @@ beginseg name "ovl_Bg_Spdweb" compress include "build/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.o" - include "build/data/ovl_Bg_Spdweb/ovl_Bg_Spdweb.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Bg_Spdweb/ovl_Bg_Spdweb_reloc.o" +#else include "build/data/ovl_Bg_Spdweb/ovl_Bg_Spdweb.reloc.o" +#endif endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c index 6fccf89a0..d1847009c 100644 --- a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c +++ b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c @@ -5,6 +5,7 @@ */ #include "z_bg_spdweb.h" +#include "objects/object_spdweb/object_spdweb.h" #define FLAGS 0x00000000 @@ -15,7 +16,14 @@ void BgSpdweb_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpdweb_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpdweb_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_809CE068(BgSpdweb* this); +void func_809CE234(BgSpdweb* this, GlobalContext* globalCtx); +void func_809CE4C8(BgSpdweb* this, GlobalContext* globalCtx); +void func_809CE830(BgSpdweb* this, GlobalContext* globalCtx); +void func_809CEBC0(BgSpdweb* this, GlobalContext* globalCtx); +void func_809CEE74(BgSpdweb* this); +void func_809CEEAC(BgSpdweb* this, GlobalContext* globalCtx); + const ActorInit Bg_Spdweb_InitVars = { ACTOR_BG_SPDWEB, ACTORCAT_BG, @@ -28,89 +36,491 @@ const ActorInit Bg_Spdweb_InitVars = { (ActorFunc)BgSpdweb_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_809CF080[2] = { +static ColliderTrisElementInit sTrisElementsInit1[2] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000C00, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000C00, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 75.0f, -8.0f, 75.0f }, { 75.0f, -8.0f, -75.0f }, { -75.0f, -8.0f, -75.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000C00, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000C00, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 75.0f, -8.0f, 75.0f }, { -75.0f, -8.0f, -75.0f }, { -75.0f, -8.0f, 75.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_809CF0F8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_2, COLSHAPE_TRIS, }, - 2, D_809CF080, // sTrisElementsInit, +static ColliderTrisInit sTrisInit1 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_TRIS, + }, + 2, + sTrisElementsInit1, }; -// static ColliderTrisElementInit sTrisElementsInit[4] = { -static ColliderTrisElementInit D_809CF108[4] = { +static ColliderTrisElementInit sTrisElementsInit2[4] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 70.0f, 160.0f, 15.0f }, { -70.0f, 160.0f, 15.0f }, { -70.0f, 20.0f, 15.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 70.0f, 160.0f, 15.0f }, { -70.0f, 20.0f, 15.0f }, { 70.0f, 20.0f, 15.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -70.0f, 160.0f, -15.0f }, { 70.0f, 160.0f, -15.0f }, { 70.0f, 20.0f, -15.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -70.0f, 160.0f, -15.0f }, { 70.0f, 20.0f, -15.0f }, { -70.0f, 20.0f, -15.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_809CF1F8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_2, COLSHAPE_TRIS, }, - 4, D_809CF108, // sTrisElementsInit, +static ColliderTrisInit sTrisInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_TRIS, + }, + 4, + sTrisElementsInit2, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809CF210[] = { +Color_RGBA8 D_809CF208 = { 255, 255, 150, 170 }; + +Color_RGBA8 D_809CF20C = { 255, 0, 0, 0 }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1500, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; +void BgSpdweb_Init(Actor* thisx, GlobalContext* globalCtx) { + BgSpdweb* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->unk_161 = 0; + this->switchFlag = BGSPDWEB_GET_SWITCHFLAG(&this->dyna.actor); + thisx->params &= 0xFF; + DynaPolyActor_Init(&this->dyna, 1); + + if (this->dyna.actor.params == BGSPDWEB_FF_0) { + Collider_InitAndSetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit1, this->colliderElements); + func_809CE068(this); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spdweb_Colheader_002678); + this->unk_2F8 = globalCtx->colCtx.dyna.bgActors[this->dyna.bgId].colHeader->vtxList; + this->unk_164 = 0.0f; + this->actionFunc = func_809CE4C8; + } else { + Collider_InitAndSetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit2, this->colliderElements); + func_809CE068(this); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spdweb_Colheader_0011C0); + this->actionFunc = func_809CEBC0; + Actor_SetFocus(&this->dyna.actor, 30.0f); + } + + this->unk_162 = 0; + + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void BgSpdweb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgSpdweb* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(globalCtx, &this->collider); +} + +void func_809CE068(BgSpdweb* this) { + Vec3f sp64[3]; + s32 i; + s32 j; + + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + + for (i = 0; i < this->collider.count; i++) { + for (j = 0; j < ARRAY_COUNT(sp64); j++) { + Matrix_MultiplyVector3fByState(this->collider.elements[i].dim.vtx + j, &sp64[j]); + } + Collider_SetTrisVertices(&this->collider, i, &sp64[0], &sp64[1], &sp64[2]); + } +} + +void func_809CE15C(BgSpdweb* this) { + this->unk_2F8[0].y = this->unk_2F8[3].y = this->unk_2F8[10].y = this->unk_2F8[11].y = this->unk_2F8[12].y = + this->unk_2F8[13].y = this->unk_2F8[14].y = this->unk_2F8[15].y = + (this->dyna.actor.home.pos.y - this->dyna.actor.world.pos.y) * 10.0f; +} + +void func_809CE1D0(BgSpdweb* this, GlobalContext* globalCtx) { + this->unk_162 = 30; + Flags_SetSwitch(globalCtx, this->switchFlag); + + if (this->dyna.actor.params == BGSPDWEB_FF_0) { + this->actionFunc = func_809CE234; + } else { + this->actionFunc = func_809CE830; + } +} + +void func_809CE234(BgSpdweb* this, GlobalContext* globalCtx) { + Vec3f spB4; + Vec3f spA8; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + s16 phi_s2; + s16 temp_s0; + s32 i; + + if (this->unk_162 != 0) { + this->unk_162--; + } + + if (this->unk_162 == 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + if ((this->unk_162 % 3) == 0) { + phi_s2 = Rand_ZeroOne() * 10922.0f; + spB4.y = 0.0f; + spA8.y = this->dyna.actor.world.pos.y; + + for (i = 0; i < 6; i++) { + temp_s0 = (s32)randPlusMinusPoint5Scaled(10240.0f) + phi_s2; + temp_f24 = Math_SinS(temp_s0); + temp_f22 = Math_CosS(temp_s0); + + spA8.x = this->dyna.actor.world.pos.x + (120.0f * temp_f24); + spA8.z = this->dyna.actor.world.pos.z + (120.0f * temp_f22); + + temp_f20 = Math_Vec3f_DistXZ(&this->dyna.actor.home.pos, &spA8) * (1.0f / 120.0f); + if (temp_f20 < 0.7f) { + temp_f20 = 1.0f - temp_f20; + temp_f24 = Math_SinS(BINANG_ROT180(temp_s0)); + temp_f22 = Math_CosS(BINANG_ROT180(temp_s0)); + } + + spB4.x = 7.0f * temp_f24 * temp_f20; + spB4.y = 0.0f; + spB4.z = 7.0f * temp_f22 * temp_f20; + + EffectSsDeadDb_Spawn(globalCtx, &this->dyna.actor.home.pos, &spB4, &gZeroVec3f, &D_809CF208, &D_809CF20C, + 0x32, 8, 0xE); + phi_s2 += 0x2AAA; + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.home.pos, 11, NA_SE_EN_EXTINCT); + } +} + +void func_809CE4C8(BgSpdweb* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + ColliderTrisElement* element; + s16 sp3A; + s32 i; + f32 temp_f12; + + sp40.x = this->dyna.actor.world.pos.x; + sp40.y = this->dyna.actor.world.pos.y - 50.0f; + sp40.z = this->dyna.actor.world.pos.z; + sp3A = player->unk_B6A; + + if (func_80123F48(globalCtx, &sp40, 70.0f, 50.0f)) { + this->dyna.actor.home.pos.x = player->swordInfo[0].tip.x; + this->dyna.actor.home.pos.z = player->swordInfo[0].tip.z; + func_809CEE74(this); + return; + } + + if (this->collider.base.acFlags & AC_HIT) { + for (i = 0; i < 2; i++) { + element = &this->collider.elements[i]; + if (element->info.bumperFlags & BUMP_HIT) { + if (this->collider.elements[i].info.acHitInfo->toucher.dmgFlags & 0x800) { + Math_Vec3s_ToVec3f(&this->dyna.actor.home.pos, &element->info.bumper.hitPos); + func_809CEE74(this); + return; + } + + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + sp3A = 300; + break; + } + } + } + } + + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + temp_f12 = 2.0f * sqrtf(CLAMP_MIN(sp3A, 0)); + if ((this->unk_164 < temp_f12) && (temp_f12 > 2.0f)) { + this->unk_164 = temp_f12; + this->unk_162 = 12; + if (sp3A > 50) { + player->stateFlags1 |= 0x20; + this->unk_161 = 1; + } + } else if (player->actor.speedXZ != 0.0f) { + this->unk_164 = CLAMP_MIN(this->unk_164, 2.0f); + } + } + + if (this->unk_162 != 0) { + this->unk_162--; + } + + this->dyna.actor.world.pos.y = (sin_rad(this->unk_162 * (M_PI / 6)) * this->unk_164) + this->dyna.actor.home.pos.y; + Math_ApproachZeroF(&this->unk_164, 1.0f, 0.8f); + + if (this->unk_162 == 4) { + if ((this->unk_161 != 0) || + ((DynaPolyActor_IsInRidingMovingState(&this->dyna) != 0) && (this->unk_164 > 2.0f))) { + player->actor.velocity.y = this->unk_164 * 0.7f; + player->unk_B68 = (SQ(this->unk_164) * 0.15f) + this->dyna.actor.world.pos.y; + this->unk_161 = 0; + player->stateFlags1 &= ~0x20; + } + } else if (this->unk_162 == 11) { + if (this->unk_164 > 3.0f) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WEB_VIBRATION); + } else { + func_801A75E8(NA_SE_EV_WEB_VIBRATION); + } + } + + if (this->unk_162 == 0) { + this->unk_162 = 12; + } + + func_809CE15C(this); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +#ifdef NON_MATCHING +void func_809CE830(BgSpdweb* this, GlobalContext* globalCtx) { + Vec3f spDC; + Vec3f spD0; + Vec3f spC4; + f32 spB0; + f32 spA4; + f32 sp9C; + f32 sp94; + f32 sp90; + f32 temp_f20; + f32 temp_f22; + f32 temp_f28; + f32 temp_f30; + s32 i; + s16 temp_s0; + s16 temp_s3; + + if (this->unk_162 != 0) { + this->unk_162--; + } + + if (this->unk_162 == 0) { + if (ActorCutscene_GetLength(this->dyna.actor.cutscene) == -1) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + } + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + if ((this->unk_162 % 3) == 0) { + temp_s3 = Rand_ZeroOne() * 0x2AAA; + spB0 = Math_CosS(this->dyna.actor.shape.rot.x); + temp_f20 = Math_SinS(this->dyna.actor.shape.rot.x); + temp_f30 = Math_CosS(this->dyna.actor.shape.rot.y); + spA4 = Math_SinS(this->dyna.actor.shape.rot.y); + if (1) {} + + spC4.x = this->dyna.actor.world.pos.x + ((90.0f * temp_f20) * spA4); + spC4.y = this->dyna.actor.world.pos.y + (90.0f * spB0); + spC4.z = this->dyna.actor.world.pos.z + ((90.0f * temp_f20) * temp_f30); + + sp94 = temp_f20 * spA4; + sp90 = temp_f20 * temp_f30; + + for (i = 0; i < 6; i++) { + temp_s0 = (s32)randPlusMinusPoint5Scaled(0x2800) + temp_s3; + temp_f20 = Math_SinS(temp_s0); + temp_f22 = Math_CosS(temp_s0); + + spD0.x = spC4.x + (90.0f * ((sp94 * temp_f22) + (temp_f30 * temp_f20))); + spD0.y = spC4.y + ((90.0f * spB0) * temp_f22); + spD0.z = spC4.z + (90.0f * ((sp90 * temp_f22) - (spA4 * temp_f20))); + + temp_f28 = Math_Vec3f_DistXYZ(&this->dyna.actor.home.pos, &spD0) * (1.0f / 90.0f); + if (temp_f28 < 0.65f) { + temp_f28 = 1.0f - temp_f28; + temp_f20 = Math_SinS(BINANG_ROT180(temp_s0)); + temp_f22 = Math_CosS(BINANG_ROT180(temp_s0)); + } + + spDC.x = (6.5f * temp_f28) * ((temp_f30 * temp_f20) + (temp_f22 * sp94)); + spDC.y = temp_f22 * ((6.5f * temp_f28) * spB0); + spDC.z = (6.5f * temp_f28) * ((temp_f22 * sp90) - (spA4 * temp_f20)); + + EffectSsDeadDb_Spawn(globalCtx, &this->dyna.actor.home.pos, &spDC, &gZeroVec3f, &D_809CF208, &D_809CF20C, + 0x3C, 8, 0xE); + temp_s3 += 0x2AAA; + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.home.pos, 11, NA_SE_EN_EXTINCT); + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE830.s") #endif -extern ColliderTrisElementInit D_809CF080[2]; -extern ColliderTrisInit D_809CF0F8; -extern ColliderTrisElementInit D_809CF108[4]; -extern ColliderTrisInit D_809CF1F8; -extern InitChainEntry D_809CF210[]; +void func_809CEBC0(BgSpdweb* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 sp58; + f32 temp_f10; + f32 temp_f18; + ColliderTrisElement* ptr; + s32 i; + Vec3f sp3C; + f32 sp38; + f32 sp34; + f32 sp30; + f32 sp2C; -extern UNK_TYPE D_06000060; -extern UNK_TYPE D_06002678; + if (this->collider.base.acFlags & AC_HIT) { + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + ptr = &this->collider.elements[i]; + if (ptr->info.bumperFlags & BUMP_HIT) { + Math_Vec3s_ToVec3f(&this->dyna.actor.home.pos, &ptr->info.bumper.hitPos); + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/BgSpdweb_Init.s") + if (i == ARRAY_COUNT(this->colliderElements)) { + this->dyna.actor.home.pos.x = + ((90.0f * Math_SinS(this->dyna.actor.shape.rot.x)) * Math_SinS(this->dyna.actor.shape.rot.y)) + + this->dyna.actor.world.pos.x; + this->dyna.actor.home.pos.y = + (90.0f * Math_CosS(this->dyna.actor.shape.rot.x)) + this->dyna.actor.world.pos.y; + this->dyna.actor.home.pos.z = + ((90.0f * Math_SinS(this->dyna.actor.shape.rot.x)) * Math_CosS(this->dyna.actor.shape.rot.y)) + + this->dyna.actor.world.pos.z; + } + func_809CEE74(this); + } else if ((player->itemActionParam == 7) && (player->unk_B28 != 0)) { + Math_Vec3f_Diff(&player->swordInfo[0].tip, &this->dyna.actor.world.pos, &sp3C); + sp38 = Math_SinS(-this->dyna.actor.shape.rot.x); + sp34 = Math_CosS(-this->dyna.actor.shape.rot.x); + sp30 = Math_SinS(-this->dyna.actor.shape.rot.y); + sp2C = Math_CosS(-this->dyna.actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/BgSpdweb_Destroy.s") + temp_f18 = ((sp3C.x * sp38 * sp30) + (sp3C.y * sp34)) - (sp3C.z * sp38 * sp2C); + sp58 = (-sp3C.x * sp34 * sp30) + (sp3C.y * sp38) + (sp3C.z * sp34 * sp2C); + temp_f10 = (sp3C.x * sp2C) + (sp3C.z * sp30); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE068.s") + if ((fabsf(temp_f10) < 70.0f) && (fabsf(sp58) < 10.0f) && (temp_f18 < 160.0f) && (temp_f18 > 20.0f)) { + Math_Vec3f_Copy(&this->dyna.actor.home.pos, &player->swordInfo[0].tip); + func_809CEE74(this); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE15C.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE1D0.s") +void func_809CEE74(BgSpdweb* this) { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->actionFunc = func_809CEEAC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE234.s") +void func_809CEEAC(BgSpdweb* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + func_809CE1D0(this, globalCtx); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE4C8.s") +void BgSpdweb_Update(Actor* thisx, GlobalContext* globalCtx) { + BgSpdweb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE830.s") + this->actionFunc(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CEBC0.s") +void BgSpdweb_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx* gfx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CEE74.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CEEAC.s") + gfx = POLY_XLU_DISP; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/BgSpdweb_Update.s") + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/BgSpdweb_Draw.s") + if (thisx->params == BGSPDWEB_FF_1) { + gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[2], object_spdweb_DL_000060); + } else { + Matrix_InsertTranslation(0.0f, (thisx->home.pos.y - thisx->world.pos.y) * 10.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, ((thisx->home.pos.y - thisx->world.pos.y) + 10.0f) * 0.1f, 1.0f, MTXMODE_APPLY); + + gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[2], object_spdweb_DL_0012F0); + } + + POLY_XLU_DISP = &gfx[3]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h index 1809d6723..9a71c278f 100644 --- a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h +++ b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h @@ -7,11 +7,21 @@ struct BgSpdweb; typedef void (*BgSpdwebActionFunc)(struct BgSpdweb*, GlobalContext*); +#define BGSPDWEB_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F) + +#define BGSPDWEB_FF_0 0 +#define BGSPDWEB_FF_1 1 + typedef struct BgSpdweb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ BgSpdwebActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x19C]; + /* 0x0160 */ u8 switchFlag; + /* 0x0161 */ u8 unk_161; + /* 0x0162 */ s16 unk_162; + /* 0x0164 */ f32 unk_164; + /* 0x0168 */ ColliderTris collider; + /* 0x0188 */ ColliderTrisElement colliderElements[4]; + /* 0x02F8 */ Vec3s* unk_2F8; } BgSpdweb; // size = 0x2FC extern const ActorInit Bg_Spdweb_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 8892918ae..ba44de7b0 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -719,13 +719,6 @@ D_06002CE0 = 0x06002CE0; D_06000048 = 0x06000048; -// ovl_Bg_Spdweb - -D_06000060 = 0x06000060; -D_060011C0 = 0x060011C0; -D_060012F0 = 0x060012F0; -D_06002678 = 0x06002678; - // ovl_Bg_Spout_Fire D_06000040 = 0x06000040; From 80cbdb956df888c0b0acc9ec1c269c131cc0a541 Mon Sep 17 00:00:00 2001 From: fig02 Date: Thu, 24 Mar 2022 22:39:34 -0400 Subject: [PATCH 104/257] En_Tanron4 OK (seagulls) (#714) * Seagull OK * small fixes * review 1 * review 2 --- assets/xml/objects/object_tanron4.xml | 12 +- include/functions.h | 2 +- spec | 3 +- src/code/z_lib.c | 2 +- .../actors/ovl_En_Tanron4/z_en_tanron4.c | 258 +++++++++++++++++- .../actors/ovl_En_Tanron4/z_en_tanron4.h | 19 +- tools/disasm/functions.txt | 8 +- 7 files changed, 279 insertions(+), 25 deletions(-) diff --git a/assets/xml/objects/object_tanron4.xml b/assets/xml/objects/object_tanron4.xml index f1002fd22..2c988e74b 100644 --- a/assets/xml/objects/object_tanron4.xml +++ b/assets/xml/objects/object_tanron4.xml @@ -1,14 +1,19 @@  + - - + + + + + + @@ -19,6 +24,7 @@ - + + diff --git a/include/functions.h b/include/functions.h index 3595508fc..aa37f2e11 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1647,7 +1647,7 @@ void Actor_ProcessInitChain(Actor* actor, InitChainEntry* ichain); f32 Math_SmoothStepToF(f32* pValue, f32 target, f32 fraction, f32 step, f32 minStep); void Math_ApproachF(f32* pValue, f32 target, f32 scale, f32 maxStep); void Math_ApproachZeroF(f32* pValue, f32 scale, f32 maxStep); -s32 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step, s16 minStep); +s16 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step, s16 minStep); void Math_ApproachS(s16* pValue, s16 target, s16 scale, s16 maxStep); void Color_RGBA8_Copy(Color_RGBA8* dst, Color_RGBA8* src); void func_801000A4(u16 sfxId); diff --git a/spec b/spec index d67962a93..32ee43eb9 100644 --- a/spec +++ b/spec @@ -4828,8 +4828,7 @@ beginseg name "ovl_En_Tanron4" compress include "build/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.o" - include "build/data/ovl_En_Tanron4/ovl_En_Tanron4.data.o" - include "build/data/ovl_En_Tanron4/ovl_En_Tanron4.reloc.o" + include "build/src/overlays/actors/ovl_En_Tanron4/ovl_En_Tanron4_reloc.o" endseg beginseg diff --git a/src/code/z_lib.c b/src/code/z_lib.c index d9300deda..aaf4bc7d9 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -578,7 +578,7 @@ void Math_ApproachZeroF(f32* pValue, f32 scale, f32 maxStep) { *pValue = *pValue - f0; } -s32 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step, s16 minStep) { +s16 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step, s16 minStep) { s16 stepSize = 0; s16 diff = target - *pValue; diff --git a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c index 9912baf60..86f4d5ea5 100644 --- a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c +++ b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c @@ -1,7 +1,7 @@ /* * File: z_en_tanron4.c * Overlay: ovl_En_Tanron4 - * Description: Flock of Seagulls + * Description: Seagull */ #include "z_en_tanron4.h" @@ -15,7 +15,22 @@ void EnTanron4_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTanron4_Update(Actor* thisx, GlobalContext* globalCtx); void EnTanron4_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnTanron4_SetupFlyNearHome(EnTanron4* this); +void EnTanron4_SetupFlyNearActor(EnTanron4* this); + +void EnTanron4_FlyNearHome(EnTanron4* this, GlobalContext* globalCtx); +void EnTanron4_FlyNearActor(EnTanron4* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ SEAGULL_FLY_FLAP, + /* 1 */ SEAGULL_FLY_GLIDE, +} SeagullFlyState; + +typedef enum { + /* 0 */ SEAGULL_TIMER_FLY_STATE, + /* 1 */ SEAGULL_TIMER_CHOOSE_TARGET, +} SeagullTimers; + const ActorInit En_Tanron4_InitVars = { ACTOR_EN_TANRON4, ACTORCAT_ITEMACTION, @@ -28,22 +43,241 @@ const ActorInit En_Tanron4_InitVars = { (ActorFunc)EnTanron4_Draw, }; -#endif +void EnTanron4_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTanron4* this = THIS; -extern UNK_TYPE D_06000168; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSeagullSkel, &gSeagullFlapAnim, this->jointTable, + this->morphTable, OBJECT_TANRON4_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/EnTanron4_Init.s") + thisx->flags &= ~ACTOR_FLAG_1; + thisx->speedXZ = 3.0f + KREG(48); + thisx->uncullZoneForward = 10000.0f + KREG(70); + this->randRollTimer = Rand_ZeroFloat(10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/EnTanron4_Destroy.s") + if (thisx->params == SEAGULL_FOLLOW_ACTOR) { + EnTanron4_SetupFlyNearActor(this); + } else { + EnTanron4_SetupFlyNearHome(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/func_80BE3DC0.s") + // spawn number of seagulls specified by params + if (thisx->params >= 0) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/func_80BE3DFC.s") + for (i = 0; i < thisx->params; i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TANRON4, + thisx->world.pos.x + randPlusMinusPoint5Scaled(500.0f), + thisx->world.pos.y + randPlusMinusPoint5Scaled(100.0f), + thisx->world.pos.z + randPlusMinusPoint5Scaled(500.0f), 0, Rand_ZeroFloat(65536.0f), 0, + SEAGULL_CLONE); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/func_80BE4268.s") + if ((gSaveContext.time > CLOCK_TIME(20, 0)) || (gSaveContext.time < CLOCK_TIME(4, 0))) { + this->timeInfluence = 1500.0f; + thisx->world.pos.y += 1500.0f; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/func_80BE42A4.s") +void EnTanron4_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/EnTanron4_Update.s") +void EnTanron4_SetupFlyNearHome(EnTanron4* this) { + this->actionFunc = EnTanron4_FlyNearHome; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/EnTanron4_Draw.s") +void EnTanron4_FlyNearHome(EnTanron4* this, GlobalContext* globalCtx) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 distToTarget; + s16 xRot; + s16 yRot; + s16 zRot; + + // `timeInfluence` controls both the height of the seagulls and when they are visible. + // They fly higher in the sky as the night goes on, and they disapear as dawn approaches. + if ((gSaveContext.time > CLOCK_TIME(20, 0)) || (gSaveContext.time < CLOCK_TIME(4, 0))) { + Math_ApproachF(&this->timeInfluence, 1500.0f, 1.0f, 1.0f); + } else { + Math_ApproachZeroF(&this->timeInfluence, 1.0f, 1.0f); + } + + xDiff = this->targetPos.x - this->actor.world.pos.x; + yDiff = (this->targetPos.y + this->timeInfluence) - this->actor.world.pos.y; + zDiff = this->targetPos.z - this->actor.world.pos.z; + + distToTarget = sqrtf(SQ(xDiff) + SQ(zDiff)); + + if ((this->timers[SEAGULL_TIMER_CHOOSE_TARGET] == 0) || (distToTarget < 100.0f)) { + this->targetPos.x = this->actor.home.pos.x + randPlusMinusPoint5Scaled(500.0f); + this->targetPos.y = this->actor.home.pos.y + randPlusMinusPoint5Scaled(100.0f); + this->targetPos.z = this->actor.home.pos.z + randPlusMinusPoint5Scaled(500.0f); + + this->timers[SEAGULL_TIMER_CHOOSE_TARGET] = Rand_ZeroFloat(100.0f) + 60.0f; + this->step = 0; + } + + yRot = Math_Atan2S(xDiff, zDiff); + xRot = Math_Atan2S(yDiff, distToTarget); + zRot = Math_SmoothStepToS(&this->actor.world.rot.y, yRot, 0xA, this->step, 0); + + if (zRot > 0x1000) { + zRot = 0x1000; + } else if (zRot < -0x1000) { + zRot = -0x1000; + } + + Math_ApproachS(&this->actor.world.rot.x, xRot, 0xA, this->step); + Math_ApproachS(&this->actor.world.rot.z, -zRot, 0xA, this->step); + + Math_ApproachS(&this->step, 0x200, 1, 0x10); + + SkelAnime_Update(&this->skelAnime); + + switch (this->flyState) { + case SEAGULL_FLY_FLAP: + if ((this->timers[SEAGULL_TIMER_FLY_STATE] == 0) && + (Animation_OnFrame(&this->skelAnime, 2.0f + KREG(42)))) { + this->flyState = SEAGULL_FLY_GLIDE; + this->timers[SEAGULL_TIMER_FLY_STATE] = Rand_ZeroFloat(50.0f) + 50.0f; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, -15.0f + KREG(43)); + this->skelAnime.curFrame = 2.0f + KREG(42); + this->skelAnime.playSpeed = 0.0f; + } + break; + + case SEAGULL_FLY_GLIDE: + if (((this->randRollTimer % 8) == 0) && (Rand_ZeroOne() < 0.5f)) { + this->rollTarget = randPlusMinusPoint5Scaled(3000.0f + KREG(44)); + } + + if (this->timers[SEAGULL_TIMER_FLY_STATE] == 0) { + this->flyState = SEAGULL_FLY_FLAP; + this->timers[SEAGULL_TIMER_FLY_STATE] = Rand_ZeroFloat(50.0f) + 70.0f; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, -10.0f + KREG(43)); + this->skelAnime.curFrame = 2.0f + KREG(42); + } + break; + } + + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + + Math_ApproachS(&this->roll, this->rollTarget, 3, 0x3E8 + KREG(45)); +} + +void EnTanron4_SetupFlyNearActor(EnTanron4* this) { + this->actionFunc = EnTanron4_FlyNearActor; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, 0.0f); +} + +void EnTanron4_FlyNearActor(EnTanron4* this, GlobalContext* globalCtx) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 distToTarget; + s16 xRot; + s16 yRot; + s16 zRot; + Actor* targetActor = this->actor.parent; + + xDiff = this->targetPos.x - this->actor.world.pos.x; + yDiff = this->targetPos.y - this->actor.world.pos.y; + zDiff = this->targetPos.z - this->actor.world.pos.z; + + distToTarget = sqrtf(SQ(xDiff) + SQ(zDiff)); + + if ((this->timers[SEAGULL_TIMER_CHOOSE_TARGET] == 0) || (distToTarget < 100.0f)) { + this->targetPos.x = targetActor->world.pos.x + randPlusMinusPoint5Scaled(200.0f + KREG(82)); + this->targetPos.y = targetActor->world.pos.y + KREG(80) + 100.0f + randPlusMinusPoint5Scaled(100.0f + KREG(81)); + this->targetPos.z = targetActor->world.pos.z + randPlusMinusPoint5Scaled(200.0f + KREG(82)); + + this->timers[SEAGULL_TIMER_CHOOSE_TARGET] = Rand_ZeroFloat(100.0f) + 60.0f; + this->step = 0; + } + + yRot = Math_Atan2S(xDiff, zDiff); + xRot = Math_Atan2S(yDiff, distToTarget); + zRot = Math_SmoothStepToS(&this->actor.world.rot.y, yRot, 0xA, this->step, 0); + + if (zRot > 0x1000) { + zRot = 0x1000; + } else if (zRot < -0x1000) { + zRot = -0x1000; + } + + Math_ApproachS(&this->actor.world.rot.x, xRot, 0xA, this->step); + Math_ApproachS(&this->actor.world.rot.z, -zRot, 0xA, this->step); + Math_ApproachS(&this->step, 0x200, 1, 0x10); + + SkelAnime_Update(&this->skelAnime); + + switch (this->flyState) { + case SEAGULL_FLY_FLAP: + if ((this->timers[SEAGULL_TIMER_FLY_STATE] == 0) && + (Animation_OnFrame(&this->skelAnime, 2.0f + KREG(42)))) { + this->flyState = SEAGULL_FLY_GLIDE; + this->timers[SEAGULL_TIMER_FLY_STATE] = Rand_ZeroFloat(50.0f) + 50.0f; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, -15.0f + KREG(43)); + this->skelAnime.curFrame = 2.0f + KREG(42); + this->skelAnime.playSpeed = 0.0f; + } + break; + + case SEAGULL_FLY_GLIDE: + if (((this->randRollTimer % 8) == 0) && (Rand_ZeroOne() < 0.5f)) { + this->rollTarget = randPlusMinusPoint5Scaled(3000.0f + KREG(44)); + } + + if (this->timers[SEAGULL_TIMER_FLY_STATE] == 0) { + this->flyState = SEAGULL_FLY_FLAP; + this->timers[SEAGULL_TIMER_FLY_STATE] = Rand_ZeroFloat(50.0f) + 70.0f; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, -10.0f + KREG(43)); + this->skelAnime.curFrame = 2.0f + KREG(42); + } + break; + } + + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + + Math_ApproachS(&this->roll, this->rollTarget, 3, 0x3E8 + KREG(45)); +} + +void EnTanron4_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTanron4* this = THIS; + + Actor_SetScale(&this->actor, 0.001f * KREG(16) + 0.01f); + + if (KREG(63) == 0) { + s32 i; + + this->randRollTimer++; + + for (i = 0; i < ARRAY_COUNT(this->timers); i++) { + if (this->timers[i] != 0) { + this->timers[i]--; + } + } + + this->actionFunc(this, globalCtx); + + Actor_UpdateVelocityWithoutGravity(&this->actor); + Actor_UpdatePos(&this->actor); + } +} + +void EnTanron4_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTanron4* this = THIS; + + if (this->timeInfluence < 1400.0f) { + Matrix_InsertZRotation_s(this->roll, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, NULL, &this->actor); + } +} diff --git a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h index abbcc6633..250a62cf1 100644 --- a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h +++ b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h @@ -2,17 +2,32 @@ #define Z_EN_TANRON4_H #include "global.h" +#include "assets/objects/object_tanron4/object_tanron4.h" struct EnTanron4; typedef void (*EnTanron4ActionFunc)(struct EnTanron4*, GlobalContext*); typedef struct EnTanron4 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xE8]; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 randRollTimer; + /* 0x146 */ s16 timers[2]; + /* 0x14A */ u8 flyState; + /* 0x14C */ Vec3f targetPos; + /* 0x158 */ s16 step; + /* 0x15A */ s16 roll; + /* 0x15C */ s16 rollTarget; + /* 0x160 */ f32 timeInfluence; + /* 0x164 */ SkelAnime skelAnime; + /* 0x1A8 */ Vec3s jointTable[OBJECT_TANRON4_LIMB_MAX]; + /* 0x1EA */ Vec3s morphTable[OBJECT_TANRON4_LIMB_MAX]; /* 0x022C */ EnTanron4ActionFunc actionFunc; } EnTanron4; // size = 0x230 +// other than these magic values, params is the number of desired seagulls in the flock +#define SEAGULL_CLONE -1 +#define SEAGULL_FOLLOW_ACTOR 100 + extern const ActorInit En_Tanron4_InitVars; #endif // Z_EN_TANRON4_H diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 7cdf982e6..41ad2eccb 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16094,10 +16094,10 @@ 0x80BE393C:("EnRuppecrow_Draw",), 0x80BE3B80:("EnTanron4_Init",), 0x80BE3DB0:("EnTanron4_Destroy",), - 0x80BE3DC0:("func_80BE3DC0",), - 0x80BE3DFC:("func_80BE3DFC",), - 0x80BE4268:("func_80BE4268",), - 0x80BE42A4:("func_80BE42A4",), + 0x80BE3DC0:("EnTanron4_SetupFlyNearHome",), + 0x80BE3DFC:("EnTanron4_FlyNearHome",), + 0x80BE4268:("EnTanron4_SetupFlyNearActor",), + 0x80BE42A4:("EnTanron4_FlyNearActor",), 0x80BE4734:("EnTanron4_Update",), 0x80BE4804:("EnTanron4_Draw",), 0x80BE4930:("func_80BE4930",), From ce7aa8745406ca97cf04ec9516ac0724f63210d3 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 25 Mar 2022 02:45:37 +0000 Subject: [PATCH 105/257] Oceff wipe6 (#686) * Uncorrupted; Not OK * Merged upstream -- actually OK * Update assets/xml/overlays/ovl_Oceff_Wipe6.xml Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * - Removed Extra 0 characters; clang-format-11 * Removed new warnings. Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --- assets/xml/overlays/ovl_Oceff_Wipe6.xml | 9 +++ include/functions.h | 2 +- include/z64.h | 3 +- spec | 3 +- src/code/z_camera.c | 2 +- .../actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c | 74 +++++++++++++++++-- .../actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h | 2 +- tools/disasm/functions.txt | 2 +- tools/sizes/code_functions.csv | 2 +- 9 files changed, 85 insertions(+), 14 deletions(-) create mode 100644 assets/xml/overlays/ovl_Oceff_Wipe6.xml diff --git a/assets/xml/overlays/ovl_Oceff_Wipe6.xml b/assets/xml/overlays/ovl_Oceff_Wipe6.xml new file mode 100644 index 000000000..e64c8cc71 --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Wipe6.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/include/functions.h b/include/functions.h index aa37f2e11..4b08dca2b 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1158,7 +1158,7 @@ s16 Camera_ClearFlags(Camera* camera, s16 flags); s32 func_800DFFAC(Camera* camera, Actor* doorActor, s16 bgCamDataId, f32 arg3, s16 timer1, s16 timer2, s16 timer3); // UNK_TYPE4 func_800E007C(Camera* param_1, Camera* param_2); // UNK_TYPE4 func_800E01AC(void); -// void func_800E01B8(void); +Vec3f* Camera_GetQuakeOffset(Vec3f* dst, Camera* camera); // void func_800E01DC(s32 param_1, u32 param_2, UNK_TYPE4 param_3, UNK_TYPE4 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6); // UNK_TYPE4 func_800E0228(void); // void func_800E0238(void); diff --git a/include/z64.h b/include/z64.h index 7d39504b8..3e8219da7 100644 --- a/include/z64.h +++ b/include/z64.h @@ -872,7 +872,8 @@ typedef struct { /* 0x12074 */ UNK_TYPE1 pad12074[0x4]; /* 0x12078 */ s32 bankRupeesSelected; /* 0x1207C */ s32 bankRupees; - /* 0x12080 */ UNK_TYPE1 pad12080[0x31]; + /* 0x12080 */ UNK_TYPE1 pad12080[0x30]; + /* 0x120B0 */ u8 unk120B0; /* 0x120B1 */ u8 unk120B1; /* 0x120B2 */ UNK_TYPE1 pad120B2[0x22]; /* 0x120D4 */ UNK_TYPE2 unk120D4; diff --git a/spec b/spec index 32ee43eb9..338c82a3c 100644 --- a/spec +++ b/spec @@ -4620,8 +4620,7 @@ beginseg name "ovl_Oceff_Wipe6" compress include "build/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.o" - include "build/data/ovl_Oceff_Wipe6/ovl_Oceff_Wipe6.data.o" - include "build/data/ovl_Oceff_Wipe6/ovl_Oceff_Wipe6.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Wipe6/ovl_Oceff_Wipe6_reloc.o" endseg beginseg diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 9aef846e0..d3f1f9203 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -356,7 +356,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E01AC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E01B8.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetQuakeOffset.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E01DC.s") diff --git a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c index 6bde6902c..a16821f00 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c +++ b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c @@ -15,7 +15,6 @@ void OceffWipe6_Destroy(Actor* thisx, GlobalContext* globalCtx); void OceffWipe6_Update(Actor* thisx, GlobalContext* globalCtx); void OceffWipe6_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Oceff_Wipe6_InitVars = { ACTOR_OCEFF_WIPE6, ACTORCAT_ITEMACTION, @@ -28,12 +27,75 @@ const ActorInit Oceff_Wipe6_InitVars = { (ActorFunc)OceffWipe6_Draw, }; -#endif +#include "overlays/ovl_Oceff_Wipe6/ovl_Oceff_Wipe6.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe6/OceffWipe6_Init.s") +void OceffWipe6_Init(Actor* thisx, GlobalContext* globalCtx) { + OceffWipe6* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe6/OceffWipe6_Destroy.s") + Actor_SetScale(&this->actor, 1.0f); + this->counter = 0; + this->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe6/OceffWipe6_Update.s") +void OceffWipe6_Destroy(Actor* thisx, GlobalContext* globalCtx) { + func_80115D5C(&globalCtx->state); + globalCtx->msgCtx.unk120B0 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe6/OceffWipe6_Draw.s") +void OceffWipe6_Update(Actor* thisx, GlobalContext* globalCtx) { + OceffWipe6* this = THIS; + + this->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; + if (this->counter < 100) { + this->counter++; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void OceffWipe6_Draw(Actor* thisx, GlobalContext* globalCtx) { + OceffWipe6* this = THIS; + f32 z; + u8 alpha; + s32 i; + s32 counter; + Vec3f activeCamEye; + s32 pad; + Vec3f quakeOffset; + s32 pad2; + + activeCamEye = GET_ACTIVE_CAM(globalCtx)->eye; + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(globalCtx)); + + if (this->counter < 32) { + counter = this->counter; + z = Math_SinS(counter * 0x200) * 1220.0f; + } else { + z = 1220.0f; + } + + if (this->counter >= 80) { + alpha = 12 * (100 - this->counter); + } else { + alpha = 255; + } + + for (i = 1; i < ARRAY_COUNT(gOceff6Vtx); i += 2) { + gOceff6Vtx[i].v.cn[3] = alpha; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(activeCamEye.x + quakeOffset.x, activeCamEye.y + quakeOffset.y, + activeCamEye.z + quakeOffset.z, MTXMODE_NEW); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_InsertXRotation_s(0x708, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, -z, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + AnimatedMat_Draw(globalCtx, ovl_Oceff_Wipe6_Matanimheader_000338); + gSPDisplayList(POLY_XLU_DISP++, gOceff6DL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h index 0b845e133..c37e3f9d4 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h +++ b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h @@ -7,7 +7,7 @@ struct OceffWipe6; typedef struct OceffWipe6 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s16 counter; } OceffWipe6; // size = 0x148 extern const ActorInit Oceff_Wipe6_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 41ad2eccb..9215796af 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1290,7 +1290,7 @@ 0x800DFFAC:("func_800DFFAC",), 0x800E007C:("func_800E007C",), 0x800E01AC:("func_800E01AC",), - 0x800E01B8:("func_800E01B8",), + 0x800E01B8:("Camera_GetQuakeOffset",), 0x800E01DC:("func_800E01DC",), 0x800E0228:("func_800E0228",), 0x800E0238:("func_800E0238",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index fa1f63c91..e312fa619 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -804,7 +804,7 @@ asm/non_matchings/code/z_camera/Camera_ClearFlags.s,Camera_ClearFlags,0x800DFF84 asm/non_matchings/code/z_camera/func_800DFFAC.s,func_800DFFAC,0x800DFFAC,0x34 asm/non_matchings/code/z_camera/func_800E007C.s,func_800E007C,0x800E007C,0x4C asm/non_matchings/code/z_camera/func_800E01AC.s,func_800E01AC,0x800E01AC,0x3 -asm/non_matchings/code/z_camera/func_800E01B8.s,func_800E01B8,0x800E01B8,0x9 +asm/non_matchings/code/z_camera/Camera_GetQuakeOffset.s,Camera_GetQuakeOffset,0x800E01B8,0x9 asm/non_matchings/code/z_camera/func_800E01DC.s,func_800E01DC,0x800E01DC,0x13 asm/non_matchings/code/z_camera/func_800E0228.s,func_800E0228,0x800E0228,0x4 asm/non_matchings/code/z_camera/func_800E0238.s,func_800E0238,0x800E0238,0x1D From fa8c723da8b3ca1265a568a3d96719a6ca538eb6 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Fri, 25 Mar 2022 17:53:19 -0700 Subject: [PATCH 106/257] Fix two small things in Bg_F40_Switch (#717) --- .../ovl_Bg_F40_Switch/z_bg_f40_switch.c | 54 +++++++++---------- .../ovl_Bg_F40_Switch/z_bg_f40_switch.h | 4 +- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c index e44cb89d6..5278a4b73 100644 --- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c +++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c @@ -52,10 +52,10 @@ void BgF40Switch_CheckAll(BgF40Switch* this, GlobalContext* globalCtx) { u32 inCsMode = Player_InCsMode(&globalCtx->state); for (actor = globalCtx->actorCtx.actorLists[ACTORCAT_SWITCH].first; actor != NULL; actor = actor->next) { - if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->actor.actor.room && actor->update != NULL) { + if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->dyna.actor.room && actor->update != NULL) { actorAsSwitch = (BgF40Switch*)actor; actorAsSwitch->wasPressed = actorAsSwitch->isPressed; - isPressed = DynaPolyActor_IsInSwitchPressedState(&actorAsSwitch->actor); + isPressed = DynaPolyActor_IsInSwitchPressedState(&actorAsSwitch->dyna); if (actorAsSwitch->isPressed && actorAsSwitch->actionFunc == BgF40Switch_IdlePressed) { // Switch is fully pressed - if there's nothing keeping it pressed, wait a short time before // reverting to unpressed state. @@ -73,7 +73,7 @@ void BgF40Switch_CheckAll(BgF40Switch* this, GlobalContext* globalCtx) { actorAsSwitch->isPressed = isPressed; } if (actorAsSwitch->isPressed) { - switchFlag = BGF40SWITCH_GET_SWITCHFLAG(actorAsSwitch); + switchFlag = BGF40SWITCH_GET_SWITCHFLAG(&actorAsSwitch->dyna.actor); if (switchFlag >= 0 && switchFlag < 0x80) { pressedSwitchFlags[(switchFlag & ~0x1F) >> 5] |= 1 << (switchFlag & 0x1F); if (!actorAsSwitch->wasPressed && actorAsSwitch->actionFunc == BgF40Switch_IdleUnpressed && @@ -85,8 +85,8 @@ void BgF40Switch_CheckAll(BgF40Switch* this, GlobalContext* globalCtx) { } } for (actor = globalCtx->actorCtx.actorLists[ACTORCAT_SWITCH].first; actor != NULL; actor = actor->next) { - if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->actor.actor.room && actor->update != 0) { - switchFlag = BGF40SWITCH_GET_SWITCHFLAG((BgF40Switch*)actor); + if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->dyna.actor.room && actor->update != 0) { + switchFlag = BGF40SWITCH_GET_SWITCHFLAG(actor); if (switchFlag >= 0 && switchFlag < 0x80 && Flags_GetSwitch(globalCtx, switchFlag) && !(pressedSwitchFlags[(switchFlag & ~0x1F) >> 5] & (1 << (switchFlag & 0x1F)))) { Flags_UnsetSwitch(globalCtx, switchFlag); @@ -107,12 +107,12 @@ static InitChainEntry sInitChain[] = { void BgF40Switch_Init(Actor* thisx, GlobalContext* globalCtx) { BgF40Switch* this = THIS; - Actor_ProcessInitChain(&this->actor.actor, sInitChain); - this->actor.actor.scale.y = 0.165f; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.scale.y = 0.165f; this->actionFunc = BgF40Switch_IdleUnpressed; - this->actor.actor.world.pos.y = this->actor.actor.home.pos.y + 1.0f; - DynaPolyActor_Init(&this->actor, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->actor, &object_f40_switch_Colheader_000118); + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 1.0f; + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_f40_switch_Colheader_000118); if (!sBgF40SwitchGlobalsInitialized) { sBgF40SwitchLastUpdateFrame = globalCtx->gameplayFrames; sBgF40SwitchGlobalsInitialized = true; @@ -122,15 +122,15 @@ void BgF40Switch_Init(Actor* thisx, GlobalContext* globalCtx) { void BgF40Switch_Destroy(Actor* thisx, GlobalContext* globalCtx) { BgF40Switch* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->actor.bgId); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } void BgF40Switch_Unpress(BgF40Switch* this, GlobalContext* globalCtx) { - this->actor.actor.scale.y += 0.0495f; - if (this->actor.actor.scale.y >= 0.165f) { - Actor_PlaySfxAtPos(&this->actor.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); + this->dyna.actor.scale.y += 0.0495f; + if (this->dyna.actor.scale.y >= 0.165f) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); this->actionFunc = BgF40Switch_IdleUnpressed; - this->actor.actor.scale.y = 0.165f; + this->dyna.actor.scale.y = 0.165f; } } @@ -141,34 +141,34 @@ void BgF40Switch_IdlePressed(BgF40Switch* this, GlobalContext* globalCtx) { } void BgF40Switch_Press(BgF40Switch* this, GlobalContext* globalCtx) { - this->actor.actor.scale.y -= 0.0495f; - if (this->actor.actor.scale.y <= 0.0165f) { - Actor_PlaySfxAtPos(&this->actor.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); - func_8013ECE0(this->actor.actor.xyzDistToPlayerSq, 120, 20, 10); + this->dyna.actor.scale.y -= 0.0495f; + if (this->dyna.actor.scale.y <= 0.0165f) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_SWITCH); + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); if (this->isInitiator) { - ActorCutscene_Stop(this->actor.actor.cutscene); + ActorCutscene_Stop(this->dyna.actor.cutscene); this->isInitiator = false; } this->actionFunc = BgF40Switch_IdlePressed; - this->actor.actor.scale.y = 0.0165f; + this->dyna.actor.scale.y = 0.0165f; this->switchReleaseDelay = 6; } } void BgF40Switch_WaitToPress(BgF40Switch* this, GlobalContext* globalCtx) { - if (!this->isInitiator || this->actor.actor.cutscene == -1) { + if (!this->isInitiator || this->dyna.actor.cutscene == -1) { this->actionFunc = BgF40Switch_Press; if (this->isInitiator) { - Flags_SetSwitch(globalCtx, BGF40SWITCH_GET_SWITCHFLAG(this)); + Flags_SetSwitch(globalCtx, BGF40SWITCH_GET_SWITCHFLAG(&this->dyna.actor)); } - } else if (ActorCutscene_GetCanPlayNext(this->actor.actor.cutscene)) { - ActorCutscene_StartAndSetUnkLinkFields(this->actor.actor.cutscene, &this->actor.actor); + } else if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); this->actionFunc = BgF40Switch_Press; if (this->isInitiator) { - Flags_SetSwitch(globalCtx, BGF40SWITCH_GET_SWITCHFLAG(this)); + Flags_SetSwitch(globalCtx, BGF40SWITCH_GET_SWITCHFLAG(&this->dyna.actor)); } } else { - ActorCutscene_SetIntentToPlay(this->actor.actor.cutscene); + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); } } diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h index ec2b4dfec..8d4e64603 100644 --- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h +++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h @@ -5,12 +5,12 @@ struct BgF40Switch; -#define BGF40SWITCH_GET_SWITCHFLAG(this) (((this)->actor.actor.params & 0xFE00) >> 9) +#define BGF40SWITCH_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9) typedef void (*BgF40SwitchActionFunc)(struct BgF40Switch*, GlobalContext*); typedef struct BgF40Switch { - /* 0x0000 */ DynaPolyActor actor; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ s16 switchReleaseDelay; // frames until a pressed switch becomes released if nothing is still pressing it /* 0x015E */ s8 isPressed; // Logical state of the switch (pressed or unpressed). Animation state may lag behind this slightly. /* 0x015F */ s8 wasPressed; // used as temporary during update function From ad9e6e2ae5c2284b08ca186bb5b072333bf792ea Mon Sep 17 00:00:00 2001 From: Kristopher Early <1191258+MrPolymorph@users.noreply.github.com> Date: Sat, 26 Mar 2022 01:00:21 +0000 Subject: [PATCH 107/257] ovl_Obj_Yasi (#719) * parking * z_obj_yasi successfully decompiled and matched * removed commented code. * more cleanup.. * Code Styling changes. * Swapped to use BINANG_SUB macro. * Formatting. * addressing PR comments * formatting --- spec | 3 +- src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c | 71 ++++++++++++++++--- src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h | 5 +- undefined_syms.txt | 5 -- 4 files changed, 64 insertions(+), 20 deletions(-) diff --git a/spec b/spec index 338c82a3c..a0db205d9 100644 --- a/spec +++ b/spec @@ -4504,8 +4504,7 @@ beginseg name "ovl_Obj_Yasi" compress include "build/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.o" - include "build/data/ovl_Obj_Yasi/ovl_Obj_Yasi.data.o" - include "build/data/ovl_Obj_Yasi/ovl_Obj_Yasi.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Yasi/ovl_Obj_Yasi_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c index 5668371fb..3ed787918 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c @@ -5,17 +5,19 @@ */ #include "z_obj_yasi.h" +#include "objects/object_obj_yasi/object_obj_yasi.h" #define FLAGS 0x00000000 #define THIS ((ObjYasi*)thisx) +#define CAN_DROP_NUT(thisx) (thisx->params < 0) + void ObjYasi_Init(Actor* thisx, GlobalContext* globalCtx); void ObjYasi_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjYasi_Update(Actor* thisx, GlobalContext* globalCtx); void ObjYasi_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Yasi_InitVars = { ACTOR_OBJ_YASI, ACTORCAT_PROP, @@ -28,25 +30,72 @@ const ActorInit Obj_Yasi_InitVars = { (ActorFunc)ObjYasi_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BB4D90[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), }; -#endif +void ObjYasi_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjYasi* this = THIS; -extern InitChainEntry D_80BB4D90[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_obj_yasi_Colheader_001428); -extern UNK_TYPE D_06000360; -extern UNK_TYPE D_06001428; + this->dyna.actor.home.rot.y = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Yasi/ObjYasi_Init.s") + if (OBJYASI_IS_WIDE(thisx)) { + this->dyna.actor.scale.x = 0.2f; + this->dyna.actor.scale.z = 0.2f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Yasi/ObjYasi_Destroy.s") +void ObjYasi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjYasi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Yasi/ObjYasi_Update.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Yasi/ObjYasi_Draw.s") +void ObjYasi_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjYasi* this = THIS; + s16 temp; + Vec3f dropPos; + + if (this->dyna.actor.home.rot.z != 0) { + if (CAN_DROP_NUT(thisx)) { + if (Rand_ZeroOne() < 0.5f) { + dropPos.x = this->dyna.actor.world.pos.x; + dropPos.y = this->dyna.actor.world.pos.y + 280.0f; + dropPos.z = this->dyna.actor.world.pos.z; + Item_DropCollectible(globalCtx, &dropPos, ITEM00_NUTS_1); + } + } + this->dyna.actor.home.rot.y = GET_PLAYER(globalCtx)->actor.shape.rot.y; + this->dyna.actor.home.rot.x = 400; + this->dyna.actor.home.rot.z = 0; + } + temp = (s16)(this->dyna.actor.shape.rot.x * 0.1f); + this->dyna.actor.home.rot.x -= temp; + this->dyna.actor.shape.rot.x += + BINANG_SUB(this->dyna.actor.home.rot.x, (s16)(this->dyna.actor.shape.rot.x * 0.08f)); +} + +void ObjYasi_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjYasi* this = THIS; + + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + + if (this->dyna.actor.shape.rot.x != 0) { + Matrix_RotateY(this->dyna.actor.home.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateY(BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.home.rot.y), MTXMODE_APPLY); + } else { + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + } + + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Gfx_DrawDListOpa(globalCtx, object_obj_yasi_DL_000360); +} diff --git a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h index 3671a776c..f4ab9ca9c 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h @@ -6,10 +6,11 @@ struct ObjYasi; typedef struct ObjYasi { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x18]; + /* 0x000 */ DynaPolyActor dyna; } ObjYasi; // size = 0x15C extern const ActorInit Obj_Yasi_InitVars; +#define OBJYASI_IS_WIDE(thisx) ((thisx)->params & 1) + #endif // Z_OBJ_YASI_H diff --git a/undefined_syms.txt b/undefined_syms.txt index ba44de7b0..6545df94c 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1965,11 +1965,6 @@ D_06000F80 = 0x06000F80; D_06001680 = 0x06001680; D_060019B0 = 0x060019B0; -// ovl_Obj_Yasi - -D_06000360 = 0x06000360; -D_06001428 = 0x06001428; - // ovl_player_actor D_06008860 = 0x06008860; From 863d6b93782b8c6910fe71114af019c64ef84208 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Fri, 25 Mar 2022 18:05:38 -0700 Subject: [PATCH 108/257] Document object_dog (#720) --- assets/xml/objects/object_dog.xml | 110 ++++++++++-------- src/overlays/actors/ovl_En_Dg/z_en_dg.c | 30 ++--- src/overlays/actors/ovl_En_Dg/z_en_dg.h | 5 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 17 +-- .../actors/ovl_En_Racedog/z_en_racedog.c | 36 +++--- .../actors/ovl_En_Racedog/z_en_racedog.h | 5 +- 6 files changed, 99 insertions(+), 104 deletions(-) diff --git a/assets/xml/objects/object_dog.xml b/assets/xml/objects/object_dog.xml index f14a3d55e..89eba9c96 100644 --- a/assets/xml/objects/object_dog.xml +++ b/assets/xml/objects/object_dog.xml @@ -1,53 +1,65 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index 0648ca4ad..da8b51cbc 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -5,7 +5,6 @@ */ #include "z_en_dg.h" -#include "objects/object_dog/object_dog.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_800000) @@ -130,22 +129,14 @@ static DamageTable sDamageTable = { }; static AnimationInfoS sAnimations[] = { - { &object_dog_Anim_0021C8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dog_Anim_0021C8, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, - { &object_dog_Anim_001BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dog_Anim_000998, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, - { &object_dog_Anim_001FB0, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_001FB0, 1.0f, 0, -1, ANIMMODE_LOOP_PARTIAL, -6 }, - { &object_dog_Anim_001048, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_001348, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, - { &object_dog_Anim_001048, 1.0f, 0, 27, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_001048, 1.0f, 28, -1, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_001048, 1.0f, 54, 54, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_0021C8, -1.5f, -1, 0, ANIMMODE_LOOP, -6 }, - { &object_dog_Anim_001560, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dog_Anim_001A84, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dog_Anim_0017C0, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dog_Anim_0021C8, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogBarkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_LOOP_PARTIAL, -6 }, + { &gDogLyingDownAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, { &gDogLyingDownLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogLyingDownAnim, 1.0f, 0, 27, ANIMMODE_ONCE, -6 }, { &gDogLyingDownAnim, 1.0f, 28, -1, ANIMMODE_ONCE, -6 }, + { &gDogLyingDownAnim, 1.0f, 54, 54, ANIMMODE_ONCE, -6 }, { &gDogWalkAnim, -1.5f, -1, 0, ANIMMODE_LOOP, -6 }, + { &gDogJumpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogLongJumpAnim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDogJump2Anim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogWalkAnim, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, }; static InitChainEntry sInitChain[] = { @@ -1117,8 +1108,7 @@ void EnDg_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dog_Skel_0080F0, NULL, this->jointTable, this->morphTable, - 13); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDogSkel, NULL, this->jointTable, this->morphTable, DOG_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -1184,7 +1174,7 @@ void EnDg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnDg* this = THIS; Vec3f sp20 = { 0.0f, 20.0f, 0.0f }; - if (limbIndex == 5) { + if (limbIndex == DOG_LIMB_HEAD) { if (this->actionFunc == func_8098BBEC) { sp20.x = 5000.0f; Matrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.h b/src/overlays/actors/ovl_En_Dg/z_en_dg.h index cfb474b18..09732ba81 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.h +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.h @@ -2,6 +2,7 @@ #define Z_EN_DG_H #include "global.h" +#include "objects/object_dog/object_dog.h" struct EnDg; @@ -18,8 +19,8 @@ typedef struct EnDg { /* 0x190 */ ColliderCylinder collider; /* 0x1DC */ Path* unk_1DC; /* 0x1E0 */ s32 unk_1E0; - /* 0x1E4 */ Vec3s jointTable[13]; - /* 0x232 */ Vec3s morphTable[13]; + /* 0x1E4 */ Vec3s jointTable[DOG_LIMB_MAX]; + /* 0x232 */ Vec3s morphTable[DOG_LIMB_MAX]; /* 0x280 */ u16 unk_280; /* 0x282 */ s16 unk_282; /* 0x284 */ s16 unk_284; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 667f66a51..7259f258e 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -3533,7 +3533,7 @@ void func_80B4B3DC(EnInvadepoh* this) { } void func_80B4B430(EnInvadepoh* this) { - Animation_MorphToLoop(&this->skelAnime, &object_dog_Anim_0021C8, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &gDogWalkAnim, -6.0f); this->actionTimer = Rand_S16Offset(50, 80); this->actionFunc = func_80B4B484; } @@ -3556,7 +3556,7 @@ void func_80B4B484(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4B510(EnInvadepoh* this) { - Animation_MorphToLoop(&this->skelAnime, &object_dog_Anim_001BD8, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &gDogRunAnim, -6.0f); this->actionTimer = Rand_S16Offset(50, 200); this->actionFunc = func_80B4B564; } @@ -3600,7 +3600,7 @@ void func_80B4B564(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4B724(EnInvadepoh* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dog_Anim_000998, -6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDogBarkAnim, -6.0f); this->actionFunc = func_80B4B768; } @@ -3620,7 +3620,7 @@ void func_80B4B768(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4B820(EnInvadepoh* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dog_Anim_001560, -6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDogJumpAnim, -6.0f); this->actionFunc = func_80B4B864; } @@ -3639,8 +3639,8 @@ void func_80B4B8BC(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; Actor_SetObjectDependency(globalCtx, &this->actor); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dog_Skel_0080F0, &object_dog_Anim_0021C8, - this->jointTable, this->morphTable, 13); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDogSkel, &gDogWalkAnim, this->jointTable, this->morphTable, + DOG_LIMB_MAX); func_80B45C04(&this->behaviorInfo, 0, 0, 0, 0, &gZeroVec3s, 3000, 0.1f, 0.0f, 0.0f); func_80B44664(this, globalCtx); EnInvadepoh_SetPathPointToWorldPos(this, 0); @@ -4552,7 +4552,8 @@ void func_80B4E3F0(Actor* thisx, GlobalContext* globalCtx) { } s32 func_80B4E5B0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { - if ((limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7)) { + if ((limbIndex == DOG_LIMB_HEAD) || (limbIndex == DOG_LIMB_RIGHT_FACE_HAIR) || + (limbIndex == DOG_LIMB_LEFT_FACE_HAIR)) { EnInvadepoh* this = THIS; rot->x += this->behaviorInfo.unk20.x; @@ -4566,7 +4567,7 @@ s32 func_80B4E5B0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p void func_80B4E61C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnInvadepoh* this = THIS; - if (limbIndex == 5) { + if (limbIndex == DOG_LIMB_HEAD) { Matrix_GetStateTranslationAndScaledY(20.0f, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index b490d8d1d..8400dbfda 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -9,7 +9,6 @@ */ #include "z_en_racedog.h" -#include "objects/object_dog/object_dog.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) @@ -142,22 +141,14 @@ static DamageTable sDamageTable = { }; static AnimationInfoS D_80B25EF0[] = { - { &object_dog_Anim_0021C8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dog_Anim_0021C8, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, - { &object_dog_Anim_001BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dog_Anim_000998, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, - { &object_dog_Anim_001FB0, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_001FB0, 1.0f, 0, -1, ANIMMODE_LOOP_PARTIAL, -6 }, - { &object_dog_Anim_001048, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_001348, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, - { &object_dog_Anim_001048, 1.0f, 0, 27, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_001048, 1.0f, 28, -1, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_001048, 1.0f, 54, 54, ANIMMODE_ONCE, -6 }, - { &object_dog_Anim_0021C8, -1.5f, -1, 0, ANIMMODE_LOOP, -6 }, - { &object_dog_Anim_001560, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dog_Anim_001A84, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dog_Anim_0017C0, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dog_Anim_0021C8, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogBarkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_LOOP_PARTIAL, -6 }, + { &gDogLyingDownAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, { &gDogLyingDownLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogLyingDownAnim, 1.0f, 0, 27, ANIMMODE_ONCE, -6 }, { &gDogLyingDownAnim, 1.0f, 28, -1, ANIMMODE_ONCE, -6 }, + { &gDogLyingDownAnim, 1.0f, 54, 54, ANIMMODE_ONCE, -6 }, { &gDogWalkAnim, -1.5f, -1, 0, ANIMMODE_LOOP, -6 }, + { &gDogJumpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogLongJumpAnim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDogJump2Anim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogWalkAnim, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, }; static InitChainEntry sInitChain[] = { @@ -228,8 +219,7 @@ void EnRacedog_Init(Actor* thisx, GlobalContext* globalCtx) { ColliderCylinder* collider = &this->collider; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dog_Skel_0080F0, NULL, this->jointTable, this->morphTable, - 13); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDogSkel, NULL, this->jointTable, this->morphTable, DOG_LIMB_MAX); Collider_InitCylinder(globalCtx, collider); Collider_SetCylinder(globalCtx, collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -601,8 +591,8 @@ void func_80B258D8(EnRacedog* this, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_OPA_DISP++, 255, this->unk_2C0, 0, 255); Matrix_Scale(this->unk_2C4 * 2.0f, this->unk_2C4 * 2.0f, this->unk_2C4 * 2.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_dog_DL_000618); - gSPDisplayList(POLY_OPA_DISP++, object_dog_DL_000550); + gSPDisplayList(POLY_OPA_DISP++, gDogSelectionArrowEmptyDL); + gSPDisplayList(POLY_OPA_DISP++, gDogSelectionArrowDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -618,11 +608,11 @@ void EnRacedog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList EnRacedog* this = THIS; Vec3f sp1C = { 0.0f, 20.0f, 0.0f }; - if (limbIndex == 5) { + if (limbIndex == DOG_LIMB_HEAD) { Matrix_MultiplyVector3fByState(&sp1C, &this->actor.focus.pos); } - if (limbIndex == 12) { + if (limbIndex == DOG_LIMB_TAIL) { func_80B258D8(this, globalCtx); } } diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h index 2f9f9b06b..19f7af7a5 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h @@ -2,6 +2,7 @@ #define Z_EN_RACEDOG_H #include "global.h" +#include "objects/object_dog/object_dog.h" #define ENRACEDOG_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) #define ENRACEDOG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 10) @@ -20,8 +21,8 @@ typedef struct EnRacedog { /* 0x1E0 */ Path* unk_1E0; /* 0x1E4 */ UNK_TYPE1 unk_1E4[0x4]; /* 0x1E8 */ s32 unk_1E8; - /* 0x1EC */ Vec3s jointTable[13]; - /* 0x23A */ Vec3s morphTable[13]; + /* 0x1EC */ Vec3s jointTable[DOG_LIMB_MAX]; + /* 0x23A */ Vec3s morphTable[DOG_LIMB_MAX]; /* 0x288 */ s16 unk_288; /* 0x28A */ s16 unk_28A; /* 0x28C */ s16 unk_28C; From 10995051e00fd547f41c4d47f3263fe614db8310 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 26 Mar 2022 01:19:14 +0000 Subject: [PATCH 109/257] En_Tanron5 (#653) * En_Tanron5 * Stuff * PR * Fix * Use x/z instead of x/y * BSS * Merge * bss --- include/z64math.h | 7 +- spec | 3 +- .../ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c | 2 +- .../actors/ovl_En_Fishing/z_en_fishing.c | 1 + .../actors/ovl_En_Racedog/z_en_racedog.c | 8 +- .../actors/ovl_En_Rail_Skb/z_en_rail_skb.c | 10 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 10 +- .../actors/ovl_En_Tanron5/z_en_tanron5.c | 502 +++++++++++++++++- .../actors/ovl_En_Tanron5/z_en_tanron5.h | 17 +- src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c | 2 +- .../actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c | 2 +- .../ovl_Obj_Skateblock/z_obj_skateblock.c | 4 +- undefined_syms.txt | 6 - 13 files changed, 528 insertions(+), 46 deletions(-) diff --git a/include/z64math.h b/include/z64math.h index dff669976..de0285e6c 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -5,9 +5,14 @@ #define VEC_SET(V,X,Y,Z) V.x=X;V.y=Y;V.z=Z +typedef struct { + /* 0x00 */ s16 x; + /* 0x02 */ s16 z; +} Vec2s; // size = 0x04 + typedef struct { /* 0x00 */ f32 x; - /* 0x04 */ f32 y; + /* 0x04 */ f32 z; } Vec2f; // size = 0x08 typedef struct { diff --git a/spec b/spec index a0db205d9..7cac618d5 100644 --- a/spec +++ b/spec @@ -4833,8 +4833,7 @@ beginseg name "ovl_En_Tanron5" compress include "build/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.o" - include "build/data/ovl_En_Tanron5/ovl_En_Tanron5.data.o" - include "build/data/ovl_En_Tanron5/ovl_En_Tanron5.reloc.o" + include "build/src/overlays/actors/ovl_En_Tanron5/ovl_En_Tanron5_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c index 4a49be53c..7e05d6977 100644 --- a/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c +++ b/src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c @@ -56,7 +56,7 @@ s32 func_80C0A740(BgIkninSusceil* this, GlobalContext* globalCtx) { Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); - return (D_80C0B0E8.x < offset.z) && (offset.z < D_80C0B0E8.y) && (offset.x > -240.0f) && (offset.x < D_80C0B0E4); + return (D_80C0B0E8.x < offset.z) && (offset.z < D_80C0B0E8.z) && (offset.x > -240.0f) && (offset.x < D_80C0B0E4); } void func_80C0A804(BgIkninSusceil* this, GlobalContext* globalCtx) { 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 adde200f9..136f109f5 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -4,6 +4,7 @@ * Description: Fishing Pond Elements (Owner, Fish, Props, Effects...) */ +#include "prevent_bss_reordering.h" #include "z_en_fishing.h" #include "objects/object_fish/object_fish.h" #include "overlays/actors/ovl_En_Kanban/z_en_kanban.h" diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index 8400dbfda..ce1952314 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -471,13 +471,13 @@ s32 func_80B25490(EnRacedog* this, Vec2f* arg1) { f32 temp; xDistToTopFront = this->actor.world.pos.x - arg1[0].x; - zDistToTopFront = this->actor.world.pos.z - arg1[0].y; + zDistToTopFront = this->actor.world.pos.z - arg1[0].z; xDistToBottomFront = this->actor.world.pos.x - arg1[1].x; - zDistToBottomFront = this->actor.world.pos.z - arg1[1].y; + zDistToBottomFront = this->actor.world.pos.z - arg1[1].z; xDistToBottomBack = this->actor.world.pos.x - arg1[2].x; - zDistToBottomBack = this->actor.world.pos.z - arg1[2].y; + zDistToBottomBack = this->actor.world.pos.z - arg1[2].z; xDistToTopBack = this->actor.world.pos.x - arg1[3].x; - zDistToTopBack = this->actor.world.pos.z - arg1[3].y; + zDistToTopBack = this->actor.world.pos.z - arg1[3].z; temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); temp = (((xDistToBottomFront * zDistToBottomBack) - (xDistToBottomBack * zDistToBottomFront))); diff --git a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c index 3b000eb13..1bb913ebd 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c @@ -194,7 +194,7 @@ void func_80B708C0(EnRailSkb* this, GlobalContext* globalCtx) { s32 func_80B70AB4(Vec2f arg0, Vec2f arg1) { s32 phi_v1; - if ((arg1.x * arg0.y) < (arg0.x * arg1.y)) { + if ((arg1.x * arg0.z) < (arg0.x * arg1.z)) { phi_v1 = 1; } else { phi_v1 = -1; @@ -213,9 +213,9 @@ s32 func_80B70B04(EnRailSkb* this, Vec3f pos) { s32 j; sp60.x = this->unk_230[0].z - pos.z; - sp60.y = this->unk_230[0].x - pos.x; + sp60.z = this->unk_230[0].x - pos.x; sp58.x = this->unk_230[1].z - pos.z; - sp58.y = this->unk_230[1].x - pos.x; + sp58.z = this->unk_230[1].x - pos.x; j = 1; temp_s3 = func_80B70AB4(sp60, sp58); @@ -229,9 +229,9 @@ s32 func_80B70B04(EnRailSkb* this, Vec3f pos) { } sp60.x = this->unk_230[i].z - pos.z; - sp60.y = this->unk_230[i].x - pos.x; + sp60.z = this->unk_230[i].x - pos.x; sp58.x = this->unk_230[j].z - pos.z; - sp58.y = this->unk_230[j].x - pos.x; + sp58.z = this->unk_230[j].x - pos.x; if (func_80B70AB4(sp60, sp58) != temp_s3) { ret = false; diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index 0cac62a0d..5a891cb64 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -817,7 +817,7 @@ void func_809964DC(EnSkb* this, GlobalContext* globalCtx) { s32 func_80996544(Vec2f arg0, Vec2f arg1) { s32 ret; - if ((arg1.x * arg0.y) < (arg0.x * arg1.y)) { + if ((arg1.x * arg0.z) < (arg0.x * arg1.z)) { ret = 1; } else { ret = -1; @@ -840,9 +840,9 @@ s32 func_80996594(EnSkb* this, GlobalContext* globalCtx) { worldX = this->actor.world.pos.x; sp60.x = D_80997468[0].z - worldZ; - sp60.y = D_80997468[0].x - worldX; + sp60.z = D_80997468[0].x - worldX; sp58.x = D_80997468[1].z - worldZ; - sp58.y = D_80997468[1].x - worldX; + sp58.z = D_80997468[1].x - worldX; j = 1; temp_s2 = func_80996544(sp60, sp58); @@ -856,9 +856,9 @@ s32 func_80996594(EnSkb* this, GlobalContext* globalCtx) { j = 0; } sp60.x = D_80997468[i].z - worldZ; - sp60.y = D_80997468[i].x - worldX; + sp60.z = D_80997468[i].x - worldX; sp58.x = D_80997468[j].z - worldZ; - sp58.y = D_80997468[j].x - worldX; + sp58.z = D_80997468[j].x - worldX; if (func_80996544(sp60, sp58) != temp_s2) { sp54 = false; break; diff --git a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c index 36f507327..d5600e0e1 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c @@ -5,6 +5,9 @@ */ #include "z_en_tanron5.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_boss02/object_boss02.h" +#include "overlays/actors/ovl_Boss_02/z_boss_02.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +18,11 @@ void EnTanron5_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx); void EnTanron5_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80BE5818(Actor* thisx, GlobalContext* globalCtx); +void func_80BE5C10(Actor* thisx, GlobalContext* globalCtx); + +s32 D_80BE5D80 = 0; + const ActorInit En_Tanron5_InitVars = { ACTOR_EN_TANRON5, ACTORCAT_BOSS, @@ -28,32 +35,493 @@ const ActorInit En_Tanron5_InitVars = { (ActorFunc)EnTanron5_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BE5DA4 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ALL, AC_ON | AC_TYPE_PLAYER | AC_TYPE_ENEMY | AC_TYPE_OTHER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ALL, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_ENEMY | AC_TYPE_OTHER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 70, 450, 0, { 0, 0, 0 } }, }; -#endif +f32 D_80BE5DD0 = 1.0f; -extern ColliderCylinderInit D_80BE5DA4; +Vec2s D_80BE5DD4[] = { + { 0x4B0, 0x9C4 }, { -0x4B0, 0x9C4 }, { 0x4B0, -0x9C4 }, { -0x4B0, -0x9C4 }, { 0x9C4, 0x4B0 }, + { -0x9C4, 0x4B0 }, { 0x9C4, -0x4B0 }, { -0x9C4, -0x4B0 }, { 0x3E8, 0x3E8 }, { -0x3E8, 0x3E8 }, + { 0x3E8, -0x3E8 }, { -0x3E8, -0x3E8 }, { 0x000, -0x3E8 }, { 0x000, 0x3E8 }, { 0x3E8, 0x000 }, + { -0x3E8, 0x000 }, { 0x000, -0x7D0 }, { 0x000, 0x7D0 }, { 0x7D0, 0x000 }, { -0x7D0, 0x000 }, +}; -extern UNK_TYPE D_06007A88; -extern UNK_TYPE D_06007D18; +Gfx* D_80BE5E24[] = { + object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, + object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, + object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, + object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, + object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/func_80BE4930.s") +f32 D_80BE5E74[] = { + 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, + 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/func_80BE4A2C.s") +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ u8 unk_24; + /* 0x26 */ s16 unk_26; + /* 0x28 */ UNK_TYPE1 unk28[0x4]; + /* 0x2C */ s16 unk_2C; + /* 0x2E */ UNK_TYPE1 unk2E[0x6]; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; +} EnTanron5Effect; // size = 0x3C -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/EnTanron5_Init.s") +void func_80BE4930(EnTanron5Effect* effect, Vec3f* arg1, f32 arg2) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/EnTanron5_Destroy.s") + for (i = 0; i < 150; i++, effect++) { + if (effect->unk_24 == 0) { + effect->unk_24 = 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/EnTanron5_Update.s") + effect->unk_00 = *arg1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/func_80BE5818.s") + effect->unk_0C = randPlusMinusPoint5Scaled(10.0f); + effect->unk_10 = Rand_ZeroFloat(2.0f) + 3.0f; + effect->unk_14 = randPlusMinusPoint5Scaled(10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/EnTanron5_Draw.s") + effect->unk_18.y = -0.15f; + effect->unk_18.x = 0.0f; + effect->unk_18.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/func_80BE5C10.s") + effect->unk_2C = Rand_ZeroFloat(100.0f) + 200.0f; + effect->unk_26 = 0; + effect->unk_34 = arg2; + effect->unk_38 = 2.0f * arg2; + break; + } + } +} + +void func_80BE4A2C(EnTanron5Effect* effect, Vec3f* arg1, f32 arg2) { + s16 i; + + for (i = 0; i < 150; i++, effect++) { + if (effect->unk_24 == 0) { + effect->unk_24 = 2; + + effect->unk_00 = *arg1; + + effect->unk_0C = randPlusMinusPoint5Scaled(30.0f); + effect->unk_10 = Rand_ZeroFloat(7.0f); + effect->unk_14 = randPlusMinusPoint5Scaled(30.0f); + + effect->unk_18.y = -0.3f; + effect->unk_18.x = 0.0f; + effect->unk_18.z = 0.0f; + + effect->unk_2C = Rand_ZeroFloat(70.0f) + 150.0f; + effect->unk_26 = 0; + effect->unk_34 = arg2; + effect->unk_38 = 2.0f * arg2; + break; + } + } +} + +void EnTanron5_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTanron5* this = THIS; + + if (ENTANRON5_GET(&this->actor) >= ENTANRON5_100) { + D_80BE5D80++; + if (D_80BE5D80 > 60) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->unk_198 = randPlusMinusPoint5Scaled(0x2000); + this->unk_19A = randPlusMinusPoint5Scaled(0x2000); + + if (ENTANRON5_GET(&this->actor) < ENTANRON5_107) { + Actor_SetScale(&this->actor, (Rand_ZeroFloat(0.025f) + 0.085f) * D_80BE5DD0); + } else { + Actor_SetScale(&this->actor, (Rand_ZeroFloat(0.015f) + 0.01f) * D_80BE5DD0); + } + + this->actor.speedXZ = (Rand_ZeroFloat(10.0f) + 10.0f) * D_80BE5DD0; + this->actor.velocity.y = (Rand_ZeroFloat(10.0f) + 15.0f) * D_80BE5DD0; + this->actor.gravity = -2.5f * D_80BE5DD0; + this->actor.terminalVelocity = -1000.0f * D_80BE5DD0; + this->actor.update = func_80BE5818; + + if (ENTANRON5_GET(&this->actor) >= ENTANRON5_110) { + this->actor.draw = func_80BE5C10; + this->unk_1A0 = Rand_ZeroFloat(1.999f); + Actor_SetScale(&this->actor, D_80BE5DD0 * 0.03f); + this->unk_144 = 250; + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; + } else { + this->unk_148 = object_boss02_DL_007A88; + this->unk_144 = 150; + } + } else if (ENTANRON5_GET(&this->actor) == ENTANRON5_0) { + EnTanron5* child; + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_80BE5E74); i++) { + child = + (EnTanron5*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TANRON5, D_80BE5DD4[i].x, + this->actor.world.pos.y, D_80BE5DD4[i].z, 0, Rand_ZeroFloat(0x10000), 0, i + 1); + + child->actor.parent = this->actor.parent; + child->unk_19C = D_80BE5E74[i]; + + Actor_SetScale(&child->actor, child->unk_19C); + + child->unk_148 = D_80BE5E24[i]; + if (child->unk_148 == object_boss02_DL_006FD0) { + child->actor.shape.rot.y = 0; + } + + Collider_InitAndSetCylinder(globalCtx, &child->collider, &child->actor, &sCylinderInit); + } + + Actor_MarkForDeath(&this->actor); + } else { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 150.0f, 100.0f, 4); + this->actor.world.pos.y = this->actor.floorHeight + -20.0f; + } +} + +void EnTanron5_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTanron5* this = THIS; + + if (ENTANRON5_GET(&this->actor) >= ENTANRON5_100) { + D_80BE5D80--; + } +} + +void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTanron5* this = THIS; + Boss02* boss02 = (Boss02*)this->actor.parent; + Player* player = GET_PLAYER(globalCtx2); + s32 i; + s32 phi_v0; + s32 spC4; + Vec3f spB8; + + if (this->unk_1A0 >= 3) { + this->unk_1A0++; + Actor_SetScale(&this->actor, 0.0f); + if (this->unk_1A0 >= 40) { + Actor_MarkForDeath(&this->actor); + } + return; + } else { + // required + } + + if (this->unk_144 != 0) { + this->unk_144--; + } + + if (boss02->actor.update != NULL) { + D_80BE5DD0 = boss02->unk_01AC; + } else { + D_80BE5DD0 = 1.0f; + } + + Actor_SetScale(&this->actor, this->unk_19C * D_80BE5DD0); + + if (this->unk_148 == object_boss02_DL_007D18) { + this->collider.dim.radius = 65.0f * D_80BE5DD0; + this->collider.dim.height = 380.0f * D_80BE5DD0; + } else if (this->unk_1A0 == 0) { + this->collider.dim.radius = 85.0f * D_80BE5DD0; + this->collider.dim.height = 200.0f * D_80BE5DD0; + } else if (this->unk_1A0 == 1) { + this->collider.dim.radius = 95.0f * D_80BE5DD0; + this->collider.dim.height = 100.0f * D_80BE5DD0; + } else if (this->unk_1A0 == 2) { + this->collider.dim.radius = 95.0f * D_80BE5DD0; + this->collider.dim.height = 30.0f * D_80BE5DD0; + } + + if (this->unk_144 == 0) { + if (this->collider.base.acFlags & AC_HIT) { + ColliderInfo* acHitInfo = this->collider.info.acHitInfo; + Actor* ac = this->collider.base.ac; + + this->collider.base.acFlags &= ~AC_HIT; + spC4 = 10; + + if (func_801690CC(globalCtx)) { + this->unk_144 = 1; + } else { + this->unk_144 = 5; + spC4 = (s32)Rand_ZeroFloat(2.99f) + 10; + } + + if ((KREG(19) != 0) || ((acHitInfo->toucher.dmgFlags & 0x05000202) && (D_80BE5DD0 < 0.5f)) || + (ac->id == ACTOR_BOSS_02)) { + if (this->unk_148 == object_boss02_DL_007D18) { + Math_Vec3f_Copy(&spB8, &this->actor.world.pos); + spB8.y += D_80BE5DD0 * 300.0f; + + for (i = 3; i < spC4; i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TANRON5, spB8.x, spB8.y, spB8.z, + Rand_ZeroFloat(0x10000), Rand_ZeroFloat(0x10000), 0, i + 100); + } + + for (i = 0; i < 6; i++) { + func_80BE4A2C(globalCtx->specialEffects, &spB8, Rand_ZeroFloat(3.0f) + 6.0f); + } + + this->actor.world.pos.y -= D_80BE5DD0 * 130.0f; + } else { + f32 spAC; + f32 spA8; + Vec3f sp9C; + + if (this->unk_1A0 == 0) { + spAC = 180.0f; + this->unk_19C *= 1.4f; + } else if (this->unk_1A0 == 1) { + spAC = 230.0f; + this->unk_19C *= 1.37f; + } else if (this->unk_1A0 == 2) { + spAC = 780.0f; + this->unk_19C *= 1.5f; + } + + this->actor.world.pos.y -= D_80BE5DD0 * spAC; + Actor_SetScale(&this->actor, this->unk_19C * D_80BE5DD0); + Math_Vec3f_Copy(&spB8, &this->actor.world.pos); + + for (i = 0; i < spC4; i++) { + if (this->unk_1A0 == 0) { + spA8 = 100.0f; + spAC = 180.0f; + } else if (this->unk_1A0 == 1) { + spA8 = 200.0f; + spAC = 100.0f; + } else if (this->unk_1A0 == 2) { + spA8 = 250.0f; + spAC = 50.0f; + } + + sp9C.x = (randPlusMinusPoint5Scaled(spA8) * D_80BE5DD0) + spB8.x; + sp9C.z = (randPlusMinusPoint5Scaled(spA8) * D_80BE5DD0) + spB8.z; + sp9C.y = this->actor.floorHeight + (spAC * D_80BE5DD0); + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TANRON5, sp9C.x, sp9C.y, sp9C.z, + Rand_ZeroFloat(0x10000), Rand_ZeroFloat(0x10000), 0, i + 100); + + if (i < 8) { + func_80BE4A2C(globalCtx->specialEffects, &sp9C, Rand_ZeroFloat(3.0f) + 6.0f); + } + } + } + + if (Rand_ZeroOne() < 0.333f) { + phi_v0 = 0x4000; + } else if (Rand_ZeroOne() < 0.5f) { + phi_v0 = -0x8000; + } else { + phi_v0 = -0x4000; + } + + this->actor.shape.rot.y += phi_v0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BIG_BOMB_EXPLOSION); + func_800BC848(&this->actor, globalCtx, 4, 4); + this->unk_1A0++; + } else { + Vec3f sp90; + ColliderInfo* info = this->collider.info.acHitInfo; + + sp90.x = info->bumper.hitPos.x; + sp90.y = info->bumper.hitPos.y; + sp90.z = info->bumper.hitPos.z; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SHIELD_REFLECT_SW); + CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &sp90); + } + } + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + if (this->unk_148 == object_boss02_DL_006FD0) { + this->collider.dim.pos.y = this->actor.floorHeight; + } + + if ((this->unk_148 == object_boss02_DL_007D18) || (D_80BE5DD0 < 0.5f)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } else { + f32 xDiff = player->actor.world.pos.x - this->actor.world.pos.x; + f32 yDiff = player->actor.world.pos.z - this->actor.world.pos.z; + + if ((fabsf(xDiff) < 120.0f) && (fabsf(yDiff) < 120.0f)) { + if (fabsf(yDiff) < fabsf(xDiff)) { + if (xDiff > 0.0f) { + player->actor.prevPos.x = player->actor.world.pos.x = this->actor.world.pos.x + 120.0f; + } else { + player->actor.prevPos.x = player->actor.world.pos.x = this->actor.world.pos.x - 120.0f; + } + } else if (yDiff > 0.0f) { + player->actor.prevPos.z = player->actor.world.pos.z = this->actor.world.pos.z + 120.0f; + } else { + player->actor.prevPos.z = player->actor.world.pos.z = this->actor.world.pos.z - 120.0f; + } + } + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_80BE5818(Actor* thisx, GlobalContext* globalCtx2) { + f32 sp6C; + s32 i; + Vec3f sp5C; + EnTanron5* this = THIS; + GlobalContext* globalCtx = globalCtx2; + + if ((ENTANRON5_GET(&this->actor) < ENTANRON5_110) && (this->unk_1A0 != 0)) { + this->unk_1A0++; + this->actor.world.pos.y -= 2.0f * D_80BE5DD0; + if (this->unk_1A0 == 40) { + Actor_MarkForDeath(&this->actor); + } + return; + } + + if (DECR(this->unk_144) == 0) { + Actor_MarkForDeath(&this->actor); + } + + if (this->actor.speedXZ > 0.02f) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 150.0f, 100.0f, 4); + } + + if (ENTANRON5_GET(&this->actor) < ENTANRON5_110) { + this->actor.shape.rot.x += this->unk_198; + this->actor.shape.rot.y += this->unk_19A; + sp6C = 1225.0f; + + if (this->actor.bgCheckFlags & 1) { + if (ENTANRON5_GET(&this->actor) < ENTANRON5_108) { + Math_Vec3f_Copy(&sp5C, &this->actor.world.pos); + sp5C.y = this->actor.floorHeight; + + for (i = 0; i < 4; i++) { + func_80BE4930(globalCtx->specialEffects, &sp5C, Rand_ZeroFloat(1.0f) + 2.0f); + } + this->unk_1A0++; + } else { + Actor_MarkForDeath(&this->actor); + } + } + } else { + sp6C = 400.0f; + this->unk_198 += 0x2000; + if (this->actor.bgCheckFlags & 1) { + this->unk_198 = 0; + this->actor.speedXZ = 0.0f; + } + } + + if (this->unk_1A1 == 0) { + if ((D_80BE5DD0 > 0.5f) && + ((ENTANRON5_GET(&this->actor) < ENTANRON5_108) || (ENTANRON5_GET(&this->actor) >= ENTANRON5_110))) { + Player* player = GET_PLAYER(globalCtx); + Vec3f temp; + + temp.x = player->actor.world.pos.x - this->actor.world.pos.x; + temp.y = (player->actor.world.pos.y + 10.0f) - this->actor.world.pos.y; + temp.z = player->actor.world.pos.z - this->actor.world.pos.z; + + if (SQXYZ(temp) < sp6C) { + if (ENTANRON5_GET(&this->actor) >= ENTANRON5_110) { + if (this->unk_1A0 == 0) { + Item_Give(globalCtx, ITEM_ARROWS_10); + } else { + Item_Give(globalCtx, ITEM_MAGIC_LARGE); + } + Actor_MarkForDeath(&this->actor); + play_sound(NA_SE_SY_GET_ITEM); + } else { + this->unk_1A1 = 20; + func_800B8D50(globalCtx, NULL, 5.0f, this->actor.world.rot.y, 0.0f, 8); + } + } + } + } else { + this->unk_1A1--; + } +} + +void EnTanron5_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTanron5* this = THIS; + + if ((-500.0f * D_80BE5DD0) < this->actor.projectedPos.z) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->unk_148); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_80BE5C10(Actor* thisx, GlobalContext* globalCtx) { + EnTanron5* this = THIS; + TexturePtr texture; + s32 phi_v0; + + if ((this->unk_144 > 50) || (this->unk_144 & 1)) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if (((-500.0f * D_80BE5DD0) < this->actor.projectedPos.z) && phi_v0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + if (this->unk_1A0 == 0) { + texture = gameplay_keep_Tex_05BEF0; + } else { + texture = gameplay_keep_Tex_0617C0; + } + + POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(texture)); + + Matrix_InsertTranslation(0.0f, 200.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_198, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h index c19bb1ded..576309694 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h @@ -5,9 +5,24 @@ struct EnTanron5; +#define ENTANRON5_GET(thisx) ((thisx)->params) + +#define ENTANRON5_0 0 +#define ENTANRON5_100 100 +#define ENTANRON5_107 107 +#define ENTANRON5_108 108 +#define ENTANRON5_110 110 + typedef struct EnTanron5 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x60]; + /* 0x0144 */ s16 unk_144; + /* 0x0148 */ Gfx* unk_148; + /* 0x014C */ ColliderCylinder collider; + /* 0x0198 */ s16 unk_198; + /* 0x019A */ s16 unk_19A; + /* 0x019C */ f32 unk_19C; + /* 0x01A0 */ u8 unk_1A0; + /* 0x01A1 */ u8 unk_1A1; } EnTanron5; // size = 0x1A4 extern const ActorInit En_Tanron5_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c index cbb0fcd7a..30898db9f 100644 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c @@ -234,7 +234,7 @@ void func_809372D0(ObjBean* this) { sp34 = Math3D_Vec3fMagnitude(&actor->velocity); temp_f2 = D_80938FF8[this->unk_1DE].x; - temp_f12 = D_80938FF8[this->unk_1DE].y; + temp_f12 = D_80938FF8[this->unk_1DE].z; if (sp34 < (actor->speedXZ * 8.0f)) { temp_f2 = ((temp_f2 - 2.0f) * 0.1f) + 2.0f; temp_f12 *= 0.4f; diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c index 359d474f1..fa3b46cf7 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -332,7 +332,7 @@ s32 ObjOshihiki_CheckWall(GlobalContext* globalCtx, s16 angle, f32 direction, Ob maxDist = maxDists[D_80918940[i]]; faceVtxOffset.x = (sFaceVtx[i].x * this->dyna.actor.scale.x * 10.0f) + sFaceDirection[i].x; - faceVtxOffset.y = (sFaceVtx[i].y * this->dyna.actor.scale.y * 10.0f) + sFaceDirection[i].y; + faceVtxOffset.y = (sFaceVtx[i].z * this->dyna.actor.scale.y * 10.0f) + sFaceDirection[i].z; faceVtxOffset.z = 0.0f; ObjOshihiki_RotateXZ(&faceVtx, &faceVtxOffset, sn, cs); diff --git a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c index a953cd304..1253747e4 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c @@ -159,7 +159,7 @@ s32 func_80A21370(ObjSkateblock* this, GlobalContext* globalCtx) { floor->bgId = BG_ACTOR_MAX; sp8C.x = this->dyna.actor.world.pos.x + ((D_80A22A1C[i].x * this->dyna.actor.scale.x) + D_80A22A44[i].x); - sp8C.z = this->dyna.actor.world.pos.z + ((D_80A22A1C[i].y * this->dyna.actor.scale.z) + D_80A22A44[i].y); + sp8C.z = this->dyna.actor.world.pos.z + ((D_80A22A1C[i].z * this->dyna.actor.scale.z) + D_80A22A44[i].z); floor->height = BgCheck_EntityRaycastFloor6(&globalCtx->colCtx, &floor->poly, &floor->bgId, &this->dyna.actor, &sp8C, 0.0f); @@ -244,7 +244,7 @@ s32 func_80A216D4(ObjSkateblock* this, GlobalContext* globalCtx, f32 arg2, Vec3f for (i = 0; i < ARRAY_COUNT(D_80A22A6C); i++) { spBC.x = (D_80A22A6C[i].x * this->dyna.actor.scale.x) + D_80A22A94[i].x; - spBC.y = (D_80A22A6C[i].y * this->dyna.actor.scale.y) + D_80A22A94[i].y; + spBC.y = (D_80A22A6C[i].z * this->dyna.actor.scale.y) + D_80A22A94[i].z; spBC.z = 0.0f; func_80A212F0(&spD4, &spBC, sp96); diff --git a/undefined_syms.txt b/undefined_syms.txt index 6545df94c..d5d76dea2 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1719,12 +1719,6 @@ D_06004550 = 0x06004550; D_06000168 = 0x06000168; D_06000E68 = 0x06000E68; -// ovl_En_Tanron5 - -D_06006FD0 = 0x06006FD0; -D_06007A88 = 0x06007A88; -D_06007D18 = 0x06007D18; - // ovl_En_Test3 D_0600CB60 = 0x0600CB60; From ad6d31442216475521a683b4f7aca27d13f2fd78 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 26 Mar 2022 01:25:35 +0000 Subject: [PATCH 110/257] Obj_Kendo_Kanban (1 non-matching) (#687) * Obj_Kendo_Kanban * PR --- spec | 5 +- .../ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c | 448 ++++++++++++++++-- .../ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h | 27 +- undefined_syms.txt | 4 - 4 files changed, 441 insertions(+), 43 deletions(-) diff --git a/spec b/spec index 7cac618d5..aa6edda2e 100644 --- a/spec +++ b/spec @@ -4118,8 +4118,11 @@ beginseg name "ovl_Obj_Kendo_Kanban" compress include "build/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.o" - include "build/data/ovl_Obj_Kendo_Kanban/ovl_Obj_Kendo_Kanban.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Kendo_Kanban/ovl_Obj_Kendo_Kanban_reloc.o" +#else include "build/data/ovl_Obj_Kendo_Kanban/ovl_Obj_Kendo_Kanban.reloc.o" +#endif endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c index 82e4e4de2..6cf8e0751 100644 --- a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c +++ b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c @@ -5,6 +5,7 @@ */ #include "z_obj_kendo_kanban.h" +#include "objects/object_dora/object_dora.h" #define FLAGS 0x00000000 @@ -15,11 +16,14 @@ void ObjKendoKanban_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjKendoKanban_Update(Actor* thisx, GlobalContext* globalCtx); void ObjKendoKanban_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B65880(ObjKendoKanban* this); void func_80B65894(ObjKendoKanban* this, GlobalContext* globalCtx); +void func_80B658A4(ObjKendoKanban* this, GlobalContext* globalCtx); void func_80B65CE0(ObjKendoKanban* this, GlobalContext* globalCtx); void func_80B65D68(ObjKendoKanban* this, GlobalContext* globalCtx); +void func_80B65DA8(ObjKendoKanban* this, GlobalContext* globalCtx); +s32 func_80B6618C(ObjKendoKanban* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Kendo_Kanban_InitVars = { ACTOR_OBJ_KENDO_KANBAN, ACTORCAT_NPC, @@ -32,33 +36,89 @@ const ActorInit Obj_Kendo_Kanban_InitVars = { (ActorFunc)ObjKendoKanban_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_80B6673C[2] = { +Vec3f D_80B66660 = { -1.5f, 10.0f, 0.5f }; +Vec3f D_80B6666C = { 1.5f, 10.0f, 0.5f }; +Vec3f D_80B66678 = { 0.0f, 4.0f, -1.0f }; +Vec3f D_80B66684 = { 1.0f, 7.0f, 4.0f }; +Vec3f D_80B66690 = { -150.0f, 425.0f, 40.0f }; +Vec3f D_80B6669C = { 150.0f, 425.0f, 40.0f }; +Vec3f D_80B666A8 = { 0.0f, 140.0f, 40.0f }; +Vec3f D_80B666B4 = { 0.0f, 565.0f, 40.0f }; + +Gfx* D_80B666C0 = object_dora_DL_002080; +Gfx* D_80B666C4 = object_dora_DL_002180; +Gfx* D_80B666C8 = object_dora_DL_002380; +Gfx* D_80B666CC = object_dora_DL_002280; + +Vec3f D_80B666D0 = { -300.0f, 850.0f, 40.0f }; +Vec3f D_80B666DC = { 10.0f, 850.0f, 40.0f }; +Vec3f D_80B666E8 = { 300.0f, 850.0f, 40.0f }; +Vec3f D_80B666F4 = { -300.0f, 310.0f, 40.0f }; +Vec3f D_80B66700 = { 0.0f, 280.0f, 40.0f }; +Vec3f D_80B6670C = { 300.0f, 250.0f, 40.0f }; +Vec3f D_80B66718 = { -300.0f, 10.0f, 40.0f }; +Vec3f D_80B66724 = { 0.0f, 10.0f, 40.0f }; +Vec3f D_80B66730 = { 300.0f, 10.0f, 40.0f }; + +static ColliderTrisElementInit sTrisElementsInit[] = { { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x01000202, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x01000202, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -300.0f, 850.0f, 40.0f }, { -300.0f, 10.0f, 40.0f }, { 300.0f, 850.0f, 40.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x01000202, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x01000202, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 300.0f, 850.0f, 40.0f }, { 300.0f, 10.0f, 40.0f }, { -300.0f, 10.0f, 40.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B667B4 = { - { COLTYPE_TREE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_TRIS, }, - 2, D_80B6673C, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_TREE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_TRIS, + }, + 2, + sTrisElementsInit, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B667C4 = { - { COLTYPE_TREE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_TREE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 33, 80, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B667F0 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -93,41 +153,357 @@ static DamageTable D_80B667F0 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B66810 = { 8, 0, 0, 0, MASS_HEAVY }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; -#endif +Vec3f D_80B6681C = { 0.0f, 0.0f, 0.0f }; +Vec3f D_80B66828 = { 1.0f, 0.0f, 0.0f }; -extern ColliderTrisElementInit D_80B6673C[2]; -extern ColliderTrisInit D_80B667B4; -extern ColliderCylinderInit D_80B667C4; -extern DamageTable D_80B667F0; -extern CollisionCheckInfoInit2 D_80B66810; +void ObjKendoKanban_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + ObjKendoKanban* this = THIS; + Vec3f sp70[3]; + s32 i; + s32 j; -extern UNK_TYPE D_06000180; + Actor_SetScale(&this->actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Init.s") + Collider_InitCylinder(globalCtx, &this->colliderCylinder); + Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + Collider_InitTris(globalCtx, &this->colliderTris); + Collider_SetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTrisElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Destroy.s") + Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65880.s") + for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { + for (j = 0; j < ARRAY_COUNT(sp70); j++) { + Matrix_MultiplyVector3fByState(&sTrisElementsInit[i].dim.vtx[j], &sp70[j]); + } + Collider_SetTrisVertices(&this->colliderTris, i, &sp70[0], &sp70[1], &sp70[2]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65894.s") + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B658A4.s") + this->unk_30C = OBJKENDOKANBAN_GET_F(&this->actor); + this->actor.gravity = -2.0f; + this->unk_2CC = D_80B6681C; + this->unk_2D8 = D_80B6681C; + this->unk_2E4 = D_80B6681C; + this->unk_2F0 = D_80B66828; + this->unk_302 = 0; + this->unk_304 = 0; + this->unk_2FC = -1; + this->unk_300 = 0; + this->unk_308 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65CE0.s") + for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { + this->unk_26C[i] = this->unk_29C[i] = D_80B6681C; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65D54.s") + this->unk_30A = 0; + if (this->unk_30C == OBJKENDOKANBAN_F_0) { + func_80B65880(this); + } else { + func_80B658A4(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65D68.s") +void ObjKendoKanban_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjKendoKanban* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65DA8.s") + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroyTris(globalCtx, &this->colliderTris); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B6618C.s") +void func_80B65880(ObjKendoKanban* this) { + this->actionFunc = func_80B65894; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B66304.s") +void func_80B65894(ObjKendoKanban* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Update.s") +void func_80B658A4(ObjKendoKanban* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + if (this->unk_30C == OBJKENDOKANBAN_F_0) { + if ((player->swordAnimation == 0) || (player->swordAnimation == 1) || (player->swordAnimation == 0x14)) { + this->unk_30C = (OBJKENDOKANBAN_F_4 | OBJKENDOKANBAN_F_1); + this->unk_304 = 0x71C; + this->actor.velocity = D_80B6666C; + this->unk_2CC = D_80B6669C; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_KENDO_KANBAN, + this->actor.home.pos.x - 5.0f, this->actor.home.pos.y, this->actor.home.pos.z, 0, 0, 0, + 0xA); + + this->unk_29C[0] = D_80B666DC; + this->unk_29C[1] = D_80B666E8; + this->unk_29C[2] = D_80B66730; + this->unk_29C[3] = D_80B66724; + } else { + this->unk_30C = (OBJKENDOKANBAN_F_8 | OBJKENDOKANBAN_F_4); + this->unk_304 = -0x71C; + this->actor.velocity = D_80B66678; + this->unk_2CC = D_80B666A8; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_KENDO_KANBAN, + this->actor.home.pos.x, this->actor.home.pos.y + 5.0f, this->actor.home.pos.z, 0, 0, 0, + 3); + + this->unk_29C[0] = D_80B666F4; + this->unk_29C[1] = D_80B6670C; + this->unk_29C[2] = D_80B66730; + this->unk_29C[3] = D_80B66718; + } + } else if (this->unk_30C == (OBJKENDOKANBAN_F_8 | OBJKENDOKANBAN_F_2)) { + this->unk_304 = 0x71C; + this->actor.velocity = D_80B66660; + this->unk_2CC = D_80B66690; + + this->unk_29C[0] = D_80B666D0; + this->unk_29C[1] = D_80B666DC; + this->unk_29C[2] = D_80B66724; + this->unk_29C[3] = D_80B66718; + } else if (this->unk_30C == (OBJKENDOKANBAN_F_2 | OBJKENDOKANBAN_F_1)) { + this->unk_304 = 0x71C; + this->actor.velocity = D_80B66684; + this->unk_2CC = D_80B666B4; + + this->unk_29C[0] = D_80B666D0; + this->unk_29C[1] = D_80B666E8; + this->unk_29C[2] = D_80B6670C; + this->unk_29C[3] = D_80B666F4; + } + + this->unk_30A = 0; + this->actionFunc = func_80B65CE0; +} + +void func_80B65CE0(ObjKendoKanban* this, GlobalContext* globalCtx) { + this->actor.velocity.y += this->actor.gravity; + Actor_UpdatePos(&this->actor); + this->unk_302 += this->unk_304; + func_80B65DA8(this, globalCtx); + if (this->actor.world.pos.y < -200.0f) { + this->actor.world.pos.y = -200.0f; + } +} + +void func_80B65D54(ObjKendoKanban* this) { + this->actionFunc = func_80B65D68; +} + +void func_80B65D68(ObjKendoKanban* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (func_80B6618C(this, globalCtx) == 1) { + player->unk_AC0 = 700.0f; + } +} + +void func_80B65DA8(ObjKendoKanban* this, GlobalContext* globalCtx) { + Vec3f sp5C; + s32 pad[2]; + Vec3f sp48; + s32 pad2; + s32 index = 0; + s32 i; + f32 sp38; + + sp5C = this->unk_26C[0]; + sp48 = this->actor.world.pos; + + sp48.x -= this->unk_2D8.x; + sp48.y -= this->unk_2D8.y; + sp48.z -= this->unk_2D8.z; + + sp38 = (this->unk_2F0.x * sp48.z) + (this->unk_2F0.z * -sp48.x); + + if (sp38 < 0.0f) { + this->unk_304 += 0x64; + } else { + this->unk_304 -= 0x64; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { + if (this->unk_26C[i].y < sp5C.y) { + sp5C = this->unk_26C[i]; + index = i; + } + } + + if (index != this->unk_2FC) { + this->unk_300 = 1; + this->unk_2FC = index; + this->unk_2E4 = this->unk_29C[index]; + + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&this->unk_2E4, &this->actor.world.pos); + this->actor.world.pos = sp5C; + this->actor.prevPos = this->actor.world.pos; + Matrix_StatePop(); + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + if (this->actor.bgCheckFlags & 1) { + this->actor.velocity.x *= 0.8f; + this->actor.velocity.z *= 0.8f; + } + + if (this->unk_300 == 1) { + if (this->unk_308 >= 7) { + s16 temp_v0_3 = this->unk_302 & 0x3FFF; + + if (temp_v0_3 >= 0x2000) { + temp_v0_3 -= 0x4000; + } + this->unk_302 -= temp_v0_3; + this->unk_304 = 0; + func_80B65D54(this); + return; + } + + if (this->actor.bgCheckFlags & 2) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WOODPLATE_BOUND); + this->unk_300 = 0; + this->actor.velocity.y *= 0.5f; + } else if (this->actor.bgCheckFlags & 1) { + this->unk_308++; + this->unk_300 = 0; + this->actor.velocity.x *= 0.3f; + this->actor.velocity.z *= 0.3f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WOODPLATE_BOUND); + + if (sp38 > 0.0f) { + if (this->unk_304 > 0) { + this->unk_304 *= 1.2f; + } else { + this->unk_304 *= -0.6f; + } + } else if (this->unk_304 < 0) { + this->unk_304 *= 1.2f; + } else { + this->unk_304 *= -0.6f; + } + } + } +} + +s32 func_80B6618C(ObjKendoKanban* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 phi_v0; + s32 phi_v1 = 0; + s32 i; + f32 x; + f32 z; + f32 x2; + f32 z2; + + for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { + if (i != 3) { + phi_v0 = i + 1; + } else { + phi_v0 = 0; + } + + z = this->unk_26C[i].z - player->actor.world.pos.z; + x = this->unk_26C[i].x - player->actor.world.pos.x; + + z2 = (this->unk_26C[phi_v0].z - player->actor.world.pos.z); + x2 = (this->unk_26C[phi_v0].x - player->actor.world.pos.x); + + if ((x * z2) < (z * x2)) { + if (phi_v1 == 0) { + phi_v1 = 1; + } else if (phi_v1 != 1) { + return false; + } + } else if (phi_v1 == 0) { + phi_v1 = -1; + } else if (phi_v1 != -1) { + return false; + } + } + return true; +} + +void func_80B66304(ObjKendoKanban* this, GlobalContext* globalCtx) { + if ((this->actionFunc != func_80B65CE0) && (this->actionFunc != func_80B65D68)) { + if (this->colliderTris.base.acFlags & AC_HIT) { + this->colliderTris.base.acFlags &= ~AC_HIT; + func_80B658A4(this, globalCtx); + } + + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + this->colliderCylinder.dim.pos.z -= (s16)(20.0f * Math_CosS(this->actor.shape.rot.y)); + this->colliderCylinder.dim.pos.x -= (s16)(20.0f * Math_SinS(this->actor.shape.rot.y)); + + if (this->actionFunc == func_80B65894) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } +} + +void ObjKendoKanban_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjKendoKanban* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80B66304(this, globalCtx); +} + +#ifdef NON_MATCHING +void ObjKendoKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjKendoKanban* this = THIS; + s32 i; + Gfx* poly; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_30C == OBJKENDOKANBAN_F_0) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dora_DL_000180); + } else { + Matrix_InsertRotationAroundUnitVector_s(this->unk_302, &this->unk_2F0, MTXMODE_APPLY); + Matrix_InsertTranslation(-this->unk_2E4.x, -this->unk_2E4.y, -this->unk_2E4.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->unk_30C & OBJKENDOKANBAN_F_1) { + gSPDisplayList(POLY_OPA_DISP++, D_80B666C0); + } + + if (this->unk_30C & OBJKENDOKANBAN_F_2) { + gSPDisplayList(POLY_OPA_DISP++, D_80B666C4); + } + + if (this->unk_30C & OBJKENDOKANBAN_F_4) { + gSPDisplayList(POLY_OPA_DISP++, D_80B666C8); + } + + if (this->unk_30C & OBJKENDOKANBAN_F_8) { + gSPDisplayList(POLY_OPA_DISP++, D_80B666CC); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { + Matrix_MultiplyVector3fByState(&this->unk_29C[i], &this->unk_26C[i]); + } + + Matrix_MultiplyVector3fByState(&this->unk_2CC, &this->unk_2D8); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Draw.s") +#endif diff --git a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h index 6adb95dd1..a8c4f8d7c 100644 --- a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h +++ b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h @@ -7,11 +7,34 @@ struct ObjKendoKanban; typedef void (*ObjKendoKanbanActionFunc)(struct ObjKendoKanban*, GlobalContext*); +#define OBJKENDOKANBAN_GET_F(thisx) ((thisx)->params & 0xF) + +#define OBJKENDOKANBAN_F_0 0 +#define OBJKENDOKANBAN_F_1 (1 << 0) +#define OBJKENDOKANBAN_F_2 (1 << 1) +#define OBJKENDOKANBAN_F_4 (1 << 2) +#define OBJKENDOKANBAN_F_8 (1 << 3) + typedef struct ObjKendoKanban { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x124]; + /* 0x0144 */ ColliderCylinder colliderCylinder; + /* 0x0190 */ ColliderTris colliderTris; + /* 0x01B0 */ ColliderTrisElement colliderTrisElements[2]; /* 0x0268 */ ObjKendoKanbanActionFunc actionFunc; - /* 0x026C */ char unk_26C[0xA4]; + /* 0x026C */ Vec3f unk_26C[4]; + /* 0x029C */ Vec3f unk_29C[4]; + /* 0x02CC */ Vec3f unk_2CC; + /* 0x02D8 */ Vec3f unk_2D8; + /* 0x02E4 */ Vec3f unk_2E4; + /* 0x02F0 */ Vec3f unk_2F0; + /* 0x02FC */ s32 unk_2FC; + /* 0x0300 */ s16 unk_300; + /* 0x0302 */ s16 unk_302; + /* 0x0304 */ s16 unk_304; + /* 0x0306 */ UNK_TYPE1 pad306[2]; + /* 0x0308 */ s16 unk_308; + /* 0x030A */ s16 unk_30A; + /* 0x030C */ u8 unk_30C; } ObjKendoKanban; // size = 0x310 extern const ActorInit Obj_Kendo_Kanban_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index d5d76dea2..5e1f083d7 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1867,10 +1867,6 @@ D_06000110 = 0x06000110; D_060003A0 = 0x060003A0; -// ovl_Obj_Kendo_Kanban - -D_06000180 = 0x06000180; - // ovl_Obj_Lift D_06000D10 = 0x06000D10; From 844b5efb6f6bb9c75961d4174037dcd92121216e Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 26 Mar 2022 01:33:42 +0000 Subject: [PATCH 111/257] En_Sda (#691) * En_Sda * Format hello? * PR --- assets/xml/overlays/ovl_En_Sda.xml | 9 + spec | 4 +- src/overlays/actors/ovl_En_Sda/z_en_sda.c | 331 +++++++++++++++++++++- src/overlays/actors/ovl_En_Sda/z_en_sda.h | 2 + 4 files changed, 334 insertions(+), 12 deletions(-) create mode 100644 assets/xml/overlays/ovl_En_Sda.xml diff --git a/assets/xml/overlays/ovl_En_Sda.xml b/assets/xml/overlays/ovl_En_Sda.xml new file mode 100644 index 000000000..7e257ee20 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Sda.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/spec b/spec index aa6edda2e..c2cb6a451 100644 --- a/spec +++ b/spec @@ -1574,9 +1574,7 @@ beginseg name "ovl_En_Sda" compress include "build/src/overlays/actors/ovl_En_Sda/z_en_sda.o" - include "build/data/ovl_En_Sda/ovl_En_Sda.data.o" - include "build/data/ovl_En_Sda/ovl_En_Sda.bss.o" - include "build/data/ovl_En_Sda/ovl_En_Sda.reloc.o" + include "build/src/overlays/actors/ovl_En_Sda/ovl_En_Sda_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Sda/z_en_sda.c b/src/overlays/actors/ovl_En_Sda/z_en_sda.c index 3a355b361..0103b1d62 100644 --- a/src/overlays/actors/ovl_En_Sda/z_en_sda.c +++ b/src/overlays/actors/ovl_En_Sda/z_en_sda.c @@ -15,7 +15,11 @@ void EnSda_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSda_Update(Actor* thisx, GlobalContext* globalCtx); void EnSda_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, GlobalContext* globalCtx); +void func_80947668(u8* shadowTexture, Player* player, GlobalContext* globalCtx); + +Vec3f D_80947EA0[16]; + const ActorInit En_Sda_InitVars = { ACTOR_EN_SDA, ACTORCAT_BOSS, @@ -28,18 +32,327 @@ const ActorInit En_Sda_InitVars = { (ActorFunc)EnSda_Draw, }; -#endif +Vec3f D_80947A60 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/EnSda_Init.s") +s16 D_80947A6C[] = { 1, 2, 3, 3, 2, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/EnSda_Destroy.s") +s16 D_80947A78[] = { 2, 3, 4, 4, 4, 3, 2, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/EnSda_Update.s") +s16 D_80947A88[] = { 2, 3, 4, 4, 4, 4, 3, 2 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/EnSda_Draw.s") +s16 D_80947A98[] = { 2, 4, 5, 5, 6, 6, 6, 6, 5, 5, 4, 2 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/func_809469C0.s") +s16 D_80947AB0[] = { 2, 4, 5, 6, 7, 8, 8, 8, 8, 7, 6, 5, 4, 2 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/func_8094702C.s") +s16 D_80947ACC[] = { 1, -1, 1, 1, 3, 4, 1, 6, 7, 2, 9, 0xA, 2, 0xC, 0xD, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/func_80947668.s") +u8 D_80947AEC[] = { + 2, 2, 2, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 3, +}; + +s8 D_80947AFC[] = { + 2, 9, 10, 11, 12, 13, 14, 0, 15, -1, 3, 4, 5, 6, 7, 8, -1, 1, 0, 0, +}; + +Vec3f D_80947B10[] = { + { -1.0f, 2.0f, -0.2f }, { 0.0f, 2.0f, -0.5f }, { 1.0f, 2.0f, -0.2f }, { -2.0f, 1.0f, -0.5f }, + { -1.0f, 1.0f, -0.2f }, { 0.0f, 1.0f, -0.2f }, { 1.0f, 1.0f, -0.2f }, { 2.0f, 1.0f, -0.5f }, + { -2.0f, 0.0f, -0.5f }, { -1.0f, 0.0f, -0.2f }, { 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, -0.2f }, + { 2.0f, 0.0f, -0.5f }, { -2.0f, -1.0f, -0.5f }, { -1.0f, -1.0f, -0.2f }, { 0.0f, -1.0f, -0.1f }, + { 1.0f, -1.0f, -0.2f }, { 2.0f, -1.0f, -0.5f }, { -1.0f, -2.0f, -0.2f }, { 0.0f, -2.0f, -0.2f }, + { 1.0f, -2.0f, -0.2f }, { 0.0f, -3.0f, -0.5f }, { -1.0f, 2.0f, -0.2f }, { 0.0f, 2.0f, -0.5f }, + { 1.0f, 2.0f, -0.2f }, { -2.0f, 1.0f, -0.5f }, { -1.0f, 1.0f, -0.2f }, { 0.0f, 1.0f, -0.2f }, + { 1.0f, 1.0f, -0.2f }, { 2.0f, 1.0f, -0.5f }, { -2.0f, 0.0f, -0.5f }, { -1.0f, 0.0f, -0.2f }, + { 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, -0.2f }, { 2.0f, 0.0f, -0.5f }, { -2.0f, -1.0f, -0.5f }, + { -1.0f, -1.0f, -0.2f }, { 0.0f, -1.0f, -0.1f }, { 1.0f, -1.0f, -0.2f }, { 2.0f, -1.0f, -0.5f }, + { -1.0f, -2.0f, -0.2f }, { 0.0f, -2.0f, -0.2f }, { 1.0f, -2.0f, -0.2f }, { 0.0f, -3.0f, -0.5f }, +}; + +static s32 sPad[2] = { 0, 0 }; + +#include "overlays/ovl_En_Sda/ovl_En_Sda.c" + +void EnSda_Init(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnSda_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnSda_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSda* this = THIS; + Player* player; + + if (this->actor.params == ENSDA_1) { + player = (Player*)this->actor.parent; + } else { + player = GET_PLAYER(globalCtx); + } + this->actor.world.pos = player->actor.world.pos; +} + +void EnSda_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSda* this = THIS; + Player* player; + u8* shadowTexture = GRAPH_ALLOC(globalCtx->state.gfxCtx, 64 * 64); + + if (this->actor.params == ENSDA_1) { + player = (Player*)this->actor.parent; + } else { + player = GET_PLAYER(globalCtx); + } + + player->actor.shape.shadowAlpha = 0; + func_8094702C(this, shadowTexture, player, globalCtx); + + if (KREG(0) < 5) { + func_80947668(shadowTexture, player, globalCtx); + } +} + +void func_809469C0(Player* player, u8* shadowTexture, f32 arg2) { + s16 temp_t0; + s16 temp_t1; + s16 temp_v1; + s16 temp_v0; + s16 phi_a0; + s16 phi_a3; + s16 i; + s16 j; + Vec3f lerp; + Vec3f sp88; + Vec3f sp7C; + + for (i = 0; i < 16; i++) { + if ((arg2 == 0.0f) || ((j = D_80947ACC[i]) >= 0)) { + if (arg2 > 0.0f) { + lerp.x = D_80947EA0[i].x + (D_80947EA0[j].x - D_80947EA0[i].x) * arg2; + lerp.y = D_80947EA0[i].y + (D_80947EA0[j].y - D_80947EA0[i].y) * arg2; + lerp.z = D_80947EA0[i].z + (D_80947EA0[j].z - D_80947EA0[i].z) * arg2; + + sp88.x = lerp.x - player->actor.world.pos.x; + sp88.y = lerp.y - player->actor.world.pos.y + BREG(48) + 76.0f + 30.0f - 105.0f + 15.0f; + sp88.z = lerp.z - player->actor.world.pos.z; + } else { + sp88.x = D_80947EA0[i].x - player->actor.world.pos.x; + sp88.y = D_80947EA0[i].y - player->actor.world.pos.y + BREG(48) + 76.0f + 30.0f - 105.0f + 15.0f; + sp88.z = D_80947EA0[i].z - player->actor.world.pos.z; + } + + Matrix_MultiplyVector3fByState(&sp88, &sp7C); + sp7C.x *= (1.0f + (BREG(49) / 100.0f)); + sp7C.y *= (1.0f + (BREG(49) / 100.0f)); + temp_t0 = sp7C.x + 32.0f; + temp_t1 = sp7C.y * 64.0f; + + if (D_80947AEC[i] == 2) { + for (j = 0, phi_a3 = -0x180; j < 12; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A98[j]; phi_a0 < D_80947A98[j]; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } else if (D_80947AEC[i] == 1) { + for (j = 0, phi_a3 = -0x100; j < 8; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A88[j]; phi_a0 < D_80947A88[j]; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } else if (D_80947AEC[i] == 0) { + for (j = 0, phi_a3 = -0xC0; j < 7; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A78[j]; phi_a0 < D_80947A78[j] - 1; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } else if (D_80947AEC[i] == 4) { + for (j = 0, phi_a3 = -0x1C0; j < 14; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947AB0[j]; phi_a0 < D_80947AB0[j]; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } else { + for (j = 0, phi_a3 = -0x80; j < 6; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A6C[j]; phi_a0 < D_80947A6C[j] - 1; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } + } + } +} + +void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, GlobalContext* globalCtx) { + s16 temp_t0; + s16 temp_t1; + s16 temp_v0; + s16 temp_v1; + s16 phi_a0; + s16 phi_a3; + s16 i; + s16 j; + Vec3f sp194; + Vec3f sp188; + s32* shadowTextureTemp32; + u8* shadowTextureTemp; + Vec3s sp178; + Vec3f sp16C; + Vec3f sp64[22]; + + if (BREG(57) != 0) { + for (shadowTextureTemp = shadowTexture, i = 0; i < 0x1000; i++, shadowTextureTemp++) { + if ((i >= 0 && i < 0x40) || (i >= 0xFC0 && i < 0x1000) || ((i & 0x3F) == 0) || ((i & 0x3F) == 0x3F)) { + *shadowTextureTemp = 255; + } else { + *shadowTextureTemp = 0; + } + } + } else { + for (shadowTextureTemp32 = (s32*)shadowTexture, i = 0; i < 0x400; i++, shadowTextureTemp32++) { + *shadowTextureTemp32 = 0; + } + } + + Matrix_SetStateXRotation((BREG(50) + 70) / 100.0f); + + for (i = 0; i < 18; i++) { + if (D_80947AFC[i] >= 0) { + D_80947EA0[D_80947AFC[i]] = player->bodyPartsPos[i]; + } + } + + D_80947EA0[0].y += 3.0f; + D_80947EA0[15].x = D_80947EA0[0].x + ((D_80947EA0[15].x - D_80947EA0[0].x) * 1.2f); + D_80947EA0[15].y = D_80947EA0[0].y + ((D_80947EA0[15].y - D_80947EA0[0].y) * -1.2f); + D_80947EA0[15].z = D_80947EA0[0].z + ((D_80947EA0[15].z - D_80947EA0[0].z) * 1.2f); + + for (i = 0; i < 6; i++) { + func_809469C0(player, shadowTexture, i / 5.0f); + } + + if (this->actor.params != ENSDA_1) { + func_8018219C(&player->shieldMf, &sp178, false); + + sp178.y += (KREG(87) * 0x8000) + 0x8000; + sp178.x *= (KREG(88) - 1); + + Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&D_80947A60, &sp16C); + Matrix_RotateY(sp178.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(sp178.x, MTXMODE_APPLY); + + for (i = 0; i < 22; i++) { + Matrix_MultiplyVector3fByState(&D_80947B10[i], &sp188); + sp64[i].x = (((KREG(82) / 100.0f) + 4.0f) * sp188.x) + sp16C.x; + sp64[i].y = (((KREG(82) / 100.0f) + 4.0f) * sp188.y) + sp16C.y; + sp64[i].z = (((KREG(82) / 100.0f) + 4.0f) * sp188.z) + sp16C.z; + } + + Matrix_SetStateXRotation((BREG(50) + 70) / 100.0f); + + for (i = 0; i < 22; i++) { + sp194.x = sp64[i].x - player->actor.world.pos.x; + sp194.y = sp64[i].y - player->actor.world.pos.y + KREG(80) + 16.0f; + sp194.z = sp64[i].z - player->actor.world.pos.z; + + Matrix_MultiplyVector3fByState(&sp194, &sp188); + + sp188.x *= (1.0f + (KREG(90) / 100.0f)); + sp188.y *= (1.0f + (KREG(90) / 100.0f)); + temp_t0 = sp188.x + 32.0f; + temp_t1 = sp188.y * 64.0f; + + do { + for (j = 0, phi_a3 = -0xC0; j < 7; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A78[j]; phi_a0 < D_80947A78[j] - 1; phi_a0++) { + temp_v0 = temp_t0 + phi_a0; + if ((temp_v0 >= 0) && (temp_v0 < 0x40)) { + temp_v1 = temp_t1 + phi_a3; + if ((temp_v1 >= 0) && (temp_v1 < 0x1000)) { + shadowTexture[temp_v0 + temp_v1] = 255; + } + } + } + } + j++; + } while (j < 6); + } + } + + if (BREG(61) == 1) { + for (shadowTextureTemp = shadowTexture, i = 0; i < 0x1000; i++, shadowTextureTemp++) { + if (*shadowTextureTemp != 0) { + *shadowTextureTemp = -((i >> 6) * (BREG(60) + 4)) + (255 - BREG(61)); + } + } + } +} + +void func_80947668(u8* shadowTexture, Player* player, GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + f32 tempx; + f32 tempz; + s16 i; + + OPEN_DISPS(gfxCtx); + + func_8012C448(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 0, 0, 0, (BREG(52) + 50)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 0); + + Matrix_InsertTranslation(player->actor.world.pos.x, player->actor.floorHeight, player->actor.world.pos.z, + MTXMODE_NEW); + Matrix_InsertYRotation_f(BREG(51) / 100.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, 1.0f, (BREG(63) / 10.0f) + 1.0f, MTXMODE_APPLY); + + tempx = (BREG(62) / 10.0f) + 2.0f; + tempz = ((player->actor.world.pos.y - player->actor.floorHeight + BREG(54)) * (BREG(55) - 5) / 10.0f) + BREG(58) - + 20.0f; + + Matrix_InsertTranslation(tempx, 0.0f, tempz, MTXMODE_APPLY); + Matrix_Scale(((BREG(56) - 250) / 1000.0f) + 0.6f, 1.0f, ((BREG(59) - 250) / 1000.0f) + 0.6f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, ovl_En_Sda_DL_1498); + gDPLoadTextureBlock(POLY_XLU_DISP++, shadowTexture, G_IM_FMT_I, G_IM_SIZ_8b, 64, 64, 0, G_TX_NOMIRROR | G_TX_CLAMP, + G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); + gSPDisplayList(POLY_XLU_DISP++, ovl_En_Sda_DL_14B8); + + for (i = 0; i < KREG(78); i++) { + Matrix_Scale((KREG(79) / 100.0f) + 1.0f, 1.0f, (KREG(79) / 100.0f) + 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, ovl_En_Sda_DL_14B8); + } + + CLOSE_DISPS(gfxCtx); + + if (1) {} +} diff --git a/src/overlays/actors/ovl_En_Sda/z_en_sda.h b/src/overlays/actors/ovl_En_Sda/z_en_sda.h index fff04d601..ff17a2538 100644 --- a/src/overlays/actors/ovl_En_Sda/z_en_sda.h +++ b/src/overlays/actors/ovl_En_Sda/z_en_sda.h @@ -5,6 +5,8 @@ struct EnSda; +#define ENSDA_1 1 + typedef struct EnSda { /* 0x000 */ Actor actor; } EnSda; // size = 0x144 From b7639a7c6fe18455085ecab7c469b2fed6d6f529 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 26 Mar 2022 01:39:33 +0000 Subject: [PATCH 112/257] En_Wood02 (#697) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * En_Wood02 * statics£ * PR * PR --- spec | 4 +- .../actors/ovl_En_Wood02/z_en_wood02.c | 487 +++++++++++++++++- .../actors/ovl_En_Wood02/z_en_wood02.h | 42 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 4 - 5 files changed, 516 insertions(+), 25 deletions(-) diff --git a/spec b/spec index c2cb6a451..f45ffe73a 100644 --- a/spec +++ b/spec @@ -1095,9 +1095,7 @@ beginseg name "ovl_En_Wood02" compress include "build/src/overlays/actors/ovl_En_Wood02/z_en_wood02.o" - include "build/data/ovl_En_Wood02/ovl_En_Wood02.data.o" - include "build/data/ovl_En_Wood02/ovl_En_Wood02.bss.o" - include "build/data/ovl_En_Wood02/ovl_En_Wood02.reloc.o" + include "build/src/overlays/actors/ovl_En_Wood02/ovl_En_Wood02_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c index e24a5af95..9db26a88c 100644 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c @@ -5,6 +5,7 @@ */ #include "z_en_wood02.h" +#include "objects/object_wood02/object_wood02.h" #define FLAGS 0x00000000 @@ -15,7 +16,28 @@ void EnWood02_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx); void EnWood02_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +/** + * WOOD_SPAWN_SPAWNER is also used by some individual trees: EnWood02_Update also checks for parent before running any + * despawning code. + * */ +typedef enum { + /* 0 */ WOOD_SPAWN_NORMAL, + /* 1 */ WOOD_SPAWN_SPAWNED, + /* 2 */ WOOD_SPAWN_SPAWNER +} WoodSpawnType; + +typedef enum { + /* 0 */ WOOD_DRAW_TREE_CONICAL, + /* 1 */ WOOD_DRAW_TREE_OVAL, + /* 2 */ WOOD_DRAW_TREE_KAKARIKO_ADULT, + /* 3 */ WOOD_DRAW_BUSH_GREEN, + /* 4 */ WOOD_DRAW_4, // Used for black bushes and green leaves + /* 5 */ WOOD_DRAW_LEAF_YELLOW +} WoodDrawType; + +static f32 sSpawnCos; +static f32 sSpawnSin; + const ActorInit En_Wood02_InitVars = { ACTOR_EN_WOOD02, ACTORCAT_PROP, @@ -28,29 +50,464 @@ const ActorInit En_Wood02_InitVars = { (ActorFunc)EnWood02_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808C4D00 = { - { COLTYPE_TREE, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x0100020A, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_TREE, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x0100020A, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 60, 0, { 0, 0, 0 } }, }; -#endif +static f32 sSpawnDistance[] = { 707.0f, 525.0f, 510.0f, 500.0f, 566.0f, 141.0f }; -extern ColliderCylinderInit D_808C4D00; +static s16 sSpawnAngle[] = { 0x1FFF, 0x4C9E, 0x77F5, 0xA5C9, -0x293D, 0xA000 }; -extern UNK_TYPE D_06000700; +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 5600, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/func_808C3C00.s") +Gfx* D_808C4D54[] = { + object_wood02_DL_0078D0, object_wood02_DL_007CA0, object_wood02_DL_008160, object_wood02_DL_000090, + object_wood02_DL_000340, object_wood02_DL_000340, object_wood02_DL_000700, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/func_808C3D28.s") +Gfx* D_808C4D70[] = { + object_wood02_DL_007968, + object_wood02_DL_007D38, + object_wood02_DL_0080D0, + NULL, + NULL, + NULL, + object_wood02_DL_007AD0, + object_wood02_DL_007E20, + object_wood02_DL_009340, + object_wood02_DL_000160, + object_wood02_DL_000440, + object_wood02_DL_000700, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/EnWood02_Init.s") +s32 EnWood02_SpawnZoneCheck(EnWood02* this, GlobalContext* globalCtx, Vec3f* arg2) { + f32 phi_f12; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/EnWood02_Destroy.s") + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg2, &this->actor.projectedPos, + &this->actor.projectedW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/func_808C4458.s") + if (this->actor.projectedW == 0.0f) { + phi_f12 = 1000.0f; + } else { + phi_f12 = fabsf(1.0f / this->actor.projectedW); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/EnWood02_Update.s") + if (((-this->actor.uncullZoneScale < this->actor.projectedPos.z) && + (this->actor.projectedPos.z < (this->actor.uncullZoneForward + this->actor.uncullZoneScale)) && + (((fabsf(this->actor.projectedPos.x) - this->actor.uncullZoneScale) * phi_f12) < 1.0f)) && + (((this->actor.projectedPos.y + this->actor.uncullZoneDownward) * phi_f12) > -1.0f) && + (((this->actor.projectedPos.y - this->actor.uncullZoneScale) * phi_f12) < 1.0f)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/EnWood02_Draw.s") +/** Spawns similar-looking trees or bushes only when the player is sufficiently close. Presumably done this way to keep + * memory usage down in Hyrule Field. */ +void EnWood02_SpawnOffspring(EnWood02* this, GlobalContext* globalCtx) { + EnWood02* child; + s32 extraRot; + Vec3f childPos; + s32 unk; + s32 i; + s16 childParams; + + for (i = 4; i >= 0; i--) { + extraRot = 0; + if (!(this->unk_14A[i] & 0x7F)) { + if (this->actor.params == WOOD_BUSH_GREEN_LARGE_SPAWNER) { + extraRot = 0x4000; + } + + sSpawnCos = Math_CosS(sSpawnAngle[i] + this->actor.world.rot.y + extraRot); + sSpawnSin = Math_SinS(sSpawnAngle[i] + this->actor.world.rot.y + extraRot); + + childPos.x = (sSpawnDistance[i] * sSpawnSin) + this->actor.home.pos.x; + childPos.y = this->actor.home.pos.y; + childPos.z = (sSpawnDistance[i] * sSpawnCos) + this->actor.home.pos.z; + + if (EnWood02_SpawnZoneCheck(this, globalCtx, &childPos)) { + if (this->unk_14A[i] & 0x80) { + unk = 0; + } else { + unk = this->actor.home.rot.z; + } + + childParams = ((this->unk_144 << 8) & 0xFF00) | (this->actor.params + 1); + child = (EnWood02*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_WOOD02, + childPos.x, childPos.y, childPos.z, this->actor.world.rot.x, + sSpawnAngle[i], unk, childParams); + if (child != NULL) { + child->unk_14A[0] = i; + this->unk_14A[i] |= 1; + child->actor.projectedPos = this->actor.projectedPos; + } else { + this->unk_14A[i] &= 0x80; + } + } + } + } +} + +void EnWood02_Init(Actor* thisx, GlobalContext* globalCtx) { + s16 spawnType = 0; + f32 actorScale = 1.0f; + EnWood02* this = THIS; + s32 pad; + CollisionPoly* outPoly; + s32 bgId; + f32 floorY; + s16 extraRot; + + this->actor.world.rot.z = 0; + this->unk_144 = ENWOOD02_GET_FF00(&this->actor); + this->unk_146 = -1; + this->actor.shape.rot.z = this->actor.world.rot.z; + + if (this->unk_144 & 0x80) { + this->unk_144 = -1; + } + + this->actor.params &= 0xFF; + this->unk_148 = this->actor.home.rot.z; + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if ((this->actor.params < WOOD_BUSH_GREEN_SMALL) || (this->actor.params == WOOD_TREE_SPECIAL)) { + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + } + + if ((this->actor.params == WOOD_TREE_SPECIAL) && !gSaveContext.isNight && (this->unk_144 != -1) && + !Flags_GetCollectible(globalCtx, this->unk_144)) { + this->actor.child = + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ANI, this->actor.world.pos.x, + this->actor.world.pos.y + 120.0f, this->actor.world.pos.z - 15.0f, 0, 0, 0, 1); + if (this->actor.child != NULL) { + this->actor.child->cutscene = this->actor.cutscene; + } + this->unk_151 = 1; + } else { + this->actor.child = NULL; + this->unk_151 = 0; + } + + switch (this->actor.params) { + case WOOD_BUSH_GREEN_LARGE_SPAWNER: + case WOOD_BUSH_BLACK_LARGE_SPAWNER: + spawnType = 1; + + case WOOD_BUSH_GREEN_LARGE_SPAWNED: + case WOOD_BUSH_BLACK_LARGE_SPAWNED: + spawnType++; + + case WOOD_TREE_CONICAL_LARGE: + case WOOD_BUSH_GREEN_LARGE: + case WOOD_BUSH_BLACK_LARGE: + case WOOD_TREE_SPECIAL: + actorScale = 1.5f; + this->actor.uncullZoneForward = 4000.0f; + this->actor.uncullZoneScale = 2000.0f; + this->actor.uncullZoneDownward = 2400.0f; + break; + + case WOOD_TREE_CONICAL_SPAWNER: + case WOOD_TREE_OVAL_YELLOW_SPAWNER: + case WOOD_TREE_OVAL_GREEN_SPAWNER: + case WOOD_BUSH_GREEN_SMALL_SPAWNER: + case WOOD_BUSH_BLACK_SMALL_SPAWNER: + spawnType = 1; + + case WOOD_TREE_CONICAL_SPAWNED: + case WOOD_TREE_OVAL_YELLOW_SPAWNED: + case WOOD_TREE_OVAL_GREEN_SPAWNED: + case WOOD_BUSH_GREEN_SMALL_SPAWNED: + case WOOD_BUSH_BLACK_SMALL_SPAWNED: + spawnType++; + + case WOOD_TREE_CONICAL_MEDIUM: + case WOOD_TREE_OVAL_GREEN: + case WOOD_TREE_KAKARIKO_ADULT: + case WOOD_BUSH_GREEN_SMALL: + case WOOD_BUSH_BLACK_SMALL: + this->actor.uncullZoneForward = 4000.0f; + this->actor.uncullZoneScale = 800.0f; + this->actor.uncullZoneDownward = 1800.0f; + break; + + case WOOD_TREE_CONICAL_SMALL: + actorScale = 0.6f; + this->actor.uncullZoneForward = 4000.0f; + this->actor.uncullZoneScale = 400.0f; + this->actor.uncullZoneDownward = 1000.0f; + break; + + case WOOD_LEAF_GREEN: + case WOOD_LEAF_YELLOW: + this->unk_14A[0] = 75; + actorScale = 0.02f; + this->actor.velocity.x = randPlusMinusPoint5Scaled(6.0f); + this->actor.velocity.z = randPlusMinusPoint5Scaled(6.0f); + this->actor.velocity.y = (Rand_ZeroOne() * 1.25f) + -3.1f; + break; + } + + if (this->actor.params < WOOD_TREE_OVAL_GREEN) { + this->drawType = WOOD_DRAW_TREE_CONICAL; + } else if (this->actor.params < WOOD_TREE_KAKARIKO_ADULT) { + this->drawType = WOOD_DRAW_TREE_OVAL; + } else if (this->actor.params < WOOD_BUSH_GREEN_SMALL) { + this->drawType = WOOD_DRAW_TREE_KAKARIKO_ADULT; + } else if (this->actor.params < WOOD_BUSH_BLACK_SMALL) { + this->drawType = WOOD_DRAW_BUSH_GREEN; + } else if (this->actor.params < WOOD_LEAF_YELLOW) { + this->drawType = WOOD_DRAW_4; + } else if (this->actor.params == WOOD_TREE_SPECIAL) { + this->drawType = WOOD_DRAW_TREE_CONICAL; + } else { + this->drawType = WOOD_DRAW_LEAF_YELLOW; + } + + Actor_SetScale(&this->actor, actorScale); + this->spawnType = spawnType; + + if (spawnType != WOOD_SPAWN_NORMAL) { + extraRot = 0; + if (this->actor.params == WOOD_BUSH_GREEN_LARGE_SPAWNER) { + extraRot = 0x4000; + } + + if (spawnType == WOOD_SPAWN_SPAWNER) { + EnWood02_SpawnOffspring(this, globalCtx); + sSpawnCos = Math_CosS(sSpawnAngle[5] + this->actor.world.rot.y + extraRot); + sSpawnSin = Math_SinS(sSpawnAngle[5] + this->actor.world.rot.y + extraRot); + this->actor.world.pos.x += sSpawnSin * sSpawnDistance[5]; + this->actor.world.pos.z += sSpawnCos * sSpawnDistance[5]; + } else { + this->actor.flags |= ACTOR_FLAG_10; + this->unk_151 = 2; + } + + // Snap to floor, or remove if over void + this->actor.world.pos.y += 200.0f; + floorY = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &outPoly, &bgId, &this->actor, &this->actor.world.pos); + + if (floorY > BGCHECK_Y_MIN) { + this->actor.world.pos.y = floorY; + } else { + Actor_MarkForDeath(&this->actor); + return; + } + } + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + this->actor.home.rot.y = 0; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; +} + +void EnWood02_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWood02* this = THIS; + + if ((this->actor.params < WOOD_BUSH_GREEN_SMALL) || (this->actor.params == WOOD_TREE_SPECIAL)) { + Collider_DestroyCylinder(globalCtx, &this->collider); + } +} + +void func_808C4458(EnWood02* this, GlobalContext* globalCtx, Vec3f* arg2, u16 arg3) { + s32 pad[2]; + s32 sp24; + + if (this->unk_148 != 0) { + if ((this->unk_144 == -1) || !Flags_GetCollectible(globalCtx, this->unk_144)) { + if ((this->unk_148 < 0) && (this->unk_148 >= -0x10)) { + if (arg3 & 1) { + Item_DropCollectibleRandom(globalCtx, &this->actor, arg2, ((-1 - this->unk_148) * 0x10) | 0x8000); + } else { + Item_DropCollectibleRandom(globalCtx, &this->actor, arg2, (-1 - this->unk_148) * 0x10); + } + } else if (this->unk_148 > 0) { + sp24 = func_800A8150(this->unk_148 - 1); + if (sp24 >= 0) { + if (this->unk_144 == -1) { + Item_DropCollectible(globalCtx, arg2, sp24); + } else { + Item_DropCollectible(globalCtx, arg2, ((this->unk_144 & 0x7F) << 8) | sp24); + } + } + } + } + this->unk_148 = 0; + } +} + +void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnWood02* this = THIS; + f32 wobbleAmplitude; + + // Despawn extra trees in a group if out of range + if ((this->spawnType == WOOD_SPAWN_SPAWNED) && (thisx->parent != NULL)) { + if (!(thisx->flags & 0x40) && (this->unk_151 != 2)) { + s32 index = this->unk_14A[0]; + s32 phi_v0 = 0; + + if (this->unk_148 == 0) { + phi_v0 = 0x80; + } + + ((EnWood02*)thisx->parent)->unk_14A[index] = phi_v0; + + Actor_MarkForDeath(thisx); + return; + } + this->unk_151 = 0; + } else if (this->spawnType == WOOD_SPAWN_SPAWNER) { + EnWood02_SpawnOffspring(this, globalCtx); + } + + if ((thisx->params < WOOD_BUSH_GREEN_SMALL) || (thisx->params == WOOD_TREE_SPECIAL)) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_PlaySfxAtPos(thisx, NA_SE_IT_REFLECTION_WOOD); + } + + if (thisx->home.rot.y != 0) { + Vec3f dropsSpawnPt = thisx->world.pos; + + dropsSpawnPt.y += 200.0f; + + func_808C4458(this, globalCtx, &dropsSpawnPt, 0); + + // Spawn falling leaves + if (this->unk_146 >= -1) { + s32 i; + s32 leavesParams = WOOD_LEAF_GREEN; + + if ((thisx->params == WOOD_TREE_OVAL_YELLOW_SPAWNER) || + (thisx->params == WOOD_TREE_OVAL_YELLOW_SPAWNED)) { + leavesParams = WOOD_LEAF_YELLOW; + } + Actor_PlaySfxAtPos(thisx, NA_SE_EV_TREE_SWING); + + for (i = 3; i >= 0; i--) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WOOD02, dropsSpawnPt.x, dropsSpawnPt.y, + dropsSpawnPt.z, 0, randPlusMinusPoint5Scaled(0xFFFF), 0, leavesParams); + } + } + + if ((thisx->child != NULL) && (this->unk_151 == 1)) { + thisx->child->home.rot.x = 1; + this->unk_151 = 0; + } + + if ((thisx->params == WOOD_TREE_SPECIAL) && (this->unk_144 != -1)) { + Flags_SetCollectible(globalCtx, this->unk_144); + this->unk_144 = -1; + } + this->unk_146 = -0x15; + thisx->home.rot.y = 0; + } + + if (thisx->xzDistToPlayer < 600.0f) { + Collider_UpdateCylinder(thisx, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } else if ((thisx->params < WOOD_LEAF_GREEN) || (thisx->params == WOOD_TREE_SPECIAL)) { // not leaves + Player* player = GET_PLAYER(globalCtx); + + if ((this->unk_146 >= -1) && (((player->rideActor == NULL) && (sqrtf(thisx->xyzDistToPlayerSq) < 20.0f) && + (player->linearVelocity != 0.0f)) || + ((player->rideActor != NULL) && (sqrtf(thisx->xyzDistToPlayerSq) < 60.0f) && + (player->rideActor->speedXZ != 0.0f)))) { + func_808C4458(this, globalCtx, &thisx->world.pos, 1); + this->unk_146 = -0x15; + Actor_PlaySfxAtPos(thisx, NA_SE_EV_TREE_SWING); + } + } else { // Leaves + this->unk_146++; + Math_ApproachF(&thisx->velocity.x, 0.0f, 1.0f, 5.0f * 0.01f); + Math_ApproachF(&thisx->velocity.z, 0.0f, 1.0f, 5.0f * 0.01f); + Actor_UpdatePos(thisx); + thisx->shape.rot.z = Math_SinS(this->unk_146 * 0xBB8) * 16384.0f; + this->unk_14A[0]--; + if (this->unk_14A[0] == 0) { + Actor_MarkForDeath(thisx); + } + } + + // Wobble from impact + if (this->unk_146 < -1) { + this->unk_146++; + wobbleAmplitude = Math_SinS((this->unk_146 ^ 0xFFFF) * 0x3332) * 250.0f; + thisx->shape.rot.x = Math_CosS(thisx->yawTowardsPlayer - thisx->shape.rot.y) * wobbleAmplitude; + thisx->shape.rot.z = Math_SinS(thisx->yawTowardsPlayer - thisx->shape.rot.y) * wobbleAmplitude; + } +} + +void EnWood02_Draw(Actor* thisx, GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s16 type; + s16 pad; + u8 red; + u8 green; + u8 blue; + + OPEN_DISPS(gfxCtx); + type = thisx->params; + + if ((type == WOOD_TREE_OVAL_GREEN_SPAWNER) || (type == WOOD_TREE_OVAL_GREEN_SPAWNED) || + (type == WOOD_TREE_OVAL_GREEN) || (type == WOOD_LEAF_GREEN)) { + red = 50; + green = 170; + blue = 70; + } else if ((type == WOOD_TREE_OVAL_YELLOW_SPAWNER) || (type == WOOD_TREE_OVAL_YELLOW_SPAWNED) || + (type == WOOD_LEAF_YELLOW)) { + red = 180; + green = 155; + blue = 0; + } else { + red = green = blue = 255; + } + + func_8012C2DC(gfxCtx); + + if ((thisx->params == WOOD_LEAF_GREEN) || (thisx->params == WOOD_LEAF_YELLOW)) { + func_8012C28C(gfxCtx); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, red, green, blue, 127); + + Gfx_DrawDListOpa(globalCtx, object_wood02_DL_000700); + } else if (D_808C4D70[THIS->drawType & 0xF] != NULL) { + Gfx_DrawDListOpa(globalCtx, D_808C4D54[THIS->drawType & 0xF]); + + gDPSetEnvColor(POLY_XLU_DISP++, red, green, blue, 0); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_808C4D70[THIS->drawType & 0xF]); + } else { + func_8012C2DC(gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_808C4D54[THIS->drawType & 0xF]); + } + + CLOSE_DISPS(gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h index ef638cfcd..310d1e5de 100644 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h @@ -5,11 +5,51 @@ struct EnWood02; +#define ENWOOD02_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + typedef struct EnWood02 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x5C]; + /* 0x144 */ s16 unk_144; + /* 0x146 */ s16 unk_146; + /* 0x148 */ s16 unk_148; + /* 0x14A */ u8 unk_14A[5]; + /* 0x14F */ u8 spawnType; + /* 0x150 */ u8 drawType; + /* 0x151 */ u8 unk_151; + /* 0x154 */ ColliderCylinder collider; } EnWood02; // size = 0x1A0 +// Types with SPAWNED in the name are those that can be managed by a spawner, however the actor allows you to spawn them +// on their own without a spawner as well. +typedef enum { + /* 0x00 */ WOOD_TREE_CONICAL_LARGE, + /* 0x01 */ WOOD_TREE_CONICAL_MEDIUM, + /* 0x02 */ WOOD_TREE_CONICAL_SMALL, + /* 0x03 */ WOOD_TREE_CONICAL_SPAWNER, + /* 0x04 */ WOOD_TREE_CONICAL_SPAWNED, + /* 0x05 */ WOOD_TREE_OVAL_GREEN, + /* 0x06 */ WOOD_TREE_OVAL_YELLOW_SPAWNER, + /* 0x07 */ WOOD_TREE_OVAL_YELLOW_SPAWNED, + /* 0x08 */ WOOD_TREE_OVAL_GREEN_SPAWNER, + /* 0x09 */ WOOD_TREE_OVAL_GREEN_SPAWNED, + /* 0x0A */ WOOD_TREE_KAKARIKO_ADULT, + /* 0x0B */ WOOD_BUSH_GREEN_SMALL, + /* 0x0C */ WOOD_BUSH_GREEN_LARGE, + /* 0x0D */ WOOD_BUSH_GREEN_SMALL_SPAWNER, + /* 0x0E */ WOOD_BUSH_GREEN_SMALL_SPAWNED, + /* 0x0F */ WOOD_BUSH_GREEN_LARGE_SPAWNER, + /* 0x10 */ WOOD_BUSH_GREEN_LARGE_SPAWNED, + /* 0x11 */ WOOD_BUSH_BLACK_SMALL, + /* 0x12 */ WOOD_BUSH_BLACK_LARGE, + /* 0x13 */ WOOD_BUSH_BLACK_SMALL_SPAWNER, + /* 0x14 */ WOOD_BUSH_BLACK_SMALL_SPAWNED, + /* 0x15 */ WOOD_BUSH_BLACK_LARGE_SPAWNER, + /* 0x16 */ WOOD_BUSH_BLACK_LARGE_SPAWNED, + /* 0x17 */ WOOD_LEAF_GREEN, + /* 0x18 */ WOOD_LEAF_YELLOW, + /* 0x1A */ WOOD_TREE_SPECIAL = 0x1A +} WoodType; + extern const ActorInit En_Wood02_InitVars; #endif // Z_EN_WOOD02_H diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 9215796af..4b28b6dc3 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -6142,8 +6142,8 @@ 0x808C3A78:("BgKeikokuSpr_Destroy",), 0x808C3A88:("BgKeikokuSpr_Update",), 0x808C3A98:("BgKeikokuSpr_Draw",), - 0x808C3C00:("func_808C3C00",), - 0x808C3D28:("func_808C3D28",), + 0x808C3C00:("EnWood02_SpawnZoneCheck",), + 0x808C3D28:("EnWood02_SpawnOffspring",), 0x808C3F30:("EnWood02_Init",), 0x808C4414:("EnWood02_Destroy",), 0x808C4458:("func_808C4458",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 5e1f083d7..08ee2e9d7 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1790,10 +1790,6 @@ D_06001690 = 0x06001690; D_06005870 = 0x06005870; D_06005C64 = 0x06005C64; -// ovl_En_Wood02 - -D_06000700 = 0x06000700; - // ovl_En_Zl4 D_06013328 = 0x06013328; From 59ec3f721a032ca5e8e5c85c09861483a8c0542a Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 26 Mar 2022 01:46:13 +0000 Subject: [PATCH 113/257] Obj_Driftice (2 non-matching) (#700) * Obj_Driftice * PR --- spec | 5 +- .../actors/ovl_Obj_Driftice/z_obj_driftice.c | 435 +++++++++++++++++- .../actors/ovl_Obj_Driftice/z_obj_driftice.h | 48 +- undefined_syms.txt | 5 - 4 files changed, 460 insertions(+), 33 deletions(-) diff --git a/spec b/spec index f45ffe73a..6771502b6 100644 --- a/spec +++ b/spec @@ -3043,8 +3043,11 @@ beginseg name "ovl_Obj_Driftice" compress include "build/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.o" - include "build/data/ovl_Obj_Driftice/ovl_Obj_Driftice.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Driftice/ovl_Obj_Driftice_reloc.o" +#else include "build/data/ovl_Obj_Driftice/ovl_Obj_Driftice.reloc.o" +#endif endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c index f193fbbc1..abd30b256 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c @@ -5,6 +5,7 @@ */ #include "z_obj_driftice.h" +#include "objects/object_driftice/object_driftice.h" #define FLAGS 0x00000000 @@ -15,7 +16,15 @@ void ObjDriftice_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjDriftice_Update(Actor* thisx, GlobalContext* globalCtx); void ObjDriftice_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A671A8(ObjDriftice* this); +void func_80A671BC(ObjDriftice* this, GlobalContext* globalCtx); +void func_80A671CC(ObjDriftice* this); +void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx); +void func_80A6743C(ObjDriftice* this); +void func_80A67450(ObjDriftice* this, GlobalContext* globalCtx); +void func_80A674A8(ObjDriftice* this); +void func_80A674C4(ObjDriftice* this, GlobalContext* globalCtx); + const ActorInit Obj_Driftice_InitVars = { ACTOR_OBJ_DRIFTICE, ACTORCAT_BG, @@ -28,52 +37,430 @@ const ActorInit Obj_Driftice_InitVars = { (ActorFunc)ObjDriftice_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A676F4[] = { +static f32 D_80A67620[][3] = { + { 1.0f, 150.0f, 150.0f }, + { 1.5f, 250.0f, 200.0f }, + { 2.0f, 350.0f, 250.0f }, +}; + +static f32 D_80A67644[] = { 1.5f, 3.0f, 4.5f, 6.0f, 7.5f, 9.0f, 10.5f, 0.0f }; + +static f32 D_80A67664[][4] = { + { 0.6f, 0.5f, 0.2f, 0.4f }, + { 0.8f, 0.7f, 0.35f, 0.7f }, + { 1.0f, 1.0f, 0.8f, 1.0f }, +}; + +typedef struct { + /* 0x0 */ s16 unk_00; + /* 0x2 */ s16 unk_02; + /* 0x4 */ f32 unk_04; + /* 0x8 */ f32 unk_08; +} ObjDrifticeDataStruct; // size = 0xC + +static ObjDrifticeDataStruct D_80A67694[] = { + { 0x12C, 0x64, 1.3f, 2.0f }, + { 0x258, 0x1F4, 1.2f, 1.8f }, + { 0x4B0, 0x3E8, 1.1f, 1.5f }, +}; + +static ObjDrifticeDataStruct D_80A676B8[] = { { 0x320, 0x190, 200.0f, 400.0f }, { 0x5DC, 0x258, 100.0f, 300.0f } }; + +static ObjDrifticeDataStruct D_80A676D0[] = { + { 0x12C, 0x64, 300.0f, 700.0f }, + { 0x258, 0x258, 200.0f, 400.0f }, + { 0x4B0, 0x4B0, 100.0f, 300.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP), }; +void func_80A66570(ObjDriftice* this, s32 arg1) { + Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, &this->unk_16C[arg1]); +} + +void func_80A665AC(s16* arg0, s16 arg1) { + if (arg1 < *arg0) { + *arg0 = arg1; + } else if (*arg0 < -arg1) { + *arg0 = -arg1; + } +} + +f32 func_80A665EC(ObjDrifticeStruct* arg0, ObjDriftice* this) { + f32 phi_f2 = 0.0f; + f32 sp20; + + if (this->unk_248 >= 10) { + sp20 = -8.0f; + } else if (this->unk_248 < -9) { + sp20 = 0.0f; + } else if (this->unk_248 > 0) { + sp20 = (Math_CosS(fabsf(this->unk_248) * (0x8000 * 0.1f)) - 1.0f) * 4.0f; + } else { + sp20 = (Math_CosS(fabsf(this->unk_248) * (0x8000 * 0.1f)) + 1.0f) * -4.0f; + } + + if (this->unk_248 > 0) { + if (arg0->unk_00.unk_00 > 0) { + arg0->unk_00.unk_00--; + } else { + arg0->unk_00.unk_00 = Rand_S16Offset(30, 70); + arg0->unk_00.unk_04 = Rand_S16Offset(1000, 1000); + arg0->unk_00.unk_0C = (Rand_ZeroOne() * 1.5f) + 1.0f; + arg0->unk_00.unk_10 = fabsf(arg0->unk_00.unk_0C - arg0->unk_00.unk_08) * 0.05f; + } + } else { + arg0->unk_00.unk_00 = 0; + arg0->unk_00.unk_0C = phi_f2; + arg0->unk_00.unk_10 = (fabsf(arg0->unk_00.unk_0C - arg0->unk_00.unk_08) * 0.05f) + 0.02f; + } + + arg0->unk_00.unk_02 += arg0->unk_00.unk_04; + Math_StepToF(&arg0->unk_00.unk_08, arg0->unk_00.unk_0C, arg0->unk_00.unk_10); + + sp20 += (Math_SinS(arg0->unk_00.unk_02) * arg0->unk_00.unk_08); + return sp20; +} + +f32 func_80A667F0(ObjDrifticeStruct3* arg0, ObjDriftice* this) { + f32 temp_f20 = 0.0f; + ObjDrifticeStruct3* temp_s0; + s32 i; + + for (i = 0; i < 3; i++) { + temp_s0 = &arg0[i]; + + if (temp_s0->unk_00 > 0) { + temp_s0->unk_00--; + } else { + temp_s0->unk_00 = Rand_S16Offset(30, 70); + temp_s0->unk_04 = Rand_S16Offset(D_80A67694[i].unk_00, D_80A67694[i].unk_02); + temp_s0->unk_0C = D_80A67694[i].unk_04 + (D_80A67694[i].unk_08 * Rand_ZeroOne()); + temp_s0->unk_10 = fabsf(temp_s0->unk_0C - temp_s0->unk_08) * 0.05f; + } + temp_s0->unk_02 += temp_s0->unk_04; + Math_StepToF(&temp_s0->unk_08, temp_s0->unk_0C, temp_s0->unk_10); + temp_f20 += Math_SinS(temp_s0->unk_02) * temp_s0->unk_08; + } + + return temp_f20; +} + +#ifdef NON_MATCHING +void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* arg3) { + ObjDrifticeStruct3* temp_s0; + f32 temp_f22 = 0.0f; + s16 phi_s0; + s32 i; + + if (this->unk_248 > 0) { + f32 temp_f20 = this->dyna.actor.xzDistToPlayer * this->unk_240 * 0.0007075472f; + if (temp_f20 > 1.0f) { + temp_f20 = 1.0f; + } else if (temp_f20 < 0.01f) { + temp_f20 = 0.01f; + } + + Math_StepToS(&arg0->unk_00[1], 1200.0f * temp_f20, 0x64); + phi_s0 = 2500.0f * temp_f20; + Math_StepToS(&arg0->unk_00[3], Math_CosS(arg0->unk_00[2] * 6.5536f) * (120.0f * temp_f20), 0x28); + Math_StepToF(&arg0->unk_08, 1.0f, 0.02f); + } else { + Math_StepToS(&arg0->unk_00[1], 0, 0x96); + phi_s0 = 0; + Math_StepToS(&arg0->unk_00[3], 20, 7); + Math_StepToF(&arg0->unk_08, 0.0f, 0.02f); + } + Math_ScaledStepToS(arg0->unk_00, this->dyna.actor.yawTowardsPlayer, arg0->unk_00[1]); + *arg3 = arg0->unk_00[0]; + Math_ScaledStepToS(&arg0->unk_00[2], phi_s0, arg0->unk_00[3]); + + for (i = 0; i < 2; i++) { + temp_s0 = &arg0->unk_0C[i]; + + if (temp_s0->unk_00 > 0) { + temp_s0->unk_00--; + } else { + temp_s0->unk_00 = Rand_S16Offset(30, 70); + temp_s0->unk_04 = Rand_S16Offset(D_80A676B8[i].unk_00, D_80A676B8[i].unk_02); + temp_s0->unk_0C = D_80A676B8[i].unk_04 + (D_80A676B8[i].unk_08 * Rand_ZeroOne()); + temp_s0->unk_10 = fabsf(temp_s0->unk_0C - temp_s0->unk_08) * 0.033333335f; + } + temp_s0->unk_02 += temp_s0->unk_04; + Math_StepToF(&temp_s0->unk_08, temp_s0->unk_0C, temp_s0->unk_10); + temp_f22 += Math_SinS(temp_s0->unk_02) * temp_s0->unk_08; + } + + temp_f22 *= arg0->unk_08; + + *arg2 = (s32)temp_f22 + arg0->unk_00[2]; +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66930.s") #endif -extern InitChainEntry D_80A676F4[]; +void func_80A66C4C(ObjDrifticeStruct4* arg0, ObjDriftice* this, s16* arg2, s16* arg3) { + ObjDrifticeStruct3* temp_s0; + f32 temp_f20 = 0.0f; + s32 i; -extern UNK_TYPE D_060016A0; -extern UNK_TYPE D_06001AA8; + if (arg0->unk_00[0] > 0) { + arg0->unk_00[0]--; + } else { + arg0->unk_00[0] = Rand_S16Offset(30, 70); + arg0->unk_00[2] = Rand_S16Offset(-200, 200); + arg0->unk_00[4] = Rand_S16Offset(-400, 400); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66570.s") + Math_StepToS(&arg0->unk_00[1], arg0->unk_00[2], 0x32); + Math_StepToS(&arg0->unk_00[3], arg0->unk_00[4], 0x32); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A665AC.s") + *arg3 = arg0->unk_00[3] + arg0->unk_00[1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A665EC.s") + for (i = 0; i < 3; i++) { + temp_s0 = &arg0->unk_0C[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A667F0.s") + if (temp_s0->unk_00 > 0) { + temp_s0->unk_00--; + } else { + temp_s0->unk_00 = Rand_S16Offset(30, 70); + temp_s0->unk_04 = Rand_S16Offset(D_80A676D0[i].unk_00, D_80A676D0[i].unk_02); + temp_s0->unk_0C = D_80A676D0[i].unk_04 + (D_80A676D0[i].unk_08 * Rand_ZeroOne()); + temp_s0->unk_10 = fabsf(temp_s0->unk_0C - temp_s0->unk_08) * 0.033333335f; + } + temp_s0->unk_02 += temp_s0->unk_04; + Math_StepToF(&temp_s0->unk_08, temp_s0->unk_0C, temp_s0->unk_10); + temp_f20 += Math_SinS(temp_s0->unk_02) * temp_s0->unk_08; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66930.s") + *arg2 = temp_f20; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66C4C.s") +void func_80A66E30(ObjDrifticeStruct* arg0, ObjDriftice* this) { + f32 temp; + f32* temp_s1 = D_80A67664[OBJDRIFTICE_GET_ROT(&this->dyna.actor) - 1]; + s16 sp36; + s16 sp34; + s16 sp32; + s16 sp30; + f32 sp2C; + f32 sp28; + f32 sp24; + s16 sp22; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66E30.s") + sp2C = func_80A665EC(arg0, this); + sp28 = func_80A667F0(arg0->unk_14, this); + func_80A66930(&arg0->unk_50, this, &sp32, &sp30); + func_80A66C4C(&arg0->unk_84, this, &sp36, &sp34); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/ObjDriftice_Init.s") + this->dyna.actor.shape.yOffset = this->unk_240 * ((sp28 * temp_s1[1]) + (sp2C * temp_s1[0])); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/ObjDriftice_Destroy.s") + sp24 = (sp32 * temp_s1[2]) + (sp36 * temp_s1[3]) * (temp = 1.0f); + sp22 = (sp34 + sp30) - this->dyna.actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671A8.s") + this->dyna.actor.shape.rot.x = Math_CosS(sp22) * sp24; + func_80A665AC(&this->dyna.actor.shape.rot.x, 0xA28); + this->dyna.actor.shape.rot.z = -Math_SinS(sp22) * sp24; + func_80A665AC(&this->dyna.actor.shape.rot.z, 0xA28); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671BC.s") +void ObjDriftice_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjDriftice* this = THIS; + f32* sp2C = D_80A67620[OBJDRIFTICE_GET_3(&this->dyna.actor)]; + Path* path; + s32 phi_a1; + s32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671CC.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.world.rot.z = 0; + + Actor_SetScale(&this->dyna.actor, sp2C[0] * 0.035377357f); + this->dyna.actor.uncullZoneScale = sp2C[1]; + this->dyna.actor.uncullZoneDownward = sp2C[2]; + this->unk_240 = 1.0f / this->dyna.actor.scale.x; + this->unk_23C = D_80A67644[OBJDRIFTICE_GET_E00(&this->dyna.actor)]; + + sp20 = 0; + if (this->unk_23C < 0.01f) { + sp20 = 1; + } + + this->unk_244 = thisx->home.rot.z * 45.511112f; + + phi_a1 = 0; + if (sp20 == 0) { + phi_a1 = 1; + } + + if (thisx->home.rot.z != 0) { + phi_a1 |= 3; + } + + DynaPolyActor_Init(&this->dyna, phi_a1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_driftice_Colheader_001AA8); + + if (sp20 != 0) { + func_80A671A8(this); + } else { + this->dyna.actor.flags |= ACTOR_FLAG_10; + + path = &globalCtx->setupPathList[OBJDRIFTICE_GET_1FC(&this->dyna.actor)]; + this->unk_164 = 0; + this->unk_160 = path->count - 1; + this->unk_168 = 1; + + this->unk_16C = Lib_SegmentedToVirtual(path->points); + func_80A66570(this, this->unk_164); + func_80A671CC(this); + } +} + +void ObjDriftice_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjDriftice* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80A671A8(ObjDriftice* this) { + this->actionFunc = func_80A671BC; +} + +void func_80A671BC(ObjDriftice* this, GlobalContext* globalCtx) { +} + +void func_80A671CC(ObjDriftice* this) { + this->actionFunc = func_80A671E0; +} + +#ifdef NON_MATCHING +// stack +void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx) { + f32 phi_f0; + Vec3f sp40; + f32 sp3C; + f32 phi_f12; + Vec3s* points; + s32 sp30; + Vec3s* points2; + + Math_Vec3s_ToVec3f(&sp40, &(&this->unk_16C[this->unk_164])[this->unk_168]); + Math_Vec3f_Diff(&sp40, &this->dyna.actor.world.pos, &this->dyna.actor.velocity); + + sp3C = Math3D_Vec3fMagnitude(&this->dyna.actor.velocity); + if (sp3C < (this->unk_23C * 8.0f)) { + phi_f0 = this->unk_23C * 0.4f; + phi_f12 = this->unk_23C * 0.05f; + } else { + phi_f0 = this->unk_23C; + phi_f12 = this->unk_23C * 0.13f; + } + + Math_StepToF(&this->dyna.actor.speedXZ, phi_f0, phi_f12); + + if ((this->dyna.actor.speedXZ + 0.05f) < sp3C) { + Math_Vec3f_Scale(&this->dyna.actor.velocity, this->dyna.actor.speedXZ / sp3C); + this->dyna.actor.world.pos.x += this->dyna.actor.velocity.x; + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; + this->dyna.actor.world.pos.z += this->dyna.actor.velocity.z; + } else { + sp30 = true; + this->unk_164 += this->unk_168; + + if (1) {} + + this->dyna.actor.speedXZ *= 0.5f; + if (((this->unk_164 >= this->unk_160) && (this->unk_168 > 0)) || + ((this->unk_164 <= 0) && (this->unk_168 < 0))) { + if (!OBJDRIFTICE_GET_1000(&this->dyna.actor)) { + this->unk_168 = -this->unk_168; + func_80A674A8(this); + } else { + points = &this->unk_16C[this->unk_160]; + + if (this->unk_168 > 0) { + this->unk_164 = 0; + } else { + this->unk_164 = this->unk_160; + } + + points2 = &this->unk_16C[0]; + if ((points2->x != points->x) || (points2->y != points->y) || (points2->z != points->z)) { + func_80A6743C(this); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + sp30 = false; + } + } + } + + if (sp30) { + func_80A66570(this, this->unk_164); + } + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671E0.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A6743C.s") +void func_80A6743C(ObjDriftice* this) { + this->actionFunc = func_80A67450; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A67450.s") +void func_80A67450(ObjDriftice* this, GlobalContext* globalCtx) { + if (this->unk_248 < 0) { + func_80A66570(this, this->unk_164); + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_80A671CC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A674A8.s") +void func_80A674A8(ObjDriftice* this) { + this->unk_24C = 10; + this->actionFunc = func_80A674C4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A674C4.s") +void func_80A674C4(ObjDriftice* this, GlobalContext* globalCtx) { + this->unk_24C--; + if (this->unk_24C <= 0) { + this->dyna.actor.speedXZ = 0.0f; + func_80A671CC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/ObjDriftice_Update.s") +void ObjDriftice_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjDriftice* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/ObjDriftice_Draw.s") + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (this->unk_248 < 0) { + this->unk_248 = 1; + } else { + this->unk_248++; + } + } else { + if (this->unk_248 > 0) { + this->unk_248 = -1; + } else { + this->unk_248--; + } + } + + this->dyna.actor.shape.rot.y += this->unk_244; + + this->actionFunc(this, globalCtx); + + if (OBJDRIFTICE_GET_ROT(&this->dyna.actor) && (this->dyna.actor.flags & ACTOR_FLAG_40)) { + func_80A66E30(&this->unk_170, this); + } +} + +void ObjDriftice_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjDriftice* this = THIS; + + Gfx_DrawDListOpa(globalCtx, object_driftice_DL_0016A0); +} diff --git a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h index cdfc01f17..190fbdcb6 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h @@ -7,11 +7,53 @@ struct ObjDriftice; typedef void (*ObjDrifticeActionFunc)(struct ObjDriftice*, GlobalContext*); +#define OBJDRIFTICE_GET_3(thisx) ((thisx)->params & 3) +#define OBJDRIFTICE_GET_1FC(thisx) (((thisx)->params >> 2) & 0x7F) +#define OBJDRIFTICE_GET_E00(thisx) (((thisx)->params >> 9) & 7) +#define OBJDRIFTICE_GET_1000(thisx) (((thisx)->params >> 0xC) & 1) +#define OBJDRIFTICE_GET_ROT(thisx) ((thisx)->home.rot.x & 3) + +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; + /* 0x04 */ s16 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; +} ObjDrifticeStruct3; // size = 0x14 + +typedef struct { + /* 0x00 */ s16 unk_00[2]; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ ObjDrifticeStruct3 unk_0C[2]; +} ObjDrifticeStruct2; // size = 0x34 + +typedef struct { + /* 0x00 */ s16 unk_00[6]; + /* 0x0C */ ObjDrifticeStruct3 unk_0C[3]; +} ObjDrifticeStruct4; // size = 0x48 + +typedef struct { + /* 0x00 */ ObjDrifticeStruct3 unk_00; + /* 0x14 */ ObjDrifticeStruct3 unk_14[3]; + /* 0x50 */ ObjDrifticeStruct2 unk_50; + /* 0x84 */ ObjDrifticeStruct4 unk_84; +} ObjDrifticeStruct; // size = 0xCC + typedef struct ObjDriftice { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjDrifticeActionFunc actionFunc; - /* 0x0160 */ char unk_160[0xF0]; + /* 0x0160 */ s32 unk_160; + /* 0x0164 */ s32 unk_164; + /* 0x0168 */ s32 unk_168; + /* 0x016C */ Vec3s* unk_16C; + /* 0x0170 */ ObjDrifticeStruct unk_170; + /* 0x023C */ f32 unk_23C; + /* 0x0240 */ f32 unk_240; + /* 0x0244 */ s16 unk_244; + /* 0x0248 */ s32 unk_248; + /* 0x024C */ s32 unk_24C; } ObjDriftice; // size = 0x250 extern const ActorInit Obj_Driftice_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 08ee2e9d7..300fefaf4 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1844,11 +1844,6 @@ D_06000BA0 = 0x06000BA0; D_06003FD0 = 0x06003FD0; D_06004160 = 0x06004160; -// ovl_Obj_Driftice - -D_060016A0 = 0x060016A0; -D_06001AA8 = 0x06001AA8; - // ovl_Obj_Entotu D_06000158 = 0x06000158; From 69c0e15a4570cc2a9d820c253490e08e5457d84e Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Fri, 25 Mar 2022 18:54:05 -0700 Subject: [PATCH 114/257] EffectSsBubble OK (#702) * Decompile eff_ss_bubble * Document effBubble stuff in gameplay keep * newline * Formatting is hard * PR suggestions * Amplitude -> Max --- assets/xml/objects/gameplay_keep.xml | 6 +- spec | 3 +- src/overlays/actors/ovl_En_Fish2/z_en_fish2.c | 6 +- .../ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c | 92 +++++++++++++++++-- tools/disasm/variables.txt | 2 +- 5 files changed, 94 insertions(+), 15 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 856e3d92b..ded5f8b67 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1003,7 +1003,7 @@ - + @@ -1423,8 +1423,8 @@ - - + + diff --git a/spec b/spec index 6771502b6..8927e5dfd 100644 --- a/spec +++ b/spec @@ -1860,8 +1860,7 @@ beginseg name "ovl_Effect_Ss_Bubble" compress include "build/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.o" - include "build/data/ovl_Effect_Ss_Bubble/ovl_Effect_Ss_Bubble.data.o" - include "build/data/ovl_Effect_Ss_Bubble/ovl_Effect_Ss_Bubble.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Bubble/ovl_Effect_Ss_Bubble_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c index 21b42c4a4..5512b00b7 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -1094,9 +1094,9 @@ void func_80B2ADB0(EnFish2* this, Vec3f* vec, s16 arg2) { TexturePtr phi_v0; if (Rand_ZeroOne() < 0.5f) { - phi_v0 = gameplay_keep_Tex_091CE0; + phi_v0 = gEffBubble2Tex; } else { - phi_v0 = gameplay_keep_Tex_091BE0; + phi_v0 = gEffBubble1Tex; } ptr->unk_20 = VIRTUAL_TO_PHYSICAL(SEGMENTED_TO_VIRTUAL(phi_v0)); @@ -1168,7 +1168,7 @@ void func_80B2B180(EnFish2* this, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_OPA_DISP++, 150, 150, 150, 0); gSPSegment(POLY_OPA_DISP++, 0x08, ptr->unk_20); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0301B0); + gSPDisplayList(POLY_OPA_DISP++, gEffBubbleDL); } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c index d18f57bb7..41a8f92ff 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c +++ b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c @@ -5,23 +5,103 @@ */ #include "z_eff_ss_bubble.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rScale regs[0] +#define rVecAdjX regs[1] +#define rVecAdjZ regs[2] #define PARAMS ((EffectSsBubbleInitParams*)initParamsx) -s32 EffectSsBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsBubble_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Bubble_InitVars = { EFFECT_SS_BUBBLE, EffectSsBubble_Init, }; -#endif +static f32 sVecAdjMaximums[] = { 291.0f, 582.0f, 1600.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bubble/EffectSsBubble_Init.s") +u32 EffectSsBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsBubbleInitParams* initParams = (EffectSsBubbleInitParams*)initParamsx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bubble/EffectSsBubble_Draw.s") + { + TexturePtr tex = (Rand_ZeroOne() < 0.5f) ? gEffBubble1Tex : gEffBubble2Tex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bubble/EffectSsBubble_Update.s") + this->gfx = VIRTUAL_TO_PHYSICAL(SEGMENTED_TO_VIRTUAL(tex)); + } + + this->pos.x = ((Rand_ZeroOne() - 0.5f) * initParams->xzPosRandScale) + initParams->pos.x; + this->pos.y = (((Rand_ZeroOne() - 0.5f) * initParams->yPosRandScale) + initParams->yPosOffset) + initParams->pos.y; + this->pos.z = ((Rand_ZeroOne() - 0.5f) * initParams->xzPosRandScale) + initParams->pos.z; + Math_Vec3f_Copy(&this->vec, &this->pos); + this->life = 1; + this->rScale = (((Rand_ZeroOne() * 0.5f) + 1.0f) * initParams->scale) * 100.0f; + this->draw = EffectSsBubble_Draw; + this->update = EffectSsBubble_Update; + + return 1; +} + +void EffectSsBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + f32 scale = this->rScale / 100.0f; + + OPEN_DISPS(gfxCtx); + + Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 150, 150, 150, 0); + gSPSegment(POLY_OPA_DISP++, 0x08, this->gfx); + gSPDisplayList(POLY_OPA_DISP++, gEffBubbleDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsBubble_Update(GlobalContext* globalCtx2, u32 index, EffectSs* this) { + WaterBox* waterBox; + f32 waterSurfaceY = this->pos.y; + Vec3f ripplePos; + GlobalContext* globalCtx = globalCtx2; + + if (!WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->pos.x, this->pos.z, &waterSurfaceY, &waterBox)) { + this->life = -1; + return; + } + if (waterSurfaceY < this->pos.y) { + ripplePos.x = this->pos.x; + ripplePos.y = waterSurfaceY; + ripplePos.z = this->pos.z; + EffectSsGRipple_Spawn(globalCtx, &ripplePos, 0, 80, 0); + this->life = -1; + label: + return; + } + if (((globalCtx->gameplayFrames + index) % 8) == 0) { + CollisionPoly* colPoly; + u32 speed; + s16 direction; + f32 rVecAdjMax; + + BgCheck_EntityRaycastFloor2_1(globalCtx, &globalCtx->colCtx, &colPoly, &this->pos); + speed = SurfaceType_GetConveyorSpeed(&globalCtx->colCtx, colPoly, BGCHECK_SCENE); + if ((speed != 0) && !SurfaceType_GetConveyorType(&globalCtx->colCtx, colPoly, BGCHECK_SCENE)) { + direction = SurfaceType_GetConveyorDirection(&globalCtx->colCtx, colPoly, BGCHECK_SCENE) << 0xA; + rVecAdjMax = sVecAdjMaximums[speed - 1]; + this->rVecAdjX = Math_SinS(direction) * rVecAdjMax; + this->rVecAdjZ = Math_CosS(direction) * rVecAdjMax; + } + } + this->vec.x += this->rVecAdjX / 100.0f; + this->vec.z += this->rVecAdjZ / 100.0f; + this->pos.x = ((Rand_ZeroOne() * 0.5f) - 0.25f) + this->vec.x; + this->accel.y = (Rand_ZeroOne() - 0.3f) * 0.2f; + this->pos.z = (Rand_ZeroOne() * 0.5f - 0.25f) + this->vec.z; + this->life++; +} diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 7861cff5a..f509fff70 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -9006,7 +9006,7 @@ 0x80979560:("Effect_Ss_D_Fire_InitVars","UNK_TYPE1","",0x1), 0x80979568:("D_80979568","UNK_TYPE1","",0x1), 0x80979AB0:("Effect_Ss_Bubble_InitVars","UNK_TYPE1","",0x8), - 0x80979AB8:("D_80979AB8","UNK_TYPE1","",0x1), + 0x80979AB8:("D_80979AB8","f32","[3]",0xC), 0x80979AD0:("D_80979AD0","f32","",0x4), 0x80979AD4:("D_80979AD4","f32","",0x4), 0x80979FF0:("Effect_Ss_G_Ripple_InitVars","UNK_TYPE1","",0x1), From 2746266881f4ba23a5ff3fd84f0065c6bda78457 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 26 Mar 2022 02:04:42 +0000 Subject: [PATCH 115/257] En_Hidden_Nuts (#705) * En_Hidden_Nuts * PR --- spec | 3 +- .../ovl_En_Hidden_Nuts/z_en_hidden_nuts.c | 404 ++++++++++++++++-- .../ovl_En_Hidden_Nuts/z_en_hidden_nuts.h | 23 +- undefined_syms.txt | 5 - 4 files changed, 400 insertions(+), 35 deletions(-) diff --git a/spec b/spec index 8927e5dfd..33b43d0db 100644 --- a/spec +++ b/spec @@ -4769,8 +4769,7 @@ beginseg name "ovl_En_Hidden_Nuts" compress include "build/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.o" - include "build/data/ovl_En_Hidden_Nuts/ovl_En_Hidden_Nuts.data.o" - include "build/data/ovl_En_Hidden_Nuts/ovl_En_Hidden_Nuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Hidden_Nuts/ovl_En_Hidden_Nuts_reloc.o" endseg beginseg 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 c19e596ac..d4f22654e 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 @@ -5,6 +5,7 @@ */ #include "z_en_hidden_nuts.h" +#include "objects/object_hintnuts/object_hintnuts.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_2000000) @@ -15,15 +16,20 @@ void EnHiddenNuts_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHiddenNuts_Update(Actor* thisx, GlobalContext* globalCtx); void EnHiddenNuts_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80BDB268(EnHiddenNuts* this); void func_80BDB2B8(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDB580(EnHiddenNuts* this); void func_80BDB59C(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDB788(EnHiddenNuts* this); void func_80BDB7E8(EnHiddenNuts* this, GlobalContext* globalCtx); void func_80BDB8F4(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDB930(EnHiddenNuts* this); void func_80BDB978(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDBA28(EnHiddenNuts* this, GlobalContext* globalCtx); void func_80BDBB48(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDBE70(EnHiddenNuts* this, GlobalContext* globalCtx); void func_80BDBED4(EnHiddenNuts* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Hidden_Nuts_InitVars = { ACTOR_EN_HIDDEN_NUTS, ACTORCAT_PROP, @@ -36,51 +42,397 @@ const ActorInit En_Hidden_Nuts_InitVars = { (ActorFunc)EnHiddenNuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BDC0D0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 30, 20, 0, { 0, 0, 0 } }, }; -#endif +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, +}; -extern ColliderCylinderInit D_80BDC0D0; +u8 D_80BDC120[] = { + ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, +}; -extern UNK_TYPE D_060024CC; +void EnHiddenNuts_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHiddenNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/EnHiddenNuts_Init.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_hintnuts_Skel_0023B8.sh, &object_hintnuts_Anim_0024CC, + this->jointTable, this->morphTable, 10); + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/EnHiddenNuts_Destroy.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB1B4.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB268.s") + this->unk_21E = ENHIDDENNUTS_GET_F80(&this->actor); + this->switchFlag = ENHIDDENNUTS_GET_SWITCHFLAG(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB2B8.s") + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB580.s") + if ((this->switchFlag >= 0) && Flags_GetSwitch(globalCtx, this->switchFlag)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB59C.s") + if (this->unk_21E == 0x1F) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB788.s") + this->path = func_8013D648(globalCtx, this->unk_21E, 0x3F); + this->unk_226 = this->actor.cutscene; + func_801A5080(2); + func_80BDB268(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB7E8.s") +void EnHiddenNuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHiddenNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB8F4.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB930.s") +void func_80BDB1B4(EnHiddenNuts* this, s32 arg1) { + f32 sp34; + f32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB978.s") + 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; + } + Animation_Change(&this->skelAnime, D_80BDC0FC[this->unk_220], 1.0f, sp34, this->unk_22C, D_80BDC120[this->unk_220], + sp30); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDBA28.s") +void func_80BDB268(EnHiddenNuts* this) { + this->actor.textId = 0x234; + this->unk_228 = 1600.0f; + this->actor.shape.yOffset = 1600.0f; + func_80BDB1B4(this, 1); + this->unk_21A = 0; + this->actionFunc = func_80BDB2B8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDBB48.s") +void func_80BDB2B8(EnHiddenNuts* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDBE70.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NEMURI_SLEEP - SFX_FLAG); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDBED4.s") + if (player->stateFlags2 & 0x8000000) { + if (this->unk_20A == 0) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + this->unk_20A = 1; + } + } else { + this->unk_20A = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/EnHiddenNuts_Update.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { + func_80BDB580(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/EnHiddenNuts_Draw.s") + if (this->unk_218 == 0) { + Vec3f sp94 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp88 = { 0.0f, 0.0f, 0.0f }; + Color_RGBA8 sp84 = { 255, 255, 255, 255 }; + Color_RGBA8 sp80 = { 150, 150, 150, 0 }; + Vec3f sp74; + + for (i = 0; i < 3; i++) { + sp94.y = Rand_ZeroFloat(1.0f) + 1.0f; + + Math_Vec3f_Copy(&sp74, &this->actor.world.pos); + + sp74.x += randPlusMinusPoint5Scaled(15.0f); + sp74.z += randPlusMinusPoint5Scaled(15.0f); + + EffectSsDtBubble_SpawnCustomColor(globalCtx, &sp74, &sp94, &sp88, &sp84, &sp80, Rand_S16Offset(120, 90), 30, + 1); + } + this->unk_218 = 30; + } + + if (!(this->actor.xzDistToPlayer > 120.0f)) { + if ((globalCtx->msgCtx.ocarinaMode == 3) && (globalCtx->msgCtx.unk1202E == 0)) { + globalCtx->msgCtx.ocarinaMode = 4; + func_80BDB788(this); + } else if (func_801A5100() == 2) { + func_80BDB788(this); + } else { + func_800B8614(&this->actor, globalCtx, BREG(13) + 100.0f); + } + } +} + +void func_80BDB580(EnHiddenNuts* this) { + this->unk_21A = 1; + this->actionFunc = func_80BDB59C; +} + +void func_80BDB59C(EnHiddenNuts* this, GlobalContext* globalCtx) { + s32 i; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NEMURI_SLEEP - SFX_FLAG); + + if (this->unk_218 == 0) { + Vec3f sp98 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp8C = { 0.0f, 0.0f, 0.0f }; + Color_RGBA8 sp88 = { 255, 255, 255, 255 }; + Color_RGBA8 sp84 = { 150, 150, 150, 0 }; + Vec3f sp78; + + for (i = 0; i < 3; i++) { + sp98.y = Rand_ZeroFloat(1.0f) + 1.0f; + + Math_Vec3f_Copy(&sp78, &this->actor.world.pos); + + sp78.x += randPlusMinusPoint5Scaled(15.0f); + sp78.z += randPlusMinusPoint5Scaled(15.0f); + + EffectSsDtBubble_SpawnCustomColor(globalCtx, &sp78, &sp98, &sp8C, &sp88, &sp84, Rand_S16Offset(120, 90), 30, + 1); + } + this->unk_218 = 30; + } + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + func_801477B4(globalCtx); + func_80BDB268(this); + } +} + +void func_80BDB788(EnHiddenNuts* this) { + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_8000000; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); + this->unk_21A = 2; + this->actionFunc = func_80BDB7E8; +} + +void func_80BDB7E8(EnHiddenNuts* this, GlobalContext* globalCtx) { + Vec3f sp3C; + + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_226); + return; + } + + if (!ActorCutscene_GetCanPlayNext(this->unk_226)) { + ActorCutscene_SetIntentToPlay(this->unk_226); + return; + } + + ActorCutscene_StartAndSetUnkLinkFields(this->unk_226, &this->actor); + this->unk_228 = -1200.0f; + + Math_Vec3f_Copy(&sp3C, &this->actor.world.pos); + sp3C.y = this->actor.floorHeight + 30.0f; + + EffectSsHahen_SpawnBurst(globalCtx, &sp3C, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + func_80BDB1B4(this, 7); + this->actionFunc = func_80BDB8F4; +} + +void func_80BDB8F4(EnHiddenNuts* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->unk_22C <= curFrame) { + func_80BDB930(this); + } +} + +void func_80BDB930(EnHiddenNuts* this) { + func_80BDB1B4(this, 3); + this->unk_21A = 3; + this->unk_228 = 500.0f; + this->actionFunc = func_80BDB978; +} + +void func_80BDB978(EnHiddenNuts* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 8.0f) || + Animation_OnFrame(&this->skelAnime, 18.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUT_FAINT); + } + + if (this->unk_22C <= curFrame) { + this->unk_224++; + if (this->unk_224 >= 2) { + func_80BDBA28(this, globalCtx); + } + } +} + +void func_80BDBA28(EnHiddenNuts* this, GlobalContext* globalCtx) { + Vec3f sp44; + + func_80BDB1B4(this, 2); + this->unk_228 = 0.0f; + + Math_Vec3f_Copy(&sp44, &this->actor.world.pos); + sp44.y = this->actor.floorHeight + 30.0f; + + EffectSsHahen_SpawnBurst(globalCtx, &sp44, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + this->unk_208 = 1; + + if ((this->path != NULL) && !func_8013D68C(this->path, this->unk_208, &this->unk_20C)) { + Actor_MarkForDeath(&this->actor); + } + + this->actor.speedXZ = 2.0f; + this->actor.gravity = -2.0f; + this->actor.velocity.y = 4.0f; + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_20C); + this->unk_21A = 4; + this->actionFunc = func_80BDBB48; +} + +void func_80BDBB48(EnHiddenNuts* this, GlobalContext* globalCtx) { + s32 pad[3]; + f32 sp58 = this->skelAnime.curFrame; + WaterBox* sp54; + f32 sp50; + s16 sp4E = 0; + Vec3f sp40; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, + &sp54) && + (this->actor.world.pos.y < sp50)) { + this->actor.velocity.y = 0.0f; + Math_Vec3f_Copy(&sp40, &this->actor.world.pos); + sp40.y = sp50; + this->actor.gravity = 0.0f; + + if ((globalCtx->gameplayFrames % 8) == 0) { + EffectSsGRipple_Spawn(globalCtx, &sp40, 650, 3150, 0); + } + + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f) || + Animation_OnFrame(&this->skelAnime, 10.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WALK_WATER); + sp4E = 1; + } + } + + if ((sp4E != 0) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f) || + Animation_OnFrame(&this->skelAnime, 10.0f))) { + Actor_PlaySfxAtPos(&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) { + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + func_80BDB1B4(this, 6); + } + } else { + Math_ApproachF(&this->actor.world.pos.x, this->unk_20C.x, 0.5f, + fabsf(Math_SinS(this->actor.world.rot.y) * (BREG(33) + 8.0f))); + Math_ApproachF(&this->actor.world.pos.z, this->unk_20C.z, 0.5f, + fabsf(Math_CosS(this->actor.world.rot.y) * (BREG(33) + 8.0f))); + + if ((sqrtf(SQ(this->actor.world.pos.x - this->unk_20C.x) + SQ(this->actor.world.pos.z - this->unk_20C.z)) < + 4.0f) && + (this->path != NULL)) { + this->unk_208++; + if (this->unk_208 >= this->path->count) { + func_80BDBE70(this, globalCtx); + } else if ((this->path != NULL) && !func_8013D68C(this->path, this->unk_208, &this->unk_20C)) { + Actor_MarkForDeath(&this->actor); + } + } + } +} + +void func_80BDBE70(EnHiddenNuts* this, GlobalContext* globalCtx) { + if (this->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, this->switchFlag); + } + func_80BDB1B4(this, 8); + this->unk_21A = 5; + this->actionFunc = func_80BDBED4; +} + +void func_80BDBED4(EnHiddenNuts* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + Vec3f sp38; + + if (this->unk_22C <= curFrame) { + Math_Vec3f_Copy(&sp38, &this->actor.world.pos); + sp38.y = this->actor.floorHeight; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + EffectSsHahen_SpawnBurst(globalCtx, &sp38, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + Actor_MarkForDeath(&this->actor); + } +} + +void EnHiddenNuts_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHiddenNuts* this = THIS; + + if (this->unk_218 != 0) { + this->unk_218--; + } + + Actor_SetFocus(&this->actor, 20.0f); + SkelAnime_Update(&this->skelAnime); + + this->actionFunc(this, globalCtx); + + Math_ApproachF(&this->actor.shape.yOffset, this->unk_228, 0.5f, 200.0f); + + if (this->unk_21A >= 4) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 40.0f, 0x1D); + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void EnHiddenNuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHiddenNuts* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); +} 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 08dc574fe..baff911b6 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 @@ -7,11 +7,30 @@ struct EnHiddenNuts; typedef void (*EnHiddenNutsActionFunc)(struct EnHiddenNuts*, GlobalContext*); +#define ENHIDDENNUTS_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define ENHIDDENNUTS_GET_F80(thisx) (((thisx)->params >> 7) & 0x1F) + typedef struct EnHiddenNuts { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xBC]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[10]; + /* 0x01C4 */ Vec3s morphTable[10]; /* 0x0200 */ EnHiddenNutsActionFunc actionFunc; - /* 0x0204 */ char unk_204[0x7C]; + /* 0x0204 */ Path* path; + /* 0x0208 */ s16 unk_208; + /* 0x020A */ u8 unk_20A; + /* 0x020C */ Vec3f unk_20C; + /* 0x0218 */ s16 unk_218; + /* 0x021A */ s16 unk_21A; + /* 0x021C */ s16 switchFlag; + /* 0x021E */ s16 unk_21E; + /* 0x0220 */ s32 unk_220; + /* 0x0224 */ s16 unk_224; + /* 0x0226 */ s16 unk_226; + /* 0x0228 */ f32 unk_228; + /* 0x022C */ f32 unk_22C; + /* 0x0230 */ UNK_TYPE1 unk230[4]; + /* 0x0234 */ ColliderCylinder collider; } EnHiddenNuts; // size = 0x280 extern const ActorInit En_Hidden_Nuts_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 300fefaf4..f18b4e54b 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1314,11 +1314,6 @@ D_0600B644 = 0x0600B644; D_0600F248 = 0x0600F248; D_06012A58 = 0x06012A58; -// ovl_En_Hidden_Nuts - -D_060023B8 = 0x060023B8; -D_060024CC = 0x060024CC; - // ovl_En_Horse D_06008C68 = 0x06008C68; From 9362fee5e87a779ae876cfaaf9f989cfadc0c55a Mon Sep 17 00:00:00 2001 From: Parker Burnett Date: Fri, 25 Mar 2022 22:10:25 -0400 Subject: [PATCH 116/257] En_kusa OK and Documented (#640) * matched one function * More matches * more matches * cleaning up some stuff * making some progress * two new matches, and a partial match * meh...i'll come back to this * fixing ctx names * more matches * OK and documented * fixing data stuff * PR suggestions * fixing name and DL issues * fixing pr suggestions * PR feedback * ....format.... * PR fix * fixes * dang format * fixing name * I'm blind * fixing obj_grass --- assets/xml/objects/gameplay_field_keep.xml | 4 +- assets/xml/objects/gameplay_keep.xml | 4 +- assets/xml/objects/object_kusa.xml | 4 +- spec | 4 +- src/overlays/actors/ovl_En_Kusa/z_en_kusa.c | 711 ++++++++++++++++-- src/overlays/actors/ovl_En_Kusa/z_en_kusa.h | 27 +- src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c | 12 +- .../actors/ovl_En_Scopenuts/z_en_scopenuts.c | 2 +- src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c | 4 +- .../actors/ovl_Obj_Grass/z_obj_grass.c | 4 +- tools/disasm/functions.txt | 56 +- undefined_syms.txt | 4 - 12 files changed, 729 insertions(+), 107 deletions(-) diff --git a/assets/xml/objects/gameplay_field_keep.xml b/assets/xml/objects/gameplay_field_keep.xml index 7a299bff7..45fa3eccd 100644 --- a/assets/xml/objects/gameplay_field_keep.xml +++ b/assets/xml/objects/gameplay_field_keep.xml @@ -40,8 +40,8 @@ - - + + diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index ded5f8b67..4adba079c 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1172,8 +1172,8 @@ - - + + diff --git a/assets/xml/objects/object_kusa.xml b/assets/xml/objects/object_kusa.xml index 0d36569a5..36c61f364 100644 --- a/assets/xml/objects/object_kusa.xml +++ b/assets/xml/objects/object_kusa.xml @@ -1,6 +1,6 @@  - - + + diff --git a/spec b/spec index 33b43d0db..646b2d515 100644 --- a/spec +++ b/spec @@ -1469,9 +1469,7 @@ beginseg name "ovl_En_Kusa" compress include "build/src/overlays/actors/ovl_En_Kusa/z_en_kusa.o" - include "build/data/ovl_En_Kusa/ovl_En_Kusa.data.o" - include "build/data/ovl_En_Kusa/ovl_En_Kusa.bss.o" - include "build/data/ovl_En_Kusa/ovl_En_Kusa.reloc.o" + include "build/src/overlays/actors/ovl_En_Kusa/ovl_En_Kusa_reloc.o" endseg beginseg 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 9b8b86969..02bd93aef 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -5,6 +5,9 @@ */ #include "z_en_kusa.h" +#include "objects/object_kusa/object_kusa.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000) @@ -14,15 +17,46 @@ void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx); void EnKusa_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKusa_Update(Actor* thisx, GlobalContext* globalCtx); -void func_809358D8(EnKusa* this, GlobalContext* globalCtx); -void func_809359AC(EnKusa* this, GlobalContext* globalCtx); -void func_80935BBC(EnKusa* this, GlobalContext* globalCtx); -void func_80935D64(EnKusa* this, GlobalContext* globalCtx); -void func_809361A4(EnKusa* this, GlobalContext* globalCtx); -void func_80936220(EnKusa* this, GlobalContext* globalCtx); -void func_809362D8(EnKusa* this, GlobalContext* globalCtx); +s32 EnKusa_SnapToFloor(EnKusa* this, GlobalContext* globalCtx, f32 yOffset); +void EnKusa_DropCollectible(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_UpdateVelY(EnKusa* this); +void EnKusa_RandScaleVecToZero(Vec3f* vec, f32 scaleFactor); +void EnKusa_SetScaleSmall(EnKusa* this); +s32 EnKusa_GetWaterBox(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupWaitObject(EnKusa* this); +void EnKusa_WaitObject(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_WaitForInteract(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupLiftedUp(EnKusa* this); +void EnKusa_LiftedUp(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_WaitObject(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupInteract(EnKusa* this); +void EnKusa_SetupFall(EnKusa* this); +void EnKusa_Fall(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupCut(EnKusa* this); +void EnKusa_CutWaitRegrow(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_DoNothing(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupUprootedWaitRegrow(EnKusa* this); +void EnKusa_UprootedWaitRegrow(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupRegrow(EnKusa* this); +void EnKusa_Regrow(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_DrawBush(Actor* thisx, GlobalContext* globalCtx2); +void EnKusa_DrawGrass(Actor* thisx, GlobalContext* globalCtx); + +s16 rotSpeedXtarget = 0; +s16 rotSpeedX = 0; +s16 rotSpeedYtarget = 0; +s16 rotSpeedY = 0; +s16 D_809366B0 = 0; +u8 D_809366B4 = true; + +u32 kusaGameplayFrames; +MtxF D_80936AD8[8]; +s16 D_80936CD8; +s16 D_80936CDA; +s16 D_80936CDC; +s16 D_80936CDE; +s16 D_80936CE0; -#if 0 const ActorInit En_Kusa_InitVars = { ACTOR_EN_KUSA, ACTORCAT_PROP, @@ -35,18 +69,40 @@ const ActorInit En_Kusa_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809366E0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x0580C71C, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON, OCELEM_ON, }, +static s16 objectIds[] = { GAMEPLAY_FIELD_KEEP, OBJECT_KUSA, OBJECT_KUSA, OBJECT_KUSA }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x0580C71C, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, { 6, 44, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_8093670C = { 0, 12, 30, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 30, MASS_IMMOVABLE }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80936754[] = { +static Vec3f sUnitDirections[] = { + { 0.0f, 0.7071f, 0.7071f }, + { 0.7071f, 0.7071f, 0.0f }, + { 0.0f, 0.7071f, -0.7071f }, + { -0.7071f, 0.7071f, 0.0f }, +}; + +static s16 sFragmentScales[] = { 108, 102, 96, 84, 66, 55, 42, 38 }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -3200, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -17000, ICHAIN_CONTINUE), @@ -55,72 +111,623 @@ static InitChainEntry D_80936754[] = { ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -#endif +/** + * @brief Applies a "swaying" motion to the provided matrix + * + */ +void EnKusa_ApplySway(MtxF* matrix) { + MtxF* mtxState = Matrix_GetCurrentState(); + f32* tmp = &mtxState->mf[0][0]; + f32* tmp2 = &matrix->mf[0][0]; + s32 i; -extern ColliderCylinderInit D_809366E0; -extern CollisionCheckInfoInit D_8093670C; -extern InitChainEntry D_80936754[]; + for (i = 0; i < 16; i++) { + *tmp++ += *tmp2++; + } +} -extern UNK_TYPE D_060002E0; +/** + * @brief Updates the matrix controlling movement of the leaves of grass to simulate a swaying motion from the wind + * blowing. + */ +void EnKusa_Sway(void) { + s32 i; + s32 pad; + f32 sin_6CDA; + f32* ptr; + f32 sin_6CDE; + f32 sin_6CE0; + f32 tempf1; + f32 tempf2; + f32 tempf3; + f32 tempf4; + f32 tempf5; + f32 sp7C[8]; + f32 cos_6CE0; + f32 cos_6CDA; + f32 cos_6CDC; + f32 cos_6CDE; + f32 cos_6CD8; + f32 sin_6CD8; + f32 sin_6CDC; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809349E0.s") + D_80936CD8 += 0x46; + D_80936CDA += 0x12C; + D_80936CDC += 0x2BC; + D_80936CDE += 0x514; + D_80936CE0 += 0x22C4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80934AB4.s") + sin_6CD8 = Math_SinS(D_80936CD8); + sin_6CDA = Math_SinS(D_80936CDA); + sin_6CDC = Math_SinS(D_80936CDC); + sin_6CDE = Math_SinS(D_80936CDE) * 1.2f; + sin_6CE0 = Math_SinS(D_80936CE0) * 1.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80934F58.s") + cos_6CD8 = Math_CosS(D_80936CD8); + cos_6CDA = Math_CosS(D_80936CDA); + cos_6CDC = Math_CosS(D_80936CDC); + cos_6CDE = Math_CosS(D_80936CDE) * 1.3f; + cos_6CE0 = Math_CosS(D_80936CE0) * 1.7f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80934FFC.s") + sp7C[0] = (sin_6CD8 - cos_6CDA) * sin_6CDC * cos_6CD8 * sin_6CD8 * 0.0015f; + sp7C[1] = (sin_6CDA - cos_6CDC) * sin_6CDE * cos_6CDA * sin_6CD8 * 0.0015f; + sp7C[2] = (sin_6CDC - cos_6CDE) * cos_6CDC * sin_6CD8 * cos_6CD8 * 0.0015f; + sp7C[3] = (sin_6CDE - cos_6CDA) * cos_6CDE * sin_6CDA * cos_6CD8 * 0.0015f; + sp7C[4] = (sin_6CD8 - cos_6CDC) * sin_6CD8 * sin_6CDA * sin_6CE0 * 0.0015f; + sp7C[5] = (sin_6CDA - cos_6CDE) * sin_6CDC * sin_6CDE * sin_6CE0 * 0.0015f; + sp7C[6] = (sin_6CDC - cos_6CD8) * cos_6CD8 * cos_6CDA * cos_6CE0 * 0.0015f; + sp7C[7] = (sin_6CDE - cos_6CDA) * cos_6CDC * cos_6CDE * cos_6CE0 * 0.0015f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809350C4.s") + for (i = 0; i < ARRAY_COUNT(D_80936AD8); i++) { + ptr = &D_80936AD8[i].mf[0][0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809350F8.s") + tempf1 = sp7C[i & 7]; + tempf2 = sp7C[(i + 1) & 7]; + tempf3 = sp7C[(i + 2) & 7]; + tempf4 = sp7C[(i + 3) & 7]; + tempf5 = sp7C[(i + 4) & 7]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_8093517C.s") + ptr[0] = sp7C[1] * 0.2f; + ptr[1] = tempf1; + ptr[2] = tempf2; + ptr[3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809351A0.s") + ptr[4] = tempf3; + ptr[5] = sp7C[0]; + ptr[6] = tempf3; + ptr[7] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809354F8.s") + ptr[8] = tempf4; + ptr[9] = tempf5; + ptr[10] = sp7C[3] * 0.2f; + ptr[11] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809355A4.s") + ptr[12] = 0.0f; + ptr[13] = 0.0f; + ptr[14] = 0.0f; + ptr[15] = 0.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_8093561C.s") +/** + * @brief Detects if a bush is able to snap to the floor. BgCheck_EntityRaycastFloor5 will give the intersect point + * if no poit is found, a false value is returned. + * + * @param this + * @param globalCtx + * @param yOffset offset of Y coordinate, can be positive or negative. + * @return true/false if the bush is able to snap to the floor and is above BGCHECK_Y_MIN + */ +s32 EnKusa_SnapToFloor(EnKusa* this, GlobalContext* globalCtx, f32 yOffset) { + s32 pad; + CollisionPoly* poly; + Vec3f pos; + s32 bgId; + f32 floorY; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/EnKusa_Init.s") + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + 30.0f; + pos.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/EnKusa_Destroy.s") + floorY = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &poly, &bgId, &this->actor, &pos); + if (floorY > BGCHECK_Y_MIN) { + this->actor.world.pos.y = floorY + yOffset; + Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); + return true; + } else { + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809358C4.s") +void EnKusa_DropCollectible(EnKusa* this, GlobalContext* globalCtx) { + s32 collectible; + s32 collectableParams; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809358D8.s") + if ((GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_GRASS) || (GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_BUSH)) { + if (!(KUSA_GET_PARAMS_0C(&this->actor))) { + Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, + KUSA_GET_RAND_COLLECTIBLE_ID(&this->actor) * 0x10); + } + } else if (GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_REGROWING_GRASS) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, 3); + } else { + collectible = func_800A8150(KUSA_GET_PARAMS_3F(&this->actor)); + if (collectible >= 0) { + collectableParams = KUSA_GET_COLLECTIBLE_ID(&this->actor); + Item_DropCollectible(globalCtx, &this->actor.world.pos, (collectableParams << 8) | collectible); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935988.s") +void EnKusa_UpdateVelY(EnKusa* this) { + this->actor.velocity.y += this->actor.gravity; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809359AC.s") +/** + * @brief Scales a vector down by provided scale factor + * + * @param vec vector to be scaled + * @param scaleFactor scale factor to be applied to vector + */ +void EnKusa_RandScaleVecToZero(Vec3f* vec, f32 scaleFactor) { + scaleFactor += ((Rand_ZeroOne() * 0.2f) - 0.1f) * scaleFactor; + vec->x -= vec->x * scaleFactor; + vec->y -= vec->y * scaleFactor; + vec->z -= vec->z * scaleFactor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935B94.s") +void EnKusa_SetScaleSmall(EnKusa* this) { + this->actor.scale.y = 160.0f * 0.001f; + this->actor.scale.x = 120.0f * 0.001f; + this->actor.scale.z = 120.0f * 0.001f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935BBC.s") +void EnKusa_SpawnFragments(EnKusa* this, GlobalContext* globalCtx) { + Vec3f velocity; + Vec3f pos; + s32 i; + s32 scaleIndex; + Vec3f* directon; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935CE8.s") + for (i = 0; i < ARRAY_COUNT(sUnitDirections); i++) { + directon = &sUnitDirections[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935D64.s") + pos.x = this->actor.world.pos.x + (directon->x * this->actor.scale.x * 20.0f); + pos.y = this->actor.world.pos.y + (directon->y * this->actor.scale.y * 20.0f) + 10.0f; + pos.z = this->actor.world.pos.z + (directon->z * this->actor.scale.z * 20.0f); + velocity.x = (Rand_ZeroOne() - 0.5f) * 8.0f; + velocity.y = Rand_ZeroOne() * 10.0f; + velocity.z = (Rand_ZeroOne() - 0.5f) * 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936120.s") + scaleIndex = (s32)(Rand_ZeroOne() * 111.1f) & 7; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936168.s") + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -100, 64, 40, 3, 0, sFragmentScales[scaleIndex], 0, 0, + 0x50, -1, 1, gKakeraLeafMiddle); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809361A4.s") + pos.x = this->actor.world.pos.x + (directon->x * this->actor.scale.x * 40.0f); + pos.y = this->actor.world.pos.y + (directon->y * this->actor.scale.y * 40.0f) + 10.0f; + pos.z = this->actor.world.pos.z + (directon->z * this->actor.scale.z * 40.0f); + velocity.x = (Rand_ZeroOne() - 0.5f) * 6.0f; + velocity.y = Rand_ZeroOne() * 10.0f; + velocity.z = (Rand_ZeroOne() - 0.5f) * 6.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809361B4.s") + scaleIndex = (s32)(Rand_ZeroOne() * 111.1f) % 7; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936220.s") + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -100, 64, 40, 3, 0, sFragmentScales[scaleIndex], 0, 0, + 0x50, -1, 1, gKakeraLeafTip); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936290.s") +void EnKusa_SpawnBugs(EnKusa* this, GlobalContext* globalCtx) { + u32 numBugs; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809362D8.s") + for (numBugs = 0; numBugs < 3; numBugs++) { + Actor* bug = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_INSECT, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 1, this->actor.cutscene, this->actor.unk20, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/EnKusa_Update.s") + if (bug == NULL) { + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936414.s") +s32 EnKusa_GetWaterBox(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* waterBox; + f32 ySurface; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809365CC.s") + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &ySurface, &waterBox, &bgId) && + (this->actor.world.pos.y < ySurface)) { + return true; + } + return false; +} + +void EnKusa_InitCollider(Actor* thisx, GlobalContext* globalCtx) { + EnKusa* this = THIS; + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(thisx, &this->collider); +} + +void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKusa* this = THIS; + s32 pad; + s32 kusaType = GET_KUSA_TYPE(&this->actor); + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if (globalCtx->csCtx.state != 0) { + this->actor.uncullZoneForward += 1000.0f; + } + EnKusa_InitCollider(&this->actor, globalCtx); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + + if (kusaType == ENKUSA_TYPE_BUSH) { + this->actor.shape.shadowScale = 1.0f; + this->actor.shape.shadowAlpha = 60; + } else { + this->actor.shape.shadowScale = 0.9f; + this->actor.shape.shadowAlpha = 70; + } + + if (this->actor.shape.rot.y == 0) { + this->actor.shape.rot.y = ((u32)Rand_Next() >> 0x10); + this->actor.home.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.y = this->actor.shape.rot.y; + } + if (!EnKusa_SnapToFloor(this, globalCtx, 0.0f)) { + Actor_MarkForDeath(&this->actor); + return; + } + if (EnKusa_GetWaterBox(this, globalCtx)) { + this->isInWater |= 1; + } + + this->objIndex = Object_GetIndex(&globalCtx->objectCtx, objectIds[(GET_KUSA_TYPE(&this->actor))]); + if (this->objIndex < 0) { + Actor_MarkForDeath(&this->actor); + return; + } + + EnKusa_SetupWaitObject(this); + if (D_809366B4) { + D_80936CD8 = ((u32)Rand_Next() >> 0x10); + D_80936CDA = ((u32)Rand_Next() >> 0x10); + D_80936CDC = ((u32)Rand_Next() >> 0x10); + D_80936CDE = ((u32)Rand_Next() >> 0x10); + D_80936CE0 = ((u32)Rand_Next() >> 0x10); + D_809366B4 = false; + EnKusa_Sway(); + kusaGameplayFrames = globalCtx->gameplayFrames; + } + this->kusaMtxIdx = D_809366B0 & 7; + D_809366B0++; +} + +void EnKusa_Destroy(Actor* thisx, GlobalContext* globalCtx) { + GlobalContext* globalCtx2 = globalCtx; + EnKusa* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnKusa_SetupWaitObject(EnKusa* this) { + this->actionFunc = EnKusa_WaitObject; +} + +void EnKusa_WaitObject(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + + if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { + s32 kusaType = GET_KUSA_TYPE(&this->actor); + + if (this->isCut) { + EnKusa_SetupCut(this); + } else { + EnKusa_SetupInteract(this); + } + if (kusaType == ENKUSA_TYPE_BUSH) { + this->actor.draw = EnKusa_DrawBush; + } else { + this->actor.draw = EnKusa_DrawGrass; + } + this->actor.objBankIndex = this->objIndex; + this->actor.flags &= ~ACTOR_FLAG_10; + } +} + +void EnKusa_SetupInteract(EnKusa* this) { + this->actionFunc = EnKusa_WaitForInteract; + this->actor.flags &= ~ACTOR_FLAG_10; +} + +void EnKusa_WaitForInteract(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + + if (Actor_HasParent(&this->actor, globalCtx)) { + EnKusa_SetupLiftedUp(this); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_PL_PULL_UP_PLANT); + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + + } else if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + EnKusa_SpawnFragments(this, globalCtx); + EnKusa_DropCollectible(this, globalCtx); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); + + if (KUSA_SHOULD_SPAWN_BUGS(&this->actor)) { + if (GET_KUSA_TYPE(&this->actor) != ENKUSA_TYPE_GRASS_2) { + EnKusa_SpawnBugs(this, globalCtx); + } + } + if (GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_BUSH) { + Actor_MarkForDeath(&this->actor); + } else { + EnKusa_SetupCut(this); + this->isCut = true; + } + + } else { + if (!(this->collider.base.ocFlags1 & OC1_TYPE_PLAYER) && (this->actor.xzDistToPlayer > 12.0f)) { + this->collider.base.ocFlags1 |= OC1_TYPE_PLAYER; + } + + if (this->actor.xzDistToPlayer < 600.0f) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->actor.xzDistToPlayer < 400.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->actor.xzDistToPlayer < 100.0f) { + if (GET_KUSA_TYPE(&this->actor) != ENKUSA_TYPE_GRASS_2) { + Actor_LiftActor(&this->actor, globalCtx); + } + } + } + } + } +} + +void EnKusa_SetupLiftedUp(EnKusa* this) { + this->actionFunc = EnKusa_LiftedUp; + this->actor.room = -1; + this->actor.flags |= ACTOR_FLAG_10; +} + +void EnKusa_LiftedUp(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f pos; + s32 bgId; + + if (Actor_HasNoParent(&this->actor, globalCtx)) { + this->actor.room = globalCtx->roomCtx.currRoom.num; + EnKusa_SetupFall(this); + this->actor.velocity.x = this->actor.speedXZ * Math_SinS(this->actor.world.rot.y); + this->actor.velocity.z = this->actor.speedXZ * Math_CosS(this->actor.world.rot.y); + this->actor.colChkInfo.mass = 80; + this->actor.gravity = -0.1f; + EnKusa_UpdateVelY(this); + EnKusa_RandScaleVecToZero(&this->actor.velocity, 0.005f); + Actor_UpdatePos(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + this->actor.gravity = -3.2f; + } else { + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + 20.0f; + pos.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &pos); + } +} + +void EnKusa_SetupFall(EnKusa* this) { + this->actionFunc = EnKusa_Fall; + rotSpeedXtarget = -0xBB8; + rotSpeedYtarget = (Rand_ZeroOne() - 0.5f) * 1600.0f; + rotSpeedX = 0; + rotSpeedY = 0; + this->timer = 0; +} + +void EnKusa_Fall(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + s32 wasHit; + Vec3f contactPos; + s32 i; + s16 angleOffset; + + wasHit = (this->collider.base.atFlags & AT_HIT) != 0; + + if (wasHit) { + this->collider.base.atFlags &= ~AT_HIT; + } + this->timer++; + if ((this->actor.bgCheckFlags & 0xB) || wasHit || (this->timer >= 100)) { + if (!(this->actor.bgCheckFlags & 0x20)) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); + } + EnKusa_SpawnFragments(this, globalCtx); + EnKusa_DropCollectible(this, globalCtx); + switch (GET_KUSA_TYPE(&this->actor)) { + case ENKUSA_TYPE_BUSH: + case ENKUSA_TYPE_GRASS: + Actor_MarkForDeath(&this->actor); + break; + + case ENKUSA_TYPE_REGROWING_GRASS: + EnKusa_SetupUprootedWaitRegrow(this); + this->actor.shape.shadowDraw = NULL; + break; + } + + } else { + if (this->actor.bgCheckFlags & 0x40) { + contactPos.y = this->actor.world.pos.y + this->actor.depthInWater; + for (angleOffset = 0, i = 0; i < 4; i++, angleOffset += 0x4000) { + contactPos.x = + (Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + angleOffset) * 15.0f) + this->actor.world.pos.x; + contactPos.z = + (Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + angleOffset) * 15.0f) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &contactPos, NULL, NULL, 0, 190); + } + contactPos.x = this->actor.world.pos.x; + contactPos.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &contactPos, NULL, NULL, 0, 280); + EffectSsGRipple_Spawn(globalCtx, &contactPos, 300, 700, 0); + this->actor.terminalVelocity = -3.0f; + this->actor.velocity.x *= 0.1f; + this->actor.velocity.y *= 0.4f; + this->actor.velocity.z *= 0.1f; + this->actor.gravity *= 0.5f; + rotSpeedX >>= 1; + rotSpeedXtarget >>= 1; + rotSpeedY >>= 1; + rotSpeedYtarget >>= 1; + this->actor.bgCheckFlags &= ~0x40; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + } + EnKusa_UpdateVelY(this); + Math_StepToS(&rotSpeedX, rotSpeedXtarget, 500); + Math_StepToS(&rotSpeedY, rotSpeedYtarget, 170); + this->actor.shape.rot.x += rotSpeedX; + this->actor.shape.rot.y += rotSpeedY; + EnKusa_RandScaleVecToZero(&this->actor.velocity, 0.05f); + Actor_UpdatePos(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void EnKusa_SetupCut(EnKusa* this) { + switch (GET_KUSA_TYPE(&this->actor)) { + case ENKUSA_TYPE_GRASS: + case ENKUSA_TYPE_GRASS_2: + this->actionFunc = EnKusa_DoNothing; + break; + case ENKUSA_TYPE_REGROWING_GRASS: + this->actionFunc = EnKusa_CutWaitRegrow; + break; + } + this->timer = 0; +} + +void EnKusa_CutWaitRegrow(EnKusa* this, GlobalContext* globalCtx) { + this->timer++; + if (this->timer >= 120) { + EnKusa_SetupRegrow(this); + } +} + +void EnKusa_DoNothing(EnKusa* this, GlobalContext* globalCtx) { +} + +void EnKusa_SetupUprootedWaitRegrow(EnKusa* this) { + this->actor.world.pos.x = this->actor.home.pos.x; + this->actor.world.pos.y = this->actor.home.pos.y - 9.0f; + this->actor.world.pos.z = this->actor.home.pos.z; + EnKusa_SetScaleSmall(this); + this->timer = 0; + this->actor.shape.rot = this->actor.home.rot; + this->actionFunc = EnKusa_UprootedWaitRegrow; +} + +void EnKusa_UprootedWaitRegrow(EnKusa* this, GlobalContext* globalCtx) { + this->timer++; + if (this->timer > 120) { + if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.6f) && (this->timer >= 170)) { + EnKusa_SetupRegrow(this); + } + } +} + +void EnKusa_SetupRegrow(EnKusa* this) { + this->actionFunc = EnKusa_Regrow; + EnKusa_SetScaleSmall(this); + this->isCut = false; + this->actor.shape.rot = this->actor.home.rot; +} + +void EnKusa_Regrow(EnKusa* this, GlobalContext* globalCtx) { + s32 isFullyGrown = 1; + + isFullyGrown &= Math_StepToF(&this->actor.scale.y, 0.4f, 0.014f); + isFullyGrown &= Math_StepToF(&this->actor.scale.x, 0.4f, 0.011f); + this->actor.scale.z = this->actor.scale.x; + if (isFullyGrown) { + Actor_SetScale(&this->actor, 0.4f); + EnKusa_SetupInteract(this); + this->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; + } +} + +void EnKusa_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnKusa* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->isCut) { + this->actor.shape.yOffset = -6.25f; + } else { + this->actor.shape.yOffset = 0.0f; + } + if ((kusaGameplayFrames != globalCtx->gameplayFrames) && (globalCtx->roomCtx.currRoom.unk3 == 0)) { + EnKusa_Sway(); + kusaGameplayFrames = globalCtx->gameplayFrames; + } +} + +void EnKusa_DrawBush(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnKusa* this = THIS; + + if ((this->actor.projectedPos.z <= 1200.0f) || ((this->isInWater & 1) && (this->actor.projectedPos.z < 1300.0f))) { + + if ((globalCtx->roomCtx.currRoom.unk3 == 0) && (this->actionFunc == EnKusa_WaitForInteract) && + (this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { + EnKusa_ApplySway(&D_80936AD8[this->kusaMtxIdx]); + } + + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); + + } else if (this->actor.projectedPos.z < 1300.0f) { + s32 alpha; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + alpha = (1300.0f - this->actor.projectedPos.z) * 2.55f; + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, alpha); + gSPDisplayList(POLY_XLU_DISP++, gKusaBushType2); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnKusa_DrawGrass(Actor* thisx, GlobalContext* globalCtx) { + EnKusa* this = THIS; + + if (this->isCut) { + Gfx_DrawDListOpa(globalCtx, gKusaStump); + } else { + if ((globalCtx->roomCtx.currRoom.unk3 == 0) && (this->actionFunc == EnKusa_WaitForInteract)) { + if ((this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { + EnKusa_ApplySway(&D_80936AD8[this->kusaMtxIdx]); + } + } + Gfx_DrawDListOpa(globalCtx, gKusaSprout); + } +} diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h index 612f7b2ef..2f0d29dd9 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h @@ -7,12 +7,33 @@ struct EnKusa; typedef void (*EnKusaActionFunc)(struct EnKusa*, GlobalContext*); +typedef enum { + /* 0 */ ENKUSA_TYPE_BUSH, + /* 1 */ ENKUSA_TYPE_REGROWING_GRASS, + /* 2 */ ENKUSA_TYPE_GRASS, + /* 3 */ ENKUSA_TYPE_GRASS_2 +} EnKusaType; + typedef struct EnKusa { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnKusaActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x54]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnKusaActionFunc actionFunc; + /* 0x148 */ ColliderCylinder collider; + /* 0x194 */ u8 timer; + /* 0x195 */ s8 objIndex; + /* 0x196 */ s8 kusaMtxIdx; + /* 0x197 */ u8 isCut; + /* 0x198 */ u8 isInWater; } EnKusa; // size = 0x19C extern const ActorInit En_Kusa_InitVars; +#define KUSA_GET_COLLECTIBLE_ID(thisx) ((((thisx)->params >> 8) & 0x7F)) +#define KUSA_GET_RAND_COLLECTIBLE_ID(thisx) (((thisx)->params >> 8) & 0xF) +#define KUSA_SHOULD_SPAWN_BUGS(thisx) (((thisx)->params >> 0x4) & 1) +#define KUSA_GET_PARAMS_0C(thisx) (((thisx)->params >> 0xC) & 0x1) +#define KUSA_GET_PARAMS_3F(thisx) (((thisx)->params >> 0x2) & 0x3F) + + +#define GET_KUSA_TYPE(thisx)((thisx)->params & 0x3) + #endif // Z_EN_KUSA_H diff --git a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c index 1d37f0fa9..1b8d1ccbc 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -1310,8 +1310,8 @@ void EnKusa2_Update(Actor* thisx, GlobalContext* globalCtx) { void func_80A5E6F0(Actor* thisx, GlobalContext* globalCtx) { static Gfx* D_80A5EB68[] = { - gameplay_keep_DL_0528B0, - gameplay_keep_DL_0527F0, + gKakeraLeafTip, + gKakeraLeafMiddle, }; EnKusa2* this = THIS; s32 i; @@ -1343,7 +1343,7 @@ void func_80A5E80C(GlobalContext* globalCtx, s32 arg1) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, arg1); - gSPDisplayList(POLY_XLU_DISP++, gameplay_field_keep_DL_007938); + gSPDisplayList(POLY_XLU_DISP++, gKusaBushType2); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1356,7 +1356,7 @@ void EnKusa2_Draw(Actor* thisx, GlobalContext* globalCtx) { (this->actor.projectedPos.z < 400.0f)) { func_80A5B954(&D_80A60908[this->unk_1CE], 0.0015f); } - Gfx_DrawDListOpa(globalCtx, gameplay_field_keep_DL_0078A0); + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); } else if (this->actor.projectedPos.z < 1300.0f) { func_80A5E80C(globalCtx, (1300.0f - this->actor.projectedPos.z) * 2.55f); } @@ -1370,14 +1370,14 @@ void func_80A5E9B4(Actor* thisx, GlobalContext* globalCtx) { sp18.z = thisx->shape.rot.z + D_80A5EAFC.z; Matrix_SetStateRotationAndTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, &sp18); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); - Gfx_DrawDListOpa(globalCtx, gameplay_field_keep_DL_0078A0); + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); } void func_80A5EA48(Actor* thisx, GlobalContext* globalCtx) { EnKusa2* this = THIS; if (this->unk_1CF == 0xFF) { - Gfx_DrawDListOpa(globalCtx, gameplay_field_keep_DL_0078A0); + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); } else { func_80A5E80C(globalCtx, this->unk_1CF); } diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c index 0eabcd80f..823cf9c05 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -90,7 +90,7 @@ static AnimationInfoS sAnimations[] = { { &object_dnt_Anim_002670, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; -Gfx* D_80BCCCDC[] = { gameplay_keep_DL_0527F0, gameplay_keep_DL_0528B0 }; +Gfx* D_80BCCCDC[] = { gKakeraLeafMiddle, gKakeraLeafTip }; Vec3f D_80BCCCE4 = { 0.0f, -0.5f, 0.0f }; diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c index 30898db9f..a02f7f604 100644 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c @@ -303,8 +303,8 @@ void func_809375C8(ObjBean* this, GlobalContext* globalCtx) { void func_809375F4(ObjBean* this, GlobalContext* globalCtx) { static Gfx* D_80939024[] = { - gameplay_keep_DL_0527F0, - gameplay_keep_DL_0528B0, + gKakeraLeafMiddle, + gKakeraLeafTip, }; Vec3f spC4; Vec3f spB8; diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c index 4808a0d5b..3da7e37f4 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c @@ -118,7 +118,7 @@ void func_809A9314(ObjGrassStruct1_1* ptr, GlobalContext* globalCtx) { spBC.z = (Rand_ZeroOne() - 0.5f) * 8.0f; EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, - D_809AAB7C[(s32)(Rand_ZeroOne() * 111.1f) & 7], 0, 0, 80, -1, 1, gameplay_keep_DL_0527F0); + D_809AAB7C[(s32)(Rand_ZeroOne() * 111.1f) & 7], 0, 0, 80, -1, 1, gKakeraLeafMiddle); spB0.x = ptr->unk_00.x + (ptr2->x * 16.0f); spB0.y = (ptr->unk_00.y + (ptr2->y * 16.0f)) + 10.0f; @@ -129,7 +129,7 @@ void func_809A9314(ObjGrassStruct1_1* ptr, GlobalContext* globalCtx) { spBC.z = (Rand_ZeroOne() - 0.5f) * 6.0f; EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, - D_809AAB7C[(s32)(Rand_ZeroOne() * 111.1f) % 7], 0, 0, 80, -1, 1, gameplay_keep_DL_0528B0); + D_809AAB7C[(s32)(Rand_ZeroOne() * 111.1f) % 7], 0, 0, 80, -1, 1, gKakeraLeafTip); } } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4b28b6dc3..43dd0963f 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -7251,37 +7251,37 @@ 0x809340BC:("func_809340BC",), 0x80934178:("func_80934178",), 0x80934464:("func_80934464",), - 0x809349E0:("func_809349E0",), - 0x80934AB4:("func_80934AB4",), - 0x80934F58:("func_80934F58",), - 0x80934FFC:("func_80934FFC",), - 0x809350C4:("func_809350C4",), - 0x809350F8:("func_809350F8",), - 0x8093517C:("func_8093517C",), - 0x809351A0:("func_809351A0",), - 0x809354F8:("func_809354F8",), - 0x809355A4:("func_809355A4",), - 0x8093561C:("func_8093561C",), + 0x809349E0:("EnKusa_ApplySway",), + 0x80934AB4:("EnKusa_Sway",), + 0x80934F58:("EnKusa_SnapToFloor",), + 0x80934FFC:("EnKusa_DropCollectible",), + 0x809350C4:("EnKusa_UpdateVelY",), + 0x809350F8:("EnKusa_RandScaleVecToZero",), + 0x8093517C:("EnKusa_SetScaleSmall",), + 0x809351A0:("EnKusa_SpawnFragments",), + 0x809354F8:("EnKusa_SpawnBugs",), + 0x809355A4:("EnKusa_GetWaterBox",), + 0x8093561C:("EnKusa_InitCollider",), 0x80935674:("EnKusa_Init",), 0x80935898:("EnKusa_Destroy",), - 0x809358C4:("func_809358C4",), - 0x809358D8:("func_809358D8",), - 0x80935988:("func_80935988",), - 0x809359AC:("func_809359AC",), - 0x80935B94:("func_80935B94",), - 0x80935BBC:("func_80935BBC",), - 0x80935CE8:("func_80935CE8",), - 0x80935D64:("func_80935D64",), - 0x80936120:("func_80936120",), - 0x80936168:("func_80936168",), - 0x809361A4:("func_809361A4",), - 0x809361B4:("func_809361B4",), - 0x80936220:("func_80936220",), - 0x80936290:("func_80936290",), - 0x809362D8:("func_809362D8",), + 0x809358C4:("EnKusa_SetupWaitObject",), + 0x809358D8:("EnKusa_WaitObject",), + 0x80935988:("EnKusa_SetupInteract",), + 0x809359AC:("EnKusa_WaitForInteract",), + 0x80935B94:("EnKusa_SetupLiftedUp",), + 0x80935BBC:("EnKusa_LiftedUp",), + 0x80935CE8:("EnKusa_SetupFall",), + 0x80935D64:("EnKusa_Fall",), + 0x80936120:("EnKusa_SetupCut",), + 0x80936168:("EnKusa_CutWaitRegrow",), + 0x809361A4:("EnKusa_DoNothing",), + 0x809361B4:("EnKusa_SetupUprootedWaitRegrow",), + 0x80936220:("EnKusa_UprootedWaitRegrow",), + 0x80936290:("EnKusa_SetupRegrow",), + 0x809362D8:("EnKusa_Regrow",), 0x80936370:("EnKusa_Update",), - 0x80936414:("func_80936414",), - 0x809365CC:("func_809365CC",), + 0x80936414:("EnKusa_DrawBush",), + 0x809365CC:("EnKusa_DrawGrass",), 0x80936CF0:("func_80936CF0",), 0x80936D58:("func_80936D58",), 0x80936F04:("func_80936F04",), diff --git a/undefined_syms.txt b/undefined_syms.txt index f18b4e54b..3befbefbd 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1495,10 +1495,6 @@ D_06003C80 = 0x06003C80; D_06003D58 = 0x06003D58; D_06006198 = 0x06006198; -// ovl_En_Kusa - -D_06000140 = 0x06000140; -D_060002E0 = 0x060002E0; // ovl_En_Lift_Nuts From 7c624422de1c9218e1e6ede054130294a76128f0 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 26 Mar 2022 02:16:28 +0000 Subject: [PATCH 117/257] En_Horse_Game_Check (#706) * En_Horse_Game_Check * PR --- .../xml/overlays/ovl_En_Horse_Game_Check.xml | 5 + spec | 3 +- src/overlays/actors/ovl_En_Horse/z_en_horse.h | 6 +- .../z_en_horse_game_check.c | 480 ++++++++++++++++-- .../z_en_horse_game_check.h | 48 +- src/overlays/actors/ovl_En_In/z_en_in.c | 56 +- undefined_syms.txt | 9 - 7 files changed, 523 insertions(+), 84 deletions(-) create mode 100644 assets/xml/overlays/ovl_En_Horse_Game_Check.xml diff --git a/assets/xml/overlays/ovl_En_Horse_Game_Check.xml b/assets/xml/overlays/ovl_En_Horse_Game_Check.xml new file mode 100644 index 000000000..bcb8ea695 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Horse_Game_Check.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/spec b/spec index 646b2d515..76d84e658 100644 --- a/spec +++ b/spec @@ -1290,8 +1290,7 @@ beginseg name "ovl_En_Horse_Game_Check" compress include "build/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.o" - include "build/data/ovl_En_Horse_Game_Check/ovl_En_Horse_Game_Check.data.o" - include "build/data/ovl_En_Horse_Game_Check/ovl_En_Horse_Game_Check.reloc.o" + include "build/src/overlays/actors/ovl_En_Horse_Game_Check/ovl_En_Horse_Game_Check_reloc.o" endseg beginseg 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 05a4065ff..d1eef6186 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.h +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.h @@ -12,7 +12,11 @@ typedef struct EnHorse { /* 0x150 */ s32 unk_150; /* 0x154 */ char unk_154[0x98]; /* 0x1EC */ UNK_TYPE4 unk_1EC; - /* 0x1F0 */ char unk_1F0[0x3A4]; + /* 0x1F0 */ char unk_1F0[0x5C]; + /* 0x24C */ u32 unk_24C; + /* 0x250 */ char unk_250[0x138]; + /* 0x388 */ s32 inRace; + /* 0x38C */ char unk_38C[0x208]; } EnHorse; // size = 0x594 extern const ActorInit En_Horse_InitVars; diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c index ff3465a0a..7b9fa684e 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c @@ -5,6 +5,7 @@ */ #include "z_en_horse_game_check.h" +#include "objects/object_horse_game_check/object_horse_game_check.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,25 @@ void EnHorseGameCheck_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHorseGameCheck_Update(Actor* thisx, GlobalContext* globalCtx); void EnHorseGameCheck_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +s32 func_808F8AA0(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8C24(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8C5C(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8C70(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8CCC(EnHorseGameCheck* this, GlobalContext* globalCtx2); +s32 func_808F8E94(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F96E4(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F9830(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F9868(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F987C(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F990C(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F9944(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F9958(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F999C(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F99B0(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F99C4(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F99D8(EnHorseGameCheck* this, GlobalContext* globalCtx); + const ActorInit En_Horse_Game_Check_InitVars = { ACTOR_EN_HORSE_GAME_CHECK, ACTORCAT_BG, @@ -28,63 +47,454 @@ const ActorInit En_Horse_Game_Check_InitVars = { (ActorFunc)EnHorseGameCheck_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808F9BDC[] = { +#include "overlays/ovl_En_Horse_Game_Check/ovl_En_Horse_Game_Check.c" + +s32 func_808F8AA0(EnHorseGameCheck* this, GlobalContext* globalCtx) { + s32 pad[3]; + CollisionHeader* sp78 = NULL; + MtxF sp38; + + this->dyna.actor.scale.x = this->dyna.actor.scale.y = this->dyna.actor.scale.z = this->unk_160 * 0.001f; + this->dyna.actor.flags |= ACTOR_FLAG_400000; + + DynaPolyActor_Init(&this->dyna, 0); + + if (GET_RACE_FLAGS != RACE_FLAG_START) { + Actor_MarkForDeath(&this->dyna.actor); + return false; + } + + CollisionHeader_GetVirtual(&object_horse_game_check_Colheader_003918, &sp78); + + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp78); + this->unk_15C = ENHORSEGAMECHECK_FF_5; + this->dyna.actor.floorPoly = NULL; + this->dyna.actor.world.pos.y += 100.0f; + + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor2( + globalCtx, &globalCtx->colCtx, &this->dyna.actor.floorPoly, &this->dyna.actor.world.pos); + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight + 3.0f; + func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, + this->dyna.actor.world.pos.z, &sp38); + + Matrix_SetCurrentState(&sp38); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.y, MTXMODE_APPLY); + Matrix_CopyCurrentState(&sp38); + + func_8018219C(&sp38, &this->dyna.actor.shape.rot, 1); + this->dyna.actor.world.rot = this->dyna.actor.shape.rot; + return true; +} + +s32 func_808F8C24(EnHorseGameCheck* this, GlobalContext* globalCtx) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + return true; +} + +s32 func_808F8C5C(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} + +s32 func_808F8C70(EnHorseGameCheck* this, GlobalContext* globalCtx) { + if (Matrix_NewMtx(globalCtx->state.gfxCtx) == NULL) { + return true; + } else { + Gfx_DrawDListXlu(globalCtx, object_horse_game_check_DL_003030); + Gfx_DrawDListOpa(globalCtx, object_horse_game_check_DL_0030C0); + } + return true; +} + +s32 func_808F8CCC(EnHorseGameCheck* this, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + s32 pad; + Vec3f sp4C = { -1262.0f, 15.0f, 780.0f }; + Vec3f sp40 = { -1262.0f, -26.0f, 470.0f }; + + this->unk_164 = 0; + this->unk_168 = 0; + this->unk_174 = 0; + + if (GET_RACE_FLAGS != RACE_FLAG_START) { + Actor_MarkForDeath(&this->dyna.actor); + return false; + } + + func_8010E9F0(4, 0); + globalCtx->interfaceCtx.unk_280 = 1; + + this->horse1 = (EnHorse*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, -1149.0f, -106.0f, 470.0f, 0, + 0x7FFF, 0, 0x2004); + if (this->horse1 == NULL) { + __assert("../z_en_horse_game_check.c", 1517); + } + + this->horse2 = (EnHorse*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, -1376.0f, -106.0f, 470.0f, 0, + 0x7FFF, 0, 0x2005); + if (this->horse2 == NULL) { + __assert("../z_en_horse_game_check.c", 1526); + } + + this->unk_17C = -1; + func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 10); + Play_CameraSetAtEye(globalCtx, 0, &sp40, &sp4C); + Play_CameraSetFov(globalCtx, 0, 45.0f); + func_800FE484(); + return false; +} + +s32 func_808F8E94(EnHorseGameCheck* this, GlobalContext* globalCtx) { + gSaveContext.unk_3DD0[4] = 0; + return true; +} + +s32 func_808F8EB0(EnHorseGameCheck* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (globalCtx->nextEntranceIndex == 0xCE20) { + return false; + } + + if (GET_RACE_FLAGS == RACE_FLAG_3) { + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 2; + } else if (GET_RACE_FLAGS == RACE_FLAG_2) { + globalCtx->unk_1887F = 0x50; + gSaveContext.nextTransition = 3; + } else if (GET_RACE_FLAGS == RACE_FLAG_4) { + SET_RACE_FLAGS(RACE_FLAG_3); + globalCtx->unk_1887F = 2; + gSaveContext.nextTransition = 2; + } + + D_801BDA9C = 0; + if (player->stateFlags1 & 0x800000) { + D_801BDAA0 = 1; + } + globalCtx->nextEntranceIndex = 0xCE20; + globalCtx->sceneLoadFlag = 0x14; + return false; +} + +f32 D_808F9BAC[] = { + -1825.0f, + -237.0f, + -2867.0f, + -1987.0f, +}; + +f32 D_808F9BBC[] = { + 1564.0f, + 3395.0f, + -1665.0f, + -200.0f, +}; + +f32 D_808F9BCC[] = { + -22.0f, + 2005.0f, + 3869.0f, + 5368.0f, +}; + +s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player = GET_PLAYER(globalCtx); + s32 pad2; + EnHorse* horse = (EnHorse*)player->rideActor; + s32 pad3[2]; + EnHorseGameCheck* horseGameCheck; + + if (horse == NULL) { + return true; + } + + if ((this->unk_168 > 50) && !(this->unk_164 & 2)) { + this->unk_164 |= 2; + } else if ((globalCtx->interfaceCtx.unk_280 >= 8) && !(this->unk_164 & 1)) { + this->unk_164 |= 1; + horse->inRace = true; + } else if ((globalCtx->interfaceCtx.unk_280 >= 8) && !(this->unk_164 & 8)) { + EnHorse* horse = this->horse1; + + horse->inRace = true; + horse = this->horse2; + horse->inRace = true; + + this->unk_164 |= 8; + this->unk_17C = this->unk_168; + } + + if ((this->unk_17C != -1) && ((this->unk_168 - this->unk_17C) > 10)) { + this->unk_17C = -1; + func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 4); + } + + this->unk_168++; + if ((this->unk_164 & 0x4000) && (this->unk_164 & 0x200000)) { + if (!(this->unk_164 & 0x10)) { + this->unk_164 |= 0x10; + } + } + + if ((this->unk_164 & 0x800) || (this->unk_164 & 0x40000) || (this->unk_164 & 0x02000000)) { + if (this->unk_174 > 0) { + this->unk_174--; + } else { + func_808F8EB0(this, globalCtx); + } + return true; + } + + if (gSaveContext.unk_3DE0[4] >= 0x4650) { + Audio_QueueSeqCmd(0x8041); + play_sound(NA_SE_SY_START_SHOT); + this->unk_164 |= 0x40000; + gSaveContext.unk_3DD0[4] = 6; + SET_RACE_FLAGS(RACE_FLAG_4) + this->unk_174 = 60; + } + + if (!(this->unk_164 & 0x1000)) { + if (Math3D_XZBoundCheck(D_808F9BAC[0], D_808F9BAC[1], D_808F9BAC[2], D_808F9BAC[3], + this->horse1->actor.world.pos.x, this->horse1->actor.world.pos.z)) { + this->unk_164 |= 0x1000; + } + } + + if (!(this->unk_164 & 0x2000) && (this->unk_164 & 0x1000)) { + if (Math3D_XZBoundCheck(D_808F9BBC[0], D_808F9BBC[1], D_808F9BBC[2], D_808F9BBC[3], + this->horse1->actor.world.pos.x, this->horse1->actor.world.pos.z)) { + this->unk_164 |= 0x2000; + } + } + + if (!(this->unk_164 & 0x4000) && (this->unk_164 & 0x2000)) { + if (Math3D_XZBoundCheck(D_808F9BCC[0], D_808F9BCC[1], D_808F9BCC[2], D_808F9BCC[3], + this->horse1->actor.world.pos.x, this->horse1->actor.world.pos.z)) { + this->unk_164 |= 0x4000; + } + } + + horseGameCheck = (EnHorseGameCheck*)DynaPoly_GetActor(&globalCtx->colCtx, this->horse1->unk_24C); + if ((this->unk_164 & 0x4000) && (horseGameCheck != NULL) && + (horseGameCheck->dyna.actor.id == ACTOR_EN_HORSE_GAME_CHECK) && + (horseGameCheck->unk_15C == ENHORSEGAMECHECK_FF_7) && !(this->unk_164 & 0x40000)) { + Audio_QueueSeqCmd(0x8041); + play_sound(NA_SE_SY_START_SHOT); + this->unk_164 |= 0x40000; + gSaveContext.unk_3DD0[4] = 6; + SET_RACE_FLAGS(RACE_FLAG_3) + this->unk_174 = 60; + } + + if (!(this->unk_164 & 0x80000)) { + if (Math3D_XZBoundCheck(D_808F9BAC[0], D_808F9BAC[1], D_808F9BAC[2], D_808F9BAC[3], + this->horse2->actor.world.pos.x, this->horse2->actor.world.pos.z)) { + this->unk_164 |= 0x80000; + } + } + + if (!(this->unk_164 & 0x100000) && (this->unk_164 & 0x80000)) { + if (Math3D_XZBoundCheck(D_808F9BBC[0], D_808F9BBC[1], D_808F9BBC[2], D_808F9BBC[3], + this->horse2->actor.world.pos.x, this->horse2->actor.world.pos.z)) { + this->unk_164 |= 0x100000; + } + } + + if (!(this->unk_164 & 0x200000) && (this->unk_164 & 0x100000)) { + if (Math3D_XZBoundCheck(D_808F9BCC[0], D_808F9BCC[1], D_808F9BCC[2], D_808F9BCC[3], + this->horse2->actor.world.pos.x, this->horse2->actor.world.pos.z)) { + this->unk_164 |= 0x200000; + } + } + + horseGameCheck = (EnHorseGameCheck*)DynaPoly_GetActor(&globalCtx->colCtx, this->horse2->unk_24C); + if ((this->unk_164 & 0x200000) && (horseGameCheck != NULL) && + (horseGameCheck->dyna.actor.id == ACTOR_EN_HORSE_GAME_CHECK) && + (horseGameCheck->unk_15C == ENHORSEGAMECHECK_FF_7) && !(this->unk_164 & 0x02000000)) { + Audio_QueueSeqCmd(0x8041); + play_sound(NA_SE_SY_START_SHOT); + this->unk_164 |= 0x02000000; + gSaveContext.unk_3DD0[4] = 6; + SET_RACE_FLAGS(RACE_FLAG_3) + this->unk_174 = 60; + } + + if (!(this->unk_164 & 0x20) && Math3D_XZBoundCheck(D_808F9BAC[0], D_808F9BAC[1], D_808F9BAC[2], D_808F9BAC[3], + horse->actor.world.pos.x, horse->actor.world.pos.z)) { + this->unk_164 |= 0x20; + } + + if (!(this->unk_164 & 0x40) && (this->unk_164 & 0x20) && + Math3D_XZBoundCheck(D_808F9BBC[0], D_808F9BBC[1], D_808F9BBC[2], D_808F9BBC[3], horse->actor.world.pos.x, + horse->actor.world.pos.z)) { + this->unk_164 |= 0x40; + } + + if (!(this->unk_164 & 0x80) && (this->unk_164 & 0x40) && + Math3D_XZBoundCheck(D_808F9BCC[0], D_808F9BCC[1], D_808F9BCC[2], D_808F9BCC[3], horse->actor.world.pos.x, + horse->actor.world.pos.z)) { + this->unk_164 |= 0x80; + } + + horseGameCheck = (EnHorseGameCheck*)DynaPoly_GetActor(&globalCtx->colCtx, horse->unk_24C); + if ((this->unk_164 & 0x80) && (horseGameCheck != NULL) && + (horseGameCheck->dyna.actor.id == ACTOR_EN_HORSE_GAME_CHECK) && + (horseGameCheck->unk_15C == ENHORSEGAMECHECK_FF_7) && !(this->unk_164 & 0x800)) { + Audio_QueueSeqCmd(0x8041); + play_sound(NA_SE_SY_START_SHOT); + this->unk_164 |= 0x800; + gSaveContext.unk_3DD0[4] = 6; + SET_RACE_FLAGS(RACE_FLAG_2) + this->unk_174 = 60; + } + return true; +} + +s32 func_808F96E4(EnHorseGameCheck* this, GlobalContext* globalCtx) { + s32 pad[3]; + CollisionHeader* sp78 = NULL; + MtxF sp38; + + this->dyna.actor.scale.x = this->dyna.actor.scale.y = this->dyna.actor.scale.z = this->unk_160 * 0.01f; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&ovl_En_Horse_Game_Check_Colheader_0010C8, &sp78); + + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp78); + this->unk_15C = ENHORSEGAMECHECK_FF_7; + this->dyna.actor.floorPoly = NULL; + this->dyna.actor.world.pos.y += 100.0f; + + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor2( + globalCtx, &globalCtx->colCtx, &this->dyna.actor.floorPoly, &this->dyna.actor.world.pos); + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight + 1.0f; + func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, + this->dyna.actor.world.pos.z, &sp38); + + Matrix_SetCurrentState(&sp38); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.y, MTXMODE_APPLY); + Matrix_CopyCurrentState(&sp38); + + func_8018219C(&sp38, &this->dyna.actor.shape.rot, 1); + this->dyna.actor.world.rot = this->dyna.actor.shape.rot; + return true; +} + +s32 func_808F9830(EnHorseGameCheck* this, GlobalContext* globalCtx) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + return true; +} + +s32 func_808F9868(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 2400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), }; -#endif +s32 func_808F987C(EnHorseGameCheck* this, GlobalContext* globalCtx) { + s32 pad[3]; + CollisionHeader* sp28 = NULL; + s32 pad2; -extern InitChainEntry D_808F9BDC[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.scale.z = 1.0f; + this->dyna.actor.scale.y = 1.0f; + this->dyna.actor.scale.x = 1.0f; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_horse_game_check_Colheader_002FB8, &sp28); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp28); + this->unk_15C = ENHORSEGAMECHECK_FF_8; + return true; +} -extern UNK_TYPE D_060014B0; -extern UNK_TYPE D_06002FB8; -extern UNK_TYPE D_06003030; -extern UNK_TYPE D_06003918; +s32 func_808F990C(EnHorseGameCheck* this, GlobalContext* globalCtx) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8AA0.s") +s32 func_808F9944(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8C24.s") +s32 func_808F9958(EnHorseGameCheck* this, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_horse_game_check_DL_0014B0); + Gfx_DrawDListOpa(globalCtx, object_horse_game_check_DL_0013A0); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8C5C.s") +s32 func_808F999C(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8C70.s") +s32 func_808F99B0(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8CCC.s") +s32 func_808F99C4(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8E94.s") +s32 func_808F99D8(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8EB0.s") +EnHorseGameCheckUnkFunc D_808F9BE4[] = { + NULL, NULL, NULL, NULL, NULL, func_808F8AA0, func_808F8CCC, func_808F96E4, func_808F987C, func_808F999C, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8FAC.s") +EnHorseGameCheckUnkFunc D_808F9C0C[] = { + NULL, NULL, NULL, NULL, NULL, func_808F8C24, func_808F8E94, func_808F9830, func_808F990C, func_808F99B0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F96E4.s") +EnHorseGameCheckUnkFunc D_808F9C34[] = { + NULL, NULL, NULL, NULL, NULL, func_808F8C5C, func_808F8FAC, func_808F9868, func_808F9944, func_808F99C4, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F9830.s") +EnHorseGameCheckUnkFunc D_808F9C5C[] = { + NULL, NULL, NULL, NULL, NULL, func_808F8C70, NULL, NULL, func_808F9958, func_808F99D8, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F9868.s") +void EnHorseGameCheck_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGameCheck* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F987C.s") + this->unk_15C = ENHORSEGAMECHECK_GET_FF(&this->dyna.actor); + this->unk_160 = ENHORSEGAMECHECK_GET_FF00(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F990C.s") + if (this->unk_15C >= ENHORSEGAMECHECK_FF_MAX) { + this->unk_15C = ENHORSEGAMECHECK_FF_0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F9944.s") + if (D_808F9BE4[this->unk_15C] != NULL) { + D_808F9BE4[this->unk_15C](this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F9958.s") +void EnHorseGameCheck_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGameCheck* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F999C.s") + if (D_808F9C0C[this->unk_15C] != NULL) { + D_808F9C0C[this->unk_15C](this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F99B0.s") +void EnHorseGameCheck_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGameCheck* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F99C4.s") + if (D_808F9C34[this->unk_15C] != NULL) { + D_808F9C34[this->unk_15C](this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F99D8.s") +void EnHorseGameCheck_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGameCheck* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/EnHorseGameCheck_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/EnHorseGameCheck_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/EnHorseGameCheck_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/EnHorseGameCheck_Draw.s") + if (D_808F9C5C[this->unk_15C] != NULL) { + D_808F9C5C[this->unk_15C](this, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h index 4c0461982..27187ee46 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h @@ -2,12 +2,56 @@ #define Z_EN_HORSE_GAME_CHECK_H #include "global.h" +#include "overlays/actors/ovl_En_Horse/z_en_horse.h" struct EnHorseGameCheck; +typedef s32 (*EnHorseGameCheckUnkFunc)(struct EnHorseGameCheck*, GlobalContext*); + +#define ENHORSEGAMECHECK_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ENHORSEGAMECHECK_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + +enum { + /* 0 */ ENHORSEGAMECHECK_FF_0, + /* 1 */ ENHORSEGAMECHECK_FF_1, + /* 2 */ ENHORSEGAMECHECK_FF_2, + /* 3 */ ENHORSEGAMECHECK_FF_3, + /* 4 */ ENHORSEGAMECHECK_FF_4, + /* 5 */ ENHORSEGAMECHECK_FF_5, + /* 6 */ ENHORSEGAMECHECK_FF_6, + /* 7 */ ENHORSEGAMECHECK_FF_7, + /* 8 */ ENHORSEGAMECHECK_FF_8, + /* 9 */ ENHORSEGAMECHECK_FF_9, + /* 10 */ ENHORSEGAMECHECK_FF_MAX, +}; + +#define RACE_FLAG_END 0 +#define RACE_FLAG_START 1 +#define RACE_FLAG_2 2 +#define RACE_FLAG_3 3 +#define RACE_FLAG_4 4 +#define RACE_FLAGS 7 + +#define GET_RACE_FLAGS (gSaveContext.weekEventReg[92] & RACE_FLAGS) + +#define SET_RACE_FLAGS(flag) { \ + gSaveContext.weekEventReg[92] &= (u8) ~RACE_FLAGS; \ + gSaveContext.weekEventReg[92] = \ + gSaveContext.weekEventReg[92] | (u8)((gSaveContext.weekEventReg[92] & ~RACE_FLAGS) | (flag)); \ +} + typedef struct EnHorseGameCheck { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x74]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s32 unk_15C; + /* 0x160 */ s32 unk_160; + /* 0x164 */ s32 unk_164; + /* 0x168 */ s32 unk_168; + /* 0x16C */ EnHorse* horse1; + /* 0x170 */ EnHorse* horse2; + /* 0x174 */ s32 unk_174; + /* 0x178 */ UNK_TYPE1 pad178[0x4]; + /* 0x17C */ s32 unk_17C; + /* 0x180 */ UNK_TYPE1 pad180[0x38]; } EnHorseGameCheck; // size = 0x1B8 extern const ActorInit En_Horse_Game_Check_InitVars; 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 5a1ec5a18..0bdabc6e2 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -6,25 +6,12 @@ #include "z_en_in.h" #include "objects/object_in/object_in.h" +#include "overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnIn*)thisx) -#define SET_FLAGS_FINISH_RACE \ - { \ - gSaveContext.weekEventReg[92] &= (u8) ~(1 | 2 | 4); \ - gSaveContext.weekEventReg[92] = \ - gSaveContext.weekEventReg[92] | (u8)(gSaveContext.weekEventReg[92] & ~(1 | 2 | 4)); \ - } - -#define SET_FLAGS_START_RACE \ - { \ - gSaveContext.weekEventReg[92] &= (u8) ~(1 | 2 | 4); \ - gSaveContext.weekEventReg[92] = \ - gSaveContext.weekEventReg[92] | (u8)((gSaveContext.weekEventReg[92] & ~(1 | 2 | 4)) | 1); \ - } - void EnIn_Init(Actor* thisx, GlobalContext* globalCtx); void EnIn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnIn_Update(Actor* thisx, GlobalContext* globalCtx); @@ -345,7 +332,7 @@ void func_808F38F8(EnIn* this, GlobalContext* globalCtx) { } void func_808F395C(EnIn* this, GlobalContext* globalCtx) { - if (this->unk4B0 == 0) { + if (this->unk4B0 == RACE_FLAG_END) { this->actionFunc = func_808F5A94; } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { @@ -361,30 +348,30 @@ void func_808F39DC(EnIn* this, GlobalContext* globalCtx) { u16 textId = 0; if (gSaveContext.day != 3) { - switch (gSaveContext.weekEventReg[92] & (1 | 2 | 4)) { - case 2: + switch (GET_RACE_FLAGS) { + case RACE_FLAG_2: textId = 0x347A; break; - case 3: + case RACE_FLAG_3: textId = 0x3476; break; } - SET_FLAGS_FINISH_RACE; + SET_RACE_FLAGS(RACE_FLAG_END); } else { - switch (gSaveContext.weekEventReg[92] & (1 | 2 | 4)) { - case 2: + switch (GET_RACE_FLAGS) { + case RACE_FLAG_2: textId = 0x349D; break; - case 3: + case RACE_FLAG_3: textId = 0x3499; break; } - SET_FLAGS_FINISH_RACE; + SET_RACE_FLAGS(RACE_FLAG_END); } this->actor.flags |= ACTOR_FLAG_10000; this->actor.textId = textId; this->actionFunc = func_808F395C; - if (this->unk4B0 == 2) { + if (this->unk4B0 == RACE_FLAG_2) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_LOST); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_JOY0); @@ -644,7 +631,7 @@ s32 func_808F4270(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext s32 func_808F43E0(EnIn* this) { this->unk48C = 0; this->actor.textId = 0; - SET_FLAGS_FINISH_RACE; + SET_RACE_FLAGS(RACE_FLAG_END); return 0; } @@ -826,7 +813,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_80151BB4(globalCtx, 0x11); break; case 0x3475: - SET_FLAGS_START_RACE; + SET_RACE_FLAGS(RACE_FLAG_START); func_800FD750(NA_BGM_HORSE); globalCtx->nextEntranceIndex = 0xCE50; globalCtx->unk_1887F = 5; @@ -1073,7 +1060,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; break; case 0x3475: - SET_FLAGS_START_RACE; + SET_RACE_FLAGS(RACE_FLAG_START); func_800FD750(NA_BGM_HORSE); globalCtx->nextEntranceIndex = 0xCE50; globalCtx->unk_1887F = 5; @@ -1331,7 +1318,7 @@ void func_808F5B58(EnIn* this, GlobalContext* globalCtx) { } void func_808F5C98(EnIn* this, GlobalContext* globalCtx) { - if (this->unk4B0 == 0) { + if (this->unk4B0 == RACE_FLAG_END) { this->actionFunc = func_808F5B58; } if ((Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.weekEventReg[63] & 0x40) || @@ -1343,7 +1330,7 @@ void func_808F5C98(EnIn* this, GlobalContext* globalCtx) { } } if (this->unk4A8 == 2) { - if (this->unk4B0 == 2) { + if (this->unk4B0 == RACE_FLAG_2) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_LOST); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_JOY0); @@ -1376,7 +1363,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk48C = 0; this->unk4AC = 0; type = ENIN_GET_TYPE(thisx); - this->unk4B0 = gSaveContext.weekEventReg[92] & (1 | 2 | 4); + this->unk4B0 = GET_RACE_FLAGS; if (type == ENIN_HORSE_RIDER_BLUE_SHIRT || type == 4) { this->unk4AC |= 8; } @@ -1397,20 +1384,19 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { this->path = func_8013D648(globalCtx, ENIN_GET_PATH(&this->actor), 0x3F); this->unk23D = 0; if (type == ENIN_YELLOW_SHIRT || type == ENIN_BLUE_SHIRT) { - if ((gSaveContext.weekEventReg[92] & (1 | 2 | 4)) == 2 || - (gSaveContext.weekEventReg[92] & (1 | 2 | 4)) == 3) { + if (GET_RACE_FLAGS == RACE_FLAG_2 || (GET_RACE_FLAGS) == RACE_FLAG_3) { gSaveContext.weekEventReg[56] &= (u8)~8; this->unk4A8 = 0; this->unk4AC |= 2; func_808F35AC(this, globalCtx); this->unk23C = 0; D_801BDAA0 = 0; - if ((gSaveContext.weekEventReg[92] & (1 | 2 | 4)) == 2) { + if (GET_RACE_FLAGS == RACE_FLAG_2) { func_808F30B0(&this->skelAnime, 6); } else { func_808F30B0(&this->skelAnime, 4); } - if ((gSaveContext.weekEventReg[92] & (1 | 2 | 4)) == 2) { + if (GET_RACE_FLAGS == RACE_FLAG_2) { this->skelAnime.curFrame = ((Rand_ZeroOne() * 0.6f) + 0.2f) * this->skelAnime.endFrame; } if (this->unk4AC & 8) { @@ -1419,7 +1405,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_808F5C98; } } else { - if ((gSaveContext.weekEventReg[92] & (1 | 2 | 4)) != 1) { + if (GET_RACE_FLAGS != RACE_FLAG_START) { gSaveContext.weekEventReg[56] &= (u8)~8; this->unk23C = 0; this->unk4AC |= 2; diff --git a/undefined_syms.txt b/undefined_syms.txt index 3befbefbd..576ebc45b 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1325,15 +1325,6 @@ D_0600D178 = 0x0600D178; D_0600D4E8 = 0x0600D4E8; D_060150D8 = 0x060150D8; -// ovl_En_Horse_Game_Check - -D_060013A0 = 0x060013A0; -D_060014B0 = 0x060014B0; -D_06002FB8 = 0x06002FB8; -D_06003030 = 0x06003030; -D_060030C0 = 0x060030C0; -D_06003918 = 0x06003918; - // ovl_En_Horse_Link_Child D_06002F98 = 0x06002F98; From e43a92de18c242d3acd267071f0cf5df54a3a973 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 26 Mar 2022 02:23:06 +0000 Subject: [PATCH 118/257] En_Attack_Niw (#707) * En_Attack_Niw * PR * newline --- spec | 3 +- .../ovl_En_Attack_Niw/z_en_attack_niw.c | 418 +++++++++++++++++- .../ovl_En_Attack_Niw/z_en_attack_niw.h | 48 +- tools/disasm/functions.txt | 2 +- undefined_syms.txt | 5 - 5 files changed, 448 insertions(+), 28 deletions(-) diff --git a/spec b/spec index 76d84e658..e6b037914 100644 --- a/spec +++ b/spec @@ -1623,8 +1623,7 @@ beginseg name "ovl_En_Attack_Niw" compress include "build/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.o" - include "build/data/ovl_En_Attack_Niw/ovl_En_Attack_Niw.data.o" - include "build/data/ovl_En_Attack_Niw/ovl_En_Attack_Niw.reloc.o" + include "build/src/overlays/actors/ovl_En_Attack_Niw/ovl_En_Attack_Niw_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c index 90e99b5ea..b100f692f 100644 --- a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c +++ b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c @@ -5,6 +5,7 @@ */ #include "z_en_attack_niw.h" +#include "overlays/actors/ovl_En_Niw/z_en_niw.h" #define FLAGS (ACTOR_FLAG_10) @@ -19,7 +20,6 @@ void func_80958634(EnAttackNiw* this, GlobalContext* globalCtx); void func_80958974(EnAttackNiw* this, GlobalContext* globalCtx); void func_80958BE4(EnAttackNiw* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Attack_Niw_InitVars = { ACTOR_EN_ATTACK_NIW, ACTORCAT_ENEMY, @@ -32,35 +32,421 @@ const ActorInit En_Attack_Niw_InitVars = { (ActorFunc)EnAttackNiw_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80959120[] = { +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 1, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), }; -#endif +void EnAttackNiw_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* this = THIS; -extern InitChainEntry D_80959120[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_niw_Skel_002530, &object_niw_Anim_0000E8, this->jointTable, + this->morphTable, OBJECT_NIW_LIMB_MAX); -extern UNK_TYPE D_060000E8; + if (this->actor.params < 0) { + this->actor.params = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/EnAttackNiw_Init.s") + Actor_SetScale(&this->actor, 0.01f); + this->actor.gravity = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/EnAttackNiw_Destroy.s") + this->unk_290.x = randPlusMinusPoint5Scaled(100.0f); + this->unk_290.y = randPlusMinusPoint5Scaled(10.0f); + this->unk_290.z = randPlusMinusPoint5Scaled(100.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958228.s") + Actor_SetScale(&this->actor, 0.01f); + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.shape.rot.y = this->actor.world.rot.y = (Rand_ZeroOne() - 0.5f) * 60000.0f; + this->actionFunc = func_80958634; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_809585B0.s") +void EnAttackNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* this = THIS; + EnNiw* parent = (EnNiw*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958634.s") + if ((thisx->parent != NULL) && (thisx->parent->update != NULL)) { + if (parent->unk290 > 0) { + parent->unk290--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958974.s") +void func_80958228(EnAttackNiw* this, GlobalContext* globalCtx, s16 arg2) { + if (this->unk_24C == 0) { + if (arg2 == 0) { + this->unk_25C = 0.0f; + } else { + this->unk_25C = -10000.0f; + } + this->unk_286++; + this->unk_24C = 3; + if ((this->unk_286 % 2) == 0) { + this->unk_25C = 0.0f; + if (arg2 == 0) { + this->unk_24C = Rand_ZeroFloat(30.0f); + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958BE4.s") + if (this->unk_250 == 0) { + this->unk_28A++; + this->unk_28A &= 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/EnAttackNiw_Update.s") + switch (arg2) { + case 0: + this->unk_264 = 0.0f; + this->unk_260 = 0.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958F6C.s") + case 1: + this->unk_250 = 3; + this->unk_264 = 7000.0f; + this->unk_260 = 7000.0f; + if (this->unk_28A == 0) { + this->unk_264 = 0.0f; + this->unk_260 = 0.0f; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/EnAttackNiw_Draw.s") + case 2: + this->unk_250 = 2; + this->unk_264 = -10000.0f; + this->unk_260 = -10000.0f; + this->unk_278 = 25000.0f; + this->unk_270 = 25000.0f; + this->unk_27C = 6000.0f; + this->unk_274 = 6000.0f; + if (this->unk_28A == 0) { + this->unk_270 = 8000.0f; + this->unk_278 = 8000.0f; + } + break; + + case 3: + this->unk_250 = 2; + this->unk_270 = 10000.0f; + this->unk_278 = 10000.0f; + if (this->unk_28A == 0) { + this->unk_270 = 3000.0f; + this->unk_278 = 3000.0f; + } + break; + + case 4: + this->unk_24E = 5; + this->unk_24C = this->unk_24E; + break; + + case 5: + this->unk_250 = 5; + this->unk_270 = 14000.0f; + this->unk_278 = 14000.0f; + if (this->unk_28A == 0) { + this->unk_270 = 10000.0f; + this->unk_278 = 10000.0f; + } + break; + } + } + + if (this->unk_280 != this->unk_2B8) { + Math_ApproachF(&this->unk_2B8, this->unk_280, 0.5f, 4000.0f); + } + + if (this->unk_25C != this->unk_2B4) { + Math_ApproachF(&this->unk_2B4, this->unk_25C, 0.5f, 4000.0f); + } + + if (this->unk_264 != this->unk_29C) { + Math_ApproachF(&this->unk_29C, this->unk_264, 0.8f, 7000.0f); + } + + if (this->unk_278 != this->unk_2A0) { + Math_ApproachF(&this->unk_2A0, this->unk_278, 0.8f, 7000.0f); + } + + if (this->unk_27C != this->unk_2A4) { + Math_ApproachF(&this->unk_2A4, this->unk_27C, 0.8f, 7000.0f); + } + + if (this->unk_260 != this->unk_2A8) { + Math_ApproachF(&this->unk_2A8, this->unk_260, 0.8f, 7000.0f); + } + + if (this->unk_270 != this->unk_2AC) { + Math_ApproachF(&this->unk_2AC, this->unk_270, 0.8f, 7000.0f); + } + + if (this->unk_274 != this->unk_2B0) { + Math_ApproachF(&this->unk_2B0, this->unk_274, 0.8f, 7000.0f); + } +} + +s32 func_809585B0(EnAttackNiw* this, GlobalContext* globalCtx) { + s16 sp1E; + s16 sp1C; + + Actor_SetFocus(&this->actor, this->unk_2DC); + Actor_GetScreenPos(globalCtx, &this->actor, &sp1E, &sp1C); + + if ((this->actor.projectedPos.z < -20.0f) || (sp1E < 0) || (sp1E > SCREEN_WIDTH) || (sp1C < 0) || + (sp1C > SCREEN_HEIGHT)) { + return false; + } + return true; +} + +void func_80958634(EnAttackNiw* this, GlobalContext* globalCtx) { + s16 sp4E; + s16 sp4C; + Vec3f temp; + Vec3f sp34; + s32 pad; + + this->actor.speedXZ = 10.0f; + + temp.x = (this->unk_290.x + globalCtx->view.at.x) - globalCtx->view.eye.x; + temp.y = (this->unk_290.y + globalCtx->view.at.y) - globalCtx->view.eye.y; + temp.z = (this->unk_290.z + globalCtx->view.at.z) - globalCtx->view.eye.z; + + sp34.x = globalCtx->view.at.x + temp.x; + sp34.y = globalCtx->view.at.y + temp.y; + sp34.z = globalCtx->view.at.z + temp.z; + + this->unk_2CC = Math_Vec3f_Yaw(&this->actor.world.pos, &sp34); + this->unk_2C8 = Math_Vec3f_Pitch(&this->actor.world.pos, &sp34) * -1.0f; + + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2CC, 5, this->unk_2D4, 0); + Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2C8, 5, this->unk_2D4, 0); + Math_ApproachF(&this->unk_2D4, 5000.0f, 1.0f, 100.0f); + + Actor_SetFocus(&this->actor, this->unk_2DC); + Actor_GetScreenPos(globalCtx, &this->actor, &sp4E, &sp4C); + + if (this->actor.bgCheckFlags & 8) { + this->unk_2CC = this->actor.yawTowardsPlayer; + this->unk_2C8 = this->actor.world.rot.x - 3000.0f; + this->unk_252 = 0; + this->unk_254 = 100; + this->unk_2D4 = 0.0f; + this->unk_27C = 0.0f; + this->unk_274 = 0.0f; + this->unk_250 = this->unk_252; + this->unk_24E = this->unk_252; + this->unk_24C = this->unk_252; + this->actor.gravity = -0.2f; + this->unk_280 = 0.0f; + this->actionFunc = func_80958974; + this->unk_2D8 = 5.0f; + } else if (((this->actor.projectedPos.z > 0.0f) && (fabsf(sp34.x - this->actor.world.pos.x) < 50.0f) && + (fabsf(sp34.y - this->actor.world.pos.y) < 50.0f) && + (fabsf(sp34.z - this->actor.world.pos.z) < 50.0f)) || + (this->actor.bgCheckFlags & 1)) { + this->unk_252 = 0; + this->unk_250 = this->unk_252; + this->unk_24E = this->unk_252; + this->unk_24C = this->unk_252; + this->unk_2D4 = 0.0f; + this->unk_274 = 0.0f; + this->unk_27C = 0.0f; + this->unk_2CC = this->actor.yawTowardsPlayer; + this->unk_2C8 = this->actor.world.rot.x - 2000.0f; + this->actor.gravity = -0.2f; + this->unk_280 = 0.0f; + this->actionFunc = func_80958974; + this->unk_2D8 = 5.0f; + } else { + this->unk_24C = 10; + this->unk_25C = -10000.0f; + this->unk_280 = -3000.0f; + func_80958228(this, globalCtx, 2); + } +} + +void func_80958974(EnAttackNiw* this, GlobalContext* globalCtx) { + if (!func_809585B0(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (this->actor.bgCheckFlags & 1) { + if (this->unk_252 == 0) { + this->unk_252 = 3; + this->actor.velocity.y = 3.5f; + } + + if (this->actor.gravity != -2.0f) { + this->unk_2CC = this->actor.yawTowardsPlayer; + this->unk_25A = 50; + this->unk_254 = 100; + this->unk_270 = 14000.0f; + this->unk_278 = 14000.0f; + this->unk_274 = 0.0f; + this->unk_27C = 0.0f; + this->unk_260 = 0.0f; + this->unk_264 = 0.0f; + this->unk_2C8 = 0.0f; + this->actor.gravity = -2.0f; + } + } + + if (this->unk_254 == 50) { + this->unk_2CC = randPlusMinusPoint5Scaled(200.0f) + this->actor.yawTowardsPlayer; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2CC, 2, this->unk_2D4, 0); + Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2C8, 2, this->unk_2D4, 0); + Math_ApproachF(&this->unk_2D4, 10000.0f, 1.0f, 1000.0f); + Math_ApproachF(&this->actor.speedXZ, this->unk_2D8, 0.9f, 1.0f); + + if ((this->actor.gravity == -2.0f) && (this->unk_25A == 0) && + ((this->actor.bgCheckFlags & 8) || (this->unk_254 == 0))) { + this->unk_2D8 = 0.0f; + this->actor.gravity = 0.0f; + this->unk_2D4 = 0.0f; + this->unk_2C8 = this->actor.world.rot.x - 5000.0f; + this->actionFunc = func_80958BE4; + } else if (this->actor.bgCheckFlags & 1) { + func_80958228(this, globalCtx, 5); + } else { + func_80958228(this, globalCtx, 2); + } +} + +void func_80958BE4(EnAttackNiw* this, GlobalContext* globalCtx) { + if (!func_809585B0(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } + + Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2C8, 5, this->unk_2D4, 0); + Math_ApproachF(&this->unk_2D4, 5000.0f, 1.0f, 100.0f); + Math_ApproachF(&this->actor.velocity.y, 5.0f, 0.3f, 1.0f); + func_80958228(this, globalCtx, 2); +} + +void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* this = THIS; + s32 pad; + EnNiw* parent; + Player* player = GET_PLAYER(globalCtx); + s32 pad2; + Vec3f sp30; + + this->unk_284++; + + if (this->unk_24C != 0) { + this->unk_24C--; + } + + if (this->unk_250 != 0) { + this->unk_250--; + } + + if (this->unk_252 != 0) { + this->unk_252--; + } + + if (this->unk_256 != 0) { + this->unk_256--; + } + + if (this->unk_258 != 0) { + this->unk_258--; + } + + if (this->unk_254 != 0) { + this->unk_254--; + } + + if (this->unk_25A != 0) { + this->unk_25A--; + } + + this->actor.shape.rot = this->actor.world.rot; + this->actor.shape.shadowScale = 15.0f; + + this->actionFunc(this, globalCtx); + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); + + if (this->actionFunc == func_80958634) { + Actor_MoveWithoutGravity(&this->actor); + } else { + Actor_MoveWithGravity(&this->actor); + } + + if (this->actor.floorHeight <= -32000.0f) { + Actor_MarkForDeath(&this->actor); + } else if ((this->actor.bgCheckFlags & 0x20) && (this->actionFunc != func_80958BE4)) { + Math_Vec3f_Copy(&sp30, &this->actor.world.pos); + sp30.y += this->actor.depthInWater; + + EffectSsGSplash_Spawn(globalCtx, &sp30, NULL, NULL, 0, 400); + this->unk_2D4 = 0.0f; + this->actor.gravity = 0.0f; + this->unk_2D8 = 0.0f; + this->unk_2C8 = this->actor.world.rot.x - 5000.0f; + this->actionFunc = func_80958BE4; + } else { + f32 temp = 20.0f; + + label: + + if (this->actor.xyzDistToPlayerSq < SQ(temp)) { + parent = (EnNiw*)this->actor.parent; + if ((this->actor.parent->update != NULL) && (this->actor.parent != NULL) && (parent != NULL) && + (parent->unusedTimer25E == 0) && (player->invincibilityTimer == 0)) { + func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); + parent->unusedTimer25E = 70; + } + } + + if (this->unk_256 == 0) { + this->unk_256 = 30; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_A); + } + + if (this->unk_258 == 0) { + this->unk_258 = 7; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); + } + } +} + +s32 EnAttackNiw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnAttackNiw* this = THIS; + + if (limbIndex == OBJECT_NIW_LIMB_0D) { + rot->y += (s16)this->unk_2B4; + } + + if (limbIndex == OBJECT_NIW_LIMB_0F) { + rot->z += (s16)this->unk_2B8; + } + + if (limbIndex == OBJECT_NIW_LIMB_0B) { + rot->x += (s16)this->unk_2B0; + rot->y += (s16)this->unk_2AC; + rot->z += (s16)this->unk_2A8; + } + + if (limbIndex == OBJECT_NIW_LIMB_07) { + rot->x += (s16)this->unk_2A4; + rot->y += (s16)this->unk_2A0; + rot->z += (s16)this->unk_29C; + } + return false; +} + +void EnAttackNiw_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnAttackNiw_OverrideLimbDraw, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h index 27d5546a1..4d3243ef5 100644 --- a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h +++ b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h @@ -2,16 +2,56 @@ #define Z_EN_ATTACK_NIW_H #include "global.h" +#include "objects/object_niw/object_niw.h" struct EnAttackNiw; typedef void (*EnAttackNiwActionFunc)(struct EnAttackNiw*, GlobalContext*); typedef struct EnAttackNiw { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; - /* 0x0248 */ EnAttackNiwActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x94]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[OBJECT_NIW_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[OBJECT_NIW_LIMB_MAX]; + /* 0x248 */ EnAttackNiwActionFunc actionFunc; + /* 0x24C */ s16 unk_24C; + /* 0x24E */ s16 unk_24E; + /* 0x250 */ s16 unk_250; + /* 0x252 */ s16 unk_252; + /* 0x254 */ s16 unk_254; + /* 0x256 */ s16 unk_256; + /* 0x258 */ s16 unk_258; + /* 0x25A */ s16 unk_25A; + /* 0x25C */ f32 unk_25C; + /* 0x260 */ f32 unk_260; + /* 0x264 */ f32 unk_264; + /* 0x268 */ UNK_TYPE1 unk268[8]; + /* 0x270 */ f32 unk_270; + /* 0x274 */ f32 unk_274; + /* 0x278 */ f32 unk_278; + /* 0x27C */ f32 unk_27C; + /* 0x280 */ f32 unk_280; + /* 0x284 */ s16 unk_284; + /* 0x286 */ s16 unk_286; + /* 0x288 */ UNK_TYPE1 unk288[2]; + /* 0x28A */ s16 unk_28A; + /* 0x28C */ UNK_TYPE1 unk28C[4]; + /* 0x290 */ Vec3f unk_290; + /* 0x29C */ f32 unk_29C; + /* 0x2A0 */ f32 unk_2A0; + /* 0x2A4 */ f32 unk_2A4; + /* 0x2A8 */ f32 unk_2A8; + /* 0x2AC */ f32 unk_2AC; + /* 0x2B0 */ f32 unk_2B0; + /* 0x2B4 */ f32 unk_2B4; + /* 0x2B8 */ f32 unk_2B8; + /* 0x2BC */ UNK_TYPE1 unk2BC[0xC]; + /* 0x2C8 */ f32 unk_2C8; + /* 0x2CC */ f32 unk_2CC; + /* 0x2D0 */ UNK_TYPE1 unk2D0[4]; + /* 0x2D4 */ f32 unk_2D4; + /* 0x2D8 */ f32 unk_2D8; + /* 0x2DC */ f32 unk_2DC; } EnAttackNiw; // size = 0x2E0 extern const ActorInit En_Attack_Niw_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 43dd0963f..bca55a746 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -7686,7 +7686,7 @@ 0x80958974:("func_80958974",), 0x80958BE4:("func_80958BE4",), 0x80958CA8:("EnAttackNiw_Update",), - 0x80958F6C:("func_80958F6C",), + 0x80958F6C:("EnAttackNiw_OverrideLimbDraw",), 0x8095909C:("EnAttackNiw_Draw",), 0x809592E0:("func_809592E0",), 0x80959390:("EnMk_Init",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 576ebc45b..0ac18443b 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1053,11 +1053,6 @@ D_060028A0 = 0x060028A0; D_06009220 = 0x06009220; D_06009D34 = 0x06009D34; -// ovl_En_Attack_Niw - -D_060000E8 = 0x060000E8; -D_06002530 = 0x06002530; - // ovl_En_Az D_06007438 = 0x06007438; From 36e48fcd91b0a4e1826bb2105d9a7f78aa499790 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 26 Mar 2022 02:33:02 +0000 Subject: [PATCH 119/257] En_Tanron1 (#708) * En_Tanron1 * PR * Fmt * PR and match (thanks petrie) --- assets/xml/overlays/ovl_En_Tanron1.xml | 7 + spec | 3 +- .../actors/ovl_En_Tanron1/z_en_tanron1.c | 389 +++++++++++++++++- .../actors/ovl_En_Tanron1/z_en_tanron1.h | 31 +- 4 files changed, 418 insertions(+), 12 deletions(-) create mode 100644 assets/xml/overlays/ovl_En_Tanron1.xml diff --git a/assets/xml/overlays/ovl_En_Tanron1.xml b/assets/xml/overlays/ovl_En_Tanron1.xml new file mode 100644 index 000000000..17cf5faf5 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Tanron1.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spec b/spec index e6b037914..c6faa6511 100644 --- a/spec +++ b/spec @@ -4508,8 +4508,7 @@ beginseg name "ovl_En_Tanron1" compress include "build/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.o" - include "build/data/ovl_En_Tanron1/ovl_En_Tanron1.data.o" - include "build/data/ovl_En_Tanron1/ovl_En_Tanron1.reloc.o" + include "build/src/overlays/actors/ovl_En_Tanron1/ovl_En_Tanron1_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c index 5985e77f9..b7e5588f7 100644 --- a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c +++ b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c @@ -15,7 +15,9 @@ void EnTanron1_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTanron1_Update(Actor* thisx, GlobalContext* globalCtx); void EnTanron1_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx); +void func_80BB5AAC(EnTanron1* this, GlobalContext* globalCtx); + const ActorInit En_Tanron1_InitVars = { ACTOR_EN_TANRON1, ACTORCAT_ENEMY, @@ -28,18 +30,387 @@ const ActorInit En_Tanron1_InitVars = { (ActorFunc)EnTanron1_Draw, }; -#endif +static u64 sPad = { 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/EnTanron1_Init.s") +#include "overlays/ovl_En_Tanron1/ovl_En_Tanron1.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/EnTanron1_Destroy.s") +void EnTanron1_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTanron1* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/func_80BB4E50.s") + this->actor.flags &= ~ACTOR_FLAG_1; + if (!ENTANRON1_GET_100(&this->actor)) { + this->unk_144 = 0; + } else { + this->actor.params = 200; + this->unk_144 = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/EnTanron1_Update.s") +void EnTanron1_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/EnTanron1_Draw.s") +void func_80BB4E50(EnTanron1Struct* arg0, Vec3f* arg1, s16 arg2) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/func_80BB5318.s") + for (i = 0; i < 200; i++, arg0++) { + if (arg0->unk_24 == 0) { + arg0->unk_24 = 1; + arg0->unk_2C = 0.0f; + arg0->unk_00 = *arg1; + arg0->unk_18 = arg0->unk_1C = 0; + arg0->unk_1A = arg2; + arg0->unk_26 = Rand_ZeroFloat(100.0f); + arg0->unk_28 = 0; + if (Rand_ZeroOne() < 0.5f) { + arg0->unk_2A = 0xC00; + } else { + arg0->unk_2A = -0xC00; + } + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/func_80BB5AAC.s") +void EnTanron1_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTanron1* this = THIS; + Actor* temp_a0; + Player* player = GET_PLAYER(globalCtx); + s16 i; + EnTanron1Struct* ptr = &this->unk_160[0]; + Vec3f temp; + f32 phi_f18; + s32 pad; + + if (this->unk_148 != 0) { + this->unk_148--; + } + + switch (this->unk_144) { + case 0: + for (i = 0; i < this->actor.params; i++) { + func_80BB4E50(this->unk_160, &this->actor.world.pos, Rand_ZeroFloat(0x10000)); + } + this->unk_144 = 200; + break; + + case 1: + this->unk_14C.x = player->actor.world.pos.x; + this->unk_14C.y = player->actor.world.pos.y + 60.0f; + this->unk_14C.z = player->actor.world.pos.z; + if (this->unk_148 != 0) { + func_80BB4E50(this->unk_160, &this->actor.world.pos, this->actor.world.rot.y); + } + this->unk_158 = 0x1000; + this->unk_15C = 150.0f; + break; + + case 100: + phi_f18 = 10.0f; + + while (phi_f18 < 1000.0f) { + temp_a0 = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; + while (temp_a0 != NULL) { + if (temp_a0->id != ACTOR_OBJ_SYOKUDAI) { + temp_a0 = temp_a0->next; + continue; + } + + temp.x = this->unk_14C.x - temp_a0->world.pos.x; + temp.y = (this->unk_14C.y - temp_a0->world.pos.y) + 70.0f; + temp.z = this->unk_14C.z - temp_a0->world.pos.z; + + if (sqrtf(SQXYZ(temp)) < phi_f18) { + this->unk_14C.x = temp_a0->world.pos.x; + this->unk_14C.y = temp_a0->world.pos.y + 70.0f; + this->unk_14C.z = temp_a0->world.pos.z; + goto end; + } + temp_a0 = temp_a0->next; + } + phi_f18 += 20.0f; + } + end: + break; + + case 200: + this->unk_14C = this->actor.world.pos; + this->unk_158 = 0x5000; + this->unk_15C = 50.0f; + break; + + case 250: + for (i = 0; i < ARRAY_COUNT(this->unk_160); i++, ptr++) { + if ((ptr->unk_24 != 0) && (ptr->unk_28 < 8)) { + ptr->unk_28 = 8; + ptr->unk_24 = 2; + } + } + this->unk_144 = 1; + break; + } + + if ((player->itemActionParam == 7) && (player->unk_B28 != 0)) { + this->unk_14C.x = player->swordInfo[0].tip.x; + this->unk_14C.y = player->swordInfo[0].tip.y; + this->unk_14C.z = player->swordInfo[0].tip.z; + + this->unk_158 = 0x5000; + this->unk_15C = 50.0f; + if (this->unk_144 != 1) { + this->unk_144 = 100; + } + } else { + temp_a0 = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + while (temp_a0 != NULL) { + if (temp_a0->params == 1) { + temp_a0 = temp_a0->next; + continue; + } + + this->unk_14C.x = temp_a0->world.pos.x; + this->unk_14C.y = temp_a0->world.pos.y + 50.0f; + this->unk_14C.z = temp_a0->world.pos.z; + + this->unk_15C = 150.0f; + this->unk_158 = 0x1000; + if (this->unk_144 != 1) { + this->unk_144 = 100; + } + break; + } + } + func_80BB5318(this, globalCtx); +} + +void EnTanron1_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTanron1* this = THIS; + + func_80BB5AAC(this, globalCtx); +} + +void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnTanron1Struct* ptr = NULL; + f32 phi_f28 = 0.0f; + Vec3f* phi_s2 = NULL; + Vec3f temp; + s16 spBA = 0; + s16 spB8 = 0; + Vec3f* spB4 = NULL; + f32 spB0; + Vec3f spA4; + WaterBox* spA0; + f32 sp9C; + CollisionPoly* sp98; + Actor* temp_v0; + s16 i; + f32 temp_f30 = this->unk_15C; + + if (player->unk_ADC != 0) { + phi_s2 = &player->swordInfo[0].tip; + if (player->swordAnimation >= 30) { + phi_f28 = 2500.0f; + } else { + phi_f28 = 400.0f; + } + } + + temp_v0 = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + while (temp_v0 != NULL) { + if (temp_v0->params != 1) { + temp_v0 = temp_v0->next; + continue; + } + phi_s2 = &temp_v0->world.pos; + phi_f28 = 40000.0f; + break; + } + + ptr = &this->unk_160[0]; + for (i = 0; i < this->actor.params; i++, ptr++) { + if (ptr->unk_24 != 0) { + ptr->unk_26++; + ptr->unk_00.x += ptr->unk_0C.x; + ptr->unk_00.y += ptr->unk_0C.y; + ptr->unk_00.z += ptr->unk_0C.z; + + if (ptr->unk_24 == 0) { + } else { + spB4 = &ptr->unk_00; + if (ptr->unk_28 == 0) { + spBA++; + ptr->unk_2C = Math_SinS(ptr->unk_26 * 0x5000) * 1.2f; + if ((ptr->unk_26 & 3) == 0) { + temp.x = ptr->unk_30 + (this->unk_14C.x - ptr->unk_00.x); + temp.y = ptr->unk_34 + (this->unk_14C.y - ptr->unk_00.y); + temp.z = ptr->unk_38 + (this->unk_14C.z - ptr->unk_00.z); + + ptr->unk_20 = Math_Atan2S(temp.x, temp.z); + ptr->unk_1E = Math_Atan2S(temp.y, sqrtf(SQXZ(temp))); + if ((ptr->unk_26 & 0xF) == 0) { + ptr->unk_30 = randPlusMinusPoint5Scaled(temp_f30); + ptr->unk_34 = randPlusMinusPoint5Scaled(temp_f30 * 0.5f); + ptr->unk_38 = randPlusMinusPoint5Scaled(temp_f30); + } + + temp.x = player->actor.world.pos.x - ptr->unk_00.x; + temp.y = (player->actor.world.pos.y + 40.0f) - ptr->unk_00.y; + temp.z = player->actor.world.pos.z - ptr->unk_00.z; + + if ((SQXYZ(temp) < 400.0f) && (player->transformation != PLAYER_FORM_DEKU)) { + func_800B8D10(globalCtx, &this->actor, 0.0f, 0, 0.0f, 1, 1); + } + } + + Math_ApproachS(&ptr->unk_1A, ptr->unk_20, 2, this->unk_158); + Math_ApproachS(&ptr->unk_18, ptr->unk_1E, 2, this->unk_158); + Matrix_RotateY(ptr->unk_1A, MTXMODE_NEW); + Matrix_InsertXRotation_s(-ptr->unk_18, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(6.0f, &ptr->unk_0C); + + if (phi_s2 != NULL) { + temp.x = phi_s2->x - ptr->unk_00.x; + temp.y = phi_s2->y - ptr->unk_00.y; + temp.z = phi_s2->z - ptr->unk_00.z; + + if (SQXYZ(temp) < phi_f28) { + ptr->unk_20 = Math_Atan2S(temp.x, temp.z); + ptr->unk_1E = Math_Atan2S(temp.y, sqrtf(SQXZ(temp))); + + Matrix_RotateY(ptr->unk_20, MTXMODE_NEW); + Matrix_InsertXRotation_s(-ptr->unk_1E, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(-20.0f, &ptr->unk_0C); + + if (phi_f28 >= 100000.0f) { + ptr->unk_28 = 1; + } else { + ptr->unk_28 = 6; + } + ptr->unk_24 = 2; + spB8++; + } + } + } else if (ptr->unk_28 < 9) { + ptr->unk_18 += 0x3000; + ptr->unk_1A += 0x5000; + ptr->unk_30 = 0.0f; + ptr->unk_34 = 0.0f; + ptr->unk_28++; + } else { + ptr->unk_1A += ptr->unk_2A; + Math_ApproachS(&ptr->unk_18, 0, 0xA, 0x1000); + Matrix_RotateY(ptr->unk_1A, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(ptr->unk_30, &spA4); + + ptr->unk_0C.x = spA4.x; + ptr->unk_0C.z = spA4.z; + ptr->unk_0C.y = -2.0f; + + if (phi_s2 != NULL) { + temp.x = phi_s2->x - ptr->unk_00.x; + temp.y = phi_s2->y - ptr->unk_00.y; + temp.z = phi_s2->z - ptr->unk_00.z; + + if (SQXYZ(temp) < phi_f28) { + ptr->unk_20 = Math_Atan2S(temp.x, temp.z); + ptr->unk_1E = Math_Atan2S(temp.y, sqrtf(SQXZ(temp))); + + Matrix_RotateY(ptr->unk_20, MTXMODE_NEW); + Matrix_InsertXRotation_s(-ptr->unk_1E, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(-20.0f, &ptr->unk_0C); + + ptr->unk_3C = ptr->unk_00.y - 1000.0f; + ptr->unk_30 = 5.0f; + } + } + + if (ptr->unk_00.y <= (ptr->unk_3C + 5.0f)) { + ptr->unk_00.y = (ptr->unk_3C + 5.0f); + Math_ApproachZeroF(&ptr->unk_30, 1.0f, 0.3f); + Math_ApproachS(&ptr->unk_2A, 0, 1, 0x100); + ptr->unk_28++; + if (ptr->unk_28 > 50) { + ptr->unk_24 = 0; + } + } else { + Math_ApproachF(&ptr->unk_30, ptr->unk_34, 1.0f, 0.5f); + if ((ptr->unk_26 & 0xF) == 0) { + if (Rand_ZeroOne() < 0.5f) { + ptr->unk_34 = randPlusMinusPoint5Scaled(12.0f); + } + ptr->unk_3C = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp98, &ptr->unk_00); + sp9C = ptr->unk_00.y; + WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, ptr->unk_00.x, ptr->unk_00.z, &sp9C, + &spA0); + if ((sp9C < ptr->unk_00.y) && (ptr->unk_3C < sp9C)) { + ptr->unk_3C = sp9C; + } + } + } + } + } + } + } + + if (spB4 != NULL) { + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, spB4, &this->unk_3360, &spB0); + if (spB8 >= (s16)(KREG(39) + 20)) { + Audio_PlaySfxAtPos(&this->unk_3360, NA_SE_EN_MB_MOTH_DEAD); + } else if (spBA >= 20) { + Audio_PlaySfxAtPos(&this->unk_3360, NA_SE_EN_MB_MOTH_FLY - SFX_FLAG); + } + } +} + +void func_80BB5AAC(EnTanron1* this, GlobalContext* globalCtx) { + EnTanron1Struct* ptrBase = &this->unk_160[0]; + s16 i; + u8 flag = 0; + EnTanron1Struct* ptr = ptrBase; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < this->actor.params; i++, ptr++) { + if (ptr->unk_24 == 1) { + if (!flag) { + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001888); + flag++; + } + Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateY(ptr->unk_1A, MTXMODE_APPLY); + Matrix_InsertXRotation_s(ptr->unk_18 * -1, MTXMODE_APPLY); + Matrix_Scale(1.2f, ptr->unk_2C, 1.2f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001900); + } + } + + flag = 0; + ptr = ptrBase; + for (i = 0; i < this->actor.params; i++, ptr++) { + if (ptr->unk_24 != 2) { + continue; + } + + if (!flag) { + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001888); + gDPLoadTextureBlock(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001428, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 32, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 4, 5, G_TX_NOLOD, G_TX_NOLOD); + flag++; + } + + Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateY(ptr->unk_1A, MTXMODE_APPLY); + Matrix_InsertXRotation_s(ptr->unk_18 * -1, MTXMODE_APPLY); + Matrix_Scale(1.0f, ptr->unk_2C, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001900); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h index b32810084..d8e96537f 100644 --- a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h +++ b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h @@ -5,9 +5,38 @@ struct EnTanron1; +#define ENTANRON1_GET_100(thisx) ((thisx)->params & 0x100) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ s16 unk_18; + /* 0x1A */ s16 unk_1A; + /* 0x1C */ s16 unk_1C; + /* 0x1E */ s16 unk_1E; + /* 0x20 */ s16 unk_20; + /* 0x22 */ UNK_TYPE1 unk_22[0x2]; + /* 0x24 */ u8 unk_24; + /* 0x26 */ s16 unk_26; + /* 0x28 */ s16 unk_28; + /* 0x2A */ s16 unk_2A; + /* 0x2C */ f32 unk_2C; + /* 0x30 */ f32 unk_30; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; + /* 0x3C */ f32 unk_3C; +} EnTanron1Struct; // size = 0x40 + typedef struct EnTanron1 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_0144[0x3228]; + /* 0x0144 */ u8 unk_144; + /* 0x0145 */ UNK_TYPE1 pad145[3]; + /* 0x0148 */ s16 unk_148; + /* 0x014C */ Vec3f unk_14C; + /* 0x0158 */ s16 unk_158; + /* 0x015C */ f32 unk_15C; + /* 0x0160 */ EnTanron1Struct unk_160[200]; + /* 0x3360 */ Vec3f unk_3360; } EnTanron1; // size = 0x336C extern const ActorInit En_Tanron1_InitVars; From 9a41b76f35539a59d19c864b60c20f06de299129 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Fri, 25 Mar 2022 19:43:14 -0700 Subject: [PATCH 120/257] SubS ActorPathing (#689) * Bring code over * Clean up * Renames * Cleanup * Split SubS stuff from z64 into z64subs * newline * Bss * Name callbacks * bss * bss --- include/functions.h | 12 +- include/z64.h | 40 +----- include/z64subs.h | 60 ++++++++ src/code/z_skelanime.c | 1 - src/code/z_sub_s.c | 131 +++++++++++++++++- .../ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c | 1 + src/overlays/actors/ovl_En_Dno/z_en_dno.c | 78 ++++++----- src/overlays/actors/ovl_En_Dno/z_en_dno.h | 2 +- src/overlays/actors/ovl_En_Ot/z_en_ot.c | 81 ++++++----- src/overlays/actors/ovl_En_Ot/z_en_ot.h | 2 +- tools/actorfixer.py | 6 + tools/disasm/functions.txt | 20 +-- tools/sizes/code_functions.csv | 12 +- 13 files changed, 296 insertions(+), 150 deletions(-) create mode 100644 include/z64subs.h diff --git a/include/functions.h b/include/functions.h index 4b08dca2b..4da5b59e4 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2481,12 +2481,12 @@ Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorC s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs); s32 func_8013DB90(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2); s32 func_8013DC40(Path* arg0, s32 arg1, s32 arg2, Vec3f* arg3); -void func_8013DCE0(GlobalContext* globalCtx, Vec3f* arg1, Actor* arg2, struct_8013DF3C_arg1* arg3, Path* arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, u8 arg9); -s32 func_8013DE04(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1, struct_8013DF3C_arg1_unk_func1 arg2, struct_8013DF3C_arg1_unk_func2 arg3, struct_8013DF3C_arg1_unk_func2 arg4, struct_8013DF3C_arg1_unk_func2 arg5); -void func_8013DF3C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); -s32 func_8013E054(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); -s32 func_8013E07C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); -s32 func_8013E0A4(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); +void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags); +s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc); +void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_MoveWithGravity(GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_MoveWithoutGravityReverse(GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_SetNextPoint(GlobalContext* globalCtx, ActorPathing* actorPath); void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, s32* curIndex); s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type); s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes); diff --git a/include/z64.h b/include/z64.h index 3e8219da7..c8e423cfb 100644 --- a/include/z64.h +++ b/include/z64.h @@ -39,6 +39,7 @@ #include "z64save.h" #include "z64scene.h" #include "z64skin.h" +#include "z64subs.h" #include "z64transition.h" #include "regs.h" @@ -1369,45 +1370,6 @@ typedef struct { /* 0x8 */ s32 unk8; // game script pointer? } struct_80133038_arg2; // size = 0xC - -typedef enum { - /* 0 */ SUBS_CUTSCENE_SET_UNK_LINK_FIELDS, - /* 1 */ SUBS_CUTSCENE_NORMAL, - /* 2 */ SUBS_CUTSCENE_SET_FLAG -} SubSCutsceneType; - -typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, Vec3s*); - -typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); - -struct struct_8013DF3C_arg1; -typedef void (*struct_8013DF3C_arg1_unk_func1)(struct GlobalContext*, struct struct_8013DF3C_arg1*); -typedef s32 (*struct_8013DF3C_arg1_unk_func2)(struct GlobalContext*, struct struct_8013DF3C_arg1*); - -typedef struct struct_8013DF3C_arg1 { - /* 0x00 */ Path* setupPathList; - /* 0x04 */ s32 pathIndex; - /* 0x08 */ Vec3s* points; - /* 0x0C */ s32 count; - /* 0x10 */ s32 unk_10; - /* 0x14 */ s32 unk_14; - /* 0x18 */ s32 unk_18; - /* 0x1C */ u8 unk_1C; - /* 0x1D */ u8 unk_1D; - /* 0x20 */ Vec3f unk_20; - /* 0x2C */ Vec3f unk_2C; - /* 0x38 */ Vec3f unk_38; - /* 0x44 */ Vec3f* unk_44; - /* 0x48 */ Actor* actor; - /* 0x4C */ f32 unk_4C; - /* 0x50 */ f32 unk_50; - /* 0x54 */ Vec3s unk_54; - /* 0x5C */ struct_8013DF3C_arg1_unk_func1 unk_5C; - /* 0x60 */ struct_8013DF3C_arg1_unk_func2 unk_60; - /* 0x64 */ struct_8013DF3C_arg1_unk_func2 unk_64; - /* 0x68 */ struct_8013DF3C_arg1_unk_func2 unk_68; -} struct_8013DF3C_arg1; // size = 0x6C - typedef struct { /* 0x00 */ u32 type; /* 0x04 */ u32 setScissor; diff --git a/include/z64subs.h b/include/z64subs.h new file mode 100644 index 000000000..7ef51c348 --- /dev/null +++ b/include/z64subs.h @@ -0,0 +1,60 @@ +#ifndef Z64SUBS_H +#define Z64SUBS_H + +#include "z64actor.h" +#include "z64scene.h" + +typedef enum { + /* 0 */ SUBS_CUTSCENE_SET_UNK_LINK_FIELDS, + /* 1 */ SUBS_CUTSCENE_NORMAL, + /* 2 */ SUBS_CUTSCENE_SET_FLAG +} SubSCutsceneType; + +typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, Vec3s*); + +typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); + +#define ACTOR_PATHING_RETURN_TO_START (1 << 0) +#define ACTOR_PATHING_SWITCH_DIRECTION (1 << 1) +#define ACTOR_PATHING_MOVE_BACKWARDS (1 << 3) +#define ACTOR_PATHING_REACHED_POINT_PERMANENT (1 << 4) +#define ACTOR_PATHING_REACHED_END_PERMANENT (1 << 5) +#define ACTOR_PATHING_REACHED_POINT_TEMPORARY (1 << 6) +#define ACTOR_PATHING_REACHED_END_TEMPORARY (1 << 7) + +#define ACTOR_PATHING_REACHED_TEMPORARY \ + (ACTOR_PATHING_REACHED_POINT_TEMPORARY | ACTOR_PATHING_REACHED_END_TEMPORARY) +#define ACTOR_PATHING_REACHED_POINT \ + (ACTOR_PATHING_REACHED_POINT_PERMANENT | ACTOR_PATHING_REACHED_POINT_TEMPORARY) +#define ACTOR_PATHING_REACHED_END \ + (ACTOR_PATHING_REACHED_END_PERMANENT | ACTOR_PATHING_REACHED_END_TEMPORARY) + +struct ActorPathing; +typedef void (*ActorPathingComputeFunc)(struct GlobalContext*, struct ActorPathing*); +typedef s32 (*ActorPathingUpdateFunc)(struct GlobalContext*, struct ActorPathing*); + +typedef struct ActorPathing { + /* 0x00 */ Path* setupPathList; + /* 0x04 */ s32 pathIndex; + /* 0x08 */ Vec3s* points; + /* 0x0C */ s32 count; + /* 0x10 */ s32 curPointIndex; + /* 0x14 */ s32 begPointIndex; + /* 0x18 */ s32 endPointIndex; + /* 0x1C */ u8 flags; + /* 0x1D */ u8 prevFlags; + /* 0x20 */ Vec3f curPoint; + /* 0x2C */ Vec3f pointOffset; + /* 0x38 */ Vec3f prevPoint; + /* 0x44 */ Vec3f* worldPos; + /* 0x48 */ Actor* actor; + /* 0x4C */ f32 distSqToCurPointXZ; + /* 0x50 */ f32 distSqToCurPoint; + /* 0x54 */ Vec3s rotToCurPoint; + /* 0x5C */ ActorPathingComputeFunc computePointInfoFunc; + /* 0x60 */ ActorPathingUpdateFunc updateActorInfoFunc; // Return true if should setNextPoint, false if the actor should move forward + /* 0x64 */ ActorPathingUpdateFunc moveFunc; // Return true if should compute and update again + /* 0x68 */ ActorPathingUpdateFunc setNextPointFunc; // Return true if should compute and update again +} ActorPathing; // size = 0x6C + +#endif diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index f0ed1f516..8ad36c891 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #define ANIM_INTERP 1 diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 52a5b07da..630b16463 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -307,17 +307,136 @@ s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* li #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DCCC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DCE0.s") +void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, + Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, + u8 flags) { + Path* path; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DE04.s") + actorPath->setupPathList = globalCtx->setupPathList; + actorPath->pathIndex = pathIndex; + path = &paths[pathIndex]; + actorPath->points = Lib_SegmentedToVirtual(path->points); + actorPath->count = path->count; + actorPath->begPointIndex = begPointIndex; + if (endPointIndex == 0) { + actorPath->endPointIndex = actorPath->count - 1; + } else if (endPointIndex > 0) { + actorPath->endPointIndex = endPointIndex; + } else { + //! @bug: endPointIndex is negative, subtraction causes result to be past the end + actorPath->endPointIndex = (actorPath->count - endPointIndex) - 1; + } + actorPath->curPointIndex = curPointIndex; + actorPath->curPoint.x = actorPath->points[0].x; + actorPath->curPoint.y = actorPath->points[0].y; + actorPath->curPoint.z = actorPath->points[0].z; + Math_Vec3f_Copy(&actorPath->prevPoint, &actorPath->curPoint); + actorPath->worldPos = worldPos; + actorPath->actor = actor; + actorPath->flags = flags; + actorPath->prevFlags = flags; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DF3C.s") +s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath, + ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, + ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc) { + s32 shouldSetNextPoint; + s32 reupdate; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E054.s") + actorPath->computePointInfoFunc = computePointInfoFunc; + actorPath->updateActorInfoFunc = updateActorInfoFunc; + actorPath->moveFunc = moveFunc; + actorPath->setNextPointFunc = setNextPointFunc; + actorPath->flags &= ~ACTOR_PATHING_REACHED_TEMPORARY; + reupdate = false; + if (actorPath->flags & ACTOR_PATHING_MOVE_BACKWARDS) { + if (!(actorPath->prevFlags & ACTOR_PATHING_MOVE_BACKWARDS)) { + actorPath->curPointIndex--; + } + } else if (actorPath->prevFlags & ACTOR_PATHING_MOVE_BACKWARDS) { + actorPath->curPointIndex++; + } + do { + shouldSetNextPoint = false; + if (actorPath->computePointInfoFunc != NULL) { + actorPath->computePointInfoFunc(globalCtx, actorPath); + } + if (actorPath->updateActorInfoFunc != NULL) { + shouldSetNextPoint = actorPath->updateActorInfoFunc(globalCtx, actorPath); + } + if (shouldSetNextPoint) { + if (actorPath->setNextPointFunc != NULL) { + reupdate = actorPath->setNextPointFunc(globalCtx, actorPath); + } + } else if (actorPath->moveFunc != NULL) { + reupdate = actorPath->moveFunc(globalCtx, actorPath); + } + } while (reupdate); + actorPath->prevFlags = actorPath->flags; + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E07C.s") +void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* actorPath) { + Vec3f diff; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E0A4.s") + actorPath->curPoint.x = actorPath->points[actorPath->curPointIndex].x + actorPath->pointOffset.x; + actorPath->curPoint.y = actorPath->points[actorPath->curPointIndex].y + actorPath->pointOffset.y; + actorPath->curPoint.z = actorPath->points[actorPath->curPointIndex].z + actorPath->pointOffset.z; + diff.x = actorPath->curPoint.x - actorPath->worldPos->x; + diff.y = actorPath->curPoint.y - actorPath->worldPos->y; + diff.z = actorPath->curPoint.z - actorPath->worldPos->z; + actorPath->distSqToCurPointXZ = Math3D_XZLengthSquared(diff.x, diff.z); + actorPath->distSqToCurPoint = Math3D_LengthSquared(&diff); + actorPath->rotToCurPoint.y = Math_FAtan2F(diff.z, diff.x); + actorPath->rotToCurPoint.x = Math_FAtan2F(sqrtf(actorPath->distSqToCurPointXZ), -diff.y); + actorPath->rotToCurPoint.z = 0; +} + +s32 SubS_ActorPathing_MoveWithGravity(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor_MoveWithGravity(actorPath->actor); + return false; +} + +s32 SubS_ActorPathing_MoveWithoutGravityReverse(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor_MoveWithoutGravityReverse(actorPath->actor); + return false; +} + +s32 SubS_ActorPathing_SetNextPoint(GlobalContext* globalCtx, ActorPathing* actorPath) { + s32 reupdate = true; + + Math_Vec3f_Copy(&actorPath->prevPoint, &actorPath->curPoint); + if (!(actorPath->flags & ACTOR_PATHING_MOVE_BACKWARDS)) { + if (actorPath->curPointIndex >= actorPath->endPointIndex) { + if (actorPath->flags & ACTOR_PATHING_RETURN_TO_START) { + actorPath->curPointIndex = actorPath->begPointIndex; + } else if (actorPath->flags & ACTOR_PATHING_SWITCH_DIRECTION) { + actorPath->flags |= ACTOR_PATHING_MOVE_BACKWARDS; + } else { + reupdate = false; + } + actorPath->flags |= ACTOR_PATHING_REACHED_END; + } else { + actorPath->curPointIndex++; + } + actorPath->flags |= ACTOR_PATHING_REACHED_POINT; + } else { + if (actorPath->begPointIndex >= actorPath->curPointIndex) { + if (actorPath->flags & ACTOR_PATHING_RETURN_TO_START) { + actorPath->curPointIndex = actorPath->endPointIndex; + } else if (actorPath->flags & ACTOR_PATHING_SWITCH_DIRECTION) { + actorPath->flags &= ~ACTOR_PATHING_MOVE_BACKWARDS; + } else { + reupdate = false; + } + actorPath->flags |= ACTOR_PATHING_REACHED_END; + } else { + actorPath->curPointIndex--; + } + } + actorPath->flags |= ACTOR_PATHING_REACHED_POINT; + return reupdate; +} void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, s32* curIndex) { diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index 4306d5582..1139f6ef4 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -4,6 +4,7 @@ * Description: Snowhead Temple Central Pillar */ +#include "prevent_bss_reordering.h" #include "z_bg_hakugin_post.h" #include "objects/object_hakugin_obj/object_hakugin_obj.h" diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.c b/src/overlays/actors/ovl_En_Dno/z_en_dno.c index d51ec8a4d..f8ff8877d 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -687,12 +687,12 @@ void func_80A72C04(EnDno* this, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_8000000; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Math_Vec3f_Copy(&this->unk_334, &this->actor.world.pos); - func_8013DCE0(globalCtx, &this->unk_334, &this->actor, &this->unk_340, globalCtx->setupPathList, - ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); - func_8013DF3C(globalCtx, &this->unk_340); + SubS_ActorPathing_Init(globalCtx, &this->unk_334, &this->actor, &this->actorPath, globalCtx->setupPathList, + ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); + SubS_ActorPathing_ComputePointInfo(globalCtx, &this->actorPath); - this->actor.world.rot.y = this->unk_340.unk_54.y; - this->actor.world.rot.x = this->unk_340.unk_54.x; + this->actor.world.rot.y = this->actorPath.rotToCurPoint.y; + this->actor.world.rot.x = this->actorPath.rotToCurPoint.x; Flags_SetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor)); this->actionFunc = func_80A730A0; @@ -704,8 +704,8 @@ void func_80A72CF8(EnDno* this, GlobalContext* globalCtx) { this->actor.floorHeight, this->actor.world.pos.z, 0, 0, 0, 0x201); } -s32 func_80A72D8C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { - Actor* actor = arg1->actor; +s32 EnDno_ActorPathing_UpdateActorInfo(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; s32 pad; s32 ret = false; f32 sp38; @@ -713,52 +713,52 @@ s32 func_80A72D8C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { s32 temp_v0_2; s32 sp2C; - actor->gravity = 0.0f; - temp_v0 = actor->yawTowardsPlayer - actor->world.rot.y; + thisx->gravity = 0.0f; + temp_v0 = thisx->yawTowardsPlayer - thisx->world.rot.y; if ((temp_v0 <= 0x4000) && (temp_v0 >= -0x4000)) { - Math_SmoothStepToF(&actor->speedXZ, 15.0f, 0.8f, 1.0f, 0.01f); + Math_SmoothStepToF(&thisx->speedXZ, 15.0f, 0.8f, 1.0f, 0.01f); } else { - if (actor->xzDistToPlayer <= 80.0f) { - Math_SmoothStepToF(&actor->speedXZ, 8.0f, 0.5f, 0.5f, 0.01f); - } else if (actor->xzDistToPlayer <= 360.0f) { - Math_SmoothStepToF(&actor->speedXZ, 7.0f, 0.5f, 0.5f, 0.01f); + if (thisx->xzDistToPlayer <= 80.0f) { + Math_SmoothStepToF(&thisx->speedXZ, 8.0f, 0.5f, 0.5f, 0.01f); + } else if (thisx->xzDistToPlayer <= 360.0f) { + Math_SmoothStepToF(&thisx->speedXZ, 7.0f, 0.5f, 0.5f, 0.01f); } else { - Math_SmoothStepToF(&actor->speedXZ, 3.5f, 0.5f, 0.5f, 0.01f); + Math_SmoothStepToF(&thisx->speedXZ, 3.5f, 0.5f, 0.5f, 0.01f); } } - if (arg1->unk_50 < SQ(actor->speedXZ)) { + if (actorPath->distSqToCurPoint < SQ(thisx->speedXZ)) { ret = true; } else { - sp38 = actor->speedXZ / sqrtf(arg1->unk_4C); - sp2C = ABS(arg1->unk_54.x - actor->world.rot.x); + sp38 = thisx->speedXZ / sqrtf(actorPath->distSqToCurPointXZ); + sp2C = ABS(actorPath->rotToCurPoint.x - thisx->world.rot.x); temp_v0_2 = sp2C; temp_v0_2 *= sp38; temp_v0_2 += 0x71C; - sp2C = ABS(arg1->unk_54.y - actor->world.rot.y); + sp2C = ABS(actorPath->rotToCurPoint.y - thisx->world.rot.y); - Math_ScaledStepToS(&actor->world.rot.x, arg1->unk_54.x, temp_v0_2); - Math_ScaledStepToS(&actor->world.rot.y, arg1->unk_54.y, (s32)(sp2C * sp38) + 0x71C); + Math_ScaledStepToS(&thisx->world.rot.x, actorPath->rotToCurPoint.x, temp_v0_2); + Math_ScaledStepToS(&thisx->world.rot.y, actorPath->rotToCurPoint.y, (s32)(sp2C * sp38) + 0x71C); } return ret; } -s32 func_80A72FAC(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { - Actor* actor = arg1->actor; - EnDno* dno = (EnDno*)actor; - f32 sp24 = Math_CosS(-actor->world.rot.x) * actor->speedXZ; +s32 EnDno_ActorPathing_Move(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; + EnDno* this = (EnDno*)thisx; + f32 sp24 = Math_CosS(-thisx->world.rot.x) * thisx->speedXZ; f32 sp20 = gFramerateDivisorHalf; - actor->velocity.x = Math_SinS(actor->world.rot.y) * sp24; - actor->velocity.y = Math_SinS(-actor->world.rot.x) * actor->speedXZ; - actor->velocity.z = Math_CosS(actor->world.rot.y) * sp24; + thisx->velocity.x = Math_SinS(thisx->world.rot.y) * sp24; + thisx->velocity.y = Math_SinS(-thisx->world.rot.x) * thisx->speedXZ; + thisx->velocity.z = Math_CosS(thisx->world.rot.y) * sp24; - dno->unk_334.x += (dno->actor.velocity.x * sp20) + dno->actor.colChkInfo.displacement.x; - dno->unk_334.y += (dno->actor.velocity.y * sp20) + dno->actor.colChkInfo.displacement.y; - dno->unk_334.z += (dno->actor.velocity.z * sp20) + dno->actor.colChkInfo.displacement.z; + this->unk_334.x += (this->actor.velocity.x * sp20) + this->actor.colChkInfo.displacement.x; + this->unk_334.y += (this->actor.velocity.y * sp20) + this->actor.colChkInfo.displacement.y; + this->unk_334.z += (this->actor.velocity.z * sp20) + this->actor.colChkInfo.displacement.z; - return 0; + return false; } void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { @@ -786,11 +786,13 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { } } - func_8013DE04(globalCtx, &this->unk_340, func_8013DF3C, func_80A72D8C, func_80A72FAC, func_8013E0A4); + SubS_ActorPathing_Update(globalCtx, &this->actorPath, SubS_ActorPathing_ComputePointInfo, + EnDno_ActorPathing_UpdateActorInfo, EnDno_ActorPathing_Move, + SubS_ActorPathing_SetNextPoint); this->unk_45C += 6553; - this->unk_340.unk_2C.x = 0.0f; - this->unk_340.unk_2C.y = 0.0f; - this->unk_340.unk_2C.z = 0.0f; + this->actorPath.pointOffset.x = 0.0f; + this->actorPath.pointOffset.y = 0.0f; + this->actorPath.pointOffset.z = 0.0f; Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_334); temp_f10 = (4.0f + Math_SinS(this->unk_3AE)) * Math_SinS(this->unk_3AC); this->actor.world.pos.y += temp_f10; @@ -799,8 +801,8 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.yawTowardsPlayer; func_80A715DC(this, globalCtx); func_800B9010(&this->actor, NA_SE_EV_BUTLER_FRY - SFX_FLAG); - if (this->unk_340.unk_1C & 0x20) { - Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_340.unk_20); + if (this->actorPath.flags & ACTOR_PATHING_REACHED_END_PERMANENT) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actorPath.curPoint); this->actor.speedXZ = 0.0f; this->actor.velocity.x = 0.0f; this->actor.velocity.y = 0.0f; diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.h b/src/overlays/actors/ovl_En_Dno/z_en_dno.h index 350e0c004..dcffee6c9 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.h +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.h @@ -34,7 +34,7 @@ typedef struct EnDno { /* 0x32C */ s32 unk_32C; /* 0x330 */ UNK_TYPE1 unk_330[0x4]; /* 0x334 */ Vec3f unk_334; - /* 0x340 */ struct_8013DF3C_arg1 unk_340; + /* 0x340 */ ActorPathing actorPath; /* 0x3AC */ s16 unk_3AC; /* 0x3AE */ s16 unk_3AE; /* 0x3B0 */ u16 unk_3B0; diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index 6eb555ef1..f81a2f40d 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -817,31 +817,27 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { } } -s32 func_80B5D37C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { - s32 pad; - EnOt* temp_s0 = (EnOt*)arg1->actor; - f32 sp24; - f32 sp20; +s32 EnOt_ActorPathing_Move(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; + EnOt* this = (EnOt*)thisx; + f32 sp24 = Math_CosS(-thisx->world.rot.x) * thisx->speedXZ; + f32 sp20 = gFramerateDivisorHalf; - sp24 = Math_CosS(temp_s0->actor.world.rot.x * -1) * temp_s0->actor.speedXZ; - sp20 = gFramerateDivisorHalf; + thisx->velocity.x = Math_SinS(thisx->world.rot.y) * sp24; + thisx->velocity.y = Math_SinS(-thisx->world.rot.x) * thisx->speedXZ; + thisx->velocity.z = Math_CosS(thisx->world.rot.y) * sp24; - temp_s0->actor.velocity.x = Math_SinS(temp_s0->actor.world.rot.y) * sp24; - temp_s0->actor.velocity.y = Math_SinS(temp_s0->actor.world.rot.x * -1) * temp_s0->actor.speedXZ; - do { - temp_s0->actor.velocity.z = Math_CosS(temp_s0->actor.world.rot.y) * sp24; - temp_s0->unk_330.x += (temp_s0->actor.velocity.x * sp20) + temp_s0->actor.colChkInfo.displacement.x; - temp_s0->unk_330.y += (temp_s0->actor.velocity.y * sp20) + temp_s0->actor.colChkInfo.displacement.y; - } while (0); - temp_s0->unk_330.z += (temp_s0->actor.velocity.z * sp20) + temp_s0->actor.colChkInfo.displacement.z; + this->unk_330.x += (thisx->velocity.x * sp20) + thisx->colChkInfo.displacement.x; + this->unk_330.y += (thisx->velocity.y * sp20) + thisx->colChkInfo.displacement.y; + this->unk_330.z += (thisx->velocity.z * sp20) + thisx->colChkInfo.displacement.z; return false; } -s32 func_80B5D470(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { +s32 EnOt_ActorPathing_UpdateActorInfo(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; + s32 ret = false; s32 pad; - s32 ret; - Actor* temp_s1 = arg1->actor; Vec3f sp50; Vec3f sp44; f32 temp; @@ -849,32 +845,31 @@ s32 func_80B5D470(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { s32 sp30; s32 sp34; - ret = false; - temp_s1->gravity = 0.0f; - Math_SmoothStepToF(&temp_s1->speedXZ, 10.0f, 0.8f, 2.0f, 0.0f); + thisx->gravity = 0.0f; + Math_SmoothStepToF(&thisx->speedXZ, 10.0f, 0.8f, 2.0f, 0.0f); - sp50.x = arg1->unk_20.x - temp_s1->world.pos.x; - sp50.y = arg1->unk_20.y - temp_s1->world.pos.y; - sp50.z = arg1->unk_20.z - temp_s1->world.pos.z; + sp50.x = actorPath->curPoint.x - thisx->world.pos.x; + sp50.y = actorPath->curPoint.y - thisx->world.pos.y; + sp50.z = actorPath->curPoint.z - thisx->world.pos.z; - sp44.x = arg1->unk_20.x - arg1->unk_38.x; - sp44.y = arg1->unk_20.y - arg1->unk_38.y; - sp44.z = arg1->unk_20.z - arg1->unk_38.z; + sp44.x = actorPath->curPoint.x - actorPath->prevPoint.x; + sp44.y = actorPath->curPoint.y - actorPath->prevPoint.y; + sp44.z = actorPath->curPoint.z - actorPath->prevPoint.z; temp = Math3D_Parallel(&sp50, &sp44); - if ((arg1->unk_4C < SQ(temp_s1->speedXZ)) || (temp <= 0.0f)) { + if ((actorPath->distSqToCurPointXZ < SQ(thisx->speedXZ)) || (temp <= 0.0f)) { ret = true; } else { - temp = SQ(temp_s1->speedXZ) / arg1->unk_50; - sp34 = ABS(arg1->unk_54.x - temp_s1->world.rot.x); + temp = SQ(thisx->speedXZ) / actorPath->distSqToCurPoint; + sp34 = ABS(actorPath->rotToCurPoint.x - thisx->world.rot.x); sp2C = (s32)(sp34 * temp) + 0xAAA; - sp34 = ABS(arg1->unk_54.y - temp_s1->world.rot.y); + sp34 = ABS(actorPath->rotToCurPoint.y - thisx->world.rot.y); - Math_SmoothStepToS(&temp_s1->world.rot.x, arg1->unk_54.x, 1, sp2C, 0); + Math_SmoothStepToS(&thisx->world.rot.x, actorPath->rotToCurPoint.x, 1, sp2C, 0); sp2C = (s32)(sp34 * temp) + 0xAAA; - Math_SmoothStepToS(&temp_s1->world.rot.y, arg1->unk_54.y, 1, sp2C, 0); - Math_SmoothStepToS(&temp_s1->shape.rot.y, temp_s1->world.rot.y, 2, sp2C, 0); + Math_SmoothStepToS(&thisx->world.rot.y, actorPath->rotToCurPoint.y, 1, sp2C, 0); + Math_SmoothStepToS(&thisx->shape.rot.y, thisx->world.rot.y, 2, sp2C, 0); } return ret; @@ -883,12 +878,12 @@ s32 func_80B5D470(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { void func_80B5D648(EnOt* this, GlobalContext* globalCtx) { func_80B5B2E0(globalCtx, &this->actor.world.pos, this->unk_346, &this->unk_348, &this->unk_340); Math_Vec3f_Copy(&this->unk_330, &this->actor.world.pos); - func_8013DCE0(globalCtx, &this->unk_330, &this->actor, &this->unk_2C0, globalCtx->setupPathList, this->unk_346, 0, - 0, this->unk_340, 0); + SubS_ActorPathing_Init(globalCtx, &this->unk_330, &this->actor, &this->actorPath, globalCtx->setupPathList, + this->unk_346, 0, 0, this->unk_340, 0); this->unk_32C = 0; - this->unk_2C0.unk_2C.x = 0.0f; - this->unk_2C0.unk_2C.y = 0.0f; - this->unk_2C0.unk_2C.z = 0.0f; + this->actorPath.pointOffset.x = 0.0f; + this->actorPath.pointOffset.y = 0.0f; + this->actorPath.pointOffset.z = 0.0f; this->actor.gravity = 0.0f; this->actor.speedXZ = 0.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIdx); @@ -900,16 +895,18 @@ void func_80B5D648(EnOt* this, GlobalContext* globalCtx) { void func_80B5D750(EnOt* this, GlobalContext* globalCtx) { if (!(this->unk_32C & 1) && !(this->unk_32C & 2)) { - func_8013DE04(globalCtx, &this->unk_2C0, func_8013DF3C, func_80B5D470, func_80B5D37C, func_8013E0A4); + SubS_ActorPathing_Update(globalCtx, &this->actorPath, SubS_ActorPathing_ComputePointInfo, + EnOt_ActorPathing_UpdateActorInfo, EnOt_ActorPathing_Move, + SubS_ActorPathing_SetNextPoint); } Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_330); - if (this->unk_2C0.unk_1C & 0x40) { + if (this->actorPath.flags & ACTOR_PATHING_REACHED_POINT_TEMPORARY) { this->unk_32C |= 2; } - if (this->unk_2C0.unk_1C & 0x80) { + if (this->actorPath.flags & ACTOR_PATHING_REACHED_END_TEMPORARY) { this->unk_32C |= 1; } diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.h b/src/overlays/actors/ovl_En_Ot/z_en_ot.h index 3a52b48c6..902cbecd7 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.h +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.h @@ -36,7 +36,7 @@ typedef struct EnOt { /* 0x01D8 */ Vec3s jointTable[19]; /* 0x024A */ Vec3s morphTable[19]; /* 0x02BC */ s32 animIdx; - /* 0x02C0 */ struct_8013DF3C_arg1 unk_2C0; + /* 0x02C0 */ ActorPathing actorPath; /* 0x032C */ u16 unk_32C; /* 0x0330 */ Vec3f unk_330; /* 0x033C */ s32 unk_33C; diff --git a/tools/actorfixer.py b/tools/actorfixer.py index b6aba86c0..3ba0615f9 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -447,6 +447,12 @@ animdict = { "func_8013D924": "SubS_GetObjectIndex", "func_8013D5E8": "SubS_AngleDiffLessEqual", "func_8012F22C": "Inventory_GetSkullTokenCount", + "func_8013DCE0": "SubS_ActorPathing_Init", + "func_8013DE04": "SubS_ActorPathing_Update", + "func_8013DF3C": "SubS_ActorPathing_ComputePointInfo", + "func_8013E054": "SubS_ActorPathing_MoveWithGravity", + "func_8013E07C": "SubS_ActorPathing_MoveWithoutGravityReverse", + "func_8013E0A4": "SubS_ActorPathing_SetNextPoint", # Struct members "skelAnime.unk03": "skelAnime.taper", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index bca55a746..26cff71a9 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2694,12 +2694,12 @@ 0x8013DB90:("func_8013DB90",), 0x8013DC40:("func_8013DC40",), 0x8013DCCC:("func_8013DCCC",), - 0x8013DCE0:("func_8013DCE0",), - 0x8013DE04:("func_8013DE04",), - 0x8013DF3C:("func_8013DF3C",), - 0x8013E054:("func_8013E054",), - 0x8013E07C:("func_8013E07C",), - 0x8013E0A4:("func_8013E0A4",), + 0x8013DCE0:("SubS_ActorPathing_Init",), + 0x8013DE04:("SubS_ActorPathing_Update",), + 0x8013DF3C:("SubS_ActorPathing_ComputePointInfo",), + 0x8013E054:("SubS_ActorPathing_MoveWithGravity",), + 0x8013E07C:("SubS_ActorPathing_MoveWithoutGravityReverse",), + 0x8013E0A4:("SubS_ActorPathing_SetNextPoint",), 0x8013E1C8:("SubS_ChangeAnimationBySpeedInfo",), 0x8013E2D4:("SubS_StartActorCutscene",), 0x8013E3B8:("SubS_FillCutscenesList",), @@ -11005,8 +11005,8 @@ 0x80A72BA4:("func_80A72BA4",), 0x80A72C04:("func_80A72C04",), 0x80A72CF8:("func_80A72CF8",), - 0x80A72D8C:("func_80A72D8C",), - 0x80A72FAC:("func_80A72FAC",), + 0x80A72D8C:("EnDno_ActorPathing_UpdateActorInfo",), + 0x80A72FAC:("EnDno_ActorPathing_Move",), 0x80A730A0:("func_80A730A0",), 0x80A73244:("func_80A73244",), 0x80A732C8:("func_80A732C8",), @@ -14116,8 +14116,8 @@ 0x80B5CEC8:("func_80B5CEC8",), 0x80B5D114:("func_80B5D114",), 0x80B5D160:("func_80B5D160",), - 0x80B5D37C:("func_80B5D37C",), - 0x80B5D470:("func_80B5D470",), + 0x80B5D37C:("EnOt_ActorPathing_Move",), + 0x80B5D470:("EnOt_ActorPathing_UpdateActorInfo",), 0x80B5D648:("func_80B5D648",), 0x80B5D750:("func_80B5D750",), 0x80B5D8AC:("EnOt_Update",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index e312fa619..13c89fa37 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2208,12 +2208,12 @@ asm/non_matchings/code/z_sub_s/SubS_FillLimbRotTables.s,SubS_FillLimbRotTables,0 asm/non_matchings/code/z_sub_s/func_8013DB90.s,func_8013DB90,0x8013DB90,0x2C asm/non_matchings/code/z_sub_s/func_8013DC40.s,func_8013DC40,0x8013DC40,0x23 asm/non_matchings/code/z_sub_s/func_8013DCCC.s,func_8013DCCC,0x8013DCCC,0x5 -asm/non_matchings/code/z_sub_s/func_8013DCE0.s,func_8013DCE0,0x8013DCE0,0x49 -asm/non_matchings/code/z_sub_s/func_8013DE04.s,func_8013DE04,0x8013DE04,0x4E -asm/non_matchings/code/z_sub_s/func_8013DF3C.s,func_8013DF3C,0x8013DF3C,0x46 -asm/non_matchings/code/z_sub_s/func_8013E054.s,func_8013E054,0x8013E054,0xA -asm/non_matchings/code/z_sub_s/func_8013E07C.s,func_8013E07C,0x8013E07C,0xA -asm/non_matchings/code/z_sub_s/func_8013E0A4.s,func_8013E0A4,0x8013E0A4,0x49 +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_Init.s,SubS_ActorPathing_Init,0x8013DCE0,0x49 +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_Update.s,SubS_ActorPathing_Update,0x8013DE04,0x4E +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_ComputePointInfo.s,SubS_ActorPathing_ComputePointInfo,0x8013DF3C,0x46 +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_MoveWithGravity.s,SubS_ActorPathing_MoveWithGravity,0x8013E054,0xA +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_MoveWithoutGravityReverse.s,SubS_ActorPathing_MoveWithoutGravityReverse,0x8013E07C,0xA +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_SetNextPoint.s,SubS_ActorPathing_SetNextPoint,0x8013E0A4,0x49 asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationBySpeedInfo.s,SubS_ChangeAnimationBySpeedInfo,0x8013E1C8,0x43 asm/non_matchings/code/z_sub_s/SubS_StartActorCutscene.s,SubS_StartActorCutscene,0x8013E2D4,0x39 asm/non_matchings/code/z_sub_s/SubS_FillCutscenesList.s,SubS_FillCutscenesList,0x8013E3B8,0x3E From 7d4aaef0cdd1e6a0e4720d82c2fcbe7a2c275fbe Mon Sep 17 00:00:00 2001 From: louist103 <35883445+louist103@users.noreply.github.com> Date: Fri, 25 Mar 2022 22:51:41 -0400 Subject: [PATCH 121/257] Fire and Light arrows (#710) * fire arrow OK * Light arrows OK * Format * Assets * Mtx Mode * PR fixes * pr fixes * Update src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c * Update src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c --- assets/xml/overlays/ovl_Arrow_Ice.xml | 4 +- assets/xml/overlays/ovl_Arrow_Light.xml | 13 + assets/xml/overlays/ovl_Arrow_fire.xml | 12 + spec | 8 +- .../actors/ovl_Arrow_Fire/z_arrow_fire.c | 279 ++++++++++++++++-- .../actors/ovl_Arrow_Fire/z_arrow_fire.h | 15 +- .../actors/ovl_Arrow_Ice/z_arrow_ice.c | 8 +- .../actors/ovl_Arrow_Light/z_arrow_light.c | 205 +++++++++++-- .../actors/ovl_Arrow_Light/z_arrow_light.h | 12 +- tools/disasm/functions.txt | 16 +- tools/disasm/variables.txt | 17 +- 11 files changed, 505 insertions(+), 84 deletions(-) create mode 100644 assets/xml/overlays/ovl_Arrow_Light.xml create mode 100644 assets/xml/overlays/ovl_Arrow_fire.xml diff --git a/assets/xml/overlays/ovl_Arrow_Ice.xml b/assets/xml/overlays/ovl_Arrow_Ice.xml index 9ac5d04e0..bec512600 100644 --- a/assets/xml/overlays/ovl_Arrow_Ice.xml +++ b/assets/xml/overlays/ovl_Arrow_Ice.xml @@ -1,8 +1,8 @@ - - + + diff --git a/assets/xml/overlays/ovl_Arrow_Light.xml b/assets/xml/overlays/ovl_Arrow_Light.xml new file mode 100644 index 000000000..3d5ae87b8 --- /dev/null +++ b/assets/xml/overlays/ovl_Arrow_Light.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Arrow_fire.xml b/assets/xml/overlays/ovl_Arrow_fire.xml new file mode 100644 index 000000000..893f335d0 --- /dev/null +++ b/assets/xml/overlays/ovl_Arrow_fire.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/spec b/spec index c6faa6511..3cb2716e3 100644 --- a/spec +++ b/spec @@ -1369,9 +1369,7 @@ beginseg name "ovl_Arrow_Fire" compress include "build/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.o" - include "build/data/ovl_Arrow_Fire/ovl_Arrow_Fire.data.o" - include "build/data/ovl_Arrow_Fire/ovl_Arrow_Fire.bss.o" - include "build/data/ovl_Arrow_Fire/ovl_Arrow_Fire.reloc.o" + include "build/src/overlays/actors/ovl_Arrow_Fire/ovl_Arrow_Fire_reloc.o" endseg beginseg @@ -1385,9 +1383,7 @@ beginseg name "ovl_Arrow_Light" compress include "build/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.o" - include "build/data/ovl_Arrow_Light/ovl_Arrow_Light.data.o" - include "build/data/ovl_Arrow_Light/ovl_Arrow_Light.bss.o" - include "build/data/ovl_Arrow_Light/ovl_Arrow_Light.reloc.o" + include "build/src/overlays/actors/ovl_Arrow_Light/ovl_Arrow_Light_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c index e85e3791a..0b9bedbb8 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -5,6 +5,7 @@ */ #include "z_arrow_fire.h" +#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) @@ -15,19 +16,10 @@ void ArrowFire_Destroy(Actor* thisx, GlobalContext* globalCtx); void ArrowFire_Update(Actor* thisx, GlobalContext* globalCtx); void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80920440(ArrowFire* this, GlobalContext* globalCtx); -void func_8092058C(ArrowFire* this, GlobalContext* globalCtx); -void func_809207A0(ArrowFire* this, GlobalContext* globalCtx); +void FireArrow_ChargeAndWait(ArrowFire* this, GlobalContext* globalCtx); +void FireArrow_Fly(ArrowFire* this, GlobalContext* globalCtx); -void ArrowFire_SetupAction(ArrowFire* this, ArrowFireActionFunc actionFunc); - -#if 0 -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_80922230 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_TYPE_PLAYER, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK0, { 0x08000000, 0x00, 0x02 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; +#include "overlays/ovl_Arrow_fire/ovl_Arrow_Fire.c" const ActorInit Arrow_Fire_InitVars = { ACTOR_ARROW_FIRE, @@ -41,29 +33,264 @@ const ActorInit Arrow_Fire_InitVars = { (ActorFunc)ArrowFire_Draw, }; -#endif +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_TYPE_PLAYER, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x08000000, 0x00, 0x02 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; -extern ColliderQuadInit D_80922230; +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP), +}; -// there are uses of D_0E000000.fillRect (appearing as D_0E0002E0) in this file -extern GfxMasterList D_0E000000; +s32 sUnused; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_SetupAction.s") +void ArrowFire_SetupAction(ArrowFire* this, ArrowFireActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Init.s") +void ArrowFire_Init(Actor* thisx, GlobalContext* globalCtx) { + ArrowFire* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Destroy.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->radius = 0; + this->height = 1.0f; + ArrowFire_SetupAction(this, FireArrow_ChargeAndWait); + Actor_SetScale(&this->actor, 0.01f); + this->alpha = 160; + this->timer = 0; + this->screenFillIntensity = 0.0f; + Collider_InitAndSetQuad(globalCtx, &this->collider1, &this->actor, &sQuadInit); + Collider_InitAndSetQuad(globalCtx, &this->collider2, &this->actor, &sQuadInit); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_80920440.s") +void ArrowFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ArrowFire* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/FireArrow_Lerp.s") + func_80115D5C(&globalCtx->state); + Collider_DestroyQuad(globalCtx, &this->collider1); + Collider_DestroyQuad(globalCtx, &this->collider2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_8092058C.s") +void FireArrow_ChargeAndWait(ArrowFire* this, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_809207A0.s") + if ((arrow == NULL) || (arrow->actor.update == NULL)) { + Actor_MarkForDeath(&this->actor); + return; + } + if (this->radius < 10) { + this->radius++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Update.s") + this->actor.world.pos = arrow->actor.world.pos; + this->actor.shape.rot = arrow->actor.shape.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_80920948.s") + func_800B9010(&this->actor, NA_SE_PL_ARROW_CHARGE_FIRE - SFX_FLAG); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Draw.s") + // if arrow has no parent, player has fired the arrow + if (arrow->actor.parent == NULL) { + this->firedPos = this->actor.world.pos; + this->radius = 10; + ArrowFire_SetupAction(this, FireArrow_Fly); + this->alpha = 255; + } +} + +void FireArrow_Lerp(Vec3f* firedPos, Vec3f* pos, f32 scale) { + VEC3F_LERPIMPDST(firedPos, firedPos, pos, scale); +} + +void FireArrow_Hit(ArrowFire* this, GlobalContext* globalCtx) { + f32 offset; + f32 scale; + u16 timer; + + if (this->actor.projectedW < 50.0f) { + scale = 10.0f; + } else if (this->actor.projectedW > 950.0f) { + scale = 310.0f; + } else { + scale = this->actor.projectedW; + scale = ((scale - 50.0f) * (1.0f / 3.0f)) + 10.0f; + } + + timer = this->timer; + if (timer != 0) { + this->timer--; + if (this->timer >= 8) { + offset = (this->timer - 8) * (1.0f / 24.0f); + offset = SQ(offset); + this->radius = (((1.0f - offset) * scale) + 10.0f); + this->height = F32_LERPIMP(this->height, 2.0f, 0.1f); + if (this->timer < 16) { + this->alpha = (this->timer * 35) - 280; + } + } + } + if (this->timer >= 9) { + if (this->screenFillIntensity < 1.0f) { + this->screenFillIntensity += 0.25f; + } + } else { + if (this->screenFillIntensity > 0.0f) { + this->screenFillIntensity -= 0.125f; + } + } + if (this->timer < 8) { + this->alpha = 0; + } + if (this->timer == 0) { + this->timer = 255; + Actor_MarkForDeath(&this->actor); + return; + } + if (this->timer >= 13) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } +} + +void FireArrow_Fly(ArrowFire* this, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)this->actor.parent; + s32 pad; + s32 pad2; + + if ((arrow == NULL) || (arrow->actor.update == NULL)) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->actor.world.pos = arrow->actor.world.pos; + this->actor.shape.rot = arrow->actor.shape.rot; + + this->height = Math_Vec3f_DistXYZ(&this->firedPos, &this->actor.world.pos) * (1.0f / 24.0f); + + if (this->height < 1.0f) { + this->height = 1.0f; + } + + FireArrow_Lerp(&this->firedPos, &this->actor.world.pos, 0.05f); + if (arrow->unk_261 & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_EXPLOSION_FRAME); + ArrowFire_SetupAction(this, FireArrow_Hit); + this->timer = 32; + this->alpha = 255; + return; + } + if (arrow->unk_260 < 34) { + if (this->alpha < 35) { + Actor_MarkForDeath(&this->actor); + return; + } + this->alpha -= 25; + } +} + +void ArrowFire_Update(Actor* thisx, GlobalContext* globalCtx) { + ArrowFire* this = (ArrowFire*)thisx; + + if ((globalCtx->msgCtx.msgMode == 0xE) || (globalCtx->msgCtx.msgMode == 0x12)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc(this, globalCtx); +} + +void FireArrow_SetQuadVerticies(ArrowFire* this) { + static Vec3f D_80922284 = { 100.0f, 700.0f, 0.0f }; + static Vec3f D_80922290 = { 400.0f, 27.0f, 0.0f }; + static Vec3f D_8092229C = { -100.0f, 700.0f, 0.0f }; + static Vec3f D_809222A8 = { -400, 27.0f, 0.0f }; + static Vec3f D_809222B4 = { 0.0f, 700.0f, 100.0f }; + static Vec3f D_809222C0 = { 0.0f, 27.0f, 400.0f }; + static Vec3f D_809222CC = { 0.0f, 700.0f, -100.0f }; + static Vec3f D_809222D8 = { 0.0f, 27.0f, -400.0f }; + Vec3f sp44; + Vec3f sp38; + Vec3f sp2C; + Vec3f sp20; + + Matrix_MultiplyVector3fByState(&D_80922284, &sp44); + Matrix_MultiplyVector3fByState(&D_80922290, &sp38); + Matrix_MultiplyVector3fByState(&D_8092229C, &sp2C); + Matrix_MultiplyVector3fByState(&D_809222A8, &sp20); + Collider_SetQuadVertices(&this->collider1, &sp44, &sp38, &sp2C, &sp20); + Matrix_MultiplyVector3fByState(&D_809222B4, &sp44); + Matrix_MultiplyVector3fByState(&D_809222C0, &sp38); + Matrix_MultiplyVector3fByState(&D_809222CC, &sp2C); + Matrix_MultiplyVector3fByState(&D_809222D8, &sp20); + Collider_SetQuadVertices(&this->collider2, &sp44, &sp38, &sp2C, &sp20); +} + +void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnArrow* arrow; + ArrowFire* this = THIS; + u32 frames = globalCtx->state.frames; + s32 pad; + + arrow = (EnArrow*)this->actor.parent; + + if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) { + Actor* transform = (arrow->unk_261 & 2) ? &this->actor : &arrow->actor; + + OPEN_DISPS(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); + Matrix_RotateY(transform->shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY); + + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + if (this->screenFillIntensity > 0.0f) { + POLY_XLU_DISP = func_8012BFC4(POLY_XLU_DISP); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s32)(this->screenFillIntensity * 40.0f) & 0xFF, 0, 0, + (s32)(150.0f * this->screenFillIntensity) & 0xFF); + + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_DISABLE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE); + + gSPDisplayList(POLY_XLU_DISP++, D_0E000000.fillRect); + } + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, this->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); + + Matrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY); + + if (this->timer != 0) { + Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } else { + Matrix_InsertTranslation(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); + } + + Matrix_Scale(this->radius * 0.2f, this->height * 4.0f, this->radius * 0.2f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + FireArrow_SetQuadVerticies(this); + gSPDisplayList(POLY_XLU_DISP++, gFireArrowMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 255 - ((frames * 2) % 256), 0, 64, 32, 1, + 255 - (frames % 256), 511 - ((frames * 10) % 512), 64, 64)); + gSPDisplayList(POLY_XLU_DISP++, gFireArrowModelDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h index bf1143cd9..5f9617c65 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h @@ -8,12 +8,19 @@ struct ArrowFire; typedef void (*ArrowFireActionFunc)(struct ArrowFire*, GlobalContext*); typedef struct ArrowFire { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x114]; - /* 0x0258 */ ArrowFireActionFunc actionFunc; - /* 0x025C */ char unk_25C[0x8]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderQuad collider1; + /* 0x1C4 */ ColliderQuad collider2; + /* 0x244 */ Vec3f firedPos; + /* 0x250 */ f32 height; + /* 0x254 */ f32 screenFillIntensity; + /* 0x258 */ ArrowFireActionFunc actionFunc; + /* 0x25C */ s16 radius; + /* 0x25E */ u16 timer; + /* 0x260 */ u8 alpha; } ArrowFire; // size = 0x264 + extern const ActorInit Arrow_Fire_InitVars; #endif // Z_ARROW_FIRE_H diff --git a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c index 8f1d75dde..8a402dfbe 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -17,7 +17,6 @@ void ArrowIce_Update(Actor* thisx, GlobalContext* globalCtx); void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx); void ArrowIce_Charge(ArrowIce* this, GlobalContext* globalCtx); -void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx); void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx); #include "overlays/ovl_Arrow_Ice/ovl_Arrow_Ice.c" @@ -94,7 +93,6 @@ void ArrowIce_LerpFiredPosition(Vec3f* firedPos, Vec3f* icePos, f32 scale) { void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx) { f32 scale; - f32 offset; u16 timer; if (this->actor.projectedW < 50.0f) { @@ -111,12 +109,12 @@ void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx) { this->timer--; if (this->timer >= 8) { - offset = ((this->timer - 8) * (1.0f / 24.0f)); + f32 offset = ((this->timer - 8) * (1.0f / 24.0f)); + offset = SQ(offset); this->radius = (((1.0f - offset) * scale) + 10.0f); - this->height += ((2.0f - this->height) * 0.1f); + this->height = F32_LERPIMP(this->height, 2.0f, 0.1f); if (this->timer < 16) { - if (1) {} this->alpha = ((this->timer * 35) - 280); } } diff --git a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c index 7d81b05a5..ac8eb1ae9 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c @@ -5,6 +5,7 @@ */ #include "z_arrow_light.h" +#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) @@ -15,13 +16,11 @@ void ArrowLight_Destroy(Actor* thisx, GlobalContext* globalCtx); void ArrowLight_Update(Actor* thisx, GlobalContext* globalCtx); void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809243AC(ArrowLight* this, GlobalContext* globalCtx); -void func_809244F8(ArrowLight* this, GlobalContext* globalCtx); -void func_809246C4(ArrowLight* this, GlobalContext* globalCtx); +void ArrowLight_Charge(ArrowLight* this, GlobalContext* globalCtx); +void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx); -void ArrowLight_SetupAction(ArrowLight* this, ArrowLightActionFunc actionFunc); +#include "overlays/ovl_Arrow_Light/ovl_Arrow_Light.c" -#if 0 const ActorInit Arrow_Light_InitVars = { ACTOR_ARROW_LIGHT, ACTORCAT_ITEMACTION, @@ -34,34 +33,198 @@ const ActorInit Arrow_Light_InitVars = { (ActorFunc)ArrowLight_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809260A0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP), }; -#endif +static s32 sUnused; -extern InitChainEntry D_809260A0[]; +void ArrowLight_SetupAction(ArrowLight* this, ArrowLightActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -// there are uses of D_0E000000.fillRect (appearing as D_0E0002E0) in this file -extern GfxMasterList D_0E000000; +void ArrowLight_Init(Actor* thisx, GlobalContext* globalCtx) { + ArrowLight* this = (ArrowLight*)thisx; + Actor_ProcessInitChain(&this->actor, sInitChain); + this->radius = 0; + this->height = 1.0f; + ArrowLight_SetupAction(this, ArrowLight_Charge); + Actor_SetScale(&this->actor, 0.01f); + this->alpha = 130; + this->timer = 0; + this->screenFillIntensity = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/D_809260B0.s") +void ArrowLight_Destroy(Actor* thisx, GlobalContext* globalCtx) { + func_80115D5C(&globalCtx->state); + (void)"消滅"; // Unreferenced in retail, means "Disappearance" +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_SetupAction.s") +void ArrowLight_Charge(ArrowLight* this, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Init.s") + if ((arrow == NULL) || (arrow->actor.update == NULL)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Destroy.s") + if (this->radius < 10) { + this->radius++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809243AC.s") + this->actor.world.pos = arrow->actor.world.pos; + this->actor.shape.rot = arrow->actor.shape.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809244A0.s") + func_800B9010(&this->actor, NA_SE_PL_ARROW_CHARGE_LIGHT - SFX_FLAG); + if (arrow->actor.parent == NULL) { + this->firedPos = this->actor.world.pos; + this->radius = 10; + ArrowLight_SetupAction(this, ArrowLight_Fly); + this->alpha = 255; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809244F8.s") +void ArrowLight_Lerp(Vec3f* firedPos, Vec3f* pos, f32 scale) { + VEC3F_LERPIMPDST(firedPos, firedPos, pos, scale); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809246C4.s") +void ArrowLight_Hit(ArrowLight* this, GlobalContext* globalCtx) { + f32 scale; + u16 timer; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Update.s") + if (this->actor.projectedW < 50.0f) { + scale = 10.0f; + } else if (this->actor.projectedW > 950.0f) { + scale = 310.0f; + } else { + scale = this->actor.projectedW; + scale = ((scale - 50.0f) * (1.0f / 3.0f)) + 10.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Draw.s") + timer = this->timer; + if (timer != 0) { + this->timer--; + if (this->timer >= 8) { + f32 offset = (this->timer - 8) * (1.0f / 24.0f); + + offset = SQ(offset); + this->radius = (((1.0f - offset) * scale) + 10.0f); + this->height = F32_LERPIMP(this->height, 2.0f, 0.1f); + if (this->timer < 16) { + this->alpha = (this->timer * 35) - 280; + } + } + } + if (this->timer >= 9) { + if (this->screenFillIntensity < 1.0f) { + this->screenFillIntensity += 0.25f; + } + } else { + if (this->screenFillIntensity > 0.0f) { + this->screenFillIntensity -= 0.125f; + } + } + if (this->timer < 8) { + this->alpha = 0; + } + if (this->timer == 0) { + this->timer = 255; + Actor_MarkForDeath(&this->actor); + return; + } +} + +void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)this->actor.parent; + s32 pad[2]; + + if ((arrow == NULL) || (arrow->actor.update == NULL)) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->actor.world.pos = arrow->actor.world.pos; + this->actor.shape.rot = arrow->actor.shape.rot; + + this->height = Math_Vec3f_DistXYZ(&this->firedPos, &this->actor.world.pos) * (1.0f / 24.0f); + if (this->height < 1.0f) { + this->height = 1.0f; + } + + ArrowLight_Lerp(&this->firedPos, &this->actor.world.pos, 0.05f); + + if (arrow->unk_261 & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_EXPLOSION_LIGHT); + ArrowLight_SetupAction(this, ArrowLight_Hit); + this->timer = 32; + this->alpha = 255; + return; + } + if (arrow->unk_260 < 34) { + if (this->alpha < 35) { + Actor_MarkForDeath(&this->actor); + return; + } + this->alpha -= 25; + } +} + +void ArrowLight_Update(Actor* thisx, GlobalContext* globalCtx) { + ArrowLight* this = THIS; + + if ((globalCtx->msgCtx.msgMode == 0xE) || (globalCtx->msgCtx.msgMode == 0x12)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc(this, globalCtx); +} + +void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ArrowLight* this = (ArrowLight*)thisx; + u32 frames = globalCtx->state.frames; + EnArrow* arrow = (EnArrow*)this->actor.parent; + + if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) { + Actor* transform = (arrow->unk_261 & 2) ? &this->actor : &arrow->actor; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); + Matrix_RotateY(transform->shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + if (this->screenFillIntensity > 0.0f) { + POLY_XLU_DISP = func_8012BFC4(POLY_XLU_DISP); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s32)(this->screenFillIntensity * 30.0f) & 0xFF, + (s32)(40.0f * this->screenFillIntensity) & 0xFF, 0, + (s32)(150.0f * this->screenFillIntensity) & 0xFF); + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_DISABLE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE); + gSPDisplayList(POLY_XLU_DISP++, D_0E000000.fillRect); + } + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, this->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 128); + + Matrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY); + if (this->timer != 0) { + Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } else { + Matrix_InsertTranslation(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); + } + Matrix_Scale(this->radius * 0.2f, this->height * 4.0f, this->radius * 0.2f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gLightArrowMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 511 - ((frames * 5) % 512), 0, 4, 32, 1, + 511 - ((frames * 10) % 512), 511 - ((frames * 30) % 512), 8, 16)); + gSPDisplayList(POLY_XLU_DISP++, gLightArrowModelDL); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.h b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.h index ef462cfde..7b3f3088f 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.h +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.h @@ -8,11 +8,17 @@ struct ArrowLight; typedef void (*ArrowLightActionFunc)(struct ArrowLight*, GlobalContext*); typedef struct ArrowLight { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; - /* 0x0160 */ ArrowLightActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 radius; + /* 0x146 */ u16 timer; + /* 0x148 */ u8 alpha; + /* 0x14C */ Vec3f firedPos; + /* 0x158 */ f32 height; + /* 0x15C */ f32 screenFillIntensity; + /* 0x160 */ ArrowLightActionFunc actionFunc; } ArrowLight; // size = 0x164 + extern const ActorInit Arrow_Light_InitVars; #endif // Z_ARROW_LIGHT_H diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 26cff71a9..8b40e2a91 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -7000,12 +7000,12 @@ 0x80920340:("ArrowFire_SetupAction",), 0x8092034C:("ArrowFire_Init",), 0x809203F8:("ArrowFire_Destroy",), - 0x80920440:("func_80920440",), + 0x80920440:("FireArrow_ChargeAndWait",), 0x80920534:("FireArrow_Lerp",), - 0x8092058C:("func_8092058C",), - 0x809207A0:("func_809207A0",), + 0x8092058C:("FireArrow_Hit",), + 0x809207A0:("FireArrow_Fly",), 0x809208F4:("ArrowFire_Update",), - 0x80920948:("func_80920948",), + 0x80920948:("FireArrow_SetQuadVerticies",), 0x80920A24:("ArrowFire_Draw",), 0x80922430:("ArrowIce_SetupAction",), 0x8092243C:("ArrowIce_Init",), @@ -7019,10 +7019,10 @@ 0x80924300:("ArrowLight_SetupAction",), 0x8092430C:("ArrowLight_Init",), 0x80924388:("ArrowLight_Destroy",), - 0x809243AC:("func_809243AC",), - 0x809244A0:("func_809244A0",), - 0x809244F8:("func_809244F8",), - 0x809246C4:("func_809246C4",), + 0x809243AC:("ArrowLight_Charge",), + 0x809244A0:("ArrowLight_Lerp",), + 0x809244F8:("ArrowLight_Hit",), + 0x809246C4:("ArrowLight_Fly",), 0x80924818:("ArrowLight_Update",), 0x8092486C:("ArrowLight_Draw",), 0x809261B0:("ObjKibako_SpawnCollectible",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index f509fff70..d578b0544 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -7992,15 +7992,14 @@ 0x8092024C:("D_8092024C","UNK_TYPE1","",0x1), 0x80920268:("D_80920268","UNK_TYPE1","",0x1), 0x80920290:("jtbl_80920290","UNK_PTR","",0x4), - 0x80920DF0:("arrowFireTexture1","u8","[2048]",0x800), - 0x809215F0:("arrowFireTexture2","u8","[2048]",0x800), - 0x80921DF0:("arrowFireVertices","F3DVertex","[43]",0x2b0), - 0x80921FF0:("D_80921FF0","UNK_TYPE1","",0x1), - 0x809220A0:("D_809220A0","Gfx","[22]",0xb0), - 0x80922150:("D_80922150","Gfx","[24]",0xc0), + 0x80920DF0:("gFireArrowTex","u8","[2048]",0x800), + 0x809215F0:("gFireArrowMaskTex","u8","[2048]",0x800), + 0x80921DF0:("gFireArrowVtx","F3DVertex","[43]",0x2b0), + 0x809220A0:("gIceArrowMaterialDL","Gfx","[22]",0xb0), + 0x80922150:("gIceArrowModelDL","Gfx","[24]",0xc0), 0x80922210:("Arrow_Fire_InitVars","ActorInit","",0x20), - 0x80922230:("D_80922230","UNK_TYPE1","",0x1), - 0x80922280:("fireArrowActorInitVars","ActorInitVar","[1]",0x4), + 0x80922230:("sQuadInit","UNK_TYPE1","",0x1), + 0x80922280:("sInitChain","ActorInitVar","[1]",0x4), 0x80922284:("D_80922284","Vec3f","",0xc), 0x80922290:("D_80922290","Vec3f","",0xc), 0x8092229C:("D_8092229C","Vec3f","",0xc), @@ -8041,7 +8040,7 @@ 0x80925F10:("D_80925F10","UNK_TYPE1","",0x1), 0x80925FC0:("D_80925FC0","UNK_TYPE1","",0x1), 0x80926080:("Arrow_Light_InitVars","UNK_TYPE1","",0x1), - 0x809260A0:("D_809260A0","UNK_TYPE1","",0x1), + 0x809260A0:("sInitChain","UNK_TYPE1","",0x1), 0x809260B0:("D_809260B0","char","[]",0x1), 0x809260B8:("D_809260B8","f32","",0x4), 0x809260BC:("D_809260BC","f32","",0x4), From acd84bda77db141588d40b15ee82d3d29cc2fd14 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Fri, 25 Mar 2022 19:57:18 -0700 Subject: [PATCH 122/257] En_Bb (Blue Bubble) OK and documented. object_bb documented (#713) * EnBb_Init OK * EnBb_Destroy OK * func_808C20D4 OK * func_808C2238 OK * func_808C1FF4 OK * func_808C1E94 OK * func_808C2344 OK * func_808C23EC OK * EnBb_Update OK * func_808C2E34 OK * func_808C254C OK * func_808C272C OK * func_808C2B94 OK * func_808C2A00 OK * func_808C1F00 OK * func_808C1F74 OK * func_808C25E0 OK * func_808C28CC OK * func_808C2B1C OK * func_808C2BD0 OK * func_808C2C38 OK * func_808C2CB4 OK * func_808C2CF0 OK * func_808C2D78 OK * EnBb_Draw OK * func_808C32EC OK * func_808C3324 OK * Migrate data to C * Use generated reloc * Object symbols and misc cleanup * Name struct vars that are used with Actor_DrawDamageEffects * Name most things in the object * Name attackRange * Good enough names for limbs for now * Might as well name the limb draw stuff for now * Name flame width/height * Enum for damage effects * Name some more stuff from OoT * Name a lot more stuff * First pass names on all functions * Name jinxTimer on gSaveContext * Name sLimbIndexToLimbPos * First pass name to the rest of the limb draw system * More cleanup * Last cleanup before PR * Incorporate Actor_DrawDamageEffect stuff * Respond to hensldm's review --- assets/xml/objects/object_bb.xml | 76 ++- include/z64save.h | 2 +- spec | 3 +- src/overlays/actors/ovl_En_Bb/z_en_bb.c | 728 +++++++++++++++++++--- src/overlays/actors/ovl_En_Bb/z_en_bb.h | 31 +- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 4 +- tools/actorfixer.py | 1 + tools/disasm/functions.txt | 46 +- undefined_syms.txt | 6 - 9 files changed, 742 insertions(+), 155 deletions(-) diff --git a/assets/xml/objects/object_bb.xml b/assets/xml/objects/object_bb.xml index 4f1c39dac..3bd04c90e 100644 --- a/assets/xml/objects/object_bb.xml +++ b/assets/xml/objects/object_bb.xml @@ -1,37 +1,47 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/z64save.h b/include/z64save.h index 31232b56c..b7f4e60fd 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -134,7 +134,7 @@ typedef struct { /* 0x100C */ u8 eventInf[8]; /* 0x1014 */ u8 unk_1014; // "stone_set_flag" /* 0x1015 */ u8 unk_1015; - /* 0x1016 */ u16 unk_1016; + /* 0x1016 */ u16 jinxTimer; /* 0x1018 */ s16 rupeeAccumulator; // "lupy_udct" /* 0x101A */ u8 unk_101A[6]; // "bottle_status", one entry for each bottle /* 0x1020 */ OSTime unk_1020[6]; // "bottle_ostime", one entry for each bottle diff --git a/spec b/spec index 3cb2716e3..401ebf854 100644 --- a/spec +++ b/spec @@ -1080,8 +1080,7 @@ beginseg name "ovl_En_Bb" compress include "build/src/overlays/actors/ovl_En_Bb/z_en_bb.o" - include "build/data/ovl_En_Bb/ovl_En_Bb.data.o" - include "build/data/ovl_En_Bb/ovl_En_Bb.reloc.o" + include "build/src/overlays/actors/ovl_En_Bb/ovl_En_Bb_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index 1ce821f66..82b3ab923 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -5,6 +5,7 @@ */ #include "z_en_bb.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200) @@ -15,15 +16,25 @@ void EnBb_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBb_Update(Actor* thisx, GlobalContext* globalCtx); void EnBb_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808C23EC(EnBb* this, GlobalContext* globalCtx); -void func_808C25E0(EnBb* this, GlobalContext* globalCtx); -void func_808C28CC(EnBb* this, GlobalContext* globalCtx); -void func_808C2B1C(EnBb* this, GlobalContext* globalCtx); -void func_808C2BD0(EnBb* this, GlobalContext* globalCtx); -void func_808C2CB4(EnBb* this, GlobalContext* globalCtx); -void func_808C2D78(EnBb* this, GlobalContext* globalCtx); +void EnBb_SetupFlyIdle(EnBb* this); +void EnBb_FlyIdle(EnBb* this, GlobalContext* globalCtx); +void EnBb_SetupAttack(EnBb* this); +void EnBb_Attack(EnBb* this, GlobalContext* globalCtx); +void EnBb_Down(EnBb* this, GlobalContext* globalCtx); +void EnBb_Dead(EnBb* this, GlobalContext* globalCtx); +void EnBb_Damage(EnBb* this, GlobalContext* globalCtx); +void EnBb_Frozen(EnBb* this, GlobalContext* globalCtx); +void EnBb_SetupWaitForRevive(EnBb* this); +void EnBb_WaitForRevive(EnBb* this, GlobalContext* globalCtx); +void EnBb_SetupRevive(EnBb* this); +void EnBb_Revive(EnBb* this, GlobalContext* globalCtx); + +typedef enum { + /* -1 */ BB_BODY_PART_DRAW_STATUS_BROKEN = -1, + /* 0 */ BB_BODY_PART_DRAW_STATUS_ALIVE, + /* 1 */ BB_BODY_PART_DRAW_STATUS_DEAD, +} EnBbBodyPartDrawStatus; -#if 0 const ActorInit En_Bb_InitVars = { ACTOR_EN_BB, ACTORCAT_ENEMY, @@ -36,118 +47,667 @@ const ActorInit En_Bb_InitVars = { (ActorFunc)EnBb_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_808C37A0 = { - { COLTYPE_HIT3, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_HIT3, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 20 }, 100 }, }; -// static DamageTable sDamageTable = { -static DamageTable D_808C37CC = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(1, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xE), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(1, 0x0), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0x0), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ EN_BB_DMGEFF_NONE, + /* 0x1 */ EN_BB_DMGEFF_STUN, + /* 0x3 */ EN_BB_DMGEFF_ICE_ARROW = 0x3, + /* 0x4 */ EN_BB_DMGEFF_LIGHT_ARROW, + /* 0x5 */ EN_BB_DMGEFF_ZORA_MAGIC, + /* 0xE */ EN_BB_DMGEFF_HOOKSHOT = 0xE, +} EnBbDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_BB_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, EN_BB_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Ice arrow */ DMG_ENTRY(2, EN_BB_DMGEFF_ICE_ARROW), + /* Light arrow */ DMG_ENTRY(2, EN_BB_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_BB_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, EN_BB_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808C37EC = { 2, 20, 40, 50 }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 20, 40, 50 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808C37F4[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 28, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 10, ICHAIN_STOP), }; -#endif +/** + * This maps a given limb based on its limbIndex to its appropriate index + * in the bodyPartsPos/Velocity arrays. An index of -1 indicates that the + * limb is not part of the bodyParts arrays. + */ +static s8 sLimbIndexToBodyPartsIndex[] = { + -1, -1, -1, -1, 0, -1, -1, -1, 1, -1, -1, -1, -1, 2, -1, 3, +}; -extern ColliderSphereInit D_808C37A0; -extern DamageTable D_808C37CC; -extern CollisionCheckInfoInit D_808C37EC; -extern InitChainEntry D_808C37F4[]; +/** + * The last element of the bodyParts arrays is a duplicate of the cranium + * limb, which is then offset by a certain amount. There is no display list + * associated with this, so it is only used for effects. + */ +static Vec3f sDuplicateCraniumBodyPartOffset = { 1000.0f, -700.0f, 0.0f }; -extern UNK_TYPE D_06000184; -extern UNK_TYPE D_06000444; +void EnBb_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/EnBb_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_Init(globalCtx, &this->skelAnime, &gBubbleSkel, &gBubbleFlyingAnim, this->jointTable, this->morphTable, + BUBBLE_LIMB_MAX); + Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + ActorShape_Init(&this->actor.shape, 1500.0f, ActorShadow_DrawCircle, 35.0f); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/EnBb_Destroy.s") + this->flameScaleY = 0.8f; + this->flameScaleX = 1.0f; + this->actor.world.pos.y += 50.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C1E94.s") + if (EN_BB_ATTACK_RANGE(&this->actor) == 0xFF) { + this->attackRange = 200.0f; + } else { + this->attackRange = EN_BB_ATTACK_RANGE(&this->actor) * 4.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C1F00.s") + EnBb_SetupFlyIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C1F74.s") +void EnBb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C1FF4.s") + Collider_DestroySphere(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C20D4.s") +/** + * Checks to see if the Bubble is touching a wall. If it is, and if the + * Bubble is facing directly "into" the wall, then rotate it away from + * the wall. + */ +void EnBb_CheckForWall(EnBb* this) { + s16 yawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2238.s") + if (this->actor.bgCheckFlags & 8) { + yawDiff = this->actor.shape.rot.y - this->actor.wallYaw; + if (ABS_ALT(yawDiff) > 0x4000) { + this->actor.shape.rot.y = ((this->actor.wallYaw * 2) - this->actor.shape.rot.y) - 0x8000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2344.s") + this->targetYRotation = this->actor.shape.rot.y; + this->actor.bgCheckFlags &= ~8; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C23EC.s") +void EnBb_Freeze(EnBb* this) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.4f; + this->drawDmgEffFrozenSteamScale = 0.6f; + this->timer = 80; + this->drawDmgEffAlpha = 1.0f; + this->actor.flags &= ~ACTOR_FLAG_200; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C254C.s") +void EnBb_Thaw(EnBb* this, GlobalContext* globalCtx) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 0.2f, + 0.15f); + this->actor.flags |= ACTOR_FLAG_200; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C25E0.s") +/** + * Updates certain variables that relate to flying like the Bubble's + * Y-position, bob phase, and flame scale. + */ +void EnBb_UpdateStateForFlying(EnBb* this) { + SkelAnime_Update(&this->skelAnime); + if (this->actor.floorHeight > BGCHECK_Y_MIN) { + Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + this->flyHeightMod, 0.5f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C272C.s") + this->actor.world.pos.y += Math_CosS(this->bobPhase); + this->bobPhase += 0x826; + Math_StepToF(&this->flameScaleY, 0.8f, 0.1f); + Math_StepToF(&this->flameScaleX, 1.0f, 0.1f); + EnBb_CheckForWall(this); + Math_StepToF(&this->actor.speedXZ, this->maxSpeed, 0.5f); + Math_ApproachS(&this->actor.shape.rot.y, this->targetYRotation, 5, 0x3E8); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C28CC.s") +void EnBb_SetupFlyIdle(EnBb* this) { + if (this->actionFunc != EnBb_FlyIdle) { + Animation_PlayLoop(&this->skelAnime, &gBubbleFlyingAnim); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2A00.s") + if (this->actionFunc == EnBb_Attack) { + this->attackWaitTimer = 40; + } else { + this->attackWaitTimer = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2B1C.s") + this->timer = (s32)Rand_ZeroFloat(20.0f) + 40; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->flyHeightMod = (Math_CosS(this->bobPhase) * 10.0f) + 30.0f; + this->targetYRotation = Actor_YawToPoint(&this->actor, &this->actor.home.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2B94.s") + if ((this->actor.xzDistToPlayer < (this->attackRange + 120.0f)) || + (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 300.0f)) { + this->targetYRotation += (s16)(Rand_Next() >> 0x11); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2BD0.s") + this->collider.base.atFlags |= AT_ON; + this->maxSpeed = Rand_ZeroFloat(1.5f) + 1.0f; + this->actionFunc = EnBb_FlyIdle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2C38.s") +/** + * Makes the Bubble fly in circles around its home. + */ +void EnBb_FlyIdle(EnBb* this, GlobalContext* globalCtx) { + EnBb_UpdateStateForFlying(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2CB4.s") + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + } else if ((Animation_OnFrame(&this->skelAnime, 0.0f)) && (Rand_ZeroOne() < 0.1f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_LAUGH); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2CF0.s") + DECR(this->attackWaitTimer); + this->timer--; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2D78.s") + if ((this->attackWaitTimer == 0) && (this->actor.xzDistToPlayer < this->attackRange) && + (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + EnBb_SetupAttack(this); + } else if (this->timer == 0) { + EnBb_SetupFlyIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2E34.s") +void EnBb_SetupAttack(EnBb* this) { + Animation_PlayLoop(&this->skelAnime, &gBubbleAttackAnim); + this->timer = (s32)Rand_ZeroFloat(20.0f) + 60; + this->flyHeightMod = (Math_CosS(this->bobPhase) * 10.0f) + 30.0f; + this->targetYRotation = this->actor.yawTowardsPlayer; + this->maxSpeed = Rand_ZeroFloat(1.5f) + 4.0f; + this->actionFunc = EnBb_Attack; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/EnBb_Update.s") +/** + * Makes the Bubble actively move towards the player. + */ +void EnBb_Attack(EnBb* this, GlobalContext* globalCtx) { + this->targetYRotation = this->actor.yawTowardsPlayer; + EnBb_UpdateStateForFlying(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C32EC.s") + if ((Animation_OnFrame(&this->skelAnime, 0.0f)) || (Animation_OnFrame(&this->skelAnime, 5.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_MOUTH); + } else if ((Animation_OnFrame(&this->skelAnime, 2.0f)) || (Animation_OnFrame(&this->skelAnime, 7.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + } else if ((Animation_OnFrame(&this->skelAnime, 0.0f)) && (Rand_ZeroOne() < 0.1f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_LAUGH); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C3324.s") + this->timer--; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/EnBb_Draw.s") + if (((this->attackRange + 120.0f) < this->actor.xzDistToPlayer) || (this->timer == 0) || + (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || + (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 400.0f)) { + EnBb_SetupFlyIdle(this); + } +} + +void EnBb_SetupDown(EnBb* this) { + Animation_PlayLoop(&this->skelAnime, &gBubbleFlyingAnim); + this->collider.base.atFlags |= AT_ON; + this->timer = 140; + this->collider.base.acFlags |= AC_ON; + this->actor.speedXZ = 2.0f; + this->flameScaleY = 0.0f; + this->flameScaleX = 0.0f; + this->actor.gravity = -2.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DOWN); + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnBb_Down; +} + +/** + * Makes the Bubble hop along the ground. + */ +void EnBb_Down(EnBb* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + EnBb_CheckForWall(this); + + if (this->actor.bgCheckFlags & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + if (this->timer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_UP); + EnBb_SetupFlyIdle(this); + return; + } + + if (this->actor.velocity.y < -14.0f) { + this->actor.velocity.y *= -0.7f; + } else { + this->actor.velocity.y = 10.0f; + } + + this->actor.bgCheckFlags &= ~1; + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 7.0f, 2, 2.0f, 0, 0, 0); + Math_ScaledStepToS(&this->actor.shape.rot.y, BINANG_ADD(this->actor.yawTowardsPlayer, 0x8000), 0xBB8); + } + + this->actor.world.rot.y = this->actor.shape.rot.y; + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + } + + if (this->timer > 0) { + this->timer--; + } +} + +void EnBb_SetupDead(EnBb* this, GlobalContext* globalCtx) { + Vec3f* bodyPartVelocity; + Vec3f posDiff; + f32 magnitude; + s32 i; + + func_800BE568(&this->actor, &this->collider); + this->timer = 15; + this->actor.shape.rot.x += 0x4E20; + this->actor.speedXZ = 0.0f; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_BUBLE_DEAD); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x70); + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->bodyPartDrawStatus = BB_BODY_PART_DRAW_STATUS_DEAD; + this->actor.gravity = -1.5f; + + bodyPartVelocity = &this->bodyPartsVelocity[0]; + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++, bodyPartVelocity++) { + Math_Vec3f_Diff(&this->bodyPartsPos[i], &this->actor.world.pos, &posDiff); + magnitude = Math3D_Vec3fMagnitude(&posDiff); + if (magnitude > 1.0f) { + magnitude = 2.5f / magnitude; + } + + bodyPartVelocity->x = posDiff.x * magnitude; + bodyPartVelocity->z = posDiff.z * magnitude; + bodyPartVelocity->y = Rand_ZeroFloat(3.5f) + 10.0f; + } + + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = EnBb_Dead; +} + +void EnBb_Dead(EnBb* this, GlobalContext* globalCtx) { + s32 i; + + this->timer--; + Math_SmoothStepToS(&this->actor.world.rot.z, 0x4000, 4, 0x1000, 0x400); + + if (this->timer == 0) { + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++) { + func_800B3030(globalCtx, &this->bodyPartsPos[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 2); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->bodyPartsPos[i], 11, NA_SE_EN_EXTINCT); + } + + EnBb_SetupWaitForRevive(this); + } else { + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++) { + Math_Vec3f_Sum(&this->bodyPartsPos[i], &this->bodyPartsVelocity[i], &this->bodyPartsPos[i]); + this->bodyPartsVelocity[i].y += this->actor.gravity; + } + } +} + +void EnBb_SetupDamage(EnBb* this) { + this->collider.base.acFlags &= ~AC_ON; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DAMAGE); + func_800BE568(&this->actor, &this->collider); + + if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_ZORA_MAGIC) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffScale = 0.4f; + } else if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_STUN) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 20); + this->actor.speedXZ = 0.0f; + } else if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_HOOKSHOT) { + this->actor.speedXZ = 0.0f; + } else { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->actor.speedXZ = 7.0f; + } + + this->actor.gravity = -1.0f; + this->actionFunc = EnBb_Damage; +} + +void EnBb_Damage(EnBb* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ < 0.1f)) { + EnBb_SetupDown(this); + } +} + +void EnBb_SetupFrozen(EnBb* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + + this->actor.gravity = -2.0f; + this->actionFunc = EnBb_Frozen; +} + +void EnBb_Frozen(EnBb* this, GlobalContext* globalCtx) { + DECR(this->timer); + + if (this->timer == 0) { + EnBb_Thaw(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + EnBb_SetupDead(this, globalCtx); + } else { + EnBb_SetupDown(this); + } + } +} + +void EnBb_SetupWaitForRevive(EnBb* this) { + this->actor.draw = NULL; + this->bodyPartDrawStatus = BB_BODY_PART_DRAW_STATUS_ALIVE; + this->drawDmgEffAlpha = 0.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actor.shape.rot.x = 0; + this->actor.world.pos.y += 50.0f; + this->timer = 200; + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + this->actionFunc = EnBb_WaitForRevive; +} + +void EnBb_WaitForRevive(EnBb* this, GlobalContext* globalCtx) { + this->timer--; + if (this->timer == 0) { + EnBb_SetupRevive(this); + } +} + +void EnBb_SetupRevive(EnBb* this) { + Animation_PlayLoop(&this->skelAnime, &gBubbleAttackAnim); + this->actor.draw = EnBb_Draw; + this->actor.scale.x = 0.0f; + this->actor.scale.y = 0.015f; + this->actor.scale.z = 0.0f; + this->flameScaleX = 1.0f; + this->flameScaleY = 0.8f; + this->actor.colChkInfo.health = sColChkInfoInit.health; + this->actionFunc = EnBb_Revive; +} + +void EnBb_Revive(EnBb* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y += 0x1F00; + + if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.0005f)) { + this->actor.flags &= ~ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_1; + this->collider.base.acFlags |= AC_ON; + this->collider.base.atFlags |= AT_ON; + this->actor.world.rot.y = this->actor.shape.rot.y; + EnBb_SetupFlyIdle(this); + } + + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = ((0.01f - this->actor.scale.x) * 0.5f) + 0.01f; +} + +void EnBb_UpdateDamage(EnBb* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + this->collider.base.atFlags &= ~AT_ON; + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + (!(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + Actor_SetDropFlag(&this->actor, &this->collider.info); + this->flameScaleY = 0.0f; + this->flameScaleX = 0.0f; + EnBb_Thaw(this, globalCtx); + + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + + if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_ICE_ARROW) { + EnBb_Freeze(this); + if (this->actor.colChkInfo.health == 0) { + this->timer = 3; + this->collider.base.acFlags &= ~AC_ON; + } + + EnBb_SetupFrozen(this); + } else if (this->actor.colChkInfo.health == 0) { + EnBb_SetupDead(this, globalCtx); + } else { + EnBb_SetupDamage(this); + } + + if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_LIGHT_ARROW) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.4f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_SMALL_LIGHT_RAYS); + } + } + } else { + if (this->collider.base.atFlags & AT_BOUNCED) { + this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + if (this->actionFunc != EnBb_Down) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; + this->actor.shape.rot.y = this->actor.world.rot.y; + EnBb_SetupDown(this); + } + } else if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; + this->actor.shape.rot.y = this->actor.world.rot.y; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_BITE); + + if (this->flameScaleX > 0.0f) { + gSaveContext.jinxTimer = 1200; + } + + if (this->actionFunc == EnBb_Attack) { + EnBb_SetupFlyIdle(this); + } + } + } +} + +void EnBb_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBb* this = THIS; + + EnBb_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + if ((this->actionFunc != EnBb_Dead) && (this->actionFunc != EnBb_WaitForRevive)) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 25.0f, 40.0f, 7); + + this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->actor.world.pos.y + 15.0f; + this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; + this->collider.dim.worldSphere.radius = this->flameScaleX * 30.0f; + this->collider.dim.worldSphere.radius = CLAMP_MIN(this->collider.dim.worldSphere.radius, 20); + + Math_Vec3s_ToVec3f(&this->actor.focus.pos, &this->collider.dim.worldSphere.center); + + if (this->collider.base.atFlags & AT_ON) { + this->actor.flags |= ACTOR_FLAG_1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.ocFlags1 & OC1_ON) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.2f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.4f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.4f, 0.01f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + } +} + +s32 EnBb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnBb* this = THIS; + + if (this->bodyPartDrawStatus == BB_BODY_PART_DRAW_STATUS_BROKEN) { + this->limbDList = *dList; + *dList = NULL; + } + + return false; +} + +void EnBb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnBb* this = THIS; + MtxF* currentMatrixState; + + if (this->bodyPartDrawStatus == BB_BODY_PART_DRAW_STATUS_ALIVE) { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + if (sLimbIndexToBodyPartsIndex[limbIndex] == 0) { + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->bodyPartsPos[0]); + } else if (sLimbIndexToBodyPartsIndex[limbIndex] == 3) { + Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->bodyPartsPos[3]); + Matrix_MultiplyVector3fByState(&sDuplicateCraniumBodyPartOffset, &this->bodyPartsPos[4]); + } else { + Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + } + } + } else if (this->bodyPartDrawStatus > BB_BODY_PART_DRAW_STATUS_ALIVE) { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + } + + if (limbIndex == BUBBLE_LIMB_CRANIUM) { + this->bodyPartDrawStatus = BB_BODY_PART_DRAW_STATUS_BROKEN; + } + } else { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + currentMatrixState = Matrix_GetCurrentState(); + currentMatrixState->mf[3][0] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].x; + currentMatrixState->mf[3][1] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].y; + currentMatrixState->mf[3][2] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].z; + Matrix_InsertZRotation_s(thisx->world.rot.z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->limbDList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} + +void EnBb_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBb* this = THIS; + MtxF* currentMatrixState; + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + POLY_OPA_DISP = &gfx[1]; + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnBb_OverrideLimbDraw, + EnBb_PostLimbDraw, &this->actor); + + if (this->flameScaleX > 0.0f) { + currentMatrixState = Matrix_GetCurrentState(); + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_RotateY( + ((Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) - this->actor.shape.rot.y) + 0x8000), + MTXMODE_APPLY); + Matrix_Scale(this->flameScaleX, this->flameScaleY, 1.0f, MTXMODE_APPLY); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 0); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + (globalCtx->gameplayFrames * -20) & 0x1FF, 32, 128)); + currentMatrixState->mf[3][1] -= 47.0f * this->flameScaleY; + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); + } + + Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.h b/src/overlays/actors/ovl_En_Bb/z_en_bb.h index 513020bd2..7d5da25b3 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.h +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.h @@ -2,16 +2,39 @@ #define Z_EN_BB_H #include "global.h" +#include "objects/object_bb/object_bb.h" + +#define EN_BB_ATTACK_RANGE(thisx) (((thisx)->params >> 8) & 0xFF) struct EnBb; typedef void (*EnBbActionFunc)(struct EnBb*, GlobalContext*); typedef struct EnBb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; - /* 0x0248 */ EnBbActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x100]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[BUBBLE_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[BUBBLE_LIMB_MAX]; + /* 0x248 */ EnBbActionFunc actionFunc; + /* 0x24C */ s8 bodyPartDrawStatus; + /* 0x24D */ u8 drawDmgEffType; + /* 0x24E */ UNK_TYPE1 unk_24E[0x2]; + /* 0x250 */ s16 timer; + /* 0x252 */ s16 attackWaitTimer; // Cannot start attacking the player if this is non-zero + /* 0x254 */ s16 targetYRotation; + /* 0x256 */ s16 bobPhase; + /* 0x258 */ f32 maxSpeed; + /* 0x25C */ f32 flyHeightMod; + /* 0x260 */ f32 attackRange; + /* 0x264 */ f32 flameScaleX; + /* 0x268 */ f32 flameScaleY; + /* 0x26C */ f32 drawDmgEffAlpha; + /* 0x270 */ f32 drawDmgEffScale; + /* 0x274 */ f32 drawDmgEffFrozenSteamScale; + /* 0x278 */ Vec3f bodyPartsPos[5]; + /* 0x2B4 */ Vec3f bodyPartsVelocity[5]; + /* 0x2F0 */ Gfx* limbDList; + /* 0x2F4 */ ColliderSphere collider; } EnBb; // size = 0x34C extern const ActorInit En_Bb_InitVars; diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index 134a7080e..268e1314a 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -363,7 +363,7 @@ void EnElf_Init(Actor* thisx, GlobalContext* globalCtx2) { case 1: colorConfig = -1; - gSaveContext.unk_1016 = 0; + gSaveContext.jinxTimer = 0; EnElf_SetupAction(this, func_8088E0F0); this->unk_254 = Math_Vec3f_DistXZ(&thisx->world.pos, &player->actor.world.pos); this->unk_248 = player->actor.shape.rot.y; @@ -677,7 +677,7 @@ void func_8088DD34(EnElf* this, GlobalContext* globalCtx) { if (this->fairyFlags & 0x200) { Parameter_AddMagic(globalCtx, ((void)0, gSaveContext.unk_3F30) + (gSaveContext.doubleMagic * 0x30) + 0x30); } - gSaveContext.unk_1016 = 0; + gSaveContext.jinxTimer = 0; this->unk_254 = 50.0f; this->unk_248 = refActor->actor.shape.rot.y; this->unk_24C = -0x1000; diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 3ba0615f9..71d87716b 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -493,6 +493,7 @@ animdict = { "player->unk_38C": "player->mountSide", "player->unk_394": "player->csMode", "globalCtx->actorCtx.actorList[": "globalCtx->actorCtx.actorLists[", + "gSaveContext.unk_1016": "gSaveContext.jinxTimer", "gSaveContext.unk_3F58": "gSaveContext.sunsSongState", "globalCtx->msgCtx.unk1202A": "globalCtx->msgCtx.ocarinaMode", "globalCtx->msgCtx.unk1202C": "globalCtx->msgCtx.ocarinaAction", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 8b40e2a91..e54876248 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -6113,30 +6113,30 @@ 0x808C1918:("ArmsHook_Draw",), 0x808C1D40:("EnBb_Init",), 0x808C1E68:("EnBb_Destroy",), - 0x808C1E94:("func_808C1E94",), - 0x808C1F00:("func_808C1F00",), - 0x808C1F74:("func_808C1F74",), - 0x808C1FF4:("func_808C1FF4",), - 0x808C20D4:("func_808C20D4",), - 0x808C2238:("func_808C2238",), - 0x808C2344:("func_808C2344",), - 0x808C23EC:("func_808C23EC",), - 0x808C254C:("func_808C254C",), - 0x808C25E0:("func_808C25E0",), - 0x808C272C:("func_808C272C",), - 0x808C28CC:("func_808C28CC",), - 0x808C2A00:("func_808C2A00",), - 0x808C2B1C:("func_808C2B1C",), - 0x808C2B94:("func_808C2B94",), - 0x808C2BD0:("func_808C2BD0",), - 0x808C2C38:("func_808C2C38",), - 0x808C2CB4:("func_808C2CB4",), - 0x808C2CF0:("func_808C2CF0",), - 0x808C2D78:("func_808C2D78",), - 0x808C2E34:("func_808C2E34",), + 0x808C1E94:("EnBb_CheckForWall",), + 0x808C1F00:("EnBb_Freeze",), + 0x808C1F74:("EnBb_Thaw",), + 0x808C1FF4:("EnBb_UpdateStateForFlying",), + 0x808C20D4:("EnBb_SetupFlyIdle",), + 0x808C2238:("EnBb_FlyIdle",), + 0x808C2344:("EnBb_SetupAttack",), + 0x808C23EC:("EnBb_Attack",), + 0x808C254C:("EnBb_SetupDown",), + 0x808C25E0:("EnBb_Down",), + 0x808C272C:("EnBb_SetupDead",), + 0x808C28CC:("EnBb_Dead",), + 0x808C2A00:("EnBb_SetupDamage",), + 0x808C2B1C:("EnBb_Damage",), + 0x808C2B94:("EnBb_SetupFrozen",), + 0x808C2BD0:("EnBb_Frozen",), + 0x808C2C38:("EnBb_SetupWaitForRevive",), + 0x808C2CB4:("EnBb_WaitForRevive",), + 0x808C2CF0:("EnBb_SetupRevive",), + 0x808C2D78:("EnBb_Revive",), + 0x808C2E34:("EnBb_UpdateDamage",), 0x808C30A0:("EnBb_Update",), - 0x808C32EC:("func_808C32EC",), - 0x808C3324:("func_808C3324",), + 0x808C32EC:("EnBb_OverrideLimbDraw",), + 0x808C3324:("EnBb_PostLimbDraw",), 0x808C351C:("EnBb_Draw",), 0x808C3A50:("BgKeikokuSpr_Init",), 0x808C3A78:("BgKeikokuSpr_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 0ac18443b..ef818ac71 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1075,12 +1075,6 @@ D_0600D530 = 0x0600D530; D_060000A0 = 0x060000A0; D_060000C8 = 0x060000C8; -// ovl_En_Bb - -D_06000184 = 0x06000184; -D_06000444 = 0x06000444; -D_06001A30 = 0x06001A30; - // ovl_En_Bbfall D_06000184 = 0x06000184; From 3986732c5d6c0a1ec59ca0bb33c3f8fc3fe55137 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Fri, 25 Mar 2022 20:07:25 -0700 Subject: [PATCH 123/257] En_Syateki_Dekunuts (Shooting Gallery Deku Scrub) OK (#716) * Import data to C * EnSyatekiDekunuts_Init OK * EnSyatekiDekunuts_Destroy OK * func_80A2BE54 OK * func_80A2BF18 OK * func_80A2BFC4 OK * func_80A2C0F8 OK * func_80A2C150 and func_80A2C168 OK * func_80A2C1AC OK and better match on func_80A2BFC4 * func_80A2C208 OK * func_80A2C27C OK * func_80A2C2E0 and func_80A2C33C OK * func_80A2C3F0 OK * func_80A2C478 and func_80A2C48C OK * EnSyatekiDekunuts_Update OK * func_80A2C4D0 OK * func_80A2C5DC OK * EnSyatekiDekunuts_Draw OK * func_80A2C8A0 OK * Use generated reloc and minor cleanup * Use object symbols * Last bit of cleanup * Use limb enum values for all syateki actors I've worked on * M_PI / 4 --- spec | 3 +- .../ovl_En_Syateki_Crow/z_en_syateki_crow.c | 19 +- .../z_en_syateki_dekunuts.c | 401 ++++++++++++++++-- .../z_en_syateki_dekunuts.h | 27 +- .../ovl_En_Syateki_Wf/z_en_syateki_wf.c | 8 +- tools/disasm/functions.txt | 2 +- undefined_syms.txt | 7 - 7 files changed, 403 insertions(+), 64 deletions(-) diff --git a/spec b/spec index 401ebf854..46a8fc677 100644 --- a/spec +++ b/spec @@ -2667,8 +2667,7 @@ beginseg name "ovl_En_Syateki_Dekunuts" compress include "build/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.o" - include "build/data/ovl_En_Syateki_Dekunuts/ovl_En_Syateki_Dekunuts.data.o" - include "build/data/ovl_En_Syateki_Dekunuts/ovl_En_Syateki_Dekunuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Syateki_Dekunuts/ovl_En_Syateki_Dekunuts_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c index 1b6397f25..e11deb354 100644 --- a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c +++ b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c @@ -83,16 +83,14 @@ void EnSyatekiCrow_Init(Actor* thisx, GlobalContext* globalCtx2) { EnSyatekiCrow* this = THIS; Path* path; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - s32 temp; + s32 i; path = syatekiMan->path; while (path->unk2 != 0) { path = &globalCtx->setupPathList[path->unk1]; } - temp = 0; - while (temp < EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor)) { - temp++; + for (i = 0; i < EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor); i++) { path = &globalCtx->setupPathList[path->unk1]; } @@ -292,10 +290,10 @@ s32 EnSyatekiCrow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx* Actor* thisx) { EnSyatekiCrow* this = THIS; - if (limbIndex == 7) { - rot->y += (s16)(3072.0f * sin_rad(this->skelAnime.curFrame * 0.7853982f)); - } else if (limbIndex == 8) { - rot->y += (s16)(5120.0f * sin_rad((this->skelAnime.curFrame + 2.5f) * 0.7853982f)); + if (limbIndex == OBJECT_CROW_LIMB_07) { + rot->y += (s16)(3072.0f * sin_rad(this->skelAnime.curFrame * (M_PI / 4))); + } else if (limbIndex == OBJECT_CROW_LIMB_08) { + rot->y += (s16)(5120.0f * sin_rad((this->skelAnime.curFrame + 2.5f) * (M_PI / 4))); } return false; @@ -305,10 +303,11 @@ void EnSyatekiCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d EnSyatekiCrow* this = THIS; Vec3f* sp1C; - if (limbIndex == 2) { + if (limbIndex == OBJECT_CROW_LIMB_02) { Matrix_MultiplyVector3fByState(&D_809CB0D8, &this->unk_144[0]); this->unk_144[0].y -= 20.0f; - } else if ((limbIndex == 4) || (limbIndex == 6) || (limbIndex == 8)) { + } else if ((limbIndex == OBJECT_CROW_LIMB_04) || (limbIndex == OBJECT_CROW_LIMB_06) || + (limbIndex == OBJECT_CROW_LIMB_08)) { sp1C = &this->unk_144[(limbIndex >> 1) - 1]; Matrix_MultiplyVector3fByState(&D_809CB050, sp1C); sp1C->y -= 20.0f; diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c index 65849b7e5..944838b3c 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c @@ -5,6 +5,9 @@ */ #include "z_en_syateki_dekunuts.h" +#include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" +#include "objects/object_dekunuts/object_dekunuts.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) @@ -15,16 +18,23 @@ void EnSyatekiDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiDekunuts_Update(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A2BE54(EnSyatekiDekunuts* this); void func_80A2BF18(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2BFC4(EnSyatekiDekunuts* this); void func_80A2C0F8(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C150(EnSyatekiDekunuts* this); void func_80A2C168(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C1AC(EnSyatekiDekunuts* this); void func_80A2C208(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C27C(EnSyatekiDekunuts* this); void func_80A2C2E0(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C33C(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C3AC(EnSyatekiDekunuts* this); void func_80A2C3F0(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C478(EnSyatekiDekunuts* this); void func_80A2C48C(EnSyatekiDekunuts* this, GlobalContext* globalCtx); void func_80A2C5DC(EnSyatekiDekunuts* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Syateki_Dekunuts_InitVars = { ACTOR_EN_SYATEKI_DEKUNUTS, ACTORCAT_ENEMY, @@ -37,69 +47,390 @@ const ActorInit En_Syateki_Dekunuts_InitVars = { (ActorFunc)EnSyatekiDekunuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A2CAB0 = { - { COLTYPE_HIT6, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 48, 80, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A2CB90[] = { +static Cylinder16 D_80A2CADC[] = { { 24, 40, 0, { 0, 0, 0 } } }; + +static AnimationInfo sAnimations[] = { + { &object_dekunuts_Anim_003180, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_dekunuts_Anim_002A5C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_dekunuts_Anim_00326C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &object_dekunuts_Anim_002FA4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &object_dekunuts_Anim_00259C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_dekunuts_Anim_002BD4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_dekunuts_Anim_002DD4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 77, ICHAIN_CONTINUE), ICHAIN_F32(gravity, 0, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2600, ICHAIN_STOP), }; -#endif +void EnSyatekiDekunuts_Init(Actor* thisx, GlobalContext* globalCtx2) { + static s32 D_80A2CB9C = 1; + EnSyatekiDekunuts* this = THIS; + GlobalContext* globalCtx = globalCtx2; + s32 phi_v0; + Path* path; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + s32 i; -extern ColliderCylinderInit D_80A2CAB0; -extern InitChainEntry D_80A2CB90[]; + path = syatekiMan->path; + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -extern UNK_TYPE D_06001E50; -extern UNK_TYPE D_06002A5C; -extern UNK_TYPE D_06003180; + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { + Actor_SetScale(&this->actor, 0.01f); + this->collider.dim = D_80A2CADC[0]; + phi_v0 = 3; + } else { + Actor_SetScale(&this->actor, 0.02f); + phi_v0 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/EnSyatekiDekunuts_Init.s") + while (path->unk2 != phi_v0) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/EnSyatekiDekunuts_Destroy.s") + for (i = 0; i < EN_SYATEKI_DEKUNUTS_GET_PARAM_FF00(&this->actor); i++) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2BE54.s") + if (D_80A2CB9C == 1) { + this->unk_1EC = 1; + D_80A2CB9C = 0; + } else { + this->unk_1EC = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2BF18.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_dekunuts_Skel_002468, &object_dekunuts_Anim_002A5C, + this->jointTable, this->morphTable, 10); + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2BFC4.s") + this->unk_1E4 = Lib_SegmentedToVirtual(path->points); + this->unk_1E8 = EN_SYATEKI_DEKUNUTS_GET_PARAM_F0(&this->actor); + this->unk_1EA = path->count; + this->unk_1D8 = 0; + this->unk_1DC = 0; + this->unk_1DA = 0; + func_80A2BE54(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C0F8.s") +void EnSyatekiDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiDekunuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C150.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C168.s") +void func_80A2BE54(EnSyatekiDekunuts* this) { + Animation_PlayOnceSetSpeed(&this->skelAnime, &object_dekunuts_Anim_003180, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C1AC.s") + this->actor.speedXZ = 0.0f; + this->actor.world = this->actor.home; + this->actor.prevPos = this->actor.home.pos; + this->actor.shape.rot = this->actor.world.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C208.s") + this->unk_1D8 = 0; + this->unk_1DC = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C27C.s") + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { + this->unk_1E2 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C2E0.s") + this->actionFunc = func_80A2BF18; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C33C.s") +void func_80A2BF18(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C3AC.s") + if ((syatekiMan->unk_26A == 1) && (this->unk_1E2 == 1) && ((syatekiMan->unk_272 & (1 << this->unk_1E8)) != 0)) { + func_80A2BFC4(this); + } else if (syatekiMan->unk_26A != 1) { + this->unk_1E2 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C3F0.s") + if ((syatekiMan->unk_272 == 0) && (syatekiMan->unk_274 == 0) && + (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1)) { + this->unk_1E2 = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C478.s") +void func_80A2BFC4(EnSyatekiDekunuts* this) { + Vec3f sp14; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C48C.s") + this->unk_1D8 = 0; + sp14.x = this->unk_1E4[this->unk_1E8].x; + sp14.y = this->unk_1E4[this->unk_1E8].y; + sp14.z = this->unk_1E4[this->unk_1E8].z; + this->actor.world.pos = this->actor.prevPos = sp14; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->unk_1EE = 140 - (syatekiMan->unk_27C * 20); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C4D0.s") + if ((syatekiMan->unk_27C & 1) != 0) { + this->unk_1F0 = 1; + this->unk_1F2 = 0; + } else { + this->unk_1F0 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C5DC.s") + this->actionFunc = func_80A2C0F8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/EnSyatekiDekunuts_Update.s") +void func_80A2C0F8(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C8A0.s") + if (this->unk_1DA > 20) { + syatekiMan = (EnSyatekiMan*)this->actor.parent; + Actor_PlaySfxAtPos(&syatekiMan->actor, NA_SE_EN_NUTS_DAMAGE); + this->unk_1DA = 0; + func_80A2C150(this); + } else { + this->unk_1DA++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/EnSyatekiDekunuts_Draw.s") +void func_80A2C150(EnSyatekiDekunuts* this) { + this->unk_1D8 = 0; + this->actionFunc = func_80A2C168; +} + +void func_80A2C168(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + if (this->unk_1DA > 20) { + func_80A2C1AC(this); + this->unk_1DA = 0; + } else { + this->unk_1DA++; + } +} + +void func_80A2C1AC(EnSyatekiDekunuts* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actionFunc = func_80A2C208; +} + +void func_80A2C208(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A2C27C(this); + } + + if (this->unk_1F0 == 1) { + Math_SmoothStepToS(&this->unk_1F2, -0x8000, 5, 0x1000, 0x100); + } + + this->unk_1D8++; +} + +void func_80A2C27C(EnSyatekiDekunuts* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { + this->actionFunc = func_80A2C2E0; + } else { + this->actionFunc = func_80A2C33C; + } +} + +void func_80A2C2E0(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if ((this->unk_1EE < this->unk_1D8) || (syatekiMan->unk_26A != 1)) { + func_80A2C3AC(this); + } + + this->unk_1D8++; +} + +void func_80A2C33C(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if ((gSaveContext.unk_3DE0[1] <= 0) || (syatekiMan->unk_26A != 1)) { + func_80A2C3AC(this); + } + + if (this->unk_1D8 < 11) { + this->unk_1D8++; + } +} + +void func_80A2C3AC(EnSyatekiDekunuts* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actionFunc = func_80A2C3F0; +} + +void func_80A2C3F0(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (syatekiMan->unk_26A == 1) { + if (this->unk_1D8 > 160 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->unk_1D8 = 0; + func_80A2C150(this); + } else { + this->unk_1D8++; + } + } else { + func_80A2C478(this); + } +} + +void func_80A2C478(EnSyatekiDekunuts* this) { + this->actionFunc = func_80A2C48C; +} + +void func_80A2C48C(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + if (this->unk_1DA > 20) { + func_80A2BE54(this); + this->unk_1DA = 0; + } else { + this->unk_1DA++; + } +} + +void func_80A2C4D0(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + static Vec3f D_80A2CBA0 = { 0.0f, 20.0f, 0.0f }; + static Vec3f D_80A2CBAC = { 0.0f, 0.0f, 0.0f }; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { + EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_80A2CBA0, &D_80A2CBAC, 5, 2); + syatekiMan->unk_280 += 100; + syatekiMan->unk_26E++; + } else { + EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_80A2CBA0, &D_80A2CBAC, 5, 0); + syatekiMan->unk_280 += 30; + syatekiMan->unk_278++; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); + this->unk_1E2 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + this->unk_1D8 = 160; + this->actionFunc = func_80A2C5DC; +} + +void func_80A2C5DC(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + static Color_RGBA8 D_80A2CBB8 = { 255, 255, 255, 255 }; + static Color_RGBA8 D_80A2CBBC = { 150, 150, 150, 0 }; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (this->unk_1D8 == 160) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); + this->unk_1D8--; + } else if (this->unk_1D8 < 160) { + Vec3f sp40; + + sp40.x = this->actor.world.pos.x; + sp40.y = this->actor.world.pos.y + 18.0f; + sp40.z = this->actor.world.pos.z; + EffectSsDeadDb_Spawn(globalCtx, &sp40, &gZeroVec3f, &gZeroVec3f, &D_80A2CBB8, &D_80A2CBBC, 200, 0, 13); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_EXTINCT); + sp40.y = this->actor.world.pos.y + 10.0f; + EffectSsHahen_SpawnBurst(globalCtx, &sp40, 3.0f, 0, 12, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); + + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { + syatekiMan->unk_272 &= ~(1 << this->unk_1E8); + } + + func_80A2BE54(this); + } + } else if (this->unk_1D8 < 160) { + this->unk_1D8--; + } +} + +void EnSyatekiDekunuts_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSyatekiDekunuts* this = THIS; + + this->actionFunc(this, globalCtx); + + if ((this->actionFunc != func_80A2BF18) && (this->unk_1D8 < this->unk_1EE) && (this->unk_1D8 > 10)) { + if ((this->collider.base.acFlags & AC_HIT) && (this->unk_1E2 == 1)) { + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { + func_801A3098(NA_BGM_GET_ITEM | 0x900); + } else { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + + this->collider.base.acFlags &= ~AC_HIT; + func_80A2C4D0(this, globalCtx); + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } else { + this->collider.base.acFlags &= ~AC_HIT; + } + + SkelAnime_Update(&this->skelAnime); +} + +s32 EnSyatekiDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnSyatekiDekunuts* this = THIS; + + if ((limbIndex == OBJECT_DEKUNUTS_LIMB_03) && (this->unk_1F0 == 1)) { + rot->z += this->unk_1F2; + } + + return false; +} + +void EnSyatekiDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiDekunuts* this = THIS; + Vec3f temp_f20; + s32 i; + + if (this->actionFunc != func_80A2BF18) { + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + EnSyatekiDekunuts_OverrideLimbDraw, NULL, &this->actor); + } + + if (this->unk_1EC == 1) { + for (i = 0; i < this->unk_1EA; i++) { + temp_f20.x = this->unk_1E4[i].x; + temp_f20.y = this->unk_1E4[i].y; + temp_f20.z = this->unk_1E4[i].z; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(temp_f20.x, temp_f20.y, temp_f20.z, MTXMODE_NEW); + Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &object_dekunuts_DL_001E50); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h index 30712d917..4055dd6b8 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h @@ -3,15 +3,34 @@ #include "global.h" +#define EN_SYATEKI_DEKUNUTS_GET_PARAM_F(thisx) ((thisx)->params & 0xF) +#define EN_SYATEKI_DEKUNUTS_GET_PARAM_F0(thisx) (((thisx)->params & 0xF0) >> 4) +#define EN_SYATEKI_DEKUNUTS_GET_PARAM_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + struct EnSyatekiDekunuts; typedef void (*EnSyatekiDekunutsActionFunc)(struct EnSyatekiDekunuts*, GlobalContext*); typedef struct EnSyatekiDekunuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnSyatekiDekunutsActionFunc actionFunc; - /* 0x018C */ char unk_18C[0xE4]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnSyatekiDekunutsActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ s16 unk_1D8; + /* 0x1DA */ s16 unk_1DA; + /* 0x1CD */ s16 unk_1DC; + /* 0x1DE */ UNK_TYPE1 unk_1DE[0x4]; + /* 0x1E2 */ s16 unk_1E2; + /* 0x1E4 */ Vec3s* unk_1E4; + /* 0x1E8 */ s16 unk_1E8; + /* 0x1EA */ s16 unk_1EA; + /* 0x1EC */ s16 unk_1EC; + /* 0x1EE */ s16 unk_1EE; + /* 0x1F0 */ s16 unk_1F0; + /* 0x1F2 */ s16 unk_1F2; + /* 0x1F4 */ Vec3s jointTable[10]; + /* 0x230 */ Vec3s morphTable[10]; + /* 0x26C */ UNK_TYPE1 unk_26C[0x4]; } EnSyatekiDekunuts; // size = 0x270 extern const ActorInit En_Syateki_Dekunuts_InitVars; diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c index 6e53877a3..ff6595044 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c @@ -145,16 +145,14 @@ void EnSyatekiWf_Init(Actor* thisx, GlobalContext* globalCtx) { EnSyatekiWf* this = THIS; Path* path; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - s32 temp; + s32 i; path = syatekiMan->path; while (path->unk2 != 2) { path = &globalCtx->setupPathList[path->unk1]; } - temp = 0; - while (temp < EN_SYATEKI_WF_GET_PARAM_FF00(&this->actor)) { - temp++; + for (i = 0; i < EN_SYATEKI_WF_GET_PARAM_FF00(&this->actor); i++) { path = &globalCtx->setupPathList[path->unk1]; } @@ -463,7 +461,7 @@ void EnSyatekiWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi Vec3f sp18; Collider_UpdateSpheres(limbIndex, &this->unk_34C); - if (limbIndex == 6) { + if (limbIndex == OBJECT_WF_2_LIMB_06) { Matrix_MultiplyVector3fByState(&D_80A20FD0, &sp18); this->unk_300.dim.pos.x = sp18.x; this->unk_300.dim.pos.y = sp18.y; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e54876248..f3217aeac 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10081,7 +10081,7 @@ 0x80A2C4D0:("func_80A2C4D0",), 0x80A2C5DC:("func_80A2C5DC",), 0x80A2C78C:("EnSyatekiDekunuts_Update",), - 0x80A2C8A0:("func_80A2C8A0",), + 0x80A2C8A0:("EnSyatekiDekunuts_OverrideLimbDraw",), 0x80A2C8E8:("EnSyatekiDekunuts_Draw",), 0x80A2CD10:("ElfMsg3_SetupAction",), 0x80A2CD1C:("func_80A2CD1C",), diff --git a/undefined_syms.txt b/undefined_syms.txt index ef818ac71..ff84de04f 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1651,13 +1651,6 @@ D_0600D640 = 0x0600D640; D_06006C18 = 0x06006C18; D_0600D640 = 0x0600D640; -// ovl_En_Syateki_Dekunuts - -D_06001E50 = 0x06001E50; -D_06002468 = 0x06002468; -D_06002A5C = 0x06002A5C; -D_06003180 = 0x06003180; - // ovl_En_Syateki_Okuta D_060033D0 = 0x060033D0; From 5649458e2f2e13df9c16a398e37337684c7dbead Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 27 Mar 2022 14:23:46 +0100 Subject: [PATCH 124/257] Bg_Hakugin_Bombwall (#709) --- spec | 5 +- .../z_bg_hakugin_bombwall.c | 412 +++++++++++++++++- .../z_bg_hakugin_bombwall.h | 13 +- 3 files changed, 402 insertions(+), 28 deletions(-) diff --git a/spec b/spec index 46a8fc677..cb1adb6e4 100644 --- a/spec +++ b/spec @@ -3320,8 +3320,11 @@ beginseg name "ovl_Bg_Hakugin_Bombwall" compress include "build/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.o" - include "build/data/ovl_Bg_Hakugin_Bombwall/ovl_Bg_Hakugin_Bombwall.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/ovl_Bg_Hakugin_Bombwall_reloc.o" +#else include "build/data/ovl_Bg_Hakugin_Bombwall/ovl_Bg_Hakugin_Bombwall.reloc.o" +#endif endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c index 4061745f7..1f0030d28 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c @@ -5,6 +5,7 @@ */ #include "z_bg_hakugin_bombwall.h" +#include "objects/object_hakugin_obj/object_hakugin_obj.h" #define FLAGS 0x00000000 @@ -15,7 +16,16 @@ void BgHakuginBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHakuginBombwall_Update(Actor* thisx, GlobalContext* globalCtx); void BgHakuginBombwall_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABC2E0(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABC7FC(BgHakuginBombwall* this, GlobalContext* globalCtx); +s32 func_80ABCB5C(Actor* thisx, GlobalContext* globalCtx); +s32 func_80ABCC00(Actor* thisx, GlobalContext* globalCtx); +void func_80ABCCE4(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABCD98(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABCE60(BgHakuginBombwall* this, GlobalContext* globalCtx); + const ActorInit Bg_Hakugin_Bombwall_InitVars = { ACTOR_BG_HAKUGIN_BOMBWALL, ACTORCAT_BG, @@ -28,48 +38,404 @@ const ActorInit Bg_Hakugin_Bombwall_InitVars = { (ActorFunc)BgHakuginBombwall_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80ABCF80 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 80, 80, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80ABD040[] = { +Color_RGBA8 D_80ABCFAC = { 210, 210, 210, 255 }; +Color_RGBA8 D_80ABCFB0 = { 140, 140, 140, 255 }; + +Vec3f D_80ABCFB4 = { 0.0f, 0.33f, 0.0f }; + +typedef struct { + /* 0x00 */ CollisionHeader* unk_00; + /* 0x04 */ Gfx* unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ s16 unk_14; + /* 0x16 */ s16 unk_16; + /* 0x18 */ s32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ BgHakuginBombwallUnkFunc unk_20; + /* 0x24 */ BgHakuginBombwallUnkFunc2 unk_24; + /* 0x28 */ BgHakuginBombwallUnkFunc2 unk_28; + /* 0x2C */ s32 unk_2C; +} BgHakuginBombwallStruct; // size = 0x30 + +BgHakuginBombwallStruct D_80ABCFC0[] = { + { + &object_hakugin_obj_Colheader_009768, + object_hakugin_obj_DL_009658, + 70.0f, + 600.0f, + 400.0f, + 80, + 80, + 0x8, + 4225.0f, + func_80ABCB5C, + func_80ABBFC0, + func_80ABC58C, + 6, + }, + { + &object_hakugin_obj_Colheader_009AF0, + object_hakugin_obj_DL_0099A8, + 10.0f, + 600.0f, + 300.0f, + 50, + 20, + 0x408, + 4225.0f, + func_80ABCC00, + func_80ABC2E0, + func_80ABC7FC, + 18, + }, +}; + +s32 D_80ABD020[] = { -73, -40, -8, 24, 57 }; + +Vec3f D_80ABD034 = { 0.0f, 3.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; +#ifdef NON_MATCHING +// Breaks relocs +void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 temp; + Vec3f spF0; + Vec3f spE4; + Vec3f spD8; + Vec3f spCC; + s32 pad; + s16 phi_s1; + s16 phi_s0; + s32 i; + s32 j; + + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + + for (i = 0; i < 6; i++) { + temp = i + 1; + for (j = 0; j < ARRAY_COUNT(D_80ABD020); j++) { + spD8.x = D_80ABD020[j] + (s32)((u32)Rand_Next() >> 0x1C); + spD8.y = ((Rand_ZeroOne() - 0.5f) * 15.0f) + (temp * 26.666666f); + spD8.z = (Rand_ZeroOne() * 20.0f) - 10.0f; + + spCC.x = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (spD8.x * 0.07777778f); + spCC.y = (Rand_ZeroOne() * 7.0f) - 2.0f; + spCC.z = spD8.z * 0.3f; + + Matrix_MultiplyVector3fByState(&spD8, &spF0); + Matrix_MultiplyVector3fByState(&spCC, &spE4); + + spF0.x += this->dyna.actor.world.pos.x; + spF0.y += this->dyna.actor.world.pos.y; + spF0.z += this->dyna.actor.world.pos.z; + + if ((Rand_Next() % 4) == 0) { + phi_s0 = 32; + } else { + phi_s0 = 64; + } + + if (Rand_Next() > 0) { + phi_s0 |= 1; + phi_s1 = 1; + func_800B0E48(globalCtx, &spF0, &gZeroVec3f, &D_80ABCFB4, &D_80ABCFAC, &D_80ABCFB0, + ((u32)Rand_Next() >> 0x1B) + 70, ((u32)Rand_Next() >> 0x1A) + 60); + } else { + phi_s1 = 0; + } + + EffectSsKakera_Spawn(globalCtx, &spF0, &spE4, &spF0, -550, phi_s0, 30, 0, 0, + (s32)(Rand_ZeroOne() * 22.0f) + 5, phi_s1, 0, 50, -1, OBJECT_HAKUGIN_OBJ, + object_hakugin_obj_DL_009830); + } + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABBFC0.s") #endif -extern ColliderCylinderInit D_80ABCF80; -extern InitChainEntry D_80ABD040[]; +void func_80ABC2E0(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 pad; + s32 i; + s16 phi_s2; + s16 phi_v0; + s16 phi_v1; + s16 phi_t0; + s16 temp_s1; + Vec3f spC8; + Vec3f spBC; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; -extern UNK_TYPE D_06009830; + for (i = 0, phi_s2 = 0; i < 25; i++, phi_s2 += 0x4E20) { + temp_f20 = (25 - i) * 2.4f; + temp_f22 = Math_SinS(phi_s2) * temp_f20; + temp_f24 = Math_CosS(phi_s2) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABBFC0.s") + spC8.x = this->dyna.actor.world.pos.x + temp_f22; + spC8.y = this->dyna.actor.world.pos.y; + spC8.z = this->dyna.actor.world.pos.z + temp_f24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABC2E0.s") + spBC.x = ((Rand_ZeroOne() - 0.5f) * 10.0f) + (temp_f22 * 0.13333334f); + spBC.y = (Rand_ZeroOne() * 17.0f) + 7.0f; + spBC.z = ((Rand_ZeroOne() - 0.5f) * 10.0f) + (temp_f24 * 0.13333334f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABC58C.s") + temp_s1 = (Rand_Next() & 3) + (i >> 2) + 4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABC7FC.s") + if ((Rand_Next() % 4) == 0) { + phi_v0 = 32; + } else { + phi_v0 = 64; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/BgHakuginBombwall_Init.s") + if (temp_s1 >= 8) { + phi_v0 |= 1; + phi_v1 = 1; + phi_t0 = -550; + } else { + phi_v1 = 0; + phi_t0 = -400; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/BgHakuginBombwall_Destroy.s") + EffectSsKakera_Spawn(globalCtx, &spC8, &spBC, &spC8, phi_t0, phi_v0, 30, 0, 0, temp_s1, phi_v1, 0, 50, -1, + OBJECT_HAKUGIN_OBJ, object_hakugin_obj_DL_009830); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCB5C.s") + if ((i & 1) == 0) { + func_800B0E48(globalCtx, &spC8, &D_80ABD034, &D_80ABCFB4, &D_80ABCFAC, &D_80ABCFB0, + ((u32)Rand_Next() >> 0x1B) + 60, ((u32)Rand_Next() >> 0x1A) + 50); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCC00.s") +void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f spD8; + Vec3f spCC; + Vec3f spC0; + Vec3f spB4; + Vec3f spA8; + Vec3f sp9C; + s32 i; + s16 phi_s1; + f32 temp_f20; + f32 temp_f22; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCCE4.s") + spA8.y = 0.0f; + spB4.y = 0.3f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCD98.s") + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCE60.s") + for (i = 0, phi_s1 = 0; i < 21; i++, phi_s1 += 0x618) { + temp_f20 = Math_SinS(phi_s1); + temp_f22 = Math_CosS(phi_s1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/BgHakuginBombwall_Update.s") + sp9C.x = (i - 10) * 9.0f; + sp9C.y = (Rand_ZeroOne() * 40.0f) + 15.0f; + sp9C.z = temp_f20 * 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/BgHakuginBombwall_Draw.s") + spA8.x = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (temp_f22 * -12.0f); + spA8.z = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (temp_f20 * 16.0f); + + spB4.x = spA8.x * -0.09f; + spB4.z = spA8.z * -0.09f; + + Matrix_MultiplyVector3fByState(&sp9C, &spC0); + Matrix_MultiplyVector3fByState(&spA8, &spCC); + Matrix_MultiplyVector3fByState(&spB4, &spD8); + + spC0.x += this->dyna.actor.world.pos.x; + spC0.y += this->dyna.actor.world.pos.y; + spC0.z += this->dyna.actor.world.pos.z; + + func_800B0E48(globalCtx, &spC0, &spCC, &spD8, &D_80ABCFAC, &D_80ABCFB0, ((u32)Rand_Next() >> 0x1A) + 60, + ((u32)Rand_Next() >> 0x1B) + 60); + } +} + +void func_80ABC7FC(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f spB8; + Vec3f spAC; + Vec3f spA0; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + s16 phi_s0; + s32 i; + + spAC.y = 0.0f; + spB8.y = 0.3f; + + for (i = 0, phi_s0 = 0; i < 20; i++, phi_s0 += 0xCCC) { + temp_f20 = Math_SinS(phi_s0); + temp_f22 = Math_CosS(phi_s0); + temp_f24 = Rand_ZeroOne() * 60.0f; + + spA0.x = (temp_f22 * temp_f24) + this->dyna.actor.world.pos.x; + spA0.y = (Rand_ZeroOne() * 20.0f) + this->dyna.actor.world.pos.y; + spA0.z = (temp_f20 * temp_f24) + this->dyna.actor.world.pos.z; + + spAC.x = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (temp_f20 * 15.0f); + spAC.z = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (temp_f22 * 15.0f); + + spB8.x = spAC.x * -0.095f; + spB8.z = spAC.z * -0.095f; + + func_800B0E48(globalCtx, &spA0, &spAC, &spB8, &D_80ABCFAC, &D_80ABCFB0, ((u32)Rand_Next() >> 0x1A) + 60, + ((u32)Rand_Next() >> 0x1B) + 60); + } +} + +void BgHakuginBombwall_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgHakuginBombwall* this = THIS; + BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + Collider_InitCylinder(globalCtx, &this->collider); + + if (Flags_GetSwitch(globalCtx, BGHAKUGIN_BOMBWALL_SWITCHFLAG(&this->dyna.actor))) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, ptr->unk_00); + + Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + this->collider.dim.radius = ptr->unk_14; + this->collider.dim.height = ptr->unk_16; + this->collider.info.bumper.dmgFlags = ptr->unk_18; + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + + Actor_SetFocus(&this->dyna.actor, ptr->unk_08); + this->dyna.actor.uncullZoneScale = ptr->unk_0C; + this->dyna.actor.uncullZoneDownward = ptr->unk_10; + this->actionFunc = func_80ABCCE4; +} + +void BgHakuginBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginBombwall* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +s32 func_80ABCB5C(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginBombwall* this = THIS; + s32 pad; + + if (this->collider.base.acFlags & AC_HIT) { + if (this->collider.base.ac != NULL) { + if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->collider.base.ac->world.pos) < + D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)].unk_1C) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 60, NA_SE_EV_WALL_BROKEN); + return true; + } + } + } + return false; +} + +s32 func_80ABCC00(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginBombwall* this = THIS; + s32 pad; + + if (this->collider.base.acFlags & AC_HIT) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 8) { + if (this->collider.base.ac != NULL) { + if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->collider.base.ac->world.pos) < + D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)].unk_1C) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 50, + NA_SE_EV_WALL_BROKEN); + return true; + } + } + } else if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + label:; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 50, NA_SE_EV_WALL_BROKEN); + return true; + } + } + return false; +} + +void func_80ABCCE4(BgHakuginBombwall* this, GlobalContext* globalCtx) { + BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; + + if (ptr->unk_20(&this->dyna.actor, globalCtx)) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->actionFunc = func_80ABCD98; + } else { + this->collider.base.acFlags &= ~AC_HIT; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80ABCD98(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 pad; + + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; + + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + ptr->unk_24(this, globalCtx); + this->dyna.actor.draw = NULL; + this->unk_1AC = 20; + Flags_SetSwitch(globalCtx, BGHAKUGIN_BOMBWALL_SWITCHFLAG(&this->dyna.actor)); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->actionFunc = func_80ABCE60; + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void func_80ABCE60(BgHakuginBombwall* this, GlobalContext* globalCtx) { + BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; + + this->unk_1AC--; + if (this->unk_1AC <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + } else if (this->unk_1AC == ptr->unk_2C) { + ptr->unk_28(this, globalCtx); + } +} + +void BgHakuginBombwall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginBombwall* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgHakuginBombwall_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(thisx)].unk_04); +} diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h index 8522fd15c..869741214 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h @@ -6,12 +6,17 @@ struct BgHakuginBombwall; typedef void (*BgHakuginBombwallActionFunc)(struct BgHakuginBombwall*, GlobalContext*); +typedef s32 (*BgHakuginBombwallUnkFunc)(Actor*, GlobalContext*); +typedef void (*BgHakuginBombwallUnkFunc2)(struct BgHakuginBombwall*, GlobalContext*); + +#define BGHAKUGIN_BOMBWALL_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define BGHAKUGIN_BOMBWALL_100(thisx) (((thisx)->params >> 8) & 1) typedef struct BgHakuginBombwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; - /* 0x01A8 */ BgHakuginBombwallActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ BgHakuginBombwallActionFunc actionFunc; + /* 0x1AC */ s32 unk_1AC; } BgHakuginBombwall; // size = 0x1B0 extern const ActorInit Bg_Hakugin_Bombwall_InitVars; From 36391bee469dcc0c5830ffc10b7021afbb0ff423 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 27 Mar 2022 14:44:55 +0100 Subject: [PATCH 125/257] En_Mk (#711) * En_Mk * PR --- spec | 3 +- src/overlays/actors/ovl_En_Mk/z_en_mk.c | 454 ++++++++++++++++++++++-- src/overlays/actors/ovl_En_Mk/z_en_mk.h | 10 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 5 - 5 files changed, 441 insertions(+), 35 deletions(-) diff --git a/spec b/spec index cb1adb6e4..46beb00b0 100644 --- a/spec +++ b/spec @@ -1625,8 +1625,7 @@ beginseg name "ovl_En_Mk" compress include "build/src/overlays/actors/ovl_En_Mk/z_en_mk.o" - include "build/data/ovl_En_Mk/ovl_En_Mk.data.o" - include "build/data/ovl_En_Mk/ovl_En_Mk.reloc.o" + include "build/src/overlays/actors/ovl_En_Mk/ovl_En_Mk_reloc.o" endseg beginseg 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 1cc0cffce..51d4243b3 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -15,6 +15,7 @@ void EnMk_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMk_Update(Actor* thisx, GlobalContext* globalCtx); void EnMk_Draw(Actor* thisx, GlobalContext* globalCtx); +s32 func_80959524(GlobalContext* globalCtx); void func_809596A0(EnMk* this, GlobalContext* globalCtx); void func_80959774(EnMk* this, GlobalContext* globalCtx); void func_80959A24(EnMk* this, GlobalContext* globalCtx); @@ -22,7 +23,6 @@ void func_80959C94(EnMk* this, GlobalContext* globalCtx); void func_80959D28(EnMk* this, GlobalContext* globalCtx); void func_80959E18(EnMk* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Mk_InitVars = { ACTOR_EN_MK, ACTORCAT_NPC, @@ -35,49 +35,453 @@ const ActorInit En_Mk_InitVars = { (ActorFunc)EnMk_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8095A260 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +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, + }; -extern ColliderCylinderInit D_8095A260; + if (index == this->unk_27C) { + return false; + } -extern UNK_TYPE D_06001C38; + if ((index < 0) || (index >= 5)) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_809592E0.s") + Animation_PlayLoop(&this->skelAnime, sAnimations[index]); + this->unk_27C = index; + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Init.s") +void EnMk_Init(Actor* thisx, GlobalContext* globalCtx) { + EnMk* this = THIS; + s16 cs; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Destroy.s") + this->actor.terminalVelocity = -4.0f; + this->actor.gravity = -1.0f; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_mk_Skel_006CA0, &object_mk_Anim_001C38, this->jointTable, + this->morphTable, OBJECT_MK_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959524.s") + this->unk_27C = -1; + func_809592E0(this, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_8095954C.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959624.s") + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_809596A0.s") + this->actionFunc = func_80959E18; + this->unk_27A = 0; + this->actor.targetMode = 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959774.s") + if (func_80959524(globalCtx) < 7) { + this->unk_27A |= 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959844.s") + cs = this->actor.cutscene; + for (i = 0; i < ARRAY_COUNT(this->unk_276); i++) { + this->unk_276[i] = cs; + if (cs != -1) { + this->actor.cutscene = cs; + cs = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959A24.s") + this->actor.cutscene = this->unk_276[0]; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959C94.s") +void EnMk_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMk* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959D28.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959E18.s") +s32 func_80959524(GlobalContext* globalCtx) { + return gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 7; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Update.s") +void func_8095954C(EnMk* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 0x7F)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 0x7F)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_8095A150.s") + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x7F)]->action) { + case 1: + case 2: + case 3: + case 4: + case 5: + func_809592E0(this, + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x7F)]->action - 1); + break; + } + } else { + func_809592E0(this, 0); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_8095A198.s") +void func_80959624(EnMk* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Draw.s") + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (this->unk_27A & 4) { + textId = 0xFB9; + } else if (gSaveContext.weekEventReg[55] & 0x80) { + textId = 0xFBC; + } else { + textId = 0xFBB; + } + } else { + textId = 0xFBA; + } + Message_StartTextbox(globalCtx, textId, &this->actor); +} + +void func_809596A0(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if ((globalCtx->msgCtx.unk11F04 == 0xFB9) || (globalCtx->msgCtx.unk11F04 == 0xFBB) || + (globalCtx->msgCtx.unk11F04 == 0xFBC)) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x400, 0x80); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 5: + if (func_80147624(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = func_80959774; + } + break; + + case 2: + this->actionFunc = func_80959774; + break; + } +} + +void func_80959774(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 3, 0x400, 0x80); + this->actor.world.rot.y = this->actor.shape.rot.y; + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80959624(this, globalCtx); + this->actionFunc = func_809596A0; + } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 130.0f); + } + + func_8095954C(this, globalCtx); +} + +void func_80959844(EnMk* this, GlobalContext* globalCtx) { + u16 textId; + + if ((this->unk_27A & 2) && (func_80959524(globalCtx) >= 7)) { + textId = 0xFB3; + } else if (gSaveContext.weekEventReg[20] & 0x40) { + textId = 0xFB9; + } else if (gSaveContext.weekEventReg[19] & 0x40) { + textId = 0xFB5; + } else if (func_80959524(globalCtx) >= 7) { + textId = 0xFB3; + } else { + switch (gSaveContext.playerForm) { + case PLAYER_FORM_DEKU: + if (gSaveContext.weekEventReg[19] & 0x10) { + if (gSaveContext.weekEventReg[55] & 0x80) { + textId = 0xFAF; + } else { + textId = 0xFAE; + } + } else { + textId = 0xFAC; + } + break; + + case PLAYER_FORM_GORON: + if (gSaveContext.weekEventReg[19] & 8) { + if (gSaveContext.weekEventReg[55] & 0x80) { + textId = 0xFAB; + } else { + textId = 0xFAA; + } + } else { + textId = 0xFA8; + } + break; + + case PLAYER_FORM_FIERCE_DEITY: + case PLAYER_FORM_HUMAN: + if (func_80959524(globalCtx) > 0) { + textId = 0xFA7; + } else if (gSaveContext.weekEventReg[19] & 4) { + if (gSaveContext.weekEventReg[55] & 0x80) { + textId = 0xFBF; + } else { + textId = 0xFA6; + } + } else { + textId = 0xFA0; + } + break; + + default: + if (func_80959524(globalCtx) > 0) { + textId = 0xFB0; + } else if (gSaveContext.weekEventReg[19] & 0x20) { + textId = 0xFB2; + } else { + textId = 0xFB1; + } + break; + } + } + Message_StartTextbox(globalCtx, textId, &this->actor); +} + +void func_80959A24(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + this->unk_27A |= 1; + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 2: + break; + + case 5: + if (func_80147624(globalCtx)) { + switch (globalCtx->msgCtx.unk11F04) { + case 0xFA1: + case 0xFA3: + case 0xFA4: + case 0xFAA: + case 0xFAE: + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0xFA2: + if (gSaveContext.weekEventReg[55] & 0x80) { + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + } + func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + break; + + case 0xFA5: + case 0xFA6: + case 0xFA7: + case 0xFA9: + case 0xFAB: + case 0xFAD: + case 0xFAF: + case 0xFB0: + case 0xFB2: + case 0xFBD: + case 0xFBE: + case 0xFBF: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + + case 0xFA0: + gSaveContext.weekEventReg[19] |= 4; + func_80151938(globalCtx, 0xFA1); + break; + + case 0xFA8: + gSaveContext.weekEventReg[19] |= 8; + if (gSaveContext.weekEventReg[55] & 0x80) { + func_80151938(globalCtx, 0xFBD); + break; + } + func_80151938(globalCtx, 0xFA9); + break; + + case 0xFAC: + gSaveContext.weekEventReg[19] |= 0x10; + if (gSaveContext.weekEventReg[55] & 0x80) { + func_80151938(globalCtx, 0xFBE); + break; + } + func_80151938(globalCtx, 0xFAD); + break; + + case 0xFB1: + gSaveContext.weekEventReg[19] |= 0x20; + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + + case 0xFB3: + case 0xFB4: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + this->actor.flags &= ~ACTOR_FLAG_10000; + break; + + case 0xFB5: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + } + } + break; + } +} + +void func_80959C94(EnMk* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80959A24; + this->unk_27A &= ~2; + Message_StartTextbox(globalCtx, 0xFB3, &this->actor); + } else { + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, globalCtx, 350.0f, 1000.0f, -1); + } +} + +void func_80959D28(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if ((globalCtx->csCtx.state == 0) && (this->actor.cutscene == -1)) { + if (gSaveContext.weekEventReg[20] & 0x40) { + this->unk_27A &= ~1; + this->actionFunc = func_80959774; + this->actor.home.rot.y += 0x4E20; + this->unk_27A |= 4; + } else { + this->actionFunc = func_80959E18; + } + this->actor.cutscene = this->unk_276[0]; + } else { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actor.cutscene = -1; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + func_8095954C(this, globalCtx); + } +} + +void func_80959E18(EnMk* this, GlobalContext* globalCtx) { + s32 pad; + s16 sp22 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + + SkelAnime_Update(&this->skelAnime); + + if (gSaveContext.weekEventReg[20] & 0x40) { + this->unk_27A &= ~1; + this->actionFunc = func_80959774; + this->actor.home.rot.y += 0x4E20; + return; + } + + if (func_800B8718(&this->actor, &globalCtx->state)) { + globalCtx->msgCtx.ocarinaMode = 4; + this->actionFunc = func_80959D28; + if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + this->actor.cutscene = this->unk_276[0]; + gSaveContext.weekEventReg[20] |= 0x40; + Item_Give(globalCtx, ITEM_SONG_NOVA); + } else { + this->actor.cutscene = this->unk_276[1]; + } + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80959844(this, globalCtx); + this->actionFunc = func_80959A24; + this->unk_27A |= 1; + } else if ((this->unk_27A & 2) && (func_80959524(globalCtx) >= 7)) { + this->actionFunc = func_80959C94; + } else if ((this->actor.xzDistToPlayer < 120.0f) && (ABS_ALT(sp22) <= 0x4300)) { + this->unk_27A |= 1; + func_800B8614(&this->actor, globalCtx, 200.0f); + if (!(gSaveContext.weekEventReg[20] & 0x40) && (gSaveContext.weekEventReg[19] & 0x40)) { + func_800B874C(&this->actor, globalCtx, 200.0f, 100.0f); + } + } else { + this->unk_27A &= ~1; + } + func_8095954C(this, globalCtx); +} + +void EnMk_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnMk* this = THIS; + Vec3s sp38; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + this->actionFunc(this, globalCtx); + + if ((this->unk_27A & 1) && !Cutscene_CheckActorAction(globalCtx, 0x7F)) { + func_800E9250(globalCtx, &this->actor, &this->unk_270, &sp38, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_270.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_270.y, 0, 6, 0x1838, 0x64); + } +} + +s32 EnMk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnMk* this = THIS; + + if (limbIndex == OBJECT_MK_LIMB_0B) { + rot->y -= this->unk_270.y; + rot->z += this->unk_270.x; + } + return false; +} + +Vec3f D_8095A2A0 = { 1000.0f, -100.0f, 0.0f }; + +void EnMk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnMk* this = THIS; + + if (limbIndex == OBJECT_MK_LIMB_0B) { + Matrix_MultiplyVector3fByState(&D_8095A2A0, &this->actor.focus.pos); + } +} + +void EnMk_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMk* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnMk_OverrideLimbDraw, EnMk_PostLimbDraw, &this->actor); +} 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 715a07c84..fee132ccd 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.h +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.h @@ -2,6 +2,7 @@ #define Z_EN_MK_H #include "global.h" +#include "objects/object_mk/object_mk.h" struct EnMk; @@ -9,7 +10,14 @@ typedef void (*EnMkActionFunc)(struct EnMk*, GlobalContext*); typedef struct EnMk { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x13C]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; + /* 0x01D4 */ Vec3s jointTable[OBJECT_MK_LIMB_MAX]; + /* 0x0222 */ Vec3s morphTable[OBJECT_MK_LIMB_MAX]; + /* 0x0270 */ Vec3s unk_270; + /* 0x0276 */ s16 unk_276[2]; + /* 0x027A */ u16 unk_27A; + /* 0x027C */ s16 unk_27C; /* 0x0280 */ EnMkActionFunc actionFunc; } EnMk; // size = 0x284 diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index f3217aeac..83923c05b 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -7702,8 +7702,8 @@ 0x80959D28:("func_80959D28",), 0x80959E18:("func_80959E18",), 0x8095A028:("EnMk_Update",), - 0x8095A150:("func_8095A150",), - 0x8095A198:("func_8095A198",), + 0x8095A150:("EnMk_OverrideLimbDraw",), + 0x8095A198:("EnMk_PostLimbDraw",), 0x8095A1D8:("EnMk_Draw",), 0x8095A510:("func_8095A510",), 0x8095A560:("EnOwl_Init",), diff --git a/undefined_syms.txt b/undefined_syms.txt index ff84de04f..717a26c8c 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1496,11 +1496,6 @@ D_06011E48 = 0x06011E48; D_06002EC0 = 0x06002EC0; -// ovl_En_Mk - -D_06001C38 = 0x06001C38; -D_06006CA0 = 0x06006CA0; - // ovl_En_Mnk D_06003584 = 0x06003584; From c0979dcb0769dc4bcb14d726e90c3a285746612d Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 27 Mar 2022 14:51:15 +0100 Subject: [PATCH 126/257] Obj_Vspinyroll (1 non-matching) (#712) * Obj_Vspinyroll * PR --- spec | 5 +- .../ovl_Obj_Vspinyroll/z_obj_vspinyroll.c | 423 ++++++++++++++++-- .../ovl_Obj_Vspinyroll/z_obj_vspinyroll.h | 31 +- undefined_syms.txt | 5 - 4 files changed, 417 insertions(+), 47 deletions(-) diff --git a/spec b/spec index 46beb00b0..5b7d8bfa9 100644 --- a/spec +++ b/spec @@ -2795,8 +2795,11 @@ beginseg name "ovl_Obj_Vspinyroll" compress include "build/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.o" - include "build/data/ovl_Obj_Vspinyroll/ovl_Obj_Vspinyroll.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Vspinyroll/ovl_Obj_Vspinyroll_reloc.o" +#else include "build/data/ovl_Obj_Vspinyroll/ovl_Obj_Vspinyroll.reloc.o" +#endif endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c index 10d87e6bc..9c5d22bac 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c @@ -5,6 +5,7 @@ */ #include "z_obj_vspinyroll.h" +#include "objects/object_spinyroll/object_spinyroll.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,13 +16,17 @@ void ObjVspinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjVspinyroll_Update(Actor* thisx, GlobalContext* globalCtx); void ObjVspinyroll_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A3CEC4(ObjVspinyroll* this); void func_80A3CEE0(ObjVspinyroll* this, GlobalContext* globalCtx); void func_80A3CF4C(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3CFAC(ObjVspinyroll* this); void func_80A3CFE0(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3D024(ObjVspinyroll* this); void func_80A3D038(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3D0E8(ObjVspinyroll* this); void func_80A3D0FC(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3D2C0(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Vspinyroll_InitVars = { ACTOR_OBJ_VSPINYROLL, ACTORCAT_PROP, @@ -34,77 +39,419 @@ const ActorInit Obj_Vspinyroll_InitVars = { (ActorFunc)ObjVspinyroll_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A3D488 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +f32 D_80A3D450[] = { 1.0f, 2.0f }; + +f32 D_80A3D458[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; + +s16 D_80A3D478[] = { 1, 10, 20, 30, 40, 50, 60, 70 }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 30, 120, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A3D4D4[] = { +f32 D_80A3D4B4[] = { 1.0f, 1.0f, -1.0f, -1.0f }; + +f32 D_80A3D4C4[] = { 29.0f, -29.0f, 29.0f, -29.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_STOP), }; +s16 D_80A3D4DC[] = { 0xFA0, -0xFA0 }; + +void func_80A3C4E0(Vec3f* arg0, Vec3f* arg1, s16 arg2) { + f32 sp1C = Math_SinS(arg2); + f32 temp_f0 = Math_CosS(arg2); + + arg0->x = (arg1->z * sp1C) + (arg1->x * temp_f0); + arg0->y = arg1->y; + arg0->z = (arg1->z * temp_f0) - (arg1->x * sp1C); +} + +void func_80A3C560(ObjVspinyroll* this) { + f32 magnitude; + Vec3f* sp20 = &this->unk_39C[this->unk_398 ^ 1]; + + Math_Vec3f_Diff(sp20, &this->dyna.actor.world.pos, &this->unk_3B4); + magnitude = Math3D_Vec3fMagnitude(&this->unk_3B4); + if (magnitude < 0.01f) { + Math_Vec3f_Diff(sp20, &this->unk_39C[this->unk_398], &this->unk_3B4); + magnitude = Math3D_Vec3fMagnitude(&this->unk_3B4); + if (magnitude < 0.01f) { + Math_Vec3f_Copy(&this->unk_3B4, &gZeroVec3f); + return; + } + } + Math_Vec3f_Scale(&this->unk_3B4, 1.0f / magnitude); +} + +void func_80A3C658(ObjVspinyroll* this) { + this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &this->unk_39C[this->unk_398 ^ 1]); +} + +void func_80A3C6A0(ObjVspinyroll* this) { + this->unk_398 = 0; + func_80A3C658(this); + func_80A3C560(this); +} + +void func_80A3C6CC(ObjVspinyroll* this) { + this->unk_398 ^= 1; + func_80A3C658(this); + func_80A3C560(this); +} + +s32 func_80A3C700(ObjVspinyroll* this) { + s32 pad; + s32 sp30 = this->unk_398 ^ 1; + Vec3f sp24; + + Math_StepToF(&this->dyna.actor.speedXZ, this->unk_394, this->unk_394 * 0.2f); + + this->dyna.actor.world.pos.x += this->dyna.actor.speedXZ * this->unk_3B4.x; + this->dyna.actor.world.pos.y += this->dyna.actor.speedXZ * this->unk_3B4.y; + this->dyna.actor.world.pos.z += this->dyna.actor.speedXZ * this->unk_3B4.z; + + Math_Vec3f_Diff(&this->unk_39C[sp30], &this->dyna.actor.world.pos, &sp24); + return Math3D_LengthSquared(&sp24) < (SQ(this->dyna.actor.speedXZ) + 0.05f); +} + +void func_80A3C7E8(ObjVspinyroll* this) { + f32 phi_f2; + s32 i; + s32 j; + f32 tempf; + s32 index = D_80A3D450[OBJVSPINYROLL_GET_4000(&this->dyna.actor)] * 120.0f * (1.0f / 58.0f); + + index += 2; + this->unk_38C = index * 4; + + tempf = ((D_80A3D450[OBJVSPINYROLL_GET_4000(&this->dyna.actor)] * 120.0f) - 2.0f) / (index - 1); + phi_f2 = 1.0f; + + for (i = 0, j = 0; i < this->unk_38C; i++) { + this->unk_1A8[i].unk_00.x = D_80A3D4C4[j]; + this->unk_1A8[i].unk_00.y = phi_f2; + this->unk_1A8[i].unk_00.z = D_80A3D4B4[j]; + + j++; + if (j >= 4) { + j = 0; + phi_f2 += tempf; + } + } +} + +#ifdef NON_MATCHING +s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3) { + s32 pad; + ObjVspinyrollStruct2* ptr = &this->unk_1A8[0]; + s32 pad2; + s32 i; + Vec3f spE4; + Vec3f spD8; + Vec3f spCC; + Vec3f spC0; + Vec3f spB4; + Vec3f spA8; + f32 temp_f20 = FLT_MAX; + f32 temp_f0; + s32 sp9C; + + spE4.z = 0.0f; + sp9C = false; + this->unk_388 = NULL; + + for (i = 0; i < this->unk_38C; i++, ptr++) { + spE4.x = ptr->unk_00.x; + spE4.y = ptr->unk_00.y; + func_80A3C4E0(&spD8, &spE4, this->dyna.actor.world.rot.y); + + spD8.x += this->dyna.actor.world.pos.x; + spD8.y += this->dyna.actor.world.pos.y; + spD8.z += this->dyna.actor.world.pos.z; + + Math_Vec3f_Copy(&spCC, &spD8); + + spCC.x += 30.0f * this->unk_3B4.x; + spCC.z += 30.0f * this->unk_3B4.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spD8, &spCC, &spC0, &this->unk_1A8[i].collisionPoly, true, + false, false, true, &this->unk_1A8[i].bgId, &this->dyna.actor, 0.0f)) { + if ((arg3 != 0) && (this->dyna.actor.flags & ACTOR_FLAG_40)) { + spA8.x = ptr->unk_00.x * 0.2f; + spA8.y = ptr->unk_00.y; + spA8.z = 20.0f; + + func_80A3C4E0(&spB4, &spA8, this->dyna.actor.world.rot.y); + + spB4.x += this->dyna.actor.world.pos.x; + spB4.y += this->dyna.actor.world.pos.y; + spB4.z += this->dyna.actor.world.pos.z; + + EffectSsHitMark_SpawnFixedScale(globalCtx, 3, &spB4); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_SHIELD_REFLECT_SW); + } + + temp_f0 = Math3D_Vec3fDistSq(&spD8, &spC0); + if (temp_f0 < temp_f20) { + temp_f20 = temp_f0; + sp9C = true; + Math_Vec3f_Diff(&spC0, &spCC, arg2); + this->unk_388 = ptr; + } + } + } + + return sp9C; +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C8D8.s") #endif -extern ColliderCylinderInit D_80A3D488; -extern InitChainEntry D_80A3D4D4[]; +s32 func_80A3CB94(ObjVspinyroll* this, GlobalContext* globalCtx, s32 arg2) { + Vec3f sp1C; -extern UNK_TYPE D_06000460; -extern UNK_TYPE D_06000F80; + if (func_80A3C8D8(this, globalCtx, &sp1C, arg2)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C4E0.s") +DynaPolyActor* func_80A3CBF0(ObjVspinyroll* this, GlobalContext* globalCtx) { + if (this->unk_388 != NULL) { + return DynaPoly_GetActor(&globalCtx->colCtx, this->unk_388->bgId); + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C560.s") +s32 func_80A3CC30(ObjVspinyroll* this, GlobalContext* globalCtx) { + DynaPolyActor* actor = func_80A3CBF0(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C658.s") + if ((actor != NULL) && (Math3D_Vec3fDistSq(&actor->actor.world.pos, &actor->actor.prevPos) > 0.0001f)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C6A0.s") +void func_80A3CC84(f32 arg0) { + MtxF* matrix = Matrix_GetCurrentState(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C6CC.s") + matrix->wy += arg0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C700.s") +void ObjVspinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjVspinyroll* this = THIS; + s32 params = OBJVSPINYROLL_GET_4000(&this->dyna.actor); + f32 sp40 = D_80A3D450[params]; + s32 pad2; + Path* path; + Vec3s* points; + Vec3s* point1; + Vec3s* point2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C7E8.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C8D8.s") + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.scale.y = 0.1f * sp40; + this->dyna.actor.scale.z = 0.1f; + this->dyna.actor.uncullZoneScale = 300.0f * sp40; + this->dyna.actor.scale.x = 0.1f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CB94.s") + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spinyroll_Colheader_000F80); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CBF0.s") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CC30.s") + if (params == OBJVSPINYROLL_4000_1) { + this->dyna.actor.draw = func_80A3D2C0; + this->collider.dim.height = 240; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CC84.s") + if (OBJVSPINYROLL_GET_7F(&this->dyna.actor) == OBJVSPINYROLL_7F_7F) { + func_80A3CEC4(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/ObjVspinyroll_Init.s") + this->dyna.actor.world.rot.y = 0; + func_80A3C7E8(this); + this->unk_394 = D_80A3D458[OBJVSPINYROLL_GET_380(thisx)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/ObjVspinyroll_Destroy.s") + path = &globalCtx->setupPathList[OBJVSPINYROLL_GET_7F(&this->dyna.actor)]; + points = Lib_SegmentedToVirtual(path->points); + point1 = &points[0]; + point2 = &points[1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CEC4.s") + Math_Vec3s_ToVec3f(&this->unk_39C[0], point1); + Math_Vec3s_ToVec3f(&this->unk_39C[1], point2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CEE0.s") + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->unk_39C[0]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CF10.s") + func_80A3C6A0(this); + this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; + func_80A3CFAC(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CF4C.s") +void ObjVspinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjVspinyroll* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CFAC.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CFE0.s") +void func_80A3CEC4(ObjVspinyroll* this) { + this->dyna.actor.speedXZ = 0.0f; + this->actionFunc = func_80A3CEE0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D024.s") +void func_80A3CEE0(ObjVspinyroll* this, GlobalContext* globalCtx) { + this->unk_3C0 += 0x6E; + if (this->unk_3C0 > 0xFA0) { + this->unk_3C0 = 0xFA0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D038.s") +void func_80A3CF10(ObjVspinyroll* this) { + this->actionFunc = func_80A3CF4C; + this->unk_3C8 = D_80A3D478[OBJVSPINYROLL_GET_1C00(&this->dyna.actor)]; + this->dyna.actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D0E8.s") +void func_80A3CF4C(ObjVspinyroll* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->unk_3C0, 0, this->unk_3C4) && (this->unk_3C8 > 0)) { + this->unk_3C8--; + if (this->unk_3C8 <= 0) { + func_80A3CFAC(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D0FC.s") +void func_80A3CFAC(ObjVspinyroll* this) { + this->actionFunc = func_80A3CFE0; + this->unk_3C2 = D_80A3D4DC[this->unk_398]; + this->dyna.actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/ObjVspinyroll_Update.s") +void func_80A3CFE0(ObjVspinyroll* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->unk_3C0, this->unk_3C2, 0x6E)) { + func_80A3D024(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/ObjVspinyroll_Draw.s") +void func_80A3D024(ObjVspinyroll* this) { + this->actionFunc = func_80A3D038; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D2C0.s") +void func_80A3D038(ObjVspinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = func_80A3C700(this); + + if (func_80A3CB94(this, globalCtx, 1)) { + this->unk_3C4 = 0x7D0; + if (func_80A3CBF0(this, globalCtx) != NULL) { + func_80A3D0E8(this); + } else { + func_80A3C6CC(this); + func_80A3CF10(this); + } + } else if (sp24 != 0) { + func_80A3C6CC(this); + this->unk_3C4 = 120; + func_80A3CF10(this); + } +} + +void func_80A3D0E8(ObjVspinyroll* this) { + this->actionFunc = func_80A3D0FC; +} + +void func_80A3D0FC(ObjVspinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = true; + + Math_ScaledStepToS(&this->unk_3C0, 0, this->unk_3C4); + if (func_80A3CB94(this, globalCtx, 0) && func_80A3CC30(this, globalCtx)) { + sp24 = false; + } + + if (sp24) { + func_80A3C6CC(this); + func_80A3CF10(this); + } +} + +void ObjVspinyroll_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjVspinyroll* this = THIS; + + this->actionFunc(this, globalCtx); + + this->unk_3C6 += this->unk_3C0; + + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjVspinyroll_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjVspinyroll* this = THIS; + + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, + this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z + 0x4000, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x + this->unk_3C6, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Gfx_DrawDListOpa(globalCtx, object_spinyroll_DL_000460); +} + +void func_80A3D2C0(Actor* thisx, GlobalContext* globalCtx) { + ObjVspinyroll* this = THIS; + Vec3s sp3C; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + sp3C.x = this->dyna.actor.shape.rot.x + this->unk_3C6; + sp3C.y = this->dyna.actor.shape.rot.y; + sp3C.z = this->dyna.actor.shape.rot.z + 0x4000; + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, + this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(sp3C.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(sp3C.z, MTXMODE_APPLY); + Matrix_InsertXRotation_s(sp3C.x, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_spinyroll_DL_000460); + + func_80A3CC84(120.0f); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_spinyroll_DL_000460); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h index 371eb7b4f..af1048267 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h @@ -7,11 +7,36 @@ struct ObjVspinyroll; typedef void (*ObjVspinyrollActionFunc)(struct ObjVspinyroll*, GlobalContext*); +#define OBJVSPINYROLL_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJVSPINYROLL_GET_380(thisx) (((thisx)->params >> 7) & 7) +#define OBJVSPINYROLL_GET_1C00(thisx) (((thisx)->params >> 0xA) & 7) +#define OBJVSPINYROLL_GET_4000(thisx) (((thisx)->params >> 0xE) & 1) + +#define OBJVSPINYROLL_7F_7F 0x7F +#define OBJVSPINYROLL_4000_1 1 + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ CollisionPoly* collisionPoly; + /* 0x10 */ s32 bgId; +} ObjVspinyrollStruct2; // size = 0x14 + typedef struct ObjVspinyroll { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x24C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderCylinder collider; + /* 0x01A8 */ ObjVspinyrollStruct2 unk_1A8[24]; + /* 0x0388 */ ObjVspinyrollStruct2* unk_388; + /* 0x038C */ s32 unk_38C; /* 0x0390 */ ObjVspinyrollActionFunc actionFunc; - /* 0x0394 */ char unk_394[0x38]; + /* 0x0394 */ f32 unk_394; + /* 0x0398 */ s32 unk_398; + /* 0x039C */ Vec3f unk_39C[2]; + /* 0x03B4 */ Vec3f unk_3B4; + /* 0x03C0 */ s16 unk_3C0; + /* 0x03C2 */ s16 unk_3C2; + /* 0x03C4 */ s16 unk_3C4; + /* 0x03C6 */ s16 unk_3C6; + /* 0x03C8 */ s16 unk_3C8; } ObjVspinyroll; // size = 0x3CC extern const ActorInit Obj_Vspinyroll_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 717a26c8c..a53d3388d 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1895,11 +1895,6 @@ D_06000098 = 0x06000098; D_06000838 = 0x06000838; D_060022AC = 0x060022AC; -// ovl_Obj_Vspinyroll - -D_06000460 = 0x06000460; -D_06000F80 = 0x06000F80; - // ovl_Obj_Y2lift D_06001680 = 0x06001680; From 061ebc3b123a94575f00eadf8729f87f70007c28 Mon Sep 17 00:00:00 2001 From: immibis Date: Sun, 27 Mar 2022 15:56:20 +0200 Subject: [PATCH 127/257] z_obj_chan OK (#591) * z_obj_chan OK * update Obj_Chan * Obj_Chan updates * Update for name changes. gameplay_keep object header is needed * format * more updates * more changes * Simplify floats Co-authored-by: angie --- spec | 4 +- src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c | 415 ++++++++++++++++-- src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h | 46 +- tools/disasm/functions.txt | 12 +- tools/disasm/variables.txt | 10 +- undefined_syms.txt | 7 - 6 files changed, 444 insertions(+), 50 deletions(-) diff --git a/spec b/spec index 5b7d8bfa9..9f79e7ac1 100644 --- a/spec +++ b/spec @@ -4528,9 +4528,7 @@ beginseg name "ovl_Obj_Chan" compress include "build/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.o" - include "build/data/ovl_Obj_Chan/ovl_Obj_Chan.data.o" - include "build/data/ovl_Obj_Chan/ovl_Obj_Chan.bss.o" - include "build/data/ovl_Obj_Chan/ovl_Obj_Chan.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Chan/ovl_Obj_Chan_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c index 465c660c6..16dd4943a 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -2,23 +2,32 @@ * File: z_obj_chan.c * Overlay: ovl_Obj_Chan * Description: Goron Shrine chandelier + * + * This actor class is used for both the chandelier and its sub-components. + * The distinction is made using the subtype actor parameter: + * - 0 for the chandelier itself + * - 1 for one of the 5 breakable pots that are attached to the chandelier */ #include "z_obj_chan.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_obj_chan/object_obj_chan.h" +#include "objects/object_tsubo/object_tsubo.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjChan*)thisx) +#define OBJCHAN_ROTATION_SPEED 364 // == (65536 * 2/360) i.e. 2 degrees per second + void ObjChan_Init(Actor* thisx, GlobalContext* globalCtx); void ObjChan_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjChan_Update(Actor* thisx, GlobalContext* globalCtx); void ObjChan_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BB9F24(ObjChan* this, GlobalContext* globalCtx); -void func_80BBA314(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_ChandelierAction(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Chan_InitVars = { ACTOR_OBJ_CHAN, ACTORCAT_BG, @@ -31,49 +40,399 @@ const ActorInit Obj_Chan_InitVars = { (ActorFunc)ObjChan_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BBAB30 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sObjChanCylinderInit = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 48, 76, -60, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BBAB5C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void ObjChan_InitChandelier(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_InitPot(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_CreateSmashParticles(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_DrawPot(Actor* thisx, GlobalContext* globalCtx); +void ObjChan_DrawFire(ObjChan* this, GlobalContext* globalCtx); -extern ColliderCylinderInit D_80BBAB30; -extern InitChainEntry D_80BBAB5C[]; +static Vec3f sObjChanFlameSize[2] = { + { 0.16f, 0.11f, 1.0f }, + { 0.13f, 0.09f, 1.0f }, +}; +static f32 sObjChanFlameYOffset[2] = { 1800, 1800 }; +static s32 sObjChanLoaded; -extern UNK_TYPE D_06000AF0; -extern UNK_TYPE D_06001960; -extern UNK_TYPE D_06002358; +void ObjChan_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjChan* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/ObjChan_Init.s") + if (OBJCHAN_SUBTYPE(&this->actor) == OBJCHAN_SUBTYPE_CHANDELIER) { + if (sObjChanLoaded) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.room = -1; + sObjChanLoaded = true; + } + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sObjChanCylinderInit); + SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + switch (OBJCHAN_SUBTYPE(&this->actor)) { + case OBJCHAN_SUBTYPE_CHANDELIER: + this->rotation = this->actor.shape.rot.y; + this->actor.shape.rot.y = 0; + ObjChan_InitChandelier(this, globalCtx); + break; + case OBJCHAN_SUBTYPE_POT: + this->actor.draw = ObjChan_DrawPot; + ObjChan_InitPot(this, globalCtx); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/ObjChan_Destroy.s") +void ObjChan_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjChan* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BB9A1C.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BB9B40.s") +u32 func_80BB9A1C(ObjChan* this, f32 arg1) { + f32 temp_f6; + f32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BB9C08.s") + sp20 = Math_SinS(this->unk1D4) * this->unk1D0; + temp_f6 = (Math_CosS(this->unk1D4) * 0.03834952f * this->unk1D0) + arg1; + if (temp_f6 != 0.0f) { + this->unk1D4 = RADF_TO_BINANG(func_80086B30(sp20 * 0.03834952f, temp_f6)); + } else if (sp20 >= 0.0f) { + this->unk1D4 = 0x4000; + } else { + this->unk1D4 = -0x4000; + } + if (Math_CosS(this->unk1D4) != 0.0f) { + this->unk1D0 = (temp_f6 / (Math_CosS(this->unk1D4) * 0.03834952f)); + } else { + this->unk1D0 = sp20; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BB9F24.s") +void ObjChan_CalculatePotPosition(Vec3f* childPosOut, Vec3s* childRotOut, Vec3f* parentPos, Vec3s* parentRot, + s16 childAngle) { + Vec3f offset; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA2FC.s") + Matrix_RotateY(parentRot->y, MTXMODE_NEW); + Matrix_InsertXRotation_s(parentRot->x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(parentRot->z, MTXMODE_APPLY); + Matrix_RotateY(childAngle, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledX(-280.0f, &offset); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA314.s") + childPosOut->x = parentPos->x + offset.x; + childPosOut->y = parentPos->y + offset.y; + childPosOut->z = parentPos->z + offset.z; + Math_Vec3s_Copy(childRotOut, parentRot); + childRotOut->y += childAngle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA488.s") +void ObjChan_InitChandelier(ObjChan* this, GlobalContext* globalCtx) { + s32 j; + s32 i; + ObjChan* temp_v0; + Vec3f childPos; + Vec3s childRot; + CollisionPoly* sp94; + s32 sp90; + Vec3f sp84; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/ObjChan_Update.s") + Math_Vec3f_Copy(&this->unk1C0, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/ObjChan_Draw.s") + Math_Vec3f_Copy(&sp84, &this->actor.world.pos); + sp84.y += 1600.0f; + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp84, &this->unk1C0, &sp94, false, false, + true, true, &sp90)) { + this->unk1CC = this->actor.world.pos.y - this->unk1C0.y; + } else { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA894.s") + for (i = 0; i < 5; i++) { + temp_v0 = (ObjChan*)&globalCtx->actorCtx; // strange cast needed for matching + ObjChan_CalculatePotPosition(&childPos, &childRot, &this->actor.world.pos, &this->actor.shape.rot, + (s32)(i * 360.0f / 5.0f * (65536.0f / 360.0f)) + this->rotation); + temp_v0 = (ObjChan*)Actor_SpawnAsChildAndCutscene((ActorContext*)temp_v0, globalCtx, ACTOR_OBJ_CHAN, childPos.x, + childPos.y, childPos.z, childRot.x, childRot.y, childRot.z, + (this->actor.params & 0xFFF) | 0x1000, this->actor.cutscene, + this->actor.unk20, &this->actor); + if (temp_v0 != NULL) { + this->pots[i] = temp_v0; + temp_v0->myPotIndex = i; + temp_v0->actor.cutscene = this->actor.cutscene; + } else { + Actor_MarkForDeath(&this->actor); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA930.s") + if (Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { + this->stateFlags |= OBJCHAN_STATE_FIRE_DELAY; + this->stateFlags |= OBJCHAN_STATE_ON_FIRE; + + this->rotationSpeed = OBJCHAN_ROTATION_SPEED; + this->flameSize = 1.0f; + + for (i = 0; i < 5; i++) { + if (this->pots[i] != NULL) { + this->pots[i]->stateFlags |= OBJCHAN_STATE_FIRE_DELAY; + this->pots[i]->stateFlags |= OBJCHAN_STATE_ON_FIRE; + this->pots[i]->flameSize = 1.0f; + } + } + } + this->collider.dim.radius = 45; + this->collider.dim.height = 60; + this->collider.dim.yShift = -20; + this->actionFunc = ObjChan_ChandelierAction; +} + +void ObjChan_ChandelierAction(ObjChan* thisx, GlobalContext* globalCtx) { + ObjChan* this = thisx; + ObjChan* temp; + s32 i; + Vec3f sp60; + Vec3s sp58; + + if (this->unk1D0 > 0.0f) { + this->unk1D4 += 0x190; + if (this->unk1D0 <= 400.0f) { + this->unk1D0 = this->unk1D0 * 0.99f; + } else { + this->unk1D0 = this->unk1D0 - 1.0f; + } + if (this->unk1D0 < 0.0f) { + this->unk1D4 = 0; + this->unk1D0 = 0.0f; + } + } + this->actor.shape.rot.z = (Math_SinS(this->unk1D4) * this->unk1D0); + if ((this->stateFlags & OBJCHAN_STATE_START_CUTSCENE) && + SubS_StartActorCutscene(&this->actor, this->cutscenes[0], -1, 0)) { + this->stateFlags |= OBJCHAN_STATE_CUTSCENE; + this->stateFlags &= ~OBJCHAN_STATE_START_CUTSCENE; + } + if ((this->stateFlags & OBJCHAN_STATE_CUTSCENE) && this->rotationSpeed == OBJCHAN_ROTATION_SPEED) { + this->stateFlags &= ~OBJCHAN_STATE_CUTSCENE; + ActorCutscene_Stop(this->cutscenes[0]); + } + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateY(this->rotation, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledY(this->unk1CC, &this->actor.world.pos); + Math_Vec3f_Sum(&this->actor.world.pos, &this->unk1C0, &this->actor.world.pos); + Collider_UpdateCylinder(&this->actor, &this->collider); + for (i = 0; i < 5; i++) { + temp = this->pots[i]; + if (temp != NULL) { + ObjChan_CalculatePotPosition(&sp60, &sp58, &this->actor.world.pos, &this->actor.shape.rot, + (s32)(i * 360.0f / 5.0f * (65536.0f / 360.0f)) + this->rotation); + Math_Vec3f_Copy(&temp->actor.world.pos, &sp60); + Math_Vec3s_Copy(&temp->actor.shape.rot, &this->actor.shape.rot); + temp->actor.shape.rot.y = this->rotation; + Math_Vec3f_ToVec3s(&temp->collider.dim.pos, &temp->actor.world.pos); + } + } + if ((this->collider.base.acFlags & AC_HIT) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x800)) { + Flags_SetSwitch(globalCtx, this->actor.params & 0x7F); + } + if (Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { + if (!(this->stateFlags & OBJCHAN_STATE_FIRE_DELAY)) { + this->rotationSpeed = 0; + this->flameSize = 0.0f; + for (i = 0; i < 5; i++) { + temp = this->pots[i]; + if (temp != NULL) { + this->pots[i]->stateFlags |= OBJCHAN_STATE_FIRE_DELAY; + this->pots[i]->fireDelayFrames = 20 + i * 5; + this->pots[i]->flameSize = 0.0f; + } + } + this->stateFlags |= OBJCHAN_STATE_FIRE_DELAY; + this->stateFlags |= OBJCHAN_STATE_ON_FIRE; + this->stateFlags |= OBJCHAN_STATE_START_CUTSCENE; + } else { + Math_StepToF(&this->flameSize, 1.0f, 0.05f); + this->rotation += this->rotationSpeed; + Math_StepToS(&this->rotationSpeed, OBJCHAN_ROTATION_SPEED, 5); + func_800B9010(&this->actor, NA_SE_EV_CHANDELIER_ROLL - SFX_FLAG); + } + } +} + +void ObjChan_InitPot(ObjChan* this, GlobalContext* globalCtx) { + this->actionFunc = ObjChan_PotAction; +} + +void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx) { + s32 potBreaks; + s16 temp_v0_2; + s32 phi_v1; + + potBreaks = false; + if ((this->collider.base.acFlags & AC_HIT) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x4004000)) { + potBreaks = true; + } + if (this->stateFlags & OBJCHAN_STATE_ON_FIRE) { + Math_StepToF(&this->flameSize, 1.0f, 0.05f); + } else if (this->stateFlags & OBJCHAN_STATE_FIRE_DELAY) { + this->fireDelayFrames--; + if (this->fireDelayFrames <= 0) { + this->stateFlags |= OBJCHAN_STATE_ON_FIRE; + } + } + if (potBreaks) { + ObjChan_CreateSmashParticles(this, globalCtx); + ((ObjChan*)this->actor.parent)->pots[this->myPotIndex] = NULL; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_CHANDELIER_BROKEN); + func_80BB9A1C((ObjChan*)this->actor.parent, 40.0f); + if (this->myPotIndex == 4) { + temp_v0_2 = gSaveContext.weekEventReg[0x25]; + if (!(temp_v0_2 & 0x10)) { + gSaveContext.weekEventReg[0x25] = temp_v0_2 | 0x10; + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x8000, + this->actor.cutscene, this->actor.unk20, NULL); + } + } + Actor_MarkForDeath(&this->actor); + } +} + +void ObjChan_CreateSmashParticles(ObjChan* this, GlobalContext* globalCtx) { + s16 new_var = 0; + s32 phi_s0; + Vec3f spDC; + Vec3f spD0; + f32 temp_f0; + f32 new_var2; + s16 temp_s1 = 0; + s32 temp_s2; + f32 spAC; + f32 spA8 = new_var + 15.0f; + f32 spA4 = new_var + (spAC = 110.0f); + + for (temp_s2 = 0, temp_s1 = 0; temp_s2 != 18; temp_s2++, temp_s1 += 0x4E20) { + f32 sin = Math_SinS(temp_s1); + f32 cos = Math_CosS(temp_s1); + spDC.x = sin * 8.0f; + spDC.y = Rand_ZeroOne() * 12.0f + 2.0f; + spDC.z = cos * 8.0f; + spD0.x = spDC.x * 0.23f; + spD0.y = Rand_ZeroOne() * 5.0f + 2.5f; + spD0.z = spDC.z * 0.23f; + temp_f0 = Rand_ZeroOne(); + if (temp_f0 < 0.2f) { + phi_s0 = 0x60; + } else if (temp_f0 < 0.6f) { + phi_s0 = 0x40; + } else { + phi_s0 = 0x20; + } + new_var2 = spA4 * Rand_ZeroOne(); + EffectSsKakera_Spawn(globalCtx, &spDC, &spD0, &this->actor.world.pos, -260, phi_s0, 20, 0, 0, spA8 + new_var2, + 0, 0, 50, -1, OBJECT_TSUBO, object_tsubo_DL_001960); + } + func_800BBFB0(globalCtx, &this->actor.world.pos, 30.0f, 2, 20, 50, true); + func_800BBFB0(globalCtx, &this->actor.world.pos, 30.0f, 2, 10, 80, true); +} + +void ObjChan_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjChan* this = THIS; + + this->actionFunc(this, globalCtx); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjChan_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjChan* this = THIS; + Gfx* opa; + Gfx* xlu; + + OPEN_DISPS(globalCtx->state.gfxCtx); + Matrix_RotateY(this->rotation, MTXMODE_APPLY); + + opa = Gfx_CallSetupDL(POLY_OPA_DISP, 0x19); + gSPMatrix(&opa[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPDisplayList(&opa[1], object_obj_chan_DL_000AF0); + POLY_OPA_DISP = &opa[2]; + + xlu = func_8012C2B4(POLY_XLU_DISP); + gSPMatrix(&xlu[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPDisplayList(&xlu[1], object_obj_chan_DL_000A10); + POLY_XLU_DISP = &xlu[2]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + if (this->stateFlags & OBJCHAN_STATE_ON_FIRE) { + ObjChan_DrawFire(this, globalCtx); + } + Matrix_StatePop(); +} + +void ObjChan_DrawPot(Actor* thisx, GlobalContext* globalCtx) { + ObjChan* this = THIS; + s32 pad; + Gfx* dl; + + OPEN_DISPS(globalCtx->state.gfxCtx); + dl = Gfx_CallSetupDL(POLY_OPA_DISP, 0x19); + gSPMatrix(&dl[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPDisplayList(&dl[1], object_obj_chan_DL_002358); + POLY_OPA_DISP = &dl[2]; + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (this->stateFlags & OBJCHAN_STATE_ON_FIRE) { + ObjChan_DrawFire(this, globalCtx); + } +} + +void ObjChan_DrawFire(ObjChan* this, GlobalContext* globalCtx) { + u32 sp4C; + Gfx* dl; + OPEN_DISPS(globalCtx->state.gfxCtx); + + sp4C = globalCtx->gameplayFrames; + + Matrix_RotateY(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y - this->rotation + 0x8000, + MTXMODE_APPLY); + Matrix_Scale(sObjChanFlameSize[OBJCHAN_SUBTYPE(&this->actor)].x * this->flameSize, + sObjChanFlameSize[OBJCHAN_SUBTYPE(&this->actor)].y * this->flameSize, 1.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, sObjChanFlameYOffset[OBJCHAN_SUBTYPE(&this->actor)], 0.0f, MTXMODE_APPLY); + + dl = func_8012C2B4(POLY_XLU_DISP); + gSPMatrix(&dl[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gMoveWd(&dl[1], 6, 32, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0U, -sp4C * 20, 32, 128)); + gDPSetPrimColor(&dl[2], 128, 128, 255, 255, 0, 255); + gDPSetEnvColor(&dl[3], 255, 0, 0, 0); + gSPDisplayList(&dl[4], &gGameplayKeepDrawFlameDL); + POLY_XLU_DISP = &dl[5]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h index 8b498f39e..2b11335b3 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h @@ -5,12 +5,56 @@ struct ObjChan; +#define OBJCHAN_SUBTYPE(thisx) (((thisx)->params >> 12) & 0xF) +#define OBJCHAN_SUBTYPE_CHANDELIER 0 +#define OBJCHAN_SUBTYPE_POT 1 + +/*** stateFlags ***/ +/* + * After the chandelier is hit by a fire attack, each pot gets OBJCHAN_STATE_FIRE_DELAY state and counts down a number of frames until it catches fire. + * The delay is different for each pot. Remaining frame count is stored in fireDelayFrames. + * The main actor also gets this flag but it's always equivalent to OBJCHAN_STATE_ON_FIRE. + */ +#define OBJCHAN_STATE_FIRE_DELAY (1 << 0) +/** + * Pot is now on fire. After this state is set the flame grows to full size over 20 frames. Flame size is stored in flameSize. + * OBJCHAN_STATE_FIRE_DELAY is not cleared when this flag is set. + * The main actor also gets this flag. + */ +#define OBJCHAN_STATE_ON_FIRE (1 << 1) // Pot has fire. Flame grows to full size over about 1 second. Flame size is stored in fireSize. +/** + * Only for the main actor. + * Once set, the actor tries to start a cutscene. + * Once cutscene is started, this flag is unset and OBJCHAN_STATE_MAIN_STOP_CUTSCENE_AT_FULL_SPEED is set. + */ +#define OBJCHAN_STATE_START_CUTSCENE (1 << 2) +/** + * Only for the main actor. + * Cutscene is running. Once set, the actor waits for full rotation speed and then cancels the cutscene. + */ +#define OBJCHAN_STATE_CUTSCENE (1 << 3) + + + typedef void (*ObjChanActionFunc)(struct ObjChan*, GlobalContext*); typedef struct ObjChan { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjChanActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x9C]; + /* 0x0148 */ ColliderCylinder collider; + /* 0x0194 */ u8 myPotIndex; // For OBJCHAN_SUBTYPE_POT: which pot is this? + /* 0x0196 */ s16 fireDelayFrames; + /* 0x0198 */ UNK_TYPE1 unk198[0x12]; + /* 0x01AA */ u8 stateFlags; + /* 0x01AC */ struct ObjChan* pots[5]; // For OBJCHAN_SUBTYPE_BODY: pointers to pot actors + /* 0x01C0 */ Vec3f unk1C0; + /* 0x01CC */ f32 unk1CC; + /* 0x01D0 */ f32 unk1D0; + /* 0x01D4 */ s16 unk1D4; + /* 0x01D8 */ f32 flameSize; + /* 0x01DC */ s16 rotationSpeed; // Main object only. Slowly ramps up under some circumstances. In other circumstances it's immediately set to maximum speed. + /* 0x01DE */ s16 rotation; // Increases as the chandelier spins. Don't know why they didn't use the actor's rotation variable. + /* 0x01E0 */ s16 cutscenes[2]; } ObjChan; // size = 0x1E4 extern const ActorInit Obj_Chan_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 83923c05b..b676feb1c 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -15375,15 +15375,15 @@ 0x80BB98E0:("ObjChan_Init",), 0x80BB99F0:("ObjChan_Destroy",), 0x80BB9A1C:("func_80BB9A1C",), - 0x80BB9B40:("func_80BB9B40",), - 0x80BB9C08:("func_80BB9C08",), - 0x80BB9F24:("func_80BB9F24",), - 0x80BBA2FC:("func_80BBA2FC",), - 0x80BBA314:("func_80BBA314",), + 0x80BB9B40:("ObjChan_CalculatePotPosition",), + 0x80BB9C08:("ObjChan_InitMain",), + 0x80BB9F24:("ObjChan_MainAction",), + 0x80BBA2FC:("ObjChan_InitPot",), + 0x80BBA314:("ObjChan_PotAction",), 0x80BBA488:("func_80BBA488",), 0x80BBA738:("ObjChan_Update",), 0x80BBA78C:("ObjChan_Draw",), - 0x80BBA894:("func_80BBA894",), + 0x80BBA894:("ObjChan_DrawPot",), 0x80BBA930:("func_80BBA930",), 0x80BBACA0:("EnZos_Init",), 0x80BBAE60:("EnZos_Destroy",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index d578b0544..f685ee576 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -15688,10 +15688,10 @@ 0x80BB97D0:("D_80BB97D0","f32","",0x4), 0x80BB97D4:("D_80BB97D4","f32","",0x4), 0x80BBAB10:("Obj_Chan_InitVars","UNK_TYPE1","",0x1), - 0x80BBAB30:("D_80BBAB30","UNK_TYPE1","",0x1), - 0x80BBAB5C:("D_80BBAB5C","UNK_TYPE1","",0x1), - 0x80BBAB60:("D_80BBAB60","UNK_TYPE4","",0x4), - 0x80BBAB78:("D_80BBAB78","f32","",0x4), + 0x80BBAB30:("sObjChanCylinderInit","UNK_TYPE1","",0x1), + 0x80BBAB5C:("sObjChanInitChain","UNK_TYPE1","",0x1), + 0x80BBAB60:("sObjChanFlameSize","UNK_TYPE4","",0x4), + 0x80BBAB78:("sObjChanFlameYOffset","f32","",0x4), 0x80BBAB80:("D_80BBAB80","f32","",0x4), 0x80BBAB84:("D_80BBAB84","f32","",0x4), 0x80BBAB88:("D_80BBAB88","f32","",0x4), @@ -15702,7 +15702,7 @@ 0x80BBAB9C:("D_80BBAB9C","f32","",0x4), 0x80BBABA0:("D_80BBABA0","f32","",0x4), 0x80BBABA4:("D_80BBABA4","f32","",0x4), - 0x80BBAC90:("D_80BBAC90","UNK_TYPE1","",0x1), + 0x80BBAC90:("sObjChanLoaded","UNK_TYPE1","",0x1), 0x80BBC6D0:("En_Zos_InitVars","UNK_TYPE1","",0x1), 0x80BBC6F0:("D_80BBC6F0","UNK_TYPE1","",0x1), 0x80BBC71C:("D_80BBC71C","UNK_TYPE1","",0x1), diff --git a/undefined_syms.txt b/undefined_syms.txt index a53d3388d..5230f6e2a 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1781,13 +1781,6 @@ D_060014F0 = 0x060014F0; D_06007630 = 0x06007630; D_06009A88 = 0x06009A88; -// ovl_Obj_Chan - -D_06000A10 = 0x06000A10; -D_06000AF0 = 0x06000AF0; -D_06001960 = 0x06001960; -D_06002358 = 0x06002358; - // ovl_Obj_Chikuwa D_06000D10 = 0x06000D10; From 145b2f6a61892772aeb3536595b9cd6c1a7a9569 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 27 Mar 2022 15:01:23 +0100 Subject: [PATCH 128/257] En_Jgame_Tsn (#722) * En_Jgame_Tsn * Merge --- spec | 3 +- .../actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c | 621 ++++++++++++++++-- .../actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h | 27 +- .../ovl_Obj_Jgame_Light/z_obj_jgame_light.h | 2 + tools/disasm/functions.txt | 4 +- undefined_syms.txt | 5 - 6 files changed, 610 insertions(+), 52 deletions(-) diff --git a/spec b/spec index 9f79e7ac1..1b64e22c7 100644 --- a/spec +++ b/spec @@ -5139,8 +5139,7 @@ beginseg name "ovl_En_Jgame_Tsn" compress include "build/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.o" - include "build/data/ovl_En_Jgame_Tsn/ovl_En_Jgame_Tsn.data.o" - include "build/data/ovl_En_Jgame_Tsn/ovl_En_Jgame_Tsn.reloc.o" + include "build/src/overlays/actors/ovl_En_Jgame_Tsn/ovl_En_Jgame_Tsn_reloc.o" endseg beginseg 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 8218d7c63..88c552595 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 @@ -5,6 +5,7 @@ */ #include "z_en_jgame_tsn.h" +#include "overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) @@ -15,7 +16,26 @@ void EnJgameTsn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnJgameTsn_Update(Actor* thisx, GlobalContext* globalCtx); void EnJgameTsn_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80C13A2C(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C13B74(EnJgameTsn* this); +void func_80C13BB8(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C13E6C(EnJgameTsn* this); +void func_80C13E90(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C13F9C(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C14030(EnJgameTsn* this); +void func_80C14044(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C1418C(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C141DC(EnJgameTsn* this); +void func_80C14230(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C144F8(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C14554(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C145FC(EnJgameTsn* this); +void func_80C14610(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C14684(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C147B4(EnJgameTsn* this, GlobalContext* globalCtx); +s32 func_80C149B0(GlobalContext* globalCtx, EnJgameTsnStruct* arg1); +s32 func_80C14BCC(EnJgameTsn* this, GlobalContext* globalCtx); + const ActorInit En_Jgame_Tsn_InitVars = { ACTOR_EN_JGAME_TSN, ACTORCAT_NPC, @@ -28,81 +48,600 @@ const ActorInit En_Jgame_Tsn_InitVars = { (ActorFunc)EnJgameTsn_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C15078 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static AnimationInfo sAnimations[] = { + { &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 }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +TexturePtr D_80C150A4[] = { + object_tsn_Tex_0073B8, + object_tsn_Tex_0085B8, +}; -extern ColliderCylinderInit D_80C15078; +void EnJgameTsn_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnJgameTsn* this = THIS; -extern UNK_TYPE D_060092FC; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tsn_Skel_008AB8, &object_tsn_Anim_0092FC, this->jointTable, + this->morphTable, OBJECT_TSN_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/EnJgameTsn_Init.s") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13A2C.s") + this->actor.targetMode = 6; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.velocity.y = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/EnJgameTsn_Destroy.s") + if (gSaveContext.entranceIndex == 0x68D0) { + this->actor.flags |= ACTOR_FLAG_10000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13B74.s") + this->unk_2F8 = 0; + this->unk_2FA = 0; + this->unk_21C = 0; + this->unk_2FE = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13BB8.s") + func_80C13A2C(this, globalCtx); + func_80C13B74(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13E6C.s") +void func_80C13A2C(EnJgameTsn* this, GlobalContext* globalCtx) { + Path* path = &globalCtx->setupPathList[ENJGAMETSN_GET_FF(&this->actor)]; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13E90.s") + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13F88.s") + for (i = 0; i < ARRAY_COUNT(this->unk_1D8); i++) { + this->unk_1D8[i].points = Lib_SegmentedToVirtual(path->points); + this->unk_1D8[i].count = path->count; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13F9C.s") + path = &globalCtx->setupPathList[path->unk1]; + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14030.s") + this->unk_1F8.points = Lib_SegmentedToVirtual(path->points); + this->unk_1F8.count = path->count; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14044.s") + path = &globalCtx->setupPathList[path->unk1]; + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C1410C.s") + this->unk_200.points = Lib_SegmentedToVirtual(path->points); + this->unk_200.count = path->count; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C1418C.s") +void EnJgameTsn_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnJgameTsn* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C141DC.s") + Collider_DestroyCylinder(globalCtx, &this->collider); + gSaveContext.weekEventReg[90] &= (u8)~0x20; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14230.s") +void func_80C13B74(EnJgameTsn* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actionFunc = func_80C13BB8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C144E4.s") +void func_80C13BB8(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C144F8.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (this->actor.flags & ACTOR_FLAG_10000) { + this->actor.flags &= ~ACTOR_FLAG_10000; + if (gSaveContext.unk_3DE0[4] > 0) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x10A2, &this->actor); + this->unk_300 = 0x10A2; + } else if (gSaveContext.minigameScore < 20) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x10A2, &this->actor); + this->unk_300 = 0x10A2; + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x10A3, &this->actor); + this->unk_300 = 0x10A3; + } + } else if (((gSaveContext.time > CLOCK_TIME(4, 0)) && (gSaveContext.time < CLOCK_TIME(7, 0))) || + ((gSaveContext.time > CLOCK_TIME(16, 0)) && (gSaveContext.time < CLOCK_TIME(19, 0)))) { + Message_StartTextbox(globalCtx, 0x1094, &this->actor); + this->unk_300 = 0x1094; + } else if (this->unk_2F8 == 0) { + this->unk_2F8 = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x1095, &this->actor); + this->unk_300 = 0x1095; + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x1096, &this->actor); + this->unk_300 = 0x1096; + } + func_80C14030(this); + } else if (this->actor.flags & ACTOR_FLAG_10000) { + func_800B8614(&this->actor, globalCtx, 200.0f); + } else { + func_800B8614(&this->actor, globalCtx, 80.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14540.s") + if ((player->actor.bgCheckFlags & 1) && !(player->stateFlags1 & 0x2000) && (this->unk_2FE == 0) && + (gSaveContext.playerForm == PLAYER_FORM_HUMAN) && func_80C149B0(globalCtx, &this->unk_1F8)) { + this->unk_2FE = 1; + func_80C13E6C(this); + } else if (!(player->actor.bgCheckFlags & 1)) { + this->unk_2FE = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14554.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 5, 0x71C, 0xB6); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C145FC.s") +void func_80C13E6C(EnJgameTsn* this) { + this->actor.flags |= ACTOR_FLAG_10000; + this->actionFunc = func_80C13E90; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14610.s") +void func_80C13E90(EnJgameTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + if (((gSaveContext.time > CLOCK_TIME(4, 0)) && (gSaveContext.time < CLOCK_TIME(7, 0))) || + ((gSaveContext.time > CLOCK_TIME(16, 0)) && (gSaveContext.time < CLOCK_TIME(19, 0)))) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x1094, &this->actor); + this->unk_300 = 0x1094; + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x1098, &this->actor); + this->unk_300 = 0x1098; + } + func_80C14030(this); + } else { + func_800B8614(&this->actor, globalCtx, 1000.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14684.s") +void func_80C13F88(EnJgameTsn* this) { + this->actionFunc = func_80C13F9C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C1476C.s") +void func_80C13F9C(EnJgameTsn* this, GlobalContext* globalCtx) { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + func_80C14030(this); + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } else { + func_80C14030(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C147B4.s") +void func_80C14030(EnJgameTsn* this) { + this->actionFunc = func_80C14044; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14960.s") +void func_80C14044(EnJgameTsn* this, GlobalContext* globalCtx) { + switch (Message_GetState(&globalCtx->msgCtx)) { + case 0: + case 1: + case 2: + case 3: + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C149B0.s") + case 4: + func_80C14684(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14BCC.s") + case 5: + func_80C147B4(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14D14.s") + case 6: + if (func_80147624(globalCtx)) { + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + func_80C13B74(this); + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14D58.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x71C, 0xB6); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/EnJgameTsn_Update.s") +void func_80C1410C(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14E64.s") + player->stateFlags1 |= 0x20; + func_801A2BB8(0x25); + globalCtx->interfaceCtx.unk_280 = 1; + func_80112AFC(globalCtx); + gSaveContext.weekEventReg[90] |= 0x20; + func_8010E9F0(4, 0x78); + this->actionFunc = func_80C1418C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14EE4.s") +void func_80C1418C(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/EnJgameTsn_Draw.s") + if (globalCtx->interfaceCtx.unk_280 == 8) { + func_80C141DC(this); + player->stateFlags1 &= ~0x20; + } +} + +void func_80C141DC(EnJgameTsn* this) { + this->unk_218 = Rand_Next() & 3; + this->unk_2FC = 0; + *this->unk_208[this->unk_218] |= 1; + this->actionFunc = func_80C14230; +} + +void func_80C14230(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + s32 rand; + + if ((this->unk_2FC > 100) || func_80C14BCC(this, globalCtx)) { + rand = (u32)Rand_Next() % 3; + + this->unk_2FC = 0; + if (rand < this->unk_218) { + this->unk_218 = rand; + } else { + this->unk_218 = rand + 1; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_208); i++) { + if (i == this->unk_218) { + *this->unk_208[i] |= 1; + *this->unk_208[i] &= ~8; + } else { + *this->unk_208[i] |= 8; + } + } + } + + this->unk_2FC++; + + if ((player->actor.bgCheckFlags & 2) && func_80C149B0(globalCtx, &this->unk_200)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x109F, &this->actor); + this->unk_300 = 0x109F; + player->stateFlags1 |= 0x20; + *this->unk_208[this->unk_218] &= ~1; + func_801A2C20(); + func_80C14030(this); + } else if ((player->actor.bgCheckFlags & 0x40) || (player->actor.bgCheckFlags & 0x20)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x10A0, &this->actor); + this->unk_300 = 0x10A0; + player->stateFlags1 |= 0x20; + *this->unk_208[this->unk_218] &= ~1; + func_801A2C20(); + func_80C14030(this); + } + + if (gSaveContext.unk_3DE0[4] == 0) { + Message_StartTextbox(globalCtx, 0x10A1, &this->actor); + this->unk_300 = 0x10A1; + player->stateFlags1 |= 0x20; + *this->unk_208[this->unk_218] &= ~1; + func_801A2C20(); + func_80C14030(this); + } +} + +void func_80C144E4(EnJgameTsn* this) { + this->actionFunc = func_80C144F8; +} + +void func_80C144F8(EnJgameTsn* this, GlobalContext* globalCtx) { + globalCtx->nextEntranceIndex = 0x68D0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 0x50; + gSaveContext.nextTransition = 3; +} + +void func_80C14540(EnJgameTsn* this) { + this->actionFunc = func_80C14554; +} + +void func_80C14554(EnJgameTsn* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + if (!(gSaveContext.weekEventReg[82] & 0x10)) { + gSaveContext.weekEventReg[82] |= 0x10; + } + func_80C145FC(this); + } else if (gSaveContext.weekEventReg[82] & 0x10) { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + } +} + +void func_80C145FC(EnJgameTsn* this) { + this->actionFunc = func_80C14610; +} + +void func_80C14610(EnJgameTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + Message_StartTextbox(globalCtx, 0x10A4, &this->actor); + this->unk_300 = 0x10A4; + func_80C14030(this); + } else { + func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + } +} + +void func_80C14684(EnJgameTsn* this, GlobalContext* globalCtx) { + if (func_80147624(globalCtx)) { + if (globalCtx->msgCtx.choiceIndex == 0) { + if (gSaveContext.rupees >= 20) { + Message_StartTextbox(globalCtx, 0x109E, &this->actor); + this->unk_300 = 0x109E; + func_801159EC(-20); + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x109D, &this->actor); + this->unk_300 = 0x109D; + } + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x109C, &this->actor); + this->unk_300 = 0x109C; + } + } +} + +void func_80C1476C(EnJgameTsn* this, GlobalContext* globalCtx) { + Actor* prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; + + while (prop != NULL) { + if (prop->id == ACTOR_OBJ_JGAME_LIGHT) { + this->unk_208[OBJJGAMELIGHT_GET_7F(prop)] = &prop->colChkInfo.health; + } + prop = prop->next; + } +} + +void func_80C147B4(EnJgameTsn* this, GlobalContext* globalCtx) { + if (func_80147624(globalCtx)) { + switch (this->unk_300) { + case 0x1095: + Message_StartTextbox(globalCtx, 0x1096, &this->actor); + this->unk_300 = 0x1096; + break; + + case 0x1096: + Message_StartTextbox(globalCtx, 0x1097, &this->actor); + this->unk_300 = 0x1097; + break; + + case 0x1098: + Message_StartTextbox(globalCtx, 0x1099, &this->actor); + this->unk_300 = 0x1099; + func_80C13F88(this); + break; + + case 0x1099: + Message_StartTextbox(globalCtx, 0x109A, &this->actor); + this->unk_300 = 0x109A; + break; + + case 0x109A: + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Message_StartTextbox(globalCtx, 0x109B, &this->actor); + this->unk_300 = 0x109B; + break; + + case 0x109E: + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + func_801477B4(globalCtx); + func_80C1476C(this, globalCtx); + func_80C1410C(this, globalCtx); + break; + + case 0x109F: + case 0x10A0: + case 0x10A1: + func_801477B4(globalCtx); + gSaveContext.minigameState = 3; + gSaveContext.unk_3DD0[4] = 5; + gSaveContext.weekEventReg[90] &= (u8)~0x20; + func_80C144E4(this); + break; + + case 0x10A3: + func_801477B4(globalCtx); + func_80C14540(this); + func_80C14554(this, globalCtx); + break; + } + } +} + +s32 func_80C14960(Vec2f arg0, Vec2f arg1) { + s32 phi_v1; + + if ((arg1.x * arg0.z) < (arg0.x * arg1.z)) { + phi_v1 = 1; + } else { + phi_v1 = -1; + } + return phi_v1; +} + +s32 func_80C149B0(GlobalContext* globalCtx, EnJgameTsnStruct* arg1) { + s32 i = 1; + s32 temp_s3; + Player* player = GET_PLAYER(globalCtx); + Vec2f sp64; + Vec2f sp5C; + s32 sp58 = true; + s32 pad; + s32 sp50 = 0; + f32 temp_f20 = player->actor.world.pos.z; + f32 temp_f22 = player->actor.world.pos.x; + + sp64.x = arg1->points[0].z - temp_f20; + sp64.z = arg1->points[0].x - temp_f22; + sp5C.x = arg1->points[1].z - temp_f20; + sp5C.z = arg1->points[1].x - temp_f22; + temp_s3 = func_80C14960(sp64, sp5C); + + while (i != 0) { + sp50++; + if (i < (arg1->count - 1)) { + i++; + } else { + i = 0; + } + + sp64.x = arg1->points[sp50].z - temp_f20; + sp64.z = arg1->points[sp50].x - temp_f22; + sp5C.x = arg1->points[i].z - temp_f20; + sp5C.z = arg1->points[i].x - temp_f22; + + if (func_80C14960(sp64, sp5C) != temp_s3) { + sp58 = false; + break; + } + } + + return sp58; +} + +s32 func_80C14BCC(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + s32 phi_s3 = -1; + + if (player->actor.bgCheckFlags & 2) { + for (i = 0; i < ARRAY_COUNT(this->unk_1D8); i++) { + if (func_80C149B0(globalCtx, &this->unk_1D8[i])) { + phi_s3 = i; + } + } + + if (phi_s3 == -1) { + return false; + } + + if (phi_s3 == this->unk_218) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + *this->unk_208[phi_s3] |= 2; + globalCtx->interfaceCtx.unk_25C = 1; + return true; + } + + if (*this->unk_208[phi_s3] & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + *this->unk_208[phi_s3] |= 2; + globalCtx->interfaceCtx.unk_25C = 1; + } else { + *this->unk_208[phi_s3] |= 4; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + } + } + + return false; +} + +void func_80C14D14(EnJgameTsn* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_80C14D58(EnJgameTsn* this, GlobalContext* globalCtx) { + func_800E9250(globalCtx, &this->actor, &this->unk_2EC, &this->unk_2F2, this->actor.focus.pos); + + if (DECR(this->unk_2FA) == 0) { + this->unk_2FA = Rand_S16Offset(60, 60); + } + + if ((this->unk_2FA == 1) || (this->unk_2FA == 3)) { + this->unk_21C = 1; + } else { + this->unk_21C = 0; + } +} + +void EnJgameTsn_Update(Actor* thisx, GlobalContext* globalCtx) { + EnJgameTsn* this = THIS; + + this->actionFunc(this, globalCtx); + + SkelAnime_Update(&this->skelAnime); + func_80C14D14(this, globalCtx); + func_80C14D58(this, globalCtx); +} + +s32 EnJgamesTsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnJgameTsn* this = THIS; + s16 temp_v0 = this->unk_2EC.x >> 1; + + if (limbIndex == OBJECT_TSN_LIMB_0F) { + rot->x += this->unk_2EC.y; + rot->z += temp_v0; + } else if (limbIndex == OBJECT_TSN_LIMB_08) { + rot->x += this->unk_2F2.y; + rot->z += temp_v0; + } + return false; +} + +void EnJgamesTsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + if (limbIndex == OBJECT_TSN_LIMB_0F) { + Matrix_GetStateTranslation(&thisx->focus.pos); + } +} + +void EnJgameTsn_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnJgameTsn* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C5B0(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C150A4[this->unk_21C])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C150A4[this->unk_21C])); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnJgamesTsn_OverrideLimbDraw, EnJgamesTsn_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h index c7e53da1a..08d07376d 100644 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h +++ b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h @@ -2,16 +2,39 @@ #define Z_EN_JGAME_TSN_H #include "global.h" +#include "objects/object_tsn/object_tsn.h" struct EnJgameTsn; typedef void (*EnJgameTsnActionFunc)(struct EnJgameTsn*, GlobalContext*); +#define ENJGAMETSN_GET_FF(thisx) ((thisx)->params & 0xFF) + +typedef struct { + /* 0x00 */ Vec3s* points; + /* 0x04 */ s32 count; +} EnJgameTsnStruct; // size = 0x8 + typedef struct EnJgameTsn { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnJgameTsnActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x12C]; + /* 0x01D8 */ EnJgameTsnStruct unk_1D8[4]; + /* 0x01F8 */ EnJgameTsnStruct unk_1F8; + /* 0x0200 */ EnJgameTsnStruct unk_200; + /* 0x0208 */ u8* unk_208[4]; + /* 0x0218 */ s32 unk_218; + /* 0x021C */ s32 unk_21C; + /* 0x0220 */ Vec3s jointTable[OBJECT_TSN_LIMB_MAX]; + /* 0x0286 */ Vec3s morphTable[OBJECT_TSN_LIMB_MAX]; + /* 0x02EC */ Vec3s unk_2EC; + /* 0x02F2 */ Vec3s unk_2F2; + /* 0x02F8 */ s16 unk_2F8; + /* 0x02FA */ s16 unk_2FA; + /* 0x02FC */ s16 unk_2FC; + /* 0x02FE */ s16 unk_2FE; + /* 0x0300 */ u16 unk_300; } EnJgameTsn; // size = 0x304 extern const ActorInit En_Jgame_Tsn_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h index 12d958e73..50023c252 100644 --- a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h +++ b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h @@ -5,6 +5,8 @@ struct ObjJgameLight; +#define OBJJGAMELIGHT_GET_7F(thisx) ((thisx)->params & 0x7F) + typedef struct ObjJgameLight { /* 0x000 */ Actor actor; /* 0x144 */ char unk_144[0x78]; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index b676feb1c..6d638b031 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16811,8 +16811,8 @@ 0x80C14D14:("func_80C14D14",), 0x80C14D58:("func_80C14D58",), 0x80C14E08:("EnJgameTsn_Update",), - 0x80C14E64:("func_80C14E64",), - 0x80C14EE4:("func_80C14EE4",), + 0x80C14E64:("EnJgamesTsn_OverrideLimbDraw",), + 0x80C14EE4:("EnJgamesTsn_PostLimbDraw",), 0x80C14F1C:("EnJgameTsn_Draw",), 0x80C152F0:("ObjJgameLight_Init",), 0x80C1542C:("ObjJgameLight_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 5230f6e2a..8cec76838 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1355,11 +1355,6 @@ D_06012FC8 = 0x06012FC8; D_06013928 = 0x06013928; D_06016588 = 0x06016588; -// ovl_En_Jgame_Tsn - -D_06008AB8 = 0x06008AB8; -D_060092FC = 0x060092FC; - // ovl_En_Js D_06010880 = 0x06010880; From e6ca183a88a248b187ce8c446bef593405c02010 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 27 Mar 2022 15:07:03 +0100 Subject: [PATCH 129/257] Bg_Dblue_Waterfall (#723) * Bg_Dblue_Waterfall * UNK --- spec | 3 +- .../z_bg_dblue_waterfall.c | 599 +++++++++++++++++- .../z_bg_dblue_waterfall.h | 18 +- undefined_syms.txt | 8 - 4 files changed, 582 insertions(+), 46 deletions(-) diff --git a/spec b/spec index 1b64e22c7..fec44e5a7 100644 --- a/spec +++ b/spec @@ -4260,8 +4260,7 @@ beginseg name "ovl_Bg_Dblue_Waterfall" compress include "build/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.o" - include "build/data/ovl_Bg_Dblue_Waterfall/ovl_Bg_Dblue_Waterfall.data.o" - include "build/data/ovl_Bg_Dblue_Waterfall/ovl_Bg_Dblue_Waterfall.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Dblue_Waterfall/ovl_Bg_Dblue_Waterfall_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c index 0c124dc07..cd3b8a9d6 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c @@ -5,6 +5,7 @@ */ #include "z_bg_dblue_waterfall.h" +#include "objects/object_dblue_object/object_dblue_object.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,12 +16,15 @@ void BgDblueWaterfall_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgDblueWaterfall_Update(Actor* thisx, GlobalContext* globalCtx); void BgDblueWaterfall_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B8484C(BgDblueWaterfall* this, GlobalContext* globalCtx); void func_80B84928(BgDblueWaterfall* this, GlobalContext* globalCtx); +void func_80B84AD4(BgDblueWaterfall* this, GlobalContext* globalCtx); void func_80B84AEC(BgDblueWaterfall* this, GlobalContext* globalCtx); +void func_80B84B9C(BgDblueWaterfall* this, GlobalContext* globalCtx); void func_80B84BCC(BgDblueWaterfall* this, GlobalContext* globalCtx); +void func_80B84EF0(BgDblueWaterfall* this, GlobalContext* globalCtx); void func_80B84F20(BgDblueWaterfall* this, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Dblue_Waterfall_InitVars = { ACTOR_BG_DBLUE_WATERFALL, ACTORCAT_PROP, @@ -33,69 +37,596 @@ const ActorInit Bg_Dblue_Waterfall_InitVars = { (ActorFunc)BgDblueWaterfall_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B85370 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00CBFBB0, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00CBFBB0, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 50, 740, -740, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B853A8[] = { +Color_RGBA8 D_80B8539C = { 200, 255, 255, 255 }; +Color_RGBA8 D_80B853A0 = { 200, 200, 200, 0 }; + +s32 func_80B83C80(Vec3f* arg0, Vec3f* arg1) { + f32 temp_f0 = Math3D_LengthSquared(arg0); + f32 temp_f2; + + if (temp_f0 < 0.0000010000001f) { + return false; + } + + temp_f2 = 1.0f / sqrtf(temp_f0); + arg1->x = arg0->x * temp_f2; + arg1->y = arg0->y * temp_f2; + arg1->z = arg0->z * temp_f2; + + return true; +} + +s32 func_80B83D04(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 phi_v1; + s32 sp18 = BGDBLUEWATERFALL_GET_100(&this->actor); + + if (Flags_GetSwitch(globalCtx, BGDBLUEWATERFALL_GET_7F(&this->actor))) { + phi_v1 = true; + } else { + phi_v1 = false; + } + return phi_v1 ^ sp18; +} + +s32 func_80B83D58(Actor* thisx, GlobalContext* globalCtx) { + BgDblueWaterfall* this = THIS; + + if (Flags_GetSwitch(globalCtx, BGDBLUEWATERFALL_GET_7F(&this->actor))) { + return false; + } + return true; +} + +void func_80B83D94(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp20 = BGDBLUEWATERFALL_GET_7F(&this->actor); + s32 sp1C = BGDBLUEWATERFALL_GET_100(&this->actor); + s32 phi_v0; + + if (Flags_GetSwitch(globalCtx, sp20)) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if (phi_v0 != sp1C) { + if (phi_v0) { + Flags_UnsetSwitch(globalCtx, sp20); + } else { + Flags_SetSwitch(globalCtx, sp20); + } + } +} + +void func_80B83E1C(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp20 = BGDBLUEWATERFALL_GET_7F(&this->actor); + s32 sp1C = BGDBLUEWATERFALL_GET_100(&this->actor); + s32 phi_v0; + + if (Flags_GetSwitch(globalCtx, sp20)) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if (phi_v0 == sp1C) { + if (phi_v0) { + Flags_UnsetSwitch(globalCtx, sp20); + } else { + Flags_SetSwitch(globalCtx, sp20); + } + } +} + +void func_80B83EA4(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 i; + s32 temp_s1; + Vec3f spD4; + Vec3f spC8; + Vec3f spBC; + Vec3f spB0; + Vec3f spA4; + Vec3f sp98; + s32 phi_s3; + + if (this->collider.info.bumperFlags & BUMP_HIT) { + f32 temp_f0_2; + f32 temp_f20; + + spB0.x = this->collider.info.bumper.hitPos.x; + spB0.y = this->collider.info.bumper.hitPos.y; + spB0.z = this->collider.info.bumper.hitPos.z; + + sp98.x = spB0.x - this->actor.world.pos.x; + sp98.y = 0.0f; + sp98.z = spB0.z - this->actor.world.pos.z; + + if (!func_80B83C80(&sp98, &spA4)) { + Math_Vec3f_Copy(&spA4, &gZeroVec3f); + } + + sp98.y = 0.0f; + spBC.y = -1.4f; + + for (i = 0, phi_s3 = 0; i < 15; i++, phi_s3 += 0x1111) { + temp_s1 = (s32)(Rand_ZeroOne() * 4369.0f) + phi_s3; + temp_f0_2 = Rand_ZeroOne(); + temp_f20 = 1.0f - SQ(temp_f0_2); + + sp98.x = Math_SinS(temp_s1) * temp_f20; + sp98.z = Math_CosS(temp_s1) * temp_f20; + temp_f20 *= 5.0f; + + spD4.x = (sp98.x * temp_f20) + spB0.x; + spD4.y = ((Rand_ZeroOne() * 16.0f) - 8.0f) + spB0.y; + spD4.z = (sp98.z * temp_f20) + spB0.z; + + spC8.x = ((2.0f * Rand_ZeroOne()) - 1.0f) + ((spA4.x * 3.0f) + (sp98.x * 5.0f)); + spC8.y = (Rand_ZeroOne() * 10.0f) + 5.0f; + spC8.z = ((2.0f * Rand_ZeroOne()) - 1.0f) + ((spA4.z * 3.0f) + (sp98.z * 5.0f)); + + spBC.x = spC8.x * -0.02f; + spBC.z = spC8.z * -0.02f; + + EffectSsEnIce_Spawn(globalCtx, &spD4, (Rand_ZeroOne() * 0.3f) + 0.1f, &spC8, &spBC, &D_80B8539C, + &D_80B853A0, 30); + } + } +} + +void func_80B841A0(BgDblueWaterfall* this, GlobalContext* globalCtx) { + Vec3f sp94; + s32 i; + f32 temp_f0; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + f32 temp_f26; + s32 temp_s3; + s32 phi_s2; + + if (this->collider.info.bumperFlags & BUMP_HIT) { + temp_f22 = this->collider.info.bumper.hitPos.x; + temp_f24 = this->collider.info.bumper.hitPos.y; + temp_f26 = this->collider.info.bumper.hitPos.z; + + for (i = 0, phi_s2 = 0; i < 10; i++, phi_s2 += 0x1999) { + temp_s3 = (s32)(Rand_ZeroOne() * 6553.0f) + phi_s2; + temp_f0 = Rand_ZeroOne(); + temp_f20 = (1.0f - SQ(temp_f0)) * 14.0f; + + sp94.x = (Math_SinS(temp_s3) * temp_f20) + temp_f22; + sp94.y = ((Rand_ZeroOne() * 20.0f) - 10.0f) + temp_f24; + sp94.z = (Math_CosS(temp_s3) * temp_f20) + temp_f26; + + EffectSsGSplash_Spawn(globalCtx, &sp94, NULL, NULL, 0, 250); + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_REFLECTION_WATER); + } +} + +void func_80B84348(BgDblueWaterfall* this, GlobalContext* globalCtx, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, + f32 arg7, s32 arg8) { + static s16 D_80B853A4 = 0; + s32 pad; + f32 spB8 = 1.0f / arg8; + s32 i; + f32 spB0 = this->actor.world.pos.y + arg3; + s32 pad2; + f32 temp_f22; + f32 temp_f24; + Vec3f sp98; + Vec3f sp8C; + Vec3f sp80; + f32 temp_f26; + f32 temp_f20; + + for (i = 0; i < arg8; i++) { + D_80B853A4 += 0x4E20; + + temp_f20 = Math_SinS(D_80B853A4); + temp_f24 = (Rand_ZeroOne() * (arg2 - arg3)) + (spB8 * i); + temp_f22 = Math_CosS(D_80B853A4); + temp_f26 = ((Rand_ZeroOne() * 0.8f) + 0.2f) * arg4; + + sp8C.x = temp_f20 * temp_f26; + sp8C.y = (Rand_ZeroOne() * 4.0f) + arg5; + sp8C.z = temp_f22 * temp_f26; + + sp80.x = sp8C.x * -0.016f; + sp80.y = sp8C.y * -0.015f; + sp80.z = sp8C.z * -0.016f; + + sp98.x = (temp_f20 * 50.0f) + this->actor.world.pos.x; + sp98.y = temp_f24 + spB0; + sp98.z = (temp_f22 * 50.0f) + this->actor.world.pos.z; + + EffectSsIceSmoke_Spawn(globalCtx, &sp98, &sp8C, &sp80, (Rand_ZeroOne() * arg7) + arg6); + } +} + +void func_80B84568(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + CollisionPoly* sp40; + WaterBox* sp3C; + s32 sp38; + f32 sp34 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp40, &sp38, &this->actor, &this->actor.world.pos); + f32 sp30; + + if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp30, + &sp3C)) { + if (sp30 < sp34) { + this->unk_198 = sp34; + } else { + this->unk_198 = sp30; + } + } else { + this->unk_198 = sp34; + } +} + +void func_80B84610(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad[2]; + Vec3f sp34; + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_1A7 <= 0) { + this->unk_1A7 = 16; + } else { + this->unk_1A7 -= (s8)((u32)Rand_Next() >> 0x1F); + } + + if (this->unk_1A7 >= 6) { + this->unk_1A8 += Rand_ZeroOne() * 0.1f; + if (this->unk_1A8 > 0.5f) { + this->unk_1A8 = 0.5f; + } else { + this->unk_1A8 = this->unk_1A8; + } + } else { + this->unk_1A8 -= Rand_ZeroOne() * 0.2f; + if (this->unk_1A8 > -0.5f) { + this->unk_1A8 = -0.5f; + } else { + this->unk_1A8 = this->unk_1A8; + } + } + + Matrix_StatePush(); + Matrix_RotateY(BINANG_ADD(this->actor.yawTowardsPlayer, 0x4000), MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(this->unk_1A8, &sp34); + Matrix_StatePop(); + + player->actor.world.pos.x += sp34.x; + player->actor.world.pos.z += sp34.z; + if (this && this && this) {} + player->unk_B80 = 8.0f; + player->unk_B84 = this->actor.yawTowardsPlayer; +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1500, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void BgDblueWaterfall_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueWaterfall* this = THIS; -extern ColliderCylinderInit D_80B85370; -extern InitChainEntry D_80B853A8[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + this->actor.shape.rot.z = 0; + this->actor.world.rot.z = 0; -extern UNK_TYPE D_0600B280; -extern UNK_TYPE D_0600B448; + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83C80.s") + this->unk_190 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00B448); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83D04.s") + Actor_SetFocus(&this->actor, -100.0f); + func_80B84568(this, globalCtx); + func_80B8484C(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83D58.s") +void BgDblueWaterfall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgDblueWaterfall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83D94.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83E1C.s") +void func_80B8484C(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 temp = func_80B83D04(this, globalCtx); + s32 sp1C = this->actor.home.rot.z * 10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83EA4.s") + if (temp) { + this->unk_19E = 0; + this->unk_19F = 255; + this->unk_1A0 = 0; + this->collider.dim.radius = 55; + this->collider.dim.height = 150; + this->collider.dim.yShift = -150; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + } else { + this->unk_19E = 255; + this->unk_19F = 0; + this->unk_1A0 = 0; + this->collider.dim.radius = 50; + this->collider.dim.height = 740; + this->collider.dim.yShift = -740; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B841A0.s") + if ((sp1C != 0) && !func_80B83D58(&this->actor, globalCtx)) { + this->unk_19C = sp1C; + } else { + this->unk_19C = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84348.s") + this->unk_1A3 = false; + this->actionFunc = func_80B84928; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84568.s") +void func_80B84928(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp30 = func_80B83D04(this, globalCtx); + s32 sp2C = (this->collider.base.acFlags & AC_HIT) != 0; + s32 sp28 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84610.s") + if (sp2C) { + this->collider.base.acFlags &= ~AC_HIT; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/BgDblueWaterfall_Init.s") + if ((sp30 == 0) && (this->collider.base.ocFlags2 & OC2_HIT_PLAYER)) { + func_80B84610(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/BgDblueWaterfall_Destroy.s") + if (this->unk_19C > 0) { + this->unk_19C--; + if (this->unk_19C == 0) { + if (sp30 != 0) { + func_80B83D94(this, globalCtx); + func_80B84EF0(this, globalCtx); + } else { + func_80B83E1C(this, globalCtx); + func_80B84B9C(this, globalCtx); + } + sp28 = true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B8484C.s") + if (!sp28) { + if (sp2C) { + if (sp30 != 0) { + func_80B83EA4(this, globalCtx); + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x800) { + this->unk_1A4 = this->actor.cutscene; + func_80B84AD4(this, globalCtx); + } + } else { + func_80B841A0(this, globalCtx); + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x1000) { + this->unk_1A4 = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + func_80B84AD4(this, globalCtx); + } + } + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84928.s") +void func_80B84AD4(BgDblueWaterfall* this, GlobalContext* globalCtx) { + this->actionFunc = func_80B84AEC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84AD4.s") +void func_80B84AEC(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84AEC.s") + if (ActorCutscene_GetCanPlayNext(this->unk_1A4)) { + sp20 = func_80B83D04(this, globalCtx); + ActorCutscene_StartAndSetUnkLinkFields(this->unk_1A4, &this->actor); + this->unk_1A3 = true; + if (sp20) { + func_80B83D94(this, globalCtx); + func_80B84EF0(this, globalCtx); + } else { + func_80B83E1C(this, globalCtx); + func_80B84B9C(this, globalCtx); + } + } else { + ActorCutscene_SetIntentToPlay(this->unk_1A4); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84B9C.s") +void func_80B84B9C(BgDblueWaterfall* this, GlobalContext* globalCtx) { + this->unk_19C = 60; + this->unk_19E = 255; + this->unk_19F = 0; + this->unk_1A0 = 0; + this->actionFunc = func_80B84BCC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84BCC.s") +void func_80B84BCC(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84EF0.s") + this->unk_19C--; + if (this->unk_19C > 0) { + s32 sp38 = this->unk_19C & 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84F20.s") + if (this->unk_19C > 56) { + func_80B84348(this, globalCtx, 0.0f, -5500.0f, 0.4f, -15.0f, 370.0f, 100.0f, 6); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/BgDblueWaterfall_Update.s") + if (!sp38) { + if ((this->unk_19C < 24) && (this->unk_19C > 10)) { + if (this->unk_198 > -32000.0f) { + func_80B84348(this, globalCtx, (this->unk_198 - this->actor.world.pos.y) + 50.0f, + (this->unk_198 - this->actor.world.pos.y), 7.0f, -1.0f, 280.0f, 100.0f, 3); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/BgDblueWaterfall_Draw.s") + if (this->unk_19C > 50) { + func_80B84348(this, globalCtx, 0.0f, -400.0f, 0.6f, -12.0f, 370.0f, 100.0f, 2); + } else if (this->unk_19C > 40) { + func_80B84348(this, globalCtx, 0.0f, -400.0f, 1.0f, -12.0f, 370.0f, 100.0f, 2); + } else if (this->unk_19C > 20) { + func_80B84348(this, globalCtx, 0.0f, -400.0f, 1.8f, -12.0f, 370.0f, 100.0f, 2); + } + } + + if (this->unk_19E > 6) { + this->unk_19E -= 6; + } else { + this->unk_19E = 0; + } + + if (this->unk_19C >= 55) { + if (this->unk_1A0 < 205) { + this->unk_1A0 += 50; + } else { + this->unk_1A0 = 255; + } + } else if (this->unk_19C >= 36) { + if (this->unk_1A0 >= 16) { + this->unk_1A0 -= 15; + } else { + this->unk_1A0 = 0; + } + } else { + this->unk_1A0 = 0; + } + + if (this->unk_19C < 60) { + if (this->unk_19F < 245) { + this->unk_19F += 10; + } else { + this->unk_19F = 255; + } + } + + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } else { + if (this->unk_1A3) { + ActorCutscene_Stop(this->unk_1A4); + } + func_80B8484C(this, globalCtx); + } +} + +void func_80B84EF0(BgDblueWaterfall* this, GlobalContext* globalCtx) { + this->unk_19C = 60; + this->unk_19E = 0; + this->unk_19F = 255; + this->unk_1A0 = 0; + this->actionFunc = func_80B84F20; +} + +void func_80B84F20(BgDblueWaterfall* this, GlobalContext* globalCtx) { + this->unk_19C--; + + if (this->unk_19C > 0) { + if (this->unk_19C >= 58) { + func_80B84348(this, globalCtx, 100.0f, -100.0f, 4.0f, -6.0f, 370.0f, 100.0f, 0xC); + } + + if (this->unk_19C < 50) { + if (this->unk_19E < 250) { + this->unk_19E += 5; + } else { + this->unk_19E = 255; + } + } + + if (this->unk_19F >= 6) { + this->unk_19F -= 5; + } else { + this->unk_19F = 0; + } + + func_800B9010(&this->actor, NA_SE_EV_ICE_MELT_LEVEL - SFX_FLAG); + } else { + if (this->unk_1A3) { + ActorCutscene_Stop(this->unk_1A4); + } + func_80B8484C(this, globalCtx); + } +} + +void BgDblueWaterfall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgDblueWaterfall* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgDblueWaterfall_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueWaterfall* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->unk_19E > 0) { + s32 sp38 = this->unk_19E * 0.49803922f; + + AnimatedMat_Draw(globalCtx, this->unk_190); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x8A, 255, 255, 255, sp38); + gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_00B280); + } + + if (this->unk_19F > 0) { + if (this->unk_19F < 255) { + gSPSegment(POLY_XLU_DISP++, 0x09, D_801AEF88); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x9B, 255, 255, 255, this->unk_19F); + gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_003358); + } else { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x09, D_801AEFA0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x9B, 255, 255, 255, 255); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dblue_object_DL_003358); + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, 255, this->unk_19F); + gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_003250); + } + + if (this->unk_1A0 > 0) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, 255, this->unk_1A0); + gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_003770); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h index eb12538fc..0fa908629 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.h @@ -7,11 +7,25 @@ struct BgDblueWaterfall; typedef void (*BgDblueWaterfallActionFunc)(struct BgDblueWaterfall*, GlobalContext*); +#define BGDBLUEWATERFALL_GET_7F(thisx) ((thisx)->params & 0x7F) +#define BGDBLUEWATERFALL_GET_100(thisx) (((thisx)->params >> 8) & 1) + typedef struct BgDblueWaterfall { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x50]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ AnimatedMaterial* unk_190; /* 0x0194 */ BgDblueWaterfallActionFunc actionFunc; - /* 0x0198 */ char unk_198[0x14]; + /* 0x0198 */ f32 unk_198; + /* 0x019C */ s16 unk_19C; + /* 0x019E */ u8 unk_19E; + /* 0x019F */ u8 unk_19F; + /* 0x01A0 */ u8 unk_1A0; + /* 0x01A1 */ UNK_TYPE1 unk1A1[2]; + /* 0x01A3 */ s8 unk_1A3; + /* 0x01A4 */ s16 unk_1A4; + /* 0x01A6 */ UNK_TYPE1 unk1A6[1]; + /* 0x01A7 */ s8 unk_1A7; + /* 0x01A8 */ f32 unk_1A8; } BgDblueWaterfall; // size = 0x1AC extern const ActorInit Bg_Dblue_Waterfall_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 8cec76838..36199793c 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -579,14 +579,6 @@ D_0600D250 = 0x0600D250; D_060002C8 = 0x060002C8; D_060005C4 = 0x060005C4; -// ovl_Bg_Dblue_Waterfall - -D_06003250 = 0x06003250; -D_06003358 = 0x06003358; -D_06003770 = 0x06003770; -D_0600B280 = 0x0600B280; -D_0600B448 = 0x0600B448; - // ovl_Bg_Dkjail_Ivy D_06000080 = 0x06000080; From 47cc65e134d0846b8ce35e8cba5d60d5f13bfaa4 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 27 Mar 2022 15:12:00 +0100 Subject: [PATCH 130/257] Bg_Dblue_Balance (#724) * Bg_Dblue_Balance * PR --- spec | 4 +- .../ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c | 698 +++++++++++++++++- .../ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h | 36 +- undefined_syms.txt | 7 - 4 files changed, 704 insertions(+), 41 deletions(-) diff --git a/spec b/spec index fec44e5a7..9cc8086bd 100644 --- a/spec +++ b/spec @@ -4251,9 +4251,7 @@ beginseg name "ovl_Bg_Dblue_Balance" compress include "build/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.o" - include "build/data/ovl_Bg_Dblue_Balance/ovl_Bg_Dblue_Balance.data.o" - include "build/data/ovl_Bg_Dblue_Balance/ovl_Bg_Dblue_Balance.bss.o" - include "build/data/ovl_Bg_Dblue_Balance/ovl_Bg_Dblue_Balance.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Dblue_Balance/ovl_Bg_Dblue_Balance_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c index 9f2e18d9c..07693307b 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c @@ -5,6 +5,7 @@ */ #include "z_bg_dblue_balance.h" +#include "objects/object_dblue_object/object_dblue_object.h" #define FLAGS 0x00000000 @@ -15,11 +16,19 @@ void BgDblueBalance_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgDblueBalance_Update(Actor* thisx, GlobalContext* globalCtx); void BgDblueBalance_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B82DC4(BgDblueBalance* this); void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx); +void func_80B8330C(Actor* thisx, GlobalContext* globalCtx); +void func_80B83344(BgDblueBalance* this); void func_80B8335C(BgDblueBalance* this, GlobalContext* globalCtx); +void func_80B833A8(BgDblueBalance* this); void func_80B833C4(BgDblueBalance* this, GlobalContext* globalCtx); +void func_80B83518(Actor* thisx, GlobalContext* globalCtx); +void func_80B83758(Actor* thisx, GlobalContext* globalCtx); + +AnimatedMaterial* D_80B83C70; +AnimatedMaterial* D_80B83C74; -#if 0 const ActorInit Bg_Dblue_Balance_InitVars = { ACTOR_BG_DBLUE_BALANCE, ACTORCAT_BG, @@ -32,56 +41,689 @@ const ActorInit Bg_Dblue_Balance_InitVars = { (ActorFunc)BgDblueBalance_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B83A98[] = { +typedef struct { + /* 0x00 */ Gfx* unk_00; + /* 0x04 */ CollisionHeader* unk_04; + /* 0x08 */ u32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ ActorFunc unk_14; + /* 0x18 */ ActorFunc unk_18; +} BgDblueBalanceStruct2; + +BgDblueBalanceStruct2 D_80B83A20[] = { + { + object_dblue_object_DL_00B8F8, + &object_dblue_object_Colheader_00BC08, + 0x10, + 360.0f, + 300.0f, + BgDblueBalance_Update, + BgDblueBalance_Draw, + }, + { + object_dblue_object_DL_00BF48, + &object_dblue_object_Colheader_00C180, + 0x10, + 210.0f, + 190.0f, + func_80B8330C, + BgDblueBalance_Draw, + }, + { + object_dblue_object_DL_00C4B8, + &object_dblue_object_Colheader_00C700, + 0x10, + 180.0f, + 180.0f, + func_80B8330C, + BgDblueBalance_Draw, + }, + { + object_dblue_object_DL_001E68, + &object_dblue_object_Colheader_002E78, + 0x30, + 1500.0f, + 1500.0f, + func_80B83518, + func_80B83758, + }, +}; + +s8 D_80B83A90[] = { + 0, + 4, +}; +s8 D_80B83A94[] = { + 0, + 2, + 4, + 6, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void func_80B823B0(BgDblueBalance* this) { + s32 pad; + Vec3f sp28; -extern InitChainEntry D_80B83A98[]; + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); -extern UNK_TYPE D_0600CD10; -extern UNK_TYPE D_0600CE00; -extern UNK_TYPE D_0600D110; + sp28.x = -138.28f; + sp28.y = 0.0f; + sp28.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B823B0.s") + if (this->unk_15C != NULL) { + Matrix_MultiplyVector3fByState(&sp28, &this->unk_15C->dyna.actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B82454.s") + sp28.x = 138.28f; + if (this->unk_160 != NULL) { + Matrix_MultiplyVector3fByState(&sp28, &this->unk_160->dyna.actor.world.pos); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8259C.s") +s32 func_80B82454(BgDblueBalance* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp58 = true; + BgDblueBalance* balance; + Vec3f sp48; + Vec3f sp3C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8264C.s") + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B828E4.s") + sp48.x = -138.28f; + sp48.y = 0.0f; + sp48.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8296C.s") + Matrix_MultiplyVector3fByState(&sp48, &sp3C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B82B00.s") + this->unk_15C = (BgDblueBalance*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_DBLUE_BALANCE, sp3C.x, + sp3C.y, sp3C.z, 0, this->dyna.actor.shape.rot.y, 0, 0x100); + if (this->unk_15C == NULL) { + sp58 = false; + } else { + balance = this->unk_15C; + balance->unk_164 = this; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/BgDblueBalance_Init.s") + sp48.x = 138.28f; + Matrix_MultiplyVector3fByState(&sp48, &sp3C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/BgDblueBalance_Destroy.s") + this->unk_160 = (BgDblueBalance*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_DBLUE_BALANCE, sp3C.x, + sp3C.y, sp3C.z, 0, this->dyna.actor.shape.rot.y, 0, 0x200); + if (this->unk_160 == NULL) { + sp58 = false; + } else { + balance = this->unk_160; + balance->unk_164 = this; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B82DC4.s") + return sp58; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B82DE0.s") +void func_80B8259C(BgDblueBalance* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* sp30; + f32 sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/BgDblueBalance_Update.s") + if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.z, &sp2C, &sp30)) { + this->dyna.actor.depthInWater = sp2C - this->dyna.actor.world.pos.y; + this->unk_228 = sp2C; + if ((this->dyna.actor.depthInWater < 150.0f) && (this->dyna.actor.depthInWater > -150.0f)) { + this->unk_182 = true; + } else { + this->unk_182 = false; + } + } else { + this->unk_182 = false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8330C.s") +void func_80B8264C(BgDblueBalance* this) { + s32 pad; + s32 i; + BgDblueBalanceStruct* phi_s0; + Vec3f sp78; + f32 temp_f0; + s16 phi_s2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B83344.s") + if (this->unk_170 != 0) { + if (this->unk_183 < 8) { + this->unk_183 = 0; + } else { + this->unk_183 -= 7; + } + } else { + if (this->unk_183 > 250) { + this->unk_183 = 255; + } else { + this->unk_183 += 4; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8335C.s") + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B833A8.s") + for (i = 0, phi_s0 = &this->unk_188[0], phi_s2 = 0; i < ARRAY_COUNT(this->unk_188); + i++, phi_s2 += 0x2000, phi_s0++) { + phi_s0->unk_0C = this->dyna.actor.shape.rot.x + phi_s2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B833C4.s") + Matrix_StatePush(); + Matrix_InsertXRotation_s(phi_s0->unk_0C, MTXMODE_NEW); + Matrix_InsertTranslation(-545.0f, 0.0f, 270.0f, MTXMODE_APPLY); + Matrix_GetStateTranslation(&sp78); + Matrix_StatePop(); + Matrix_MultiplyVector3fByState(&sp78, &phi_s0->unk_00); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B83518.s") + temp_f0 = (sp78.z - 135.0f); + if (sp78.z > 135.0f) { + temp_f0 *= 1.8962963f; + if (temp_f0 > 255.0f) { + phi_s0->unk_0E = 0xFF; + phi_s0->unk_10 = 0.1f; + } else if (temp_f0 < 1.0f) { + phi_s0->unk_0E = 0; + phi_s0->unk_10 = 0.0f; + } else { + phi_s0->unk_0E = temp_f0; + phi_s0->unk_10 = temp_f0 * 0.000390625f; + } + } else { + phi_s0->unk_0E = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/BgDblueBalance_Draw.s") +void func_80B828E4(BgDblueBalance* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor)) && (this->unk_17D <= 0)) { + if (this->unk_183 >= 252) { + this->unk_183 = 255; + } else { + this->unk_183 += 3; + } + } else if (this->unk_183 < 7) { + this->unk_183 = 0; + } else { + this->unk_183 -= 6; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B83758.s") +void func_80B8296C(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2) { + s32 i; + Vec3f sp60; + f32 temp_f0; + f32 temp_f20 = arg2 * 2; + + for (i = 0; i < ARRAY_COUNT(D_80B83A90); i++) { + sp60.x = ((Rand_ZeroOne() - 0.5f) * temp_f20) + arg1->x; + sp60.y = arg1->y; + sp60.z = ((Rand_ZeroOne() - 0.5f) * temp_f20) + arg1->z; + EffectSsGRipple_Spawn(globalCtx, &sp60, 500, 2000, D_80B83A90[i]); + } + + for (i = 0; i < ARRAY_COUNT(D_80B83A94); i++) { + temp_f0 = Rand_ZeroOne(); + temp_f20 = 1.0f - SQ(temp_f0); + if (Rand_Next() > 0) { + temp_f20 = -temp_f20; + } + + sp60.x = (temp_f20 * arg2) + arg1->x; + sp60.y = arg1->y; + + temp_f0 = Rand_ZeroOne(); + temp_f20 = 1.0f - SQ(temp_f0); + if (Rand_Next() > 0) { + temp_f20 = -temp_f20; + } + sp60.z = (temp_f20 * arg2) + arg1->z; + + EffectSsGRipple_Spawn(globalCtx, &sp60, 400, 800, D_80B83A94[i]); + } +} + +s32 func_80B82B00(s16 arg0, s16 arg1, s16 arg2) { + if (arg0 < arg1) { + return (arg0 < arg2 && arg1 >= arg2); + } + return (arg0 < arg2 || arg1 >= arg2); +} + +void BgDblueBalance_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueBalance* this = THIS; + s32 sp2C = BGDBLUEBALANCE_GET_300(&this->dyna.actor); + s32 pad2; + s32 sp24 = Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor)); + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + + this->dyna.actor.flags = D_80B83A20[sp2C].unk_08; + this->dyna.actor.uncullZoneScale = D_80B83A20[sp2C].unk_0C; + this->dyna.actor.uncullZoneDownward = D_80B83A20[sp2C].unk_10; + this->dyna.actor.update = D_80B83A20[sp2C].unk_14; + this->dyna.actor.draw = D_80B83A20[sp2C].unk_18; + + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_80B83A20[sp2C].unk_04); + + if (sp2C == 3) { + D_80B83C70 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00CE00); + } else if (sp2C == 0) { + D_80B83C74 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00D250); + } + + if (sp2C == 0) { + if (sp24 != 0) { + this->dyna.actor.shape.rot.z = -0x1C72; + this->unk_174 = -0x1C72; + } else { + this->dyna.actor.shape.rot.z = 0x1C72; + this->unk_174 = 0x1C72; + } + func_80B82454(this, globalCtx); + func_80B8259C(this, globalCtx); + func_80B82DC4(this); + } else if (sp2C == 3) { + this->unk_16C = sp24; + this->unk_170 = sp24; + if (sp24 != 0) { + func_80B83344(this); + } else { + this->unk_178 = 0x1F4; + func_80B833A8(this); + } + } +} + +void BgDblueBalance_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueBalance* this = THIS; + s32 sp1C = BGDBLUEBALANCE_GET_300(&this->dyna.actor); + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + + if (sp1C == 0) { + if (this->unk_15C != NULL) { + this->unk_15C->unk_164 = NULL; + } + if (this->unk_160 != NULL) { + this->unk_160->unk_164 = NULL; + } + } else if (sp1C == 1) { + if (this->unk_164 != NULL) { + this->unk_164->unk_15C = NULL; + } + } else if (sp1C == 2) { + if (this->unk_164 != NULL) { + this->unk_164->unk_160 = NULL; + } + } +} + +void func_80B82DC4(BgDblueBalance* this) { + this->unk_17D = 20; + this->actionFunc = func_80B82DE0; +} + +void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx) { + s32 pad; + f32 sp88 = Math_CosS(this->dyna.actor.shape.rot.z * 2.2499313f); + Actor* actor = &this->dyna.actor; + s32 pad2; + s16 abs; + s32 phi_a0; + s32 phi_a1; + f32 phi_f2; + f32 temp2; + Vec3f sp60; + BgDblueBalance* sp5C; + Vec3f sp50; + s32 pad3; + Vec3f sp40; + BgDblueBalance* sp3C; + Vec3f sp30; + + if (Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor))) { + if (this->unk_17D > 0) { + this->unk_17D--; + } else { + this->unk_174 = -0x1C72; + this->unk_176 = (s32)(sp88 * -300.0f) - 60; + } + } else { + BgDblueBalance* balance1 = this->unk_160; + BgDblueBalance* balance2 = this->unk_15C; + + phi_a0 = 0; + phi_a1 = 1; + this->unk_17D = 20; + if (balance1 != NULL) { + if (balance1->unk_181 != 0) { + phi_a0 = 4; + } else if (balance1->unk_180 != 0) { + phi_a0 = 2; + } + } + + if (balance2 != NULL) { + if (balance2->unk_181 != 0) { + phi_a1 = 5; + } else if (balance2->unk_180 != 0) { + phi_a1 = 3; + } + } + + if (phi_a0 < phi_a1) { + this->unk_174 = 0x1C72; + this->unk_176 = (s32)(sp88 * 370.0f) + 80; + } else { + this->unk_174 = -0x1C72; + this->unk_176 = (s32)(sp88 * -160.0f) - 80; + } + } + + if (this->dyna.actor.shape.rot.z == this->unk_174) { + this->unk_178 = 0; + this->unk_17C = 0; + return; + } + + abs = this->dyna.actor.shape.rot.z - this->unk_174; + abs = ABS_ALT(abs); + + if ((this->unk_17C > 0) && (abs < 0x7D0)) { + phi_a0 = 3; + } else { + phi_a0 = 40; + this->unk_17C = 0; + } + + if (this->unk_176 >= 0) { + this->unk_178 += phi_a0; + if (this->unk_176 < this->unk_178) { + this->unk_178 = this->unk_176; + } + } else { + this->unk_178 -= phi_a0; + if (this->unk_178 < this->unk_176) { + this->unk_178 = this->unk_176; + } + } + + phi_f2 = this->unk_178; + temp2 = this->unk_17A; + if ((phi_f2 * temp2) <= 0.0f) { + func_801A7328(&this->dyna.actor.projectedPos, NA_SE_EV_SEESAW_INCLINE - SFX_FLAG); + } + + phi_f2 *= 0.0022222223f; + phi_f2 = fabsf(phi_f2); + if (phi_f2 > 1.0f) { + phi_f2 = 1.0f; + } + + func_8019FAD8(&this->dyna.actor.projectedPos, NA_SE_EV_SEESAW_INCLINE - SFX_FLAG, phi_f2 + 1.0f); + actor->shape.rot.z += this->unk_178; + + if (this->dyna.actor.shape.rot.z > 0x1C71) { + if (this->unk_17C < 2) { + actor->shape.rot.z = 0x1C71; + this->unk_178 *= -0.6f; + this->unk_17C++; + if (this->unk_182) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_WATER_BOUND); + sp5C = this->unk_15C; + Matrix_StatePush(); + Matrix_RotateY(BINANG_SUB(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(45.0f, &sp60); + Matrix_StatePop(); + + sp50.x = sp5C->dyna.actor.world.pos.x + sp60.x; + sp50.y = this->unk_228; + sp50.z = sp5C->dyna.actor.world.pos.z + sp60.z; + + func_80B8296C(globalCtx, &sp50, 70.0f); + } else { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_BOUND); + } + } else { + this->dyna.actor.shape.rot.z = 0x1C72; + this->unk_178 = 0; + } + } else if (this->dyna.actor.shape.rot.z < -0x1C71) { + if (this->unk_17C < 2) { + actor->shape.rot.z = -0x1C71; + this->unk_178 *= -0.6f; + this->unk_17C++; + if (this->unk_182) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_WATER_BOUND); + sp3C = this->unk_160; + Matrix_StatePush(); + Matrix_RotateY(BINANG_ADD(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(30.0f, &sp40); + Matrix_StatePop(); + + sp30.x = sp3C->dyna.actor.world.pos.x + sp40.x; + sp30.y = this->unk_228; + sp30.z = sp3C->dyna.actor.world.pos.z + sp40.z; + + func_80B8296C(globalCtx, &sp30, 47.0f); + } else { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_BOUND); + } + } else { + this->dyna.actor.shape.rot.z = -0x1C72; + this->unk_178 = 0; + } + } + func_80B823B0(this); +} + +void BgDblueBalance_Update(Actor* thisx, GlobalContext* globalCtx) { + BgDblueBalance* this = THIS; + + this->unk_17A = this->unk_178; + + this->actionFunc(this, globalCtx); + + func_80B828E4(this, globalCtx); +} + +void func_80B8330C(Actor* thisx, GlobalContext* globalCtx) { + BgDblueBalance* this = THIS; + + this->unk_180 = DynaPolyActor_IsInSwitchPressedState(&this->dyna); + this->unk_181 = DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna); +} + +void func_80B83344(BgDblueBalance* this) { + this->unk_178 = 0; + this->actionFunc = func_80B8335C; +} + +void func_80B8335C(BgDblueBalance* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor))) { + this->unk_178 = -0x14; + func_80B833A8(this); + } +} + +void func_80B833A8(BgDblueBalance* this) { + this->unk_186 = 0; + this->unk_187 = 0; + this->actionFunc = func_80B833C4; +} + +void func_80B833C4(BgDblueBalance* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp28 = false; + s16 sp26; + s16 sp24; + + if (this->unk_170 != 0) { + if ((this->unk_16C == 0) && (this->unk_17F == 0)) { + this->unk_17F = 1; + } + + if (this->unk_186 != 0) { + if (this->unk_178 >= 0x50) { + this->unk_178 -= 5; + } + } + } else { + this->unk_187 = Math_StepToS(&this->unk_178, 0x1F4, 5); + } + + sp26 = this->dyna.actor.shape.rot.x; + this->dyna.actor.shape.rot.x += this->unk_178; + sp24 = this->dyna.actor.shape.rot.x; + if (sp24) {} + + if (this->unk_170 != 0) { + if (this->unk_186 != 0) { + if (func_80B82B00(sp26, sp24, this->unk_184)) { + sp28 = true; + } + } else if (this->unk_187 != 0) { + if (func_80B82B00(sp26, sp24, 0x2097)) { + this->unk_184 = -0x8000; + this->unk_186 = 1; + } else if (func_80B82B00(sp26, sp24, -0x5F69)) { + this->unk_184 = 0; + this->unk_186 = 1; + } + } + } + + func_80B8264C(this); + + if (sp28) { + this->dyna.actor.shape.rot.x = this->unk_184; + func_80B83344(this); + } +} + +void func_80B83518(Actor* thisx, GlobalContext* globalCtx) { + BgDblueBalance* this = THIS; + + this->unk_170 = Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor)); + + this->actionFunc(this, globalCtx); + + if (this->unk_17F == 2) { + this->unk_17E--; + if (this->unk_17E <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->unk_17F = 0; + } + } else if ((this->unk_17F != 0) && (this->unk_17F == 1)) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->unk_17F = 2; + this->unk_17E = 0x50; + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } + } + this->unk_16C = this->unk_170; +} + +void BgDblueBalance_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueBalance* this = THIS; + BgDblueBalanceStruct2* ptr2 = &D_80B83A20[BGDBLUEBALANCE_GET_300(&this->dyna.actor)]; + BgDblueBalance* sp38; + Gfx* gfx; + + Gfx_DrawDListOpa(globalCtx, ptr2->unk_00); + + if (!(BGDBLUEBALANCE_GET_300(&this->dyna.actor)) && (this->unk_160 != NULL)) { + AnimatedMat_Draw(globalCtx, D_80B83C74); + sp38 = this->unk_160; + Matrix_SetStateRotationAndTranslation(sp38->dyna.actor.world.pos.x, sp38->dyna.actor.world.pos.y, + sp38->dyna.actor.world.pos.z, &sp38->dyna.actor.shape.rot); + Matrix_InsertTranslation(30.0f, 15.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(sp38->dyna.actor.scale.x, sp38->dyna.actor.scale.y, sp38->dyna.actor.scale.z, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_XLU_DISP; + + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetEnvColor(gfx++, 0, 0, 0, this->unk_183); + gSPDisplayList(gfx++, object_dblue_object_DL_00D110); + + POLY_XLU_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_80B83758(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueBalance* this = THIS; + f32 temp_f0; + Gfx* gfx; + s32 i; + BgDblueBalanceStruct* ptr; + BgDblueBalanceStruct2* ptr2; + s32 temp; + + if (this->unk_178 != 0) { + if (this->unk_178 == 0x1F4) { + temp_f0 = 1.0f; + } else { + temp_f0 = this->unk_178 * 0.002f; + temp_f0 = CLAMP(temp_f0, 0.0f, 1.0f); + } + func_8019FB0C(&this->dyna.actor.projectedPos, NA_SE_EV_SMALL_WATER_WHEEL - SFX_FLAG, temp_f0, 0x20); + } + + if (this->dyna.actor.flags & ACTOR_FLAG_40) { + ptr2 = &D_80B83A20[BGDBLUEBALANCE_GET_300(&this->dyna.actor)]; + Gfx_DrawDListOpa(globalCtx, ptr2->unk_00); + + if (this->unk_183 != 0) { + AnimatedMat_Draw(globalCtx, D_80B83C70); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_XLU_DISP; + + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + + for (i = 0, ptr = &this->unk_188[0]; i < ARRAY_COUNT(this->unk_188); i++, ptr++) { + if (ptr->unk_0E != 0) { + Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(ptr->unk_0C, MTXMODE_APPLY); + Matrix_Scale(ptr->unk_10, ptr->unk_10, ptr->unk_10, MTXMODE_APPLY); + + temp = ptr->unk_0E * (f32)this->unk_183 * 0.003921569f; + gDPSetEnvColor(gfx++, 0, 0, 0, temp); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, object_dblue_object_DL_00CD10); + } + } + + POLY_XLU_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h index 8750f4077..16eed26e3 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h +++ b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.h @@ -7,11 +7,41 @@ struct BgDblueBalance; typedef void (*BgDblueBalanceActionFunc)(struct BgDblueBalance*, GlobalContext*); +#define BGDBLUEBALANCE_GET_7F(thisx) ((thisx)->params & 0x7F) +#define BGDBLUEBALANCE_GET_300(thisx) (((thisx)->params >> 8) & 3) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ u8 unk_0E; + /* 0x10 */ f32 unk_10; +} BgDblueBalanceStruct; // size = 0x14 + typedef struct BgDblueBalance { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x24]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ struct BgDblueBalance* unk_15C; + /* 0x0160 */ struct BgDblueBalance* unk_160; + /* 0x0164 */ struct BgDblueBalance* unk_164; /* 0x0168 */ BgDblueBalanceActionFunc actionFunc; - /* 0x016C */ char unk_16C[0xC0]; + /* 0x016C */ s32 unk_16C; + /* 0x0170 */ s32 unk_170; + /* 0x0174 */ s16 unk_174; + /* 0x0176 */ s16 unk_176; + /* 0x0178 */ s16 unk_178; + /* 0x017A */ s16 unk_17A; + /* 0x017C */ s8 unk_17C; + /* 0x017D */ s8 unk_17D; + /* 0x017E */ s8 unk_17E; + /* 0x017F */ s8 unk_17F; + /* 0x0180 */ s8 unk_180; + /* 0x0181 */ s8 unk_181; + /* 0x0182 */ s8 unk_182; + /* 0x0183 */ u8 unk_183; + /* 0x0184 */ s16 unk_184; + /* 0x0186 */ s8 unk_186; + /* 0x0187 */ s8 unk_187; + /* 0x0188 */ BgDblueBalanceStruct unk_188[8]; + /* 0x0228 */ f32 unk_228; } BgDblueBalance; // size = 0x22C extern const ActorInit Bg_Dblue_Balance_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 36199793c..6daeec194 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -567,13 +567,6 @@ D_06000C98 = 0x06000C98; D_060003A0 = 0x060003A0; D_06000E00 = 0x06000E00; -// ovl_Bg_Dblue_Balance - -D_0600CD10 = 0x0600CD10; -D_0600CE00 = 0x0600CE00; -D_0600D110 = 0x0600D110; -D_0600D250 = 0x0600D250; - // ovl_Bg_Dblue_Elevator D_060002C8 = 0x060002C8; From ba1595b5ad5c0497ba8ac0c482f5d8955d777cbb Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 27 Mar 2022 15:17:15 +0100 Subject: [PATCH 131/257] En_Hanabi (#728) * En_Hanabi * PR --- spec | 3 +- .../actors/ovl_En_Hanabi/z_en_hanabi.c | 323 ++++++++++++++++-- .../actors/ovl_En_Hanabi/z_en_hanabi.h | 21 +- tools/disasm/functions.txt | 2 +- 4 files changed, 326 insertions(+), 23 deletions(-) diff --git a/spec b/spec index 9cc8086bd..292fe429a 100644 --- a/spec +++ b/spec @@ -3894,8 +3894,7 @@ beginseg name "ovl_En_Hanabi" compress include "build/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.o" - include "build/data/ovl_En_Hanabi/ovl_En_Hanabi.data.o" - include "build/data/ovl_En_Hanabi/ovl_En_Hanabi.reloc.o" + include "build/src/overlays/actors/ovl_En_Hanabi/ovl_En_Hanabi_reloc.o" endseg beginseg 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 2b15971bf..7d485ce61 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -5,6 +5,7 @@ */ #include "z_en_hanabi.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -18,8 +19,8 @@ void func_80B23894(EnHanabi* this, GlobalContext* globalCtx); void func_80B238D4(EnHanabi* this, GlobalContext* globalCtx); void func_80B23910(EnHanabi* this, GlobalContext* globalCtx); void func_80B23934(EnHanabi* this, GlobalContext* globalCtx); +void EnHanabi_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Hanabi_InitVars = { ACTOR_EN_HANABI, ACTORCAT_ITEMACTION, @@ -32,38 +33,322 @@ const ActorInit En_Hanabi_InitVars = { (ActorFunc)NULL, }; -#endif +Vec3s D_80B23AA0[] = { + { 85, 14, 49 }, { 70, -70, 0 }, { 85, 14, -49 }, { 90, -32, 28 }, { 90, -32, -28 }, { 98, 16, 0 }, + { 70, 70, 0 }, { 84, 45, 26 }, { 84, 45, -26 }, { 50, -50, 70 }, { 73, -19, 64 }, { 65, -65, 38 }, + { 50, -50, -70 }, { 65, -65, -38 }, { 73, -19, -64 }, { 0, 0, -100 }, { 14, 85, -49 }, { 49, 8, -86 }, + { 8, 49, -86 }, { 57, 57, -57 }, { 45, 84, -26 }, { 27, -27, -92 }, { -50, 50, -70 }, { -27, 27, -92 }, + { -19, 73, -64 }, { -70, 70, 0 }, { 14, 85, 49 }, { -32, 90, -28 }, { -32, 90, 28 }, { 16, 98, 0 }, + { 45, 84, 26 }, { -65, 65, -38 }, { -50, 50, 70 }, { -65, 65, 38 }, { -19, 73, 64 }, { 0, 0, 100 }, + { 8, 49, 86 }, { 49, 8, 86 }, { 57, 57, 57 }, { -27, 27, 92 }, { 27, -27, 92 }, { -14, -85, -49 }, + { -14, -85, 49 }, { 32, -90, -28 }, { 32, -90, 28 }, { -16, -98, 0 }, { -70, -70, 0 }, { -45, -84, -26 }, + { -45, -84, 26 }, { 19, -73, -64 }, { 19, -73, 64 }, { -85, -14, -49 }, { -49, -8, -86 }, { -8, -49, -86 }, + { -57, -57, -57 }, { -84, -45, -26 }, { -73, 19, -64 }, { -85, -14, 49 }, { -90, 32, 28 }, { -90, 32, -28 }, + { -98, -16, 0 }, { -84, -45, 26 }, { -73, 19, 64 }, { -8, -49, 86 }, { -49, -8, 86 }, { -57, -57, 57 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22C00.s") +u8 D_80B23C2C[] = { + 255, 255, 200, 255, 200, 255, 200, 255, 255, 255, 200, 200, 200, 255, 200, 200, 200, 255, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22C2C.s") +u8 D_80B23C40[] = { + 200, 200, 0, 200, 0, 200, 0, 200, 200, 200, 0, 0, 0, 200, 0, 0, 200, 200, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22C80.s") +void func_80B22C00(EnHanabiStruct* arg0) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22E0C.s") + for (i = 0; i < 400; i++, arg0++) { + arg0->unk_00 = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22F34.s") +void func_80B22C2C(EnHanabiStruct* arg0, s32 arg1) { + arg0->unk_01 = (s32)Rand_ZeroFloat(20.0f) + 60; + arg0->unk_02 = arg1; + arg0->unk_14.x = 0.7f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22FA8.s") +s32 func_80B22C80(Vec3f* arg0, EnHanabiStruct* arg1, f32 arg2) { + Vec3s* phi_s1 = &D_80B23AA0[0]; + f32 temp_f22 = (Rand_ZeroFloat(0.2f) + 0.6f) * arg2; + s32 temp_s6 = (s32)Rand_ZeroFloat(6.0f) * 3; + s32 i; + s32 j; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/EnHanabi_Init.s") + for (i = 0, j = 0; j < ARRAY_COUNT(D_80B23AA0) && i < 400; i++, arg1++) { + if (arg1->unk_00 <= 0) { + arg1->unk_00 = 1; + Math_Vec3f_Copy(&arg1->unk_08, arg0); + arg1->unk_20.x = phi_s1->x * temp_f22; + arg1->unk_20.y = (phi_s1->y * temp_f22) + 50.0f; + arg1->unk_20.z = phi_s1->z * temp_f22; + arg1->unk_04 = 1.5f * arg2; + func_80B22C2C(arg1, temp_s6); + phi_s1++; + j++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/EnHanabi_Destroy.s") + return temp_s6; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B234C8.s") +void func_80B22E0C(EnHanabiStruct* arg0) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B235CC.s") + for (i = 0; i < 400; i++, arg0++) { + if (arg0->unk_00 == 1) { + arg0->unk_08.x += arg0->unk_20.x; + arg0->unk_08.y += arg0->unk_20.y; + arg0->unk_08.z += arg0->unk_20.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B236C8.s") + arg0->unk_20.x *= arg0->unk_14.x; + arg0->unk_20.z *= arg0->unk_14.x; + arg0->unk_20.y *= arg0->unk_14.x; + arg0->unk_20.y -= 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B23894.s") + arg0->unk_20.x += randPlusMinusPoint5Scaled(0.8f); + arg0->unk_20.y += randPlusMinusPoint5Scaled(0.8f); + arg0->unk_20.z += randPlusMinusPoint5Scaled(0.8f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B238D4.s") + if (arg0->unk_01 > 0) { + arg0->unk_01--; + } else { + arg0->unk_00 = 0; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B23910.s") +s32 func_80B22F34(EnHanabiStruct* arg0) { + s32 count = 0; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B23934.s") + for (i = 0; i < 400; i++, arg0++) { + if (arg0->unk_00 == 1) { + count++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/EnHanabi_Update.s") + return count; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B23A38.s") +void func_80B22FA8(EnHanabiStruct* arg0, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s32 i; + u8 sp53; + + OPEN_DISPS(gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB10); + + sp53 = 0xFF; + if (sp53) {} + + for (i = 0; i < 400; i++, arg0++) { + if (arg0->unk_00 == 1) { + Matrix_InsertTranslation(arg0->unk_08.x, arg0->unk_08.y, arg0->unk_08.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + if (arg0->unk_01 < 40) { + Matrix_Scale(arg0->unk_04 * 0.025f * arg0->unk_01, arg0->unk_04 * 0.025f * arg0->unk_01, 1.0f, + MTXMODE_APPLY); + } else { + Matrix_Scale(arg0->unk_04, arg0->unk_04, 1.0f, MTXMODE_APPLY); + } + Matrix_InsertZRotation_s(globalCtx->gameplayFrames * 4864, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (sp53 != arg0->unk_02) { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, D_80B23C40[arg0->unk_02], D_80B23C40[arg0->unk_02 + 1], + D_80B23C40[arg0->unk_02 + 2], 255); + + sp53 = arg0->unk_02; + } + + if (arg0->unk_01 < 6) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80B23C2C[arg0->unk_02], D_80B23C2C[arg0->unk_02 + 1], + D_80B23C2C[arg0->unk_02 + 2], arg0->unk_01 * 50); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80B23C2C[arg0->unk_02], D_80B23C2C[arg0->unk_02 + 1], + D_80B23C2C[arg0->unk_02 + 2], 255); + } + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB58); + } + } + + CLOSE_DISPS(gfxCtx); +} + +void EnHanabi_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnHanabi* this = THIS; + s32 i; + + if (1) {} + + Actor_SetScale(thisx, 1.0f); + this->actionFunc = func_80B23910; + this->unk_144 = 0; + func_80B22C00(this->unk_148); + + for (i = 0; i < ARRAY_COUNT(this->unk_4608); i++) { + Lights_PointNoGlowSetInfo(&this->unk_4608[i], thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 255, + 255, 255, -1); + this->unk_4634[i] = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->unk_4608[i]); + } + + if (ENHANABI_GET_1F(thisx) == ENHANABI_1F_1) { + this->actionFunc = func_80B23934; + this->actor.home.rot.x = 0x384; + } +} + +void EnHanabi_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnHanabi* this = THIS; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_4634); i++) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->unk_4634[i]); + } +} + +void func_80B234C8(EnHanabi* this) { + s16 phi_v1; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_4640); i++) { + if (this->unk_4640[i] > 0) { + this->unk_4640[i]--; + if (this->unk_4640[i] == 0) { + phi_v1 = -1; + } else { + if (this->unk_4640[i] >= 0xA) { + phi_v1 = 0x3E8; + } else { + phi_v1 = this->unk_4640[i] * 0x64; + } + + if (this->actor.home.rot.x >= 0x259) { + phi_v1 *= 2; + } + } + + Lights_PointSetColorAndRadius(&this->unk_4608[i], D_80B23C2C[this->unk_4648[i]], + D_80B23C2C[this->unk_4648[i] + 1], D_80B23C2C[this->unk_4648[i] + 2], phi_v1); + } + } +} + +void func_80B235CC(EnHanabi* this, Vec3f* arg1, s32 arg2) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_4640); i++) { + if (this->unk_4640[i] == 0) { + this->unk_4648[i] = arg2; + Lights_PointNoGlowSetInfo(&this->unk_4608[i], arg1->x, arg1->y, arg1->z, D_80B23C2C[arg2], + D_80B23C2C[arg2 + 1], D_80B23C2C[arg2 + 2], 0x3E8); + this->unk_4640[i] = 20; + break; + } + } +} + +void func_80B236C8(EnHanabi* this, GlobalContext* globalCtx) { + Vec3f sp34; + f32 sp30; + s32 pad; + s32 sp28; + + this->actor.draw = EnHanabi_Draw; + func_80B234C8(this); + if (this->actor.home.rot.x != 0) { + if (this->unk_144 > 0) { + this->unk_144--; + return; + } + + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + + if (this->actor.home.rot.x != 0) { + sp30 = Rand_ZeroFloat(200.0f) + this->actor.home.rot.x; + } else { + sp30 = Rand_ZeroFloat(200.0f) + 300.0f; + } + + sp34.x += sp30 * Math_SinS(this->actor.home.rot.y); + sp34.y += randPlusMinusPoint5Scaled(300.0f); + sp34.z += sp30 * Math_CosS(this->actor.home.rot.y); + + if (this->actor.home.rot.x >= 0x259) { + sp28 = func_80B22C80(&sp34, this->unk_148, 2.0f); + } else { + sp28 = func_80B22C80(&sp34, this->unk_148, 1.0f); + } + + this->actor.home.rot.y += (s16)((Rand_ZeroFloat(40.0f) + 80.0f) * 256.0f); + this->unk_144 = (s32)Rand_ZeroFloat(5.0f) + 20; + Actor_PlaySfxAtPos(&this->actor, NA_SE_OC_FIREWORKS); + func_80B235CC(this, &sp34, sp28); + } +} + +void func_80B23894(EnHanabi* this, GlobalContext* globalCtx) { + func_80B236C8(this, globalCtx); + if (func_80B22F34(this->unk_148) == 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80B238D4(EnHanabi* this, GlobalContext* globalCtx) { + func_80B236C8(this, globalCtx); + if (this->actor.home.rot.x == 0) { + this->actionFunc = func_80B23894; + } +} + +void func_80B23910(EnHanabi* this, GlobalContext* globalCtx) { + if (this->actor.home.rot.x != 0) { + this->actionFunc = func_80B238D4; + } +} + +void func_80B23934(EnHanabi* this, GlobalContext* globalCtx) { + if ((gSaveContext.entranceIndex == 0x5410) && (gSaveContext.sceneSetupIndex == 7)) { + if (globalCtx->csCtx.frames > 1650) { + func_80B236C8(this, globalCtx); + func_800B8FE8(&this->actor, NA_SE_EV_FIREWORKS_LAUNCH - SFX_FLAG); + } + } + + if ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7) && + (globalCtx->csCtx.currentCsIndex == 0) && (globalCtx->csCtx.frames == 610)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KYOJIN_GROAN); + } +} + +void EnHanabi_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHanabi* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80B22E0C(this->unk_148); +} + +void EnHanabi_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHanabi* this = THIS; + + Matrix_StatePush(); + func_80B22FA8(this->unk_148, globalCtx); + Matrix_StatePop(); +} diff --git a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.h b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.h index 78f198ed4..ed4963daf 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.h +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.h @@ -7,9 +7,28 @@ struct EnHanabi; typedef void (*EnHanabiActionFunc)(struct EnHanabi*, GlobalContext*); +#define ENHANABI_GET_1F(thisx) ((thisx)->params & 0x1F) + +#define ENHANABI_1F_1 1 + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 unk_01; + /* 0x02 */ u8 unk_02; + /* 0x04 */ f32 unk_04; + /* 0x08 */ Vec3f unk_08; + /* 0x14 */ Vec3f unk_14; + /* 0x20 */ Vec3f unk_20; +} EnHanabiStruct; // size = 0x2C + typedef struct EnHanabi { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4510]; + /* 0x0144 */ s16 unk_144; + /* 0x0148 */ EnHanabiStruct unk_148[400]; + /* 0x4608 */ LightInfo unk_4608[3]; + /* 0x4634 */ LightNode* unk_4634[3]; + /* 0x4640 */ s16 unk_4640[3]; + /* 0x4648 */ s32 unk_4648[3]; /* 0x4654 */ EnHanabiActionFunc actionFunc; } EnHanabi; // size = 0x4658 diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 6d638b031..00e0a1be3 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -13267,7 +13267,7 @@ 0x80B23910:("func_80B23910",), 0x80B23934:("func_80B23934",), 0x80B239FC:("EnHanabi_Update",), - 0x80B23A38:("func_80B23A38",), + 0x80B23A38:("EnHanabi_Draw",), 0x80B23D50:("func_80B23D50",), 0x80B23DD0:("func_80B23DD0",), 0x80B23E10:("ObjDowsing_Init",), From 35bc48de5499a9191bb9c96704c0865da1493229 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 27 Mar 2022 15:22:16 +0100 Subject: [PATCH 132/257] En_Maruta (#725) * En_Maruta * Match (thanks petrie) Co-authored-by: Anghelo Carvajal --- spec | 3 +- .../actors/ovl_En_Maruta/z_en_maruta.c | 635 ++++++++++++++++-- .../actors/ovl_En_Maruta/z_en_maruta.h | 15 +- undefined_syms.txt | 4 - 4 files changed, 607 insertions(+), 50 deletions(-) diff --git a/spec b/spec index 292fe429a..5e17fed56 100644 --- a/spec +++ b/spec @@ -3993,8 +3993,7 @@ beginseg name "ovl_En_Maruta" compress include "build/src/overlays/actors/ovl_En_Maruta/z_en_maruta.o" - include "build/data/ovl_En_Maruta/ovl_En_Maruta.data.o" - include "build/data/ovl_En_Maruta/ovl_En_Maruta.reloc.o" + include "build/src/overlays/actors/ovl_En_Maruta/ovl_En_Maruta_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c index 0c736886e..9d6f6312e 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c @@ -5,6 +5,8 @@ */ #include "z_en_maruta.h" +#include "overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h" +#include "objects/object_maruta/object_maruta.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_10) @@ -15,16 +17,25 @@ void EnMaruta_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMaruta_Update(Actor* thisx, GlobalContext* globalCtx); void EnMaruta_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B372B8(EnMaruta* this); void func_80B372CC(EnMaruta* this, GlobalContext* globalCtx); +void func_80B37364(EnMaruta* this); void func_80B3738C(EnMaruta* this, GlobalContext* globalCtx); +void func_80B373F4(EnMaruta* this); void func_80B37428(EnMaruta* this, GlobalContext* globalCtx); void func_80B374FC(EnMaruta* this, GlobalContext* globalCtx); +void func_80B37590(EnMaruta* this, GlobalContext* globalCtx); void func_80B37950(EnMaruta* this, GlobalContext* globalCtx); void func_80B379C0(EnMaruta* this, GlobalContext* globalCtx); +void func_80B37A14(EnMaruta* this); void func_80B37A64(EnMaruta* this, GlobalContext* globalCtx); void func_80B37AA0(EnMaruta* this, GlobalContext* globalCtx); +void func_80B37C04(s16* arg0); +void func_80B37EC0(EnMaruta* this, GlobalContext* globalCtx); +void func_80B38060(EnMaruta* this, Vec3f* arg1); +void func_80B3828C(Vec3f* arg0, Vec3f* arg1, s16 arg2, s16 arg3, s32 arg4); +void func_80B382E4(GlobalContext* globalCtx, Vec3f arg1); -#if 0 const ActorInit En_Maruta_InitVars = { ACTOR_EN_MARUTA, ACTORCAT_PROP, @@ -37,15 +48,94 @@ const ActorInit En_Maruta_InitVars = { (ActorFunc)EnMaruta_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B38AFC = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +Gfx* D_80B386A0[] = { + object_maruta_DL_002220, object_maruta_DL_0023D0, object_maruta_DL_002568, object_maruta_DL_002660, + object_maruta_DL_002758, object_maruta_DL_002850, object_maruta_DL_002948, object_maruta_DL_002AE0, +}; + +u8 D_80B386C0[] = { + 0xFF, 0x2B, 0xD4, 0x17, 0xE8, 0x55, 0xAA, 0x0F, 0xF0, +}; + +s32 D_80B386CC[] = { + 5, 5, 3, 3, 7, 7, 7, 7, 3, 3, 3, 3, 7, 7, 3, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, +}; + +Vec3f D_80B38754 = { -2.0f, 3.0f, 0.0f }; +Vec3f D_80B38760 = { -2.0f, 3.0f, 0.0f }; +Vec3f D_80B3876C = { 2.0f, 3.0f, 0.0f }; +Vec3f D_80B38778 = { -2.0f, 10.0f, 0.0f }; +Vec3f D_80B38784 = { -2.5f, 5.0f, 0.0f }; +Vec3f D_80B38790 = { -3.0f, 10.0f, 0.0f }; +Vec3f D_80B3879C = { 2.5f, 5.0f, 0.0f }; +Vec3f D_80B387A8 = { 3.0f, 10.0f, 0.0f }; +Vec3f D_80B387B4 = { -1.0f, 7.0f, -1.0f }; +Vec3f D_80B387C0 = { 1.0f, 7.0f, -1.0f }; +Vec3f D_80B387CC = { 0.0f, 8.0f, -1.5f }; +Vec3f D_80B387D8 = { 0.0f, 8.0f, -1.5f }; + +Vec3f D_80B387E4[] = { + { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { -10.0f, 460.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f }, { 10.0f, 460.0f, 0.0f }, { -40.0f, 315.0f, 0.0f }, + { 40.0f, 315.0f, 0.0f }, { 0.0f, 140.0f, 0.0f }, { 0.0f, 445.0f, 0.0f }, +}; + +Vec3f D_80B38850[] = { + { 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, -1.0f }, { 0.0f, 0.0f, -1.0f }, { 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, 1.0f }, + { 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, -1.0f }, { -1.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 1.0f }, +}; + +Vec3f D_80B388BC[] = { + { 90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, 78.0f }, { 90.0f, 630.0f, 78.0f }, + { 90.0f, 350.0f, -78.0f }, { -90.0f, 170.0f, -78.0f }, { -90.0f, 170.0f, 78.0f }, { 90.0f, 350.0f, 78.0f }, +}; + +Vec3f D_80B3891C[] = { + { 90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, 78.0f }, { 90.0f, 630.0f, 78.0f }, + { 90.0f, 170.0f, -78.0f }, { -90.0f, 350.0f, -78.0f }, { -90.0f, 350.0f, 78.0f }, { 90.0f, 170.0f, 78.0f }, +}; + +Vec3f D_80B3897C[] = { + { 0.0f, 630.0f, -104.0f }, { -90.0f, 630.0f, -52.0f }, { -90.0f, 630.0f, 52.0f }, { 0.0f, 630.0f, 104.0f }, + { 0.0f, 0.0f, -104.0f }, { -90.0f, 0.0f, -52.0f }, { -90.0f, 0.0f, 52.0f }, { 0.0f, 0.0f, 104.0f }, +}; + +Vec3f D_80B389DC[] = { + { 0.0f, 630.0f, -104.0f }, { 90.0f, 630.0f, -52.0f }, { 90.0f, 630.0f, 52.0f }, { 0.0f, 630.0f, 104.0f }, + { 0.0f, 0.0f, -104.0f }, { 90.0f, 0.0f, -52.0f }, { 90.0f, 0.0f, 52.0f }, { 0.0f, 0.0f, 104.0f }, +}; + +Vec3f D_80B38A3C[] = { + { 90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, 78.0f }, { 90.0f, 630.0f, 78.0f }, + { 90.0f, 260.0f, -78.0f }, { -90.0f, 260.0f, -78.0f }, { -90.0f, 260.0f, 78.0f }, { 90.0f, 260.0f, 78.0f }, +}; + +Vec3f D_80B38A9C[] = { + { 90.0f, 260.0f, -78.0f }, { -90.0f, 260.0f, -78.0f }, { -90.0f, 260.0f, 78.0f }, { 90.0f, 260.0f, 78.0f }, + { 90.0f, 20.0f, -78.0f }, { -90.0f, 20.0f, -78.0f }, { -90.0f, 20.0f, 78.0f }, { 90.0f, 20.0f, 78.0f }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 12, 65, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B38B28 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -80,71 +170,530 @@ static DamageTable D_80B38B28 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B38B48 = { 8, 0, 0, 0, MASS_HEAVY }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; -#endif +Vec3f D_80B38B54 = { 0.0f, 0.0f, 0.0f }; -extern ColliderCylinderInit D_80B38AFC; -extern DamageTable D_80B38B28; -extern CollisionCheckInfoInit2 D_80B38B48; +void EnMaruta_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnMaruta* this = THIS; + s32 i; -extern UNK_TYPE D_06002EC0; + Actor_SetScale(&this->actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/EnMaruta_Init.s") + this->actor.targetMode = 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/EnMaruta_Destroy.s") + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 50.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B372B8.s") + this->actor.colChkInfo.health = 1; + this->actor.world.pos.y -= 4.0f; + this->actor.home.pos.y -= 4.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B372CC.s") + this->unk_210 = ENMARUTA_GET_FF00(&this->actor); + this->unk_218 = 0; + this->unk_21A = 0; + this->unk_1A0 = NULL; + this->unk_21C = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37364.s") + this->unk_194.x = 0.0f; + this->unk_194.y = 0.0f; + this->unk_194.z = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B3738C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_1A4); i++) { + this->unk_1A4[i] = D_80B38B54; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B373F4.s") + this->unk_214 = -1; + this->unk_220 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37428.s") + if (this->unk_210 == 0) { + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B374B8.s") + if (this->unk_210 == 0) { + if (ENMARUTA_GET_FF(&this->actor) == 0xFF) { + func_80B372B8(this); + } else { + func_80B37364(this); + } + } else { + func_80B37590(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B374FC.s") +void EnMaruta_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMaruta* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37590.s") + if (this->unk_210 == 0) { + Collider_DestroyCylinder(globalCtx, &this->collider); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37950.s") +void func_80B372B8(EnMaruta* this) { + this->actionFunc = func_80B372CC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37998.s") +void func_80B372CC(EnMaruta* this, GlobalContext* globalCtx) { + s16 temp_v1 = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B379C0.s") + if (temp_v1 > 0x1555) { + this->actor.shape.rot.y += 0x2AAA; + } else if (temp_v1 < -0x1555) { + this->actor.shape.rot.y -= 0x2AAA; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37A14.s") + if (this->unk_220 == 1) { + func_80B373F4(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37A64.s") + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_KENDO_JS)) { + EnKendoJs* kendoJs = (EnKendoJs*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37A8C.s") + kendoJs->unk_292 = this->actor.isTargeted; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37AA0.s") +void func_80B37364(EnMaruta* this) { + this->actor.world.pos.y = this->actor.home.pos.y - 630.0f; + this->actionFunc = func_80B3738C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37B78.s") +void func_80B3738C(EnMaruta* this, GlobalContext* globalCtx) { + if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.4f, 100.0f, 10.0f) == 0.0f) { + func_80B372B8(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37C04.s") +void func_80B373F4(EnMaruta* this) { + this->collider.base.acFlags |= AC_HIT; + this->actor.velocity.y = 0.0f; + this->actor.gravity = -2.0f; + this->actionFunc = func_80B37428; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37C60.s") +void func_80B37428(EnMaruta* this, GlobalContext* globalCtx) { + if ((this->actor.floorHeight - 630.0f) < this->actor.world.pos.y) { + this->actor.velocity.y += this->actor.gravity; + this->actor.world.pos.y += this->actor.velocity.y; + } else { + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_KENDO_JS)) { + EnKendoJs* kendoJs = (EnKendoJs*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37CA0.s") + kendoJs->unk_28C--; + } + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37EC0.s") +void func_80B374B8(EnMaruta* this) { + this->actor.flags &= ~ACTOR_FLAG_1; + if (this->actionFunc != func_80B37428) { + this->unk_21E = 0; + this->actor.gravity = -2.0f; + this->actionFunc = func_80B374FC; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B38028.s") +void func_80B374FC(EnMaruta* this, GlobalContext* globalCtx) { + if (this->unk_21E == 40) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B38060.s") + if (((this->actor.floorHeight - 630.0f) < this->actor.world.pos.y) && (this->unk_21E > 30)) { + this->actor.velocity.y += this->actor.gravity; + this->actor.world.pos.y += this->actor.velocity.y; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B3828C.s") + this->unk_21E++; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B382E4.s") +void func_80B37590(EnMaruta* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp48; + s16 sp46; + Vec3f sp38; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/EnMaruta_Update.s") + this->unk_21E = 0; + this->unk_21C = 0; + this->actor.gravity = -2.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/EnMaruta_Draw.s") + switch (this->unk_210) { + case 2: + sp48 = D_80B38754; + this->unk_1A0 = D_80B388BC; + break; + + case 4: + if (player->swordAnimation == 8) { + sp48 = D_80B3876C; + } else { + sp48 = D_80B38778; + } + this->unk_1A0 = D_80B3891C; + break; + + case 5: + if (player->swordAnimation == 0) { + sp48 = D_80B38784; + } else { + sp48 = D_80B38790; + } + this->unk_1A0 = D_80B3897C; + break; + + case 6: + if (player->swordAnimation == 0) { + sp48 = D_80B3879C; + } else { + sp48 = D_80B387A8; + } + this->unk_1A0 = D_80B389DC; + break; + + case 8: + if (player->swordAnimation == 4) { + sp48 = D_80B387B4; + } else { + sp48 = D_80B387C0; + } + this->unk_1A0 = D_80B38A3C; + break; + + case 7: + sp48 = D_80B387CC; + this->unk_1A0 = D_80B38A9C; + break; + + default: + sp48 = D_80B38B54; + break; + } + + sp46 = this->actor.shape.rot.y; + this->actor.velocity.x = (sp48.x * Math_CosS(sp46) + (Math_SinS(sp46) * sp48.z)); + this->actor.velocity.y = sp48.y; + this->actor.velocity.z = (-sp48.x * Math_SinS(sp46) + (Math_CosS(sp46) * sp48.z)); + + sp38 = D_80B38850[this->unk_210]; + + func_80B3828C(&sp38, &this->unk_194, Rand_Next() & 0xFFF, Rand_Next() & 0xFFF, 0); + this->unk_21A = Rand_Next() & 0x7FF; + + if (this->unk_210 == 7) { + this->unk_21A |= 0x3F; + } else { + this->unk_21A |= 0xFF; + } + + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = func_80B37950; +} + +void func_80B37950(EnMaruta* this, GlobalContext* globalCtx) { + this->unk_218 += this->unk_21A; + this->actor.velocity.y += this->actor.gravity; + func_80B37EC0(this, globalCtx); + Actor_UpdatePos(&this->actor); +} + +void func_80B37998(EnMaruta* this) { + this->unk_21E = 0; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->unk_21A = 0; + this->actionFunc = func_80B379C0; +} + +void func_80B379C0(EnMaruta* this, GlobalContext* globalCtx) { + if (this->unk_21E == 40) { + func_80B37A14(this); + } else { + this->unk_21E++; + } + func_80B37C04(&this->unk_218); +} + +void func_80B37A14(EnMaruta* this) { + s16 temp = this->unk_218 & 0x7FFF; + + if (((this->unk_210 == 5) || (this->unk_210 == 6)) && !temp) { + this->unk_21E = 100; + } else { + this->unk_21E = 0; + } + this->actionFunc = func_80B37A64; +} + +void func_80B37A64(EnMaruta* this, GlobalContext* globalCtx) { + if (this->unk_21E > 100) { + this->actor.colChkInfo.health = 0; + } else { + this->unk_21E++; + } +} + +void func_80B37A8C(EnMaruta* this) { + this->actionFunc = func_80B37AA0; +} + +void func_80B37AA0(EnMaruta* this, GlobalContext* globalCtx) { + if (this->actor.scale.y == 0.0f) { + if (this->actor.scale.x == 0.0f) { + Actor_MarkForDeath(&this->actor); + return; + } + Math_SmoothStepToF(&this->actor.scale.x, 0.0f, 0.2f, 0.01f, 0.001f); + Math_SmoothStepToF(&this->actor.scale.z, 0.0f, 0.2f, 0.01f, 0.001f); + } else { + Math_SmoothStepToF(&this->actor.scale.y, 0.0f, 0.2f, 0.003f, 0.001f); + } +} + +s32 func_80B37B78(EnMaruta* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 temp_v1 = BINANG_SUB(this->actor.yawTowardsPlayer, 0x8000); + + temp_v1 = BINANG_SUB(temp_v1, player->actor.shape.rot.y); + if ((ABS_ALT(temp_v1) < 0x1555) || + ((player->swordState != 0) && ((player->swordAnimation == 4) || (player->swordAnimation == 6) || + (player->swordAnimation == 0x1E) || (player->swordAnimation == 0x20)))) { + return true; + } + return false; +} + +void func_80B37C04(s16* arg0) { + s16 temp_a1 = *arg0 & 0xC000; + s16 temp = *arg0 & 0x3FFF; + + if (temp > 0x2000) { + temp_a1 += 0x4000; + } + Math_SmoothStepToS(arg0, temp_a1, 1, 0xAAA, 0xB6); +} + +void func_80B37C60(EnMaruta* this) { + if ((this->actionFunc != func_80B37AA0) && (this->actor.colChkInfo.health == 0)) { + func_80B37A8C(this); + } +} + +void func_80B37CA0(EnMaruta* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((this->actionFunc == func_80B372CC) || (this->actionFunc == func_80B3738C) || + (this->actionFunc == func_80B374FC) || (this->actionFunc == func_80B37AA0) || + ((this->actionFunc == func_80B37428) && !(this->actor.world.pos.y < (this->actor.floorHeight - 20.0f)))) { + if ((this->collider.base.acFlags & AC_HIT) && (this->actionFunc == func_80B372CC)) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SWORD_STRIKE); + + if (D_80B386CC[player->swordAnimation] != 0) { + s32 temp = D_80B386CC[player->swordAnimation] + 1; + + temp = (temp << 8) & 0xFF00; + this->unk_210 = D_80B386CC[player->swordAnimation]; + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_MARUTA, + this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, + this->actor.shape.rot.y, 0, temp); + this->actor.world.rot.y = this->actor.shape.rot.y; + if ((this->unk_210 == 5) || ((this->unk_210 == 7) && (player->swordAnimation == 0xC))) { + func_80B37590(this, globalCtx); + } else { + func_80B374B8(this); + } + + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_KENDO_JS)) { + EnKendoJs* kendoJs = (EnKendoJs*)this->actor.parent; + + kendoJs->unk_28E = 1; + kendoJs->unk_28C--; + } + return; + } + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (func_80B37B78(this, globalCtx) && (this->actionFunc == func_80B372CC)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void func_80B37EC0(EnMaruta* this, GlobalContext* globalCtx) { + Vec3f sp34 = this->unk_204; + s32 phi_a2 = -1; + s32 i; + f32 temp; + + for (i = 0; i < ARRAY_COUNT(this->unk_1A4); i++) { + if (this->unk_1A4[i].y < sp34.y) { + sp34 = this->unk_1A4[i]; + phi_a2 = i; + } + this->unk_214 = phi_a2; + } + + if (sp34.y < this->actor.floorHeight) { + this->unk_218 -= this->unk_21A; + + temp = this->actor.floorHeight - sp34.y; + this->actor.velocity.y -= this->actor.gravity; + this->actor.velocity.x *= 0.6f; + this->actor.velocity.z *= 0.6f; + this->actor.world.pos.y += temp; + + if (this->actor.velocity.y < -this->actor.gravity) { + func_80B382E4(globalCtx, sp34); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_LOG_BOUND); + this->actor.velocity.y *= -0.6f; + func_80B38060(this, &sp34); + } + } +} + +f32 func_80B38028(Vec3f* arg0, Vec3f* arg1, Vec3f* arg2) { + f32 x0 = arg0->x; + f32 z0 = arg0->z; + f32 dx = arg2->x - arg1->x; + f32 dz = arg2->z - arg1->z; + + return z0 * dx - x0 * dz; +} + +void func_80B38060(EnMaruta* this, Vec3f* arg1) { + Vec3f sp44; + s32 pad; + f32 temp_f0; + f32 phi_f2; + + func_80B3828C(&this->unk_194, &sp44, 0, this->actor.shape.rot.y, 0); + temp_f0 = func_80B38028(&sp44, &this->unk_204, arg1); + + if ((this->unk_210 == 5) || (this->unk_210 == 6)) { + phi_f2 = 8.0f; + } else if (this->unk_210 == 4) { + phi_f2 = 5.0f; + } else { + phi_f2 = 2.0f; + } + + if ((temp_f0 < phi_f2) && (-phi_f2 < temp_f0)) { + phi_f2 = 3.0f; + } else { + phi_f2 = 1.2f; + } + + if (temp_f0 > 0.0f) { + if (this->unk_21A > 0) { + this->unk_21A *= phi_f2; + } else { + this->unk_21A *= -0.8f; + } + } else { + if (this->unk_21A > 0) { + this->unk_21A *= -0.8f; + } else { + this->unk_21A *= phi_f2; + } + } + + if ((ABS_ALT(this->unk_21A) < 0x38E) && + (((this->unk_218 & 0x3FFF) < 0x71C) || ((this->unk_218 & 0x3FFF) >= 0x38E4))) { + this->actor.gravity *= 0.8f; + this->unk_21C++; + if (this->unk_21C == 2) { + func_80B37998(this); + } + } else if (ABS_ALT(this->unk_21A) > 0x38E) { + if (this->unk_21A < 0) { + this->unk_21A = -0x38E; + } else { + this->unk_21A = 0x38E; + } + } +} + +void func_80B3828C(Vec3f* arg0, Vec3f* arg1, s16 arg2, s16 arg3, s32 arg4) { + Matrix_StatePush(); + Matrix_InsertRotation(arg2, arg3, arg4, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(arg0, arg1); + Matrix_StatePop(); +} + +void func_80B382E4(GlobalContext* globalCtx, Vec3f arg1) { + Vec3f sp84 = arg1; + Vec3f sp78; + Vec3f sp6C; + Color_RGBA8 sp68 = { 170, 130, 90, 255 }; + Color_RGBA8 sp64 = { 100, 60, 20, 255 }; + s32 i; + + sp6C.y = 0.0f; + sp84.y += 15.0f; + + for (i = 0; i < 10; i++) { + sp78.x = Rand_Centered() * 10.0f; + sp78.y = 2.0f * Rand_ZeroOne(); + sp78.z = Rand_Centered() * 10.0f; + sp6C.x = -0.2f * sp78.x; + sp6C.z = -0.2f * sp78.z; + func_800B0EB0(globalCtx, &sp84, &sp78, &sp6C, &sp68, &sp64, 60, 20, 10); + } +} + +void EnMaruta_Update(Actor* thisx, GlobalContext* globalCtx) { + EnMaruta* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80B37CA0(this, globalCtx); + func_80B37C60(this); +} + +void EnMaruta_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMaruta* this = THIS; + Vec3f sp50; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_210 == 0) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_maruta_DL_002EC0); + } else { + sp50 = D_80B387E4[this->unk_210]; + + Matrix_StatePush(); + Matrix_InsertTranslation(sp50.x, sp50.y, sp50.z, MTXMODE_APPLY); + Matrix_InsertRotationAroundUnitVector_s(this->unk_218, &this->unk_194, MTXMODE_APPLY); + Matrix_InsertTranslation(-sp50.x, -sp50.y, -sp50.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + for (i = 0; i < 8; i++) { + if (D_80B386C0[this->unk_210] & (1 << i)) { + gSPDisplayList(POLY_OPA_DISP++, D_80B386A0[i]); + } + } + + if (this->unk_1A0 != NULL) { + for (i = 0; i < ARRAY_COUNT(this->unk_1A4); i++) { + Matrix_MultiplyVector3fByState(&this->unk_1A0[i], &this->unk_1A4[i]); + } + Matrix_MultiplyVector3fByState(&sp50, &this->unk_204); + } + + Matrix_StatePop(); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h index 0fc546e4d..162618fc6 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h @@ -7,10 +7,23 @@ struct EnMaruta; typedef void (*EnMarutaActionFunc)(struct EnMaruta*, GlobalContext*); +#define ENMARUTA_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ENMARUTA_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + typedef struct EnMaruta { /* 0x0000 */ Actor actor; /* 0x0144 */ EnMarutaActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xD8]; + /* 0x0148 */ ColliderCylinder collider; + /* 0x0194 */ Vec3f unk_194; + /* 0x01A0 */ Vec3f* unk_1A0; + /* 0x01A4 */ Vec3f unk_1A4[8]; + /* 0x0204 */ Vec3f unk_204; + /* 0x0210 */ s32 unk_210; + /* 0x0214 */ s32 unk_214; + /* 0x0218 */ s16 unk_218; + /* 0x021A */ s16 unk_21A; + /* 0x021C */ s16 unk_21C; + /* 0x021E */ s16 unk_21E; /* 0x0220 */ s16 unk_220; } EnMaruta; // size = 0x224 diff --git a/undefined_syms.txt b/undefined_syms.txt index 6daeec194..6ea90b0f9 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1472,10 +1472,6 @@ D_06011740 = 0x06011740; D_06011BC0 = 0x06011BC0; D_06011E48 = 0x06011E48; -// ovl_En_Maruta - -D_06002EC0 = 0x06002EC0; - // ovl_En_Mnk D_06003584 = 0x06003584; From 38eef9252ed9a578eb3f64367bd6db36d40189a9 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 27 Mar 2022 15:27:09 +0100 Subject: [PATCH 133/257] En_Kbt (#732) * En_Kbt * PR * a --- assets/xml/objects/object_kbt.xml | 8 +- spec | 3 +- src/overlays/actors/ovl_En_Kbt/z_en_kbt.c | 546 +++++++++++++++++++++- src/overlays/actors/ovl_En_Kbt/z_en_kbt.h | 12 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 5 - 6 files changed, 549 insertions(+), 29 deletions(-) diff --git a/assets/xml/objects/object_kbt.xml b/assets/xml/objects/object_kbt.xml index ec8dbd6ea..aad49e946 100644 --- a/assets/xml/objects/object_kbt.xml +++ b/assets/xml/objects/object_kbt.xml @@ -42,7 +42,13 @@ - + + + + + + + diff --git a/spec b/spec index 5e17fed56..0bc7d373f 100644 --- a/spec +++ b/spec @@ -3978,8 +3978,7 @@ beginseg name "ovl_En_Kbt" compress include "build/src/overlays/actors/ovl_En_Kbt/z_en_kbt.o" - include "build/data/ovl_En_Kbt/ovl_En_Kbt.data.o" - include "build/data/ovl_En_Kbt/ovl_En_Kbt.reloc.o" + include "build/src/overlays/actors/ovl_En_Kbt/ovl_En_Kbt_reloc.o" endseg beginseg 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 deedb3e78..afcaafbf3 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c @@ -15,10 +15,13 @@ void EnKbt_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKbt_Update(Actor* thisx, GlobalContext* globalCtx); void EnKbt_Draw(Actor* thisx, GlobalContext* globalCtx); +s32 func_80B33E64(GlobalContext* globalCtx); +s32 func_80B33E8C(GlobalContext* globalCtx); +void func_80B33EF0(EnKbt* this, s16 arg1); +Actor* func_80B3403C(GlobalContext* globalCtx); void func_80B34314(EnKbt* this, GlobalContext* globalCtx); void func_80B34598(EnKbt* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Kbt_InitVars = { ACTOR_EN_KBT, ACTORCAT_NPC, @@ -31,36 +34,543 @@ const ActorInit En_Kbt_InitVars = { (ActorFunc)EnKbt_Draw, }; -#endif +void EnKbt_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKbt* this = THIS; -extern UNK_TYPE D_06004274; + Actor_SetScale(&this->actor, 0.01f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_kbt_Skel_00DEE8, &object_kbt_Anim_004274, this->jointTable, + this->morphTable, OBJECT_KBT_LIMB_MAX); + this->unk_27C = 0; + this->actor.home.rot.z = 0; + this->unk_27E = 4; + this->unk_27F = 0; + this->unk_280 = 13; + this->unk_282 = 13; + this->unk_278 = func_80B3403C(globalCtx); + this->unk_284 = 0; + this->actor.textId = 0; + if (func_80B33E64(globalCtx)) { + func_80B33EF0(this, 6); + this->unk_282 = 11; + if (func_80B33E8C(globalCtx)) { + this->actor.textId = 0xC50; + } else { + this->actor.textId = 0xC4E; + this->unk_27C |= 1; + } + this->actionFunc = func_80B34314; + } else { + func_80B33EF0(this, 0); + this->unk_282 = 0; + this->actionFunc = func_80B34598; + } + this->actor.flags &= ~ACTOR_FLAG_1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/EnKbt_Init.s") +void EnKbt_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/EnKbt_Destroy.s") +s32 func_80B33E64(GlobalContext* globalCtx) { + return gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B33E64.s") +s32 func_80B33E8C(GlobalContext* globalCtx) { + if ((CURRENT_DAY == 3) || + ((CURRENT_DAY == 2) && (gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 2))) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B33E8C.s") +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, + }; + 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, + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B33EF0.s") + 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); + } else { + Animation_Change(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[arg1]), + sp38[arg1], -5.0f); + } + this->unk_280 = arg1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B3403C.s") +Actor* func_80B3403C(GlobalContext* globalCtx) { + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34078.s") + while (npc != NULL) { + if (npc->id == ACTOR_EN_KGY) { + return npc; + } + npc = npc->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B3415C.s") + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34314.s") +void func_80B34078(EnKbt* this) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_284 > 0) { + this->unk_284--; + } else { + switch (this->unk_280) { + case 2: + switch (this->unk_282) { + case 0: + func_80B33EF0(this, 12); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34574.s") + case 5: + this->actor.home.rot.z = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34598.s") + default: + func_80B33EF0(this, 5); + break; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/EnKbt_Update.s") + case 12: + func_80B33EF0(this, 0); + this->actor.home.rot.z = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B349C8.s") + case 4: + func_80B33EF0(this, 1); + this->unk_27E = 2; + this->actor.home.rot.z = 0; + break; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34A00.s") +void func_80B3415C(EnKbt* this) { + if (this->unk_27C & 2) { + if (this->unk_284 > 0) { + this->unk_284--; + } else { + this->unk_27F = 0; + this->unk_282 = 3; + this->unk_27C &= ~2; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/EnKbt_Draw.s") + switch (this->unk_282) { + case 0: + if ((this->unk_280 != 2) && (this->unk_280 != 12)) { + func_80B33EF0(this, 0); + } + break; + + case 1: + func_80B33EF0(this, 2); + this->unk_282 = 0; + break; + + case 2: + if (this->unk_280 != 12) { + func_80B33EF0(this, 3); + } + break; + + case 3: + if (this->unk_280 != 1) { + func_80B33EF0(this, 4); + } + break; + + case 10: + func_80B33EF0(this, 11); + break; + + case 4: + func_80B33EF0(this, 2); + this->unk_282 = 6; + break; + + case 6: + if (this->unk_280 != 2) { + func_80B33EF0(this, 5); + } + break; + + case 11: + func_80B33EF0(this, 6); + break; + + case 7: + if (this->unk_280 != 2) { + func_80B33EF0(this, 7); + } + break; + + case 8: + if (this->unk_280 != 2) { + func_80B33EF0(this, 8); + } + break; + + case 9: + if (this->unk_280 != 2) { + func_80B33EF0(this, 9); + } + break; + + case 12: + func_80B33EF0(this, 10); + break; + } +} + +void func_80B34314(EnKbt* this, GlobalContext* globalCtx) { + s32 playerForm; + + func_80B34078(this); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80B34598; + Actor_ChangeFocus(&this->actor, globalCtx, this->unk_278); + this->unk_278->textId = this->actor.textId; + this->unk_27C &= ~4; + if (this->actor.textId == 0xC4E) { + this->unk_27C |= 0x10; + } + } else if (this->actor.xzDistToPlayer < 250.0f) { + if ((this->unk_278 != NULL) && (this->unk_278->xzDistToPlayer < 250.0f)) { + if (this->unk_27C & 4) { + playerForm = gSaveContext.playerForm; + if (((playerForm ^ 0) != PLAYER_FORM_HUMAN) || ((CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_KOKIRI) && + (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_RAZOR) && + (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_GILDED))) { + this->actor.textId = 0xC38; + } else if (CURRENT_DAY == 3) { + this->actor.textId = 0xC39; + } else if (this->unk_27C & 8) { + this->actor.textId = 0xC3E; + } else { + this->actor.textId = 0xC3A; + } + } + + if (this->actor.textId != 0xC37) { + if (((this->actor.textId == 0xC4E) || (this->actor.textId == 0xC4F) || (this->actor.textId == 0xC50)) && + (gSaveContext.playerForm != PLAYER_FORM_HUMAN)) { + this->actor.textId = 0xC37; + } + } else if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (func_80B33E8C(globalCtx)) { + this->actor.textId = 0xC50; + } else { + this->actor.textId = 0xC4E; + } + } + func_800B8614(&this->actor, globalCtx, 260.0f); + } + } + func_80B3415C(this); +} + +void func_80B34574(EnKbt* this) { + this->unk_27E = 0; + this->unk_27F = 0; + this->unk_282 = 6; + this->actionFunc = func_80B34314; +} + +void func_80B34598(EnKbt* this, GlobalContext* globalCtx) { + func_80B34078(this); + + switch (this->actor.textId) { + case 0x1: + this->unk_27E = 4; + this->unk_27F = 0; + this->unk_282 = 0; + break; + + case 0x2: + func_80B34574(this); + this->actor.textId = 0xC3E; + this->unk_27C |= 0x4; + this->unk_27C |= 0x8; + return; + + case 0x3: + func_80B34574(this); + this->actor.textId = 0xC58; + return; + + case 0x4: + func_80B34574(this); + this->actor.textId = 0xC4B; + return; + + case 0x5: + this->unk_27E = 4; + this->unk_27F = 0; + this->unk_282 = 0; + func_80B33EF0(this, 12); + break; + + case 0x6: + func_80B34574(this); + this->actor.textId = 0xC3A; + this->unk_27C |= 4; + return; + + case 0x7: + this->unk_27E = 4; + this->unk_27F = 0; + this->unk_282 = 11; + if (func_80B33E8C(globalCtx)) { + this->actor.textId = 0xC50; + } else if (this->unk_27C & 0x10) { + this->actor.textId = 0xC4F; + } else { + this->actor.textId = 0xC4E; + } + this->actionFunc = func_80B34314; + return; + + case 0x8: + func_80B34574(this); + this->actor.textId = 0xC56; + return; + + case 0xC1E: + this->unk_27E = 2; + this->unk_27F = 1; + break; + + case 0xC1F: + case 0xC2E: + this->unk_27E = 2; + this->unk_27F = 1; + this->unk_282 = 1; + this->unk_284 = 20; + break; + + case 0xC20: + case 0xC23: + case 0xC2F: + this->unk_27E = 0; + this->unk_282 = 2; + break; + + case 0xC21: + case 0xC29: + this->unk_284 = 10; + this->unk_27C |= 2; + break; + + case 0xC22: + case 0xC2A: + this->unk_27F = 1; + break; + + case 0xC2C: + this->unk_27E = 0; + this->unk_27F = 0; + this->unk_282 = 2; + break; + + case 0xC31: + this->unk_27E = 2; + this->unk_27F = 1; + this->unk_282 = 4; + break; + + case 0xC32: + this->unk_27E = 1; + this->unk_282 = 7; + break; + + case 0xC34: + this->unk_27E = 0; + this->unk_282 = 8; + break; + + case 0xC35: + this->unk_27E = 4; + this->unk_27F = 0; + func_80B33EF0(this, 2); + this->unk_282 = 5; + break; + + case 0xC36: + this->unk_27E = 1; + this->unk_27F = 1; + func_80B33EF0(this, 7); + this->unk_282 = 7; + break; + + case 0xC37: + func_80B33EF0(this, 10); + this->unk_27E = 0; + this->unk_27F = 1; + break; + + case 0xC38: + case 0xC39: + func_80B33EF0(this, 7); + this->unk_27E = 0; + this->unk_27F = 1; + break; + + case 0xC3A: + case 0xC4D: + case 0xC58: + this->unk_27E = 0; + this->unk_27F = 1; + this->unk_282 = 8; + break; + + case 0xC3C: + case 0xC57: + this->unk_27E = 1; + this->unk_282 = 7; + break; + + case 0xC3D: + this->unk_27E = 0; + break; + + case 0xC3E: + this->unk_27F = 1; + this->unk_282 = 8; + break; + + case 0xC3F: + case 0xC47: + case 0xC4C: + this->unk_27E = 1; + this->unk_27F = 1; + this->unk_282 = 7; + break; + + case 0xC40: + this->unk_27E = 3; + this->unk_282 = 6; + break; + + case 0xC45: + case 0xC4B: + case 0xC56: + this->unk_27E = 0; + this->unk_27F = 1; + this->unk_282 = 7; + break; + + case 0xC46: + this->unk_27E = 1; + this->unk_27F = 1; + this->unk_282 = 9; + break; + + case 0xC48: + this->unk_27E = 2; + this->unk_27F = 0; + this->unk_282 = 10; + break; + + case 0xC49: + this->unk_27F = 1; + break; + + case 0xC4A: + this->unk_27E = 0; + this->unk_282 = 7; + break; + + case 0xC4E: + this->unk_27E = 1; + this->unk_27F = 1; + this->unk_282 = 12; + break; + + case 0xC4F: + this->unk_27E = 2; + this->unk_27F = 1; + this->unk_282 = 12; + break; + + case 0xC50: + this->unk_27E = 0; + this->unk_27F = 1; + this->unk_282 = 12; + break; + } + + this->actor.textId = 0; + func_80B3415C(this); +} + +void EnKbt_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKbt* this = THIS; + + this->actionFunc(this, globalCtx); +} + +s32 EnKbt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnKbt* this = THIS; + + if (!(this->unk_27C & 1) && (limbIndex == OBJECT_KBT_LIMB_0E)) { + *dList = NULL; + } + return false; +} + +Vec3f D_80B34B84 = { 500.0f, 500.0f, 0.0f }; + +void EnKbt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnKbt* this = THIS; + + if (limbIndex == OBJECT_KBT_LIMB_09) { + Matrix_MultiplyVector3fByState(&D_80B34B84, &this->actor.focus.pos); + } +} + +TexturePtr D_80B34B90[] = { + object_kbt_Tex_00A5B8, + object_kbt_Tex_00ADB8, +}; + +TexturePtr D_80B34B98[] = { + object_kbt_Tex_00B5B8, object_kbt_Tex_00BDB8, object_kbt_Tex_00C5B8, object_kbt_Tex_00CDB8, object_kbt_Tex_00D5B8, +}; + +void EnKbt_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKbt* this = THIS; + Gfx* gfx; + TexturePtr tex; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + tex = Lib_SegmentedToVirtual(D_80B34B98[this->unk_27E]); + gSPSegment(&gfx[0], 0x08, tex); + + tex = Lib_SegmentedToVirtual(D_80B34B90[this->unk_27F]); + gSPSegment(&gfx[1], 0x09, tex); + + POLY_OPA_DISP = &gfx[2]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnKbt_OverrideLimbDraw, EnKbt_PostLimbDraw, &this->actor); +} 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 9d68dce1d..7556e3f5c 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h @@ -2,6 +2,7 @@ #define Z_EN_KBT_H #include "global.h" +#include "objects/object_kbt/object_kbt.h" struct EnKbt; @@ -9,7 +10,16 @@ typedef void (*EnKbtActionFunc)(struct EnKbt*, GlobalContext*); typedef struct EnKbt { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x144]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[OBJECT_KBT_LIMB_MAX]; + /* 0x0200 */ Vec3s morphTable[OBJECT_KBT_LIMB_MAX]; + /* 0x0278 */ Actor* unk_278; + /* 0x027C */ u16 unk_27C; + /* 0x027E */ u8 unk_27E; + /* 0x027F */ u8 unk_27F; + /* 0x0280 */ s16 unk_280; + /* 0x0282 */ s16 unk_282; + /* 0x0284 */ s16 unk_284; /* 0x0288 */ EnKbtActionFunc actionFunc; } EnKbt; // size = 0x28C diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 00e0a1be3..87b8ac401 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -13501,8 +13501,8 @@ 0x80B34574:("func_80B34574",), 0x80B34598:("func_80B34598",), 0x80B349A4:("EnKbt_Update",), - 0x80B349C8:("func_80B349C8",), - 0x80B34A00:("func_80B34A00",), + 0x80B349C8:("EnKbt_OverrideLimbDraw",), + 0x80B34A00:("EnKbt_PostLimbDraw",), 0x80B34A40:("EnKbt_Draw",), 0x80B34F70:("func_80B34F70",), 0x80B34FB4:("func_80B34FB4",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 6ea90b0f9..ece018da0 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1370,11 +1370,6 @@ D_0600D828 = 0x0600D828; D_06000C30 = 0x06000C30; D_06001630 = 0x06001630; -// ovl_En_Kbt - -D_06004274 = 0x06004274; -D_0600DEE8 = 0x0600DEE8; - // ovl_En_Kitan D_06000CE8 = 0x06000CE8; From 9e13859495446c37410f841ea1c0938d47862d54 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 27 Mar 2022 15:32:08 +0100 Subject: [PATCH 134/257] En_Tru_Mt (#726) * En_Tru_Mt * PR Co-authored-by: Anghelo Carvajal --- spec | 3 +- .../actors/ovl_En_Jc_Mato/z_en_jc_mato.c | 6 +- .../actors/ovl_En_Tru_Mt/z_en_tru_mt.c | 517 ++++++++++++++++-- .../actors/ovl_En_Tru_Mt/z_en_tru_mt.h | 30 +- tools/disasm/functions.txt | 6 +- undefined_syms.txt | 5 - 6 files changed, 517 insertions(+), 50 deletions(-) diff --git a/spec b/spec index 0bc7d373f..e7d0fc98e 100644 --- a/spec +++ b/spec @@ -4194,8 +4194,7 @@ beginseg name "ovl_En_Tru_Mt" compress include "build/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.o" - include "build/data/ovl_En_Tru_Mt/ovl_En_Tru_Mt.data.o" - include "build/data/ovl_En_Tru_Mt/ovl_En_Tru_Mt.reloc.o" + include "build/src/overlays/actors/ovl_En_Tru_Mt/ovl_En_Tru_Mt_reloc.o" endseg beginseg 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 8051f71f4..4e50ceba6 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 @@ -95,7 +95,7 @@ s32 EnJcMato_CheckForHit(EnJcMato* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_HIT; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); globalCtx->interfaceCtx.unk_25C = 1; - this->hitFlag = 1; + this->hitFlag = true; return 1; } else { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); @@ -111,7 +111,7 @@ void EnJcMato_SetupIdle(EnJcMato* this) { void EnJcMato_Idle(EnJcMato* this, GlobalContext* globalCtx) { s16 shouldDespawn; - if (this->hitFlag != 0) { + if (this->hitFlag) { if (this->despawnTimer == 0) { shouldDespawn = 0; } else { @@ -133,7 +133,7 @@ void EnJcMato_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.worldSphere.radius = 0xF; this->actor.colChkInfo.damageTable = &sDamageTable; Actor_SetScale(&this->actor, 0.008f); - this->hitFlag = 0; + this->hitFlag = false; this->despawnTimer = 25; EnJcMato_SetupIdle(this); } diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c index 2cb79a8c1..c70e8264f 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c @@ -5,6 +5,7 @@ */ #include "z_en_tru_mt.h" +#include "overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -19,7 +20,6 @@ void func_80B76A64(EnTruMt* this, GlobalContext* globalCtx); void func_80B76BB8(EnTruMt* this, GlobalContext* globalCtx); void func_80B76C38(EnTruMt* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Tru_Mt_InitVars = { ACTOR_EN_TRU_MT, ACTORCAT_NPC, @@ -32,15 +32,27 @@ const ActorInit En_Tru_Mt_InitVars = { (ActorFunc)EnTruMt_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80B77510 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 22 }, 100 }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B7753C = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -75,58 +87,491 @@ static DamageTable D_80B7753C = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -#endif +static AnimationInfoS D_80B7755C[] = { + { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_0108AC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_009348, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_00EEDC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_014728, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_tru_Anim_01B5C4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_tru_Anim_007FA0, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_016B4C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_011F88, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_003698, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_002BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern ColliderSphereInit D_80B77510; -extern DamageTable D_80B7753C; +Vec3f D_80B7765C = { 3000.0f, -800.0f, 0.0f }; -extern UNK_TYPE D_060004C8; -extern UNK_TYPE D_0601AA60; +Vec3f D_80B77668 = { 0.0f, 0.0f, -3000.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76030.s") +s32 func_80B76030(SkelAnime* skelAnime, s16 arg1) { + s16 endFrame; + s16 startFrame; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76110.s") + if ((arg1 >= 0) && (arg1 < ARRAY_COUNT(D_80B7755C))) { + endFrame = D_80B7755C[arg1].frameCount; + if (endFrame < 0) { + endFrame = Animation_GetLastFrame(D_80B7755C[arg1].animation); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76188.s") + startFrame = D_80B7755C[arg1].startFrame; + if (startFrame < 0) { + startFrame = Animation_GetLastFrame(D_80B7755C[arg1].animation); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B761FC.s") + Animation_Change(skelAnime, D_80B7755C[arg1].animation, D_80B7755C[arg1].playSpeed, startFrame, endFrame, + D_80B7755C[arg1].mode, D_80B7755C[arg1].morphFrames); + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76368.s") +void func_80B76110(EnTruMt* this) { + if (DECR(this->unk_34E) == 0) { + this->unk_34C++; + if (this->unk_34C >= 3) { + this->unk_34E = Rand_S16Offset(30, 30); + this->unk_34C = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B763C4.s") +void func_80B76188(EnTruMt* this) { + this->unk_38E.x = Math_CosS(this->unk_38A) * this->unk_38C; + this->unk_38A += 0x1555; + Math_SmoothStepToS(&this->unk_38C, 0, 4, 0x3E8, 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76440.s") +s32 func_80B761FC(EnTruMt* this, GlobalContext* globalCtx) { + this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->actor.world.pos.y + 16.0f; + this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76540.s") + if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { + if (!(((EnJcMato*)this->actor.child)->collider.base.acFlags & AC_HIT) && + (this->actor.child->colChkInfo.damageEffect != 0xF)) { + this->collider.base.acFlags &= ~AC_HIT; + if (this->unk_3A4 == 0) { + this->unk_3A4 = 1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_DAMAGE); + } else { + this->unk_3A4 = 0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_DAMAGE2); + } + globalCtx->interfaceCtx.unk_25E = 1; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76600.s") + if (this->unk_38C >= 0xB7) { + func_80B76188(this); + } else { + this->unk_38E.x = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B7679C.s") + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B768F0.s") +s32 func_80B76368(EnTruMt* this, GlobalContext* globalCtx) { + Actor* bgActor = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76924.s") + while (bgActor != NULL) { + if (bgActor->id == ACTOR_BG_INGATE) { + this->unk_394 = bgActor->shape.rot.y; + this->unk_398 = bgActor->world.pos; + return true; + } + bgActor = bgActor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76980.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76A64.s") +s32 func_80B763C4(EnTruMt* this, GlobalContext* globalCtx) { + Actor* foundActor; + Actor* actor = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76BB8.s") + while (true) { + foundActor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_TRU_MT); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76C38.s") + if (foundActor == NULL) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/EnTruMt_Init.s") + if ((EnTruMt*)foundActor != this) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/EnTruMt_Destroy.s") + foundActor = foundActor->next; + if (foundActor == NULL) { + break; + } + actor = foundActor; + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/EnTruMt_Update.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76ED4.s") +void func_80B76440(EnTruMt* this, GlobalContext* globalCtx) { + if (func_80B76368(this, globalCtx)) { + s16 temp_v1 = this->unk_394 - Math_Vec3f_Yaw(&this->unk_398, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B77008.s") + if ((temp_v1 <= -0x2000) || (temp_v1 >= 0x2000)) { + Math_ApproachF(&this->actor.speedXZ, 7.0f, 0.2f, 1.0f); + } else if (this->actor.xzDistToPlayer < 300.0f) { + Math_ApproachF(&this->actor.speedXZ, 7.0f, 0.2f, 1.0f); + } else if (this->actor.xzDistToPlayer > 500.0f) { + Math_ApproachF(&this->actor.speedXZ, 2.5f, 0.2f, 1.0f); + } else { + Math_ApproachF(&this->actor.speedXZ, 4.0f, 0.2f, 1.0f); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B77078.s") +f32 func_80B76540(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3) { + s32 pad; + Vec3f sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B77354.s") + if (path != NULL) { + Vec3s* temp_v1 = Lib_SegmentedToVirtual(path->points); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/EnTruMt_Draw.s") + temp_v1 = &temp_v1[arg1]; + sp20.x = temp_v1->x; + sp20.y = temp_v1->y; + sp20.z = temp_v1->z; + } + arg3->y = Math_Vec3f_Yaw(arg2, &sp20); + arg3->x = Math_Vec3f_Pitch(arg2, &sp20); + + return sp20.y - arg2->y; +} + +s32 func_80B76600(EnTruMt* this, Path* path, s32 arg2) { + Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); + s32 sp58 = path->count; + s32 idx = arg2; + s32 sp50 = false; + f32 phi_f12; + f32 phi_f14; + f32 sp44; + f32 sp40; + f32 sp3C; + Vec3f sp30; + + Math_Vec3s_ToVec3f(&sp30, &sp5C[idx]); + + if (idx == 0) { + phi_f12 = sp5C[1].x - sp5C[0].x; + phi_f14 = sp5C[1].z - sp5C[0].z; + } else if (idx == (sp58 - 1)) { + phi_f12 = sp5C[sp58 - 1].x - sp5C[sp58 - 2].x; + phi_f14 = sp5C[sp58 - 1].z - sp5C[sp58 - 2].z; + } else { + phi_f12 = sp5C[idx + 1].x - sp5C[idx - 1].x; + phi_f14 = sp5C[idx + 1].z - sp5C[idx - 1].z; + } + + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); + if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { + sp50 = true; + } + + return sp50; +} + +void func_80B7679C(EnTruMt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + Vec3f sp34; + + Math_SmoothStepToS(&this->unk_34A, (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - 0x4000, 4, 0x38E0, 1); + this->unk_34A = CLAMP(this->unk_34A, -0x38E0, 0x38E0); + + sp40 = player->actor.world.pos; + sp40.y = player->bodyPartsPos[7].y + 3.0f; + + sp34 = this->actor.world.pos; + sp34.y += 30.0f; + + Math_SmoothStepToS(&this->unk_348, Math_Vec3f_Pitch(&sp34, &sp40), 4, 0x1C70, 1); + this->unk_348 = CLAMP(this->unk_348, -0x1C70, 0x1C70); +} + +s32 func_80B768F0(EnTruMt* this, GlobalContext* globalCtx) { + if (this->unk_328 & 0x10) { + func_80B7679C(this, globalCtx); + } + return true; +} + +void func_80B76924(EnTruMt* this) { + this->unk_38E.z = Math_SinS(this->unk_388) * 30.0f * (0x10000 / 360.0f); + this->unk_388 += 0x400; +} + +void func_80B76980(EnTruMt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (gSaveContext.unk_3F3C >= 10) { + Message_StartTextbox(globalCtx, 0x87F, &this->actor); + gSaveContext.eventInf[3] |= 0x40; + gSaveContext.eventInf[4] |= 1; + player->stateFlags3 &= ~0x400; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80B76BB8; + } else if (gSaveContext.eventInf[4] & 1) { + u32 score = gSaveContext.minigameScore; + + if (((gSaveContext.unk_EE8 & 0xFFFF0000) >> 0x10) < score) { + gSaveContext.unk_EE8 = ((gSaveContext.minigameScore & 0xFFFF) << 0x10) | (gSaveContext.unk_EE8 & 0xFFFF); + gSaveContext.eventInf[3] |= 0x80; + } + } +} + +void func_80B76A64(EnTruMt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3s sp34; + + func_80B76924(this); + func_80B76980(this, globalCtx); + player->stateFlags3 |= 0x400; + + if (this->path != NULL) { + func_80B76540(this->path, this->unk_36C, &this->actor.world.pos, &sp34); + Math_SmoothStepToS(&this->actor.world.rot.y, sp34.y, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->actor.shape.rot.x, sp34.x, 4, 0x3E8, 1); + + this->actor.world.rot.x = -this->actor.shape.rot.x; + this->actor.shape.rot.z = CLAMP(this->actor.world.rot.y, -0x1770, 0x1770); + this->actor.world.rot.z = this->actor.shape.rot.z; + + if (func_80B76600(this, this->path, this->unk_36C)) { + if (this->unk_36C >= (this->path->count - 1)) { + this->actionFunc = func_80B76C38; + this->actor.speedXZ = 0.0f; + return; + } + this->unk_36C++; + } + func_80B76440(this, globalCtx); + } +} + +void func_80B76BB8(EnTruMt* this, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 5) { + if (func_80147624(globalCtx)) { + globalCtx->nextEntranceIndex = 0xA810; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 3; + globalCtx->sceneLoadFlag = 0x14; + } + } +} + +void func_80B76C38(EnTruMt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + func_80B76924(this); + func_80B76980(this, globalCtx); + player->stateFlags3 |= 0x400; +} + +void EnTruMt_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTruMt* this = THIS; + + if (!(gSaveContext.eventInf[3] & 0x20)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80B763C4(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tru_Skel_01AA60, NULL, this->jointTable, this->morphTable, + OBJECT_TRU_LIMB_MAX); + + Collider_InitSphere(globalCtx, &this->collider); + Collider_SetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + + this->collider.dim.worldSphere.radius = 22; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->path = func_8013D648(globalCtx, ENTRUMT_GET_FF(&this->actor), 0x3F); + this->actor.targetMode = 0; + + Actor_SetScale(&this->actor, 0.008f); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + this->unk_328 = 0; + this->actor.room = -1; + this->path = func_8013D648(globalCtx, ENTRUMT_GET_FC00(&this->actor), 0x3F); + func_80B76030(&this->skelAnime, 14); + this->actionFunc = func_80B76A64; +} + +void EnTruMt_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTruMt* this = THIS; + + Collider_DestroySphere(globalCtx, &this->collider); +} + +void EnTruMt_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTruMt* this = THIS; + + func_80B768F0(this, globalCtx); + SkelAnime_Update(&this->skelAnime); + + this->actionFunc(this, globalCtx); + + func_80B76110(this); + Actor_SetFocus(&this->actor, 34.0f); + + if (!(gSaveContext.eventInf[4] & 1)) { + func_80B761FC(this, globalCtx); + } + + Actor_MoveWithoutGravity(&this->actor); +} + +void func_80B76ED4(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4) { + Vec3f sp7C; + Vec3f sp70 = gZeroVec3f; + Vec3s sp68; + MtxF sp28; + + Matrix_MultiplyVector3fByState(&sp70, &sp7C); + Matrix_CopyCurrentState(&sp28); + func_8018219C(&sp28, &sp68, 0); + + *arg2 = sp7C; + + if (arg4 != 0) { + sp68.x += arg0; + sp68.y += arg1; + Math_SmoothStepToS(&arg3->x, sp68.x, 4, 0x1FFE, 1); + Math_SmoothStepToS(&arg3->y, sp68.y, 4, 0x1FFE, 1); + Math_SmoothStepToS(&arg3->z, sp68.z, 4, 0x1FFE, 1); + } else { + arg3->x = sp68.x; + arg3->y = sp68.y; + arg3->z = sp68.z; + } +} + +s32 EnTruMt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnTruMt* this = THIS; + + if (limbIndex == OBJECT_TRU_LIMB_15) { + Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk_35C); + } + + if (limbIndex == OBJECT_TRU_LIMB_15) { + Matrix_MultiplyVector3fByState(&D_80B7765C, &this->unk_350); + } + return false; +} + +void EnTruMt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnTruMt* this = THIS; + MtxF* sp54; + s32 phi_v0; + + if (limbIndex == OBJECT_TRU_LIMB_15) { + if (this->unk_328 & 0x10) { + phi_v0 = 1; + } else { + phi_v0 = 0; + } + func_80B76ED4(this->unk_348, this->unk_34A, &this->unk_33C, &this->unk_336, phi_v0); + Matrix_InsertTranslation(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_336.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_336.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_336.z, MTXMODE_APPLY); + } + + if (limbIndex == OBJECT_TRU_LIMB_0E) { + func_8012C28C(globalCtx->state.gfxCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_MultiplyVector3fByState(&D_80B77668, &this->unk_370); + Matrix_InsertTranslation(this->unk_370.x, this->unk_370.y, this->unk_370.z, MTXMODE_NEW); + Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_38E.z, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_38E.x, MTXMODE_APPLY); + Matrix_Scale(0.008f, 0.008f, 0.008f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_0004C8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + sp54 = Matrix_GetCurrentState(); + if ((this->actor.child == NULL) || (this->actor.child->update == NULL)) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_JC_MATO, sp54->wx, sp54->wy, + sp54->wz, this->unk_38E.x, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), + this->unk_38E.z, -1); + } else if (!((EnJcMato*)this->actor.child)->hitFlag) { + this->actor.child->world.pos.x = sp54->wx; + this->actor.child->world.pos.y = sp54->wy; + this->actor.child->world.pos.z = sp54->wz; + + this->actor.child->world.rot = this->unk_38E; + this->actor.child->world.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + + this->actor.child->shape.rot = this->actor.child->world.rot; + } + } +} + +void EnTruMt_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnTruMt* this = THIS; + + if (limbIndex == OBJECT_TRU_LIMB_15) { + Matrix_InsertTranslation(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_336.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_336.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_336.z, MTXMODE_APPLY); + } +} + +void EnTruMt_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTruMt* this = THIS; + TexturePtr sp48[] = { + object_tru_Tex_018FA0, + object_tru_Tex_0197A0, + object_tru_Tex_019FA0, + }; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp48[this->unk_34C])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sp48[this->unk_34C])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnTruMt_OverrideLimbDraw, EnTruMt_PostLimbDraw, + EnTruMt_TransformLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h index 793958ed7..049c11ecd 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h @@ -2,15 +2,43 @@ #define Z_EN_TRU_MT_H #include "global.h" +#include "objects/object_tru/object_tru.h" struct EnTruMt; typedef void (*EnTruMtActionFunc)(struct EnTruMt*, GlobalContext*); +#define ENTRUMT_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ENTRUMT_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) + typedef struct EnTruMt { /* 0x0000 */ Actor actor; /* 0x0144 */ EnTruMtActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x260]; + /* 0x0148 */ SkelAnime skelAnime; + /* 0x018C */ ColliderSphere collider; + /* 0x01E4 */ Vec3s jointTable[OBJECT_TRU_LIMB_MAX]; + /* 0x0286 */ Vec3s morphTable[OBJECT_TRU_LIMB_MAX]; + /* 0x0328 */ u16 unk_328; + /* 0x032A */ UNK_TYPE1 unk32A[0xC]; + /* 0x0336 */ Vec3s unk_336; + /* 0x033C */ Vec3f unk_33C; + /* 0x0348 */ s16 unk_348; + /* 0x034A */ s16 unk_34A; + /* 0x034C */ s16 unk_34C; + /* 0x034E */ s16 unk_34E; + /* 0x0350 */ Vec3f unk_350; + /* 0x035C */ Vec3f unk_35C; + /* 0x0368 */ Path* path; + /* 0x036C */ s32 unk_36C; + /* 0x0370 */ Vec3f unk_370; + /* 0x037C */ UNK_TYPE1 unk37C[0xC]; + /* 0x0388 */ s16 unk_388; + /* 0x038A */ s16 unk_38A; + /* 0x038C */ s16 unk_38C; + /* 0x038E */ Vec3s unk_38E; + /* 0x0394 */ s16 unk_394; + /* 0x0398 */ Vec3f unk_398; + /* 0x03A4 */ u8 unk_3A4; } EnTruMt; // size = 0x3A8 extern const ActorInit En_Tru_Mt_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 87b8ac401..ffcbdf8fe 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -14457,9 +14457,9 @@ 0x80B76E1C:("EnTruMt_Destroy",), 0x80B76E48:("EnTruMt_Update",), 0x80B76ED4:("func_80B76ED4",), - 0x80B77008:("func_80B77008",), - 0x80B77078:("func_80B77078",), - 0x80B77354:("func_80B77354",), + 0x80B77008:("EnTruMt_OverrideLimbDraw",), + 0x80B77078:("EnTruMt_PostLimbDraw",), + 0x80B77354:("EnTruMt_TransformLimbDraw",), 0x80B773D0:("EnTruMt_Draw",), 0x80B77770:("func_80B77770",), 0x80B77FA4:("func_80B77FA4",), diff --git a/undefined_syms.txt b/undefined_syms.txt index ece018da0..0c42e684c 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1671,11 +1671,6 @@ D_06000A44 = 0x06000A44; D_0601A820 = 0x0601A820; D_0601A830 = 0x0601A830; -// ovl_En_Tru_Mt - -D_060004C8 = 0x060004C8; -D_0601AA60 = 0x0601AA60; - // ovl_En_Twig D_060014C8 = 0x060014C8; From 9e230005b06a581983983fb8ab0a64860097a34d Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 27 Mar 2022 15:36:59 +0100 Subject: [PATCH 135/257] En_Fu_Kago (#729) * En_Fu_Kago * PR --- spec | 3 +- src/overlays/actors/ovl_En_Fu/z_en_fu.h | 1 + .../actors/ovl_En_Fu_Kago/z_en_fu_kago.c | 381 ++++++++++++++++-- .../actors/ovl_En_Fu_Kago/z_en_fu_kago.h | 18 +- undefined_syms.txt | 10 - 5 files changed, 374 insertions(+), 39 deletions(-) diff --git a/spec b/spec index e7d0fc98e..f7c6744ef 100644 --- a/spec +++ b/spec @@ -3512,8 +3512,7 @@ beginseg name "ovl_En_Fu_Kago" compress include "build/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.o" - include "build/data/ovl_En_Fu_Kago/ovl_En_Fu_Kago.data.o" - include "build/data/ovl_En_Fu_Kago/ovl_En_Fu_Kago.reloc.o" + include "build/src/overlays/actors/ovl_En_Fu_Kago/ovl_En_Fu_Kago_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.h b/src/overlays/actors/ovl_En_Fu/z_en_fu.h index b16ea4620..6af75768f 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.h +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.h @@ -2,6 +2,7 @@ #define Z_EN_FU_H #include "global.h" +#include "overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h" struct EnFu; diff --git a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c index 3cc50bbec..ad92b34d6 100644 --- a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c +++ b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c @@ -5,6 +5,9 @@ */ #include "z_en_fu_kago.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "overlays/actors/ovl_En_Fu/z_en_fu.h" +#include "objects/object_fu_mato/object_fu_mato.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +18,15 @@ void EnFuKago_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFuKago_Update(Actor* thisx, GlobalContext* globalCtx); void EnFuKago_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80ACF994(EnFuKago* this); +void func_80ACF9A8(EnFuKago* this, GlobalContext* globalCtx); +void func_80ACF9DC(EnFuKago* this); +void func_80ACF9FC(EnFuKago* this, GlobalContext* globalCtx); +void func_80ACFA78(EnFuKago* this, GlobalContext* globalCtx); +void func_80AD0028(EnFuKago* this, GlobalContext* globalCtx); +void func_80AD0274(EnFuKago* this); +void func_80AD0288(EnFuKago* this, GlobalContext* globalCtx); + const ActorInit En_Fu_Kago_InitVars = { ACTOR_EN_FU_KAGO, ACTORCAT_BG, @@ -28,46 +39,368 @@ const ActorInit En_Fu_Kago_InitVars = { (ActorFunc)EnFuKago_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80AD05F0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_NO_PUSH | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK4, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_NO_PUSH | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK4, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 200 }, 100 }, }; -#endif +Gfx* D_80AD061C[] = { + object_fu_mato_DL_0006A0, object_fu_mato_DL_000740, object_fu_mato_DL_0007E0, + object_fu_mato_DL_000880, object_fu_mato_DL_000920, object_fu_mato_DL_0009C0, +}; -extern ColliderSphereInit D_80AD05F0; +Vec3f D_80AD0634[] = { + { -1.0f, 0.5f, 1.73f }, { 1.0f, 0.5f, 1.73f }, { 2.0f, 0.5f, 0.0f }, + { 1.0f, 0.5f, -1.73f }, { -1.0f, 0.5f, -1.73f }, { -2.0f, 0.5f, 0.0f }, +}; -extern UNK_TYPE D_060006A0; -extern UNK_TYPE D_060015C0; +Vec3f D_80AD067C[] = { + { -0.5f, 0.5f, 0.87f }, { 0.5f, 0.5f, 0.87f }, { 1.0f, 0.5f, 0.0f }, + { 0.5f, 0.5f, -0.87f }, { -0.5f, 0.5f, -0.87f }, { -1.0f, 0.5f, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/EnFuKago_Init.s") +Vec3f D_80AD06C4[] = { + { -13.7f, 9.0f, 15.5f }, { 13.7f, 9.0f, 15.5f }, { 13.7f, 9.0f, 0.0f }, + { 13.7f, 9.0f, -15.5f }, { -13.7f, 9.0f, -15.5f }, { -13.7f, 9.0f, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/EnFuKago_Destroy.s") +void EnFuKago_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFuKago* this = THIS; + CollisionHeader* sp34 = NULL; + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF8B8.s") + DynaPolyActor_Init(&this->dyna, 1); + CollisionHeader_GetVirtual(&object_fu_mato_Colheader_0015C0, &sp34); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp34); + Actor_SetScale(&this->dyna.actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF994.s") + while (npc != NULL) { + if (npc->id == ACTOR_EN_FU) { + this->dyna.actor.parent = npc; + break; + } + npc = npc->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF9A8.s") + if (npc == NULL) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF9DC.s") + Collider_InitSphere(globalCtx, &this->collider); + Collider_SetSphere(globalCtx, &this->collider, &this->dyna.actor, &sSphereInit); + this->collider.dim.worldSphere.radius = 10; + this->unk_33A = 0; + this->unk_33C = 0; + this->dyna.actor.colChkInfo.health = 1; + func_80ACF994(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF9FC.s") +void EnFuKago_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFuKago* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACFA78.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACFDAC.s") +s32 func_80ACF8B8(EnFuKago* this, GlobalContext* globalCtx) { + this->collider.dim.worldSphere.center.x = this->dyna.actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->dyna.actor.world.pos.y + 10.0f; + this->collider.dim.worldSphere.center.z = this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80AD0028.s") + if (this->collider.base.ocFlags1 & OC1_HIT) { + this->collider.base.ocFlags1 &= ~OC1_HIT; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80AD0274.s") + if (this->collider.base.oc->id == ACTOR_EN_BOM) { + this->dyna.actor.child = this->collider.base.oc; + } else if (this->collider.base.oc->id == ACTOR_PLAYER) { + func_80ACFA78(this, globalCtx); + return false; + } else { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80AD0288.s") + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); + return true; + } else { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/EnFuKago_Update.s") +void func_80ACF994(EnFuKago* this) { + this->actionFunc = func_80ACF9A8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80AD0340.s") +void func_80ACF9A8(EnFuKago* this, GlobalContext* globalCtx) { + if (func_80ACF8B8(this, globalCtx)) { + func_80ACF9DC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/EnFuKago_Draw.s") +void func_80ACF9DC(EnFuKago* this) { + EnBom* bom = (EnBom*)this->dyna.actor.child; + + bom->timer = 20; + this->actionFunc = func_80ACF9FC; +} + +void func_80ACF9FC(EnFuKago* this, GlobalContext* globalCtx) { + EnBom* bom = (EnBom*)this->dyna.actor.child; + EnFu* fu = (EnFu*)this->dyna.actor.parent; + + if (this->dyna.actor.child->update == NULL) { + this->dyna.actor.child = NULL; + func_80ACF994(this); + } else if (bom->timer == 1) { + fu->unk_548++; + func_80ACFA78(this, globalCtx); + } else { + this->dyna.actor.child->world.pos.x = this->dyna.actor.world.pos.x; + this->dyna.actor.child->world.pos.z = this->dyna.actor.world.pos.z; + } +} + +void func_80ACFA78(EnFuKago* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp98; + Vec3s sp90; + Vec3s sp88 = { 0, 0, 0 }; + EnFuKagoStruct* ptr; + s16 y; + + this->dyna.actor.colChkInfo.health = 0; + sp98 = this->dyna.actor.world.pos; + sp90 = this->dyna.actor.shape.rot; + + ptr = &this->unk_1B8[0]; + y = sp90.y; + + for (i = 0; i < ARRAY_COUNT(this->unk_1B8); i++) { + ptr->unk_00 = sp98; + ptr->unk_30 = sp88; + + ptr->unk_0C.x = (Math_CosS(y) * D_80AD0634[i].x) + (Math_SinS(y) * D_80AD0634[i].z); + ptr->unk_0C.y = D_80AD0634[i].y + Rand_Centered(); + ptr->unk_0C.z = (Math_CosS(y) * D_80AD0634[i].z) - (Math_SinS(y) * D_80AD0634[i].x); + + ptr->unk_18.x = (Math_CosS(y) * D_80AD067C[i].x) + (Math_SinS(y) * D_80AD067C[i].z); + ptr->unk_18.y = D_80AD067C[i].y; + ptr->unk_18.z = (Math_CosS(y) * D_80AD067C[i].z) - (Math_SinS(y) * D_80AD067C[i].x); + + ptr->unk_36.x = (s16)Rand_Next() >> 5; + ptr->unk_36.y = 0; + ptr->unk_36.z = (s16)Rand_Next() >> 5; + + ptr->unk_24.x = D_80AD06C4[i].x; + ptr->unk_24.y = D_80AD06C4[i].y; + ptr->unk_24.z = D_80AD06C4[i].z; + + ptr->unk_3C = 0; + + ptr->unk_00.x += 18.0f * ptr->unk_0C.x; + ptr->unk_00.y += 18.0f * ptr->unk_0C.y; + ptr->unk_00.z += 18.0f * ptr->unk_0C.z; + + ptr++; + } + + this->dyna.actor.freezeTimer = 2; + EffectSsHahen_SpawnBurst(globalCtx, &this->dyna.actor.world.pos, 17.0f, 0, 15, 13, 20, -1, 10, NULL); + + this->unk_338 = 60; + this->unk_33A = 1; + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODBOX_BREAK); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->actionFunc = func_80AD0028; +} + +Vec3f D_80AD0714 = { 0.0f, 0.0f, 0.0f }; + +void func_80ACFDAC(EnFuKago* this, GlobalContext* globalCtx, EnFuKagoStruct* arg2) { + Vec3f sp34; + f32 temp_f0; + + if (arg2->unk_3C == 0) { + if (arg2->unk_00.y < 15.0f) { + sp34 = arg2->unk_00; + sp34.y = 30.0f; + EffectSsGSplash_Spawn(globalCtx, &sp34, NULL, NULL, 0, 800); + EffectSsGRipple_Spawn(globalCtx, &sp34, 250, 650, 0); + arg2->unk_3C = 1; + } + + Math_SmoothStepToF(&arg2->unk_18.x, 0.0f, 0.1f, 0.1f, 0.1f); + Math_SmoothStepToF(&arg2->unk_18.y, -1.0f, 0.1f, 0.1f, 0.1f); + Math_SmoothStepToF(&arg2->unk_18.z, 0.0f, 0.1f, 0.1f, 0.1f); + return; + } + + temp_f0 = Math_Vec3f_DistXZ(&arg2->unk_00, &D_80AD0714); + + arg2->unk_18.y = ((15.0f - arg2->unk_00.y) * 0.1f) - (0.2f * arg2->unk_0C.y); + arg2->unk_18.x = arg2->unk_0C.x * -0.1f; + arg2->unk_18.z = arg2->unk_0C.z * -0.1f; + + if (temp_f0 < 190.0f) { + arg2->unk_00.x *= 190.0f / temp_f0; + arg2->unk_00.z *= 190.0f / temp_f0; + } + + if (ABS_ALT(arg2->unk_36.x) > 100) { + Math_SmoothStepToS(&arg2->unk_36.x, 0, 0xA, 0x64, 0xA); + } + + if (ABS_ALT(arg2->unk_36.z) > 100) { + Math_SmoothStepToS(&arg2->unk_36.z, 0, 0xA, 0x64, 0xA); + } + + if ((globalCtx->gameplayFrames % 8) == 0) { + sp34 = arg2->unk_00; + sp34.y = 30.0f; + EffectSsGRipple_Spawn(globalCtx, &sp34, 250, 650, 0); + } +} + +void func_80AD0028(EnFuKago* this, GlobalContext* globalCtx) { + EnFuKagoStruct* ptr = this->unk_1B8; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_1B8); i++) { + func_80ACFDAC(this, globalCtx, ptr); + + ptr->unk_0C.x += ptr->unk_18.x; + ptr->unk_0C.y += ptr->unk_18.y; + ptr->unk_0C.z += ptr->unk_18.z; + + ptr->unk_00.x += ptr->unk_0C.x; + ptr->unk_00.y += ptr->unk_0C.y; + ptr->unk_00.z += ptr->unk_0C.z; + + ptr->unk_30.x += ptr->unk_36.x; + ptr->unk_30.y += ptr->unk_36.y; + ptr->unk_30.z += ptr->unk_36.z; + + ptr++; + } + + if (this->unk_338 == 59) { + this->unk_1B8[3].unk_0C.x *= -1.0f; + this->unk_1B8[3].unk_0C.z *= -1.0f; + + this->unk_1B8[4].unk_0C.x *= -1.0f; + this->unk_1B8[4].unk_0C.z *= -1.0f; + } else if (this->unk_338 == 58) { + Vec3f sp34 = this->unk_1B8[5].unk_0C; + + this->unk_1B8[5].unk_0C.x = sp34.z; + this->unk_1B8[5].unk_0C.z = -sp34.x; + + sp34 = this->unk_1B8[2].unk_0C; + this->unk_1B8[2].unk_0C.x = -sp34.z; + this->unk_1B8[2].unk_0C.z = sp34.x; + + this->unk_1B8[5].unk_36.x *= -1; + this->unk_1B8[5].unk_36.y *= -1; + this->unk_1B8[5].unk_36.z *= -1; + + this->unk_1B8[2].unk_36.x *= -1; + this->unk_1B8[2].unk_36.y *= -1; + this->unk_1B8[2].unk_36.z *= -1; + } else if (this->unk_338 == 0) { + func_80AD0274(this); + } + this->unk_338--; +} + +void func_80AD0274(EnFuKago* this) { + this->actionFunc = func_80AD0288; +} + +void func_80AD0288(EnFuKago* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f* scale = &this->dyna.actor.scale; + + Math_SmoothStepToF(&scale->x, 0.0f, 0.1f, 0.005f, 0.005f); + scale->z = scale->x; + scale->y = scale->x; + if (scale->x == 0.0f) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void EnFuKago_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFuKago* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->unk_33C == 1) { + func_80AD0274(this); + } +} + +void func_80AD0340(EnFuKago* this, GlobalContext* globalCtx) { + s32 pad[2]; + EnFuKagoStruct* ptr = &this->unk_1B8[0]; + s32 i; + Vec3f* scale = &this->dyna.actor.scale; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(D_80AD061C); i++, ptr++) { + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &this->dyna.actor.shape.rot); + Matrix_InsertTranslation(ptr->unk_24.x, ptr->unk_24.y, ptr->unk_24.z, MTXMODE_APPLY); + Matrix_InsertRotation(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + Matrix_InsertTranslation(-ptr->unk_24.x, -ptr->unk_24.y, -ptr->unk_24.z, MTXMODE_APPLY); + Matrix_Scale(scale->x, scale->y, scale->z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_80AD061C[i]); + + Matrix_StatePop(); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFuKago_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFuKago* this = THIS; + + if (this->unk_33A == 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_0006A0); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_000740); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_0007E0); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_000880); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_000920); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_0009C0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + func_80AD0340(this, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h index db37f2f2d..19022093e 100644 --- a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h +++ b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h @@ -7,11 +7,23 @@ struct EnFuKago; typedef void (*EnFuKagoActionFunc)(struct EnFuKago*, GlobalContext*); +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ Vec3f unk_24; + /* 0x30 */ Vec3s unk_30; + /* 0x36 */ Vec3s unk_36; + /* 0x3C */ s16 unk_3C; +} EnFuKagoStruct; // size = 0x40 + typedef struct EnFuKago { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ EnFuKagoActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x1DC]; + /* 0x0160 */ ColliderSphere collider; + /* 0x01B8 */ EnFuKagoStruct unk_1B8[6]; + /* 0x0338 */ s16 unk_338; + /* 0x033A */ s16 unk_33A; /* 0x033C */ s16 unk_33C; } EnFuKago; // size = 0x340 diff --git a/undefined_syms.txt b/undefined_syms.txt index 0c42e684c..3112afc65 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1236,16 +1236,6 @@ D_0600007C = 0x0600007C; D_0600CFE0 = 0x0600CFE0; D_06011058 = 0x06011058; -// ovl_En_Fu_Kago - -D_060006A0 = 0x060006A0; -D_06000740 = 0x06000740; -D_060007E0 = 0x060007E0; -D_06000880 = 0x06000880; -D_06000920 = 0x06000920; -D_060009C0 = 0x060009C0; -D_060015C0 = 0x060015C0; - // ovl_En_Fu_Mato D_060023D4 = 0x060023D4; From f1d1173558e6fc01dfe7e884e29643d640db5a77 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Mon, 28 Mar 2022 01:42:19 +1100 Subject: [PATCH 136/257] River_Sound OK and Documented + River_Sound Related `z_actor`/`Audio` Functions (#661) * First pass of `func_800BCCDC` * river_sound OK (copy progress from audio WIP) * Copy progress from `code_8019AF00.c` (still waiting for data to be imported) * More docs * feedback * Add in `code_8019AF00.c` functions * format * params * Minor cleanup * Small fix * one more * Better names * Add comment, cleanup Idx * Fix bss * Fix BSS --- include/functions.h | 24 +- include/variables.h | 2 +- spec | 3 +- src/code/audio/code_80192BE0.c | 2 +- src/code/audio/code_8019AF00.c | 293 +++++++++++++++++- src/code/audio/code_801A5BD0.c | 2 +- src/code/audio/code_801A7B10.c | 2 +- src/code/z_actor.c | 200 +++++++----- .../ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c | 1 + .../ovl_En_River_Sound/z_en_river_sound.c | 69 ++++- .../ovl_En_River_Sound/z_en_river_sound.h | 37 ++- .../ovl_En_Weather_Tag/z_en_weather_tag.c | 4 +- tools/disasm/functions.txt | 32 +- tools/sizes/code_functions.csv | 32 +- 14 files changed, 553 insertions(+), 150 deletions(-) diff --git a/include/functions.h b/include/functions.h index 4da5b59e4..87846d8d9 100644 --- a/include/functions.h +++ b/include/functions.h @@ -777,7 +777,7 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type); void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u16 xluFlag, u16 duration); Hilite* func_800BCBF4(Vec3f* arg0, GlobalContext* globalCtx); Hilite* func_800BCC68(Vec3f* arg0, GlobalContext* globalCtx); -void func_800BCCDC(Vec3s* points, s32 pathCount, Vec3f* pos1, Vec3f* pos2, s32 parm5); +void Actor_GetClosestPosOnPath(Vec3s* points, s32 numPoints, Vec3f* srcPos, Vec3f* dstPos, s32 isPathLoop); s32 func_800BD2B4(GlobalContext* globalCtx, Actor* actor, s16* arg2, f32 arg3, u16 (*textIdCallback)(GlobalContext*, Actor*), s16 (*arg5)(GlobalContext*, Actor*)); void func_800BD888(Actor* actor, struct_800BD888_arg1* arg1, s16 arg2, s16 arg3); void func_800BD9E0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s16 alpha); @@ -3359,7 +3359,7 @@ AudioTask* func_80192BE0(void); // void func_8019380C(void); // void func_80193858(void); // void func_8019387C(void); -// void func_801938A0(void); +void Audio_QueueCmdS8(u32 opArgs, s8 data); // void func_801938D0(void); // void func_80193900(void); // void func_80193990(void); @@ -3537,24 +3537,24 @@ void func_8019FDC8(UNK_PTR arg0, u16 sfxId, UNK_TYPE arg2); void func_8019FE74(f32* arg0, f32 arg1, s32 arg2); // void func_8019FEDC(void); // void func_8019FF38(void); -// void func_8019FF9C(void); -// void func_801A0048(void); -// void func_801A00EC(void); +void Audio_PlaySfxForRiver(Vec3f* pos, f32 freqScale); +// void Audio_PlaySfxForWaterfall(void); +// void Audio_StepFreqLerp(void); void func_801A0124(Vec3f* pos, u8 arg1); // void func_801A0184(void); // void func_801A01C4(void); void func_801A0204(s8 seqId); void func_801A0238(s32 arg0, s32 arg1); -// void func_801A026C(void); -// void func_801A0318(void); -// void func_801A046C(void); +// void Audio_SetGanonsTowerBgmVolumeLevel(void); +// void Audio_SetGanonsTowerBgmVolume(void); +// void Audio_UpdateRiverSoundVolumes(void); // void func_801A0554(void); // void func_801A05F0(void); void func_801A0654(Vec3f* arg0, u16 sfxId, s32 arg2); void func_801A0810(Vec3f* arg0, u16 sfxId, u8 arg2); // void func_801A0868(void); // void func_801A09D4(void); -// void func_801A0CB0(void); +// void Audio_SplitBgmChannels(void); // void func_801A0E44(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); // void func_801A1290(void); // void func_801A1348(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); @@ -3678,16 +3678,16 @@ void func_801A75E8(u16 sfxId); void func_801A7794(u32 param_1, u32 param_2, u32 param_3); // void func_801A7828(void); // void func_801A787C(void); -// void func_801A78E4(void); +u8 Audio_IsSfxPlaying(u32 sfxId); // void func_801A794C(void); // void func_801A7B10(void); // void func_801A7D04(void); // void func_801A7D84(void); -void Audio_QueueSeqCmd(u32 arg0); +void Audio_QueueSeqCmd(u32 cmd); // void func_801A89D0(void); s32 func_801A8A50(s32 param1); // void func_801A8ABC(void); -// void func_801A8BD0(void); +void Audio_SetVolumeScale(u8 playerIdx, u8 scaleIdx, u8 targetVol, u8 volFadeTimer); // void func_801A8D5C(void); // void func_801A8E90(void); // void func_801A9768(void); diff --git a/include/variables.h b/include/variables.h index 11c9dca92..1fccfc97b 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3008,7 +3008,7 @@ extern f32 D_801E05B4; extern f32 D_801E05B8; extern f32 D_801E05D0; extern f32 D_801E05D4; -// extern UNK_TYPE1 D_801E0BD0; +extern const u16 gAudioEnvironmentalSfx[]; // extern UNK_TYPE1 D_801E0BFC; extern f32 D_801E0CEC; extern f32 D_801E0CF0; diff --git a/spec b/spec index f7c6744ef..be7b1bd66 100644 --- a/spec +++ b/spec @@ -965,8 +965,7 @@ beginseg name "ovl_En_River_Sound" compress include "build/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.o" - include "build/data/ovl_En_River_Sound/ovl_En_River_Sound.data.o" - include "build/data/ovl_En_River_Sound/ovl_En_River_Sound.reloc.o" + include "build/src/overlays/actors/ovl_En_River_Sound/ovl_En_River_Sound_reloc.o" endseg beginseg diff --git a/src/code/audio/code_80192BE0.c b/src/code/audio/code_80192BE0.c index cd430b5ce..d088db607 100644 --- a/src/code/audio/code_80192BE0.c +++ b/src/code/audio/code_80192BE0.c @@ -18,7 +18,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019387C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801938A0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/Audio_QueueCmdS8.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801938D0.s") diff --git a/src/code/audio/code_8019AF00.c b/src/code/audio/code_8019AF00.c index 17404280b..0006122c2 100644 --- a/src/code/audio/code_8019AF00.c +++ b/src/code/audio/code_8019AF00.c @@ -66,6 +66,9 @@ typedef struct { /* 0xC */ s32 remainingFrames; } FreqLerp; // size = 0x10 +s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume); +void func_801A3238(s8 playerIndex, u16 seqId, u8 fadeTimer, s8 arg3, u8 arg4); + // Sfx bss SfxSettings sSfxSettings[8]; u8 sSfxSettingsFlags; @@ -2071,11 +2074,50 @@ const char sAudioOcarinaUnusedText7[] = "check is over!!! %d %d %d\n"; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019FF38.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019FF9C.s") +/** + * Used for EnRiverSound + */ +void Audio_PlaySfxForRiver(Vec3f* pos, f32 freqScale) { + if (!Audio_IsSfxPlaying(NA_SE_EV_RIVER_STREAM - SFX_FLAG)) { + sRiverFreqScaleLerp.value = freqScale; + } else if (freqScale != sRiverFreqScaleLerp.value) { + sRiverFreqScaleLerp.target = freqScale; + sRiverFreqScaleLerp.remainingFrames = 40; + sRiverFreqScaleLerp.step = (sRiverFreqScaleLerp.target - sRiverFreqScaleLerp.value) / 40; + } + Audio_PlaySfxGeneral(NA_SE_EV_RIVER_STREAM - SFX_FLAG, pos, 4, &sRiverFreqScaleLerp.value, &D_801DB4B0, + &D_801DB4B8); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0048.s") +/** + * Unused remnant of OoT's EnRiverSound + * Used for Zora's River Waterfall + */ +void Audio_PlaySfxForWaterfall(Vec3f* pos, f32 freqScale) { + if (!Audio_IsSfxPlaying(NA_SE_EV_WATER_WALL_BIG - SFX_FLAG)) { + sWaterfallFreqScaleLerp.value = freqScale; + } else if (freqScale != sWaterfallFreqScaleLerp.value) { + sWaterfallFreqScaleLerp.target = freqScale; + sWaterfallFreqScaleLerp.remainingFrames = 40; + sWaterfallFreqScaleLerp.step = (sWaterfallFreqScaleLerp.target - sWaterfallFreqScaleLerp.value) / 40; + } + Audio_PlaySfxGeneral(NA_SE_EV_WATER_WALL_BIG - SFX_FLAG, pos, 4, &sWaterfallFreqScaleLerp.value, + &sWaterfallFreqScaleLerp.value, &D_801DB4B8); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A00EC.s") +/** + * Used for EnRiverSound variables + */ +void Audio_StepFreqLerp(FreqLerp* lerp) { + if (lerp->remainingFrames != 0) { + lerp->remainingFrames--; + if (lerp->remainingFrames != 0) { + lerp->value += lerp->step; + } else { + lerp->value = lerp->target; + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0124.s") @@ -2087,13 +2129,131 @@ const char sAudioOcarinaUnusedText7[] = "check is over!!! %d %d %d\n"; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0238.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A026C.s") +/** + * Unused remnant from OoT's EnRiverSound + * Was designed to incrementally increase volume of NA_BGM_GANON_TOWER for each new room during the climb of Ganon's + * Tower + */ +void Audio_SetGanonsTowerBgmVolumeLevel(u8 ganonsTowerLevel) { + u8 channelIndex; + s8 pan = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0318.s") + // Ganondorfs's Lair + if (ganonsTowerLevel == 0) { + pan = 0x7F; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0450.s") + for (channelIndex = 0; channelIndex < 16; channelIndex++) { + // CHAN_UPD_PAN_UNSIGNED + Audio_QueueCmdS8(((u8)(u32)channelIndex << 8) | 0x7000000, pan); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A046C.s") + // Lowest room in Ganon's Tower (Entrance Room) + if (ganonsTowerLevel == 7) { + // Adds a delay to setting the volume in the first room + sEnterGanonsTowerTimer = 2; + } else { + Audio_SetGanonsTowerBgmVolume(sGanonsTowerLevelsVol[ganonsTowerLevel % ARRAY_COUNTU(sGanonsTowerLevelsVol)]); + } +} + +/** + * Unused remnant from OoT's EnRiverSound + * If a new volume is requested for ganon's tower, update the volume and + * calculate a new low-pass filter cutoff and reverb based on the new volume + */ +s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume) { + u8 lowPassFilterCutoff; + u8 channelIndex; + u16 reverb; + + if (sGanonsTowerVol != targetVolume) { + // Sets the volume + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, targetVolume, 2); + + // Sets the filter cutoff of the form (lowPassFilterCutoff << 4) | (highPassFilter & 0xF). highPassFilter is + // always set to 0 + if (targetVolume < 0x40) { + // Only the first room + lowPassFilterCutoff = 0x10; + } else { + // Higher volume leads to a higher cut-off frequency in the low-pass filtering + lowPassFilterCutoff = (((targetVolume - 0x40) >> 2) + 1) << 4; + } + + Audio_QueueSeqCmd((8 << 28) | ((u8)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u8)(4) << 16) | ((u8)(15) << 8) | + (u8)(lowPassFilterCutoff)); + + // Sets the reverb + for (channelIndex = 0; channelIndex < ARRAY_COUNT(gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels); + channelIndex++) { + if (&gAudioContext.sequenceChannelNone != + gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]) { + // soundScriptIO[5] was set to 0x40 in channels 0, 1, and 4 (BGM no longer in OoT) + if ((u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->soundScriptIO[5] != + 0xFF) { + // Higher volume leads to lower reverb + reverb = + (((u16)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->soundScriptIO[5] - + targetVolume) + + 0x7F); + + if (reverb > 0x7F) { + reverb = 0x7F; + } + + // CHAN_UPD_REVERB + Audio_QueueCmdS8(_SHIFTL(5, 24, 8) | _SHIFTL(SEQ_PLAYER_BGM_MAIN, 16, 8) | + _SHIFTL(channelIndex, 8, 8), + (u8)reverb); + } + } + } + + sGanonsTowerVol = targetVolume; + } + return -1; +} + +/** + * Unused remnant from OoT's EnRiverSound + * Responsible for lowering market bgm in Child Market Entrance and Child Market Back Alley + * Only lowers volume for 1 frame, so must be called every frame to maintain lower volume + */ +void Audio_LowerMainBgmVolume(u8 volume) { + sRiverSoundMainBgmVol = volume; + sRiverSoundMainBgmLower = true; +} + +/** + * Unused remnant from OoT's EnRiverSound + * Still called by Audio_Update every frame, but none of these processes get initialized + */ +void Audio_UpdateRiverSoundVolumes(void) { + // Updates Main Bgm Volume (RiverSound of type RS_LOWER_MAIN_BGM_VOLUME) + if (sRiverSoundMainBgmLower == true) { + if (sRiverSoundMainBgmCurrentVol != sRiverSoundMainBgmVol) { + // lowers the volume for 1 frame + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, sRiverSoundMainBgmVol, 10); + sRiverSoundMainBgmCurrentVol = sRiverSoundMainBgmVol; + sRiverSoundMainBgmRestore = true; + } + sRiverSoundMainBgmLower = false; + } else if ((sRiverSoundMainBgmRestore == true) && !sAudioIsWindowOpen) { + // restores the volume every frame + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, 0x7F, 10); + sRiverSoundMainBgmCurrentVol = 0x7F; + sRiverSoundMainBgmRestore = false; + } + + // Update Ganon's Tower Volume (RiverSound of type RS_GANON_TOWER_7) + if (sEnterGanonsTowerTimer != 0) { + sEnterGanonsTowerTimer--; + if (sEnterGanonsTowerTimer == 0) { + Audio_SetGanonsTowerBgmVolume(sGanonsTowerLevelsVol[7]); + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0554.s") @@ -2107,13 +2267,71 @@ const char sAudioOcarinaUnusedText7[] = "check is over!!! %d %d %d\n"; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0868.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A09D4.s") +/** + * Unused remnant of OoT's EnRiverSound (func_800F4E30) + */ +void func_801A09D4(Vec3f* pos, f32 xzDistToPlayer) { + f32 volumeRel; + s8 pan; + u8 channelIndex; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0C70.s") + if (sRiverSoundBgmPos == NULL) { + sRiverSoundBgmPos = pos; + sRiverSoundXZDistToPlayer = xzDistToPlayer; + } else if (sRiverSoundBgmPos != pos) { + if (sRiverSoundXZDistToPlayer > xzDistToPlayer) { + sRiverSoundBgmPos = pos; + sRiverSoundXZDistToPlayer = xzDistToPlayer; + } + } else { + sRiverSoundXZDistToPlayer = xzDistToPlayer; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0C90.s") + if (sRiverSoundBgmPos->x > 100.0f) { + pan = 0x7F; + } else if (sRiverSoundBgmPos->x < -100.0f) { + pan = 0; + } else { + pan = ((sRiverSoundBgmPos->x / 100.0f) * 64.0f) + 64.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0CB0.s") + if (sRiverSoundXZDistToPlayer > 400.0f) { + volumeRel = 0.1f; + } else if (sRiverSoundXZDistToPlayer < 120.0f) { + volumeRel = 1.0f; + } else { + volumeRel = ((1.0f - ((sRiverSoundXZDistToPlayer - 120.0f) / 280.0f)) * 0.9f) + 0.1f; + } + + for (channelIndex = 0; channelIndex < 16; channelIndex++) { + if (channelIndex != 9) { + Audio_QueueSeqCmd(((u32)(6) << 28) | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(2) << 16) | + ((u32)(channelIndex) << 8) | ((u8)(127.0f * volumeRel))); + Audio_QueueCmdS8(0x03000000 | ((u8)((u32)channelIndex) << 8), pan); + } + } +} + +/** + * Unused remnant of OoT's EnRiverSound + */ +void Audio_ClearSariaBgm(void) { + if (sRiverSoundBgmPos != NULL) { + sRiverSoundBgmPos = NULL; + } +} + +/** + * Unused remnant of OoT's EnRiverSound + */ +void Audio_ClearSariaBgmAtPos(Vec3f* pos) { + if (sRiverSoundBgmPos == pos) { + sRiverSoundBgmPos = NULL; + } +} + +void Audio_SplitBgmChannels(s8 volumeSplit); +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SplitBgmChannels.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0E44.s") @@ -2147,9 +2365,58 @@ const char sAudioOcarinaUnusedText7[] = "check is over!!! %d %d %d\n"; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2090.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A21FC.s") +/** + * Unused remnant of OoT's EnRiverSound + */ +void Audio_PlaySariaBgm(Vec3f* pos, u16 seqId, u16 distMax) { + f32 absY; + f32 dist; + u8 targetVolume; + f32 prevDist; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2460.s") + if (sRiverSoundBgmTimer != 0) { + sRiverSoundBgmTimer--; + return; + } + + dist = sqrtf(SQ(pos->z) + (SQ(pos->x) + SQ(pos->y))); + + if (sRiverSoundBgmPos == NULL) { + sRiverSoundBgmPos = pos; + func_801A3238(SEQ_PLAYER_BGM_SUB, seqId, 0, 7, 2); + } else { + prevDist = sqrtf(SQ(sRiverSoundBgmPos->z) + SQ(sRiverSoundBgmPos->x)); + if (dist < prevDist) { + sRiverSoundBgmPos = pos; + } else { + dist = prevDist; + } + } + + absY = ABS_ALT(pos->y); + + if ((distMax / 15.0f) < absY) { + targetVolume = 0; + } else if (dist < distMax) { + targetVolume = (1.0f - (dist / distMax)) * 127.0f; + } else { + targetVolume = 0; + } + + if (seqId != NA_BGM_FAIRY_FOUNTAIN) { + Audio_SplitBgmChannels(targetVolume); + } + + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 3, targetVolume, 0); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F - targetVolume, 0); +} + +/** + * Unused remnant of OoT's EnRiverSound + */ +void Audio_ClearSariaBgm2(void) { + sRiverSoundBgmPos = NULL; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A246C.s") diff --git a/src/code/audio/code_801A5BD0.c b/src/code/audio/code_801A5BD0.c index 7d796aa9f..8397fd52e 100644 --- a/src/code/audio/code_801A5BD0.c +++ b/src/code/audio/code_801A5BD0.c @@ -40,6 +40,6 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A787C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A78E4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/Audio_IsSfxPlaying.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A794C.s") diff --git a/src/code/audio/code_801A7B10.c b/src/code/audio/code_801A7B10.c index d2d9a71a2..6d3faaeab 100644 --- a/src/code/audio/code_801A7B10.c +++ b/src/code/audio/code_801A7B10.c @@ -18,7 +18,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8B2C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8BD0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/Audio_SetVolumeScale.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8D5C.s") diff --git a/src/code/z_actor.c b/src/code/z_actor.c index c8e490311..6b7c863aa 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -3908,104 +3908,148 @@ Hilite* func_800BCC68(Vec3f* arg0, GlobalContext* globalCtx) { return Hilite_DrawXlu(arg0, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); } -void func_800BCCDC(Vec3s* points, s32 pathCount, Vec3f* pos1, Vec3f* pos2, s32 arg4) { - s32 spB4; - s32 spB0; - s32 spA8[2] = { 0, 0 }; - s32 spA0[2] = { 0, 0 }; - Vec3f sp94; - Vec3f sp7C[2]; - Vec3f sp70; - Vec3f sp64; - f32 sp60; - f32 sp5C; - f32 sp54[2]; +/** + * Calculates the closest position `dstPos` to the input position `srcPos` along the path given by `points`/`numPoints` + * Whether the points provided forms a closed-loop path is indicated by `isPathLoop` + */ +void Actor_GetClosestPosOnPath(Vec3s* points, s32 numPoints, Vec3f* srcPos, Vec3f* dstPos, s32 isPathLoop) { + s32 pointIndex; + s32 closestPointIndex; + s32 useAdjacentLines[2] = { + false, // determines whether to use line connecting to previous point in calculations + false, // determines whether to use line connecting to next point in calculations + }; + s32 isRightSideOfAdjacentLines[2] = { + false, // determines whether srcPos is on the right side of the line from prev to curr point + false, // determines whether srcPos is on the right side of the line from curr to next point + }; + Vec3f closestPoint; + Vec3f closestPos[2]; + Vec3f closestPointNext; + Vec3f closestPointPrev; + f32 distSq; // First used as distSq to closest point, then used as distSq to closest position + f32 closestPointDistSq; + f32 loopDistSq[2]; + s32 i; - spB0 = 0; - sp5C = SQ(40000.0f); + closestPointIndex = 0; + closestPointDistSq = SQ(40000.0f); - for (spB4 = 0; spB4 < pathCount; spB4++) { - sp60 = Math3D_XZDistanceSquared(pos1->x, pos1->z, points[spB4].x, points[spB4].z); - if (sp60 < sp5C) { - sp5C = sp60; - spB0 = spB4; + // Find the point closest to srcPos + for (pointIndex = 0; pointIndex < numPoints; pointIndex++) { + distSq = Math3D_XZDistanceSquared(srcPos->x, srcPos->z, points[pointIndex].x, points[pointIndex].z); + if (distSq < closestPointDistSq) { + closestPointDistSq = distSq; + closestPointIndex = pointIndex; } } - sp94.x = (points + spB0)->x; - sp94.z = (points + spB0)->z; - pos2->y = (points + spB0)->y; - if (spB0 != 0) { - sp64.x = (points + spB0 - 1)->x; - sp64.z = (points + spB0 - 1)->z; - } else if (arg4) { - sp64.x = (points + pathCount - 1)->x; - sp64.z = (points + pathCount - 1)->z; + closestPoint.x = (points + closestPointIndex)->x; + closestPoint.z = (points + closestPointIndex)->z; + dstPos->y = (points + closestPointIndex)->y; + + // Analyze point on path immediately previous to the closest point + if (closestPointIndex != 0) { + // The point previous to the closest point + closestPointPrev.x = (points + closestPointIndex - 1)->x; + closestPointPrev.z = (points + closestPointIndex - 1)->z; + } else if (isPathLoop) { + // Closest point is the first point in the path list + // Set the previous point to loop around to the the final point on the path + closestPointPrev.x = (points + numPoints - 1)->x; + closestPointPrev.z = (points + numPoints - 1)->z; + } + if ((closestPointIndex != 0) || isPathLoop) { + // Use the adjacent line + useAdjacentLines[0] = + Math3D_PointDistToLine2D(srcPos->x, srcPos->z, closestPointPrev.x, closestPointPrev.z, closestPoint.x, + closestPoint.z, &closestPos[0].x, &closestPos[0].z, &distSq); } - if ((spB0 != 0) || arg4) { - spA8[0] = - Math3D_PointDistToLine2D(pos1->x, pos1->z, sp64.x, sp64.z, sp94.x, sp94.z, &sp7C[0].x, &sp7C[0].z, &sp60); + // Analyze point on path immediately next to the closest point + if (closestPointIndex + 1 != numPoints) { + // The point next to the closest point + closestPointNext.x = (points + closestPointIndex + 1)->x; + closestPointNext.z = (points + closestPointIndex + 1)->z; + } else if (isPathLoop) { + // Closest point is the final point in the path list + // Set the next point to loop around to the the first point on the path + closestPointNext.x = (points + 0)->x; + closestPointNext.z = (points + 0)->z; + } + if ((closestPointIndex + 1 != numPoints) || isPathLoop) { + useAdjacentLines[1] = + Math3D_PointDistToLine2D(srcPos->x, srcPos->z, closestPoint.x, closestPoint.z, closestPointNext.x, + closestPointNext.z, &closestPos[1].x, &closestPos[1].z, &distSq); } - if (spB0 + 1 != pathCount) { - sp70.x = (points + spB0 + 1)->x; - sp70.z = (points + spB0 + 1)->z; - } else if (arg4) { - sp70.x = points->x; - sp70.z = points->z; - } + /** + * For close-looped paths, they must be defined in a clockwise orientation looking from the top down. + * Therefore, `srcPos` being interior of the loop will lead to both lines of `isRightSideOfAdjacentLines` + * returning true. + */ + if (isPathLoop) { + isRightSideOfAdjacentLines[0] = ((closestPointPrev.x - srcPos->x) * (closestPoint.z - srcPos->z)) < + ((closestPointPrev.z - srcPos->z) * (closestPoint.x - srcPos->x)); - if ((spB0 + 1 != pathCount) || arg4) { - spA8[1] = - Math3D_PointDistToLine2D(pos1->x, pos1->z, sp94.x, sp94.z, sp70.x, sp70.z, &sp7C[1].x, &sp7C[1].z, &sp60); - } + isRightSideOfAdjacentLines[1] = ((closestPointNext.z - srcPos->z) * (closestPoint.x - srcPos->x)) < + ((closestPoint.z - srcPos->z) * (closestPointNext.x - srcPos->x)); - if (arg4) { - s32 phi_s0_2; - - spA0[0] = ((sp64.x - pos1->x) * (sp94.z - pos1->z)) < ((sp64.z - pos1->z) * (sp94.x - pos1->x)); - spA0[1] = ((sp70.z - pos1->z) * (sp94.x - pos1->x)) < ((sp94.z - pos1->z) * (sp70.x - pos1->x)); - - for (phi_s0_2 = 0; phi_s0_2 < ARRAY_COUNT(sp54); phi_s0_2++) { - if (spA8[phi_s0_2] != 0) { - sp54[phi_s0_2] = Math3D_XZDistanceSquared(pos1->x, pos1->z, sp7C[phi_s0_2].x, sp7C[phi_s0_2].z); + for (i = 0; i < ARRAY_COUNT(loopDistSq); i++) { + if (useAdjacentLines[i]) { + // Get distSq from srcPos to closestPos + loopDistSq[i] = Math3D_XZDistanceSquared(srcPos->x, srcPos->z, closestPos[i].x, closestPos[i].z); } else { - sp54[phi_s0_2] = SQ(40000.0f); + // The closest Pos is not contained within the line-segment + loopDistSq[i] = SQ(40000.0f); } } } - if (arg4 && (((spA0[0] != 0) && (spA0[1] != 0)) || ((spA0[0] != 0) && (spA8[0] != 0) && (sp54[0] < sp54[1])) || - ((spA0[1] != 0) && (spA8[1] != 0) && (sp54[1] < sp54[0])))) { - pos2->x = pos1->x; - pos2->z = pos1->z; - } else if ((spA8[0] != 0) && (spA8[1] != 0)) { - if ((spA0[0] == 0) && (spA0[1] == 0)) { - if (Math3D_PointDistToLine2D(pos1->x, pos1->z, sp7C[0].x, sp7C[0].z, sp7C[1].x, sp7C[1].z, &pos2->x, - &pos2->z, &sp60) == 0) { - pos2->x = (sp7C[1].x + sp7C[0].x) * 0.5f; - pos2->z = (sp7C[1].z + sp7C[0].z) * 0.5f; + // Calculate closest position along path + if (isPathLoop && ((isRightSideOfAdjacentLines[0] && isRightSideOfAdjacentLines[1]) || + (isRightSideOfAdjacentLines[0] && useAdjacentLines[0] && (loopDistSq[0] < loopDistSq[1])) || + (isRightSideOfAdjacentLines[1] && useAdjacentLines[1] && (loopDistSq[1] < loopDistSq[0])))) { + // srcPos is contained within the closed loop + dstPos->x = srcPos->x; + dstPos->z = srcPos->z; + } else if (useAdjacentLines[0] && useAdjacentLines[1]) { + // srcPos is somewhere withing the bend of the path + if (!isRightSideOfAdjacentLines[0] && !isRightSideOfAdjacentLines[1]) { + // srcPos is not inside a loop + if (!Math3D_PointDistToLine2D(srcPos->x, srcPos->z, closestPos[0].x, closestPos[0].z, closestPos[1].x, + closestPos[1].z, &dstPos->x, &dstPos->z, &distSq)) { + // The dstPos calculated in Math3D_PointDistToLine2D was not valid. + // Take the midpoint of the two closest ponits instead + dstPos->x = (closestPos[1].x + closestPos[0].x) * 0.5f; + dstPos->z = (closestPos[1].z + closestPos[0].z) * 0.5f; } - } else if (sp54[1] < sp54[0]) { - pos2->x = sp7C[1].x; - pos2->z = sp7C[1].z; + } else if (loopDistSq[1] < loopDistSq[0]) { + // Use closest position along the line in the loop connecting the closest point and the next point + dstPos->x = closestPos[1].x; + dstPos->z = closestPos[1].z; } else { - pos2->x = sp7C[0].x; - pos2->z = sp7C[0].z; + // Use closest position along the ling in the loop connecting the closest point and the prev point + dstPos->x = closestPos[0].x; + dstPos->z = closestPos[0].z; } - } else if (spA8[0] != 0) { - pos2->x = sp7C[0].x; - pos2->z = sp7C[0].z; - } else if (spA8[1] != 0) { - pos2->x = sp7C[1].x; - pos2->z = sp7C[1].z; - } else if (arg4 && ((((sp64.x - pos1->x) * (sp70.z - pos1->z)) < ((sp64.z - pos1->z) * (sp70.x - pos1->x))))) { - pos2->x = pos1->x; - pos2->z = pos1->z; + } else if (useAdjacentLines[0]) { + // Use closest position along line segment connecting the closest point and the prev point + dstPos->x = closestPos[0].x; + dstPos->z = closestPos[0].z; + } else if (useAdjacentLines[1]) { + // Use closest position along line segment connecting the closest point and the next point + dstPos->x = closestPos[1].x; + dstPos->z = closestPos[1].z; + } else if (isPathLoop && ((((closestPointPrev.x - srcPos->x) * (closestPointNext.z - srcPos->z)) < + ((closestPointPrev.z - srcPos->z) * (closestPointNext.x - srcPos->x))))) { + // Inside the line that directly connects the previous point to the next point (inside the bend of a corner) + dstPos->x = srcPos->x; + dstPos->z = srcPos->z; } else { - pos2->x = sp94.x; - pos2->z = sp94.z; + // The closest point and the closest position are the same (srcPos is near the outer region of a corner) + dstPos->x = closestPoint.x; + dstPos->z = closestPoint.z; } } diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index 1139f6ef4..1ad88f3f8 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -7,6 +7,7 @@ #include "prevent_bss_reordering.h" #include "z_bg_hakugin_post.h" #include "objects/object_hakugin_obj/object_hakugin_obj.h" +#include "prevent_bss_reordering.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) diff --git a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c index db20137b1..2084130ce 100644 --- a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c +++ b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c @@ -1,7 +1,7 @@ /* * File: z_en_river_sound.c * Overlay: ovl_En_River_Sound - * Description: Various environment Sfx (e.g., ocean waves, gulls, waterfall, lava, etc) + * Description: Various environment Sfx along a path (e.g., ocean waves, gulls, waterfall, lava, etc) */ #include "z_en_river_sound.h" @@ -14,7 +14,6 @@ void EnRiverSound_Init(Actor* thisx, GlobalContext* globalCtx); void EnRiverSound_Update(Actor* thisx, GlobalContext* globalCtx); void EnRiverSound_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_River_Sound_InitVars = { ACTOR_EN_RIVER_SOUND, ACTORCAT_ITEMACTION, @@ -27,10 +26,68 @@ const ActorInit En_River_Sound_InitVars = { (ActorFunc)EnRiverSound_Draw, }; -#endif +void EnRiverSound_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRiverSound* this = THIS; + Path* path; + s32 pathIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_River_Sound/EnRiverSound_Init.s") + this->playSound = false; + pathIndex = RS_GET_PATH_INDEX(&this->actor); + this->actor.params = RS_GET_TYPE(&this->actor); + if (pathIndex == 0xFF) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_River_Sound/EnRiverSound_Update.s") + path = &globalCtx->setupPathList[pathIndex]; + this->pathPoints = Lib_SegmentedToVirtual(path->points); + this->numPoints = path->count; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_River_Sound/EnRiverSound_Draw.s") +void EnRiverSound_Update(Actor* thisx, GlobalContext* globalCtx) { + EnRiverSound* this = THIS; + Vec3f* worldPos = &this->actor.world.pos; + Vec3f eye; + s32 bgId; + + Math_Vec3f_Copy(&eye, &globalCtx->view.eye); + + if (this->actor.params < RS_RIVER_DEFAULT_LOW_FREQ) { + // All sfx from river_sound that accesses gAudioEnvironmentalSfx is associated with a closed-loop + // path that is used to play a regional sfx + Actor_GetClosestPosOnPath(this->pathPoints, this->numPoints, &eye, worldPos, true); + } else { + Actor_GetClosestPosOnPath(this->pathPoints, this->numPoints, &eye, worldPos, false); + if (BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, &this->actor, worldPos) != + BGCHECK_Y_MIN) { + this->soundFreqIndex = SurfaceType_GetConveyorSpeed(&globalCtx->colCtx, this->actor.floorPoly, bgId); + } else { + this->soundFreqIndex = 0; + } + + if (this->soundFreqIndex == 0) { + this->soundFreqIndex = this->actor.params - RS_RIVER_DEFAULT_LOW_FREQ; + } else { + this->soundFreqIndex--; + } + + this->soundFreqIndex = CLAMP_MAX(this->soundFreqIndex, 2); + } +} + +void EnRiverSound_Draw(Actor* thisx, GlobalContext* globalCtx) { + static f32 freqScale[] = { + 0.7f, // 1 / sqrt(2) + 1.0f, // 1 + 1.4f, // sqrt(2) + }; + EnRiverSound* this = THIS; + s16 params = this->actor.params; + + if (params < RS_RIVER_DEFAULT_LOW_FREQ) { + Actor_PlaySfxAtPos(&this->actor, gAudioEnvironmentalSfx[params]); + } else { + Audio_PlaySfxForRiver(&this->actor.projectedPos, freqScale[this->soundFreqIndex]); + } +} diff --git a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h index dc02f58fa..b8dbcc513 100644 --- a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h +++ b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h @@ -5,9 +5,44 @@ struct EnRiverSound; +#define RS_GET_TYPE(thisx) ((thisx)->params & 0xFF); +#define RS_GET_PATH_INDEX(thisx) (((thisx)->params >> 8) & 0xFF); + +// Any param not as one of these values will result in UB +typedef enum { + /* 0x00 */ RS_RIVER_STREAM, + /* 0x01 */ RS_WAVE, + /* 0x02 */ RS_WATER_WALL_BIG, + /* 0x03 */ RS_WATER_WALL, + /* 0x04 */ RS_MAGMA_LEVEL, + /* 0x05 */ RS_MAGMA_LEVEL_M, + /* 0x06 */ RS_MAGMA_LEVEL_L, + /* 0x07 */ RS_TORCH, + /* 0x08 */ RS_FOUNTAIN, + /* 0x09 */ RS_DRAIN, + /* 0x0A */ RS_CROWD, + /* 0x0B */ RS_WATER_CONVECTION, + /* 0x0C */ RS_GORON_CHEER, + /* 0x0D */ RS_WATER_WALL_BIG_SILENT, + /* 0x0E */ RS_WATER_BUBBLE, + /* 0x0F */ RS_COW_CRY_LV, + /* 0x10 */ RS_MAKE_TURRET, + /* 0x11 */ RS_BOILED_WATER_S, + /* 0x12 */ RS_BOILED_WATER_L, + /* 0x13 */ RS_WAVE_0, + /* 0x14 */ RS_WAVE_1, + /* 0x15 */ RS_WAVE_2, + /* 0xFD */ RS_RIVER_DEFAULT_LOW_FREQ = 0xFD, + /* 0xFE */ RS_RIVER_DEFAULT_MEDIUM_FREQ, + /* 0xFF */ RS_RIVER_DEFAULT_HIGH_FREQ +} RiverSoundType; + typedef struct EnRiverSound { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x8]; + /* 0x144 */ u8 playSound; // Unused remnant of OoT + /* 0x145 */ u8 soundFreqIndex; + /* 0x146 */ u8 numPoints; + /* 0x148 */ Vec3s* pathPoints; } EnRiverSound; // size = 0x14C extern const ActorInit En_River_Sound_InitVars; diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index 7e025ce43..88c7a3778 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -422,8 +422,8 @@ void func_809672DC(EnWeatherTag* this, GlobalContext* globalCtx) { f32 range; f32 strength = 0.0f; - func_800BCCDC(this->pathPoints, this->pathCount, &GET_PLAYER(globalCtx)->actor.world.pos, &this->actor.world.pos, - 0); + Actor_GetClosestPosOnPath(this->pathPoints, this->pathCount, &GET_PLAYER(globalCtx)->actor.world.pos, + &this->actor.world.pos, false); distance = Actor_XZDistanceBetweenActors(&player->actor, &this->actor); range = WEATHER_TAG_RANGE100(this); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index ffcbdf8fe..d3a00f445 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -867,7 +867,7 @@ 0x800BCB70:("Actor_SetColorFilter",), 0x800BCBF4:("func_800BCBF4",), 0x800BCC68:("func_800BCC68",), - 0x800BCCDC:("func_800BCCDC",), + 0x800BCCDC:("Actor_GetClosestPosOnPath",), 0x800BD2B4:("func_800BD2B4",), 0x800BD384:("func_800BD384",), 0x800BD6B8:("func_800BD6B8",), @@ -3689,7 +3689,7 @@ 0x8019380C:("func_8019380C",), 0x80193858:("func_80193858",), 0x8019387C:("func_8019387C",), - 0x801938A0:("func_801938A0",), + 0x801938A0:("Audio_QueueCmdS8",), 0x801938D0:("func_801938D0",), 0x80193900:("func_80193900",), 0x80193990:("func_80193990",), @@ -3897,18 +3897,18 @@ 0x8019FE74:("func_8019FE74",), 0x8019FEDC:("func_8019FEDC",), 0x8019FF38:("func_8019FF38",), - 0x8019FF9C:("func_8019FF9C",), - 0x801A0048:("func_801A0048",), - 0x801A00EC:("func_801A00EC",), + 0x8019FF9C:("Audio_PlaySfxForRiver",), + 0x801A0048:("Audio_PlaySfxForWaterfall",), + 0x801A00EC:("Audio_StepFreqLerp",), 0x801A0124:("func_801A0124",), 0x801A0184:("func_801A0184",), 0x801A01C4:("func_801A01C4",), 0x801A0204:("func_801A0204",), 0x801A0238:("func_801A0238",), - 0x801A026C:("func_801A026C",), - 0x801A0318:("func_801A0318",), - 0x801A0450:("func_801A0450",), - 0x801A046C:("func_801A046C",), + 0x801A026C:("Audio_SetGanonsTowerBgmVolumeLevel",), + 0x801A0318:("Audio_SetGanonsTowerBgmVolume",), + 0x801A0450:("Audio_LowerMainBgmVolume",), + 0x801A046C:("Audio_UpdateRiverSoundVolumes",), 0x801A0554:("func_801A0554",), 0x801A05E4:("func_801A05E4",), 0x801A05F0:("func_801A05F0",), @@ -3916,9 +3916,9 @@ 0x801A0810:("func_801A0810",), 0x801A0868:("func_801A0868",), 0x801A09D4:("func_801A09D4",), - 0x801A0C70:("func_801A0C70",), - 0x801A0C90:("func_801A0C90",), - 0x801A0CB0:("func_801A0CB0",), + 0x801A0C70:("Audio_ClearSariaBgm",), + 0x801A0C90:("Audio_ClearSariaBgmAtPos",), + 0x801A0CB0:("Audio_SplitBgmChannels",), 0x801A0E44:("func_801A0E44",), 0x801A1290:("func_801A1290",), 0x801A1348:("func_801A1348",), @@ -3935,8 +3935,8 @@ 0x801A1F88:("func_801A1F88",), 0x801A1FB4:("func_801A1FB4",), 0x801A2090:("func_801A2090",), - 0x801A21FC:("func_801A21FC",), - 0x801A2460:("func_801A2460",), + 0x801A21FC:("Audio_PlaySariaBgm",), + 0x801A2460:("Audio_ClearSariaBgm2",), 0x801A246C:("func_801A246C",), 0x801A2544:("func_801A2544",), 0x801A257C:("func_801A257C",), @@ -4050,7 +4050,7 @@ 0x801A7794:("func_801A7794",), 0x801A7828:("func_801A7828",), 0x801A787C:("func_801A787C",), - 0x801A78E4:("func_801A78E4",), + 0x801A78E4:("Audio_IsSfxPlaying",), 0x801A794C:("func_801A794C",), 0x801A7B10:("func_801A7B10",), 0x801A7D04:("func_801A7D04",), @@ -4061,7 +4061,7 @@ 0x801A8ABC:("func_801A8ABC",), 0x801A8B14:("func_801A8B14",), 0x801A8B2C:("func_801A8B2C",), - 0x801A8BD0:("func_801A8BD0",), + 0x801A8BD0:("Audio_SetVolumeScale",), 0x801A8D5C:("func_801A8D5C",), 0x801A9768:("func_801A9768",), 0x801A982C:("func_801A982C",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 13c89fa37..bc8fd6f48 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -381,7 +381,7 @@ asm/non_matchings/code/z_actor/Actor_SpawnShieldParticlesMetal.s,Actor_SpawnShie asm/non_matchings/code/z_actor/Actor_SetColorFilter.s,Actor_SetColorFilter,0x800BCB70,0x21 asm/non_matchings/code/z_actor/func_800BCBF4.s,func_800BCBF4,0x800BCBF4,0x1D asm/non_matchings/code/z_actor/func_800BCC68.s,func_800BCC68,0x800BCC68,0x1D -asm/non_matchings/code/z_actor/func_800BCCDC.s,func_800BCCDC,0x800BCCDC,0x176 +asm/non_matchings/code/z_actor/Actor_GetClosestPosOnPath.s,Actor_GetClosestPosOnPath,0x800BCCDC,0x176 asm/non_matchings/code/z_actor/func_800BD2B4.s,func_800BD2B4,0x800BD2B4,0x34 asm/non_matchings/code/z_actor/func_800BD384.s,func_800BD384,0x800BD384,0xCD asm/non_matchings/code/z_actor/func_800BD6B8.s,func_800BD6B8,0x800BD6B8,0xB @@ -3205,7 +3205,7 @@ asm/non_matchings/code/code_80192BE0/func_80193774.s,func_80193774,0x80193774,0x asm/non_matchings/code/code_80192BE0/func_8019380C.s,func_8019380C,0x8019380C,0x13 asm/non_matchings/code/code_80192BE0/func_80193858.s,func_80193858,0x80193858,0x9 asm/non_matchings/code/code_80192BE0/func_8019387C.s,func_8019387C,0x8019387C,0x9 -asm/non_matchings/code/code_80192BE0/func_801938A0.s,func_801938A0,0x801938A0,0xC +asm/non_matchings/code/code_80192BE0/Audio_QueueCmdS8.s,Audio_QueueCmdS8,0x801938A0,0xC asm/non_matchings/code/code_80192BE0/func_801938D0.s,func_801938D0,0x801938D0,0xC asm/non_matchings/code/code_80192BE0/func_80193900.s,func_80193900,0x80193900,0x24 asm/non_matchings/code/code_80192BE0/func_80193990.s,func_80193990,0x80193990,0x6 @@ -3413,18 +3413,18 @@ asm/non_matchings/code/code_8019AF00/func_8019FE1C.s,func_8019FE1C,0x8019FE1C,0x asm/non_matchings/code/code_8019AF00/func_8019FE74.s,func_8019FE74,0x8019FE74,0x1A asm/non_matchings/code/code_8019AF00/func_8019FEDC.s,func_8019FEDC,0x8019FEDC,0x17 asm/non_matchings/code/code_8019AF00/func_8019FF38.s,func_8019FF38,0x8019FF38,0x19 -asm/non_matchings/code/code_8019AF00/func_8019FF9C.s,func_8019FF9C,0x8019FF9C,0x2B -asm/non_matchings/code/code_8019AF00/func_801A0048.s,func_801A0048,0x801A0048,0x29 -asm/non_matchings/code/code_8019AF00/func_801A00EC.s,func_801A00EC,0x801A00EC,0xE +asm/non_matchings/code/code_8019AF00/Audio_PlaySfxForRiver.s,Audio_PlaySfxForRiver,0x8019FF9C,0x2B +asm/non_matchings/code/code_8019AF00/Audio_PlaySfxForWaterfall.s,Audio_PlaySfxForWaterfall,0x801A0048,0x29 +asm/non_matchings/code/code_8019AF00/Audio_StepFreqLerp.s,Audio_StepFreqLerp,0x801A00EC,0xE asm/non_matchings/code/code_8019AF00/func_801A0124.s,func_801A0124,0x801A0124,0x18 asm/non_matchings/code/code_8019AF00/func_801A0184.s,func_801A0184,0x801A0184,0x10 asm/non_matchings/code/code_8019AF00/func_801A01C4.s,func_801A01C4,0x801A01C4,0x10 asm/non_matchings/code/code_8019AF00/func_801A0204.s,func_801A0204,0x801A0204,0xD asm/non_matchings/code/code_8019AF00/func_801A0238.s,func_801A0238,0x801A0238,0xD -asm/non_matchings/code/code_8019AF00/func_801A026C.s,func_801A026C,0x801A026C,0x2B -asm/non_matchings/code/code_8019AF00/func_801A0318.s,func_801A0318,0x801A0318,0x4E -asm/non_matchings/code/code_8019AF00/func_801A0450.s,func_801A0450,0x801A0450,0x7 -asm/non_matchings/code/code_8019AF00/func_801A046C.s,func_801A046C,0x801A046C,0x3A +asm/non_matchings/code/code_8019AF00/Audio_SetGanonsTowerBgmVolumeLevel.s,Audio_SetGanonsTowerBgmVolumeLevel,0x801A026C,0x2B +asm/non_matchings/code/code_8019AF00/Audio_SetGanonsTowerBgmVolume.s,Audio_SetGanonsTowerBgmVolume,0x801A0318,0x4E +asm/non_matchings/code/code_8019AF00/Audio_LowerMainBgmVolume.s,Audio_LowerMainBgmVolume,0x801A0450,0x7 +asm/non_matchings/code/code_8019AF00/Audio_UpdateRiverSoundVolumes.s,Audio_UpdateRiverSoundVolumes,0x801A046C,0x3A asm/non_matchings/code/code_8019AF00/func_801A0554.s,func_801A0554,0x801A0554,0x24 asm/non_matchings/code/code_8019AF00/func_801A05E4.s,func_801A05E4,0x801A05E4,0x3 asm/non_matchings/code/code_8019AF00/func_801A05F0.s,func_801A05F0,0x801A05F0,0x19 @@ -3432,9 +3432,9 @@ asm/non_matchings/code/code_8019AF00/func_801A0654.s,func_801A0654,0x801A0654,0x asm/non_matchings/code/code_8019AF00/func_801A0810.s,func_801A0810,0x801A0810,0x16 asm/non_matchings/code/code_8019AF00/func_801A0868.s,func_801A0868,0x801A0868,0x5B asm/non_matchings/code/code_8019AF00/func_801A09D4.s,func_801A09D4,0x801A09D4,0xA7 -asm/non_matchings/code/code_8019AF00/func_801A0C70.s,func_801A0C70,0x801A0C70,0x8 -asm/non_matchings/code/code_8019AF00/func_801A0C90.s,func_801A0C90,0x801A0C90,0x8 -asm/non_matchings/code/code_8019AF00/func_801A0CB0.s,func_801A0CB0,0x801A0CB0,0x65 +asm/non_matchings/code/code_8019AF00/Audio_ClearSariaBgm.s,Audio_ClearSariaBgm,0x801A0C70,0x8 +asm/non_matchings/code/code_8019AF00/Audio_ClearSariaBgmAtPos.s,Audio_ClearSariaBgmAtPos,0x801A0C90,0x8 +asm/non_matchings/code/code_8019AF00/Audio_SplitBgmChannels.s,Audio_SplitBgmChannels,0x801A0CB0,0x65 asm/non_matchings/code/code_8019AF00/func_801A0E44.s,func_801A0E44,0x801A0E44,0x113 asm/non_matchings/code/code_8019AF00/func_801A1290.s,func_801A1290,0x801A1290,0x2E asm/non_matchings/code/code_8019AF00/func_801A1348.s,func_801A1348,0x801A1348,0x1D @@ -3451,8 +3451,8 @@ asm/non_matchings/code/code_8019AF00/func_801A1F00.s,func_801A1F00,0x801A1F00,0x asm/non_matchings/code/code_8019AF00/func_801A1F88.s,func_801A1F88,0x801A1F88,0xB asm/non_matchings/code/code_8019AF00/func_801A1FB4.s,func_801A1FB4,0x801A1FB4,0x37 asm/non_matchings/code/code_8019AF00/func_801A2090.s,func_801A2090,0x801A2090,0x5B -asm/non_matchings/code/code_8019AF00/func_801A21FC.s,func_801A21FC,0x801A21FC,0x99 -asm/non_matchings/code/code_8019AF00/func_801A2460.s,func_801A2460,0x801A2460,0x3 +asm/non_matchings/code/code_8019AF00/Audio_PlaySariaBgm.s,Audio_PlaySariaBgm,0x801A21FC,0x99 +asm/non_matchings/code/code_8019AF00/Audio_ClearSariaBgm2.s,Audio_ClearSariaBgm2,0x801A2460,0x3 asm/non_matchings/code/code_8019AF00/func_801A246C.s,func_801A246C,0x801A246C,0x36 asm/non_matchings/code/code_8019AF00/func_801A2544.s,func_801A2544,0x801A2544,0xE asm/non_matchings/code/code_8019AF00/func_801A257C.s,func_801A257C,0x801A257C,0x1A @@ -3566,7 +3566,7 @@ asm/non_matchings/code/code_801A5BD0/func_801A7720.s,func_801A7720,0x801A7720,0x asm/non_matchings/code/code_801A5BD0/func_801A7794.s,func_801A7794,0x801A7794,0x25 asm/non_matchings/code/code_801A5BD0/func_801A7828.s,func_801A7828,0x801A7828,0x15 asm/non_matchings/code/code_801A5BD0/func_801A787C.s,func_801A787C,0x801A787C,0x1A -asm/non_matchings/code/code_801A5BD0/func_801A78E4.s,func_801A78E4,0x801A78E4,0x1A +asm/non_matchings/code/code_801A5BD0/Audio_IsSfxPlaying.s,Audio_IsSfxPlaying,0x801A78E4,0x1A asm/non_matchings/code/code_801A5BD0/func_801A794C.s,func_801A794C,0x801A794C,0x71 asm/non_matchings/code/code_801A7B10/func_801A7B10.s,func_801A7B10,0x801A7B10,0x7D asm/non_matchings/code/code_801A7B10/func_801A7D04.s,func_801A7D04,0x801A7D04,0x20 @@ -3577,7 +3577,7 @@ asm/non_matchings/code/code_801A7B10/func_801A8A50.s,func_801A8A50,0x801A8A50,0x asm/non_matchings/code/code_801A7B10/func_801A8ABC.s,func_801A8ABC,0x801A8ABC,0x16 asm/non_matchings/code/code_801A7B10/func_801A8B14.s,func_801A8B14,0x801A8B14,0x6 asm/non_matchings/code/code_801A7B10/func_801A8B2C.s,func_801A8B2C,0x801A8B2C,0x29 -asm/non_matchings/code/code_801A7B10/func_801A8BD0.s,func_801A8BD0,0x801A8BD0,0x63 +asm/non_matchings/code/code_801A7B10/Audio_SetVolumeScale.s,Audio_SetVolumeScale,0x801A8BD0,0x63 asm/non_matchings/code/code_801A7B10/func_801A8D5C.s,func_801A8D5C,0x801A8D5C,0x283 asm/non_matchings/code/code_801A7B10/func_801A9768.s,func_801A9768,0x801A9768,0x31 asm/non_matchings/code/code_801A7B10/func_801A982C.s,func_801A982C,0x801A982C,0x63 From 928acac500e8b7df19998003b466b4dc8371dc01 Mon Sep 17 00:00:00 2001 From: louist103 <35883445+louist103@users.noreply.github.com> Date: Sun, 27 Mar 2022 10:47:34 -0400 Subject: [PATCH 137/257] Bombers2 OK (#721) * OK * OK * cleanups * restore makefile * format * format * format * Update src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h Co-authored-by: Derek Hensley * Update src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h Co-authored-by: Derek Hensley * Update src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c Co-authored-by: Derek Hensley * Update src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c Co-authored-by: Derek Hensley * Update src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c Co-authored-by: Derek Hensley * Update src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c Co-authored-by: Derek Hensley * Update object_cs.xml * fixes * format Co-authored-by: Derek Hensley Co-authored-by: angie --- assets/xml/objects/object_cs.xml | 4 +- include/z64.h | 6 +- spec | 3 +- src/code/code_8012EC80.c | 6 +- .../ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c | 4 +- .../actors/ovl_En_Bombers/z_en_bombers.c | 4 +- .../actors/ovl_En_Bombers2/z_en_bombers2.c | 407 +++++++++++++++++- .../actors/ovl_En_Bombers2/z_en_bombers2.h | 31 +- .../actors/ovl_En_Bomjima/z_en_bomjima.c | 6 +- .../actors/ovl_En_Bomjimb/z_en_bomjimb.c | 6 +- tools/disasm/functions.txt | 2 +- tools/disasm/variables.txt | 18 +- 12 files changed, 444 insertions(+), 53 deletions(-) diff --git a/assets/xml/objects/object_cs.xml b/assets/xml/objects/object_cs.xml index 5ed725493..803d2b02c 100644 --- a/assets/xml/objects/object_cs.xml +++ b/assets/xml/objects/object_cs.xml @@ -20,7 +20,7 @@ - + @@ -62,7 +62,7 @@ - + diff --git a/include/z64.h b/include/z64.h index c8e423cfb..dc8912d49 100644 --- a/include/z64.h +++ b/include/z64.h @@ -863,10 +863,8 @@ typedef struct { /* 0x12046 */ UNK_TYPE1 pad12046[0x2]; /* 0x12048 */ u8 unk12048; // EnKakasi /* 0x12049 */ UNK_TYPE1 pad12049[0xB]; - /* 0x12054 */ s16 unk12054; // First digit in lottery code guess - /* 0x12056 */ s16 unk12056; // Second digit lottery code guess - /* 0x12058 */ s16 unk12058; // Third digit lottery code guess - /* 0x1205A */ UNK_TYPE1 pad1205A[0x10]; + /* 0x12054 */ s16 unk12054[5]; // Number entry + /* 0x1205A */ UNK_TYPE1 pad1205A[0xC]; /* 0x1206A */ s16 unk1206A; /* 0x1206C */ s32 unk1206C; /* 0x12070 */ s32 unk12070; diff --git a/spec b/spec index be7b1bd66..8ec008154 100644 --- a/spec +++ b/spec @@ -5003,8 +5003,7 @@ beginseg name "ovl_En_Bombers2" compress include "build/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.o" - include "build/data/ovl_En_Bombers2/ovl_En_Bombers2.data.o" - include "build/data/ovl_En_Bombers2/ovl_En_Bombers2.reloc.o" + include "build/src/overlays/actors/ovl_En_Bombers2/ovl_En_Bombers2_reloc.o" endseg beginseg diff --git a/src/code/code_8012EC80.c b/src/code/code_8012EC80.c index c65697483..f60d98568 100644 --- a/src/code/code_8012EC80.c +++ b/src/code/code_8012EC80.c @@ -720,8 +720,8 @@ s16 Inventory_GetSkullTokenCount(s16 sceneIndex) { void Inventory_SaveLotteryCodeGuess(GlobalContext* globalCtx) { u16 lotteryCodeGuess; - lotteryCodeGuess = ((globalCtx->msgCtx.unk12054 & 0xF) << 8); // First Digit - lotteryCodeGuess |= ((globalCtx->msgCtx.unk12056 & 0xF) << 4); // Second Digit - lotteryCodeGuess |= (globalCtx->msgCtx.unk12058 & 0xF); // Third Digit + lotteryCodeGuess = ((globalCtx->msgCtx.unk12054[0] & 0xF) << 8); // First Digit + lotteryCodeGuess |= ((globalCtx->msgCtx.unk12054[1] & 0xF) << 4); // Second Digit + lotteryCodeGuess |= (globalCtx->msgCtx.unk12054[2] & 0xF); // Third Digit gSaveContext.lotteryCodeGuess = (gSaveContext.lotteryCodeGuess & 0xFFFF0000) | (lotteryCodeGuess & 0xFFFF); } diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c index 397f23068..3b78fbcd1 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c @@ -50,7 +50,7 @@ const ActorInit En_Bom_Bowl_Man_InitVars = { }; static AnimationHeader* sAnimations[] = { - &object_cs_Anim_0064B8, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, + &gBomberIdleAnim, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_001A1C, &object_cs_Anim_003EE4, &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, &object_cs_Anim_001708, @@ -76,7 +76,7 @@ void EnBomBowlMan_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); this->actor.gravity = -3.0f; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &object_cs_Anim_0064B8, this->jointTable, + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, this->morphTable, 21); this->unk_2F6 = ENBOMBOWLMAN_GET_F0(&this->actor); this->unk_2F4 = ENBOMBOWLMAN_GET_F(&this->actor); 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 4024c39b0..3bedadb4b 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c @@ -58,7 +58,7 @@ static ColliderCylinderInit sCylinderInit = { }; AnimationHeader* D_80C0479C[] = { - &object_cs_Anim_0064B8, &object_cs_Anim_0053F4, &object_cs_Anim_01007C, &object_cs_Anim_00349C, + &gBomberIdleAnim, &object_cs_Anim_0053F4, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_001A1C, &object_cs_Anim_003EE4, &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, &object_cs_Anim_001708, &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, &object_cs_Anim_0036B0, @@ -94,7 +94,7 @@ void EnBombers_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); this->actor.gravity = -1.0f; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &object_cs_Anim_0064B8, this->jointTable, + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, this->morphtable, 21); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actor.targetMode = 0; diff --git a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c index bcd76ab9d..6f51487e8 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c @@ -18,8 +18,11 @@ void EnBombers2_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80C04BA0(EnBombers2* this, GlobalContext* globalCtx); void func_80C04D8C(EnBombers2* this, GlobalContext* globalCtx); void func_80C0520C(EnBombers2* this, GlobalContext* globalCtx); +void func_80C04B40(EnBombers2* this); +void EnBombers2_ChangeAnim(EnBombers2* this, s32 animIndex, f32 playSpeed); +void func_80C04D00(EnBombers2* this); +void func_80C050B8(EnBombers2* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Bombers2_InitVars = { ACTOR_EN_BOMBERS2, ACTORCAT_NPC, @@ -32,39 +35,403 @@ const ActorInit En_Bombers2_InitVars = { (ActorFunc)EnBombers2_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C058B0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static u16 sTextIds[] = { + 0x0727, 0x0728, 0x0726, 0x0729, 0x072B, 0x0725, 0x072A, 0x073C, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 35, 30, 0, { 0, 0, 0 } }, }; -#endif +static AnimationHeader* sAnimations[] = { + &gBomberIdleAnim, &object_cs_Anim_0053F4, &object_cs_Anim_01007C, &object_cs_Anim_00349C, + &object_cs_Anim_0060E8, &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, +}; -extern ColliderCylinderInit D_80C058B0; +static u8 sAnimModes[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, +}; -extern UNK_TYPE D_060064B8; +static Gfx sSetPrimColorDL[] = { + gsDPSetPrimColor(0, 0xFF, 198, 140, 0, 255), + gsSPEndDisplayList(), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/EnBombers2_Init.s") +static Gfx* sSetPrimColorDlPtr = sSetPrimColorDL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/EnBombers2_Destroy.s") +static TexturePtr sEyeTextures[] = { + object_cs_Tex_00C520, + object_cs_Tex_00CD20, + object_cs_Tex_00D520, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04AAC.s") +static TexturePtr D_80C05920 = object_cs_Tex_00E220; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04B40.s") +void EnBombers2_Init(Actor* thisx, GlobalContext* globalCtx) { + f32 cos; + EnBombers2* this = (EnBombers2*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04BA0.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->morphTable, + this->jointTable, OBJECT_CS_LIMB_MAX); + this->actor.targetMode = 6; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + if ((gSaveContext.weekEventReg[0x49] & 0x80) || (gSaveContext.entranceIndex == 0xD220)) { + this->actor.world.pos.x += Math_SinS(this->actor.home.rot.y + 0xC100) * 50.0f; + cos = Math_CosS(this->actor.home.rot.y + 0xC100) * 50.0f; + this->unk_2AC = 1; + this->actor.world.pos.z += cos; + } + this->cutscene = this->actor.cutscene; + if (this->cutscene == 0) { + Actor_MarkForDeath(&this->actor); + } + func_80C04B40(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04D00.s") +void EnBombers2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBombers2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04D8C.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C050B8.s") +void EnBombers2_ChangeAnim(EnBombers2* this, s32 animIndex, f32 playSpeed) { + f32 lastFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C0520C.s") + this->animIndex = animIndex; + lastFrame = Animation_GetLastFrame(sAnimations[this->animIndex]); + this->lastAnimFrame = lastFrame; + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], playSpeed, 0.0f, lastFrame, + sAnimModes[this->animIndex], -10.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/EnBombers2_Update.s") +void func_80C04B40(EnBombers2* this) { + if (this->unk_2AC == 0) { + EnBombers2_ChangeAnim(this, 4, 1.0f); + } else { + EnBombers2_ChangeAnim(this, 0, 1.0f); + } + this->unk_2C0 = 0; + this->actionFunc = func_80C04BA0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C056D4.s") +void func_80C04BA0(EnBombers2* this, GlobalContext* globalCtx) { + s32 yawDiffAbs; + s16 yawDiff; + Player* player; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/EnBombers2_Draw.s") + yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + yawDiffAbs = ABS_ALT(yawDiff); + player = GET_PLAYER(globalCtx); + + switch (player->transformation) { + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + this->textIdIndex = 1; + this->unk_2CE = 5; + break; + case PLAYER_FORM_DEKU: + case PLAYER_FORM_HUMAN: + this->textIdIndex = 2; + this->unk_2CE = 5; + break; + } + if (this->unk_2AC != 0) { + this->textIdIndex = 7; + } + this->actor.textId = sTextIds[this->textIdIndex]; + + if (Text_GetFaceReaction(globalCtx, 0x15) != 0) { + this->actor.textId = Text_GetFaceReaction(globalCtx, 0x15); + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2B6 = this->actor.world.rot.y; + gSaveContext.weekEventReg[0x56] |= 2; + func_80C04D00(this); + return; + } + if (yawDiffAbs < 0x3BB5) { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} + +void func_80C04D00(EnBombers2* this) { + if ((this->textIdIndex == 0) || (this->textIdIndex == 1)) { + EnBombers2_ChangeAnim(this, 5, 1.0f); + } else { + EnBombers2_ChangeAnim(this, 1, 1.0f); + } + + this->unk_2A8 = 0; + if (this->unk_2AC != 0) { + EnBombers2_ChangeAnim(this, 6, 1.0f); + } + this->unk_2C0 = 1; + this->actionFunc = func_80C04D8C; +} + +void func_80C04D8C(EnBombers2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp = this->skelAnime.curFrame; + + if ((this->unk_2AC == 0) && (this->lastAnimFrame <= temp)) { + if (!(this->unk_2A8 & 1)) { + EnBombers2_ChangeAnim(this, 1, 1.0f); + } else { + EnBombers2_ChangeAnim(this, 5, 1.0f); + } + this->unk_2A8++; + this->unk_2A8 &= 1; + } + switch (player->transformation) { + case PLAYER_FORM_HUMAN: + this->unk_28E = -0xFA0; + break; + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + this->unk_28E = -0x1770; + break; + default: + break; + } + if ((this->unk_2CE == Message_GetState(&globalCtx->msgCtx)) && (func_80147624(globalCtx) != 0)) { + if (this->unk_2CE == 0xF) { + s32 i; + s32 correctDigits; + + for (i = 0; i < ARRAY_COUNT(this->correctDigitSlots); i++) { + if (!(this->correctDigitSlots[i]) && (globalCtx->msgCtx.unk12054[i] == gSaveContext.bomberCode[i])) { + this->correctDigitSlots[i] = true; + } + } + for (i = 0, correctDigits = 0; i < ARRAY_COUNT(this->correctDigitSlots); i++) { + if (this->correctDigitSlots[i]) { + correctDigits++; + } + } + + if (correctDigits >= 5) { + this->textIdIndex = 6; + this->actor.textId = sTextIds[this->textIdIndex]; + func_80151938(globalCtx, this->actor.textId); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); + this->unk_2CE = 5; + return; + } + } + if (Text_GetFaceReaction(globalCtx, 0x15) != 0) { + this->unk_28E = 0; + func_801477B4(globalCtx); + func_80C04B40(this); + } else { + s32 j; + + switch (this->textIdIndex) { + case 0: + case 1: + case 5: + case 7: + this->unk_28E = 0; + func_801477B4(globalCtx); + func_80C04B40(this); + break; + case 2: + this->textIdIndex = 3; + this->actor.textId = sTextIds[this->textIdIndex]; + func_80151938(globalCtx, this->actor.textId); + this->unk_2CE = 0xF; + break; + case 3: + for (j = 0; j < ARRAY_COUNT(this->correctDigitSlots); j++) { + this->correctDigitSlots[j] = false; + } + this->textIdIndex = 4; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + this->actor.textId = sTextIds[this->textIdIndex]; + func_80151938(globalCtx, this->actor.textId); + this->unk_2CE = 5; + break; + case 4: + this->textIdIndex = 5; + this->actor.textId = sTextIds[this->textIdIndex]; + func_80151938(globalCtx, this->actor.textId); + this->unk_2CE = 5; + break; + case 6: + globalCtx->msgCtx.unk11F10 = 0; + func_80C050B8(this, globalCtx); + break; + } + } + } +} + +void func_80C050B8(EnBombers2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 homeYawToPlayer; + + EnBombers2_ChangeAnim(this, 2, 1.0f); + this->unk_2A8 = 0; + homeYawToPlayer = Math_Vec3f_Yaw(&this->actor.home.pos, &player->actor.world.pos); + Math_Vec3f_Copy(&this->unk_29C, &this->actor.world.pos); + if (this->actor.home.rot.y < homeYawToPlayer) { + this->unk_29C.x += Math_SinS(this->actor.home.rot.y + 0xC100) * 50.0f; + this->unk_29C.z += Math_CosS(this->actor.home.rot.y + 0xC100) * 50.0f; + } else { + this->unk_29C.x += Math_SinS(this->actor.home.rot.y + 0x3F00) * 50.0f; + this->unk_29C.z += Math_CosS(this->actor.home.rot.y + 0x3F00) * 50.0f; + } + this->unk_2B6 = Math_Vec3f_Yaw(&this->actor.home.pos, &this->unk_29C); + this->unk_2C0 = 2; + this->actionFunc = func_80C0520C; +} + +void func_80C0520C(EnBombers2* this, GlobalContext* globalCtx) { + if (this->unk_2A8 == 0) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->cutscene) == 0) { + ActorCutscene_SetIntentToPlay(this->cutscene); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &this->actor); + this->unk_2A8 = 1; + } + } else { + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2B6, 1, 0xBB8, 0); + if ((fabsf(this->unk_29C.x - this->actor.world.pos.x) < 3.0f) && + (fabsf(this->unk_29C.z - this->actor.world.pos.z) < 3.0f)) { + this->unk_2B6 = this->actor.yawTowardsPlayer; + this->actor.speedXZ = 0.0f; + if (fabsf(this->actor.world.rot.y - this->actor.yawTowardsPlayer) < 100.0f) { + func_801477B4(globalCtx); + this->unk_2CE = 5; + this->textIdIndex = 7; + EnBombers2_ChangeAnim(this, 6, 1.0f); + this->unk_2A8 = 0; + this->unk_2C0 = 1; + gSaveContext.weekEventReg[0x49] |= 0x80; + ActorCutscene_Stop(this->cutscene); + this->unk_2AC = 1; + this->actor.textId = sTextIds[this->textIdIndex]; + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + this->actionFunc = func_80C04D8C; + } + } else { + Math_ApproachF(&this->actor.world.pos.x, this->unk_29C.x, 0.3f, 1.0f); + Math_ApproachF(&this->actor.world.pos.z, this->unk_29C.z, 0.3f, 1.0f); + } + } +} + +void EnBombers2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBombers2* this = (EnBombers2*)thisx; + f32 temp_f4; + Vec3f sp34; + s32 yawDiffAbs; + + SkelAnime_Update(&this->skelAnime); + if (this->unk_2B2 != 0) { + this->unk_2B2--; + } + if ((this->animIndex == 2) && + (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 10.0f) || + Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 18.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); + } + this->actor.shape.rot.y = this->actor.world.rot.y; + if (this->unk_2C0 != 2) { + + yawDiffAbs = ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.world.rot.y)); + this->unk_290 = 0; + if (yawDiffAbs < 0x3A98) { + this->unk_290 = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + if (this->unk_290 >= 0x2711) { + this->unk_290 = 0x2710; + } else if (this->unk_290 < -0x2710) { + this->unk_290 = -0x2710; + } + } + } + Actor_SetFocus(&this->actor, 20.0f); + Actor_SetScale(&this->actor, 0.008f); + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Math_SmoothStepToS(&this->unk_28A, this->unk_290, 1, 0xBB8, 0); + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0xBB8, 0); + if (this->unk_2BE == 0) { + this->eyeIndex += 1; + if (this->eyeIndex >= 3) { + this->eyeIndex = 0; + this->unk_2BE = (s16)Rand_ZeroFloat(60.0f) + 0x14; + } + } + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + if (this->unk_2AC == 0) { + this->actor.world.pos.x = (Math_SinS((this->actor.world.rot.y + 0x8000)) * 26.0f) + sp34.x; + temp_f4 = Math_CosS(this->actor.world.rot.y + 0x8000) * 26.0f; + this->actor.world.pos.z = temp_f4 + sp34.z; + this->collider.dim.radius = 0x23; + this->collider.dim.height = 0x1E; + } else { + this->collider.dim.radius = 0xA; + this->collider.dim.height = 0x19; + } + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->unk_2AC == 0) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + } + Math_Vec3f_Copy(&this->actor.world.pos, &sp34); +} + +s32 func_80C056D4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnBombers2* this = THIS; + + if (limbIndex == OBJECT_CS_LIMB_08) { + rot->x += this->unk_296; + } + if (limbIndex == OBJECT_CS_LIMB_11) { + rot->x += this->unk_28A; + rot->z += this->unk_288; + } + if ((limbIndex == OBJECT_CS_LIMB_0F) || (limbIndex == OBJECT_CS_LIMB_13) || (limbIndex == OBJECT_CS_LIMB_14)) { + *dList = NULL; + } + return false; +} + +void EnBombers2_Draw(Actor* thisx, GlobalContext* globalCtx) { + + EnBombers2* this = THIS; + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C05920)); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(sSetPrimColorDlPtr)); + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80C056D4, NULL, &this->actor); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h index 25c5fd773..ed10a84db 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h @@ -3,15 +3,42 @@ #include "global.h" +#include "objects/object_cs/object_cs.h" + struct EnBombers2; typedef void (*EnBombers2ActionFunc)(struct EnBombers2*, GlobalContext*); typedef struct EnBombers2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x140]; + /* 0x014C */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s morphTable[OBJECT_CS_LIMB_MAX]; + /* 0x0206 */ Vec3s jointTable[OBJECT_CS_LIMB_MAX]; /* 0x0284 */ EnBombers2ActionFunc actionFunc; - /* 0x0288 */ char unk_288[0x94]; + /* 0x0288 */ s16 unk_288; + /* 0x028A */ s16 unk_28A; + /* 0x028C */ UNK_TYPE1 pad_28C[2]; + /* 0x028E */ s16 unk_28E; + /* 0x0290 */ s16 unk_290; + /* 0x0292 */ UNK_TYPE1 pad_292[4]; + /* 0x0296 */ s16 unk_296; + /* 0x0298 */ UNK_TYPE1 pad_298[4]; + /* 0x029C */ Vec3f unk_29C; + /* 0x02A8 */ s32 unk_2A8; + /* 0x02AC */ u8 unk_2AC; + /* 0x02AE */ s16 animIndex; + /* 0x02B0 */ s16 cutscene; + /* 0x02B2 */ s16 unk_2B2; + /* 0x02B4 */ s16 unk_2B4; + /* 0x02B6 */ s16 unk_2B6; + /* 0x02B8 */ f32 lastAnimFrame; + /* 0x02BC */ s16 eyeIndex; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C2 */ s16 textIdIndex; + /* 0x02C4 */ s16 correctDigitSlots[5]; + /* 0x02CE */ s16 unk_2CE; + /* 0x02D0 */ ColliderCylinder collider; } EnBombers2; // size = 0x31C extern const ActorInit En_Bombers2_InitVars; diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c index b803b454c..8d9c7b848 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -89,7 +89,7 @@ u16 D_80C00A70[] = { u16 D_80C00A8C[] = { 0x736, 0x737, 0x738, 0x74E }; static AnimationHeader* sAnimations[] = { - &object_cs_Anim_0064B8, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, + &gBomberIdleAnim, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_001A1C, &object_cs_Anim_003EE4, &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, &object_cs_Anim_001708, @@ -114,8 +114,8 @@ void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); this->actor.gravity = -3.0f; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &object_cs_Anim_0064B8, this->jointTable, - this->morphTable, 21); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, + this->morphTable, OBJECT_CS_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); gSaveContext.weekEventReg[83] &= (u8)~4; this->actor.targetMode = 0; diff --git a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c index 2989bbd02..d4d60f2fe 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -78,8 +78,8 @@ void EnBomjimb_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); this->actor.gravity = -2.0f; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &object_cs_Anim_0064B8, this->jointTable, - this->morphTable, 21); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, + this->morphTable, OBJECT_CS_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actor.targetMode = 6; Actor_SetScale(&this->actor, 0.01f); @@ -160,7 +160,7 @@ void EnBomjimb_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80C0113C(EnBomjimb* this, s32 arg1, f32 arg2) { static AnimationHeader* sAnimations[] = { - &object_cs_Anim_0064B8, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, + &gBomberIdleAnim, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_002930, &object_cs_Anim_001A1C, &object_cs_Anim_003EE4, &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index d3a00f445..e7afe1452 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16534,7 +16534,7 @@ 0x80C04614:("EnBombers_Draw",), 0x80C04930:("EnBombers2_Init",), 0x80C04A80:("EnBombers2_Destroy",), - 0x80C04AAC:("func_80C04AAC",), + 0x80C04AAC:("EnBombers2_ChangeAnim",), 0x80C04B40:("func_80C04B40",), 0x80C04BA0:("func_80C04BA0",), 0x80C04D00:("func_80C04D00",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index f685ee576..cf0c734af 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -16144,9 +16144,9 @@ 0x80BE6150:("En_Tanron6_InitVars","UNK_TYPE1","",0x1), 0x80BE6170:("D_80BE6170","UNK_TYPE1","",0x1), 0x80BE78D0:("En_Daiku2_InitVars","UNK_TYPE1","",0x1), - 0x80BE78F0:("sTextIds","UNK_TYPE1","",0x1), + 0x80BE78F0:("sTextIds","s16","",0x1), 0x80BE7900:("D_80BE7900","UNK_TYPE1","",0x1), - 0x80BE792C:("sAnimations","UNK_TYPE1","",0x1), + 0x80BE792C:("sAnimations","AnimationHeader*","",0x1), 0x80BE7958:("D_80BE7958","UNK_TYPE1","",0x1), 0x80BE7970:("D_80BE7970","f32","",0x4), 0x80BE7974:("D_80BE7974","f32","",0x4), @@ -16413,13 +16413,13 @@ 0x80C0482C:("D_80C0482C","UNK_TYPE1","",0x1), 0x80C04838:("D_80C04838","UNK_TYPE1","",0x1), 0x80C05880:("En_Bombers2_InitVars","UNK_TYPE1","",0x1), - 0x80C058A0:("D_80C058A0","UNK_TYPE1","",0x1), - 0x80C058B0:("D_80C058B0","UNK_TYPE1","",0x1), - 0x80C058DC:("D_80C058DC","UNK_TYPE1","",0x1), - 0x80C058F8:("D_80C058F8","UNK_TYPE1","",0x1), - 0x80C05900:("D_80C05900","UNK_TYPE1","",0x1), - 0x80C05910:("D_80C05910","UNK_PTR","",0x4), - 0x80C05914:("D_80C05914","UNK_TYPE1","",0x1), + 0x80C058A0:("sTextIds","u16","",0x1), + 0x80C058B0:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80C058DC:("sAnimations","AnimationHeader*","",0x1), + 0x80C058F8:("sAnimModes","u8","",0x1), + 0x80C05900:("sSetPrimColorDL","UNK_TYPE1","",0x1), + 0x80C05910:("sSetPrimColorDlPtr","Gfx*","",0x4), + 0x80C05914:("sEyeTextures","void*","",0x1), 0x80C05920:("D_80C05920","UNK_TYPE4","",0x4), 0x80C05930:("jtbl_80C05930","UNK_PTR","",0x4), 0x80C06440:("En_Bombal_InitVars","UNK_TYPE1","",0x1), From 02cb97161609e1c9aa53e2bbdc29e8b6f4f46c47 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Mon, 28 Mar 2022 01:52:43 +1100 Subject: [PATCH 138/257] En_Gakufu OK and Documented + Related Audio Functions (#662) * Gakufu OK, copy progress from audio WIP * Extraction * import wip in prep for audio data import * Add in `code_8019AF00.c` functions * Finish docs * Spacing * Add enum * Many PR suggestions * Another enum * PR Suggestions * Fix bss * Move comment higher * Fix bss Co-authored-by: angie --- assets/xml/overlays/ovl_En_Gakufu.xml | 8 + include/functions.h | 18 +- include/variables.h | 2 +- include/z64ocarina.h | 12 +- spec | 3 +- src/code/audio/code_80192BE0.c | 2 +- src/code/audio/code_8019AF00.c | 182 ++++++++++-- .../actors/ovl_En_Gakufu/z_en_gakufu.c | 270 ++++++++++++++++-- .../actors/ovl_En_Gakufu/z_en_gakufu.h | 14 +- src/overlays/actors/ovl_En_Zot/z_en_zot.c | 6 +- tools/disasm/functions.txt | 30 +- tools/disasm/variables.txt | 24 +- tools/sizes/code_functions.csv | 18 +- 13 files changed, 488 insertions(+), 101 deletions(-) create mode 100644 assets/xml/overlays/ovl_En_Gakufu.xml diff --git a/assets/xml/overlays/ovl_En_Gakufu.xml b/assets/xml/overlays/ovl_En_Gakufu.xml new file mode 100644 index 000000000..92b2672d4 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Gakufu.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/include/functions.h b/include/functions.h index 87846d8d9..a956de5ee 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3383,7 +3383,7 @@ void Audio_QueueCmdS8(u32 opArgs, s8 data); // void func_80194528(void); // void func_80194548(void); // void func_80194568(void); -// void func_80194668(void); +u32 Audio_NextRandom(void); void Audio_InitMesgQueues(void); void Audio_InvalDCache(void* buf, size_t size); void Audio_WritebackDCache(void* buf, size_t size); @@ -3455,13 +3455,13 @@ void func_8019AEC0(UNK_PTR param_1, UNK_PTR param_2); // void func_8019AF58(void); // void func_8019AFE8(void); // void func_8019B02C(void); -// void func_8019B074(void); +// void AudioOcarina_MapSongFromNotesToButtons(void); // void func_8019B144(void); // void func_8019B378(void); // void func_8019B38C(void); // void func_8019B3D0(void); // void func_8019B4B8(void); -void func_8019B544(u16 arg0); +void AudioOcarina_StartDefault(u32 arg0); // void func_8019B568(void); // void func_8019B5AC(void); // void func_8019B5EC(void); @@ -3473,7 +3473,7 @@ void func_8019B544(u16 arg0); // void func_8019C1D0(void); // void func_8019C268(void); // void func_8019C2E4(void); -void func_8019C300(s32 arg0); +u32 AudioOcarina_SetInstrumentId(u8 arg0); // void func_8019C398(void); // void func_8019C5A0(void); // void func_8019C8D8(void); @@ -3483,12 +3483,12 @@ void func_8019C300(s32 arg0); // void func_8019CEBC(void); // void func_8019CF6C(void); // void func_8019CF78(void); -// void func_8019CF9C(void); +OcarinaStaff* AudioOcarina_GetPlaybackStaff(void); // void func_8019CFA8(void); -// void func_8019D134(void); -// void func_8019D26C(void); -// void func_8019D488(void); -// void func_8019D4F8(void); +// void AudioOcarina_TerminaWallValidateNotes(void); +void AudioOcarina_TerminaWallGenerateNotes(void); +// void AudioOcarina_MemoryGameSetNumNotes(void); +// void AudioOcarina_MemoryGameGenerateNotes(void); // void func_8019D600(void); void func_8019D758(void); // void func_8019D864(void); diff --git a/include/variables.h b/include/variables.h index 1fccfc97b..7d3070f58 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1774,7 +1774,7 @@ extern UNK_PTR D_801D88A0; extern UNK_PTR D_801D88A4; // extern UNK_TYPE1 D_801D88A8; // extern UNK_TYPE1 D_801D88B8; -// extern UNK_TYPE1 D_801D8A48; +extern OcarinaSongButtons gOcarinaSongButtons[24]; // extern UNK_TYPE1 D_801D8B20; extern UNK_PTR D_801D8B24; // extern UNK_TYPE2 D_801D8B28; diff --git a/include/z64ocarina.h b/include/z64ocarina.h index cc1662fbd..ed634f520 100644 --- a/include/z64ocarina.h +++ b/include/z64ocarina.h @@ -39,7 +39,7 @@ typedef enum { /* 3 */ OCARINA_BTN_C_LEFT, /* 4 */ OCARINA_BTN_C_UP, /* -1 */ OCARINA_BTN_INVALID = 0xFF -} OcarinaButtonIdx; +} OcarinaButtonIndex; // Uses scientific pitch notation relative to middle C // https://en.wikipedia.org/wiki/Scientific_pitch_notation @@ -93,7 +93,7 @@ typedef enum { /** * BFlat4Flag Note: - * Flag for resolving whether (noteIdx = NOTE_BFLAT4) + * Flag for resolving whether (pitch = OCARINA_PITCH_BFLAT4) * gets mapped to either C_RIGHT and C_LEFT * * This is required as C_RIGHT and C_LEFT are the only notes @@ -103,21 +103,21 @@ typedef enum { */ typedef struct { - /* 0x0 */ u8 noteIdx; // number of semitones above middle C + /* 0x0 */ u8 pitch; // number of semitones above middle C /* 0x2 */ u16 length; // number of frames the note is sustained /* 0x4 */ u8 volume; /* 0x5 */ u8 vibrato; - /* 0x6 */ s8 bend; // frequency multiplicative offset from the pitch defined by noteIdx + /* 0x6 */ s8 bend; // frequency multiplicative offset from the pitch defined by pitch /* 0x7 */ u8 BFlat4Flag; // See note above } OcarinaNote; // size = 0x8 typedef struct { /* 0x0 */ u8 numButtons; - /* 0x1 */ u8 buttonIdx[8]; + /* 0x1 */ u8 buttonIndex[8]; } OcarinaSongButtons; // size = 0x9 typedef struct { - /* 0x0 */ u8 buttonIdx; + /* 0x0 */ u8 buttonIndex; /* 0x1 */ u8 state; // original name: "status" /* 0x2 */ u8 pos; // original name: "locate" } OcarinaStaff; // size = 0x3 diff --git a/spec b/spec index 8ec008154..7aa66bcfb 100644 --- a/spec +++ b/spec @@ -3745,8 +3745,7 @@ beginseg name "ovl_En_Gakufu" compress include "build/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.o" - include "build/data/ovl_En_Gakufu/ovl_En_Gakufu.data.o" - include "build/data/ovl_En_Gakufu/ovl_En_Gakufu.reloc.o" + include "build/src/overlays/actors/ovl_En_Gakufu/ovl_En_Gakufu_reloc.o" endseg beginseg diff --git a/src/code/audio/code_80192BE0.c b/src/code/audio/code_80192BE0.c index d088db607..20b4239da 100644 --- a/src/code/audio/code_80192BE0.c +++ b/src/code/audio/code_80192BE0.c @@ -76,6 +76,6 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194568.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194668.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/Audio_NextRandom.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/Audio_InitMesgQueues.s") diff --git a/src/code/audio/code_8019AF00.c b/src/code/audio/code_8019AF00.c index 0006122c2..2e7cc91e1 100644 --- a/src/code/audio/code_8019AF00.c +++ b/src/code/audio/code_8019AF00.c @@ -45,7 +45,7 @@ typedef enum { /* 0xD */ SFX_CHANNEL_OCARINA, // SfxOcarinaBank /* 0xE */ SFX_CHANNEL_VOICE0, // SfxVoiceBank /* 0xF */ SFX_CHANNEL_VOICE1 -} SfxChannelIdx; // playerIdx = 2 +} SfxChannelIndex; // playerIndex = 2 // Global IO ports for sequences, 8 global ports per seqPlayer typedef enum { @@ -66,6 +66,7 @@ typedef struct { /* 0xC */ s32 remainingFrames; } FreqLerp; // size = 0x10 +s32 AudioOcarina_MemoryGameGenerateNotes(void); s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume); void func_801A3238(s8 playerIndex, u16 seqId, u8 fadeTimer, s8 arg3, u8 arg4); @@ -107,7 +108,7 @@ u8 sIsFinalHoursOrSoaring; u8 sObjSoundFanfareSeqId; u8 sObjSoundFanfareRequested; Vec3f sObjSoundFanfarePos; -u8 sObjSoundPlayerIdx; +u8 sObjSoundPlayerIndex; Vec3f sObjSoundPos; s16 sObjSoundFlags; f32 sObjSoundMinDist; @@ -122,7 +123,7 @@ u8 sSpatialSeqFlags; u8 D_801FD432; u8 sSpatialSubBgmFadeTimer; u8 D_801FD434; -u8 sSpatialSeqPlayerIdx; +u8 sSpatialSeqPlayerIndex; u8 sSpatialSeqFadeTimer; u16 D_801FD438; @@ -139,8 +140,8 @@ s32 sOcaInputBtnPress; u8 sOcarinaResetDelay; u8 sOcarinaResetUnused; u8 sOcarinaHasStartedSong; -u8 sFirstOcarinaSongIdx; -u8 sLastOcarinaSongIdx; +u8 sFirstOcarinaSongIndex; +u8 sLastOcarinaSongIndex; u32 sOcarinaAvailSongs; u8 sOcarinaStaffPlayingPos; u16 sMusicStaffPos[OCARINA_SONG_MAX]; @@ -987,11 +988,11 @@ u8 sIsOcarinaInputEnabled = false; s8 sOcarinaInstrumentId = OCARINA_INSTRUMENT_OFF; u8 sCurOcarinaPitch = OCARINA_PITCH_NONE; u8 sPrevOcarinaPitch = 0; -u8 sCurOcarinaButtonIdx = 0; +u8 sCurOcarinaButtonIndex = 0; u8 sMusicStaffPrevPitch = 0; f32 sCurOcarinaBendFreq = 1.0f; f32 sDefaultOcarinaVolume = 0.68503935f; -s8 sCurOcarinaBendIdx = 0; +s8 sCurOcarinaBendIndex = 0; s8 sCurOcarinaVolume = 0x57; s8 sCurOcarinaVibrato = 0; u8 sPlaybackState = 0; @@ -1017,7 +1018,7 @@ u8 sCurOcarinaSong[8] = { u8 sOcarinaSongAppendPos = 0; u8 sOcarinaSongStartingPos = 0; -u8 sButtonToNoteMap[5] = { +u8 sButtonToPitchMap[5] = { OCARINA_PITCH_D4, // OCARINA_BTN_A OCARINA_PITCH_F4, // OCARINA_BTN_C_DOWN OCARINA_PITCH_A4, // OCARINA_BTN_C_RIGHT @@ -1025,7 +1026,7 @@ u8 sButtonToNoteMap[5] = { OCARINA_PITCH_D5, // OCARINA_BTN_C_UP }; -u8 sOcaMemoryGameAppendPos = 0; +u8 sOcarinaMemoryGameAppendPos = 0; u8 sOcaMemoryGameEndPos = 0; u8 sOcaMemoryGameNumNotes[] = { 5, 6, 8 }; OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { @@ -1446,9 +1447,9 @@ u32 sOcarinaRecordTaskStart = 0; u8 sRecordOcarinaPitch = 0; u8 sRecordOcarinaVolume = 0; u8 sRecordOcarinaVibrato = 0; -s8 sRecordOcarinaBendIdx = 0; -u8 sRecordOcarinaButtonIdx = 0; -u8 sPlayedOcarinaSongIdxPlusOne = 0; +s8 sRecordOcarinaBendIndex = 0; +u8 sRecordOcarinaButtonIndex = 0; +u8 sPlayedOcarinaSongIndexPlusOne = 0; u8 sMusicStaffNumNotesPerTest = 0; u8 D_801D8530 = false; u32 D_801D8534 = 0; @@ -1463,7 +1464,7 @@ OcarinaNote* gScarecrowLongSongPtr = sScarecrowsLongSongNotes; u8* gScarecrowSpawnSongPtr = (u8*)&sOcarinaSongNotes[OCARINA_SONG_SCARECROW]; OcarinaNote* sTerminaWallSongPtr = sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL]; -u8 sNoteToButtonMap[16] = { +u8 sPitchToButtonMap[16] = { OCARINA_BTN_A, // OCARINA_PITCH_C4 OCARINA_BTN_A, // OCARINA_PITCH_DFLAT4 OCARINA_BTN_A, // OCARINA_PITCH_D4 @@ -1852,6 +1853,7 @@ const u16 gAudioEnvironmentalSfx[] = { NA_SE_EV_WAVE_S - SFX_FLAG, NA_SE_EV_WAVE_S - SFX_FLAG, }; +extern const u8 sIsOcarinaSongReserved[OCARINA_SONG_MAX]; /** const u8 sIsOcarinaSongReserved[OCARINA_SONG_MAX] = { true, // OCARINA_SONG_SONATA @@ -1889,7 +1891,8 @@ const u8 sIsOcarinaSongReserved[OCARINA_SONG_MAX] = { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B02C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B074.s") +void AudioOcarina_MapSongFromNotesToButtons(u8 noteSongIndex, u8 buttonSongIndex, u8 numButtons); +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_MapSongFromNotesToButtons.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B144.s") @@ -1901,7 +1904,7 @@ const u8 sIsOcarinaSongReserved[OCARINA_SONG_MAX] = { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B4B8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B544.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_StartDefault.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B568.s") @@ -1927,7 +1930,7 @@ const u8 sIsOcarinaSongReserved[OCARINA_SONG_MAX] = { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C2E4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C300.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_SetInstrumentId.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C398.s") @@ -1956,17 +1959,154 @@ const char sAudioOcarinaUnusedText7[] = "check is over!!! %d %d %d\n"; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CF78.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CF9C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_GetPlaybackStaff.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CFA8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D134.s") +/** + * Tests to see if the notes from songIndex contain identical notes + * within its song to any of the reserved songIndex from 0 up to maxSongIndex + */ +s32 AudioOcarina_TerminaWallValidateNotes(u8 songIndex, u8 maxSongIndex) { + u8 curSongIndex; + u8 j; + u8 k; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D26C.s") + // loop through all possible songs up to maxSongIndex + for (curSongIndex = 0; curSongIndex < maxSongIndex; curSongIndex++) { + // check to see if the song is reserved or not + if (sIsOcarinaSongReserved[curSongIndex]) { + // starting index to test the song + for (j = 0; j < (9 - gOcarinaSongButtons[curSongIndex].numButtons); j++) { + // loop through each note in the song + for (k = 0; (k < gOcarinaSongButtons[curSongIndex].numButtons) && ((k + j) < 8) && + (gOcarinaSongButtons[curSongIndex].buttonIndex[k] == + gOcarinaSongButtons[songIndex].buttonIndex[(k + j)]); + k++) { + continue; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D488.s") + if (k == gOcarinaSongButtons[curSongIndex].numButtons) { + // failure: songIndex is identical to curSongIndex. + return -1; + } + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D4F8.s") + // success: notes are accepted and used + return 0; +} + +/** + * Generates the notes displayed on the Termina Field wall of musical notes + * Song generation loop alternates between 8 random notes and a random song from Ocarina of Time (OoT). + * Will check to see that the notes are valid by ensuring no playable song is within the selected notes + * All OoT songs are valid, so the outer loop will run a maxiumum of two times. + * i.e. if random notes fails, then the next set of notes will be from a valid OoT song + */ +void AudioOcarina_TerminaWallGenerateNotes(void) { + OcarinaNote* ocarinaNote; + u8 randButtonIndex; + u8 i; + u8 j; + + do { + i = 0; + if (sOcarinaWallCounter++ % 2) { + j = 0; + + for (; i < 8; i++) { + randButtonIndex = Audio_NextRandom() % ARRAY_COUNT(sButtonToPitchMap); + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].pitch = sButtonToPitchMap[randButtonIndex]; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].length = 19; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].volume = 80; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].vibrato = 0; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].bend = 0; + j++; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].length = 3; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].volume = 0; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].vibrato = 0; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].bend = 0; + j++; + } + + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j - 2].length = 90; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j - 1].length = 22; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j + 1].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j + 1].length = 0; + AudioOcarina_MapSongFromNotesToButtons(OCARINA_SONG_TERMINA_WALL, OCARINA_SONG_TERMINA_WALL, 8); + } else { + j = Audio_NextRandom() % ARRAY_COUNT(sOoTOcarinaSongNotes); + ocarinaNote = sOoTOcarinaSongNotes[j]; + + for (; ocarinaNote[i].length != 0; i++) { + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][i] = ocarinaNote[i]; + } + + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][i].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][i].length = 0; + AudioOcarina_MapSongFromNotesToButtons(OCARINA_SONG_TERMINA_WALL, OCARINA_SONG_TERMINA_WALL, + sOoTOcarinaSongsNumNotes[j]); + } + } while (AudioOcarina_TerminaWallValidateNotes(OCARINA_SONG_TERMINA_WALL, OCARINA_SONG_TERMINA_WALL) != 0); +} + +/** + * Unused remnant of OoT + */ +void AudioOcarina_MemoryGameSetNumNotes(u8 minigameRound) { + u8 i; + + if (minigameRound > 2) { + minigameRound = 2; + } + + sOcarinaMemoryGameAppendPos = 0; + sOcaMemoryGameEndPos = sOcaMemoryGameNumNotes[minigameRound]; + + for (i = 0; i < 3; i++) { + AudioOcarina_MemoryGameGenerateNotes(); + } +} + +/** + * Unused remnant of OoT, Id 14 now represent Goron Lullaby Intro instead of the OoT ocarina memory game + * //! @bug calling this function in MM will overwrite Goron Lullaby Intro + */ +#define OCARINA_SONG_MEMORYGAME 14 +s32 AudioOcarina_MemoryGameGenerateNotes(void) { + u32 randButtonIndex; + u8 randPitch; + + if (sOcarinaMemoryGameAppendPos == sOcaMemoryGameEndPos) { + return true; + } + + randButtonIndex = Audio_NextRandom(); + randPitch = sButtonToPitchMap[randButtonIndex % ARRAY_COUNT(sButtonToPitchMap)]; + + if (sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos - 1].pitch == randPitch) { + randPitch = sButtonToPitchMap[(randButtonIndex + 1) % ARRAY_COUNT(sButtonToPitchMap)]; + } + + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].pitch = randPitch; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].length = 45; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].volume = 0x50; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].vibrato = 0; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].bend = 0; + + sOcarinaMemoryGameAppendPos++; + + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].length = 0; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos + 1].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos + 1].length = 0; + if (1) {} + return false; +} +#undef OCARINA_SONG_MEMORYGAME #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D600.s") diff --git a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c index 024c857ea..6923c6679 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c @@ -5,6 +5,7 @@ */ #include "z_en_gakufu.h" +#include "interface/parameter_static/parameter_static.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) @@ -15,13 +16,15 @@ void EnGakufu_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGakufu_Update(Actor* thisx, GlobalContext* globalCtx); void EnGakufu_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80AFCB94(EnGakufu* this, GlobalContext* globalCtx); -void func_80AFCBD4(EnGakufu* this, GlobalContext* globalCtx); -void func_80AFCC14(EnGakufu* this, GlobalContext* globalCtx); -void func_80AFCD44(EnGakufu* this, GlobalContext* globalCtx); -void func_80AFCDC8(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_ProcessNotes(EnGakufu* this); +s32 EnGakufu_IsPlayerInRange(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_DisplayOnTimer(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_WaitForTimer(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_DoNothing(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_GiveReward(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_PlayRewardCutscene(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_WaitForSong(EnGakufu* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Gakufu_InitVars = { ACTOR_EN_GAKUFU, ACTORCAT_ITEMACTION, @@ -34,28 +37,257 @@ const ActorInit En_Gakufu_InitVars = { (ActorFunc)EnGakufu_Draw, }; -#endif +Vec3f sRewardDropsSpawnTerminaFieldPos = { + -710.0f, + -123.0f, + -3528.0f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFC960.s") +/** + * Determines which set of `sRewardDrops` to collect when successfully playing the notes on the wall. + * Rewards come in batches of three, and the reward you get depends on the time of day. + */ +u8 sRewardDropsIndex[] = { + 3, // CLOCK_TIME(0, 0) to CLOCKTIME(1, 0) + 12, // CLOCK_TIME(1, 0) to CLOCKTIME(2, 0) + 6, // CLOCK_TIME(2, 0) to CLOCKTIME(3, 0) + 12, // CLOCK_TIME(3, 0) to CLOCKTIME(4, 0) + 9, // CLOCK_TIME(4, 0) to CLOCKTIME(5, 0) + 12, // CLOCK_TIME(5, 0) to CLOCKTIME(6, 0) + 0, // CLOCK_TIME(6, 0) to CLOCKTIME(7, 0) + 12, // CLOCK_TIME(7, 0) to CLOCKTIME(8, 0) + 3, // CLOCK_TIME(8, 0) to CLOCKTIME(9, 0) + 12, // CLOCK_TIME(9, 0) to CLOCKTIME(10, 0) + 6, // CLOCK_TIME(10, 0) to CLOCKTIME(11, 0) + 12, // CLOCK_TIME(11, 0) to CLOCKTIME(12, 0) + 3, // CLOCK_TIME(12, 0) to CLOCKTIME(13, 0) + 12, // CLOCK_TIME(13, 0) to CLOCKTIME(14, 0) + 6, // CLOCK_TIME(14, 0) to CLOCKTIME(15, 0) + 12, // CLOCK_TIME(15, 0) to CLOCKTIME(16, 0) + 3, // CLOCK_TIME(16, 0) to CLOCKTIME(17, 0) + 12, // CLOCK_TIME(17, 0) to CLOCKTIME(18, 0) + 6, // CLOCK_TIME(18, 0) to CLOCKTIME(19, 0) + 12, // CLOCK_TIME(19, 0) to CLOCKTIME(20, 0) + 9, // CLOCK_TIME(20, 0) to CLOCKTIME(21, 0) + 12, // CLOCK_TIME(21, 0) to CLOCKTIME(22, 0) + 6, // CLOCK_TIME(22, 0) to CLOCKTIME(23, 0) + 12, // CLOCK_TIME(23, 0) to CLOCKTIME(0, 0) +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/EnGakufu_Init.s") +/** + * The set of rewards when the song notes on the wall are played. + * Should be thought of as a 2D array: sRewardDrops[5][3] + * i.e. there are 5 sets of possible rewards. And each set gives out three rewards + */ +u8 sRewardDrops[] = { + ITEM00_RUPEE_RED, ITEM00_RUPEE_RED, ITEM00_RUPEE_RED, // Set 1 (index 0) + ITEM00_RUPEE_RED, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, // Set 2 (index 3) + ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, // Set 3 (index 6) + ITEM00_RUPEE_RED, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, // Set 4 (index 9) + ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, // Set 5 (index 12) +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/EnGakufu_Destroy.s") +// y-offsets of ocarina buttons drawn on wall +f32 sOcarinaBtnWallYOffsets[] = { + -4.0f, -2.0f, 0.0f, 1.0f, 3.0f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCB94.s") +TexturePtr sOcarinaBtnWallTextures[] = { + gOcarinaATex, gOcarinaCDownTex, gOcarinaCRightTex, gOcarinaCLeftTex, gOcarinaCUpTex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCBD4.s") +#include "overlays/ovl_En_Gakufu/ovl_En_Gakufu.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCC14.s") +void EnGakufu_ProcessNotes(EnGakufu* this) { + OcarinaStaff* playbackStaff; + OcarinaSongButtons* ocarinaSongButtons; + s32 songNumButtons; + s32 i; + s32 songIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCC24.s") + AudioOcarina_TerminaWallGenerateNotes(); + AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_DEFAULT); + AudioOcarina_StartDefault((1 << this->songIndex) | 0x80000000); + playbackStaff = AudioOcarina_GetPlaybackStaff(); + playbackStaff->pos = 0; + playbackStaff->state = 0xFF; + AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_OFF); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCC58.s") + songIndex = this->songIndex; + ocarinaSongButtons = &gOcarinaSongButtons[songIndex]; + songNumButtons = gOcarinaSongButtons[this->songIndex].numButtons; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCD44.s") + for (i = 0; i < songNumButtons; i++) { + this->buttonIndex[i] = ocarinaSongButtons->buttonIndex[i]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCDC8.s") + for (; i < ARRAY_COUNT(this->buttonIndex); i++) { + this->buttonIndex[i] = OCARINA_BTN_INVALID; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/EnGakufu_Update.s") +void EnGakufu_Init(Actor* thisx, GlobalContext* globalCtx) { + EnGakufu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/EnGakufu_Draw.s") + this->songIndex = OCARINA_SONG_TERMINA_WALL; + EnGakufu_ProcessNotes(this); + Actor_SetScale(&this->actor, 1.0f); + + if (GAKUFU_GET_TYPE(&this->actor) == GAKUFU_MILK_BAR) { + this->actor.draw = NULL; + this->actionFunc = EnGakufu_WaitForTimer; + return; + } + + this->actor.flags &= ~ACTOR_FLAG_2000000; + + if (EnGakufu_IsPlayerInRange(this, globalCtx)) { + gSaveContext.eventInf[3] |= 2; + } else { + gSaveContext.eventInf[3] &= (u8)~2; + } + + this->actionFunc = EnGakufu_WaitForSong; + gSaveContext.eventInf[3] &= (u8)~4; +} + +void EnGakufu_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGakufu* this = THIS; + + if (GAKUFU_GET_TYPE(&this->actor) != GAKUFU_MILK_BAR) { + gSaveContext.eventInf[3] &= (u8)~2; + } +} + +/** + * Special behaviour for the Milk Bar: + * this->actor.home.rot.x acts as a timer. Draws the notes on the back of the stage + * until the timer runs out + */ +void EnGakufu_DisplayOnTimer(EnGakufu* this, GlobalContext* globalCtx) { + if (this->actor.home.rot.x > 0) { + this->actor.draw = EnGakufu_Draw; + this->actor.home.rot.x--; + } else { + this->actor.draw = NULL; + this->actor.home.rot.x = 0; + this->actionFunc = EnGakufu_WaitForTimer; + } +} + +/** + * Special behaviour for the Milk Bar: + * this->actor.home.rot.x acts as a timer. Waits for this timer to be set, + * then rerolls the notes and start displaying the notes + */ +void EnGakufu_WaitForTimer(EnGakufu* this, GlobalContext* globalCtx) { + if (this->actor.home.rot.x > 0) { + EnGakufu_ProcessNotes(this); + this->actionFunc = EnGakufu_DisplayOnTimer; + } +} + +void EnGakufu_DoNothing(EnGakufu* this, GlobalContext* globalCtx) { +} + +s32 EnGakufu_IsPlayerInRange(EnGakufu* this, GlobalContext* globalCtx) { + if (this->actor.xzDistToPlayer < 600.0f) { + return true; + } else { + return false; + } +} + +/** + * Reward the player with three item drops depending on the time of day + */ +void EnGakufu_GiveReward(EnGakufu* this, GlobalContext* globalCtx) { + s32 hour; + s32 i; + + play_sound(NA_SE_SY_CORRECT_CHIME); + + hour = gSaveContext.time * (24.0f / 0x10000); + for (i = 0; i < 3; i++) { + Item_DropCollectible(globalCtx, &sRewardDropsSpawnTerminaFieldPos, sRewardDrops[i + sRewardDropsIndex[hour]]); + } + + this->actionFunc = EnGakufu_DoNothing; +} + +void EnGakufu_PlayRewardCutscene(EnGakufu* this, GlobalContext* globalCtx) { + if (this->actor.cutscene == -1) { + EnGakufu_GiveReward(this, globalCtx); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + EnGakufu_GiveReward(this, globalCtx); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +/** + * Waits for the notes on the wall to be played and updates the corresponding flags + * (gSaveContext.eventInf[3] & 2) is checking if Player is within range of the wall + * (gSaveContext.eventInf[3] & 4) is checking if Player has played the notes of the wall + */ +void EnGakufu_WaitForSong(EnGakufu* this, GlobalContext* globalCtx) { + if (gSaveContext.eventInf[3] & 2) { + if (gSaveContext.eventInf[3] & 4) { + gSaveContext.eventInf[3] &= (u8)~2; + gSaveContext.eventInf[3] &= (u8)~4; + + this->actionFunc = EnGakufu_PlayRewardCutscene; + EnGakufu_PlayRewardCutscene(this, globalCtx); + this->actor.draw = NULL; + } else if (!EnGakufu_IsPlayerInRange(this, globalCtx)) { + gSaveContext.eventInf[3] &= (u8)~2; + } + } else if (EnGakufu_IsPlayerInRange(this, globalCtx)) { + gSaveContext.eventInf[3] |= 2; + } +} + +void EnGakufu_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGakufu* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void EnGakufu_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 i; + s32 pad; + EnGakufu* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gDPPipeSync(POLY_XLU_DISP++); + gSPSegment(POLY_XLU_DISP++, 0x02, globalCtx->interfaceCtx.parameterSegment); + + for (i = 0; (i < ARRAY_COUNT(this->buttonIndex)) && (this->buttonIndex[i] != OCARINA_BTN_INVALID); i++) { + Matrix_StatePush(); + Matrix_InsertTranslation(30 * i - 105, sOcarinaBtnWallYOffsets[this->buttonIndex[i]] * 7.5f, 1.0f, + MTXMODE_APPLY); + Matrix_Scale(0.6f, 0.6f, 0.6f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetTextureLUT(POLY_XLU_DISP++, G_TT_NONE); + gDPLoadTextureBlock(POLY_XLU_DISP++, sOcarinaBtnWallTextures[this->buttonIndex[i]], G_IM_FMT_IA, G_IM_SIZ_8b, + 16, 16, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 4, 4, G_TX_NOLOD, + G_TX_NOLOD); + + if (this->buttonIndex[i] == OCARINA_BTN_A) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 80, 150, 255, 200); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 50, 200); + } + + gSPDisplayList(POLY_XLU_DISP++, gGakufuButtonIndexDL); + + Matrix_StatePop(); + } + + gSPSegment(POLY_XLU_DISP++, 0x02, globalCtx->sceneSegment); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h index b4bf8643c..9ba96a724 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h @@ -7,10 +7,18 @@ struct EnGakufu; typedef void (*EnGakufuActionFunc)(struct EnGakufu*, GlobalContext*); +#define GAKUFU_GET_TYPE(thisx) ((thisx)->params & 0xF) + +typedef enum { + /* 0x00 */ GAKUFU_TERMINA_FIELD, + /* 0x01 */ GAKUFU_MILK_BAR +} GakufuType; + typedef struct EnGakufu { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC]; - /* 0x0150 */ EnGakufuActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s32 songIndex; + /* 0x148 */ u8 buttonIndex[8]; + /* 0x150 */ EnGakufuActionFunc actionFunc; } EnGakufu; // size = 0x154 extern const ActorInit En_Gakufu_InitVars; diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index 08a49d891..88c236e98 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -1104,14 +1104,14 @@ void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { func_801477B4(globalCtx); this->actionFunc = func_80B98CA8; gSaveContext.weekEventReg[41] &= (u8)~0x20; - func_8019C300(0); + AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_OFF); break; case 0x12BA: func_801477B4(globalCtx); this->actionFunc = func_80B98CA8; gSaveContext.weekEventReg[41] |= 0x20; - func_8019C300(0); + AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_OFF); break; default: @@ -1140,7 +1140,7 @@ void func_80B98BF4(EnZot* this, GlobalContext* globalCtx) { void func_80B98CA8(EnZot* this, GlobalContext* globalCtx) { if (func_800B8718(&this->actor, &globalCtx->state)) { globalCtx->msgCtx.ocarinaMode = 4; - func_8019B544(0xFFFF); + AudioOcarina_StartDefault(0xFFFF); this->actionFunc = func_80B98BF4; this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 120.0f); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e7afe1452..0373f06e2 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3718,7 +3718,7 @@ 0x80194528:("func_80194528",), 0x80194548:("func_80194548",), 0x80194568:("func_80194568",), - 0x80194668:("func_80194668",), + 0x80194668:("Audio_NextRandom",), 0x801946E4:("Audio_InitMesgQueues",), 0x80194710:("Audio_InvalDCache",), 0x80194750:("Audio_WritebackDCache",), @@ -3809,13 +3809,13 @@ 0x8019AF58:("func_8019AF58",), 0x8019AFE8:("func_8019AFE8",), 0x8019B02C:("func_8019B02C",), - 0x8019B074:("func_8019B074",), + 0x8019B074:("AudioOcarina_MapSongFromNotesToButtons",), 0x8019B144:("func_8019B144",), 0x8019B378:("func_8019B378",), 0x8019B38C:("func_8019B38C",), 0x8019B3D0:("func_8019B3D0",), 0x8019B4B8:("func_8019B4B8",), - 0x8019B544:("func_8019B544",), + 0x8019B544:("AudioOcarina_StartDefault",), 0x8019B568:("func_8019B568",), 0x8019B5AC:("func_8019B5AC",), 0x8019B5EC:("func_8019B5EC",), @@ -3828,7 +3828,7 @@ 0x8019C1D0:("func_8019C1D0",), 0x8019C268:("func_8019C268",), 0x8019C2E4:("func_8019C2E4",), - 0x8019C300:("func_8019C300",), + 0x8019C300:("AudioOcarina_SetInstrumentId",), 0x8019C398:("func_8019C398",), 0x8019C5A0:("func_8019C5A0",), 0x8019C8D8:("func_8019C8D8",), @@ -3838,12 +3838,12 @@ 0x8019CEBC:("func_8019CEBC",), 0x8019CF6C:("func_8019CF6C",), 0x8019CF78:("func_8019CF78",), - 0x8019CF9C:("func_8019CF9C",), + 0x8019CF9C:("AudioOcarina_GetPlaybackStaff",), 0x8019CFA8:("func_8019CFA8",), - 0x8019D134:("func_8019D134",), - 0x8019D26C:("func_8019D26C",), - 0x8019D488:("func_8019D488",), - 0x8019D4F8:("func_8019D4F8",), + 0x8019D134:("AudioOcarina_TerminaWallValidateNotes",), + 0x8019D26C:("AudioOcarina_TerminaWallGenerateNotes",), + 0x8019D488:("AudioOcarina_MemoryGameSetNumNotes",), + 0x8019D4F8:("AudioOcarina_MemoryGameGenerateNotes",), 0x8019D600:("func_8019D600",), 0x8019D758:("func_8019D758",), 0x8019D864:("func_8019D864",), @@ -12776,14 +12776,14 @@ 0x80AFAA44:("EnPm_PostLimbDraw",), 0x80AFABAC:("EnPm_TransformLimbDraw",), 0x80AFACAC:("EnPm_Draw",), - 0x80AFC960:("func_80AFC960",), + 0x80AFC960:("EnGakufu_ProcessNotes",), 0x80AFCA94:("EnGakufu_Init",), 0x80AFCB64:("EnGakufu_Destroy",), - 0x80AFCB94:("func_80AFCB94",), - 0x80AFCBD4:("func_80AFCBD4",), - 0x80AFCC14:("func_80AFCC14",), - 0x80AFCC24:("func_80AFCC24",), - 0x80AFCC58:("func_80AFCC58",), + 0x80AFCB94:("EnGakufu_DisplayOnTimer",), + 0x80AFCBD4:("EnGakufu_WaitForTimer",), + 0x80AFCC14:("EnGakufu_DoNothing",), + 0x80AFCC24:("EnGakufu_IsPlayerInRange",), + 0x80AFCC58:("EnGakufu_GiveReward",), 0x80AFCD44:("func_80AFCD44",), 0x80AFCDC8:("func_80AFCDC8",), 0x80AFCE70:("EnGakufu_Update",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index cf0c734af..2b6e72ca9 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2351,11 +2351,11 @@ 0x801D6FB8:("sOcarinaInstrumentId","UNK_TYPE1","",0x1), 0x801D6FBC:("sCurOcarinaPitch","UNK_TYPE1","",0x1), 0x801D6FC0:("sPrevOcarinaPitch","UNK_TYPE1","",0x1), - 0x801D6FC4:("sCurOcarinaButtonIdx","UNK_TYPE1","",0x1), + 0x801D6FC4:("sCurOcarinaButtonIndex","UNK_TYPE1","",0x1), 0x801D6FC8:("sMusicStaffPrevPitch","UNK_TYPE1","",0x1), 0x801D6FCC:("sCurOcarinaBendFreq","f32","",0x4), 0x801D6FD0:("sDefaultOcarinaVolume","UNK_TYPE1","",0x1), - 0x801D6FD4:("sCurOcarinaBendIdx","UNK_TYPE1","",0x1), + 0x801D6FD4:("sCurOcarinaBendIndex","UNK_TYPE1","",0x1), 0x801D6FD8:("sCurOcarinaVolume","UNK_TYPE1","",0x1), 0x801D6FDC:("sCurOcarinaVibrato","UNK_TYPE1","",0x1), 0x801D6FE0:("sPlaybackState","UNK_TYPE1","",0x1), @@ -2377,8 +2377,8 @@ 0x801D7020:("sCurOcarinaSong","u8","[8]",0x8), 0x801D7028:("sOcarinaSongAppendPos","UNK_TYPE1","",0x1), 0x801D702C:("sOcarinaSongStartingPos","UNK_TYPE1","",0x1), - 0x801D7030:("sButtonToNoteMap","UNK_TYPE1","",0x1), - 0x801D7038:("sOcaMemoryGameAppendPos","UNK_TYPE1","",0x1), + 0x801D7030:("sButtonToPitchMap","UNK_TYPE1","",0x1), + 0x801D7038:("sOcarinaMemoryGameAppendPos","UNK_TYPE1","",0x1), 0x801D703C:("sOcaMemoryGameEndPos","UNK_TYPE1","",0x1), 0x801D7040:("sOcaMemoryGameNumNotes","UNK_TYPE1","",0x1), 0x801D7044:("sOcarinaSongNotes","OcarinaNote","[24][20]",0xF00), @@ -2393,9 +2393,9 @@ 0x801D8514:("sRecordOcarinaPitch","UNK_TYPE1","",0x1), 0x801D8518:("sRecordOcarinaVolume","UNK_TYPE1","",0x1), 0x801D851C:("sRecordOcarinaVibrato","UNK_TYPE1","",0x1), - 0x801D8520:("sRecordOcarinaBendIdx","UNK_TYPE1","",0x1), - 0x801D8524:("sRecordOcarinaButtonIdx","UNK_TYPE1","",0x1), - 0x801D8528:("sPlayedOcarinaSongIdxPlusOne","UNK_TYPE1","",0x1), + 0x801D8520:("sRecordOcarinaBendIndex","UNK_TYPE1","",0x1), + 0x801D8524:("sRecordOcarinaButtonIndex","UNK_TYPE1","",0x1), + 0x801D8528:("sPlayedOcarinaSongIndexPlusOne","UNK_TYPE1","",0x1), 0x801D852C:("sMusicStaffNumNotesPerTest","UNK_TYPE1","",0x1), 0x801D8530:("D_801D8530","UNK_TYPE1","",0x1), 0x801D8534:("D_801D8534","UNK_TYPE4","",0x4), @@ -2404,7 +2404,7 @@ 0x801D889C:("gScarecrowLongSongPtr","UNK_PTR","",0x4), 0x801D88A0:("gScarecrowSpawnSongPtr","UNK_PTR","",0x4), 0x801D88A4:("sTerminaWallSongPtr","UNK_PTR","",0x4), - 0x801D88A8:("sNoteToButtonMap","UNK_TYPE1","",0x1), + 0x801D88A8:("sPitchToButtonMap","UNK_TYPE1","",0x1), 0x801D88B8:("sCustomSequenceScript","UNK_TYPE1","",0x1), 0x801D8A48:("gOcarinaSongButtons","UNK_TYPE1","",0x1), 0x801D8B20:("sScarecrowAfterCreditsState","UNK_TYPE1","",0x1), @@ -4326,7 +4326,7 @@ 0x801FD3D9:("sObjSoundFanfareSeqId","UNK_TYPE1","",0x1), 0x801FD3DA:("sObjSoundFanfareRequested","UNK_TYPE1","",0x1), 0x801FD3E0:("sObjSoundFanfarePos","UNK_TYPE1","",0x1), - 0x801FD3EC:("sObjSoundPlayerIdx","UNK_TYPE1","",0x1), + 0x801FD3EC:("sObjSoundPlayerIndex","UNK_TYPE1","",0x1), 0x801FD3F0:("sObjSoundPos","UNK_TYPE1","",0x1), 0x801FD3FC:("sObjSoundFlags","UNK_TYPE1","",0x1), 0x801FD400:("sObjSoundMinDist","UNK_TYPE1","",0x1), @@ -4341,7 +4341,7 @@ 0x801FD432:("D_801FD432","UNK_TYPE1","",0x1), 0x801FD433:("sSpatialSubBgmFadeTimer","UNK_TYPE1","",0x1), 0x801FD434:("D_801FD434","UNK_TYPE1","",0x1), - 0x801FD435:("sSpatialSeqPlayerIdx","UNK_TYPE1","",0x1), + 0x801FD435:("sSpatialSeqPlayerIndex","UNK_TYPE1","",0x1), 0x801FD436:("sSpatialSeqFadeTimer","UNK_TYPE1","",0x1), 0x801FD438:("D_801FD438","UNK_TYPE1","",0x1), 0x801FD43A:("sPlayingStaff","OcarinaStaff","",0x3), @@ -4356,8 +4356,8 @@ 0x801FD460:("sOcarinaResetDelay","UNK_TYPE1","",0x1), 0x801FD461:("sOcarinaResetUnused","UNK_TYPE1","",0x1), 0x801FD462:("sOcarinaHasStartedSong","UNK_TYPE1","",0x1), - 0x801FD463:("sFirstOcarinaSongIdx","UNK_TYPE1","",0x1), - 0x801FD464:("sLastOcarinaSongIdx","UNK_TYPE1","",0x1), + 0x801FD463:("sFirstOcarinaSongIndex","UNK_TYPE1","",0x1), + 0x801FD464:("sLastOcarinaSongIndex","UNK_TYPE1","",0x1), 0x801FD468:("sOcarinaAvailSongs","UNK_TYPE1","",0x1), 0x801FD46C:("sOcarinaStaffPlayingPos","UNK_TYPE1","",0x1), 0x801FD470:("sMusicStaffPos","UNK_TYPE1","",0x1), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index bc8fd6f48..bf777cba1 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -3234,7 +3234,7 @@ asm/non_matchings/code/code_80192BE0/func_8019440C.s,func_8019440C,0x8019440C,0x asm/non_matchings/code/code_80192BE0/func_80194528.s,func_80194528,0x80194528,0x8 asm/non_matchings/code/code_80192BE0/func_80194548.s,func_80194548,0x80194548,0x8 asm/non_matchings/code/code_80192BE0/func_80194568.s,func_80194568,0x80194568,0x40 -asm/non_matchings/code/code_80192BE0/func_80194668.s,func_80194668,0x80194668,0x1F +asm/non_matchings/code/code_80192BE0/Audio_NextRandom.s,Audio_NextRandom,0x80194668,0x1F asm/non_matchings/code/code_80192BE0/Audio_InitMesgQueues.s,Audio_InitMesgQueues,0x801946E4,0xB asm/non_matchings/code/code_80194710/Audio_InvalDCache.s,Audio_InvalDCache,0x80194710,0x10 asm/non_matchings/code/code_80194710/Audio_WritebackDCache.s,Audio_WritebackDCache,0x80194750,0x10 @@ -3325,13 +3325,13 @@ asm/non_matchings/code/code_8019AF00/func_8019AF00.s,func_8019AF00,0x8019AF00,0x asm/non_matchings/code/code_8019AF00/func_8019AF58.s,func_8019AF58,0x8019AF58,0x24 asm/non_matchings/code/code_8019AF00/func_8019AFE8.s,func_8019AFE8,0x8019AFE8,0x11 asm/non_matchings/code/code_8019AF00/func_8019B02C.s,func_8019B02C,0x8019B02C,0x12 -asm/non_matchings/code/code_8019AF00/func_8019B074.s,func_8019B074,0x8019B074,0x34 +asm/non_matchings/code/code_8019AF00/AudioOcarina_MapSongFromNotesToButtons.s,AudioOcarina_MapSongFromNotesToButtons,0x8019B074,0x34 asm/non_matchings/code/code_8019AF00/func_8019B144.s,func_8019B144,0x8019B144,0x8D asm/non_matchings/code/code_8019AF00/func_8019B378.s,func_8019B378,0x8019B378,0x5 asm/non_matchings/code/code_8019AF00/func_8019B38C.s,func_8019B38C,0x8019B38C,0x11 asm/non_matchings/code/code_8019AF00/func_8019B3D0.s,func_8019B3D0,0x8019B3D0,0x3A asm/non_matchings/code/code_8019AF00/func_8019B4B8.s,func_8019B4B8,0x8019B4B8,0x23 -asm/non_matchings/code/code_8019AF00/func_8019B544.s,func_8019B544,0x8019B544,0x9 +asm/non_matchings/code/code_8019AF00/AudioOcarina_StartDefault.s,AudioOcarina_StartDefault,0x8019B544,0x9 asm/non_matchings/code/code_8019AF00/func_8019B568.s,func_8019B568,0x8019B568,0x11 asm/non_matchings/code/code_8019AF00/func_8019B5AC.s,func_8019B5AC,0x8019B5AC,0x10 asm/non_matchings/code/code_8019AF00/func_8019B5EC.s,func_8019B5EC,0x8019B5EC,0xB @@ -3344,7 +3344,7 @@ asm/non_matchings/code/code_8019AF00/func_8019C1C0.s,func_8019C1C0,0x8019C1C0,0x asm/non_matchings/code/code_8019AF00/func_8019C1D0.s,func_8019C1D0,0x8019C1D0,0x26 asm/non_matchings/code/code_8019AF00/func_8019C268.s,func_8019C268,0x8019C268,0x1F asm/non_matchings/code/code_8019AF00/func_8019C2E4.s,func_8019C2E4,0x8019C2E4,0x7 -asm/non_matchings/code/code_8019AF00/func_8019C300.s,func_8019C300,0x8019C300,0x26 +asm/non_matchings/code/code_8019AF00/AudioOcarina_SetInstrumentId.s,AudioOcarina_SetInstrumentId,0x8019C300,0x26 asm/non_matchings/code/code_8019AF00/func_8019C398.s,func_8019C398,0x8019C398,0x82 asm/non_matchings/code/code_8019AF00/func_8019C5A0.s,func_8019C5A0,0x8019C5A0,0xCE asm/non_matchings/code/code_8019AF00/func_8019C8D8.s,func_8019C8D8,0x8019C8D8,0x10C @@ -3354,12 +3354,12 @@ asm/non_matchings/code/code_8019AF00/func_8019CE6C.s,func_8019CE6C,0x8019CE6C,0x asm/non_matchings/code/code_8019AF00/func_8019CEBC.s,func_8019CEBC,0x8019CEBC,0x2C asm/non_matchings/code/code_8019AF00/func_8019CF6C.s,func_8019CF6C,0x8019CF6C,0x3 asm/non_matchings/code/code_8019AF00/func_8019CF78.s,func_8019CF78,0x8019CF78,0x9 -asm/non_matchings/code/code_8019AF00/func_8019CF9C.s,func_8019CF9C,0x8019CF9C,0x3 +asm/non_matchings/code/code_8019AF00/AudioOcarina_GetPlaybackStaff.s,AudioOcarina_GetPlaybackStaff,0x8019CF9C,0x3 asm/non_matchings/code/code_8019AF00/func_8019CFA8.s,func_8019CFA8,0x8019CFA8,0x63 -asm/non_matchings/code/code_8019AF00/func_8019D134.s,func_8019D134,0x8019D134,0x4E -asm/non_matchings/code/code_8019AF00/func_8019D26C.s,func_8019D26C,0x8019D26C,0x87 -asm/non_matchings/code/code_8019AF00/func_8019D488.s,func_8019D488,0x8019D488,0x1C -asm/non_matchings/code/code_8019AF00/func_8019D4F8.s,func_8019D4F8,0x8019D4F8,0x42 +asm/non_matchings/code/code_8019AF00/AudioOcarina_TerminaWallValidateNotes.s,AudioOcarina_TerminaWallValidateNotes,0x8019D134,0x4E +asm/non_matchings/code/code_8019AF00/AudioOcarina_TerminaWallGenerateNotes.s,AudioOcarina_TerminaWallGenerateNotes,0x8019D26C,0x87 +asm/non_matchings/code/code_8019AF00/AudioOcarina_MemoryGameSetNumNotes.s,AudioOcarina_MemoryGameSetNumNotes,0x8019D488,0x1C +asm/non_matchings/code/code_8019AF00/AudioOcarina_MemoryGameGenerateNotes.s,AudioOcarina_MemoryGameGenerateNotes,0x8019D4F8,0x42 asm/non_matchings/code/code_8019AF00/func_8019D600.s,func_8019D600,0x8019D600,0x56 asm/non_matchings/code/code_8019AF00/func_8019D758.s,func_8019D758,0x8019D758,0x43 asm/non_matchings/code/code_8019AF00/func_8019D864.s,func_8019D864,0x8019D864,0x14 From 4f3202fd7e5313ab7b777eb3be162283fe5ea142 Mon Sep 17 00:00:00 2001 From: Andzura <11079691+Andzura@users.noreply.github.com> Date: Sun, 27 Mar 2022 17:09:47 +0200 Subject: [PATCH 139/257] z_message progress (#701) * 8 functions matching, 1 non-matching, 45 untouched * match func_801518B0 * match func_8014CC14 * matching 8 func, 1 non-matching * matched func_80148CBC * matched func_80156758 * matched func_80147564 * matched func_80151BB4 * matched func80152EC0/Message_Spawn_Song_Effect * matched func_80151C9C * WIP func_80148B98 * WIP func_80151938 * matched func_80151938 * matched func_80148B98 * matched func_80147734 * matched func_80147624 * WIP func_8014EBC * match func_801518B0 * matched func_80147564 * matched func80152EC0/Message_Spawn_Song_Effect * matched func_80151C9C * WIP func_80148B98 * matched func_80151938 * matched func_80148B98 * matched func_80147734 * matched func_80147624 * WIP#2 func_8014EBC * matched func_80149EBC * WIP func_8014CCB4 * matched func_8014CCB4 * matched func_80151A68 * WIP func_8014D62C * fix func_8015A68 signature * z_message_nes & z_message_staff progress * z_message_nes & z_message_staff renaming * documenting z_message * cleaning & renaming * documenting MessageContext * matched func_80151A68 * format * naming convention fix * re-add func_80147564 * apply renaming of Message_ShouldAdvanceSilent on the whole project * re-format, add clang-format off/on in z_message.c needed for matching * rename staff => credits; add renames in actorfixer. * change rupees array to ascii * remove useless comments * change MessageContext.decodedBuffer to a union * remove decodedBuffer from actorfixer * applied AngheloAlf suggestions & ran sfxconvert on z_message.c * rename message_struct => message_data_static; revert decodedBuffer as union creating differences. * use true/false instead of 1/0 * use SET_FULLSCREEN_VIEWPORT macro in func_80152c64 * AngheloAlf suggestions. * extract assign from dayTime calculation for readability in Message_LoadTimeNES * remove bss_reordering from osFlash, idle & boot_main to typedef MessageTableEntry in message_data_static & make decodedBuffer an union. * remove useless casts * Changes hexa to ascii chars when it's meaningful; add comments to func_8014CCB4 to show what hexa constant means. * Hensldm suggestions * ran actorfixer on new changes; fix new bss reordering error introduced with rebase * use new TIME_TO_MINUTES_F macro * re-ran format.sh * hensldm suggestions #2 + overall cleaning * remove useless parenthesis * Update include/message_data_static.h Co-authored-by: Anghelo Carvajal * actorfixer and format * more fixes Co-authored-by: Andzura Co-authored-by: abaud Co-authored-by: Anghelo Carvajal --- docs/tutorial/advanced_control_flow.md | 42 +- docs/tutorial/documenting.md | 4 +- docs/tutorial/other_functions.md | 6 +- include/functions.h | 44 +- include/message_data_static.h | 12 + include/variables.h | 12 +- include/z64.h | 78 ++- src/code/z_demo.c | 4 +- src/code/z_message.c | 493 +++++++++++++++++- src/code/z_message_nes.c | 276 +++++++++- src/code/z_message_staff.c | 23 +- .../actors/ovl_Bg_Ingate/z_bg_ingate.c | 2 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 2 +- .../actors/ovl_Door_Warp1/z_door_warp1.c | 2 +- src/overlays/actors/ovl_En_Ah/z_en_ah.c | 2 +- .../ovl_En_Akindonuts/z_en_akindonuts.c | 10 +- src/overlays/actors/ovl_En_Al/z_en_al.c | 2 +- src/overlays/actors/ovl_En_Ani/z_en_ani.c | 2 +- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 16 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 6 +- .../actors/ovl_En_Baisen/z_en_baisen.c | 6 +- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 8 +- .../ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c | 4 +- .../actors/ovl_En_Bombers/z_en_bombers.c | 4 +- .../actors/ovl_En_Bombers2/z_en_bombers2.c | 2 +- .../actors/ovl_En_Bomjima/z_en_bomjima.c | 8 +- .../actors/ovl_En_Bomjimb/z_en_bomjimb.c | 4 +- .../actors/ovl_En_Col_Man/z_en_col_man.c | 2 +- src/overlays/actors/ovl_En_Cow/z_en_cow.c | 6 +- src/overlays/actors/ovl_En_Daiku/z_en_daiku.c | 2 +- .../actors/ovl_En_Daiku2/z_en_daiku2.c | 2 +- .../ovl_En_Demo_heishi/z_en_demo_heishi.c | 2 +- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 32 +- src/overlays/actors/ovl_En_Dnq/z_en_dnq.c | 2 +- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 12 +- src/overlays/actors/ovl_En_Fish2/z_en_fish2.c | 2 +- .../actors/ovl_En_Fishing/z_en_fishing.c | 32 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 32 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 12 +- src/overlays/actors/ovl_En_Gb2/z_en_gb2.c | 12 +- src/overlays/actors/ovl_En_Geg/z_en_geg.c | 8 +- src/overlays/actors/ovl_En_Gg/z_en_gg.c | 2 +- src/overlays/actors/ovl_En_Gg2/z_en_gg2.c | 2 +- .../actors/ovl_En_Ginko_Man/z_en_ginko_man.c | 12 +- src/overlays/actors/ovl_En_Gk/z_en_gk.c | 10 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 4 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 2 +- src/overlays/actors/ovl_En_Gs/z_en_gs.c | 4 +- .../ovl_En_Guard_Nuts/z_en_guard_nuts.c | 2 +- .../actors/ovl_En_Guruguru/z_en_guruguru.c | 2 +- src/overlays/actors/ovl_En_Hgo/z_en_hgo.c | 4 +- .../ovl_En_Hidden_Nuts/z_en_hidden_nuts.c | 2 +- .../actors/ovl_En_Hint_Skb/z_en_hint_skb.c | 6 +- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 2 +- src/overlays/actors/ovl_En_In/z_en_in.c | 4 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 2 +- src/overlays/actors/ovl_En_Ja/z_en_ja.c | 2 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 8 +- .../actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c | 6 +- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 8 +- .../actors/ovl_En_Kendo_Js/z_en_kendo_js.c | 8 +- src/overlays/actors/ovl_En_Kgy/z_en_kgy.c | 24 +- .../actors/ovl_En_Look_Nuts/z_en_look_nuts.c | 2 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 6 +- .../actors/ovl_En_Ma_Yto/z_en_ma_yto.c | 20 +- .../actors/ovl_En_Ma_Yts/z_en_ma_yts.c | 4 +- .../actors/ovl_En_Minifrog/z_en_minifrog.c | 16 +- src/overlays/actors/ovl_En_Mk/z_en_mk.c | 14 +- src/overlays/actors/ovl_En_Mm2/z_en_mm2.c | 2 +- src/overlays/actors/ovl_En_Mm3/z_en_mm3.c | 6 +- src/overlays/actors/ovl_En_Ms/z_en_ms.c | 6 +- .../actors/ovl_En_Mt_tag/z_en_mt_tag.c | 4 +- src/overlays/actors/ovl_En_Muto/z_en_muto.c | 8 +- src/overlays/actors/ovl_En_Osk/z_en_osk.c | 2 +- src/overlays/actors/ovl_En_Osn/z_en_osn.c | 4 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 20 +- src/overlays/actors/ovl_En_Ot/z_en_ot.c | 6 +- src/overlays/actors/ovl_En_Owl/z_en_owl.c | 20 +- .../actors/ovl_En_Pamera/z_en_pamera.c | 4 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 4 +- .../actors/ovl_En_Rail_Skb/z_en_rail_skb.c | 6 +- .../actors/ovl_En_Railgibud/z_en_railgibud.c | 4 +- .../actors/ovl_En_Recepgirl/z_en_recepgirl.c | 2 +- .../actors/ovl_En_Scopenuts/z_en_scopenuts.c | 4 +- .../actors/ovl_En_Sellnuts/z_en_sellnuts.c | 14 +- src/overlays/actors/ovl_En_Shn/z_en_shn.c | 6 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 4 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 18 +- src/overlays/actors/ovl_En_Ssh/z_en_ssh.c | 6 +- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 20 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 12 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 14 +- src/overlays/actors/ovl_En_Tab/z_en_tab.c | 6 +- .../ovl_En_Talk_Gibud/z_en_talk_gibud.c | 4 +- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 8 +- src/overlays/actors/ovl_En_Toto/z_en_toto.c | 6 +- src/overlays/actors/ovl_En_Trt/z_en_trt.c | 40 +- src/overlays/actors/ovl_En_Trt2/z_en_trt2.c | 14 +- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 2 +- .../actors/ovl_En_Tru_Mt/z_en_tru_mt.c | 2 +- src/overlays/actors/ovl_En_Tsn/z_en_tsn.c | 36 +- .../ovl_En_Weather_Tag/z_en_weather_tag.c | 6 +- src/overlays/actors/ovl_En_Yb/z_en_yb.c | 4 +- src/overlays/actors/ovl_En_Zob/z_en_zob.c | 24 +- src/overlays/actors/ovl_En_Zog/z_en_zog.c | 20 +- src/overlays/actors/ovl_En_Zos/z_en_zos.c | 20 +- src/overlays/actors/ovl_En_Zot/z_en_zot.c | 58 +-- src/overlays/actors/ovl_En_Zov/z_en_zov.c | 10 +- src/overlays/actors/ovl_En_Zow/z_en_zow.c | 6 +- .../actors/ovl_Obj_Ghaka/z_obj_ghaka.c | 4 +- .../ovl_Obj_Moon_Stone/z_obj_moon_stone.c | 2 +- .../actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c | 4 +- .../ovl_Obj_Warpstone/z_obj_warpstone.c | 2 +- tools/actorfixer.py | 19 +- tools/disasm/functions.txt | 24 +- tools/sizes/code_functions.csv | 24 +- 116 files changed, 1377 insertions(+), 574 deletions(-) create mode 100644 include/message_data_static.h diff --git a/docs/tutorial/advanced_control_flow.md b/docs/tutorial/advanced_control_flow.md index 3420fc597..8cd9660ba 100644 --- a/docs/tutorial/advanced_control_flow.md +++ b/docs/tutorial/advanced_control_flow.md @@ -159,14 +159,14 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 != 4) { if (temp_v0 != 5) { - if ((temp_v0 == 6) && (func_80147624(globalCtx) != 0)) { + if ((temp_v0 == 6) && (Message_ShouldAdvance(globalCtx) != 0)) { this->actionFunc = func_80952734; return; } // Duplicate return node #17. Try simplifying control flow for better match return; } - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; @@ -175,7 +175,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { // Duplicate return node #17. Try simplifying control flow for better match return; } - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { temp_v0_2 = globalCtx->msgCtx.choiceIndex; if (temp_v0_2 != 0) { if (temp_v0_2 != 1) { @@ -211,7 +211,7 @@ which is long, messy, and contains some rather nasty-looking control flow, inclu temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 != 4) { if (temp_v0 != 5) { - if ((temp_v0 == 6) && (func_80147624(globalCtx) != 0)) { + if ((temp_v0 == 6) && (Message_ShouldAdvance(globalCtx) != 0)) { this->actionFunc = func_80952734; return; } @@ -248,13 +248,13 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { goto block_17; } - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } this->actionFunc = func_80952734; return; block_5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } func_801477B4(globalCtx); @@ -262,7 +262,7 @@ block_5: this->actionFunc = func_809529AC; return; block_7: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } temp_v0_2 = globalCtx->msgCtx.choiceIndex; @@ -350,13 +350,13 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { goto block_17; } - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } this->actionFunc = func_80952734; return; block_5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } func_801477B4(globalCtx); @@ -364,7 +364,7 @@ block_5: this->actionFunc = func_809529AC; return; block_7: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } temp_v0_2 = globalCtx->msgCtx.choiceIndex; @@ -420,13 +420,13 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { return; } - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } this->actionFunc = func_80952734; return; block_5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } func_801477B4(globalCtx); @@ -434,7 +434,7 @@ block_5: this->actionFunc = func_809529AC; return; block_7: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } temp_v0_2 = globalCtx->msgCtx.choiceIndex; @@ -557,7 +557,7 @@ There's a couple of other obvious things here: Well, at least the bottom half looks respectable now. Again, there is no code after the switch, so the next thing up, namely ```C - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } ``` @@ -578,13 +578,13 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { return; } - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } this->actionFunc = func_80952734; return; block_5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } func_801477B4(globalCtx); @@ -592,7 +592,7 @@ block_5: this->actionFunc = func_809529AC; return; block_7: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_801477B4(globalCtx); @@ -647,7 +647,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { break; case 5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } func_801477B4(globalCtx); @@ -656,7 +656,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { break; case 4: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_801477B4(globalCtx); @@ -700,7 +700,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { break; case 5: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; @@ -708,7 +708,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { break; case 4: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_801477B4(globalCtx); diff --git a/docs/tutorial/documenting.md b/docs/tutorial/documenting.md index b064b3e3b..e50921bef 100644 --- a/docs/tutorial/documenting.md +++ b/docs/tutorial/documenting.md @@ -183,7 +183,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { return; } - if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { + if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); @@ -500,7 +500,7 @@ void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) { if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; // hear directions again? func_80C10148(this); - } else if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { + } else if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { // "Welcome..." Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); diff --git a/docs/tutorial/other_functions.md b/docs/tutorial/other_functions.md index b0350a838..0795fa76e 100644 --- a/docs/tutorial/other_functions.md +++ b/docs/tutorial/other_functions.md @@ -288,7 +288,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { func_80C10148(this); return; } - if (((temp_v0_2 & 0xFF) == 5) && (func_80147624(globalCtx) != 0)) { + if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { temp_v0_3 = this->actor.textId; if (temp_v0_3 == 0x2AD9) { Flags_SetSwitch(globalCtx, (s32) this->actor.params); @@ -347,7 +347,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { return; } - if (((temp_v0_2 & 0xFF) == 5) && (func_80147624(globalCtx) != 0)) { + if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); @@ -397,7 +397,7 @@ somehow we skipped over `t0`. Where is this in the code? The `153` in the middle return; } - if (((temp_v0_2 & 0xFF) == 5) && (func_80147624(globalCtx) != 0)) { + if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { ``` If you look at the conditionals and the declaration of `temp_v0_2`, you may notice something odd: `temp_v0_2` is a `u8`. Therefore the `& 0xFF` does nothing! It's surprisingly common for this to happen, be it leaving out a `& 0xFF` or adding an extraneous one. If we remove it, we get a match: diff --git a/include/functions.h b/include/functions.h index a956de5ee..7c9f8d044 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1801,7 +1801,7 @@ void func_80105818(GlobalContext* globalCtx, u32 uParm2, TransitionActorEntry* p // void func_80109F78(void); s32 func_8010A000(GlobalContext* globalCtx); s32 func_8010A074(GlobalContext* globalCtx); -// void func_8010A0A4(void); +s32 func_8010A0A4(GlobalContext* globalCtx); // void func_8010A0F0(void); // void func_8010A164(void); // void func_8010A194(void); @@ -2609,10 +2609,10 @@ void func_80147198(SramContext* param_1); // void Sram_nop8014750C(UNK_TYPE4 param_1); // void func_80147520(void); void func_80147564(GlobalContext* globalCtx); -s32 func_80147624(GlobalContext* globalCtx); -s32 func_80147734(GlobalContext* globalCtx); +s32 Message_ShouldAdvance(GlobalContext* globalCtx); +s32 Message_ShouldAdvanceSilent(GlobalContext* globalCtx); void func_801477B4(GlobalContext* globalCtx); -// void func_80147818(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); +void func_80147818(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); // void func_80147F18(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); // void func_80148558(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); void func_80148B98(GlobalContext* globalCtx, u8 bParm2); @@ -2623,28 +2623,28 @@ void func_80148B98(GlobalContext* globalCtx, u8 bParm2); // void func_80149454(void); // void func_801496C8(void); // void func_8014995C(void); -// void func_80149C18(void); -// void func_80149EBC(void); +void func_80149C18(GlobalContext* globalCtx); +// void Message_FindMessage(void); void func_80149F74(GlobalContext* globalCtx, u32** ppuParm2); // void func_8014AAD0(void); void func_8014ADBC(GlobalContext* globalCtx, UNK_PTR puParm2); // void func_8014C70C(void); -// void func_8014CC14(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); +void Message_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32* offset, f32* arg3, s16 arg4); // void func_8014CCB4(void); // void func_8014CDF0(void); // void func_8014CFDC(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_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); -// void func_80150A84(void); +void func_80150A84(GlobalContext* globalCtx); void func_80150D08(GlobalContext* globalCtx, u32 uParm2); // void func_801514B0(void); void Message_StartTextbox(GlobalContext* globalCtx, u16 textId, Actor* Actor); void func_80151938(GlobalContext* globalCtx, u16 textId); void func_80151A68(GlobalContext* globalCtx, u16 textId); -void func_80151BB4(GlobalContext* globalCtx, u32 uParm2); +void func_80151BB4(GlobalContext* globalCtx, u8 uParm2); // void func_80151C9C(void); -// void func_80151DA4(void); +void func_80151DA4(GlobalContext* globalCtx, u16 arg2); void func_80152434(GlobalContext* globalCtx, u16 arg2); // void func_80152464(void); u8 Message_GetState(MessageContext* msgCtx); @@ -2656,23 +2656,23 @@ u8 Message_GetState(MessageContext* msgCtx); // void func_80153750(void); // void func_80153E7C(void); // void func_80153EF0(void); -// void func_801541D4(void); +void func_801541D4(GlobalContext* globalCtx, Gfx** gfxp); // void func_80156758(void); void func_8015680C(GlobalContext* globalCtx); void func_801586A4(GlobalContext* globalCtx); void Message_Init(GlobalContext* globalCtx); -void func_801588D0(GlobalContext* globalCtx, s16 param_2); -// void func_80158988(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); -// void func_80158A24(void); -// void func_80158C04(void); -// void func_80158D98(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); -// void func_80158FB0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8015926C(void); +void Message_FindMessageNES(GlobalContext* globalCtx, 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_LoadAreaTextNES(void); // void func_80159438(void); -// void func_8015966C(void); +void func_8015966C(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE arg3); // void func_8015A144(void); -// void func_8015B198(void); -// void func_8015E750(void); +void func_8015B198(GlobalContext* globalCtx); +void Message_FindCreditsMessage(GlobalContext *globalCtx, u16 textId); void func_8015E7EC(GlobalContext* globalCtx, UNK_PTR puParm2); // void func_8015F8A8(UNK_TYPE4 ctxt); diff --git a/include/message_data_static.h b/include/message_data_static.h new file mode 100644 index 000000000..f69e17232 --- /dev/null +++ b/include/message_data_static.h @@ -0,0 +1,12 @@ +#ifndef MESSAGE_DATA_STATIC_H +#define MESSAGE_DATA_STATIC_H + +#include "PR/ultratypes.h" + +typedef struct MessageTableEntry{ + /* 0x0 */ u16 textId; + /* 0x2 */ u8 typePos; + /* 0x4 */ const char* segment; +} MessageTableEntry; // size = 0x8; + +#endif diff --git a/include/variables.h b/include/variables.h index 7d3070f58..399fadc98 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1412,9 +1412,7 @@ extern u16 D_801C6A44; // extern UNK_TYPE1 D_801C6A98; // extern UNK_TYPE1 D_801C6AB8; // extern UNK_TYPE1 D_801C6B28; -// extern UNK_TYPE1 D_801C6B98; // extern UNK_TYPE1 D_801CED40; -// extern UNK_TYPE1 D_801CFB08; // extern UNK_TYPE2 D_801CFC78; // extern UNK_TYPE1 D_801CFC7A; // extern UNK_TYPE1 D_801CFC7C; @@ -1424,8 +1422,8 @@ extern u16 D_801C6A44; // extern UNK_TYPE1 D_801CFC8C; // extern UNK_TYPE1 D_801CFC8E; // extern UNK_TYPE1 D_801CFC92; -// extern UNK_TYPE1 D_801CFC98; -// extern UNK_TYPE2 D_801CFCA4; +extern u8 D_801CFC98; +extern s16 D_801CFCA4[9]; // extern UNK_TYPE2 D_801CFCAC; // extern UNK_TYPE1 D_801CFCB8; // extern UNK_TYPE2 D_801CFCD8; @@ -1517,11 +1515,11 @@ extern char D_801D039C[]; // extern UNK_TYPE1 D_801D0428; // extern UNK_TYPE1 D_801D045A; // extern UNK_TYPE1 D_801D0462; -// extern UNK_TYPE1 D_801D0468; +//extern UNK_TYPE1 D_801D0468; // extern UNK_TYPE1 D_801D0470; -extern char D_801D06F0[]; +// extern char D_801D06F0[]; // extern UNK_TYPE1 D_801D0710; -extern char D_801D0714[]; +// extern char D_801D0714[]; // extern UNK_TYPE1 D_801D07C4; // extern UNK_TYPE1 D_801D07DC; // extern UNK_TYPE1 D_801D080C; diff --git a/include/z64.h b/include/z64.h index dc8912d49..5c6c931a4 100644 --- a/include/z64.h +++ b/include/z64.h @@ -21,6 +21,7 @@ #include "ichain.h" #include "sequence.h" #include "sfx.h" +#include "message_data_static.h" #include "z64actor.h" #include "z64animation.h" @@ -174,7 +175,7 @@ typedef struct { } msgBuf; /* 0x11D80 */ u8* messageStart; /* 0x11D84 */ u8* messageEnd; - /* 0x11D88 */ u8 unk_11D88; + /* 0x11D88 */ u8 unk_11D88; // current Char Buffer ? } Font; // size = 0x11D8C // Game Info aka. Static Context @@ -839,44 +840,91 @@ typedef struct { typedef struct { /* 0x00000 */ View view; /* 0x00168 */ Font font; - /* 0x11EF4 */ char unk_11EF4[0x10]; - /* 0x11F04 */ u16 unk11F04; + /* 0x11EF4 */ char unk_11EF4[0x4]; + /* 0x11EF8 */ UNK_PTR unk11EF8; + /* 0x11EFC */ UNK_TYPE1 unk11EFC[0x8]; + /* 0x11F04 */ u16 currentTextId; /* 0x11F06 */ UNK_TYPE1 pad11F06[0x4]; /* 0x11F0A */ u8 unk11F0A; /* 0x11F0B */ UNK_TYPE1 pad11F0B[0x5]; /* 0x11F10 */ s32 unk11F10; - /* 0x11F14 */ UNK_TYPE1 pad11F14[0xE]; + /* 0x11F14 */ UNK_TYPE1 pad11F14[0x6]; + /* 0x11F1A */ s16 unk11F1A[3]; + /* 0x11F20 */ UNK_TYPE1 pad11F20[0x2]; /* 0x11F22 */ u8 msgMode; - /* 0x11F23 */ UNK_TYPE1 pad11F23[0xFD]; + /* 0x11F23 */ UNK_TYPE1 pad11F23; + /* 0x11F24 */ union { + u8 schar[206]; + u16 wchar[103]; + } decodedBuffer; + /* 0x11FF2 */ u16 unk11FF2; + /* 0x11FF4 */ s16 unk11FF4; + /* 0x11FF6 */ s16 unk11FF6; + /* 0x11FF8 */ UNK_TYPE1 unk11FF8[0x6]; + /* 0x11FFE */ s16 unk11FFE[0x3]; + /* 0x12004 */ s16 unk12004; + /* 0x12006 */ s16 unk12006; + /* 0x12008 */ u8 unk12008[0x16]; + /* 0x1201E */ s16 unk1201E; /* 0x12020 */ u8 unk12020; /* 0x12021 */ u8 choiceIndex; /* 0x12022 */ u8 unk12022; /* 0x12023 */ u8 unk12023; - /* 0x12024 */ UNK_TYPE1 unk12024[0x6]; + /* 0x12024 */ s16 unk12024; + /* 0x12026 */ u16 unk12026; + /* 0x12028 */ u16 songPlayed; /* 0x1202A */ u16 ocarinaMode; /* 0x1202C */ u16 ocarinaAction; /* 0x1202E */ u16 unk1202E; /* 0x12030 */ s16 unk_12030; /* 0x12032 */ UNK_TYPE1 unk_12032[0x2]; - /* 0x12034 */ UNK_TYPE1 pad12034[0x10]; + /* 0x12034 */ UNK_TYPE1 pad12034[0x6]; + /* 0x1203A */ s16 unk1203A; + /* 0x1203C */ s16 unk1203C; + /* 0x1203E */ s16 pad1203E; + /* 0x12040 */ Actor* unkActor; /* 0x12044 */ s16 unk12044; - /* 0x12046 */ UNK_TYPE1 pad12046[0x2]; + /* 0x12046 */ s16 unk12046; /* 0x12048 */ u8 unk12048; // EnKakasi - /* 0x12049 */ UNK_TYPE1 pad12049[0xB]; - /* 0x12054 */ s16 unk12054[5]; // Number entry - /* 0x1205A */ UNK_TYPE1 pad1205A[0xC]; + /* 0x12049 */ UNK_TYPE1 pad12049[0x1]; + /* 0x1204A */ s16 unk1204A[0x5]; + /* 0x12054 */ s16 unk12054[3]; // First, second and third digits in lottery code guess + /* 0x1205A */ UNK_TYPE1 pad1205A[0xE]; + /* 0x12068 */ s16 unk12068; /* 0x1206A */ s16 unk1206A; /* 0x1206C */ s32 unk1206C; /* 0x12070 */ s32 unk12070; /* 0x12074 */ UNK_TYPE1 pad12074[0x4]; /* 0x12078 */ s32 bankRupeesSelected; /* 0x1207C */ s32 bankRupees; - /* 0x12080 */ UNK_TYPE1 pad12080[0x30]; + /* 0x12080 */ MessageTableEntry* messageEntryTable; + /* 0x12084 */ MessageTableEntry* messageEntryTableNes; + /* 0x12088 */ UNK_TYPE4 unk12088; + /* 0x1208C */ MessageTableEntry* messageTableStaff; + /* 0x12090 */ s16 unk12090; + /* 0x12092 */ s16 unk12092; + /* 0x12094 */ s8 unk12094; + /* 0x12095 */ UNK_TYPE1 unk12095[0x3]; + /* 0x12098 */ f32 unk12098; // Text_Scale? + /* 0x1209C */ s16 unk1209C; + /* 0x1209E */ UNK_TYPE1 unk1209E[0x2]; + /* 0x120A0 */ s32 unk120A0; + /* 0x120A4 */ UNK_TYPE1 unk120A4[0xC]; /* 0x120B0 */ u8 unk120B0; /* 0x120B1 */ u8 unk120B1; - /* 0x120B2 */ UNK_TYPE1 pad120B2[0x22]; - /* 0x120D4 */ UNK_TYPE2 unk120D4; - /* 0x120D6 */ UNK_TYPE2 unk120D6; + /* 0x120B2 */ u8 unk120B2[0xC]; + /* 0x120BE */ s16 unk120BE; + /* 0x120C0 */ s16 unk120C0; + /* 0x120C2 */ s16 unk120C2; + /* 0x120C4 */ s32 unk120C4; + /* 0x120C8 */ s16 unk120C8; + /* 0x120CA */ s16 unk120CA; + /* 0x120CC */ s16 unk120CC; + /* 0x120CE */ s16 unk120CE; + /* 0x120D0 */ s16 unk120D0; + /* 0x120D2 */ s16 unk120D2; + /* 0x120D4 */ s16 unk120D4; + /* 0x120D6 */ s16 unk120D6; /* 0x120D8 */ UNK_TYPE1 pad120D8[0x8]; } MessageContext; // size = 0x120E0 diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 785f86856..23dd435ec 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1055,7 +1055,7 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, dialogState = Message_GetState(&globalCtx->msgCtx); if ((dialogState != 2) && (dialogState != 0) && (dialogState != 7) && (dialogState != 8)) { csCtx->frames--; - if ((dialogState == 4) && func_80147624(globalCtx)) { + if ((dialogState == 4) && Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { if (cmd->base == 0x33BD) { func_8019F230(); @@ -1093,7 +1093,7 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, } } - if (dialogState == 5 && func_80147624(globalCtx) != 0) { + if (dialogState == 5 && Message_ShouldAdvance(globalCtx) != 0) { func_80152434(globalCtx, cmd->base); } } diff --git a/src/code/z_message.c b/src/code/z_message.c index 0eceeee30..447c354c6 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -1,14 +1,111 @@ #include "global.h" +#include "message_data_static.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147520.s") +#if 0 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147564.s") +s16 D_801D02D8[15] = { + ACTOR_OCEFF_WIPE5, ACTOR_OCEFF_WIPE5, // Sonata of Awakening Effect, Sonata of Awakening Effect + ACTOR_OCEFF_WIPE5, ACTOR_OCEFF_WIPE5, // Sonata of Awakening Effect, Sonata of Awakening Effect + ACTOR_OCEFF_WIPE5, ACTOR_OCEFF_WIPE5, // Sonata of Awakening Effect, Sonata of Awakening Effect + ACTOR_OCEFF_WIPE, ACTOR_OCEFF_WIPE7, // Song of Time Effect, Song of Healing Effect + ACTOR_OCEFF_WIPE2, ACTOR_OCEFF_WIPE6, // Epona's Song Effect, Song of Soaring Effect + ACTOR_OCEFF_STORM, ACTOR_OCEFF_SPOT, // Song of Storms Effect II [?], Sun's Song Effect + ACTOR_OCEFF_WIPE, ACTOR_OCEFF_WIPE, // Song of Time Effect, Song of Time Effect + ACTOR_OCEFF_WIPE4 // Scarecrow's Song Effect +}; +s32 D_801D02F8[15] = { 0,1,2,3,4,0,1,0,0,0,0,0,1,1,0 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147624.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147734.s") +extern u16 D_801C6AB8[]; +extern u16 D_801C6B28[]; +extern s16 D_801D02D8[]; +extern s32 D_801D02F8[]; +extern s16 D_801F6B0C; +extern s16 D_801F6B0E; +extern s16 D_801F6B10; +extern s16 D_801F6B12; +extern s16 D_801F6B14; +extern s16 D_801F6B16; +extern s16 D_801F6B18; +extern s16 D_801F6B1A; +extern s16 D_801F6B1C; +extern s16 D_801F6B1E; +extern s16 D_801F6B20; +extern s16 D_801F6B22; +extern MessageTableEntry D_801C6B98[]; +extern MessageTableEntry D_801CFB08[]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801477B4.s") +void func_80147520(void) { + D_801CFC98 = 0xFF; + D_801CFCA4[0] = D_801CFCA4[1] = D_801CFCA4[2] = D_801CFCA4[3] = D_801CFCA4[4] = D_801CFCA4[5] = D_801CFCA4[6] = + D_801CFCA4[7] = D_801CFCA4[8] = 0; +} + +void func_80147564(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + + msgCtx->unk1204A[0] = 0xBD; + msgCtx->unk1204A[1] = 0xB8; + msgCtx->unk1204A[2] = 0xB3; + msgCtx->unk1204A[3] = 0xAE; + msgCtx->unk1204A[4] = 0xA9; + func_80147520(); + D_801F6B0C = 0x50; + D_801F6B10 = 0x96; + D_801F6B0E = 0xFF; + D_801F6B12 = 0xA; + D_801F6B16 = 0xA; + D_801F6B14 = 0xA; + D_801F6B18 = 0xFF; + D_801F6B1C = 0xFF; + D_801F6B1A = 0x32; + D_801F6B1E = 0xA; + D_801F6B22 = 0xA; + D_801F6B20 = 0xA; +} + +s32 Message_ShouldAdvance(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Input* controller = CONTROLLER1(globalCtx); + + if ((msgCtx->unk12020 == 0x10) || (msgCtx->unk12020 == 0x11)) { + if (CHECK_BTN_ALL(controller->press.button, BTN_A)) { + play_sound(NA_SE_SY_MESSAGE_PASS); + } + return CHECK_BTN_ALL(controller->press.button, BTN_A); + } else { + if (CHECK_BTN_ALL(controller->press.button, BTN_A) || CHECK_BTN_ALL(controller->press.button, BTN_B) || + CHECK_BTN_ALL(controller->press.button, BTN_CUP)) { + play_sound(NA_SE_SY_MESSAGE_PASS); + } + return CHECK_BTN_ALL(controller->press.button, BTN_A) || CHECK_BTN_ALL(controller->press.button, BTN_B) || + CHECK_BTN_ALL(controller->press.button, BTN_CUP); + } +} + +s32 Message_ShouldAdvanceSilent(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Input* controller = CONTROLLER1(globalCtx); + + if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { + return CHECK_BTN_ALL(controller->press.button, BTN_A); + } else { + return CHECK_BTN_ALL(controller->press.button, BTN_A) || CHECK_BTN_ALL(controller->press.button, BTN_B) || + CHECK_BTN_ALL(controller->press.button, BTN_CUP); + } +} + +void func_801477B4(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + + if (globalCtx->msgCtx.unk11F10 != 0) { + msgCtx->unk12023 = 2; + msgCtx->msgMode = 0x43; + msgCtx->unk12020 = 0; + play_sound(NA_SE_PL_WALK_GROUND - SFX_FLAG); + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147818.s") @@ -16,9 +113,51 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148558.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148B98.s") +#ifdef NON_MATCHING +void func_80148B98(GlobalContext* globalCtx, u8 arg1) { + static s16 held = 0; + MessageContext* msgCtx = &globalCtx->msgCtx; + Input* curInput = CONTROLLER1(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148CBC.s") + if ((curInput->rel.stick_y > 29) && held == 0) { + held = 1; + msgCtx->choiceIndex--; + if (msgCtx->choiceIndex > 128) { + msgCtx->choiceIndex = 0; + } else { + play_sound(NA_SE_SY_CURSOR); + } + return; + } else if ((curInput->rel.stick_y < -29) && held == 0) { + held = 1; + msgCtx->choiceIndex++; + if (msgCtx->choiceIndex > arg1) { + msgCtx->choiceIndex = arg1; + } else { + play_sound(NA_SE_SY_CURSOR); + } + return; + } else { + if (ABS_ALT(curInput->rel.stick_y) < 30) { + held = 0; + } + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148B98.s") +#endif + +void func_80148CBC(GlobalContext* globalCtx, UNK_PTR puParm2, u8 arg2) { + MessageContext* msgCtx = &globalCtx->msgCtx; + + msgCtx->unk11FF4 = 0x30; + if (arg2 == 1) { + msgCtx->unk11FF6 = msgCtx->unk11FFE[1 + msgCtx->choiceIndex]; + } else { + msgCtx->unk11FF6 = msgCtx->unk11FFE[msgCtx->choiceIndex]; + } + func_80147818(globalCtx, puParm2, msgCtx->unk11FF4, msgCtx->unk11FF6); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148D64.s") @@ -34,7 +173,33 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80149C18.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80149EBC.s") +void Message_FindMessage(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Font* font = &msgCtx->font; + MessageTableEntry* msgEntry = msgCtx->messageEntryTable; + const char* segment = msgEntry->segment; + const char* foundSegment; + const char* nextSegment; + + while (msgEntry->textId != 0xFFFF) { + if (msgEntry->textId == textId) { + foundSegment = msgEntry->segment; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; + return; + } + msgEntry++; + } + + msgEntry = msgCtx->messageEntryTable; + foundSegment = msgEntry->segment; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80149F74.s") @@ -44,9 +209,43 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014C70C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014CC14.s") +void Message_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s32 temp1 = *offset; + f32 temp2 = *arg3; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014CCB4.s") + Font_LoadChar(globalCtx, codePointIndex, temp1); + msgCtx->decodedBuffer.wchar[decodedBufPos] = codePointIndex; + temp1 += FONT_CHAR_TEX_SIZE; + temp2 += (16.0f * msgCtx->unk12098); + *offset = temp1; + *arg3 = temp2; +} + +// Message_LoadRupees JPN ? +void func_8014CCB4(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 t = *decodedBufPos; + s32 k = *offset; + f32 f = *arg3; + + Font_LoadChar(globalCtx, 0x838B, k); // 0x838b = ル in JISX0213 + k += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.wchar[t] = 0x838B; + t += 1; + Font_LoadChar(globalCtx, 0x8373, k); // 0x8373 = ピ in JISX0213 + k += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.wchar[t] = 0x8373; + t += 1; + Font_LoadChar(globalCtx, 0x815C, k); // Ox815C = ― in JISX0213 + k += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.wchar[t] = 0x815C; + + f += 16.0f * msgCtx->unk12098 * 3.0f; + *decodedBufPos = t; + *offset = k; + *arg3 = f; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014CDF0.s") @@ -54,7 +253,62 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014D304.s") +#ifdef NON_EQUIVALENT +extern u16* D_801D0188; +extern s16* D_801D0250; + +void func_8014D62C(GlobalContext* arg0, s32* arg1, f32* arg2, s16* arg3) { + f32 sp3C; + s16 temp_s0; + s16 temp_s1; + s16 temp_s1_2; + s16 temp_s6; + s32 temp_s2; + s32 temp_s2_2; + u16* temp_v0; + s16 phi_v0; + s16 phi_s0; + s16 phi_s1; + s32 phi_s2; + s16 phi_s1_2; + s32 phi_s2_2; + + temp_s1 = *arg3; + temp_s2 = *arg1; + sp3C = *arg2; + if ((func_8010A0A4(arg0) != 0) || (arg0->sceneNum == 0x4F)) { + phi_v0 = 0xA; + } else { + phi_v0 = arg0->pauseCtx.unk_238[4]; + } + temp_s6 = *(&D_801D0250 + (phi_v0 * 2)); + phi_s0 = 0; + phi_s1_2 = temp_s1; + phi_s2_2 = temp_s2; + if ((s32)temp_s6 > 0) { + phi_s1 = temp_s1; + phi_s2 = temp_s2; + do { + temp_v0 = (phi_v0 * 0x12) + &D_801D0188 + (phi_s0 * 2); + (arg0 + 0x4908 + (phi_s1 * 2))->decodedBuffer = (u16)*temp_v0; + Font_LoadChar(arg0, *temp_v0, phi_s2); + temp_s0 = phi_s0 + 1; + temp_s1_2 = phi_s1 + 1; + temp_s2_2 = phi_s2 + 0x80; + phi_s0 = temp_s0; + phi_s1 = temp_s1_2; + phi_s2 = temp_s2_2; + phi_s1_2 = temp_s1_2; + phi_s2_2 = temp_s2_2; + } while ((s32)temp_s0 < (s32)temp_s6); + } + *arg3 = phi_s1_2 - 1; + *arg1 = phi_s2_2; + *arg2 = sp3C + ((f32)(temp_s6 - 1) * (16.0f * arg0->msgCtx.unk12098)); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014D62C.s") +#endif #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014D7B4.s") @@ -64,46 +318,239 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801514B0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_StartTextbox.s") +void Message_StartTextbox(GlobalContext* globalCtx, u16 textId, Actor* Actor) { + MessageContext* msgCtx = &globalCtx->msgCtx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151938.s") + msgCtx->ocarinaAction = 0xFFFF; + func_80150D08(globalCtx, textId); + msgCtx->unkActor = Actor; + msgCtx->msgMode = 1; + msgCtx->unk12023 = 0; + msgCtx->unk12024 = 0; + globalCtx->msgCtx.ocarinaMode = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151A68.s") +void func_80151938(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151BB4.s") + msgCtx->unk11F10 = 0; + func_80150D08(globalCtx, textId); + func_80150A84(globalCtx); + msgCtx->msgMode = 5; + msgCtx->unk12023 = 8; + msgCtx->unk12024 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151C9C.s") + if (interfaceCtx->unk_222 == 0) { + if (textId != 0x1B93) { + func_8011552C(globalCtx, 0x10); + } else if (textId != 0xF8) { + func_8011552C(globalCtx, 6); + } + } + msgCtx->unk1203C = msgCtx->unk1203A; + + if (globalCtx->pauseCtx.unk_1F0 != 0) { + msgCtx->unk12004 = 0x22; + msgCtx->unk12006 = 0x15E; + func_80149C18(globalCtx); + msgCtx->unk12023 = 1; + } +} + +void func_80151A68(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + + msgCtx->unk11F10 = 0; + func_80150D08(globalCtx, textId); + func_80150A84(globalCtx); + func_8015B198(globalCtx); + msgCtx->msgMode = 0x45; + msgCtx->unk12024 = 0; + msgCtx->unk1203C = msgCtx->unk1203A = msgCtx->unk1201E = 0; + msgCtx->unk12023 = 0x1E; + + // Day/Dawn/Night.. Messages + if ((msgCtx->currentTextId >= 0x1BB2) && (msgCtx->currentTextId < 0x1BB7)) { + XREG(74) = 0x6A; + XREG(75) = 0; + XREG(77) = 0x58; + XREG(76) = 0x44; + } else { + XREG(74) = 0x42; + XREG(75) = 0x1E; + XREG(77) = 0x3C; + XREG(76) = 0x1C; + msgCtx->unk11F1A[0] = msgCtx->unk11F1A[1] = msgCtx->unk11F1A[2] = 0; + Interface_ChangeAlpha(1); + } +} + +void func_80151BB4(GlobalContext* globalCtx, u8 arg1) { + MessageContext* msgCtx = &globalCtx->msgCtx; + u8 temp = arg1; + + if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { + if ((gSaveContext.weekEventReg[D_801C6B28[arg1] >> 8] & (u8)D_801C6B28[arg1]) == 0) { + msgCtx->unk120B2[msgCtx->unk120B1] = temp; + msgCtx->unk120B1++; + } + } else if (arg1 >= 20) { + if ((gSaveContext.weekEventReg[D_801C6B28[arg1] >> 8] & (u8)D_801C6B28[arg1]) == 0) { + msgCtx->unk120B2[msgCtx->unk120B1] = temp; + msgCtx->unk120B1++; + } + } +} + +u32 func_80151C9C(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + u8 flag; + + while (true) { + if (msgCtx->unk120B1 == 0) { + return 0; + } + msgCtx->unk120B1--; + + if ((gSaveContext.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] & + (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]) == 0) { + flag = gSaveContext.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8]; + gSaveContext.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] = + flag | (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]; + if ((D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]] != 0) && CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { + func_80151938(globalCtx, D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]]); + play_sound(NA_SE_SY_SCHEDULE_WRITE); + return 1; + } + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151DA4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152434.s") +void func_80152434(GlobalContext* globalCtx, u16 arg2) { + globalCtx->msgCtx.unk12046 = 0; + func_80151DA4(globalCtx, arg2); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152464.s") +void func_80152464(GlobalContext* globalCtx, u16 arg1) { + globalCtx->msgCtx.unk12046 = 1; + func_80151DA4(globalCtx, arg1); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_GetState.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8015268C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152C64.s") +void func_80152C64(View* view) { + SET_FULLSCREEN_VIEWPORT(view); + func_8013FBC8(view); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152CAC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152EC0.s") +// Spawn song effect? +void func_80152EC0(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Player* player = GET_PLAYER(globalCtx); + + if (1) {} + if ((msgCtx->songPlayed < 0x17) && (msgCtx->songPlayed != 0xE) && + ((msgCtx->ocarinaAction < 0x43) || (msgCtx->ocarinaAction >= 0x47))) { + msgCtx->unk120B0 = 1; + if (msgCtx->songPlayed != 0x16) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, D_801D02D8[msgCtx->songPlayed], player->actor.world.pos.x, + player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, D_801D02F8[msgCtx->songPlayed]); + return; + } + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OCEFF_WIPE4, player->actor.world.pos.x, + player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, 0); + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152FB8.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153750.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153E7C.s") +void func_80153E7C(GlobalContext* globalCtx, void* arg1) { + if ((gSaveContext.language == 0) && (globalCtx->msgCtx.unk12090 == 0)) { + func_8014ADBC(globalCtx, arg1); + return; + } + if (globalCtx->msgCtx.unk12090 != 0) { + func_8015E7EC(globalCtx, arg1); + return; + } + func_8015966C(globalCtx, arg1, 0); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153EF0.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801541D4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80156758.s") +void func_80156758(GlobalContext* globalCtx) { + Gfx* nextDisplayList; + Gfx* polyOpa; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + polyOpa = POLY_OPA_DISP; + nextDisplayList = Graph_GfxPlusOne(polyOpa); + gSPDisplayList(OVERLAY_DISP++, nextDisplayList); + + if ((globalCtx->msgCtx.currentTextId != 0x5E6) || (func_801690CC(globalCtx) == 0)) { + func_801541D4(globalCtx, &nextDisplayList); + } + + gSPEndDisplayList(nextDisplayList++); + Graph_BranchDlist(polyOpa, nextDisplayList); + POLY_OPA_DISP = nextDisplayList; + CLOSE_DISPS(gfxCtx); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8015680C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801586A4.s") +void func_801586A4(GlobalContext* globalCtx) { + globalCtx->msgCtx.messageEntryTableNes = D_801C6B98; + globalCtx->msgCtx.messageTableStaff = D_801CFB08; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_Init.s") +void Message_Init(GlobalContext* globalCtx) { + Font* font; + MessageContext* messageCtx = &globalCtx->msgCtx; + + func_801586A4(globalCtx); + globalCtx->msgCtx.ocarinaMode = 0; + messageCtx->msgMode = 0; + messageCtx->unk11F10 = 0; + messageCtx->currentTextId = 0; + messageCtx->unk12020 = 0; + messageCtx->choiceIndex = 0; + messageCtx->ocarinaAction = messageCtx->unk11FF2 = 0; + messageCtx->unk1201E = 0xFF; + View_Init(&messageCtx->view, globalCtx->state.gfxCtx); + messageCtx->unk11EF8 = THA_AllocEndAlign16(&globalCtx->state.heap, 0x13C00); + font = &globalCtx->msgCtx.font; + Font_LoadOrderedFont(&globalCtx->msgCtx.font); + font->unk_11D88 = 0; + messageCtx->unk12090 = messageCtx->unk12092 = 0; + messageCtx->unk12094 = 0; + messageCtx->unk1209C = 0; + messageCtx->unk120A0 = 0; + messageCtx->unk12068 = 0x34; + messageCtx->unk1206A = 0x24; + messageCtx->unk120B0 = 0; + messageCtx->unk120BE = 0; + messageCtx->unk120C0 = 0; + messageCtx->unk120C2 = 0; + messageCtx->unk120C4 = 0; + messageCtx->unk120C8 = 0; + messageCtx->unk120CA = 0; + messageCtx->unk120CC = 0; + messageCtx->unk120CE = 0; + messageCtx->unk120D0 = 0; + messageCtx->unk120D2 = 0; + messageCtx->unk120D4 = 0; + messageCtx->unk120D6 = 0; +} diff --git a/src/code/z_message_nes.c b/src/code/z_message_nes.c index 4767810fb..7a961c882 100644 --- a/src/code/z_message_nes.c +++ b/src/code/z_message_nes.c @@ -1,18 +1,280 @@ #include "global.h" +#include "message_data_static.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_801588D0.s") +#if 0 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158988.s") +//fontWidth +extern f32 D_801D0470[159]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158A24.s") +//rupeesTextLocalization +u8 D_801D06F0[4][8] = { { "rupee(s)" }, //EN + { "rubin(e)" }, //DE + { "rubis" }, //FR + { "rupia(s)" } //SPA + }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158C04.s") +// rupeesTextLength +u8 D_801D0710[4] = {8,8,5,8}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158D98.s") +//TextArea +char D_801D0714[11][16] = { + "Great Bay Coast", + "Zora Cape", + "Snowhead", + "Mountain Village", + "Clock Town", + "Milk Road", + "Woodfall", + "Southern Swamp", + "Ikana Canyon", + "Stone Tower", + "Entrance" + }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158FB0.s") +//TextAreaLength +s16 D_801D07C4[11] = {15,9,8,16,10,9,8,14,12,11,8}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_8015926C.s") +#endif + +extern f32 D_801D0470[159]; +extern u8 D_801D06F0[4][8]; +extern u8 D_801D0710[4]; +extern u8 D_801D0714[11][16]; +extern s16 D_801D07C4[11]; + +void Message_FindMessageNES(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Font* font = &msgCtx->font; + MessageTableEntry* msgEntry = msgCtx->messageEntryTableNes; + const char* segment = msgEntry->segment; + const char* foundSegment; + const char* nextSegment; + + while (msgEntry->textId != 0xFFFF) { + if (msgEntry->textId == textId) { + foundSegment = msgEntry->segment; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; + return; + } + msgEntry++; + } + + msgEntry = msgCtx->messageEntryTableNes; + foundSegment = msgEntry->segment; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; +} + +void Message_LoadCharNES(GlobalContext* globalCtx, u8 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s32 temp1 = *offset; + f32 temp2 = *arg3; + + Font_LoadCharNES(globalCtx, codePointIndex, temp1); + msgCtx->decodedBuffer.schar[decodedBufPos] = codePointIndex; + temp1 += FONT_CHAR_TEX_SIZE; + temp2 += (16.0f * msgCtx->unk12098); + *offset = temp1; + *arg3 = temp2; +} + +void Message_LoadPluralRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg3; + + msgCtx->decodedBuffer.schar[p] = 0x20; + p++; + Font_LoadCharNES(globalCtx, 'R', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'R'; + p++; + Font_LoadCharNES(globalCtx, 'u', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'u'; + p++; + Font_LoadCharNES(globalCtx, 'p', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'p'; + p++; + Font_LoadCharNES(globalCtx, 'e', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'e'; + p++; + Font_LoadCharNES(globalCtx, 'e', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'e'; + p++; + Font_LoadCharNES(globalCtx, 's', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 's'; + + f += 16.0f * msgCtx->unk12098 * 6.0f; + *decodedBufPos = p; + *offset = o; + *arg3 = f; +} + +void Message_LoadLocalizedRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg3; + u8 j; + + msgCtx->decodedBuffer.schar[p] = ' '; + p++; + + for (j = 0; j < D_801D0710[gSaveContext.language - 1]; j++) { + Font_LoadCharNES(globalCtx, D_801D06F0[gSaveContext.language - 1][j], o); + msgCtx->decodedBuffer.schar[p] = D_801D06F0[gSaveContext.language - 1][j]; + o += FONT_CHAR_TEX_SIZE; + p++; + } + + p--; + f += 16.0f * msgCtx->unk12098 * (D_801D0710[gSaveContext.language - 1] + 1); + *decodedBufPos = p; + *offset = o; + *arg3 = f; +} + +void Message_LoadRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3, s16 singular) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg3; + + msgCtx->decodedBuffer.schar[p] = ' '; + p++; + Font_LoadCharNES(globalCtx, 'R', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'R'; + p++; + Font_LoadCharNES(globalCtx, 'u', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'u'; + p++; + Font_LoadCharNES(globalCtx, 'p', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'p'; + p++; + Font_LoadCharNES(globalCtx, 'e', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'e'; + p++; + Font_LoadCharNES(globalCtx, 'e', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'e'; + + if (singular != 1) { + p++; + Font_LoadCharNES(globalCtx, 's', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 's'; + f += 16.0f * msgCtx->unk12098 * 6.0f; + } else { + f += 16.0f * msgCtx->unk12098 * 5.0f; + } + + *decodedBufPos = p; + *offset = o; + *arg3 = f; +} + +void Message_LoadTimeNES(GlobalContext* globalCtx, u8 arg1, s32* offset, f32* arg3, s16* decodedBufPos) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg3; + u32 dayTime; + s16 digits[4]; + f32 timeInMinutes; + s32 day; + s16 i; + + if (arg1 == 0xCF) { + day = gSaveContext.day; + dayTime = 0x40000 - ((day % 5) << 16) - (u16)(-0x4000 + gSaveContext.time); + } else { + dayTime = 0x10000 - (u16)(-0x4000 + gSaveContext.time); + } + timeInMinutes = TIME_TO_MINUTES_F(dayTime); + + digits[0] = 0; + digits[1] = (timeInMinutes / 60.0f); + while (digits[1] >= 10) { + digits[0]++; + digits[1] -= 10; + } + + digits[2] = 0; + digits[3] = (s32)timeInMinutes % 60; + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + for (i = 0; i < 4; i++) { + Font_LoadCharNES(globalCtx, digits[i] + '0', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = digits[i] + '0'; + p++; + if (i == 1) { + Font_LoadCharNES(globalCtx, ':', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = ':'; + p++; + } + } + + f += 5.0f * (16.0f * msgCtx->unk12098); + *decodedBufPos = p - 1; + *offset = o; + *arg3 = f; +} + +void Message_LoadAreaTextNES(GlobalContext* globalCtx, s32* offset, f32* arg2, s16* decodedBufPos) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg2; + s16 i; + u8 currentChar; + s16 currentArea; + s16 stringLimit; + + if ((func_8010A0A4(globalCtx) != 0) || (globalCtx->sceneNum == SCENE_SECOM)) { + currentArea = 10; + } else { + currentArea = globalCtx->pauseCtx.unk_238[4]; + } + stringLimit = D_801D07C4[currentArea]; + + for (i = 0; i < stringLimit; i++) { + msgCtx->decodedBuffer.schar[p] = D_801D0714[currentArea][i]; + currentChar = msgCtx->decodedBuffer.schar[p]; + if (currentChar != ' ') { + Font_LoadCharNES(globalCtx, D_801D0714[currentArea][i], o); + o += FONT_CHAR_TEX_SIZE; + } + currentChar = msgCtx->decodedBuffer.schar[p]; + p++; + f += (D_801D0470[currentChar - ' '] * msgCtx->unk12098); + } + + p--; + f += (stringLimit - 1) * (16.0f * msgCtx->unk12098); + *decodedBufPos = p; + *offset = o; + *arg2 = f; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80159438.s") diff --git a/src/code/z_message_staff.c b/src/code/z_message_staff.c index 2dd698690..6620f88d5 100644 --- a/src/code/z_message_staff.c +++ b/src/code/z_message_staff.c @@ -1,6 +1,27 @@ #include "global.h" +#include "message_data_static.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_staff/func_8015E750.s") +void Message_FindCreditsMessage(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Font* font = &msgCtx->font; + MessageTableEntry* msgEntry = msgCtx->messageTableStaff; + const char* segment = msgEntry->segment; + const char* foundSegment; + const char* nextSegment; + + while (msgEntry->textId != 0xFFFF) { + if (msgEntry->textId == textId) { + foundSegment = msgEntry->segment; + font->charBuf[font->unk_11D88][0] = msgEntry->typePos; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; + return; + } + msgEntry++; + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message_staff/func_8015E7EC.s") diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index c7e39eec6..d84003061 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -271,7 +271,7 @@ void func_80954340(BgIngate* this, GlobalContext* globalCtx) { void func_809543D4(BgIngate* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if (((talkState == 4) || (talkState == 5)) && func_80147624(globalCtx)) { + if (((talkState == 4) || (talkState == 5)) && Message_ShouldAdvance(globalCtx)) { switch (this->dyna.actor.textId) { case 0x9E4: this->dyna.actor.textId = 0x9E5; diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index b32140c83..eb1316f69 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -1566,7 +1566,7 @@ void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { } if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && - (globalCtx->msgCtx.unk11F04 == 0x5E6) && !FrameAdvance_IsEnabled(&globalCtx->state) && + (globalCtx->msgCtx.currentTextId == 0x5E6) && !FrameAdvance_IsEnabled(&globalCtx->state) && (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { time = gSaveContext.time; diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index 56f39772a..4f89b39b7 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -356,7 +356,7 @@ void func_808B93A0(DoorWarp1* this, GlobalContext* globalCtx) { s32 pad; Player* player = GET_PLAYER(globalCtx); - if (Message_GetState(&globalCtx->msgCtx) == 4 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 4 && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index 3a3e76c24..4250a71d5 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -290,7 +290,7 @@ void func_80BD3118(EnAh* this, GlobalContext* globalCtx) { s32 func_80BD3198(EnAh* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; if (player->stateFlags1 & 0x40) { if (this->unk_2DA != temp) { diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c index 7f540f3b6..cd36694cc 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -1243,7 +1243,7 @@ void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_32C & 1) { this->unk_32C &= ~0x1; globalCtx->msgCtx.msgMode = 0x43; @@ -1265,7 +1265,7 @@ void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx) { } } } else if (temp_v0 == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: this->unk_32C |= 0x8; @@ -1285,7 +1285,7 @@ void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx) { } void func_80BEF18C(EnAkindonuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_33C = 0; @@ -1310,7 +1310,7 @@ void func_80BEF20C(EnAkindonuts* this, GlobalContext* globalCtx) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 6); } - if ((sp27 == 5) && func_80147624(globalCtx)) { + if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_32C & 1) { this->unk_32C &= ~0x1; globalCtx->msgCtx.msgMode = 0x43; @@ -1341,7 +1341,7 @@ void func_80BEF360(EnAkindonuts* this, GlobalContext* globalCtx) { } void func_80BEF450(EnAkindonuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { func_800B85E0(&this->actor, globalCtx, 400.0f, -1); this->actionFunc = func_80BEF4B8; } diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index 98ba1c91f..0aef5ae40 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -559,7 +559,7 @@ void func_80BDEFE4(EnAl* this, GlobalContext* globalCtx) { s32 func_80BDF064(EnAl* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 sp22 = globalCtx->msgCtx.unk11F04; + u16 sp22 = globalCtx->msgCtx.currentTextId; Actor* sp1C = func_80BDE1A0(this, globalCtx, 4, 0xA4); Actor* temp_v0 = func_80BDE1A0(this, globalCtx, 4, 0x234); diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.c b/src/overlays/actors/ovl_En_Ani/z_en_ani.c index 00bf05461..43e9de4f0 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -175,7 +175,7 @@ void EnAni_IdleStanding(EnAni* this, GlobalContext* globalCtx) { void EnAni_Talk(EnAni* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (Message_GetState(&globalCtx->msgCtx) == 2 && globalCtx->msgCtx.unk11F04 == 0x6DE) { + if (Message_GetState(&globalCtx->msgCtx) == 2 && globalCtx->msgCtx.currentTextId == 0x6DE) { this->actionFunc = EnAni_IdleInPain; } } diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index 26cde7e4c..9fcd11517 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -433,7 +433,7 @@ void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: if (gSaveContext.rupees < 10) { @@ -457,7 +457,7 @@ void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { break; } } - } else if ((temp_v0 == 5) && func_80147624(globalCtx)) { + } else if ((temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_210 = 0; @@ -561,7 +561,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 &= ~8; } } else if (sp2F == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk_2D2 &= ~0x40; switch (globalCtx->msgCtx.choiceIndex) { case 0: @@ -577,7 +577,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { } } } else if (sp2F == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk_2D2 &= ~0x40; if (this->unk_2D2 & 0x10) { this->unk_2D2 &= ~0x10; @@ -588,7 +588,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { func_809C16DC(this, globalCtx); } } - } else if ((sp2F == 14) && func_80147624(globalCtx)) { + } else if ((sp2F == 14) && Message_ShouldAdvance(globalCtx)) { this->unk_2D2 &= ~0x40; this->unk_434 = globalCtx->msgCtx.bankRupeesSelected; func_809C16DC(this, globalCtx); @@ -749,7 +749,7 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { u8 sp2F = Message_GetState(&globalCtx->msgCtx); if (func_809C15BC(this)) { - if ((sp2F == 5) && func_80147624(globalCtx)) { + if ((sp2F == 5) && Message_ShouldAdvance(globalCtx)) { this->unk_434 = 0; globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -778,7 +778,7 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { void func_809C2BE4(EnAob01* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); - if (((temp_v0 == 5) || (temp_v0 == 6)) && func_80147624(globalCtx)) { + if (((temp_v0 == 5) || (temp_v0 == 6)) && Message_ShouldAdvance(globalCtx)) { if (gSaveContext.weekEventReg[63] & 2) { gSaveContext.weekEventReg[63] &= (u8)~2; } @@ -819,7 +819,7 @@ void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { } } - if ((sp2F == 5) && func_80147624(globalCtx)) { + if ((sp2F == 5) && Message_ShouldAdvance(globalCtx)) { this->unk_2D2 &= ~0x40; this->unk_2D2 &= ~0x80; if (this->unk_434 >= 150) { diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index 25cf5e6e4..061d7bcea 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -514,7 +514,7 @@ void func_80BA9758(EnBaba* this, GlobalContext* globalCtx) { void func_80BA9848(EnBaba* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); - if (((temp_v0 == 5) || (temp_v0 == 6)) && func_80147624(globalCtx)) { + if (((temp_v0 == 5) || (temp_v0 == 6)) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->actionFunc = func_80BA9B80; @@ -526,7 +526,7 @@ void func_80BA98EC(EnBaba* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_40A & 1) { this->unk_40A &= ~1; globalCtx->msgCtx.msgMode = 0x43; @@ -556,7 +556,7 @@ void func_80BA98EC(EnBaba* this, GlobalContext* globalCtx) { } } } else if (temp_v0 == 6) { - if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk120B1 == 0)) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.unk120B1 == 0)) { gSaveContext.weekEventReg[81] |= 2; func_80BA8C4C(globalCtx, 0xD670); } diff --git a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c index dc7bca14c..3d4c5cab5 100644 --- a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c +++ b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c @@ -196,8 +196,8 @@ void func_80BE89D8(EnBaisen* this, GlobalContext* globalCtx) { EnBaisen_ChangeAnimation(this, 0); } } - if ((globalCtx->msgCtx.unk11F04 == 0x2AC6) || (globalCtx->msgCtx.unk11F04 == 0x2AC7) || - (globalCtx->msgCtx.unk11F04 == 0x2AC8)) { + if ((globalCtx->msgCtx.currentTextId == 0x2AC6) || (globalCtx->msgCtx.currentTextId == 0x2AC7) || + (globalCtx->msgCtx.currentTextId == 0x2AC8)) { this->skelAnime.playSpeed = 0.0f; this->unk29E = this->actor.yawTowardsPlayer; } @@ -220,7 +220,7 @@ void func_80BE8AAC(EnBaisen* this, GlobalContext* globalCtx) { EnBaisen_ChangeAnimation(this, 0); } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->textIdIndex++; if (this->textIdIndex < 6) { diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 8faf1cdba..897f699d2 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -207,7 +207,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { } break; case 4: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.params = ENBJI01_PARAMS_FINISHED_CONVERSATION; switch (globalCtx->msgCtx.choiceIndex) { @@ -235,9 +235,9 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { } break; case 5: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { this->actor.flags &= ~ACTOR_FLAG_10000; - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0x5DE: SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 3, &this->animationIndex); func_80151938(globalCtx, 0x5DF); @@ -259,7 +259,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { case 0x5EE: case 0x5F2: case 0x5F5: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x5F0: case 0x5F6: diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c index 3b78fbcd1..ecaea2984 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c @@ -238,7 +238,7 @@ void func_809C4DA4(EnBomBowlMan* this, GlobalContext* globalCtx) { } } - if ((this->unk_2BC == 0) && (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((this->unk_2BC == 0) && (Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { Player* player = GET_PLAYER(globalCtx); s32 pad; s32 sp28 = false; @@ -411,7 +411,7 @@ void func_809C5524(EnBomBowlMan* this, GlobalContext* globalCtx) { } void func_809C5598(EnBomBowlMan* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if ((this->actor.textId == 0x72F) || (this->actor.textId == 0x730)) { this->actor.textId = 0x731; 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 3bedadb4b..c4fab7365 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c @@ -334,7 +334,7 @@ void func_80C03FAC(EnBombers* this, GlobalContext* globalCtx) { break; } - if ((this->unk_2A6 == Message_GetState(&globalCtx->msgCtx)) && func_80147624(globalCtx)) { + if ((this->unk_2A6 == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { sp2A = 0; func_801477B4(globalCtx); this->unk_2A6 = 5; @@ -446,7 +446,7 @@ void func_80C04354(EnBombers* this, GlobalContext* globalCtx) { void func_80C043C8(EnBombers* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x3E8, 0); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80C042F8(this); } diff --git a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c index 6f51487e8..5aacb8820 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c @@ -213,7 +213,7 @@ void func_80C04D8C(EnBombers2* this, GlobalContext* globalCtx) { default: break; } - if ((this->unk_2CE == Message_GetState(&globalCtx->msgCtx)) && (func_80147624(globalCtx) != 0)) { + if ((this->unk_2CE == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { if (this->unk_2CE == 0xF) { s32 i; s32 correctDigits; diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c index 8d9c7b848..9d1cd3970 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -581,7 +581,7 @@ void func_80BFF4F4(EnBomjima* this) { } void func_80BFF52C(EnBomjima* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex == 0) { Player* player = GET_PLAYER(globalCtx); @@ -624,7 +624,7 @@ void func_80BFF6CC(EnBomjima* this, GlobalContext* globalCtx) { f32 curFrame = this->skelAnime.curFrame; if (this->unk_2CC <= curFrame) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80BFE494(this, 1, 1.0f); this->actionFunc = func_80BFF754; @@ -729,7 +729,7 @@ void func_80BFF9B0(EnBomjima* this, GlobalContext* globalCtx) { } void func_80BFFB40(EnBomjima* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80BFE494(this, 15, 1.0f); D_80C009F0 = 100; @@ -916,7 +916,7 @@ void func_80C00284(EnBomjima* this, GlobalContext* globalCtx) { break; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { this->collider.dim.radius = 10; this->collider.dim.height = 30; if ((this->unk_2A0 == 4) || (this->unk_2CA == 1) || ((this->unk_2CA == 3) && (this->unk_2C8 >= 2))) { diff --git a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c index d4d60f2fe..6835a90fc 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -758,7 +758,7 @@ void func_80C02A14(EnBomjimb* this, GlobalContext* globalCtx) { player->actor.freezeTimer = 3; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if ((this->unk_2CA == 8) && (gSaveContext.unk_FE6 >= 5)) { func_80C02CA4(this, globalCtx); @@ -777,7 +777,7 @@ void func_80C02BCC(EnBomjimb* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 5000, 0); if (this->unk_2C0 == 0) { player->actor.freezeTimer = 3; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->unk_2C0 = 1; player->stateFlags1 &= ~0x10000000; diff --git a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c index 5b5cf5133..f5f399a65 100644 --- a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c +++ b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c @@ -138,7 +138,7 @@ void func_80AFDE00(EnColMan* this, GlobalContext* globalCtx) { } void EnColMan_SetHeartPieceCollectedAndKill(EnColMan* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { gSaveContext.weekEventReg[56] |= 2; Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index 73569c34b..13e4c8868 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -200,7 +200,7 @@ void EnCow_UpdateAnimation(EnCow* this, GlobalContext* globalCtx) { } void EnCow_TalkEnd(EnCow* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { this->actor.flags &= ~ACTOR_FLAG_10000; func_801477B4(globalCtx); this->actionFunc = EnCow_Idle; @@ -224,7 +224,7 @@ void EnCow_GiveMilkWait(EnCow* this, GlobalContext* globalCtx) { } void EnCow_GiveMilk(EnCow* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { this->actor.flags &= ~ACTOR_FLAG_10000; func_801477B4(globalCtx); this->actionFunc = EnCow_GiveMilkWait; @@ -233,7 +233,7 @@ void EnCow_GiveMilk(EnCow* this, GlobalContext* globalCtx) { } void EnCow_CheckForEmptyBottle(EnCow* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (Interface_HasEmptyBottle()) { func_80151938(globalCtx, 0x32C9); // Text to give milk. this->actionFunc = EnCow_GiveMilk; diff --git a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c index 011c0ebbd..79012db84 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -241,7 +241,7 @@ void func_80943BDC(EnDaiku* this, GlobalContext* globalCtx) { } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80943820(this); } diff --git a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c index 434e1c79f..0a1195b1a 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -292,7 +292,7 @@ void func_80BE6B40(EnDaiku2* this, GlobalContext* globalCtx) { void func_80BE6BC0(EnDaiku2* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0x0); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { s32 day = gSaveContext.day - 1; func_801477B4(globalCtx); diff --git a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c index 65aad6461..76934448a 100644 --- a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c +++ b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.c @@ -144,7 +144,7 @@ void EnDemoheishi_SetupTalk(EnDemoheishi* this) { } void EnDemoheishi_Talk(EnDemoheishi* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); EnDemoheishi_SetupIdle(this); } diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.c b/src/overlays/actors/ovl_En_Dno/z_en_dno.c index f8ff8877d..57e697380 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -381,7 +381,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { break; case 3: - if (globalCtx->msgCtx.unk11F04 == 0x80B) { + if (globalCtx->msgCtx.currentTextId == 0x80B) { switch (this->unk_32C) { case 16: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { @@ -405,7 +405,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0x80B: switch (this->unk_32C) { case 16: @@ -415,7 +415,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { break; case 9: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 10, &this->unk_32C); globalCtx->msgCtx.msgMode = 0x44; } @@ -432,13 +432,13 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { break; case 0x80C: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x80D); } break; case 0x80D: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x80E); } break; @@ -450,20 +450,20 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); } - } else if ((this->unk_32C == 13) && func_80147624(globalCtx)) { + } else if ((this->unk_32C == 13) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80A71B68(this, globalCtx); } break; case 0x80F: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x810); } break; case 0x810: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk_3B0 |= 0x20; func_801477B4(globalCtx); func_80A71B68(this, globalCtx); @@ -484,7 +484,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { break; case 0x811: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80A71B68(this, globalCtx); } @@ -572,7 +572,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { case 1: case 2: case 3: - if (((globalCtx->msgCtx.unk11F04 == 0x800) || (globalCtx->msgCtx.unk11F04 == 0x801)) && + if (((globalCtx->msgCtx.currentTextId == 0x800) || (globalCtx->msgCtx.currentTextId == 0x801)) && (this->unk_32C == 8)) { Math_SmoothStepToF(&this->unk_454, 1.0f, 1.0f, 0.1f, 0.01f); if (this->skelAnime.curFrame <= 23.0f) { @@ -596,10 +596,10 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0x800: case 0x801: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x44; this->unk_452 = 1; this->unk_454 = 0.0f; @@ -608,7 +608,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { break; case 0x802: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (INV_CONTENT(ITEM_MASK_SCENTS) == ITEM_MASK_SCENTS) { this->unk_458 = GI_RUPEE_RED; } else { @@ -621,14 +621,14 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { break; case 0x803: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80A72AE4(this, globalCtx); } break; case 0x804: if (this->unk_32C == 14) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 5, &this->unk_32C); if (!(this->unk_3B0 & 0x40)) { func_80A72CF8(this, globalCtx); @@ -642,7 +642,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { break; case 0x806: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x800); } break; diff --git a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c index f25abc6a4..d5bedf333 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -254,7 +254,7 @@ s32 func_80A52A78(EnDnq* this, GlobalContext* globalCtx) { s32 func_80A52B68(EnDnq* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; if ((player->stateFlags1 & 0x40) && (player->targetActor == &this->actor)) { switch (temp) { diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index 268e1314a..34fcedd50 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -1360,8 +1360,8 @@ void func_8088FE64(Actor* thisx, GlobalContext* globalCtx2) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { - if (globalCtx->msgCtx.unk11F04 == 0x202) { + if (Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.currentTextId == 0x202) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F230(); @@ -1375,19 +1375,19 @@ void func_8088FE64(Actor* thisx, GlobalContext* globalCtx2) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 - 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId - 1); break; case 1: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; } } break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 576: func_80151938(globalCtx, 0x245); break; diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c index 5512b00b7..d20b82865 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -434,7 +434,7 @@ void func_80B29128(EnFish2* this) { } void func_80B2913C(EnFish2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80B28B5C(this); } 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 136f109f5..9bf1643b2 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -1128,7 +1128,7 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { } if ((effect->unk_2C >= 100) && (Message_GetState(&globalCtx->msgCtx) == 5)) { - if (func_80147624(globalCtx) || Message_GetState(&globalCtx->msgCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) || Message_GetState(&globalCtx->msgCtx) == 0) { func_801477B4(globalCtx); func_801159EC(-50); effect->unk_2C = -1; @@ -3866,7 +3866,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { switch (this->unk_1CD) { case 0: if ((Message_GetState(&globalCtx->msgCtx) == 4) || Message_GetState(&globalCtx->msgCtx) == 0) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex == 0) { if (D_8090CCF0 == 0.0f) { @@ -3897,7 +3897,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { break; case 1: if ((Message_GetState(&globalCtx->msgCtx) == 4) || Message_GetState(&globalCtx->msgCtx) == 0) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex != 0) { f32 temp1 = D_8090CCF0; @@ -4723,7 +4723,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 1: - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -4751,7 +4751,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 2: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80151938(globalCtx, 0x407F); this->unk_154 = 4; @@ -4759,7 +4759,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 3: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->unk_154 = 0; } @@ -4769,7 +4769,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 4: - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -4786,7 +4786,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 5: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); globalCtx->interfaceCtx.unk_27E = 1; @@ -4803,7 +4803,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { case 10: if (D_8090CD0C != 0) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -4819,7 +4819,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { } } } else { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -4892,7 +4892,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { case 11: if (((Message_GetState(&globalCtx->msgCtx) == 5) || Message_GetState(&globalCtx->msgCtx) == 0) && - func_80147624(globalCtx)) { + Message_ShouldAdvance(globalCtx)) { s32 getItemId; func_801477B4(globalCtx); @@ -4968,14 +4968,14 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 20: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->unk_154 = 0; } break; case 21: - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -5017,7 +5017,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { case 24: D_8090CCF4 = false; - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { if (D_809171D0 == 0) { this->unk_154 = 0; } else { @@ -5354,7 +5354,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { // fallthrough case 21: - if ((D_8090CD50 == 0) && func_80147624(globalCtx)) { + if ((D_8090CD50 == 0) && Message_ShouldAdvance(globalCtx)) { D_8090CD4C = 22; D_8090CD50 = 40; // func_800B7298 call removed in MM @@ -5411,7 +5411,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { if (D_8090CD50 == 0) { if ((Message_GetState(&globalCtx->msgCtx) == 4) || Message_GetState(&globalCtx->msgCtx) == 0) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); func_801477B4(globalCtx); diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index cd4b3884f..2cef9e38e 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -209,7 +209,7 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_HandleSetupResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx) && + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx) && this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); @@ -821,7 +821,7 @@ void EnFsn_StartBuying(EnFsn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnFsn_HandleLookToShopkeeperBuyingCutscene(this); - if (talkState == 5 && func_80147624(globalCtx)) { + if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { switch (this->actor.textId) { case 0x29CC: this->actor.textId = 0x29CD; @@ -849,7 +849,7 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->actor.textId) { case 0x29CC: if (CURRENT_DAY != 3) { @@ -880,7 +880,7 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { } } else if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { + if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -953,7 +953,7 @@ void EnFsn_MakeOffer(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); - if (talkState == 4 && func_80147624(globalCtx)) { + if (talkState == 4 && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -1189,7 +1189,7 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_SetupEndInteraction(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { + if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { if (globalCtx->msgCtx.unk120B1 == 0) { EnFsn_EndInteraction(this, globalCtx); @@ -1208,7 +1208,7 @@ void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx) { if (EnFsn_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnFsn_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { + if (!EnFsn_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnFsn_HandleCanPlayerBuyItem(this, globalCtx); @@ -1223,7 +1223,7 @@ void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_PlayerCannotBuy(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); } @@ -1245,7 +1245,7 @@ void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { } } if (talkState == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -1261,7 +1261,7 @@ void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { break; } } - } else if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { + } else if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { if (globalCtx->msgCtx.unk120B1 == 0) { EnFsn_EndInteraction(this, globalCtx); @@ -1291,7 +1291,7 @@ void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx) } } if (talkState == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -1308,7 +1308,7 @@ void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx) break; } } - } else if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { + } else if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { if (globalCtx->msgCtx.unk120B1 == 0) { EnFsn_EndInteraction(this, globalCtx); @@ -1329,7 +1329,7 @@ void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx) { if (talkState == 4) { func_8011552C(globalCtx, 6); if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && - (!func_80147624(globalCtx) || !EnFsn_FacingShopkeeperDialogResult(this, globalCtx)) && + (!Message_ShouldAdvance(globalCtx) || !EnFsn_FacingShopkeeperDialogResult(this, globalCtx)) && this->stickAccumX > 0) { cursorIdx = EnFsn_SetCursorIndexFromNeutral(this); if (cursorIdx != CURSOR_INVALID) { @@ -1340,7 +1340,7 @@ void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_CURSOR); } } - } else if (talkState == 5 && func_80147624(globalCtx)) { + } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { this->actor.textId = 0x29D6; Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); if (globalCtx) {} @@ -1348,7 +1348,7 @@ void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_SetupEndInteractionImmediately(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { EnFsn_EndInteraction(this, globalCtx); } } @@ -1364,7 +1364,7 @@ void EnFsn_IdleBackroom(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_ConverseBackroom(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { if (this->flags & ENFSN_END_CONVERSATION) { this->flags &= ~ENFSN_END_CONVERSATION; globalCtx->msgCtx.msgMode = 0x43; diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index aac247546..99e32fee8 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -426,7 +426,7 @@ void func_80962340(EnFu* this, GlobalContext* globalCtx) { } void func_80962588(EnFu* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx) && (this->unk_552 == 0x2871)) { + if (Message_ShouldAdvance(globalCtx) && (this->unk_552 == 0x2871)) { if (1) {} if (globalCtx->msgCtx.choiceIndex == 0) { if (gSaveContext.rupees >= 10) { @@ -449,7 +449,7 @@ void func_80962588(EnFu* this, GlobalContext* globalCtx) { void func_80962660(EnFu* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_552) { case 0x283C: func_80963F44(this, globalCtx); @@ -596,7 +596,7 @@ void func_809628D0(EnFu* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk_54A = 1; switch (this->unk_552) { case 0x287F: @@ -842,7 +842,7 @@ void func_80963350(EnFu* this, GlobalContext* globalCtx) { static s32 D_80964C24 = 0; BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; - if ((this->unk_54A == 0) && (((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) || + if ((this->unk_54A == 0) && (((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) || ((Message_GetState(&globalCtx->msgCtx) == 2) && (globalCtx->msgCtx.unk12023 == 1)))) { func_801477B4(globalCtx); this->unk_54A = 2; @@ -1210,7 +1210,7 @@ void func_8096413C(EnFu* this, GlobalContext* globalCtx) { } void func_80964190(EnFu* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_552) { case 0x2842: case 0x2844: @@ -1262,7 +1262,7 @@ void func_80964190(EnFu* this, GlobalContext* globalCtx) { } void func_8096426C(EnFu* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_552) { case 0x2840: case 0x2841: 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 4427bd3b1..b350aa76b 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -389,7 +389,7 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_26C & 2) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -403,7 +403,7 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } } - } else if ((temp_v0 == 4) && func_80147624(globalCtx)) { + } else if ((temp_v0 == 4) && Message_ShouldAdvance(globalCtx)) { if (this->unk_26E == 0x14D5) { switch (globalCtx->msgCtx.choiceIndex) { case 0: @@ -551,7 +551,7 @@ void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_26C & 2) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -572,7 +572,7 @@ void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } } - } else if ((temp_v0 == 4) && func_80147624(globalCtx)) { + } else if ((temp_v0 == 4) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: if (gSaveContext.rupees < this->unk_288) { @@ -746,7 +746,7 @@ void func_80B10DAC(EnGb2* this, GlobalContext* globalCtx) { } void func_80B10E98(EnGb2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_26C & 2) { this->unk_26C &= ~2; globalCtx->msgCtx.msgMode = 0x43; @@ -790,7 +790,7 @@ void func_80B11048(EnGb2* this, GlobalContext* globalCtx) { } void func_80B110F8(EnGb2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_26C & 2) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; 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 60c5ebdb6..5bf1ca75e 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -542,7 +542,7 @@ void func_80BB2520(EnGeg* this, GlobalContext* globalCtx) { } void func_80BB26EC(EnGeg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { switch (this->unk_496) { case 0xD5E: this->unk_49A = this->unk_49C[1]; @@ -564,7 +564,7 @@ void func_80BB26EC(EnGeg* this, GlobalContext* globalCtx) { } void func_80BB27D4(EnGeg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { switch (this->unk_496) { case 0xD63: globalCtx->msgCtx.msgMode = 0x43; @@ -615,7 +615,7 @@ void func_80BB2944(EnGeg* this, GlobalContext* globalCtx) { this->unk_4AC = 6; func_80BB2020(this, globalCtx); } - } else if ((sp27 == 5) && func_80147624(globalCtx)) { + } else if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_496 == 0xD67) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -629,7 +629,7 @@ void func_80BB2944(EnGeg* this, GlobalContext* globalCtx) { } void func_80BB2A54(EnGeg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_496 == 0xD65) { ActorCutscene_Stop(this->unk_498); this->unk_230 &= ~0x10; 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 c9b6435f5..ab86e0161 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -247,7 +247,7 @@ void func_80B35450(EnGg* this, GlobalContext* globalCtx) { } void func_80B3556C(EnGg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_2E6 == 4) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; 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 252853a24..f3ecfd9aa 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -172,7 +172,7 @@ void func_80B3B05C(EnGg2* this, GlobalContext* globalCtx) { } void func_80B3B0A0(EnGg2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_2F0 = 0; 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 fe480fb14..5ed7ccdf3 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 @@ -103,7 +103,7 @@ void EnGinkoMan_Idle(EnGinkoMan* this, GlobalContext* globalCtx) { // action func: non-input dialogue void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { - if (!func_80147624(globalCtx)) { + if (!Message_ShouldAdvance(globalCtx)) { return; } @@ -261,7 +261,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { this->curTextId = 0x46B; // So... break; case 0x470: // "Is that so? Come back and deposit some after saving up a bunch!" - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->isStampChecked = false; EnGinkoMan_SetupIdle(this); // change to waiting for approach @@ -304,7 +304,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { // actionfunc: wait for player dialogue input void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) { - if (!func_80147624(globalCtx)) { + if (!Message_ShouldAdvance(globalCtx)) { return; } @@ -436,7 +436,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) } void EnGinkoMan_WaitForRupeeCount(EnGinkoMan* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->curTextId) { case 0x450: // "How much? How much?" [rupee prompt] Set the amount with [Control Stick] and if (globalCtx->msgCtx.bankRupeesSelected == 0) { @@ -481,7 +481,7 @@ void EnGinkoMan_Dialogue(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_DepositDialogue(this, globalCtx); break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->isStampChecked = false; EnGinkoMan_SetupIdle(this); } @@ -546,7 +546,7 @@ void EnGinkoMan_BankAward2(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_SetupDialogue(this); } else if (this->curTextId == 0x45D) { // saved up 5000 rupees for HP - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { if (!(gSaveContext.weekEventReg[59] & 8)) { gSaveContext.weekEventReg[59] |= 8; } 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 4f2d77498..5ac1c8cb3 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -662,7 +662,7 @@ void func_80B51760(EnGk* this, GlobalContext* globalCtx) { void func_80B51970(EnGk* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); - if (((temp_v0 == 6) || (temp_v0 == 5)) && func_80147624(globalCtx)) { + if (((temp_v0 == 6) || (temp_v0 == 5)) && Message_ShouldAdvance(globalCtx)) { if ((this->unk_31C == 0xE84) || (this->unk_31C == 0xE99)) { ActorCutscene_Stop(this->unk_318); this->unk_318 = ActorCutscene_GetAdditionalCutscene(this->unk_318); @@ -713,7 +713,7 @@ void func_80B51B40(EnGk* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 6) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_1E4 & 1) { this->unk_1E4 &= ~1; this->unk_1E4 &= ~4; @@ -741,7 +741,7 @@ void func_80B51B40(EnGk* this, GlobalContext* globalCtx) { this->unk_1E4 |= 2; } } - } else if ((temp_v0 == 4) && (func_80147624(globalCtx) != 0)) { + } else if ((temp_v0 == 4) && (Message_ShouldAdvance(globalCtx) != 0)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -874,7 +874,7 @@ void func_80B5202C(EnGk* this, GlobalContext* globalCtx) { } void func_80B5216C(EnGk* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->actionFunc = func_80B51698; @@ -929,7 +929,7 @@ void func_80B52340(EnGk* this, GlobalContext* globalCtx) { } void func_80B52430(EnGk* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { switch (this->unk_31C) { case 0xE93: this->unk_31C = 0xE89; 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 094de1c62..b034a5899 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -778,7 +778,7 @@ void func_8094F2E8(EnGm* this) { void func_8094F3D0(EnGm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 sp28 = Message_GetState(&globalCtx->msgCtx); - s32 var = globalCtx->msgCtx.unk11F04; + s32 var = globalCtx->msgCtx.currentTextId; if ((&this->actor == player->targetActor) && ((var < 0xFF) || (var > 0x200)) && (sp28 == 3) && (this->unk_3F0 == 3)) { @@ -807,7 +807,7 @@ s32 func_8094F4EC(EnGm* this, GlobalContext* globalCtx) { s32 func_8094F53C(EnGm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 sp32 = globalCtx->msgCtx.unk11F04; + u16 sp32 = globalCtx->msgCtx.currentTextId; Actor* al = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); Actor* toto = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TOTO); 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 00355cb45..f173e26f9 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -821,7 +821,7 @@ void func_80A12DF4(EnGo* this, GlobalContext* globalCtx) { } s32 func_80A12E80(EnGo* this, GlobalContext* globalCtx) { - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; Player* player = GET_PLAYER(globalCtx); if (ENGO_GET_F(&this->actor) != ENGO_F_4) { 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 7dc4e6968..b0a451aab 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -217,8 +217,8 @@ void func_80997E4C(EnGs* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x20D0: func_80997D14(this, globalCtx); break; 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 d1ad25092..9eef9f188 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 @@ -228,7 +228,7 @@ void func_80ABB590(EnGuardNuts* this, GlobalContext* globalCtx) { if ((this->guardTextIndex == 3) && (this->animIndex == WAIT_HEAD_TILT_ANIM)) { EnGuardNuts_ChangeAnim(this, WAIT_HEAD_TILT_ANIM); } - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { if (D_80ABBE38[this->guardTextIndex] != 1) { if (D_80ABBE38[this->guardTextIndex] == 2) { func_801477B4(globalCtx); 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 f3ba53251..5e1675583 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -207,7 +207,7 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { } } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && (Message_ShouldAdvance(globalCtx))) { func_801477B4(globalCtx); this->headZRotTarget = 0; if ((this->textIdIndex == 13) || (this->textIdIndex == 14)) { 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 d089de0da..b827e4d62 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -185,7 +185,7 @@ void EnHgo_DefaultDialogueHandler(EnHgo* this, GlobalContext* globalCtx) { func_80BD06FC(this, globalCtx); break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80BD049C(this); } } @@ -194,7 +194,7 @@ void EnHgo_DefaultDialogueHandler(EnHgo* this, GlobalContext* globalCtx) { } void func_80BD06FC(EnHgo* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_314) { case 0x158F: Message_StartTextbox(globalCtx, 0x1590, &this->actor); 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 d4f22654e..4ea774d71 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 @@ -224,7 +224,7 @@ void func_80BDB59C(EnHiddenNuts* this, GlobalContext* globalCtx) { this->unk_218 = 30; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80BDB268(this); } 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 72ab850b8..51a408e6e 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 @@ -438,7 +438,7 @@ void func_80C208D0(EnHintSkb* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80C2075C(this); } break; @@ -516,7 +516,7 @@ void func_80C20A74(EnHintSkb* this, GlobalContext* globalCtx) { } void func_80C20B88(EnHintSkb* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); this->unk_3E8 |= 0x10; @@ -531,7 +531,7 @@ void func_80C20B88(EnHintSkb* this, GlobalContext* globalCtx) { } void func_80C20C24(EnHintSkb* this, GlobalContext* globalCtx) { - if (!func_80147624(globalCtx)) { + if (!Message_ShouldAdvance(globalCtx)) { return; } 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 c43f065dc..93e62e137 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -435,7 +435,7 @@ s32 func_80BF1AE0(EnIg* this, GlobalContext* globalCtx) { s32 func_80BF1B40(EnIg* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; s32 pad; if (player->stateFlags1 & 0xC40) { 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 0bdabc6e2..39ef956d5 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -1183,7 +1183,7 @@ s32 func_808F5674(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 4: case 5: - if (func_80147624(globalCtx) && func_808F4414(globalCtx, this, arg2)) { + if (Message_ShouldAdvance(globalCtx) && func_808F4414(globalCtx, this, arg2)) { func_801477B4(globalCtx); ret = true; } @@ -1478,7 +1478,7 @@ void func_808F6334(EnIn* this, GlobalContext* globalCtx) { Matrix_InsertTranslation(this->unk4C4, 0.0f, 0.0f, MTXMODE_APPLY); if (&this->actor == player->targetActor && - !(globalCtx->msgCtx.unk11F04 >= 0xFF && globalCtx->msgCtx.unk11F04 <= 0x200) && newUnk4C8 == 3 && + !(globalCtx->msgCtx.currentTextId >= 0xFF && globalCtx->msgCtx.currentTextId <= 0x200) && newUnk4C8 == 3 && this->unk4C8 == 3) { if (!(globalCtx->state.frames & 1)) { this->unk4C0 = this->unk4C0 != 0.0f ? 0.0f : 1.0f; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 7259f258e..180483cd5 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -3402,7 +3402,7 @@ void func_80B4ADB8(EnInvadepoh* this) { } void func_80B4ADCC(EnInvadepoh* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x3331) { if (gSaveContext.weekEventReg[22] & 2) { EnInvadepoh_SetTextID(this, globalCtx, 0x3334); 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 b31436bb4..7f6d53f60 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -211,7 +211,7 @@ void func_80BC1E40(EnJa* this, GlobalContext* globalCtx) { s32 sp20 = Message_GetState(&globalCtx->msgCtx); f32 phi_f0; - if (((globalCtx->msgCtx.unk11F04 < 0xFF) || (globalCtx->msgCtx.unk11F04 > 0x200)) && (sp20 == 3) && + if (((globalCtx->msgCtx.currentTextId < 0xFF) || (globalCtx->msgCtx.currentTextId > 0x200)) && (sp20 == 3) && (this->unk_374 == 3) && (&this->actor == player->targetActor)) { if ((globalCtx->state.frames % 2) == 0) { if (this->unk_348 != 0.0f) { 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 7797f2ad4..216ce8f80 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -358,7 +358,7 @@ void EnJg_GoronShrineIdle(EnJg* this, GlobalContext* globalCtx) { } void EnJg_GoronShrineTalk(EnJg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && (Message_ShouldAdvance(globalCtx))) { if ((this->textId == 0xDCC) || (this->textId == 0xDDD) || (this->textId == 0xDE0)) { // There is nothing more to say after these lines, so end the current conversation. globalCtx->msgCtx.msgMode = 0x43; @@ -425,7 +425,7 @@ void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, GlobalContext* globalCtx) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } } else if (this->animationIndex == EN_JG_ANIMATION_SURPRISE_LOOP) { - if ((messageState == 5) && (func_80147624(globalCtx))) { + if ((messageState == 5) && (Message_ShouldAdvance(globalCtx))) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->flags &= ~FLAG_LOOKING_AT_PLAYER; @@ -480,7 +480,7 @@ void EnJg_Talk(EnJg* this, GlobalContext* globalCtx) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } - if ((messageState == 5) && (func_80147624(globalCtx))) { + if ((messageState == 5) && (Message_ShouldAdvance(globalCtx))) { temp = this->textId; if ((temp == 0xDB4) || (temp == 0xDB5) || (temp == 0xDC4) || (temp == 0xDC6)) { // There is nothing more to say after these lines, so end the current conversation. @@ -600,7 +600,7 @@ void EnJg_FrozenIdle(EnJg* this, GlobalContext* globalCtx) { } void EnJg_EndFrozenInteraction(EnJg* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx) != 0) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx) != 0) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->actionFunc = EnJg_FrozenIdle; 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 88c552595..586fe34cd 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 @@ -266,7 +266,7 @@ void func_80C14044(EnJgameTsn* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { ActorCutscene_Stop(this->actor.cutscene); } @@ -405,7 +405,7 @@ void func_80C14610(EnJgameTsn* this, GlobalContext* globalCtx) { } void func_80C14684(EnJgameTsn* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { if (gSaveContext.rupees >= 20) { Message_StartTextbox(globalCtx, 0x109E, &this->actor); @@ -436,7 +436,7 @@ void func_80C1476C(EnJgameTsn* this, GlobalContext* globalCtx) { } void func_80C147B4(EnJgameTsn* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_300) { case 0x1095: Message_StartTextbox(globalCtx, 0x1096, &this->actor); 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 d7e113cb3..648542adf 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -415,7 +415,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { this->unkState1A8 = 0; } - if (this->unkMsgState1AC == Message_GetState(&globalCtx->msgCtx) && func_80147624(globalCtx) != 0) { + if (this->unkMsgState1AC == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); if (this->unkMsgState1AC == 5) { // bad song input @@ -560,7 +560,7 @@ void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx) { * before actually teaching */ void EnKakasi_OcarinaRemark(EnKakasi* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx) != 0) { func_80152434(globalCtx, 0x35); this->unkState1A8 = 0; if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -735,7 +735,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { func_8096FAAC(this, globalCtx); if (this->unkState1A8 != 0 && Message_GetState(&globalCtx->msgCtx) == this->unkMsgState1AC && - func_80147624(globalCtx) != 0) { + Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); @@ -1101,7 +1101,7 @@ void EnKakasi_IdleRisen(EnKakasi* this, GlobalContext* globalCtx) { void EnKakasi_RisenDialogue(EnKakasi* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); EnKakasi_SetupIdleRisen(this); } 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 eee97c5f7..973e4be9c 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 @@ -212,7 +212,7 @@ void func_80B2654C(EnKendoJs* this, GlobalContext* globalCtx) { } void func_80B26758(EnKendoJs* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx) && (this->unk_288 == 0x2716)) { + if (Message_ShouldAdvance(globalCtx) && (this->unk_288 == 0x2716)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: if (CUR_EQUIP_VALUE_VOID(EQUIP_SWORD) == EQUIP_SWORD) { @@ -261,7 +261,7 @@ void func_80B26758(EnKendoJs* this, GlobalContext* globalCtx) { void func_80B269A4(EnKendoJs* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (!func_80147624(globalCtx)) { + if (!Message_ShouldAdvance(globalCtx)) { return; } @@ -325,7 +325,7 @@ void func_80B26AFC(EnKendoJs* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_288 == 0x272C) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); } @@ -503,7 +503,7 @@ void func_80B2714C(EnKendoJs* this) { void func_80B27188(EnKendoJs* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_288 == 0x2729) { func_80B26F14(this, globalCtx); } else if (!func_80B26F6C(this, globalCtx)) { 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 0099ff967..f41ab8de3 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -457,7 +457,7 @@ void func_80B4163C(EnKgy* this, GlobalContext* globalCtx) { void func_80B417B8(EnKgy* this, GlobalContext* globalCtx) { func_80B4163C(this, globalCtx); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80B413C8(this); this->actor.flags &= ~ACTOR_FLAG_100; @@ -481,8 +481,8 @@ void func_80B41858(EnKgy* this, GlobalContext* globalCtx) { void func_80B418C4(EnKgy* this, GlobalContext* globalCtx) { func_80B4163C(this, globalCtx); if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx) && - ((globalCtx->msgCtx.unk11F04 == 0xC4E) || (globalCtx->msgCtx.unk11F04 == 0xC4F))) { + (Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx) && + ((globalCtx->msgCtx.currentTextId == 0xC4E) || (globalCtx->msgCtx.currentTextId == 0xC4F))) { func_801477B4(globalCtx); this->actor.textId = 0xC4F; func_80B413C8(this); @@ -616,8 +616,8 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && func_80B40E54(this) == 0) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { - temp = globalCtx->msgCtx.unk11F04; + if (Message_ShouldAdvance(globalCtx)) { + temp = globalCtx->msgCtx.currentTextId; switch (temp) { case 0xC3B: @@ -658,8 +658,8 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - temp = globalCtx->msgCtx.unk11F04; + if (Message_ShouldAdvance(globalCtx)) { + temp = globalCtx->msgCtx.currentTextId; switch (temp) { case 0xC35: @@ -856,7 +856,7 @@ void func_80B425A0(EnKgy* this, GlobalContext* globalCtx) { void func_80B42660(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80B413C8(this); this->actor.flags &= ~ACTOR_FLAG_100; @@ -897,8 +897,8 @@ void func_80B427C8(EnKgy* this, GlobalContext* globalCtx) { } if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - temp_a2 = globalCtx->msgCtx.unk11F04; + (Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + temp_a2 = globalCtx->msgCtx.currentTextId; switch (temp_a2) { case 0xC30: @@ -969,8 +969,8 @@ void func_80B42A8C(EnKgy* this, GlobalContext* globalCtx) { } if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - temp_a2 = globalCtx->msgCtx.unk11F04; + (Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + temp_a2 = globalCtx->msgCtx.currentTextId; switch (temp_a2) { case 0xC1D: case 0xC2D: diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c index 57b441e7a..2c15b22ba 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c @@ -291,7 +291,7 @@ void EnLookNuts_SetupSendPlayerToSpawn(EnLookNuts* this) { void EnLookNuts_SendPlayerToSpawn(EnLookNuts* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); globalCtx->nextEntranceIndex = Entrance_CreateIndexFromSpawn(this->spawnIndex); gSaveContext.nextCutsceneIndex = 0; diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index b5080ec79..32c29db3f 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -357,7 +357,7 @@ void EnMa4_Wait(EnMa4* this, GlobalContext* globalCtx) { // Chooses the next dialogue based on player's selection void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (this->textId) { case 0x3339: if (globalCtx->msgCtx.choiceIndex == 0) { @@ -491,7 +491,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 aux; - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (this->textId) { case 0x2390: func_801477B4(globalCtx); @@ -643,7 +643,7 @@ void EnMa4_DialogueHandler(EnMa4* this, GlobalContext* globalCtx) { break; case 6: // End conversation - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { if ((globalCtx->msgCtx.unk120B1 == 0) || !CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { EnMa4_SetupWait(this); } diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c index 9294a6a71..60edae403 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -422,7 +422,7 @@ void EnMaYto_DefaultDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk31E = 0; EnMaYto_SetupDefaultWait(this); } @@ -443,7 +443,7 @@ void EnMaYto_DefaultDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_DefaultHandlePlayerChoice(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { // Yes func_8019F208(); EnMaYto_SetFaceExpression(this, 0, 3); @@ -460,7 +460,7 @@ void EnMaYto_DefaultHandlePlayerChoice(EnMaYto* this, GlobalContext* globalCtx) } void EnMaYto_DefaultChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x3391: EnMaYto_SetFaceExpression(this, 0, 3); @@ -554,7 +554,7 @@ void EnMaYto_DinnerDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnMaYto_SetupDinnerWait(this); } break; @@ -568,7 +568,7 @@ void EnMaYto_DinnerDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_DinnerHandlePlayerChoice(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { // Yes func_8019F208(); EnMaYto_SetFaceExpression(this, 0, 3); @@ -585,7 +585,7 @@ void EnMaYto_DinnerHandlePlayerChoice(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x3398: EnMaYto_SetFaceExpression(this, 0, 3); @@ -740,7 +740,7 @@ void EnMaYto_BarnDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk31E = 0; EnMaYto_SetupBarnWait(this); } @@ -756,7 +756,7 @@ void EnMaYto_BarnDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x33A9: func_80B90E50(this, 0); @@ -932,7 +932,7 @@ void EnMaYto_AfterMilkRunDialogueHandler(EnMaYto* this, GlobalContext* globalCtx } void EnMaYto_AfterMilkRunChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x33C1: EnMaYto_SetFaceExpression(this, 3, 1); @@ -1068,7 +1068,7 @@ void EnMaYto_SetupPostMilkRunWaitDialogueEnd(EnMaYto* this) { void EnMaYto_PostMilkRunWaitDialogueEnd(EnMaYto* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 6 || Message_GetState(&globalCtx->msgCtx) == 5) { - if (func_80147624(globalCtx) && Message_GetState(&globalCtx->msgCtx) == 5) { + if (Message_ShouldAdvance(globalCtx) && Message_GetState(&globalCtx->msgCtx) == 5) { func_800B7298(globalCtx, &this->actor, 7); func_801477B4(globalCtx); } diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c index bb88e4435..f1bd0d773 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c @@ -359,7 +359,7 @@ void EnMaYts_DialogueHandler(EnMaYts* this, GlobalContext* globalCtx) { break; case 6: // End conversation - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { EnMaYts_SetupStartDialogue(this); } break; @@ -426,7 +426,7 @@ void EnMaYts_EndCreditsHandler(EnMaYts* this, GlobalContext* globalCtx) { // Select the following dialogue based on the current one, and an appropiate face expression void EnMaYts_ChooseNextDialogue(EnMaYts* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (this->textId) { case 0x335F: EnMaYts_SetFaceExpression(this, 0, 2); diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index 806ffe71a..8b6fc45e8 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -259,16 +259,16 @@ void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, GlobalContext* globalCtx) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { EnMinifrog_SetJumpState(this); - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0xD81: // "Ah! Don Gero! It has been so long." case 0xD83: // "Could it be... Has spring finally come to the mountains?" case 0xD84: // "That look...It is true! Winter was so long that I began to lose all hope." case 0xD86: // "Could it be... You came all this way looking for me?" case 0xD87: // "Ah! You need not say a thing. Upon seeing that face, I understand!" ... - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0xD82: // "What has brought you all this way?" if (gSaveContext.weekEventReg[33] & 0x80) { // Mountain village is unfrozen @@ -496,7 +496,7 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { EnMinifrog_Jump(this); switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: // Yes func_8019F208(); @@ -511,12 +511,12 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { } break; case 5: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnMinifrog_SetJumpState(this); - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0xD76: // "I have been waiting for you, Don Gero. Forgive me if I'm mistaken, but it looks like // you've lost a little weight..." - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); this->actor.flags &= ~ACTOR_FLAG_10000; gSaveContext.weekEventReg[34] |= 1; // Spoken to MINIFROG_YELLOW break; @@ -525,7 +525,7 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { // has come to the mountains..." case 0xD7A: // "And when the great Don Gero has come for us, too...What a pity." case 0xD7F: // "Well, if it isn't the great Don Gero." - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0xD77: // "Let us begin our chorus" this->actionFunc = EnMinifrog_BeginChoirCutscene; 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 51d4243b3..062a75a12 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -162,15 +162,15 @@ void func_80959624(EnMk* this, GlobalContext* globalCtx) { void func_809596A0(EnMk* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if ((globalCtx->msgCtx.unk11F04 == 0xFB9) || (globalCtx->msgCtx.unk11F04 == 0xFBB) || - (globalCtx->msgCtx.unk11F04 == 0xFBC)) { + if ((globalCtx->msgCtx.currentTextId == 0xFB9) || (globalCtx->msgCtx.currentTextId == 0xFBB) || + (globalCtx->msgCtx.currentTextId == 0xFBC)) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x400, 0x80); this->actor.world.rot.y = this->actor.shape.rot.y; } switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->actionFunc = func_80959774; } @@ -273,14 +273,14 @@ void func_80959A24(EnMk* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0xFA1: case 0xFA3: case 0xFA4: case 0xFAA: case 0xFAE: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0xFA2: @@ -289,7 +289,7 @@ void func_80959A24(EnMk* this, GlobalContext* globalCtx) { this->actionFunc = func_80959E18; break; } - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0xFA5: diff --git a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c index 718f384f3..79b4987e9 100644 --- a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c +++ b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c @@ -49,7 +49,7 @@ void EnMm2_Reading(EnMm2* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState != 2) { - if (talkState == 5 && func_80147624(globalCtx)) { + if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->actionFunc = EnMm2_WaitForRead; } diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index fd676186e..e6024c79a 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -139,7 +139,7 @@ void func_80A6F2C8(EnMm3* this, GlobalContext* globalCtx) { } void func_80A6F3B4(EnMm3* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_2B4) { case 0x278E: if (globalCtx->msgCtx.choiceIndex == 0) { @@ -193,7 +193,7 @@ void func_80A6F3B4(EnMm3* this, GlobalContext* globalCtx) { } void func_80A6F5E4(EnMm3* this, GlobalContext* globalCtx) { - if (((this->unk_2B4 != 0x2791) || (this->unk_2AC == 0)) && func_80147624(globalCtx)) { + if (((this->unk_2B4 != 0x2791) || (this->unk_2AC == 0)) && Message_ShouldAdvance(globalCtx)) { switch (this->unk_2B4) { case 0x278A: if (func_80A6FFAC(this, globalCtx)) { @@ -332,7 +332,7 @@ void func_80A6F9DC(EnMm3* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_2B4 == 0x2790) { Player* player = GET_PLAYER(globalCtx); diff --git a/src/overlays/actors/ovl_En_Ms/z_en_ms.c b/src/overlays/actors/ovl_En_Ms/z_en_ms.c index 59aa5a22b..4497b7945 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.c @@ -99,13 +99,13 @@ void EnMs_Wait(EnMs* this, GlobalContext* globalCtx) { void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 6: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { this->actionFunc = EnMs_Wait; } break; case 5: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); Actor_PickUp(&this->actor, globalCtx, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, this->actor.playerHeightRel); @@ -114,7 +114,7 @@ void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { break; case 4: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: // yes func_801477B4(globalCtx); diff --git a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c index 9bd5b084b..2a20e8135 100644 --- a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c +++ b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c @@ -416,7 +416,7 @@ void EnMttag_RaceFinish(EnMttag* this, GlobalContext* globalCtx) { void EnMttag_PotentiallyRestartRace(EnMttag* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if (((talkState == 5 && func_80147624(globalCtx)) || talkState == 2)) { + if (((talkState == 5 && Message_ShouldAdvance(globalCtx)) || talkState == 2)) { if (this->shouldRestartRace) { globalCtx->nextEntranceIndex = 0xD010; @@ -452,7 +452,7 @@ void EnMttag_PotentiallyRestartRace(EnMttag* this, GlobalContext* globalCtx) { * responded to the Goron Elder's son's question. */ void EnMttag_HandleCantWinChoice(EnMttag* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && (func_80147624(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && (Message_ShouldAdvance(globalCtx))) { if (globalCtx->msgCtx.choiceIndex != 0) { // Exit the race func_8019F230(); diff --git a/src/overlays/actors/ovl_En_Muto/z_en_muto.c b/src/overlays/actors/ovl_En_Muto/z_en_muto.c index 0e3cbded4..b8e4750a7 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.c +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.c @@ -195,7 +195,7 @@ void EnMuto_SetupDialogue(EnMuto* this, GlobalContext* globalCtx) { void EnMuto_InDialogue(EnMuto* this, GlobalContext* globalCtx) { if (!this->isInMayorsRoom) { this->yawTowardsTarget = this->actor.yawTowardsPlayer; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (this->actor.textId == 0x62C) { @@ -226,13 +226,13 @@ void EnMuto_InDialogue(EnMuto* this, GlobalContext* globalCtx) { } } - if (globalCtx->msgCtx.unk11F04 == 0x2AC6 || globalCtx->msgCtx.unk11F04 == 0x2AC7 || - globalCtx->msgCtx.unk11F04 == 0x2AC8) { + if (globalCtx->msgCtx.currentTextId == 0x2AC6 || globalCtx->msgCtx.currentTextId == 0x2AC7 || + globalCtx->msgCtx.currentTextId == 0x2AC8) { this->skelAnime.playSpeed = 0.0f; this->yawTowardsTarget = this->actor.yawTowardsPlayer; this->skelAnime.curFrame = 30.0f; } - if (globalCtx->msgCtx.unk11F04 == 0x2ACF) { + if (globalCtx->msgCtx.currentTextId == 0x2ACF) { this->skelAnime.playSpeed = 0.0f; } diff --git a/src/overlays/actors/ovl_En_Osk/z_en_osk.c b/src/overlays/actors/ovl_En_Osk/z_en_osk.c index 62771a433..30d9a1666 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.c +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.c @@ -169,7 +169,7 @@ void func_80BF5F70(EnOsk* this) { void func_80BF609C(EnOsk* this, GlobalContext* globalCtx) { if (this->actor.draw != NULL) { if (this->actor.home.rot.z != 0) { - if (globalCtx->msgCtx.unk11F04 == 0x1531) { + if (globalCtx->msgCtx.currentTextId == 0x1531) { this->actor.home.rot.z = 0; } } else { diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.c b/src/overlays/actors/ovl_En_Osn/z_en_osn.c index 620d4450a..f53912c4d 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -746,7 +746,7 @@ void func_80AD16A8(EnOsn* this, GlobalContext* globalCtx) { void func_80AD19A0(EnOsn* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); - if ((temp_v0 == 6 || temp_v0 == 5) && func_80147624(globalCtx)) { + if ((temp_v0 == 6 || temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_1EA & 0x20) { this->unk_1EA &= ~0x20; globalCtx->msgCtx.msgMode = 0x43; @@ -894,7 +894,7 @@ void EnOsn_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_1FA == 0xFF) { func_8012C28C(globalCtx->state.gfxCtx); if ((this->unk_1EC == 0xB) || (this->unk_1EC == 0xC) || (this->unk_1EC == 0x17) || - (globalCtx->msgCtx.unk11F04 == 0x1FCA)) { + (globalCtx->msgCtx.currentTextId == 0x1FCA)) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD258C)); gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2594)); } else if ((this->unk_1EC == 7) || (this->unk_1EC == 3) || (this->unk_1EC == 0xD)) { diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index 13c9ee276..625e9674f 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -563,7 +563,7 @@ void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnOssan_RotateHead(this, globalCtx); - if (talkState == 5 && func_80147624(globalCtx)) { + if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { if ((this->animationIndex == ANI_ANIMATION_APOLOGY_LOOP) && (this->actor.params == ENOSSAN_PART_TIME_WORKER)) { this->animationIndex = ANI_ANIMATION_STANDING_NORMAL_LOOP_2; SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); @@ -581,7 +581,7 @@ void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { } } if ((talkState == 10) && (this->actor.params == ENOSSAN_PART_TIME_WORKER) && - (player->transformation == PLAYER_FORM_ZORA) && func_80147624(globalCtx)) { + (player->transformation == PLAYER_FORM_ZORA) && Message_ShouldAdvance(globalCtx)) { this->animationIndex = ANI_ANIMATION_APOLOGY_LOOP; SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, ANI_ANIMATION_APOLOGY_LOOP); } @@ -632,7 +632,7 @@ void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { if (talkState == 4) { func_8011552C(globalCtx, 6); if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && - (!func_80147624(globalCtx) || !EnOssan_FacingShopkeeperDialogResult(this, globalCtx))) { + (!Message_ShouldAdvance(globalCtx) || !EnOssan_FacingShopkeeperDialogResult(this, globalCtx))) { if (this->stickAccumX < 0) { cursorIdx = EnOssan_SetCursorIndexFromNeutral(this, 4); if (cursorIdx != CURSOR_INVALID) { @@ -665,7 +665,7 @@ void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { void EnOssan_TalkToShopkeeper(EnOssan* this, GlobalContext* globalCtx) { AnimationInfoS* animations = sAnimations[this->actor.params]; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { if ((this->animationIndex == ANI_ANIMATION_APOLOGY_LOOP) && (this->actor.params == ENOSSAN_PART_TIME_WORKER)) { this->animationIndex = ANI_ANIMATION_STANDING_NORMAL_LOOP_2; SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); @@ -1053,7 +1053,7 @@ void EnOssan_SelectItem(EnOssan* this, GlobalContext* globalCtx) { if (EnOssan_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnOssan_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { + if (!EnOssan_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnOssan_HandleCanBuyItem(globalCtx, this); @@ -1069,7 +1069,7 @@ void EnOssan_SelectItem(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_CannotBuy(EnOssan* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); } @@ -1078,7 +1078,7 @@ void EnOssan_CannotBuy(EnOssan* this, GlobalContext* globalCtx) { void EnOssan_CanBuy(EnOssan* this, GlobalContext* globalCtx) { EnGirlA* item; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; @@ -1098,7 +1098,7 @@ void EnOssan_BuyItemWithFanfare(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_SetupItemPurchased(EnOssan* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; EnOssan_SetupAction(this, EnOssan_ItemPurchased); @@ -1120,7 +1120,7 @@ void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); @@ -1142,7 +1142,7 @@ void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { } } } - } else if (talkState == 5 && func_80147624(globalCtx)) { + } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index f81a2f40d..229f1d661 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -663,7 +663,7 @@ void func_80B5CD40(EnOt* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1069)) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1069)) { this->unk_32C |= 4; ActorCutscene_Stop(this->cutscenes[0]); player->stateFlags2 &= ~0x20000000; @@ -786,8 +786,8 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { default: case 0x1068: case 0x106B: diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index f7eb61490..5a020ef5e 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -324,7 +324,7 @@ void func_8095ACEC(EnOwl* this) { } void func_8095AD54(EnOwl* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case OWL_REPEAT: func_80151938(globalCtx, 0x7D1); @@ -340,14 +340,14 @@ void func_8095AD54(EnOwl* this, GlobalContext* globalCtx) { } void func_8095AE00(EnOwl* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x7D2); this->actionFunc = func_8095AD54; } } void func_8095AE60(EnOwl* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x7D1); this->actionFunc = func_8095AE00; } @@ -364,13 +364,13 @@ void func_8095AEC0(EnOwl* this, GlobalContext* globalCtx) { void func_8095AF2C(EnOwl* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { - if (globalCtx->msgCtx.unk11F04 == 0xBFE) { + if (Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.currentTextId == 0xBFE) { func_8095ACEC(this); func_801477B4(globalCtx); this->actionFunc = func_8095ABF0; } else { - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); } } break; @@ -607,8 +607,8 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0xBEC: switch (globalCtx->msgCtx.choiceIndex) { case 0: @@ -646,8 +646,8 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0xBEA: gSaveContext.weekEventReg[9] |= 0x20; func_80151938(globalCtx, 0xBEB); diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index 467ef3901..ae14fa125 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -639,7 +639,7 @@ void EnPamera_HandleDialogue(EnPamera* this, GlobalContext* globalCtx) { func_80BD9B4C(this, globalCtx); break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80BD9938(this); } break; @@ -651,7 +651,7 @@ void EnPamera_HandleDialogue(EnPamera* this, GlobalContext* globalCtx) { } void func_80BD9B4C(EnPamera* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_324) { case 0x1587: Message_StartTextbox(globalCtx, 0x1588, &this->actor); diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 7792e578f..0ff811a39 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -839,7 +839,7 @@ void func_80AF8BA8(s32 arg0) { void func_80AF8C68(EnPm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 sp28 = Message_GetState(&globalCtx->msgCtx); - u16 temp_a0 = globalCtx->msgCtx.unk11F04; + u16 temp_a0 = globalCtx->msgCtx.currentTextId; if ((player->targetActor == &this->actor) && ((temp_a0 < 255) || (temp_a0 > 512)) && (sp28 == 3) && (this->unk_388 == 3)) { @@ -873,7 +873,7 @@ s32 func_80AF8D84(EnPm* this, GlobalContext* globalCtx) { s32 func_80AF8DD4(EnPm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; s32 pad; if (player->stateFlags1 & (0x400 | 0x40)) { diff --git a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c index 1bb913ebd..e1971c182 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c @@ -534,7 +534,7 @@ void func_80B717E0(EnRailSkb* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80B71650(this); } break; @@ -700,7 +700,7 @@ void func_80B71F3C(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_3F2 = 1; } - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_400) { case 0x13EC: Message_StartTextbox(globalCtx, 0x13ED, &this->actor); @@ -753,7 +753,7 @@ void func_80B71F3C(EnRailSkb* this, GlobalContext* globalCtx) { } void func_80B72100(EnRailSkb* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); Message_StartTextbox(globalCtx, 0x13F1, &this->actor); 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 e1266fbca..b1c6b76cb 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -968,14 +968,14 @@ void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, GlobalContext* global } else { switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { Message_StartTextbox(globalCtx, 0x13B3, &this->actor); this->textId = 0x13B3; } break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->textId = 0; this->isInvincible = false; this->actor.speedXZ = 0.6f; diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c index 226cc821d..30449a3b4 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -144,7 +144,7 @@ void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx) { if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; // hear directions again? EnRecepgirl_SetupWait(this); - } else if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { + } else if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { // "Welcome..." Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c index 823cf9c05..bbe21471c 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -315,7 +315,7 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_328 & 1) { this->unk_328 &= ~1; globalCtx->msgCtx.msgMode = 0x43; @@ -331,7 +331,7 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { } } } else if (temp_v0 == 4) { - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: if (gSaveContext.rupees < this->unk_358) { diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c index a35715170..e1f52ceed 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -438,7 +438,7 @@ void func_80ADB924(EnSellnuts* this, GlobalContext* globalCtx) { func_80151938(globalCtx, this->unk_340); this->actionFunc = func_80ADB0D8; } - } else if ((msgState == 5) && func_80147624(globalCtx)) { + } else if ((msgState == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_340 == D_80ADD910[this->unk_33A]) { this->unk_340 = D_80ADD938[this->unk_33A]; func_80151938(globalCtx, this->unk_340); @@ -468,7 +468,7 @@ void func_80ADBAB8(EnSellnuts* this, GlobalContext* globalCtx) { SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 6); } - if ((sp27 == 5) && func_80147624(globalCtx)) { + if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->actionFunc = func_80ADBBEC; @@ -497,7 +497,7 @@ void func_80ADBC60(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADBCE4(EnSellnuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); this->unk_340 = D_80ADD930[this->unk_33A]; this->actionFunc = func_80ADBC60; @@ -514,7 +514,7 @@ void func_80ADBD64(EnSellnuts* this, GlobalContext* globalCtx) { SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); } - if ((sp27 == 5) && func_80147624(globalCtx)) { + if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_338 &= ~2; @@ -556,7 +556,7 @@ void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADBFA0(EnSellnuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; if (this->unk_34C == 0) { @@ -719,7 +719,7 @@ void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADC6D0(EnSellnuts* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; if (player->transformation == PLAYER_FORM_DEKU) { @@ -749,7 +749,7 @@ void func_80ADC7B4(EnSellnuts* this, GlobalContext* globalCtx) { } ActorCutscene_SetIntentToPlay(this->cutscene); } - } else if ((this->unk_366 == 1) && (temp == 5) && func_80147624(globalCtx)) { + } else if ((this->unk_366 == 1) && (temp == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_366 = 0; diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.c b/src/overlays/actors/ovl_En_Shn/z_en_shn.c index 6d886fad3..d1bc0f8ba 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.c +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.c @@ -186,8 +186,8 @@ void func_80AE6488(EnShn* this, GlobalContext* globalCtx) { this->unk_2D4 = CLAMP(this->unk_2D4, 0.0f, 80.0f); Matrix_InsertTranslation(this->unk_2D4, 0.0f, 0.0f, 1); if ((&this->actor == player->targetActor) && - ((globalCtx->msgCtx.unk11F04 < 0xFF) || (globalCtx->msgCtx.unk11F04 >= 0x201)) && (tempMsgState == 3) && - (this->msgState == 3)) { + ((globalCtx->msgCtx.currentTextId < 0xFF) || (globalCtx->msgCtx.currentTextId >= 0x201)) && + (tempMsgState == 3) && (this->msgState == 3)) { if (globalCtx->state.frames % 2 == 0) { if (this->unk_2D0 != 0.0f) { this->unk_2D0 = 0.0f; @@ -203,7 +203,7 @@ void func_80AE6488(EnShn* this, GlobalContext* globalCtx) { s32 func_80AE65F4(EnShn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; if (player->stateFlags1 & 0x40) { if (this->unk_1DA != temp) { diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index 5a891cb64..8a0e4f02c 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -372,7 +372,7 @@ void func_80995190(EnSkb* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { Message_StartTextbox(globalCtx, 0x13F7, &this->actor); if (this->unk_3DE == 2) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); @@ -381,7 +381,7 @@ void func_80995190(EnSkb* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->actionFunc = func_80995244; } break; diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index 7d63609c1..e344a574d 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -503,7 +503,7 @@ void EnSob1_SetupLookToShopkeeperFromShelf(GlobalContext* globalCtx, EnSob1* thi } void EnSob1_EndingInteraction(EnSob1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { EnSob1_EndInteraction(globalCtx, this); } } @@ -607,7 +607,7 @@ void EnSob1_Hello(EnSob1* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if ((talkState == 5) && (func_80147624(globalCtx)) && + if ((talkState == 5) && (Message_ShouldAdvance(globalCtx)) && (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)))) { if (this->welcomeTextId == 0x68A) { // Welcome text when wearing Kafei's mask EnSob1_EndInteraction(globalCtx, this); @@ -659,7 +659,7 @@ void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { if (talkState == 4) { func_8011552C(globalCtx, 6); if (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { - if (!func_80147624(globalCtx) || !EnSob1_FacingShopkeeperDialogResult(this, globalCtx)) { + if (!Message_ShouldAdvance(globalCtx) || !EnSob1_FacingShopkeeperDialogResult(this, globalCtx)) { if (this->stickAccumX > 0) { cursorIdx = EnSob1_SetCursorIndexFromNeutral(this, 2); if (cursorIdx != CURSOR_INVALID) { @@ -677,7 +677,7 @@ void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_TalkingToShopkeeper(EnSob1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { EnSob1_StartShopping(globalCtx, this); } } @@ -1020,7 +1020,7 @@ void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx) { if (EnSob1_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnSob1_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { + if (!EnSob1_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnSob1_HandleCanBuyItem(globalCtx, this); @@ -1037,7 +1037,7 @@ void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_CannotBuy(EnSob1* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); } @@ -1047,7 +1047,7 @@ void EnSob1_CannotBuy(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_CanBuy(EnSob1* this, GlobalContext* globalCtx) { EnGirlA* item; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnSob1_ResetItemPosition(this); item = this->items[this->cursorIdx]; @@ -1067,7 +1067,7 @@ void EnSob1_BuyItemWithFanfare(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_SetupItemPurchased(EnSob1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; EnSob1_SetupAction(this, EnSob1_ItemPurchased); @@ -1086,7 +1086,7 @@ void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnGirlA* item; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && (Message_ShouldAdvance(globalCtx))) { EnSob1_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); 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 4c0983545..c73c934d0 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -683,8 +683,8 @@ void EnSsh_Wait(EnSsh* this, GlobalContext* globalCtx) { void EnSsh_Talk(EnSsh* this, GlobalContext* globalCtx) { EnSsh_Bob(this, globalCtx); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x904: case 0x905: case 0x906: @@ -693,7 +693,7 @@ void EnSsh_Talk(EnSsh* this, GlobalContext* globalCtx) { case 0x911: case 0x912: case 0x914: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; default: diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index 746c0e92d..774dcf40e 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -200,7 +200,7 @@ void func_80B67148(EnSth* this, GlobalContext* globalCtx) { void func_80B671A0(EnSth* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { this->actionFunc = func_80B67208; func_801477B4(globalCtx); } @@ -313,10 +313,10 @@ void func_80B67540(EnSth* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1134: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1132: @@ -403,7 +403,7 @@ void func_80B677BC(EnSth* this, GlobalContext* globalCtx) { void func_80B67838(EnSth* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { this->actionFunc = func_80B678A8; func_801477B4(globalCtx); } @@ -494,17 +494,17 @@ void func_80B67C1C(EnSth* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x90C: func_80B670A4(this, 2); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x916: case 0x919: func_80B670A4(this, 3); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x8FC: @@ -512,7 +512,7 @@ void func_80B67C1C(EnSth* this, GlobalContext* globalCtx) { case 0x900: case 0x90A: case 0x90D: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x901: diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 1ef192571..5935aa2c1 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -1111,7 +1111,7 @@ void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAD130(EnSuttari* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { + if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; if (this->flags1 & 8) { @@ -1142,7 +1142,7 @@ void func_80BAD230(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD2B4(EnSuttari* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x2A30) { ActorCutscene_Stop(this->cutscenes[0]); ActorCutscene_SetIntentToPlay(this->cutscenes[1]); @@ -1162,13 +1162,13 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); - if ((player->stateFlags1 & 0x40) && (globalCtx->msgCtx.unk11F04 != 0x2A31)) { + if ((player->stateFlags1 & 0x40) && (globalCtx->msgCtx.currentTextId != 0x2A31)) { this->flags1 |= 0x8000; this->actor.speedXZ = 0.0f; } else { this->flags1 &= ~0x8000; func_80BABA90(this, 1, 1); - if ((this->flags1 & 0x4000) && (talkState == 5) && func_80147624(globalCtx)) { + if ((this->flags1 & 0x4000) && (talkState == 5) && Message_ShouldAdvance(globalCtx)) { this->flags2 &= ~0x10; player->stateFlags1 &= ~0x10000000; this->flags1 &= ~0x4000; @@ -1306,7 +1306,7 @@ void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } if (talkstate == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->flags1 & 0x400) { if (this->textId == 0x29EE) { ActorCutscene_Stop(this->cutscenes[this->cutsceneIdx]); @@ -1328,7 +1328,7 @@ void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { } func_80BAAB78(this, globalCtx); } - } else if ((talkstate == 4) && func_80147624(globalCtx)) { + } else if ((talkstate == 4) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index ae1f01934..36030a12d 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -252,7 +252,7 @@ void func_809C6848(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { if (!CUR_UPG_VALUE(UPG_QUIVER)) { play_sound(NA_SE_SY_ERROR); @@ -309,7 +309,7 @@ void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C6C2C(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_284) { case 0xA28: case 0xA29: @@ -387,7 +387,7 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; player->stateFlags1 &= ~0x20; @@ -519,7 +519,7 @@ void func_809C72D8(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { if (!CUR_UPG_VALUE(UPG_QUIVER)) { play_sound(NA_SE_SY_ERROR); @@ -582,7 +582,7 @@ void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_284) { case 0x3E8: case 0x3E9: @@ -721,7 +721,7 @@ void func_809C7990(EnSyatekiMan* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { gSaveContext.weekEventReg[63] &= (u8)~1; gSaveContext.weekEventReg[63] &= (u8)~2; player->stateFlags1 &= ~0x20; @@ -832,7 +832,7 @@ void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (CURRENT_DAY != 3) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { player->stateFlags1 &= ~0x20; this->unk_280 = 0; this->unk_26A = 0; diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index a22faeb59..a3b31b93f 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -256,7 +256,7 @@ void func_80BE0A98(EnTab* this, GlobalContext* globalCtx) { Matrix_InsertTranslation(this->unk_308, 0.0f, 0.0f, MTXMODE_APPLY); if ((&this->actor == player->targetActor) && - ((globalCtx->msgCtx.unk11F04 < 0xFF) || (globalCtx->msgCtx.unk11F04 > 0x200)) && (sp20 == 3) && + ((globalCtx->msgCtx.currentTextId < 0xFF) || (globalCtx->msgCtx.currentTextId > 0x200)) && (sp20 == 3) && (this->unk_334 == 3)) { if ((globalCtx->state.frames % 2) == 0) { if (this->unk_304 != 0.0f) { @@ -415,8 +415,8 @@ s32 func_80BE10BC(EnTab* this, GlobalContext* globalCtx) { switch (this->unk_1D8) { case 1: - if ((player->stateFlags1 & 0x40) && !(globalCtx->msgCtx.unk11F04 <= 0x2B00) && - (globalCtx->msgCtx.unk11F04 < 0x2B08)) { + if ((player->stateFlags1 & 0x40) && !(globalCtx->msgCtx.currentTextId <= 0x2B00) && + (globalCtx->msgCtx.currentTextId < 0x2B08)) { this->actor.child = &this->unk_1E4->actor; this->unk_2FC |= 8; } else { diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c index 52fc6115c..2f7b5c5c6 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c @@ -678,7 +678,7 @@ void EnTalkGibud_GetTextIdForRequestedItem(EnTalkGibud* this, GlobalContext* glo } void EnTalkGibud_GetNextTextBoxId(EnTalkGibud* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x1388: EnTalkGibud_GetTextIdForRequestedItem(this, globalCtx); @@ -814,7 +814,7 @@ void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x138A) { // Remove the requested item/amount from the player's inventory requestedItem = &sRequestedItemTable[this->requestedItemIndex]; diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 32e4c9c81..60488183e 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -579,8 +579,8 @@ void func_80AED610(EnTk* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x13FD: this->unk_2CA |= 0x10; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); @@ -828,8 +828,8 @@ void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1404: this->unk_2CA |= 0x1000; func_80AED898(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index 9334180cd..d446fd9d3 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -207,7 +207,7 @@ void EnToto_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80BA383C(EnToto* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime) && this->actionFuncIndex == 1 && this->skelAnime.animation != &object_zm_Anim_000C80) { - if (globalCtx->msgCtx.unk11F04 != 0x2A98 && globalCtx->msgCtx.unk11F04 != 0x2A99) { + if (globalCtx->msgCtx.currentTextId != 0x2A98 && globalCtx->msgCtx.currentTextId != 0x2A99) { if (this->unk2B4 & 1 || Rand_ZeroOne() > 0.5f) { this->unk2B4 = (this->unk2B4 + 1) & 3; } @@ -408,7 +408,7 @@ s32 func_80BA407C(EnToto* this, GlobalContext* globalCtx) { } s32 func_80BA40D4(EnToto* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { return 1; } return 0; @@ -422,7 +422,7 @@ s32 func_80BA4128(EnToto* this, GlobalContext* globalCtx) { } s32 func_80BA415C(EnToto* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 4 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 4 && Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex != 0) { func_8019F230(); } else { diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.c b/src/overlays/actors/ovl_En_Trt/z_en_trt.c index b0b793211..13a3d20cb 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -312,7 +312,7 @@ void EnTrt_Hello(EnTrt* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (talkState == 5 && func_80147624(globalCtx)) { + if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { play_sound(NA_SE_SY_MESSAGE_PASS); if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { EnTrt_StartShopping(globalCtx, this); @@ -330,7 +330,7 @@ void EnTrt_GetMushroom(EnTrt* this, GlobalContext* globalCtx) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { player->stateFlags2 &= ~0x20000000; } - } else if (talkState == 5 && func_80147624(globalCtx)) { + } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x883: this->textId = 0x884; @@ -370,7 +370,7 @@ void EnTrt_PayForMushroom(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_Goodbye(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x886: this->textId = 0x887; @@ -385,7 +385,7 @@ void EnTrt_Goodbye(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x88F) { if (Interface_HasEmptyBottle() || !(gSaveContext.weekEventReg[12] & 0x10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { @@ -450,7 +450,7 @@ void EnTrt_GivenRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { //! @bug: player is set to NULL not PLAYER Player* player = NULL; - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); @@ -475,11 +475,11 @@ void EnTrt_EndConversation(EnTrt* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnTrt_EndInteraction(globalCtx, this); } } else if (talkState == 6) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnTrt_EndInteraction(globalCtx, this); } } @@ -521,7 +521,7 @@ void EnTrt_FaceShopkeeper(EnTrt* this, GlobalContext* globalCtx) { } else if (talkState == 4) { func_8011552C(globalCtx, 6); if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { - if ((!func_80147624(globalCtx) || !EnTrt_FacingShopkeeperDialogResult(this, globalCtx)) && + if ((!Message_ShouldAdvance(globalCtx) || !EnTrt_FacingShopkeeperDialogResult(this, globalCtx)) && (this->stickAccumX > 0)) { cursorIdx = EnTrt_SetCursorIndexFromNeutral(this, 2); if (cursorIdx != CURSOR_INVALID) { @@ -707,7 +707,7 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { if (EnTrt_TakeItemOffShelf(this)) { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnTrt_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { + if (!EnTrt_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnTrt_HandleCanBuyItem(globalCtx, this); @@ -719,7 +719,7 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { break; } } - } else if (talkState == 5 && func_80147624(globalCtx)) { + } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { if (!Interface_HasEmptyBottle()) { play_sound(NA_SE_SY_ERROR); EnTrt_SetupCannotBuy(globalCtx, this, 0x846); @@ -930,7 +930,7 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCt u8 talkState = Message_GetState(&globalCtx->msgCtx); this->blinkFunc = EnTrt_Blink; - if (talkState == 6 && func_80147624(globalCtx)) { + if (talkState == 6 && Message_ShouldAdvance(globalCtx)) { if (Interface_HasEmptyBottle() || !(gSaveContext.weekEventReg[12] & 0x10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); @@ -948,7 +948,7 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCt } void EnTrt_TryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x83C) { if (Interface_HasEmptyBottle()) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { @@ -1015,7 +1015,7 @@ void EnTrt_ItemGiven(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_SetupEndInteraction(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { EnTrt_EndInteraction(globalCtx, this); } } @@ -1032,7 +1032,7 @@ void EnTrt_ShopkeeperGone(EnTrt* this, GlobalContext* globalCtx) { func_800B8614(&this->actor, globalCtx, 200.0f); } } - if (talkState == 6 && func_80147624(globalCtx)) { + if (talkState == 6 && Message_ShouldAdvance(globalCtx)) { if (gSaveContext.weekEventReg[20] & 2) { globalCtx->nextEntranceIndex = 0xC50; } else { @@ -1045,7 +1045,7 @@ void EnTrt_ShopkeeperGone(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_CannotBuy(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, EnTrt_GetItemTextId(this)); } @@ -1054,7 +1054,7 @@ void EnTrt_CannotBuy(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_CanBuy(EnTrt* this, GlobalContext* globalCtx) { EnGirlA* item; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; @@ -1074,7 +1074,7 @@ void EnTrt_BuyItemWithFanfare(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_SetupItemGiven(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { this->actionFunc = EnTrt_ItemGiven; if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -1094,7 +1094,7 @@ void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx) { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); @@ -1117,7 +1117,7 @@ void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx) { } } } else if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); @@ -1362,7 +1362,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { s32 itemGiven; if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->talkOptionTextId == 0x845 || this->talkOptionTextId == 0x882) { func_80151938(globalCtx, 0xFF); } else { diff --git a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c index 9560ea842..f8de547cd 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -332,7 +332,7 @@ void func_80AD3CEC(EnTrt2* this, GlobalContext* globalCtx) { if (this->unk_3D8) { Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); this->unk_3D8 = false; - } else if ((sp27 == 5) && func_80147624(globalCtx)) { + } else if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; func_80AD3380(&this->skelAnime, sAnimations, 6); @@ -359,7 +359,7 @@ void func_80AD3DA4(EnTrt2* this, GlobalContext* globalCtx) { } void func_80AD3E34(EnTrt2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (Interface_HasEmptyBottle()) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -377,7 +377,7 @@ void func_80AD3EF0(EnTrt2* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 6) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if ((Interface_HasEmptyBottle() && !(gSaveContext.weekEventReg[84] & 0x40)) || !(gSaveContext.weekEventReg[12] & 0x10)) { this->unk_3B2 = 12; @@ -388,7 +388,7 @@ void func_80AD3EF0(EnTrt2* this, GlobalContext* globalCtx) { this->unk_3B2 = 10; } } - } else if ((temp_v0 == 5) && func_80147624(globalCtx)) { + } else if ((temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_3B2 = 12; @@ -411,7 +411,7 @@ void func_80AD3FF4(EnTrt2* this, GlobalContext* globalCtx) { } void func_80AD40AC(EnTrt2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { func_800B85E0(&this->actor, globalCtx, 400.0f, -1); this->unk_3B2 = 13; } @@ -428,7 +428,7 @@ void func_80AD4110(EnTrt2* this, GlobalContext* globalCtx) { } void func_80AD417C(EnTrt2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_3A8 == 0x84B) { func_80AD349C(this); func_80AD3DA4(this, globalCtx); @@ -514,7 +514,7 @@ void func_80AD4550(EnTrt2* this, GlobalContext* globalCtx) { this->unk_3B2 = 17; } - if ((sp23 == 5) && func_80147624(globalCtx)) { + if ((sp23 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; } diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index 31f87f603..41d40649b 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -821,7 +821,7 @@ s32 func_80A8777C(Actor* thisx, GlobalContext* globalCtx) { case 4: case 5: - if (!func_80147624(globalCtx)) { + if (!Message_ShouldAdvance(globalCtx)) { break; } } diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c index c70e8264f..4425e7f87 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c @@ -371,7 +371,7 @@ void func_80B76A64(EnTruMt* this, GlobalContext* globalCtx) { void func_80B76BB8(EnTruMt* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { globalCtx->nextEntranceIndex = 0xA810; globalCtx->unk_1887F = 3; gSaveContext.nextTransition = 3; diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c index 5f0309fbb..e3d6831b6 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c @@ -175,7 +175,7 @@ void func_80ADFF84(EnTsn* this, GlobalContext* globalCtx) { } void func_80AE0010(EnTsn* this, GlobalContext* globalCtx) { - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0x107F: case 0x1080: case 0x1081: @@ -193,15 +193,15 @@ void func_80AE0010(EnTsn* this, GlobalContext* globalCtx) { break; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x107F: case 0x1081: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1080: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_001198, -10.0f); break; @@ -221,13 +221,13 @@ void func_80AE0010(EnTsn* this, GlobalContext* globalCtx) { break; case 0x1084: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_000964, -10.0f); break; case 0x1085: case 0x1086: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1089: @@ -241,7 +241,7 @@ void func_80AE0010(EnTsn* this, GlobalContext* globalCtx) { case 0x1087: Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_001198, -10.0f); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1088: @@ -375,7 +375,7 @@ void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad[2]; - if ((this->unk_220 & 8) && (globalCtx->msgCtx.unk11F04 == 0x1078)) { + if ((this->unk_220 & 8) && (globalCtx->msgCtx.currentTextId == 0x1078)) { this->unk_220 &= ~8; Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_001198, -10.0f); } @@ -385,8 +385,8 @@ void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x106E: if (gSaveContext.weekEventReg[25] & 0x40) { func_80151938(globalCtx, 0x1074); @@ -403,13 +403,13 @@ void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { case 0x1070: case 0x1071: case 0x1072: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1076: case 0x1079: Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_000964, -10.0f); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x107A: @@ -419,7 +419,7 @@ void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { case 0x1075: case 0x1078: player->exchangeItemId = 0; - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); break; @@ -447,7 +447,7 @@ void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { case 0x107B: player->exchangeItemId = 0; - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); break; @@ -463,7 +463,7 @@ void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { case 0x108A: case 0x1091: gSaveContext.weekEventReg[26] |= 4; - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); this->unk_220 |= 2; this->actor.textId = 0x1091; break; @@ -473,7 +473,7 @@ void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { case 0x108D: case 0x108E: case 0x108F: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1092: @@ -539,7 +539,7 @@ void func_80AE0C88(EnTsn* this, GlobalContext* globalCtx) { } void func_80AE0D10(EnTsn* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->actionFunc = func_80AE0D78; ActorCutscene_Stop(this->actor.cutscene); diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index 88c7a3778..feea46771 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -485,9 +485,9 @@ void EnWeatherTag_Update(Actor* thisx, GlobalContext* globalCtx) { u16 oldTime; this->actionFunc(this, globalCtx); - if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && (globalCtx->msgCtx.unk11F04 == 0x5E6) && - (!FrameAdvance_IsEnabled(&globalCtx->state)) && (globalCtx->sceneLoadFlag == 0) && - (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { + if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && + (globalCtx->msgCtx.currentTextId == 0x5E6) && (!FrameAdvance_IsEnabled(&globalCtx->state)) && + (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { oldTime = gSaveContext.time; gSaveContext.time = (u16)REG(0xF) + oldTime; // cast req diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.c b/src/overlays/actors/ovl_En_Yb/z_en_yb.c index fec9af08f..d2bf094fc 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -287,8 +287,8 @@ void EnYb_Talk(EnYb* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; EnYb_UpdateAnimation(this, globalCtx); - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx) != 0) { + switch (globalCtx->msgCtx.currentTextId) { case 0x147D: // I am counting on you func_801477B4(globalCtx); this->actionFunc = EnYb_Disappear; diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.c b/src/overlays/actors/ovl_En_Zob/z_en_zob.c index a3f503874..3fe0808a0 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.c +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.c @@ -368,7 +368,7 @@ void func_80BA00BC(EnZob* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1212)) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1212)) { switch (globalCtx->msgCtx.choiceIndex) { case 1: func_8019F208(); @@ -386,12 +386,12 @@ void func_80BA00BC(EnZob* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1208: case 0x120E: case 0x1216: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x120C: @@ -405,7 +405,7 @@ void func_80BA00BC(EnZob* this, GlobalContext* globalCtx) { case 0x1211: case 0x1213: case 0x1217: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); this->unk_304 = 3; func_80B9F7E4(this, 4, 2); break; @@ -453,7 +453,7 @@ void func_80BA0374(EnZob* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1205)) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1205)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -470,8 +470,8 @@ void func_80BA0374(EnZob* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x11F8: gSaveContext.weekEventReg[30] |= 2; func_80151938(globalCtx, 0x11F9); @@ -490,19 +490,19 @@ void func_80BA0374(EnZob* this, GlobalContext* globalCtx) { case 0x11FF: case 0x1201: case 0x1203: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x11FD: this->unk_304 = 3; func_80B9F7E4(this, 4, 2); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x11FE: this->unk_304 = 1; func_80B9F7E4(this, 3, 0); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x11FA: @@ -631,7 +631,7 @@ void func_80BA0A04(EnZob* this, GlobalContext* globalCtx) { temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 != 2) { - if ((temp_v0 == 5) && func_80147624(globalCtx)) { + if ((temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->actionFunc = func_80BA0AD8; this->unk_304 = 0; diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.c b/src/overlays/actors/ovl_En_Zog/z_en_zog.c index 5e12cba0d..0806413b2 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -613,7 +613,7 @@ void func_80B943EC(EnZog* this, GlobalContext* globalCtx) { void func_80B94470(EnZog* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 5) { - if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x103C)) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x103C)) { func_801477B4(globalCtx); this->actionFunc = func_80B9451C; this->unk_300 = this->unk_302 = 0; @@ -664,7 +664,7 @@ void func_80B946B4(EnZog* this, GlobalContext* globalCtx) { void func_80B946FC(EnZog* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -682,19 +682,19 @@ void func_80B946FC(EnZog* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1008: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1009: this->unk_300 = 4; - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1014: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1015: @@ -827,13 +827,13 @@ void func_80B94D0C(EnZog* this, GlobalContext* globalCtx) { this->unk_31E = 0; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { this->unk_320 = 5; - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1004: case 0x1005: case 0x1006: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1007: diff --git a/src/overlays/actors/ovl_En_Zos/z_en_zos.c b/src/overlays/actors/ovl_En_Zos/z_en_zos.c index a69223d09..6d355f1a0 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.c +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.c @@ -301,8 +301,8 @@ void func_80BBB574(EnZos* this, GlobalContext* globalCtx) { } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x124B: if (this->unk_2B8 == 9) { globalCtx->msgCtx.unk11F10 = 0; @@ -386,8 +386,8 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1237: player->exchangeItemId = 0; @@ -397,13 +397,13 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { case 0x123C: case 0x123E: case 0x123F: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1244: this->unk_2B6 &= ~0x10; func_80BBAE84(this, 6, 0); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1232: @@ -413,18 +413,18 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { case 0x1239: case 0x1246: func_80BBAE84(this, 6, 0); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1233: func_80BBAE84(this, 5, 0); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1245: case 0x1248: func_80BBAE84(this, 3, 0); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1231: @@ -582,7 +582,7 @@ void func_80BBC070(EnZos* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80BBAE84(this, 2, 0); func_801477B4(globalCtx); this->actionFunc = func_80BBC14C; diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index 88c236e98..95bdbc964 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -378,11 +378,11 @@ void func_80B97110(EnZot* this, GlobalContext* globalCtx) { } void func_80B97194(EnZot* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x125C: case 0x125F: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x125D: @@ -447,13 +447,13 @@ void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { func_80B96D4C(this); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x126E: case 0x1270: case 0x1273: case 0x1274: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1272: @@ -521,15 +521,15 @@ void func_80B975F8(EnZot* this, GlobalContext* globalCtx) { void func_80B9765C(EnZot* this, GlobalContext* globalCtx) { func_80B96D4C(this); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { s32 requiredScopeTemp; - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1262: case 0x1267: case 0x126A: case 0x126B: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; default: func_801477B4(globalCtx); @@ -658,15 +658,15 @@ void func_80B979DC(EnZot* this, GlobalContext* globalCtx) { } void func_80B97A44(EnZot* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1279: case 0x127C: case 0x127F: case 0x1282: case 0x1285: case 0x1288: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x127D: @@ -718,7 +718,7 @@ void func_80B97BF8(EnZot* this, GlobalContext* globalCtx) { void func_80B97C40(EnZot* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->actionFunc = func_80B97CC8; } @@ -767,18 +767,18 @@ void func_80B97E4C(EnZot* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x128C: this->unk_2F2 &= ~4; func_80B96BEC(this, 6, 2); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x128D: case 0x128E: case 0x128F: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1290: @@ -979,7 +979,7 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1293)) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1293)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -995,8 +995,8 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1291: case 0x1292: case 0x1296: @@ -1013,7 +1013,7 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { case 0x12A7: case 0x12A8: case 0x12AE: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x12A9: @@ -1091,13 +1091,13 @@ void func_80B98A4C(EnZot* this, GlobalContext* globalCtx) { } void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x12B1: case 0x12B4: case 0x12B7: case 0x12B9: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x12B8: @@ -1213,15 +1213,15 @@ void func_80B98F94(EnZot* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x12BB: this->unk_2F2 &= ~4; case 0x12BC: case 0x12C0: case 0x12C3: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x12BE: @@ -1274,8 +1274,8 @@ void func_80B991E4(EnZot* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - u16 temp = globalCtx->msgCtx.unk11F04; + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + u16 temp = globalCtx->msgCtx.currentTextId; u32 temp2; if ((temp == 0x12C6) || (temp == 0x12C7) || (temp == 0x12CA) || (temp == 0x12CB)) { diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.c b/src/overlays/actors/ovl_En_Zov/z_en_zov.c index 724f074da..a23f5da2b 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.c +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.c @@ -261,8 +261,8 @@ void func_80BD187C(EnZov* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1022: func_80151938(globalCtx, 0x1023); break; @@ -411,15 +411,15 @@ void func_80BD1DB8(EnZov* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1033: case 0x1034: case 0x1035: case 0x1036: case 0x1037: case 0x1038: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1039: diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.c b/src/overlays/actors/ovl_En_Zow/z_en_zow.c index 5fd785ad1..d9d8b1864 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -463,8 +463,8 @@ void func_80BDD570(EnZow* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x12E8: case 0x12E9: case 0x12EC: @@ -480,7 +480,7 @@ void func_80BDD570(EnZow* this, GlobalContext* globalCtx) { case 0x12FB: case 0x12FD: case 0x12FF: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; default: diff --git a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c index cf5269fc8..6e55293a3 100644 --- a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c +++ b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c @@ -97,13 +97,13 @@ void func_80B3C4E0(ObjGhaka* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; func_80B3C260(this); } } else if (talkState == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); diff --git a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c index a0fc2eff7..6f79fa1f3 100644 --- a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c +++ b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c @@ -129,7 +129,7 @@ void func_80C0685C(ObjMoonStone* this) { } void func_80C06870(ObjMoonStone* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { gSaveContext.weekEventReg[74] |= 0x40; Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c index 16ca76317..bfb244aa3 100644 --- a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c +++ b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c @@ -109,7 +109,7 @@ void func_80C06CD8(ObjMuPict* this, GlobalContext* globalCtx) { func_80C06E88(this, globalCtx); break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80C06B5C(this); if (this->actor.cutscene >= 0) { ActorCutscene_Stop(this->actor.cutscene); @@ -154,7 +154,7 @@ void func_80C06DC8(ObjMuPict* this, GlobalContext* globalCtx) { } void func_80C06E88(ObjMuPict* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x159A: Message_StartTextbox(globalCtx, 0x159B, &this->actor); diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c index 37a141264..cc888cdcd 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c @@ -138,7 +138,7 @@ void ObjWarpstone_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->isTalking) { if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { this->isTalking = false; - } else if ((Message_GetState(&globalCtx->msgCtx) == 4) && (func_80147624(globalCtx))) { + } else if ((Message_GetState(&globalCtx->msgCtx) == 4) && (Message_ShouldAdvance(globalCtx))) { if (globalCtx->msgCtx.choiceIndex != 0) { func_8019F208(); globalCtx->msgCtx.msgMode = 0x4D; diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 71d87716b..3ca33148d 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -418,7 +418,6 @@ animdict = { "func_8016A0AC": "Play_IsUnderwater", "func_800F5A8C": "Environment_LerpWeight", "func_801A3F54": "Audio_SetCutsceneFlag", - "func_801518B0": "Message_StartTextbox", "func_800EA0D4": "Cutscene_Start", "func_800EA0EC": "Cutscene_End", "func_800EDE34": "Cutscene_ActorTranslate", @@ -454,7 +453,22 @@ animdict = { "func_8013E07C": "SubS_ActorPathing_MoveWithoutGravityReverse", "func_8013E0A4": "SubS_ActorPathing_SetNextPoint", - # Struct members + "func_80147624": "Message_ShouldAdvance", + "func_80147734": "Message_ShouldAdvanceSilent", + "func_80149EBC": "Message_FindMessage", + "func_8014CC14": "Message_LoadChar", + "func_801518B0": "Message_StartTextbox", + "func_801588D0": "Message_FindMessageNES", + "func_80158988": "Message_LoadCharNES", + "func_80158A24": "Message_LoadPluralRupeesNES", + "func_80158C04": "Message_LoadLocalizedRupeesNES", + "func_80158D98": "Message_LoadRupeesNES", + "func_80158FB0": "Message_LoadTimeNES", + "func_8015926C": "Message_LoadAreaTextNES", + "func_8015E750": "Message_FindCreditsMessage", + + + # Structs members "skelAnime.unk03": "skelAnime.taper", "skelAnime.animCurrentSeg": "skelAnime.animation", "skelAnime.initialFrame": "skelAnime.startFrame", @@ -498,6 +512,7 @@ animdict = { "globalCtx->msgCtx.unk1202A": "globalCtx->msgCtx.ocarinaMode", "globalCtx->msgCtx.unk1202C": "globalCtx->msgCtx.ocarinaAction", "globalCtx->msgCtx.unk11F22": "globalCtx->msgCtx.msgMode", + "globalCtx->msgCtx.unk11F04": "globalCtx->msgCtx.currentTextId", "D_801D15B0" : "gZeroVec3f", "D_801D15BC" : "gZeroVec3s", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 0373f06e2..9a4c19d2c 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2822,8 +2822,8 @@ 0x8014750C:("Sram_nop8014750C",), 0x80147520:("func_80147520",), 0x80147564:("func_80147564",), - 0x80147624:("func_80147624",), - 0x80147734:("func_80147734",), + 0x80147624:("Message_ShouldAdvance",), + 0x80147734:("Message_ShouldAdvanceSilent",), 0x801477B4:("func_801477B4",), 0x80147818:("func_80147818",), 0x80147F18:("func_80147F18",), @@ -2837,12 +2837,12 @@ 0x801496C8:("func_801496C8",), 0x8014995C:("func_8014995C",), 0x80149C18:("func_80149C18",), - 0x80149EBC:("func_80149EBC",), + 0x80149EBC:("Message_FindMessage",), 0x80149F74:("func_80149F74",), 0x8014AAD0:("func_8014AAD0",), 0x8014ADBC:("func_8014ADBC",), 0x8014C70C:("func_8014C70C",), - 0x8014CC14:("func_8014CC14",), + 0x8014CC14:("Message_LoadChar",), 0x8014CCB4:("func_8014CCB4",), 0x8014CDF0:("func_8014CDF0",), 0x8014CFDC:("func_8014CFDC",), @@ -2874,17 +2874,17 @@ 0x8015680C:("func_8015680C",), 0x801586A4:("func_801586A4",), 0x801586D4:("Message_Init",), - 0x801588D0:("func_801588D0",), - 0x80158988:("func_80158988",), - 0x80158A24:("func_80158A24",), - 0x80158C04:("func_80158C04",), - 0x80158D98:("func_80158D98",), - 0x80158FB0:("func_80158FB0",), - 0x8015926C:("func_8015926C",), + 0x801588D0:("Message_FindMessageNES",), + 0x80158988:("Message_LoadCharNES",), + 0x80158A24:("Message_LoadPluralRupeesNES",), + 0x80158C04:("Message_LoadLocalizedRupeesNES",), + 0x80158D98:("Message_LoadRupeesNES",), + 0x80158FB0:("Message_LoadTimeNES",), + 0x8015926C:("Message_LoadAreaTextNES",), 0x80159438:("func_80159438",), 0x8015966C:("func_8015966C",), 0x8015B198:("func_8015B198",), - 0x8015E750:("func_8015E750",), + 0x8015E750:("Message_FindCreditsMessage",), 0x8015E7EC:("func_8015E7EC",), 0x8015F8A8:("func_8015F8A8",), 0x80160A90:("PlayerCall_InitFuncPtrs",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index bf777cba1..58e4703e1 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2336,8 +2336,8 @@ asm/non_matchings/code/z_sram_NES/func_80147414.s,func_80147414,0x80147414,0x3E asm/non_matchings/code/z_sram_NES/Sram_nop8014750C.s,Sram_nop8014750C,0x8014750C,0x5 asm/non_matchings/code/z_message/func_80147520.s,func_80147520,0x80147520,0x11 asm/non_matchings/code/z_message/func_80147564.s,func_80147564,0x80147564,0x30 -asm/non_matchings/code/z_message/func_80147624.s,func_80147624,0x80147624,0x44 -asm/non_matchings/code/z_message/func_80147734.s,func_80147734,0x80147734,0x20 +asm/non_matchings/code/z_message/Message_ShouldAdvance.s,Message_ShouldAdvance,0x80147624,0x44 +asm/non_matchings/code/z_message/Message_ShouldAdvanceSilent.s,Message_ShouldAdvanceSilent,0x80147734,0x20 asm/non_matchings/code/z_message/func_801477B4.s,func_801477B4,0x801477B4,0x19 asm/non_matchings/code/z_message/func_80147818.s,func_80147818,0x80147818,0x1C0 asm/non_matchings/code/z_message/func_80147F18.s,func_80147F18,0x80147F18,0x190 @@ -2351,12 +2351,12 @@ 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/func_80149EBC.s,func_80149EBC,0x80149EBC,0x2E +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/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/func_8014CC14.s,func_8014CC14,0x8014CC14,0x28 +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 @@ -2388,17 +2388,17 @@ asm/non_matchings/code/z_message/func_80156758.s,func_80156758,0x80156758,0x2D asm/non_matchings/code/z_message/func_8015680C.s,func_8015680C,0x8015680C,0x7A6 asm/non_matchings/code/z_message/func_801586A4.s,func_801586A4,0x801586A4,0xC asm/non_matchings/code/z_message/Message_Init.s,Message_Init,0x801586D4,0x7F -asm/non_matchings/code/z_message_nes/func_801588D0.s,func_801588D0,0x801588D0,0x2E -asm/non_matchings/code/z_message_nes/func_80158988.s,func_80158988,0x80158988,0x27 -asm/non_matchings/code/z_message_nes/func_80158A24.s,func_80158A24,0x80158A24,0x78 -asm/non_matchings/code/z_message_nes/func_80158C04.s,func_80158C04,0x80158C04,0x65 -asm/non_matchings/code/z_message_nes/func_80158D98.s,func_80158D98,0x80158D98,0x86 -asm/non_matchings/code/z_message_nes/func_80158FB0.s,func_80158FB0,0x80158FB0,0xAF -asm/non_matchings/code/z_message_nes/func_8015926C.s,func_8015926C,0x8015926C,0x73 +asm/non_matchings/code/z_message_nes/Message_FindMessageNES.s,Message_FindMessageNES,0x801588D0,0x2E +asm/non_matchings/code/z_message_nes/Message_LoadCharNES.s,Message_LoadCharNES,0x80158988,0x27 +asm/non_matchings/code/z_message_nes/Message_LoadPluralRupeesNES.s,Message_LoadPluralRupeesNES,0x80158A24,0x78 +asm/non_matchings/code/z_message_nes/Message_LoadLocalizedRupeesNES.s,Message_LoadLocalizedRupeesNES,0x80158C04,0x65 +asm/non_matchings/code/z_message_nes/Message_LoadRupeesNES.s,Message_LoadRupeesNES,0x80158D98,0x86 +asm/non_matchings/code/z_message_nes/Message_LoadTimeNES.s,Message_LoadTimeNES,0x80158FB0,0xAF +asm/non_matchings/code/z_message_nes/Message_LoadAreaTextNES.s,Message_LoadAreaTextNES,0x8015926C,0x73 asm/non_matchings/code/z_message_nes/func_80159438.s,func_80159438,0x80159438,0x8D asm/non_matchings/code/z_message_nes/func_8015966C.s,func_8015966C,0x8015966C,0x6CB asm/non_matchings/code/z_message_nes/func_8015B198.s,func_8015B198,0x8015B198,0xD6E -asm/non_matchings/code/z_message_staff/func_8015E750.s,func_8015E750,0x8015E750,0x27 +asm/non_matchings/code/z_message_staff/Message_FindCreditsMessage.s,Message_FindCreditsMessage,0x8015E750,0x27 asm/non_matchings/code/z_message_staff/func_8015E7EC.s,func_8015E7EC,0x8015E7EC,0x42F asm/non_matchings/code/z_message_staff/func_8015F8A8.s,func_8015F8A8,0x8015F8A8,0x47A asm/non_matchings/code/z_player_call/PlayerCall_InitFuncPtrs.s,PlayerCall_InitFuncPtrs,0x80160A90,0x1A From 95c6ddbcc89992b527f270e80d1e2397b146a2ff Mon Sep 17 00:00:00 2001 From: quaantuum <96855062+quaantuum@users.noreply.github.com> Date: Sun, 27 Mar 2022 08:14:55 -0700 Subject: [PATCH 140/257] Decompile obj_wturn (#564) * Decompile obj_wturn * Format * Rename struct member * Make suggestions * Format * Fix warning Co-authored-by: Elliptic Ellipsis --- spec | 3 +- .../actors/ovl_Obj_Wturn/z_obj_wturn.c | 116 ++++++++++++++---- .../actors/ovl_Obj_Wturn/z_obj_wturn.h | 3 +- 3 files changed, 98 insertions(+), 24 deletions(-) diff --git a/spec b/spec index 7aa66bcfb..9de1886e0 100644 --- a/spec +++ b/spec @@ -957,8 +957,7 @@ beginseg name "ovl_Obj_Wturn" compress include "build/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.o" - include "build/data/ovl_Obj_Wturn/ovl_Obj_Wturn.data.o" - include "build/data/ovl_Obj_Wturn/ovl_Obj_Wturn.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Wturn/ovl_Obj_Wturn_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c index 225587cdc..34d82523f 100644 --- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c +++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c @@ -13,42 +13,116 @@ void ObjWturn_Init(Actor* thisx, GlobalContext* globalCtx); void ObjWturn_Update(Actor* thisx, GlobalContext* globalCtx); +void func_808A7954(ObjWturn* this); void func_808A7968(ObjWturn* this, GlobalContext* globalCtx); +void func_808A7A24(ObjWturn* this); void func_808A7A5C(ObjWturn* this, GlobalContext* globalCtx); +void func_808A7AAC(ObjWturn* this, GlobalContext* globalCtx); void func_808A7BA0(ObjWturn* this, GlobalContext* globalCtx); +void func_808A7C04(ObjWturn* this, GlobalContext* globalCtx); void func_808A7C78(ObjWturn* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Wturn_InitVars = { - ACTOR_OBJ_WTURN, - ACTORCAT_ITEMACTION, - FLAGS, - GAMEPLAY_KEEP, - sizeof(ObjWturn), - (ActorFunc)ObjWturn_Init, - (ActorFunc)Actor_Noop, - (ActorFunc)ObjWturn_Update, - (ActorFunc)NULL, + ACTOR_OBJ_WTURN, ACTORCAT_ITEMACTION, FLAGS, + GAMEPLAY_KEEP, sizeof(ObjWturn), (ActorFunc)ObjWturn_Init, + (ActorFunc)Actor_Noop, (ActorFunc)ObjWturn_Update, (ActorFunc)NULL, }; -#endif +void ObjWturn_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjWturn* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/ObjWturn_Init.s") + func_808A7954(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7954.s") +void func_808A7954(ObjWturn* this) { + this->actionFunc = func_808A7968; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7968.s") +void func_808A7968(ObjWturn* this, GlobalContext* globalCtx) { + if (globalCtx->msgCtx.ocarinaMode >= 28 && globalCtx->msgCtx.ocarinaMode < 39) { + Flags_UnsetSwitch(globalCtx, this->actor.params); + Actor_MarkForDeath(&this->actor); + } else if ((Flags_GetSwitch(globalCtx, this->actor.params) && (globalCtx->sceneNum == SCENE_F40)) || + (!Flags_GetSwitch(globalCtx, this->actor.params) && (globalCtx->sceneNum == SCENE_F41))) { + func_808A7A24(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7A24.s") +void func_808A7A24(ObjWturn* this) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = func_808A7A5C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7A5C.s") +void func_808A7A5C(ObjWturn* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + func_808A7AAC(this, globalCtx); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7AAC.s") +void func_808A7AAC(ObjWturn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f eye; + Vec3f at; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7BA0.s") + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + func_8016566C(140); + this->camId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + func_800B7298(globalCtx, &this->actor, 21); + at.x = player->actor.focus.pos.x; + at.z = player->actor.focus.pos.z; + at.y = player->actor.focus.pos.y; + eye.x = (Math_SinS(this->actor.shape.rot.y) * 150.0f) + at.x; + eye.z = (Math_CosS(this->actor.shape.rot.y) * 150.0f) + at.z; + eye.y = at.y + 4.0f; + Play_CameraSetAtEye(globalCtx, this->camId, &at, &eye); + this->actionFunc = func_808A7BA0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7C04.s") +void func_808A7BA0(ObjWturn* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->actor.shape.rot.z, -0x8000, 0x0200)) { + func_808A7C04(this, globalCtx); + } + func_800B8FE8(&this->actor, NA_SE_EV_EARTHQUAKE - SFX_FLAG); + Play_CameraSetRoll(globalCtx, this->camId, this->actor.shape.rot.z); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7C78.s") +void func_808A7C04(ObjWturn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/ObjWturn_Update.s") + this->actor.world.pos.y += this->actor.playerHeightRel; + player->actor.shape.shadowAlpha = 0; + func_800B7298(globalCtx, &this->actor, 0x54); + func_800B8E58(player, NA_SE_VO_NAVY_ENEMY); + this->unk_14A = 0; + func_80165690(); + this->actionFunc = func_808A7C78; +} + +void func_808A7C78(ObjWturn* this, GlobalContext* globalCtx) { + static Vec3f D_808A7DC0 = { 0.0f, -1.0f, 0.0f }; + Camera* camera = Play_GetCamera(globalCtx, this->camId); + Player* player = GET_PLAYER(globalCtx); + + this->unk_14A++; + player->actor.world.pos.y = this->actor.world.pos.y + this->unk_14A * 4.0f; + Play_CameraSetAtEyeUp(globalCtx, this->camId, &player->actor.focus.pos, &camera->eye, &D_808A7DC0); + if (this->unk_14A == 1) { + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 3; + gSaveContext.nextCutsceneIndex = 0; + if (globalCtx->sceneNum == 0x58) { + globalCtx->nextEntranceIndex = 0xAC00; + } else { + globalCtx->nextEntranceIndex = 0xAA10; + } + globalCtx->sceneLoadFlag = 0x14; + } +} + +void ObjWturn_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjWturn* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h index 0b0b8b375..0390ac7a8 100644 --- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h +++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h @@ -10,7 +10,8 @@ typedef void (*ObjWturnActionFunc)(struct ObjWturn*, GlobalContext*); typedef struct ObjWturn { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjWturnActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4]; + /* 0x0148 */ s16 camId; + /* 0x014A */ s16 unk_14A; } ObjWturn; // size = 0x14C extern const ActorInit Obj_Wturn_InitVars; From b08880f7a7fdc49ca104fb86f5ffd4fd4a2aa221 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 27 Mar 2022 12:37:02 -0300 Subject: [PATCH 141/257] `z_sram_NES` with 2 NON_MATCHINGs and 1 NON_EQUIVALENTs (#531) * Rename Sram_InitDebugSave * Sram_InitDebugSave * err * Sram_IncrementDay * non_matchings * func_80146F5C and protos * func_80146EE8 * func_80145698 * func_80143A54 * Split SaveContext * problems with bss * Fix bss * more * a small bunch * Fix warnings * almost everything * two attempts * at least compiles * import data * bss * format * stuff? * Progress? * More progress * clean up data a little * More progress * disaster * re split data * A bit less of a disaster * Fix renamed stuff * data stuff * fix conflicts * format * CycleSceneFlags * some enums * cleanup * Fix merge issues * format * some changes * format * Lots of progress on z_sram_NES, but no matches yet * SaveContent Documentation * Oops * Oops2 * Document more SaveContext * Oops, don't need that anymore * add small comment * Another comment * dekuPlaygroundPlayerName * Fix merge issues * format * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * remove magic number * format * fix merge issues * bss * format * macro cleanup * review * merge issues * review * cleanup * UNK_TYPE1 * Fix * Remove comment * small change * conflicts * review * fix * fixes * format * Update actorCtx renames part * Match func_80143B0C thanks to Petrie and Anon * minor cleaning pass * format * cleanup * more minor cleanups * Macros for accessing gSaveContext.save.stolenItems * Introduce STOLEN_ITEM_NONE and remove CLEAR_STOLEN_ITEM_ * format * Update include/macros.h Co-authored-by: Derek Hensley * Update src/code/z_sram_NES.c Co-authored-by: Derek Hensley * Update src/code/z_sram_NES.c Co-authored-by: Derek Hensley * Update src/code/z_sram_NES.c Co-authored-by: Derek Hensley * Update src/code/z_sram_NES.c Co-authored-by: Derek Hensley * Update src/code/z_sram_NES.c Co-authored-by: Derek Hensley * Update src/code/z_sram_NES.c Co-authored-by: Derek Hensley * Update src/code/z_sram_NES.c Co-authored-by: Derek Hensley * @hensldm review * Update include/functions.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update include/functions.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Rename QUEST_SONG_NEW_WAVE * Add scene name comments to D_801C5FC0 * rename horseData.yaw * Update include/functions.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * // = CUR_UPG_VALUE(UPG_WALLET); * run actorfixer and format * fix bss * Fix merge problems and run format * Some improvements to func_801457CC by anon * bss * format * run actorfixer * actorfixer, bss and format * Use original names for the RESPAWN_MODE enum because the current ones are bad * QUEST_SONG_BOSSA_NOVA * some minor fixes on the SaveContext struct according to the debug rom * Merge Inventory.items and Inventory.masks * a * simplify saveBuf accesses * A few func renames * actorfixer * bss * fixes * bss * actorfixer * actorfixer and format * actorfixer * whoops * whops * bss Co-authored-by: engineer124 Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> Co-authored-by: Derek Hensley --- Makefile | 1 + docs/tutorial/advanced_control_flow.md | 42 +- docs/tutorial/documenting.md | 6 +- docs/tutorial/other_functions.md | 2 +- include/functions.h | 52 +- include/ichain.h | 4 +- include/macros.h | 71 +- include/segment_symbols.h | 7 +- include/variables.h | 31 +- include/z64.h | 13 - include/z64item.h | 3 +- include/z64save.h | 430 +++-- include/z64scene.h | 3 +- spec | 3 +- src/boot_O2_g3/idle_extra_bss.c | 3 +- src/code/code_8012EC80.c | 45 +- src/code/flg_set.c | 204 +- src/code/sched.c | 1 - src/code/z_actor.c | 8 +- src/code/z_bgcheck.c | 10 +- src/code/z_common_data.c | 12 +- src/code/z_demo.c | 77 +- src/code/z_elf_message.c | 26 +- src/code/z_en_item00.c | 22 +- src/code/z_game_over.c | 8 +- src/code/z_lifemeter.c | 28 +- src/code/z_message.c | 12 +- src/code/z_message_nes.c | 14 +- src/code/z_play.c | 18 +- src/code/z_scene.c | 22 +- src/code/z_snap.c | 18 +- src/code/z_sram_NES.c | 1671 ++++++++++++++++- .../actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c | 18 +- .../actors/ovl_Bg_Ingate/z_bg_ingate.c | 14 +- .../ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c | 2 +- src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c | 2 +- .../actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c | 4 +- .../actors/ovl_Bg_Tobira01/z_bg_tobira01.c | 16 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 4 +- src/overlays/actors/ovl_Boss_06/z_boss_06.c | 2 +- .../actors/ovl_Dm_Char01/z_dm_char01.c | 16 +- .../actors/ovl_Dm_Ravine/z_dm_ravine.c | 2 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 30 +- src/overlays/actors/ovl_Door_Ana/z_door_ana.c | 8 +- .../actors/ovl_Door_Shutter/z_door_shutter.c | 6 +- .../actors/ovl_Door_Warp1/z_door_warp1.c | 47 +- src/overlays/actors/ovl_En_Ah/z_en_ah.c | 2 +- .../ovl_En_Akindonuts/z_en_akindonuts.c | 84 +- src/overlays/actors/ovl_En_Al/z_en_al.c | 14 +- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 80 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 44 +- .../actors/ovl_En_Baisen/z_en_baisen.c | 10 +- .../actors/ovl_En_Bigokuta/z_en_bigokuta.c | 2 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 6 +- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 30 +- .../ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c | 26 +- .../actors/ovl_En_Bombers/z_en_bombers.c | 52 +- .../actors/ovl_En_Bombers2/z_en_bombers2.c | 9 +- .../actors/ovl_En_Bomjima/z_en_bomjima.c | 70 +- .../actors/ovl_En_Bomjimb/z_en_bomjimb.c | 56 +- src/overlays/actors/ovl_En_Cha/z_en_cha.c | 10 +- .../actors/ovl_En_Col_Man/z_en_col_man.c | 8 +- src/overlays/actors/ovl_En_Cow/z_en_cow.c | 10 +- src/overlays/actors/ovl_En_Dai/z_en_dai.c | 8 +- src/overlays/actors/ovl_En_Daiku/z_en_daiku.c | 11 +- .../actors/ovl_En_Daiku2/z_en_daiku2.c | 18 +- src/overlays/actors/ovl_En_Dg/z_en_dg.c | 5 +- .../actors/ovl_En_Dinofos/z_en_dinofos.c | 2 +- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 16 +- src/overlays/actors/ovl_En_Dnp/z_en_dnp.c | 16 +- src/overlays/actors/ovl_En_Dnq/z_en_dnq.c | 10 +- src/overlays/actors/ovl_En_Dns/z_en_dns.c | 13 +- src/overlays/actors/ovl_En_Door/z_en_door.c | 4 +- src/overlays/actors/ovl_En_Drs/z_en_drs.c | 2 +- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 25 +- .../actors/ovl_En_Elfgrp/z_en_elfgrp.c | 41 +- .../actors/ovl_En_Elforg/z_en_elforg.c | 10 +- src/overlays/actors/ovl_En_Fall/z_en_fall.c | 16 +- src/overlays/actors/ovl_En_Fish2/z_en_fish2.c | 36 +- .../actors/ovl_En_Fishing/z_en_fishing.c | 339 ++-- .../actors/ovl_En_Floormas/z_en_floormas.c | 2 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 48 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 82 +- .../actors/ovl_En_Gakufu/z_en_gakufu.c | 2 +- src/overlays/actors/ovl_En_Gb2/z_en_gb2.c | 40 +- src/overlays/actors/ovl_En_Geg/z_en_geg.c | 10 +- src/overlays/actors/ovl_En_Gg/z_en_gg.c | 28 +- src/overlays/actors/ovl_En_Gg2/z_en_gg2.c | 62 +- src/overlays/actors/ovl_En_Giant/z_en_giant.c | 3 +- .../actors/ovl_En_Ginko_Man/z_en_ginko_man.c | 89 +- src/overlays/actors/ovl_En_GirlA/z_en_girla.c | 60 +- src/overlays/actors/ovl_En_Gk/z_en_gk.c | 60 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 22 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 36 +- src/overlays/actors/ovl_En_Gs/z_en_gs.c | 30 +- .../ovl_En_Guard_Nuts/z_en_guard_nuts.c | 10 +- .../actors/ovl_En_Guruguru/z_en_guruguru.c | 24 +- .../actors/ovl_En_Hanabi/z_en_hanabi.c | 2 +- .../actors/ovl_En_Heishi/z_en_heishi.c | 8 +- src/overlays/actors/ovl_En_Hg/z_en_hg.c | 10 +- src/overlays/actors/ovl_En_Hgo/z_en_hgo.c | 8 +- .../z_en_horse_game_check.h | 13 +- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 8 +- src/overlays/actors/ovl_En_In/z_en_in.c | 141 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 89 +- src/overlays/actors/ovl_En_Ja/z_en_ja.c | 2 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 18 +- .../actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c | 26 +- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 44 +- .../actors/ovl_En_Kanban/z_en_kanban.c | 2 +- src/overlays/actors/ovl_En_Kbt/z_en_kbt.c | 10 +- .../actors/ovl_En_Kendo_Js/z_en_kendo_js.c | 31 +- src/overlays/actors/ovl_En_Kgy/z_en_kgy.c | 30 +- .../actors/ovl_En_Look_Nuts/z_en_look_nuts.c | 4 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 48 +- .../actors/ovl_En_Ma_Yto/z_en_ma_yto.c | 74 +- .../actors/ovl_En_Ma_Yts/z_en_ma_yts.c | 32 +- src/overlays/actors/ovl_En_Mag/z_en_mag.c | 6 +- .../actors/ovl_En_Minifrog/z_en_minifrog.c | 24 +- src/overlays/actors/ovl_En_Mk/z_en_mk.c | 50 +- src/overlays/actors/ovl_En_Mm/z_en_mm.c | 4 +- src/overlays/actors/ovl_En_Mm3/z_en_mm3.c | 26 +- src/overlays/actors/ovl_En_Ms/z_en_ms.c | 4 +- .../actors/ovl_En_Mt_tag/z_en_mt_tag.c | 13 +- src/overlays/actors/ovl_En_Muto/z_en_muto.c | 16 +- src/overlays/actors/ovl_En_Osn/z_en_osn.c | 57 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 30 +- src/overlays/actors/ovl_En_Ot/z_en_ot.c | 36 +- src/overlays/actors/ovl_En_Owl/z_en_owl.c | 10 +- .../actors/ovl_En_Pamera/z_en_pamera.c | 44 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 4 +- .../actors/ovl_En_Peehat/z_en_peehat.c | 10 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 80 +- src/overlays/actors/ovl_En_Pr/z_en_pr.c | 4 +- src/overlays/actors/ovl_En_Prz/z_en_prz.c | 2 +- .../actors/ovl_En_Racedog/z_en_racedog.c | 4 +- .../actors/ovl_En_Railgibud/z_en_railgibud.c | 14 +- .../actors/ovl_En_Recepgirl/z_en_recepgirl.c | 4 +- src/overlays/actors/ovl_En_Rg/z_en_rg.c | 6 +- src/overlays/actors/ovl_En_Rr/z_en_rr.c | 4 +- .../actors/ovl_En_Scopenuts/z_en_scopenuts.c | 17 +- .../actors/ovl_En_Sellnuts/z_en_sellnuts.c | 34 +- src/overlays/actors/ovl_En_Shn/z_en_shn.c | 12 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 2 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 46 +- src/overlays/actors/ovl_En_Ssh/z_en_ssh.c | 4 +- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 50 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 68 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 96 +- src/overlays/actors/ovl_En_Tab/z_en_tab.c | 7 +- .../ovl_En_Talk_Gibud/z_en_talk_gibud.c | 6 +- .../actors/ovl_En_Tanron4/z_en_tanron4.c | 4 +- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 222 +-- .../actors/ovl_En_Thiefbird/z_en_thiefbird.c | 25 +- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 20 +- src/overlays/actors/ovl_En_Torch/z_en_torch.c | 2 +- .../actors/ovl_En_Torch2/z_en_torch2.c | 4 +- src/overlays/actors/ovl_En_Toto/z_en_toto.c | 44 +- src/overlays/actors/ovl_En_Trt/z_en_trt.c | 52 +- src/overlays/actors/ovl_En_Trt2/z_en_trt2.c | 38 +- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 20 +- .../actors/ovl_En_Tru_Mt/z_en_tru_mt.c | 5 +- src/overlays/actors/ovl_En_Tsn/z_en_tsn.c | 36 +- .../actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c | 2 +- .../ovl_En_Weather_Tag/z_en_weather_tag.c | 16 +- .../actors/ovl_En_Wood02/z_en_wood02.c | 2 +- src/overlays/actors/ovl_En_Yb/z_en_yb.c | 10 +- src/overlays/actors/ovl_En_Zob/z_en_zob.c | 36 +- src/overlays/actors/ovl_En_Zog/z_en_zog.c | 18 +- .../actors/ovl_En_Zoraegg/z_en_zoraegg.c | 12 +- src/overlays/actors/ovl_En_Zos/z_en_zos.c | 50 +- src/overlays/actors/ovl_En_Zot/z_en_zot.c | 152 +- src/overlays/actors/ovl_En_Zov/z_en_zov.c | 16 +- src/overlays/actors/ovl_En_Zow/z_en_zow.c | 32 +- src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c | 4 +- src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c | 4 +- .../actors/ovl_Obj_Dinner/z_obj_dinner.c | 2 +- .../actors/ovl_Obj_Ghaka/z_obj_ghaka.c | 11 +- .../actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c | 2 +- .../ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c | 2 +- .../actors/ovl_Obj_Hunsui/z_obj_hunsui.c | 1 + .../actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c | 2 +- .../actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c | 8 +- .../ovl_Obj_Moon_Stone/z_obj_moon_stone.c | 28 +- .../actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c | 2 +- .../ovl_Obj_Tokei_Step/z_obj_tokei_step.c | 2 +- .../actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c | 46 +- .../ovl_Obj_Warpstone/z_obj_warpstone.c | 4 +- .../ovl_Obj_Warpstone/z_obj_warpstone.h | 2 +- src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c | 4 +- .../gamestates/ovl_daytelop/z_daytelop.c | 22 +- .../ovl_file_choose/z_file_choose.h | 54 +- .../gamestates/ovl_opening/z_opening.c | 20 +- src/overlays/gamestates/ovl_select/z_select.c | 176 +- src/overlays/gamestates/ovl_title/z_title.c | 4 +- tools/actorfixer.py | 49 +- tools/disasm/files.txt | 1 + tools/disasm/functions.txt | 22 +- tools/disasm/variables.txt | 28 +- tools/permuter_settings.toml | 1 + tools/sizes/code_functions.csv | 20 +- 201 files changed, 4584 insertions(+), 2880 deletions(-) diff --git a/Makefile b/Makefile index c0569cbe1..c41cc941f 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,7 @@ ifeq ($(NON_MATCHING),1) COMPARE := 0 endif +DISASM_FLAGS ?= ifneq ($(FULL_DISASM), 0) DISASM_FLAGS += --full endif diff --git a/docs/tutorial/advanced_control_flow.md b/docs/tutorial/advanced_control_flow.md index 8cd9660ba..4952f7586 100644 --- a/docs/tutorial/advanced_control_flow.md +++ b/docs/tutorial/advanced_control_flow.md @@ -81,7 +81,7 @@ void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80952734(EnMs* this, GlobalContext* globalCtx) { s16 temp_v1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (gSaveContext.inventory.items[10] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[10] == ITEM_NONE) { this->actor.textId = 0x92E; } else { this->actor.textId = 0x932; @@ -187,12 +187,12 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { return; } func_801477B4(globalCtx); - if ((s32) gSaveContext.rupees < 0xA) { + if ((s32) gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); return; } - if ((s32) gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if ((s32) gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); return; @@ -275,14 +275,14 @@ block_7: goto block_16; block_11: func_801477B4(globalCtx); - if ((s32) gSaveContext.rupees >= 0xA) { + if ((s32) gSaveContext.save.playerData.rupees >= 0xA) { goto block_13; } play_sound(0x4806U); func_80151938(globalCtx, 0x935U); return; block_13: - if ((s32) gSaveContext.inventory.ammo[gItemSlots[0xA]] < 0x14) { + if ((s32) gSaveContext.save.inventory.ammo[gItemSlots[0xA]] < 0x14) { goto block_15; } play_sound(0x4806U); @@ -312,7 +312,7 @@ which in many ways looks worse: you can see why the use of gotos in code is stro The simplest sort of block label to eliminate is one that is only used once, and where the corresponding goto jumps over a simple block of code with no extra internal control flow structure. There are two obvious examples of this here, the first being ```C - if ((s32) gSaveContext.rupees >= 0xA) { + if ((s32) gSaveContext.save.playerData.rupees >= 0xA) { goto block_13; } play_sound(0x4806U); @@ -324,7 +324,7 @@ block_13: Currently, this says to jump over the code block `play_sound...` if the condition in the if is satisfied. In non-goto terms, this means that the block should be run if the condition is *not* satisfied. This also illustrates a general property of goto-only mode: you have to reverse the senses of all of the ifs. Therefore the appropriate approach is to swap the if round, put the code block inside, and remove the goto and the label: ```C - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); return; @@ -378,12 +378,12 @@ block_7: block_11: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); return; } - if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); return; @@ -448,12 +448,12 @@ block_7: block_11: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); return; } - if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); return; @@ -497,12 +497,12 @@ So let us rewrite the entire second half as a switch: case 0: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); return; } - if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); return; @@ -532,10 +532,10 @@ There's a couple of other obvious things here: case 0: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); - } else if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); } else { @@ -597,10 +597,10 @@ block_7: case 0: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); - } else if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); } else { @@ -661,10 +661,10 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { case 0: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); - } else if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); } else { @@ -713,10 +713,10 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { case 0: func_801477B4(globalCtx); - if (gSaveContext.rupees < 0xA) { + if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); - } else if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); func_80151938(globalCtx, 0x937U); } else { diff --git a/docs/tutorial/documenting.md b/docs/tutorial/documenting.md index e50921bef..a5e64d2a9 100644 --- a/docs/tutorial/documenting.md +++ b/docs/tutorial/documenting.md @@ -182,12 +182,12 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { func_80C10148(this); return; } - + if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); - if ((gSaveContext.weekEventReg[63] & 0x80)) { + if ((gSaveContext.save.weekEventReg[63] & 0x80)) { this->actor.textId = 0x2ADF; } else { this->actor.textId = 0x2ADA; @@ -504,7 +504,7 @@ void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) { if (this->actor.textId == 0x2AD9) { // "Welcome..." Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); - if (gSaveContext.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting + if (gSaveContext.save.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended) } else { this->actor.textId = 0x2ADA; // Mayor's office is on the left (meeting ongoing) diff --git a/docs/tutorial/other_functions.md b/docs/tutorial/other_functions.md index 0795fa76e..796939dd8 100644 --- a/docs/tutorial/other_functions.md +++ b/docs/tutorial/other_functions.md @@ -378,7 +378,7 @@ There remains one thing we need to fix before trying to compile it, namely `*(&g /* 0x0EF8 */ u8 weekEventReg[100]; // "week_event_reg" /* 0x0F5C */ u32 mapsVisited; // "area_arrival" ``` -so it's somewhere in `weekEventReg`. `0xF37 - 0xEF8 = 0x3F = 63`, and it's a byte array, so the access is actually `gSaveContext.weekEventReg[63] & 0x80`. Now it will compile. We also don't use `!= 0` for flag comparisons: just `if (gSaveContext.weekEventReg[63] & 0x80)` will do. +so it's somewhere in `weekEventReg`. `0xF37 - 0xEF8 = 0x3F = 63`, and it's a byte array, so the access is actually `gSaveContext.save.weekEventReg[63] & 0x80`. Now it will compile. We also don't use `!= 0` for flag comparisons: just `if (gSaveContext.save.weekEventReg[63] & 0x80)` will do. Running `./diff.py -mwo3 func_80C102D4` and scrolling down, we discover that this doesn't match! diff --git a/include/functions.h b/include/functions.h index 7c9f8d044..121d9bb05 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1495,7 +1495,7 @@ void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor); // void func_800F3940(void); // void func_800F39B4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_800F3A64(void); -// void func_800F3B2C(void); +void func_800F3B2C(GlobalContext* globalCtx); // void func_800F3B68(void); // void func_800F3C44(void); // void func_800F3ED4(void); @@ -1913,13 +1913,13 @@ void Interface_ChangeAlpha(u16 param_1); // void func_80111CB4(void); // void func_801129E4(void); void func_80112AFC(GlobalContext* globalCtx); -void func_80112B40(GlobalContext* globalCtx, s32 arg1); +void func_80112B40(GlobalContext* globalCtx, u8 arg1); // void func_80112BE4(void); // void func_80112C0C(void); u32 Item_Give(GlobalContext* globalCtx, u8 param_2); // void func_801143CC(void); UNK_TYPE func_80114978(UNK_TYPE arg0); -void func_801149A0(s32 arg0, s16 arg1); +void func_801149A0(s32 itemId, s16 slotId); // void func_80114A9C(void); // void func_80114B84(void); // void func_80114CA0(void); @@ -2574,39 +2574,7 @@ Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z); void SkyboxDraw_SetColors(SkyboxContext* skyboxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB); void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y, f32 z); void SkyboxDraw_Noop(SkyboxContext* skyboxCtx); -void func_80143A10(u8 owlId); -// void func_80143A54(void); -void func_80143AC4(void); -void func_80143B0C(GlobalContext* globalCtx); -void Sram_IncrementDay(void); -u32 Sram_CalcChecksum(u8* data, u32 length); -// void func_80144628(void); -// void Sram_GenerateRandomSaveFields(void); -void func_80144890(void); -void Sram_InitDebugSave(void); -void func_80144A94(SramContext* sramCtx); -// void func_80144E78(void); -// void func_8014546C(void); -// void func_80145698(void); -void func_801457CC(GameState* gameState, SramContext* param_2); -void func_80146580(s32 param_1, SramContext* param_2, s32 param_3); -// void func_80146628(void); -// void func_80146AA0(void); -// void func_80146DF8(void); -void func_80146E40(GameState* gameState, SramContext* sramCtx); -void Sram_Alloc(GameState* gameState, SramContext* sramCtx); -// void func_80146EBC(SramContext* param_1, UNK_TYPE4 param_2, UNK_TYPE4 param_3); -void func_80146EE8(GlobalContext* globalCtx); -void func_80146F5C(GlobalContext* globalCtx); -// void func_80147008(void); -void func_80147020(SramContext* param_1); -void func_80147068(SramContext* param_1); -// void func_80147138(SramContext* param_1, UNK_TYPE4 param_2, UNK_TYPE4 param_3); -void func_80147150(SramContext* param_1); -void func_80147198(SramContext* param_1); -// void func_80147314(void); -// void func_80147414(void); -// void Sram_nop8014750C(UNK_TYPE4 param_1); + // void func_80147520(void); void func_80147564(GlobalContext* globalCtx); s32 Message_ShouldAdvance(GlobalContext* globalCtx); @@ -3234,17 +3202,17 @@ void Slowly_Stop(SlowlyTask* slowly); // char* func_801857D0(void); // void func_80185864(void); u32 func_80185908(void); -// void func_80185968(void); +UNK_TYPE func_80185968(void* arg0, UNK_TYPE arg1, UNK_TYPE arg2); // void func_801859F0(void); // void func_80185A2C(void); // void func_80185B1C(void); // void func_80185BE4(void); // void func_80185C24(void); void SysFlashrom_ThreadEntry(s80185D40* param_1); -// void func_80185DDC(void); -// void func_80185EC4(void); -// void func_80185F04(void); -// void func_80185F64(void); +void func_80185DDC(u8* arg0, u32 arg1, u32 arg2); +s32 func_80185EC4(void); +s32 func_80185F04(void); +void func_80185F64(void* arg0, UNK_TYPE arg1, UNK_TYPE arg2); s32 func_80185F90(u32 param_1); u32 osFlashGetAddr(u32 pageNum); OSPiHandle* osFlashReInit(u8 latency, u8 pulse, u8 pageSize, u8 relDuration, u32 start); @@ -3606,7 +3574,7 @@ void func_801A3B48(UNK_TYPE arg0); // void func_801A3B90(void); void func_801A3CD8(s8 param_1); // void func_801A3CF4(void); -// void func_801A3D98(void); +void func_801A3D98(s8 audioSetting); // void func_801A3E38(void); // void func_801A3EC0(void); void Audio_SetCutsceneFlag(u8 flag); diff --git a/include/ichain.h b/include/ichain.h index f9131545c..07bd07313 100644 --- a/include/ichain.h +++ b/include/ichain.h @@ -1,5 +1,5 @@ -#ifndef _ICHAIN_H_ -#define _ICHAIN_H_ +#ifndef ICHAIN_H +#define ICHAIN_H #include "libc/stddef.h" diff --git a/include/macros.h b/include/macros.h index 8b5ec577f..64f084efe 100644 --- a/include/macros.h +++ b/include/macros.h @@ -44,10 +44,10 @@ // linkAge still exists in MM, but is always set to 0 (always adult) // There are remnants of these macros from OOT, but they are essentially useless -#define LINK_IS_CHILD (gSaveContext.linkAge == 1) -#define LINK_IS_ADULT (gSaveContext.linkAge == 0) +#define LINK_IS_CHILD (gSaveContext.save.linkAge == 1) +#define LINK_IS_ADULT (gSaveContext.save.linkAge == 0) -#define CURRENT_DAY (((void)0, gSaveContext.day) % 5) +#define CURRENT_DAY (((void)0, gSaveContext.save.day) % 5) #define TIME_TO_MINUTES(time) (s32)((time) * ((24 * 60) / 0x10000)) #define CLOCK_TIME(hr, min) (s32)(((hr) * 60 + (min)) * 0x10000 / (24 * 60)) @@ -60,28 +60,53 @@ #define CLOCK_TIME_ALT_F(hr, min) (((hr) * 60.0f + (min)) / (24.0f * 60.0f / 0x10000)) #define SLOT(item) gItemSlots[item] -#define AMMO(item) gSaveContext.inventory.ammo[SLOT(item)] -#define INV_CONTENT(item) gSaveContext.inventory.items[SLOT(item)] +#define AMMO(item) gSaveContext.save.inventory.ammo[SLOT(item)] +#define INV_CONTENT(item) gSaveContext.save.inventory.items[SLOT(item)] +#define GET_INV_CONTENT(item) ((void)0, gSaveContext.save.inventory.items)[SLOT(item)] -#define ALL_EQUIP_VALUE_VOID(equip) \ - ((((void)0, gSaveContext.inventory.equipment) & gEquipMasks[equip]) >> gEquipShifts[equip]) -#define CUR_EQUIP_VALUE_VOID(equip) \ - ((((void)0, gSaveContext.equips.equipment) & gEquipMasks[equip]) >> gEquipShifts[equip]) -#define CUR_UPG_VALUE_VOID(upg) \ - ((((void)0, gSaveContext.inventory.upgrades) & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) -#define INV_CONTENT_VOID(item) ((void)0, gSaveContext.inventory.items)[SLOT(item)] +#define CUR_FORM ((gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) ? 0 : gSaveContext.save.playerForm) -#define CUR_FORM ((gSaveContext.playerForm == PLAYER_FORM_HUMAN) ? 0 : gSaveContext.playerForm) +#define GET_SAVE_EQUIPS_EQUIPMENT ((void)0, gSaveContext.save.equips.equipment) +#define GET_SAVE_INVENTORY_UPGRADES ((void)0, gSaveContext.save.inventory.upgrades) +#define GET_SAVE_INVENTORY_QUEST_ITEMS ((void)0, gSaveContext.save.inventory.questItems) -#define ALL_EQUIP_VALUE(equip) ((gSaveContext.inventory.equipment & gEquipMasks[equip]) >> gEquipShifts[equip]) -#define CUR_EQUIP_VALUE(equip) ((gSaveContext.equips.equipment & gEquipMasks[equip]) >> gEquipShifts[equip]) -#define CUR_UPG_VALUE(upg) ((gSaveContext.inventory.upgrades & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) -#define SET_EQUIP_VALUE(equip, value) (gSaveContext.equips.equipment = ((((void)0, gSaveContext.equips.equipment) & (gEquipNegMasks[equip])) | (u16)((u16)(value) << gEquipShifts[equip]))) -#define CUR_FORM_EQUIP(button) (gSaveContext.equips.buttonItems[CUR_FORM][button]) -#define CHECK_QUEST_ITEM(item) (((void)0, gSaveContext.inventory.questItems) & gBitFlags[item]) -#define REMOVE_QUEST_ITEM(item) (gSaveContext.inventory.questItems = (((void)0, gSaveContext.inventory.questItems) & (-1 - gBitFlags[item]))) -#define CHECK_DUNGEON_ITEM(item, dungeonIndex) (gSaveContext.inventory.dungeonItems[(void)0, dungeonIndex] & gBitFlags[item]) -#define DUNGEON_KEY_COUNT(dungeonIndex) (gSaveContext.inventory.dungeonKeys[(void)0, dungeonIndex]) +#define GET_CUR_EQUIP_VALUE(equip) ((GET_SAVE_EQUIPS_EQUIPMENT & gEquipMasks[equip]) >> gEquipShifts[equip]) + +#define CUR_UPG_VALUE(upg) ((gSaveContext.save.inventory.upgrades & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) +#define GET_CUR_UPG_VALUE(upg) ((GET_SAVE_INVENTORY_UPGRADES & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) + +#define SET_EQUIP_VALUE(equip, value) (gSaveContext.save.equips.equipment = ((GET_SAVE_EQUIPS_EQUIPMENT & gEquipNegMasks[equip]) | (u16)((u16)(value) << gEquipShifts[equip]))) + +#define BUTTON_ITEM_EQUIP(form, button) (gSaveContext.save.equips.buttonItems[form][button]) +#define CUR_FORM_EQUIP(button) BUTTON_ITEM_EQUIP(CUR_FORM, button) + +#define C_SLOT_EQUIP(form, button) (gSaveContext.save.equips.cButtonSlots[form][button]) +#define CHECK_QUEST_ITEM(item) (GET_SAVE_INVENTORY_QUEST_ITEMS & gBitFlags[item]) +#define REMOVE_QUEST_ITEM(item) (gSaveContext.save.inventory.questItems = (GET_SAVE_INVENTORY_QUEST_ITEMS & (-1 - gBitFlags[item]))) + +#define CHECK_DUNGEON_ITEM(item, dungeonIndex) (gSaveContext.save.inventory.dungeonItems[(void)0, dungeonIndex] & gBitFlags[item]) +#define DUNGEON_KEY_COUNT(dungeonIndex) (gSaveContext.save.inventory.dungeonKeys[(void)0, dungeonIndex]) + +#define GET_CUR_FORM_BTN_ITEM(btn) ((u8)((btn) == EQUIP_SLOT_B ? BUTTON_ITEM_EQUIP(CUR_FORM, btn) : BUTTON_ITEM_EQUIP(0, btn))) + +#define SET_CUR_FORM_BTN_ITEM(btn, item) \ + do { \ + if ((btn) == EQUIP_SLOT_B) { \ + BUTTON_ITEM_EQUIP(CUR_FORM, (btn)) = (item); \ + } else { \ + BUTTON_ITEM_EQUIP(0, (btn)) = (item); \ + } \ + } while (0) + +#define STOLEN_ITEM_NONE (0) + +#define STOLEN_ITEM_1 ((gSaveContext.save.stolenItems & 0xFF000000) >> 0x18) +#define STOLEN_ITEM_2 ((gSaveContext.save.stolenItems & 0x00FF0000) >> 0x10) + +#define SET_STOLEN_ITEM_1(itemId) \ + (gSaveContext.save.stolenItems = (gSaveContext.save.stolenItems & ~0xFF000000) | ((itemId & 0xFF) << 0x18)) +#define SET_STOLEN_ITEM_2(itemId) \ + (gSaveContext.save.stolenItems = (gSaveContext.save.stolenItems & ~0x00FF0000) | ((itemId & 0xFF) << 0x10)) #define CAPACITY(upg, value) gUpgradeCapacities[upg][value] #define CUR_CAPACITY(upg) CAPACITY(upg, CUR_UPG_VALUE(upg)) @@ -182,4 +207,4 @@ extern GraphicsContext* __gfxCtx; #define ALIGNED8 #endif -#endif // _MACROS_H_ +#endif // MACROS_H diff --git a/include/segment_symbols.h b/include/segment_symbols.h index 3f02baa5c..e133437cc 100644 --- a/include/segment_symbols.h +++ b/include/segment_symbols.h @@ -1,7 +1,8 @@ -#ifndef _SEGMENT_SYMBOLS_H_ -#define _SEGMENT_SYMBOLS_H_ +#ifndef SEGMENT_SYMBOLS_H +#define SEGMENT_SYMBOLS_H -#include "z64.h" +#include "libc/stddef.h" +#include "PR/ultratypes.h" #define DECLARE_SEGMENT(name) \ extern u8 _##name##SegmentStart[]; \ diff --git a/include/variables.h b/include/variables.h index 399fadc98..c5047526c 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1369,36 +1369,7 @@ extern s32 D_801C5E9C[]; // D_801C5E9C extern s32 D_801C5EB0[]; // D_801C5EB0 extern s16 D_801C5EC4[]; // D_801C5EC4 extern struct_801C5F44 D_801C5F44[]; // D_801C5F44 -// extern UNK_TYPE4 D_801C5FC0; -// extern UNK_TYPE4 D_801C5FC4; -// extern UNK_TYPE4 D_801C5FC8; -// extern UNK_TYPE4 D_801C5FCC; -// extern UNK_TYPE4 D_801C5FD0; -// extern UNK_TYPE2 D_801C66D0; -// extern UNK_TYPE4 D_801C6798; -// extern UNK_TYPE1 D_801C67B0; -// extern UNK_TYPE4 D_801C67C8; -// extern UNK_TYPE4 D_801C67CC; -// extern UNK_TYPE4 D_801C67E8; -// extern UNK_TYPE4 D_801C67F0; -// extern UNK_TYPE4 D_801C67F4; -// extern UNK_TYPE1 D_801C6818; -// extern UNK_TYPE4 D_801C6838; -// extern UNK_TYPE1 D_801C6840; -// extern UNK_TYPE1 D_801C6850; -// extern UNK_TYPE1 D_801C6870; -// extern UNK_TYPE1 D_801C6890; -// extern UNK_TYPE1 D_801C6898; -// extern UNK_TYPE1 D_801C68C0; -extern Inventory gSaveDefaultInventory; -extern u16 gSaveDefaultChecksum; -// extern UNK_TYPE1 D_801C6970; -// extern UNK_TYPE1 D_801C6998; -extern Inventory D_801C69BC; -extern u16 D_801C6A44; -// extern UNK_TYPE1 D_801C6A48; -// extern UNK_TYPE1 D_801C6A50; -// extern UNK_TYPE1 D_801C6A58; + // extern UNK_TYPE1 D_801C6A70; // extern UNK_TYPE2 D_801C6A74; // extern UNK_TYPE2 D_801C6A78; diff --git a/include/z64.h b/include/z64.h index 5c6c931a4..f49686c6c 100644 --- a/include/z64.h +++ b/include/z64.h @@ -315,19 +315,6 @@ typedef struct { /* 0x3 */ s8 pillarboxMagnitude; } ShrinkWindowContext; // size = 0x4 -typedef struct { - /* 0x00 */ u8* readBuff; - /* 0x04 */ u32* flashReadBuff; - /* 0x08 */ char unk_08[4]; - /* 0x0C */ s16 status; - /* 0x10 */ u32 curPage; - /* 0x14 */ u32 numPages; - /* 0x18 */ OSTime unk_18; - /* 0x20 */ s16 unk_20; - /* 0x22 */ s16 unk_22; - /* 0x24 */ s16 unk_24; -} SramContext; // size = 0x28 - typedef struct { /* 0x0 */ s32 topY; /* 0x4 */ s32 bottomY; diff --git a/include/z64item.h b/include/z64item.h index 00eb0a5a8..77ceb240c 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -31,7 +31,7 @@ typedef enum { /* 0x05 */ QUEST_SWORD, /* 0x06 */ QUEST_SONG_SONATA, /* 0x07 */ QUEST_SONG_LULLABY, - /* 0x08 */ QUEST_SONG_NOVA, + /* 0x08 */ QUEST_SONG_BOSSA_NOVA, /* 0x09 */ QUEST_SONG_ELEGY, /* 0x0A */ QUEST_SONG_OATH, /* 0x0B */ QUEST_SONG_SARIA, @@ -261,6 +261,7 @@ typedef enum { /* 0xA1 */ ITEM_GOLD_DUST_2, /* 0xA2 */ ITEM_HYLIAN_LOACH_2, /* 0xA3 */ ITEM_SEA_HORSE_CAUGHT, + /* 0xFD */ ITEM_UNK_FD = 0xFD, /* 0xFF */ ITEM_NONE = 0xFF } ItemID; diff --git a/include/z64save.h b/include/z64save.h index b7f4e60fd..2595b3c27 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -1,99 +1,142 @@ -#ifndef _Z64SAVE_H_ -#define _Z64SAVE_H_ +#ifndef Z64SAVE_H +#define Z64SAVE_H #include "ultra64.h" #include "z64math.h" #include "os.h" -typedef struct { - /* 0x00 */ u8 buttonItems[4][4]; - /* 0x10 */ u8 cButtonSlots[4][4]; - /* 0x20 */ u16 equipment; -} ItemEquips; // size = 0x0A +struct GameState; +struct GlobalContext; +struct FileChooseContext; -typedef struct { - /* 0x00 */ u8 items[24]; - /* 0x18 */ u8 masks[24]; - /* 0x30 */ s8 ammo[24]; - /* 0x48 */ u32 upgrades; // some bits are wallet upgrades - /* 0x4C */ u32 questItems; - /* 0x50 */ u8 dungeonItems[10]; - /* 0x5A */ s8 dungeonKeys[10]; - /* 0x64 */ s8 strayFairies[10]; // "orange_fairy" - /* 0x6E */ char dekuPlaygroundPlayerName[3][8]; // Stores playerName (8 char) over (3 days) when getting a new high score. original name: degnuts_memory_name +// TODO: properly name DOWN, RETURN and TOP +typedef enum RespawnMode { + /* 0 */ RESTART_MODE_DOWN, // "RESTART_MODE_DOWN" + /* 1 */ RESTART_MODE_RETURN, // "RESTART_MODE_RETURN" + /* 2 */ RESTART_MODE_TOP, // "RESTART_MODE_TOP" + /* 3 */ RESPAWN_MODE_UNK_3, // Maybe related to grottos + /* 4 */ RESPAWN_MODE_GORON, // "RESTART_MODE_GORON" + /* 5 */ RESPAWN_MODE_ZORA, // "RESTART_MODE_ZORA" + /* 6 */ RESPAWN_MODE_DEKU, // "RESTART_MODE_NUTS" + /* 7 */ RESPAWN_MODE_HUMAN, // "RESTART_MODE_CHILD" + /* 8 */ RESPAWN_MODE_MAX +} RespawnMode; + +#define SAVE_BUFFER_SIZE 0x4000 + +typedef struct SramContext { + /* 0x00 */ u8* readBuff; + /* 0x04 */ u8 *saveBuf; + /* 0x08 */ char unk_08[4]; + /* 0x0C */ s16 status; + /* 0x10 */ u32 curPage; + /* 0x14 */ u32 numPages; + /* 0x18 */ OSTime unk_18; + /* 0x20 */ s16 unk_20; + /* 0x22 */ s16 unk_22; + /* 0x24 */ s16 unk_24; +} SramContext; // size = 0x28 + +typedef struct ItemEquips { + /* 0x00 */ u8 buttonItems[4][4]; // "register_item" + /* 0x10 */ u8 cButtonSlots[4][4]; // "register_item_pt" + /* 0x20 */ u16 equipment; +} ItemEquips; // size = 0x22 + +typedef struct Inventory { + /* 0x00 */ u8 items[48]; // "item_register", first 24 elements are normal items and the other 24 are masks + /* 0x30 */ s8 ammo[24]; // "item_count" + /* 0x48 */ u32 upgrades; // "non_equip_register" some bits are wallet upgrades + /* 0x4C */ u32 questItems; // "collect_register" + /* 0x50 */ u8 dungeonItems[10]; // "key_compass_map" + /* 0x5A */ s8 dungeonKeys[10]; // "key_register" + /* 0x64 */ s8 strayFairies[10]; // "orange_fairy" + /* 0x6E */ char dekuPlaygroundPlayerName[3][8]; // "degnuts_memory_name" Stores playerName (8 char) over (3 days) when getting a new high score } Inventory; // size = 0x88 -typedef struct { - /* 0x00 */ s16 scene; - /* 0x02 */ Vec3s pos; - /* 0x08 */ s16 angle; +typedef struct HorseData { + /* 0x00 */ s16 scene; // "spot_no" + /* 0x02 */ Vec3s pos; // "horse_x", "horse_y" and "horse_z" + /* 0x08 */ s16 yaw; // "horse_a" } HorseData; // size = 0x0A -typedef struct { - /* 0x0 */ Vec3f pos; - /* 0xC */ s16 yaw; - /* 0xE */ s16 playerParams; +typedef struct RespawnData { + /* 0x00 */ Vec3f pos; + /* 0x0C */ s16 yaw; + /* 0x0E */ s16 playerParams; /* 0x10 */ u16 entranceIndex; /* 0x12 */ u8 roomIndex; /* 0x13 */ s8 data; - /* 0x14 */ u32 tempSwchFlags; + /* 0x14 */ u32 tempSwitchFlags; /* 0x18 */ u32 unk_18; /* 0x1C */ u32 tempCollectFlags; } RespawnData; // size = 0x20 -typedef struct { +typedef struct PermanentSceneFlags { /* 0x00 */ u32 chest; - /* 0x04 */ u32 swch0; - /* 0x08 */ u32 swch1; + /* 0x04 */ u32 switch0; + /* 0x08 */ u32 switch1; /* 0x0C */ u32 clearedRoom; /* 0x10 */ u32 collectible; /* 0x14 */ u32 unk_14; /* 0x18 */ u32 unk_18; } PermanentSceneFlags; // size = 0x1C -typedef struct { +typedef struct CycleSceneFlags { /* 0x00 */ u32 chest; - /* 0x04 */ u32 swch0; - /* 0x08 */ u32 swch1; + /* 0x04 */ u32 switch0; + /* 0x08 */ u32 switch1; /* 0x0C */ u32 clearedRoom; /* 0x10 */ u32 collectible; } CycleSceneFlags; // size = 0x14 -typedef struct { - /* 0x0000 */ u32 entranceIndex; // "scene_no" - /* 0x0004 */ u8 equippedMask; // "player_mask" - /* 0x0005 */ u8 unk_05; // "opening_flag" +typedef struct SaveOptions { + /* 0x00 */ u16 optionId; // "option_id" + /* 0x02 */ u8 language; // "j_n" + /* 0x03 */ s8 audioSetting; // "s_sound" + /* 0x04 */ u8 languageSetting; // "language" + /* 0x05 */ u8 zTargetSetting; // "z_attention", 0: Switch; 1: Hold +} SaveOptions; // size = 0x06 + +typedef struct SavePlayerData { + /* 0x0000 */ char newf[6]; // "newf" Will always be "ZELDA3 for a valid save + /* 0x0006 */ u16 deaths; // "savect" + /* 0x0008 */ char playerName[8]; // "player_name" + /* 0x0010 */ s16 healthCapacity; // "max_life" + /* 0x0012 */ s16 health; // "now_life" + /* 0x0014 */ s8 magicLevel; // "magic_max" + /* 0x0015 */ s8 magic; // "magic_now" + /* 0x0016 */ s16 rupees; // "lupy_count" + /* 0x0018 */ u16 swordHealth; // "long_sword_hp" + /* 0x001A */ u16 tatlTimer; // "navi_timer" + /* 0x001C */ u8 magicAcquired; // "magic_mode" + /* 0x001D */ u8 doubleMagic; // "magic_ability" + /* 0x001E */ u8 doubleDefense; // "life_ability" + /* 0x001F */ u8 unk_1F; // "ocarina_round" + /* 0x0020 */ u8 unk_20; // "first_memory" + /* 0x0022 */ u16 owlActivationFlags; // "memory_warp_point" + /* 0x0024 */ u8 unk_24; // "last_warp_pt" + /* 0x0026 */ s16 savedSceneNum; // "scene_data_ID" +} SavePlayerData; // size = 0x28 + +typedef struct Save { + /* 0x0000 */ u32 entranceIndex; // "scene_no" + /* 0x0004 */ u8 equippedMask; // "player_mask" + /* 0x0005 */ u8 isFirstCycle; // "opening_flag" /* 0x0006 */ u8 unk_06; - /* 0x0007 */ u8 linkAge; // "link_age" - /* 0x0008 */ s32 cutscene; // "day_time" - /* 0x000C */ u16 time; // "zelda_time" + /* 0x0007 */ u8 linkAge; // "link_age" + /* 0x0008 */ s32 cutscene; // "day_time" + /* 0x000C */ u16 time; // "zelda_time" /* 0x000E */ u16 owlSaveLocation; - /* 0x0010 */ s32 isNight; // "asahiru_fg" - /* 0x0014 */ u32 unk_14; // "change_zelda_time" - /* 0x0018 */ s32 day; // "totalday" - /* 0x001C */ u32 daysElapsed; // "eventday" - /* 0x0020 */ u8 playerForm; // "player_character" - /* 0x0021 */ u8 snowheadCleared; // "spring_flag" - /* 0x0022 */ u8 hasTatl; // "bell_flag" + /* 0x0010 */ s32 isNight; // "asahiru_fg" + /* 0x0014 */ u32 daySpeed; // "change_zelda_time" + /* 0x0018 */ s32 day; // "totalday" + /* 0x001C */ u32 daysElapsed; // "eventday" + /* 0x0020 */ u8 playerForm; // "player_character" + /* 0x0021 */ u8 snowheadCleared; // "spring_flag" + /* 0x0022 */ u8 hasTatl; // "bell_flag" /* 0x0023 */ u8 isOwlSave; - /* 0x0024 */ char newf[6]; // Will always be "ZELDA3" for a valid save - /* 0x002B */ u16 deaths; // "savect" - /* 0x002C */ char playerName[8]; // "player_name" - /* 0x0034 */ s16 healthCapacity; // "max_life" - /* 0x0036 */ s16 health; // "now_life" - /* 0x0038 */ s8 magicLevel; // "magic_max" - /* 0x0039 */ s8 magic; // "magic_now" - /* 0x003A */ s16 rupees; // "lupy_count" - /* 0x003C */ u16 swordHealth; // "long_sword_hp" - /* 0x003E */ u16 tatlTimer; // "navi_timer" - /* 0x0040 */ u8 magicAcquired; // "magic_mode" - /* 0x0041 */ u8 doubleMagic; // "magic_ability" - /* 0x0042 */ u8 doubleDefense; // "life_ability" - /* 0x0043 */ u8 unk_43; // "ocarina_round" - /* 0x0044 */ u8 unk_44; // "first_memory" - /* 0x0046 */ u16 owlActivationFlags; // "memory_warp_point" - /* 0x0048 */ u8 unk_48; // "last_warp_pt" - /* 0x004A */ s16 savedSceneNum; // "scene_data_ID" + /* 0x0024 */ SavePlayerData playerData; /* 0x004C */ ItemEquips equips; /* 0x0070 */ Inventory inventory; /* 0x00F8 */ PermanentSceneFlags permanentSceneFlags[120]; @@ -103,144 +146,167 @@ typedef struct { /* 0x0E7C */ u32 pictoFlags1; /* 0x0E80 */ u32 unk_E80; /* 0x0E84 */ u32 unk_E84; - /* 0x0E88 */ u32 unk_E88[7]; // Invadepoh flags - /* 0x0EA4 */ u32 scenesVisible[7]; // tingle maps and clouded regions on pause map. Stores scenes bitwise for up to 224 scenes even though there are not that many scenes - /* 0x0EC0 */ u32 skullTokenCount; // upper 16 bits store Swamp skulls, lower 16 bits store Ocean skulls - /* 0x0EC4 */ u32 unk_EC4; // Gossic stone heart piece flags + /* 0x0E88 */ u32 unk_E88[7]; // Invadepoh flags + /* 0x0EA4 */ u32 scenesVisible[7]; // tingle maps and clouded regions on pause map. Stores scenes bitwise for up to 224 scenes even though there are not that many scenes + /* 0x0EC0 */ u32 skullTokenCount; // upper 16 bits store Swamp skulls, lower 16 bits store Ocean skulls + /* 0x0EC4 */ u32 unk_EC4; // Gossic stone heart piece flags /* 0x0EC8 */ u32 unk_EC8; - /* 0x0ECC */ u32 unk_ECC[2]; // Related to blue warps - /* 0x0ED4 */ u32 stolenItems; // Items stolen by Takkuri and given to Curiosity Shop Man + /* 0x0ECC */ u32 unk_ECC[2]; // Related to blue warps + /* 0x0ED4 */ u32 stolenItems; // Items stolen by Takkuri and given to Curiosity Shop Man /* 0x0ED8 */ u32 unk_DD8; /* 0x0EDC */ u32 bankRupees; /* 0x0EE0 */ u32 unk_EE0; - /* 0x0EE4 */ u32 unk_EE4; // Fishing flags + /* 0x0EE4 */ u32 unk_EE4; // Fishing flags /* 0x0EE8 */ u32 unk_EE8; /* 0x0EEC */ u32 horseBackBalloonHighScore; - /* 0x0EF0 */ u32 lotteryCodeGuess; // Lottery code chosen by player (only uses lower three hex digits) - /* 0x0EF4 */ u32 unk_EF4; // Shooting Gallery Man Flags - /* 0x0EF8 */ u8 weekEventReg[100]; // "week_event_reg" - /* 0x0F5C */ u32 mapsVisited; // "area_arrival" - /* 0x0F60 */ u32 mapsVisible; // "cloud_clear" - /* 0x0F64 */ u8 unk_F64; // "oca_rec_flag" - /* 0x0F65 */ u8 unk_F65; // "oca_rec_flag8" - /* 0x0F66 */ u8 unk_F66[128]; // "oca_rec_buff8" - /* 0x0FE6 */ s8 unk_FE6; // "aikotoba_index" - /* 0x0FE7 */ s8 unk_FE7[5]; // "aikotoba_table" - /* 0x0FEC */ s8 lotteryCodes[3][3]; // Preset lottery codes "numbers_table" - /* 0x0FF5 */ s8 spiderHouseMaskOrder[6]; // "kinsta_color_table" - /* 0x0FFB */ s8 bomberCode[5]; // "bombers_aikotoba_table" + /* 0x0EF0 */ u32 lotteryCodeGuess; // Lottery code chosen by player (only uses lower three hex digits) + /* 0x0EF4 */ u32 unk_EF4; // Shooting Gallery Man Flags + /* 0x0EF8 */ u8 weekEventReg[100]; // "week_event_reg" + /* 0x0F5C */ u32 mapsVisited; // "area_arrival" + /* 0x0F60 */ u32 mapsVisible; // "cloud_clear" + /* 0x0F64 */ u8 unk_F64; // "oca_rec_flag" has scarecrows song + /* 0x0F65 */ u8 unk_F65; // "oca_rec_flag8" scarecrows song set? + /* 0x0F66 */ u8 scarecrowsSong[128]; + /* 0x0FE6 */ s8 bombersCaughtNum; // "aikotoba_index" + /* 0x0FE7 */ s8 bombersCaughtOrder[5]; // "aikotoba_table" + /* 0x0FEC */ s8 lotteryCodes[3][3]; // "numbers_table", Preset lottery codes + /* 0x0FF5 */ s8 spiderHouseMaskOrder[6]; // "kinsta_color_table" + /* 0x0FFB */ s8 bomberCode[5]; // "bombers_aikotoba_table" /* 0x1000 */ HorseData horseData; - /* 0x100A */ u16 checksum; // "check_sum" - /* 0x100C */ u8 eventInf[8]; - /* 0x1014 */ u8 unk_1014; // "stone_set_flag" + /* 0x100A */ u16 checksum; // "check_sum" +} Save; // size = 0x100C + +typedef struct SaveContext { + /* 0x0000 */ Save save; + /* 0x100C */ u8 eventInf[8]; // "event_inf" + /* 0x1014 */ u8 unk_1014; // "stone_set_flag" /* 0x1015 */ u8 unk_1015; /* 0x1016 */ u16 jinxTimer; - /* 0x1018 */ s16 rupeeAccumulator; // "lupy_udct" - /* 0x101A */ u8 unk_101A[6]; // "bottle_status", one entry for each bottle - /* 0x1020 */ OSTime unk_1020[6]; // "bottle_ostime", one entry for each bottle - /* 0x1050 */ OSTime unk_1050[6]; // "bottle_sub", one entry for each bottle - /* 0x1080 */ OSTime unk_1080[6]; // "bottle_time", one entry for each bottle - /* 0x10B0 */ OSTime unk_10B0[6]; // "bottle_stop_time", one entry for each bottle - /* 0x10E0 */ u64 pictoPhoto[1400]; // buffer containing the pictograph photo - /* 0x3CA0 */ s32 fileNum; // "file_no" - /* 0x3CA4 */ s16 powderKegTimer; // "big_bom_timer" + /* 0x1018 */ s16 rupeeAccumulator; // "lupy_udct" + /* 0x101A */ u8 unk_101A[6]; // "bottle_status", one entry for each bottle + /* 0x1020 */ OSTime unk_1020[6]; // "bottle_ostime", one entry for each bottle + /* 0x1050 */ OSTime unk_1050[6]; // "bottle_sub", one entry for each bottle + /* 0x1080 */ OSTime unk_1080[6]; // "bottle_time", one entry for each bottle + /* 0x10B0 */ OSTime unk_10B0[6]; // "bottle_stop_time", one entry for each bottle + /* 0x10E0 */ u64 pictoPhoto[1400]; // buffer containing the pictograph photo + /* 0x3CA0 */ s32 fileNum; // "file_no" + /* 0x3CA4 */ s16 powderKegTimer; // "big_bom_timer" /* 0x3CA6 */ u8 unk_3CA6; - /* 0x3CA7 */ u8 unk_3CA7; // "day_night_flag" - /* 0x3CA8 */ s32 gameMode; // "mode" - /* 0x3CAC */ s32 sceneSetupIndex; // "counter" - /* 0x3CB0 */ s32 respawnFlag; // "restart_flag" - /* 0x3CB4 */ RespawnData respawn[8]; // "restart_data" - /* 0x3DB4 */ f32 entranceSpeed; // "player_wipe_speedF" - /* 0x3DB8 */ u16 entranceSound; // "player_wipe_door_SE" - /* 0x3DBA */ u8 unk_3DBA; // "player_wipe_item" - /* 0x3DBB */ u8 unk_3DBB; // "next_walk" - /* 0x3DBC */ u16 dogParams; // "dog_flag" - /* 0x3DBE */ u8 textTriggerFlags; // "guide_status" - /* 0x3DBF */ u8 showTitleCard; // "name_display" - /* 0x3DC0 */ s16 unk_3DC0; // "shield_magic_timer" - /* 0x3DC2 */ u8 unk_3DC2; // "pad1" - /* 0x3DC8 */ OSTime unk_3DC8; // "get_time" - /* 0x3DD0 */ u8 unk_3DD0[7]; // "event_fg" - /* 0x3DD7 */ u8 unk_3DD7[7]; // "calc_flag" - /* 0x3DE0 */ OSTime unk_3DE0[7]; // "event_ostime" - /* 0x3E18 */ OSTime unk_3E18[7]; // "event_sub" - /* 0x3E50 */ OSTime unk_3E50[7]; // "func_time" - /* 0x3E88 */ OSTime unk_3E88[7]; // "func_end_time" - /* 0x3EC0 */ OSTime unk_3EC0[7]; // "func_stop_time" - /* 0x3EF8 */ s16 timerX[7]; // "event_xp" - /* 0x3F06 */ s16 timerY[7]; // "event_yp" - /* 0x3F14 */ s16 unk_3F14; // "character_change" - /* 0x3F16 */ u8 seqIndex; // "old_bgm" - /* 0x3F17 */ u8 nightSeqIndex; // "old_env" - /* 0x3F18 */ u8 buttonStatus[6]; // "button_item" - /* 0x3F1E */ u8 unk_3F1E; // "ck_fg" - /* 0x3F20 */ u16 unk_3F20; // "alpha_type" - /* 0x3F22 */ u16 unk_3F22; // "prev_alpha_type" - /* 0x3F24 */ u16 unk_3F24; // "alpha_count" - /* 0x3F26 */ u16 unk_3F26; // "last_time_type" - /* 0x3F28 */ s16 unk_3F28; // "magic_flag" - /* 0x3F2A */ s16 unk_3F2A; // "recovery_magic_flag" - /* 0x3F2C */ s16 unk_3F2C; // "keep_magic_flag" - /* 0x3F2E */ s16 unk_3F2E; // "magic_now_max" - /* 0x3F30 */ s16 unk_3F30; // "magic_now_now" - /* 0x3F32 */ s16 unk_3F32; // "magic_used" - /* 0x3F34 */ s16 unk_3F34; // "magic_recovery" - /* 0x3F36 */ u16 mapIndex; // "scene_ID" - /* 0x3F38 */ u16 minigameState; // "yabusame_mode" - /* 0x3F3A */ u16 minigameScore; // "yabusame_total" - /* 0x3F3C */ u16 unk_3F3C; // "yabusame_out_ct" - /* 0x3F3E */ u8 unk_3F3E; // "no_save" - /* 0x3F3F */ u8 unk_3F3F; // "flash_flag" - /* 0x3F40 */ u16 option_id; // "option_id" - /* 0x3F42 */ u8 language; // "j_n" - /* 0x3F43 */ u8 audioSetting; // "s_sound" - /* 0x3F44 */ u8 unk_3F44; // "language" - /* 0x3F45 */ u8 zTargetSetting; // 0: Switch; 1: Hold - /* 0x3F46 */ u16 unk_3F46; // "NottoriBgm" - /* 0x3F48 */ u8 unk_3F48; // "fade_go" - /* 0x3F4A */ u16 nextCutsceneIndex; // "next_daytime" - /* 0x3F4C */ u8 cutsceneTrigger; // "doukidemo" - /* 0x3F4D */ u8 unk_3F4D; // "Kenjya_no" - /* 0x3F4E */ u16 nextDayTime; // "next_zelda_time" - /* 0x3F50 */ u8 fadeDuration; // "fade_speed" - /* 0x3F51 */ u8 unk_3F51; // "wipe_speed" - /* 0x3F52 */ u16 environmentTime; // "kankyo_time" - /* 0x3F54 */ u8 dogIsLost; // "dog_event_flag" - /* 0x3F55 */ u8 nextTransition; // "next_wipe" - /* 0x3F56 */ s16 worldMapArea; // "area_type" - /* 0x3F58 */ s16 sunsSongState; // "sunmoon_flag" - /* 0x3F5A */ s16 healthAccumulator; // "life_mode" - /* 0x3F5C */ s32 unk_3F5C; // "bet_rupees" - /* 0x3F60 */ u8 unk_3F60; // "framescale_flag" - /* 0x3F64 */ f32 unk_3F64; // "framescale_scale" - /* 0x3F68 */ CycleSceneFlags cycleSceneFlags[120]; // Scene flags that are temporarily stored over the duration of a single 3-day cycle - /* 0x48C8 */ u16 unk_48C8; // "scene_id_mix" - /* 0x48CA */ u8 maskMaskBit[3]; // masks given away on the Moon - /* 0x48CD */ char unk_48CD[24]; + /* 0x3CA7 */ u8 unk_3CA7; // "day_night_flag" + /* 0x3CA8 */ s32 gameMode; // "mode" + /* 0x3CAC */ s32 sceneSetupIndex; // "counter" + /* 0x3CB0 */ s32 respawnFlag; // "restart_flag" + /* 0x3CB4 */ RespawnData respawn[RESPAWN_MODE_MAX]; // "restart_data" + /* 0x3DB4 */ f32 entranceSpeed; // "player_wipe_speedF" + /* 0x3DB8 */ u16 entranceSound; // "player_wipe_door_SE" + /* 0x3DBA */ u8 unk_3DBA; // "player_wipe_item" + /* 0x3DBB */ u8 unk_3DBB; // "next_walk" + /* 0x3DBC */ u16 dogParams; // "dog_flag" + /* 0x3DBE */ u8 textTriggerFlags; // "guide_status" + /* 0x3DBF */ u8 showTitleCard; // "name_display" + /* 0x3DC0 */ s16 unk_3DC0; // "shield_magic_timer" + /* 0x3DC2 */ u8 unk_3DC2; // "pad1" + /* 0x3DC8 */ OSTime unk_3DC8; // "get_time" + /* 0x3DD0 */ u8 unk_3DD0[7]; // "event_fg" + /* 0x3DD7 */ u8 unk_3DD7[7]; // "calc_flag" + /* 0x3DE0 */ OSTime unk_3DE0[7]; // "event_ostime" + /* 0x3E18 */ OSTime unk_3E18[7]; // "event_sub" + /* 0x3E50 */ OSTime unk_3E50[7]; // "func_time" + /* 0x3E88 */ OSTime unk_3E88[7]; // "func_end_time" + /* 0x3EC0 */ OSTime unk_3EC0[7]; // "func_stop_time" + /* 0x3EF8 */ s16 timerX[7]; // "event_xp" + /* 0x3F06 */ s16 timerY[7]; // "event_yp" + /* 0x3F14 */ s16 unk_3F14; // "character_change" + /* 0x3F16 */ u8 seqIndex; // "old_bgm" + /* 0x3F17 */ u8 nightSeqIndex; // "old_env" + /* 0x3F18 */ u8 buttonStatus[6]; // "button_item" + /* 0x3F1E */ u8 unk_3F1E; // "ck_fg" + /* 0x3F20 */ u16 unk_3F20; // "alpha_type" + /* 0x3F22 */ u16 unk_3F22; // "prev_alpha_type" + /* 0x3F24 */ u16 unk_3F24; // "alpha_count" + /* 0x3F26 */ u16 unk_3F26; // "last_time_type" + /* 0x3F28 */ s16 unk_3F28; // "magic_flag" + /* 0x3F2A */ s16 unk_3F2A; // "recovery_magic_flag" + /* 0x3F2C */ s16 unk_3F2C; // "keep_magic_flag" + /* 0x3F2E */ s16 unk_3F2E; // "magic_now_max" + /* 0x3F30 */ s16 unk_3F30; // "magic_now_now" + /* 0x3F32 */ s16 unk_3F32; // "magic_used" + /* 0x3F34 */ s16 unk_3F34; // "magic_recovery" + /* 0x3F36 */ u16 mapIndex; // "scene_ID" + /* 0x3F38 */ u16 minigameState; // "yabusame_mode" + /* 0x3F3A */ u16 minigameScore; // "yabusame_total" + /* 0x3F3C */ u16 unk_3F3C; // "yabusame_out_ct" + /* 0x3F3E */ u8 unk_3F3E; // "no_save" + /* 0x3F3F */ u8 unk_3F3F; // "flash_flag" + /* 0x3F40 */ SaveOptions options; + /* 0x3F46 */ u16 unk_3F46; // "NottoriBgm" + /* 0x3F48 */ u8 unk_3F48; // "fade_go" + /* 0x3F4A */ u16 nextCutsceneIndex; // "next_daytime" + /* 0x3F4C */ u8 cutsceneTrigger; // "doukidemo" + /* 0x3F4D */ u8 unk_3F4D; // "Kenjya_no" + /* 0x3F4E */ u16 nextDayTime; // "next_zelda_time" + /* 0x3F50 */ u8 fadeDuration; // "fade_speed" + /* 0x3F51 */ u8 fadeSpeed; // "wipe_speed" transition related + /* 0x3F52 */ u16 environmentTime; // "kankyo_time" + /* 0x3F54 */ u8 dogIsLost; // "dog_event_flag" + /* 0x3F55 */ u8 nextTransition; // "next_wipe" + /* 0x3F56 */ s16 worldMapArea; // "area_type" + /* 0x3F58 */ s16 sunsSongState; // "sunmoon_flag" + /* 0x3F5A */ s16 healthAccumulator; // "life_mode" + /* 0x3F5C */ s32 unk_3F5C; // "bet_rupees" + /* 0x3F60 */ u8 screenScaleFlag; // "framescale_flag" + /* 0x3F64 */ f32 screenScale; // "framescale_scale" + /* 0x3F68 */ CycleSceneFlags cycleSceneFlags[120]; // Scene flags that are temporarily stored over the duration of a single 3-day cycle + /* 0x48C8 */ u16 unk_48C8; // "scene_id_mix" + /* 0x48CA */ u8 maskMaskBit[27]; // "mask_mask_bit", masks given away on the Moon } SaveContext; // size = 0x48C8 -typedef enum { - /* 0x00 */ RESPAWN_MODE_VOID_OUT, - /* 0x01 */ RESPAWN_MODE_GROTTO, // Exiting a grotto - /* 0x02 */ RESPAWN_MODE_FARORES_WIND, // Unused in MM - /* 0x03 */ RESPAWN_MODE_GORON, - /* 0x04 */ RESPAWN_MODE_ZORA, - /* 0x05 */ RESPAWN_MODE_DEKU, - /* 0x06 */ RESPAWN_MODE_CHILD_LINK, - /* 0x07 */ RESPAWN_MODE_UNK_7, - /* 0x07 */ RESPAWN_MODE_UNK_8 -} RespawnMode; - -typedef enum { +typedef enum ButtonStatus { /* 0x00 */ BTN_ENABLED, /* 0xFF */ BTN_DISABLED = 0xFF } ButtonStatus; -typedef enum { +typedef enum SunsSongState { /* 0 */ SUNSSONG_INACTIVE, /* 1 */ SUNSSONG_START, // the suns ocarina effect signals that the song has finished playing /* 2 */ SUNSSONG_SPEED_TIME, // suns was played where time passes, speed up the advancement of time /* 3 */ SUNSSONG_SPECIAL // time does not advance, but signals the song was played. used for freezing redeads } SunsSongState; +void Sram_ActivateOwl(u8 owlId); +void Sram_ClearFlagsAtDawnOfTheFirstDay(void); +void Sram_SaveEndOfCycle(struct GlobalContext* globalCtx); +void Sram_IncrementDay(void); +u16 Sram_CalcChecksum(void* data, size_t count); +void Sram_InitNewSave(void); +void Sram_InitDebugSave(void); +void func_80144A94(SramContext* sramCtx); +void Sram_OpenSave(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); +void func_8014546C(SramContext* sramCtx); +void func_801457CC(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); +void func_80146580(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx, s32 fileNum); +void func_80146628(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); +void Sram_InitSave(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); +void func_80146DF8(SramContext* sramCtx); +void Sram_InitSram(struct GameState* gameState, SramContext* sramCtx); +void Sram_Alloc(struct GameState* gamestate, SramContext* sramCtx); +void Sram_SaveSpecialEnterClockTown(struct GlobalContext* globalCtx); +void Sram_SaveSpecialNewDay(struct GlobalContext* globalCtx); +void func_80147008(SramContext* sramCtx, u32 curPage, u32 numPages); +void func_80147020(SramContext* sramCtx); +void func_80147068(SramContext* sramCtx); +void func_80147138(SramContext* sramCtx, s32 curPage, s32 numPages); +void func_80147150(SramContext* sramCtx); +void func_80147198(SramContext* sramCtx); + +extern s32 D_801C6798[]; +extern u8 D_801C67B0[24]; +extern s32 D_801C67C8[]; +extern s32 D_801C67E8[]; +extern s32 D_801C67F0[]; +extern s32 D_801C6818[]; +extern s32 D_801C6838[]; +extern s32 D_801C6840[]; +extern s32 D_801C6850[]; + #endif diff --git a/include/z64scene.h b/include/z64scene.h index b20313198..5a1c39e16 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -645,7 +645,8 @@ typedef enum { /* 0x6D */ SCENE_ICHIBA, /* 0x6E */ SCENE_BACKTOWN, /* 0x6F */ SCENE_CLOCKTOWER, - /* 0x70 */ SCENE_ALLEY + /* 0x70 */ SCENE_ALLEY, + /* 0x71 */ SCENE_MAX } SceneID; // SceneTableEntry draw configs diff --git a/spec b/spec index 9de1886e0..152a2c41b 100644 --- a/spec +++ b/spec @@ -544,9 +544,8 @@ beginseg include "build/src/code/z_vr_box.o" include "build/src/code/z_vr_box_draw.o" include "build/src/code/z_sram_NES.o" - include "build/data/code/z_sram_NES.data.o" - include "build/data/code/z_sram_NES.bss.o" include "build/src/code/z_message.o" + 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" diff --git a/src/boot_O2_g3/idle_extra_bss.c b/src/boot_O2_g3/idle_extra_bss.c index 019b62640..24fc0083f 100644 --- a/src/boot_O2_g3/idle_extra_bss.c +++ b/src/boot_O2_g3/idle_extra_bss.c @@ -1,4 +1,5 @@ -#include "global.h" +#include "PR/ultratypes.h" +#include "ultra64/vi.h" // This file is currently required to fix bss reordering in idle.c. It is not resolved by prevent_bss_reordering.h . // Hopefully it will not be permanent. diff --git a/src/code/code_8012EC80.c b/src/code/code_8012EC80.c index f60d98568..5dee17fb5 100644 --- a/src/code/code_8012EC80.c +++ b/src/code/code_8012EC80.c @@ -504,7 +504,7 @@ void Inventory_ChangeEquipment(s16 value) { u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment) { Player* player = GET_PLAYER(globalCtx); - if (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) != 0) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { SET_EQUIP_VALUE(EQUIP_SHIELD, 0); Player_SetEquipmentData(globalCtx, player); return true; @@ -514,12 +514,12 @@ u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment) { } void Inventory_ChangeUpgrade(s16 upgrade, u32 value) { - u32 upgrades = gSaveContext.inventory.upgrades; + u32 upgrades = gSaveContext.save.inventory.upgrades; upgrades &= gUpgradeNegMasks[upgrade]; upgrades |= value << gUpgradeShifts[upgrade]; - gSaveContext.inventory.upgrades = upgrades; + gSaveContext.save.inventory.upgrades = upgrades; } s32 Inventory_IsMapVisible(s16 sceneNum) { @@ -546,7 +546,7 @@ s32 Inventory_IsMapVisible(s16 sceneNum) { } } - if (gSaveContext.scenesVisible[index] & gBitFlags[sceneNum - (index << 5)]) { + if (gSaveContext.save.scenesVisible[index] & gBitFlags[sceneNum - (index << 5)]) { return true; } @@ -659,23 +659,23 @@ void Inventory_SetMapVisibility(s16 tingleIndex) { index = 6; } - gSaveContext.scenesVisible[index] = - gSaveContext.scenesVisible[index] | gBitFlags[(s16)(*tingleMapSceneIndices)[i] - (index << 5)]; + gSaveContext.save.scenesVisible[index] = + gSaveContext.save.scenesVisible[index] | gBitFlags[(s16)(*tingleMapSceneIndices)[i] - (index << 5)]; i++; } if ((*tingleMapSceneIndices) == sScenesPerTingleMap[0]) { - gSaveContext.mapsVisible |= 3; + gSaveContext.save.mapsVisible |= 3; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[1]) { - gSaveContext.mapsVisible |= 0x1C; + gSaveContext.save.mapsVisible |= 0x1C; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[2]) { - gSaveContext.mapsVisible |= 0xE0; + gSaveContext.save.mapsVisible |= 0xE0; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[3]) { - gSaveContext.mapsVisible |= 0x100; + gSaveContext.save.mapsVisible |= 0x100; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[4]) { - gSaveContext.mapsVisible |= 0x1E00; + gSaveContext.save.mapsVisible |= 0x1E00; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[5]) { - gSaveContext.mapsVisible |= 0x6000; + gSaveContext.save.mapsVisible |= 0x6000; } } @@ -688,32 +688,34 @@ void Inventory_SetMapVisibility(s16 tingleIndex) { void Inventory_SaveDekuPlaygroundHighScore(s16 timerId) { s16 i; - gSaveContext.dekuPlaygroundHighScores[CURRENT_DAY - 1] = gSaveContext.unk_3DE0[timerId]; + gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1] = gSaveContext.unk_3DE0[timerId]; for (i = 0; i < 8; i++) { - gSaveContext.inventory.dekuPlaygroundPlayerName[CURRENT_DAY - 1][i] = gSaveContext.playerName[i]; + gSaveContext.save.inventory.dekuPlaygroundPlayerName[CURRENT_DAY - 1][i] = + gSaveContext.save.playerData.playerName[i]; } } void Inventory_IncrementSkullTokenCount(s16 sceneIndex) { if (sceneIndex == SCENE_KINSTA1) { // Swamp Spider House (increment high bits of skullTokenCount) - gSaveContext.skullTokenCount = ((u16)(((gSaveContext.skullTokenCount & 0xFFFF0000) >> 0x10) + 1) << 0x10) | - (gSaveContext.skullTokenCount & 0xFFFF); + gSaveContext.save.skullTokenCount = + ((u16)(((gSaveContext.save.skullTokenCount & 0xFFFF0000) >> 0x10) + 1) << 0x10) | + (gSaveContext.save.skullTokenCount & 0xFFFF); } else { // Ocean Spider House (increment low bits of skullTokenCount) - gSaveContext.skullTokenCount = - (((u16)gSaveContext.skullTokenCount + 1) & 0xFFFF) | (gSaveContext.skullTokenCount & 0xFFFF0000); + gSaveContext.save.skullTokenCount = + (((u16)gSaveContext.save.skullTokenCount + 1) & 0xFFFF) | (gSaveContext.save.skullTokenCount & 0xFFFF0000); } } s16 Inventory_GetSkullTokenCount(s16 sceneIndex) { if (sceneIndex == SCENE_KINSTA1) { // Swamp Spider House - return (gSaveContext.skullTokenCount & 0xFFFF0000) >> 0x10; + return (gSaveContext.save.skullTokenCount & 0xFFFF0000) >> 0x10; } else { // Ocean Spider House - return gSaveContext.skullTokenCount & 0xFFFF; + return gSaveContext.save.skullTokenCount & 0xFFFF; } } @@ -723,5 +725,6 @@ void Inventory_SaveLotteryCodeGuess(GlobalContext* globalCtx) { lotteryCodeGuess = ((globalCtx->msgCtx.unk12054[0] & 0xF) << 8); // First Digit lotteryCodeGuess |= ((globalCtx->msgCtx.unk12054[1] & 0xF) << 4); // Second Digit lotteryCodeGuess |= (globalCtx->msgCtx.unk12054[2] & 0xF); // Third Digit - gSaveContext.lotteryCodeGuess = (gSaveContext.lotteryCodeGuess & 0xFFFF0000) | (lotteryCodeGuess & 0xFFFF); + gSaveContext.save.lotteryCodeGuess = + (gSaveContext.save.lotteryCodeGuess & 0xFFFF0000) | (lotteryCodeGuess & 0xFFFF); } diff --git a/src/code/flg_set.c b/src/code/flg_set.c index 780884c85..53be7b68d 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -12,106 +12,106 @@ #include "global.h" static FlagSetEntry sFlagEntries[] = { - { &gSaveContext.weekEventReg[0], "week_event_reg[0]" }, - { &gSaveContext.weekEventReg[1], "week_event_reg[1]" }, - { &gSaveContext.weekEventReg[2], "week_event_reg[2]" }, - { &gSaveContext.weekEventReg[3], "week_event_reg[3]" }, - { &gSaveContext.weekEventReg[4], "week_event_reg[4]" }, - { &gSaveContext.weekEventReg[5], "week_event_reg[5]" }, - { &gSaveContext.weekEventReg[6], "week_event_reg[6]" }, - { &gSaveContext.weekEventReg[7], "week_event_reg[7]" }, - { &gSaveContext.weekEventReg[8], "week_event_reg[8]" }, - { &gSaveContext.weekEventReg[9], "week_event_reg[9]" }, - { &gSaveContext.weekEventReg[10], "week_event_reg[10]" }, - { &gSaveContext.weekEventReg[11], "week_event_reg[11]" }, - { &gSaveContext.weekEventReg[12], "week_event_reg[12]" }, - { &gSaveContext.weekEventReg[13], "week_event_reg[13]" }, - { &gSaveContext.weekEventReg[14], "week_event_reg[14]" }, - { &gSaveContext.weekEventReg[15], "week_event_reg[15]" }, - { &gSaveContext.weekEventReg[16], "week_event_reg[16]" }, - { &gSaveContext.weekEventReg[17], "week_event_reg[17]" }, - { &gSaveContext.weekEventReg[18], "week_event_reg[18]" }, - { &gSaveContext.weekEventReg[19], "week_event_reg[19]" }, - { &gSaveContext.weekEventReg[20], "week_event_reg[20]" }, - { &gSaveContext.weekEventReg[21], "week_event_reg[21]" }, - { &gSaveContext.weekEventReg[22], "week_event_reg[22]" }, - { &gSaveContext.weekEventReg[23], "week_event_reg[23]" }, - { &gSaveContext.weekEventReg[24], "week_event_reg[24]" }, - { &gSaveContext.weekEventReg[25], "week_event_reg[25]" }, - { &gSaveContext.weekEventReg[26], "week_event_reg[26]" }, - { &gSaveContext.weekEventReg[27], "week_event_reg[27]" }, - { &gSaveContext.weekEventReg[28], "week_event_reg[28]" }, - { &gSaveContext.weekEventReg[29], "week_event_reg[29]" }, - { &gSaveContext.weekEventReg[30], "week_event_reg[30]" }, - { &gSaveContext.weekEventReg[31], "week_event_reg[31]" }, - { &gSaveContext.weekEventReg[32], "week_event_reg[32]" }, - { &gSaveContext.weekEventReg[33], "week_event_reg[33]" }, - { &gSaveContext.weekEventReg[34], "week_event_reg[34]" }, - { &gSaveContext.weekEventReg[35], "week_event_reg[35]" }, - { &gSaveContext.weekEventReg[36], "week_event_reg[36]" }, - { &gSaveContext.weekEventReg[37], "week_event_reg[37]" }, - { &gSaveContext.weekEventReg[38], "week_event_reg[38]" }, - { &gSaveContext.weekEventReg[39], "week_event_reg[39]" }, - { &gSaveContext.weekEventReg[40], "week_event_reg[40]" }, - { &gSaveContext.weekEventReg[41], "week_event_reg[41]" }, - { &gSaveContext.weekEventReg[42], "week_event_reg[42]" }, - { &gSaveContext.weekEventReg[43], "week_event_reg[43]" }, - { &gSaveContext.weekEventReg[44], "week_event_reg[44]" }, - { &gSaveContext.weekEventReg[45], "week_event_reg[45]" }, - { &gSaveContext.weekEventReg[46], "week_event_reg[46]" }, - { &gSaveContext.weekEventReg[47], "week_event_reg[47]" }, - { &gSaveContext.weekEventReg[48], "week_event_reg[48]" }, - { &gSaveContext.weekEventReg[49], "week_event_reg[49]" }, - { &gSaveContext.weekEventReg[50], "week_event_reg[50]" }, - { &gSaveContext.weekEventReg[51], "week_event_reg[51]" }, - { &gSaveContext.weekEventReg[52], "week_event_reg[52]" }, - { &gSaveContext.weekEventReg[53], "week_event_reg[53]" }, - { &gSaveContext.weekEventReg[54], "week_event_reg[54]" }, - { &gSaveContext.weekEventReg[55], "week_event_reg[55]" }, - { &gSaveContext.weekEventReg[56], "week_event_reg[56]" }, - { &gSaveContext.weekEventReg[57], "week_event_reg[57]" }, - { &gSaveContext.weekEventReg[58], "week_event_reg[58]" }, - { &gSaveContext.weekEventReg[59], "week_event_reg[59]" }, - { &gSaveContext.weekEventReg[60], "week_event_reg[60]" }, - { &gSaveContext.weekEventReg[61], "week_event_reg[61]" }, - { &gSaveContext.weekEventReg[62], "week_event_reg[62]" }, - { &gSaveContext.weekEventReg[63], "week_event_reg[63]" }, - { &gSaveContext.weekEventReg[64], "week_event_reg[64]" }, - { &gSaveContext.weekEventReg[65], "week_event_reg[65]" }, - { &gSaveContext.weekEventReg[66], "week_event_reg[66]" }, - { &gSaveContext.weekEventReg[67], "week_event_reg[67]" }, - { &gSaveContext.weekEventReg[68], "week_event_reg[68]" }, - { &gSaveContext.weekEventReg[69], "week_event_reg[69]" }, - { &gSaveContext.weekEventReg[70], "week_event_reg[70]" }, - { &gSaveContext.weekEventReg[71], "week_event_reg[71]" }, - { &gSaveContext.weekEventReg[72], "week_event_reg[72]" }, - { &gSaveContext.weekEventReg[73], "week_event_reg[73]" }, - { &gSaveContext.weekEventReg[74], "week_event_reg[74]" }, - { &gSaveContext.weekEventReg[75], "week_event_reg[75]" }, - { &gSaveContext.weekEventReg[76], "week_event_reg[76]" }, - { &gSaveContext.weekEventReg[77], "week_event_reg[77]" }, - { &gSaveContext.weekEventReg[78], "week_event_reg[78]" }, - { &gSaveContext.weekEventReg[79], "week_event_reg[79]" }, - { &gSaveContext.weekEventReg[80], "week_event_reg[80]" }, - { &gSaveContext.weekEventReg[81], "week_event_reg[81]" }, - { &gSaveContext.weekEventReg[82], "week_event_reg[82]" }, - { &gSaveContext.weekEventReg[83], "week_event_reg[83]" }, - { &gSaveContext.weekEventReg[84], "week_event_reg[84]" }, - { &gSaveContext.weekEventReg[85], "week_event_reg[85]" }, - { &gSaveContext.weekEventReg[86], "week_event_reg[86]" }, - { &gSaveContext.weekEventReg[87], "week_event_reg[87]" }, - { &gSaveContext.weekEventReg[88], "week_event_reg[88]" }, - { &gSaveContext.weekEventReg[89], "week_event_reg[89]" }, - { &gSaveContext.weekEventReg[90], "week_event_reg[90]" }, - { &gSaveContext.weekEventReg[91], "week_event_reg[91]" }, - { &gSaveContext.weekEventReg[92], "week_event_reg[92]" }, - { &gSaveContext.weekEventReg[93], "week_event_reg[93]" }, - { &gSaveContext.weekEventReg[94], "week_event_reg[94]" }, - { &gSaveContext.weekEventReg[95], "week_event_reg[95]" }, - { &gSaveContext.weekEventReg[96], "week_event_reg[96]" }, - { &gSaveContext.weekEventReg[97], "week_event_reg[97]" }, - { &gSaveContext.weekEventReg[98], "week_event_reg[98]" }, - { &gSaveContext.weekEventReg[99], "week_event_reg[99]" }, + { &gSaveContext.save.weekEventReg[0], "week_event_reg[0]" }, + { &gSaveContext.save.weekEventReg[1], "week_event_reg[1]" }, + { &gSaveContext.save.weekEventReg[2], "week_event_reg[2]" }, + { &gSaveContext.save.weekEventReg[3], "week_event_reg[3]" }, + { &gSaveContext.save.weekEventReg[4], "week_event_reg[4]" }, + { &gSaveContext.save.weekEventReg[5], "week_event_reg[5]" }, + { &gSaveContext.save.weekEventReg[6], "week_event_reg[6]" }, + { &gSaveContext.save.weekEventReg[7], "week_event_reg[7]" }, + { &gSaveContext.save.weekEventReg[8], "week_event_reg[8]" }, + { &gSaveContext.save.weekEventReg[9], "week_event_reg[9]" }, + { &gSaveContext.save.weekEventReg[10], "week_event_reg[10]" }, + { &gSaveContext.save.weekEventReg[11], "week_event_reg[11]" }, + { &gSaveContext.save.weekEventReg[12], "week_event_reg[12]" }, + { &gSaveContext.save.weekEventReg[13], "week_event_reg[13]" }, + { &gSaveContext.save.weekEventReg[14], "week_event_reg[14]" }, + { &gSaveContext.save.weekEventReg[15], "week_event_reg[15]" }, + { &gSaveContext.save.weekEventReg[16], "week_event_reg[16]" }, + { &gSaveContext.save.weekEventReg[17], "week_event_reg[17]" }, + { &gSaveContext.save.weekEventReg[18], "week_event_reg[18]" }, + { &gSaveContext.save.weekEventReg[19], "week_event_reg[19]" }, + { &gSaveContext.save.weekEventReg[20], "week_event_reg[20]" }, + { &gSaveContext.save.weekEventReg[21], "week_event_reg[21]" }, + { &gSaveContext.save.weekEventReg[22], "week_event_reg[22]" }, + { &gSaveContext.save.weekEventReg[23], "week_event_reg[23]" }, + { &gSaveContext.save.weekEventReg[24], "week_event_reg[24]" }, + { &gSaveContext.save.weekEventReg[25], "week_event_reg[25]" }, + { &gSaveContext.save.weekEventReg[26], "week_event_reg[26]" }, + { &gSaveContext.save.weekEventReg[27], "week_event_reg[27]" }, + { &gSaveContext.save.weekEventReg[28], "week_event_reg[28]" }, + { &gSaveContext.save.weekEventReg[29], "week_event_reg[29]" }, + { &gSaveContext.save.weekEventReg[30], "week_event_reg[30]" }, + { &gSaveContext.save.weekEventReg[31], "week_event_reg[31]" }, + { &gSaveContext.save.weekEventReg[32], "week_event_reg[32]" }, + { &gSaveContext.save.weekEventReg[33], "week_event_reg[33]" }, + { &gSaveContext.save.weekEventReg[34], "week_event_reg[34]" }, + { &gSaveContext.save.weekEventReg[35], "week_event_reg[35]" }, + { &gSaveContext.save.weekEventReg[36], "week_event_reg[36]" }, + { &gSaveContext.save.weekEventReg[37], "week_event_reg[37]" }, + { &gSaveContext.save.weekEventReg[38], "week_event_reg[38]" }, + { &gSaveContext.save.weekEventReg[39], "week_event_reg[39]" }, + { &gSaveContext.save.weekEventReg[40], "week_event_reg[40]" }, + { &gSaveContext.save.weekEventReg[41], "week_event_reg[41]" }, + { &gSaveContext.save.weekEventReg[42], "week_event_reg[42]" }, + { &gSaveContext.save.weekEventReg[43], "week_event_reg[43]" }, + { &gSaveContext.save.weekEventReg[44], "week_event_reg[44]" }, + { &gSaveContext.save.weekEventReg[45], "week_event_reg[45]" }, + { &gSaveContext.save.weekEventReg[46], "week_event_reg[46]" }, + { &gSaveContext.save.weekEventReg[47], "week_event_reg[47]" }, + { &gSaveContext.save.weekEventReg[48], "week_event_reg[48]" }, + { &gSaveContext.save.weekEventReg[49], "week_event_reg[49]" }, + { &gSaveContext.save.weekEventReg[50], "week_event_reg[50]" }, + { &gSaveContext.save.weekEventReg[51], "week_event_reg[51]" }, + { &gSaveContext.save.weekEventReg[52], "week_event_reg[52]" }, + { &gSaveContext.save.weekEventReg[53], "week_event_reg[53]" }, + { &gSaveContext.save.weekEventReg[54], "week_event_reg[54]" }, + { &gSaveContext.save.weekEventReg[55], "week_event_reg[55]" }, + { &gSaveContext.save.weekEventReg[56], "week_event_reg[56]" }, + { &gSaveContext.save.weekEventReg[57], "week_event_reg[57]" }, + { &gSaveContext.save.weekEventReg[58], "week_event_reg[58]" }, + { &gSaveContext.save.weekEventReg[59], "week_event_reg[59]" }, + { &gSaveContext.save.weekEventReg[60], "week_event_reg[60]" }, + { &gSaveContext.save.weekEventReg[61], "week_event_reg[61]" }, + { &gSaveContext.save.weekEventReg[62], "week_event_reg[62]" }, + { &gSaveContext.save.weekEventReg[63], "week_event_reg[63]" }, + { &gSaveContext.save.weekEventReg[64], "week_event_reg[64]" }, + { &gSaveContext.save.weekEventReg[65], "week_event_reg[65]" }, + { &gSaveContext.save.weekEventReg[66], "week_event_reg[66]" }, + { &gSaveContext.save.weekEventReg[67], "week_event_reg[67]" }, + { &gSaveContext.save.weekEventReg[68], "week_event_reg[68]" }, + { &gSaveContext.save.weekEventReg[69], "week_event_reg[69]" }, + { &gSaveContext.save.weekEventReg[70], "week_event_reg[70]" }, + { &gSaveContext.save.weekEventReg[71], "week_event_reg[71]" }, + { &gSaveContext.save.weekEventReg[72], "week_event_reg[72]" }, + { &gSaveContext.save.weekEventReg[73], "week_event_reg[73]" }, + { &gSaveContext.save.weekEventReg[74], "week_event_reg[74]" }, + { &gSaveContext.save.weekEventReg[75], "week_event_reg[75]" }, + { &gSaveContext.save.weekEventReg[76], "week_event_reg[76]" }, + { &gSaveContext.save.weekEventReg[77], "week_event_reg[77]" }, + { &gSaveContext.save.weekEventReg[78], "week_event_reg[78]" }, + { &gSaveContext.save.weekEventReg[79], "week_event_reg[79]" }, + { &gSaveContext.save.weekEventReg[80], "week_event_reg[80]" }, + { &gSaveContext.save.weekEventReg[81], "week_event_reg[81]" }, + { &gSaveContext.save.weekEventReg[82], "week_event_reg[82]" }, + { &gSaveContext.save.weekEventReg[83], "week_event_reg[83]" }, + { &gSaveContext.save.weekEventReg[84], "week_event_reg[84]" }, + { &gSaveContext.save.weekEventReg[85], "week_event_reg[85]" }, + { &gSaveContext.save.weekEventReg[86], "week_event_reg[86]" }, + { &gSaveContext.save.weekEventReg[87], "week_event_reg[87]" }, + { &gSaveContext.save.weekEventReg[88], "week_event_reg[88]" }, + { &gSaveContext.save.weekEventReg[89], "week_event_reg[89]" }, + { &gSaveContext.save.weekEventReg[90], "week_event_reg[90]" }, + { &gSaveContext.save.weekEventReg[91], "week_event_reg[91]" }, + { &gSaveContext.save.weekEventReg[92], "week_event_reg[92]" }, + { &gSaveContext.save.weekEventReg[93], "week_event_reg[93]" }, + { &gSaveContext.save.weekEventReg[94], "week_event_reg[94]" }, + { &gSaveContext.save.weekEventReg[95], "week_event_reg[95]" }, + { &gSaveContext.save.weekEventReg[96], "week_event_reg[96]" }, + { &gSaveContext.save.weekEventReg[97], "week_event_reg[97]" }, + { &gSaveContext.save.weekEventReg[98], "week_event_reg[98]" }, + { &gSaveContext.save.weekEventReg[99], "week_event_reg[99]" }, { &gSaveContext.eventInf[0], "event_inf[0]" }, { &gSaveContext.eventInf[1], "event_inf[1]" }, @@ -245,8 +245,8 @@ void FlagSet_Update(GameState* gameState) { if (CHECK_BTN_ALL(input->cur.button, BTN_START)) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { s16 i; - for (i = 0; i < ARRAY_COUNT(gSaveContext.weekEventReg); i++) { - gSaveContext.weekEventReg[i] = 0; + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.weekEventReg); i++) { + gSaveContext.save.weekEventReg[i] = 0; } for (i = 0; i < ARRAY_COUNT(gSaveContext.eventInf); i++) { gSaveContext.eventInf[i] = 0; diff --git a/src/code/sched.c b/src/code/sched.c index 5f9cdf236..927a48f66 100644 --- a/src/code/sched.c +++ b/src/code/sched.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #define RSP_DONE_MSG 667 diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 6b7c863aa..a0f479f54 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -2224,7 +2224,7 @@ void func_800B90F4(GlobalContext* globalCtx) { void func_800B9120(ActorContext* actorCtx) { s32 phi_v0 = CURRENT_DAY * 2; - if (gSaveContext.time < CLOCK_TIME(6, 0) || gSaveContext.time > CLOCK_TIME(18, 0)) { + if (gSaveContext.save.time < CLOCK_TIME(6, 0) || gSaveContext.save.time > CLOCK_TIME(18, 0)) { phi_v0++; } @@ -2236,7 +2236,7 @@ void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEn CycleSceneFlags* cycleFlags; s32 i; - gSaveContext.weekEventReg[92] |= 0x80; + gSaveContext.save.weekEventReg[92] |= 0x80; cycleFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(globalCtx->sceneNum)]; bzero(actorCtx, sizeof(ActorContext)); @@ -2252,8 +2252,8 @@ void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEn } actorCtx->flags.chest = cycleFlags->chest; - actorCtx->flags.switches[0] = cycleFlags->swch0; - actorCtx->flags.switches[1] = cycleFlags->swch1; + actorCtx->flags.switches[0] = cycleFlags->switch0; + actorCtx->flags.switches[1] = cycleFlags->switch1; if (globalCtx->sceneNum == SCENE_INISIE_R) { cycleFlags = &gSaveContext.cycleSceneFlags[globalCtx->sceneNum]; } diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 910458b77..b2891de90 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -6,11 +6,11 @@ #define DYNA_RAYCAST_WALLS 2 #define DYNA_RAYCAST_CEILINGS 4 -static u32 sWallFlags[32] = { +u32 sWallFlags[32] = { 0, 1, 3, 5, 8, 16, 32, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -static u16 sSurfaceTypeSfx[] = { +u16 sSurfaceTypeSfx[] = { /* 0x00 */ NA_SE_PL_WALK_GROUND - SFX_FLAG, /* 0x01 */ NA_SE_PL_WALK_SAND - SFX_FLAG, /* 0x02 */ NA_SE_PL_WALK_CONCRETE - SFX_FLAG, @@ -28,7 +28,7 @@ static u16 sSurfaceTypeSfx[] = { /* 0x0E */ NA_SE_PL_WALK_SNOW - SFX_FLAG }; -static u8 D_801B46C0[] = { +u8 D_801B46C0[] = { /* 0x00 */ 1, /* 0x01 */ 1, /* 0x02 */ 0, @@ -46,7 +46,7 @@ static u8 D_801B46C0[] = { /* 0x0E */ 1 }; -static s16 sSmallMemScenes[] = { +s16 sSmallMemScenes[] = { SCENE_F01, }; @@ -55,7 +55,7 @@ typedef struct { u32 memSize; } BgCheckSceneMemEntry; -static BgCheckSceneMemEntry sSceneMemList[] = { +BgCheckSceneMemEntry sSceneMemList[] = { { SCENE_00KEIKOKU, 0xC800 }, }; diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index 26fd324a7..3860cf153 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -3,8 +3,9 @@ SaveContext gSaveContext; void SaveContext_Init(void) { - bzero(&gSaveContext, sizeof(gSaveContext)); - gSaveContext.playerForm = 0; + bzero(&gSaveContext, sizeof(SaveContext)); + + gSaveContext.save.playerForm = 0; gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.unk_3F46 = NA_BGM_GENERAL_SFX; @@ -16,7 +17,8 @@ void SaveContext_Init(void) { gSaveContext.dogIsLost = true; gSaveContext.nextTransition = 0xFF; gSaveContext.unk_3F26 = 50; - gSaveContext.language = 1; - gSaveContext.audioSetting = 0; - gSaveContext.zTargetSetting = 0; + + gSaveContext.options.language = 1; + gSaveContext.options.audioSetting = 0; + gSaveContext.options.zTargetSetting = 0; } diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 23dd435ec..e486bc769 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -68,7 +68,7 @@ CutsceneStateHandler sCsStateHandlers1[] = { }; void Cutscene_Update1(GlobalContext* globalCtx, CutsceneContext* csCtx) { - if (gSaveContext.cutscene < 0xFFF0) { + if (gSaveContext.save.cutscene < 0xFFF0) { sCsStateHandlers1[csCtx->state](globalCtx, csCtx); } } @@ -87,11 +87,11 @@ void Cutscene_Update2(GlobalContext* globalCtx, CutsceneContext* csCtx) { } if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_0)) { - gSaveContext.cutscene = 0xFFFD; + gSaveContext.save.cutscene = 0xFFFD; gSaveContext.cutsceneTrigger = 1; } - if (gSaveContext.cutscene >= 0xFFF0) { + if (gSaveContext.save.cutscene >= 0xFFF0) { func_800EDA84(globalCtx, csCtx); sCsStateHandlers2[csCtx->state](globalCtx, csCtx); } @@ -250,12 +250,12 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs gSaveContext.sunsSongState = SUNSSONG_START; break; case 0x12: - if (!gSaveContext.isNight) { - time = gSaveContext.time; - gSaveContext.time = time - (u16)REG(15); + if (!gSaveContext.save.isNight) { + time = gSaveContext.save.time; + gSaveContext.save.time = time - (u16)REG(15); } else { - time = gSaveContext.time; - gSaveContext.time = time - (u16)(2 * REG(15)); + time = gSaveContext.save.time; + gSaveContext.save.time = time - (u16)(2 * REG(15)); } break; case 0x13: @@ -270,7 +270,7 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs EnvFlags_Set(globalCtx, 4); break; case 0x16: - gSaveContext.playerForm = PLAYER_FORM_DEKU; + gSaveContext.save.playerForm = PLAYER_FORM_DEKU; break; case 0x17: player->stateFlags2 |= 0x4000000; @@ -279,9 +279,9 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs player->stateFlags2 &= ~0x4000000; break; case 0x19: - sCutsceneStoredPlayerForm = gSaveContext.playerForm; - gSaveContext.playerForm = PLAYER_FORM_HUMAN; - gSaveContext.equippedMask = PLAYER_MASK_NONE; + sCutsceneStoredPlayerForm = gSaveContext.save.playerForm; + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.save.equippedMask = PLAYER_MASK_NONE; break; case 0x1A: func_8019F128(NA_SE_EV_EARTHQUAKE_LAST2 - SFX_FLAG); @@ -306,7 +306,7 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs } break; case 0x1D: - gSaveContext.playerForm = sCutsceneStoredPlayerForm; + gSaveContext.save.playerForm = sCutsceneStoredPlayerForm; break; case 0x1E: D_801F4DE0 = true; @@ -316,7 +316,7 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs break; case 0x21: if (isStartFrame) { - func_80146EE8(globalCtx); + Sram_SaveSpecialEnterClockTown(globalCtx); } break; case 0x22: @@ -329,10 +329,10 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs D_801BB15C = csCtx->frames; if (REG(15) != 0) { - time = gSaveContext.time; - gSaveContext.time = (u16)REG(15) + time; - time = gSaveContext.time; - gSaveContext.time = (u16)gSaveContext.unk_14 + time; + time = gSaveContext.save.time; + gSaveContext.save.time = (u16)REG(15) + time; + time = gSaveContext.save.time; + gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + time; } } break; @@ -349,7 +349,7 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs case 0x26: // Seems to be used to trigger "Dawn of A New Day" - gSaveContext.day = 9; + gSaveContext.save.day = 9; { GameState* gameState = &globalCtx->state; @@ -357,11 +357,11 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs } SET_NEXT_GAMESTATE(&globalCtx->state, Daytelop_Init, DaytelopContext); - func_80146F5C(globalCtx); + Sram_SaveSpecialNewDay(globalCtx); break; case 0x27: - gSaveContext.playerForm = PLAYER_FORM_ZORA; + gSaveContext.save.playerForm = PLAYER_FORM_ZORA; break; case 0x28: @@ -442,7 +442,7 @@ void func_800EADB0(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* u8 dayMinusOne; if (csCtx->frames == cmd->startFrame) { - dayMinusOne = (gSaveContext.day - 1); + dayMinusOne = (gSaveContext.save.day - 1); if (dayMinusOne >= 3) { dayMinusOne = 0; } @@ -557,7 +557,7 @@ void Cutscene_Command_SetTime(GlobalContext* globalCtx, CutsceneContext* csCtx, minutes = CLOCK_TIME_ALT_F(0, cmd->minute + 1); nextTime = hourAsMinutes + minutes; - gSaveContext.time = nextTime; + gSaveContext.save.time = nextTime; gSaveContext.environmentTime = nextTime; } } @@ -572,7 +572,7 @@ void Cutscene_TerminatorImpl(GlobalContext* globalCtx, CutsceneContext* csCtx, C gSaveContext.unk_3F1E = 1; } - gSaveContext.cutscene = 0; + gSaveContext.save.cutscene = 0; if (cmd->base == 1) { globalCtx->nextEntranceIndex = globalCtx->csCtx.sceneCsList[globalCtx->csCtx.currentCsIndex].nextEntranceIndex; gSaveContext.nextCutsceneIndex = 0; @@ -607,7 +607,7 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt switch (D_801F4DE2) { case 0x1F: - if (gSaveContext.weekEventReg[0x14] & 2) { + if (gSaveContext.save.weekEventReg[20] & 2) { globalCtx->nextEntranceIndex = 0x3010; globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 3; @@ -620,7 +620,7 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt break; case 0x44: - if (gSaveContext.weekEventReg[0x21] & 0x80) { + if (gSaveContext.save.weekEventReg[33] & 0x80) { globalCtx->nextEntranceIndex = 0xAE70; globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 3; @@ -633,7 +633,7 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt break; case 0x5F: - gSaveContext.weekEventReg[0x37] |= 0x80; + gSaveContext.save.weekEventReg[55] |= 0x80; globalCtx->nextEntranceIndex = 0x6A80; gSaveContext.nextCutsceneIndex = 0xFFF0; globalCtx->sceneLoadFlag = 0x14; @@ -641,7 +641,7 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt break; case 0x36: - gSaveContext.weekEventReg[0x34] |= 0x20; + gSaveContext.save.weekEventReg[52] |= 0x20; globalCtx->nextEntranceIndex = 0x2000; gSaveContext.nextCutsceneIndex = 0xFFF1; globalCtx->sceneLoadFlag = 0x14; @@ -813,7 +813,7 @@ void Cutscene_Command_GiveTatlToPlayer(GlobalContext* globalCtx, CutsceneContext if (csCtx->frames == cmd->startFrame) { if (cmd->base == 1) { - gSaveContext.hasTatl = true; + gSaveContext.save.hasTatl = true; if (player->tatlActor != NULL) { return; } @@ -1093,7 +1093,7 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, } } - if (dialogState == 5 && Message_ShouldAdvance(globalCtx) != 0) { + if (dialogState == 5 && Message_ShouldAdvance(globalCtx)) { func_80152434(globalCtx, cmd->base); } } @@ -1424,7 +1424,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, /* End of command handling section */ void func_800ED980(GlobalContext* globalCtx, CutsceneContext* csCtx) { - if (gSaveContext.cutscene >= 0xFFF0) { + if (gSaveContext.save.cutscene >= 0xFFF0) { csCtx->frames++; Cutscene_ProcessCommands(globalCtx, csCtx, (u8*)globalCtx->csCtx.csData); } @@ -1448,7 +1448,7 @@ void func_800EDA04(GlobalContext* globalCtx, CutsceneContext* csCtx) { csCtx->actorActions[i] = NULL; } - gSaveContext.cutscene = 0; + gSaveContext.save.cutscene = 0; gSaveContext.gameMode = 0; ActorCutscene_Stop(0x7F); Audio_SetCutsceneFlag(false); @@ -1458,10 +1458,10 @@ void func_800EDA04(GlobalContext* globalCtx, CutsceneContext* csCtx) { void func_800EDA84(GlobalContext* globalCtx, CutsceneContext* csCtx) { if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_0) && !Player_InCsMode(&globalCtx->state)) { - gSaveContext.cutscene = 0xFFFD; + gSaveContext.save.cutscene = 0xFFFD; } - if ((gSaveContext.cutscene >= 0xFFF0) && (csCtx->state == CS_STATE_0)) { + if ((gSaveContext.save.cutscene >= 0xFFF0) && (csCtx->state == CS_STATE_0)) { s16 i; D_801BB124 = 0; @@ -1515,8 +1515,9 @@ void func_800EDBE0(GlobalContext* globalCtx) { ActorCutscene_Start(sp2A, NULL); gSaveContext.showTitleCard = false; } else if (!((1 << (temp_a3[temp_v0_3].unk7 % 8)) & - gSaveContext.weekEventReg[temp_a3[temp_v0_3].unk7 / 8])) { - gSaveContext.weekEventReg[(temp_a3[temp_v0_3].unk7 / 8)] |= 1 << (temp_a3[temp_v0_3].unk7 % 8); + gSaveContext.save.weekEventReg[temp_a3[temp_v0_3].unk7 / 8])) { + gSaveContext.save.weekEventReg[(temp_a3[temp_v0_3].unk7 / 8)] |= + 1 << (temp_a3[temp_v0_3].unk7 % 8); ActorCutscene_Start(sp2A, NULL); gSaveContext.showTitleCard = false; } @@ -1530,8 +1531,8 @@ void func_800EDBE0(GlobalContext* globalCtx) { if ((gSaveContext.respawnFlag == 0) || (gSaveContext.respawnFlag == -2)) { sp24 = globalCtx->loadedScene; if ((sp24->titleTextId != 0) && gSaveContext.showTitleCard) { - if ((Entrance_GetTransitionFlags(gSaveContext.sceneSetupIndex + gSaveContext.entranceIndex) & 0x4000) != - 0) { + if ((Entrance_GetTransitionFlags(gSaveContext.sceneSetupIndex + gSaveContext.save.entranceIndex) & + 0x4000) != 0) { func_80151A68(globalCtx, sp24->titleTextId); } } diff --git a/src/code/z_elf_message.c b/src/code/z_elf_message.c index 7308b33f4..cd2fa96b6 100644 --- a/src/code/z_elf_message.c +++ b/src/code/z_elf_message.c @@ -7,17 +7,17 @@ u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) { if (CURRENT_DAY <= 0) { return 0; } - if (gSaveContext.weekEventReg[88] & 0x20) { + if (gSaveContext.save.weekEventReg[88] & 0x20) { return 0; } - if (gSaveContext.weekEventReg[79] & 0x10) { - if (gSaveContext.weekEventReg[8] & 0x40) { + if (gSaveContext.save.weekEventReg[79] & 0x10) { + if (gSaveContext.save.weekEventReg[8] & 0x40) { return 0; } return 0x224; } - if (!(gSaveContext.weekEventReg[8] & 0x80)) { - if (gSaveContext.weekEventReg[9] & 1) { + if (!(gSaveContext.save.weekEventReg[8] & 0x80)) { + if (gSaveContext.save.weekEventReg[9] & 1) { return 0x21E; } if (globalCtx->sceneNum == SCENE_YOUSEI_IZUMI) { @@ -25,7 +25,7 @@ u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) { } return 0x21D; } - if (gSaveContext.magicAcquired != true) { + if (gSaveContext.save.playerData.magicAcquired != true) { return 0x21F; } if (INV_CONTENT(ITEM_DEED_LAND) == ITEM_DEED_LAND) { @@ -35,27 +35,27 @@ u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) { return 0; } if (INV_CONTENT(ITEM_MOON_TEAR) == ITEM_MOON_TEAR) { - if (gSaveContext.weekEventReg[86] & 4) { + if (gSaveContext.save.weekEventReg[86] & 4) { return 0x242; } return 0x243; } - if (gSaveContext.weekEventReg[74] & 0x20) { + if (gSaveContext.save.weekEventReg[74] & 0x20) { return 0x223; } - if (gSaveContext.weekEventReg[73] & 0x80) { + if (gSaveContext.save.weekEventReg[73] & 0x80) { return 0x222; } - if (gSaveContext.weekEventReg[73] & 0x20) { + if (gSaveContext.save.weekEventReg[73] & 0x20) { return 0x221; } - if (gSaveContext.weekEventReg[77] & 2) { - if (gSaveContext.weekEventReg[73] & 0x10) { + if (gSaveContext.save.weekEventReg[77] & 2) { + if (gSaveContext.save.weekEventReg[73] & 0x10) { return 0x240; } return 0x241; } - if ((gSaveContext.weekEventReg[86] & 2) || (gSaveContext.weekEventReg[73] & 0x40)) { + if ((gSaveContext.save.weekEventReg[86] & 2) || (gSaveContext.save.weekEventReg[73] & 0x40)) { return 0x23F; } return 0x220; diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 5c8a75f98..b8fa0f4f1 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -822,13 +822,14 @@ s16 func_800A7650(s16 dropId) { (((dropId == ITEM00_ARROWS_10) || (dropId == ITEM00_ARROWS_30) || (dropId == ITEM00_ARROWS_40) || (dropId == ITEM00_ARROWS_50)) && (INV_CONTENT(ITEM_BOW) == ITEM_NONE)) || - (((dropId == ITEM00_MAGIC_LARGE) || (dropId == ITEM00_MAGIC_SMALL)) && (gSaveContext.magicLevel == 0))) { + (((dropId == ITEM00_MAGIC_LARGE) || (dropId == ITEM00_MAGIC_SMALL)) && + (gSaveContext.save.playerData.magicLevel == 0))) { return ITEM00_NO_DROP; } if (dropId == ITEM00_HEART) { - healthCapacity = gSaveContext.healthCapacity; - if (healthCapacity == gSaveContext.health) { + healthCapacity = gSaveContext.save.playerData.healthCapacity; + if (healthCapacity == gSaveContext.save.playerData.health) { return ITEM00_RUPEE_GREEN; } } @@ -1049,7 +1050,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 dropQuantity = sDropTableAmounts[params + dropTableIndex]; if (dropId == ITEM00_MASK) { - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case PLAYER_FORM_HUMAN: dropId = ITEM00_ARROWS_10; break; @@ -1085,26 +1086,27 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 } if (dropId == ITEM00_FLEXIBLE) { - if (gSaveContext.health <= 0x10) { + if (gSaveContext.save.playerData.health <= 0x10) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, 2); SoundSource_PlaySfxAtFixedWorldPos(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY); return; } - if (gSaveContext.health <= 0x30) { + if (gSaveContext.save.playerData.health <= 0x30) { params = 0x10; dropId = ITEM00_HEART; dropQuantity = 3; - } else if (gSaveContext.health <= 0x50) { + } else if (gSaveContext.save.playerData.health <= 0x50) { params = 0x10; dropId = ITEM00_HEART; dropQuantity = 1; - } else if ((gSaveContext.magicLevel != 0) && (gSaveContext.magic == 0)) { + } else if ((gSaveContext.save.playerData.magicLevel != 0) && (gSaveContext.save.playerData.magic == 0)) { params = 0xD0; dropId = ITEM00_MAGIC_LARGE; dropQuantity = 1; - } else if ((gSaveContext.magicLevel != 0) && ((gSaveContext.magicLevel >> 1) >= gSaveContext.magic)) { + } else if ((gSaveContext.save.playerData.magicLevel != 0) && + ((gSaveContext.save.playerData.magicLevel >> 1) >= gSaveContext.save.playerData.magic)) { params = 0xD0; dropId = ITEM00_MAGIC_LARGE; dropQuantity = 1; @@ -1116,7 +1118,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 params = 0xB0; dropId = ITEM00_BOMBS_A; dropQuantity = 1; - } else if (gSaveContext.rupees < 11) { + } else if (gSaveContext.save.playerData.rupees < 11) { params = 0xA0; dropId = ITEM00_RUPEE_RED; dropQuantity = 1; diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 411cb5d00..62d55bc00 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -44,7 +44,7 @@ void GameOver_Update(GlobalContext* globalCtx) { } gSaveContext.unk_3DC0 = 2000; - gSaveContext.tatlTimer = 0; + gSaveContext.save.playerData.tatlTimer = 0; gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.eventInf[0] = 0; @@ -72,11 +72,11 @@ void GameOver_Update(GlobalContext* globalCtx) { gSaveContext.respawnFlag = -6; } gSaveContext.nextTransition = 2; - gSaveContext.health = 48; + gSaveContext.save.playerData.health = 48; gameOverCtx->state++; if (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU) { - gSaveContext.playerForm = PLAYER_FORM_HUMAN; - gSaveContext.equippedMask = PLAYER_MASK_NONE; + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.save.equippedMask = PLAYER_MASK_NONE; } func_8013EE24(); } diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index 703b966de..d89b427e9 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -38,7 +38,7 @@ void LifeMeter_Init(GlobalContext* globalCtx) { interfaceCtx->unkTimer = 320; - interfaceCtx->health = gSaveContext.health; + interfaceCtx->health = gSaveContext.save.playerData.health; interfaceCtx->lifeColorChange = 0; interfaceCtx->lifeColorChangeDirection = 0; @@ -168,7 +168,7 @@ void LifeMeter_UpdateColors(GlobalContext* globalCtx) { } s32 LifeMeter_SaveInterfaceHealth(GlobalContext* globalCtx) { - gSaveContext.health = globalCtx->interfaceCtx.health; + gSaveContext.save.playerData.health = globalCtx->interfaceCtx.health; return 1; } @@ -178,8 +178,8 @@ s32 LifeMeter_IncreaseInterfaceHealth(GlobalContext* globalCtx) { interfaceCtx->unkTimer = 320; interfaceCtx->health += 0x10; - if (globalCtx->interfaceCtx.health >= gSaveContext.health) { - globalCtx->interfaceCtx.health = gSaveContext.health; + if (globalCtx->interfaceCtx.health >= gSaveContext.save.playerData.health) { + globalCtx->interfaceCtx.health = gSaveContext.save.playerData.health; return 1; } return 0; @@ -195,7 +195,7 @@ s32 LifeMeter_DecreaseInterfaceHealth(GlobalContext* globalCtx) { interfaceCtx->health -= 0x10; if (interfaceCtx->health <= 0) { interfaceCtx->health = 0; - globalCtx->damagePlayer(globalCtx, -(((void)0, gSaveContext.health) + 1)); + globalCtx->damagePlayer(globalCtx, -(((void)0, gSaveContext.save.playerData.health) + 1)); return 1; } } @@ -216,18 +216,18 @@ void LifeMeter_Draw(GlobalContext* globalCtx) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; Vtx* beatingHeartVtx = interfaceCtx->beatingHeartVtx; - s32 fractionHeartCount = gSaveContext.health % 0x10; - s16 healthCapacity = gSaveContext.healthCapacity / 0x10; - s16 fullHeartCount = gSaveContext.health / 0x10; + s32 fractionHeartCount = gSaveContext.save.playerData.health % 0x10; + s16 healthCapacity = gSaveContext.save.playerData.healthCapacity / 0x10; + s16 fullHeartCount = gSaveContext.save.playerData.health / 0x10; s32 pad2; f32 lifesize = interfaceCtx->lifeSizeChange * 0.1f; u32 curCombineModeSet = 0; TexturePtr temp = NULL; - s32 ddCount = gSaveContext.inventory.dungeonKeys[9] - 1; + s32 ddCount = gSaveContext.save.inventory.dungeonKeys[9] - 1; OPEN_DISPS(gfxCtx); - if ((gSaveContext.health % 0x10) == 0) { + if ((gSaveContext.save.playerData.health % 0x10) == 0) { fullHeartCount--; } offsetY = 0.0f; @@ -417,19 +417,19 @@ void LifeMeter_UpdateSizeAndBeep(GlobalContext* globalCtx) { u32 LifeMeter_IsCritical(void) { s16 criticalThreshold; - if (gSaveContext.healthCapacity <= 80) { // healthCapacity <= 5 hearts? + if (gSaveContext.save.playerData.healthCapacity <= 80) { // healthCapacity <= 5 hearts? criticalThreshold = 16; - } else if (gSaveContext.healthCapacity <= 160) { // healthCapacity <= 10 hearts? + } else if (gSaveContext.save.playerData.healthCapacity <= 160) { // healthCapacity <= 10 hearts? criticalThreshold = 24; - } else if (gSaveContext.healthCapacity <= 240) { // healthCapacity <= 15 hearts? + } else if (gSaveContext.save.playerData.healthCapacity <= 240) { // healthCapacity <= 15 hearts? criticalThreshold = 32; } else { criticalThreshold = 44; } - if ((criticalThreshold >= gSaveContext.health) && (gSaveContext.health > 0)) { + if ((criticalThreshold >= gSaveContext.save.playerData.health) && (gSaveContext.save.playerData.health > 0)) { return true; } return false; diff --git a/src/code/z_message.c b/src/code/z_message.c index 447c354c6..d7fdbff42 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -391,12 +391,12 @@ void func_80151BB4(GlobalContext* globalCtx, u8 arg1) { u8 temp = arg1; if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { - if ((gSaveContext.weekEventReg[D_801C6B28[arg1] >> 8] & (u8)D_801C6B28[arg1]) == 0) { + if ((gSaveContext.save.weekEventReg[D_801C6B28[arg1] >> 8] & (u8)D_801C6B28[arg1]) == 0) { msgCtx->unk120B2[msgCtx->unk120B1] = temp; msgCtx->unk120B1++; } } else if (arg1 >= 20) { - if ((gSaveContext.weekEventReg[D_801C6B28[arg1] >> 8] & (u8)D_801C6B28[arg1]) == 0) { + if ((gSaveContext.save.weekEventReg[D_801C6B28[arg1] >> 8] & (u8)D_801C6B28[arg1]) == 0) { msgCtx->unk120B2[msgCtx->unk120B1] = temp; msgCtx->unk120B1++; } @@ -413,10 +413,10 @@ u32 func_80151C9C(GlobalContext* globalCtx) { } msgCtx->unk120B1--; - if ((gSaveContext.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] & + if ((gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] & (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]) == 0) { - flag = gSaveContext.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8]; - gSaveContext.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] = + flag = gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8]; + gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] = flag | (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]; if ((D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]] != 0) && CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { func_80151938(globalCtx, D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]]); @@ -474,7 +474,7 @@ void func_80152EC0(GlobalContext* globalCtx) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153750.s") void func_80153E7C(GlobalContext* globalCtx, void* arg1) { - if ((gSaveContext.language == 0) && (globalCtx->msgCtx.unk12090 == 0)) { + if ((gSaveContext.options.language == 0) && (globalCtx->msgCtx.unk12090 == 0)) { func_8014ADBC(globalCtx, arg1); return; } diff --git a/src/code/z_message_nes.c b/src/code/z_message_nes.c index 7a961c882..1de839d68 100644 --- a/src/code/z_message_nes.c +++ b/src/code/z_message_nes.c @@ -131,15 +131,15 @@ void Message_LoadLocalizedRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos msgCtx->decodedBuffer.schar[p] = ' '; p++; - for (j = 0; j < D_801D0710[gSaveContext.language - 1]; j++) { - Font_LoadCharNES(globalCtx, D_801D06F0[gSaveContext.language - 1][j], o); - msgCtx->decodedBuffer.schar[p] = D_801D06F0[gSaveContext.language - 1][j]; + for (j = 0; j < D_801D0710[gSaveContext.options.language - 1]; j++) { + Font_LoadCharNES(globalCtx, D_801D06F0[gSaveContext.options.language - 1][j], o); + msgCtx->decodedBuffer.schar[p] = D_801D06F0[gSaveContext.options.language - 1][j]; o += FONT_CHAR_TEX_SIZE; p++; } p--; - f += 16.0f * msgCtx->unk12098 * (D_801D0710[gSaveContext.language - 1] + 1); + f += 16.0f * msgCtx->unk12098 * (D_801D0710[gSaveContext.options.language - 1] + 1); *decodedBufPos = p; *offset = o; *arg3 = f; @@ -200,10 +200,10 @@ void Message_LoadTimeNES(GlobalContext* globalCtx, u8 arg1, s32* offset, f32* ar s16 i; if (arg1 == 0xCF) { - day = gSaveContext.day; - dayTime = 0x40000 - ((day % 5) << 16) - (u16)(-0x4000 + gSaveContext.time); + day = gSaveContext.save.day; + dayTime = 0x40000 - ((day % 5) << 16) - (u16)(-0x4000 + gSaveContext.save.time); } else { - dayTime = 0x10000 - (u16)(-0x4000 + gSaveContext.time); + dayTime = 0x10000 - (u16)(-0x4000 + gSaveContext.save.time); } timeInMinutes = TIME_TO_MINUTES_F(dayTime); diff --git a/src/code/z_play.c b/src/code/z_play.c index b5c2b15c8..57b09f67e 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -158,8 +158,8 @@ void Play_SaveCycleSceneFlags(GameState* gameState) { cycleSceneFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(globalCtx->sceneNum)]; cycleSceneFlags->chest = globalCtx->actorCtx.flags.chest; - cycleSceneFlags->swch0 = globalCtx->actorCtx.flags.switches[0]; - cycleSceneFlags->swch1 = globalCtx->actorCtx.flags.switches[1]; + cycleSceneFlags->switch0 = globalCtx->actorCtx.flags.switches[0]; + cycleSceneFlags->switch1 = globalCtx->actorCtx.flags.switches[1]; if (globalCtx->sceneNum == SCENE_INISIE_R) { // Inverted Stone Tower Temple cycleSceneFlags = &gSaveContext.cycleSceneFlags[globalCtx->sceneNum]; @@ -178,7 +178,7 @@ void Play_SetRespawnData(GameState* gameState, s32 respawnMode, u16 entranceInde gSaveContext.respawn[respawnMode].pos = *pos; gSaveContext.respawn[respawnMode].yaw = yaw; gSaveContext.respawn[respawnMode].playerParams = playerParams; - gSaveContext.respawn[respawnMode].tempSwchFlags = globalCtx->actorCtx.flags.switches[2]; + gSaveContext.respawn[respawnMode].tempSwitchFlags = globalCtx->actorCtx.flags.switches[2]; gSaveContext.respawn[respawnMode].unk_18 = globalCtx->actorCtx.flags.collectible[1]; gSaveContext.respawn[respawnMode].tempCollectFlags = globalCtx->actorCtx.flags.collectible[2]; } @@ -188,7 +188,7 @@ void Play_SetupRespawnPoint(GameState* gameState, s32 respawnMode, s32 playerPar Player* player = GET_PLAYER(globalCtx); if (globalCtx->sceneNum != SCENE_KAKUSIANA) { // Grottos - Play_SetRespawnData(&globalCtx->state, respawnMode, (u16)((void)0, gSaveContext.entranceIndex), + Play_SetRespawnData(&globalCtx->state, respawnMode, (u16)((void)0, gSaveContext.save.entranceIndex), globalCtx->roomCtx.currRoom.num, playerParams, &player->actor.world.pos, player->actor.shape.rot.y); } @@ -207,10 +207,10 @@ void func_80169ECC(GlobalContext* globalCtx) { void func_80169EFC(GameState* gameState) { GlobalContext* globalCtx = (GlobalContext*)gameState; - gSaveContext.respawn[0].tempSwchFlags = globalCtx->actorCtx.flags.switches[2]; - gSaveContext.respawn[0].unk_18 = globalCtx->actorCtx.flags.collectible[1]; - gSaveContext.respawn[0].tempCollectFlags = globalCtx->actorCtx.flags.collectible[2]; - globalCtx->nextEntranceIndex = gSaveContext.respawn[0].entranceIndex; + gSaveContext.respawn[RESTART_MODE_DOWN].tempSwitchFlags = globalCtx->actorCtx.flags.switches[2]; + gSaveContext.respawn[RESTART_MODE_DOWN].unk_18 = globalCtx->actorCtx.flags.collectible[1]; + gSaveContext.respawn[RESTART_MODE_DOWN].tempCollectFlags = globalCtx->actorCtx.flags.collectible[2]; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex; gSaveContext.respawnFlag = 1; func_80169ECC(globalCtx); globalCtx->sceneLoadFlag = 0x14; @@ -222,7 +222,7 @@ void func_80169EFC(GameState* gameState) { void func_80169F78(GameState* gameState) { GlobalContext* globalCtx = (GlobalContext*)gameState; - globalCtx->nextEntranceIndex = gSaveContext.respawn[2].entranceIndex; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_TOP].entranceIndex; gSaveContext.respawnFlag = -1; func_80169ECC(globalCtx); globalCtx->sceneLoadFlag = 0x14; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 6ef6a6091..8a9bdd4e7 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -151,7 +151,7 @@ void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->linkActorEntry = (ActorEntry*)Lib_SegmentedToVirtual(cmd->spawnList.segment) + globalCtx->setupEntranceList[globalCtx->curSpawn].spawn; if ((globalCtx->linkActorEntry->params & 0x0F00) >> 8 == 0x0C || - (gSaveContext.respawnFlag == 0x02 && gSaveContext.respawn[1].playerParams == 0x0CFF)) { + (gSaveContext.respawnFlag == 0x02 && gSaveContext.respawn[RESTART_MODE_RETURN].playerParams == 0x0CFF)) { // Skull Kid Object Object_Spawn(&globalCtx->objectCtx, OBJECT_STK); return; @@ -161,7 +161,7 @@ void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) { nextObject = globalCtx2->objectCtx.status[globalCtx2->objectCtx.num].segment; globalCtx->objectCtx.num = loadedCount; globalCtx->objectCtx.spawnedObjectCount = loadedCount; - playerForm = gSaveContext.playerForm; + playerForm = gSaveContext.save.playerForm; playerObjectId = gLinkFormObjectIndexes[playerForm]; gActorOverlayTable[0].initInfo->objectId = playerObjectId; Object_Spawn(&globalCtx->objectCtx, playerObjectId); @@ -383,7 +383,7 @@ void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { u32 dayTime; if (cmd->timeSettings.hour != 0xFF && cmd->timeSettings.min != 0xFF) { - gSaveContext.environmentTime = gSaveContext.time = + gSaveContext.environmentTime = gSaveContext.save.time = (u16)(((cmd->timeSettings.hour + (cmd->timeSettings.min / 60.0f)) * 60.0f) / 0.021972656f); } @@ -393,7 +393,7 @@ void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->envCtx.timeIncrement = 0; } - if ((gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) && (globalCtx->envCtx.timeIncrement != 0)) { + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) && (globalCtx->envCtx.timeIncrement != 0)) { globalCtx->envCtx.timeIncrement = 5; } @@ -401,15 +401,15 @@ void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { REG(15) = globalCtx->envCtx.timeIncrement; } - dayTime = gSaveContext.time; + dayTime = gSaveContext.save.time; globalCtx->envCtx.unk_4 = -(Math_SinS(dayTime - 0x8000) * 120.0f) * 25.0f; - dayTime = gSaveContext.time; + dayTime = gSaveContext.save.time; globalCtx->envCtx.unk_8 = (Math_CosS(dayTime - 0x8000) * 120.0f) * 25.0f; - dayTime = gSaveContext.time; + dayTime = gSaveContext.save.time; globalCtx->envCtx.unk_C = (Math_CosS(dayTime - 0x8000) * 20.0f) * 25.0f; - if (globalCtx->envCtx.timeIncrement == 0 && gSaveContext.cutscene < 0xFFF0) { - gSaveContext.environmentTime = gSaveContext.time; + if (globalCtx->envCtx.timeIncrement == 0 && gSaveContext.save.cutscene < 0xFFF0) { + gSaveContext.environmentTime = gSaveContext.save.time; if (gSaveContext.environmentTime >= CLOCK_TIME(4, 0) && gSaveContext.environmentTime < CLOCK_TIME(6, 30)) { gSaveContext.environmentTime = CLOCK_TIME(5, 0); @@ -527,7 +527,7 @@ void Scene_HeaderCmdSetAreaVisitedFlag(GlobalContext* globalCtx, SceneCmd* cmd) } if (i < ARRAY_COUNT(gScenesPerRegion)) { - gSaveContext.mapsVisited = (gBitFlags[i] | gSaveContext.mapsVisited) | gSaveContext.mapsVisited; + gSaveContext.save.mapsVisited = (gBitFlags[i] | gSaveContext.save.mapsVisited) | gSaveContext.save.mapsVisited; } } @@ -610,5 +610,5 @@ u16 Entrance_CreateIndex(s32 sceneIndex, s32 spawnIndex, s32 sceneSetup) { * Creates an entrance index from the current entrance index with the given spawn index. */ u16 Entrance_CreateIndexFromSpawn(s32 spawnIndex) { - return Entrance_CreateIndex(gSaveContext.entranceIndex >> 9, spawnIndex, 0); + return Entrance_CreateIndex(gSaveContext.save.entranceIndex >> 9, spawnIndex, 0); } diff --git a/src/code/z_snap.c b/src/code/z_snap.c index bce1f67d7..f85f33f0a 100644 --- a/src/code/z_snap.c +++ b/src/code/z_snap.c @@ -12,8 +12,8 @@ s32 func_8013A240(GlobalContext* globalCtx) { s32 seen; s32 count = 0; - gSaveContext.pictoFlags0 = 0; - gSaveContext.pictoFlags1 = 0; + gSaveContext.save.pictoFlags0 = 0; + gSaveContext.save.pictoFlags1 = 0; if (globalCtx->sceneNum == SCENE_20SICHITAI) { func_8013A41C(1); @@ -76,19 +76,19 @@ s32 func_8013A240(GlobalContext* globalCtx) { void func_8013A41C(s32 flag) { if (flag < 0x20) { - gSaveContext.pictoFlags0 |= (1 << flag); + gSaveContext.save.pictoFlags0 |= (1 << flag); } else { flag &= 0x1F; - gSaveContext.pictoFlags1 |= (1 << flag); + gSaveContext.save.pictoFlags1 |= (1 << flag); } } void func_8013A46C(s32 flag) { if (flag < 0x20) { - gSaveContext.pictoFlags0 &= ~(1 << flag); + gSaveContext.save.pictoFlags0 &= ~(1 << flag); } else { flag &= 0x1F; - gSaveContext.pictoFlags1 &= ~(1 << flag); + gSaveContext.save.pictoFlags1 &= ~(1 << flag); } } @@ -96,10 +96,10 @@ u32 func_8013A4C4(s32 flag) { SaveContext* saveCtx = &gSaveContext; if (flag < 0x20) { - return saveCtx->pictoFlags0 & (1 << flag); + return saveCtx->save.pictoFlags0 & (1 << flag); } else { flag &= 0x1F; - return saveCtx->pictoFlags1 & (1 << flag); + return saveCtx->save.pictoFlags1 & (1 << flag); } } @@ -135,7 +135,7 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Actor_GetProjectedPos(globalCtx, pos, &screenSpace, &distance); x = (s16)(screenSpace.x * distance * 160.0f + 160.0f) - 85; y = (s16)(screenSpace.y * distance * -120.0f + 120.0f) - 67; - if ((x < 0) || (0x96 < x) || (y < 0) || (0x69 < y)) { + if ((x < 0) || (150 < x) || (y < 0) || (105 < y)) { func_8013A41C(0x3D); ret |= 0x3D; } diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 5b5b2f5f0..b1dbdb1fe 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -1,67 +1,1676 @@ #include "global.h" +#include "overlays/gamestates/ovl_file_choose/z_file_choose.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80143A10.s") +void func_80146EBC(SramContext* sramCtx, s32 curPage, s32 numPages); +void func_80147314(SramContext* sramCtx, s32 fileNum); +void func_80147414(SramContext* sramCtx, s32 fileNum, s32 arg2); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80143A54.s") +#define CHECK_NEWF(newf) \ + ((newf)[0] != 'Z' || (newf)[1] != 'E' || (newf)[2] != 'L' || (newf)[3] != 'D' || (newf)[4] != 'A' || \ + (newf)[5] != '3') -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80143AC4.s") +// default scene flags (?) +// indices of subarray: +// - 0: switch0 +// - 1: switch1 +// - 2: chest +// - 3: collectible +u32 D_801C5FC0[SCENE_MAX][4] = { + { 0xC00, 0, 0, 0x40000000 }, // SCENE_20SICHITAI2 + { 0, 0, 0, 0 }, // SCENE_UNSET_1 + { 0, 0, 0, 0 }, // SCENE_UNSET_2 + { 0, 0, 0, 0 }, // SCENE_UNSET_3 + { 0, 0, 0, 0 }, // SCENE_UNSET_4 + { 0, 0, 0, 0 }, // SCENE_UNSET_5 + { 0, 0, 0, 0 }, // SCENE_UNSET_6 + { 0, 0, 0, 0xC04 }, // SCENE_KAKUSIANA + { 0, 0, 0, 0 }, // SCENE_SPOT00 + { 0, 0, 0, 0 }, // SCENE_UNSET_9 + { 0, 0, 0, 0 }, // SCENE_WITCH_SHOP + { 0, 0, 0, 0x80000000 }, // SCENE_LAST_BS + { 0, 0, 0, 0x80000000 }, // SCENE_HAKASHITA + { 0, 0, 0, 0 }, // SCENE_AYASHIISHOP + { 0, 0, 0, 0 }, // SCENE_UNSET_E + { 0, 0, 0, 0 }, // SCENE_UNSET_F + { 0, 0, 0, 0 }, // SCENE_OMOYA + { 0, 0, 0, 0 }, // SCENE_BOWLING + { 0, 0, 0, 0 }, // SCENE_SONCHONOIE + { 0x100000, 0, 0, 0x40000002 }, // SCENE_IKANA + { 0, 0, 0, 0 }, // SCENE_KAIZOKU + { 0, 0, 0, 0 }, // SCENE_MILK_BAR + { 0x4000000, 0, 0, 0 }, // SCENE_INISIE_N + { 2, 0, 0, 0 }, // SCENE_TAKARAYA + { 0x4000000, 0, 0, 0 }, // SCENE_INISIE_R + { 0, 0, 0, 0 }, // SCENE_OKUJOU + { 0xF, 0, 0, 0 }, // SCENE_OPENINGDAN + { 0x70B000, 0, 0, 0 }, // SCENE_MITURIN + { 0, 0, 0, 0 }, // SCENE_13HUBUKINOMITI + { 0, 0x80000000, 0, 0x400 }, // SCENE_CASTLE + { 0, 0, 0, 0 }, // SCENE_DEKUTES + { 0, 0, 0, 0x80000000 }, // SCENE_MITURIN_BS + { 0, 0, 0, 0 }, // SCENE_SYATEKI_MIZU + { 0x1A00020, 0, 0, 0 }, // SCENE_HAKUGIN + { 0x400, 0, 0, 0 }, // SCENE_ROMANYMAE + { 0, 0, 0, 0x1000 }, // SCENE_PIRATE + { 0, 0, 0, 0 }, // SCENE_SYATEKI_MORI + { 0, 0, 0, 2 }, // SCENE_SINKAI + { 0x400, 0, 0, 0 }, // SCENE_YOUSEI_IZUMI + { 0, 0, 0, 0 }, // SCENE_KINSTA1 + { 0, 0, 0, 0x80000000 }, // SCENE_KINDAN2 + { 0, 0, 0, 0 }, // SCENE_TENMON_DAI + { 0, 0, 0, 2 }, // SCENE_LAST_DEKU + { 0, 0, 0, 0x40000000 }, // SCENE_22DEKUCITY + { 0, 0, 0, 0 }, // SCENE_KAJIYA + { 0x10, 0, 0, 0 }, // SCENE_00KEIKOKU + { 3, 0, 0, 0 }, // SCENE_POSTHOUSE + { 0, 0, 0, 0 }, // SCENE_LABO + { 0, 0, 0, 0x80000000 }, // SCENE_DANPEI2TEST + { 0, 0, 0, 0 }, // SCENE_UNSET_31 + { 0, 0, 0, 0 }, // SCENE_16GORON_HOUSE + { 0, 0, 0, 0 }, // SCENE_33ZORACITY + { 0, 0, 0, 0 }, // SCENE_8ITEMSHOP + { 0, 0, 0, 0 }, // SCENE_F01 + { 0, 0, 0, 0x80000000 }, // SCENE_INISIE_BS + { 0x100400, 0, 0, 0x22 }, // SCENE_30GYOSON + { 0x400, 0, 0, 0x80 }, // SCENE_31MISAKI + { 0, 0, 0, 0 }, // SCENE_TAKARAKUJI + { 0, 0, 0, 0 }, // SCENE_UNSET_3A + { 0x400, 0, 0, 0 }, // SCENE_TORIDE + { 0, 0, 0, 0 }, // SCENE_FISHERMAN + { 0, 0, 0, 0 }, // SCENE_GORONSHOP + { 0, 0, 0, 0 }, // SCENE_DEKU_KING + { 0, 0, 0, 2 }, // SCENE_LAST_GORON + { 0, 0, 0, 0x80000002 }, // SCENE_24KEMONOMITI + { 0, 0, 0, 0 }, // SCENE_F01_B + { 0, 0, 0, 0 }, // SCENE_F01C + { 0, 0, 0, 0 }, // SCENE_BOTI + { 0, 0, 0, 0x80000000 }, // SCENE_HAKUGIN_BS + { 0xC00, 0, 0, 0x40000000 }, // SCENE_20SICHITAI + { 0x102, 0, 0, 0x400 }, // SCENE_21MITURINMAE + { 0, 0, 0, 2 }, // SCENE_LAST_ZORA + { 0, 0, 0, 0x40000000 }, // SCENE_11GORONNOSATO2 + { 0x70, 0, 0, 0 }, // SCENE_SEA + { 0, 0, 0, 0 }, // SCENE_35TAKI + { 0, 0, 0, 0 }, // SCENE_REDEAD + { 0, 0, 0, 0x40000000 }, // SCENE_BANDROOM + { 0, 0, 0, 0x40000000 }, // SCENE_11GORONNOSATO + { 0, 0, 0, 0 }, // SCENE_GORON_HAKA + { 0, 0, 0, 0 }, // SCENE_SECOM + { 0x100000, 0, 0, 0x80000000 }, // SCENE_10YUKIYAMANOMURA + { 0, 0, 0, 0 }, // SCENE_TOUGITES + { 0, 0, 0, 0 }, // SCENE_DANPEI + { 0, 0, 0, 0 }, // SCENE_IKANAMAE + { 0, 0, 0, 0 }, // SCENE_DOUJOU + { 0, 0, 0, 0 }, // SCENE_MUSICHOUSE + { 0, 0, 0, 0 }, // SCENE_IKNINSIDE + { 0, 0, 0, 0 }, // SCENE_MAP_SHOP + { 0x400, 0, 0, 0 }, // SCENE_F40 + { 0x400, 0, 0, 0 }, // SCENE_F41 + { 0x100000, 0, 0, 0x80000000 }, // SCENE_10YUKIYAMANOMURA2 + { 0, 0, 0, 0x100 }, // SCENE_14YUKIDAMANOMITI + { 0x400, 0, 0, 0 }, // SCENE_12HAKUGINMAE + { 0, 0, 0, 0x80 }, // SCENE_17SETUGEN + { 0, 0, 0, 0x80 }, // SCENE_17SETUGEN2 + { 0, 0, 0, 0x80000000 }, // SCENE_SEA_BS + { 0, 0, 0, 0x400 }, // SCENE_RANDOM + { 0, 0, 0, 0 }, // SCENE_YADOYA + { 0, 0, 0, 0 }, // SCENE_KONPEKI_ENT + { 1, 0, 0, 0 }, // SCENE_INSIDETOWER + { 0, 0, 0, 0 }, // SCENE_26SARUNOMORI + { 0, 0, 0, 0 }, // SCENE_LOST_WOODS + { 0, 0, 0, 2 }, // SCENE_LAST_LINK + { 0, 0, 0, 0 }, // SCENE_SOUGEN + { 0, 0, 0, 0 }, // SCENE_BOMYA + { 0, 0, 0, 0 }, // SCENE_KYOJINNOMA + { 0, 0, 0, 0 }, // SCENE_KOEPONARACE + { 0, 0, 0, 0 }, // SCENE_GORONRACE + { 1, 0, 0, 0 }, // SCENE_TOWN + { 0, 0, 0, 0 }, // SCENE_ICHIBA + { 0, 0, 0, 0x400 }, // SCENE_BACKTOWN + { 0x100000, 0, 0, 0x400 }, // SCENE_CLOCKTOWER + { 0, 0, 1, 0 }, // SCENE_ALLEY +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80143B0C.s") +// Related to weekEventReg +u16 D_801C66D0[ARRAY_COUNT(gSaveContext.save.weekEventReg)] = { + 0xFFFC, 0xFFFF, 0xFFFF, 0xFFFF, 0, 0, 0, 0xC000, 0xC00, 0, 0xC0, 0, 0x300, + 0x3000, 0xC000, 0xC00, 0, 0, 0, 0, 0, 0, 0xC00C, 0xC00C, 0xC008, 3, + 0x3000, 0, 0, 0, 0xFF00, 0xC3F, 0x3F, 0, 0, 0xCFFF, 0, 0, 0xC00, + 0xC00, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0, 0, 0x3C, 0x20, + 0, 0x300C, 0x3000, 0, 0xC, 0xC0, 0, 0xFF0, 0x300, 0, 0, 0xC00, 0, + 0, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xC0, 0, 0xC000, 0, 3, + 0, 0xC000, 0, 0xC0, 0x300, 0, 0, 0, 0xC000, 0xFFF0, 0, 0, 0x300, + 0, 0xC000, 0xF0, 0, 0, 0, 0, 0, 0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_IncrementDay.s") +// used in other files +s32 D_801C6798[] = { + 0x00000020, 0x00001470, 0x000028C0, 0x00003D10, 0x00005160, 0x000065B0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_CalcChecksum.s") +u8 D_801C67B0[24] = { + ITEM_NONE, ITEM_BOW, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_BOMB, ITEM_BOMBCHU, + ITEM_STICK, ITEM_NUT, ITEM_MAGIC_BEANS, ITEM_NONE, ITEM_POWDER_KEG, ITEM_PICTO_BOX, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144628.s") +s32 D_801C67C8[] = { 0, 0x40, 0x80, 0xC0, 0x100, 0x180, 0x200, 0x280 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_GenerateRandomSaveFields.s") +s32 D_801C67E8[] = { 0x300, 0x380 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144890.s") +s32 D_801C67F0[] = { 0x40, 0x40, 0x40, 0x40, 0x80, 0x80, 0x80, 0x80 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_InitDebugSave.s") +s32 D_801C6810[] = { 1, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144A94.s") +s32 D_801C6818[] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144E78.s") +s32 D_801C6838[] = { 1, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_8014546C.s") +s32 D_801C6840[] = { 0x100, 0x180, 0x200, 0x280 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80145698.s") +s32 D_801C6850[] = { 0x80, 0x80, 0x80, 0x80, 0x300, 0x380, 1, 1 }; +s32 D_801C6870[] = { + sizeof(Save), + sizeof(Save), + sizeof(Save), + sizeof(Save), + offsetof(SaveContext, fileNum), + offsetof(SaveContext, fileNum), + offsetof(SaveContext, fileNum), + offsetof(SaveContext, fileNum), +}; + +u8 D_801C6890[8] = { 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80 }; + +u16 D_801F6AF0; +u8 D_801F6AF2; + +void Sram_ActivateOwl(u8 owlId) { + gSaveContext.save.playerData.owlActivationFlags = + ((void)0, gSaveContext.save.playerData.owlActivationFlags) | (u16)gBitFlags[owlId]; + + if (gSaveContext.save.playerData.unk_20 == 0xFF) { + gSaveContext.save.playerData.unk_20 = owlId; + } +} + +void Sram_ClearHighscores(void) { + gSaveContext.save.unk_EE8 = (gSaveContext.save.unk_EE8 & 0xFFFF) | 0x130000; + gSaveContext.save.unk_EE8 = (gSaveContext.save.unk_EE8 & 0xFFFF0000) | 0xA; + gSaveContext.save.horseBackBalloonHighScore = 6000; // 60 seconds + gSaveContext.save.unk_EF4 = (gSaveContext.save.unk_EF4 & 0xFFFF0000) | 0x27; + gSaveContext.save.unk_EF4 = (gSaveContext.save.unk_EF4 & 0xFFFF) | 0xA0000; + + gSaveContext.save.dekuPlaygroundHighScores[0] = 7500; // 75 seconds + gSaveContext.save.dekuPlaygroundHighScores[1] = 7500; // 75 seconds + gSaveContext.save.dekuPlaygroundHighScores[2] = 7600; // 76 seconds +} + +/** + * Clears specific weekEventReg flags. Used by the "Dawn of the First Day" message + */ +void Sram_ClearFlagsAtDawnOfTheFirstDay(void) { + // Unconfirmed: "Link the Goron Claims His Reservation: 4:30 PM" + gSaveContext.save.weekEventReg[55] &= (u8)~2; + // Unconfirmed: "Postman fleeing town" + gSaveContext.save.weekEventReg[90] &= (u8)~1; + // Unconfirmed: "Postman is about to flee" + gSaveContext.save.weekEventReg[89] &= (u8)~0x40; + // Unconfirmed: "Postman has delivered priority mail" + gSaveContext.save.weekEventReg[89] &= (u8)~8; + // Unconfirmed: "Postman showing priority mail to Madame" + gSaveContext.save.weekEventReg[85] &= (u8)~0x80; +} + +/** + * Used by Song of Time (when clicking "Yes") and (indirectly) by the "Dawn of the New Day" cutscene + */ +void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { + s16 sceneNum; + s32 j; + s32 i; + u8 temp; + u8 temp2; + + gSaveContext.save.daySpeed = 0; + gSaveContext.save.daysElapsed = 0; + gSaveContext.save.day = 0; + gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; + + gSaveContext.save.playerData.deaths++; + if (gSaveContext.save.playerData.deaths > 999) { + gSaveContext.save.playerData.deaths = 999; + } + + sceneNum = Play_GetOriginalSceneNumber(globalCtx->sceneNum); + Play_SaveCycleSceneFlags(&globalCtx->state); + + globalCtx->actorCtx.flags.chest &= D_801C5FC0[sceneNum][2]; + globalCtx->actorCtx.flags.switches[0] &= D_801C5FC0[sceneNum][0]; + globalCtx->actorCtx.flags.switches[1] &= D_801C5FC0[sceneNum][1]; + globalCtx->actorCtx.flags.collectible[0] &= D_801C5FC0[sceneNum][3]; + globalCtx->actorCtx.flags.clearedRoom = 0; + + for (i = 0; i < SCENE_MAX; i++) { + gSaveContext.cycleSceneFlags[i].switch0 = ((void)0, gSaveContext.cycleSceneFlags[i].switch0) & D_801C5FC0[i][0]; + gSaveContext.cycleSceneFlags[i].switch1 = ((void)0, gSaveContext.cycleSceneFlags[i].switch1) & D_801C5FC0[i][1]; + gSaveContext.cycleSceneFlags[i].chest = ((void)0, gSaveContext.cycleSceneFlags[i].chest) & D_801C5FC0[i][2]; + gSaveContext.cycleSceneFlags[i].collectible = + ((void)0, gSaveContext.cycleSceneFlags[i].collectible) & D_801C5FC0[i][3]; + gSaveContext.cycleSceneFlags[i].clearedRoom = 0; + gSaveContext.save.permanentSceneFlags[i].unk_14 = 0; + gSaveContext.save.permanentSceneFlags[i].unk_18 = 0; + } + + for (; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.cycleSceneFlags[i].chest = 0; + gSaveContext.cycleSceneFlags[i].switch0 = 0; + gSaveContext.cycleSceneFlags[i].switch1 = 0; + gSaveContext.cycleSceneFlags[i].clearedRoom = 0; + gSaveContext.cycleSceneFlags[i].collectible = 0; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.maskMaskBit); i++) { + gSaveContext.maskMaskBit[i] = 0; + } + + if (gSaveContext.save.weekEventReg[84] & 0x20) { + func_801149A0(ITEM_MASK_FIERCE_DEITY, SLOT(ITEM_MASK_FIERCE_DEITY)); + } + + for (i = 0; i < ARRAY_COUNT(D_801C66D0); i++) { + u16 phi_v1_3 = D_801C66D0[i]; + + for (j = 0; j < ARRAY_COUNT(D_801C6890); j++) { + if ((phi_v1_3 & 3) == 0) { + gSaveContext.save.weekEventReg[i] = + ((void)0, gSaveContext.save.weekEventReg[i]) & (0xFF ^ D_801C6890[j]); + } + phi_v1_3 >>= 2; + } + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.eventInf); i++) { + gSaveContext.eventInf[i] = 0; + } + + gSaveContext.eventInf[7] &= (u8)~1; + gSaveContext.eventInf[7] &= (u8)~2; + gSaveContext.eventInf[7] &= (u8)~4; + gSaveContext.eventInf[7] &= (u8)~8; + gSaveContext.eventInf[7] &= (u8)~0x10; + + if (gSaveContext.save.playerData.rupees != 0) { + gSaveContext.eventInf[7] |= 1; + } + + if (INV_CONTENT(ITEM_BOMB) == ITEM_BOMB) { + temp2 = INV_CONTENT(ITEM_BOMB); + if (AMMO(temp2) != 0) { + gSaveContext.eventInf[7] |= 2; + } + } + if (INV_CONTENT(ITEM_NUT) == ITEM_NUT) { + temp2 = INV_CONTENT(ITEM_NUT); + if (AMMO(temp2) != 0) { + gSaveContext.eventInf[7] |= 4; + } + } + if (INV_CONTENT(ITEM_STICK) == ITEM_STICK) { + temp2 = INV_CONTENT(ITEM_STICK); + if (AMMO(temp2) != 0) { + gSaveContext.eventInf[7] |= 8; + } + } + if (INV_CONTENT(ITEM_BOW) == ITEM_BOW) { + temp2 = INV_CONTENT(ITEM_BOW); + if (AMMO(temp2) != 0) { + gSaveContext.eventInf[7] |= 0x10; + } + } + + for (i = 0; i < ARRAY_COUNT(D_801C67B0); i++) { + if (D_801C67B0[i] != ITEM_NONE) { + if ((gSaveContext.save.inventory.items[i] != ITEM_NONE) && (i != SLOT_PICTO_BOX)) { + temp2 = gSaveContext.save.inventory.items[i]; + AMMO(temp2) = 0; + } + } + } + + for (i = SLOT_BOTTLE_1; i <= SLOT_BOTTLE_6; i++) { + // Check for all bottled items + if (gSaveContext.save.inventory.items[i] >= ITEM_POTION_RED) { + if (gSaveContext.save.inventory.items[i] <= ITEM_OBABA_DRINK) { + for (j = 1; j < 4; j++) { + if (GET_CUR_FORM_BTN_ITEM(j) == gSaveContext.save.inventory.items[i]) { + SET_CUR_FORM_BTN_ITEM(j, ITEM_BOTTLE); + func_80112B40(globalCtx, j); + } + } + gSaveContext.save.inventory.items[i] = ITEM_BOTTLE; + } + } + } + + REMOVE_QUEST_ITEM(QUEST_UNK_19); + + if (gSaveContext.save.playerData.health < 0x30) { + gSaveContext.save.playerData.health = 0x30; + } + + if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) < 3) { + SET_EQUIP_VALUE(EQUIP_SWORD, 1); + + if (CUR_FORM == 0) { + if ((STOLEN_ITEM_1 >= ITEM_SWORD_GILDED) || (STOLEN_ITEM_2 >= ITEM_SWORD_GILDED)) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_SWORD_GILDED; + SET_EQUIP_VALUE(EQUIP_SWORD, 3); + } else { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; + } + } else { + if ((STOLEN_ITEM_1 >= ITEM_SWORD_GILDED) || (STOLEN_ITEM_2 >= ITEM_SWORD_GILDED)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = ITEM_SWORD_GILDED; + SET_EQUIP_VALUE(EQUIP_SWORD, 3); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; + } + } + } + + if ((STOLEN_ITEM_1 == ITEM_SWORD_GREAT_FAIRY) || (STOLEN_ITEM_2 == ITEM_SWORD_GREAT_FAIRY)) { + INV_CONTENT(ITEM_SWORD_GREAT_FAIRY) = ITEM_SWORD_GREAT_FAIRY; + } + + if (STOLEN_ITEM_1 == ITEM_BOTTLE) { + temp = SLOT(ITEM_BOTTLE); + for (i = 0; i < 6; i++) { + if (gSaveContext.save.inventory.items[temp + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[temp + i] = ITEM_BOTTLE; + break; + } + } + } + + if (STOLEN_ITEM_2 == ITEM_BOTTLE) { + temp = SLOT(ITEM_BOTTLE); + for (i = 0; i < 6; i++) { + if (gSaveContext.save.inventory.items[temp + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[temp + i] = ITEM_BOTTLE; + break; + } + } + } + + SET_STOLEN_ITEM_1(STOLEN_ITEM_NONE); + SET_STOLEN_ITEM_2(STOLEN_ITEM_NONE); + + // ?? + func_801149A0(ITEM_OCARINA_FAIRY, SLOT_TRADE_DEED); + func_801149A0(ITEM_SLINGSHOT, SLOT_TRADE_KEY_MAMA); + func_801149A0(ITEM_LONGSHOT, SLOT_TRADE_COUPLE); + + for (j = 1; j < 4; j++) { + if (GET_CUR_FORM_BTN_ITEM(j) >= ITEM_MOON_TEAR && GET_CUR_FORM_BTN_ITEM(j) <= ITEM_PENDANT_MEMORIES) { + SET_CUR_FORM_BTN_ITEM(j, ITEM_NONE); + func_80112B40(globalCtx, j); + } + } + + gSaveContext.save.skullTokenCount &= ~0xFFFF0000; + gSaveContext.save.skullTokenCount &= ~0x0000FFFF; + gSaveContext.save.unk_EC4 = 0; + + gSaveContext.save.unk_E88[0] = 0; + gSaveContext.save.unk_E88[1] = 0; + gSaveContext.save.unk_E88[2] = 0; + gSaveContext.save.unk_E88[3] = 0; + gSaveContext.save.unk_E88[4] = 0; + gSaveContext.save.unk_E88[5] = 0; + gSaveContext.save.unk_E88[6] = 0; + + Sram_ClearHighscores(); + + for (i = 0; i < 8; i++) { + gSaveContext.save.inventory.dungeonItems[i] &= (u8)~1; + gSaveContext.save.inventory.dungeonKeys[i] = 0; + gSaveContext.save.inventory.strayFairies[i] = 0; + } + + gSaveContext.save.playerData.rupees = 0; + gSaveContext.save.unk_F65 = 0; + gSaveContext.powderKegTimer = 0; + gSaveContext.unk_1014 = 0; + gSaveContext.jinxTimer = 0; + gSaveContext.rupeeAccumulator = 0; + + func_800F3B2C(globalCtx); +} + +void Sram_IncrementDay(void) { + if (CURRENT_DAY <= 3) { + gSaveContext.save.day++; + gSaveContext.save.daysElapsed++; + } + + gSaveContext.save.bombersCaughtNum = 0; + gSaveContext.save.bombersCaughtOrder[0] = 0; + gSaveContext.save.bombersCaughtOrder[1] = 0; + gSaveContext.save.bombersCaughtOrder[2] = 0; + gSaveContext.save.bombersCaughtOrder[3] = 0; + gSaveContext.save.bombersCaughtOrder[4] = 0; + + // Unconfirmed: "Bombers Hide & Seek started on Day 1???" + gSaveContext.save.weekEventReg[73] &= (u8)~0x10; + // Unconfirmed: "Bombers Hide & Seek in Progress" + gSaveContext.save.weekEventReg[85] &= (u8)~2; +} + +u16 Sram_CalcChecksum(void* data, size_t count) { + u8* dataPtr = data; + u16 chkSum = 0; + + while (count-- > 0) { + chkSum += *dataPtr; + dataPtr++; + } + return chkSum; +} + +// Resets `Save` substruct +void Sram_ResetSave(void) { + gSaveContext.save.entranceIndex = 0x1C00; + gSaveContext.save.equippedMask = 0; + gSaveContext.save.isFirstCycle = false; + gSaveContext.save.unk_06 = 0; + gSaveContext.save.linkAge = 0; + gSaveContext.save.isNight = false; + gSaveContext.save.daySpeed = 0; + gSaveContext.save.snowheadCleared = 0; + gSaveContext.save.hasTatl = false; + gSaveContext.save.isOwlSave = false; + + // Instead of bloating all save context accesses with an extra sub-struct, the size of the would-be sub-struct + // is calculated manually + bzero(&gSaveContext.save.playerData, sizeof(Save) - offsetof(Save, playerData)); +} + +/** + * Initializes with random values the following fields: + * - lotteryCodes + * - spiderHouseMaskOrder + * - bomberCode + */ +void Sram_GenerateRandomSaveFields(void) { + s32 randBombers; + s16 sp2A; + s16 pad; + s16 i; + s16 j; + s32 k; + s16 randSpiderHouse; + + Sram_ClearHighscores(); + + gSaveContext.save.lotteryCodes[0][0] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[0][1] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[0][2] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[1][0] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[1][1] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[1][2] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[2][0] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[2][1] = Rand_S16Offset(0, 10); + gSaveContext.save.lotteryCodes[2][2] = Rand_S16Offset(0, 10); + + // Needed to match... + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) {} + } + + i = 0; + sp2A = Rand_S16Offset(0, 16) & 3; + k = 6; + while (i != k) { + randSpiderHouse = Rand_S16Offset(0, 16) & 3; + if (sp2A != randSpiderHouse) { + gSaveContext.save.spiderHouseMaskOrder[i] = randSpiderHouse; + i++; + sp2A = randSpiderHouse; + } + } + + do { + randBombers = Rand_S16Offset(0, 6); + } while (randBombers <= 0 || randBombers >= 6); + + gSaveContext.save.bomberCode[0] = randBombers; + + i = 1; + while (i != 5) { + k = false; + + do { + randBombers = Rand_S16Offset(0, 6); + } while (randBombers <= 0 || randBombers >= 6); + + sp2A = 0; + do { + if (randBombers == gSaveContext.save.bomberCode[sp2A]) { + k = true; + } + sp2A++; + } while (sp2A < i); + + if (k == false) { + gSaveContext.save.bomberCode[i] = randBombers; + i++; + } + } +} + +SavePlayerData sSaveDefaultPlayerData = { + { '\0', '\0', '\0', '\0', '\0', '\0' }, // newf + 0, // deaths + { 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E }, // playerName " " + 0x30, // healthCapacity + 0x30, // health + 0, // magicLevel + 0x30, // magic + 0, // rupees + 0, // swordHealth + 0, // tatlTimer + 0, // magicAcquired + 0, // doubleMagic + 0, // doubleDefense + 0, // unk_1F + 0xFF, // unk_20 + 0x0000, // owlActivationFlags + 0xFF, // unk_24 + SCENE_SPOT00, // savedSceneNum +}; + +ItemEquips sSaveDefaultItemEquips = { + { + { ITEM_SWORD_KOKIRI, ITEM_NONE, ITEM_NONE, ITEM_NONE }, + { ITEM_SWORD_KOKIRI, ITEM_NONE, ITEM_NONE, ITEM_NONE }, + { ITEM_SWORD_KOKIRI, ITEM_NONE, ITEM_NONE, ITEM_NONE }, + { ITEM_UNK_FD, ITEM_NONE, ITEM_NONE, ITEM_NONE }, + }, + { + { SLOT_OCARINA, SLOT_NONE, SLOT_NONE, SLOT_NONE }, + { SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE }, + { SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE }, + { SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE }, + }, + 0x11, +}; + +Inventory sSaveDefaultInventory = { + // items + { + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + }, + // ammo + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + // upgrades + 0x120000, + // questItems + 0, + // dungeonItems + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + // dungeonKeys + { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0 }, + // strayFairies + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + // dekuPlaygroundPlayerName + { + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + }, +}; + +u16 sSaveDefaultChecksum = 0; + +/** + * Initialize new save. + * This save has an empty inventory with 3 hearts, sword and shield. + */ +void Sram_InitNewSave(void) { + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.save.daysElapsed = 0; + gSaveContext.save.day = 0; + gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; + Sram_ResetSave(); + + Lib_MemCpy(&gSaveContext.save.playerData, &sSaveDefaultPlayerData, sizeof(SavePlayerData)); + Lib_MemCpy(&gSaveContext.save.equips, &sSaveDefaultItemEquips, sizeof(ItemEquips)); + Lib_MemCpy(&gSaveContext.save.inventory, &sSaveDefaultInventory, sizeof(Inventory)); + Lib_MemCpy(&gSaveContext.save.checksum, &sSaveDefaultChecksum, sizeof(gSaveContext.save.checksum)); + + gSaveContext.save.horseData.scene = SCENE_F01; + gSaveContext.save.horseData.pos.x = -1420; + gSaveContext.save.horseData.pos.y = 257; + gSaveContext.save.horseData.pos.z = -1285; + gSaveContext.save.horseData.yaw = -0x7554; + + gSaveContext.nextCutsceneIndex = 0; + gSaveContext.save.playerData.magicLevel = 0; + Sram_GenerateRandomSaveFields(); +} + +SavePlayerData sSaveDebugPlayerData = { + { 'Z', 'E', 'L', 'D', 'A', '3' }, // newf + 0x0000, // deaths + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, // playerName "LINK " + 0x80, // healthCapacity + 0x80, // health + 0, // magicLevel + 0x30, // magic + 0x32, // rupees + 0x64, // swordHealth + 0, // tatlTimer + 1, // magicAcquired + 0, // doubleMagic + 0, // doubleDefense + 0, // unk_1F + 0xFF, // unk_20 + 0, // owlActivationFlags + 0xFF, // unk_24 + SCENE_SPOT00, // savedSceneNum +}; + +ItemEquips sSaveDebugItemEquips = { + { + { ITEM_SWORD_KOKIRI, ITEM_BOW, ITEM_POTION_RED, ITEM_OCARINA }, + { ITEM_SWORD_KOKIRI, ITEM_BOW, ITEM_MASK_GORON, ITEM_OCARINA }, + { ITEM_SWORD_KOKIRI, ITEM_BOW, ITEM_MASK_ZORA, ITEM_OCARINA }, + { ITEM_NUT, ITEM_NUT, ITEM_MASK_DEKU, ITEM_OCARINA }, + }, + { + { SLOT_OCARINA, SLOT_BOW, SLOT_BOTTLE_2, SLOT_OCARINA }, + { SLOT_OCARINA, SLOT_MAGIC_BEANS, SLOT_MASK_GORON, SLOT_BOMBCHU }, + { SLOT_OCARINA, SLOT_POWDER_KEG, SLOT_MASK_ZORA, SLOT_BOMBCHU }, + { SLOT_OCARINA, SLOT_BOW, SLOT_MASK_DEKU, SLOT_BOMBCHU }, + }, + 0x11, +}; + +Inventory sSaveDebugInventory = { + // items + { + ITEM_OCARINA, + ITEM_BOW, + ITEM_ARROW_FIRE, + ITEM_ARROW_ICE, + ITEM_ARROW_LIGHT, + ITEM_MOON_TEAR, + ITEM_BOMB, + ITEM_BOMBCHU, + ITEM_STICK, + ITEM_NUT, + ITEM_MAGIC_BEANS, + ITEM_ROOM_KEY, + ITEM_POWDER_KEG, + ITEM_PICTO_BOX, + ITEM_LENS, + ITEM_HOOKSHOT, + ITEM_SWORD_GREAT_FAIRY, + ITEM_LETTER_TO_KAFEI, + ITEM_BOTTLE, + ITEM_POTION_RED, + ITEM_POTION_GREEN, + ITEM_POTION_BLUE, + ITEM_NONE, + ITEM_NONE, + ITEM_MASK_POSTMAN, + ITEM_MASK_ALL_NIGHT, + ITEM_MASK_BLAST, + ITEM_MASK_STONE, + ITEM_MASK_GREAT_FAIRY, + ITEM_MASK_DEKU, + ITEM_MASK_KEATON, + ITEM_MASK_BREMEN, + ITEM_MASK_BUNNY, + ITEM_MASK_DON_GERO, + ITEM_MASK_SCENTS, + ITEM_MASK_GORON, + ITEM_MASK_ROMANI, + ITEM_MASK_CIRCUS_LEADER, + ITEM_MASK_KAFEIS_MASK, + ITEM_MASK_COUPLE, + ITEM_MASK_TRUTH, + ITEM_MASK_ZORA, + ITEM_MASK_KAMARO, + ITEM_MASK_GIBDO, + ITEM_MASK_GARO, + ITEM_MASK_CAPTAIN, + ITEM_MASK_GIANT, + ITEM_MASK_FIERCE_DEITY, + }, + // ammo + { 1, 30, 1, 1, 1, 1, 30, 30, 30, 30, 1, 1, 1, 1, 30, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + // upgrades + 0x120009, + // questItems + (1 << QUEST_SONG_SONATA) | (1 << QUEST_SONG_LULLABY) | (1 << QUEST_SONG_BOSSA_NOVA) | (1 << QUEST_SONG_ELEGY) | + (1 << QUEST_SONG_OATH) | (1 << QUEST_SONG_TIME) | (1 << QUEST_SONG_HEALING) | (1 << QUEST_SONG_EPONA) | + (1 << QUEST_SONG_SOARING) | (1 << QUEST_SONG_STORMS) | (1 << QUEST_BOMBERS_NOTEBOOK) | + (1 << QUEST_SONG_LULLABY_INTRO), + // dungeonItems + { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, + // dungeonKeys + { 8, 8, 8, 8, 8, 8, 8, 8, 8, 0 }, + // strayFairies + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + // dekuPlaygroundPlayerName + { + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + }, +}; + +u16 sSaveDebugChecksum = 0; + +u8 D_801C6A48[] = { + ITEM_MASK_FIERCE_DEITY, ITEM_MASK_GORON, ITEM_MASK_ZORA, ITEM_MASK_DEKU, ITEM_MASK_FIERCE_DEITY, +}; + +u8 D_801C6A50[] = { + SLOT_MASK_FIERCE_DEITY, SLOT_MASK_GORON, SLOT_MASK_ZORA, SLOT_MASK_DEKU, SLOT_MASK_FIERCE_DEITY, +}; + +/** + * Initialize debug save. This is also used on the Title Screen + * This save has a mostly full inventory, every mask and 10 hearts. + * + * Some noteable flags that are set: + * TODO: Investigate the flags + */ +void Sram_InitDebugSave(void) { + Sram_ResetSave(); + + Lib_MemCpy(&gSaveContext.save.playerData, &sSaveDebugPlayerData, sizeof(SavePlayerData)); + Lib_MemCpy(&gSaveContext.save.equips, &sSaveDebugItemEquips, sizeof(ItemEquips)); + Lib_MemCpy(&gSaveContext.save.inventory, &sSaveDebugInventory, sizeof(Inventory)); + Lib_MemCpy(&gSaveContext.save.checksum, &sSaveDebugChecksum, sizeof(gSaveContext.save.checksum)); + + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + BUTTON_ITEM_EQUIP(0, 2) = D_801C6A48[((void)0, gSaveContext.save.playerForm & 0xFF)]; + C_SLOT_EQUIP(0, 2) = D_801C6A50[((void)0, gSaveContext.save.playerForm & 0xFF)]; + } + + gSaveContext.save.hasTatl = true; + + gSaveContext.save.horseData.scene = SCENE_F01; + gSaveContext.save.horseData.pos.x = -1420; + gSaveContext.save.horseData.pos.y = 257; + gSaveContext.save.horseData.pos.z = -1285; + gSaveContext.save.horseData.yaw = -0x7554; + + gSaveContext.save.entranceIndex = 0x1C00; + gSaveContext.save.isFirstCycle = true; + + // + gSaveContext.save.weekEventReg[0x0F] |= 0x20; + // Unconfirmed: "Entered South Clock Town" + gSaveContext.save.weekEventReg[0x3B] |= 0x04; + // Unconfirmed: "Tatl's Second Cycle Text?" + gSaveContext.save.weekEventReg[0x1F] |= 0x04; + + gSaveContext.cycleSceneFlags[SCENE_INSIDETOWER].switch0 = 1; + gSaveContext.save.permanentSceneFlags[SCENE_INSIDETOWER].switch0 = 1; + gSaveContext.save.playerData.magicLevel = 0; + + Sram_GenerateRandomSaveFields(); +} + +// Unused +void func_80144A94(SramContext* sramCtx) { + s32 i; + s32 cutscene = gSaveContext.save.cutscene; + + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + + if (func_80185968(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2], D_801C67F0[gSaveContext.fileNum * 2]) != + 0) { + func_80185968(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2 + 1], + D_801C67F0[gSaveContext.fileNum * 2 + 1]); + } + Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); + if (CHECK_NEWF(gSaveContext.save.playerData.newf)) { + func_80185968(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2 + 1], + D_801C67F0[gSaveContext.fileNum * 2 + 1]); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, sizeof(Save)); + } + gSaveContext.save.cutscene = cutscene; + + for (i = 0; i < ARRAY_COUNT(gSaveContext.eventInf); i++) { + gSaveContext.eventInf[i] = 0; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.cycleSceneFlags[i].chest = gSaveContext.save.permanentSceneFlags[i].chest; + gSaveContext.cycleSceneFlags[i].switch0 = gSaveContext.save.permanentSceneFlags[i].switch0; + gSaveContext.cycleSceneFlags[i].switch1 = gSaveContext.save.permanentSceneFlags[i].switch1; + gSaveContext.cycleSceneFlags[i].clearedRoom = gSaveContext.save.permanentSceneFlags[i].clearedRoom; + gSaveContext.cycleSceneFlags[i].collectible = gSaveContext.save.permanentSceneFlags[i].collectible; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3DD0); i++) { + gSaveContext.unk_3DD0[i] = 0; + gSaveContext.unk_3DE0[i] = 0; + gSaveContext.unk_3E18[i] = 0; + gSaveContext.unk_3E50[i] = 0; + gSaveContext.unk_3E88[i] = 0; + gSaveContext.unk_3EC0[i] = 0; + } + + D_801BDAA0 = 1; + D_801BDA9C = 0; + gSaveContext.powderKegTimer = 0; + gSaveContext.unk_1014 = 0; + gSaveContext.jinxTimer = 0; +} + +u16 D_801C6A58[] = { 0x68B0, 0x6A60, 0xB230, 0x9A80, 0xD890, 0x3E40, 0x8640, 0x84A0, 0x2040, 0xAA30 }; + +#ifdef NON_MATCHING +// Small regalloc between v0/t6/t7 +void Sram_OpenSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) { + s32 i; + s32 pad; + s32 phi_t1; + s32 pad1[2]; + s32 fileNum; + + if (gSaveContext.unk_3F3F) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + + if (gSaveContext.fileNum == 0xFF) { + func_80185968(sramCtx->saveBuf, D_801C67C8[0], D_801C67F0[0]); + } else if (fileChooseCtx->unk_2446A[gSaveContext.fileNum] != 0) { + phi_t1 = gSaveContext.fileNum + 2; + phi_t1 *= 2; + + if (func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1], D_801C67F0[phi_t1]) != 0) { + func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1 + 1], D_801C67F0[phi_t1 + 1]); + } + } else { + phi_t1 = gSaveContext.fileNum; + phi_t1 *= 2; + + if (func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1], D_801C67F0[phi_t1]) != 0) { + func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1 + 1], D_801C67F0[phi_t1 + 1]); + } + } + + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[phi_t1]); + + if (CHECK_NEWF(gSaveContext.save.playerData.newf)) { + func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1 + 1], D_801C67F0[phi_t1 + 1]); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[phi_t1]); + } + } + + gSaveContext.save.playerData.magicLevel = 0; + + if (!gSaveContext.save.isOwlSave) { + for (i = 0; i < ARRAY_COUNT(gSaveContext.eventInf); i++) { + gSaveContext.eventInf[i] = 0; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.cycleSceneFlags[i].chest = gSaveContext.save.permanentSceneFlags[i].chest; + gSaveContext.cycleSceneFlags[i].switch0 = gSaveContext.save.permanentSceneFlags[i].switch0; + gSaveContext.cycleSceneFlags[i].switch1 = gSaveContext.save.permanentSceneFlags[i].switch1; + gSaveContext.cycleSceneFlags[i].clearedRoom = gSaveContext.save.permanentSceneFlags[i].clearedRoom; + gSaveContext.cycleSceneFlags[i].collectible = gSaveContext.save.permanentSceneFlags[i].collectible; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3DD0); i++) { + gSaveContext.unk_3DD0[i] = 0; + gSaveContext.unk_3DE0[i] = 0; + gSaveContext.unk_3E18[i] = 0; + gSaveContext.unk_3E50[i] = 0; + gSaveContext.unk_3E88[i] = 0; + gSaveContext.unk_3EC0[i] = 0; + } + + if (gSaveContext.save.isFirstCycle) { + gSaveContext.save.entranceIndex = 0xD800; + gSaveContext.save.day = 0; + gSaveContext.save.time = 0x3FFF; + } else { + gSaveContext.save.entranceIndex = 0x1C00; + gSaveContext.nextCutsceneIndex = 0; + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + } + } else { + gSaveContext.save.entranceIndex = D_801C6A58[gSaveContext.save.owlSaveLocation]; + if (D_801C6A58[gSaveContext.save.owlSaveLocation] == 0x84A0 && (gSaveContext.save.weekEventReg[20] & 2)) { + // Unconfirmed weekEventReg: "Woodfall Temple Prison Entrance raised / Water cleansed" + gSaveContext.save.entranceIndex = 0xCA0; + } else if (D_801C6A58[gSaveContext.save.owlSaveLocation] == 0x9A80 && + (gSaveContext.save.weekEventReg[33] & 0x80)) { + // Unconfirmed weekEventReg: "Mountain Village Unfrozen" + gSaveContext.save.entranceIndex = 0xAE80; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.cycleSceneFlags[i].chest = gSaveContext.save.permanentSceneFlags[i].chest; + gSaveContext.cycleSceneFlags[i].switch0 = gSaveContext.save.permanentSceneFlags[i].switch0; + gSaveContext.cycleSceneFlags[i].switch1 = gSaveContext.save.permanentSceneFlags[i].switch1; + gSaveContext.cycleSceneFlags[i].clearedRoom = gSaveContext.save.permanentSceneFlags[i].clearedRoom; + gSaveContext.cycleSceneFlags[i].collectible = gSaveContext.save.permanentSceneFlags[i].collectible; + } + + if (gSaveContext.save.unk_F65) { + Lib_MemCpy(D_801D88A0, gSaveContext.save.scarecrowsSong, sizeof(gSaveContext.save.scarecrowsSong)); + + for (i = 0; i != ARRAY_COUNT(gSaveContext.save.scarecrowsSong); i++) {} + } + + fileNum = gSaveContext.fileNum; + func_80147314(sramCtx, fileNum); + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_OpenSave.s") +#endif + +// Similar to func_80145698, but accounts for owl saves? +void func_8014546C(SramContext* sramCtx) { + s32 i; + + if (gSaveContext.save.isOwlSave) { + for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.save.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; + gSaveContext.save.permanentSceneFlags[i].switch0 = gSaveContext.cycleSceneFlags[i].switch0; + gSaveContext.save.permanentSceneFlags[i].switch1 = gSaveContext.cycleSceneFlags[i].switch1; + gSaveContext.save.permanentSceneFlags[i].clearedRoom = gSaveContext.cycleSceneFlags[i].clearedRoom; + gSaveContext.save.permanentSceneFlags[i].collectible = gSaveContext.cycleSceneFlags[i].collectible; + } + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext, offsetof(SaveContext, fileNum)); + + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext, offsetof(SaveContext, fileNum)); + } else { + for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.save.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; + gSaveContext.save.permanentSceneFlags[i].switch0 = gSaveContext.cycleSceneFlags[i].switch0; + gSaveContext.save.permanentSceneFlags[i].switch1 = gSaveContext.cycleSceneFlags[i].switch1; + gSaveContext.save.permanentSceneFlags[i].clearedRoom = gSaveContext.cycleSceneFlags[i].clearedRoom; + gSaveContext.save.permanentSceneFlags[i].collectible = gSaveContext.cycleSceneFlags[i].collectible; + } + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); + + if (gSaveContext.unk_3F3F) { + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext, sizeof(Save)); + Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); + } + } +} + +/** + * Save permanent scene flags, calculate checksum, copy save context to the save buffer + */ +void func_80145698(SramContext* sramCtx) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.save.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; + gSaveContext.save.permanentSceneFlags[i].switch0 = gSaveContext.cycleSceneFlags[i].switch0; + gSaveContext.save.permanentSceneFlags[i].switch1 = gSaveContext.cycleSceneFlags[i].switch1; + gSaveContext.save.permanentSceneFlags[i].clearedRoom = gSaveContext.cycleSceneFlags[i].clearedRoom; + gSaveContext.save.permanentSceneFlags[i].collectible = gSaveContext.cycleSceneFlags[i].collectible; + } + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); + if (gSaveContext.unk_3F3F) { + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext, sizeof(Save)); + Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); + } +} + +// Verifies save and use backup if corrupted? +#ifdef NON_EQUIVALENT +void func_801457CC(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { + FileChooseContext* fileChooseCtx = fileChooseCtx2; + u16 sp7A; + // u16 sp78; + u16 sp76; + // u16 sp74; + u16 sp6E; //! + // s32 sp68; + // u16 sp66; + u16 phi_s2; //! + u16 sp64; + // s32 sp60; + // s32 sp5C; + // s32 sp58; + // u32 new_var; + u16 phi_s2_3; + // s16 fakevar; + + u16 temp_s2; + u16 temp_v0_2; + u16 phi_a0; // maskCount + + if (gSaveContext.unk_3F3F) { + D_801F6AF0 = gSaveContext.save.time; + D_801F6AF2 = gSaveContext.unk_3F3F; + sp64 = 0; + + for (sp76 = 0; sp76 < 5; sp76++, sp64 += 2) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + + phi_s2 = false; + sp6E = 0; + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64], D_801C67F0[sp64])) { + sp6E = 1; + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { + phi_s2 = true; + } + } + + if (sp76 < 2) { + fileChooseCtx->unk_24468[sp76] = 0; + if (phi_s2) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + } else { + // Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + temp_s2 = gSaveContext.save.checksum; + gSaveContext.save.checksum = 0; + temp_v0_2 = Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]); + gSaveContext.save.checksum = temp_s2; + + if (CHECK_NEWF(gSaveContext.save.playerData.newf) || (temp_s2 != temp_v0_2)) { + sp6E = 1; + if (CHECK_NEWF2(gSaveContext.save.playerData.newf)) {} + + phi_s2 = false; + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { + phi_s2 = true; + } + + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + temp_s2 = gSaveContext.save.checksum; + gSaveContext.save.checksum = 0; + if (phi_s2 || CHECK_NEWF(gSaveContext.save.playerData.newf) || + (temp_s2 != Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]))) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); + sp6E = 999; + } + } + } + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = + Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64 & 0xFFFFFFFF]); // TODO: Needed? + + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.newf); sp7A++) { + fileChooseCtx->newf[sp76][sp7A] = gSaveContext.save.playerData.newf[sp7A]; + } + + if (!CHECK_NEWF(fileChooseCtx->newf[sp76])) { + fileChooseCtx->unk_2440C[sp76] = gSaveContext.save.playerData.deaths; + + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.playerName); sp7A++) { + fileChooseCtx->unk_24414[sp76][sp7A] = gSaveContext.save.playerData.playerName[sp7A]; + } + + fileChooseCtx->healthCapacity[sp76] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->health[sp76] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24454[sp76] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_24444[sp76] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_24458[sp76] = gSaveContext.save.time; + fileChooseCtx->unk_24460[sp76] = gSaveContext.save.day; + fileChooseCtx->unk_24468[sp76] = gSaveContext.save.isOwlSave; + fileChooseCtx->rupees[sp76] = gSaveContext.save.playerData.rupees; + fileChooseCtx->unk_24474[sp76] = CUR_UPG_VALUE(4); + + for (sp7A = 0, phi_a0 = 0; sp7A < 24; sp7A++) { + if (gSaveContext.save.inventory.items[sp7A + 24] != 0xFF) { + phi_a0++; + } + } + fileChooseCtx->maskCount[sp76] = phi_a0; + fileChooseCtx->heartPieceCount[sp76] = + ((gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C); + } + + if (sp6E == 1) { + Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); + func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C6818[sp64]); + } else if (sp6E == 0) { // TODO: == 0? + temp_s2 = gSaveContext.save.checksum; + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { + phi_s2_3 = 1; + } else { + Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); + phi_s2_3 = gSaveContext.save.checksum; + gSaveContext.save.checksum = 0; + sp7A = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); + } + + if (CHECK_NEWF(gSaveContext.save.playerData.newf) || (phi_s2_3 != sp7A) || (phi_s2_3 != temp_s2)) { + func_80185968(sramCtx->saveBuf, D_801C67C8[sp64], D_801C67F0[sp64]); + Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); + Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); + func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C6818[sp64]); + } + } + } else if (sp76 < 4) { + fileChooseCtx->unk_24468[sp76] = 0; + + if (!CHECK_NEWF(fileChooseCtx->newf2[(s32)sp76])) { // TODO: Needed? + if (phi_s2) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, + D_801C6870[sp64]); // TODO: Needed? + } else { + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + temp_s2 = gSaveContext.save.checksum; + + gSaveContext.save.checksum = 0; + temp_v0_2 = Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]); + gSaveContext.save.checksum = temp_s2; + if (CHECK_NEWF(gSaveContext.save.playerData.newf) || (temp_s2 != temp_v0_2)) { + sp6E = 1; + if ((gSaveContext.save.playerData.newf[0] == 'Z') && + (gSaveContext.save.playerData.newf[1] == 'E')) { + phi_s2 = false; + } + + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { + phi_s2 = true; + } + + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + temp_s2 = gSaveContext.save.checksum; + gSaveContext.save.checksum = 0; + if (phi_s2 || CHECK_NEWF(gSaveContext.save.playerData.newf) || + (temp_s2 != Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]))) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + sp6E = 999; + } + } + } + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = + Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64 & 0xFFFFFFFF]); // TODO: Needed? + + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.newf); sp7A++) { + fileChooseCtx->newf[sp76][sp7A] = gSaveContext.save.playerData.newf[sp7A]; + } + + if (!CHECK_NEWF(fileChooseCtx->newf[sp76])) { + fileChooseCtx->unk_2440C[sp76] = gSaveContext.save.playerData.deaths; + + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.playerName); sp7A++) { + phi_s2 += 0; // TODO: Needed? + fileChooseCtx->unk_24414[sp76][sp7A] = gSaveContext.save.playerData.playerName[sp7A]; + } + + fileChooseCtx->healthCapacity[sp76] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->health[sp76] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24454[sp76] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_24444[sp76] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_24458[sp76] = gSaveContext.save.time; + fileChooseCtx->unk_24460[sp76] = gSaveContext.save.day; + fileChooseCtx->unk_24468[sp76] = gSaveContext.save.isOwlSave; + fileChooseCtx->rupees[sp76] = gSaveContext.save.playerData.rupees; + fileChooseCtx->unk_24474[sp76] = CUR_UPG_VALUE(4); + + for (sp7A = 0, phi_a0 = 0; sp7A < 24; sp7A++) { + if (gSaveContext.save.inventory.items[sp7A + 24] != 0xFF) { + phi_a0++; + } + } + fileChooseCtx->maskCount[sp76] = phi_a0; + fileChooseCtx->heartPieceCount[sp76] = + ((gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C); + } + + if (sp6E == 1) { + func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C67F0[sp64]); + func_80146EBC(sramCtx, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1]); + } else if (!sp6E) { // TODO: == 0? + temp_s2 = gSaveContext.save.checksum; + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { + phi_s2_3 = 1; + } else { + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + phi_s2_3 = gSaveContext.save.checksum; + gSaveContext.save.checksum = 0; + // phi_s2_3 = gSaveContext.save.checksum; + sp7A = Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]); + } + + if (CHECK_NEWF(gSaveContext.save.playerData.newf) || (phi_s2_3 != sp7A) || + (phi_s2_3 != temp_s2)) { + func_80185968(sramCtx->saveBuf, D_801C67C8[sp64], D_801C67F0[sp64]); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C67F0[sp64]); + func_80146EBC(sramCtx, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1]); + } + } + } else { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C67F0[sp64]); + func_80146EBC(sramCtx, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1]); + } + } else { + if (phi_s2) { + gSaveContext.options.optionId = 0xA51D; + gSaveContext.options.language = 1; + gSaveContext.options.audioSetting = 0; + gSaveContext.options.languageSetting = 0; + gSaveContext.options.zTargetSetting = 0; + } else { + Lib_MemCpy(&gSaveContext.options, sramCtx->saveBuf, sizeof(SaveOptions)); + if (gSaveContext.options.optionId != 0xA51D) { + gSaveContext.options.optionId = 0xA51D; + gSaveContext.options.language = 1; + gSaveContext.options.audioSetting = 0; + gSaveContext.options.languageSetting = 0; + gSaveContext.options.zTargetSetting = 0; + } + } + func_801A3D98(gSaveContext.options.audioSetting); + } + } + + gSaveContext.save.time = D_801F6AF0; + gSaveContext.unk_3F3F = D_801F6AF2; + } + + gSaveContext.options.language = 1; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_801457CC.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146580.s") +void func_80146580(FileChooseContext* fileChooseCtx2, SramContext* sramCtx, s32 fileNum) { + FileChooseContext* fileChooseCtx = fileChooseCtx2; + s32 pad; + if (gSaveContext.unk_3F3F) { + if (fileChooseCtx->unk_2446A[fileNum]) { + func_80147314(sramCtx, fileNum); + fileChooseCtx->unk_2446A[fileNum] = 0; + } + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, sizeof(Save)); + } + + gSaveContext.save.time = D_801F6AF0; + gSaveContext.unk_3F3F = D_801F6AF2; +} + +#ifdef NON_MATCHING +// v0/v1 +void func_80146628(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { + FileChooseContext* fileChooseCtx = fileChooseCtx2; + u16 i; + s16 maskCount; + + if (gSaveContext.unk_3F3F) { + if (fileChooseCtx->unk_2446A[fileChooseCtx->unk_2448E]) { + func_80147414(sramCtx, fileChooseCtx->unk_2448E, fileChooseCtx->fileNum); + fileChooseCtx->unk_24410[fileChooseCtx->fileNum] = gSaveContext.save.playerData.deaths; + + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { + fileChooseCtx->unk_24424[fileChooseCtx->fileNum][i] = gSaveContext.save.playerData.playerName[i]; + } + + fileChooseCtx->unk_24438[fileChooseCtx->fileNum] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->unk_24440[fileChooseCtx->fileNum] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24456[fileChooseCtx->fileNum] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_2444C[fileChooseCtx->fileNum] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_2445C[fileChooseCtx->fileNum] = gSaveContext.save.time; + fileChooseCtx->unk_24464[fileChooseCtx->fileNum] = gSaveContext.save.day; + fileChooseCtx->unk_2446A[fileChooseCtx->fileNum] = gSaveContext.save.isOwlSave; + fileChooseCtx->unk_24470[fileChooseCtx->fileNum] = gSaveContext.save.playerData.rupees; + // = CUR_UPG_VALUE(UPG_WALLET); + fileChooseCtx->unk_24476[fileChooseCtx->fileNum] = + (gSaveContext.save.inventory.upgrades & gUpgradeMasks[4]) >> gUpgradeShifts[4]; + + for (i = 0, maskCount = 0; i < 24; i++) { + if (gSaveContext.save.inventory.items[i + 24] != ITEM_NONE) { + maskCount++; + } + } + + fileChooseCtx->unk_2447A[fileChooseCtx->fileNum] = maskCount; + fileChooseCtx->unk_2447E[fileChooseCtx->fileNum] = + (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; + } + + // clear buffer + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + // read to buffer + func_80185968(sramCtx->saveBuf, D_801C67C8[fileChooseCtx->unk_2448E * 2], + D_801C67F0[fileChooseCtx->unk_2448E * 2]); + + if (1) {} + func_80185968(&sramCtx->saveBuf[0x2000], D_801C67C8[fileChooseCtx->unk_2448E * 2 + 1], + D_801C67F0[fileChooseCtx->unk_2448E * 2 + 1]); + if (1) {} + + // copy buffer to save context + Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); + + fileChooseCtx->unk_2440C[fileChooseCtx->fileNum] = gSaveContext.save.playerData.deaths; + + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { + fileChooseCtx->unk_24414[fileChooseCtx->fileNum][i] = gSaveContext.save.playerData.playerName[i]; + } + + fileChooseCtx->healthCapacity[fileChooseCtx->fileNum] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->health[fileChooseCtx->fileNum] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24454[fileChooseCtx->fileNum] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_24444[fileChooseCtx->fileNum] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_24458[fileChooseCtx->fileNum] = gSaveContext.save.time; + fileChooseCtx->unk_24460[fileChooseCtx->fileNum] = gSaveContext.save.day; + fileChooseCtx->unk_24468[fileChooseCtx->fileNum] = gSaveContext.save.isOwlSave; + fileChooseCtx->rupees[fileChooseCtx->fileNum] = gSaveContext.save.playerData.rupees; + // = CUR_UPG_VALUE(UPG_WALLET); + fileChooseCtx->unk_24474[fileChooseCtx->fileNum] = + (gSaveContext.save.inventory.upgrades & gUpgradeMasks[4]) >> gUpgradeShifts[4]; + + for (i = 0, maskCount = 0; i < 24; i++) { + if (gSaveContext.save.inventory.items[i + 24] != ITEM_NONE) { + maskCount++; + } + } + + fileChooseCtx->maskCount[fileChooseCtx->fileNum] = maskCount; + fileChooseCtx->heartPieceCount[fileChooseCtx->fileNum] = + (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; + } + + gSaveContext.save.time = D_801F6AF0; + gSaveContext.unk_3F3F = D_801F6AF2; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146628.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146AA0.s") +void Sram_InitSave(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { + s32 phi_v0; + u16 i; + FileChooseContext* fileChooseCtx = fileChooseCtx2; + s16 maskCount; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146DF8.s") + if (gSaveContext.unk_3F3F) { + Sram_InitNewSave(); + if (fileChooseCtx->unk_24480 == 0) { + gSaveContext.save.cutscene = 0xFFF0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146E40.s") + for (phi_v0 = 0; phi_v0 < ARRAY_COUNT(gSaveContext.save.playerData.playerName); phi_v0++) { + gSaveContext.save.playerData.playerName[phi_v0] = + fileChooseCtx->unk_24414[fileChooseCtx->unk_24480][phi_v0]; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_Alloc.s") + gSaveContext.save.playerData.newf[0] = 'Z'; + gSaveContext.save.playerData.newf[1] = 'E'; + gSaveContext.save.playerData.newf[2] = 'L'; + gSaveContext.save.playerData.newf[3] = 'D'; + gSaveContext.save.playerData.newf[4] = 'A'; + gSaveContext.save.playerData.newf[5] = '3'; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146EBC.s") + gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146EE8.s") + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext.save, sizeof(Save)); + Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146F5C.s") + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.newf); i++) { + fileChooseCtx->newf[fileChooseCtx->unk_24480][i] = gSaveContext.save.playerData.newf[i]; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147008.s") + fileChooseCtx->unk_2440C[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.deaths; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147020.s") + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { + fileChooseCtx->unk_24414[fileChooseCtx->unk_24480][i] = gSaveContext.save.playerData.playerName[i]; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147068.s") + fileChooseCtx->healthCapacity[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->health[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24454[fileChooseCtx->unk_24480] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_24444[fileChooseCtx->unk_24480] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_24458[fileChooseCtx->unk_24480] = gSaveContext.save.time; + fileChooseCtx->unk_24460[fileChooseCtx->unk_24480] = gSaveContext.save.day; + fileChooseCtx->unk_24468[fileChooseCtx->unk_24480] = gSaveContext.save.isOwlSave; + fileChooseCtx->rupees[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.rupees; + fileChooseCtx->unk_24474[fileChooseCtx->unk_24480] = CUR_UPG_VALUE(UPG_WALLET); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147138.s") + for (i = 0, maskCount = 0; i < 24; i++) { + if (gSaveContext.save.inventory.items[i + 24] != ITEM_NONE) { + maskCount++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147150.s") + fileChooseCtx->maskCount[fileChooseCtx->unk_24480] = maskCount; + fileChooseCtx->heartPieceCount[fileChooseCtx->unk_24480] = + (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147198.s") + gSaveContext.save.time = D_801F6AF0; + gSaveContext.unk_3F3F = D_801F6AF2; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147314.s") +void func_80146DF8(SramContext* sramCtx) { + if (gSaveContext.unk_3F3F) { + // TODO: macros for languages + gSaveContext.options.language = 1; + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext.options, sizeof(SaveOptions)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147414.s") +void Sram_InitSram(GameState* gameState, SramContext* sramCtx) { + if (&gSaveContext.save) {} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_nop8014750C.s") + func_801A3D98(gSaveContext.options.audioSetting); +} + +void Sram_Alloc(GameState* gamestate, SramContext* sramCtx) { + if (gSaveContext.unk_3F3F) { + sramCtx->saveBuf = THA_AllocEndAlign16(&gamestate->heap, SAVE_BUFFER_SIZE); + sramCtx->status = 0; + } +} + +/** + * Synchronous flash write + */ +void func_80146EBC(SramContext* sramCtx, s32 curPage, s32 numPages) { + sramCtx->curPage = curPage; + sramCtx->numPages = numPages; + func_80185F64(sramCtx->saveBuf, curPage, numPages); +} + +/** + * Saves the game on the very first time Player enters South Clock Town from the Clock Tower + */ +void Sram_SaveSpecialEnterClockTown(GlobalContext* globalCtx) { + s32 pad[2]; + SramContext* sramCtx = &globalCtx->sramCtx; + + gSaveContext.save.isFirstCycle = true; + gSaveContext.save.isOwlSave = false; + func_80145698(sramCtx); + func_80185F64(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2], D_801C6818[gSaveContext.fileNum * 2]); +} + +/** + * Saves when beating the game, after showing the "Dawn of the New Day" message + */ +void Sram_SaveSpecialNewDay(GlobalContext* globalCtx) { + s32 cutscene = gSaveContext.save.cutscene; + s32 day; + u16 time = gSaveContext.save.time; + + day = gSaveContext.save.day; + + // Unconfirmed: "Obtained Fierce Deity Mask?" + gSaveContext.save.weekEventReg[84] &= (u8)~0x20; + + Sram_SaveEndOfCycle(globalCtx); + func_8014546C(&globalCtx->sramCtx); + + gSaveContext.save.day = day; + gSaveContext.save.time = time; + gSaveContext.save.cutscene = cutscene; + func_80185F64(globalCtx->sramCtx.saveBuf, D_801C67C8[gSaveContext.fileNum * 2], + D_801C67F0[gSaveContext.fileNum * 2]); +} + +void func_80147008(SramContext* sramCtx, u32 curPage, u32 numPages) { + sramCtx->curPage = curPage; + sramCtx->numPages = numPages; + sramCtx->status = 1; +} + +void func_80147020(SramContext* sramCtx) { + // async flash write + func_80185DDC(sramCtx->saveBuf, sramCtx->curPage, sramCtx->numPages); + + sramCtx->unk_18 = osGetTime(); + sramCtx->status = 2; +} + +void func_80147068(SramContext* sramCtx) { + if (sramCtx->status == 2) { + if (func_80185EC4() != 0) { // if task running + if (func_80185F04() == 0) { // wait for task done + // task success + sramCtx->status = 4; + } else { + // task failure + sramCtx->status = 4; + } + } + } else if (((osGetTime() - sramCtx->unk_18) * 0x40) / 3000 / 10000 >= 200) { + sramCtx->status = 0; + } +} + +void func_80147138(SramContext* sramCtx, s32 curPage, s32 numPages) { + sramCtx->curPage = curPage; + sramCtx->numPages = numPages; + sramCtx->status = 6; +} + +void func_80147150(SramContext* sramCtx) { + func_80185DDC(sramCtx->saveBuf, sramCtx->curPage, sramCtx->numPages); + + sramCtx->unk_18 = osGetTime(); + sramCtx->status = 7; +} + +void func_80147198(SramContext* sramCtx) { + if (sramCtx->status == 7) { + if (func_80185EC4() != 0) { // Is task running + if (func_80185F04() == 0) { // Wait for task done + func_80185DDC(sramCtx->saveBuf, sramCtx->curPage + 0x80, sramCtx->numPages); + sramCtx->status = 8; + } else { + func_80185DDC(sramCtx->saveBuf, sramCtx->curPage + 0x80, sramCtx->numPages); + sramCtx->status = 8; + } + } + } else if (sramCtx->status == 8) { + if (func_80185EC4() != 0) { // Is task running + if (func_80185F04() == 0) { // Wait for task done + sramCtx->status = 4; + } else { + sramCtx->status = 4; + } + } + } else if (((osGetTime() - sramCtx->unk_18) * 0x40) / 3000 / 10000 >= 200) { + sramCtx->status = 0; + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + gSaveContext.save.isOwlSave = false; + gSaveContext.save.checksum = 0; + // flash read to buffer then copy to save context + func_80185968(sramCtx->saveBuf, sramCtx->curPage, sramCtx->numPages); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, offsetof(SaveContext, fileNum)); + } +} + +void func_80147314(SramContext* sramCtx, s32 fileNum) { + s32 pad; + + gSaveContext.save.isOwlSave = false; + + gSaveContext.save.playerData.newf[0] = '\0'; + gSaveContext.save.playerData.newf[1] = '\0'; + gSaveContext.save.playerData.newf[2] = '\0'; + gSaveContext.save.playerData.newf[3] = '\0'; + gSaveContext.save.playerData.newf[4] = '\0'; + gSaveContext.save.playerData.newf[5] = '\0'; + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext, offsetof(SaveContext, fileNum)); + + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext, offsetof(SaveContext, fileNum)); + func_80146EBC(sramCtx, D_801C6840[fileNum * 2], D_801C6850[fileNum * 2]); + func_80146EBC(sramCtx, D_801C6840[fileNum * 2 + 1], D_801C6850[fileNum * 2]); + + gSaveContext.save.isOwlSave = true; + + gSaveContext.save.playerData.newf[0] = 'Z'; + gSaveContext.save.playerData.newf[1] = 'E'; + gSaveContext.save.playerData.newf[2] = 'L'; + gSaveContext.save.playerData.newf[3] = 'D'; + gSaveContext.save.playerData.newf[4] = 'A'; + gSaveContext.save.playerData.newf[5] = '3'; +} + +void func_80147414(SramContext* sramCtx, s32 fileNum, s32 arg2) { + s32 pad; + + // Clear save buffer + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + + // Read save file + if (func_80185968(sramCtx->saveBuf, D_801C6840[fileNum * 2], D_801C6850[fileNum * 2]) != 0) { + // If failed, read backup save file + func_80185968(sramCtx->saveBuf, D_801C6840[fileNum * 2 + 1], D_801C6850[fileNum * 2 + 1]); + } + + // Copy buffer to save context + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, offsetof(SaveContext, fileNum)); + + func_80146EBC(sramCtx, D_801C6840[arg2 * 2], D_801C6850[arg2 * 2]); + func_80146EBC(sramCtx, D_801C6840[arg2 * 2 + 1], D_801C6850[arg2 * 2]); +} + +void Sram_nop8014750C(UNK_TYPE4 arg0) { +} diff --git a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c index 7cd39251c..023b4b706 100644 --- a/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c +++ b/src/overlays/actors/ovl_Bg_Iknv_Obj/z_bg_iknv_obj.c @@ -84,7 +84,7 @@ void BgIknvObj_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; - gSaveContext.weekEventReg[51] &= (u8)~0x10; + gSaveContext.save.weekEventReg[51] &= (u8)~0x10; Actor_SetFocus(&this->dyna.actor, IREG(88)); break; default: @@ -98,7 +98,7 @@ void BgIknvObj_Destroy(Actor* thisx, GlobalContext* globalCtx) { if (IKNV_OBJ_TYPE(this) != IKNV_OBJ_RAISED_DOOR) { if (IKNV_OBJ_TYPE(this) == IKNV_OBJ_SAKON_DOOR) { Collider_DestroyCylinder(globalCtx, &this->collider); - gSaveContext.weekEventReg[51] &= (u8)~0x10; + gSaveContext.save.weekEventReg[51] &= (u8)~0x10; } else { return; } @@ -125,7 +125,7 @@ s32 func_80BD7CEC(BgIknvObj* this) { } void BgIknvObj_UpdateWaterwheel(BgIknvObj* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[14] & 4) { + if (gSaveContext.save.weekEventReg[14] & 4) { this->dyna.actor.shape.rot.z -= 0x64; func_800B9098(&this->dyna.actor); func_800B9010(&this->dyna.actor, NA_SE_EV_WOOD_WATER_WHEEL - SFX_FLAG); @@ -156,16 +156,16 @@ s32 func_80BD7E0C(BgIknvObj* this, s16 targetRotation, GlobalContext* globalCtx) void func_80BD7ED8(BgIknvObj* this, GlobalContext* globalCtx) { if (func_80BD7E0C(this, this->dyna.actor.home.rot.y, globalCtx)) { this->actionFunc = BgIknvObj_UpdateSakonDoor; - gSaveContext.weekEventReg[51] &= (u8)~0x10; + gSaveContext.save.weekEventReg[51] &= (u8)~0x10; } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } void func_80BD7F4C(BgIknvObj* this, GlobalContext* globalCtx) { - if (gSaveContext.time > CLOCK_TIME(19, 30)) { + if (gSaveContext.save.time > CLOCK_TIME(19, 30)) { this->actionFunc = func_80BD7ED8; } - if ((this->dyna.actor.home.rot.x == 1) && !(gSaveContext.weekEventReg[58] & 0x80)) { + if ((this->dyna.actor.home.rot.x == 1) && !(gSaveContext.save.weekEventReg[58] & 0x80)) { ActorCutscene_Stop(this->dyna.actor.cutscene); this->dyna.actor.home.rot.x = 0; } @@ -175,7 +175,7 @@ void func_80BD7F4C(BgIknvObj* this, GlobalContext* globalCtx) { void func_80BD7FDC(BgIknvObj* this, GlobalContext* globalCtx) { if (func_80BD7E0C(this, this->dyna.actor.home.rot.y + 0x4000, globalCtx)) { this->actionFunc = func_80BD7F4C; - gSaveContext.weekEventReg[51] |= 0x10; + gSaveContext.save.weekEventReg[51] |= 0x10; this->dyna.actor.home.rot.x = 1; } } @@ -188,9 +188,9 @@ void func_80BD8040(BgIknvObj* this, GlobalContext* globalCtx) { } void BgIknvObj_UpdateSakonDoor(BgIknvObj* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[58] & 0x80) { + if (gSaveContext.save.weekEventReg[58] & 0x80) { this->actionFunc = func_80BD8040; - gSaveContext.weekEventReg[89] |= 0x80; + gSaveContext.save.weekEventReg[89] |= 0x80; } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index d84003061..2648b3069 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -194,7 +194,7 @@ void func_80953F9C(BgIngate* this, GlobalContext* globalCtx) { this->dyna.actor.textId = 0x9E4; Message_StartTextbox(globalCtx, this->dyna.actor.textId, NULL); this->unk16C += 1; - gSaveContext.weekEventReg[90] |= 0x40; + gSaveContext.save.weekEventReg[90] |= 0x40; this->actionFunc = func_809543D4; } else { @@ -253,7 +253,7 @@ void func_809542A0(BgIngate* this, GlobalContext* globalCtx) { globalCtx->unk_1887F = 3; gSaveContext.nextTransition = 3; this->actionFunc = func_80953F8C; - gSaveContext.weekEventReg[90] &= (u8)~0x40; + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; func_800FE498(); } @@ -289,7 +289,7 @@ void func_809543D4(BgIngate* this, GlobalContext* globalCtx) { this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; } func_80953F14(this, globalCtx); - gSaveContext.weekEventReg[90] &= (u8)~0x40; + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; func_8019F230(); } func_801477B4(globalCtx); @@ -297,7 +297,7 @@ void func_809543D4(BgIngate* this, GlobalContext* globalCtx) { case 0x9E6: if (globalCtx->msgCtx.choiceIndex == 0) { func_80953EA4(this, globalCtx); - gSaveContext.weekEventReg[90] &= (u8)~0x40; + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; func_8019F208(); } else { this = this; @@ -330,10 +330,10 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_SetScale(&this->dyna.actor, 1.0f); this->unk164 = func_8013BB34(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); this->dyna.actor.room = -1; - if (gSaveContext.weekEventReg[20] & 2) { - gSaveContext.weekEventReg[90] &= (u8)~0x40; + if (gSaveContext.save.weekEventReg[20] & 2) { + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; } - if (!(gSaveContext.eventInf[3] & 0x20) && (gSaveContext.weekEventReg[90] & 0x40)) { + if (!(gSaveContext.eventInf[3] & 0x20) && (gSaveContext.save.weekEventReg[90] & 0x40)) { phi_a2 = 1; this->unk16C = 1; this->actionFunc = func_809541B8; diff --git a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c index d169be6de..6e27d1dc9 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c @@ -194,7 +194,7 @@ void BgKin2Fence_HandleMaskCode(BgKin2Fence* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { hitMask = BgKin2Fence_CheckHitMask(this); if (hitMask >= 0) { - nextMask = (s8)gSaveContext.spiderHouseMaskOrder[this->masksHit]; + nextMask = (s8)gSaveContext.save.spiderHouseMaskOrder[this->masksHit]; if (hitMask == nextMask) { play_sound(NA_SE_SY_TRE_BOX_APPEAR); this->masksHit += 1; diff --git a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c index 5c2a972b5..71f1d2b6a 100644 --- a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c +++ b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c @@ -97,7 +97,7 @@ void BgLotus_Wait(BgLotus* this, GlobalContext* globalCtx) { EffectSsGRipple_Spawn(globalCtx, &this->dyna.actor.world.pos, 1000, 1400, 8); this->timer = 40; } - if (gSaveContext.playerForm != PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm != PLAYER_FORM_DEKU) { this->timer = 40; this->dyna.actor.flags |= ACTOR_FLAG_10; this->actionFunc = BgLotus_Sink; diff --git a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c index bf556345f..186376d9b 100644 --- a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c +++ b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c @@ -161,7 +161,7 @@ void BgNumaHana_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - if (gSaveContext.weekEventReg[12] & 1) { + if (gSaveContext.save.weekEventReg[12] & 1) { func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); this->petalZRotation = 0x2000; @@ -219,7 +219,7 @@ void BgNumaHana_ClosedIdle(BgNumaHana* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FLAME_IGNITION); if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - gSaveContext.weekEventReg[12] |= 1; + gSaveContext.save.weekEventReg[12] |= 1; Flags_SetSwitch(globalCtx, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor)); BgNumaHana_SetupUnfoldInnerPetals(this); } else { diff --git a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c index 3adec0ce4..f9b76fd00 100644 --- a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c +++ b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c @@ -38,13 +38,13 @@ void BgTobira01_Open(BgTobira01* this, GlobalContext* globalCtx) { ActorCutscene_Stop(0x7C); } else if (ActorCutscene_GetCanPlayNext(cutsceneId)) { ActorCutscene_StartAndSetUnkLinkFields(cutsceneId, &this->dyna.actor); - gSaveContext.weekEventReg[88] |= 0x40; + gSaveContext.save.weekEventReg[88] |= 0x40; this->playCutscene = false; } else { ActorCutscene_SetIntentToPlay(cutsceneId); } - } else if (!(gSaveContext.weekEventReg[88] & 0x40) && (this->timer == 0) && (globalCtx->actorCtx.unk1F5 != 0) && - (globalCtx->actorCtx.unk1F4 == 0) && + } else if (!(gSaveContext.save.weekEventReg[88] & 0x40) && (this->timer == 0) && + (globalCtx->actorCtx.unk1F5 != 0) && (globalCtx->actorCtx.unk1F4 == 0) && (SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId) == 6)) { this->playCutscene = true; @@ -53,7 +53,7 @@ void BgTobira01_Open(BgTobira01* this, GlobalContext* globalCtx) { prevTimer = this->timer; - if (gSaveContext.weekEventReg[88] & 0x40) { + if (gSaveContext.save.weekEventReg[88] & 0x40) { this->timer++; } else { this->timer--; @@ -68,8 +68,8 @@ void BgTobira01_Open(BgTobira01* this, GlobalContext* globalCtx) { this->timer2 = 180; } - if (!(player->stateFlags1 & 0x40) && (gSaveContext.weekEventReg[88] & 0x40) && (DECR(this->timer2) == 0)) { - gSaveContext.weekEventReg[88] &= (u8)~0x40; + if (!(player->stateFlags1 & 0x40) && (gSaveContext.save.weekEventReg[88] & 0x40) && (DECR(this->timer2) == 0)) { + gSaveContext.save.weekEventReg[88] &= (u8)~0x40; } } @@ -79,9 +79,9 @@ void BgTobira01_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_Init(&this->dyna, 1); DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spot11_obj_Colheader_0011C0); - gSaveContext.weekEventReg[88] &= (u8)~0x40; + gSaveContext.save.weekEventReg[88] &= (u8)~0x40; Actor_SetScale(&this->dyna.actor, 1.0f); - this->timer2 = gSaveContext.isNight; + this->timer2 = gSaveContext.save.isNight; this->timer = 0; this->actionFunc = BgTobira01_Open; } diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index af5e4fbe1..e2a4e41f5 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -549,7 +549,7 @@ void Boss02_Init(Actor* thisx, GlobalContext* globalCtx) { s32 i; s32 pad[2]; - if ((gSaveContext.weekEventReg[52] & 0x20) && (this->actor.params == 0)) { + if ((gSaveContext.save.weekEventReg[52] & 0x20) && (this->actor.params == 0)) { D_809E0434 = (DoorWarp1*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, 60.0f, 0.0f, 0, 0, 0, 1); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 0.0f, 30.0f, -150.0f, 0, 1, 0, 0); @@ -2057,7 +2057,7 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { break; case 1: - if ((gSaveContext.weekEventReg[52] & 0x20) || ((u32)(KREG(13) + 15) >= this->unk_1D1C)) { + if ((gSaveContext.save.weekEventReg[52] & 0x20) || ((u32)(KREG(13) + 15) >= this->unk_1D1C)) { break; } Cutscene_Start(globalCtx, &globalCtx->csCtx); diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index 72fc0253a..5a88f67c6 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -519,7 +519,7 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_8012C2DC(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - temp_v0 = gSaveContext.time; + temp_v0 = gSaveContext.save.time; if (temp_v0 > CLOCK_TIME(12, 0)) { temp_v0 = 0xFFFF - temp_v0; } diff --git a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c index 959207b8d..b4537b1af 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -66,7 +66,7 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { switch (DMCHAR01_GET(&this->dyna.actor)) { case DMCHAR01_0: - if (gSaveContext.weekEventReg[20] & 2) { + if (gSaveContext.save.weekEventReg[20] & 2) { this->unk_34C = 2; this->actionFunc = func_80AA8F1C; break; @@ -96,7 +96,7 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { break; case DMCHAR01_1: - if ((gSaveContext.weekEventReg[20] & 2) || (gSaveContext.sceneSetupIndex == 1)) { + if ((gSaveContext.save.weekEventReg[20] & 2) || (gSaveContext.sceneSetupIndex == 1)) { this->unk_34C = 1; this->actionFunc = func_80AA8F1C; } else { @@ -106,7 +106,7 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { case DMCHAR01_2: this->unk_34C = 0; - if (!(gSaveContext.weekEventReg[20] & 1)) { + if (!(gSaveContext.save.weekEventReg[20] & 1)) { this->unk_34C = 1; this->dyna.actor.world.pos.y -= 400.0f; } @@ -122,7 +122,7 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { case DMCHAR01_3: this->dyna.actor.world.rot.y += 0x8000; this->dyna.actor.shape.rot.y += 0x8000; - if (!(gSaveContext.weekEventReg[20] & 1)) { + if (!(gSaveContext.save.weekEventReg[20] & 1)) { Actor_MarkForDeath(&this->dyna.actor); return; } @@ -132,7 +132,7 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_mtoride_Colheader_00FE5C); this->unk_34D = true; - if (!(gSaveContext.weekEventReg[20] & 2)) { + if (!(gSaveContext.save.weekEventReg[20] & 2)) { this->actionFunc = func_80AA9020; this->dyna.actor.world.pos.y -= 120.0f; } else { @@ -158,7 +158,7 @@ void func_80AA8698(DmChar01* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Player* player2 = GET_PLAYER(globalCtx); - if (gSaveContext.weekEventReg[20] & 1) { + if (gSaveContext.save.weekEventReg[20] & 1) { return; } @@ -178,7 +178,7 @@ void func_80AA8698(DmChar01* this, GlobalContext* globalCtx) { if ((player2->actor.world.pos.x > -40.0f) && (player2->actor.world.pos.x < 40.0f) && (player2->actor.world.pos.z > 1000.0f) && (player2->actor.world.pos.z < 1078.0f)) { - gSaveContext.weekEventReg[20] |= 1; + gSaveContext.save.weekEventReg[20] |= 1; this->actionFunc = func_80AA884C; } } @@ -344,7 +344,7 @@ void func_80AA9020(DmChar01* this, GlobalContext* globalCtx) { CsCmdActorAction* temp_v1 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 135)]; if ((temp_v1->startFrame == globalCtx->csCtx.frames) && (temp_v1->action == 2)) { - gSaveContext.weekEventReg[20] |= 2; + gSaveContext.save.weekEventReg[20] |= 2; this->actionFunc = func_80AA90AC; } } diff --git a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c index 4c39ddd54..bb8b735a4 100644 --- a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c +++ b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c @@ -30,7 +30,7 @@ const ActorInit Dm_Ravine_InitVars = { void DmRavine_Init(Actor* thisx, GlobalContext* globalCtx) { DmRavine* this = THIS; - u8 flag = gSaveContext.weekEventReg[0]; + u8 flag = gSaveContext.save.weekEventReg[0]; if (((flag & 0x10) | cREG(0)) != 0) { Actor_MarkForDeath(&this->actor); return; diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index eb1316f69..08e515d26 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -841,7 +841,7 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); - if (gSaveContext.entranceIndex == 0x2C00) { + if (gSaveContext.save.entranceIndex == 0x2C00) { if (gSaveContext.sceneSetupIndex == 0) { if (gSaveContext.unk_3DD0[3] == 0) { func_8010E9F0(3, 300); @@ -849,7 +849,7 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { XREG(81) = 115; } - if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { sCylinderInit.base.colType = COLTYPE_WOOD; this->actionFunc = func_80AA18D8; } else { @@ -938,7 +938,7 @@ void func_80AA1704(DmStk* this, GlobalContext* globalCtx) { void func_80AA1714(DmStk* this, GlobalContext* globalCtx) { Vec3f sp1C; - if (!(gSaveContext.weekEventReg[74] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[74] & 0x20)) { func_80169474(globalCtx, &this->actor.world.pos, &sp1C); if (globalCtx->view.fovy < 25.0f) { if ((sp1C.x >= 70.0f) && (sp1C.x < 250.0f) && (sp1C.y >= 30.0f) && (sp1C.y < 210.0f)) { @@ -955,10 +955,10 @@ void func_80AA17F8(DmStk* this, GlobalContext* globalCtx) { s16 sp18 = ActorCutscene_GetAdditionalCutscene(sp1C); s16 cutscene; - if (gSaveContext.day < 3) { + if (gSaveContext.save.day < 3) { cutscene = sp1E; - } else if ((gSaveContext.weekEventReg[8] & 0x40) || - ((CURRENT_DAY == 3) && (gSaveContext.time < CLOCK_TIME(6, 0)))) { + } else if ((gSaveContext.save.weekEventReg[8] & 0x40) || + ((CURRENT_DAY == 3) && (gSaveContext.save.time < CLOCK_TIME(6, 0)))) { cutscene = sp18; } else { cutscene = sp1C; @@ -1171,7 +1171,7 @@ void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { case 22: this->unk_2E0 = 29; - if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { this->unk_32D = 3; } break; @@ -1183,7 +1183,7 @@ void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { case 24: this->unk_2E0 = 32; - if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { this->unk_32D = 3; } break; @@ -1194,14 +1194,14 @@ void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { case 26: this->unk_2E0 = 34; - if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { this->unk_32D = 3; } break; case 27: this->unk_2E0 = 36; - if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { this->unk_32D = 3; } break; @@ -1399,7 +1399,7 @@ void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { if (this->unk_2E4 < 0) { this->unk_2E4 = 0; this->unk_32F = 0; - gSaveContext.weekEventReg[12] |= 4; + gSaveContext.save.weekEventReg[12] |= 4; if (!(globalCtx->actorCtx.unk5 & 2)) { Actor_MarkForDeath(&this->actor); } else { @@ -1569,11 +1569,11 @@ void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { (globalCtx->msgCtx.currentTextId == 0x5E6) && !FrameAdvance_IsEnabled(&globalCtx->state) && (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { - time = gSaveContext.time; - gSaveContext.time = (u16)REG(15) + time; + time = gSaveContext.save.time; + gSaveContext.save.time = (u16)REG(15) + time; if (REG(15) != 0) { - time = gSaveContext.time; - gSaveContext.time = (u16)gSaveContext.unk_14 + time; + time = gSaveContext.save.time; + gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + time; } } } diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c index f814eeafd..b512dff9a 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -139,13 +139,13 @@ void DoorAna_WaitOpen(DoorAna* this, GlobalContext* globalCtx) { } else { s32 destinationIdx = DOORANA_GET_ENTRANCE(&this->actor); - Play_SetupRespawnPoint(&globalCtx->state, 3, 0x4FF); + Play_SetupRespawnPoint(&globalCtx->state, RESPAWN_MODE_UNK_3, 0x4FF); - gSaveContext.respawn[3].pos.y = this->actor.world.pos.y; - gSaveContext.respawn[3].yaw = this->actor.home.rot.y; + gSaveContext.respawn[RESPAWN_MODE_UNK_3].pos.y = this->actor.world.pos.y; + gSaveContext.respawn[RESPAWN_MODE_UNK_3].yaw = this->actor.home.rot.y; // Stores item and chest flag that ACTOR_EN_TORCH uses for spawning the grotto chest - gSaveContext.respawn[3].data = DOORANA_GET_ITEMFLAGS(&this->actor); + gSaveContext.respawn[RESPAWN_MODE_UNK_3].data = DOORANA_GET_ITEMFLAGS(&this->actor); if (destinationIdx < 0) { destinationIdx = DOORANA_GET_EX_ENTRANCE(&this->actor); diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index e28e05a16..01430acc3 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -344,7 +344,7 @@ void func_808A1090(DoorShutter* this, GlobalContext* globalCtx) { if (this->unk_166 != 0) { Flags_SetSwitch(globalCtx, DOORSHUTTER_GET_7F(&this->actor)); if (this->doorType != 5) { - gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex]--; + gSaveContext.save.inventory.dungeonKeys[gSaveContext.mapIndex]--; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK_B); @@ -367,7 +367,7 @@ void func_808A1090(DoorShutter* this, GlobalContext* globalCtx) { } if (this->doorType == 6) { - if (gSaveContext.healthCapacity < (DOORSHUTTER_GET_1F(&this->actor) * 0x10)) { + if (gSaveContext.save.playerData.healthCapacity < (DOORSHUTTER_GET_1F(&this->actor) * 0x10)) { player->doorType = -1; this->actor.textId = 0x14FC; } @@ -570,7 +570,7 @@ void func_808A1884(DoorShutter* this, GlobalContext* globalCtx) { if (DoorShutter_SetupDoor(this, globalCtx) && !(player->stateFlags1 & 0x800)) { DoorShutter_SetupAction(this, func_808A1C50); if (ActorCutscene_GetCurrentIndex() == 0x7D) { - s8 data = gSaveContext.respawn[0].data; + s8 data = gSaveContext.respawn[RESTART_MODE_DOWN].data; func_801226E0(globalCtx, data); player->unk_A86 = -1; diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index 4f89b39b7..0360ae87a 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -270,7 +270,7 @@ void func_808B8E78(DoorWarp1* this, GlobalContext* globalCtx) { this->unk_1A4 = 700.0f; if (globalCtx->sceneNum == SCENE_INISIE_N) { DoorWarp1_SetupAction(this, func_808B96A0); - } else if (gSaveContext.weekEventReg[86] & 0x80) { + } else if (gSaveContext.save.weekEventReg[86] & 0x80) { this->unk_1D4 = 0; DoorWarp1_SetupAction(this, func_808B921C); } else { @@ -553,27 +553,28 @@ void func_808B9CE8(DoorWarp1* this, GlobalContext* globalCtx) { switch (globalCtx->sceneNum) { case SCENE_MITURIN_BS: - gSaveContext.unk_ECC[0] = - (((void)0, gSaveContext.unk_ECC[0]) & 0xFFFFFF00) | (((u8)gSaveContext.unk_ECC[1]) & 0xFF); + gSaveContext.save.unk_ECC[0] = + (((void)0, gSaveContext.save.unk_ECC[0]) & 0xFFFFFF00) | (((u8)gSaveContext.save.unk_ECC[1]) & 0xFF); break; case SCENE_HAKUGIN_BS: - gSaveContext.unk_ECC[0] = - (((void)0, gSaveContext.unk_ECC[0]) & 0xFFFF00FF) | ((((u8)gSaveContext.unk_ECC[1]) & 0xFF) << 8); + gSaveContext.save.unk_ECC[0] = (((void)0, gSaveContext.save.unk_ECC[0]) & 0xFFFF00FF) | + ((((u8)gSaveContext.save.unk_ECC[1]) & 0xFF) << 8); break; case SCENE_INISIE_BS: - gSaveContext.unk_ECC[0] = - (((void)0, gSaveContext.unk_ECC[0]) & 0xFF00FFFF) | ((((u8)gSaveContext.unk_ECC[1]) & 0xFF) << 0x10); + gSaveContext.save.unk_ECC[0] = (((void)0, gSaveContext.save.unk_ECC[0]) & 0xFF00FFFF) | + ((((u8)gSaveContext.save.unk_ECC[1]) & 0xFF) << 0x10); break; case SCENE_SEA_BS: - gSaveContext.unk_ECC[0] = - (((void)0, gSaveContext.unk_ECC[0]) & 0x00FFFFFF) | ((((u8)gSaveContext.unk_ECC[1]) & 0xFF) << 0x18); + gSaveContext.save.unk_ECC[0] = (((void)0, gSaveContext.save.unk_ECC[0]) & 0x00FFFFFF) | + ((((u8)gSaveContext.save.unk_ECC[1]) & 0xFF) << 0x18); break; } - gSaveContext.unk_ECC[1] = (gSaveContext.unk_ECC[1] & 0xFFFFFF00) | ((((u8)gSaveContext.unk_ECC[1]) + 1) & 0xFF); + gSaveContext.save.unk_ECC[1] = + (gSaveContext.save.unk_ECC[1] & 0xFFFFFF00) | ((((u8)gSaveContext.save.unk_ECC[1]) + 1) & 0xFF); Item_Give(globalCtx, func_808B849C(this, globalCtx) + (ITEM_REMAINS_ODOLWA - 1)); DoorWarp1_SetupAction(this, func_808B9E94); } @@ -651,24 +652,24 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { if (this->unk_202 != 0) { if (phi_v0_2 > 0) { - gSaveContext.weekEventReg[7] |= 0x80; + gSaveContext.save.weekEventReg[7] |= 0x80; } switch (phi_v0_2) { case 0: - phi_a0 = gSaveContext.unk_ECC[0] & 0xFF; + phi_a0 = gSaveContext.save.unk_ECC[0] & 0xFF; break; case 1: - phi_a0 = (gSaveContext.unk_ECC[0] & 0xFF00) >> 8; + phi_a0 = (gSaveContext.save.unk_ECC[0] & 0xFF00) >> 8; break; case 2: - phi_a0 = (gSaveContext.unk_ECC[0] & 0xFF0000) >> 0x10; + phi_a0 = (gSaveContext.save.unk_ECC[0] & 0xFF0000) >> 0x10; break; case 3: - phi_a0 = (gSaveContext.unk_ECC[0] & 0xFF000000) >> 0x18; + phi_a0 = (gSaveContext.save.unk_ECC[0] & 0xFF000000) >> 0x18; break; default: @@ -709,8 +710,8 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { } else { switch (phi_v0_2) { case 0: - if (gSaveContext.weekEventReg[20] & 2) { - gSaveContext.weekEventReg[7] |= 0x80; + if (gSaveContext.save.weekEventReg[20] & 2) { + gSaveContext.save.weekEventReg[7] |= 0x80; globalCtx->nextEntranceIndex = 0x3010; globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 3; @@ -725,7 +726,7 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { break; case 1: - gSaveContext.weekEventReg[33] |= 0x80; + gSaveContext.save.weekEventReg[33] |= 0x80; globalCtx->nextEntranceIndex = 0xAE70; globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 3; @@ -733,14 +734,14 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { break; case 3: - if (gSaveContext.weekEventReg[55] & 0x80) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { globalCtx->nextEntranceIndex = 0x6A90; gSaveContext.nextCutsceneIndex = 0xFFF0; globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 3; gSaveContext.nextTransition = 3; } else { - gSaveContext.weekEventReg[55] |= 0x80; + gSaveContext.save.weekEventReg[55] |= 0x80; globalCtx->nextEntranceIndex = 0x6A80; gSaveContext.nextCutsceneIndex = 0xFFF0; globalCtx->sceneLoadFlag = 0x14; @@ -750,7 +751,7 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { break; case 2: - gSaveContext.weekEventReg[52] |= 0x20; + gSaveContext.save.weekEventReg[52] |= 0x20; globalCtx->nextEntranceIndex = 0x20F0; gSaveContext.nextCutsceneIndex = 0xFFF2; globalCtx->sceneLoadFlag = 0x14; @@ -885,14 +886,14 @@ void func_808BAAF4(DoorWarp1* this, GlobalContext* globalCtx) { phi_f2 = 85.0f; } - if (!(gSaveContext.weekEventReg[86] & 0x80) && (fabsf(this->dyna.actor.xzDistToPlayer) < phi_f2) && + if (!(gSaveContext.save.weekEventReg[86] & 0x80) && (fabsf(this->dyna.actor.xzDistToPlayer) < phi_f2) && ((player->actor.world.pos.y - 20.0f) < this->dyna.actor.world.pos.y) && (this->dyna.actor.world.pos.y < (player->actor.world.pos.y + 20.0f))) { cutscene = this->dyna.actor.cutscene; if (ActorCutscene_GetCanPlayNext(cutscene)) { ActorCutscene_Start(cutscene, &this->dyna.actor); - gSaveContext.weekEventReg[86] |= 0x80; + gSaveContext.save.weekEventReg[86] |= 0x80; DoorWarp1_SetupAction(this, func_808BABF4); } else { ActorCutscene_SetIntentToPlay(cutscene); diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index 4250a71d5..be25dec24 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -338,7 +338,7 @@ s32* func_80BD3294(EnAh* this, GlobalContext* globalCtx) { switch (this->unk_1DC) { case 1: - if (gSaveContext.day == 2) { + if (gSaveContext.save.day == 2) { return D_80BD3DF0; } return D_80BD3DE8; diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c index cd36694cc..21691cbf8 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -257,17 +257,17 @@ void func_80BED090(GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (player->transformation == PLAYER_FORM_DEKU) { - gSaveContext.weekEventReg[63] |= 8; - gSaveContext.weekEventReg[63] &= (u8)~0x10; + gSaveContext.save.weekEventReg[63] |= 8; + gSaveContext.save.weekEventReg[63] &= (u8)~0x10; } else if (player->transformation == PLAYER_FORM_ZORA) { - gSaveContext.weekEventReg[63] &= (u8)~8; - gSaveContext.weekEventReg[63] |= 0x10; + gSaveContext.save.weekEventReg[63] &= (u8)~8; + gSaveContext.save.weekEventReg[63] |= 0x10; } else if (player->transformation == PLAYER_FORM_GORON) { - gSaveContext.weekEventReg[63] |= 8; - gSaveContext.weekEventReg[63] |= 0x10; + gSaveContext.save.weekEventReg[63] |= 8; + gSaveContext.save.weekEventReg[63] |= 0x10; } else if (player->transformation == PLAYER_FORM_HUMAN) { - gSaveContext.weekEventReg[63] &= (u8)~8; - gSaveContext.weekEventReg[63] &= (u8)~0x10; + gSaveContext.save.weekEventReg[63] &= (u8)~8; + gSaveContext.save.weekEventReg[63] &= (u8)~0x10; } } @@ -275,19 +275,19 @@ s32 func_80BED140(GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (player->transformation == PLAYER_FORM_DEKU) { - if ((gSaveContext.weekEventReg[63] & 8) && !(gSaveContext.weekEventReg[63] & 0x10)) { + if ((gSaveContext.save.weekEventReg[63] & 8) && !(gSaveContext.save.weekEventReg[63] & 0x10)) { return true; } } else if (player->transformation == PLAYER_FORM_ZORA) { - if (!(gSaveContext.weekEventReg[63] & 8) && (gSaveContext.weekEventReg[63] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[63] & 8) && (gSaveContext.save.weekEventReg[63] & 0x10)) { return true; } } else if (player->transformation == PLAYER_FORM_GORON) { - if ((gSaveContext.weekEventReg[63] & 8) && (gSaveContext.weekEventReg[63] & 0x10)) { + if ((gSaveContext.save.weekEventReg[63] & 8) && (gSaveContext.save.weekEventReg[63] & 0x10)) { return true; } } else if (player->transformation == PLAYER_FORM_HUMAN) { - if (!(gSaveContext.weekEventReg[63] & 8) && !(gSaveContext.weekEventReg[63] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[63] & 8) && !(gSaveContext.save.weekEventReg[63] & 0x10)) { return true; } } @@ -300,7 +300,7 @@ s32 func_80BED208(EnAkindonuts* this) { return 0; } - if (gSaveContext.rupees < 10) { + if (gSaveContext.save.playerData.rupees < 10) { return 1; } @@ -314,15 +314,15 @@ s32 func_80BED208(EnAkindonuts* this) { } s32 func_80BED27C(EnAkindonuts* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 3) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 3) { return 2; } - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) < 2) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) < 2) { return 0; } - if (gSaveContext.rupees < 200) { + if (gSaveContext.save.playerData.rupees < 200) { return 1; } @@ -336,7 +336,7 @@ s32 func_80BED2FC(EnAkindonuts* this) { return 2; } - if (gSaveContext.rupees < 40) { + if (gSaveContext.save.playerData.rupees < 40) { return 1; } @@ -350,7 +350,7 @@ s32 func_80BED35C(EnAkindonuts* this) { return 2; } - if (gSaveContext.rupees < 100) { + if (gSaveContext.save.playerData.rupees < 100) { return 1; } @@ -384,8 +384,8 @@ void func_80BED3BC(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 0x15E7: - if (!(gSaveContext.weekEventReg[61] & 0x20)) { - gSaveContext.weekEventReg[61] |= 0x20; + if (!(gSaveContext.save.weekEventReg[61] & 0x20)) { + gSaveContext.save.weekEventReg[61] |= 0x20; this->unk_33C = 0x15E8; break; } @@ -446,7 +446,7 @@ void func_80BED3BC(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x15E5: this->unk_33C = 0x15E6; func_80BED090(globalCtx); - gSaveContext.weekEventReg[61] |= 0x10; + gSaveContext.save.weekEventReg[61] |= 0x10; this->unk_32C |= 0x20; break; @@ -461,8 +461,8 @@ void func_80BED3BC(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BED680(EnAkindonuts* this, GlobalContext* globalCtx) { switch (this->unk_33C) { case 0: - if (func_80BED140(globalCtx) && !(gSaveContext.weekEventReg[61] & 0x40)) { - gSaveContext.weekEventReg[61] |= 0x40; + if (func_80BED140(globalCtx) && !(gSaveContext.save.weekEventReg[61] & 0x40)) { + gSaveContext.save.weekEventReg[61] |= 0x40; this->unk_33C = 0x15F0; break; } @@ -562,8 +562,8 @@ void func_80BED8A4(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 0x15FE: - if (!(gSaveContext.weekEventReg[62] & 1)) { - gSaveContext.weekEventReg[62] |= 1; + if (!(gSaveContext.save.weekEventReg[62] & 1)) { + gSaveContext.save.weekEventReg[62] |= 1; this->unk_33C = 0x15FF; break; } @@ -623,7 +623,7 @@ void func_80BED8A4(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x15FA: this->unk_33C = 0x15FB; - gSaveContext.weekEventReg[61] |= 0x80; + gSaveContext.save.weekEventReg[61] |= 0x80; this->unk_32C |= 0x20; break; @@ -640,8 +640,8 @@ void func_80BEDB88(EnAkindonuts* this, GlobalContext* globalCtx) { switch (this->unk_33C) { case 0: - if ((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.weekEventReg[62] & 2)) { - gSaveContext.weekEventReg[62] |= 2; + if ((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.save.weekEventReg[62] & 2)) { + gSaveContext.save.weekEventReg[62] |= 2; this->unk_33C = 0x15F0; break; } @@ -740,8 +740,8 @@ void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 0x1610: - if (!(gSaveContext.weekEventReg[62] & 8)) { - gSaveContext.weekEventReg[62] |= 8; + if (!(gSaveContext.save.weekEventReg[62] & 8)) { + gSaveContext.save.weekEventReg[62] |= 8; this->unk_33C = 0x1611; break; } @@ -796,7 +796,7 @@ void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x15FA: this->unk_33C = 0x160D; - gSaveContext.weekEventReg[62] |= 4; + gSaveContext.save.weekEventReg[62] |= 4; this->unk_32C |= 0x20; break; @@ -813,8 +813,8 @@ void func_80BEE070(EnAkindonuts* this, GlobalContext* globalCtx) { switch (this->unk_33C) { case 0: - if ((player->transformation == PLAYER_FORM_GORON) && !(gSaveContext.weekEventReg[62] & 0x10)) { - gSaveContext.weekEventReg[62] |= 0x10; + if ((player->transformation == PLAYER_FORM_GORON) && !(gSaveContext.save.weekEventReg[62] & 0x10)) { + gSaveContext.save.weekEventReg[62] |= 0x10; this->unk_33C = 0x1614; break; } @@ -900,8 +900,8 @@ void func_80BEE274(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 0x1624: - if (!(gSaveContext.weekEventReg[62] & 0x40)) { - gSaveContext.weekEventReg[62] |= 0x40; + if (!(gSaveContext.save.weekEventReg[62] & 0x40)) { + gSaveContext.save.weekEventReg[62] |= 0x40; this->unk_33C = 0x1625; break; } @@ -957,7 +957,7 @@ void func_80BEE274(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x1622: this->unk_33C = 0x1623; - gSaveContext.weekEventReg[62] |= 0x20; + gSaveContext.save.weekEventReg[62] |= 0x20; this->unk_32C |= 0x20; break; @@ -974,8 +974,8 @@ void func_80BEE530(EnAkindonuts* this, GlobalContext* globalCtx) { switch (this->unk_33C) { case 0: - if ((player->transformation == PLAYER_FORM_ZORA) && !(gSaveContext.weekEventReg[62] & 0x80)) { - gSaveContext.weekEventReg[62] |= 0x80; + if ((player->transformation == PLAYER_FORM_ZORA) && !(gSaveContext.save.weekEventReg[62] & 0x80)) { + gSaveContext.save.weekEventReg[62] |= 0x80; this->unk_33C = 0x162A; break; } @@ -1095,7 +1095,7 @@ void func_80BEE73C(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BEE938(EnAkindonuts* this, GlobalContext* globalCtx) { switch (ENAKINDONUTS_GET_3(&this->actor)) { case 0: - if (gSaveContext.weekEventReg[61] & 0x10) { + if (gSaveContext.save.weekEventReg[61] & 0x10) { if (ENAKINDONUTS_GET_4(&this->actor)) { this->unk_2DC = func_80BED680; } else { @@ -1109,7 +1109,7 @@ void func_80BEE938(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 1: - if (gSaveContext.weekEventReg[61] & 0x80) { + if (gSaveContext.save.weekEventReg[61] & 0x80) { if (ENAKINDONUTS_GET_4(&this->actor)) { this->unk_2DC = func_80BEDB88; } else { @@ -1123,7 +1123,7 @@ void func_80BEE938(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 2: - if (gSaveContext.weekEventReg[62] & 4) { + if (gSaveContext.save.weekEventReg[62] & 4) { if (ENAKINDONUTS_GET_4(&this->actor)) { this->unk_2DC = func_80BEE070; } else { @@ -1137,7 +1137,7 @@ void func_80BEE938(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 3: - if (gSaveContext.weekEventReg[62] & 0x20) { + if (gSaveContext.save.weekEventReg[62] & 0x20) { if (ENAKINDONUTS_GET_4(&this->actor)) { this->unk_2DC = func_80BEE530; } else { diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index 0aef5ae40..e86f3971d 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -187,7 +187,7 @@ Actor* func_80BDE384(EnAl* this, GlobalContext* globalCtx) { switch (this->unk_35C) { case 2: - if (!(gSaveContext.weekEventReg[89] & 8) && (gSaveContext.weekEventReg[85] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[89] & 8) && (gSaveContext.save.weekEventReg[85] & 0x80)) { actor = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_PM); } else { actor = &GET_PLAYER(globalCtx)->actor; @@ -398,7 +398,7 @@ s32 func_80BDEA14(EnAl* this, GlobalContext* globalCtx) { switch (this->unk_4E6) { case 0: case 1: - if ((gSaveContext.weekEventReg[75] & 2)) { + if ((gSaveContext.save.weekEventReg[75] & 2)) { sp18 = true; } else if (func_80BDE4E0(this, &this->unk_4E6, 0)) { sp18 = true; @@ -439,7 +439,7 @@ s32* func_80BDEABC(EnAl* this, GlobalContext* globalCtx) { return D_80BDFE84; case 2: - if (!(gSaveContext.weekEventReg[89] & 8) && (gSaveContext.weekEventReg[85] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[89] & 8) && (gSaveContext.save.weekEventReg[85] & 0x80)) { this->unk_4EC = func_80BDE7FC; return D_80BDFCBC; } @@ -687,15 +687,15 @@ void func_80BDF414(EnAl* this, GlobalContext* globalCtx) { switch (this->unk_4EA) { case 0: case 1: - if (!(gSaveContext.weekEventReg[89] & 8)) { - if (gSaveContext.weekEventReg[85] & 0x80) { + if (!(gSaveContext.save.weekEventReg[89] & 8)) { + if (gSaveContext.save.weekEventReg[85] & 0x80) { func_80BDE4E0(this, &this->unk_4EA, 0); } } break; case 2: - if (gSaveContext.weekEventReg[89] & 8) { + if (gSaveContext.save.weekEventReg[89] & 8) { this->unk_4EA++; } break; @@ -734,7 +734,7 @@ void func_80BDF578(EnAl* this, GlobalContext* globalCtx) { } void func_80BDF5E8(EnAl* this, GlobalContext* globalCtx) { - u32* unk14 = &gSaveContext.unk_14; + u32* unk14 = &gSaveContext.save.daySpeed; struct_80133038_arg2 sp20; this->unk_4E0 = REG(15) + *unk14; diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index 9fcd11517..41cb91724 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -101,11 +101,11 @@ void func_809C10B0(EnAob01* this, s32 arg1) { } void func_809C1124(void) { - u16 time = gSaveContext.time; + u16 time = gSaveContext.save.time; - gSaveContext.time = (u16)REG(15) + time; - time = gSaveContext.time; - gSaveContext.time = (u16)gSaveContext.unk_14 + time; + gSaveContext.save.time = (u16)REG(15) + time; + time = gSaveContext.save.time; + gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + time; } void func_809C1158(EnAob01* this, GlobalContext* globalCtx) { @@ -219,18 +219,18 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { case 0x3548: case 0x3549: case 0x354A: - switch (gSaveContext.day) { + switch (gSaveContext.save.day) { case 1: - if (!gSaveContext.isNight) { - if (!(gSaveContext.weekEventReg[64] & 0x80)) { - gSaveContext.weekEventReg[64] |= 0x80; + if (!gSaveContext.save.isNight) { + if (!(gSaveContext.save.weekEventReg[64] & 0x80)) { + gSaveContext.save.weekEventReg[64] |= 0x80; this->unk_210 = 0x3520; } else { this->unk_210 = 0x352F; } } else { - if (!(gSaveContext.weekEventReg[65] & 1)) { - gSaveContext.weekEventReg[65] |= 1; + if (!(gSaveContext.save.weekEventReg[65] & 1)) { + gSaveContext.save.weekEventReg[65] |= 1; this->unk_210 = 0x3530; } else { this->unk_210 = 0x352F; @@ -239,16 +239,16 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { break; case 2: - if (!gSaveContext.isNight) { - if (!(gSaveContext.weekEventReg[65] & 2)) { - gSaveContext.weekEventReg[65] |= 2; + if (!gSaveContext.save.isNight) { + if (!(gSaveContext.save.weekEventReg[65] & 2)) { + gSaveContext.save.weekEventReg[65] |= 2; this->unk_210 = 0x3531; } else { this->unk_210 = 0x352F; } } else { - if (!(gSaveContext.weekEventReg[65] & 4)) { - gSaveContext.weekEventReg[65] |= 4; + if (!(gSaveContext.save.weekEventReg[65] & 4)) { + gSaveContext.save.weekEventReg[65] |= 4; this->unk_210 = 0x3532; } else { this->unk_210 = 0x352F; @@ -257,16 +257,16 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { break; case 3: - if (!gSaveContext.isNight) { - if (!(gSaveContext.weekEventReg[65] & 8)) { - gSaveContext.weekEventReg[65] |= 8; + if (!gSaveContext.save.isNight) { + if (!(gSaveContext.save.weekEventReg[65] & 8)) { + gSaveContext.save.weekEventReg[65] |= 8; this->unk_210 = 0x3533; } else { this->unk_210 = 0x352F; } } else { - if (!(gSaveContext.weekEventReg[65] & 0x10)) { - gSaveContext.weekEventReg[65] |= 0x10; + if (!(gSaveContext.save.weekEventReg[65] & 0x10)) { + gSaveContext.save.weekEventReg[65] |= 0x10; this->unk_210 = 0x3534; } else { this->unk_210 = 0x352F; @@ -307,7 +307,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { break; case PLAYER_FORM_HUMAN: - if (gSaveContext.rupees < 10) { + if (gSaveContext.save.playerData.rupees < 10) { this->unk_210 = 0x3524; this->unk_2D2 |= 0x10; } else { @@ -371,7 +371,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { break; case 0x3528: - if (gSaveContext.rupees < this->unk_434) { + if (gSaveContext.save.playerData.rupees < this->unk_434) { this->unk_210 = 0x3536; this->unk_2D2 |= 0x40; this->unk_43C = 1; @@ -416,8 +416,8 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { void func_809C1C9C(EnAob01* this, GlobalContext* globalCtx) { if (gSaveContext.rupeeAccumulator == 0) { - gSaveContext.weekEventReg[63] |= 1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->unk_2D2 |= 0x20; func_800FD750(0x40); globalCtx->nextEntranceIndex = 0x7C10; @@ -436,7 +436,7 @@ void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (gSaveContext.rupees < 10) { + if (gSaveContext.save.playerData.rupees < 10) { play_sound(NA_SE_SY_ERROR); this->unk_210 = 0x3524; Message_StartTextbox(globalCtx, this->unk_210, &this->actor); @@ -761,13 +761,13 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { this->unk_2E0 = this->unk_2F2; this->actor.parent = NULL; this->actor.shape.rot.y = this->actor.world.rot.y; - if (gSaveContext.weekEventReg[8] & 0x20) { + if (gSaveContext.save.weekEventReg[8] & 0x20) { this->actionFunc = func_809C2BE4; } else { - gSaveContext.weekEventReg[8] |= 0x20; + gSaveContext.save.weekEventReg[8] |= 0x20; this->actionFunc = func_809C2BE4; } - } else if (gSaveContext.weekEventReg[8] & 0x20) { + } else if (gSaveContext.save.weekEventReg[8] & 0x20) { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 300.0f, 300.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 300.0f, 300.0f); @@ -779,12 +779,12 @@ void func_809C2BE4(EnAob01* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (((temp_v0 == 5) || (temp_v0 == 6)) && Message_ShouldAdvance(globalCtx)) { - if (gSaveContext.weekEventReg[63] & 2) { - gSaveContext.weekEventReg[63] &= (u8)~2; + if (gSaveContext.save.weekEventReg[63] & 2) { + gSaveContext.save.weekEventReg[63] &= (u8)~2; } - if (gSaveContext.weekEventReg[63] & 1) { - gSaveContext.weekEventReg[63] &= (u8)~1; + if (gSaveContext.save.weekEventReg[63] & 1) { + gSaveContext.save.weekEventReg[63] &= (u8)~1; } this->unk_210 = 0; @@ -833,12 +833,12 @@ void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { this->unk_434 = 0; this->actor.shape.rot.y = this->actor.world.rot.y; - if (gSaveContext.weekEventReg[63] & 2) { - gSaveContext.weekEventReg[63] &= (u8)~2; + if (gSaveContext.save.weekEventReg[63] & 2) { + gSaveContext.save.weekEventReg[63] &= (u8)~2; } - if (gSaveContext.weekEventReg[63] & 1) { - gSaveContext.weekEventReg[63] &= (u8)~1; + if (gSaveContext.save.weekEventReg[63] & 1) { + gSaveContext.save.weekEventReg[63] &= (u8)~1; } this->unk_210 = 0x354C; @@ -902,7 +902,7 @@ void func_809C2FA0(void) { } for (i = 0; i < ARRAY_COUNT(sp44); i++) { - gSaveContext.weekEventReg[42 + i] = 0; + gSaveContext.save.weekEventReg[42 + i] = 0; sp44[i] = 0; } @@ -912,8 +912,8 @@ void func_809C2FA0(void) { if (i % 2) { sp44[idx2] |= orig2 << 0x4; - idx = gSaveContext.weekEventReg[42 + idx2]; - gSaveContext.weekEventReg[42 + idx2] = idx | sp44[idx2]; + idx = gSaveContext.save.weekEventReg[42 + idx2]; + gSaveContext.save.weekEventReg[42 + idx2] = idx | sp44[idx2]; } else { sp44[idx2] |= orig2; } @@ -967,7 +967,7 @@ void EnAob01_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnAob01* this = THIS; if (!(this->unk_2D2 & 0x20)) { - gSaveContext.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~1; } Collider_DestroyCylinder(globalCtx, &this->collider); } diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index 061d7bcea..7ce0ea260 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -130,12 +130,12 @@ void func_80BA886C(EnBaba* this, GlobalContext* globalCtx) { switch (this->unk_1E0) { case 0: if (this->unk_40A & 8) { - if (gSaveContext.weekEventReg[33] & 8) { + if (gSaveContext.save.weekEventReg[33] & 8) { this->unk_1E0 = 0x2A34; break; } - if (gSaveContext.weekEventReg[79] & 0x40) { + if (gSaveContext.save.weekEventReg[79] & 0x40) { this->unk_40A |= 1; this->unk_1E0 = 0x2A33; break; @@ -145,8 +145,8 @@ void func_80BA886C(EnBaba* this, GlobalContext* globalCtx) { this->unk_1E0 = 0x2A32; break; } else if (player->transformation == PLAYER_FORM_DEKU) { - if (!(gSaveContext.weekEventReg[79] & 0x20)) { - gSaveContext.weekEventReg[79] |= 0x20; + if (!(gSaveContext.save.weekEventReg[79] & 0x20)) { + gSaveContext.save.weekEventReg[79] |= 0x20; this->unk_40A |= 1; this->unk_1E0 = 0x2A37; break; @@ -155,15 +155,15 @@ void func_80BA886C(EnBaba* this, GlobalContext* globalCtx) { this->unk_1E0 = 0x2A38; } break; - } else if (!(gSaveContext.weekEventReg[33] & 8)) { - if (!(gSaveContext.weekEventReg[73] & 1)) { + } else if (!(gSaveContext.save.weekEventReg[33] & 8)) { + if (!(gSaveContext.save.weekEventReg[73] & 1)) { this->unk_1E0 = 0x660; break; } this->unk_1E0 = 0x662; break; } else { - if (!(gSaveContext.weekEventReg[73] & 2)) { + if (!(gSaveContext.save.weekEventReg[73] & 2)) { this->unk_1E0 = 0x65A; break; } @@ -185,7 +185,7 @@ void func_80BA886C(EnBaba* this, GlobalContext* globalCtx) { case 0x662: Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); this->unk_1E0 = 0x663; - gSaveContext.weekEventReg[73] |= 1; + gSaveContext.save.weekEventReg[73] |= 1; this->unk_40A |= 1; break; @@ -202,7 +202,7 @@ void func_80BA886C(EnBaba* this, GlobalContext* globalCtx) { case 0x65C: Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); this->unk_1E0 = 0x65D; - gSaveContext.weekEventReg[73] |= 2; + gSaveContext.save.weekEventReg[73] |= 2; this->unk_40A |= 1; break; @@ -306,7 +306,7 @@ void func_80BA8DF4(EnBaba* this, GlobalContext* globalCtx) { } s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp26 = (u16)(gSaveContext.time - 0x3FFC); + u16 sp26 = (u16)(gSaveContext.save.time - 0x3FFC); u16 temp; u8 sp23 = ENBABA_GET_3F00(&this->actor); @@ -413,7 +413,7 @@ s32 func_80BA9160(EnBaba* this, GlobalContext* globalCtx) { void func_80BA93AC(EnBaba* this, GlobalContext* globalCtx) { if (this->unk_434 != 1) { if (this->unk_434 == 2) { - gSaveContext.weekEventReg[58] |= 0x40; + gSaveContext.save.weekEventReg[58] |= 0x40; this->unk_40A |= 2; func_80BA9160(this, globalCtx); } @@ -443,10 +443,10 @@ void func_80BA9480(EnBaba* this, GlobalContext* globalCtx) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80BA9758; } else if (globalCtx->sceneNum == SCENE_BACKTOWN) { - if ((ENBABA_GET_C000(&this->actor) == ENBABA_C000_0) && (gSaveContext.entranceIndex != 0xD670) && + if ((ENBABA_GET_C000(&this->actor) == ENBABA_C000_0) && (gSaveContext.save.entranceIndex != 0xD670) && ((ENBABA_GET_3F00(&this->actor)) != ENBABA_3F00_3F)) { - if ((gSaveContext.weekEventReg[58] & 0x40) || - (!(gSaveContext.time < CLOCK_TIME(0, 20)) && (gSaveContext.time < CLOCK_TIME(6, 0)))) { + if ((gSaveContext.save.weekEventReg[58] & 0x40) || + (!(gSaveContext.save.time < CLOCK_TIME(0, 20)) && (gSaveContext.save.time < CLOCK_TIME(6, 0)))) { Actor_MarkForDeath(&this->actor); return; } @@ -455,14 +455,14 @@ void func_80BA9480(EnBaba* this, GlobalContext* globalCtx) { this->unk_40C = 2; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->actionFunc = func_80BA9B80; - } else if ((ENBABA_GET_C000(&this->actor) == ENBABA_C000_1) && (gSaveContext.entranceIndex == 0xD670)) { - if (gSaveContext.weekEventReg[81] & 2) { + } else if ((ENBABA_GET_C000(&this->actor) == ENBABA_C000_1) && (gSaveContext.save.entranceIndex == 0xD670)) { + if (gSaveContext.save.weekEventReg[81] & 2) { Actor_MarkForDeath(&this->actor); return; } this->unk_40A |= 2; - if (gSaveContext.weekEventReg[33] & 8) { + if (gSaveContext.save.weekEventReg[33] & 8) { this->unk_40C = 0; } else { this->unk_40C = 1; @@ -534,12 +534,12 @@ void func_80BA98EC(EnBaba* this, GlobalContext* globalCtx) { if (this->unk_40A & 8) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { if (globalCtx->msgCtx.unk120B1 == 0) { - gSaveContext.weekEventReg[81] |= 2; + gSaveContext.save.weekEventReg[81] |= 2; func_80BA8C4C(globalCtx, 0xD670); return; } } else { - gSaveContext.weekEventReg[81] |= 2; + gSaveContext.save.weekEventReg[81] |= 2; func_80BA8C4C(globalCtx, 0xD670); } } else { @@ -557,7 +557,7 @@ void func_80BA98EC(EnBaba* this, GlobalContext* globalCtx) { } } else if (temp_v0 == 6) { if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.unk120B1 == 0)) { - gSaveContext.weekEventReg[81] |= 2; + gSaveContext.save.weekEventReg[81] |= 2; func_80BA8C4C(globalCtx, 0xD670); } } @@ -583,7 +583,7 @@ void func_80BA9B24(EnBaba* this, GlobalContext* globalCtx) { } void func_80BA9B80(EnBaba* this, GlobalContext* globalCtx) { - u32* unk14 = &gSaveContext.unk_14; + u32* unk14 = &gSaveContext.save.daySpeed; struct_80133038_arg2 sp20; this->unk_436 = REG(15) + *unk14; @@ -629,7 +629,7 @@ void func_80BA9CD4(EnBaba* this, GlobalContext* globalCtx) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); } } else { - if ((gSaveContext.weekEventReg[79] & 0x40) && (DECR(this->unk_404) == 0)) { + if ((gSaveContext.save.weekEventReg[79] & 0x40) && (DECR(this->unk_404) == 0)) { Audio_QueueSeqCmd(0x101400FF); func_80BA8C4C(globalCtx, 0xD670); } else { diff --git a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c index 3d4c5cab5..193c899c9 100644 --- a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c +++ b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c @@ -71,14 +71,16 @@ void EnBaisen_Init(Actor* thisx, GlobalContext* globalCtx) { this->paramCopy = this->actor.params; if (this->actor.params == 0) { this->unk290 = true; - if (!(gSaveContext.weekEventReg[63] & 0x80) && ((gSaveContext.day != 3) || !gSaveContext.isNight)) { + if (!(gSaveContext.save.weekEventReg[63] & 0x80) && + ((gSaveContext.save.day != 3) || !gSaveContext.save.isNight)) { Actor_MarkForDeath(&this->actor); } } else { this->collider.dim.radius = 30; this->collider.dim.height = 60; this->collider.dim.yShift = 0; - if ((gSaveContext.weekEventReg[63] & 0x80) || ((gSaveContext.day == 3) && (gSaveContext.isNight))) { + if ((gSaveContext.save.weekEventReg[63] & 0x80) || + ((gSaveContext.save.day == 3) && (gSaveContext.save.isNight))) { Actor_MarkForDeath(&this->actor); } } @@ -153,7 +155,7 @@ void func_80BE887C(EnBaisen* this, GlobalContext* globalCtx) { } else { if (this->paramCopy != 0) { this->textIdIndex = 0; - if (gSaveContext.weekEventReg[60] & 8) { + if (gSaveContext.save.weekEventReg[60] & 8) { this->textIdIndex = 1; } if (Player_GetMask(globalCtx) == PLAYER_MASK_COUPLE) { @@ -246,7 +248,7 @@ void EnBaisen_Update(Actor* thisx, GlobalContext* globalCtx) { this->unusedCounter--; } this->actor.shape.rot.y = this->actor.world.rot.y; - if ((this->paramCopy != 0) && (gSaveContext.day == 3) && gSaveContext.isNight) { + if ((this->paramCopy != 0) && (gSaveContext.save.day == 3) && gSaveContext.save.isNight) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c index 10ea3a7a2..8431d6706 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -105,7 +105,7 @@ void EnBigokuta_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); this->cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); - if (gSaveContext.weekEventReg[20] & 2 || + if (gSaveContext.save.weekEventReg[20] & 2 || ((this->actor.params != 0xFF) && Flags_GetSwitch(globalCtx, this->actor.params))) { Actor_MarkForDeath(&this->actor); } else { diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index 5475650ca..c0c1326a3 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -309,7 +309,7 @@ static InitChainEntry sInitChain[] = { }; void EnBigslime_Init(Actor* thisx, GlobalContext* globalCtx2) { - // gSaveContext.weekEventReg[KEY] = VALUE + // gSaveContext.save.weekEventReg[KEY] = VALUE // KEY | VALUE static s32 isFrogReturnedFlags[] = { (32 << 8) | 0x40, // Woodfall Temple Frog Returned @@ -340,7 +340,7 @@ void EnBigslime_Init(Actor* thisx, GlobalContext* globalCtx2) { if (Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num)) { Actor_MarkForDeath(&this->actor); - if (!(gSaveContext.weekEventReg[isFrogReturnedFlags[this->actor.params - 1] >> 8] & + if (!(gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->actor.params - 1] >> 8] & (u8)isFrogReturnedFlags[this->actor.params - 1])) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MINIFROG, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, @@ -1614,7 +1614,7 @@ void EnBigslime_AttackPlayerInBigslime(EnBigslime* this, GlobalContext* globalCt if (this->numGekkoMeleeAttacks == 0) { this->numGekkoPosGrabPlayer--; - if ((gSaveContext.health < 5) || (this->numGekkoPosGrabPlayer == 0)) { + if ((gSaveContext.save.playerData.health < 5) || (this->numGekkoPosGrabPlayer == 0)) { this->numGekkoPosGrabPlayer = 0; this->gekkoRot.y = this->actor.world.rot.y; this->gekkoPosOffset.x = Math_SinS(this->gekkoRot.y) * -50.0f; diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 897f699d2..818515446 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -122,44 +122,44 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { switch (this->actor.params) { case ENBJI01_PARAMS_DEFAULT: case ENBJI01_PARAMS_FINISHED_CONVERSATION: - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case PLAYER_FORM_DEKU: - if (gSaveContext.weekEventReg[17] & 0x10) { - if (gSaveContext.weekEventReg[74] & 0x80) { + if (gSaveContext.save.weekEventReg[17] & 0x10) { + if (gSaveContext.save.weekEventReg[74] & 0x80) { this->textId = 0x5F4; } else { this->textId = 0x5E2; } } else { this->textId = 0x5EC; - gSaveContext.weekEventReg[17] |= 0x10; + gSaveContext.save.weekEventReg[17] |= 0x10; } break; case PLAYER_FORM_HUMAN: if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { this->textId = 0x236A; - } else if (gSaveContext.weekEventReg[74] & 0x10) { + } else if (gSaveContext.save.weekEventReg[74] & 0x10) { this->textId = 0x5F6; } else { this->textId = 0x5F5; - gSaveContext.weekEventReg[74] |= 0x10; + gSaveContext.save.weekEventReg[74] |= 0x10; } break; case PLAYER_FORM_GORON: case PLAYER_FORM_ZORA: - if (gSaveContext.weekEventReg[75] & 8) { + if (gSaveContext.save.weekEventReg[75] & 8) { this->textId = 0x5E4; } else { this->textId = 0x5DC; - gSaveContext.weekEventReg[75] |= 8; + gSaveContext.save.weekEventReg[75] |= 8; } break; } break; case ENBJI01_PARAMS_LOOKED_THROUGH_TELESCOPE: - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case PLAYER_FORM_DEKU: - if (gSaveContext.weekEventReg[74] & 0x80) { + if (gSaveContext.save.weekEventReg[74] & 0x80) { this->textId = 0x5F2; } else { this->textId = 0x5F1; @@ -180,9 +180,9 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { this->textId = 0x5EA; break; case 3: - tempDay = gSaveContext.day; + tempDay = gSaveContext.save.day; tempTimeBeforeMoonCrash = - ((-(tempDay % 5 << 0x10) - ((u16)(gSaveContext.time - 0x4000))) + 0x40000); + ((-(tempDay % 5 << 0x10) - ((u16)(gSaveContext.save.time - 0x4000))) + 0x40000); if (tempTimeBeforeMoonCrash < CLOCK_TIME_F(1, 0)) { /* 1 hr */ this->textId = 0x5E8; } else { @@ -218,7 +218,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { break; case 1: func_8019F230(); - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case PLAYER_FORM_DEKU: func_80151938(globalCtx, 0x5F0); break; @@ -298,7 +298,7 @@ void func_809CD634(EnBji01* this, GlobalContext* globalCtx) { func_801A5BD0(0x6F); Audio_QueueSeqCmd(0xE0000101); globalCtx->nextEntranceIndex = 0x54A0; /* Termina Field from telescope */ - gSaveContext.respawn[0].entranceIndex = globalCtx->nextEntranceIndex; + gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex = globalCtx->nextEntranceIndex; func_80169EFC(&globalCtx->state); /* Load new entrance? */ gSaveContext.respawnFlag = -2; this->actionFunc = EnBji01_DoNothing; @@ -344,7 +344,7 @@ void EnBji01_Init(Actor* thisx, GlobalContext* globalCtx) { SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); this->moonsTear = (ObjMoonStone*)SubS_FindActor(globalCtx, NULL, ACTORCAT_PROP, ACTOR_OBJ_MOON_STONE); - switch (gSaveContext.entranceIndex) { + switch (gSaveContext.save.entranceIndex) { case 0x4C00: /* Observatory from ECT */ case 0x4C10: /* Observatory from Termina Field door */ this->actor.params = ENBJI01_PARAMS_DEFAULT; diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c index ecaea2984..49e6caa63 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c @@ -97,7 +97,7 @@ void EnBomBowlMan_Init(Actor* thisx, GlobalContext* globalCtx) { this->path = func_8013D648(globalCtx, this->unk_29A, 0x3F); this->unk_2C8 = 80.0f; - if ((gSaveContext.entranceIndex == 0xD220) && (gSaveContext.weekEventReg[73] & 0x80) && + if ((gSaveContext.save.entranceIndex == 0xD220) && (gSaveContext.save.weekEventReg[73] & 0x80) && !CHECK_QUEST_ITEM(ITEM_BOTTLE)) { this->unk_2D6 = this->actor.cutscene; if (this->unk_2D6 == 0) { @@ -173,9 +173,9 @@ void func_809C4BC4(EnBomBowlMan* this, GlobalContext* globalCtx) { func_809C4B50(this); func_809C493C(this, 0, 1.0f); - for (i = 0; i < ARRAY_COUNT(gSaveContext.bomberCode); i++) { + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.bomberCode); i++) { Math_Vec3f_Copy(&sp7C, &this->actor.home.pos); - code = gSaveContext.bomberCode[i]; + code = gSaveContext.save.bomberCode[i]; if (code == 1) { Math_Vec3f_Copy(&this->actor.world.pos, &D_809C61A0[i]); this->unk_2D8[code] = this; @@ -203,8 +203,8 @@ void func_809C4BC4(EnBomBowlMan* this, GlobalContext* globalCtx) { func_809C493C(this, 3, 1.0f); this->unk_2D4 = this->actor.yawTowardsPlayer; this->unk_290 = this->actor.yawTowardsPlayer; - gSaveContext.weekEventReg[73] &= (u8)~0x10; - gSaveContext.weekEventReg[85] &= (u8)~2; + gSaveContext.save.weekEventReg[73] &= (u8)~0x10; + gSaveContext.save.weekEventReg[85] &= (u8)~2; this->unk_29C = 0; this->actionFunc = func_809C4DA4; } @@ -338,13 +338,13 @@ void func_809C51B4(EnBomBowlMan* this, GlobalContext* globalCtx) { globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 0x56; gSaveContext.nextTransition = 3; - gSaveContext.weekEventReg[75] &= (u8)~0x40; + gSaveContext.save.weekEventReg[75] &= (u8)~0x40; if (player->transformation == PLAYER_FORM_HUMAN) { - gSaveContext.weekEventReg[84] |= 0x80; - gSaveContext.weekEventReg[77] &= (u8)~2; + gSaveContext.save.weekEventReg[84] |= 0x80; + gSaveContext.save.weekEventReg[77] &= (u8)~2; } else { - gSaveContext.weekEventReg[73] |= 0x20; - gSaveContext.weekEventReg[85] &= (u8)~1; + gSaveContext.save.weekEventReg[73] |= 0x20; + gSaveContext.save.weekEventReg[85] &= (u8)~1; } } } @@ -402,7 +402,7 @@ void func_809C5408(EnBomBowlMan* this, GlobalContext* globalCtx) { void func_809C5524(EnBomBowlMan* this, GlobalContext* globalCtx) { this->actor.textId = 0x730; - if (!(gSaveContext.weekEventReg[85] & 2)) { + if (!(gSaveContext.save.weekEventReg[85] & 2)) { this->actor.textId = 0x72F; } func_809C493C(this, 3, 1.0f); @@ -484,8 +484,8 @@ void func_809C5738(EnBomBowlMan* this, GlobalContext* globalCtx) { (this->path != NULL)) { this->unk_298++; if (this->unk_298 >= this->path->count) { - gSaveContext.weekEventReg[84] |= 0x80; - gSaveContext.weekEventReg[83] &= (u8)~4; + gSaveContext.save.weekEventReg[84] |= 0x80; + gSaveContext.save.weekEventReg[83] &= (u8)~4; ActorCutscene_Stop(this->unk_2D6); Actor_MarkForDeath(&this->actor); } else { 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 c4fab7365..a76c901eb 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c @@ -104,19 +104,19 @@ void EnBombers_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2BE = ENBOMBERS_GET_F(&this->actor); if (this->unk_2BC == ENBOMBERS_F0_0) { - if ((gSaveContext.weekEventReg[73] & 0x10) || (gSaveContext.weekEventReg[85] & 2)) { + if ((gSaveContext.save.weekEventReg[73] & 0x10) || (gSaveContext.save.weekEventReg[85] & 2)) { Actor_MarkForDeath(&this->actor); } else { this->unk_2BE++; func_80C03ACC(this); } - } else if (((gSaveContext.weekEventReg[73] & 0x10) || (gSaveContext.weekEventReg[85] & 2)) && - (((this->unk_2BE == ENBOMBERS_F_0) && (gSaveContext.weekEventReg[76] & 1)) || - ((this->unk_2BE == ENBOMBERS_F_1) && (gSaveContext.weekEventReg[76] & 2)) || - ((this->unk_2BE == ENBOMBERS_F_2) && (gSaveContext.weekEventReg[76] & 4)) || - ((this->unk_2BE == ENBOMBERS_F_3) && (gSaveContext.weekEventReg[76] & 8)) || - ((this->unk_2BE == ENBOMBERS_F_4) && (gSaveContext.weekEventReg[76] & 0x10)))) { - if (gSaveContext.weekEventReg[75] & 0x40) { + } else if (((gSaveContext.save.weekEventReg[73] & 0x10) || (gSaveContext.save.weekEventReg[85] & 2)) && + (((this->unk_2BE == ENBOMBERS_F_0) && (gSaveContext.save.weekEventReg[76] & 1)) || + ((this->unk_2BE == ENBOMBERS_F_1) && (gSaveContext.save.weekEventReg[76] & 2)) || + ((this->unk_2BE == ENBOMBERS_F_2) && (gSaveContext.save.weekEventReg[76] & 4)) || + ((this->unk_2BE == ENBOMBERS_F_3) && (gSaveContext.save.weekEventReg[76] & 8)) || + ((this->unk_2BE == ENBOMBERS_F_4) && (gSaveContext.save.weekEventReg[76] & 0x10)))) { + if (gSaveContext.save.weekEventReg[75] & 0x40) { if (this->unk_2BE == ENBOMBERS_F_0) { EnBomBowlMan* bomBowlMan = (EnBomBowlMan*)Actor_Spawn( &globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM_BOWL_MAN, this->actor.world.pos.x, @@ -130,11 +130,11 @@ void EnBombers_Init(Actor* thisx, GlobalContext* globalCtx) { while (cs != -1) { bomBowlMan->unk_2CC[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); i++; } // clang-format on - gSaveContext.weekEventReg[76] &= (u8)~1; - gSaveContext.weekEventReg[76] &= (u8)~2; - gSaveContext.weekEventReg[76] &= (u8)~4; - gSaveContext.weekEventReg[76] &= (u8)~8; - gSaveContext.weekEventReg[76] &= (u8)~0x10; + gSaveContext.save.weekEventReg[76] &= (u8)~1; + gSaveContext.save.weekEventReg[76] &= (u8)~2; + gSaveContext.save.weekEventReg[76] &= (u8)~4; + gSaveContext.save.weekEventReg[76] &= (u8)~8; + gSaveContext.save.weekEventReg[76] &= (u8)~0x10; } } Actor_MarkForDeath(&this->actor); @@ -180,7 +180,7 @@ void func_80C039A8(EnBombers* this, GlobalContext* globalCtx) { switch (player->transformation) { case PLAYER_FORM_HUMAN: this->actor.textId = 0x73D; - if (gSaveContext.weekEventReg[84] & 0x80) { + if (gSaveContext.save.weekEventReg[84] & 0x80) { this->actor.textId = 0x74B; } break; @@ -194,14 +194,14 @@ void func_80C039A8(EnBombers* this, GlobalContext* globalCtx) { break; case PLAYER_FORM_DEKU: - if (gSaveContext.weekEventReg[73] & 0x20) { + if (gSaveContext.save.weekEventReg[73] & 0x20) { this->actor.textId = 0x75A; - } else if (gSaveContext.weekEventReg[73] & 0x40) { + } else if (gSaveContext.save.weekEventReg[73] & 0x40) { this->actor.textId = 0x749; - if (((this->unk_2BE == ENBOMBERS_F_1) && (gSaveContext.weekEventReg[74] & 1)) || - ((this->unk_2BE == ENBOMBERS_F_2) && (gSaveContext.weekEventReg[74] & 2)) || - ((this->unk_2BE == ENBOMBERS_F_3) && (gSaveContext.weekEventReg[74] & 4)) || - ((this->unk_2BE == ENBOMBERS_F_4) && (gSaveContext.weekEventReg[74] & 8))) { + if (((this->unk_2BE == ENBOMBERS_F_1) && (gSaveContext.save.weekEventReg[74] & 1)) || + ((this->unk_2BE == ENBOMBERS_F_2) && (gSaveContext.save.weekEventReg[74] & 2)) || + ((this->unk_2BE == ENBOMBERS_F_3) && (gSaveContext.save.weekEventReg[74] & 4)) || + ((this->unk_2BE == ENBOMBERS_F_4) && (gSaveContext.save.weekEventReg[74] & 8))) { this->actor.textId = 0x74A; } } else { @@ -375,7 +375,7 @@ void func_80C03FAC(EnBombers* this, GlobalContext* globalCtx) { sp2A = 1; } } else if (this->actor.textId == 0x744) { - s32 day = gSaveContext.day - 1; + s32 day = gSaveContext.save.day - 1; if (day == 2) { this->actor.textId = 0x746; @@ -393,22 +393,22 @@ void func_80C03FAC(EnBombers* this, GlobalContext* globalCtx) { } else if (this->actor.textId == 0x748) { switch (this->unk_2BE) { case ENBOMBERS_F_1: - gSaveContext.weekEventReg[74] |= 1; + gSaveContext.save.weekEventReg[74] |= 1; break; case ENBOMBERS_F_2: - gSaveContext.weekEventReg[74] |= 2; + gSaveContext.save.weekEventReg[74] |= 2; break; case ENBOMBERS_F_3: - gSaveContext.weekEventReg[74] |= 4; + gSaveContext.save.weekEventReg[74] |= 4; break; case ENBOMBERS_F_4: - gSaveContext.weekEventReg[74] |= 8; + gSaveContext.save.weekEventReg[74] |= 8; break; } - gSaveContext.weekEventReg[73] |= 0x40; + gSaveContext.save.weekEventReg[73] |= 0x40; } switch (sp2A) { diff --git a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c index 5aacb8820..8b2fa6d90 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c @@ -94,7 +94,7 @@ void EnBombers2_Init(Actor* thisx, GlobalContext* globalCtx) { this->jointTable, OBJECT_CS_LIMB_MAX); this->actor.targetMode = 6; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - if ((gSaveContext.weekEventReg[0x49] & 0x80) || (gSaveContext.entranceIndex == 0xD220)) { + if ((gSaveContext.save.weekEventReg[73] & 0x80) || (gSaveContext.save.entranceIndex == 0xD220)) { this->actor.world.pos.x += Math_SinS(this->actor.home.rot.y + 0xC100) * 50.0f; cos = Math_CosS(this->actor.home.rot.y + 0xC100) * 50.0f; this->unk_2AC = 1; @@ -165,7 +165,7 @@ void func_80C04BA0(EnBombers2* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_2B6 = this->actor.world.rot.y; - gSaveContext.weekEventReg[0x56] |= 2; + gSaveContext.save.weekEventReg[86] |= 2; func_80C04D00(this); return; } @@ -219,7 +219,8 @@ void func_80C04D8C(EnBombers2* this, GlobalContext* globalCtx) { s32 correctDigits; for (i = 0; i < ARRAY_COUNT(this->correctDigitSlots); i++) { - if (!(this->correctDigitSlots[i]) && (globalCtx->msgCtx.unk12054[i] == gSaveContext.bomberCode[i])) { + if (!(this->correctDigitSlots[i]) && + (globalCtx->msgCtx.unk12054[i] == gSaveContext.save.bomberCode[i])) { this->correctDigitSlots[i] = true; } } @@ -329,7 +330,7 @@ void func_80C0520C(EnBombers2* this, GlobalContext* globalCtx) { EnBombers2_ChangeAnim(this, 6, 1.0f); this->unk_2A8 = 0; this->unk_2C0 = 1; - gSaveContext.weekEventReg[0x49] |= 0x80; + gSaveContext.save.weekEventReg[73] |= 0x80; ActorCutscene_Stop(this->cutscene); this->unk_2AC = 1; this->actor.textId = sTextIds[this->textIdIndex]; diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c index 9d1cd3970..300679a4e 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -117,7 +117,7 @@ void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, this->morphTable, OBJECT_CS_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - gSaveContext.weekEventReg[83] &= (u8)~4; + gSaveContext.save.weekEventReg[83] &= (u8)~4; this->actor.targetMode = 0; this->unk_2E6 = ENBOMJIMA_GET_F0(&this->actor); this->unk_2E4 = ENBOMJIMA_GET_F(&this->actor); @@ -139,8 +139,8 @@ void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { func_80BFFCFC(this); } - if ((gSaveContext.weekEventReg[75] & 0x40) || (gSaveContext.weekEventReg[73] & 0x10) || - (gSaveContext.weekEventReg[85] & 2)) { + if ((gSaveContext.save.weekEventReg[75] & 0x40) || (gSaveContext.save.weekEventReg[73] & 0x10) || + (gSaveContext.save.weekEventReg[85] & 2)) { Actor_MarkForDeath(&this->actor); } } @@ -166,12 +166,12 @@ void func_80BFE32C(EnBomjima* this, GlobalContext* globalCtx, s32 arg2) { case 0: if (player->transformation == PLAYER_FORM_DEKU) { this->actor.textId = 0x759; - if (!(gSaveContext.weekEventReg[73] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[73] & 0x20)) { this->actor.textId = 0x708; } } else if (player->transformation == PLAYER_FORM_HUMAN) { this->actor.textId = 0x75A; - if (!(gSaveContext.weekEventReg[84] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[84] & 0x80)) { this->actor.textId = 0x719; } } else if ((this->unk_2C8 == 1) || (this->unk_2C8 == 2)) { @@ -350,18 +350,18 @@ void func_80BFEB64(EnBomjima* this, GlobalContext* globalCtx) { func_80BFE32C(this, globalCtx, 0); if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.weekEventReg[73] & 0x20) { + if (gSaveContext.save.weekEventReg[73] & 0x20) { this->unk_2C8 = 3; func_80BFE32C(this, globalCtx, 3); - } else if (gSaveContext.weekEventReg[77] & 2) { + } else if (gSaveContext.save.weekEventReg[77] & 2) { this->unk_2C8 = 11; func_80BFE32C(this, globalCtx, 2); } } else if (player->transformation == PLAYER_FORM_HUMAN) { - if (gSaveContext.weekEventReg[84] & 0x80) { + if (gSaveContext.save.weekEventReg[84] & 0x80) { this->unk_2C8 = 0; func_80BFE32C(this, globalCtx, 3); - } else if (gSaveContext.weekEventReg[85] & 1) { + } else if (gSaveContext.save.weekEventReg[85] & 1) { this->unk_2C8 = 11; func_80BFE32C(this, globalCtx, 2); } @@ -460,7 +460,7 @@ void func_80BFF03C(EnBomjima* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->unk_2D4[0]); } else { player->stateFlags1 &= ~0x20; - gSaveContext.weekEventReg[83] &= (u8)~4; + gSaveContext.save.weekEventReg[83] &= (u8)~4; this->actor.world.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); this->unk_2DC = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[0], &this->actor); @@ -506,11 +506,11 @@ void func_80BFF174(EnBomjima* this, GlobalContext* globalCtx) { } if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.weekEventReg[73] & 0x20) { + if (gSaveContext.save.weekEventReg[73] & 0x20) { this->unk_2C8 = 3; func_80BFE32C(this, globalCtx, 3); } else { - if (!(gSaveContext.weekEventReg[77] & 2)) { + if (!(gSaveContext.save.weekEventReg[77] & 2)) { if (this->unk_2E8 == 0) { this->unk_2C8 = 4; } else { @@ -522,11 +522,11 @@ void func_80BFF174(EnBomjima* this, GlobalContext* globalCtx) { func_80BFE32C(this, globalCtx, 2); } } else if (player->transformation == PLAYER_FORM_HUMAN) { - if (gSaveContext.weekEventReg[84] & 0x80) { + if (gSaveContext.save.weekEventReg[84] & 0x80) { this->unk_2C8 = 0; func_80BFE32C(this, globalCtx, 3); } else { - if (!(gSaveContext.weekEventReg[85] & 1)) { + if (!(gSaveContext.save.weekEventReg[85] & 1)) { if (this->unk_2EA == 0) { this->unk_2C8 = 4; } else { @@ -566,7 +566,7 @@ void func_80BFF430(EnBomjima* this, GlobalContext* globalCtx) { bombal->unk_150 = 0.0f; bombal->unk_14C = this->unk_2F4; Actor_ChangeFocus(&this->actor, globalCtx, &bombal->actor); - gSaveContext.weekEventReg[83] &= (u8)~4; + gSaveContext.save.weekEventReg[83] &= (u8)~4; func_80BFE65C(this); func_801477B4(globalCtx); this->actionFunc = func_80BFEA94; @@ -689,31 +689,31 @@ void func_80BFF9B0(EnBomjima* this, GlobalContext* globalCtx) { D_80C009F0 = 0; this->unk_2C8 = 9; if (player->transformation == PLAYER_FORM_DEKU) { - gSaveContext.weekEventReg[73] |= 0x10; - gSaveContext.weekEventReg[77] |= 2; + gSaveContext.save.weekEventReg[73] |= 0x10; + gSaveContext.save.weekEventReg[77] |= 2; } else { - gSaveContext.weekEventReg[85] |= 2; - gSaveContext.weekEventReg[85] |= 1; + gSaveContext.save.weekEventReg[85] |= 2; + gSaveContext.save.weekEventReg[85] |= 1; } - gSaveContext.weekEventReg[11] &= (u8)~1; - gSaveContext.weekEventReg[11] &= (u8)~2; - gSaveContext.weekEventReg[11] &= (u8)~4; - gSaveContext.weekEventReg[11] &= (u8)~8; - gSaveContext.weekEventReg[11] &= (u8)~0x10; + gSaveContext.save.weekEventReg[11] &= (u8)~1; + gSaveContext.save.weekEventReg[11] &= (u8)~2; + gSaveContext.save.weekEventReg[11] &= (u8)~4; + gSaveContext.save.weekEventReg[11] &= (u8)~8; + gSaveContext.save.weekEventReg[11] &= (u8)~0x10; - gSaveContext.weekEventReg[76] &= (u8)~1; - gSaveContext.weekEventReg[76] &= (u8)~2; - gSaveContext.weekEventReg[76] &= (u8)~4; - gSaveContext.weekEventReg[76] &= (u8)~8; - gSaveContext.weekEventReg[76] &= (u8)~0x10; + gSaveContext.save.weekEventReg[76] &= (u8)~1; + gSaveContext.save.weekEventReg[76] &= (u8)~2; + gSaveContext.save.weekEventReg[76] &= (u8)~4; + gSaveContext.save.weekEventReg[76] &= (u8)~8; + gSaveContext.save.weekEventReg[76] &= (u8)~0x10; - gSaveContext.unk_FE6 = 0; - gSaveContext.unk_FE7[0] = 0; - gSaveContext.unk_FE7[1] = 0; - gSaveContext.unk_FE7[2] = 0; - gSaveContext.unk_FE7[3] = 0; - gSaveContext.unk_FE7[4] = 0; + gSaveContext.save.bombersCaughtNum = 0; + gSaveContext.save.bombersCaughtOrder[0] = 0; + gSaveContext.save.bombersCaughtOrder[1] = 0; + gSaveContext.save.bombersCaughtOrder[2] = 0; + gSaveContext.save.bombersCaughtOrder[3] = 0; + gSaveContext.save.bombersCaughtOrder[4] = 0; func_80BFE494(this, 3, 1.0f); this->unk_2C8 = 9; diff --git a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c index 6835a90fc..915b785cd 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -99,38 +99,38 @@ void EnBomjimb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2C6 = ENBOMJIMB_F0_0; } - if ((gSaveContext.weekEventReg[73] & 0x10) || (gSaveContext.weekEventReg[85] & 2)) { + if ((gSaveContext.save.weekEventReg[73] & 0x10) || (gSaveContext.save.weekEventReg[85] & 2)) { switch (this->unk_2C8) { case ENBOMJIMB_F_0: - if (gSaveContext.weekEventReg[11] & 1) { + if (gSaveContext.save.weekEventReg[11] & 1) { Actor_MarkForDeath(&this->actor); return; } break; case ENBOMJIMB_F_1: - if (gSaveContext.weekEventReg[11] & 2) { + if (gSaveContext.save.weekEventReg[11] & 2) { Actor_MarkForDeath(&this->actor); return; } break; case ENBOMJIMB_F_2: - if (gSaveContext.weekEventReg[11] & 4) { + if (gSaveContext.save.weekEventReg[11] & 4) { Actor_MarkForDeath(&this->actor); return; } break; case ENBOMJIMB_F_3: - if (gSaveContext.weekEventReg[11] & 8) { + if (gSaveContext.save.weekEventReg[11] & 8) { Actor_MarkForDeath(&this->actor); return; } break; case ENBOMJIMB_F_4: - if (gSaveContext.weekEventReg[11] & 0x10) { + if (gSaveContext.save.weekEventReg[11] & 0x10) { Actor_MarkForDeath(&this->actor); return; } @@ -138,8 +138,8 @@ void EnBomjimb_Init(Actor* thisx, GlobalContext* globalCtx) { } } - if ((!(gSaveContext.weekEventReg[73] & 0x10) && !(gSaveContext.weekEventReg[85] & 2)) || - (gSaveContext.weekEventReg[75] & 0x40)) { + if ((!(gSaveContext.save.weekEventReg[73] & 0x10) && !(gSaveContext.save.weekEventReg[85] & 2)) || + (gSaveContext.save.weekEventReg[75] & 0x40)) { Actor_MarkForDeath(&this->actor); return; } @@ -671,8 +671,8 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { return; } - if (((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.weekEventReg[73] & 0x10)) || - ((player->transformation == PLAYER_FORM_HUMAN) && !(gSaveContext.weekEventReg[85] & 2))) { + if (((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.save.weekEventReg[73] & 0x10)) || + ((player->transformation == PLAYER_FORM_HUMAN) && !(gSaveContext.save.weekEventReg[85] & 2))) { func_80C0113C(this, 17, 1.0f); Message_StartTextbox(globalCtx, 0x72E, &this->actor); player->stateFlags1 |= 0x10000000; @@ -683,13 +683,13 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { return; } - idx = gSaveContext.unk_FE6; + idx = gSaveContext.save.bombersCaughtNum; Message_StartTextbox(globalCtx, D_80C03230[idx], &this->actor); - idx = gSaveContext.unk_FE6; - gSaveContext.unk_FE7[idx] = this->unk_2C8 + 1; - gSaveContext.unk_FE6++; + idx = gSaveContext.save.bombersCaughtNum; + gSaveContext.save.bombersCaughtOrder[idx] = this->unk_2C8 + 1; + gSaveContext.save.bombersCaughtNum++; - if (gSaveContext.unk_FE6 > 4) { + if (gSaveContext.save.bombersCaughtNum > 4) { func_801A3098(0x922); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); @@ -697,28 +697,28 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { switch (this->unk_2C8) { case ENBOMJIMB_F_0: - gSaveContext.weekEventReg[76] |= 1; - gSaveContext.weekEventReg[11] |= 1; + gSaveContext.save.weekEventReg[76] |= 1; + gSaveContext.save.weekEventReg[11] |= 1; break; case ENBOMJIMB_F_1: - gSaveContext.weekEventReg[76] |= 2; - gSaveContext.weekEventReg[11] |= 2; + gSaveContext.save.weekEventReg[76] |= 2; + gSaveContext.save.weekEventReg[11] |= 2; break; case ENBOMJIMB_F_2: - gSaveContext.weekEventReg[76] |= 4; - gSaveContext.weekEventReg[11] |= 4; + gSaveContext.save.weekEventReg[76] |= 4; + gSaveContext.save.weekEventReg[11] |= 4; break; case ENBOMJIMB_F_3: - gSaveContext.weekEventReg[76] |= 8; - gSaveContext.weekEventReg[11] |= 8; + gSaveContext.save.weekEventReg[76] |= 8; + gSaveContext.save.weekEventReg[11] |= 8; break; case ENBOMJIMB_F_4: - gSaveContext.weekEventReg[76] |= 0x10; - gSaveContext.weekEventReg[11] |= 0x10; + gSaveContext.save.weekEventReg[76] |= 0x10; + gSaveContext.save.weekEventReg[11] |= 0x10; break; } @@ -760,7 +760,7 @@ void func_80C02A14(EnBomjimb* this, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); - if ((this->unk_2CA == 8) && (gSaveContext.unk_FE6 >= 5)) { + if ((this->unk_2CA == 8) && (gSaveContext.save.bombersCaughtNum >= 5)) { func_80C02CA4(this, globalCtx); } else { if (this->unk_2CA == 8) { @@ -800,8 +800,8 @@ void func_80C02CA4(EnBomjimb* this, GlobalContext* globalCtx) { globalCtx->unk_1887F = 0x56; gSaveContext.nextTransition = 3; } - gSaveContext.weekEventReg[75] |= 0x40; - gSaveContext.weekEventReg[83] |= 4; + gSaveContext.save.weekEventReg[75] |= 0x40; + gSaveContext.save.weekEventReg[83] |= 4; this->actionFunc = func_80C02DAC; } diff --git a/src/overlays/actors/ovl_En_Cha/z_en_cha.c b/src/overlays/actors/ovl_En_Cha/z_en_cha.c index 129045a6c..0f340da3a 100644 --- a/src/overlays/actors/ovl_En_Cha/z_en_cha.c +++ b/src/overlays/actors/ovl_En_Cha/z_en_cha.c @@ -61,7 +61,7 @@ void EnCha_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.home.rot.z = 0; this->actionFunc = EnCha_Idle; this->actor.home.rot.x = this->actor.home.rot.z; - gSaveContext.weekEventReg[60] &= (u8)~4; + gSaveContext.save.weekEventReg[60] &= (u8)~4; } void EnCha_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -83,16 +83,16 @@ void EnCha_Ring(EnCha* this, GlobalContext* globalCtx) { } void EnCha_Idle(EnCha* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[60] & 4) { + if (gSaveContext.save.weekEventReg[60] & 4) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DOOR_BELL); - gSaveContext.weekEventReg[60] &= (u8)~4; + gSaveContext.save.weekEventReg[60] &= (u8)~4; this->actor.home.rot.z = 0x7D0; } if (this->collider.base.acFlags & AC_HIT) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DOOR_BELL); this->actor.home.rot.z = 0x7D0; - if (!(gSaveContext.weekEventReg[51] & 4)) { - gSaveContext.weekEventReg[51] |= 4; + if (!(gSaveContext.save.weekEventReg[51] & 4)) { + gSaveContext.save.weekEventReg[51] |= 4; this->actionFunc = EnCha_Ring; } } diff --git a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c index f5f399a65..6817c1830 100644 --- a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c +++ b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c @@ -94,7 +94,7 @@ void EnColMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80AFDD60(EnColMan* this) { - if (!(gSaveContext.weekEventReg[56] & 2)) { + if (!(gSaveContext.save.weekEventReg[56] & 2)) { this->actor.draw = func_80AFE414; this->actor.shape.yOffset = 700.0f; if (this->actor.params == EN_COL_MAN_HEART_PIECE) { @@ -123,14 +123,14 @@ void func_80AFDE00(EnColMan* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; } } - if (!(gSaveContext.weekEventReg[56] & 2)) { + if (!(gSaveContext.save.weekEventReg[56] & 2)) { this->actor.shape.rot.y += 0x3E8; } if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; this->actor.draw = NULL; this->actionFunc = EnColMan_SetHeartPieceCollectedAndKill; - } else if (!(gSaveContext.weekEventReg[56] & 2)) { + } else if (!(gSaveContext.save.weekEventReg[56] & 2)) { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 40.0f, 40.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RECOVERY_HEART, 40.0f, 40.0f); @@ -139,7 +139,7 @@ void func_80AFDE00(EnColMan* this, GlobalContext* globalCtx) { void EnColMan_SetHeartPieceCollectedAndKill(EnColMan* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { - gSaveContext.weekEventReg[56] |= 2; + gSaveContext.save.weekEventReg[56] |= 2; Actor_MarkForDeath(&this->actor); } } diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index 13e4c8868..772d054ab 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -116,7 +116,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = EnCow_Idle; - if (!(gSaveContext.weekEventReg[22] & 1) && (CURRENT_DAY != 1) && + if (!(gSaveContext.save.weekEventReg[22] & 1) && (CURRENT_DAY != 1) && (EN_COW_TYPE(thisx) == EN_COW_TYPE_ABDUCTED)) { Actor_MarkForDeath(&this->actor); return; @@ -153,7 +153,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); this->flags = 0; - gSaveContext.weekEventReg[87] &= (u8)~1; + gSaveContext.save.weekEventReg[87] &= (u8)~1; } void EnCow_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -289,8 +289,8 @@ void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer < 150.0f && ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 25000) { if (func_801A5100() == 4) { - if (!(gSaveContext.weekEventReg[87] & 1)) { - gSaveContext.weekEventReg[87] |= 1; + if (!(gSaveContext.save.weekEventReg[87] & 1)) { + gSaveContext.save.weekEventReg[87] |= 1; if (Interface_HasEmptyBottle()) { this->actor.textId = 0x32C9; // Text to give milk. } else { @@ -301,7 +301,7 @@ void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { this->actionFunc = EnCow_Talk; } } else { - gSaveContext.weekEventReg[87] &= (u8)~1; + gSaveContext.save.weekEventReg[87] &= (u8)~1; } } diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index 3b96d1b4d..bd7de1418 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -179,7 +179,7 @@ s32 func_80B3E69C(EnDai* this, GlobalContext* globalCtx) { s32 ret = false; if ((globalCtx->csCtx.state != 0) && (globalCtx->sceneNum == SCENE_12HAKUGINMAE) && - (globalCtx->csCtx.currentCsIndex == 0) && !(gSaveContext.weekEventReg[30] & 1)) { + (globalCtx->csCtx.currentCsIndex == 0) && !(gSaveContext.save.weekEventReg[30] & 1)) { if (!(this->unk_1CE & 0x10)) { Flags_SetSwitch(globalCtx, 20); this->unk_1CE |= (0x80 | 0x10); @@ -194,7 +194,7 @@ s32 func_80B3E69C(EnDai* this, GlobalContext* globalCtx) { } else if (this->unk_1CE & 0x10) { this->unk_1CE &= ~0x10; this->unk_1CE |= 0x200; - gSaveContext.weekEventReg[30] |= 1; + gSaveContext.save.weekEventReg[30] |= 1; this->actionFunc = func_80B3F00C; } @@ -525,7 +525,7 @@ void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_1CE = 0; this->unk_1D6 = 0; - if (gSaveContext.weekEventReg[33] & 0x80) { + if (gSaveContext.save.weekEventReg[33] & 0x80) { SubS_UpdateFlags(&this->unk_1CE, 3, 7); this->unk_1CE |= 0x80; this->unk_1CD = 0xFF; @@ -533,7 +533,7 @@ void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - if (gSaveContext.weekEventReg[30] & 1) { + if (gSaveContext.save.weekEventReg[30] & 1) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c index 79012db84..a15d09515 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -77,10 +77,11 @@ void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.height = 60; this->collider.dim.yShift = 0; this->actor.flags |= ACTOR_FLAG_8000000; - if ((gSaveContext.weekEventReg[63] & 0x80) || ((gSaveContext.day == 3) && gSaveContext.isNight)) { + if ((gSaveContext.save.weekEventReg[63] & 0x80) || + ((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { Actor_MarkForDeath(&this->actor); } - } else if ((gSaveContext.day == 3) && gSaveContext.isNight) { + } else if ((gSaveContext.save.day == 3) && gSaveContext.save.isNight) { Actor_MarkForDeath(&this->actor); } @@ -140,7 +141,7 @@ void func_809437C8(EnDaiku* this) { } void func_80943820(EnDaiku* this) { - s32 day = gSaveContext.day - 1; + s32 day = gSaveContext.save.day - 1; switch (this->unk_278) { case 0: @@ -167,7 +168,7 @@ void func_80943820(EnDaiku* this) { void func_809438F8(EnDaiku* this, GlobalContext* globalCtx) { f32 currentFrame = this->skelAnime.curFrame; s32 pad; - s32 day = gSaveContext.day - 1; + s32 day = gSaveContext.save.day - 1; s32 pad2; if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { @@ -255,7 +256,7 @@ void EnDaiku_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); } - if ((this->unk_278 == ENDAIKU_PARAMS_FF_0) && (gSaveContext.day == 3) && (gSaveContext.isNight)) { + if ((this->unk_278 == ENDAIKU_PARAMS_FF_0) && (gSaveContext.save.day == 3) && (gSaveContext.save.isNight)) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c index 0a1195b1a..009094f93 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -78,7 +78,7 @@ void func_80BE61D0(EnDaiku2* this) { void EnDaiku2_Init(Actor* thisx, GlobalContext* globalCtx) { EnDaiku2* this = THIS; - s32 day = gSaveContext.day; + s32 day = gSaveContext.save.day; this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 40.0f); @@ -163,10 +163,10 @@ s32 func_80BE64C0(EnDaiku2* this, GlobalContext* globalCtx) { } void func_80BE65B4(EnDaiku2* this, GlobalContext* globalCtx) { - switch (gSaveContext.day - 1) { + switch (gSaveContext.save.day - 1) { case 0: this->unk_28A = 0; - if (gSaveContext.weekEventReg[64] & 2) { + if (gSaveContext.save.weekEventReg[64] & 2) { this->unk_28A = 6; } func_80BE6408(this, 8); @@ -174,7 +174,7 @@ void func_80BE65B4(EnDaiku2* this, GlobalContext* globalCtx) { case 1: this->unk_28A = 2; - if (gSaveContext.weekEventReg[64] & 4) { + if (gSaveContext.save.weekEventReg[64] & 4) { this->unk_28A = 7; } func_80BE6408(this, 8); @@ -201,7 +201,7 @@ void func_80BE65B4(EnDaiku2* this, GlobalContext* globalCtx) { void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx) { f32 sp9C = this->skelAnime.curFrame; - s32 sp98 = gSaveContext.day - 1; + s32 sp98 = gSaveContext.save.day - 1; s32 i; Vec3f sp88; Vec3f sp7C; @@ -279,7 +279,7 @@ void func_80BE66E4(EnDaiku2* this, GlobalContext* globalCtx) { } void func_80BE6B40(EnDaiku2* this, GlobalContext* globalCtx) { - s32 day = gSaveContext.day; + s32 day = gSaveContext.save.day; this->unk_288 = 1; if ((day != 3) && Flags_GetSwitch(globalCtx, this->unk_278)) { @@ -293,7 +293,7 @@ void func_80BE6B40(EnDaiku2* this, GlobalContext* globalCtx) { void func_80BE6BC0(EnDaiku2* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0x0); if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { - s32 day = gSaveContext.day - 1; + s32 day = gSaveContext.save.day - 1; func_801477B4(globalCtx); @@ -307,11 +307,11 @@ void func_80BE6BC0(EnDaiku2* this, GlobalContext* globalCtx) { } else { switch (day) { case 0: - gSaveContext.weekEventReg[64] |= 2; + gSaveContext.save.weekEventReg[64] |= 2; break; case 1: - gSaveContext.weekEventReg[64] |= 4; + gSaveContext.save.weekEventReg[64] |= 4; break; } func_80BE65B4(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index da8b51cbc..5d477d21f 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -348,10 +348,11 @@ void func_80989BF8(EnDg* this) { if (this->unk_286 < 14) { if (this->unk_286 % 2) { D_8098C2A8[this->unk_286].unk_04 = - 0x3538 + ((gSaveContext.weekEventReg[42 + (this->unk_286 / 2)] & (0x10 | 0x20 | 0x40 | 0x80)) >> 4); + 0x3538 + + ((gSaveContext.save.weekEventReg[42 + (this->unk_286 / 2)] & (0x10 | 0x20 | 0x40 | 0x80)) >> 4); } else { D_8098C2A8[this->unk_286].unk_04 = - 0x3538 + (gSaveContext.weekEventReg[42 + (this->unk_286 / 2)] & (1 | 2 | 4 | 8)); + 0x3538 + (gSaveContext.save.weekEventReg[42 + (this->unk_286 / 2)] & (1 | 2 | 4 | 8)); } } else { Actor_MarkForDeath(&this->actor); diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index 10e3fd8b8..9236ce6fa 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -450,7 +450,7 @@ s32 func_8089AE00(EnDinofos* this, GlobalContext* globalCtx) { return true; } - if ((gSaveContext.playerForm == PLAYER_FORM_GORON) && (player->actor.velocity.y < -5.0f) && + if ((gSaveContext.save.playerForm == PLAYER_FORM_GORON) && (player->actor.velocity.y < -5.0f) && (player->unk_AE7 == 1) && (this->unk_28B == 0)) { this->unk_28B = 1; for (i = 0; i < ARRAY_COUNT(this->colliderJntSphElement) - 3; i++) { diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.c b/src/overlays/actors/ovl_En_Dno/z_en_dno.c index 57e697380..ceffe3d93 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -211,7 +211,7 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { switch (ENDNO_GET_C000(thisx)) { case ENDNO_GET_C000_0: func_80A71788(this, globalCtx); - if (!(gSaveContext.weekEventReg[23] & 0x20) || (gSaveContext.weekEventReg[93] & 2)) { + if (!(gSaveContext.save.weekEventReg[23] & 0x20) || (gSaveContext.save.weekEventReg[93] & 2)) { Actor_MarkForDeath(thisx); } else { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); @@ -225,7 +225,7 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ENDNO_GET_C000_1: - if (gSaveContext.weekEventReg[23] & 0x20) { + if (gSaveContext.save.weekEventReg[23] & 0x20) { Actor_MarkForDeath(thisx); } else { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); @@ -267,7 +267,7 @@ void func_80A71B68(EnDno* this, GlobalContext* globalCtx) { this->unk_452 = 0; this->actor.textId = 0; if (CHECK_QUEST_ITEM(QUEST_SONG_SONATA)) { - if (gSaveContext.weekEventReg[27] & 1) { + if (gSaveContext.save.weekEventReg[27] & 1) { if (!(this->unk_3B0 & 0x20)) { SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->unk_460); @@ -331,17 +331,17 @@ void func_80A71C3C(EnDno* this, GlobalContext* globalCtx) { void func_80A71E54(EnDno* this, GlobalContext* globalCtx) { if (CHECK_QUEST_ITEM(QUEST_SONG_SONATA)) { - if (gSaveContext.weekEventReg[27] & 1) { + if (gSaveContext.save.weekEventReg[27] & 1) { this->textId = 0x811; } else { this->textId = 0x80F; - gSaveContext.weekEventReg[27] |= 1; + gSaveContext.save.weekEventReg[27] |= 1; } - } else if (gSaveContext.weekEventReg[26] & 0x80) { + } else if (gSaveContext.save.weekEventReg[26] & 0x80) { this->textId = 0x80B; } else { this->textId = 0x80C; - gSaveContext.weekEventReg[26] |= 0x80; + gSaveContext.save.weekEventReg[26] |= 0x80; } if (this->textId != 0x811) { @@ -558,7 +558,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { case 2: if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2D8)) { - gSaveContext.weekEventReg[93] |= 2; + gSaveContext.save.weekEventReg[93] |= 2; Message_StartTextbox(globalCtx, 0x802, &this->actor); } break; diff --git a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c index d7274837c..13a02345d 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -206,7 +206,7 @@ s32 func_80B3CF60(EnDnp* this, GlobalContext* globalCtx) { this->unk_322 |= 8; this->actionFunc = func_80B3D3F8; ret = true; - } else if (!(gSaveContext.weekEventReg[23] & 0x20) && Actor_HasParent(&this->actor, globalCtx)) { + } else if (!(gSaveContext.save.weekEventReg[23] & 0x20) && Actor_HasParent(&this->actor, globalCtx)) { SubS_UpdateFlags(&this->unk_322, 0, 7); this->unk_322 &= ~0x500; this->actor.parent = NULL; @@ -247,10 +247,10 @@ void func_80B3D11C(EnDnp* this, GlobalContext* globalCtx) { s32 temp_v0; s32 val; - if (!(gSaveContext.weekEventReg[29] & 0x40) && (globalCtx->sceneNum == SCENE_MITURIN) && + if (!(gSaveContext.save.weekEventReg[29] & 0x40) && (globalCtx->sceneNum == SCENE_MITURIN) && (globalCtx->csCtx.currentCsIndex == 0)) { this->unk_322 |= 0x20; - gSaveContext.weekEventReg[29] |= 0x40; + gSaveContext.save.weekEventReg[29] |= 0x40; } if (Cutscene_CheckActorAction(globalCtx, 101)) { @@ -337,7 +337,7 @@ void func_80B3D47C(EnDnp* this, GlobalContext* globalCtx) { void func_80B3D558(EnDnp* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); - gSaveContext.weekEventReg[23] |= 0x20; + gSaveContext.save.weekEventReg[23] |= 0x20; } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); } @@ -366,12 +366,12 @@ void EnDnp_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.cutscene = 0x10; this->actionFunc = func_80B3D47C; } else if (((ENDNP_GET_7(&this->actor) == ENDNP_GET_7_0) && !Interface_HasItemInBottle(ITEM_DEKU_PRINCESS) && - !(gSaveContext.weekEventReg[23] & 0x20)) || - ((ENDNP_GET_7(&this->actor) == ENDNP_GET_7_2) && (gSaveContext.weekEventReg[23] & 0x20))) { + !(gSaveContext.save.weekEventReg[23] & 0x20)) || + ((ENDNP_GET_7(&this->actor) == ENDNP_GET_7_2) && (gSaveContext.save.weekEventReg[23] & 0x20))) { Actor_SetScale(&this->actor, 0.0085f); SubS_UpdateFlags(&this->unk_322, 3, 7); this->unk_322 |= 0x400; - if ((globalCtx->sceneNum == SCENE_MITURIN) && (gSaveContext.weekEventReg[29] & 0x40)) { + if ((globalCtx->sceneNum == SCENE_MITURIN) && (gSaveContext.save.weekEventReg[29] & 0x40)) { this->unk_322 |= 0x20; func_80B3CC38(this, 1); } @@ -407,7 +407,7 @@ void EnDnp_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); sp2C = this->collider.dim.radius + 50; sp28 = this->collider.dim.height + 30; - if ((this->unk_322 & 0x400) && !(gSaveContext.weekEventReg[23] & 0x20)) { + if ((this->unk_322 & 0x400) && !(gSaveContext.save.weekEventReg[23] & 0x20)) { Actor_PickUp(&this->actor, globalCtx, GI_MAX, sp2C, sp28); } func_8013C964(&this->actor, globalCtx, sp2C, sp28, 0, this->unk_322 & 7); diff --git a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c index d5bedf333..535201ac3 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -306,7 +306,7 @@ void func_80A52C6C(EnDnq* this, GlobalContext* globalCtx) { } s32* func_80A52CF8(EnDnq* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[23] & 0x20) { + if (gSaveContext.save.weekEventReg[23] & 0x20) { return &D_80A53400[14]; } @@ -340,11 +340,11 @@ void func_80A52DC8(EnDnq* this, GlobalContext* globalCtx) { SubS_UpdateFlags(&this->unk_37C, 0, 7); } - if (!(gSaveContext.weekEventReg[23] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { this->unk_390 = 70.0f; if (Interface_HasItemInBottle(ITEM_DEKU_PRINCESS) && !func_801690CC(globalCtx) && (Message_GetState(&globalCtx->msgCtx) == 0) && (ActorCutscene_GetCurrentIndex() == -1)) { - if ((DECR(this->unk_384) == 0) && (gSaveContext.weekEventReg[29] & 0x40)) { + if ((DECR(this->unk_384) == 0) && (gSaveContext.save.weekEventReg[29] & 0x40)) { Message_StartTextbox(globalCtx, 0x969, NULL); this->unk_384 = 200; } @@ -358,7 +358,7 @@ void func_80A52DC8(EnDnq* this, GlobalContext* globalCtx) { this->actor.xzDistToPlayer = this->unk_394; - if (gSaveContext.weekEventReg[83] & 8) { + if (gSaveContext.save.weekEventReg[83] & 8) { func_80A52A78(this, globalCtx); } else if (this->unk_3A4 == 0) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); @@ -427,7 +427,7 @@ void EnDnq_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_386 = 0; this->unk_37C = 0; SubS_UpdateFlags(&this->unk_37C, 3, 7); - if (gSaveContext.weekEventReg[9] & 0x80) { + if (gSaveContext.save.weekEventReg[9] & 0x80) { this->unk_3A4 = 1; } else { this->unk_3A4 = 0; diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c index b9f1605f9..646a2b778 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -182,7 +182,7 @@ void func_8092C934(EnDns* this) { s32* func_8092C9BC(EnDns* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (!(gSaveContext.weekEventReg[23] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { if (player->transformation != PLAYER_FORM_DEKU) { return &D_8092DCB0[16]; } else if (this->unk_2FC != 0) { @@ -361,14 +361,14 @@ s32 func_8092D068(EnDns* this) { s32 ret = false; if (ENDNS_GET_8000(&this->actor)) { - if (gSaveContext.weekEventReg[23] & 0x20) { + if (gSaveContext.save.weekEventReg[23] & 0x20) { ret = true; } } else if (ENDNS_GET_4000(&this->actor)) { - if ((gSaveContext.weekEventReg[9] & 0x80) && !(gSaveContext.weekEventReg[23] & 0x20)) { + if ((gSaveContext.save.weekEventReg[9] & 0x80) && !(gSaveContext.save.weekEventReg[23] & 0x20)) { ret = true; } - } else if (!(gSaveContext.weekEventReg[9] & 0x80) && !(gSaveContext.weekEventReg[23] & 0x20)) { + } else if (!(gSaveContext.save.weekEventReg[9] & 0x80) && !(gSaveContext.save.weekEventReg[23] & 0x20)) { ret = true; } @@ -399,7 +399,8 @@ void func_8092D1B8(EnDns* this, GlobalContext* globalCtx) { } if (!ENDNS_GET_4000(&this->actor) || (this->unk_2D2 != 0)) { - if (!(gSaveContext.weekEventReg[23] & 0x20) && !(gSaveContext.eventInf[1] & 0x20) && func_8092CC68(globalCtx)) { + if (!(gSaveContext.save.weekEventReg[23] & 0x20) && !(gSaveContext.eventInf[1] & 0x20) && + func_8092CC68(globalCtx)) { player->stateFlags1 |= 0x20; this->unk_2C6 |= 0x100; SubS_UpdateFlags(&this->unk_2C6, 4, 7); @@ -524,7 +525,7 @@ void EnDns_Init(Actor* thisx, GlobalContext* globalCtx) { SubS_UpdateFlags(&this->unk_2C6, 3, 7); this->unk_2C6 |= (0x40 | 0x10); this->unk_2C6 |= 0x200; - if (gSaveContext.weekEventReg[9] & 0x80) { + if (gSaveContext.save.weekEventReg[9] & 0x80) { this->unk_2FC = 1; } else { this->unk_2FC = 0; diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.c b/src/overlays/actors/ovl_En_Door/z_en_door.c index e5733c2b1..1fdbbd32f 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -346,7 +346,7 @@ void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { Animation_PlayOnceSetSpeed(&this->skelAnime, sAnimations[this->animIndex], (player->stateFlags1 & 0x8000000) ? 0.75f : 1.5f); if (this->unk_1A6 != 0) { - gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex]--; + gSaveContext.save.inventory.dungeonKeys[gSaveContext.mapIndex]--; Flags_SetSwitch(globalCtx, this->switchFlag); Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CHAIN_KEY_UNLOCK); } @@ -366,7 +366,7 @@ void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { player->doorDirection = playerPosRelToDoor.z >= 0.0f ? 1.0f : -1.0f; player->doorActor = &this->dyna.actor; if (this->unk_1A6 != 0) { - if (gSaveContext.inventory.dungeonKeys[((void)0, gSaveContext.mapIndex)] <= 0) { + if (gSaveContext.save.inventory.dungeonKeys[((void)0, gSaveContext.mapIndex)] <= 0) { player->doorType = -1; this->dyna.actor.textId = 0x1802; } else { diff --git a/src/overlays/actors/ovl_En_Drs/z_en_drs.c b/src/overlays/actors/ovl_En_Drs/z_en_drs.c index 8643dfa91..74f4f19cc 100644 --- a/src/overlays/actors/ovl_En_Drs/z_en_drs.c +++ b/src/overlays/actors/ovl_En_Drs/z_en_drs.c @@ -108,7 +108,7 @@ void EnDrs_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList, V // Anju removes the Moon Mask at the start of the Couple's Mask cutscene // after that it will no longer be rendered. - if (!(gSaveContext.weekEventReg[87] & 2) && (limbIndex == WEDDING_DRESS_MANNEQUIN_LIMB_MASK)) { + if (!(gSaveContext.save.weekEventReg[87] & 2) && (limbIndex == WEDDING_DRESS_MANNEQUIN_LIMB_MASK)) { OPEN_DISPS(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[temp].segment); gSPDisplayList(POLY_OPA_DISP++, &gMoonMaskDL); diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index 34fcedd50..782b56f7e 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -355,8 +355,8 @@ void EnElf_Init(Actor* thisx, GlobalContext* globalCtx2) { this->elfMsg = NULL; this->unk_234 = NULL; this->unk_269 = 20; - if ((gSaveContext.tatlTimer >= 25800) || (gSaveContext.tatlTimer < 3000)) { - gSaveContext.tatlTimer = 0; + if ((gSaveContext.save.playerData.tatlTimer >= 25800) || (gSaveContext.save.playerData.tatlTimer < 3000)) { + gSaveContext.save.playerData.tatlTimer = 0; } this->unk_266 = ElfMessage_GetFirstCycleHint(globalCtx); break; @@ -675,7 +675,8 @@ void func_8088DD34(EnElf* this, GlobalContext* globalCtx) { !func_8088C804(&this->actor.world.pos, &refActor->actor.world.pos, 10.0f)) { func_80115908(globalCtx, 0x80); if (this->fairyFlags & 0x200) { - Parameter_AddMagic(globalCtx, ((void)0, gSaveContext.unk_3F30) + (gSaveContext.doubleMagic * 0x30) + 0x30); + Parameter_AddMagic(globalCtx, ((void)0, gSaveContext.unk_3F30) + + (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); } gSaveContext.jinxTimer = 0; this->unk_254 = 50.0f; @@ -1414,10 +1415,10 @@ void func_8088FE64(Actor* thisx, GlobalContext* globalCtx2) { break; case 3: - if (!gSaveContext.isNight) { + if (!gSaveContext.save.isNight) { func_80151938(globalCtx, 0x248); - } else if ((gSaveContext.time < CLOCK_TIME(6, 0)) && - (gSaveContext.weekEventReg[74] & 0x20)) { + } else if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && + (gSaveContext.save.weekEventReg[74] & 0x20)) { func_80151938(globalCtx, 0x225); } else { func_80151938(globalCtx, 0x249); @@ -1454,11 +1455,11 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { if (temp_v0 != this->unk_266) { this->unk_266 = temp_v0; - gSaveContext.tatlTimer = 0; + gSaveContext.save.playerData.tatlTimer = 0; } if ((player->tatlTextId == 0) && (player->unk_730 == NULL)) { - if ((gSaveContext.tatlTimer >= 600) && (gSaveContext.tatlTimer <= 3000)) { + if ((gSaveContext.save.playerData.tatlTimer >= 600) && (gSaveContext.save.playerData.tatlTimer <= 3000)) { player->tatlTextId = ElfMessage_GetFirstCycleHint(globalCtx); } } @@ -1473,7 +1474,7 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { if (thisx->textId == ElfMessage_GetFirstCycleHint(globalCtx)) { this->fairyFlags |= 0x80; - gSaveContext.tatlTimer = 3001; + gSaveContext.save.playerData.tatlTimer = 3001; } this->fairyFlags |= 0x10; @@ -1504,10 +1505,10 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if (!func_801690CC(globalCtx)) { - if (gSaveContext.tatlTimer < 25800) { - gSaveContext.tatlTimer++; + if (gSaveContext.save.playerData.tatlTimer < 25800) { + gSaveContext.save.playerData.tatlTimer++; } else if (!(this->fairyFlags & 0x80)) { - gSaveContext.tatlTimer = 0; + gSaveContext.save.playerData.tatlTimer = 0; } } } diff --git a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c index ee7475061..3acd2adf5 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c @@ -91,7 +91,7 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { switch (this->unk_147) { case ENELFGRP_1: - if (gSaveContext.weekEventReg[23] & 2) { + if (gSaveContext.save.weekEventReg[23] & 2) { func_80A396B0(this, 1); } else { this->unk_14A |= 4; @@ -99,13 +99,13 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ENELFGRP_2: - if (gSaveContext.doubleMagic == true) { + if (gSaveContext.save.playerData.doubleMagic == true) { func_80A396B0(this, 1); } break; case ENELFGRP_3: - if (gSaveContext.doubleDefense) { + if (gSaveContext.save.playerData.doubleDefense) { func_80A396B0(this, 1); } break; @@ -123,7 +123,7 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.textId = (this->unk_147 * 3) + 0x581; } else { this->actionFunc = func_80A3A8F8; - if ((gSaveContext.weekEventReg[9] & this->unk_146)) { + if ((gSaveContext.save.weekEventReg[9] & this->unk_146)) { this->actor.textId = (this->unk_147 * 3) + 0x580; } else { this->actor.textId = (this->unk_147 * 3) + 0x57F; @@ -146,7 +146,7 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_14A |= 2; func_80A396B0(this, 6); } - } else if ((gSaveContext.weekEventReg[8] & 0x80)) { + } else if ((gSaveContext.save.weekEventReg[8] & 0x80)) { func_80A39DC8(this, globalCtx, 24, 0); this->actionFunc = func_80A3A398; if (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU) { @@ -156,13 +156,13 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A396B0(this, 3); this->unk_14A |= 2; } - } else if (gSaveContext.magicAcquired == true) { + } else if (gSaveContext.save.playerData.magicAcquired == true) { func_80A396B0(this, 1); } } else { func_80A39DC8(this, globalCtx, 24, 0); this->actionFunc = func_80A3A8F8; - if ((gSaveContext.weekEventReg[9] & this->unk_146)) { + if ((gSaveContext.save.weekEventReg[9] & this->unk_146)) { this->actor.textId = 0x580; } else { this->actor.textId = 0x578; @@ -183,7 +183,7 @@ s32 func_80A39BD0(GlobalContext* globalCtx, s32 arg2) { return 0; } - sp1F = gSaveContext.inventory.strayFairies[arg2 - 1]; + sp1F = gSaveContext.save.inventory.strayFairies[arg2 - 1]; return (sp1F - func_80A39C1C(globalCtx, arg2)) + 10; } @@ -208,13 +208,13 @@ s32 func_80A39C1C(GlobalContext* globalCtx, s32 arg1) { } if (arg1 == 0) { - if (gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1) { + if (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1) { return 25; } return 24; } - temp_v1 = (gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 >> (((arg1 - 1) * 5) + 1)) & 0x1F; + temp_v1 = (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 >> (((arg1 - 1) * 5) + 1)) & 0x1F; if (temp_v1 < 10) { temp_v1 = 10; } else if (temp_v1 > 25) { @@ -230,13 +230,13 @@ void func_80A39CD4(GlobalContext* globalCtx, s32 arg1, s32 arg2) { if (arg1 == 0) { if (arg2 == 25) { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 1; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 1; } else { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~1; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~1; } } else { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~(0x1F << ((arg1 * 5) - 4)); - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= arg2 << ((arg1 * 5) - 4); + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~(0x1F << ((arg1 * 5) - 4)); + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= arg2 << ((arg1 * 5) - 4); } } @@ -425,7 +425,7 @@ void func_80A3A398(EnElfgrp* this, GlobalContext* globalCtx) { } if ((this->unk_14A & 4) != 0) { - gSaveContext.weekEventReg[23] |= 2; + gSaveContext.save.weekEventReg[23] |= 2; } if (this->unk_14A & 0x10) { @@ -481,7 +481,8 @@ void func_80A3A610(EnElfgrp* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (this->unk_144 == 60) { - Parameter_AddMagic(globalCtx, ((void)0, gSaveContext.unk_3F30) + (gSaveContext.doubleMagic * 0x30) + 0x30); + Parameter_AddMagic(globalCtx, + ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); gSaveContext.healthAccumulator = 320; } @@ -526,7 +527,7 @@ void func_80A3A7FC(EnElfgrp* this, GlobalContext* globalCtx) { s32 temp_s0; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - gSaveContext.weekEventReg[9] |= this->unk_146; + gSaveContext.save.weekEventReg[9] |= this->unk_146; this->actionFunc = func_80A3A6F4; temp_s0 = func_80A39BD0(globalCtx, this->unk_147); func_80A39DC8(this, globalCtx, temp_s0, 1); @@ -546,7 +547,7 @@ void func_80A3A8F8(EnElfgrp* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - gSaveContext.weekEventReg[9] |= this->unk_146; + gSaveContext.save.weekEventReg[9] |= this->unk_146; this->actionFunc = func_80A3A6F4; return; } @@ -559,13 +560,13 @@ void func_80A3A8F8(EnElfgrp* this, GlobalContext* globalCtx) { } if (this->actor.xzDistToPlayer < 30.0f) { - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { this->actor.flags &= ~ACTOR_FLAG_10000; player->actor.freezeTimer = 100; player->stateFlags1 |= 0x20000000; Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = func_80A3A77C; - gSaveContext.weekEventReg[9] |= this->unk_146; + gSaveContext.save.weekEventReg[9] |= this->unk_146; } else { this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 100.0f); diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index 3c263c018..36ad91c0f 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -81,7 +81,7 @@ void EnElforg_Init(Actor* thisx, GlobalContext* globalCtx) { switch (STRAY_FAIRY_TYPE(&this->actor)) { case STRAY_FAIRY_TYPE_CLOCK_TOWN: - if (gSaveContext.weekEventReg[8] & 0x80) { + if (gSaveContext.save.weekEventReg[8] & 0x80) { Actor_MarkForDeath(&this->actor); return; } @@ -364,7 +364,7 @@ void EnElforg_CirclePlayer(EnElforg* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 distanceFromPlayer; - if (gSaveContext.playerForm == PLAYER_FORM_GORON) { + if (gSaveContext.save.playerForm == PLAYER_FORM_GORON) { distanceFromPlayer = 40.0f; } else { distanceFromPlayer = 20.0f; @@ -407,7 +407,7 @@ void EnElforg_ClockTownFairyCollected(EnElforg* this, GlobalContext* globalCtx) player->actor.freezeTimer = 0; player->stateFlags1 &= ~0x20000000; Actor_MarkForDeath(&this->actor); - gSaveContext.weekEventReg[8] |= 0x80; + gSaveContext.save.weekEventReg[8] |= 0x80; ActorCutscene_Stop(0x7C); } else { func_800B9010(&this->actor, NA_SE_PL_CHIBI_FAIRY_HEAL - SFX_FLAG); @@ -463,9 +463,9 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { } if (func_8010A074(globalCtx)) { - gSaveContext.inventory.strayFairies[gSaveContext.unk_48C8]++; + gSaveContext.save.inventory.strayFairies[gSaveContext.unk_48C8]++; Message_StartTextbox(globalCtx, 0x11, NULL); - if (gSaveContext.inventory.strayFairies[(void)0, gSaveContext.unk_48C8] >= 15) { + if (gSaveContext.save.inventory.strayFairies[(void)0, gSaveContext.unk_48C8] >= 15) { func_801A3098(NA_BGM_GET_ITEM | 0x900); } } diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.c b/src/overlays/actors/ovl_En_Fall/z_en_fall.c index 8c7f291ce..dabd62e0f 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -77,7 +77,7 @@ const ActorInit En_Fall_InitVars = { * it also moves the moon closer to the ground depending on the current time. */ void EnFall_Moon_AdjustScaleAndPosition(EnFall* this, GlobalContext* globalCtx) { - u16 currentTime = gSaveContext.time; + u16 currentTime = gSaveContext.save.time; u16 dayStartTime = this->dayStartTime; f32 finalDayRelativeHeight; @@ -218,7 +218,7 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actor.draw = EnFall_Moon_Draw; this->actionFunc = EnFall_StoppedClosedMouthMoon_PerformCutsceneActions; Actor_SetScale(&this->actor, this->scale * 3.0f); - if (!(gSaveContext.weekEventReg[25] & 2)) { + if (!(gSaveContext.save.weekEventReg[25] & 2)) { Actor_MarkForDeath(&this->actor); } break; @@ -227,7 +227,7 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actionFunc = EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions; Actor_SetScale(&this->actor, this->scale * 3.0f); this->actor.draw = EnFall_Moon_Draw; - if (gSaveContext.weekEventReg[25] & 2) { + if (gSaveContext.save.weekEventReg[25] & 2) { Actor_MarkForDeath(&this->actor); } break; @@ -325,7 +325,7 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globa case 2: if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { - if (gSaveContext.weekEventReg[93] & 4) { + if (gSaveContext.save.weekEventReg[93] & 4) { if (ActorCutscene_GetCanPlayNext(0xC)) { ActorCutscene_Start(0xC, &this->actor); sGiantsCutsceneState++; @@ -334,7 +334,7 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globa } } else if (ActorCutscene_GetCanPlayNext(0xB)) { ActorCutscene_Start(0xB, &this->actor); - gSaveContext.weekEventReg[93] |= 4; + gSaveContext.save.weekEventReg[93] |= 4; sGiantsCutsceneState++; } else { ActorCutscene_SetIntentToPlay(0xB); @@ -481,7 +481,7 @@ void EnFall_Moon_PerformDefaultActions(EnFall* this, GlobalContext* globalCtx) { currentDay = CURRENT_DAY; if ((u16)this->currentDay != (u32)currentDay) { this->currentDay = currentDay; - this->dayStartTime = gSaveContext.time; + this->dayStartTime = gSaveContext.save.time; } EnFall_Moon_AdjustScaleAndPosition(this, globalCtx); } @@ -518,8 +518,8 @@ void EnFall_MoonsTear_Fall(EnFall* this, GlobalContext* globalCtx) { if (this->actor.draw != NULL) { if (Math_Vec3f_StepTo(&this->actor.world.pos, &this->actor.home.pos, this->actor.speedXZ) <= 0.0f) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_BOUND_1); - gSaveContext.weekEventReg[74] |= 0x80; - gSaveContext.weekEventReg[74] |= 0x20; + gSaveContext.save.weekEventReg[74] |= 0x80; + gSaveContext.save.weekEventReg[74] |= 0x20; Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TEST, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, -2); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c index d20b82865..f86cda7d8 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -161,27 +161,27 @@ void EnFish2_Init(Actor* thisx, GlobalContext* globalCtx) { this->jointTable, this->morphTable, 24); this->actor.colChkInfo.mass = MASS_IMMOVABLE; if (this->unk_344 == 0) { - if (gSaveContext.weekEventReg[81] & 0x10) { + if (gSaveContext.save.weekEventReg[81] & 0x10) { this->unk_2C0 = 1; } - if (gSaveContext.weekEventReg[81] & 0x20) { + if (gSaveContext.save.weekEventReg[81] & 0x20) { this->unk_2C0 = 2; } - if (gSaveContext.weekEventReg[81] & 0x40) { + if (gSaveContext.save.weekEventReg[81] & 0x40) { this->unk_2C0 = 3; } } else { - if (gSaveContext.weekEventReg[81] & 0x80) { + if (gSaveContext.save.weekEventReg[81] & 0x80) { this->unk_2C0 = 1; } - if (gSaveContext.weekEventReg[82] & 1) { + if (gSaveContext.save.weekEventReg[82] & 1) { this->unk_2C0 = 2; } - if (gSaveContext.weekEventReg[82] & 2) { + if (gSaveContext.save.weekEventReg[82] & 2) { this->unk_2C0 = 3; } } @@ -619,18 +619,18 @@ void func_80B297FC(EnFish2* this, GlobalContext* globalCtx) { this->unk_2C0++; if (this->unk_344 == 0) { if (this->unk_2C0 == 1) { - gSaveContext.weekEventReg[81] |= 0x10; + gSaveContext.save.weekEventReg[81] |= 0x10; } else if (this->unk_2C0 == 2) { - gSaveContext.weekEventReg[81] |= 0x20; + gSaveContext.save.weekEventReg[81] |= 0x20; } else if (this->unk_2C0 == 3) { - gSaveContext.weekEventReg[81] |= 0x40; + gSaveContext.save.weekEventReg[81] |= 0x40; } } else if (this->unk_2C0 == 1) { - gSaveContext.weekEventReg[81] |= 0x80; + gSaveContext.save.weekEventReg[81] |= 0x80; } else if (this->unk_2C0 == 2) { - gSaveContext.weekEventReg[82] |= 1; + gSaveContext.save.weekEventReg[82] |= 1; } else if (this->unk_2C0 == 3) { - gSaveContext.weekEventReg[82] |= 2; + gSaveContext.save.weekEventReg[82] |= 2; } if (this->unk_2B0 != 0) { @@ -890,12 +890,12 @@ void func_80B2A498(EnFish2* this, GlobalContext* globalCtx) { temp_v0->speedXZ = 4.0f; temp_v0->velocity.y = 15.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); - gSaveContext.weekEventReg[81] &= (u8)~0x10; - gSaveContext.weekEventReg[81] &= (u8)~0x20; - gSaveContext.weekEventReg[81] &= (u8)~0x40; - gSaveContext.weekEventReg[81] &= (u8)~0x80; - gSaveContext.weekEventReg[82] &= (u8)~1; - gSaveContext.weekEventReg[82] &= (u8)~2; + gSaveContext.save.weekEventReg[81] &= (u8)~0x10; + gSaveContext.save.weekEventReg[81] &= (u8)~0x20; + gSaveContext.save.weekEventReg[81] &= (u8)~0x40; + gSaveContext.save.weekEventReg[81] &= (u8)~0x80; + gSaveContext.save.weekEventReg[82] &= (u8)~1; + gSaveContext.save.weekEventReg[82] &= (u8)~2; } } 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 9bf1643b2..eccee0fe9 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -119,86 +119,86 @@ typedef struct { #define LINE_SEG_COUNT 200 #define SINKING_LURE_SEG_COUNT 20 -static f32 D_809101B0; -static f32 D_809101B4; -static s16 D_809101B8; -static f32 D_809101BC; -static f32 D_809101C0; -static f32 D_809101C4; -static f32 D_809101C8; -static s16 D_809101CC; -static f32 D_809101D0; -static Vec3f sRodTipPos; -static Vec3f sReelLinePos[LINE_SEG_COUNT]; -static Vec3f sReelLineRot[LINE_SEG_COUNT]; -static Vec3f sReelLineUnk[LINE_SEG_COUNT]; -static Vec3f sLureHookRefPos[2]; -static f32 sLureHookRotY[2]; -static u8 D_80911E28; -static Vec3f sSinkingLurePos[SINKING_LURE_SEG_COUNT]; -static s16 D_80911F20; -static f32 sProjectedW; -static Vec3f sCameraEye; -static Vec3f sCameraAt; -static s16 sCameraId; -static f32 D_80911F48; -static f32 D_80911F4C; -static f32 D_80911F50; -static Vec3f sSinkingLureBasePos; -static f32 D_80911F64; -static s32 sRandSeed0; -static s32 sRandSeed1; -static s32 sRandSeed2; -static FishingProp sPondProps[POND_PROP_COUNT]; -static FishingGroupFish sGroupFishes[GROUP_FISH_COUNT]; -static f32 sFishGroupAngle1; -static f32 sFishGroupAngle2; -static f32 sFishGroupAngle3; -static FishingEffect sFishingEffects[EFFECT_COUNT]; -static Vec3f sStreamSoundProjectedPos; -static EnFishing* sFishingMain; -static u8 D_809171C8; -static u8 sLinkAge; -static u8 D_809171CA; -static u8 D_809171CB; -static f32 D_809171CC; -static u8 D_809171D0; -static u8 D_809171D1; -static u8 D_809171D2; -static s16 D_809171D4; -static u8 D_809171D6; -static u16 D_809171D8; -static u16 D_809171DA; -static s8 D_809171DC; -static Vec3f sOwnerHeadPos; -static Vec3s sEffOwnerHatRot; -static u8 D_809171F2; -static s16 D_809171F4; -static s16 D_809171F6; -static EnFishing* sFishingHookedFish; -static s16 D_809171FC; -static s16 D_809171FE; -static s16 D_80917200; -static s16 D_80917202; -static s16 D_80917204; -static u8 D_80917206; -static Vec3f sLurePos; -static Vec3f D_80917218; -static Vec3f sLureRot; -static Vec3f D_80917238; -static Vec3f D_80917248; -static f32 D_80917254; -static f32 D_80917258; -static f32 D_8091725C; -static f32 D_80917260; -static s8 D_80917264; -static s16 D_80917266; -static u8 D_80917268; -static f32 D_8091726C; -static u8 D_80917270; -static s16 D_80917272; -static u8 D_80917274; -static Vec3f D_80917278; +f32 D_809101B0; +f32 D_809101B4; +s16 D_809101B8; +f32 D_809101BC; +f32 D_809101C0; +f32 D_809101C4; +f32 D_809101C8; +s16 D_809101CC; +f32 D_809101D0; +Vec3f sRodTipPos; +Vec3f sReelLinePos[LINE_SEG_COUNT]; +Vec3f sReelLineRot[LINE_SEG_COUNT]; +Vec3f sReelLineUnk[LINE_SEG_COUNT]; +Vec3f sLureHookRefPos[2]; +f32 sLureHookRotY[2]; +u8 D_80911E28; +Vec3f sSinkingLurePos[SINKING_LURE_SEG_COUNT]; +s16 D_80911F20; +f32 sProjectedW; +Vec3f sCameraEye; +Vec3f sCameraAt; +s16 sCameraId; +f32 D_80911F48; +f32 D_80911F4C; +f32 D_80911F50; +Vec3f sSinkingLureBasePos; +f32 D_80911F64; +s32 sRandSeed0; +s32 sRandSeed1; +s32 sRandSeed2; +FishingProp sPondProps[POND_PROP_COUNT]; +FishingGroupFish sGroupFishes[GROUP_FISH_COUNT]; +f32 sFishGroupAngle1; +f32 sFishGroupAngle2; +f32 sFishGroupAngle3; +FishingEffect sFishingEffects[EFFECT_COUNT]; +Vec3f sStreamSoundProjectedPos; +EnFishing* sFishingMain; +u8 D_809171C8; +u8 sLinkAge; +u8 D_809171CA; +u8 D_809171CB; +f32 D_809171CC; +u8 D_809171D0; +u8 D_809171D1; +u8 D_809171D2; +s16 D_809171D4; +u8 D_809171D6; +u16 D_809171D8; +u16 D_809171DA; +s8 D_809171DC; +Vec3f sOwnerHeadPos; +Vec3s sEffOwnerHatRot; +u8 D_809171F2; +s16 D_809171F4; +s16 D_809171F6; +EnFishing* sFishingHookedFish; +s16 D_809171FC; +s16 D_809171FE; +s16 D_80917200; +s16 D_80917202; +s16 D_80917204; +u8 D_80917206; +Vec3f sLurePos; +Vec3f D_80917218; +Vec3f sLureRot; +Vec3f D_80917238; +Vec3f D_80917248; +f32 D_80917254; +f32 D_80917258; +f32 D_8091725C; +f32 D_80917260; +s8 D_80917264; +s16 D_80917266; +u8 D_80917268; +f32 D_8091726C; +u8 D_80917270; +s16 D_80917272; +u8 D_80917274; +Vec3f D_80917278; const ActorInit En_Fishing_InitVars = { ACTOR_EN_FISHING, @@ -212,38 +212,38 @@ const ActorInit En_Fishing_InitVars = { (ActorFunc)EnFishing_DrawFish, }; -static f32 D_8090CCD0 = 0.0f; -static u8 D_8090CCD4 = 0; -static f32 D_8090CCD8 = 0.0f; -static Vec3f D_8090CCDC = { 0.0f, 0.0f, 0.0f }; -static f32 D_8090CCE8 = 0.0f; -static u8 sSinkingLureLocation = 0; -static f32 D_8090CCF0 = 0.0f; -static u8 D_8090CCF4 = true; -static u16 D_8090CCF8 = 0; -static u8 D_8090CCFC = 0; -static s32 D_8090CD00 = 0; -static s16 D_8090CD04 = 0; -static u8 D_8090CD08 = 0; -static u8 D_8090CD0C = 0; -static u8 D_8090CD10 = 0; -static s16 D_8090CD14 = 0; -static Vec3f sFishMouthOffset = { 500.0f, 500.0f, 0.0f }; -static u8 D_8090CD24 = 0; -static f32 D_8090CD28 = 0; -static f32 D_8090CD2C = 0; -static f32 D_8090CD30 = 0.0f; -static f32 D_8090CD34 = 0.0f; -static f32 D_8090CD38 = 0.0f; -static f32 D_8090CD3C = 0.0f; -static f32 D_8090CD40 = 0.0f; -static s16 D_8090CD44 = 0; -static s16 D_8090CD48 = 0; -static u8 D_8090CD4C = 0; -static u8 D_8090CD50 = 0; -static u8 D_8090CD54 = 0; +f32 D_8090CCD0 = 0.0f; +u8 D_8090CCD4 = 0; +f32 D_8090CCD8 = 0.0f; +Vec3f D_8090CCDC = { 0.0f, 0.0f, 0.0f }; +f32 D_8090CCE8 = 0.0f; +u8 sSinkingLureLocation = 0; +f32 D_8090CCF0 = 0.0f; +u8 D_8090CCF4 = true; +u16 D_8090CCF8 = 0; +u8 D_8090CCFC = 0; +s32 D_8090CD00 = 0; +s16 D_8090CD04 = 0; +u8 D_8090CD08 = 0; +u8 D_8090CD0C = 0; +u8 D_8090CD10 = 0; +s16 D_8090CD14 = 0; +Vec3f sFishMouthOffset = { 500.0f, 500.0f, 0.0f }; +u8 D_8090CD24 = 0; +f32 D_8090CD28 = 0; +f32 D_8090CD2C = 0; +f32 D_8090CD30 = 0.0f; +f32 D_8090CD34 = 0.0f; +f32 D_8090CD38 = 0.0f; +f32 D_8090CD3C = 0.0f; +f32 D_8090CD40 = 0.0f; +s16 D_8090CD44 = 0; +s16 D_8090CD48 = 0; +u8 D_8090CD4C = 0; +u8 D_8090CD50 = 0; +u8 D_8090CD54 = 0; -static ColliderJntSphElementInit sJntSphElementsInit[12] = { +static ColliderJntSphElementInit sJntSphElementsInit[] = { { { ELEMTYPE_UNK0, @@ -387,13 +387,13 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 12, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; -static u8 D_8090CF18 = 0; +u8 D_8090CF18 = 0; static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; -static Vec3f D_8090CF28 = { 0.0f, 0.0f, 2000.0f }; // Unused +Vec3f D_8090CF28 = { 0.0f, 0.0f, 2000.0f }; // Unused void EnFishing_SetColliderElement(s32 index, ColliderJntSph* collider, Vec3f* pos, f32 scale) { collider->elements[index].dim.worldSphere.center.x = pos->x; @@ -580,7 +580,7 @@ void EnFishing_SpawnRainDrop(FishingEffect* effect, Vec3f* pos, Vec3f* rot) { } } -static FishingPropInit sPondPropInits[POND_PROP_COUNT + 1] = { +FishingPropInit sPondPropInits[POND_PROP_COUNT + 1] = { { FS_PROP_ROCK, { 529, -53, -498 } }, { FS_PROP_ROCK, { 461, -66, -480 } }, { FS_PROP_ROCK, { 398, -73, -474 } }, @@ -780,7 +780,7 @@ void EnFishing_InitPondProps(EnFishing* this, GlobalContext* globalCtx) { } } -static FishingFishInit sFishInits[] = { +FishingFishInit sFishInits[] = { { 0, { 666, -45, 354 }, 38, 0.1f }, { 0, { 681, -45, 240 }, 36, 0.1f }, { 0, { 670, -45, 90 }, 41, 0.05f }, { 0, { 615, -45, -450 }, 35, 0.2f }, { 0, { 500, -45, -420 }, 39, 0.1f }, { 0, { 420, -45, -550 }, 44, 0.05f }, { 0, { -264, -45, -640 }, 40, 0.1f }, { 0, { -470, -45, -540 }, 34, 0.2f }, { 0, { -557, -45, -430 }, 54, 0.01f }, @@ -802,7 +802,7 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_ProcessInitChain(thisx, sInitChain); ActorShape_Init(&thisx->shape, 0.0f, NULL, 0.0f); - sLinkAge = gSaveContext.linkAge; + sLinkAge = gSaveContext.save.linkAge; if (thisx->params < 100) { s16 i; @@ -834,7 +834,7 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { if (sLinkAge != 1) { // HIGH_SCORE(HS_FISHING) from OoT - if (gSaveContext.unk_EE4 & 0x1000) { + if (gSaveContext.save.unk_EE4 & 0x1000) { D_8090CD08 = 0; } else { D_8090CD08 = 1; @@ -852,18 +852,18 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { Audio_QueueSeqCmd(0x100100FF); if (sLinkAge == 1) { - if (gSaveContext.unk_EE4 & 0x7F) { - D_809171CC = gSaveContext.unk_EE4 & 0x7F; + if (gSaveContext.save.unk_EE4 & 0x7F) { + D_809171CC = gSaveContext.save.unk_EE4 & 0x7F; } else { D_809171CC = 40.0f; } - } else if (gSaveContext.unk_EE4 & 0x7F000000) { - D_809171CC = (gSaveContext.unk_EE4 & 0x7F000000) >> 0x18; + } else if (gSaveContext.save.unk_EE4 & 0x7F000000) { + D_809171CC = (gSaveContext.save.unk_EE4 & 0x7F000000) >> 0x18; } else { D_809171CC = 45.0f; } - D_809171D1 = (gSaveContext.unk_EE4 & 0xFF0000) >> 0x10; + D_809171D1 = (gSaveContext.save.unk_EE4 & 0xFF0000) >> 0x10; if ((D_809171D1 & 7) == 7) { globalCtx->roomCtx.unk7A[0] = 90; D_809171CA = 1; @@ -1700,7 +1700,7 @@ void EnFishing_UpdateSinkingLure(GlobalContext* globalCtx) { } } -static f32 sSinkingLureSizes[] = { +f32 sSinkingLureSizes[] = { 1.0f, 1.5f, 1.8f, 2.0f, 1.8f, 1.6f, 1.4f, 1.2f, 1.0f, 1.0f, 0.9f, 0.85f, 0.8f, 0.7f, 0.8f, 1.0f, 1.2f, 1.1f, 1.0f, 0.8f, }; @@ -1905,18 +1905,18 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* CLOSE_DISPS(globalCtx->state.gfxCtx); } -static f32 sRodScales[22] = { +f32 sRodScales[22] = { 1.0f, 1.0f, 1.0f, 0.9625f, 0.925f, 0.8875f, 0.85f, 0.8125f, 0.775f, 0.73749995f, 0.7f, 0.6625f, 0.625f, 0.5875f, 0.54999995f, 0.5125f, 0.47499996f, 0.4375f, 0.39999998f, 0.36249995f, 0.325f, 0.28749996f, }; -static f32 sRodBendRatios[22] = { +f32 sRodBendRatios[22] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.06f, 0.12f, 0.18f, 0.24f, 0.30f, 0.36f, 0.42f, 0.48f, 0.54f, 0.60f, 0.60f, 0.5142f, 0.4285f, 0.3428f, 0.2571f, 0.1714f, 0.0857f, }; -static Vec3f sRodTipOffset = { 0.0f, 0.0f, 0.0f }; +Vec3f sRodTipOffset = { 0.0f, 0.0f, 0.0f }; void EnFishing_DrawRod(GlobalContext* globalCtx) { s16 i; @@ -2057,7 +2057,7 @@ void EnFishing_DrawRod(GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -static Vec3f D_8090D614 = { 0.0f, 0.0f, 0.0f }; +Vec3f D_8090D614 = { 0.0f, 0.0f, 0.0f }; void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { f32 spE4; @@ -2801,8 +2801,8 @@ void func_80903C60(EnFishing* this, u8 arg1) { void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { if (sLinkAge == 1) { - if (gSaveContext.unk_EE4 & 0x7F) { - if (gSaveContext.unk_EE4 & 0x80) { + if (gSaveContext.save.unk_EE4 & 0x7F) { + if (gSaveContext.save.unk_EE4 & 0x80) { this->actor.textId = 0x40B1; } else { this->actor.textId = 0x4089; @@ -2810,8 +2810,8 @@ void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x40AE; } - } else if (gSaveContext.unk_EE4 & 0x7F000000) { - if (gSaveContext.unk_EE4 & 0x80000000) { + } else if (gSaveContext.save.unk_EE4 & 0x7F000000) { + if (gSaveContext.save.unk_EE4 & 0x80000000) { this->actor.textId = 0x40B1; } else { this->actor.textId = 0x4089; @@ -3065,11 +3065,11 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } if (Message_GetState(&globalCtx->msgCtx) == 0) { - if ((gSaveContext.time >= 0xC000) && (gSaveContext.time <= 0xC01B)) { + if ((gSaveContext.save.time >= CLOCK_TIME(18, 0)) && (gSaveContext.save.time <= 0xC01B)) { this->unk_150 = 7; this->unk_172[3] = Rand_ZeroFloat(150.0f) + 200.0f; } - if ((gSaveContext.time >= 0x3AAA) && (gSaveContext.time <= 0x3AC5)) { + if ((gSaveContext.save.time >= CLOCK_TIME(5, 30)) && (gSaveContext.save.time <= 0x3AC5)) { this->unk_150 = 7; this->unk_172[3] = Rand_ZeroFloat(150.0f) + 200.0f; } @@ -3313,9 +3313,9 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { multiplier = 1.0f; } - if ((gSaveContext.time >= 0xB555) && (gSaveContext.time <= 0xCAAA)) { + if ((gSaveContext.save.time >= 0xB555) && (gSaveContext.save.time <= 0xCAAA)) { multiplier *= 1.75f; - } else if ((gSaveContext.time >= 0x3555) && (gSaveContext.time <= 0x4AAA)) { + } else if ((gSaveContext.save.time >= 0x3555) && (gSaveContext.save.time <= 0x4AAA)) { multiplier *= 1.5f; } else if (D_809171CA != 0) { multiplier *= 1.5f; @@ -3752,8 +3752,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { if ((D_80917272 == 0) && (D_80917274 == 0)) { // Assignment of OoT's D_80B7E086 here removed in MM - if (((sLinkAge == 1) && (gSaveContext.unk_EE4 & 0x400)) || - ((sLinkAge != 1) && (gSaveContext.unk_EE4 & 0x800))) { + if (((sLinkAge == 1) && (gSaveContext.save.unk_EE4 & 0x400)) || + ((sLinkAge != 1) && (gSaveContext.save.unk_EE4 & 0x800))) { // Assignment of OoT's D_80B7A67C here removed in MM, this is now an empty branch } } else { @@ -4685,14 +4685,14 @@ void EnFishing_DrawGroupFishes(GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -static u16 D_8090D638[] = { 0x4096, 0x408D, 0x408E, 0x408F, 0x4094, 0x4095 }; +u16 D_8090D638[] = { 0x4096, 0x408D, 0x408E, 0x408F, 0x4094, 0x4095 }; void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { switch (this->unk_154) { case 0: if (D_809171FC == 0) { if (sLinkAge != 1) { - if ((gSaveContext.unk_EE4 & 0x100) && !(gSaveContext.unk_EE4 & 0x200)) { + if ((gSaveContext.save.unk_EE4 & 0x100) && !(gSaveContext.save.unk_EE4 & 0x200)) { this->actor.textId = 0x4093; } else { this->actor.textId = 0x407B; @@ -4710,9 +4710,9 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { if (D_809171FC == 0) { this->unk_154 = 1; if (sLinkAge != 1) { - gSaveContext.unk_EE4 |= 0x200; + gSaveContext.save.unk_EE4 |= 0x200; } else { - gSaveContext.unk_EE4 |= 0x100; + gSaveContext.save.unk_EE4 |= 0x100; } } else { this->unk_154 = 10; @@ -4728,7 +4728,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (gSaveContext.rupees >= 20) { + if (gSaveContext.save.playerData.rupees >= 20) { func_801159EC(-20); if (func_8013EE04() == 0) { this->actor.textId = 0x407C; @@ -4795,8 +4795,8 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { D_8090CD04 = 20; this->unk_154 = 0; - if ((gSaveContext.unk_EE4 & 0xFF0000) < 0xFF0000) { - gSaveContext.unk_EE4 += 0x10000; + if ((gSaveContext.save.unk_EE4 & 0xFF0000) < 0xFF0000) { + gSaveContext.save.unk_EE4 += 0x10000; } } break; @@ -4904,30 +4904,29 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { if (sLinkAge == 1) { f32 temp; - gSaveContext.unk_EE4 &= 0xFFFFFF00; - gSaveContext.unk_EE4 |= ((s16)D_809171CC & 0x7F); - - temp = (gSaveContext.unk_EE4 & 0x7F000000) >> 0x18; + gSaveContext.save.unk_EE4 &= 0xFFFFFF00; + gSaveContext.save.unk_EE4 |= ((s16)D_809171CC & 0x7F); + temp = (gSaveContext.save.unk_EE4 & 0x7F000000) >> 0x18; if (temp < D_809171CC) { - gSaveContext.unk_EE4 &= 0xFFFFFF; - gSaveContext.unk_EE4 |= ((s16)D_809171CC & 0x7F) << 0x18; + gSaveContext.save.unk_EE4 &= 0xFFFFFF; + gSaveContext.save.unk_EE4 |= ((s16)D_809171CC & 0x7F) << 0x18; if (D_809171D2 == 2) { - gSaveContext.unk_EE4 |= 0x80000000; + gSaveContext.save.unk_EE4 |= 0x80000000; } } if (D_809171D2 == 2) { - gSaveContext.unk_EE4 |= 0x80; + gSaveContext.save.unk_EE4 |= 0x80; this->unk_154 = 0; break; } } else { - gSaveContext.unk_EE4 &= 0xFFFFFF; - gSaveContext.unk_EE4 |= ((s16)D_809171CC & 0x7F) << 0x18; + gSaveContext.save.unk_EE4 &= 0xFFFFFF; + gSaveContext.save.unk_EE4 |= ((s16)D_809171CC & 0x7F) << 0x18; if (D_809171D2 == 2) { - gSaveContext.unk_EE4 |= 0x80000000; + gSaveContext.save.unk_EE4 |= 0x80000000; this->unk_154 = 0; break; } @@ -4944,14 +4943,14 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { } if (sLinkAge == 1) { - if ((D_809171CC >= 50.0f) && !(gSaveContext.unk_EE4 & 0x400)) { - gSaveContext.unk_EE4 |= 0x400; + if ((D_809171CC >= 50.0f) && !(gSaveContext.save.unk_EE4 & 0x400)) { + gSaveContext.save.unk_EE4 |= 0x400; getItemId = GI_HEART_PIECE; sSinkingLureLocation = Rand_ZeroFloat(3.999f) + 1.0f; } } else { - if ((D_809171CC >= 60.0f) && !(gSaveContext.unk_EE4 & 0x800)) { - gSaveContext.unk_EE4 |= 0x800; + if ((D_809171CC >= 60.0f) && !(gSaveContext.save.unk_EE4 & 0x800)) { + gSaveContext.save.unk_EE4 |= 0x800; getItemId = GI_SCALE_GOLD; sSinkingLureLocation = Rand_ZeroFloat(3.999f) + 1.0f; } @@ -5029,11 +5028,11 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { } } -static s16 D_8090D644[] = { 0, 1, 2, 2, 1 }; +s16 D_8090D644[] = { 0, 1, 2, 2, 1 }; -static Vec3f sStreamSoundPos = { 670.0f, 0.0f, -600.0f }; +Vec3f sStreamSoundPos = { 670.0f, 0.0f, -600.0f }; -static Vec3s sSinkingLureLocationPos[] = { +Vec3s sSinkingLureLocationPos[] = { { -364, -30, -269 }, { 1129, 3, -855 }, { -480, 0, -1055 }, @@ -5114,9 +5113,9 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { } if (D_8090CD08 == 0) { - gSaveContext.unk_EE4 |= 0x1000; + gSaveContext.save.unk_EE4 |= 0x1000; } else if (D_8090CD08 == 1) { - gSaveContext.unk_EE4 &= ~0x1000; + gSaveContext.save.unk_EE4 &= ~0x1000; } if (D_8090CCFC != 0) { @@ -5579,7 +5578,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { Audio_PlaySfxAtPos(&sStreamSoundProjectedPos, NA_SE_EV_WATER_WALL - SFX_FLAG); - if (gSaveContext.language == 0) { // Added in MM + if (gSaveContext.options.language == 0) { // Added in MM gSaveContext.minigameScore = D_8090CCF8; } else { gSaveContext.minigameScore = (SQ((f32)D_8090CCF8) * 0.0036f) + 0.5f; @@ -5613,10 +5612,10 @@ void EnFishing_OwnerPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** } } -static UNK_TYPE sFishingOwnerEyeTexs[] = { - &gFishingOwnerEyeOpenTex, - &gFishingOwnerEyeHalfTex, - &gFishingOwnerEyeClosedTex, +TexturePtr sFishingOwnerEyeTexs[] = { + gFishingOwnerEyeOpenTex, + gFishingOwnerEyeHalfTex, + gFishingOwnerEyeClosedTex, }; void EnFishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index 12ac7cdf4..ce5928004 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -721,7 +721,7 @@ void func_808D217C(EnFloormas* this, Player* player) { this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; func_808D08D0(this); - playerForm = gSaveContext.playerForm; + playerForm = gSaveContext.save.playerForm; ptr = &D_808D3900[playerForm]; this->actor.home.pos.x = ptr->z * Math_SinS(this->actor.shape.rot.y); this->actor.home.pos.y = CLAMP(-this->actor.playerHeightRel, ptr->x, ptr->y); diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index 2cef9e38e..a69730bed 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -153,7 +153,7 @@ u16 EnFsn_GetWelcome(GlobalContext* globalCtx) { void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { switch (this->textId) { case 0: - if (!(gSaveContext.weekEventReg[80] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[80] & 0x10)) { this->textId = 0x29E0; break; } else { @@ -166,7 +166,7 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { this->flags |= ENFSN_GIVE_ITEM; this->flags |= ENFSN_GAVE_LETTER_TO_MAMA; this->getItemId = GI_LETTER_TO_MAMA; - gSaveContext.weekEventReg[80] |= 0x10; + gSaveContext.save.weekEventReg[80] |= 0x10; this->textId = 0x29F1; break; } else { @@ -186,7 +186,7 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { this->flags |= ENFSN_GIVE_ITEM; this->flags |= ENFSN_GAVE_LETTER_TO_MAMA; this->getItemId = GI_LETTER_TO_MAMA; - gSaveContext.weekEventReg[80] |= 0x10; + gSaveContext.save.weekEventReg[80] |= 0x10; this->textId = 0x29F1; break; case 0x29F1: @@ -301,8 +301,8 @@ void EnFsn_CursorLeftRight(EnFsn* this) { } s16 EnFsn_GetThirdDayItemId(void) { - if (!(gSaveContext.weekEventReg[33] & 4) && CURRENT_DAY == 3) { - if (!(gSaveContext.weekEventReg[33] & 8) && !(gSaveContext.weekEventReg[79] & 0x40)) { + if (!(gSaveContext.save.weekEventReg[33] & 4) && CURRENT_DAY == 3) { + if (!(gSaveContext.save.weekEventReg[33] & 8) && !(gSaveContext.save.weekEventReg[79] & 0x40)) { return SI_BOMB_BAG_30_1; } return SI_MASK_ALL_NIGHT; @@ -328,22 +328,23 @@ s16 EnFsn_GetStolenItemId(u32 stolenItem) { s32 EnFsn_HasItemsToSell(void) { if (CURRENT_DAY != 3) { - if (((gSaveContext.stolenItems & 0xFF000000) >> 0x18) || ((gSaveContext.stolenItems & 0xFF0000) >> 0x10)) { - return true; - } - return false; - } else { - if (((gSaveContext.stolenItems & 0xFF000000) >> 0x18) || ((gSaveContext.stolenItems & 0xFF0000) >> 0x10) || - !(gSaveContext.weekEventReg[33] & 4)) { + if ((STOLEN_ITEM_1 != STOLEN_ITEM_NONE) || (STOLEN_ITEM_2 != STOLEN_ITEM_NONE)) { return true; } return false; } + + if ((STOLEN_ITEM_1 != STOLEN_ITEM_NONE) || (STOLEN_ITEM_2 != STOLEN_ITEM_NONE) || + !(gSaveContext.save.weekEventReg[33] & 4)) { + return true; + } + + return false; } void EnFsn_GetShopItemIds(EnFsn* this) { - u32 stolenItem1 = (gSaveContext.stolenItems & 0xFF000000) >> 0x18; - u32 stolenItem2 = (gSaveContext.stolenItems & 0xFF0000) >> 0x10; + u32 stolenItem1 = STOLEN_ITEM_1; + u32 stolenItem2 = STOLEN_ITEM_2; s16 itemId; this->stolenItem1 = this->stolenItem2 = 0; @@ -440,9 +441,9 @@ s32 EnFsn_FacingShopkeeperDialogResult(EnFsn* this, GlobalContext* globalCtx) { func_8019F208(); if (CURRENT_DAY != 3) { this->actor.textId = 0x29FB; - } else if (gSaveContext.weekEventReg[33] & 4) { + } else if (gSaveContext.save.weekEventReg[33] & 4) { this->actor.textId = 0x29FF; - } else if (!(gSaveContext.weekEventReg[33] & 8) && !(gSaveContext.weekEventReg[79] & 0x40)) { + } else if (!(gSaveContext.save.weekEventReg[33] & 8) && !(gSaveContext.save.weekEventReg[79] & 0x40)) { this->actor.textId = 0x29D7; } else { this->actor.textId = 0x29D8; @@ -860,9 +861,10 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); break; case 0x29D2: - if (gSaveContext.weekEventReg[33] & 4) { + if (gSaveContext.save.weekEventReg[33] & 4) { this->actor.textId = 0x2A01; - } else if (!(gSaveContext.weekEventReg[33] & 8) && !(gSaveContext.weekEventReg[79] & 0x40)) { + } else if (!(gSaveContext.save.weekEventReg[33] & 8) && + !(gSaveContext.save.weekEventReg[79] & 0x40)) { this->actor.textId = 0x29D3; } else { this->actor.textId = 0x29D4; @@ -923,7 +925,7 @@ void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx) { if (player->heldItemButton == 0) { buttonItem = CUR_FORM_EQUIP(player->heldItemButton); } else { - buttonItem = gSaveContext.equips.buttonItems[0][player->heldItemButton]; + buttonItem = gSaveContext.save.equips.buttonItems[0][player->heldItemButton]; } this->price = (buttonItem < ITEM_MOON_TEAR) ? gItemPrices[buttonItem] : 0; if (this->price > 0) { @@ -1147,7 +1149,7 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { switch (item->canBuyFunc(globalCtx, item)) { case CANBUY_RESULT_SUCCESS_2: func_8019F208(); - gSaveContext.weekEventReg[33] |= 4; + gSaveContext.save.weekEventReg[33] |= 4; case CANBUY_RESULT_SUCCESS_1: if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); @@ -1165,9 +1167,9 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { item = this->items[this->cursorIdx]; item->boughtFunc(globalCtx, item); if (this->stolenItem1 == this->cursorIdx) { - gSaveContext.stolenItems &= ~0xFF000000; + SET_STOLEN_ITEM_1(STOLEN_ITEM_NONE); } else if (this->stolenItem2 == this->cursorIdx) { - gSaveContext.stolenItems &= ~0xFF0000; + SET_STOLEN_ITEM_2(STOLEN_ITEM_NONE); } this->numSellingItems--; this->itemIds[this->cursorIdx] = -1; @@ -1416,7 +1418,7 @@ void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx) { EnFsn_GetCutscenes(this); EnFsn_InitShop(this, globalCtx); } else { - if ((gSaveContext.weekEventReg[33] & 8) || (gSaveContext.weekEventReg[79] & 0x40)) { + if ((gSaveContext.save.weekEventReg[33] & 8) || (gSaveContext.save.weekEventReg[79] & 0x40)) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index 99e32fee8..ba83b5f23 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -112,7 +112,7 @@ void func_809616E0(EnFu* this, GlobalContext* globalCtx) { s16 spA0 = false; Vec3f sp94; - if ((gSaveContext.playerForm == PLAYER_FORM_DEKU) && (CURRENT_DAY == 3)) { + if ((gSaveContext.save.playerForm == PLAYER_FORM_DEKU) && (CURRENT_DAY == 3)) { spA0 = true; } this->unk_54C = 0; @@ -230,8 +230,8 @@ void EnFu_Init(Actor* thisx, GlobalContext* globalCtx) { void EnFu_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnFu* this = THIS; - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[8] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[8] &= (u8)~1; Collider_DestroyCylinder(globalCtx, &this->collider); } @@ -386,12 +386,12 @@ void func_80962340(EnFu* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->unk_54A == 2) { if (this->unk_552 == 0x287D) { - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { Message_StartTextbox(globalCtx, 0x287E, &this->actor); this->unk_552 = 0x287E; - } else if ((CURRENT_DAY == 3) && (gSaveContext.weekEventReg[22] & 0x10) && - (gSaveContext.weekEventReg[22] & 0x20)) { - if ((gSaveContext.weekEventReg[22] & 0x40)) { + } else if ((CURRENT_DAY == 3) && (gSaveContext.save.weekEventReg[22] & 0x10) && + (gSaveContext.save.weekEventReg[22] & 0x20)) { + if ((gSaveContext.save.weekEventReg[22] & 0x40)) { Message_StartTextbox(globalCtx, 0x2883, &this->actor); this->unk_552 = 0x2883; } else { @@ -429,7 +429,7 @@ void func_80962588(EnFu* this, GlobalContext* globalCtx) { if (Message_ShouldAdvance(globalCtx) && (this->unk_552 == 0x2871)) { if (1) {} if (globalCtx->msgCtx.choiceIndex == 0) { - if (gSaveContext.rupees >= 10) { + if (gSaveContext.save.playerData.rupees >= 10) { func_8019F208(); func_801159EC(-10); func_80963DE4(this, globalCtx); @@ -532,8 +532,8 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { break; case 0x287D: - gSaveContext.weekEventReg[63] |= 1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; func_801477B4(globalCtx); player->stateFlags1 |= 0x20; this->unk_53C = 0; @@ -605,8 +605,8 @@ void func_809628D0(EnFu* this, GlobalContext* globalCtx) { case 0x2884: case 0x2887: case 0x288A: - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; func_809622FC(this); break; @@ -652,10 +652,10 @@ void func_80962A10(EnFu* this, GlobalContext* globalCtx) { this->unk_546 = 1; } - if ((gSaveContext.playerForm == PLAYER_FORM_DEKU) && gSaveContext.magicAcquired) { + if ((gSaveContext.save.playerForm == PLAYER_FORM_DEKU) && gSaveContext.save.playerData.magicAcquired) { s16 temp = gSaveContext.unk_3F30; - Parameter_AddMagic(globalCtx, temp + (gSaveContext.doubleMagic * 48) + 48); + Parameter_AddMagic(globalCtx, temp + (gSaveContext.save.playerData.doubleMagic * 48) + 48); } func_80962F10(this); @@ -739,7 +739,7 @@ void func_80962EBC(EnFu* this, GlobalContext* globalCtx) { void func_80962F10(EnFu* this) { this->unk_548 = 0; this->actor.flags &= ~ACTOR_FLAG_1; - gSaveContext.weekEventReg[8] |= 1; + gSaveContext.save.weekEventReg[8] |= 1; this->actionFunc = func_80962F4C; } @@ -749,7 +749,7 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { switch (this->unk_542) { case 0: - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { player->stateFlags3 |= 0x400; } break; @@ -822,11 +822,11 @@ void func_8096326C(EnFu* this, GlobalContext* globalCtx) { } void func_809632D0(EnFu* this) { - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { Interface_ChangeAlpha(50); } - gSaveContext.weekEventReg[8] &= (u8)~1; + gSaveContext.save.weekEventReg[8] &= (u8)~1; if (this->unk_2D4 != NULL) { BgFuMizu* mizu = this->unk_2D4; @@ -879,7 +879,7 @@ void func_80963560(EnFu* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; func_80963610(this); - } else if ((this->unk_552 == 0x2880) && !(gSaveContext.weekEventReg[22] & 0x80)) { + } else if ((this->unk_552 == 0x2880) && !(gSaveContext.save.weekEventReg[22] & 0x80)) { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); @@ -896,13 +896,13 @@ void func_80963630(EnFu* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if ((gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20) && (CURRENT_DAY == 3) && - (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { - if (gSaveContext.weekEventReg[22] & 0x40) { + if ((gSaveContext.save.weekEventReg[22] & 0x10) && (gSaveContext.save.weekEventReg[22] & 0x20) && + (CURRENT_DAY == 3) && (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { + if (gSaveContext.save.weekEventReg[22] & 0x40) { Message_StartTextbox(globalCtx, 0x2884, &this->actor); this->unk_552 = 0x2884; - } else if (!(gSaveContext.weekEventReg[22] & 0x80)) { - gSaveContext.weekEventReg[22] |= 0x80; + } else if (!(gSaveContext.save.weekEventReg[22] & 0x80)) { + gSaveContext.save.weekEventReg[22] |= 0x80; Message_StartTextbox(globalCtx, 0x2882, &this->actor); this->unk_552 = 0x2882; } else { @@ -918,18 +918,18 @@ void func_80963630(EnFu* this, GlobalContext* globalCtx) { this->actor.child->freezeTimer = 0; func_809628BC(this); - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { switch (CURRENT_DAY) { case 1: - gSaveContext.weekEventReg[22] |= 0x10; + gSaveContext.save.weekEventReg[22] |= 0x10; break; case 2: - gSaveContext.weekEventReg[22] |= 0x20; + gSaveContext.save.weekEventReg[22] |= 0x20; break; case 3: - gSaveContext.weekEventReg[22] |= 0x40; + gSaveContext.save.weekEventReg[22] |= 0x40; break; } } @@ -1016,11 +1016,11 @@ s32 func_809638F8(GlobalContext* globalCtx) { void func_809639D0(EnFu* this, GlobalContext* globalCtx) { switch (CURRENT_DAY) { case 1: - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { Message_StartTextbox(globalCtx, 0x2853, &this->actor); this->unk_552 = 0x2853; - } else if (gSaveContext.weekEventReg[22] & 0x10) { + } else if (gSaveContext.save.weekEventReg[22] & 0x10) { Message_StartTextbox(globalCtx, 0x284D, &this->actor); this->unk_552 = 0x284D; } else if (this->unk_53E == 1) { @@ -1038,13 +1038,13 @@ void func_809639D0(EnFu* this, GlobalContext* globalCtx) { break; case 2: - if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { Message_StartTextbox(globalCtx, 0x286F, &this->actor); this->unk_552 = 0x286F; } else if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { Message_StartTextbox(globalCtx, 0x2853, &this->actor); this->unk_552 = 0x2853; - } else if (!(gSaveContext.weekEventReg[22] & 0x10)) { + } else if (!(gSaveContext.save.weekEventReg[22] & 0x10)) { if (this->unk_53E == 1) { Message_StartTextbox(globalCtx, 0x285B, &this->actor); this->unk_552 = 0x285B; @@ -1053,7 +1053,7 @@ void func_809639D0(EnFu* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x285D, &this->actor); this->unk_552 = 0x285D; } - } else if (gSaveContext.weekEventReg[22] & 0x20) { + } else if (gSaveContext.save.weekEventReg[22] & 0x20) { Message_StartTextbox(globalCtx, 0x2855, &this->actor); this->unk_552 = 0x2855; } else if (this->unk_53E == 1) { @@ -1067,8 +1067,8 @@ void func_809639D0(EnFu* this, GlobalContext* globalCtx) { break; case 3: - if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { func_80963EAC(this, globalCtx); } else { Message_StartTextbox(globalCtx, 0x2841, &this->actor); @@ -1077,15 +1077,15 @@ void func_809639D0(EnFu* this, GlobalContext* globalCtx) { } else if (CUR_UPG_VALUE(UPG_QUIVER) == 0) { Message_StartTextbox(globalCtx, 0x284B, &this->actor); this->unk_552 = 0x284B; - } else if (gSaveContext.weekEventReg[22] & 0x40) { - if ((gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20)) { + } else if (gSaveContext.save.weekEventReg[22] & 0x40) { + if ((gSaveContext.save.weekEventReg[22] & 0x10) && (gSaveContext.save.weekEventReg[22] & 0x20)) { Message_StartTextbox(globalCtx, 0x285F, &this->actor); this->unk_552 = 0x285F; } else { Message_StartTextbox(globalCtx, 0x2861, &this->actor); this->unk_552 = 0x2861; } - } else if ((gSaveContext.weekEventReg[22] & 0x10) && (gSaveContext.weekEventReg[22] & 0x20)) { + } else if ((gSaveContext.save.weekEventReg[22] & 0x10) && (gSaveContext.save.weekEventReg[22] & 0x20)) { if (this->unk_53E == 1) { Message_StartTextbox(globalCtx, 0x2863, &this->actor); this->unk_552 = 0x2863; @@ -1094,7 +1094,7 @@ void func_809639D0(EnFu* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x2865, &this->actor); this->unk_552 = 0x2865; } - } else if ((gSaveContext.weekEventReg[22] & 0x10) || (gSaveContext.weekEventReg[22] & 0x20)) { + } else if ((gSaveContext.save.weekEventReg[22] & 0x10) || (gSaveContext.save.weekEventReg[22] & 0x20)) { if (this->unk_53E == 1) { Message_StartTextbox(globalCtx, 0x2867, &this->actor); this->unk_552 = 0x2867; @@ -1118,7 +1118,7 @@ void func_809639D0(EnFu* this, GlobalContext* globalCtx) { void func_80963DE4(EnFu* this, GlobalContext* globalCtx) { switch (this->unk_542) { case 0: - if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { Message_StartTextbox(globalCtx, 0x2875, &this->actor); this->unk_552 = 0x2875; } else { @@ -1140,7 +1140,7 @@ void func_80963DE4(EnFu* this, GlobalContext* globalCtx) { } void func_80963EAC(EnFu* this, GlobalContext* globalCtx) { - if (gSaveContext.magicAcquired) { + if (gSaveContext.save.playerData.magicAcquired) { if (this->unk_540 == 1) { Message_StartTextbox(globalCtx, 0x2847, &this->actor); this->unk_552 = 0x2847; diff --git a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c index 6923c6679..1d9175b49 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c @@ -207,7 +207,7 @@ void EnGakufu_GiveReward(EnGakufu* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_CORRECT_CHIME); - hour = gSaveContext.time * (24.0f / 0x10000); + hour = gSaveContext.save.time * (24.0f / 0x10000); for (i = 0; i < 3; i++) { Item_DropCollectible(globalCtx, &sRewardDropsSpawnTerminaFieldPos, sRewardDrops[i + sRewardDropsIndex[hour]]); } 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 b350aa76b..82010f193 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -120,8 +120,8 @@ s32 func_80B0F660(EnGb2* this, GlobalContext* globalCtx) { } void func_80B0F6DC(EnGb2* this) { - if (!(gSaveContext.weekEventReg[54] & 0x20)) { - gSaveContext.weekEventReg[54] |= 0x20; + if (!(gSaveContext.save.weekEventReg[54] & 0x20)) { + gSaveContext.save.weekEventReg[54] |= 0x20; this->unk_26E = 0x14D0; } else { this->unk_26E = 0x14D1; @@ -163,7 +163,7 @@ u16 func_80B0F7FC(EnGb2* this) { return 0x14E4; } - if (gSaveContext.health > 48) { + if (gSaveContext.save.playerData.health > 48) { return 0x14D2; } @@ -171,7 +171,7 @@ u16 func_80B0F7FC(EnGb2* this) { return 0x14D3; case 0x14E4: - if (gSaveContext.health > 48) { + if (gSaveContext.save.playerData.health > 48) { return 0x14D2; } @@ -208,7 +208,7 @@ u16 func_80B0F8F8(EnGb2* this) { case 0x14DE: this->unk_26C |= 2; - gSaveContext.weekEventReg[54] |= 0x80; + gSaveContext.save.weekEventReg[54] |= 0x80; return 0x14DF; case 0x14E1: @@ -226,7 +226,7 @@ u16 func_80B0F97C(EnGb2* this) { return 0x14F7; case 0x14F7: - gSaveContext.weekEventReg[76] |= 0x80; + gSaveContext.save.weekEventReg[76] |= 0x80; this->unk_26C |= 2; return 0x14F8; @@ -259,7 +259,7 @@ s32 func_80B0FA48(EnGb2* this, GlobalContext* globalCtx) { return false; case PLAYER_MASK_CAPTAIN: - if (!(gSaveContext.weekEventReg[80] & 0x40)) { + if (!(gSaveContext.save.weekEventReg[80] & 0x40)) { this->unk_26E = 0x14EB; return false; } @@ -267,7 +267,7 @@ s32 func_80B0FA48(EnGb2* this, GlobalContext* globalCtx) { return true; } - if (!(gSaveContext.weekEventReg[80] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[80] & 0x20)) { this->unk_26E = 0x14EF; return false; } else { @@ -407,7 +407,7 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { if (this->unk_26E == 0x14D5) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (gSaveContext.rupees < this->unk_288) { + if (gSaveContext.save.playerData.rupees < this->unk_288) { play_sound(NA_SE_SY_ERROR); this->unk_26E = 0x14D7; this->unk_26C |= 2; @@ -505,7 +505,7 @@ void func_80B10344(EnGb2* this, GlobalContext* globalCtx) { } } - if (gSaveContext.health < 49) { + if (gSaveContext.save.playerData.health < 49) { gSaveContext.unk_3DD0[1] = 5; gSaveContext.eventInf[4] |= 0x40; gSaveContext.eventInf[4] |= 0x20; @@ -575,7 +575,7 @@ void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { } else if ((temp_v0 == 4) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (gSaveContext.rupees < this->unk_288) { + if (gSaveContext.save.playerData.rupees < this->unk_288) { play_sound(NA_SE_SY_ERROR); this->unk_26E = 0x14D7; this->unk_26C |= 2; @@ -617,7 +617,7 @@ void func_80B10868(EnGb2* this, GlobalContext* globalCtx) { void func_80B10924(EnGb2* this, GlobalContext* globalCtx) { s32 sp24; - if (gSaveContext.weekEventReg[54] & 0x40) { + if (gSaveContext.save.weekEventReg[54] & 0x40) { sp24 = 5; } else { sp24 = 12; @@ -626,7 +626,7 @@ void func_80B10924(EnGb2* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; if (sp24 == 12) { - gSaveContext.weekEventReg[54] |= 0x40; + gSaveContext.save.weekEventReg[54] |= 0x40; } else { func_801159EC(50); } @@ -706,9 +706,9 @@ void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_10000; Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); if (this->unk_26E == 0x14EB) { - gSaveContext.weekEventReg[80] |= 0x40; + gSaveContext.save.weekEventReg[80] |= 0x40; } else if (this->unk_26E == 0x14EF) { - gSaveContext.weekEventReg[80] |= 0x20; + gSaveContext.save.weekEventReg[80] |= 0x20; } this->unk_26C &= ~0x20; this->unk_290 = 0; @@ -885,13 +885,13 @@ void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { switch (ENGB2_GET_7(&this->actor)) { case ENGB2_7_0: - if (gSaveContext.weekEventReg[54] & 0x80) { + if (gSaveContext.save.weekEventReg[54] & 0x80) { Actor_MarkForDeath(&this->actor); - } else if (gSaveContext.weekEventReg[52] & 0x20) { + } else if (gSaveContext.save.weekEventReg[52] & 0x20) { Actor_MarkForDeath(&this->actor); } - if (gSaveContext.entranceIndex == 0x9C10) { + if (gSaveContext.save.entranceIndex == 0x9C10) { func_800FE484(); this->actionFunc = func_80B10240; break; @@ -910,7 +910,7 @@ void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ENGB2_7_1: - if ((globalCtx->curSpawn == 1) || (gSaveContext.weekEventReg[80] & 0x80)) { + if ((globalCtx->curSpawn == 1) || (gSaveContext.save.weekEventReg[80] & 0x80)) { Actor_MarkForDeath(&this->actor); return; } @@ -940,7 +940,7 @@ void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - if (gSaveContext.weekEventReg[76] & 0x80) { + if (gSaveContext.save.weekEventReg[76] & 0x80) { this->actor.draw = NULL; this->unk_26C |= 0x100; this->actor.flags &= ~ACTOR_FLAG_1; 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 5bf1ca75e..d022058dd 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -452,7 +452,7 @@ void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { } } else { this->unk_230 &= ~4; - if (gSaveContext.weekEventReg[35] & 0x40) { + if (gSaveContext.save.weekEventReg[35] & 0x40) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_230 & 8)) { this->unk_496 = 0xD62; Message_StartTextbox(globalCtx, this->unk_496, &this->actor); @@ -463,7 +463,7 @@ void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { this->unk_230 |= 8; } } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_230 & 8)) { - gSaveContext.weekEventReg[35] |= 0x40; + gSaveContext.save.weekEventReg[35] |= 0x40; this->unk_496 = 0xD5E; this->unk_49A = this->unk_49C[0]; Message_StartTextbox(globalCtx, this->unk_496, &this->actor); @@ -655,7 +655,7 @@ void func_80BB2B1C(EnGeg* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCurrentIndex() != this->unk_49C[4]) { if (ActorCutscene_GetCanPlayNext(this->unk_498)) { - gSaveContext.weekEventReg[37] |= 8; + gSaveContext.save.weekEventReg[37] |= 8; if (this->actor.child != NULL) { Actor_MarkForDeath(this->actor.child); } @@ -797,7 +797,7 @@ void func_80BB31B8(EnGeg* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - gSaveContext.weekEventReg[61] |= 1; + gSaveContext.save.weekEventReg[61] |= 1; if (getItemId == GI_MASK_DON_GERO) { this->unk_230 |= 0x40; } @@ -860,7 +860,7 @@ void EnGeg_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad2; s32 sp34[] = { 0x3E, 0xF64 }; - if (gSaveContext.weekEventReg[61] & 1) { + if (gSaveContext.save.weekEventReg[61] & 1) { Actor_MarkForDeath(&this->actor); return; } 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 ab86e0161..d889bc7a0 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -129,7 +129,7 @@ s32 func_80B34FB4(EnGg* this, GlobalContext* globalCtx) { pitch = Math_Vec3f_Pitch(&sp34, &sp40); if ((this->actor.xzDistToPlayer < 250.0f) && (this->actor.xzDistToPlayer > 50.0f) && - (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (gSaveContext.weekEventReg[19] & 0x80))) { + (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (gSaveContext.save.weekEventReg[19] & 0x80))) { Math_SmoothStepToS(&this->unk_2E8, pitch, 4, 0x2AA8, 1); } else { Math_SmoothStepToS(&this->unk_2E8, 0, 4, 0x2AA8, 1); @@ -212,7 +212,7 @@ void func_80B352A4(EnGg* this, GlobalContext* globalCtx) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); break; } - gSaveContext.weekEventReg[19] |= 0x80; + gSaveContext.save.weekEventReg[19] |= 0x80; this->actionFunc = func_80B3556C; } else if ((this->unk_2E6 == 0) && ((this->actor.textId == 0xCED) || (this->actor.textId == 0xCEE))) { if (sp26 < (lastFrame - 1)) { @@ -225,7 +225,7 @@ void func_80B352A4(EnGg* this, GlobalContext* globalCtx) { } void func_80B35450(EnGg* this, GlobalContext* globalCtx) { - if ((gSaveContext.weekEventReg[91] & 0x10) && (globalCtx->csCtx.state == 0)) { + if ((gSaveContext.save.weekEventReg[91] & 0x10) && (globalCtx->csCtx.state == 0)) { func_80B359DC(this, globalCtx); } @@ -236,7 +236,7 @@ void func_80B35450(EnGg* this, GlobalContext* globalCtx) { this->unk_308 = 1; this->actionFunc = func_80B352A4; } else if ((this->actor.xzDistToPlayer < 200.0f) && (this->actor.xzDistToPlayer > 50.0f)) { - if (gSaveContext.weekEventReg[19] & 0x80) { + if (gSaveContext.save.weekEventReg[19] & 0x80) { func_800B863C(&this->actor, globalCtx); this->actor.textId = 0xCEE; } else if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_80) { @@ -400,8 +400,8 @@ void func_80B359DC(EnGg* this, GlobalContext* globalCtx) { if ((player->transformation == PLAYER_FORM_HUMAN) && (globalCtx->msgCtx.ocarinaMode == 3) && (globalCtx->msgCtx.unk1202E == 7)) { - if (!(gSaveContext.weekEventReg[19] & 0x80)) { - gSaveContext.weekEventReg[19] |= 0x80; + if (!(gSaveContext.save.weekEventReg[19] & 0x80)) { + gSaveContext.save.weekEventReg[19] |= 0x80; } this->unk_307 = true; } @@ -661,9 +661,9 @@ void EnGg_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - gSaveContext.weekEventReg[20] &= (u8)~4; - gSaveContext.weekEventReg[20] &= (u8)~8; - gSaveContext.weekEventReg[20] &= (u8)~0x10; + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; this->actor.flags &= ~ACTOR_FLAG_80; this->unk_310 = this->actor.home.pos.y; this->unk_2DC = this->actor.cutscene; @@ -691,7 +691,7 @@ void EnGg_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; } - if (gSaveContext.weekEventReg[19] & 0x80) { + if (gSaveContext.save.weekEventReg[19] & 0x80) { if (globalCtx->csCtx.state == 0) { this->actor.flags |= ACTOR_FLAG_1; } else { @@ -709,10 +709,10 @@ void EnGg_Update(Actor* thisx, GlobalContext* globalCtx) { func_80B35968(this, globalCtx); } - if (!(gSaveContext.weekEventReg[91] & 0x10) && - ((gSaveContext.weekEventReg[19] & 0x80) || CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || + if (!(gSaveContext.save.weekEventReg[91] & 0x10) && + ((gSaveContext.save.weekEventReg[19] & 0x80) || CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (this->unk_308 == 1))) { - gSaveContext.weekEventReg[91] |= 0x10; + gSaveContext.save.weekEventReg[91] |= 0x10; } this->actionFunc(this, globalCtx); @@ -790,7 +790,7 @@ void EnGg_Draw(Actor* thisx, GlobalContext* globalCtx) { this->unk_344.unk_38(&this->unk_344, globalCtx); } - if (gSaveContext.weekEventReg[19] & 0x80) { + if (gSaveContext.save.weekEventReg[19] & 0x80) { func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B36DFC[this->unk_2E2])); 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 f3ecfd9aa..7b019933f 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -214,17 +214,17 @@ void func_80B3B294(EnGg2* this, GlobalContext* globalCtx) { if (this->unk_2F1 == 0) { if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { - gSaveContext.weekEventReg[20] |= 4; - gSaveContext.weekEventReg[20] &= (u8)~8; - gSaveContext.weekEventReg[20] &= (u8)~0x10; + gSaveContext.save.weekEventReg[20] |= 4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; } else if (globalCtx->sceneNum == SCENE_17SETUGEN) { - gSaveContext.weekEventReg[20] &= (u8)~4; - gSaveContext.weekEventReg[20] |= 8; - gSaveContext.weekEventReg[20] &= (u8)~0x10; + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] |= 8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { - gSaveContext.weekEventReg[20] &= (u8)~4; - gSaveContext.weekEventReg[20] &= (u8)~8; - gSaveContext.weekEventReg[20] |= 0x10; + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] |= 0x10; } if (this->unk_1D8 != NULL) { @@ -240,17 +240,17 @@ void func_80B3B294(EnGg2* this, GlobalContext* globalCtx) { } else { this->unk_2F1 = 1; if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { - gSaveContext.weekEventReg[20] |= 4; - gSaveContext.weekEventReg[20] &= (u8)~8; - gSaveContext.weekEventReg[20] &= (u8)~0x10; + gSaveContext.save.weekEventReg[20] |= 4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; } else if (globalCtx->sceneNum == SCENE_17SETUGEN) { - gSaveContext.weekEventReg[20] &= (u8)~4; - gSaveContext.weekEventReg[20] |= 8; - gSaveContext.weekEventReg[20] &= (u8)~0x10; + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] |= 8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { - gSaveContext.weekEventReg[20] &= (u8)~4; - gSaveContext.weekEventReg[20] &= (u8)~8; - gSaveContext.weekEventReg[20] |= 0x10; + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] |= 0x10; } } } @@ -360,7 +360,7 @@ void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { return; } - if (gSaveContext.weekEventReg[91] & 0x10) { + if (gSaveContext.save.weekEventReg[91] & 0x10) { Actor_MarkForDeath(&this->actor); return; } @@ -381,16 +381,16 @@ void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk_2EA = 0; if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { - gSaveContext.weekEventReg[20] &= (u8)~4; - gSaveContext.weekEventReg[20] &= (u8)~8; - gSaveContext.weekEventReg[20] &= (u8)~0x10; + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; this->unk_2EE = 0; Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); this->actionFunc = func_80B3AFB0; } else if (globalCtx->sceneNum == SCENE_17SETUGEN) { - if ((gSaveContext.weekEventReg[20] & 4) && !(gSaveContext.weekEventReg[20] & 8) && - !(gSaveContext.weekEventReg[20] & 0x10)) { - gSaveContext.weekEventReg[20] &= (u8)~4; + if ((gSaveContext.save.weekEventReg[20] & 4) && !(gSaveContext.save.weekEventReg[20] & 8) && + !(gSaveContext.save.weekEventReg[20] & 0x10)) { + gSaveContext.save.weekEventReg[20] &= (u8)~4; this->unk_2EE = 8; Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); this->actionFunc = func_80B3B05C; @@ -398,9 +398,9 @@ void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_MarkForDeath(&this->actor); } } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { - if (!(gSaveContext.weekEventReg[20] & 4) && (gSaveContext.weekEventReg[20] & 8) && - !(gSaveContext.weekEventReg[20] & 0x10)) { - gSaveContext.weekEventReg[20] &= (u8)~8; + if (!(gSaveContext.save.weekEventReg[20] & 4) && (gSaveContext.save.weekEventReg[20] & 8) && + !(gSaveContext.save.weekEventReg[20] & 0x10)) { + gSaveContext.save.weekEventReg[20] &= (u8)~8; this->unk_2EE = 8; Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); this->actionFunc = func_80B3B05C; @@ -408,9 +408,9 @@ void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_MarkForDeath(&this->actor); } } else { - gSaveContext.weekEventReg[20] &= (u8)~4; - gSaveContext.weekEventReg[20] &= (u8)~8; - gSaveContext.weekEventReg[20] &= (u8)~0x10; + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; Actor_MarkForDeath(&this->actor); } } 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 c509db2b8..90d945e2a 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -183,10 +183,11 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { } if (GIANT_TYPE_IS_CLOCK_TOWER_SUCCESS(type)) { - if (!(gSaveContext.weekEventReg[25] & 2)) { + if (!(gSaveContext.save.weekEventReg[25] & 2)) { Actor_MarkForDeath(&this->actor); return; } + this->actorActionCommand = 0x1C5; Actor_SetScale(&this->actor, 0.32f); this->actionFunc = EnGiant_PerformClockTowerSuccessActions; 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 5ed7ccdf3..34b0e36b4 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 @@ -81,13 +81,13 @@ void EnGinkoMan_Idle(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_SwitchAnimation(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if ((gSaveContext.bankRupees & 0xFFFF) == 0) { + if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); Message_StartTextbox(globalCtx, 0x44C, &this->actor); this->curTextId = 0x44C; // would you like to make an account } else { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - if ((CURRENT_DAY == 3) && (gSaveContext.isNight == 1)) { + if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == true)) { Message_StartTextbox(globalCtx, 0x467, &this->actor); this->curTextId = 0x467; // "What's this? You need somethin' on a day like this? } else { @@ -110,7 +110,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { switch (this->curTextId) { case 0x44C: // "Hey there, little guy! Won't you deposit some Rupees? (first dialogue) Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - if (gSaveContext.weekEventReg[10] & 8) { + if (gSaveContext.save.weekEventReg[10] & 8) { Message_StartTextbox(globalCtx, 0x44E, &this->actor); this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" } else { @@ -145,7 +145,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); } - globalCtx->msgCtx.bankRupees = gSaveContext.bankRupees & 0xFFFF; + globalCtx->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; Message_StartTextbox(globalCtx, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" } @@ -156,22 +156,22 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" break; case 0x45A: // "All right, little guy, now I've got a total of [rupees] from you!" - if (((gSaveContext.bankRupees & 0xFFFF) >= 200) && (this->previousBankValue < 200) && - !(gSaveContext.weekEventReg[59] & 0x40)) { - gSaveContext.weekEventReg[59] |= 0x40; + if (((gSaveContext.save.bankRupees & 0xFFFF) >= 200) && (this->previousBankValue < 200) && + !(gSaveContext.save.weekEventReg[59] & 0x40)) { + gSaveContext.save.weekEventReg[59] |= 0x40; Message_StartTextbox(globalCtx, 0x45B, &this->actor); this->curTextId = 0x45B; // "What's this? You've already saved up 200 Rupees!?! - } else if (((gSaveContext.bankRupees & 0xFFFF) >= 1000) && ((this->previousBankValue) < 1000) && - !(gSaveContext.weekEventReg[59] & 0x80)) { - gSaveContext.weekEventReg[59] |= 0x80; + } else if (((gSaveContext.save.bankRupees & 0xFFFF) >= 1000) && ((this->previousBankValue) < 1000) && + !(gSaveContext.save.weekEventReg[59] & 0x80)) { + gSaveContext.save.weekEventReg[59] |= 0x80; Message_StartTextbox(globalCtx, 0x45C, &this->actor); this->curTextId = 0x45C; // "What's this? You've already saved up 1000 Rupees!?! - } else if ((gSaveContext.bankRupees & 0xFFFF) >= 5000) { - if ((this->previousBankValue < 5000) && !(gSaveContext.weekEventReg[60] & 1)) { - gSaveContext.weekEventReg[60] |= 1; + } else if ((gSaveContext.save.bankRupees & 0xFFFF) >= 5000) { + if ((this->previousBankValue < 5000) && !(gSaveContext.save.weekEventReg[60] & 1)) { + gSaveContext.save.weekEventReg[60] |= 1; Message_StartTextbox(globalCtx, 0x45D, &this->actor); this->curTextId = 0x45D; // "What's this? You've already saved up 5000 Rupees?! - } else if (this->previousBankValue < (s16)(gSaveContext.bankRupees & 0xFFFF)) { + } else if (this->previousBankValue < (s16)(gSaveContext.save.bankRupees & 0xFFFF)) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); Message_StartTextbox(globalCtx, 0x45E, &this->actor); this->curTextId = @@ -213,7 +213,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { break; case 0x465: // "There! Now I'll know you when I see you!" Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); - globalCtx->msgCtx.bankRupees = gSaveContext.bankRupees & 0xFFFF; + globalCtx->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; Message_StartTextbox(globalCtx, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" break; @@ -229,10 +229,10 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { case 0x46C: // "Ah, yes...[Link], right? If I remember, you're the little guy who deposited [rupees]." case 0x47E: // "Your deposits total [rupees]." if (this->choiceDepositWithdrawl == GINKOMAN_CHOICE_DEPOSIT) { - if ((u32)(gSaveContext.bankRupees & 0xFFFF) >= 5000) { + if ((u32)(gSaveContext.save.bankRupees & 0xFFFF) >= 5000) { Message_StartTextbox(globalCtx, 0x45F, &this->actor); this->curTextId = 0x45F; // "Excuuuse me! But I can't take anymore deposits! - } else if (gSaveContext.rupees == 0) { + } else if (gSaveContext.save.playerData.rupees == 0) { Message_StartTextbox(globalCtx, 0x458, &this->actor); this->curTextId = 0x458; // "Hmm...You play mean jokes, little guy! You haven't even got a single Rupee! @@ -240,7 +240,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x479, &this->actor); this->curTextId = 0x479; // "Well, are you gonna make a deposit?" } - } else if ((CURRENT_DAY == 3) && (gSaveContext.isNight == 1)) { + } else if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == true)) { Message_StartTextbox(globalCtx, 0x46D, &this->actor); // "Look, little guy, if it's 'cause of the bad rumors going around, forget it! They're just rumors!" this->curTextId = 0x46D; @@ -280,12 +280,12 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { case 0x473: // Use it wisely... case 0x474: // "Aw, you're taking out all that? If you spend it like that, it'll all be gone before you know // it!" - if ((gSaveContext.bankRupees & 0xFFFF) == 0) { + if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { Message_StartTextbox(globalCtx, 0x478, &this->actor); // "Look, little guy, all the Rupees you deposited are gone, so you can't use that stamp anymore." this->curTextId = 0x478; } else { - globalCtx->msgCtx.bankRupees = gSaveContext.bankRupees & 0xFFFF; + globalCtx->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; Message_StartTextbox(globalCtx, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" } @@ -311,12 +311,12 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) switch (this->curTextId) { case 0x44E: // "...So, what'll it be? if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { - if ((gSaveContext.bankRupees & 0xFFFF) >= 5000) { + if ((gSaveContext.save.bankRupees & 0xFFFF) >= 5000) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(globalCtx, 0x45F, &this->actor); this->curTextId = 0x45F; // bank full, cannot accept more } else { - if (gSaveContext.rupees > 0) { + if (gSaveContext.save.playerData.rupees > 0) { func_8019F208(); Message_StartTextbox(globalCtx, 0x44F, &this->actor); this->curTextId = 0x44F; // "All right! so..." @@ -334,7 +334,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) break; case 0x452: // Really? are you really depositing rupees? if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { - if (gSaveContext.rupees < globalCtx->msgCtx.bankRupeesSelected) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.bankRupeesSelected) { play_sound(NA_SE_SY_ERROR); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); Message_StartTextbox(globalCtx, 0x459, &this->actor); @@ -353,20 +353,20 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) this->curTextId = 0x453; // That's it? That aint nothing at all } - if ((gSaveContext.bankRupees & 0xFFFF) == 0) { + if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { this->isNewAccount = true; } func_801159EC((s16)-globalCtx->msgCtx.bankRupeesSelected); - this->previousBankValue = gSaveContext.bankRupees & 0xFFFF; - gSaveContext.bankRupees = - ((gSaveContext.bankRupees & 0xFFFF) + globalCtx->msgCtx.bankRupeesSelected) | - (gSaveContext.bankRupees & 0xFFFF0000); + this->previousBankValue = gSaveContext.save.bankRupees & 0xFFFF; + gSaveContext.save.bankRupees = + ((gSaveContext.save.bankRupees & 0xFFFF) + globalCtx->msgCtx.bankRupeesSelected) | + (gSaveContext.save.bankRupees & 0xFFFF0000); } } else { // GINKOMAN_CHOICE_NO func_8019F230(); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - if ((gSaveContext.bankRupees & 0xFFFF) == 0) { + if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { Message_StartTextbox(globalCtx, 0x456, &this->actor); this->curTextId = 0x456; // Is that so? think about it } else { @@ -395,13 +395,14 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) break; case 0x471: // Are you really withdrawling [selected rupees]? if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { - if ((s32)((gSaveContext.bankRupees & 0xFFFF)) < + if ((s32)((gSaveContext.save.bankRupees & 0xFFFF)) < ((s32)(globalCtx->msgCtx.bankRupeesSelected + this->serviceFee))) { play_sound(NA_SE_SY_ERROR); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); Message_StartTextbox(globalCtx, 0x476, &this->actor); this->curTextId = 0x476; // you dont have enough deposited to withdrawl - } else if (CUR_CAPACITY(UPG_WALLET) < (globalCtx->msgCtx.bankRupeesSelected + gSaveContext.rupees)) { + } else if (CUR_CAPACITY(UPG_WALLET) < + (globalCtx->msgCtx.bankRupeesSelected + gSaveContext.save.playerData.rupees)) { // check if wallet is big enough play_sound(NA_SE_SY_ERROR); Message_StartTextbox(globalCtx, 0x475, &this->actor); @@ -419,11 +420,11 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) this->curTextId = 0x472; // It's a waste to take out such a tiny bit } - this->previousBankValue = (s16)(gSaveContext.bankRupees & 0xFFFF); - gSaveContext.bankRupees = - (((gSaveContext.bankRupees & 0xFFFF) - globalCtx->msgCtx.bankRupeesSelected) - + this->previousBankValue = (s16)(gSaveContext.save.bankRupees & 0xFFFF); + gSaveContext.save.bankRupees = + (((gSaveContext.save.bankRupees & 0xFFFF) - globalCtx->msgCtx.bankRupeesSelected) - this->serviceFee) | - (gSaveContext.bankRupees & 0xFFFF0000); + (gSaveContext.save.bankRupees & 0xFFFF0000); func_801159EC(globalCtx->msgCtx.bankRupeesSelected); } } else { @@ -452,7 +453,7 @@ void EnGinkoMan_WaitForRupeeCount(EnGinkoMan* this, GlobalContext* globalCtx) { if (globalCtx->msgCtx.bankRupeesSelected == 0) { Message_StartTextbox(globalCtx, 0x46F, &this->actor); this->curTextId = 0x46F; // "Zero Rupees?!? That's a cruel joke!" - } else if (gSaveContext.isNight == 1) { + } else if (gSaveContext.save.isNight == true) { Message_StartTextbox(globalCtx, 0x477, &this->actor); this->curTextId = 0x477; // "...You know, at this time of day there's a 4 Rupee service charge... } else { @@ -510,14 +511,14 @@ void EnGinkoMan_BankAward(EnGinkoMan* this, GlobalContext* globalCtx) { this->actor.parent = NULL; EnGinkoMan_SetupBankAward2(this); } else if (this->curTextId == 0x45B) { // "Whats this, you already saved up 200?" - if (!(gSaveContext.weekEventReg[10] & 8)) { + if (!(gSaveContext.save.weekEventReg[10] & 8)) { Actor_PickUp(&this->actor, globalCtx, GI_WALLET_ADULT + CUR_UPG_VALUE(UPG_WALLET), 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); } } else if (this->curTextId == 0x45C) { // "Whats this, you already saved up 5000?" Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); - } else if (!(gSaveContext.weekEventReg[59] & 8)) { + } else if (!(gSaveContext.save.weekEventReg[59] & 8)) { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_BLUE, 500.0f, 100.0f); @@ -532,10 +533,10 @@ void EnGinkoMan_SetupBankAward2(EnGinkoMan* this) { // separate function to handle bank rewards... called while the player is receiving the award void EnGinkoMan_BankAward2(EnGinkoMan* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if (!(gSaveContext.weekEventReg[10] & 8) && (this->curTextId == 0x45B)) { + if (!(gSaveContext.save.weekEventReg[10] & 8) && (this->curTextId == 0x45B)) { // "What's this? You've already saved up 200 Rupees!?! Well, little guy, here's your special gift. Take // it!" - gSaveContext.weekEventReg[10] |= 8; + gSaveContext.save.weekEventReg[10] |= 8; Message_StartTextbox(globalCtx, 0x47A, &this->actor); this->curTextId = 0x47A; // Message after receiving reward for depositing 200 rupees. } else { @@ -547,8 +548,8 @@ void EnGinkoMan_BankAward2(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_SetupDialogue(this); } else if (this->curTextId == 0x45D) { // saved up 5000 rupees for HP if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { - if (!(gSaveContext.weekEventReg[59] & 8)) { - gSaveContext.weekEventReg[59] |= 8; + if (!(gSaveContext.save.weekEventReg[59] & 8)) { + gSaveContext.save.weekEventReg[59] |= 8; } EnGinkoMan_SetupIdle(this); } @@ -577,8 +578,8 @@ void EnGinkoMan_Stamp(EnGinkoMan* this, GlobalContext* globalCtx) { break; case 0x469: // "Excuse me, but let me take a look at you..." Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); - globalCtx->msgCtx.bankRupees = (gSaveContext.bankRupees & 0xFFFF); - if ((CURRENT_DAY == 3) && (gSaveContext.isNight == 1)) { + globalCtx->msgCtx.bankRupees = (gSaveContext.save.bankRupees & 0xFFFF); + if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == true)) { Message_StartTextbox(globalCtx, 0x46C, &this->actor); this->curTextId = 0x46C; // "Ah, yes...[Link], right? } else { diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c index df2206522..b509d4500 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -188,7 +188,7 @@ s32 EnGirlA_CanBuyPotionRed(GlobalContext* globalCtx, EnGirlA* this) { if (!Interface_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; @@ -198,46 +198,46 @@ s32 EnGirlA_CanBuyPotionGreen(GlobalContext* globalCtx, EnGirlA* this) { if (!Interface_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyPotionBlue(GlobalContext* globalCtx, EnGirlA* this) { - if (!(gSaveContext.weekEventReg[53] & 8)) { + if (!(gSaveContext.save.weekEventReg[53] & 8)) { return CANBUY_RESULT_CANNOT_GET_NOW; } if (!Interface_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (!(gSaveContext.weekEventReg[53] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[53] & 0x10)) { return CANBUY_RESULT_SUCCESS_2; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyArrows(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_QUIVER) == 0) { + if (GET_CUR_UPG_VALUE(UPG_QUIVER) == 0) { return CANBUY_RESULT_CANNOT_GET_NOW_2; } if (AMMO(ITEM_BOW) >= CUR_CAPACITY(UPG_QUIVER)) { return CANBUY_RESULT_NO_ROOM_2; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyNuts(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_CAPACITY(UPG_NUTS) != 0 && AMMO(ITEM_NUT) >= CUR_CAPACITY(UPG_NUTS)) { + if (CUR_CAPACITY(UPG_NUTS) != 0 && CUR_CAPACITY(UPG_NUTS) <= AMMO(ITEM_NUT)) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } if (func_80114978(ITEM_NUT) == ITEM_NONE) { @@ -247,10 +247,10 @@ s32 EnGirlA_CanBuyNuts(GlobalContext* globalCtx, EnGirlA* this) { } s32 EnGirlA_CanBuyShieldHero(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) != 0) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; @@ -260,7 +260,7 @@ s32 EnGirlA_CanBuyStick(GlobalContext* globalCtx, EnGirlA* this) { if (CUR_CAPACITY(UPG_STICKS) != 0 && AMMO(ITEM_STICK) >= CUR_CAPACITY(UPG_STICKS)) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } if (func_80114978(ITEM_STICK) == ITEM_NONE) { @@ -270,56 +270,56 @@ s32 EnGirlA_CanBuyStick(GlobalContext* globalCtx, EnGirlA* this) { } s32 EnGirlA_CanBuyMaskAllNight(GlobalContext* globalCtx, EnGirlA* this) { - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyBombBagCuriosityShop(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) >= 2) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) >= 2) { return CANBUY_RESULT_CANNOT_GET_NOW; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyBombBag20BombShop(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 1) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 1) { return CANBUY_RESULT_ALREADY_HAVE; } - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) >= 2) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) >= 2) { return CANBUY_RESULT_HAVE_BETTER; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } s32 EnGirlA_CanBuyBombBag30BombShop(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 2) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 2) { return CANBUY_RESULT_ALREADY_HAVE; } - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 3) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 3) { return CANBUY_RESULT_HAVE_BETTER; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } s32 EnGirlA_CanBuyBombchus(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 0) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { return CANBUY_RESULT_CANNOT_GET_NOW; } if (AMMO(ITEM_BOMBCHU) >= CUR_CAPACITY(UPG_BOMB_BAG)) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } if (func_80114978(ITEM_BOMBCHU) == ITEM_NONE) { @@ -329,37 +329,37 @@ s32 EnGirlA_CanBuyBombchus(GlobalContext* globalCtx, EnGirlA* this) { } s32 EnGirlA_CanBuyBombs(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 0) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { return CANBUY_RESULT_CANNOT_GET_NOW; } if (AMMO(ITEM_BOMB) >= CUR_CAPACITY(UPG_BOMB_BAG)) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; } s32 EnGirlA_CanBuyBottle(GlobalContext* globalCtx, EnGirlA* this) { - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } s32 EnGirlA_CanBuySword(GlobalContext* globalCtx, EnGirlA* this) { - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; } s32 EnGirlA_CanBuyShieldMirror(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) != 0) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { return CANBUY_RESULT_NO_ROOM; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_1; @@ -369,7 +369,7 @@ s32 EnGirlA_CanBuyFairy(GlobalContext* globalCtx, EnGirlA* this) { if (!Interface_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } return CANBUY_RESULT_SUCCESS_2; 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 5ac1c8cb3..135d9f6d7 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -120,7 +120,7 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { if (globalCtx->sceneNum == SCENE_17SETUGEN2) { if (player->transformation == PLAYER_FORM_GORON) { - if (!(gSaveContext.weekEventReg[40] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[40] & 0x80)) { switch (this->unk_31C) { case 0xE7A: return 0xE7B; @@ -133,7 +133,7 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { case 0xE7E: return 0xE7F; case 0xE7F: - gSaveContext.weekEventReg[40] |= 0x80; + gSaveContext.save.weekEventReg[40] |= 0x80; this->unk_1E4 |= 1; return 0xE80; default: @@ -143,7 +143,7 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { this->unk_1E4 |= 1; return 0xE81; } - } else if (!(gSaveContext.weekEventReg[41] & 1)) { + } else if (!(gSaveContext.save.weekEventReg[41] & 1)) { switch (this->unk_31C) { case 0xE82: return 0xE83; @@ -154,7 +154,7 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { case 0xE7E: return 0xE7F; case 0xE7F: - gSaveContext.weekEventReg[41] |= 1; + gSaveContext.save.weekEventReg[41] |= 1; this->unk_1E4 |= 1; return 0xE80; default: @@ -166,12 +166,12 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { } } else if (globalCtx->sceneNum == SCENE_GORONRACE) { if (player->transformation == PLAYER_FORM_GORON) { - if (!(gSaveContext.weekEventReg[41] & 4)) { + if (!(gSaveContext.save.weekEventReg[41] & 4)) { if (this->unk_31C == 0xE88) { - if (!(gSaveContext.weekEventReg[41] & 8) || Interface_HasEmptyBottle()) { + if (!(gSaveContext.save.weekEventReg[41] & 8) || Interface_HasEmptyBottle()) { return 0xE89; } - gSaveContext.weekEventReg[41] |= 4; + gSaveContext.save.weekEventReg[41] |= 4; this->unk_1E4 |= 1; return 0xE94; } @@ -179,10 +179,10 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { } if ((this->unk_31C == 0xE8D) || (this->unk_31C == 0xE98)) { - if (!(gSaveContext.weekEventReg[41] & 8) || Interface_HasEmptyBottle()) { + if (!(gSaveContext.save.weekEventReg[41] & 8) || Interface_HasEmptyBottle()) { return 0xE89; } - gSaveContext.weekEventReg[41] |= 4; + gSaveContext.save.weekEventReg[41] |= 4; this->unk_1E4 |= 1; return 0xE94; } @@ -193,12 +193,12 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { return 0xE98; } - if (!(gSaveContext.weekEventReg[41] & 2)) { + if (!(gSaveContext.save.weekEventReg[41] & 2)) { switch (this->unk_31C) { case 0xE85: return 0xE86; case 0xE86: - gSaveContext.weekEventReg[41] |= 2; + gSaveContext.save.weekEventReg[41] |= 2; this->unk_1E4 |= 1; return 0xE87; default: @@ -216,7 +216,7 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { u16 func_80B50710(EnGk* this) { switch (this->unk_31C) { case 0xE8E: - gSaveContext.weekEventReg[41] |= 4; + gSaveContext.save.weekEventReg[41] |= 4; this->unk_1E4 &= ~0x10; this->unk_1E4 |= 1; return 0xE8F; @@ -225,7 +225,7 @@ u16 func_80B50710(EnGk* this) { return 0xE8B; case 0xE8B: - gSaveContext.weekEventReg[41] |= 4; + gSaveContext.save.weekEventReg[41] |= 4; this->unk_1E4 |= 0x10; this->unk_1E4 |= 1; return 0xE8C; @@ -633,7 +633,7 @@ void func_80B51760(EnGk* this, GlobalContext* globalCtx) { } } else { if (Flags_GetSwitch(globalCtx, ENGK_GET_3F00(&this->actor))) { - gSaveContext.weekEventReg[40] |= 0x40; + gSaveContext.save.weekEventReg[40] |= 0x40; this->actionFunc = func_80B51D9C; return; } @@ -648,7 +648,7 @@ void func_80B51760(EnGk* this, GlobalContext* globalCtx) { this->unk_1E4 |= 2; } } else if (((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && - (gSaveContext.entranceIndex != 0xD010)) { + (gSaveContext.save.entranceIndex != 0xD010)) { func_800B863C(&this->actor, globalCtx); } @@ -727,8 +727,8 @@ void func_80B51B40(EnGk* this, GlobalContext* globalCtx) { globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 3; gSaveContext.nextTransition = 3; - Parameter_AddMagic(globalCtx, - ((void)0, gSaveContext.unk_3F30) + (gSaveContext.doubleMagic * 0x30) + 0x30); + Parameter_AddMagic(globalCtx, ((void)0, gSaveContext.unk_3F30) + + (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); } else { this->actionFunc = func_80B51760; } @@ -833,7 +833,7 @@ void func_80B51EA4(EnGk* this, GlobalContext* globalCtx) { } void func_80B51FD0(EnGk* this, GlobalContext* globalCtx) { - if (!(gSaveContext.weekEventReg[22] & 4)) { + if (!(gSaveContext.save.weekEventReg[22] & 4)) { if (this->unk_1E4 & 2) { func_801A4748(&this->actor.projectedPos, NA_SE_EN_GOLON_KID_CRY - SFX_FLAG); } else { @@ -851,7 +851,7 @@ void func_80B5202C(EnGk* this, GlobalContext* globalCtx) { if (!func_80B50854(this, globalCtx)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - gSaveContext.weekEventReg[24] |= 0x80; + gSaveContext.save.weekEventReg[24] |= 0x80; this->actionFunc = func_80B51698; } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); @@ -900,7 +900,7 @@ void func_80B5227C(EnGk* this, GlobalContext* globalCtx) { func_800B14D4(globalCtx, 20.0f, &this->actor.home.pos); this->unk_350 = 60; if (!(this->unk_1E4 & 0x80)) { - gSaveContext.weekEventReg[22] |= 4; + gSaveContext.save.weekEventReg[22] |= 4; } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SIT_IMT); this->unk_350 = 0x4000; @@ -960,7 +960,7 @@ void func_80B52430(EnGk* this, GlobalContext* globalCtx) { void func_80B5253C(EnGk* this, GlobalContext* globalCtx) { s32 sp24; - if (gSaveContext.weekEventReg[41] & 8) { + if (gSaveContext.save.weekEventReg[41] & 8) { sp24 = 0x93; } else { sp24 = 0x6A; @@ -969,7 +969,7 @@ void func_80B5253C(EnGk* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; if (sp24 == 0x6A) { - gSaveContext.weekEventReg[41] |= 8; + gSaveContext.save.weekEventReg[41] |= 8; } this->actionFunc = func_80B525E0; } else { @@ -990,7 +990,7 @@ void func_80B525E0(EnGk* this, GlobalContext* globalCtx) { void func_80B52654(EnGk* this, GlobalContext* globalCtx) { this->unk_350 += 0x400; if ((this->unk_1E4 & 0x80) && (globalCtx->csCtx.frames == 250)) { - gSaveContext.weekEventReg[22] |= 4; + gSaveContext.save.weekEventReg[22] |= 4; } this->unk_354 = Math_SinS(this->unk_350) * 0.006f * 0.06f; @@ -1032,10 +1032,10 @@ void EnGk_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_80B51760; } } else if (globalCtx->sceneNum == SCENE_GORONRACE) { - if (gSaveContext.weekEventReg[33] & 0x80) { - if (gSaveContext.entranceIndex == 0xD010) { + if (gSaveContext.save.weekEventReg[33] & 0x80) { + if (gSaveContext.save.entranceIndex == 0xD010) { this->actionFunc = func_80B51760; - } else if (gSaveContext.entranceIndex == 0xD020) { + } else if (gSaveContext.save.entranceIndex == 0xD020) { this->actionFunc = func_80B52340; } else { this->actionFunc = func_80B51760; @@ -1047,7 +1047,7 @@ void EnGk_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } } else if (ENGK_GET_F(&this->actor) == ENGK_F_2) { - if (!(gSaveContext.weekEventReg[22] & 4)) { + if (!(gSaveContext.save.weekEventReg[22] & 4)) { this->actionFunc = func_80B51FD0; this->actor.draw = NULL; this->actor.flags |= ACTOR_FLAG_10; @@ -1055,7 +1055,7 @@ void EnGk_Init(Actor* thisx, GlobalContext* globalCtx) { } else { Actor_MarkForDeath(&this->actor); } - } else if (!(gSaveContext.weekEventReg[22] & 4)) { + } else if (!(gSaveContext.save.weekEventReg[22] & 4)) { this->unk_2E4 = 0; this->unk_318 = this->actor.cutscene; this->actor.flags |= ACTOR_FLAG_10; @@ -1079,7 +1079,7 @@ void EnGk_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if ((ENGK_GET_F(&this->actor) == ENGK_F_1) || - ((ENGK_GET_F(&this->actor) == ENGK_F_0) && !(gSaveContext.weekEventReg[22] & 4))) { + ((ENGK_GET_F(&this->actor) == ENGK_F_0) && !(gSaveContext.save.weekEventReg[22] & 4))) { func_80B507A0(this, globalCtx); SkelAnime_Update(&this->skelAnime); func_800E9250(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); @@ -1238,7 +1238,7 @@ void EnGk_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); - if ((ENGK_GET_F(&this->actor) == ENGK_F_0) && (gSaveContext.weekEventReg[22] & 4)) { + if ((ENGK_GET_F(&this->actor) == ENGK_F_0) && (gSaveContext.save.weekEventReg[22] & 4)) { Matrix_InsertXRotation_s(-0x4000, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); 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 b034a5899..50a809dfd 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -382,7 +382,7 @@ s32 func_8094E52C(EnGm* this, GlobalContext* globalCtx) { } case 2: - if (!(gSaveContext.weekEventReg[86] & 0x40) && (this->unk_3E0 == 2)) { + if (!(gSaveContext.save.weekEventReg[86] & 0x40) && (this->unk_3E0 == 2)) { ActorCutscene_Stop(sp2A); } else { Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); @@ -552,8 +552,8 @@ s32 func_8094EB1C(EnGm* this, GlobalContext* globalCtx) { switch (this->unk_3E0) { case 0: - if ((gSaveContext.weekEventReg[50] & 1) || (gSaveContext.weekEventReg[51] & 0x80) || - (gSaveContext.weekEventReg[75] & 2)) { + if ((gSaveContext.save.weekEventReg[50] & 1) || (gSaveContext.save.weekEventReg[51] & 0x80) || + (gSaveContext.save.weekEventReg[75] & 2)) { ret = true; break; } @@ -659,14 +659,14 @@ s32 func_8094EE84(EnGm* this, GlobalContext* globalCtx) { this->actor.child = this->unk_268; this->unk_264 = func_8094EDBC(this, globalCtx); - if ((this->unk_258 == 5) && !(gSaveContext.weekEventReg[50] & 1) && - !(gSaveContext.weekEventReg[51] & 0x80) && !(gSaveContext.weekEventReg[75] & 2)) { + if ((this->unk_258 == 5) && !(gSaveContext.save.weekEventReg[50] & 1) && + !(gSaveContext.save.weekEventReg[51] & 0x80) && !(gSaveContext.save.weekEventReg[75] & 2)) { this->unk_3A4 |= 0x20; } else if ((this->unk_258 != 1) && (this->unk_258 != 5) && (this->unk_258 != 7)) { this->unk_3A4 |= 0x20; } - if ((this->unk_258 == 3) && (gSaveContext.weekEventReg[75] & 1)) { + if ((this->unk_258 == 3) && (gSaveContext.save.weekEventReg[75] & 1)) { this->unk_3A4 &= ~0x20; } @@ -920,7 +920,7 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp56 = gSaveContext.time - 0x3FFC; + u16 sp56 = gSaveContext.save.time - 0x3FFC; u8 sp55 = ENGM_GET_FF(&this->actor); EnDoor* door; Vec3s* sp4C; @@ -966,7 +966,7 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp2E = gSaveContext.time - 0x3FFC; + u16 sp2E = gSaveContext.save.time - 0x3FFC; u16 phi_v1; u8 sp2B = ENGM_GET_FF(&this->actor); s32 pad; @@ -1052,7 +1052,7 @@ s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar func_8094E054(this, globalCtx, 11); SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_268 = al; - if (!(gSaveContext.weekEventReg[86] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[86] & 0x20)) { this->unk_3C8 = 2; this->unk_3CA = 2; this->unk_3CC = 8; @@ -1267,7 +1267,7 @@ s32 func_80950490(EnGm* this, GlobalContext* globalCtx) { }; s32 pad; - if ((gSaveContext.weekEventReg[50] & 1) || (gSaveContext.weekEventReg[51] & 0x80)) { + if ((gSaveContext.save.weekEventReg[50] & 1) || (gSaveContext.save.weekEventReg[51] & 0x80)) { if (this->unk_400 == 0) { this->unk_3C8 = 1; this->unk_3CA = 1; @@ -1493,7 +1493,7 @@ void func_80950C24(EnGm* this, GlobalContext* globalCtx) { } void func_80950CDC(EnGm* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; + u32* unk_14 = &gSaveContext.save.daySpeed; struct_80133038_arg2 sp20; this->unk_3C4 = REG(15) + *unk_14; 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 f173e26f9..dbe7c3d72 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -536,7 +536,7 @@ s32 func_80A1222C(EnGo* this, GlobalContext* globalCtx) { if (((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.ocarinaMode == 3) && (globalCtx->msgCtx.unk1202E == 1) && (this->unk_3EC == 0) && (this->actor.xzDistToPlayer < 400.0f)) || - (!(gSaveContext.weekEventReg[22] & 4) && (globalCtx->sceneNum == SCENE_16GORON_HOUSE) && + (!(gSaveContext.save.weekEventReg[22] & 4) && (globalCtx->sceneNum == SCENE_16GORON_HOUSE) && (gSaveContext.sceneSetupIndex == 0) && (this->unk_3EC == 0) && (globalCtx->csCtx.currentCsIndex == 1))) { ret = true; } @@ -943,7 +943,7 @@ void func_80A132C8(EnGo* this, GlobalContext* globalCtx) { if ((fabsf(this->actor.playerHeightRel) > 20.0f) || (this->actor.xzDistToPlayer > 300.0f)) { SubS_UpdateFlags(&this->unk_390, 3, 7); } else if ((player->transformation != PLAYER_FORM_GORON) || (ABS_ALT(temp_v1) >= 0x1C70) || - (gSaveContext.weekEventReg[21] & 4) || (gSaveContext.weekEventReg[21] & 8)) { + (gSaveContext.save.weekEventReg[21] & 4) || (gSaveContext.save.weekEventReg[21] & 8)) { SubS_UpdateFlags(&this->unk_390, 3, 7); } else { SubS_UpdateFlags(&this->unk_390, 4, 7); @@ -951,7 +951,7 @@ void func_80A132C8(EnGo* this, GlobalContext* globalCtx) { } void func_80A133A8(EnGo* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[21] & 8) { + if (gSaveContext.save.weekEventReg[21] & 8) { SubS_UpdateFlags(&this->unk_390, 3, 7); } else { SubS_UpdateFlags(&this->unk_390, 4, 7); @@ -986,7 +986,7 @@ Actor* func_80A13400(EnGo* this, GlobalContext* globalCtx) { } void func_80A134B0(EnGo* this, GlobalContext* globalCtx, s32 arg2) { - if ((gSaveContext.weekEventReg[18] & 0x80) || (globalCtx->actorCtx.unk5 & 1) || arg2) { + if ((gSaveContext.save.weekEventReg[18] & 0x80) || (globalCtx->actorCtx.unk5 & 1) || arg2) { this->colliderSphere.dim.modelSphere.radius = 300; } else { this->colliderSphere.dim.modelSphere.radius = 380; @@ -1177,7 +1177,7 @@ s32 func_80A13B1C(EnGo* this, GlobalContext* globalCtx) { func_80A13728(this, globalCtx); this->unk_3C4++; this->unk_3C2 = 0; - gSaveContext.weekEventReg[88] |= 0x40; + gSaveContext.save.weekEventReg[88] |= 0x40; } break; @@ -1197,19 +1197,19 @@ s32 func_80A13B1C(EnGo* this, GlobalContext* globalCtx) { if (this->unk_3C0 >= 65) { switch (player->transformation) { case 4: - gSaveContext.weekEventReg[88] |= 0x80; + gSaveContext.save.weekEventReg[88] |= 0x80; break; case 1: - gSaveContext.weekEventReg[89] |= 4; + gSaveContext.save.weekEventReg[89] |= 4; break; case 2: - gSaveContext.weekEventReg[89] |= 2; + gSaveContext.save.weekEventReg[89] |= 2; break; case 3: - gSaveContext.weekEventReg[89] |= 1; + gSaveContext.save.weekEventReg[89] |= 1; break; } ret = true; @@ -1373,8 +1373,8 @@ void func_80A143A8(EnGo* this, GlobalContext* globalCtx) { } void func_80A14430(EnGo* this, GlobalContext* globalCtx) { - if (((gSaveContext.entranceIndex == 0xD000) || (gSaveContext.entranceIndex == 0xD020)) && - (gSaveContext.weekEventReg[33] & 0x80)) { + if (((gSaveContext.save.entranceIndex == 0xD000) || (gSaveContext.save.entranceIndex == 0xD020)) && + (gSaveContext.save.weekEventReg[33] & 0x80)) { func_80A14018(this, globalCtx); this->actionFunc = func_80A149B0; } else { @@ -1383,7 +1383,7 @@ void func_80A14430(EnGo* this, GlobalContext* globalCtx) { } void func_80A1449C(EnGo* this, GlobalContext* globalCtx) { - if ((gSaveContext.entranceIndex == 0xD010) || (gSaveContext.entranceIndex == 0x1C00)) { + if ((gSaveContext.save.entranceIndex == 0xD010) || (gSaveContext.save.entranceIndex == 0x1C00)) { func_80A14104(this, globalCtx); this->actionFunc = func_80A149B0; } else { @@ -1392,7 +1392,7 @@ void func_80A1449C(EnGo* this, GlobalContext* globalCtx) { } void func_80A144F4(EnGo* this, GlobalContext* globalCtx) { - if (gSaveContext.day >= 2) { + if (gSaveContext.save.day >= 2) { this->unk_284 = func_8013BEDC(globalCtx, ENGO_GET_7F80(&this->actor), 0xFF, &this->unk_3E4); if (this->unk_284 != NULL) { this->unk_3E4 = 1; @@ -1411,7 +1411,7 @@ void func_80A145AC(EnGo* this, GlobalContext* globalCtx) { if ((ENGO_GET_70(&this->actor) == ENGO_70_1) && (((globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.currentCsIndex == 0)) || - !(gSaveContext.weekEventReg[21] & 8))) { + !(gSaveContext.save.weekEventReg[21] & 8))) { this->actor.child = func_80A13400(this, globalCtx); this->actor.child->child = &this->actor; func_80A141D4(this, globalCtx); @@ -1423,7 +1423,7 @@ void func_80A145AC(EnGo* this, GlobalContext* globalCtx) { } void func_80A14668(EnGo* this, GlobalContext* globalCtx) { - if (!(gSaveContext.weekEventReg[22] & 4)) { + if (!(gSaveContext.save.weekEventReg[22] & 4)) { func_80A14324(this, globalCtx); this->actionFunc = func_80A149B0; } else { @@ -1511,7 +1511,7 @@ void func_80A14798(EnGo* this, GlobalContext* globalCtx) { void func_80A149B0(EnGo* this, GlobalContext* globalCtx) { s16 sp26 = this->actor.world.rot.y; - if ((ENGO_GET_F(&this->actor) == ENGO_F_2) && (gSaveContext.entranceIndex == 0xD010)) { + if ((ENGO_GET_F(&this->actor) == ENGO_F_2) && (gSaveContext.save.entranceIndex == 0xD010)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_CHEER - SFX_FLAG); } else if (ENGO_GET_F(&this->actor) != ENGO_F_8) { if (func_80A1222C(this, globalCtx)) { @@ -1568,7 +1568,7 @@ void func_80A14B30(EnGo* this, GlobalContext* globalCtx) { this->unk_390 &= ~0x200; this->unk_390 |= 0x8000; this->actor.shape.yOffset = 0.0f; - } else if ((this->unk_3EC != 0) && (gSaveContext.weekEventReg[22] & 4)) { + } else if ((this->unk_3EC != 0) && (gSaveContext.save.weekEventReg[22] & 4)) { this->actor.scale.x = this->unk_3A4 - (Math_SinS(this->unk_3AE) * 0.001f); this->actor.scale.y = (Math_SinS(this->unk_3AE) * 0.001f) + this->unk_3A4; this->actor.scale.z = (Math_SinS(this->unk_3AE) * 0.001f) + this->unk_3A4; @@ -1771,7 +1771,7 @@ void func_80A153FC(EnGo* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_COLD); - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { func_80A141D4(this, globalCtx); this->actionFunc = func_80A14E14; } else { 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 b0a451aab..3e7f73775 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -112,7 +112,7 @@ s8 func_80997A90(s16 arg0, s16 arg1) { if ((arg0 == 0) || ((arg0 != 1) && (arg0 != 2) && (arg0 == 3))) { phi_v1 = 0; } else { - phi_v1 = (gSaveContext.unk_EC4 >> (arg1 * 3)) & 7; + phi_v1 = (gSaveContext.save.unk_EC4 >> (arg1 * 3)) & 7; } return phi_v1; } @@ -296,7 +296,7 @@ void func_8099807C(EnGs* this, GlobalContext* globalCtx) { break; case 0: - if ((this->actor.params == ENGS_1) && (gSaveContext.playerForm == PLAYER_FORM_DEKU)) { + if ((this->actor.params == ENGS_1) && (gSaveContext.save.playerForm == PLAYER_FORM_DEKU)) { this->unk_194 = 1; this->unk_19C = 5; this->unk_19A |= 1; @@ -306,7 +306,7 @@ void func_8099807C(EnGs* this, GlobalContext* globalCtx) { break; case 2: - if ((this->actor.params == ENGS_1) && (gSaveContext.playerForm == PLAYER_FORM_ZORA)) { + if ((this->actor.params == ENGS_1) && (gSaveContext.save.playerForm == PLAYER_FORM_ZORA)) { this->unk_194 = 3; this->unk_19C = 5; this->unk_19A |= 1; @@ -316,7 +316,7 @@ void func_8099807C(EnGs* this, GlobalContext* globalCtx) { break; case 1: - if ((this->actor.params == ENGS_1) && (gSaveContext.playerForm == PLAYER_FORM_GORON)) { + if ((this->actor.params == ENGS_1) && (gSaveContext.save.playerForm == PLAYER_FORM_GORON)) { this->unk_194 = 2; this->unk_19C = 5; this->unk_19A |= 1; @@ -388,8 +388,8 @@ void func_809985B8(EnGs* this, GlobalContext* globalCtx) { Math_Vec3f_Sum(&player->actor.world.pos, &sp38, &player->actor.world.pos); Math_Vec3f_Copy(&player->actor.prevPos, &player->actor.world.pos); this->unk_200 = 0.0f; - gSaveContext.unk_EC4 = - ((u32)gSaveContext.unk_EC4 & ~(7 << (this->unk_198 * 3))) | ((this->unk_194 & 7) << (this->unk_198 * 3)); + gSaveContext.save.unk_EC4 = ((u32)gSaveContext.save.unk_EC4 & ~(7 << (this->unk_198 * 3))) | + ((this->unk_194 & 7) << (this->unk_198 * 3)); gossipStone = NULL; do { @@ -450,7 +450,7 @@ void func_8099874C(EnGs* this, GlobalContext* globalCtx) { phi_v0 = 1; for (i = 0; i < 4; i++) { - if (((gSaveContext.unk_EC4 >> (i * 3)) & 7) != (u32)this->unk_194) { + if (((gSaveContext.save.unk_EC4 >> (i * 3)) & 7) != (u32)this->unk_194) { phi_v0 = 0; } } @@ -459,29 +459,29 @@ void func_8099874C(EnGs* this, GlobalContext* globalCtx) { this->unk_20C = -1; switch (this->unk_194) { case 1: - if (!(gSaveContext.weekEventReg[77] & 8)) { + if (!(gSaveContext.save.weekEventReg[77] & 8)) { this->unk_20C = 6; - gSaveContext.weekEventReg[77] |= 8; + gSaveContext.save.weekEventReg[77] |= 8; } break; case 3: - if (!(gSaveContext.weekEventReg[77] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[77] & 0x10)) { this->unk_20C = 6; - gSaveContext.weekEventReg[77] |= 0x10; + gSaveContext.save.weekEventReg[77] |= 0x10; } break; case 2: - if (!(gSaveContext.weekEventReg[77] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[77] & 0x20)) { this->unk_20C = 6; - gSaveContext.weekEventReg[77] |= 0x20; + gSaveContext.save.weekEventReg[77] |= 0x20; } break; } - if (!(gSaveContext.weekEventReg[90] & 0x10)) { - gSaveContext.weekEventReg[90] |= 0x10; + if (!(gSaveContext.save.weekEventReg[90] & 0x10)) { + gSaveContext.save.weekEventReg[90] |= 0x10; this->unk_20C = 12; } 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 9eef9f188..2434ca2cf 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 @@ -108,7 +108,7 @@ void EnGuardNuts_Init(Actor* thisx, GlobalContext* globalCtx) { sGuardCount++; // If you have returned deku princess guards will init burrowed. - if (!(gSaveContext.weekEventReg[23] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { EnGuardNuts_SetupWait(this); } else { EnGuardNuts_Burrow(this, globalCtx); @@ -157,10 +157,10 @@ void EnGuardNuts_Wait(EnGuardNuts* this, GlobalContext* globalCtx) { if (player->transformation == PLAYER_FORM_DEKU) { // this is the palace of... this->guardTextIndex = 0; - if ((gSaveContext.weekEventReg[17] & 4) && (!this->hasCompletedConversation)) { + if ((gSaveContext.save.weekEventReg[17] & 4) && (!this->hasCompletedConversation)) { // I told you not to enter!! this->guardTextIndex = 7; - } else if (gSaveContext.weekEventReg[12] & 0x40) { + } else if (gSaveContext.save.weekEventReg[12] & 0x40) { // come to see the monkey again? this->guardTextIndex = 4; } @@ -233,7 +233,7 @@ void func_80ABB590(EnGuardNuts* this, GlobalContext* globalCtx) { if (D_80ABBE38[this->guardTextIndex] == 2) { func_801477B4(globalCtx); D_80ABBE20 = 2; - gSaveContext.weekEventReg[12] |= 0x40; + gSaveContext.save.weekEventReg[12] |= 0x40; EnGuardNuts_Burrow(this, globalCtx); } else { this->guardTextIndex++; @@ -299,7 +299,7 @@ void EnGuardNuts_Unburrow(EnGuardNuts* this, GlobalContext* globalCtx) { Vec3f digPos; // If you have returned Deku Princess, guards will not unburrow - if (!(gSaveContext.weekEventReg[23] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.home.rot.y)); if ((yawDiff < 0x4000) && ((D_80ABBE20 == 0) || (this->actor.xzDistToPlayer > 150.0f))) { Math_Vec3f_Copy(&digPos, &this->actor.world.pos); 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 5e1675583..8844062b8 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -79,7 +79,7 @@ void EnGuruguru_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params != 2) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); } - if (!gSaveContext.isNight) { + if (!gSaveContext.save.isNight) { if (this->actor.params == 0) { func_80BC6E10(this); } else if (this->actor.params == 2) { @@ -119,10 +119,10 @@ void func_80BC6E10(EnGuruguru* this) { this->textIdIndex = 0; this->unk270 = 0; if (this->actor.params == 0) { - if (gSaveContext.weekEventReg[38] & 0x10) { + if (gSaveContext.save.weekEventReg[38] & 0x10) { this->textIdIndex = 1; } - } else if (gSaveContext.weekEventReg[38] & 0x40) { + } else if (gSaveContext.save.weekEventReg[38] & 0x40) { this->textIdIndex = 2; } else { this->textIdIndex = 3; @@ -131,8 +131,8 @@ void func_80BC6E10(EnGuruguru* this) { this->headZRotTarget = 0; this->unk268 = 1; this->actor.textId = textIDs[this->textIdIndex]; - if ((this->textIdIndex == 0 || this->textIdIndex == 1) && (gSaveContext.weekEventReg[77] & 4)) { - if (!(gSaveContext.weekEventReg[88] & 4)) { + if ((this->textIdIndex == 0 || this->textIdIndex == 1) && (gSaveContext.save.weekEventReg[77] & 4)) { + if (!(gSaveContext.save.weekEventReg[88] & 4)) { this->actor.textId = 0x295F; } else { this->actor.textId = 0x2960; @@ -153,7 +153,7 @@ void func_80BC6F14(EnGuruguru* this, GlobalContext* globalCtx) { this->textIdIndex = 3; if (player->transformation == PLAYER_FORM_DEKU) { this->textIdIndex = 13; - if (gSaveContext.weekEventReg[79] & 4) { + if (gSaveContext.save.weekEventReg[79] & 4) { this->textIdIndex = 14; } } @@ -212,16 +212,16 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { this->headZRotTarget = 0; if ((this->textIdIndex == 13) || (this->textIdIndex == 14)) { func_80151BB4(globalCtx, 0x13); - gSaveContext.weekEventReg[79] |= 4; + gSaveContext.save.weekEventReg[79] |= 4; func_80BC6E10(this); return; } if (this->actor.params == 0) { if (this->actor.textId == 0x295F) { - gSaveContext.weekEventReg[88] |= 4; + gSaveContext.save.weekEventReg[88] |= 4; } if (this->actor.textId == 0x292A) { - gSaveContext.weekEventReg[38] |= 0x10; + gSaveContext.save.weekEventReg[38] |= 0x10; } func_80151BB4(globalCtx, 0x13); func_80BC6E10(this); @@ -232,7 +232,7 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { return; } if (this->textIdIndex == 12) { - gSaveContext.weekEventReg[38] |= 0x40; + gSaveContext.save.weekEventReg[38] |= 0x40; func_801A3B48(0); func_80151BB4(globalCtx, 0x36); func_80151BB4(globalCtx, 0x13); @@ -297,7 +297,7 @@ void func_80BC7440(EnGuruguru* this, GlobalContext* globalCtx) { func_801A3B48(1); func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, EXCH_ITEM_MINUS1); this->unk268 = 0; - gSaveContext.weekEventReg[38] |= 0x40; + gSaveContext.save.weekEventReg[38] |= 0x40; this->actionFunc = func_80BC7520; } else { Actor_PickUp(&this->actor, globalCtx, GI_MASK_BREMEN, 300.0f, 300.0f); @@ -319,7 +319,7 @@ void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 yawTemp; - if (!gSaveContext.isNight) { + if (!gSaveContext.save.isNight) { if (this->actor.params == 1) { Actor_MarkForDeath(&this->actor); return; 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 7d485ce61..d7ec6103f 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -324,7 +324,7 @@ void func_80B23910(EnHanabi* this, GlobalContext* globalCtx) { } void func_80B23934(EnHanabi* this, GlobalContext* globalCtx) { - if ((gSaveContext.entranceIndex == 0x5410) && (gSaveContext.sceneSetupIndex == 7)) { + if ((gSaveContext.save.entranceIndex == 0x5410) && (gSaveContext.sceneSetupIndex == 7)) { if (globalCtx->csCtx.frames > 1650) { func_80B236C8(this, globalCtx); func_800B8FE8(&this->actor, NA_SE_EV_FIREWORKS_LAUNCH - SFX_FLAG); 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 14bbf6a99..bb2fb002b 100644 --- a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c +++ b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c @@ -73,14 +73,16 @@ void EnHeishi_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->paramsCopy == 0) { this->shouldSetHeadRotation = 1; - if (!(gSaveContext.weekEventReg[63] & 0x80) && !((gSaveContext.day == 3) && gSaveContext.isNight)) { + if (!(gSaveContext.save.weekEventReg[63] & 0x80) && + !((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { Actor_MarkForDeath(&this->actor); } } else { this->colliderCylinder.dim.radius = 30; this->colliderCylinder.dim.height = 60; this->colliderCylinder.dim.yShift = 0; - if ((gSaveContext.weekEventReg[63] & 0x80) || ((gSaveContext.day == 3) && gSaveContext.isNight)) { + if ((gSaveContext.save.weekEventReg[63] & 0x80) || + ((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { Actor_MarkForDeath(&this->actor); } } @@ -150,7 +152,7 @@ void EnHeishi_Update(Actor* thisx, GlobalContext* globalCtx) { } this->actor.shape.rot.y = this->actor.world.rot.y; - if ((this->paramsCopy != 0) && (gSaveContext.day == 3) && gSaveContext.isNight) { + if ((this->paramsCopy != 0) && (gSaveContext.save.day == 3) && gSaveContext.save.isNight) { Actor_MarkForDeath(&this->actor); } else { this->actionFunc(this, globalCtx); 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 2af301e13..0bbef0b9e 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -126,7 +126,7 @@ void EnHg_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); - if ((gSaveContext.weekEventReg[75] & 0x20) || (gSaveContext.weekEventReg[52] & 0x20)) { + if ((gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.weekEventReg[52] & 0x20)) { Actor_MarkForDeath(&this->actor); } this->actor.targetMode = 1; @@ -304,7 +304,7 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); break; case 6: - gSaveContext.weekEventReg[75] |= 0x20; + gSaveContext.save.weekEventReg[75] |= 0x20; Actor_MarkForDeath(&this->actor); break; } @@ -358,7 +358,7 @@ void func_80BCFC0C(EnHg* this, GlobalContext* globalCtx) { D_80BD00C8 = false; } if (globalCtx->msgCtx.ocarinaMode == 3) { - if (globalCtx->msgCtx.unk1202E == 7 && gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (globalCtx->msgCtx.unk1202E == 7 && gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { if (INV_CONTENT(ITEM_MASK_GIBDO) == ITEM_MASK_GIBDO) { this->unk218 = 3; } else { @@ -369,8 +369,8 @@ void func_80BCFC0C(EnHg* this, GlobalContext* globalCtx) { } else { if (this->actor.xzDistToPlayer < 60.0f && fabsf(this->actor.playerHeightRel) < 40.0f) { if ((this->actionFunc != func_80BCF8A0) && (this->actionFunc != func_80BCF95C)) { - if (!(gSaveContext.weekEventReg[61] & 2)) { - gSaveContext.weekEventReg[61] |= 2; + if (!(gSaveContext.save.weekEventReg[61] & 2)) { + gSaveContext.save.weekEventReg[61] |= 2; this->unk218 = 0; } else { this->unk218 = 2; 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 b827e4d62..2aa217846 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -94,7 +94,7 @@ void EnHgo_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_314 = 0; this->unk_310 = 0; this->unk_312 = 0; - if ((gSaveContext.weekEventReg[75] & 0x20) || (gSaveContext.weekEventReg[52] & 0x20)) { + if ((gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.weekEventReg[52] & 0x20)) { func_80BD049C(this); } else { thisx->draw = NULL; @@ -144,7 +144,7 @@ void func_80BD04E0(EnHgo* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x15A7, &this->actor); this->unk_314 = 0x15A7; // can I research that mask } - } else if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { if (!(this->unk_310 & 1)) { this->unk_310 |= 1; Message_StartTextbox(globalCtx, 0x158F, &this->actor); @@ -201,7 +201,7 @@ void func_80BD06FC(EnHgo* this, GlobalContext* globalCtx) { this->unk_314 = 0x1590; break; case 0x1590: - if (gSaveContext.weekEventReg[14] & 4) { + if (gSaveContext.save.weekEventReg[14] & 4) { Message_StartTextbox(globalCtx, 0x1591, &this->actor); this->unk_314 = 0x1591; break; @@ -303,7 +303,7 @@ s32 func_80BD0898(EnHgo* this, GlobalContext* globalCtx) { Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); return true; } - if ((globalCtx->csCtx.state == 0) && (((gSaveContext.weekEventReg[75]) & 0x20)) && + if ((globalCtx->csCtx.state == 0) && (((gSaveContext.save.weekEventReg[75]) & 0x20)) && (this->actionFunc == func_80BD0410)) { this->actor.shape.rot.y = this->actor.world.rot.y; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ELF_MSG2, this->actor.focus.pos.x, this->actor.focus.pos.y, diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h index 27187ee46..1e4bf4f5a 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h @@ -32,13 +32,14 @@ enum { #define RACE_FLAG_4 4 #define RACE_FLAGS 7 -#define GET_RACE_FLAGS (gSaveContext.weekEventReg[92] & RACE_FLAGS) +#define GET_RACE_FLAGS (gSaveContext.save.weekEventReg[92] & RACE_FLAGS) -#define SET_RACE_FLAGS(flag) { \ - gSaveContext.weekEventReg[92] &= (u8) ~RACE_FLAGS; \ - gSaveContext.weekEventReg[92] = \ - gSaveContext.weekEventReg[92] | (u8)((gSaveContext.weekEventReg[92] & ~RACE_FLAGS) | (flag)); \ -} +#define SET_RACE_FLAGS(flag) \ + { \ + gSaveContext.save.weekEventReg[92] &= (u8)~RACE_FLAGS; \ + gSaveContext.save.weekEventReg[92] = \ + gSaveContext.save.weekEventReg[92] | (u8)((gSaveContext.save.weekEventReg[92] & ~RACE_FLAGS) | (flag)); \ + } typedef struct EnHorseGameCheck { /* 0x000 */ DynaPolyActor dyna; 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 93e62e137..6ab8fb486 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -341,7 +341,7 @@ s32 func_80BF17BC(EnIg* this, GlobalContext* globalCtx) { case 1: case 3: - if (!(gSaveContext.weekEventReg[75] & 0x10) && (this->unk_3F6 == 3)) { + if (!(gSaveContext.save.weekEventReg[75] & 0x10) && (this->unk_3F6 == 3)) { ActorCutscene_Stop(sp2A); this->unk_3F6 = 5; } else { @@ -509,7 +509,7 @@ s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp56 = gSaveContext.time - 0x3FFC; + u16 sp56 = gSaveContext.save.time - 0x3FFC; u8 sp55 = ENIG_GET_FF(&this->actor); EnDoor* door; Vec3s* sp4C; @@ -554,7 +554,7 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp2E = gSaveContext.time - 0x3FFC; + u16 sp2E = gSaveContext.save.time - 0x3FFC; u16 phi_v1; u8 sp2B = ENIG_GET_FF(&this->actor); s32 temp_t8; @@ -840,7 +840,7 @@ void func_80BF2A50(EnIg* this, GlobalContext* globalCtx) { } void func_80BF2AF8(EnIg* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; + u32* unk_14 = &gSaveContext.save.daySpeed; struct_80133038_arg2 sp20; this->unk_3EC = REG(15) + *unk_14; 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 39ef956d5..f3293f6dd 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -218,12 +218,11 @@ s32 func_808F3334(EnIn* this, GlobalContext* globalCtx) { } s32 func_808F33B8(void) { - s32 ret; + s32 ret = (((gSaveContext.save.day == 1) && + ((gSaveContext.save.time >= CLOCK_TIME(5, 30)) && (gSaveContext.save.time <= CLOCK_TIME(6, 0)))) || + (gSaveContext.save.day >= 2)) && + !(gSaveContext.save.weekEventReg[22] & 1); - if (((ret = gSaveContext.day == 1) && (ret = gSaveContext.time >= 0x3AAA) && (ret = gSaveContext.time <= 0x4000)) || - (ret = gSaveContext.day >= 2)) { - ret = (gSaveContext.weekEventReg[22] & 1) == 0; - } return ret; } @@ -347,7 +346,7 @@ void func_808F395C(EnIn* this, GlobalContext* globalCtx) { void func_808F39DC(EnIn* this, GlobalContext* globalCtx) { u16 textId = 0; - if (gSaveContext.day != 3) { + if (gSaveContext.save.day != 3) { switch (GET_RACE_FLAGS) { case RACE_FLAG_2: textId = 0x347A; @@ -395,7 +394,7 @@ void func_808F3B40(EnIn* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_808F3AD4; - textId = gSaveContext.day != 3 ? 0x3481 : 0x34A4; + textId = gSaveContext.save.day != 3 ? 0x3481 : 0x34A4; this->actor.textId = textId; } else { Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); @@ -419,7 +418,7 @@ void func_808F3C40(EnIn* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_808F3BD4; - textId = gSaveContext.day != 3 ? 0x346A : 0x3492; + textId = gSaveContext.save.day != 3 ? 0x346A : 0x3492; this->actor.textId = textId; } else { Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); @@ -442,7 +441,7 @@ void func_808F3D40(EnIn* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; this->actionFunc = func_808F3CD4; - textId = gSaveContext.day != 3 ? 0x347D : 0x34A0; + textId = gSaveContext.save.day != 3 ? 0x347D : 0x34A0; this->actor.textId = textId; this->actor.flags |= ACTOR_FLAG_10000; } else { @@ -456,7 +455,7 @@ u16 func_808F3DD4(GlobalContext* globalCtx, EnIn* this, u32 arg2) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER) { s32 requiredScopeTemp; - if (!(gSaveContext.weekEventReg[63] & 0x40)) { + if (!(gSaveContext.save.weekEventReg[63] & 0x40)) { return 0x34A9; } else if (this->unk4AC & 8) { return 0x34B1; @@ -466,41 +465,43 @@ u16 func_808F3DD4(GlobalContext* globalCtx, EnIn* this, u32 arg2) { } else { switch (arg2) { case 0: - if ((gSaveContext.playerForm == PLAYER_FORM_ZORA) || (gSaveContext.playerForm == PLAYER_FORM_GORON)) { + if ((gSaveContext.save.playerForm == PLAYER_FORM_ZORA) || + (gSaveContext.save.playerForm == PLAYER_FORM_GORON)) { textId = 0x345C; - } else if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { textId = 0x3460; - } else if (!(gSaveContext.weekEventReg[15] & 8)) { + } else if (!(gSaveContext.save.weekEventReg[15] & 8)) { textId = 0x3458; } else { textId = 0x345B; } break; case 1: - if (!(gSaveContext.weekEventReg[15] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[15] & 0x10)) { textId = 0x3463; } else { textId = 0x346B; } break; case 3: - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { textId = 0x3485; - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA || - gSaveContext.playerForm == PLAYER_FORM_GORON) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || + gSaveContext.save.playerForm == PLAYER_FORM_GORON) { textId = 0x3484; - } else if (!(gSaveContext.weekEventReg[56] & 4)) { + } else if (!(gSaveContext.save.weekEventReg[56] & 4)) { textId = 0x346D; } else { textId = 0x3482; } break; case 4: - if (gSaveContext.playerForm == PLAYER_FORM_ZORA || gSaveContext.playerForm == PLAYER_FORM_GORON) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || + gSaveContext.save.playerForm == PLAYER_FORM_GORON) { textId = 0x348A; - } else if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { textId = 0x348B; - } else if (!(gSaveContext.weekEventReg[16] & 1)) { + } else if (!(gSaveContext.save.weekEventReg[16] & 1)) { textId = 0x3486; } else { textId = 0x3489; @@ -509,19 +510,19 @@ u16 func_808F3DD4(GlobalContext* globalCtx, EnIn* this, u32 arg2) { case 5: if (func_808F33B8()) { textId = 0x34B3; - } else if (!(gSaveContext.weekEventReg[16] & 2)) { + } else if (!(gSaveContext.save.weekEventReg[16] & 2)) { textId = 0x348E; } else { textId = 0x3493; } break; case 7: - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { textId = 0x34A8; - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA || - gSaveContext.playerForm == PLAYER_FORM_GORON) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA || + gSaveContext.save.playerForm == PLAYER_FORM_GORON) { textId = 0x34A7; - } else if (!(gSaveContext.weekEventReg[16] & 4)) { + } else if (!(gSaveContext.save.weekEventReg[16] & 4)) { textId = 0x3495; } else { textId = 0x34A5; @@ -572,9 +573,9 @@ s32 func_808F4150(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { func_801159EC(-globalCtx->msgCtx.unk1206C); - if (!(gSaveContext.weekEventReg[57] & 1)) { + if (!(gSaveContext.save.weekEventReg[57] & 1)) { func_808F4108(this, globalCtx, 0x3474); } else if (this->unk4AC & 8) { func_808F4108(this, globalCtx, 0x3475); @@ -598,9 +599,9 @@ s32 func_808F4270(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.rupees >= fee) { + if (gSaveContext.save.playerData.rupees >= fee) { func_801159EC(-fee); - if (!(gSaveContext.weekEventReg[57] & 1)) { + if (!(gSaveContext.save.weekEventReg[57] & 1)) { if (arg4 != 0) { func_800E8EA0(globalCtx, &this->actor, 0x3474); } else { @@ -648,7 +649,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x34A9: func_808F4108(this, globalCtx, 0x34AA); - gSaveContext.weekEventReg[63] |= 0x40; + gSaveContext.save.weekEventReg[63] |= 0x40; ret = false; break; case 0x34AA: @@ -679,7 +680,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 0: switch (textId) { case 0x3458: - gSaveContext.weekEventReg[15] |= 8; + gSaveContext.save.weekEventReg[15] |= 8; func_800E8EA0(globalCtx, &this->actor, 0x3459); ret = false; break; @@ -728,7 +729,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 1: switch (textId) { case 0x3463: - gSaveContext.weekEventReg[15] |= 0x10; + gSaveContext.save.weekEventReg[15] |= 0x10; func_800E8EA0(globalCtx, &this->actor, 0x3464); ret = false; break; @@ -743,7 +744,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 0x3466: if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { if (Interface_HasEmptyBottle()) { this->actionFunc = func_808F3C40; Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); @@ -804,12 +805,12 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3472: func_808F43E0(this); - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; func_80151BB4(globalCtx, 0x11); ret = true; break; case 0x3473: - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; func_80151BB4(globalCtx, 0x11); break; case 0x3475: @@ -818,7 +819,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { globalCtx->nextEntranceIndex = 0xCE50; globalCtx->unk_1887F = 5; globalCtx->sceneLoadFlag = 0x14; - gSaveContext.weekEventReg[57] |= 1; + gSaveContext.save.weekEventReg[57] |= 1; break; case 0x3478: if (msgCtx->choiceIndex == 0) { @@ -826,14 +827,14 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; } else { func_8019F230(); - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; func_808F4108(this, globalCtx, 0x3479); ret = false; } break; case 0x347B: func_808F4108(this, globalCtx, 0x347C); - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; ret = false; break; } @@ -842,8 +843,8 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { switch (textId) { case 0x346D: func_808F4108(this, globalCtx, 0x346E); - gSaveContext.weekEventReg[56] |= 4; - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[56] |= 4; + gSaveContext.save.weekEventReg[56] |= 8; ret = false; break; case 0x346F: @@ -852,7 +853,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3482: func_808F4108(this, globalCtx, 0x3483); - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[56] |= 8; ret = false; break; case 0x3484: @@ -872,7 +873,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; break; case 0x3477: - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[56] |= 8; func_808F4108(this, globalCtx, 0x3478); ret = false; break; @@ -883,7 +884,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_800E8EA0(globalCtx, &this->actor, 0x347E); ret = false; } else { - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[56] |= 8; func_808F4108(this, globalCtx, 0x347B); ret = false; } @@ -939,7 +940,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { switch (textId) { case 0x3486: func_800E8EA0(globalCtx, &this->actor, 0x3487); - gSaveContext.weekEventReg[16] |= 1; + gSaveContext.save.weekEventReg[16] |= 1; ret = false; break; case 0x3487: @@ -980,7 +981,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 0x348E: case 0x34B3: func_800E8EA0(globalCtx, &this->actor, 0x348F); - gSaveContext.weekEventReg[16] |= 2; + gSaveContext.save.weekEventReg[16] |= 2; ret = false; break; case 0x3493: @@ -995,7 +996,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 0x3490: if (msgCtx->choiceIndex == 0) { func_8019F208(); - if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { if (Interface_HasEmptyBottle()) { this->actionFunc = func_808F3C40; Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); @@ -1032,8 +1033,8 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3495: func_808F4108(this, globalCtx, 0x3496); - gSaveContext.weekEventReg[16] |= 4; - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[16] |= 4; + gSaveContext.save.weekEventReg[56] |= 8; ret = false; break; case 0x3497: @@ -1048,11 +1049,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x34A5: func_808F4108(this, globalCtx, 0x34A6); - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[56] |= 8; ret = false; break; case 0x3473: - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; func_80151BB4(globalCtx, 0x11); break; case 0x3474: @@ -1065,7 +1066,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { globalCtx->nextEntranceIndex = 0xCE50; globalCtx->unk_1887F = 5; globalCtx->sceneLoadFlag = 0x14; - gSaveContext.weekEventReg[57] |= 1; + gSaveContext.save.weekEventReg[57] |= 1; break; case 0x349D: func_808F30B0(&this->skelAnime, 1); @@ -1074,7 +1075,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_800E8EA0(globalCtx, &this->actor, 0x34A1); ret = false; } else { - gSaveContext.weekEventReg[56] |= 8; + gSaveContext.save.weekEventReg[56] |= 8; func_808F4108(this, globalCtx, 0x349E); ret = false; } @@ -1157,13 +1158,13 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3472: func_808F43E0(this); - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; func_80151BB4(globalCtx, 0x11); ret = true; break; case 0x349E: func_808F4108(this, globalCtx, 0x349F); - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; ret = false; break; } @@ -1274,7 +1275,7 @@ s32 func_808F5994(EnIn* this, GlobalContext* globalCtx, Vec3f* arg2, s16 arg3) { } void func_808F5A34(EnIn* this, GlobalContext* globalCtx) { - if (gSaveContext.day != 3) { + if (gSaveContext.save.day != 3) { func_808F5728(globalCtx, this, 3, &this->unk48C); } else { func_808F5728(globalCtx, this, 7, &this->unk48C); @@ -1283,13 +1284,13 @@ void func_808F5A34(EnIn* this, GlobalContext* globalCtx) { void func_808F5A94(EnIn* this, GlobalContext* globalCtx) { if (func_800F41E4(globalCtx, &globalCtx->actorCtx)) { - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { func_808F5728(globalCtx, this, 7, &this->unk48C); } else { func_808F5728(globalCtx, this, 3, &this->unk48C); } } else { - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { func_808F5728(globalCtx, this, 5, &this->unk48C); } else { func_808F5728(globalCtx, this, 1, &this->unk48C); @@ -1299,17 +1300,17 @@ void func_808F5A94(EnIn* this, GlobalContext* globalCtx) { void func_808F5B58(EnIn* this, GlobalContext* globalCtx) { if (func_800F41E4(globalCtx, &globalCtx->actorCtx)) { - if ((Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.weekEventReg[63] & 0x40) || - gSaveContext.weekEventReg[56] & 8) { - if (gSaveContext.day == 3) { + if ((Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.save.weekEventReg[63] & 0x40) || + gSaveContext.save.weekEventReg[56] & 8) { + if (gSaveContext.save.day == 3) { func_808F5728(globalCtx, this, 6, &this->unk48C); } else { func_808F5728(globalCtx, this, 2, &this->unk48C); } } } else if (Player_GetMask(globalCtx) != PLAYER_MASK_CIRCUS_LEADER || - (Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.weekEventReg[63] & 0x40)) { - if (gSaveContext.day == 3) { + (Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.save.weekEventReg[63] & 0x40)) { + if (gSaveContext.save.day == 3) { func_808F5728(globalCtx, this, 4, &this->unk48C); } else { func_808F5728(globalCtx, this, 0, &this->unk48C); @@ -1321,9 +1322,9 @@ void func_808F5C98(EnIn* this, GlobalContext* globalCtx) { if (this->unk4B0 == RACE_FLAG_END) { this->actionFunc = func_808F5B58; } - if ((Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.weekEventReg[63] & 0x40) || - gSaveContext.weekEventReg[56] & 8) { - if (gSaveContext.day != 3) { + if ((Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.save.weekEventReg[63] & 0x40) || + gSaveContext.save.weekEventReg[56] & 8) { + if (gSaveContext.save.day != 3) { func_808F5728(globalCtx, this, 2, &this->unk48C); } else { func_808F5728(globalCtx, this, 6, &this->unk48C); @@ -1385,7 +1386,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk23D = 0; if (type == ENIN_YELLOW_SHIRT || type == ENIN_BLUE_SHIRT) { if (GET_RACE_FLAGS == RACE_FLAG_2 || (GET_RACE_FLAGS) == RACE_FLAG_3) { - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; this->unk4A8 = 0; this->unk4AC |= 2; func_808F35AC(this, globalCtx); @@ -1406,7 +1407,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { } } else { if (GET_RACE_FLAGS != RACE_FLAG_START) { - gSaveContext.weekEventReg[56] &= (u8)~8; + gSaveContext.save.weekEventReg[56] &= (u8)~8; this->unk23C = 0; this->unk4AC |= 2; if (type == ENIN_BLUE_SHIRT) { @@ -1414,7 +1415,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { func_808F30B0(&this->skelAnime, 0); this->actionFunc = func_808F5A94; } else { - if (gSaveContext.weekEventReg[52] & 1) { + if (gSaveContext.save.weekEventReg[52] & 1) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_KANBAN, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, 0xF); @@ -1425,7 +1426,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { } } } else { - if (gSaveContext.weekEventReg[52] & 1) { + if (gSaveContext.save.weekEventReg[52] & 1) { Actor_MarkForDeath(&this->actor); } else { func_808F30B0(&this->skelAnime, 7); diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 180483cd5..8d2f416a7 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -628,9 +628,10 @@ void func_80B439B0(s32 arg0, s32 arg1) { } if (!(arg0 & 1)) { - gSaveContext.unk_E88[arg0 >> 1] = (gSaveContext.unk_E88[arg0 >> 1] & 0xFFFF0000) | (arg1 & 0xFFFF); + gSaveContext.save.unk_E88[arg0 >> 1] = (gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF0000) | (arg1 & 0xFFFF); } else { - gSaveContext.unk_E88[arg0 >> 1] = (gSaveContext.unk_E88[arg0 >> 1] & 0xFFFF) | ((arg1 & 0xFFFF) << 0x10); + gSaveContext.save.unk_E88[arg0 >> 1] = + (gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF) | ((arg1 & 0xFFFF) << 0x10); } } @@ -638,19 +639,19 @@ s32 func_80B43A24(s32 arg0) { u32 phi_v1; if ((arg0 & 1) == 0) { - phi_v1 = gSaveContext.unk_E88[arg0 >> 1] & 0xFFFF; + phi_v1 = gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF; } else { - phi_v1 = (gSaveContext.unk_E88[arg0 >> 1] & 0xFFFF0000) >> 0x10; + phi_v1 = (gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF0000) >> 0x10; } return phi_v1 + 0x1AAA; } void func_80B43A74(s32 arg0) { - gSaveContext.unk_E88[4] = (gSaveContext.unk_E88[4] & ~0xFF) | (arg0 & 0xFF); + gSaveContext.save.unk_E88[4] = (gSaveContext.save.unk_E88[4] & ~0xFF) | (arg0 & 0xFF); } s32 func_80B43A9C(void) { - return (gSaveContext.unk_E88[4] >> 0) & 0xFF; + return (gSaveContext.save.unk_E88[4] >> 0) & 0xFF; } s32 func_80B43AB0(void) { @@ -664,7 +665,7 @@ s32 func_80B43AB0(void) { } void func_80B43AF0(s32 arg0) { - s32 currentTime = gSaveContext.time; + s32 currentTime = gSaveContext.save.time; if (((CURRENT_DAY == 1) && (currentTime >= CLOCK_TIME(2, 30))) && (currentTime < CLOCK_TIME(5, 15))) { s32 adjustment = (0xC - func_80B43A9C()) * 25.0f; @@ -872,7 +873,7 @@ s32 func_80B44234(EnInvadepoh* this, Vec3f* vec) { void func_80B442E4(EnInvadepoh* this) { s32 pad; - s32 sp18 = gSaveContext.time; + s32 sp18 = gSaveContext.save.time; s32 temp_v1_2 = sp18 - func_80B43A24(this->actor.params & 7); if (D_80B4E940 == 1) { @@ -945,7 +946,7 @@ void func_80B44540(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B44570(EnInvadepoh* this) { - s32 currentTime = gSaveContext.time; + s32 currentTime = gSaveContext.save.time; if ((currentTime < CLOCK_TIME(2, 0)) || (currentTime >= CLOCK_TIME(6, 0))) { this->clockTime = 0.0f; @@ -989,7 +990,7 @@ void func_80B446D0(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B44700(EnInvadepoh* this) { - s32 currentTime = gSaveContext.time; + s32 currentTime = gSaveContext.save.time; s32 new_var4 = 0xFFFF2AAB; if ((currentTime < CLOCK_TIME(20, 0)) && (currentTime >= CLOCK_TIME(6, 0))) { @@ -1262,7 +1263,7 @@ void func_80B451A0(EnInvadepoh* this, GlobalContext* globalCtx) { if (CURRENT_DAY <= 0) { D_80B4E940 = 1; } else if (CURRENT_DAY == 1) { - currentTime = gSaveContext.time; + currentTime = gSaveContext.save.time; if ((currentTime < CLOCK_TIME(2, 30)) || (currentTime >= CLOCK_TIME(6, 0))) { D_80B4E940 = 1; } else if (currentTime < CLOCK_TIME(5, 15)) { @@ -1283,7 +1284,7 @@ void func_80B451A0(EnInvadepoh* this, GlobalContext* globalCtx) { } if (D_80B4E940 == 0) { - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { D_80B4E940 = 3; } else { D_80B4E940 = 4; @@ -1648,7 +1649,7 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { if (D_80B4E940 == 1) { func_80B46DA8(this); } else if (D_80B4E940 == 2) { - if (gSaveContext.time < CLOCK_TIME(2, 31)) { + if (gSaveContext.save.time < CLOCK_TIME(2, 31)) { func_80B46DA8(this); } else { func_80B454BC(this, globalCtx); @@ -1657,10 +1658,10 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { func_80B46F88(this); } } else if (D_80B4E940 == 3) { - if (gSaveContext.entranceIndex == 0x6460) { + if (gSaveContext.save.entranceIndex == 0x6460) { func_80B471C0(this); - } else if (gSaveContext.entranceIndex == 0x6470) { + } else if (gSaveContext.save.entranceIndex == 0x6470) { func_80B47248(this); } else { func_80B47248(this); @@ -1747,23 +1748,23 @@ void EnInvadepoh_InitRomani(EnInvadepoh* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } if (temp == 5) { - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { Actor_MarkForDeath(&this->actor); return; } } else if (temp == 7) { - if (gSaveContext.time < CLOCK_TIME(6, 0) && gSaveContext.time >= CLOCK_TIME(2, 15)) { + if (gSaveContext.save.time < CLOCK_TIME(6, 0) && gSaveContext.save.time >= CLOCK_TIME(2, 15)) { Actor_MarkForDeath(&this->actor); return; } } else if (temp != 8) { if (temp == 9) { - if (gSaveContext.entranceIndex != 0x6460) { + if (gSaveContext.save.entranceIndex != 0x6460) { Actor_MarkForDeath(&this->actor); return; } } else if (temp == 0xC) { - if (!(gSaveContext.weekEventReg[22] & 1)) { + if (!(gSaveContext.save.weekEventReg[22] & 1)) { Actor_MarkForDeath(&this->actor); } D_80B503F4 = this; @@ -1776,7 +1777,7 @@ void func_80B468B4(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.update = func_80B49B1C; this->actor.draw = func_80B4E3F0; func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_NPC); - if (D_80B4E940 == 1 || gSaveContext.time < CLOCK_TIME(2, 31)) { + if (D_80B4E940 == 1 || gSaveContext.save.time < CLOCK_TIME(2, 31)) { this->actor.world.pos.x += D_80B4E934.x; this->actor.world.pos.y += D_80B4E934.y + 3000.0f; this->actor.world.pos.z += D_80B4E934.z; @@ -1818,7 +1819,7 @@ void EnInvadepoh_InitCremia(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->bankIndex < 0) { Actor_MarkForDeath(&this->actor); } - if (!(gSaveContext.weekEventReg[22] & 1)) { + if (!(gSaveContext.save.weekEventReg[22] & 1)) { Actor_MarkForDeath(&this->actor); } D_80B503F8 = this; @@ -1899,7 +1900,7 @@ void func_80B46DA8(EnInvadepoh* this) { } void func_80B46DC8(EnInvadepoh* this, GlobalContext* globalCtx) { - if ((gSaveContext.time < CLOCK_TIME(6, 0)) && (gSaveContext.time >= CLOCK_TIME(2, 30))) { + if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(2, 30))) { func_80B454BC(this, globalCtx); func_80B452EC(this, globalCtx); func_80B46E20(this); @@ -1954,8 +1955,8 @@ void func_80B46F88(EnInvadepoh* this) { void func_80B46FA8(EnInvadepoh* this, GlobalContext* globalCtx) { s32 i; - if ((gSaveContext.time < CLOCK_TIME(6, 0)) && (gSaveContext.time >= CLOCK_TIME(5, 15))) { - gSaveContext.weekEventReg[22] |= 1; + if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(5, 15))) { + gSaveContext.save.weekEventReg[22] |= 1; func_80B47064(this); } else { func_80B457A0(this); @@ -2040,7 +2041,7 @@ void func_80B47298(EnInvadepoh* this, GlobalContext* globalCtx) { globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 0x48; gSaveContext.nextTransition = 0x48; - gSaveContext.weekEventReg[89] |= 0x10; + gSaveContext.save.weekEventReg[89] |= 0x10; func_80B47304(this); } @@ -2289,7 +2290,7 @@ void func_80B47BAC(Actor* thisx, GlobalContext* globalCtx) { func_80B447C0(this, globalCtx); func_80B43F0C(this); func_80B4516C(this); - if (D_80B4E940 == 1 || gSaveContext.time < CLOCK_TIME(2, 31)) { + if (D_80B4E940 == 1 || gSaveContext.save.time < CLOCK_TIME(2, 31)) { func_80B47380(this); } else if (D_80B4E940 == 2) { if (this->clockTime >= 0.0001f) { @@ -3061,7 +3062,7 @@ void func_80B49DFC(EnInvadepoh* this, GlobalContext* globalCtx) { substruct->unk26.y = CLAMP(temp_v1, -0x1F40, 0x1F40); if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { if (this->actor.textId == 0x332D) { - gSaveContext.weekEventReg[54] |= 0x10; + gSaveContext.save.weekEventReg[54] |= 0x10; this->actor.textId = 0x332E; } func_80B49BD0(this); @@ -3074,7 +3075,7 @@ void func_80B49F88(Actor* thisx, GlobalContext* globalCtx) { s32 sp38; if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { - sp38 = gSaveContext.time; + sp38 = gSaveContext.save.time; this->actor.objBankIndex = this->bankIndex; Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44F58(); @@ -3086,8 +3087,8 @@ void func_80B49F88(Actor* thisx, GlobalContext* globalCtx) { func_80B44C24(this, globalCtx); func_80B43F0C(this); func_80B4516C(this); - if (0x20 & gSaveContext.weekEventReg[21]) { - if (gSaveContext.weekEventReg[54] & 0x10) { + if (0x20 & gSaveContext.save.weekEventReg[21]) { + if (gSaveContext.save.weekEventReg[54] & 0x10) { this->actor.textId = 0x332E; } else { this->actor.textId = 0x332D; @@ -3113,7 +3114,7 @@ void func_80B49F88(Actor* thisx, GlobalContext* globalCtx) { void func_80B4A168(Actor* thisx, GlobalContext* globalCtx) { EnInvadepoh* this = THIS; - if ((gSaveContext.time < CLOCK_TIME(6, 0)) && (gSaveContext.time >= CLOCK_TIME(2, 0))) { + if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(2, 0))) { this->actor.update = func_80B4A1B8; this->actor.draw = func_80B4E324; func_80B49BD0(this); @@ -3288,7 +3289,7 @@ void func_80B4A81C(EnInvadepoh* this, GlobalContext* globalCtx) { if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { if (this->actor.textId == 0x332D) { - gSaveContext.weekEventReg[54] |= 0x10; + gSaveContext.save.weekEventReg[54] |= 0x10; this->actor.textId = 0x332E; } if (this->pathIndex == this->endPoint) { @@ -3305,7 +3306,7 @@ void func_80B4A9C8(Actor* thisx, GlobalContext* globalCtx) { s32 sp38; if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { - sp38 = gSaveContext.time; + sp38 = gSaveContext.save.time; this->actor.objBankIndex = this->bankIndex; Actor_SetObjectDependency(globalCtx, &this->actor); func_80B44F58(); @@ -3327,8 +3328,8 @@ void func_80B4A9C8(Actor* thisx, GlobalContext* globalCtx) { func_80B43F0C(this); func_800B4AEC(globalCtx, &this->actor, 50.0f); func_80B4516C(this); - if (gSaveContext.weekEventReg[21] & 0x20) { - if (gSaveContext.weekEventReg[54] & 0x10) { + if (gSaveContext.save.weekEventReg[21] & 0x20) { + if (gSaveContext.save.weekEventReg[54] & 0x10) { this->actor.textId = 0x332E; } else { this->actor.textId = 0x332D; @@ -3342,7 +3343,7 @@ void func_80B4A9C8(Actor* thisx, GlobalContext* globalCtx) { void func_80B4AB8C(Actor* thisx, GlobalContext* globalCtx) { EnInvadepoh* this = THIS; - if ((gSaveContext.time < CLOCK_TIME(6, 0)) && (gSaveContext.time >= CLOCK_TIME(2, 15))) { + if ((gSaveContext.save.time < CLOCK_TIME(6, 0)) && (gSaveContext.save.time >= CLOCK_TIME(2, 15))) { this->actor.update = func_80B4ABDC; this->actor.draw = func_80B4E324; func_80B4A614(this); @@ -3376,7 +3377,7 @@ void func_80B4ACDC(EnInvadepoh* this) { } void func_80B4ACF0(EnInvadepoh* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { this->actor.draw = func_80B4E324; this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80B4AD3C(this); @@ -3404,7 +3405,7 @@ void func_80B4ADB8(EnInvadepoh* this) { void func_80B4ADCC(EnInvadepoh* this, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x3331) { - if (gSaveContext.weekEventReg[22] & 2) { + if (gSaveContext.save.weekEventReg[22] & 2) { EnInvadepoh_SetTextID(this, globalCtx, 0x3334); func_80151BB4(globalCtx, 0x1D); func_80151BB4(globalCtx, 5); @@ -3436,7 +3437,7 @@ void func_80B4AEDC(EnInvadepoh* this, GlobalContext* globalCtx) { } if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - gSaveContext.weekEventReg[22] |= 2; + gSaveContext.save.weekEventReg[22] |= 2; func_80B4AF80(this); } else { Actor_PickUp(&this->actor, globalCtx, GI_MILK_BOTTLE, 2000.0f, 2000.0f); @@ -3791,7 +3792,7 @@ void func_80B4BC4C(EnInvadepoh* this, GlobalContext* globalCtx) { (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } - if (gSaveContext.time > CLOCK_TIME(20, 15)) { + if (gSaveContext.save.time > CLOCK_TIME(20, 15)) { Actor_MarkForDeath(&this->actor); } else if ((temp_t6 != NULL) && (temp_t6->actionFunc == func_80B4CB0C)) { func_80B4C1BC(this); @@ -3868,7 +3869,7 @@ void func_80B4C3A0(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { s32 pad[2]; - s32 currentTime = gSaveContext.time; + s32 currentTime = gSaveContext.save.time; this->actor.objBankIndex = this->bankIndex; Actor_SetObjectDependency(globalCtx, &this->actor); @@ -3904,7 +3905,7 @@ void func_80B4C3A0(Actor* thisx, GlobalContext* globalCtx) { void func_80B4C568(Actor* thisx, GlobalContext* globalCtx) { EnInvadepoh* this = THIS; - if ((gSaveContext.time >= 0xD573) && (gSaveContext.time < CLOCK_TIME(20, 15))) { + if ((gSaveContext.save.time >= 0xD573) && (gSaveContext.save.time < CLOCK_TIME(20, 15))) { this->actor.update = func_80B4C5C0; this->actor.draw = func_80B4E7BC; func_80B4BBE0(this); @@ -4089,7 +4090,7 @@ void func_80B4CE54(Actor* thisx, GlobalContext* globalCtx) { s32 sp38; if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { - sp38 = gSaveContext.time; + sp38 = gSaveContext.save.time; this->actor.objBankIndex = this->bankIndex; Actor_SetObjectDependency(globalCtx, &this->actor); @@ -4120,7 +4121,7 @@ void func_80B4CE54(Actor* thisx, GlobalContext* globalCtx) { void func_80B4CFFC(Actor* thisx, GlobalContext* globalCtx) { EnInvadepoh* this = THIS; - if ((gSaveContext.time >= CLOCK_TIME(20, 0)) && (gSaveContext.time < 0xD7E1)) { + if ((gSaveContext.save.time >= CLOCK_TIME(20, 0)) && (gSaveContext.save.time < 0xD7E1)) { this->actor.update = func_80B4D054; this->actor.draw = func_80B4E324; func_80B4C6C8(this); 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 7f6d53f60..392d8091e 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -291,7 +291,7 @@ void func_80BC2150(EnJa* this, GlobalContext* globalCtx) { } void func_80BC21A8(EnJa* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; + u32* unk_14 = &gSaveContext.save.daySpeed; struct_80133038_arg2 sp18; this->unk_35C = REG(15) + *unk_14; 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 216ce8f80..8bc5df4cc 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -493,14 +493,14 @@ void EnJg_Talk(EnJg* this, GlobalContext* globalCtx) { temp = this->textId; if ((temp == 0xDBB) || (temp == 0xDBC)) { - if (!(gSaveContext.weekEventReg[24] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[24] & 0x80)) { // The player hasn't talked to the Goron Child at least once, so they can't learn // the Lullaby Intro. End the current conversation with the player. globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->flags &= ~FLAG_LOOKING_AT_PLAYER; this->actionFunc = EnJg_SetupWalk; - } else if (((gSaveContext.weekEventReg[24] & 0x40)) || + } else if (((gSaveContext.save.weekEventReg[24] & 0x40)) || (CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO))) { // The player already has the Lullaby or Lullaby Intro, so say "I'm counting on you" this->textId = EnJg_GetNextTextId(this); @@ -700,7 +700,7 @@ void EnJg_LullabyIntroCutsceneAction(EnJg* this, GlobalContext* globalCtx) { } else { this->csAction = 99; this->freezeTimer = 1000; - gSaveContext.weekEventReg[24] |= 0x40; + gSaveContext.save.weekEventReg[24] |= 0x40; this->actionFunc = EnJg_Idle; } } @@ -830,7 +830,7 @@ s32 EnJg_GetNextTextId(EnJg* this) { return 0xDDC; // Everyone would accept you case 0xDDC: // Everyone would accept you - gSaveContext.weekEventReg[77] |= 0x80; + gSaveContext.save.weekEventReg[77] |= 0x80; return 0xDDD; // Think it over slowly default: @@ -848,7 +848,7 @@ s32 EnJg_GetStartingConversationTextId(EnJg* this, GlobalContext* globalCtx) { if (!EN_JG_IS_IN_GORON_SHRINE(&this->actor)) { if (player->transformation == PLAYER_FORM_GORON) { - if ((gSaveContext.weekEventReg[24] & 0x10) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) || + if ((gSaveContext.save.weekEventReg[24] & 0x10) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO)) { // The player has already talked as a Goron at least once. return 0xDBC; // Following me won't do you any good @@ -858,7 +858,7 @@ s32 EnJg_GetStartingConversationTextId(EnJg* this, GlobalContext* globalCtx) { return 0xDB6; // "Hunh???" } - if (gSaveContext.weekEventReg[24] & 0x20) { + if (gSaveContext.save.weekEventReg[24] & 0x20) { // The player has already talked as a non-Goron at least once. return 0xDB5; // This is our problem (repeat) } @@ -868,7 +868,7 @@ s32 EnJg_GetStartingConversationTextId(EnJg* this, GlobalContext* globalCtx) { } if (player->transformation == PLAYER_FORM_GORON) { - if (gSaveContext.weekEventReg[77] & 0x80) { + if (gSaveContext.save.weekEventReg[77] & 0x80) { // The player has heard the Goron Shrine cheer as a Goron at least once. return 0xDDE; // Come back after entering the race } @@ -908,9 +908,9 @@ void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, GlobalContext* if (this->textId == 0xDAC) { this->action = EN_JG_ACTION_FIRST_THAW; } else if (this->textId == 0xDAE) { - gSaveContext.weekEventReg[24] |= 0x20; + gSaveContext.save.weekEventReg[24] |= 0x20; } else if (this->textId == 0xDB6) { - gSaveContext.weekEventReg[24] |= 0x10; + gSaveContext.save.weekEventReg[24] |= 0x10; } Message_StartTextbox(globalCtx, this->textId, &this->actor); 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 586fe34cd..104e2bc3c 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 @@ -94,7 +94,7 @@ void EnJgameTsn_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.velocity.y = 0.0f; - if (gSaveContext.entranceIndex == 0x68D0) { + if (gSaveContext.save.entranceIndex == 0x68D0) { this->actor.flags |= ACTOR_FLAG_10000; } @@ -141,7 +141,7 @@ void EnJgameTsn_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnJgameTsn* this = THIS; Collider_DestroyCylinder(globalCtx, &this->collider); - gSaveContext.weekEventReg[90] &= (u8)~0x20; + gSaveContext.save.weekEventReg[90] &= (u8)~0x20; } void func_80C13B74(EnJgameTsn* this) { @@ -168,8 +168,8 @@ void func_80C13BB8(EnJgameTsn* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x10A3, &this->actor); this->unk_300 = 0x10A3; } - } else if (((gSaveContext.time > CLOCK_TIME(4, 0)) && (gSaveContext.time < CLOCK_TIME(7, 0))) || - ((gSaveContext.time > CLOCK_TIME(16, 0)) && (gSaveContext.time < CLOCK_TIME(19, 0)))) { + } else 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)))) { Message_StartTextbox(globalCtx, 0x1094, &this->actor); this->unk_300 = 0x1094; } else if (this->unk_2F8 == 0) { @@ -190,7 +190,7 @@ void func_80C13BB8(EnJgameTsn* this, GlobalContext* globalCtx) { } if ((player->actor.bgCheckFlags & 1) && !(player->stateFlags1 & 0x2000) && (this->unk_2FE == 0) && - (gSaveContext.playerForm == PLAYER_FORM_HUMAN) && func_80C149B0(globalCtx, &this->unk_1F8)) { + (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) && func_80C149B0(globalCtx, &this->unk_1F8)) { this->unk_2FE = 1; func_80C13E6C(this); } else if (!(player->actor.bgCheckFlags & 1)) { @@ -209,8 +209,8 @@ void func_80C13E6C(EnJgameTsn* this) { void func_80C13E90(EnJgameTsn* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - if (((gSaveContext.time > CLOCK_TIME(4, 0)) && (gSaveContext.time < CLOCK_TIME(7, 0))) || - ((gSaveContext.time > CLOCK_TIME(16, 0)) && (gSaveContext.time < CLOCK_TIME(19, 0)))) { + 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, sAnimations, 2); Message_StartTextbox(globalCtx, 0x1094, &this->actor); this->unk_300 = 0x1094; @@ -286,7 +286,7 @@ void func_80C1410C(EnJgameTsn* this, GlobalContext* globalCtx) { func_801A2BB8(0x25); globalCtx->interfaceCtx.unk_280 = 1; func_80112AFC(globalCtx); - gSaveContext.weekEventReg[90] |= 0x20; + gSaveContext.save.weekEventReg[90] |= 0x20; func_8010E9F0(4, 0x78); this->actionFunc = func_80C1418C; } @@ -379,11 +379,11 @@ void func_80C14540(EnJgameTsn* this) { void func_80C14554(EnJgameTsn* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { - if (!(gSaveContext.weekEventReg[82] & 0x10)) { - gSaveContext.weekEventReg[82] |= 0x10; + if (!(gSaveContext.save.weekEventReg[82] & 0x10)) { + gSaveContext.save.weekEventReg[82] |= 0x10; } func_80C145FC(this); - } else if (gSaveContext.weekEventReg[82] & 0x10) { + } else if (gSaveContext.save.weekEventReg[82] & 0x10) { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); @@ -407,7 +407,7 @@ void func_80C14610(EnJgameTsn* this, GlobalContext* globalCtx) { void func_80C14684(EnJgameTsn* this, GlobalContext* globalCtx) { if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { - if (gSaveContext.rupees >= 20) { + if (gSaveContext.save.playerData.rupees >= 20) { Message_StartTextbox(globalCtx, 0x109E, &this->actor); this->unk_300 = 0x109E; func_801159EC(-20); @@ -480,7 +480,7 @@ void func_80C147B4(EnJgameTsn* this, GlobalContext* globalCtx) { func_801477B4(globalCtx); gSaveContext.minigameState = 3; gSaveContext.unk_3DD0[4] = 5; - gSaveContext.weekEventReg[90] &= (u8)~0x20; + gSaveContext.save.weekEventReg[90] &= (u8)~0x20; func_80C144E4(this); break; 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 648542adf..c3194461d 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -176,14 +176,14 @@ void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx) { } if (this->aboveGroundStatus) { - if (gSaveContext.weekEventReg[79] & 8) { + if (gSaveContext.save.weekEventReg[79] & 8) { this->aboveGroundStatus = ENKAKASI_ABOVE_GROUND_TYPE; this->songSummonDist = 80.0f; EnKakasi_SetupIdleUnderground(this); } else { Actor_SetFocus(&this->actor, 60.0f); this->unkFunc = EnKakasi_8096F88C; - if (gSaveContext.weekEventReg[83] & 1) { + if (gSaveContext.save.weekEventReg[83] & 1) { EnKakasi_InitTimeSkipDialogue(this); } else { EnKakasi_SetupIdleStanding(this); @@ -302,13 +302,13 @@ void EnKakasi_TimeSkipDialogue(EnKakasi* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (gSaveContext.respawnFlag != -4 && gSaveContext.respawnFlag != -8) { - if (gSaveContext.time != CLOCK_TIME(6, 0) && gSaveContext.time != CLOCK_TIME(18, 0) && + if (gSaveContext.save.time != CLOCK_TIME(6, 0) && gSaveContext.save.time != CLOCK_TIME(18, 0) && !(gSaveContext.eventInf[1] & 0x80)) { if (this->actor.textId == 0) { // dialogue after skipped time 'did you feel that? went by in an instant' this->actor.textId = 0x1653; - gSaveContext.weekEventReg[83] &= (u8)~1; + gSaveContext.save.weekEventReg[83] &= (u8)~1; this->unkMsgState1AC = 5; player->stateFlags1 |= 0x20; this->actor.flags |= ACTOR_FLAG_10000; @@ -332,7 +332,7 @@ void EnKakasi_SetupIdleStanding(EnKakasi* this) { } void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx) { - u32 saveContextDay = gSaveContext.day; + u32 saveContextDay = gSaveContext.save.day; s16 x; s16 y; @@ -361,7 +361,7 @@ void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx) { EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); this->skelanime.playSpeed = 2.0f; } - } else if (saveContextDay == 3 && gSaveContext.isNight) { + } else if (saveContextDay == 3 && gSaveContext.save.isNight) { this->skelanime.playSpeed = 1.0f; if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { EnKakasi_SetAnimation(this, 1); @@ -388,7 +388,7 @@ void EnKakasi_SetupDialogue(EnKakasi* this) { } void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { - u32 saveContextDay = gSaveContext.day; + u32 saveContextDay = gSaveContext.save.day; f32 currentAnimeFrame = this->skelanime.curFrame; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 2000, 0); @@ -425,16 +425,16 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { // after timeskip if (this->actor.textId == 0x1653) { - u32 saveContextDay2 = gSaveContext.day; + u32 saveContextDay2 = gSaveContext.save.day; if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } - if (saveContextDay2 == 3 && gSaveContext.isNight) { + if (saveContextDay2 == 3 && gSaveContext.save.isNight) { // text: dangerous outside this->actor.textId = 0x164F; - } else if (gSaveContext.isNight) { + } else if (gSaveContext.save.isNight) { // text: would you like to skip time? this->actor.textId = 0x164E; } else { @@ -475,7 +475,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } - if (gSaveContext.isNight) { + if (gSaveContext.save.isNight) { this->actor.textId = 0x164E; } else { this->actor.textId = 0x1645; @@ -519,7 +519,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { this->actor.textId = 0x1658; } else if (this->actor.textId == 0x165C) { this->actor.textId = 0x165E; - } else if (saveContextDay == 3 && gSaveContext.isNight) { + } else if (saveContextDay == 3 && gSaveContext.save.isNight) { this->actor.textId = 0x164F; } else { this->actor.textId = 0x1652; @@ -788,7 +788,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { * talking before dancing the night away, and cutscene setup */ void EnKakasi_DancingRemark(EnKakasi* this, GlobalContext* globalCtx) { - u32 currentDay = gSaveContext.day; + u32 currentDay = gSaveContext.save.day; this->unkState196 = 3; if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -799,7 +799,7 @@ void EnKakasi_DancingRemark(EnKakasi* this, GlobalContext* globalCtx) { } else { ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); - if (currentDay == 3 && gSaveContext.isNight) { + if (currentDay == 3 && gSaveContext.save.isNight) { EnKakasi_SetupDigAway(this); } else { func_801A2BB8(NA_BGM_SARIAS_SONG); @@ -931,20 +931,20 @@ void EnKakasi_DancingNightAway(EnKakasi* this, GlobalContext* globalCtx) { if (this->unk204 == 0) { player = GET_PLAYER(globalCtx); - Play_SetRespawnData(&globalCtx->state, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF, - &player->unk_3C0, player->unk_3CC); + Play_SetRespawnData(&globalCtx->state, RESTART_MODE_DOWN, Entrance_CreateIndexFromSpawn(0), + player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); func_80169EFC(&globalCtx->state); if (0) {} - if (gSaveContext.time > CLOCK_TIME(18, 0) || gSaveContext.time < CLOCK_TIME(6, 0)) { - gSaveContext.time = CLOCK_TIME(6, 0); + if (gSaveContext.save.time > CLOCK_TIME(18, 0) || gSaveContext.save.time < CLOCK_TIME(6, 0)) { + gSaveContext.save.time = CLOCK_TIME(6, 0); gSaveContext.respawnFlag = -4; gSaveContext.eventInf[2] |= 0x80; } else { - gSaveContext.time = CLOCK_TIME(18, 0); + gSaveContext.save.time = CLOCK_TIME(18, 0); gSaveContext.respawnFlag = -8; } - gSaveContext.weekEventReg[83] |= 1; + gSaveContext.save.weekEventReg[83] |= 1; this->unk190 = 0; this->actionFunc = EnKakasi_DoNothing; } @@ -1013,7 +1013,7 @@ void EnKakasi_DiggingAway(EnKakasi* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.shape.yOffset, -6000.0f, 0.5f, 200.0f); if (fabsf(this->actor.shape.yOffset + 6000.0f) < 10.0f) { - gSaveContext.weekEventReg[79] |= 8; + gSaveContext.save.weekEventReg[79] |= 8; func_800B7298(globalCtx, &this->actor, 6); ActorCutscene_Stop(this->actorCutscenes[0]); this->aboveGroundStatus = ENKAKASI_ABOVE_GROUND_TYPE; @@ -1031,7 +1031,7 @@ void EnKakasi_SetupIdleUnderground(EnKakasi* this) { } void EnKakasi_IdleUnderground(EnKakasi* this, GlobalContext* globalCtx) { - if ((gSaveContext.weekEventReg[79] & 8) && this->actor.xzDistToPlayer < this->songSummonDist && + if ((gSaveContext.save.weekEventReg[79] & 8) && this->actor.xzDistToPlayer < this->songSummonDist && (BREG(1) != 0 || globalCtx->msgCtx.ocarinaMode == 0xD)) { this->actor.flags &= ~ACTOR_FLAG_8000000; globalCtx->msgCtx.ocarinaMode = 4; diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c index 849e3e1d6..33474cda5 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -991,7 +991,7 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { if ((this->actor.projectedPos.z <= 400.0f) && (this->actor.projectedPos.z > 0.0f) && (this->actor.floorHeight > -3000.0f) && ((this->bounceX != 0) || (this->bounceZ != 0))) { - u16 dayTime = gSaveContext.time; + u16 dayTime = gSaveContext.save.time; f32 shadowAlpha; if (dayTime >= CLOCK_TIME(12, 0)) { 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 afcaafbf3..9a42980db 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c @@ -71,12 +71,12 @@ void EnKbt_Destroy(Actor* thisx, GlobalContext* globalCtx) { } s32 func_80B33E64(GlobalContext* globalCtx) { - return gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1; + return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1; } s32 func_80B33E8C(GlobalContext* globalCtx) { if ((CURRENT_DAY == 3) || - ((CURRENT_DAY == 2) && (gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 2))) { + ((CURRENT_DAY == 2) && (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 2))) { return true; } return false; @@ -250,7 +250,7 @@ void func_80B34314(EnKbt* this, GlobalContext* globalCtx) { } else if (this->actor.xzDistToPlayer < 250.0f) { if ((this->unk_278 != NULL) && (this->unk_278->xzDistToPlayer < 250.0f)) { if (this->unk_27C & 4) { - playerForm = gSaveContext.playerForm; + playerForm = gSaveContext.save.playerForm; if (((playerForm ^ 0) != PLAYER_FORM_HUMAN) || ((CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_KOKIRI) && (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_RAZOR) && (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_GILDED))) { @@ -266,10 +266,10 @@ void func_80B34314(EnKbt* this, GlobalContext* globalCtx) { if (this->actor.textId != 0xC37) { if (((this->actor.textId == 0xC4E) || (this->actor.textId == 0xC4F) || (this->actor.textId == 0xC50)) && - (gSaveContext.playerForm != PLAYER_FORM_HUMAN)) { + (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN)) { this->actor.textId = 0xC37; } - } else if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { if (func_80B33E8C(globalCtx)) { this->actor.textId = 0xC50; } else { 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 973e4be9c..92053374a 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 @@ -109,7 +109,8 @@ void EnKendoJs_Init(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_js_Skel_006990, &object_js_Anim_000F4C, this->jointTable, this->morphTable, 13); - if ((CURRENT_DAY == 3) && !((gSaveContext.time <= CLOCK_TIME(23, 0)) && (gSaveContext.time >= CLOCK_TIME(6, 0)))) { + if ((CURRENT_DAY == 3) && + !((gSaveContext.save.time <= CLOCK_TIME(23, 0)) && (gSaveContext.save.time >= CLOCK_TIME(6, 0)))) { if (ENKENDOJS_GET_FF(&this->actor) != ENKENDOJS_FF_1) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_KANBAN, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z - 10.0f, this->actor.home.rot.x, @@ -145,7 +146,7 @@ void EnKendoJs_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnKendoJs* this = THIS; Collider_DestroyCylinder(globalCtx, &this->collider); - gSaveContext.weekEventReg[82] &= (u8)~8; + gSaveContext.save.weekEventReg[82] &= (u8)~8; } void func_80B26538(EnKendoJs* this) { @@ -166,8 +167,8 @@ void func_80B2654C(EnKendoJs* this, GlobalContext* globalCtx) { if (ENKENDOJS_GET_FF(&this->actor) == ENKENDOJS_FF_1) { Message_StartTextbox(globalCtx, 0x273C, &this->actor); this->unk_288 = 0x273C; - } else if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - switch (gSaveContext.playerForm) { + } else if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + switch (gSaveContext.save.playerForm) { case PLAYER_FORM_DEKU: phi_v0 = 0; break; @@ -215,12 +216,12 @@ void func_80B26758(EnKendoJs* this, GlobalContext* globalCtx) { if (Message_ShouldAdvance(globalCtx) && (this->unk_288 == 0x2716)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (CUR_EQUIP_VALUE_VOID(EQUIP_SWORD) == EQUIP_SWORD) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) == EQUIP_SWORD) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(globalCtx, 0x272C, &this->actor); this->unk_288 = 0x272C; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - } else if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + } else if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(globalCtx, 0x2718, &this->actor); this->unk_288 = 0x2718; @@ -233,12 +234,12 @@ void func_80B26758(EnKendoJs* this, GlobalContext* globalCtx) { break; case 1: - if (CUR_EQUIP_VALUE_VOID(EQUIP_SWORD) == EQUIP_SWORD) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) == EQUIP_SWORD) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(globalCtx, 0x272C, &this->actor); this->unk_288 = 0x272C; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - } else if (gSaveContext.rupees < globalCtx->msgCtx.unk12070) { + } else if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk12070) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(globalCtx, 0x2718, &this->actor); this->unk_288 = 0x2718; @@ -492,7 +493,7 @@ void func_80B27030(EnKendoJs* this, GlobalContext* globalCtx) { } void func_80B2714C(EnKendoJs* this) { - gSaveContext.weekEventReg[82] |= 8; + gSaveContext.save.weekEventReg[82] |= 8; this->unk_28C = 1; this->unk_290 = 0; this->unk_284 = 0; @@ -553,14 +554,14 @@ void func_80B27188(EnKendoJs* this, GlobalContext* globalCtx) { } if (this->unk_284 == 7) { - gSaveContext.weekEventReg[82] &= (u8)~8; + gSaveContext.save.weekEventReg[82] &= (u8)~8; func_80B26AE8(this); } } } void func_80B273D0(EnKendoJs* this) { - gSaveContext.weekEventReg[82] |= 8; + gSaveContext.save.weekEventReg[82] |= 8; this->unk_290 = 120; this->unk_284 = 0; this->unk_286 = 1; @@ -593,7 +594,7 @@ void func_80B274BC(EnKendoJs* this, GlobalContext* globalCtx) { this->unk_288 = 0x272E; } player->stateFlags1 |= 0x20; - gSaveContext.weekEventReg[82] &= (u8)~8; + gSaveContext.save.weekEventReg[82] &= (u8)~8; func_80B26AE8(this); return; } @@ -635,7 +636,7 @@ void func_80B276D8(EnKendoJs* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; func_80B27760(this); - } else if (!(gSaveContext.weekEventReg[63] & 0x20)) { + } else if (!(gSaveContext.save.weekEventReg[63] & 0x20)) { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 800.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 800.0f, 100.0f); @@ -650,8 +651,8 @@ void func_80B27774(EnKendoJs* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if (!(gSaveContext.weekEventReg[63] & 0x20)) { - gSaveContext.weekEventReg[63] |= 0x20; + if (!(gSaveContext.save.weekEventReg[63] & 0x20)) { + gSaveContext.save.weekEventReg[63] |= 0x20; Message_StartTextbox(globalCtx, 0x272F, &this->actor); this->unk_288 = 0x272F; } else { 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 f41ab8de3..176a556e5 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -60,10 +60,10 @@ void EnKgy_Init(Actor* thisx, GlobalContext* globalCtx) { this->zubora = EnKgy_FindZubora(globalCtx); this->iceBlock = EnKgy_FindIceBlock(globalCtx); Flags_UnsetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); - if (Flags_GetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor)) || (gSaveContext.weekEventReg[33] & 0x80)) { + if (Flags_GetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor)) || (gSaveContext.save.weekEventReg[33] & 0x80)) { Flags_SetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); globalCtx->envCtx.lightSettingOverride = 1; - gSaveContext.weekEventReg[21] |= 1; + gSaveContext.save.weekEventReg[21] |= 1; if (!func_80B40D64(globalCtx)) { EnKgy_ChangeAnim(this, 4, 0, 0); this->actionFunc = func_80B425A0; @@ -80,7 +80,7 @@ void EnKgy_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.textId = 0xC50; } } else { - if (gSaveContext.weekEventReg[20] & 0x80) { + if (gSaveContext.save.weekEventReg[20] & 0x80) { EnKgy_ChangeAnim(this, 4, 0, 0); } else { EnKgy_ChangeAnim(this, 0, 0, 0); @@ -153,33 +153,33 @@ ObjIcePoly* EnKgy_FindIceBlock(GlobalContext* globalCtx) { } void func_80B40C74(GlobalContext* globalCtx) { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 1; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 1; if (CURRENT_DAY == 1) { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 2; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 2; } else { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~2; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~2; } } void func_80B40D00(GlobalContext* globalCtx) { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 4; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 4; } void func_80B40D30(GlobalContext* globalCtx) { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~7; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~7; } s32 func_80B40D64(GlobalContext* globalCtx) { - return gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1; + return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1; } s32 func_80B40D8C(GlobalContext* globalCtx) { - return gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 4; + return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 4; } s32 func_80B40DB4(GlobalContext* globalCtx) { if ((CURRENT_DAY == 3) || - ((CURRENT_DAY == 2) && (gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 2))) { + ((CURRENT_DAY == 2) && (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 2))) { return true; } return false; @@ -362,7 +362,7 @@ void func_80B413C8(EnKgy* this) { } s32 func_80B41460(void) { - if ((gSaveContext.playerForm != PLAYER_FORM_HUMAN) || + if ((gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) || ((CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_KOKIRI) && (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_RAZOR) && (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_GILDED))) { return 0xC38; @@ -623,7 +623,7 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { case 0xC3B: switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (gSaveContext.rupees < globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { play_sound(NA_SE_SY_ERROR); func_80B40E74(this, globalCtx, 0xC3F); } else { @@ -1056,7 +1056,7 @@ void func_80B42D28(EnKgy* this, GlobalContext* globalCtx) { func_80B40BC0(this, 1); } else { EnKgy_ChangeAnim(this, 5, 2, -5.0f); - gSaveContext.weekEventReg[20] |= 0x80; + gSaveContext.save.weekEventReg[20] |= 0x80; } func_80B411DC(this, globalCtx, 0); func_80B40E18(this, this->actor.textId); @@ -1064,7 +1064,7 @@ void func_80B42D28(EnKgy* this, GlobalContext* globalCtx) { if (Flags_GetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor))) { this->actor.textId = 0xC30; this->actionFunc = func_80B4296C; - gSaveContext.weekEventReg[21] |= 1; + gSaveContext.save.weekEventReg[21] |= 1; } else if (this->actor.xzDistToPlayer < 200.0f) { if (this->unk_2D2 == 4) { this->actor.textId = 0xC2D; diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c index 2c15b22ba..f93851035 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c @@ -297,7 +297,7 @@ void EnLookNuts_SendPlayerToSpawn(EnLookNuts* this, GlobalContext* globalCtx) { gSaveContext.nextCutsceneIndex = 0; Scene_SetExitFade(globalCtx); globalCtx->sceneLoadFlag = 0x14; - gSaveContext.weekEventReg[17] |= 4; + gSaveContext.save.weekEventReg[17] |= 4; } } @@ -339,7 +339,7 @@ void EnLookNuts_Update(Actor* thisx, GlobalContext* globalCtx) { Matrix_StatePop(); if (!this->isPlayerDetected) { s16 drawFlag = 1; - if (gSaveContext.isNight) { + if (gSaveContext.save.isNight) { drawFlag = 0; } if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) { diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index 32c29db3f..031f2113f 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -202,7 +202,7 @@ void EnMa4_Init(Actor* thisx, GlobalContext* globalCtx) { if (CURRENT_DAY == 1) { this->type = MA4_TYPE_DAY1; - } else if (gSaveContext.weekEventReg[22] & 1) { // Aliens defeated + } else if (gSaveContext.save.weekEventReg[22] & 1) { // Aliens defeated this->type = MA4_TYPE_ALIENS_DEFEATED; } else { this->type = MA4_TYPE_ALIENS_WON; @@ -216,10 +216,10 @@ void EnMa4_Init(Actor* thisx, GlobalContext* globalCtx) { } else { EnMa4_InitPath(this, globalCtx); - if (gSaveContext.entranceIndex == 0x6410) { + if (gSaveContext.save.entranceIndex == 0x6410) { EnMa4_ChangeAnim(this, 0); this->state = MA4_STATE_AFTERHORSEBACKGAME; - } else if (gSaveContext.entranceIndex == 0x64A0) { + } else if (gSaveContext.save.entranceIndex == 0x64A0) { EnMa4_ChangeAnim(this, 0); this->state = MA4_STATE_AFTERDESCRIBETHEMCS; } else { @@ -240,7 +240,7 @@ void EnMa4_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnMa4* this = THIS; Collider_DestroyCylinder(globalCtx, &this->collider); - gSaveContext.weekEventReg[8] &= (u8)~1; + gSaveContext.save.weekEventReg[8] &= (u8)~1; } // Running in circles in the ranch @@ -374,7 +374,7 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3341: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - gSaveContext.weekEventReg[21] |= 0x20; + gSaveContext.save.weekEventReg[21] |= 0x20; Message_StartTextbox(globalCtx, 0x3343, &this->actor); this->textId = 0x3343; } else { @@ -390,7 +390,7 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3346: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - gSaveContext.weekEventReg[21] |= 0x20; + gSaveContext.save.weekEventReg[21] |= 0x20; Message_StartTextbox(globalCtx, 0x3343, &this->actor); this->textId = 0x3343; } else { @@ -605,7 +605,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { break; case 0x3358: - if ((gSaveContext.playerForm != PLAYER_FORM_HUMAN) || !(CHECK_QUEST_ITEM(QUEST_SONG_EPONA))) { + if ((gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) || !(CHECK_QUEST_ITEM(QUEST_SONG_EPONA))) { Message_StartTextbox(globalCtx, 0x335C, &this->actor); this->textId = 0x335C; func_80151BB4(globalCtx, 5); @@ -694,7 +694,7 @@ void EnMa4_InitHorsebackGame(EnMa4* this, GlobalContext* globalCtx) { globalCtx->interfaceCtx.unk_280 = 1; func_8010E9F0(4, 0); - gSaveContext.weekEventReg[8] |= 1; + gSaveContext.save.weekEventReg[8] |= 1; func_80112AFC(globalCtx); player->stateFlags1 |= 0x20; this->actionFunc = EnMa4_SetupHorsebackGameWait; @@ -730,7 +730,7 @@ void EnMa4_HorsebackGameWait(EnMa4* this, GlobalContext* globalCtx) { } void EnMa4_SetupHorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { - gSaveContext.weekEventReg[8] &= (u8)~1; + gSaveContext.save.weekEventReg[8] &= (u8)~1; this->actionFunc = EnMa4_HorsebackGameEnd; Audio_QueueSeqCmd(NA_BGM_STOP); Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000); @@ -876,8 +876,8 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { switch (this->type) { case MA4_TYPE_DAY1: - if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - if ((gSaveContext.weekEventReg[21] & 0x80)) { + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + if ((gSaveContext.save.weekEventReg[21] & 0x80)) { EnMa4_SetFaceExpression(this, 3, 3); Message_StartTextbox(globalCtx, 0x3337, &this->actor); this->textId = 0x3337; @@ -885,11 +885,11 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { } else { Message_StartTextbox(globalCtx, 0x3335, &this->actor); this->textId = 0x3335; - gSaveContext.weekEventReg[21] |= 0x80; + gSaveContext.save.weekEventReg[21] |= 0x80; } } else if (this->state == MA4_STATE_DEFAULT) { - if ((gSaveContext.weekEventReg[21] & 0x40)) { - if (!(gSaveContext.weekEventReg[21] & 0x20)) { + if ((gSaveContext.save.weekEventReg[21] & 0x40)) { + if (!(gSaveContext.save.weekEventReg[21] & 0x20)) { Message_StartTextbox(globalCtx, 0x3346, &this->actor); this->textId = 0x3346; } else { @@ -899,7 +899,7 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { } else { Message_StartTextbox(globalCtx, 0x3338, &this->actor); this->textId = 0x3338; - gSaveContext.weekEventReg[21] |= 0x40; + gSaveContext.save.weekEventReg[21] |= 0x40; } } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { @@ -909,9 +909,9 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { this->textId = 0x336D; } else { time = gSaveContext.unk_3DE0[4]; - if ((s32)time < (s32)gSaveContext.horseBackBalloonHighScore) { + if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { // [Score] New record! - gSaveContext.horseBackBalloonHighScore = time; + gSaveContext.save.horseBackBalloonHighScore = time; EnMa4_SetFaceExpression(this, 0, 3); Message_StartTextbox(globalCtx, 0x3350, &this->actor); this->textId = 0x3350; @@ -932,8 +932,8 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { break; case MA4_TYPE_ALIENS_DEFEATED: - if (gSaveContext.playerForm != PLAYER_FORM_HUMAN) { - if ((gSaveContext.weekEventReg[21] & 0x80)) { + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + if ((gSaveContext.save.weekEventReg[21] & 0x80)) { EnMa4_SetFaceExpression(this, 3, 3); Message_StartTextbox(globalCtx, 0x3337, &this->actor); this->textId = 0x3337; @@ -941,7 +941,7 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { } else { Message_StartTextbox(globalCtx, 0x3335, &this->actor); this->textId = 0x3335; - gSaveContext.weekEventReg[21] |= 0x80; + gSaveContext.save.weekEventReg[21] |= 0x80; } } else if (this->state == MA4_STATE_DEFAULT) { Message_StartTextbox(globalCtx, 0x3354, &this->actor); @@ -953,8 +953,8 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { this->textId = 0x3356; } else { time = gSaveContext.unk_3DE0[4]; - if ((s32)time < (s32)gSaveContext.horseBackBalloonHighScore) { - gSaveContext.horseBackBalloonHighScore = time; + if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { + gSaveContext.save.horseBackBalloonHighScore = time; EnMa4_SetFaceExpression(this, 0, 3); Message_StartTextbox(globalCtx, 0x3350, &this->actor); this->textId = 0x3350; @@ -980,9 +980,9 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { this->textId = 0x3356; } else { time = gSaveContext.unk_3DE0[4]; - if ((s32)time < (s32)gSaveContext.horseBackBalloonHighScore) { + if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { // New record - gSaveContext.horseBackBalloonHighScore = time; + gSaveContext.save.horseBackBalloonHighScore = time; Message_StartTextbox(globalCtx, 0x335D, &this->actor); this->textId = 0x335D; } else { diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c index 60edae403..bd92db4bc 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -146,7 +146,7 @@ void EnMaYto_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk320 = 0; this->eyeTexIndex = 0; - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYto_SetFaceExpression(this, 0, 1); } else { EnMaYto_SetFaceExpression(this, 5, 2); @@ -180,34 +180,34 @@ void EnMaYto_Init(Actor* thisx, GlobalContext* globalCtx) { s32 EnMaYto_CheckValidSpawn(EnMaYto* this, GlobalContext* globalCtx) { switch (this->type) { case MA_YTO_TYPE_DEFAULT: - if (CURRENT_DAY == 3 && !(gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 3 && !(gSaveContext.save.weekEventReg[22] & 1)) { return false; } break; case MA_YTO_TYPE_DINNER: - if (CURRENT_DAY != 1 && (gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY != 1 && (gSaveContext.save.weekEventReg[22] & 1)) { return false; } break; case MA_YTO_TYPE_BARN: - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { if (((this->actor.params & 0x0F00) >> 8) != 0) { return false; } } else if (((this->actor.params & 0x0F00) >> 8) == 0) { return false; } - if (gSaveContext.time >= CLOCK_TIME(20, 0) && CURRENT_DAY == 3) { + if (gSaveContext.save.time >= CLOCK_TIME(20, 0) && CURRENT_DAY == 3) { return false; } break; case MA_YTO_TYPE_AFTERMILKRUN: - // if (!(ProtectedCremia) && !(gSaveContext.weekEventReg[52] & 2)) || (PlayedMilkMinigame)) - if ((!(gSaveContext.weekEventReg[52] & 1) && !(gSaveContext.weekEventReg[52] & 2)) || - (gSaveContext.weekEventReg[14] & 1)) { + // if (!(ProtectedCremia) && !(gSaveContext.save.weekEventReg[52] & 2)) || (PlayedMilkMinigame)) + if ((!(gSaveContext.save.weekEventReg[52] & 1) && !(gSaveContext.save.weekEventReg[52] & 2)) || + (gSaveContext.save.weekEventReg[14] & 1)) { return false; } break; @@ -235,7 +235,7 @@ void EnMaYto_InitAnimation(EnMaYto* this, GlobalContext* globalCtx) { case MA_YTO_TYPE_BARN: // if (AliensDefeated) - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { EnMaYto_ChangeAnim(this, 12); } else { EnMaYto_ChangeAnim(this, 8); @@ -273,7 +273,7 @@ void EnMaYto_ChooseAction(EnMaYto* this, GlobalContext* globalCtx) { case MA_YTO_TYPE_AFTERMILKRUN: this->unk310 = 0; - if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI && (gSaveContext.weekEventReg[52] & 1) && + if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI && (gSaveContext.save.weekEventReg[52] & 1) && (Rand_Next() & 0x80)) { EnMaYto_SetupBeginWarmFuzzyFeelingCs(this); } else { @@ -328,7 +328,7 @@ s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx) { return 0; case MA_YTO_TYPE_DINNER: - if (!(gSaveContext.weekEventReg[22] & 1) && CURRENT_DAY == 2) { + if (!(gSaveContext.save.weekEventReg[22] & 1) && CURRENT_DAY == 2) { return 0; } if (EnMaYto_SearchRomani(this, globalCtx)) { @@ -338,7 +338,7 @@ s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx) { case MA_YTO_TYPE_BARN: // if (AliensDefeated) - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { if (EnMaYto_SearchRomani(this, globalCtx)) { return 2; } @@ -492,7 +492,7 @@ void EnMaYto_DefaultChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) } void EnMaYto_SetupDinnerWait(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { func_80B90E50(this, 0); this->unk31E = 0; } else { @@ -533,7 +533,7 @@ void EnMaYto_DinnerWait(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupDinnerDialogueHandler(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { func_80B90E50(this, 1); } else { func_80B90E50(this, 2); @@ -684,7 +684,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupBarnWait(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYto_ChangeAnim(this, 13); func_80B90E50(this, 0); this->unk31E = 0; @@ -712,7 +712,7 @@ void EnMaYto_BarnWait(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_BarnStartDialogue(this, globalCtx); EnMaYto_SetupBarnDialogueHandler(this); - } else if (!(gSaveContext.weekEventReg[22] & 1) || ABS_ALT(direction) < 0x2000) { + } else if (!(gSaveContext.save.weekEventReg[22] & 1) || ABS_ALT(direction) < 0x2000) { func_800B8614(&this->actor, globalCtx, 100.0f); child = this->actor.child; @@ -724,7 +724,7 @@ void EnMaYto_BarnWait(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupBarnDialogueHandler(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { func_80B90E50(this, 1); } else { func_80B90E50(this, 2); @@ -872,7 +872,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this) { - if (gSaveContext.weekEventReg[52] & 1) { // if (ProtectedCremia) + if (gSaveContext.save.weekEventReg[52] & 1) { // if (ProtectedCremia) EnMaYto_SetFaceExpression(this, 3, 1); } else { func_801A3098(NA_BGM_FAILURE_1); @@ -887,7 +887,7 @@ void EnMaYto_AfterMilkRunInit(EnMaYto* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - if (gSaveContext.weekEventReg[52] & 1) { // if (ProtectedCremia) + if (gSaveContext.save.weekEventReg[52] & 1) { // if (ProtectedCremia) Message_StartTextbox(globalCtx, 0x33C1, &this->actor); this->textId = 0x33C1; } else { @@ -896,7 +896,7 @@ void EnMaYto_AfterMilkRunInit(EnMaYto* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x33C0, &this->actor); this->textId = 0x33C0; // Attempted Cremia Cart Ride - gSaveContext.weekEventReg[14] |= 1; + gSaveContext.save.weekEventReg[14] |= 1; this->unk310 = 4; EnMaYto_SetupPostMilkRunWaitDialogueEnd(this); func_80151BB4(globalCtx, 6); @@ -978,7 +978,7 @@ void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x33C3, &this->actor); this->textId = 0x33C3; // Attempted Cremia Cart Ride - gSaveContext.weekEventReg[14] |= 1; + gSaveContext.save.weekEventReg[14] |= 1; this->unk310 = 3; func_80151BB4(globalCtx, 0x20); func_80151BB4(globalCtx, 0x1F); @@ -990,7 +990,7 @@ void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x33D0, &this->actor); this->textId = 0x33D0; // Attempted Cremia Cart Ride - gSaveContext.weekEventReg[14] |= 1; + gSaveContext.save.weekEventReg[14] |= 1; this->unk310 = 3; func_80151BB4(globalCtx, 6); EnMaYto_SetupPostMilkRunWaitDialogueEnd(this); @@ -1041,7 +1041,7 @@ void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx) { case 2: // Attempted Cremia Cart Ride - gSaveContext.weekEventReg[14] |= 1; + gSaveContext.save.weekEventReg[14] |= 1; EnMaYto_ChangeAnim(this, 18); break; @@ -1099,7 +1099,7 @@ void EnMaYto_PostMilkRunEnd(EnMaYto* this, GlobalContext* globalCtx) { void EnMaYto_DefaultStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { if (CURRENT_DAY == 1) { - if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE && gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE && gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { switch (Player_GetMask(globalCtx)) { case PLAYER_MASK_ROMANI: Message_StartTextbox(globalCtx, 0x235D, &this->actor); @@ -1158,7 +1158,7 @@ void EnMaYto_DefaultStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { switch (CURRENT_DAY) { case 1: - if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE && gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE && gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { switch (Player_GetMask(globalCtx)) { case PLAYER_MASK_ROMANI: Message_StartTextbox(globalCtx, 0x235D, &this->actor); @@ -1225,7 +1225,7 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { void EnMaYto_BarnStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { // if (AliensDefeated) - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { if (CURRENT_DAY == 2) { if (this->unk310 == 1) { Message_StartTextbox(globalCtx, 0x33AE, &this->actor); @@ -1348,7 +1348,7 @@ void EnMaYto_SetFaceExpression(EnMaYto* this, s16 overrideEyeTexIndex, s16 mouth } void EnMaYto_InitFaceExpression(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYto_SetFaceExpression(this, 0, 1); EnMaYto_SetRomaniFaceExpression(this, 0, 0); } else { @@ -1360,19 +1360,19 @@ void EnMaYto_InitFaceExpression(EnMaYto* this) { s32 EnMaYto_HasSpokeToPlayerToday(void) { switch (CURRENT_DAY) { case 1: - if (gSaveContext.weekEventReg[13] & 4) { + if (gSaveContext.save.weekEventReg[13] & 4) { return true; } break; case 2: - if (gSaveContext.weekEventReg[13] & 8) { + if (gSaveContext.save.weekEventReg[13] & 8) { return true; } break; case 3: - if (gSaveContext.weekEventReg[13] & 0x10) { + if (gSaveContext.save.weekEventReg[13] & 0x10) { return true; } break; @@ -1384,17 +1384,17 @@ s32 EnMaYto_HasSpokeToPlayer(void) { // Please note each case doesn't have their respective `break`s. switch (CURRENT_DAY) { case 3: - if (gSaveContext.weekEventReg[13] & 0x10) { + if (gSaveContext.save.weekEventReg[13] & 0x10) { return true; } case 2: - if (gSaveContext.weekEventReg[13] & 8) { + if (gSaveContext.save.weekEventReg[13] & 8) { return true; } case 1: - if (gSaveContext.weekEventReg[13] & 4) { + if (gSaveContext.save.weekEventReg[13] & 4) { return true; } } @@ -1404,15 +1404,15 @@ s32 EnMaYto_HasSpokeToPlayer(void) { void EnMaYto_SetTalkedFlag(void) { switch (CURRENT_DAY) { case 1: - gSaveContext.weekEventReg[13] |= 4; + gSaveContext.save.weekEventReg[13] |= 4; break; case 2: - gSaveContext.weekEventReg[13] |= 8; + gSaveContext.save.weekEventReg[13] |= 8; break; case 3: - gSaveContext.weekEventReg[13] |= 0x10; + gSaveContext.save.weekEventReg[13] |= 0x10; break; } } @@ -1464,7 +1464,7 @@ void EnMaYto_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx); - if (this->type == MA_YTO_TYPE_BARN && (gSaveContext.weekEventReg[22] & 1)) { // Aliens defeated + if (this->type == MA_YTO_TYPE_BARN && (gSaveContext.save.weekEventReg[22] & 1)) { // Aliens defeated gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gCremiaWoodenBox); } diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c index f1bd0d773..29eb6cdcc 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c @@ -145,7 +145,7 @@ void EnMaYts_InitAnimation(EnMaYts* this, GlobalContext* globalCtx) { case MA_YTS_TYPE_SITTING: this->actor.targetMode = 6; // Day 1 or "Winning" the alien invasion - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYts_ChangeAnim(this, 14); } else { EnMaYts_ChangeAnim(this, 18); @@ -178,14 +178,14 @@ s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { case 2: // Failing the alien invasion - if (!(gSaveContext.weekEventReg[22] & 1)) { + if (!(gSaveContext.save.weekEventReg[22] & 1)) { return false; } break; case 3: // "Winning" the alien invasion - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { return false; } break; @@ -194,16 +194,16 @@ s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { case MA_YTS_TYPE_BARN: // Failing the alien invasion - if (!(gSaveContext.weekEventReg[22] & 1)) { + if (!(gSaveContext.save.weekEventReg[22] & 1)) { return false; - } else if (gSaveContext.time >= CLOCK_TIME(20, 0) && CURRENT_DAY == 3) { + } else if (gSaveContext.save.time >= CLOCK_TIME(20, 0) && CURRENT_DAY == 3) { return false; } break; case MA_YTS_TYPE_SLEEPING: // "Winning" the alien invasion - if (gSaveContext.weekEventReg[22] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { return false; } break; @@ -250,7 +250,7 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { this->hasBow = false; } - if (CURRENT_DAY == 1 || (gSaveContext.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { this->overrideEyeTexIndex = 0; this->eyeTexIndex = 0; this->mouthTexIndex = 0; @@ -268,7 +268,7 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { this->mouthTexIndex = 0; this->unk_32C = 2; EnMaYts_SetupEndCreditsHandler(this); - } else if (CURRENT_DAY == 2 && gSaveContext.isNight == 1 && (gSaveContext.weekEventReg[22] & 1)) { + } else if (CURRENT_DAY == 2 && gSaveContext.save.isNight == 1 && (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYts_SetupStartDialogue(this); } else { EnMaYts_SetupDoNothing(this); @@ -297,10 +297,10 @@ void EnMaYts_StartDialogue(EnMaYts* this, GlobalContext* globalCtx) { s16 sp26 = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if (!(gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { - if (!(gSaveContext.weekEventReg[65] & 0x80)) { + if (!(gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { + if (!(gSaveContext.save.weekEventReg[65] & 0x80)) { // Saying to non-human Link: "Cremia went to town." - gSaveContext.weekEventReg[65] |= 0x80; + gSaveContext.save.weekEventReg[65] |= 0x80; EnMaYts_SetFaceExpression(this, 0, 0); Message_StartTextbox(globalCtx, 0x335F, &this->actor); this->textId = 0x335F; @@ -312,8 +312,8 @@ void EnMaYts_StartDialogue(EnMaYts* this, GlobalContext* globalCtx) { func_80151BB4(globalCtx, 5); } } else if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE) { - if (!(gSaveContext.weekEventReg[65] & 0x40)) { - gSaveContext.weekEventReg[65] |= 0x40; + if (!(gSaveContext.save.weekEventReg[65] & 0x40)) { + gSaveContext.save.weekEventReg[65] |= 0x40; EnMaYts_SetFaceExpression(this, 0, 0); Message_StartTextbox(globalCtx, 0x3363, &this->actor); this->textId = 0x3363; @@ -323,14 +323,14 @@ void EnMaYts_StartDialogue(EnMaYts* this, GlobalContext* globalCtx) { this->textId = 0x3366; func_80151BB4(globalCtx, 5); } - } else if (!(gSaveContext.weekEventReg[21] & 0x20)) { + } else if (!(gSaveContext.save.weekEventReg[21] & 0x20)) { EnMaYts_SetFaceExpression(this, 0, 0); Message_StartTextbox(globalCtx, 0x3367, &this->actor); this->textId = 0x3367; } else { - if (!(gSaveContext.weekEventReg[65] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[65] & 0x20)) { // Saying to Grasshopper: "Cremia went to town." - gSaveContext.weekEventReg[65] |= 0x20; + gSaveContext.save.weekEventReg[65] |= 0x20; EnMaYts_SetFaceExpression(this, 4, 2); Message_StartTextbox(globalCtx, 0x3369, &this->actor); this->textId = 0x3369; diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c index 9e6b3e9e9..907ba619b 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -162,7 +162,7 @@ void EnMag_Init(Actor* thisx, GlobalContext* globalCtx) { this->state = MAG_STATE_FADE_IN_MASK; sInputDelayTimer = 20; gSaveContext.fadeDuration = 1; - gSaveContext.unk_3F51 = 255; + gSaveContext.fadeSpeed = 255; } Font_LoadOrderedFont(&this->font); @@ -246,7 +246,7 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk11F02 = 30; sInputDelayTimer = 20; gSaveContext.fadeDuration = 1; - gSaveContext.unk_3F51 = 255; + gSaveContext.fadeSpeed = 255; } } } else { @@ -392,7 +392,7 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { globalCtx->sceneLoadFlag = 0x14; globalCtx->unk_1887F = 2; globalCtx->nextEntranceIndex = 0x1C00; - gSaveContext.cutscene = 0; + gSaveContext.save.cutscene = 0; gSaveContext.sceneSetupIndex = 0; } this->unk11F54 = 15; diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index 8b6fc45e8..27192800e 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -66,7 +66,7 @@ static TexturePtr D_808A4D74[] = { object_fr_Tex_005BA0, }; -// gSaveContext.weekEventReg[KEY] = VALUE +// gSaveContext.save.weekEventReg[KEY] = VALUE // KEY | VALUE static u16 isFrogReturnedFlags[] = { (0 << 8) | 0x00, // NULL @@ -114,7 +114,7 @@ void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx) { if (1) {} if (!EN_MINIFROG_IS_RETURNED(this)) { if ((this->frogIndex == MINIFROG_YELLOW) || - ((gSaveContext.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] & + ((gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] & (u8)isFrogReturnedFlags[this->frogIndex]))) { Actor_MarkForDeath(&this->actor); } else { @@ -129,7 +129,7 @@ void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = EnMinifrog_SetupYellowFrogDialog; // Not spoken to MINIFROG_YELLOW - if (!(gSaveContext.weekEventReg[34] & 1)) { + if (!(gSaveContext.save.weekEventReg[34] & 1)) { this->actor.flags |= ACTOR_FLAG_10000; } @@ -140,7 +140,7 @@ void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; // Frog has been returned - if ((gSaveContext.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] & + if ((gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] & (u8)isFrogReturnedFlags[this->frogIndex])) { this->actionFunc = EnMinifrog_SetupNextFrogInit; } else { @@ -270,15 +270,15 @@ void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, GlobalContext* globalCtx) { case 0xD87: // "Ah! You need not say a thing. Upon seeing that face, I understand!" ... func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; - case 0xD82: // "What has brought you all this way?" - if (gSaveContext.weekEventReg[33] & 0x80) { // Mountain village is unfrozen + case 0xD82: // "What has brought you all this way?" + if (gSaveContext.save.weekEventReg[33] & 0x80) { // Mountain village is unfrozen func_80151938(globalCtx, 0xD83); // "Could it be... Has spring finally come to the mountains?" } else { func_80151938(globalCtx, 0xD86); // "Could it be... You came all this way looking for me?" } - flag = gSaveContext.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8]; - gSaveContext.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] = + flag = gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8]; + gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] = flag | (u8)isFrogReturnedFlags[this->frogIndex]; break; case 0xD85: // "I understand. I shall head for the mountains immediately." @@ -518,7 +518,7 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { // you've lost a little weight..." func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); this->actor.flags &= ~ACTOR_FLAG_10000; - gSaveContext.weekEventReg[34] |= 1; // Spoken to MINIFROG_YELLOW + gSaveContext.save.weekEventReg[34] |= 1; // Spoken to MINIFROG_YELLOW break; case 0xD78: // "Unfortunately, it seems not all of our members have gathered." case 0xD79: // "Perhaps it is because winter was too long? They must not have realized that spring @@ -532,11 +532,11 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { globalCtx->msgCtx.unk11F10 = 0; break; case 0xD7C: // "The conducting was spectacular. And all of our members rose to the occasion!" - if (gSaveContext.weekEventReg[35] & 0x80) { // Obtained Heart Piece + if (gSaveContext.save.weekEventReg[35] & 0x80) { // Obtained Heart Piece func_80151938(globalCtx, 0xD7E); } else { func_80151938(globalCtx, 0xD7D); // Get Heart Piece - gSaveContext.weekEventReg[35] |= 0x80; + gSaveContext.save.weekEventReg[35] |= 0x80; } break; case 0xD7D: // "This is how deeply we were moved by your spectacular conducting..." @@ -564,7 +564,7 @@ void EnMinifrog_SetupYellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx EnMinifrog_JumpTimer(this); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = EnMinifrog_YellowFrogDialog; - if (!(gSaveContext.weekEventReg[34] & 1)) { // Not spoken with MINIFROG_YELLOW + if (!(gSaveContext.save.weekEventReg[34] & 1)) { // Not spoken with MINIFROG_YELLOW Message_StartTextbox(globalCtx, 0xD76, &this->actor); // "I have been waiting for you, Don Gero. Forgive me if I'm mistaken, // but it looks like you've lost a little weight..." 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 062a75a12..8c20b4106 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -120,7 +120,7 @@ void EnMk_Destroy(Actor* thisx, GlobalContext* globalCtx) { } s32 func_80959524(GlobalContext* globalCtx) { - return gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 7; + return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 7; } void func_8095954C(EnMk* this, GlobalContext* globalCtx) { @@ -145,10 +145,10 @@ void func_8095954C(EnMk* this, GlobalContext* globalCtx) { void func_80959624(EnMk* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { if (this->unk_27A & 4) { textId = 0xFB9; - } else if (gSaveContext.weekEventReg[55] & 0x80) { + } else if (gSaveContext.save.weekEventReg[55] & 0x80) { textId = 0xFBC; } else { textId = 0xFBB; @@ -203,17 +203,17 @@ void func_80959844(EnMk* this, GlobalContext* globalCtx) { if ((this->unk_27A & 2) && (func_80959524(globalCtx) >= 7)) { textId = 0xFB3; - } else if (gSaveContext.weekEventReg[20] & 0x40) { + } else if (gSaveContext.save.weekEventReg[20] & 0x40) { textId = 0xFB9; - } else if (gSaveContext.weekEventReg[19] & 0x40) { + } else if (gSaveContext.save.weekEventReg[19] & 0x40) { textId = 0xFB5; } else if (func_80959524(globalCtx) >= 7) { textId = 0xFB3; } else { - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case PLAYER_FORM_DEKU: - if (gSaveContext.weekEventReg[19] & 0x10) { - if (gSaveContext.weekEventReg[55] & 0x80) { + if (gSaveContext.save.weekEventReg[19] & 0x10) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { textId = 0xFAF; } else { textId = 0xFAE; @@ -224,8 +224,8 @@ void func_80959844(EnMk* this, GlobalContext* globalCtx) { break; case PLAYER_FORM_GORON: - if (gSaveContext.weekEventReg[19] & 8) { - if (gSaveContext.weekEventReg[55] & 0x80) { + if (gSaveContext.save.weekEventReg[19] & 8) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { textId = 0xFAB; } else { textId = 0xFAA; @@ -239,8 +239,8 @@ void func_80959844(EnMk* this, GlobalContext* globalCtx) { case PLAYER_FORM_HUMAN: if (func_80959524(globalCtx) > 0) { textId = 0xFA7; - } else if (gSaveContext.weekEventReg[19] & 4) { - if (gSaveContext.weekEventReg[55] & 0x80) { + } else if (gSaveContext.save.weekEventReg[19] & 4) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { textId = 0xFBF; } else { textId = 0xFA6; @@ -253,7 +253,7 @@ void func_80959844(EnMk* this, GlobalContext* globalCtx) { default: if (func_80959524(globalCtx) > 0) { textId = 0xFB0; - } else if (gSaveContext.weekEventReg[19] & 0x20) { + } else if (gSaveContext.save.weekEventReg[19] & 0x20) { textId = 0xFB2; } else { textId = 0xFB1; @@ -284,7 +284,7 @@ void func_80959A24(EnMk* this, GlobalContext* globalCtx) { break; case 0xFA2: - if (gSaveContext.weekEventReg[55] & 0x80) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { func_801477B4(globalCtx); this->actionFunc = func_80959E18; break; @@ -309,13 +309,13 @@ void func_80959A24(EnMk* this, GlobalContext* globalCtx) { break; case 0xFA0: - gSaveContext.weekEventReg[19] |= 4; + gSaveContext.save.weekEventReg[19] |= 4; func_80151938(globalCtx, 0xFA1); break; case 0xFA8: - gSaveContext.weekEventReg[19] |= 8; - if (gSaveContext.weekEventReg[55] & 0x80) { + gSaveContext.save.weekEventReg[19] |= 8; + if (gSaveContext.save.weekEventReg[55] & 0x80) { func_80151938(globalCtx, 0xFBD); break; } @@ -323,8 +323,8 @@ void func_80959A24(EnMk* this, GlobalContext* globalCtx) { break; case 0xFAC: - gSaveContext.weekEventReg[19] |= 0x10; - if (gSaveContext.weekEventReg[55] & 0x80) { + gSaveContext.save.weekEventReg[19] |= 0x10; + if (gSaveContext.save.weekEventReg[55] & 0x80) { func_80151938(globalCtx, 0xFBE); break; } @@ -332,7 +332,7 @@ void func_80959A24(EnMk* this, GlobalContext* globalCtx) { break; case 0xFB1: - gSaveContext.weekEventReg[19] |= 0x20; + gSaveContext.save.weekEventReg[19] |= 0x20; func_801477B4(globalCtx); this->actionFunc = func_80959E18; break; @@ -374,7 +374,7 @@ void func_80959D28(EnMk* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if ((globalCtx->csCtx.state == 0) && (this->actor.cutscene == -1)) { - if (gSaveContext.weekEventReg[20] & 0x40) { + if (gSaveContext.save.weekEventReg[20] & 0x40) { this->unk_27A &= ~1; this->actionFunc = func_80959774; this->actor.home.rot.y += 0x4E20; @@ -402,7 +402,7 @@ void func_80959E18(EnMk* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (gSaveContext.weekEventReg[20] & 0x40) { + if (gSaveContext.save.weekEventReg[20] & 0x40) { this->unk_27A &= ~1; this->actionFunc = func_80959774; this->actor.home.rot.y += 0x4E20; @@ -412,9 +412,9 @@ void func_80959E18(EnMk* this, GlobalContext* globalCtx) { if (func_800B8718(&this->actor, &globalCtx->state)) { globalCtx->msgCtx.ocarinaMode = 4; this->actionFunc = func_80959D28; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { this->actor.cutscene = this->unk_276[0]; - gSaveContext.weekEventReg[20] |= 0x40; + gSaveContext.save.weekEventReg[20] |= 0x40; Item_Give(globalCtx, ITEM_SONG_NOVA); } else { this->actor.cutscene = this->unk_276[1]; @@ -429,7 +429,7 @@ void func_80959E18(EnMk* this, GlobalContext* globalCtx) { } else if ((this->actor.xzDistToPlayer < 120.0f) && (ABS_ALT(sp22) <= 0x4300)) { this->unk_27A |= 1; func_800B8614(&this->actor, globalCtx, 200.0f); - if (!(gSaveContext.weekEventReg[20] & 0x40) && (gSaveContext.weekEventReg[19] & 0x40)) { + if (!(gSaveContext.save.weekEventReg[20] & 0x40) && (gSaveContext.save.weekEventReg[19] & 0x40)) { func_800B874C(&this->actor, globalCtx, 200.0f, 100.0f); } } else { diff --git a/src/overlays/actors/ovl_En_Mm/z_en_mm.c b/src/overlays/actors/ovl_En_Mm/z_en_mm.c index dfb69be0f..5f79cf9e4 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -74,8 +74,8 @@ void EnMm_Init(Actor* thisx, GlobalContext* globalCtx) { EnMm* this = THIS; EnMmActionFunc action; - if ((this->actor.params >= 0) && ((!(gSaveContext.weekEventReg[37] & 0x10)) || - (gSaveContext.weekEventReg[37] & 8) || (gSaveContext.unk_1014 != 0))) { + if ((this->actor.params >= 0) && ((!(gSaveContext.save.weekEventReg[37] & 0x10)) || + (gSaveContext.save.weekEventReg[37] & 8) || (gSaveContext.unk_1014 != 0))) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index e6024c79a..396a3f040 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -102,7 +102,7 @@ void EnMm3_Init(Actor* thisx, GlobalContext* globalCtx) { void EnMm3_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnMm3* this = THIS; - gSaveContext.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~1; Collider_DestroyCylinder(globalCtx, &this->collider); } @@ -144,7 +144,7 @@ void func_80A6F3B4(EnMm3* this, GlobalContext* globalCtx) { case 0x278E: if (globalCtx->msgCtx.choiceIndex == 0) { if (this->unk_2B2 & 0x20) { - if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { func_8019F208(); Message_StartTextbox(globalCtx, 0x2790, &this->actor); this->unk_2B4 = 0x2790; @@ -170,7 +170,7 @@ void func_80A6F3B4(EnMm3* this, GlobalContext* globalCtx) { case 0x279A: if (globalCtx->msgCtx.choiceIndex == 0) { - if (gSaveContext.rupees >= globalCtx->msgCtx.unk1206C) { + if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { func_8019F208(); Message_StartTextbox(globalCtx, 0x2790, &this->actor); this->unk_2B4 = 0x2790; @@ -274,7 +274,7 @@ void func_80A6F5E4(EnMm3* this, GlobalContext* globalCtx) { case 0x2795: case 0x2796: case 0x2797: - if (gSaveContext.weekEventReg[63] & 2) { + if (gSaveContext.save.weekEventReg[63] & 2) { Message_StartTextbox(globalCtx, 0x279B, &this->actor); this->unk_2B4 = 0x279B; func_80151BB4(globalCtx, 0xB); @@ -346,8 +346,8 @@ void func_80A6F9DC(EnMm3* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_START_SHOT); func_80A6FBA0(this); } else { - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; func_80A6F270(this); } } @@ -368,8 +368,8 @@ void func_80A6F9DC(EnMm3* this, GlobalContext* globalCtx) { void func_80A6FBA0(EnMm3* this) { func_801A5BD0(0x6F); func_801A0238(0, 5); - gSaveContext.weekEventReg[63] |= 1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->actionFunc = func_80A6FBFC; } @@ -424,12 +424,12 @@ void func_80A6FE1C(EnMm3* this) { void func_80A6FE30(EnMm3* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { - if (!(gSaveContext.weekEventReg[77] & 1)) { - gSaveContext.weekEventReg[77] |= 1; + if (!(gSaveContext.save.weekEventReg[77] & 1)) { + gSaveContext.save.weekEventReg[77] |= 1; } this->actor.parent = NULL; func_80A6FED8(this); - } else if (gSaveContext.weekEventReg[77] & 1) { + } else if (gSaveContext.save.weekEventReg[77] & 1) { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); @@ -457,7 +457,7 @@ void func_80A6FEEC(EnMm3* this, GlobalContext* globalCtx) { } s32 func_80A6FFAC(EnMm3* this, GlobalContext* globalCtx) { - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case 4: if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { if (this->unk_2B2 & 0x10) { @@ -491,7 +491,7 @@ s32 func_80A6FFAC(EnMm3* this, GlobalContext* globalCtx) { } void func_80A70084(EnMm3* this, GlobalContext* globalCtx) { - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case 4: if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { this->unk_2B2 |= 0x10; diff --git a/src/overlays/actors/ovl_En_Ms/z_en_ms.c b/src/overlays/actors/ovl_En_Ms/z_en_ms.c index 4497b7945..729e36d49 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.c @@ -83,7 +83,7 @@ void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnMs_Wait(EnMs* this, GlobalContext* globalCtx) { s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (gSaveContext.inventory.items[SLOT_MAGIC_BEANS] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[SLOT_MAGIC_BEANS] == ITEM_NONE) { this->actor.textId = 0x92E; // "[...] You're the first customer [...]" } else { this->actor.textId = 0x932; // "[...] So you liked my Magic Beans [...]" @@ -118,7 +118,7 @@ void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { switch (globalCtx->msgCtx.choiceIndex) { case 0: // yes func_801477B4(globalCtx); - if (gSaveContext.rupees < 10) { + if (gSaveContext.save.playerData.rupees < 10) { play_sound(NA_SE_SY_ERROR); func_80151938(globalCtx, 0x935); // "[...] You don't have enough Rupees." } else if (AMMO(ITEM_MAGIC_BEANS) >= 20) { diff --git a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c index 2a20e8135..6952f10c2 100644 --- a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c +++ b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c @@ -234,7 +234,7 @@ s32 EnMttag_UpdateCheckpoints(EnMttag* this, GlobalContext* globalCtx) { s32 EnMttag_ExitRace(GlobalContext* globalCtx, s32 arg1, s32 nextTransition) { CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; globalCtx->nextEntranceIndex = 0xD020; - if ((gSaveContext.weekEventReg[33] & 0x80)) { + if ((gSaveContext.save.weekEventReg[33] & 0x80)) { // Spring gSaveContext.nextCutsceneIndex = 0xFFF0; } else { @@ -288,7 +288,7 @@ void EnMttag_ShowIntroCutscene(EnMttag* this, GlobalContext* globalCtx) { */ void EnMttag_WaitForIntroCutsceneToEnd(EnMttag* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { - gSaveContext.weekEventReg[12] |= 2; + gSaveContext.save.weekEventReg[12] |= 2; this->actionFunc = EnMttag_RaceStart; } } @@ -420,7 +420,7 @@ void EnMttag_PotentiallyRestartRace(EnMttag* this, GlobalContext* globalCtx) { if (this->shouldRestartRace) { globalCtx->nextEntranceIndex = 0xD010; - if (gSaveContext.weekEventReg[33] & 0x80) { + if (gSaveContext.save.weekEventReg[33] & 0x80) { // Spring gSaveContext.nextCutsceneIndex = 0xFFF0; } else { @@ -433,7 +433,8 @@ void EnMttag_PotentiallyRestartRace(EnMttag* this, GlobalContext* globalCtx) { gSaveContext.nextTransition = 2; func_801477B4(globalCtx); func_800B7298(globalCtx, &this->actor, 7); - Parameter_AddMagic(globalCtx, ((void)0, gSaveContext.unk_3F30) + (gSaveContext.doubleMagic * 48) + 48); + Parameter_AddMagic(globalCtx, + ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 48) + 48); gSaveContext.eventInf[1] &= (u8)~1; gSaveContext.eventInf[1] &= (u8)~2; @@ -477,7 +478,7 @@ void EnMttag_Init(Actor* thisx, GlobalContext* globalCtx) { Player* player; EnMttag* this = THIS; - if (gSaveContext.entranceIndex == 0xD010) { + if (gSaveContext.save.entranceIndex == 0xD010) { player = GET_PLAYER(globalCtx); player->stateFlags1 |= 0x20; this->raceInitialized = false; @@ -488,7 +489,7 @@ void EnMttag_Init(Actor* thisx, GlobalContext* globalCtx) { gSaveContext.eventInf[1] &= (u8)~4; gSaveContext.eventInf[1] &= (u8)~8; - if (!(gSaveContext.weekEventReg[12] & 2)) { + if (!(gSaveContext.save.weekEventReg[12] & 2)) { this->actionFunc = EnMttag_ShowIntroCutscene; } else { s32 requiredScopeTemp; diff --git a/src/overlays/actors/ovl_En_Muto/z_en_muto.c b/src/overlays/actors/ovl_En_Muto/z_en_muto.c index b8e4750a7..4aed3132f 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.c +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.c @@ -70,11 +70,11 @@ void EnMuto_Init(Actor* thisx, GlobalContext* globalCtx) { if (!this->isInMayorsRoom) { this->shouldSetHeadRotation = true; this->textIdIndex = 2; - if (gSaveContext.weekEventReg[60] & 0x80) { + if (gSaveContext.save.weekEventReg[60] & 0x80) { this->textIdIndex = 3; } - if (gSaveContext.day != 3 || !gSaveContext.isNight) { + if (gSaveContext.save.day != 3 || !gSaveContext.save.isNight) { Actor_MarkForDeath(&this->actor); } } else { @@ -82,7 +82,7 @@ void EnMuto_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.height = 60; this->collider.dim.yShift = 0; - if (gSaveContext.weekEventReg[63] & 0x80 || (gSaveContext.day == 3 && gSaveContext.isNight)) { + if (gSaveContext.save.weekEventReg[63] & 0x80 || (gSaveContext.save.day == 3 && gSaveContext.save.isNight)) { Actor_MarkForDeath(&this->actor); } } @@ -134,7 +134,7 @@ void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { this->actor.textId = sTextIds[this->textIdIndex]; if (!this->isInMayorsRoom && (player = GET_PLAYER(globalCtx))->transformation == PLAYER_FORM_DEKU) { - if (!(gSaveContext.weekEventReg[88] & 8)) { + if (!(gSaveContext.save.weekEventReg[88] & 8)) { this->actor.textId = 0x62C; } else { this->actor.textId = 0x62B; @@ -161,7 +161,7 @@ void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { } } else { this->textIdIndex = 0; - if (gSaveContext.weekEventReg[60] & 8) { + if (gSaveContext.save.weekEventReg[60] & 8) { this->textIdIndex = 1; } if (Player_GetMask(globalCtx) == PLAYER_MASK_COUPLE) { @@ -199,10 +199,10 @@ void EnMuto_InDialogue(EnMuto* this, GlobalContext* globalCtx) { func_801477B4(globalCtx); if (this->actor.textId == 0x62C) { - gSaveContext.weekEventReg[88] |= 8; + gSaveContext.save.weekEventReg[88] |= 8; } if (this->actor.textId == 0x624) { - gSaveContext.weekEventReg[60] |= 0x80; + gSaveContext.save.weekEventReg[60] |= 0x80; } this->textIdIndex = 3; @@ -251,7 +251,7 @@ void EnMuto_Update(Actor* thisx, GlobalContext* globalCtx2) { EnMuto_SetHeadRotation(this); } - if (this->isInMayorsRoom && gSaveContext.day == 3 && gSaveContext.isNight) { + if (this->isInMayorsRoom && gSaveContext.save.day == 3 && gSaveContext.save.isNight) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.c b/src/overlays/actors/ovl_En_Osn/z_en_osn.c index f53912c4d..48a87b30e 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -324,7 +324,8 @@ s32 func_80AD0B38(EnOsn* this, GlobalContext* globalCtx) { break; } this->unk_1EA |= 0x20; - if (gSaveContext.day == 3 && gSaveContext.time >= CLOCK_TIME(5, 0) && gSaveContext.time < CLOCK_TIME(6, 0)) { + if (gSaveContext.save.day == 3 && gSaveContext.save.time >= CLOCK_TIME(5, 0) && + gSaveContext.save.time < CLOCK_TIME(6, 0)) { return 0x2006; } return 0x1FCD; @@ -333,13 +334,13 @@ s32 func_80AD0B38(EnOsn* this, GlobalContext* globalCtx) { s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((gSaveContext.inventory.items[SLOT_OCARINA] != ITEM_NONE) && CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) && CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { if (this->unk_1EA & 1) { this->unk_1EA |= 0x20; - if ((gSaveContext.inventory.items[SLOT_OCARINA] != ITEM_NONE) && + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) && (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { - if ((gSaveContext.day == 3) && (gSaveContext.time >= CLOCK_TIME(5, 0)) && - (gSaveContext.time < CLOCK_TIME(6, 0))) { + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; @@ -350,8 +351,8 @@ s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { if (player->transformation == PLAYER_FORM_DEKU) { if (this->unk_1EA & 4) { this->unk_1EA |= 0x20; - if ((gSaveContext.day == 3) && (gSaveContext.time >= CLOCK_TIME(5, 0)) && - (gSaveContext.time < CLOCK_TIME(6, 0))) { + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; @@ -363,43 +364,43 @@ s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { if (player->transformation == PLAYER_FORM_GORON) { if (this->unk_1EA & 8) { this->unk_1EA |= 0x20; - if ((gSaveContext.day == 3) && (gSaveContext.time >= CLOCK_TIME(5, 0)) && - (gSaveContext.time < CLOCK_TIME(6, 0))) { + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; } this->unk_1EA |= 8; - if (gSaveContext.weekEventReg[76] & 0x20) { + if (gSaveContext.save.weekEventReg[76] & 0x20) { return 0x1FC8; } - gSaveContext.weekEventReg[76] |= 0x20; + gSaveContext.save.weekEventReg[76] |= 0x20; return 0x1FCE; } if (player->transformation == PLAYER_FORM_ZORA) { if (this->unk_1EA & 0x10) { this->unk_1EA |= 0x20; - if ((gSaveContext.day == 3) && (gSaveContext.time >= CLOCK_TIME(5, 0)) && - (gSaveContext.time < CLOCK_TIME(6, 0))) { + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; } this->unk_1EA |= 0x10; - if (gSaveContext.weekEventReg[76] & 0x40) { + if (gSaveContext.save.weekEventReg[76] & 0x40) { return 0x1FC8; } - gSaveContext.weekEventReg[76] |= 0x40; + gSaveContext.save.weekEventReg[76] |= 0x40; return 0x1FD0; } if (Player_GetMask(globalCtx) == PLAYER_MASK_NONE) { if (this->unk_1EA & 2) { this->unk_1EA |= 0x20; - if ((gSaveContext.day == 3) && (gSaveContext.time >= CLOCK_TIME(5, 0)) && - (gSaveContext.time < CLOCK_TIME(6, 0))) { + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; @@ -412,7 +413,8 @@ s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { } this->unk_1EA |= 0x20; - if ((gSaveContext.day == 3) && (gSaveContext.time >= CLOCK_TIME(5, 0)) && (gSaveContext.time < CLOCK_TIME(6, 0))) { + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2004; } @@ -430,8 +432,8 @@ void func_80AD10FC(EnOsn* this, GlobalContext* globalCtx) { break; case 0x1FCA: - if ((gSaveContext.day == 3 && gSaveContext.time >= CLOCK_TIME(5, 0)) && - gSaveContext.time < CLOCK_TIME(6, 0)) { + if ((gSaveContext.save.day == 3 && gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + gSaveContext.save.time < CLOCK_TIME(6, 0)) { this->unk_1F4 = 0x2007; } else { this->unk_1F4 = 0x1FCB; @@ -579,10 +581,11 @@ void func_80AD10FC(EnOsn* this, GlobalContext* globalCtx) { void func_80AD1398(EnOsn* this) { this->cutscene = this->actor.cutscene; - if ((gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) || (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) || + (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); - if ((gSaveContext.inventory.items[SLOT_OCARINA] != ITEM_NONE) || + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) || (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); } @@ -604,7 +607,7 @@ void func_80AD144C(EnOsn* this, GlobalContext* globalCtx) { void func_80AD14C8(EnOsn* this, GlobalContext* globalCtx) { s16 temp_v1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (gSaveContext.inventory.items[SLOT_OCARINA] != ITEM_NONE && !CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { + if (gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE && !CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80AD1634; } else if ((((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && (temp_v1 < 0x4000)) && @@ -774,17 +777,17 @@ void EnOsn_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_1FA = 255; switch (ENOSN_GET_3(&this->actor)) { case 0: - if (((gSaveContext.entranceIndex == 0xC020) || (gSaveContext.entranceIndex == 0xC030)) || - (gSaveContext.entranceIndex == 0xC060)) { + if (((gSaveContext.save.entranceIndex == 0xC020) || (gSaveContext.save.entranceIndex == 0xC030)) || + (gSaveContext.save.entranceIndex == 0xC060)) { this->unk_1EA |= 1; } this->unk_1F0 = 1; if (globalCtx->sceneNum == SCENE_INSIDETOWER) { - if ((gSaveContext.entranceIndex == 0xC020) || (gSaveContext.entranceIndex == 0xC060)) { + if ((gSaveContext.save.entranceIndex == 0xC020) || (gSaveContext.save.entranceIndex == 0xC060)) { this->actionFunc = func_80AD16A8; return; } - if (gSaveContext.entranceIndex == 0xC030) { + if (gSaveContext.save.entranceIndex == 0xC030) { func_80AD1398(this); this->actionFunc = func_80AD1634; return; diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index 625e9674f..3464314b1 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -207,10 +207,10 @@ s32 EnOssan_TestItemSelected(GlobalContext* globalCtx) { } void EnOssan_CheckValidSpawn(EnOssan* this) { - switch (gSaveContext.day) { + switch (gSaveContext.save.day) { case 1: case 2: - if (gSaveContext.time <= CLOCK_TIME(21, 30) && gSaveContext.time > CLOCK_TIME(6, 00)) { + if (gSaveContext.save.time <= CLOCK_TIME(21, 30) && gSaveContext.save.time > CLOCK_TIME(6, 00)) { if (this->actor.params != ENOSSAN_CURIOSITY_SHOP_MAN) { Actor_MarkForDeath(&this->actor); } @@ -222,7 +222,7 @@ void EnOssan_CheckValidSpawn(EnOssan* this) { if (this->actor.params == ENOSSAN_CURIOSITY_SHOP_MAN) { Actor_MarkForDeath(&this->actor); } - if (!(gSaveContext.time <= CLOCK_TIME(22, 00) && gSaveContext.time >= CLOCK_TIME(6, 00))) { + if (!(gSaveContext.save.time <= CLOCK_TIME(22, 00) && gSaveContext.save.time >= CLOCK_TIME(6, 00))) { if (this->actor.params != ENOSSAN_CURIOSITY_SHOP_MAN) { Actor_MarkForDeath(&this->actor); } @@ -1386,19 +1386,19 @@ u16 EnOssan_CuriosityShopMan_GetWelcome(EnOssan* this, GlobalContext* globalCtx) switch (player->transformation) { case PLAYER_FORM_DEKU: this->animationIndex = FSN_ANIMATION_SLAM_COUNTER_START; - if (gSaveContext.weekEventReg[18] & 0x10) { + if (gSaveContext.save.weekEventReg[18] & 0x10) { return sWelcomeDekuTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeDekuFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; case PLAYER_FORM_ZORA: this->animationIndex = FSN_ANIMATION_LEAN_FORWARD_START; - if (gSaveContext.weekEventReg[18] & 8) { + if (gSaveContext.save.weekEventReg[18] & 8) { return sWelcomeZoraTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeZoraFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; case PLAYER_FORM_GORON: this->animationIndex = FSN_ANIMATION_HAND_ON_FACE_START; - if (gSaveContext.weekEventReg[18] & 4) { + if (gSaveContext.save.weekEventReg[18] & 4) { return sWelcomeGoronTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeGoronFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; @@ -1417,17 +1417,17 @@ u16 EnOssan_PartTimerWorker_GetWelcome(EnOssan* this, GlobalContext* globalCtx) } switch (player->transformation) { case PLAYER_FORM_DEKU: - if (gSaveContext.weekEventReg[55] & 0x10) { + if (gSaveContext.save.weekEventReg[55] & 0x10) { return sWelcomeDekuTextIds[ENOSSAN_PART_TIME_WORKER]; } return sWelcomeDekuFirstTimeTextIds[ENOSSAN_PART_TIME_WORKER]; case PLAYER_FORM_ZORA: - if (gSaveContext.weekEventReg[55] & 8) { + if (gSaveContext.save.weekEventReg[55] & 8) { return sWelcomeZoraTextIds[ENOSSAN_PART_TIME_WORKER]; } return sWelcomeZoraFirstTimeTextIds[ENOSSAN_PART_TIME_WORKER]; case PLAYER_FORM_GORON: - if (gSaveContext.weekEventReg[55] & 4) { + if (gSaveContext.save.weekEventReg[55] & 4) { return sWelcomeGoronTextIds[ENOSSAN_PART_TIME_WORKER]; } return sWelcomeGoronFirstTimeTextIds[ENOSSAN_PART_TIME_WORKER]; @@ -1438,22 +1438,22 @@ u16 EnOssan_PartTimerWorker_GetWelcome(EnOssan* this, GlobalContext* globalCtx) void EnOssan_SetHaveMet(EnOssan* this) { switch (this->textId) { case 0x06A9: - gSaveContext.weekEventReg[18] |= 0x10; + gSaveContext.save.weekEventReg[18] |= 0x10; break; case 0x06C6: - gSaveContext.weekEventReg[55] |= 0x10; + gSaveContext.save.weekEventReg[55] |= 0x10; break; case 0x06A7: - gSaveContext.weekEventReg[18] |= 8; + gSaveContext.save.weekEventReg[18] |= 8; break; case 0x06C4: - gSaveContext.weekEventReg[55] |= 8; + gSaveContext.save.weekEventReg[55] |= 8; break; case 0x06A5: - gSaveContext.weekEventReg[18] |= 4; + gSaveContext.save.weekEventReg[18] |= 4; break; case 0x06C2: - gSaveContext.weekEventReg[55] |= 4; + gSaveContext.save.weekEventReg[55] |= 4; break; } } diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index 229f1d661..7573947e6 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -180,7 +180,7 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, &this->actor.world.pos) + 50.0f; - if (gSaveContext.weekEventReg[84] & 0x10) { + if (gSaveContext.save.weekEventReg[84] & 0x10) { Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); Matrix_GetStateTranslationAndScaledZ(52.519997f, &sp64); Math_Vec3f_Sum(&this->actor.world.pos, &sp64, &sp64); @@ -195,7 +195,7 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_394.y = this->actor.world.pos.y; this->unk_394.z = (this->actor.world.pos.z + this->unk_360->actor.world.pos.z) * 0.5f; Math_Vec3f_Copy(&this->unk_360->unk_394, &this->unk_394); - if (gSaveContext.weekEventReg[32] & 1) { + if (gSaveContext.save.weekEventReg[32] & 1) { func_80B5C244(this, globalCtx); } else { func_80B5C684(this, globalCtx); @@ -230,7 +230,7 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { switch (this->unk_344) { case 0: Actor_SetScale(&this->actor, 0.0f); - if (!(gSaveContext.weekEventReg[13] & 1)) { + if (!(gSaveContext.save.weekEventReg[13] & 1)) { Actor_SetScale(&this->actor, 0.0f); func_80B5C910(this, globalCtx); } else { @@ -250,8 +250,8 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { case 1: Actor_SetScale(&this->actor, 0.012999999f); - if (gSaveContext.weekEventReg[84] & 0x10) { - if (gSaveContext.weekEventReg[32] & 1) { + if (gSaveContext.save.weekEventReg[84] & 0x10) { + if (gSaveContext.save.weekEventReg[32] & 1) { func_80B5C244(this, globalCtx); } else { func_80B5C684(this, globalCtx); @@ -264,7 +264,7 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { break; case 3: - if (!(gSaveContext.weekEventReg[26] & 8)) { + if (!(gSaveContext.save.weekEventReg[26] & 8)) { this->actor.flags |= ACTOR_FLAG_8000000; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Actor_SetScale(&this->actor, 0.0064999997f); @@ -376,11 +376,11 @@ void func_80B5BFB8(EnOt* this, GlobalContext* globalCtx) { } void func_80B5C154(EnOt* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[32] & 1) { + if (gSaveContext.save.weekEventReg[32] & 1) { this->unk_38C = GI_RUPEE_RED; } else { this->unk_38C = GI_HEART_PIECE; - gSaveContext.weekEventReg[32] |= 1; + gSaveContext.save.weekEventReg[32] |= 1; } Actor_PickUp(&this->actor, globalCtx, this->unk_38C, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_80B5C1CC; @@ -482,7 +482,7 @@ void func_80B5C634(EnOt* this, GlobalContext* globalCtx) { } void func_80B5C64C(EnOt* this, GlobalContext* globalCtx) { - if (gSaveContext.weekEventReg[26] & 8) { + if (gSaveContext.save.weekEventReg[26] & 8) { Actor_MarkForDeath(&this->actor); } } @@ -505,7 +505,7 @@ void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx) { Matrix_GetStateTranslationAndScaledZ(26.259998f, &sp30); } else { if (this->unk_73C == 0) { - gSaveContext.weekEventReg[84] |= 0x10; + gSaveContext.save.weekEventReg[84] |= 0x10; switch (this->unk_388) { case 0: ActorCutscene_Stop(this->cutscenes[2]); @@ -527,7 +527,7 @@ void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.world.pos.x, this->unk_348.x, 1.0f, 2.0f, 0.01f); Math_SmoothStepToF(&this->actor.world.pos.z, this->unk_348.z, 1.0f, 2.0f, 0.01f); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); - if ((gSaveContext.weekEventReg[84] & 0x10) && (this->unk_33C == 1)) { + if ((gSaveContext.save.weekEventReg[84] & 0x10) && (this->unk_33C == 1)) { this->actor.textId = 0; this->unk_384 = 1; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { @@ -556,7 +556,7 @@ void func_80B5C910(EnOt* this, GlobalContext* globalCtx) { void func_80B5C950(EnOt* this, GlobalContext* globalCtx) { if (this->unk_32C & 8) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SEAHORSE_OUT_BOTTLE); - gSaveContext.weekEventReg[25] |= 4; + gSaveContext.save.weekEventReg[25] |= 4; func_80B5CAD0(this, globalCtx); } } @@ -650,7 +650,7 @@ void func_80B5CD40(EnOt* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; if (1) {} if (!temp) { - gSaveContext.weekEventReg[23] |= 0x10; + gSaveContext.save.weekEventReg[23] |= 0x10; Message_StartTextbox(globalCtx, 0x1069, NULL); } break; @@ -701,7 +701,7 @@ void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx) { } } - if (!(gSaveContext.weekEventReg[84] & 0x10) && (ENOT_GET_C000(&this->actor) == 1)) { + if (!(gSaveContext.save.weekEventReg[84] & 0x10) && (ENOT_GET_C000(&this->actor) == 1)) { if ((fabsf(this->actor.xzDistToPlayer) <= 130.0f) && (fabsf(this->actor.playerHeightRel) <= 130.0f)) { player->unk_B2B = 29; } @@ -754,7 +754,7 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { phi_a1 = 0x1069; } } else if (Flags_GetSwitch(globalCtx, ENOT_GET_3F80(&this->actor))) { - if (gSaveContext.weekEventReg[23] & 0x10) { + if (gSaveContext.save.weekEventReg[23] & 0x10) { phi_a1 = 0x106C; } else { phi_a1 = 0x106B; @@ -985,8 +985,8 @@ void func_80B5DB6C(Actor* thisx, GlobalContext* globalCtx) { EnOt* this = THIS; Player* player = GET_PLAYER(globalCtx); - if (!(gSaveContext.weekEventReg[84] & 0x10) && !(this->unk_32C & 8)) { - if (gSaveContext.weekEventReg[25] & 4) { + if (!(gSaveContext.save.weekEventReg[84] & 0x10) && !(this->unk_32C & 8)) { + if (gSaveContext.save.weekEventReg[25] & 4) { Vec3f sp50; func_80B5B2E0(globalCtx, &this->actor.world.pos, ENOT_GET_7F(&this->actor), &sp50, &this->unk_340); @@ -998,7 +998,7 @@ void func_80B5DB6C(Actor* thisx, GlobalContext* globalCtx) { } else if (D_80B5E888 != NULL) { s32 sp4C = false; - if (gSaveContext.weekEventReg[13] & 1) { + if (gSaveContext.save.weekEventReg[13] & 1) { if (!SurfaceType_IsHorseBlocked(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { sp4C = true; } diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index 5a020ef5e..ab8f721ae 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -157,7 +157,7 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ENOWL_GET_TYPE_2: - if (gSaveContext.inventory.items[SLOT_LENS] == ITEM_LENS) { + if (gSaveContext.save.inventory.items[ITEM_LENS] == ITEM_LENS) { Actor_MarkForDeath(&this->actor); return; } @@ -183,7 +183,7 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { case ENOWL_GET_TYPE_2: this->actionFunc = func_8095BE0C; - if (gSaveContext.weekEventReg[9] & 0x20) { + if (gSaveContext.save.weekEventReg[9] & 0x20) { this->actor.textId = 0xBF0; } else { this->actor.textId = 0xBEA; @@ -613,10 +613,10 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); - if (gSaveContext.weekEventReg[9] & 0x40) { + if (gSaveContext.save.weekEventReg[9] & 0x40) { func_80151938(globalCtx, 0xBF4); } else { - gSaveContext.weekEventReg[9] |= 0x40; + gSaveContext.save.weekEventReg[9] |= 0x40; func_80151938(globalCtx, 0xBED); } break; @@ -649,7 +649,7 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.currentTextId) { case 0xBEA: - gSaveContext.weekEventReg[9] |= 0x20; + gSaveContext.save.weekEventReg[9] |= 0x20; func_80151938(globalCtx, 0xBEB); break; diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index ae14fa125..06cf9b22d 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -155,14 +155,14 @@ void EnPamera_Init(Actor* thisx, GlobalContext* globalCtx) { func_80BD8588(this, globalCtx); func_80BD8658(this); if (1) {} - if (!(gSaveContext.weekEventReg[14] & 4) || (gSaveContext.weekEventReg[52] & 0x20) || - (gSaveContext.weekEventReg[75] & 0x20) || (gSaveContext.entranceIndex == 0x2090)) { + if (!(gSaveContext.save.weekEventReg[14] & 4) || (gSaveContext.save.weekEventReg[52] & 0x20) || + (gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.entranceIndex == 0x2090)) { Actor_MarkForDeath(&this->actor); } - if (gSaveContext.weekEventReg[61] & 4) { - if (!(gSaveContext.weekEventReg[59] & 1) || (gSaveContext.entranceIndex != 0x2020)) { - if ((gSaveContext.entranceIndex != 0x2020) && (gSaveContext.weekEventReg[59] & 1)) { - gSaveContext.weekEventReg[59] &= (u8)~1; + if (gSaveContext.save.weekEventReg[61] & 4) { + if (!(gSaveContext.save.weekEventReg[59] & 1) || (gSaveContext.save.entranceIndex != 0x2020)) { + if ((gSaveContext.save.entranceIndex != 0x2020) && (gSaveContext.save.weekEventReg[59] & 1)) { + gSaveContext.save.weekEventReg[59] &= (u8)~1; } func_80BD8700(this); } else { @@ -173,7 +173,7 @@ void EnPamera_Init(Actor* thisx, GlobalContext* globalCtx) { func_80BD8CCC(this); } } else { - gSaveContext.weekEventReg[59] |= 1; + gSaveContext.save.weekEventReg[59] |= 1; func_80BD8FF0(this); } } @@ -200,7 +200,7 @@ void func_80BD8588(EnPamera* this, GlobalContext* globalCtx) { if (path == NULL) { Actor_MarkForDeath(&this->actor); } - if (gSaveContext.weekEventReg[61] & 4) { + if (gSaveContext.save.weekEventReg[61] & 4) { path = &globalCtx->setupPathList[path->unk1]; } this->pathPoints = Lib_SegmentedToVirtual(path->points); @@ -289,7 +289,7 @@ void func_80BD8964(EnPamera* this, GlobalContext* globalCtx) { if (Math_Vec3f_StepTo(&this->actor.world.pos, &vec, 1.0f) < 5.0f) { this->actor.speedXZ = 1.5f; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); - gSaveContext.weekEventReg[59] |= 1; + gSaveContext.save.weekEventReg[59] |= 1; func_80BD8B50(this); } } @@ -304,10 +304,10 @@ void func_80BD8A7C(EnPamera* this, GlobalContext* globalCtx) { 0x3000, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; if (Math_Vec3f_StepTo(&this->actor.world.pos, &this->actor.home.pos, 1.5f) < 10.0f) { - gSaveContext.weekEventReg[59] &= (u8)~1; - if (!(gSaveContext.weekEventReg[61] & 4)) { + gSaveContext.save.weekEventReg[59] &= (u8)~1; + if (!(gSaveContext.save.weekEventReg[61] & 4)) { func_80BD92D0(this, globalCtx); - gSaveContext.weekEventReg[61] |= 4; + gSaveContext.save.weekEventReg[61] |= 4; } func_80BD8700(this); } @@ -567,7 +567,7 @@ void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { this->actor.update = func_80BDA344; this->actor.flags |= ACTOR_FLAG_2000000; this->actor.flags |= ACTOR_FLAG_100000; - if ((gSaveContext.weekEventReg[75] & 0x20) || (gSaveContext.weekEventReg[52] & 0x20)) { + if ((gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.weekEventReg[52] & 0x20)) { func_80BD9E60(this); func_80BD9938(this); } else { @@ -575,7 +575,7 @@ void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { func_80BD9E60(this); func_80BD9904(this); } - if (gSaveContext.weekEventReg[14] & 4) { + if (gSaveContext.save.weekEventReg[14] & 4) { func_801A0204(NA_BGM_MUSIC_BOX_HOUSE); } else { func_801A0204(NA_BGM_INSIDE_A_HOUSE); @@ -602,8 +602,8 @@ void func_80BD994C(EnPamera* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x15A8, &this->actor); this->unk_324 = 0x15A8; - } else if ((gSaveContext.playerForm != PLAYER_FORM_HUMAN) || - ((gSaveContext.weekEventReg[52] & 0x20) && (!(gSaveContext.weekEventReg[75] & 0x20)))) { + } else if ((gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) || + ((gSaveContext.save.weekEventReg[52] & 0x20) && (!(gSaveContext.save.weekEventReg[75] & 0x20)))) { func_80BD93CC(this, 1, 0); Message_StartTextbox(globalCtx, 0x158E, &this->actor); this->unk_324 = 0x158E; @@ -726,7 +726,7 @@ s32 func_80BD9CB8(EnPamera* this, GlobalContext* globalCtx) { this->setupFunc(this, globalCtx); return 1; } - if ((globalCtx->csCtx.state == 0) && (gSaveContext.weekEventReg[75] & 0x20)) { + if ((globalCtx->csCtx.state == 0) && (gSaveContext.save.weekEventReg[75] & 0x20)) { if ((this->actionFunc != func_80BD994C) && (this->actionFunc != EnPamera_HandleDialogue)) { this->actor.shape.rot.y = this->actor.world.rot.y; func_80BD9904(this); @@ -850,11 +850,11 @@ void func_80BDA344(Actor* thisx, GlobalContext* globalCtx) { func_80BD9384(this, globalCtx); if (func_80BD9CB8(this, globalCtx)) { // Pamela is outside - if (gSaveContext.weekEventReg[59] & 1) { - gSaveContext.weekEventReg[59] &= (u8)~1; + if (gSaveContext.save.weekEventReg[59] & 1) { + gSaveContext.save.weekEventReg[59] &= (u8)~1; } - if (!(gSaveContext.weekEventReg[61] & 4)) { - gSaveContext.weekEventReg[61] |= 4; + if (!(gSaveContext.save.weekEventReg[61] & 4)) { + gSaveContext.save.weekEventReg[61] |= 4; } func_800E8F08(&this->limb9Rot, &this->limb8Rot); } else { @@ -863,7 +863,7 @@ void func_80BDA344(Actor* thisx, GlobalContext* globalCtx) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } - if (gSaveContext.weekEventReg[14] & 4) { + if (gSaveContext.save.weekEventReg[14] & 4) { globalCtx->roomCtx.unk7A[0]++; } } diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c index d8731cc85..901e226c5 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -170,7 +170,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 10, ICHAIN_STOP), }; -// gSaveContext.weekEventReg[KEY] = VALUE +// gSaveContext.save.weekEventReg[KEY] = VALUE // KEY | VALUE static s32 isFrogReturnedFlags[] = { (32 << 8) | 0x40, // Woodfall Temple Frog Returned @@ -192,7 +192,7 @@ void EnPametfrog_Init(Actor* thisx, GlobalContext* globalCtx) { this->params = CLAMP(this->actor.params, 1, 4); if (Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num)) { Actor_MarkForDeath(&this->actor); - if (!(gSaveContext.weekEventReg[isFrogReturnedFlags[this->actor.params - 1] >> 8] & + if (!(gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->actor.params - 1] >> 8] & (u8)isFrogReturnedFlags[this->actor.params - 1])) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MINIFROG, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, this->params); diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c index b528e60c3..a5321bf26 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -189,7 +189,7 @@ void EnPeehat_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == 0) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit1); - if (gSaveContext.isNight) { + if (gSaveContext.save.isNight) { this->actor.shape.yOffset = -1000.0f; } Actor_SetScale(&this->actor, 0.036f); @@ -296,7 +296,7 @@ void func_80897498(EnPeehat* this) { } void func_80897520(EnPeehat* this, GlobalContext* globalCtx) { - if (!gSaveContext.isNight) { + if (!gSaveContext.save.isNight) { this->actor.flags |= ACTOR_FLAG_1; this->colliderSphere.base.acFlags |= AC_ON; if (this->actor.xzDistToPlayer < 740.0f) { @@ -381,7 +381,7 @@ void func_80897910(EnPeehat* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.speedXZ, 3.0f, 0.25f); Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + 80.0f, 3.0f); SkelAnime_Update(&this->skelAnime); - if (!gSaveContext.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { + if (!gSaveContext.save.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1000); this->actor.shape.rot.y += (s16)(this->unk_2AD * 450); } else { @@ -521,7 +521,7 @@ void func_80897F44(EnPeehat* this, GlobalContext* globalCtx) { this->actor.world.rot.y += this->unk_2B6; this->actor.shape.rot.y += 0x15E; - if (!gSaveContext.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { + if (!gSaveContext.save.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; func_80897864(this); } else { @@ -566,7 +566,7 @@ void func_80898144(EnPeehat* this, GlobalContext* globalCtx) { func_80897D00(this); } - if (!gSaveContext.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { + if (!gSaveContext.save.isNight && (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 1200.0f)) { func_80897864(this); } func_800B9010(&this->actor, NA_SE_EN_PIHAT_FLY - SFX_FLAG); diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 0ff811a39..27c7af9f5 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -248,19 +248,19 @@ static AnimationInfoS sAnimations[] = { }; s32 func_80AF7B40(void) { - if (gSaveContext.weekEventReg[90] & 1) { + if (gSaveContext.save.weekEventReg[90] & 1) { return 4; } - if (gSaveContext.weekEventReg[89] & 0x40) { + if (gSaveContext.save.weekEventReg[89] & 0x40) { return 3; } - if (gSaveContext.weekEventReg[89] & 8) { + if (gSaveContext.save.weekEventReg[89] & 8) { return 2; } - if (gSaveContext.weekEventReg[86] & 1) { + if (gSaveContext.save.weekEventReg[86] & 1) { return 1; } @@ -270,29 +270,29 @@ s32 func_80AF7B40(void) { s32 func_80AF7BAC(EnPm* this) { switch (this->unk_38C) { case 0: - if (gSaveContext.weekEventReg[86] & 1) { - D_801F4E78 = gSaveContext.time; + if (gSaveContext.save.weekEventReg[86] & 1) { + D_801F4E78 = gSaveContext.save.time; this->unk_38C++; } break; case 1: - if (gSaveContext.weekEventReg[89] & 8) { - D_801F4E78 = gSaveContext.time; + if (gSaveContext.save.weekEventReg[89] & 8) { + D_801F4E78 = gSaveContext.save.time; this->unk_38C++; } break; case 2: - if (gSaveContext.weekEventReg[89] & 0x40) { + if (gSaveContext.save.weekEventReg[89] & 0x40) { D_801F4E78 = 0; this->unk_38C++; } break; case 3: - if (gSaveContext.weekEventReg[90] & 1) { - D_801F4E78 = gSaveContext.time; + if (gSaveContext.save.weekEventReg[90] & 1) { + D_801F4E78 = gSaveContext.save.time; this->unk_38C++; } break; @@ -547,7 +547,7 @@ s32 func_80AF81E8(EnPm* this, GlobalContext* globalCtx) { case 1: case 3: case 5: - if ((gSaveContext.weekEventReg[86] & 8) && (this->unk_378 == 3)) { + if ((gSaveContext.save.weekEventReg[86] & 8) && (this->unk_378 == 3)) { ActorCutscene_Stop(sp2A); } else { Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); @@ -816,24 +816,26 @@ void func_80AF8BA8(s32 arg0) { }; s32 temp; - if (!(gSaveContext.weekEventReg[88] & 2)) { - if (gSaveContext.weekEventReg[D_80AFB8D4[arg0] >> 8] & (D_80AFB8D4[arg0] & (1 | 2 | 4 | 0x38 | 0x40 | 0x80))) { - switch (gSaveContext.day) { + if (!(gSaveContext.save.weekEventReg[88] & 2)) { + if (gSaveContext.save.weekEventReg[D_80AFB8D4[arg0] >> 8] & + (D_80AFB8D4[arg0] & (1 | 2 | 4 | 0x38 | 0x40 | 0x80))) { + switch (gSaveContext.save.day) { case 2: - gSaveContext.weekEventReg[28] |= 8; + gSaveContext.save.weekEventReg[28] |= 8; break; case 3: - gSaveContext.weekEventReg[28] |= 0x10; + gSaveContext.save.weekEventReg[28] |= 0x10; break; } - gSaveContext.weekEventReg[51] |= 2; - gSaveContext.weekEventReg[90] |= 8; + gSaveContext.save.weekEventReg[51] |= 2; + gSaveContext.save.weekEventReg[90] |= 8; } } - temp = gSaveContext.weekEventReg[D_80AFB8E0[arg0] >> 8]; - gSaveContext.weekEventReg[D_80AFB8E0[arg0] >> 8] = temp | (D_80AFB8E0[arg0] & (1 | 2 | 4 | 0x38 | 0x40 | 0x80)); + temp = gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8]; + gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8] = + temp | (D_80AFB8E0[arg0] & (1 | 2 | 4 | 0x38 | 0x40 | 0x80)); } void func_80AF8C68(EnPm* this, GlobalContext* globalCtx) { @@ -933,7 +935,7 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp56 = gSaveContext.time - 0x3FFC; + u16 sp56 = gSaveContext.save.time - 0x3FFC; u8 sp55 = this->actor.params & 0xFF; EnDoor* door; Vec3s* sp4C; @@ -967,7 +969,7 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_36C = arg2->unk8 - arg2->unk4; this->unk_36E = sp56 - arg2->unk4; this->actor.flags &= ~ACTOR_FLAG_1; - if (gSaveContext.weekEventReg[90] & 8) { + if (gSaveContext.save.weekEventReg[90] & 8) { this->unk_356 |= 0x800; } this->unk_356 |= 0x9000; @@ -981,7 +983,7 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp2E = (u16)(gSaveContext.time - 0x3FFC); + u16 sp2E = (u16)(gSaveContext.save.time - 0x3FFC); u16 phi_v1; u8 sp2B = this->actor.params & 0xFF; s32 pad; @@ -1045,7 +1047,7 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar default: SubS_UpdateFlags(&this->unk_356, 3, 7); func_80AF7E98(this, 0); - if (gSaveContext.weekEventReg[90] & 8) { + if (gSaveContext.save.weekEventReg[90] & 8) { this->unk_356 |= 0x800; } this->unk_356 |= 0x9000; @@ -1161,10 +1163,10 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar break; case 23: - if (gSaveContext.weekEventReg[90] & 8) { + if (gSaveContext.save.weekEventReg[90] & 8) { this->unk_356 |= 0x800; } - gSaveContext.weekEventReg[60] |= 4; + gSaveContext.save.weekEventReg[60] |= 4; default: if (arg2->unk0 == 0x1D) { @@ -1482,11 +1484,11 @@ s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { } if ((this->unk_356 & 0x10) && (this->unk_258 == 90)) { - u8 val = gSaveContext.weekEventReg[89] | 0x40; + u8 val = gSaveContext.save.weekEventReg[89] | 0x40; - gSaveContext.weekEventReg[89] = val; + gSaveContext.save.weekEventReg[89] = val; if (val == 0) { - gSaveContext.weekEventReg[89] |= 0x40; + gSaveContext.save.weekEventReg[89] |= 0x40; } } @@ -1499,8 +1501,8 @@ s32 func_80AFA170(EnPm* this, GlobalContext* globalCtx) { switch (this->unk_258) { case 28: - if (gSaveContext.time >= CLOCK_TIME(1, 39)) { - gSaveContext.weekEventReg[89] |= 8; + if (gSaveContext.save.time >= CLOCK_TIME(1, 39)) { + gSaveContext.save.weekEventReg[89] |= 8; } case 16: @@ -1689,16 +1691,16 @@ void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { static UNK_PTR D_80AFB900[] = { D_80AFAD80, D_80AFB30C, D_80AFB3C0, D_80AFB3FC, D_80AFB41C, }; - u16 time = gSaveContext.time; + u16 time = gSaveContext.save.time; u16 sp3C = 0; - u32* unk_14 = &gSaveContext.unk_14; + u32* unk_14 = &gSaveContext.save.daySpeed; struct_80133038_arg2 sp2C; this->unk_374 = REG(15) + *unk_14; if (this->unk_38C != 0) { - time = gSaveContext.time - D_801F4E78; - sp3C = gSaveContext.time; - gSaveContext.time = time; + time = gSaveContext.save.time - D_801F4E78; + sp3C = gSaveContext.save.time; + gSaveContext.save.time = time; } if (!func_80133038(globalCtx, D_80AFB900[this->unk_38C], &sp2C) || @@ -1715,7 +1717,7 @@ void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { this->unk_268 = func_80AF8040(this, globalCtx); func_80AFA438(this, globalCtx); if (this->unk_38C != 0) { - gSaveContext.time = sp3C; + gSaveContext.save.time = sp3C; } } @@ -1824,7 +1826,7 @@ void EnPm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } - if ((this->unk_356 & 0x8000) && !(gSaveContext.weekEventReg[90] & 4)) { + if ((this->unk_356 & 0x8000) && !(gSaveContext.save.weekEventReg[90] & 4)) { func_80AF8890(this, gfx, 1); } break; diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.c b/src/overlays/actors/ovl_En_Pr/z_en_pr.c index f8c702479..8c5d417f3 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.c +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.c @@ -345,7 +345,7 @@ void func_80A32B20(EnPr* this, GlobalContext* globalCtx) { this->actor.speedXZ = BREG(57) + 3.0f; Math_SmoothStepToS(&this->unk_22C, this->actor.yawTowardsPlayer, BREG(49) + 1, BREG(50) + 1000, BREG(51)); - this->unk_2B8 = D_80A338C0[(void)0, gSaveContext.playerForm] + player->actor.world.pos.y; + this->unk_2B8 = D_80A338C0[(void)0, gSaveContext.save.playerForm] + player->actor.world.pos.y; func_80A324E0(this, globalCtx); if (!(player->stateFlags1 & 0x8000000)) { @@ -382,7 +382,7 @@ void func_80A32D28(EnPr* this, GlobalContext* globalCtx) { } else { Math_SmoothStepToS(&this->unk_22C, this->actor.yawTowardsPlayer, BREG(49) + 1, BREG(50) + 1000, BREG(51)); func_80A325E4(this); - this->unk_2B8 = D_80A338C0[(void)0, gSaveContext.playerForm] + player->actor.world.pos.y; + this->unk_2B8 = D_80A338C0[(void)0, gSaveContext.save.playerForm] + player->actor.world.pos.y; func_80A324E0(this, globalCtx); if (this->unk_2C8 < sqrtf(SQ(player->actor.world.pos.x - this->actor.home.pos.x) + SQ(player->actor.world.pos.z - this->actor.home.pos.z))) { diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.c b/src/overlays/actors/ovl_En_Prz/z_en_prz.c index 2a86294dc..29df2aa2c 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.c +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.c @@ -354,7 +354,7 @@ void func_80A767A8(EnPrz* this, GlobalContext* globalCtx) { this->unk_1C8 = 1; } - playerForm = gSaveContext.playerForm; + playerForm = gSaveContext.save.playerForm; this->unk_1D8.y = (player->actor.world.pos.y + D_80A771E0[playerForm]) + randPlusMinusPoint5Scaled((2.0f * this->unk_1E6) + 1.0f); func_80A76070(this, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_1D8), globalCtx); diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index ce1952314..064c2d2e4 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -330,10 +330,10 @@ void func_80B24CB4(EnRacedog* this, GlobalContext* globalCtx) { void func_80B24E14(EnRacedog* this) { if (this->unk_290 % 2) { D_80B25D88[this->unk_290].unk_0E = - (((gSaveContext.weekEventReg[42 + (this->unk_290 / 2)]) & (0x10 | 0x20 | 0x40 | 0x80)) >> 4) + 0x3539; + (((gSaveContext.save.weekEventReg[42 + (this->unk_290 / 2)]) & (0x10 | 0x20 | 0x40 | 0x80)) >> 4) + 0x3539; } else { D_80B25D88[this->unk_290].unk_0E = - ((gSaveContext.weekEventReg[42 + (this->unk_290 / 2)]) & (1 | 2 | 4 | 8)) + 0x3539; + ((gSaveContext.save.weekEventReg[42 + (this->unk_290 / 2)]) & (1 | 2 | 4 | 8)) + 0x3539; } if ((D_80B25D88[this->unk_290].unk_0E >= 0x3547) || (D_80B25D88[this->unk_290].unk_0E < 0x3539)) { 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 b1c6b76cb..70d9fb708 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -254,7 +254,7 @@ void EnRailgibud_Init(Actor* thisx, GlobalContext* globalCtx) { EnRailgibud_SpawnOtherGibdosAndSetPositionAndRotation(this, globalCtx); this->playerStunWaitTimer = 0; - this->timeInitialized = gSaveContext.time; + this->timeInitialized = gSaveContext.save.time; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->type = EN_RAILGIBUD_TYPE_GIBDO; this->textId = 0; @@ -270,7 +270,7 @@ void EnRailgibud_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - if (gSaveContext.weekEventReg[14] & 4) { + if (gSaveContext.save.weekEventReg[14] & 4) { Actor_MarkForDeath(&this->actor); } @@ -381,7 +381,8 @@ void EnRailgibud_WalkToPlayer(EnRailgibud* this, GlobalContext* globalCtx) { if (EnRailgibud_PlayerInRangeWithCorrectState(this, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { player->actor.freezeTimer = 0; - if ((gSaveContext.playerForm == PLAYER_FORM_GORON) || (gSaveContext.playerForm == PLAYER_FORM_DEKU)) { + if ((gSaveContext.save.playerForm == PLAYER_FORM_GORON) || + (gSaveContext.save.playerForm == PLAYER_FORM_DEKU)) { // If the Gibdo/Redead tries to grab Goron or Deku Link, it will fail to // do so. It will appear to take damage and shake its head side-to-side. EnRailgibud_SetupGrabFail(this); @@ -552,7 +553,7 @@ void EnRailgibud_WalkToHome(EnRailgibud* this, GlobalContext* globalCtx) { this->actor.world.rot = this->actor.shape.rot; } if (EnRailgibud_PlayerInRangeWithCorrectState(this, globalCtx)) { - if ((gSaveContext.playerForm != PLAYER_FORM_GORON) && (gSaveContext.playerForm != PLAYER_FORM_DEKU) && + if ((gSaveContext.save.playerForm != PLAYER_FORM_GORON) && (gSaveContext.save.playerForm != PLAYER_FORM_DEKU) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { EnRailgibud_SetupWalkToPlayer(this); } @@ -865,7 +866,7 @@ s32 EnRailgibud_MoveToIdealGrabPositionAndRotation(EnRailgibud* this, GlobalCont distanceFromTargetPos = Math_Vec3f_StepTo(&this->actor.world.pos, &targetPos, 10.0f); distanceFromTargetAngle = Math_SmoothStepToS(&this->actor.shape.rot.y, player->actor.shape.rot.y, 1, 0x1770, 0x64); this->actor.world.rot.y = this->actor.shape.rot.y; - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { distanceFromTargetYOffset = Math_SmoothStepToF(&this->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); } @@ -1112,8 +1113,7 @@ void EnRailgibud_InitCutsceneGibdo(EnRailgibud* this, GlobalContext* globalCtx) Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - - if (gSaveContext.entranceIndex != 0x2090) { // NOT Cutscene: Music Box House Opens + if (gSaveContext.save.entranceIndex != 0x2090) { // NOT Cutscene: Music Box House Opens Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c index 30449a3b4..8c2f5b6c8 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -149,8 +149,8 @@ void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx) { Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); - if (gSaveContext.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting - this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended) + if (gSaveContext.save.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting + this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended) } else { this->actor.textId = 0x2ADA; // Mayor's office is on the left (meeting ongoing) } diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index b7d4f5d5d..4e41b70a9 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -667,7 +667,7 @@ void func_80BF4EBC(EnRg* this, GlobalContext* globalCtx) { this->actor.shape.yOffset = 14.0f; this->actionFunc = func_80BF4FC4; } - } else if (gSaveContext.weekEventReg[12] & 2) { + } else if (gSaveContext.save.weekEventReg[12] & 2) { if (DECR(this->unk_318) == 0) { func_80BF409C(this, 1); this->unk_310 &= ~8; @@ -733,7 +733,7 @@ void func_80BF4FC4(EnRg* this, GlobalContext* globalCtx) { void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { EnRg* this = THIS; - if (gSaveContext.entranceIndex == 0xD010) { + if (gSaveContext.save.entranceIndex == 0xD010) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, this->morphTable, 18); @@ -759,7 +759,7 @@ void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; SubS_UpdateFlags(&this->unk_310, 3, 7); - if (!(gSaveContext.weekEventReg[12] & 2)) { + if (!(gSaveContext.save.weekEventReg[12] & 2)) { this->unk_318 = Rand_S16Offset(30, 30); } diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.c b/src/overlays/actors/ovl_En_Rr/z_en_rr.c index 17324a3b6..4bd5bcf32 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -304,8 +304,8 @@ void func_808FA4F4(EnRr* this, GlobalContext* globalCtx) { this->unk_210 = 0.0f; this->unk_20C = 0x800; - if (((this->unk_1E2 == 0) && (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) && - (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) == EQUIP_SHIELD)) { + if (((this->unk_1E2 == 0) && (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) && + (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) == 1)) { sp34 = true; this->unk_1E2 = Inventory_DeleteEquipment(globalCtx, 1); } else { diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c index bbe21471c..cf4935187 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -170,7 +170,7 @@ void func_80BCAE78(EnScopenuts* this, GlobalContext* globalCtx) { s16 func_80BCAF0C(EnScopenuts* this) { switch (this->unk_33C) { case 0x0: - if (gSaveContext.weekEventReg[53] & 2) { + if (gSaveContext.save.weekEventReg[53] & 2) { this->unk_328 |= 1; return 0x1638; } @@ -239,7 +239,7 @@ void func_80BCB1C8(EnScopenuts* this, GlobalContext* globalCtx) { this->unk_350 *= 0.92f; Actor_SetScale(&this->actor, this->unk_350); if (this->actor.bgCheckFlags & 1) { - gSaveContext.weekEventReg[52] |= 0x40; + gSaveContext.save.weekEventReg[52] |= 0x40; Actor_MarkForDeath(&this->actor); } } @@ -334,7 +334,7 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - if (gSaveContext.rupees < this->unk_358) { + if (gSaveContext.save.playerData.rupees < this->unk_358) { play_sound(NA_SE_SY_ERROR); this->unk_33C = 0x1636; this->unk_328 |= 1; @@ -368,7 +368,7 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { void func_80BCB90C(EnScopenuts* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - gSaveContext.weekEventReg[53] |= 2; + gSaveContext.save.weekEventReg[53] |= 2; this->actionFunc = func_80BCB6D0; } else { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 300.0f, 300.0f); @@ -594,7 +594,7 @@ void func_80BCBFFC(EnScopenuts* this, GlobalContext* globalCtx) { if (sp32 == 3) { if (this->unk_334 >= (this->path->count - 1)) { ActorCutscene_Stop(this->unk_338); - gSaveContext.weekEventReg[52] &= (u8)~0x40; + gSaveContext.save.weekEventReg[52] &= (u8)~0x40; this->actionFunc = func_80BCC288; } else { this->unk_334++; @@ -684,7 +684,8 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnScopenuts* this = THIS; - if (!(gSaveContext.weekEventReg[74] & 0x40) && (gSaveContext.inventory.items[ITEM_OCARINA] == ITEM_NONE)) { + if (!(gSaveContext.save.weekEventReg[74] & 0x40) && + (gSaveContext.save.inventory.items[ITEM_OCARINA] == ITEM_NONE)) { Actor_MarkForDeath(&this->actor); return; } @@ -704,7 +705,7 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; if (ENSCOPENUTS_GET_3E0(&this->actor) == ENSCOPENUTS_3E0_0) { - if (gSaveContext.weekEventReg[52] & 0x40) { + if (gSaveContext.save.weekEventReg[52] & 0x40) { Actor_MarkForDeath(&this->actor); } else if (globalCtx->actorCtx.unk5 & 2) { this->path = func_8013D648(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); @@ -715,7 +716,7 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } } else if (ENSCOPENUTS_GET_3E0(&this->actor) == ENSCOPENUTS_3E0_1) { - if (gSaveContext.weekEventReg[52] & 0x40) { + if (gSaveContext.save.weekEventReg[52] & 0x40) { this->path = func_8013D648(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); if (this->path == NULL) { Actor_MarkForDeath(&this->actor); diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c index e1f52ceed..199338bf1 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -348,21 +348,21 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { } else { switch (this->unk_340) { case 0x60E: - gSaveContext.weekEventReg[17] |= 0x20; - gSaveContext.weekEventReg[86] |= 4; + gSaveContext.save.weekEventReg[17] |= 0x20; + gSaveContext.save.weekEventReg[86] |= 4; Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; case 0x628: - gSaveContext.weekEventReg[77] |= 0x40; - gSaveContext.weekEventReg[86] |= 4; + gSaveContext.save.weekEventReg[77] |= 0x40; + gSaveContext.save.weekEventReg[86] |= 4; Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; case 0x614: - gSaveContext.weekEventReg[17] |= 0x40; + gSaveContext.save.weekEventReg[17] |= 0x40; Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; @@ -384,22 +384,22 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { this->actor.isTargeted) { func_800B85E0(&this->actor, globalCtx, 80.0f, EXCH_ITEM_2A); if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { this->unk_33A = 2; - if (gSaveContext.weekEventReg[77] & 0x40) { + if (gSaveContext.save.weekEventReg[77] & 0x40) { this->unk_340 = D_80ADD918[this->unk_33A]; } else { this->unk_340 = D_80ADD910[this->unk_33A]; } } else { this->unk_33A = 1; - if (gSaveContext.weekEventReg[17] & 0x20) { + if (gSaveContext.save.weekEventReg[17] & 0x20) { this->unk_340 = D_80ADD918[this->unk_33A]; } else { this->unk_340 = D_80ADD910[this->unk_33A]; } } - } else if (gSaveContext.weekEventReg[17] & 0x40) { + } else if (gSaveContext.save.weekEventReg[17] & 0x40) { this->unk_340 = D_80ADD918[this->unk_33A]; } else { this->unk_340 = D_80ADD910[this->unk_33A]; @@ -479,7 +479,7 @@ void func_80ADBAB8(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADBBEC(EnSellnuts* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - gSaveContext.weekEventReg[17] |= 0x80; + gSaveContext.save.weekEventReg[17] |= 0x80; this->actionFunc = func_80ADBCE4; } else { Actor_PickUp(&this->actor, globalCtx, GI_DEED_LAND, 300.0f, 300.0f); @@ -723,7 +723,7 @@ void func_80ADC6D0(EnSellnuts* this, GlobalContext* globalCtx) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { this->unk_33A = 2; } else { this->unk_33A = 1; @@ -835,7 +835,7 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 17); } else if (this->unk_34C == 17) { ActorCutscene_Stop(this->cutscene); - gSaveContext.weekEventReg[73] |= 4; + gSaveContext.save.weekEventReg[73] |= 4; Actor_MarkForDeath(&this->actor); } } @@ -871,7 +871,7 @@ void func_80ADCC04(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADCD3C(EnSellnuts* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); - if (gSaveContext.weekEventReg[73] & 4) { + if (gSaveContext.save.weekEventReg[73] & 4) { this->unk_338 |= 2; this->unk_338 |= 1; this->unk_340 = 0x626; @@ -947,7 +947,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad2; - if ((gSaveContext.weekEventReg[17] & 0x80) || (gSaveContext.weekEventReg[61] & 0x10)) { + if ((gSaveContext.save.weekEventReg[17] & 0x80) || (gSaveContext.save.weekEventReg[61] & 0x10)) { Actor_MarkForDeath(&this->actor); } @@ -969,7 +969,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_36C = 0.01f; this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; - if (gSaveContext.weekEventReg[73] & 4) { + if (gSaveContext.save.weekEventReg[73] & 4) { if (ENSELLNUTS_GET_1(&this->actor)) { Actor_MarkForDeath(&this->actor); return; @@ -977,7 +977,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_338 |= 2; this->unk_338 |= 1; if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { this->unk_33A = 2; } else { this->unk_33A = 1; @@ -1035,7 +1035,7 @@ void EnSellnuts_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_328++; if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { this->unk_33A = 2; } else { this->unk_33A = 1; diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.c b/src/overlays/actors/ovl_En_Shn/z_en_shn.c index d1bc0f8ba..92d4c7514 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.c +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.c @@ -220,7 +220,7 @@ s32 func_80AE65F4(EnShn* this, GlobalContext* globalCtx) { this->unk_1DA = temp; this->unk_1D8 |= 0x40; } else if (this->unk_1D8 & 0x40) { - if (!(gSaveContext.weekEventReg[23] & 8)) { + if (!(gSaveContext.save.weekEventReg[23] & 8)) { func_80AE615C(this, 3); } this->unk_1DA = 0; @@ -256,7 +256,7 @@ s32 func_80AE6704(EnShn* thisx, GlobalContext* globalCtx) { } break; case 6: - gSaveContext.weekEventReg[90] &= (u8)~0x40; + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; func_800B7298(globalCtx, &this->actor, 7); globalCtx->nextEntranceIndex = 0x8460; gSaveContext.nextCutsceneIndex = 0; @@ -301,7 +301,7 @@ s32 func_80AE68F0(EnShn* this, GlobalContext* globalCtx) { SubS_UpdateFlags(&this->unk_1D8, 0, 7); this->unk_1DC = func_80AE6880(this, globalCtx); this->unk_2C6 = 0; - if (gSaveContext.weekEventReg[23] & 8) { + if (gSaveContext.save.weekEventReg[23] & 8) { this->unk_1D8 |= 8; } this->actionFunc = func_80AE6A64; @@ -313,7 +313,7 @@ s32 func_80AE68F0(EnShn* this, GlobalContext* globalCtx) { void func_80AE69E8(EnShn* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); - if ((gSaveContext.weekEventReg[23] & 8) && EnShn_IsFacingPlayer(this)) { + if ((gSaveContext.save.weekEventReg[23] & 8) && EnShn_IsFacingPlayer(this)) { this->unk_1D8 |= 8; } else { this->unk_1D8 &= ~0x8; @@ -348,7 +348,7 @@ void EnShn_Init(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gObjectShnSkel, NULL, this->jointTable, this->morphTable, OBJECT_SHN_LIMB_MAX); this->unk_2E8 = -1; - if (gSaveContext.weekEventReg[23] & 8) { + if (gSaveContext.save.weekEventReg[23] & 8) { func_80AE615C(this, 0); } else { func_80AE615C(this, 2); @@ -358,7 +358,7 @@ void EnShn_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2E0 = 0; this->unk_2D8 = 0; this->unk_1D8 = 0; - if (gSaveContext.entranceIndex != 0xA820) { + if (gSaveContext.save.entranceIndex != 0xA820) { SubS_UpdateFlags(&this->unk_1D8, 3, 7); this->unk_2BE = 0; } else { diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index 8a0e4f02c..f7fca7448 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -807,7 +807,7 @@ void func_809964A0(EnSkb* this, GlobalContext* globalCtx) { void func_809964DC(EnSkb* this, GlobalContext* globalCtx) { if (this->unk_3D6 == 0) { if ((this->actionFunc != func_80994E94) && (this->actionFunc != func_80996284) && - (this->actionFunc != func_809964A0) && (gSaveContext.weekEventReg[85] & 0x40)) { + (this->actionFunc != func_809964A0) && (gSaveContext.save.weekEventReg[85] & 0x40)) { this->actor.colChkInfo.health = 0; func_809961E4(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index e344a574d..8579dc8f0 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -185,9 +185,9 @@ u16 EnSob1_GetTalkOption(EnSob1* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (this->shopType == BOMB_SHOP) { - if (gSaveContext.day == 1 && gSaveContext.time >= CLOCK_TIME(6, 00)) { + if (gSaveContext.save.day == 1 && gSaveContext.save.time >= CLOCK_TIME(6, 00)) { return 0x648; - } else if (gSaveContext.weekEventReg[33] & 8) { + } else if (gSaveContext.save.weekEventReg[33] & 8) { return 0x649; } else { return 0x64A; @@ -257,58 +257,58 @@ u16 EnSob1_GetWelcome(EnSob1* this, GlobalContext* globalCtx) { } else if (this->shopType == ZORA_SHOP) { switch (player->transformation) { case PLAYER_FORM_HUMAN: - if (gSaveContext.weekEventReg[57] & 0x10) { + if (gSaveContext.save.weekEventReg[57] & 0x10) { return 0x12CF; } - gSaveContext.weekEventReg[57] |= 0x10; + gSaveContext.save.weekEventReg[57] |= 0x10; return 0x12CE; case PLAYER_FORM_DEKU: - if (gSaveContext.weekEventReg[57] & 0x20) { + if (gSaveContext.save.weekEventReg[57] & 0x20) { return 0x12D1; } - gSaveContext.weekEventReg[57] |= 0x20; + gSaveContext.save.weekEventReg[57] |= 0x20; return 0x12D0; case PLAYER_FORM_GORON: - if (gSaveContext.weekEventReg[57] & 0x40) { + if (gSaveContext.save.weekEventReg[57] & 0x40) { return 0x12D3; } - gSaveContext.weekEventReg[57] |= 0x40; + gSaveContext.save.weekEventReg[57] |= 0x40; return 0x12D2; case PLAYER_FORM_ZORA: - if (gSaveContext.weekEventReg[57] & 0x80) { + if (gSaveContext.save.weekEventReg[57] & 0x80) { return 0x12D5; } - gSaveContext.weekEventReg[57] |= 0x80; + gSaveContext.save.weekEventReg[57] |= 0x80; return 0x12D4; default: return 0x12CE; } } else if (this->shopType == GORON_SHOP) { if (player->transformation != PLAYER_FORM_GORON) { - if (gSaveContext.weekEventReg[58] & 4) { + if (gSaveContext.save.weekEventReg[58] & 4) { return 0xBB9; } - gSaveContext.weekEventReg[58] |= 4; + gSaveContext.save.weekEventReg[58] |= 4; return 0xBB8; } else { - if (gSaveContext.weekEventReg[58] & 8) { + if (gSaveContext.save.weekEventReg[58] & 8) { return 0xBBB; } - gSaveContext.weekEventReg[58] |= 8; + gSaveContext.save.weekEventReg[58] |= 8; return 0xBBA; } } else if (this->shopType == GORON_SHOP_SPRING) { if (player->transformation != PLAYER_FORM_GORON) { - if (gSaveContext.weekEventReg[58] & 0x10) { + if (gSaveContext.save.weekEventReg[58] & 0x10) { return 0xBBD; } - gSaveContext.weekEventReg[58] |= 0x10; + gSaveContext.save.weekEventReg[58] |= 0x10; return 0xBBC; } else { - if (gSaveContext.weekEventReg[58] & 0x20) { + if (gSaveContext.save.weekEventReg[58] & 0x20) { return 0xBBF; } - gSaveContext.weekEventReg[58] |= 0x20; + gSaveContext.save.weekEventReg[58] |= 0x20; return 0xBBE; } } @@ -317,11 +317,11 @@ u16 EnSob1_GetWelcome(EnSob1* this, GlobalContext* globalCtx) { u16 EnSob1_GetGoodbye(EnSob1* this) { if (this->shopType == BOMB_SHOP) { - if (gSaveContext.day == 1) { + if (gSaveContext.save.day == 1) { return 0x64C; - } else if (gSaveContext.day == 2) { + } else if (gSaveContext.save.day == 2) { return 0x64D; - } else if (!gSaveContext.isNight) { + } else if (!gSaveContext.save.isNight) { return 0x64E; } else { return 0x64F; @@ -383,7 +383,7 @@ void EnSob1_Init(Actor* thisx, GlobalContext* globalCtx) { this->shopType = ZORA_SHOP; break; case GORON_SHOP: - if (gSaveContext.weekEventReg[33] & 0x80) { + if (gSaveContext.save.weekEventReg[33] & 0x80) { this->shopType = GORON_SHOP_SPRING; } else { this->shopType = GORON_SHOP; @@ -1360,7 +1360,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { this->actor.world.pos.y += posOffset->y; this->actor.world.pos.z += posOffset->z; shopItems = sShops[this->shopType]; - if ((this->shopType == BOMB_SHOP) && (gSaveContext.weekEventReg[33] & 8)) { + if ((this->shopType == BOMB_SHOP) && (gSaveContext.save.weekEventReg[33] & 8)) { sShops[this->shopType][0].shopItemId = SI_BOMB_BAG_30_2; } 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 c73c934d0..d880c4873 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -707,11 +707,11 @@ void EnSsh_Talk(EnSsh* this, GlobalContext* globalCtx) { void func_809756D0(EnSsh* this, GlobalContext* globalCtx) { u16 phi_a1; - if (gSaveContext.weekEventReg[34] & 8) { + if (gSaveContext.save.weekEventReg[34] & 8) { phi_a1 = 0x914; } else { phi_a1 = 0x910; - gSaveContext.weekEventReg[34] |= 8; + gSaveContext.save.weekEventReg[34] |= 8; } Message_StartTextbox(globalCtx, phi_a1, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index 774dcf40e..82e314d60 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -119,13 +119,13 @@ void EnSth_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } this->actor.textId = 0; - if (!(gSaveContext.weekEventReg[34] & 0x40) || !(gSaveContext.weekEventReg[34] & 8)) { + if (!(gSaveContext.save.weekEventReg[34] & 0x40) || !(gSaveContext.save.weekEventReg[34] & 8)) { this->unk_29C |= 1; } break; case ENSTH_F_3: - if ((gSaveContext.skullTokenCount & 0xFFFF) >= 30) { + if ((gSaveContext.save.skullTokenCount & 0xFFFF) >= 30) { Actor_MarkForDeath(&this->actor); return; } @@ -136,19 +136,20 @@ void EnSth_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ENSTH_F_4: - if (gSaveContext.weekEventReg[13] & 0x20) { + if (gSaveContext.save.weekEventReg[13] & 0x20) { Actor_MarkForDeath(&this->actor); return; } this->actor.textId = 0; this->actionFunc = func_80B677BC; - if (gSaveContext.weekEventReg[13] & 0x80) { + if (gSaveContext.save.weekEventReg[13] & 0x80) { this->unk_29C |= 2; } break; case ENSTH_F_5: - if (!(gSaveContext.weekEventReg[13] & 0x20) || (Inventory_GetSkullTokenCount(globalCtx->sceneNum) < 30)) { + if (!(gSaveContext.save.weekEventReg[13] & 0x20) || + (Inventory_GetSkullTokenCount(globalCtx->sceneNum) < 30)) { Actor_MarkForDeath(&this->actor); return; } @@ -258,7 +259,7 @@ void func_80B67348(EnSth* this, GlobalContext* globalCtx) { break; case 5: - if (gSaveContext.weekEventReg[13] & 0x40) { + if (gSaveContext.save.weekEventReg[13] & 0x40) { phi_a1 = 0x113D; } else { phi_a1 = 0x113C; @@ -266,7 +267,7 @@ void func_80B67348(EnSth* this, GlobalContext* globalCtx) { break; default: - if (gSaveContext.weekEventReg[13] & 0x40) { + if (gSaveContext.save.weekEventReg[13] & 0x40) { phi_a1 = 0x1142; } else { phi_a1 = 0x1141; @@ -331,14 +332,14 @@ void func_80B67540(EnSth* this, GlobalContext* globalCtx) { break; case 0x1136: - gSaveContext.weekEventReg[13] |= 0x80; + gSaveContext.save.weekEventReg[13] |= 0x80; switch (sp2C) { case 0: - if (gSaveContext.weekEventReg[13] & 0x40) { + if (gSaveContext.save.weekEventReg[13] & 0x40) { this->actor.home.rot.z = 6; } else { - gSaveContext.weekEventReg[13] |= 0x40; + gSaveContext.save.weekEventReg[13] |= 0x40; switch (CUR_UPG_VALUE(UPG_WALLET)) { case 0: this->actor.home.rot.z = 8; @@ -416,7 +417,7 @@ void func_80B678A8(EnSth* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B67838; } else if (func_80B6703C(this, globalCtx) || this->actor.isTargeted) { - if ((gSaveContext.time >= CLOCK_TIME(6, 0)) && (gSaveContext.time <= CLOCK_TIME(18, 0))) { + if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time <= CLOCK_TIME(18, 0))) { this->actor.textId = 0x1130; } else { this->actor.textId = 0x1131; @@ -433,14 +434,14 @@ void func_80B67958(EnSth* this, GlobalContext* globalCtx) { void func_80B67984(EnSth* this, GlobalContext* globalCtx) { u16 sp1E; - if (gSaveContext.weekEventReg[34] & 0x10) { + if (gSaveContext.save.weekEventReg[34] & 0x10) { sp1E = 0x903; func_80B670A4(this, 2); - } else if (gSaveContext.weekEventReg[34] & 0x20) { + } else if (gSaveContext.save.weekEventReg[34] & 0x20) { sp1E = 0x90F; func_80B670A4(this, 2); - } else if (gSaveContext.weekEventReg[34] & 0x40) { - if (!(gSaveContext.weekEventReg[34] & 8)) { + } else if (gSaveContext.save.weekEventReg[34] & 0x40) { + if (!(gSaveContext.save.weekEventReg[34] & 8)) { sp1E = 0x91B; } else { sp1E = 0x918; @@ -453,11 +454,11 @@ void func_80B67984(EnSth* this, GlobalContext* globalCtx) { } else { sp1E = 0x916; } - } else if (gSaveContext.weekEventReg[34] & 2) { + } else if (gSaveContext.save.weekEventReg[34] & 2) { sp1E = 0x8FF; } else { sp1E = 0x8FC; - gSaveContext.weekEventReg[34] |= 2; + gSaveContext.save.weekEventReg[34] |= 2; } Message_StartTextbox(globalCtx, sp1E, &this->actor); } @@ -467,7 +468,7 @@ void func_80B67AB4(EnSth* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B67C1C; - gSaveContext.weekEventReg[34] |= 0x40; + gSaveContext.save.weekEventReg[34] |= 0x40; Message_StartTextbox(globalCtx, 0x918, &this->actor); } else { func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); @@ -484,7 +485,7 @@ void func_80B67B50(EnSth* this, GlobalContext* globalCtx) { func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); } else { this->unk_29C &= ~1; - gSaveContext.weekEventReg[34] |= 8; + gSaveContext.save.weekEventReg[34] |= 8; Actor_PickUp(&this->actor, globalCtx, GI_MASK_CAPTAIN, 10000.0f, 50.0f); } } @@ -524,8 +525,8 @@ void func_80B67C1C(EnSth* this, GlobalContext* globalCtx) { break; case 0x91A: - gSaveContext.weekEventReg[34] |= 0x40; - gSaveContext.weekEventReg[34] &= (u8)~8; + gSaveContext.save.weekEventReg[34] |= 0x40; + gSaveContext.save.weekEventReg[34] &= (u8)~8; case 0x902: case 0x903: @@ -579,8 +580,9 @@ void EnSth_Update(Actor* thisx, GlobalContext* globalCtx) { this->jointTable, this->morphTable, 16); Animation_PlayLoop(&this->skelAnime, &ovl_En_Sth_Anim_0045B4); this->unk_29A = 1; - if ((gSaveContext.weekEventReg[34] & 0x10) || (gSaveContext.weekEventReg[34] & 0x20) || - (gSaveContext.weekEventReg[34] & 0x40) || (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30)) { + if ((gSaveContext.save.weekEventReg[34] & 0x10) || (gSaveContext.save.weekEventReg[34] & 0x20) || + (gSaveContext.save.weekEventReg[34] & 0x40) || + (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30)) { func_80B670A4(this, 3); } } else { @@ -598,7 +600,7 @@ void EnSth_Update(Actor* thisx, GlobalContext* globalCtx) { break; case ENSTH_F_4: - if (gSaveContext.weekEventReg[13] & 0x80) { + if (gSaveContext.save.weekEventReg[13] & 0x80) { func_80B670A4(this, 5); } else { func_80B670A4(this, 5); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 5935aa2c1..a989ee8ad 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -186,12 +186,12 @@ void EnSuttari_SetNextEntrance(GlobalContext* globalCtx, u16 nextEntranceIndex) } void EnSuttari_UpdateTime(void) { - u32* unk_14 = &gSaveContext.unk_14; - u16 time = gSaveContext.time; + u32* unk_14 = &gSaveContext.save.daySpeed; + u16 time = gSaveContext.save.time; - gSaveContext.time = (u16)REG(15) + time; - time = gSaveContext.time; - gSaveContext.time = (u16)*unk_14 + time; + gSaveContext.save.time = (u16)REG(15) + time; + time = gSaveContext.save.time; + gSaveContext.save.time = (u16)*unk_14 + time; } s32 func_80BAA904(EnSuttari* this, GlobalContext* globalCtx) { @@ -323,7 +323,7 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { } else if (this->flags1 & 1) { switch (this->textId) { case 0: - if (gSaveContext.weekEventReg[81] & 1) { + if (gSaveContext.save.weekEventReg[81] & 1) { this->textId = 0x1455; ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 8; this->flags2 |= 1; @@ -341,12 +341,12 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { } else { this->flags1 |= 0x400; this->textId = 0x1452; - gSaveContext.weekEventReg[81] |= 1; + gSaveContext.save.weekEventReg[81] |= 1; } break; case 0x1453: this->flags1 |= 0x400; - gSaveContext.weekEventReg[81] |= 1; + gSaveContext.save.weekEventReg[81] |= 1; ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 8; this->flags2 |= 1; this->textId = 0x1454; @@ -414,7 +414,7 @@ void func_80BAAFDC(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[0] != 0) { this->unk1F4[0]--; } - gSaveContext.weekEventReg[61] |= 8; + gSaveContext.save.weekEventReg[61] |= 8; this->unk3F6 = 20; this->actionFunc = func_80BADE8C; } @@ -446,7 +446,7 @@ void func_80BAB1A0(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[0] != 0) { this->unk1F4[0]--; } - gSaveContext.weekEventReg[61] |= 8; + gSaveContext.save.weekEventReg[61] |= 8; this->unk3F6 = 20; this->actionFunc = func_80BADE8C; } else { @@ -636,7 +636,7 @@ void func_80BABB90(EnSuttari* this, s32 arg1) { } s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg2* unkStruct) { - u16 sp26 = gSaveContext.time - 0x3FFC; + u16 sp26 = gSaveContext.save.time - 0x3FFC; u16 pad1; u8 sp23 = ENSUTTARI_GET_PATH(&this->actor); u16 pad2; @@ -679,7 +679,7 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg UNK_TYPE sp24; sp47 = ENSUTTARI_GET_PATH(&this->actor); - sp44 = gSaveContext.time - 0x3FFC; + sp44 = gSaveContext.save.time - 0x3FFC; if (this->unk428 == 10 || this->unk428 == 11 || this->unk428 == 2) { return 0; } @@ -819,7 +819,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { this->animationIndex = 2; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - if (!(gSaveContext.weekEventReg[83] & 4) && !(this->flags1 & 0x1000)) { + if (!(gSaveContext.save.weekEventReg[83] & 4) && !(this->flags1 & 0x1000)) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[0])) { ActorCutscene_Start(this->cutscenes[0], &this->actor); if (!(player->stateFlags1 & 0x10000000)) { @@ -868,7 +868,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); break; case 2: - if (!(gSaveContext.weekEventReg[81] & 4)) { + if (!(gSaveContext.save.weekEventReg[81] & 4)) { this->flags1 |= 0x80; this->actor.world.pos.x = -16.0f; this->actor.world.pos.z = -16.0f; @@ -878,7 +878,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { } break; case 4: - if (!(gSaveContext.weekEventReg[33] & 8)) { + if (!(gSaveContext.save.weekEventReg[33] & 8)) { if (this->animationIndex == 2 || this->animationIndex == 1) { this->animationIndex = 5; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); @@ -908,25 +908,25 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_1; if (globalCtx->sceneNum == SCENE_IKANA) { this->flags1 |= 1; - if (gSaveContext.day == 1 || gSaveContext.day == 2) { + if (gSaveContext.save.day == 1 || gSaveContext.save.day == 2) { this->animationIndex = 2; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->flags1 |= 0x80; this->actionFunc = func_80BACA14; return; - } else if ((gSaveContext.day == 3) && (gSaveContext.time <= CLOCK_TIME(19, 00)) && - !(gSaveContext.weekEventReg[61] & 8) && !(gSaveContext.weekEventReg[33] & 8) && - (gSaveContext.weekEventReg[51] & 8)) { + } else if ((gSaveContext.save.day == 3) && (gSaveContext.save.time <= CLOCK_TIME(19, 0)) && + !(gSaveContext.save.weekEventReg[61] & 8) && !(gSaveContext.save.weekEventReg[33] & 8) && + (gSaveContext.save.weekEventReg[51] & 8)) { this->animationIndex = 2; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = func_80BACEE0; return; } } else if (globalCtx->sceneNum == SCENE_BACKTOWN) { - if (gSaveContext.time >= CLOCK_TIME(0, 20) && gSaveContext.time < CLOCK_TIME(6, 00)) { + if (gSaveContext.save.time >= CLOCK_TIME(0, 20) && gSaveContext.save.time < CLOCK_TIME(6, 00)) { Actor_MarkForDeath(&this->actor); } - if ((gSaveContext.entranceIndex == 0xD670) || (gSaveContext.weekEventReg[58] & 0x40)) { + if ((gSaveContext.save.entranceIndex == 0xD670) || (gSaveContext.save.weekEventReg[58] & 0x40)) { Actor_MarkForDeath(&this->actor); } this->cutscenes[0] = this->actor.cutscene; @@ -938,7 +938,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { this->actionFunc = func_80BAD004; return; } else if (globalCtx->sceneNum == SCENE_ICHIBA) { - if (gSaveContext.weekEventReg[33] & 8) { + if (gSaveContext.save.weekEventReg[33] & 8) { Actor_MarkForDeath(&this->actor); return; } @@ -948,7 +948,7 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { this->actionFunc = func_80BAD5F8; return; } else if (globalCtx->sceneNum == SCENE_AYASHIISHOP) { - if (gSaveContext.weekEventReg[33] & 8) { + if (gSaveContext.save.weekEventReg[33] & 8) { Actor_MarkForDeath(&this->actor); return; } @@ -982,7 +982,7 @@ void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { this->unk3F2 = this->unk2DC.y; this->actionFunc = func_80BACBB0; } - } else if ((player->transformation == PLAYER_FORM_HUMAN) && CUR_EQUIP_VALUE_VOID(EQUIP_SWORD) != 0) { + } else if ((player->transformation == PLAYER_FORM_HUMAN) && GET_CUR_EQUIP_VALUE(EQUIP_SWORD) != 0) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk3F2 = this->unk2DC.y; func_80BAAB78(this, globalCtx); @@ -1061,7 +1061,7 @@ void func_80BACE4C(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; + u32* unk_14 = &gSaveContext.save.daySpeed; struct_80133038_arg2 unkStruct; this->unk42A = REG(15) + *unk_14; @@ -1076,7 +1076,7 @@ void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { func_80BAC2FC(this, globalCtx); func_80BAB434(this); if (this->unk428 == 5) { - gSaveContext.weekEventReg[58] |= 0x80; + gSaveContext.save.weekEventReg[58] |= 0x80; this->actionFunc = func_80BADDB4; this->actor.speedXZ = 0.0f; } else if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) { @@ -1086,7 +1086,7 @@ void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; + u32* unk_14 = &gSaveContext.save.daySpeed; struct_80133038_arg2 unkStruct; this->unk42A = REG(15) + *unk_14; @@ -1181,7 +1181,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { this->flags2 |= 8; func_80BAAF1C(this); } else if (this->flags1 & 0x200) { - gSaveContext.weekEventReg[79] |= 0x40; + gSaveContext.save.weekEventReg[79] |= 0x40; this->flags2 |= 4; this->actor.speedXZ = 0.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, @@ -1192,7 +1192,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { } if (this->unk1F4[1] == -0x63) { if (this->flags2 & 8) { - gSaveContext.weekEventReg[33] |= 8; + gSaveContext.save.weekEventReg[33] |= 8; } this->actor.speedXZ = 0.0f; Audio_QueueSeqCmd(0x101400FF); @@ -1208,7 +1208,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; + u32* unk_14 = &gSaveContext.save.daySpeed; struct_80133038_arg2 unkStruct; s16 curFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); @@ -1244,7 +1244,7 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; + u32* unk_14 = &gSaveContext.save.daySpeed; struct_80133038_arg2 unkStruct; s16 curFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); @@ -1286,7 +1286,7 @@ void func_80BADA08(EnSuttari* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; func_80BAAB78(this, globalCtx); - gSaveContext.weekEventReg[81] |= 4; + gSaveContext.save.weekEventReg[81] |= 4; } else if (this->actor.xzDistToPlayer < 500.0f) { this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 500.0f); @@ -1364,7 +1364,7 @@ void func_80BADD0C(EnSuttari* this, GlobalContext* globalCtx) { void func_80BADDB4(EnSuttari* this, GlobalContext* globalCtx) { func_80BABA90(this, 1, 1); func_80BAB434(this); - if (gSaveContext.weekEventReg[51] & 0x10) { + if (gSaveContext.save.weekEventReg[51] & 0x10) { this->actionFunc = func_80BADE14; } Actor_MoveWithGravity(&this->actor); @@ -1410,7 +1410,7 @@ void EnSuttari_Init(Actor* thisx, GlobalContext* globalCtx) { EnSuttari* this = THIS; s32 pad; - if (gSaveContext.weekEventReg[79] & 0x40) { + if (gSaveContext.save.weekEventReg[79] & 0x40) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 36030a12d..e69c7e5ab 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -164,7 +164,7 @@ void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx) { } void EnSyatekiMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { - gSaveContext.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~1; } s32 func_809C6720(GlobalContext* globalCtx, Vec3f arg1) { @@ -258,7 +258,7 @@ void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(globalCtx, 0xA30, &this->actor); this->unk_284 = 0xA30; - } else if (gSaveContext.rupees < 20) { + } else if (gSaveContext.save.playerData.rupees < 20) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(globalCtx, 0xA31, &this->actor); this->unk_284 = 0xA31; @@ -269,8 +269,8 @@ void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { } else { func_8019F208(); func_801159EC(-20); - gSaveContext.weekEventReg[63] |= 1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_26A = 7; @@ -332,11 +332,11 @@ void func_809C6C2C(EnSyatekiMan* this, GlobalContext* globalCtx) { break; case 0xA32: - if (gSaveContext.weekEventReg[63] & 2) { + if (gSaveContext.save.weekEventReg[63] & 2) { func_801477B4(globalCtx); player->stateFlags1 &= ~0x20; - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->actionFunc = func_809C6848; gSaveContext.minigameState = 3; this->unk_26A = 0; @@ -391,8 +391,8 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; player->stateFlags1 &= ~0x20; - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->actionFunc = func_809C6848; this->unk_26A = 0; } @@ -416,7 +416,7 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { } void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { - switch (gSaveContext.playerForm) { + switch (gSaveContext.save.playerForm) { case PLAYER_FORM_HUMAN: Flags_SetAllTreasure(globalCtx, Flags_GetAllTreasure(globalCtx) + 1); if (CURRENT_DAY != 3) { @@ -530,7 +530,7 @@ void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x3FA, &this->actor); this->unk_284 = 0x3FA; } - } else if (gSaveContext.rupees < 20) { + } else if (gSaveContext.save.playerData.rupees < 20) { play_sound(NA_SE_SY_ERROR); if (CURRENT_DAY != 3) { Message_StartTextbox(globalCtx, 0x3FB, &this->actor); @@ -557,8 +557,8 @@ void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x3FF, &this->actor); this->unk_284 = 0x3FF; } - gSaveContext.weekEventReg[63] |= 1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; } } else { func_8019F230(); @@ -633,8 +633,8 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { player->actor.freezeTimer = 0; this->unk_26A = 7; player->stateFlags1 |= 0x20; - gSaveContext.weekEventReg[63] |= 1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->actionFunc = func_809C8710; } break; @@ -653,10 +653,10 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { break; case 0x401: - if (gSaveContext.weekEventReg[63] & 2) { + if (gSaveContext.save.weekEventReg[63] & 2) { func_801477B4(globalCtx); - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->unk_26A = 0; this->actionFunc = func_809C72D8; } else { @@ -666,10 +666,10 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { break; case 0x403: - if (gSaveContext.weekEventReg[63] & 2) { + if (gSaveContext.save.weekEventReg[63] & 2) { func_801477B4(globalCtx); - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->unk_26A = 0; this->actionFunc = func_809C72D8; } else { @@ -722,8 +722,8 @@ void func_809C7990(EnSyatekiMan* this, GlobalContext* globalCtx) { case 6: if (Message_ShouldAdvance(globalCtx)) { - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; player->stateFlags1 &= ~0x20; this->actionFunc = func_809C72D8; this->unk_26A = 0; @@ -745,19 +745,19 @@ void func_809C7A90(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_HasParent(&this->actor, globalCtx)) { - if (!(gSaveContext.weekEventReg[59] & 0x10)) { - gSaveContext.weekEventReg[59] |= 0x10; - } else if (!(gSaveContext.weekEventReg[32] & 2) && (this->unk_280 >= 0x884)) { - gSaveContext.weekEventReg[32] |= 2; + if (!(gSaveContext.save.weekEventReg[59] & 0x10)) { + gSaveContext.save.weekEventReg[59] |= 0x10; + } else if (!(gSaveContext.save.weekEventReg[32] & 2) && (this->unk_280 >= 0x884)) { + gSaveContext.save.weekEventReg[32] |= 2; } this->actor.parent = NULL; this->actionFunc = func_809C7C14; } else { - if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !(gSaveContext.weekEventReg[59] & 0x10)) { + if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !(gSaveContext.save.weekEventReg[59] & 0x10)) { Actor_PickUp(&this->actor, globalCtx, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); } else if (this->unk_280 < 0x884) { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 500.0f, 100.0f); - } else if (!(gSaveContext.weekEventReg[32] & 2)) { + } else if (!(gSaveContext.save.weekEventReg[32] & 2)) { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); @@ -774,7 +774,7 @@ void func_809C7C14(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if ((CURRENT_DAY == 3) && (gSaveContext.time > CLOCK_TIME(12, 00))) { + if ((CURRENT_DAY == 3) && (gSaveContext.save.time > CLOCK_TIME(12, 0))) { Message_StartTextbox(globalCtx, 0xA36, &this->actor); this->unk_284 = 0xA36; } else { @@ -796,26 +796,26 @@ void func_809C7D14(EnSyatekiMan* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { if (this->unk_284 == 0x407) { - if (!(gSaveContext.weekEventReg[59] & 0x20)) { - gSaveContext.weekEventReg[59] |= 0x20; + if (!(gSaveContext.save.weekEventReg[59] & 0x20)) { + gSaveContext.save.weekEventReg[59] |= 0x20; } } if ((this->unk_284 == 0x405) || (this->unk_284 == 0x406)) { - if (!(gSaveContext.weekEventReg[32] & 4)) { - gSaveContext.weekEventReg[32] |= 4; + if (!(gSaveContext.save.weekEventReg[32] & 4)) { + gSaveContext.save.weekEventReg[32] |= 4; } } this->actor.parent = NULL; this->actionFunc = func_809C7EB4; } else { if (this->unk_284 == 0x407) { - if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !(gSaveContext.weekEventReg[59] & 0x20)) { + if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !(gSaveContext.save.weekEventReg[59] & 0x20)) { Actor_PickUp(&this->actor, globalCtx, GI_QUIVER_30 + CUR_UPG_VALUE(UPG_QUIVER), 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); } - } else if (!(gSaveContext.weekEventReg[32] & 4)) { + } else if (!(gSaveContext.save.weekEventReg[32] & 4)) { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_HUGE, 500.0f, 100.0f); @@ -836,8 +836,8 @@ void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx) { player->stateFlags1 &= ~0x20; this->unk_280 = 0; this->unk_26A = 0; - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->actionFunc = func_809C6810; } } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { @@ -974,8 +974,8 @@ void func_809C8488(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_274 = 0; this->unk_276 = 0; if (this->unk_270 <= 0) { - if ((s32)((gSaveContext.unk_EF4 & 0xFFFF0000) >> 0x10) < this->unk_280) { - gSaveContext.unk_EF4 = ((gSaveContext.unk_EF4) & 0xFFFF) | ((u16)this->unk_280 << 0x10); + if ((s32)((gSaveContext.save.unk_EF4 & 0xFFFF0000) >> 0x10) < this->unk_280) { + gSaveContext.save.unk_EF4 = ((gSaveContext.save.unk_EF4) & 0xFFFF) | ((u16)this->unk_280 << 0x10); } this->unk_270 = 15; if (this->unk_280 >= 0x848) { @@ -983,9 +983,9 @@ void func_809C8488(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_284 = 0xA34; this->unk_26A = 6; } else if (this->unk_280 >= 0x7D0) { - if (gSaveContext.weekEventReg[63] & 2) { - gSaveContext.weekEventReg[63] &= (u8)~1; - gSaveContext.weekEventReg[63] &= (u8)~2; + if (gSaveContext.save.weekEventReg[63] & 2) { + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; this->unk_26A = 0; gSaveContext.minigameState = 3; this->actionFunc = func_809C6848; @@ -1039,7 +1039,7 @@ void func_809C8610(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C8710(EnSyatekiMan* this, GlobalContext* globalCtx) { Vec3f sp24; - if (gSaveContext.playerForm == PLAYER_FORM_FIERCE_DEITY) { + if (gSaveContext.save.playerForm == PLAYER_FORM_FIERCE_DEITY) { sp24 = D_809C9480; } else { sp24 = D_809C948C; @@ -1164,9 +1164,9 @@ void func_809C8BF0(EnSyatekiMan* this, GlobalContext* globalCtx) { if ((this->unk_270 <= 0) && (globalCtx->interfaceCtx.unk_286 == 0)) { Flags_SetAllTreasure(globalCtx, this->unk_280); this->unk_270 = 15; - if (((s32)(gSaveContext.unk_EF4 & 0xFFFF) < this->unk_280) || (this->unk_280 == 50)) { - if ((s32)(gSaveContext.unk_EF4 & 0xFFFF) < this->unk_280) { - if (!(gSaveContext.weekEventReg[59] & 0x20)) { + if (((s32)(gSaveContext.save.unk_EF4 & 0xFFFF) < this->unk_280) || (this->unk_280 == 50)) { + if ((s32)(gSaveContext.save.unk_EF4 & 0xFFFF) < this->unk_280) { + if (!(gSaveContext.save.weekEventReg[59] & 0x20)) { Message_StartTextbox(globalCtx, 0x407, &this->actor); this->unk_284 = 0x407; } else if (this->unk_280 == 50) { @@ -1180,7 +1180,7 @@ void func_809C8BF0(EnSyatekiMan* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, 0x406, &this->actor); this->unk_284 = 0x406; } - gSaveContext.unk_EF4 = (gSaveContext.unk_EF4 & 0xFFFF0000) | (this->unk_280 & 0xFFFF); + gSaveContext.save.unk_EF4 = (gSaveContext.save.unk_EF4 & 0xFFFF0000) | (this->unk_280 & 0xFFFF); this->unk_26A = 6; } else { if (CURRENT_DAY != 3) { diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index a3b31b93f..48a1bc064 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -333,7 +333,7 @@ s32* func_80BE0E04(EnTab* this, GlobalContext* globalCtx) { return D_80BE1998; } - if (gSaveContext.day == 3) { + if (gSaveContext.save.day == 3) { return D_80BE1A0C; } return D_80BE19A0; @@ -422,7 +422,8 @@ s32 func_80BE10BC(EnTab* this, GlobalContext* globalCtx) { } else { dist = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_1E4->actor.world.pos); - if ((gSaveContext.weekEventReg[75] & 1) || (this->unk_1E4->actor.draw == NULL) || !(dist < 160.0f)) { + if ((gSaveContext.save.weekEventReg[75] & 1) || (this->unk_1E4->actor.draw == NULL) || + !(dist < 160.0f)) { tempActor = &GET_PLAYER(globalCtx)->actor; this->actor.child = tempActor; } else { @@ -458,7 +459,7 @@ void func_80BE1224(EnTab* this, GlobalContext* globalCtx) { } void func_80BE127C(EnTab* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.unk_14; + u32* unk_14 = &gSaveContext.save.daySpeed; struct_80133038_arg2 sp18; this->unk_31A = REG(15) + *unk_14; diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c index 2f7b5c5c6..a2324aaf6 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c @@ -344,7 +344,7 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { if (EnTalkGibud_PlayerInRangeWithCorrectState(this, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { player->actor.freezeTimer = 0; - if ((gSaveContext.playerForm == PLAYER_FORM_GORON) || (gSaveContext.playerForm == PLAYER_FORM_DEKU)) { + if (gSaveContext.save.playerForm == PLAYER_FORM_GORON || gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { // If the Gibdo/Redead tries to grab Goron or Deku Link, it will fail to // do so. It will appear to take damage and shake its head side-to-side. EnTalkGibud_SetupGrabFail(this); @@ -510,7 +510,7 @@ void EnTalkGibud_WalkToHome(EnTalkGibud* this, GlobalContext* globalCtx) { this->actor.world.rot = this->actor.shape.rot; } if (EnTalkGibud_PlayerInRangeWithCorrectState(this, globalCtx)) { - if ((gSaveContext.playerForm != PLAYER_FORM_GORON) && (gSaveContext.playerForm != PLAYER_FORM_DEKU) && + if (gSaveContext.save.playerForm != PLAYER_FORM_GORON && gSaveContext.save.playerForm != PLAYER_FORM_DEKU && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { EnTalkGibud_SetupWalkToPlayer(this); } @@ -980,7 +980,7 @@ s32 EnTalkGibud_MoveToIdealGrabPositionAndRotation(EnTalkGibud* this, GlobalCont distanceFromTargetPos = Math_Vec3f_StepTo(&this->actor.world.pos, &targetPos, 10.0f); distanceFromTargetAngle = Math_SmoothStepToS(&this->actor.shape.rot.y, player->actor.shape.rot.y, 1, 0x1770, 0x64); this->actor.world.rot.y = this->actor.shape.rot.y; - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { distanceFromTargetYOffset = Math_SmoothStepToF(&this->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); } diff --git a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c index 86f4d5ea5..969a87cf6 100644 --- a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c +++ b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c @@ -73,7 +73,7 @@ void EnTanron4_Init(Actor* thisx, GlobalContext* globalCtx2) { } } - if ((gSaveContext.time > CLOCK_TIME(20, 0)) || (gSaveContext.time < CLOCK_TIME(4, 0))) { + if ((gSaveContext.save.time > CLOCK_TIME(20, 0)) || (gSaveContext.save.time < CLOCK_TIME(4, 0))) { this->timeInfluence = 1500.0f; thisx->world.pos.y += 1500.0f; } @@ -99,7 +99,7 @@ void EnTanron4_FlyNearHome(EnTanron4* this, GlobalContext* globalCtx) { // `timeInfluence` controls both the height of the seagulls and when they are visible. // They fly higher in the sky as the night goes on, and they disapear as dawn approaches. - if ((gSaveContext.time > CLOCK_TIME(20, 0)) || (gSaveContext.time < CLOCK_TIME(4, 0))) { + if ((gSaveContext.save.time > CLOCK_TIME(20, 0)) || (gSaveContext.save.time < CLOCK_TIME(4, 0))) { Math_ApproachF(&this->timeInfluence, 1500.0f, 1.0f, 1.0f); } else { Math_ApproachZeroF(&this->timeInfluence, 1.0f, 1.0f); diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index 6886d2b29..5dc94a1c4 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -51,11 +51,11 @@ void func_80A41D70(EnTest4* this, GlobalContext* globalCtx) { } else if ((sCutscenes[this->unk_144] < 0) || ((globalCtx->actorCtx.unk5 & 2) != 0)) { if (globalCtx->actorCtx.unk5 & 2) { Sram_IncrementDay(); - gSaveContext.time = CLOCK_TIME(6, 0); + gSaveContext.save.time = CLOCK_TIME(6, 0); func_80151A68(globalCtx, sDayMessages1[CURRENT_DAY - 1]); } else { this->unk_144 = 0; - this->unk_146 = gSaveContext.time += CLOCK_TIME_MINUTE; + this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; } func_8010EE74(globalCtx, CURRENT_DAY); @@ -84,7 +84,7 @@ void func_80A41D70(EnTest4* this, GlobalContext* globalCtx) { this->unk_144 = 0; } - this->unk_146 = gSaveContext.time += CLOCK_TIME_MINUTE; + this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; } } @@ -93,7 +93,7 @@ void func_80A41FA4(EnTest4* this, GlobalContext* globalCtx) { func_80151A68(globalCtx, sNightMessages2[CURRENT_DAY - 1]); } else if ((sCutscenes[this->unk_144] < 0) || ((globalCtx->actorCtx.unk5 & 2) != 0)) { Sram_IncrementDay(); - gSaveContext.time = CLOCK_TIME(6, 0); + gSaveContext.save.time = CLOCK_TIME(6, 0); func_8010EE74(globalCtx, CURRENT_DAY); func_80151A68(globalCtx, sDayMessages2[CURRENT_DAY - 1]); D_801BDBC8 = 0xFE; @@ -121,168 +121,168 @@ void func_80A41FA4(EnTest4* this, GlobalContext* globalCtx) { this->unk_144 = 0; } - this->unk_146 = gSaveContext.time += CLOCK_TIME_MINUTE; + this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; } } // Bells on last day void func_80A42198(EnTest4* this) { - if ((gSaveContext.time >= CLOCK_TIME(6, 0)) && (gSaveContext.time <= CLOCK_TIME(18, 0))) { - if (gSaveContext.time < CLOCK_TIME(17, 30)) { + if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time <= CLOCK_TIME(18, 0))) { + if (gSaveContext.save.time < CLOCK_TIME(17, 30)) { this->nextBellTime = CLOCK_TIME(17, 30); - } else if (gSaveContext.time < CLOCK_TIME(17, 36)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 36)) { this->nextBellTime = CLOCK_TIME(17, 36); - } else if (gSaveContext.time < CLOCK_TIME(17, 42)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 42)) { this->nextBellTime = CLOCK_TIME(17, 42); - } else if (gSaveContext.time < CLOCK_TIME(17, 48)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 48)) { this->nextBellTime = CLOCK_TIME(17, 48); - } else if (gSaveContext.time < CLOCK_TIME(17, 54)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 54)) { this->nextBellTime = CLOCK_TIME(17, 54); } else { this->nextBellTime = CLOCK_TIME(0, 0); } - } else if (gSaveContext.time > CLOCK_TIME(6, 0)) { + } else if (gSaveContext.save.time > CLOCK_TIME(6, 0)) { this->nextBellTime = CLOCK_TIME(0, 0); - } else if (gSaveContext.time < CLOCK_TIME(0, 10)) { + } else if (gSaveContext.save.time < CLOCK_TIME(0, 10)) { this->nextBellTime = CLOCK_TIME(0, 10); - } else if (gSaveContext.time < CLOCK_TIME(0, 20)) { + } else if (gSaveContext.save.time < CLOCK_TIME(0, 20)) { this->nextBellTime = CLOCK_TIME(0, 20); - } else if (gSaveContext.time < CLOCK_TIME(0, 30)) { + } else if (gSaveContext.save.time < CLOCK_TIME(0, 30)) { this->nextBellTime = CLOCK_TIME(0, 30); - } else if (gSaveContext.time < CLOCK_TIME(0, 40)) { + } else if (gSaveContext.save.time < CLOCK_TIME(0, 40)) { this->nextBellTime = CLOCK_TIME(0, 40); - } else if (gSaveContext.time < CLOCK_TIME(0, 50)) { + } else if (gSaveContext.save.time < CLOCK_TIME(0, 50)) { this->nextBellTime = CLOCK_TIME(0, 50); - } else if (gSaveContext.time < CLOCK_TIME(1, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(1, 0)) { this->nextBellTime = CLOCK_TIME(1, 0); - } else if (gSaveContext.time < CLOCK_TIME(1, 10)) { + } else if (gSaveContext.save.time < CLOCK_TIME(1, 10)) { this->nextBellTime = CLOCK_TIME(1, 10); - } else if (gSaveContext.time < CLOCK_TIME(1, 20)) { + } else if (gSaveContext.save.time < CLOCK_TIME(1, 20)) { this->nextBellTime = CLOCK_TIME(1, 20); - } else if (gSaveContext.time < CLOCK_TIME(1, 30) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(1, 30) - 1) { this->nextBellTime = CLOCK_TIME(1, 30) - 1; - } else if (gSaveContext.time < CLOCK_TIME(1, 40) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(1, 40) - 1) { this->nextBellTime = CLOCK_TIME(1, 40) - 1; - } else if (gSaveContext.time < CLOCK_TIME(1, 50) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(1, 50) - 1) { this->nextBellTime = CLOCK_TIME(1, 50) - 1; - } else if (gSaveContext.time < CLOCK_TIME(2, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(2, 0)) { this->nextBellTime = CLOCK_TIME(2, 0); - } else if (gSaveContext.time < CLOCK_TIME(2, 10)) { + } else if (gSaveContext.save.time < CLOCK_TIME(2, 10)) { this->nextBellTime = CLOCK_TIME(2, 10); - } else if (gSaveContext.time < CLOCK_TIME(2, 20)) { + } else if (gSaveContext.save.time < CLOCK_TIME(2, 20)) { this->nextBellTime = CLOCK_TIME(2, 20); - } else if (gSaveContext.time < CLOCK_TIME(2, 30)) { + } else if (gSaveContext.save.time < CLOCK_TIME(2, 30)) { this->nextBellTime = CLOCK_TIME(2, 30); - } else if (gSaveContext.time < CLOCK_TIME(2, 40)) { + } else if (gSaveContext.save.time < CLOCK_TIME(2, 40)) { this->nextBellTime = CLOCK_TIME(2, 40); - } else if (gSaveContext.time < CLOCK_TIME(2, 50)) { + } else if (gSaveContext.save.time < CLOCK_TIME(2, 50)) { this->nextBellTime = CLOCK_TIME(2, 50); - } else if (gSaveContext.time < CLOCK_TIME(3, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(3, 0)) { this->nextBellTime = CLOCK_TIME(3, 0); - } else if (gSaveContext.time < CLOCK_TIME(3, 10)) { + } else if (gSaveContext.save.time < CLOCK_TIME(3, 10)) { this->nextBellTime = CLOCK_TIME(3, 10); - } else if (gSaveContext.time < CLOCK_TIME(3, 20)) { + } else if (gSaveContext.save.time < CLOCK_TIME(3, 20)) { this->nextBellTime = CLOCK_TIME(3, 20); - } else if (gSaveContext.time < CLOCK_TIME(3, 30)) { + } else if (gSaveContext.save.time < CLOCK_TIME(3, 30)) { this->nextBellTime = CLOCK_TIME(3, 30); - } else if (gSaveContext.time < CLOCK_TIME(3, 40)) { + } else if (gSaveContext.save.time < CLOCK_TIME(3, 40)) { this->nextBellTime = CLOCK_TIME(3, 40); - } else if (gSaveContext.time < CLOCK_TIME(3, 50)) { + } else if (gSaveContext.save.time < CLOCK_TIME(3, 50)) { this->nextBellTime = CLOCK_TIME(3, 50); - } else if (gSaveContext.time < CLOCK_TIME(4, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(4, 0)) { this->nextBellTime = CLOCK_TIME(4, 0); - } else if (gSaveContext.time < CLOCK_TIME(4, 10)) { + } else if (gSaveContext.save.time < CLOCK_TIME(4, 10)) { this->nextBellTime = CLOCK_TIME(4, 10); - } else if (gSaveContext.time < CLOCK_TIME(4, 20)) { + } else if (gSaveContext.save.time < CLOCK_TIME(4, 20)) { this->nextBellTime = CLOCK_TIME(4, 20); - } else if (gSaveContext.time < CLOCK_TIME(4, 30) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(4, 30) - 1) { this->nextBellTime = CLOCK_TIME(4, 30) - 1; - } else if (gSaveContext.time < CLOCK_TIME(4, 40) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(4, 40) - 1) { this->nextBellTime = CLOCK_TIME(4, 40) - 1; - } else if (gSaveContext.time < CLOCK_TIME(4, 50) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(4, 50) - 1) { this->nextBellTime = CLOCK_TIME(4, 50) - 1; - } else if (gSaveContext.time < CLOCK_TIME(5, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 0)) { this->nextBellTime = CLOCK_TIME(5, 0); - } else if (gSaveContext.time < CLOCK_TIME(5, 5)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 5)) { this->nextBellTime = CLOCK_TIME(5, 5); - } else if (gSaveContext.time < CLOCK_TIME(5, 10)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 10)) { this->nextBellTime = CLOCK_TIME(5, 10); - } else if (gSaveContext.time < CLOCK_TIME(5, 15) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 15) - 1) { this->nextBellTime = CLOCK_TIME(5, 15) - 1; - } else if (gSaveContext.time < CLOCK_TIME(5, 20)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 20)) { this->nextBellTime = CLOCK_TIME(5, 20); - } else if (gSaveContext.time < CLOCK_TIME(5, 25) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 25) - 1) { this->nextBellTime = CLOCK_TIME(5, 25) - 1; - } else if (gSaveContext.time < CLOCK_TIME(5, 30)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 30)) { this->nextBellTime = CLOCK_TIME(5, 30); - } else if (gSaveContext.time < CLOCK_TIME(5, 33) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 33) - 1) { this->nextBellTime = CLOCK_TIME(5, 33) - 1; - } else if (gSaveContext.time < CLOCK_TIME(5, 36)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 36)) { this->nextBellTime = CLOCK_TIME(5, 36); - } else if (gSaveContext.time < CLOCK_TIME(5, 39) - 1) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 39) - 1) { this->nextBellTime = CLOCK_TIME(5, 39) - 1; - } else if (gSaveContext.time < CLOCK_TIME(5, 42)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 42)) { this->nextBellTime = CLOCK_TIME(5, 42); - } else if (gSaveContext.time < CLOCK_TIME(5, 45)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 45)) { this->nextBellTime = CLOCK_TIME(5, 45); - } else if (gSaveContext.time < CLOCK_TIME(5, 48)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 48)) { this->nextBellTime = CLOCK_TIME(5, 48); - } else if (gSaveContext.time < CLOCK_TIME(5, 51)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 51)) { this->nextBellTime = CLOCK_TIME(5, 51); - } else if (gSaveContext.time < CLOCK_TIME(5, 54)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 54)) { this->nextBellTime = CLOCK_TIME(5, 54); - } else if (gSaveContext.time < CLOCK_TIME(5, 57)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 57)) { this->nextBellTime = CLOCK_TIME(5, 57); - } else if (gSaveContext.time < CLOCK_TIME(6, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(6, 0)) { this->nextBellTime = CLOCK_TIME(6, 0); } } // Bells on first and second day void func_80A425E4(EnTest4* this, GlobalContext* globalCtx) { - gSaveContext.unk_3F64 = 1000.0f; + gSaveContext.screenScale = 1000.0f; - if ((gSaveContext.time >= CLOCK_TIME(6, 0)) && (gSaveContext.time < CLOCK_TIME(18, 0))) { - if (gSaveContext.time < CLOCK_TIME(17, 30)) { + if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time < CLOCK_TIME(18, 0))) { + if (gSaveContext.save.time < CLOCK_TIME(17, 30)) { this->nextBellTime = CLOCK_TIME(17, 30); - } else if (gSaveContext.time < CLOCK_TIME(17, 36)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 36)) { this->nextBellTime = CLOCK_TIME(17, 36); - } else if (gSaveContext.time < CLOCK_TIME(17, 42)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 42)) { this->nextBellTime = CLOCK_TIME(17, 42); - } else if (gSaveContext.time < CLOCK_TIME(17, 48)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 48)) { this->nextBellTime = CLOCK_TIME(17, 48); - } else if (gSaveContext.time < CLOCK_TIME(17, 54)) { + } else if (gSaveContext.save.time < CLOCK_TIME(17, 54)) { this->nextBellTime = CLOCK_TIME(17, 54); } else { this->nextBellTime = CLOCK_TIME(5, 30); } } else { - if (gSaveContext.time < CLOCK_TIME(5, 30)) { + if (gSaveContext.save.time < CLOCK_TIME(5, 30)) { this->nextBellTime = CLOCK_TIME(5, 30); - } else if (gSaveContext.time < CLOCK_TIME(5, 36)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 36)) { this->nextBellTime = CLOCK_TIME(5, 36); - } else if (gSaveContext.time < CLOCK_TIME(5, 42)) { + } else if (gSaveContext.save.time < CLOCK_TIME(5, 42)) { this->nextBellTime = CLOCK_TIME(5, 42); - gSaveContext.unk_3F64 -= 50.0f; - } else if (gSaveContext.time < CLOCK_TIME(5, 48)) { + gSaveContext.screenScale -= 50.0f; + } else if (gSaveContext.save.time < CLOCK_TIME(5, 48)) { this->nextBellTime = CLOCK_TIME(5, 48); - gSaveContext.unk_3F64 -= 100.0f; - } else if (gSaveContext.time < CLOCK_TIME(5, 54)) { + gSaveContext.screenScale -= 100.0f; + } else if (gSaveContext.save.time < CLOCK_TIME(5, 54)) { this->nextBellTime = CLOCK_TIME(5, 54); - gSaveContext.unk_3F64 -= 150.0f; - } else if (gSaveContext.time < CLOCK_TIME(6, 0)) { + gSaveContext.screenScale -= 150.0f; + } else if (gSaveContext.save.time < CLOCK_TIME(6, 0)) { this->nextBellTime = CLOCK_TIME(17, 30); - gSaveContext.unk_3F64 -= 200.0f; + gSaveContext.screenScale -= 200.0f; } else { this->nextBellTime = CLOCK_TIME(17, 30); } if ((sCutscenes[this->unk_144] < 0) || ((globalCtx->actorCtx.unk5 & 2) != 0) || (CURRENT_DAY == 3) || - (gSaveContext.time >= CLOCK_TIME(17, 0))) { - gSaveContext.unk_3F64 = 1000.0f; + (gSaveContext.save.time >= CLOCK_TIME(17, 0))) { + gSaveContext.screenScale = 1000.0f; } - if (gSaveContext.unk_3F64 != 1000.0f) { - gSaveContext.unk_3F60 = 1; + if (gSaveContext.screenScale != 1000.0f) { + gSaveContext.screenScaleFlag = 1; } } } @@ -309,11 +309,11 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { } else { sIsLoaded = true; this->actor.room = -1; - gSaveContext.unk_3F60 = 0; - gSaveContext.unk_3F64 = 1000.0f; + gSaveContext.screenScaleFlag = 0; + gSaveContext.screenScale = 1000.0f; if (CURRENT_DAY == 0) { - if (gSaveContext.time < CLOCK_TIME(6, 1)) { - gSaveContext.time = CLOCK_TIME(6, 0); + if (gSaveContext.save.time < CLOCK_TIME(6, 1)) { + gSaveContext.save.time = CLOCK_TIME(6, 0); gSaveContext.gameMode = 0; { GameState* state = &globalCtx->state; @@ -322,17 +322,17 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { SET_NEXT_GAMESTATE(&globalCtx->state, Daytelop_Init, DaytelopContext); if (this && this && this) {} this->unk_144 = 1; - gSaveContext.time = CLOCK_TIME(6, 0); + gSaveContext.save.time = CLOCK_TIME(6, 0); Actor_MarkForDeath(&this->actor); } else { - gSaveContext.day = 1; - dayTemp = gSaveContext.day; - gSaveContext.daysElapsed = dayTemp; + gSaveContext.save.day = 1; + dayTemp = gSaveContext.save.day; + gSaveContext.save.daysElapsed = dayTemp; this->unk_144 = 1; - this->unk_146 = gSaveContext.time; + this->unk_146 = gSaveContext.save.time; this->actionFunc = func_80A42AB8; } - } else if (gSaveContext.time == CLOCK_TIME(6, 0)) { + } else if (gSaveContext.save.time == CLOCK_TIME(6, 0)) { this->unk_144 = 0; func_80A41D70(this, globalCtx); if ((gSaveContext.cutsceneTrigger == 0) && (sCutscenes[this->unk_144] >= 0) && @@ -340,12 +340,12 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { player->stateFlags1 |= 0x200; } } else { - if ((gSaveContext.time > CLOCK_TIME(18, 0)) || (gSaveContext.time < CLOCK_TIME(6, 0))) { + if ((gSaveContext.save.time > CLOCK_TIME(18, 0)) || (gSaveContext.save.time < CLOCK_TIME(6, 0))) { this->unk_144 = 0; } else { this->unk_144 = 1; } - this->unk_146 = gSaveContext.time; + this->unk_146 = gSaveContext.save.time; this->actionFunc = func_80A42AB8; } } @@ -356,10 +356,10 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A425E4(this, globalCtx); } - this->lastBellTime = gSaveContext.time; + this->lastBellTime = gSaveContext.save.time; if ((sCutscenes[this->unk_144] < 0) || (globalCtx->actorCtx.unk5 & 2)) { - gSaveContext.unk_3F60 = 0; - gSaveContext.unk_3F64 = 1000.0f; + gSaveContext.screenScaleFlag = 0; + gSaveContext.screenScale = 1000.0f; } } @@ -377,10 +377,10 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { s16 bellDiff; s16 new_var; - temp_a3 = gSaveContext.time - temp_a0; + temp_a3 = gSaveContext.save.time - temp_a0; temp_a2 = this->unk_146 - temp_a0; bellDiff = this->lastBellTime - this->nextBellTime; - new_var = gSaveContext.time - this->nextBellTime; + new_var = gSaveContext.save.time - this->nextBellTime; if ((temp_a3 * temp_a2) <= 0) { gSaveContext.unk_3CA7 = 1; @@ -398,9 +398,9 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { } else if (((sCutscenes[this->unk_144] < 0) || (globalCtx->actorCtx.unk5 & 2)) && CURRENT_DAY != 3) { func_80A41FA4(this, globalCtx); } else { - gSaveContext.unk_3F64 = 0.0f; - Play_SetRespawnData(&globalCtx->state, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF, - &player->unk_3C0, player->unk_3CC); + gSaveContext.screenScale = 0.0f; + Play_SetRespawnData(&globalCtx->state, RESTART_MODE_DOWN, Entrance_CreateIndexFromSpawn(0), + player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); func_80169EFC(&globalCtx->state); if (player->stateFlags1 & 0x800000) { EnHorse* rideActor = (EnHorse*)player->rideActor; @@ -422,7 +422,7 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { if ((sCutscenes[this->unk_144] >= 0) && ((globalCtx->actorCtx.unk5 & 2) == 0)) { player->stateFlags1 |= 0x200; - this->unk_146 = gSaveContext.time; + this->unk_146 = gSaveContext.save.time; } else { if (this->unk_144 == 0) { this->unk_144 = 1; @@ -430,26 +430,26 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { this->unk_144 = 0; } - this->unk_146 = gSaveContext.time += CLOCK_TIME_MINUTE; + this->unk_146 = gSaveContext.save.time += CLOCK_TIME_MINUTE; } } else if ((new_var * bellDiff) <= 0) { func_801A0124(&this->actor.projectedPos, (this->actor.params >> 5) & 0xF); - this->lastBellTime = gSaveContext.time; + this->lastBellTime = gSaveContext.save.time; if (CURRENT_DAY == 3) { if ((this->nextBellTime == CLOCK_TIME(0, 0)) && - ((gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) || + ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) || (globalCtx->sceneNum == SCENE_CLOCKTOWER))) { s32 playerParams; - u32 entranceIndex = gSaveContext.entranceIndex; + u32 entranceIndex = gSaveContext.save.entranceIndex; if ((globalCtx->actorCtx.unk5 & 2)) { playerParams = 0xCFF; } else { playerParams = 0xBFF; } - Play_SetRespawnData(&globalCtx->state, 1, entranceIndex, player->unk_3CE, playerParams, - &player->unk_3C0, player->unk_3CC); + Play_SetRespawnData(&globalCtx->state, RESTART_MODE_RETURN, entranceIndex, player->unk_3CE, + playerParams, &player->unk_3C0, player->unk_3CC); if ((globalCtx->sceneNum == SCENE_TENMON_DAI) || (globalCtx->sceneNum == SCENE_00KEIKOKU)) { globalCtx->nextEntranceIndex = 0x5400; @@ -494,8 +494,8 @@ void func_80A42F20(EnTest4* this, GlobalContext* globalCtx) { if (this->transitionCsTimer == 60) { Player* player = GET_PLAYER(globalCtx); - gSaveContext.time += CLOCK_TIME_MINUTE; - this->unk_146 = gSaveContext.time; + gSaveContext.save.time += CLOCK_TIME_MINUTE; + this->unk_146 = gSaveContext.save.time; globalCtx->numSetupActors = -globalCtx->numSetupActors; player->stateFlags1 &= ~0x200; } @@ -517,8 +517,8 @@ void func_80A42F20(EnTest4* this, GlobalContext* globalCtx) { } void func_80A430C8(EnTest4* this, GlobalContext* globalCtx) { - if ((CURRENT_DAY == 2) && (gSaveContext.time >= CLOCK_TIME(7, 0)) && (gSaveContext.time < CLOCK_TIME(17, 30)) && - (globalCtx->envCtx.unk_F2[2] == 0)) { + if ((CURRENT_DAY == 2) && (gSaveContext.save.time >= CLOCK_TIME(7, 0)) && + (gSaveContext.save.time < CLOCK_TIME(17, 30)) && (globalCtx->envCtx.unk_F2[2] == 0)) { // rain? D_801BDBB0 = 1; @@ -542,7 +542,7 @@ void func_80A430C8(EnTest4* this, GlobalContext* globalCtx) { } void func_80A431C8(EnTest4* this, GlobalContext* globalCtx) { - if (((gSaveContext.time >= CLOCK_TIME(17, 30)) && (gSaveContext.time < CLOCK_TIME(23, 0)) && + if (((gSaveContext.save.time >= CLOCK_TIME(17, 30)) && (gSaveContext.save.time < CLOCK_TIME(23, 0)) && (globalCtx->envCtx.unk_F2[0] != 0)) || (globalCtx->envCtx.unk_F2[2] != 0)) { D_801BDBB0 = 0; diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index c16d8c220..5a89347e7 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -168,7 +168,7 @@ void EnThiefbird_Init(Actor* thisx, GlobalContext* globalCtx) { D_80C1392C = 1; Math_Vec3f_Copy(&D_80C13920, &this->actor.world.pos); Actor_MarkForDeath(&this->actor); - } else if ((gSaveContext.stolenItems & 0xFF000000) >> 0x18) { + } else if (STOLEN_ITEM_1 != STOLEN_ITEM_NONE) { Actor_MarkForDeath(&this->actor); } else { func_80C11538(this); @@ -213,17 +213,17 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { s32 itemId1; s16 itemId2 = 0; - for (; slotId < ARRAY_COUNT(gSaveContext.inventory.items); slotId++) { - if ((gSaveContext.inventory.items[slotId] >= ITEM_BOTTLE) && - (gSaveContext.inventory.items[slotId] <= ITEM_POTION_BLUE)) { + for (; slotId < 24; slotId++) { + if ((gSaveContext.save.inventory.items[slotId] >= ITEM_BOTTLE) && + (gSaveContext.save.inventory.items[slotId] <= ITEM_POTION_BLUE)) { isItemFound = true; - itemId2 = gSaveContext.inventory.items[slotId]; + itemId2 = gSaveContext.save.inventory.items[slotId]; break; } } - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { - phi_a3 = CUR_EQUIP_VALUE_VOID(EQUIP_SWORD); + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { + phi_a3 = GET_CUR_EQUIP_VALUE(EQUIP_SWORD); if (INV_CONTENT(ITEM_SWORD_GREAT_FAIRY) == ITEM_SWORD_GREAT_FAIRY) { phi_a3 += 4; } @@ -271,10 +271,10 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { return false; } - if (!((gSaveContext.stolenItems & 0xFF000000) >> 0x18)) { - gSaveContext.stolenItems = (gSaveContext.stolenItems & 0xFFFFFF) | ((itemId1 & 0xFF) << 0x18); + if (STOLEN_ITEM_1 == STOLEN_ITEM_NONE) { + SET_STOLEN_ITEM_1(itemId1); } else { - gSaveContext.stolenItems = (gSaveContext.stolenItems & 0xFF00FFFF) | ((itemId1 & 0xFF) << 0x10); + SET_STOLEN_ITEM_2(itemId1); } return true; @@ -334,7 +334,7 @@ s32 func_80C10E98(GlobalContext* globalCtx) { spAC = 0; } - sp98 = (gSaveContext.rupees / 4) * 3; + sp98 = (gSaveContext.save.playerData.rupees / 4) * 3; phi_s0_2 = sp98 / 50; sp5C = (-spB0 - spAC); sp5C += 8; @@ -570,8 +570,7 @@ void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); if (!(this->collider.base.atFlags & AT_BOUNCED)) { if ((D_80C1392C != 0) && CUR_UPG_VALUE(UPG_QUIVER) && - (!((gSaveContext.stolenItems & 0xFF000000) >> 0x18) || - !((gSaveContext.stolenItems & 0xFF0000) >> 0x10)) && + ((STOLEN_ITEM_1 == STOLEN_ITEM_NONE) || (STOLEN_ITEM_2 == STOLEN_ITEM_NONE)) && (Rand_ZeroOne() < 0.5f) && func_80C10B0C(this, globalCtx)) { func_80C1242C(this); } else if (func_80C10E98(globalCtx)) { diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 60488183e..58d0fc0a2 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -502,7 +502,7 @@ s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp1E = gSaveContext.time - 0x3FFC; + u16 sp1E = gSaveContext.save.time - 0x3FFC; u8 params = ENTK_GET_F800(&this->actor); u16 phi_a1; s32 idx = arg2->unk0 - 1; @@ -534,14 +534,14 @@ void func_80AED4F8(EnTk* this, GlobalContext* globalCtx) { } void func_80AED544(EnTk* this, GlobalContext* globalCtx) { - if (!(gSaveContext.weekEventReg[31] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[31] & 0x10)) { Message_StartTextbox(globalCtx, 0x13FE, &this->actor); - gSaveContext.weekEventReg[31] |= 0x10; - } else if (gSaveContext.time < CLOCK_TIME(9, 0)) { + gSaveContext.save.weekEventReg[31] |= 0x10; + } else if (gSaveContext.save.time < CLOCK_TIME(9, 0)) { Message_StartTextbox(globalCtx, 0x13FF, &this->actor); - } else if (gSaveContext.time < CLOCK_TIME(12, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(12, 0)) { Message_StartTextbox(globalCtx, 0x1400, &this->actor); - } else if (gSaveContext.time < CLOCK_TIME(15, 0)) { + } else if (gSaveContext.save.time < CLOCK_TIME(15, 0)) { Message_StartTextbox(globalCtx, 0x1401, &this->actor); } else { Message_StartTextbox(globalCtx, 0x1402, &this->actor); @@ -563,7 +563,7 @@ void func_80AED610(EnTk* this, GlobalContext* globalCtx) { func_80AED544(this, globalCtx); } else if (!Flags_GetSwitch(globalCtx, ENTK_GET_7F0(&this->actor))) { Message_StartTextbox(globalCtx, 0x1403, &this->actor); - } else if (gSaveContext.weekEventReg[60] & 2) { + } else if (gSaveContext.save.weekEventReg[60] & 2) { func_80AED544(this, globalCtx); } else { Message_StartTextbox(globalCtx, 0x1413, &this->actor); @@ -594,7 +594,7 @@ void func_80AED610(EnTk* this, GlobalContext* globalCtx) { case 0x1413: func_801159EC(30); - gSaveContext.weekEventReg[60] |= 2; + gSaveContext.save.weekEventReg[60] |= 2; func_80151938(globalCtx, 0x13FF); break; @@ -757,7 +757,7 @@ void func_80AEDE10(EnTk* this, GlobalContext* globalCtx) { switch (this->unk_310) { case 0: this->unk_2CA &= ~0x1000; - if (!(gSaveContext.weekEventReg[52] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[52] & 0x80)) { this->unk_2E6 = 0x1405; } else { this->unk_2E6 = 0x140B; @@ -862,7 +862,7 @@ void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { break; case 0x140A: - gSaveContext.weekEventReg[52] |= 0x80; + gSaveContext.save.weekEventReg[52] |= 0x80; case 0x140B: func_80AEE784(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Torch/z_en_torch.c b/src/overlays/actors/ovl_En_Torch/z_en_torch.c index b5c891af0..fc06cff18 100644 --- a/src/overlays/actors/ovl_En_Torch/z_en_torch.c +++ b/src/overlays/actors/ovl_En_Torch/z_en_torch.c @@ -21,7 +21,7 @@ static u8 sChestContents[] = { 0x02, 0x04, 0x05, 0x06, 0x36, 0x3A, 0x14, 0x14 }; void EnTorch_Init(Actor* thisx, GlobalContext* globalCtx) { EnTorch* this = THIS; - s8 returnData = gSaveContext.respawn[3].data; + s8 returnData = gSaveContext.respawn[RESPAWN_MODE_UNK_3].data; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOX, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, diff --git a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c index 3789bb99a..c6931fac5 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -87,8 +87,8 @@ void EnTorch2_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnTorch2* this = THIS; Collider_DestroyCylinder(globalCtx, &this->collider); - Play_SetRespawnData(&globalCtx->state, this->actor.params + 3, 0xFF, 0, 0xBFF, &this->actor.world.pos, - this->actor.shape.rot.y); + Play_SetRespawnData(&globalCtx->state, this->actor.params + RESPAWN_MODE_GORON - 1, 0xFF, 0, 0xBFF, + &this->actor.world.pos, this->actor.shape.rot.y); globalCtx->actorCtx.unk254[this->actor.params] = 0; } diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index d446fd9d3..f12baac71 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -11,7 +11,7 @@ #define THIS ((EnToto*)thisx) -#define ENTOTO_WEEK_EVENT_FLAGS (gSaveContext.weekEventReg[50] & 1 || gSaveContext.weekEventReg[51] & 0x80) +#define ENTOTO_WEEK_EVENT_FLAGS (gSaveContext.save.weekEventReg[50] & 1 || gSaveContext.save.weekEventReg[51] & 0x80) void EnToto_Init(Actor* thisx, GlobalContext* globalCtx); void EnToto_Destroy(Actor* thisx, GlobalContext* globalCtx); @@ -185,7 +185,7 @@ void EnToto_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); if (globalCtx->sceneNum == SCENE_MILK_BAR && - (gSaveContext.time >= CLOCK_TIME(6, 0) && gSaveContext.time < CLOCK_TIME(21, 30))) { + (gSaveContext.save.time >= CLOCK_TIME(6, 0) && gSaveContext.save.time < CLOCK_TIME(21, 30))) { Actor_MarkForDeath(&this->actor); return; } @@ -253,7 +253,7 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { //! @TODO: 0xED02 nor 0xED01 match CLOCK_TIME macro if ((globalCtx->sceneNum == SCENE_MILK_BAR && - !(gSaveContext.time >= CLOCK_TIME(6, 0) && gSaveContext.time < 0xED02)) || + !(gSaveContext.save.time >= CLOCK_TIME(6, 0) && gSaveContext.save.time < 0xED02)) || (globalCtx->sceneNum != SCENE_MILK_BAR && func_80BA397C(this, 0x2000))) { if (this->unk2B6 != 0) { this->text = D_80BA5044; @@ -438,7 +438,7 @@ s32 func_80BA4204(EnToto* this, GlobalContext* globalCtx) { if (DECR(this->unk2B1) == 0) { if (!ENTOTO_WEEK_EVENT_FLAGS) { - temp_v1_2 = &D_80BA50DC[gSaveContext.playerForm - 1]; + temp_v1_2 = &D_80BA50DC[gSaveContext.save.playerForm - 1]; Message_StartTextbox(globalCtx, (this->text->unk0 == 6) ? temp_v1_2->unk0 : temp_v1_2->unk4, NULL); } return 1; @@ -516,7 +516,7 @@ s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { return this->text->unk1; } if (player->actor.bgCheckFlags & 1) { - temp_s0 = &D_80BA50DC[gSaveContext.playerForm - 1]; + temp_s0 = &D_80BA50DC[gSaveContext.save.playerForm - 1]; if (func_80BA44D4(temp_s0, player)) { Math_Vec3s_ToVec3f(&player->actor.world.pos, &temp_s0->unk6); player->actor.shape.rot.y = 0; @@ -529,8 +529,8 @@ s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { if (this->unk2B1 < 10) { this->unk2B1++; if (this->unk2B1 >= 10) { - Message_StartTextbox(globalCtx, D_80BA50DC[((void)0, gSaveContext.playerForm) - 1].unk2, - NULL); + Message_StartTextbox(globalCtx, + D_80BA50DC[((void)0, gSaveContext.save.playerForm) - 1].unk2, NULL); } } return 0; @@ -550,17 +550,17 @@ s32 func_80BA46D8(EnToto* this, GlobalContext* globalCtx) { s32 func_80BA4740(EnToto* this, GlobalContext* globalCtx) { if (globalCtx->msgCtx.ocarinaMode == 4) { - if (gSaveContext.playerForm == PLAYER_FORM_HUMAN) { - gSaveContext.weekEventReg[56] |= 0x10; + if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { + gSaveContext.save.weekEventReg[56] |= 0x10; } - if (gSaveContext.playerForm == PLAYER_FORM_DEKU) { - gSaveContext.weekEventReg[56] |= 0x20; + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { + gSaveContext.save.weekEventReg[56] |= 0x20; } - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - gSaveContext.weekEventReg[56] |= 0x40; + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + gSaveContext.save.weekEventReg[56] |= 0x40; } - if (gSaveContext.playerForm == PLAYER_FORM_GORON) { - gSaveContext.weekEventReg[56] |= 0x80; + if (gSaveContext.save.playerForm == PLAYER_FORM_GORON) { + gSaveContext.save.weekEventReg[56] |= 0x80; } return 1; } @@ -572,20 +572,20 @@ s32 func_80BA47E0(EnToto* this, GlobalContext* globalCtx) { s32 i; this->unk2B3 = 0; - if (gSaveContext.weekEventReg[56] & 0x10) { + if (gSaveContext.save.weekEventReg[56] & 0x10) { this->unk2B3 += 1; } - if (gSaveContext.weekEventReg[56] & 0x20) { + if (gSaveContext.save.weekEventReg[56] & 0x20) { this->unk2B3 += 2; } - if (gSaveContext.weekEventReg[56] & 0x40) { + if (gSaveContext.save.weekEventReg[56] & 0x40) { this->unk2B3 += 4; } - if (gSaveContext.weekEventReg[56] & 0x80) { + if (gSaveContext.save.weekEventReg[56] & 0x80) { this->unk2B3 += 8; } for (i = 0; i < 4; i++) { - if (gSaveContext.playerForm != (i + 1) && (D_80BA5128[i] & this->unk2B3)) { + if (gSaveContext.save.playerForm != (i + 1) && (D_80BA5128[i] & this->unk2B3)) { Math_Vec3s_ToVec3f(&spawnPos, &D_80BA50DC[i].unk6); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_PLAYER, spawnPos.x, spawnPos.y, spawnPos.z, i + 2, 0, 0, -1); @@ -622,9 +622,9 @@ s32 func_80BA4A00(EnToto* this, GlobalContext* globalCtx) { func_800B7298(globalCtx, NULL, 0x45); if (this->unk2B3 == 0xF) { if (CURRENT_DAY == 1) { - gSaveContext.weekEventReg[50] |= 1; + gSaveContext.save.weekEventReg[50] |= 1; } else { - gSaveContext.weekEventReg[51] |= 0x80; + gSaveContext.save.weekEventReg[51] |= 0x80; } } else { func_80BA402C(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.c b/src/overlays/actors/ovl_En_Trt/z_en_trt.c index 13a3d20cb..dde803708 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -189,7 +189,7 @@ u16 EnTrt_GetItemTextId(EnTrt* this) { u16 EnTrt_GetItemChoiceTextId(EnTrt* this) { EnGirlA* item = this->items[this->cursorIdx]; - if (item->actor.params == SI_POTION_BLUE && !(gSaveContext.weekEventReg[53] & 0x10)) { + if (item->actor.params == SI_POTION_BLUE && !(gSaveContext.save.weekEventReg[53] & 0x10)) { this->textId = 0x881; return 0x881; } @@ -335,7 +335,7 @@ void EnTrt_GetMushroom(EnTrt* this, GlobalContext* globalCtx) { case 0x883: this->textId = 0x884; Message_StartTextbox(globalCtx, this->textId, &this->actor); - gSaveContext.weekEventReg[53] |= 8; + gSaveContext.save.weekEventReg[53] |= 8; func_80123D50(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); break; case 0x888: @@ -387,7 +387,7 @@ void EnTrt_Goodbye(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x88F) { - if (Interface_HasEmptyBottle() || !(gSaveContext.weekEventReg[12] & 0x10)) { + if (Interface_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[12] & 0x10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; @@ -398,28 +398,28 @@ void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { } else { this->tmpTextId = this->textId; this->textId = 0x88E; - gSaveContext.weekEventReg[85] |= 8; + gSaveContext.save.weekEventReg[85] |= 8; Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } } else { - if (gSaveContext.weekEventReg[12] & 8) { + if (gSaveContext.save.weekEventReg[12] & 8) { this->textId = 0x83D; EnTrt_SetupStartShopping(globalCtx, this, 0); - } else if (gSaveContext.weekEventReg[84] & 0x40) { + } else if (gSaveContext.save.weekEventReg[84] & 0x40) { this->textId = 0x83B; if (Interface_HasItemInBottle(ITEM_POTION_RED)) { EnTrt_SetupStartShopping(globalCtx, this, false); } else { this->actionFunc = EnTrt_TryToGiveRedPotion; } - } else if (gSaveContext.weekEventReg[16] & 0x10) { + } else if (gSaveContext.save.weekEventReg[16] & 0x10) { this->timer = 30; this->textId = 0x838; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING_SPECIAL; this->actionFunc = EnTrt_Surprised; return; - } else if (gSaveContext.weekEventReg[17] & 1) { + } else if (gSaveContext.save.weekEventReg[17] & 1) { this->textId = 0x835; EnTrt_SetupStartShopping(globalCtx, this, false); } @@ -433,13 +433,13 @@ void EnTrt_GiveRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - if (!(gSaveContext.weekEventReg[12] & 0x10)) { - gSaveContext.weekEventReg[12] |= 0x10; + if (!(gSaveContext.save.weekEventReg[12] & 0x10)) { + gSaveContext.save.weekEventReg[12] |= 0x10; } - gSaveContext.weekEventReg[84] |= 0x40; + gSaveContext.save.weekEventReg[84] |= 0x40; player->stateFlags2 &= ~0x20000000; this->actionFunc = EnTrt_GivenRedPotionForKoume; - } else if (gSaveContext.weekEventReg[12] & 0x10) { + } else if (gSaveContext.save.weekEventReg[12] & 0x10) { Actor_PickUp(&this->actor, globalCtx, GI_POTION_RED, 300.0f, 300.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_BOTTLE_POTION_RED, 300.0f, 300.0f); @@ -732,7 +732,7 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { this->drawCursor = 0; this->shopItemSelectedTween = 0.0f; item->boughtFunc(globalCtx, item); - gSaveContext.weekEventReg[53] |= 0x10; + gSaveContext.save.weekEventReg[53] |= 0x10; } } } @@ -741,14 +741,14 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((gSaveContext.weekEventReg[85] & 8) && !(gSaveContext.weekEventReg[84] & 0x40)) { + if ((gSaveContext.save.weekEventReg[85] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40)) { this->textId = 0x88F; } else if (!(this->flags & ENTRT_MET)) { this->textId = 0x834; } else { this->textId = 0x83E; } - if (!(gSaveContext.weekEventReg[53] & 8)) { + if (!(gSaveContext.save.weekEventReg[53] & 8)) { this->talkOptionTextId = 0x845; } else if (this->flags & ENTRT_GIVEN_MUSHROOM) { this->talkOptionTextId = 0x882; @@ -873,8 +873,8 @@ void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { this->animationIndex = 5; switch (this->textId) { case 0x834: - if (!(gSaveContext.weekEventReg[12] & 8) && !(gSaveContext.weekEventReg[84] & 0x40) && - !(gSaveContext.weekEventReg[16] & 0x10) && !(gSaveContext.weekEventReg[17] & 1)) { + if (!(gSaveContext.save.weekEventReg[12] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40) && + !(gSaveContext.save.weekEventReg[16] & 0x10) && !(gSaveContext.save.weekEventReg[17] & 1)) { func_8011552C(globalCtx, 6); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; @@ -931,7 +931,7 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCt this->blinkFunc = EnTrt_Blink; if (talkState == 6 && Message_ShouldAdvance(globalCtx)) { - if (Interface_HasEmptyBottle() || !(gSaveContext.weekEventReg[12] & 0x10)) { + if (Interface_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[12] & 0x10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; @@ -940,7 +940,7 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCt } else { this->tmpTextId = this->textId; this->textId = 0x88E; - gSaveContext.weekEventReg[85] |= 8; + gSaveContext.save.weekEventReg[85] |= 8; Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } @@ -961,7 +961,7 @@ void EnTrt_TryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { } else { this->tmpTextId = this->textId; this->textId = 0x88E; - gSaveContext.weekEventReg[85] |= 8; + gSaveContext.save.weekEventReg[85] |= 8; Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } @@ -1033,7 +1033,7 @@ void EnTrt_ShopkeeperGone(EnTrt* this, GlobalContext* globalCtx) { } } if (talkState == 6 && Message_ShouldAdvance(globalCtx)) { - if (gSaveContext.weekEventReg[20] & 2) { + if (gSaveContext.save.weekEventReg[20] & 2) { globalCtx->nextEntranceIndex = 0xC50; } else { globalCtx->nextEntranceIndex = 0x8450; @@ -1373,7 +1373,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { itemGiven = func_80123810(globalCtx); if (itemGiven > EXCH_ITEM_NONE) { if (itemGiven == EXCH_ITEM_1E) { - if (gSaveContext.weekEventReg[53] & 8) { + if (gSaveContext.save.weekEventReg[53] & 8) { player->actor.textId = 0x888; } else { player->actor.textId = 0x883; @@ -1442,7 +1442,8 @@ void EnTrt_LookToShopkeeperFromShelf(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_InitShopkeeper(EnTrt* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_trt_Skel_00FEF0, &object_trt_Anim_00FD34, NULL, NULL, 0); - if (!(gSaveContext.weekEventReg[12] & 8) && !(gSaveContext.weekEventReg[84] & 0x40) && gSaveContext.day >= 2) { + if (!(gSaveContext.save.weekEventReg[12] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40) && + gSaveContext.save.day >= 2) { this->actor.draw = NULL; } else { this->actor.draw = EnTrt_Draw; @@ -1457,7 +1458,8 @@ void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.colChkInfo.cylRadius = 50; this->timer = Rand_S16Offset(40, 20); - if (!(gSaveContext.weekEventReg[12] & 8) && !(gSaveContext.weekEventReg[84] & 0x40) && gSaveContext.day >= 2) { + if (!(gSaveContext.save.weekEventReg[12] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40) && + gSaveContext.save.day >= 2) { this->textId = 0x84A; this->actionFunc = EnTrt_ShopkeeperGone; } else { @@ -1522,7 +1524,7 @@ void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { this->blinkTimer = 20; this->eyeTextureIdx = 0; this->blinkFunc = EnTrt_EyesClosed; - if (gSaveContext.weekEventReg[53] & 8) { + if (gSaveContext.save.weekEventReg[53] & 8) { this->flags |= ENTRT_GIVEN_MUSHROOM; } diff --git a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c index f8de547cd..bca0f4b84 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -131,13 +131,13 @@ void func_80AD341C(EnTrt2* this, GlobalContext* globalCtx) { } void func_80AD349C(EnTrt2* this) { - if ((gSaveContext.weekEventReg[85] & 0x10) && !(gSaveContext.weekEventReg[84] & 0x40)) { + if ((gSaveContext.save.weekEventReg[85] & 0x10) && !(gSaveContext.save.weekEventReg[84] & 0x40)) { this->unk_3A8 = 0x88F; } else if (this->unk_3A8 == 0) { this->unk_3A8 = 0x84B; - } else if (gSaveContext.weekEventReg[16] & 0x10) { + } else if (gSaveContext.save.weekEventReg[16] & 0x10) { this->unk_3A8 = 0x838; - } else if (gSaveContext.weekEventReg[17] & 1) { + } else if (gSaveContext.save.weekEventReg[17] & 1) { this->unk_3A8 = 0x84D; } else { this->unk_3A8 = 0x849; @@ -365,7 +365,7 @@ void func_80AD3E34(EnTrt2* this, GlobalContext* globalCtx) { globalCtx->msgCtx.unk12023 = 4; this->unk_3B2 = 12; } else { - gSaveContext.weekEventReg[85] |= 0x10; + gSaveContext.save.weekEventReg[85] |= 0x10; this->unk_3A8 = 0x88E; Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); this->unk_3B2 = 10; @@ -378,11 +378,11 @@ void func_80AD3EF0(EnTrt2* this, GlobalContext* globalCtx) { if (temp_v0 == 6) { if (Message_ShouldAdvance(globalCtx)) { - if ((Interface_HasEmptyBottle() && !(gSaveContext.weekEventReg[84] & 0x40)) || - !(gSaveContext.weekEventReg[12] & 0x10)) { + if ((Interface_HasEmptyBottle() && !(gSaveContext.save.weekEventReg[84] & 0x40)) || + !(gSaveContext.save.weekEventReg[12] & 0x10)) { this->unk_3B2 = 12; } else { - gSaveContext.weekEventReg[85] |= 0x10; + gSaveContext.save.weekEventReg[85] |= 0x10; this->unk_3A8 = 0x88E; Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); this->unk_3B2 = 10; @@ -397,13 +397,13 @@ void func_80AD3EF0(EnTrt2* this, GlobalContext* globalCtx) { void func_80AD3FF4(EnTrt2* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { - if (!(gSaveContext.weekEventReg[12] & 0x10)) { - gSaveContext.weekEventReg[12] |= 0x10; + if (!(gSaveContext.save.weekEventReg[12] & 0x10)) { + gSaveContext.save.weekEventReg[12] |= 0x10; } - gSaveContext.weekEventReg[84] |= 0x40; + gSaveContext.save.weekEventReg[84] |= 0x40; this->actor.parent = NULL; this->unk_3B2 = 14; - } else if (gSaveContext.weekEventReg[12] & 0x10) { + } else if (gSaveContext.save.weekEventReg[12] & 0x10) { Actor_PickUp(&this->actor, globalCtx, GI_POTION_RED, 300.0f, 300.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_BOTTLE_POTION_RED, 300.0f, 300.0f); @@ -729,20 +729,20 @@ void func_80AD4DB4(EnTrt2* this, GlobalContext* globalCtx) { this->unk_3B8 = 0; this->unk_3BC = func_80AD4608; - if (gSaveContext.weekEventReg[12] & 8) { + if (gSaveContext.save.weekEventReg[12] & 8) { Actor_MarkForDeath(&this->actor); return; } - if (gSaveContext.weekEventReg[84] & 0x40) { + if (gSaveContext.save.weekEventReg[84] & 0x40) { Actor_MarkForDeath(&this->actor); return; } if ((globalCtx->sceneNum == SCENE_20SICHITAI) || (globalCtx->sceneNum == SCENE_20SICHITAI2)) { - if (gSaveContext.day == 2) { - if (!(gSaveContext.weekEventReg[15] & 0x80)) { - gSaveContext.weekEventReg[15] |= 0x80; + if (gSaveContext.save.day == 2) { + if (!(gSaveContext.save.weekEventReg[15] & 0x80)) { + gSaveContext.save.weekEventReg[15] |= 0x80; this->unk_3B2 = 3; } else { Actor_MarkForDeath(&this->actor); @@ -752,14 +752,14 @@ void func_80AD4DB4(EnTrt2* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); return; } - } else if (gSaveContext.day == 2) { - if (gSaveContext.weekEventReg[15] & 0x80) { + } else if (gSaveContext.save.day == 2) { + if (gSaveContext.save.weekEventReg[15] & 0x80) { this->unk_3B2 = 4; } else { Actor_MarkForDeath(&this->actor); return; } - } else if (gSaveContext.day == 3) { + } else if (gSaveContext.save.day == 3) { this->unk_3B2 = 4; } this->actionFunc = func_80AD4FE4; diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index 41d40649b..e3bfe7f36 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -654,11 +654,11 @@ UNK_TYPE* func_80A871E0(EnTru* this, GlobalContext* globalCtx) { return D_80A88924; } - if (!(this->unk_34E & 0x40) && !(gSaveContext.weekEventReg[16] & 0x10)) { + if (!(this->unk_34E & 0x40) && !(gSaveContext.save.weekEventReg[16] & 0x10)) { return D_80A88918; } - if ((this->unk_34E & 0x1000) && !(gSaveContext.weekEventReg[16] & 0x10)) { + if ((this->unk_34E & 0x1000) && !(gSaveContext.save.weekEventReg[16] & 0x10)) { return D_80A88910; } @@ -753,7 +753,7 @@ s32 func_80A875AC(Actor* thisx, GlobalContext* globalCtx) { switch (this->unk_364) { case 0: - if ((this->unk_34E & 0x40) || (gSaveContext.weekEventReg[16] & 0x10)) { + if ((this->unk_34E & 0x40) || (gSaveContext.save.weekEventReg[16] & 0x10)) { this->unk_374 = this->actor.cutscene; this->unk_364++; } else { @@ -1029,7 +1029,7 @@ s32 func_80A87DC0(Actor* thisx, GlobalContext* globalCtx) { case 4: if (func_80A87400(this, globalCtx) || (DECR(this->unk_362) == 0)) { ret = true; - gSaveContext.weekEventReg[12] |= 8; + gSaveContext.save.weekEventReg[12] |= 8; } break; } @@ -1046,7 +1046,7 @@ s32 func_80A87DC0(Actor* thisx, GlobalContext* globalCtx) { void func_80A87FD0(EnTru* this, GlobalContext* globalCtx) { if (this->actor.draw != NULL) { - if ((this->unk_34E & 0x80) || (gSaveContext.weekEventReg[16] & 0x10)) { + if ((this->unk_34E & 0x80) || (gSaveContext.save.weekEventReg[16] & 0x10)) { if (func_80A873B8(this)) { SubS_UpdateFlags(&this->unk_34E, 3, 7); } else { @@ -1068,7 +1068,7 @@ void func_80A87FD0(EnTru* this, GlobalContext* globalCtx) { func_80A86924(this, 2); } } - } else if (!(gSaveContext.weekEventReg[16] & 0x10) && (fabsf(this->actor.playerHeightRel) < 10.0f) && + } else if (!(gSaveContext.save.weekEventReg[16] & 0x10) && (fabsf(this->actor.playerHeightRel) < 10.0f) && (this->actor.xzDistToPlayer < 140.0f)) { SubS_UpdateFlags(&this->unk_34E, 4, 7); this->unk_34E |= 0x1040; @@ -1093,12 +1093,12 @@ void func_80A881E0(EnTru* this, GlobalContext* globalCtx) { ActorCutscene_Stop(ActorCutscene_GetCurrentIndex()); } - if (!(this->unk_34E & 0x40) && !(gSaveContext.weekEventReg[16] & 0x10)) { + if (!(this->unk_34E & 0x40) && !(gSaveContext.save.weekEventReg[16] & 0x10)) { func_80A86924(this, 0); } else if (this->unk_34E & 0x80) { func_80A86924(this, 0); func_80A86460(this); - } else if (gSaveContext.weekEventReg[16] & 0x10) { + } else if (gSaveContext.save.weekEventReg[16] & 0x10) { func_80A86924(this, 6); } @@ -1115,7 +1115,7 @@ void func_80A881E0(EnTru* this, GlobalContext* globalCtx) { void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { EnTru* this = THIS; - if ((gSaveContext.entranceIndex != 0xC200) || (gSaveContext.weekEventReg[12] & 8)) { + if ((gSaveContext.save.entranceIndex != 0xC200) || (gSaveContext.save.weekEventReg[12] & 8)) { Actor_MarkForDeath(&this->actor); return; } @@ -1136,7 +1136,7 @@ void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.008f); this->unk_34E = 0; - if (gSaveContext.weekEventReg[16] & 0x10) { + if (gSaveContext.save.weekEventReg[16] & 0x10) { func_80A86924(this, 5); } else { this->unk_388 = 0; diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c index 4425e7f87..37715b513 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c @@ -332,8 +332,9 @@ void func_80B76980(EnTruMt* this, GlobalContext* globalCtx) { } else if (gSaveContext.eventInf[4] & 1) { u32 score = gSaveContext.minigameScore; - if (((gSaveContext.unk_EE8 & 0xFFFF0000) >> 0x10) < score) { - gSaveContext.unk_EE8 = ((gSaveContext.minigameScore & 0xFFFF) << 0x10) | (gSaveContext.unk_EE8 & 0xFFFF); + if (((gSaveContext.save.unk_EE8 & 0xFFFF0000) >> 0x10) < score) { + gSaveContext.save.unk_EE8 = + ((gSaveContext.minigameScore & 0xFFFF) << 0x10) | (gSaveContext.save.unk_EE8 & 0xFFFF); gSaveContext.eventInf[3] |= 0x80; } } diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c index e3d6831b6..e999e5c5c 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c @@ -86,7 +86,7 @@ void func_80ADFCEC(EnTsn* this, GlobalContext* globalCtx) { switch (ENTSN_GET_F(&this->actor)) { case ENTSN_F_0: - if (gSaveContext.weekEventReg[26] & 8) { + if (gSaveContext.save.weekEventReg[26] & 8) { Actor_MarkForDeath(&this->actor); return; } @@ -94,7 +94,7 @@ void func_80ADFCEC(EnTsn* this, GlobalContext* globalCtx) { break; case ENTSN_F_1: - if (gSaveContext.weekEventReg[26] & 4) { + if (gSaveContext.save.weekEventReg[26] & 4) { this->actor.textId = 0x1091; } else { this->actor.textId = 0x108A; @@ -102,7 +102,7 @@ void func_80ADFCEC(EnTsn* this, GlobalContext* globalCtx) { break; } - if (gSaveContext.weekEventReg[55] & 0x80) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { if ((ENTSN_GET_F(&this->actor)) == ENTSN_F_0) { this->actionFunc = func_80AE0D78; } else { @@ -143,7 +143,7 @@ void EnTsn_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.terminalVelocity = -9.0f; this->actor.gravity = -1.0f; - if (gSaveContext.weekEventReg[55] & 0x80) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { Actor_MarkForDeath(&this->actor); } } @@ -157,15 +157,15 @@ void EnTsn_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80ADFF84(EnTsn* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.weekEventReg[26] & 8) { + if (gSaveContext.save.weekEventReg[26] & 8) { textId = 0x107E; - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[25] & 0x80) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[25] & 0x80) { textId = 0x1083; } else { textId = 0x107F; } - } else if (gSaveContext.weekEventReg[26] & 1) { + } else if (gSaveContext.save.weekEventReg[26] & 1) { textId = 0x1089; } else { textId = 0x1084; @@ -207,14 +207,14 @@ void func_80AE0010(EnTsn* this, GlobalContext* globalCtx) { case 0x1082: Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); - gSaveContext.weekEventReg[25] |= 0x80; + gSaveContext.save.weekEventReg[25] |= 0x80; func_801477B4(globalCtx); this->actionFunc = func_80AE0304; this->actor.textId = 0; break; case 0x1083: - gSaveContext.weekEventReg[25] |= 0x80; + gSaveContext.save.weekEventReg[25] |= 0x80; func_801477B4(globalCtx); this->actionFunc = func_80AE0304; this->actor.textId = 0; @@ -232,7 +232,7 @@ void func_80AE0010(EnTsn* this, GlobalContext* globalCtx) { case 0x1089: case 0x1093: - gSaveContext.weekEventReg[26] |= 1; + gSaveContext.save.weekEventReg[26] |= 1; func_801477B4(globalCtx); Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); this->actionFunc = func_80AE0304; @@ -245,7 +245,7 @@ void func_80AE0010(EnTsn* this, GlobalContext* globalCtx) { break; case 0x1088: - gSaveContext.weekEventReg[26] |= 1; + gSaveContext.save.weekEventReg[26] |= 1; if (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA) { func_801477B4(globalCtx); Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); @@ -316,7 +316,7 @@ void func_80AE04FC(EnTsn* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 0x10) { sp24 = func_80123810(globalCtx); if (sp24 != 0) { - gSaveContext.weekEventReg[26] |= 2; + gSaveContext.save.weekEventReg[26] |= 2; } if (sp24 > 0) { @@ -388,13 +388,13 @@ void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.currentTextId) { case 0x106E: - if (gSaveContext.weekEventReg[25] & 0x40) { + if (gSaveContext.save.weekEventReg[25] & 0x40) { func_80151938(globalCtx, 0x1074); } else { func_80151938(globalCtx, 0x106F); } this->unk_220 |= 2; - gSaveContext.weekEventReg[25] |= 0x40; + gSaveContext.save.weekEventReg[25] |= 0x40; ENTSN_SET_Z(&this->unk_1D8->actor, true); this->unk_220 |= 4; break; @@ -425,7 +425,7 @@ void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { case 0x107C: if (Interface_HasEmptyBottle()) { - gSaveContext.weekEventReg[26] |= 8; + gSaveContext.save.weekEventReg[26] |= 8; func_801477B4(globalCtx); this->actionFunc = func_80AE0460; func_80AE0460(this, globalCtx); @@ -462,7 +462,7 @@ void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { case 0x108A: case 0x1091: - gSaveContext.weekEventReg[26] |= 4; + gSaveContext.save.weekEventReg[26] |= 4; func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); this->unk_220 |= 2; this->actor.textId = 0x1091; @@ -477,7 +477,7 @@ void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { break; case 0x1092: - if (gSaveContext.weekEventReg[26] & 8) { + if (gSaveContext.save.weekEventReg[26] & 8) { func_80AE0698(this, globalCtx); } else { func_80151938(globalCtx, 0x10A7); diff --git a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c index ffbb9526b..51ef3ef38 100644 --- a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c +++ b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c @@ -112,7 +112,7 @@ void func_80A66278(EnWarpUzu* this, GlobalContext* globalCtx) { void func_80A66384(EnWarpUzu* this, GlobalContext* globalCtx) { globalCtx->nextEntranceIndex = 0x22A0; - gSaveContext.respawn[0].entranceIndex = globalCtx->nextEntranceIndex; + gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex = globalCtx->nextEntranceIndex; func_80169EFC(&globalCtx->state); gSaveContext.respawnFlag = -2; this->actionFunc = EnWarpUzu_DoNothing; diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index feea46771..f4d999fae 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -77,7 +77,7 @@ void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx) { EnWeatherTag_SetupAction(this, func_80966A08); break; case WEATHERTAG_TYPE_UNK1: - if (gSaveContext.weekEventReg[52] & 0x20) { // if cleared STT + if (gSaveContext.save.weekEventReg[52] & 0x20) { // if cleared STT Actor_MarkForDeath(&this->actor); } EnWeatherTag_SetupAction(this, func_80966B08); @@ -252,7 +252,7 @@ void func_80966BF4(EnWeatherTag* this, GlobalContext* globalCtx) { if (Cutscene_CheckActorAction(globalCtx, 567)) { tmpAction = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 567)]; if ((globalCtx->csCtx.frames >= tmpAction->startFrame) && (tmpAction->action >= 2)) { - switch (gSaveContext.day) { + switch (gSaveContext.save.day) { case 0: case 1: default: @@ -282,7 +282,7 @@ void func_80966BF4(EnWeatherTag* this, GlobalContext* globalCtx) { void func_80966D20(EnWeatherTag* this, GlobalContext* globalCtx) { u8 newUnk20; - switch (gSaveContext.day) { + switch (gSaveContext.save.day) { case 0: case 1: default: @@ -452,7 +452,7 @@ void func_809674C8(EnWeatherTag* this, GlobalContext* globalCtx) { if (Actor_XZDistanceBetweenActors(&player->actor, &this->actor) < WEATHER_TAG_RANGE100(this)) { if (CURRENT_DAY == 2) { - if ((gSaveContext.time >= CLOCK_TIME(7, 0)) && (gSaveContext.time < CLOCK_TIME(17, 30)) && + if ((gSaveContext.save.time >= CLOCK_TIME(7, 0)) && (gSaveContext.save.time < CLOCK_TIME(17, 30)) && (globalCtx->envCtx.unk_F2[2] == 0)) { D_801BDBB0 = 1; @@ -489,11 +489,11 @@ void EnWeatherTag_Update(Actor* thisx, GlobalContext* globalCtx) { (globalCtx->msgCtx.currentTextId == 0x5E6) && (!FrameAdvance_IsEnabled(&globalCtx->state)) && (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { - oldTime = gSaveContext.time; - gSaveContext.time = (u16)REG(0xF) + oldTime; // cast req + oldTime = gSaveContext.save.time; + gSaveContext.save.time = (u16)REG(0xF) + oldTime; // cast req if (REG(0xF) != 0) { - oldTime = gSaveContext.time; - gSaveContext.time = (u16)gSaveContext.unk_14 + oldTime; + oldTime = gSaveContext.save.time; + gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + oldTime; } } } diff --git a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c index 9db26a88c..446d92cbd 100644 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c @@ -196,7 +196,7 @@ void EnWood02_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); } - if ((this->actor.params == WOOD_TREE_SPECIAL) && !gSaveContext.isNight && (this->unk_144 != -1) && + if ((this->actor.params == WOOD_TREE_SPECIAL) && !gSaveContext.save.isNight && (this->unk_144 != -1) && !Flags_GetCollectible(globalCtx, this->unk_144)) { this->actor.child = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ANI, this->actor.world.pos.x, diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.c b/src/overlays/actors/ovl_En_Yb/z_en_yb.c index d2bf094fc..25cf4c473 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -112,7 +112,7 @@ void EnYb_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.cutscene = this->cutscenes[0]; // between midnight and morning start spawned - if (gSaveContext.time < CLOCK_TIME(6, 0)) { + if (gSaveContext.save.time < CLOCK_TIME(6, 0)) { this->alpha = 255; } else { // else (night 6pm to midnight): wait to appear this->alpha = 0; @@ -121,7 +121,7 @@ void EnYb_Init(Actor* thisx, GlobalContext* globalCtx) { } // check if already healed - if (gSaveContext.weekEventReg[82] & 4) { + if (gSaveContext.save.weekEventReg[82] & 4) { Actor_MarkForDeath(&this->actor); } } @@ -292,7 +292,7 @@ void EnYb_Talk(EnYb* this, GlobalContext* globalCtx) { case 0x147D: // I am counting on you func_801477B4(globalCtx); this->actionFunc = EnYb_Disappear; - gSaveContext.weekEventReg[82] |= 0x4; + gSaveContext.save.weekEventReg[82] |= 0x4; break; case 0x147C: // Spread my dance across the world if (Player_GetMask(globalCtx) == PLAYER_MASK_KAMARO) { @@ -353,7 +353,7 @@ void EnYb_Idle(EnYb* this, GlobalContext* globalCtx) { EnYb_UpdateAnimation(this, globalCtx); if (this->actor.xzDistToPlayer < 180.0f && fabsf(this->actor.playerHeightRel) < 50.0f && globalCtx->msgCtx.ocarinaMode == 3 && globalCtx->msgCtx.unk1202E == 7 && - gSaveContext.playerForm == PLAYER_FORM_HUMAN) { + gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { this->actionFunc = EnYb_TeachingDance; this->teachingCutsceneTimer = 200; EnYb_ChangeCutscene(this, 0); @@ -385,7 +385,7 @@ void EnYb_Idle(EnYb* this, GlobalContext* globalCtx) { } void EnYb_WaitForMidnight(EnYb* this, GlobalContext* globalCtx) { - if (gSaveContext.time < CLOCK_TIME(6, 0)) { + if (gSaveContext.save.time < CLOCK_TIME(6, 0)) { EnYb_UpdateAnimation(this, globalCtx); this->alpha += 5; if (this->alpha > 250) { diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.c b/src/overlays/actors/ovl_En_Zob/z_en_zob.c index 3fe0808a0..6e9ddb5c0 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.c +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.c @@ -114,13 +114,13 @@ void EnZob_Init(Actor* thisx, GlobalContext* globalCtx) { switch (ENZOB_GET_F(&this->actor)) { case ENZOB_F_1: - if (gSaveContext.weekEventReg[78] & 1) { + if (gSaveContext.save.weekEventReg[78] & 1) { this->actionFunc = func_80BA0BB4; } else { this->actionFunc = func_80BA0AD8; } - if (!(gSaveContext.weekEventReg[55] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { Actor_MarkForDeath(&this->actor); return; } @@ -135,7 +135,7 @@ void EnZob_Init(Actor* thisx, GlobalContext* globalCtx) { break; default: - if (gSaveContext.weekEventReg[55] & 0x80) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { Actor_MarkForDeath(&this->actor); } this->actor.flags |= ACTOR_FLAG_10; @@ -210,8 +210,8 @@ void func_80B9FA3C(EnZob* this, GlobalContext* globalCtx) { this->unk_2F4 |= 1; - if (gSaveContext.playerForm != PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[30] & 2) { + if (gSaveContext.save.playerForm != PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[30] & 2) { textId = 0x11F9; } else { textId = 0x11F8; @@ -222,7 +222,7 @@ void func_80B9FA3C(EnZob* this, GlobalContext* globalCtx) { textId = 0x1210; this->unk_304 = 3; func_80B9F7E4(this, 5, 2); - } else if (gSaveContext.weekEventReg[31] & 8) { + } else if (gSaveContext.save.weekEventReg[31] & 8) { textId = 0x1205; this->unk_304 = 1; func_80B9F7E4(this, 3, 0); @@ -234,12 +234,12 @@ void func_80B9FA3C(EnZob* this, GlobalContext* globalCtx) { textId = 0x1203; this->unk_304 = 1; func_80B9F7E4(this, 2, 2); - } else if (gSaveContext.weekEventReg[30] & 8) { + } else if (gSaveContext.save.weekEventReg[30] & 8) { textId = 0x11FA; this->unk_304 = 1; func_80B9F7E4(this, 2, 2); - } else if (!(gSaveContext.weekEventReg[30] & 4)) { - gSaveContext.weekEventReg[30] |= 4; + } else if (!(gSaveContext.save.weekEventReg[30] & 4)) { + gSaveContext.save.weekEventReg[30] |= 4; textId = 0x11FB; this->unk_304 = 1; func_80B9F7E4(this, 2, 2); @@ -420,7 +420,7 @@ void func_80BA00BC(EnZob* this, GlobalContext* globalCtx) { break; case 0x120F: - gSaveContext.weekEventReg[31] |= 8; + gSaveContext.save.weekEventReg[31] |= 8; this->unk_2F4 |= 0x10; func_80B9FCA0(this, globalCtx); break; @@ -473,7 +473,7 @@ void func_80BA0374(EnZob* this, GlobalContext* globalCtx) { if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.currentTextId) { case 0x11F8: - gSaveContext.weekEventReg[30] |= 2; + gSaveContext.save.weekEventReg[30] |= 2; func_80151938(globalCtx, 0x11F9); break; @@ -563,9 +563,9 @@ void func_80BA0728(EnZob* this, GlobalContext* globalCtx) { func_80B9F86C(this); if (func_800B8718(&this->actor, &globalCtx->state)) { - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { Message_StartTextbox(globalCtx, 0x1208, NULL); - gSaveContext.weekEventReg[30] |= 8; + gSaveContext.save.weekEventReg[30] |= 8; } else { Message_StartTextbox(globalCtx, 0x1216, NULL); } @@ -594,18 +594,18 @@ void func_80BA0728(EnZob* this, GlobalContext* globalCtx) { void func_80BA08E8(EnZob* this, GlobalContext* globalCtx) { s32 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[79] & 1) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[79] & 1) { textId = 0x1257; this->unk_304 = 3; func_80B9F7E4(this, 4, 2); - } else if (gSaveContext.weekEventReg[78] & 0x40) { + } else if (gSaveContext.save.weekEventReg[78] & 0x40) { textId = 0x1256; this->unk_304 = 1; func_80B9F7E4(this, 2, 2); } else { textId = 0x1255; - gSaveContext.weekEventReg[78] |= 0x40; + gSaveContext.save.weekEventReg[78] |= 0x40; this->unk_304 = 1; func_80B9F7E4(this, 2, 2); } @@ -663,7 +663,7 @@ void func_80BA0AD8(EnZob* this, GlobalContext* globalCtx) { void func_80BA0BB4(EnZob* this, GlobalContext* globalCtx) { func_80B9F86C(this); - if (gSaveContext.weekEventReg[79] & 1) { + if (gSaveContext.save.weekEventReg[79] & 1) { this->actionFunc = func_80BA09E0; func_80B9F7E4(this, 0, 2); this->unk_304 = 5; diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.c b/src/overlays/actors/ovl_En_Zog/z_en_zog.c index 0806413b2..f4514a9aa 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -265,7 +265,7 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { } } - if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && (gSaveContext.weekEventReg[88] & 0x10)) { + if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && (gSaveContext.save.weekEventReg[88] & 0x10)) { this->unk_302 = this->unk_300 = 0; this->unk_2FC = this->unk_2FE = 3; this->actor.flags |= ACTOR_FLAG_2000000; @@ -275,7 +275,7 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { Animation_PlayLoop(&this->skelAnime, D_80B958DC[0]); this->actor.textId = 0x1009; - if (gSaveContext.weekEventReg[91] & 2) { + if (gSaveContext.save.weekEventReg[91] & 2) { this->actor.textId = 0x103C; this->actionFunc = func_80B9451C; } else { @@ -629,7 +629,7 @@ void func_80B9451C(EnZog* this, GlobalContext* globalCtx) { this->unk_300 = 2; this->actionFunc = func_80B94470; } else if ((globalCtx->msgCtx.ocarinaMode == 3) && (this->actor.xzDistToPlayer < 120.0f)) { - if ((globalCtx->msgCtx.unk1202E == 7) && (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { + if ((globalCtx->msgCtx.unk1202E == 7) && (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { func_80B93BA8(this, 2); this->actionFunc = func_80B943C0; this->actor.shape.shadowDraw = NULL; @@ -645,7 +645,7 @@ void func_80B9461C(EnZog* this, GlobalContext* globalCtx) { this->actor.textId = 0x103C; this->actionFunc = func_80B9451C; this->actor.flags |= ACTOR_FLAG_2000000; - gSaveContext.weekEventReg[91] |= 2; + gSaveContext.save.weekEventReg[91] |= 2; } if ((this->unk_304 == 11) && ((s32)this->skelAnime.curFrame >= 55)) { @@ -717,7 +717,7 @@ void func_80B948A8(EnZog* this, GlobalContext* globalCtx) { this->unk_300 = 2; this->actionFunc = func_80B946FC; } else if ((globalCtx->msgCtx.ocarinaMode == 3) && (this->actor.xzDistToPlayer < 120.0f)) { - if ((globalCtx->msgCtx.unk1202E == 7) && (gSaveContext.playerForm == PLAYER_FORM_HUMAN)) { + if ((globalCtx->msgCtx.unk1202E == 7) && (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { func_80B93BA8(this, 2); this->actionFunc = func_80B943C0; this->actor.shape.shadowDraw = NULL; @@ -747,11 +747,11 @@ void func_80B94A00(EnZog* this, GlobalContext* globalCtx) { if (func_80B93BE0(this, globalCtx)) { this->actionFunc = func_80B948A8; this->actor.flags |= ACTOR_FLAG_2000000; - if (gSaveContext.weekEventReg[29] & 0x20) { + if (gSaveContext.save.weekEventReg[29] & 0x20) { this->actor.textId = 0x1009; } else { this->actor.textId = 0x1008; - gSaveContext.weekEventReg[29] |= 0x20; + gSaveContext.save.weekEventReg[29] |= 0x20; } this->unk_300 = 2; this->unk_31C = 2; @@ -904,7 +904,7 @@ void func_80B94E34(EnZog* this, GlobalContext* globalCtx) { this->unk_31C = 1; this->unk_31E = 0; func_80B93BA8(this, 0); - gSaveContext.weekEventReg[88] |= 0x10; + gSaveContext.save.weekEventReg[88] |= 0x10; } else if ((this->actor.yawTowardsPlayer > 16000) && (this->actor.yawTowardsPlayer < 32000) && (this->unk_302 == 0)) { func_800B8614(&this->actor, globalCtx, 150.0f); @@ -938,7 +938,7 @@ void func_80B95128(EnZog* this, GlobalContext* globalCtx) { } this->actor.flags &= ~ACTOR_FLAG_10000; - gSaveContext.weekEventReg[91] |= 1; + gSaveContext.save.weekEventReg[91] |= 1; } else { func_800B8614(&this->actor, globalCtx, 150.0f); } diff --git a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c index 7250daaa8..61be7c8e7 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c @@ -118,7 +118,7 @@ void EnZoraegg_Init(Actor* thisx, GlobalContext* globalCtx) { case ENZORAEGG_1F_7: case ENZORAEGG_1F_8: case ENZORAEGG_1F_9: - if (gSaveContext.weekEventReg[19] & 0x40) { + if (gSaveContext.save.weekEventReg[19] & 0x40) { Actor_MarkForDeath(&this->actor); return; } @@ -131,7 +131,7 @@ void EnZoraegg_Init(Actor* thisx, GlobalContext* globalCtx) { case ENZORAEGG_1F_14: case ENZORAEGG_1F_15: case ENZORAEGG_1F_16: - if (!(gSaveContext.weekEventReg[19] & 0x40)) { + if (!(gSaveContext.save.weekEventReg[19] & 0x40)) { Actor_MarkForDeath(&this->actor); return; } @@ -206,13 +206,13 @@ void EnZoraegg_Destroy(Actor* thisx, GlobalContext* globalCtx) { } s32 func_80B319A8(GlobalContext* globalCtx) { - return gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 7; + return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 7; } void func_80B319D0(GlobalContext* globalCtx, s32 arg1) { if ((arg1 < 8) && (arg1 >= 0)) { - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~7; - gSaveContext.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= arg1; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~7; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= arg1; } } @@ -479,7 +479,7 @@ void func_80B326F4(EnZoraegg* this, GlobalContext* globalCtx) { Animation_GetLastFrame(&object_zoraegg_Anim_004D20), 2, 5.0f); this->unk_1E8 = 0; this->actionFunc = func_80B32644; - gSaveContext.weekEventReg[19] |= 0x40; + gSaveContext.save.weekEventReg[19] |= 0x40; this->unk_1EC = 2; this->unk_1EE = 100; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_2); diff --git a/src/overlays/actors/ovl_En_Zos/z_en_zos.c b/src/overlays/actors/ovl_En_Zos/z_en_zos.c index 6d355f1a0..419d3325e 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.c +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.c @@ -84,11 +84,11 @@ void EnZos_Init(Actor* thisx, GlobalContext* globalCtx) { switch (ENZOS_GET_F(&this->actor)) { case ENZOS_F_1: - if (!(gSaveContext.weekEventReg[55] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { Actor_MarkForDeath(&this->actor); } - if (gSaveContext.weekEventReg[78] & 1) { + if (gSaveContext.save.weekEventReg[78] & 1) { this->actionFunc = func_80BBC24C; } else { this->actionFunc = func_80BBC14C; @@ -104,7 +104,7 @@ void EnZos_Init(Actor* thisx, GlobalContext* globalCtx) { break; default: - if (gSaveContext.weekEventReg[55] & 0x80) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { Actor_MarkForDeath(&this->actor); } this->actor.flags |= ACTOR_FLAG_10; @@ -115,7 +115,7 @@ void EnZos_Init(Actor* thisx, GlobalContext* globalCtx) { void EnZos_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnZos* this = THIS; - gSaveContext.weekEventReg[52] &= (u8)~0x10; + gSaveContext.save.weekEventReg[52] &= (u8)~0x10; } void func_80BBAE84(EnZos* this, s16 arg1, u8 arg2) { @@ -187,7 +187,7 @@ void func_80BBB0D4(EnZos* this, GlobalContext* globalCtx) { void func_80BBB15C(EnZos* this, GlobalContext* globalCtx) { s32 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { if (this->unk_2B6 & 8) { textId = 0x1235; func_80BBAE84(this, 6, 0); @@ -196,7 +196,7 @@ void func_80BBB15C(EnZos* this, GlobalContext* globalCtx) { textId = 0x123E; func_80BBAE84(this, 6, 0); this->unk_2B6 |= 2; - } else if (gSaveContext.weekEventReg[40] & 0x20) { + } else if (gSaveContext.save.weekEventReg[40] & 0x20) { textId = 0x1236; func_80BBAE84(this, 6, 0); this->unk_2B6 |= 0x80; @@ -207,13 +207,13 @@ void func_80BBB15C(EnZos* this, GlobalContext* globalCtx) { } } else { this->unk_2B6 &= ~2; - if (gSaveContext.weekEventReg[39] & 0x10) { + if (gSaveContext.save.weekEventReg[39] & 0x10) { textId = 0x1243; func_80BBAE84(this, 6, 0); this->unk_2B6 |= 0x80; } else { textId = 0x1244; - gSaveContext.weekEventReg[39] |= 0x10; + gSaveContext.save.weekEventReg[39] |= 0x10; func_80BBAE84(this, 4, 0); this->unk_2B6 |= 0x10; } @@ -237,11 +237,11 @@ void func_80BBB354(EnZos* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; this->actionFunc = func_80BBB2C4; - gSaveContext.weekEventReg[39] |= 0x20; + gSaveContext.save.weekEventReg[39] |= 0x20; this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); } else { - if (gSaveContext.weekEventReg[39] & 0x20) { + if (gSaveContext.save.weekEventReg[39] & 0x20) { item = GI_RUPEE_PURPLE; } else { item = GI_HEART_PIECE; @@ -348,22 +348,22 @@ void func_80BBB718(EnZos* this, GlobalContext* globalCtx) { player->actor.textId = 0x1232; func_80BBAE84(this, 5, 0); this->unk_2B6 |= 8; - gSaveContext.weekEventReg[40] |= 0x20; - } else if (gSaveContext.weekEventReg[39] & 8) { + gSaveContext.save.weekEventReg[40] |= 0x20; + } else if (gSaveContext.save.weekEventReg[39] & 8) { player->actor.textId = 0x1241; } else { player->actor.textId = 0x1237; - gSaveContext.weekEventReg[39] |= 8; + gSaveContext.save.weekEventReg[39] |= 8; func_80BBAE84(this, 4, 0); this->unk_2B6 |= 4; } this->actionFunc = func_80BBB8AC; } else if (sp24 < 0) { - if (gSaveContext.weekEventReg[39] & 8) { + if (gSaveContext.save.weekEventReg[39] & 8) { func_80151938(globalCtx, 0x1241); } else { func_80151938(globalCtx, 0x1237); - gSaveContext.weekEventReg[39] |= 8; + gSaveContext.save.weekEventReg[39] |= 8; func_80BBAE84(this, 4, 0); this->unk_2B6 |= 4; } @@ -470,17 +470,17 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { void func_80BBBB84(EnZos* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { Message_StartTextbox(globalCtx, 0x1248, &this->actor); this->actionFunc = func_80BBB8AC; func_80BBAE84(this, 6, 0); this->unk_2B6 |= 2; - } else if (gSaveContext.weekEventReg[41] & 0x10) { + } else if (gSaveContext.save.weekEventReg[41] & 0x10) { Message_StartTextbox(globalCtx, 0x124A, &this->actor); this->actionFunc = func_80BBB8AC; func_80BBAE84(this, 6, 0); } else { - gSaveContext.weekEventReg[41] |= 0x10; + gSaveContext.save.weekEventReg[41] |= 0x10; Message_StartTextbox(globalCtx, 0x124B, &this->actor); this->actionFunc = func_80BBB574; func_80BBAE84(this, 9, 2); @@ -544,9 +544,9 @@ void func_80BBBDE0(EnZos* this, GlobalContext* globalCtx) { } if (!Actor_IsFacingPlayer(&this->actor, 0x4000) && (this->actor.xzDistToPlayer < 100.0f)) { - gSaveContext.weekEventReg[52] |= 0x10; + gSaveContext.save.weekEventReg[52] |= 0x10; } else { - gSaveContext.weekEventReg[52] &= (u8)~0x10; + gSaveContext.save.weekEventReg[52] &= (u8)~0x10; } sp28.x = this->actor.projectedPos.x; @@ -558,14 +558,14 @@ void func_80BBBDE0(EnZos* this, GlobalContext* globalCtx) { void func_80BBBFBC(EnZos* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[79] & 1) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[79] & 1) { textId = 0x125B; - } else if (gSaveContext.weekEventReg[78] & 0x80) { + } else if (gSaveContext.save.weekEventReg[78] & 0x80) { textId = 0x125A; } else { textId = 0x1259; - gSaveContext.weekEventReg[78] |= 0x80; + gSaveContext.save.weekEventReg[78] |= 0x80; } func_80BBAE84(this, 5, 0); } else { @@ -626,7 +626,7 @@ void func_80BBC22C(EnZos* this, GlobalContext* globalCtx) { void func_80BBC24C(EnZos* this, GlobalContext* globalCtx) { func_80BBB0D4(this, globalCtx); - if (gSaveContext.weekEventReg[79] & 1) { + if (gSaveContext.save.weekEventReg[79] & 1) { this->actionFunc = func_80BBC22C; func_80BBAE84(this, 7, 2); } diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index 95bdbc964..bfab9fcf6 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -184,14 +184,14 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { func_80B96BEC(this, 2, 0); this->actor.colChkInfo.cylRadius = 0; this->actor.shape.yOffset = -1400.0f; - if (!(gSaveContext.weekEventReg[55] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { Actor_MarkForDeath(&this->actor); } break; case 18: this->actionFunc = func_80B99384; - if (!(gSaveContext.weekEventReg[55] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { Actor_MarkForDeath(&this->actor); } break; @@ -219,7 +219,7 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { break; } - if ((ENZOT_GET_1F(thisx) >= 2) && (ENZOT_GET_1F(thisx) < 11) && (gSaveContext.weekEventReg[55] & 0x80)) { + if ((ENZOT_GET_1F(thisx) >= 2) && (ENZOT_GET_1F(thisx) < 11) && (gSaveContext.save.weekEventReg[55] & 0x80)) { Actor_MarkForDeath(&this->actor); } } @@ -229,7 +229,7 @@ void EnZot_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); if (ENZOT_GET_1F(&this->actor) == 8) { - gSaveContext.weekEventReg[41] &= (u8)~0x20; + gSaveContext.save.weekEventReg[41] &= (u8)~0x20; } } @@ -359,19 +359,19 @@ void func_80B97100(EnZot* this, GlobalContext* globalCtx) { void func_80B97110(EnZot* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { textId = 0x125F; - if (gSaveContext.weekEventReg[28] & 0x80) { + if (gSaveContext.save.weekEventReg[28] & 0x80) { textId = 0x1261; } else { - gSaveContext.weekEventReg[28] |= 0x80; + gSaveContext.save.weekEventReg[28] |= 0x80; } } else { textId = 0x125C; - if (gSaveContext.weekEventReg[28] & 0x40) { + if (gSaveContext.save.weekEventReg[28] & 0x40) { textId = 0x125E; } else { - gSaveContext.weekEventReg[28] |= 0x40; + gSaveContext.save.weekEventReg[28] |= 0x40; } } Message_StartTextbox(globalCtx, textId, &this->actor); @@ -409,35 +409,35 @@ void func_80B97240(EnZot* this, GlobalContext* globalCtx) { void func_80B972E8(EnZot* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.weekEventReg[29] & 0x10) { - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[29] & 0x10) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { textId = 0x126A; - if (gSaveContext.weekEventReg[29] & 1) { + if (gSaveContext.save.weekEventReg[29] & 1) { textId = 0x126D; } else { - gSaveContext.weekEventReg[29] |= 1; + gSaveContext.save.weekEventReg[29] |= 1; } } else { textId = 0x1267; - if (gSaveContext.weekEventReg[29] & 2) { + if (gSaveContext.save.weekEventReg[29] & 2) { textId = 0x1269; } else { - gSaveContext.weekEventReg[29] |= 2; + gSaveContext.save.weekEventReg[29] |= 2; } } - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { textId = 0x1265; - if (gSaveContext.weekEventReg[29] & 4) { + if (gSaveContext.save.weekEventReg[29] & 4) { textId = 0x1266; } else { - gSaveContext.weekEventReg[29] |= 4; + gSaveContext.save.weekEventReg[29] |= 4; } } else { textId = 0x1262; - if (gSaveContext.weekEventReg[29] & 8) { + if (gSaveContext.save.weekEventReg[29] & 8) { textId = 0x1264; } else { - gSaveContext.weekEventReg[29] |= 8; + gSaveContext.save.weekEventReg[29] |= 8; } } Message_StartTextbox(globalCtx, textId, &this->actor); @@ -466,7 +466,7 @@ void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { break; case 0x1275: - if (gSaveContext.rupees < 10) { + if (gSaveContext.save.playerData.rupees < 10) { func_80151938(globalCtx, 0x1277); } else { func_80151938(globalCtx, 0x1278); @@ -559,15 +559,15 @@ void func_80B97708(EnZot* this, GlobalContext* globalCtx) { } if (phi_v1 != 0) { - gSaveContext.weekEventReg[29] |= 0x10; + gSaveContext.save.weekEventReg[29] |= 0x10; this->actor.flags |= ACTOR_FLAG_10000; if (phi_v1 == 5) { - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { this->actor.textId = 0x126E; } else { this->actor.textId = 0x1272; } - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { this->actor.textId = 0x1273; } else { this->actor.textId = 0x1276; @@ -584,61 +584,61 @@ void func_80B9787C(EnZot* this, GlobalContext* globalCtx) { u16 textId; if (this->actor.textId == 0) { - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { switch (ENZOT_GET_1F(&this->actor)) { case 2: - if (gSaveContext.weekEventReg[37] & 0x40) { + if (gSaveContext.save.weekEventReg[37] & 0x40) { textId = 0x127E; } else { textId = 0x127C; - gSaveContext.weekEventReg[37] |= 0x40; + gSaveContext.save.weekEventReg[37] |= 0x40; } break; case 3: - if (gSaveContext.weekEventReg[38] & 1) { + if (gSaveContext.save.weekEventReg[38] & 1) { textId = 0x1284; } else { textId = 0x1282; - gSaveContext.weekEventReg[38] |= 1; + gSaveContext.save.weekEventReg[38] |= 1; } break; default: - if (gSaveContext.weekEventReg[38] & 4) { + if (gSaveContext.save.weekEventReg[38] & 4) { textId = 0x128A; } else { textId = 0x1288; - gSaveContext.weekEventReg[38] |= 4; + gSaveContext.save.weekEventReg[38] |= 4; } break; } } else { switch (ENZOT_GET_1F(&this->actor)) { case 2: - if (gSaveContext.weekEventReg[37] & 0x20) { + if (gSaveContext.save.weekEventReg[37] & 0x20) { textId = 0x127B; } else { textId = 0x1279; - gSaveContext.weekEventReg[37] |= 0x20; + gSaveContext.save.weekEventReg[37] |= 0x20; } break; case 3: - if (gSaveContext.weekEventReg[37] & 0x80) { + if (gSaveContext.save.weekEventReg[37] & 0x80) { textId = 0x1281; } else { textId = 0x127F; - gSaveContext.weekEventReg[37] |= 0x80; + gSaveContext.save.weekEventReg[37] |= 0x80; } break; default: - if (gSaveContext.weekEventReg[38] & 2) { + if (gSaveContext.save.weekEventReg[38] & 2) { textId = 0x1287; } else { textId = 0x1285; - gSaveContext.weekEventReg[38] |= 2; + gSaveContext.save.weekEventReg[38] |= 2; } break; } @@ -707,7 +707,7 @@ void func_80B97B5C(EnZot* this, GlobalContext* globalCtx) { void func_80B97BF8(EnZot* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { textId = 0x128C; } else { textId = 0x128B; @@ -786,7 +786,7 @@ void func_80B97E4C(EnZot* this, GlobalContext* globalCtx) { this->actionFunc = func_80B97D6C; this->unk_2F2 |= 4; func_80B96BEC(this, 3, 0); - gSaveContext.weekEventReg[38] |= 8; + gSaveContext.save.weekEventReg[38] |= 8; break; case 0x128B: @@ -803,8 +803,8 @@ void func_80B97FD0(EnZot* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B97E4C; func_80B97BF8(this, globalCtx); - } else if (gSaveContext.weekEventReg[38] & 8) { - if ((this->actor.xzDistToPlayer < 120.0f) && (gSaveContext.playerForm == PLAYER_FORM_ZORA)) { + } else if (gSaveContext.save.weekEventReg[38] & 8) { + if ((this->actor.xzDistToPlayer < 120.0f) && (gSaveContext.save.playerForm == PLAYER_FORM_ZORA)) { this->unk_2F2 |= 4; this->actionFunc = func_80B97E0C; func_80B96BEC(this, 6, 2); @@ -834,38 +834,38 @@ void func_80B98178(EnZot* this, GlobalContext* globalCtx) { switch (ENZOT_GET_1F(&this->actor)) { case 6: - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { if (CURRENT_DAY == 3) { textId = 0x129D; - } else if (gSaveContext.weekEventReg[39] & 1) { + } else if (gSaveContext.save.weekEventReg[39] & 1) { textId = 0x129C; } else { textId = 0x129B; - gSaveContext.weekEventReg[39] |= 1; + gSaveContext.save.weekEventReg[39] |= 1; } - } else if (gSaveContext.weekEventReg[38] & 0x80) { + } else if (gSaveContext.save.weekEventReg[38] & 0x80) { textId = 0x1293; } else { textId = 0x1291; - gSaveContext.weekEventReg[38] |= 0x80; + gSaveContext.save.weekEventReg[38] |= 0x80; } break; case 7: - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[39] & 4) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[39] & 4) { textId = 0x12AA; } else { textId = 0x12A6; - gSaveContext.weekEventReg[39] |= 4; + gSaveContext.save.weekEventReg[39] |= 4; } } else if (Flags_GetSwitch(globalCtx, this->actor.home.rot.z & 0x7F)) { textId = 0x12A0; - } else if (gSaveContext.weekEventReg[39] & 2) { + } else if (gSaveContext.save.weekEventReg[39] & 2) { textId = 0x12A5; } else { textId = 0x12A2; - gSaveContext.weekEventReg[39] |= 2; + gSaveContext.save.weekEventReg[39] |= 2; } break; @@ -877,18 +877,18 @@ void func_80B98178(EnZot* this, GlobalContext* globalCtx) { case 16: case 17: phi_v0 = (ENZOT_GET_1F(&this->actor) * 4) - 44; - if (gSaveContext.weekEventReg[79] & 1) { + if (gSaveContext.save.weekEventReg[79] & 1) { phi_v0 += 2; } - if (gSaveContext.playerForm != PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm != PLAYER_FORM_ZORA) { phi_v0++; } textId = phi_v0 + 0x1302; break; default: - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { textId = 0x129F; } else { textId = 0x1295; @@ -1074,18 +1074,18 @@ void func_80B98998(EnZot* this, GlobalContext* globalCtx) { void func_80B98A4C(EnZot* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[39] & 0x80) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[39] & 0x80) { textId = 0x12B6; } else { textId = 0x12B4; - gSaveContext.weekEventReg[39] |= 0x80; + gSaveContext.save.weekEventReg[39] |= 0x80; } - } else if (gSaveContext.weekEventReg[39] & 0x40) { + } else if (gSaveContext.save.weekEventReg[39] & 0x40) { textId = 0x12B3; } else { textId = 0x12B1; - gSaveContext.weekEventReg[39] |= 0x40; + gSaveContext.save.weekEventReg[39] |= 0x40; } Message_StartTextbox(globalCtx, textId, &this->actor); } @@ -1103,14 +1103,14 @@ void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { case 0x12B8: func_801477B4(globalCtx); this->actionFunc = func_80B98CA8; - gSaveContext.weekEventReg[41] &= (u8)~0x20; + gSaveContext.save.weekEventReg[41] &= (u8)~0x20; AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_OFF); break; case 0x12BA: func_801477B4(globalCtx); this->actionFunc = func_80B98CA8; - gSaveContext.weekEventReg[41] |= 0x20; + gSaveContext.save.weekEventReg[41] |= 0x20; AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_OFF); break; @@ -1125,7 +1125,7 @@ void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { void func_80B98BF4(EnZot* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; - if (gSaveContext.weekEventReg[41] & 0x20) { + if (gSaveContext.save.weekEventReg[41] & 0x20) { Message_StartTextbox(globalCtx, 0x12B7, &this->actor); this->actionFunc = func_80B98AD0; } else { @@ -1152,32 +1152,32 @@ void func_80B98CA8(EnZot* this, GlobalContext* globalCtx) { func_800B8614(&this->actor, globalCtx, 120.0f); } - if ((gSaveContext.playerForm == PLAYER_FORM_ZORA) || (this->actor.xzDistToPlayer < 100.0f)) { + if ((gSaveContext.save.playerForm == PLAYER_FORM_ZORA) || (this->actor.xzDistToPlayer < 100.0f)) { func_800B874C(&this->actor, globalCtx, 120.0, 100.0f); } } if (this->actor.xzDistToPlayer > 100.0f) { - gSaveContext.weekEventReg[41] &= (u8)~0x20; + gSaveContext.save.weekEventReg[41] &= (u8)~0x20; } } void func_80B98E10(EnZot* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { if (Flags_GetSwitch(globalCtx, this->actor.home.rot.z & 0x7F)) { - if (gSaveContext.weekEventReg[40] & 4) { + if (gSaveContext.save.weekEventReg[40] & 4) { textId = 0x12C5; } else { textId = 0x12C3; - gSaveContext.weekEventReg[40] |= 4; + gSaveContext.save.weekEventReg[40] |= 4; } - } else if (gSaveContext.weekEventReg[40] & 2) { + } else if (gSaveContext.save.weekEventReg[40] & 2) { textId = 0x12C2; } else { textId = 0x12C0; - gSaveContext.weekEventReg[40] |= 2; + gSaveContext.save.weekEventReg[40] |= 2; } } else { if (Flags_GetSwitch(globalCtx, this->actor.home.rot.z & 0x7F)) { @@ -1187,10 +1187,10 @@ void func_80B98E10(EnZot* this, GlobalContext* globalCtx) { textId = 0x12BE; this->unk_2F2 |= 0x10; } - } else if (gSaveContext.weekEventReg[40] & 1) { + } else if (gSaveContext.save.weekEventReg[40] & 1) { textId = 0x12BC; } else { - gSaveContext.weekEventReg[40] |= 1; + gSaveContext.save.weekEventReg[40] |= 1; this->unk_2F2 |= 4; textId = 0x12BB; } @@ -1252,18 +1252,18 @@ void func_80B990A4(EnZot* this, GlobalContext* globalCtx) { void func_80B99160(EnZot* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[40] & 0x10) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[40] & 0x10) { textId = 0x12CD; } else { textId = 0x12CA; - gSaveContext.weekEventReg[40] |= 0x10; + gSaveContext.save.weekEventReg[40] |= 0x10; } - } else if (gSaveContext.weekEventReg[40] & 8) { + } else if (gSaveContext.save.weekEventReg[40] & 8) { textId = 0x12C9; } else { textId = 0x12C6; - gSaveContext.weekEventReg[40] |= 8; + gSaveContext.save.weekEventReg[40] |= 8; } Message_StartTextbox(globalCtx, textId, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.c b/src/overlays/actors/ovl_En_Zov/z_en_zov.c index a23f5da2b..f593709cf 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.c +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.c @@ -107,7 +107,7 @@ void EnZov_Init(Actor* thisx, GlobalContext* globalCtx) { case ENZOV_F_1: this->actionFunc = func_80BD1F1C; func_80BD1570(this, 9, 0); - if (!(gSaveContext.weekEventReg[55] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { Actor_MarkForDeath(&this->actor); return; } @@ -120,7 +120,7 @@ void EnZov_Init(Actor* thisx, GlobalContext* globalCtx) { default: this->unk_320 |= 2; - if ((gSaveContext.weekEventReg[55] & 0x80) || (gSaveContext.weekEventReg[53] & 0x20)) { + if ((gSaveContext.save.weekEventReg[55] & 0x80) || (gSaveContext.save.weekEventReg[53] & 0x20)) { Actor_MarkForDeath(&this->actor); } break; @@ -185,9 +185,9 @@ s32 func_80BD15A4(EnZov* this, GlobalContext* globalCtx) { void func_80BD160C(EnZov* this, GlobalContext* globalCtx) { s32 textId = 0; - if (gSaveContext.weekEventReg[53] & 0x20) { + if (gSaveContext.save.weekEventReg[53] & 0x20) { this->unk_320 &= ~2; - if (gSaveContext.playerForm != PLAYER_FORM_ZORA) { + if (gSaveContext.save.playerForm != PLAYER_FORM_ZORA) { textId = 0x1024; if ((this->unk_322 == 0) || (this->unk_322 == 4)) { func_80BD1570(this, 4, 2); @@ -201,7 +201,7 @@ void func_80BD160C(EnZov* this, GlobalContext* globalCtx) { this->unk_320 |= 4; func_80BD1570(this, 3, 2); } - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { func_80BD1570(this, 2, 2); this->actionFunc = func_80BD19FC; this->unk_324 = 10; @@ -390,8 +390,8 @@ void func_80BD1C84(EnZov* this, GlobalContext* globalCtx) { void func_80BD1D30(EnZov* this, GlobalContext* globalCtx) { u16 textId; - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[79] & 1) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[79] & 1) { textId = 0x1032; } else { textId = 0x1033; @@ -426,7 +426,7 @@ void func_80BD1DB8(EnZov* this, GlobalContext* globalCtx) { globalCtx->nextEntranceIndex = globalCtx->setupExitList[ENZOV_GET_FE00(&this->actor)]; globalCtx->unk_1887F = 5; globalCtx->sceneLoadFlag = 0x14; - gSaveContext.weekEventReg[78] |= 1; + gSaveContext.save.weekEventReg[78] |= 1; this->actionFunc = func_80BD1D94; globalCtx->msgCtx.unk11F10 = 0; Audio_QueueSeqCmd(0x101400FF); diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.c b/src/overlays/actors/ovl_En_Zow/z_en_zow.c index d9d8b1864..ff258fc20 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -360,45 +360,45 @@ void func_80BDD1E0(EnZow* this, GlobalContext* globalCtx) { u16 phi_a1; if (ENZOW_GET_F(&this->actor) == ENZOW_F_1) { - if (gSaveContext.weekEventReg[55] & 0x80) { - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[78] & 4) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[78] & 4) { phi_a1 = 0x12FD; } else { phi_a1 = 0x12FA; - gSaveContext.weekEventReg[78] |= 4; + gSaveContext.save.weekEventReg[78] |= 4; } - } else if (gSaveContext.weekEventReg[78] & 0x10) { + } else if (gSaveContext.save.weekEventReg[78] & 0x10) { phi_a1 = 0x1301; } else { - gSaveContext.weekEventReg[78] |= 0x10; + gSaveContext.save.weekEventReg[78] |= 0x10; phi_a1 = 0x12FF; } - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[78] & 8) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[78] & 8) { phi_a1 = 0x12F8; } else { phi_a1 = 0x12F3; - gSaveContext.weekEventReg[78] |= 8; + gSaveContext.save.weekEventReg[78] |= 8; } - } else if (gSaveContext.weekEventReg[78] & 0x10) { + } else if (gSaveContext.save.weekEventReg[78] & 0x10) { phi_a1 = 0x1301; } else { - gSaveContext.weekEventReg[78] |= 0x10; + gSaveContext.save.weekEventReg[78] |= 0x10; phi_a1 = 0x12FF; } - } else if (gSaveContext.weekEventReg[55] & 0x80) { - if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { + } else if (gSaveContext.save.weekEventReg[55] & 0x80) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { phi_a1 = 0x12EC; } else { phi_a1 = 0x12F1; } - } else if (gSaveContext.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.weekEventReg[78] & 2) { + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[78] & 2) { phi_a1 = 0x12EB; } else { phi_a1 = 0x12E8; - gSaveContext.weekEventReg[78] |= 2; + gSaveContext.save.weekEventReg[78] |= 2; } } else { phi_a1 = 0x12EF; diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c index 16dd4943a..2d84030f1 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -311,9 +311,9 @@ void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_CHANDELIER_BROKEN); func_80BB9A1C((ObjChan*)this->actor.parent, 40.0f); if (this->myPotIndex == 4) { - temp_v0_2 = gSaveContext.weekEventReg[0x25]; + temp_v0_2 = gSaveContext.save.weekEventReg[0x25]; if (!(temp_v0_2 & 0x10)) { - gSaveContext.weekEventReg[0x25] = temp_v0_2 | 0x10; + gSaveContext.save.weekEventReg[0x25] = temp_v0_2 | 0x10; Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MM, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x8000, this->actor.cutscene, this->actor.unk20, NULL); diff --git a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c index f40634044..573b34fdc 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c @@ -334,7 +334,7 @@ void ObjComb_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); Collider_InitJntSph(globalCtx, &this->collider); - if ((sp2C == 1) && OBJCOMB_GET_10(&this->actor) && (gSaveContext.weekEventReg[83] & 2)) { + if ((sp2C == 1) && OBJCOMB_GET_10(&this->actor) && (gSaveContext.save.weekEventReg[83] & 2)) { Actor_MarkForDeath(&this->actor); return; } @@ -531,7 +531,7 @@ void ObjComb_Update(Actor* thisx, GlobalContext* globalCtx) { if (((OBJCOMB_GET_8000(&this->actor) | OBJCOMB_GET_80(&this->actor)) == 1) && OBJCOMB_GET_10(&this->actor)) { - gSaveContext.weekEventReg[83] |= 2; + gSaveContext.save.weekEventReg[83] |= 2; } this->unk_1B5 = 2; diff --git a/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c b/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c index 03e73043f..57f9d7550 100644 --- a/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c +++ b/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c @@ -31,7 +31,7 @@ const ActorInit Obj_Dinner_InitVars = { void ObjDinner_Init(Actor* thisx, GlobalContext* globalCtx) { ObjDinner* this = THIS; - if (gSaveContext.isNight != true || (CURRENT_DAY == 3 && gSaveContext.weekEventReg[22] & 1)) { + if (gSaveContext.save.isNight != true || (CURRENT_DAY == 3 && gSaveContext.save.weekEventReg[22] & 1)) { Actor_MarkForDeath(&this->actor); } Actor_SetScale(&this->actor, 0.1f); diff --git a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c index 6e55293a3..bedb0a38f 100644 --- a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c +++ b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c @@ -44,7 +44,7 @@ static InitChainEntry D_80B3C96C[] = { }; void func_80B3C260(ObjGhaka* this) { - if (gSaveContext.weekEventReg[20] & 0x20) { + if (gSaveContext.save.weekEventReg[20] & 0x20) { this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + 100.0f; } this->actionFunc = func_80B3C39C; @@ -59,7 +59,7 @@ void func_80B3C2B0(ObjGhaka* this) { } void func_80B3C2C4(ObjGhaka* this, GlobalContext* globalCtx) { - if (!(gSaveContext.weekEventReg[20] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[20] & 0x20)) { Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_BG_GORON_OYU, 0.0f, 25.0f, 261.0f, 0, 0, 0, 0, this->dyna.actor.cutscene, this->dyna.actor.unk20, 0); } else { @@ -84,7 +84,8 @@ void func_80B3C39C(ObjGhaka* this, GlobalContext* globalCtx) { } } } - if (this->dyna.pushForce < 0.0f && !(gSaveContext.weekEventReg[20] & 0x20) && + + if (this->dyna.pushForce < 0.0f && !(gSaveContext.save.weekEventReg[20] & 0x20) && player->transformation == PLAYER_FORM_GORON) { func_80B3C2B0(this); } else { @@ -135,7 +136,7 @@ void func_80B3C624(ObjGhaka* this, GlobalContext* globalCtx) { player->stateFlags2 &= ~0x10; this->dyna.pushForce = 0.0f; func_80B3C2C4(this, globalCtx); - gSaveContext.weekEventReg[20] |= 0x20; + gSaveContext.save.weekEventReg[20] |= 0x20; func_80B3C260(this); Audio_PlaySfxAtPos(&D_80B3C960, NA_SE_EV_BLOCK_BOUND); } else { @@ -157,7 +158,7 @@ void ObjGhaka_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->dyna.actor.floorPoly == 0) { Actor_MarkForDeath(&this->dyna.actor); } - if (gSaveContext.weekEventReg[20] & 0x20) { + if (gSaveContext.save.weekEventReg[20] & 0x20) { func_80B3C2C4(this, globalCtx); } func_80B3C260(this); diff --git a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c index 6c37e68b5..4e6b3791d 100644 --- a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c +++ b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c @@ -96,7 +96,7 @@ void ObjHgdoor_SetupCheckShouldOpen(ObjHgdoor* this) { } void ObjHgdoor_CheckShouldOpen(ObjHgdoor* this, GlobalContext* globalCtx) { - if (!(gSaveContext.weekEventReg[75] & 0x20) && !(gSaveContext.weekEventReg[52] & 0x20) && + if (!(gSaveContext.save.weekEventReg[75] & 0x20) && !(gSaveContext.save.weekEventReg[52] & 0x20) && (this->dyna.actor.xzDistToPlayer < 100.0f) && (this->dyna.actor.playerHeightRel < 40.0f) && OBJHGDOOR_IS_RIGHT_DOOR(&this->dyna.actor)) { ObjHgdoor_SetChild(this, globalCtx); diff --git a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c index 74e00403c..06293bf40 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -409,7 +409,7 @@ void func_80A54CEC(ObjHugebombiwa* this, GlobalContext* globalCtx) { Flags_SetSwitch(globalCtx, ENHUGEBOMBIWA_GET_7F(&this->actor)); if (!(ENHUGEBOMBIWA_GET_100(&this->actor)) && ((globalCtx->sceneNum == SCENE_17SETUGEN) || (globalCtx->sceneNum == SCENE_17SETUGEN2))) { - gSaveContext.weekEventReg[19] |= 2; + gSaveContext.save.weekEventReg[19] |= 2; } if (!(ENHUGEBOMBIWA_GET_100(&this->actor))) { diff --git a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c index 05f6b212d..4e09bb655 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c @@ -4,6 +4,7 @@ * Description: Switch-Activated Geyser */ +#include "prevent_bss_reordering.h" #include "z_obj_hunsui.h" #include "objects/object_hunsui/object_hunsui.h" diff --git a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c index f122dca41..d6ac6f342 100644 --- a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c +++ b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c @@ -116,7 +116,7 @@ void ObjIcePoly_Init(Actor* thisx, GlobalContext* globalCtx) { thisx->shape.rot.z = -0x500; if (((this->unk_149 != OBJICEPOLY_FF_FF) && Flags_GetSwitch(globalCtx, this->unk_149)) || - ((globalCtx->sceneNum == SCENE_KAJIYA) && (gSaveContext.weekEventReg[33] & 0x80))) { + ((globalCtx->sceneNum == SCENE_KAJIYA) && (gSaveContext.save.weekEventReg[33] & 0x80))) { Actor_MarkForDeath(thisx); return; } diff --git a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c index 81090139b..a32f791bc 100644 --- a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c +++ b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c @@ -58,7 +58,7 @@ void ObjMilkBin_Init(Actor* thisx, GlobalContext* globalCtx) { this->disableDraw = 0; this->type = thisx->params; - if ((this->type == OBJ_MILK_BIN_TYPE_2) && !(gSaveContext.weekEventReg[52] & 1)) { + if ((this->type == OBJ_MILK_BIN_TYPE_2) && !(gSaveContext.save.weekEventReg[52] & 1)) { this->disableDraw |= 1; } } @@ -74,14 +74,14 @@ void ObjMilkBin_Update(Actor* thisx, GlobalContext* globalCtx2) { ObjMilkBin* this = THIS; if (this->type == OBJ_MILK_BIN_TYPE_1) { - if (gSaveContext.weekEventReg[22] & 1) { - if (((gSaveContext.day == 2) && (gSaveContext.isNight == 1)) || (gSaveContext.day >= 3)) { + if (gSaveContext.save.weekEventReg[22] & 1) { + if (((gSaveContext.save.day == 2) && (gSaveContext.save.isNight == 1)) || (gSaveContext.save.day >= 3)) { Actor_MarkForDeath(&this->actor); return; } } } else if (this->type == OBJ_MILK_BIN_TYPE_2) { - if (gSaveContext.weekEventReg[52] & 1) { + if (gSaveContext.save.weekEventReg[52] & 1) { this->disableDraw &= ~1; } else { this->disableDraw |= 1; diff --git a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c index 6f79fa1f3..546f0db16 100644 --- a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c +++ b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c @@ -49,17 +49,15 @@ void ObjMoonStone_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.health = 0; this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80C0662C(this); - } else { - if ((gSaveContext.weekEventReg[74] & 0x40) == 0) { - if ((gSaveContext.weekEventReg[74] & 0x80)) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, 1, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, -1); - } - this->actor.flags &= ~ACTOR_FLAG_1; - func_80C0673C(this); - } else { - Actor_MarkForDeath(&this->actor); + } else if (!(gSaveContext.save.weekEventReg[74] & 0x40)) { + if ((gSaveContext.save.weekEventReg[74] & 0x80)) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, 1, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, -1); } + this->actor.flags &= ~ACTOR_FLAG_1; + func_80C0673C(this); + } else { + Actor_MarkForDeath(&this->actor); } } @@ -99,15 +97,15 @@ void func_80C0670C(ObjMoonStone* this, GlobalContext* globalCtx) { } void func_80C0673C(ObjMoonStone* this) { - if ((gSaveContext.weekEventReg[74] & 0x80) == 0) { + if (!(gSaveContext.save.weekEventReg[74] & 0x80)) { this->actor.draw = NULL; } this->actionFunc = func_80C06768; } void func_80C06768(ObjMoonStone* this, GlobalContext* globalCtx) { - if ((gSaveContext.weekEventReg[74] & 0x80)) { - if (this->actor.draw == 0) { + if ((gSaveContext.save.weekEventReg[74] & 0x80)) { + if (this->actor.draw == NULL) { this->actor.draw = ObjMoonStone_Draw; Actor_Spawn(&globalCtx->actorCtx, globalCtx, 1, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, -1); @@ -130,7 +128,7 @@ void func_80C0685C(ObjMoonStone* this) { void func_80C06870(ObjMoonStone* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { - gSaveContext.weekEventReg[74] |= 0x40; + gSaveContext.save.weekEventReg[74] |= 0x40; Actor_MarkForDeath(&this->actor); } } @@ -139,7 +137,7 @@ void ObjMoonStone_Update(Actor* thisx, GlobalContext* globalCtx) { ObjMoonStone* this = THIS; Player* player = GET_PLAYER(globalCtx); - if ((player->stateFlags1 & 0x10000282) == 0) { + if (!(player->stateFlags1 & 0x10000282)) { this->actionFunc(this, globalCtx); } } diff --git a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c index bfb244aa3..f81b4fe47 100644 --- a/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c +++ b/src/overlays/actors/ovl_Obj_Mu_Pict/z_obj_mu_pict.c @@ -40,7 +40,7 @@ const ActorInit Obj_Mu_Pict_InitVars = { void ObjMuPict_Init(Actor* thisx, GlobalContext* globalCtx) { ObjMuPict* this = THIS; - if (!(gSaveContext.weekEventReg[75] & 0x20) && !(gSaveContext.weekEventReg[52] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[75] & 0x20) && !(gSaveContext.save.weekEventReg[52] & 0x20)) { Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c index 9ff5b4599..b46f2626e 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c @@ -197,7 +197,7 @@ void ObjTokeiStep_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClocktowerPanelCol); ObjTokeiStep_InitSteps(this); ObjTokeiStep_SetupBeginOpen(this); - } else if (((CURRENT_DAY == 3) && (gSaveContext.time < CLOCK_TIME(6, 0))) || (gSaveContext.day >= 4)) { + } else if (((CURRENT_DAY == 3) && (gSaveContext.save.time < CLOCK_TIME(6, 0))) || (gSaveContext.save.day >= 4)) { this->dyna.actor.draw = ObjTokeiStep_DrawOpen; ObjTokeiStep_InitStepsOpen(this); ObjTokeiStep_SetupDoNothingOpen(this); diff --git a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c index 3ecac575f..d13a3bb4d 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -88,7 +88,7 @@ static InitChainEntry sInitChain[] = { * the middle of rotating. */ s32 ObjTokeidai_GetTargetSunMoonPanelRotation() { - if (gSaveContext.isNight) { + if (gSaveContext.save.isNight) { return 0x8000; } return 0; @@ -126,11 +126,11 @@ void ObjTokeidai_ExteriorGear_Init(ObjTokeidai* this, GlobalContext* globalCtx) ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.currentCsIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); - } else if ((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { + } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->actionFunc = ObjTokeidai_ExteriorGear_OpenedIdle; this->actor.world.pos.y += this->actor.scale.y * 1900.0f; this->actor.shape.yOffset = 1500.0f; - gSaveContext.weekEventReg[8] |= 0x40; + gSaveContext.save.weekEventReg[8] |= 0x40; } else { this->actionFunc = ObjTokeidai_ExteriorGear_Idle; } @@ -145,7 +145,7 @@ void ObjTokeidai_TowerClock_Init(ObjTokeidai* this, GlobalContext* globalCtx) { ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.currentCsIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); - } else if ((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { + } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->actor.world.pos.y += (this->actor.scale.y * 5191.0f) - 50.0f; this->actor.world.pos.x += Math_SinS(this->actor.world.rot.y) * this->actor.scale.z * 1791.0f; this->actor.world.pos.z += -Math_CosS(this->actor.world.rot.y) * this->actor.scale.z * 1791.0f; @@ -169,7 +169,7 @@ void ObjTokeidai_Counterweight_Init(ObjTokeidai* this, GlobalContext* globalCtx) this->actor.draw = ObjTokeidai_Counterweight_Draw; this->opaDList = gClockTowerCounterweightDL; this->xluDList = gClockTowerSpotlightDL; - if (gSaveContext.isNight) { + if (gSaveContext.save.isNight) { this->spotlightIntensity = 100; } else { this->spotlightIntensity = 0; @@ -199,7 +199,7 @@ void ObjTokeidai_Counterweight_Init(ObjTokeidai* this, GlobalContext* globalCtx) this->actor.child->home.rot.x = 0x12C; } } - } else if ((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { + } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->spotlightIntensity = 0; this->actor.world.pos.y += this->actor.scale.y * -2160.0f; this->actor.world.pos.x += Math_SinS(this->actor.world.rot.y) * this->actor.scale.z * 5400.0f; @@ -221,7 +221,7 @@ void ObjTokeidai_Init(Actor* thisx, GlobalContext* globalCtx) { this->xRotation = 0; this->yTranslation = 0; this->clockFaceZTranslation = 0; - this->clockTime = gSaveContext.time; + this->clockTime = gSaveContext.save.time; this->actor.home.rot.x = 0; switch (OBJ_TOKEIDAI_TYPE(&this->actor)) { @@ -448,19 +448,19 @@ void ObjTokeidai_TerminaFieldWalls_Idle(ObjTokeidai* this, GlobalContext* global void ObjTokeidai_TowerOpening_EndCutscene(ObjTokeidai* this, GlobalContext* globalCtx) { if (Cutscene_CheckActorAction(globalCtx, 132) != 0 && globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 5) { - gSaveContext.weekEventReg[8] |= 0x40; + gSaveContext.save.weekEventReg[8] |= 0x40; if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.currentCsIndex == 0)) || ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.currentCsIndex == 0))) { Audio_SetCutsceneFlag(false); - gSaveContext.cutscene = 0; + gSaveContext.save.cutscene = 0; gSaveContext.nextCutsceneIndex = 0; gSaveContext.respawnFlag = 2; globalCtx->sceneLoadFlag = 0x14; - globalCtx->nextEntranceIndex = gSaveContext.respawn[1].entranceIndex; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_RETURN].entranceIndex; globalCtx->unk_1887F = 2; - if (gSaveContext.respawn[1].playerParams == 0xCFF) { + if (gSaveContext.respawn[RESTART_MODE_RETURN].playerParams == 0xCFF) { gSaveContext.nextTransition = 0x15; } else { gSaveContext.nextTransition = 2; @@ -595,7 +595,7 @@ void ObjTokeidai_TowerOpening_RaiseTower(ObjTokeidai* this, GlobalContext* globa void ObjTokeidai_TowerOpening_Start(ObjTokeidai* this, GlobalContext* globalCtx) { if ((Cutscene_CheckActorAction(globalCtx, 132) && globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 4) || - (gSaveContext.weekEventReg[8] & 0x40)) { + (gSaveContext.save.weekEventReg[8] & 0x40)) { this->actionFunc = ObjTokeidai_TowerOpening_RaiseTower; } } @@ -617,8 +617,8 @@ void ObjTokeidai_DoNothing(ObjTokeidai* this, GlobalContext* globalCtx) { } void ObjTokeidai_StaircaseToRooftop_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (((CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) || - (gSaveContext.weekEventReg[8] & 0x40)) { + if (((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) || + (gSaveContext.save.weekEventReg[8] & 0x40)) { this->actor.draw = ObjTokeidai_Draw; } else { this->actor.draw = NULL; @@ -626,10 +626,10 @@ void ObjTokeidai_StaircaseToRooftop_Idle(ObjTokeidai* this, GlobalContext* globa } s32 ObjTokeidai_IsPostFirstCycleFinalHours(ObjTokeidai* this, GlobalContext* globalCtx) { - if (gSaveContext.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { return false; } - if (CURRENT_DAY == 3 && gSaveContext.time < CLOCK_TIME(6, 0)) { + if (CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) { ObjTokeidai_SetupTowerOpening(this); return true; } @@ -690,10 +690,10 @@ void ObjTokeidai_RotateOnHourChange(ObjTokeidai* this, GlobalContext* globalCtx) } void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (CURRENT_DAY == 3 && this->clockHour < 6 && gSaveContext.time < CLOCK_TIME(6, 0)) { + if (CURRENT_DAY == 3 && this->clockHour < 6 && gSaveContext.save.time < CLOCK_TIME(6, 0)) { this->actor.draw = ObjTokeidai_Clock_Draw; ObjTokeidai_SetupTowerOpening(this); - gSaveContext.weekEventReg[8] |= 0x40; + gSaveContext.save.weekEventReg[8] |= 0x40; return; } @@ -707,21 +707,21 @@ void ObjTokeidai_TowerClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { ActorCutscene_GetCurrentIndex() == -1) { this->actor.draw = NULL; } - this->clockTime = gSaveContext.time; + this->clockTime = gSaveContext.save.time; if (this->actor.home.rot.x != 0) { ObjTokeidai_Clock_Init(this); this->actor.home.rot.x = 0; } } - if (CURRENT_DAY != 3 || gSaveContext.time >= CLOCK_TIME(6, 0)) { + if (CURRENT_DAY != 3 || gSaveContext.save.time >= CLOCK_TIME(6, 0)) { ObjTokeidai_RotateOnMinuteChange(this, true); } ObjTokeidai_RotateOnHourChange(this, globalCtx); } void ObjTokeidai_WallClock_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { - this->clockTime = gSaveContext.time; + this->clockTime = gSaveContext.save.time; ObjTokeidai_RotateOnMinuteChange(this, true); ObjTokeidai_RotateOnHourChange(this, globalCtx); } @@ -740,7 +740,7 @@ void ObjTokeidai_ExteriorGear_Idle(ObjTokeidai* this, GlobalContext* globalCtx) ActorCutscene_GetCurrentIndex() == -1) { this->actor.draw = NULL; } - this->clockTime = gSaveContext.time; + this->clockTime = gSaveContext.save.time; if (this->actor.home.rot.x != 0) { ObjTokeidai_SetupClockOrExteriorGear(this); this->actor.home.rot.x = 0; @@ -775,7 +775,7 @@ void ObjTokeidai_Counterweight_Idle(ObjTokeidai* this, GlobalContext* globalCtx) } } else { this->actor.shape.rot.y -= 0x40; - if (gSaveContext.isNight) { + if (gSaveContext.save.isNight) { if (this->spotlightIntensity < 100) { this->spotlightIntensity += 4; } diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c index cc888cdcd..fde0406f1 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c @@ -110,7 +110,7 @@ s32 ObjWarpstone_BeginOpeningCutscene(ObjWarpstone* this, GlobalContext* globalC s32 ObjWarpstone_PlayOpeningCutscene(ObjWarpstone* this, GlobalContext* globalCtx) { if (this->openingCSTimer++ >= OBJ_WARPSTONE_TIMER_ACTIVATE_THRESHOLD) { ActorCutscene_Stop(this->dyna.actor.cutscene); - func_80143A10(OBJ_WARPSTONE_GET_ID(this)); + Sram_ActivateOwl(OBJ_WARPSTONE_GET_ID(this)); ObjWarpstone_SetupAction(this, ObjWarpstone_OpenedIdle); } else if (this->openingCSTimer < OBJ_WARPSTONE_TIMER_OPEN_THRESHOLD) { Math_StepToF(&this->dyna.actor.velocity.x, 0.01f, 0.001f); @@ -144,7 +144,7 @@ void ObjWarpstone_Update(Actor* thisx, GlobalContext* globalCtx) { globalCtx->msgCtx.msgMode = 0x4D; globalCtx->msgCtx.unk120D6 = 0; globalCtx->msgCtx.unk120D4 = 0; - gSaveContext.owlSaveLocation = OBJ_WARPSTONE_GET_ID(this); + gSaveContext.save.owlSaveLocation = OBJ_WARPSTONE_GET_ID(this); } else { func_801477B4(globalCtx); } diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h index 47163ec2c..37cfb99ab 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h @@ -29,6 +29,6 @@ typedef struct ObjWarpstone { extern const ActorInit Obj_Warpstone_InitVars; #define OBJ_WARPSTONE_GET_ID(this) ((u16)(this->dyna.actor.params & 0xF)) -#define OBJ_WARPSTONE_IS_ACTIVATED(owlId) (((void)0,gSaveContext.owlActivationFlags) & (u16)gBitFlags[owlId]) +#define OBJ_WARPSTONE_IS_ACTIVATED(owlId) (((void)0, gSaveContext.save.playerData.owlActivationFlags) & (u16)gBitFlags[owlId]) #endif // Z_OBJ_WARPSTONE_H diff --git a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c index 91bc39495..997941057 100644 --- a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c +++ b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c @@ -39,7 +39,7 @@ void ObjYado_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); D_80C16470 = Lib_SegmentedToVirtual(object_yado_obj_Matanimheader_0012E8); - this->isNight = gSaveContext.isNight; + this->isNight = gSaveContext.save.isNight; } void ObjYado_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -48,7 +48,7 @@ void ObjYado_Destroy(Actor* thisx, GlobalContext* globalCtx) { void ObjYado_Update(Actor* thisx, GlobalContext* globalCtx) { ObjYado* this = THIS; - this->isNight = gSaveContext.isNight; + this->isNight = gSaveContext.save.isNight; } void ObjYado_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c index f38818cbe..0ac471162 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c @@ -70,11 +70,11 @@ void Daytelop_Update(DaytelopContext* this, GameState* gameState) { this->transitionCountdown--; if (this->transitionCountdown == 0) { - if (gSaveContext.day < 9) { + if (gSaveContext.save.day < 9) { gSaveContext.gameMode = 0; } else { gSaveContext.nextCutsceneIndex = 0xFFF6; - gSaveContext.day = 1; + gSaveContext.save.day = 1; } { @@ -83,7 +83,7 @@ void Daytelop_Update(DaytelopContext* this, GameState* gameState) { } SET_NEXT_GAMESTATE(&this->state, Play_Init, GlobalContext); - gSaveContext.time = CLOCK_TIME(6, 0); + gSaveContext.save.time = CLOCK_TIME(6, 0); D_801BDBC8 = 0xFE; } else if (this->transitionCountdown == 90) { this->fadeInState = DAYTELOP_HOURSTEXT_FADEIN; @@ -132,7 +132,7 @@ void Daytelop_Draw(DaytelopContext* this) { OPEN_DISPS(gfxCtx); func_8012C628(this->state.gfxCtx); - if (gSaveContext.day >= 9) { + if (gSaveContext.save.day >= 9) { // Draw a white screen gDPSetRenderMode(POLY_OPA_DISP++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); @@ -145,12 +145,12 @@ void Daytelop_Draw(DaytelopContext* this) { gDPSetRenderMode(POLY_OPA_DISP++, G_RM_OPA_SURF, G_RM_OPA_SURF2); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); - if (gSaveContext.day >= 9) { + if (gSaveContext.save.day >= 9) { gDPSetAlphaCompare(POLY_OPA_DISP++, G_AC_NONE); } // Draw the left side of the "Dawn of" texture - if (gSaveContext.day < 9) { + if (gSaveContext.save.day < 9) { gDPLoadTextureBlock_4b(POLY_OPA_DISP++, sDayLeftTextures[CURRENT_DAY - 1], G_IM_FMT_I, 128, 64, 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); @@ -163,7 +163,7 @@ void Daytelop_Draw(DaytelopContext* this) { 0x0400, 0x0400); // Draw the right side of the "Dawn of" texture - if (gSaveContext.day < 9) { + if (gSaveContext.save.day < 9) { gDPLoadTextureBlock_4b(POLY_OPA_DISP++, sDayRightTextures[CURRENT_DAY - 1], G_IM_FMT_I, 128, 64, 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); @@ -176,7 +176,7 @@ void Daytelop_Draw(DaytelopContext* this) { 0x0400, 0x0400); // Draw the "Hours left" texture - if (gSaveContext.day < 9) { + if (gSaveContext.save.day < 9) { gDPPipeSync(POLY_OPA_DISP++); gDPSetRenderMode(POLY_OPA_DISP++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, this->alpha); @@ -234,9 +234,9 @@ void Daytelop_Init(GameState* thisx) { this->transitionCountdown = 140; this->fadeInState = DAYTELOP_HOURSTEXT_OFF; - if (gSaveContext.day < 9) { - if (gSaveContext.day == 0) { - func_80143AC4(); + if (gSaveContext.save.day < 9) { + if (gSaveContext.save.day == 0) { + Sram_ClearFlagsAtDawnOfTheFirstDay(); } Sram_IncrementDay(); } diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose.h b/src/overlays/gamestates/ovl_file_choose/z_file_choose.h index d2e71587d..74fd293d0 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.h +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.h @@ -1,12 +1,12 @@ -#ifndef _Z64_FILE_CHOOSE_H_ -#define _Z64_FILE_CHOOSE_H_ +#ifndef Z64_FILE_CHOOSE_H +#define Z64_FILE_CHOOSE_H #include "global.h" void FileChoose_Init(GameState* thisx); void FileChoose_Destroy(GameState* thisx); -typedef struct { +typedef struct FileChooseContext { /* 0x00000 */ GameState state; /* 0x000A4 */ Vtx* unk_A4; /* 0x000A8 */ u8* staticSegment; @@ -21,23 +21,35 @@ typedef struct { /* 0x242E0 */ EnvironmentContext envCtx; /* 0x243E0 */ Vtx* unk_243E0; /* 0x243E4 */ Vtx* unk_243E4; - /* 0x243E8 */ Vtx* unk_243E8; - /* 0x243EC */ Vtx* unk_243EC; - /* 0x243F0 */ Vtx* unk_243F0; - /* 0x243F4 */ u8 newf[6][4]; - /* 0x2440C */ u16 unk_2440C[4]; - /* 0x24414 */ u8 unk_24414[8][4]; - /* 0x24434 */ s16 healthCapacity[4]; - /* 0x2443C */ s16 health[4]; - /* 0x24444 */ u32 unk_24444[4]; - /* 0x24454 */ s8 unk_24454[4]; - /* 0x24458 */ u16 unk_24458[4]; - /* 0x24460 */ s16 unk_24460[4]; - /* 0x24468 */ u8 unk_24468[4]; - /* 0x2446C */ s16 rupees[4]; - /* 0x24474 */ u8 unk_24474[4]; - /* 0x24478 */ u8 unk_24478[4]; - /* 0x2447C */ u8 unk_2447C[4]; + /* 0x243E8 */ u8 newf2[2][6]; + /* 0x243F4 */ u8 newf[2][6]; + /* 0x24400 */ UNK_TYPE1 unk_24400[0xC]; + /* 0x2440C */ u16 unk_2440C[2]; + /* 0x24410 */ u16 unk_24410[2]; + /* 0x24414 */ u8 unk_24414[2][8]; // playername + /* 0x24424 */ u8 unk_24424[2][8]; // playername + /* 0x24434 */ s16 healthCapacity[2]; + /* 0x24438 */ u16 unk_24438[2]; + /* 0x2443C */ s16 health[2]; + /* 0x24440 */ u16 unk_24440[2]; + /* 0x24444 */ u32 unk_24444[2]; + /* 0x2444C */ u32 unk_2444C[2]; + /* 0x24454 */ s8 unk_24454[2]; + /* 0x24456 */ u8 unk_24456[2]; + /* 0x24458 */ u16 unk_24458[2]; + /* 0x2445C */ u16 unk_2445C[2]; + /* 0x24460 */ s16 unk_24460[2]; + /* 0x24464 */ s16 unk_24464[2]; + /* 0x24468 */ u8 unk_24468[2]; + /* 0x2446A */ u8 unk_2446A[2]; + /* 0x2446C */ s16 rupees[2]; + /* 0x24470 */ s16 unk_24470[2]; + /* 0x24474 */ s8 unk_24474[2]; + /* 0x24476 */ s8 unk_24476[2]; + /* 0x24478 */ s8 maskCount[2]; + /* 0x2447A */ s8 unk_2447A[2]; + /* 0x2447C */ s8 heartPieceCount[2]; + /* 0x2447E */ s8 unk_2447E[2]; /* 0x24480 */ s16 unk_24480; /* 0x24482 */ s16 unk_24482; /* 0x24484 */ s16 unk_24484; @@ -50,7 +62,7 @@ typedef struct { /* 0x24492 */ s16 unk_24492[3]; /* 0x24498 */ s16 unk_24498; /* 0x2449A */ s16 unk_2449A[6]; - /* 0x244A6 */ s16 unk_244A6; + /* 0x244A6 */ s16 fileNum; /* 0x244A8 */ s16 unk_244A8; /* 0x244AA */ s16 unk_244AA; /* 0x244AC */ s16 unk_244AC; diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index cff312816..f0dd8190e 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -13,21 +13,21 @@ void Opening_SetupForTitleCutscene(OpeningContext* this) { gSaveContext.eventInf[1] &= (u8)~0x80; gSaveContext.gameMode = 1; - func_80144890(); + Sram_InitNewSave(); - gSaveContext.entranceIndex = openingEntrances[D_801BB12C]; - gSaveContext.nextCutsceneIndex = gSaveContext.cutscene = openingCutscenes[D_801BB12C]; + gSaveContext.save.entranceIndex = openingEntrances[D_801BB12C]; + gSaveContext.nextCutsceneIndex = gSaveContext.save.cutscene = openingCutscenes[D_801BB12C]; gSaveContext.sceneSetupIndex = 0; - gSaveContext.time = CLOCK_TIME(8, 0); - gSaveContext.day = 1; + gSaveContext.save.time = CLOCK_TIME(8, 0); + gSaveContext.save.day = 1; { GameState* thisx = &this->gameState; thisx->running = false; } SET_NEXT_GAMESTATE(&this->gameState, Play_Init, GlobalContext); - gSaveContext.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; } void func_80803EA0(OpeningContext* this) { @@ -57,8 +57,8 @@ void Opening_Init(GameState* thisx) { this->gameState.destroy = Opening_Destroy; gSaveContext.respawnFlag = 0; - gSaveContext.respawn[4].entranceIndex = 0xFF; - gSaveContext.respawn[5].entranceIndex = 0xFF; - gSaveContext.respawn[6].entranceIndex = 0xFF; - gSaveContext.respawn[7].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_GORON].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_ZORA].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_DEKU].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_HUMAN].entranceIndex = 0xFF; } diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index ccc0d434c..53dbc266f 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -33,26 +33,26 @@ void Select_LoadGame(SelectContext* this, u32 entranceIndex, s32 opt) { gSaveContext.unk_3F24 = 0; Audio_QueueSeqCmd(NA_BGM_STOP); - gSaveContext.entranceIndex = entranceIndex; + gSaveContext.save.entranceIndex = entranceIndex; if (opt != 0) { - gSaveContext.entranceIndex = - Entrance_CreateIndex((s32)gSaveContext.entranceIndex >> 9, opt, gSaveContext.entranceIndex & 0xF); + gSaveContext.save.entranceIndex = + Entrance_CreateIndex((s32)gSaveContext.save.entranceIndex >> 9, opt, gSaveContext.save.entranceIndex & 0xF); } - if (gSaveContext.entranceIndex == 0xC000) { - gSaveContext.day = 0; - gSaveContext.time = CLOCK_TIME(6, 0) - 1; + if (gSaveContext.save.entranceIndex == 0xC000) { + gSaveContext.save.day = 0; + gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; } - gSaveContext.respawn[0].entranceIndex = 0xFFFF; + gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex = 0xFFFF; gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.showTitleCard = true; gSaveContext.respawnFlag = 0; - gSaveContext.respawn[4].entranceIndex = 0xFF; - gSaveContext.respawn[5].entranceIndex = 0xFF; - gSaveContext.respawn[6].entranceIndex = 0xFF; - gSaveContext.respawn[7].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_GORON].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_ZORA].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_DEKU].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_HUMAN].entranceIndex = 0xFF; D_801BDBB0 = 0; do { @@ -382,78 +382,78 @@ void Select_UpdateMenu(SelectContext* this) { } if (CHECK_BTN_ALL(controller1->press.button, BTN_B)) { - playerForm = gSaveContext.playerForm - 1; + playerForm = gSaveContext.save.playerForm - 1; if (playerForm < PLAYER_FORM_FIERCE_DEITY) { playerForm = PLAYER_FORM_HUMAN; } - gSaveContext.playerForm = playerForm; + gSaveContext.save.playerForm = playerForm; } if (CHECK_BTN_ALL(controller1->press.button, BTN_Z)) { - if (gSaveContext.cutscene == 0x8000) { - gSaveContext.cutscene = 0; - } else if (gSaveContext.cutscene == 0) { - gSaveContext.cutscene = 0x8800; - } else if (gSaveContext.cutscene == 0x8800) { - gSaveContext.cutscene = 0xFFF0; - } else if (gSaveContext.cutscene == 0xFFF0) { - gSaveContext.cutscene = 0xFFF1; - } else if (gSaveContext.cutscene == 0xFFF1) { - gSaveContext.cutscene = 0xFFF2; - } else if (gSaveContext.cutscene == 0xFFF2) { - gSaveContext.cutscene = 0xFFF3; - } else if (gSaveContext.cutscene == 0xFFF3) { - gSaveContext.cutscene = 0xFFF4; - } else if (gSaveContext.cutscene == 0xFFF4) { - gSaveContext.cutscene = 0xFFF5; - } else if (gSaveContext.cutscene == 0xFFF5) { - gSaveContext.cutscene = 0xFFF6; - } else if (gSaveContext.cutscene == 0xFFF6) { - gSaveContext.cutscene = 0xFFF7; - } else if (gSaveContext.cutscene == 0xFFF7) { - gSaveContext.cutscene = 0xFFF8; - } else if (gSaveContext.cutscene == 0xFFF8) { - gSaveContext.cutscene = 0xFFF9; - } else if (gSaveContext.cutscene == 0xFFF9) { - gSaveContext.cutscene = 0xFFFA; - } else if (gSaveContext.cutscene == 0xFFFA) { - gSaveContext.cutscene = 0x8000; + if (gSaveContext.save.cutscene == 0x8000) { + gSaveContext.save.cutscene = 0; + } else if (gSaveContext.save.cutscene == 0) { + gSaveContext.save.cutscene = 0x8800; + } else if (gSaveContext.save.cutscene == 0x8800) { + gSaveContext.save.cutscene = 0xFFF0; + } else if (gSaveContext.save.cutscene == 0xFFF0) { + gSaveContext.save.cutscene = 0xFFF1; + } else if (gSaveContext.save.cutscene == 0xFFF1) { + gSaveContext.save.cutscene = 0xFFF2; + } else if (gSaveContext.save.cutscene == 0xFFF2) { + gSaveContext.save.cutscene = 0xFFF3; + } else if (gSaveContext.save.cutscene == 0xFFF3) { + gSaveContext.save.cutscene = 0xFFF4; + } else if (gSaveContext.save.cutscene == 0xFFF4) { + gSaveContext.save.cutscene = 0xFFF5; + } else if (gSaveContext.save.cutscene == 0xFFF5) { + gSaveContext.save.cutscene = 0xFFF6; + } else if (gSaveContext.save.cutscene == 0xFFF6) { + gSaveContext.save.cutscene = 0xFFF7; + } else if (gSaveContext.save.cutscene == 0xFFF7) { + gSaveContext.save.cutscene = 0xFFF8; + } else if (gSaveContext.save.cutscene == 0xFFF8) { + gSaveContext.save.cutscene = 0xFFF9; + } else if (gSaveContext.save.cutscene == 0xFFF9) { + gSaveContext.save.cutscene = 0xFFFA; + } else if (gSaveContext.save.cutscene == 0xFFFA) { + gSaveContext.save.cutscene = 0x8000; } } else if (CHECK_BTN_ALL(controller1->press.button, BTN_R)) { - if (gSaveContext.cutscene == 0x8000) { - gSaveContext.cutscene = 0xFFFA; - } else if (gSaveContext.cutscene == 0) { - gSaveContext.cutscene = 0x8000; - } else if (gSaveContext.cutscene == 0x8800) { - gSaveContext.cutscene = 0; - } else if (gSaveContext.cutscene == 0xFFF0) { - gSaveContext.cutscene = 0x8800; - } else if (gSaveContext.cutscene == 0xFFF1) { - gSaveContext.cutscene = 0xFFF0; - } else if (gSaveContext.cutscene == 0xFFF2) { - gSaveContext.cutscene = 0xFFF1; - } else if (gSaveContext.cutscene == 0xFFF3) { - gSaveContext.cutscene = 0xFFF2; - } else if (gSaveContext.cutscene == 0xFFF4) { - gSaveContext.cutscene = 0xFFF3; - } else if (gSaveContext.cutscene == 0xFFF5) { - gSaveContext.cutscene = 0xFFF4; - } else if (gSaveContext.cutscene == 0xFFF6) { - gSaveContext.cutscene = 0xFFF5; - } else if (gSaveContext.cutscene == 0xFFF7) { - gSaveContext.cutscene = 0xFFF6; - } else if (gSaveContext.cutscene == 0xFFF8) { - gSaveContext.cutscene = 0xFFF7; - } else if (gSaveContext.cutscene == 0xFFF9) { - gSaveContext.cutscene = 0xFFF8; - } else if (gSaveContext.cutscene == 0xFFFA) { - gSaveContext.cutscene = 0xFFF9; + if (gSaveContext.save.cutscene == 0x8000) { + gSaveContext.save.cutscene = 0xFFFA; + } else if (gSaveContext.save.cutscene == 0) { + gSaveContext.save.cutscene = 0x8000; + } else if (gSaveContext.save.cutscene == 0x8800) { + gSaveContext.save.cutscene = 0; + } else if (gSaveContext.save.cutscene == 0xFFF0) { + gSaveContext.save.cutscene = 0x8800; + } else if (gSaveContext.save.cutscene == 0xFFF1) { + gSaveContext.save.cutscene = 0xFFF0; + } else if (gSaveContext.save.cutscene == 0xFFF2) { + gSaveContext.save.cutscene = 0xFFF1; + } else if (gSaveContext.save.cutscene == 0xFFF3) { + gSaveContext.save.cutscene = 0xFFF2; + } else if (gSaveContext.save.cutscene == 0xFFF4) { + gSaveContext.save.cutscene = 0xFFF3; + } else if (gSaveContext.save.cutscene == 0xFFF5) { + gSaveContext.save.cutscene = 0xFFF4; + } else if (gSaveContext.save.cutscene == 0xFFF6) { + gSaveContext.save.cutscene = 0xFFF5; + } else if (gSaveContext.save.cutscene == 0xFFF7) { + gSaveContext.save.cutscene = 0xFFF6; + } else if (gSaveContext.save.cutscene == 0xFFF8) { + gSaveContext.save.cutscene = 0xFFF7; + } else if (gSaveContext.save.cutscene == 0xFFF9) { + gSaveContext.save.cutscene = 0xFFF8; + } else if (gSaveContext.save.cutscene == 0xFFFA) { + gSaveContext.save.cutscene = 0xFFF9; } } - gSaveContext.isNight = false; - if (gSaveContext.cutscene == 0x8800) { - gSaveContext.isNight = true; + gSaveContext.save.isNight = false; + if (gSaveContext.save.cutscene == 0x8800) { + gSaveContext.save.isNight = true; } if (CHECK_BTN_ALL(controller1->press.button, BTN_CUP)) { @@ -464,14 +464,14 @@ void Select_UpdateMenu(SelectContext* this) { } if (CHECK_BTN_ALL(controller1->press.button, BTN_CLEFT)) { - if (gSaveContext.day > 1) { - gSaveContext.day--; + if (gSaveContext.save.day > 1) { + gSaveContext.save.day--; } } if (CHECK_BTN_ALL(controller1->press.button, BTN_CRIGHT)) { - if (gSaveContext.day < 4) { - gSaveContext.day++; + if (gSaveContext.save.day < 4) { + gSaveContext.save.day++; } } @@ -723,19 +723,19 @@ void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csI case 0: // clang-format off // "Afternoon-jara" - gSaveContext.time = CLOCK_TIME(12, 0); stage = "\x8Dオヒル\x8Cジャラ"; + gSaveContext.save.time = CLOCK_TIME(12, 0); stage = "\x8Dオヒル\x8Cジャラ"; // clang-format on break; case 0x8000: // clang-format off // "Morning-jara" - gSaveContext.time = CLOCK_TIME(6, 0) + 1; stage = "\x8Dアサ \x8Cジャラ"; + gSaveContext.save.time = CLOCK_TIME(6, 0) + 1; stage = "\x8Dアサ \x8Cジャラ"; // clang-format on break; case 0x8800: - gSaveContext.time = CLOCK_TIME(18, 1); + gSaveContext.save.time = CLOCK_TIME(18, 1); // "Night-jara" stage = "\x8Dヨル \x8Cジャラ"; break; @@ -743,7 +743,7 @@ void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csI case 0xFFF0: // clang-format off // "Cutscene 00" - gSaveContext.time = CLOCK_TIME(12, 0); stage = "デモ00"; + gSaveContext.save.time = CLOCK_TIME(12, 0); stage = "デモ00"; // clang-format on break; case 0xFFF1: @@ -791,13 +791,13 @@ void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csI stage = "???"; break; } - gSaveContext.environmentTime = gSaveContext.time; + gSaveContext.environmentTime = gSaveContext.save.time; GfxPrint_Printf(printer, "Stage:\x8C%s", stage); GfxPrint_SetPos(printer, 23, 25); GfxPrint_SetColor(printer, 255, 255, 55, 255); - switch (gSaveContext.day) { + switch (gSaveContext.save.day) { case 1: // "The First Day" day = "\x8Dサイショノヒ"; @@ -815,7 +815,7 @@ void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csI day = "\x8Dクリアーノヒ"; break; default: - gSaveContext.day = 1; + gSaveContext.save.day = 1; // "The First Day" day = "\x8Dサイショノヒ"; break; @@ -837,8 +837,8 @@ void Select_DrawMenu(SelectContext* this) { GfxPrint_Open(printer, POLY_OPA_DISP); Select_PrintMenu(this, printer); - Select_PrintAgeSetting(this, printer, ((void)0, gSaveContext.playerForm)); - Select_PrintCutsceneSetting(this, printer, ((void)0, gSaveContext.cutscene)); + Select_PrintAgeSetting(this, printer, ((void)0, gSaveContext.save.playerForm)); + Select_PrintCutsceneSetting(this, printer, ((void)0, gSaveContext.save.cutscene)); POLY_OPA_DISP = GfxPrint_Close(printer); GfxPrint_Destroy(printer); @@ -928,7 +928,7 @@ void Select_Init(GameState* thisx) { } Game_SetFramerateDivisor(&this->state, 1); - gSaveContext.cutscene = 0; - gSaveContext.playerForm = PLAYER_FORM_HUMAN; - gSaveContext.linkAge = 0; + gSaveContext.save.cutscene = 0; + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.save.linkAge = 0; } diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 79d1c19f2..afeafe09f 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -145,7 +145,7 @@ void Title_Main(GameState* thisx) { void Title_Destroy(GameState* thisx) { TitleContext* this = (TitleContext*)thisx; - func_80146E40(&this->gameState, &this->sramCtx); + Sram_InitSram(&this->gameState, &this->sramCtx); ShrinkWindow_Destroy(); CIC6105_Nop80081828(); } @@ -173,7 +173,7 @@ void Title_Init(GameState* thisx) { gSaveContext.fileNum = 0xFF; } - gSaveContext.unk_3F3F = 1; + gSaveContext.unk_3F3F = true; Sram_Alloc(thisx, &this->sramCtx); this->ult = 0; this->timer = 20; diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 3ca33148d..0c6eedbad 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -489,16 +489,32 @@ animdict = { "actor.minVelocityY": "actor.terminalVelocity", "actor.yDistToWater": "actor.depthInWater", "actor.yDistToPlayer": "actor.playerHeightRel", - "globalCtx->mf_187FC": "globalCtx->billboardMtxF", - "globalCtx->projectionMatrix": "globalCtx->viewProjectionMtxF", - "csCtx.npcActions": "csCtx.actorActions", - "csCtx->npcActions": "csCtx->actorActions", - "csCtx.unk_12": "csCtx.currentCsIndex", - "globalCtx->envCtx.unk_8C": "globalCtx->envCtx.lightSettings", - "globalCtx->envCtx.unk_E5": "globalCtx->envCtx.fillScreen", - "globalCtx->envCtx.unk_E6": "globalCtx->envCtx.screenFillColor", - "globalCtx->envCtx.unk_C3": "globalCtx->envCtx.lightSettingOverride", - "globalCtx->envCtx.unk_DC": "globalCtx->envCtx.lightBlend", + "gSaveContext.weekEventReg": "gSaveContext.save.weekEventReg", + "gSaveContext.playerForm": "gSaveContext.save.playerForm", + "gSaveContext.day": "gSaveContext.save.day", + # "gSaveContext.cutscene": "gSaveContext.save.cutscene", + "gSaveContext.isNight": "gSaveContext.save.isNight", + "gSaveContext.naviTimer": "gSaveContext.save.playerData.tatlTimer", + "gSaveContext.tatlTimer": "gSaveContext.save.playerData.tatlTimer", + # "gSaveContext.health": "gSaveContext.save.playerData.health", + "gSaveContext.rupees": "gSaveContext.save.playerData.rupees", + "gSaveContext.magicAcquired": "gSaveContext.save.playerData.magicAcquired", + "gSaveContext.doubleMagic": "gSaveContext.save.playerData.doubleMagic", + "gSaveContext.doubleDefense": "gSaveContext.save.playerData.doubleDefense", + "gSaveContext.playerName": "gSaveContext.save.playerData.playerName", + "gSaveContext.inventory": "gSaveContext.save.inventory", + "gSaveContext.equippedMask": "gSaveContext.save.equippedMask", + "gSaveContext.entranceIndex": "gSaveContext.save.entranceIndex", + "gSaveContext.time": "gSaveContext.save.time", + "gSaveContext.unk_14": "gSaveContext.save.daySpeed", + "gSaveContext.unk_FE6": "gSaveContext.save.bombersCaughtNum", + "gSaveContext.unk_FE7": "gSaveContext.save.bombersCaughtOrder", + "gSaveContext.linkAge": "gSaveContext.save.linkAge", + "gSaveContext.dekuPlaygroundHighScores": "gSaveContext.save.dekuPlaygroundHighScores", + "gSaveContext.lotteryCodeGuess": "gSaveContext.save.lotteryCodeGuess", + "gSaveContext.permanentSceneFlags": "gSaveContext.save.permanentSceneFlags", + "gSaveContext.bomberCode": "gSaveContext.save.bomberCode", + "gSaveContext.skullTokenCount": "gSaveContext.save.skullTokenCount", "player->unk_A87": "player->exchangeItemId", "player->leftHandActor": "player->heldActor", "player->unk_384": "player->getItemId", @@ -506,7 +522,17 @@ animdict = { "player->unk_388": "player->interactRangeActor", "player->unk_38C": "player->mountSide", "player->unk_394": "player->csMode", + "csCtx.npcActions": "csCtx.actorActions", + "csCtx->npcActions": "csCtx->actorActions", + "csCtx.unk_12": "csCtx.currentCsIndex", + "globalCtx->mf_187FC": "globalCtx->billboardMtxF", + "globalCtx->projectionMatrix": "globalCtx->viewProjectionMtxF", "globalCtx->actorCtx.actorList[": "globalCtx->actorCtx.actorLists[", + "globalCtx->envCtx.unk_8C": "globalCtx->envCtx.lightSettings", + "globalCtx->envCtx.unk_E5": "globalCtx->envCtx.fillScreen", + "globalCtx->envCtx.unk_E6": "globalCtx->envCtx.screenFillColor", + "globalCtx->envCtx.unk_C3": "globalCtx->envCtx.lightSettingOverride", + "globalCtx->envCtx.unk_DC": "globalCtx->envCtx.lightBlend", "gSaveContext.unk_1016": "gSaveContext.jinxTimer", "gSaveContext.unk_3F58": "gSaveContext.sunsSongState", "globalCtx->msgCtx.unk1202A": "globalCtx->msgCtx.ocarinaMode", @@ -527,6 +553,9 @@ animdict = { "ActorAnimationEntryS": "AnimationInfoS", "struct_80B8E1A8": "AnimationSpeedInfo", + # Macros + "CUR_EQUIP_VALUE_VOID": "GET_CUR_EQUIP_VALUE", + "CUR_UPG_VALUE_VOID": "GET_CUR_UPG_VALUE", "ICHAIN_F32_DIV1000(minVelocityY,": "ICHAIN_F32_DIV1000(terminalVelocity,", "ICHAIN_F32(minVelocityY,": "ICHAIN_F32(terminalVelocity,", } diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index a43ef93f4..cd1bbac2f 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -561,6 +561,7 @@ 0x801C5DD0 : "z_vimode", 0x801C5E30 : "z_vr_box", 0x801C5FC0 : "z_sram_NES", + 0x801C6A70 : "z_message", 0x801D0470 : "z_message_nes", 0x801D0B50 : "z_player_call", 0x801D0B70 : "z_kaleido_manager", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 9a4c19d2c..8c6a53946 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2787,30 +2787,30 @@ 0x80143624:("SkyboxDraw_SetColors",), 0x80143668:("SkyboxDraw_Draw",), 0x80143A04:("SkyboxDraw_Noop",), - 0x80143A10:("func_80143A10",), - 0x80143A54:("func_80143A54",), - 0x80143AC4:("func_80143AC4",), - 0x80143B0C:("func_80143B0C",), + 0x80143A10:("Sram_ActivateOwl",), + 0x80143A54:("Sram_ClearHighscores",), + 0x80143AC4:("Sram_ClearFlagsAtDawnOfTheFirstDay",), + 0x80143B0C:("Sram_SaveEndOfCycle",), 0x80144574:("Sram_IncrementDay",), 0x801445E4:("Sram_CalcChecksum",), - 0x80144628:("func_80144628",), + 0x80144628:("Sram_ResetSave",), 0x80144684:("Sram_GenerateRandomSaveFields",), - 0x80144890:("func_80144890",), + 0x80144890:("Sram_InitNewSave",), 0x80144968:("Sram_InitDebugSave",), 0x80144A94:("func_80144A94",), - 0x80144E78:("func_80144E78",), + 0x80144E78:("Sram_OpenSave",), 0x8014546C:("func_8014546C",), 0x80145698:("func_80145698",), 0x801457CC:("func_801457CC",), 0x80146580:("func_80146580",), 0x80146628:("func_80146628",), - 0x80146AA0:("func_80146AA0",), + 0x80146AA0:("Sram_InitSave",), 0x80146DF8:("func_80146DF8",), - 0x80146E40:("func_80146E40",), + 0x80146E40:("Sram_InitSram",), 0x80146E70:("Sram_Alloc",), 0x80146EBC:("func_80146EBC",), - 0x80146EE8:("func_80146EE8",), - 0x80146F5C:("func_80146F5C",), + 0x80146EE8:("Sram_SaveSpecialEnterClockTown",), + 0x80146F5C:("Sram_SaveSpecialNewDay",), 0x80147008:("func_80147008",), 0x80147020:("func_80147020",), 0x80147068:("func_80147068",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 2b6e72ca9..5e1be9b2a 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -1983,33 +1983,27 @@ 0x801C5EB0:("D_801C5EB0","UNK_TYPE4","",0x4), 0x801C5EC4:("D_801C5EC4","UNK_TYPE2","",0x2), 0x801C5F44:("D_801C5F44","UNK_TYPE4","",0x4), - 0x801C5FC0:("D_801C5FC0","UNK_TYPE4","",0x4), - 0x801C5FC4:("D_801C5FC4","UNK_TYPE4","",0x4), - 0x801C5FC8:("D_801C5FC8","UNK_TYPE4","",0x4), - 0x801C5FCC:("D_801C5FCC","UNK_TYPE4","",0x4), - 0x801C5FD0:("D_801C5FD0","UNK_TYPE4","",0x4), + 0x801C5FC0:("D_801C5FC0","u32","[452]",0x710), 0x801C66D0:("D_801C66D0","UNK_TYPE2","",0x2), 0x801C6798:("D_801C6798","UNK_TYPE4","",0x4), 0x801C67B0:("D_801C67B0","UNK_TYPE1","",0x1), - 0x801C67C8:("D_801C67C8","UNK_TYPE4","",0x4), - 0x801C67CC:("D_801C67CC","UNK_TYPE4","",0x4), + 0x801C67C8:("D_801C67C8","s32","[8]",0x20), 0x801C67E8:("D_801C67E8","UNK_TYPE4","",0x4), - 0x801C67F0:("D_801C67F0","UNK_TYPE4","",0x4), - 0x801C67F4:("D_801C67F4","UNK_TYPE4","",0x4), + 0x801C67F0:("D_801C67F0","s32","[8]",0x20), 0x801C6818:("D_801C6818","UNK_TYPE1","",0x1), 0x801C6838:("D_801C6838","UNK_TYPE4","",0x4), 0x801C6840:("D_801C6840","UNK_TYPE1","",0x1), 0x801C6850:("D_801C6850","UNK_TYPE1","",0x1), 0x801C6870:("D_801C6870","UNK_TYPE1","",0x1), 0x801C6890:("D_801C6890","UNK_TYPE1","",0x1), - 0x801C6898:("D_801C6898","SaveInfo","",0x28), - 0x801C68C0:("D_801C68C0","SaveContext_struct2","",0x22), - 0x801C68E4:("gSaveDefaultInventory","Inventory","",0x88), - 0x801C696C:("gSaveDefaultChecksum","u16","",0x2), - 0x801C6970:("D_801C6970","SaveInfo","",0x28), - 0x801C6998:("D_801C6998","SaveContext_struct2","",0x22), - 0x801C69BC:("D_801C69BC","Inventory","",0x88), - 0x801C6A44:("D_801C6A44","u16","",0x2), + 0x801C6898:("sSaveDefaultPlayerData","SavePlayerData","",0x28), + 0x801C68C0:("sSaveDefaultItemEquips","ItemEquips","",0x22), + 0x801C68E4:("sSaveDefaultInventory","Inventory","",0x88), + 0x801C696C:("sSaveDefaultChecksum","u16","",0x2), + 0x801C6970:("sSaveDebugPlayerData","SaveInfo","",0x28), + 0x801C6998:("sSaveDebugItemEquips","ItemEquips","",0x22), + 0x801C69BC:("sSaveDebugInventory","Inventory","",0x88), + 0x801C6A44:("sSaveDebugChecksum","u16","",0x2), 0x801C6A48:("D_801C6A48","UNK_TYPE1","",0x1), 0x801C6A50:("D_801C6A50","UNK_TYPE1","",0x1), 0x801C6A58:("D_801C6A58","UNK_TYPE1","",0x1), diff --git a/tools/permuter_settings.toml b/tools/permuter_settings.toml index eb2f1ac4b..2676d13ee 100644 --- a/tools/permuter_settings.toml +++ b/tools/permuter_settings.toml @@ -13,6 +13,7 @@ SQ = "int" CLAMP = "int" CLOCK_TIME = "int" CURRENT_DAY = "int" +CHECK_NEWF = "int" NULL = "int" [decompme.compilers] diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 58e4703e1..78ac67dba 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2301,30 +2301,30 @@ asm/non_matchings/code/z_vr_box_draw/func_801435A0.s,func_801435A0,0x801435A0,0x asm/non_matchings/code/z_vr_box_draw/func_80143624.s,func_80143624,0x80143624,0x11 asm/non_matchings/code/z_vr_box_draw/func_80143668.s,func_80143668,0x80143668,0xE7 asm/non_matchings/code/z_vr_box_draw/func_80143A04.s,func_80143A04,0x80143A04,0x3 -asm/non_matchings/code/z_sram_NES/func_80143A10.s,func_80143A10,0x80143A10,0x11 -asm/non_matchings/code/z_sram_NES/func_80143A54.s,func_80143A54,0x80143A54,0x1C -asm/non_matchings/code/z_sram_NES/func_80143AC4.s,func_80143AC4,0x80143AC4,0x12 -asm/non_matchings/code/z_sram_NES/func_80143B0C.s,func_80143B0C,0x80143B0C,0x29A +asm/non_matchings/code/z_sram_NES/Sram_ActivateOwl.s,Sram_ActivateOwl,0x80143A10,0x11 +asm/non_matchings/code/z_sram_NES/Sram_ClearHighscores.s,Sram_ClearHighscores,0x80143A54,0x1C +asm/non_matchings/code/z_sram_NES/Sram_ClearFlagsAtDawnOfTheFirstDay.s,Sram_ClearFlagsAtDawnOfTheFirstDay,0x80143AC4,0x12 +asm/non_matchings/code/z_sram_NES/Sram_SaveEndOfCycle.s,Sram_SaveEndOfCycle,0x80143B0C,0x29A asm/non_matchings/code/z_sram_NES/Sram_IncrementDay.s,Sram_IncrementDay,0x80144574,0x1C asm/non_matchings/code/z_sram_NES/Sram_CalcChecksum.s,Sram_CalcChecksum,0x801445E4,0x11 -asm/non_matchings/code/z_sram_NES/func_80144628.s,func_80144628,0x80144628,0x17 +asm/non_matchings/code/z_sram_NES/Sram_ResetSave.s,Sram_ResetSave,0x80144628,0x17 asm/non_matchings/code/z_sram_NES/Sram_GenerateRandomSaveFields.s,Sram_GenerateRandomSaveFields,0x80144684,0x83 asm/non_matchings/code/z_sram_NES/func_80144890.s,func_80144890,0x80144890,0x36 asm/non_matchings/code/z_sram_NES/Sram_InitDebugSave.s,Sram_InitDebugSave,0x80144968,0x4B asm/non_matchings/code/z_sram_NES/func_80144A94.s,func_80144A94,0x80144A94,0xF9 -asm/non_matchings/code/z_sram_NES/func_80144E78.s,func_80144E78,0x80144E78,0x17D +asm/non_matchings/code/z_sram_NES/Sram_OpenSave.s,Sram_OpenSave,0x80144E78,0x17D asm/non_matchings/code/z_sram_NES/func_8014546C.s,func_8014546C,0x8014546C,0x8B asm/non_matchings/code/z_sram_NES/func_80145698.s,func_80145698,0x80145698,0x4D asm/non_matchings/code/z_sram_NES/func_801457CC.s,func_801457CC,0x801457CC,0x36D asm/non_matchings/code/z_sram_NES/func_80146580.s,func_80146580,0x80146580,0x2A asm/non_matchings/code/z_sram_NES/func_80146628.s,func_80146628,0x80146628,0x11E -asm/non_matchings/code/z_sram_NES/func_80146AA0.s,func_80146AA0,0x80146AA0,0xD6 +asm/non_matchings/code/z_sram_NES/Sram_InitSave.s,Sram_InitSave,0x80146AA0,0xD6 asm/non_matchings/code/z_sram_NES/func_80146DF8.s,func_80146DF8,0x80146DF8,0x12 -asm/non_matchings/code/z_sram_NES/func_80146E40.s,func_80146E40,0x80146E40,0xC +asm/non_matchings/code/z_sram_NES/Sram_InitSram.s,Sram_InitSram,0x80146E40,0xC asm/non_matchings/code/z_sram_NES/Sram_Alloc.s,Sram_Alloc,0x80146E70,0x13 asm/non_matchings/code/z_sram_NES/func_80146EBC.s,func_80146EBC,0x80146EBC,0xB -asm/non_matchings/code/z_sram_NES/func_80146EE8.s,func_80146EE8,0x80146EE8,0x1D -asm/non_matchings/code/z_sram_NES/func_80146F5C.s,func_80146F5C,0x80146F5C,0x2B +asm/non_matchings/code/z_sram_NES/Sram_SaveSpecialEnterClockTown.s,Sram_SaveSpecialEnterClockTown,0x80146EE8,0x1D +asm/non_matchings/code/z_sram_NES/Sram_SaveSpecialNewDay.s,Sram_SaveSpecialNewDay,0x80146F5C,0x2B asm/non_matchings/code/z_sram_NES/func_80147008.s,func_80147008,0x80147008,0x6 asm/non_matchings/code/z_sram_NES/func_80147020.s,func_80147020,0x80147020,0x12 asm/non_matchings/code/z_sram_NES/func_80147068.s,func_80147068,0x80147068,0x34 From 1ff183bc05bb9f9a692ae4278430d8a0157fdd51 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 02:25:08 +0100 Subject: [PATCH 142/257] En_Test7 (#628) * En_Test7 * Clean some stuff * I hate BSS * PR * Fix * Merge * Fix * Match (thanks Anon) * PR * PR * PR * Fix --- assets/xml/objects/gameplay_keep.xml | 6 +- include/functions.h | 6 +- spec | 4 +- src/overlays/actors/ovl_En_Test7/z_en_test7.c | 954 +++++++++++++++++- src/overlays/actors/ovl_En_Test7/z_en_test7.h | 52 +- tools/disasm/variables.txt | 7 +- 6 files changed, 973 insertions(+), 56 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 4adba079c..3e74b3ace 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1356,7 +1356,8 @@ - + + @@ -1387,7 +1388,8 @@ - + + diff --git a/include/functions.h b/include/functions.h index 121d9bb05..fea33cabb 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1559,7 +1559,7 @@ void func_800FD538(Color_RGB8* param_1, Color_RGB8* param_2, f32 param_3, Vec3s* void func_800FD59C(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); void func_800FD5E0(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); void func_800FD654(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); -// void func_800FD698(void); +void func_800FD698(GlobalContext* globalCtx, s32 arg1, s32 arg2, f32 arg3); // u32 get_days_elapsed(void); // void reset_days_elapsed(void); // u32 get_current_day(void); @@ -3161,7 +3161,7 @@ void func_80183070(void); // void func_8018340C(void); void func_80183430(SkeletonInfo* skeletonInfo, void* arg1, void* arg2, Vec3s* arg3, s16* arg4, UnkKeyframeCallback* callbacks); void func_8018349C(UNK_PTR arg0); -// void func_801834A8(void); +void func_801834A8(SkeletonInfo* skeletonInfo, void* arg1); // void func_80183510(void); // void func_80183580(void); void func_801835EC(UNK_PTR arg0, UNK_PTR arg1); @@ -3554,7 +3554,7 @@ void func_801A2C20(void); void func_801A2C88(u16 seqId); void func_801A2D54(u16 seqId); s32 Audio_IsSequencePlaying(u8 seqId); -void func_801A2E54(s32 param_1); +void func_801A2E54(s32 bgmId); void func_801A2ED8(void); // void func_801A2F88(void); // void func_801A3000(void); diff --git a/spec b/spec index 152a2c41b..fd7ffe007 100644 --- a/spec +++ b/spec @@ -3680,9 +3680,7 @@ beginseg name "ovl_En_Test7" compress include "build/src/overlays/actors/ovl_En_Test7/z_en_test7.o" - include "build/data/ovl_En_Test7/ovl_En_Test7.data.o" - include "build/data/ovl_En_Test7/ovl_En_Test7.bss.o" - include "build/data/ovl_En_Test7/ovl_En_Test7.reloc.o" + include "build/src/overlays/actors/ovl_En_Test7/ovl_En_Test7_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.c b/src/overlays/actors/ovl_En_Test7/z_en_test7.c index e84e2d3fd..c5fda21f0 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -5,6 +5,7 @@ */ #include "z_en_test7.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_100000 | ACTOR_FLAG_200000 | ACTOR_FLAG_2000000) @@ -15,11 +16,24 @@ void EnTest7_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTest7_Update(Actor* thisx, GlobalContext* globalCtx); void EnTest7_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80AF2854(EnTest7* this, GlobalContext* globalCtx); - void EnTest7_SetupAction(EnTest7* this, EnTest7ActionFunc actionFunc); +void func_80AF19A8(EnTest7* this, GlobalContext* globalCtx); +void func_80AF1A2C(EnTest7* this, GlobalContext* globalCtx); +void func_80AF1CA0(EnTest7* this, GlobalContext* globalCtx); +void func_80AF1E44(EnTest7* this, GlobalContext* globalCtx); +void func_80AF1F48(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2030(EnTest7* this, GlobalContext* globalCtx); +void func_80AF21E8(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2318(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2350(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2854(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2938(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2AE8(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2C48(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2EC8(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2F98(EnTest7* this, GlobalContext* globalCtx); +void func_80AF30F4(EnTest7* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Test7_InitVars = { ACTOR_EN_TEST7, ACTORCAT_ITEMACTION, @@ -32,80 +46,936 @@ const ActorInit En_Test7_InitVars = { (ActorFunc)EnTest7_Draw, }; -#endif +void EnTest7_SetupAction(EnTest7* this, EnTest7ActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_SetupAction.s") +void func_80AF082C(EnTest7* this, EnTest7UnkFunc func) { + this->unk_1E58 = func; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF082C.s") +void func_80AF0838(EnTest7Struct2* arg0) { + EnTest7Struct2* ptr = arg0; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF0838.s") + for (i = 0, ptr = arg0; i < 100; i++, ptr++) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF0984.s") + ptr->unk_00 = 0; + ptr->unk_04 = 0; + ptr->unk_08.x = 0.0f; + ptr->unk_08.y = 0.0f; + ptr->unk_08.z = 0.0f; + ptr->unk_14 = 0.0f; + ptr->unk_18 = 0.0f; + ptr->unk_1C = 0.0f; + ptr->unk_20 = 0.0f; + ptr->unk_24 = 0.0f; + ptr->unk_28 = 0.0f; + ptr->unk_2C = 0.00001f; + ptr->unk_30.x = 0; + ptr->unk_30.y = 0; + ptr->unk_30.z = 0; + ptr->unk_36 = 0; + ptr->unk_38 = 0; + ptr->unk_3A = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF0C30.s") +void func_80AF0984(EnTest7Struct2* arg0, Vec3f* arg1, s32 arg2) { + s16 sp26 = Rand_ZeroOne() * 0xFFFF; + f32 sp20; + f32 temp_f0; + f32 temp_f0_2; + f32 temp_f0_3; + f32 temp_f4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF0CDC.s") + arg0->unk_08 = *arg1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF10D8.s") + if (arg2 != 0) { + Math_CosS(sp26); + arg0->unk_08.x = arg0->unk_08.x; + arg0->unk_08.y += (Rand_ZeroOne() * 100.0f) - 20.0f; + Math_SinS(sp26); + arg0->unk_08.z = arg0->unk_08.z; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF118C.s") + sp20 = (Rand_ZeroOne() * 4.0f) + 2.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF14FC.s") + arg0->unk_14 = Math_CosS(sp26) * sp20; + arg0->unk_18 = Rand_ZeroOne(); + arg0->unk_1C = Math_SinS(sp26) * sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1730.s") + arg0->unk_20 = 0.0f; + arg0->unk_24 = 0.0f; + arg0->unk_28 = 0.0f; + arg0->unk_2C = 0.25f; + arg0->unk_30.x = Rand_ZeroOne() * 0x10000; + arg0->unk_30.y = Rand_ZeroOne() * 0x10000; + arg0->unk_30.z = Rand_ZeroOne() * 0x10000; + arg0->unk_04 = 60; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_Init.s") + if (Rand_ZeroOne() < 0.9f) { + arg0->unk_00 = 1; + arg0->unk_30.x = Rand_ZeroOne() * 0x10000; + arg0->unk_30.y = Rand_ZeroOne() * 0x10000; + arg0->unk_30.z = Rand_ZeroOne() * 0x10000; + arg0->unk_36 = 0; + arg0->unk_38 = 0; + arg0->unk_3A = 0; + } else { + arg0->unk_00 = 2; + arg0->unk_30.x = 0; + arg0->unk_30.y = 0; + arg0->unk_30.z = Rand_ZeroOne() * 5000.0f; + arg0->unk_36 = 0; + arg0->unk_38 = (Rand_ZeroOne() * 8000.0f) + 2000.0f; + if (Rand_ZeroOne() > 0.5f) { + arg0->unk_38 = -arg0->unk_38; + } + arg0->unk_3A = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_Destroy.s") +void func_80AF0C30(EnTest7Struct2* arg0, Vec3f* arg1, s32 arg2) { + static s32 D_80AF3410 = 0; + s32 i; + s32 phi_t0 = false; + EnTest7Struct2* ptr; + s32 idx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF19A8.s") + for (i = 0, ptr = arg0; i < 100; i++, ptr++) { + if (ptr->unk_00 == 0) { + func_80AF0984(ptr, arg1, arg2); + D_80AF3410 = i; + phi_t0 = true; + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1A2C.s") + if (!phi_t0) { + idx = D_80AF3410 + 1; + if (idx >= 100) { + idx = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1B68.s") + func_80AF0984(&arg0[idx], arg1, arg2); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1CA0.s") +Vec3f D_80AF3414 = { 0.0f, 1.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1E44.s") +Vec3f D_80AF3420 = { 0.0f, 0.0f, 1.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1F48.s") +void func_80AF0CDC(GlobalContext* globalCtx, EnTest7Struct2* arg1) { + static MtxF D_80AF38B0; + static Vec3f D_80AF38F0; + static f32 D_80AF38FC; + static Vec3f D_80AF3900; + s32 sp2C; + s32 sp28; + s32 sp24; + s16 temp_v0_2; + s16 temp_v0_3; + s32 temp_v0; + f32 phi_f8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2030.s") + sp2C = arg1->unk_04 % 41; + sp24 = 0; + sp28 = (arg1->unk_04 + 0x1B58) % 41; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF21E8.s") + SkinMatrix_SetRotateRPY(&D_80AF38B0, arg1->unk_30.x, arg1->unk_30.y, arg1->unk_30.z); + SkinMatrix_Vec3fMtxFMultXYZ(&D_80AF38B0, &D_80AF3414, &D_80AF38F0); + SkinMatrix_Vec3fMtxFMultXYZ(&D_80AF38B0, &D_80AF3420, &D_80AF3900); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2318.s") + if (arg1->unk_30.x < 0x3448) { + arg1->unk_30.x += 0x384; + } else if (arg1->unk_30.x >= 0x4BB9) { + arg1->unk_30.x -= 0x384; + } else { + arg1->unk_30.x = (Math_SinS((sp2C * 65535.0f) / 41.0f) * 2000.0f) + 16384.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2350.s") + if (arg1->unk_30.y < -0xBB8) { + arg1->unk_30.y += 0x384; + } else if (arg1->unk_30.y > 0xBB8) { + arg1->unk_30.y -= 0x384; + } else { + sp24 = 1; + arg1->unk_30.y = Math_SinS((sp28 * 65535.0f) / 41.0f) * 2000.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF24D8.s") + if (sp24 == 1) { + if (D_80AF38F0.y < 0.0f) { + arg1->unk_14 += D_80AF38F0.x * 0.5f; + arg1->unk_18 += (D_80AF38F0.y * 0.5f) + 0.08f; + arg1->unk_1C += (D_80AF38F0.z * 0.5f); + } else { + arg1->unk_14 += -D_80AF38F0.x * 0.5f; + arg1->unk_18 += (-D_80AF38F0.y * 0.5f) + 0.08f; + arg1->unk_1C += -D_80AF38F0.z * 0.5f; + } + } else if (D_80AF38F0.y < 0.0f) { + arg1->unk_14 += D_80AF38F0.x * 0.2f; + arg1->unk_18 += (D_80AF38F0.y * 0.2f) + 0.08f; + arg1->unk_1C += D_80AF38F0.z * 0.2f; + } else { + arg1->unk_14 += -D_80AF38F0.x * 0.2f; + arg1->unk_18 += (-D_80AF38F0.y * 0.2f) + 0.08f; + arg1->unk_1C += (-D_80AF38F0.z * 0.2f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2654.s") + arg1->unk_08.x += arg1->unk_14; + arg1->unk_08.y += arg1->unk_18; + arg1->unk_08.z += arg1->unk_1C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2808.s") +void func_80AF10D8(GlobalContext* globalCtx, EnTest7Struct2* arg1) { + arg1->unk_30.y += arg1->unk_38; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2854.s") + arg1->unk_20 = Rand_Centered(); + arg1->unk_24 = Rand_Centered() + -0.01f; + arg1->unk_28 = Rand_Centered(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2938.s") + arg1->unk_14 += arg1->unk_20; + arg1->unk_18 += arg1->unk_24; + arg1->unk_1C += arg1->unk_28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF29C0.s") + arg1->unk_08.x += arg1->unk_14; + arg1->unk_08.y += arg1->unk_18; + arg1->unk_08.z += arg1->unk_1C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2AE8.s") +void func_80AF118C(GlobalContext* globalCtx, EnTest7Struct2* arg1, EnTest7* this, s32 arg3, s32 arg4) { + s32 pad[4]; + EnTest7Struct2* ptr; + s16 phi_s1; + s32 i; + f32 temp_f28; + Vec3f sp8C; + f32 temp_f0; + f32 temp_f22; + f32 temp_f24; + f32 temp_f26; + f32 temp_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2BAC.s") + for (i = 0, ptr = arg1; i < (s32)(ARRAY_COUNT(this->unk_15C) * sizeof(this->unk_15C[0])); + i += sizeof(this->unk_15C[0]), ptr++) { + arg1 = ptr; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2C48.s") + if (arg1->unk_00 == 0) { + continue; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2DB4.s") + if (arg1->unk_00 == 1) { + func_80AF0CDC(globalCtx, arg1); + } else { + func_80AF10D8(globalCtx, arg1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2EC8.s") + if (arg3) { + temp_f22 = arg1->unk_08.x - this->actor.world.pos.x; + temp_f24 = arg1->unk_08.z - this->actor.world.pos.z; + temp_f0 = SQ(temp_f22) + SQ(temp_f24); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2F98.s") + phi_s1 = -10000; + if (temp_f0 > SQ(20.0f)) { + phi_s1 /= ((temp_f0 - SQ(20.0f)) * 0.00125f) + 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF30F4.s") + temp_f26 = (temp_f22 * Math_CosS(phi_s1)) - (Math_SinS(phi_s1) * temp_f24); + temp_f28 = (temp_f22 * Math_SinS(phi_s1)) + (Math_CosS(phi_s1) * temp_f24); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_Update.s") + arg1->unk_08.x = this->actor.world.pos.x + temp_f26; + arg1->unk_08.z = this->actor.world.pos.z + temp_f28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF31D0.s") + temp_f22 = arg1->unk_14; + temp_f24 = arg1->unk_1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_Draw.s") + arg1->unk_14 = (temp_f22 * Math_CosS(phi_s1)) - (Math_SinS(phi_s1) * temp_f24); + arg1->unk_1C = (temp_f22 * Math_SinS(phi_s1)) + (Math_CosS(phi_s1) * temp_f24); + + temp_f22 = arg1->unk_20; + temp_f24 = arg1->unk_28; + + arg1->unk_20 = (temp_f22 * Math_CosS(phi_s1)) - (Math_SinS(phi_s1) * temp_f24); + arg1->unk_28 = (temp_f22 * Math_SinS(phi_s1)) + (Math_CosS(phi_s1) * temp_f24); + } + + if (arg4) { + sp8C.x = arg1->unk_08.x - this->actor.world.pos.x; + sp8C.y = arg1->unk_08.y - (this->actor.world.pos.y + 40.0f); + sp8C.z = arg1->unk_08.z - this->actor.world.pos.z; + + temp_f2 = 1.0f - (0.5f / ((Math3D_Vec3fMagnitude(&sp8C) / 500.0f) + 1.0f)); + + sp8C.x *= temp_f2; + sp8C.y *= temp_f2; + sp8C.z *= temp_f2; + + arg1->unk_08.x = this->actor.world.pos.x + sp8C.x; + arg1->unk_08.y = this->actor.world.pos.y + sp8C.y + 40.0f; + arg1->unk_08.z = this->actor.world.pos.z + sp8C.z; + } + } +} + +void func_80AF14FC(GlobalContext* globalCtx2, EnTest7Struct2* arg1) { + s32 pad[3]; + GlobalContext* globalCtx = globalCtx2; + Mtx* temp_v0; + EnTest7Struct2* ptr; + s32 i; + MtxF sp6C; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C1C0(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + + for (i = 0, ptr = arg1; i < 0x1770; i += 0x3C, ptr++) { + if (ptr->unk_00 == 0) { + continue; + } + + if ((ptr->unk_08.x > 30000.0f) || (ptr->unk_08.x < -30000.0f) || (ptr->unk_08.y > 30000.0f) || + (ptr->unk_08.y < -30000.0f) || (ptr->unk_08.z > 30000.0f) || (ptr->unk_08.z < -30000.0f)) { + ptr->unk_00 = 0; + continue; + } + + Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + + if (ptr->unk_00 == 1) { + Matrix_InsertRotation(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + } else { + SkinMatrix_SetRotateYRP(&sp6C, ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z); + Matrix_InsertMatrix(&sp6C, MTXMODE_APPLY); + } + + Matrix_Scale(ptr->unk_2C, ptr->unk_2C, ptr->unk_2C, MTXMODE_APPLY); + if (ptr->unk_00 == 2) { + Matrix_InsertTranslation(0.0f, 30.0f, 0.0f, MTXMODE_APPLY); + } + + temp_v0 = Matrix_NewMtx(globalCtx->state.gfxCtx); + if (temp_v0 != NULL) { + gSPMatrix(POLY_OPA_DISP++, temp_v0, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_081628); + } + } + + if (ptr) {} + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80AF1730(EnTest7Struct* arg0) { + arg0->unk_00 = 0.0f; + arg0->unk_04 = 0.0f; + arg0->unk_08 = 1.0f; + arg0->unk_0C = 1.0f; + arg0->unk_10 = 0; +} + +void EnTest7_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTest7* this = THIS; + Player* player = GET_PLAYER(globalCtx); + Player* player2 = GET_PLAYER(globalCtx); + + this->actor.world.rot.y = this->actor.shape.rot.y = player->actor.shape.rot.y; + this->unk_144 = 0; + this->unk_1E54 = 0; + this->unk_1E8E = player->actor.shape.rot.y; + this->unk_1E90 = player->actor.scale.x; + this->unk_1E94 = player->actor.scale.z; + + func_80183430(&this->unk_18CC, &gameplay_keep_Blob_085640, &gameplay_keep_Blob_083534, this->unk_18FC, + this->unk_1BA8, 0); + func_801834A8(&this->unk_18CC, &gameplay_keep_Blob_083534); + func_80AF0838(this->unk_15C); + func_80AF1730(&this->unk_148); + + if (ENTEST7_GET(&this->actor) == ENTEST7_MINUS1) { + func_80AF082C(this, func_80AF2938); + EnTest7_SetupAction(this, NULL); + } else { + func_80AF082C(this, func_80AF19A8); + EnTest7_SetupAction(this, func_80AF2854); + func_801A2E54(NA_BGM_SONG_OF_SOARING); + } + + if (globalCtx->playerActorCsIds[8] == -1) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + player2->stateFlags1 |= 0x20; + Lights_PointNoGlowSetInfo(&this->lightInfo, (Math_SinS(this->unk_1E8E) * 90.0f) + player->actor.world.pos.x, + player->actor.world.pos.y + 10.0f, + (Math_CosS(this->unk_1E8E) * 90.0f) + player->actor.world.pos.z, 255, 255, 255, 255); + this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); +} + +void EnTest7_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTest7* this = THIS; + + ActorCutscene_Stop(globalCtx->playerActorCsIds[8]); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); +} + +void func_80AF19A8(EnTest7* this, GlobalContext* globalCtx) { + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + } else { + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + func_80AF082C(this, func_80AF1A2C); + globalCtx->unk_18844 = 1; + } +} + +void func_80AF1A2C(EnTest7* this, GlobalContext* globalCtx) { + Color_RGB8 sp34 = { 64, 0, 0 }; + Color_RGB8 sp30 = { 220, 220, 255 }; + f32 sp2C = this->unk_1E54 / 10.0f; + + func_800FD59C(globalCtx, &sp30, sp2C); + func_800FD654(globalCtx, &sp34, sp2C); + func_800FD698(globalCtx, 2000, 4000, sp2C); + + if (this->unk_1E54 >= 10) { + Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + this->unk_1E60 = camera->eye; + this->unk_1E6C = camera->at; + this->unk_1E78 = camera->fov; + + func_80AF082C(this, func_80AF1CA0); + this->unk_144 |= 0x20; + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_OPEN); + func_8016566C(0x78); + } +} + +void func_80AF1B68(EnTest7* this, GlobalContext* globalCtx) { + this->unk_144 |= 2; + + if (this->unk_148.unk_04 < 11.0f) { + this->unk_148.unk_04 = this->unk_148.unk_04 + 0.3f; + this->unk_148.unk_08 = ((this->unk_148.unk_00 * -0.45f) / 11.0f) + 0.7f; + this->unk_148.unk_0C = ((this->unk_148.unk_00 * -0.29999998f) / 11.0f) + 0.7f; + } + + if (this->unk_148.unk_00 < 11.0f) { + this->unk_148.unk_00 += 1.0f; + if (this->unk_148.unk_00 > 6.0f) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_144 &= ~1; + player->actor.draw = NULL; + } + } else if (this->unk_1E54 >= 87) { + func_80AF082C(this, func_80AF1F48); + this->unk_144 &= -9; + this->unk_148.unk_10 -= 0x2EE0; + } else { + this->unk_148.unk_10 -= 0x2EE0; + } +} + +void func_80AF1CA0(EnTest7* this, GlobalContext* globalCtx) { + Vec3f sp34; + + if (func_80183DE0(&this->unk_18CC)) { + func_80AF082C(this, func_80AF1E44); + } + + if (this->unk_18CC.frameCtrl.unk_10 > 60.0f) { + func_80AF1B68(this, globalCtx); + } + + if ((this->unk_18CC.frameCtrl.unk_10 > 20.0f) && !(this->unk_144 & 0x40)) { + this->unk_144 |= 0x40; + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_CLOSE); + } + + if (this->unk_18CC.frameCtrl.unk_10 > 42.0f) { + if (!(this->unk_144 & 0x80)) { + this->unk_144 |= 0x80; + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_ROLL); + } + + if (Rand_ZeroOne() < 0.3f) { + Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + f32 rand = Rand_ZeroOne(); + + sp34.x = ((camera->eye.x - this->actor.world.pos.x) * rand) + this->actor.world.pos.x; + sp34.y = ((camera->eye.y - this->actor.world.pos.y) * rand) + this->actor.world.pos.y; + sp34.z = ((camera->eye.z - this->actor.world.pos.z) * rand) + this->actor.world.pos.z; + + func_80AF0C30(this->unk_15C, &sp34, 1); + this->unk_144 |= 8; + } + } else { + this->unk_144 |= 1; + } +} + +void func_80AF1E44(EnTest7* this, GlobalContext* globalCtx) { + Vec3f sp34; + Camera* camera; + f32 rand; + + func_80AF1B68(this, globalCtx); + + if (Rand_ZeroOne() < 0.3f) { + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + rand = Rand_ZeroOne(); + sp34.x = ((camera->eye.x - this->actor.world.pos.x) * rand) + this->actor.world.pos.x; + sp34.y = ((camera->eye.y - this->actor.world.pos.y) * rand) + this->actor.world.pos.y; + sp34.z = ((camera->eye.z - this->actor.world.pos.z) * rand) + this->actor.world.pos.z; + func_80AF0C30(this->unk_15C, &sp34, 1); + } + + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + func_80AF0C30(this->unk_15C, &sp34, 1); + this->unk_18FC[1].y += 0x2EE0; +} + +void func_80AF1F48(EnTest7* this, GlobalContext* globalCtx) { + s32 pad; + s32 temp = this->unk_1E54 - 86; + f32 temp_f0 = temp / 10.0f; + Vec3f sp20; + + this->unk_144 |= 0x10; + + this->unk_148.unk_08 = (-0.15f * temp_f0) + 0.25f; + this->unk_148.unk_0C = (-0.3f * temp_f0) + 0.4f; + this->unk_148.unk_10 -= 0x2EE0; + + this->unk_144 |= 4; + + if (this->unk_1E54 >= 96) { + func_80AF082C(this, func_80AF2030); + this->unk_144 &= ~0x10; + } + Math_Vec3f_Copy(&sp20, &this->actor.world.pos); + func_80AF0C30(this->unk_15C, &sp20, 1); +} + +void func_80AF2030(EnTest7* this, GlobalContext* globalCtx) { + s32 temp = this->unk_1E54 - 96; + f32 four = 4; + f32 sp1C = 1.0f - (temp / four); + Camera* camera; + f32 temp_f2; + f32 temp_f4; + + this->unk_148.unk_08 = ((temp * -0.1f) / four) + 0.1f; + this->unk_148.unk_0C = ((temp * 5.9f) / four) + 0.1f; + this->unk_148.unk_10 -= 0x2EE0; + this->actor.world.pos.y += 100.0f; + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + camera->player = NULL; + + camera->eye.x = ((camera->eye.x - this->unk_1E60.x) * sp1C) + this->unk_1E60.x; + camera->eye.y = ((camera->eye.y - this->unk_1E60.y) * sp1C) + this->unk_1E60.y; + camera->eye.z = ((camera->eye.z - this->unk_1E60.z) * sp1C) + this->unk_1E60.z; + camera->fov = ((camera->fov - this->unk_1E78) * sp1C) + this->unk_1E78; + + if (this->unk_1E54 >= 100) { + MREG(64) = 1; + MREG(65) = 255; + MREG(66) = 255; + MREG(67) = 255; + MREG(68) = 255; + globalCtx->unk_18844 = 0; + this->unk_144 &= ~4; + func_80AF082C(this, func_80AF21E8); + func_80165690(); + } +} + +void func_80AF21E8(EnTest7* this, GlobalContext* globalCtx) { + s32 sp2C = this->unk_1E54 - 100; + f32 sp1C; + Color_RGB8 sp24 = { 64, 0, 0 }; + Color_RGB8 sp20 = { 220, 220, 255 }; + + if (MREG(64) != 0) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_VANISH); + MREG(64) = 0; + MREG(65) = 0; + MREG(66) = 0; + MREG(67) = 0; + MREG(68) = 0; + } + + sp1C = 1.0f - (sp2C / 10.0f); + func_800FD59C(globalCtx, &sp20, sp1C); + func_800FD654(globalCtx, &sp24, sp1C); + func_800FD698(globalCtx, 2000, 4000, sp1C); + + if (this->unk_1E54 >= 110) { + func_80AF082C(this, func_80AF2318); + } +} + +void func_80AF2318(EnTest7* this, GlobalContext* globalCtx) { + if (this->unk_1E54 >= 130) { + func_80AF082C(this, func_80AF2350); + } +} + +u16 D_80AF343C[] = { + 0x68B0, 0x6A60, 0xB230, 0x9A80, 0xD890, 0x3E40, 0x8640, 0x84A0, 0x2040, 0xAA30, +}; + +void func_80AF2350(EnTest7* this, GlobalContext* globalCtx) { + Vec3f sp2C; + + if (this) {} + + Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); + + if (Rand_ZeroOne() < 0.1f) { + func_80AF0C30(this->unk_15C, &sp2C, 1); + } + + this->unk_148.unk_10 -= 0x2EE0; + + if (globalCtx->sceneNum == SCENE_SECOM) { + globalCtx->nextEntranceIndex = 0x2060; + } else if (ENTEST7_GET(&this->actor) == ENTEST7_26) { + func_80169F78(&globalCtx->state); + gSaveContext.respawn[2].playerParams = (gSaveContext.respawn[2].playerParams & 0xFF) | 0x600; + gSaveContext.respawnFlag = -6; + } else { + globalCtx->nextEntranceIndex = D_80AF343C[ENTEST7_GET(&this->actor) - ENTEST7_1C]; + if ((globalCtx->nextEntranceIndex == 0x84A0) && (gSaveContext.save.weekEventReg[20] & 2)) { + globalCtx->nextEntranceIndex = 0xCA0; + } else if ((globalCtx->nextEntranceIndex == 0x9A80) && (gSaveContext.save.weekEventReg[33] & 0x80)) { + globalCtx->nextEntranceIndex = 0xAE80; + } + } + + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 2; + gSaveContext.seqIndex = 0xFF; + gSaveContext.nightSeqIndex = 0xFF; +} + +void func_80AF24D8(EnTest7* this, GlobalContext* globalCtx, f32 arg2) { + Vec3f sp3C; + Vec3f* pos; + Player* player = GET_PLAYER(globalCtx); + Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + pos = &player->actor.world.pos; + camera->player = NULL; + + sp3C.x = ((180.0f * Math_SinS(this->unk_1E8E)) * Math_CosS(0xFA0)) + pos->x; + sp3C.y = (Math_SinS(0xFA0) * 180.0f) + pos->y; + sp3C.z = ((180.0f * Math_CosS(this->unk_1E8E)) * Math_CosS(0xFA0)) + pos->z; + + camera->eye.x = ((sp3C.x - camera->eye.x) * arg2) + camera->eye.x; + camera->eye.y = ((sp3C.y - camera->eye.y) * arg2) + camera->eye.y; + camera->eye.z = ((sp3C.z - camera->eye.z) * arg2) + camera->eye.z; + + camera->fov = ((this->unk_1E78 - camera->fov) * arg2) + camera->fov; + camera->at.y += 1.4444444f; +} + +void func_80AF2654(EnTest7* this, GlobalContext* globalCtx, f32 arg2) { + Vec3f* pos; + Player* player = GET_PLAYER(globalCtx); + Camera* camera; + Vec3f sp30; + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + camera->player = NULL; + + pos = &player->actor.world.pos; + + sp30.x = ((80.0f * Math_SinS(this->unk_1E8E)) * Math_CosS(0xBB8)) + pos->x; + sp30.y = (Math_SinS(0xBB8) * 80.0f) + pos->y; + sp30.z = ((80.0f * Math_CosS(this->unk_1E8E)) * Math_CosS(0xBB8)) + pos->z; + + camera->eye.x = ((sp30.x - camera->eye.x) * arg2) + camera->eye.x; + camera->eye.y = ((sp30.y - camera->eye.y) * arg2) + camera->eye.y; + camera->eye.z = ((sp30.z - camera->eye.z) * arg2) + camera->eye.z; + + camera->at.x = ((pos->x - camera->at.x) * arg2) + camera->at.x; + camera->at.y = (((pos->y + 40.0f) - camera->at.y) * arg2) + camera->at.y; + camera->at.z = ((pos->z - camera->at.z) * arg2) + camera->at.z; + + camera->fov = ((this->unk_1E78 - camera->fov) * arg2) + camera->fov; +} + +void func_80AF2808(EnTest7* this, GlobalContext* globalCtx, f32 arg2) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.shape.rot.y += 0x2EE0; + player->actor.scale.x = ((0.0f - this->unk_1E90) * arg2) + this->unk_1E90; + player->actor.scale.z = ((0.0f - this->unk_1E94) * arg2) + this->unk_1E94; +} + +void func_80AF2854(EnTest7* this, GlobalContext* globalCtx) { + f32 temp; + f32 sixteen = 16.0f; + + if ((this->unk_1E54 >= 12) && (this->unk_1E54 < 31)) { + temp = (this->unk_1E54 - 12) / 18.0f; + func_80AF24D8(this, globalCtx, temp); + } else if ((this->unk_1E54 >= 79) && (this->unk_1E54 < 96)) { + temp = (this->unk_1E54 - 79) / sixteen; + func_80AF2654(this, globalCtx, temp); + } + + if ((this->unk_1E54 >= 42) && (this->unk_1E54 < 69)) { + temp = (this->unk_1E54 - 42) / 26.0f; + func_80AF2808(this, globalCtx, temp); + } +} + +void func_80AF2938(EnTest7* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_1E98 = player->actor.draw; + player->actor.draw = NULL; + player->stateFlags2 |= 0x20000000; + this->unk_144 |= 2; + this->unk_148.unk_04 = 30.0f; + if (globalCtx->roomCtx.currRoom.unk3 != 1) { + func_80AF082C(this, func_80AF2AE8); + } else { + func_80AF082C(this, func_80AF2EC8); + } +} + +s16 D_80AF3450[] = { 0, 0x31C7 }; + +f32 D_80AF3454 = 3500.0f; + +void func_80AF29C0(EnTest7* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + Vec3f* pos = &player->actor.world.pos; + Camera* temp_s0 = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + temp_s0->at.x = ((D_80AF3454 * Math_SinS(D_80AF3450[0]) * Math_CosS(D_80AF3450[1]))) + pos->x; + temp_s0->at.y = (Math_SinS(D_80AF3450[1]) * D_80AF3454) + pos->y; + temp_s0->at.z = ((D_80AF3454 * Math_CosS(D_80AF3450[0])) * Math_CosS(D_80AF3450[1])) + pos->z; + + this->actor.world.pos.x = temp_s0->at.x; + this->actor.world.pos.y = temp_s0->at.y - 40.0f; + this->actor.world.pos.z = temp_s0->at.z; +} + +void func_80AF2AE8(EnTest7* this, GlobalContext* globalCtx) { + Camera* camera; + + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + return; + } + + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + func_80AF082C(this, func_80AF2C48); + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + this->unk_1E60 = camera->eye; + this->unk_1E6C = camera->at; + + func_80AF29C0(this, globalCtx); +} + +void func_80AF2BAC(EnTest7* this, GlobalContext* globalCtx, Vec3f* arg2, f32 arg3) { + f32 x; + f32 y; + f32 z; + Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + camera->player = NULL; + x = ((camera->at.x - arg2->x) * arg3) + arg2->x; + y = ((camera->at.y - arg2->y) * arg3) + arg2->y; + z = ((camera->at.z - arg2->z) * arg3) + arg2->z; + + camera->at.x = x; + camera->at.y = y; + camera->at.z = z; +} + +void func_80AF2C48(EnTest7* this, GlobalContext* globalCtx) { + f32 sp24 = (40 - this->unk_1E54) / 40.0f; + Camera* camera; + + this->unk_148.unk_00 = 11.0f; + this->unk_144 |= 4; + this->unk_148.unk_08 = 0.05f; + this->unk_148.unk_0C = 0.05f; + this->unk_148.unk_10 += 0x2EE0; + + this->actor.world.pos.x = ((this->actor.world.pos.x - this->actor.home.pos.x) * sp24) + this->actor.home.pos.x; + this->actor.world.pos.y = ((this->actor.world.pos.y - this->actor.home.pos.y) * sp24) + this->actor.home.pos.y; + this->actor.world.pos.z = ((this->actor.world.pos.z - this->actor.home.pos.z) * sp24) + this->actor.home.pos.z; + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + func_80AF2BAC(this, globalCtx, &this->actor.home.pos, sp24); + + camera->at.x = this->actor.world.pos.x; + camera->at.y = this->actor.world.pos.y + 40.0f; + camera->at.z = this->actor.world.pos.z; + + func_800B9010(&this->actor, NA_SE_PL_WARP_WING_ROLL_2 - SFX_FLAG); + if (this->unk_1E54 >= 40) { + this->unk_144 &= ~4; + func_80AF082C(this, func_80AF2F98); + } +} + +void func_80AF2DB4(EnTest7* this, GlobalContext* globalCtx) { + Camera* camera; + Player* player = GET_PLAYER(globalCtx); + Vec3f* pos = &player->actor.world.pos; + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + camera->eye.x = (Math_SinS(-player->actor.shape.rot.y) * 200.0f * -0.83907f) + pos->x; + camera->eye.y = pos->y + 108.8042f; + camera->eye.z = (Math_CosS(-player->actor.shape.rot.y) * 200.0f * -0.83907f) + pos->z; + + camera->at.x = pos->x; + camera->at.y = pos->y + 40.0f; + camera->at.z = pos->z; +} + +void func_80AF2EC8(EnTest7* this, GlobalContext* globalCtx) { + Camera* camera; + + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + } else { + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + func_80AF082C(this, func_80AF2F98); + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + this->unk_1E60 = camera->eye; + this->unk_1E6C = camera->at; + this->unk_1E54 = 40; + + func_80AF2DB4(this, globalCtx); + } +} + +void func_80AF2F98(EnTest7* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Player* player2 = GET_PLAYER(globalCtx); + Vec3f sp2C; + + func_800B9010(&this->actor, NA_SE_PL_WARP_WING_ROLL_2 - SFX_FLAG); + + sp2C = this->actor.world.pos; + + func_80AF0C30(this->unk_15C, &sp2C, 1); + func_80AF0C30(this->unk_15C, &sp2C, 1); + this->unk_148.unk_04 = 70 - this->unk_1E54; + if (this->unk_1E54 > 70) { + func_80AF082C(this, func_80AF30F4); + } + + if (this->unk_148.unk_04 > 11.0f) { + f32 temp = this->unk_148.unk_04 - 11.0f; + + this->unk_148.unk_08 = ((-0.35f * temp) / 19.0f) + 0.4f; + this->unk_148.unk_0C = ((-0.35f * temp) / 19.0f) + 0.4f; + this->unk_148.unk_10 += 0x2EE0; + } else { + player2->actor.draw = this->unk_1E98; + this->unk_148.unk_00 = this->unk_148.unk_04; + this->unk_148.unk_08 = ((this->unk_148.unk_04 * -0.29999998f) / 11.0f) + 0.7f; + this->unk_148.unk_0C = ((this->unk_148.unk_04 * -0.29999998f) / 11.0f) + 0.7f; + player->stateFlags2 &= ~0x20000000; + } +} + +void func_80AF30F4(EnTest7* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_1E54 > 90) { + player->stateFlags1 &= ~0x20; + player->stateFlags1 &= ~0x20000000; + Actor_MarkForDeath(&this->actor); + } +} + +void EnTest7_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTest7* this = THIS; + + this->unk_1E58(this, globalCtx); + + if (this->actionFunc != NULL) { + this->actionFunc(this, globalCtx); + } + + this->unk_1E54++; + + func_80AF118C(globalCtx, this->unk_15C, this, (this->unk_144 & 8) != 0, (this->unk_144 & 0x10) != 0); +} + +s32 func_80AF31D0(GlobalContext* globalCtx, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList, u8* flags, + Actor* thisx, Vec3f* scale, Vec3s* rot, Vec3f* pos) { + EnTest7* this = THIS; + Vec3f sp18; + + if ((*dList != NULL) && (Rand_ZeroOne() < 0.03f)) { + Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp18); + func_80AF0C30(this->unk_15C, &sp18, 0); + } + return true; +} + +void EnTest7_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + EnTest7* this = THIS; + s32 sp40; + + if (this->unk_144 & 1) { + Mtx* mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * this->unk_18CC.unk_18->unk_1)); + + if (mtx != NULL) { + func_8018450C(globalCtx, &this->unk_18CC, mtx, func_80AF31D0, NULL, &this->actor); + } else { + return; + } + } + + if (this->unk_144 & 2) { + Matrix_StatePush(); + Matrix_InsertTranslation(0.0f, 4000.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertRotation(0, this->unk_148.unk_10, 0, MTXMODE_APPLY); + Matrix_Scale(this->unk_148.unk_08 * 100.0f, this->unk_148.unk_0C * 100.0f, this->unk_148.unk_08 * 100.0f, + MTXMODE_APPLY); + sp40 = this->unk_148.unk_00; + AnimatedMat_DrawStep(globalCtx, Lib_SegmentedToVirtual(&gameplay_keep_Matanimheader_0815D0), sp40); + Gfx_DrawDListXlu(globalCtx, gameplay_keep_DL_080FC8); + Matrix_StatePop(); + } + + func_80AF14FC(globalCtx, this->unk_15C); + + if (this->unk_144 & 4) { + func_800F9824(globalCtx, &globalCtx->envCtx, &globalCtx->view, globalCtx->state.gfxCtx, this->actor.world.pos, + 70.0f, 5.0f, 0, 0); + } +} diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.h b/src/overlays/actors/ovl_En_Test7/z_en_test7.h index 0973b4245..a074c7875 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.h +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.h @@ -6,12 +6,60 @@ struct EnTest7; typedef void (*EnTest7ActionFunc)(struct EnTest7*, GlobalContext*); +typedef void (*EnTest7UnkFunc)(struct EnTest7*, GlobalContext*); +typedef void (*EnTest7UnkDrawFunc)(Actor*, GlobalContext*); + +#define ENTEST7_GET(thisx) ((thisx)->params) + +#define ENTEST7_MINUS1 -1 +#define ENTEST7_26 0x26 +#define ENTEST7_1C 0x1C + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ s16 unk_10; +} EnTest7Struct; // size >= 0x14 + +typedef struct { + /* 0x00 */ s32 unk_00; + /* 0x04 */ s32 unk_04; + /* 0x08 */ Vec3f unk_08; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ f32 unk_20; + /* 0x24 */ f32 unk_24; + /* 0x28 */ f32 unk_28; + /* 0x2C */ f32 unk_2C; + /* 0x30 */ Vec3s unk_30; + /* 0x36 */ s16 unk_36; + /* 0x38 */ s16 unk_38; + /* 0x3A */ s16 unk_3A; +} EnTest7Struct2; // size = 0x3C typedef struct EnTest7 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1D18]; + /* 0x0144 */ s32 unk_144; + /* 0x0148 */ EnTest7Struct unk_148; + /* 0x015C */ EnTest7Struct2 unk_15C[100]; + /* 0x18CC */ SkeletonInfo unk_18CC; + /* 0x18FC */ Vec3s unk_18FC[114]; + /* 0x1BA8 */ s16 unk_1BA8[342]; + /* 0x1E54 */ s32 unk_1E54; + /* 0x1E58 */ EnTest7UnkFunc unk_1E58; /* 0x1E5C */ EnTest7ActionFunc actionFunc; - /* 0x1E60 */ char unk_1E60[0x3C]; + /* 0x1E60 */ Vec3f unk_1E60; + /* 0x1E6C */ Vec3f unk_1E6C; + /* 0x1E78 */ f32 unk_1E78; + /* 0x1E7C */ LightNode* lightNode; + /* 0x1E80 */ LightInfo lightInfo; + /* 0x1E8E */ s16 unk_1E8E; + /* 0x1E90 */ f32 unk_1E90; + /* 0x1E94 */ f32 unk_1E94; + /* 0x1E98 */ EnTest7UnkDrawFunc unk_1E98; } EnTest7; // size = 0x1E9C extern const ActorInit En_Test7_InitVars; diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 5e1be9b2a..63a7f9a74 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -13473,10 +13473,9 @@ 0x80AF34F4:("D_80AF34F4","f32","",0x4), 0x80AF34F8:("D_80AF34F8","f32","",0x4), 0x80AF38B0:("D_80AF38B0","UNK_TYPE1","",0x1), - 0x80AF38F0:("D_80AF38F0","f32","",0x4), - 0x80AF38F4:("D_80AF38F4","f32","",0x4), - 0x80AF38F8:("D_80AF38F8","f32","",0x4), - 0x80AF3900:("D_80AF3900","UNK_TYPE1","",0x1), + 0x80AF38F0:("D_80AF38F0","Vec3f","",0xC), + 0x80AF38FC:("D_80AF38FC","UNK_TYPE4","",0x4), + 0x80AF3900:("D_80AF3900","Vec3f","",0xC), 0x80AF3E80:("Obj_Lightblock_InitVars","UNK_TYPE1","",0x1), 0x80AF3EA0:("D_80AF3EA0","UNK_TYPE1","",0x1), 0x80AF3ECC:("D_80AF3ECC","UNK_TYPE1","",0x1), From 84d9efda92ea523b9e6a917674bcf57fff404ef3 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Tue, 29 Mar 2022 12:13:24 -0300 Subject: [PATCH 143/257] ZAPD update: Cutscene extraction (#770) * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "89a0b2628" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "89a0b2628" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "efae567d3" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "efae567d3" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" --- tools/ZAPD/.gitrepo | 4 +- .../ZAPD/OtherStructs/CutsceneMM_Commands.cpp | 208 +++ .../ZAPD/OtherStructs/CutsceneMM_Commands.h | 140 ++ .../ZAPD/OtherStructs/Cutscene_Commands.cpp | 591 ++++++++ .../ZAPD/OtherStructs/Cutscene_Commands.h | 267 ++++ tools/ZAPD/ZAPD/ZCutscene.cpp | 1211 +++-------------- tools/ZAPD/ZAPD/ZCutscene.h | 426 +----- tools/ZAPD/ZAPD/ZCutsceneMM.cpp | 61 - tools/ZAPD/ZAPD/ZCutsceneMM.h | 29 - tools/ZAPD/ZAPD/ZFile.cpp | 6 +- tools/ZAPD/ZAPD/ZFile.h | 6 +- .../ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp | 98 +- tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h | 6 +- .../ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp | 5 +- tools/ZAPD/ZAPD/ZSkeleton.cpp | 4 +- tools/ZAPD/ZAPDUtils/Utils/BitConverter.h | 1 + 16 files changed, 1463 insertions(+), 1600 deletions(-) create mode 100644 tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp create mode 100644 tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.h create mode 100644 tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp create mode 100644 tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.h delete mode 100644 tools/ZAPD/ZAPD/ZCutsceneMM.cpp delete mode 100644 tools/ZAPD/ZAPD/ZCutsceneMM.h diff --git a/tools/ZAPD/.gitrepo b/tools/ZAPD/.gitrepo index 475415d99..5d67a3762 100644 --- a/tools/ZAPD/.gitrepo +++ b/tools/ZAPD/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/zeldaret/ZAPD.git branch = master - commit = 119a6883e6f795815744b9afd6a79084c619ddb6 - parent = 66a66f61b6368af0ed711803c54a963494329217 + commit = efae567d3917afa341bd843ba185b3bd66d57429 + parent = 22c6551083172f5c506aecf8c31ad761afbbd658 method = merge cmdver = 0.4.3 diff --git a/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp new file mode 100644 index 000000000..b69f47321 --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp @@ -0,0 +1,208 @@ +#include "CutsceneMM_Commands.h" + +#include +#include + +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +// Specific for command lists where each entry has size 8 bytes +const std::unordered_map csCommandsDescMM = { + {CutsceneMMCommands::CS_CMD_MISC, {"CS_MISC", "(0x%02X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_SET_LIGHTING, {"CS_LIGHTING", "(0x%02X, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_SCENE_TRANS_FX, {"CS_SCENE_TRANS_FX", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_MOTIONBLUR, {"CS_MOTIONBLUR", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_GIVETATL, {"CS_GIVETATL", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_PLAYSEQ, {"CS_PLAYSEQ", "(0x%04X, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_130, {"CS_SCENE_UNK_130", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_131, {"CS_SCENE_UNK_131", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_132, {"CS_SCENE_UNK_132", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_STOPSEQ, {"CS_STOPSEQ", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_PLAYAMBIENCE, {"CS_PLAYAMBIENCE", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_FADEAMBIENCE, {"CS_FADEAMBIENCE", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_TERMINATOR, {"CS_TERMINATOR", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_CHOOSE_CREDITS_SCENES, + {"CS_CHOOSE_CREDITS_SCENES", "(%i, %i, %i)"}}, +}; + +CutsceneSubCommandEntry_GenericMMCmd::CutsceneSubCommandEntry_GenericMMCmd( + const std::vector& rawData, offset_t rawDataIndex, CutsceneMMCommands cmdId) + : CutsceneSubCommandEntry(rawData, rawDataIndex), commandId(cmdId) +{ +} + +std::string CutsceneSubCommandEntry_GenericMMCmd::GetBodySourceCode() const +{ + const auto& element = csCommandsDescMM.find(commandId); + std::string entryFmt = "CS_UNK_DATA(0x%02X, %i, %i, %i)"; + + if (element != csCommandsDescMM.end()) + { + entryFmt = element->second.cmdMacro; + entryFmt += element->second.args; + } + + return StringHelper::Sprintf(entryFmt.c_str(), base, startFrame, endFrame, pad); +} + +CutsceneMMCommand_GenericCmd::CutsceneMMCommand_GenericCmd(const std::vector& rawData, + offset_t rawDataIndex, + CutsceneMMCommands cmdId) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + commandID = static_cast(cmdId); + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_GenericMMCmd(rawData, rawDataIndex, cmdId); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_GenericCmd::GetCommandMacro() const +{ + const auto& element = csCommandsDescMM.find(static_cast(commandID)); + + if (element != csCommandsDescMM.end()) + { + return StringHelper::Sprintf("%s_LIST(%i)", element->second.cmdMacro, numEntries); + } + + return StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%X, %i)", commandID, numEntries); +} + +CutsceneSubCommandEntry_Camera::CutsceneSubCommandEntry_Camera(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ +} + +std::string CutsceneSubCommandEntry_Camera::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CMD_HH(0x%04X, 0x%04X)", base, startFrame); +} + +size_t CutsceneSubCommandEntry_Camera::GetRawSize() const +{ + return 0x04; +} + +CutsceneMMCommand_Camera::CutsceneMMCommand_Camera(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries / 4; i++) + { + auto* entry = new CutsceneSubCommandEntry_Camera(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_Camera::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_CAMERA_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_FadeScreen::CutsceneSubCommandEntry_FadeScreen( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + unk_06 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x06); + unk_07 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x07); + unk_08 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); + unk_09 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x09); + unk_0A = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0A); + unk_0B = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0B); +} + +std::string CutsceneSubCommandEntry_FadeScreen::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CS_FADESCREEN(0x%02X, %i, %i, %i, %i, %i)", base, startFrame, + endFrame, unk_06, unk_07, unk_08); +} + +size_t CutsceneSubCommandEntry_FadeScreen::GetRawSize() const +{ + return 0x0C; +} + +CutsceneMMCommand_FadeScreen::CutsceneMMCommand_FadeScreen(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_FadeScreen(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_FadeScreen::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_FADESCREEN_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_FadeSeq::CutsceneSubCommandEntry_FadeSeq( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + unk_08 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); +} + +std::string CutsceneSubCommandEntry_FadeSeq::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CS_FADESEQ(%i, %i, %i)", base, startFrame, endFrame); +} + +size_t CutsceneSubCommandEntry_FadeSeq::GetRawSize() const +{ + return 0x0C; +} + +CutsceneMMCommand_FadeSeq::CutsceneMMCommand_FadeSeq(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_FadeSeq(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_FadeSeq::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_FADESEQ_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_NonImplemented::CutsceneSubCommandEntry_NonImplemented( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ +} + +CutsceneMMCommand_NonImplemented::CutsceneMMCommand_NonImplemented( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_NonImplemented(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} diff --git a/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.h b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.h new file mode 100644 index 000000000..c8ae4eb60 --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.h @@ -0,0 +1,140 @@ +#pragma once + +#include "Cutscene_Commands.h" + +enum class CutsceneMMCommands +{ + /* 0x00A */ CS_CMD_TEXTBOX = 0xA, + /* 0x05A */ CS_CMD_CAMERA = 0x5A, + /* 0x096 */ CS_CMD_MISC = 0x96, + /* 0x097 */ CS_CMD_SET_LIGHTING, + /* 0x098 */ CS_CMD_SCENE_TRANS_FX, + /* 0x099 */ CS_CMD_MOTIONBLUR, + /* 0x09A */ CS_CMD_GIVETATL, + /* 0x09B */ CS_CMD_FADESCREEN, + /* 0x09C */ CS_CMD_FADESEQ, + /* 0x09D */ CS_CMD_SETTIME, + /* 0x0C8 */ CS_CMD_SET_PLAYER_ACTION = 0xC8, + /* 0x0FA */ CS_CMD_UNK_FA = 0xFA, + /* 0x0FE */ CS_CMD_UNK_FE = 0xFE, + /* 0x0FF */ CS_CMD_UNK_FF, + /* 0x100 */ CS_CMD_UNK_100, + /* 0x101 */ CS_CMD_UNK_101, + /* 0x102 */ CS_CMD_UNK_102, + /* 0x103 */ CS_CMD_UNK_103, + /* 0x104 */ CS_CMD_UNK_104, + /* 0x105 */ CS_CMD_UNK_105, + /* 0x108 */ CS_CMD_UNK_108 = 0x108, + /* 0x109 */ CS_CMD_UNK_109, + /* 0x12C */ CS_CMD_PLAYSEQ = 0x12C, + /* 0x12D */ CS_CMD_UNK_12D, + /* 0x130 */ CS_CMD_130 = 0x130, + /* 0x131 */ CS_CMD_131 = 0x131, + /* 0x132 */ CS_CMD_132 = 0x132, + /* 0x133 */ CS_CMD_STOPSEQ, + /* 0x134 */ CS_CMD_PLAYAMBIENCE, + /* 0x135 */ CS_CMD_FADEAMBIENCE, + /* 0x15E */ CS_CMD_TERMINATOR = 0x15E, + /* 0x15F */ CS_CMD_CHOOSE_CREDITS_SCENES, + /* 0x190 */ CS_CMD_RUMBLE = 0x190, +}; + +class CutsceneSubCommandEntry_GenericMMCmd : public CutsceneSubCommandEntry +{ +public: + CutsceneMMCommands commandId; + + CutsceneSubCommandEntry_GenericMMCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneMMCommands cmdId); + + std::string GetBodySourceCode() const override; +}; + +class CutsceneMMCommand_GenericCmd : public CutsceneCommand +{ +public: + CutsceneMMCommand_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneMMCommands cmdId); + + std::string GetCommandMacro() const override; +}; + +// TODO: MM cutscene camera command is implemented as a placeholder until we better understand how +// it works +class CutsceneSubCommandEntry_Camera : public CutsceneSubCommandEntry +{ +public: + uint32_t unk_08; + + CutsceneSubCommandEntry_Camera(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_Camera : public CutsceneCommand +{ +public: + CutsceneMMCommand_Camera(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_FadeScreen : public CutsceneSubCommandEntry +{ +public: + uint8_t unk_06; + uint8_t unk_07; + uint8_t unk_08; + uint8_t unk_09; + uint8_t unk_0A; + uint8_t unk_0B; + + CutsceneSubCommandEntry_FadeScreen(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_FadeScreen : public CutsceneCommand +{ +public: + CutsceneMMCommand_FadeScreen(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_FadeSeq : public CutsceneSubCommandEntry +{ +public: + uint32_t unk_08; + + CutsceneSubCommandEntry_FadeSeq(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_FadeSeq : public CutsceneCommand +{ +public: + CutsceneMMCommand_FadeSeq(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_NonImplemented : public CutsceneSubCommandEntry +{ +public: + CutsceneSubCommandEntry_NonImplemented(const std::vector& rawData, + offset_t rawDataIndex); +}; + +class CutsceneMMCommand_NonImplemented : public CutsceneCommand +{ +public: + CutsceneMMCommand_NonImplemented(const std::vector& rawData, offset_t rawDataIndex); +}; diff --git a/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp new file mode 100644 index 000000000..a716176b9 --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp @@ -0,0 +1,591 @@ +#include "Cutscene_Commands.h" + +#include +#include + +#include "CutsceneMM_Commands.h" +#include "Globals.h" +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +/* CutsceneSubCommandEntry */ + +CutsceneSubCommandEntry::CutsceneSubCommandEntry(const std::vector& rawData, + offset_t rawDataIndex) +{ + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + pad = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); +} + +std::string CutsceneSubCommandEntry::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CMD_HH(0x%04X, 0x%04X), CMD_HH(0x%04X, 0x%04X)", base, startFrame, + endFrame, pad); +} + +size_t CutsceneSubCommandEntry::GetRawSize() const +{ + return 0x08; +} + +/* CutsceneCommand */ + +CutsceneCommand::CutsceneCommand(const std::vector& rawData, offset_t rawDataIndex) +{ + numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); +} + +CutsceneCommand::~CutsceneCommand() +{ + for (auto& entry : entries) + { + delete entry; + } +} + +std::string CutsceneCommand::GetCommandMacro() const +{ + return StringHelper::Sprintf("CMD_W(0x%08X), CMD_W(0x%08X)", commandID, numEntries); +} + +std::string CutsceneCommand::GenerateSourceCode() const +{ + std::string result; + + result += GetCommandMacro(); + result += ",\n"; + + for (auto& entry : entries) + { + result += " "; + result += entry->GetBodySourceCode(); + result += ",\n"; + } + + return result; +} + +size_t CutsceneCommand::GetCommandSize() const +{ + size_t size = 0; + if (entries.size() > 0) + { + size = entries.at(0)->GetRawSize() * entries.size(); + } + else + { + size = 0x08 * numEntries; + } + return 0x08 + size; +} + +void CutsceneCommand::SetCommandID(uint32_t nCommandID) +{ + commandID = nCommandID; + + for (auto& entry : entries) + { + entry->commandID = commandID; + } +} + +// Specific for command lists where each entry has size 0x30 bytes +const std::unordered_map csCommandsDesc = { + {CutsceneCommands::Misc, + {"CS_MISC", "(0x%04X, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::SetLighting, + {"CS_LIGHTING", "(0x%02X, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::PlayBGM, {"CS_PLAY_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::StopBGM, {"CS_STOP_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::FadeBGM, {"CS_FADE_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, +}; + +CutsceneSubCommandEntry_GenericCmd::CutsceneSubCommandEntry_GenericCmd( + const std::vector& rawData, offset_t rawDataIndex, CutsceneCommands cmdId) + : CutsceneSubCommandEntry(rawData, rawDataIndex), commandId(cmdId) +{ + word0 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x0); + word1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x4); + + unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x8); + unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0xC); + unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x10); + unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x14); + unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x18); + unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x1C); + unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x20); + unused8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x24); + unused9 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x28); + unused10 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x2C); +} + +std::string CutsceneSubCommandEntry_GenericCmd::GetBodySourceCode() const +{ + const auto& element = csCommandsDesc.find(commandId); + + if (element != csCommandsDesc.end()) + { + std::string entryFmt = element->second.cmdMacro; + entryFmt += element->second.args; + + return StringHelper::Sprintf(entryFmt.c_str(), base, startFrame, endFrame, pad, unused1, + unused2, unused3, unused4, unused5, unused6, unused7, unused8, + unused9, unused10); + } + + return StringHelper::Sprintf("CS_UNK_DATA(0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, " + "0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X)", + word0, word1, unused1, unused2, unused3, unused4, unused5, unused6, + unused7, unused8, unused9, unused10); +} + +size_t CutsceneSubCommandEntry_GenericCmd::GetRawSize() const +{ + return 0x30; +} + +CutsceneCommand_GenericCmd::CutsceneCommand_GenericCmd(const std::vector& rawData, + offset_t rawDataIndex, + CutsceneCommands cmdId) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + commandID = static_cast(cmdId); + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_GenericCmd(rawData, rawDataIndex, cmdId); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_GenericCmd::GetCommandMacro() const +{ + const auto& element = csCommandsDesc.find(static_cast(commandID)); + + if (element != csCommandsDesc.end()) + { + return StringHelper::Sprintf("%s_LIST(%i)", element->second.cmdMacro, numEntries); + } + + return StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%X, %i)", commandID, numEntries); +} + +CutsceneCameraPoint::CutsceneCameraPoint(const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + continueFlag = BitConverter::ToInt8BE(rawData, rawDataIndex + 0); + cameraRoll = BitConverter::ToInt8BE(rawData, rawDataIndex + 1); + nextPointFrame = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); + viewAngle = BitConverter::ToFloatBE(rawData, rawDataIndex + 4); + + posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 8); + posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 10); + posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 12); + + unused = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); +} + +std::string CutsceneCameraPoint::GetBodySourceCode() const +{ + std::string result = ""; + + if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) + { + result += "CS_CAM_FOCUS_POINT"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) + { + result += "CS_CAM_FOCUS_POINT_PLAYER"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) + { + result += "CS_CAM_POS_PLAYER"; + } + else + { + result += "CS_CAM_POS"; + } + + std::string continueMacro = "CS_CMD_CONTINUE"; + if (continueFlag != 0) + continueMacro = "CS_CMD_STOP"; + + result += + StringHelper::Sprintf("(%s, 0x%02X, %i, %ff, %i, %i, %i, 0x%04X)", continueMacro.c_str(), + cameraRoll, nextPointFrame, viewAngle, posX, posY, posZ, unused); + return result; +} + +size_t CutsceneCameraPoint::GetRawSize() const +{ + return 0x10; +} + +CutsceneCommandSetCameraPos::CutsceneCommandSetCameraPos(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + unused = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); + + bool shouldContinue = true; + + uint32_t currentPtr = rawDataIndex + 8; + + while (shouldContinue) + { + CutsceneCameraPoint* camPoint = new CutsceneCameraPoint(rawData, currentPtr); + entries.push_back(camPoint); + + if (camPoint->continueFlag == -1) + shouldContinue = false; + + currentPtr += camPoint->GetRawSize(); + } +} + +std::string CutsceneCommandSetCameraPos::GetCommandMacro() const +{ + std::string result; + + std::string listStr; + + if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) + { + listStr = "CS_CAM_FOCUS_POINT_LIST"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) + { + listStr = "CS_CAM_FOCUS_POINT_PLAYER_LIST"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) + { + listStr = "CS_CAM_POS_PLAYER_LIST"; + } + else + { + listStr = "CS_CAM_POS_LIST"; + } + + result += StringHelper::Sprintf("%s(%i, %i)", listStr.c_str(), startFrame, endFrame); + + return result; +} + +size_t CutsceneCommandSetCameraPos::GetCommandSize() const +{ + return 0x0C + entries.at(0)->GetRawSize() * entries.size(); +} + +CutsceneSubCommandEntry_Rumble::CutsceneSubCommandEntry_Rumble(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + unk_06 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x06); + unk_07 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x07); + unk_08 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); + unk_09 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x09); + unk_0A = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0A); + unk_0B = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0B); +} + +std::string CutsceneSubCommandEntry_Rumble::GetBodySourceCode() const +{ + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + return StringHelper::Sprintf("CS_RUMBLE(%i, %i, %i, 0x%02X, 0x%02X, 0x%02X)", base, + startFrame, endFrame, unk_06, unk_07, unk_08); + } + + return StringHelper::Sprintf("CS_CMD_09(%i, %i, %i, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X)", + base, startFrame, endFrame, unk_06, unk_07, unk_08, unk_09, unk_0A, + unk_0B); +} + +size_t CutsceneSubCommandEntry_Rumble::GetRawSize() const +{ + return 0x0C; +} + +CutsceneCommand_Rumble::CutsceneCommand_Rumble(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_Rumble(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_Rumble::GetCommandMacro() const +{ + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + return StringHelper::Sprintf("CS_RUMBLE_LIST(%i)", numEntries); + } + return StringHelper::Sprintf("CS_CMD_09_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_SetTime::CutsceneSubCommandEntry_SetTime( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + hour = BitConverter::ToUInt8BE(rawData, rawDataIndex + 6); + minute = BitConverter::ToUInt8BE(rawData, rawDataIndex + 7); + unk_08 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); +} + +std::string CutsceneSubCommandEntry_SetTime::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CS_TIME(%i, %i, %i, %i, %i, %i)", base, startFrame, endFrame, + hour, minute, unk_08); +} + +size_t CutsceneSubCommandEntry_SetTime::GetRawSize() const +{ + return 0x0C; +} + +CutsceneCommand_SetTime::CutsceneCommand_SetTime(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_SetTime(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_SetTime::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_TIME_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_TextBox::CutsceneSubCommandEntry_TextBox( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6); + textId1 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8); + textId2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA); +} + +std::string CutsceneSubCommandEntry_TextBox::GetBodySourceCode() const +{ + if (type == 0xFFFF) + { + return StringHelper::Sprintf("CS_TEXT_NONE(%i, %i)", startFrame, endFrame); + } + if (type == 2) + { + return StringHelper::Sprintf("CS_TEXT_LEARN_SONG(%i, %i, %i, 0x%X)", base, startFrame, + endFrame, textId1); + } + + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + switch (type) + { + case 0: + return StringHelper::Sprintf("CS_TEXT_DEFAULT(0x%X, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, textId1, textId2); + + case 1: + return StringHelper::Sprintf("CS_TEXT_TYPE_1(0x%X, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, textId1, textId2); + + case 3: + return StringHelper::Sprintf("CS_TEXT_TYPE_3(0x%X, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, textId1, textId2); + + case 4: + return StringHelper::Sprintf("CS_TEXT_BOSSES_REMAINS(0x%X, %i, %i, 0x%X)", base, + startFrame, endFrame, textId1); + + case 5: + return StringHelper::Sprintf("CS_TEXT_ALL_NORMAL_MASKS(0x%X, %i, %i, 0x%X)", base, + startFrame, endFrame, textId1); + } + } + + return StringHelper::Sprintf("CS_TEXT_DISPLAY_TEXTBOX(0x%X, %i, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, type, textId1, textId2); +} + +size_t CutsceneSubCommandEntry_TextBox::GetRawSize() const +{ + return 0x0C; +} + +CutsceneCommand_TextBox::CutsceneCommand_TextBox(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_TextBox(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_TextBox::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_TEXT_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_ActorAction::CutsceneSubCommandEntry_ActorAction( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6); + rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8); + rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA); + startPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 0xC); + startPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x10); + startPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x14); + endPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x18); + endPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x1C); + endPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x20); + normalX = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x24); + normalY = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x28); + normalZ = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x2C); +} + +std::string CutsceneSubCommandEntry_ActorAction::GetBodySourceCode() const +{ + std::string result; + + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + if (static_cast(commandID) == + CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION) + { + result = "CS_PLAYER_ACTION"; + } + else + { + result = "CS_ACTOR_ACTION"; + } + } + else + { + if (static_cast(commandID) == CutsceneCommands::SetPlayerAction) + { + result = "CS_PLAYER_ACTION"; + } + else + { + result = "CS_NPC_ACTION"; + } + } + + result += + StringHelper::Sprintf("(%i, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, " + "%i, %i, %i, %i, %.11ef, %.11ef, %.11ef)", + base, startFrame, endFrame, rotX, rotY, rotZ, startPosX, startPosY, + startPosZ, endPosX, endPosY, endPosZ, normalX, normalY, normalZ); + return result; +} + +size_t CutsceneSubCommandEntry_ActorAction::GetRawSize() const +{ + return 0x30; +} + +CutsceneCommand_ActorAction::CutsceneCommand_ActorAction(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_ActorAction(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_ActorAction::GetCommandMacro() const +{ + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + if (static_cast(commandID) == + CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION) + { + return StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i)", numEntries); + } + return StringHelper::Sprintf("CS_ACTOR_ACTION_LIST(0x%03X, %i)", commandID, numEntries); + } + + if (static_cast(commandID) == CutsceneCommands::SetPlayerAction) + { + return StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i)", entries.size()); + } + return StringHelper::Sprintf("CS_NPC_ACTION_LIST(0x%03X, %i)", commandID, entries.size()); +} + +CutsceneCommand_Terminator::CutsceneCommand_Terminator(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + unknown = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); // endFrame duplicate +} + +std::string CutsceneCommand_Terminator::GenerateSourceCode() const +{ + std::string result; + + result += StringHelper::Sprintf("CS_TERMINATOR(%i, %i, %i),\n", base, startFrame, endFrame); + + return result; +} + +size_t CutsceneCommand_Terminator::GetCommandSize() const +{ + return 0x10; +} + +CutsceneCommandSceneTransFX::CutsceneCommandSceneTransFX(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); +} + +std::string CutsceneCommandSceneTransFX::GenerateSourceCode() const +{ + return StringHelper::Sprintf("CS_SCENE_TRANS_FX(%i, %i, %i),\n", base, startFrame, endFrame); +} + +size_t CutsceneCommandSceneTransFX::GetCommandSize() const +{ + return 0x10; +} diff --git a/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.h b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.h new file mode 100644 index 000000000..c46273587 --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.h @@ -0,0 +1,267 @@ +#pragma once + +#include +#include +#include + +#include "Declaration.h" + +enum class CutsceneCommands +{ + SetCameraPos = 0x0001, + SetCameraFocus = 0x0002, + Misc = 0x0003, + SetLighting = 0x0004, + SetCameraPosLink = 0x0005, + SetCameraFocusLink = 0x0006, + Cmd07 = 0x0007, + Cmd08 = 0x0008, + Cmd09 = 0x0009, // Rumble + Textbox = 0x0013, + SetPlayerAction = 0x000A, + SetActorAction1 = 0x000F, + SetActorAction2 = 0x000E, + SetActorAction3 = 0x0019, + SetActorAction4 = 0x001D, + SetActorAction5 = 0x001E, + SetActorAction6 = 0x002C, + SetActorAction7 = 0x001F, + SetActorAction8 = 0x0031, + SetActorAction9 = 0x003E, + SetActorAction10 = 0x008F, + SetSceneTransFX = 0x002D, + PlayBGM = 0x0056, + StopBGM = 0x0057, + FadeBGM = 0x007C, + SetTime = 0x008C, + Terminator = 0x03E8, +}; + +typedef struct CsCommandListDescriptor +{ + const char* cmdMacro; + const char* args; +} CsCommandListDescriptor; + +class CutsceneSubCommandEntry +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + uint16_t pad; + + uint32_t commandID; + + CutsceneSubCommandEntry(const std::vector& rawData, offset_t rawDataIndex); + virtual ~CutsceneSubCommandEntry() = default; + + virtual std::string GetBodySourceCode() const; + + virtual size_t GetRawSize() const; +}; + +class CutsceneCommand +{ +public: + uint32_t commandID; + uint32_t commandIndex; + + uint32_t numEntries; + std::vector entries; + + CutsceneCommand(const std::vector& rawData, offset_t rawDataIndex); + virtual ~CutsceneCommand(); + + virtual std::string GetCommandMacro() const; + virtual std::string GenerateSourceCode() const; + virtual size_t GetCommandSize() const; + + virtual void SetCommandID(uint32_t nCommandID); +}; + +class CutsceneSubCommandEntry_GenericCmd : public CutsceneSubCommandEntry +{ +public: + CutsceneCommands commandId; + + uint32_t word0 = 0; + uint32_t word1 = 0; + + uint32_t unused1 = 0; + uint32_t unused2 = 0; + uint32_t unused3 = 0; + uint32_t unused4 = 0; + uint32_t unused5 = 0; + uint32_t unused6 = 0; + uint32_t unused7 = 0; + uint32_t unused8 = 0; + uint32_t unused9 = 0; + uint32_t unused10 = 0; + + CutsceneSubCommandEntry_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneCommands cmdId); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_GenericCmd : public CutsceneCommand +{ +public: + CutsceneCommand_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneCommands cmdId); + + std::string GetCommandMacro() const override; +}; + +class CutsceneCameraPoint : public CutsceneSubCommandEntry +{ +public: + int8_t continueFlag; + int8_t cameraRoll; + int16_t nextPointFrame; + float viewAngle; + int16_t posX, posY, posZ; + int16_t unused; + + CutsceneCameraPoint(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommandSetCameraPos : public CutsceneCommand +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + uint16_t unused; + + CutsceneCommandSetCameraPos(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; + + size_t GetCommandSize() const override; +}; + +class CutsceneCommandSceneTransFX : public CutsceneCommand +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + + CutsceneCommandSceneTransFX(const std::vector& rawData, offset_t rawDataIndex); + + std::string GenerateSourceCode() const override; + size_t GetCommandSize() const override; +}; + +class CutsceneSubCommandEntry_Rumble : public CutsceneSubCommandEntry +{ +public: + uint8_t unk_06; + uint8_t unk_07; + uint8_t unk_08; + uint8_t unk_09; + uint8_t unk_0A; + uint8_t unk_0B; + + CutsceneSubCommandEntry_Rumble(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_Rumble : public CutsceneCommand +{ +public: + CutsceneCommand_Rumble(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_SetTime : public CutsceneSubCommandEntry +{ +public: + uint8_t hour; + uint8_t minute; + uint32_t unk_08; + + CutsceneSubCommandEntry_SetTime(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_SetTime : public CutsceneCommand +{ +public: + CutsceneCommand_SetTime(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_TextBox : public CutsceneSubCommandEntry +{ +public: + uint16_t type; + uint16_t textId1; + uint16_t textId2; + + CutsceneSubCommandEntry_TextBox(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_TextBox : public CutsceneCommand +{ +public: + CutsceneCommand_TextBox(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_ActorAction : public CutsceneSubCommandEntry +{ +public: + uint16_t rotX, rotY, rotZ; + int32_t startPosX, startPosY, startPosZ; + int32_t endPosX, endPosY, endPosZ; + float normalX, normalY, normalZ; + + CutsceneSubCommandEntry_ActorAction(const std::vector& rawData, offset_t rawDataIndex); + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_ActorAction : public CutsceneCommand +{ +public: + CutsceneCommand_ActorAction(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneCommand_Terminator : public CutsceneCommand +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + uint16_t unknown; + + CutsceneCommand_Terminator(const std::vector& rawData, offset_t rawDataIndex); + + std::string GenerateSourceCode() const override; + size_t GetCommandSize() const override; +}; diff --git a/tools/ZAPD/ZAPD/ZCutscene.cpp b/tools/ZAPD/ZAPD/ZCutscene.cpp index 71bb690c7..62f814b13 100644 --- a/tools/ZAPD/ZAPD/ZCutscene.cpp +++ b/tools/ZAPD/ZAPD/ZCutscene.cpp @@ -1,5 +1,9 @@ #include "ZCutscene.h" +#include + +#include "Globals.h" +#include "OtherStructs/CutsceneMM_Commands.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" #include "WarningHandler.h" @@ -7,7 +11,7 @@ REGISTER_ZFILENODE(Cutscene, ZCutscene); -ZCutscene::ZCutscene(ZFile* nParent) : ZCutsceneBase(nParent) +ZCutscene::ZCutscene(ZFile* nParent) : ZResource(nParent) { } @@ -16,91 +20,20 @@ ZCutscene::~ZCutscene() for (CutsceneCommand* cmd : commands) delete cmd; } -CutsceneCommandSetCameraPos::~CutsceneCommandSetCameraPos() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandSpecialAction::~CutsceneCommandSpecialAction() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandFadeBGM::~CutsceneCommandFadeBGM() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandPlayBGM::~CutsceneCommandPlayBGM() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandStopBGM::~CutsceneCommandStopBGM() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandEnvLighting::~CutsceneCommandEnvLighting() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandUnknown9::~CutsceneCommandUnknown9() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandUnknown::~CutsceneCommandUnknown() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandDayTime::~CutsceneCommandDayTime() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandTextbox::~CutsceneCommandTextbox() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandActorAction::~CutsceneCommandActorAction() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandSceneTransFX::~CutsceneCommandSceneTransFX() -{ -} std::string ZCutscene::GetBodySourceCode() const { std::string output = ""; - uint32_t curPtr = 0; output += StringHelper::Sprintf(" CS_BEGIN_CUTSCENE(%i, %i),\n", commands.size(), endFrame); for (size_t i = 0; i < commands.size(); i++) { CutsceneCommand* cmd = commands[i]; - output += " " + cmd->GenerateSourceCode(curPtr); - curPtr += cmd->GetCommandSize(); + output += " " + cmd->GenerateSourceCode(); } - output += StringHelper::Sprintf(" CS_END(),\n", commands.size(), endFrame); + output += StringHelper::Sprintf(" CS_END(),", commands.size(), endFrame); return output; } @@ -115,12 +48,19 @@ size_t ZCutscene::GetRawDataSize() const for (size_t i = 0; i < commands.size(); i++) { CutsceneCommand* cmd = commands[i]; + size += cmd->GetCommandSize(); - size += 4; } // End - size += 8; + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + size += 4; + } + else + { + size += 8; + } return size; } @@ -135,153 +75,68 @@ void ZCutscene::ParseRawData() commands = std::vector(); endFrame = BitConverter::ToInt32BE(rawData, rawDataIndex + 4); - uint32_t currentPtr = rawDataIndex + 8; + offset_t currentPtr = rawDataIndex + 8; for (int32_t i = 0; i < numCommands; i++) { - int32_t id = BitConverter::ToInt32BE(rawData, currentPtr); + uint32_t id = BitConverter::ToUInt32BE(rawData, currentPtr); - if (id == -1) + if (id == 0xFFFFFFFF) break; - CutsceneCommands cmdID = (CutsceneCommands)GetCommandFromID(id); + if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) + { + printf("Cutscene Command: 0x%X (%i)\n", id, id); + } + currentPtr += 4; - int32_t numEntries = 1; + CutsceneCommand* cmd = nullptr; - for (int32_t j = 0; j < numEntries; j++) + if (Globals::Instance->game == ZGame::MM_RETAIL) { - CutsceneCommand* cmd = nullptr; - - switch (cmdID) - { - case CutsceneCommands::Cmd00: - break; - case CutsceneCommands::SetCameraPos: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::SetCameraFocus: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::SpecialAction: - cmd = new CutsceneCommandSpecialAction(rawData, currentPtr); - break; - case CutsceneCommands::SetLighting: - cmd = new CutsceneCommandEnvLighting(rawData, currentPtr); - break; - case CutsceneCommands::SetCameraPosLink: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::SetCameraFocusLink: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::Cmd07: - break; - case CutsceneCommands::Cmd08: - break; - case CutsceneCommands::Cmd09: - cmd = new CutsceneCommandUnknown9(rawData, currentPtr); - break; - case CutsceneCommands::Textbox: - cmd = new CutsceneCommandTextbox(rawData, currentPtr); - break; - case CutsceneCommands::Unknown: - cmd = new CutsceneCommandUnknown(rawData, currentPtr); - break; - case CutsceneCommands::SetActorAction0: - case CutsceneCommands::SetActorAction1: - case CutsceneCommands::SetActorAction2: - case CutsceneCommands::SetActorAction3: - case CutsceneCommands::SetActorAction4: - case CutsceneCommands::SetActorAction5: - case CutsceneCommands::SetActorAction6: - case CutsceneCommands::SetActorAction7: - case CutsceneCommands::SetActorAction8: - case CutsceneCommands::SetActorAction9: - case CutsceneCommands::SetActorAction10: - cmd = new CutsceneCommandActorAction(rawData, currentPtr); - break; - case CutsceneCommands::SetSceneTransFX: - cmd = new CutsceneCommandSceneTransFX(rawData, currentPtr); - break; - case CutsceneCommands::Nop: - cmd = new CutsceneCommandNop(rawData, currentPtr); - break; - case CutsceneCommands::PlayBGM: - cmd = new CutsceneCommandPlayBGM(rawData, currentPtr); - break; - case CutsceneCommands::StopBGM: - cmd = new CutsceneCommandStopBGM(rawData, currentPtr); - break; - case CutsceneCommands::FadeBGM: - cmd = new CutsceneCommandFadeBGM(rawData, currentPtr); - break; - case CutsceneCommands::SetTime: - cmd = new CutsceneCommandDayTime(rawData, currentPtr); - break; - case CutsceneCommands::Terminator: - cmd = new CutsceneCommandTerminator(rawData, currentPtr); - break; - case CutsceneCommands::End: - cmd = new CutsceneCommandEnd(rawData, currentPtr); - break; - case CutsceneCommands::Error: - HANDLE_WARNING_RESOURCE(WarningType::NotImplemented, parent, this, rawDataIndex, - StringHelper::Sprintf("cutscene command error %d", cmdID), - ""); - break; - } - - cmd->commandIndex = i; - cmd->commandID = (uint32_t)id; - currentPtr += (uint32_t)cmd->GetCommandSize(); - - commands.push_back(cmd); + cmd = GetCommandMM(id, currentPtr); } + else + { + cmd = GetCommandOoT(id, currentPtr); + } + + if (cmd == nullptr) + { + HANDLE_WARNING_RESOURCE( + WarningType::NotImplemented, parent, this, rawDataIndex, + StringHelper::Sprintf("Cutscene command not implemented"), + StringHelper::Sprintf("Command ID: 0x%X\nIndex: %d\ncurrentPtr-rawDataIndex: 0x%X", + id, i, currentPtr - rawDataIndex)); + cmd = new CutsceneMMCommand_NonImplemented(rawData, currentPtr); + } + + assert(cmd != nullptr); + + cmd->commandIndex = i; + cmd->SetCommandID(id); + size_t commmandSize = cmd->GetCommandSize(); + if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) + { + printf("\t Command size: 0x%zX (%zu)\n", commmandSize, commmandSize); + } + currentPtr += commmandSize - 4; + + commands.push_back(cmd); } } -CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) +CutsceneCommand* ZCutscene::GetCommandOoT(uint32_t id, offset_t currentPtr) const { + CutsceneCommands cmdID = static_cast(id); + + const auto& rawData = parent->GetRawData(); + switch (id) { - case 0x0003: - return CutsceneCommands::SpecialAction; - case 0x0004: - return CutsceneCommands::SetLighting; - case 0x0056: - return CutsceneCommands::PlayBGM; - case 0x0057: - return CutsceneCommands::StopBGM; - case 0x007C: - return CutsceneCommands::FadeBGM; - case 0x0009: - return CutsceneCommands::Cmd09; - case 0x0013: - return CutsceneCommands::Textbox; - case 0x008C: - return CutsceneCommands::SetTime; - case 0x0001: - return CutsceneCommands::SetCameraPos; - case 0x0002: - return CutsceneCommands::SetCameraFocus; - case 0x0005: - return CutsceneCommands::SetCameraPosLink; - case 0x0006: - return CutsceneCommands::SetCameraFocusLink; - case 0x0007: - return CutsceneCommands::Cmd07; - case 0x0008: - return CutsceneCommands::Cmd08; - case 0x03E8: - return CutsceneCommands::Terminator; - case 0xFFFF: - return CutsceneCommands::End; - case 0x002D: - return CutsceneCommands::SetSceneTransFX; - case 10: - return CutsceneCommands::SetActorAction0; - case 15: + case 10: // CutsceneCommands::SetPlayerAction + case 15: // CutsceneCommands::SetActorAction1 case 17: case 18: case 23: @@ -299,8 +154,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 138: case 139: case 144: - return CutsceneCommands::SetActorAction1; - case 14: + case 14: // CutsceneCommands::SetActorAction2 case 16: case 24: case 35: @@ -318,8 +172,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 125: case 131: case 141: - return CutsceneCommands::SetActorAction2; - case 25: + case 25: // CutsceneCommands::SetActorAction3 case 36: case 41: case 50: @@ -332,8 +185,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 121: case 126: case 132: - return CutsceneCommands::SetActorAction3; - case 29: + case 29: // CutsceneCommands::SetActorAction4 case 37: case 42: case 51: @@ -346,8 +198,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 108: case 127: case 133: - return CutsceneCommands::SetActorAction4; - case 30: + case 30: // CutsceneCommands::SetActorAction5 case 38: case 43: case 47: @@ -356,16 +207,14 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 83: case 128: case 135: - return CutsceneCommands::SetActorAction5; - case 44: + case 44: // CutsceneCommands::SetActorAction6 case 55: case 77: case 84: case 90: case 129: case 136: - return CutsceneCommands::SetActorAction6; - case 31: + case 31: // CutsceneCommands::SetActorAction7 case 52: case 57: case 58: @@ -373,19 +222,17 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 115: case 130: case 137: - return CutsceneCommands::SetActorAction7; - case 49: + case 49: // CutsceneCommands::SetActorAction8 case 60: case 89: case 111: case 114: case 134: case 142: - return CutsceneCommands::SetActorAction8; - case 62: - return CutsceneCommands::SetActorAction9; - case 143: - return CutsceneCommands::SetActorAction10; + case 62: // CutsceneCommands::SetActorAction9 + case 143: // CutsceneCommands::SetActorAction10 + return new CutsceneCommand_ActorAction(rawData, currentPtr); + case 0x0B: case 0x0D: case 0x1A: @@ -403,835 +250,120 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 0x70: case 0x71: case 0x4A: - return CutsceneCommands::Unknown; + return new CutsceneCommand_GenericCmd(rawData, currentPtr, cmdID); } - HANDLE_WARNING_RESOURCE( - WarningType::NotImplemented, parent, this, rawDataIndex, - StringHelper::Sprintf("could not identify cutscene command. ID 0x%04X", id), ""); - - return CutsceneCommands::Error; -} - -ZResourceType ZCutscene::GetResourceType() const -{ - return ZResourceType::Cutscene; -} - -CutsceneCommand::CutsceneCommand([[maybe_unused]] const std::vector& rawData, - [[maybe_unused]] uint32_t rawDataIndex) -{ -} - -CutsceneCommand::~CutsceneCommand() -{ -} - -std::string CutsceneCommand::GetCName() -{ - return "SCmdCutsceneData"; -} - -std::string CutsceneCommand::GenerateSourceCode(uint32_t baseAddress) -{ - return StringHelper::Sprintf("%s CutsceneData%04XCmd%02X = { 0x%02X,", GetCName().c_str(), - baseAddress, commandIndex, commandID); -} - -size_t CutsceneCommand::GetCommandSize() -{ - return 4; -} - -CutsceneCameraPoint::CutsceneCameraPoint(const std::vector& rawData, uint32_t rawDataIndex) -{ - continueFlag = rawData.at(rawDataIndex + 0); - cameraRoll = rawData.at(rawDataIndex + 1); - nextPointFrame = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - viewAngle = BitConverter::ToFloatBE(rawData, rawDataIndex + 4); - - posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 8); - posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 10); - posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 12); - - unused = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); -} - -CutsceneCommandSetCameraPos::CutsceneCommandSetCameraPos(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unused = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - - entries = std::vector(); - - bool shouldContinue = true; - - uint32_t currentPtr = rawDataIndex + 8; - - while (shouldContinue) + switch (cmdID) { - CutsceneCameraPoint* camPoint = new CutsceneCameraPoint(rawData, currentPtr); - entries.push_back(camPoint); + case CutsceneCommands::Misc: + case CutsceneCommands::SetLighting: + case CutsceneCommands::PlayBGM: + case CutsceneCommands::StopBGM: + case CutsceneCommands::FadeBGM: + return new CutsceneCommand_GenericCmd(rawData, currentPtr, cmdID); - if (camPoint->continueFlag == -1) - shouldContinue = false; + case CutsceneCommands::SetCameraPos: + case CutsceneCommands::SetCameraFocus: + case CutsceneCommands::SetCameraPosLink: + case CutsceneCommands::SetCameraFocusLink: + return new CutsceneCommandSetCameraPos(rawData, currentPtr); - currentPtr += 16; + case CutsceneCommands::Cmd07: + break; + case CutsceneCommands::Cmd08: + break; + case CutsceneCommands::Cmd09: + return new CutsceneCommand_Rumble(rawData, currentPtr); + case CutsceneCommands::Textbox: + return new CutsceneCommand_TextBox(rawData, currentPtr); + + case CutsceneCommands::SetPlayerAction: + case CutsceneCommands::SetActorAction1: + case CutsceneCommands::SetActorAction2: + case CutsceneCommands::SetActorAction3: + case CutsceneCommands::SetActorAction4: + case CutsceneCommands::SetActorAction5: + case CutsceneCommands::SetActorAction6: + case CutsceneCommands::SetActorAction7: + case CutsceneCommands::SetActorAction8: + case CutsceneCommands::SetActorAction9: + case CutsceneCommands::SetActorAction10: + break; + + case CutsceneCommands::SetSceneTransFX: + return new CutsceneCommandSceneTransFX(rawData, currentPtr); + + case CutsceneCommands::SetTime: + return new CutsceneCommand_SetTime(rawData, currentPtr); + case CutsceneCommands::Terminator: + return new CutsceneCommand_Terminator(rawData, currentPtr); } + + return nullptr; } -// TODO -std::string CutsceneCommandSetCameraPos::GetCName() +CutsceneCommand* ZCutscene::GetCommandMM(uint32_t id, offset_t currentPtr) const { - return ""; -} + CutsceneMMCommands cmdID = static_cast(id); -std::string CutsceneCommandSetCameraPos::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; + const auto& rawData = parent->GetRawData(); - std::string listStr; - std::string posStr; - - if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) + if (((id >= 100) && (id < 150)) || (id == 201) || ((id >= 450) && (id < 600))) { - listStr = "CS_CAM_FOCUS_POINT_LIST"; - posStr = "CS_CAM_FOCUS_POINT"; + return new CutsceneCommand_ActorAction(rawData, currentPtr); } - else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) + + switch (cmdID) { - listStr = "CS_CAM_FOCUS_POINT_PLAYER_LIST"; - posStr = "CS_CAM_FOCUS_POINT_PLAYER"; - } - else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) - { - listStr = "CS_CAM_POS_PLAYER_LIST"; - posStr = "CS_CAM_POS_PLAYER"; - } - else - { - listStr = "CS_CAM_POS_LIST"; - posStr = "CS_CAM_POS"; + case CutsceneMMCommands::CS_CMD_MISC: + case CutsceneMMCommands::CS_CMD_SET_LIGHTING: + case CutsceneMMCommands::CS_CMD_SCENE_TRANS_FX: + case CutsceneMMCommands::CS_CMD_MOTIONBLUR: + case CutsceneMMCommands::CS_CMD_GIVETATL: + case CutsceneMMCommands::CS_CMD_PLAYSEQ: + case CutsceneMMCommands::CS_CMD_130: + case CutsceneMMCommands::CS_CMD_131: + case CutsceneMMCommands::CS_CMD_132: + case CutsceneMMCommands::CS_CMD_STOPSEQ: + case CutsceneMMCommands::CS_CMD_PLAYAMBIENCE: + case CutsceneMMCommands::CS_CMD_FADEAMBIENCE: + case CutsceneMMCommands::CS_CMD_TERMINATOR: + case CutsceneMMCommands::CS_CMD_CHOOSE_CREDITS_SCENES: + + case CutsceneMMCommands::CS_CMD_UNK_FA: + case CutsceneMMCommands::CS_CMD_UNK_FE: + case CutsceneMMCommands::CS_CMD_UNK_FF: + case CutsceneMMCommands::CS_CMD_UNK_100: + case CutsceneMMCommands::CS_CMD_UNK_101: + case CutsceneMMCommands::CS_CMD_UNK_102: + case CutsceneMMCommands::CS_CMD_UNK_103: + case CutsceneMMCommands::CS_CMD_UNK_104: + case CutsceneMMCommands::CS_CMD_UNK_105: + case CutsceneMMCommands::CS_CMD_UNK_108: + case CutsceneMMCommands::CS_CMD_UNK_109: + case CutsceneMMCommands::CS_CMD_UNK_12D: + return new CutsceneMMCommand_GenericCmd(rawData, currentPtr, cmdID); + + case CutsceneMMCommands::CS_CMD_TEXTBOX: + return new CutsceneCommand_TextBox(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_CAMERA: + return new CutsceneMMCommand_Camera(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_FADESCREEN: + return new CutsceneMMCommand_FadeScreen(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_FADESEQ: + return new CutsceneMMCommand_FadeSeq(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_SETTIME: + return new CutsceneCommand_SetTime(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION: + return new CutsceneCommand_ActorAction(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_RUMBLE: + return new CutsceneCommand_Rumble(rawData, currentPtr); } - result += StringHelper::Sprintf("%s(%i, %i),\n", listStr.c_str(), startFrame, endFrame); - - for (size_t i = 0; i < entries.size(); i++) - { - std::string continueMacro = "CS_CMD_CONTINUE"; - if (entries[i]->continueFlag != 0) - continueMacro = "CS_CMD_STOP"; - result += StringHelper::Sprintf(" %s(%s, 0x%02X, %i, %ff, %i, %i, %i, 0x%04X),\n", - posStr.c_str(), continueMacro.c_str(), - entries[i]->cameraRoll, entries[i]->nextPointFrame, - entries[i]->viewAngle, entries[i]->posX, entries[i]->posY, - entries[i]->posZ, entries[i]->unused); - } - - return result; -} - -size_t CutsceneCommandSetCameraPos::GetCommandSize() -{ - return 8 + (entries.size() * 16); -} - -MusicFadeEntry::MusicFadeEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unknown0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - unknown1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unknown2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unknown3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unknown4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unknown5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unknown6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unknown7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); - unknown8 = BitConverter::ToUInt32BE(rawData, - rawDataIndex + 36); // Macro hardcodes it as zero - unknown9 = BitConverter::ToUInt32BE(rawData, - rawDataIndex + 40); // Macro hardcodes it as zero - unknown10 = BitConverter::ToUInt32BE(rawData, - rawDataIndex + 44); // Macro hardcodes it as zero -} - -CutsceneCommandFadeBGM::CutsceneCommandFadeBGM(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - uint32_t numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (uint32_t i = 0; i < numEntries; i++) - { - entries.push_back(new MusicFadeEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandFadeBGM::GetCName() -{ - return "CsCmdMusicFade"; -} - -std::string CutsceneCommandFadeBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_FADE_BGM_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_FADE_BGM(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->base, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->unknown0, - entries[i]->unknown1, entries[i]->unknown2, entries[i]->unknown3, entries[i]->unknown4, - entries[i]->unknown5, entries[i]->unknown6, entries[i]->unknown7); - } - - return result; -} - -size_t CutsceneCommandFadeBGM::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 0x30 * entries.size(); -} - -MusicChangeEntry::MusicChangeEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - sequence = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unknown0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - unknown1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unknown2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unknown3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unknown4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unknown5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unknown6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unknown7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); -} - -CutsceneCommandPlayBGM::CutsceneCommandPlayBGM(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - uint32_t numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (uint32_t i = 0; i < numEntries; i++) - { - entries.push_back(new MusicChangeEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandPlayBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_PLAY_BGM_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_PLAY_BGM(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", - entries[i]->sequence, entries[i]->startFrame, entries[i]->endFrame, - entries[i]->unknown0, entries[i]->unknown1, entries[i]->unknown2, entries[i]->unknown3, - entries[i]->unknown4, entries[i]->unknown5, entries[i]->unknown6, entries[i]->unknown7); - } - - return result; -} - -std::string CutsceneCommandPlayBGM::GetCName() -{ - return "CsCmdMusicChange"; -} - -size_t CutsceneCommandPlayBGM::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 0x30; -} - -CutsceneCommandStopBGM::CutsceneCommandStopBGM(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - uint32_t numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (uint32_t i = 0; i < numEntries; i++) - { - entries.push_back(new MusicChangeEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandStopBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_STOP_BGM_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\tCS_STOP_BGM(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->sequence, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->unknown0, - entries[i]->unknown1, entries[i]->unknown2, entries[i]->unknown3, entries[i]->unknown4, - entries[i]->unknown5, entries[i]->unknown6, entries[i]->unknown7); - } - - return result; -} - -std::string CutsceneCommandStopBGM::GetCName() -{ - return "CsCmdMusicChange"; -} - -size_t CutsceneCommandStopBGM::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 0x30; -} - -EnvLightingEntry::EnvLightingEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - setting = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unused0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); -} - -CutsceneCommandEnvLighting::CutsceneCommandEnvLighting(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new EnvLightingEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandEnvLighting::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_LIGHTING_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\tCS_LIGHTING(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->setting, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->unused0, entries[i]->unused1, - entries[i]->unused2, entries[i]->unused3, entries[i]->unused4, entries[i]->unused5, - entries[i]->unused6, entries[i]->unused7); - } - - return result; -} - -std::string CutsceneCommandEnvLighting::GetCName() -{ - return "CsCmdEnvLighting"; -} - -size_t CutsceneCommandEnvLighting::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (0x30 * entries.size()); -} - -Unknown9Entry::Unknown9Entry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unk2 = rawData[rawDataIndex + 6]; - unk3 = rawData[rawDataIndex + 7]; - unk4 = rawData[rawDataIndex + 8]; - unused0 = rawData[rawDataIndex + 10]; - unused1 = rawData[rawDataIndex + 11]; - ; -} - -CutsceneCommandUnknown9::CutsceneCommandUnknown9(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new Unknown9Entry(rawData, rawDataIndex)); - rawDataIndex += 0x0C; - } -} - -std::string CutsceneCommandUnknown9::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_CMD_09_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf("\t\tCS_CMD_09(%i, %i, %i, %i, %i, %i, %i, %i),\n", - entries[i]->base, entries[i]->startFrame, - entries[i]->endFrame, entries[i]->unk2, entries[i]->unk3, - entries[i]->unk4, entries[i]->unused0, entries[i]->unused1); - } - - return result; -} - -std::string CutsceneCommandUnknown9::GetCName() -{ - return "CsCmdUnknown9"; -} - -size_t CutsceneCommandUnknown9::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 12); -} - -UnkEntry::UnkEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - unused0 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 4); - unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unused8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); - unused9 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 36); - unused10 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 40); - unused11 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 44); -} - -CutsceneCommandUnknown::CutsceneCommandUnknown(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new UnkEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandUnknown::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%02X, %i),\n", commandID, entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_UNK_DATA(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", - entries[i]->unused0, entries[i]->unused1, entries[i]->unused2, entries[i]->unused3, - entries[i]->unused4, entries[i]->unused5, entries[i]->unused6, entries[i]->unused7, - entries[i]->unused8, entries[i]->unused9, entries[i]->unused10, entries[i]->unused11); - } - - return result; -} - -std::string CutsceneCommandUnknown::GetCName() -{ - return "CsCmdUnknown1A"; -} - -size_t CutsceneCommandUnknown::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 0x30); -} - -DayTimeEntry::DayTimeEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - hour = rawData[rawDataIndex + 6]; - minute = rawData[rawDataIndex + 7]; - unused = rawData[rawDataIndex + 8]; -} - -CutsceneCommandDayTime::CutsceneCommandDayTime(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new DayTimeEntry(rawData, rawDataIndex)); - rawDataIndex += 12; - } -} - -std::string CutsceneCommandDayTime::GetCName() -{ - return "CsCmdDayTime"; -} - -std::string CutsceneCommandDayTime::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_TIME_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_TIME(%i, %i, %i, %i, %i, %i),\n", entries[i]->base, entries[i]->startFrame, - entries[i]->endFrame, entries[i]->hour, entries[i]->minute, entries[i]->unused); - } - - return result; -} - -size_t CutsceneCommandDayTime::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 12); -} - -TextboxEntry::TextboxEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - textID1 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); - textID2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); -} - -CutsceneCommandTextbox::CutsceneCommandTextbox(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new TextboxEntry(rawData, rawDataIndex)); - rawDataIndex += 12; - } -} - -std::string CutsceneCommandTextbox::GetCName() -{ - return "CsCmdTextbox"; -} - -std::string CutsceneCommandTextbox::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_TEXT_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - if (entries[i]->base == 0xFFFF) - { - result += StringHelper::Sprintf(" CS_TEXT_NONE(%i, %i),\n", - entries[i]->startFrame, entries[i]->endFrame); - } - else - { - result += StringHelper::Sprintf( - " CS_TEXT_DISPLAY_TEXTBOX(%i, %i, %i, %i, %i, %i),\n", entries[i]->base, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->type, entries[i]->textID1, - entries[i]->textID2); - } - } - - return result; -} - -size_t CutsceneCommandTextbox::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 12); -} - -ActorAction::ActorAction(const std::vector& rawData, uint32_t rawDataIndex) -{ - action = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); - rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); - startPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 12); - startPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 16); - startPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 20); - endPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 24); - endPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 28); - endPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 32); - normalX = BitConverter::ToFloatBE(rawData, rawDataIndex + 36); - normalY = BitConverter::ToFloatBE(rawData, rawDataIndex + 40); - normalZ = BitConverter::ToFloatBE(rawData, rawDataIndex + 44); -} - -CutsceneCommandActorAction::CutsceneCommandActorAction(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new ActorAction(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandActorAction::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - std::string subCommand; - - if (commandID == 10) - { - result += StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i),\n", entries.size()); - subCommand = "CS_PLAYER_ACTION"; - } - else - { - result += StringHelper::Sprintf("CS_NPC_ACTION_LIST(%i, %i),\n", commandID, entries.size()); - subCommand = "CS_NPC_ACTION"; - } - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\t%s(0x%04X, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, %i, %i, %i, %i, %.11ef, " - "%.11ef, %.11ef),\n", - subCommand.c_str(), entries[i]->action, entries[i]->startFrame, entries[i]->endFrame, - entries[i]->rotX, entries[i]->rotY, entries[i]->rotZ, entries[i]->startPosX, - entries[i]->startPosY, entries[i]->startPosZ, entries[i]->endPosX, entries[i]->endPosY, - entries[i]->endPosZ, entries[i]->normalX, entries[i]->normalY, entries[i]->normalZ); - } - - return result; -} - -std::string CutsceneCommandActorAction::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandActorAction::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 0x30); -} - -CutsceneCommandTerminator::CutsceneCommandTerminator(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unknown = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); // endFrame duplicate -} - -std::string CutsceneCommandTerminator::GetCName() -{ - return "CsCmdBase"; -} - -std::string CutsceneCommandTerminator::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_TERMINATOR(0x%04X, %i, %i),\n", base, startFrame, endFrame); - - return result; -} - -size_t CutsceneCommandTerminator::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 8; -} - -CutsceneCommandEnd::CutsceneCommandEnd(const std::vector& rawData, uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); -} - -std::string CutsceneCommandEnd::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_END(),\n"); - - return result; -} - -std::string CutsceneCommandEnd::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandEnd::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 6; -} - -SpecialActionEntry::SpecialActionEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unused0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); - unused8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 36); - unused9 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 40); - unused10 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 44); -} - -CutsceneCommandSpecialAction::CutsceneCommandSpecialAction(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new SpecialActionEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandSpecialAction::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_MISC_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\tCS_MISC(0x%04X, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, %i, %i, %i, %i, %i, " - "%i),\n", - entries[i]->base, entries[i]->startFrame, entries[i]->endFrame, entries[i]->unused0, - entries[i]->unused1, entries[i]->unused2, entries[i]->unused3, entries[i]->unused4, - entries[i]->unused5, entries[i]->unused6, entries[i]->unused7, entries[i]->unused8, - entries[i]->unused9, entries[i]->unused10); - } - - return result; -} - -std::string CutsceneCommandSpecialAction::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandSpecialAction::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (0x30 * entries.size()); -} - -CutsceneCommandNop::CutsceneCommandNop(const std::vector& rawData, uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); -} - -std::string CutsceneCommandNop::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandNop::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 6; -} - -CutsceneCommandSceneTransFX::CutsceneCommandSceneTransFX(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); -} - -std::string CutsceneCommandSceneTransFX::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - return StringHelper::Sprintf("CS_SCENE_TRANS_FX(%i, %i, %i),\n", base, startFrame, endFrame); -} - -std::string CutsceneCommandSceneTransFX::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandSceneTransFX::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 8; -} - -ZCutsceneBase::ZCutsceneBase(ZFile* nParent) : ZResource(nParent) -{ + return nullptr; } -Declaration* ZCutsceneBase::DeclareVar(const std::string& prefix, const std::string& bodyStr) +Declaration* ZCutscene::DeclareVar(const std::string& prefix, const std::string& bodyStr) { std::string auxName = name; @@ -1245,7 +377,12 @@ Declaration* ZCutsceneBase::DeclareVar(const std::string& prefix, const std::str return decl; } -std::string ZCutsceneBase::GetSourceTypeName() const +std::string ZCutscene::GetSourceTypeName() const { return "CutsceneData"; } + +ZResourceType ZCutscene::GetResourceType() const +{ + return ZResourceType::Cutscene; +} diff --git a/tools/ZAPD/ZAPD/ZCutscene.h b/tools/ZAPD/ZAPD/ZCutscene.h index 8e901e307..098f3ad86 100644 --- a/tools/ZAPD/ZAPD/ZCutscene.h +++ b/tools/ZAPD/ZAPD/ZCutscene.h @@ -3,422 +3,13 @@ #include #include #include -#include "ZFile.h" -#include "ZResource.h" #include "tinyxml2.h" -enum class CutsceneCommands -{ - Cmd00 = 0x0000, - SetCameraPos = 0x0001, - SetCameraFocus = 0x0002, - SpecialAction = 0x0003, - SetLighting = 0x0004, - SetCameraPosLink = 0x0005, - SetCameraFocusLink = 0x0006, - Cmd07 = 0x0007, - Cmd08 = 0x0008, - Cmd09 = 0x0009, - Unknown = 0x001A, - Textbox = 0x0013, - SetActorAction0 = 0x000A, - SetActorAction1 = 0x000F, - SetActorAction2 = 0x000E, - SetActorAction3 = 0x0019, - SetActorAction4 = 0x001D, - SetActorAction5 = 0x001E, - SetActorAction6 = 0x002C, - SetActorAction7 = 0x001F, - SetActorAction8 = 0x0031, - SetActorAction9 = 0x003E, - SetActorAction10 = 0x008F, - SetSceneTransFX = 0x002D, - Nop = 0x000B, - PlayBGM = 0x0056, - StopBGM = 0x0057, - FadeBGM = 0x007C, - SetTime = 0x008C, - Terminator = 0x03E8, - End = 0xFFFF, - Error = 0xFEAF, -}; +#include "OtherStructs/Cutscene_Commands.h" +#include "ZFile.h" +#include "ZResource.h" -class CutsceneCameraPoint -{ -public: - int8_t continueFlag; - int8_t cameraRoll; - int16_t nextPointFrame; - float viewAngle; - int16_t posX, posY, posZ; - int16_t unused; - - CutsceneCameraPoint(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommand -{ -public: - uint32_t commandID; - uint32_t commandIndex; - virtual ~CutsceneCommand(); - CutsceneCommand(const std::vector& rawData, uint32_t rawDataIndex); - virtual std::string GetCName(); - virtual std::string GenerateSourceCode(uint32_t baseAddress); - virtual size_t GetCommandSize(); -}; - -class CutsceneCommandSetCameraPos : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unused; - - std::vector entries; - ~CutsceneCommandSetCameraPos(); - CutsceneCommandSetCameraPos(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class SpecialActionEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unused0; - uint32_t unused1; - uint32_t unused2; - uint32_t unused3; - uint32_t unused4; - uint32_t unused5; - uint32_t unused6; - uint32_t unused7; - uint32_t unused8; - uint32_t unused9; - uint32_t unused10; - - SpecialActionEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandSpecialAction : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandSpecialAction(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandSpecialAction(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class MusicFadeEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unknown0; - uint32_t unknown1; - uint32_t unknown2; - uint32_t unknown3; - uint32_t unknown4; - uint32_t unknown5; - uint32_t unknown6; - uint32_t unknown7; - uint32_t unknown8; - uint32_t unknown9; - uint32_t unknown10; - - MusicFadeEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandFadeBGM : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandFadeBGM(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandFadeBGM(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class MusicChangeEntry -{ -public: - uint16_t sequence; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unknown0; - uint32_t unknown1; - uint32_t unknown2; - uint32_t unknown3; - uint32_t unknown4; - uint32_t unknown5; - uint32_t unknown6; - uint32_t unknown7; - - MusicChangeEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandPlayBGM : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandPlayBGM(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandPlayBGM(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandStopBGM : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandStopBGM(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandStopBGM(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class EnvLightingEntry -{ -public: - uint16_t setting; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unused0; - uint32_t unused1; - uint32_t unused2; - uint32_t unused3; - uint32_t unused4; - uint32_t unused5; - uint32_t unused6; - uint32_t unused7; - - EnvLightingEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandEnvLighting : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandEnvLighting(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandEnvLighting(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandSceneTransFX : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - ~CutsceneCommandSceneTransFX(); - CutsceneCommandSceneTransFX(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class Unknown9Entry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unk2; - uint16_t unk3; - uint16_t unk4; - uint8_t unused0; - uint8_t unused1; - - Unknown9Entry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandUnknown9 : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandUnknown9(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandUnknown9(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class UnkEntry -{ -public: - uint32_t unused0; - uint32_t unused1; - uint32_t unused2; - uint32_t unused3; - uint32_t unused4; - uint32_t unused5; - uint32_t unused6; - uint32_t unused7; - uint32_t unused8; - uint32_t unused9; - uint32_t unused10; - uint32_t unused11; - - UnkEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandUnknown : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandUnknown(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandUnknown(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class DayTimeEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint8_t hour; - uint8_t minute; - uint8_t unused; - - DayTimeEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandDayTime : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandDayTime(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandDayTime(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class TextboxEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t type; - uint16_t textID1; - uint16_t textID2; - - TextboxEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandTextbox : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandTextbox(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandTextbox(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class ActorAction -{ -public: - uint16_t action; - uint16_t startFrame; - uint16_t endFrame; - int16_t rotX, rotY, rotZ; - int32_t startPosX, startPosY, startPosZ; - int32_t endPosX, endPosY, endPosZ; - float normalX, normalY, normalZ; - - ActorAction(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandActorAction : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandActorAction(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandActorAction(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandTerminator : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unknown; - - CutsceneCommandTerminator(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandEnd : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - - CutsceneCommandEnd(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandNop : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - - CutsceneCommandNop(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - size_t GetCommandSize(); -}; - -class ZCutsceneBase : public ZResource -{ -public: - ZCutsceneBase(ZFile* nParent); - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - - std::string GetSourceTypeName() const override; -}; - -class ZCutscene : public ZCutsceneBase +class ZCutscene : public ZResource { public: ZCutscene(ZFile* nParent); @@ -426,15 +17,20 @@ public: void ParseRawData() override; + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; + std::string GetBodySourceCode() const override; size_t GetRawDataSize() const override; + std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; - CutsceneCommands GetCommandFromID(int32_t id); - int32_t numCommands; int32_t endFrame; std::vector commands; + +protected: + CutsceneCommand* GetCommandOoT(uint32_t id, offset_t currentPtr) const; + CutsceneCommand* GetCommandMM(uint32_t id, offset_t currentPtr) const; }; diff --git a/tools/ZAPD/ZAPD/ZCutsceneMM.cpp b/tools/ZAPD/ZAPD/ZCutsceneMM.cpp deleted file mode 100644 index d0208bc07..000000000 --- a/tools/ZAPD/ZAPD/ZCutsceneMM.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "ZCutsceneMM.h" - -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" - -ZCutsceneMM::ZCutsceneMM(ZFile* nParent) : ZCutsceneBase(nParent) -{ -} - -ZCutsceneMM::~ZCutsceneMM() -{ - for (CutsceneCommand* cmd : commands) - delete cmd; -} - -std::string ZCutsceneMM::GetBodySourceCode() const -{ - std::string output; - - output += StringHelper::Sprintf(" CS_BEGIN_CUTSCENE(%i, %i),", numCommands, endFrame); - - for (size_t i = 0; i < data.size(); i++) - { - if ((i % 4) == 0) - output += "\n "; - output += StringHelper::Sprintf("0x%08X, ", data[i]); - } - - return output; -} - -size_t ZCutsceneMM::GetRawDataSize() const -{ - return 8 + data.size() * 4; -} - -void ZCutsceneMM::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - - numCommands = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); - commands = std::vector(); - - endFrame = BitConverter::ToInt32BE(rawData, rawDataIndex + 4); - uint32_t currentPtr = rawDataIndex + 8; - uint32_t lastData = 0; - - // TODO currently cutscenes aren't being parsed, so just consume words until we see an end - // marker. - do - { - lastData = BitConverter::ToInt32BE(rawData, currentPtr); - data.push_back(lastData); - currentPtr += 4; - } while (lastData != 0xFFFFFFFF); -} - -ZResourceType ZCutsceneMM::GetResourceType() const -{ - return ZResourceType::Cutscene; -} diff --git a/tools/ZAPD/ZAPD/ZCutsceneMM.h b/tools/ZAPD/ZAPD/ZCutsceneMM.h deleted file mode 100644 index 44b108d6c..000000000 --- a/tools/ZAPD/ZAPD/ZCutsceneMM.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include -#include -#include -#include "ZCutscene.h" -#include "ZFile.h" -#include "tinyxml2.h" - -class ZCutsceneMM : public ZCutsceneBase -{ -public: - ZCutsceneMM(ZFile* nParent); - virtual ~ZCutsceneMM(); - - std::string GetBodySourceCode() const override; - - size_t GetRawDataSize() const override; - - void ParseRawData() override; - ZResourceType GetResourceType() const override; - -protected: - int32_t numCommands; - int32_t endFrame; - std::vector commands; - - std::vector data; -}; diff --git a/tools/ZAPD/ZAPD/ZFile.cpp b/tools/ZAPD/ZAPD/ZFile.cpp index d9733f326..b81399e2a 100644 --- a/tools/ZAPD/ZAPD/ZFile.cpp +++ b/tools/ZAPD/ZAPD/ZFile.cpp @@ -695,7 +695,7 @@ bool ZFile::GetDeclarationArrayIndexedName(segptr_t segAddress, size_t elementSi return true; } -Declaration* ZFile::GetDeclaration(uint32_t address) const +Declaration* ZFile::GetDeclaration(offset_t address) const { if (declarations.find(address) != declarations.end()) return declarations.at(address); @@ -703,7 +703,7 @@ Declaration* ZFile::GetDeclaration(uint32_t address) const return nullptr; } -Declaration* ZFile::GetDeclarationRanged(uint32_t address) const +Declaration* ZFile::GetDeclarationRanged(offset_t address) const { for (const auto decl : declarations) { @@ -714,7 +714,7 @@ Declaration* ZFile::GetDeclarationRanged(uint32_t address) const return nullptr; } -bool ZFile::HasDeclaration(uint32_t address) +bool ZFile::HasDeclaration(offset_t address) { assert(GETSEGNUM(address) == 0); return declarations.find(address) != declarations.end(); diff --git a/tools/ZAPD/ZAPD/ZFile.h b/tools/ZAPD/ZAPD/ZFile.h index 365c7bbbb..275e27f1b 100644 --- a/tools/ZAPD/ZAPD/ZFile.h +++ b/tools/ZAPD/ZAPD/ZFile.h @@ -81,9 +81,9 @@ public: const std::string& expectedType, std::string& declName) const; - Declaration* GetDeclaration(uint32_t address) const; - Declaration* GetDeclarationRanged(uint32_t address) const; - bool HasDeclaration(uint32_t address); + Declaration* GetDeclaration(offset_t address) const; + Declaration* GetDeclarationRanged(offset_t address) const; + bool HasDeclaration(offset_t address); std::string GetHeaderInclude() const; std::string GetZRoomHeaderInclude() const; diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp index e51e550b0..3820203ef 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp @@ -10,53 +10,65 @@ SetCutscenes::SetCutscenes(ZFile* nParent) : ZRoomCommand(nParent) { } -SetCutscenes::~SetCutscenes() -{ - for (ZCutsceneBase* cutscene : cutscenes) - delete cutscene; -} - void SetCutscenes::ParseRawData() { ZRoomCommand::ParseRawData(); - std::string output; numCutscenes = cmdArg1; - if (Globals::Instance->game == ZGame::OOT_RETAIL || Globals::Instance->game == ZGame::OOT_SW97) - { - ZCutscene* cutscene = new ZCutscene(parent); - cutscene->ExtractFromFile(segmentOffset); - auto decl = parent->GetDeclaration(segmentOffset); - if (decl == nullptr) - { - cutscene->DeclareVar(zRoom->GetName().c_str(), ""); - } - - cutscenes.push_back(cutscene); - } - else + if (Globals::Instance->game == ZGame::MM_RETAIL) { int32_t currentPtr = segmentOffset; - std::string declaration; for (uint8_t i = 0; i < numCutscenes; i++) { CutsceneEntry entry(parent->GetRawData(), currentPtr); cutsceneEntries.push_back(entry); currentPtr += 8; + } + } +} - // TODO: don't hardcode %sCutsceneData_%06X, look up for the declared name instead - declaration += StringHelper::Sprintf( - " { %sCutsceneData_%06X, 0x%04X, 0x%02X, 0x%02X },", zRoom->GetName().c_str(), - entry.segmentOffset, entry.exit, entry.entrance, entry.flag); +void SetCutscenes::DeclareReferences(const std::string& prefix) +{ + std::string varPrefix = name; + if (varPrefix == "") + varPrefix = prefix; - if (i < numCutscenes - 1) + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + std::string declaration; + size_t i = 0; + + for (const auto& entry : cutsceneEntries) + { + if (entry.segmentPtr != SEGMENTED_NULL && + GETSEGNUM(entry.segmentPtr) == parent->segment) + { + offset_t csOffset = Seg2Filespace(entry.segmentPtr, parent->baseAddress); + if (!parent->HasDeclaration(csOffset)) + { + auto* cutscene = new ZCutscene(parent); + cutscene->ExtractFromFile(csOffset); + cutscene->SetName(cutscene->GetDefaultName(varPrefix)); + cutscene->DeclareVar(varPrefix, ""); + cutscene->DeclareReferences(varPrefix); + parent->AddResource(cutscene); + } + } + + std::string csName; + Globals::Instance->GetSegmentedPtrName(entry.segmentPtr, parent, "CutsceneData", + csName); + + declaration += + StringHelper::Sprintf(" { %s, 0x%04X, 0x%02X, 0x%02X },", csName.c_str(), + entry.exit, entry.entrance, entry.flag); + + if (i + 1 < numCutscenes) declaration += "\n"; - ZCutsceneMM* cutscene = new ZCutsceneMM(parent); - cutscene->ExtractFromFile(entry.segmentOffset); - cutscenes.push_back(cutscene); + i++; } parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, @@ -65,19 +77,19 @@ void SetCutscenes::ParseRawData() zRoom->GetName().c_str(), segmentOffset), cutsceneEntries.size(), declaration); } - - for (ZCutsceneBase* cutscene : cutscenes) + else { - if (cutscene->GetRawDataIndex() != 0) + if (cmdArg2 != SEGMENTED_NULL && GETSEGNUM(cmdArg2) == parent->segment) { - Declaration* decl = parent->GetDeclaration(cutscene->GetRawDataIndex()); - if (decl == nullptr) + offset_t csOffset = Seg2Filespace(cmdArg2, parent->baseAddress); + if (!parent->HasDeclaration(csOffset)) { - cutscene->GetSourceOutputCode(zRoom->GetName()); - } - else if (decl->text == "") - { - decl->text = cutscene->GetBodySourceCode(); + auto* cutscene = new ZCutscene(parent); + cutscene->ExtractFromFile(csOffset); + cutscene->SetName(cutscene->GetDefaultName(varPrefix)); + cutscene->DeclareVar(varPrefix, ""); + cutscene->DeclareReferences(varPrefix); + parent->AddResource(cutscene); } } } @@ -86,11 +98,15 @@ void SetCutscenes::ParseRawData() std::string SetCutscenes::GetBodySourceCode() const { std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneData", listName); if (Globals::Instance->game == ZGame::MM_RETAIL) + { + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneEntry", listName); return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_LIST(%i, %s)", numCutscenes, listName.c_str()); + } + + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneData", listName); return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_DATA(%s)", listName.c_str()); } @@ -105,7 +121,7 @@ RoomCommand SetCutscenes::GetRoomCommand() const } CutsceneEntry::CutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex) - : segmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 0))), + : segmentPtr(BitConverter::ToInt32BE(rawData, rawDataIndex + 0)), exit(BitConverter::ToInt16BE(rawData, rawDataIndex + 4)), entrance(rawData[rawDataIndex + 6]), flag(rawData[rawDataIndex + 7]) { diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h index ad032bbe6..81a622c5b 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h @@ -1,7 +1,6 @@ #pragma once #include "ZCutscene.h" -#include "ZCutsceneMM.h" #include "ZRoom/ZRoomCommand.h" class CutsceneEntry @@ -9,7 +8,7 @@ class CutsceneEntry public: CutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex); - uint32_t segmentOffset; + segptr_t segmentPtr; uint16_t exit; uint8_t entrance; uint8_t flag; @@ -18,14 +17,13 @@ public: class SetCutscenes : public ZRoomCommand { public: - std::vector cutscenes; std::vector cutsceneEntries; // (MM Only) uint8_t numCutscenes; // (MM Only) SetCutscenes(ZFile* nParent); - ~SetCutscenes(); void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; std::string GetBodySourceCode() const override; diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp index 7027fa1f9..20138dd4d 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp @@ -104,9 +104,8 @@ std::string RomFile::GetBodySourceCode() const if (!isFirst) declaration += "\n"; - declaration += - StringHelper::Sprintf("\t{ (u32)_%sSegmentRomStart, (u32)_%sSegmentRomEnd },", - roomName.c_str(), roomName.c_str()); + declaration += StringHelper::Sprintf("\t{ _%sSegmentRomStart, _%sSegmentRomEnd },", + roomName.c_str(), roomName.c_str()); isFirst = false; } } diff --git a/tools/ZAPD/ZAPD/ZSkeleton.cpp b/tools/ZAPD/ZAPD/ZSkeleton.cpp index ff4333129..b3f7ce8c0 100644 --- a/tools/ZAPD/ZAPD/ZSkeleton.cpp +++ b/tools/ZAPD/ZAPD/ZSkeleton.cpp @@ -159,8 +159,8 @@ std::string ZSkeleton::GetBodySourceCode() const return StringHelper::Sprintf("\n\t%s, %s\n", limbArrayName.c_str(), countStr.c_str()); case ZSkeletonType::Flex: - return StringHelper::Sprintf("\n\t{ %s, %s }, %i\n", limbArrayName.c_str(), countStr.c_str(), - dListCount); + return StringHelper::Sprintf("\n\t{ %s, %s }, %i\n", limbArrayName.c_str(), + countStr.c_str(), dListCount); } // TODO: Throw exception? diff --git a/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h b/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h index 98c46bc79..ac82c24ca 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h +++ b/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include From 9582a3e79faea8773451f9d43080ac79cb9ae075 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Tue, 29 Mar 2022 08:19:59 -0700 Subject: [PATCH 144/257] Update Readme (#765) * Update * Update MacOS instructions * forgot . * New python step * typo --- README.md | 30 ++++++++++++++++++++---------- docs/BUILDING_MACOS.md | 2 +- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 845a10cc6..c3ce27e97 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ We recommend using Debian or Ubuntu 20.04 Linux distributions. ### MacOS -Preparation is covered in a [separate document](docsBUILDING_MACOS.md). +Preparation is covered in a [separate document](docs/BUILDING_MACOS.md). ### Linux (Native or under WSL / VM) @@ -74,13 +74,7 @@ sudo apt update sudo apt install make git build-essential binutils-mips-linux-gnu python3 python3-pip libpng-dev ``` -To install the Python dependencies simply run in a terminal: - -```bash -python3 -m pip install -r requirements.txt -``` - -#### 2. Fork the repository +#### 2. Clone the repository Create your own fork of the repository at `https://github.com/zeldaret/mm`. Then clone your fork where you wish to have the project, with the command: @@ -88,11 +82,27 @@ Create your own fork of the repository at `https://github.com/zeldaret/mm`. Then git clone https://github.com//mm.git ``` -#### 3. Prepare a base ROM +This will copy the GitHub repository contents into a new folder in the current directory called `mm`. Change into this directory before doing anything else: + +```bash +cd mm +``` + +#### 3. Install python dependencies + +The build process has a few python packages required that are located in `requirements.txt`. + +To install them simply run in a terminal: + +```bash +python3 -m pip install -r requirements.txt +``` + +#### 4. Prepare a base ROM Copy your ROM to inside the root of this new project directory, and rename the file of the baserom to reflect the version of ROM you are using. ex: `baserom.mm.us.rev1.z64` -#### 4. Make and Build the ROM +#### 5. Make and Build the ROM To start the extraction/build process, run the following command: diff --git a/docs/BUILDING_MACOS.md b/docs/BUILDING_MACOS.md index 17b683442..77f1d839e 100644 --- a/docs/BUILDING_MACOS.md +++ b/docs/BUILDING_MACOS.md @@ -80,4 +80,4 @@ If this worked, you can now delete the temporary directory `~/binutils-tmp`. Apple's version of `make` is very out-of-date, so you should use the brew-installed `gmake` in place of `make` in this repo from now on. -You should now be able to continue from [step 2](README.md#2-clone-the-repository) of the Linux instructions. +You should now be able to continue from [step 2](../README.md#2-clone-the-repository) of the Linux instructions. From b567c4ee686d8afef5fd9ce501b47a10ceb28510 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 16:29:34 +0100 Subject: [PATCH 145/257] En_Hs (#746) * En_Hs * Add limb switch * Merge --- spec | 3 +- src/overlays/actors/ovl_En_Hs/z_en_hs.c | 322 ++++++++++++++++++++++-- src/overlays/actors/ovl_En_Hs/z_en_hs.h | 15 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 5 - 5 files changed, 313 insertions(+), 36 deletions(-) diff --git a/spec b/spec index fd7ffe007..4eb2ae3d6 100644 --- a/spec +++ b/spec @@ -1589,8 +1589,7 @@ beginseg name "ovl_En_Hs" compress include "build/src/overlays/actors/ovl_En_Hs/z_en_hs.o" - include "build/data/ovl_En_Hs/ovl_En_Hs.data.o" - include "build/data/ovl_En_Hs/ovl_En_Hs.reloc.o" + include "build/src/overlays/actors/ovl_En_Hs/ovl_En_Hs_reloc.o" endseg beginseg 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 70c021d0e..8bc720489 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -23,7 +23,6 @@ void func_809532D0(EnHs* this, GlobalContext* globalCtx); void func_80953354(EnHs* this, GlobalContext* globalCtx); void func_8095345C(EnHs* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Hs_InitVars = { ACTOR_EN_HS, ACTORCAT_NPC, @@ -36,51 +35,322 @@ const ActorInit En_Hs_InitVars = { (ActorFunc)EnHs_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80953910 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 40, 40, 0, { 0, 0, 0 } }, }; -#endif +Vec3f D_8095393C = { 300.0f, 1000.0f, 0.0f }; -extern ColliderCylinderInit D_80953910; +void func_80952C50(EnHs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; -extern UNK_TYPE D_060005C0; + for (i = 0; i < ARRAY_COUNT(this->unk_2A4); i++) { + Math_Vec3f_Copy(&this->unk_2A4[i], &player->actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952C50.s") + this->actor.home.rot.x = 0; + this->actor.home.rot.z = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/EnHs_Init.s") +void EnHs_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/EnHs_Destroy.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_hs_Skel_006260, &object_hs_Anim_0005C0, this->jointTable, + this->morphTable, OBJECT_HS_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &object_hs_Anim_0005C0); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_8095345C; + if (globalCtx->curSpawn == 1) { + this->actor.flags |= ACTOR_FLAG_10000; + } + this->unk_2A0 = 0; + this->actor.targetMode = 6; + func_80952C50(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952DFC.s") +void EnHs_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952E50.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952F00.s") +void func_80952DFC(GlobalContext* globalCtx) { + if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { + func_80151BB4(globalCtx, 0x2E); + } + func_80151BB4(globalCtx, 0x10); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952FE0.s") +void func_80952E50(Vec3f* dst, Vec3f src, f32 arg2) { + Vec3f sp1C; + f32 temp_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80953098.s") + Math_Vec3f_Diff(&src, dst, &sp1C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80953180.s") + temp_f0 = SQ(sp1C.x) + SQ(sp1C.z); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_809532C0.s") + if (SQ(arg2) > temp_f0) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_809532D0.s") + temp_f0 = sqrtf(temp_f0); + sp1C.x *= (temp_f0 - arg2) / temp_f0; + sp1C.z *= (temp_f0 - arg2) / temp_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80953354.s") + dst->x += sp1C.x; + dst->z += sp1C.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_809533A0.s") +void func_80952F00(EnHs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + f32 phi_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_8095345C.s") + if (this->actor.home.rot.z >= 20) { + phi_f20 = 15.0f; + } else { + phi_f20 = 10.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/EnHs_Update.s") + func_80952E50(&this->unk_2A4[0], player->actor.world.pos, phi_f20); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_8095376C.s") + for (i = 1; i < ARRAY_COUNT(this->unk_2A4); i++) { + func_80952E50(&this->unk_2A4[i], this->unk_2A4[i - 1], phi_f20); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80953848.s") +void func_80952FE0(EnHs* this, GlobalContext* globalCtx) { + if (this->unk_2A2 < 40) { + Math_SmoothStepToS(&this->unk_294.y, 0x1F40, 6, 0x1838, 0x64); + } else if (this->unk_2A2 < 80) { + Math_SmoothStepToS(&this->unk_294.y, -0x1F40, 6, 0x1838, 0x64); + } else { + this->actionFunc = func_80953180; + this->unk_2A0 &= ~4; + func_80151938(globalCtx, 0x33F6); + func_80952DFC(globalCtx); + } + this->unk_2A2++; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/EnHs_Draw.s") +void func_80953098(EnHs* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = func_8095345C; + this->actor.flags |= ACTOR_FLAG_10000; + this->unk_2A0 |= 0x10; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } else { + this->unk_2A0 |= 8; + if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 10000.0f, 50.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_MASK_BUNNY, 10000.0f, 50.0f); + } + } +} + +void func_80953180(EnHs* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x33F4: + case 0x33F6: + func_801477B4(globalCtx); + this->actionFunc = func_8095345C; + break; + + case 0x33F7: + this->actor.flags &= ~ACTOR_FLAG_10000; + func_801477B4(globalCtx); + this->actionFunc = func_80953098; + func_80953098(this, globalCtx); + break; + + case 0x33F9: + this->actor.flags &= ~ACTOR_FLAG_10000; + func_801477B4(globalCtx); + this->actionFunc = func_8095345C; + break; + + case 0x33F5: + globalCtx->msgCtx.unk11F10 = 0; + this->actionFunc = func_80952FE0; + this->unk_2A2 = 0; + this->unk_294.z = 0; + this->unk_2A0 |= 4; + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_8095345C; + break; + } + } +} + +void func_809532C0(EnHs* this, GlobalContext* globalCtx) { +} + +void func_809532D0(EnHs* this, GlobalContext* globalCtx) { + if (DECR(this->unk_2A2) == 0) { + globalCtx->nextEntranceIndex = globalCtx->setupExitList[ENHS_GET_F(&this->actor)]; + globalCtx->sceneLoadFlag = 0x14; + gSaveContext.save.weekEventReg[25] |= 8; + this->actionFunc = func_809532C0; + } +} + +void func_80953354(EnHs* this, GlobalContext* globalCtx) { + if (!func_801690CC(globalCtx)) { + func_800B7298(globalCtx, &this->actor, 7); + this->actionFunc = func_809532D0; + } +} + +void func_809533A0(EnHs* this, GlobalContext* globalCtx) { + u16 sp1E; + + if ((globalCtx->curSpawn == 1) && !(this->unk_2A0 & 0x20)) { + sp1E = 0x33F7; + this->unk_2A0 |= 0x20; + } else if (this->unk_2A0 & 0x10) { + sp1E = 0x33F9; + this->unk_2A0 &= ~0x10; + } else if (gSaveContext.save.weekEventReg[25] & 8) { + sp1E = 0x33F4; + } else { + sp1E = 0x33F5; + } + + Message_StartTextbox(globalCtx, sp1E, &this->actor); + + if (sp1E == 0x33F4) { + func_80952DFC(globalCtx); + } +} + +void func_8095345C(EnHs* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80953180; + func_809533A0(this, globalCtx); + if (this->unk_2A0 & 8) { + func_80952DFC(globalCtx); + this->unk_2A0 &= ~8; + } + } else if (this->actor.home.rot.x >= 20) { + this->actionFunc = func_80953354; + this->unk_2A2 = 40; + } else if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_10000) { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + this->unk_2A0 |= 1; + } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x2000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 130.0f); + this->unk_2A0 |= 1; + } else { + this->unk_2A0 &= ~1; + } +} + +void EnHs_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHs* this = THIS; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + if (SkelAnime_Update(&this->skelAnime)) { + this->skelAnime.curFrame = 0.0f; + } + + this->actionFunc(this, globalCtx); + + func_80952F00(this, globalCtx); + + if (this->unk_2A0 & 4) { + Math_SmoothStepToS(&this->unk_294.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_29A.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_29A.y, 0, 6, 0x1838, 0x64); + } else if (this->unk_2A0 & 1) { + func_800E9250(globalCtx, &this->actor, &this->unk_294, &this->unk_29A, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_294.x, 0x3200, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_294.y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_29A.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_29A.y, 0, 6, 0x1838, 0x64); + } +} + +s32 EnHs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnHs* this = THIS; + + switch (limbIndex) { + case OBJECT_HS_LIMB_09: + rot->x += this->unk_294.y; + rot->z += this->unk_294.x; + break; + + case OBJECT_HS_LIMB_0A: + rot->x += this->unk_294.y; + rot->z += this->unk_294.x; + break; + + case OBJECT_HS_LIMB_0B: + *dList = NULL; + return false; + + case OBJECT_HS_LIMB_0C: + if (this->actor.params == ENHS_1) { + *dList = NULL; + return false; + } + break; + + case OBJECT_HS_LIMB_0D: + if (this->actor.params == ENHS_1) { + *dList = NULL; + return false; + } + break; + } + return false; +} + +void EnHs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnHs* this = THIS; + + if (limbIndex == OBJECT_HS_LIMB_09) { + Matrix_MultiplyVector3fByState(&D_8095393C, &this->actor.focus.pos); + } +} + +void EnHs_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHs* this = THIS; + + func_8012C5B0(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnHs_OverrideLimbDraw, EnHs_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.h b/src/overlays/actors/ovl_En_Hs/z_en_hs.h index b9442c03d..0a50ee360 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.h +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.h @@ -2,14 +2,27 @@ #define Z_EN_HS_H #include "global.h" +#include "objects/object_hs/object_hs.h" struct EnHs; typedef void (*EnHsActionFunc)(struct EnHs*, GlobalContext*); +#define ENHS_GET_F(thisx) ((thisx)->params & 0xF) + +#define ENHS_1 1 + typedef struct EnHs { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x250]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; + /* 0x01D4 */ Vec3s jointTable[OBJECT_HS_LIMB_MAX]; + /* 0x0234 */ Vec3s morphTable[OBJECT_HS_LIMB_MAX]; + /* 0x0294 */ Vec3s unk_294; + /* 0x029A */ Vec3s unk_29A; + /* 0x02A0 */ u16 unk_2A0; + /* 0x02A2 */ s16 unk_2A2; + /* 0x02A4 */ Vec3f unk_2A4[20]; /* 0x0394 */ EnHsActionFunc actionFunc; } EnHs; // size = 0x398 diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 8c6a53946..87bc6d1e8 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -7652,8 +7652,8 @@ 0x809533A0:("func_809533A0",), 0x8095345C:("func_8095345C",), 0x8095359C:("EnHs_Update",), - 0x8095376C:("func_8095376C",), - 0x80953848:("func_80953848",), + 0x8095376C:("EnHs_OverrideLimbDraw",), + 0x80953848:("EnHs_PostLimbDraw",), 0x80953888:("EnHs_Draw",), 0x80953A90:("BgIngate_FindActor",), 0x80953B40:("func_80953B40",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 3112afc65..57a107e9f 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1294,11 +1294,6 @@ D_060150D8 = 0x060150D8; D_06002F98 = 0x06002F98; D_0600A480 = 0x0600A480; -// ovl_En_Hs - -D_060005C0 = 0x060005C0; -D_06006260 = 0x06006260; - // ovl_En_Ik D_06000CE8 = 0x06000CE8; From f187471a332d256eba86e15fecbdc96084f6fe18 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 16:46:40 +0100 Subject: [PATCH 146/257] En_Fu_Mato (#675) * En_Fu_Mato * A bit of fmt * PR * PR * Merge --- spec | 3 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 3 +- .../actors/ovl_En_Fu_Mato/z_en_fu_mato.c | 459 ++++++++++++++++-- .../actors/ovl_En_Fu_Mato/z_en_fu_mato.h | 25 +- undefined_syms.txt | 5 - 5 files changed, 456 insertions(+), 39 deletions(-) diff --git a/spec b/spec index 4eb2ae3d6..82a48366f 100644 --- a/spec +++ b/spec @@ -3500,8 +3500,7 @@ beginseg name "ovl_En_Fu_Mato" compress include "build/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.o" - include "build/data/ovl_En_Fu_Mato/ovl_En_Fu_Mato.data.o" - include "build/data/ovl_En_Fu_Mato/ovl_En_Fu_Mato.reloc.o" + include "build/src/overlays/actors/ovl_En_Fu_Mato/ovl_En_Fu_Mato_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index ba83b5f23..b67a3080e 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -4,12 +4,11 @@ * Description: Honey & Darling */ +#include "z_en_fu.h" #include "overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h" #include "overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h" -#include "overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h" #include "overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.h" #include "overlays/actors/ovl_En_Bom/z_en_bom.h" -#include "z_en_fu.h" #include "objects/object_mu/object_mu.h" #include "objects/gameplay_keep/gameplay_keep.h" diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c index fb4fc2a45..ec0209729 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c @@ -5,6 +5,8 @@ */ #include "z_en_fu_mato.h" +#include "overlays/actors/ovl_En_Fu/z_en_fu.h" +#include "objects/object_fu_mato/object_fu_mato.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +17,15 @@ void EnFuMato_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFuMato_Update(Actor* thisx, GlobalContext* globalCtx); void EnFuMato_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80ACE4B4(EnFuMato* this); +void func_80ACE4C8(EnFuMato* this, GlobalContext* globalCtx); +void func_80ACE508(EnFuMato* this); +void func_80ACE51C(EnFuMato* this, GlobalContext* globalCtx); +void func_80ACE718(EnFuMato* this, GlobalContext* globalCtx); +void func_80ACECFC(EnFuMato* this, GlobalContext* globalCtx); +void func_80ACEFC4(EnFuMato* this); +void func_80ACEFD8(EnFuMato* this, GlobalContext* globalCtx); + const ActorInit En_Fu_Mato_InitVars = { ACTOR_EN_FU_MATO, ACTORCAT_BG, @@ -28,52 +38,447 @@ const ActorInit En_Fu_Mato_InitVars = { (ActorFunc)EnFuMato_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80ACF610 = { - { COLTYPE_HIT3, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK4, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_HIT3, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK4, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 200 }, 100 }, }; -#endif +Gfx* D_80ACF63C[] = { + object_fu_mato_DL_001C80, object_fu_mato_DL_001D68, object_fu_mato_DL_001E50, + object_fu_mato_DL_001F38, object_fu_mato_DL_002020, object_fu_mato_DL_002108, +}; -extern ColliderSphereInit D_80ACF610; +Vec2f D_80ACF654[] = { + { -1.0f, -1.73f }, { 1.0f, -1.73f }, { 2.0f, 0.0f }, { 1.0f, 1.73f }, { -1.0f, 1.73f }, { -2.0f, 0.0f }, +}; -extern UNK_TYPE D_060023D4; -extern UNK_TYPE D_06002720; +void EnFuMato_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFuMato* this = THIS; + CollisionHeader* sp2C = NULL; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; + EnFu* fu; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/EnFuMato_Init.s") + DynaPolyActor_Init(&this->dyna, 3); + CollisionHeader_GetVirtual(&object_fu_mato_Colheader_0023D4, &sp2C); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp2C); + Actor_SetScale(&this->dyna.actor, 0.1f); + Collider_InitSphere(globalCtx, &this->collider); + Collider_SetSphere(globalCtx, &this->collider, &this->dyna.actor, &sSphereInit); + this->collider.dim.worldSphere.radius = 20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/EnFuMato_Destroy.s") + while (actor != NULL) { + if (actor->id == ACTOR_EN_FU) { + this->dyna.actor.parent = actor; + break; + } + actor = actor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE4B4.s") + if (actor == NULL) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE4C8.s") + fu = (EnFu*)this->dyna.actor.parent; + if (fu->unk_542 == 2) { + this->collider.info.elemType = ELEMTYPE_UNK0; + this->collider.dim.worldSphere.radius = 30; + } else { + this->collider.dim.worldSphere.radius = 17; + this->unk_2F8 = fu->unk_538; + this->unk_2F4 = fu->unk_520; + this->unk_2F0 = ENFUMATO_GET(&this->dyna.actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE508.s") + this->unk_302 = 0; + this->unk_304 = 0; + func_80ACE4B4(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE51C.s") +void EnFuMato_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFuMato* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE680.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroySphere(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE718.s") +void func_80ACE4B4(EnFuMato* this) { + this->actionFunc = func_80ACE4C8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE850.s") +void func_80ACE4C8(EnFuMato* this, GlobalContext* globalCtx) { + EnFu* fu = (EnFu*)this->dyna.actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACEB2C.s") + if ((fu->unk_54A == 0) && (fu->unk_542 == 0)) { + func_80ACE508(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACECFC.s") +void func_80ACE508(EnFuMato* this) { + this->actionFunc = func_80ACE51C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACEFC4.s") +void func_80ACE51C(EnFuMato* this, GlobalContext* globalCtx) { + EnFu* fu = (EnFu*)this->dyna.actor.parent; + Vec3f sp30; + f32 sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACEFD8.s") + sp30.x = this->unk_2F8[this->unk_2F0].x; + sp30.y = this->unk_2F8[this->unk_2F0].y; + sp30.z = this->unk_2F8[this->unk_2F0].z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACF04C.s") + sp2C = Math_Vec3f_DistXZ(&this->dyna.actor.world.pos, &sp30); + this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &sp30); + this->dyna.actor.world.rot.x = Math_Vec3f_Pitch(&this->dyna.actor.world.pos, &sp30); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/EnFuMato_Update.s") + if (sp2C < 10.0f) { + if (this->unk_2F0 < (this->unk_2F4 - 1)) { + this->unk_2F0++; + } else { + this->unk_2F0 = 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACF1F4.s") + this->dyna.actor.speedXZ = 2.0f; + this->dyna.actor.shape.rot.y = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &this->dyna.actor.parent->world.pos); + Actor_MoveWithGravity(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACF3F4.s") + if (fu->unk_54A != 0) { + func_80ACE4B4(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/EnFuMato_Draw.s") +void func_80ACE680(EnFuMato* this) { + this->dyna.actor.gravity = -0.5f; + this->dyna.actor.velocity.y = 1.0f; + this->dyna.actor.velocity.x = 2.0f * Rand_Centered(); + this->dyna.actor.velocity.z = 2.0f * Rand_Centered(); + this->unk_2FC.x = Rand_Next() & 0xFFF; + this->unk_2FC.y = Rand_Next() & 0xFFF; + this->unk_2FC.z = Rand_Next() & 0xFFF; + this->unk_302 = 3; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODPLATE_BOUND); + this->actionFunc = func_80ACE718; +} + +void func_80ACE718(EnFuMato* this, GlobalContext* globalCtx) { + this->dyna.actor.shape.rot.x += this->unk_2FC.x; + this->dyna.actor.shape.rot.y += this->unk_2FC.y; + this->dyna.actor.shape.rot.z += this->unk_2FC.z; + this->dyna.actor.velocity.y += this->dyna.actor.gravity; + + Actor_UpdatePos(&this->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 15.0f, 30.0f, 60.0f, 5); + + if ((this->dyna.actor.bgCheckFlags & 1) || (this->dyna.actor.world.pos.y < -500.0f)) { + Vec3f sp3C = { 0.0f, 0.0f, 0.0f }; + Vec3f sp30 = { 0.0f, 2.0f, 0.0f }; + + func_800B3030(globalCtx, &this->dyna.actor.world.pos, &sp3C, &sp30, 20, 40, 2); + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void func_80ACE850(EnFuMato* this, GlobalContext* globalCtx) { + EnFuMatoStruct* ptr = this->unk_1B8; + s16 temp_s4 = this->dyna.actor.shape.rot.y; + s32 phi_s2; + s32 i; + + this->unk_308 = (u32)Rand_Next() % ARRAY_COUNT(this->unk_1B8); + this->unk_302 = 1; + this->dyna.actor.gravity = -1.0f; + this->dyna.actor.velocity.y = Rand_ZeroOne(); + + phi_s2 = this->unk_308; + + for (i = 0; i < 2; i++) { + ptr->unk_00 = this->dyna.actor.world.pos; + + ptr->unk_0C.x = Math_CosS(temp_s4) * D_80ACF654[phi_s2].x; + ptr->unk_0C.y = D_80ACF654[phi_s2].z; + ptr->unk_0C.z = -Math_SinS(temp_s4) * D_80ACF654[phi_s2].x; + + ptr->unk_0C.x += Rand_Centered(); + ptr->unk_0C.y += Rand_ZeroOne() * 0.5f; + ptr->unk_0C.z += Rand_Centered(); + + ptr->unk_18.x = 0.0f; + ptr->unk_18.y = -1.0f; + ptr->unk_18.z = 0.0f; + + ptr->unk_00.x += 9.0f * ptr->unk_0C.x; + ptr->unk_00.y += 9.0f * ptr->unk_0C.y; + ptr->unk_00.z += 9.0f * ptr->unk_0C.z; + + ptr->unk_24 = this->dyna.actor.shape.rot; + + ptr->unk_2A.x = (s16)Rand_Next() >> 6; + ptr->unk_2A.y = (s16)Rand_Next() >> 6; + ptr->unk_2A.z = (s16)Rand_Next() >> 6; + ptr->unk_30 = 1; + + phi_s2 = (phi_s2 + 3) % ARRAY_COUNT(this->unk_1B8); + ptr++; + } + + this->dyna.actor.freezeTimer = 2; + EffectSsHahen_SpawnBurst(globalCtx, &this->dyna.actor.world.pos, 13.0f, 0, 7, 8, 20, -1, 10, NULL); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODPLATE_BROKEN); + this->actionFunc = func_80ACECFC; +} + +void func_80ACEB2C(EnFuMato* this) { + EnFuMatoStruct sp18[2]; + s32 phi_v0 = this->unk_308; + s32 i; + s32 phi_v1; + s32 phi_a1; + + sp18[0] = this->unk_1B8[0]; + sp18[1] = this->unk_1B8[1]; + + for (i = 0; i < ARRAY_COUNT(sp18); i++) { + if (phi_v0 == 0) { + phi_v1 = 5; + } else { + phi_v1 = phi_v0 - 1; + } + + if (phi_v0 == 5) { + phi_a1 = 0; + } else { + phi_a1 = phi_v0 + 1; + } + + this->unk_1B8[phi_v0] = sp18[i]; + this->unk_1B8[phi_v1] = sp18[i]; + this->unk_1B8[phi_a1] = sp18[i]; + + phi_v0 = (phi_v0 + 3) % ARRAY_COUNT(this->unk_1B8); + } + + this->unk_302 = 2; + this->actionFunc = func_80ACECFC; +} + +void func_80ACECFC(EnFuMato* this, GlobalContext* globalCtx) { + EnFuMatoStruct* ptr = this->unk_1B8; + s32 phi_s3; + s32 i; + + this->dyna.actor.velocity.y += this->dyna.actor.gravity; + Actor_UpdatePos(&this->dyna.actor); + + if (this->dyna.actor.world.pos.y < -500.0f) { + this->dyna.actor.world.pos.y = -500.0f; + } + + if (this->unk_302 == 1) { + phi_s3 = 2; + } else { + phi_s3 = ARRAY_COUNT(this->unk_1B8); + } + + for (i = 0; i < phi_s3; i++, ptr++) { + ptr->unk_00.x += ptr->unk_0C.x; + ptr->unk_00.y += ptr->unk_0C.y; + ptr->unk_00.z += ptr->unk_0C.z; + + ptr->unk_0C.x += ptr->unk_18.x; + ptr->unk_0C.y += ptr->unk_18.y; + ptr->unk_0C.z += ptr->unk_18.z; + + ptr->unk_24.x += ptr->unk_2A.x; + ptr->unk_24.y += ptr->unk_2A.y; + ptr->unk_24.z += ptr->unk_2A.z; + + if ((this->unk_302 == 2) && (ptr->unk_30 == 1) && (ptr->unk_00.y < (this->dyna.actor.floorHeight + 10.0f))) { + if (ptr->unk_0C.y < 0.0f) { + ptr->unk_0C.y = -ptr->unk_0C.y; + } else { + ptr->unk_0C.y = ptr->unk_0C.y; + } + ptr->unk_0C.y *= 0.5f; + ptr->unk_0C.x *= (Rand_Centered() * 1.5f) + 2.0f; + ptr->unk_0C.z *= (Rand_Centered() * 1.5f) + 2.0f; + + ptr->unk_2A.x = (s16)Rand_Next() >> 5; + ptr->unk_2A.y = (s16)Rand_Next() >> 5; + ptr->unk_2A.z = (s16)Rand_Next() >> 5; + + ptr->unk_30 = 0; + } + } + + if (this->unk_302 == 1) { + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 15.0f, 30.0f, 60.0f, 5); + if (this->dyna.actor.bgCheckFlags & 1) { + func_80ACEB2C(this); + } + } + + if (this->unk_304 < 60) { + this->unk_304++; + } else { + func_80ACEFC4(this); + } +} + +void func_80ACEFC4(EnFuMato* this) { + this->actionFunc = func_80ACEFD8; +} + +void func_80ACEFD8(EnFuMato* this, GlobalContext* globalCtx) { + Vec3f* scale = &this->dyna.actor.scale; + + Math_SmoothStepToF(&scale->x, 0.0f, 0.1f, 0.005f, 0.005f); + scale->y = scale->z = scale->x; + if (scale->x == 0.0f) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +s32 func_80ACF04C(EnFuMato* this, GlobalContext* globalCtx) { + EnFu* fu = (EnFu*)this->dyna.actor.parent; + + this->collider.dim.worldSphere.center.x = this->dyna.actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->dyna.actor.world.pos.y; + this->collider.dim.worldSphere.center.z = this->dyna.actor.world.pos.z; + + if ((this->unk_302 == 0) && (((fu->unk_542 == 0) && (this->collider.base.acFlags & AC_HIT)) || + ((fu->unk_542 == 2) && (this->collider.base.ocFlags1 & OC1_HIT)))) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.ocFlags1 &= ~OC1_HIT; + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); + + fu->unk_548++; + if ((fu->unk_542 == 2) || (gSaveContext.save.playerForm == PLAYER_FORM_DEKU)) { + fu->unk_546 = 1; + func_80ACE680(this); + } else { + func_80ACE850(this, globalCtx); + } + return true; + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + return false; +} + +void EnFuMato_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFuMato* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80ACF04C(this, globalCtx); + + if (this->unk_30A == 1) { + func_80ACEFC4(this); + } +} + +void func_80ACF1F4(EnFuMato* this, GlobalContext* globalCtx) { + EnFuMatoStruct* ptr = this->unk_1B8; + s32 temp_s4 = this->unk_308; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < 2; i++) { + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_24); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4]); + + switch (temp_s4) { + case 0: + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[5]); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4 + 1]); + break; + + case 5: + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4 - 1]); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[0]); + break; + + default: + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4 - 1]); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4 + 1]); + break; + } + + Matrix_StatePop(); + + temp_s4 = (temp_s4 + 3) % ARRAY_COUNT(this->unk_1B8); + ptr++; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80ACF3F4(EnFuMato* this, GlobalContext* globalCtx) { + EnFuMatoStruct* ptr = this->unk_1B8; + Vec3f* scale = &this->dyna.actor.scale; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(D_80ACF63C); i++, ptr++) { + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_24); + Matrix_Scale(scale->x, scale->y, scale->z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[i]); + + Matrix_StatePop(); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFuMato_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFuMato* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if ((this->unk_302 == 0) || (this->unk_302 == 3)) { + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_002720); + } else if (this->unk_302 == 1) { + func_80ACF1F4(this, globalCtx); + } else { + func_80ACF3F4(this, globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h index 51dbf177f..5666b71fc 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h @@ -7,11 +7,30 @@ struct EnFuMato; typedef void (*EnFuMatoActionFunc)(struct EnFuMato*, GlobalContext*); +#define ENFUMATO_GET(thisx) ((thisx)->params) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ Vec3s unk_24; + /* 0x2A */ Vec3s unk_2A; + /* 0x30 */ s16 unk_30; +} EnFuMatoStruct; // size = 0x34 + typedef struct EnFuMato { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ EnFuMatoActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x1AA]; + /* 0x0160 */ ColliderSphere collider; + /* 0x01B8 */ EnFuMatoStruct unk_1B8[6]; + /* 0x02F0 */ s32 unk_2F0; + /* 0x02F4 */ s32 unk_2F4; + /* 0x02F8 */ Vec3s* unk_2F8; + /* 0x02FC */ Vec3s unk_2FC; + /* 0x0302 */ s16 unk_302; + /* 0x0304 */ s16 unk_304; + /* 0x0306 */ UNK_TYPE1 unk306[2]; + /* 0x0308 */ s16 unk_308; /* 0x030A */ s16 unk_30A; } EnFuMato; // size = 0x30C diff --git a/undefined_syms.txt b/undefined_syms.txt index 57a107e9f..85bf81bf9 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1236,11 +1236,6 @@ D_0600007C = 0x0600007C; D_0600CFE0 = 0x0600CFE0; D_06011058 = 0x06011058; -// ovl_En_Fu_Mato - -D_060023D4 = 0x060023D4; -D_06002720 = 0x06002720; - // ovl_En_Ge1 D_06002B98 = 0x06002B98; From e19705f7eb5859531bf8c9790932a87b9e3eed05 Mon Sep 17 00:00:00 2001 From: Parker Burnett Date: Tue, 29 Mar 2022 11:55:29 -0400 Subject: [PATCH 147/257] En_crow OK and Documented (#698) * this is the guay * do you know the guay? * No guay! * got too excited to pr lol, fixes are here * Majoras Mask: No Guay Home * fixing objects * 4mattt --- assets/xml/objects/object_crow.xml | 40 +- spec | 3 +- src/overlays/actors/ovl_En_Crow/z_en_crow.c | 519 ++++++++++++++++-- src/overlays/actors/ovl_En_Crow/z_en_crow.h | 16 +- .../actors/ovl_En_Ruppecrow/z_en_ruppecrow.c | 8 +- .../actors/ovl_En_Ruppecrow/z_en_ruppecrow.h | 6 +- .../ovl_En_Syateki_Crow/z_en_syateki_crow.c | 16 +- tools/disasm/functions.txt | 32 +- 8 files changed, 538 insertions(+), 102 deletions(-) diff --git a/assets/xml/objects/object_crow.xml b/assets/xml/objects/object_crow.xml index 3092d91ec..de51da580 100644 --- a/assets/xml/objects/object_crow.xml +++ b/assets/xml/objects/object_crow.xml @@ -1,24 +1,24 @@  - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index 82a48366f..3fb3af904 100644 --- a/spec +++ b/spec @@ -2156,8 +2156,7 @@ beginseg name "ovl_En_Crow" compress include "build/src/overlays/actors/ovl_En_Crow/z_en_crow.o" - include "build/data/ovl_En_Crow/ovl_En_Crow.data.o" - include "build/data/ovl_En_Crow/ovl_En_Crow.reloc.o" + include "build/src/overlays/actors/ovl_En_Crow/ovl_En_Crow_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.c b/src/overlays/actors/ovl_En_Crow/z_en_crow.c index 8293ddd94..bf77b1897 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.c +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.c @@ -15,14 +15,18 @@ void EnCrow_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnCrow_Update(Actor* thisx, GlobalContext* globalCtx); void EnCrow_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_8099AC8C(EnCrow* this, GlobalContext* globalCtx); -void func_8099B0CC(EnCrow* this, GlobalContext* globalCtx); -void func_8099B584(EnCrow* this, GlobalContext* globalCtx); -void func_8099B6C4(EnCrow* this, GlobalContext* globalCtx); -void func_8099B838(EnCrow* this, GlobalContext* globalCtx); -void func_8099B9E8(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_SetupFlyIdle(EnCrow* this); +void EnCrow_FlyIdle(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_SetupDiveAttack(EnCrow* this); +void EnCrow_DiveAttack(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_CheckIfFrozen(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_Damaged(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_SetupDie(EnCrow* this); +void EnCrow_Die(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_SetupRespawn(EnCrow* this); +void EnCrow_TurnAway(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_Respawn(EnCrow* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Crow_InitVars = { ACTOR_EN_CROW, ACTORCAT_ENEMY, @@ -35,25 +39,36 @@ const ActorInit En_Crow_InitVars = { (ActorFunc)EnCrow_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8099C070[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8099C094 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_8099C070, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_8099C0A4 = { 1, 15, 30, 30 }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 30, 30 }; -// static DamageTable sDamageTable = { -static DamageTable D_8099C0AC = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -88,60 +103,470 @@ static DamageTable D_8099C0AC = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8099C0D0[] = { +static s32 D_8099C0CC = 0; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), ICHAIN_S8(hintId, 88, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -#endif +void EnCrow_Init(Actor* thisx, GlobalContext* globalCtx) { + EnCrow* this = THIS; -extern ColliderJntSphElementInit D_8099C070[1]; -extern ColliderJntSphInit D_8099C094; -extern CollisionCheckInfoInit D_8099C0A4; -extern DamageTable D_8099C0AC; -extern InitChainEntry D_8099C0D0[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, + OBJECT_CROW_LIMB_MAX); + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderItems); + this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); + D_8099C0CC = 0; + if (this->actor.parent != NULL) { + this->actor.flags &= ~ACTOR_FLAG_1; + } + EnCrow_SetupFlyIdle(this); +} -extern UNK_TYPE D_060000F0; +void EnCrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnCrow* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/EnCrow_Init.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/EnCrow_Destroy.s") +void EnCrow_SetupFlyIdle(EnCrow* this) { + this->timer = 100; + this->collider.base.acFlags |= AC_ON; + this->actionFunc = EnCrow_FlyIdle; + this->skelAnime.playSpeed = 1.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099AC58.s") +void EnCrow_FlyIdle(EnCrow* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 dist; + s32 onInitialAnimFrame; + s16 yaw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099AC8C.s") + SkelAnime_Update(&this->skelAnime); + onInitialAnimFrame = Animation_OnFrame(&this->skelAnime, 0.0f); + this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 3.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B098.s") + if ((this->actor.parent != NULL) && (this->actor.parent->home.rot.z == 0)) { + this->actor.home.pos.x = this->actor.parent->world.pos.x; + this->actor.home.pos.z = this->actor.parent->world.pos.z; + dist = Actor_XZDistanceToPoint(&this->actor, &this->actor.parent->world.pos); + } else { + dist = 450.0f; + this->actor.flags |= ACTOR_FLAG_1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B0CC.s") + if (this->actor.bgCheckFlags & 8) { + this->aimRotY = this->actor.wallYaw; + } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 300.0f) { + this->aimRotY = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B318.s") + if ((Math_SmoothStepToS(&this->actor.shape.rot.y, this->aimRotY, 5, 0x300, 0x10) == 0) && onInitialAnimFrame && + (Rand_ZeroOne() < 0.1f)) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B384.s") + yaw = (Actor_YawToPoint(&this->actor, &this->actor.home.pos) - this->actor.shape.rot.y); + if (yaw > 0) { + this->aimRotY += Rand_S16Offset(0x1000, 0x1000); + } else { + this->aimRotY -= Rand_S16Offset(0x1000, 0x1000); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B584.s") + if ((this->actor.depthInWater > -40.0f) || (this->actor.bgCheckFlags & 1)) { + this->aimRotX = -0x1000; + } else if (this->actor.world.pos.y < (this->actor.home.pos.y - 50.0f)) { + this->aimRotX = -Rand_S16Offset(0x800, 0x800); + } else if (this->actor.world.pos.y > (this->actor.home.pos.y + 50.0f)) { + this->aimRotX = Rand_S16Offset(0x800, 0x800); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B6AC.s") + if ((Math_SmoothStepToS(&this->actor.shape.rot.x, this->aimRotX, 0xA, 0x100, 8) == 0) && onInitialAnimFrame && + (Rand_ZeroOne() < 0.1f)) { + if (this->actor.home.pos.y < this->actor.world.pos.y) { + this->aimRotX -= Rand_S16Offset(0x400, 0x400); + } else { + this->aimRotX += Rand_S16Offset(0x400, 0x400); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B6C4.s") + this->aimRotX = CLAMP(this->aimRotX, -0x1000, 0x1000); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B778.s") + if (this->actor.bgCheckFlags & 1) { + Math_ScaledStepToS(&this->actor.shape.rot.x, -0x100, 0x400); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B838.s") + if (this->timer != 0) { + this->timer--; + } + if ((this->timer == 0) && + (((this->actor.xzDistToPlayer < 300.0f) && !(player->stateFlags1 & 0x800000)) || (dist < 300.0f)) && + (this->actor.depthInWater < -40.0f) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + if (dist < this->actor.xzDistToPlayer) { + this->actor.child = this->actor.parent; + } else { + this->actor.child = &player->actor; + } + EnCrow_SetupDiveAttack(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B8EC.s") +void EnCrow_SetupDiveAttack(EnCrow* this) { + this->timer = 300; + this->actionFunc = EnCrow_DiveAttack; + this->actor.speedXZ = 4.0f; + this->skelAnime.playSpeed = 2.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B9E8.s") +void EnCrow_DiveAttack(EnCrow* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 isFacingActor; + Vec3f pos; + s16 pitch; + s16 pitchTarget; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099BAB4.s") + SkelAnime_Update(&this->skelAnime); + if (this->timer != 0) { + this->timer--; + } + isFacingActor = Actor_ActorAIsFacingActorB(&this->actor, this->actor.child, 0x2800); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/EnCrow_Update.s") + if (isFacingActor) { + if (&player->actor == this->actor.child) { + pos.y = this->actor.child->world.pos.y + 20.0f; + } else { + pos.y = this->actor.child->world.pos.y + 40.0f; + } + pos.x = this->actor.child->world.pos.x; + pos.z = this->actor.child->world.pos.z; + pitch = Actor_PitchToPoint(&this->actor, &pos); + pitchTarget = CLAMP(pitch, -0x3000, 0x3000); + Math_SmoothStepToS(&this->actor.shape.rot.x, pitchTarget, 2, 0x400, 64); + } else { + Math_SmoothStepToS(&this->actor.shape.rot.x, -0x800, 2, 0x100, 16); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099BE48.s") + if (isFacingActor || (Actor_XZDistanceBetweenActors(&this->actor, this->actor.child) > 80.0f)) { + Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->actor.child), 4, 0xC00, + 0xC0); + } + if (((this->timer == 0) || ((&player->actor != this->actor.child) && (this->actor.child->home.rot.z != 0)) || + ((&player->actor == this->actor.child) && + ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (player->stateFlags1 & 0x800000))) || + ((this->collider.base.atFlags & AT_HIT) || (this->actor.bgCheckFlags & 9))) || + (this->actor.depthInWater > -40.0f)) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099BF20.s") + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_ATTACK); + } + EnCrow_SetupFlyIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/EnCrow_Draw.s") +void EnCrow_CheckIfFrozen(EnCrow* this, GlobalContext* globalCtx) { + if (this->deathMode == 10) { + this->deathMode = 0; + this->effectAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->bodyPartsPos, 4, 2, 0.2f, 0.2f); + } +} + +void EnCrow_SetupDamaged(EnCrow* this, GlobalContext* globalCtx) { + f32 scale; + + this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); + this->actor.velocity.y = 0.0f; + Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -3.0f); + this->actor.shape.yOffset = 0.0f; + this->actor.targetArrowOffset = 0.0f; + this->actor.bgCheckFlags &= ~1; + scale = (this->actor.scale.x * 100.0f); + this->actor.world.pos.y += 20.0f * scale; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_DEAD); + + if (this->actor.colChkInfo.damageEffect == 3) { + this->deathMode = 10; // Ice arrows + this->effectAlpha = 1.0f; + this->effectScale = 0.75f; + this->steamScale = 0.5f; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->deathMode = 20; // Light Arrows + this->effectAlpha = 4.0f; + this->steamScale = 0.5f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.elements->info.bumper.hitPos.x, + this->collider.elements->info.bumper.hitPos.y, this->collider.elements->info.bumper.hitPos.z, 0, 0, + 0, CLEAR_TAG_SMALL_LIGHT_RAYS); + } else if (this->actor.colChkInfo.damageEffect == 2) { + this->deathMode = 0; // Fire arrows + this->effectAlpha = 4.0f; + this->steamScale = 0.5f; + } + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + if (this->actor.flags & ACTOR_FLAG_8000) { + this->actor.speedXZ = 0.0f; + } + + this->collider.base.acFlags &= ~AC_ON; + this->actor.flags |= ACTOR_FLAG_10; + + this->actionFunc = EnCrow_Damaged; +} + +void EnCrow_Damaged(EnCrow* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + this->actor.colorFilterTimer = 40; + + if (!(this->actor.flags & ACTOR_FLAG_8000)) { + if (this->deathMode != 10) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x200); + this->actor.shape.rot.z += 0x1780; + } + if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { + EnCrow_CheckIfFrozen(this, globalCtx); + func_800B3030(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, this->actor.scale.x * 10000.0f, + 0, 0); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + + if (this->actor.parent != NULL) { + Actor_MarkForDeath(&this->actor); + return; + } + EnCrow_SetupDie(this); + } + } +} + +void EnCrow_SetupDie(EnCrow* this) { + this->actor.colorFilterTimer = 0; + this->actionFunc = EnCrow_Die; +} + +void EnCrow_Die(EnCrow* this, GlobalContext* globalCtx) { + f32 stepScale; + + if (this->actor.params != 0) { + stepScale = 0.006f; + } else { + stepScale = 0.002f; + } + if (Math_StepToF(&this->actor.scale.x, 0.0f, stepScale) != 0) { + if (this->actor.params == 0) { + D_8099C0CC++; + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x80); + } else { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); + } + EnCrow_SetupRespawn(this); + } + this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; +} + +void EnCrow_SetupTurnAway(EnCrow* this) { + this->timer = 100; + this->aimRotX = -0x1000; + this->actor.speedXZ = 3.5f; + this->aimRotY = this->actor.yawTowardsPlayer + 0x8000; + this->skelAnime.playSpeed = 2.0f; + if (this->actor.colChkInfo.damageEffect == 1) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + } else { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->actionFunc = EnCrow_TurnAway; +} + +void EnCrow_TurnAway(EnCrow* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (this->actor.bgCheckFlags & 8) { + this->aimRotY = this->actor.wallYaw; + } else { + this->aimRotY = this->actor.yawTowardsPlayer + 0x8000; + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->aimRotY, 3, 0xC00, 0xC0); + Math_SmoothStepToS(&this->actor.shape.rot.x, this->aimRotX, 5, 0x100, 0x10); + + if (this->timer != 0) { + this->timer--; + } + + if (this->timer == 0) { + EnCrow_SetupFlyIdle(this); + } +} + +void EnCrow_SetupRespawn(EnCrow* this) { + if (D_8099C0CC == 10) { + this->actor.params = 1; + D_8099C0CC = 0; + this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements->dim.modelSphere.radius * 0.03f * 100.0f; + } else { + this->actor.params = 0; + this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements->dim.modelSphere.radius; + } + Animation_PlayLoop(&this->skelAnime, &gGuayFlyAnim); + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actor.shape.rot.x = 0; + this->actor.shape.rot.z = 0; + this->timer = 300; + this->actor.draw = NULL; + this->actor.shape.yOffset = 2000.0f; + this->actor.targetArrowOffset = 2000.0; + this->effectAlpha = 0.0f; + this->actionFunc = EnCrow_Respawn; +} + +void EnCrow_Respawn(EnCrow* this, GlobalContext* globalCtx) { + f32 target; + + if (this->timer != 0) { + this->timer--; + } + if (this->timer == 0) { + SkelAnime_Update(&this->skelAnime); + this->actor.draw = EnCrow_Draw; + if (this->actor.params != 0) { + target = 0.03f; + } else { + target = 0.01f; + } + if (Math_StepToF(&this->actor.scale.x, target, target * 0.1f)) { + this->actor.flags |= ACTOR_FLAG_1; + this->actor.flags &= ~ACTOR_FLAG_10; + this->actor.colChkInfo.health = 1; + EnCrow_SetupFlyIdle(this); + } + this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; + } +} + +void EnCrow_UpdateDamage(EnCrow* this, GlobalContext* globalCtx) { + + if (this->collider.base.acFlags & AT_HIT) { + this->collider.base.acFlags &= ~AT_HIT; + Actor_SetDropFlag(&this->actor, &this->collider.elements->info); + + if (this->actor.colChkInfo.damageEffect == 1) { + EnCrow_SetupTurnAway(this); + + } else if (this->actor.colChkInfo.damageEffect == 5) { + this->deathMode = 31; // Stunned via deku nuts or zora barrier + this->effectAlpha = 2.0f; + this->steamScale = 0.5f; + EnCrow_SetupTurnAway(this); + + } else { + this->actor.colChkInfo.health = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + Enemy_StartFinishingBlow(globalCtx, &this->actor); + EnCrow_SetupDamaged(this, globalCtx); + } + } +} + +void EnCrow_Update(Actor* thisx, GlobalContext* globalCtx) { + f32 pad; + EnCrow* this = (EnCrow*)thisx; + f32 height; + f32 scale; + + EnCrow_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + scale = this->actor.scale.x * 100.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.x = -this->actor.shape.rot.x; + + if (this->actionFunc != EnCrow_Respawn) { + if (this->actor.colChkInfo.health != 0) { + height = 20.0f * scale; + Actor_MoveWithoutGravity(&this->actor); + } else { + height = 0.0f; + Actor_MoveWithGravity(&this->actor); + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 12.0f * scale, 25.0f * scale, 50.0f * scale, 7); + } else { + height = 0.0f; + } + + this->collider.elements[0].dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.elements[0].dim.worldSphere.center.y = this->actor.world.pos.y + height; + this->collider.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; + + if (this->actionFunc == EnCrow_DiveAttack) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + if (this->actionFunc != EnCrow_Respawn) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + Actor_SetFocus(&this->actor, height); + + if ((this->actor.colChkInfo.health != 0) && (Animation_OnFrame(&this->skelAnime, 3.0f))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_FLUTTER); + } + if (this->effectAlpha > 0.0f) { + if (this->deathMode != 10) { + Math_StepToF(&this->effectAlpha, 0.0f, 0.05f); + this->steamScale = (this->effectAlpha + 1.0f) * 0.25f; + if (this->steamScale > 0.5f) { + this->steamScale = 0.5f; + } else { + this->steamScale = this->steamScale; + } + } else if (Math_StepToF(&this->effectScale, 0.5f, 0.0125f) == 0) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } +} + +s32 EnCrow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnCrow* this = (EnCrow*)thisx; + + if (this->actor.colChkInfo.health != 0) { + if (limbIndex == OBJECT_CROW_LIMB_UPPER_TAIL) { + rot->y += (s16)(0xC00 * sin_rad(this->skelAnime.curFrame * (M_PI / 4))); + } else if (limbIndex == OBJECT_CROW_LIMB_TAIL) { + rot->y += (s16)(0x1400 * sin_rad((this->skelAnime.curFrame + 2.5f) * (M_PI / 4))); + } + } + return false; +} + +void EnCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnCrow* this = (EnCrow*)thisx; + + if (limbIndex == OBJECT_CROW_LIMB_BODY) { + Matrix_GetStateTranslationAndScaledX(2500.0f, this->bodyPartsPos); + return; + } + if ((limbIndex == OBJECT_CROW_LIMB_RIGHT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_LEFT_WING_TIP) || + (limbIndex == OBJECT_CROW_LIMB_TAIL)) { + Matrix_GetStateTranslation(&this->bodyPartsPos[(limbIndex >> 1) - 1]); + } +} + +void EnCrow_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnCrow* this = (EnCrow*)thisx; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnCrow_OverrideLimbDraw, EnCrow_PostLimbDraw, &this->actor); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->actor.scale.x * 100.0f * this->steamScale, this->effectScale, this->effectAlpha, + this->deathMode); +} diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.h b/src/overlays/actors/ovl_En_Crow/z_en_crow.h index e1d763142..9076a198c 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.h +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.h @@ -2,6 +2,7 @@ #define Z_EN_CROW_H #include "global.h" +#include "objects/object_crow/object_crow.h" struct EnCrow; @@ -9,9 +10,20 @@ typedef void (*EnCrowActionFunc)(struct EnCrow*, GlobalContext*); typedef struct EnCrow { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnCrowActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x110]; + /* 0x18C */ u8 deathMode; + /* 0x18E */ s16 timer; + /* 0x190 */ s16 aimRotX; + /* 0x192 */ s16 aimRotY; + /* 0x194 */ Vec3s jointTable[OBJECT_CROW_LIMB_MAX]; + /* 0x1CA */ Vec3s morphTable[OBJECT_CROW_LIMB_MAX]; + /* 0x200 */ ColliderJntSph collider; + /* 0x220 */ ColliderJntSphElement colliderItems[1]; + /* 0x260 */ Vec3f bodyPartsPos[4]; + /* 0x290 */ f32 effectAlpha; + /* 0x294 */ f32 steamScale; + /* 0x298 */ f32 effectScale; } EnCrow; // size = 0x29C extern const ActorInit En_Crow_InitVars; diff --git a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c index 7cfefa59c..c21395ef5 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c @@ -225,7 +225,7 @@ void EnRuppecrow_ShatterIce(EnRuppecrow* this, GlobalContext* globalCtx) { if (this->currentEffect == ENRUPPECROW_EFFECT_ICE) { this->currentEffect = ENRUPPECROW_EFFECT_NONE; this->unk_2C8 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ENRUPPECROW_LIMB_POS_COUNT, 0x2, 0.2f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 0x2, 0.2f, 0.2f); } } @@ -440,7 +440,7 @@ void EnRuppecrow_HandleDeath(EnRuppecrow* this) { this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); this->actor.velocity.y = 0.0f; - Animation_Change(&this->skelAnime, &object_crow_Anim_0000F0, 0.4f, 0.0f, 0.0f, 0x1, -3.0f); + Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, 0x1, -3.0f); this->actor.shape.yOffset = 0.0f; this->actor.targetArrowOffset = 0.0f; @@ -627,8 +627,8 @@ void EnRuppecrow_Init(Actor* thisx, GlobalContext* globalCtx2) { EnRuppecrow* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_crow_Skel_0010C0, &object_crow_Anim_0000F0, this->joinTable, - this->morphTable, ENRUPPECROW_LIMB_COUNT); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->joinTable, this->morphTable, + OBJECT_CROW_LIMB_MAX); ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); Collider_InitJntSph(globalCtx, &this->collider); diff --git a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h index 4c9cafa67..de9fceac9 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h @@ -2,11 +2,11 @@ #define Z_EN_RUPPECROW_H #include "global.h" +#include "objects/object_crow/object_crow.h" #define ENRUPPECROW_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 0xA) #define ENRUPPECROW_RUPEE_COUNT 20 -#define ENRUPPECROW_LIMB_COUNT 9 #define ENRUPPECROW_LIMB_POS_COUNT 4 struct EnRuppecrow; @@ -19,8 +19,8 @@ typedef struct EnRuppecrow { /* 0x194 */ SkelAnime skelAnime; /* 0x1D8 */ EnRuppecrowActionFunc actionFunc; /* 0x1DC */ UNK_TYPE4 unk_1DC; // unused - /* 0x1E0 */ Vec3s joinTable[ENRUPPECROW_LIMB_COUNT]; - /* 0x216 */ Vec3s morphTable[ENRUPPECROW_LIMB_COUNT]; + /* 0x1E0 */ Vec3s joinTable[OBJECT_CROW_LIMB_MAX]; + /* 0x216 */ Vec3s morphTable[OBJECT_CROW_LIMB_MAX]; /* 0x24C */ Path* path; /* 0x250 */ s32 currentPoint; /* 0x254 */ ColliderJntSph collider; diff --git a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c index e11deb354..23a16debc 100644 --- a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c +++ b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c @@ -95,8 +95,8 @@ void EnSyatekiCrow_Init(Actor* thisx, GlobalContext* globalCtx2) { } Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_crow_Skel_0010C0, &object_crow_Anim_0000F0, - this->jointTable, this->morphTable, 9); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, + OBJECT_CROW_LIMB_MAX); Collider_InitJntSph(globalCtx, &this->unk_23C); Collider_SetJntSph(globalCtx, &this->unk_23C, &this->actor, &sJntSphInit, &this->unk_25C); this->unk_23C.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; @@ -225,7 +225,7 @@ void func_809CAAF8(EnSyatekiCrow* this) { this->unk_1C2 = 0; this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); this->actor.velocity.y = 0.0f; - Animation_Change(&this->skelAnime, &object_crow_Anim_0000F0, 0.4f, 0.0f, 0.0f, 1, -3.0f); + Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, 1, -3.0f); this->actor.bgCheckFlags &= ~1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_DEAD); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); @@ -290,9 +290,9 @@ s32 EnSyatekiCrow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx* Actor* thisx) { EnSyatekiCrow* this = THIS; - if (limbIndex == OBJECT_CROW_LIMB_07) { + if (limbIndex == OBJECT_CROW_LIMB_UPPER_TAIL) { rot->y += (s16)(3072.0f * sin_rad(this->skelAnime.curFrame * (M_PI / 4))); - } else if (limbIndex == OBJECT_CROW_LIMB_08) { + } else if (limbIndex == OBJECT_CROW_LIMB_TAIL) { rot->y += (s16)(5120.0f * sin_rad((this->skelAnime.curFrame + 2.5f) * (M_PI / 4))); } @@ -303,11 +303,11 @@ void EnSyatekiCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d EnSyatekiCrow* this = THIS; Vec3f* sp1C; - if (limbIndex == OBJECT_CROW_LIMB_02) { + if (limbIndex == OBJECT_CROW_LIMB_BODY) { Matrix_MultiplyVector3fByState(&D_809CB0D8, &this->unk_144[0]); this->unk_144[0].y -= 20.0f; - } else if ((limbIndex == OBJECT_CROW_LIMB_04) || (limbIndex == OBJECT_CROW_LIMB_06) || - (limbIndex == OBJECT_CROW_LIMB_08)) { + } else if ((limbIndex == OBJECT_CROW_LIMB_RIGHT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_LEFT_WING_TIP) || + (limbIndex == OBJECT_CROW_LIMB_TAIL)) { sp1C = &this->unk_144[(limbIndex >> 1) - 1]; Matrix_MultiplyVector3fByState(&D_809CB050, sp1C); sp1C->y -= 20.0f; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 87bc6d1e8..9d7af0b01 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -8573,23 +8573,23 @@ 0x8099AA84:("func_8099AA84",), 0x8099AB30:("EnCrow_Init",), 0x8099AC2C:("EnCrow_Destroy",), - 0x8099AC58:("func_8099AC58",), - 0x8099AC8C:("func_8099AC8C",), - 0x8099B098:("func_8099B098",), - 0x8099B0CC:("func_8099B0CC",), - 0x8099B318:("func_8099B318",), - 0x8099B384:("func_8099B384",), - 0x8099B584:("func_8099B584",), - 0x8099B6AC:("func_8099B6AC",), - 0x8099B6C4:("func_8099B6C4",), - 0x8099B778:("func_8099B778",), - 0x8099B838:("func_8099B838",), - 0x8099B8EC:("func_8099B8EC",), - 0x8099B9E8:("func_8099B9E8",), - 0x8099BAB4:("func_8099BAB4",), + 0x8099AC58:("EnCrow_SetupFlyIdle",), + 0x8099AC8C:("EnCrow_FlyIdle",), + 0x8099B098:("EnCrow_SetupDiveAttack",), + 0x8099B0CC:("EnCrow_DiveAttack",), + 0x8099B318:("EnCrow_CheckIfFrozen",), + 0x8099B384:("EnCrow_SetupDamaged",), + 0x8099B584:("EnCrow_Damaged",), + 0x8099B6AC:("EnCrow_SetupDie",), + 0x8099B6C4:("EnCrow_Die",), + 0x8099B778:("EnCrow_SetupTurnAway",), + 0x8099B838:("EnCrow_TurnAway",), + 0x8099B8EC:("EnCrow_SetupRespawn",), + 0x8099B9E8:("EnCrow_Respawn",), + 0x8099BAB4:("EnCrow_UpdateDamage",), 0x8099BB84:("EnCrow_Update",), - 0x8099BE48:("func_8099BE48",), - 0x8099BF20:("func_8099BF20",), + 0x8099BE48:("EnCrow_OverrideLimbDraw",), + 0x8099BF20:("EnCrow_PostLimbDraw",), 0x8099BFA4:("EnCrow_Draw",), 0x8099C290:("func_8099C290",), 0x8099C328:("func_8099C328",), From 348e87083b714562011b9c31d410824c5293a3a5 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 17:11:08 +0100 Subject: [PATCH 148/257] Bg_Breakwall (#733) * Bg_Breakwall * PR and match (thanks petrie) * PR * Merge --- include/functions.h | 4 +- spec | 3 +- .../actors/ovl_Bg_Breakwall/z_bg_breakwall.c | 427 ++++++++++++++++-- .../actors/ovl_Bg_Breakwall/z_bg_breakwall.h | 17 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 5 - 6 files changed, 407 insertions(+), 53 deletions(-) diff --git a/include/functions.h b/include/functions.h index fea33cabb..42047e7f9 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1586,9 +1586,9 @@ void func_800FE658(f32 arg0); // void func_800FE778(void); // void func_800FE788(void); // void func_800FE798(void); -void func_800FE7A8(Color_RGBA8* arg0, Color_RGBA8* arg1); +void func_800FE7A8(Color_RGBA8* inColor, Color_RGBA8* outColor); s32 func_800FE9B4(GlobalContext* globalCtx); -// void func_800FEA50(void); +void func_800FEA50(GlobalContext* globalCtx); void func_800FEAB0(void); // void func_800FEAC0(void); void func_800FEAF4(EnvironmentContext* envCtx); diff --git a/spec b/spec index 3fb3af904..f85beef17 100644 --- a/spec +++ b/spec @@ -1022,8 +1022,7 @@ beginseg name "ovl_Bg_Breakwall" compress include "build/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.o" - include "build/data/ovl_Bg_Breakwall/ovl_Bg_Breakwall.data.o" - include "build/data/ovl_Bg_Breakwall/ovl_Bg_Breakwall.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Breakwall/ovl_Bg_Breakwall_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c index 63a9e69dc..b2fe546cf 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c @@ -5,6 +5,15 @@ */ #include "z_bg_breakwall.h" +#include "objects/object_omoya_obj/object_omoya_obj.h" +#include "objects/object_yukimura_obj/object_yukimura_obj.h" +#include "objects/object_keikoku_obj/object_keikoku_obj.h" +#include "objects/object_posthouse_obj/object_posthouse_obj.h" +#include "objects/object_kumo30/object_kumo30.h" +#include "objects/object_mnk/object_mnk.h" +#include "objects/object_ikninside_obj/object_ikninside_obj.h" +#include "objects/object_kaizoku_obj/object_kaizoku_obj.h" +#include "objects/object_spot11_obj/object_spot11_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -14,80 +23,418 @@ void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx); void BgBreakwall_Update(Actor* thisx, GlobalContext* globalCtx); void BgBreakwall_SetupAction(BgBreakwall* this, BgBreakwallActionFunc actionFunc); +s32 func_808B736C(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B7380(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B73C4(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B73FC(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B7410(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B7460(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B74A8(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B74D8(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B751C(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B76CC(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B77D0(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B77E0(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B782C(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B78A4(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B78DC(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B7914(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B7A10(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B7A90(Actor* thisx, GlobalContext* globalCtx); +void func_808B7B54(Actor* thisx, GlobalContext* globalCtx); +void func_808B7D34(Actor* thisx, GlobalContext* globalCtx); +void BgBreakwall_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Breakwall_InitVars = { - ACTOR_BG_BREAKWALL, - ACTORCAT_ITEMACTION, - FLAGS, - GAMEPLAY_KEEP, - sizeof(BgBreakwall), - (ActorFunc)BgBreakwall_Init, - (ActorFunc)NULL, - (ActorFunc)BgBreakwall_Update, - (ActorFunc)NULL, + ACTOR_BG_BREAKWALL, ACTORCAT_ITEMACTION, FLAGS, + GAMEPLAY_KEEP, sizeof(BgBreakwall), (ActorFunc)BgBreakwall_Init, + (ActorFunc)NULL, (ActorFunc)BgBreakwall_Update, (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808B82E0[] = { +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x04 */ Gfx* unk_04; + /* 0x08 */ Gfx* unk_08; + /* 0x0C */ AnimatedMaterial* unk_0C; + /* 0x10 */ CollisionHeader* unk_10; + /* 0x14 */ BgBreakwallUnkFunc unk_14; + /* 0x18 */ BgBreakwallUnkFunc2 unk_18; + /* 0x1C */ ActorFunc unk_1C; +} BgBreakwallStruct; + +BgBreakwallStruct D_808B8140[] = { + { OBJECT_OMOYA_OBJ, object_omoya_obj_DL_0001A0, NULL, NULL, NULL, func_808B7380, func_808B77D0, NULL }, + { OBJECT_YUKIMURA_OBJ, object_yukimura_obj_DL_000F98, object_yukimura_obj_DL_000EB0, + object_yukimura_obj_Matanimheader_002090, NULL, func_808B73C4, func_808B77D0, NULL }, + { OBJECT_KEIKOKU_OBJ, object_keikoku_obj_DL_0027D8, NULL, object_keikoku_obj_Matanimheader_004290, NULL, + func_808B73FC, func_808B77D0, NULL }, + { OBJECT_KEIKOKU_OBJ, object_keikoku_obj_DL_0044A8, NULL, NULL, NULL, func_808B736C, func_808B77D0, NULL }, + { OBJECT_POSTHOUSE_OBJ, object_posthouse_obj_DL_000A50, NULL, NULL, NULL, func_808B7410, func_808B77E0, NULL }, + { OBJECT_POSTHOUSE_OBJ, object_posthouse_obj_DL_001870, NULL, NULL, &object_posthouse_obj_Colheader_002948, + func_808B7460, func_808B782C, NULL }, + { OBJECT_KUMO30, NULL, object_kumo30_DL_002A40, object_kumo30_Matanimheader_003368, NULL, func_808B74A8, + func_808B78A4, func_808B7A90 }, + { OBJECT_KUMO30, NULL, NULL, object_kumo30_Matanimheader_002890, NULL, func_808B736C, func_808B78DC, + func_808B7B54 }, + { OBJECT_MNK, object_mnk_DL_000F58, NULL, object_mnk_Matanimheader_002E28, &object_mnk_Colheader_0033E8, + func_808B74D8, func_808B7914, NULL }, + { OBJECT_IKNINSIDE_OBJ, NULL, object_ikninside_obj_DL_00AB10, object_ikninside_obj_Matanimheader_00BCC8, NULL, + func_808B751C, func_808B7A10, func_808B7D34 }, + { OBJECT_KAIZOKU_OBJ, object_kaizoku_obj_DL_00AD50, NULL, NULL, &object_kaizoku_obj_Colheader_00B868, func_808B736C, + func_808B77D0, NULL }, + { OBJECT_IKNINSIDE_OBJ, NULL, object_ikninside_obj_DL_00AEC0, object_ikninside_obj_Matanimheader_00BCB8, NULL, + func_808B751C, func_808B7A10, func_808B7D34 }, + { OBJECT_SPOT11_OBJ, object_spot11_obj_DL_0013F0, NULL, NULL, &object_spot11_obj_Colheader_001EB8, func_808B736C, + func_808B77D0, NULL }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F(scale, 1, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), }; -#endif +Color_RGBA8 D_808B82F0[] = { + { 255, 230, 240, 255 }, + { 255, 255, 255, 255 }, + { 255, 230, 220, 255 }, + { 80, 120, 160, 255 }, +}; -extern InitChainEntry D_808B82E0[]; +Color_RGBA8 D_808B8300[] = { + { 140, 60, 70, 255 }, + { 50, 150, 150, 255 }, + { 140, 60, 50, 255 }, + { 30, 40, 160, 255 }, +}; -extern UNK_TYPE D_06000A50; +Color_RGBA8 D_808B8310[] = { + { 210, 160, 180, 255 }, + { 120, 150, 160, 255 }, + { 210, 170, 160, 255 }, + { 70, 100, 120, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/BgBreakwall_SetupAction.s") +Color_RGBA8 D_808B8320[] = { + { 255, 240, 255, 255 }, + { 255, 255, 255, 255 }, + { 255, 255, 240, 255 }, + { 150, 170, 180, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B736C.s") +Color_RGBA8 D_808B8330[] = { + { 60, 20, 40, 255 }, + { 0, 50, 50, 255 }, + { 60, 30, 30, 255 }, + { 0, 20, 30, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7380.s") +Color_RGBA8 D_808B8340[] = { + { 160, 120, 140, 255 }, + { 100, 160, 150, 255 }, + { 160, 150, 120, 255 }, + { 60, 110, 110, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B73C4.s") +void BgBreakwall_SetupAction(BgBreakwall* this, BgBreakwallActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B73FC.s") +s32 func_808B736C(BgBreakwall* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7410.s") +s32 func_808B7380(BgBreakwall* this, GlobalContext* globalCtx) { + if ((gSaveContext.save.day >= 2) && !(gSaveContext.save.weekEventReg[22] & 1)) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7460.s") +s32 func_808B73C4(BgBreakwall* this, GlobalContext* globalCtx) { + return (gSaveContext.save.weekEventReg[33] & 0x80) || (gSaveContext.save.weekEventReg[21] & 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B74A8.s") +s32 func_808B73FC(BgBreakwall* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B74D8.s") +s32 func_808B7410(BgBreakwall* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->dyna.actor.draw = NULL; + } + Actor_SetScale(&this->dyna.actor, 0.1f); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B751C.s") +s32 func_808B7460(BgBreakwall* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->dyna.actor.scale.x = 0.1f; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/BgBreakwall_Init.s") +s32 func_808B74A8(BgBreakwall* this, GlobalContext* globalCtx) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B767C.s") +s32 func_808B74D8(BgBreakwall* this, GlobalContext* globalCtx) { + if (!(gSaveContext.save.weekEventReg[9] & 0x80) || (gSaveContext.save.weekEventReg[23] & 0x20)) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B76CC.s") +s32 func_808B751C(BgBreakwall* this, GlobalContext* globalCtx) { + Actor_SetScale(&this->dyna.actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B77D0.s") + if ((BGBREAKWALL_SWITCHFLAG(&this->dyna.actor) != 0x7F) && + !Flags_GetSwitch(globalCtx, BGBREAKWALL_SWITCHFLAG(&this->dyna.actor))) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B77E0.s") + func_800FEA50(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B782C.s") + if (gSaveContext.save.isNight) { + this->unk_15E = 0; + } else { + this->unk_15E = 255; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B78A4.s") +void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgBreakwall* this = THIS; + BgBreakwallStruct* sp24 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B78DC.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->unk_15C = Object_GetIndex(&globalCtx->objectCtx, sp24->unk_00); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7914.s") + if ((this->unk_15C < 0) || !sp24->unk_14(this, globalCtx)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7A10.s") + BgBreakwall_SetupAction(this, func_808B76CC); + this->switchFlag = BGBREAKWALL_SWITCHFLAG(&this->dyna.actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/BgBreakwall_Update.s") +void BgBreakwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgBreakwall* this = THIS; + BgBreakwallStruct* temp_s1 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7A90.s") + if (temp_s1->unk_10 != NULL) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7B54.s") +void func_808B76CC(BgBreakwall* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_15C)) { + BgBreakwallStruct* temp_s1 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7D34.s") + this->dyna.actor.objBankIndex = this->unk_15C; + this->dyna.actor.draw = BgBreakwall_Draw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7FE4.s") + if (((BGBREAKWALL_GET_F(&this->dyna.actor)) != BGBREAKWALL_F_7) && + ((BGBREAKWALL_GET_F(&this->dyna.actor)) != BGBREAKWALL_F_9) && + ((BGBREAKWALL_GET_F(&this->dyna.actor)) != BGBREAKWALL_F_11)) { + this->dyna.actor.flags &= ~ACTOR_FLAG_10; + } + + Actor_SetObjectDependency(globalCtx, &this->dyna.actor); + + if (temp_s1->unk_0C != NULL) { + temp_s1->unk_0C = Lib_SegmentedToVirtual(temp_s1->unk_0C); + } + + if (temp_s1->unk_10 != NULL) { + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, temp_s1->unk_10); + } + + BgBreakwall_SetupAction(this, temp_s1->unk_18); + this->dyna.actor.destroy = BgBreakwall_Destroy; + } +} + +void func_808B77D0(BgBreakwall* this, GlobalContext* globalCtx) { +} + +void func_808B77E0(BgBreakwall* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->dyna.actor.draw = BgBreakwall_Draw; + } else { + this->dyna.actor.draw = NULL; + } +} + +void func_808B782C(BgBreakwall* this, GlobalContext* globalCtx) { + f32 phi_f0; + + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + phi_f0 = 1.0f; + } else { + phi_f0 = 0.1f; + } + Math_SmoothStepToF(&this->dyna.actor.scale.x, phi_f0, 0.2f, 0.3f, 0.06f); +} + +void func_808B78A4(BgBreakwall* this, GlobalContext* globalCtx) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void func_808B78DC(BgBreakwall* this, GlobalContext* globalCtx) { + Actor_SetScale(&this->dyna.actor, 3.5f); + func_800B9010(&this->dyna.actor, NA_SE_EV_TORNADE - SFX_FLAG); +} + +void func_808B7914(BgBreakwall* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + Vec3f sp24; + + if ((globalCtx->gameplayFrames % 8) == 0) { + sp30.x = Rand_ZeroFloat(80.0f) + (this->dyna.actor.world.pos.x - 55.0f); + sp30.y = this->dyna.actor.world.pos.y + 70.0f; + sp30.z = Rand_ZeroFloat(80.0f) + (this->dyna.actor.world.pos.z - 130.0f); + + sp24.x = 0.0f; + sp24.y = 0.5f; + sp24.z = 0.0f; + + EffectSsIceSmoke_Spawn(globalCtx, &sp30, &sp24, &gZeroVec3f, -200 - (s32)(Rand_ZeroOne() * 50.0f)); + } +} + +void func_808B7A10(BgBreakwall* this, GlobalContext* globalCtx) { + if (gSaveContext.save.isNight) { + if (this->unk_15E < 245) { + this->unk_15E += 10; + } else { + this->unk_15E = 255; + } + } else if (this->unk_15E > 10) { + this->unk_15E -= 10; + } else { + this->unk_15E = 0; + } +} + +void BgBreakwall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgBreakwall* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void func_808B7A90(Actor* thisx, GlobalContext* globalCtx) { + Color_RGBA8 sp2C; + Color_RGBA8 sp28; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_800FE7A8(D_808B82F0, &sp2C); + func_800FE7A8(D_808B8300, &sp28); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sp2C.r, sp2C.g, sp2C.b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sp28.r, sp28.g, sp28.b, 255); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_808B7B54(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + Color_RGBA8 sp50; + Color_RGBA8 sp4C; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_800FE7A8(D_808B8310, &sp50); + func_800FE7A8(D_808B8330, &sp4C); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sp50.r, sp50.g, sp50.b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sp4C.r, sp4C.g, sp4C.b, 255); + gSPDisplayList(POLY_XLU_DISP++, object_posthouse_obj_DL_000A50); + + func_800FE7A8(D_808B8320, &sp50); + func_800FE7A8(D_808B8340, &sp4C); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sp50.r, sp50.g, sp50.b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sp4C.r, sp4C.g, sp4C.b, 255); + gSPDisplayList(POLY_XLU_DISP++, object_kumo30_DL_000C98); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_808B7D34(Actor* thisx, GlobalContext* globalCtx) { + BgBreakwall* this = THIS; + s32 sp48; + s32 tempA; + s32 tempB; + s32 tempC; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + sp48 = 255 - this->unk_15E; + + tempA = (((sp48 * 245) + (this->unk_15E * 255)) & 0xFF00) >> 8; + tempB = (((sp48 * 145) + (this->unk_15E * 85)) & 0xFF00) >> 8; + tempC = (((sp48 * 135) + (this->unk_15E * 55)) & 0xFF00) >> 8; + + gSPSegment(POLY_XLU_DISP++, 0x09, Gfx_PrimColor(globalCtx->state.gfxCtx, 255, 255, tempA, tempB, tempC)); + + tempA = (((sp48 * 255) + (this->unk_15E * 150)) & 0xFF00) >> 8; + tempB = (((sp48 * 255) + (this->unk_15E * 100)) & 0xFF00) >> 8; + tempC = (((sp48 * 255) + (this->unk_15E * 75)) & 0xFF00) >> 8; + + gSPSegment(POLY_XLU_DISP++, 0x0A, Gfx_PrimColor(globalCtx->state.gfxCtx, 255, tempA, tempA, tempB, tempC)); + + tempA = (((sp48 * 185) + (this->unk_15E * 140)) & 0xFF00) >> 8; + tempB = (((sp48 * 235) + (this->unk_15E * 45)) & 0xFF00) >> 8; + + gSPSegment(POLY_XLU_DISP++, 0x0B, Gfx_PrimColor(globalCtx->state.gfxCtx, 255, 255, 255, tempA, tempB)); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void BgBreakwall_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgBreakwall* this = THIS; + BgBreakwallStruct* temp_s2 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (temp_s2->unk_0C != NULL) { + AnimatedMat_Draw(globalCtx, temp_s2->unk_0C); + } + + if (temp_s2->unk_1C != NULL) { + temp_s2->unk_1C(&this->dyna.actor, globalCtx); + } + + if (temp_s2->unk_04 != NULL) { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, temp_s2->unk_04); + } + + if (temp_s2->unk_08 != NULL) { + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, temp_s2->unk_08); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h index 279aba17b..322929344 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h @@ -6,10 +6,23 @@ struct BgBreakwall; typedef void (*BgBreakwallActionFunc)(struct BgBreakwall*, GlobalContext*); +typedef s32 (*BgBreakwallUnkFunc)(struct BgBreakwall*, GlobalContext*); +typedef void (*BgBreakwallUnkFunc2)(struct BgBreakwall*, GlobalContext*); + +#define BGBREAKWALL_GET_F(thisx) ((thisx)-> params & 0xF) +#define BGBREAKWALL_SWITCHFLAG(thisx) (((thisx)-> params & 0xFE00) >> 9) + +enum { + /* 7 */ BGBREAKWALL_F_7 = 7, + /* 9 */ BGBREAKWALL_F_9 = 9, + /* 11 */ BGBREAKWALL_F_11 = 11, +}; typedef struct BgBreakwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ s8 unk_15C; + /* 0x015D */ u8 switchFlag; + /* 0x015E */ u8 unk_15E; /* 0x0160 */ BgBreakwallActionFunc actionFunc; } BgBreakwall; // size = 0x164 diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 9d7af0b01..c97446d78 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -5971,7 +5971,7 @@ 0x808B74D8:("func_808B74D8",), 0x808B751C:("func_808B751C",), 0x808B75B0:("BgBreakwall_Init",), - 0x808B767C:("func_808B767C",), + 0x808B767C:("BgBreakwall_Destroy",), 0x808B76CC:("func_808B76CC",), 0x808B77D0:("func_808B77D0",), 0x808B77E0:("func_808B77E0",), @@ -5984,7 +5984,7 @@ 0x808B7A90:("func_808B7A90",), 0x808B7B54:("func_808B7B54",), 0x808B7D34:("func_808B7D34",), - 0x808B7FE4:("func_808B7FE4",), + 0x808B7FE4:("BgBreakwall_Draw",), 0x808B8490:("DoorWarp1_SetupAction",), 0x808B849C:("func_808B849C",), 0x808B8568:("func_808B8568",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 85bf81bf9..c730153bd 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -557,11 +557,6 @@ D_06002498 = 0x06002498; D_06000638 = 0x06000638; D_06001BD8 = 0x06001BD8; -// ovl_Bg_Breakwall - -D_06000A50 = 0x06000A50; -D_06000C98 = 0x06000C98; - // ovl_Bg_Crace_Movebg D_060003A0 = 0x060003A0; From 26d7085ac299b309c8c844e06fa151a3db4eec17 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 17:16:28 +0100 Subject: [PATCH 149/257] Obj_Armos (#734) * Obj_Armos * PR --- spec | 3 +- .../actors/ovl_Obj_Armos/z_obj_armos.c | 364 ++++++++++++++++-- .../actors/ovl_Obj_Armos/z_obj_armos.h | 30 +- undefined_syms.txt | 6 - 4 files changed, 365 insertions(+), 38 deletions(-) diff --git a/spec b/spec index f85beef17..fe0468dfb 100644 --- a/spec +++ b/spec @@ -2255,8 +2255,7 @@ beginseg name "ovl_Obj_Armos" compress include "build/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.o" - include "build/data/ovl_Obj_Armos/ovl_Obj_Armos.data.o" - include "build/data/ovl_Obj_Armos/ovl_Obj_Armos.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Armos/ovl_Obj_Armos_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c index 2d7db7644..998e85d68 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c @@ -5,6 +5,7 @@ */ #include "z_obj_armos.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_4000000) @@ -15,11 +16,13 @@ void ObjArmos_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjArmos_Update(Actor* thisx, GlobalContext* globalCtx); void ObjArmos_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_809A54B4(ObjArmos* this); void func_809A54E0(ObjArmos* this, GlobalContext* globalCtx); +void func_809A5610(ObjArmos* this); void func_809A562C(ObjArmos* this, GlobalContext* globalCtx); +void func_809A57D8(ObjArmos* this); void func_809A57F4(ObjArmos* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Armos_InitVars = { ACTOR_OBJ_ARMOS, ACTORCAT_PROP, @@ -32,51 +35,358 @@ const ActorInit Obj_Armos_InitVars = { (ActorFunc)ObjArmos_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809A5BC0[] = { - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 120, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 250, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -4000, ICHAIN_CONTINUE), +s16 D_809A5BB0[] = { 1, -1, 0, 0 }; +s16 D_809A5BB8[] = { 0, 0, 1, -1 }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 120, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 250, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -4000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), }; -#endif +s32 func_809A4E00(ObjArmos* this, GlobalContext* globalCtx, s16 arg2) { + return !DynaPolyActor_ValidateMove(globalCtx, &this->dyna, 30, arg2, 1) || + !DynaPolyActor_ValidateMove(globalCtx, &this->dyna, 30, arg2, 28); +} -extern InitChainEntry D_809A5BC0[]; +s32 func_809A4E68(ObjArmos* this) { + s16 temp_v0; -extern UNK_TYPE D_0600033C; + if (fabsf(this->dyna.pushForce) > 0.1f) { + temp_v0 = BINANG_ADD(this->dyna.yRotation, 0x2000); + if (this->dyna.pushForce < 0.0f) { + temp_v0 = BINANG_ROT180(temp_v0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A4E00.s") + if (temp_v0 < -0x4000) { + return 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A4E68.s") + if (temp_v0 < 0) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A4F00.s") + if (temp_v0 < 0x4000) { + return 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A500C.s") + return 0; + } + return -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A518C.s") +s32 func_809A4F00(ObjArmos* this, s32 arg1) { + s32 temp_v0 = OBJARMOS_GET_ROTZ_7(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/ObjArmos_Init.s") + if (temp_v0 == OBJARMOS_ROT_7_0) { + return arg1 == 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/ObjArmos_Destroy.s") + if (temp_v0 == OBJARMOS_ROT_7_1) { + return arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A54B4.s") + if (temp_v0 == OBJARMOS_ROT_7_2) { + return arg1 == 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A54E0.s") + if (temp_v0 == OBJARMOS_ROT_7_3) { + return arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A5610.s") + if (temp_v0 == OBJARMOS_ROT_7_4) { + return arg1 == 0 || arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A562C.s") + if (temp_v0 == OBJARMOS_ROT_7_5) { + return arg1 == 2 || arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A57D8.s") + if (temp_v0 == OBJARMOS_ROT_7_6) { + if (this->unk_26E != 0) { + return arg1 == 0 || arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A57F4.s") + if (this->unk_270 != 0) { + return arg1 == 2 || arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/ObjArmos_Update.s") + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A5960.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A5A3C.s") +s32 func_809A500C(ObjArmos* this, s32 arg1) { + s32 temp_v0 = OBJARMOS_GET_ROTZ_7(&this->dyna.actor); + s32 temp_v1 = OBJARMOS_GET_ROTX_F(&this->dyna.actor); + s32 temp; + s32 temp2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/ObjArmos_Draw.s") + if (temp_v0 == OBJARMOS_ROT_7_0) { + return this->unk_26E < temp_v1; + } + + if (temp_v0 == OBJARMOS_ROT_7_1) { + return -temp_v1 < this->unk_26E; + } + + if (temp_v0 == OBJARMOS_ROT_7_2) { + return this->unk_270 < temp_v1; + } + + if (temp_v0 == OBJARMOS_ROT_7_3) { + return -temp_v1 < this->unk_270; + } + + if (temp_v0 == OBJARMOS_ROT_7_4) { + temp = D_809A5BB0[arg1] + this->unk_26E; + return temp <= temp_v1 && -temp_v1 <= temp; + } + + if (temp_v0 == OBJARMOS_ROT_7_5) { + temp2 = D_809A5BB8[arg1] + this->unk_270; + return temp2 <= temp_v1 && -temp_v1 <= temp2; + } + + if (temp_v0 == OBJARMOS_ROT_7_6) { + if ((arg1 == 0) || (arg1 == 1)) { + temp = D_809A5BB0[arg1] + this->unk_26E; + return temp <= temp_v1 && -temp_v1 <= temp; + } + + temp2 = D_809A5BB8[arg1] + this->unk_270; + return temp2 <= temp_v1 && -temp_v1 <= temp2; + } + + return false; +} + +void func_809A518C(ObjArmos* this, s32 arg1) { + this->unk_26E += D_809A5BB0[arg1]; + this->unk_270 += D_809A5BB8[arg1]; + + if ((arg1 == 0) || (arg1 == 1)) { + this->unk_25C = &this->dyna.actor.world.pos.x; + this->unk_260 = this->dyna.actor.home.pos.x + (this->unk_26E * 60); + } else { + this->unk_25C = &this->dyna.actor.world.pos.z; + this->unk_260 = this->dyna.actor.home.pos.z + (this->unk_270 * 60); + } + this->unk_264 = arg1; +} + +void ObjArmos_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjArmos* this = THIS; + s32 sp44 = OBJARMOS_GET_ROTZ_7(&this->dyna.actor); + s32 sp40 = OBJARMOS_GET_ROTX_F(&this->dyna.actor); + f32 sp3C = Animation_GetLastFrame(&gArmosPushedBackAnim); + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + + this->dyna.actor.home.rot.y = this->dyna.actor.world.rot.x = this->dyna.actor.world.rot.y = + this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.x = this->dyna.actor.shape.rot.z = 0; + + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_am_Colheader_005CF8); + + SkelAnime_Init(globalCtx, &this->skelAnime, &object_am_Skel_005948, &gArmosPushedBackAnim, this->jointTable, + this->morphTable, OBJECT_AM_LIMB_MAX); + + Animation_Change(&this->skelAnime, &gArmosPushedBackAnim, 0.0f, sp3C, sp3C, ANIMMODE_ONCE, 0.0f); + + if (sp40 == 0) { + func_809A57D8(this); + } else if (Flags_GetSwitch(globalCtx, OBJARMOS_GET_7F(&this->dyna.actor))) { + if (sp44 == OBJARMOS_ROT_7_0) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + (sp40 * 60); + func_809A57D8(this); + } else if (sp44 == OBJARMOS_ROT_7_1) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x - (sp40 * 60); + func_809A57D8(this); + } else if (sp44 == OBJARMOS_ROT_7_2) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + (sp40 * 60); + func_809A57D8(this); + } else if (sp44 == OBJARMOS_ROT_7_3) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z - (sp40 * 60); + func_809A57D8(this); + } else { + func_809A54B4(this); + } + } else { + func_809A54B4(this); + } +} + +void ObjArmos_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjArmos* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_809A54B4(ObjArmos* this) { + this->actionFunc = func_809A54E0; + this->unk_24C = 4; + this->unk_266[1] = 0; + this->unk_266[2] = 0; + this->unk_266[3] = 0; + this->unk_266[0] = 0; +} + +void func_809A54E0(ObjArmos* this, GlobalContext* globalCtx) { + s32 i; + s32 sp20 = func_809A4E68(this); + + for (i = 0; i < ARRAY_COUNT(this->unk_266); i++) { + if (sp20 == i) { + this->unk_266[i]++; + } else if (this->unk_266[i] > 0) { + this->unk_266[i]--; + } + } + + if (sp20 != -1) { + if ((this->unk_266[sp20] >= 9) && func_809A4F00(this, sp20) && func_809A500C(this, sp20) && + !func_809A4E00(this, globalCtx, (this->dyna.pushForce > 0.0f) ? 90 : 120)) { + func_809A518C(this, sp20); + func_809A5610(this); + } else { + GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } + } +} + +void func_809A5610(ObjArmos* this) { + this->actionFunc = func_809A562C; + this->unk_24C = 5; +} + +void func_809A562C(ObjArmos* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player; + f32 temp2 = this->unk_260 - *this->unk_25C; + s32 temp; + s32 sp20; + + if (Math_StepToF(this->unk_25C, this->unk_260, (Math_SinS(fabsf(temp2) * 546.13336f) * 1.6f) + 1.0f)) { + player = GET_PLAYER(globalCtx); + temp = OBJARMOS_GET_ROTZ_7(&this->dyna.actor); + sp20 = false; + + if ((temp == OBJARMOS_ROT_7_4) || (temp == OBJARMOS_ROT_7_5) || (temp == OBJARMOS_ROT_7_6)) { + if (!func_809A500C(this, this->unk_264) || func_809A4E00(this, globalCtx, 0x5A)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else if (func_809A500C(this, this->unk_264)) { + if (func_809A4E00(this, globalCtx, 0x5A)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Flags_SetSwitch(globalCtx, OBJARMOS_GET_7F(&this->dyna.actor)); + sp20 = true; + } + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + + if (!sp20) { + func_809A54B4(this); + } else { + func_809A57D8(this); + } + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + } +} + +void func_809A57D8(ObjArmos* this) { + this->actionFunc = func_809A57F4; + this->unk_24C = 4; +} + +void func_809A57F4(ObjArmos* this, GlobalContext* globalCtx) { + if (fabsf(this->dyna.pushForce) > 0.1f) { + GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } +} + +void ObjArmos_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjArmos* this = THIS; + s32 sp2C; + + this->actionFunc(this, globalCtx); + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + + if (this->unk_24C != 0) { + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 20.0f, 30.0f, 0.0f, this->unk_24C); + + if ((this->actionFunc == func_809A54E0) && (this->dyna.actor.bgCheckFlags & 1) && + (DynaPoly_GetActor(&globalCtx->colCtx, this->dyna.actor.floorBgId) == NULL)) { + this->unk_24C = 0; + } + + this->unk_250.x = (Math_SinS(this->dyna.actor.shape.rot.y) * -9.0f) + this->dyna.actor.world.pos.x; + this->unk_250.y = this->dyna.actor.world.pos.y + 20.0f; + this->unk_250.z = (Math_CosS(this->dyna.actor.shape.rot.y) * -9.0f) + this->dyna.actor.world.pos.z; + + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->dyna.actor.floorPoly, + &sp2C, &this->dyna.actor, &this->unk_250); + } +} + +void func_809A5960(ObjArmos* this, GlobalContext* globalCtx) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + Vec3f sp28; + + sp28.x = Math_SinS(this->dyna.actor.shape.rot.y); + Matrix_SetStateRotationAndTranslation( + (sp28.x * -9.0f) + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + (Math_CosS(this->dyna.actor.shape.rot.y) * -9.0f) + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Scale(0.014f, 0.014f, 0.014f, MTXMODE_APPLY); + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->dyna.actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_809A5A3C(ObjArmos* this, GlobalContext* globalCtx) { + s32 pad[2]; + MtxF sp48; + + if (this->dyna.actor.floorPoly != NULL) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C448(globalCtx->state.gfxCtx); + + gDPSetCombineLERP(POLY_XLU_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, 0, + COMBINED); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); + + func_800C0094(this->dyna.actor.floorPoly, this->unk_250.x, this->dyna.actor.floorHeight, this->unk_250.z, + &sp48); + Matrix_SetCurrentState(&sp48); + Matrix_Scale(0.6f, 1.0f, 0.6f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void ObjArmos_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjArmos* this = THIS; + + func_809A5960(this, globalCtx); + func_809A5A3C(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h index cfc360daa..0a03d4915 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h @@ -2,16 +2,40 @@ #define Z_OBJ_ARMOS_H #include "global.h" +#include "objects/object_am/object_am.h" struct ObjArmos; typedef void (*ObjArmosActionFunc)(struct ObjArmos*, GlobalContext*); +#define OBJARMOS_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJARMOS_GET_ROTZ_7(thisx) ((thisx)->home.rot.z & 7) +#define OBJARMOS_GET_ROTX_F(thisx) ((thisx)->home.rot.x & 0xF) + +enum { + /* 0 */ OBJARMOS_ROT_7_0, + /* 1 */ OBJARMOS_ROT_7_1, + /* 2 */ OBJARMOS_ROT_7_2, + /* 3 */ OBJARMOS_ROT_7_3, + /* 4 */ OBJARMOS_ROT_7_4, + /* 5 */ OBJARMOS_ROT_7_5, + /* 6 */ OBJARMOS_ROT_7_6, +}; + typedef struct ObjArmos { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ SkelAnime skelAnime; + /* 0x01A0 */ Vec3s jointTable[OBJECT_AM_LIMB_MAX]; + /* 0x01F4 */ Vec3s morphTable[OBJECT_AM_LIMB_MAX]; /* 0x0248 */ ObjArmosActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x28]; + /* 0x024C */ u32 unk_24C; + /* 0x0250 */ Vec3f unk_250; + /* 0x025C */ f32* unk_25C; + /* 0x0260 */ f32 unk_260; + /* 0x0264 */ s16 unk_264; + /* 0x0266 */ s16 unk_266[4]; + /* 0x026E */ s16 unk_26E; + /* 0x0270 */ s16 unk_270; } ObjArmos; // size = 0x274 extern const ActorInit Obj_Armos_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index c730153bd..3f0785fbb 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1706,12 +1706,6 @@ D_06000168 = 0x06000168; D_060003F8 = 0x060003F8; D_060004B0 = 0x060004B0; -// ovl_Obj_Armos - -D_0600033C = 0x0600033C; -D_06005948 = 0x06005948; -D_06005CF8 = 0x06005CF8; - // ovl_Obj_Bigicicle D_060009B0 = 0x060009B0; From 84dd09048e6fa4b11ce9b5cf0959068be0dfee84 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Tue, 29 Mar 2022 09:26:46 -0700 Subject: [PATCH 150/257] EffectSsSibuki OK (#735) * OK * Small formating * Fix merge --- spec | 3 +- .../ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c | 106 +++++++++++++++++- 2 files changed, 101 insertions(+), 8 deletions(-) diff --git a/spec b/spec index fe0468dfb..791212700 100644 --- a/spec +++ b/spec @@ -1907,8 +1907,7 @@ beginseg name "ovl_Effect_Ss_Sibuki" compress include "build/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.o" - include "build/data/ovl_Effect_Ss_Sibuki/ovl_Effect_Ss_Sibuki.data.o" - include "build/data/ovl_Effect_Ss_Sibuki/ovl_Effect_Ss_Sibuki.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Sibuki/ovl_Effect_Ss_Sibuki_reloc.o" endseg beginseg diff --git a/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c b/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c index 6d2d4c6dd..d4356f90c 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c +++ b/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c @@ -5,23 +5,117 @@ */ #include "z_eff_ss_sibuki.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rPrimColorR regs[0] +#define rPrimColorG regs[1] +#define rPrimColorB regs[2] +#define rPrimColorA regs[3] +#define rEnvColorR regs[4] +#define rEnvColorG regs[5] +#define rEnvColorB regs[6] +#define rEnvColorA regs[7] +#define rMoveDelay regs[8] +#define rDirection regs[9] +#define rScale regs[10] #define PARAMS ((EffectSsSibukiInitParams*)initParamsx) -s32 EffectSsSibuki_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsSibuki_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsSibuki_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsSibuki_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Sibuki_InitVars = { EFFECT_SS_SIBUKI, EffectSsSibuki_Init, }; -#endif +u32 EffectSsSibuki_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsSibukiInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sibuki/EffectSsSibuki_Init.s") + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sibuki/EffectSsSibuki_Draw.s") + { + TexturePtr tex = (KREG(2) != 0) ? gEffBubble2Tex : gEffBubble1Tex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sibuki/EffectSsSibuki_Update.s") + this->gfx = VIRTUAL_TO_PHYSICAL(SEGMENTED_TO_VIRTUAL(tex)); + } + + this->life = ((s32)((Rand_ZeroOne() * (500.0f + KREG(64))) * 0.01f)) + KREG(65) + 10; + this->rMoveDelay = initParams->moveDelay + 1; + this->draw = EffectSsSibuki_Draw; + this->update = EffectSsSibuki_Update; + this->rDirection = initParams->direction; + this->rScale = initParams->scale; + this->rPrimColorR = 100; + this->rPrimColorG = 100; + this->rPrimColorB = 100; + this->rPrimColorA = 100; + this->rEnvColorR = 255; + this->rEnvColorG = 255; + this->rEnvColorB = 255; + this->rEnvColorA = 255; + + return 1; +} + +void EffectSsSibuki_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + f32 scale = this->rScale / 100.0f; + + OPEN_DISPS(gfxCtx); + + Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, this->rPrimColorA); + gDPSetEnvColor(POLY_OPA_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + gSPSegment(POLY_OPA_DISP++, 0x08, this->gfx); + gSPDisplayList(POLY_OPA_DISP++, gEffBubbleDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsSibuki_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + Player* player = GET_PLAYER(globalCtx); + s32 pad[2]; + f32 xzVelScale; + + if (this->pos.y <= player->actor.floorHeight) { + this->life = 0; + } + + if (this->rMoveDelay != 0) { + this->rMoveDelay--; + + if (this->rMoveDelay == 0) { + s16 yaw = Camera_GetInputDirYaw(Play_GetCamera(globalCtx, CAM_ID_MAIN)); + + xzVelScale = ((200.0f + KREG(20)) * 0.01f) + ((0.1f * Rand_ZeroOne()) * (KREG(23) + 20.0f)); + + if (this->rDirection != 0) { + xzVelScale *= -1.0f; + } + + this->velocity.x = Math_CosS(yaw) * xzVelScale; + this->velocity.z = -Math_SinS(yaw) * xzVelScale; + + this->velocity.y = ((700.0f + KREG(21)) * 0.01f) + ((0.1f * Rand_ZeroOne()) * (KREG(24) + 20.0f)); + this->accel.y = ((-100.0f + KREG(22)) * 0.01f) + ((0.1f * Rand_ZeroOne()) * KREG(25)); + + if (KREG(3) != 0) { + this->velocity.x *= (KREG(3) * 0.01f); + this->velocity.y *= (KREG(3) * 0.01f); + this->velocity.z *= (KREG(3) * 0.01f); + this->accel.y *= (KREG(4) * 0.01f); + } + } + } else { + if (this->rScale != 0) { + this->rScale = (this->rScale - KREG(26)) - 3; + } + } +} From 78acaef73dfb2f5742a9223e3b4c5c5eb16eb9db Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Tue, 29 Mar 2022 13:41:44 -0300 Subject: [PATCH 151/257] `ovl_Boss_03`: Gyorg OK (#736) * Boss03_Init NON_EQUIVALENT * rand functions * Boss03_Draw * match the limb draws * Match Boss03_Init by Synray and Engineer * A bit of cleanup * a bunch of functions * another bunch of functions * func_809E299C and GyorgEffect * import data * A bit of cleanup * effects related functions * func_809E2DA0 * func_809E34B8 NON_EQUIVALENT * func_809E3968 NON_EQUIVALENT * func_809E3D98 * func_809E421C NON_EQUIVALENT * func_809E475C * func_809E497C * func_809E4C90 * func_809E6640 NON_MATCHING * func_809E6A38 * Match func_809E6640 by Tharo * func_809E7D00 * func_809E8810 * func_809E4E80 NON_EQUIVALENT * func_809E5B64 * func_809E6CB4 * Boss03_Update NON_EQUIVALENT * func_809E81E4 attempt * Boss03_Update improvement thanks to Petrie * func_809E81E4 NON_MATCHING * func_809E34B8 is at least equivalent * cleanups * format * import bss * more cleanup and minor renames * Match func_809E81E4 * cleanup effect functions * a few more renames * func_809E4E80 matched by Maide * documentation pass * name workTimer * macros * More renames * Improve func_809E34B8 a bit and match Boss03_ChewPlayer * defines placeholders for work timer, enum for effects and other minor renames * actorfixer * some cleanups * effects named * Some more renames and cleanups * more cleanups * Boss03_UpdateCollision, Boss03_SeaweedUpdate and Boss03_SeaweedDraw * Rename more actionfuncs * cleanup undefined syms * collision stuff and run formatter * more cleanups * more cleanups i forgot to commit * and yet more clenaup * Add notes * Remove debugging stuff * format * Match the last 3 functions by Anon58 * bit of cleaning * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: Derek Hensley * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: Derek Hensley * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: Derek Hensley * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: Derek Hensley * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: Derek Hensley * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: Derek Hensley * PR * format * Remove some if (1) from Boss03_IntroCutscene * Update src/overlays/actors/ovl_Boss_03/z_boss_03.h Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * PR * address pr * prevent_bss_reordering * Anon review * seaweed stuff thanks to elliptic * format * whoops * huh * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * address PR Co-authored-by: EllipticEllipsis * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Address PR Co-authored-by: EllipticEllipsis * Sectioning * whoops * a Co-authored-by: EllipticEllipsis * a * kinda * , * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: Tom Overton * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: Tom Overton * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: Tom Overton * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: Tom Overton * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: Tom Overton * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: Tom Overton * Update src/overlays/actors/ovl_Boss_03/z_boss_03.c Co-authored-by: Tom Overton * remove redundant comment * actorfixer Co-authored-by: Derek Hensley Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Co-authored-by: EllipticEllipsis Co-authored-by: Tom Overton --- assets/xml/objects/object_boss03.xml | 30 +- include/functions.h | 4 +- spec | 4 +- src/code/z_actor.c | 10 +- src/overlays/actors/ovl_Boss_03/z_boss_03.c | 2632 ++++++++++++++++- src/overlays/actors/ovl_Boss_03/z_boss_03.h | 103 +- .../actors/ovl_En_Tanron3/z_en_tanron3.c | 10 +- .../actors/ovl_En_Tanron3/z_en_tanron3.h | 11 - tools/disasm/functions.txt | 80 +- tools/disasm/variables.txt | 26 +- undefined_syms.txt | 15 - 11 files changed, 2712 insertions(+), 213 deletions(-) diff --git a/assets/xml/objects/object_boss03.xml b/assets/xml/objects/object_boss03.xml index e483cbc89..75ce1d3c9 100644 --- a/assets/xml/objects/object_boss03.xml +++ b/assets/xml/objects/object_boss03.xml @@ -49,23 +49,23 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + diff --git a/include/functions.h b/include/functions.h index 42047e7f9..0e641326d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -772,7 +772,7 @@ s32 Actor_OtherIsTargeted(GlobalContext* globalCtx, Actor* actor); void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx); void func_800BC770(GlobalContext* globalCtx, s16 y, s16 countdown); void func_800BC7D8(GlobalContext* globalCtx, s16 y, s16 countdown, s16 speed); -void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 arg2, s16 arg3); +void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 y, s16 countdown); void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type); void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u16 xluFlag, u16 duration); Hilite* func_800BCBF4(Vec3f* arg0, GlobalContext* globalCtx); @@ -3485,7 +3485,7 @@ void func_8019F230(void); // cancel sfx // void func_8019F300(void); void func_8019F420(Vec3f* pos, u16 sfxId); void func_8019F4AC(Vec3f* pos, u16 sfxId); -void func_8019F540(u8 arg0); +void func_8019F540(s8 arg0); void func_8019F570(Vec3f* pos, s8 arg1); // void func_8019F5AC(void); // void func_8019F638(void); diff --git a/spec b/spec index 791212700..20d583887 100644 --- a/spec +++ b/spec @@ -2481,9 +2481,7 @@ beginseg name "ovl_Boss_03" compress include "build/src/overlays/actors/ovl_Boss_03/z_boss_03.o" - include "build/data/ovl_Boss_03/ovl_Boss_03.data.o" - include "build/data/ovl_Boss_03/ovl_Boss_03.bss.o" - include "build/data/ovl_Boss_03/ovl_Boss_03.reloc.o" + include "build/src/overlays/actors/ovl_Boss_03/ovl_Boss_03_reloc.o" endseg beginseg diff --git a/src/code/z_actor.c b/src/code/z_actor.c index a0f479f54..93eeeddc7 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -3799,13 +3799,13 @@ void func_800BC7D8(GlobalContext* globalCtx, s16 y, s16 countdown, s16 speed) { Quake_SetCountdown(idx, countdown); } -void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 arg2, s16 arg3) { - if (arg2 >= 5) { +void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 y, s16 countdown) { + if (y >= 5) { func_8013ECE0(actor->xyzDistToPlayerSq, 255, 20, 150); } else { func_8013ECE0(actor->xyzDistToPlayerSq, 180, 20, 100); } - func_800BC770(globalCtx, arg2, arg3); + func_800BC770(globalCtx, y, countdown); } typedef struct { @@ -4232,11 +4232,11 @@ Gfx D_801AEFA0[] = { gsSPEndDisplayList(), }; -void* func_800BD9A0(GraphicsContext* gfxCtx) { +Gfx* func_800BD9A0(GraphicsContext* gfxCtx) { Gfx* displayListHead; Gfx* displayList; - displayListHead = displayList = GRAPH_ALLOC(gfxCtx, 0x10); + displayListHead = displayList = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); gDPSetRenderMode(displayListHead++, AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.c b/src/overlays/actors/ovl_Boss_03/z_boss_03.c index 70a6405bc..31e8fb0ae 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -4,12 +4,79 @@ * Description: Gyorg */ +/** + * Some notes: + * + * Global flags: + * - gSaveContext.eventInf[5] & 0x40: Enabled when Gyorg's intro cutscene has been watched + * - gSaveContext.save.weekEventReg[55] & 0x80: Checked to know if Gyorg has been defeated + * + * Seaweed: + * - Refers to the seaweed at the bottom of the stage where Player fights Gyorg + * - The default Gyorg actor will spawn 5 other Gyorg instances using the parameter GYORG_PARAM_SEAWEED to spawn them + * - Seaweed can bend when the main Gyorg instance (the actual boss) or Player are near + * + * This actor makes some heavy assumptions about the positions of the room where it is spawned + * + * Cutscenes: + * - There are 3 cutscenes: + * - IntroCutscene: The cs which is played when Player falls into the main room. It also shows Gyorg's titlecard + * - SpawnSmallFishesCutscene: The short cs which is played when Gyorg is spawning the small fishes (EnTanron3). This + * is triggered when Gyorg reaches half of its life + * - DeathCutscene: Played when Gyorg dies. Showing it splashing and becoming smaller each time until it disappears + * - This actor mainly handles the 3 cutscenes it has manually (instead of relying on existing systems for it) + * + * Main behaviour: + * - Gyorg has two types of behaviour depending on Player's state: + * - If Player is standing on the main platform, then Gyorg follows the PrepareCharge -> Charge -> JumpOverPlatform + * branch + * - Otherwise, Gyorg follows the ChasePlayer -> CatchPlayer -> ChewPlayer branch + * - The main actionFunc which decides which branch should be taken is func_809E34B8 + * - Most of the actions of those two branches are constantly checking for the WORK_TIMER_CURRENT_ACTION timer. If it + * runs out, then the behaviour resets back to func_809E34B8 + * - Either branch behaviour can be interrupted at any time by a hit from Player + * - Being hit once makes Gyorg Stunned + * - When Gyorg is Stunned, it is vulnerable to be Damaged by Player + * - When Gyorg's health drops below half, it spawns the small fishes + * + * The collision logic is handled manually + * + * This file is more or less sectioned like this: + * - SpawnEffect + * - RNG + * - Gyorg + * - Init and actionFuncs + * - Cutscenes + * - More actionFuncs and Update + * - Draw + * - Effect Update/Draw + * - Seaweed + */ + #include "z_boss_03.h" +#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_water_effect/object_water_effect.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss03*)thisx) +#define WORK_TIMER_UNK0_A 0 // used in func_809E34B8 +#define WORK_TIMER_CURRENT_ACTION 0 +#define WORK_TIMER_UNK0_C 0 // used in DeathCutscene + +#define WORK_TIMER_UNK1_A 1 // used in func_809E34B8 +#define WORK_TIMER_UNK1_B 1 // used in PrepareCharge + +#define WORK_TIMER_UNK2_A 2 // used in func_809E34B8 +#define WORK_TIMER_STUNNED 2 + +// The Y position of the top of the platform +#define PLATFORM_HEIGHT 440.0f +#define WATER_HEIGHT 430.0f + void Boss03_Init(Actor* thisx, GlobalContext* globalCtx); void Boss03_Destroy(Actor* thisx, GlobalContext* globalCtx); void Boss03_Update(Actor* thisx, GlobalContext* globalCtx); @@ -17,18 +84,200 @@ void Boss03_Draw(Actor* thisx, GlobalContext* globalCtx); void func_809E344C(Boss03* this, GlobalContext* globalCtx); void func_809E34B8(Boss03* this, GlobalContext* globalCtx); -void func_809E3968(Boss03* this, GlobalContext* globalCtx); -void func_809E3D98(Boss03* this, GlobalContext* globalCtx); -void func_809E421C(Boss03* this, GlobalContext* globalCtx); -void func_809E475C(Boss03* this, GlobalContext* globalCtx); -void func_809E497C(Boss03* this, GlobalContext* globalCtx); -void func_809E4C90(Boss03* this, GlobalContext* globalCtx); -void func_809E4E80(Boss03* this, GlobalContext* globalCtx); -void func_809E5B64(Boss03* this, GlobalContext* globalCtx); -void func_809E6640(Boss03* this, GlobalContext* globalCtx); -void func_809E6BC0(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupChasePlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupCatchPlayer(Boss03* this, GlobalContext* globalCtx, u8 arg2); +void Boss03_CatchPlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupChewPlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupPrepareCharge(Boss03* this, GlobalContext* globalCtx); +void Boss03_PrepareCharge(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupCharge(Boss03* this, GlobalContext* globalCtx); +void Boss03_Charge(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupJumpOverPlatform(Boss03* this, GlobalContext* globalCtx); +void Boss03_JumpOverPlatform(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupIntroCutscene(Boss03* this, GlobalContext* globalCtx); +void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx); +void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx); +void Boss03_SpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx); +void Boss03_Stunned(Boss03* this, GlobalContext* globalCtx); +void Boss03_Damaged(Boss03* this, GlobalContext* globalCtx); + +void Boss03_UpdateEffects(GlobalContext* globalCtx); +void Boss03_DrawEffects(GlobalContext* globalCtx); + +void Boss03_SeaweedUpdate(Actor* thisx, GlobalContext* globalCtx); +void Boss03_SeaweedDraw(Actor* thisx, GlobalContext* globalCtx); + +u8 D_809E9840; +// Timer used to start playing the boss background music if the intro cutscene was skipped (because it was already +// watched) +u8 D_809E9841; +// Used to set the timer D_809E9841 in case the intro cutscene was skipped +u8 D_809E9842; + +// Set to Gyorg's projectedPos. sGyorgProjectedPos? +Vec3f D_809E9848; + +GyorgEffect sGyorgEffects[GYORG_EFFECT_COUNT]; + +// Used by the Seaweed variant to interact with the "real" Gyorg boss +Boss03* sGyorgBossInstance; + +void Boss03_PlayUnderwaterSfx(Vec3f* projectedPos, u16 sfxId) { + func_8019F420(projectedPos, sfxId); +} + +/* Start of SpawnEffect section */ + +void Boss03_SpawnEffectWetSpot(GlobalContext* globalCtx, Vec3f* pos) { + s16 i; + GyorgEffect* eff = globalCtx->specialEffects; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++) { + if ((eff->type == GYORG_EFFECT_NONE) || (eff->type == GYORG_EFFECT_BUBBLE)) { + eff->type = GYORG_EFFECT_WET_SPOT; + eff->pos = *pos; + eff->unk_34.x = 0.1f; + eff->unk_34.y = 0.4f; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->alpha = 150; + eff->alphaDelta = Rand_ZeroFloat(4.0f) + 5.0f; + return; + } + + eff++; + } +} + +void Boss03_SpawnEffectDroplet(GlobalContext* globalCtx, Vec3f* pos) { + s16 i; + GyorgEffect* eff = globalCtx->specialEffects; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++) { + if ((eff->type == GYORG_EFFECT_NONE) || (eff->type == GYORG_EFFECT_BUBBLE)) { + eff->type = GYORG_EFFECT_DROPLET; + eff->pos = *pos; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->accel.y = -2.0f; + eff->unk_34.x = 0.1f; + eff->unk_34.y = 0.0f; + eff->unk_34.z = Rand_ZeroFloat(2 * M_PI); + eff->unk_02 = Rand_ZeroFloat(100.0f); + eff->velocity.x = randPlusMinusPoint5Scaled(25.0f); + eff->velocity.z = randPlusMinusPoint5Scaled(25.0f); + return; + } + + eff++; + } +} + +void Boss03_SpawnEffectSplash(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity) { + Vec3f accel = { 0.0f, -1.0f, 0.0f }; + f32 temp_f2; + GyorgEffect* eff = globalCtx->specialEffects; + s16 i; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++) { + if ((eff->type == GYORG_EFFECT_NONE) || (eff->type == GYORG_EFFECT_BUBBLE)) { + eff->type = GYORG_EFFECT_SPLASH; + eff->pos = *pos; + eff->velocity = *velocity; + eff->accel = accel; + temp_f2 = Rand_ZeroFloat(0.02f) + 0.02f; + eff->unk_34.y = temp_f2; + eff->unk_34.x = temp_f2; + eff->unk_34.z = Rand_ZeroFloat(2 * M_PI); + eff->unk_02 = Rand_ZeroFloat(100.0f); + return; + } + + eff++; + } +} + +void Boss03_SpawnEffectBubble(GlobalContext* globalCtx, Vec3f* pos) { + s16 i; + GyorgEffect* eff = globalCtx->specialEffects; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++) { + if (eff->type == GYORG_EFFECT_NONE) { + eff->type = GYORG_EFFECT_BUBBLE; + eff->pos = *pos; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->accel.y = 0.2f; + eff->unk_34.x = Rand_ZeroFloat(0.3f) + 0.2f; + eff->unk_02 = 0; + return; + } + + eff++; + } +} + +/* End of SpawnEffect section */ + +void Boss03_UpdateSphereElement(s32 index, ColliderJntSph* collider, Vec3f* sphereCenter) { + ColliderJntSphElement* sphElement; + + collider->elements[index].dim.worldSphere.center.x = sphereCenter->x; + collider->elements[index].dim.worldSphere.center.y = sphereCenter->y; + collider->elements[index].dim.worldSphere.center.z = sphereCenter->z; + + sphElement = &collider->elements[index]; + sphElement->dim.worldSphere.radius = sphElement->dim.scale * sphElement->dim.modelSphere.radius; +} + +/* Start of RNG section */ + +static s32 sRandSeed0; +static s32 sRandSeed1; +static s32 sRandSeed2; + +void Boss03_SeedRand(s32 seed0, s32 seed1, s32 seed2) { + sRandSeed0 = seed0; + sRandSeed1 = seed1; + sRandSeed2 = seed2; +} + +f32 Boss03_RandZeroOne(void) { + f32 rand; + + // Wichmann-Hill algorithm + sRandSeed0 = (sRandSeed0 * 171) % 30269; + sRandSeed1 = (sRandSeed1 * 172) % 30307; + sRandSeed2 = (sRandSeed2 * 170) % 30323; + + rand = (sRandSeed0 / 30269.0f) + (sRandSeed1 / 30307.0f) + (sRandSeed2 / 30323.0f); + while (rand >= 1.0f) { + rand -= 1.0f; + } + + return fabsf(rand); +} + +/* End of RNG section */ + +// ACTOR_BG_DBLUE_MOVEBG is never spawned naturally on Gyorg's fight +Actor* Boss03_FindActorDblueMovebg(GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; + + while (actor != NULL) { + if (actor->id == ACTOR_BG_DBLUE_MOVEBG) { + return actor; + } + actor = actor->next; + } + + return NULL; +} + +/* Start of Gyorg's Init and actionFuncs section */ -#if 0 const ActorInit Boss_03_InitVars = { ACTOR_BOSS_03, ACTORCAT_BOSS, @@ -41,157 +290,2350 @@ const ActorInit Boss_03_InitVars = { (ActorFunc)Boss03_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_809E8ECC[2] = { +// The limbs referenced here are not used. The spheres are positioned manually by Boss03_PostLimbDraw +static ColliderJntSphElementInit sHeadJntSphElementsInit[] = { { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 0, { { 0, 0, 0 }, 70 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_NONE, { { 0, 0, 0 }, 70 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 1, { { 0, 0, 0 }, 50 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_ROOT, { { 0, 0, 0 }, 50 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809E8F14 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_809E8ECC, // sJntSphElementsInit, +static ColliderJntSphInit sHeadJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sHeadJntSphElementsInit), + sHeadJntSphElementsInit, }; -// static ColliderJntSphElementInit sJntSphElementsInit[5] = { -static ColliderJntSphElementInit D_809E8F24[5] = { +// The limbs referenced here are not used. The spheres are positioned manually by Boss03_PostLimbDraw +static ColliderJntSphElementInit sBodyJntSphElementsInit[] = { { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 2, { { 0, 0, 0 }, 20 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_HEAD, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 5, { { 0, 0, 0 }, 20 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_LOWER_TRUNK, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 6, { { 0, 0, 0 }, 70 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_TAIL, { { 0, 0, 0 }, 70 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 7, { { 0, 0, 0 }, 70 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_RIGHT_FIN_ROOT, { { 0, 0, 0 }, 70 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 8, { { 0, 0, 0 }, 30 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_UPPER_RIGHT_FIN, { { 0, 0, 0 }, 30 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809E8FD8 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 5, D_809E8F24, // sJntSphElementsInit, +static ColliderJntSphInit sBodyJntSphInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sBodyJntSphElementsInit), + sBodyJntSphElementsInit, }; -#endif +Vec3f sGyorgInitialPos = { 1216.0f, 140.0f, -1161.0f }; -extern ColliderJntSphElementInit D_809E8ECC[2]; -extern ColliderJntSphInit D_809E8F14; -extern ColliderJntSphElementInit D_809E8F24[5]; -extern ColliderJntSphInit D_809E8FD8; +// unused +Vec3f D_809E8FF4[] = { + { 261.0f, 140.0f, -1000.0f }, { -504.0f, 120.0f, -1276.0f }, { -1157.0f, 80.0f, -836.0f }, + { -1020.0f, 120.0f, 381.0f }, { -34.0f, 120.0f, 1213.0f }, { 803.0f, 80.0f, 1250.0f }, + { 1143.0f, 120.0f, 605.0f }, { 1228.0f, 140.0f, -244.0f }, { 1216.0f, 140.0f, -1161.0f }, + { 261.0f, 140.0f, -1000.0f }, { -504.0f, 120.0f, -890.0f }, { -1157.0f, 80.0f, -836.0f }, + { -1020.0f, 120.0f, 381.0f }, { -34.0f, 120.0f, 1213.0f }, { 803.0f, 80.0f, 1250.0f }, + { 1143.0f, 120.0f, 605.0f }, { 1228.0f, 140.0f, -244.0f }, { 0.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f }, +}; -extern UNK_TYPE D_06007EB0; -extern UNK_TYPE D_06007EC8; -extern UNK_TYPE D_06009554; -extern UNK_TYPE D_060099D0; -extern UNK_TYPE D_06009C14; -extern UNK_TYPE D_06009CF8; -extern UNK_TYPE D_0600A6C8; +Color_RGBA8 sGyorgDustPrimColor = { 60, 50, 20, 255 }; +Color_RGBA8 sGyorgDustEnvColor = { 40, 30, 30, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2760.s") +/** + * Used when chasing Player and Gyorg is near the bottom + */ +void Boss03_SpawnDust(Boss03* this, GlobalContext* globalCtx) { + if (this->insideJawPos.y < 80.0f) { + u8 i; + Vec3f pos; + Vec3f velocity; + Vec3f accel; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2788.s") + for (i = 0; i < 5; i++) { + velocity.x = randPlusMinusPoint5Scaled(10.0f); + velocity.y = Rand_ZeroFloat(2.0f) + 2.0f; + velocity.z = randPlusMinusPoint5Scaled(10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2880.s") + accel.y = -0.075f; + accel.z = 0.0f; + accel.x = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E299C.s") + pos.y = Rand_ZeroFloat(20.0f) + 5.0f; + pos.z = randPlusMinusPoint5Scaled(150.0f) + this->insideJawPos.z; + pos.x = randPlusMinusPoint5Scaled(150.0f) + this->insideJawPos.x; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2AB4.s") + func_800B0EB0(globalCtx, &pos, &velocity, &accel, &sGyorgDustPrimColor, &sGyorgDustEnvColor, + Rand_ZeroFloat(200.0f) + 400.0f, 10, Rand_ZeroFloat(10.0f) + 25.0f); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2B8C.s") +void Boss03_Init(Actor* thisx, GlobalContext* globalCtx2) { + Boss03* this = THIS; + s32 i; + GlobalContext* globalCtx = globalCtx2; + Vec3f sp70; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2C1C.s") + if (gSaveContext.save.weekEventReg[55] & 0x80) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, PLATFORM_HEIGHT, + 200.0f, 0, 0, 0, ENDOORWARP1_FF_1); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 0.0f, PLATFORM_HEIGHT, 0.0f, 0, 0, 0, 0); + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2C3C.s") + if (this->actor.params == GYORG_PARAM_SEAWEED) { + this->actor.update = Boss03_SeaweedUpdate; + this->actor.draw = Boss03_SeaweedDraw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2D64.s") + this->unk_240 = Rand_ZeroFloat(1000.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2DA0.s") + this->actor.scale.x = Rand_ZeroFloat(0.0075f) + 0.027f; + this->actor.scale.y = 0.02f; + this->actor.scale.z = 0.015f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/Boss03_Init.s") + // Manually set the joint table of seaweed + for (i = 0; i < 6; i++) { + this->jointTable[i].x = Math_SinS(this->unk_240 * 0x100 + i * 15000) * 3000.0f; + this->jointTable[i].y = Math_SinS(this->unk_240 * 0x180 + i * 20000) * 2000.0f; + this->jointTable[i].z = Math_SinS(this->unk_240 * 0x10 + i * 19000) * 4000.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/Boss03_Destroy.s") + this->actor.flags &= ~ACTOR_FLAG_1; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E344C.s") + this->actor.world.pos = sGyorgInitialPos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E34B8.s") + // Since Boss03_RandZeroOne is only used on this Init function, the resulting values end up being deterministic + Boss03_SeedRand(1, 29093, 9786); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E38EC.s") + for (i = 0; i < 5; i++) { + f32 rand; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E3968.s") + rand = Boss03_RandZeroOne(); + Matrix_InsertYRotation_f((rand * M_PI * 0.2f) + ((2.0f * M_PI / 5.0f) * i), MTXMODE_NEW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E3D34.s") + rand = Boss03_RandZeroOne(); + Matrix_GetStateTranslationAndScaledZ((rand * 800.0f) + 400.0f, &sp70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E3D98.s") + rand = Boss03_RandZeroOne(); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_03, sp70.x, sp70.y, sp70.z, 0, rand * 0x10000, 0, + GYORG_PARAM_SEAWEED); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4180.s") + sGyorgBossInstance = this; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E421C.s") + globalCtx->specialEffects = sGyorgEffects; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4674.s") + for (i = 0; i < ARRAY_COUNT(sGyorgEffects); i++) { + sGyorgEffects[i].type = GYORG_EFFECT_NONE; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E475C.s") + this->actor.targetMode = 5; + this->actor.colChkInfo.mass = MASS_HEAVY; + this->actor.colChkInfo.health = 10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4910.s") + Collider_InitAndSetJntSph(globalCtx, &this->headCollider, &this->actor, &sHeadJntSphInit, + this->headColliderElements); + Collider_InitAndSetJntSph(globalCtx, &this->bodyCollider, &this->actor, &sBodyJntSphInit, + this->bodyColliderElements); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGyorgSkel, &gGyorgCrawlingAnim, this->jointTable, + this->morphTable, GYORG_LIMB_MAX); + Actor_SetScale(&this->actor, 0.2f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E497C.s") + // gSaveContext.eventInf[5] & 0x40: intro cutscene already watched + if ((KREG(64) != 0) || (gSaveContext.eventInf[5] & 0x40)) { + this->actionFunc = func_809E344C; + D_809E9842 = false; + Audio_QueueSeqCmd(NA_BGM_STOP | 0x10000); + } else { + Boss03_SetupIntroCutscene(this, globalCtx); + D_809E9842 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4C34.s") + this->numSpawnedSmallFish = -1; + this->waterHeight = WATER_HEIGHT; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4C90.s") +void Boss03_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Boss03* this = THIS; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4E2C.s") +/* Start of ActionFuncs section */ -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4E80.s") +void func_809E344C(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E5ADC.s") + // Mid-air + if (player->actor.world.pos.y < 540.0f) { + this->actionFunc = func_809E34B8; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -15.0f); + this->unk_274 = 0; + this->actor.flags |= ACTOR_FLAG_1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E5B64.s") +/** + * Swims randomly until WORK_TIMER_UNK1_A runs out + */ +void func_809E34B8(Boss03* this, GlobalContext* globalCtx) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 bodyYRotTarget; + s32 pad; + s16 i; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E65F4.s") + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_WAIT_OLD - SFX_FLAG); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6640.s") + this->unk_276 = 0x800; + this->skelAnime.playSpeed = 1.0f; + this->unk_27C = 1.0f; + this->unk_278 = 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E69A4.s") + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6A38.s") + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6B70.s") + xDiff = this->unk_268.x - this->actor.world.pos.x; + yDiff = this->unk_268.y - this->actor.world.pos.y; + zDiff = this->unk_268.z - this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6BC0.s") + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6CB4.s") + bodyYRotTarget = + Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * -0.5f; + Math_ApproachS(&this->bodyYRot, bodyYRotTarget, 5, 0x100); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/Boss03_Update.s") + Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); + Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, this->unk_27C); + Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E7920.s") + if ((this->workTimer[WORK_TIMER_UNK2_A] == 0) && (this->actor.bgCheckFlags & 8)) { + Matrix_GetStateTranslationAndScaledZ(-500.0f, &this->unk_268); + this->unk_268.y = Rand_ZeroFloat(100.0f) + 150.0f; + this->workTimer[WORK_TIMER_UNK2_A] = 60; + this->workTimer[WORK_TIMER_UNK0_A] = Rand_ZeroFloat(60.0f) + 60.0f; + this->unk_274 = 0x100; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E79C4.s") + if (this->workTimer[WORK_TIMER_UNK2_A] == 0) { + if ((sqrtf(SQ(xDiff) + SQ(zDiff)) < 100.0f) || (this->workTimer[WORK_TIMER_UNK0_A] == 0)) { + for (i = 0; i < 200; i++) { + this->unk_268.x = randPlusMinusPoint5Scaled(2500.0f); + this->unk_268.y = Rand_ZeroFloat(100.0f) + 150.0f; + this->unk_268.z = randPlusMinusPoint5Scaled(2500.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E7AA8.s") + xDiff = this->unk_268.x - this->actor.world.pos.x; + zDiff = this->unk_268.z - this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/Boss03_Draw.s") + if (sqrtf(SQ(xDiff) + SQ(zDiff)) > 300.0f) { + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E7D00.s") + this->unk_274 = 0x100; + this->workTimer[WORK_TIMER_UNK0_A] = Rand_ZeroFloat(60.0f) + 60.0f; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E81E4.s") + Actor_MoveWithoutGravityReverse(&this->actor); + Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, this->unk_274 * 2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E8810.s") + if (this->workTimer[WORK_TIMER_UNK1_A] == 0) { + // Player is above water && Player is standing on ground + if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { + Boss03_SetupPrepareCharge(this, globalCtx); + } else if ((player->transformation != PLAYER_FORM_GORON) && (player->transformation != PLAYER_FORM_DEKU)) { + if (KREG(70) == 0) { + Boss03_SetupChasePlayer(this, globalCtx); + } else if (this->numSpawnedSmallFish <= 0) { + Boss03_SetupChasePlayer(this, globalCtx); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E8BEC.s") +void Boss03_SetupChasePlayer(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_ChasePlayer; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -10.0f); + this->workTimer[WORK_TIMER_CURRENT_ACTION] = 100; + this->unk_276 = 0x1000; + this->skelAnime.playSpeed = 1.5f; + this->unk_278 = 10.0f; + this->unk_27C = 1.0f; +} + +/** + * Approach Player until near enough, then try to catch Player, unless it has since got back on the platform + */ +void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 bodyYRotTarget; + Vec3f sp50; + s32 pad; + f32 phi_f2; + f32 sp44; + u8 sp43; + + this->unk_2BD = true; + + SkelAnime_Update(&this->skelAnime); + + xDiff = player->actor.world.pos.x - this->actor.world.pos.x; + yDiff = (player->actor.world.pos.y - this->actor.world.pos.y) + 50.0f; + zDiff = player->actor.world.pos.z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); + bodyYRotTarget = + Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * -0.5f; + Math_ApproachS(&this->bodyYRot, bodyYRotTarget, 5, 0x100); + + Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); + Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, this->unk_27C); + Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Actor_MoveWithoutGravityReverse(&this->actor); + + Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, this->unk_274 * 2); + + // If either (Player is standing on ground && Player is above water) or (WORK_TIMER_CURRENT_ACTION timer runs out), + // then stop chasing + if (((player->actor.bgCheckFlags & 1) && (player->actor.shape.feetPos[0].y >= WATER_HEIGHT + 8.0f)) || + (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0)) { + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + } + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 100; + } else { + if ((this->waterHeight - 80.0f) < player->actor.world.pos.y) { + sp43 = 1; + phi_f2 = 100.0f; + sp44 = 50.0f; + } else { + sp43 = 0; + phi_f2 = 200.0f; + sp44 = 100.0f; + } + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(sp44, &sp50); + + xDiff = sp50.x - player->actor.world.pos.x; + zDiff = sp50.z - player->actor.world.pos.z; + + if (sqrtf(SQ(xDiff) + SQ(zDiff)) < (2.0f * phi_f2)) { + Math_ApproachS(&this->jawZRot, 0x3200, 2, 0x1800); + this->unk_278 = 25.0f; + this->unk_27C = 5.0f; + this->skelAnime.playSpeed = 2.5f; + } + + // Near enough to Player? + if (sqrtf(SQ(xDiff) + SQ(zDiff)) < phi_f2) { + Boss03_SetupCatchPlayer(this, globalCtx, sp43); + + if (sp43 != 0) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, player->actor.world.pos.x, + this->waterHeight, player->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_777); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_SINK_OLD); + } + + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_UTSUBO_EAT); + } + } + + Boss03_SpawnDust(this, globalCtx); +} + +void Boss03_SetupCatchPlayer(Boss03* this, GlobalContext* globalCtx, u8 arg2) { + this->actionFunc = Boss03_CatchPlayer; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -15.0f); + this->workTimer[WORK_TIMER_CURRENT_ACTION] = 100; + this->unk_2C4 = 0.0f; + this->unk_2B8 = 0.0f; + this->unk_242 = arg2; +} + +void Boss03_CatchPlayer(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 xDiff; + f32 yDiff; + f32 zDiff; + s32 pad; + + this->skelAnime.playSpeed = 2.0f; + this->unk_27C = 2.0f; + this->unk_276 = 0x1000; + this->unk_2BD = true; + this->unk_278 = 15.0f; + this->actor.flags &= ~ACTOR_FLAG_1; + + SkelAnime_Update(&this->skelAnime); + + xDiff = player->actor.world.pos.x - this->actor.world.pos.x; + yDiff = player->actor.world.pos.y - this->actor.world.pos.y; + zDiff = player->actor.world.pos.z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); + Math_ApproachS(&this->bodyYRot, + Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * + -0.5f, + 5, 0x100); + Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); + Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, this->unk_27C); + Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Actor_MoveWithoutGravityReverse(&this->actor); + Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, this->unk_274 * 2); + + // If either (Player is standing on ground && Player is above water) or (WORK_TIMER_CURRENT_ACTION timer runs out) + // then stop trying to catch Player + if (((player->actor.bgCheckFlags & 1) && (player->actor.shape.feetPos[FOOT_LEFT].y >= WATER_HEIGHT + 8.0f)) || + (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0)) { + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + func_80165690(); + } + + func_809E344C(this, globalCtx); + // WORK_TIMER_UNK1_A wasn't set + } else { + f32 phi_f0; + + Math_ApproachF(&player->actor.world.pos.x, this->insideJawPos.x, 1.0f, this->unk_2B8); + Math_ApproachF(&player->actor.world.pos.y, this->insideJawPos.y, 1.0f, this->unk_2B8); + Math_ApproachF(&player->actor.world.pos.z, this->insideJawPos.z, 1.0f, this->unk_2B8); + + if (this->unk_242 != 0) { + phi_f0 = 10.0f; + } else { + phi_f0 = 2.0f; + } + + Math_ApproachF(&this->unk_2B8, 100.0f, 1.0f, phi_f0); + + if (this->unk_2B8 > 30.0f) { + if ((&this->actor != player->actor.parent) && (globalCtx->grabPlayer(globalCtx, player) != 0)) { + player->actor.parent = &this->actor; + Audio_PlaySfxGeneral(NA_SE_VO_LI_DAMAGE_S, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, + &D_801DB4B8); + Boss03_SetupChewPlayer(this, globalCtx); + } + } else { + Math_ApproachS(&this->jawZRot, 0x3200, 2, 0xC00 * phi_f0); + } + + Math_ApproachS(&player->actor.world.rot.x, 0x4000, 1, 0x400); + Math_ApproachS(&player->actor.shape.rot.x, 0x4000, 1, 0x400); + Math_ApproachS(&player->actor.world.rot.y, this->unk_2A2.y, 1, 0x400); + Math_ApproachS(&player->actor.shape.rot.y, this->unk_2A2.y, 1, 0x400); + } + + Boss03_SpawnDust(this, globalCtx); +} + +void Boss03_SetupChewPlayer(Boss03* this, GlobalContext* globalCtx) { + s16 pitchAngle; + Vec3f out; + + this->actionFunc = Boss03_ChewPlayer; + + pitchAngle = Math_FAtan2F(this->actor.world.pos.z, this->actor.world.pos.x); + Matrix_RotateY(pitchAngle, MTXMODE_NEW); + + out.x = 0.0f; + out.y = 200.0f; + out.z = 700.0f; + Matrix_MultiplyVector3fByState(&out, &this->unk_268); + + this->unk_276 = 0x800; + this->unk_242 = 0; + this->workTimer[WORK_TIMER_CURRENT_ACTION] = 100; + this->skelAnime.playSpeed = 1.0f; +} + +void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Input* input = CONTROLLER1(globalCtx); + f32 jawZRotTarget; + f32 xDiff; + f32 yDiff; + f32 zDiff; + + this->unk_2BD = true; + this->unk_25C = 15; + + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 90) { + func_8016566C(0x96); + } + + SkelAnime_Update(&this->skelAnime); + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + + xDiff = this->unk_268.x - this->actor.world.pos.x; + yDiff = this->unk_268.y - this->actor.world.pos.y; + zDiff = this->unk_268.z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); + Math_ApproachS(&this->bodyYRot, + Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * + -0.5f, + 5, 0x100); + Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); + Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + + switch (this->unk_242) { + case 0: + Math_ApproachF(&this->actor.speedXZ, 10.0f, 1.0f, 1.0f); + if (sqrtf(SQ(xDiff) + SQ(zDiff)) < 100.0f) { + this->unk_242 = 1; + Animation_MorphToLoop(&this->skelAnime, &gGyorgBackingUpAnim, -15.0f); + } + break; + + case 1: + Math_ApproachF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f); + Math_ApproachF(&this->actor.world.pos.y, 200.0f, 0.05f, 5.0f); + break; + } + + Actor_MoveWithoutGravityReverse(&this->actor); + + Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, this->unk_274 * 2); + + // Mashing A or B reduces the time Gyorg is chewing Player + if (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_B)) { + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] != 0) { + this->workTimer[WORK_TIMER_CURRENT_ACTION]--; + } + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] != 0) { + this->workTimer[WORK_TIMER_CURRENT_ACTION]--; + } + } + + // Stop chewing when the timer runs out + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0) { + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + func_80165690(); + func_800B8D50(globalCtx, NULL, 10.0f, this->actor.shape.rot.y, 0.0f, 0x20); + } + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = Rand_ZeroFloat(100.0f) + 200.0f; + + return; + } + + player->actor.world.pos = this->insideJawPos; + + jawZRotTarget = Math_SinS(this->unk_240 * 0x2000); + Math_ApproachS(&this->jawZRot, jawZRotTarget * 2000.0f, 2, 0x3000); + + player->actor.shape.rot.x = 0x4000; + player->actor.world.rot.x = player->actor.shape.rot.x; + + player->actor.world.rot.y = player->actor.shape.rot.y = this->unk_2A2.y; + + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] < 5) { + Math_ApproachS(&this->jawZRot, 0x3200, 2, 0x1800); + Math_ApproachF(&this->unk_2C4, 100.0f, 1.0f, 100.0f); + } else { + Math_ApproachF(&this->unk_2C4, -300.0f, 1.0f, 5.0f); + if ((this->unk_240 % 8) == 0) { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_BITE_OLD); + } + } +} + +void Boss03_SetupPrepareCharge(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_PrepareCharge; + Animation_MorphToLoop(&this->skelAnime, &gGyorgBackingUpAnim, -15.0f); + this->workTimer[WORK_TIMER_CURRENT_ACTION] = Rand_ZeroFloat(30.0f) + 80.0f; + this->workTimer[WORK_TIMER_UNK1_B] = 50; + this->unk_274 = 0; + + if (sqrtf(SQXZ(this->actor.world.pos)) > 600.0f) { + if (Rand_ZeroOne() < 0.5f) { + this->unk_242 = 1; + } else { + this->unk_242 = 0; + } + } else { + this->unk_242 = 0; + } +} + +/** + * Slowly turns back while looking at Player during WORK_TIMER_CURRENT_ACTION frames, then prepares to charge + */ +void Boss03_PrepareCharge(Boss03* this, GlobalContext* globalCtx) { + f32 posYTarget; + Player* player = GET_PLAYER(globalCtx); + + if (this->workTimer[WORK_TIMER_UNK1_B] != 0) { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_WAIT_OLD - SFX_FLAG); + } + + // Rotate towards Player + Math_ApproachS(&this->bodyYRot, + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xA, this->unk_274, 0) * + -0.7f, + 5, 0x200); + Math_ApproachS(&this->unk_274, 0x800, 1, 0x100); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 0x1000); + Math_ApproachS(&this->actor.world.rot.x, 0, 0xA, 0x200); + Math_ApproachS(&this->actor.shape.rot.x, 0, 0xA, 0x200); + + posYTarget = this->waterHeight - 70.0f; + if (posYTarget < this->actor.world.pos.y) { + Math_ApproachF(&this->actor.world.pos.y, posYTarget, 0.05f, 5.0f); + } + + SkelAnime_Update(&this->skelAnime); + + // Player is above water && Player is standing on ground + if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0) { + Boss03_SetupCharge(this, globalCtx); + } + } else if (player->actor.world.pos.y <= this->waterHeight) { + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 20; + } + + // Turns back slowly + Math_ApproachF(&this->actor.speedXZ, -3.0f, 1.0f, 0.5f); + Actor_MoveWithoutGravityReverse(&this->actor); +} + +void Boss03_SetupCharge(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->actionFunc = Boss03_Charge; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -15.0f); + this->unk_268 = player->actor.world.pos; +} + +/** + * Charge against the platform, either by clashing against the platform or by preparing to jump over it + */ +void Boss03_Charge(Boss03* this, GlobalContext* globalCtx) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + Player* player = GET_PLAYER(globalCtx); + s16 rotXTarget; + + this->skelAnime.playSpeed = 2.0f; + SkelAnime_Update(&this->skelAnime); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_PREATTACK_OLD - SFX_FLAG); + + xDiff = this->unk_268.x - this->actor.world.pos.x; + yDiff = (this->unk_268.y - this->actor.world.pos.y) - 50.0f; + zDiff = this->unk_268.z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, 0x1000); + + rotXTarget = Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff); + Math_ApproachS(&this->actor.world.rot.x, rotXTarget, 0xA, 0x1000); + + this->actor.shape.rot = this->actor.world.rot; + + Math_ApproachF(&this->actor.speedXZ, 25.0f, 1.0f, 3.0f); + Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Actor_MoveWithoutGravityReverse(&this->actor); + + if (this->actor.speedXZ >= 20.0f) { + // Jump over platform + if (this->unk_242 == 1) { + if (sqrtf(SQXZ(this->actor.world.pos)) < 700.0f) { + Boss03_SetupJumpOverPlatform(this, globalCtx); + return; + } + } + + // Attack platform + if (this->actor.bgCheckFlags & 8) { + play_sound(NA_SE_IT_BIG_BOMB_EXPLOSION); + func_800BC848(&this->actor, globalCtx, 20, 15); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, 0.0f, this->waterHeight, 0.0f, 0, 0, + 0x96, ENWATEREFFECT_780); + + // Player is above water && Player is standing on ground + if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { + func_800B8D50(globalCtx, NULL, 7.0f, Math_FAtan2F(player->actor.world.pos.z, player->actor.world.pos.x), + 7.0f, 0); + } + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 50; + } + } +} + +void Boss03_SetupJumpOverPlatform(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_JumpOverPlatform; + this->actor.gravity = -2.0f; + this->actor.velocity.y = 30.0f; + this->actor.speedXZ = 25.0f; + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_JUMP_OLD); +} + +void Boss03_JumpOverPlatform(Boss03* this, GlobalContext* globalCtx) { + this->bubbleEffectSpawnCount = 0; + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_JUMP_LEV_OLD - SFX_FLAG); + + this->skelAnime.playSpeed = 2.0f; + SkelAnime_Update(&this->skelAnime); + + Math_ApproachS(&this->actor.world.rot.x, this->actor.velocity.y * -300.0f, 2, 0x2000); + this->actor.shape.rot.x = this->actor.world.rot.x; + + Actor_MoveWithGravity(&this->actor); + if ((this->actor.velocity.y < 0.0f) && (this->actor.world.pos.y < this->waterHeight + 50.0f)) { + this->bubbleEffectSpawnCount = 2; + this->actor.gravity = 0.0f; + Math_ApproachZeroF(&this->actor.velocity.y, 1.0f, 1.0f); + if (this->actor.velocity.y == 0.0f) { + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 50; + } + } else { + s16 i; + Vec3f sp30; + + for (i = 0; i < 3; i++) { + sp30.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(150.0f); + sp30.y = this->actor.world.pos.y; + sp30.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(150.0f); + Boss03_SpawnEffectDroplet(globalCtx, &sp30); + } + } +} + +/* End of Gyorg's Init and actionFuncs section */ + +/* Start of Gyorg's Cutscenes section */ + +void Boss03_SetupIntroCutscene(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_IntroCutscene; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -10.0f); + this->skelAnime.playSpeed = 2.0f; +} + +Vec3f D_809E9104[] = { + { 770.0f, 200.0f, 720.0f }, + { 831.0f, 200.0f, -570.0f }, + { 0.0f, 450.0f, 0.0f }, +}; + +void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx) { + s16 i; + Vec3f effectPos; + f32 xDiff; + f32 yDiff; + f32 zDiff; + s32 pad; + f32 sp5C; + s16 sp5A; + s16 pad2; + s16 bubblesToSpawnNum = 0; + f32 phi_f2; + Player* player = GET_PLAYER(globalCtx); + + this->bubbleEffectSpawnCount = 0; + this->csTimer++; + this->unk_290 = 0; + + sp5A = 0x4BC; + + switch (this->csState) { + case 0: + if (player->actor.world.pos.y < 1350.0f) { + Cutscene_Start(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 7); + this->csCamId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->csCamId, 7); + + this->actor.world.rot.y = -0x7B30; + this->prevPlayerPos.y = 1850.0f; + + this->actor.world.pos.x = 1400.0f; + this->actor.world.pos.y = 130.0f; + this->actor.world.pos.z = 1400.0f; + + player->actor.shape.rot.y = 0; + player->actor.world.pos.y = 1850.0f; + player->actor.world.rot.y = player->actor.shape.rot.y; + + this->csCamAt.y = player->actor.world.pos.y + 30.0f; + this->csState = 1; + this->csTimer = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + this->unk_2D5 = true; + + this->cameraFov = KREG(14) + 60.0f; + + case 1: + player->actor.world.pos.z = 0.0f; + player->actor.world.pos.x = 0.0f; + player->actor.speedXZ = 0.0f; + + this->csCamEye.x = 100.0f; + this->csCamEye.y = 540.0f; + + this->csCamEye.z = player->actor.world.pos.z + 100.0f; + this->csCamAt.x = player->actor.world.pos.x; + + Math_ApproachF(&this->csCamAt.y, player->actor.world.pos.y + 30.0f, 0.5f, 100.0f); + this->csCamAt.z = player->actor.world.pos.z; + + if (this->csTimer > 105) { + this->csState = 2; + this->csTimer = 0; + this->unk_240 = 0; + func_8016566C(0x96); + this->cameraFov = 80.0f; + + case 2: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_DEMO_MOVE_OLD - SFX_FLAG); + + xDiff = D_809E9104[this->unk_242].x - this->actor.world.pos.x; + yDiff = D_809E9104[this->unk_242].y - this->actor.world.pos.y; + zDiff = D_809E9104[this->unk_242].z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), + 0xA, this->unk_274); + Math_ApproachS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274); + Math_ApproachS(&this->unk_274, 0x200, 1, 0x10); + + if ((this->csTimer > 30) && (this->csTimer < 50)) { + bubblesToSpawnNum = 2; + } + + if ((this->csTimer == 40) || (this->csTimer == (u32)(KREG(91) + 270))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_WATER_DEEP); + } + + if (this->csTimer > 50) { + Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, 0.1f); + } + + if (this->unk_242 < 2) { + if (sqrtf(SQ(xDiff) + SQ(zDiff)) < 100.0f) { + this->unk_242++; + this->unk_274 = 0; + if (this->unk_242 >= 2) { + this->csTimer = 100; + } + } + this->unk_278 = 5.0f; + } else { + this->unk_278 = 0.0f; + bubblesToSpawnNum = 1; + if ((this->actor.speedXZ == 0.0f) && (this->csTimer > 230)) { + this->csState = 3; + this->csTimer = 0; + } + if (this->csTimer == 165) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_WATER_MID); + } + if (this->csTimer == 180) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_WATER_DEEP); + } + } + } + } + break; + + case 3: + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_PREATTACK_OLD - SFX_FLAG); + sp5A = 0x1970; + Math_ApproachF(&this->actor.speedXZ, 15.0f, 1.0f, 2.0f); + if (this->csTimer > 20) { + this->csState = 4; + this->csTimer = 0; + } + break; + + case 4: + player->actor.world.rot.y = player->actor.shape.rot.y = 0; + + if (this->csTimer == 5) { + // Rotates Player towards Gyorg + func_800B7298(globalCtx, &this->actor, 8); + } + + this->csCamEye.x = player->actor.world.pos.x + 30.0f; + this->csCamEye.y = player->actor.world.pos.y + Player_GetHeight(player) - 4.0f + BREG(17); + this->csCamEye.z = player->actor.world.pos.z - 30.0f; + + this->csCamAt.x = player->actor.world.pos.x; + this->csCamAt.y = player->actor.world.pos.y + Player_GetHeight(player) - 18.0f + 6.0f + BREG(18); + this->csCamAt.z = player->actor.world.pos.z; + + if (player->transformation == PLAYER_FORM_FIERCE_DEITY) { + this->csCamEye.y -= 60.0f; + this->csCamAt.y -= 35.0f; + } + + this->cameraFov = 60.0f; + if (this->csTimer == 16) { + this->csState = 5; + this->csTimer = 0; + this->unk_2D5 = false; + this->actor.speedXZ = -200.0f; + Actor_MoveWithoutGravityReverse(&this->actor); + this->actor.world.pos.y = this->waterHeight - 150.0f; + func_80165690(); + + case 5: + SkelAnime_Update(&this->skelAnime); + this->actor.speedXZ = 20.0f; + Actor_MoveWithoutGravityReverse(&this->actor); + player->actor.shape.rot.y = -0x1470; + player->actor.world.rot.y = player->actor.shape.rot.y; + + this->csCamEye.x = player->actor.world.pos.x + 30.0f - 90.0f + 300.0f; + this->csCamEye.y = player->actor.world.pos.y + 40.0f + 10.0f; + this->csCamEye.z = player->actor.world.pos.z - 30.0f + 160.0f + 300.0f; + + this->csCamAt.x = this->actor.world.pos.x; + this->csCamAt.y = this->actor.world.pos.y - 100.0f; + this->csCamAt.z = this->actor.world.pos.z; + + if (this->csTimer == 10) { + this->actor.velocity.y = 30.0f; + this->csState = 6; + this->csTimer = 0; + this->actor.gravity = -1.5f; + this->actor.speedXZ = 20.0f; + + Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_JUMP_OLD); + this->skelAnime.playSpeed = 1.0f; + } + } + break; + + case 6: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_JUMP_LEV_OLD - SFX_FLAG); + + if (this->csTimer == 30) { + TitleCard_InitBossName(&globalCtx->state, &globalCtx->actorCtx.titleCtxt, + Lib_SegmentedToVirtual(gGyorgTitleCardTex), 160, 180, 128, 40); + } + + if ((this->csTimer < 24) || (this->csTimer >= 90)) { + SkelAnime_Update(&this->skelAnime); + Math_ApproachS(&this->actor.world.rot.x, this->actor.velocity.y * -300.0f, 3, 0x1000); + Actor_MoveWithGravity(&this->actor); + if ((this->actor.velocity.y <= 0.0f) && (this->actor.world.pos.y < (this->waterHeight + 50.0f))) { + this->bubbleEffectSpawnCount = 2; + this->actor.gravity = 0.0f; + Math_ApproachZeroF(&this->actor.velocity.y, 1.0f, 1.0f); + Math_ApproachZeroF(&this->actor.speedXZ, 1.0f, 0.5f); + } else { + if (1) {} + if (1) {} + if (1) {} + + for (i = 0; i < 3; i++) { + effectPos.x = randPlusMinusPoint5Scaled(150.0f) + this->actor.world.pos.x; + effectPos.y = this->actor.world.pos.y; + effectPos.z = randPlusMinusPoint5Scaled(150.0f) + this->actor.world.pos.z; + + Boss03_SpawnEffectDroplet(globalCtx, &effectPos); + } + + this->csCamTargetAt.x = this->actor.world.pos.x; + this->csCamTargetAt.y = this->actor.world.pos.y - 100.0f; + this->csCamTargetAt.z = this->actor.world.pos.z; + } + } else { + Math_ApproachF(&this->csCamEye.x, player->actor.world.pos.x + 30.0f - 90.0f + 300.0f - 90.0f, 0.05f, + 3.0f); + Math_ApproachF(&this->csCamEye.y, player->actor.world.pos.y + 40.0f + 10.0f + 90.0f, 0.05f, 3.0f); + Math_ApproachF(&this->csCamEye.z, player->actor.world.pos.z - 30.0f + 160.0f + 300.0f - 90.0f, 0.05f, + 3.0f); + Math_ApproachF(&this->unk_568, 90.0f, 0.05f, 3.0f); + } + + Math_ApproachF(&this->csCamAt.x, this->csCamTargetAt.x, 0.5f, 100.0f); + Math_ApproachF(&this->csCamAt.y, this->csCamTargetAt.y + this->unk_568, 0.5f, 100.0f); + Math_ApproachF(&this->csCamAt.z, this->csCamTargetAt.z, 0.5f, 100.0f); + + if (this->csTimer == 145) { + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + + camera->eye = this->csCamEye; + camera->eyeNext = this->csCamEye; + camera->at = this->csCamAt; + + func_80169AFC(globalCtx, this->csCamId, 0); + Cutscene_End(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); + this->csCamId = 0; + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 50; + + gSaveContext.eventInf[5] |= 0x40; + } + break; + } + + this->actor.shape.rot = this->actor.world.rot; + + if ((this->csState == 2) || (this->csState == 3)) { + Actor_MoveWithoutGravityReverse(&this->actor); + + phi_f2 = this->actor.speedXZ * 0.02f; + phi_f2 = CLAMP_MAX(phi_f2, 0.12f); + + sp5C = Math_SinS(this->unk_240 * sp5A) * phi_f2; + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_InsertYRotation_f(sp5C, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->actor.world.rot.x, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(100.0f, &this->csCamAt); + + this->csCamEye = this->actor.world.pos; + + for (i = 0; i < bubblesToSpawnNum; i++) { + effectPos.x = randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.x; + effectPos.y = (randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.y) - 150.0f; + effectPos.z = randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.z; + + Boss03_SpawnEffectBubble(globalCtx, &effectPos); + } + } + + if (this->csCamId != 0) { + Play_CameraSetAtEye(globalCtx, this->csCamId, &this->csCamAt, &this->csCamEye); + Play_CameraSetFov(globalCtx, this->csCamId, this->cameraFov); + } +} + +void Boss03_SetupDeathCutscene(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_DeathCutscene; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFloppingAnim, -10.0f); + this->floppingAnimLastFrame = Animation_GetLastFrame(&gGyorgFloppingAnim); + Audio_QueueSeqCmd(NA_BGM_STOP | 0x10000); + this->workTimer[WORK_TIMER_UNK0_C] = 0; + this->unk_242 = 0; + this->csState = 0; + this->actor.flags &= ~ACTOR_FLAG_1; +} + +void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx) { + s16 i; + Vec3f sp90; + Vec3f sp84; + Vec3f sp78; + f32 aux; + f32 aux2; + s32 pad; + f32 pad2; + f32 sp64; + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + Player* player; + f32 sp4C; + + aux2 = 0.0f; + player = GET_PLAYER(globalCtx); + sp64 = this->actor.scale.x * 5.0f; + + this->csTimer++; + + switch (this->csState) { + case 0: + if (ActorCutscene_GetCurrentIndex() == -1) { + Cutscene_Start(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 1); + this->csCamId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->csCamId, 7); + this->unk_2BE = Math_FAtan2F(this->actor.world.pos.z, this->actor.world.pos.x); + + // Player is above water && Player is standing on ground + if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { + player->actor.world.pos.x = 0.0f; + player->actor.world.pos.z = -200.0f; + } + + case 1: + this->csTimer = 0; + this->csState = 2; + this->csCamEye.x = camera->eye.x; + this->csCamEye.y = camera->eye.y; + this->csCamEye.z = camera->eye.z; + this->csCamAt.x = camera->at.x; + this->csCamAt.y = camera->at.y; + this->csCamAt.z = camera->at.z; + + aux = this->csCamEye.x - this->actor.world.pos.x; + this->unk_568 = Math_Acot2F(this->csCamEye.z - this->actor.world.pos.z, aux); + + this->unk_570 = 0.0f; + this->unk_56C = 0.0f; + + case 2: + sp90.x = 0.0f; + sp90.y = (50.0f * sp64) + 150.0f; + sp90.z = (400.0f * sp64) + 300.0f; + + this->csCamTargetAt.x = this->actor.world.pos.x; + this->csCamTargetAt.y = this->actor.world.pos.y; + this->csCamTargetAt.z = this->actor.world.pos.z; + + this->unk_568 += this->unk_56C; + Matrix_InsertYRotation_f(this->unk_568, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp90, &this->csCamTargetEye); + + this->csCamTargetEye.x += this->actor.world.pos.x; + this->csCamTargetEye.y += this->waterHeight; + this->csCamTargetEye.z += this->actor.world.pos.z; + + sp4C = 40.0f + aux2; + Math_ApproachF(&this->csCamEye.x, this->csCamTargetEye.x, 0.1f, sp4C); + Math_ApproachF(&this->csCamEye.y, this->csCamTargetEye.y, 0.1f, sp4C); + Math_ApproachF(&this->csCamEye.z, this->csCamTargetEye.z, 0.1f, sp4C); + sp4C = 70.0f + aux2; + Math_ApproachF(&this->csCamAt.x, this->csCamTargetAt.x, 0.1f, sp4C); + Math_ApproachF(&this->csCamAt.y, this->csCamTargetAt.y, 0.1f, sp4C); + Math_ApproachF(&this->csCamAt.z, this->csCamTargetAt.z, 0.1f, sp4C); + } + break; + } + + SkelAnime_Update(&this->skelAnime); + + switch (this->unk_242) { + case 0: + Math_ApproachF(&this->actor.world.pos.y, Math_SinS(this->unk_240 * 0x1000) * 80.0f + this->waterHeight, + 1.0f, 10.0f); + this->actor.shape.rot.z += 0x100; + Matrix_RotateY(this->unk_2BE, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(500.0f, &sp84); + Math_ApproachF(&this->actor.world.pos.x, sp84.x, 0.1f, 5.0f); + Math_ApproachF(&this->actor.world.pos.z, sp84.z, 0.1f, 5.0f); + + if (Animation_OnFrame(&this->skelAnime, this->floppingAnimLastFrame)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_DEAD_JUMP2_OLD); + } + if (Animation_OnFrame(&this->skelAnime, this->floppingAnimLastFrame * 0.5f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_DEAD_JUMP_OLD); + } + + if ((this->workTimer[WORK_TIMER_UNK0_C] == 0) && ((this->waterHeight - 100.0f) < this->actor.world.pos.y)) { + this->workTimer[WORK_TIMER_UNK0_C] = Rand_ZeroFloat(15.0f) + 15.0f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, + this->waterHeight, this->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_777); + + if (this->actionFunc == Boss03_DeathCutscene) { + if ((D_809E9840 % 2) != 0) { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_JUMP_OLD); + } else { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_SINK_OLD); + } + D_809E9840++; + } + + this->unk_284 = this->actor.world.pos.x; + this->unk_288 = this->waterHeight; + this->unk_28C = this->actor.world.pos.z; + + this->unk_280 = 27; + if ((fabsf(this->actor.world.pos.x - sp84.x) < 5.0f) && + (fabsf(this->actor.world.pos.z - sp84.z) < 5.0f)) { + this->unk_242 = 1; + this->actor.gravity = -2.0f; + this->actor.velocity.y = 25.0f; + this->actor.speedXZ = 10.0f; + this->actor.world.rot.y = this->unk_2BE + 0x8000; + this->unk_240 = 0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_DEAD_JUMP2_OLD); + } + } + Math_ApproachF(&this->unk_56C, 0.01f, 1.0f, 0.0005f); + break; + + case 1: + if (this->unk_240 == 0x96) { + Audio_QueueSeqCmd(NA_BGM_CLEAR_BOSS | 0x8000); + } + Math_ApproachF(&this->unk_56C, 0.01f, 1.0f, 0.0005f); + Math_ApproachF(&this->actor.scale.x, 0.01f, 0.05f, 0.001f); + Actor_SetScale(&this->actor, this->actor.scale.x); + + if (this->actor.velocity.y < 0.0f) { + if (this->actor.world.pos.y < PLATFORM_HEIGHT + (100.0f * sp64)) { + this->actor.world.pos.y = PLATFORM_HEIGHT + (100.0f * sp64); + this->actor.velocity.y = ((Rand_ZeroFloat(10.0f) + 7.5f) * sp64) + 7.5f; + this->actor.speedXZ = ((Rand_ZeroFloat(5.0f) + 2.5f) * sp64) + 2.5f; + + if (Rand_ZeroOne() < 0.5f) { + this->shapeRotTargetX = + ((s16)randPlusMinusPoint5Scaled(500.0f) + this->shapeRotTargetX) + 0x8000; + } + + if (Rand_ZeroOne() < 0.5f) { + this->shapeRotTargetZ = + ((s16)randPlusMinusPoint5Scaled(500.0f) + this->shapeRotTargetZ) + 0x8000; + } + + if (Rand_ZeroOne() < 0.5f) { + this->shapeRotTargetY = Rand_ZeroFloat(65536.0f); + } + + this->actor.world.rot.y = Math_FAtan2F(-this->actor.world.pos.z, -this->actor.world.pos.x); + + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_BOUND_OLD); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_BOUND2_OLD); + } + } + + Math_ApproachS(&this->actor.shape.rot.y, this->shapeRotTargetY, 3, 0x500); + Math_ApproachS(&this->actor.shape.rot.x, this->shapeRotTargetX, 3, 0xA00); + Math_ApproachS(&this->actor.shape.rot.z, this->shapeRotTargetZ, 3, 0xA00); + + sp4C = 150.0f * sp64; + + for (i = 0; i < 1; i++) { + sp78.x = randPlusMinusPoint5Scaled(sp4C) + this->actor.world.pos.x; + sp78.y = this->actor.world.pos.y; + sp78.z = randPlusMinusPoint5Scaled(sp4C) + this->actor.world.pos.z; + Boss03_SpawnEffectDroplet(globalCtx, &sp78); + } + + Actor_MoveWithGravity(&this->actor); + if (this->actor.scale.x <= 0.0111f) { + this->unk_242 = 2; + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, + PLATFORM_HEIGHT, 200.0f, 0, 0, 0, ENDOORWARP1_FF_1); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, this->actor.focus.pos.x, + PLATFORM_HEIGHT, this->actor.focus.pos.z, 0, 0, 0, 0); + this->csTimer = 0; + Actor_SetScale(&this->actor, 0.0f); + Audio_StopSfxByPos(&this->actor.projectedPos); + } + break; + + case 2: + Math_ApproachZeroF(&this->unk_56C, 1.0f, 0.0005f); + if (this->csTimer == 60) { + camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + camera->eye = this->csCamEye; + camera->eyeNext = this->csCamEye; + camera->at = this->csCamAt; + func_80169AFC(globalCtx, this->csCamId, 0); + this->csCamId = 0; + Cutscene_End(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); + this->csState = 3; + func_80165690(); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_INIT_OLD); + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_INIT_OLD); + } + break; + + case 3: + this->actor.world.pos.y = 5000.0f; + break; + } + + if (this->csCamId != 0) { + Play_CameraSetAtEye(globalCtx, this->csCamId, &this->csCamAt, &this->csCamEye); + } +} + +void Boss03_SetupSpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_SpawnSmallFishesCutscene; + Animation_MorphToLoop(&this->skelAnime, &gGyorgBackingUpAnim, -15.0f); + this->csState = 0; + this->csTimer = 0; +} + +void Boss03_SpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&this->skelAnime); + this->csTimer++; + switch (this->csState) { + case 0: + if (ActorCutscene_GetCurrentIndex() == -1) { + Cutscene_Start(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 1); + this->csCamId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->csCamId, 7); + this->csState = 1; + this->unk_2BE = 0xBB8; + + case 1: + if (player->actor.world.pos.y < 437.0f) { + player->actor.world.pos.z = 500.0f; + player->actor.world.pos.x = 500.0f; + } + + this->actor.shape.rot.z = 0; + this->actor.world.pos.z = 1000.0f; + this->actor.world.pos.x = 1000.0f; + this->actor.world.pos.y = 200.0f; + this->actor.shape.rot.x = this->actor.shape.rot.z; + + this->actor.shape.rot.y = this->actor.world.rot.y = + Math_FAtan2F(-this->actor.world.pos.x, -this->actor.world.pos.x); + this->unk_260 = 0.0f; + + player->actor.shape.rot.y = player->actor.world.rot.y = this->actor.world.rot.y + 0x8000; + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y + this->unk_2BE, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(340.0f, &this->csCamEye); + + this->csCamAt.x = this->actor.world.pos.x; + this->csCamAt.y = this->actor.world.pos.y; + this->csCamAt.z = this->actor.world.pos.z; + + Math_ApproachS(&this->unk_2BE, -4000, 10, 70); + + if (this->csTimer >= 61) { + Math_ApproachS(&this->jawZRot, 0x3200, 5, 0x500); + if ((this->csTimer >= 90) && (this->csTimer < 130)) { + if ((this->csTimer % 2) != 0) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TANRON3, + this->actor.world.pos.x - 110.0f, this->actor.world.pos.y - 20.0f, + this->actor.world.pos.z - 110.0f, 0, this->actor.shape.rot.y, 0, 0); + this->numSpawnedSmallFish++; + } + if ((this->csTimer % 8) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_MINI_APPEAR); + } + } + } + + if (this->csTimer >= 150) { + Camera* camera; + + camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + camera->eye = this->csCamEye; + camera->eyeNext = this->csCamEye; + camera->at = this->csCamAt; + + func_80169AFC(globalCtx, this->csCamId, 0); + this->csCamId = 0; + Cutscene_End(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 50; + } + } + break; + } + + if (this->csCamId != 0) { + Play_CameraSetAtEye(globalCtx, this->csCamId, &this->csCamAt, &this->csCamEye); + } +} + +/* End of Gyorg's Cutscenes section */ + +/* Start of Gyorg's More actionFuncs and Update section */ + +void Boss03_SetupStunned(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->actionFunc != Boss03_Stunned) { + Animation_MorphToLoop(&this->skelAnime, &gGyorgStunnedAnim, -15.0f); + this->workTimer[WORK_TIMER_STUNNED] = 200; + this->actionFunc = Boss03_Stunned; + } + + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + func_80165690(); + } + + this->unk_240 = 0; +} + +void Boss03_Stunned(Boss03* this, GlobalContext* globalCtx) { + this->actor.hintId = 0x29; + + if (this->unk_240 >= 16) { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_COMMON_WEAKENED - SFX_FLAG); + } + + SkelAnime_Update(&this->skelAnime); + + if ((this->waterHeight + 30.0f) < this->actor.world.pos.y) { + this->actor.gravity = -2.0f; + Actor_MoveWithGravity(&this->actor); + if (this->actor.bgCheckFlags & 2) { + play_sound(NA_SE_IT_WALL_HIT_HARD); + func_800BC848(&this->actor, globalCtx, 10, 10); + } + } else { + Math_ApproachS(&this->actor.shape.rot.z, -0x6000, 0xA, 0x900); + Math_ApproachS(&this->actor.world.rot.x, 0x800, 0xA, 0x1000); + this->actor.shape.rot.x = this->actor.world.rot.x; + + Math_ApproachF(&this->actor.world.pos.y, 100.0f, 0.05f, 5.0f); + Math_ApproachF(&this->actor.speedXZ, 0.0f, 1.0f, 1.5f); + Actor_MoveWithoutGravityReverse(&this->actor); + } + + if (this->workTimer[WORK_TIMER_STUNNED] == 0) { + func_809E344C(this, globalCtx); + // WORK_TIMER_UNK1_A wasn't set + } +} + +void Boss03_SetupDamaged(Boss03* this, GlobalContext* globalCtx) { + Animation_MorphToLoop(&this->skelAnime, &gGyorgFloppingAnim, -10.0f); + this->actionFunc = Boss03_Damaged; + this->workTimer[WORK_TIMER_CURRENT_ACTION] = 30; +} + +/** + * Invulnerability period by being damaged by Player + */ +void Boss03_Damaged(Boss03* this, GlobalContext* globalCtx) { + this->unk_25C = 15; + + SkelAnime_Update(&this->skelAnime); + + Math_ApproachS(&this->jawZRot, ((Math_SinS(this->unk_240 * 0x2000) * 3000.0f) + 0x3000), 2, 0x3000); + Math_ApproachF(&this->actor.world.pos.y, 200.0f, 0.05f, 10.0f); + + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0) { + if ((s8)this->actor.colChkInfo.health <= 5) { + if (!this->hasSpwanedSmallFishes) { + this->hasSpwanedSmallFishes++; + Boss03_SetupSpawnSmallFishesCutscene(this, globalCtx); + return; + } + } + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 100; + } +} + +/* End of ActionFuncs section */ + +void Boss03_UpdateCollision(Boss03* this, GlobalContext* globalCtx) { + ColliderInfo* hitbox; + u8 sp4B = true; + Player* player = GET_PLAYER(globalCtx); + s32 i; + s32 phi_v1; + u32 phi_v0; + Boss03ActionFunc stunnedActionFunc = Boss03_Stunned; + + if (((KREG(20) + (this->waterHeight - 50.0f)) < player->actor.world.pos.y) && + (player->transformation != PLAYER_FORM_FIERCE_DEITY)) { + sp4B = false; + } + + if (this->waterHeight < player->actor.world.pos.y) { + for (i = 0; i < ARRAY_COUNT(sHeadJntSphElementsInit); i++) { + if (this->headCollider.elements[i].info.toucherFlags & TOUCH_HIT) { + this->headCollider.elements[i].info.toucherFlags &= ~TOUCH_HIT; + player->unk_B84 = this->actor.shape.rot.y; + player->unk_B80 = 20.0f; + } + } + + for (i = 0; i < ARRAY_COUNT(sBodyJntSphElementsInit); i++) { + if (this->bodyCollider.elements[i].info.toucherFlags & TOUCH_HIT) { + this->bodyCollider.elements[i].info.toucherFlags &= ~TOUCH_HIT; + player->unk_B84 = this->actor.shape.rot.y; + player->unk_B80 = 20.0f; + } + } + } + + if (this->unk_25C == 0) { + if ((this->actionFunc == stunnedActionFunc) && sp4B) { + for (i = 0; i < ARRAY_COUNT(sBodyJntSphElementsInit); i++) { + if (this->bodyCollider.elements[i].info.bumperFlags & BUMP_HIT) { + hitbox = this->bodyCollider.elements[i].info.acHitInfo; + this->bodyCollider.elements[i].info.bumperFlags &= ~BUMP_HIT; + this->unk_25C = 15; + this->unk_25E = 15; + + // (DMG_SWORD_BEAM | DMG_SPIN_ATTACK | DMG_ZORA_PUNCH | DMG_ZORA_BARRIER | DMG_DEKU_LAUNCH | + // DMG_DEKU_SPIN | DMG_GORON_SPIKES | DMG_SWORD | DMG_GORON_PUNCH | DMG_DEKU_STICK) + phi_v0 = (hitbox->toucher.dmgFlags & 0x038AC302) + ? this->bodyCollider.elements[i].info.acHitInfo->toucher.damage + : 0; + + phi_v1 = phi_v0; + if (phi_v0 < 1) { + phi_v1 = 1; + } + this->actor.colChkInfo.health -= phi_v1; + + if ((s8)this->actor.colChkInfo.health <= 0) { + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_DEAD_OLD); + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_DEAD2_OLD); + Boss03_SetupDeathCutscene(this, globalCtx); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } else { + Boss03_SetupDamaged(this, globalCtx); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_DAMAGE_OLD); + } + return; + } + } + } + + for (i = 0; i < ARRAY_COUNT(sHeadJntSphElementsInit); i++) { + if (this->headCollider.elements[i].info.bumperFlags & BUMP_HIT) { + hitbox = this->headCollider.elements[i].info.acHitInfo; + this->headCollider.elements[i].info.bumperFlags &= ~BUMP_HIT; + this->unk_25C = 15; + + if (this->actionFunc != stunnedActionFunc) { + Boss03_SetupStunned(this, globalCtx); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_DAMAGE_OLD); + + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + func_80165690(); + } + + continue; + } + + if (sp4B) { + this->unk_25E = 15; + + // (DMG_SWORD_BEAM | DMG_SPIN_ATTACK | DMG_ZORA_PUNCH | DMG_ZORA_BARRIER | DMG_DEKU_LAUNCH | + // DMG_DEKU_SPIN | DMG_GORON_SPIKES | DMG_SWORD | DMG_GORON_PUNCH | DMG_DEKU_STICK) + phi_v0 = (hitbox->toucher.dmgFlags & 0x038AC302) + ? (this->headCollider.elements[i].info.acHitInfo->toucher.damage) + : 0; + + phi_v1 = phi_v0; + if (phi_v0 < 1) { + phi_v1 = 1; + } + this->actor.colChkInfo.health -= phi_v1; + if ((s8)this->actor.colChkInfo.health <= 0) { + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_DEAD_OLD); + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_DEAD2_OLD); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Boss03_SetupDeathCutscene(this, globalCtx); + } else { + Boss03_SetupDamaged(this, globalCtx); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_DAMAGE_OLD); + } + } + return; + } + } + } +} + +void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + Boss03* this = THIS; + Actor* dblueActor; + Player* player = GET_PLAYER(globalCtx); + s32 i; + Vec3f wetSpotPos; + Vec3f bubblePos; + Vec3f dropletPos; + s16 j; + f32 yRot; + + this->actor.hintId = 0x28; + + if (!D_809E9842 && (player->actor.world.pos.y < (PLATFORM_HEIGHT + 5.0f))) { + D_809E9842 = true; + D_809E9841 = 5; + } + + if (KREG(63) == 0) { + this->unk_290 = 1; + this->unk_240++; + this->unk_2BC = 1; + + this->unk_2BD = false; + + Math_Vec3f_Copy(&D_809E9848, &this->actor.projectedPos); + + for (i = 0; i < ARRAY_COUNT(this->workTimer); i++) { + if (this->workTimer[i] != 0) { + this->workTimer[i]--; + } + } + + if (this->unk_324 != 0) { + this->unk_324--; + } + + if (this->unk_25C != 0) { + this->unk_25C--; + } + + if (this->unk_25E != 0) { + this->unk_25E--; + } + + this->actionFunc(this, globalCtx); + + if (this->actionFunc != Boss03_DeathCutscene) { + Math_ApproachS(&this->actor.shape.rot.z, 0, 0xA, 0x800); + this->actor.world.pos.y -= 100.0f; + this->actor.prevPos.y -= 100.0f; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 150.0f, 100.0f, 5); + this->actor.world.pos.y += 100.0f; + this->actor.prevPos.y += 100.0f; + } + } + + if ((this->actionFunc != Boss03_DeathCutscene) && (!this->unk_2D5)) { + // Going into or out of the water + if (((this->actor.world.pos.y < this->waterHeight + 50.0f) && + (this->waterHeight + 50.0f <= this->actor.prevPos.y)) || + ((this->waterHeight - 50.0f < this->actor.world.pos.y) && + (this->actor.prevPos.y <= this->waterHeight - 50.0f))) { + if ((this->actor.velocity.y < 0.0f) && (this->actionFunc != Boss03_DeathCutscene)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_SINK_OLD); + } + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, + this->waterHeight, this->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_777); + + this->unk_280 = 27; + this->unk_284 = this->actor.world.pos.x; + this->unk_288 = this->waterHeight; + this->unk_28C = this->actor.world.pos.z; + } + } + + if (this->actionFunc != Boss03_DeathCutscene) { + if ((this->actionFunc == Boss03_Stunned) || (this->actionFunc == Boss03_Damaged)) { + this->bodyCollider.base.colType = COLTYPE_HIT3; + } else { + this->bodyCollider.base.colType = COLTYPE_METAL; + } + + Boss03_UpdateCollision(this, globalCtx); + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); + + if (player->transformation == PLAYER_FORM_HUMAN) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); + } + + if (!this->unk_2BD) { + if (player->transformation != PLAYER_FORM_HUMAN) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); + } + + if ((this->actionFunc != Boss03_Stunned) && (!this->unk_2BD)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); + } + } + + dblueActor = Boss03_FindActorDblueMovebg(globalCtx); + if (dblueActor != NULL) { + dblueActor->world.pos.y = this->waterHeight; + } + + Math_ApproachZeroF(&this->unk_260, 0.1f, 0.05f); + + if (this->unk_290 != 0) { + this->unk_294 += 0.1f; + this->unk_298 += 0.12f; + this->leftFinYRot = __sinf(this->unk_294) * 1280.0f; + this->rightFinYRot = __sinf(this->unk_298) * 1280.0f; + } else { + Math_ApproachS(&this->rightFinYRot, 0, 0xA, 0x100); + Math_ApproachS(&this->leftFinYRot, 0, 0xA, 0x100); + } + + Math_ApproachS(&this->bodyYRot, 0, 0xA, 0x100); + Math_ApproachS(&this->jawZRot, 0, 0xA, 0x200); + + if ((this->unk_240 % 2) == 0) { + for (i = 0; i < this->bubbleEffectSpawnCount; i++) { + bubblePos.x = randPlusMinusPoint5Scaled(100.0f) + this->actor.world.pos.x; + bubblePos.y = randPlusMinusPoint5Scaled(100.0f) + this->actor.world.pos.y; + bubblePos.z = randPlusMinusPoint5Scaled(100.0f) + this->actor.world.pos.z; + + Boss03_SpawnEffectBubble(globalCtx, &bubblePos); + } + } + + this->bubbleEffectSpawnCount = 1; + Boss03_UpdateEffects(globalCtx); + + if (D_809E9841 != 0) { + D_809E9841--; + if (D_809E9841 == 0) { + Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000); + } + } + + if (this->actionFunc != Boss03_CatchPlayer) { + Math_ApproachS(&player->actor.world.rot.x, 0, 1, 0x80); + Math_ApproachS(&player->actor.shape.rot.x, 0, 1, 0x80); + } + + if ((this->waterHeight < player->actor.world.pos.y) && (this->prevPlayerPos.y <= this->waterHeight)) { + this->wetSpotEffectSpawnCount = 20; + } + + // Player is standing on ground && Player is above water + if ((player->actor.bgCheckFlags & 1) && (player->actor.shape.feetPos[FOOT_LEFT].y >= WATER_HEIGHT + 8.0f)) { + if (this->wetSpotEffectSpawnCount != 0) { + this->wetSpotEffectSpawnCount--; + + wetSpotPos.x = randPlusMinusPoint5Scaled(50.0f) + player->actor.world.pos.x; + wetSpotPos.y = PLATFORM_HEIGHT; + wetSpotPos.z = randPlusMinusPoint5Scaled(50.0f) + player->actor.world.pos.z; + Boss03_SpawnEffectWetSpot(globalCtx, &wetSpotPos); + } + } + + this->prevPlayerPos = player->actor.world.pos; + + if (this->waterHeight < this->actor.world.pos.y) { + func_8019F540(0); + } else { + func_8019F540(1); + } + + if (this->unk_280 != 0) { + this->unk_280--; + } + + if ((this->unk_280 == 1) || (this->unk_280 == 5) || (this->unk_280 == 9)) { + yRot = 0.0f; + + for (j = 0, i = 0; i < 20; j++) { + Matrix_InsertYRotation_f(yRot, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(60.000004f) + 312.0f, &dropletPos); + dropletPos.x += this->unk_284 + randPlusMinusPoint5Scaled(40.0f); + dropletPos.y = PLATFORM_HEIGHT; + dropletPos.z += this->unk_28C + randPlusMinusPoint5Scaled(40.0f); + + if (sqrtf(SQ(dropletPos.x) + SQ(dropletPos.z)) < 355.0f) { + Boss03_SpawnEffectDroplet(globalCtx, &dropletPos); + i++; + } + + yRot += ((2.0f * M_PI) / 50.0f); + if (j >= 50) { + break; + } + } + } +} + +/* End of Gyorg's More actionFuncs and Update section */ + +/* Start of Gyorg's Draw section */ + +void Boss03_SetObject(GlobalContext* globalCtx, s16 objectId) { + s32 objectIndex = Object_GetIndex(&globalCtx->objectCtx, objectId); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[objectIndex].segment); + + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[objectIndex].segment); + gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[objectIndex].segment); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +s32 Boss03_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + Boss03* this = THIS; + + if ((limbIndex == GYORG_LIMB_UPPER_TRUNK) || (limbIndex == GYORG_LIMB_LOWER_TRUNK) || + (limbIndex == GYORG_LIMB_TAIL)) { + rot->y += this->bodyYRot; + } + if (limbIndex == GYORG_LIMB_UPPER_RIGHT_FIN) { + rot->y += this->rightFinYRot; + } + if (limbIndex == GYORG_LIMB_LOWER_RIGHT_FIN) { + rot->y += (s16)(2 * this->rightFinYRot); + } + if (limbIndex == GYORG_LIMB_UPPER_LEFT_FIN) { + rot->y -= this->leftFinYRot; + } + if (limbIndex == GYORG_LIMB_LOWER_LEFT_FIN) { + rot->y -= (s16)(2 * this->leftFinYRot); + } + if (limbIndex == GYORG_LIMB_JAW) { + rot->z += this->jawZRot; + } + + return false; +} + +/** + * Used to manually index the spheres elements of the two colliders + * Since there are two sets of ColliderJntSph, indices < 2 (ARRAY_COUNT(sHeadJntSphElementsInit)) refers to the first + * collider and indices >= 2 refers to the second one + */ +s8 sGyorgSphElementIndices[] = { + -1, // GYORG_LIMB_NONE, + -1, // GYORG_LIMB_ROOT, + 0, // GYORG_LIMB_HEAD, + -1, // GYORG_LIMB_BODY_ROOT, + 4, // GYORG_LIMB_UPPER_TRUNK, + 5, // GYORG_LIMB_LOWER_TRUNK, + 6, // GYORG_LIMB_TAIL, + -1, // GYORG_LIMB_RIGHT_FIN_ROOT, + 2, // GYORG_LIMB_UPPER_RIGHT_FIN, + -1, // GYORG_LIMB_LOWER_RIGHT_FIN, + -1, // GYORG_LIMB_LEFT_FIN_ROOT, + 3, // GYORG_LIMB_UPPER_LEFT_FIN, + -1, // GYORG_LIMB_LOWER_LEFT_FIN, + -1, // GYORG_LIMB_JAW_ROOT, + 1, // GYORG_LIMB_JAW, + -1, // GYORG_LIMB_MAX + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; + +Vec3f D_809E9148 = { 600.0f, -100.0f, 0.0f }; +Vec3f D_809E9154[] = { + { 450.0f, 0.0f, 0.0f }, { 140.0f, -60.0f, 0.0f }, { 350.0f, 0.0f, 0.0f }, { 350.0f, 0.0f, 0.0f }, + { 100.0f, 0.0f, 0.0f }, { 150.0f, 0.0f, 0.0f }, { 500.0f, 0.0f, 0.0f }, +}; +Vec3f D_809E91A8 = { 100000.0f, 100000.0f, 100000.0f }; +Vec3f D_809E91B4 = { 300.0f, -100.0f, -200.0f }; + +void Boss03_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + Boss03* this = THIS; + s32 pad; + s8 sphereElementIndex; + Vec3f spherePos; + Player* player = GET_PLAYER(globalCtx); + + if (limbIndex == GYORG_LIMB_HEAD) { + Matrix_MultiplyVector3fByState(&D_809E9148, &this->actor.focus.pos); + } + + sphereElementIndex = sGyorgSphElementIndices[limbIndex]; + if (sphereElementIndex >= 0) { + Matrix_MultiplyVector3fByState(&D_809E9154[sphereElementIndex], &spherePos); + + if (sphereElementIndex < 2) { + if ((this->actionFunc == Boss03_Stunned) && (this->waterHeight < player->actor.world.pos.y)) { + Boss03_UpdateSphereElement(sphereElementIndex, &this->headCollider, &D_809E91A8); + } else { + Boss03_UpdateSphereElement(sphereElementIndex, &this->headCollider, &spherePos); + } + } else { + Boss03_UpdateSphereElement(sphereElementIndex - 2, &this->bodyCollider, &spherePos); + } + } + + if (limbIndex == GYORG_LIMB_JAW) { + MtxF mf; + + D_809E91B4.x = this->unk_2C4 + 300.0f; + Matrix_MultiplyVector3fByState(&D_809E91B4, &this->insideJawPos); + Matrix_CopyCurrentState(&mf); + func_8018219C(&mf, &this->unk_2A2, 0); + } +} + +void Boss03_Draw(Actor* thisx, GlobalContext* globalCtx) { + Boss03* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (!this->unk_2D5) { + if ((this->unk_25E % 2) != 0) { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 900, 1099); + } + + Matrix_InsertYRotation_f(this->unk_260, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -600.0f, 0.0f, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, Boss03_OverrideLimbDraw, Boss03_PostLimbDraw, &this->actor); + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + } + + this->unk_2BC = 0; + + Boss03_DrawEffects(globalCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +/* End of Gyorg's Draw section */ + +/* Start of Effect Update/Draw section */ + +void Boss03_UpdateEffects(GlobalContext* globalCtx) { + GyorgEffect* eff = globalCtx->specialEffects; + s16 i; + Vec3f sp94; + Vec3f velocity; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++, eff++) { + f32 phi_f0; + + if (eff->type == GYORG_EFFECT_NONE) { + continue; + } + + eff->unk_02++; + + eff->pos.x += eff->velocity.x; + eff->pos.y += eff->velocity.y; + eff->pos.z += eff->velocity.z; + + eff->velocity.y += eff->accel.y; + + if ((eff->unk_02 & 6) != 0) { + phi_f0 = 80.0f; + } else { + phi_f0 = 200.0f; + } + + Math_ApproachF(&eff->unk_40, phi_f0, 1.0f, 80.0f); + + if (eff->type == GYORG_EFFECT_DROPLET) { + eff->unk_34.z += 0.15f; + + Math_ApproachF(&eff->unk_34.x, 0.03f, 0.5f, 0.005f); + Math_ApproachF(&eff->unk_34.y, 0.5f, 0.5f, 0.02f); + + if (eff->pos.y <= WATER_HEIGHT) { + eff->type = GYORG_EFFECT_NONE; + eff->pos.y = WATER_HEIGHT; + EffectSsGRipple_Spawn(globalCtx, &eff->pos, 0, 80, 0); + } else if (eff->pos.y <= PLATFORM_HEIGHT) { + s16 j; + + eff->type = GYORG_EFFECT_WET_SPOT; + eff->pos.y = PLATFORM_HEIGHT; + eff->unk_34.x = 0.1f; + eff->unk_34.y = 0.6f; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->alpha = 150; + eff->alphaDelta = Rand_ZeroFloat(4.0f) + 5.0f; + + for (j = 0; j < 4; j++) { + Matrix_InsertYRotation_f((2.0f * (j * M_PI)) / 6.0f, 0); + sp94.x = 0.0f; + sp94.y = Rand_ZeroFloat(4.0f) + 2.0f; + sp94.z = Rand_ZeroFloat(1.5f) + 1.5f; + Matrix_MultiplyVector3fByState(&sp94, &velocity); + Boss03_SpawnEffectSplash(globalCtx, &eff->pos, &velocity); + } + } + } else if (eff->type == GYORG_EFFECT_SPLASH) { + eff->unk_34.z += 0.15f; + + if (eff->velocity.y < -8.0f) { + eff->velocity.y = -8.0f; + } + + if ((eff->velocity.y < 0.0f) && (eff->pos.y <= PLATFORM_HEIGHT)) { + eff->type = GYORG_EFFECT_WET_SPOT; + eff->pos.y = PLATFORM_HEIGHT; + eff->unk_34.x = 0.05f; + eff->unk_34.y = 0.2f; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->alpha = 150; + eff->alphaDelta = Rand_ZeroFloat(4.0f) + 5.0f; + } + } else if (eff->type == GYORG_EFFECT_WET_SPOT) { + Math_ApproachF(&eff->unk_34.x, eff->unk_34.y, 0.1f, 0.6f); + + eff->alpha -= eff->alphaDelta; + if (eff->alpha <= 0) { + eff->alpha = 0; + eff->type = GYORG_EFFECT_NONE; + } + } else if (eff->type == GYORG_EFFECT_BUBBLE) { + if (eff->velocity.y > 5.0f) { + eff->velocity.y = 5.0f; + } + if (sGyorgBossInstance->waterHeight < eff->pos.y) { + eff->type = GYORG_EFFECT_NONE; + } + } + } +} + +void Boss03_DrawEffects(GlobalContext* globalCtx) { + u8 flag = false; + s16 i; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s32 pad; + GyorgEffect* eff = globalCtx->specialEffects; + GyorgEffect* effFirst = eff; + + OPEN_DISPS(gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(gfxCtx); + + for (i = 0; i < GYORG_EFFECT_COUNT; i++, eff++) { + if (eff->type == GYORG_EFFECT_BUBBLE) { + if (!flag) { + gSPDisplayList(POLY_OPA_DISP++, gGyorgBubbleMaterialDL); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 150, 150, 150, 0); + + flag = true; + } + + Matrix_InsertTranslation(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + Matrix_Scale(eff->unk_34.x, eff->unk_34.x, 1.0f, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gGyorgBubbleModelDL); + } + } + + eff = effFirst; + + Boss03_SetObject(globalCtx, OBJECT_WATER_EFFECT); + + flag = false; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++, eff++) { + if ((eff->type == GYORG_EFFECT_DROPLET) || (eff->type == GYORG_EFFECT_SPLASH)) { + + if (!flag) { + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust1Tex)); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); + + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)eff->unk_40, (u8)((((void)0, eff->unk_40) + 55.0f)), 225, 150); + + Matrix_InsertTranslation(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + + if (eff->type == GYORG_EFFECT_DROPLET) { + Matrix_InsertYRotation_f(Camera_GetInputDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) * + (M_PI / 0x8000), + MTXMODE_APPLY); + } else { // GYORG_EFFECT_SPLASH + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + } + + Matrix_Scale(eff->unk_34.x, eff->unk_34.y, 1.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_f(eff->unk_34.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042B0); + } + } + + eff = effFirst; + + flag = false; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++, eff++) { + if (eff->type == GYORG_EFFECT_WET_SPOT) { + if (!flag) { + func_8012C448(gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust1Tex)); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); + + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s16)eff->unk_40, ((void)0, ((s16)eff->unk_40) + 55), 225, + eff->alpha); + + Matrix_InsertTranslation(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + + Matrix_Scale(eff->unk_34.x, 1.0f, eff->unk_34.x, MTXMODE_APPLY); + Matrix_InsertYRotation_f(eff->unk_34.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042F8); + } + } + + Boss03_SetObject(globalCtx, OBJECT_BOSS03); + + CLOSE_DISPS(gfxCtx); +} + +/* End of Effect Update/Draw section */ + +/* Start of Seaweed section */ + +#define SEAWEED_FLAG_INTERACT_NONE 0 +#define SEAWEED_FLAG_INTERACT_PLAYER 1 +#define SEAWEED_FLAG_INTERACT_GYORG 2 + +void Boss03_SeaweedUpdate(Actor* thisx, GlobalContext* globalCtx) { + Boss03* this = THIS; + s16 i; + s16 pad; + s16 maxBendSpeed; + u8 flag; + Player* player = GET_PLAYER(globalCtx); + f32 distanceBetweenSeaweedAndDisturbance; + f32 disturbanceFactor; + f32 xDiff; + f32 yDiff; + f32 zDiff; + + flag = SEAWEED_FLAG_INTERACT_NONE; + this->unk_240++; + + for (i = 0; i < ARRAY_COUNT(this->seaweedSegmentPositions); i++) { + xDiff = player->actor.world.pos.x - this->seaweedSegmentPositions[i].x; + yDiff = player->actor.world.pos.y - this->seaweedSegmentPositions[i].y; + zDiff = player->actor.world.pos.z - this->seaweedSegmentPositions[i].z; + distanceBetweenSeaweedAndDisturbance = sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)); + disturbanceFactor = player->actor.speedXZ * 3.0f + 70.0f; + + // Player is standing on ground + if (player->actor.bgCheckFlags & 1) { + maxBendSpeed = 0; + } else { + maxBendSpeed = player->actor.speedXZ * 16.0f; + if (maxBendSpeed > 0x1000) { + maxBendSpeed = 0x1000; + } else if (maxBendSpeed < 0x100) { + maxBendSpeed = 0x100; + } + } + + if (distanceBetweenSeaweedAndDisturbance < disturbanceFactor) { + Math_ApproachS(&this->morphTable[i].x, (disturbanceFactor - distanceBetweenSeaweedAndDisturbance) * 200.0f, + 0xA, maxBendSpeed); + if (maxBendSpeed != 0) { + flag |= SEAWEED_FLAG_INTERACT_PLAYER; + } + } + } + + if (flag & SEAWEED_FLAG_INTERACT_PLAYER) { + Math_ApproachS(&this->actor.shape.rot.y, Math_FAtan2F(zDiff, xDiff), 0x14, 0x800); + } + + if (sGyorgBossInstance->actor.world.pos.y - 40.0f < sGyorgBossInstance->waterHeight) { + for (i = 0; i < 6; i++) { + xDiff = sGyorgBossInstance->actor.world.pos.x - this->seaweedSegmentPositions[i].x; + yDiff = sGyorgBossInstance->actor.world.pos.y - this->seaweedSegmentPositions[i].y; + zDiff = sGyorgBossInstance->actor.world.pos.z - this->seaweedSegmentPositions[i].z; + + distanceBetweenSeaweedAndDisturbance = sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)); + + if ((i == 0) && (distanceBetweenSeaweedAndDisturbance > 400.0f)) { + break; + } + + maxBendSpeed = sGyorgBossInstance->actor.speedXZ * 16.0f; + disturbanceFactor = sGyorgBossInstance->actor.speedXZ * 5.0f + 150.0f; + if (maxBendSpeed > 0x1000) { + maxBendSpeed = 0x1000; + } else if (maxBendSpeed < 0x100) { + maxBendSpeed = 0x0100; + } + + if (distanceBetweenSeaweedAndDisturbance < disturbanceFactor) { + Math_ApproachS(&this->morphTable[i].x, + (disturbanceFactor - distanceBetweenSeaweedAndDisturbance) * 200.0f, 0xA, maxBendSpeed); + if (maxBendSpeed != 0) { + flag |= SEAWEED_FLAG_INTERACT_GYORG; + } + } + } + + if (flag & SEAWEED_FLAG_INTERACT_GYORG) { + Math_ApproachS(&this->actor.shape.rot.y, Math_FAtan2F(zDiff, xDiff), 0x14, 0x800); + } + } + + if (flag == SEAWEED_FLAG_INTERACT_NONE) { + for (i = 0; i < 6; i++) { + Math_ApproachS(&this->morphTable[i].x, 0, 0x14, 0x80); + } + } +} + +Gfx* sGyorgSeaweedDLs[] = { + gGyorgSeaweedTopDL, gGyorgSeaweedPiece5DL, gGyorgSeaweedPiece4DL, + gGyorgSeaweedPiece3DL, gGyorgSeaweedPiece2DL, gGyorgSeaweedPiece1DL, +}; + +void Boss03_SeaweedDraw(Actor* thisx, GlobalContext* globalCtx) { + Boss03* this = THIS; + s16 i; + // Why 10 Mtxs? This seems to only use the first 6 elements + Mtx* mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Mtx) * 10); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(0x4000, MTXMODE_APPLY); + // The indices looks a bit random... + Matrix_RotateY(this->jointTable[5].x * -5.0f * 0.1f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->jointTable[3].y * -5.0f * 0.1f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->jointTable[2].z * 6.0f * 0.1f, MTXMODE_APPLY); + + for (i = 0; i < ARRAY_COUNT(sGyorgSeaweedDLs); i++, mtx++) { + Matrix_RotateY(this->jointTable[i].x + this->morphTable[i].x, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->jointTable[i].y + this->morphTable[i].y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->jointTable[i].z + this->morphTable[i].z, MTXMODE_APPLY); + + Matrix_ToMtx(mtx); + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, sGyorgSeaweedDLs[i]); + + Matrix_GetStateTranslation(&this->seaweedSegmentPositions[i]); + Matrix_InsertTranslation(4000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +/* End of Seaweed section */ diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.h b/src/overlays/actors/ovl_Boss_03/z_boss_03.h index ca8a92328..f5af516c0 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.h +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.h @@ -2,22 +2,109 @@ #define Z_BOSS_03_H #include "global.h" +#include "objects/object_boss03/object_boss03.h" struct Boss03; typedef void (*Boss03ActionFunc)(struct Boss03*, GlobalContext*); +#define GYORG_WORK_TIMER_MAX 3 + +typedef struct { + /* 0x00 */ u8 type; + /* 0x02 */ s16 unk_02; + /* 0x04 */ Vec3f pos; + /* 0x10 */ Vec3f velocity; + /* 0x1C */ Vec3f accel; + /* 0x28 */ UNK_TYPE1 unk_28[0x4]; + /* 0x2C */ s16 alpha; + /* 0x2E */ s16 alphaDelta; + /* 0x30 */ UNK_TYPE1 unk_30[0x4]; + /* 0x34 */ Vec3f unk_34; // it may not be a Vec3f + /* 0x40 */ f32 unk_40; // colorIntensity? +} GyorgEffect; // size = 0x44 + +#define GYORG_EFFECT_COUNT 150 + +typedef enum { + /* 0 */ GYORG_EFFECT_NONE, + /* 1 */ GYORG_EFFECT_BUBBLE, + /* 2 */ GYORG_EFFECT_DROPLET, + /* 3 */ GYORG_EFFECT_SPLASH, + /* 4 */ GYORG_EFFECT_WET_SPOT, +} GyorgEffectType; + typedef struct Boss03 { /* 0x0000 */ Actor actor; - /* 0x0144 */ UNK_TYPE1 unk_144[0x10E]; - /* 0x0252 */ s8 unk_252; // number of Tanron3 fish that are currently alive, maybe "numSmallFishAlive"? - /* 0x0253 */ UNK_TYPE1 unk_253[0xD1]; - /* 0x0324 */ s16 unk_324; - /* 0x0326 */ UNK_TYPE1 unk_326[0x2]; + /* 0x0144 */ UNK_TYPE1 unk_144[0x04]; + /* 0x0148 */ SkelAnime skelAnime; + /* 0x018C */ Vec3s jointTable[GYORG_LIMB_MAX]; + /* 0x01E6 */ Vec3s morphTable[GYORG_LIMB_MAX]; + /* 0x0240 */ s16 unk_240; // generic timer? used by Gyorg and seaweed + /* 0x0242 */ u8 unk_242; + /* 0x0243 */ UNK_TYPE1 unk_243[0x09]; + /* 0x024C */ s16 workTimer[GYORG_WORK_TIMER_MAX]; + /* 0x0252 */ s8 numSpawnedSmallFish; // number of Tanron3 fish that are currently alive, -1 indexed + /* 0x0253 */ u8 hasSpwanedSmallFishes; // Tanron + /* 0x0254 */ s16 bubbleEffectSpawnCount; // Amount of bubble effect which will be spawned by Update + /* 0x0258 */ f32 waterHeight; // always 430.0f + /* 0x025C */ s16 unk_25C; // Timer related to collision? + /* 0x025E */ s16 unk_25E; + /* 0x0260 */ f32 unk_260; // rotY + /* 0x0264 */ UNK_TYPE1 unk_264[0x04]; + /* 0x0268 */ Vec3f unk_268; // set to player.world.pos or random values + /* 0x0274 */ s16 unk_274; + /* 0x0276 */ s16 unk_276; + /* 0x0278 */ f32 unk_278; + /* 0x027C */ f32 unk_27C; + /* 0x0280 */ s16 unk_280; + /* 0x0284 */ f32 unk_284; // Maybe a Vec3f + /* 0x0288 */ f32 unk_288; // Set but not used + /* 0x028C */ f32 unk_28C; + /* 0x0290 */ u8 unk_290; + /* 0x0294 */ f32 unk_294; + /* 0x0298 */ f32 unk_298; + /* 0x029C */ s16 leftFinYRot; + /* 0x029E */ s16 rightFinYRot; + /* 0x02A0 */ s16 bodyYRot; + /* 0x02A2 */ Vec3s unk_2A2; + /* 0x02A8 */ s16 jawZRot; + /* 0x02AC */ Vec3f insideJawPos; // used to grab player + /* 0x02B8 */ f32 unk_2B8; + /* 0x02BC */ u8 unk_2BC; // set but not used + /* 0x02BD */ u8 unk_2BD; // playerUnderwater? + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ UNK_TYPE1 unk_2C0[0x04]; + /* 0x02C0 */ f32 unk_2C4; + /* 0x02C8 */ Vec3f prevPlayerPos; + /* 0x02D4 */ u8 wetSpotEffectSpawnCount; + /* 0x02D5 */ u8 unk_2D5; // flag + /* 0x02D6 */ s16 shapeRotTargetX; + /* 0x02D8 */ s16 shapeRotTargetY; + /* 0x02DA */ s16 shapeRotTargetZ; + /* 0x02DC */ Vec3f seaweedSegmentPositions[6]; + /* 0x0324 */ s16 unk_324; // timer? set by Tanron3 /* 0x0328 */ Boss03ActionFunc actionFunc; - /* 0x032C */ UNK_TYPE1 unk_32C[0x250]; + /* 0x032C */ ColliderJntSph headCollider; + /* 0x034C */ ColliderJntSphElement headColliderElements[2]; + /* 0x03CC */ ColliderJntSph bodyCollider; + /* 0x03EC */ ColliderJntSphElement bodyColliderElements[5]; + /* 0x052C */ f32 floppingAnimLastFrame; + /* 0x0530 */ u32 csTimer; + /* 0x0534 */ s16 csState; + /* 0x0536 */ s16 csCamId; + /* 0x0538 */ Vec3f csCamEye; + /* 0x0544 */ Vec3f csCamAt; + /* 0x0550 */ Vec3f csCamTargetEye; + /* 0x055C */ Vec3f csCamTargetAt; + /* 0x0568 */ f32 unk_568; + /* 0x056C */ f32 unk_56C; + /* 0x0570 */ f32 unk_570; // set but not used + /* 0x0574 */ UNK_TYPE1 unk_574[0x04]; + /* 0x0578 */ f32 cameraFov; } Boss03; // size = 0x57C - -extern const ActorInit Boss_03_InitVars; + +#define GYORG_PARAM_DEFAULT (0) +#define GYORG_PARAM_SEAWEED (0x23) #endif // Z_BOSS_03_H diff --git a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c index f845d9fa2..15d307326 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c @@ -86,12 +86,12 @@ static ColliderCylinderInit sUnusedCylinderInit = { }; void EnTanron3_CreateEffect(GlobalContext* globalCtx, Vec3f* effectPos) { - UnkTanron3Effect* effectPtr = (UnkTanron3Effect*)globalCtx->specialEffects; + GyorgEffect* effectPtr = globalCtx->specialEffects; s16 i; - for (i = 0; i < 150; i++, effectPtr++) { - if ((effectPtr->type == 0) || (effectPtr->type == 1)) { - effectPtr->type = 2; + for (i = 0; i < GYORG_EFFECT_COUNT; i++, effectPtr++) { + if ((effectPtr->type == GYORG_EFFECT_NONE) || (effectPtr->type == GYORG_EFFECT_BUBBLE)) { + effectPtr->type = GYORG_EFFECT_DROPLET; effectPtr->pos = *effectPos; effectPtr->velocity = *sZeroVec; effectPtr->accel = *sZeroVec; @@ -124,7 +124,7 @@ void EnTanron3_Init(Actor* thisx, GlobalContext* globalCtx) { } void EnTanron3_Destroy(Actor* thisx, GlobalContext* globalCtx) { - sGyorg->unk_252--; + sGyorg->numSpawnedSmallFish--; } void EnTanron3_SpawnBubbles(EnTanron3* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.h b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.h index 9d67154df..5f984e2ef 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.h +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.h @@ -10,17 +10,6 @@ typedef void (*EnTanron3ActionFunc)(struct EnTanron3*, GlobalContext*); #define TANRON3_WORK_TIMER_MAX 3 -typedef struct { - /* 0x00 */ u8 type; - /* 0x02 */ s16 unk_02; - /* 0x04 */ Vec3f pos; - /* 0x10 */ Vec3f velocity; - /* 0x1C */ Vec3f accel; - /* 0x28 */ char unk_28[0xC]; - /* 0x34 */ Vec3f unk_34; - /* 0x40 */ char unk_40[0x4]; -} UnkTanron3Effect; - typedef struct EnTanron3 { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index c97446d78..5a7448701 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -9315,52 +9315,52 @@ 0x809DD2F8:("func_809DD2F8",), 0x809DD934:("func_809DD934",), 0x809DEAC4:("func_809DEAC4",), - 0x809E2760:("func_809E2760",), - 0x809E2788:("func_809E2788",), - 0x809E2880:("func_809E2880",), - 0x809E299C:("func_809E299C",), - 0x809E2AB4:("func_809E2AB4",), - 0x809E2B8C:("func_809E2B8C",), - 0x809E2C1C:("func_809E2C1C",), - 0x809E2C3C:("func_809E2C3C",), - 0x809E2D64:("func_809E2D64",), - 0x809E2DA0:("func_809E2DA0",), + 0x809E2760:("Boss03_PlayUnderwaterSfx",), + 0x809E2788:("Boss03_SpawnEffectWetSpot",), + 0x809E2880:("Boss03_SpawnEffectDroplet",), + 0x809E299C:("Boss03_SpawnEffectSplash",), + 0x809E2AB4:("Boss03_SpawnEffectBubble",), + 0x809E2B8C:("Boss03_UpdateSphereElement",), + 0x809E2C1C:("Boss03_SeedRand",), + 0x809E2C3C:("Boss03_RandZeroOne",), + 0x809E2D64:("Boss03_FindActorDblueMovebg",), + 0x809E2DA0:("Boss03_SpawnDust",), 0x809E2F7C:("Boss03_Init",), 0x809E343C:("Boss03_Destroy",), 0x809E344C:("func_809E344C",), 0x809E34B8:("func_809E34B8",), - 0x809E38EC:("func_809E38EC",), - 0x809E3968:("func_809E3968",), - 0x809E3D34:("func_809E3D34",), - 0x809E3D98:("func_809E3D98",), - 0x809E4180:("func_809E4180",), - 0x809E421C:("func_809E421C",), - 0x809E4674:("func_809E4674",), - 0x809E475C:("func_809E475C",), - 0x809E4910:("func_809E4910",), - 0x809E497C:("func_809E497C",), - 0x809E4C34:("func_809E4C34",), - 0x809E4C90:("func_809E4C90",), - 0x809E4E2C:("func_809E4E2C",), - 0x809E4E80:("func_809E4E80",), - 0x809E5ADC:("func_809E5ADC",), - 0x809E5B64:("func_809E5B64",), - 0x809E65F4:("func_809E65F4",), - 0x809E6640:("func_809E6640",), - 0x809E69A4:("func_809E69A4",), - 0x809E6A38:("func_809E6A38",), - 0x809E6B70:("func_809E6B70",), - 0x809E6BC0:("func_809E6BC0",), - 0x809E6CB4:("func_809E6CB4",), + 0x809E38EC:("Boss03_SetupChasePlayer",), + 0x809E3968:("Boss03_ChasePlayer",), + 0x809E3D34:("Boss03_SetupCatchPlayer",), + 0x809E3D98:("Boss03_CatchPlayer",), + 0x809E4180:("Boss03_SetupChewPlayer",), + 0x809E421C:("Boss03_ChewPlayer",), + 0x809E4674:("Boss03_SetupPrepareCharge",), + 0x809E475C:("Boss03_PrepareCharge",), + 0x809E4910:("Boss03_SetupCharge",), + 0x809E497C:("Boss03_Charge",), + 0x809E4C34:("Boss03_SetupJumpOverPlatform",), + 0x809E4C90:("Boss03_JumpOverPlatform",), + 0x809E4E2C:("Boss03_SetupIntroCutscene",), + 0x809E4E80:("Boss03_IntroCutscene",), + 0x809E5ADC:("Boss03_SetupDeathCutscene",), + 0x809E5B64:("Boss03_DeathCutscene",), + 0x809E65F4:("Boss03_SetupSpawnSmallFishesCutscene",), + 0x809E6640:("Boss03_SpawnSmallFishesCutscene",), + 0x809E69A4:("Boss03_SetupStunned",), + 0x809E6A38:("Boss03_Stunned",), + 0x809E6B70:("Boss03_SetupDamaged",), + 0x809E6BC0:("Boss03_Damaged",), + 0x809E6CB4:("Boss03_UpdateCollision",), 0x809E70EC:("Boss03_Update",), - 0x809E7920:("func_809E7920",), - 0x809E79C4:("func_809E79C4",), - 0x809E7AA8:("func_809E7AA8",), + 0x809E7920:("Boss03_SetObject",), + 0x809E79C4:("Boss03_OverrideLimbDraw",), + 0x809E7AA8:("Boss03_PostLimbDraw",), 0x809E7C0C:("Boss03_Draw",), - 0x809E7D00:("func_809E7D00",), - 0x809E81E4:("func_809E81E4",), - 0x809E8810:("func_809E8810",), - 0x809E8BEC:("func_809E8BEC",), + 0x809E7D00:("Boss03_UpdateEffects",), + 0x809E81E4:("Boss03_DrawEffects",), + 0x809E8810:("Boss03_SeaweedUpdate",), + 0x809E8BEC:("Boss03_SeaweedDraw",), 0x809EC040:("func_809EC040",), 0x809EC0D0:("Boss04_Init",), 0x809EC534:("Boss04_Destroy",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 63a7f9a74..2e66c57e1 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -10310,17 +10310,17 @@ 0x809E8F14:("D_809E8F14","UNK_TYPE1","",0x1), 0x809E8F24:("D_809E8F24","UNK_TYPE1","",0x1), 0x809E8FD8:("D_809E8FD8","UNK_TYPE1","",0x1), - 0x809E8FE8:("D_809E8FE8","UNK_TYPE4","",0x4), - 0x809E90FC:("D_809E90FC","UNK_TYPE1","",0x1), - 0x809E9100:("D_809E9100","UNK_TYPE1","",0x1), + 0x809E8FE8:("sGyorgInitialPos","Vec3f","",0xC), + 0x809E8FF4:("D_809E8FF4","f32","",0x1), + 0x809E90FC:("sGyorgDustPrimColor","UNK_TYPE1","",0x1), + 0x809E9100:("sGyorgDustEnvColor","UNK_TYPE1","",0x1), 0x809E9104:("D_809E9104","UNK_TYPE1","",0x1), - 0x809E9128:("D_809E9128","UNK_TYPE1","",0x1), - 0x809E9136:("D_809E9136","UNK_TYPE1","",0x1), + 0x809E9128:("sGyorgSphElementIndices","s8","[30]",0x1E), 0x809E9148:("D_809E9148","UNK_TYPE1","",0x1), - 0x809E9154:("D_809E9154","UNK_TYPE1","",0x1), + 0x809E9154:("D_809E9154","Vec3f","[7]",0x54), 0x809E91A8:("D_809E91A8","UNK_TYPE1","",0x1), 0x809E91B4:("D_809E91B4","f32","",0x4), - 0x809E91C0:("D_809E91C0","UNK_TYPE4","",0x4), + 0x809E91C0:("sGyorgSeaweedDLs","UNK_TYPE4","",0x4), 0x809E91E0:("D_809E91E0","f32","",0x4), 0x809E91E4:("D_809E91E4","f32","",0x4), 0x809E91E8:("D_809E91E8","f32","",0x4), @@ -10383,13 +10383,11 @@ 0x809E9841:("D_809E9841","UNK_TYPE1","",0x1), 0x809E9842:("D_809E9842","UNK_TYPE1","",0x1), 0x809E9848:("D_809E9848","UNK_TYPE1","",0x1), - 0x809E9858:("D_809E9858","UNK_TYPE1","",0x1), - 0x809E989C:("D_809E989C","UNK_TYPE1","",0x1), - 0x809E98E0:("D_809E98E0","UNK_TYPE1","",0x1), - 0x809EC030:("D_809EC030","UNK_TYPE4","",0x4), - 0x809EC034:("D_809EC034","UNK_TYPE4","",0x4), - 0x809EC038:("D_809EC038","UNK_TYPE4","",0x4), - 0x809EC03C:("D_809EC03C","UNK_TYPE4","",0x4), + 0x809E9858:("sGyorgEffects","UNK_TYPE1","[150]",0x27D8), + 0x809EC030:("sGyorgBossInstance","UNK_TYPE4","",0x4), + 0x809EC034:("sRandSeed0","UNK_TYPE4","",0x4), + 0x809EC038:("sRandSeed1","UNK_TYPE4","",0x4), + 0x809EC03C:("sRandSeed2","UNK_TYPE4","",0x4), 0x809EE150:("D_809EE150","UNK_TYPE1","",0x1), 0x809EE170:("Boss_04_InitVars","UNK_TYPE1","",0x1), 0x809EE190:("D_809EE190","UNK_TYPE1","",0x1), diff --git a/undefined_syms.txt b/undefined_syms.txt index 3f0785fbb..f02460c26 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -745,21 +745,6 @@ D_06022118 = 0x06022118; D_060222D0 = 0x060222D0; D_06022550 = 0x06022550; -// ovl_Boss_03 - -D_06004260 = 0x06004260; -D_060042B0 = 0x060042B0; -D_060042F8 = 0x060042F8; -D_06007E50 = 0x06007E50; -D_06007EB0 = 0x06007EB0; -D_06007EC8 = 0x06007EC8; -D_060093A8 = 0x060093A8; -D_06009554 = 0x06009554; -D_060099D0 = 0x060099D0; -D_06009C14 = 0x06009C14; -D_06009CF8 = 0x06009CF8; -D_0600A6C8 = 0x0600A6C8; - // ovl_Boss_05 D_060006A4 = 0x060006A4; From ea3bbee803e77672509046e387e55d86007c9227 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 17:49:44 +0100 Subject: [PATCH 152/257] Dm_An (#737) * Dm_An * Merge --- assets/xml/objects/object_an1.xml | 13 +- spec | 3 +- src/overlays/actors/ovl_Dm_An/z_dm_an.c | 339 ++++++++++++++++++++++-- src/overlays/actors/ovl_Dm_An/z_dm_an.h | 26 +- undefined_syms.txt | 5 - 5 files changed, 355 insertions(+), 31 deletions(-) diff --git a/assets/xml/objects/object_an1.xml b/assets/xml/objects/object_an1.xml index 15c38af32..2c212923d 100644 --- a/assets/xml/objects/object_an1.xml +++ b/assets/xml/objects/object_an1.xml @@ -35,15 +35,22 @@ - + - + - + + + + + + + + diff --git a/spec b/spec index 20d583887..18b8558b7 100644 --- a/spec +++ b/spec @@ -5209,8 +5209,7 @@ beginseg name "ovl_Dm_An" compress include "build/src/overlays/actors/ovl_Dm_An/z_dm_an.o" - include "build/data/ovl_Dm_An/ovl_Dm_An.data.o" - include "build/data/ovl_Dm_An/ovl_Dm_An.reloc.o" + include "build/src/overlays/actors/ovl_Dm_An/ovl_Dm_An_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Dm_An/z_dm_an.c b/src/overlays/actors/ovl_Dm_An/z_dm_an.c index e6175bfd9..2c23601f7 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.c +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.c @@ -5,6 +5,8 @@ */ #include "z_dm_an.h" +#include "objects/object_an4/object_an4.h" +#include "objects/object_msmo/object_msmo.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -17,8 +19,8 @@ void DmAn_Update(Actor* thisx, GlobalContext* globalCtx); void func_80C1C958(DmAn* this, GlobalContext* globalCtx); void func_80C1CAB0(DmAn* this, GlobalContext* globalCtx); void func_80C1CC80(DmAn* this, GlobalContext* globalCtx); +void func_80C1D0B0(Actor* this, GlobalContext* globalCtx); -#if 0 const ActorInit Dm_An_InitVars = { ACTOR_DM_AN, ACTORCAT_NPC, @@ -31,37 +33,336 @@ const ActorInit Dm_An_InitVars = { (ActorFunc)NULL, }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_an1_Anim_007E08, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an1_Anim_0071E8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_006CC0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an1_Anim_013E1C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_007E3C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_0088C0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_0013C8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_002550, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_00353C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_004498, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_0060B4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_00041C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_004A78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_00506C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern UNK_TYPE D_06000E70; -extern UNK_TYPE D_06012618; +s32 func_80C1C410(DmAn* this, GlobalContext* globalCtx) { + s8 objectIndex = this->actor.objBankIndex; + s8 objectIndex2; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C410.s") + if (this->unk_2C8 < 2) { + objectIndex2 = this->actor.objBankIndex; + } else { + objectIndex2 = this->unk_2AC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C4D8.s") + if (objectIndex2 >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + ret = SkelAnime_Update(&this->skelAnime); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C5B4.s") +s32 func_80C1C4D8(DmAn* this, GlobalContext* globalCtx, s32 arg2) { + s8 objectIndex = this->actor.objBankIndex; + s8 objectIndex2; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C62C.s") + if (arg2 < 2) { + objectIndex2 = this->actor.objBankIndex; + } else { + objectIndex2 = this->unk_2AC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C83C.s") + if ((objectIndex2 >= 0) && (arg2 != this->unk_2C8)) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + this->unk_2C8 = arg2; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg2); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C8E8.s") +void func_80C1C5B4(DmAn* this) { + if (DECR(this->unk_2BA) == 0) { + this->unk_2B8++; + if (this->unk_2B8 >= 4) { + this->unk_2BA = Rand_S16Offset(30, 30); + this->unk_2B8 = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C958.s") +s32 func_80C1C62C(DmAn* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1CAB0.s") + Math_Vec3f_Copy(&sp40, &this->unk_2B4->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1CC80.s") + Math_ApproachS(&this->unk_2C0, (sp32 - this->unk_2C4) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2C0 = CLAMP(this->unk_2C0, -0x1FFE, 0x1FFE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/DmAn_Init.s") + Math_ApproachS(&this->unk_2C4, (sp32 - this->unk_2C0) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2C4 = CLAMP(this->unk_2C4, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/DmAn_Destroy.s") + if (this->unk_2B4->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_2B4)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_2B4->focus.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/DmAn_Update.s") + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + Math_ApproachS(&this->unk_2BE, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2C2, 4, 0x2AA8); + this->unk_2BE = CLAMP(this->unk_2BE, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1CD80.s") + Math_ApproachS(&this->unk_2C2, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2BE, 4, 0x2AA8); + this->unk_2C2 = CLAMP(this->unk_2C2, -0x1C70, 0x1C70); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1CEFC.s") +s32 func_80C1C83C(DmAn* this, GlobalContext* globalCtx) { + if (this->unk_2B4 != NULL) { + func_80C1C62C(this, globalCtx); + this->unk_2AE &= ~1; + this->unk_2AE |= 2; + } else if (this->unk_2AE & 2) { + this->unk_2AE &= ~2; + this->unk_2BE = 0; + this->unk_2C0 = 0; + this->unk_2C2 = 0; + this->unk_2C4 = 0; + this->unk_2BC = 20; + } else if (DECR(this->unk_2BC) == 0) { + this->unk_2AE |= 1; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1D0B0.s") +Actor* func_80C1C8E8(GlobalContext* globalCtx) { + Actor* tempActor; + Actor* foundActor = NULL; + + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, ACTORCAT_NPC, ACTOR_DM_AH); + + if ((foundActor == NULL) || (foundActor->update != NULL)) { + break; + } + + tempActor = foundActor->next; + if (tempActor == NULL || NULL) { + foundActor = NULL; + break; + } + foundActor = tempActor; + } + return foundActor; +} + +void func_80C1C958(DmAn* this, GlobalContext* globalCtx) { + if ((this->unk_2AC >= 0) && SubS_IsObjectLoaded(this->unk_2AC, globalCtx) && (this->unk_2AD >= 0) && + SubS_IsObjectLoaded(this->unk_2AD, globalCtx)) { + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 14.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_an1_Skel_012618, NULL, this->jointTable, + this->morphTable, OBJECT_AN1_LIMB_MAX); + + this->unk_2C8 = -1; + func_80C1C4D8(this, globalCtx, 0); + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + this->unk_2AE |= 1; + this->actor.draw = func_80C1D0B0; + + if ((globalCtx->sceneNum == SCENE_YADOYA) && (globalCtx->curSpawn == 4)) { + this->unk_2B4 = func_80C1C8E8(globalCtx); + func_80C1C4D8(this, globalCtx, 1); + this->actionFunc = func_80C1CC80; + } else { + this->actionFunc = func_80C1CAB0; + } + } +} + +void func_80C1CAB0(DmAn* this, GlobalContext* globalCtx) { + s32 sp28[] = { 0, 0, 12, 2, 4, 6, 8, 10, 11, 3 }; + u16 action; + s32 sp20; + + if (globalCtx->csCtx.state != 0) { + if (this->unk_2D0 == 0) { + this->unk_2B0 = 255; + this->unk_2D0 = 1; + this->unk_2D4 = 0; + this->unk_2CC = this->unk_2C8; + } + + if (Cutscene_CheckActorAction(globalCtx, 0x22D)) { + sp20 = Cutscene_GetActorActionIndex(globalCtx, 0x22D); + action = globalCtx->csCtx.actorActions[sp20]->action; + + if (this->unk_2B0 != (action & 0xFF)) { + this->unk_2B0 = action; + this->unk_2D4 = 1; + func_80C1C4D8(this, globalCtx, sp28[action]); + } + + switch (this->unk_2B0) { + case 2: + case 4: + case 5: + case 6: + case 7: + case 8: + if ((this->unk_2C8 == 12) || (this->unk_2C8 == 4) || (this->unk_2C8 == 6) || (this->unk_2C8 == 8)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80C1C4D8(this, globalCtx, this->unk_2C8 + 1); + } + } + break; + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, sp20); + } + } else if (this->unk_2D0 != 0) { + this->unk_2D0 = 0; + this->unk_2D4 = 0; + func_80C1C4D8(this, globalCtx, this->unk_2CC); + } +} + +void func_80C1CC80(DmAn* this, GlobalContext* globalCtx) { +} + +void DmAn_Init(Actor* thisx, GlobalContext* globalCtx) { + DmAn* this = THIS; + + this->unk_2AC = SubS_GetObjectIndex(OBJECT_AN4, globalCtx); + this->unk_2AD = SubS_GetObjectIndex(OBJECT_MSMO, globalCtx); + this->actionFunc = func_80C1C958; +} + +void DmAn_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void DmAn_Update(Actor* thisx, GlobalContext* globalCtx) { + DmAn* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80C1C83C(this, globalCtx); + + if (this->actor.draw != NULL) { + func_80C1C410(this, globalCtx); + func_80C1C5B4(this); + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); +} + +Vec3f D_80C1D2C8 = { 450.0f, 700.0f, -760.0f }; +Vec3s D_80C1D2D4 = { 0x238C, 0, -0x3FFC }; +Vec3f D_80C1D2DC = { 1000.0f, 0.0f, 0.0f }; + +void func_80C1CD80(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad[2]; + DmAn* this = THIS; + s8 sp2B = this->actor.objBankIndex; + s8 sp2A = this->unk_2AD; + + if ((limbIndex == OBJECT_AN1_LIMB_05) && (this->unk_2D4 != 0)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + Matrix_JointPosition(&D_80C1D2C8, &D_80C1D2D4); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2A].segment); + gSPDisplayList(POLY_OPA_DISP++, gMoonMaskDL); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2B].segment); + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (limbIndex == OBJECT_AN1_LIMB_09) { + Matrix_MultiplyVector3fByState(&D_80C1D2DC, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } +} + +void func_80C1CEFC(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + DmAn* this = THIS; + s16 phi_v1; + s16 phi_v0; + + if (!(this->unk_2AE & 1)) { + if (this->unk_2AE & 2) { + phi_v0 = 1; + } else { + phi_v0 = 0; + } + phi_v1 = 1; + } else { + phi_v1 = 0; + phi_v0 = 0; + } + + if (limbIndex == OBJECT_AN1_LIMB_09) { + func_8013AD9C(this->unk_2BE + this->unk_2C2 + 0x4000, + this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, &this->unk_1A4, + phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_1A4.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_1A4.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_1A4.z, MTXMODE_APPLY); + Matrix_StatePush(); + } else if (limbIndex == OBJECT_AN1_LIMB_02) { + func_8013AD9C(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, + &this->unk_1AA, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_1AA.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_1AA.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_1AA.z, MTXMODE_APPLY); + Matrix_StatePush(); + } +} + +TexturePtr D_80C1D2E8[] = { + object_an1_Tex_00E6E0, + &object_an1_Tex_00F7A0, + &object_an1_Tex_0101A0, +}; + +TexturePtr D_80C1D2F4[] = { + &object_an1_Tex_00E1E0, &object_an1_Tex_00EFA0, &object_an1_Tex_00F3A0, &object_an1_Tex_00EFA0, + &object_an1_Tex_00FDA0, &object_an1_Tex_00F9A0, &object_an1_Tex_0103A0, +}; + +void func_80C1D0B0(Actor* thisx, GlobalContext* globalCtx) { + DmAn* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C1D2F4[this->unk_2B8])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C1D2E8[0])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, func_80C1CD80, func_80C1CEFC, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_An/z_dm_an.h b/src/overlays/actors/ovl_Dm_An/z_dm_an.h index 70fcaa852..1b2b6f354 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.h +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.h @@ -2,6 +2,7 @@ #define Z_DM_AN_H #include "global.h" +#include "objects/object_an1/object_an1.h" struct DmAn; @@ -9,9 +10,30 @@ typedef void (*DmAnActionFunc)(struct DmAn*, GlobalContext*); typedef struct DmAn { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ DmAnActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x14C]; + /* 0x018C */ Vec3f unk_18C; + /* 0x018C */ Vec3f unk_194; + /* 0x01A4 */ Vec3s unk_1A4; + /* 0x01A4 */ Vec3s unk_1AA; + /* 0x01B0 */ Vec3s jointTable[OBJECT_AN1_LIMB_MAX]; + /* 0x022E */ Vec3s morphTable[OBJECT_AN1_LIMB_MAX]; + /* 0x02AC */ s8 unk_2AC; + /* 0x02AD */ s8 unk_2AD; + /* 0x02AE */ u16 unk_2AE; + /* 0x02B0 */ u8 unk_2B0; + /* 0x02B4 */ Actor* unk_2B4; + /* 0x02B8 */ s16 unk_2B8; + /* 0x02BA */ s16 unk_2BA; + /* 0x02BC */ s16 unk_2BC; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C2 */ s16 unk_2C2; + /* 0x02C4 */ s16 unk_2C4; + /* 0x02C8 */ s32 unk_2C8; + /* 0x02CC */ s32 unk_2CC; + /* 0x02D0 */ s32 unk_2D0; + /* 0x02D4 */ s32 unk_2D4; } DmAn; // size = 0x2D8 extern const ActorInit Dm_An_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index f02460c26..3b9d3fbe9 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -880,11 +880,6 @@ D_06009E70 = 0x06009E70; D_0600A0D8 = 0x0600A0D8; -// ovl_Dm_An - -D_06000E70 = 0x06000E70; -D_06012618 = 0x06012618; - // ovl_Dm_Bal D_060005FC = 0x060005FC; From 37e82498dfb03275ce7dac4f101cc97a12e2947d Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 17:55:32 +0100 Subject: [PATCH 153/257] Dm_Gm (#739) * Dm_Gm * PR --- spec | 3 +- src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c | 340 ++++++++++++++++++++++-- src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h | 26 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 5 - 5 files changed, 348 insertions(+), 30 deletions(-) diff --git a/spec b/spec index 18b8558b7..5d82b9e2f 100644 --- a/spec +++ b/spec @@ -5319,8 +5319,7 @@ beginseg name "ovl_Dm_Gm" compress include "build/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.o" - include "build/data/ovl_Dm_Gm/ovl_Dm_Gm.data.o" - include "build/data/ovl_Dm_Gm/ovl_Dm_Gm.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Gm/ovl_Dm_Gm_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c index c2edb33a0..88a99ad53 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c @@ -5,6 +5,8 @@ */ #include "z_dm_gm.h" +#include "objects/object_an4/object_an4.h" +#include "objects/object_msmo/object_msmo.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -17,8 +19,8 @@ void DmGm_Update(Actor* thisx, GlobalContext* globalCtx); void func_80C248A8(DmGm* this, GlobalContext* globalCtx); void func_80C24A00(DmGm* this, GlobalContext* globalCtx); void func_80C24BD0(DmGm* this, GlobalContext* globalCtx); +void func_80C25000(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Dm_Gm_InitVars = { ACTOR_DM_GM, ACTORCAT_NPC, @@ -31,37 +33,337 @@ const ActorInit Dm_Gm_InitVars = { (ActorFunc)NULL, }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_an1_Anim_007E08, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an1_Anim_0071E8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_006CC0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_an1_Anim_013E1C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_an4_Anim_007E3C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_0088C0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_0013C8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_002550, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_00353C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_004498, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_0060B4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_00041C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_004A78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_00506C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern UNK_TYPE D_06000E70; -extern UNK_TYPE D_06012618; +s32 func_80C24360(DmGm* this, GlobalContext* globalCtx) { + s8 objectIndex = this->actor.objBankIndex; + s8 objectIndex2; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24360.s") + if (this->unk_2C8 < 2) { + objectIndex2 = this->actor.objBankIndex; + } else { + objectIndex2 = this->unk_2AC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24428.s") + if (objectIndex2 >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + ret = SkelAnime_Update(&this->skelAnime); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24504.s") +s32 func_80C24428(DmGm* this, GlobalContext* globalCtx, s32 arg2) { + s8 objectIndex = this->actor.objBankIndex; + s8 objectIndex2; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C2457C.s") + if (arg2 < 2) { + objectIndex2 = this->actor.objBankIndex; + } else { + objectIndex2 = this->unk_2AC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C2478C.s") + if ((objectIndex2 >= 0) && (arg2 != this->unk_2C8)) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + this->unk_2C8 = arg2; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg2); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24838.s") +void func_80C24504(DmGm* this) { + if (DECR(this->unk_2BA) == 0) { + this->unk_2B8++; + if (this->unk_2B8 >= 4) { + this->unk_2BA = Rand_S16Offset(30, 30); + this->unk_2B8 = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C248A8.s") +s32 func_80C2457C(DmGm* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24A00.s") + Math_Vec3f_Copy(&sp40, &this->unk_2B4->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24BD0.s") + Math_ApproachS(&this->unk_2C0, (sp32 - this->unk_2C4) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2C0 = CLAMP(this->unk_2C0, -0x1FFE, 0x1FFE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/DmGm_Init.s") + Math_ApproachS(&this->unk_2C4, (sp32 - this->unk_2C0) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2C4 = CLAMP(this->unk_2C4, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/DmGm_Destroy.s") + if (this->unk_2B4->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_2B4)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_2B4->focus.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/DmGm_Update.s") + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + Math_ApproachS(&this->unk_2BE, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2C2, 4, 0x2AA8); + this->unk_2BE = CLAMP(this->unk_2BE, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24CD0.s") + Math_ApproachS(&this->unk_2C2, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2BE, 4, 0x2AA8); + this->unk_2C2 = CLAMP(this->unk_2C2, -0x1C70, 0x1C70); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24E4C.s") +s32 func_80C2478C(DmGm* this, GlobalContext* globalCtx) { + if (this->unk_2B4 != NULL) { + func_80C2457C(this, globalCtx); + this->unk_2AE &= ~1; + this->unk_2AE |= 2; + } else if (this->unk_2AE & 2) { + this->unk_2AE &= ~2; + this->unk_2BE = 0; + this->unk_2C0 = 0; + this->unk_2C2 = 0; + this->unk_2C4 = 0; + this->unk_2BC = 20; + } else if (DECR(this->unk_2BC) == 0) { + this->unk_2AE |= 1; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C25000.s") +Actor* func_80C24838(GlobalContext* globalCtx) { + Actor* tempActor; + Actor* foundActor = NULL; + + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, ACTORCAT_NPC, ACTOR_DM_AH); + + if ((foundActor == NULL) || (foundActor->update != NULL)) { + break; + } + + tempActor = foundActor->next; + if (tempActor == NULL || false) { + foundActor = NULL; + break; + } + foundActor = tempActor; + } + return foundActor; +} + +void func_80C248A8(DmGm* this, GlobalContext* globalCtx) { + if ((this->unk_2AC >= 0) && SubS_IsObjectLoaded(this->unk_2AC, globalCtx) && (this->unk_2AD >= 0) && + SubS_IsObjectLoaded(this->unk_2AD, globalCtx)) { + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 14.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_an1_Skel_012618, NULL, this->jointTable, + this->morphTable, OBJECT_AN1_LIMB_MAX); + + this->unk_2C8 = -1; + func_80C24428(this, globalCtx, 0); + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + this->unk_2AE |= 1; + this->actor.draw = func_80C25000; + + if ((globalCtx->sceneNum == SCENE_YADOYA) && (globalCtx->curSpawn == 4)) { + this->unk_2B4 = func_80C24838(globalCtx); + func_80C24428(this, globalCtx, 1); + this->actionFunc = func_80C24BD0; + } else { + this->actionFunc = func_80C24A00; + } + } +} + +void func_80C24A00(DmGm* this, GlobalContext* globalCtx) { + s32 sp28[] = { 0, 0, 12, 2, 4, 6, 8, 10, 11, 3 }; + u16 action; + s32 sp20; + + if (globalCtx->csCtx.state != 0) { + if (this->unk_2D0 == 0) { + this->unk_2B0 = 255; + this->unk_2D0 = 1; + this->unk_2D4 = 0; + this->unk_2CC = this->unk_2C8; + } + + if (Cutscene_CheckActorAction(globalCtx, 0x22D)) { + sp20 = Cutscene_GetActorActionIndex(globalCtx, 0x22D); + action = globalCtx->csCtx.actorActions[sp20]->action; + + if (this->unk_2B0 != (action & 0xFF)) { + this->unk_2B0 = action; + this->unk_2D4 = 1; + func_80C24428(this, globalCtx, sp28[action]); + } + + switch (this->unk_2B0) { + case 2: + case 4: + case 5: + case 6: + case 7: + case 8: + if ((this->unk_2C8 == 12) || (this->unk_2C8 == 4) || (this->unk_2C8 == 6) || (this->unk_2C8 == 8)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80C24428(this, globalCtx, this->unk_2C8 + 1); + } + } + break; + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, sp20); + } + } else if (this->unk_2D0 != 0) { + this->unk_2D0 = 0; + this->unk_2D4 = 0; + func_80C24428(this, globalCtx, this->unk_2CC); + } +} + +void func_80C24BD0(DmGm* this, GlobalContext* globalCtx) { +} + +void DmGm_Init(Actor* thisx, GlobalContext* globalCtx) { + DmGm* this = THIS; + + this->unk_2AC = SubS_GetObjectIndex(OBJECT_AN4, globalCtx); + this->unk_2AD = SubS_GetObjectIndex(OBJECT_MSMO, globalCtx); + this->actionFunc = func_80C248A8; +} + +void DmGm_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void DmGm_Update(Actor* thisx, GlobalContext* globalCtx) { + DmGm* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80C2478C(this, globalCtx); + + if (this->actor.draw != NULL) { + func_80C24360(this, globalCtx); + func_80C24504(this); + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); +} + +Vec3f D_80C25218 = { 450.0f, 700.0f, -760.0f }; +Vec3s D_80C25224 = { 0x238C, 0, -0x3FFC }; +Vec3f D_80C2522C = { 1000.0f, 0.0f, 0.0f }; + +void DmGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad[2]; + DmGm* this = THIS; + s8 sp2B = this->actor.objBankIndex; + s8 sp2A = this->unk_2AD; + + if ((limbIndex == OBJECT_AN1_LIMB_05) && (this->unk_2D4 != 0)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + Matrix_JointPosition(&D_80C25218, &D_80C25224); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2A].segment); + gSPDisplayList(POLY_OPA_DISP++, gMoonMaskDL); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2B].segment); + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (limbIndex == OBJECT_AN1_LIMB_09) { + Matrix_MultiplyVector3fByState(&D_80C2522C, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } +} + +void DmGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + DmGm* this = THIS; + s16 phi_v1; + s16 phi_v0; + + if (!(this->unk_2AE & 1)) { + if (this->unk_2AE & 2) { + phi_v0 = 1; + } else { + phi_v0 = 0; + } + phi_v1 = 1; + } else { + phi_v1 = 0; + phi_v0 = 0; + } + + if (limbIndex == OBJECT_AN1_LIMB_09) { + func_8013AD9C(this->unk_2BE + this->unk_2C2 + 0x4000, + this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, &this->unk_1A4, + phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_1A4.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_1A4.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_1A4.z, MTXMODE_APPLY); + Matrix_StatePush(); + } else if (limbIndex == OBJECT_AN1_LIMB_02) { + func_8013AD9C(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, + &this->unk_1AA, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_1AA.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_1AA.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_1AA.z, MTXMODE_APPLY); + Matrix_StatePush(); + } +} + +TexturePtr D_80C25238[] = { + object_an1_Tex_00E6E0, + object_an1_Tex_00F7A0, + object_an1_Tex_0101A0, +}; + +TexturePtr D_80C25244[] = { + object_an1_Tex_00E1E0, object_an1_Tex_00EFA0, object_an1_Tex_00F3A0, object_an1_Tex_00EFA0, + object_an1_Tex_00FDA0, object_an1_Tex_00F9A0, object_an1_Tex_0103A0, +}; + +void func_80C25000(Actor* thisx, GlobalContext* globalCtx) { + DmGm* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C25244[this->unk_2B8])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C25238[0])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, DmGm_PostLimbDraw, DmGm_TransformLimbDraw, + &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h index 8b416d7b7..6f2307378 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h @@ -2,6 +2,7 @@ #define Z_DM_GM_H #include "global.h" +#include "objects/object_an1/object_an1.h" struct DmGm; @@ -9,9 +10,30 @@ typedef void (*DmGmActionFunc)(struct DmGm*, GlobalContext*); typedef struct DmGm { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ DmGmActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x14C]; + /* 0x018C */ Vec3f unk_18C; + /* 0x018C */ Vec3f unk_194; + /* 0x01A4 */ Vec3s unk_1A4; + /* 0x01A4 */ Vec3s unk_1AA; + /* 0x01B0 */ Vec3s jointTable[OBJECT_AN1_LIMB_MAX]; + /* 0x022E */ Vec3s morphTable[OBJECT_AN1_LIMB_MAX]; + /* 0x02AC */ s8 unk_2AC; + /* 0x02AD */ s8 unk_2AD; + /* 0x02AE */ u16 unk_2AE; + /* 0x02B0 */ u8 unk_2B0; + /* 0x02B4 */ Actor* unk_2B4; + /* 0x02B8 */ s16 unk_2B8; + /* 0x02BA */ s16 unk_2BA; + /* 0x02BC */ s16 unk_2BC; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C2 */ s16 unk_2C2; + /* 0x02C4 */ s16 unk_2C4; + /* 0x02C8 */ s32 unk_2C8; + /* 0x02CC */ s32 unk_2CC; + /* 0x02D0 */ s32 unk_2D0; + /* 0x02D4 */ s32 unk_2D4; } DmGm; // size = 0x2D8 extern const ActorInit Dm_Gm_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 5a7448701..fd1b38a79 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -17112,8 +17112,8 @@ 0x80C24BE0:("DmGm_Init",), 0x80C24C34:("DmGm_Destroy",), 0x80C24C44:("DmGm_Update",), - 0x80C24CD0:("func_80C24CD0",), - 0x80C24E4C:("func_80C24E4C",), + 0x80C24CD0:("DmGm_PostLimbDraw",), + 0x80C24E4C:("DmGm_TransformLimbDraw",), 0x80C25000:("func_80C25000",), 0x80C25360:("func_80C25360",), 0x80C253D0:("func_80C253D0",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 3b9d3fbe9..0952a6663 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -911,11 +911,6 @@ D_0600E748 = 0x0600E748; D_0600005C = 0x0600005C; D_06001398 = 0x06001398; -// ovl_Dm_Gm - -D_06000E70 = 0x06000E70; -D_06012618 = 0x06012618; - // ovl_Dm_Opstage D_06000970 = 0x06000970; From a8e9b6c9b36104dc1aeda528ca7e17c0d49e4235 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 18:08:50 +0100 Subject: [PATCH 154/257] OBj_Fireshield (#740) --- spec | 3 +- .../ovl_Obj_Fireshield/z_obj_fireshield.c | 373 ++++++++++++++++-- .../ovl_Obj_Fireshield/z_obj_fireshield.h | 20 +- 3 files changed, 363 insertions(+), 33 deletions(-) diff --git a/spec b/spec index 5d82b9e2f..a300d6d9c 100644 --- a/spec +++ b/spec @@ -2883,8 +2883,7 @@ beginseg name "ovl_Obj_Fireshield" compress include "build/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.o" - include "build/data/ovl_Obj_Fireshield/ovl_Obj_Fireshield.data.o" - include "build/data/ovl_Obj_Fireshield/ovl_Obj_Fireshield.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Fireshield/ovl_Obj_Fireshield_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c index 00810af23..705dc93bf 100644 --- a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c +++ b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c @@ -5,6 +5,7 @@ */ #include "z_obj_fireshield.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,12 +16,12 @@ void ObjFireshield_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjFireshield_Update(Actor* thisx, GlobalContext* globalCtx); void ObjFireshield_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A4CABC(ObjFireshield* this, GlobalContext* globalCtx); -void func_80A4CB7C(ObjFireshield* this, GlobalContext* globalCtx); -void func_80A4CCBC(ObjFireshield* this, GlobalContext* globalCtx); -void func_80A4CD28(ObjFireshield* this, GlobalContext* globalCtx); +void func_80A4CABC(ObjFireshield* this); +void func_80A4CB7C(ObjFireshield* this); +void func_80A4CC54(ObjFireshield* this); +void func_80A4CCBC(ObjFireshield* this); +void func_80A4CD28(ObjFireshield* this); -#if 0 const ActorInit Obj_Fireshield_InitVars = { ACTOR_OBJ_FIRESHIELD, ACTORCAT_PROP, @@ -33,49 +34,365 @@ const ActorInit Obj_Fireshield_InitVars = { (ActorFunc)ObjFireshield_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A4D820 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x01, 0x04 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, { 28, 144, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A4D8A4[] = { +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; +} ObjFireshieldStruct; // size = 0x8 + +ObjFireshieldStruct D_80A4D84C[] = { + { 1.0f, 200.0f }, + { 2.0f, 400.0f }, + { 3.0f, 700.0f }, +}; + +s32 D_80A4D864[] = { 0, 0, 0, 0 }; +s32 D_80A4D874[] = { 0, 0, 0, 0 }; +s32 D_80A4D884[] = { 0, 0, 0, 0 }; +s32 D_80A4D894[] = { 0, 0, 0, 0 }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void func_80A4CA90(ObjFireshield* this) { + if (this->actor.cutscene >= 0) { + this->actionFunc = func_80A4CABC; + } else { + this->actionFunc = func_80A4CC54; + } +} -extern ColliderCylinderInit D_80A4D820; -extern InitChainEntry D_80A4D8A4[]; +void func_80A4CABC(ObjFireshield* this) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CA90.s") + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + s32 sp18 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 temp_a0 = (sp18 & ~0x1F) >> 5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CABC.s") + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actionFunc = func_80A4CB7C; + this->unk_194 = 20; + D_80A4D884[temp_a0] |= 1 << (sp18 & 0x1F); + D_80A4D894[temp_a0] |= 1 << (sp18 & 0x1F); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CB7C.s") +void func_80A4CB7C(ObjFireshield* this) { + s32 pad; + s32 sp18 = OBJFIRESHIELD_GET_7F(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CC54.s") + if (this->unk_194 > 0) { + if (this->unk_194 == 20) { + D_80A4D884[(sp18 & ~0x1F) >> 5] &= ~(1 << (sp18 & 0x1F)); + } + this->unk_194--; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CCBC.s") + ActorCutscene_Stop(this->actor.cutscene); + this->actionFunc = func_80A4CD28; + D_80A4D894[(sp18 & ~0x1F) >> 5] &= ~(1 << (sp18 & 0x1F)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CD28.s") +void func_80A4CC54(ObjFireshield* this) { + s32 temp_v0 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 temp_v1 = 1 << (temp_v0 & 0x1F); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CD34.s") + this->actionFunc = func_80A4CCBC; + D_80A4D884[(temp_v0 & ~0x1F) >> 5] |= temp_v1; + D_80A4D894[(temp_v0 & ~0x1F) >> 5] |= temp_v1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CE28.s") +void func_80A4CCBC(ObjFireshield* this) { + s32 temp_v0 = OBJFIRESHIELD_GET_7F(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4D174.s") + this->actionFunc = func_80A4CD28; + D_80A4D884[(temp_v0 & ~0x1F) >> 5] &= ~(1 << (temp_v0 & 0x1F)); + D_80A4D894[(temp_v0 & ~0x1F) >> 5] &= ~(1 << (temp_v0 & 0x1F)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4D1CC.s") +void func_80A4CD28(ObjFireshield* this) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/ObjFireshield_Init.s") +void func_80A4CD34(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjFireshield* this = THIS; + s32 sp24 = Flags_GetSwitch(globalCtx, OBJFIRESHIELD_GET_7F(&this->actor)); + s32 phi_v1; + s32 phi_a0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/ObjFireshield_Destroy.s") + if (this->unk_1A8 == 0) { + if (OBJFIRESHIELD_GET_2000(&this->actor)) { + phi_v1 = false; + phi_a0 = false; + } else { + phi_v1 = Flags_GetTreasure(globalCtx, OBJFIRESHIELD_GET_1F00(&this->actor)); + phi_a0 = false; + } + } else { + phi_a0 = Flags_GetSwitch(globalCtx, OBJFIRESHIELD_GET_3F80(&this->actor)); + phi_v1 = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/ObjFireshield_Update.s") + if (phi_v1 || phi_a0) { + this->unk_19C = 0; + } else if (sp24) { + this->unk_19C = 0; + } else { + this->unk_19C = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/ObjFireshield_Draw.s") + if (this->unk_19C == 0) { + this->unk_198 = 0.0f; + } else { + this->unk_198 = 1.0f; + } +} + +void func_80A4CE28(ObjFireshield* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp30 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 pad2[2]; + s32 sp24; + s32 sp20; + + if (this->unk_1A8 == 0) { + if (OBJFIRESHIELD_GET_2000(&this->actor)) { + sp24 = false; + sp20 = false; + } else { + sp24 = Flags_GetTreasure(globalCtx, OBJFIRESHIELD_GET_1F00(&this->actor)); + sp20 = false; + } + } else { + sp20 = Flags_GetSwitch(globalCtx, OBJFIRESHIELD_GET_3F80(&this->actor)); + sp24 = false; + } + + if (!sp24 || !sp20 || (this->unk_19C != 0)) { + s32 sp1C = Flags_GetSwitch(globalCtx, sp30); + s32 temp_v0 = (sp30 & ~0x1F) >> 5; + + if (this->unk_19C == 2) { + if (Math_StepToF(&this->unk_198, 1.0f, 0.03f)) { + this->unk_19C = 1; + if (((this->actor.home.rot.z * 10) > 0) && (this->unk_1A7 != 0)) { + Flags_UnsetSwitch(globalCtx, sp30); + sp1C = false; + } + } + } else if (this->unk_19C == 3) { + if (Math_StepToF(&this->unk_198, 0.0f, 0.03f)) { + this->unk_19C = 0; + } + } + + if ((this->unk_1A0 > 0) && (this->unk_19C == 1) && ((this->actor.home.rot.z * 10) > 0) && + !(D_80A4D894[temp_v0] & (1 << (sp30 & 0x1F)))) { + this->unk_1A0 = 0; + } + + if ((this->unk_19C == 0) || (this->unk_19C == 3)) { + if (!sp24 && !sp20) { + if ((this->actor.home.rot.z * 10) > 0) { + if (this->unk_1A0 > 1) { + this->unk_1A0--; + } + + if (this->unk_1A0 == 1) { + this->unk_19C = 2; + } + } + + if (!sp1C) { + this->unk_19C = 2; + } + } + } else if (sp24 || sp20) { + this->unk_19C = 3; + } else if (sp1C && ((this->unk_19C == 1) || (this->unk_19C == 2))) { + if ((D_80A4D884[temp_v0] & 1 << (sp30 & 0x1F)) && !(D_80A4D874[temp_v0] & 1 << (sp30 & 0x1F))) { + this->unk_19C = 3; + } else if (((this->actor.home.rot.z * 10) == 0) || (this->unk_1A0 == 0)) { + if ((this->actor.home.rot.z * 10) > 0) { + this->unk_1A0 = this->actor.home.rot.z * 10; + } + + if (this->unk_1A7 != 0) { + func_80A4CA90(this); + } + } + } + } +} + +void func_80A4D174(ObjFireshield* this) { + s32 temp_v0 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 temp_v1 = 1 << (temp_v0 & 0x1F); + + if (!(D_80A4D864[(temp_v0 & ~0x1F) >> 5] & temp_v1)) { + this->unk_1A7 = 1; + D_80A4D864[(temp_v0 & ~0x1F) >> 5] |= temp_v1; + } +} + +void func_80A4D1CC(void) { + D_80A4D864[0] = 0; + D_80A4D864[1] = 0; + D_80A4D864[2] = 0; + D_80A4D864[3] = 0; +} + +void ObjFireshield_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjFireshield* this = THIS; + s32 temp = 0x8000; + ObjFireshieldStruct* sp2C = &D_80A4D84C[OBJFIRESHIELD_GET_C000(&this->actor)]; + s32 sp28 = OBJFIRESHIELD_GET_ROTX(&this->actor); + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if (sp28) { + this->actor.shape.rot.z = temp; + } else { + this->actor.shape.rot.z = 0; + } + + this->actor.world.rot.z = 0; + this->actor.shape.rot.x = 0; + this->actor.world.rot.x = 0; + + this->actor.scale.x = sp2C->unk_00 * 0.0348f; + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = 0.05f; + + this->actor.uncullZoneScale = sp2C->unk_04; + this->unk_1A4 = Rand_ZeroOne() * 128.0f; + + if ((this->actor.home.rot.z * 10) < 0) { + this->unk_1A8 = 1; + this->actor.home.rot.z = -thisx->home.rot.z; + } + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider); + + this->collider.dim.radius *= sp2C->unk_00; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + func_80A4D174(this); + func_80A4CD34(&this->actor, globalCtx); + this->actionFunc = func_80A4CD28; +} + +void ObjFireshield_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjFireshield* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void ObjFireshield_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjFireshield* this = THIS; + ObjFireshield* this2 = THIS; + s32 sp44 = OBJFIRESHIELD_GET_ROTX(&this->actor); + s32 sp40 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 temp_a0; + s32 temp_v1; + + func_80A4D1CC(); + + if (this->unk_1A7 != 0) { + temp_a0 = (sp40 & ~0x1F) >> 5; + temp_v1 = 1 << (sp40 & 0x1F); + if ((D_80A4D884[temp_a0] & temp_v1)) { + D_80A4D874[temp_a0] |= temp_v1; + } else { + D_80A4D874[temp_a0] &= ~temp_v1; + } + } + + this->unk_1A4++; + + this->actionFunc(this); + + if (this->actionFunc == func_80A4CABC) { + this->collider.base.atFlags &= ~AT_HIT; + } else if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + func_800B8D98(globalCtx, &this->actor, 5.0f, this->actor.yawTowardsPlayer, 1.0f); + } + + func_80A4CE28(this, globalCtx); + + this->actor.world.pos.y = ((sp44 ? 144.0f : -144.0f) * (1.0f - this2->unk_198)) + this->actor.home.pos.y; + + this->unk_1A6 = this->unk_198 * 255.0f; + + if (this->unk_198 >= 0.7f) { + Player* player = GET_PLAYER(globalCtx); + + this->collider.dim.height = this->unk_198 * 80.0f; + + if (sp44) { + this->collider.dim.yShift = + (s32)(this->actor.home.pos.y - this->actor.world.pos.y) - this->collider.dim.height; + } else { + this->collider.dim.yShift = this->actor.home.pos.y - this->actor.world.pos.y; + } + + func_800B9010(&this->actor, NA_SE_EV_BURNING - SFX_FLAG); + + if (player->transformation == PLAYER_FORM_GORON) { + this->collider.info.toucher.damage = 0; + this->collider.info.toucher.effect = 0; + } else { + this->collider.info.toucher.damage = 4; + this->collider.info.toucher.effect = 1; + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void ObjFireshield_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjFireshield* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 220, 0, this->unk_1A6); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, this->unk_1A4 & 0x7F, 0, 0x20, 0x40, 1, 0, + (this->unk_1A4 * -15) & 0xFF, 0x20, 0x40)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_02E510); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h index f39039793..4d6a971eb 100644 --- a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h +++ b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h @@ -5,13 +5,27 @@ struct ObjFireshield; -typedef void (*ObjFireshieldActionFunc)(struct ObjFireshield*, GlobalContext*); +typedef void (*ObjFireshieldActionFunc)(struct ObjFireshield*); + +#define OBJFIRESHIELD_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJFIRESHIELD_GET_1F00(thisx) (((thisx)->params >> 8) & 0x1F) +#define OBJFIRESHIELD_GET_2000(thisx) (((thisx)->params >> 0xD) & 1) +#define OBJFIRESHIELD_GET_3F80(thisx) (((thisx)->params >> 7) & 0x7F) +#define OBJFIRESHIELD_GET_C000(thisx) (((thisx)->params >> 0xE) & 3) +#define OBJFIRESHIELD_GET_ROTX(thisx) ((thisx)->home.rot.x & 1) typedef struct ObjFireshield { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; + /* 0x0144 */ ColliderCylinder collider; /* 0x0190 */ ObjFireshieldActionFunc actionFunc; - /* 0x0194 */ char unk_194[0x18]; + /* 0x0194 */ s32 unk_194; + /* 0x0198 */ f32 unk_198; + /* 0x019C */ s32 unk_19C; + /* 0x01A0 */ s32 unk_1A0; + /* 0x01A4 */ s16 unk_1A4; + /* 0x01A6 */ u8 unk_1A6; + /* 0x01A7 */ s8 unk_1A7; + /* 0x01A8 */ s8 unk_1A8; } ObjFireshield; // size = 0x1AC extern const ActorInit Obj_Fireshield_InitVars; From 9af2914992edb32f35e771b86cb6aa82ccd7b01c Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 18:16:05 +0100 Subject: [PATCH 155/257] Obj_Grass_Carry (#741) * Obj_Grass_Carry * Fix? * Fix2? * Merge * Test * Merge --- spec | 3 +- .../actors/ovl_Obj_Grass/z_obj_grass.c | 3 +- .../actors/ovl_Obj_Grass/z_obj_grass.h | 8 +- .../ovl_Obj_Grass_Carry/z_obj_grass_carry.c | 333 ++++++++++++++++-- .../ovl_Obj_Grass_Carry/z_obj_grass_carry.h | 10 +- 5 files changed, 318 insertions(+), 39 deletions(-) diff --git a/spec b/spec index a300d6d9c..16fb78b81 100644 --- a/spec +++ b/spec @@ -2283,8 +2283,7 @@ beginseg name "ovl_Obj_Grass_Carry" compress include "build/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.o" - include "build/data/ovl_Obj_Grass_Carry/ovl_Obj_Grass_Carry.data.o" - include "build/data/ovl_Obj_Grass_Carry/ovl_Obj_Grass_Carry.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Grass_Carry/ovl_Obj_Grass_Carry_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c index 3da7e37f4..d95cc0631 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c @@ -5,6 +5,7 @@ */ #include "z_obj_grass.h" +#include "overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h" #include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -266,7 +267,7 @@ void func_809A983C(ObjGrass* this, GlobalContext* globalCtx) { Math_Vec3f_Yaw(&player->actor.world.pos, &ptr->unk_0C[j].unk_00); if (ABS_ALT(yaw) < 0x2000) { - this->unk_3294 = &ptr->unk_0C[j].unk_00; + this->unk_3294 = &ptr->unk_0C[j]; } } } diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h index 83c638a69..1c87108df 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h @@ -5,8 +5,9 @@ #include "overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h" struct ObjGrass; +struct ObjGrassCarry; -typedef struct { +typedef struct ObjGrassStruct1_1 { /* 0x00 */ Vec3f unk_00; /* 0x0C */ s16 unk_0C; /* 0x0E */ s8 unk_0E; @@ -38,8 +39,9 @@ typedef struct ObjGrass { /* 0x328C */ s16 unk_328C; /* 0x328E */ s16 unk_328E; /* 0x3290 */ s16 unk_3290; - /* 0x3294 */ Vec3f* unk_3294; - /* 0x3298 */ ObjGrassCarry* unk_3298[2]; + /* 0x3292 */ s16 unk_3292; + /* 0x3294 */ ObjGrassStruct1_1* unk_3294; + /* 0x3298 */ struct ObjGrassCarry* unk_3298[2]; } ObjGrass; // size = 0x32A0 extern const ActorInit Obj_Grass_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c index 0a703c965..2e9df3323 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c +++ b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.c @@ -5,6 +5,9 @@ */ #include "z_obj_grass_carry.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "overlays/actors/ovl_Obj_Grass/z_obj_grass.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_800000) @@ -14,7 +17,18 @@ void ObjGrassCarry_Init(Actor* thisx, GlobalContext* globalCtx); void ObjGrassCarry_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjGrassCarry_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_809AB3C4(ObjGrassCarry* this); +void func_809AB3D8(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB428(ObjGrassCarry* this); +void func_809AB43C(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB474(ObjGrassCarry* this); +void func_809AB4A8(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB5FC(ObjGrassCarry* this); +void func_809AB610(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB6FC(ObjGrassCarry* this); +void func_809AB77C(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809ABB7C(Actor* this, GlobalContext* globalCtx); + const ActorInit Obj_Grass_Carry_InitVars = { ACTOR_OBJ_GRASS_CARRY, ACTORCAT_PROP, @@ -27,61 +41,320 @@ const ActorInit Obj_Grass_Carry_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809ABBD0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, { 10, 44, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809ABC4C[] = { +s16 D_809ABBFC = 0; +s16 D_809ABC00 = 0; +s16 D_809ABC04 = 0; +s16 D_809ABC08 = 0; + +Vec3f D_809ABC0C[] = { + { 0.0f, 0.7071f, 0.7071f }, + { 0.7071f, 0.7071f, 0.0f }, + { 0.0f, 0.7071f, -0.7071f }, + { -0.7071f, 0.7071f, 0.0f }, +}; + +s16 D_809ABC3C[] = { 0x6C, 0x66, 0x60, 0x54, 0x42, 0x37, 0x2A, 0x26 }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -3200, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -17000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_STOP), }; -#endif +void func_809AAE60(ObjGrassCarry* this) { + this->actor.velocity.y += this->actor.gravity; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } +} -extern ColliderCylinderInit D_809ABBD0; -extern InitChainEntry D_809ABC4C[]; +void func_809AAE94(Vec3f* arg0, f32 arg1) { + arg1 += ((Rand_ZeroOne() * 0.2f) - 0.1f) * arg1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAE60.s") + arg0->x -= (arg0->x * arg1); + arg0->y -= (arg0->y * arg1); + arg0->z -= (arg0->z * arg1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAE94.s") +void func_809AAF18(ObjGrassCarry* this) { + func_809AAE60(this); + func_809AAE94(&this->actor.velocity, 0.05f); + Actor_UpdatePos(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAF18.s") +void func_809AAF58(ObjGrassCarry* this, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAF58.s") +void func_809AAF9C(Vec3f* arg0, s16 arg1, GlobalContext* globalCtx) { + if (!(arg1 & 0x10)) { + Item_DropCollectibleRandom(globalCtx, NULL, arg0, arg1 * 0x10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAF9C.s") +void func_809AAFE8(Vec3f* arg0, GlobalContext* globalCtx) { + Vec3f spBC; + Vec3f spB0; + s32 i; + Vec3f* ptr; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAFE8.s") + for (i = 0; i < ARRAY_COUNT(D_809ABC0C); i++) { + ptr = &D_809ABC0C[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/ObjGrassCarry_Init.s") + spB0.x = arg0->x + (ptr->x * 8.0f); + spB0.y = arg0->y + (ptr->y * 8.0f) + 10.0f; + spB0.z = arg0->z + (ptr->z * 8.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/ObjGrassCarry_Destroy.s") + spBC.x = (Rand_ZeroOne() - 0.5f) * 8.0f; + spBC.y = Rand_ZeroOne() * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB3C4.s") + EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, + D_809ABC3C[(s32)(Rand_ZeroOne() * 111.1f) & 7], 0, 0, 80, -1, 1, gKakeraLeafMiddle); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB3D8.s") + spB0.x = arg0->x + (ptr->x * 16.0f); + spB0.y = arg0->y + (ptr->y * 16.0f) + 10.0f; + spB0.z = arg0->z + (ptr->z * 16.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB428.s") + spBC.x = (Rand_ZeroOne() - 0.5f) * 6.0f; + spBC.y = Rand_ZeroOne() * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 6.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB43C.s") + EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, + D_809ABC3C[(s32)(Rand_ZeroOne() * 111.1f) % 7], 0, 0, 80, -1, 1, gKakeraLeafTip); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB474.s") +void ObjGrassCarry_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjGrassCarry* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB4A8.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = 80; + func_809AB3C4(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB5FC.s") +void ObjGrassCarry_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjGrassCarry* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB610.s") + Collider_DestroyCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB6FC.s") + if (this->unk_190 != NULL) { + ObjGrassCarry** carry = &this->unk_190->unk_3298[this->actor.params]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB77C.s") + if (this == *carry) { + *carry = NULL; + this->unk_190 = NULL; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/ObjGrassCarry_Update.s") +void func_809AB3C4(ObjGrassCarry* this) { + this->actionFunc = func_809AB3D8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809ABB7C.s") +void func_809AB3D8(ObjGrassCarry* this, GlobalContext* globalCtx) { + if (this->unk_190 != NULL) { + if (this->actor.params != this->unk_190->unk_3292) { + func_809AB474(this); + } else { + func_809AB428(this); + } + } +} + +void func_809AB428(ObjGrassCarry* this) { + this->actionFunc = func_809AB43C; +} + +void func_809AB43C(ObjGrassCarry* this, GlobalContext* globalCtx) { + if (this->actor.params != this->unk_190->unk_3292) { + func_809AB474(this); + } +} + +void func_809AB474(ObjGrassCarry* this) { + this->actor.shape.rot.z = 0; + this->actionFunc = func_809AB4A8; + this->unk_194 = NULL; + this->actor.shape.rot.y = this->actor.shape.rot.z; + this->actor.shape.rot.x = this->actor.shape.rot.z; + this->actor.world.rot.z = this->actor.shape.rot.z; + this->actor.world.rot.y = this->actor.shape.rot.z; + this->actor.world.rot.x = this->actor.shape.rot.z; +} + +void func_809AB4A8(ObjGrassCarry* this, GlobalContext* globalCtx) { + ObjGrassCarry* this2 = this; + + if (Actor_HasParent(&this->actor, globalCtx)) { + func_809AB5FC(this); + if (this->unk_194 != NULL) { + this->unk_194->unk_0F |= 4; + } + this->actor.draw = func_809ABB7C; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.shape.shadowAlpha = 60; + this->actor.shape.shadowScale = 1.0f; + this->unk_190->unk_3292 ^= 1; + this->actor.room = -1; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_PL_PULL_UP_PLANT); + } else if (this->unk_190->unk_3294 != NULL) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_194 = this->unk_190->unk_3294; + Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_194->unk_00); + this->actor.shape.rot.y = this->actor.world.rot.y = this->unk_194->unk_0C; + this->unk_198 = this2->unk_194->unk_0E; + this->actor.xzDistToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &player->actor); + this->actor.playerHeightRel = Actor_HeightDiff(&this->actor, &player->actor); + this->actor.xyzDistToPlayerSq = SQ(this->actor.xzDistToPlayer) + SQ(this->actor.playerHeightRel); + this->actor.yawTowardsPlayer = Actor_YawBetweenActors(&this->actor, &player->actor); + Actor_LiftActor(&this->actor, globalCtx); + } +} + +void func_809AB5FC(ObjGrassCarry* this) { + this->actionFunc = func_809AB610; +} + +void func_809AB610(ObjGrassCarry* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + s32 sp2C; + + if (Actor_HasNoParent(&this->actor, globalCtx)) { + func_809AB6FC(this); + this->actor.velocity.x = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; + this->actor.velocity.z = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; + this->actor.gravity = -0.1f; + this->actor.terminalVelocity = -17.0f; + func_809AAF18(this); + func_809AAF58(this, globalCtx); + this->actor.gravity = -3.2f; + } else { + sp30.x = this->actor.world.pos.x; + sp30.y = this->actor.world.pos.y + 20.0f; + sp30.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); + } +} + +void func_809AB6FC(ObjGrassCarry* this) { + this->actionFunc = func_809AB77C; + D_809ABBFC = -0xBB8; + D_809ABC04 = (Rand_ZeroOne() - 0.5f) * 1600.0f; + D_809ABC00 = 0; + D_809ABC08 = 0; + this->unk_19A = 60; +} + +void func_809AB77C(ObjGrassCarry* this, GlobalContext* globalCtx) { + s16 phi_s0; + s32 temp_v0 = (this->collider.base.atFlags & AT_HIT) != 0; + Vec3f sp5C; + s32 i; + + if (temp_v0) { + this->collider.base.atFlags &= ~AT_HIT; + } + + this->unk_19A--; + + if ((this->actor.bgCheckFlags & (1 | 2 | 8)) || temp_v0 || (this->unk_19A <= 0)) { + func_809AAFE8(&this->actor.world.pos, globalCtx); + func_809AAF9C(&this->actor.world.pos, this->unk_198, globalCtx); + + this->actor.draw = NULL; + this->actor.shape.shadowDraw = NULL; + + if (this->unk_190 != NULL) { + this->actor.room = this->unk_190->actor.room; + } + + if (!(this->actor.bgCheckFlags & 0x20)) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); + } + func_809AB428(this); + return; + } + + if (this->actor.bgCheckFlags & 0x40) { + sp5C.y = this->actor.world.pos.y + this->actor.depthInWater; + + for (phi_s0 = 0, i = 0; i < 4; i++, phi_s0 += 0x4000) { + sp5C.x = (Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.x; + sp5C.z = (Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp5C, NULL, NULL, 0, 190); + } + + sp5C.x = this->actor.world.pos.x; + sp5C.z = this->actor.world.pos.z; + + EffectSsGSplash_Spawn(globalCtx, &sp5C, NULL, NULL, 0, 280); + EffectSsGRipple_Spawn(globalCtx, &sp5C, 300, 700, 0); + + this->actor.terminalVelocity = -3.0f; + this->actor.velocity.x *= 0.1f; + this->actor.velocity.y *= 0.4f; + this->actor.velocity.z *= 0.1f; + this->actor.gravity *= 0.5f; + + D_809ABC00 = D_809ABC00 >> 1; + D_809ABBFC = D_809ABBFC >> 1; + D_809ABC08 = D_809ABC08 >> 1; + D_809ABC04 = D_809ABC04 >> 1; + this->actor.bgCheckFlags &= ~0x40; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + } + + Math_StepToS(&D_809ABC00, D_809ABBFC, 0x1F4); + Math_StepToS(&D_809ABC08, D_809ABC04, 0xAA); + this->actor.shape.rot.x += D_809ABC00; + this->actor.shape.rot.y += D_809ABC08; + func_809AAF18(this); + func_809AAF58(this, globalCtx); + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjGrassCarry_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjGrassCarry* this = THIS; + + if (this->unk_190 == NULL) { + if ((this->actionFunc != func_809AB610) && (this->actionFunc != func_809AB77C)) { + Actor_MarkForDeath(&this->actor); + return; + } + } + + this->actionFunc(this, globalCtx); +} + +void func_809ABB7C(Actor* this, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); +} diff --git a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h index 5c0f12495..50d2f61f7 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h +++ b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h @@ -4,14 +4,18 @@ #include "global.h" struct ObjGrassCarry; +struct ObjGrass; +struct ObjGrassStruct1_1; typedef void (*ObjGrassCarryActionFunc)(struct ObjGrassCarry*, GlobalContext*); typedef struct ObjGrassCarry { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; - /* 0x0190 */ s32 unk_190; - /* 0x0194 */ char unk_194[0x8]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ struct ObjGrass* unk_190; + /* 0x0194 */ struct ObjGrassStruct1_1* unk_194; + /* 0x0198 */ s16 unk_198; + /* 0x019A */ s16 unk_19A; /* 0x019C */ ObjGrassCarryActionFunc actionFunc; } ObjGrassCarry; // size = 0x1A0 From cbffe83c9b745b5a811ebb956a7a1ed6c5e076d6 Mon Sep 17 00:00:00 2001 From: Isghj <42048411+isghj5@users.noreply.github.com> Date: Tue, 29 Mar 2022 10:21:36 -0700 Subject: [PATCH 156/257] EnWarpTag OK (Warping pedestals in Goron Trial) (#747) * EnWarpTag: OK * Apply suggestions from code review Co-authored-by: Anghelo Carvajal * WarpTag: move macros * WarpTag: format * WarpTag: fix save entrance index Co-authored-by: Isghj8 Co-authored-by: Anghelo Carvajal --- assets/xml/objects/gameplay_dangeon_keep.xml | 12 +- include/functions.h | 2 +- spec | 3 +- .../actors/ovl_En_Warp_tag/z_en_warp_tag.c | 250 ++++++++++++++++-- .../actors/ovl_En_Warp_tag/z_en_warp_tag.h | 22 +- tools/disasm/functions.txt | 14 +- 6 files changed, 265 insertions(+), 38 deletions(-) diff --git a/assets/xml/objects/gameplay_dangeon_keep.xml b/assets/xml/objects/gameplay_dangeon_keep.xml index f3ad6195a..9d5a9901a 100644 --- a/assets/xml/objects/gameplay_dangeon_keep.xml +++ b/assets/xml/objects/gameplay_dangeon_keep.xml @@ -75,15 +75,19 @@ + + - - - - + + + + + + diff --git a/include/functions.h b/include/functions.h index 0e641326d..c4bd9eef7 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3582,7 +3582,7 @@ void Audio_SetCutsceneFlag(u8 flag); // void func_801A3FB4(void); // void func_801A3FFC(UNK_TYPE1 param_1); void audio_setBGM(u32 bgmID); -// void func_801A4058(void); +void func_801A4058(UNK_TYPE arg0); // void func_801A41C8(void); // void func_801A41F8(void); // void func_801A429C(void); diff --git a/spec b/spec index 16fb78b81..66ab043e0 100644 --- a/spec +++ b/spec @@ -2346,8 +2346,7 @@ beginseg name "ovl_En_Warp_tag" compress include "build/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.o" - include "build/data/ovl_En_Warp_tag/ovl_En_Warp_tag.data.o" - include "build/data/ovl_En_Warp_tag/ovl_En_Warp_tag.reloc.o" + include "build/src/overlays/actors/ovl_En_Warp_tag/ovl_En_Warp_tag_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c index ce6367b87..5759b0a9b 100644 --- a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c +++ b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c @@ -2,9 +2,11 @@ * File: z_en_warp_tag.c * Overlay: ovl_En_Warp_tag * Description: Warp to Trial Entrance + * if GoronTrial, has model: Uses GAMEPLAY_DANGEON_KEEP object assigned in EnWarptag_Init */ #include "z_en_warp_tag.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000) @@ -13,15 +15,15 @@ void EnWarptag_Init(Actor* thisx, GlobalContext* globalCtx); void EnWarptag_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWarptag_Update(Actor* thisx, GlobalContext* globalCtx); +void EnWarpTag_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809C085C(EnWarptag* this, GlobalContext* globalCtx); -void func_809C08E0(EnWarptag* this, GlobalContext* globalCtx); -void func_809C09A0(EnWarptag* this, GlobalContext* globalCtx); -void func_809C0A20(EnWarptag* this, GlobalContext* globalCtx); -void func_809C0AB4(EnWarptag* this, GlobalContext* globalCtx); -void func_809C0E30(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_CheckDungeonKeepObject(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_WaitForPlayer(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_Unused809C09A0(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_Unused809C0A20(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_RespawnPlayer(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_GrottoReturn(EnWarptag* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Warp_tag_InitVars = { ACTOR_EN_WARP_TAG, ACTORCAT_ITEMACTION, @@ -34,32 +36,238 @@ const ActorInit En_Warp_tag_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809C1008[] = { +// this appears to be unused, as the code never accesses it in known vanilla cases +// these unknown values get passed to a unknown z_message function +u8 D_809C1000[] = { 0x28, 0x29, 0x2A, 0x2B, 0x2D, 0x2C, 0, 0 }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F(scale, 1, ICHAIN_CONTINUE), ICHAIN_VEC3S(shape.rot, 0, ICHAIN_STOP), }; -#endif +void EnWarptag_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWarptag* this = THIS; -extern InitChainEntry D_809C1008[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_SetFocus(&this->dyna.actor, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/EnWarptag_Init.s") + if (GET_WARPTAG_3C0_MAX(thisx) == WARPTAG_3C0_MAX) { + this->dyna.actor.flags &= ~ACTOR_FLAG_1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/EnWarptag_Destroy.s") + if (GET_WARPTAG_INVISIBLE(&this->dyna.actor)) { + this->actionFunc = EnWarpTag_WaitForPlayer; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C085C.s") + } else { + if ((this->dangeonKeepObject = Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_DANGEON_KEEP)) < 0) { + Actor_MarkForDeath(&this->dyna.actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C08E0.s") + this->actionFunc = EnWarpTag_CheckDungeonKeepObject; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C09A0.s") + } else { // not used by known variants + this->actionFunc = EnWarpTag_Unused809C09A0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C0A20.s") +void EnWarptag_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWarptag* this = THIS; + if (this->dyna.actor.draw != NULL) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C0AB4.s") +/** + * Loads DynaPoly from GAMEPLAY_DANGEON_KEEP. + */ +void EnWarpTag_CheckDungeonKeepObject(EnWarptag* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->dangeonKeepObject)) { + this->actionFunc = EnWarpTag_WaitForPlayer; + DynaPolyActor_Init(&this->dyna, 0x1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gWarpTagGoronTrialBaseCollider); + this->dyna.actor.objBankIndex = this->dangeonKeepObject; + this->dyna.actor.draw = EnWarpTag_Draw; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C0E30.s") +void EnWarpTag_WaitForPlayer(EnWarptag* this, GlobalContext* globalCtx) { + if (!Player_InCsMode(&globalCtx->state) && (this->dyna.actor.xzDistToPlayer <= 30.0f) && + (this->dyna.actor.playerHeightRel <= 10.0f)) { + if (GET_WARPTAG_INVISIBLE(&this->dyna.actor)) { + func_800B7298(globalCtx, NULL, 0x51); + this->actionFunc = EnWarpTag_GrottoReturn; + } else { + func_800B7298(globalCtx, NULL, 0xF); + this->actionFunc = EnWarpTag_RespawnPlayer; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/EnWarptag_Update.s") +/** + * Unused ActionFunc: assigned in EnWarpTag_Init, no known variants use. + */ +void EnWarpTag_Unused809C09A0(EnWarptag* this, GlobalContext* globalCtx) { + if (func_800B8718(&this->dyna.actor, &globalCtx->state)) { + // func above: checks for ACTOR_FLAG_20000000, returns true and resets if set, else return false + // this actor doesnt have that flag set default, or in init, and this is called shortly after init + // and I doubt its set externally by another actor, so I believe this is unused + // might be a bug, they might have meant to set actor flag (0x2000 0000) up above but mistyped (0x200 0000) + // also GET_WARPTAG_3C0 should always return 2C0 -> 0xF for all known in-game uses, which is OOB + func_80152434(globalCtx, D_809C1000[GET_WARPTAG_3C0(&this->dyna.actor)]); // unk message function + this->actionFunc = EnWarpTag_Unused809C0A20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C0F3C.s") + } else { + func_800B8804(&this->dyna.actor, globalCtx, 50.0f); // updates player->unk_A90 + } +} + +/** + * Unused ActionFunc: assigned by EnWarpTag_Unused809C09A0, no known variants use. + */ +void EnWarpTag_Unused809C0A20(EnWarptag* this, GlobalContext* globalCtx) { + if (globalCtx->msgCtx.ocarinaMode == 9) { + func_800B7298(globalCtx, NULL, 7); + this->actionFunc = EnWarpTag_RespawnPlayer; + ActorCutscene_Stop(ActorCutscene_GetCurrentIndex()); + + } else if (globalCtx->msgCtx.ocarinaMode >= 2) { + globalCtx->msgCtx.ocarinaMode = 4; + this->actionFunc = EnWarpTag_Unused809C09A0; + } +} + +/** + * ActionFunc: Goron Trial (Moon), respawn at the beginning of goron rolling track, try again. + */ +void EnWarpTag_RespawnPlayer(EnWarptag* this, GlobalContext* globalCtx) { + ActorEntry* playerActorEntry; + Player* player; + s32 playerSpawnIndex; + s32 new15E; + s32 entranceIndex; + u32 playerSpawnIndexPerForm[PLAYER_FORM_MAX]; + u8 playerForm; + s16 playerParams; + + player = GET_PLAYER(globalCtx); + if (globalCtx->playerActorCsIds[4] >= 0 && ActorCutscene_GetCurrentIndex() != globalCtx->playerActorCsIds[4]) { + if (ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[4]) == 0) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[4]); + + } else { + ActorCutscene_StartAndSetUnkLinkFields(globalCtx->playerActorCsIds[4], &this->dyna.actor); + func_800B8E58(player, NA_SE_PL_WARP_PLATE); + func_8016566C(0); + } + + } else { + f32 diffX = player->actor.world.pos.x - this->dyna.actor.world.pos.x; + Vec3f newRespawnPos; + f32 diffZ = player->actor.world.pos.z - this->dyna.actor.world.pos.z; + f32 distance = sqrtf(SQ(diffX) + SQ(diffZ)); + + // some weird float behavior prevention? + if (distance != 0.0f) { + distance = (distance - 1.0f) / distance; + distance = CLAMP_MIN(distance, 0.0f); + } + + player->actor.world.pos.x = this->dyna.actor.world.pos.x + (diffX * distance); + player->actor.world.pos.z = this->dyna.actor.world.pos.z + (diffZ * distance); + + if (Math_StepToS(&this->unkValue15E, 0x2710, 0xC8)) { + player->stateFlags3 |= 0x1; + player->actor.gravity = -0.5f; + + if (this->dyna.actor.playerHeightRel < -80.0f) { + playerSpawnIndexPerForm[PLAYER_FORM_FIERCE_DEITY] = GET_WARPTAG_EXIT_INDEX(&this->dyna.actor); + playerSpawnIndexPerForm[PLAYER_FORM_HUMAN] = playerSpawnIndexPerForm[PLAYER_FORM_FIERCE_DEITY]; + playerSpawnIndexPerForm[PLAYER_FORM_GORON] = this->dyna.actor.world.rot.x; + playerSpawnIndexPerForm[PLAYER_FORM_ZORA] = this->dyna.actor.world.rot.y; + playerSpawnIndexPerForm[PLAYER_FORM_DEKU] = this->dyna.actor.world.rot.z; + + if (this->dyna.actor.draw != NULL) { + playerForm = PLAYER_BOOTS_FIERCE_DEITY; + } else { + playerForm = player->transformation; + } + + entranceIndex = gSaveContext.save.entranceIndex; + + playerSpawnIndex = playerSpawnIndexPerForm[playerForm]; + playerActorEntry = &globalCtx->linkActorEntry[playerSpawnIndex]; + newRespawnPos.x = playerActorEntry->pos.x; + newRespawnPos.y = playerActorEntry->pos.y; + newRespawnPos.z = playerActorEntry->pos.z; + + if (GET_WARPTAG_3C0_MAX(&this->dyna.actor) == WARPTAG_3C0_MAX) { + playerParams = 0x9FF; + } else { // not used by any known variant + playerParams = 0x8FF; + } + + // why are we getting player home rotation from the room data? doesnt player have home.rot.y? + // especially because we are converting from deg to binang, but isnt home.rot.y already in binang?? + Play_SetRespawnData( + &globalCtx->state, 0, entranceIndex, // parameter 3 is called "sceneSetup" + globalCtx->setupEntranceList[playerSpawnIndex].room, playerParams, &newRespawnPos, + ((((playerActorEntry->rot.y >> 7) & 0x1FF) / 180.0f) * 32768.0f)); // DEG_TO_BINANG ? + + func_80169EFC(&globalCtx->state); + gSaveContext.respawnFlag = ~0x4; + func_80165690(); + } + } + + player->actor.shape.rot.y += this->unkValue15E; + new15E = this->unkValue15E - 0xFA0; + if (new15E < 0) { + new15E = 0; + } + func_80165658(new15E * 0.04f); // unknown Play_ function + } +} + +/** + * ActionFunc: Deku Playground, return to North Clock Town. + */ +void EnWarpTag_GrottoReturn(EnWarptag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() != this->dyna.actor.cutscene) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } + } + + if (this->grottoExitDelay++ == 10) { + globalCtx->nextEntranceIndex = globalCtx->setupExitList[GET_WARPTAG_EXIT_INDEX(&this->dyna.actor)]; + Scene_SetExitFade(globalCtx); + globalCtx->sceneLoadFlag = 0x14; + func_8019F128(NA_SE_OC_SECRET_HOLE_OUT); + func_801A4058(5); + if (1) {} + gSaveContext.seqIndex = 0xFF; + gSaveContext.nightSeqIndex = 0xFF; + } +} + +void EnWarptag_Update(Actor* thisx, GlobalContext* globalCtx) { + EnWarptag* this = THIS; + this->actionFunc(this, globalCtx); +} + +/** + * Only draws for Goron Trial (a rainblow animated target). + */ +void EnWarpTag_Draw(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&gWarpTagRainbowAnimMat)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, gWarpTagGoronTrialBaseDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.h b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.h index 1be6eb5ec..925fda930 100644 --- a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.h +++ b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.h @@ -8,11 +8,27 @@ struct EnWarptag; typedef void (*EnWarptagActionFunc)(struct EnWarptag*, GlobalContext*); typedef struct EnWarptag { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; - /* 0x0160 */ EnWarptagActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s8 dangeonKeepObject; + /* 0x15E */ union { + s16 reusedValue; // default name + s16 unkValue15E; // passed to unk play func, mods player rotation, stepped to 0x2710 + s16 grottoExitDelay; // 10 frame delay before player can leave the grotto + }; + /* 0x160 */ EnWarptagActionFunc actionFunc; } EnWarptag; // size = 0x164 extern const ActorInit En_Warp_tag_InitVars; +// Only two known Variants: +// Goron Trial (MOON): 0x03C1 +// Deku Playground: 0x83C0 + +#define GET_WARPTAG_3C0_MAX(thisx) ((thisx)->params & 0x3C0) +#define GET_WARPTAG_3C0(thisx) (((thisx)->params >> 6) & 0xF) +#define GET_WARPTAG_EXIT_INDEX(thisx) ((thisx)->params & 0x3F) +#define GET_WARPTAG_INVISIBLE(thisx) ((thisx)->params < 0) // 0x8000 flag + +#define WARPTAG_3C0_MAX 0x3C0 + #endif // Z_EN_WARP_TAG_H diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index fd1b38a79..bd06baf02 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -8989,14 +8989,14 @@ 0x809BD858:("func_809BD858",), 0x809C0760:("EnWarptag_Init",), 0x809C0824:("EnWarptag_Destroy",), - 0x809C085C:("func_809C085C",), - 0x809C08E0:("func_809C08E0",), - 0x809C09A0:("func_809C09A0",), - 0x809C0A20:("func_809C0A20",), - 0x809C0AB4:("func_809C0AB4",), - 0x809C0E30:("func_809C0E30",), + 0x809C085C:("EnWarpTag_CheckDungeonKeepObject",), + 0x809C08E0:("EnWarpTag_WaitForPlayer",), + 0x809C09A0:("EnWarpTag_Unused809C09A0",), + 0x809C0A20:("EnWarpTag_Unused809C0A20",), + 0x809C0AB4:("EnWarpTag_RespawnPlayer",), + 0x809C0E30:("EnWarpTag_GrottoReturn",), 0x809C0F18:("EnWarptag_Update",), - 0x809C0F3C:("func_809C0F3C",), + 0x809C0F3C:("EnWarpTag_Draw",), 0x809C10B0:("func_809C10B0",), 0x809C1124:("func_809C1124",), 0x809C1158:("func_809C1158",), From 275f13881b9ec38387b715dd8abb650b54f5998d Mon Sep 17 00:00:00 2001 From: Isghj <42048411+isghj5@users.noreply.github.com> Date: Tue, 29 Mar 2022 10:28:19 -0700 Subject: [PATCH 157/257] `EffectEnIceBlock` OK, `object_ice_block` documented (and minor `Obj_Iceblock` documented) (#748) * EffIceBlock: OK * object_ice_block: documented * EffectIceBlock: matching gfxCtx in the draw function * Iceblock: removed undefined sym Co-authored-by: Isghj8 --- assets/xml/objects/object_ice_block.xml | 35 +++-- spec | 3 +- .../actors/ovl_Obj_Iceblock/z_obj_iceblock.c | 136 +++++++++--------- .../actors/ovl_Obj_Iceblock/z_obj_iceblock.h | 14 +- .../z_eff_en_ice_block.c | 72 ++++++++-- tools/disasm/functions.txt | 6 +- undefined_syms.txt | 4 - 7 files changed, 168 insertions(+), 102 deletions(-) diff --git a/assets/xml/objects/object_ice_block.xml b/assets/xml/objects/object_ice_block.xml index 1e14ea5b5..ba755d100 100644 --- a/assets/xml/objects/object_ice_block.xml +++ b/assets/xml/objects/object_ice_block.xml @@ -1,15 +1,28 @@  - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index 66ab043e0..18d27d612 100644 --- a/spec +++ b/spec @@ -2624,8 +2624,7 @@ beginseg name "ovl_Effect_En_Ice_Block" compress include "build/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.o" - include "build/data/ovl_Effect_En_Ice_Block/ovl_Effect_En_Ice_Block.data.o" - include "build/data/ovl_Effect_En_Ice_Block/ovl_Effect_En_Ice_Block.reloc.o" + include "build/src/overlays/effects/ovl_Effect_En_Ice_Block/ovl_Effect_En_Ice_Block_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c index 28de274f5..582c3a299 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -16,8 +16,8 @@ void ObjIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx); void ObjIceblock_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A257A0(ObjIceblock* this); -void func_80A257B4(ObjIceblock* this, GlobalContext* globalCtx); +void ObjIceBlock_SetupAttemptSpawnCutscene(ObjIceblock* this); +void ObjIceBlock_AttemptSpawnCutscene(ObjIceblock* this, GlobalContext* globalCtx); void func_80A25824(ObjIceblock* this); void func_80A2586C(ObjIceblock* this, GlobalContext* globalCtx); void func_80A25978(ObjIceblock* this); @@ -77,7 +77,7 @@ static ColliderCylinderInit sCylinderInit = { { 44, 62, -31, { 0, 0, 0 } }, }; -static AnimatedMaterial* D_80A26E7C = NULL; +static AnimatedMaterial* sCubeSublimatingAirTexMat = NULL; s16 func_80A23090(s16 arg0, s16 arg1, s16 arg2) { if (arg0 >= 0) { @@ -915,28 +915,29 @@ void ObjIceblock_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.world.rot.z = 0; this->dyna.actor.home.rot.x = 0; this->dyna.actor.home.rot.z = 0; - if (!OBJICEBLOCK_GET_2(&this->dyna.actor)) { + if (!GET_ICEBLOCK_SNAP_ROT(&this->dyna.actor)) { this->dyna.actor.shape.rot.y = (this->dyna.actor.shape.rot.y + 0x2000) & 0xC000; this->dyna.actor.home.rot.y = this->dyna.actor.shape.rot.y; this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y; } DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_ice_block_Colheader_000438); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gIceBlockDynaColHeader); func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->collider.dim.yShift = -100; this->collider.dim.height = 126; this->collider.dim.radius = 29; } - if (D_80A26E7C == NULL) { - D_80A26E7C = Lib_SegmentedToVirtual(object_ice_block_Matanimheader_000328); + if (sCubeSublimatingAirTexMat == NULL) { + sCubeSublimatingAirTexMat = Lib_SegmentedToVirtual(gIceBlockCubeSublimatingAirTexAnim); } + // ... this is init, why would this value be set? if (!(this->unk_1B0 & 8)) { parent = this->dyna.actor.parent; if (parent != NULL) { @@ -948,14 +949,14 @@ void ObjIceblock_Init(Actor* thisx, GlobalContext* globalCtx) { } } - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = -1.0f; } this->unk_2B0 = 0; - this->unkFunc = func_80A26B64; - func_80A257A0(this); - this->unk_2AE = 450; + this->extendedDrawFunc = func_80A26B64; + ObjIceBlock_SetupAttemptSpawnCutscene(this); + this->meltTimer = 450; // (450/20) = 22 seconds } void ObjIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -965,15 +966,15 @@ void ObjIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } -void func_80A257A0(ObjIceblock* this) { - this->actionFunc = func_80A257B4; +void ObjIceBlock_SetupAttemptSpawnCutscene(ObjIceblock* this) { + this->actionFunc = ObjIceBlock_AttemptSpawnCutscene; } -void func_80A257B4(ObjIceblock* this, GlobalContext* globalCtx) { +void ObjIceBlock_AttemptSpawnCutscene(ObjIceblock* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - this->unkFunc = func_80A26BF8; - this->unk_2B1 = 80; + this->extendedDrawFunc = func_80A26BF8; + this->spawnCutsceneTimer = 80; func_80A25824(this); } else { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); @@ -982,7 +983,7 @@ void func_80A257B4(ObjIceblock* this, GlobalContext* globalCtx) { void func_80A25824(ObjIceblock* this) { this->actionFunc = func_80A2586C; - this->unk_2A0 = 2; + this->stateTimer = 2; Actor_SetScale(&this->dyna.actor, 0.01f); func_80A2319C(this, this->dyna.actor.scale.x); } @@ -990,20 +991,20 @@ void func_80A25824(ObjIceblock* this) { void func_80A2586C(ObjIceblock* this, GlobalContext* globalCtx) { func_80A236D4(this, &this->dyna.actor.home.pos); - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; return; } if (Math_StepToF(&this->dyna.actor.scale.x, 0.1f, 0.02f)) { Actor_SetScale(&this->dyna.actor, 0.1f); - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = 0.05f; } func_80A25978(this); } else { Actor_SetScale(&this->dyna.actor, this->dyna.actor.scale.x); - this->unk_2A0 = 2; + this->stateTimer = 2; } func_80A2319C(this, this->dyna.actor.scale.x); @@ -1015,7 +1016,7 @@ void func_80A2586C(ObjIceblock* this, GlobalContext* globalCtx) { void func_80A25978(ObjIceblock* this) { this->actionFunc = func_80A25994; - this->unk_2A0 = 4; + this->stateTimer = 4; } void func_80A25994(ObjIceblock* this, GlobalContext* globalCtx) { @@ -1023,14 +1024,14 @@ void func_80A25994(ObjIceblock* this, GlobalContext* globalCtx) { Vec3f sp30; func_80A236D4(this, &this->dyna.actor.home.pos); - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; return; } if (this->dyna.actor.flags & ACTOR_FLAG_40) { func_80A2339C(globalCtx, &this->dyna.actor.world.pos, this->dyna.actor.scale.x, 1.2f, 15); - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { sp30.x = this->dyna.actor.world.pos.x; sp30.y = this->dyna.actor.world.pos.y - 30.0f; sp30.z = this->dyna.actor.world.pos.z; @@ -1038,17 +1039,17 @@ void func_80A25994(ObjIceblock* this, GlobalContext* globalCtx) { } } - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = 0.1f; } func_80A25A8C(this); - this->unkFunc = func_80A26B74; + this->extendedDrawFunc = func_80A26B74; } void func_80A25A8C(ObjIceblock* this) { this->actionFunc = func_80A25AA8; - this->unk_2A0 = 2; + this->stateTimer = 2; } void func_80A25AA8(ObjIceblock* this, GlobalContext* globalCtx) { @@ -1056,8 +1057,8 @@ void func_80A25AA8(ObjIceblock* this, GlobalContext* globalCtx) { f32 sp24; s32 temp = func_80A236D4(this, &this->dyna.actor.home.pos); - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; return; } @@ -1074,7 +1075,7 @@ void func_80A25AA8(ObjIceblock* this, GlobalContext* globalCtx) { this->dyna.actor.shape.yOffset = 300.0f; this->unk_248.y += sp24; - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->collider.dim.yShift = -69; } else { this->collider.dim.yShift = 0; @@ -1226,7 +1227,7 @@ void func_80A260E8(ObjIceblock* this) { this->unk_260 = D_80A26FC0[this->unk_26C]; this->unk_25C = 0.0f; this->dyna.actor.velocity.y = 0.0f; - this->unk_2A0 = 15; + this->stateTimer = 15; func_80A24DC4(this); this->actionFunc = func_80A26144; } @@ -1237,8 +1238,8 @@ void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { s32 isBool; s32 sp24; - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; } Math_StepToF(&this->unk_25C, this->unk_260, 0.75f); @@ -1248,7 +1249,7 @@ void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { sp24 = func_80A23F90(this, globalCtx); isBool = sp24 == 0; - if (isBool || sp28 || (this->unk_2A0 == 1)) { + if (isBool || sp28 || (this->stateTimer == 1)) { func_80A2541C(this, globalCtx); } @@ -1275,7 +1276,7 @@ void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { void func_80A262BC(ObjIceblock* this) { this->actionFunc = func_80A262EC; this->dyna.actor.velocity.y *= 0.7f; - this->unk_2A0 = -1; + this->stateTimer = -1; } void func_80A262EC(ObjIceblock* this, GlobalContext* globalCtx) { @@ -1289,20 +1290,20 @@ void func_80A262EC(ObjIceblock* this, GlobalContext* globalCtx) { func_80A2541C(this, globalCtx); } - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; } - if (this->unk_2A0 == -1) { + if (this->stateTimer == -1) { if ((this->dyna.actor.velocity.y < 0.0f) && (this->dyna.actor.world.pos.y < this->unk_244) && ((this->unk_244 - (600.0f * this->dyna.actor.scale.y)) <= this->dyna.actor.world.pos.y)) { func_80A24BDC(this, globalCtx, 1.0f, 0.9f, 11); func_80A24B74(this, globalCtx); - this->unk_2A0 = 3; + this->stateTimer = 3; } else { - this->unk_2A0 = 0; + this->stateTimer = 0; } - } else if (this->unk_2A0 == 1) { + } else if (this->stateTimer == 1) { func_80A24BDC(this, globalCtx, 0.7f, 1.3f, 6); func_80A24B74(this, globalCtx); } @@ -1344,7 +1345,7 @@ void func_80A26574(ObjIceblock* this) { this->unk_27C.unk_18 = 500; this->unk_27C.unk_22 = 500; this->unk_27C.unk_08 = 7.0f; - this->unk_2A0 = 40; + this->stateTimer = 40; } void func_80A265C0(ObjIceblock* this, GlobalContext* globalCtx) { @@ -1355,11 +1356,11 @@ void func_80A265C0(ObjIceblock* this, GlobalContext* globalCtx) { func_80A2541C(this, globalCtx); } - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; } else { ptr = &this->unk_27C; - this->unk_2A0 = Rand_S16Offset(30, 60); + this->stateTimer = Rand_S16Offset(30, 60); ptr->unk_0C = Rand_S16Offset(300, 300); ptr->unk_0E = Rand_S16Offset(900, 600); ptr->unk_04 = (2.0f * Rand_ZeroOne()) + 1.0f; @@ -1400,7 +1401,7 @@ void func_80A266E0(ObjIceblock* this, GlobalContext* globalCtx) { actor->scale.z = actor->scale.x; } - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = actor->scale.y; this->collider.dim.height = (s32)(actor->scale.y * 1230.0f) + 1; this->collider.dim.yShift = actor->scale.y * -1000.0f; @@ -1441,14 +1442,14 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { } if ((this->unk_2B0 == 1) || (this->unk_2B0 == 2) || (this->unk_2B0 == 3)) { - if (this->unk_2AE > 0) { - this->unk_2AE--; + if (this->meltTimer > 0) { + this->meltTimer--; } } if (((this->collider.base.acFlags & AC_HIT) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x800)) || - (this->unk_2AE == 0)) { - this->unk_2AE = -1; + (this->meltTimer == 0)) { + this->meltTimer = -1; this->unk_2B0 = 4; this->unk_1B0 &= ~0x100; if (this->unk_1B0 & 1) { @@ -1458,9 +1459,10 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { func_80A266C4(this); } - if (this->unk_2B1 > 0) { - this->unk_2B1--; - if (this->unk_2B1 == 0) { + // this could have been in the actionFunc? + if (this->spawnCutsceneTimer > 0) { + this->spawnCutsceneTimer--; + if (this->spawnCutsceneTimer == 0) { ActorCutscene_Stop(this->dyna.actor.cutscene); } } @@ -1482,7 +1484,7 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { Collider_UpdateCylinder(&this->dyna.actor, &this->collider); if (this->unk_1B0 & 0x10) { - if (OBJICEBLOCK_GET_1(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { this->collider.base.ocFlags1 &= ~OC1_NO_PUSH; this->collider.base.ocFlags1 |= (OC1_TYPE_2 | OC1_TYPE_1 | OC1_TYPE_PLAYER); this->collider.info.bumper.dmgFlags |= @@ -1507,14 +1509,16 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { void func_80A26B64(ObjIceblock* this, GlobalContext* globalCtx) { } +// draw func void func_80A26B74(ObjIceblock* this, GlobalContext* globalCtx) { - Gfx_DrawDListXlu(globalCtx, object_ice_block_DL_0001A0); - if (OBJICEBLOCK_GET_1(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_ice_block_Matanimheader_0009D0)); - Gfx_DrawDListXlu(globalCtx, object_ice_block_DL_0007F0); + Gfx_DrawDListXlu(globalCtx, gIceBlockCubeDL); + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gIceBlockIceBergSublimatingAirTexAnim)); + Gfx_DrawDListXlu(globalCtx, gIceBlockIceBergDL); } } +// draw func void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { s32 pad[2]; ObjIceBlockUnkStruct* ptr; @@ -1535,17 +1539,17 @@ void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { Matrix_Scale(ptr->unk_04, ptr->unk_08, ptr->unk_0C, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ice_block_DL_0001A0); + gSPDisplayList(POLY_XLU_DISP++, gIceBlockCubeDL); } - if (OBJICEBLOCK_GET_1(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_ice_block_Matanimheader_0009D0)); + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gIceBlockIceBergSublimatingAirTexAnim)); Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 20.0f, this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_Scale(this->unk_2B4, this->unk_2B4, this->unk_2B4, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ice_block_DL_0007F0); + gSPDisplayList(POLY_XLU_DISP++, gIceBlockIceBergDL); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -1554,7 +1558,7 @@ void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { void ObjIceblock_Draw(Actor* thisx, GlobalContext* globalCtx) { ObjIceblock* this = THIS; - AnimatedMat_Draw(globalCtx, D_80A26E7C); - this->unkFunc(this, globalCtx); + AnimatedMat_Draw(globalCtx, sCubeSublimatingAirTexMat); + this->extendedDrawFunc(this, globalCtx); func_80A24AA8(this, globalCtx); } diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h index 6a4875bb3..52460b87d 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h @@ -6,10 +6,10 @@ struct ObjIceblock; typedef void (*ObjIceblockActionFunc)(struct ObjIceblock*, GlobalContext*); -typedef void (*ObjIceblockUnkFunc)(struct ObjIceblock*, GlobalContext*); +typedef void (*ObjIceblockExtendedDrawFunc)(struct ObjIceblock*, GlobalContext*); -#define OBJICEBLOCK_GET_2(thisx) (((thisx)->params >> 1) & 1) -#define OBJICEBLOCK_GET_1(thisx) ((thisx)->params & 1) +#define GET_ICEBLOCK_SNAP_ROT(thisx) (((thisx)->params >> 1) & 1) +#define GET_ICEBLOCK_ICEBERG(thisx) ((thisx)->params & 1) typedef struct { /* 0x00 */ s16 unk_00; @@ -51,7 +51,7 @@ typedef struct ObjIceblock { /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ColliderCylinder collider; /* 0x01A8 */ ObjIceblockActionFunc actionFunc; - /* 0x01AC */ ObjIceblockUnkFunc unkFunc; + /* 0x01AC */ ObjIceblockExtendedDrawFunc extendedDrawFunc; /* 0x01B0 */ s32 unk_1B0; /* 0x01B4 */ ObjIceBlockUnkStruct unk_1B4[4]; /* 0x01F4 */ ObjIceBlockUnkStruct2 unk_1F4[5]; @@ -67,14 +67,14 @@ typedef struct ObjIceblock { /* 0x0276 */ s16 unk_276; /* 0x0278 */ s16 unk_278; /* 0x027C */ ObjIceBlockUnkStruct4 unk_27C; - /* 0x02A0 */ s16 unk_2A0; + /* 0x02A0 */ s16 stateTimer; // re-used per-actionFunc /* 0x02A2 */ s16 unk_2A2; /* 0x02A4 */ f32 unk_2A4; /* 0x02A8 */ f32 unk_2A8; /* 0x02AC */ s16 unk_2AC; - /* 0x02AE */ s16 unk_2AE; + /* 0x02AE */ s16 meltTimer; // starts at 450 frames = 22 seconds /* 0x02B0 */ s8 unk_2B0; - /* 0x02B1 */ s8 unk_2B1; + /* 0x02B1 */ s8 spawnCutsceneTimer; /* 0x02B4 */ f32 unk_2B4; } ObjIceblock; // size = 0x2B8 diff --git a/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c b/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c index 62c56c04b..29ac6b18b 100644 --- a/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c +++ b/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c @@ -1,31 +1,85 @@ /* * File: z_eff_en_ice_block.c * Overlay: ovl_Effect_En_Ice_Block - * Description: + * Description: Ice Shard (Pentagon shaped) thrown off of the Obj_Iceblock actor during growth animation + * Object Requirement: OBJECT_ICE_BLOCK */ #include "z_eff_en_ice_block.h" +#include "objects/object_ice_block/object_ice_block.h" #define PARAMS ((EffectEnIceBlockInitParams*)initParamsx) -s32 EffectEnIceBlock_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectEnIceBlock_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectEnIceBlock_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectEnIceBlock_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_En_Ice_Block_InitVars = { EFFECT_EN_ICE_BLOCK, EffectEnIceBlock_Init, }; -#endif +#define rObjId regs[0] +#define rScale regs[1] +#define rRot regs[2] +#define rRotVel regs[3] -extern UNK_TYPE D_06000A38; +u32 EffectEnIceBlock_CheckIceBlockObject(EffectSs* this, GlobalContext* globalCtx) { + if (((this->rObjId = Object_GetIndex(&globalCtx->objectCtx, OBJECT_ICE_BLOCK)) < 0) || + (!Object_IsLoaded(&globalCtx->objectCtx, this->rObjId))) { + this->life = -1; + this->draw = NULL; + return false; + } else { + return true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_En_Ice_Block/func_80A22D40.s") +u32 EffectEnIceBlock_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectEnIceBlockInitParams* params = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_En_Ice_Block/EffectEnIceBlock_Init.s") + Math_Vec3f_Copy(&this->pos, ¶ms->pos); + Math_Vec3f_Copy(&this->velocity, ¶ms->velocity); + Math_Vec3f_Copy(&this->accel, ¶ms->accel); + this->rScale = params->scale; + this->rRot = Rand_ZeroOne() * 65535.0f; + this->rRotVel = (s32)(Rand_ZeroOne() * 512.0f) + 0x400; + this->life = 40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_En_Ice_Block/EffectEnIceBlock_Draw.s") + this->draw = EffectEnIceBlock_Draw; + this->update = EffectEnIceBlock_Update; + EffectEnIceBlock_CheckIceBlockObject(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_En_Ice_Block/EffectEnIceBlock_Update.s") + return 1; +} + +void EffectEnIceBlock_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + s32 pad; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + if (EffectEnIceBlock_CheckIceBlockObject(this, globalCtx)) { + f32 scale = this->rScale * 0.1f * 0.01f; + + OPEN_DISPS(gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x06, + globalCtx->objectCtx.status[this->rObjId].segment); // object: OBJECT_ICE_BLOCK + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->rRot, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, &gIceBlockShardEffectDL); + + CLOSE_DISPS(gfxCtx); + } +} + +void EffectEnIceBlock_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + this->rRot += this->rRotVel; + EffectEnIceBlock_CheckIceBlockObject(this, globalCtx); +} diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index bd06baf02..4c829c84d 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -9925,7 +9925,7 @@ 0x80A227C0:("func_80A227C0",), 0x80A22880:("ObjSkateblock_Update",), 0x80A228D8:("ObjSkateblock_Draw",), - 0x80A22D40:("func_80A22D40",), + 0x80A22D40:("EffectEnIceBlock_CheckIceBlockObject",), 0x80A22DB8:("EffectEnIceBlock_Init",), 0x80A22E94:("EffectEnIceBlock_Draw",), 0x80A22FE4:("EffectEnIceBlock_Update",), @@ -9963,8 +9963,8 @@ 0x80A25440:("func_80A25440",), 0x80A25598:("ObjIceblock_Init",), 0x80A25758:("ObjIceblock_Destroy",), - 0x80A257A0:("func_80A257A0",), - 0x80A257B4:("func_80A257B4",), + 0x80A257A0:("ObjIceBlock_SetupAttemptSpawnCutscene",), + 0x80A257B4:("ObjIceBlock_AttemptSpawnCutscene",), 0x80A25824:("func_80A25824",), 0x80A2586C:("func_80A2586C",), 0x80A25978:("func_80A25978",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 0952a6663..ea2d42b3a 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -942,10 +942,6 @@ D_060057D8 = 0x060057D8; D_060058C8 = 0x060058C8; D_06007238 = 0x06007238; -// ovl_Effect_En_Ice_Block - -D_06000A38 = 0x06000A38; - // ovl_Effect_Ss_D_Fire D_060098A0 = 0x060098A0; From c127a5a0ca24b9dec4e8ec040cd0be74ddbb3d57 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 18:34:18 +0100 Subject: [PATCH 158/257] Elf_Msg6 (#743) * Elf_Msg6 * Elf_Msg6 --- spec | 3 +- src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c | 380 +++++++++++++++++- src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h | 4 + 3 files changed, 368 insertions(+), 19 deletions(-) diff --git a/spec b/spec index 18d27d612..1121c8895 100644 --- a/spec +++ b/spec @@ -4399,8 +4399,7 @@ beginseg name "ovl_Elf_Msg6" compress include "build/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.o" - include "build/data/ovl_Elf_Msg6/ovl_Elf_Msg6.data.o" - include "build/data/ovl_Elf_Msg6/ovl_Elf_Msg6.reloc.o" + include "build/src/overlays/actors/ovl_Elf_Msg6/ovl_Elf_Msg6_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c index e7daab294..68c22f2d1 100644 --- a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c +++ b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c @@ -5,6 +5,7 @@ */ #include "z_elf_msg6.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" #define FLAGS (ACTOR_FLAG_10) @@ -22,7 +23,6 @@ void func_80BA2048(ElfMsg6* this, GlobalContext* globalCtx); void func_80BA215C(ElfMsg6* this, GlobalContext* globalCtx); void func_80BA21C4(ElfMsg6* this, GlobalContext* globalCtx); -#if 0 const ActorInit Elf_Msg6_InitVars = { ACTOR_ELF_MSG6, ACTORCAT_ITEMACTION, @@ -35,34 +35,380 @@ const ActorInit Elf_Msg6_InitVars = { (ActorFunc)NULL, }; -#endif +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA15A0.s") +s32 func_80BA15A0(void) { + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && !(gSaveContext.save.weekEventReg[87] & 0x10)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA165C.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && !(gSaveContext.save.weekEventReg[87] & 0x20)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA16F4.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && !(gSaveContext.save.weekEventReg[87] & 0x40)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/ElfMsg6_Init.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD) && !(gSaveContext.save.weekEventReg[87] & 0x80)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/ElfMsg6_Destroy.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1C00.s") +void func_80BA165C(void) { + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { + gSaveContext.save.weekEventReg[87] |= 0x10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1C88.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) { + gSaveContext.save.weekEventReg[87] |= 0x20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1CF8.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG)) { + gSaveContext.save.weekEventReg[87] |= 0x40; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1E30.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { + gSaveContext.save.weekEventReg[87] |= 0x80; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1F80.s") +s32 func_80BA16F4(ElfMsg6* this, GlobalContext* globalCtx) { + if (!(gSaveContext.save.weekEventReg[31] & 4) && (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { + this->actor.textId = 0x216; + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA2038.s") + if (!func_80BA15A0()) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA2048.s") + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { + this->actor.textId = 0x256; + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA215C.s") + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) { + if (gSaveContext.save.weekEventReg[31] & 1) { + this->actor.textId = 0x257; + } else { + this->actor.textId = 0x231; + } + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA21C4.s") + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG)) { + if (gSaveContext.save.weekEventReg[31] & 2) { + this->actor.textId = 0x258; + } else { + this->actor.textId = 0x232; + } + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/ElfMsg6_Update.s") + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { + if (gSaveContext.save.weekEventReg[80] & 4) { + this->actor.textId = 0x259; + } else { + this->actor.textId = 0x233; + } + return false; + } + + return true; +} + +void ElfMsg6_Init(Actor* thisx, GlobalContext* globalCtx) { + ElfMsg6* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if (ABS_ALT(this->actor.home.rot.x) == 0) { + this->actor.scale.z = 0.4f; + this->actor.scale.x = 0.4f; + } else { + this->actor.scale.x = this->actor.scale.z = ABS_ALT(this->actor.home.rot.x) * 0.04f; + } + + if (this->actor.home.rot.z == 0) { + this->actor.scale.y = 0.4f; + } else { + this->actor.scale.y = this->actor.home.rot.z * 0.04f; + } + + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; + + switch (ELFMSG6_GET_F(&this->actor)) { + case 0: + this->actionFunc = func_80BA1E30; + if (func_80BA16F4(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + + case 1: + this->actionFunc = func_80BA1F80; + if ((this->actor.cutscene == -1) || ((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && + Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)))) { + Actor_MarkForDeath(&this->actor); + return; + } + + switch (ELFMSG6_GET_F0(&this->actor)) { + case 0: + if (gSaveContext.save.inventory.items[ITEM_HOOKSHOT] != ITEM_HOOKSHOT) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + + case 1: + if (gSaveContext.save.weekEventReg[83] & 2) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + } + break; + + case 2: + if (INV_CONTENT(ITEM_OCARINA) == ITEM_OCARINA) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (gSaveContext.save.weekEventReg[8] & 0x40) { + if (gSaveContext.save.weekEventReg[88] & 0x20) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.textId = 0x25B; + } else { + if (!(gSaveContext.save.weekEventReg[74] & 0x20) || (gSaveContext.save.weekEventReg[79] & 0x10)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.textId = 0x224; + } + this->actionFunc = func_80BA1CF8; + break; + + case 3: + if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && + Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor))) || + (gSaveContext.save.weekEventReg[88] & 0x10) || (gSaveContext.save.weekEventReg[91] & 1) || + (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc = func_80BA2048; + this->actor.textId = 0x24D; + break; + + case 4: + this->actionFunc = func_80BA215C; + this->actor.textId = 0x255; + break; + + case 5: + this->actionFunc = func_80BA21C4; + this->actor.textId = 0x25E; + break; + + case 6: + this->actionFunc = func_80BA21C4; + this->actor.textId = 0x25F; + break; + + default: + this->actionFunc = func_80BA2038; + break; + } +} + +void ElfMsg6_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +s32 func_80BA1C00(ElfMsg6* this) { + return (this->actor.xzDistToPlayer < (100.0f * this->actor.scale.x)) && + ((this->actor.playerHeightRel >= 0.0f) && (this->actor.playerHeightRel < (100.0f * this->actor.scale.y))); +} + +void func_80BA1C88(ElfMsg6* this, GlobalContext* globalCtx, s16 arg2) { + Player* player = GET_PLAYER(globalCtx); + EnElf* sp20 = (EnElf*)player->tatlActor; + + if (player->tatlActor != NULL) { + player->tatlTextId = arg2; + ActorCutscene_SetIntentToPlay(0x7C); + sp20->elfMsg = &this->actor; + if (this->actor.cutscene == -1) { + this->actor.cutscene = 0x7C; + } + } +} + +void func_80BA1CF8(ElfMsg6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnElf* sp20 = (EnElf*)player->tatlActor; + + if (player->tatlActor == NULL) { + return; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + switch (this->actor.textId) { + case 0x224: + gSaveContext.save.weekEventReg[79] |= 0x10; + break; + + case 0x25B: + gSaveContext.save.weekEventReg[88] |= 0x20; + break; + } + Actor_MarkForDeath(&this->actor); + return; + } + + if ((this->actor.textId == 0x224) && (gSaveContext.save.weekEventReg[8] & 0x40)) { + this->actor.textId = 0x25B; + } else if (func_80BA1C00(this) && (player->actor.speedXZ > 1.0f)) { + player->tatlTextId = -this->actor.textId; + ActorCutscene_SetIntentToPlay(0x7C); + sp20->elfMsg = &this->actor; + if (this->actor.cutscene == -1) { + this->actor.cutscene = 0x7C; + } + } +} + +void func_80BA1E30(ElfMsg6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnElf* sp20 = (EnElf*)player->tatlActor; + + if (player->tatlActor == NULL) { + return; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + switch (this->actor.textId) { + case 0x216: + gSaveContext.save.weekEventReg[31] |= 4; + break; + + case 0x231: + gSaveContext.save.weekEventReg[31] |= 1; + break; + + case 0x232: + gSaveContext.save.weekEventReg[31] |= 2; + break; + + case 0x233: + gSaveContext.save.weekEventReg[80] |= 4; + break; + } + func_80BA165C(); + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this) && (player->actor.speedXZ > 1.0f)) { + player->tatlTextId = -this->actor.textId; + ActorCutscene_SetIntentToPlay(0x7C); + sp20->elfMsg = &this->actor; + if (this->actor.cutscene == -1) { + this->actor.cutscene = 0x7C; + } + } +} + +void func_80BA1F80(ElfMsg6* this, GlobalContext* globalCtx) { + if (((ELFMSG6_GET_F0(&this->actor)) == 1) && (gSaveContext.save.weekEventReg[83] & 2)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this)) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, NULL); + Flags_SetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)); + Actor_MarkForDeath(&this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} + +void func_80BA2038(ElfMsg6* this, GlobalContext* globalCtx) { +} + +void func_80BA2048(ElfMsg6* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + EnElf* sp20 = (EnElf*)GET_PLAYER(globalCtx)->tatlActor; + + sp20->unk_264 |= 0x20; + if (ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return; + } + + if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor))) || + (gSaveContext.save.weekEventReg[88] & 0x10) || (gSaveContext.save.weekEventReg[91] & 1) || + (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this)) { + func_80BA1C88(this, globalCtx, 0x24D); + } +} + +void func_80BA215C(ElfMsg6* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this)) { + func_80BA1C88(this, globalCtx, -this->actor.textId); + } +} + +void func_80BA21C4(ElfMsg6* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + EnElf* sp20 = (EnElf*)GET_PLAYER(globalCtx)->tatlActor; + + sp20->unk_264 |= 0x20; + if (ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return; + } + + if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor))) || + CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this)) { + func_80BA1C88(this, globalCtx, this->actor.textId); + } +} + +void ElfMsg6_Update(Actor* thisx, GlobalContext* globalCtx) { + ElfMsg6* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h index 05713b146..78f970de0 100644 --- a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h +++ b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h @@ -7,6 +7,10 @@ struct ElfMsg6; typedef void (*ElfMsg6ActionFunc)(struct ElfMsg6*, GlobalContext*); +#define ELFMSG6_GET_F(thisx) ((thisx)->params & 0xF) +#define ELFMSG6_GET_F0(thisx) (((thisx)->params & 0xF0) >> 4) +#define ELFMSG6_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9) + typedef struct ElfMsg6 { /* 0x0000 */ Actor actor; /* 0x0144 */ ElfMsg6ActionFunc actionFunc; From 6132d950e36f9b8638e1d44b8339ed7d1aa027bc Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 18:48:25 +0100 Subject: [PATCH 159/257] En_Light (#744) * En_Light * PR * PR * Format --- spec | 3 +- src/overlays/actors/ovl_En_Light/z_en_light.c | 175 +++++++++++++++++- src/overlays/actors/ovl_En_Light/z_en_light.h | 12 +- 3 files changed, 179 insertions(+), 11 deletions(-) diff --git a/spec b/spec index 1121c8895..397064c1c 100644 --- a/spec +++ b/spec @@ -760,8 +760,7 @@ beginseg name "ovl_En_Light" compress include "build/src/overlays/actors/ovl_En_Light/z_en_light.o" - include "build/data/ovl_En_Light/ovl_En_Light.data.o" - include "build/data/ovl_En_Light/ovl_En_Light.reloc.o" + include "build/src/overlays/actors/ovl_En_Light/ovl_En_Light_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Light/z_en_light.c b/src/overlays/actors/ovl_En_Light/z_en_light.c index fdb2cf123..f815147a2 100644 --- a/src/overlays/actors/ovl_En_Light/z_en_light.c +++ b/src/overlays/actors/ovl_En_Light/z_en_light.c @@ -5,6 +5,7 @@ */ #include "z_en_light.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000000 @@ -15,7 +16,8 @@ void EnLight_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnLight_Update(Actor* thisx, GlobalContext* globalCtx); void EnLight_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80865F38(Actor* thisx, GlobalContext* globalCtx); + const ActorInit En_Light_InitVars = { ACTOR_EN_LIGHT, ACTORCAT_ITEMACTION, @@ -28,16 +30,173 @@ const ActorInit En_Light_InitVars = { (ActorFunc)EnLight_Draw, }; -#endif +typedef struct { + /* 0x00 */ Color_RGBA8 unk_00; + /* 0x04 */ Color_RGB8 unk_04; + /* 0x07 */ u8 unk_07; +} EnLightStruct; // size = 0x8 -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/EnLight_Init.s") +EnLightStruct D_808666D0[] = { + { { 255, 200, 0, 255 }, { 255, 0, 0 }, 75 }, { { 255, 235, 175, 255 }, { 255, 0, 0 }, 75 }, + { { 0, 170, 255, 255 }, { 0, 0, 255 }, 75 }, { { 170, 255, 0, 255 }, { 0, 150, 0 }, 75 }, + { { 255, 200, 0, 255 }, { 255, 0, 0 }, 40 }, { { 255, 200, 0, 255 }, { 255, 0, 0 }, 75 }, + { { 170, 255, 0, 255 }, { 0, 150, 0 }, 75 }, { { 0, 170, 255, 255 }, { 0, 0, 255 }, 75 }, + { { 255, 0, 170, 255 }, { 200, 0, 0 }, 75 }, { { 255, 255, 170, 255 }, { 255, 50, 0 }, 75 }, + { { 255, 255, 170, 255 }, { 255, 255, 0 }, 75 }, { { 255, 255, 170, 255 }, { 100, 255, 0 }, 75 }, + { { 255, 170, 255, 255 }, { 255, 0, 100 }, 75 }, { { 255, 170, 255, 255 }, { 100, 0, 255 }, 75 }, + { { 170, 255, 255, 255 }, { 0, 0, 255 }, 75 }, { { 170, 255, 255, 255 }, { 0, 150, 255 }, 75 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/EnLight_Destroy.s") +void EnLight_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnLight* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/func_80865BF8.s") + if (!ENLIGHT_GET_4000(&this->actor)) { + if ((gSaveContext.gameMode == 3) || ENLIGHT_GET_2000(&this->actor)) { + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, + ((this->actor.params < 0) ? 1 : 40) + (s32)this->actor.world.pos.y, + this->actor.world.pos.z, 255, 255, 180, -1); + } else { + Lights_PointGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, + ((this->actor.params < 0) ? 1 : 40) + (s32)this->actor.world.pos.y, + this->actor.world.pos.z, 255, 255, 180, -1); + } + this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/EnLight_Update.s") + Actor_SetScale(&this->actor, D_808666D0[ENLIGHT_GET_F(&this->actor)].unk_07 * 0.0001f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/func_80865F38.s") + this->unk_144 = (s8)(Rand_ZeroOne() * 255.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/EnLight_Draw.s") + if (ENLIGHT_GET_800(&this->actor)) { + this->actor.update = func_80865F38; + if (ENLIGHT_GET_1000(&this->actor) && Flags_GetSwitch(globalCtx, ENLIGHT_SWITCHFLAG(&this->actor))) { + Actor_SetScale(&this->actor, 0.0f); + } + } else if (ENLIGHT_GET_2000(&this->actor)) { + this->actor.draw = NULL; + } +} + +void EnLight_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnLight* this = THIS; + + if (!ENLIGHT_GET_4000(&this->actor)) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + } +} + +void func_80865BF8(EnLight* this, GlobalContext* globalCtx) { + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + + if (this->actor.parent != NULL) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.parent->world.pos); + this->actor.world.pos.y += 17.0f; + } + + this->unk_144++; +} + +void EnLight_Update(Actor* thisx, GlobalContext* globalCtx) { + EnLight* this = THIS; + + if (!ENLIGHT_GET_4000(&this->actor)) { + EnLightStruct* sp28 = &D_808666D0[ENLIGHT_GET_F(&this->actor)]; + f32 temp_f2 = (Rand_ZeroOne() * 0.5f) + 0.5f; + s32 radius = (this->actor.params < 0) ? 100 : ENLIGHT_GET_2000(&this->actor) ? 730 : 300; + + Lights_PointSetColorAndRadius(&this->lightInfo, (u8)(sp28->unk_00.r * temp_f2), (u8)(sp28->unk_00.g * temp_f2), + (u8)(sp28->unk_00.b * temp_f2), radius); + } + + func_80865BF8(this, globalCtx); + + if ((this->actor.params >= 0) && !ENLIGHT_GET_4000(&this->actor)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); + } +} + +void func_80865F38(Actor* thisx, GlobalContext* globalCtx) { + EnLight* this = THIS; + EnLightStruct* sp38 = &D_808666D0[ENLIGHT_GET_F(&this->actor)]; + f32 temp_f2; + f32 sp30 = this->actor.scale.x / (sp38->unk_07 * 0.0001f); + s32 sp2C = false; + + if (ENLIGHT_GET_1000(&this->actor)) { + if (Flags_GetSwitch(globalCtx, ENLIGHT_SWITCHFLAG(&this->actor))) { + Math_StepToF(&sp30, 1.0f, 0.05f); + sp2C = true; + } else { + if (sp30 < 0.1f) { + Actor_SetScale(&this->actor, 0.0f); + sp30 = 0.0f; + } + Math_StepToF(&sp30, 0.0f, 0.05f); + } + } else if (Flags_GetSwitch(globalCtx, ENLIGHT_SWITCHFLAG(&this->actor))) { + if (sp30 < 0.1f) { + Actor_SetScale(&this->actor, 0.0f); + sp30 = 0.0f; + } + Math_StepToF(&sp30, 0.0f, 0.05f); + } else { + Math_StepToF(&sp30, 1.0f, 0.05f); + sp2C = true; + } + + Actor_SetScale(&this->actor, sp38->unk_07 * 0.0001f * sp30); + + if (!ENLIGHT_GET_4000(&this->actor)) { + temp_f2 = (Rand_ZeroOne() * 0.5f) + 0.5f; + Lights_PointSetColorAndRadius(&this->lightInfo, (u8)(sp38->unk_00.r * temp_f2), (u8)(sp38->unk_00.g * temp_f2), + (u8)(sp38->unk_00.b * temp_f2), 300.0f * sp30); + } + + func_80865BF8(this, globalCtx); + + if ((this->actor.params >= 0) && (sp2C == true)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); + } +} + +void EnLight_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnLight* this = THIS; + EnLightStruct* sp6C = &D_808666D0[ENLIGHT_GET_F(&this->actor)]; + Gfx* sp68; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + if (this->actor.params >= 0) { + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (this->unk_144 * -20) & 0x1FF, + 0x20, 0x80)); + sp68 = gGameplayKeepDrawFlameDL; + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, sp6C->unk_00.r, sp6C->unk_00.g, sp6C->unk_00.b, sp6C->unk_00.a); + gDPSetEnvColor(POLY_XLU_DISP++, sp6C->unk_04.r, sp6C->unk_04.g, sp6C->unk_04.b, 0); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x10, 0x20, 1, (this->unk_144 * 2) & 0x3F, + (this->unk_144 * -6) & 0x7F, 0x10, 0x20)); + sp68 = gameplay_keep_DL_01ACF0; + gDPSetPrimColor(POLY_XLU_DISP++, 0xC0, 0xC0, 255, 200, 0, 0); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + } + + Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y), + MTXMODE_APPLY); + + if (ENLIGHT_GET_1(&this->actor)) { + Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + } + + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sp68); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Light/z_en_light.h b/src/overlays/actors/ovl_En_Light/z_en_light.h index f1aff8de9..b17f55fd7 100644 --- a/src/overlays/actors/ovl_En_Light/z_en_light.h +++ b/src/overlays/actors/ovl_En_Light/z_en_light.h @@ -5,9 +5,19 @@ struct EnLight; +#define ENLIGHT_GET_1(thisx) ((thisx)->params & 1) +#define ENLIGHT_GET_F(thisx) ((thisx)->params & 0xF) +#define ENLIGHT_GET_800(thisx) ((thisx)->params & 0x800) +#define ENLIGHT_SWITCHFLAG(thisx) (((thisx)->params & 0x7F0) >> 4) +#define ENLIGHT_GET_1000(thisx) ((thisx)->params & 0x1000) +#define ENLIGHT_GET_2000(thisx) ((thisx)->params & 0x2000) +#define ENLIGHT_GET_4000(thisx) ((thisx)->params & 0x4000) + typedef struct EnLight { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x18]; + /* 0x144 */ u8 unk_144; + /* 0x148 */ LightNode* lightNode; + /* 0x14C */ LightInfo lightInfo; } EnLight; // size = 0x15C extern const ActorInit En_Light_InitVars; From 72265fac927658187cbb3c7a3a184677bf5f28fa Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 18:56:20 +0100 Subject: [PATCH 160/257] Obj_Entotu (#745) * Obj_Entotu * Time macro * PR * Merge --- assets/xml/overlays/ovl_Obj_Entotu.xml | 7 + include/macros.h | 5 +- spec | 3 +- .../actors/ovl_Obj_Entotu/z_obj_entotu.c | 148 ++++++++++++++++-- .../actors/ovl_Obj_Entotu/z_obj_entotu.h | 6 +- undefined_syms.txt | 5 - 6 files changed, 151 insertions(+), 23 deletions(-) create mode 100644 assets/xml/overlays/ovl_Obj_Entotu.xml diff --git a/assets/xml/overlays/ovl_Obj_Entotu.xml b/assets/xml/overlays/ovl_Obj_Entotu.xml new file mode 100644 index 000000000..e6e6c64cf --- /dev/null +++ b/assets/xml/overlays/ovl_Obj_Entotu.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/include/macros.h b/include/macros.h index 64f084efe..5e9c062c9 100644 --- a/include/macros.h +++ b/include/macros.h @@ -49,14 +49,13 @@ #define CURRENT_DAY (((void)0, gSaveContext.save.day) % 5) -#define TIME_TO_MINUTES(time) (s32)((time) * ((24 * 60) / 0x10000)) #define CLOCK_TIME(hr, min) (s32)(((hr) * 60 + (min)) * 0x10000 / (24 * 60)) #define CLOCK_TIME_MINUTE (CLOCK_TIME(0, 1)) -#define TIME_TO_MINUTES_F(time) ((time) * ((24.0f * 60.0f) / 0x10000)) +#define TIME_TO_MINUTES_F(time) ((time) * ((24.0f * 60.0f) / 0x10000)) // 0.021972656f #define CLOCK_TIME_F(hr, min) (((hr) * 60.0f + (min)) * (0x10000 / (24.0f * 60.0f))) -#define TIME_TO_MINUTES_ALT_F(time) ((time) / (24.0f * 60.0f / 0x10000)) +#define TIME_TO_MINUTES_ALT_F(time) ((time) / (0x10000 / (24.0f * 60.0f))) #define CLOCK_TIME_ALT_F(hr, min) (((hr) * 60.0f + (min)) / (24.0f * 60.0f / 0x10000)) #define SLOT(item) gItemSlots[item] diff --git a/spec b/spec index 397064c1c..515ff2e31 100644 --- a/spec +++ b/spec @@ -2712,8 +2712,7 @@ beginseg name "ovl_Obj_Entotu" compress include "build/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.o" - include "build/data/ovl_Obj_Entotu/ovl_Obj_Entotu.data.o" - include "build/data/ovl_Obj_Entotu/ovl_Obj_Entotu.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Entotu/ovl_Obj_Entotu_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c index 72f0a8015..8ed237927 100644 --- a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c +++ b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c @@ -5,6 +5,7 @@ */ #include "z_obj_entotu.h" +#include "objects/object_f53_obj/object_f53_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +16,6 @@ void ObjEntotu_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjEntotu_Update(Actor* thisx, GlobalContext* globalCtx); void ObjEntotu_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Entotu_InitVars = { ACTOR_OBJ_ENTOTU, ACTORCAT_PROP, @@ -28,23 +28,147 @@ const ActorInit Obj_Entotu_InitVars = { (ActorFunc)ObjEntotu_Draw, }; -#endif +#include "overlays/ovl_Obj_Entotu/ovl_Obj_Entotu.c" -extern UNK_TYPE D_06000158; -extern UNK_TYPE D_06001C00; +s32 func_80A34700(s16 minutes) { + s32 ret = 0; + s16 time = TIME_TO_MINUTES_F(gSaveContext.save.time); + s32 hours = time / 60; + s32 currMinutes = time % 60; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/func_80A34700.s") + if (hours >= 16) { + if ((hours == 16) && (currMinutes < minutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/func_80A349C0.s") + if (hours >= 20) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/func_80A34A44.s") + if ((hours == 19) && (minutes < currMinutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/func_80A34B28.s") + ret = 3; + } else if (hours >= 11) { + if ((hours == 11) && (currMinutes < minutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/ObjEntotu_Init.s") + if (hours >= 14) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/ObjEntotu_Destroy.s") + if ((hours == 13) && (minutes < currMinutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/ObjEntotu_Update.s") + ret = 2; + } else if (hours >= 6) { + if ((hours == 6) && (currMinutes < minutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/ObjEntotu_Draw.s") + if (hours >= 9) { + return 0; + } + + if ((hours == 8) && (minutes < currMinutes)) { + return 0; + } + + ret = 1; + } + return ret; +} + +void func_80A349C0(ObjEntotu* this) { + s32 temp_v0 = func_80A34700(this->unk_1C6); + u8 temp = temp_v0; + s16 temp2 = this->unk_1C4; + + if (temp_v0 != temp2) { + this->unk_1C4 = temp; + this->unk_1C6 = Rand_S16Offset(0, 59); + } + + temp2 = this->unk_1C4; + Math_ApproachF(&this->unk_1B8.x, (temp2 == 0) ? 0.0f : 1.0f, 0.02f, 1000.0f); +} + +void func_80A34A44(ObjEntotu* this, GlobalContext* globalCtx) { + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_f53_obj_DL_000158); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A34B28(ObjEntotu* this, GlobalContext* globalCtx) { + u8 sp57; + u8 sp56; + s32 i; + + this->unk_1B8.y += 1.8f; + this->unk_1B8.z += 0.6f; + sp57 = 0x7F - (u8)this->unk_1B8.y; + sp56 = 0x7F - (u8)this->unk_1B8.z; + + this->unk_1B8.x = CLAMP(this->unk_1B8.x, 0.0f, 1.0f); + + for (i = 0; i < ARRAY_COUNT(ovl_Obj_Entotu_Vtx_000D10); i++) { + this->unk_148[i].v.cn[3] = ovl_Obj_Entotu_Vtx_000D10[i].v.cn[3] * this->unk_1B8.x; + } + + if (this->unk_1B8.x > 0.0f) { + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, sp57, 0x20, 0x20, 1, 0, sp56, 0x20, 0x20)); + gSPSegment(POLY_XLU_DISP++, 0x09, Lib_SegmentedToVirtual(this->unk_148)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_f53_obj_DL_001C00); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void ObjEntotu_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjEntotu* this = THIS; + + Lib_MemCpy(this->unk_148, ovl_Obj_Entotu_Vtx_000D10, sizeof(ovl_Obj_Entotu_Vtx_000D10)); + this->unk_1C6 = Rand_S16Offset(0, 59); + this->unk_1C4 = 0; +} + +void ObjEntotu_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void ObjEntotu_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjEntotu* this = THIS; + + func_80A349C0(this); +} + +void ObjEntotu_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjEntotu* this = THIS; + + func_80A34B28(this, globalCtx); + func_80A34A44(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h index 5d0b3cedd..a00a7fcd4 100644 --- a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h +++ b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h @@ -7,7 +7,11 @@ struct ObjEntotu; typedef struct ObjEntotu { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x84]; + /* 0x144 */ UNK_TYPE1 unk144[4]; + /* 0x148 */ Vtx unk_148[7]; + /* 0x1B8 */ Vec3f unk_1B8; + /* 0x1C4 */ u8 unk_1C4; + /* 0x1C6 */ s16 unk_1C6; } ObjEntotu; // size = 0x1C8 extern const ActorInit Obj_Entotu_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index ea2d42b3a..5b25825ae 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1702,11 +1702,6 @@ D_06000BA0 = 0x06000BA0; D_06003FD0 = 0x06003FD0; D_06004160 = 0x06004160; -// ovl_Obj_Entotu - -D_06000158 = 0x06000158; -D_06001C00 = 0x06001C00; - // ovl_Obj_Hariko D_06000080 = 0x06000080; From 941f3e6949414005b98de69fbf848d8f426fe19f Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Tue, 29 Mar 2022 11:06:19 -0700 Subject: [PATCH 161/257] Document object_aob (Mamamu Yan's object) (#749) --- assets/xml/objects/object_aob.xml | 110 ++++++++++-------- src/code/z_en_hy_code.c | 2 +- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 50 ++++---- .../actors/ovl_En_Aob_01/z_en_aob_01.h | 13 ++- 4 files changed, 94 insertions(+), 81 deletions(-) diff --git a/assets/xml/objects/object_aob.xml b/assets/xml/objects/object_aob.xml index 7c1e2e4ef..3325e9b53 100644 --- a/assets/xml/objects/object_aob.xml +++ b/assets/xml/objects/object_aob.xml @@ -1,53 +1,65 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/code/z_en_hy_code.c b/src/code/z_en_hy_code.c index 915687125..ab42ea622 100644 --- a/src/code/z_en_hy_code.c +++ b/src/code/z_en_hy_code.c @@ -12,7 +12,7 @@ #include "objects/object_os_anime/object_os_anime.h" static AnimationInfoS sAnimations[] = { - { &object_aob_Anim_00007C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gMamamuYanUnusedIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_boj_Anim_001494, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_boj_Anim_001494, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, { &object_boj_Anim_001908, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index 41cb91724..ecbb73400 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -7,7 +7,6 @@ #include "z_en_aob_01.h" #include "overlays/actors/ovl_En_Racedog/z_en_racedog.h" #include "overlays/actors/ovl_En_Dg/z_en_dg.h" -#include "objects/object_aob/object_aob.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) @@ -46,12 +45,12 @@ const ActorInit En_Aob_01_InitVars = { }; static AnimationInfo D_809C3790[6] = { - { &object_aob_Anim_007758, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_aob_Anim_0068B4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &object_aob_Anim_00700C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_aob_Anim_0058EC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &object_aob_Anim_006040, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_aob_Anim_007758, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, + { &gMamamuYanIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gMamamuYanLaughStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gMamamuYanLaughLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gMamamuYanSurpriseStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gMamamuYanSurpriseLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gMamamuYanIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -91,11 +90,11 @@ static EnAobStruct D_809C384C[] = { }; void func_809C10B0(EnAob01* this, s32 arg1) { - if (DECR(this->unk_3F0) == 0) { - this->unk_3EE++; - if (this->unk_3EE >= arg1) { - this->unk_3EE = 0; - this->unk_3F0 = Rand_S16Offset(30, 30); + if (DECR(this->blinkTimer) == 0) { + this->eyeIndex++; + if (this->eyeIndex >= arg1) { + this->eyeIndex = 0; + this->blinkTimer = Rand_S16Offset(30, 30); } } } @@ -925,8 +924,8 @@ void EnAob01_Init(Actor* thisx, GlobalContext* globalCtx) { EnAob01* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_aob_Skel_000180, NULL, this->jointTable, this->morphTable, - 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gMamamuYanSkel, NULL, this->jointTable, this->morphTable, + MAMAMU_YAN_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->unk_43C = 0; @@ -982,35 +981,36 @@ void EnAob01_Update(Actor* thisx, GlobalContext* globalCtx) { s32 EnAob01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnAob01* this = THIS; - TexturePtr sp38[] = { - object_aob_Tex_000658, - object_aob_Tex_000E58, - object_aob_Tex_001658, + TexturePtr eyeTextures[] = { + gMamamuYanEyeOpenTex, + gMamamuYanEyeHalfTex, + gMamamuYanEyeClosedTex, }; - if (limbIndex == 15) { + if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { OPEN_DISPS(globalCtx->state.gfxCtx); - *dList = object_aob_DL_003D18; + *dList = gMamamuYanHeadDL; - gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(sp38[this->unk_3EE])); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(eyeTextures[this->eyeIndex])); CLOSE_DISPS(globalCtx->state.gfxCtx); } - if (limbIndex == 15) { + if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_InsertXRotation_s(this->unk_2DA.y, MTXMODE_APPLY); Matrix_InsertZRotation_s(this->unk_2DA.x * -1, MTXMODE_APPLY); Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } - if (limbIndex == 8) { + if (limbIndex == MAMAMU_YAN_LIMB_TORSO) { Matrix_InsertXRotation_s(this->unk_2E0.y * -1, MTXMODE_APPLY); Matrix_InsertZRotation_s(this->unk_2E0.x * -1, MTXMODE_APPLY); } - if ((limbIndex == 8) || (limbIndex == 9) || (limbIndex == 12)) { + if ((limbIndex == MAMAMU_YAN_LIMB_TORSO) || (limbIndex == MAMAMU_YAN_LIMB_LEFT_UPPER_ARM) || + (limbIndex == MAMAMU_YAN_LIMB_RIGHT_UPPER_ARM)) { rot->y += (s16)Math_SinS(this->unk_2F8[limbIndex]) * 200; rot->z += (s16)Math_CosS(this->unk_318[limbIndex]) * 200; } @@ -1021,7 +1021,7 @@ void EnAob01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, static Vec3f D_809C3968 = { 0.0f, 0.0f, 0.0f }; EnAob01* this = THIS; - if (limbIndex == 15) { + if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { Matrix_MultiplyVector3fByState(&D_809C3968, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h index be7655fad..69e15f658 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h @@ -2,6 +2,7 @@ #define Z_EN_AOB_01_H #include "global.h" +#include "objects/object_aob/object_aob.h" struct EnAob01; @@ -17,8 +18,8 @@ typedef struct EnAob01 { /* 0x18C */ ColliderCylinder collider; /* 0x1D8 */ Path* unk_1D8[14]; /* 0x210 */ u16 unk_210; - /* 0x212 */ Vec3s jointTable[16]; - /* 0x272 */ Vec3s morphTable[16]; + /* 0x212 */ Vec3s jointTable[MAMAMU_YAN_LIMB_MAX]; + /* 0x272 */ Vec3s morphTable[MAMAMU_YAN_LIMB_MAX]; /* 0x2D2 */ u16 unk_2D2; /* 0x2D4 */ Vec3s unk_2D4; /* 0x2DA */ Vec3s unk_2DA; @@ -26,11 +27,11 @@ typedef struct EnAob01 { /* 0x2E6 */ Vec3s unk_2E6; /* 0x2EC */ Vec3s unk_2EC; /* 0x2F2 */ Vec3s unk_2F2; - /* 0x2F8 */ s16 unk_2F8[16]; - /* 0x318 */ s16 unk_318[16]; + /* 0x2F8 */ s16 unk_2F8[MAMAMU_YAN_LIMB_MAX]; + /* 0x318 */ s16 unk_318[MAMAMU_YAN_LIMB_MAX]; /* 0x338 */ UNK_TYPE1 unk338[0xB6]; - /* 0x3EE */ s16 unk_3EE; - /* 0x3F0 */ s16 unk_3F0; + /* 0x3EE */ s16 eyeIndex; + /* 0x3F0 */ s16 blinkTimer; /* 0x3F4 */ Actor* unk_3F4; /* 0x3F8 */ Actor* unk_3F8[14]; /* 0x430 */ s16 unk_430; From afec1c56a62d2d451e4ab00a1e5da5a14cf6a9c0 Mon Sep 17 00:00:00 2001 From: LtPeriwinkle <62761190+LtPeriwinkle@users.noreply.github.com> Date: Tue, 29 Mar 2022 11:12:35 -0700 Subject: [PATCH 162/257] EnNeoReeba OK and documented, object_rb mostly doc'd (#750) * match some functions * finish decompiling * mostly document except some dmgeffs * Document object_rb * update functions.txt, damagetable * remove number comments * suggestions * format and fix enum names * comment object_rb.xml --- assets/xml/objects/object_rb.xml | 67 +- spec | 3 +- .../actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c | 755 ++++++++++++++++-- .../actors/ovl_En_Neo_Reeba/z_en_neo_reeba.h | 25 +- tools/disasm/functions.txt | 58 +- 5 files changed, 768 insertions(+), 140 deletions(-) diff --git a/assets/xml/objects/object_rb.xml b/assets/xml/objects/object_rb.xml index a344c5327..72b3e6cb6 100644 --- a/assets/xml/objects/object_rb.xml +++ b/assets/xml/objects/object_rb.xml @@ -1,44 +1,53 @@  + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + diff --git a/spec b/spec index 515ff2e31..45da21f4f 100644 --- a/spec +++ b/spec @@ -4188,8 +4188,7 @@ beginseg name "ovl_En_Neo_Reeba" compress include "build/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.o" - include "build/data/ovl_En_Neo_Reeba/ovl_En_Neo_Reeba.data.o" - include "build/data/ovl_En_Neo_Reeba/ovl_En_Neo_Reeba.reloc.o" + include "build/src/overlays/actors/ovl_En_Neo_Reeba/ovl_En_Neo_Reeba_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c index 5e288df38..591d4ddcb 100644 --- a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c +++ b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c @@ -5,6 +5,7 @@ */ #include "z_en_neo_reeba.h" +#include "objects/object_rb/object_rb.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200) @@ -15,7 +16,26 @@ void EnNeoReeba_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnNeoReeba_Update(Actor* thisx, GlobalContext* globalCtx); void EnNeoReeba_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnNeoReeba_SetupWaitUnderground(EnNeoReeba* this); +void EnNeoReeba_WaitUnderground(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_ChooseAction(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupSink(EnNeoReeba* this); +void EnNeoReeba_Sink(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupRise(EnNeoReeba* this); +void EnNeoReeba_RiseOutOfGround(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupMove(EnNeoReeba* this); +void EnNeoReeba_Move(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupReturnHome(EnNeoReeba* this); +void EnNeoReeba_ReturnHome(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_Bounce(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_Stunned(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_Frozen(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupDamageAnim(EnNeoReeba* this); +void EnNeoReeba_DamageAnim(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupDeathEffects(EnNeoReeba* this); +void EnNeoReeba_PlayDeathEffects(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SpawnIce(EnNeoReeba* this, GlobalContext* globalCtx); + const ActorInit En_Neo_Reeba_InitVars = { ACTOR_EN_NEO_REEBA, ACTORCAT_ENEMY, @@ -28,118 +48,701 @@ const ActorInit En_Neo_Reeba_InitVars = { (ActorFunc)EnNeoReeba_Draw, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B7E500 = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(1, 0xE), - /* Horse trample */ DMG_ENTRY(1, 0xF), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(1, 0xE), - /* Normal arrow */ DMG_ENTRY(1, 0xE), - /* UNK_DMG_0x06 */ DMG_ENTRY(1, 0xF), - /* Hookshot */ DMG_ENTRY(0, 0xC), - /* Goron punch */ DMG_ENTRY(1, 0xF), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(1, 0xF), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(1, 0xE), - /* Deku launch */ DMG_ENTRY(2, 0xF), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0xD), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0xF), - /* Zora punch */ DMG_ENTRY(1, 0xF), - /* Spin attack */ DMG_ENTRY(1, 0xF), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0xF), +typedef enum { + /* 0x0 */ EN_NEO_REEBA_DMGEFF_IMMUNE, // No effect on the leever + /* 0x1 */ EN_NEO_REEBA_DMGEFF_STUN, // Turns blue, frozen in place + /* 0x2 */ EN_NEO_REEBA_DMGEFF_FIRE, + /* 0x3 */ EN_NEO_REEBA_DMGEFF_FREEZE, // Ice effects, frozen in place + /* 0x4 */ EN_NEO_REEBA_DMGEFF_LIGHT, + /* 0xC */ EN_NEO_REEBA_DMGEFF_HOOKSHOT = 0xC, // No damage, used only for hookshot + /* 0xD */ EN_NEO_REEBA_DMGEFF_ELECTRIC_STUN, // Electric effects, frozen in place + /* 0xE */ EN_NEO_REEBA_DMGEFF_NONE, // Normal hit + /* 0xF */ EN_NEO_REEBA_DMGEFF_SHATTER, // Normal hit that can break ice if leever is frozen +} EnNeoReebaDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Deku Stick */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Explosives */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Zora boomerang */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Hookshot */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Sword */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Goron pound */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Fire arrow */ DMG_ENTRY(2, EN_NEO_REEBA_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, EN_NEO_REEBA_DMGEFF_FREEZE), + /* Light arrow */ DMG_ENTRY(2, EN_NEO_REEBA_DMGEFF_LIGHT), + /* Goron spikes */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Deku spin */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_NEO_REEBA_DMGEFF_SHATTER), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Zora barrier */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_ELECTRIC_STUN), + /* Normal shield */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Light ray */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Thrown object */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Zora punch */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Spin attack */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Sword beam */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Normal Roll */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Unblockable */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Powder Keg */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B7E520 = { - { COLTYPE_HIT5, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x08, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT5, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x08, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 18, 30, 0, { 0, 0, 0 } }, }; -#endif +void EnNeoReeba_Init(Actor* thisx, GlobalContext* globalCtx) { + EnNeoReeba* this = THIS; -extern DamageTable D_80B7E500; -extern ColliderCylinderInit D_80B7E520; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gLeeverSkel, &gLeeverSpinAnim, this->jointTable, this->morphTable, + LEEVER_LIMB_MAX); -extern UNK_TYPE D_060001E4; + if (!EN_NEO_REEBA_IS_LARGE(&this->actor)) { + Actor_SetScale(&this->actor, 0.04f); + this->actor.colChkInfo.mass = 90; + this->actor.colChkInfo.health = 1; + } else { + Actor_SetScale(&this->actor, 0.05f); + this->actor.colChkInfo.mass = 180; + this->actor.colChkInfo.health = 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/EnNeoReeba_Init.s") + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.targetMode = 2; + this->actor.hintId = 0x47; + this->actor.gravity = -0.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/EnNeoReeba_Destroy.s") + this->targetPos = gZeroVec3f; + this->velToTarget = gZeroVec3f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CA34.s") + this->rotationAngle = 0; + this->sfxTimer = 0; + this->stunTimer = 0; + this->actionTimer = 0; + this->sinkRiseRate = 0.0f; + this->rotationSpeed = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CA70.s") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CB3C.s") + EnNeoReeba_SetupWaitUnderground(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CB88.s") +void EnNeoReeba_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnNeoReeba* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CCE0.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CD28.s") +void EnNeoReeba_SetupWaitUnderground(EnNeoReeba* this) { + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.draw = NULL; + this->actionTimer = 10; + this->actionFunc = EnNeoReeba_WaitUnderground; + this->actor.shape.yOffset = -2000.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CE34.s") +void EnNeoReeba_WaitUnderground(EnNeoReeba* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CE94.s") + if ((Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos) < 200.0f) && + (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && (fabsf(this->actor.playerHeightRel) < 100.0f)) { + EnNeoReeba_SetupRise(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CFA0.s") + if (this->actionTimer == 0) { + this->actor.world.pos = this->actor.home.pos; + this->actionTimer = -1; + } else { + this->actionTimer--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CFFC.s") +void EnNeoReeba_SetupChooseAction(EnNeoReeba* this) { + this->actor.shape.yOffset = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D130.s") + if (this->actionFunc == EnNeoReeba_Move) { + this->actionTimer = 20; + } else { + this->actionTimer = 10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D150.s") + this->actionFunc = EnNeoReeba_ChooseAction; + this->skelAnime.playSpeed = 1.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D254.s") +void EnNeoReeba_ChooseAction(EnNeoReeba* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 distToPlayer = Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D2E4.s") + if ((distToPlayer > 200.0f) || (fabsf(this->actor.playerHeightRel) > 100.0f)) { + EnNeoReeba_SetupSink(this); + } else { + if (this->actionTimer == 0) { + if ((distToPlayer < 140.0f) && (fabsf(this->actor.playerHeightRel) < 100.0f)) { + this->targetPos = player->actor.world.pos; + this->targetPos.x += 10.0f * player->actor.speedXZ * Math_SinS(player->actor.world.rot.y); + this->targetPos.z += 10.0f * player->actor.speedXZ * Math_CosS(player->actor.world.rot.y); + EnNeoReeba_SetupMove(this); + } else { + EnNeoReeba_SetupReturnHome(this); + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D360.s") + if (this->actionTimer != 0) { + this->actionTimer--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D398.s") +void EnNeoReeba_SetupSink(EnNeoReeba* this) { + this->sinkRiseRate = 0.0f; + this->skelAnime.playSpeed = 2.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + this->actionFunc = EnNeoReeba_Sink; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D3EC.s") +void EnNeoReeba_Sink(EnNeoReeba* this, GlobalContext* globalCtx) { + if (Math_SmoothStepToF(&this->actor.shape.yOffset, -2000.0f, 0.5f, this->sinkRiseRate, 10.0f) == 0.0f) { + EnNeoReeba_SetupWaitUnderground(this); + } else if (globalCtx->gameplayFrames % 4 == 0) { + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, + 8.0f, 500, 10, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D47C.s") + if (this->sinkRiseRate < 300.0f) { + this->sinkRiseRate += 20.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D4FC.s") + Math_ApproachF(&this->actor.shape.shadowScale, 0.0f, 1.0f, 1.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D5A4.s") +void EnNeoReeba_SetupRise(EnNeoReeba* this) { + this->actor.draw = EnNeoReeba_Draw; + this->sinkRiseRate = 300.0f; + this->skelAnime.playSpeed = 2.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_APPEAR); + this->actor.flags |= ACTOR_FLAG_1; + this->actionFunc = EnNeoReeba_RiseOutOfGround; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D6D0.s") +void EnNeoReeba_RiseOutOfGround(EnNeoReeba* this, GlobalContext* globalCtx) { + if (Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 0.5f, this->sinkRiseRate, 10.0f) == 0.0f) { + EnNeoReeba_SetupChooseAction(this); + } else if (globalCtx->gameplayFrames % 4 == 0) { + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, + 8.0f, 500, 10, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D788.s") + if (this->sinkRiseRate > 20.0f) { + this->sinkRiseRate -= 10.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D9B8.s") + Math_ApproachF(&this->actor.shape.shadowScale, 12.0f, 1.0f, 1.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7DC80.s") +void EnNeoReeba_SetupMove(EnNeoReeba* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIVA_MOVE); + this->sfxTimer = 10; + this->actionTimer = 60; + this->actionFunc = EnNeoReeba_Move; + this->skelAnime.playSpeed = 2.0f; + this->actor.speedXZ = 14.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7DD7C.s") +void EnNeoReeba_Move(EnNeoReeba* this, GlobalContext* globalCtx) { + f32 remainingDist = Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->targetPos, this->actor.speedXZ); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7DF34.s") + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, 4.0f, + 0xFA, 0xA, 1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7E0BC.s") + if (remainingDist < 2.0f) { + EnNeoReeba_SetupChooseAction(this); + } else if (remainingDist < 40.0f && this->actor.speedXZ > 3.0f) { + this->actor.speedXZ -= 2.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7E260.s") + if (this->sfxTimer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIVA_MOVE); + this->sfxTimer = 10; + } else { + this->sfxTimer--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/EnNeoReeba_Update.s") + if (this->actionTimer == 0) { + EnNeoReeba_SetupChooseAction(this); + } else { + this->actionTimer--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7E378.s") +void EnNeoReeba_SetupReturnHome(EnNeoReeba* this) { + this->actionFunc = EnNeoReeba_ReturnHome; + this->actor.speedXZ = 6.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/EnNeoReeba_Draw.s") +void EnNeoReeba_ReturnHome(EnNeoReeba* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + f32 remainingDist = Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->actor.home.pos, this->actor.speedXZ); + + if (remainingDist < 2.0f) { + EnNeoReeba_SetupChooseAction(this); + } else if (remainingDist < 40.0f && this->actor.speedXZ > 3.0f) { + this->actor.speedXZ -= 1.0f; + } + + if (Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos) > 200.0f || + fabsf(this->actor.playerHeightRel) > 100.0f) { + EnNeoReeba_SetupSink(this); + } +} + +void EnNeoReeba_SetupBounce(EnNeoReeba* this) { + this->actionTimer = 60; + this->targetPos = this->actor.world.pos; + this->targetPos.x -= 20.0f * Math_SinS(this->actor.yawTowardsPlayer); + this->targetPos.z -= 20.0f * Math_CosS(this->actor.yawTowardsPlayer); + this->actionFunc = EnNeoReeba_Bounce; +} + +void EnNeoReeba_Bounce(EnNeoReeba* this, GlobalContext* globalCtx) { + if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->targetPos, this->actor.speedXZ) < 2.0f) { + EnNeoReeba_SetupChooseAction(this); + } + + if (this->actionTimer == 0) { + EnNeoReeba_SetupChooseAction(this); + } else { + this->actionTimer--; + } +} + +void EnNeoReeba_SetupStun(EnNeoReeba* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->actionFunc = EnNeoReeba_Stunned; +} + +void EnNeoReeba_Stunned(EnNeoReeba* this, GlobalContext* globalCtx) { + if (this->stunTimer > 0) { + this->stunTimer--; + } else { + this->drawEffectAlpha = 0.0f; + this->drawEffectScale = 0.0f; + } + + if (this->actor.colorFilterTimer == 0) { + this->stunTimer = 0; + EnNeoReeba_SetupChooseAction(this); + } +} + +void EnNeoReeba_SetupFrozen(EnNeoReeba* this) { + this->drawEffectType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawEffectScale = 0.5f; + this->drawEffectAlpha = 1.0f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + this->drawEffectScale *= 1.5f; + } + + if (this->actor.colChkInfo.health != 0) { + this->stunTimer = 80; + } else { + this->stunTimer = 12; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->actionFunc = EnNeoReeba_Frozen; +} + +void EnNeoReeba_Frozen(EnNeoReeba* this, GlobalContext* globalCtx) { + if (this->stunTimer == 0) { + this->stunTimer = 0; + this->drawEffectScale = 0.0f; + this->drawEffectAlpha = 0.0f; + + if (this->actor.colChkInfo.health != 0) { + EnNeoReeba_SetupDamageAnim(this); + } else { + EnNeoReeba_SetupDeathEffects(this); + } + } else if (this->stunTimer == 1) { + this->stunTimer--; + EnNeoReeba_SpawnIce(this, globalCtx); + } else { + this->stunTimer--; + } +} + +void EnNeoReeba_SetupDamageAnim(EnNeoReeba* this) { + this->actionTimer = 10; + this->skelAnime.playSpeed = 1.0f; + this->velToTarget.x = Math_SinS(this->actor.yawTowardsPlayer) * -12.0f; + this->velToTarget.z = Math_CosS(this->actor.yawTowardsPlayer) * -12.0f; + this->rotationSpeed = 4551.0f; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIVA_DAMAGE); + this->actionFunc = EnNeoReeba_DamageAnim; +} + +static f32 sDamageAnimXZScales[] = { 0.04, 0.04, 0.039, 0.042, 0.045, 0.043, 0.04, 0.035, 0.03, 0.033, 0.04 }; +static f32 sDamageAnimYScales[] = { 0.04f, 0.04f, 0.041f, 0.038f, 0.035f, 0.037f, 0.04f, 0.045f, 0.05f, 0.047f, 0.04f }; + +void EnNeoReeba_DamageAnim(EnNeoReeba* this, GlobalContext* globalCtx) { + if (this->actionTimer == 0) { + this->rotationSpeed = 0.0f; + EnNeoReeba_SetupChooseAction(this); + } else { + this->rotationAngle -= 0x1F40; + Math_SmoothStepToF(&this->rotationSpeed, 0.0f, 0.5f, 182.0f, 18.0f); + this->actor.scale.x = this->actor.scale.z = sDamageAnimXZScales[this->actionTimer]; + this->actor.scale.y = sDamageAnimYScales[this->actionTimer]; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + this->actor.scale.x *= 1.5f; + this->actor.scale.y *= 1.5f; + this->actor.scale.z *= 1.5f; + } + + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, + 4.0f, 250, 10, 1); + this->actionTimer--; + } +} + +void EnNeoReeba_SetupDeathEffects(EnNeoReeba* this) { + this->actionTimer = 10; + + this->velToTarget.x = Math_SinS(this->actor.yawTowardsPlayer) * -12.0f; + this->velToTarget.z = Math_CosS(this->actor.yawTowardsPlayer) * -12.0f; + + this->rotationSpeed = 3640.0f; + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 25); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIVA_DEAD); + this->actionFunc = EnNeoReeba_PlayDeathEffects; +} + +void EnNeoReeba_PlayDeathEffects(EnNeoReeba* this, GlobalContext* globalCtx) { + static Vec3f sDeadDbVel = { 0.0f, 0.0f, 0.0f }; + static Vec3f sDeadDbAccel = { 0.0f, 4.0f, 0.0f }; + + if (this->actionTimer == 0) { + Math_ApproachZeroF(&this->actor.scale.x, 0.1f, 0.01f); + Math_ApproachZeroF(&this->actor.scale.y, 0.1f, 0.01f); + Math_ApproachZeroF(&this->actor.scale.z, 0.1f, 0.01f); + Math_ApproachZeroF(&this->drawEffectAlpha, 0.1f, 0.1f); + Math_ApproachZeroF(&this->drawEffectScale, 0.1f, 0.1f); + + if (this->actor.scale.x < 0.01f) { + func_800B3030(globalCtx, &this->actor.world.pos, &sDeadDbAccel, &sDeadDbVel, 120, 0, 0); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + Actor_MarkForDeath(&this->actor); + } + } else { + if (this->actionTimer <= 10) { + this->rotationAngle -= 0x1388; + this->actor.scale.x = this->actor.scale.z = sDamageAnimXZScales[this->actionTimer]; + this->actor.scale.y = sDamageAnimYScales[this->actionTimer]; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + this->actor.scale.x *= 1.5f; + this->actor.scale.y *= 1.5f; + this->actor.scale.z *= 1.5f; + } + } + + if (this->drawEffectType == ACTOR_DRAW_DMGEFF_FIRE) { + f32 target = 1.2f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + target *= 1.5f; + } + + Math_SmoothStepToF(&this->drawEffectScale, target, 0.5f, 0.3f, 0.0f); + } else { + f32 target = 1.6f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + target *= 1.5f; + } + + Math_SmoothStepToF(&this->drawEffectScale, target, 0.5f, 0.3f, 0.0f); + } + this->actionTimer--; + } +} + +void EnNeoReeba_HandleHit(EnNeoReeba* this, GlobalContext* globalCtx) { + Actor_SetFocus(&this->actor, 20.0f); + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + + if (this->actionFunc == EnNeoReeba_Frozen) { + switch (this->actor.colChkInfo.damageEffect) { + case EN_NEO_REEBA_DMGEFF_STUN: + case EN_NEO_REEBA_DMGEFF_FREEZE: + case EN_NEO_REEBA_DMGEFF_LIGHT: + case EN_NEO_REEBA_DMGEFF_ELECTRIC_STUN: + case EN_NEO_REEBA_DMGEFF_NONE: + return; + default: + if (this->stunTimer >= 2) { + EnNeoReeba_SpawnIce(this, globalCtx); + } + this->stunTimer = 0; + } + } + + Actor_ApplyDamage(&this->actor); + + switch (this->actor.colChkInfo.damageEffect) { + case EN_NEO_REEBA_DMGEFF_FREEZE: + EnNeoReeba_SetupFrozen(this); + break; + + case EN_NEO_REEBA_DMGEFF_FIRE: + case EN_NEO_REEBA_DMGEFF_LIGHT: + if (this->actor.colChkInfo.damageEffect == EN_NEO_REEBA_DMGEFF_FIRE) { + this->drawEffectType = ACTOR_DRAW_DMGEFF_FIRE; + this->stunTimer = 80; + } else { + this->drawEffectType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->stunTimer = 40; + } + this->drawEffectAlpha = 1.0f; + this->drawEffectScale = 0.0f; + /* fallthrough */ + case EN_NEO_REEBA_DMGEFF_NONE: + case EN_NEO_REEBA_DMGEFF_SHATTER: + if ((this->actor.colChkInfo.damageEffect == EN_NEO_REEBA_DMGEFF_SHATTER) || + (this->actor.colChkInfo.damageEffect == EN_NEO_REEBA_DMGEFF_NONE)) { + this->stunTimer = 0; + } + if (this->actor.colChkInfo.health > 0) { + EnNeoReeba_SetupDamageAnim(this); + } else { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + EnNeoReeba_SetupDeathEffects(this); + } + break; + + case EN_NEO_REEBA_DMGEFF_ELECTRIC_STUN: + this->drawEffectType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->stunTimer = 40; + this->drawEffectAlpha = 1.0f; + this->drawEffectScale = 2.0f; + Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); + EnNeoReeba_SetupStun(this); + break; + + case EN_NEO_REEBA_DMGEFF_STUN: + Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); + EnNeoReeba_SetupStun(this); + break; + } + } else { + if (((this->collider.base.ocFlags2 & OC2_HIT_PLAYER) || (this->collider.base.atFlags & AT_BOUNCED)) && + (this->actionFunc == EnNeoReeba_Move)) { + EnNeoReeba_SetupBounce(this); + } + } + if ((this->actionFunc != EnNeoReeba_WaitUnderground) && (this->actionFunc != EnNeoReeba_Sink) && + (this->actionFunc != EnNeoReeba_RiseOutOfGround) && (this->actionFunc != EnNeoReeba_DamageAnim) && + (this->actionFunc != EnNeoReeba_PlayDeathEffects)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->actionFunc != EnNeoReeba_Stunned) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void EnNeoReeba_UpdatePosition(EnNeoReeba* this, GlobalContext* globalCtx) { + if ((this->actionFunc != EnNeoReeba_WaitUnderground) && (this->actionFunc != EnNeoReeba_Sink) && + (this->actionFunc != EnNeoReeba_RiseOutOfGround)) { + this->actor.velocity.y += this->actor.gravity; + + this->actor.world.pos.y += this->actor.velocity.y; + this->actor.world.pos.x += this->actor.colChkInfo.displacement.x; + this->actor.world.pos.z += this->actor.colChkInfo.displacement.z; + + this->actor.world.pos.x += this->velToTarget.x; + this->actor.world.pos.z += this->velToTarget.z; + + Math_ApproachZeroF(&this->velToTarget.x, 1.0f, 2.0f); + Math_ApproachZeroF(&this->velToTarget.z, 1.0f, 2.0f); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 40.0f, 40.0f, 5); + } +} + +void EnNeoReeba_DrawFrozenEffects(EnNeoReeba* this, GlobalContext* globalCtx) { + s32 i; + f32 limbPosScale = 10.0f; + f32 phi_f2 = 20.0f; + f32 drawEffectScale = 0.8f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + limbPosScale *= 1.5f; + phi_f2 *= 1.5f; + drawEffectScale *= 1.5f; + } + + for (i = 0; i < ARRAY_COUNT(this->limbPos) - 1; i++) { + this->limbPos[i] = this->actor.world.pos; + + this->limbPos[i].x += limbPosScale * Math_SinS(BINANG_ADD(this->actor.shape.rot.y, i * 0x5555)); + this->limbPos[i].z += limbPosScale * Math_CosS(BINANG_ADD(this->actor.shape.rot.y, i * 0x5555)); + this->limbPos[i].y += 5.0f; + } + + this->limbPos[ARRAY_COUNT(this->limbPos) - 1] = this->actor.world.pos; + this->limbPos[ARRAY_COUNT(this->limbPos) - 1].y += phi_f2; + + this->drawEffectScale = drawEffectScale; + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), drawEffectScale, 0.5f, + this->drawEffectAlpha, this->drawEffectType); +} + +void EnNeoReeba_DrawEffects(EnNeoReeba* this, GlobalContext* globalCtx) { + s32 i; + f32 scale = 15.0f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + scale *= 1.5f; + } + + if ((this->drawEffectType == ACTOR_DRAW_DMGEFF_FIRE) || (this->drawEffectType == ACTOR_DRAW_DMGEFF_LIGHT_ORBS) || + (this->drawEffectType == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL)) { + for (i = 0; i < ARRAY_COUNT(this->limbPos) - 1; i++) { + this->limbPos[i] = this->actor.world.pos; + this->limbPos[i].x += scale * Math_SinS(BINANG_ADD(this->actor.shape.rot.y, i * 0x5555)); + this->limbPos[i].z += scale * Math_CosS(BINANG_ADD(this->actor.shape.rot.y, i * 0x5555)); + this->limbPos[i].y += -20.0f; + } + + this->limbPos[ARRAY_COUNT(this->limbPos) - 1] = this->actor.world.pos; + Actor_DrawDamageEffects(globalCtx, NULL, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawEffectScale, 0.5f, + this->drawEffectAlpha, this->drawEffectType); + } +} + +void EnNeoReeba_SpawnIce(EnNeoReeba* this, GlobalContext* globalCtx) { + static Color_RGBA8 sIcePrimColor = { 170, 255, 255, 255 }; + static Color_RGBA8 sIceEnvColor = { 200, 200, 255, 255 }; + static Vec3f sIceAccel = { 0.0f, -1.0f, 0.0f }; + Vec3f iceVel; + f32 xVel; + f32 zVel; + s32 i; + s16 yaw; + s32 j; + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); + + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->limbPos[i]); + xVel = Math_SinS(yaw) * 3.0f; + zVel = Math_CosS(yaw) * 3.0f; + + for (j = 0; j < 4; j++) { + iceVel.x = (Rand_Centered() * 3.0f) + xVel; + iceVel.z = (Rand_Centered() * 3.0f) + zVel; + iceVel.y = (Rand_ZeroOne() * 6.0f) + 4.0f; + EffectSsEnIce_Spawn(globalCtx, &this->limbPos[i], 0.7f, &iceVel, &sIceAccel, &sIcePrimColor, &sIceEnvColor, + 30); + } + } +} + +void EnNeoReeba_SinkIfStoneMask(EnNeoReeba* this, GlobalContext* globalCtx) { + if ((this->actionFunc == EnNeoReeba_ChooseAction) || (this->actionFunc == EnNeoReeba_Move) || + (this->actionFunc == EnNeoReeba_ReturnHome)) { + if (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) { + EnNeoReeba_SetupSink(this); + } + } +} + +void EnNeoReeba_Update(Actor* thisx, GlobalContext* globalCtx) { + EnNeoReeba* this = THIS; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + this->collider.dim.radius = 27; + this->collider.dim.height = 45; + } + + this->actionFunc(this, globalCtx); + + if ((this->actionFunc != EnNeoReeba_WaitUnderground) && (this->actionFunc != EnNeoReeba_Stunned) && + (this->actionFunc != EnNeoReeba_Frozen)) { + SkelAnime_Update(&this->skelAnime); + } + + EnNeoReeba_HandleHit(this, globalCtx); + EnNeoReeba_UpdatePosition(this, globalCtx); + EnNeoReeba_SinkIfStoneMask(this, globalCtx); +} + +s32 EnNeoReeba_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnNeoReeba* this = THIS; + + if ((limbIndex == OBJECT_RB_LIMB_03) && (this->rotationSpeed != 0.0f)) { + rot->y += (s16)(this->rotationSpeed * Math_SinS(this->rotationAngle)); + rot->z += (s16)(this->rotationSpeed * Math_CosS(this->rotationAngle)); + } + + return false; +} + +void EnNeoReeba_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnNeoReeba* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x01, 255, 255, 255, 255); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnNeoReeba_OverrideLimbDraw, + NULL, &this->actor); + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (this->stunTimer > 0) { + if (this->drawEffectType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) { + EnNeoReeba_DrawFrozenEffects(this, globalCtx); + } else { + EnNeoReeba_DrawEffects(this, globalCtx); + } + } +} diff --git a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.h b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.h index 8d1091dfc..df6aaab1d 100644 --- a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.h +++ b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.h @@ -2,16 +2,33 @@ #define Z_EN_NEO_REEBA_H #include "global.h" +#include "objects/object_rb/object_rb.h" + +#define EN_NEO_REEBA_IS_LARGE(thisx) ((thisx)->params & 0x8000) struct EnNeoReeba; typedef void (*EnNeoReebaActionFunc)(struct EnNeoReeba*, GlobalContext*); typedef struct EnNeoReeba { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x168]; - /* 0x02AC */ EnNeoReebaActionFunc actionFunc; - /* 0x02B0 */ char unk_2B0[0x64]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ ColliderCylinder collider; + /* 0x1D4 */ Vec3s jointTable[LEEVER_LIMB_MAX]; + /* 0x240 */ Vec3s morphTable[LEEVER_LIMB_MAX]; + /* 0x2AC */ EnNeoReebaActionFunc actionFunc; + /* 0x2B0 */ Vec3f targetPos; + /* 0x2BC */ Vec3f velToTarget; + /* 0x2C8 */ Vec3f limbPos[4]; + /* 0x2F8 */ f32 sinkRiseRate; + /* 0x2FC */ f32 rotationSpeed; + /* 0x300 */ f32 drawEffectAlpha; + /* 0x304 */ f32 drawEffectScale; + /* 0x308 */ s16 rotationAngle; + /* 0x30A */ s16 actionTimer; + /* 0x30C */ s16 sfxTimer; + /* 0x30E */ s16 stunTimer; + /* 0x310 */ u8 drawEffectType; } EnNeoReeba; // size = 0x314 extern const ActorInit En_Neo_Reeba_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4c829c84d..fd71e02ad 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -14517,36 +14517,36 @@ 0x80B7C03C:("ObjUm_Draw",), 0x80B7C890:("EnNeoReeba_Init",), 0x80B7CA08:("EnNeoReeba_Destroy",), - 0x80B7CA34:("func_80B7CA34",), - 0x80B7CA70:("func_80B7CA70",), - 0x80B7CB3C:("func_80B7CB3C",), - 0x80B7CB88:("func_80B7CB88",), - 0x80B7CCE0:("func_80B7CCE0",), - 0x80B7CD28:("func_80B7CD28",), - 0x80B7CE34:("func_80B7CE34",), - 0x80B7CE94:("func_80B7CE94",), - 0x80B7CFA0:("func_80B7CFA0",), - 0x80B7CFFC:("func_80B7CFFC",), - 0x80B7D130:("func_80B7D130",), - 0x80B7D150:("func_80B7D150",), - 0x80B7D254:("func_80B7D254",), - 0x80B7D2E4:("func_80B7D2E4",), - 0x80B7D360:("func_80B7D360",), - 0x80B7D398:("func_80B7D398",), - 0x80B7D3EC:("func_80B7D3EC",), - 0x80B7D47C:("func_80B7D47C",), - 0x80B7D4FC:("func_80B7D4FC",), - 0x80B7D5A4:("func_80B7D5A4",), - 0x80B7D6D0:("func_80B7D6D0",), - 0x80B7D788:("func_80B7D788",), - 0x80B7D9B8:("func_80B7D9B8",), - 0x80B7DC80:("func_80B7DC80",), - 0x80B7DD7C:("func_80B7DD7C",), - 0x80B7DF34:("func_80B7DF34",), - 0x80B7E0BC:("func_80B7E0BC",), - 0x80B7E260:("func_80B7E260",), + 0x80B7CA34:("EnNeoReeba_SetupWaitUnderground",), + 0x80B7CA70:("EnNeoReeba_WaitUnderground",), + 0x80B7CB3C:("EnNeoReeba_SetupChooseAction",), + 0x80B7CB88:("EnNeoReeba_ChooseAction",), + 0x80B7CCE0:("EnNeoReeba_SetupSink",), + 0x80B7CD28:("EnNeoReeba_Sink",), + 0x80B7CE34:("EnNeoReeba_SetupRise",), + 0x80B7CE94:("EnNeoReeba_RiseOutOfGround",), + 0x80B7CFA0:("EnNeoReeba_SetupMove",), + 0x80B7CFFC:("EnNeoReeba_Move",), + 0x80B7D130:("EnNeoReeba_SetupReturnHome",), + 0x80B7D150:("EnNeoReeba_ReturnHome",), + 0x80B7D254:("EnNeoReeba_SetupBounce",), + 0x80B7D2E4:("EnNeoReeba_Bounce",), + 0x80B7D360:("EnNeoReeba_SetupStun",), + 0x80B7D398:("EnNeoReeba_Stunned",), + 0x80B7D3EC:("EnNeoReeba_SetupFrozen",), + 0x80B7D47C:("EnNeoReeba_Frozen",), + 0x80B7D4FC:("EnNeoReeba_SetupDamageAnim",), + 0x80B7D5A4:("EnNeoReeba_DamageAnim",), + 0x80B7D6D0:("EnNeoReeba_SetupDeathEffects",), + 0x80B7D788:("EnNeoReeba_PlayDeathEffects",), + 0x80B7D9B8:("EnNeoReeba_HandleHit",), + 0x80B7DC80:("EnNeoReeba_UpdatePosition",), + 0x80B7DD7C:("EnNeoReeba_DrawFrozenEffects",), + 0x80B7DF34:("EnNeoReeba_DrawEffects",), + 0x80B7E0BC:("EnNeoReeba_SpawnIce",), + 0x80B7E260:("EnNeoReeba_SinkIfStoneMask",), 0x80B7E2C4:("EnNeoReeba_Update",), - 0x80B7E378:("func_80B7E378",), + 0x80B7E378:("EnNeoReeba_OverrideLimbDraw",), 0x80B7E424:("EnNeoReeba_Draw",), 0x80B7E930:("BgMbarChair_Init",), 0x80B7E980:("BgMbarChair_Destroy",), From ec9909c65cc909be4f1fb4dec08a003dbae520ee Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Tue, 29 Mar 2022 12:42:44 -0700 Subject: [PATCH 163/257] Boot_800862E0 OK (#769) * boot_800862E0 OK * Ran format.sh * attempt at fixing bss reordering * boot_800862E0 OK (for real this time) * Run formatter * Changes u32 pointers to uintptr_t and sizes to size_t * Run formatter * Fix bss reordering * Delete baserom.mm.us.rev1.z64:Zone.Identifier * Cleanup and some notes * Try my best to document * remove comments * Remove D_80097508 from variables.h Co-authored-by: kyleburnette Co-authored-by: Anghelo Carvajal --- include/functions.h | 12 ++-- include/variables.h | 1 - spec | 1 - src/boot_O2/boot_800862E0.c | 116 ++++++++++++++++++++++++++++++--- tools/disasm/functions.txt | 12 ++-- tools/disasm/variables.txt | 4 +- tools/sizes/boot_functions.csv | 12 ++-- 7 files changed, 126 insertions(+), 32 deletions(-) diff --git a/include/functions.h b/include/functions.h index c4bd9eef7..26de0794d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -153,14 +153,10 @@ void MtxConv_L2F(MtxF* m1, MatrixInternal* m2); void __assert(const char* file, u32 lineNum); // void func_800862B4(void); void* SystemArena_MallocMin1(u32 size); -void SystemArena_FreeNull(void* pvParm1); -void func_8008633C(u32 param_1, s32 param_2, s32 param_3, UNK_PTR param_4); -void func_800863AC(u32 param_1, s32 param_2, s32 param_3, UNK_PTR param_4); -// void func_8008641C(void); -// void func_800864EC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80086588(void); -void SystemArena_Init(u32 base, u32 size); -s32 PadSetup_Init(OSMesgQueue* mq, u8* outMask, OSContStatus* status); +void SystemArena_FreeNullCheck(void* ptr); +void SystemArena_RunInits(void); +void SystemArena_Init(void* start, size_t size); +s32 func_80086620(OSMesgQueue* param_1, PadMgr* param_2, OSContStatus* param_3); // void func_80086760(void); // void func_80086794(void); // void func_800867B4(void); diff --git a/include/variables.h b/include/variables.h index c5047526c..4d2e0e42c 100644 --- a/include/variables.h +++ b/include/variables.h @@ -43,7 +43,6 @@ extern StackEntry* sStackInfoListEnd; // extern UNK_TYPE1 sGfxPrintUnkTLUT; // extern UNK_TYPE1 sGfxPrintUnkData; // extern UNK_TYPE1 sGfxPrintFontData; -// extern UNK_TYPE4 D_80097500; // extern UNK_TYPE4 D_80097524; // extern u32 sRandInt; extern OSViMode osViModeNtscHpf1; diff --git a/spec b/spec index 45da21f4f..73bb622b4 100644 --- a/spec +++ b/spec @@ -38,7 +38,6 @@ beginseg include "build/src/boot_O2/mtxuty-cvt.o" include "build/src/boot_O2/assert.o" include "build/src/boot_O2/boot_800862E0.o" - include "build/data/boot/boot_800862E0.data.o" include "build/src/boot_O2/padsetup.o" include "build/src/boot_O2/boot_80086760.o" include "build/asm/boot/fp.text.o" diff --git a/src/boot_O2/boot_800862E0.c b/src/boot_O2/boot_800862E0.c index 1055dfe1b..5774af9da 100644 --- a/src/boot_O2/boot_800862E0.c +++ b/src/boot_O2/boot_800862E0.c @@ -1,18 +1,116 @@ #include "global.h" -#include "os_malloc.h" +#include "system_malloc.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/SystemArena_MallocMin1.s") +typedef void (*BlockFunc)(void*); +typedef void (*BlockFunc1)(void*, u32); +typedef void (*BlockFunc8)(void*, u32, u32, u32, u32, u32, u32, u32, u32); -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/SystemArena_FreeNull.s") +typedef struct InitFunc { + uintptr_t nextOffset; + void (*func)(void); +} InitFunc; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_8008633C.s") +void* sInitFuncs = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_800863AC.s") +char sNew[] = { 0x00, 0x00, 0x00, 0x00 }; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_8008641C.s") +char D_80097508[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x00, 0x00, + 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, +}; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_800864EC.s") +void* SystemArena_MallocMin1(size_t size) { + if (size == 0) { + size = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_80086588.s") + return __osMalloc(&gSystemArena, size); +} -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/SystemArena_Init.s") +void SystemArena_FreeNullCheck(void* ptr) { + if (ptr != NULL) { + __osFree(&gSystemArena, ptr); + } +} + +void SystemArena_RunBlockFunc(void* blk, size_t nBlk, size_t blkSize, BlockFunc blockFunc) { + uintptr_t pos = blk; + + for (; pos < (uintptr_t)blk + (nBlk * blkSize); pos += (blkSize & ~0)) { + blockFunc(pos); + } +} + +void SystemArena_RunBlockFunc1(void* blk, size_t nBlk, size_t blkSize, BlockFunc1 blockFunc) { + uintptr_t pos = blk; + + for (; pos < (uintptr_t)blk + (nBlk * blkSize); pos += (blkSize & ~0)) { + blockFunc(pos, 2); + } +} + +void* SystemArena_RunBlockFunc8(void* blk, size_t nBlk, size_t blkSize, BlockFunc8 blockFunc) { + if (blk == NULL) { + blk = SystemArena_MallocMin1(nBlk * blkSize); + } + + if (blk != NULL && blockFunc != NULL) { + uintptr_t pos = blk; + + for (; pos < (uintptr_t)blk + (nBlk * blkSize); pos += (blkSize & ~0)) { + blockFunc(pos, 0, 0, 0, 0, 0, 0, 0, 0); + } + } + + return blk; +} + +void SystemArena_RunBlockFunc1Reverse(void* blk, size_t nBlk, size_t blkSize, BlockFunc1 blockFunc, s32 shouldFree) { + uintptr_t pos; + uintptr_t start; + size_t maskedBlkSize; + + if (blk == NULL) { + return; + } + + if (blockFunc != NULL) { + start = blk; + maskedBlkSize = (blkSize & ~0); + pos = (uintptr_t)start + (nBlk * blkSize); + + while (pos > start) { + pos -= maskedBlkSize; + blockFunc(pos, 2); + } + } + + if (shouldFree) { + SystemArena_FreeNullCheck(blk); + } +} + +void SystemArena_RunInits(void) { + InitFunc* initFunc = (InitFunc*)&sInitFuncs; + u32 nextOffset = initFunc->nextOffset; + InitFunc* prev = NULL; + + while (nextOffset != 0) { + initFunc = (InitFunc*)((uintptr_t)initFunc + nextOffset); + + if (initFunc->func != NULL) { + (*initFunc->func)(); + } + + nextOffset = initFunc->nextOffset; + initFunc->nextOffset = (uintptr_t)prev; + prev = initFunc; + } + + sInitFuncs = prev; +} + +void SystemArena_Init(void* start, size_t size) { + SystemArena_InitArena(start, size); + SystemArena_RunInits(); +} diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index fd71e02ad..2ca5d4dd1 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -158,12 +158,12 @@ 0x80086280:("__assert",), 0x800862B4:("func_800862B4",), 0x800862E0:("SystemArena_MallocMin1",), - 0x80086310:("SystemArena_FreeNull",), - 0x8008633C:("func_8008633C",), - 0x800863AC:("func_800863AC",), - 0x8008641C:("func_8008641C",), - 0x800864EC:("func_800864EC",), - 0x80086588:("func_80086588",), + 0x80086310:("SystemArena_FreeNullCheck",), + 0x8008633C:("SystemArena_RunBlockFunc",), + 0x800863AC:("SystemArena_RunBlockFunc1",), + 0x8008641C:("SystemArena_RunBlockFunc8",), + 0x800864EC:("SystemArena_RunBlockFunc1Reverse",), + 0x80086588:("SystemArena_RunInits",), 0x800865F8:("SystemArena_Init",), 0x80086620:("PadSetup_Init",), 0x80086760:("func_80086760",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 2e66c57e1..e7adc27f4 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -35,7 +35,9 @@ 0x80096CD0:("sGfxPrintUnkTLUT","u16","[16]",0x20), 0x80096CF0:("sGfxPrintUnkData","u8","[8]",0x8), 0x80096CF8:("sGfxPrintFontData","u8","[0x800]",0x800), - 0x80097500:("D_80097500","UNK_TYPE4","",0x4), + 0x80097500:("sInitFuncs","void*","",0x4), + 0x80097504:("sNew","char","[4]",0x4), + 0x80097508:("D_80097508","[24]","",0x18), 0x80097520:("qNaN0x3FFFFF","f32","",0x4), 0x80097524:("qNaN0x10000","f32","",0x4), 0x80097528:("sNaN0x3FFFFF","f32","",0x4), diff --git a/tools/sizes/boot_functions.csv b/tools/sizes/boot_functions.csv index f652c0d43..6c5c92e16 100644 --- a/tools/sizes/boot_functions.csv +++ b/tools/sizes/boot_functions.csv @@ -155,12 +155,12 @@ asm/non_matchings/boot/mtxuty-cvt/MtxConv_L2F.s,MtxConv_L2F,0x80086258,0xA asm/non_matchings/boot/assert/__assert.s,__assert,0x80086280,0xD asm/non_matchings/boot/assert/func_800862B4.s,func_800862B4,0x800862B4,0xB asm/non_matchings/boot/boot_800862E0/SystemArena_MallocMin1.s,SystemArena_MallocMin1,0x800862E0,0xC -asm/non_matchings/boot/boot_800862E0/SystemArena_FreeNull.s,SystemArena_FreeNull,0x80086310,0xB -asm/non_matchings/boot/boot_800862E0/func_8008633C.s,func_8008633C,0x8008633C,0x1C -asm/non_matchings/boot/boot_800862E0/func_800863AC.s,func_800863AC,0x800863AC,0x1C -asm/non_matchings/boot/boot_800862E0/func_8008641C.s,func_8008641C,0x8008641C,0x34 -asm/non_matchings/boot/boot_800862E0/func_800864EC.s,func_800864EC,0x800864EC,0x27 -asm/non_matchings/boot/boot_800862E0/func_80086588.s,func_80086588,0x80086588,0x1C +asm/non_matchings/boot/boot_800862E0/SystemArena_FreeNullCheck.s,SystemArena_FreeNullCheck,0x80086310,0xB +asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc.s,SystemArena_RunBlockFunc,0x8008633C,0x1C +asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc1.s,SystemArena_RunBlockFunc1,0x800863AC,0x1C +asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc8.s,SystemArena_RunBlockFunc8,0x8008641C,0x34 +asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc1Reverse.s,SystemArena_RunBlockFunc1Reverse,0x800864EC,0x27 +asm/non_matchings/boot/boot_800862E0/SystemArena_RunInits.s,SystemArena_RunInits,0x80086588,0x1C asm/non_matchings/boot/boot_800862E0/SystemArena_Init.s,SystemArena_Init,0x800865F8,0xA asm/non_matchings/boot/padsetup/PadSetup_Init.s,PadSetup_Init,0x80086620,0x50 asm/non_matchings/boot/boot_80086760/func_80086760.s,func_80086760,0x80086760,0xD From 036a68cb3e3477b31a29ee377ad81a012897327e Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Tue, 29 Mar 2022 12:52:37 -0700 Subject: [PATCH 164/257] Effects Stick and Kakera cleanup (#752) * cleanup * cleanup * idx -> index --- assets/xml/objects/gameplay_keep.xml | 4 +- .../ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c | 183 ++++++++++-------- .../ovl_Effect_Ss_Stick/z_eff_ss_stick.c | 23 ++- tools/disasm/functions.txt | 2 +- 4 files changed, 117 insertions(+), 95 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 3e74b3ace..009bc87ae 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -38,7 +38,7 @@ - + @@ -68,7 +68,7 @@ - + diff --git a/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c b/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c index fe070b28d..d2ea02f7c 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c +++ b/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c @@ -6,43 +6,59 @@ #include "z_eff_ss_kakera.h" +#define rReg0 regs[0] +#define rGravity regs[1] +#define rPitch regs[2] +#define rYaw regs[3] +#define rReg4 regs[4] +#define rReg5 regs[5] +#define rReg6 regs[6] +#define rScale regs[7] +#define rReg8 regs[8] +#define rReg9 regs[9] +#define rObjId regs[10] +#define rObjBankIndex regs[11] +#define rColorIndex regs[12] + #define PARAMS ((EffectSsKakeraInitParams*)initParamsx) u32 EffectSsKakera_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsKakera_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_8097E130(EffectSs* this, GlobalContext* globalCtx); +void EffectSsKakera_CheckForObject(EffectSs* this, GlobalContext* globalCtx); const EffectSsInit Effect_Ss_Kakera_InitVars = { EFFECT_SS_KAKERA, EffectSsKakera_Init, }; + KakeraColorStruct D_8097EAD8[] = { { 0, { 255, 255, 255 } }, { 0, { 235, 170, 130 } }, { 1, { 210, 190, 170 } }, }; + f32 D_8097EAE4[] = { 1.0f, 100.0f, 40.0f, 5.0f, 100.0f, 40.0f, 5.0f, 100.0f, 40.0f, 5.0f }; u32 EffectSsKakera_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { - EffectSsKakeraInitParams* params = PARAMS; + EffectSsKakeraInitParams* initParams = PARAMS; - this->pos = params->pos; - this->velocity = params->velocity; - this->life = params->life; + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->life = initParams->life; this->priority = 101; - if (params->dList != NULL) { - this->gfx = params->dList; - switch (params->objId) { + if (initParams->dList != NULL) { + this->gfx = initParams->dList; + switch (initParams->objId) { case GAMEPLAY_KEEP: case GAMEPLAY_FIELD_KEEP: case GAMEPLAY_DANGEON_KEEP: - this->regs[10] = KAKERA_OBJECT_DEFAULT; + this->rObjId = KAKERA_OBJECT_DEFAULT; break; default: - this->regs[10] = params->objId; - func_8097E130(this, globalCtx); + this->rObjId = initParams->objId; + EffectSsKakera_CheckForObject(this, globalCtx); break; } } else { @@ -50,18 +66,18 @@ u32 EffectSsKakera_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, voi } this->draw = EffectSsKakera_Draw; this->update = EffectSsKakera_Update; - this->vec = params->unk_18; - this->regs[0] = params->unk_2C; - this->regs[1] = params->gravity; - this->regs[2] = Rand_ZeroOne() * 0x8000; - this->regs[3] = Rand_ZeroOne() * 0x8000; - this->regs[4] = params->unk_26; - this->regs[5] = params->unk_28; - this->regs[6] = params->unk_2A; - this->regs[7] = params->scale; - this->regs[8] = params->unk_30; - this->regs[9] = params->unk_32; - this->regs[12] = params->colorIdx; + this->vec = initParams->unk_18; + this->rReg0 = initParams->unk_2C; + this->rGravity = initParams->gravity; + this->rPitch = Rand_ZeroOne() * 0x8000; + this->rYaw = Rand_ZeroOne() * 0x8000; + this->rReg4 = initParams->unk_26; + this->rReg5 = initParams->unk_28; + this->rReg6 = initParams->unk_2A; + this->rScale = initParams->scale; + this->rReg8 = initParams->unk_30; + this->rReg9 = initParams->unk_32; + this->rColorIndex = initParams->colorIdx; return 1; } @@ -72,24 +88,24 @@ f32 func_8097DE30(f32 center, f32 range) { void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s16 pad; - f32 scale = this->regs[7] / 256.0f; - s32 colorIndex = this->regs[12]; + f32 scale = this->rScale / 256.0f; + s32 colorIndex = this->rColorIndex; OPEN_DISPS(gfxCtx); - if (this->regs[10] != KAKERA_OBJECT_DEFAULT) { - if ((((this->regs[4] >> 7) & 1) << 7) == 0x80) { - gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[this->regs[11]].segment); + if (this->rObjId != KAKERA_OBJECT_DEFAULT) { + if ((((this->rReg4 >> 7) & 1) << 7) == 0x80) { + gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[this->rObjBankIndex].segment); } else { - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->regs[11]].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->rObjBankIndex].segment); } } Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); - Matrix_RotateY(this->regs[3], MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->regs[2], MTXMODE_APPLY); + Matrix_RotateY(this->rYaw, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->rPitch, MTXMODE_APPLY); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - if ((((this->regs[4] >> 7) & 1) << 7) == 0x80) { + if ((((this->rReg4 >> 7) & 1) << 7) == 0x80) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_8012C2DC(globalCtx->state.gfxCtx); if (colorIndex >= 0) { @@ -109,9 +125,9 @@ void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { CLOSE_DISPS(gfxCtx); } -void func_8097E130(EffectSs* this, GlobalContext* globalCtx) { - this->regs[11] = Object_GetIndex(&globalCtx->objectCtx, this->regs[10]); - if ((this->regs[11] < 0) || (!Object_IsLoaded(&globalCtx->objectCtx, this->regs[11]))) { +void EffectSsKakera_CheckForObject(EffectSs* this, GlobalContext* globalCtx) { + this->rObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, this->rObjId); + if ((this->rObjBankIndex < 0) || (!Object_IsLoaded(&globalCtx->objectCtx, this->rObjBankIndex))) { this->life = 0; this->draw = NULL; } @@ -127,9 +143,9 @@ void func_8097E19C(EffectSs* this) { f32 temp_f20; f32 temp_f2_2; - temp_f18 = this->regs[5] / 1024.0f; - temp_f20 = this->regs[6] / 1024.0f; - range = (this->regs[9] / 1024.0f) * 4.0f; + temp_f18 = this->rReg5 / 1024.0f; + temp_f20 = this->rReg6 / 1024.0f; + range = (this->rReg9 / 1024.0f) * 4.0f; temp_f2 = this->velocity.x - func_8097DE30(0.0f, range); temp_f16 = this->velocity.y - func_8097DE30(0.0f, range); temp_f12 = this->velocity.z - func_8097DE30(0.0f, range); @@ -187,7 +203,7 @@ f32 func_8097E400(f32 arg0, s32 index) { s32 func_8097E420(EffectSs* this, Vec3f* diff, f32 distance) { static f32 D_8097EB0C[] = { 0.05f, 1.0f }; f32 phi_f0; - s32 index = this->regs[0] & 3; + s32 index = this->rReg0 & 3; if (index != 0) { if (distance > 1.0f) { @@ -198,23 +214,23 @@ s32 func_8097E420(EffectSs* this, Vec3f* diff, f32 distance) { this->accel.x += D_8097EB0C[index - 1] * diff->z * phi_f0; this->accel.z -= D_8097EB0C[index - 1] * diff->x * phi_f0; } - return 1; + return true; } s32 func_8097E4B0(EffectSs* this, Vec3f* diff, f32 distance) { static f32 D_8097EB14[] = { 4.0f, 0.1f, 0.3f, 0.9f, -0.1f, -0.3f, -0.9f }; - s32 index = (this->regs[0] >> 2) & 7; + s32 index = (this->rReg0 >> 2) & 7; if (index != 0) { this->accel.y += D_8097EB14[index]; } - return 1; + return true; } s32 func_8097E4F0(EffectSs* this, Vec3f* diff, f32 distance) { static f32 D_8097EB30[] = { 0.1f, 1.0f, 6.0f }; f32 phi_f0; - s32 index = (this->regs[0] >> 5) & 3; + s32 index = (this->rReg0 >> 5) & 3; if (index != 0) { if (distance > 1.0f) { @@ -225,32 +241,33 @@ s32 func_8097E4F0(EffectSs* this, Vec3f* diff, f32 distance) { this->accel.x -= diff->x * D_8097EB30[index - 1] * phi_f0; this->accel.z -= diff->z * D_8097EB30[index - 1] * phi_f0; } - return 1; + return true; } s32 func_8097E584(EffectSs* this, Vec3f* diff, f32 distance) { - static f32 (*D_8097EB3C[])(f32, - s32) = { func_8097E368, func_8097E384, func_8097E384, func_8097E384, func_8097E3C0, - func_8097E3C0, func_8097E3C0, func_8097E400, func_8097E400, func_8097E400 }; + static f32 (*D_8097EB3C[])(f32, s32) = { + func_8097E368, func_8097E384, func_8097E384, func_8097E384, func_8097E3C0, + func_8097E3C0, func_8097E3C0, func_8097E400, func_8097E400, func_8097E400, + }; f32 center; f32 rand; s32 index; - index = (this->regs[0] >> 7) & 0xF; + index = (this->rReg0 >> 7) & 0xF; center = D_8097EB3C[index](distance, index); - rand = func_8097DE30(center, (this->regs[9] * center) / 1024.0f); + rand = func_8097DE30(center, (this->rReg9 * center) / 1024.0f); this->accel.x *= rand; this->accel.y *= rand; this->accel.z *= rand; this->accel.x += rand * 0.01f; this->accel.y += rand * 0.01f; this->accel.z += rand * 0.01f; - return 1; + return true; } s32 func_8097E660(EffectSs* this, Vec3f* diff, f32 distance) { - this->accel.y += this->regs[1] / 256.0f; - return 1; + this->accel.y += this->rGravity / 256.0f; + return true; } s32 func_8097E698(EffectSs* this) { @@ -265,21 +282,21 @@ s32 func_8097E698(EffectSs* this) { if (distance > 1000.0f) { return false; } - if (this->regs[0] != 0) { - if (func_8097E420(this, &diff, distance) == 0) { + if (this->rReg0 != 0) { + if (!func_8097E420(this, &diff, distance)) { return false; } - if (func_8097E4B0(this, &diff, distance) == 0) { + if (!func_8097E4B0(this, &diff, distance)) { return false; } - if (func_8097E4F0(this, &diff, distance) == 0) { + if (!func_8097E4F0(this, &diff, distance)) { return false; } - if (func_8097E584(this, &diff, distance) == 0) { + if (!func_8097E584(this, &diff, distance)) { return false; } } - if (func_8097E660(this, &diff, distance) == 0) { + if (!func_8097E660(this, &diff, distance)) { return false; } else { return true; @@ -290,41 +307,41 @@ void func_8097E7E0(EffectSs* this, GlobalContext* globalCtx) { static f32 D_8097EB64[] = { 10.0f, 20.0f, 40.0f }; Player* player = GET_PLAYER(globalCtx); - if (this->regs[8] == 0) { - if ((((this->regs[4] >> 4) & 1) << 4) == (1 << 4)) { - if (this->pos.y <= (player->actor.floorHeight - ((this->regs[4] >> 2) & 3))) { - this->regs[9] = 0; - this->regs[0] = 0; - this->regs[4] &= ~0x60; + if (this->rReg8 == 0) { + if ((((this->rReg4 >> 4) & 1) << 4) == (1 << 4)) { + if (this->pos.y <= (player->actor.floorHeight - ((this->rReg4 >> 2) & 3))) { + this->rReg9 = 0; + this->rReg0 = 0; + this->rReg4 &= ~0x60; this->accel.x = this->accel.y = this->accel.z = 0.0f; this->velocity.x = this->velocity.y = this->velocity.z = 0.0f; - this->regs[5] = this->regs[9]; - this->regs[1] = this->regs[9]; + this->rReg5 = this->rReg9; + this->rGravity = this->rReg9; } } else { - if (this->pos.y <= ((player->actor.floorHeight - ((this->regs[4] >> 2) & 3)) - 600.0f)) { + if (this->pos.y <= ((player->actor.floorHeight - ((this->rReg4 >> 2) & 3)) - 600.0f)) { this->life = 0; } } } else { - switch (this->regs[4] & 3) { + switch (this->rReg4 & 3) { case 0: - this->regs[8] = 0; + this->rReg8 = 0; break; case 1: if ((this->velocity.y < 0.0f) && - (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_8097EB64[(this->regs[4] >> 2) & 3]))) { + (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_8097EB64[(this->rReg4 >> 2) & 3]))) { this->velocity.x *= func_8097DE30(0.9f, 0.2f); this->velocity.y *= -0.8f; this->velocity.z *= func_8097DE30(0.9f, 0.2f); - if (this->regs[8] > 0) { - this->regs[8]--; + if (this->rReg8 > 0) { + this->rReg8--; } } break; case 2: - if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_8097EB64[(this->regs[4] >> 2) & 3])) { - this->regs[8] = 0; + if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_8097EB64[(this->rReg4 >> 2) & 3])) { + this->rReg8 = 0; } break; } @@ -332,18 +349,18 @@ void func_8097E7E0(EffectSs* this, GlobalContext* globalCtx) { } void EffectSsKakera_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - switch (((this->regs[4] >> 5) & 3) << 5) { + switch (((this->rReg4 >> 5) & 3) << 5) { case 0x20: - this->regs[2] += 0x47B; - this->regs[3] += 0x139; + this->rPitch += 0x47B; + this->rYaw += 0x139; break; case 0x40: - this->regs[2] += 0x1A7C; - this->regs[3] += 0x47B; + this->rPitch += 0x1A7C; + this->rYaw += 0x47B; break; case 0x60: - this->regs[2] += 0x3F27; - this->regs[3] += 0xCA1; + this->rPitch += 0x3F27; + this->rYaw += 0xCA1; break; } func_8097E19C(this); @@ -351,7 +368,7 @@ void EffectSsKakera_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) this->life = 0; } func_8097E7E0(this, globalCtx); - if (this->regs[10] != KAKERA_OBJECT_DEFAULT) { - func_8097E130(this, globalCtx); + if (this->rObjId != KAKERA_OBJECT_DEFAULT) { + EffectSsKakera_CheckForObject(this, globalCtx); } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c index c49059262..d26135729 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c @@ -7,6 +7,9 @@ #include "z_eff_ss_stick.h" #include "objects/gameplay_keep/gameplay_keep.h" +#define rObjBankIndex regs[0] +#define rYaw regs[1] + #define PARAMS ((EffectSsStickInitParams*)initParamsx) u32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); @@ -19,16 +22,16 @@ const EffectSsInit Effect_Ss_Stick_InitVars = { }; u32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { - EffectSsStickInitParams* params = PARAMS; + EffectSsStickInitParams* initParams = PARAMS; Vec3f pos; - this->regs[0] = Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_KEEP); - pos = params->pos; + this->rObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_KEEP); + pos = initParams->pos; this->pos = pos; this->vec = pos; - this->regs[1] = params->yaw; - this->velocity.x = Math_SinS(params->yaw) * 6.0f; - this->velocity.z = Math_CosS(params->yaw) * 6.0f; + this->rYaw = initParams->yaw; + this->velocity.x = Math_SinS(initParams->yaw) * 6.0f; + this->velocity.z = Math_CosS(initParams->yaw) * 6.0f; this->life = 20; this->draw = EffectSsStick_Draw; this->update = EffectSsStick_Update; @@ -42,14 +45,16 @@ void EffectSsStick_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; OPEN_DISPS(gfxCtx); + Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Scale(0.01f, 0.0025f, 0.01f, MTXMODE_APPLY); - Matrix_InsertRotation(0, this->regs[1], 0, MTXMODE_APPLY); + Matrix_InsertRotation(0, this->rYaw, 0, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_8012C28C(gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->regs[0]].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->rObjBankIndex].segment); gSPSegment(POLY_OPA_DISP++, 0x0C, D_801C0850); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0032B0); + gSPDisplayList(POLY_OPA_DISP++, gDekuStickDL); + CLOSE_DISPS(gfxCtx); } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 2ca5d4dd1..9ff9270d7 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -8201,7 +8201,7 @@ 0x8097DCA0:("EffectSsKakera_Init",), 0x8097DE30:("func_8097DE30",), 0x8097DE6C:("EffectSsKakera_Draw",), - 0x8097E130:("func_8097E130",), + 0x8097E130:("EffectSsKakera_CheckForObject",), 0x8097E19C:("func_8097E19C",), 0x8097E34C:("func_8097E34C",), 0x8097E368:("func_8097E368",), From cdc475bea9b7fd8bef375dce3c7d36c2efff8e1d Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 20:59:59 +0100 Subject: [PATCH 165/257] Bg_F40_Block (#754) --- spec | 3 +- .../actors/ovl_Bg_F40_Block/z_bg_f40_block.c | 347 ++++++++++++++++-- .../actors/ovl_Bg_F40_Block/z_bg_f40_block.h | 10 +- undefined_syms.txt | 5 - 4 files changed, 330 insertions(+), 35 deletions(-) diff --git a/spec b/spec index 73bb622b4..64b949c12 100644 --- a/spec +++ b/spec @@ -4534,8 +4534,7 @@ beginseg name "ovl_Bg_F40_Block" compress include "build/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.o" - include "build/data/ovl_Bg_F40_Block/ovl_Bg_F40_Block.data.o" - include "build/data/ovl_Bg_F40_Block/ovl_Bg_F40_Block.reloc.o" + include "build/src/overlays/actors/ovl_Bg_F40_Block/ovl_Bg_F40_Block_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c index 769118e69..1e8c369fb 100644 --- a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c +++ b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c @@ -5,6 +5,7 @@ */ #include "z_bg_f40_block.h" +#include "objects/object_f40_obj/object_f40_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,16 @@ void BgF40Block_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgF40Block_Update(Actor* thisx, GlobalContext* globalCtx); void BgF40Block_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80BC41AC(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4228(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4344(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4380(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC43CC(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4448(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC44F4(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4530(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC457C(BgF40Block* this, GlobalContext* globalCtx); + const ActorInit Bg_F40_Block_InitVars = { ACTOR_BG_F40_BLOCK, ACTORCAT_BG, @@ -28,55 +38,340 @@ const ActorInit Bg_F40_Block_InitVars = { (ActorFunc)BgF40Block_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BC4668[] = { +static Vec3f D_80BC4620[] = { + { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f }, + { -1.0f, 0.0f, 0.0f }, { 0.0f, -1.0f, 0.0f }, { 0.0f, 0.0f, -1.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +s32 func_80BC3980(BgF40Block* this, GlobalContext* globalCtx) { + Vec3s* points; -extern InitChainEntry D_80BC4668[]; + this->unk_160 = 0; + this->unk_164 = 0; -extern UNK_TYPE D_060043D0; -extern UNK_TYPE D_06004640; + if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) { + this->path = &globalCtx->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)]; + if (this->path != NULL) { + points = Lib_SegmentedToVirtual(this->path->points); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3980.s") + this->dyna.actor.world.pos.x = points->x; + this->dyna.actor.world.pos.y = points->y; + this->dyna.actor.world.pos.z = points->z; + } + } else { + this->path = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3A2C.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3B00.s") +s32 func_80BC3A2C(BgF40Block* this, GlobalContext* globalCtx) { + Vec3s* points; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3CA4.s") + this->unk_160 = this->path->count - 1; + this->unk_164 = this->path->count - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3D08.s") + if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) { + this->path = &globalCtx->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)]; + if (this->path != NULL) { + points = Lib_SegmentedToVirtual(this->path->points); + points += this->unk_164; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4038.s") + this->dyna.actor.world.pos.x = points->x; + this->dyna.actor.world.pos.y = points->y; + this->dyna.actor.world.pos.z = points->z; + } + } else { + this->path = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Init.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Destroy.s") +s32 func_80BC3B00(BgF40Block* this) { + s32 pad; + Path* path; + Vec3s* points; + Vec3f sp28; + Vec3f sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC41AC.s") + if (this->path == NULL) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4228.s") + if (this->unk_160 == this->unk_164) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4344.s") + path = this->path; + points = Lib_SegmentedToVirtual(path->points); + points += this->unk_164; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4380.s") + sp28.x = points->x; + sp28.y = points->y; + sp28.z = points->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC43CC.s") + if (this->unk_168 == 6) { + sp24.x = sp28.x - this->dyna.actor.world.pos.x; + sp24.y = sp28.y - this->dyna.actor.world.pos.y; + sp24.z = sp28.z - this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4448.s") + if (sp24.x > 10.0f) { + this->unk_168 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC44F4.s") + if (sp24.y > 10.0f) { + this->unk_168 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4530.s") + if (sp24.z > 10.0f) { + this->unk_168 = 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC457C.s") + if (sp24.x < -10.0f) { + this->unk_168 = 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Update.s") + if (sp24.y < -10.0f) { + this->unk_168 = 4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Draw.s") + if (sp24.z < -10.0f) { + this->unk_168 = 5; + } + } + + if (Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &sp28, this->dyna.actor.speedXZ) <= 0.0f) { + this->unk_168 = 6; + this->unk_160 = this->unk_164; + return true; + } + return false; +} + +s32 func_80BC3CA4(BgF40Block* this) { + if (this->dyna.actor.cutscene == -1) { + return true; + } + + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + return true; + } + + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + return false; +} + +s32 func_80BC3D08(BgF40Block* this, GlobalContext* globalCtx, s32 arg2) { + CollisionPoly* sp54; + Vec3f sp48; + Vec3f sp3C; + Vec3f sp30; + + if (this->unk_168 == 6) { + return false; + } + + if (arg2 != 0) { + sp48.x = + (D_80BC4620[this->unk_168].x * ((800.0f * this->dyna.actor.scale.x) - (this->dyna.actor.speedXZ * 0.5f))) + + this->dyna.actor.world.pos.x; + sp48.y = + (D_80BC4620[this->unk_168].y * ((800.0f * this->dyna.actor.scale.y) - (this->dyna.actor.speedXZ * 0.5f))) + + this->dyna.actor.world.pos.y; + sp48.z = + (D_80BC4620[this->unk_168].z * ((800.0f * this->dyna.actor.scale.z) - (this->dyna.actor.speedXZ * 0.5f))) + + this->dyna.actor.world.pos.z; + + sp3C.x = (D_80BC4620[this->unk_168].x * this->dyna.actor.speedXZ) + sp48.x; + sp3C.y = (D_80BC4620[this->unk_168].y * this->dyna.actor.speedXZ) + sp48.y; + sp3C.z = (D_80BC4620[this->unk_168].z * this->dyna.actor.speedXZ) + sp48.z; + } else { + sp3C.x = (D_80BC4620[this->unk_168].x * 800.0f * this->dyna.actor.scale.x) + this->dyna.actor.world.pos.x; + sp3C.y = (D_80BC4620[this->unk_168].y * 800.0f * this->dyna.actor.scale.y) + this->dyna.actor.world.pos.y; + sp3C.z = (D_80BC4620[this->unk_168].z * 800.0f * this->dyna.actor.scale.z) + this->dyna.actor.world.pos.z; + + sp48.x = sp3C.x - (D_80BC4620[this->unk_168].x * this->dyna.actor.speedXZ * 1.5f); + sp48.y = sp3C.y - (D_80BC4620[this->unk_168].y * this->dyna.actor.speedXZ * 1.5f); + sp48.z = sp3C.z - (D_80BC4620[this->unk_168].z * this->dyna.actor.speedXZ * 1.5f); + } + + if (BgCheck_AnyLineTest1(&globalCtx->colCtx, &sp48, &sp3C, &sp30, &sp54, true)) { + if (arg2 == 0) { + this->dyna.actor.world.pos.x -= sp3C.x - sp30.x; + this->dyna.actor.world.pos.y -= sp3C.y - sp30.y; + this->dyna.actor.world.pos.z -= sp3C.z - sp30.z; + } + return true; + } + + return false; +} + +void func_80BC4038(BgF40Block* this) { + s32 temp = this->unk_160; + + this->unk_160 = this->unk_164; + this->unk_164 = temp; + this->unk_168 = 6; +} + +void BgF40Block_Init(Actor* thisx, GlobalContext* globalCtx) { + BgF40Block* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_f40_obj_Colheader_004640); + + if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) { + this->path = &globalCtx->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)]; + } else { + this->path = NULL; + } + + if (this->path != NULL) { + if (Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + this->actionFunc = func_80BC4530; + this->dyna.actor.speedXZ = 40.0f; + func_80BC3A2C(this, globalCtx); + } else { + this->actionFunc = func_80BC4380; + this->dyna.actor.speedXZ = 20.0f; + func_80BC3980(this, globalCtx); + } + } else { + this->actionFunc = func_80BC457C; + } + this->unk_168 = 6; +} + +void BgF40Block_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgF40Block* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80BC41AC(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3D08(this, globalCtx, 1)) { + if (!Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + func_80BC4038(this); + this->actionFunc = func_80BC44F4; + } + } else { + this->actionFunc = func_80BC4344; + } +} + +void func_80BC4228(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3B00(this)) { + this->dyna.actor.speedXZ = 20.0f; + if (this->unk_160 < (this->path->count - 1)) { + this->unk_164 = this->unk_160 + 1; + } else { + this->actionFunc = func_80BC4530; + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_C); + } + } + + if (func_80BC3D08(this, globalCtx, 0)) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->actionFunc = func_80BC41AC; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_F); + return; + } + + switch (this->unk_168) { + case 0: + case 3: + func_800B9010(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_MOVE_X - SFX_FLAG); + break; + + case 1: + case 4: + func_800B9010(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_MOVE_Y - SFX_FLAG); + break; + + case 2: + case 5: + func_800B9010(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_MOVE_Z - SFX_FLAG); + break; + } +} + +void func_80BC4344(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3CA4(this)) { + this->actionFunc = func_80BC4228; + } +} + +void func_80BC4380(BgF40Block* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + this->actionFunc = func_80BC4344; + } +} + +void func_80BC43CC(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3D08(this, globalCtx, 1)) { + if (Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + func_80BC4038(this); + this->actionFunc = func_80BC4344; + } + } else { + this->actionFunc = func_80BC44F4; + } +} + +void func_80BC4448(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3B00(this)) { + this->dyna.actor.speedXZ = 40.0f; + if (this->unk_160 > 0) { + this->unk_164 = this->unk_160 - 1; + } else { + this->actionFunc = func_80BC4380; + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_C); + } + } + + if (func_80BC3D08(this, globalCtx, 0)) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->actionFunc = func_80BC43CC; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_F); + } +} + +void func_80BC44F4(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3CA4(this)) { + this->actionFunc = func_80BC4448; + } +} + +void func_80BC4530(BgF40Block* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + this->actionFunc = func_80BC44F4; + } +} + +void func_80BC457C(BgF40Block* this, GlobalContext* globalCtx) { +} + +void BgF40Block_Update(Actor* thisx, GlobalContext* globalCtx) { + BgF40Block* this = THIS; + + this->actionFunc(this, globalCtx); + + Math_Vec3f_Copy(&this->dyna.actor.focus.pos, &this->dyna.actor.world.pos); +} + +void BgF40Block_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_f40_obj_DL_0043D0); +} diff --git a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h index 92b1d1e9e..cf9dfb03b 100644 --- a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h +++ b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h @@ -7,9 +7,15 @@ struct BgF40Block; typedef void (*BgF40BlockActionFunc)(struct BgF40Block*, GlobalContext*); +#define BGF40BLOCK_GET_PATH(thisx) (((thisx)->params & 0x1FC) >> 2) +#define BGF40BLOCK_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9) + typedef struct BgF40Block { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x28]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ Path* path; + /* 0x0160 */ s32 unk_160; + /* 0x0164 */ s32 unk_164; + /* 0x0168 */ s32 unk_168; /* 0x016C */ BgF40BlockActionFunc actionFunc; } BgF40Block; // size = 0x170 diff --git a/undefined_syms.txt b/undefined_syms.txt index 5b25825ae..b5da7029e 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -580,11 +580,6 @@ D_0600D228 = 0x0600D228; D_0601C6F4 = 0x0601C6F4; D_0601C8B4 = 0x0601C8B4; -// ovl_Bg_F40_Block - -D_060043D0 = 0x060043D0; -D_06004640 = 0x06004640; - // ovl_Bg_F40_Flift D_06004038 = 0x06004038; From f5ba6986f9e910e4bb48d49819b66774b0a76fb3 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 21:05:33 +0100 Subject: [PATCH 166/257] Obj_Pzlblock (#755) * Obj_Pzlblock * PR --- include/functions.h | 2 +- spec | 3 +- .../actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c | 343 ++++++++++++++++-- .../actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h | 19 +- 4 files changed, 341 insertions(+), 26 deletions(-) diff --git a/include/functions.h b/include/functions.h index 26de0794d..3f22bd67b 100644 --- a/include/functions.h +++ b/include/functions.h @@ -975,7 +975,7 @@ s32 DynaPolyActor_IsInRidingMovingState(DynaPolyActor* dynaActor); s32 DynaPolyActor_IsInRidingRotatingState(DynaPolyActor* dynaActor); s32 DynaPolyActor_IsInSwitchPressedState(DynaPolyActor* dynaActor); s32 DynaPolyActor_IsInHeavySwitchPressedState(DynaPolyActor* dynaActor); -s32 DynaPolyActor_ValidateMove(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 arg2, s16 arg3, s16 arg4); +s32 DynaPolyActor_ValidateMove(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 startRadius, s16 endRadius, s16 startHeight); f32 Camera_fabsf(f32 f); f32 Camera_LengthVec3f(Vec3f* v); // void func_800CB270(void); diff --git a/spec b/spec index 64b949c12..7a8a21569 100644 --- a/spec +++ b/spec @@ -2236,8 +2236,7 @@ beginseg name "ovl_Obj_Pzlblock" compress include "build/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.o" - include "build/data/ovl_Obj_Pzlblock/ovl_Obj_Pzlblock.data.o" - include "build/data/ovl_Obj_Pzlblock/ovl_Obj_Pzlblock.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Pzlblock/ovl_Obj_Pzlblock_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c index d6f35c491..95b9a3a13 100644 --- a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c +++ b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c @@ -5,6 +5,8 @@ */ #include "z_obj_pzlblock.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" +#include "objects/object_secom_obj/object_secom_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_4000000) @@ -14,7 +16,15 @@ void ObjPzlblock_Init(Actor* thisx, GlobalContext* globalCtx); void ObjPzlblock_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjPzlblock_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_809A3A48(ObjPzlblock* this); +void func_809A3A74(ObjPzlblock* this, GlobalContext* globalCtx); +void func_809A3BA4(ObjPzlblock* this); +void func_809A3BC0(ObjPzlblock* this, GlobalContext* globalCtx); +void func_809A3D1C(ObjPzlblock* this); +void func_809A3D38(ObjPzlblock* this, GlobalContext* globalCtx); +void func_809A3E58(Actor* thisx, GlobalContext* globalCtx); +void func_809A3F0C(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Obj_Pzlblock_InitVars = { ACTOR_OBJ_PZLBLOCK, ACTORCAT_PROP, @@ -27,46 +37,337 @@ const ActorInit Obj_Pzlblock_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809A4078[] = { +s16 D_809A4050[] = { 1, -1, 0, 0 }; +s16 D_809A4058[] = { 0, 0, 1, -1 }; + +typedef struct { + /* 0x0 */ s16 unk_00; + /* 0x4 */ CollisionHeader* unk_04; + /* 0x8 */ Gfx* unk_08; +} ObjPzlblockStruct; + +ObjPzlblockStruct D_809A4060[] = { + { GAMEPLAY_DANGEON_KEEP, &gameplay_dangeon_keep_Colheader_01D488, gameplay_dangeon_keep_DL_01C228 }, + { OBJECT_SECOM_OBJ, &object_secom_obj_Colheader_002CB8, object_secom_obj_DL_001A58 }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3S(world.rot, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -#endif +Color_RGB8 D_809A4088[] = { + { 180, 150, 250 }, { 100, 180, 150 }, { 0, 0, 255 }, { 255, 255, 0 }, + { 0, 255, 255 }, { 255, 0, 255 }, { 0, 0, 0 }, { 255, 255, 255 }, +}; -extern InitChainEntry D_809A4078[]; +s32 func_809A33E0(ObjPzlblock* this, GlobalContext* globalCtx, s16 arg2) { + return !DynaPolyActor_ValidateMove(globalCtx, &this->dyna, 30, arg2, 1) || + !DynaPolyActor_ValidateMove(globalCtx, &this->dyna, 30, arg2, 28); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A33E0.s") +s32 func_809A3448(ObjPzlblock* this) { + s16 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3448.s") + if (fabsf(this->dyna.pushForce) > 0.1f) { + temp_v0 = BINANG_ADD(this->dyna.yRotation, 0x2000); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A34E0.s") + if (this->dyna.pushForce < 0.0f) { + temp_v0 = BINANG_ROT180(temp_v0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A35EC.s") + if (temp_v0 < -0x4000) { + return 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A376C.s") + if (temp_v0 < 0) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/ObjPzlblock_Init.s") + if (temp_v0 < 0x4000) { + return 2; + } + return 0; + } + return -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/ObjPzlblock_Destroy.s") +s32 func_809A34E0(ObjPzlblock* this, s32 arg1) { + s32 temp_v0 = OBJPZLBLOCK_GET_ROTZ(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3A48.s") + if (temp_v0 == 0) { + return arg1 == 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3A74.s") + if (temp_v0 == 1) { + return arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3BA4.s") + if (temp_v0 == 2) { + return arg1 == 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3BC0.s") + if (temp_v0 == 3) { + return arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3D1C.s") + if (temp_v0 == 4) { + return arg1 == 0 || arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3D38.s") + if (temp_v0 == 5) { + return arg1 == 2 || arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/ObjPzlblock_Update.s") + if (temp_v0 == 6) { + if (this->unk_176 != 0) { + return arg1 == 0 || arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3E58.s") + if (this->unk_178 != 0) { + return arg1 == 2 || arg1 == 3; + } + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3F0C.s") +s32 func_809A35EC(ObjPzlblock* this, s32 arg1) { + s32 temp_v0 = OBJPZLBLOCK_GET_ROTZ(&this->dyna.actor); + s32 temp_v1 = this->dyna.actor.home.rot.x & 0xF; + s32 temp; + + if (temp_v0 == 0) { + return this->unk_176 < temp_v1; + } + + if (temp_v0 == 1) { + return -temp_v1 < this->unk_176; + } + + if (temp_v0 == 2) { + return this->unk_178 < temp_v1; + } + + if (temp_v0 == 3) { + return -temp_v1 < this->unk_178; + } + + if (temp_v0 == 4) { + temp = D_809A4050[arg1] + this->unk_176; + return (temp_v1 >= temp) && (-temp_v1 <= temp); + } + + if (temp_v0 == 5) { + temp = D_809A4058[arg1] + this->unk_178; + return (temp_v1 >= temp) && (-temp_v1 <= temp); + } + + if (temp_v0 == 6) { + if ((arg1 == 0) || (arg1 == 1)) { + temp = D_809A4050[arg1] + this->unk_176; + return (temp_v1 >= temp) && (-temp_v1 <= temp); + } + + temp = D_809A4058[arg1] + this->unk_178; + return (temp_v1 >= temp) && (-temp_v1 <= temp); + } + + return false; +} + +void func_809A376C(ObjPzlblock* this, s32 arg1) { + this->unk_176 += D_809A4050[arg1]; + this->unk_178 += D_809A4058[arg1]; + if ((arg1 == 0) || (arg1 == 1)) { + this->unk_164 = &this->dyna.actor.world.pos.x; + this->unk_168 = this->dyna.actor.home.pos.x + (this->unk_176 * 60); + } else { + this->unk_164 = &this->dyna.actor.world.pos.z; + this->unk_168 = this->dyna.actor.home.pos.z + (this->unk_178 * 60); + } + this->unk_16C = arg1; +} + +void ObjPzlblock_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjPzlblock* this = THIS; + s32 sp2C = OBJPZLBLOCK_GET_ROTZ(&this->dyna.actor); + s32 sp28 = this->dyna.actor.home.rot.x & 0xF; + ObjPzlblockStruct* sp24 = &D_809A4060[OBJPZLBLOCK_GET_1000(&this->dyna.actor)]; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_SetScale(&this->dyna.actor, 0.1f); + + this->dyna.actor.home.rot.y = 0; + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + + DynaPolyActor_Init(&this->dyna, 0); + + this->unk_17A = Object_GetIndex(&globalCtx->objectCtx, sp24->unk_00); + + if (sp28 == 0) { + func_809A3D1C(this); + } else if (Flags_GetSwitch(globalCtx, OBJPZLBLOCK_GET_7F(&this->dyna.actor))) { + if (sp2C == 0) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + (sp28 * 60); + func_809A3D1C(this); + } else if (sp2C == 1) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x - (sp28 * 60); + func_809A3D1C(this); + } else if (sp2C == 2) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + (sp28 * 60); + func_809A3D1C(this); + } else if (sp2C == 3) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z - (sp28 * 60); + func_809A3D1C(this); + } else { + func_809A3A48(this); + } + } else { + func_809A3A48(this); + } +} + +void ObjPzlblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjPzlblock* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_809A3A48(ObjPzlblock* this) { + this->actionFunc = func_809A3A74; + this->unk_16E[1] = 0; + this->unk_16E[2] = 0; + this->unk_16E[3] = 0; + this->unk_16E[0] = 0; + this->unk_160 = 4; +} + +void func_809A3A74(ObjPzlblock* this, GlobalContext* globalCtx) { + s32 i; + s32 sp20 = func_809A3448(this); + + for (i = 0; i < ARRAY_COUNT(this->unk_16E); i++) { + if (sp20 == i) { + this->unk_16E[i]++; + } else if (this->unk_16E[i] > 0) { + this->unk_16E[i]--; + } + } + + if (sp20 != -1) { + if ((this->unk_16E[sp20] >= 11) && func_809A34E0(this, sp20) && func_809A35EC(this, sp20)) { + if (!func_809A33E0(this, globalCtx, (this->dyna.pushForce > 0.0f) ? 90 : 120)) { + func_809A376C(this, sp20); + func_809A3BA4(this); + return; + } + } + + GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } +} + +void func_809A3BA4(ObjPzlblock* this) { + this->actionFunc = func_809A3BC0; + this->unk_160 = 5; +} + +void func_809A3BC0(ObjPzlblock* this, GlobalContext* globalCtx) { + if (Math_StepToF(this->unk_164, this->unk_168, 2.3f)) { + Player* player = GET_PLAYER(globalCtx); + s32 params = OBJPZLBLOCK_GET_ROTZ(&this->dyna.actor); + s32 pad; + s32 sp20 = 0; + + if ((params == 4) || (params == 5) || (params == 6)) { + if (!func_809A35EC(this, this->unk_16C) || func_809A33E0(this, globalCtx, 0x5A)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else if (func_809A35EC(this, this->unk_16C)) { + if (func_809A33E0(this, globalCtx, 0x5A)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Flags_SetSwitch(globalCtx, OBJPZLBLOCK_GET_7F(&this->dyna.actor)); + sp20 = 1; + } + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + if (sp20 == 0) { + func_809A3A48(this); + } else { + func_809A3D1C(this); + } + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + } +} + +void func_809A3D1C(ObjPzlblock* this) { + this->actionFunc = func_809A3D38; + this->unk_160 = 4; +} + +void func_809A3D38(ObjPzlblock* this, GlobalContext* globalCtx) { + if (fabsf(this->dyna.pushForce) > 0.1f) { + GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } +} + +void ObjPzlblock_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjPzlblock* this = THIS; + + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 15.0f, 30.0f, 0.0f, 4); + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_17A)) { + ObjPzlblockStruct* sp2C = &D_809A4060[OBJPZLBLOCK_GET_1000(&this->dyna.actor)]; + + this->dyna.actor.objBankIndex = this->unk_17A; + Actor_SetObjectDependency(globalCtx, &this->dyna.actor); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, sp2C->unk_04); + this->dyna.actor.update = func_809A3E58; + this->dyna.actor.draw = func_809A3F0C; + } +} + +void func_809A3E58(Actor* thisx, GlobalContext* globalCtx) { + ObjPzlblock* this = THIS; + + this->actionFunc(this, globalCtx); + + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + + if (this->unk_160 != 0) { + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 15.0f, 30.0f, 0.0f, this->unk_160); + if (((this->actionFunc == func_809A3A74) || (this->actionFunc == func_809A3D38)) && + (this->dyna.actor.bgCheckFlags & 1) && !DynaPoly_GetActor(&globalCtx->colCtx, this->dyna.actor.floorBgId)) { + this->unk_160 = 0; + } + } +} + +void func_809A3F0C(Actor* thisx, GlobalContext* globalCtx) { + ObjPzlblockStruct* sp2C = &D_809A4060[OBJPZLBLOCK_GET_1000(thisx)]; + Color_RGB8* sp28 = &D_809A4088[OBJPZLBLOCK_GET_700(thisx)]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sp28->r, sp28->g, sp28->b, 255); + gSPDisplayList(POLY_OPA_DISP++, sp2C->unk_08); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h index 437583f62..fa1ca1f59 100644 --- a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h +++ b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h @@ -5,9 +5,24 @@ struct ObjPzlblock; +typedef void (*ObjPzlblockActionFunc)(struct ObjPzlblock*, GlobalContext*); + +#define OBJPZLBLOCK_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJPZLBLOCK_GET_700(thisx) (((thisx)->params >> 8) & 7) +#define OBJPZLBLOCK_GET_1000(thisx) (((thisx)->params >> 0xC) & 1) +#define OBJPZLBLOCK_GET_ROTZ(thisx) ((thisx)->home.rot.z & 7) + typedef struct ObjPzlblock { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x38]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjPzlblockActionFunc actionFunc; + /* 0x160 */ s32 unk_160; + /* 0x164 */ f32* unk_164; + /* 0x168 */ f32 unk_168; + /* 0x16C */ s16 unk_16C; + /* 0x16E */ s16 unk_16E[4]; + /* 0x176 */ s16 unk_176; + /* 0x178 */ s16 unk_178; + /* 0x17A */ s8 unk_17A; } ObjPzlblock; // size = 0x17C extern const ActorInit Obj_Pzlblock_InitVars; From 98143afb1c64c8f7a1599e3207578bd0c93bec93 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 21:14:29 +0100 Subject: [PATCH 167/257] En_Test (#756) * En_Test * PR * PR * PR * Fix --- assets/xml/objects/gameplay_keep.xml | 6 +- spec | 3 +- src/overlays/actors/ovl_En_Test/z_en_test.c | 247 +++++++++++++++++++- src/overlays/actors/ovl_En_Test/z_en_test.h | 20 +- tools/disasm/functions.txt | 2 +- 5 files changed, 261 insertions(+), 17 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 009bc87ae..86f48d61d 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1262,7 +1262,8 @@ - + + @@ -1271,7 +1272,8 @@ - + + diff --git a/spec b/spec index 7a8a21569..8014652dd 100644 --- a/spec +++ b/spec @@ -736,8 +736,7 @@ beginseg name "ovl_En_Test" compress include "build/src/overlays/actors/ovl_En_Test/z_en_test.o" - include "build/data/ovl_En_Test/ovl_En_Test.data.o" - include "build/data/ovl_En_Test/ovl_En_Test.reloc.o" + include "build/src/overlays/actors/ovl_En_Test/ovl_En_Test_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.c b/src/overlays/actors/ovl_En_Test/z_en_test.c index 0a0b86ea1..7f99833b4 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -5,6 +5,7 @@ */ #include "z_en_test.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,6 @@ void EnTest_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTest_Update(Actor* thisx, GlobalContext* globalCtx); void EnTest_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Test_InitVars = { ACTOR_EN_TEST, ACTORCAT_ITEMACTION, @@ -28,22 +28,247 @@ const ActorInit En_Test_InitVars = { (ActorFunc)EnTest_Draw, }; -#endif +void func_80862B70(EnTestStruct* arg0) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_80862B70.s") + for (i = 0; i < 20; i++) { + EnTestStruct* ptr = &arg0[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_80862CBC.s") + ptr->unk_00 = false; + ptr->unk_04 = 0; + ptr->unk_08.x = 0.0f; + ptr->unk_08.y = 0.0f; + ptr->unk_08.z = 0.0f; + ptr->unk_14.x = 0.0f; + ptr->unk_14.y = 0.0f; + ptr->unk_14.z = 0.0f; + ptr->unk_20.x = 0.0f; + ptr->unk_20.y = 0.0f; + ptr->unk_20.z = 0.0f; + ptr->unk_2C = 0.001f; + ptr->unk_30.x = 0; + ptr->unk_30.y = 0; + ptr->unk_30.z = 0; + ptr->unk_36.x = 0; + ptr->unk_36.y = 0; + ptr->unk_36.z = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_80862EDC.s") +void func_80862CBC(EnTestStruct* arg0, Vec3f* arg1) { + EnTestStruct* ptr; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_80863048.s") + for (i = 0; i < 20; i++) { + ptr = &arg0[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/EnTest_Init.s") + if (!ptr->unk_00) { + s16 sp26 = Rand_ZeroOne() * 0xFFFF; + f32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/EnTest_Destroy.s") + ptr->unk_00 = true; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/EnTest_Update.s") + ptr->unk_08.x = (Math_CosS(sp26) * 20.0f) + arg1->x; + ptr->unk_08.y = arg1->y; + ptr->unk_08.z = (Math_SinS(sp26) * 20.0f) + arg1->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_808634B8.s") + sp20 = Rand_ZeroOne(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/EnTest_Draw.s") + ptr->unk_14.x = Math_CosS(sp26) * 13.0f * sp20; + ptr->unk_14.y = (Rand_ZeroOne() * 5.0f) + 8.0f; + ptr->unk_14.z = (Math_SinS(sp26) * 13.0f) * sp20; + + ptr->unk_20.x = 0.0f; + ptr->unk_20.z = 0.0f; + ptr->unk_20.y = -2.0f; + + ptr->unk_2C = (Rand_ZeroOne() * 0.0004f) + 0.0004f; + + ptr->unk_30.x = Rand_ZeroOne() * 0x7FFE; + ptr->unk_30.y = Rand_ZeroOne() * 0x7FFE; + ptr->unk_30.z = Rand_ZeroOne() * 0x7FFE; + + ptr->unk_36.x = Rand_ZeroOne() * 0x2000; + ptr->unk_36.y = Rand_ZeroOne() * 0x2000; + ptr->unk_36.z = Rand_ZeroOne() * 0x2000; + + ptr->unk_04 = 10; + break; + } + } +} + +void func_80862EDC(EnTestStruct* arg0) { + s32 i; + EnTestStruct* ptr; + + for (i = 0; i < 20; i++) { + ptr = &arg0[i]; + + if (ptr->unk_00) { + ptr->unk_04--; + if (ptr->unk_04 < 0) { + ptr->unk_00 = false; + } + + ptr->unk_08.x += ptr->unk_14.x; + ptr->unk_08.y += ptr->unk_14.y; + ptr->unk_08.z += ptr->unk_14.z; + + ptr->unk_14.x += ptr->unk_20.x; + ptr->unk_14.y += ptr->unk_20.y; + ptr->unk_14.z += ptr->unk_20.z; + + ptr->unk_30.x += ptr->unk_36.x; + ptr->unk_30.y += ptr->unk_36.y; + ptr->unk_30.z += ptr->unk_36.z; + } + } +} + +void func_80863048(GlobalContext* globalCtx, EnTestStruct* arg1) { + EnTestStruct* ptr; + s32 i; + Mtx* mtx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + + for (i = 0; i < 20; i++) { + ptr = &arg1[i]; + + if (!ptr->unk_00) { + continue; + } + + Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + Matrix_InsertRotation(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + Matrix_Scale(ptr->unk_2C, ptr->unk_2C, ptr->unk_2C, MTXMODE_APPLY); + + mtx = Matrix_NewMtx(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06AB30); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnTest_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTest* this = THIS; + MtxF sp38; + s32 sp34; + + this->unk_209 = 0; + this->unk_174 = 0; + + if (thisx->params > 0) { + Actor_SetScale(thisx, thisx->params / 100000.0f); + this->unk_20A = 0; + } else { + thisx->floorPoly = NULL; + thisx->world.pos.y += 10.0f; + thisx->floorHeight = + BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &thisx->floorPoly, &sp34, &thisx->world.pos); + + if ((thisx->floorPoly == NULL) || (thisx->floorHeight == BGCHECK_Y_MIN)) { + Actor_MarkForDeath(thisx); + return; + } + + thisx->world.pos.y = thisx->floorHeight; + func_800C0094(thisx->floorPoly, thisx->world.pos.x, thisx->floorHeight, thisx->world.pos.z, &sp38); + func_8018219C(&sp38, &thisx->shape.rot, 1); + thisx->world.rot = thisx->shape.rot; + this->unk_20A = func_800C9BB8(&globalCtx->colCtx, thisx->floorPoly, sp34); + } + + func_80183430(&this->skeletonInfo, &gameplay_keep_Blob_06EB70, &gameplay_keep_Blob_06BB0C, this->unk_178, + this->unk_1C0, NULL); + func_801834A8(&this->skeletonInfo, &gameplay_keep_Blob_06BB0C); + this->skeletonInfo.frameCtrl.unk_10 = 9.0f; + func_80862B70(this->unk_20C); +} + +void EnTest_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTest* this = THIS; + + func_8018349C(&this->skeletonInfo); +} + +void EnTest_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTest* this = THIS; + s32 i; + + this->unk_208 = this->skeletonInfo.frameCtrl.unk_10; + + if (func_80183DE0(&this->skeletonInfo) && (this->actor.parent == NULL) && (this->actor.params != -1)) { + this->unk_209++; + if (this->unk_209 > 20) { + Actor_MarkForDeath(&this->actor); + } + } + + if ((this->actor.params != -1) && (this->unk_208 >= 2)) { + if (!(this->unk_174 & 1)) { + this->unk_174 |= 1; + + for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { + func_80862CBC(this->unk_20C, &this->actor.world.pos); + } + } + } + func_80862EDC(this->unk_20C); +} + +s32 EnTest_OverrideKeyframeDraw(GlobalContext* globalCtx, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList, + u8* flags, Actor* thisx, Vec3f* scale, Vec3s* rot, Vec3f* pos) { + EnTest* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((this->actor.params == -1) && ((limbIndex == 1) || (limbIndex == 2))) { + *dList = NULL; + } + + if ((this->actor.params == -2) && (limbIndex == 3)) { + *dList = NULL; + } + + if (limbIndex == 3) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 0, 0, 0, ((20 - this->unk_209) * 255.0f) / 20.0f); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, ((20 - this->unk_209) * 255.0f) / 20.0f); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + return true; +} + +void EnTest_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTest* this = THIS; + Mtx* sp28; + s32 sp2C = this->unk_208 - 1; + + if (sp2C >= 29) { + sp2C = 29; + } + + if ((this->unk_20A == 15) || (this->unk_20A == 14)) { + AnimatedMat_DrawStep(globalCtx, Lib_SegmentedToVirtual(gameplay_keep_Matanimheader_06B730), sp2C); + } else { + AnimatedMat_DrawStep(globalCtx, Lib_SegmentedToVirtual(gameplay_keep_Matanimheader_06B6A0), sp2C); + } + + sp28 = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(this->skeletonInfo.unk_18->unk_1 * sizeof(Mtx))); + + if (sp28 != NULL) { + func_8012C2DC(globalCtx->state.gfxCtx); + func_8018450C(globalCtx, &this->skeletonInfo, sp28, EnTest_OverrideKeyframeDraw, NULL, thisx); + func_80863048(globalCtx, this->unk_20C); + } +} diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.h b/src/overlays/actors/ovl_En_Test/z_en_test.h index 32015ecb1..bcb0c4a1e 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.h +++ b/src/overlays/actors/ovl_En_Test/z_en_test.h @@ -5,9 +5,27 @@ struct EnTest; +typedef struct { + /* 0x00 */ s32 unk_00; + /* 0x04 */ s32 unk_04; + /* 0x08 */ Vec3f unk_08; + /* 0x14 */ Vec3f unk_14; + /* 0x20 */ Vec3f unk_20; + /* 0x2C */ f32 unk_2C; + /* 0x30 */ Vec3s unk_30; + /* 0x36 */ Vec3s unk_36; +} EnTestStruct; // size = 0x3C + typedef struct EnTest { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x578]; + /* 0x144 */ SkeletonInfo skeletonInfo; + /* 0x174 */ s32 unk_174; + /* 0x178 */ Vec3s unk_178[12]; + /* 0x1C0 */ s16 unk_1C0[36]; + /* 0x208 */ u8 unk_208; + /* 0x209 */ u8 unk_209; + /* 0x20A */ u8 unk_20A; + /* 0x20C */ EnTestStruct unk_20C[20]; } EnTest; // size = 0x6BC extern const ActorInit En_Test_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 9ff9270d7..46d871372 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -4893,7 +4893,7 @@ 0x80863188:("EnTest_Init",), 0x80863310:("EnTest_Destroy",), 0x8086333C:("EnTest_Update",), - 0x808634B8:("func_808634B8",), + 0x808634B8:("EnTest_OverrideKeyframeDraw",), 0x808636A8:("EnTest_Draw",), 0x80863870:("EnGirlA_SetupAction",), 0x8086387C:("EnGirlA_InitObjIndex",), From 7ea2474b71901d5cc93b4193a8a3b7faea6dd251 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 21:21:56 +0100 Subject: [PATCH 168/257] En_Kujiya (#757) * En_Kujiya * En_Kujiya * PR --- spec | 3 +- .../actors/ovl_En_Kujiya/z_en_kujiya.c | 341 ++++++++++++++++-- .../actors/ovl_En_Kujiya/z_en_kujiya.h | 7 +- undefined_syms.txt | 15 - 4 files changed, 322 insertions(+), 44 deletions(-) diff --git a/spec b/spec index 8014652dd..bdfcef79a 100644 --- a/spec +++ b/spec @@ -4445,8 +4445,7 @@ beginseg name "ovl_En_Kujiya" compress include "build/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.o" - include "build/data/ovl_En_Kujiya/ovl_En_Kujiya.data.o" - include "build/data/ovl_En_Kujiya/ovl_En_Kujiya.reloc.o" + include "build/src/overlays/actors/ovl_En_Kujiya/ovl_En_Kujiya_reloc.o" endseg beginseg 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 cde905653..0e2bbf3eb 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c @@ -5,6 +5,7 @@ */ #include "z_en_kujiya.h" +#include "objects/object_kujiya/object_kujiya.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_8000000) @@ -15,14 +16,22 @@ void EnKujiya_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKujiya_Update(Actor* thisx, GlobalContext* globalCtx); void EnKujiya_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80BB09A8(EnKujiya* this); void func_80BB09BC(EnKujiya* this, GlobalContext* globalCtx); +void func_80BB0E44(EnKujiya* this); void func_80BB0E58(EnKujiya* this, GlobalContext* globalCtx); +void func_80BB0F24(EnKujiya* this); void func_80BB0F38(EnKujiya* this, GlobalContext* globalCtx); +void func_80BB0F94(EnKujiya* this); void func_80BB0FA8(EnKujiya* this, GlobalContext* globalCtx); +s32 func_80BB0FF8(void); +void func_80BB1088(void); +void func_80BB10F8(void); +void func_80BB1168(EnKujiya* this); void func_80BB1180(EnKujiya* this, GlobalContext* globalCtx); +void func_80BB1250(EnKujiya* this); void func_80BB1268(EnKujiya* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Kujiya_InitVars = { ACTOR_EN_KUJIYA, ACTORCAT_NPC, @@ -35,48 +44,332 @@ const ActorInit En_Kujiya_InitVars = { (ActorFunc)EnKujiya_Draw, }; -#endif +#define CHECK_LOTTERY_NUMBERS \ + (((u32)((void)0, gSaveContext.save.lotteryCodes[CURRENT_DAY - 1][0]) == \ + ((((void)0, gSaveContext.save.lotteryCodeGuess & 0xFFFF) & 0xF00) >> 8)) && \ + ((u32)((void)0, gSaveContext.save.lotteryCodes[CURRENT_DAY - 1][1]) == \ + ((((void)0, gSaveContext.save.lotteryCodeGuess & 0xFFFF) & 0xF0) >> 4)) && \ + ((u32)((void)0, gSaveContext.save.lotteryCodes[CURRENT_DAY - 1][2]) == \ + (((void)0, gSaveContext.save.lotteryCodeGuess & 0xFFFF) & 0xF))) -extern UNK_TYPE D_06006198; +void EnKujiya_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKujiya* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/EnKujiya_Init.s") + Actor_SetScale(&this->actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/EnKujiya_Destroy.s") + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.targetMode = 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB09A8.s") + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 30.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB09BC.s") + if (func_80BB0FF8() && (gSaveContext.save.time >= CLOCK_TIME(6, 0)) && + (gSaveContext.save.time < CLOCK_TIME(18, 0))) { + this->actor.shape.rot.y = 0; + } else { + this->actor.shape.rot.y = 0x7555; + } + func_80BB09A8(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0B28.s") +void EnKujiya_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0BF8.s") +void func_80BB09A8(EnKujiya* this) { + this->actionFunc = func_80BB09BC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0E44.s") +void func_80BB09BC(EnKujiya* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time < CLOCK_TIME(18, 0))) { + if (func_80BB0FF8()) { + Message_StartTextbox(globalCtx, 0x2B61, &this->actor); + this->unk_14A = 0x2B61; + } else { + Message_StartTextbox(globalCtx, 0x2B5C, &this->actor); + this->unk_14A = 0x2B5C; + } + } else if (func_80BB0FF8()) { + Message_StartTextbox(globalCtx, 0x2B64, &this->actor); + this->unk_14A = 0x2B64; + } else { + Message_StartTextbox(globalCtx, 0x2B63, &this->actor); + this->unk_14A = 0x2B63; + } + func_80BB0E44(this); + } else if ((gSaveContext.save.time >= CLOCK_TIME(18, 0)) && func_80BB0FF8() && (this->actor.shape.rot.y == 0)) { + func_80BB1168(this); + } else if (this->actor.xzDistToPlayer < 100.0f) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0E58.s") +void func_80BB0B28(EnKujiya* this, GlobalContext* globalCtx) { + if (Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.choiceIndex == 0) { + if (gSaveContext.save.playerData.rupees < 10) { + play_sound(NA_SE_SY_ERROR); + Message_StartTextbox(globalCtx, 0x2B62, &this->actor); + this->unk_14A = 0x2B62; + } else { + func_8019F208(); + func_801159EC(-10); + Message_StartTextbox(globalCtx, 0x2B5F, &this->actor); + this->unk_14A = 0x2B5F; + } + } else { + func_8019F230(); + Message_StartTextbox(globalCtx, 0x2B5E, &this->actor); + this->unk_14A = 0x2B5E; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0F24.s") +void func_80BB0BF8(EnKujiya* this, GlobalContext* globalCtx) { + u32 lotteryCode; + s8 digit1; + s8 digit2; + s8 digit3; + s8* lotteryCodes; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0F38.s") + if (this->unk_14A == 0x2B65) { + if (this->unk_148 != 0) { + this->unk_148--; + return; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0F94.s") + if (Message_ShouldAdvance(globalCtx)) { + switch (this->unk_14A) { + case 0x2B5C: + Message_StartTextbox(globalCtx, 0x2B5D, &this->actor); + this->unk_14A = 0x2B5D; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0FA8.s") + case 0x2B60: + func_80BB1088(); + func_801477B4(globalCtx); + func_80BB1250(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0FF8.s") + case 0x2B64: + func_80BB10F8(); + this->unk_148 = 0x14; + Message_StartTextbox(globalCtx, 0x2B65, &this->actor); + this->unk_14A = 0x2B65; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1088.s") + case 0x2B65: + if (CHECK_LOTTERY_NUMBERS) { + Message_StartTextbox(globalCtx, 0x2B66, &this->actor); + this->unk_14A = 0x2B66; + } else { + Message_StartTextbox(globalCtx, 0x2B67, &this->actor); + this->unk_14A = 0x2B67; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB10F8.s") + case 0x2B66: + func_801477B4(globalCtx); + func_80BB0F24(this); + func_80BB0F38(this, globalCtx); + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1168.s") +void func_80BB0E44(EnKujiya* this) { + this->actionFunc = func_80BB0E58; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1180.s") +void func_80BB0E58(EnKujiya* this, GlobalContext* globalCtx) { + switch (Message_GetState(&globalCtx->msgCtx)) { + case 0: + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1250.s") + case 4: + func_80BB0B28(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1268.s") + case 5: + func_80BB0BF8(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/EnKujiya_Update.s") + case 6: + if (Message_ShouldAdvance(globalCtx)) { + func_80BB09A8(this); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/EnKujiya_Draw.s") + case 17: + if (Message_ShouldAdvance(globalCtx)) { + Inventory_SaveLotteryCodeGuess(globalCtx); + Message_StartTextbox(globalCtx, 0x2B60, &this->actor); + this->unk_14A = 0x2B60; + } + break; + } +} + +void func_80BB0F24(EnKujiya* this) { + this->actionFunc = func_80BB0F38; +} + +void func_80BB0F38(EnKujiya* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + func_80BB0F94(this); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + } +} + +void func_80BB0F94(EnKujiya* this) { + this->actionFunc = func_80BB0FA8; +} + +void func_80BB0FA8(EnKujiya* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { + func_80BB09A8(this); + } +} + +s32 func_80BB0FF8(void) { + switch (CURRENT_DAY) { + case 1: + if (gSaveContext.save.weekEventReg[33] & 0x10) { + return true; + } + break; + + case 2: + if (gSaveContext.save.weekEventReg[33] & 0x20) { + return true; + } + break; + + case 3: + if (gSaveContext.save.weekEventReg[33] & 0x40) { + return true; + } + break; + } + return false; +} + +void func_80BB1088(void) { + switch (CURRENT_DAY) { + case 1: + gSaveContext.save.weekEventReg[33] |= 0x10; + break; + + case 2: + gSaveContext.save.weekEventReg[33] |= 0x20; + break; + + case 3: + gSaveContext.save.weekEventReg[33] |= 0x40; + break; + } +} + +void func_80BB10F8(void) { + switch (CURRENT_DAY) { + case 1: + gSaveContext.save.weekEventReg[33] &= (u8)~0x10; + break; + + case 2: + gSaveContext.save.weekEventReg[33] &= (u8)~0x20; + break; + + case 3: + gSaveContext.save.weekEventReg[33] &= (u8)~0x40; + break; + } +} + +void func_80BB1168(EnKujiya* this) { + this->unk_148 = 0; + this->actionFunc = func_80BB1180; +} + +void func_80BB1180(EnKujiya* this, GlobalContext* globalCtx) { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + + if (!Math_SmoothStepToS(&this->actor.shape.rot.y, 0x7555, 0xA, 0x16C, 0x16C)) { + if (this->unk_148 > 20) { + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + func_80BB09A8(this); + } else { + this->unk_148++; + } + } else { + func_800B9010(&this->actor, NA_SE_EV_WINDMILL_LEVEL - SFX_FLAG); + } +} + +void func_80BB1250(EnKujiya* this) { + this->unk_148 = 0; + this->actionFunc = func_80BB1268; +} + +void func_80BB1268(EnKujiya* this, GlobalContext* globalCtx) { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + + if (!Math_SmoothStepToS(&this->actor.shape.rot.y, 0, 0xA, 0x16C, 0x16C)) { + if (this->unk_148 > 20) { + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + func_80BB09A8(this); + } else { + this->unk_148++; + } + } else { + func_800B9010(&this->actor, NA_SE_EV_WINDMILL_LEVEL - SFX_FLAG); + } +} + +void EnKujiya_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKujiya* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void EnKujiya_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKujiya* this = THIS; + + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_kujiya_Matanimheader_006198)); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_002A80); + gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_003030); + gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_003248); + gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_003358); + gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_0034A8); + gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_0035B8); + gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_0036B0); + gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_0037C0); + gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_003C80); + gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_003D58); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h index 72aeb93b7..bfb50e5af 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h @@ -8,9 +8,10 @@ struct EnKujiya; typedef void (*EnKujiyaActionFunc)(struct EnKujiya*, GlobalContext*); typedef struct EnKujiya { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnKujiyaActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnKujiyaActionFunc actionFunc; + /* 0x148 */ s16 unk_148; + /* 0x14A */ s16 unk_14A; } EnKujiya; // size = 0x14C extern const ActorInit En_Kujiya_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index b5da7029e..733319036 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1377,21 +1377,6 @@ D_06021E34 = 0x06021E34; D_06022728 = 0x06022728; D_06022CAC = 0x06022CAC; -// ovl_En_Kujiya - -D_06002A80 = 0x06002A80; -D_06003030 = 0x06003030; -D_06003248 = 0x06003248; -D_06003358 = 0x06003358; -D_060034A8 = 0x060034A8; -D_060035B8 = 0x060035B8; -D_060036B0 = 0x060036B0; -D_060037C0 = 0x060037C0; -D_06003C80 = 0x06003C80; -D_06003D58 = 0x06003D58; -D_06006198 = 0x06006198; - - // ovl_En_Lift_Nuts D_060029E8 = 0x060029E8; From cabb14e4b71009261e12e762bbbda25d465af32d Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 21:29:35 +0100 Subject: [PATCH 169/257] Obj_Smork (#758) * Obj_Smork * PR * PR --- assets/xml/overlays/ovl_Obj_Smork.xml | 7 + spec | 3 +- .../actors/ovl_En_Kanban/z_en_kanban.h | 2 +- .../actors/ovl_Obj_Smork/z_obj_smork.c | 125 ++++++++++++++++-- .../actors/ovl_Obj_Smork/z_obj_smork.h | 8 +- undefined_syms.txt | 4 - 6 files changed, 131 insertions(+), 18 deletions(-) create mode 100644 assets/xml/overlays/ovl_Obj_Smork.xml diff --git a/assets/xml/overlays/ovl_Obj_Smork.xml b/assets/xml/overlays/ovl_Obj_Smork.xml new file mode 100644 index 000000000..745c6b6af --- /dev/null +++ b/assets/xml/overlays/ovl_Obj_Smork.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/spec b/spec index bdfcef79a..4b23e0551 100644 --- a/spec +++ b/spec @@ -2788,8 +2788,7 @@ beginseg name "ovl_Obj_Smork" compress include "build/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.o" - include "build/data/ovl_Obj_Smork/ovl_Obj_Smork.data.o" - include "build/data/ovl_Obj_Smork/ovl_Obj_Smork.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Smork/ovl_Obj_Smork_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h index b667bd9e8..201364bc0 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h @@ -66,7 +66,7 @@ typedef enum { typedef struct EnKanban { /* 0x000 */ Actor actor; - /* 0x144 */ UNK_TYPE1 unk144[4]; // actionFunc? + /* 0x144 */ UNK_TYPE1 unk_144[4]; // actionFunc? /* 0x148 */ u8 frameCount; /* 0x14A */ s16 airTimer; /* 0x14C */ u8 actionState; diff --git a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c index badd4318e..ded17da2d 100644 --- a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c +++ b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c @@ -5,6 +5,7 @@ */ #include "z_obj_smork.h" +#include "objects/object_f53_obj/object_f53_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +16,6 @@ void ObjSmork_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSmork_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSmork_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Smork_InitVars = { ACTOR_OBJ_SMORK, ACTORCAT_PROP, @@ -28,20 +28,125 @@ const ActorInit Obj_Smork_InitVars = { (ActorFunc)ObjSmork_Draw, }; -#endif +#include "overlays/ovl_Obj_Smork/ovl_Obj_Smork.c" -extern UNK_TYPE D_06001C00; +u8 func_80A3D680(s16 arg0) { + u8 ret = 0; + s16 temp_f18 = TIME_TO_MINUTES_F(gSaveContext.save.time); + s32 hours = temp_f18 / 60; + s32 minutes = temp_f18 % 60; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/func_80A3D680.s") + if (hours >= 16) { + if ((hours == 16) && (minutes < arg0)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/func_80A3D940.s") + if (hours >= 20) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/func_80A3D9C4.s") + if ((hours == 19) && (arg0 < minutes)) { + return 0; + } + ret = 3; + } else if (hours >= 11) { + if ((hours == 11) && (minutes < arg0)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/ObjSmork_Init.s") + if (hours >= 14) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/ObjSmork_Destroy.s") + if ((hours == 13) && (arg0 < minutes)) { + return 0; + } + ret = 2; + } else if (hours >= 6) { + if ((hours == 6) && (minutes < arg0)) { + return 0; + } + if (hours >= 9) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/ObjSmork_Update.s") + if ((hours == 8) && (arg0 < minutes)) { + return 0; + } + ret = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/ObjSmork_Draw.s") + return ret; +} + +void func_80A3D940(ObjSmork* this) { + u8 temp_v0 = func_80A3D680(this->unk_1C6); + + if (temp_v0 != this->unk_1C4) { + this->unk_1C4 = temp_v0; + this->unk_1C6 = Rand_S16Offset(0, 59); + } + + Math_ApproachF(&this->unk_1B8, (this->unk_1C4 == 0) ? 0.0f : 1.0f, 0.02f, 1000.0f); +} + +void func_80A3D9C4(ObjSmork* this, GlobalContext* globalCtx) { + u8 sp57; + u8 sp56; + s32 i; + + this->unk_1BC += 1.8f; + this->unk_1C0 += 0.6f; + + sp57 = 127 - (u8)this->unk_1BC; + sp56 = 127 - (u8)this->unk_1C0; + + this->unk_1B8 = CLAMP(this->unk_1B8, 0.0f, 1.0f); + + for (i = 0; i < ARRAY_COUNT(this->unk_148); i++) { + this->unk_148[i].v.cn[3] = ovl_Obj_Smork_Vtx_000C10[i].v.cn[3] * this->unk_1B8; + } + + if (this->unk_1B8 > 0.0f) { + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, sp57, 0x20, 0x20, 1, 0, sp56, 0x20, 0x20)); + gSPSegment(POLY_XLU_DISP++, 0x09, Lib_SegmentedToVirtual(this->unk_148)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_f53_obj_DL_001C00); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void ObjSmork_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjSmork* this = THIS; + + Lib_MemCpy(this->unk_148, ovl_Obj_Smork_Vtx_000C10, sizeof(Vtx) * ARRAY_COUNT(ovl_Obj_Smork_Vtx_000C10)); + this->unk_1C6 = Rand_S16Offset(0, 59); + this->unk_1C4 = 0; +} + +void ObjSmork_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void ObjSmork_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSmork* this = THIS; + + func_80A3D940(this); +} + +void ObjSmork_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjSmork* this = THIS; + + func_80A3D9C4(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h index dd6ab4cf7..5ab3e405c 100644 --- a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h +++ b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h @@ -7,7 +7,13 @@ struct ObjSmork; typedef struct ObjSmork { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x84]; + /* 0x144 */ UNK_TYPE1 unk_144[4]; + /* 0x148 */ Vtx unk_148[7]; + /* 0x1B8 */ f32 unk_1B8; + /* 0x1BC */ f32 unk_1BC; + /* 0x1C0 */ f32 unk_1C0; + /* 0x1C4 */ u8 unk_1C4; + /* 0x1C6 */ s16 unk_1C6; } ObjSmork; // size = 0x1C8 extern const ActorInit Obj_Smork_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 733319036..de13da3ae 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1721,10 +1721,6 @@ D_060048D0 = 0x060048D0; D_060011E0 = 0x060011E0; -// ovl_Obj_Smork - -D_06001C00 = 0x06001C00; - // ovl_Obj_Takaraya_Wall D_06000B70 = 0x06000B70; From 486e7cbe83dcfe395a792e01f60e8c5e5f42d6aa Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Tue, 29 Mar 2022 13:37:58 -0700 Subject: [PATCH 170/257] SubS General Pathing Helpers (#760) * Brought code over and cleanup * cleanup functions.h and format * add comment * Whitespace * Format * Update src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c Co-authored-by: Anghelo Carvajal * Format Co-authored-by: Anghelo Carvajal --- assets/xml/code/sub_s.xml | 6 + include/functions.h | 27 +-- include/z64subs.h | 2 +- spec | 1 - src/code/z_en_hy_code.c | 14 +- src/code/z_sub_s.c | 202 ++++++++++++++++-- .../actors/ovl_Bg_Ingate/z_bg_ingate.c | 6 +- .../ovl_En_Akindonuts/z_en_akindonuts.c | 2 +- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 2 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 6 +- .../actors/ovl_En_Bba_01/z_en_bba_01.c | 2 +- .../ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c | 4 +- .../actors/ovl_En_Cne_01/z_en_cne_01.c | 2 +- src/overlays/actors/ovl_En_Daiku/z_en_daiku.c | 4 +- .../actors/ovl_En_Daiku2/z_en_daiku2.c | 4 +- src/overlays/actors/ovl_En_Dg/z_en_dg.c | 6 +- src/overlays/actors/ovl_En_Gg2/z_en_gg2.c | 2 +- src/overlays/actors/ovl_En_Gk/z_en_gk.c | 2 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 8 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 6 +- .../ovl_En_Hidden_Nuts/z_en_hidden_nuts.c | 6 +- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 8 +- src/overlays/actors/ovl_En_In/z_en_in.c | 8 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 2 +- .../actors/ovl_En_Look_Nuts/z_en_look_nuts.c | 4 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 10 +- src/overlays/actors/ovl_En_Pr2/z_en_pr2.c | 4 +- .../actors/ovl_En_Racedog/z_en_racedog.c | 2 +- src/overlays/actors/ovl_En_Rg/z_en_rg.c | 8 +- .../actors/ovl_En_Ruppecrow/z_en_ruppecrow.c | 2 +- .../actors/ovl_En_Scopenuts/z_en_scopenuts.c | 4 +- .../actors/ovl_En_Sellnuts/z_en_sellnuts.c | 4 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 20 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 52 +++-- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 2 +- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 2 +- src/overlays/actors/ovl_En_Trt2/z_en_trt2.c | 6 +- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 4 +- .../actors/ovl_En_Tru_Mt/z_en_tru_mt.c | 4 +- src/overlays/actors/ovl_En_Zo/z_en_zo.c | 8 +- tools/actorfixer.py | 12 ++ tools/disasm/functions.txt | 28 +-- tools/sizes/code_functions.csv | 24 +-- 43 files changed, 360 insertions(+), 172 deletions(-) create mode 100644 assets/xml/code/sub_s.xml diff --git a/assets/xml/code/sub_s.xml b/assets/xml/code/sub_s.xml new file mode 100644 index 000000000..d48335ec7 --- /dev/null +++ b/assets/xml/code/sub_s.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/include/functions.h b/include/functions.h index 3f22bd67b..ed9c8541b 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2439,8 +2439,8 @@ void func_8013A46C(s32 flag); u32 func_8013A4C4(s32 flag); s16 func_8013A504(s16 val); s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax, s16 angleError); -struct EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5); -Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 idx, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); +struct EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag); +Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx); s32 func_8013AD6C(GlobalContext* globalCtx); s32 func_8013AD9C(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5); @@ -2451,14 +2451,14 @@ void func_8013B0C8(s32 arg0, f32 arg1, s32 arg2, f32* arg3, f32* arg4); void func_8013B350(Vec3f* arg0, f32* arg1, f32 arg2, s32 arg3, s32 arg4, Vec3s* arg5, f32* arg6); s32 func_8013B6B0(Path* path, f32* arg1, s32* arg2, s32 arg3, s32 arg4, s32* arg5, f32* arg6, Vec3f* arg7, s32 arg8); void func_8013B878(GlobalContext* globalCtx, Path* path, s32 arg2, Vec3f* arg3); -Path* func_8013BB34(GlobalContext* globalCtx, u8 arg1, s32 arg2); +Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max); Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId); s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index); -s32 func_8013BD40(Actor* actor, Path* path, s32 arg2); -Path* func_8013BEDC(GlobalContext* globalCtx, u8 arg1, u8 arg2, s32* arg3); +s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex); +Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex); s32 func_8013C068(Path* path, s32 arg1, Vec3f* arg2, f32 arg3, s32 arg4); s32 func_8013C624(Actor* actor, Path* path, s32* arg2, f32* arg3, s32 arg4, s32 arg5); -s32 func_8013C8B8(Path* path, s32 arg1, Vec3f* arg2); +s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst); s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, s32 arg5); void func_8013CC2C(s32 arg0, s32 arg1, u8* arg2, s32 arg3); void func_8013CD64(Vec3f* arg0, Vec3f* arg1, u8* arg2, f32 arg3, u8 arg4, u8* arg5, s8* arg6); @@ -2466,17 +2466,18 @@ void func_8013CF04(Actor* actor, GraphicsContext** gfxCtxPtr, u8* arg2); s16 func_8013D0E0(s16* arg0, s16 arg1, s16 arg2, f32 arg3, f32 arg4, f32 arg5); s32 func_8013D2E0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Vec3s* arg3, Vec3s* arg4, Vec3s* arg5, u16* arg6); s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); -Path* func_8013D648(GlobalContext* globalCtx, s16 arg1, s16 arg2); -s32 func_8013D68C(Path* path, s32 arg1, Vec3f* arg2); -s16 func_8013D720(Vec3f* arg0, Vec3f* arg1, f32* arg2); -s32 func_8013D768(Actor* actor, Vec3f* arg1, s16 arg2); -s16 func_8013D83C(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); +Path* SubS_GetPathByIndex(GlobalContext* globalCtx, s16 pathIndex, s16 max); +s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst); +s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq); +s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep); +s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx); s8 SubS_GetObjectIndex(s16 id, GlobalContext* globalCtx); Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs); -s32 func_8013DB90(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2); -s32 func_8013DC40(Path* arg0, s32 arg1, s32 arg2, Vec3f* arg3); +s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove); +s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst); +u8 SubS_GetPathCount(Path* paths, s32 index); void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags); s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc); void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* actorPath); diff --git a/include/z64subs.h b/include/z64subs.h index 7ef51c348..ca69e72cb 100644 --- a/include/z64subs.h +++ b/include/z64subs.h @@ -10,7 +10,7 @@ typedef enum { /* 2 */ SUBS_CUTSCENE_SET_FLAG } SubSCutsceneType; -typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, Vec3s*); +typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, void*); typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); diff --git a/spec b/spec index 4b23e0551..0bfd74504 100644 --- a/spec +++ b/spec @@ -530,7 +530,6 @@ beginseg include "build/src/code/z_skin_matrix.o" include "build/src/code/z_snap.o" include "build/src/code/z_sub_s.o" - include "build/data/code/z_sub_s.data.o" include "build/data/code/code_801DE890.rodata.o" include "build/src/code/code_8013EC10.o" include "build/data/code/code_8013EC10.bss.o" diff --git a/src/code/z_en_hy_code.c b/src/code/z_en_hy_code.c index ab42ea622..6b16cc91c 100644 --- a/src/code/z_en_hy_code.c +++ b/src/code/z_en_hy_code.c @@ -152,7 +152,7 @@ s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3 EnDoor* door; s32 pad; - if (func_8013D68C(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { door = EnHy_FindNearestDoor(&enHy->actor, globalCtx); if (door != NULL) { ret = true; @@ -174,7 +174,7 @@ s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3) { EnDoor* door; enHy->curPoint = 0; - if (func_8013D68C(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { door = EnHy_FindNearestDoor(&enHy->actor, globalCtx); if (door != NULL) { ret = true; @@ -209,7 +209,8 @@ s32 EnHy_MoveForwards(EnHy* enHy, f32 speedTarget) { Math_SmoothStepToF(&enHy->actor.speedXZ, speedTarget, 0.4f, 1000.0f, 0.0f); rotStep = enHy->actor.speedXZ * 400.0f; - if (func_8013D68C(enHy->path, enHy->curPoint, &curPointPos) && func_8013D768(&enHy->actor, &curPointPos, rotStep)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &curPointPos) && + SubS_MoveActorToPoint(&enHy->actor, &curPointPos, rotStep)) { enHy->curPoint++; if (enHy->curPoint >= enHy->path->count) { reachedEnd = true; @@ -226,7 +227,8 @@ s32 EnHy_MoveBackwards(EnHy* enHy, f32 speedTarget) { Math_SmoothStepToF(&enHy->actor.speedXZ, speedTarget, 0.4f, 1000.0f, 0.0f); rotStep = enHy->actor.speedXZ * 400.0f; - if (func_8013D68C(enHy->path, enHy->curPoint, &curPointPos) && func_8013D768(&enHy->actor, &curPointPos, rotStep)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &curPointPos) && + SubS_MoveActorToPoint(&enHy->actor, &curPointPos, rotStep)) { enHy->curPoint--; if (enHy->curPoint < 0) { reachedEnd = true; @@ -263,12 +265,12 @@ s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThr sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, enHy->actor.floorPoly, enHy->actor.floorBgId) + SFX_FLAG; } - enHy->isLeftFootOnGround = isFootOnGround = func_8013DB90(globalCtx, &enHy->leftFootPos, distAboveThreshold); + enHy->isLeftFootOnGround = isFootOnGround = SubS_IsFloorAbove(globalCtx, &enHy->leftFootPos, distAboveThreshold); if (enHy->isLeftFootOnGround && !wasLeftFootOnGround && isFootOnGround) { Actor_PlaySfxAtPos(&enHy->actor, sfxId); } - enHy->isRightFootOnGround = isFootOnGround = func_8013DB90(globalCtx, &enHy->rightFootPos, distAboveThreshold); + enHy->isRightFootOnGround = isFootOnGround = SubS_IsFloorAbove(globalCtx, &enHy->rightFootPos, distAboveThreshold); if (enHy->isRightFootOnGround && !wasRightFootOnGround && isFootOnGround) { Actor_PlaySfxAtPos(&enHy->actor, sfxId); } diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 630b16463..c36365d48 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -6,10 +6,18 @@ #include "global.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" +s16 sPathDayFlags[] = { 0x40, 0x20, 0x10, 8, 4, 2, 1, 0 }; + +#include "code/sub_s/sub_s.c" + +Vec3f D_801C5DB0 = { 1.0f, 1.0f, 1.0f }; + +s32 D_801C5DBC[] = { 0, 1 }; // Unused + /** - * Finds the first EnDoor instance with unk_1A4 == 5 and the specified unk_1A5. + * Finds the first EnDoor instance with unk_1A4 == 5 and the specified switchFlag. */ -EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5) { +EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag) { Actor* actor = NULL; EnDoor* door; @@ -21,7 +29,7 @@ EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5) { break; } - if ((door->unk_1A4 == 5) && (door->switchFlag == (u8)unk_1A5)) { + if ((door->unk_1A4 == 5) && (door->switchFlag == (u8)switchFlag)) { break; } @@ -170,7 +178,21 @@ void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B878.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BB34.s") +Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max) { + Path* path; + s32 i = 0; + + do { + path = &globalCtx->setupPathList[pathIndex]; + if (i >= max) { + break; + } + pathIndex = path->unk1; + i++; + } while (pathIndex != 0xFF); + + return path; +} /** * Finds the nearest actor instance of a specified Id and category to an actor. @@ -228,15 +250,88 @@ s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations return true; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BD40.s") +s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 count = path->count; + s32 index = pointIndex; + s32 reached = false; + f32 diffX; + f32 diffZ; + f32 px; + f32 pz; + f32 d; + Vec3f point; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BEDC.s") + Math_Vec3s_ToVec3f(&point, &points[index]); + + if (index == 0) { + diffX = points[1].x - points[0].x; + diffZ = points[1].z - points[0].z; + } else if (index == count - 1) { + diffX = points[count - 1].x - points[count - 2].x; + diffZ = points[count - 1].z - points[count - 2].z; + } else { + diffX = points[index + 1].x - points[index - 1].x; + diffZ = points[index + 1].z - points[index - 1].z; + } + + func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); + if (((px * actor->world.pos.x) + (pz * actor->world.pos.z) + d) > 0.0f) { + reached = true; + } + + return reached; +} + +Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex) { + Path* path = NULL; + s32 found = false; + s32 time = (((s16)TIME_TO_MINUTES_F(gSaveContext.save.time) % 60) + + ((s16)TIME_TO_MINUTES_F(gSaveContext.save.time) / 60) * 60) / + 30; + s32 day = CURRENT_DAY; + + if (pathIndex == max) { + return NULL; + } + + while (pathIndex != 0xFF) { + path = &globalCtx->setupPathList[pathIndex]; + if (sPathDayFlags[day] & path->unk2) { + found = true; + break; + } + pathIndex = path->unk1; + } + + if (found == true) { + *startPointIndex = time; + *startPointIndex = CLAMP(*startPointIndex, 0, path->count - 1); + } else { + *startPointIndex = 0; + } + + return path; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C068.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C624.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C8B8.s") +s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst) { + Vec3s* point; + + if ((path == NULL) || (pointIndex >= path->count) || (pointIndex < 0)) { + return false; + } + + point = Lib_SegmentedToVirtual(path->points); + point = &point[pointIndex]; + dst->x = point->x; + dst->y = point->y; + dst->z = point->z; + return true; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C964.s") @@ -254,15 +349,68 @@ s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB) { return (ABS_ALT(BINANG_SUB(angleB, angleA)) <= threshold) ? true : false; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D648.s") +Path* SubS_GetPathByIndex(GlobalContext* globalCtx, s16 pathIndex, s16 max) { + return (pathIndex != max) ? &globalCtx->setupPathList[pathIndex] : NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D68C.s") +s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst) { + Vec3s* point; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D720.s") + if (path == NULL) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D768.s") + point = Lib_SegmentedToVirtual(path->points); + point = &point[pointIndex]; + dst->x = point->x; + dst->y = point->y; + dst->z = point->z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D83C.s") + return true; +} + +s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq) { + f32 diffX = vecA->x - vecB->x; + f32 diffZ = vecA->z - vecB->z; + + *distSq = SQ(diffX) + SQ(diffZ); + return Math_Atan2S(diffX, diffZ); +} + +/** + * Returns true when the actor has reached the inputed point + */ +s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep) { + Vec3f offsetBefore; + Vec3f offsetAfter; + f32 distSqBefore; + f32 distSqAfter; + + Actor_OffsetOfPointInActorCoords(actor, &offsetBefore, point); + Math_SmoothStepToS(&actor->world.rot.y, SubS_GetDistSqAndOrientPoints(point, &actor->world.pos, &distSqBefore), 4, + rotStep, 1); + actor->shape.rot.y = actor->world.rot.y; + Actor_MoveWithGravity(actor); + Actor_OffsetOfPointInActorCoords(actor, &offsetAfter, point); + SubS_GetDistSqAndOrientPoints(point, &actor->world.pos, &distSqAfter); + return ((offsetBefore.z > 0.0f) && (offsetAfter.z <= 0.0f)) ? true : false; +} + +s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIndex, Vec3f* pos, f32* distSq) { + Vec3s* point; + f32 diffX = 0.0f; + f32 diffZ = 0.0f; + + if (path != NULL) { + point = Lib_SegmentedToVirtual(path->points); + point = &point[pointIndex]; + diffX = point->x - pos->x; + diffZ = point->z - pos->z; + } + + *distSq = SQ(diffX) + SQ(diffZ); + return Math_Atan2S(diffX, diffZ); +} s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx) { return !Object_IsLoaded(&globalCtx->objectCtx, index) ? false : true; @@ -301,11 +449,35 @@ s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* li return true; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DB90.s") +s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove) { + CollisionPoly* outPoly; + Vec3f posA; + Vec3f posB; + Vec3f posResult; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DC40.s") + posA = posB = *pos; + posB.y += distAbove; + return BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posResult, &outPoly, false, true, false, true, + &bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DCCC.s") +s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst) { + Path* path = &paths[pathIndex]; + Vec3s* point = &((Vec3s*)Lib_SegmentedToVirtual(path->points))[pointIndex]; + + dst->x = point->x; + dst->y = point->y; + dst->z = point->z; + + return false; +} + +u8 SubS_GetPathCount(Path* paths, s32 index) { + Path* path = &paths[index]; + + return path->count; +} void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index 2648b3069..9020f368c 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -328,7 +328,7 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk160 |= 0x8; this->unk160 |= 0x10; Actor_SetScale(&this->dyna.actor, 1.0f); - this->unk164 = func_8013BB34(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); this->dyna.actor.room = -1; if (gSaveContext.save.weekEventReg[20] & 2) { gSaveContext.save.weekEventReg[90] &= (u8)~0x40; @@ -350,7 +350,7 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actionFunc = func_80953F8C; } } - this->unk164 = func_8013BB34(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); + this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); if (this->unk164 != 0) { sp38 = Lib_SegmentedToVirtual(this->unk164->points); Math_Vec3s_ToVec3f(&sp2C, &sp38[0]); @@ -361,7 +361,7 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->dyna.actor.world.pos.y = -15.0f; this->dyna.actor.world.pos.z = sp2C.z; } - this->unk164 = func_8013BB34(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); } else { Actor_MarkForDeath(&this->dyna.actor); } diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c index 21691cbf8..70e98fc15 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -1606,7 +1606,7 @@ void EnAkindonuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; if (!ENAKINDONUTS_GET_4(&this->actor)) { - this->path = func_8013D648(globalCtx, ENAKINDONUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENAKINDONUTS_GET_FC00(&this->actor), 0x3F); if (this->path == NULL) { Actor_MarkForDeath(&this->actor); return; diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index ecbb73400..0705d7f06 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -113,7 +113,7 @@ void func_809C1158(EnAob01* this, GlobalContext* globalCtx) { if (temp_s0 != 0x3F) { do { - this->unk_1D8[i] = func_8013D648(globalCtx, temp_s0, 0x3F); + this->unk_1D8[i] = SubS_GetPathByIndex(globalCtx, temp_s0, 0x3F); temp_s0 = this->unk_1D8[i]->unk1; i++; } while (temp_s0 != 0xFF); diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index 7ce0ea260..ff2d7c48e 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -266,7 +266,7 @@ s32 func_80BA8D2C(EnBaba* this, f32 arg1) { Math_SmoothStepToF(&this->actor.speedXZ, arg1, 0.4f, 1000.0f, 0.0f); sp3E = this->actor.speedXZ * 400.0f; - if (func_8013D68C(this->path, this->unk_1E8, &sp2C) && func_8013D768(&this->actor, &sp2C, sp3E)) { + if (SubS_CopyPointFromPath(this->path, this->unk_1E8, &sp2C) && SubS_MoveActorToPoint(&this->actor, &sp2C, sp3E)) { this->unk_1E8++; if (this->unk_1E8 >= this->path->count) { ret = true; @@ -311,7 +311,7 @@ s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* u8 sp23 = ENBABA_GET_3F00(&this->actor); if (D_80BAA4A8[arg2->unk0] >= 0) { - this->unk_410 = func_8013BB34(globalCtx, sp23, D_80BAA4A8[arg2->unk0]); + this->unk_410 = SubS_GetAdditionalPath(globalCtx, sp23, D_80BAA4A8[arg2->unk0]); } if (this->unk_410 == NULL) { @@ -659,7 +659,7 @@ void EnBaba_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->path = func_8013D648(globalCtx, ENBABA_GET_3F00(&this->actor), ENBABA_3F00_3F); + this->path = SubS_GetPathByIndex(globalCtx, ENBABA_GET_3F00(&this->actor), ENBABA_3F00_3F); Actor_SetScale(&this->actor, 0.01f); diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index 00f4be6e8..e502b6637 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -220,7 +220,7 @@ void EnBba01_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->enHy.collider, &this->enHy.actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->enHy.actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->enHy.actor.flags &= ~ACTOR_FLAG_1; - this->enHy.path = func_8013D648(globalCtx, ENBBA01_GET_PATH(&this->enHy.actor), ENBBA01_NO_PATH); + this->enHy.path = SubS_GetPathByIndex(globalCtx, ENBBA01_GET_PATH(&this->enHy.actor), ENBBA01_NO_PATH); this->enHy.waitingOnInit = true; Actor_SetScale(&this->enHy.actor, 0.01f); this->enHy.actionFunc = EnBba01_FinishInit; diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c index 49e6caa63..321468424 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c @@ -94,7 +94,7 @@ void EnBomBowlMan_Init(Actor* thisx, GlobalContext* globalCtx) { } this->unk_29A = ENBOMBOWLMAN_GET_FF00(&this->actor); - this->path = func_8013D648(globalCtx, this->unk_29A, 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, this->unk_29A, 0x3F); this->unk_2C8 = 80.0f; if ((gSaveContext.save.entranceIndex == 0xD220) && (gSaveContext.save.weekEventReg[73] & 0x80) && @@ -157,7 +157,7 @@ void func_809C4B50(EnBomBowlMan* this) { void func_809C4B6C(EnBomBowlMan* this) { if ((this->unk_29A != ENBOMBOWLMAN_FF00_MINUS1) && (this->path != NULL)) { - if (!func_8013D68C(this->path, this->unk_298, &this->unk_2A0)) { + if (!SubS_CopyPointFromPath(this->path, this->unk_298, &this->unk_2A0)) { Actor_MarkForDeath(&this->actor); } } diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index 3d8623e7a..e7c6ebc6e 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -210,7 +210,7 @@ void EnCne01_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->enHy.collider, &this->enHy.actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->enHy.actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->enHy.actor.flags &= ~ACTOR_FLAG_1; - this->enHy.path = func_8013D648(globalCtx, ENCNE01_GET_PATH(&this->enHy.actor), ENCNE01_NO_PATH); + this->enHy.path = SubS_GetPathByIndex(globalCtx, ENCNE01_GET_PATH(&this->enHy.actor), ENCNE01_NO_PATH); this->enHy.waitingOnInit = true; Actor_SetScale(&this->enHy.actor, 0.01f); this->enHy.actionFunc = EnCne01_FinishInit; diff --git a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c index a15d09515..3d76b7391 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -67,7 +67,7 @@ void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_278 = ENDAIKU_GET_FF(&this->actor); if (this->unk_278 == ENDAIKU_PARAMS_FF_3) { this->unk_288 = ENDAIKU_GET_FF00(&this->actor); - this->unk_258 = func_8013D648(globalCtx, this->unk_288, 0x3F); + this->unk_258 = SubS_GetPathByIndex(globalCtx, this->unk_288, 0x3F); } else if (this->unk_278 == ENDAIKU_PARAMS_FF_2) { this->unk_264 = -2000; } @@ -134,7 +134,7 @@ void func_8094373C(EnDaiku* this, s32 arg1) { void func_809437C8(EnDaiku* this) { if ((this->unk_288 != -1) && (this->unk_258 != 0)) { - if (!func_8013D68C(this->unk_258, this->unk_25C, &this->unk_26C)) { + if (!SubS_CopyPointFromPath(this->unk_258, this->unk_25C, &this->unk_26C)) { Actor_MarkForDeath(&this->actor); } } diff --git a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c index 009094f93..64a8c3d9b 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -70,7 +70,7 @@ static ColliderCylinderInit sCylinderInit = { void func_80BE61D0(EnDaiku2* this) { if ((this->unk_27A != -1) && (this->unk_258 != 0)) { - if (func_8013D68C(this->unk_258, this->unk_25C, &this->unk_268) == 0) { + if (!SubS_CopyPointFromPath(this->unk_258, this->unk_25C, &this->unk_268)) { Actor_MarkForDeath(&this->actor); } } @@ -88,7 +88,7 @@ void EnDaiku2_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->unk_278 = ENDAIKU2_GET_7F(&this->actor); this->unk_27A = ENDAIKU2_GET_1F80(&this->actor); - this->unk_258 = func_8013D648(globalCtx, this->unk_27A, 0x3F); + this->unk_258 = SubS_GetPathByIndex(globalCtx, this->unk_27A, 0x3F); this->unk_280 = ENDAIKU2_GET_8000(&this->actor); Actor_SetScale(&this->actor, 0.01f); if (!this->unk_280) { diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index 5d477d21f..dce730c48 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -212,7 +212,7 @@ s32 func_80989418(EnDg* this, Path* arg1, s32 arg2) { if (idx == 0) { phi_f12 = sp5C[1].x - sp5C[0].x; phi_f14 = sp5C[1].z - sp5C[0].z; - } else if ((idx + 1) == ((void)0, count)) { + } else if (idx == count - 1) { phi_f12 = sp5C[count - 1].x - sp5C[count - 2].x; phi_f14 = sp5C[count - 1].z - sp5C[count - 2].z; } else { @@ -220,7 +220,7 @@ s32 func_80989418(EnDg* this, Path* arg1, s32 arg2) { phi_f14 = sp5C[idx + 1].z - sp5C[idx - 1].z; } - func_8017B7F8(&sp30, func_80086B30(phi_f12, phi_f14) * 10430.378f, &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { sp50 = true; } @@ -1114,7 +1114,7 @@ void EnDg_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_ProcessInitChain(&this->actor, sInitChain); - this->unk_1DC = func_8013D648(globalCtx, ENDG_GET_FC00(&this->actor), 0x3F); + this->unk_1DC = SubS_GetPathByIndex(globalCtx, ENDG_GET_FC00(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.0075f); this->actor.targetMode = 1; this->actor.gravity = -3.0f; 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 7b019933f..ebe127fcf 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -369,7 +369,7 @@ void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actor.bgCheckFlags |= 0x400; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_gg_Skel_00F6C0, &object_gg_Anim_00F578, this->jointTable, this->morphTable, 20); - this->unk_1D8 = func_8013D648(globalCtx, ENGG2_GET_FC00(&this->actor), 0x3F); + this->unk_1D8 = SubS_GetPathByIndex(globalCtx, ENGG2_GET_FC00(&this->actor), 0x3F); this->actor.flags &= ~ACTOR_FLAG_80; this->unk_2F0 = 0; this->unk_2F1 = 0; 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 135d9f6d7..059f18c9c 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -1028,7 +1028,7 @@ void EnGk_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } else { this->unk_318 = this->actor.cutscene; - this->path = func_8013D648(globalCtx, ENGK_GET_F0(&this->actor), 15); + this->path = SubS_GetPathByIndex(globalCtx, ENGK_GET_F0(&this->actor), 15); this->actionFunc = func_80B51760; } } else if (globalCtx->sceneNum == SCENE_GORONRACE) { 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 50a809dfd..107c9a656 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -902,7 +902,7 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar actor = func_8094DEE0(this, globalCtx, arg3, arg4); if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80951A0C[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->unk0]); } if ((actor != NULL) && (actor->update != NULL)) { @@ -933,7 +933,7 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar door = func_8094DF90(globalCtx, arg2->unk0); if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp55, D_80951A0C[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80951A0C[arg2->unk0]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { @@ -974,7 +974,7 @@ s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp2B, D_80951A0C[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80951A0C[arg2->unk0]); } if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { @@ -1076,7 +1076,7 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80951A0C[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->unk0]); } if (this->unk_234 != NULL) { 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 dbe7c3d72..57c8dc044 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -1332,7 +1332,7 @@ void func_80A1428C(EnGo* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp30, &this->actor.world.pos); if (this->unk_284 != NULL) { this->actor.flags &= ~ACTOR_FLAG_2000000; - func_8013C8B8(this->unk_284, 0, &sp24); + SubS_CopyPointFromPathCheckBounds(this->unk_284, 0, &sp24); temp = Math_Vec3f_Yaw(&sp30, &sp24); this->actor.shape.rot.y = temp; this->actor.world.rot.y = temp; @@ -1393,7 +1393,7 @@ void func_80A1449C(EnGo* this, GlobalContext* globalCtx) { void func_80A144F4(EnGo* this, GlobalContext* globalCtx) { if (gSaveContext.save.day >= 2) { - this->unk_284 = func_8013BEDC(globalCtx, ENGO_GET_7F80(&this->actor), 0xFF, &this->unk_3E4); + this->unk_284 = SubS_GetDayDependentPath(globalCtx, ENGO_GET_7F80(&this->actor), 0xFF, &this->unk_3E4); if (this->unk_284 != NULL) { this->unk_3E4 = 1; } @@ -1785,7 +1785,7 @@ void func_80A153FC(EnGo* this, GlobalContext* globalCtx) { } sp5C = Lib_SegmentedToVirtual(this->unk_284->points); - if (func_8013BD40(&this->actor, this->unk_284, this->unk_3E4)) { + if (SubS_HasReachedPoint(&this->actor, this->unk_284, this->unk_3E4)) { if (this->unk_3E4 >= (this->unk_284->count - 1)) { this->unk_3E4 = 0; } else { 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 4ea774d71..e1432c10a 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 @@ -103,7 +103,7 @@ void EnHiddenNuts_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - this->path = func_8013D648(globalCtx, this->unk_21E, 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, this->unk_21E, 0x3F); this->unk_226 = this->actor.cutscene; func_801A5080(2); func_80BDB268(this); @@ -311,7 +311,7 @@ void func_80BDBA28(EnHiddenNuts* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); this->unk_208 = 1; - if ((this->path != NULL) && !func_8013D68C(this->path, this->unk_208, &this->unk_20C)) { + if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_208, &this->unk_20C)) { Actor_MarkForDeath(&this->actor); } @@ -376,7 +376,7 @@ void func_80BDBB48(EnHiddenNuts* this, GlobalContext* globalCtx) { this->unk_208++; if (this->unk_208 >= this->path->count) { func_80BDBE70(this, globalCtx); - } else if ((this->path != NULL) && !func_8013D68C(this->path, this->unk_208, &this->unk_20C)) { + } else if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_208, &this->unk_20C)) { Actor_MarkForDeath(&this->actor); } } 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 6ab8fb486..7f847cf08 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -478,7 +478,7 @@ s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_274 = NULL; if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp4F, D_80BF3318[arg2->unk0]); + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->unk0]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { @@ -522,7 +522,7 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar door = func_80BF1200(globalCtx, arg2->unk0); if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp55, D_80BF3318[arg2->unk0]); + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp55, D_80BF3318[arg2->unk0]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { @@ -563,7 +563,7 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_274 = NULL; if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp2B, D_80BF3318[arg2->unk0]); + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80BF3318[arg2->unk0]); } if ((this->unk_274 != NULL) && (this->unk_274->count < 3)) { @@ -613,7 +613,7 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_274 = NULL; if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp4F, D_80BF3318[arg2->unk0]); + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->unk0]); } if ((this->unk_274 != 0) && (this->unk_274->count >= 2)) { 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 f3293f6dd..57c4bfe47 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -165,11 +165,11 @@ s32 func_808F3178(EnIn* this, GlobalContext* globalCtx) { u8 prevUnk261 = this->unk261; u8 tmp; - this->unk260 = tmp = func_8013DB90(globalCtx, &this->unk248, -6.0f); + this->unk260 = tmp = SubS_IsFloorAbove(globalCtx, &this->unk248, -6.0f); if (this->unk260 != 0 && prevUnk260 == 0 && tmp) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_CONCRETE); } - this->unk261 = tmp = func_8013DB90(globalCtx, &this->unk254, -6.0f); + this->unk261 = tmp = SubS_IsFloorAbove(globalCtx, &this->unk254, -6.0f); if (this->unk261 != 0 && prevUnk261 == 0 && tmp) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_CONCRETE); } @@ -286,7 +286,7 @@ void func_808F3690(EnIn* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.speedXZ, 1.0f, 0.4f, 1000.0f, 0.0f); sp36 = this->actor.speedXZ * 400.0f; - if (func_8013D68C(this->path, this->unk244, &sp28) && func_8013D768(&this->actor, &sp28, sp36)) { + if (SubS_CopyPointFromPath(this->path, this->unk244, &sp28) && SubS_MoveActorToPoint(&this->actor, &sp28, sp36)) { this->unk244++; if (this->unk244 >= this->path->count) { this->unk244 = 0; @@ -1382,7 +1382,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, &this->colliderJntSphElement); Actor_SetScale(&this->actor, 0.01f); this->actor.gravity = -4.0f; - this->path = func_8013D648(globalCtx, ENIN_GET_PATH(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENIN_GET_PATH(&this->actor), 0x3F); this->unk23D = 0; if (type == ENIN_YELLOW_SHIRT || type == ENIN_BLUE_SHIRT) { if (GET_RACE_FLAGS == RACE_FLAG_2 || (GET_RACE_FLAGS) == RACE_FLAG_3) { 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 8bc5df4cc..9412e5594 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -957,7 +957,7 @@ void EnJg_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = EnJg_LullabyIntroCutsceneAction; } else { // This is the elder that appears in Mountain Village or the Path to Goron Village in winter. - this->path = func_8013D648(globalCtx, EN_JG_GET_PATH(thisx), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, EN_JG_GET_PATH(thisx), 0x3F); this->animationIndex = EN_JG_ANIMATION_SURPRISE_START; this->action = EN_JG_ACTION_SPAWNING; this->freezeTimer = 1000; diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c index f93851035..d687c2aa8 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c @@ -164,9 +164,9 @@ void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx) { return; } - this->path = func_8013D648(globalCtx, this->pathLocation, 0x1F); + this->path = SubS_GetPathByIndex(globalCtx, this->pathLocation, 0x1F); if (this->path != NULL) { - sp34 = func_8013D83C(this->path, this->currentPathIndex, &this->actor.world.pos, &sp30); + sp34 = SubS_GetDistSqAndOrientPath(this->path, this->currentPathIndex, &this->actor.world.pos, &sp30); } if (sp30 < 10.0f) { diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 27c7af9f5..2736fc71a 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -916,7 +916,7 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; sp2C = func_80AF7CB0(this, globalCtx, actorCat, actorId); if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80AFB430[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->unk0]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { @@ -947,7 +947,7 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; door = func_80AF7D60(globalCtx, arg2->unk0); if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp55, D_80AFB430[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80AFB430[arg2->unk0]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { @@ -992,7 +992,7 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp2B, D_80AFB430[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80AFB430[arg2->unk0]); } if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { @@ -1072,7 +1072,7 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80AFB430[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->unk0]); } if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { @@ -1125,7 +1125,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; phi_a3 = D_80AFB430[arg2->unk0]; if (phi_a3 >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, phi_a3); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, phi_a3); } if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { 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 6fa76d817..39f1e4f95 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c @@ -152,7 +152,7 @@ void EnPr2_Init(Actor* thisx, GlobalContext* globalCtx) { if (parent->update != NULL) { this->unk_1C8 = ((EnEncount1*)parent)->unk_15A; - this->path = func_8013D648(globalCtx, this->unk_1C8, 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, this->unk_1C8, 0x3F); this->unk_208 = parent->world.rot.z * 20.0f; if (this->unk_208 < 20.0f) { this->unk_208 = 20.0f; @@ -276,7 +276,7 @@ void func_80A745FC(EnPr2* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.speedXZ, 10.0f, 0.3f, 1.0f); } - if ((this->path != NULL) && !func_8013D68C(this->path, this->unk_1D0, &this->unk_21C)) { + if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_1D0, &this->unk_21C)) { Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index 064c2d2e4..0166ed423 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -225,7 +225,7 @@ void EnRacedog_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_ProcessInitChain(&this->actor, sInitChain); - this->unk_1E0 = func_8013D648(globalCtx, ENRACEDOG_GET_PATH(&this->actor), 0x3F); + this->unk_1E0 = SubS_GetPathByIndex(globalCtx, ENRACEDOG_GET_PATH(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.0075f); this->actor.gravity = -3.0f; if (ENRACEDOG_GET_3E0(&this->actor) < 14) { diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index 4e41b70a9..bf7158d73 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -383,8 +383,8 @@ s32 func_80BF43FC(EnRg* this) { s32 phi_s0 = D_80BF57E4[this->unk_344][temp_s7]; while (true) { - func_8013C8B8(this->path, phi_s0 - 1, &sp9C); - func_8013C8B8(this->path, phi_s0 + 1, &sp90); + SubS_CopyPointFromPathCheckBounds(this->path, phi_s0 - 1, &sp9C); + SubS_CopyPointFromPathCheckBounds(this->path, phi_s0 + 1, &sp90); if (Math3D_PointDistToLine2D(this->actor.world.pos.x, this->actor.world.pos.z, sp9C.x, sp9C.z, sp90.x, sp90.z, &sp8C, &sp88, &sp84) && (!phi_s6 || ((phi_s4 + 1) == phi_s0) || (sp84 < phi_f20))) { @@ -521,7 +521,7 @@ void func_80BF4964(EnRg* this) { if (this->path != NULL) { sp3C = Lib_SegmentedToVirtual(this->path->points); - if (func_8013BD40(&this->actor, this->path, this->unk_33C)) { + if (SubS_HasReachedPoint(&this->actor, this->path, this->unk_33C)) { if ((this->path->count - 1) < (this->unk_33C + 1)) { this->unk_33C = this->path->count - 1; } else { @@ -749,7 +749,7 @@ void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { Effect_Add(globalCtx, &this->unk_340, EFFECT_TIRE_MARK, 0, 0, &D_80BF59F0); - this->path = func_8013BEDC(globalCtx, ENRG_GET_7F80(&this->actor), 255, &this->unk_33C); + this->path = SubS_GetDayDependentPath(globalCtx, ENRG_GET_7F80(&this->actor), 255, &this->unk_33C); if (this->path != NULL) { this->unk_33C = 1; } diff --git a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c index c21395ef5..2b4026858 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c @@ -639,7 +639,7 @@ void EnRuppecrow_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_SetScale(&this->actor, 0.01f); this->actor.flags |= ACTOR_FLAG_2000000; - this->path = func_8013D648(globalCtx, ENRUPPECROW_GET_PATH(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENRUPPECROW_GET_PATH(&this->actor), 0x3F); if (this->path != NULL) { this->actionFunc = EnRuppecrow_HandleSong; } else { diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c index cf4935187..dc7715fa0 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -708,7 +708,7 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.save.weekEventReg[52] & 0x40) { Actor_MarkForDeath(&this->actor); } else if (globalCtx->actorCtx.unk5 & 2) { - this->path = func_8013D648(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); this->actor.draw = NULL; this->actionFunc = func_80BCAFA8; this->actor.gravity = 0.0f; @@ -717,7 +717,7 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { } } else if (ENSCOPENUTS_GET_3E0(&this->actor) == ENSCOPENUTS_3E0_1) { if (gSaveContext.save.weekEventReg[52] & 0x40) { - this->path = func_8013D648(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); if (this->path == NULL) { Actor_MarkForDeath(&this->actor); } else { diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c index 199338bf1..5735d1e28 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -915,7 +915,7 @@ s32 func_80ADCE4C(EnSellnuts* this, Path* path, s32 arg2) { pointY = points[var + 1].z - points[var - 1].z; } - func_8017B7F8(&sp30, func_80086B30(pointX, pointY) * 10430.378f, &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(pointX, pointY)), &sp44, &sp40, &sp3C); if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { ret = true; } @@ -957,7 +957,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - this->path = func_8013D648(globalCtx, ENSELLNUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENSELLNUTS_GET_FC00(&this->actor), 0x3F); this->cutscene = this->actor.cutscene; Actor_SetScale(&this->actor, 0.01f); this->actor.colChkInfo.cylRadius = 0; diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index 8579dc8f0..fc2ba1432 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -53,7 +53,7 @@ void EnSob1_Blink(EnSob1* this); s32 EnSob1_TakeItemOffShelf(EnSob1* this); s32 EnSob1_ReturnItemToShelf(EnSob1* this); -s16 EnSob1_GetXZAngleAndDistanceSqToPoint(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); +s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); static AnimationInfoS sAnimationsBombShopkeeper[] = { { &object_rs_Anim_009120, 2.0f, 0, -1, ANIMMODE_LOOP, 20 }, @@ -711,10 +711,9 @@ void EnSob1_EndWalk(EnSob1* this, GlobalContext* globalCtx) { s16 curFrame = this->skelAnime.curFrame / this->skelAnime.playSpeed; s16 animLastFrame = Animation_GetLastFrame(&object_rs_Anim_009120) / (s16)this->skelAnime.playSpeed; - Math_SmoothStepToS( - &this->actor.world.rot.y, - EnSob1_GetXZAngleAndDistanceSqToPoint(this->path, this->pathPointsIdx - 1, &this->actor.world.pos, &distSq), 4, - 1000, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, + EnSob1_GetDistSqAndOrient(this->path, this->pathPointsIdx - 1, &this->actor.world.pos, &distSq), + 4, 1000, 1); this->actor.shape.rot.y = this->actor.world.rot.y; Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); if (distSq < 12.0f) { @@ -750,10 +749,9 @@ void EnSob1_Walk(EnSob1* this, GlobalContext* globalCtx) { } } if (this->path != NULL) { - Math_SmoothStepToS( - &this->actor.world.rot.y, - EnSob1_GetXZAngleAndDistanceSqToPoint(this->path, this->pathPointsIdx, &this->actor.world.pos, &distSq), 4, - 1000, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, + EnSob1_GetDistSqAndOrient(this->path, this->pathPointsIdx, &this->actor.world.pos, &distSq), + 4, 1000, 1); this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.speedXZ = 2.0f; if (distSq < SQ(5.0f)) { @@ -1249,7 +1247,7 @@ void EnSob1_UpdateStickDirectionPromptAnim(EnSob1* this) { this->stickLeftPrompt.stickTexY = 95.0f; } -s16 EnSob1_GetXZAngleAndDistanceSqToPoint(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq) { +s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq) { Vec3s* points; f32 diffX; f32 diffZ; @@ -1375,7 +1373,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { this->pathPointsIdx = 0; if (this->shopType == BOMB_SHOP) { - this->path = func_8013D648(globalCtx, ENSOB1_GET_PATH(&this->actor), 0x1F); + this->path = SubS_GetPathByIndex(globalCtx, ENSOB1_GET_PATH(&this->actor), 0x1F); } if (this->shopType == BOMB_SHOP) { EnSob1_SetupAction(this, EnSob1_SetupWalk); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index a989ee8ad..dafed18c5 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -473,8 +473,8 @@ void func_80BAB434(EnSuttari* this) { } void EnSuttari_GetPaths(EnSuttari* this, GlobalContext* globalCtx) { - this->paths[0] = func_8013D648(globalCtx, ENSUTTARI_GET_PATH(&this->actor), 0x3F); - this->paths[1] = func_8013D648(globalCtx, this->paths[0]->unk1, 0x3F); + this->paths[0] = SubS_GetPathByIndex(globalCtx, ENSUTTARI_GET_PATH(&this->actor), 0x3F); + this->paths[1] = SubS_GetPathByIndex(globalCtx, this->paths[0]->unk1, 0x3F); } void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { @@ -504,28 +504,29 @@ void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { SubS_FillLimbRotTables(globalCtx, this->unk2FA, this->unk31A, ARRAY_COUNT(this->unk2FA)); } -s16 func_80BAB698(Path* path, s32 idx, Vec3f* pos, f32* distSQ) { +s16 EnSuttari_GetDistSqAndOrient(Path* path, s32 index, Vec3f* pos, f32* distSq) { Vec3s* points; f32 diffX; f32 diffZ; if (path != NULL) { points = Lib_SegmentedToVirtual(path->points); - points = &points[idx]; + points = &points[index]; diffX = points->x - pos->x; diffZ = points->z - pos->z; } else { diffX = 0.0f; diffZ = 0.0f; } - *distSQ = SQ(diffX) + SQ(diffZ); - return Math_Acot2F(diffZ, diffX) * (0x8000 / M_PI); + + *distSq = SQ(diffX) + SQ(diffZ); + return RADF_TO_BINANG(Math_Acot2F(diffZ, diffX)); } s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); s32 sp58 = path->count; - s32 idx = arg2; + s32 index = arg2; s32 ret = false; f32 sp54; f32 sp48; @@ -534,16 +535,16 @@ s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { f32 sp3C; Vec3f sp30; - Math_Vec3s_ToVec3f(&sp30, &sp5C[idx]); - if (idx == 0) { + Math_Vec3s_ToVec3f(&sp30, &sp5C[index]); + if (index == 0) { sp54 = sp5C[1].x - sp5C[0].x; sp48 = sp5C[1].z - sp5C[0].z; - } else if (idx == sp58 - 1) { + } else if (index == sp58 - 1) { sp54 = sp5C[sp58 - 1].x - sp5C[sp58 - 2].x; sp48 = sp5C[sp58 - 1].z - sp5C[sp58 - 2].z; } else { - sp54 = sp5C[idx + 1].x - sp5C[idx - 1].x; - sp48 = sp5C[idx + 1].z - sp5C[idx - 1].z; + sp54 = sp5C[index + 1].x - sp5C[index - 1].x; + sp48 = sp5C[index + 1].z - sp5C[index - 1].z; } func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(sp54, sp48)), &sp44, &sp40, &sp3C); if (((sp44 * this->actor.world.pos.x) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { @@ -554,29 +555,26 @@ s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { s32 func_80BAB8F4(EnSuttari* this, Path* path, s32 arg2) { Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); - s32 sp58; + s32 sp58 = path->count; + s32 index = arg2; + s32 ret = false; f32 sp54; - s32 ret; - s32 pad4C; f32 sp48; f32 sp44; f32 sp40; f32 sp3C; Vec3f sp30; - if (sp5C[arg2 - 1].x) {} - sp58 = path->count; - ret = false; - Math_Vec3s_ToVec3f(&sp30, &sp5C[arg2]); - if (arg2 == 0) { + Math_Vec3s_ToVec3f(&sp30, &sp5C[index]); + if (index == 0) { sp54 = sp5C[0].x - sp5C[1].x; sp48 = sp5C[0].z - sp5C[1].z; - } else if (arg2 == sp58 - 1) { + } else if (index == sp58 - 1) { sp54 = sp5C[sp58 - 2].x - sp5C[sp58 - 1].x; sp48 = sp5C[sp58 - 2].z - sp5C[sp58 - 1].z; } else { - sp54 = sp5C[arg2 - 1].x - sp5C[arg2 + 1].x; - sp48 = sp5C[arg2 - 1].z - sp5C[arg2 + 1].z; + sp54 = sp5C[index - 1].x - sp5C[index + 1].x; + sp48 = sp5C[index - 1].z - sp5C[index + 1].z; } func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(sp54, sp48)), &sp44, &sp40, &sp3C); if (((sp44 * this->actor.world.pos.x) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { @@ -590,7 +588,7 @@ void func_80BABA90(EnSuttari* this, s32 arg1, u8 arg2) { f32 dist; if (this->paths[arg1] != NULL) { - target = func_80BAB698(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &dist); + target = EnSuttari_GetDistSqAndOrient(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &dist); if (this->actor.bgCheckFlags & 8) { if (arg2 == 2) { this->unk1F4[arg1] = -0x63; @@ -619,7 +617,7 @@ void func_80BABB90(EnSuttari* this, s32 arg1) { f32 sp30; if (this->paths[arg1] != NULL) { - target = func_80BAB698(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &sp30); + target = EnSuttari_GetDistSqAndOrient(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &sp30); if (this->actor.bgCheckFlags & 8) { target = this->actor.wallYaw; } @@ -644,7 +642,7 @@ s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg u16 phi_a0; if (sp1C >= 0) { - this->unk404 = func_8013BB34(globalCtx, sp23, sp1C); + this->unk404 = SubS_GetAdditionalPath(globalCtx, sp23, sp1C); } if (this->unk404 == NULL) { return 0; @@ -686,7 +684,7 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg sp48 = (EnDoor*)SubS_FindNearestActor(&this->actor, globalCtx, ACTORCAT_DOOR, ACTOR_EN_DOOR); sp24 = D_80BAE8F8[unkStruct->unk0]; if ((sp48 != NULL) && (sp24 >= 0)) { - this->unk404 = func_8013BB34(globalCtx, sp47, sp24); + this->unk404 = SubS_GetAdditionalPath(globalCtx, sp47, sp24); } if ((sp48 == NULL) || (this->unk404 == NULL)) { return 0; diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 3db46de49..f0d1a3aa7 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -1175,7 +1175,7 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.info.toucher.damage = 16; } - this->unk_1E4 = func_8013BEDC(globalCtx, ENSW_GET_FF00(&this->actor), 255, &this->unk_4A0); + this->unk_1E4 = SubS_GetDayDependentPath(globalCtx, ENSW_GET_FF00(&this->actor), 255, &this->unk_4A0); if (this->unk_1E4 != NULL) { this->unk_4A0 = 1; } diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 58d0fc0a2..3c72de53d 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -507,7 +507,7 @@ s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* ar u16 phi_a1; s32 idx = arg2->unk0 - 1; - this->unk_3C8 = func_8013BB34(globalCtx, params, D_80AEF8E8[idx + 1]); + this->unk_3C8 = SubS_GetAdditionalPath(globalCtx, params, D_80AEF8E8[idx + 1]); if (this->unk_3C8 == 0) { return false; } diff --git a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c index bca0f4b84..0af7ac4bb 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -203,7 +203,7 @@ void func_80AD36EC(EnTrt2* this, GlobalContext* globalCtx) { this->unk_1E4 = 0; this->unk_3D9 = 1; this->actor.velocity.y = 0.0f; - this->path = func_8013D648(globalCtx, this->path->unk1, -1); + this->path = SubS_GetPathByIndex(globalCtx, this->path->unk1, -1); ActorCutscene_Stop(this->unk_3DA); this->unk_3DA = ActorCutscene_GetAdditionalCutscene(this->unk_3DA); ActorCutscene_SetIntentToPlay(this->unk_3DA); @@ -437,7 +437,7 @@ void func_80AD417C(EnTrt2* this, GlobalContext* globalCtx) { globalCtx->msgCtx.unk12023 = 4; if (this->unk_3A8 == 0x84C) { func_80AD3380(&this->skelAnime, sAnimations, 6); - this->path = func_8013D648(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); this->unk_3B2 = 18; } else if (this->unk_3A8 == 0x88F) { this->unk_3A8 = 0x88E; @@ -708,7 +708,7 @@ void func_80AD4DB4(EnTrt2* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_10; Actor_SetObjectDependency(globalCtx, &this->actor); Actor_SetScale(&this->actor, 0.008f); - this->path = func_8013D648(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); this->unk_3AE = Rand_S16Offset(100, 50); this->unk_3B0 = 10; this->unk_3A8 = 0; diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index e3bfe7f36..909cc2f99 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -723,7 +723,7 @@ s32 func_80A87400(EnTru* this, GlobalContext* globalCtx) { if (this->path != NULL) { sp4C = Lib_SegmentedToVirtual(this->path->points); - if (func_8013BD40(&this->actor, this->path, this->unk_384)) { + if (SubS_HasReachedPoint(&this->actor, this->path, this->unk_384)) { if (this->unk_384 > this->unk_384 + 1) { this->unk_384 = this->path->count - 2; ret = true; @@ -1127,7 +1127,7 @@ void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); this->unk_37C = -1; func_80A86924(this, 0); - this->path = func_8013BEDC(globalCtx, this->actor.params & 0xFF, 255, &this->unk_384); + this->path = SubS_GetDayDependentPath(globalCtx, this->actor.params & 0xFF, 255, &this->unk_384); if (this->path != NULL) { this->unk_384 = 1; } diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c index 37715b513..e191cc3cd 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c @@ -412,7 +412,7 @@ void EnTruMt_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.worldSphere.radius = 22; this->actor.colChkInfo.damageTable = &sDamageTable; - this->path = func_8013D648(globalCtx, ENTRUMT_GET_FF(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENTRUMT_GET_FF(&this->actor), 0x3F); this->actor.targetMode = 0; Actor_SetScale(&this->actor, 0.008f); @@ -420,7 +420,7 @@ void EnTruMt_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_328 = 0; this->actor.room = -1; - this->path = func_8013D648(globalCtx, ENTRUMT_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENTRUMT_GET_FC00(&this->actor), 0x3F); func_80B76030(&this->skelAnime, 14); this->actionFunc = func_80B76A64; } diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 3a9872406..0f91171fb 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -141,12 +141,12 @@ s32 EnZo_PlayWalkingSound(EnZo* this, GlobalContext* globalCtx) { sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) + SFX_FLAG; } - this->isLeftFootGrounded = isFootGrounded = func_8013DB90(globalCtx, &this->leftFootPos, -6.0f); + this->isLeftFootGrounded = isFootGrounded = SubS_IsFloorAbove(globalCtx, &this->leftFootPos, -6.0f); if ((this->isLeftFootGrounded) && (!leftWasGrounded) && (isFootGrounded)) { Actor_PlaySfxAtPos(&this->actor, sfxId); } - this->isRightFootGrounded = isFootGrounded = func_8013DB90(globalCtx, &this->rightFootPos, -6.0f); + this->isRightFootGrounded = isFootGrounded = SubS_IsFloorAbove(globalCtx, &this->rightFootPos, -6.0f); if ((this->isRightFootGrounded) && (!rightWasGrounded) && (isFootGrounded)) { Actor_PlaySfxAtPos(&this->actor, sfxId); } @@ -218,7 +218,7 @@ void EnZo_FollowPath(EnZo* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.speedXZ, 1.0f, 0.4f, 1000.0f, 0.0f); speed = this->actor.speedXZ * 400.0f; - if (func_8013D68C(this->path, this->waypoint, &pos) && func_8013D768(&this->actor, &pos, speed)) { + if (SubS_CopyPointFromPath(this->path, this->waypoint, &pos) && SubS_MoveActorToPoint(&this->actor, &pos, speed)) { this->waypoint++; if (this->waypoint >= this->path->count) { this->waypoint = 0; @@ -259,7 +259,7 @@ void EnZo_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->path = func_8013D648(globalCtx, ENZO_GET_PATH(&this->actor), ENZO_NO_PATH); + this->path = SubS_GetPathByIndex(globalCtx, ENZO_GET_PATH(&this->actor), ENZO_NO_PATH); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = EnZo_Walk; diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 0c6eedbad..bd7da8ff2 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -452,6 +452,18 @@ animdict = { "func_8013E054": "SubS_ActorPathing_MoveWithGravity", "func_8013E07C": "SubS_ActorPathing_MoveWithoutGravityReverse", "func_8013E0A4": "SubS_ActorPathing_SetNextPoint", + "func_8013BB34": "SubS_GetAdditionalPath", + "func_8013BD40": "SubS_HasReachedPoint", + "func_8013BEDC": "SubS_GetDayDependentPath", + "func_8013C8B8": "SubS_CopyPointFromPathCheckBounds", + "func_8013D648": "SubS_GetPathByIndex", + "func_8013D68C": "SubS_CopyPointFromPath", + "func_8013D720": "SubS_GetDistSqAndOrientPoints", + "func_8013D768": "SubS_MoveActorToPoint", + "func_8013D83C": "SubS_GetDistSqAndOrientPath", + "func_8013DB90": "SubS_IsFloorAbove", + "func_8013DC40": "SubS_CopyPointFromPathList", + "func_8013DCCC": "SubS_GetPathCount", "func_80147624": "Message_ShouldAdvance", "func_80147734": "Message_ShouldAdvanceSilent", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 46d871372..a49849eec 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2667,14 +2667,14 @@ 0x8013B350:("func_8013B350",), 0x8013B6B0:("func_8013B6B0",), 0x8013B878:("func_8013B878",), - 0x8013BB34:("func_8013BB34",), + 0x8013BB34:("SubS_GetAdditionalPath",), 0x8013BB7C:("SubS_FindNearestActor",), 0x8013BC6C:("SubS_ChangeAnimationByInfoS",), - 0x8013BD40:("func_8013BD40",), - 0x8013BEDC:("func_8013BEDC",), + 0x8013BD40:("SubS_HasReachedPoint",), + 0x8013BEDC:("SubS_GetDayDependentPath",), 0x8013C068:("func_8013C068",), 0x8013C624:("func_8013C624",), - 0x8013C8B8:("func_8013C8B8",), + 0x8013C8B8:("SubS_CopyPointFromPathCheckBounds",), 0x8013C964:("func_8013C964",), 0x8013CC2C:("func_8013CC2C",), 0x8013CD64:("func_8013CD64",), @@ -2682,18 +2682,18 @@ 0x8013D0E0:("func_8013D0E0",), 0x8013D2E0:("func_8013D2E0",), 0x8013D5E8:("SubS_AngleDiffLessEqual",), - 0x8013D648:("func_8013D648",), - 0x8013D68C:("func_8013D68C",), - 0x8013D720:("func_8013D720",), - 0x8013D768:("func_8013D768",), - 0x8013D83C:("func_8013D83C",), + 0x8013D648:("SubS_GetPathByIndex",), + 0x8013D68C:("SubS_CopyPointFromPath",), + 0x8013D720:("SubS_GetDistSqAndOrientPoints",), + 0x8013D768:("SubS_MoveActorToPoint",), + 0x8013D83C:("SubS_GetDistSqAndOrientPath",), 0x8013D8DC:("SubS_IsObjectLoaded",), 0x8013D924:("SubS_GetObjectIndex",), 0x8013D960:("SubS_FindActor",), 0x8013D9C8:("SubS_FillLimbRotTables",), - 0x8013DB90:("func_8013DB90",), - 0x8013DC40:("func_8013DC40",), - 0x8013DCCC:("func_8013DCCC",), + 0x8013DB90:("SubS_IsFloorAbove",), + 0x8013DC40:("SubS_CopyPointFromPathList",), + 0x8013DCCC:("SubS_GetPathCount",), 0x8013DCE0:("SubS_ActorPathing_Init",), 0x8013DE04:("SubS_ActorPathing_Update",), 0x8013DF3C:("SubS_ActorPathing_ComputePointInfo",), @@ -9654,7 +9654,7 @@ 0x80A0EEC8:("EnSob1_UpdateItemSelectedProperty",), 0x80A0EF48:("EnSob1_UpdateCursorAnim",), 0x80A0F014:("EnSob1_UpdateStickDirectionPromptAnim",), - 0x80A0F1C4:("EnSob1_GetXZAngleAndDistanceSqToPoint",), + 0x80A0F1C4:("EnSob1_GetDistSqAndOrient",), 0x80A0F284:("EnSob1_GetCutscenes",), 0x80A0F2C8:("EnSob1_WaitForBlink",), 0x80A0F2FC:("EnSob1_Blink",), @@ -15211,7 +15211,7 @@ 0x80BAB434:("func_80BAB434",), 0x80BAB490:("EnSuttari_GetPaths",), 0x80BAB4F0:("func_80BAB4F0",), - 0x80BAB698:("func_80BAB698",), + 0x80BAB698:("EnSuttari_GetDistSqAndOrient",), 0x80BAB758:("func_80BAB758",), 0x80BAB8F4:("func_80BAB8F4",), 0x80BABA90:("func_80BABA90",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 78ac67dba..7ead89bdd 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2181,14 +2181,14 @@ asm/non_matchings/code/z_sub_s/func_8013B0C8.s,func_8013B0C8,0x8013B0C8,0xA2 asm/non_matchings/code/z_sub_s/func_8013B350.s,func_8013B350,0x8013B350,0xD8 asm/non_matchings/code/z_sub_s/func_8013B6B0.s,func_8013B6B0,0x8013B6B0,0x72 asm/non_matchings/code/z_sub_s/func_8013B878.s,func_8013B878,0x8013B878,0xAF -asm/non_matchings/code/z_sub_s/func_8013BB34.s,func_8013BB34,0x8013BB34,0x12 +asm/non_matchings/code/z_sub_s/SubS_GetAdditionalPath.s,SubS_GetAdditionalPath,0x8013BB34,0x12 asm/non_matchings/code/z_sub_s/SubS_FindNearestActor.s,SubS_FindNearestActor,0x8013BB7C,0x3C asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationByInfoS.s,SubS_ChangeAnimationByInfoS,0x8013BC6C,0x35 -asm/non_matchings/code/z_sub_s/func_8013BD40.s,func_8013BD40,0x8013BD40,0x67 -asm/non_matchings/code/z_sub_s/func_8013BEDC.s,func_8013BEDC,0x8013BEDC,0x63 +asm/non_matchings/code/z_sub_s/SubS_HasReachedPoint.s,SubS_HasReachedPoint,0x8013BD40,0x67 +asm/non_matchings/code/z_sub_s/SubS_GetDayDependentPath.s,SubS_GetDayDependentPath,0x8013BEDC,0x63 asm/non_matchings/code/z_sub_s/func_8013C068.s,func_8013C068,0x8013C068,0x16F asm/non_matchings/code/z_sub_s/func_8013C624.s,func_8013C624,0x8013C624,0xA5 -asm/non_matchings/code/z_sub_s/func_8013C8B8.s,func_8013C8B8,0x8013C8B8,0x2B +asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathCheckBounds.s,SubS_CopyPointFromPathCheckBounds,0x8013C8B8,0x2B asm/non_matchings/code/z_sub_s/func_8013C964.s,func_8013C964,0x8013C964,0xB2 asm/non_matchings/code/z_sub_s/func_8013CC2C.s,func_8013CC2C,0x8013CC2C,0x4E asm/non_matchings/code/z_sub_s/func_8013CD64.s,func_8013CD64,0x8013CD64,0x68 @@ -2196,18 +2196,18 @@ asm/non_matchings/code/z_sub_s/func_8013CF04.s,func_8013CF04,0x8013CF04,0x77 asm/non_matchings/code/z_sub_s/func_8013D0E0.s,func_8013D0E0,0x8013D0E0,0x80 asm/non_matchings/code/z_sub_s/func_8013D2E0.s,func_8013D2E0,0x8013D2E0,0xC2 asm/non_matchings/code/z_sub_s/SubS_AngleDiffLessEqual.s,SubS_AngleDiffLessEqual,0x8013D5E8,0x18 -asm/non_matchings/code/z_sub_s/func_8013D648.s,func_8013D648,0x8013D648,0x11 -asm/non_matchings/code/z_sub_s/func_8013D68C.s,func_8013D68C,0x8013D68C,0x25 -asm/non_matchings/code/z_sub_s/func_8013D720.s,func_8013D720,0x8013D720,0x12 -asm/non_matchings/code/z_sub_s/func_8013D768.s,func_8013D768,0x8013D768,0x35 -asm/non_matchings/code/z_sub_s/func_8013D83C.s,func_8013D83C,0x8013D83C,0x28 +asm/non_matchings/code/z_sub_s/SubS_GetPathByIndex.s,SubS_GetPathByIndex,0x8013D648,0x11 +asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPath.s,SubS_CopyPointFromPath,0x8013D68C,0x25 +asm/non_matchings/code/z_sub_s/SubS_GetDistSqAndOrientPoints.s,SubS_GetDistSqAndOrientPoints,0x8013D720,0x12 +asm/non_matchings/code/z_sub_s/SubS_MoveActorToPoint.s,SubS_MoveActorToPoint,0x8013D768,0x35 +asm/non_matchings/code/z_sub_s/SubS_GetDistSqAndOrientPath.s,SubS_GetDistSqAndOrientPath,0x8013D83C,0x28 asm/non_matchings/code/z_sub_s/SubS_IsObjectLoaded.s,SubS_IsObjectLoaded,0x8013D8DC,0x12 asm/non_matchings/code/z_sub_s/SubS_GetObjectIndex.s,SubS_GetObjectIndex,0x8013D924,0xF asm/non_matchings/code/z_sub_s/SubS_FindActor.s,SubS_FindActor,0x8013D960,0x1A asm/non_matchings/code/z_sub_s/SubS_FillLimbRotTables.s,SubS_FillLimbRotTables,0x8013D9C8,0x72 -asm/non_matchings/code/z_sub_s/func_8013DB90.s,func_8013DB90,0x8013DB90,0x2C -asm/non_matchings/code/z_sub_s/func_8013DC40.s,func_8013DC40,0x8013DC40,0x23 -asm/non_matchings/code/z_sub_s/func_8013DCCC.s,func_8013DCCC,0x8013DCCC,0x5 +asm/non_matchings/code/z_sub_s/SubS_IsFloorAbove.s,SubS_IsFloorAbove,0x8013DB90,0x2C +asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathList.s,SubS_CopyPointFromPathList,0x8013DC40,0x23 +asm/non_matchings/code/z_sub_s/SubS_GetPathCount.s,SubS_GetPathCount,0x8013DCCC,0x5 asm/non_matchings/code/z_sub_s/SubS_ActorPathing_Init.s,SubS_ActorPathing_Init,0x8013DCE0,0x49 asm/non_matchings/code/z_sub_s/SubS_ActorPathing_Update.s,SubS_ActorPathing_Update,0x8013DE04,0x4E asm/non_matchings/code/z_sub_s/SubS_ActorPathing_ComputePointInfo.s,SubS_ActorPathing_ComputePointInfo,0x8013DF3C,0x46 From 8c7d8359fa1eaf858cd59111c0f7075b30f544d6 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 21:44:07 +0100 Subject: [PATCH 171/257] Obj_Hamishi (#762) --- spec | 3 +- .../actors/ovl_Obj_Hamishi/z_obj_hamishi.c | 261 ++++++++++++++++-- .../actors/ovl_Obj_Hamishi/z_obj_hamishi.h | 13 +- 3 files changed, 252 insertions(+), 25 deletions(-) diff --git a/spec b/spec index 0bfd74504..c99912457 100644 --- a/spec +++ b/spec @@ -2204,8 +2204,7 @@ beginseg name "ovl_Obj_Hamishi" compress include "build/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.o" - include "build/data/ovl_Obj_Hamishi/ovl_Obj_Hamishi.data.o" - include "build/data/ovl_Obj_Hamishi/ovl_Obj_Hamishi.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hamishi/ovl_Obj_Hamishi_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c index b887f7a1b..10d8891ef 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c @@ -5,6 +5,7 @@ */ #include "z_obj_hamishi.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,6 @@ void ObjHamishi_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHamishi_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHamishi_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Hamishi_InitVars = { ACTOR_OBJ_HAMISHI, ACTORCAT_PROP, @@ -28,44 +28,261 @@ const ActorInit Obj_Hamishi_InitVars = { (ActorFunc)ObjHamishi_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809A1AA0 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x81C37FB6, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x81C37FB6, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 50, 70, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_809A1ACC = { 0, 12, 60, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_IMMOVABLE }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809A1AE8[] = { +s16 D_809A1AD4[] = { + 145, 135, 115, 85, 75, 53, 45, 40, 35, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 250, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_STOP), }; -#endif +void func_809A0F20(Actor* thisx, GlobalContext* globalCtx) { + ObjHamishi* this = THIS; -extern ColliderCylinderInit D_809A1AA0; -extern CollisionCheckInfoInit D_809A1ACC; -extern InitChainEntry D_809A1AE8[]; + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A0F20.s") +void func_809A0F78(ObjHamishi* this) { + if (this->unk_198 > 0) { + this->unk_198--; + this->unk_19A += 0x1388; + this->unk_19C += 0xE10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A0F78.s") + Math_StepToF(&this->unk_190, 0.0f, 0.15f); + Math_StepToF(&this->unk_194, 0.0f, 40.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A10F4.s") + this->actor.world.pos.x = (Math_SinS(this->unk_19A * 4) * this->unk_190) + this->actor.home.pos.x; + this->actor.world.pos.z = (Math_CosS(this->unk_19A * 7) * this->unk_190) + this->actor.home.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A13A0.s") + this->actor.shape.rot.x = (s32)(Math_SinS(this->unk_19C * 4) * this->unk_194) + this->actor.home.rot.x; + this->actor.shape.rot.z = (s32)(Math_CosS(this->unk_19C * 7) * this->unk_194) + this->actor.home.rot.z; + } else { + Math_StepToF(&this->actor.world.pos.x, this->actor.home.pos.x, 1.0f); + Math_StepToF(&this->actor.world.pos.z, this->actor.home.pos.z, 1.0f); + Math_ScaledStepToS(&this->actor.shape.rot.x, this->actor.home.rot.x, 0xBB8); + Math_ScaledStepToS(&this->actor.shape.rot.z, this->actor.home.rot.z, 0xBB8); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A1408.s") +void func_809A10F4(ObjHamishi* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spC8; + Vec3f spBC; + f32 temp_f20; + s16 temp_s0 = 1000; + s32 gravity; + s32 phi_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/ObjHamishi_Init.s") + for (i = 0; i < ARRAY_COUNT(D_809A1AD4); i++) { + temp_s0 += 0x4E20; + temp_f20 = Rand_ZeroOne() * 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/ObjHamishi_Destroy.s") + spBC.x = (Math_SinS(temp_s0) * temp_f20) + this->actor.world.pos.x; + spBC.y = (Rand_ZeroOne() * 40.0f) + this->actor.world.pos.y + 5.0f; + spBC.z = (Math_CosS(temp_s0) * temp_f20) + this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/ObjHamishi_Update.s") + temp_f20 = (Rand_ZeroOne() * 10.0f) + 2.0f; + spC8.x = Math_SinS(temp_s0) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/ObjHamishi_Draw.s") + spC8.y = (Rand_ZeroOne() * 15.0f) + (Rand_ZeroOne() * i * 2.5f); + spC8.z = Math_CosS(temp_s0) * temp_f20; + + if (i == 0) { + phi_v0 = 41; + gravity = -450; + } else if (i < 4) { + phi_v0 = 37; + gravity = -380; + } else { + phi_v0 = 69; + gravity = -320; + } + + EffectSsKakera_Spawn(globalCtx, &spBC, &spC8, &this->actor.world.pos, gravity, phi_v0, 30, 5, 0, D_809A1AD4[i], + 3, 0, 70, 1, GAMEPLAY_FIELD_KEEP, gameplay_field_keep_DL_006420); + } + + func_800BBFB0(globalCtx, &this->actor.world.pos, 140.0f, 6, 180, 90, 1); + func_800BBFB0(globalCtx, &this->actor.world.pos, 140.0f, 12, 80, 90, 1); +} + +void func_809A13A0(ObjHamishi* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp28; + s32 sp24; + + sp28.x = this->actor.world.pos.x; + sp28.y = this->actor.world.pos.y + 30.0f; + sp28.z = this->actor.world.pos.z; + + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp24, &this->actor, &sp28); +} + +s32 func_809A1408(ObjHamishi* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* sp30; + f32 sp2C; + s32 sp28; + + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp2C, + &sp30, &sp28) && + (this->actor.world.pos.y < sp2C)) { + return true; + } + return false; +} + +void ObjHamishi_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjHamishi* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if (globalCtx->csCtx.state != 0) { + this->actor.uncullZoneForward += 1000.0f; + } + + if (this->actor.shape.rot.y == 0) { + this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.home.rot.y = this->actor.shape.rot.y; + } + + func_809A0F20(&this->actor, globalCtx); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + func_809A13A0(this, globalCtx); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 2.3f); + + if (Flags_GetSwitch(globalCtx, OBJHAMISHI_GET_SWITCHFLAG(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->actor.shape.yOffset = 80.0f; + + if (func_809A1408(this, globalCtx)) { + this->unk_1A2 |= 1; + } +} + +void ObjHamishi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyCylinder(globalCtx, &THIS->collider); +} + +void ObjHamishi_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjHamishi* this = THIS; + s32 sp24 = (this->collider.base.acFlags & AC_HIT) != 0; + + func_809A0F78(this); + + if (sp24) { + this->unk_1A1 = 5; + this->collider.base.acFlags &= ~AC_HIT; + } + + if (sp24) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000500) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x400) { + this->unk_1A0 = 26; + } else { + this->unk_1A0 = 11; + } + + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000000) { + this->unk_19E = 2; + } else { + this->unk_19E++; + } + + if (this->unk_19E < 2) { + this->unk_198 = 15; + this->unk_190 = 2.0f; + this->unk_194 = 400.0f; + } else { + func_809A10F4(this, globalCtx); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_WALL_BROKEN); + Flags_SetSwitch(globalCtx, OBJHAMISHI_GET_SWITCHFLAG(&this->actor)); + Actor_MarkForDeath(&this->actor); + } + } + } + + if (this->actor.update != NULL) { + if (this->unk_1A1 > 0) { + this->unk_1A1--; + if (this->unk_1A1 == 0) { + this->collider.base.colType = COLTYPE_HARD; + } else { + this->collider.base.colType = COLTYPE_NONE; + } + } + + if (this->unk_1A0 > 0) { + this->unk_1A0--; + } else if ((this->actor.flags & ACTOR_FLAG_40) && (this->actor.xzDistToPlayer < 1000.0f)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->actor.xzDistToPlayer < 600.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void ObjHamishi_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjHamishi* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((thisx->projectedPos.z <= 2150.0f) || ((this->unk_1A2 & 1) && (thisx->projectedPos.z < 2250.0f))) { + thisx->shape.shadowAlpha = 160; + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 170, 130, 255); + gSPDisplayList(POLY_OPA_DISP++, gameplay_field_keep_DL_0061E8); + } else if (thisx->projectedPos.z < 2250.0f) { + f32 sp20 = (2250.0f - thisx->projectedPos.z) * 2.55f; + + thisx->shape.shadowAlpha = sp20 * 0.627451f; + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 170, 130, (s32)sp20); + gSPDisplayList(POLY_XLU_DISP++, gameplay_field_keep_DL_0061E8); + } else { + thisx->shape.shadowAlpha = 0; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h index 1305f49ee..da838d480 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h @@ -5,9 +5,20 @@ struct ObjHamishi; +#define OBJHAMISHI_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) + typedef struct ObjHamishi { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x60]; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ f32 unk_190; + /* 0x194 */ f32 unk_194; + /* 0x198 */ s16 unk_198; + /* 0x19A */ s16 unk_19A; + /* 0x19C */ s16 unk_19C; + /* 0x19E */ s16 unk_19E; + /* 0x1A0 */ s8 unk_1A0; + /* 0x1A1 */ s8 unk_1A1; + /* 0x1A2 */ u8 unk_1A2; } ObjHamishi; // size = 0x1A4 extern const ActorInit Obj_Hamishi_InitVars; From 72bae2b6ba70c6631e2f68c92bab369f7d6bf829 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Tue, 29 Mar 2022 18:04:41 -0300 Subject: [PATCH 172/257] `z_kaleido_setup` (#768) * KaleidoSetup_Init * func_800F4C0C * func_800F4A10 NON_EQUIVALENT * fixes * func_800F4A10 * import data * Rename Play_InCsMode * Name KaleidoSetup_Update * minor cleanup * Update src/code/z_play.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_En_Bom/z_en_bom.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_En_Gs/z_en_gs.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/code/z_kaleido_setup.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/code/z_kaleido_setup.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/code/z_kaleido_setup.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_Door_Ana/z_door_ana.c Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/overlays/actors/ovl_Door_Ana/z_door_ana.c * unname D_801BDB00 * format * a * actorfixer Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> --- include/functions.h | 9 +- include/variables.h | 4 +- spec | 1 - src/code/z_kaleido_setup.c | 144 +++++++++++++++++- src/code/z_lifemeter.c | 5 +- src/code/z_message.c | 2 +- src/code/z_play.c | 4 +- src/overlays/actors/ovl_Door_Ana/z_door_ana.c | 6 +- .../actors/ovl_Door_Warp1/z_door_warp1.c | 6 +- src/overlays/actors/ovl_En_Bom/z_en_bom.c | 2 +- .../actors/ovl_En_Bomjimb/z_en_bomjimb.c | 4 +- .../actors/ovl_En_Dinofos/z_en_dinofos.c | 2 +- src/overlays/actors/ovl_En_Dnq/z_en_dnq.c | 2 +- src/overlays/actors/ovl_En_Dns/z_en_dns.c | 2 +- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 2 +- src/overlays/actors/ovl_En_Gs/z_en_gs.c | 4 +- src/overlays/actors/ovl_En_Hs/z_en_hs.c | 2 +- .../actors/ovl_En_Look_Nuts/z_en_look_nuts.c | 6 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 2 +- src/overlays/actors/ovl_En_Rg/z_en_rg.c | 4 +- .../actors/ovl_En_Tanron5/z_en_tanron5.c | 2 +- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 2 +- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 4 +- .../ovl_En_Water_Effect/z_en_water_effect.c | 2 +- .../ovl_file_choose/z_file_choose.h | 9 ++ tools/actorfixer.py | 11 +- tools/disasm/functions.txt | 4 +- tools/disasm/variables.txt | 4 +- tools/sizes/code_functions.csv | 4 +- 29 files changed, 200 insertions(+), 55 deletions(-) diff --git a/include/functions.h b/include/functions.h index ed9c8541b..75c0727b3 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1500,9 +1500,10 @@ void func_800F40A0(GameState* gameState, Player* player); UNK_TYPE func_800F41E4(GlobalContext* globalCtx, ActorContext* actorCtx); void func_800F4A10(GlobalContext* globalCtx); -void func_800F4C0C(GlobalContext* globalCtx); +void KaleidoSetup_Update(GlobalContext* globalCtx); void KaleidoSetup_Init(GlobalContext* globalCtx); void KaleidoSetup_Destroy(GlobalContext* globalCtx); + void Font_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32 offset); void Font_LoadCharNES(GlobalContext* globalCtx, u8 codePointIndex, s32 offset); void Font_LoadMessageBoxEndIcon(Font* font, u16 icon); @@ -2745,7 +2746,7 @@ void func_80167DE4(GlobalContext* globalCtx); void Play_Draw(GlobalContext* globalCtx); void func_80168DAC(GlobalContext* globalCtx); void Play_Update(GlobalContext* globalCtx); -s32 func_801690CC(GlobalContext* globalCtx); +s32 Play_InCsMode(GlobalContext* globalCtx); f32 func_80169100(GlobalContext* globalCtx, MtxF* mtx, CollisionPoly** arg2, s32* arg3, Vec3f* feetPosPtr); // void func_801691F0(void); void* Play_LoadScene(GlobalContext* globalCtx, RomFile* entry); @@ -3564,9 +3565,9 @@ void func_801A31EC(u16 seqId, s8 arg1, u8 arg2); // void func_801A3590(void); u8 func_801A3950(s32 playerIndex, s32 isChannelIOSet); u8 func_801A39F8(void); -// void func_801A3A7C(void); +void func_801A3A7C(s32 arg0); // void func_801A3AC0(void); -// void func_801A3AEC(void); +void func_801A3AEC(s32 arg0); void func_801A3B48(UNK_TYPE arg0); // void func_801A3B90(void); void func_801A3CD8(s8 param_1); diff --git a/include/variables.h b/include/variables.h index 4d2e0e42c..f603f7c1a 100644 --- a/include/variables.h +++ b/include/variables.h @@ -908,9 +908,7 @@ extern UNK_TYPE4 D_801BDAA4; // extern UNK_TYPE4 D_801BDACC; // extern UNK_TYPE4 D_801BDAF0; // extern UNK_TYPE4 D_801BDAF8; -// extern UNK_TYPE1 D_801BDB00; -// extern UNK_TYPE1 D_801BDB08; -// extern UNK_TYPE1 D_801BDB18; + extern u8 kanfontOrdering[92]; // extern UNK_TYPE4 D_801BDB90; // extern UNK_TYPE4 D_801BDB94; diff --git a/spec b/spec index c99912457..f028bfa1a 100644 --- a/spec +++ b/spec @@ -479,7 +479,6 @@ beginseg include "build/data/code/z_horse.data.o" include "build/src/code/z_jpeg.o" include "build/src/code/z_kaleido_setup.o" - include "build/data/code/z_kaleido_setup.data.o" include "build/src/code/z_kanfont.o" include "build/src/code/z_kankyo.o" include "build/data/code/z_kankyo.data.o" diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 7f4d43784..5a234ea44 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -1,9 +1,145 @@ #include "global.h" +#include "overlays/gamestates/ovl_file_choose/z_file_choose.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/func_800F4A10.s") +s16 D_801BDB00[] = { PAUSE_1, PAUSE_2, PAUSE_3, PAUSE_0 }; +f32 sKaleidoSetupEyeX[] = { -64.0f, 0.0f, 64.0f, 0.0f }; +f32 sKaleidoSetupEyeZ[] = { 0.0f, -64.0f, 0.0f, 64.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/func_800F4C0C.s") +void func_800F4A10(GlobalContext* globalCtx) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/KaleidoSetup_Init.s") + func_8013EE24(); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/KaleidoSetup_Destroy.s") + pauseCtx->unk_206 = 0; + pauseCtx->unk_200 = 1; + pauseCtx->eye.x = sKaleidoSetupEyeX[pauseCtx->pageIndex]; + pauseCtx->eye.z = sKaleidoSetupEyeZ[pauseCtx->pageIndex]; + pauseCtx->pageIndex = D_801BDB00[pauseCtx->pageIndex]; + pauseCtx->unk_27E = -40; + + for (i = 0; i < ARRAY_COUNT(pauseCtx->worldMapPoints); i++) { + pauseCtx->worldMapPoints[i] = 0; + } + + if (pauseCtx->state == 1) { + for (i = 0; i < 11; i++) { + if ((gSaveContext.save.mapsVisited >> i) & 1) { + pauseCtx->worldMapPoints[i] = 1; + } + } + } else { + for (i = 9; i >= 0; i--) { + if ((gSaveContext.save.playerData.owlActivationFlags >> i) & 1) { + pauseCtx->worldMapPoints[i] = 1; + pauseCtx->unk_238[4] = i; + } + } + + if ((gSaveContext.save.playerData.owlActivationFlags >> 4) & 1) { + pauseCtx->unk_238[4] = 4; + } + } + + YREG(11) = -0x00C8; + YREG(12) = -0x3840; + YREG(13) = 0x2710; + YREG(14) = 0x2710; + YREG(15) = 0x2710; + YREG(16) = -0x00BE; + YREG(17) = -0x06D6; + YREG(18) = -0x0B90; + YREG(19) = 0x06E0; + YREG(20) = 0; + YREG(21) = -0x0622; + YREG(22) = -0x0C44; + YREG(23) = 0x0622; + YREG(24) = -0x0622; + YREG(25) = -0x005A; + YREG(26) = -0x3840; +} + +void KaleidoSetup_Update(GlobalContext* globalCtx) { + Input* input = CONTROLLER1(globalCtx); + MessageContext* msgCtx = &globalCtx->msgCtx; + Player* player = GET_PLAYER(globalCtx); + PauseContext* pauseCtx = &globalCtx->pauseCtx; + + if (CHECK_BTN_ALL(input->cur.button, BTN_R)) { + if (msgCtx && msgCtx) {} + } + + if ((pauseCtx->state == 0) && (pauseCtx->debugState == 0) && (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE)) { + if ((globalCtx->sceneLoadFlag == 0) && (globalCtx->unk_18B4A == 0)) { + if ((gSaveContext.save.cutscene < 0xFFF0) && (gSaveContext.nextCutsceneIndex < 0xFFF0)) { + if (!Play_InCsMode(globalCtx) || ((msgCtx->msgMode != 0) && (msgCtx->currentTextId == 0xFF))) { + if ((globalCtx->unk_1887C < 2) && (gSaveContext.unk_3F28 != 8) && (gSaveContext.unk_3F28 != 9)) { + if (!(gSaveContext.eventInf[1] & 0x80) && !(player->stateFlags1 & 0x20)) { + if (!(globalCtx->actorCtx.unk5 & 2) && !(globalCtx->actorCtx.unk5 & 4)) { + if ((globalCtx->actorCtx.unk268 == 0) && + CHECK_BTN_ALL(input->press.button, BTN_START)) { + gSaveContext.unk_3F26 = gSaveContext.unk_3F22; + pauseCtx->unk_2B9 = 0; + pauseCtx->state = 1; + func_800F4A10(globalCtx); + pauseCtx->mode = pauseCtx->pageIndex * 2 + 1; + func_801A3A7C(1); + } + + if (pauseCtx->state == 1) { + Game_SetFramerateDivisor(&globalCtx->state, 2); + if (ShrinkWindow_GetLetterboxTarget() != 0) { + ShrinkWindow_SetLetterboxTarget(0); + } + func_801A3AEC(1); + } + } + } + } + } + } + } + } +} + +void KaleidoSetup_Init(GlobalContext* globalCtx) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + s32 pad[2]; + + bzero(pauseCtx, sizeof(PauseContext)); + + pauseCtx->pageIndex = PAUSE_0; + + pauseCtx->unk_21C = 160.0f; + pauseCtx->unk_218 = 160.0f; + pauseCtx->unk_214 = 160.0f; + pauseCtx->unk_210 = 160.0f; + + pauseCtx->eye.x = -64.0f; + pauseCtx->unk_20C = 936.0f; + pauseCtx->unk_220 = -314.0f; + + pauseCtx->unk_238[PAUSE_1] = XREG(94) + 3; + + pauseCtx->unk_258 = 11; + pauseCtx->unk_25A = 0; + + pauseCtx->unk_25E[PAUSE_0] = 999; + pauseCtx->unk_25E[PAUSE_1] = XREG(94) + 3; + pauseCtx->unk_25E[PAUSE_2] = 999; + pauseCtx->unk_25E[PAUSE_3] = 999; + + pauseCtx->unk_268[PAUSE_0] = 0; + pauseCtx->unk_268[PAUSE_1] = XREG(94) + 3; + + pauseCtx->unk_284 = 2; + pauseCtx->unk_2A0 = -1; + pauseCtx->unk_2BA = 320; + pauseCtx->unk_2BC = 40; + pauseCtx->unk_29E = 100; + + View_Init(&pauseCtx->view, globalCtx->state.gfxCtx); +} + +void KaleidoSetup_Destroy(GlobalContext* globalCtx) { +} diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index d89b427e9..73ba326b5 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -399,9 +399,8 @@ void LifeMeter_UpdateSizeAndBeep(GlobalContext* globalCtx) { if (interfaceCtx->lifeSizeChange <= 0) { interfaceCtx->lifeSizeChange = 0; interfaceCtx->lifeSizeChangeDirection = 0; - if (Player_InCsMode(&globalCtx->state) == 0 && (globalCtx->pauseCtx.state == 0) && - (globalCtx->pauseCtx.debugState == 0) && LifeMeter_IsCritical() && func_801690CC(globalCtx) == 0) { - // Player_InCsMode and func_801690CC : Check if in Cutscene + if (!Player_InCsMode(&globalCtx->state) && (globalCtx->pauseCtx.state == 0) && + (globalCtx->pauseCtx.debugState == 0) && LifeMeter_IsCritical() && !Play_InCsMode(globalCtx)) { play_sound(NA_SE_SY_HITPOINT_ALARM); } } diff --git a/src/code/z_message.c b/src/code/z_message.c index d7fdbff42..f41c713f6 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -499,7 +499,7 @@ void func_80156758(GlobalContext* globalCtx) { nextDisplayList = Graph_GfxPlusOne(polyOpa); gSPDisplayList(OVERLAY_DISP++, nextDisplayList); - if ((globalCtx->msgCtx.currentTextId != 0x5E6) || (func_801690CC(globalCtx) == 0)) { + if ((globalCtx->msgCtx.currentTextId != 0x5E6) || !Play_InCsMode(globalCtx)) { func_801541D4(globalCtx, &nextDisplayList); } diff --git a/src/code/z_play.c b/src/code/z_play.c index 57b09f67e..aa360934e 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -58,7 +58,9 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Update.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_801690CC.s") +s32 Play_InCsMode(GlobalContext* globalCtx) { + return (globalCtx->csCtx.state != 0) || Player_InCsMode(&globalCtx->state); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169100.s") diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c index b512dff9a..0d1daa6b5 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -156,9 +156,9 @@ void DoorAna_WaitOpen(DoorAna* this, GlobalContext* globalCtx) { DoorAna_SetupAction(this, DoorAna_GrabLink); - } else if (func_801690CC(globalCtx) == 0 && (player->stateFlags1 & 0x08800000) == 0 && - this->actor.xzDistToPlayer <= 20.0f && this->actor.playerHeightRel >= -50.0f && - this->actor.playerHeightRel <= 15.0f) { + } else if (!Play_InCsMode(globalCtx) && !(player->stateFlags1 & 0x08800000) && + (this->actor.xzDistToPlayer <= 20.0f) && (this->actor.playerHeightRel >= -50.0f) && + (this->actor.playerHeightRel <= 15.0f)) { player->stateFlags1 |= 0x80000000; this->actor.targetMode = 1; diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index 0360ae87a..b2b05230f 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -343,7 +343,7 @@ void func_808B921C(DoorWarp1* this, GlobalContext* globalCtx) { func_808BB8D4(this, globalCtx, 1); } - if (func_808B866C(this, globalCtx) && !func_801690CC(globalCtx)) { + if (func_808B866C(this, globalCtx) && !Play_InCsMode(globalCtx)) { func_800B7298(globalCtx, &this->dyna.actor, 7); Message_StartTextbox(globalCtx, 0xF2, &this->dyna.actor); DoorWarp1_SetupAction(this, func_808B93A0); @@ -443,7 +443,7 @@ void func_808B96B0(DoorWarp1* this, GlobalContext* globalCtx) { void func_808B977C(DoorWarp1* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); - if (func_808B866C(this, globalCtx) && !func_801690CC(globalCtx)) { + if (func_808B866C(this, globalCtx) && !Play_InCsMode(globalCtx)) { Player* player = GET_PLAYER(globalCtx); Audio_PlaySfxGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); @@ -595,7 +595,7 @@ void func_808B9ED8(DoorWarp1* this, GlobalContext* globalCtx) { void func_808B9F10(DoorWarp1* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); - if ((this->unk_203 == 0) && func_808B866C(this, globalCtx) && !func_801690CC(globalCtx) && (this->unk_203 == 0)) { + if ((this->unk_203 == 0) && func_808B866C(this, globalCtx) && !Play_InCsMode(globalCtx) && (this->unk_203 == 0)) { Player* player = GET_PLAYER(globalCtx); Interface_ChangeAlpha(1); diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/src/overlays/actors/ovl_En_Bom/z_en_bom.c index 57a88bcef..eeae2b8de 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -455,7 +455,7 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx) { } else { thisx->gravity = -1.2f; if (this->timer != 0) { - if (!this->isPowderKeg || (func_808715B8 == this->actionFunc) || !func_801690CC(globalCtx)) { + if (!this->isPowderKeg || (func_808715B8 == this->actionFunc) || !Play_InCsMode(globalCtx)) { this->timer--; } } diff --git a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c index 915b785cd..c18a94209 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -209,7 +209,7 @@ void func_80C012E0(EnBomjimb* this) { s32 func_80C012FC(EnBomjimb* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (!func_801690CC(globalCtx) && (this->actor.xzDistToPlayer < 40.0f) && + if (!Play_InCsMode(globalCtx) && (this->actor.xzDistToPlayer < 40.0f) && (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 50.0f) && (globalCtx->msgCtx.unk11F10 == 0)) { this->actor.speedXZ = 0.0f; func_80C02740(this, globalCtx); @@ -722,7 +722,7 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { break; } - if (!func_801690CC(globalCtx)) { + if (!Play_InCsMode(globalCtx)) { Player* player = GET_PLAYER(globalCtx); player->stateFlags1 |= 0x10000000; diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index 9236ce6fa..e06e2e776 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -1234,7 +1234,7 @@ void func_8089D42C(EnDinofos* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->unk_28E, cos_rad(M_PI) * 0x2C00, 0x233); } else if (this->actionFunc == func_8089CBEC) { this->unk_28E = cos_rad(this->unk_290 * (M_PI / 20)) * 0x2C00; - } else if (!func_801690CC(globalCtx)) { + } else if (!Play_InCsMode(globalCtx)) { temp_v0_2 = this->unk_28E + this->actor.shape.rot.y; temp_v0_2 = BINANG_SUB(this->actor.yawTowardsPlayer, temp_v0_2); temp_v0_2 = CLAMP(temp_v0_2, -0x300, 0x300); diff --git a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c index 535201ac3..917a2d4d9 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -342,7 +342,7 @@ void func_80A52DC8(EnDnq* this, GlobalContext* globalCtx) { if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { this->unk_390 = 70.0f; - if (Interface_HasItemInBottle(ITEM_DEKU_PRINCESS) && !func_801690CC(globalCtx) && + if (Interface_HasItemInBottle(ITEM_DEKU_PRINCESS) && !Play_InCsMode(globalCtx) && (Message_GetState(&globalCtx->msgCtx) == 0) && (ActorCutscene_GetCurrentIndex() == -1)) { if ((DECR(this->unk_384) == 0) && (gSaveContext.save.weekEventReg[29] & 0x40)) { Message_StartTextbox(globalCtx, 0x969, NULL); diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c index 646a2b778..e2c07cce7 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -274,7 +274,7 @@ s32 func_8092CC68(GlobalContext* globalCtx) { s32 ret = false; s16 bgId; - if (!func_801690CC(globalCtx) && (player->actor.bgCheckFlags & 1) && (player->transformation != PLAYER_FORM_DEKU)) { + if (!Play_InCsMode(globalCtx) && (player->actor.bgCheckFlags & 1) && (player->transformation != PLAYER_FORM_DEKU)) { bgId = player->actor.floorBgId; if (SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, player->actor.floorPoly, bgId) != 4) { ret = true; diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index 782b56f7e..62d455147 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -1504,7 +1504,7 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { } else { this->actionFunc(this, globalCtx); - if (!func_801690CC(globalCtx)) { + if (!Play_InCsMode(globalCtx)) { if (gSaveContext.save.playerData.tatlTimer < 25800) { gSaveContext.save.playerData.tatlTimer++; } else if (!(this->fairyFlags & 0x80)) { 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 3e7f73775..cfd252d07 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -533,8 +533,8 @@ s32 func_80998A48(EnGs* this, GlobalContext* globalCtx) { } else if (this->unk_19D == 1) { if (func_80998334(this, globalCtx, &this->unk_1DC, &this->unk_1E0, &this->unk_1D4, 0.8f, 0.007f, 0.001f, 7, 0) == 0.0f) { - if ((this->actor.params != ENGS_0) && !func_801690CC(globalCtx) && - Message_GetState(&globalCtx->msgCtx) == 0) { + if ((this->actor.params != ENGS_0) && !Play_InCsMode(globalCtx) && + (Message_GetState(&globalCtx->msgCtx) == 0)) { this->unk_216 = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIVE_LUPY_COUNT); Message_StartTextbox(globalCtx, 0x20D2, NULL); 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 8bc720489..2f68a1a1d 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -222,7 +222,7 @@ void func_809532D0(EnHs* this, GlobalContext* globalCtx) { } void func_80953354(EnHs* this, GlobalContext* globalCtx) { - if (!func_801690CC(globalCtx)) { + if (!Play_InCsMode(globalCtx)) { func_800B7298(globalCtx, &this->actor, 7); this->actionFunc = func_809532D0; } diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c index d687c2aa8..07b9e8db0 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c @@ -149,7 +149,7 @@ void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx) { f32 sp30; SkelAnime_Update(&this->skelAnime); - if (func_801690CC(globalCtx) != 0) { + if (Play_InCsMode(globalCtx)) { this->actor.speedXZ = 0.0f; return; } @@ -205,7 +205,7 @@ void EnLookNuts_StandAndWait(EnLookNuts* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); Math_ApproachZeroF(&this->actor.speedXZ, 0.3f, 1.0f); - if ((func_801690CC(globalCtx) == 0) && (D_80A6862C == 0) && (this->eventTimer == 0)) { + if (!Play_InCsMode(globalCtx) && (D_80A6862C == 0) && (this->eventTimer == 0)) { this->eventTimer = 10; switch (this->waitTimer) { case 0: @@ -351,7 +351,7 @@ void EnLookNuts_Update(Actor* thisx, GlobalContext* globalCtx) { if ((this->isPlayerDetected == true) || (this->actor.xzDistToPlayer < 20.0f)) { Player* player = GET_PLAYER(globalCtx); - if (!(player->stateFlags3 & 0x100) && !func_801690CC(globalCtx)) { + if (!(player->stateFlags3 & 0x100) && !Play_InCsMode(globalCtx)) { Math_Vec3f_Copy(&this->headRotTarget, &gZeroVec3f); this->state = PALACE_GUARD_RUNNING_TO_PLAYER; play_sound(NA_SE_SY_FOUND); diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c index 901e226c5..542238a17 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -1035,7 +1035,7 @@ void EnPametfrog_LookAround(EnPametfrog* this, GlobalContext* globalCtx) { EnPametfrog_IdleWaterEffects(this, globalCtx); Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 5, 0x400, 0x80); this->actor.shape.rot.y = this->actor.world.rot.y; - if (SkelAnime_Update(&this->skelAnime) && (func_801690CC(globalCtx) == 0)) { + if (SkelAnime_Update(&this->skelAnime) && !Play_InCsMode(globalCtx)) { if (!this->unk_2AE) { func_801A2E54(NA_BGM_MINI_BOSS); this->unk_2AE = true; diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index bf7158d73..13d4a93e9 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -683,7 +683,7 @@ void func_80BF4EBC(EnRg* this, GlobalContext* globalCtx) { void func_80BF4FC4(EnRg* this, GlobalContext* globalCtx) { this->unk_344 = func_80BF4560(this, globalCtx); - if (!func_801690CC(globalCtx)) { + if (!Play_InCsMode(globalCtx)) { if (this->actor.bgCheckFlags & 2) { if (this->unk_310 & 0x400) { this->unk_310 &= ~0x400; @@ -802,7 +802,7 @@ void EnRg_Update(Actor* thisx, GlobalContext* globalCtx) { func_80BF3ED4(this, globalCtx); - if (!func_801690CC(globalCtx)) { + if (!Play_InCsMode(globalCtx)) { func_80BF3C64(this); } } diff --git a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c index d5600e0e1..ada39da61 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c @@ -271,7 +271,7 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { this->collider.base.acFlags &= ~AC_HIT; spC4 = 10; - if (func_801690CC(globalCtx)) { + if (Play_InCsMode(globalCtx)) { this->unk_144 = 1; } else { this->unk_144 = 5; diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index 5dc94a1c4..3d6687263 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -369,7 +369,7 @@ void EnTest4_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((globalCtx->unk_18B4A == 0) && (func_801690CC(globalCtx) == 0) && (globalCtx->numSetupActors <= 0) && + if ((globalCtx->unk_18B4A == 0) && !Play_InCsMode(globalCtx) && (globalCtx->numSetupActors <= 0) && (globalCtx->roomCtx.unk31 == 0) && (func_8016A168() == 0)) { s16 temp_a2; u16 temp_a0 = D_80A43364[this->unk_144]; diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 3c72de53d..976a5ac31 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -1043,7 +1043,7 @@ s32 func_80AEE86C(EnTk* this, GlobalContext* globalCtx) { (this->actor.xyzDistToPlayerSq <= SQ(115.0f)) && func_80AEE7E0(&this->actor.world.pos, 100.0f, this->unk_324, this->unk_36C) && (((this->unk_2CA & 2) && (Math_Vec3f_DistXZ(&this->unk_300, &sp28) >= 100.0f)) || !(this->unk_2CA & 2)) && - !func_801690CC(globalCtx)) { + !Play_InCsMode(globalCtx)) { Math_Vec3f_Copy(&this->unk_300, &sp28); ret = true; } @@ -1189,7 +1189,7 @@ void func_80AEED38(EnTk* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; } - if (Message_GetState(&globalCtx->msgCtx) == 0 && !func_801690CC(globalCtx) && (this->unk_2C6-- <= 0)) { + if (Message_GetState(&globalCtx->msgCtx) == 0 && !Play_InCsMode(globalCtx) && (this->unk_2C6-- <= 0)) { Message_StartTextbox(globalCtx, 0x140C, NULL); this->unk_2CA |= 0x4000; this->unk_2C6 = 200; diff --git a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c index 314d168cc..127bcc1c2 100644 --- a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c +++ b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c @@ -405,7 +405,7 @@ void func_80A59C04(Actor* thisx, GlobalContext* globalCtx2) { if ((rotaryRoom != NULL) && Flags_GetSwitch(globalCtx, (rotaryRoom->params >> 1) & 0x7F)) { this->unk_DC6 = Rand_ZeroFloat(150.0f) + 100.0f; - } else if (!func_801690CC(globalCtx)) { + } else if (!Play_InCsMode(globalCtx)) { this->unk_DC4++; if (this->unk_DC6 == 0) { this->unk_DC6 = Rand_ZeroFloat(150.0f) + 100.0f; diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose.h b/src/overlays/gamestates/ovl_file_choose/z_file_choose.h index 74fd293d0..78c4a9a62 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.h +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.h @@ -113,4 +113,13 @@ typedef struct FileChooseContext { /* 0x24550 */ s16 unk_24550; } FileChooseContext; // size = 0x24558 +// TODO: Confirm those values has the same meaning as their OoT counterparts +typedef enum { + /* 0x00 */ PAUSE_0, // PAUSE_ITEM + /* 0x01 */ PAUSE_1, // PAUSE_MAP + /* 0x02 */ PAUSE_2, // PAUSE_QUEST + /* 0x03 */ PAUSE_3, // PAUSE_EQUIP + /* 0x04 */ PAUSE_4 // PAUSE_WORLD_MAP +} PauseMenuPage; + #endif diff --git a/tools/actorfixer.py b/tools/actorfixer.py index bd7da8ff2..d7ffef8d1 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -403,6 +403,12 @@ animdict = { "func_80169BC4": "Play_CameraGetUID", "func_80169C64": "Play_GetCsCamDataSetting", "func_80169C84": "Play_GetCsCamDataVec3s", + "convert_scene_number_among_shared_scenes": "Play_GetOriginalSceneNumber", + "func_80169D40": "Play_SaveCycleSceneFlags", + "func_80169DCC": "Play_SetRespawnData", + "func_80169E6C": "Play_SetupRespawnPoint", + "func_8016A0AC": "Play_IsUnderwater", + "func_801690CC": "Play_InCsMode", "func_8017D2FC": "Math3D_LineSegVsPlane", "func_8013A7C0": "SubS_FindDoor", "func_8013E640": "SubS_FindActorCustom", @@ -411,11 +417,6 @@ animdict = { "func_800A81F0": "EffectBlure_AddVertex", "func_800A8514": "EffectBlure_AddSpace", "Effect_GetParams": "Effect_GetByIndex", - "convert_scene_number_among_shared_scenes": "Play_GetOriginalSceneNumber", - "func_80169D40": "Play_SaveCycleSceneFlags", - "func_80169DCC": "Play_SetRespawnData", - "func_80169E6C": "Play_SetupRespawnPoint", - "func_8016A0AC": "Play_IsUnderwater", "func_800F5A8C": "Environment_LerpWeight", "func_801A3F54": "Audio_SetCutsceneFlag", "func_800EA0D4": "Cutscene_Start", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index a49849eec..abfae35aa 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1699,7 +1699,7 @@ 0x800F4540:("Jpeg_ParseMarkers",), 0x800F470C:("Jpeg_Decode",), 0x800F4A10:("func_800F4A10",), - 0x800F4C0C:("func_800F4C0C",), + 0x800F4C0C:("KaleidoSetup_Update",), 0x800F4E20:("KaleidoSetup_Init",), 0x800F4F28:("KaleidoSetup_Destroy",), 0x800F4F40:("Font_LoadChar",), @@ -2998,7 +2998,7 @@ 0x80168090:("Play_Draw",), 0x80168DAC:("func_80168DAC",), 0x80168F64:("Play_Update",), - 0x801690CC:("func_801690CC",), + 0x801690CC:("Play_InCsMode",), 0x80169100:("func_80169100",), 0x801691F0:("func_801691F0",), 0x80169220:("Play_LoadScene",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index e7adc27f4..0d6b8fc76 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -960,8 +960,8 @@ 0x801BDAF0:("D_801BDAF0","UNK_TYPE4","",0x4), 0x801BDAF8:("D_801BDAF8","UNK_TYPE4","",0x4), 0x801BDB00:("D_801BDB00","UNK_TYPE1","",0x1), - 0x801BDB08:("D_801BDB08","UNK_TYPE1","",0x1), - 0x801BDB18:("D_801BDB18","UNK_TYPE1","",0x1), + 0x801BDB08:("sKaleidoSetupEyeX","UNK_TYPE1","",0x1), + 0x801BDB18:("sKaleidoSetupEyeZ","UNK_TYPE1","",0x1), 0x801BDB30:("kanfontOrdering","u8","[92]",0x5c), 0x801BDB90:("D_801BDB90","f32","",0x4), 0x801BDB94:("D_801BDB94","UNK_TYPE4","",0x4), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 7ead89bdd..a1267e0d3 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1213,7 +1213,7 @@ asm/non_matchings/code/z_jpeg/Jpeg_GetUnalignedU16.s,Jpeg_GetUnalignedU16,0x800F asm/non_matchings/code/z_jpeg/Jpeg_ParseMarkers.s,Jpeg_ParseMarkers,0x800F4540,0x73 asm/non_matchings/code/z_jpeg/Jpeg_Decode.s,Jpeg_Decode,0x800F470C,0xC1 asm/non_matchings/code/z_kaleido_setup/func_800F4A10.s,func_800F4A10,0x800F4A10,0x7F -asm/non_matchings/code/z_kaleido_setup/func_800F4C0C.s,func_800F4C0C,0x800F4C0C,0x85 +asm/non_matchings/code/z_kaleido_setup/KaleidoSetup_Update.s,KaleidoSetup_Update,0x800F4C0C,0x85 asm/non_matchings/code/z_kaleido_setup/func_800F4E20.s,func_800F4E20,0x800F4E20,0x42 asm/non_matchings/code/z_kaleido_setup/func_800F4F28.s,func_800F4F28,0x800F4F28,0x6 asm/non_matchings/code/z_kanfont/Font_LoadChar.s,Font_LoadChar,0x800F4F40,0x5 @@ -2512,7 +2512,7 @@ asm/non_matchings/code/z_play/func_80167F0C.s,func_80167F0C,0x80167F0C,0x61 asm/non_matchings/code/z_play/Play_Draw.s,Play_Draw,0x80168090,0x347 asm/non_matchings/code/z_play/func_80168DAC.s,func_80168DAC,0x80168DAC,0x6E asm/non_matchings/code/z_play/Play_Update.s,Play_Update,0x80168F64,0x5A -asm/non_matchings/code/z_play/func_801690CC.s,func_801690CC,0x801690CC,0xD +asm/non_matchings/code/z_play/Play_InCsMode.s,Play_InCsMode,0x801690CC,0xD asm/non_matchings/code/z_play/func_80169100.s,func_80169100,0x80169100,0x3C asm/non_matchings/code/z_play/func_801691F0.s,func_801691F0,0x801691F0,0xC asm/non_matchings/code/z_play/Play_LoadScene.s,Play_LoadScene,0x80169220,0x17 From 7280d1040419c5e0a016e01b1309f110df0216e1 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 22:15:26 +0100 Subject: [PATCH 173/257] En_Horse (2 non-matching) (#413) * En_Horse * a * Warnings * Warnigns 2 * PR * Formats * Fix * PR * Merge * Merge * Merge --- .../xml/objects/object_horse_link_child.xml | 4 +- include/functions.h | 7 +- include/variables.h | 2 +- spec | 5 +- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 5047 +++++++++++++++-- src/overlays/actors/ovl_En_Horse/z_en_horse.h | 213 +- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 2 +- tools/actorfixer.py | 4 +- tools/disasm/functions.txt | 212 +- tools/disasm/variables.txt | 17 +- undefined_syms.txt | 11 - 11 files changed, 5035 insertions(+), 489 deletions(-) diff --git a/assets/xml/objects/object_horse_link_child.xml b/assets/xml/objects/object_horse_link_child.xml index 47ceff55a..506135e0c 100644 --- a/assets/xml/objects/object_horse_link_child.xml +++ b/assets/xml/objects/object_horse_link_child.xml @@ -10,7 +10,9 @@ - + + + diff --git a/include/functions.h b/include/functions.h index 75c0727b3..79d2f0d55 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1488,7 +1488,7 @@ void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* in void FireObj_Destroy(GlobalContext* globalCtx, FireObj* fire); void FireObj_SetState2(FireObj* fire, f32 dynamicSizeStep, u8 newState); void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor); -// void func_800F3940(void); +s32 func_800F3940(GlobalContext* globalCtx); // void func_800F39B4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_800F3A64(void); void func_800F3B2C(GlobalContext* globalCtx); @@ -1496,7 +1496,7 @@ void func_800F3B2C(GlobalContext* globalCtx); // void func_800F3C44(void); // void func_800F3ED4(void); void func_800F40A0(GameState* gameState, Player* player); -// void func_800F415C(void); +void func_800F415C(Actor* actor, Vec3f* arg1, s16 arg2); UNK_TYPE func_800F41E4(GlobalContext* globalCtx, ActorContext* actorCtx); void func_800F4A10(GlobalContext* globalCtx); @@ -2408,7 +2408,6 @@ void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle); s32 Animation_OnFrame(SkelAnime* skelAnime, f32 frame); void SkelAnime_Free(SkelAnime* skelAnime, GlobalContext* globalCtx); void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); - void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest); void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, Vec3f* src, Vec3f* dest); void SkinMatrix_MtxFMtxFMult(MtxF* mfB, MtxF* mfA, MtxF* dest); @@ -3068,7 +3067,7 @@ s32 Math3D_LineSegVsPlane(f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* linePoi void Math3D_TriSetCoords(TriNorm* tri, Vec3f* pointA, Vec3f* pointB, Vec3f* pointC); u32 Math3D_IsPointInSphere(Sphere16* sphere, Vec3f* point); s32 Math3D_PointDistToLine2D(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32* arg6, f32* arg7, f32* arg8); // returns boolean -// void func_8017D7C0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); +s32 func_8017D7C0(f32 x0, f32 y0, f32 x1, f32 y1, f32 x2, f32 y2, f32* lineLenSq); // void func_8017D814(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_8017D91C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_8017DA24(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); diff --git a/include/variables.h b/include/variables.h index f603f7c1a..1ce8e336d 100644 --- a/include/variables.h +++ b/include/variables.h @@ -893,7 +893,7 @@ extern s32 graphNumGameStates; // extern UNK_TYPE2 D_801BDA7C; extern s32 D_801BDA9C; extern UNK_TYPE4 D_801BDAA0; -extern UNK_TYPE4 D_801BDAA4; +extern s32 D_801BDAA4; // extern UNK_TYPE2 D_801BDAA8; // extern UNK_TYPE2 D_801BDAAA; // extern UNK_TYPE2 D_801BDAAC; diff --git a/spec b/spec index f028bfa1a..2cc83081c 100644 --- a/spec +++ b/spec @@ -822,8 +822,11 @@ beginseg name "ovl_En_Horse" compress include "build/src/overlays/actors/ovl_En_Horse/z_en_horse.o" - include "build/data/ovl_En_Horse/ovl_En_Horse.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_En_Horse/ovl_En_Horse_reloc.o" +#else include "build/data/ovl_En_Horse/ovl_En_Horse.reloc.o" +#endif endseg beginseg 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 ad9089df6..440ac3578 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -5,6 +5,7 @@ */ #include "z_en_horse.h" +#include "objects/object_horse_link_child/object_horse_link_child.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,116 @@ void EnHorse_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx); void EnHorse_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_8087D540(Actor* thisx, GlobalContext* globalCtx); +void EnHorse_StartMountedIdleResetAnim(EnHorse* this); +void EnHorse_StartMountedIdle(EnHorse* this); +void EnHorse_MountedIdle(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_MountedIdleAnim(EnHorse* this); +void EnHorse_MountedIdleWhinney(EnHorse* this); +void EnHorse_StartTurning(EnHorse* this); +void EnHorse_StartWalkingFromIdle(EnHorse* this); +void EnHorse_StartWalkingInterruptable(EnHorse* this); +void EnHorse_StartWalking(EnHorse* this); +void EnHorse_StartTrotting(EnHorse* this); +void EnHorse_StartGallopingInterruptable(EnHorse* this); +void EnHorse_StartGalloping(EnHorse* this); +void EnHorse_StartBraking(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_StartReversingInterruptable(EnHorse* this); +void EnHorse_StartReversing(EnHorse* this); +void EnHorse_StartLowJump(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_StartHighJump(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_InitInactive(EnHorse* this); +void EnHorse_ChangeIdleAnimation(EnHorse* this, s32 anim, 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_SetFollowAnimation(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_InitIngoHorse(EnHorse* this); +void EnHorse_UpdateIngoHorseAnim(EnHorse* this); +void func_80881290(EnHorse* this, GlobalContext* globalCtx); +void func_8088159C(EnHorse* this, GlobalContext* globalCtx); +void func_80881634(EnHorse* this); +void func_8088168C(EnHorse* this); +void EnHorse_CsMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsPlayHighJumpAnim(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_CsJumpInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsJump(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_WarpMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsWarpMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsWarpRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsWarpRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_InitCutscene(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_InitHorsebackArchery(EnHorse* this); +void EnHorse_UpdateHbaAnim(EnHorse* this); +void func_80883BEC(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883CB0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883D64(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883DE0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883E10(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883EA0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883F18(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883F98(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884010(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808840C4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884194(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_8088424C(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884314(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808843B4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884444(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808844E0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884564(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884604(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808846B4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808846DC(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808846F0(EnHorse* this, GlobalContext* globalCtx); +void func_80884994(EnHorse* this); +void func_80884D04(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_StickDirection(Vec2f* curStick, f32* stickMag, s16* angle); +s32 EnHorse_GetMountSide(EnHorse* this, GlobalContext* globalCtx); + +typedef struct { + s32 csAction; + s32 csFuncIdx; +} CsActionEntry; + +typedef struct { + s16 x; + s16 y; + s16 z; + s16 speed; + s16 angle; +} RaceWaypoint; + +typedef struct { + s32 numWaypoints; + RaceWaypoint* waypoints; +} RaceInfo; + +static AnimationHeader* sEponaAnimHeaders[] = { + &object_horse_link_child_Anim_006D44, &object_horse_link_child_Anim_007468, &object_horse_link_child_Anim_005F64, + &object_horse_link_child_Anim_004DE8, &object_horse_link_child_Anim_007D50, &object_horse_link_child_Anim_0043AC, + &object_horse_link_child_Anim_002F98, &object_horse_link_child_Anim_0035B0, &object_horse_link_child_Anim_003D38, +}; + +static AnimationHeader* sHniAnimHeaders[] = { + &object_ha_Anim_00C850, &object_ha_Anim_00CE70, &object_ha_Anim_00B9C8, + &object_ha_Anim_00B00C, &object_ha_Anim_00D648, &object_ha_Anim_00A650, + &object_ha_Anim_009208, &object_ha_Anim_009858, &object_ha_Anim_00A05C, +}; + +static AnimationHeader** sAnimationHeaders[] = { + NULL, NULL, sEponaAnimHeaders, sHniAnimHeaders, sHniAnimHeaders, +}; + +static f32 sPlaybackSpeeds[] = { 2.0f / 3.0f, 2.0f / 3.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f / 3.0f, 2.0f / 3.0f }; + +static SkeletonHeader* sSkeletonHeaders[] = { + NULL, NULL, &object_horse_link_child_Skel_00A480, NULL, NULL, +}; + const ActorInit En_Horse_InitVars = { ACTOR_EN_HORSE, ACTORCAT_BG, @@ -28,370 +138,4617 @@ const ActorInit En_Horse_InitVars = { (ActorFunc)EnHorse_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80888F74 = { - { COLTYPE_NONE, AT_NONE | AT_TYPE_PLAYER, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1 | OC2_UNK1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000004, 0x00, 0x02 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_ON, }, - { 20, 70, 0, { 0, 0, 0 } }, -}; - -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80888FA0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1 | OC2_UNK1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, - { 20, 70, 0, { 0, 0, 0 } }, -}; - -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80888FCC[1] = { +static ColliderCylinderInit sCylinderInit1 = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00013820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_NO_AT_INFO | BUMP_NO_DAMAGE | BUMP_NO_SWORD_SFX | BUMP_NO_HITMARK, OCELEM_ON, }, + COLTYPE_NONE, + AT_NONE | AT_TYPE_PLAYER, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000004, 0x00, 0x02 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 20, 70, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, + { 20, 70, 0, { 0, 0, 0 } }, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00013820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_NO_AT_INFO | BUMP_NO_DAMAGE | BUMP_NO_SWORD_SFX | BUMP_NO_HITMARK, + OCELEM_ON, + }, { 13, { { 0, 0, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80888FF0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1 | OC2_UNK1, COLSHAPE_JNTSPH, }, - 1, D_80888FCC, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80889000 = { 10, 35, 100, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 10, 35, 100, MASS_HEAVY }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80889010[] = { +static s32 sAnimSoundFrames[] = { + 0, + 16, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), }; +static u8 sResetNoInput[] = { + false, false, false, false, false, false, true, true, true, true, true, true, + true, true, true, false, false, false, false, false, false, false, false, false, +}; + +static s32 sIdleAnimIds[] = { + 1, 3, 0, 3, 1, 0, +}; + +static s16 sIngoAnimations[] = { 7, 6, 2, 2, 1, 1, 0, 0, 0, 0 }; + +static EnHorseCsFunc sCutsceneInitFuncs[] = { + NULL, + EnHorse_CsMoveInit, + EnHorse_CsJumpInit, + EnHorse_CsRearingInit, + EnHorse_WarpMoveInit, + EnHorse_CsWarpRearingInit, +}; + +static EnHorseCsFunc sCutsceneActionFuncs[] = { + NULL, EnHorse_CsMoveToPoint, EnHorse_CsJump, EnHorse_CsRearing, EnHorse_CsWarpMoveToPoint, EnHorse_CsWarpRearing, +}; + +static CsActionEntry sCsActionTable[] = { + { 36, 1 }, { 37, 2 }, { 38, 3 }, { 64, 4 }, { 65, 5 }, +}; + +static RaceWaypoint sHbaWaypoints[] = { + { 3600, 1413, -5055, 11, 0x8001 }, { 3360, 1413, -5220, 5, 0xC000 }, { 3100, 1413, -4900, 5, 0x0000 }, + { 3600, 1413, -4100, 11, 0x0000 }, { 3600, 1413, 360, 11, 0x0000 }, +}; + +static RaceInfo sHbaInfo = { 5, sHbaWaypoints }; + +static EnHorseCsFunc D_808890F0[] = { + NULL, func_80883BEC, func_80883D64, func_80883E10, func_80883F18, func_80884010, + func_80884194, func_80884314, func_80884444, func_80884564, func_808846B4, +}; + +static EnHorseCsFunc D_8088911C[] = { + NULL, func_80883CB0, func_80883DE0, func_80883EA0, func_80883F98, func_808840C4, + func_8088424C, func_808843B4, func_808844E0, func_80884604, func_808846DC, +}; + +void EnHorse_RaceWaypointPos(RaceWaypoint* waypoints, s32 idx, Vec3f* pos) { + pos->x = waypoints[idx].x; + pos->y = waypoints[idx].y; + pos->z = waypoints[idx].z; +} + +void EnHorse_RotateToPoint(EnHorse* this, GlobalContext* globalCtx, Vec3f* pos, s16 turnAmount) { + func_800F415C(&this->actor, pos, turnAmount); +} + +void func_8087B7C0(EnHorse* this, GlobalContext* globalCtx, Path* path) { + s32 spA4; + Vec3s* spA0; + f32 phi_f12; + f32 phi_f14; + Vec3f sp8C; + Vec3f sp80; + f32 sp7C; + f32 sp78; + f32 sp74; + f32 sp70; + s32 i; + s32 sp68; + f32 sp64; + s32 sp60; + f32 temp_f0; + Vec3f sp50; + + spA4 = path->count; + spA0 = Lib_SegmentedToVirtual(path->points); + Math_Vec3s_ToVec3f(&sp8C, &spA0[this->curRaceWaypoint]); + + if (this->curRaceWaypoint == 0) { + phi_f12 = spA0[1].x - spA0[0].x; + phi_f14 = spA0[1].z - spA0[0].z; + } else if ((this->curRaceWaypoint + 1) == path->count) { + phi_f12 = spA0[path->count - 1].x - spA0[path->count - 2].x; + phi_f14 = spA0[path->count - 1].z - spA0[path->count - 2].z; + } else { + phi_f12 = spA0[this->curRaceWaypoint + 1].x - spA0[this->curRaceWaypoint - 1].x; + phi_f14 = spA0[this->curRaceWaypoint + 1].z - spA0[this->curRaceWaypoint - 1].z; + } + + func_8017B7F8(&sp8C, Math_Atan2S(phi_f12, phi_f14), &sp7C, &sp78, &sp74); + + if (((this->actor.world.pos.x * sp7C) + (sp78 * this->actor.world.pos.z) + sp74) > 0.0f) { + this->curRaceWaypoint++; + if (this->curRaceWaypoint >= spA4) { + this->curRaceWaypoint = spA4 - 1; + } + Math_Vec3s_ToVec3f(&sp8C, &spA0[this->curRaceWaypoint]); + } + + if (this->curRaceWaypoint == 0) { + Math_Vec3s_ToVec3f(&sp80, &spA0[1]); + } else { + Math_Vec3s_ToVec3f(&sp80, &spA0[this->curRaceWaypoint - 1]); + } + + func_8017D7C0(this->actor.world.pos.x, this->actor.world.pos.z, sp80.x, sp80.z, sp8C.x, sp8C.z, &sp70); + + if ((this->actor.bgCheckFlags & 8) || (this->unk_1EC & 4)) { + EnHorse_RotateToPoint(this, globalCtx, &sp8C, 0xC80); + if (this->unk_1EC & 4) { + this->unk_1EC &= ~4; + } + } else { + EnHorse_RotateToPoint(this, globalCtx, &sp8C, 0x320); + if (sp70 < SQ(100.0f)) { + if ((this->actor.xzDistToPlayer < 100.0f) || + (this->colliderJntSph.elements[0].info.ocElemFlags & OCELEM_HIT)) { + s32 pad; + + if (Math_SinS(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0.0f) { + this->actor.world.rot.y -= 0x1E0; + } else { + this->actor.world.rot.y += 0x1E0; + } + } else if (this->actor.xzDistToPlayer < 300.0f) { + if (Math_SinS(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0.0f) { + this->actor.world.rot.y += 0x1E0; + } else { + this->actor.world.rot.y -= 0x1E0; + } + } + this->actor.shape.rot.y = this->actor.world.rot.y; + } + } + + sp68 = this->curRaceWaypoint - 3; + if (sp68 < 0) { + sp68 = 0; + } + + sp64 = 1.0e+38; + sp60 = sp68 + 5; + if (path->count < sp60) { + sp60 = path->count; + } + + for (i = sp68; i < sp60; i++) { + Math_Vec3s_ToVec3f(&sp50, &spA0[i]); + temp_f0 = Math3D_Distance(&this->actor.world.pos, &sp50); + if (temp_f0 < sp64) { + sp64 = temp_f0; + sp68 = i; + } + } + + this->unk_398 = spA0[this->curRaceWaypoint].y * 0.01f; + if ((this->unk_1EC & 0x100) && !(this->stateFlags & ENHORSE_JUMPING) && + ((this->colliderCylinder1.base.acFlags & AC_HIT) || (this->colliderCylinder2.base.acFlags & AC_HIT) || + (this->unk_58C > 0))) { + if (this->unk_58C == 0) { + this->unk_590 = 0x1F4; + this->unk_58C = 0x2B; + } + this->unk_58C--; + if (this->actor.speedXZ > 5.0f) { + this->actor.speedXZ -= 0.5f; + } + } else if (this->unk_590 > 0) { + if (this->unk_590 == 0x1F4) { + if (this->rider != NULL) { + Actor_PlaySfxAtPos(&this->rider->actor, NA_SE_VO_IN_CRY_0); + } + } + this->unk_590--; + if (this->actor.speedXZ < this->unk_398) { + this->actor.speedXZ += 1.0f; + } else { + this->actor.speedXZ -= 0.5f; + } + } else if (this->actor.params == ENHORSE_5) { + s16 sp4A; + + if (sp68 >= this->curRaceWaypoint) { + if (this->actor.speedXZ < this->unk_398) { + this->actor.speedXZ += 0.5f; + } else { + this->actor.speedXZ -= 0.5f; + } + this->unk_394 |= 1; + return; + } + + sp4A = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; + + if ((fabsf(Math_SinS(sp4A)) < 0.9f) && (Math_CosS(sp4A) > 0.0f)) { + if (this->actor.speedXZ < this->unk_398) { + this->actor.speedXZ += 0.5f; + } else { + this->actor.speedXZ -= 0.25f; + } + this->unk_394 |= 1; + } else { + if (this->actor.speedXZ < 13.0f) { + this->actor.speedXZ += 0.4f; + } else { + this->actor.speedXZ -= 0.2f; + } + this->unk_394 &= ~1; + } + } else if (sp68 >= this->curRaceWaypoint) { + if (this->actor.speedXZ < this->unk_398) { + this->actor.speedXZ += 0.5f; + } else { + this->actor.speedXZ -= 0.5f; + } + this->unk_394 |= 1; + } else if ((sp68 + 1) == this->curRaceWaypoint) { + s16 sp48 = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; + + if ((fabsf(Math_SinS(sp48)) < 0.9f) && (Math_CosS(sp48) > 0.0f)) { + if (this->actor.speedXZ < this->unk_398) { + this->actor.speedXZ += 0.5f; + } else { + this->actor.speedXZ -= 0.25f; + } + this->unk_394 |= 1; + } else { + if (this->actor.speedXZ < 12.0f) { + this->actor.speedXZ += 0.4f; + } else { + this->actor.speedXZ -= 0.2f; + } + this->unk_394 &= ~1; + } + } else { + if (this->actor.speedXZ < 13.0f) { + this->actor.speedXZ += 0.4f; + } else { + this->actor.speedXZ -= 0.2f; + } + this->unk_394 &= ~1; + } +} + +void EnHorse_PlayWalkingSound(EnHorse* this) { + if (sAnimSoundFrames[this->soundTimer] < this->curFrame) { + if ((this->soundTimer == 0) && (sAnimSoundFrames[1] < this->curFrame)) { + return; + } + + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_WALK); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_WALK); + } + + this->soundTimer++; + if (this->soundTimer > 1) { + this->soundTimer = 0; + } + } +} + +void func_8087C178(EnHorse* this) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } +} + +void func_8087C1C0(EnHorse* this) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } +} + +f32 EnHorse_SlopeSpeedMultiplier(EnHorse* this, GlobalContext* globalCtx) { + f32 multiplier = 1.0f; + + if ((Math_CosS(this->actor.shape.rot.x) < 0.939262f) && (Math_SinS(this->actor.shape.rot.x) < 0.0f)) { + multiplier = 0.7f; + } + return multiplier; +} + +void func_8087C288(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, f32* arg3) { + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg1, arg2, arg3); +} + +s32 func_8087C2B8(GlobalContext* globalCtx, EnHorse* this, Vec3f* arg2, f32 arg3) { + f32 phi_f14; + + if ((arg2->z > 0.0f) && (arg2->z < (this->actor.uncullZoneForward + this->actor.uncullZoneScale))) { + if (arg3 < 1.0f) { + phi_f14 = 1.0f; + } else { + phi_f14 = 1.0f / arg3; + } + + if (((fabsf(arg2->x) * phi_f14) < 1.0f) && (((arg2->y + this->actor.uncullZoneDownward) * phi_f14) > -1.0f) && + (((arg2->y - this->actor.uncullZoneScale) * phi_f14) < 1.0f)) { + return true; + } + } + return false; +} + +s32 func_8087C38C(GlobalContext* globalCtx, EnHorse* this, Vec3f* arg2) { + Vec3f sp24; + f32 sp20; + f32 eyeDist; + + func_8087C288(globalCtx, arg2, &sp24, &sp20); + + if (fabsf(sp20) < 0.008f) { + return false; + } + + eyeDist = Math3D_Distance(arg2, &globalCtx->view.eye); + + return func_8087C2B8(globalCtx, this, &sp24, sp20) || (eyeDist < 100.0f); +} + +void EnHorse_IdleAnimSounds(EnHorse* this, GlobalContext* globalCtx) { + if ((this->animationIdx == ENHORSE_ANIM_IDLE) && + (((this->curFrame > 35.0f) && (this->type == HORSE_EPONA)) || + ((this->curFrame > 28.0f) && (this->type == HORSE_HNI)) || + ((this->curFrame > 25.0f) && (this->type == HORSE_2))) && + !(this->stateFlags & ENHORSE_SANDDUST_SOUND)) { + this->stateFlags |= ENHORSE_SANDDUST_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } + } else if ((this->animationIdx == 3) && (this->curFrame > 25.0f) && !(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + } +} + +s32 EnHorse_Spawn(EnHorse* this, GlobalContext* globalCtx) { + s32 i; + f32 dist; + Path* path; + s32 spawn = false; + f32 minDist = 1.0e+38; + Player* player = GET_PLAYER(globalCtx); + Vec3f spawnPos; + s32 pathIdx = func_800F3940(globalCtx); + s32 pathCount; + Vec3s* pathPoints; + + if (pathIdx == -1) { + return false; + } + + path = &globalCtx->setupPathList[pathIdx]; + pathCount = path->count; + pathPoints = Lib_SegmentedToVirtual(path->points); + + for (i = 0; i < pathCount; i++) { + spawnPos.x = pathPoints[i].x; + spawnPos.y = pathPoints[i].y; + spawnPos.z = pathPoints[i].z; + dist = Math3D_Distance(&player->actor.world.pos, &spawnPos); + + if ((minDist < dist) || func_8087C38C(globalCtx, this, &spawnPos)) { + continue; + } + + minDist = dist; + this->actor.world.pos.x = spawnPos.x; + this->actor.world.pos.y = spawnPos.y; + this->actor.world.pos.z = spawnPos.z; + this->actor.prevPos = this->actor.world.pos; + this->actor.world.rot.y = 0; + this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + spawn = true; + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->actor.world.pos, &this->actor.projectedPos, + &this->actor.projectedW); + } + + if (spawn == true) { + return true; + } + + for (i = 0; i < pathCount; i++) { + spawnPos.x = pathPoints[i].x; + spawnPos.y = pathPoints[i].y; + spawnPos.z = pathPoints[i].z; + dist = Math3D_Distance(&player->actor.world.pos, &spawnPos); + + if (minDist < dist) { + continue; + } + + minDist = dist; + this->actor.world.pos.x = spawnPos.x; + this->actor.world.pos.y = spawnPos.y; + this->actor.world.pos.z = spawnPos.z; + this->actor.prevPos = this->actor.world.pos; + this->actor.world.rot.y = 0; + this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + spawn = true; + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->actor.world.pos, &this->actor.projectedPos, + &this->actor.projectedW); + } + + return spawn; +} + +void EnHorse_ResetCutscene(EnHorse* this, GlobalContext* globalCtx) { + this->cutsceneAction = -1; + this->cutsceneFlags = 0; +} + +void EnHorse_ResetRace(EnHorse* this, GlobalContext* globalCtx) { + this->inRace = false; +} + +s32 EnHorse_PlayerCanMove(EnHorse* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags1 & 1) || (func_800B7128(GET_PLAYER(globalCtx)) == true) || + (player->stateFlags1 & 0x100000) || + (((this->stateFlags & ENHORSE_FLAG_19) || (this->stateFlags & ENHORSE_FLAG_29)) && !this->inRace) || + (this->action == 19) || (player->actor.flags & ACTOR_FLAG_100) || (globalCtx->csCtx.state != 0) || + (ActorCutscene_GetCurrentIndex() != -1) || (player->stateFlags1 & 0x20) || (player->csMode != 0)) { + return false; + } + return true; +} + +void EnHorse_ResetHorsebackArchery(EnHorse* this, GlobalContext* globalCtx) { + this->unk_39C = 0; + this->hbaStarted = 0; + this->hbaFlags = 0; +} + +void EnHorse_ClearDustFlags(u16* dustFlags) { + *dustFlags = 0; +} + +void func_8087C9F8(EnHorse* this) { +} + +void func_8087CA04(EnHorse* this, GlobalContext* globalCtx) { +} + +#ifdef NON_MATCHING +void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnHorse* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + EnHorse_ClearDustFlags(&this->dustFlags); + D_801BDAA4 = 0; + Skin_Setup(&this->skin); + this->riderPos = this->actor.world.pos; + this->unk_52C = 0; + this->noInputTimer = 0; + this->riderPos.y += 70.0f; + this->noInputTimerMax = 0; + this->unk_1EC = 0; + this->unk_58C = 0; + this->unk_590 = 0; + this->unk_3E8 = 0.0f; + this->unk_528 = 100.0f; + + if (ENHORSE_GET_8000(&this->actor)) { + this->type = HORSE_4; + this->unk_528 = 80.0f; + this->boostSpeed = 12; + if ((this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HA)) < 0) { + Actor_MarkForDeath(&this->actor); + return; + } + this->unk_1EC |= 1; + this->actor.update = func_8087D540; + } else if (ENHORSE_GET_4000(&this->actor)) { + this->type = HORSE_2; + this->unk_528 = 64.8f; + this->boostSpeed = 15; + if ((this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HORSE_LINK_CHILD)) < 0) { + this->actor.objBankIndex = Object_Spawn(&globalCtx->objectCtx, OBJECT_HORSE_LINK_CHILD); + Actor_SetObjectDependency(globalCtx, &this->actor); + Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + this->unk_1EC |= 0x200; + } else { + this->actor.update = func_8087D540; + } + } else if (ENHORSE_GET_2000(&this->actor)) { + this->type = HORSE_3; + this->boostSpeed = 12; + if ((this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HA)) < 0) { + Actor_MarkForDeath(&this->actor); + return; + } + this->unk_1EC |= 1; + this->actor.update = func_8087D540; + } else { + this->type = HORSE_EPONA; + this->boostSpeed = 15; + Actor_MarkForDeath(&this->actor); + } + + this->actor.params &= ~0xE000; + if (this->actor.params == 0x1FFF) { + this->actor.params = ENHORSE_1; + } + + if (this->actor.params == ENHORSE_3) { + this->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP | ENHORSE_UNRIDEABLE; + } else if (this->actor.params == ENHORSE_8) { + this->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP; + if (CHECK_QUEST_ITEM(14)) { + this->stateFlags &= ~ENHORSE_CANT_JUMP; + this->stateFlags |= ENHORSE_FLAG_26; + } + } else if (this->actor.params == ENHORSE_13) { + this->stateFlags = ENHORSE_FLAG_29; + this->unk_1EC |= 0x10; + } else if (this->actor.params == ENHORSE_4) { + this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; + this->actor.flags |= ACTOR_FLAG_80000000; + } else if (this->actor.params == ENHORSE_5) { + this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; + this->actor.flags |= ACTOR_FLAG_80000000; + } else if (this->actor.params == ENHORSE_15) { + this->stateFlags = ENHORSE_UNRIDEABLE | ENHORSE_FLAG_7; + } else if (this->actor.params == ENHORSE_17) { + this->stateFlags = 0; + this->unk_1EC |= 8; + } else if (this->actor.params == ENHORSE_18) { + this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; + this->actor.flags |= ACTOR_FLAG_80000000; + } else if (this->actor.params == ENHORSE_1) { + this->stateFlags = ENHORSE_FLAG_7; + } else if ((this->actor.params == ENHORSE_19) || (this->actor.params == ENHORSE_20)) { + this->stateFlags = ENHORSE_CANT_JUMP | ENHORSE_UNRIDEABLE; + } else { + this->stateFlags = 0; + } + + if (((globalCtx->sceneNum == SCENE_KOEPONARACE) && ((gSaveContext.save.weekEventReg[92] & (1 | 2 | 4)) == 1)) || + ((gSaveContext.save.entranceIndex == 0x6400) && Cutscene_GetSceneSetupIndex(globalCtx))) { + this->stateFlags |= ENHORSE_FLAG_25; + } + + this->actor.gravity = -3.5f; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); + this->action = ENHORSE_ACT_IDLE; + this->actor.speedXZ = 0.0f; + + if (this->type == HORSE_2) { + sJntSphInit.elements[0].dim.limb = 13; + } else if ((this->type == HORSE_3) || (this->type == HORSE_4)) { + sJntSphInit.elements[0].dim.limb = 10; + } + + Collider_InitCylinder(globalCtx, &this->colliderCylinder1); + Collider_SetCylinder(globalCtx, &this->colliderCylinder1, &this->actor, &sCylinderInit1); + Collider_InitCylinder(globalCtx, &this->colliderCylinder2); + Collider_SetCylinder(globalCtx, &this->colliderCylinder2, &this->actor, &sCylinderInit2); + Collider_InitJntSph(globalCtx, &this->colliderJntSph); + Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, this->colliderJntSphElements); + + if (this->type == HORSE_2) { + this->colliderCylinder1.dim.radius = this->colliderCylinder1.dim.radius * 0.8f; + this->colliderCylinder2.dim.radius = this->colliderCylinder2.dim.radius * 0.8f; + this->colliderJntSph.elements[0].dim.modelSphere.radius *= 0.6f; + } else if (this->type == HORSE_4) { + this->colliderCylinder1.dim.radius = 50; + } + + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + + if (this->type == HORSE_2) { + Actor_SetScale(&this->actor, 0.00648f); + } else if (this->type == HORSE_4) { + Actor_SetScale(&this->actor, 0.008f); + } else { + Actor_SetScale(&this->actor, 0.01f); + } + + this->actor.focus.pos = this->actor.world.pos; + this->playerControlled = false; + this->actor.focus.pos.y += 70.0f; + + if (!(this->unk_1EC & 1) && !(this->unk_1EC & 0x200) && (this->actor.update == EnHorse_Update)) { + Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); + } + + this->animationIdx = 0; + this->numBoosts = 6; + this->boostRegenTime = 0; + this->postDrawFunc = NULL; + this->blinkTimer = 0; + + EnHorse_ResetCutscene(this, globalCtx); + EnHorse_ResetRace(this, globalCtx); + EnHorse_ResetHorsebackArchery(this, globalCtx); + + if (this->actor.params == ENHORSE_2) { + this->unk_53C = 0; + EnHorse_InitInactive(this); + } else if (this->actor.params == ENHORSE_3) { + EnHorse_InitIngoHorse(this); + this->rider = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, + this->actor.shape.rot.y, 1, 1); + this->unk_398 = 14.34f; + } else if (this->actor.params == ENHORSE_4) { + func_80881634(this); + this->unk_398 = 14.34f; + this->rider = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, + this->actor.shape.rot.y, 1, 1); + this->unk_1EC |= 0x100; + } else if (this->actor.params == ENHORSE_5) { + func_80881634(this); + this->unk_398 = 14.525f; + this->rider = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, + this->actor.shape.rot.y, 1, 2); + this->unk_1EC |= 0x100; + } else if (this->actor.params == ENHORSE_9) { + EnHorse_InitCutscene(this, globalCtx); + } else if (this->actor.params == ENHORSE_10) { + EnHorse_InitHorsebackArchery(this); + func_80112AFC(globalCtx); + } else if (this->actor.params == ENHORSE_14) { + func_808846F0(this, globalCtx); + if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(globalCtx)) { + Actor_MarkForDeath(&this->actor); + } + } else if (this->actor.params == ENHORSE_16) { + func_8087C9F8(this); + } else if (this->actor.params == ENHORSE_15) { + EnHorse_ResetIdleAnimation(this); + } else if (this->actor.params == ENHORSE_18) { + func_80884994(this); + } else if (this->actor.params == ENHORSE_19) { + EnIn* in; + + func_80884D04(this, globalCtx); + in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, + this->actor.shape.rot.y, 1, 1); + this->rider = in; + in->unk4AC |= (0x20 | 0x4); + } else if (this->actor.params == ENHORSE_20) { + EnIn* in; + + func_80884D04(this, globalCtx); + in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, + this->actor.shape.rot.y, 1, 1); + this->rider = in; + in->unk4AC |= (0x20 | 0x8 | 0x4); + } else { + EnHorse_StartIdleRidable(this); + } + + this->actor.shape.rot.z = 0; + this->actor.world.rot.z = this->actor.shape.rot.z; + this->actor.home.rot.z = this->actor.shape.rot.z; + this->unk_3EC = this->actor.world.rot.y; + this->unk_538 = 0; + + if (this->unk_1EC & 0x100) { + this->colliderCylinder1.base.colType = COLTYPE_HIT3; + this->colliderCylinder1.base.acFlags |= (AC_TYPE_PLAYER | AC_ON); + this->colliderCylinder1.info.bumperFlags |= BUMP_ON; + this->colliderCylinder1.info.bumper.dmgFlags = 0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20; + this->colliderCylinder2.base.colType = COLTYPE_HIT3; + this->colliderCylinder2.base.acFlags |= (AC_TYPE_PLAYER | AC_ON); + this->colliderCylinder2.info.bumperFlags |= BUMP_ON; + this->colliderCylinder2.info.bumper.dmgFlags = 0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20; + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Init.s") #endif -extern ColliderCylinderInit D_80888F74; -extern ColliderCylinderInit D_80888FA0; -extern ColliderJntSphElementInit D_80888FCC[1]; -extern ColliderJntSphInit D_80888FF0; -extern CollisionCheckInfoInit D_80889000; -extern InitChainEntry D_80889010[]; - -extern UNK_TYPE D_06008C68; -extern UNK_TYPE D_0600A8DC; -extern UNK_TYPE D_0600AD08; -extern UNK_TYPE D_0600B3E0; -extern UNK_TYPE D_0600BDE0; -extern UNK_TYPE D_0600D178; -extern UNK_TYPE D_0600D4E8; - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087B730.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087B784.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087B7C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C0AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C178.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C1C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C208.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C288.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C2B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C38C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C43C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C590.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C8B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C8D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C8E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C9D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C9EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C9F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087CA04.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D540.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D70C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D75C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D814.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D988.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087DDEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087DE28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087DF64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E080.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E0A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E18C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E2A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E350.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E564.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E5B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E5D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E684.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E6D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E92C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E9D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EA1C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EB54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EB78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EC20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EC78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087ED10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EEC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F078.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F1FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F39C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F590.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F5B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F658.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F9A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F9C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FB08.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FB14.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FD94.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FDB8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FF08.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FF14.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808801A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808801F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808802D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808804A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808804CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880500.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880534.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808806DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880844.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880978.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880D50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880DA8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880E00.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881128.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088126C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881290.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881398.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088159C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881634.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088168C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808819D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881BDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881C54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881DA4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881DC8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881F10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881F48.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808821C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808822CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088247C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882564.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808826B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882820.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808829D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808829F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882A44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882B9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882D8C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882DC0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883104.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883308.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883B70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883BEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883CB0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883D64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883DE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883E10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883EA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883F18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883F98.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884010.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808840C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884194.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088424C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884314.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808843B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884444.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808844E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884564.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884604.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808846B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808846DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808846F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884718.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884868.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808848C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884994.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884A40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884D04.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884E0C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885060.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808850DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885220.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808853E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088598C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885A80.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885AF4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885B4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885C90.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885DA4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80886C00.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80886DC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80886FA8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808870A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808871A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887270.s") - +void func_8087D540(Actor* thisx, GlobalContext* globalCtx) { + EnHorse* this = THIS; + + if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { + this->actor.objBankIndex = this->bankIndex; + Actor_SetObjectDependency(globalCtx, &this->actor); + this->actor.update = EnHorse_Update; + if (this->unk_1EC & 1) { + if (this->type == HORSE_3) { + SkelAnime_InitFlex(globalCtx, &this->skin.skelAnime, &object_ha_Skel_008C68, NULL, this->jointTable, + this->morphTable, OBJECT_HA_1_LIMB_MAX); + } else { + SkelAnime_InitFlex(globalCtx, &this->skin.skelAnime, &object_ha_Skel_0150D8, NULL, this->jointTable, + this->morphTable, OBJECT_HA_2_LIMB_MAX); + } + } else { + Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); + } + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + } +} + +void EnHorse_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHorse* this = THIS; + + if (this->stateFlags & ENHORSE_DRAW) { + Audio_StopSfxByPos(&this->unk_218); + } + Skin_Free(&globalCtx->state, &this->skin); + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder1); + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder2); + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); +} + +void EnHorse_RotateToPlayer(EnHorse* this, GlobalContext* globalCtx) { + EnHorse_RotateToPoint(this, globalCtx, &GET_PLAYER(globalCtx)->actor.world.pos, 0x320); + if (this->stateFlags & ENHORSE_OBSTACLE) { + this->actor.world.rot.y += 1600; + } + this->actor.shape.rot.y = this->actor.world.rot.y; +} + +void EnHorse_Freeze(EnHorse* this, GlobalContext* globalCtx) { + if ((this->action != ENHORSE_ACT_HBA) && (this->action != ENHORSE_ACT_21) && + (this->action != ENHORSE_ACT_FLEE_PLAYER)) { + if (sResetNoInput[this->actor.params] && (this->actor.params != ENHORSE_6)) { + Player* player = GET_PLAYER(globalCtx); + + this->noInputTimerMax = 0; + this->noInputTimer = 0; + player->actor.world.pos = this->actor.world.pos; + player->actor.world.pos.y += 70.0f; + } + this->prevAction = this->action; + this->action = ENHORSE_ACT_FROZEN; + this->colliderCylinder1.base.ocFlags1 &= ~OC1_ON; + this->colliderCylinder2.base.ocFlags1 &= ~OC1_ON; + this->colliderJntSph.base.ocFlags1 &= ~OC1_ON; + this->animationIdx = ENHORSE_ANIM_IDLE; + } +} + +void EnHorse_Frozen(EnHorse* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + this->noInputTimer--; + if (this->noInputTimer < 0) { + this->colliderCylinder1.base.ocFlags1 |= OC1_ON; + this->colliderCylinder2.base.ocFlags1 |= OC1_ON; + this->colliderJntSph.base.ocFlags1 |= OC1_ON; + if (this->playerControlled == true) { + this->stateFlags &= ~ENHORSE_FLAG_7; + if (this->actor.params == ENHORSE_6) { + EnHorse_StartMountedIdleResetAnim(this); + } else if (this->actor.params == ENHORSE_11) { + this->actor.params = ENHORSE_7; + if (globalCtx->csCtx.state != 0) { + EnHorse_StartMountedIdle(this); + } else { + this->actor.speedXZ = 8.0f; + EnHorse_StartGalloping(this); + } + } else if (this->prevAction == ENHORSE_ACT_IDLE) { + EnHorse_StartMountedIdle(this); + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + + if (this->actor.params != ENHORSE_0) { + this->actor.params = ENHORSE_0; + } + } else if (this->prevAction == ENHORSE_ACT_MOUNTED_TURN) { + EnHorse_ChangeIdleAnimation(this, 0, 0.0f); + } else if (this->prevAction == ENHORSE_ACT_MOUNTED_WALK) { + EnHorse_ChangeIdleAnimation(this, 0, 0.0f); + } else { + EnHorse_ChangeIdleAnimation(this, 0, 0.0f); + } + } +} + +void EnHorse_UpdateSpeed(EnHorse* this, GlobalContext* globalCtx, f32 brakeDecel, f32 brakeAngle, f32 minStickMag, + f32 decel, f32 baseSpeed, s16 turnSpeed) { + f32 phi_f0; + f32 stickMag; + s16 stickAngle; + s16 turn; + f32 temp_f12; + + if (!EnHorse_PlayerCanMove(this, globalCtx)) { + if (this->actor.speedXZ > 8.0f) { + this->actor.speedXZ -= decel; + } else if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + return; + } + + baseSpeed *= EnHorse_SlopeSpeedMultiplier(this, globalCtx); + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + + if (Math_CosS(stickAngle) <= brakeAngle) { + this->actor.speedXZ -= brakeDecel; + this->actor.speedXZ = CLAMP_MIN(this->actor.speedXZ, 0.0f); + return; + } + + if (stickMag < minStickMag) { + this->stateFlags &= ~ENHORSE_BOOST; + this->stateFlags &= ~ENHORSE_BOOST_DECEL; + this->actor.speedXZ -= decel; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + return; + } + + if (this->stateFlags & ENHORSE_BOOST) { + if ((16 - this->boostTimer) > 0) { + this->actor.speedXZ = + (((EnHorse_SlopeSpeedMultiplier(this, globalCtx) * this->boostSpeed) - this->actor.speedXZ) / + (16.0f - this->boostTimer)) + + this->actor.speedXZ; + } else { + this->actor.speedXZ = EnHorse_SlopeSpeedMultiplier(this, globalCtx) * this->boostSpeed; + } + + if ((EnHorse_SlopeSpeedMultiplier(this, globalCtx) * this->boostSpeed) <= this->actor.speedXZ) { + this->stateFlags &= ~ENHORSE_BOOST; + this->stateFlags |= ENHORSE_BOOST_DECEL; + } + } else if (this->stateFlags & ENHORSE_BOOST_DECEL) { + if (this->actor.speedXZ > baseSpeed) { + this->actor.speedXZ -= 0.06f; + } else if (this->actor.speedXZ < baseSpeed) { + this->actor.speedXZ = baseSpeed; + this->stateFlags &= ~ENHORSE_BOOST_DECEL; + } + } else { + if (this->actor.speedXZ <= (baseSpeed * (1.0f / 54.0f) * stickMag)) { + phi_f0 = 1.0f; + } else { + phi_f0 = -1.0f; + } + + this->actor.speedXZ += phi_f0 * 50.0f * 0.01f; + + if (this->actor.speedXZ > baseSpeed) { + this->actor.speedXZ -= decel; + if (this->actor.speedXZ < baseSpeed) { + this->actor.speedXZ = baseSpeed; + } + } + } + + temp_f12 = stickAngle * (1 / 32236.f); + turn = stickAngle * temp_f12 * temp_f12 * (2.2f - (this->actor.speedXZ * (1.0f / this->boostSpeed))); + turn = CLAMP(turn, -turnSpeed * (2.2f - (1.7f * this->actor.speedXZ * (1.0f / this->boostSpeed))), + turnSpeed * (2.2f - (1.7f * this->actor.speedXZ * (1.0f / this->boostSpeed)))); + this->actor.world.rot.y += turn; + this->actor.shape.rot.y = this->actor.world.rot.y; +} + +void EnHorse_StartMountedIdleResetAnim(EnHorse* this) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_StartMountedIdle(this); + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; +} + +void EnHorse_StartMountedIdle(EnHorse* this) { + f32 curFrame; + + this->action = ENHORSE_ACT_MOUNTED_TURN; + this->animationIdx = ENHORSE_ANIM_IDLE; + + if (((this->curFrame > 35.0f) && (this->type == HORSE_EPONA)) || + ((this->curFrame > 28.0f) && (this->type == HORSE_HNI))) { + if (!(this->stateFlags & ENHORSE_SANDDUST_SOUND)) { + this->stateFlags |= ENHORSE_SANDDUST_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } + } + } + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedIdle(EnHorse* this, GlobalContext* globalCtx) { + f32 mag; + s16 angle = 0; + + this->actor.speedXZ = 0.0f; + EnHorse_StickDirection(&this->curStick, &mag, &angle); + if (mag > 10.0f) { + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (Math_CosS(angle) <= -0.5f) { + EnHorse_StartReversingInterruptable(this); + } else if (Math_CosS(angle) <= 0.7071f) { + EnHorse_StartTurning(this); + } else { + EnHorse_StartWalkingFromIdle(this); + } + } else if (this->unk_3EC != this->actor.world.rot.y) { + EnHorse_StartTurning(this); + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + EnHorse_MountedIdleAnim(this); + } +} + +void EnHorse_MountedIdleAnim(EnHorse* this) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_MountedIdleWhinney(this); +} + +void EnHorse_MountedIdleWhinney(EnHorse* this) { + f32 curFrame; + + this->action = ENHORSE_ACT_MOUNTED_WALK; + this->animationIdx = ENHORSE_ANIM_WHINNEY; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][1]), ANIMMODE_ONCE, -3.0f); + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_GROAN); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_GROAN); + } + } +} + +void EnHorse_MountedIdleWhinneying(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle = 0; + + this->actor.speedXZ = 0.0f; + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + if (stickMag > 10.0f) { + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (Math_CosS(stickAngle) <= -0.5f) { + EnHorse_StartReversingInterruptable(this); + } else if (Math_CosS(stickAngle) <= 0.7071f) { + EnHorse_StartTurning(this); + } else { + EnHorse_StartWalkingFromIdle(this); + } + } else if (this->unk_3EC != this->actor.world.rot.y) { + EnHorse_StartTurning(this); + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + EnHorse_StartMountedIdleResetAnim(this); + } +} + +void EnHorse_StartTurning(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_TROT; + this->soundTimer = 0; + this->animationIdx = ENHORSE_ANIM_WALK; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][4]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedTurn(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 clampedYaw; + s16 stickAngle; + + this->actor.speedXZ = 0.0f; + EnHorse_PlayWalkingSound(this); + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + if (stickMag > 10.0f) { + if (!EnHorse_PlayerCanMove(this, globalCtx)) { + EnHorse_StartMountedIdleResetAnim(this); + } else if (Math_CosS(stickAngle) <= -0.5f) { + EnHorse_StartReversingInterruptable(this); + } else if (Math_CosS(stickAngle) <= 0.7071f) { + clampedYaw = CLAMP(stickAngle, -1600.0f, 1600.0f); + this->actor.world.rot.y += clampedYaw; + this->actor.shape.rot.y = this->actor.world.rot.y; + } else { + EnHorse_StartWalkingInterruptable(this); + } + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (Math_CosS(stickAngle) <= 0.7071f) { + EnHorse_StartTurning(this); + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } else if (this->unk_3EC != this->actor.world.rot.y) { + EnHorse_StartTurning(this); + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } +} + +void EnHorse_StartWalkingFromIdle(EnHorse* this) { + EnHorse_StartWalkingInterruptable(this); + if (!(this->stateFlags & ENHORSE_FLAG_8) && !(this->stateFlags & ENHORSE_FLAG_9)) { + this->stateFlags |= ENHORSE_FLAG_9; + this->waitTimer = 8; + } else { + this->waitTimer = 0; + } +} + +void EnHorse_StartWalkingInterruptable(EnHorse* this) { + this->noInputTimer = 0; + this->noInputTimerMax = 0; + EnHorse_StartWalking(this); +} + +void EnHorse_StartWalking(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_GALLOP; + this->soundTimer = 0; + this->animationIdx = ENHORSE_ANIM_WALK; + this->waitTimer = 0; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][4]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedWalkingReset(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_GALLOP; + this->soundTimer = 0; + this->animationIdx = ENHORSE_ANIM_WALK; + this->waitTimer = 0; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); +} + +void EnHorse_MountedWalk(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + EnHorse_PlayWalkingSound(this); + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + + if ((this->noInputTimerMax == 0) || + ((this->noInputTimer > 0) && (this->noInputTimer < (this->noInputTimerMax - 20)))) { + EnHorse_UpdateSpeed(this, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 3.0f, 0x320); + } else { + this->actor.speedXZ = 3.0f; + } + + if (this->actor.speedXZ == 0.0f) { + this->stateFlags &= ~ENHORSE_FLAG_9; + EnHorse_StartMountedIdleResetAnim(this); + this->noInputTimer = 0; + this->noInputTimerMax = 0; + } else if (this->actor.speedXZ > 3.0f) { + this->stateFlags &= ~ENHORSE_FLAG_9; + EnHorse_StartTrotting(this); + this->noInputTimer = 0; + this->noInputTimerMax = 0; + } + + if (this->noInputTimer > 0) { + this->noInputTimer--; + if (this->noInputTimer <= 0) { + this->noInputTimerMax = 0; + } + } + + if (this->waitTimer <= 0) { + this->stateFlags &= ~ENHORSE_FLAG_9; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; + if ((SkelAnime_Update(&this->skin.skelAnime) || (this->actor.speedXZ == 0.0f)) && (this->noInputTimer <= 0)) { + if (this->actor.speedXZ > 3.0f) { + EnHorse_StartTrotting(this); + this->noInputTimer = 0; + this->noInputTimerMax = 0; + } else if ((stickMag < 10.0f) || (Math_CosS(stickAngle) <= -0.5f)) { + EnHorse_StartMountedIdleResetAnim(this); + this->noInputTimer = 0; + this->noInputTimerMax = 0; + } else { + EnHorse_MountedWalkingReset(this); + } + } + } else { + this->waitTimer--; + this->actor.speedXZ = 0.0f; + } +} + +void EnHorse_StartTrotting(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_REARING; + this->animationIdx = ENHORSE_ANIM_TROT; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedTrotReset(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_REARING; + this->animationIdx = ENHORSE_ANIM_TROT; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); +} + +void EnHorse_MountedTrot(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + EnHorse_UpdateSpeed(this, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 6.0f, 800); + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + if (this->actor.speedXZ < 3.0f) { + EnHorse_StartWalkingInterruptable(this); + } + + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; + + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_8087C178(this); + func_8013ECE0(0.0f, 60, 8, 255); + if (this->actor.speedXZ >= 6.0f) { + EnHorse_StartGallopingInterruptable(this); + } else if (this->actor.speedXZ < 3.0f) { + EnHorse_StartWalkingInterruptable(this); + } else { + EnHorse_MountedTrotReset(this); + } + } +} + +void EnHorse_StartGallopingInterruptable(EnHorse* this) { + this->noInputTimer = 0; + this->noInputTimerMax = 0; + EnHorse_StartGalloping(this); +} + +void EnHorse_StartGalloping(EnHorse* this) { + this->action = ENHORSE_ACT_STOPPING; + this->animationIdx = ENHORSE_ANIM_GALLOP; + this->unk_230 = 0; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedGallopReset(EnHorse* this) { + this->noInputTimer = 0; + this->noInputTimerMax = 0; + this->action = ENHORSE_ACT_STOPPING; + this->animationIdx = ENHORSE_ANIM_GALLOP; + this->unk_230 = 0; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); +} + +void EnHorse_JumpLanding(EnHorse* this, GlobalContext* globalCtx) { + Vec3s* jointTable; + f32 y; + + this->action = ENHORSE_ACT_STOPPING; + this->animationIdx = ENHORSE_ANIM_GALLOP; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y += y * 0.01f * this->unk_528 * 0.01f; + this->postDrawFunc = NULL; +} + +void EnHorse_MountedGallop(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + + if (this->noInputTimer <= 0) { + EnHorse_UpdateSpeed(this, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 8.0f, 800); + } else if (this->noInputTimer > 0) { + this->noInputTimer--; + this->actor.speedXZ = 8.0f; + } + + if (this->actor.speedXZ < 6.0f) { + EnHorse_StartTrotting(this); + } + + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_8087C1C0(this); + func_8013ECE0(0.0f, 120, 8, 255); + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if ((stickMag >= 10.0f) && (Math_CosS(stickAngle) <= -0.5f)) { + EnHorse_StartBraking(this, globalCtx); + } else if (this->actor.speedXZ < 6.0f) { + EnHorse_StartTrotting(this); + } else { + EnHorse_MountedGallopReset(this); + } + } else { + EnHorse_MountedGallopReset(this); + } + } +} + +void EnHorse_StartRearing(EnHorse* this) { + this->action = ENHORSE_ACT_REVERSE; + this->animationIdx = ENHORSE_ANIM_REARING; + + if (sAnimationHeaders[this->type][this->animationIdx] == NULL) { + if (Rand_ZeroOne() > 0.5f) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + func_8013ECE0(0.0f, 180, 20, 100); + this->stateFlags &= ~ENHORSE_STOPPING_NEIGH_SOUND; + } + EnHorse_StartMountedIdleResetAnim(this); + } + + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + + func_8013ECE0(0.0f, 180, 20, 100); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedRearing(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + this->actor.speedXZ = 0.0f; + if (this->curFrame > 25.0f) { + if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + func_8013ECE0(0.0f, 180, 20, 100); + } + } + + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (this->stateFlags & ENHORSE_FORCE_REVERSING) { + this->noInputTimer = 100; + this->noInputTimerMax = 100; + this->stateFlags &= ~ENHORSE_FORCE_REVERSING; + EnHorse_StartReversing(this); + } else if (this->stateFlags & ENHORSE_FORCE_WALKING) { + this->noInputTimer = 100; + this->noInputTimerMax = 100; + this->stateFlags &= ~ENHORSE_FORCE_WALKING; + EnHorse_StartWalking(this); + } else if (Math_CosS(stickAngle) <= -0.5f) { + EnHorse_StartReversingInterruptable(this); + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } +} + +void EnHorse_StartBraking(EnHorse* this, GlobalContext* globalCtx) { + this->action = ENHORSE_ACT_LOW_JUMP; + this->animationIdx = ENHORSE_ANIM_STOPPING; + if (sAnimationHeaders[this->type][this->animationIdx] == NULL) { + if (Rand_ZeroOne() > 0.5f) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + func_8013ECE0(0.0f, 180, 20, 100); + this->stateFlags &= ~ENHORSE_STOPPING_NEIGH_SOUND; + } + EnHorse_StartMountedIdleResetAnim(this); + } + + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_SLIP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_SLIP); + } + + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + this->stateFlags |= ENHORSE_STOPPING_NEIGH_SOUND; + this->stateFlags &= ~ENHORSE_BOOST; +} + +void EnHorse_Stopping(EnHorse* this, GlobalContext* globalCtx) { + if (this->actor.speedXZ > 0.0f) { + this->actor.speedXZ -= 0.6f; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + } + + if ((this->stateFlags & ENHORSE_STOPPING_NEIGH_SOUND) && (this->skin.skelAnime.curFrame > 29.0f)) { + this->actor.speedXZ = 0.0f; + if ((Rand_ZeroOne() > 0.5f) && + ((gSaveContext.save.entranceIndex != 0x6400) || !Cutscene_GetSceneSetupIndex(globalCtx))) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + func_8013ECE0(0.0f, 180, 20, 100); + this->stateFlags &= ~ENHORSE_STOPPING_NEIGH_SOUND; + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } + + if (this->skin.skelAnime.curFrame > 29.0f) { + this->actor.speedXZ = 0.0f; + } else if ((this->actor.speedXZ > 3.0f) && (this->stateFlags & ENHORSE_FORCE_REVERSING)) { + this->actor.speedXZ = 3.0f; + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (this->stateFlags & ENHORSE_FORCE_REVERSING) { + this->noInputTimer = 100; + this->noInputTimerMax = 100; + EnHorse_StartReversing(this); + this->stateFlags &= ~ENHORSE_FORCE_REVERSING; + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } +} + +void EnHorse_StartReversingInterruptable(EnHorse* this) { + this->noInputTimer = 0; + this->noInputTimerMax = 0; + EnHorse_StartReversing(this); +} + +void EnHorse_StartReversing(EnHorse* this) { + this->action = ENHORSE_ACT_HIGH_JUMP; + this->animationIdx = ENHORSE_ANIM_WALK; + this->soundTimer = 0; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_LOOP, -3.0f); +} + +void EnHorse_Reverse(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + s16 turnAmount; + Player* player = GET_PLAYER(globalCtx); + + EnHorse_PlayWalkingSound(this); + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if ((this->noInputTimerMax == 0) || + ((this->noInputTimer > 0) && (this->noInputTimer < (this->noInputTimerMax - 20)))) { + if ((stickMag < 10.0f) && (this->noInputTimer <= 0)) { + EnHorse_StartMountedIdleResetAnim(this); + this->actor.speedXZ = 0.0f; + return; + } else if (stickMag < 10.0f) { + stickAngle = -0x7FFF; + } else if (Math_CosS(stickAngle) > -0.5f) { + this->noInputTimerMax = 0; + EnHorse_StartMountedIdleResetAnim(this); + this->actor.speedXZ = 0.0f; + return; + } + } else if (stickMag < 10.0f) { + stickAngle = -0x7FFF; + } + } else if ((player->actor.flags & ACTOR_FLAG_100) || (globalCtx->csCtx.state != 0) || + (ActorCutscene_GetCurrentIndex() != -1) || (player->stateFlags1 & 0x20)) { + EnHorse_StartMountedIdleResetAnim(this); + this->actor.speedXZ = 0.0f; + return; + } else { + stickAngle = -0x7FFF; + } + + this->actor.speedXZ = -2.0f; + turnAmount = -0x8000 - stickAngle; + turnAmount = CLAMP(turnAmount, -2400.0f, 2400.0f); + this->actor.world.rot.y += turnAmount; + this->actor.shape.rot.y = this->actor.world.rot.y; + + if (this->noInputTimer > 0) { + this->noInputTimer--; + if (this->noInputTimer <= 0) { + this->noInputTimerMax = 0; + } + } + + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.5f * 1.5f; + + if (SkelAnime_Update(&this->skin.skelAnime) && (this->noInputTimer <= 0) && + (EnHorse_PlayerCanMove(this, globalCtx) == true)) { + if ((stickMag > 10.0f) && (Math_CosS(stickAngle) <= -0.5f)) { + this->noInputTimerMax = 0; + EnHorse_StartReversingInterruptable(this); + } else if (stickMag < 10.0f) { + this->noInputTimerMax = 0; + EnHorse_StartMountedIdleResetAnim(this); + } else { + EnHorse_StartReversing(this); + } + } +} + +void EnHorse_LowJumpInit(EnHorse* this, GlobalContext* globalCtx) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_StartLowJump(this, globalCtx); +} + +void EnHorse_StartLowJump(EnHorse* this, GlobalContext* globalCtx) { + f32 curFrame; + Vec3s* jointTable; + f32 y; + + this->action = ENHORSE_ACT_BRIDGE_JUMP; + this->animationIdx = ENHORSE_ANIM_LOW_JUMP; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + this->postDrawFunc = NULL; + this->jumpStartY = this->actor.world.pos.y; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y -= ((y * 0.01f) * this->unk_528) * 0.01f; + + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } + func_8013ECE0(0.0f, 170, 10, 10); +} + +void EnHorse_Stub1(EnHorse* this) { +} + +void EnHorse_LowJump(EnHorse* this, GlobalContext* globalCtx) { + Vec3f pad; + f32 temp_f0; + f32 curFrame; + Vec3s* jointTable; + + this->stateFlags |= ENHORSE_JUMPING; + + if (this->actor.speedXZ < 12.0f) { + this->actor.speedXZ = 12.0f; + } + + if (this->actor.floorHeight != BGCHECK_Y_MIN) { + CollisionPoly* colPoly; + s32 floorBgId; + Vec3f pos = this->actor.world.pos; + + pos.y = this->actor.floorHeight - 5.0f; + temp_f0 = + BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &colPoly, &floorBgId, &this->actor, &pos); + if ((this->actor.floorHeight - 120.0f) < temp_f0) { + this->actor.floorHeight = temp_f0; + this->actor.floorPoly = colPoly; + this->actor.floorBgId = floorBgId; + } + } + + curFrame = this->skin.skelAnime.curFrame; + + if (curFrame > 17.0f) { + this->actor.gravity = -3.5f; + if (this->actor.velocity.y == 0.0f) { + this->actor.velocity.y = -6.0f; + } + if (this->actor.world.pos.y < (this->actor.floorHeight + 90.0f)) { + this->skin.skelAnime.playSpeed = 1.5f; + } else { + this->skin.skelAnime.playSpeed = 0.0f; + } + } else { + jointTable = this->skin.skelAnime.jointTable; + temp_f0 = jointTable->y; + + this->actor.world.pos.y = this->jumpStartY + (temp_f0 * 0.01f * this->unk_528 * 0.01f); + } + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((curFrame > 17.0f) && + (this->actor.world.pos.y < ((this->actor.floorHeight - this->actor.velocity.y) + 80.0f)))) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } + func_8013ECE0(0.0f, 255, 10, 80); + this->stateFlags &= ~ENHORSE_JUMPING; + this->actor.gravity = -3.5f; + this->actor.world.pos.y = this->actor.floorHeight; + EnHorse_JumpLanding(this, globalCtx); + } +} + +void EnHorse_HighJumpInit(EnHorse* this, GlobalContext* globalCtx) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_StartHighJump(this, globalCtx); +} + +void EnHorse_StartHighJump(EnHorse* this, GlobalContext* globalCtx) { + f32 curFrame; + Vec3s* jointTable; + f32 y; + + this->action = ENHORSE_ACT_CS_UPDATE; + this->animationIdx = ENHORSE_ANIM_HIGH_JUMP; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + + this->postDrawFunc = NULL; + this->jumpStartY = this->actor.world.pos.y; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y -= ((y * 0.01f) * this->unk_528) * 0.01f; + + this->stateFlags |= ENHORSE_CALC_RIDER_POS; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } + func_8013ECE0(0.0f, 170, 10, 10); +} + +void EnHorse_Stub2(EnHorse* this) { +} + +void EnHorse_HighJump(EnHorse* this, GlobalContext* globalCtx) { + Vec3f pad; + f32 temp_f0; + f32 curFrame; + Vec3s* jointTable; + + this->stateFlags |= ENHORSE_JUMPING; + + if (this->actor.speedXZ < 13.0f) { + this->actor.speedXZ = 13.0f; + } + + if (this->actor.floorHeight != BGCHECK_Y_MIN) { + CollisionPoly* colPoly; + s32 floorBgId; + Vec3f pos = this->actor.world.pos; + + pos.y = this->actor.floorHeight - 5.0f; + temp_f0 = + BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &colPoly, &floorBgId, &this->actor, &pos); + if ((this->actor.floorHeight - 120.0f) < temp_f0) { + this->actor.floorHeight = temp_f0; + this->actor.floorPoly = colPoly; + this->actor.floorBgId = floorBgId; + } + } + + curFrame = this->skin.skelAnime.curFrame; + + if (curFrame > 23.0f) { + this->actor.gravity = -3.5f; + if (this->actor.velocity.y == 0.0f) { + this->actor.velocity.y = -10.5f; + } + if (this->actor.world.pos.y < (this->actor.floorHeight + 90.0f)) { + this->skin.skelAnime.playSpeed = 1.5f; + } else { + this->skin.skelAnime.playSpeed = 0.0f; + } + } else { + jointTable = this->skin.skelAnime.jointTable; + temp_f0 = jointTable->y; + this->actor.world.pos.y = this->jumpStartY + (temp_f0 * 0.01f * this->unk_528 * 0.01f); + } + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((curFrame > 23.0f) && + (this->actor.world.pos.y < ((this->actor.floorHeight - this->actor.velocity.y) + 80.0f)))) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } + func_8013ECE0(0.0f, 255, 10, 80); + this->stateFlags &= ~ENHORSE_JUMPING; + this->actor.gravity = -3.5f; + this->actor.world.pos.y = this->actor.floorHeight; + func_800B1598(globalCtx, 25.0f, &this->actor.world.pos); + EnHorse_JumpLanding(this, globalCtx); + } +} + +void EnHorse_InitInactive(EnHorse* this) { + this->colliderCylinder1.base.ocFlags1 &= ~OC1_ON; + this->colliderCylinder2.base.ocFlags1 &= ~OC1_ON; + this->colliderJntSph.base.ocFlags1 &= ~OC1_ON; + this->action = ENHORSE_ACT_INACTIVE; + this->animationIdx = ENHORSE_ANIM_WALK; + this->stateFlags |= ENHORSE_INACTIVE; + this->followTimer = 0; +} + +void EnHorse_Inactive(EnHorse* this, GlobalContext* globalCtx) { + if ((D_801BDAA4 != 0) && (this->type == HORSE_2)) { + D_801BDAA4 = 0; + if (EnHorse_Spawn(this, globalCtx)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } + this->stateFlags &= ~ENHORSE_INACTIVE; + } + } + + if (!(this->stateFlags & ENHORSE_INACTIVE)) { + this->followTimer = 0; + EnHorse_SetFollowAnimation(this, globalCtx); + this->actor.params = ENHORSE_0; + this->colliderCylinder1.base.ocFlags1 |= OC1_ON; + this->colliderCylinder2.base.ocFlags1 |= OC1_ON; + this->colliderJntSph.base.ocFlags1 |= OC1_ON; + } +} + +void EnHorse_PlayIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 startFrames) { + this->action = ENHORSE_ACT_IDLE; + this->actor.speedXZ = 0.0f; + + if ((anim != ENHORSE_ANIM_IDLE) && (anim != ENHORSE_ANIM_WHINNEY) && (anim != ENHORSE_ANIM_REARING)) { + anim = ENHORSE_ANIM_IDLE; + } + + if (sAnimationHeaders[this->type][anim] == NULL) { + anim = ENHORSE_ANIM_IDLE; + } + + if (anim != this->animationIdx) { + this->animationIdx = anim; + if (anim == ENHORSE_ANIM_IDLE) { + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + } else { + if (this->animationIdx == ENHORSE_ANIM_WHINNEY) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_GROAN); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_GROAN); + } + } + } else if (this->animationIdx == ENHORSE_ANIM_REARING) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + } + } + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, startFrames, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + morphFrames); + } +} + +void EnHorse_ChangeIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames) { + EnHorse_PlayIdleAnimation(this, anim, morphFrames, this->curFrame); +} + +void EnHorse_ResetIdleAnimation(EnHorse* this) { + this->animationIdx = ENHORSE_ANIM_WALK; + EnHorse_PlayIdleAnimation(this, this->animationIdx, 0.0f, 0.0f); +} + +void EnHorse_StartIdleRidable(EnHorse* this) { + EnHorse_ResetIdleAnimation(this); + this->stateFlags &= ~ENHORSE_UNRIDEABLE; +} + +void EnHorse_Idle(EnHorse* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + EnHorse_IdleAnimSounds(this, globalCtx); + + if ((D_801BDAA4 != 0) && (this->type == HORSE_2)) { + D_801BDAA4 = 0; + if (!func_8087C38C(globalCtx, this, &this->actor.world.pos)) { + if (EnHorse_Spawn(this, globalCtx)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_NEIGH); + } + this->followTimer = 0; + EnHorse_SetFollowAnimation(this, globalCtx); + } + } else { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_NEIGH); + } + this->followTimer = 0; + EnHorse_StartMovingAnimation(this, 6, -3.0f, 0.0f); + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + s32 idleAnimIdx = 0; + + if (this->animationIdx != 0) { + if (this->animationIdx == 1) { + idleAnimIdx = 1; + } else if (this->animationIdx == 3) { + idleAnimIdx = 2; + } + } + // Play one of the two other idle animations + EnHorse_PlayIdleAnimation(this, sIdleAnimIds[((Rand_ZeroOne() > 0.5f) ? 0 : 1) + idleAnimIdx * 2], 0.0f, 0.0f); + } +} + +void EnHorse_StartMovingAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 startFrames) { + this->action = ENHORSE_ACT_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 (anim != this->animationIdx) { + this->animationIdx = anim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, startFrames, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + morphFrames); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, startFrames, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void EnHorse_SetFollowAnimation(EnHorse* this, GlobalContext* globalCtx) { + s32 anim = ENHORSE_ANIM_WALK; + f32 distToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + + if (distToPlayer > 400.0f) { + anim = ENHORSE_ANIM_GALLOP; + } else if (!(distToPlayer <= 300.0f) && (distToPlayer <= 400.0f)) { + anim = ENHORSE_ANIM_TROT; + } + + if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + if (distToPlayer > 400.0f) { + anim = ENHORSE_ANIM_GALLOP; + } else { + anim = ENHORSE_ANIM_TROT; + } + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + if (distToPlayer > 400.0f) { + anim = ENHORSE_ANIM_GALLOP; + } else if (distToPlayer < 300.0f) { + anim = ENHORSE_ANIM_WALK; + } else { + anim = ENHORSE_ANIM_TROT; + } + } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + if (distToPlayer > 300.0f) { + anim = ENHORSE_ANIM_TROT; + } else { + anim = ENHORSE_ANIM_WALK; + } + } + + EnHorse_StartMovingAnimation(this, anim, -3.0f, 0.0f); +} + +void EnHorse_FollowPlayer(EnHorse* this, GlobalContext* globalCtx) { + f32 distToPlayer; + + D_801BDAA4 = 0; + distToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + + if (((this->playerDir == PLAYER_DIR_BACK_R) || (this->playerDir == PLAYER_DIR_BACK_L)) && (distToPlayer > 300.0f) && + !(this->stateFlags & ENHORSE_TURNING_TO_PLAYER)) { + f32 angleDiff; + + this->animationIdx = ENHORSE_ANIM_REARING; + this->stateFlags |= ENHORSE_TURNING_TO_PLAYER; + this->angleToPlayer = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + + angleDiff = (f32)this->angleToPlayer - this->actor.world.rot.y; + if (angleDiff > 0x7FFF) { + angleDiff -= 0x7FFF; + } else if (angleDiff < -0x7FFF) { + angleDiff += 0x7FFF; + } + + this->followPlayerTurnSpeed = + angleDiff / Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]); + + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + this->skin.skelAnime.playSpeed = 1.0f; + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + } else if (this->stateFlags & ENHORSE_TURNING_TO_PLAYER) { + this->actor.world.rot.y += this->followPlayerTurnSpeed; + this->actor.shape.rot.y = this->actor.world.rot.y; + if ((this->curFrame > 25.0f) && !(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + } + } else { + EnHorse_RotateToPlayer(this, globalCtx); + } + + if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + this->actor.speedXZ = 8.0f; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + } else { + if (this->animationIdx == ENHORSE_ANIM_TROT) { + this->actor.speedXZ = 6.0f; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; + } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + this->actor.speedXZ = 3.0f; + EnHorse_PlayWalkingSound(this); + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; + } else { + this->actor.speedXZ = 0.0f; + this->skin.skelAnime.playSpeed = 1.0f; + } + } + + if (!(this->stateFlags & ENHORSE_TURNING_TO_PLAYER)) { + this->followTimer++; + if (this->followTimer > 300) { + EnHorse_StartIdleRidable(this); + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + func_8087C1C0(this); + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + func_8087C178(this); + } + + this->stateFlags &= ~ENHORSE_TURNING_TO_PLAYER; + + if (distToPlayer < 100.0f) { + EnHorse_StartIdleRidable(this); + } else { + EnHorse_SetFollowAnimation(this, globalCtx); + } + } +} + +void EnHorse_InitIngoHorse(EnHorse* this) { + this->curRaceWaypoint = 0; + this->soundTimer = 0; + this->actor.speedXZ = 0.0f; + EnHorse_UpdateIngoHorseAnim(this); + if (this->stateFlags & ENHORSE_DRAW) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_IT_INGO_HORSE_NEIGH); + } +} + +void EnHorse_SetIngoAnimation(s32 anim, f32 curFrame, s32 arg2, s16* animIdxOut) { + *animIdxOut = sIngoAnimations[anim]; + if (arg2 == 1) { + if (anim == 5) { + *animIdxOut = 4; + } else if (anim == 6) { + *animIdxOut = 3; + } + } +} + +void EnHorse_UpdateIngoHorseAnim(EnHorse* this) { + s32 animChanged = false; + f32 animSpeed; + + this->action = ENHORSE_ACT_INGO_RACE; + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + + if (this->actor.speedXZ == 0.0f) { + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_IDLE; + } else if (this->actor.speedXZ <= 3.0f) { + if (this->animationIdx != ENHORSE_ANIM_WALK) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_WALK; + } else if (this->actor.speedXZ <= 6.0f) { + if (this->animationIdx != ENHORSE_ANIM_TROT) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_TROT; + } else { + if (this->animationIdx != ENHORSE_ANIM_GALLOP) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_GALLOP; + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + animSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + animSpeed = this->actor.speedXZ * 0.25f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + animSpeed = this->actor.speedXZ * 0.2f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + } else { + animSpeed = 1.0f; + } + + if (animChanged == true) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void EnHorse_UpdateIngoRace(EnHorse* this, GlobalContext* globalCtx) { + f32 playSpeed; + + if ((this->animationIdx == ENHORSE_ANIM_IDLE) || (this->animationIdx == ENHORSE_ANIM_WHINNEY)) { + EnHorse_IdleAnimSounds(this, globalCtx); + } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + EnHorse_PlayWalkingSound(this); + } + + if (!this->inRace) { + this->actor.speedXZ = 0.0f; + this->rider->actor.speedXZ = 0.0f; + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + EnHorse_UpdateIngoHorseAnim(this); + } + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + playSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == 5) { + playSpeed = this->actor.speedXZ * 0.25f; + } else if (this->animationIdx == 6) { + playSpeed = this->actor.speedXZ * 0.2f; + } else { + playSpeed = 1.0f; + } + this->skin.skelAnime.playSpeed = playSpeed; + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { + EnHorse_UpdateIngoHorseAnim(this); + } +} + +void func_8088126C(EnHorse* this, GlobalContext* globalCtx) { + this->skin.skelAnime.curFrame = 0.0f; + func_80881290(this, globalCtx); +} + +void func_80881290(EnHorse* this, GlobalContext* globalCtx) { + f32 curFrame; + + this->action = ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING; + this->animationIdx = ENHORSE_ANIM_HIGH_JUMP; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + this->postDrawFunc = NULL; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->jumpStartY = this->actor.world.pos.y; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } + func_8013ECE0(0.0f, 170, 10, 10); +} + +void func_80881398(EnHorse* this, GlobalContext* globalCtx) { + Vec3s* jointTable; + f32 y; + s32 animeUpdated; + f32 curFrame; + + this->stateFlags |= ENHORSE_JUMPING; + if (this->actor.speedXZ < 14.0f) { + this->actor.speedXZ = 14.0f; + } + + animeUpdated = SkelAnime_Update(&this->skin.skelAnime); + curFrame = this->skin.skelAnime.curFrame; + + if (curFrame > 23.0f) { + this->actor.gravity = -3.5f; + if (this->actor.velocity.y == 0.0f) { + this->actor.velocity.y = -10.5f; + } + if (this->actor.world.pos.y < (this->actor.floorHeight + 90.0f)) { + this->skin.skelAnime.playSpeed = 1.5f; + } else { + this->skin.skelAnime.playSpeed = 0.0f; + } + } else { + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + 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 (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } + func_8013ECE0(0.0f, 255, 10, 80); + this->stateFlags &= ~ENHORSE_JUMPING; + this->stateFlags &= ~ENHORSE_FLAG_30; + this->actor.gravity = -3.5f; + this->actor.world.pos.y = this->actor.floorHeight; + func_800B1598(globalCtx, 25.0f, &this->actor.world.pos); + func_8088159C(this, globalCtx); + } +} + +void func_8088159C(EnHorse* this, GlobalContext* globalCtx) { + Vec3s* jointTable; + f32 y; + + this->action = ENHORSE_ACT_MOUNTED_IDLE; + this->animationIdx = ENHORSE_ANIM_GALLOP; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y += y * 0.01f * this->unk_528 * 0.01f; + this->postDrawFunc = NULL; +} + +void func_80881634(EnHorse* this) { + this->curRaceWaypoint = 0; + this->soundTimer = 0; + this->actor.speedXZ = 0.0f; + func_8088168C(this); + if (this->stateFlags & ENHORSE_DRAW) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_IT_INGO_HORSE_NEIGH); + } +} + +void func_8088168C(EnHorse* this) { + s32 animChanged = false; + f32 animSpeed; + f32 finalAnimSpeed; + + this->action = ENHORSE_ACT_MOUNTED_IDLE; + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + + if (this->actor.speedXZ == 0.0f) { + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_IDLE; + } else if (this->actor.speedXZ <= 3.0f) { + if (this->animationIdx != ENHORSE_ANIM_WALK) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_WALK; + } else if (this->actor.speedXZ <= 6.0f) { + if (this->animationIdx != ENHORSE_ANIM_TROT) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_TROT; + } else { + if (this->animationIdx != ENHORSE_ANIM_GALLOP) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_GALLOP; + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + animSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + animSpeed = this->actor.speedXZ * 0.25f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + animSpeed = this->actor.speedXZ * 0.2f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + } else { + animSpeed = 1.0f; + } + + finalAnimSpeed = sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f; + if (finalAnimSpeed < 1.0f) { + finalAnimSpeed = 1.0f; + } + + if (animChanged == true) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], finalAnimSpeed, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], finalAnimSpeed, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void func_808819D8(EnHorse* this, GlobalContext* globalCtx) { + Path* path; + f32 animSpeed; + + if ((this->animationIdx == ENHORSE_ANIM_IDLE) || (this->animationIdx == ENHORSE_ANIM_WHINNEY)) { + EnHorse_IdleAnimSounds(this, globalCtx); + } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + EnHorse_PlayWalkingSound(this); + } + + if (!this->inRace) { + this->actor.speedXZ = 0.0f; + this->rider->actor.speedXZ = 0.0f; + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + EnHorse_UpdateIngoHorseAnim(this); + } + } + + if (this->actor.params == ENHORSE_4) { + path = &globalCtx->setupPathList[0]; + func_8087B7C0(this, globalCtx, path); + } else if (this->actor.params == ENHORSE_5) { + path = &globalCtx->setupPathList[1]; + func_8087B7C0(this, globalCtx, path); + } + + if (!this->inRace) { + this->actor.speedXZ = 0.0f; + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + func_8088168C(this); + } + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + animSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + animSpeed = this->actor.speedXZ * 0.25f; + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + animSpeed = this->actor.speedXZ * 0.2f; + } else { + animSpeed = 1.0f; + } + this->skin.skelAnime.playSpeed = animSpeed; + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { + func_8088168C(this); + } + + if ((gSaveContext.save.weekEventReg[92] & (1 | 2 | 4)) == 3) { + this->rider->unk488 = 7; + } else { + EnHorse_SetIngoAnimation(this->animationIdx, this->skin.skelAnime.curFrame, this->unk_394 & 1, + &this->rider->unk488); + } +} + +void EnHorse_CsMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->animationIdx = ENHORSE_ANIM_GALLOP; + this->cutsceneAction = 1; + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + this->actor.speedXZ * 0.2f * 1.5f); +} + +void EnHorse_CsMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Vec3f endPos; + s32 pad; + + endPos.x = action->endPos.x; + endPos.y = action->endPos.y; + endPos.z = action->endPos.z; + + if (Math3D_Distance(&endPos, &this->actor.world.pos) > 8.0f) { + EnHorse_RotateToPoint(this, globalCtx, &endPos, 0x320); + this->actor.speedXZ = 8.0f; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + } else { + this->actor.world.pos = endPos; + this->actor.speedXZ = 0.0f; + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_8087C1C0(this); + func_8013ECE0(0.0f, 120, 8, 255); + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + this->actor.speedXZ * 0.3f); + } +} + +void EnHorse_CsSetAnimHighJump(EnHorse* this, GlobalContext* globalCtx) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_CsPlayHighJumpAnim(this, globalCtx); +} + +void EnHorse_CsPlayHighJumpAnim(EnHorse* this, GlobalContext* globalCtx) { + f32 curFrame; + f32 y; + Vec3s* jointTable; + + this->animationIdx = ENHORSE_ANIM_HIGH_JUMP; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + this->postDrawFunc = NULL; + this->jumpStartY = this->actor.world.pos.y; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y -= y * 0.01f * this->unk_528 * 0.01f; + + this->stateFlags |= ENHORSE_ANIM_HIGH_JUMP; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } + func_8013ECE0(0.0f, 170, 10, 10); +} + +void EnHorse_CsJumpInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + EnHorse_CsSetAnimHighJump(this, globalCtx); + this->cutsceneAction = 2; + this->cutsceneFlags &= ~1; +} + +void EnHorse_CsJump(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + f32 curFrame; + f32 y; + Vec3s* jointTable; + s32 pad[2]; + + if (this->cutsceneFlags & 1) { + EnHorse_CsMoveToPoint(this, globalCtx, action); + return; + } + + curFrame = this->skin.skelAnime.curFrame; + this->actor.speedXZ = 13.0f; + this->stateFlags |= ENHORSE_JUMPING; + + if (curFrame > 19.0f) { + this->actor.gravity = -3.5f; + if (this->actor.velocity.y == 0.0f) { + this->actor.velocity.y = -10.5f; + } + if (this->actor.world.pos.y < (this->actor.floorHeight + 90.0f)) { + this->skin.skelAnime.playSpeed = 1.5f; + } else { + this->skin.skelAnime.playSpeed = 0.0f; + } + } else { + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + + this->actor.world.pos.y = this->jumpStartY + (y * 0.01f * this->unk_528 * 0.01f); + } + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((curFrame > 19.0f) && + (this->actor.world.pos.y < ((this->actor.floorHeight - this->actor.velocity.y) + 80.0f)))) { + this->cutsceneFlags |= 1; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } + func_8013ECE0(0.0f, 255, 10, 80); + this->stateFlags &= ~ENHORSE_JUMPING; + this->actor.gravity = -3.5f; + this->actor.velocity.y = 0.0f; + this->actor.world.pos.y = this->actor.floorHeight; + func_800B1598(globalCtx, 25.0f, &this->actor.world.pos); + this->animationIdx = ENHORSE_ANIM_GALLOP; + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[6]); + + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y += y * 0.01f * this->unk_528 * 0.01f; + + this->postDrawFunc = NULL; + } +} + +void EnHorse_CsRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->animationIdx = ENHORSE_ANIM_REARING; + this->cutsceneAction = 3; + this->cutsceneFlags &= ~4; + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_CsRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->actor.speedXZ = 0.0f; + if (this->curFrame > 25.0f) { + if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + this->animationIdx = ENHORSE_ANIM_IDLE; + if (!(this->cutsceneFlags & 4)) { + this->cutsceneFlags |= 4; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_LOOP, + 0.0f); + } + } +} + +void EnHorse_WarpMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->actor.world.pos.x = action->startPos.x; + this->actor.world.pos.y = action->startPos.y; + this->actor.world.pos.z = action->startPos.z; + this->actor.prevPos = this->actor.world.pos; + + this->actor.world.rot.y = action->urot.y; + this->actor.shape.rot = this->actor.world.rot; + + this->animationIdx = ENHORSE_ANIM_GALLOP; + this->cutsceneAction = 4; + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + this->actor.speedXZ * 0.3f); +} + +void EnHorse_CsWarpMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Vec3f endPos; + s32 pad; + + endPos.x = action->endPos.x; + endPos.y = action->endPos.y; + endPos.z = action->endPos.z; + + if (Math3D_Distance(&endPos, &this->actor.world.pos) > 8.0f) { + EnHorse_RotateToPoint(this, globalCtx, &endPos, 0x320); + this->actor.speedXZ = 8.0f; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + } else { + this->actor.world.pos = endPos; + this->actor.speedXZ = 0.0f; + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_8087C1C0(this); + func_8013ECE0(0.0f, 120, 8, 255); + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + this->actor.speedXZ * 0.3f); + } +} + +void EnHorse_CsWarpRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->actor.world.pos.x = action->startPos.x; + this->actor.world.pos.y = action->startPos.y; + this->actor.world.pos.z = action->startPos.z; + this->actor.prevPos = this->actor.world.pos; + + this->actor.world.rot.y = action->urot.y; + this->actor.shape.rot = this->actor.world.rot; + + this->animationIdx = ENHORSE_ANIM_REARING; + this->cutsceneAction = 5; + this->cutsceneFlags &= ~4; + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_CsWarpRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->actor.speedXZ = 0.0f; + if (this->curFrame > 25.0f) { + if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + this->animationIdx = ENHORSE_ANIM_IDLE; + if (!(this->cutsceneFlags & 4)) { + this->cutsceneFlags |= 4; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_LOOP, + 0.0f); + } + } +} + +void EnHorse_InitCutscene(EnHorse* this, GlobalContext* globalCtx) { + this->playerControlled = false; + this->action = ENHORSE_ACT_HBA; + this->cutsceneAction = 0; + this->actor.speedXZ = 0.0f; +} + +s32 EnHorse_GetCutsceneFunctionIndex(s32 csAction) { + s32 numActions = ARRAY_COUNT(sCsActionTable); // prevents unrolling + s32 i; + + for (i = 0; i < numActions; i++) { + if (csAction == sCsActionTable[i].csAction) { + return sCsActionTable[i].csFuncIdx; + } + + if (csAction < sCsActionTable[i].csAction) { + return 0; + } + } + return 0; +} + +void EnHorse_CutsceneUpdate(EnHorse* this, GlobalContext* globalCtx) { + s32 csFunctionIdx; + CsCmdActorAction* playerAction = globalCtx->csCtx.playerAction; + + if (globalCtx->csCtx.state == 3) { + this->playerControlled = true; + this->actor.params = ENHORSE_12; + this->action = ENHORSE_ACT_IDLE; + EnHorse_Freeze(this, globalCtx); + return; + } + + if (playerAction != NULL) { + csFunctionIdx = EnHorse_GetCutsceneFunctionIndex(playerAction->action); + if (csFunctionIdx != 0) { + if (csFunctionIdx != this->cutsceneAction) { + if (this->cutsceneAction == 0) { + this->actor.world.pos.x = playerAction->startPos.x; + this->actor.world.pos.y = playerAction->startPos.y; + this->actor.world.pos.z = playerAction->startPos.z; + + this->actor.world.rot.y = playerAction->urot.y; + this->actor.shape.rot = this->actor.world.rot; + this->actor.prevPos = this->actor.world.pos; + } + this->cutsceneAction = csFunctionIdx; + sCutsceneInitFuncs[csFunctionIdx](this, globalCtx, playerAction); + } + sCutsceneActionFuncs[this->cutsceneAction](this, globalCtx, playerAction); + } + } +} + +s32 EnHorse_UpdateHbaRaceInfo(EnHorse* this, GlobalContext* globalCtx, RaceInfo* raceInfo) { + Vec3f pos; + f32 px; + f32 pz; + f32 d; + + EnHorse_RaceWaypointPos(raceInfo->waypoints, this->curRaceWaypoint, &pos); + func_8017B7F8(&pos, raceInfo->waypoints[this->curRaceWaypoint].angle, &px, &pz, &d); + + if ((this->curRaceWaypoint >= (raceInfo->numWaypoints - 1)) && + (Math3D_Distance(&pos, &this->actor.world.pos) < DREG(8))) { + this->hbaFlags |= 2; + } + + if (((this->actor.world.pos.x * px) + (pz * this->actor.world.pos.z) + d) > 0.0f) { + this->curRaceWaypoint++; + if (this->curRaceWaypoint >= raceInfo->numWaypoints) { + this->hbaFlags |= 1; + return true; + } + } + + if (!(this->hbaFlags & 1)) { + EnHorse_RotateToPoint(this, globalCtx, &pos, 0x640); + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + if ((this->actor.speedXZ < raceInfo->waypoints[this->curRaceWaypoint].speed) && !(this->hbaFlags & 1)) { + this->actor.speedXZ += 0.4f; + } else { + this->actor.speedXZ -= 0.4f; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + } + return false; +} + +void EnHorse_InitHorsebackArchery(EnHorse* this) { + this->hbaStarted = 0; + this->soundTimer = 0; + this->curRaceWaypoint = 0; + this->hbaTimer = 0; + this->actor.speedXZ = 0.0f; + EnHorse_UpdateHbaAnim(this); +} + +void EnHorse_UpdateHbaAnim(EnHorse* this) { + s32 animChanged = false; + f32 animSpeed; + + this->action = ENHORSE_ACT_FLEE_PLAYER; + if (this->actor.speedXZ == 0.0f) { + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_IDLE; + } else if (this->actor.speedXZ <= 3.0f) { + if (this->animationIdx != ENHORSE_ANIM_WALK) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_WALK; + } else if (this->actor.speedXZ <= 6.0f) { + if (this->animationIdx != ENHORSE_ANIM_TROT) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_TROT; + } else { + if (this->animationIdx != ENHORSE_ANIM_GALLOP) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_GALLOP; + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + animSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + animSpeed = this->actor.speedXZ * 0.25f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + func_8013ECE0(0.0f, 60, 8, 255); + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + animSpeed = this->actor.speedXZ * 0.2f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + func_8013ECE0(0.0f, 120, 8, 255); + } else { + animSpeed = 1.0f; + } + + if (animChanged == true) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void EnHorse_UpdateHorsebackArchery(EnHorse* this, GlobalContext* globalCtx) { + f32 playSpeed; + s32 sp28; + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + EnHorse_PlayWalkingSound(this); + } + + if (globalCtx->interfaceCtx.hbaAmmo == 0) { + this->hbaTimer++; + } + + sp28 = Audio_IsSequencePlaying(0x41); + EnHorse_UpdateHbaRaceInfo(this, globalCtx, &sHbaInfo); + + if (((this->hbaFlags & 1) || (this->hbaTimer > 45)) && (sp28 != 1) && (gSaveContext.minigameState != 3)) { + gSaveContext.save.cutscene = 0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 0x40; + } + + if (globalCtx->interfaceCtx.hbaAmmo) {} + + if (((globalCtx->interfaceCtx.hbaAmmo == 0) || (this->hbaFlags & 2)) && (this->hbaFlags & 4)) { + this->hbaFlags &= ~4; + Audio_QueueSeqCmd(0x8041); + } + + if (this->hbaStarted == 0) { + this->actor.speedXZ = 0.0f; + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + EnHorse_UpdateHbaAnim(this); + } + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + playSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + playSpeed = this->actor.speedXZ * 0.25f; + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + playSpeed = this->actor.speedXZ * 0.2f; + } else { + playSpeed = 1.0f; + } + this->skin.skelAnime.playSpeed = playSpeed; + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { + EnHorse_UpdateHbaAnim(this); + } +} + +#ifdef NON_MATCHING +void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 distToHome; + f32 playerDistToHome; + f32 distToPlayer; + s32 nextAnim; + s32 animFinished; + s16 yaw; + + if ((D_801BDAA4 != 0) || (this->type == HORSE_HNI)) { + EnHorse_StartIdleRidable(this); + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_NEIGH); + } + } + + distToHome = Math3D_Distance(&this->actor.home.pos, &this->actor.world.pos); + playerDistToHome = Math3D_Distance(&player->actor.world.pos, &this->actor.home.pos); + distToPlayer = Math3D_Distance(&player->actor.world.pos, &this->actor.world.pos); + + if (playerDistToHome > 300.0f) { + if (distToHome > 150.0f) { + this->actor.speedXZ += 0.4f; + if (this->actor.speedXZ > 8.0f) { + this->actor.speedXZ = 8.0f; + } + } else { + this->actor.speedXZ -= 0.5f; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + } + } else if (distToPlayer < 300.0f) { + this->actor.speedXZ += 0.4f; + if (this->actor.speedXZ > 8.0f) { + this->actor.speedXZ = 8.0f; + } + } else { + this->actor.speedXZ -= 0.5f; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + } + + if (this->actor.speedXZ >= 6.0f) { + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + nextAnim = ENHORSE_ANIM_GALLOP; + } else if (this->actor.speedXZ >= 3.0f) { + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; + nextAnim = ENHORSE_ANIM_TROT; + } else if (this->actor.speedXZ > 0.1f) { + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; + nextAnim = ENHORSE_ANIM_WALK; + EnHorse_PlayWalkingSound(this); + } else { + if (Rand_ZeroOne() > 0.5f) { + nextAnim = ENHORSE_ANIM_WHINNEY; + } else { + nextAnim = ENHORSE_ANIM_IDLE; + } + EnHorse_IdleAnimSounds(this, globalCtx); + this->skin.skelAnime.playSpeed = 1.0f; + } + + if ((nextAnim == ENHORSE_ANIM_GALLOP) || (nextAnim == ENHORSE_ANIM_TROT) || (nextAnim == ENHORSE_ANIM_WALK)) { + if (playerDistToHome < 300.0f) { + yaw = player->actor.shape.rot.y; + yaw += ((Actor_YawBetweenActors(&this->actor, &player->actor) > 0) ? 1 : -1) * 0x3FFF; + } else { + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos) - this->actor.world.rot.y; + } + + if (yaw > 800.0f) { + this->actor.world.rot.y += 0x320; + } else if (yaw < -800.0f) { + this->actor.world.rot.y += -0x320; + } else { + this->actor.world.rot.y += yaw; + } + this->actor.shape.rot.y = this->actor.world.rot.y; + } + + animFinished = SkelAnime_Update(&this->skin.skelAnime); + + if (((this->animationIdx == ENHORSE_ANIM_IDLE) || (this->animationIdx == ENHORSE_ANIM_WHINNEY)) && + ((nextAnim == ENHORSE_ANIM_GALLOP) || (nextAnim == ENHORSE_ANIM_TROT) || (nextAnim == ENHORSE_ANIM_WALK))) { + this->animationIdx = nextAnim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][nextAnim]), ANIMMODE_ONCE, -3.0f); + if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + func_8087C1C0(this); + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + func_8087C178(this); + } + } else if (animFinished) { + if (nextAnim == ENHORSE_ANIM_GALLOP) { + func_8087C1C0(this); + } else if (nextAnim == ENHORSE_ANIM_TROT) { + func_8087C178(this); + } + + if ((this->animationIdx == ENHORSE_ANIM_IDLE) || (this->animationIdx == ENHORSE_ANIM_WHINNEY)) { + if (nextAnim != this->animationIdx) { + this->animationIdx = nextAnim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), + ANIMMODE_ONCE, -3.0f); + } else { + if (Rand_ZeroOne() > 0.5f) { + this->animationIdx = ENHORSE_ANIM_IDLE; + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + } else { + this->animationIdx = ENHORSE_ANIM_WHINNEY; + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_GROAN); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_GROAN); + } + } + } + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), + ANIMMODE_ONCE, -3.0f); + } + } else if (nextAnim != this->animationIdx) { + this->animationIdx = nextAnim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } + } else if ((this->animationIdx == ENHORSE_ANIM_WALK) && + ((nextAnim == ENHORSE_ANIM_IDLE) || (nextAnim == ENHORSE_ANIM_WHINNEY))) { + this->animationIdx = nextAnim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } +} +#else +void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_FleePlayer.s") +#endif + +void func_80883B70(EnHorse* this, CsCmdActorAction* action) { + this->actor.world.pos.x = action->startPos.x; + this->actor.world.pos.y = action->startPos.y; + this->actor.world.pos.z = action->startPos.z; + + this->actor.world.rot.y = action->urot.y; + this->actor.shape.rot = this->actor.world.rot; + + this->actor.prevPos = this->actor.world.pos; +} + +void func_80883BEC(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->animationIdx = ENHORSE_ANIM_IDLE; + this->unk_3E0 = 1; + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, 0.0f); + this->stateFlags |= ENHORSE_SANDDUST_SOUND; +} + +void func_80883CB0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + EnHorse_IdleAnimSounds(this, globalCtx); + if (SkelAnime_Update(&this->skin.skelAnime)) { + this->animationIdx = ENHORSE_ANIM_IDLE; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void func_80883D64(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 2; + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00A8DC, 0.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00A8DC), ANIMMODE_ONCE, 0.0f); +} + +void func_80883DE0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + SkelAnime_Update(&this->skin.skelAnime); +} + +void func_80883E10(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 3; + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00A8DC, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00A8DC), ANIMMODE_ONCE, -3.0f); + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); +} + +void func_80883EA0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00B3E0, 1.0f, 11.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00B3E0), ANIMMODE_ONCE, 0.0f); + } +} + +void func_80883F18(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 4; + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00AD08, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00AD08), ANIMMODE_ONCE, -3.0f); +} + +void func_80883F98(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + if (Animation_OnFrame(&this->skin.skelAnime, Animation_GetLastFrame(&object_horse_link_child_Anim_00AD08) - 1.0f)) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + SkelAnime_Update(&this->skin.skelAnime); +} + +void func_80884010(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 5; + this->animationIdx = ENHORSE_ANIM_WALK; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void func_808840C4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + EnHorse_PlayWalkingSound(this); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void func_80884194(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 6; + this->animationIdx = ENHORSE_ANIM_GALLOP; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + func_8087C1C0(this); +} + +void func_8088424C(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + func_8087C1C0(this); + } +} + +void func_80884314(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 20.0f); + func_80883B70(this, action); + this->unk_3E0 = 7; + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00D178, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00D178), ANIMMODE_ONCE, 0.0f); + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); +} + +void func_808843B4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + SkelAnime_Update(&this->skin.skelAnime); + if (this->curFrame > 42.0f) { + if (((s32)this->curFrame % 11) == 0) { + func_8087C1C0(this); + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + } +} + +void func_80884444(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 20.0f); + func_80883B70(this, action); + this->cutsceneAction = 8; + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00D4E8, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00D4E8), ANIMMODE_ONCE, 0.0f); + func_8087C1C0(this); +} + +void func_808844E0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00D4E8, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00D4E8), ANIMMODE_ONCE, 0.0f); + func_8087C1C0(this); + } +} + +void func_80884564(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 20.0f); + func_80883B70(this, action); + this->cutsceneAction = 8; + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00BDE0, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00BDE0), ANIMMODE_ONCE, -3.0f); + func_8087C1C0(this); +} + +void func_80884604(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, &object_horse_link_child_Anim_00BDE0, 1.0f, 0.0f, + Animation_GetLastFrame(&object_horse_link_child_Anim_00BDE0), ANIMMODE_ONCE, 0.0f); + } + + if (((s32)this->curFrame % 11) == 0) { + func_8087C1C0(this); + } +} + +void func_808846B4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Actor_MarkForDeath(&this->actor); +} + +void func_808846DC(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +} + +void func_808846F0(EnHorse* this, GlobalContext* globalCtx) { + this->playerControlled = false; + this->action = ENHORSE_ACT_21; + this->unk_3E0 = -1; + this->actor.speedXZ = 0.0f; +} + +void func_80884718(EnHorse* this, GlobalContext* globalCtx) { + CsCmdActorAction* action; + + if (Cutscene_CheckActorAction(globalCtx, 0x70)) { + this->unk_530 = Cutscene_GetActorActionIndex(globalCtx, 0x70); + action = globalCtx->csCtx.actorActions[this->unk_530]; + + this->unk_1EC |= 0x20; + if (this->unk_3E0 != action->action) { + if (this->unk_3E0 == -1) { + this->actor.world.pos.x = action->startPos.x; + this->actor.world.pos.y = action->startPos.y; + this->actor.world.pos.z = action->startPos.z; + + this->actor.world.rot.y = action->urot.y; + this->actor.shape.rot = this->actor.world.rot; + + this->actor.prevPos = this->actor.world.pos; + } + + this->unk_3E0 = action->action; + if (D_808890F0[this->unk_3E0] != NULL) { + D_808890F0[this->unk_3E0](this, globalCtx, action); + } + } + + if (D_8088911C[this->unk_3E0] != NULL) { + D_8088911C[this->unk_3E0](this, globalCtx, action); + } + } +} + +void func_80884868(EnHorse* this) { + this->action = ENHORSE_ACT_23; + this->animationIdx = ENHORSE_ANIM_WALK; + Animation_PlayLoop(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + this->stateFlags |= ENHORSE_UNRIDEABLE; +} + +void func_808848C8(EnHorse* this, GlobalContext* globalCtx) { + Vec3f sp24 = { -1916.0f, -106.0f, -523.0f }; + + EnHorse_PlayWalkingSound(this); + this->actor.speedXZ = 4.0f; + func_800F415C(&this->actor, &sp24, 2000); + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; + SkelAnime_Update(&this->skin.skelAnime); + if (Math3D_Distance(&sp24, &this->actor.world.pos) < 30.0f) { + this->stateFlags &= ~ENHORSE_UNRIDEABLE; + EnHorse_StartIdleRidable(this); + } +} + +void func_80884994(EnHorse* this) { + this->unk_534 = -1; + this->animationIdx = ENHORSE_ANIM_TROT; + this->action = ENHORSE_ACT_24; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 2.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void func_80884A40(EnHorse* this, GlobalContext* globalCtx) { + s32 sp44[] = { 5, 6, 0 }; + s32 sp40; + s32 temp_v0; + + if (this->animationIdx == ENHORSE_ANIM_WHINNEY) { + temp_v0 = 0; + } else { + temp_v0 = this->animationIdx; + } + + sp40 = sp44[this->unk_538] != temp_v0; + + if (SkelAnime_Update(&this->skin.skelAnime) || sp40) { + this->animationIdx = sp44[this->unk_538]; + if ((this->animationIdx == ENHORSE_ANIM_IDLE) && (Rand_ZeroOne() < 0.5f)) { + this->animationIdx = ENHORSE_ANIM_WHINNEY; + } + + if (sp40) { + if (this->animationIdx == ENHORSE_ANIM_IDLE) { + Animation_MorphToPlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 2.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), + ANIMMODE_ONCE, -3.0f); + } + } else if (this->animationIdx == ENHORSE_ANIM_IDLE) { + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 2.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } + + if ((this->unk_538 == 0) || (this->unk_538 == 1)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HORSE_RUN); + } else if (this->unk_538 == 2) { + if (this->animationIdx == ENHORSE_ANIM_IDLE) { + EnHorse_IdleAnimSounds(this, globalCtx); + } else if (this->animationIdx == ENHORSE_ANIM_WHINNEY) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HORSE_GROAN); + } + } + } +} + +void func_80884D04(EnHorse* this, GlobalContext* globalCtx) { + f32 playSpeed; + + this->actor.speedXZ = 10.0f; + this->action = ENHORSE_ACT_25; + this->unk_540 = this->actor.world.pos; + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_INGO_HORSE_NEIGH); + this->animationIdx = ENHORSE_ANIM_GALLOP; + playSpeed = this->actor.speedXZ * 0.2f; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * playSpeed * 2.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, 0.0f); +} + +void func_80884E0C(EnHorse* this, GlobalContext* globalCtx) { + f32 playSpeed = (this->unk_56C * 0.2f * 0.5f) + 1.0f; + Vec3f pos; + CollisionPoly* sp3C; + + this->skin.skelAnime.playSpeed = playSpeed; + + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * playSpeed * 2.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + + this->unk_57C = this->actor.world.pos; + this->actor.world.pos.x = this->unk_570.x; + this->actor.world.pos.z = this->unk_570.z; + + this->unk_56C = Math3D_Distance(&this->actor.world.pos, &this->actor.prevPos); + if (((this->unk_550 == 5) || (this->unk_550 == 7)) && (Player_GetMask(globalCtx) != PLAYER_MASK_CIRCUS_LEADER)) { + this->rider->unk488 = 7; + } else { + EnHorse_SetIngoAnimation(this->animationIdx, this->skin.skelAnime.curFrame, this->unk_394 & 1, + &this->rider->unk488); + } + + pos = this->actor.world.pos; + pos.y += 10.0f; + + if (BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp3C, &pos) != BGCHECK_Y_MIN) { + this->actor.velocity.y += this->actor.gravity; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } + this->actor.world.pos.y += this->actor.velocity.y * 0.5f; + } else { + this->actor.world.pos.y = this->unk_570.y; + } +} + +void EnHorse_Vec3fOffset(Vec3f* src, s16 yaw, f32 dist, f32 height, Vec3f* dst) { + dst->x = (Math_SinS(yaw) * dist) + src->x; + dst->y = src->y + height; + dst->z = (Math_CosS(yaw) * dist) + src->z; +} + +s32 EnHorse_CalcFloorHeight(EnHorse* this, GlobalContext* globalCtx, Vec3f* pos, CollisionPoly** polyFloor, + f32* floorHeight, s32* bgId) { + f32 waterY; + WaterBox* waterbox; + + *polyFloor = NULL; + *floorHeight = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, polyFloor, bgId, pos); + if (*floorHeight == BGCHECK_Y_MIN) { + return 1; // No floor + } + + if ((WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, pos->x, pos->z, &waterY, &waterbox) == 1) && + (*floorHeight < waterY)) { + return 2; // Water + } + + if ((COLPOLY_GET_NORMAL((*polyFloor)->normal.y) < 0.81915206f) || + SurfaceType_IsHorseBlocked(&globalCtx->colCtx, *polyFloor, *bgId) || + (func_800C99D4(&globalCtx->colCtx, *polyFloor, *bgId) == 7)) { + return 3; // Horse blocked surface + } + + return 0; +} + +/** + * obstacleType: + * 1: Water in front + * 2: Water behind? + * 3: ? + * 4: Obstructed in front + * 5: Obstructed behind + */ +void EnHorse_ObstructMovement(EnHorse* this, GlobalContext* globalCtx, s32 obstacleType, s32 galloping) { + if (this->action != ENHORSE_ACT_HBA) { + if ((this->action == ENHORSE_ACT_MOUNTED_IDLE) || (this->action == ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING)) { + this->actor.world.pos = this->actor.prevPos; + this->actor.world.rot.y -= 0x640; + this->actor.speedXZ = 0.0f; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->unk_1EC |= 4; + } else if (this->action == ENHORSE_ACT_25) { + this->unk_1EC |= 0x80; + this->actor.world.pos = this->actor.prevPos; + this->actor.speedXZ = 0.0f; + } else if ((globalCtx->sceneNum != SCENE_KOEPONARACE) || (this->unk_1EC & 2)) { + this->unk_1EC &= ~2; + this->actor.world.pos = this->lastPos; + this->stateFlags |= ENHORSE_OBSTACLE; + if (this->playerControlled == 0) { + if (this->animationIdx != 3) {} + } else if (this->action != ENHORSE_ACT_REVERSE) { + if (this->stateFlags & ENHORSE_JUMPING) { + this->stateFlags &= ~ENHORSE_JUMPING; + this->actor.gravity = -3.5f; + this->actor.world.pos.y = this->actor.floorHeight; + } + + if ((obstacleType == 1) || (obstacleType == 4)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + } else if ((obstacleType == 2) || (obstacleType == 5)) { + this->stateFlags |= ENHORSE_FORCE_WALKING; + } + + if (galloping == true) { + EnHorse_StartRearing(this); + } + } + } + } +} + +void EnHorse_CheckFloors(EnHorse* this, GlobalContext* globalCtx) { + s32 pad; + CollisionPoly* frontFloor; + CollisionPoly* backFloor; + s32 bgId; + s16 floorSlope; + Vec3f frontPos; + Vec3f backPos; + Vec3f pos; + f32 nx; + f32 ny; + f32 nz; + s32 galloping = this->actor.speedXZ > 8.0f; + s32 status; + f32 waterHeight; + WaterBox* waterbox; + f32 dist; + + if ((WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterHeight, &waterbox) == true) && + (this->actor.floorHeight < waterHeight)) { + EnHorse_ObstructMovement(this, globalCtx, 1, galloping); + return; + } + + if (this->type != HORSE_2) { + EnHorse_Vec3fOffset(&this->actor.world.pos, this->actor.shape.rot.y, 30.0f, 55.0f, &frontPos); + } else { + EnHorse_Vec3fOffset(&this->actor.world.pos, this->actor.shape.rot.y, 15.0f, 30.0f, &frontPos); + } + + status = EnHorse_CalcFloorHeight(this, globalCtx, &frontPos, &frontFloor, &this->yFront, &this->unk_24C); + if (status == 1) { + this->actor.shape.rot.x = 0; + EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + return; + } + + if (status == 3) { + this->unk_1EC |= 2; + EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + return; + } + + if (this->type != HORSE_2) { + EnHorse_Vec3fOffset(&this->actor.world.pos, this->actor.shape.rot.y, -30.0f, 55.0f, &backPos); + } else { + EnHorse_Vec3fOffset(&this->actor.world.pos, this->actor.shape.rot.y, -15.0f, 30.0f, &backPos); + } + + status = EnHorse_CalcFloorHeight(this, globalCtx, &backPos, &backFloor, &this->yBack, &bgId); + if (status == 1) { + this->actor.shape.rot.x = 0; + EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + return; + } + + if (status == 3) { + this->unk_1EC |= 2; + EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + return; + } + + floorSlope = Math_Atan2S(this->yBack - this->yFront, 60.0f); + if (this->actor.floorPoly != NULL) { + nx = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.x); + ny = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); + nz = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); + + pos = frontPos; + pos.y = this->yFront; + + dist = Math3D_DistPlaneToPos(nx, ny, nz, this->actor.floorPoly->dist, &pos); + if ((frontFloor != this->actor.floorPoly) && (this->actor.speedXZ >= 0.0f) && + ((!(this->stateFlags & ENHORSE_JUMPING) && (dist < -40.0f)) || + ((this->stateFlags & ENHORSE_JUMPING) && (dist < -200.0f)))) { + EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + return; + } + + pos = backPos; + pos.y = this->yBack; + + dist = Math3D_DistPlaneToPos(nx, ny, nz, this->actor.floorPoly->dist, &pos); + if ((backFloor != this->actor.floorPoly) && (this->actor.speedXZ <= 0.0f) && + ((!(this->stateFlags & ENHORSE_JUMPING) && (dist < -40.0f)) || + ((this->stateFlags & ENHORSE_JUMPING) && (dist < -200.0f)))) { + EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + return; + } + + if ((ny < 0.81915206f) || + SurfaceType_IsHorseBlocked(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) || + (func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 7)) { + if (this->actor.speedXZ >= 0.0f) { + EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + } else { + EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + } + } else if (this->stateFlags & 4) { + this->actor.shape.rot.x = 0; + } else if ((this->actor.floorHeight + 4.0f) < this->actor.world.pos.y) { + this->actor.shape.rot.x = 0; + } else if (!(fabsf(floorSlope) > 0x1FFF)) { + this->actor.shape.rot.x = floorSlope; + this->actor.shape.yOffset = + ((this->yFront + (((this->yBack - this->yFront) * 20.0f) / 45.0f)) - this->actor.floorHeight) + + this->unk_3E8; + } + } +} + +void EnHorse_MountDismount(EnHorse* this, GlobalContext* globalCtx) { + s32 mountSide = EnHorse_GetMountSide(this, globalCtx); + + if ((mountSide != 0) && !(this->stateFlags & ENHORSE_UNRIDEABLE)) { + Actor_SetRideActor(globalCtx, &this->actor, mountSide); + } + + if ((this->playerControlled == false) && (Actor_HasRider(globalCtx, &this->actor) == true)) { + this->noInputTimer = 26; + this->noInputTimerMax = 26; + this->playerControlled = true; + EnHorse_Freeze(this, globalCtx); + } else if ((this->playerControlled == true) && (Actor_HasNoRider(globalCtx, &this->actor) == true)) { + this->noInputTimer = 35; + this->noInputTimerMax = 35; + this->stateFlags &= ~ENHORSE_UNRIDEABLE; + this->playerControlled = false; + EnHorse_Freeze(this, globalCtx); + } +} + +void EnHorse_StickDirection(Vec2f* curStick, f32* stickMag, s16* angle) { + *stickMag = sqrtf(SQ(curStick->x) + SQ(curStick->z)); + *stickMag = CLAMP_MAX(*stickMag, 60.0f); + *angle = Math_Atan2S(-curStick->x, curStick->z); +} + +void EnHorse_UpdateStick(EnHorse* this, GlobalContext* globalCtx) { + Input* input = &globalCtx->state.input[this->unk_52C]; + + this->lastStick = this->curStick; + this->curStick.x = input->rel.stick_x; + this->curStick.z = input->rel.stick_y; +} + +void EnHorse_ResolveCollision(EnHorse* this, GlobalContext* globalCtx, CollisionPoly* colPoly) { + f32 dist; + f32 nx; + f32 ny; + f32 nz; + f32 offset; + + nx = COLPOLY_GET_NORMAL(colPoly->normal.x); + ny = COLPOLY_GET_NORMAL(colPoly->normal.y); + nz = COLPOLY_GET_NORMAL(colPoly->normal.z); + + if (!(Math_CosS(BINANG_ROT180(this->actor.world.rot.y - Math_Atan2S(colPoly->normal.x, colPoly->normal.z))) < + 0.7071f)) { // cos(45 degrees) + dist = Math3D_DistPlaneToPos(nx, ny, nz, colPoly->dist, &this->actor.world.pos); + offset = (1.0f / sqrtf(SQ(nx) + SQ(nz))); + offset = (30.0f - dist) * offset; + this->actor.world.pos.x += offset * nx; + this->actor.world.pos.z += offset * nz; + } +} + +void EnHorse_BgCheckSlowMoving(EnHorse* this, GlobalContext* globalCtx) { + f32 yOffset = 40.0f; + Vec3f start; + Vec3f end; + Vec3f intersect; + CollisionPoly* colPoly; + s32 bgId; + + Math_Vec3f_Copy(&start, &this->actor.world.pos); + start.y += yOffset; + + Math_Vec3f_Copy(&end, &start); + end.x += 30.0f * Math_SinS(this->actor.world.rot.y); + end.y += 30.0f * Math_SinS(-this->actor.shape.rot.x); + end.z += 30.0f * Math_CosS(this->actor.world.rot.y); + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &start, &end, &intersect, &colPoly, true, false, false, true, + &bgId)) { + EnHorse_ResolveCollision(this, globalCtx, colPoly); + } +} + +void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { + s32 pad2[2]; + Vec3f startPos; + Vec3f endPos; + Vec3f obstaclePos; + f32 temp_f0; + f32 intersectDist; + CollisionPoly* wall = NULL; + CollisionPoly* obstacleFloor = NULL; + s32 bgId; + f32 obstacleHeight; + f32 behindObstacleHeight; + DynaPolyActor* horseJump; + s32 movingFast; + s16 sp7E = 0; + DynaPolyActor* horseGameCheck = NULL; + s32 pad6; + s32 pad; + Vec3f intersect; + Vec3f obstacleTop; + s32 pad5; + s32 pad4; + + if ((this->actor.params != ENHORSE_4) && (this->actor.params != ENHORSE_5) && (this->actor.params != ENHORSE_19) && + (this->actor.params != ENHORSE_20) && (this->actor.params != ENHORSE_18)) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 35.0f, 100.0f, 0x1D); + } else { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 35.0f, 100.0f, 0x1C); + } + + if ((this->actor.bgCheckFlags & 8) && (Math_CosS(this->actor.wallYaw - this->actor.world.rot.y) < -0.3f)) { + if (this->actor.speedXZ > 4.0f) { + this->actor.speedXZ -= 1.0f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } + } + } + + horseJump = DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId); + + if (!(this->stateFlags & ENHORSE_JUMPING)) { + if ((horseJump != NULL) && (horseJump->actor.id == ACTOR_EN_HORSE_GAME_CHECK) && + ((horseJump->actor.params & 0xFF) == 5)) { + this->stateFlags |= ENHORSE_FLAG_28; + this->unk_3E8 += ((-10.0f / this->actor.scale.y) - this->unk_3E8) * 0.5f; + if (this->actor.speedXZ > 2.0f) { + this->actor.speedXZ -= 1.0f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } + } + } else { + this->stateFlags &= ~ENHORSE_FLAG_28; + this->unk_3E8 *= 0.5f; + } + } + + if ((this->stateFlags & ENHORSE_JUMPING) || (this->stateFlags & ENHORSE_FLAG_28) || (this->actor.speedXZ < 0.0f) || + (this->action == ENHORSE_ACT_LOW_JUMP) || (this->action == ENHORSE_ACT_REVERSE)) { + return; + } + + if (this->actor.speedXZ > 8.0f) { + if (this->actor.speedXZ < 12.8f) { + intersectDist = 160.0f; + movingFast = false; + } else { + intersectDist = 230.0f; + movingFast = true; + } + } else { + EnHorse_BgCheckSlowMoving(this, globalCtx); + return; + } + + startPos = this->actor.world.pos; + startPos.y += 19.0f; + + endPos = startPos; + endPos.x += intersectDist * Math_SinS(this->actor.world.rot.y); + endPos.y += intersectDist * Math_SinS(-this->actor.shape.rot.x); + endPos.z += intersectDist * Math_CosS(this->actor.world.rot.y); + + intersect = endPos; + wall = NULL; + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &startPos, &endPos, &intersect, &wall, true, false, false, true, + &bgId) == true) { + intersectDist = sqrtf(Math3D_Vec3fDistSq(&startPos, &intersect)); + this->stateFlags |= ENHORSE_OBSTACLE; + } + + if (wall != NULL) { + if (intersectDist < 30.0f) { + EnHorse_ResolveCollision(this, globalCtx, wall); + } + + sp7E = BINANG_ROT180(this->actor.world.rot.y - Math_Atan2S(wall->normal.x, wall->normal.z)); + + if ((Math_CosS(sp7E) < 0.5f) || SurfaceType_IsHorseBlocked(&globalCtx->colCtx, wall, bgId)) { + return; + } + + if (((movingFast == false) && (intersectDist < 80.0f)) || ((movingFast == true) && (intersectDist < 150.0f))) { + if ((globalCtx->sceneNum != SCENE_KOEPONARACE) && (Math_CosS(sp7E) < 0.9f) && + (this->playerControlled == true)) { + if (movingFast == false) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + } else if (movingFast == true) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + } + return; + } + + horseJump = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + if ((this->stateFlags & ENHORSE_FLAG_26) && + (((horseJump != NULL) && (horseJump->actor.id != ACTOR_BG_UMAJUMP)) || (horseJump == NULL))) { + if (this->playerControlled == true) { + if (movingFast == false) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + } else if (movingFast == true) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + } + return; + } + } + + intersectDist += 5.0f; + obstaclePos = startPos; + + obstaclePos.x += intersectDist * Math_SinS(this->actor.world.rot.y); + obstaclePos.y = this->actor.world.pos.y + 120.0f; + obstaclePos.z += intersectDist * Math_CosS(this->actor.world.rot.y); + + obstacleTop = obstaclePos; + obstacleTop.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &obstacleFloor, &bgId, &obstaclePos); + + if (obstacleTop.y == BGCHECK_Y_MIN) { + return; + } + + obstacleHeight = obstacleTop.y - this->actor.world.pos.y; + + if ((this->actor.floorPoly == NULL) || (obstacleFloor == NULL)) { + return; + } + + if ((Math3D_DistPlaneToPos(COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.x), + COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y), + COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z), this->actor.floorPoly->dist, + &obstacleTop) < -40.0f) && + (Math3D_DistPlaneToPos(COLPOLY_GET_NORMAL(obstacleFloor->normal.x), COLPOLY_GET_NORMAL(obstacleFloor->normal.y), + COLPOLY_GET_NORMAL(obstacleFloor->normal.z), obstacleFloor->dist, + &this->actor.world.pos) > 40.0f)) { + if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACT_LOW_JUMP) && + (globalCtx->sceneNum != SCENE_KOEPONARACE)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + this->stateFlags |= ENHORSE_OBSTACLE; + return; + } + + temp_f0 = COLPOLY_GET_NORMAL(obstacleFloor->normal.y); + if ((temp_f0 < 0.81915206f) || SurfaceType_IsHorseBlocked(&globalCtx->colCtx, obstacleFloor, bgId) || + (func_800C99D4(&globalCtx->colCtx, obstacleFloor, bgId) == 7)) { + if ((Math_CosS(sp7E) < 0.9f) && (movingFast == true) && (this->playerControlled == true) && + (this->action != ENHORSE_ACT_LOW_JUMP) && (globalCtx->sceneNum != SCENE_KOEPONARACE)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + return; + } + + if (wall == NULL) { + horseGameCheck = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + if ((horseGameCheck == NULL) || (horseGameCheck->actor.id != ACTOR_EN_HORSE_GAME_CHECK) || + ((horseGameCheck->actor.params & 0xFF) != 5)) { + return; + } + } + + if (((obstacleTop.y < intersect.y) && + ((horseGameCheck == NULL) || (horseGameCheck->actor.id != ACTOR_EN_HORSE_GAME_CHECK) || + ((horseGameCheck->actor.params & 0xFF) != 5))) || + ((this->stateFlags & ENHORSE_CANT_JUMP) && (this->action != ENHORSE_ACT_MOUNTED_IDLE))) { + return; + } + + if ((this->action == ENHORSE_ACT_MOUNTED_IDLE) && !(this->stateFlags & ENHORSE_FLAG_30)) { + horseGameCheck = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + if ((horseGameCheck != NULL) && (horseGameCheck->actor.id == ACTOR_EN_HORSE_GAME_CHECK) && + ((horseGameCheck->actor.params & 0xFF) == 5)) { + this->stateFlags |= ENHORSE_FLAG_30; + this->postDrawFunc = func_8088126C; + } + } + + if (this->playerControlled == false) { + return; + } + + obstaclePos = startPos; + obstaclePos.y = this->actor.world.pos.y + 120.0f; + + if (movingFast == false) { + obstaclePos.x += 276.0f * Math_SinS(this->actor.world.rot.y); + obstaclePos.z += 276.0f * Math_CosS(this->actor.world.rot.y); + } else { + obstaclePos.x += 390.0f * Math_SinS(this->actor.world.rot.y); + obstaclePos.z += 390.0f * Math_CosS(this->actor.world.rot.y); + } + + obstacleTop = obstaclePos; + obstacleTop.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &obstacleFloor, &bgId, &obstaclePos); + + if (obstacleTop.y == BGCHECK_Y_MIN) { + return; + } + + behindObstacleHeight = obstacleTop.y - this->actor.world.pos.y; + + if (obstacleFloor == NULL) { + return; + } + + temp_f0 = COLPOLY_GET_NORMAL(obstacleFloor->normal.y); + if ((temp_f0 < 0.81915206f) || SurfaceType_IsHorseBlocked(&globalCtx->colCtx, obstacleFloor, bgId) || + (func_800C99D4(&globalCtx->colCtx, obstacleFloor, bgId) == 7)) { + if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACT_LOW_JUMP) && + (globalCtx->sceneNum != SCENE_KOEPONARACE)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + } else if (behindObstacleHeight < -70.0f) { + if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACT_LOW_JUMP) && + (globalCtx->sceneNum != SCENE_KOEPONARACE)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + } else { + temp_f0 = (this->actor.scale.y * 100.0f); + + if ((horseGameCheck == NULL) || (horseGameCheck->actor.id != ACTOR_EN_HORSE_GAME_CHECK) || + ((horseGameCheck->actor.params & 0xFF) != 5)) { + if ((movingFast == false) && ((19.0f * temp_f0) < obstacleHeight) && + (obstacleHeight <= (40.0f * temp_f0))) { + EnHorse_Stub1(this); + this->postDrawFunc = EnHorse_LowJumpInit; + } else if ((movingFast == true) && + (((this->actor.speedXZ < 13.8f) && ((19.0f * temp_f0) < obstacleHeight) && + (obstacleHeight <= (72.0f * temp_f0))) || + ((this->actor.speedXZ > 13.8f) && (obstacleHeight <= (112.0f * temp_f0))))) { + EnHorse_Stub2(this); + this->postDrawFunc = EnHorse_HighJumpInit; + } + } else if (movingFast == false) { + EnHorse_Stub1(this); + this->postDrawFunc = EnHorse_LowJumpInit; + } else if (movingFast == true) { + EnHorse_Stub2(this); + this->postDrawFunc = EnHorse_HighJumpInit; + } + } +} + +void func_80886C00(EnHorse* this, GlobalContext* globalCtx) { + Input* input = &globalCtx->state.input[this->unk_52C]; + + if (((this->action == ENHORSE_ACT_MOUNTED_GALLOP) || (this->action == ENHORSE_ACT_MOUNTED_REARING) || + (this->action == ENHORSE_ACT_STOPPING)) && + (CHECK_BTN_ALL(input->press.button, BTN_A) || (func_801A5100() == 5)) && + (globalCtx->interfaceCtx.unk_212 == 8) && !(this->stateFlags & ENHORSE_BOOST) && + !(this->stateFlags & ENHORSE_FLAG_8) && !(this->stateFlags & ENHORSE_FLAG_9)) { + if (this->numBoosts > 0) { + func_8013ECE0(0.0f, 180, 20, 100); + this->stateFlags |= ENHORSE_BOOST; + this->stateFlags |= ENHORSE_FIRST_BOOST_REGEN; + this->stateFlags |= ENHORSE_FLAG_8; + this->numBoosts--; + this->boostTimer = 0; + if (this->numBoosts == 0) { + this->boostRegenTime = 140; + } else if (this->type == HORSE_EPONA) { + if (this->stateFlags & ENHORSE_FIRST_BOOST_REGEN) { + this->boostRegenTime = 60; + this->stateFlags &= ~ENHORSE_FIRST_BOOST_REGEN; + } else { + this->boostRegenTime = 8; + } + } else { + this->boostRegenTime = 70; + } + } else if ((this->stateFlags & ENHORSE_DRAW) && (Rand_ZeroOne() < 0.1f)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + } +} + +void EnHorse_RegenBoost(EnHorse* this, GlobalContext* globalCtx) { + s32 playSfx; + + if ((this->numBoosts < 6) && (this->numBoosts > 0)) { + this->boostRegenTime--; + this->boostTimer++; + if (this->boostRegenTime <= 0) { + this->numBoosts++; + if (((this->action == ENHORSE_ACT_MOUNTED_TURN) || (this->action == ENHORSE_ACT_FROZEN) || + (this->action == ENHORSE_ACT_MOUNTED_WALK)) && + !(this->stateFlags & ENHORSE_FLAG_19) && !(this->stateFlags & ENHORSE_FLAG_25)) { + playSfx = true; + } else { + playSfx = false; + } + + if (!playSfx) { + play_sound(NA_SE_SY_CARROT_RECOVER); + } + + if (this->numBoosts < 6) { + this->boostRegenTime = 11; + } + } + } else if (this->numBoosts == 0) { + this->boostRegenTime--; + this->boostTimer++; + if (this->boostRegenTime <= 0) { + this->boostRegenTime = 0; + this->numBoosts = 6; + if (((this->action == ENHORSE_ACT_MOUNTED_TURN) || (this->action == ENHORSE_ACT_FROZEN) || + (this->action == ENHORSE_ACT_MOUNTED_WALK)) && + !(this->stateFlags & ENHORSE_FLAG_19) && !(this->stateFlags & ENHORSE_FLAG_25)) { + playSfx = true; + } else { + playSfx = false; + } + + if (!playSfx) { + play_sound(NA_SE_SY_CARROT_RECOVER); + } + } + } + + if (this->boostTimer == 8) { + if ((Rand_ZeroOne() < 0.25f) && (this->stateFlags & ENHORSE_DRAW)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + } + + globalCtx->interfaceCtx.numHorseBoosts = this->numBoosts; +} + +void EnHorse_UpdatePlayerDir(EnHorse* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 angle = Actor_YawBetweenActors(&this->actor, &player->actor) - this->actor.world.rot.y; + f32 s = Math_SinS(angle); + f32 c = Math_CosS(angle); + + if (s > 0.8660254f) { // sin(60 degrees) + this->playerDir = PLAYER_DIR_SIDE_L; + } else if (s < -0.8660254f) { // -sin(60 degrees) + this->playerDir = PLAYER_DIR_SIDE_R; + } else if (c > 0.0f) { + if (s > 0.0f) { + this->playerDir = PLAYER_DIR_FRONT_L; + } else { + this->playerDir = PLAYER_DIR_FRONT_R; + } + } else if (s > 0.0f) { + this->playerDir = PLAYER_DIR_BACK_L; + } else { + this->playerDir = PLAYER_DIR_BACK_R; + } +} + +void EnHorse_TiltBody(EnHorse* this, GlobalContext* globalCtx) { + f32 speed; + f32 rollDiff; + s32 targetRoll; + s16 turnVel; + + speed = this->actor.speedXZ / this->boostSpeed; + turnVel = this->actor.shape.rot.y - this->lastYaw; + targetRoll = -((s16)((2730.0f * speed) * (turnVel / 960.00006f))); + rollDiff = targetRoll - this->actor.world.rot.z; + + if (fabsf(targetRoll) < 100.0f) { + this->actor.world.rot.z = 0; + } else if (fabsf(rollDiff) < 100.0f) { + this->actor.world.rot.z = targetRoll; + } else if (rollDiff > 0.0f) { + this->actor.world.rot.z += 0x64; + } else { + this->actor.world.rot.z -= 0x64; + } + + this->actor.shape.rot.z = this->actor.world.rot.z; +} + +s32 EnHorse_UpdateConveyors(EnHorse* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 conveyorDir; + + if ((this->actor.floorPoly == NULL) || (&this->actor != player->rideActor) || + !SurfaceType_GetConveyorSpeed(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + return false; + } + + conveyorDir = SurfaceType_GetConveyorDirection(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + conveyorDir = (conveyorDir * 0x400) - this->actor.world.rot.y; + if (conveyorDir > 0x640) { + this->actor.world.rot.y += 0x640; + } else if (conveyorDir < -0x640) { + this->actor.world.rot.y -= 0x640; + } else { + this->actor.world.rot.y += conveyorDir; + } + this->actor.shape.rot.y = this->actor.world.rot.y; + return true; +} + +s32 EnHorse_RandInt(f32 arg0) { + return Rand_ZeroOne() * arg0; +} + +#ifdef NON_MATCHING +void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { + static EnHorseActionFunc sActionFuncs[] = { + EnHorse_Frozen, + EnHorse_Inactive, + EnHorse_Idle, + EnHorse_FollowPlayer, + EnHorse_UpdateIngoRace, + func_808819D8, + func_80881398, + EnHorse_MountedIdle, + EnHorse_MountedIdleWhinneying, + EnHorse_MountedTurn, + EnHorse_MountedWalk, + EnHorse_MountedTrot, + EnHorse_MountedGallop, + EnHorse_MountedRearing, + EnHorse_Stopping, + EnHorse_Reverse, + EnHorse_LowJump, + EnHorse_HighJump, + EnHorse_CutsceneUpdate, + EnHorse_UpdateHorsebackArchery, + EnHorse_FleePlayer, + func_80884718, + func_8087CA04, + func_808848C8, + func_80884A40, + func_80884E0C, + }; + s32 pad; + EnHorse* this = THIS; + Vec3f dustAcc = { 0.0f, 0.0f, 0.0f }; + Vec3f dustVel = { 0.0f, 1.0f, 0.0f }; + Player* player = GET_PLAYER(globalCtx); + + if (this->type == HORSE_2) { + Actor_SetScale(&this->actor, 0.00648f); + } else if (this->type == HORSE_4) { + Actor_SetScale(&this->actor, 0.008f); + } else { + Actor_SetScale(&this->actor, 0.01f); + } + + this->lastYaw = this->actor.shape.rot.y; + EnHorse_UpdateStick(this, globalCtx); + EnHorse_UpdatePlayerDir(this, globalCtx); + + if (!(this->stateFlags & ENHORSE_INACTIVE)) { + EnHorse_MountDismount(this, globalCtx); + } + + if (this->stateFlags & ENHORSE_FLAG_19) { + if ((this->stateFlags & ENHORSE_FLAG_20) && (this->inRace == true)) { + this->stateFlags &= ~ENHORSE_FLAG_20; + EnHorse_StartRearing(this); + } else if (!(this->stateFlags & ENHORSE_FLAG_20) && (this->stateFlags & ENHORSE_FLAG_21) && + (this->action != ENHORSE_ACT_REVERSE) && (this->inRace == true)) { + this->stateFlags &= ~ENHORSE_FLAG_21; + EnHorse_StartRearing(this); + } + } + + sActionFuncs[this->action](this, globalCtx); + + this->stateFlags &= ~ENHORSE_OBSTACLE; + this->unk_3EC = this->actor.world.rot.y; + if ((this->animationIdx == ENHORSE_ANIM_STOPPING) || (this->animationIdx == ENHORSE_ANIM_REARING)) { + this->skin.skelAnime.jointTable[0].y += 0x154; + } + + this->curFrame = this->skin.skelAnime.curFrame; + this->lastPos = this->actor.world.pos; + + if (!(this->stateFlags & ENHORSE_INACTIVE)) { + if ((this->action == ENHORSE_ACT_STOPPING) || (this->action == ENHORSE_ACT_MOUNTED_REARING) || + (this->action == ENHORSE_ACT_MOUNTED_GALLOP)) { + func_80886C00(this, globalCtx); + } + + if (this->playerControlled == true) { + EnHorse_RegenBoost(this, globalCtx); + } + + if (ActorCutscene_GetCurrentIndex() != -1) { + this->actor.speedXZ = 0.0f; + } + + if (this->action != ENHORSE_ACT_25) { + Actor_MoveWithGravity(&this->actor); + } + + if (this->rider != NULL) { + if ((this->action == ENHORSE_ACT_INGO_RACE) || (this->action == ENHORSE_ACT_MOUNTED_IDLE) || + (this->action == ENHORSE_ACT_25)) { + this->rider->actor.world.pos.x = this->actor.world.pos.x; + this->rider->actor.world.pos.y = this->actor.world.pos.y + 10.0f; + this->rider->actor.world.pos.z = this->actor.world.pos.z; + this->rider->actor.shape.rot.x = this->actor.shape.rot.x; + this->rider->actor.shape.rot.y = this->actor.shape.rot.y; + } else if (this->action == ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING) { + EnIn* in = this->rider; + s16 jnt = in->jointTable[0].y; + + in->actor.world.pos.x = this->riderPos.x; + in->actor.world.pos.y = this->riderPos.y - (jnt * 0.01f * this->unk_528 * 0.01f); + in->actor.world.pos.z = this->riderPos.z; + in->actor.shape.rot.x = this->actor.shape.rot.x; + in->actor.shape.rot.y = this->actor.shape.rot.y; + } + } + + if (this->colliderJntSph.elements->info.ocElemFlags & OCELEM_HIT) { + if (this->actor.speedXZ > 10.0f) { + this->actor.speedXZ -= 1.0f; + } + } + + if ((this->colliderJntSph.base.acFlags & AC_HIT) && (this->stateFlags & ENHORSE_DRAW)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + + if ((this->action != ENHORSE_ACT_INGO_RACE) && (this->action != ENHORSE_ACT_MOUNTED_IDLE) && + (this->action != ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING)) { + EnHorse_TiltBody(this, globalCtx); + } + + if ((this->playerControlled == false) && (this->unk_1EC & 8)) { + if ((this->colliderJntSph.elements->info.ocElemFlags & OCELEM_HIT) && + (this->colliderJntSph.base.oc->id == ACTOR_EN_IN)) { + func_80884868(this); + } + + if ((this->colliderCylinder1.base.ocFlags1 & OC1_HIT) && + (this->colliderCylinder1.base.oc->id == ACTOR_EN_IN)) { + func_80884868(this); + } + + if ((this->colliderCylinder2.base.ocFlags1 & OC1_HIT) && + (this->colliderCylinder2.base.oc->id == ACTOR_EN_IN)) { + func_80884868(this); + } + } + + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder1); + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder2); + + if (this->type == HORSE_2) { + this->colliderCylinder1.dim.pos.x = + (s16)(Math_SinS(this->actor.shape.rot.y) * 11.0f) + this->colliderCylinder1.dim.pos.x; + this->colliderCylinder1.dim.pos.z = + (s16)(Math_CosS(this->actor.shape.rot.y) * 11.0f) + this->colliderCylinder1.dim.pos.z; + this->colliderCylinder2.dim.pos.x = + (s16)(Math_SinS(this->actor.shape.rot.y) * -18.0f) + this->colliderCylinder2.dim.pos.x; + this->colliderCylinder2.dim.pos.z = + (s16)(Math_CosS(this->actor.shape.rot.y) * -18.0f) + this->colliderCylinder2.dim.pos.z; + } else { + this->colliderCylinder1.dim.pos.x = + (s16)(Math_SinS(this->actor.shape.rot.y) * 6.6000004f) + this->colliderCylinder1.dim.pos.x; + this->colliderCylinder1.dim.pos.z = + (s16)(Math_CosS(this->actor.shape.rot.y) * 6.6000004f) + this->colliderCylinder1.dim.pos.z; + this->colliderCylinder2.dim.pos.x = + (s16)(Math_SinS(this->actor.shape.rot.y) * -10.8f) + this->colliderCylinder2.dim.pos.x; + this->colliderCylinder2.dim.pos.z = + (s16)(Math_CosS(this->actor.shape.rot.y) * -10.8f) + this->colliderCylinder2.dim.pos.z; + } + + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder1.base); + if (!(this->stateFlags & ENHORSE_JUMPING) && !(this->unk_1EC & 0x20)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder1.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder2.base); + } else { + this->unk_1EC &= ~0x20; + } + + if (this->unk_1EC & 0x100) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder2.base); + } + + if ((player->stateFlags1 & ENHORSE_BOOST) && (player->rideActor != NULL)) { + EnHorse_UpdateConveyors(this, globalCtx); + } + + EnHorse_UpdateBgCheckInfo(this, globalCtx); + EnHorse_CheckFloors(this, globalCtx); + if (this->actor.world.pos.y < this->yFront) { + if (this->actor.world.pos.y < this->yBack) { + if (this->yBack < this->yFront) { + this->actor.world.pos.y = this->yBack; + } else { + this->actor.world.pos.y = this->yFront; + } + } + } + + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 70.0f; + + if ((Rand_ZeroOne() < 0.025f) && (this->blinkTimer == 0)) { + this->blinkTimer++; + } else if (this->blinkTimer > 0) { + this->blinkTimer++; + if (this->blinkTimer > 3) { + this->blinkTimer = 0; + } + } + + if ((this->actor.speedXZ == 0.0f) && !(this->stateFlags & ENHORSE_FLAG_19)) { + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + } else { + this->actor.colChkInfo.mass = MASS_HEAVY; + } + + if (this->actor.speedXZ >= 5.0f) { + this->colliderCylinder1.base.atFlags |= AT_ON; + } else { + this->colliderCylinder1.base.atFlags &= ~AT_ON; + } + + if (this->dustFlags & 1) { + this->dustFlags &= ~1; + func_800B12F0(globalCtx, &this->frontRightHoof, &dustVel, &dustAcc, EnHorse_RandInt(100.0f) + 200, + EnHorse_RandInt(10.0f) + 30, EnHorse_RandInt(20.0f) + 30); + } else if (this->dustFlags & 2) { + this->dustFlags &= ~2; + func_800B12F0(globalCtx, &this->frontLeftHoof, &dustVel, &dustAcc, EnHorse_RandInt(100.0f) + 200, + EnHorse_RandInt(10.0f) + 30, EnHorse_RandInt(20.0f) + 30); + } else if (this->dustFlags & 4) { + this->dustFlags &= ~4; + func_800B12F0(globalCtx, &this->backRightHoof, &dustVel, &dustAcc, EnHorse_RandInt(100.0f) + 200, + EnHorse_RandInt(10.0f) + 30, EnHorse_RandInt(20.0f) + 30); + } else if (this->dustFlags & 8) { + this->dustFlags &= ~8; + func_800B12F0(globalCtx, &this->backLeftHoof, &dustVel, &dustAcc, EnHorse_RandInt(100.0f) + 200, + EnHorse_RandInt(10.0f) + 30, EnHorse_RandInt(20.0f) + 30); + } + this->stateFlags &= ~ENHORSE_DRAW; + } +} +#else +EnHorseActionFunc sActionFuncs[] = { + EnHorse_Frozen, + EnHorse_Inactive, + EnHorse_Idle, + EnHorse_FollowPlayer, + EnHorse_UpdateIngoRace, + func_808819D8, + func_80881398, + EnHorse_MountedIdle, + EnHorse_MountedIdleWhinneying, + EnHorse_MountedTurn, + EnHorse_MountedWalk, + EnHorse_MountedTrot, + EnHorse_MountedGallop, + EnHorse_MountedRearing, + EnHorse_Stopping, + EnHorse_Reverse, + EnHorse_LowJump, + EnHorse_HighJump, + EnHorse_CutsceneUpdate, + EnHorse_UpdateHorsebackArchery, + EnHorse_FleePlayer, + func_80884718, + func_8087CA04, + func_808848C8, + func_80884A40, + func_80884E0C, +}; +Vec3f D_808891C8 = { 0.0f, 0.0f, 0.0f }; +Vec3f D_808891D4 = { 0.0f, 1.0f, 0.0f }; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Update.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887D20.s") +s32 EnHorse_PlayerDirToMountSide(EnHorse* this, GlobalContext* globalCtx, Player* player) { + if (this->playerDir == PLAYER_DIR_SIDE_L) { + return -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887D60.s") + if (this->playerDir == PLAYER_DIR_SIDE_R) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887E64.s") + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887EBC.s") +s32 EnHorse_MountSideCheck(EnHorse* this, GlobalContext* globalCtx, Player* player) { + s32 mountSide; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887F58.s") + if (Actor_XZDistanceBetweenActors(&this->actor, &player->actor) > 75.0f) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80888C48.s") + if (fabsf(this->actor.world.pos.y - player->actor.world.pos.y) > 30.0f) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80888D18.s") + if (Math_CosS(Actor_YawBetweenActors(&player->actor, &this->actor) - player->actor.world.rot.y) < + 0.17364818f) { // cos(80 degrees) + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Draw.s") + mountSide = EnHorse_PlayerDirToMountSide(this, globalCtx, player); + if (mountSide == -1) { + return -1; + } + + if (mountSide == 1) { + return 1; + } + + return 0; +} + +s32 EnHorse_GetMountSide(EnHorse* this, GlobalContext* globalCtx) { + if (this->action != ENHORSE_ACT_IDLE) { + return 0; + } + + if ((this->animationIdx != ENHORSE_ANIM_IDLE) && (this->animationIdx != ENHORSE_ANIM_WHINNEY)) { + return 0; + } + + return EnHorse_MountSideCheck(this, globalCtx, GET_PLAYER(globalCtx)); +} + +void EnHorse_RandomOffset(Vec3f* src, f32 dist, Vec3f* dst) { + dst->x = ((Rand_ZeroOne() * (2.0f * dist)) + src->x) - dist; + dst->y = ((Rand_ZeroOne() * (2.0f * dist)) + src->y) - dist; + dst->z = ((Rand_ZeroOne() * (2.0f * dist)) + src->z) - dist; +} + +void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { + s32 pad; + EnHorse* this = THIS; + Vec3f sp7C = { 0.0f, 0.0f, 0.0f }; + Vec3f hoofOffset = { 5.0f, -4.0f, 5.0f }; + Vec3f sp64; + f32 curFrame = this->skin.skelAnime.curFrame; + Vec3f center; + Vec3f newCenter; + s32 i; + Vec3f sp38; + f32 sp34; + + if (!(this->stateFlags & ENHORSE_CALC_RIDER_POS)) { + if (this->type == HORSE_2) { + Skin_GetVertexPos(skin, 5, 120, &this->riderPos); + this->riderPos.y += 13.0f; + } else { + Vec3f riderOffset = { 600.0f, -1670.0f, 0.0f }; + + Skin_GetLimbPos(skin, 30, &riderOffset, &this->riderPos); + } + this->riderPos.x -= this->actor.world.pos.x; + this->riderPos.y -= this->actor.world.pos.y; + this->riderPos.z -= this->actor.world.pos.z; + } else { + this->stateFlags &= ~ENHORSE_CALC_RIDER_POS; + } + + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 13, &sp7C, &sp38); + } else { + Skin_GetLimbPos(skin, 13, &sp7C, &sp38); + } + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &sp38, &this->unk_218, &sp34); + + if ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->action != ENHORSE_ACT_FROZEN) && + (((curFrame > 40.0f) && (curFrame < 45.0f) && (this->type == 0)) || + ((curFrame > 28.0f) && (curFrame < 33.0f) && (this->type == 1)))) { + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 1; + Skin_GetLimbPos(skin, 28, &hoofOffset, &this->frontRightHoof); + this->frontRightHoof.y -= 5.0f; + } + } else { + if (this->action == ENHORSE_ACT_LOW_JUMP) { + if (((curFrame > 10.0f) && (curFrame < 13.0f)) || ((curFrame > 25.0f) && (curFrame < 33.0f))) { + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 2; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->frontLeftHoof); + } + + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 1; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); + } else { + curFrame = curFrame; + Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->frontRightHoof); + } + } + + if (((curFrame > 6.0f) && (curFrame < 10.0f)) || ((curFrame > 23.0f) && (curFrame < 29.0f))) { + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 8; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backLeftHoof); + } + } + + if ((((curFrame > 7.0f) && (curFrame < 14.0f)) || ((curFrame > 26.0f) && (curFrame < 30.0f))) && + (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 4; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 44, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 45, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backRightHoof); + } + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + if ((curFrame > 14.0f) && (curFrame < 16.0f) && (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 1; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 5.0f, &this->frontRightHoof); + } else if ((curFrame > 8.0f) && (curFrame < 10.0f) && (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 2; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->frontLeftHoof); + } else if ((curFrame > 1.0f) && (curFrame < 3.0f) && (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 4; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 44, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 45, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backRightHoof); + } else if ((curFrame > 26.0f) && (curFrame < 28.0f) && (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 8; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backLeftHoof); + } + } else if ((this->action == ENHORSE_ACT_BRIDGE_JUMP) && (curFrame > 6.0f) && + (Rand_ZeroOne() < (1.0f - ((curFrame - 6.0f) * (1.0f / 17.0f))))) { + if (Rand_ZeroOne() < 0.05f) { + this->dustFlags |= 8; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backLeftHoof); + } + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 4; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 44, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 45, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backRightHoof); + } + } else if ((this->action == ENHORSE_ACT_CS_UPDATE) && (curFrame > 5.0f)) { + if (Rand_ZeroOne() < (1.0f - ((curFrame - 5.0f) * 0.04f))) { + if (Rand_ZeroOne() < 0.05f) { + this->dustFlags |= 8; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backLeftHoof); + } + + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 4; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 44, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 45, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backRightHoof); + } + } + } + } + + for (i = 0; i < this->colliderJntSph.count; i++) { + center.x = this->colliderJntSph.elements[i].dim.modelSphere.center.x; + center.y = this->colliderJntSph.elements[i].dim.modelSphere.center.y; + center.z = this->colliderJntSph.elements[i].dim.modelSphere.center.z; + + Skin_GetLimbPos(skin, this->colliderJntSph.elements[i].dim.limb, ¢er, &newCenter); + + this->colliderJntSph.elements[i].dim.worldSphere.center.x = newCenter.x; + this->colliderJntSph.elements[i].dim.worldSphere.center.y = newCenter.y; + this->colliderJntSph.elements[i].dim.worldSphere.center.z = newCenter.z; + + this->colliderJntSph.elements[i].dim.worldSphere.radius = + this->colliderJntSph.elements[i].dim.modelSphere.radius * this->colliderJntSph.elements[i].dim.scale; + } + + //! @bug Setting colliders in a draw function allows for duplicate entries to be added to their respective lists + //! under certain conditions, like when pausing and unpausing the game. + //! Actors will draw for a couple of frames between the pauses, but some important logic updates will not occur. + //! In the case of OC, this can cause unwanted effects such as a very large amount of displacement being applied to + //! a colliding actor. + if (!(this->stateFlags & ENHORSE_JUMPING)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + } +} + +s32 EnHorse_OverrideLimbDraw(Actor* thisx, GlobalContext* globalCtx, s32 limbIndex, Skin* skin) { + static TexturePtr D_80889204[] = { + object_horse_link_child_Tex_001D28, + object_horse_link_child_Tex_001928, + object_horse_link_child_Tex_001B28, + }; + static u8 D_80889210[] = { 0, 1, 2, 1 }; + EnHorse* this = THIS; + s32 drawOriginalLimb = true; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((limbIndex != 13) || (this->type != HORSE_EPONA)) { + if ((limbIndex == 13) && (this->type == HORSE_2)) { + u8 idx = D_80889210[this->blinkTimer]; + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80889204[idx])); + } else if ((this->type == HORSE_HNI) && (this->stateFlags & ENHORSE_FLAG_18) && (limbIndex == 30)) { + drawOriginalLimb = false; + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + return drawOriginalLimb; +} + +s32 func_80888D18(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + Vec3f sp1C = { -98.0f, -1454.0f, 0.0f }; + EnHorse* this = THIS; + + if (limbIndex == 3) { + Matrix_MultiplyVector3fByState(&sp1C, &this->riderPos); + } + return false; +} + +void EnHorse_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHorse* this = THIS; + + if (!(this->stateFlags & ENHORSE_INACTIVE) && (this->actor.update != func_8087D540)) { + func_8012C28C(globalCtx->state.gfxCtx); + this->stateFlags |= ENHORSE_DRAW; + if (!(this->unk_1EC & 1)) { + if (this->stateFlags & ENHORSE_JUMPING) { + func_80138258(&this->actor, globalCtx, &this->skin, EnHorse_PostDraw, EnHorse_OverrideLimbDraw, false); + } else { + func_80138258(&this->actor, globalCtx, &this->skin, EnHorse_PostDraw, EnHorse_OverrideLimbDraw, true); + } + } else { + if (this->stateFlags & ENHORSE_JUMPING) { + this->skin.skelAnime.jointTable->x = 0; + this->skin.skelAnime.jointTable->y = 0; + this->skin.skelAnime.jointTable->z = 0; + } + SkelAnime_DrawFlexOpa(globalCtx, this->skin.skelAnime.skeleton, this->skin.skelAnime.jointTable, + this->skin.skelAnime.dListCount, func_80888D18, NULL, &this->actor); + } + + if (this->postDrawFunc != NULL) { + this->postDrawFunc(this, globalCtx); + } + } +} 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 d1eef6186..2dc5e44f5 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.h +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.h @@ -3,20 +3,217 @@ #include "global.h" #include "z64skin.h" +#include "overlays/actors/ovl_En_In/z_en_in.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_ha/object_ha.h" struct EnHorse; +typedef void (*EnHorseActionFunc)(struct EnHorse*, GlobalContext*); +typedef void (*EnHorsePostdrawFunc)(struct EnHorse*, GlobalContext*); +typedef void (*EnHorseCsFunc)(struct EnHorse*, GlobalContext*, CsCmdActorAction*); + +#define ENHORSE_BOOST (1 << 0) /* 0x1 */ +#define ENHORSE_BOOST_DECEL (1 << 1) /* 0x2 */ +#define ENHORSE_JUMPING (1 << 2) /* 0x4 */ +#define ENHORSE_CALC_RIDER_POS (1 << 3) /* 0x8 */ +#define ENHORSE_FORCE_REVERSING (1 << 4) /* 0x10 */ +#define ENHORSE_FORCE_WALKING (1 << 5) /* 0x20 */ +#define ENHORSE_FLAG_6 (1 << 6) /* 0x40 */ +#define ENHORSE_FLAG_7 (1 << 7) /* 0x80 */ +#define ENHORSE_FLAG_8 (1 << 8) /* 0x100 */ +#define ENHORSE_FLAG_9 (1 << 9) /* 0x200 */ +#define ENHORSE_STOPPING_NEIGH_SOUND (1 << 10) /* 0x400 */ +#define ENHORSE_LAND2_SOUND (1 << 11) /* 0x800 */ +#define ENHORSE_SANDDUST_SOUND (1 << 12) /* 0x1000 */ +#define ENHORSE_INACTIVE (1 << 13) /* 0x2000 */ +#define ENHORSE_OBSTACLE (1 << 14) /* 0x4000 */ +#define ENHORSE_TURNING_TO_PLAYER (1 << 15) /* 0x8000 */ +#define ENHORSE_UNRIDEABLE (1 << 16) /* 0x10000 */ +#define ENHORSE_CANT_JUMP (1 << 17) /* 0x20000 */ +#define ENHORSE_FLAG_18 (1 << 18) /* 0x40000 */ +#define ENHORSE_FLAG_19 (1 << 19) /* 0x80000 */ +#define ENHORSE_FLAG_20 (1 << 20) /* 0x100000 */ +#define ENHORSE_FLAG_21 (1 << 21) /* 0x200000 */ +#define ENHORSE_FIRST_BOOST_REGEN (1 << 22) /* 0x400000 */ +#define ENHORSE_INGO_WON (1 << 23) /* 0x800000 */ +#define ENHORSE_FLAG_24 (1 << 24) /* 0x1000000 */ +#define ENHORSE_FLAG_25 (1 << 25) /* 0x2000000 */ +#define ENHORSE_FLAG_26 (1 << 26) /* 0x4000000 */ +#define ENHORSE_DRAW (1 << 27) /* 0x8000000 */ +#define ENHORSE_FLAG_28 (1 << 28) /* 0x10000000 */ +#define ENHORSE_FLAG_29 (1 << 29) /* 0x20000000 */ +#define ENHORSE_FLAG_30 (1 << 30) /* 0x40000000 */ +#define ENHORSE_FLAG_31 (1 << 31) /* 0x80000000 */ + +typedef enum { + /* 0 */ ENHORSE_ACT_FROZEN, + /* 1 */ ENHORSE_ACT_INACTIVE, + /* 2 */ ENHORSE_ACT_IDLE, + /* 3 */ ENHORSE_ACT_FOLLOW_PLAYER, + /* 4 */ ENHORSE_ACT_INGO_RACE, + /* 5 */ ENHORSE_ACT_MOUNTED_IDLE, + /* 6 */ ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING, + /* 7 */ ENHORSE_ACT_MOUNTED_TURN, + /* 8 */ ENHORSE_ACT_MOUNTED_WALK, + /* 9 */ ENHORSE_ACT_MOUNTED_TROT, + /* 10 */ ENHORSE_ACT_MOUNTED_GALLOP, + /* 11 */ ENHORSE_ACT_MOUNTED_REARING, + /* 12 */ ENHORSE_ACT_STOPPING, + /* 13 */ ENHORSE_ACT_REVERSE, + /* 14 */ ENHORSE_ACT_LOW_JUMP, + /* 15 */ ENHORSE_ACT_HIGH_JUMP, + /* 16 */ ENHORSE_ACT_BRIDGE_JUMP, + /* 17 */ ENHORSE_ACT_CS_UPDATE, + /* 18 */ ENHORSE_ACT_HBA, + /* 19 */ ENHORSE_ACT_FLEE_PLAYER, + /* 20 */ ENHORSE_ACT_20, + /* 21 */ ENHORSE_ACT_21, + /* 22 */ ENHORSE_ACT_22, + /* 23 */ ENHORSE_ACT_23, + /* 24 */ ENHORSE_ACT_24, + /* 25 */ ENHORSE_ACT_25, +} EnHorseAction; + +typedef enum { + /* 0 */ PLAYER_DIR_FRONT_R, + /* 1 */ PLAYER_DIR_FRONT_L, + /* 2 */ PLAYER_DIR_BACK_R, + /* 3 */ PLAYER_DIR_BACK_L, + /* 4 */ PLAYER_DIR_SIDE_R, + /* 5 */ PLAYER_DIR_SIDE_L +} EnHorsePlayerDir; + +typedef enum { + /* 0 */ ENHORSE_ANIM_IDLE, + /* 1 */ ENHORSE_ANIM_WHINNEY, + /* 2 */ ENHORSE_ANIM_STOPPING, + /* 3 */ ENHORSE_ANIM_REARING, + /* 4 */ ENHORSE_ANIM_WALK, + /* 5 */ ENHORSE_ANIM_TROT, + /* 6 */ ENHORSE_ANIM_GALLOP, + /* 7 */ ENHORSE_ANIM_LOW_JUMP, + /* 8 */ ENHORSE_ANIM_HIGH_JUMP +} EnHorseAnimationIndex; + +typedef enum { + /* 0 */ HORSE_EPONA, + /* 1 */ HORSE_HNI, + /* 2 */ HORSE_2, + /* 3 */ HORSE_3, + /* 4 */ HORSE_4 +} HorseType; + +#define ENHORSE_GET_2000(thisx) ((thisx)->params & 0x2000) +#define ENHORSE_GET_4000(thisx) ((thisx)->params & 0x4000) +#define ENHORSE_GET_8000(thisx) ((thisx)->params & 0x8000) + +enum { + /* 0 */ ENHORSE_0, + /* 1 */ ENHORSE_1, + /* 2 */ ENHORSE_2, + /* 3 */ ENHORSE_3, + /* 4 */ ENHORSE_4, + /* 5 */ ENHORSE_5, + /* 6 */ ENHORSE_6, + /* 7 */ ENHORSE_7, + /* 8 */ ENHORSE_8, + /* 9 */ ENHORSE_9, + /* 10 */ ENHORSE_10, + /* 11 */ ENHORSE_11, + /* 12 */ ENHORSE_12, + /* 13 */ ENHORSE_13, + /* 14 */ ENHORSE_14, + /* 15 */ ENHORSE_15, + /* 16 */ ENHORSE_16, + /* 17 */ ENHORSE_17, + /* 18 */ ENHORSE_18, + /* 19 */ ENHORSE_19, + /* 20 */ ENHORSE_20, +}; + typedef struct EnHorse { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xC]; - /* 0x150 */ s32 unk_150; - /* 0x154 */ char unk_154[0x98]; - /* 0x1EC */ UNK_TYPE4 unk_1EC; - /* 0x1F0 */ char unk_1F0[0x5C]; - /* 0x24C */ u32 unk_24C; - /* 0x250 */ char unk_250[0x138]; + /* 0x144 */ s32 action; + /* 0x148 */ s32 noInputTimer; + /* 0x14C */ s32 noInputTimerMax; + /* 0x150 */ s32 type; + /* 0x154 */ s8 bankIndex; + /* 0x158 */ Skin skin; + /* 0x1E8 */ s32 stateFlags; + /* 0x1EC */ s32 unk_1EC; + /* 0x1F0 */ Vec3f lastPos; + /* 0x1FC */ s16 lastYaw; + /* 0x200 */ s32 curRaceWaypoint; + /* 0x204 */ s32 boostSpeed; + /* 0x208 */ s32 playerControlled; + /* 0x20C */ s32 animationIdx; + /* 0x210 */ f32 curFrame; + /* 0x214 */ s32 soundTimer; + /* 0x218 */ Vec3f unk_218; + /* 0x224 */ UNK_TYPE1 unk224[0xC]; + /* 0x230 */ s32 unk_230; + /* 0x234 */ u8 numBoosts; + /* 0x238 */ s32 boostRegenTime; + /* 0x23C */ s32 boostTimer; + /* 0x240 */ EnHorsePostdrawFunc postDrawFunc; + /* 0x244 */ f32 yFront; + /* 0x248 */ f32 yBack; + /* 0x24C */ s32 unk_24C; + /* 0x250 */ s16 followTimer; + /* 0x254 */ s32 prevAction; + /* 0x258 */ Vec3f riderPos; + /* 0x264 */ Vec2f curStick; + /* 0x26C */ Vec2f lastStick; + /* 0x274 */ f32 jumpStartY; + /* 0x278 */ ColliderCylinder colliderCylinder1; + /* 0x2C4 */ ColliderCylinder colliderCylinder2; + /* 0x310 */ ColliderJntSph colliderJntSph; + /* 0x330 */ ColliderJntSphElement colliderJntSphElements[1]; + /* 0x370 */ s32 playerDir; + /* 0x374 */ UNK_TYPE1 unk374[0x2]; + /* 0x376 */ s16 angleToPlayer; + /* 0x378 */ s16 followPlayerTurnSpeed; + /* 0x37A */ u8 blinkTimer; + /* 0x37C */ s16 waitTimer; + /* 0x380 */ s32 cutsceneAction; + /* 0x384 */ u16 cutsceneFlags; /* 0x388 */ s32 inRace; - /* 0x38C */ char unk_38C[0x208]; + /* 0x38C */ struct EnIn* rider; + /* 0x390 */ UNK_TYPE1 unk390[0x4]; + /* 0x394 */ u16 unk_394; + /* 0x398 */ f32 unk_398; + /* 0x39C */ s32 unk_39C; + /* 0x3A0 */ s32 hbaStarted; + /* 0x3A4 */ s32 hbaFlags; + /* 0x3A8 */ s32 hbaTimer; + /* 0x3AC */ u16 dustFlags; + /* 0x3B0 */ Vec3f frontRightHoof; + /* 0x3BC */ Vec3f frontLeftHoof; + /* 0x3C8 */ Vec3f backRightHoof; + /* 0x3D4 */ Vec3f backLeftHoof; + /* 0x3E0 */ s32 unk_3E0; + /* 0x3E4 */ UNK_TYPE1 unk3E4[0x4]; + /* 0x3E8 */ f32 unk_3E8; + /* 0x3EC */ s16 unk_3EC; + /* 0x3EE */ Vec3s jointTable[OBJECT_HA_1_LIMB_MAX]; + /* 0x48A */ Vec3s morphTable[OBJECT_HA_1_LIMB_MAX]; + /* 0x528 */ f32 unk_528; + /* 0x52C */ s32 unk_52C; + /* 0x530 */ s32 unk_530; + /* 0x534 */ s32 unk_534; + /* 0x538 */ s32 unk_538; + /* 0x53C */ s32 unk_53C; + /* 0x540 */ Vec3f unk_540; + /* 0x54C */ UNK_TYPE1 unk54C[0x4]; + /* 0x550 */ s32 unk_550; + /* 0x554 */ UNK_TYPE1 unk554[0x18]; + /* 0x56C */ f32 unk_56C; + /* 0x570 */ Vec3f unk_570; + /* 0x57C */ Vec3f unk_57C; + /* 0x588 */ UNK_TYPE1 unk588[0x4]; + /* 0x58C */ s32 unk_58C; + /* 0x590 */ s32 unk_590; } EnHorse; // size = 0x594 extern const ActorInit En_Horse_InitVars; diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index 3d6687263..729a82a70 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -405,7 +405,7 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { if (player->stateFlags1 & 0x800000) { EnHorse* rideActor = (EnHorse*)player->rideActor; - if ((rideActor->unk_150 == 0) || (rideActor->unk_150 == 2)) { + if ((rideActor->type == HORSE_EPONA) || (rideActor->type == HORSE_2)) { if (CURRENT_DAY < 3) { D_801BDA9C = 1; } else { diff --git a/tools/actorfixer.py b/tools/actorfixer.py index d7ffef8d1..0370f0043 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -505,11 +505,11 @@ animdict = { "gSaveContext.weekEventReg": "gSaveContext.save.weekEventReg", "gSaveContext.playerForm": "gSaveContext.save.playerForm", "gSaveContext.day": "gSaveContext.save.day", - # "gSaveContext.cutscene": "gSaveContext.save.cutscene", + "gSaveContext.cutscene": "gSaveContext.save.cutscene", "gSaveContext.isNight": "gSaveContext.save.isNight", "gSaveContext.naviTimer": "gSaveContext.save.playerData.tatlTimer", "gSaveContext.tatlTimer": "gSaveContext.save.playerData.tatlTimer", - # "gSaveContext.health": "gSaveContext.save.playerData.health", + "gSaveContext.health": "gSaveContext.save.playerData.health", "gSaveContext.rupees": "gSaveContext.save.playerData.rupees", "gSaveContext.magicAcquired": "gSaveContext.save.playerData.magicAcquired", "gSaveContext.doubleMagic": "gSaveContext.save.playerData.doubleMagic", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index abfae35aa..0ac959c7a 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -5206,82 +5206,82 @@ 0x8087AF48:("EnFirefly_OverrideLimbDraw",), 0x8087AF98:("EnFirefly_PostLimbDraw",), 0x8087B320:("EnFirefly_Draw",), - 0x8087B730:("func_8087B730",), - 0x8087B784:("func_8087B784",), + 0x8087B730:("EnHorse_RaceWaypointPos",), + 0x8087B784:("EnHorse_RotateToPoint",), 0x8087B7C0:("func_8087B7C0",), - 0x8087C0AC:("func_8087C0AC",), + 0x8087C0AC:("EnHorse_PlayWalkingSound",), 0x8087C178:("func_8087C178",), 0x8087C1C0:("func_8087C1C0",), - 0x8087C208:("func_8087C208",), + 0x8087C208:("EnHorse_SlopeSpeedMultiplier",), 0x8087C288:("func_8087C288",), 0x8087C2B8:("func_8087C2B8",), 0x8087C38C:("func_8087C38C",), - 0x8087C43C:("func_8087C43C",), - 0x8087C590:("func_8087C590",), - 0x8087C8B8:("func_8087C8B8",), - 0x8087C8D0:("func_8087C8D0",), - 0x8087C8E0:("func_8087C8E0",), - 0x8087C9D4:("func_8087C9D4",), - 0x8087C9EC:("func_8087C9EC",), + 0x8087C43C:("EnHorse_IdleAnimSounds",), + 0x8087C590:("EnHorse_Spawn",), + 0x8087C8B8:("EnHorse_ResetCutscene",), + 0x8087C8D0:("EnHorse_ResetRace",), + 0x8087C8E0:("EnHorse_PlayerCanMove",), + 0x8087C9D4:("EnHorse_ResetHorsebackArchery",), + 0x8087C9EC:("EnHorse_ClearDustFlags",), 0x8087C9F8:("func_8087C9F8",), 0x8087CA04:("func_8087CA04",), 0x8087CA14:("EnHorse_Init",), 0x8087D540:("func_8087D540",), 0x8087D69C:("EnHorse_Destroy",), - 0x8087D70C:("func_8087D70C",), - 0x8087D75C:("func_8087D75C",), - 0x8087D814:("func_8087D814",), - 0x8087D988:("func_8087D988",), - 0x8087DDEC:("func_8087DDEC",), - 0x8087DE28:("func_8087DE28",), - 0x8087DF64:("func_8087DF64",), - 0x8087E080:("func_8087E080",), - 0x8087E0A4:("func_8087E0A4",), - 0x8087E18C:("func_8087E18C",), - 0x8087E2A8:("func_8087E2A8",), - 0x8087E350:("func_8087E350",), - 0x8087E564:("func_8087E564",), - 0x8087E5B4:("func_8087E5B4",), - 0x8087E5D8:("func_8087E5D8",), - 0x8087E684:("func_8087E684",), - 0x8087E6D8:("func_8087E6D8",), - 0x8087E92C:("func_8087E92C",), - 0x8087E9D0:("func_8087E9D0",), - 0x8087EA1C:("func_8087EA1C",), - 0x8087EB54:("func_8087EB54",), - 0x8087EB78:("func_8087EB78",), - 0x8087EC20:("func_8087EC20",), - 0x8087EC78:("func_8087EC78",), - 0x8087ED10:("func_8087ED10",), - 0x8087EEC4:("func_8087EEC4",), - 0x8087F078:("func_8087F078",), - 0x8087F1FC:("func_8087F1FC",), - 0x8087F39C:("func_8087F39C",), - 0x8087F590:("func_8087F590",), - 0x8087F5B4:("func_8087F5B4",), - 0x8087F658:("func_8087F658",), - 0x8087F9A0:("func_8087F9A0",), - 0x8087F9C4:("func_8087F9C4",), - 0x8087FB08:("func_8087FB08",), - 0x8087FB14:("func_8087FB14",), - 0x8087FD94:("func_8087FD94",), - 0x8087FDB8:("func_8087FDB8",), - 0x8087FF08:("func_8087FF08",), - 0x8087FF14:("func_8087FF14",), - 0x808801A8:("func_808801A8",), - 0x808801F8:("func_808801F8",), - 0x808802D0:("func_808802D0",), - 0x808804A4:("func_808804A4",), - 0x808804CC:("func_808804CC",), - 0x80880500:("func_80880500",), - 0x80880534:("func_80880534",), - 0x808806DC:("func_808806DC",), - 0x80880844:("func_80880844",), - 0x80880978:("func_80880978",), - 0x80880D50:("func_80880D50",), - 0x80880DA8:("func_80880DA8",), - 0x80880E00:("func_80880E00",), - 0x80881128:("func_80881128",), + 0x8087D70C:("EnHorse_RotateToPlayer",), + 0x8087D75C:("EnHorse_Freeze",), + 0x8087D814:("EnHorse_Frozen",), + 0x8087D988:("EnHorse_UpdateSpeed",), + 0x8087DDEC:("EnHorse_StartMountedIdleResetAnim",), + 0x8087DE28:("EnHorse_StartMountedIdle",), + 0x8087DF64:("EnHorse_MountedIdle",), + 0x8087E080:("EnHorse_MountedIdleAnim",), + 0x8087E0A4:("EnHorse_MountedIdleWhinney",), + 0x8087E18C:("EnHorse_MountedIdleWhinneying",), + 0x8087E2A8:("EnHorse_StartTurning",), + 0x8087E350:("EnHorse_MountedTurn",), + 0x8087E564:("EnHorse_StartWalkingFromIdle",), + 0x8087E5B4:("EnHorse_StartWalkingInterruptable",), + 0x8087E5D8:("EnHorse_StartWalking",), + 0x8087E684:("EnHorse_MountedWalkingReset",), + 0x8087E6D8:("EnHorse_MountedWalk",), + 0x8087E92C:("EnHorse_StartTrotting",), + 0x8087E9D0:("EnHorse_MountedTrotReset",), + 0x8087EA1C:("EnHorse_MountedTrot",), + 0x8087EB54:("EnHorse_StartGallopingInterruptable",), + 0x8087EB78:("EnHorse_StartGalloping",), + 0x8087EC20:("EnHorse_MountedGallopReset",), + 0x8087EC78:("EnHorse_JumpLanding",), + 0x8087ED10:("EnHorse_MountedGallop",), + 0x8087EEC4:("EnHorse_StartRearing",), + 0x8087F078:("EnHorse_MountedRearing",), + 0x8087F1FC:("EnHorse_StartBraking",), + 0x8087F39C:("EnHorse_Stopping",), + 0x8087F590:("EnHorse_StartReversingInterruptable",), + 0x8087F5B4:("EnHorse_StartReversing",), + 0x8087F658:("EnHorse_Reverse",), + 0x8087F9A0:("EnHorse_LowJumpInit",), + 0x8087F9C4:("EnHorse_StartLowJump",), + 0x8087FB08:("EnHorse_Stub1",), + 0x8087FB14:("EnHorse_LowJump",), + 0x8087FD94:("EnHorse_HighJumpInit",), + 0x8087FDB8:("EnHorse_StartHighJump",), + 0x8087FF08:("EnHorse_Stub2",), + 0x8087FF14:("EnHorse_HighJump",), + 0x808801A8:("EnHorse_InitInactive",), + 0x808801F8:("EnHorse_Inactive",), + 0x808802D0:("EnHorse_PlayIdleAnimation",), + 0x808804A4:("EnHorse_ChangeIdleAnimation",), + 0x808804CC:("EnHorse_ResetIdleAnimation",), + 0x80880500:("EnHorse_StartIdleRidable",), + 0x80880534:("EnHorse_Idle",), + 0x808806DC:("EnHorse_StartMovingAnimation",), + 0x80880844:("EnHorse_SetFollowAnimation",), + 0x80880978:("EnHorse_FollowPlayer",), + 0x80880D50:("EnHorse_InitIngoHorse",), + 0x80880DA8:("EnHorse_SetIngoAnimation",), + 0x80880E00:("EnHorse_UpdateIngoHorseAnim",), + 0x80881128:("EnHorse_UpdateIngoRace",), 0x8088126C:("func_8088126C",), 0x80881290:("func_80881290",), 0x80881398:("func_80881398",), @@ -5289,26 +5289,26 @@ 0x80881634:("func_80881634",), 0x8088168C:("func_8088168C",), 0x808819D8:("func_808819D8",), - 0x80881BDC:("func_80881BDC",), - 0x80881C54:("func_80881C54",), - 0x80881DA4:("func_80881DA4",), - 0x80881DC8:("func_80881DC8",), - 0x80881F10:("func_80881F10",), - 0x80881F48:("func_80881F48",), - 0x808821C8:("func_808821C8",), - 0x808822CC:("func_808822CC",), - 0x8088247C:("func_8088247C",), - 0x80882564:("func_80882564",), - 0x808826B4:("func_808826B4",), - 0x80882820:("func_80882820",), - 0x808829D0:("func_808829D0",), - 0x808829F4:("func_808829F4",), - 0x80882A44:("func_80882A44",), - 0x80882B9C:("func_80882B9C",), - 0x80882D8C:("func_80882D8C",), - 0x80882DC0:("func_80882DC0",), - 0x80883104:("func_80883104",), - 0x80883308:("func_80883308",), + 0x80881BDC:("EnHorse_CsMoveInit",), + 0x80881C54:("EnHorse_CsMoveToPoint",), + 0x80881DA4:("EnHorse_CsSetAnimHighJump",), + 0x80881DC8:("EnHorse_CsPlayHighJumpAnim",), + 0x80881F10:("EnHorse_CsJumpInit",), + 0x80881F48:("EnHorse_CsJump",), + 0x808821C8:("EnHorse_CsRearingInit",), + 0x808822CC:("EnHorse_CsRearing",), + 0x8088247C:("EnHorse_WarpMoveInit",), + 0x80882564:("EnHorse_CsWarpMoveToPoint",), + 0x808826B4:("EnHorse_CsWarpRearingInit",), + 0x80882820:("EnHorse_CsWarpRearing",), + 0x808829D0:("EnHorse_InitCutscene",), + 0x808829F4:("EnHorse_GetCutsceneFunctionIndex",), + 0x80882A44:("EnHorse_CutsceneUpdate",), + 0x80882B9C:("EnHorse_UpdateHbaRaceInfo",), + 0x80882D8C:("EnHorse_InitHorsebackArchery",), + 0x80882DC0:("EnHorse_UpdateHbaAnim",), + 0x80883104:("EnHorse_UpdateHorsebackArchery",), + 0x80883308:("EnHorse_FleePlayer",), 0x80883B70:("func_80883B70",), 0x80883BEC:("func_80883BEC",), 0x80883CB0:("func_80883CB0",), @@ -5338,29 +5338,29 @@ 0x80884A40:("func_80884A40",), 0x80884D04:("func_80884D04",), 0x80884E0C:("func_80884E0C",), - 0x80885060:("func_80885060",), - 0x808850DC:("func_808850DC",), - 0x80885220:("func_80885220",), - 0x808853E0:("func_808853E0",), - 0x8088598C:("func_8088598C",), - 0x80885A80:("func_80885A80",), - 0x80885AF4:("func_80885AF4",), - 0x80885B4C:("func_80885B4C",), - 0x80885C90:("func_80885C90",), - 0x80885DA4:("func_80885DA4",), + 0x80885060:("EnHorse_Vec3fOffset",), + 0x808850DC:("EnHorse_CalcFloorHeight",), + 0x80885220:("EnHorse_ObstructMovement",), + 0x808853E0:("EnHorse_CheckFloors",), + 0x8088598C:("EnHorse_MountDismount",), + 0x80885A80:("EnHorse_StickDirection",), + 0x80885AF4:("EnHorse_UpdateStick",), + 0x80885B4C:("EnHorse_ResolveCollision",), + 0x80885C90:("EnHorse_BgCheckSlowMoving",), + 0x80885DA4:("EnHorse_UpdateBgCheckInfo",), 0x80886C00:("func_80886C00",), - 0x80886DC4:("func_80886DC4",), - 0x80886FA8:("func_80886FA8",), - 0x808870A4:("func_808870A4",), - 0x808871A0:("func_808871A0",), - 0x80887270:("func_80887270",), + 0x80886DC4:("EnHorse_RegenBoost",), + 0x80886FA8:("EnHorse_UpdatePlayerDir",), + 0x808870A4:("EnHorse_TiltBody",), + 0x808871A0:("EnHorse_UpdateConveyors",), + 0x80887270:("EnHorse_RandInt",), 0x808872A4:("EnHorse_Update",), - 0x80887D20:("func_80887D20",), - 0x80887D60:("func_80887D60",), - 0x80887E64:("func_80887E64",), - 0x80887EBC:("func_80887EBC",), - 0x80887F58:("func_80887F58",), - 0x80888C48:("func_80888C48",), + 0x80887D20:("EnHorse_PlayerDirToMountSide",), + 0x80887D60:("EnHorse_MountSideCheck",), + 0x80887E64:("EnHorse_GetMountSide",), + 0x80887EBC:("EnHorse_RandomOffset",), + 0x80887F58:("EnHorse_PostDraw",), + 0x80888C48:("EnHorse_OverrideLimbDraw",), 0x80888D18:("func_80888D18",), 0x80888D78:("EnHorse_Draw",), 0x8088A240:("EnArrow_Init",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 0d6b8fc76..2cce52fba 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -5896,19 +5896,18 @@ 0x8087B538:("D_8087B538","f32","",0x4), 0x80888EC0:("D_80888EC0","UNK_TYPE1","",0x1), 0x80888EE4:("D_80888EE4","UNK_TYPE1","",0x1), - 0x80888F08:("D_80888F08","UNK_TYPE1","",0x1), + 0x80888F08:("sAnimationHeaders","AnimationHeader*","[5]",0x14), 0x80888F1C:("D_80888F1C","UNK_TYPE1","",0x1), 0x80888F34:("D_80888F34","UNK_TYPE4","",0x4), - 0x80888F40:("D_80888F40","UNK_TYPE1","",0x1), + 0x80888F40:("sSkeletonHeaders","UNK_TYPE1","",0x1), 0x80888F54:("En_Horse_InitVars","UNK_TYPE1","",0x1), - 0x80888F74:("D_80888F74","UNK_TYPE1","",0x1), - 0x80888FA0:("D_80888FA0","UNK_TYPE1","",0x1), + 0x80888F74:("sCylinderInit1","UNK_TYPE1","",0x1), + 0x80888FA0:("sCylinderInit2","UNK_TYPE1","",0x1), 0x80888FCC:("D_80888FCC","UNK_TYPE1","",0x1), - 0x80888FF0:("D_80888FF0","UNK_TYPE1","",0x1), - 0x80888FFC:("D_80888FFC","UNK_PTR","",0x4), - 0x80889000:("D_80889000","UNK_TYPE1","",0x1), + 0x80888FF0:("sJntSphInit","UNK_TYPE1","",0x10), + 0x80889000:("sColChkInfoInit","UNK_TYPE1","",0x1), 0x80889008:("D_80889008","UNK_TYPE1","",0x1), - 0x80889010:("D_80889010","UNK_TYPE1","",0x1), + 0x80889010:("sInitChain","UNK_TYPE1","",0x1), 0x80889018:("D_80889018","UNK_TYPE1","",0x1), 0x80889030:("D_80889030","UNK_TYPE1","",0x1), 0x80889048:("D_80889048","UNK_TYPE1","",0x1), @@ -5923,7 +5922,7 @@ 0x8088911C:("D_8088911C","UNK_TYPE1","",0x1), 0x80889148:("D_80889148","UNK_TYPE4","",0x4), 0x80889154:("D_80889154","UNK_TYPE4","",0x4), - 0x80889160:("D_80889160","UNK_PTR","",0x4), + 0x80889160:("sActionFuncs","UNK_PTR","",0x4), 0x808891C8:("D_808891C8","UNK_TYPE4","",0x4), 0x808891D4:("D_808891D4","UNK_TYPE4","",0x4), 0x808891E0:("D_808891E0","UNK_TYPE4","",0x4), diff --git a/undefined_syms.txt b/undefined_syms.txt index de13da3ae..4807cfc11 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1234,17 +1234,6 @@ D_0600B644 = 0x0600B644; D_0600F248 = 0x0600F248; D_06012A58 = 0x06012A58; -// ovl_En_Horse - -D_06008C68 = 0x06008C68; -D_0600A8DC = 0x0600A8DC; -D_0600AD08 = 0x0600AD08; -D_0600B3E0 = 0x0600B3E0; -D_0600BDE0 = 0x0600BDE0; -D_0600D178 = 0x0600D178; -D_0600D4E8 = 0x0600D4E8; -D_060150D8 = 0x060150D8; - // ovl_En_Horse_Link_Child D_06002F98 = 0x06002F98; From b4842eb16c046ee4efedc889bdf52f1a818b3e3f Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 22:26:56 +0100 Subject: [PATCH 174/257] Mir_Ray3 (1 non-matching) (#695) --- spec | 5 +- src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c | 399 +++++++++++++++++- src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h | 11 +- 3 files changed, 393 insertions(+), 22 deletions(-) diff --git a/spec b/spec index 2cc83081c..3ba626c71 100644 --- a/spec +++ b/spec @@ -4377,8 +4377,11 @@ beginseg name "ovl_Mir_Ray3" compress include "build/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.o" - include "build/data/ovl_Mir_Ray3/ovl_Mir_Ray3.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Mir_Ray3/ovl_Mir_Ray3_reloc.o" +#else include "build/data/ovl_Mir_Ray3/ovl_Mir_Ray3.reloc.o" +#endif endseg beginseg diff --git a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c index 1da636c1d..15bef2ca5 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c @@ -5,6 +5,7 @@ */ #include "z_mir_ray3.h" +#include "objects/object_mir_ray/object_mir_ray.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +16,6 @@ void MirRay3_Destroy(Actor* thisx, GlobalContext* globalCtx); void MirRay3_Update(Actor* thisx, GlobalContext* globalCtx); void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Mir_Ray3_InitVars = { ACTOR_MIR_RAY3, ACTORCAT_ITEMACTION, @@ -28,39 +28,398 @@ const ActorInit Mir_Ray3_InitVars = { (ActorFunc)MirRay3_Draw, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_80B9F420 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK0, { 0x00200000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x00200000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B9F470 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, OC1_NONE, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 10, 10, 0, { 0, 0, 0 } }, }; +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ MtxF unk_0C; + /* 0x4C */ CollisionPoly* unk_4C; + /* 0x50 */ u8 unk_50; +} MirRay3Struct; // size = 0x54 + +void MirRay3_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + MirRay3* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + Actor_SetScale(&this->actor, 1.0f); + + this->unk_218[0].x = -536.0f; + this->unk_218[0].y = -939.0f; + + this->unk_218[1].x = -1690.0f; + this->unk_218[1].y = 0.0f; + + this->unk_218[2].x = -536.0f; + this->unk_218[2].y = 938.0f; + + this->unk_218[3].x = 921.0f; + this->unk_218[3].y = 0.0f; + + this->unk_218[4].x = 758.0f; + this->unk_218[4].y = 800.0f; + + this->unk_218[5].x = 758.0f; + this->unk_218[5].y = -800.0f; + + Collider_InitQuad(globalCtx, &this->colliderQuad); + Collider_SetQuad(globalCtx, &this->colliderQuad, &this->actor, &sQuadInit); + Collider_InitCylinder(globalCtx, &this->colliderCylinder); + Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + this->actor.world.rot.x = this->actor.shape.rot.x = 0; +} + +void MirRay3_Destroy(Actor* thisx, GlobalContext* globalCtx) { + MirRay3* this = THIS; + + Collider_DestroyQuad(globalCtx, &this->colliderQuad); + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); +} + +void MirRay3_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + MirRay3* this = THIS; + Player* player = GET_PLAYER(globalCtx); + + this->unk_210 &= ~1; + + if (this->unk_214 > 0.5f) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderQuad.base); + } + + this->unk_210 &= ~2; + + if (func_8012405C(globalCtx)) { + if (this->colliderCylinder.base.acFlags & AC_HIT) { + this->unk_210 |= 2; + } + this->actor.world.pos.x = player->shieldMf.mf[3][0]; + this->actor.world.pos.y = player->shieldMf.mf[3][1]; + this->actor.world.pos.z = player->shieldMf.mf[3][2]; + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } + + if (this->unk_214 > 0.1f) { + func_800B8F98(&player->actor, NA_SE_IT_SHIELD_BEAM - SFX_FLAG); + } + + Math_ApproachZeroF(&this->unk_214, 1.0f, 0.1f); +} + +void func_80B9E544(MirRay3* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + MtxF* shieldMtx = &player->shieldMf; + f32 temp_f0; + + if (this->unk_210 & 2) { + temp_f0 = sqrtf(SQ(shieldMtx->mf[2][0]) + SQ(shieldMtx->mf[2][1]) + SQ(shieldMtx->mf[2][2])); + if (temp_f0 == 0.0f) { + this->unk_260 = 1.0f; + } else { + this->unk_260 = 1.0f / temp_f0; + } + Math_ApproachF(&this->unk_214, 1.0f, 0.5f, 0.25f); + } +} + +void func_80B9E5F4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr) { + Player* player = GET_PLAYER(globalCtx); + MtxF* shieldMtx = &player->shieldMf; + s32 i; + Vec3f sp88; + Vec3f sp7C; + Vec3f sp70; + CollisionPoly* sp6C; + f32 sp60[3]; + + sp60[0] = -(shieldMtx->mf[2][0] * this->unk_260) * this->unk_214 * 400.0f; + sp60[1] = -(shieldMtx->mf[2][1] * this->unk_260) * this->unk_214 * 400.0f; + sp60[2] = -(shieldMtx->mf[2][2] * this->unk_260) * this->unk_214 * 400.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_218); i++) { + sp88.x = (shieldMtx->mf[3][0] + (this->unk_218[i].x * shieldMtx->mf[0][0])) + + (this->unk_218[i].y * shieldMtx->mf[1][0]); + sp88.y = (shieldMtx->mf[3][1] + (this->unk_218[i].x * shieldMtx->mf[0][1])) + + (this->unk_218[i].y * shieldMtx->mf[1][1]); + sp88.z = (shieldMtx->mf[3][2] + (this->unk_218[i].x * shieldMtx->mf[0][2])) + + (this->unk_218[i].y * shieldMtx->mf[1][2]); + + sp7C.x = sp60[0] + sp88.x; + sp7C.y = sp60[1] + sp88.y; + sp7C.z = sp60[2] + sp88.z; + + if (BgCheck_AnyLineTest1(&globalCtx->colCtx, &sp88, &sp7C, &sp70, &sp6C, true)) { + ptr[i].unk_4C = sp6C; + } else { + ptr[i].unk_4C = NULL; + } + } +} + +void func_80B9E7D0(MirRay3Struct* ptr) { + s32 i; + s32 j; + + for (i = 0; i < 6; i++) { + for (j = i + 1; j < 6; j++) { + if ((ptr[i].unk_4C != NULL) && (ptr[j].unk_4C != NULL)) { + if ((ABS(ptr[i].unk_4C->normal.x - ptr[j].unk_4C->normal.x) < 100) && + (ABS(ptr[i].unk_4C->normal.y - ptr[j].unk_4C->normal.y) < 100) && + (ABS(ptr[i].unk_4C->normal.z - ptr[j].unk_4C->normal.z) < 100) && + (ptr[i].unk_4C->dist == ptr[j].unk_4C->dist)) { + ptr[j].unk_4C = NULL; + } + } + } + } +} + +#ifdef NON_MATCHING +void func_80B9E8D4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + MtxF* shieldMf = &player->shieldMf; + Vec3f sp140; + Vec3f sp134; + Vec3f sp128; + Vec3f sp11C; + Vec3f sp110; + Vec3f sp104; + f32 spF8[3]; + f32 spEC[3]; + f32 temp_f0; + f32 temp_f26; + f32 temp_f2; + Vec3f spD4; + Vec3f spC8; + CollisionPoly* spC4; + + spF8[0] = -(shieldMf->mf[2][0] * this->unk_260) * this->unk_214 * 400.0f; + spF8[1] = -(shieldMf->mf[2][1] * this->unk_260) * this->unk_214 * 400.0f; + spF8[2] = -(shieldMf->mf[2][2] * this->unk_260) * this->unk_214 * 400.0f; + + sp140.x = shieldMf->mf[3][0]; + sp140.y = shieldMf->mf[3][1]; + sp140.z = shieldMf->mf[3][2]; + + sp134.x = spF8[0] + sp140.x; + sp134.y = spF8[1] + sp140.y; + sp134.z = spF8[2] + sp140.z; + + temp_f26 = this->unk_214 * 400.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_218); i++) { + if (ptr[i].unk_4C != NULL) { + spEC[0] = COLPOLY_GET_NORMAL(ptr[i].unk_4C->normal.x); + spEC[1] = COLPOLY_GET_NORMAL(ptr[i].unk_4C->normal.y); + spEC[2] = COLPOLY_GET_NORMAL(ptr[i].unk_4C->normal.z); + + if (Math3D_LineSegVsPlane(spEC[0], spEC[1], spEC[2], ptr[i].unk_4C->dist, &sp140, &sp134, &sp128, true)) { + ptr[i].unk_00.x = sp128.x; + ptr[i].unk_00.y = sp128.y; + ptr[i].unk_00.z = sp128.z; + + temp_f0 = sqrtf(SQ(sp128.x - sp140.x) + SQ(sp128.y - sp140.y) + SQ(sp128.z - sp140.z)); + + if (temp_f0 < (temp_f26 * 0.9f)) { + ptr[i].unk_50 = 0xFF; + } else if (temp_f26 < temp_f0) { + ptr[i].unk_50 = 0; + } else { + ptr[i].unk_50 = (s32)((10.0f - ((10.0f / temp_f26) * temp_f0)) * 255.0f); + } + + sp11C.x = (shieldMf->mf[0][0] * 100.0f) + sp140.x; + sp11C.y = (shieldMf->mf[0][1] * 100.0f) + sp140.y; + sp11C.z = (shieldMf->mf[0][2] * 100.0f) + sp140.z; + + sp110.x = (spF8[0] * 4.0f) + sp11C.x; + sp110.y = (spF8[1] * 4.0f) + sp11C.y; + sp110.z = (spF8[2] * 4.0f) + sp11C.z; + + ptr[i].unk_0C.mf[0][0] = ptr[i].unk_0C.mf[1][1] = ptr[i].unk_0C.mf[2][2] = ptr[i].unk_0C.mf[3][3] = + 1.0f; + + ptr[i].unk_0C.mf[0][1] = ptr[i].unk_0C.mf[0][2] = ptr[i].unk_0C.mf[0][3] = ptr[i].unk_0C.mf[1][0] = + ptr[i].unk_0C.mf[1][2] = ptr[i].unk_0C.mf[1][3] = ptr[i].unk_0C.mf[2][0] = ptr[i].unk_0C.mf[2][1] = + ptr[i].unk_0C.mf[2][3] = ptr[i].unk_0C.mf[3][0] = ptr[i].unk_0C.mf[3][1] = + ptr[i].unk_0C.mf[3][2] = 0.0f; + + if (Math3D_LineSegVsPlane(spEC[0], spEC[1], spEC[2], ptr[i].unk_4C->dist, &sp11C, &sp110, &sp104, + true)) { + ptr[i].unk_0C.mf[0][0] = sp104.x - sp128.x; + ptr[i].unk_0C.mf[0][1] = sp104.y - sp128.y; + ptr[i].unk_0C.mf[0][2] = sp104.z - sp128.z; + } + + sp11C.x = (shieldMf->mf[1][0] * 100.0f) + sp140.x; + sp11C.y = (shieldMf->mf[1][1] * 100.0f) + sp140.y; + sp11C.z = (shieldMf->mf[1][2] * 100.0f) + sp140.z; + + sp110.x = (spF8[0] * 4.0f) + sp11C.x; + sp110.y = (spF8[1] * 4.0f) + sp11C.y; + sp110.z = (spF8[2] * 4.0f) + sp11C.z; + + if (Math3D_LineSegVsPlane(spEC[0], spEC[1], spEC[2], ptr[i].unk_4C->dist, &sp11C, &sp110, &sp104, + true)) { + ptr[i].unk_0C.mf[1][0] = sp104.x - sp128.x; + ptr[i].unk_0C.mf[1][1] = sp104.y - sp128.y; + ptr[i].unk_0C.mf[1][2] = sp104.z - sp128.z; + } + } else { + ptr[i].unk_4C = NULL; + } + } + } + + temp_f2 = this->unk_214 * 400.0f; + + spF8[0] = -(this->unk_260 * shieldMf->mf[2][0]); + spF8[1] = -(this->unk_260 * shieldMf->mf[2][1]); + spF8[2] = -(this->unk_260 * shieldMf->mf[2][2]); + + sp134.x = (spF8[0] * temp_f2) + sp140.x; + sp134.y = (spF8[1] * temp_f2) + sp140.y; + sp134.z = (spF8[2] * temp_f2) + sp140.z; + + if (!BgCheck_AnyLineTest1(&globalCtx->colCtx, &sp140, &sp134, &sp128, &spC4, 1)) { + Math_Vec3f_Copy(&sp128, &sp134); + } + + sp128.x += spF8[0] * 5.0f; + sp128.y += spF8[1] * 5.0f; + sp128.z += spF8[2] * 5.0f; + + spD4.x = (shieldMf->mf[0][0] * 300.0f) + sp140.x; + spD4.y = (shieldMf->mf[0][1] * 300.0f) + sp140.y; + spD4.z = (shieldMf->mf[0][2] * 300.0f) + sp140.z; + + spC8.x = (shieldMf->mf[0][0] * 300.0f) + sp128.x; + spC8.y = (shieldMf->mf[0][1] * 300.0f) + sp128.y; + spC8.z = (shieldMf->mf[0][2] * 300.0f) + sp128.z; + + Collider_SetQuadVertices(&this->colliderQuad, &spD4, &sp140, &spC8, &sp128); +} +#else +void func_80B9E8D4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E8D4.s") #endif -extern ColliderQuadInit D_80B9F420; -extern ColliderCylinderInit D_80B9F470; +void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + MirRay3* this = THIS; + MirRay3Struct sp8C[6]; + Player* player = GET_PLAYER(globalCtx); + s32 i; + f32 temp; + u16 phi_a0; -extern UNK_TYPE D_060003F8; + if (!(this->unk_210 & 1) && func_8012405C(globalCtx)) { + Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); + func_80B9E544(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/MirRay3_Init.s") + if (this->unk_214 <= 0.1f) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/MirRay3_Destroy.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/MirRay3_Update.s") + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Scale(1.0f, 1.0f, this->unk_214, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E544.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E5F4.s") + if (MIRRAY3_GET_F(&this->actor) == MIRRAY3_F_1) { + phi_a0 = gSaveContext.save.time; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E7D0.s") + if (phi_a0 > CLOCK_TIME(12, 0)) { + phi_a0 = 0xFFFF - phi_a0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E8D4.s") + temp = (phi_a0 * (1.0f / 0x8000)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x78, 255, 255, 255, (u8)(s8)(100 * this->unk_214)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/MirRay3_Draw.s") + gDPSetEnvColor(POLY_XLU_DISP++, 218, 225, (u8)((100.0f * temp) + 105.0f), 255); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x78, 255, 255, 255, (u8)(s8)(100 * this->unk_214)); + gDPSetEnvColor(POLY_XLU_DISP++, 218, 225, 205, 255); + } + + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_mir_ray_Matanimheader_0003F8)); + + gSPDisplayList(POLY_XLU_DISP++, object_mir_ray_DL_000168); + + func_80B9E5F4(this, globalCtx, sp8C); + func_80B9E7D0(sp8C); + func_80B9E8D4(this, globalCtx, sp8C); + + if (sp8C[0].unk_4C == NULL) { + sp8C[0].unk_50 = 0; + } + + for (i = 1; i < ARRAY_COUNT(sp8C); i++) { + if ((sp8C[i].unk_4C != NULL) && (sp8C[0].unk_50 < sp8C[i].unk_50)) { + sp8C[0].unk_50 = sp8C[i].unk_50; + } + } + + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_DECAL2); + + for (i = 0; i < ARRAY_COUNT(sp8C); i++) { + if (sp8C[i].unk_4C != NULL) { + Matrix_InsertTranslation(sp8C[i].unk_00.x, sp8C[i].unk_00.y, sp8C[i].unk_00.z, MTXMODE_NEW); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + Matrix_InsertMatrix(&sp8C[i].unk_0C, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, sp8C[0].unk_50); + gSPDisplayList(POLY_XLU_DISP++, object_mir_ray_DL_0004B0); + } + } + + this->unk_210 |= 1; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h index 18510673d..7aecd111f 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h @@ -5,9 +5,18 @@ struct MirRay3; +#define MIRRAY3_GET_F(thisx) ((thisx)->params & 0xF) + +#define MIRRAY3_F_1 1 + typedef struct MirRay3 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x120]; + /* 0x144 */ ColliderQuad colliderQuad; + /* 0x1C4 */ ColliderCylinder colliderCylinder; + /* 0x210 */ u16 unk_210; + /* 0x214 */ f32 unk_214; + /* 0x218 */ Vec3f unk_218[6]; + /* 0x260 */ f32 unk_260; } MirRay3; // size = 0x264 extern const ActorInit Mir_Ray3_InitVars; From 6faf186a9560ae00d2a804f8818212d3ec637c6b Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Tue, 29 Mar 2022 14:33:32 -0700 Subject: [PATCH 175/257] En_Wallmas (Wallmaster) OK and documented. object_wallmaster documented (#731) * EnWallmas_Init and EnWallmas_Destroy OK * func_80874B88 OK * func_80874BE4 OK * func_80874D1C OK * func_80874DE8 OK * func_80874F14 OK * A bunch of small functions OK * A bunch of smaller functions OK again * func_808752CC OK * func_808758C8 OK * func_80875910 and func_8087596C OK * func_808756AC and func_8087571C OK * EnWallmas_Update OK * func_80875A74 OK * func_80874A88 and func_80874B04 OK * A bunch of functions OK * func_808759B8 and func_80875A0C * EnWallmas_Draw OK * func_808760A4 and func_80876118 OK * func_80875F04 OK * Use object symbols * Import data to C * Use generated reloc * Document object_wallmaster * Misc cleanup * Name the DrawDamageEffects variables * Name draw functions * Enum for damage values * Port function names from OoT * Last cleanup before PR * Respond to Elliptic's review * Respond to Elliptic's second review * gWallmasterWaitAnim -> gWallmasterIdleAnim * Change all EnWallmas to Wallmaster (except the actor's name itself) * Respond to hensldm's review * Fix merge conflicts --- assets/xml/objects/object_wallmaster.xml | 130 +-- spec | 3 +- .../actors/ovl_En_Floormas/z_en_floormas.c | 63 +- .../actors/ovl_En_Floormas/z_en_floormas.h | 5 +- src/overlays/actors/ovl_En_Pr2/z_en_pr2.c | 6 +- .../actors/ovl_En_Wallmas/z_en_wallmas.c | 787 +++++++++++++++--- .../actors/ovl_En_Wallmas/z_en_wallmas.h | 46 +- tools/disasm/functions.txt | 66 +- tools/disasm/variables.txt | 5 +- undefined_syms.txt | 14 - 10 files changed, 862 insertions(+), 263 deletions(-) diff --git a/assets/xml/objects/object_wallmaster.xml b/assets/xml/objects/object_wallmaster.xml index d6ab1aa02..fba2bc246 100644 --- a/assets/xml/objects/object_wallmaster.xml +++ b/assets/xml/objects/object_wallmaster.xml @@ -1,63 +1,75 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index 3ba626c71..bbf6420cc 100644 --- a/spec +++ b/spec @@ -800,8 +800,7 @@ beginseg name "ovl_En_Wallmas" compress include "build/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.o" - include "build/data/ovl_En_Wallmas/ovl_En_Wallmas.data.o" - include "build/data/ovl_En_Wallmas/ovl_En_Wallmas.reloc.o" + include "build/src/overlays/actors/ovl_En_Wallmas/ovl_En_Wallmas_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index ce5928004..489d46441 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -5,7 +5,6 @@ */ #include "z_en_floormas.h" -#include "objects/object_wallmaster/object_wallmaster.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) @@ -154,8 +153,8 @@ void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 50.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_wallmaster_Skel_008FB0, &object_wallmaster_Anim_009DB0, - this->jointTable, this->morphTable, 25); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWallmasterSkel, &gWallmasterIdleAnim, this->jointTable, + this->morphTable, WALLMASTER_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -259,7 +258,7 @@ void func_808D0A48(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D0B08(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009DB0); + Animation_PlayOnce(&this->skelAnime, &gWallmasterIdleAnim); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D0B50; } @@ -278,7 +277,7 @@ void func_808D0B50(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D0C14(EnFloormas* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_wallmaster_Anim_00A054, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterStandUpAnim, -3.0f); this->actionFunc = func_808D0C58; } @@ -296,7 +295,7 @@ void func_808D0C58(EnFloormas* this, GlobalContext* globalCtx) { void func_808D0CE4(EnFloormas* this) { if (this->actionFunc != func_808D0F80) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &object_wallmaster_Anim_0041F4, 1.5f); + Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 1.5f); } else { this->skelAnime.playSpeed = 1.5f; } @@ -334,7 +333,7 @@ void func_808D0D70(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D0ECC(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009244); + Animation_PlayOnce(&this->skelAnime, &gWallmasterStopWalkAnim); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D0F14; } @@ -373,10 +372,10 @@ void func_808D108C(EnFloormas* this) { this->actor.speedXZ = 0.0f; if (sp36 > 0) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_wallmaster_Anim_002158, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gFloormasterTurnAnim, -3.0f); } else { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_002158, -1.0f, - Animation_GetLastFrame(&object_wallmaster_Anim_002158.common), 0.0f, 2, -3.0f); + Animation_Change(&this->skelAnime, &gFloormasterTurnAnim, -1.0f, Animation_GetLastFrame(&gFloormasterTurnAnim), + 0.0f, ANIMMODE_ONCE, -3.0f); } if (this->actor.scale.x > 0.009f) { @@ -418,8 +417,8 @@ void func_808D11BC(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1380(EnFloormas* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_009520, 3.0f, 0.0f, - Animation_GetLastFrame(&object_wallmaster_Anim_009520.common), 2, -3.0f); + Animation_Change(&this->skelAnime, &gWallmasterHoverAnim, 3.0f, 0.0f, Animation_GetLastFrame(&gWallmasterHoverAnim), + ANIMMODE_ONCE, -3.0f); this->actor.speedXZ = 0.0f; this->actor.gravity = 0.0f; func_808D08D0(this); @@ -492,7 +491,7 @@ void func_808D1650(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1740(EnFloormas* this) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 1.0f, 41.0f, 42.0f, 2, 5.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, 42.0f, ANIMMODE_ONCE, 5.0f); if ((this->actor.speedXZ < 0.0f) || (this->actionFunc != func_808D1650)) { this->unk_18E = 30; } else { @@ -538,7 +537,7 @@ void func_808D17EC(EnFloormas* this, GlobalContext* globalCtx) { if ((this->unk_18E == 0) && (sp24 != 0)) { if (this->skelAnime.endFrame < 45.0f) { - this->skelAnime.endFrame = Animation_GetLastFrame(&object_wallmaster_Anim_0019CC.common); + this->skelAnime.endFrame = Animation_GetLastFrame(&gWallmasterJumpAnim); } else if (this->actor.params == ENFLOORMAS_GET_7FFF_40) { func_808D2700(this); } else { @@ -569,8 +568,8 @@ void func_808D19D4(EnFloormas* this) { this->actor.shape.rot.y = parent->shape.rot.y + 0x5555; this->actor.world.pos = parent->world.pos; this->actor.params = ENFLOORMAS_GET_7FFF_10; - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 1.0f, 41.0f, - Animation_GetLastFrame(&object_wallmaster_Anim_0019CC.common), 2, 0.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), + ANIMMODE_ONCE, 0.0f); this->collider.dim.radius = sCylinderInit.dim.radius * 0.6f; this->collider.dim.height = sCylinderInit.dim.height * 0.6f; this->actor.flags &= ~ACTOR_FLAG_400; @@ -596,7 +595,7 @@ void func_808D1B44(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1BCC(EnFloormas* this) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &object_wallmaster_Anim_0041F4, 4.5f); + Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 4.5f); this->actor.speedXZ = 5.0f; this->actionFunc = func_808D1C1C; } @@ -623,7 +622,7 @@ void func_808D1C1C(EnFloormas* this, GlobalContext* globalCtx) { void func_808D1D0C(EnFloormas* this) { if (this->actionFunc != func_808D1C1C) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &object_wallmaster_Anim_0041F4, 4.5f); + Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 4.5f); } this->actor.speedXZ = 5.0f; this->actionFunc = func_808D1D6C; @@ -686,7 +685,7 @@ void func_808D1F7C(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1FD4(EnFloormas* this) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 2.0f, 0.0f, 41.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 2.0f, 0.0f, 41.0f, ANIMMODE_ONCE, 0.0f); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D2040; } @@ -716,7 +715,7 @@ void func_808D217C(EnFloormas* this, Player* player) { Vec3f* ptr; u8 playerForm; - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 1.0f, 36.0f, 45.0f, 2, -3.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 36.0f, 45.0f, ANIMMODE_ONCE, -3.0f); this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; @@ -772,7 +771,7 @@ void func_808D22C8(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2484(EnFloormas* this) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 2.0f, 0.0f, 41.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 2.0f, 0.0f, 41.0f, ANIMMODE_ONCE, 0.0f); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D24F0; } @@ -816,7 +815,7 @@ void func_808D24F0(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2700(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009DB0); + Animation_PlayOnce(&this->skelAnime, &gWallmasterIdleAnim); this->unk_18E = 0; this->unk_194 = 1500; this->actor.params = ENFLOORMAS_GET_7FFF_40; @@ -881,10 +880,10 @@ void func_808D2764(EnFloormas* this, GlobalContext* globalCtx) { this->actor.colChkInfo.health = sColChkInfoInit.health; func_808D0C14(this); } else if (this->unk_18E == 0) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_0039B0); + Animation_PlayOnce(&this->skelAnime, &gFloormasterTapFingerAnim); this->unk_18E = 1; } else { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009DB0); + Animation_PlayOnce(&this->skelAnime, &gWallmasterIdleAnim); this->unk_18E = 0; } } @@ -924,7 +923,7 @@ void func_808D2AF4(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2B18(EnFloormas* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_wallmaster_Anim_000590, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterDamageAnim, -3.0f); func_800BE504(&this->actor, &this->collider); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); this->actor.speedXZ = 5.0f; @@ -967,7 +966,7 @@ void func_808D2C08(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2CDC(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_000EA4); + Animation_PlayOnce(&this->skelAnime, &gWallmasterRecoverFromDamageAnim); this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -1151,9 +1150,10 @@ s32 EnFloormas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d Actor* thisx, Gfx** gfx) { EnFloormas* this = THIS; - if (limbIndex == 1) { + if (limbIndex == WALLMASTER_LIMB_ROOT) { pos->z += this->unk_192; } + return false; } @@ -1165,13 +1165,10 @@ void EnFloormas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis Matrix_GetStateTranslation(&this->limbPos[D_808D393C[limbIndex]]); } - if (limbIndex == 19) { + if (limbIndex == WALLMASTER_LIMB_WRIST) { Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[9]); Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->limbPos[10]); - return; - } - - if (limbIndex == 2) { + } else if (limbIndex == WALLMASTER_LIMB_HAND) { Matrix_StatePush(); Matrix_InsertTranslation(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); Matrix_InsertYRotation_f(M_PI / 3, MTXMODE_APPLY); @@ -1179,7 +1176,7 @@ void EnFloormas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList((*gfx)++, object_wallmaster_DL_008688); + gSPDisplayList((*gfx)++, gWallmasterLittleFingerDL); Matrix_StatePop(); } diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h index 7cf52edc3..5c33ba886 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h @@ -2,6 +2,7 @@ #define Z_EN_FLOORMAS_H #include "global.h" +#include "objects/object_wallmaster/object_wallmaster.h" struct EnFloormas; @@ -26,8 +27,8 @@ typedef struct EnFloormas { /* 0x0190 */ s16 unk_190; /* 0x0192 */ s16 unk_192; /* 0x0194 */ s16 unk_194; - /* 0x0196 */ Vec3s jointTable[25]; - /* 0x022C */ Vec3s morphTable[25]; + /* 0x0196 */ Vec3s jointTable[WALLMASTER_LIMB_MAX]; + /* 0x022C */ Vec3s morphTable[WALLMASTER_LIMB_MAX]; /* 0x02C4 */ f32 drawDmgEffAlpha; /* 0x02C8 */ f32 drawDmgEffScale; /* 0x02CC */ f32 drawDmgEffFrozenSteamScale; 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 39f1e4f95..6bb60f174 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c @@ -186,10 +186,10 @@ void EnPr2_Destroy(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.parent != NULL) { - Actor* parent = this->actor.parent; + EnEncount1* encount1 = (EnEncount1*)this->actor.parent; - if ((parent->update != NULL) && (((EnEncount1*)parent)->unk_14E > 0)) { - ((EnEncount1*)parent)->unk_14E--; + if ((encount1->actor.update != NULL) && (encount1->unk_14E > 0)) { + encount1->unk_14E--; } } } diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c index 0bdb51729..1b88d692b 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c @@ -5,6 +5,8 @@ */ #include "z_en_wallmas.h" +#include "overlays/actors/ovl_En_Encount1/z_en_encount1.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) @@ -15,22 +17,32 @@ void EnWallmas_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWallmas_Update(Actor* thisx, GlobalContext* globalCtx); void EnWallmas_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80874BE4(EnWallmas* this, GlobalContext* globalCtx); -void func_80874DE8(EnWallmas* this, GlobalContext* globalCtx); -void func_80874FD8(EnWallmas* this, GlobalContext* globalCtx); -void func_80875054(EnWallmas* this, GlobalContext* globalCtx); -void func_80875108(EnWallmas* this, GlobalContext* globalCtx); -void func_8087520C(EnWallmas* this, GlobalContext* globalCtx); -void func_808752CC(EnWallmas* this, GlobalContext* globalCtx); -void func_80875484(EnWallmas* this, GlobalContext* globalCtx); -void func_8087556C(EnWallmas* this, GlobalContext* globalCtx); -void func_80875638(EnWallmas* this, GlobalContext* globalCtx); -void func_8087571C(EnWallmas* this, GlobalContext* globalCtx); -void func_80875910(EnWallmas* this, GlobalContext* globalCtx); -void func_8087596C(EnWallmas* this, GlobalContext* globalCtx); -void func_80875A0C(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_TimerInit(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_WaitToDrop(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupDrop(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Drop(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupLand(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Land(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupStand(EnWallmas* this); +void EnWallmas_Stand(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupWalk(EnWallmas* this); +void EnWallmas_Walk(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupJumpToCeiling(EnWallmas* this); +void EnWallmas_JumpToCeiling(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupReturnToCeiling(EnWallmas* this); +void EnWallmas_ReturnToCeiling(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Damage(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupCooldown(EnWallmas* this); +void EnWallmas_Cooldown(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupDie(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Die(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupTakePlayer(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_TakePlayer(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_ProximityOrSwitchInit(EnWallmas* this); +void EnWallmas_WaitForProximity(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_WaitForSwitchFlag(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Stun(EnWallmas* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Wallmas_InitVars = { ACTOR_EN_WALLMAS, ACTORCAT_ENEMY, @@ -43,147 +55,704 @@ const ActorInit En_Wallmas_InitVars = { (ActorFunc)EnWallmas_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80876360 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_8087638C = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(1, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(1, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xF), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(1, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ WALLMASTER_DMGEFF_NONE, + /* 0x1 */ WALLMASTER_DMGEFF_STUN, + /* 0x2 */ WALLMASTER_DMGEFF_FIRE_ARROW, + /* 0x3 */ WALLMASTER_DMGEFF_ICE_ARROW, + /* 0x4 */ WALLMASTER_DMGEFF_LIGHT_ARROW, + /* 0x5 */ WALLMASTER_DMGEFF_ZORA_MAGIC, + /* 0xF */ WALLMASTER_DMGEFF_HOOKSHOT = 0xF +} EnWallmasDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, WALLMASTER_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, WALLMASTER_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, WALLMASTER_DMGEFF_FIRE_ARROW), + /* Ice arrow */ DMG_ENTRY(1, WALLMASTER_DMGEFF_ICE_ARROW), + /* Light arrow */ DMG_ENTRY(2, WALLMASTER_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(0, WALLMASTER_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, WALLMASTER_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, WALLMASTER_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808763AC = { 3, 30, 40, 150 }; +static CollisionCheckInfoInit sColChkInfoInit = { 3, 30, 40, 150 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808763B4[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 48, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 5500, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1500, ICHAIN_STOP), }; -#endif +static f32 sYOffsetPerForm[] = { 50.0f, 55.0f, 50.0f, 20.0f, 30.0f }; -extern ColliderCylinderInit D_80876360; -extern DamageTable D_8087638C; -extern CollisionCheckInfoInit D_808763AC; -extern InitChainEntry D_808763B4[]; +/** + * This maps a given limb based on its limbIndex to its appropriate index + * in the limbPos array. An index of -1 indicates that the limb is not part + * of the limbPos array. + */ +static s8 sLimbIndexToLimbPosIndex[] = { + -1, -1, -1, -1, 0, -1, -1, 1, -1, 2, -1, -1, 3, -1, 4, -1, -1, 5, -1, -1, -1, 6, 7, -1, 8, +}; -extern UNK_TYPE D_06000590; -extern UNK_TYPE D_06000EA4; -extern UNK_TYPE D_060019CC; -extern UNK_TYPE D_0600299C; -extern UNK_TYPE D_060041F4; -extern UNK_TYPE D_06008688; -extern UNK_TYPE D_06009244; -extern UNK_TYPE D_06009520; -extern UNK_TYPE D_06009DB0; -extern UNK_TYPE D_0600A054; +void EnWallmas_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.5f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWallmasterSkel, &gWallmasterIdleAnim, this->jointTable, + this->morphTable, WALLMASTER_LIMB_MAX); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Destroy.s") + this->switchFlag = WALLMASTER_GET_SWITCH_FLAG(thisx); + this->actor.params &= 0xFF; + this->detectionRadius = this->actor.shape.rot.x * 40.0f * 0.1f; + this->actor.shape.rot.x = 0; + this->actor.world.rot.x = 0; + if (this->detectionRadius <= 0.0f) { + this->detectionRadius = 200.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874A88.s") + Actor_SetFocus(&this->actor, 25.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874B04.s") + if (WALLMASTER_IS_FROZEN(&this->actor)) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, + this->actor.world.pos.y - 15.0f, this->actor.world.pos.z, this->actor.world.rot.x, + (this->actor.world.rot.y + 0x5900), this->actor.world.rot.z, 0xFF50); + this->actor.params &= ~0x80; + EnWallmas_SetupReturnToCeiling(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874B88.s") + if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_FLAG) { + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874BE4.s") + EnWallmas_ProximityOrSwitchInit(this); + } else if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_PROXIMITY) { + EnWallmas_ProximityOrSwitchInit(this); + } else { + EnWallmas_TimerInit(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874D1C.s") +void EnWallmas_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874DE8.s") + Collider_DestroyCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874F14.s") + if (this->actor.parent != NULL) { + EnEncount1* encount1 = (EnEncount1*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874FD8.s") + if ((encount1->actor.update != NULL) && (encount1->unk_14E > 0)) { + encount1->unk_14E--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875014.s") +void EnWallmas_Freeze(EnWallmas* this) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; + this->drawDmgEffAlpha = 1.0f; + this->collider.base.colType = 3; + this->timer = 80; + this->actor.flags &= ~ACTOR_FLAG_400; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875054.s") +void EnWallmas_ThawIfFrozen(EnWallmas* this, GlobalContext* globalCtx) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->collider.base.colType = 0; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 11, 2, 0.3f, 0.2f); + this->actor.flags |= ACTOR_FLAG_400; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808750B8.s") +void EnWallmas_TimerInit(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875108.s") + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_20; + this->timer = 130; + this->actor.velocity.y = 0.0f; + this->actor.world.pos.y = player->actor.world.pos.y; + this->actor.floorHeight = player->actor.floorHeight; + this->actor.draw = EnWallmas_Draw; + this->actionFunc = EnWallmas_WaitToDrop; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808751C4.s") +void EnWallmas_WaitToDrop(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f* playerPos = &player->actor.world.pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087520C.s") + this->actor.world.pos = *playerPos; + this->actor.floorHeight = player->actor.floorHeight; + this->actor.floorPoly = player->actor.floorPoly; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875248.s") + if (this->timer != 0) { + this->timer--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808752CC.s") + if ((player->stateFlags1 & 0x08100000) || (player->stateFlags2 & 0x80) || (player->unk_B5E > 0) || + (player->actor.freezeTimer > 0) || !(player->actor.bgCheckFlags & 1) || + ((WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_PROXIMITY) && + (Math_Vec3f_DistXZ(&this->actor.home.pos, playerPos) > (120.f + this->detectionRadius)))) { + func_801A75E8(NA_SE_EN_FALL_AIM); + this->timer = 130; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808753F0.s") + if (this->timer == 80) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_AIM); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875484.s") + if (this->timer == 0) { + EnWallmas_SetupDrop(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875518.s") +void EnWallmas_SetupDrop(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087556C.s") + Animation_Change(&this->skelAnime, &gWallmasterLungeAnim, 0.0f, 20.0f, + Animation_GetLastFrame(&gWallmasterLungeAnim), ANIMMODE_ONCE, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808755A8.s") + this->yTarget = player->actor.world.pos.y; + this->actor.world.pos.y = player->actor.world.pos.y + 300.0f; + this->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.floorHeight = player->actor.floorHeight; + this->actor.flags |= ACTOR_FLAG_1; + this->actor.flags &= ~ACTOR_FLAG_20; + this->actionFunc = EnWallmas_Drop; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875638.s") +void EnWallmas_Drop(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808756AC.s") + if ((player->stateFlags2 & 0x80) || (player->actor.freezeTimer > 0)) { + EnWallmas_SetupReturnToCeiling(this); + } else if (!Play_InCsMode(globalCtx) && !(player->stateFlags2 & 0x10) && (player->invincibilityTimer >= 0) && + (this->actor.xzDistToPlayer < 30.0f) && (this->actor.playerHeightRel < -5.0f) && + (-(f32)(player->cylinder.dim.height + 10) < this->actor.playerHeightRel)) { + EnWallmas_SetupTakePlayer(this, globalCtx); + } else if (this->actor.world.pos.y <= this->yTarget) { + this->actor.world.pos.y = this->yTarget; + this->actor.velocity.y = 0.0f; + EnWallmas_SetupLand(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087571C.s") +void EnWallmas_SetupLand(EnWallmas* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), + ANIMMODE_ONCE, -3.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808758C8.s") + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 15.0f, 6, 20.0f, 300, 100, true); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_LAND); + this->actionFunc = EnWallmas_Land; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875910.s") +void EnWallmas_Land(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupStand(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087596C.s") +void EnWallmas_SetupStand(EnWallmas* this) { + Animation_PlayOnce(&this->skelAnime, &gWallmasterStandUpAnim); + this->actionFunc = EnWallmas_Stand; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808759B8.s") +void EnWallmas_Stand(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupWalk(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875A0C.s") + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 0xB6); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875A74.s") +void EnWallmas_SetupWalk(EnWallmas* this) { + Animation_PlayOnceSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 3.0f); + this->actor.speedXZ = 3.0f; + this->actionFunc = EnWallmas_Walk; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Update.s") +void EnWallmas_Walk(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupJumpToCeiling(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875F04.s") + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 0xB6); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f) || + Animation_OnFrame(&this->skelAnime, 24.0f) || Animation_OnFrame(&this->skelAnime, 36.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_WALK); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808760A4.s") +void EnWallmas_SetupJumpToCeiling(EnWallmas* this) { + Animation_PlayOnce(&this->skelAnime, &gWallmasterStopWalkAnim); + this->actor.speedXZ = 0.0f; + this->actionFunc = EnWallmas_JumpToCeiling; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80876118.s") +void EnWallmas_JumpToCeiling(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupReturnToCeiling(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Draw.s") +void EnWallmas_SetupReturnToCeiling(EnWallmas* this) { + this->timer = 0; + this->actor.speedXZ = 0.0f; + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 3.0f, 0.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), + ANIMMODE_ONCE, -3.0f); + this->actionFunc = EnWallmas_ReturnToCeiling; +} + +void EnWallmas_ReturnToCeiling(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&this->skelAnime); + if (this->skelAnime.curFrame > 20.0f) { + this->actor.world.pos.y += 30.0f; + this->timer += 9; + this->actor.flags &= ~ACTOR_FLAG_2000; + } + + if (Animation_OnFrame(&this->skelAnime, 20.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_UP); + } + + if (this->actor.playerHeightRel < -900.0f) { + if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_FLAG) { + Actor_MarkForDeath(&this->actor); + return; + } + + if ((WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_TIMER_ONLY) || + (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < this->detectionRadius)) { + EnWallmas_TimerInit(this, globalCtx); + } else { + EnWallmas_ProximityOrSwitchInit(this); + } + } +} + +void EnWallmas_SetupDamage(EnWallmas* this, s32 arg1) { + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterDamageAnim, -3.0f); + + if (arg1) { + func_800BE504(&this->actor, &this->collider); + } + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->actor.speedXZ = 5.0f; + this->actor.velocity.y = 10.0f; + this->actionFunc = EnWallmas_Damage; +} + +void EnWallmas_Damage(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->actor.colChkInfo.health == 0) { + EnWallmas_SetupDie(this, globalCtx); + } else { + EnWallmas_SetupCooldown(this); + } + } + + if (Animation_OnFrame(&this->skelAnime, 13.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + } + + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); +} + +void EnWallmas_SetupCooldown(EnWallmas* this) { + Animation_PlayOnce(&this->skelAnime, &gWallmasterRecoverFromDamageAnim); + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnWallmas_Cooldown; +} + +void EnWallmas_Cooldown(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupReturnToCeiling(this); + } +} + +void EnWallmas_SetupDie(EnWallmas* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + func_800B3030(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 250, -10, 2); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + this->actionFunc = EnWallmas_Die; +} + +void EnWallmas_Die(EnWallmas* this, GlobalContext* globalCtx) { + if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.0015f)) { + Actor_SetScale(&this->actor, 0.01f); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); + Actor_MarkForDeath(&this->actor); + } + + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = this->actor.scale.x; +} + +void EnWallmas_SetupTakePlayer(EnWallmas* this, GlobalContext* globalCtx) { + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterHoverAnim, -5.0f); + this->timer = -30; + this->actionFunc = EnWallmas_TakePlayer; + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + this->yTarget = this->actor.playerHeightRel; + func_800B724C(globalCtx, &this->actor, 18); +} + +void EnWallmas_TakePlayer(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Animation_OnFrame(&this->skelAnime, 1.0f)) { + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_CATCH); + } + + if (SkelAnime_Update(&this->skelAnime)) { + player->actor.world.pos.x = this->actor.world.pos.x; + player->actor.world.pos.z = this->actor.world.pos.z; + + if (this->timer < 0) { + this->actor.world.pos.y += 2.0f; + } else { + this->actor.world.pos.y += 10.0f; + } + + player->actor.world.pos.y = this->actor.world.pos.y - sYOffsetPerForm[((void)0, gSaveContext.save.playerForm)]; + if (this->timer == -30) { + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_TAKEN_AWAY); + } + + if (this->timer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_UP); + } + + this->timer += 2; + } else { + Math_StepToF(&this->actor.world.pos.y, + sYOffsetPerForm[((void)0, gSaveContext.save.playerForm)] + player->actor.world.pos.y, 5.0f); + } + + Math_StepToF(&this->actor.world.pos.x, player->actor.world.pos.x, 3.0f); + Math_StepToF(&this->actor.world.pos.z, player->actor.world.pos.z, 3.0f); + + if (this->timer == 30) { + play_sound(NA_SE_OC_ABYSS); + func_80169FDC(&globalCtx->state); + } +} + +void EnWallmas_ProximityOrSwitchInit(EnWallmas* this) { + this->timer = 0; + this->actor.draw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_PROXIMITY) { + this->actionFunc = EnWallmas_WaitForProximity; + } else { + this->actionFunc = EnWallmas_WaitForSwitchFlag; + } +} + +void EnWallmas_WaitForProximity(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < this->detectionRadius) { + EnWallmas_TimerInit(this, globalCtx); + } +} + +void EnWallmas_WaitForSwitchFlag(EnWallmas* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + EnWallmas_TimerInit(this, globalCtx); + this->timer = 81; + } +} + +void EnWallmas_SetupStun(EnWallmas* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + + func_800BE504(&this->actor, &this->collider); + this->actionFunc = EnWallmas_Stun; +} + +void EnWallmas_Stun(EnWallmas* this, GlobalContext* globalCtx) { + if (this->timer != 0) { + this->timer--; + } + + if (this->timer == 0) { + EnWallmas_ThawIfFrozen(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + EnWallmas_SetupDamage(this, false); + } else { + this->actor.world.rot.y = this->actor.shape.rot.y; + EnWallmas_SetupReturnToCeiling(this); + } + } +} + +void EnWallmas_UpdateDamage(EnWallmas* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&this->actor, &this->collider.info); + + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + (!(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIOCTA_REVERSE); + this->actor.flags &= ~ACTOR_FLAG_1; + } else if (this->actor.colChkInfo.damage != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_DAMAGE); + } + + EnWallmas_ThawIfFrozen(this, globalCtx); + + if (this->actor.colChkInfo.damageEffect != WALLMASTER_DMGEFF_HOOKSHOT) { + if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_ICE_ARROW) { + EnWallmas_Freeze(this); + if (this->actor.colChkInfo.health == 0) { + this->timer = 3; + this->collider.base.acFlags &= ~AC_ON; + } + + EnWallmas_SetupStun(this); + } else if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_STUN) { + this->timer = 40; + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + EnWallmas_SetupStun(this); + } else if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_ZORA_MAGIC) { + this->timer = 40; + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; + EnWallmas_SetupStun(this); + } else { + if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_FIRE_ARROW) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } else if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_LIGHT_ARROW) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, + this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + + EnWallmas_SetupDamage(this, true); + } + } + } + } +} + +void EnWallmas_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnWallmas* this = THIS; + + EnWallmas_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + + if ((this->actionFunc != EnWallmas_WaitToDrop) && (this->actionFunc != EnWallmas_WaitForProximity) && + (this->actionFunc != EnWallmas_TakePlayer) && (this->actionFunc != EnWallmas_WaitForSwitchFlag)) { + if ((this->actionFunc != EnWallmas_ReturnToCeiling) && (this->actionFunc != EnWallmas_TakePlayer)) { + Actor_MoveWithGravity(&this->actor); + } + + if (this->actionFunc != EnWallmas_Drop) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 25.0f, 0.0f, 0x1DU); + } + + if ((this->actionFunc != EnWallmas_Die) && (this->actionFunc != EnWallmas_Drop)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if ((this->actionFunc != EnWallmas_Damage) && (this->actor.bgCheckFlags & 1) && + (this->actor.freezeTimer == 0)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } + + Actor_SetFocus(&this->actor, 25.0f); + + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if (Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f) == 0) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + } +} + +void EnWallmas_DrawShadow(EnWallmas* this, GlobalContext* globalCtx) { + s32 pad; + f32 xzScale; + MtxF mf; + Gfx* gfx; + + if ((this->actor.floorPoly != NULL) && ((this->timer < 81) || (this->actionFunc == EnWallmas_Stun))) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 44]); + gDPSetPrimColor(&gfx[1], 0, 0, 0, 0, 0, 255); + func_800C0094(this->actor.floorPoly, this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, + &mf); + Matrix_InsertMatrix(&mf, MTXMODE_NEW); + + if ((this->actionFunc != EnWallmas_WaitToDrop) && (this->actionFunc != EnWallmas_ReturnToCeiling) && + (this->actionFunc != EnWallmas_TakePlayer) && (this->actionFunc != EnWallmas_WaitForSwitchFlag)) { + xzScale = this->actor.scale.x * 50.0f; + } else { + xzScale = CLAMP_MAX(80 - this->timer, 80) * 0.00625f; + } + + Matrix_Scale(xzScale, 1.0f, xzScale, MTXMODE_APPLY); + gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[3], gCircleShadowDL); + + POLY_OPA_DISP = &gfx[4]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +s32 EnWallmas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnWallmas* this = THIS; + + if (limbIndex == WALLMASTER_LIMB_ROOT) { + if (this->actionFunc != EnWallmas_TakePlayer) { + pos->z -= 1600.0f; + } else { + pos->z -= (1600.0f * (this->skelAnime.endFrame - this->skelAnime.curFrame)) / this->skelAnime.endFrame; + } + } + + return false; +} + +void EnWallmas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnWallmas* this = THIS; + Gfx* gfx; + + if (sLimbIndexToLimbPosIndex[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->limbPos[sLimbIndexToLimbPosIndex[limbIndex]]); + } + + if (limbIndex == WALLMASTER_LIMB_WRIST) { + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[9]); + Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->limbPos[10]); + } else if (limbIndex == WALLMASTER_LIMB_HAND) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + Matrix_StatePush(); + Matrix_InsertTranslation(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); + Matrix_RotateY(0x2AAA, MTXMODE_APPLY); + Matrix_InsertZRotation_s(0xAAA, MTXMODE_APPLY); + Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); + + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], gWallmasterLittleFingerDL); + + POLY_OPA_DISP = &gfx[2]; + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnWallmas_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* this = THIS; + + if (this->actionFunc != EnWallmas_WaitToDrop) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnWallmas_OverrideLimbDraw, EnWallmas_PostLimbDraw, + &this->actor); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); + } + + if (this->actor.colorFilterTimer != 0) { + func_800AE5A0(globalCtx); + } + + EnWallmas_DrawShadow(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h index 1bd6fbe83..06d4d24d1 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h @@ -2,16 +2,54 @@ #define Z_EN_WALLMAS_H #include "global.h" +#include "objects/object_wallmaster/object_wallmaster.h" + +#define WALLMASTER_GET_TYPE(thisx) ((thisx)->params) +#define WALLMASTER_GET_SWITCH_FLAG(thisx) (((thisx)->params >> 8) & 0xFF) +#define WALLMASTER_IS_FROZEN(thisx) ((thisx)->params & 0x80) + +/** + * This type determines under what conditions the Wallmaster will drop from the ceiling. + * - WALLMASTER_TYPE_TIMER_ONLY: These Wallmasters don't check for anything to determine + * whether or not to drop; they just set a 130-frame timer and drop once it reaches 0. + * - WALLMASTER_TYPE_PROXIMITY: These Wallmasters ensure that the player in within a certain + * distance of their current position (as dictated by detectionRadius); once the player + * enters that range, they set a 130-frame timer and drop once it reaches 0. + * - WALLMASTER_TYPE_FLAG: These Wallmasters wait for a certain switch flag to be activated, + * as specified in their params. Once this switch is activated, they set an 81-frame timer + * and drop once it reaches 0. + * + * While in the "waiting to drop" state, all Wallmaster variations can be forced to reset the + * timer to 130 frames if the player enters certain states (e.g., if the player is no longer + * touching the ground). Additionally, WALLMASTER_TYPE_PROXIMITY-type Wallmasters will reset + * the timer to 130 frames if the player strays too far from the Wallmaster's current position. + */ +typedef enum { + /* 0x00 */ WALLMASTER_TYPE_TIMER_ONLY, + /* 0x01 */ WALLMASTER_TYPE_PROXIMITY, + /* 0x02 */ WALLMASTER_TYPE_FLAG +} WallmasterType; struct EnWallmas; typedef void (*EnWallmasActionFunc)(struct EnWallmas*, GlobalContext*); typedef struct EnWallmas { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnWallmasActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x218]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnWallmasActionFunc actionFunc; + /* 0x18C */ u8 drawDmgEffType; + /* 0x18E */ s16 timer; + /* 0x190 */ s16 switchFlag; + /* 0x192 */ Vec3s jointTable[WALLMASTER_LIMB_MAX]; + /* 0x228 */ Vec3s morphTable[WALLMASTER_LIMB_MAX]; + /* 0x2C0 */ f32 yTarget; + /* 0x2C4 */ f32 detectionRadius; + /* 0x2C8 */ f32 drawDmgEffAlpha; + /* 0x2CC */ f32 drawDmgEffScale; + /* 0x2D0 */ f32 drawDmgEffFrozenSteamScale; + /* 0x2D4 */ Vec3f limbPos[11]; + /* 0x358 */ ColliderCylinder collider; } EnWallmas; // size = 0x3A4 extern const ActorInit En_Wallmas_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 0ac959c7a..72fadfea5 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -5108,40 +5108,40 @@ 0x80872BC0:("func_80872BC0",), 0x80874810:("EnWallmas_Init",), 0x80874A28:("EnWallmas_Destroy",), - 0x80874A88:("func_80874A88",), - 0x80874B04:("func_80874B04",), - 0x80874B88:("func_80874B88",), - 0x80874BE4:("func_80874BE4",), - 0x80874D1C:("func_80874D1C",), - 0x80874DE8:("func_80874DE8",), - 0x80874F14:("func_80874F14",), - 0x80874FD8:("func_80874FD8",), - 0x80875014:("func_80875014",), - 0x80875054:("func_80875054",), - 0x808750B8:("func_808750B8",), - 0x80875108:("func_80875108",), - 0x808751C4:("func_808751C4",), - 0x8087520C:("func_8087520C",), - 0x80875248:("func_80875248",), - 0x808752CC:("func_808752CC",), - 0x808753F0:("func_808753F0",), - 0x80875484:("func_80875484",), - 0x80875518:("func_80875518",), - 0x8087556C:("func_8087556C",), - 0x808755A8:("func_808755A8",), - 0x80875638:("func_80875638",), - 0x808756AC:("func_808756AC",), - 0x8087571C:("func_8087571C",), - 0x808758C8:("func_808758C8",), - 0x80875910:("func_80875910",), - 0x8087596C:("func_8087596C",), - 0x808759B8:("func_808759B8",), - 0x80875A0C:("func_80875A0C",), - 0x80875A74:("func_80875A74",), + 0x80874A88:("EnWallmas_Freeze",), + 0x80874B04:("EnWallmas_ThawIfFrozen",), + 0x80874B88:("EnWallmas_TimerInit",), + 0x80874BE4:("EnWallmas_WaitToDrop",), + 0x80874D1C:("EnWallmas_SetupDrop",), + 0x80874DE8:("EnWallmas_Drop",), + 0x80874F14:("EnWallmas_SetupLand",), + 0x80874FD8:("EnWallmas_Land",), + 0x80875014:("EnWallmas_SetupStand",), + 0x80875054:("EnWallmas_Stand",), + 0x808750B8:("EnWallmas_SetupWalk",), + 0x80875108:("EnWallmas_Walk",), + 0x808751C4:("EnWallmas_SetupJumpToCeiling",), + 0x8087520C:("EnWallmas_JumpToCeiling",), + 0x80875248:("EnWallmas_SetupReturnToCeiling",), + 0x808752CC:("EnWallmas_ReturnToCeiling",), + 0x808753F0:("EnWallmas_SetupDamage",), + 0x80875484:("EnWallmas_Damage",), + 0x80875518:("EnWallmas_SetupCooldown",), + 0x8087556C:("EnWallmas_Cooldown",), + 0x808755A8:("EnWallmas_SetupDie",), + 0x80875638:("EnWallmas_Die",), + 0x808756AC:("EnWallmas_SetupTakePlayer",), + 0x8087571C:("EnWallmas_TakePlayer",), + 0x808758C8:("EnWallmas_ProximityOrSwitchInit",), + 0x80875910:("EnWallmas_WaitForProximity",), + 0x8087596C:("EnWallmas_WaitForSwitchFlag",), + 0x808759B8:("EnWallmas_SetupStun",), + 0x80875A0C:("EnWallmas_Stun",), + 0x80875A74:("EnWallmas_Update",), 0x80875CF4:("EnWallmas_Update",), - 0x80875F04:("func_80875F04",), - 0x808760A4:("func_808760A4",), - 0x80876118:("func_80876118",), + 0x80875F04:("EnWallmas_DrawShadow",), + 0x808760A4:("EnWallmas_OverrideLimbDraw",), + 0x80876118:("EnWallmas_PostLimbDraw",), 0x80876268:("EnWallmas_Draw",), 0x80876670:("EnDodongo_Init",), 0x808768D0:("EnDodongo_Destroy",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 2cce52fba..4fac6bb9e 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -5801,10 +5801,7 @@ 0x808763AC:("D_808763AC","UNK_TYPE1","",0x1), 0x808763B4:("D_808763B4","UNK_TYPE1","",0x1), 0x808763C0:("D_808763C0","UNK_TYPE1","",0x1), - 0x808763D4:("D_808763D4","UNK_TYPE1","",0x1), - 0x808763D6:("D_808763D6","UNK_TYPE1","",0x1), - 0x808763E6:("D_808763E6","UNK_TYPE1","",0x1), - 0x808763E7:("D_808763E7","UNK_TYPE1","",0x1), + 0x808763D4:("D_808763D4","s8","[25]",0x25), 0x808763F0:("D_808763F0","f32","",0x4), 0x808763F4:("D_808763F4","f32","",0x4), 0x808763F8:("D_808763F8","f32","",0x4), diff --git a/undefined_syms.txt b/undefined_syms.txt index 4807cfc11..28008293b 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1591,20 +1591,6 @@ D_0601A830 = 0x0601A830; D_060014C8 = 0x060014C8; D_06001C38 = 0x06001C38; -// ovl_En_Wallmas - -D_06000590 = 0x06000590; -D_06000EA4 = 0x06000EA4; -D_060019CC = 0x060019CC; -D_0600299C = 0x0600299C; -D_060041F4 = 0x060041F4; -D_06008688 = 0x06008688; -D_06008FB0 = 0x06008FB0; -D_06009244 = 0x06009244; -D_06009520 = 0x06009520; -D_06009DB0 = 0x06009DB0; -D_0600A054 = 0x0600A054; - // ovl_En_Wdhand D_060000F4 = 0x060000F4; From 89ecf74189852699bf21659248da4521680a2d77 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 29 Mar 2022 22:39:06 +0100 Subject: [PATCH 176/257] Obj_Bigicicle (#753) * Obj_Bigicicle * PR Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> --- spec | 3 +- .../ovl_Obj_Bigicicle/z_obj_bigicicle.c | 291 ++++++++++++++++-- .../ovl_Obj_Bigicicle/z_obj_bigicicle.h | 8 +- undefined_syms.txt | 5 - 4 files changed, 272 insertions(+), 35 deletions(-) diff --git a/spec b/spec index bbf6420cc..b24816b29 100644 --- a/spec +++ b/spec @@ -3623,8 +3623,7 @@ beginseg name "ovl_Obj_Bigicicle" compress include "build/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.o" - include "build/data/ovl_Obj_Bigicicle/ovl_Obj_Bigicicle.data.o" - include "build/data/ovl_Obj_Bigicicle/ovl_Obj_Bigicicle.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Bigicicle/ovl_Obj_Bigicicle_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c index 1995aacf9..b4a85a3a0 100644 --- a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c +++ b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c @@ -5,6 +5,8 @@ */ #include "z_obj_bigicicle.h" +#include "overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h" +#include "objects/object_bigicicle/object_bigicicle.h" #define FLAGS 0x00000000 @@ -21,7 +23,6 @@ void func_80AE9180(ObjBigicicle* this, GlobalContext* globalCtx); void func_80AE9258(ObjBigicicle* this, GlobalContext* globalCtx); void func_80AE939C(ObjBigicicle* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Bigicicle_InitVars = { ACTOR_OBJ_BIGICICLE, ACTORCAT_PROP, @@ -34,51 +35,287 @@ const ActorInit Obj_Bigicicle_InitVars = { (ActorFunc)ObjBigicicle_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AE9820 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00003820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00003820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 23, 68, -40, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AE984C = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 31, 90, -150, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AE9888[] = { +AnimatedMaterial* D_80AE9878 = object_bigicicle_Matanimheader_001678; + +Vec3f D_80AE987C = { 0.0f, -1.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(gravity, -2, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 5600, ICHAIN_STOP), }; -#endif +s32 D_80AE9890 = false; -extern ColliderCylinderInit D_80AE9820; -extern ColliderCylinderInit D_80AE984C; -extern InitChainEntry D_80AE9888[]; +Color_RGBA8 D_80AE9894 = { 250, 250, 250, 255 }; +Color_RGBA8 D_80AE9898 = { 180, 180, 180, 255 }; -extern UNK_TYPE D_060009B0; -extern UNK_TYPE D_060014F0; +Gfx* D_80AE989C[] = { object_bigicicle_DL_001D10, object_bigicicle_DL_002530, object_bigicicle_DL_002C20 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/ObjBigicicle_Init.s") +Gfx* D_80AE98A8[] = { + object_bigicicle_DL_000B20, + object_bigicicle_DL_000D60, + object_bigicicle_DL_000F40, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/ObjBigicicle_Destroy.s") +void ObjBigicicle_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjBigicicle* this = THIS; + f32 sp30; + s32 sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE8DE4.s") + Actor_ProcessInitChain(&this->actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE8FD4.s") + sp28 = OBJBIGICLE_GET_FF00(&this->actor); + if ((sp28 == 0) || (sp28 == 0xFF)) { + sp28 = 0x3C; + } + Actor_SetScale(&this->actor, sp28 * 0.001f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE9090.s") + this->actor.params &= 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + sp30 = sp28 * (1.0f / 60.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE9180.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); + this->collider1.dim.radius = this->collider1.dim.radius * sp30; + this->collider1.dim.height = this->collider1.dim.height * sp30; + this->collider1.dim.yShift = this->collider1.dim.yShift * sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE9258.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); + this->collider2.dim.radius = this->collider2.dim.radius * sp30; + this->collider2.dim.height = this->collider2.dim.height * sp30; + this->collider2.dim.yShift = this->collider2.dim.yShift * sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE939C.s") + if (Flags_GetSwitch(globalCtx, this->actor.params)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/ObjBigicicle_Update.s") + this->unk_148 = this->actor.shape.rot.x; + this->actor.shape.rot.x = 0x4000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/ObjBigicicle_Draw.s") + Collider_UpdateCylinder(&this->actor, &this->collider1); + Collider_UpdateCylinder(&this->actor, &this->collider2); + + if (!D_80AE9890) { + D_80AE9878 = Lib_SegmentedToVirtual(D_80AE9878); + D_80AE9890 = true; + } + + this->unk_149 = 0; + this->actionFunc = func_80AE8FD4; +} + +void ObjBigicicle_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjBigicicle* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider1); + Collider_DestroyCylinder(globalCtx, &this->collider2); +} + +void func_80AE8DE4(ObjBigicicle* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp98; + Vec3f sp8C; + f32 temp_f20 = this->actor.scale.x * (50.0f / 3.0f); + + for (i = 0; i < 10; i++) { + sp98.x = (randPlusMinusPoint5Scaled(4.0f) * temp_f20) + this->actor.world.pos.x; + sp98.y = ((Rand_ZeroFloat(20.0f) - 35.0f) * temp_f20) + this->actor.world.pos.y; + sp98.z = (randPlusMinusPoint5Scaled(4.0f) * temp_f20) + this->actor.world.pos.z; + + sp8C.x = randPlusMinusPoint5Scaled(13.0f); + sp8C.y = Rand_ZeroFloat(2.0f); + sp8C.z = randPlusMinusPoint5Scaled(13.0f); + + EffectSsHahen_Spawn(globalCtx, &sp98, &sp8C, &D_80AE987C, 2, (Rand_ZeroFloat(20.0f) + 30.0f) * temp_f20, + OBJECT_BIGICICLE, 0x28, object_bigicicle_DL_0009B0); + } + + sp98.x = this->actor.world.pos.x; + sp98.y = this->actor.world.pos.y - (25.0f * temp_f20); + sp98.z = this->actor.world.pos.z; + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &sp98, 40, NA_SE_EV_ICE_PIECE); +} + +void func_80AE8FD4(ObjBigicicle* this, GlobalContext* globalCtx) { + if ((this->collider1.base.acFlags & AC_HIT) || + ((this->collider2.base.acFlags & AC_HIT) && (this->collider2.info.acHitInfo->toucher.dmgFlags & 0x3820))) { + if ((this->unk_148 == 0) || (this->unk_149 == 1)) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = func_80AE9090; + return; + } + + func_80AE8DE4(this, globalCtx); + this->unk_149++; + this->unk_14A = 50; + this->actionFunc = func_80AE9180; + } +} + +void func_80AE9090(ObjBigicicle* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->unk_149++; + func_80AE8DE4(this, globalCtx); + if (this->unk_149 == 2) { + f32 temp_f0 = this->actor.scale.y * 2100.0f; + + this->actor.flags |= ACTOR_FLAG_10; + this->actor.shape.yOffset = 2100.0f; + this->actor.world.pos.y -= temp_f0; + this->collider1.dim.yShift += (s16)temp_f0; + this->collider2.dim.yShift += (s16)temp_f0; + this->actionFunc = func_80AE9258; + } else { + this->unk_14A = 50; + this->actionFunc = func_80AE9180; + } + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80AE9180(ObjBigicicle* this, GlobalContext* globalCtx) { + this->unk_14A--; + + if (this->unk_14A > 0) { + this->unk_14A--; + this->actor.shape.rot.x = BINANG_ADD((s32)(randPlusMinusPoint5Scaled(1408.0f) * 0.02f * this->unk_14A), 0x4000); + this->actor.shape.rot.z = randPlusMinusPoint5Scaled(1408.0f) * 0.02f * this->unk_14A; + } else { + this->actor.shape.rot.x = 0x4000; + this->actor.shape.rot.z = 0; + ActorCutscene_Stop(this->actor.cutscene); + this->actionFunc = func_80AE8FD4; + } +} + +void func_80AE9258(ObjBigicicle* this, GlobalContext* globalCtx) { + Actor* itemAction; + f32 temp_f0; + ObjIcePoly* icePoly; + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + + while (itemAction != NULL) { + if (itemAction->id == ACTOR_OBJ_ICE_POLY) { + icePoly = (ObjIcePoly*)itemAction; + temp_f0 = this->actor.world.pos.y - icePoly->actor.world.pos.y; + if ((temp_f0 < icePoly->colliders1[0].dim.height) && (temp_f0 > 0.0f) && + (Actor_XZDistanceBetweenActors(&this->actor, &icePoly->actor) < icePoly->colliders1[0].dim.radius)) { + Flags_SetSwitch(globalCtx, this->actor.params); + this->actionFunc = func_80AE939C; + return; + } + } + itemAction = itemAction->next; + } + + if (this->actor.bgCheckFlags & 1) { + this->actionFunc = func_80AE939C; + } else { + Collider_UpdateCylinder(&this->actor, &this->collider1); + Collider_UpdateCylinder(&this->actor, &this->collider2); + } +} + +void func_80AE939C(ObjBigicicle* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp98; + Vec3f sp8C; + f32 temp_f20 = this->actor.scale.x * (50.0f / 3.0f); + + for (i = 0; i < 20; i++) { + sp8C.x = randPlusMinusPoint5Scaled(15.0f); + sp8C.y = Rand_ZeroFloat(7.0f) + 3.0f; + sp8C.z = randPlusMinusPoint5Scaled(15.0f); + + sp98.x = this->actor.world.pos.x + (sp8C.x * 5.0f * temp_f20); + sp98.y = this->actor.world.pos.y + (sp8C.y * 7.0f * temp_f20); + sp98.z = this->actor.world.pos.z + (sp8C.z * 5.0f * temp_f20); + + EffectSsHahen_Spawn(globalCtx, &sp98, &sp8C, &D_80AE987C, 2, (Rand_ZeroFloat(30.0f) + 40.0f) * temp_f20, + OBJECT_BIGICICLE, 30, object_bigicicle_DL_0009B0); + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_GLASSBROKEN_IMPACT); + ActorCutscene_Stop(this->actor.cutscene); + Actor_MarkForDeath(&this->actor); +} + +void ObjBigicicle_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjBigicicle* this = THIS; + Vec3f sp44; + + this->actionFunc(this, globalCtx); + + if (Rand_ZeroOne() < 0.05f) { + sp44.x = (((215.0f + Rand_ZeroFloat(65.0f)) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)) * this->actor.scale.x) + + this->actor.world.pos.x; + sp44.y = ((((Rand_ZeroFloat(1400.0f) + -150.0f) - 2100.0f) + this->actor.shape.yOffset) * this->actor.scale.y) + + this->actor.world.pos.y; + sp44.z = (((215.0f + Rand_ZeroFloat(65.0f)) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)) * this->actor.scale.z) + + this->actor.world.pos.z; + + EffectSsKiraKira_SpawnDispersed(globalCtx, &sp44, &gZeroVec3f, &gZeroVec3f, &D_80AE9894, &D_80AE9898, 2000, 5); + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); +} + +void ObjBigicicle_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjBigicicle* this = THIS; + + Gfx_DrawDListXlu(globalCtx, D_80AE989C[this->unk_149]); + Gfx_DrawDListXlu(globalCtx, D_80AE98A8[this->unk_149]); + AnimatedMat_Draw(globalCtx, D_80AE9878); + Gfx_DrawDListXlu(globalCtx, object_bigicicle_DL_0014F0); +} diff --git a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h index 5c3235ef2..1744a81b4 100644 --- a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h +++ b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h @@ -7,10 +7,16 @@ struct ObjBigicicle; typedef void (*ObjBigicicleActionFunc)(struct ObjBigicicle*, GlobalContext*); +#define OBJBIGICLE_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + typedef struct ObjBigicicle { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjBigicicleActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x9C]; + /* 0x0148 */ u8 unk_148; + /* 0x0149 */ u8 unk_149; + /* 0x014A */ s16 unk_14A; + /* 0x014C */ ColliderCylinder collider1; + /* 0x0198 */ ColliderCylinder collider2; } ObjBigicicle; // size = 0x1E4 extern const ActorInit Obj_Bigicicle_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 28008293b..679f6ca1b 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1632,11 +1632,6 @@ D_06000168 = 0x06000168; D_060003F8 = 0x060003F8; D_060004B0 = 0x060004B0; -// ovl_Obj_Bigicicle - -D_060009B0 = 0x060009B0; -D_060014F0 = 0x060014F0; - // ovl_Obj_Boat D_06007630 = 0x06007630; From 33643b9471defc9cd3614929ca6b77a5fb862c38 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 29 Mar 2022 21:13:44 -0600 Subject: [PATCH 177/257] Obj_Hariko (#766) * Initial decompilation of hariko * Documented and touched up on ObjHariko header * Documented Hariko assets and added review suggestions * Added file comment, shuffled function order * Added DL suffix to hariko dlists * Updated hariko body out name to hariko_body --- assets/xml/objects/object_hariko.xml | 9 ++- spec | 3 +- .../actors/ovl_Obj_Hariko/z_obj_hariko.c | 78 +++++++++++++++---- .../actors/ovl_Obj_Hariko/z_obj_hariko.h | 5 +- undefined_syms.txt | 5 -- 5 files changed, 74 insertions(+), 26 deletions(-) diff --git a/assets/xml/objects/object_hariko.xml b/assets/xml/objects/object_hariko.xml index e0f139b88..5cb2d8328 100644 --- a/assets/xml/objects/object_hariko.xml +++ b/assets/xml/objects/object_hariko.xml @@ -1,8 +1,9 @@  + - - - - + + + + diff --git a/spec b/spec index b24816b29..c99b6bfa5 100644 --- a/spec +++ b/spec @@ -4092,8 +4092,7 @@ beginseg name "ovl_Obj_Hariko" compress include "build/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.o" - include "build/data/ovl_Obj_Hariko/ovl_Obj_Hariko.data.o" - include "build/data/ovl_Obj_Hariko/ovl_Obj_Hariko.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hariko/ovl_Obj_Hariko_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c index 0caec6ea4..f07b9c6d4 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c @@ -5,6 +5,7 @@ */ #include "z_obj_hariko.h" +#include "assets/objects/object_hariko/object_hariko.h" #define FLAGS (ACTOR_FLAG_20 | ACTOR_FLAG_2000000) @@ -15,10 +16,12 @@ void ObjHariko_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHariko_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHariko_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B66A90(ObjHariko* this, GlobalContext* globalCtx); -void func_80B66AC4(ObjHariko* this, GlobalContext* globalCtx); +void ObjHariko_SetupWait(ObjHariko* this); +void ObjHariko_Wait(ObjHariko* this, GlobalContext* globalCtx); +void ObjHariko_SetupBobHead(ObjHariko* this); +void ObjHariko_BobHead(ObjHariko* this, GlobalContext* globalCtx); +void ObjHariko_CheckForQuakes(ObjHariko* this); -#if 0 const ActorInit Obj_Hariko_InitVars = { ACTOR_OBJ_HARIKO, ACTORCAT_PROP, @@ -31,24 +34,71 @@ const ActorInit Obj_Hariko_InitVars = { (ActorFunc)ObjHariko_Draw, }; -#endif +void ObjHariko_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjHariko* this = THIS; -extern UNK_TYPE D_06000080; + Actor_SetScale(&this->actor, 0.1f); + this->headRotation.x = 0; + this->headRotation.y = 0; + this->headRotation.z = 0; + this->headOffset = 0; + this->bobbleStep = 0.0f; + ObjHariko_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/ObjHariko_Init.s") +void ObjHariko_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/ObjHariko_Destroy.s") +void ObjHariko_SetupWait(ObjHariko* this) { + this->actionFunc = ObjHariko_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66A7C.s") +void ObjHariko_Wait(ObjHariko* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66A90.s") +void ObjHariko_SetupBobHead(ObjHariko* this) { + this->bobbleStep = 2730.0f; + this->unk154 = 0; + this->actionFunc = ObjHariko_BobHead; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66AA0.s") +void ObjHariko_BobHead(ObjHariko* this, GlobalContext* globalCtx) { + this->headOffset += 0x1555; + this->headRotation.x = Math_SinS(this->headOffset) * this->bobbleStep; + this->headRotation.y = Math_CosS(this->headOffset) * this->bobbleStep; + Math_SmoothStepToF(&this->bobbleStep, 0, 0.5f, 18.0f, 18.0f); + if (this->bobbleStep < 182.0f) { + ObjHariko_SetupWait(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66AC4.s") +void ObjHariko_CheckForQuakes(ObjHariko* this) { + if (Quake_NumActiveQuakes() != 0) { + ObjHariko_SetupBobHead(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66B78.s") +void ObjHariko_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjHariko* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/ObjHariko_Update.s") + this->actionFunc(this, globalCtx); + ObjHariko_CheckForQuakes(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/ObjHariko_Draw.s") +void ObjHariko_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjHariko* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + Matrix_InsertXRotation_s(this->headRotation.x, MTXMODE_APPLY); + Matrix_RotateY(this->headRotation.y, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gHarikoBodyDL); + gSPDisplayList(POLY_OPA_DISP++, gHarikoFaceDL); + + Matrix_StatePop(); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h index d9ac284bd..12d4fe505 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h @@ -10,7 +10,10 @@ typedef void (*ObjHarikoActionFunc)(struct ObjHariko*, GlobalContext*); typedef struct ObjHariko { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjHarikoActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x10]; + /* 0x0148 */ f32 bobbleStep; + /* 0x014C */ Vec3s headRotation; + /* 0x0152 */ s16 headOffset; + /* 0x0154 */ s16 unk154; // Set but not used } ObjHariko; // size = 0x158 extern const ActorInit Obj_Hariko_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 679f6ca1b..d426e0481 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1652,11 +1652,6 @@ D_06000BA0 = 0x06000BA0; D_06003FD0 = 0x06003FD0; D_06004160 = 0x06004160; -// ovl_Obj_Hariko - -D_06000080 = 0x06000080; -D_06000110 = 0x06000110; - // ovl_Obj_Jgame_Light D_060003A0 = 0x060003A0; From 54a4d1eb1202c912f6c3b269e6223ea189e7c42c Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Wed, 30 Mar 2022 00:23:20 -0300 Subject: [PATCH 178/257] Fix actorfixer (#774) --- tools/actorfixer.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 0370f0043..e5e125905 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -505,11 +505,9 @@ animdict = { "gSaveContext.weekEventReg": "gSaveContext.save.weekEventReg", "gSaveContext.playerForm": "gSaveContext.save.playerForm", "gSaveContext.day": "gSaveContext.save.day", - "gSaveContext.cutscene": "gSaveContext.save.cutscene", "gSaveContext.isNight": "gSaveContext.save.isNight", "gSaveContext.naviTimer": "gSaveContext.save.playerData.tatlTimer", "gSaveContext.tatlTimer": "gSaveContext.save.playerData.tatlTimer", - "gSaveContext.health": "gSaveContext.save.playerData.health", "gSaveContext.rupees": "gSaveContext.save.playerData.rupees", "gSaveContext.magicAcquired": "gSaveContext.save.playerData.magicAcquired", "gSaveContext.doubleMagic": "gSaveContext.save.playerData.doubleMagic", From 15dfaf0862e761b97edcda9c1dcc01639cfba5f4 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Thu, 31 Mar 2022 18:22:19 +0100 Subject: [PATCH 179/257] ABI FPR names (#767) * Add o32 to disassembler and update macro.inc * Add a variable for asm processor to makefile and improve objdump flags * Update diff settings * git subrepo pull --force tools/asm-differ subrepo: subdir: "tools/asm-differ" merged: "1236288d1" upstream: origin: "https://github.com/simonlindholm/asm-differ" branch: "main" commit: "1236288d1" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * Remove * import and implement option * Fix some stuff in the makefile * Update asm-processor * Review * Fix old var name --- Makefile | 39 +-- diff_settings.py | 1 + include/macro.inc | 36 +++ tools/asm-differ/.gitrepo | 4 +- tools/asm-differ/.pre-commit-config.yaml | 3 +- tools/asm-differ/README.md | 4 +- tools/asm-differ/diff.py | 196 ++++++++++----- tools/asm-processor/asm_processor.py | 101 +++++--- tools/asm-processor/build.py | 56 ++++- tools/asm-processor/prelude.inc | 40 ++- tools/disasm/disasm.py | 298 ++++++++++++----------- tools/disasm/mips_isa.py | 15 +- 12 files changed, 513 insertions(+), 280 deletions(-) diff --git a/Makefile b/Makefile index c41cc941f..7326b88a7 100644 --- a/Makefile +++ b/Makefile @@ -21,9 +21,9 @@ ifeq ($(NON_MATCHING),1) COMPARE := 0 endif -DISASM_FLAGS ?= +DISASM_FLAGS := --reg-names=o32 ifneq ($(FULL_DISASM), 0) - DISASM_FLAGS += --full + DISASM_FLAGS += --all endif PROJECT_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) @@ -73,6 +73,9 @@ AS := $(MIPS_BINUTILS_PREFIX)as LD := $(MIPS_BINUTILS_PREFIX)ld OBJCOPY := $(MIPS_BINUTILS_PREFIX)objcopy OBJDUMP := $(MIPS_BINUTILS_PREFIX)objdump +ASM_PROC := python3 tools/asm-processor/build.py + +ASM_PROC_FLAGS := --input-enc=utf-8 --output-enc=euc-jp IINC := -Iinclude -Isrc -Iassets -Ibuild -I. @@ -99,6 +102,9 @@ MIPS_VERSION := -mips2 # we support Microsoft extensions such as anonymous structs, which the compiler does support but warns for their usage. Surpress the warnings with -woff. CFLAGS += -G 0 -non_shared -Xfullwarn -Xcpluscomm $(IINC) -nostdinc -Wab,-r4300_mul -woff 624,649,838,712 +# Use relocations and abi fpr names in the dump +OBJDUMP_FLAGS := -d -r -z -Mreg-names=32 + ifeq ($(shell getconf LONG_BIT), 32) # Work around memory allocation bug in QEMU export QEMU_GUEST_BASE := 1 @@ -178,6 +184,7 @@ build/src/libultra/flash/%.o: MIPS_VERSION := -mips1 build/src/code/audio/%.o: OPTFLAGS := -O2 build/assets/%.o: OPTFLAGS := -O1 +build/assets/%.o: ASM_PROC_FLAGS := # file flags build/src/boot_O2_g3/fault.o: CFLAGS += -trapuv @@ -194,21 +201,19 @@ build/src/libultra/libc/llcvt.o: OPTFLAGS := -O1 build/src/libultra/libc/llcvt.o: MIPS_VERSION := -mips3 -32 # cc & asm-processor -build/src/boot_O2/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/boot_O2_g3/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/src/boot_O2/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- +build/src/boot_O2_g3/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- -build/src/libultra/%.o: CC := python3 tools/asm-processor/build.py $(CC_OLD) -- $(AS) $(ASFLAGS) -- +build/src/libultra/%.o: CC := $(CC_OLD) +# Needed at least until voice is decompiled +build/src/libultra/voice/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC_OLD) -- $(AS) $(ASFLAGS) -- -build/src/code/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/code/audio/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/src/code/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- +build/src/code/audio/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/actors/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/effects/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/fbdemos/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/gamestates/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/kaleido_scope/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/src/overlays/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- -build/assets/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/assets/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- #### Main Targets ### @@ -303,7 +308,7 @@ build/data/%.o: data/%.s build/src/overlays/%.o: src/overlays/%.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - @$(OBJDUMP) -d $@ > $(@:.o=.s) + @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) # TODO: `() || true` is currently necessary to suppress `Error 1 (ignored)` make warnings caused by `test`, but this will go away if # the following is moved to a separate rule that is only run once when all the required objects have been compiled. $(ZAPD) bovl -eh -i $@ -cfg $< --outputpath $(@D)/$(notdir $(@D))_reloc.s @@ -313,21 +318,21 @@ build/src/overlays/%.o: src/overlays/%.c build/src/%.o: src/%.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - @$(OBJDUMP) -d $@ > $(@:.o=.s) + @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) $(RM_MDEBUG) build/src/libultra/libc/ll.o: src/libultra/libc/ll.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< python3 tools/set_o32abi_bit.py $@ - @$(OBJDUMP) -d $@ > $(@:.o=.s) + @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) $(RM_MDEBUG) build/src/libultra/libc/llcvt.o: src/libultra/libc/llcvt.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< python3 tools/set_o32abi_bit.py $@ - @$(OBJDUMP) -d $@ > $(@:.o=.s) + @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) $(RM_MDEBUG) # Build C files from assets diff --git a/diff_settings.py b/diff_settings.py index a6cee9dc8..4eeb4989c 100755 --- a/diff_settings.py +++ b/diff_settings.py @@ -5,4 +5,5 @@ def apply(config, args): config['myimg'] = 'mm.us.rev1.rom_uncompressed.z64' config['mapfile'] = 'build/mm.map' config['source_directories'] = ['./src','./include'] + config['objdump_flags'] = ['-M','reg-names=32'] config['makeflags'] = ['KEEP_MDEBUG=1'] diff --git a/include/macro.inc b/include/macro.inc index 396a4cb68..d7a8da875 100644 --- a/include/macro.inc +++ b/include/macro.inc @@ -37,3 +37,39 @@ .set TagHi, $29 .set ErrorEPC, $30 .set Reserved31, $31 + + +# Float register aliases (o32 ABI, odd ones are rarely used) + +.set $fv0, $f0 +.set $fv0f, $f1 +.set $fv1, $f2 +.set $fv1f, $f3 +.set $ft0, $f4 +.set $ft0f, $f5 +.set $ft1, $f6 +.set $ft1f, $f7 +.set $ft2, $f8 +.set $ft2f, $f9 +.set $ft3, $f10 +.set $ft3f, $f11 +.set $fa0, $f12 +.set $fa0f, $f13 +.set $fa1, $f14 +.set $fa1f, $f15 +.set $ft4, $f16 +.set $ft4f, $f17 +.set $ft5, $f18 +.set $ft5f, $f19 +.set $fs0, $f20 +.set $fs0f, $f21 +.set $fs1, $f22 +.set $fs1f, $f23 +.set $fs2, $f24 +.set $fs2f, $f25 +.set $fs3, $f26 +.set $fs3f, $f27 +.set $fs4, $f28 +.set $fs4f, $f29 +.set $fs5, $f30 +.set $fs5f, $f31 diff --git a/tools/asm-differ/.gitrepo b/tools/asm-differ/.gitrepo index 48e215c08..8d0a6445d 100644 --- a/tools/asm-differ/.gitrepo +++ b/tools/asm-differ/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/simonlindholm/asm-differ branch = main - commit = 6f8f80b719359d018a2b734288c977aae6538870 - parent = 91a6e9f647d2035eba281d286c78f089f70f269f + commit = 1236288d1520335c2bfb672078fec65084d7cb5c + parent = 2c5690701a350c7e7c3d6252dff925ad65d59910 method = merge cmdver = 0.4.3 diff --git a/tools/asm-differ/.pre-commit-config.yaml b/tools/asm-differ/.pre-commit-config.yaml index 6695f71ac..ccc4afc0e 100644 --- a/tools/asm-differ/.pre-commit-config.yaml +++ b/tools/asm-differ/.pre-commit-config.yaml @@ -1,6 +1,5 @@ repos: - repo: https://github.com/psf/black - rev: 20.8b1 + rev: 22.1.0 hooks: - id: black - language_version: python3.6 diff --git a/tools/asm-differ/README.md b/tools/asm-differ/README.md index 4a7f329b3..205310d39 100644 --- a/tools/asm-differ/README.md +++ b/tools/asm-differ/README.md @@ -11,10 +11,10 @@ Nice differ for assembly code. Currently supports MIPS, PPC, AArch64, and ARM32; ## Usage -Create a file `diff_settings.sh` in some directory (see the one in this repo for an example). Then from that directory, run +Create a file `diff_settings.py` in some directory (see the one in this repo for an example). Then from that directory, run ```bash -/path/to/diff.sh [flags] (function|rom addr) +/path/to/diff.py [flags] (function|rom addr) ``` Recommended flags are `-mwo` (automatically run `make` on source file changes, and include symbols in diff). See `--help` for more details. diff --git a/tools/asm-differ/diff.py b/tools/asm-differ/diff.py index 9781420bb..4b5bc892e 100755 --- a/tools/asm-differ/diff.py +++ b/tools/asm-differ/diff.py @@ -109,6 +109,15 @@ if __name__ == "__main__": help="""Diff .o files rather than a whole binary. This makes it possible to see symbol names. (Recommended)""", ) + parser.add_argument( + "-f", + "--objfile", + dest="objfile", + type=str, + help="""File path for an object file being diffed. When used + the map file isn't searched for the function given. Useful for dynamically + linked libraries.""", + ) parser.add_argument( "-e", "--elf", @@ -132,6 +141,14 @@ if __name__ == "__main__": help="""Tweak --source handling to make it work with binutils < 2.33. Implies --source.""", ) + parser.add_argument( + "-j", + "--section", + dest="diff_section", + default=".text", + metavar="SECTION", + help="Diff restricted to a given output section.", + ) parser.add_argument( "-L", "--line-numbers", @@ -356,6 +373,7 @@ except ModuleNotFoundError as e: class ProjectSettings: arch_str: str objdump_executable: str + objdump_flags: List[str] build_command: List[str] map_format: str mw_build_dir: str @@ -365,6 +383,7 @@ class ProjectSettings: source_directories: Optional[List[str]] source_extensions: List[str] show_line_numbers_default: bool + disassemble_all: bool @dataclass @@ -379,8 +398,10 @@ class Config: # Build/objdump options diff_obj: bool + objfile: Optional[str] make: bool source_old_binutils: bool + diff_section: str inlines: bool max_function_size_lines: int max_function_size_bytes: int @@ -422,9 +443,11 @@ def create_project_settings(settings: Dict[str, Any]) -> ProjectSettings: "source_extensions", [".c", ".h", ".cpp", ".hpp", ".s"] ), objdump_executable=get_objdump_executable(settings.get("objdump_executable")), + objdump_flags=settings.get("objdump_flags", []), map_format=settings.get("map_format", "gnu"), mw_build_dir=settings.get("mw_build_dir", "build/"), show_line_numbers_default=settings.get("show_line_numbers_default", True), + disassemble_all=settings.get("disassemble_all", False), ) @@ -461,8 +484,10 @@ def create_config(args: argparse.Namespace, project: ProjectSettings) -> Config: arch=arch, # Build/objdump options diff_obj=args.diff_obj, + objfile=args.objfile, make=args.make, source_old_binutils=args.source_old_binutils, + diff_section=args.diff_section, inlines=args.inlines, max_function_size_lines=args.max_lines, max_function_size_bytes=args.max_lines * 4, @@ -518,7 +543,7 @@ def get_arch(arch_str: str) -> "ArchSettings": raise ValueError(f"Unknown architecture: {arch_str}") -BUFFER_CMD: List[str] = ["tail", "-c", str(10 ** 9)] +BUFFER_CMD: List[str] = ["tail", "-c", str(10**9)] # -S truncates long lines instead of wrapping them # -R interprets color escape sequences @@ -809,12 +834,7 @@ class JsonFormatter(Formatter): return {"text": s, "format": f.name.lower()} elif isinstance(f, RotationFormat): attrs = asdict(f) - attrs.update( - { - "text": s, - "format": "rotation", - } - ) + attrs.update({"text": s, "format": "rotation"}) return attrs else: static_assert_unreachable(f) @@ -962,7 +982,7 @@ def restrict_to_function(dump: str, fn_name: str) -> str: return "" -def serialize_data_references(references: List[Tuple[int, int, str]]) -> str: +def serialize_rodata_references(references: List[Tuple[int, int, str]]) -> str: return "".join( f"DATAREF {text_offset} {from_offset} {from_section}\n" for (text_offset, from_offset, from_section) in references @@ -991,7 +1011,11 @@ def run_objdump(cmd: ObjdumpCommand, config: Config, project: ProjectSettings) - flags, target, restrict = cmd try: out = subprocess.run( - [project.objdump_executable] + config.arch.arch_flags + flags + [target], + [project.objdump_executable] + + config.arch.arch_flags + + project.objdump_flags + + flags + + [target], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, @@ -1009,11 +1033,11 @@ def run_objdump(cmd: ObjdumpCommand, config: Config, project: ProjectSettings) - with open(target, "rb") as f: obj_data = f.read() - return preprocess_objdump_out(restrict, obj_data, out) + return preprocess_objdump_out(restrict, obj_data, out, config) def preprocess_objdump_out( - restrict: Optional[str], obj_data: Optional[bytes], objdump_out: str + restrict: Optional[str], obj_data: Optional[bytes], objdump_out: str, config: Config ) -> str: """ Preprocess the output of objdump into a format that `process()` expects. @@ -1033,13 +1057,16 @@ def preprocess_objdump_out( out = out.rstrip("\n") if obj_data: - out = serialize_data_references(parse_elf_data_references(obj_data)) + out + out = ( + serialize_rodata_references(parse_elf_rodata_references(obj_data, config)) + + out + ) return out def search_map_file( - fn_name: str, project: ProjectSettings + fn_name: str, project: ProjectSettings, config: Config ) -> Tuple[Optional[str], Optional[int]]: if not project.mapfile: fail(f"No map file configured; cannot find function {fn_name}.") @@ -1059,7 +1086,7 @@ def search_map_file( cands = [] last_line = "" for line in lines: - if line.startswith(" .text"): + if line.startswith(" " + config.diff_section): cur_objfile = line.split()[3] if "load address" in line: tokens = last_line.split() + line.split() @@ -1084,9 +1111,12 @@ def search_map_file( re.compile( # ram elf rom r" \S+ \S+ (\S+) (\S+) . " - + fn_name - # object name - + r"(?: \(entry of \.(?:init|text)\))? \t(\S+)" + + re.escape(fn_name) + + r"(?: \(entry of " + + re.escape(config.diff_section) + + r"\))? \t" + # object name + + "(\S+)" ), contents, ) @@ -1121,7 +1151,9 @@ def search_map_file( return None, None -def parse_elf_data_references(data: bytes) -> List[Tuple[int, int, str]]: +def parse_elf_rodata_references( + data: bytes, config: Config +) -> List[Tuple[int, int, str]]: e_ident = data[:16] if e_ident[:4] != b"\x7FELF": return [] @@ -1134,7 +1166,6 @@ def parse_elf_data_references(data: bytes) -> List[Tuple[int, int, str]]: is_little_endian = e_ident[5] == 1 str_end = "<" if is_little_endian else ">" str_off = "I" if is_32bit else "Q" - sym_size = {"B": 1, "H": 2, "I": 4, "Q": 8} def read(spec: str, offset: int) -> Tuple[int, ...]: spec = spec.replace("P", str_off) @@ -1186,7 +1217,12 @@ def parse_elf_data_references(data: bytes) -> List[Tuple[int, int, str]]: assert len(symtab_sections) == 1 symtab = sections[symtab_sections[0]] - text_sections = [i for i in range(e_shnum) if sec_names[i] == b".text" and sections[i].sh_size != 0] + section_name = config.diff_section.encode("utf-8") + text_sections = [ + i + for i in range(e_shnum) + if sec_names[i] == section_name and sections[i].sh_size != 0 + ] if len(text_sections) != 1: return [] text_section = text_sections[0] @@ -1195,11 +1231,10 @@ def parse_elf_data_references(data: bytes) -> List[Tuple[int, int, str]]: for s in sections: if s.sh_type == SHT_REL or s.sh_type == SHT_RELA: if s.sh_info == text_section: - # Skip .text -> .text references + # Skip section_name -> section_name references continue sec_name = sec_names[s.sh_info].decode("latin1") - if sec_name == ".mwcats.text": - # Skip Metrowerks CATS Utility section + if sec_name != ".rodata": continue sec_base = sections[s.sh_info].sh_offset for i in range(0, s.sh_size, s.sh_entsize): @@ -1257,11 +1292,16 @@ def dump_elf( f"--stop-address={end_addr}", ] + if project.disassemble_all: + disassemble_flag = "-D" + else: + disassemble_flag = "-d" + flags2 = [ f"--disassemble={diff_elf_symbol}", ] - objdump_flags = ["-drz", "-j", ".text"] + objdump_flags = [disassemble_flag, "-rz", "-j", config.diff_section] return ( project.myimg, (objdump_flags + flags1, project.baseimg, None), @@ -1283,7 +1323,10 @@ def dump_objfile( if start.startswith("0"): fail("numerical start address not supported with -o; pass a function name") - objfile, _ = search_map_file(start, project) + objfile = config.objfile + if not objfile: + objfile, _ = search_map_file(start, project, config) + if not objfile: fail("Not able to find .o file for function.") @@ -1297,7 +1340,12 @@ def dump_objfile( if not os.path.isfile(refobjfile): fail(f'Please ensure an OK .o file exists at "{refobjfile}".') - objdump_flags = ["-drz", "-j", ".text"] + if project.disassemble_all: + disassemble_flag = "-D" + else: + disassemble_flag = "-d" + + objdump_flags = [disassemble_flag, "-rz", "-j", config.diff_section] return ( objfile, (objdump_flags, refobjfile, start), @@ -1314,7 +1362,7 @@ def dump_binary( run_make(project.myimg, project) start_addr = maybe_eval_int(start) if start_addr is None: - _, start_addr = search_map_file(start, project) + _, start_addr = search_map_file(start, project, config) if start_addr is None: fail("Not able to find function in map file.") if end is not None: @@ -1333,6 +1381,7 @@ def dump_binary( (objdump_flags + flags2, project.myimg, None), ) + # Example: "ldr r4, [pc, #56] ; (4c )" ARM32_LOAD_POOL_PATTERN = r"(ldr\s+r([0-9]|1[0-3]),\s+\[pc,.*;\s*)(\([a-fA-F0-9]+.*\))" @@ -1363,7 +1412,7 @@ class AsmProcessor: class AsmProcessorMIPS(AsmProcessor): def process_reloc(self, row: str, prev: str) -> str: arch = self.config.arch - if "R_MIPS_NONE" in row: + if "R_MIPS_NONE" in row or "R_MIPS_JALR" in row: # GNU as emits no-op relocations immediately after real ones when # assembling with -mabi=64. Return without trying to parse 'imm' as an # integer. @@ -1378,12 +1427,9 @@ class AsmProcessorMIPS(AsmProcessor): # TODO: handle unambiguous cases where all addends for a symbol are the # same, or show "+???". mnemonic = prev.split()[0] - if ( - mnemonic in arch.instructions_with_address_immediates - and not imm.startswith("0x") - ): - imm = "0x" + imm - repl += "+" + imm if int(imm, 0) > 0 else imm + if mnemonic in arch.instructions_with_address_immediates: + imm = hex(int(imm, 16)) + repl += ("" if imm.startswith("-") else "+") + imm if "R_MIPS_LO16" in row: repl = f"%lo({repl})" elif "R_MIPS_HI16" in row: @@ -1398,6 +1444,12 @@ class AsmProcessorMIPS(AsmProcessor): # Branch to glabel. This gives confusing output, but there's not much # we can do here. pass + elif "R_MIPS_GPREL16" in row: + repl = f"%gp_rel({repl})" + elif "R_MIPS_GOT16" in row: + repl = f"%got({repl})" + elif "R_MIPS_CALL16" in row: + repl = f"%call16({repl})" else: assert False, f"unknown relocation type '{row}' for line '{prev}'" return before + repl + after @@ -1544,6 +1596,7 @@ class ArchSettings: big_endian: Optional[bool] = True delay_slot_instructions: Set[str] = field(default_factory=set) + MIPS_BRANCH_LIKELY_INSTRUCTIONS = { "beql", "bnel", @@ -1651,10 +1704,13 @@ PPC_BRANCH_INSTRUCTIONS = { MIPS_SETTINGS = ArchSettings( name="mips", re_int=re.compile(r"[0-9]+"), - re_comment=re.compile(r"<.*?>"), - re_reg=re.compile( - r"\$?\b(a[0-7]|t[0-9]|s[0-8]|at|v[01]|f[12]?[0-9]|f3[01]|kt?[01]|fp|ra|zero)\b" - ), + re_comment=re.compile(r"<.*>"), + # Includes: + # - General purpose registers v0..1, a0..7, t0..9, s0..8, zero, at, fp, k0..1/kt0..1 + # - Float registers f0..31, or fv0..1, fa0..7, ft0..15, fs0..8 plus odd complements + # (actually used number depends on ABI) + # sp, gp should not be in this list + re_reg=re.compile(r"\$?\b([astv][0-9]|at|f[astv]?[0-9]+f?|kt?[01]|fp|ra|zero)\b"), re_sprel=re.compile(r"(?<=,)([0-9]+|0x[0-9a-f]+)\(sp\)"), re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"), re_imm=re.compile(r"(\b|-)([0-9]+|0x[0-9a-fA-F]+)\b(?!\(sp)|%(lo|hi)\([^)]*\)"), @@ -1672,7 +1728,7 @@ MIPSEL_SETTINGS = replace(MIPS_SETTINGS, name="mipsel", big_endian=False) ARM32_SETTINGS = ArchSettings( name="arm32", re_int=re.compile(r"[0-9]+"), - re_comment=re.compile(r"(<.*?>|//.*$)"), + re_comment=re.compile(r"(<.*>|//.*$)"), # Includes: # - General purpose registers: r0..13 # - Frame pointer registers: lr (r14), pc (r15) @@ -1690,26 +1746,33 @@ ARM32_SETTINGS = ArchSettings( proc=AsmProcessorARM32, ) +ARMEL_SETTINGS = replace(ARM32_SETTINGS, name="armel", big_endian=False) + AARCH64_SETTINGS = ArchSettings( name="aarch64", re_int=re.compile(r"[0-9]+"), - re_comment=re.compile(r"(<.*?>|//.*$)"), - # GPRs and FP registers: X0-X30, W0-W30, [DSHQ]0..31 + re_comment=re.compile(r"(<.*>|//.*$)"), + # GPRs and FP registers: X0-X30, W0-W30, [BHSDVQ]0..31 + # (FP registers may be followed by data width and number of elements, e.g. V0.4S) # The zero registers and SP should not be in this list. - re_reg=re.compile(r"\$?\b([dshq][12]?[0-9]|[dshq]3[01]|[xw][12]?[0-9]|[xw]30)\b"), + re_reg=re.compile( + r"\$?\b([bhsdvq]([12]?[0-9]|3[01])(\.\d\d?[bhsdvq])?|[xw][12]?[0-9]|[xw]30)\b" + ), re_sprel=re.compile(r"sp, #-?(0x[0-9a-fA-F]+|[0-9]+)\b"), re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"), re_imm=re.compile(r"(?|//.*$)"), + re_comment=re.compile(r"(<.*>|//.*$)"), re_reg=re.compile(r"\$?\b([rf][0-9]+)\b"), re_sprel=re.compile(r"(?<=,)(-?[0-9]+|-?0x[0-9a-f]+)\(r1\)"), re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"), @@ -1724,6 +1787,7 @@ ARCH_SETTINGS = [ MIPS_SETTINGS, MIPSEL_SETTINGS, ARM32_SETTINGS, + ARMEL_SETTINGS, AARCH64_SETTINGS, PPC_SETTINGS, ] @@ -1743,6 +1807,7 @@ def hexify_int(row: str, pat: Match[str], arch: ArchSettings) -> str: def parse_relocated_line(line: str) -> Tuple[str, str, str]: + # Pick out the last argument for c in ",\t ": if c in line: ind2 = line.rindex(c) @@ -1751,6 +1816,7 @@ def parse_relocated_line(line: str) -> Tuple[str, str, str]: raise Exception(f"failed to parse relocated line: {line}") before = line[: ind2 + 1] after = line[ind2 + 1 :] + # Move an optional ($reg) part of it to 'after' ind2 = after.find("(") if ind2 == -1: imm, after = after, "" @@ -1879,8 +1945,15 @@ def process(dump: str, config: Config) -> List[Line]: row_parts = [part.lstrip() for part in row.split(" ", 1)] mnemonic = row_parts[0].strip() - if mnemonic not in arch.instructions_with_address_immediates: - row = re.sub(arch.re_int, lambda m: hexify_int(row, m, arch), row) + addr = "" + if mnemonic in arch.instructions_with_address_immediates: + row, addr = split_off_address(row) + # objdump prefixes addresses with 0x/-0x if they don't resolve to some + # symbol + offset. Strip that. + addr = addr.replace("0x", "") + + row = re.sub(arch.re_int, lambda m: hexify_int(row, m, arch), row) + row += addr # Let 'original' be 'row' with relocations applied, while we continue # transforming 'row' into a coarser version that ignores registers and @@ -1900,9 +1973,6 @@ def process(dump: str, config: Config) -> List[Line]: scorable_line = normalized_original if not config.score_stack_differences: scorable_line = re.sub(arch.re_sprel, "addr(sp)", scorable_line) - if mnemonic in arch.branch_instructions: - # Replace the final argument with "" - scorable_line = re.sub(r"[^, \t]+$", "", scorable_line) if skip_next: skip_next = False @@ -1925,8 +1995,6 @@ def process(dump: str, config: Config) -> List[Line]: branch_target = None if mnemonic in arch.branch_instructions: branch_target = int(row_parts[1].strip().split(",")[-1], 16) - if mnemonic in arch.branch_likely_instructions: - branch_target -= 4 output.append( Line( @@ -1974,7 +2042,9 @@ def split_off_address(line: str) -> Tuple[str, str]: parts = line.split(",") if len(parts) < 2: parts = line.split(None, 1) - off = len(line) - len(parts[-1]) + if len(parts) < 2: + parts.append("") + off = len(line) - len(parts[-1].strip()) return line[:off], line[off:] @@ -1990,7 +2060,7 @@ def diff_sequences( ) -> List[Tuple[str, int, int, int, int]]: if ( algorithm != "levenshtein" - or len(seq1) * len(seq2) > 4 * 10 ** 8 + or len(seq1) * len(seq2) > 4 * 10**8 or len(seq1) + len(seq2) >= 0x110000 ): return diff_sequences_difflib(seq1, seq2) @@ -2177,10 +2247,15 @@ class Diff: def trim_nops(lines: List[Line], arch: ArchSettings) -> List[Line]: lines = lines[:] - while lines and lines[-1].mnemonic == "nop" and (len(lines) == 1 or lines[-2].mnemonic not in arch.delay_slot_instructions): + while ( + lines + and lines[-1].mnemonic == "nop" + and (len(lines) == 1 or lines[-2].mnemonic not in arch.delay_slot_instructions) + ): lines.pop() return lines + def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: if config.show_source: import cxxfilt @@ -2212,7 +2287,6 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: lines2 = trim_nops(lines2, arch) diffed_lines = diff_lines(lines1, lines2, config.algorithm) - score = score_diff_lines(diffed_lines, config) max_score = len(lines1) * config.penalty_deletion line_num_base = -1 @@ -2281,10 +2355,15 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: line2_line = line_num_2to1[line2.line_num] line2_target = (line2_line[0] + (target - line2.line_num), 0) - # Set the key for three-way diffing to a normalized version. + # Adjust the branch target for scoring and three-way diffing. norm2, norm_branch2 = split_off_address(line2.normalized_original) - if norm_branch2 != "": - line2.normalized_original = norm2 + str(line2_target) + if norm_branch2 != "": + retargetted = hex(line2_target[0]).replace("0x", "") + if line2_target[1] != 0: + retargetted += f"+{line2_target[1]}" + line2.normalized_original = norm2 + retargetted + sc_base, _ = split_off_address(line2.scorable_line) + line2.scorable_line = sc_base + retargetted same_target = line2_target == (line1.branch_target, 0) else: # Do a naive comparison for non-branches (e.g. function calls). @@ -2444,6 +2523,7 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: ) ) + score = score_diff_lines(diffed_lines, config) output = output[config.skip_lines :] return Diff(lines=output, score=score, max_score=max_score) diff --git a/tools/asm-processor/asm_processor.py b/tools/asm-processor/asm_processor.py index 6923752be..544b1b1b7 100644 --- a/tools/asm-processor/asm_processor.py +++ b/tools/asm-processor/asm_processor.py @@ -783,6 +783,13 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende else: min_instr_count = 2 skip_instr_count = 1 + elif opt == 'O0': + if framepointer: + min_instr_count = 8 + skip_instr_count = 8 + else: + min_instr_count = 4 + skip_instr_count = 4 elif opt == 'g': if framepointer: min_instr_count = 7 @@ -792,7 +799,7 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende skip_instr_count = 4 else: if opt != 'g3': - raise Failure("must pass one of -g, -O1, -O2, -O2 -g3") + raise Failure("must pass one of -g, -O0, -O1, -O2, -O2 -g3") if framepointer: min_instr_count = 4 skip_instr_count = 4 @@ -813,6 +820,7 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende ] is_cutscene_data = False + is_early_include = False for line_no, raw_line in enumerate(f, 1): raw_line = raw_line.rstrip() @@ -832,44 +840,51 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende global_asm = None else: global_asm.process_line(raw_line, output_enc) + elif line in ['GLOBAL_ASM(', '#pragma GLOBAL_ASM(']: + global_asm = GlobalAsmBlock("GLOBAL_ASM block at line " + str(line_no)) + start_index = len(output_lines) + elif ((line.startswith('GLOBAL_ASM("') or line.startswith('#pragma GLOBAL_ASM("')) + and line.endswith('")')): + fname = line[line.index('(') + 2 : -2] + out_dependencies.append(fname) + global_asm = GlobalAsmBlock(fname) + with open(fname, encoding=input_enc) as f: + for line2 in f: + global_asm.process_line(line2.rstrip(), output_enc) + src, fn = global_asm.finish(state) + output_lines[-1] = ''.join(src) + asm_functions.append(fn) + global_asm = None + elif line == '#pragma asmproc recurse': + # C includes qualified as + # #pragma asmproc recurse + # #include "file.c" + # will be processed recursively when encountered + is_early_include = True + elif is_early_include: + # Previous line was a #pragma asmproc recurse + is_early_include = False + if not line.startswith("#include "): + raise Failure("#pragma asmproc recurse must be followed by an #include ") + fpath = os.path.dirname(f.name) + fname = os.path.join(fpath, line[line.index(' ') + 2 : -1]) + out_dependencies.append(fname) + include_src = StringIO() + with open(fname, encoding=input_enc) as include_file: + parse_source(include_file, opt, framepointer, mips1, input_enc, output_enc, out_dependencies, include_src) + include_src.write('#line ' + str(line_no + 1) + ' "' + f.name + '"') + output_lines[-1] = include_src.getvalue() + include_src.close() else: - if line in ['GLOBAL_ASM(', '#pragma GLOBAL_ASM(']: - global_asm = GlobalAsmBlock("GLOBAL_ASM block at line " + str(line_no)) - start_index = len(output_lines) - elif ((line.startswith('GLOBAL_ASM("') or line.startswith('#pragma GLOBAL_ASM("')) - and line.endswith('")')): - fname = line[line.index('(') + 2 : -2] - out_dependencies.append(fname) - global_asm = GlobalAsmBlock(fname) - with open(fname, encoding=input_enc) as f: - for line2 in f: - global_asm.process_line(line2.rstrip(), output_enc) - src, fn = global_asm.finish(state) - output_lines[-1] = ''.join(src) - asm_functions.append(fn) - global_asm = None - elif line.startswith('#include "') and line.endswith('" EARLY'): - # C includes qualified with EARLY (i.e. #include "file.c" EARLY) will be - # processed recursively when encountered - fpath = os.path.dirname(f.name) - fname = os.path.join(fpath, line[line.index(' ') + 2 : -7]) - out_dependencies.append(fname) - include_src = StringIO() - with open(fname, encoding=input_enc) as include_file: - parse_source(include_file, opt, framepointer, mips1, input_enc, output_enc, out_dependencies, include_src) - include_src.write('#line ' + str(line_no + 1) + ' "' + f.name + '"') - output_lines[-1] = include_src.getvalue() - include_src.close() - else: - # This is a hack to replace all floating-point numbers in an array of a particular type - # (in this case CutsceneData) with their corresponding IEEE-754 hexadecimal representation - if cutscene_data_regexpr.search(line) is not None: - is_cutscene_data = True - elif line.endswith("};"): - is_cutscene_data = False - if is_cutscene_data: - raw_line = re.sub(float_regexpr, repl_float_hex, raw_line) - output_lines[-1] = raw_line + # This is a hack to replace all floating-point numbers in an array of a particular type + # (in this case CutsceneData) with their corresponding IEEE-754 hexadecimal representation + if cutscene_data_regexpr.search(line) is not None: + is_cutscene_data = True + elif line.endswith("};"): + is_cutscene_data = False + if is_cutscene_data: + raw_line = re.sub(float_regexpr, repl_float_hex, raw_line) + output_lines[-1] = raw_line if print_source: if isinstance(print_source, StringIO): @@ -877,7 +892,14 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende print_source.write(line + '\n') else: for line in output_lines: - print_source.write(line.encode(output_enc) + b'\n') + try: + line_encoded = line.encode(output_enc) + except UnicodeEncodeError: + print("Failed to encode a line to", output_enc) + print("The line:", line) + print("The line, utf-8-encoded:", line.encode("utf-8")) + raise + print_source.write(line_encoded + b'\n') print_source.flush() if print_source != sys.stdout.buffer: print_source.close() @@ -1239,6 +1261,7 @@ def run_wrapped(argv, outfile, functions): parser.add_argument('-mips1', dest='mips1', action='store_true') parser.add_argument('-g3', dest='g3', action='store_true') group = parser.add_mutually_exclusive_group(required=True) + group.add_argument('-O0', dest='opt', action='store_const', const='O0') group.add_argument('-O1', dest='opt', action='store_const', const='O1') group.add_argument('-O2', dest='opt', action='store_const', const='O2') group.add_argument('-g', dest='opt', action='store_const', const='g') diff --git a/tools/asm-processor/build.py b/tools/asm-processor/build.py index 493afd4d5..480dec9ed 100755 --- a/tools/asm-processor/build.py +++ b/tools/asm-processor/build.py @@ -10,30 +10,49 @@ dir_path = os.path.dirname(os.path.realpath(__file__)) prelude = os.path.join(dir_path, "prelude.inc") all_args = sys.argv[1:] -sep1 = all_args.index('--') -sep2 = all_args.index('--', sep1+1) +sep0 = [index for index, arg in enumerate(all_args) if not arg.startswith("-")][0] +sep1 = all_args.index("--") +sep2 = all_args.index("--", sep1 + 1) -compiler = all_args[:sep1] +asmproc_flags = all_args[:sep0] +compiler = all_args[sep0:sep1] -assembler = all_args[sep1+1:sep2] -assembler_sh = ' '.join(shlex.quote(x) for x in assembler) +assembler = all_args[sep1 + 1 : sep2] +assembler_sh = " ".join(shlex.quote(x) for x in assembler) -compile_args = all_args[sep2+1:] +compile_args = all_args[sep2 + 1 :] in_file = compile_args[-1] -out_ind = compile_args.index('-o') +out_ind = compile_args.index("-o") out_file = compile_args[out_ind + 1] del compile_args[-1] del compile_args[out_ind + 1] del compile_args[out_ind] in_dir = os.path.split(os.path.realpath(in_file))[0] -opt_flags = [x for x in compile_args if x in ['-g3', '-g', '-O1', '-O2', '-framepointer']] +opt_flags = [ + x for x in compile_args if x in ["-g3", "-g", "-O0", "-O1", "-O2", "-framepointer"] +] +if "-mips2" not in compile_args: + opt_flags.append("-mips1") -preprocessed_file = tempfile.NamedTemporaryFile(prefix='preprocessed', suffix='.c', delete=False) +asmproc_flags += opt_flags + [in_file] + +# Drop .mdebug and .gptab sections from resulting binaries. This makes +# resulting .o files much smaller and speeds up builds, but loses line +# number debug data. +# asmproc_flags += ["--drop-mdebug-gptab"] + +# Convert encoding before compiling. +# asmproc_flags += ["--input-enc", "utf-8", "--output-enc", "euc-jp"] + +preprocessed_file = tempfile.NamedTemporaryFile( + prefix="preprocessed", suffix=".c", delete=False +) try: - asmproc_flags = opt_flags + [in_file, '--input-enc', 'utf-8', '--output-enc', 'euc-jp'] - compile_cmdline = compiler + compile_args + ['-I', in_dir, '-o', out_file, preprocessed_file.name] + compile_cmdline = ( + compiler + compile_args + ["-I", in_dir, "-o", out_file, preprocessed_file.name] + ) functions, deps = asm_processor.run(asmproc_flags, outfile=preprocessed_file) try: @@ -41,13 +60,24 @@ try: except subprocess.CalledProcessError as e: print("Failed to compile file " + in_file + ". Command line:") print() - print(' '.join(shlex.quote(x) for x in compile_cmdline)) + print(" ".join(shlex.quote(x) for x in compile_cmdline)) print() sys.exit(55) # To keep the preprocessed file: # os._exit(1) - asm_processor.run(asmproc_flags + ['--post-process', out_file, '--assembler', assembler_sh, '--asm-prelude', prelude], functions=functions) + asm_processor.run( + asmproc_flags + + [ + "--post-process", + out_file, + "--assembler", + assembler_sh, + "--asm-prelude", + prelude, + ], + functions=functions, + ) deps_file = out_file[:-2] + ".asmproc.d" if deps: diff --git a/tools/asm-processor/prelude.inc b/tools/asm-processor/prelude.inc index 1ec8c6036..3e58ff149 100644 --- a/tools/asm-processor/prelude.inc +++ b/tools/asm-processor/prelude.inc @@ -1,5 +1,43 @@ .set noat .set noreorder .set gp=64 -.include "macro.inc" +.macro glabel label + .global \label + \label: +.endm + +# Float register aliases (o32 ABI, odd ones are rarely used) + +.set $fv0, $f0 +.set $fv0f, $f1 +.set $fv1, $f2 +.set $fv1f, $f3 +.set $ft0, $f4 +.set $ft0f, $f5 +.set $ft1, $f6 +.set $ft1f, $f7 +.set $ft2, $f8 +.set $ft2f, $f9 +.set $ft3, $f10 +.set $ft3f, $f11 +.set $fa0, $f12 +.set $fa0f, $f13 +.set $fa1, $f14 +.set $fa1f, $f15 +.set $ft4, $f16 +.set $ft4f, $f17 +.set $ft5, $f18 +.set $ft5f, $f19 +.set $fs0, $f20 +.set $fs0f, $f21 +.set $fs1, $f22 +.set $fs1f, $f23 +.set $fs2, $f24 +.set $fs2f, $f25 +.set $fs3, $f26 +.set $fs3f, $f27 +.set $fs4, $f28 +.set $fs4f, $f29 +.set $fs5, $f30 +.set $fs5f, $f31 diff --git a/tools/disasm/disasm.py b/tools/disasm/disasm.py index 103860ed2..cb634d138 100755 --- a/tools/disasm/disasm.py +++ b/tools/disasm/disasm.py @@ -2,34 +2,44 @@ import argparse, ast, math, os, re, struct import bisect -from mips_isa import * -from multiprocessing import * +import multiprocessing from pathlib import Path +import mips_isa + +# Consider implementing gpr naming too, but already uses abi names by default +fpr_name_options = { + "numeric": mips_isa.numeric_fpr_names, + "o32": mips_isa.o32_fpr_names, +} parser = argparse.ArgumentParser() parser.add_argument( "-j", dest="jobs", type=int, default=1, help="number of processes to run at once" ) parser.add_argument( - "--full", - "-f", - dest="full", + "-a", + "--all", + dest="all", action="store_true", default=False, help="Decompile all files regardless of whether they are used or not", ) parser.add_argument( - "-files", + "-f", "--files", dest="files", nargs="+", required=False, help="Optional list of files to diassemble separated by a space. This is a whitelist, all files will be skipped besides the ones listed here if used.", ) +parser.add_argument("--reg-names", choices=fpr_name_options.keys(), help="How to name registers in the output") args = parser.parse_args() jobs = args.jobs +mips_isa.mips_fpr_names = fpr_name_options.get(args.reg_names, mips_isa.mips_fpr_names) + + ASM_OUT = "asm/" DATA_OUT = "data/" @@ -122,71 +132,71 @@ def discard_decomped_files(files_spec, include_files): MIPS_BRANCH_LIKELY_INSNS = [ - MIPS_INS_BEQL, - MIPS_INS_BGEZALL, - MIPS_INS_BGEZL, - MIPS_INS_BGTZL, - MIPS_INS_BLEZL, - MIPS_INS_BLTZALL, - MIPS_INS_BLTZL, - MIPS_INS_BNEL, - MIPS_INS_BC1TL, - MIPS_INS_BC1FL, + mips_isa.MIPS_INS_BEQL, + mips_isa.MIPS_INS_BGEZALL, + mips_isa.MIPS_INS_BGEZL, + mips_isa.MIPS_INS_BGTZL, + mips_isa.MIPS_INS_BLEZL, + mips_isa.MIPS_INS_BLTZALL, + mips_isa.MIPS_INS_BLTZL, + mips_isa.MIPS_INS_BNEL, + mips_isa.MIPS_INS_BC1TL, + mips_isa.MIPS_INS_BC1FL, ] MIPS_BRANCH_INSNS = [ *MIPS_BRANCH_LIKELY_INSNS, - MIPS_INS_BEQ, - MIPS_INS_BGEZ, - MIPS_INS_BGEZAL, - MIPS_INS_BGTZ, - MIPS_INS_BNE, - MIPS_INS_BLTZ, - MIPS_INS_BLTZAL, - MIPS_INS_BLEZ, - MIPS_INS_BC1T, - MIPS_INS_BC1F, - MIPS_INS_BEQZ, - MIPS_INS_BNEZ, - MIPS_INS_B, + mips_isa.MIPS_INS_BEQ, + mips_isa.MIPS_INS_BGEZ, + mips_isa.MIPS_INS_BGEZAL, + mips_isa.MIPS_INS_BGTZ, + mips_isa.MIPS_INS_BNE, + mips_isa.MIPS_INS_BLTZ, + mips_isa.MIPS_INS_BLTZAL, + mips_isa.MIPS_INS_BLEZ, + mips_isa.MIPS_INS_BC1T, + mips_isa.MIPS_INS_BC1F, + mips_isa.MIPS_INS_BEQZ, + mips_isa.MIPS_INS_BNEZ, + mips_isa.MIPS_INS_B, ] -MIPS_JUMP_INSNS = [MIPS_INS_JAL, MIPS_INS_JALR, MIPS_INS_J, MIPS_INS_JR] +MIPS_JUMP_INSNS = [mips_isa.MIPS_INS_JAL, mips_isa.MIPS_INS_JALR, mips_isa.MIPS_INS_J, mips_isa.MIPS_INS_JR] -MIPS_FP_LOAD_INSNS = [MIPS_INS_LWC1, MIPS_INS_LDC1] +MIPS_FP_LOAD_INSNS = [mips_isa.MIPS_INS_LWC1, mips_isa.MIPS_INS_LDC1] -MIPS_FP_STORE_INSNS = [MIPS_INS_SWC1, MIPS_INS_SDC1] +MIPS_FP_STORE_INSNS = [mips_isa.MIPS_INS_SWC1, mips_isa.MIPS_INS_SDC1] MIPS_FP_LOAD_STORE_INSNS = [*MIPS_FP_LOAD_INSNS, *MIPS_FP_STORE_INSNS] MIPS_STORE_INSNS = [ - MIPS_INS_SB, - MIPS_INS_SH, - MIPS_INS_SW, - MIPS_INS_SWL, - MIPS_INS_SWR, - MIPS_INS_SD, - MIPS_INS_SDL, - MIPS_INS_SDR, - MIPS_INS_SC, - MIPS_INS_SCD, + mips_isa.MIPS_INS_SB, + mips_isa.MIPS_INS_SH, + mips_isa.MIPS_INS_SW, + mips_isa.MIPS_INS_SWL, + mips_isa.MIPS_INS_SWR, + mips_isa.MIPS_INS_SD, + mips_isa.MIPS_INS_SDL, + mips_isa.MIPS_INS_SDR, + mips_isa.MIPS_INS_SC, + mips_isa.MIPS_INS_SCD, *MIPS_FP_STORE_INSNS, ] MIPS_LOAD_STORE_INSNS = [ - MIPS_INS_LB, - MIPS_INS_LBU, - MIPS_INS_LH, - MIPS_INS_LHU, - MIPS_INS_LW, - MIPS_INS_LWL, - MIPS_INS_LWR, - MIPS_INS_LWU, - MIPS_INS_LD, - MIPS_INS_LDL, - MIPS_INS_LDR, - MIPS_INS_LL, - MIPS_INS_LLD, + mips_isa.MIPS_INS_LB, + mips_isa.MIPS_INS_LBU, + mips_isa.MIPS_INS_LH, + mips_isa.MIPS_INS_LHU, + mips_isa.MIPS_INS_LW, + mips_isa.MIPS_INS_LWL, + mips_isa.MIPS_INS_LWR, + mips_isa.MIPS_INS_LWU, + mips_isa.MIPS_INS_LD, + mips_isa.MIPS_INS_LDL, + mips_isa.MIPS_INS_LDR, + mips_isa.MIPS_INS_LL, + mips_isa.MIPS_INS_LLD, *MIPS_STORE_INSNS, *MIPS_FP_LOAD_STORE_INSNS, ] @@ -615,7 +625,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): # assert insn.value_forname(insn.fields[0]) is not None # print(f"insn: {insn.mnemonic}, rt: {insn.rt}, first: {insn.value_forname(insn.fields[0])}") - # assert insn.id not in [MIPS_INS_ORI, MIPS_INS_ADDIU, *MIPS_LOAD_STORE_INSNS] or insn.rt == insn.value_forname(insn.fields[0]) + # assert insn.id not in [MIPS_INS_ORI, mips_isa.MIPS_INS_ADDIU, *MIPS_LOAD_STORE_INSNS] or insn.rt == insn.value_forname(insn.fields[0]) if ( delay_slot @@ -636,9 +646,9 @@ def find_symbols_in_text(section, rodata_section, data_regions): insns = [] for i, raw_insn in enumerate(raw_insns, 0): - insn = decode_insn(raw_insn, vram + i * 4) + insn = mips_isa.decode_insn(raw_insn, vram + i * 4) - if insn.id == MIPS_INS_JR and insn.rs != MIPS_REG_RA: + if insn.id == mips_isa.MIPS_INS_JR and insn.rs != mips_isa.MIPS_REG_RA: # It's hard to find when two jump tables next to each other end, so do a naive first pass # to try and find as many jump tables as possible. # Luckily IDO has a very homogeneous output for jump tables for which it is very unlikely @@ -651,9 +661,9 @@ def find_symbols_in_text(section, rodata_section, data_regions): insn_m2 = insns[-2] insn_m3 = insns[-3] if ( - insn_m1.id == MIPS_INS_LW - and insn_m2.id == MIPS_INS_ADDU - and insn_m3.id == MIPS_INS_LUI + insn_m1.id == mips_isa.MIPS_INS_LW + and insn_m2.id == mips_isa.MIPS_INS_ADDU + and insn_m3.id == mips_isa.MIPS_INS_LUI ): prospective_jtbls.add((insn_m3.imm << 0x10) + insn_m1.imm) insns.append(insn) @@ -674,7 +684,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): Relocated jump targets give us functions in this section """ assert ( - insn.id == MIPS_INS_JAL + insn.id == mips_isa.MIPS_INS_JAL ), f"R_MIPS_26 applied to {insn.mnemonic} when it should be JAL" put_symbol(symbols_dict, "functions", insn.target) elif reloc[1] == 5: # R_MIPS_HI16 @@ -682,7 +692,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): Relocated %hi gives us %hi values to match with associated %lo """ assert ( - insn.id == MIPS_INS_LUI + insn.id == mips_isa.MIPS_INS_LUI ), f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be LUI" prev_hi = insn.imm hi_vram = vram + reloc[2] @@ -691,7 +701,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): Relocated %lo + a %hi to match with gives us relocated symbols in data sections """ assert ( - insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS + insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS ), f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be ADDIU or a load/store" symbol_value = (prev_hi << 0x10) + insn.imm put_symbols(symbols_dict, "symbols", {hi_vram: symbol_value}) @@ -757,16 +767,16 @@ def find_symbols_in_text(section, rodata_section, data_regions): if insn.id in MIPS_BRANCH_INSNS: func_branch_labels.add(insn.offset) delayed_insn = insn - elif insn.id == MIPS_INS_ERET: + elif insn.id == mips_isa.MIPS_INS_ERET: put_symbol(symbols_dict, "functions", vaddr + 4) elif insn.id in MIPS_JUMP_INSNS: - if insn.id == MIPS_INS_JAL: + if insn.id == mips_isa.MIPS_INS_JAL: # mark function at target put_symbol(symbols_dict, "functions", insn.target) - elif insn.id == MIPS_INS_J: + elif insn.id == mips_isa.MIPS_INS_J: # mark label at target func_branch_labels.add(insn.target) - elif insn.id == MIPS_INS_JR: + elif insn.id == mips_isa.MIPS_INS_JR: # check if anything branches past it in either branch or jtbl labels if vaddr >= max(func_branch_labels, default=0) and vaddr >= max( func_jtbl_labels, default=0 @@ -792,7 +802,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): symbols_dict, "functions", vaddr + 8 + n_padding * 4 ) delayed_insn = insn - elif insn.id == MIPS_INS_LUI: + elif insn.id == mips_isa.MIPS_INS_LUI: """ Process LUI instruction @@ -809,34 +819,34 @@ def find_symbols_in_text(section, rodata_section, data_regions): save_tracker(delayed_insn.offset, {insn.rt: (vaddr, insn.imm)}) else: lui_tracker.update({insn.rt: (vaddr, insn.imm)}) - elif insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: + elif insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: # try match with tracked lui and mark symbol hi_vram, imm_value = lui_tracker.get( - insn.rs if insn.id == MIPS_INS_ADDIU else insn.base, (None, None) + insn.rs if insn.id == mips_isa.MIPS_INS_ADDIU else insn.base, (None, None) ) # if a match was found, validate and record the symbol, TODO improve validation if hi_vram != None and ( (((imm_value >> 0x8) & 0xF) != 0 and imm_value < 0x1000) or (imm_value >= 0x8000 and imm_value < 0x80D0) or (imm_value >= 0xA400 and imm_value < 0xA480) - or (imm_value < 0x0400 and insn.id == MIPS_INS_ADDIU) + or (imm_value < 0x0400 and insn.id == mips_isa.MIPS_INS_ADDIU) ): lo_vram = vaddr symbol_value = (imm_value << 0x10) + insn.imm put_symbols(symbols_dict, "symbols", {hi_vram: symbol_value}) put_symbols(symbols_dict, "symbols", {lo_vram: symbol_value}) - if insn.id == MIPS_INS_LW: + if insn.id == mips_isa.MIPS_INS_LW: # try find jr within the same block cur_idx = i lookahead_insn = insns[cur_idx] # TODO fix vaddr here # still in same block unless one of these instructions are found while lookahead_insn.id not in [ *MIPS_BRANCH_INSNS, - MIPS_INS_JAL, - MIPS_INS_JALR, - MIPS_INS_J, + mips_isa.MIPS_INS_JAL, + mips_isa.MIPS_INS_JALR, + mips_isa.MIPS_INS_J, ]: - if lookahead_insn.id == MIPS_INS_JR: + if lookahead_insn.id == mips_isa.MIPS_INS_JR: if lookahead_insn.rs == ( insn.ft if insn.id in MIPS_FP_LOAD_STORE_INSNS @@ -884,24 +894,24 @@ def find_symbols_in_text(section, rodata_section, data_regions): if cur_idx >= len(raw_insns): break lookahead_insn = insns[cur_idx] # TODO fix vaddr here - elif insn.id == MIPS_INS_LD: # doubleword loads + elif insn.id == mips_isa.MIPS_INS_LD: # doubleword loads put_symbol(symbols_dict, "dwords", symbol_value) - elif insn.id in [MIPS_INS_LWC1, MIPS_INS_SWC1]: # float load/stores + elif insn.id in [mips_isa.MIPS_INS_LWC1, mips_isa.MIPS_INS_SWC1]: # float load/stores # add float put_symbol(symbols_dict, "floats", symbol_value) - elif insn.id in [MIPS_INS_LDC1, MIPS_INS_SDC1]: # double load/stores + elif insn.id in [mips_isa.MIPS_INS_LDC1, mips_isa.MIPS_INS_SDC1]: # double load/stores # add double put_symbol(symbols_dict, "doubles", symbol_value) elif ( - insn.id == MIPS_INS_ADDIU and vaddr % 4 == 0 + insn.id == mips_isa.MIPS_INS_ADDIU and vaddr % 4 == 0 ): # strings seem to only ever be 4-byte aligned # add possible string put_symbol(symbols_dict, "prospective_strings", symbol_value) # clear lui tracking state if register is clobbered by the addiu/load instruction itself - # insn.rt == (insn.rs if insn.id == MIPS_INS_ADDIU else insn.base) and + # insn.rt == (insn.rs if insn.id == mips_isa.MIPS_INS_ADDIU else insn.base) and if insn.id not in MIPS_STORE_INSNS and insn.id not in MIPS_FP_LOAD_INSNS: clobber_conditionally(insn) - elif insn.id == MIPS_INS_ORI: + elif insn.id == mips_isa.MIPS_INS_ORI: # try match with tracked lui and mark constant hi_vram, imm_value = lui_tracker.get(insn.rs, (None, None)) if hi_vram != None: # found match @@ -916,7 +926,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): else: # clear lui tracking if register is clobbered by something unrelated if ( - insn.id == MIPS_INS_ADDU + insn.id == mips_isa.MIPS_INS_ADDU and insn.rs in lui_tracker.keys() and (insn.rd == insn.rs) ): @@ -929,35 +939,35 @@ def find_symbols_in_text(section, rodata_section, data_regions): pass # insns listed either write to fprs/cop0 or don't write to any elif insn.id not in [ - MIPS_INS_MTC0, - MIPS_INS_MTC1, - MIPS_INS_DMTC1, - MIPS_INS_MULT, - MIPS_INS_MULTU, - MIPS_INS_DMULT, - MIPS_INS_DMULTU, - MIPS_INS_DIV, - MIPS_INS_DIVU, - MIPS_INS_DDIV, - MIPS_INS_DDIVU, - MIPS_INS_MTHI, - MIPS_INS_MTLO, - MIPS_INS_CTC1, - MIPS_INS_NOP, - MIPS_INS_BREAK, - MIPS_INS_TLBP, - MIPS_INS_TLBR, - MIPS_INS_TLBWI, - MIPS_INS_MOV_S, - MIPS_INS_MOV_D, - MIPS_INS_C_LT_S, - MIPS_INS_C_LT_D, - MIPS_INS_DIV_S, - MIPS_INS_MUL_S, - MIPS_INS_TRUNC_W_S, - MIPS_INS_CVT_S_W, - MIPS_INS_SUB_S, - MIPS_INS_ADD_S, + mips_isa.MIPS_INS_MTC0, + mips_isa.MIPS_INS_MTC1, + mips_isa.MIPS_INS_DMTC1, + mips_isa.MIPS_INS_MULT, + mips_isa.MIPS_INS_MULTU, + mips_isa.MIPS_INS_DMULT, + mips_isa.MIPS_INS_DMULTU, + mips_isa.MIPS_INS_DIV, + mips_isa.MIPS_INS_DIVU, + mips_isa.MIPS_INS_DDIV, + mips_isa.MIPS_INS_DDIVU, + mips_isa.MIPS_INS_MTHI, + mips_isa.MIPS_INS_MTLO, + mips_isa.MIPS_INS_CTC1, + mips_isa.MIPS_INS_NOP, + mips_isa.MIPS_INS_BREAK, + mips_isa.MIPS_INS_TLBP, + mips_isa.MIPS_INS_TLBR, + mips_isa.MIPS_INS_TLBWI, + mips_isa.MIPS_INS_MOV_S, + mips_isa.MIPS_INS_MOV_D, + mips_isa.MIPS_INS_C_LT_S, + mips_isa.MIPS_INS_C_LT_D, + mips_isa.MIPS_INS_DIV_S, + mips_isa.MIPS_INS_MUL_S, + mips_isa.MIPS_INS_TRUNC_W_S, + mips_isa.MIPS_INS_CVT_S_W, + mips_isa.MIPS_INS_SUB_S, + mips_isa.MIPS_INS_ADD_S, ]: clobber_conditionally(insn) @@ -1000,18 +1010,18 @@ def find_symbols_in_text(section, rodata_section, data_regions): part += ", " op_str.append(part) - elif insn.id == MIPS_INS_LUI: + elif insn.id == mips_isa.MIPS_INS_LUI: op_str = [op_str] instr["rt"] = insn.rt - elif insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: + elif insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: op_str = [op_str] instr["rt"] = insn.rt instr["rs"] = insn.rs instr["ft"] = insn.ft instr["base"] = insn.base - elif insn.id == MIPS_INS_ORI: + elif insn.id == mips_isa.MIPS_INS_ORI: op_str = [op_str] instr["rt"] = insn.rt instr["rs"] = insn.rs @@ -1031,13 +1041,13 @@ def find_symbols_in_text(section, rodata_section, data_regions): if delay_slot and delayed_insn is not None: if ( - delayed_insn.id == MIPS_INS_JAL - or delayed_insn.id == MIPS_INS_JALR - or (delayed_insn.id == MIPS_INS_JR and delayed_insn.rs == MIPS_REG_RA) + delayed_insn.id == mips_isa.MIPS_INS_JAL + or delayed_insn.id == mips_isa.MIPS_INS_JALR + or (delayed_insn.id == mips_isa.MIPS_INS_JR and delayed_insn.rs == mips_isa.MIPS_REG_RA) ): # destroy lui tracking state lui_tracker.clear() - elif delayed_insn.id == MIPS_INS_JR and vaddr == next_jtbl_jr + 4: + elif delayed_insn.id == mips_isa.MIPS_INS_JR and vaddr == next_jtbl_jr + 4: # save lui tracking state for each jtbl label for label in individual_jtbl_labels[next_jtbl_jr]: save_tracker(label, lui_tracker.copy()) @@ -1046,7 +1056,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): # save lui tracking state save_tracker(delayed_insn.offset, lui_tracker.copy()) # destroy current lui tracking state for unconditional branches - if delayed_insn.id == MIPS_INS_B: + if delayed_insn.id == mips_isa.MIPS_INS_B: lui_tracker.clear() delayed_insn = None @@ -1265,35 +1275,35 @@ def fixup_text_symbols(data, vram, data_regions, info): else: line += op_part - elif insn["id"] == MIPS_INS_LUI: + elif insn["id"] == mips_isa.MIPS_INS_LUI: symbol_value = symbols.get(vaddr, None) if symbol_value is not None: line += ( - f"{mips_gpr_names[insn['rt']]}, %hi({proper_name(symbol_value)})" + f"{ mips_isa.mips_gpr_names[insn['rt']]}, %hi({proper_name(symbol_value)})" ) else: constant_value = constants.get(vaddr, None) if constant_value is not None: line += ( - f"{mips_gpr_names[insn['rt']]}, (0x{constant_value:08X} >> 16)" + f"{ mips_isa.mips_gpr_names[insn['rt']]}, (0x{constant_value:08X} >> 16)" ) else: line += entry["op"][0] - elif insn["id"] == MIPS_INS_ADDIU or insn["id"] in MIPS_LOAD_STORE_INSNS: + elif insn["id"] == mips_isa.MIPS_INS_ADDIU or insn["id"] in MIPS_LOAD_STORE_INSNS: symbol_value = symbols.get(vaddr, None) if symbol_value is not None: - if insn["id"] == MIPS_INS_ADDIU: - line += f"{mips_gpr_names[insn['rt']]}, {mips_gpr_names[insn['rs']]}, %lo({proper_name(symbol_value)})" + if insn["id"] == mips_isa.MIPS_INS_ADDIU: + line += f"{ mips_isa.mips_gpr_names[insn['rt']]}, { mips_isa.mips_gpr_names[insn['rs']]}, %lo({proper_name(symbol_value)})" else: - line += f"{mips_fpr_names[insn['ft']] if insn['id'] in MIPS_FP_LOAD_STORE_INSNS else mips_gpr_names[insn['rt']]}, %lo({proper_name(symbol_value)})({mips_gpr_names[insn['base']]})" + line += f"{mips_isa.mips_fpr_names[insn['ft']] if insn['id'] in MIPS_FP_LOAD_STORE_INSNS else mips_isa.mips_gpr_names[insn['rt']]}, %lo({proper_name(symbol_value)})({ mips_isa.mips_gpr_names[insn['base']]})" else: line += entry["op"][0] - elif insn["id"] == MIPS_INS_ORI: + elif insn["id"] == mips_isa.MIPS_INS_ORI: constant_value = constants.get(vaddr, None) if constant_value is not None: - line += f"{mips_gpr_names[insn['rt']]}, {mips_gpr_names[insn['rs']]}, (0x{constant_value:08X} & 0xFFFF)" + line += f"{ mips_isa.mips_gpr_names[insn['rt']]}, { mips_isa.mips_gpr_names[insn['rs']]}, (0x{constant_value:08X} & 0xFFFF)" else: line += entry["op"][0] @@ -1329,7 +1339,7 @@ def disassemble_text(data, vram, data_regions, info): for i, raw_insn in enumerate(raw_insns, 0): i *= 4 vaddr = vram + i - insn = decode_insn(raw_insns[i // 4], vaddr) + insn = mips_isa.decode_insn(raw_insns[i // 4], vaddr) mnemonic = insn.mnemonic op_str = insn.op_str @@ -1389,27 +1399,27 @@ def disassemble_text(data, vram, data_regions, info): op_str_parts.append(insn.format_field(field)) op_str = ", ".join(op_str_parts) delayed_insn = insn - elif insn.id == MIPS_INS_LUI: + elif insn.id == mips_isa.MIPS_INS_LUI: symbol_value = symbols.get(vaddr, None) if symbol_value is not None: - op_str = f"{mips_gpr_names[insn.rt]}, %hi({proper_name(symbol_value)})" + op_str = f"{ mips_isa.mips_gpr_names[insn.rt]}, %hi({proper_name(symbol_value)})" else: constant_value = constants.get(vaddr, None) if constant_value is not None: op_str = ( - f"{mips_gpr_names[insn.rt]}, (0x{constant_value:08X} >> 16)" + f"{ mips_isa.mips_gpr_names[insn.rt]}, (0x{constant_value:08X} >> 16)" ) - elif insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: + elif insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: symbol_value = symbols.get(vaddr, None) if symbol_value is not None: - if insn.id == MIPS_INS_ADDIU: - op_str = f"{mips_gpr_names[insn.rt]}, {mips_gpr_names[insn.rs]}, %lo({proper_name(symbol_value)})" + if insn.id == mips_isa.MIPS_INS_ADDIU: + op_str = f"{ mips_isa.mips_gpr_names[insn.rt]}, { mips_isa.mips_gpr_names[insn.rs]}, %lo({proper_name(symbol_value)})" else: - op_str = f"{mips_fpr_names[insn.ft] if insn.id in MIPS_FP_LOAD_STORE_INSNS else mips_gpr_names[insn.rt]}, %lo({proper_name(symbol_value)})({mips_gpr_names[insn.base]})" - elif insn.id == MIPS_INS_ORI: + op_str = f"{mips_isa.mips_fpr_names[insn.ft] if insn.id in MIPS_FP_LOAD_STORE_INSNS else mips_isa.mips_gpr_names[insn.rt]}, %lo({proper_name(symbol_value)})({ mips_isa.mips_gpr_names[insn.base]})" + elif insn.id == mips_isa.MIPS_INS_ORI: constant_value = constants.get(vaddr, None) if constant_value is not None: - op_str = f"{mips_gpr_names[insn.rt]}, {mips_gpr_names[insn.rs]}, (0x{constant_value:08X} & 0xFFFF)" + op_str = f"{ mips_isa.mips_gpr_names[insn.rt]}, { mips_isa.mips_gpr_names[insn.rs]}, (0x{constant_value:08X} & 0xFFFF)" if delay_slot: mnemonic = " " + mnemonic @@ -2205,7 +2215,7 @@ for segment in files_spec: new[offset] = name full_file_list[segment[0]] = new -if args.full: +if args.all: new_spec = [] for segment in files_spec: if args.files and not any( @@ -2357,7 +2367,7 @@ for segment in files_spec: del files_spec[:] -pool = get_context("fork").Pool(jobs) +pool = multiprocessing.get_context("fork").Pool(jobs) # Find symbols for each segment for section in all_sections: if section[-1]["name"] == "makerom": @@ -2393,7 +2403,7 @@ for section in all_sections: pool.close() pool.join() -pool = get_context("fork").Pool(jobs) +pool = multiprocessing.get_context("fork").Pool(jobs) for section in all_sections: if section[-1]["type"] == "makerom": continue @@ -2418,7 +2428,7 @@ for section in all_sections: vrom_addrs = {addr for _, addr in vrom_variables} # Textual disassembly for each segment -with get_context("fork").Pool(jobs) as p: +with multiprocessing.get_context("fork").Pool(jobs) as p: p.map( disassemble_segment, [ diff --git a/tools/disasm/mips_isa.py b/tools/disasm/mips_isa.py index 44cddacd7..337bbd021 100644 --- a/tools/disasm/mips_isa.py +++ b/tools/disasm/mips_isa.py @@ -286,15 +286,26 @@ mips_cop0_names = [ "TagLo" , "TagHi" , "ErrorEPC" , "Reserved31", ] -mips_fpr_names = [ +numeric_fpr_names = [ "$f0", "$f1", "$f2", "$f3", "$f4", "$f5", "$f6", "$f7", "$f8", "$f9", "$f10", "$f11", "$f12", "$f13", "$f14", "$f15", "$f16", "$f17", "$f18", "$f19", "$f20", "$f21", "$f22", "$f23", "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", - "$31", + "$31", # Floating-point control/status register ] +o32_fpr_names = [ + "$fv0", "$fv0f", "$fv1", "$fv1f", + "$ft0", "$ft0f", "$ft1", "$ft1f", "$ft2", "$ft2f", "$ft3", "$ft3f", + "$fa0", "$fa0f", "$fa1", "$fa1f", + "$ft4", "$ft4f", "$ft5", "$ft5f", + "$fs0", "$fs0f", "$fs1", "$fs1f", "$fs2", "$fs2f", "$fs3", "$fs3f", "$fs4", "$fs4f", "$fs5", + "$31", # Floating-point control/status register +] + +mips_fpr_names = numeric_fpr_names + # Instruction field fetching def sign_extend_16(value): From 50c5ab0fc7f0941092e3671ae7e92f6ff1d892a3 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Wed, 6 Apr 2022 18:03:27 -0700 Subject: [PATCH 180/257] En_Dragon (Deep Python) OK and documented. object_utubo documented (#771) * EnDragon_Init OK * func_80B5EDF0 OK * func_80B5EAA0 OK * EnDragon_Destroy OK * EnDragon_Update OK * func_80B60138 OK * func_80B5EE3C OK * func_80B5EF88 OK * func_80B5F418 OK * func_80B5ED90 OK * func_80B5EB40 OK (commented out because data is not imported yet) * Import data into C * Uncomment func_80B5EB40 * func_80B5EFD0 OK * func_80B5F3A4 OK * func_80B5F888 OK * func_80B5FCC0 OK * Draw functions OK * func_80B5FD68 OK * func_80B5F508 OK * func_80B5F8D8 OK * Better match on func_80B5FD68 * Use generated reloc * Remove undefined_syms for this actor * Some minor cleanup * Make the data like Anghelo said * Document object_utubo * Name a bunch of stuff * Name some more stuff * Some documentation around death * Documentation for actions * Name a bunch of junk * Use regs instead of directly accessing gGameInfo * Name the player position vars * Update weekEventReg references * Name and list out states * Name timer * Document extend stuff * Finish documentation * Respond to Anghelo's review * Respond to hensldm's review * The thing Anghelo suggested *actually* matches --- assets/xml/objects/object_utubo.xml | 87 +- include/z64.h | 2 +- spec | 3 +- .../ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c | 2 +- .../actors/ovl_En_Dragon/z_en_dragon.c | 866 ++++++++++++++++-- .../actors/ovl_En_Dragon/z_en_dragon.h | 45 +- tools/disasm/functions.txt | 34 +- tools/disasm/variables.txt | 13 +- undefined_syms.txt | 5 - 9 files changed, 889 insertions(+), 168 deletions(-) diff --git a/assets/xml/objects/object_utubo.xml b/assets/xml/objects/object_utubo.xml index 68cd3e196..a1f499eb6 100644 --- a/assets/xml/objects/object_utubo.xml +++ b/assets/xml/objects/object_utubo.xml @@ -1,42 +1,53 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/z64.h b/include/z64.h index f49686c6c..6f8067136 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1322,7 +1322,7 @@ struct GlobalContext { /* 0x18760 */ DoorContext doorCtx; /* 0x18768 */ void (*playerInit)(Player* player, struct GlobalContext* globalCtx, FlexSkeletonHeader* skelHeader); /* 0x1876C */ void (*playerUpdate)(Player* player, struct GlobalContext* globalCtx, Input* input); - /* 0x18770 */ void* unk_18770; //! @TODO: Determine function prototype + /* 0x18770 */ void (*unk_18770)(struct GlobalContext* globalCtx, Player* player); /* 0x18774 */ s32 (*startPlayerFishing)(struct GlobalContext* globalCtx); /* 0x18778 */ s32 (*grabPlayer)(struct GlobalContext* globalCtx, Player* player); /* 0x1877C */ s32 (*startPlayerCutscene)(struct GlobalContext* globalCtx, Player* player, s32 mode); diff --git a/spec b/spec index c99b6bfa5..34a0c96e7 100644 --- a/spec +++ b/spec @@ -4058,8 +4058,7 @@ beginseg name "ovl_En_Dragon" compress include "build/src/overlays/actors/ovl_En_Dragon/z_en_dragon.o" - include "build/data/ovl_En_Dragon/ovl_En_Dragon.data.o" - include "build/data/ovl_En_Dragon/ovl_En_Dragon.reloc.o" + include "build/src/overlays/actors/ovl_En_Dragon/ovl_En_Dragon_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c index 15bac4d13..e5af3fe1f 100644 --- a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c +++ b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c @@ -1,7 +1,7 @@ /* * File: z_bg_sinkai_kabe.c * Overlay: ovl_Bg_Sinkai_Kabe - * Description: Large Rotating Green Rupee + * Description: Manages the Deep Pythons and Seahorse in Pinnacle Rock */ #include "z_bg_sinkai_kabe.h" diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c index 604be5441..5b7091d02 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c @@ -15,16 +15,51 @@ void EnDragon_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDragon_Update(Actor* thisx, GlobalContext* globalCtx); void EnDragon_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B5ED90(EnDragon* this, GlobalContext* globalCtx); -void func_80B5EE3C(EnDragon* this, GlobalContext* globalCtx); -void func_80B5EFD0(EnDragon* this, GlobalContext* globalCtx); -void func_80B5F418(EnDragon* this, GlobalContext* globalCtx); -void func_80B5F508(EnDragon* this, GlobalContext* globalCtx); -void func_80B5F8D8(EnDragon* this, GlobalContext* globalCtx); -void func_80B5FCC0(EnDragon* this, GlobalContext* globalCtx); -void func_80B5FD68(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_SetupRetreatOrIdle(EnDragon* this); +void EnDragon_RetreatOrIdle(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_SetupExtend(EnDragon* this); +void EnDragon_Extend(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_Grab(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_SetupAttack(EnDragon* this); +void EnDragon_Attack(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_Dead(EnDragon* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ DEEP_PYTHON_ANIMATION_SMALL_SIDE_SWAY, + /* 1 */ DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY, + /* 2 */ DEEP_PYTHON_ANIMATION_VERTICAL_SWAY, + /* 3 */ DEEP_PYTHON_ANIMATION_IDLE +} DeepPythonAnimationIndex; + +typedef enum { + /* 0 */ DEEP_PYTHON_ACTION_IDLE, + /* 1 */ DEEP_PYTHON_ACTION_EXTEND, + /* 2 */ DEEP_PYTHON_ACTION_GRAB, + /* 3 */ DEEP_PYTHON_ACTION_DAMAGE, + /* 4 */ DEEP_PYTHON_ACTION_RETREAT, + /* 5 */ DEEP_PYTHON_ACTION_SETUP_DEAD, + /* 6 */ DEEP_PYTHON_ACTION_DEAD, +} DeepPythonAction; + +typedef enum { + /* 0 */ DEEP_PYTHON_EXTEND_STATE_NOT_FULLY_EXTENDED, + /* 1 */ DEEP_PYTHON_EXTEND_STATE_FULLY_EXTENDED, + /* 2 */ DEEP_PYTHON_EXTEND_STATE_REPEAT_LARGE_SWAY, + /* 3 */ DEEP_PYTHON_EXTEND_STATE_REPEAT_SMALL_SWAY, +} DeepPythonExtendState; + +typedef enum { + /* 0 */ DEEP_PYTHON_GRAB_STATE_START, + /* 1 */ DEEP_PYTHON_GRAB_STATE_GRABBED, +} DeepPythonGrabState; + +typedef enum { + /* 0 */ DEEP_PYTHON_ATTACK_STATE_START, + /* 1 */ DEEP_PYTHON_ATTACK_STATE_RELEASED, +} DeepPythonAttackState; + +static s32 sNumPythonsDead = 0; -#if 0 const ActorInit En_Dragon_InitVars = { ACTOR_EN_DRAGON, ACTORCAT_ENEMY, @@ -37,130 +72,779 @@ const ActorInit En_Dragon_InitVars = { (ActorFunc)EnDragon_Draw, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B605F4 = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(0, 0x0), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(1, 0xF), - /* Normal arrow */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x0), - /* Goron punch */ DMG_ENTRY(0, 0x0), - /* Sword */ DMG_ENTRY(0, 0x0), - /* Goron pound */ DMG_ENTRY(0, 0x0), - /* Fire arrow */ DMG_ENTRY(0, 0x0), - /* Ice arrow */ DMG_ENTRY(0, 0x0), - /* Light arrow */ DMG_ENTRY(0, 0x0), - /* Goron spikes */ DMG_ENTRY(0, 0x0), - /* Deku spin */ DMG_ENTRY(0, 0x0), - /* Deku bubble */ DMG_ENTRY(0, 0x0), - /* Deku launch */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(1, 0xF), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(0, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0xF), - /* Spin attack */ DMG_ENTRY(0, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0xF), +typedef enum { + /* 0x0 */ DEEP_PYTHON_DMGEFF_NONE, + /* 0xF */ DEEP_PYTHON_DMGEFF_DAMAGE = 0xF +} DeepPythonDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), + /* Zora boomerang */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), + /* Normal arrow */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Ice arrow */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Light arrow */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Goron spikes */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), + /* Normal shield */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), + /* Spin attack */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), }; -// static ColliderJntSphElementInit sJntSphElementsInit[8] = { -static ColliderJntSphElementInit D_80B60614[8] = { +static ColliderJntSphElementInit sJntSphElementsInit[8] = { { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 13, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_HEAD, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 12, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_COLLAR, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 12, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_COLLAR, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 10, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_1, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 10, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_1, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 9, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_2, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 9, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_2, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 9, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_2, { { 0, 0, 0 }, 0 }, 1 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B60734 = { - { COLTYPE_HIT6, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 8, D_80B60614, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -#endif +void EnDragon_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDragon* this = THIS; -extern DamageTable D_80B605F4; -extern ColliderJntSphElementInit D_80B60614[8]; -extern ColliderJntSphInit D_80B60734; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDeepPythonSkel, &gDeepPythonSmallSideSwayAnim, this->jointTable, + this->morphTable, DEEP_PYTHON_LIMB_MAX); -extern UNK_TYPE D_060048B8; + this->actor.colChkInfo.health = 4; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.targetMode = 0xA; + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/EnDragon_Init.s") + this->collider.elements[0].dim.scale = this->collider.elements[1].dim.scale = this->collider.elements[2].dim.scale = + this->collider.elements[3].dim.scale = this->collider.elements[4].dim.scale = + this->collider.elements[5].dim.scale = this->collider.elements[6].dim.scale = + this->collider.elements[7].dim.scale = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/EnDragon_Destroy.s") + this->collider.elements[0].dim.modelSphere.radius = 150; + this->collider.elements[0].dim.modelSphere.center.x = 420; + this->collider.elements[1].dim.modelSphere.radius = 160; + this->collider.elements[1].dim.modelSphere.center.x = 630; + this->collider.elements[2].dim.modelSphere.radius = 130; + this->collider.elements[2].dim.modelSphere.center.x = 630; + this->collider.elements[3].dim.modelSphere.radius = 170; + this->collider.elements[3].dim.modelSphere.center.x = 920; + this->collider.elements[4].dim.modelSphere.radius = 150; + this->collider.elements[4].dim.modelSphere.center.x = 530; + this->collider.elements[5].dim.modelSphere.radius = 140; + this->collider.elements[5].dim.modelSphere.center.x = 730; + this->collider.elements[6].dim.modelSphere.radius = 120; + this->collider.elements[6].dim.modelSphere.center.x = 430; + this->collider.elements[7].dim.modelSphere.radius = 110; + this->collider.elements[7].dim.modelSphere.center.x = 160; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EAA0.s") + this->pythonIndex = EN_DRAGON_GET_PYTHON_INDEX(&this->actor); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->action = DEEP_PYTHON_ACTION_IDLE; + this->actor.hintId = 0xE; + this->scale = 0.5f; + this->actor.flags &= ~ACTOR_FLAG_8000000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EB40.s") + EnDragon_SetupRetreatOrIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5ED90.s") +void EnDragon_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDragon* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EDF0.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EE3C.s") +static AnimationHeader* sAnimations[] = { + &gDeepPythonSmallSideSwayAnim, + &gDeepPythonLargeSideSwayAnim, + &gDeepPythonVerticalSwayAnim, + &gDeepPythonSmallSideSwayAnim, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EF88.s") +static u8 sAnimationModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EFD0.s") +void EnDragon_ChangeAnimation(EnDragon* this, s32 animationIndex) { + f32 startFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F3A4.s") + this->animationIndex = animationIndex; + this->endFrame = Animation_GetLastFrame(sAnimations[animationIndex]); + startFrame = 0.0f; + if (this->animationIndex == DEEP_PYTHON_ANIMATION_IDLE) { + startFrame = this->endFrame; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F418.s") + Animation_Change(&this->skelAnime, sAnimations[animationIndex], 1.0f, startFrame, this->endFrame, + sAnimationModes[this->animationIndex], -4.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F508.s") +static Color_RGBA8 sBubblePrimColors[] = { + { 255, 255, 255, 255 }, + { 150, 255, 255, 255 }, + { 100, 255, 255, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F888.s") +static Color_RGBA8 sBubbleEnvColors[] = { + { 150, 150, 150, 0 }, + { 0, 100, 0, 255 }, + { 0, 0, 255, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F8D8.s") +void EnDragon_SpawnBubbles(EnDragon* this, GlobalContext* globalCtx, Vec3f basePos) { + static Vec3f sBubbleVelocity = { 0.0f, 0.0f, 0.0f }; + static Vec3f sBubbleAccel = { 0.0f, 0.1f, 0.0f }; + s32 bubbleCount; + s16 colorIndex; + s16 scale; + Vec3f bubblePos; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5FCC0.s") + bubbleCount = (s32)randPlusMinusPoint5Scaled(5.0f) + 10; + colorIndex = 0; + if (this->action == DEEP_PYTHON_ACTION_DEAD) { + colorIndex = 1; + bubbleCount = (s32)randPlusMinusPoint5Scaled(5.0f) + 10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5FD68.s") + for (i = 0; i < bubbleCount; i++) { + Math_Vec3f_Copy(&bubblePos, &basePos); + sBubbleVelocity.x = Rand_ZeroFloat(1.0f) * 23.0f; + sBubbleVelocity.y = Rand_ZeroFloat(1.0f) * 10.0f; + sBubbleVelocity.z = Rand_ZeroFloat(1.0f) * 23.0f; + bubblePos.x += randPlusMinusPoint5Scaled(i * 30.0f); + bubblePos.y += randPlusMinusPoint5Scaled(5.0f); + bubblePos.z += randPlusMinusPoint5Scaled(i * 30.0f); + sBubbleAccel.y = Rand_ZeroFloat(1.0f) * 20.0f * 3.0f; + scale = Rand_S16Offset(380, 240); + EffectSsDtBubble_SpawnCustomColor(globalCtx, &bubblePos, &sBubbleVelocity, &sBubbleAccel, + &sBubblePrimColors[colorIndex], &sBubbleEnvColors[colorIndex], scale, 30, 0); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B60138.s") +void EnDragon_RetreatOnceTimerEnds(EnDragon* this, GlobalContext* globalCtx) { + if (this->timer == 0) { + func_800B8D50(globalCtx, &this->actor, 10.0f, this->actor.world.rot.y, 10.0f, 8); + EnDragon_SetupRetreatOrIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/EnDragon_Update.s") +void EnDragon_SetupRetreatOrIdle(EnDragon* this) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_IDLE); + this->state = 0; + this->unk_2CC = 0; + this->hasGrabbedPlayer = false; + this->grabTimer = 0; + this->timer = 30; + this->actionFunc = EnDragon_RetreatOrIdle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B6043C.s") +void EnDragon_RetreatOrIdle(EnDragon* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (this->action == DEEP_PYTHON_ACTION_EXTEND) { + EnDragon_SetupExtend(this); + } else if ((this->timer != 0) && (fabsf(this->actor.world.pos.x - this->actor.home.pos.x) > 101.0f) && + (fabsf(this->actor.world.pos.z - this->actor.home.pos.z) > 101.0f)) { + this->actor.speedXZ = -100.0f; + } else { + this->actor.speedXZ = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B60494.s") + if ((fabsf(this->actor.world.pos.x - this->actor.home.pos.x) > 4.0f) && + (fabsf(this->actor.world.pos.z - this->actor.home.pos.z) > 4.0f)) { + Math_ApproachF(&this->actor.world.pos.x, this->actor.home.pos.x, 0.3f, 200.0f); + Math_ApproachF(&this->actor.world.pos.z, this->actor.home.pos.z, 0.3f, 200.0f); + } else if (this->action != DEEP_PYTHON_ACTION_IDLE) { + this->action = DEEP_PYTHON_ACTION_IDLE; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/EnDragon_Draw.s") +void EnDragon_SetupExtend(EnDragon* this) { + this->state = 0; + this->behindJawRetreatTimer = this->state; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_APPEAR_TRG); + this->retreatTimer = 250; + this->actionFunc = EnDragon_Extend; +} + +void EnDragon_Extend(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 currentFrame = this->skelAnime.curFrame; + s16 yaw; + + EnDragon_SpawnBubbles(this, globalCtx, this->jawPos); + + if (this->action >= DEEP_PYTHON_ACTION_DAMAGE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BACK); + EnDragon_SetupRetreatOrIdle(this); + } else if (this->retreatTimer == 0) { + this->action = DEEP_PYTHON_ACTION_RETREAT; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BACK); + EnDragon_SetupRetreatOrIdle(this); + } else if (this->state == DEEP_PYTHON_EXTEND_STATE_NOT_FULLY_EXTENDED) { + Vec3f extendedPos; + + Math_Vec3f_Copy(&extendedPos, &this->burrowEntrancePos); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_APPEAR - SFX_FLAG); + extendedPos.x += Math_SinS(this->actor.world.rot.y) * -530.0f; + extendedPos.z += Math_CosS(this->actor.world.rot.y) * -530.0f; + this->actor.speedXZ = 40.0f; + Math_SmoothStepToS(&this->jawZRotation, 0xFA0, 5, 0xBB8, 0x14); + + if ((fabsf(this->actor.world.pos.x - extendedPos.x) < 51.0f) && + (fabsf(this->actor.world.pos.z - extendedPos.z) < 51.0f)) { + this->actor.speedXZ = 0.0f; + Math_ApproachF(&this->actor.world.pos.x, extendedPos.x, 0.3f, 50.0f); + Math_ApproachF(&this->actor.world.pos.z, extendedPos.z, 0.3f, 50.0f); + if ((fabsf(this->actor.world.pos.x - extendedPos.x) < 4.0f) && + (fabsf(this->actor.world.pos.z - extendedPos.z) < 4.0f)) { + if (this->animationIndex != DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY); + } + + this->state = DEEP_PYTHON_EXTEND_STATE_FULLY_EXTENDED; + } + } + } else { + Math_SmoothStepToS(&this->jawZRotation, 0, 5, 0xBB8, 0x14); + SkelAnime_Update(&this->skelAnime); + if (this->state == DEEP_PYTHON_EXTEND_STATE_FULLY_EXTENDED) { + if (currentFrame < this->endFrame) { + return; + } + + this->state = DEEP_PYTHON_EXTEND_STATE_REPEAT_LARGE_SWAY; + } + + yaw = ABS_ALT(BINANG_SUB(Math_Vec3f_Yaw(&this->jawPos, &player->actor.world.pos), this->actor.shape.rot.y)); + if (yaw < 0x5000) { + // Player is in front of the jaw + if ((this->endFrame <= currentFrame) && (this->largeSwayWaitTimer == 0)) { + if (this->animationIndex != DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY); + } + + this->state = DEEP_PYTHON_EXTEND_STATE_REPEAT_LARGE_SWAY; + } + + this->behindJawRetreatTimer = 0; + } else { + // Player is in behind the jaw + if (this->state == DEEP_PYTHON_EXTEND_STATE_REPEAT_LARGE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_SMALL_SIDE_SWAY); + this->largeSwayWaitTimer = Rand_ZeroFloat(20.0f) + this->endFrame; + this->state = DEEP_PYTHON_EXTEND_STATE_REPEAT_SMALL_SWAY; + } + + this->behindJawRetreatTimer++; + if (this->behindJawRetreatTimer > 60) { + this->action = DEEP_PYTHON_ACTION_RETREAT; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BACK); + EnDragon_SetupRetreatOrIdle(this); + } + } + } +} + +void EnDragon_CameraSetAtEye(EnDragon* this, GlobalContext* globalCtx, Vec3f eye, Vec3f at) { + this->cameraId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + Math_Vec3f_Copy(&this->cameraEye, &eye); + Math_Vec3f_Copy(&this->cameraAt, &at); + Play_CameraSetAtEye(globalCtx, this->cameraId, &this->cameraAt, &this->cameraEye); +} + +void EnDragon_SetupGrab(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f extendedPos; + s16 yaw; + + if (!ActorCutscene_GetCanPlayNext(this->grabCutsceneIndex)) { + ActorCutscene_SetIntentToPlay(this->grabCutsceneIndex); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->grabCutsceneIndex, &this->actor); + Math_Vec3f_Copy(&extendedPos, &this->burrowEntrancePos); + extendedPos.x += Math_SinS(this->actor.world.rot.y) * -530.0f; + extendedPos.z += Math_CosS(this->actor.world.rot.y) * -530.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &extendedPos); + yaw = Math_Vec3f_Yaw(&player->actor.world.pos, &this->jawPos); + player->actor.shape.rot.y = yaw; + player->actor.world.rot.y = yaw; + this->state = DEEP_PYTHON_GRAB_STATE_START; + this->grabTimer = 0; + this->hasGrabbedPlayer = false; + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_IDLE); + this->actionFunc = EnDragon_Grab; + } +} + +static Vec3f sCameraEyePerPython[] = { + { 1600.0f, 0.0f, 1400.0f }, { 1400.0f, 0.0f, 400.0f }, { 1800.0f, 0.0f, 1400.f }, { 1100.0f, -200.0f, 1500.0f }, + { 2000.0f, 0.0f, 1500.0f }, { 1900.0f, 0.0f, 1800.0f }, { 1700.0f, 0.0f, 1100.0f }, { 1700.0f, 0.0f, 1100.0f }, +}; + +static Vec3f sCameraAtPerPython[] = { + { 300.0f, -100.0f, 1300.0f }, { 1500.0f, 0.0f, 2400.0f }, { 300.0f, -100.0f, 1300.0f }, { 1900.0f, 500.0f, 600.0f }, + { -1000.0f, 0.0f, 1000.0f }, { 1200.0f, 0.0f, 1500.0f }, { 1100.0f, 0.0f, 2000.0f }, { 1100.0f, 0.0f, 2000.0f }, +}; + +static s16 sZRotPerPython[] = { 0x07D0, 0x07D0, 0x07D0, 0x07D0, 0x07D0, 0x0BB8, 0x0000, 0x0000 }; + +static s32 sMaxGrabTimerPerPython[] = { 5, 5, 5, 4, 5, 8, 5, 5 }; + +void EnDragon_Grab(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp50; // used as both the extended position and the camera eye + Vec3f at; + + this->cameraId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + SkelAnime_Update(&this->skelAnime); + + if (this->grabTimer == 0) { + if (!this->hasGrabbedPlayer) { + Math_Vec3f_Copy(&player->actor.world.pos, &this->playerGrabPosition); + Math_Vec3f_Copy(&this->playerGrabPositionTemp, &this->playerGrabPosition); + this->hasGrabbedPlayer = true; + } else { + Math_Vec3f_Copy(&player->actor.world.pos, &this->playerGrabPositionTemp); + } + + Math_Vec3f_Copy(&sp50, &this->burrowEntrancePos); + sp50.x += Math_SinS(this->actor.world.rot.y) * -930.0f; + sp50.z += Math_CosS(this->actor.world.rot.y) * -930.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &sp50); + this->jawZRotation = 0x1450; + this->actor.speedXZ = 60.0f; + } + + this->grabTimer++; + Math_SmoothStepToS(&this->actor.shape.rot.z, sZRotPerPython[this->pythonIndex], 0xA, 0x1F4, 0x14); + EnDragon_SpawnBubbles(this, globalCtx, this->jawPos); + + Math_Vec3f_Copy(&sp50, &this->burrowEntrancePos); + sp50.x += Math_SinS(this->actor.world.rot.y) * sCameraEyePerPython[this->pythonIndex].x; + sp50.y += sCameraEyePerPython[this->pythonIndex].y; + sp50.z += Math_CosS(this->actor.world.rot.y) * sCameraEyePerPython[this->pythonIndex].z; + + Math_Vec3f_Copy(&at, &this->actor.world.pos); + at.x += Math_SinS(this->actor.world.rot.y) * sCameraAtPerPython[this->pythonIndex].x; + at.y += sCameraAtPerPython[this->pythonIndex].y; + at.z += Math_CosS(this->actor.world.rot.y) * sCameraAtPerPython[this->pythonIndex].z; + + EnDragon_CameraSetAtEye(this, globalCtx, sp50, at); + + if (this->grabTimer > sMaxGrabTimerPerPython[this->pythonIndex]) { + if (this->state == DEEP_PYTHON_GRAB_STATE_START) { + func_800B7298(globalCtx, &this->actor, 6); + this->state = DEEP_PYTHON_GRAB_STATE_GRABBED; + } + + globalCtx->unk_18770(globalCtx, player); + player->actor.parent = &this->actor; + player->unk_AE8 = 50; + this->action = DEEP_PYTHON_ACTION_GRAB; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_EAT); + EnDragon_SetupAttack(this); + } +} + +void EnDragon_SetupAttack(EnDragon* this) { + if (this->animationIndex != DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY); + } + + this->behindJawRetreatTimer = 0; + this->grabTimer = 0; + this->state = DEEP_PYTHON_ATTACK_STATE_START; + this->actionFunc = EnDragon_Attack; +} + +void EnDragon_Attack(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 currentFrame = this->skelAnime.curFrame; + Vec3f sp4C; // used as both the extended position and the camera eye + Vec3f at; + + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.shape.rot.z, 0, 0xA, 0x1388, 0); + if ((globalCtx->gameplayFrames % 16) == 0) { + globalCtx->damagePlayer(globalCtx, -2); + + //! @bug: This function should only pass Player*: it uses *(this + 0x153), which is meant to be + //! player->currentMask, but in this case is garbage in the skelAnime + func_800B8E58((Player*)this, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BITE); + CollisionCheck_GreenBlood(globalCtx, NULL, &player->actor.world.pos); + } + + Math_Vec3f_Copy(&sp4C, &this->actor.world.pos); + sp4C.x += Math_SinS(this->actor.world.rot.y) * 3000.0f; + sp4C.y += 600.0f; + sp4C.z += Math_CosS(this->actor.world.rot.y) * 3000.0f; + + Math_Vec3f_Copy(&at, &this->actor.world.pos); + at.x += Math_SinS(this->actor.world.rot.y) * 1200.0f; + at.y += -100.0f; + at.z += Math_CosS(this->actor.world.rot.y) * 1200.0f; + + EnDragon_CameraSetAtEye(this, globalCtx, sp4C, at); + + player->actor.world.rot.y = player->actor.shape.rot.y = this->actor.world.rot.y; + player->actor.world.rot.x = player->actor.shape.rot.x = this->actor.world.rot.x; + player->actor.world.rot.z = player->actor.shape.rot.z = this->actor.world.rot.z - 0x36B0; + Math_Vec3f_Copy(&player->actor.world.pos, &this->playerGrabPosition); + this->jawZRotation = 0xC8; + + Math_Vec3f_Copy(&sp4C, &this->burrowEntrancePos); + sp4C.x += Math_SinS(this->actor.world.rot.y) * -530.0f; + sp4C.z += Math_CosS(this->actor.world.rot.y) * -530.0f; + Math_ApproachF(&this->actor.world.pos.x, sp4C.x, 0.3f, 200.0f); + Math_ApproachF(&this->actor.world.pos.y, sp4C.y, 0.3f, 200.0f); + Math_ApproachF(&this->actor.world.pos.z, sp4C.z, 0.3f, 200.0f); + + if ((this->state <= DEEP_PYTHON_ATTACK_STATE_START) && (this->endFrame <= currentFrame)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BITE); + if (this->animationIndex != DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY); + } + + this->state++; + } + + if (((this->state != DEEP_PYTHON_ATTACK_STATE_START) && (this->endFrame <= currentFrame)) || + (!(player->stateFlags2 & 0x80)) || ((this->collider.elements[0].info.bumperFlags & BUMP_HIT)) || + (this->collider.elements[1].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[2].info.bumperFlags & BUMP_HIT)) { + player->actor.parent = NULL; + this->grabWaitTimer = 30; + ActorCutscene_Stop(this->grabCutsceneIndex); + if (player->stateFlags2 & 0x80) { + player->unk_AE8 = 100; + } + + this->actor.flags &= ~ACTOR_FLAG_100000; + + if ((this->state != DEEP_PYTHON_ATTACK_STATE_START) && (this->endFrame <= currentFrame)) { + this->timer = 3; + this->actionFunc = EnDragon_RetreatOnceTimerEnds; + } else { + EnDragon_SetupRetreatOrIdle(this); + } + } +} + +void EnDragon_SetupDead(EnDragon* this, GlobalContext* globalCtx) { + if (!ActorCutscene_GetCanPlayNext(this->deathCutsceneIndex)) { + ActorCutscene_SetIntentToPlay(this->deathCutsceneIndex); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->deathCutsceneIndex, &this->actor); + this->endFrame = Animation_GetLastFrame(&gDeepPythonSmallSideSwayAnim); + Animation_Change(&this->skelAnime, &gDeepPythonSmallSideSwayAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); + this->timer = 20; + this->actionFunc = EnDragon_Dead; + } +} + +void EnDragon_Dead(EnDragon* this, GlobalContext* globalCtx) { + Vec3f seahorsePos; + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.z += 0x1000; + this->jawZRotation = 0xFA0; + EnDragon_SpawnBubbles(this, globalCtx, this->jawPos); + + if ((this->timer != 0) && (fabsf(this->actor.world.pos.x - this->actor.home.pos.x) > 121.0f) && + (fabsf(this->actor.world.pos.z - this->actor.home.pos.z) > 121.0f)) { + this->actor.speedXZ = -120.0f; + if (((this->pythonIndex & 1) == 0) && (Rand_ZeroOne() < 0.5f)) { + //! @bug: !globalCtx->gameplayFrames is 0 essentially all the time, so this code never runs. + if (((!globalCtx->gameplayFrames) & 0x1F)) { + Item_DropCollectibleRandom(globalCtx, NULL, &this->jawPos, 0x90); + } + } + + this->action = DEEP_PYTHON_ACTION_DEAD; + return; + } + + this->actor.speedXZ = 0.0f; + if ((fabsf(this->actor.world.pos.x - this->actor.home.pos.x) > 20.0f) && + (fabsf(this->actor.world.pos.z - this->actor.home.pos.z) > 20.0f)) { + Math_ApproachF(&this->actor.world.pos.x, this->actor.home.pos.x, 0.3f, 300.0f); + Math_ApproachF(&this->actor.world.pos.z, this->actor.home.pos.z, 0.3f, 300.0f); + return; + } + + sNumPythonsDead++; + if (sNumPythonsDead >= (BREG(39) + 8)) { + Math_Vec3f_Copy(&seahorsePos, &this->actor.parent->world.pos); + seahorsePos.x += (Math_SinS((this->actor.parent->world.rot.y + 0x8000)) * (500.0f + BREG(38))); + seahorsePos.y += -100.0f + BREG(33); + seahorsePos.z += (Math_CosS((this->actor.parent->world.rot.y + 0x8000)) * (500.0f + BREG(38))); + if (Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OT, seahorsePos.x, seahorsePos.y, + seahorsePos.z, 0, this->actor.shape.rot.y, 0, 0x4000, this->actor.cutscene, + this->actor.unk20, NULL)) { + gSaveContext.save.weekEventReg[13] |= 1; + switch (this->pythonIndex) { + case 0: + gSaveContext.save.weekEventReg[83] |= 0x10; + break; + + case 1: + gSaveContext.save.weekEventReg[83] |= 0x20; + break; + + case 2: + gSaveContext.save.weekEventReg[83] |= 0x40; + break; + + case 3: + gSaveContext.save.weekEventReg[83] |= 0x80; + break; + case 4: + gSaveContext.save.weekEventReg[84] |= 1; + break; + + case 5: + gSaveContext.save.weekEventReg[84] |= 2; + break; + + case 6: + gSaveContext.save.weekEventReg[84] |= 4; + break; + + case 7: + gSaveContext.save.weekEventReg[84] |= 8; + break; + } + } + } + + Actor_MarkForDeath(&this->actor); +} + +void EnDragon_UpdateDamage(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u32 sp30; + + if ((this->action == DEEP_PYTHON_ACTION_EXTEND)) { + if ((this->collider.elements[2].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[3].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[4].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[5].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[6].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[7].info.bumperFlags & BUMP_HIT)) { + Actor_ApplyDamage(&this->actor); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); + if (this->actor.colChkInfo.health > 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_DAMAGE); + this->action = DEEP_PYTHON_ACTION_DAMAGE; + } else { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_DEAD); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_100000; + this->action = DEEP_PYTHON_ACTION_SETUP_DEAD; + this->actionFunc = EnDragon_SetupDead; + } + } + } + + if ((this->action == DEEP_PYTHON_ACTION_EXTEND) && (this->grabWaitTimer == 0) && + (player->invincibilityTimer == 0) && (this->collider.elements[0].info.ocElemFlags & OCELEM_HIT) && + (!(func_800B64FC(globalCtx, 1000.0f, &this->actor.world.pos, &sp30) >= 0.0f) || (sp30 != 1))) { + this->actor.speedXZ = 0.0f; + this->action = DEEP_PYTHON_ACTION_GRAB; + this->actor.flags |= ACTOR_FLAG_100000; + this->actionFunc = EnDragon_SetupGrab; + } +} + +void EnDragon_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDragon* this = THIS; + + if (this->retreatTimer != 0) { + this->retreatTimer--; + } + + if (this->timer != 0) { + this->timer--; + } + + if (this->largeSwayWaitTimer != 0) { + this->largeSwayWaitTimer--; + } + + if (this->grabWaitTimer != 0) { + this->grabWaitTimer--; + } + + EnDragon_UpdateDamage(this, globalCtx); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_Vec3f_Copy(&this->actor.focus.pos, &this->focusPos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + Actor_SetScale(&this->actor, this->scale); + + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + + if (this->action != DEEP_PYTHON_ACTION_GRAB) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->action < DEEP_PYTHON_ACTION_DAMAGE) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +s32 EnDragon_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnDragon* this = THIS; + + if (limbIndex == DEEP_PYTHON_LIMB_JAW) { + rot->x += this->jawXRotation; + rot->y += this->jawYRotation; + rot->z += this->jawZRotation; + } + + return false; +} + +void EnDragon_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnDragon* this = THIS; + Vec3f playerGrabOffsetFromJawPos = { 350.0f, -120.0f, -60.0f }; + + if (limbIndex == DEEP_PYTHON_LIMB_JAW) { + Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->jawPos); + playerGrabOffsetFromJawPos.x = 350.0f; + playerGrabOffsetFromJawPos.y = -120.0f; + playerGrabOffsetFromJawPos.z = -60.0f; + Matrix_MultiplyVector3fByState(&playerGrabOffsetFromJawPos, &this->playerGrabPosition); + } + + if (limbIndex == DEEP_PYTHON_LIMB_HEAD_AND_COLLAR_ROOT) { + Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->focusPos); + } + + Collider_UpdateSpheres(limbIndex, &this->collider); +} + +void EnDragon_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDragon* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnDragon_OverrideLimbDraw, EnDragon_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h index f22874804..c7ec4d81e 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h @@ -2,16 +2,53 @@ #define Z_EN_DRAGON_H #include "global.h" +#include "objects/object_utubo/object_utubo.h" + +#define EN_DRAGON_GET_PYTHON_INDEX(thisx) (((thisx)->params >> 7) & 0x1F) struct EnDragon; typedef void (*EnDragonActionFunc)(struct EnDragon*, GlobalContext*); typedef struct EnDragon { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; - /* 0x0248 */ EnDragonActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x2B0]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[DEEP_PYTHON_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[DEEP_PYTHON_LIMB_MAX]; + /* 0x248 */ EnDragonActionFunc actionFunc; + /* 0x24C */ s32 animationIndex; + /* 0x250 */ s32 pythonIndex; + /* 0x254 */ Vec3f jawPos; + /* 0x260 */ Vec3f burrowEntrancePos; // Vertically and horizontally centered on the burrow opening. Set by Bg_Sinkai_Kabe + /* 0x26C */ Vec3f playerGrabPosition; + /* 0x278 */ Vec3f cameraEye; + /* 0x278 */ Vec3f cameraAt; + /* 0x290 */ Vec3f playerGrabPositionTemp; + /* 0x29C */ Vec3f focusPos; + /* 0x2A8 */ s16 jawZRotation; + /* 0x2AA */ s16 jawYRotation; // Never initialized by the actor + /* 0x2AC */ s16 jawXRotation; // Never initialized by the actor + /* 0x2AE */ s16 retreatTimer; // If the Deep Python is extended and this timer reaches 0, it is forced to retreat back to its burrow + /* 0x2B0 */ s16 behindJawRetreatTimer; // If the player is behind the jaw, then this will count up. When it reaches 60, the Deep Python will retreat + /* 0x2B2 */ s16 largeSwayWaitTimer; // If the player is in front of the jaw, it won't play or replay the large sway animation unless this is zero. + /* 0x2B4 */ s16 timer; + /* 0x2B6 */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero + /* 0x2B8 */ s16 hasGrabbedPlayer; + /* 0x2BA */ s16 action; + /* 0x2BC */ UNK_TYPE1 unk_2BC[0x2]; + /* 0x2BE */ s16 state; + /* 0x2C0 */ s16 grabCutsceneIndex; + /* 0x2C2 */ s16 deathCutsceneIndex; + /* 0x2C4 */ UNK_TYPE1 unk_2C4[0x4]; + /* 0x2C8 */ s16 cameraId; + /* 0x2CA */ s16 grabTimer; // Counts up from the time a grab starts until the time the actor begins attacking + /* 0x2CC */ s16 unk_2CC; // Initialized, but never used + /* 0x2CE */ UNK_TYPE1 unk_2CE[0x2]; + /* 0x2D0 */ f32 endFrame; + /* 0x2D4 */ f32 scale; + /* 0x2D8 */ UNK_TYPE1 unk_2D8[0x4]; + /* 0x2DC */ ColliderJntSph collider; + /* 0x2FC */ ColliderJntSphElement colliderElements[8]; } EnDragon; // size = 0x4FC extern const ActorInit En_Dragon_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 72fadfea5..e9443093b 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -14130,24 +14130,24 @@ 0x80B5E1D8:("func_80B5E1D8",), 0x80B5E890:("EnDragon_Init",), 0x80B5EA74:("EnDragon_Destroy",), - 0x80B5EAA0:("func_80B5EAA0",), - 0x80B5EB40:("func_80B5EB40",), - 0x80B5ED90:("func_80B5ED90",), - 0x80B5EDF0:("func_80B5EDF0",), - 0x80B5EE3C:("func_80B5EE3C",), - 0x80B5EF88:("func_80B5EF88",), - 0x80B5EFD0:("func_80B5EFD0",), - 0x80B5F3A4:("func_80B5F3A4",), - 0x80B5F418:("func_80B5F418",), - 0x80B5F508:("func_80B5F508",), - 0x80B5F888:("func_80B5F888",), - 0x80B5F8D8:("func_80B5F8D8",), - 0x80B5FCC0:("func_80B5FCC0",), - 0x80B5FD68:("func_80B5FD68",), - 0x80B60138:("func_80B60138",), + 0x80B5EAA0:("EnDragon_ChangeAnimation",), + 0x80B5EB40:("EnDragon_SpawnBubbles",), + 0x80B5ED90:("EnDragon_RetreatOnceTimerEnds",), + 0x80B5EDF0:("EnDragon_SetupRetreatOrIdle",), + 0x80B5EE3C:("EnDragon_RetreatOrIdle",), + 0x80B5EF88:("EnDragon_SetupExtend",), + 0x80B5EFD0:("EnDragon_Extend",), + 0x80B5F3A4:("EnDragon_CameraSetAtEye",), + 0x80B5F418:("EnDragon_SetupGrab",), + 0x80B5F508:("EnDragon_Grab",), + 0x80B5F888:("EnDragon_SetupAttack",), + 0x80B5F8D8:("EnDragon_Attack",), + 0x80B5FCC0:("EnDragon_SetupDead",), + 0x80B5FD68:("EnDragon_Dead",), + 0x80B60138:("EnDragon_UpdateDamage",), 0x80B6031C:("EnDragon_Update",), - 0x80B6043C:("func_80B6043C",), - 0x80B60494:("func_80B60494",), + 0x80B6043C:("EnDragon_OverrideLimbDraw",), + 0x80B60494:("EnDragon_PostLimbDraw",), 0x80B60564:("EnDragon_Draw",), 0x80B60AD0:("ObjDora_Init",), 0x80B60C70:("ObjDora_Destroy",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 4fac6bb9e..c96b82408 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -14800,15 +14800,10 @@ 0x80B60754:("D_80B60754","UNK_TYPE1","",0x1), 0x80B60758:("D_80B60758","UNK_TYPE1","",0x1), 0x80B60764:("D_80B60764","UNK_TYPE1","",0x1), - 0x80B60770:("D_80B60770","f32","",0x4), - 0x80B60774:("D_80B60774","f32","",0x4), - 0x80B60778:("D_80B60778","f32","",0x4), - 0x80B6077C:("D_80B6077C","UNK_TYPE1","",0x1), - 0x80B60780:("D_80B60780","f32","",0x4), - 0x80B60788:("D_80B60788","UNK_TYPE1","",0x1), - 0x80B60790:("D_80B60790","f32","",0x4), - 0x80B607E8:("D_80B607E8","UNK_TYPE1","",0x1), - 0x80B607F0:("D_80B607F0","f32","",0x4), + 0x80B60770:("D_80B60770","Vec3f","",0xC), + 0x80B6077C:("D_80B6077C","Vec3f","",0xC), + 0x80B60788:("D_80B60788","Vec3f","[8]",0x60), + 0x80B607E8:("D_80B607E8","Vec3f","[8]",0x60), 0x80B60848:("D_80B60848","UNK_TYPE1","",0x1), 0x80B60858:("D_80B60858","UNK_TYPE1","",0x1), 0x80B60878:("D_80B60878","UNK_TYPE4","",0x4), diff --git a/undefined_syms.txt b/undefined_syms.txt index d426e0481..5852e813c 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1136,11 +1136,6 @@ D_0600D640 = 0x0600D640; D_06002950 = 0x06002950; -// ovl_En_Dragon - -D_06004398 = 0x06004398; -D_060048B8 = 0x060048B8; - // ovl_En_Ds2n D_06008038 = 0x06008038; From 8a0b0b7ec8512efd1815736860b377f7d49c7d72 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Thu, 7 Apr 2022 11:23:13 -0700 Subject: [PATCH 181/257] En_Syateki_Okuta (Shooting Gallery Octorok) OK (#772) * EnSyatekiOkuta_Init and EnSyatekiOkuta_Destroy OK * func_80A36260, func_80A362A8, func_80A362F8, and func_80A36350 OK * func_80A361F4 OK * Decomp a bunch of functions * Better match for func_80A368E0 * func_80A36CB0 OK * Draw functions OK * All functions OK * Import data to C * Use object symbols * Final cleanup and generated spec * Remove something I missed * char -> UNK_TYPE1 * Respond to reviews * Remove static from unnamed variables, whoops --- assets/xml/overlays/ovl_En_Syateki_Okuta.xml | 13 + spec | 3 +- .../ovl_En_Syateki_Okuta/z_en_syateki_okuta.c | 488 ++++++++++++++++-- .../ovl_En_Syateki_Okuta/z_en_syateki_okuta.h | 18 +- tools/disasm/functions.txt | 2 +- undefined_syms.txt | 5 - 6 files changed, 481 insertions(+), 48 deletions(-) create mode 100644 assets/xml/overlays/ovl_En_Syateki_Okuta.xml diff --git a/assets/xml/overlays/ovl_En_Syateki_Okuta.xml b/assets/xml/overlays/ovl_En_Syateki_Okuta.xml new file mode 100644 index 000000000..0f4de7c4e --- /dev/null +++ b/assets/xml/overlays/ovl_En_Syateki_Okuta.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/spec b/spec index 34a0c96e7..e102d8d2a 100644 --- a/spec +++ b/spec @@ -2722,8 +2722,7 @@ beginseg name "ovl_En_Syateki_Okuta" compress include "build/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.o" - include "build/data/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.data.o" - include "build/data/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.reloc.o" + include "build/src/overlays/actors/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c index cffef2fc9..94f2f3495 100644 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c +++ b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c @@ -5,6 +5,7 @@ */ #include "z_en_syateki_okuta.h" +#include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) @@ -15,14 +16,18 @@ void EnSyatekiOkuta_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiOkuta_Update(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiOkuta_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A36260(EnSyatekiOkuta* this); void func_80A362A8(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A362F8(EnSyatekiOkuta* this); void func_80A36350(EnSyatekiOkuta* this, GlobalContext* globalCtx); void func_80A363B4(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A36444(EnSyatekiOkuta* this); void func_80A36488(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A364C0(EnSyatekiOkuta* this); void func_80A36504(EnSyatekiOkuta* this, GlobalContext* globalCtx); void func_80A365EC(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A36CB0(EnSyatekiOkuta* this); -#if 0 const ActorInit En_Syateki_Okuta_InitVars = { ACTOR_EN_SYATEKI_OKUTA, ACTORCAT_ENEMY, @@ -35,72 +40,483 @@ const ActorInit En_Syateki_Okuta_InitVars = { (ActorFunc)EnSyatekiOkuta_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A37570 = { - { COLTYPE_HIT3, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT3, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 40, -30, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A37B88[] = { +static AnimationInfo sAnimations[] = { + { &object_okuta_Anim_00044C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_okuta_Anim_003958, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_okuta_Anim_003B24, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_okuta_Anim_003EE4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &object_okuta_Anim_00466C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_okuta_Anim_004204, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, +}; + +#include "assets/overlays/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.c" + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 66, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 6500, ICHAIN_STOP), }; -#endif +Color_RGBA8 D_80A37B90 = { 255, 255, 255, 255 }; -extern ColliderCylinderInit D_80A37570; -extern InitChainEntry D_80A37B88[]; +Color_RGBA8 D_80A37B94 = { 150, 150, 150, 255 }; -extern UNK_TYPE D_0600466C; +Vec3f D_80A37B98 = { 0.0f, -0.5, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/EnSyatekiOkuta_Init.s") +Color_RGBA8 D_80A37BA4 = { 255, 255, 255, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/EnSyatekiOkuta_Destroy.s") +Color_RGBA8 D_80A37BA8 = { 150, 150, 150, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36148.s") +void EnSyatekiOkuta_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSyatekiOkuta* this = THIS; + WaterBox* waterbox; + f32 ySurface; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A361B0.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_okuta_Skel_0033D0, &object_okuta_Anim_00466C, this->jointTable, + this->morphTable, OBJECT_OKUTA_LIMB_MAX); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A361F4.s") + this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, + &this->actor, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36260.s") + if (!(WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &ySurface, &waterbox)) || + (ySurface <= this->actor.floorHeight)) { + Actor_MarkForDeath(&this->actor); + } else { + this->actor.world.pos.y = this->actor.home.pos.y = ySurface; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A362A8.s") + this->unk_2A4 = 0; + this->unk_2AA = 0; + func_80A36260(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A362F8.s") +void EnSyatekiOkuta_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiOkuta* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36350.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36360.s") +void func_80A36148(Vec3f* pos, Vec3f* velocity, s16 scaleStep, GlobalContext* globalCtx) { + func_800B0DE0(globalCtx, pos, velocity, &gZeroVec3f, &D_80A37B90, &D_80A37B94, 400, scaleStep); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A363B4.s") +void func_80A361B0(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + EffectSsGSplash_Spawn(globalCtx, &this->actor.home.pos, NULL, NULL, 0, 800); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36444.s") +s32 func_80A361F4(EnSyatekiOkuta* this) { + s32 temp_a0; + s32 temp_a1; + s32 temp_v1; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36488.s") + temp_v1 = EN_SYATEKI_OKUTA_GET_F(&this->actor); + if ((temp_v1 == 1) || (temp_v1 == 4)) { + temp_a0 = syatekiMan->unk_190; + temp_a1 = (temp_v1 * 2) + 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A364C0.s") + if ((temp_a0 >> temp_a1) & 3) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36504.s") + if ((temp_a1 == 8) && ((temp_a0 >> 0xE) & 3)) { + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A3657C.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A365EC.s") +void func_80A36260(EnSyatekiOkuta* this) { + Animation_PlayOnceSetSpeed(&this->skelAnime, &object_okuta_Anim_00466C, 0.0f); + this->actor.draw = NULL; + this->actionFunc = func_80A362A8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A368E0.s") +void func_80A362A8(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + Actor* actorIt = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36A90.s") + while (actorIt != NULL) { + if (actorIt->id == ACTOR_EN_SYATEKI_MAN) { + this->actor.parent = actorIt; + func_80A362F8(this); + break; + } else { + actorIt = actorIt->next; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36AF8.s") +void func_80A362F8(EnSyatekiOkuta* this) { + Animation_PlayOnceSetSpeed(&this->skelAnime, &object_okuta_Anim_00466C, 0.0f); + this->actor.draw = NULL; + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_80A36350; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/EnSyatekiOkuta_Update.s") +void func_80A36350(EnSyatekiOkuta* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36CB0.s") +void func_80A36360(EnSyatekiOkuta* this) { + this->actor.draw = EnSyatekiOkuta_Draw; + this->unk_2AA = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + this->actionFunc = func_80A363B4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A370EC.s") +void func_80A363B4(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + if ((Animation_OnFrame(&this->skelAnime, 2.0f)) || (Animation_OnFrame(&this->skelAnime, 15.0f))) { + if (func_80A361F4(this)) { + return; + } else { + func_80A361B0(this, globalCtx); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OCTAROCK_JUMP); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A37294.s") + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A36444(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/EnSyatekiOkuta_Draw.s") +void func_80A36444(EnSyatekiOkuta* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + this->actionFunc = func_80A36488; +} + +void func_80A36488(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (syatekiMan->unk_26C >= 0x46) { + func_80A364C0(this); + } +} + +void func_80A364C0(EnSyatekiOkuta* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + this->actionFunc = func_80A36504; +} + +void func_80A36504(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + if (Animation_OnFrame(&this->skelAnime, 4.0f)) { + func_80A361B0(this, globalCtx); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIOCTA_LAND); + } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A362F8(this); + } +} + +void func_80A3657C(EnSyatekiOkuta* this) { + this->unk_2A4 = 0; + this->unk_2AA = 300; + if (this->unk_2A6 == 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OCTAROCK_DEAD1); + } + + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actionFunc = func_80A365EC; +} + +void func_80A365EC(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + Vec3f sp84; + Vec3f sp78; + s32 pad; + s32 i; + + if (this->unk_2AA > 0) { + this->unk_2AA -= 15; + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (this->unk_2A4 == 0) { + sp78.x = this->actor.world.pos.x; + sp78.y = this->actor.world.pos.y + 40.0f; + sp78.z = this->actor.world.pos.z; + sp84.x = 0.0f; + sp84.y = -0.5f; + sp84.z = 0.0f; + func_80A36148(&sp78, &sp84, -20, globalCtx); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OCTAROCK_DEAD2); + } + + this->unk_2A4++; + } + + if (Animation_OnFrame(&this->skelAnime, 15.0f)) { + func_80A361B0(this, globalCtx); + } + + if (this->unk_2A4 < 3) { + Actor_SetScale(&this->actor, ((this->unk_2A4 * 0.25f) + 1.0f) * 0.01f); + } else if (this->unk_2A4 < 6) { + Actor_SetScale(&this->actor, (1.5f - ((this->unk_2A4 - 2) * 0.2333f)) * 0.01f); + } else if (this->unk_2A4 < 11) { + Actor_SetScale(&this->actor, (((this->unk_2A4 - 5) * 0.04f) + 0.8f) * 0.01f); + } else { + if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.002f)) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_COMMON_WATER_MID); + for (i = 0; i < 10; i++) { + sp84.x = (Rand_ZeroOne() - 0.5f) * 7.0f; + sp84.y = Rand_ZeroOne() * 7.0f; + sp84.z = (Rand_ZeroOne() - 0.5f) * 7.0f; + EffectSsDtBubble_SpawnCustomColor(globalCtx, &this->actor.world.pos, &sp84, &D_80A37B98, &D_80A37BA4, + &D_80A37BA8, Rand_S16Offset(100, 50), 25, 0); + } + + func_80A362F8(this); + } + + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; + } +} + +void func_80A368E0(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + this->collider.dim.height = + (sCylinderInit.dim.height - this->collider.dim.yShift) * this->unk_1D8.y * this->actor.scale.y * 100.0f; + this->collider.dim.radius = sCylinderInit.dim.radius * this->actor.scale.x * 100.0f; + + if (this->actionFunc == func_80A363B4) { + if ((this->unk_2A6 == 2) && func_80A361F4(this)) { + return; + } + + if (this->skelAnime.curFrame < (this->skelAnime.endFrame - 5.0f)) { + this->collider.dim.height *= 1.35f; + } + } + + if (this->unk_2A6 == 1) { + this->collider.dim.radius += 10; + this->collider.dim.height += 15; + } + + this->collider.dim.pos.x = this->actor.world.pos.x; + // jointTable->y is the y-translation of the skeleton root + this->collider.dim.pos.y = this->actor.world.pos.y + (this->skelAnime.jointTable->y * this->actor.scale.y); + this->collider.dim.pos.z = this->actor.world.pos.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +s32 func_80A36A90(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + if ((this->actionFunc == func_80A365EC) || (this->actionFunc == func_80A36350)) { + return false; + } + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + return true; + } + + func_80A368E0(this, globalCtx); + return false; +} + +void func_80A36AF8(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + s16 temp_v1_2; + + if ((this->actionFunc != func_80A36488) && (this->actionFunc != func_80A363B4) && (syatekiMan->unk_26A == 1) && + (syatekiMan->unk_26C == 0)) { + temp_v1_2 = (syatekiMan->unk_190 >> (EN_SYATEKI_OKUTA_GET_F(&this->actor) * 2)) & 3; + if (temp_v1_2 > 0) { + Actor_SetScale(&this->actor, 0.01f); + this->unk_2A6 = temp_v1_2; + func_80A36360(this); + } + } +} + +void EnSyatekiOkuta_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSyatekiOkuta* this = THIS; + EnSyatekiMan* syatekiMan; + + this->actionFunc(this, globalCtx); + + if (this->actionFunc != func_80A36350) { + SkelAnime_Update(&this->skelAnime); + } + + func_80A36AF8(this, globalCtx); + + if (func_80A36A90(this, globalCtx)) { + syatekiMan = (EnSyatekiMan*)this->actor.parent; + if (this->unk_2A6 == 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + globalCtx->interfaceCtx.unk_25C++; + syatekiMan->unk_280++; + syatekiMan->unk_26E = 1; + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + syatekiMan->unk_26E = 2; + } + + func_80A3657C(this); + } else { + this->collider.base.acFlags &= ~AC_HIT; + } + + func_80A36CB0(this); +} + +void func_80A36CB0(EnSyatekiOkuta* this) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->actionFunc == func_80A363B4) { + if (curFrame < 8.0f) { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.0f; + } else if (curFrame < 10.0f) { + this->unk_1D8.x = this->unk_1D8.z = 1.0f; + this->unk_1D8.y = ((curFrame - 7.0f) * 0.4f) + 1.0f; + } else if (curFrame < 14.0f) { + this->unk_1D8.x = this->unk_1D8.z = ((curFrame - 9.0f) * 0.075f) + 1.0f; + this->unk_1D8.y = 1.8f - ((curFrame - 9.0f) * 0.25f); + } else { + this->unk_1D8.x = this->unk_1D8.z = 1.3f - ((curFrame - 13.0f) * 0.05f); + this->unk_1D8.y = ((curFrame - 13.0f) * 0.0333f) + 0.8f; + } + } else if (this->actionFunc == func_80A36488) { + this->unk_1D8.x = this->unk_1D8.z = 1.0f; + this->unk_1D8.y = (sin_rad((M_PI / 16) * curFrame) * 0.2f) + 1.0f; + } else if (this->actionFunc == func_80A36504) { + if (curFrame < 3.0f) { + this->unk_1D8.y = 1.0f; + } else if (curFrame < 4.0f) { + this->unk_1D8.y = (curFrame - 2.0f) + 1.0f; + } else { + this->unk_1D8.y = 2.0f - ((curFrame - 3.0f) * 0.333f); + } + this->unk_1D8.x = this->unk_1D8.z = 1.0f; + } else if (this->actionFunc == func_80A365EC) { + curFrame += this->unk_2A4; + if (curFrame >= 35.0f) { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.0f; + } else if (curFrame < 4.0f) { + this->unk_1D8.x = this->unk_1D8.z = 1.0f - (curFrame * 0.0666f); + this->unk_1D8.y = (curFrame * 0.1666f) + 1.0f; + } else if (curFrame < 25.0f) { + this->unk_1D8.x = this->unk_1D8.z = ((curFrame - 4.0f) * 0.01f) + 0.8f; + this->unk_1D8.y = 1.5f - ((curFrame - 4.0f) * 0.025f); + } else if (curFrame < 27.0f) { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = ((curFrame - 24.0f) * 0.25f) + 1.0f; + } else if (curFrame < 30.0f) { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.5f - ((curFrame - 26.0f) * 0.233f); + } else { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = ((curFrame - 29.0f) * 0.04f) + 0.8f; + } + } else { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.0f; + } +} + +s32 func_80A370EC(EnSyatekiOkuta* this, f32 arg1, Vec3f* arg2) { + if (this->actionFunc == func_80A363B4) { + arg2->y = 1.0f; + arg2->z = 1.0f; + arg2->x = (sin_rad((M_PI / 16) * arg1) * 0.4f) + 1.0f; + } else if (this->actionFunc == func_80A365EC) { + if ((arg1 >= 35.0f) || (arg1 < 25.0f)) { + return false; + } + + if (arg1 < 27.0f) { + arg2->z = 1.0f; + arg2->x = arg2->y = ((arg1 - 24.0f) * 0.5f) + 1.0f; + } else if (arg1 < 30.0f) { + arg2->z = (arg1 - 26.0f) * 0.333f + 1.0f; + arg2->x = arg2->y = 2.0f - (arg1 - 26.0f) * 0.333f; + } else { + arg2->z = 2.0f - ((arg1 - 29.0f) * 0.2f); + arg2->x = arg2->y = 1.0f; + } + } else { + return false; + } + + return true; +} + +s32 EnSyatekiOkuta_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + s32 pad; + Vec3f sp20; + f32 curFrame; + EnSyatekiOkuta* this = THIS; + + curFrame = this->skelAnime.curFrame; + if (this->actionFunc == func_80A365EC) { + curFrame += this->unk_2A4; + } + + if (limbIndex == OBJECT_OKUTA_LIMB_0E) { + sp20 = this->unk_1D8; + Matrix_Scale(sp20.x, sp20.y, sp20.z, MTXMODE_APPLY); + } else if ((limbIndex == OBJECT_OKUTA_LIMB_0F) && (func_80A370EC(this, curFrame, &sp20))) { + Matrix_Scale(sp20.x, sp20.y, sp20.z, MTXMODE_APPLY); + } + + return false; +} + +void EnSyatekiOkuta_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiOkuta* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + if (this->unk_2A6 == 1) { + gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, ovl_En_Syateki_Okuta_DL_001640); + } + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSyatekiOkuta_OverrideLimbDraw, + NULL, &this->actor); + func_8012C2DC(globalCtx->state.gfxCtx); + if (this->actionFunc == func_80A365EC) { + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 30.0f, + this->actor.world.pos.z + 20.0f, 0); + + if (this->unk_2AA >= 256) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 210, 64, 32, 255); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 210, 64, 32, this->unk_2AA); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->unk_2A6 == 2) { + gSPDisplayList(POLY_XLU_DISP++, ovl_En_Syateki_Okuta_DL_001A98); + } else { + gSPDisplayList(POLY_XLU_DISP++, ovl_En_Syateki_Okuta_DL_001B18); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h index f3f569eda..e083f26e1 100644 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h +++ b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h @@ -2,16 +2,26 @@ #define Z_EN_SYATEKI_OKUTA_H #include "global.h" +#include "objects/object_okuta/object_okuta.h" + +#define EN_SYATEKI_OKUTA_GET_F(thisx) ((thisx)->params & 0xF) struct EnSyatekiOkuta; typedef void (*EnSyatekiOkutaActionFunc)(struct EnSyatekiOkuta*, GlobalContext*); typedef struct EnSyatekiOkuta { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnSyatekiOkutaActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x120]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnSyatekiOkutaActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1DC */ Vec3f unk_1D8; + /* 0x1E4 */ Vec3s jointTable[OBJECT_OKUTA_LIMB_MAX]; + /* 0x244 */ Vec3s morphTable[OBJECT_OKUTA_LIMB_MAX]; + /* 0x2A4 */ s16 unk_2A4; + /* 0x2A6 */ s16 unk_2A6; + /* 0x2A8 */ UNK_TYPE1 unk_2A8[0x2]; + /* 0x2AA */ s16 unk_2AA; } EnSyatekiOkuta; // size = 0x2AC extern const ActorInit En_Syateki_Okuta_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e9443093b..a9893775d 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10238,7 +10238,7 @@ 0x80A36B9C:("EnSyatekiOkuta_Update",), 0x80A36CB0:("func_80A36CB0",), 0x80A370EC:("func_80A370EC",), - 0x80A37294:("func_80A37294",), + 0x80A37294:("EnSyatekiOkuta_OverrideLimbDraw",), 0x80A3735C:("EnSyatekiOkuta_Draw",), 0x80A37ED0:("ObjShutter_Init",), 0x80A37EE0:("ObjShutter_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 5852e813c..892c20e98 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1527,11 +1527,6 @@ D_0600D640 = 0x0600D640; D_06006C18 = 0x06006C18; D_0600D640 = 0x0600D640; -// ovl_En_Syateki_Okuta - -D_060033D0 = 0x060033D0; -D_0600466C = 0x0600466C; - // ovl_En_S_Goro D_060091A8 = 0x060091A8; From c2f4572d130d61e66587ea70c05675f830c29b07 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Thu, 7 Apr 2022 20:27:24 +0100 Subject: [PATCH 182/257] Document EnKujiya (Lottery Shop) (#777) * 7 * 7 * Update assets/xml/objects/object_kujiya.xml Co-authored-by: Derek Hensley Co-authored-by: Derek Hensley --- assets/xml/objects/object_kujiya.xml | 48 +++-- .../actors/ovl_En_Kujiya/z_en_kujiya.c | 200 +++++++++--------- .../actors/ovl_En_Kujiya/z_en_kujiya.h | 4 +- tools/disasm/functions.txt | 34 +-- 4 files changed, 147 insertions(+), 139 deletions(-) diff --git a/assets/xml/objects/object_kujiya.xml b/assets/xml/objects/object_kujiya.xml index 3b17d43c0..f657e8bd8 100644 --- a/assets/xml/objects/object_kujiya.xml +++ b/assets/xml/objects/object_kujiya.xml @@ -1,25 +1,31 @@  + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + 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 0e2bbf3eb..caf235b05 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c @@ -2,6 +2,8 @@ * File: z_en_kujiya.c * Overlay: ovl_En_Kujiya * Description: Clock Town - Lottery Shop + * + * (kuji = lottery, ya = shop) */ #include "z_en_kujiya.h" @@ -16,21 +18,21 @@ void EnKujiya_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKujiya_Update(Actor* thisx, GlobalContext* globalCtx); void EnKujiya_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BB09A8(EnKujiya* this); -void func_80BB09BC(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB0E44(EnKujiya* this); -void func_80BB0E58(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB0F24(EnKujiya* this); -void func_80BB0F38(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB0F94(EnKujiya* this); -void func_80BB0FA8(EnKujiya* this, GlobalContext* globalCtx); -s32 func_80BB0FF8(void); -void func_80BB1088(void); -void func_80BB10F8(void); -void func_80BB1168(EnKujiya* this); -void func_80BB1180(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB1250(EnKujiya* this); -void func_80BB1268(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupWait(EnKujiya* this); +void EnKujiya_Wait(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupTalk(EnKujiya* this); +void EnKujiya_Talk(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupGivePrize(EnKujiya* this); +void EnKujiya_GivePrize(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupFinishGivePrize(EnKujiya* this); +void EnKujiya_FinishGivePrize(EnKujiya* this, GlobalContext* globalCtx); +s32 EnKujiya_CheckBoughtTicket(void); +void EnKujiya_SetBoughtTicket(void); +void EnKujiya_UnsetBoughtTicket(void); +void EnKujiya_SetupTurnToOpen(EnKujiya* this); +void EnKujiya_TurnToOpen(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupTurnToClosed(EnKujiya* this); +void EnKujiya_TurnToClosed(EnKujiya* this, GlobalContext* globalCtx); const ActorInit En_Kujiya_InitVars = { ACTOR_EN_KUJIYA, @@ -63,141 +65,138 @@ void EnKujiya_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 30.0f; - if (func_80BB0FF8() && (gSaveContext.save.time >= CLOCK_TIME(6, 0)) && + if (EnKujiya_CheckBoughtTicket() && (gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time < CLOCK_TIME(18, 0))) { this->actor.shape.rot.y = 0; } else { this->actor.shape.rot.y = 0x7555; } - func_80BB09A8(this); + EnKujiya_SetupWait(this); } void EnKujiya_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void func_80BB09A8(EnKujiya* this) { - this->actionFunc = func_80BB09BC; +void EnKujiya_SetupWait(EnKujiya* this) { + this->actionFunc = EnKujiya_Wait; } -void func_80BB09BC(EnKujiya* this, GlobalContext* globalCtx) { +void EnKujiya_Wait(EnKujiya* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time < CLOCK_TIME(18, 0))) { - if (func_80BB0FF8()) { + if (EnKujiya_CheckBoughtTicket()) { Message_StartTextbox(globalCtx, 0x2B61, &this->actor); - this->unk_14A = 0x2B61; + this->textId = 0x2B61; // Come back tomorrow } else { Message_StartTextbox(globalCtx, 0x2B5C, &this->actor); - this->unk_14A = 0x2B5C; + this->textId = 0x2B5C; // Pick 3 numbers } - } else if (func_80BB0FF8()) { + } else if (EnKujiya_CheckBoughtTicket()) { Message_StartTextbox(globalCtx, 0x2B64, &this->actor); - this->unk_14A = 0x2B64; + this->textId = 0x2B64; // Announce winning numbers } else { Message_StartTextbox(globalCtx, 0x2B63, &this->actor); - this->unk_14A = 0x2B63; + this->textId = 0x2B63; // Exchanging winning tickets } - func_80BB0E44(this); - } else if ((gSaveContext.save.time >= CLOCK_TIME(18, 0)) && func_80BB0FF8() && (this->actor.shape.rot.y == 0)) { - func_80BB1168(this); + + EnKujiya_SetupTalk(this); + } else if ((gSaveContext.save.time >= CLOCK_TIME(18, 0)) && EnKujiya_CheckBoughtTicket() && + (this->actor.shape.rot.y == 0)) { + EnKujiya_SetupTurnToOpen(this); } else if (this->actor.xzDistToPlayer < 100.0f) { func_800B8614(&this->actor, globalCtx, 100.0f); } } -void func_80BB0B28(EnKujiya* this, GlobalContext* globalCtx) { +void EnKujiya_HandlePlayerChoice(EnKujiya* this, GlobalContext* globalCtx) { if (Message_ShouldAdvance(globalCtx)) { - if (globalCtx->msgCtx.choiceIndex == 0) { + if (globalCtx->msgCtx.choiceIndex == 0) { // Buy if (gSaveContext.save.playerData.rupees < 10) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(globalCtx, 0x2B62, &this->actor); - this->unk_14A = 0x2B62; + this->textId = 0x2B62; // Not enough Rupees } else { func_8019F208(); func_801159EC(-10); Message_StartTextbox(globalCtx, 0x2B5F, &this->actor); - this->unk_14A = 0x2B5F; + this->textId = 0x2B5F; // Enter number } - } else { + } else { // Don't buy func_8019F230(); Message_StartTextbox(globalCtx, 0x2B5E, &this->actor); - this->unk_14A = 0x2B5E; + this->textId = 0x2B5E; // Too bad } } } -void func_80BB0BF8(EnKujiya* this, GlobalContext* globalCtx) { - u32 lotteryCode; - s8 digit1; - s8 digit2; - s8 digit3; - s8* lotteryCodes; - - if (this->unk_14A == 0x2B65) { - if (this->unk_148 != 0) { - this->unk_148--; +void EnKujiya_ChooseNextDialogue(EnKujiya* this, GlobalContext* globalCtx) { + // Build suspense + if (this->textId == 0x2B65) { // Your numbers vs winning numbers + if (this->timer != 0) { + this->timer--; return; } } if (Message_ShouldAdvance(globalCtx)) { - switch (this->unk_14A) { + switch (this->textId) { case 0x2B5C: Message_StartTextbox(globalCtx, 0x2B5D, &this->actor); - this->unk_14A = 0x2B5D; + this->textId = 0x2B5D; // Buy or not break; case 0x2B60: - func_80BB1088(); + EnKujiya_SetBoughtTicket(); func_801477B4(globalCtx); - func_80BB1250(this); + EnKujiya_SetupTurnToClosed(this); break; case 0x2B64: - func_80BB10F8(); - this->unk_148 = 0x14; + EnKujiya_UnsetBoughtTicket(); + this->timer = 20; Message_StartTextbox(globalCtx, 0x2B65, &this->actor); - this->unk_14A = 0x2B65; + this->textId = 0x2B65; // Your numbers vs winning numbers break; case 0x2B65: if (CHECK_LOTTERY_NUMBERS) { Message_StartTextbox(globalCtx, 0x2B66, &this->actor); - this->unk_14A = 0x2B66; + this->textId = 0x2B66; // Won 50 Rupees } else { Message_StartTextbox(globalCtx, 0x2B67, &this->actor); - this->unk_14A = 0x2B67; + this->textId = 0x2B67; // Lost, come back tomorrow } break; case 0x2B66: func_801477B4(globalCtx); - func_80BB0F24(this); - func_80BB0F38(this, globalCtx); + EnKujiya_SetupGivePrize(this); + EnKujiya_GivePrize(this, globalCtx); break; } } } -void func_80BB0E44(EnKujiya* this) { - this->actionFunc = func_80BB0E58; +void EnKujiya_SetupTalk(EnKujiya* this) { + this->actionFunc = EnKujiya_Talk; } -void func_80BB0E58(EnKujiya* this, GlobalContext* globalCtx) { +void EnKujiya_Talk(EnKujiya* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 0: break; case 4: - func_80BB0B28(this, globalCtx); + EnKujiya_HandlePlayerChoice(this, globalCtx); break; case 5: - func_80BB0BF8(this, globalCtx); + EnKujiya_ChooseNextDialogue(this, globalCtx); break; case 6: if (Message_ShouldAdvance(globalCtx)) { - func_80BB09A8(this); + EnKujiya_SetupWait(this); } break; @@ -205,35 +204,35 @@ void func_80BB0E58(EnKujiya* this, GlobalContext* globalCtx) { if (Message_ShouldAdvance(globalCtx)) { Inventory_SaveLotteryCodeGuess(globalCtx); Message_StartTextbox(globalCtx, 0x2B60, &this->actor); - this->unk_14A = 0x2B60; + this->textId = 0x2B60; // Will announce winning numbers after 6 } break; } } -void func_80BB0F24(EnKujiya* this) { - this->actionFunc = func_80BB0F38; +void EnKujiya_SetupGivePrize(EnKujiya* this) { + this->actionFunc = EnKujiya_GivePrize; } -void func_80BB0F38(EnKujiya* this, GlobalContext* globalCtx) { +void EnKujiya_GivePrize(EnKujiya* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { - func_80BB0F94(this); + EnKujiya_SetupFinishGivePrize(this); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); } } -void func_80BB0F94(EnKujiya* this) { - this->actionFunc = func_80BB0FA8; +void EnKujiya_SetupFinishGivePrize(EnKujiya* this) { + this->actionFunc = EnKujiya_FinishGivePrize; } -void func_80BB0FA8(EnKujiya* this, GlobalContext* globalCtx) { +void EnKujiya_FinishGivePrize(EnKujiya* this, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { - func_80BB09A8(this); + EnKujiya_SetupWait(this); } } -s32 func_80BB0FF8(void) { +s32 EnKujiya_CheckBoughtTicket(void) { switch (CURRENT_DAY) { case 1: if (gSaveContext.save.weekEventReg[33] & 0x10) { @@ -256,7 +255,7 @@ s32 func_80BB0FF8(void) { return false; } -void func_80BB1088(void) { +void EnKujiya_SetBoughtTicket(void) { switch (CURRENT_DAY) { case 1: gSaveContext.save.weekEventReg[33] |= 0x10; @@ -272,7 +271,10 @@ void func_80BB1088(void) { } } -void func_80BB10F8(void) { +/** + * Used when player turns in a ticket + */ +void EnKujiya_UnsetBoughtTicket(void) { switch (CURRENT_DAY) { case 1: gSaveContext.save.weekEventReg[33] &= (u8)~0x10; @@ -288,12 +290,12 @@ void func_80BB10F8(void) { } } -void func_80BB1168(EnKujiya* this) { - this->unk_148 = 0; - this->actionFunc = func_80BB1180; +void EnKujiya_SetupTurnToOpen(EnKujiya* this) { + this->timer = 0; + this->actionFunc = EnKujiya_TurnToOpen; } -void func_80BB1180(EnKujiya* this, GlobalContext* globalCtx) { +void EnKujiya_TurnToOpen(EnKujiya* this, GlobalContext* globalCtx) { if (this->actor.cutscene != -1) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); @@ -303,25 +305,25 @@ void func_80BB1180(EnKujiya* this, GlobalContext* globalCtx) { } if (!Math_SmoothStepToS(&this->actor.shape.rot.y, 0x7555, 0xA, 0x16C, 0x16C)) { - if (this->unk_148 > 20) { + if (this->timer > 20) { if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { ActorCutscene_Stop(this->actor.cutscene); } - func_80BB09A8(this); + EnKujiya_SetupWait(this); } else { - this->unk_148++; + this->timer++; } } else { func_800B9010(&this->actor, NA_SE_EV_WINDMILL_LEVEL - SFX_FLAG); } } -void func_80BB1250(EnKujiya* this) { - this->unk_148 = 0; - this->actionFunc = func_80BB1268; +void EnKujiya_SetupTurnToClosed(EnKujiya* this) { + this->timer = 0; + this->actionFunc = EnKujiya_TurnToClosed; } -void func_80BB1268(EnKujiya* this, GlobalContext* globalCtx) { +void EnKujiya_TurnToClosed(EnKujiya* this, GlobalContext* globalCtx) { if (this->actor.cutscene != -1) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); @@ -331,13 +333,13 @@ void func_80BB1268(EnKujiya* this, GlobalContext* globalCtx) { } if (!Math_SmoothStepToS(&this->actor.shape.rot.y, 0, 0xA, 0x16C, 0x16C)) { - if (this->unk_148 > 20) { + if (this->timer > 20) { if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { ActorCutscene_Stop(this->actor.cutscene); } - func_80BB09A8(this); + EnKujiya_SetupWait(this); } else { - this->unk_148++; + this->timer++; } } else { func_800B9010(&this->actor, NA_SE_EV_WINDMILL_LEVEL - SFX_FLAG); @@ -353,23 +355,23 @@ void EnKujiya_Update(Actor* thisx, GlobalContext* globalCtx) { void EnKujiya_Draw(Actor* thisx, GlobalContext* globalCtx) { EnKujiya* this = THIS; - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_kujiya_Matanimheader_006198)); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gLotteryShopTexAnim)); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_002A80); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_003030); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_003248); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_003358); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_0034A8); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_0035B8); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_0036B0); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_0037C0); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_003C80); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_003D58); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopCylinderDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopBackSignDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopOpenBoxDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopScrollingEffectsDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopRedRupeesDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopGreenRupeesDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopBlueRupeesDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopTargetArrowAndSignDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopScrollingArrowDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopMaskDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h index bfb50e5af..b95a5bb36 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h @@ -10,8 +10,8 @@ typedef void (*EnKujiyaActionFunc)(struct EnKujiya*, GlobalContext*); typedef struct EnKujiya { /* 0x000 */ Actor actor; /* 0x144 */ EnKujiyaActionFunc actionFunc; - /* 0x148 */ s16 unk_148; - /* 0x14A */ s16 unk_14A; + /* 0x148 */ s16 timer; + /* 0x14A */ s16 textId; } EnKujiya; // size = 0x14C extern const ActorInit En_Kujiya_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index a9893775d..d1bc43e78 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -15274,23 +15274,23 @@ 0x80BB03E8:("EnZod_Draw",), 0x80BB08E0:("EnKujiya_Init",), 0x80BB0998:("EnKujiya_Destroy",), - 0x80BB09A8:("func_80BB09A8",), - 0x80BB09BC:("func_80BB09BC",), - 0x80BB0B28:("func_80BB0B28",), - 0x80BB0BF8:("func_80BB0BF8",), - 0x80BB0E44:("func_80BB0E44",), - 0x80BB0E58:("func_80BB0E58",), - 0x80BB0F24:("func_80BB0F24",), - 0x80BB0F38:("func_80BB0F38",), - 0x80BB0F94:("func_80BB0F94",), - 0x80BB0FA8:("func_80BB0FA8",), - 0x80BB0FF8:("func_80BB0FF8",), - 0x80BB1088:("func_80BB1088",), - 0x80BB10F8:("func_80BB10F8",), - 0x80BB1168:("func_80BB1168",), - 0x80BB1180:("func_80BB1180",), - 0x80BB1250:("func_80BB1250",), - 0x80BB1268:("func_80BB1268",), + 0x80BB09A8:("EnKujiya_SetupWait",), + 0x80BB09BC:("EnKujiya_Wait",), + 0x80BB0B28:("EnKujiya_HandlePlayerChoice",), + 0x80BB0BF8:("EnKujiya_ChooseNextDialogue",), + 0x80BB0E44:("EnKujiya_SetupTalk",), + 0x80BB0E58:("EnKujiya_Talk",), + 0x80BB0F24:("EnKujiya_SetupGivePrize",), + 0x80BB0F38:("EnKujiya_GivePrize",), + 0x80BB0F94:("EnKujiya_SetupFinishGivePrize",), + 0x80BB0FA8:("EnKujiya_FinishGivePrize",), + 0x80BB0FF8:("EnKujiya_CheckBoughtTicket",), + 0x80BB1088:("EnKujiya_SetBoughtTicket",), + 0x80BB10F8:("EnKujiya_UnsetBoughtTicket",), + 0x80BB1168:("EnKujiya_SetupTurnToOpen",), + 0x80BB1180:("EnKujiya_TurnToOpen",), + 0x80BB1250:("EnKujiya_SetupTurnToClosed",), + 0x80BB1268:("EnKujiya_TurnToClosed",), 0x80BB1338:("EnKujiya_Update",), 0x80BB135C:("EnKujiya_Draw",), 0x80BB16D0:("func_80BB16D0",), From 06412c070f0240eacfaa860eee99b9c723245b7f Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Thu, 7 Apr 2022 12:39:11 -0700 Subject: [PATCH 183/257] Cleanup 3 (#778) * lights * D_801D88A0 -> gScarecrowSpawnSongPtr * Misc fixes * CHECK_FLAG_ALL * Trailing commas in enums * matches * Remove todo from lights bss * Update src/overlays/actors/ovl_En_In/z_en_in.c Co-authored-by: Anghelo Carvajal * thisx -> this2 * fix * Todos Co-authored-by: Anghelo Carvajal --- include/variables.h | 4 +- include/z64.h | 2 +- include/z64audio.h | 2 +- include/z64item.h | 2 +- include/z64light.h | 1 - include/z64ocarina.h | 2 +- spec | 1 - src/code/z_lights.c | 7 ++- src/code/z_sram_NES.c | 3 +- .../actors/ovl_Bg_Ingate/z_bg_ingate.c | 8 +-- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 2 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 35 +++++------- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 2 +- src/overlays/actors/ovl_En_Door/z_en_door.c | 2 +- .../actors/ovl_En_Floormas/z_en_floormas.c | 2 +- src/overlays/actors/ovl_En_Gg/z_en_gg.c | 4 +- src/overlays/actors/ovl_En_Hs/z_en_hs.c | 2 +- src/overlays/actors/ovl_En_In/z_en_in.c | 18 +++--- .../actors/ovl_En_Minislime/z_en_minislime.c | 8 +-- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 55 ++++++++----------- src/overlays/actors/ovl_En_Tru/z_en_tru.h | 2 + src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c | 3 +- src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c | 20 +++---- tools/disasm/functions.txt | 6 +- 24 files changed, 93 insertions(+), 100 deletions(-) diff --git a/include/variables.h b/include/variables.h index 1ce8e336d..605b63939 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1736,7 +1736,7 @@ extern UNK_PTR D_801D84F0; // extern UNK_TYPE2 D_801D853E; // extern UNK_TYPE1 D_801D8544; extern UNK_PTR D_801D889C; -extern UNK_PTR D_801D88A0; +extern u8* gScarecrowSpawnSongPtr; extern UNK_PTR D_801D88A4; // extern UNK_TYPE1 D_801D88A8; // extern UNK_TYPE1 D_801D88B8; @@ -3200,7 +3200,7 @@ extern s16 D_801F4E7A; // extern UNK_TYPE1 D_801F4F66; // extern UNK_TYPE1 D_801F4F68; // extern UNK_TYPE1 D_801F4F6A; -extern LightsBuffer sLightsBuffer; +// extern LightsBuffer sLightsBuffer; // extern UNK_TYPE1 D_801F5130; // extern UNK_TYPE1 D_801F5270; // extern UNK_TYPE1 D_801F528E; diff --git a/include/z64.h b/include/z64.h index 6f8067136..3a7c7ea32 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1156,7 +1156,7 @@ typedef struct { typedef enum { /* 0 */ DISTORTION_INACTIVE, /* 1 */ DISTORTION_ACTIVE, - /* 2 */ DISTORTION_SETUP, + /* 2 */ DISTORTION_SETUP } DistortionState; typedef struct { diff --git a/include/z64audio.h b/include/z64audio.h index ec0fcd797..5dd78f73a 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -32,7 +32,7 @@ typedef enum { /* 1 */ AUDIO_MODE_HEADSET, /* 2 */ AUDIO_MODE_UNK, /* 3 */ AUDIO_MODE_MONO, - /* 4 */ AUDIO_MODE_SURROUND, + /* 4 */ AUDIO_MODE_SURROUND } AudioSoundMode; typedef enum { diff --git a/include/z64item.h b/include/z64item.h index 77ceb240c..a3c8a7c70 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -386,7 +386,7 @@ typedef enum { /* 0x6A */ GID_6A = 0x6A, /* 0x6B */ GID_6B, /* 0x70 */ GID_70 = 0x70, - /* 0x71 */ GID_71, + /* 0x71 */ GID_71 } GetItemDrawID; // TODO: fill diff --git a/include/z64light.h b/include/z64light.h index 8154ca401..0c90be713 100644 --- a/include/z64light.h +++ b/include/z64light.h @@ -63,7 +63,6 @@ typedef struct LightNode { /* 0x8 */ struct LightNode* next; } LightNode; // size = 0xC -// TODO move LightsBuffer to .c file once .bss has been split #define LIGHTS_BUFFER_SIZE 32 typedef struct LightsBuffer { diff --git a/include/z64ocarina.h b/include/z64ocarina.h index ed634f520..56ab48312 100644 --- a/include/z64ocarina.h +++ b/include/z64ocarina.h @@ -81,7 +81,7 @@ typedef enum { /* 13 */ OCARINA_INSTRUMENT_PIANO, /* 14 */ OCARINA_INSTRUMENT_BASS_GUITAR, /* 15 */ OCARINA_INSTRUMENT_BABY_SINGING, - /* 16 */ OCARINA_INSTRUMENT_AMPLIFIED_GUITAR, // Related to (gSaveContext.weekEventReg[41] & 0x20) + /* 16 */ OCARINA_INSTRUMENT_AMPLIFIED_GUITAR // Related to (gSaveContext.weekEventReg[41] & 0x20) } OcarinaInstrumentId; typedef enum { diff --git a/spec b/spec index e102d8d2a..b974bd390 100644 --- a/spec +++ b/spec @@ -486,7 +486,6 @@ beginseg include "build/src/code/z_lib.o" include "build/src/code/z_lifemeter.o" include "build/src/code/z_lights.o" - include "build/data/code/z_lights.bss.o" include "build/src/code/z_malloc.o" include "build/src/code/z_map_disp.o" include "build/data/code/z_map_disp.data.o" diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 615e11e69..2b0db8ad4 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -1,6 +1,8 @@ #include "global.h" #include "objects/gameplay_keep/gameplay_keep.h" +LightsBuffer sLightsBuffer; + void Lights_PointSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius, s32 type) { info->type = type; info->params.point.x = x; @@ -128,6 +130,7 @@ void Lights_BindPoint(Lights* lights, LightParams* params, GlobalContext* global Vec3f posF; Vec3f adjustedPos; u32 pad; + if (radiusF > 0) { posF.x = params->point.x; posF.y = params->point.y; @@ -373,7 +376,7 @@ void Lights_GlowCheck(GlobalContext* globalCtx) { LightNode* light = globalCtx->lightCtx.listHead; while (light != NULL) { - LightPoint* params = (LightPoint*)&light->info->params; + LightPoint* params = &light->info->params.point; if (light->info->type == LIGHT_POINT_GLOW) { Vec3f pos; @@ -422,7 +425,7 @@ void Lights_DrawGlow(GlobalContext* globalCtx) { do { if (light->info->type == LIGHT_POINT_GLOW) { - params = (LightPoint*)&light->info->params; + params = &light->info->params.point; if (params->drawGlow) { f32 scale = SQ((f32)params->radius) * 2e-6f; diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index b1dbdb1fe..52acc9379 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -979,7 +979,8 @@ void Sram_OpenSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) { } if (gSaveContext.save.unk_F65) { - Lib_MemCpy(D_801D88A0, gSaveContext.save.scarecrowsSong, sizeof(gSaveContext.save.scarecrowsSong)); + Lib_MemCpy(gScarecrowSpawnSongPtr, gSaveContext.save.scarecrowsSong, + sizeof(gSaveContext.save.scarecrowsSong)); for (i = 0; i != ARRAY_COUNT(gSaveContext.save.scarecrowsSong); i++) {} } diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index 9020f368c..8c55cc2f3 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -164,7 +164,7 @@ void func_80953F14(BgIngate* this, GlobalContext* globalCtx) { player->actor.focus.rot.y = player->actor.shape.rot.y; this->unk160 |= 0x10; func_80953DA8(this, globalCtx); - if (this->unk164 != 0) { + if (this->unk164 != NULL) { func_80953B40(this); } this->unk16E = -1; @@ -259,7 +259,7 @@ void func_809542A0(BgIngate* this, GlobalContext* globalCtx) { void func_80954340(BgIngate* this, GlobalContext* globalCtx) { if (!DECR(this->unk16A)) { - if (this->unk164 != 0) { + if (this->unk164 != NULL) { func_800B7298(globalCtx, &this->dyna.actor, 6); this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; func_80953F14(this, globalCtx); @@ -285,7 +285,7 @@ void func_809543D4(BgIngate* this, GlobalContext* globalCtx) { func_800FE498(); func_8019F208(); } else { - if (this->unk164 != 0) { + if (this->unk164 != NULL) { this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; } func_80953F14(this, globalCtx); @@ -351,7 +351,7 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { } } this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); - if (this->unk164 != 0) { + if (this->unk164 != NULL) { sp38 = Lib_SegmentedToVirtual(this->unk164->points); Math_Vec3s_ToVec3f(&sp2C, &sp38[0]); Math_Vec3s_ToVec3f(&sp20, &sp38[1]); diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index e15122688..b51fc64ec 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -633,7 +633,7 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Scale(this->particles[i].scale * alphaScale, this->particles[i].scale * alphaScale, this->particles[i].scale * alphaScale, MTXMODE_APPLY); alphaScale = Math_Vec3f_DistXYZ(&worldPos, &globalCtx->view.eye) / 300.0f; - alphaScale = (alphaScale > 1.0f) ? 0.0f : (1.0f - alphaScale) > 1.0f ? 1.0f : 1.0f - alphaScale; + alphaScale = CLAMP(1.0f - alphaScale, 0.0f, 1.0f); if (this->actor.params == DEMO_KANKYO_TYPE_GIANTS) { this->particles[i].alpha = 255.0f * alphaScale; diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index ac5b19ecf..38ab1c5d2 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -1014,7 +1014,6 @@ void EnBigpo_RevealedFireIdle(EnBigpo* this, GlobalContext* globalCtx) { if (this->idleTimer == 0) { //! @bug: unreachable code this->actor.params = ENBIGPO_UNK5; - return; } } else { if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.001f)) { @@ -1089,7 +1088,7 @@ void EnBigpo_UpdateColor(EnBigpo* this) { // this might be a triple ternary but it matches and is easier to read spread out bplus5 = this->mainColor.b + 5; - if (this->mainColor.b >= 211) { + if (this->mainColor.b > 210) { bminus5 = this->mainColor.b - 5; if (bminus5 < 210) { this->mainColor.b = 210; @@ -1097,7 +1096,7 @@ void EnBigpo_UpdateColor(EnBigpo* this) { this->mainColor.b = bminus5; } } else { - if (bplus5 >= 211) { + if (bplus5 > 210) { this->mainColor.b = 210; } else { this->mainColor.b = bplus5; @@ -1153,7 +1152,7 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; ColliderCylinder* thisCollider; - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->hoverHeightCycleTimer = 0; this->savedHeight = this->actor.world.pos.y; } @@ -1265,25 +1264,20 @@ void EnBigpo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (limbByte != -1) { if (limbByte < 3) { Matrix_GetStateTranslation(&this->limbPos[limbByte]); - return; - } - if (limbByte == 3) { + } else if (limbByte == 3) { Matrix_GetStateTranslationAndScaledX(3000.0f, &this->limbPos[limbByte]); - return; - } - if (limbByte == 4) { + } else if (limbByte == 4) { Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->limbPos[limbByte]); - return; - } + } else { + v2ptr = &this->limbPos[limbByte + 1]; + v1ptr = D_80B65084; + Matrix_GetStateTranslationAndScaledX(-4000.0f, &this->limbPos[limbByte]); - v2ptr = &this->limbPos[limbByte + 1]; - v1ptr = D_80B65084; - Matrix_GetStateTranslationAndScaledX(-4000.0f, &this->limbPos[limbByte]); - - for (i = limbByte + 1; i < ARRAY_COUNT(this->limbPos); i++) { - Matrix_MultiplyVector3fByState(v1ptr, v2ptr); - v2ptr++; - v1ptr++; + for (i = limbByte + 1; i < ARRAY_COUNT(this->limbPos); i++) { + Matrix_MultiplyVector3fByState(v1ptr, v2ptr); + v2ptr++; + v1ptr++; + } } } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -1443,6 +1437,7 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(this->fires); i++) { EnBigpoFireEffect* firePtr = &this->fires[i]; + Lights_PointNoGlowSetInfo(&this->fires[i].info, this->fires[i].pos.x, this->fires[i].pos.y, this->fires[i].pos.z, 170, 255, 255, fireRadius); mtfxPtr->wx = firePtr->pos.x; diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index c0c1326a3..5428e701a 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -2176,7 +2176,7 @@ void EnBigslime_SetupDamageGekko(EnBigslime* this, s32 isNotFrozen) { } EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_DAMAGE); - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->actor.flags &= ~ACTOR_FLAG_2000; } diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.c b/src/overlays/actors/ovl_En_Door/z_en_door.c index 1fdbbd32f..bb1c574e2 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -514,7 +514,7 @@ s32 EnDoor_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList *dList = dl[dlIndex]; } } - return 0; + return false; } void EnDoor_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index 489d46441..de7d34024 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -558,7 +558,7 @@ void func_808D19D4(EnFloormas* this) { this->drawDmgEffAlpha = 0.0f; Actor_SetScale(&this->actor, 0.004f); this->actor.flags |= ACTOR_FLAG_10; - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_80) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { this->actor.draw = func_808D3754; } else { this->actor.draw = EnFloormas_Draw; 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 d889bc7a0..3d80cc847 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -230,7 +230,7 @@ void func_80B35450(EnGg* this, GlobalContext* globalCtx) { } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_80) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { func_800B90F4(globalCtx); } this->unk_308 = 1; @@ -239,7 +239,7 @@ void func_80B35450(EnGg* this, GlobalContext* globalCtx) { if (gSaveContext.save.weekEventReg[19] & 0x80) { func_800B863C(&this->actor, globalCtx); this->actor.textId = 0xCEE; - } else if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_80) { + } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { func_800B863C(&this->actor, globalCtx); this->actor.textId = 0xCE5; } 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 2f68a1a1d..e15e3adb3 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -261,7 +261,7 @@ void func_8095345C(EnHs* this, GlobalContext* globalCtx) { } else if (this->actor.home.rot.x >= 20) { this->actionFunc = func_80953354; this->unk_2A2 = 40; - } else if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_10000) { + } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_10000)) { func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); this->unk_2A0 |= 1; } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x2000, globalCtx)) { 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 57c4bfe47..758543f45 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -295,9 +295,10 @@ void func_808F3690(EnIn* this, GlobalContext* globalCtx) { } void func_808F374C(EnIn* this, GlobalContext* globalCtx) { - AnimationHeader* animations[] = { &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[] = { + &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, + }; if (this->skelAnime.animation == &object_in_Anim_016484 || this->skelAnime.animation == &object_in_Anim_0170DC) { if (Animation_OnFrame(&this->skelAnime, 8.0f)) { @@ -312,9 +313,10 @@ void func_808F374C(EnIn* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_CRY_0); } if (SkelAnime_Update(&this->skelAnime)) { - this->unk486 = this->unk488 %= 8; - Animation_Change(&this->skelAnime, animations[this->unk488], 1.0f, 0.0f, - Animation_GetLastFrame(animations[this->unk488]), 2, -10.0f); + 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]), 2, -10.0f); } } @@ -1365,7 +1367,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk4AC = 0; type = ENIN_GET_TYPE(thisx); this->unk4B0 = GET_RACE_FLAGS; - if (type == ENIN_HORSE_RIDER_BLUE_SHIRT || type == 4) { + if (type == ENIN_HORSE_RIDER_BLUE_SHIRT || type == ENIN_BLUE_SHIRT) { this->unk4AC |= 8; } if (type == ENIN_HORSE_RIDER_YELLOW_SHIRT || type == ENIN_HORSE_RIDER_BLUE_SHIRT) { @@ -1385,7 +1387,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { this->path = SubS_GetPathByIndex(globalCtx, ENIN_GET_PATH(&this->actor), 0x3F); this->unk23D = 0; if (type == ENIN_YELLOW_SHIRT || type == ENIN_BLUE_SHIRT) { - if (GET_RACE_FLAGS == RACE_FLAG_2 || (GET_RACE_FLAGS) == RACE_FLAG_3) { + if (GET_RACE_FLAGS == RACE_FLAG_2 || GET_RACE_FLAGS == RACE_FLAG_3) { gSaveContext.save.weekEventReg[56] &= (u8)~8; this->unk4A8 = 0; this->unk4AC |= 2; diff --git a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c index ea4389917..4efc18714 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -506,7 +506,7 @@ void EnMinislime_SetupMoveToBigslime(EnMinislime* this) { } this->frozenAlpha = 0; - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->actor.flags &= ~ACTOR_FLAG_2000; } this->actionFunc = EnMinislime_MoveToBigslime; @@ -562,7 +562,7 @@ void EnMinislime_SetupDefeatIdle(EnMinislime* this) { } this->frozenAlpha = 0; - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->actor.flags &= ~ACTOR_FLAG_2000; } @@ -630,7 +630,7 @@ void EnMinislime_SetupMoveToGekko(EnMinislime* this) { this->actor.velocity.y = 0.0f; this->collider.base.acFlags &= ~AC_ON; this->collider.base.ocFlags1 &= ~OC1_ON; - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->actor.flags &= ~ACTOR_FLAG_2000; } @@ -720,7 +720,7 @@ void EnMinislime_Update(Actor* thisx, GlobalContext* globalCtx) { } else if ((this->actor.params == MINISLIME_FORM_BIGSLIME) && (this->actionFunc != EnMinislime_MoveToBigslime)) { EnMinislime_SetupMoveToBigslime(this); } else { - if CHECK_FLAG_ALL (this->actor.flags, ACTOR_FLAG_2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->collider.base.acFlags &= ~AC_HIT; return; } diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index 909cc2f99..ea0e8ae44 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -807,42 +807,33 @@ s32 func_80A875AC(Actor* thisx, GlobalContext* globalCtx) { } s32 func_80A8777C(Actor* thisx, GlobalContext* globalCtx) { - s32 temp_v0; + EnTru* this = THIS; s32 ret = 0; - - temp_v0 = Message_GetState(&globalCtx->msgCtx); + s32 temp_v0 = Message_GetState(&globalCtx->msgCtx); switch (temp_v0) { - default: - if (temp_v0 != 0x10) { - break; - } - if (0) { - - case 4: - case 5: - if (!Message_ShouldAdvance(globalCtx)) { - break; + case 4: + case 5: + if (Message_ShouldAdvance(globalCtx)) { + case 16: + temp_v0 = func_80123810(globalCtx); + if ((temp_v0 == 35) || (temp_v0 == 36)) { + this->unk_34E |= 8; + if (temp_v0 == 35) { + this->unk_390 = 1; + } else { + this->unk_390 = 2; + } + this->unk_378 = func_80A87880; + this->unk_364 = 0; + ret = 1; + } else if (temp_v0 < 0) { + ret = 3; + } else if (temp_v0 != 0) { + ret = 2; } + break; } - - temp_v0 = func_80123810(globalCtx); - if ((temp_v0 == 35) || (temp_v0 == 36)) { - ((EnTru*)thisx)->unk_34E |= 8; - if (temp_v0 == 35) { - ((EnTru*)thisx)->unk_390 = 1; - } else { - ((EnTru*)thisx)->unk_390 = 2; - } - ((EnTru*)thisx)->unk_378 = func_80A87880; - ((EnTru*)thisx)->unk_364 = 0; - ret = 1; - } else if (temp_v0 < 0) { - ret = 3; - } else if (temp_v0 != 0) { - ret = 2; - } - break; } return ret; @@ -1127,7 +1118,7 @@ void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); this->unk_37C = -1; func_80A86924(this, 0); - this->path = SubS_GetDayDependentPath(globalCtx, this->actor.params & 0xFF, 255, &this->unk_384); + this->path = SubS_GetDayDependentPath(globalCtx, ENTRU_GET_PATH(&this->actor), 255, &this->unk_384); if (this->path != NULL) { this->unk_384 = 1; } diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.h b/src/overlays/actors/ovl_En_Tru/z_en_tru.h index 4127fcdff..d1090cec4 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.h +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.h @@ -8,6 +8,8 @@ struct EnTru; typedef void (*EnTruActionFunc)(struct EnTru*, GlobalContext*); typedef s32 (*EnTruUnkFunc)(Actor*, GlobalContext*); +#define ENTRU_GET_PATH(thisx) ((thisx)->params & 0xFF) + typedef struct { /* 0x00 */ u8 unk_00; /* 0x01 */ u8 unk_01; diff --git a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c index 18aafc07a..c6de60ce2 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c @@ -465,7 +465,8 @@ void MirRay_SetupReflectionPolys(MirRay* this, GlobalContext* globalCtx, MirRayS // Remove reflections that are in the same position and are sufficiently near to the same plane void MirRay_RemoveSimilarReflections(MirRayShieldReflection* reflection) { - s32 i, j; + s32 i; + s32 j; for (i = 0; i < 6; i++) { for (j = i + 1; j < 6; j++) { diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c index 2d84030f1..8a822bea4 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -64,7 +64,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void ObjChan_InitChandelier(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_InitChandelier(ObjChan* this2, GlobalContext* globalCtx); void ObjChan_InitPot(ObjChan* this, GlobalContext* globalCtx); void ObjChan_CreateSmashParticles(ObjChan* this, GlobalContext* globalCtx); void ObjChan_DrawPot(Actor* thisx, GlobalContext* globalCtx); @@ -150,8 +150,9 @@ void ObjChan_CalculatePotPosition(Vec3f* childPosOut, Vec3s* childRotOut, Vec3f* childRotOut->y += childAngle; } -void ObjChan_InitChandelier(ObjChan* this, GlobalContext* globalCtx) { - s32 j; +//! @TODO: Possibly takes actor and recasts +void ObjChan_InitChandelier(ObjChan* this2, GlobalContext* globalCtx) { + ObjChan* this = this2; s32 i; ObjChan* temp_v0; Vec3f childPos; @@ -173,13 +174,11 @@ void ObjChan_InitChandelier(ObjChan* this, GlobalContext* globalCtx) { } for (i = 0; i < 5; i++) { - temp_v0 = (ObjChan*)&globalCtx->actorCtx; // strange cast needed for matching ObjChan_CalculatePotPosition(&childPos, &childRot, &this->actor.world.pos, &this->actor.shape.rot, (s32)(i * 360.0f / 5.0f * (65536.0f / 360.0f)) + this->rotation); - temp_v0 = (ObjChan*)Actor_SpawnAsChildAndCutscene((ActorContext*)temp_v0, globalCtx, ACTOR_OBJ_CHAN, childPos.x, - childPos.y, childPos.z, childRot.x, childRot.y, childRot.z, - (this->actor.params & 0xFFF) | 0x1000, this->actor.cutscene, - this->actor.unk20, &this->actor); + temp_v0 = (ObjChan*)Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_OBJ_CHAN, childPos.x, childPos.y, childPos.z, childRot.x, childRot.y, + childRot.z, (this->actor.params & 0xFFF) | 0x1000, this->actor.cutscene, this->actor.unk20, &this->actor); if (temp_v0 != NULL) { this->pots[i] = temp_v0; temp_v0->myPotIndex = i; @@ -210,8 +209,9 @@ void ObjChan_InitChandelier(ObjChan* this, GlobalContext* globalCtx) { this->actionFunc = ObjChan_ChandelierAction; } -void ObjChan_ChandelierAction(ObjChan* thisx, GlobalContext* globalCtx) { - ObjChan* this = thisx; +//! @TODO: More descriptive name than Action? +void ObjChan_ChandelierAction(ObjChan* this2, GlobalContext* globalCtx) { + ObjChan* this = this2; ObjChan* temp; s32 i; Vec3f sp60; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index d1bc43e78..bed963c7a 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -15376,11 +15376,11 @@ 0x80BB99F0:("ObjChan_Destroy",), 0x80BB9A1C:("func_80BB9A1C",), 0x80BB9B40:("ObjChan_CalculatePotPosition",), - 0x80BB9C08:("ObjChan_InitMain",), - 0x80BB9F24:("ObjChan_MainAction",), + 0x80BB9C08:("ObjChan_InitChandelier",), + 0x80BB9F24:("ObjChan_ChandelierAction",), 0x80BBA2FC:("ObjChan_InitPot",), 0x80BBA314:("ObjChan_PotAction",), - 0x80BBA488:("func_80BBA488",), + 0x80BBA488:("ObjChan_CreateSmashParticles",), 0x80BBA738:("ObjChan_Update",), 0x80BBA78C:("ObjChan_Draw",), 0x80BBA894:("ObjChan_DrawPot",), From afd3ae243d35f54bad77193f9c4e5cb894bfa49c Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sat, 9 Apr 2022 05:38:54 +0100 Subject: [PATCH 184/257] En_Test6 (#627) * En_Test6 * ArrCount * Always forget params * PR * Move defs * PR * Fix * PR * Merge * Merge * PR * Fix * PR * PR * Fix bss * Match (thanks Anon) * bss * PR * Merge * bss Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Co-authored-by: Elliptic Ellipsis --- include/functions.h | 8 +- include/z64.h | 26 +- spec | 4 +- src/code/z_demo.c | 2 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 1 + src/overlays/actors/ovl_En_Test6/z_en_test6.c | 1288 ++++++++++++++++- src/overlays/actors/ovl_En_Test6/z_en_test6.h | 38 +- tools/actorfixer.py | 3 + 8 files changed, 1326 insertions(+), 44 deletions(-) diff --git a/include/functions.h b/include/functions.h index 79d2f0d55..522fac154 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1556,7 +1556,7 @@ void func_800FD538(Color_RGB8* param_1, Color_RGB8* param_2, f32 param_3, Vec3s* void func_800FD59C(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); void func_800FD5E0(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); void func_800FD654(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); -void func_800FD698(GlobalContext* globalCtx, s32 arg1, s32 arg2, f32 arg3); +void func_800FD698(GlobalContext* globalCtx, s16 arg1, s16 arg2, f32 arg3); // u32 get_days_elapsed(void); // void reset_days_elapsed(void); // u32 get_current_day(void); @@ -2654,10 +2654,10 @@ void ShrinkWindow_Destroy(void); void ShrinkWindow_Update(s32 framerateDivisor); void ShrinkWindow_Draw(GraphicsContext* gfxCtx); // void func_80161180(void); -void func_8016119C(Camera* camera, struct_801F4D48* arg1); +s32 func_8016119C(Camera* camera, DbCameraUnkStruct* arg1); // void func_8016122C(void); // void func_801612B8(void); -s32 func_80161998(UNK_PTR arg0, struct_801F4D48* arg1); +s32 func_80161998(u8* cmd, DbCameraUnkStruct* arg1); // s32 func_80161BAC(void); void func_80161BE0(s16 arg0); void func_80161C0C(void); @@ -2723,7 +2723,7 @@ void func_80165438(UNK_PTR param_1); // void func_80165608(void); // void func_80165630(void); void func_80165658(u32 arg0); -void func_8016566C(s32 arg0); +void func_8016566C(u32 arg0); void func_80165690(void); // void func_801656A4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); // void func_80165DCC(void); diff --git a/include/z64.h b/include/z64.h index 3a7c7ea32..1ef496df3 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1495,6 +1495,20 @@ enum fram_mode { FRAM_MODE_STATUS }; +typedef struct { + /* 0x00 */ UNK_TYPE1 unk_00[0x14]; + /* 0x14 */ s16 unk_14; + /* 0x16 */ s16 unk_16; + /* 0x18 */ s16 unk_18; + /* 0x1A */ UNK_TYPE1 unk_1A[0x3]; + /* 0x0C */ u8 unk_1D; + /* 0x1E */ UNK_TYPE1 unk_1E[0xC]; + /* 0x2A */ s16 unk_2A; + /* 0x1E */ UNK_TYPE1 unk_2C[0x1]; + /* 0x2D */ u8 unk_2D; + /* 0x2E */ UNK_TYPE1 unk_2E[2]; +} DbCameraUnkSubStruct; // size = 0x30 + typedef struct { /* 0x00 */ s16 unk_00; /* 0x02 */ s16 unk_02; @@ -1504,18 +1518,12 @@ typedef struct { /* 0x0A */ s16 unk_0A; /* 0x0C */ s16 unk_0C; /* 0x0E */ UNK_TYPE1 unk_0E[0x02]; - /* 0x10 */ UNK_TYPE1 unk_10[0x2C]; - /* 0x3C */ UNK_TYPE1 unk_3C[0x01]; - /* 0x3D */ u8 unk_3D; - /* 0x3E */ UNK_TYPE1 unk_3E[0x02]; - /* 0x40 */ UNK_TYPE1 unk_40[0x2C]; - /* 0x6C */ UNK_TYPE1 unk_6C[0x01]; - /* 0x6D */ u8 unk_6D; - /* 0x6E */ UNK_TYPE1 unk_6E[0x02]; + /* 0x10 */ DbCameraUnkSubStruct unk_10; + /* 0x40 */ DbCameraUnkSubStruct unk_40; /* 0x70 */ UNK_PTR unk_70; /* 0x74 */ UNK_PTR unk_74; /* 0x78 */ UNK_PTR unk_78; /* 0x7C */ Camera* camera; -} struct_801F4D48; // size = 0x80 +} DbCameraUnkStruct; // size = 0x80 #endif diff --git a/spec b/spec index b974bd390..1c64ca1e8 100644 --- a/spec +++ b/spec @@ -3145,9 +3145,7 @@ beginseg name "ovl_En_Test6" compress include "build/src/overlays/actors/ovl_En_Test6/z_en_test6.o" - include "build/data/ovl_En_Test6/ovl_En_Test6.data.o" - include "build/data/ovl_En_Test6/ovl_En_Test6.bss.o" - include "build/data/ovl_En_Test6/ovl_En_Test6.reloc.o" + include "build/src/overlays/actors/ovl_En_Test6/ovl_En_Test6_reloc.o" endseg beginseg diff --git a/src/code/z_demo.c b/src/code/z_demo.c index e486bc769..0af7dfb4d 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -22,7 +22,7 @@ u8 sCutsceneStoredPlayerForm = 0; static u16 seqId; #endif s16 sCutsceneQuakeIndex; -struct_801F4D48 sCutsceneCameraInfo; +DbCameraUnkStruct sCutsceneCameraInfo; u16 D_801F4DC8[10]; UNK_TYPE D_801F4DDC; u8 D_801F4DE0; diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index e2a4e41f5..888a0587a 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -9,6 +9,7 @@ #include "overlays/actors/ovl_Item_B_Heart/z_item_b_heart.h" #include "objects/object_boss02/object_boss02.h" #include "objects/gameplay_keep/gameplay_keep.h" +#include "prevent_bss_reordering.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index 3305d4c04..de1a18241 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -5,6 +5,7 @@ */ #include "z_en_test6.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200000 | ACTOR_FLAG_2000000) @@ -15,14 +16,31 @@ void EnTest6_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTest6_Update(Actor* thisx, GlobalContext* globalCtx); void EnTest6_Draw(Actor* thisx, GlobalContext* globalCtx); +struct EnTest6Struct; + +typedef void (*EnTest6StructFunc)(EnTest6*, GlobalContext*, struct EnTest6Struct*); + +typedef struct EnTest6Struct { + /* 0x00 */ s32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ EnTest6StructFunc unk_14; +} EnTest6Struct; // size = 0x18 + +void func_80A90D34(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr); +void func_80A90FC0(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr); +void EnTest6_SetupAction(EnTest6* this, EnTest6ActionFunc actionFunc); void func_80A9156C(EnTest6* this, GlobalContext* globalCtx); +void func_80A91690(EnTest6* this, GlobalContext* globalCtx); void func_80A91760(EnTest6* this, GlobalContext* globalCtx); +void func_80A920C8(EnTest6* this, GlobalContext* globalCtx); void func_80A92188(EnTest6* this, GlobalContext* globalCtx); void func_80A92950(EnTest6* this, GlobalContext* globalCtx); -void EnTest6_SetupAction(EnTest6* this, EnTest6ActionFunc actionFunc); +EnTest6Struct D_80A94910[12]; -#if 0 const ActorInit En_Test6_InitVars = { ACTOR_EN_TEST6, ACTORCAT_ITEMACTION, @@ -35,50 +53,1268 @@ const ActorInit En_Test6_InitVars = { (ActorFunc)EnTest6_Draw, }; -#endif +u8 D_80A93E80[] = { + 0x00, 0x0D, 0x01, 0xA8, 0x00, 0x00, 0x00, 0x64, 0x04, 0x64, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x15, 0xFF, 0xED, 0x00, + 0x00, 0x04, 0x64, 0x00, 0x12, 0x00, 0x00, 0x00, 0x15, 0xFF, 0xED, 0x00, 0x00, 0x04, 0x64, 0x00, 0x10, 0x00, 0x00, + 0x00, 0x15, 0xFF, 0xED, 0x00, 0x00, 0x04, 0x64, 0x00, 0x11, 0xFF, 0xE6, 0xFF, 0xFB, 0xFF, 0xE0, 0x00, 0x00, 0x04, + 0x64, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x12, 0xFF, 0xE0, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0E, 0x00, 0x01, 0x00, 0x16, + 0xFF, 0xE5, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFB, 0x00, 0x00, 0x04, 0x64, 0x00, + 0x07, 0x00, 0x10, 0x00, 0x1D, 0xFF, 0xB3, 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0x00, 0x01, 0x00, 0x13, 0x00, 0x6F, + 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0xFF, 0xC5, 0x00, 0x15, 0x00, 0x5B, 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0xFF, + 0xED, 0x00, 0x3B, 0x00, 0x54, 0x00, 0x00, 0x04, 0x64, 0x00, 0x88, 0xFF, 0xED, 0x00, 0x3B, 0x00, 0x54, 0x00, 0x00, + 0x04, 0x64, 0x00, 0x6C, 0xFF, 0xEF, 0x00, 0x39, 0x00, 0x52, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0D, 0x00, 0x00, 0x00, + 0x32, 0x02, 0xA9, 0x00, 0x00, 0x04, 0x64, 0x00, 0x12, 0x00, 0x00, 0x00, 0x32, 0x02, 0xA9, 0x00, 0x00, 0x04, 0x64, + 0x00, 0x10, 0x00, 0x00, 0x00, 0x32, 0x02, 0xA9, 0x00, 0x00, 0x04, 0x64, 0x00, 0x11, 0xFF, 0x98, 0x01, 0x77, 0x01, + 0x59, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0F, 0x00, 0x00, 0xFF, 0xC2, 0x01, 0x21, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0E, + 0xFF, 0xD1, 0x00, 0x7D, 0x00, 0xCD, 0x00, 0x00, 0x04, 0x64, 0x00, 0x0C, 0xFF, 0xC6, 0xFF, 0xEF, 0x00, 0xC7, 0x00, + 0x00, 0x04, 0x64, 0x00, 0x07, 0x00, 0x10, 0x00, 0x35, 0x00, 0xD3, 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0xFF, 0xE1, + 0x00, 0x3F, 0x02, 0x6F, 0x00, 0x00, 0x04, 0x64, 0x00, 0x03, 0xFE, 0xAB, 0x01, 0xD0, 0x02, 0x1E, 0x00, 0x00, 0x04, + 0x64, 0x00, 0x03, 0xFE, 0xAB, 0x01, 0xD0, 0x02, 0x1E, 0x00, 0x00, 0x04, 0x64, 0x00, 0x88, 0xFE, 0xAB, 0x01, 0xD0, + 0x02, 0x1E, 0x00, 0x00, 0x04, 0x64, 0x00, 0x6C, 0xFE, 0xAD, 0x01, 0xCE, 0x02, 0x1C, 0x00, 0x00, 0x00, 0x0F, 0x00, + 0x0A, 0x00, 0x46, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x0A, 0x00, 0x46, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x0A, 0x00, 0x46, + 0x00, 0x00, 0x00, 0x0A, 0x00, 0x02, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x0A, 0xFF, 0xEC, 0x00, 0x37, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x06, 0x00, 0x2F, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFB, + 0x00, 0x32, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xDC, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xD8, 0x00, 0x78, 0x00, + 0x00, 0x00, 0x02, 0xFF, 0xC4, 0x00, 0x78, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xBA, 0x00, 0x82, 0x00, 0x00, 0x00, 0x02, + 0xFF, 0xB0, 0x00, 0x8C, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x04, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90730.s") +TexturePtr D_80A9402C[] = { + NULL, + gameplay_keep_Tex_05B6F0, + gameplay_keep_Tex_05CEF0, + gameplay_keep_Tex_0607C0, + gameplay_keep_Tex_060FC0, + gameplay_keep_Tex_061FC0, + gameplay_keep_Tex_061FE0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90C08.s") +Color_RGB8 D_80A94048 = { 230, 230, 220 }; +Color_RGB8 D_80A9404C = { 120, 120, 100 }; +Color_RGB8 D_80A94050 = { 0, 0, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90C34.s") +s16 D_80A94054 = 500; +s16 D_80A94058 = 1500; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90C54.s") +Vec3f D_80A9405C = { 0.0f, 1.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90D20.s") +Color_RGB8 D_80A94068 = { 225, 230, 225 }; +Color_RGB8 D_80A9406C = { 120, 120, 100 }; +Color_RGB8 D_80A94070 = { 0, 0, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90D34.s") +s16 D_80A94074 = 940; +s16 D_80A94078 = 2000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90FC0.s") +void func_80A90730(EnTest6* this, GlobalContext* globalCtx) { + s32 i; + Player* player = GET_PLAYER(globalCtx); + s32 phi_s0; + f32 phi_f24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_SetupAction.s") + this->actor.home.pos = player->actor.world.pos; + this->actor.home.rot = player->actor.shape.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_Init.s") + switch (ENTEST6_GET(&this->actor)) { + case ENTEST6_24: + case ENTEST6_25: + func_80A91690(this, globalCtx); + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + return; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_Destroy.s") + case ENTEST6_26: + func_80A920C8(this, globalCtx); + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A9156C.s") + phi_s0 = 0; + phi_f24 = -900.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A91690.s") + if (gSaveContext.eventInf[7] & 1) { + for (i = 0; i < 6; i++) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 5; + } + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 5; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 6; + phi_s0 |= 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A916F0.s") + if (gSaveContext.eventInf[7] & 0x10) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; + if (!(phi_s0 & 1)) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; + } + phi_s0 |= 0x10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A91760.s") + if (gSaveContext.eventInf[7] & 2) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; + if (!(phi_s0 & 1)) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; + } + phi_s0 |= 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A920C8.s") + if (gSaveContext.eventInf[7] & 4) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 3; + if (!(phi_s0 & (0x10 | 0x2 | 0x1))) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 3; + } + phi_s0 |= 4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A92118.s") + if (gSaveContext.eventInf[7] & 8) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 4; + if (!(phi_s0 & (0x10 | 0x2 | 0x1))) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 4; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A92188.s") + for (i = 0; i < ARRAY_COUNT(D_80A94910); i++) { + D_80A94910[i].unk_08 = ((2.0f * Rand_ZeroOne()) - 1.0f) * 80.0f; + D_80A94910[i].unk_10 = ((2.0f * Rand_ZeroOne()) - 1.0f) * 80.0f; + D_80A94910[i].unk_0C = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + phi_f24; + D_80A94910[i].unk_04 = -10.0f; + if (D_80A94910[i].unk_00 < 5) { + D_80A94910[i].unk_14 = func_80A90D34; + } else { + D_80A94910[i].unk_14 = func_80A90FC0; + } + phi_f24 += 50.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_Update.s") +void func_80A90C08(s16 arg0) { + func_8016566C(arg0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A92950.s") +void func_80A90C34(void) { + func_80165690(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A93298.s") +void func_80A90C54(GlobalContext* globalCtx, f32 arg1) { + globalCtx->envCtx.fillScreen = 1; + globalCtx->envCtx.screenFillColor[0] = 250; + globalCtx->envCtx.screenFillColor[1] = 250; + globalCtx->envCtx.screenFillColor[2] = 250; + globalCtx->envCtx.screenFillColor[3] = 255.0f * arg1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A9369C.s") +void func_80A90D20(GlobalContext* globalCtx) { + globalCtx->envCtx.fillScreen = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A939E8.s") +void func_80A90D34(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_Draw.s") + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (ptr->unk_00 != 0) { + Matrix_InsertTranslation(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_Scale(ptr->unk_04 * 0.02f, ptr->unk_04 * 0.02f, ptr->unk_04 * 0.02f, MTXMODE_APPLY); + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A9402C[ptr->unk_00])); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + } + + Matrix_InsertTranslation(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_Scale(2.0f * ptr->unk_04, 2.0f * ptr->unk_04, 2.0f * ptr->unk_04, MTXMODE_APPLY); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_InsertZRotation_s(globalCtx->state.frames * 512, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, 2.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 210, 210, 230, 128); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 0); + gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A90FC0(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) { + s32 pad; + Gfx* gfx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 2); + Gfx* gfx2 = gfx; + Hilite* sp70; + Vec3f sp64; + + sp64.x = ptr->unk_08 * ptr->unk_04; + sp64.y = ptr->unk_0C; + sp64.z = ptr->unk_10 * ptr->unk_04; + + sp70 = func_800BCBF4(&sp64, globalCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (gfx != NULL) { + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetTileSize(gfx++, 1, sp70->h.x1 & 0xFFFF, sp70->h.y1 & 0xFFFF, (sp70->h.x1 + 60) & 0xFFFF, + (sp70->h.y1 + 60) & 0xFFFF); + gSPEndDisplayList(gfx); + + gSPSegment(POLY_OPA_DISP++, 0x07, gfx2); + + Matrix_InsertTranslation(sp64.x, sp64.y, sp64.z, MTXMODE_NEW); + Matrix_Scale(ptr->unk_04 * 0.018f, ptr->unk_04 * 0.018f, ptr->unk_04 * 0.018f, MTXMODE_APPLY); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A9402C[ptr->unk_00])); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); + } + + Matrix_InsertTranslation(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_Scale(ptr->unk_04 * 2.5f, ptr->unk_04 * 2.5f, ptr->unk_04 * 2.5f, MTXMODE_APPLY); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_InsertZRotation_s(globalCtx->state.frames * 256, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, 4.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 220, 220, 230, 192); + gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 0); + gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnTest6_SetupAction(EnTest6* this, EnTest6ActionFunc actionFunc) { + this->actionFunc = actionFunc; +} + +void EnTest6_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTest6* this = THIS; + s32 i; + + if (((ENTEST6_GET(&this->actor) == ENTEST6_24) || (ENTEST6_GET(&this->actor) == ENTEST6_25) || + (ENTEST6_GET(&this->actor) == ENTEST6_26)) && + (globalCtx->playerActorCsIds[8] == -1)) { + Actor_MarkForDeath(&this->actor); + return; + } + + for (i = 0; i < ARRAY_COUNT(this->lights); i++) { + Lights_PointNoGlowSetInfo(&this->lights[i].info, this->actor.world.pos.x, (s32)this->actor.world.pos.y - 20, + this->actor.world.pos.z, 255, 255, 180, -1); + this->lights[i].node = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lights[i].info); + } + + this->unk_286 = 0; + this->unk_274 = 0; + this->unk_278 = 0; + this->unk_276 = 99; + func_80A90730(this, globalCtx); + EnTest6_SetupAction(this, func_80A9156C); +} + +void EnTest6_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTest6* this = THIS; + s32 i; + + globalCtx->envCtx.lightSettings.ambientColor[0] = 0; + globalCtx->envCtx.lightSettings.ambientColor[1] = 0; + globalCtx->envCtx.lightSettings.ambientColor[2] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[0] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[1] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[2] = 0; + globalCtx->envCtx.lightSettings.diffuseColor2[0] = 0; + globalCtx->envCtx.lightSettings.diffuseColor2[1] = 0; + globalCtx->envCtx.lightSettings.diffuseColor2[2] = 0; + globalCtx->envCtx.lightSettings.fogColor[0] = 0; + globalCtx->envCtx.lightSettings.fogColor[1] = 0; + globalCtx->envCtx.lightSettings.fogColor[2] = 0; + globalCtx->envCtx.lightSettings.fogNear = 0; + globalCtx->envCtx.lightSettings.fogFar = 0; + globalCtx->envCtx.fillScreen = 0; + + for (i = 0; i < ARRAY_COUNT(this->lights); i++) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lights[i].node); + } +} + +void func_80A9156C(EnTest6* this, GlobalContext* globalCtx) { + switch (ENTEST6_GET(&this->actor)) { + case ENTEST6_24: + case ENTEST6_25: + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + } else { + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + this->unk_284 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + EnTest6_SetupAction(this, func_80A91760); + } + break; + + case ENTEST6_26: + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + } else { + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + this->unk_284 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + EnTest6_SetupAction(this, func_80A92188); + } + break; + + default: + gSaveContext.save.daysElapsed = 0; + gSaveContext.save.day = false; + gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; + EnTest6_SetupAction(this, func_80A92950); + break; + } +} + +void func_80A91690(EnTest6* this, GlobalContext* globalCtx) { + this->unk_274 = 90; + this->unk_27A = 100; + this->unk_286 = 0; + if (ENTEST6_GET(&this->actor) == ENTEST6_25) { + play_sound(NA_SE_SY_TIME_CONTROL_SLOW); + } else if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + play_sound(NA_SE_SY_TIME_CONTROL_NORMAL); + } +} + +void func_80A916F0(EnTest6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.freezeTimer = 0; + globalCtx->unk_18844 = 0; + ActorCutscene_Stop(globalCtx->playerActorCsIds[8]); + func_800B7298(globalCtx, NULL, 6); + func_80A90C34(); + Distortion_ClearType(0x20); + Actor_MarkForDeath(&this->actor); +} + +void func_80A91760(EnTest6* this, GlobalContext* globalCtx) { + Input* input = CONTROLLER1(globalCtx); + s16 temp_s0; + Player* player = GET_PLAYER(globalCtx); + Camera* sp78; + Vec3f sp6C; + Vec3f sp60; + Vec3f sp54; + s32 i; + f32 sp4C; + Camera* temp_s3 = Play_GetCamera(globalCtx, this->unk_284); + + sp78 = Play_GetCamera(globalCtx, CAM_ID_MAIN); + + switch (this->unk_274) { + case 90: + this->unk_276 = 2; + this->unk_15C = 0.0f; + this->unk_14C = 0.1f; + this->unk_282 = 0; + this->unk_278 = 0; + this->unk_274 = 91; + break; + + case 91: + this->unk_15C += this->unk_14C; + func_800FD59C(globalCtx, &D_80A9404C, this->unk_15C); + func_800FD5E0(globalCtx, &D_80A94050, this->unk_15C); + func_800FD654(globalCtx, &D_80A94048, this->unk_15C); + func_800FD698(globalCtx, D_80A94054, D_80A94058, this->unk_15C); + + if (this->unk_27A == 90) { + this->unk_282 = 0; + if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + this->unk_27C = 0x200; + this->unk_150 = 0.0f; + sp4C = -100.0f; + } else { + this->unk_27C = 0x570; + this->unk_150 = 110.0f; + sp4C = 100.0f; + } + this->unk_14C = 1.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { + this->unk_20C[i].x = player->actor.world.pos.x; + this->unk_20C[i].y = player->actor.world.pos.y; + this->unk_20C[i].z = player->actor.world.pos.z; + } + + this->unk_254 = ZeldaArena_Malloc(sizeof(Vec3f) * 64); + if (this->unk_254 != NULL) { + for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { + (*this->unk_254)[i].x = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + temp_s3->eye.x + + ((temp_s3->at.x - temp_s3->eye.x) * 0.2f); + (*this->unk_254)[i].y = (((2.0f * Rand_ZeroOne()) - 1.0f) * 120.0f) + temp_s3->eye.y + + ((temp_s3->at.y - temp_s3->eye.y) * 0.2f) + sp4C; + (*this->unk_254)[i].z = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + temp_s3->eye.z + + ((temp_s3->at.z - temp_s3->eye.z) * 0.2f); + } + } + func_80A90C08(0x78); + Distortion_SetType(0x20); + Distortion_SetCountdown(80); + globalCtx->unk_18844 = 1; + this->unk_274 = 95; + } + break; + + case 95: + if (this->unk_27A > 80) { + this->unk_282 += 25; + } + + if (this->unk_27A < 20) { + this->unk_282 -= 25; + } + + func_800FD59C(globalCtx, &D_80A9404C, this->unk_15C); + func_800FD5E0(globalCtx, &D_80A94050, this->unk_15C); + func_800FD654(globalCtx, &D_80A94048, this->unk_15C); + func_800FD698(globalCtx, D_80A94054 + this->unk_282, D_80A94058 + this->unk_282, this->unk_15C); + + this->unk_278 -= this->unk_27C; + temp_s0 = this->unk_278; + if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + this->unk_27C += 8; + this->unk_150 += this->unk_14C; + } else { + this->unk_27C -= 8; + this->unk_150 -= this->unk_14C; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { + temp_s0 += 0x10000 / ARRAY_COUNT(this->unk_20C); + if (player) {} + this->unk_20C[i].x = (Math_SinS(temp_s0) * this->unk_150) + player->actor.world.pos.x; + this->unk_20C[i].y = player->actor.world.pos.y; + this->unk_20C[i].z = (Math_CosS(temp_s0) * this->unk_150) + player->actor.world.pos.z; + } + + if (this->unk_254 != NULL) { + for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { + (*this->unk_254)[i].x += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + (*this->unk_254)[i].y += 1.0f; + } else { + if (1) {} + (*this->unk_254)[i].y -= 1.0f; + } + (*this->unk_254)[i].z += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + } + } + + if (this->unk_27A == 10) { + this->unk_14C = 0.1f; + func_80A90C34(); + Distortion_ClearType(0x20); + globalCtx->unk_18844 = 0; + if (this->unk_254 != NULL) { + ZeldaArena_Free(this->unk_254); + } + this->unk_274 = 99; + } + break; + + case 99: + this->unk_15C -= this->unk_14C; + func_800FD59C(globalCtx, &D_80A9404C, this->unk_15C); + func_800FD5E0(globalCtx, &D_80A94050, this->unk_15C); + func_800FD654(globalCtx, &D_80A94048, this->unk_15C); + func_800FD698(globalCtx, D_80A94054, D_80A94058, this->unk_15C); + break; + } + + if (this->unk_286 != 0) { + func_800B7298(globalCtx, NULL, 7); + } else { + if (this->unk_27A == 90) { + func_800B7298(globalCtx, NULL, 0x42); + } + + if (this->unk_27A == 70) { + func_800B7298(globalCtx, NULL, 0x52); + } + + if (this->unk_27A == 30) { + func_800B7298(globalCtx, NULL, 0x51); + } + + if (this->unk_27A == 5) { + func_800B7298(globalCtx, NULL, 0x4A); + } + } + + if (this->unk_27A > 80) { + temp_s3->fov += (90.0f - temp_s3->fov) / (this->unk_27A - 80); + } else if (this->unk_27A > 60) { + sp4C = 1.0f / (this->unk_27A - 60); + + sp6C.x = temp_s3->at.x + ((player->actor.world.pos.x - temp_s3->at.x) * sp4C); + sp6C.y = temp_s3->at.y + (((player->actor.focus.pos.y - temp_s3->at.y) - 20.0f) * sp4C); + sp6C.z = temp_s3->at.z + ((player->actor.world.pos.z - temp_s3->at.z) * sp4C); + + sp54.x = (Math_SinS(player->actor.world.rot.y) * 80.0f) + sp6C.x; + sp54.y = sp6C.y + 20.0f; + sp54.z = (Math_CosS(player->actor.world.rot.y) * 80.0f) + sp6C.z; + sp4C *= 0.75f; + + VEC3F_LERPIMPDST(&sp60, &temp_s3->eye, &sp54, sp4C); + + Play_CameraSetAtEye(globalCtx, this->unk_284, &sp6C, &sp60); + } else if ((this->unk_27A < 11) && (this->unk_27A > 0)) { + temp_s3->fov += (sp78->fov - temp_s3->fov) / this->unk_27A; + } + + if (this->unk_286 != 0) { + func_80A90C54(globalCtx, this->unk_286 * 0.05f); + temp_s3->fov += (sp78->fov - temp_s3->fov) * 0.05f; + this->unk_286++; + if (this->unk_286 >= 20) { + this->unk_27A = 1; + } + } else if ((this->unk_27A <= 60) && (this->unk_27A > 40) && + (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_B))) { + this->unk_286 = 1; + if (ENTEST6_GET(&this->actor) == ENTEST6_25) { + func_801A75E8(NA_SE_SY_TIME_CONTROL_SLOW); + } else if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + func_801A75E8(NA_SE_SY_TIME_CONTROL_NORMAL); + } + } + + if (DECR(this->unk_27A) == 0) { + func_80A916F0(this, globalCtx); + globalCtx->msgCtx.ocarinaMode = 4; + } +} + +void func_80A920C8(EnTest6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_27A = 120; + this->unk_286 = 0; + this->unk_160 = 0.0f; + this->actor.home.pos = player->actor.world.pos; + this->actor.home.rot = player->actor.shape.rot; +} + +void func_80A92118(EnTest6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.freezeTimer = 0; + globalCtx->unk_18844 = 0; + ActorCutscene_Stop(globalCtx->playerActorCsIds[8]); + func_800B7298(globalCtx, NULL, 6); + func_80A90C34(); + Distortion_ClearType(0x20); + Actor_MarkForDeath(&this->actor); +} + +void func_80A92188(EnTest6* this, GlobalContext* globalCtx) { + Input* input = CONTROLLER1(globalCtx); + Player* player = GET_PLAYER(globalCtx); + Camera* camera; + s32 pad; + s16 sp46; + s16 sp44; + + if (this->unk_27A > 115) { + this->unk_160 += 0.2f; + func_80A90C54(globalCtx, this->unk_160); + } else if (this->unk_27A > 90) { + this->unk_160 -= 0.05f; + func_80A90C54(globalCtx, this->unk_160); + } else if (this->unk_27A == 90) { + this->unk_160 = 0.0f; + func_80A90D20(globalCtx); + } + + if (this->unk_27A == 1) { + this->unk_160 = 0.0f; + func_80A90D20(globalCtx); + } else if (this->unk_27A < 17) { + this->unk_160 -= 0.06666666f; + func_80A90C54(globalCtx, this->unk_160); + } else if (this->unk_27A < 22) { + this->unk_160 += 0.2f; + func_80A90C54(globalCtx, this->unk_160); + } + + if (this->unk_27A == 115) { + func_800FD59C(globalCtx, &D_80A9406C, 1.0f); + func_800FD5E0(globalCtx, &D_80A94070, 1.0f); + func_800FD654(globalCtx, &D_80A94068, 1.0f); + func_800FD698(globalCtx, D_80A94074, D_80A94078, 1.0f); + globalCtx->unk_18844 = 1; + } + + if (this->unk_27A == 15) { + func_800FD59C(globalCtx, &D_80A9406C, 0.0f); + func_800FD5E0(globalCtx, &D_80A94070, 0.0f); + func_800FD654(globalCtx, &D_80A94068, 0.0f); + func_800FD698(globalCtx, D_80A94074, D_80A94078, 0.0f); + globalCtx->unk_18844 = 0; + } + + if (this->unk_286 >= 20) { + func_800FD59C(globalCtx, &D_80A9406C, this->unk_160); + func_800FD5E0(globalCtx, &D_80A94070, this->unk_160); + func_800FD654(globalCtx, &D_80A94068, this->unk_160); + func_800FD698(globalCtx, D_80A94074, D_80A94078, this->unk_160); + globalCtx->unk_18844 = 0; + } + + func_800B8F98(&player->actor, NA_SE_PL_FLYING_AIR - SFX_FLAG); + + switch (this->unk_27A) { + case 119: + func_80A90C08(0x32); + break; + + case 115: + func_80A90C08(0x14); + Distortion_SetType(0x20); + Distortion_SetCountdown(90); + this->unk_274 = 2; + break; + + case 110: + func_801A3098(0x4A); + break; + + case 38: + case 114: + this->unk_274 = 1; + break; + + case 76: + this->unk_274 = 3; + break; + + case 61: + func_80A90C08(0x96); + this->unk_274 = 4; + break; + + case 51: + func_80A90C08(0xB4); + this->unk_274 = 5; + break; + + case 14: + case 15: + func_80A90C08(0x32); + Distortion_ClearType(0x20); + this->unk_274 = 0; + break; + + case 1: + func_80A90C34(); + if (gSaveContext.eventInf[5] & 4) { + this->unk_274 = 9; + } + break; + } + + func_80A92950(this, globalCtx); + + if (this->unk_27A == 115) { + sp44 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + camera = Play_GetCamera(globalCtx, sp44); + + this->unk_258 = camera->at; + this->unk_264 = camera->eye; + this->unk_270 = camera->fov; + func_8016119C(camera, &this->unk_18C); + } + + if ((this->unk_27A <= 115) && (this->unk_27A >= 16)) { + func_80161998(D_80A93E80, &this->unk_18C); + } else if (this->unk_27A < 16) { + sp46 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + + Play_CameraSetAtEyeUp(globalCtx, sp46, &this->unk_258, &this->unk_264, &D_80A9405C); + Play_CameraSetFov(globalCtx, sp46, this->unk_270); + Play_CameraSetRoll(globalCtx, sp46, 0); + } + + switch (this->unk_27A) { + case 116: + player->actor.freezeTimer = 2; + player->actor.shape.rot.x = 0; + player->actor.shape.rot.y = 0; + player->actor.world.pos.x = 0.0f; + player->actor.world.pos.y = 0.0f; + player->actor.world.pos.z = 0.0f; + player->actor.home.pos.x = 0.0f; + player->actor.home.pos.y = 0.0f; + player->actor.home.pos.z = 0.0f; + break; + + case 98: + func_800B7298(globalCtx, NULL, 0x40); + break; + + case 68: + func_800B7298(globalCtx, NULL, 0x41); + break; + + case 52: + func_800B7298(globalCtx, NULL, 0x58); + break; + + case 43: + func_800B7298(globalCtx, NULL, 0x72); + break; + + case 38: + func_800B7298(globalCtx, NULL, 7); + break; + + case 14: + player->actor.freezeTimer = 5; + player->actor.world.pos = player->actor.home.pos = this->actor.home.pos; + player->actor.shape.rot = this->actor.home.rot; + player->actor.focus.rot.y = player->actor.shape.rot.y; + player->currentYaw = player->actor.shape.rot.y; + player->unk_ABC = 0.0f; + player->unk_AC0 = 0.0f; + player->actor.shape.yOffset = 0.0f; + break; + } + + if ((this->unk_286 > 0) && (this->unk_286 < 20)) { + func_80A90C54(globalCtx, this->unk_286 * 0.05f); + this->unk_286++; + if (this->unk_286 >= 20) { + this->unk_27A = 15; + this->unk_160 = 0.9333333f; + } + } else if ((this->unk_27A < 96) && (this->unk_27A > 50) && + (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_B))) { + this->unk_286 = 1; + this->unk_27A = 39; + Audio_QueueSeqCmd(0x111400FF); + } + + if (DECR(this->unk_27A) == 0) { + func_80A92118(this, globalCtx); + } +} + +void EnTest6_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTest6* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void func_80A92950(EnTest6* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player = GET_PLAYER(globalCtx); + f32 temp_f0; + s32 i; + s32 temp_v0; + + if (Cutscene_CheckActorAction(globalCtx, 0x1F9)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 0x1F9); + this->unk_274 = globalCtx->csCtx.actorActions[temp_v0]->action; + + switch (this->unk_274) { + case 1: + break; + + case 2: + this->unk_276 = 0; + this->unk_278 = 0; + this->unk_27C = 0; + player->actor.shape.shadowDraw = NULL; + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } else { + this->unk_154 = 150.0f; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 = globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + } else { + this->unk_280 = 38; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_150 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.z; + } else { + this->unk_150 = 480.0f; + } + break; + + case 3: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 += (s16)globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + + } else { + this->unk_280 += 6; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_158 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.z; + } else { + this->unk_158 = -32.0f; + } + this->unk_150 += this->unk_158; + break; + + case 4: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 += (s16)globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + } else { + this->unk_280 -= 4; + } + break; + + case 5: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 += (s16)globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + } else { + this->unk_280 -= 8; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_158 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.z; + } else { + this->unk_158 += 20.0f; + } + + this->unk_150 += this->unk_158; + if (this->unk_150 > 3500.0f) { + this->unk_150 = 3500.0f; + this->unk_274 = 0; + } + break; + + case 6: + this->unk_276 = 1; + this->unk_278 = 0; + this->unk_27C = 0; + player->actor.shape.shadowDraw = NULL; + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } else { + this->unk_154 = 100.0f; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_14C = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + } else { + this->unk_14C = 20.0f; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_150 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.z; + } else { + this->unk_150 = 300.0f; + } + this->unk_158 = 0.0f; + break; + + case 7: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_158 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } else { + this->unk_158 = -5.0f; + } + this->unk_154 += this->unk_158; + break; + + case 8: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_158 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } else { + this->unk_158 += 2.0f; + } + + this->unk_154 += this->unk_158; + if (this->unk_154 > 10000.0f) { + this->unk_154 = 10000.0f; + this->unk_274 = 0; + } + break; + + case 0: + default: + this->unk_276 = 99; + return; + + case 9: + Play_SetRespawnData(&globalCtx->state, 1, ((void)0, gSaveContext.save.entranceIndex & 0xFFFF), + player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); + this->unk_276 = 99; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_RETURN].entranceIndex; + globalCtx->unk_1887F = 2; + if ((gSaveContext.save.time > CLOCK_TIME(18, 0)) || (gSaveContext.save.time < CLOCK_TIME(6, 0))) { + gSaveContext.respawnFlag = -0x63; + gSaveContext.eventInf[2] |= 0x80; + } else { + gSaveContext.respawnFlag = 2; + } + globalCtx->msgCtx.ocarinaMode = 4; + return; + } + } else { + switch (this->unk_274) { + case 2: + this->unk_276 = 0; + this->unk_278 = 0; + this->unk_27C = 0; + player->actor.shape.shadowDraw = NULL; + this->unk_280 = 38; + this->unk_154 = 150.0f; + this->unk_150 = 480.0f; + + case 1: + break; + + case 3: + this->unk_158 = -32.0f; + this->unk_280 += 6; + this->unk_150 += -32.0f; + break; + + case 4: + this->unk_280 -= 4; + break; + + case 5: + this->unk_280 -= 8; + this->unk_158 += 20.0f; + this->unk_150 += this->unk_158; + if (this->unk_150 > 3500.0f) { + this->unk_150 = 3500.0f; + this->unk_274 = 0; + } + break; + + case 6: + this->unk_276 = 1; + this->unk_278 = 0; + this->unk_27C = 0; + player->actor.shape.shadowDraw = NULL; + this->unk_154 = 100.0f; + this->unk_14C = 20.0f; + this->unk_150 = 300.0f; + this->unk_158 = 0.0f; + break; + + case 7: + this->unk_158 = -5.0f; + this->unk_154 += -5.0f; + break; + + case 8: + this->unk_158 += 2.0f; + this->unk_154 += this->unk_158; + if (this->unk_154 > 10000.0f) { + this->unk_154 = 10000.0f; + this->unk_274 = 0; + } + break; + + case 0: + default: + this->unk_276 = 99; + return; + + case 9: + if (gSaveContext.save.time > CLOCK_TIME(12, 0)) { + Play_SetRespawnData(&globalCtx->state, 1, ((void)0, gSaveContext.save.entranceIndex & 0xFFFF), + player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); + this->unk_276 = 99; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_RETURN].entranceIndex; + globalCtx->unk_1887F = 2; + gSaveContext.respawnFlag = 2; + globalCtx->msgCtx.ocarinaMode = 4; + } + return; + } + } + + if (this->unk_276 == 1) { + for (i = 0; i < ARRAY_COUNT(D_80A94910); i++) { + D_80A94910[i].unk_08 += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + D_80A94910[i].unk_10 += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + D_80A94910[i].unk_0C += 3.0f; + + if (player->actor.world.pos.y < D_80A94910[i].unk_0C) { + temp_f0 = D_80A94910[i].unk_0C - player->actor.world.pos.y; + if (temp_f0 > 550.0f) { + temp_f0 = 1.0f; + } else { + temp_f0 = temp_f0 / 550.0f; + } + D_80A94910[i].unk_04 = SQ(temp_f0); + } else { + D_80A94910[i].unk_04 = -10.0f; + } + } + } + this->unk_278++; +} + +void func_80A93298(EnTest6* this, GlobalContext* globalCtx) { + s16 temp_s3; + s16 temp_s4; + f32 phi_f24; + s16 phi_s2; + s32 i; + f32 cos; + f32 sin; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + this->unk_148 = POLY_OPA_DISP; + phi_f24 = 0.0f; + + temp_s3 = this->unk_27C; + temp_s4 = (s32)(Math_SinS(globalCtx->state.frames) * 12000.0f) + temp_s3 + 0x4E20; + phi_s2 = (globalCtx->state.frames & 0x3C) * 1024; + phi_s2 *= (this->unk_154 / 200.0f); + this->unk_27C += (s16)this->unk_154; + this->unk_27E = (s16)((this->unk_154 / 200.0f) * 256.0f); + + for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { + temp_s3 += 0x1000; + cos = Math_CosS(temp_s3) * this->unk_150; + sin = Math_SinS(temp_s3) * this->unk_150; + Matrix_InsertTranslation(cos, phi_f24, sin, MTXMODE_NEW); + Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(phi_s2, MTXMODE_APPLY); + + gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); + gDPSetEnvColor(this->unk_148++, 255, 255, 255, 255); + gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + + temp_s4 += 0x1000; + cos = Math_CosS(temp_s4) * this->unk_150; + sin = Math_SinS(temp_s4) * this->unk_150; + Matrix_InsertTranslation(cos, phi_f24, sin, MTXMODE_NEW); + Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-phi_s2, MTXMODE_APPLY); + + gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); + gDPSetEnvColor(this->unk_148++, 255, 255, 255, 255); + gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + + phi_f24 -= this->unk_14C; + phi_s2 += this->unk_27E; + } + + POLY_OPA_DISP = this->unk_148; + + for (i = 0; i < ARRAY_COUNT(D_80A94910); i++) { + if (D_80A94910[i].unk_04 > 0.0f) { + D_80A94910[i].unk_14(this, globalCtx, &D_80A94910[i]); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A9369C(Actor* thisx, GlobalContext* globalCtx2) { + EnTest6* this = THIS; + GlobalContext* globalCtx = globalCtx2; + f32 temp_f20; + f32 temp_f22; + f32 phi_f26; + s16 phi_s2; + s16 sp78; + s32 i; + Player* player = GET_PLAYER(globalCtx); + s32 pad; + + if (this) {} + OPEN_DISPS(globalCtx->state.gfxCtx); + + this->unk_148 = POLY_OPA_DISP; + this->unk_27C += (s16)this->unk_154; + this->unk_27E = this->unk_27C * 2; + sp78 = (globalCtx->state.frames & 0x3C) * 1024; + phi_s2 = this->unk_27C + 0x4000; + + switch (player->transformation) { + default: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + + case PLAYER_FORM_DEKU: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + + case PLAYER_FORM_GORON: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + + case PLAYER_FORM_ZORA: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + + case PLAYER_FORM_FIERCE_DEITY: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + } + + for (i = 0; i < 51; i++) { + temp_f20 = Math_CosS(phi_s2) * this->unk_150; + temp_f22 = Math_SinS(phi_s2) * this->unk_150; + Matrix_InsertZRotation_s(this->unk_27E, MTXMODE_NEW); + Matrix_InsertTranslation(phi_f26, temp_f20, temp_f22, MTXMODE_APPLY); + Matrix_Scale(0.85f, 0.85f, 0.85f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(phi_s2, MTXMODE_APPLY); + Matrix_InsertZRotation_s(sp78, MTXMODE_APPLY); + + gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->unk_148++, 0, 0xFF, this->unk_280, this->unk_280, this->unk_280, 255); + gDPSetEnvColor(this->unk_148++, 235, 238, 235, 255); + gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + + phi_s2 += 0x505; + } + + Lights_PointSetPosition(&this->lights[0].info, player->actor.world.pos.x, player->actor.world.pos.y - 10.0f, + player->actor.world.pos.z); + Lights_PointSetColorAndRadius(&this->lights[0].info, 100, 250, 100, 200); + + POLY_OPA_DISP = this->unk_148; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A939E8(EnTest6* this, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + Player* player = GET_PLAYER(globalCtx); + f32 temp_f20; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + switch (this->unk_274) { + case 91: + case 93: + Lights_PointSetPosition(&this->lights[0].info, player->actor.world.pos.x, player->actor.world.pos.y - 10.0f, + player->actor.world.pos.z); + Lights_PointSetColorAndRadius(&this->lights[0].info, 245, 245, 200, this->unk_282); + break; + + case 95: + this->unk_148 = POLY_XLU_DISP; + + for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { + Matrix_InsertTranslation(this->unk_20C[i].x, this->unk_20C[i].y, this->unk_20C[i].z, MTXMODE_NEW); + Matrix_Scale(0.3f, 0.3f, 0.3f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(-0x4000, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_278, MTXMODE_APPLY); + + gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); + gDPSetEnvColor(this->unk_148++, 245, 245, 200, this->unk_282); + gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); + gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + + POLY_XLU_DISP = this->unk_148; + } + + if (this->unk_254 != NULL) { + for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { + temp_f20 = Rand_ZeroOne() * 0.0025f; + Matrix_InsertTranslation((*this->unk_254)[i].x, (*this->unk_254)[i].y, (*this->unk_254)[i].z, + MTXMODE_NEW); + Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 128, 128, 128, this->unk_282 >> 1); + gDPSetEnvColor(POLY_XLU_DISP++, 230, 230, 180, this->unk_282); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_278 + (i << 2), MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + } + } + Lights_PointSetPosition(&this->lights[0].info, player->actor.world.pos.x, player->actor.world.pos.y - 10.0f, + player->actor.world.pos.z); + Lights_PointSetColorAndRadius(&this->lights[0].info, 250, 250, 100, this->unk_282); + break; + + case 90: + case 92: + case 94: + case 96: + case 97: + case 98: + case 99: + break; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnTest6_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTest6* this = THIS; + + if (this->unk_274 != 0) { + switch (this->unk_276) { + case 1: + func_80A93298(this, globalCtx); + break; + + case 0: + func_80A9369C(thisx, globalCtx); + break; + + case 2: + func_80A939E8(this, globalCtx); + break; + } + } +} diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.h b/src/overlays/actors/ovl_En_Test6/z_en_test6.h index 9cee7cf1d..0c1aab3b0 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.h +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.h @@ -7,10 +7,46 @@ struct EnTest6; typedef void (*EnTest6ActionFunc)(struct EnTest6*, GlobalContext*); +#define ENTEST6_GET(thisx) ((thisx)->params) + +enum { + /* 24 */ ENTEST6_24 = 24, + /* 25 */ ENTEST6_25, + /* 26 */ ENTEST6_26, +}; + +typedef struct { + /* 0x00 */ LightNode* node; + /* 0x04 */ LightInfo info; +} EnTest6Light; + typedef struct EnTest6 { /* 0x0000 */ Actor actor; /* 0x0144 */ EnTest6ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x140]; + /* 0x0148 */ Gfx* unk_148; + /* 0x014C */ f32 unk_14C; + /* 0x0150 */ f32 unk_150; + /* 0x0154 */ f32 unk_154; + /* 0x0158 */ f32 unk_158; + /* 0x015C */ f32 unk_15C; + /* 0x0160 */ f32 unk_160; + /* 0x0164 */ EnTest6Light lights[2]; + /* 0x018C */ DbCameraUnkStruct unk_18C; + /* 0x020C */ Vec3f unk_20C[6]; + /* 0x0254 */ Vec3f (*unk_254)[64]; + /* 0x0258 */ Vec3f unk_258; + /* 0x0264 */ Vec3f unk_264; + /* 0x0270 */ f32 unk_270; + /* 0x0274 */ s16 unk_274; + /* 0x0276 */ s16 unk_276; + /* 0x0278 */ s16 unk_278; + /* 0x027A */ s16 unk_27A; + /* 0x027C */ s16 unk_27C; + /* 0x027E */ s16 unk_27E; + /* 0x0280 */ s16 unk_280; + /* 0x0282 */ s16 unk_282; + /* 0x0284 */ s16 unk_284; + /* 0x0286 */ s16 unk_286; } EnTest6; // size = 0x288 extern const ActorInit En_Test6_InitVars; diff --git a/tools/actorfixer.py b/tools/actorfixer.py index e5e125905..907b83a8b 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -439,6 +439,9 @@ animdict = { "func_80114E90": "Interface_HasEmptyBottle", "func_80114F2C": "Interface_HasItemInBottle", "func_80123C90": "Player_SetEquipmentData", + "Quake2_ClearType": "Distortion_ClearType", + "Quake2_SetType": "Distortion_SetType", + "Quake2_SetCountdown": "Distortion_SetCountdown", "func_800BE680": "Actor_DrawDamageEffects", "func_8013E2D4": "SubS_StartActorCutscene", "func_8013E3B8": "SubS_FillCutscenesList", From bbc6dd77ea730740bb0b6dbe9ddcc1f02da4c5f8 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 17 Apr 2022 16:08:16 +0100 Subject: [PATCH 185/257] Obj_Nozoki (#704) * Obj_Nozoki * GID * PR * Merge * PR --- include/z64item.h | 3 +- spec | 4 +- .../actors/ovl_Obj_Nozoki/z_obj_nozoki.c | 435 ++++++++++++++++-- .../actors/ovl_Obj_Nozoki/z_obj_nozoki.h | 15 +- tools/disasm/functions.txt | 2 +- undefined_syms.txt | 4 - 6 files changed, 425 insertions(+), 38 deletions(-) diff --git a/include/z64item.h b/include/z64item.h index a3c8a7c70..785d56577 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -374,7 +374,8 @@ typedef enum { /* 0x31 */ GID_POTION_RED, /* 0x32 */ GID_POTION_BLUE, /* 0x33 */ GID_SHIELD_MIRROR, - /* 0x3A */ GID_3A = 0x3A, + /* 0x39 */ GID_39 = 0x39, + /* 0x3A */ GID_3A, /* 0x3B */ GID_FAIRY, /* 0x3E */ GID_3E = 0x3E, /* 0x44 */ GID_44 = 0x44, diff --git a/spec b/spec index 1c64ca1e8..4a9f46bde 100644 --- a/spec +++ b/spec @@ -4394,9 +4394,7 @@ beginseg name "ovl_Obj_Nozoki" compress include "build/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.o" - include "build/data/ovl_Obj_Nozoki/ovl_Obj_Nozoki.data.o" - include "build/data/ovl_Obj_Nozoki/ovl_Obj_Nozoki.bss.o" - include "build/data/ovl_Obj_Nozoki/ovl_Obj_Nozoki.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Nozoki/ovl_Obj_Nozoki_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c index ba5b62151..c0ce7408e 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c @@ -5,6 +5,7 @@ */ #include "z_obj_nozoki.h" +#include "objects/object_secom_obj/object_secom_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -14,17 +15,23 @@ void ObjNozoki_Init(Actor* thisx, GlobalContext* globalCtx); void ObjNozoki_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjNozoki_Update(Actor* thisx, GlobalContext* globalCtx); +void ObjNozoki_SetupAction(ObjNozoki* this, ObjNozokiActionFunc actionFunc); void func_80BA2514(ObjNozoki* this, GlobalContext* globalCtx); +void func_80BA27C4(ObjNozoki* this, GlobalContext* globalCtx); void func_80BA28DC(ObjNozoki* this, GlobalContext* globalCtx); void func_80BA2AB4(ObjNozoki* this, GlobalContext* globalCtx); void func_80BA2BA4(ObjNozoki* this, GlobalContext* globalCtx); +void func_80BA2C94(ObjNozoki* this, GlobalContext* globalCtx); void func_80BA3044(ObjNozoki* this, GlobalContext* globalCtx); +void func_80BA311C(ObjNozoki* this, GlobalContext* globalCtx); void func_80BA3230(ObjNozoki* this, GlobalContext* globalCtx); void func_80BA3344(ObjNozoki* this, GlobalContext* globalCtx); +void ObjNozoki_Draw(Actor* thisx, GlobalContext* globalCtx); -void ObjNozoki_SetupAction(ObjNozoki* this, ObjNozokiActionFunc actionFunc); +s32 D_80BA36B0; +s32 D_80BA36B4; +f32 D_80BA36B8; -#if 0 const ActorInit Obj_Nozoki_InitVars = { ACTOR_OBJ_NOZOKI, ACTORCAT_ITEMACTION, @@ -37,54 +44,428 @@ const ActorInit Obj_Nozoki_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BA34B0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F(scale, 1, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 0, ICHAIN_STOP), }; -#endif +s16 D_80BA34B8[] = { OBJECT_SECOM_OBJ, OBJECT_GI_MSSA, OBJECT_SECOM_OBJ, OBJECT_SECOM_OBJ }; -extern InitChainEntry D_80BA34B0[]; +Vec3f D_80BA34C0 = { 0.0f, 0.0f, -1110.0f }; -extern UNK_TYPE D_060001C0; +Vec3f D_80BA34CC = { 0.0f, 0.0f, 38.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/ObjNozoki_SetupAction.s") +f32 D_80BA34D8[] = { 100.0f, 9999.0f, 9999.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/ObjNozoki_Init.s") +f32 D_80BA34E4[] = { 0.5f, 0.25f, 1.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/ObjNozoki_Destroy.s") +void ObjNozoki_SetupAction(ObjNozoki* this, ObjNozokiActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2514.s") +void ObjNozoki_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjNozoki* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA26A8.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + this->unk_15F = this->dyna.actor.cutscene; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2708.s") + if (globalCtx->sceneNum == SCENE_AYASHIISHOP) { + this->unk_15C = 4; + ObjNozoki_SetupAction(this, func_80BA3230); + this->dyna.actor.colChkInfo.cylRadius = -40; + } else { + this->unk_15C = OBJNOZOKI_GET_180(&this->dyna.actor); + if (this->unk_15C == 0) { + DynaPolyActor_Init(&this->dyna, 0); + } + ObjNozoki_SetupAction(this, func_80BA2514); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2790.s") +void ObjNozoki_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjNozoki* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA27C4.s") + if (this->unk_15C == 0) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA28DC.s") +void func_80BA2514(ObjNozoki* this, GlobalContext* globalCtx) { + s32 sp24 = Object_GetIndex(&globalCtx->objectCtx, D_80BA34B8[this->unk_15C]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2AB4.s") + if (sp24 < 0) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2B64.s") + if (Object_IsLoaded(&globalCtx->objectCtx, sp24)) { + this->dyna.actor.objBankIndex = sp24; + this->dyna.actor.draw = ObjNozoki_Draw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2BA4.s") + if (this->unk_15C == 0) { + Actor_SetObjectDependency(globalCtx, &this->dyna.actor); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_secom_obj_Colheader_0001C0); + if (ActorCutscene_GetAdditionalCutscene(this->unk_15F) >= 0) { + this->dyna.actor.params |= OBJNOZOKI_400; + } + ObjNozoki_SetupAction(this, func_80BA27C4); + } else if (this->unk_15C == 1) { + Lib_Vec3f_TranslateAndRotateY(&this->dyna.actor.world.pos, this->dyna.actor.shape.rot.y, &D_80BA34C0, + &this->dyna.actor.home.pos); + Actor_SetScale(&this->dyna.actor, 0.6f); + this->dyna.actor.flags |= ACTOR_FLAG_20; + ObjNozoki_SetupAction(this, func_80BA2BA4); + } else if (this->unk_15C == 2) { + Lib_Vec3f_TranslateAndRotateY(&this->dyna.actor.home.pos, this->dyna.actor.shape.rot.y, &D_80BA34CC, + &this->dyna.actor.focus.pos); + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->dyna.actor.focus.pos); + ObjNozoki_SetupAction(this, func_80BA3044); + } else { + ObjNozoki_SetupAction(this, func_80BA311C); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2C28.s") +s32 func_80BA26A8(ObjNozoki* this) { + if (this->unk_15F < 0) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA2C94.s") + if (ActorCutscene_GetCanPlayNext(this->unk_15F)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_15F, &this->dyna.actor); + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA3044.s") + ActorCutscene_SetIntentToPlay(this->unk_15F); + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA311C.s") +s32 func_80BA2708(ObjNozoki* this, GlobalContext* globalCtx) { + Actor* enemy = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; + Vec3f sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA3230.s") + while (enemy != NULL) { + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &sp30, &enemy->world.pos); + if (sp30.z >= 0.0f) { + return false; + } + enemy = enemy->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA3344.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/ObjNozoki_Update.s") +void func_80BA2790(ObjNozoki* this) { + ObjNozoki_SetupAction(this, func_80BA28DC); + this->dyna.actor.velocity.y = 0.0f; + this->unk_15E = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Nozoki/func_80BA3434.s") +void func_80BA27C4(ObjNozoki* this, GlobalContext* globalCtx) { + if (!(globalCtx->actorCtx.unk5 & 0x20)) { + if (OBJNOZOKI_GET_200(&this->dyna.actor)) { + if (!func_80BA2708(this, globalCtx)) { + return; + } + } else { + if (D_80BA36B0 != 0) { + globalCtx->actorCtx.unk5 |= 0x80; + } + + if (!Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + return; + } + } + + if ((D_80BA36B0 == 0) || func_80BA26A8(this)) { + func_80BA2790(this); + if (D_80BA36B0 == 0) { + this->unk_15E = 25; + play_sound(NA_SE_SY_SECOM_WARNING); + } else { + this->unk_15E = ActorCutscene_GetLength(this->unk_15F); + if (this->unk_15E < 0) { + this->unk_15E = 50; + } + globalCtx->actorCtx.unk5 |= 0x10; + } + } + GET_PLAYER(globalCtx)->linearVelocity = 0.0f; + } +} + +void func_80BA28DC(ObjNozoki* this, GlobalContext* globalCtx) { + if (this->unk_15E != 0) { + if (DECR(this->unk_15E) == 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); + } + return; + } + + if (!(globalCtx->actorCtx.unk5 & 0x20)) { + Math_StepToF(&this->dyna.actor.velocity.y, 15.0f, 3.0f); + Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 200.0f, this->dyna.actor.velocity.y); + + if (OBJNOZOKI_GET_200(&this->dyna.actor)) { + if (!Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + return; + } + } else if (Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + s32 cs = this->dyna.actor.cutscene; + + if (cs == this->unk_15F) { + if (OBJNOZOKI_GET_400(&this->dyna.actor)) { + Vec3f sp28; + + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &sp28, &GET_PLAYER(globalCtx)->actor.world.pos); + if (sp28.z < -20.0f) { + this->unk_15F = ActorCutscene_GetAdditionalCutscene(this->unk_15F); + } + } + } else if (D_80BA36B4 == 0) { + if (func_80BA26A8(this)) { + D_80BA36B4 = 1; + } + } else if (ActorCutscene_GetCurrentIndex() != this->unk_15F) { + this->unk_15F = cs; + this->dyna.actor.params &= ~OBJNOZOKI_400; + Audio_QueueSeqCmd(0x881A); + } + return; + } + } + + ObjNozoki_SetupAction(this, func_80BA2AB4); + this->dyna.actor.velocity.y = 0.0f; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); +} + +void func_80BA2AB4(ObjNozoki* this, GlobalContext* globalCtx) { + this->dyna.actor.velocity.y = 30.0f; + + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 30.0f) && (D_80BA36B0 == 0)) { + ObjNozoki_SetupAction(this, func_80BA27C4); + D_80BA36B0 = 1; + } + + if (!(globalCtx->actorCtx.unk5 & 0x20)) { + if (!(OBJNOZOKI_GET_200(&this->dyna.actor)) && + Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + func_80BA2790(this); + } + } +} + +void func_80BA2B64(ObjNozoki* this, GlobalContext* globalCtx, s32 arg2, s32 arg3) { + this->unk_15D = arg2; + this->unk_15E = 80; + Flags_UnsetSwitch(globalCtx, arg3); +} + +void func_80BA2BA4(ObjNozoki* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + this->dyna.actor.shape.rot.x = -0x1F40; + this->unk_15E = 80; + } else if (DECR(this->unk_15E) == 0) { + ObjNozoki_SetupAction(this, func_80BA2C94); + } +} + +s32 func_80BA2C28(ObjNozoki* this) { + s32 i; + s16 cs = this->unk_15F; + + for (i = 0; i < 3; i++) { + if (ActorCutscene_GetCurrentIndex() == cs) { + return i; + } + cs = ActorCutscene_GetAdditionalCutscene(cs); + } + + return -1; +} + +void func_80BA2C94(ObjNozoki* this, GlobalContext* globalCtx) { + s32 temp_v0 = func_80BA2C28(this); + f32 sp38; + f32 sp34; + f32 temp_f0; + + if (temp_v0 >= 0) { + D_80BA36B4 = temp_v0; + } + + if ((temp_v0 < 0) && Play_InCsMode(globalCtx)) { + return; + } + + if (D_80BA36B8 < D_80BA34D8[D_80BA36B4]) { + sp38 = this->dyna.actor.home.pos.y - this->dyna.actor.world.pos.y; + + if ((this->unk_15D != 1) && Flags_GetSwitch(globalCtx, this->dyna.actor.world.rot.z)) { + func_80BA2B64(this, globalCtx, 1, this->dyna.actor.world.rot.x); + } else if ((this->unk_15D != 2) && Flags_GetSwitch(globalCtx, this->dyna.actor.world.rot.x)) { + func_80BA2B64(this, globalCtx, 2, this->dyna.actor.world.rot.z); + } else if (DECR(this->unk_15E) == 0) { + this->unk_15D = 0; + Flags_UnsetSwitch(globalCtx, this->dyna.actor.world.rot.z); + Flags_UnsetSwitch(globalCtx, this->dyna.actor.world.rot.x); + } + + Math_StepToF(&this->dyna.actor.speedXZ, D_80BA34E4[this->unk_15D], 0.1f); + + if ((globalCtx->actorCtx.unk5 & 0x40) || (globalCtx->actorCtx.unk5 & 0x20)) { + temp_f0 = 0.5f; + } else { + temp_f0 = this->dyna.actor.speedXZ; + } + + sp34 = Math_Vec3f_StepToXZ(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos, temp_f0); + + D_80BA36B8 += this->dyna.actor.speedXZ; + + if (globalCtx->actorCtx.unk5 & 0x40) { + if (sp34 <= 5.0f) { + Actor_MarkForDeath(&this->dyna.actor); + } + } else if (!(globalCtx->actorCtx.unk5 & 0x20) && (GET_PLAYER(globalCtx)->actor.id == ACTOR_PLAYER) && + Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG2(&this->dyna.actor)) && (sp38 < 20.0f)) { + static Vec3f D_80BA34F0 = { 0.0f, 0.0f, 50.0f }; + + globalCtx->actorCtx.unk5 |= 0x40; + Lib_Vec3f_TranslateAndRotateY(&this->dyna.actor.home.pos, this->dyna.actor.shape.rot.y, &D_80BA34F0, + &this->dyna.actor.world.pos); + this->dyna.actor.shape.rot.x = -0x1F40; + } else if (sp34 < 50.0f) { + globalCtx->actorCtx.unk5 |= 0x20; + + if (sp34 < 20.0f) { + this->dyna.actor.velocity.y -= 0.4f; + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; + + sp38 = this->dyna.actor.home.pos.y - this->dyna.actor.world.pos.y; + if (sp38 >= 100.0f) { + Actor_MarkForDeath(&this->dyna.actor); + } + + this->dyna.actor.shape.rot.x = -0x1F40 - (s16)(sp38 * 400.0f); + } + } + } + + this->dyna.actor.velocity.x += this->dyna.actor.speedXZ * 0.66f; + if (this->dyna.actor.velocity.x >= 0x10000) { + this->dyna.actor.velocity.x -= 0x10000; + } + + globalCtx->roomCtx.unk7A[0] = this->dyna.actor.velocity.x; + + func_8019FAD8(&D_801DB4A4, NA_SE_EV_SECOM_CONVEYOR - SFX_FLAG, this->dyna.actor.speedXZ); +} + +void func_80BA3044(ObjNozoki* this, GlobalContext* globalCtx) { + Vec3f* sp1C = &this->dyna.actor.focus.pos; + + if (this->unk_15D == 0) { + if (globalCtx->actorCtx.unk5 & 0x40) { + this->unk_15D = 1; + this->unk_15E = 20; + Math_Vec3f_Copy(&this->dyna.actor.world.pos, sp1C); + } else if (!(globalCtx->actorCtx.unk5 & 0x20) && + Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + sp1C = &this->dyna.actor.home.pos; + } + } else if (DECR(this->unk_15E) == 0) { + sp1C = &this->dyna.actor.home.pos; + } + + Math_Vec3f_StepToXZ(&this->dyna.actor.world.pos, sp1C, 8.0f); +} + +void func_80BA311C(ObjNozoki* this, GlobalContext* globalCtx) { + if (this->unk_15D == 0) { + if (Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + this->unk_15D = 1; + this->unk_15E = 70; + } + } else if (this->unk_15D == 1) { + if (D_80BA36B8 > 40.0f) { + this->unk_15D = 2; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_PL_SIT_ON_HORSE); + } else if (this->unk_15E != 0) { + if (DECR(this->unk_15E) == 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CONVEYOR_SHUTTER_OPEN); + } + } else { + Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 50.0f, 4.0f); + } + } else { + Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 4.0f); + } +} + +void func_80BA3230(ObjNozoki* this, GlobalContext* globalCtx) { + if (gSaveContext.save.weekEventReg[64] & 0x20) { + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; + Actor* test3 = SubS_FindActor(globalCtx, npc, ACTORCAT_NPC, ACTOR_EN_TEST3); + + if ((test3 != NULL) && (test3->draw != NULL)) { + if ((globalCtx->curSpawn == 3) && !(gSaveContext.save.weekEventReg[64] & 0x40)) { + this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10000); + this->dyna.actor.textId = 0x297A; + } else { + this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + if (gSaveContext.save.weekEventReg[64] & 0x40) { + this->dyna.actor.textId = 0; + } else { + this->dyna.actor.textId = 0x2979; + } + } + + if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state)) { + ObjNozoki_SetupAction(this, func_80BA3344); + } else { + func_800B8614(&this->dyna.actor, globalCtx, 50.0f); + } + } + } +} + +void func_80BA3344(ObjNozoki* this, GlobalContext* globalCtx) { + if ((globalCtx->curSpawn == 3) && !(gSaveContext.save.weekEventReg[64] & 0x40)) { + if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { + gSaveContext.save.weekEventReg[64] |= 0x40; + this->dyna.actor.flags &= ~ACTOR_FLAG_10000; + ObjNozoki_SetupAction(this, func_80BA3230); + } + } else if ((this->dyna.actor.textId == 0) || Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { + globalCtx->nextEntranceIndex = 0xE20; + globalCtx->sceneLoadFlag = 0x14; + } +} + +void ObjNozoki_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjNozoki* this = THIS; + + this->actionFunc(this, globalCtx); +} + +Gfx* D_80BA34FC[] = { + object_secom_obj_DL_000080, + (Gfx*)0x0A0001A0, //! @bug This dlist should point to a dlist in OBJECT_GI_MSSA, but the segment and the offset are + //! wrong. This doesn't have side effects because of the extra check in the Draw function + object_secom_obj_DL_001230, + object_secom_obj_DL_001300, +}; + +void ObjNozoki_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjNozoki* this = THIS; + + if (this->unk_15C == 1) { + GetItem_Draw(globalCtx, GID_39); + } else { + Gfx_DrawDListOpa(globalCtx, D_80BA34FC[this->unk_15C]); + } +} diff --git a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h index 164e25ecc..08af2bc02 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h @@ -7,9 +7,20 @@ struct ObjNozoki; typedef void (*ObjNozokiActionFunc)(struct ObjNozoki*, GlobalContext*); +#define OBJNOZOKI_GET_SWITCHFLAG1(thisx) ((thisx)->params & 0x7F) +#define OBJNOZOKI_GET_180(thisx) (((thisx)->params >> 7) & 3) +#define OBJNOZOKI_GET_200(thisx) ((thisx)->params & 0x200) +#define OBJNOZOKI_GET_400(thisx) ((thisx)->params & 0x400) +#define OBJNOZOKI_GET_SWITCHFLAG2(thisx) (((thisx)->params >> 9) & 0x7F) + +#define OBJNOZOKI_400 0x400 + typedef struct ObjNozoki { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ u8 unk_15C; + /* 0x015D */ u8 unk_15D; + /* 0x015E */ s8 unk_15E; + /* 0x015F */ s8 unk_15F; /* 0x0160 */ ObjNozokiActionFunc actionFunc; } ObjNozoki; // size = 0x164 diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index bed963c7a..73c959b32 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -15076,7 +15076,7 @@ 0x80BA3230:("func_80BA3230",), 0x80BA3344:("func_80BA3344",), 0x80BA3410:("ObjNozoki_Update",), - 0x80BA3434:("func_80BA3434",), + 0x80BA3434:("ObjNozoki_Draw",), 0x80BA36C0:("func_80BA36C0",), 0x80BA36FC:("EnToto_Init",), 0x80BA3810:("EnToto_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 892c20e98..ca9dfd0a8 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1662,10 +1662,6 @@ D_06000030 = 0x06000030; D_06002068 = 0x06002068; D_06002188 = 0x06002188; -// ovl_Obj_Nozoki - -D_060001C0 = 0x060001C0; - // ovl_Obj_Ocarinalift D_06001DB0 = 0x06001DB0; From 313fdecf37d3e7460beb1c640a7dc51e369e87fd Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 17 Apr 2022 18:39:13 +0100 Subject: [PATCH 186/257] Bg_Kin2_Shelf (#759) * Bg_Kin2_Shelf * PR --- spec | 3 +- .../ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c | 351 ++++++++++++++++-- .../ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.h | 11 +- 3 files changed, 339 insertions(+), 26 deletions(-) diff --git a/spec b/spec index 4a9f46bde..9fc8e7327 100644 --- a/spec +++ b/spec @@ -4139,8 +4139,7 @@ beginseg name "ovl_Bg_Kin2_Shelf" compress include "build/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.o" - include "build/data/ovl_Bg_Kin2_Shelf/ovl_Bg_Kin2_Shelf.data.o" - include "build/data/ovl_Bg_Kin2_Shelf/ovl_Bg_Kin2_Shelf.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Kin2_Shelf/ovl_Bg_Kin2_Shelf_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c index cf09d0896..dc504ecb7 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c @@ -5,6 +5,7 @@ */ #include "z_bg_kin2_shelf.h" +#include "objects/object_kin2_obj/object_kin2_obj.h" #define FLAGS 0x00000000 @@ -15,7 +16,13 @@ void BgKin2Shelf_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgKin2Shelf_Update(Actor* thisx, GlobalContext* globalCtx); void BgKin2Shelf_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B700A8(BgKin2Shelf* this); +void func_80B700C0(BgKin2Shelf* this, GlobalContext* globalCtx); +void func_80B70214(BgKin2Shelf* this); +void func_80B70230(BgKin2Shelf* this, GlobalContext* globalCtx); +void func_80B70498(BgKin2Shelf* this); +void func_80B704B4(BgKin2Shelf* this, GlobalContext* globalCtx); + const ActorInit Bg_Kin2_Shelf_InitVars = { ACTOR_BG_KIN2_SHELF, ACTORCAT_BG, @@ -28,43 +35,345 @@ const ActorInit Bg_Kin2_Shelf_InitVars = { (ActorFunc)BgKin2Shelf_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B7077C[] = { +f32 D_80B70750[] = { 60.0f, 120.0f }; + +f32 D_80B70758[] = { 40.0f, 0.0f }; + +f32 D_80B70760[] = { 10.0f, 15.0f }; + +f32 D_80B70768[] = { 15.0f, 60.0f }; + +f32 D_80B70770[] = { 10.0f, 15.0f }; + +u8 D_80B70778[] = { 0x0F, 0x0A }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP), }; -#endif +CollisionHeader* D_80B70780[] = { &object_kin2_obj_Colheader_001328, &object_kin2_obj_Colheader_000F80 }; -extern InitChainEntry D_80B7077C[]; +Gfx* D_80B70788[] = { object_kin2_obj_DL_0010F8, object_kin2_obj_DL_000CA8 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FB30.s") +s32 func_80B6FB30(BgKin2Shelf* this, GlobalContext* globalCtx) { + s32 temp_v1 = BGKIN2SHELF_GET_1(&this->dyna.actor); + f32 phi_f0; + f32 spA4; + s16 spA2; + Vec3f sp94; + Vec3f sp88; + Vec3f sp7C; + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + CollisionPoly* sp54; + s32 sp50; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FCA4.s") + if (this->unk_164 & 2) { + spA2 = 0x4000; + } else { + spA2 = -0x4000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FE08.s") + spA4 = D_80B70750[temp_v1] + ((this->dyna.pushForce < 0.0f) ? 28.0f : -2.0f) + D_80B70768[temp_v1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FE48.s") + Matrix_InsertTranslation(0.0f, 10.0f, D_80B70760[temp_v1], MTXMODE_NEW); + Matrix_RotateY(spA2, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FEBC.s") + sp58.x = 0.0f; + sp58.y = 0.0f; + sp58.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B6FF28.s") + Matrix_MultiplyVector3fByState(&sp58, &sp94); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/BgKin2Shelf_Init.s") + sp58.z = spA4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/BgKin2Shelf_Destroy.s") + Matrix_MultiplyVector3fByState(&sp58, &sp88); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_MultiplyVector3fByState(&sp94, &sp7C); + Matrix_MultiplyVector3fByState(&sp88, &sp70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B700A8.s") + return BgCheck_EntityLineTest3(&globalCtx->colCtx, &sp7C, &sp70, &sp64, &sp54, true, false, false, true, &sp50, + &this->dyna.actor, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B700C0.s") +s32 func_80B6FCA4(BgKin2Shelf* this, GlobalContext* globalCtx) { + s32 pad; + f32 spA0; + s16 sp9E; + Vec3f sp90; + Vec3f sp84; + Vec3f sp78; + Vec3f sp6C; + Vec3f sp60; + Vec3f sp54; + CollisionPoly* sp50; + s32 sp4C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B70214.s") + if (this->unk_164 & 1) { + sp9E = 0; + } else { + sp9E = -0x8000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B70230.s") + spA0 = D_80B70758[0] + ((this->dyna.pushForce < 0.0f) ? 28.0f : -2.0f) + D_80B70770[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B70498.s") + Matrix_InsertTranslation(0.0f, 10.0f, *D_80B70760, MTXMODE_NEW); + Matrix_RotateY(sp9E, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/func_80B704B4.s") + sp54.x = 0.0f; + sp54.y = 0.0f; + sp54.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/BgKin2Shelf_Update.s") + Matrix_MultiplyVector3fByState(&sp54, &sp90); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Shelf/BgKin2Shelf_Draw.s") + sp54.z = spA0; + + Matrix_MultiplyVector3fByState(&sp54, &sp84); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_MultiplyVector3fByState(&sp90, &sp78); + Matrix_MultiplyVector3fByState(&sp84, &sp6C); + + return BgCheck_EntityLineTest3(&globalCtx->colCtx, &sp78, &sp6C, &sp60, &sp50, true, false, false, true, &sp4C, + &this->dyna.actor, 0.0f); +} + +s32 func_80B6FE08(BgKin2Shelf* this, GlobalContext* globalCtx) { + if (this->unk_164 & (0x8 | 0x2)) { + return func_80B6FB30(this, globalCtx); + } + return func_80B6FCA4(this, globalCtx); +} + +s32 func_80B6FE48(BgKin2Shelf* this, GlobalContext* globalCtx) { + s32 params = BGKIN2SHELF_GET_1(&this->dyna.actor); + u8 temp_v1 = D_80B70778[params] & this->unk_164; + + if ((this->unk_166 != 0) && (this->unk_167 != 0)) { + return false; + } + + if ((this->unk_166 == 0) && (this->unk_167 == 0)) { + return temp_v1 != 0; + } + + if (this->unk_166 != 0) { + return temp_v1 & (0x8 | 0x2); + } + + return temp_v1 & 5; +} + +s32 func_80B6FEBC(BgKin2Shelf* this, GlobalContext* globalCtx) { + if (this->unk_164 & 1) { + return this->unk_167 < 1; + } + + if (this->unk_164 & 2) { + return this->unk_166 < 1; + } + + if (this->unk_164 & 4) { + return this->unk_167 >= 0; + } + + if (this->unk_164 & 8) { + return this->unk_166 >= 0; + } + return false; +} + +s32 func_80B6FF28(BgKin2Shelf* this, GlobalContext* globalCtx) { + return (this->unk_165 > 8) && func_80B6FE48(this, globalCtx) && func_80B6FEBC(this, globalCtx) && + !func_80B6FE08(this, globalCtx); +} + +void BgKin2Shelf_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgKin2Shelf* this = THIS; + s32 sp24 = BGKIN2SHELF_GET_1(&this->dyna.actor); + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + + if (sp24 == 0) { + this->dyna.actor.uncullZoneScale = 150.0f; + this->dyna.actor.uncullZoneDownward = 140.0f; + Actor_SetScale(&this->dyna.actor, 0.1f); + } else { + this->dyna.actor.uncullZoneScale = 250.0f; + this->dyna.actor.uncullZoneDownward = 300.0f; + Actor_SetScale(&this->dyna.actor, 1.0f); + this->dyna.actor.flags |= ACTOR_FLAG_10000000; + } + + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_80B70780[sp24]); + func_80B700A8(this); +} + +void BgKin2Shelf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgKin2Shelf* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80B700A8(BgKin2Shelf* this) { + this->unk_165 = 0; + this->actionFunc = func_80B700C0; +} + +void func_80B700C0(BgKin2Shelf* this, GlobalContext* globalCtx) { + s16 temp_v0; + u8 phi_v0_2; + + if (fabsf(this->dyna.pushForce) > 0.1f) { + temp_v0 = this->dyna.yRotation - this->dyna.actor.shape.rot.y; + if (this->dyna.pushForce < 0.0f) { + temp_v0 = BINANG_ROT180(temp_v0); + } + + if ((temp_v0 < -0x6000) || (temp_v0 >= 0x6000)) { + phi_v0_2 = 4; + } else if (temp_v0 < -0x2000) { + phi_v0_2 = 8; + } else if (temp_v0 < 0x2000) { + phi_v0_2 = 1; + } else { + phi_v0_2 = 2; + } + + if ((phi_v0_2 == this->unk_164) || (this->unk_164 == 0)) { + this->unk_164 = phi_v0_2; + this->unk_165++; + } else { + this->unk_165 = 0; + this->unk_164 = 0; + } + + if (func_80B6FF28(this, globalCtx)) { + if (this->unk_164 & (0x8 | 0x2)) { + func_80B70214(this); + } else { + func_80B70498(this); + } + } else { + Player* player = GET_PLAYER(globalCtx); + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } + } else { + this->unk_165 = 0; + this->unk_164 = 0; + } +} + +void func_80B70214(BgKin2Shelf* this) { + this->unk_160 = 0.0f; + this->actionFunc = func_80B70230; +} + +void func_80B70230(BgKin2Shelf* this, GlobalContext* globalCtx) { + f32 phi_f20; + s32 sp40 = BGKIN2SHELF_GET_1(&this->dyna.actor); + f32 phi_f2; + s32 pad; + s16 sp36 = BINANG_ADD(this->dyna.actor.shape.rot.y, 0x4000); + + if ((BGKIN2SHELF_GET_1(&this->dyna.actor)) == 0) { + phi_f2 = (Math_SinS(this->unk_160 * 0x8000) * 0.012f) + 0.014f; + } else { + phi_f2 = (Math_SinS(this->unk_160 * 0x8000) * 0.003f) + 0.009f; + } + this->unk_160 += phi_f2; + + if (this->unk_160 >= 1.0f) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_160 = 1.0f; + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + + if (this->unk_164 & 8) { + this->unk_166--; + } else { + this->unk_166++; + } + + phi_f20 = this->unk_166; + + this->dyna.actor.world.pos.x = ((Math_SinS(sp36) * phi_f20) * D_80B70750[sp40]) + this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.z = ((Math_CosS(sp36) * phi_f20) * D_80B70750[sp40]) + this->dyna.actor.home.pos.z; + + if (this->unk_166 != 0) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + func_80B700A8(this); + } else { + if (this->unk_164 & 8) { + phi_f20 = this->unk_166 - this->unk_160; + } else { + phi_f20 = this->unk_166 + this->unk_160; + } + this->dyna.actor.world.pos.x = ((Math_SinS(sp36) * phi_f20) * D_80B70750[sp40]) + this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.z = ((Math_CosS(sp36) * phi_f20) * D_80B70750[sp40]) + this->dyna.actor.home.pos.z; + } +} + +void func_80B70498(BgKin2Shelf* this) { + this->unk_160 = 0.0f; + this->actionFunc = func_80B704B4; +} + +void func_80B704B4(BgKin2Shelf* this, GlobalContext* globalCtx) { + f32 temp_f20; + s32 sp40 = BGKIN2SHELF_GET_1(&this->dyna.actor); + f32 phi_f20; + s32 pad; + s16 sp36 = this->dyna.actor.shape.rot.y; + + this->unk_160 += (Math_SinS(this->unk_160 * 0x8000) * 0.022f) + 0.022f; + + if (this->unk_160 >= 1.0f) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_160 = 1.0f; + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + + if (this->unk_164 & 4) { + this->unk_167--; + } else { + this->unk_167++; + } + + temp_f20 = this->unk_167; + this->dyna.actor.world.pos.x = ((Math_SinS(sp36) * temp_f20) * D_80B70758[sp40]) + this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.z = ((Math_CosS(sp36) * temp_f20) * D_80B70758[sp40]) + this->dyna.actor.home.pos.z; + + if (this->unk_167 != 0) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + func_80B700A8(this); + } else { + if (this->unk_164 & 4) { + temp_f20 = this->unk_167 - this->unk_160; + } else { + temp_f20 = this->unk_167 + this->unk_160; + } + this->dyna.actor.world.pos.x = ((Math_SinS(sp36) * temp_f20) * D_80B70758[sp40]) + this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.z = ((Math_CosS(sp36) * temp_f20) * D_80B70758[sp40]) + this->dyna.actor.home.pos.z; + } +} + +void BgKin2Shelf_Update(Actor* thisx, GlobalContext* globalCtx) { + BgKin2Shelf* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgKin2Shelf_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, D_80B70788[BGKIN2SHELF_GET_1(thisx)]); +} diff --git a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.h b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.h index d5cf40c2f..29a295851 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.h +++ b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.h @@ -7,11 +7,16 @@ struct BgKin2Shelf; typedef void (*BgKin2ShelfActionFunc)(struct BgKin2Shelf*, GlobalContext*); +#define BGKIN2SHELF_GET_1(thisx) ((thisx)->params & 1) + typedef struct BgKin2Shelf { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ BgKin2ShelfActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x8]; + /* 0x0160 */ f32 unk_160; + /* 0x0164 */ u8 unk_164; + /* 0x0165 */ s8 unk_165; + /* 0x0166 */ s8 unk_166; + /* 0x0167 */ s8 unk_167; } BgKin2Shelf; // size = 0x168 extern const ActorInit Bg_Kin2_Shelf_InitVars; From f4bb821b56f7f3e957cac4d26052542969521523 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 17 Apr 2022 11:07:25 -0700 Subject: [PATCH 187/257] EffectSsSbn OK (#751) * Ok * Cleanup and document * File header description * rename scroll related regs * undef syms * Cleanup for PR * Move comment * Add todo --- assets/xml/objects/gameplay_keep.xml | 38 ++-- include/z64effect.h | 1 + spec | 3 +- src/overlays/actors/ovl_En_Arrow/z_en_arrow.c | 8 +- .../effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c | 198 +++++++++++++++++- .../effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h | 9 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 4 - 8 files changed, 219 insertions(+), 46 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 86f48d61d..22626d302 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1287,27 +1287,27 @@ - + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - + + + + + diff --git a/include/z64effect.h b/include/z64effect.h index d9211ef5e..0b848a478 100644 --- a/include/z64effect.h +++ b/include/z64effect.h @@ -257,6 +257,7 @@ typedef struct { /* 0x18 */ u8 unk18; // Always 1? } EffectSsOverlay; // size = 0x1C +//! TODO: Review reuse of vec/gfx/actor fields across all effects typedef struct EffectSs { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f velocity; diff --git a/spec b/spec index 9fc8e7327..3a3d2f8ff 100644 --- a/spec +++ b/spec @@ -3411,8 +3411,7 @@ beginseg name "ovl_Effect_Ss_Sbn" compress include "build/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.o" - include "build/data/ovl_Effect_Ss_Sbn/ovl_Effect_Ss_Sbn.data.o" - include "build/data/ovl_Effect_Ss_Sbn/ovl_Effect_Ss_Sbn.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Sbn/ovl_Effect_Ss_Sbn_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index d3286f545..f1dc5c6f6 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -357,10 +357,10 @@ void func_8088ACE0(EnArrow* this, GlobalContext* globalCtx) { if ((this->unk_262 != 0) && (this->actor.wallBgId == BG_ACTOR_MAX)) { - Math_Vec3f_Copy(&sp84.unk_00, &this->actor.world.pos); - sp84.unk_0C = this->actor.wallPoly; - sp84.unk_10 = this->bubble.unk_144; - EffectSs_Spawn(globalCtx, EFFECT_SS_SBN, 128, &sp84.unk_00); + Math_Vec3f_Copy(&sp84.pos, &this->actor.world.pos); + sp84.colPoly = this->actor.wallPoly; + sp84.scale = this->bubble.unk_144; + EffectSs_Spawn(globalCtx, EFFECT_SS_SBN, 128, &sp84); } } Actor_MarkForDeath(&this->actor); diff --git a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c index b09dca014..26901bac5 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c +++ b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c @@ -1,30 +1,208 @@ /* * File: z_eff_ss_sbn.c * Overlay: ovl_Effect_Ss_Sbn - * Description: + * Description: Popped Deku Bubble + * + * Note: The gfx field is used to store the colPoly, not anything gfx related + * This is not a problem since gfx is already void* */ #include "z_eff_ss_sbn.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rScrollStep regs[0] +#define rScroll regs[1] +#define rTexIndex regs[2] +#define rAlpha regs[3] +#define rReg4 regs[4] +#define rReg4Step regs[5] +#define rRotAngle regs[6] +#define rScale regs[7] +#define rReg8 regs[8] #define PARAMS ((EffectSsSbnInitParams*)initParamsx) -s32 EffectSsSbn_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsSbn_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsSbn_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_80AC8ECC(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_80AC9164(GlobalContext* globalCtx, u32 index, EffectSs* this); +void EffectSsSbn_DrawSliding(GlobalContext* globalCtx, u32 index, EffectSs* this); +void EffectSsSbn_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Sbn_InitVars = { EFFECT_SS_SBN, EffectSsSbn_Init, }; -#endif +static TexturePtr sSlidingTextures[] = { + gEffPoppedDekuBubbleSliding1Tex, gEffPoppedDekuBubbleSliding2Tex, gEffPoppedDekuBubbleSliding3Tex, + gEffPoppedDekuBubbleSliding4Tex, gEffPoppedDekuBubbleSliding5Tex, gEffPoppedDekuBubbleSliding6Tex, + gEffPoppedDekuBubbleSliding7Tex, gEffPoppedDekuBubbleSliding8Tex, gEffPoppedDekuBubbleSliding9Tex, + gEffPoppedDekuBubbleSliding10Tex, gEffPoppedDekuBubbleSliding11Tex, gEffPoppedDekuBubbleSliding12Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sbn/EffectSsSbn_Init.s") +static TexturePtr sTextures[] = { + gEffPoppedDekuBubble1Tex, gEffPoppedDekuBubble2Tex, gEffPoppedDekuBubble3Tex, + gEffPoppedDekuBubble4Tex, gEffPoppedDekuBubble5Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sbn/func_80AC8ECC.s") +u32 EffectSsSbn_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsSbnInitParams* initParams = PARAMS; + CollisionPoly* colPoly; + MtxF mtx; + Vec3f normal; + Vec3f colPolyVec; + Vec3f bubbleVec; + f32 angle; + f32 opposite; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sbn/func_80AC9164.s") + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &gZeroVec3f); + Math_Vec3f_Copy(&this->accel, &gZeroVec3f); + this->flags = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sbn/EffectSsSbn_Update.s") + this->gfx = initParams->colPoly; + + this->rScroll = 0; + this->rScrollStep = 7; + this->rTexIndex = 0; + this->rAlpha = 200; + this->rReg4 = 250; + this->rReg4Step = 30; + + this->rScale = randPlusMinusPoint5Scaled(100.0f) + (initParams->scale * 120.0f); + if (this->rScale < 600) { + this->rScale = 600; + } else if (this->rScale > 1500) { + this->rScale = 1500; + } + + this->rReg8 = 1000; + this->rRotAngle = 0; + this->life = 93; + this->draw = EffectSsSbn_DrawSliding; + this->update = EffectSsSbn_Update; + + if (this->gfx != NULL) { + colPoly = this->gfx; + func_800C0094(colPoly, this->pos.x, this->pos.y, this->pos.z, &mtx); + normal.x = COLPOLY_GET_NORMAL(colPoly->normal.x); + normal.y = COLPOLY_GET_NORMAL(colPoly->normal.y); + normal.z = COLPOLY_GET_NORMAL(colPoly->normal.z); + if ((normal.y > 0.95f) || (normal.y < -0.95f)) { + this->draw = EffectSsSbn_Draw; + return 1; + } + if (normal.y > 0.05f) { + colPolyVec.x = normal.x * 10.0f; + colPolyVec.y = (-(SQ(normal.x) + SQ(normal.z)) * 10.0f) / normal.y; + colPolyVec.z = normal.z * 10.0f; + } else if (normal.y < -0.05f) { + colPolyVec.x = -normal.x * 10.0f; + colPolyVec.y = (-(SQ(normal.x) + SQ(normal.z)) * 10.0f) / -normal.y; + colPolyVec.z = -normal.z * 10.0f; + } else { + colPolyVec.x = 0.0f; + colPolyVec.y = -10.0f; + colPolyVec.z = 0.0f; + } + bubbleVec.x = -mtx.mf[2][0] * 10.0f; + bubbleVec.y = -mtx.mf[2][1] * 10.0f; + bubbleVec.z = -mtx.mf[2][2] * 10.0f; + Math3D_AngleBetweenVectors(&colPolyVec, &bubbleVec, &angle); + + opposite = (SQ(angle) >= 1.0f) ? 0.0f : sqrtf(1.0f - SQ(angle)); + if (((mtx.mf[0][0] * colPolyVec.x) + (mtx.mf[0][1] * colPolyVec.y) + (mtx.mf[0][2] * colPolyVec.z)) < 0.0f) { + this->rRotAngle = Math_FAtan2F(angle, opposite); + } else { + this->rRotAngle = -Math_FAtan2F(angle, opposite); + } + } + + return 1; +} + +void EffectSsSbn_DrawSliding(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + MtxF mtx; + f32 scale = this->rScale * 0.001f; + s32 pad; + + func_800C0094(this->gfx, this->pos.x, this->pos.y, this->pos.z, &mtx); + SkinMatrix_MulYRotation(&mtx, this->rRotAngle); + Matrix_InsertMatrix(&mtx, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_Scale(0.05f, 0.05f, 0.05f, MTXMODE_APPLY); + + OPEN_DISPS(gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(gfxCtx); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_XLU_DECAL2); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, this->rAlpha); + + if (this->rTexIndex < ARRAY_COUNT(sSlidingTextures)) { + { + TexturePtr tex = sSlidingTextures[this->rTexIndex]; + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(tex)); + } + this->rTexIndex++; + this->rScroll += this->rScrollStep; + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffPoppedDekuBubbleSliding12Tex)); + if ((this->rScrollStep >= 2) && ((globalCtx->state.frames % 2) == 0)) { + this->rScrollStep--; + } + this->rScroll += this->rScrollStep; + } + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, this->rScroll, 0x20, 0x20)); + gSPDisplayList(POLY_XLU_DISP++, gEffPoppedDekuBubbleSlidingDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsSbn_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + MtxF mtx; + f32 scale = this->rScale * 0.001f; + + func_800C0094(this->gfx, this->pos.x, this->pos.y, this->pos.z, &mtx); + SkinMatrix_MulYRotation(&mtx, this->rRotAngle); + Matrix_InsertMatrix(&mtx, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_Scale(0.05f, 0.05f, 0.05f, MTXMODE_APPLY); + + OPEN_DISPS(gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(gfxCtx); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_XLU_DECAL2); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, this->rAlpha); + + if (this->rTexIndex < ARRAY_COUNT(sTextures)) { + { + TexturePtr tex = sTextures[this->rTexIndex]; + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(tex)); + } + this->rTexIndex++; + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffPoppedDekuBubble5Tex)); + } + gSPDisplayList(POLY_XLU_DISP++, gEffPoppedDekuBubbleDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsSbn_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + if (this->life < 10) { + this->rAlpha -= 20; + } else if (this->life >= 45) { + if (this->life < 85) { + this->rReg8 += 12; + this->rReg4 -= this->rReg4Step; + } else { + this->rReg8 = 1000; + } + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h index ba2355d23..439ef88a0 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h +++ b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h @@ -4,11 +4,10 @@ #include "global.h" typedef struct { - /* 0x00 */ Vec3f unk_00; - /* 0x0C */ CollisionPoly* unk_0C; - /* 0x10 */ f32 unk_10; - /* 0x14 */ char unk_14[UNK_SIZE]; -} EffectSsSbnInitParams; // size = ? + /* 0x00 */ Vec3f pos; + /* 0x0C */ CollisionPoly* colPoly; + /* 0x10 */ f32 scale; +} EffectSsSbnInitParams; // size = 0x14 extern const EffectSsInit Effect_Ss_Sbn_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 73c959b32..6a7b92683 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -11997,8 +11997,8 @@ 0x80AC8A94:("TransitionWipe5_SetColor",), 0x80AC8AA0:("TransitionWipe5_SetEnvColor",), 0x80AC8B50:("EffectSsSbn_Init",), - 0x80AC8ECC:("func_80AC8ECC",), - 0x80AC9164:("func_80AC9164",), + 0x80AC8ECC:("EffectSsSbn_DrawSliding",), + 0x80AC9164:("EffectSsSbn_Draw",), 0x80AC933C:("EffectSsSbn_Update",), 0x80AC94C0:("func_80AC94C0",), 0x80AC94FC:("ObjOcarinalift_Init",), diff --git a/undefined_syms.txt b/undefined_syms.txt index ca9dfd0a8..296d6273e 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -470,10 +470,6 @@ D_0406F380 = 0x0406F380; D_0406F9F0 = 0x0406F9F0; D_0406FAE0 = 0x0406FAE0; D_040706E0 = 0x040706E0; -D_04071230 = 0x04071230; -D_04073F00 = 0x04073F00; -D_04074330 = 0x04074330; -D_04075400 = 0x04075400; D_04075A40 = 0x04075A40; D_04076BC0 = 0x04076BC0; D_04079B10 = 0x04079B10; From bfe22610f7963564a92e733a3abb6feae017af29 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 17 Apr 2022 11:35:13 -0700 Subject: [PATCH 188/257] EffectSsStone1 Ok (#730) * EffectSsStone1 OK * gameplay object stuff * unk_C -> reg0 * Fix * Reverse order of stone textures * undef syms --- assets/xml/objects/gameplay_keep.xml | 18 ++--- include/functions.h | 2 +- spec | 3 +- src/code/z_effect_soft_sprite_old_init.c | 4 +- .../ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c | 67 +++++++++++++++++-- .../ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h | 2 +- undefined_syms.txt | 1 - 7 files changed, 75 insertions(+), 22 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 22626d302..41b144120 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1053,15 +1053,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/include/functions.h b/include/functions.h index 522fac154..d15fbbbfa 100644 --- a/include/functions.h +++ b/include/functions.h @@ -572,7 +572,7 @@ void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstSca // void EffectSsStick_Spawn(UNK_TYPE4 uParm1, UNK_PTR puParm2, UNK_TYPE2 uParm3); // void EffectSsSibuki_Spawn(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); void EffectSsSibuki_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos); -void EffectSsStone1_Spawn(GlobalContext* globalCtx, Vec3f* arg1, s32 arg2); +void EffectSsStone1_Spawn(GlobalContext* globalCtx, Vec3f* pos, s32 reg0); // void EffectSsHitMark_Spawn(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, UNK_TYPE2 uParm3, Vec3f* pzParm4); void EffectSsHitMark_SpawnFixedScale(GlobalContext* globalCtx, s32 type, Vec3f* pos); void EffectSsHitMark_SpawnCustomScale(GlobalContext* globalCtx, s32 type, s16 scale, Vec3f* pos); diff --git a/spec b/spec index 3a3d2f8ff..8328eaa43 100644 --- a/spec +++ b/spec @@ -1910,8 +1910,7 @@ beginseg name "ovl_Effect_Ss_Stone1" compress include "build/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.o" - include "build/data/ovl_Effect_Ss_Stone1/ovl_Effect_Ss_Stone1.data.o" - include "build/data/ovl_Effect_Ss_Stone1/ovl_Effect_Ss_Stone1.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Stone1/ovl_Effect_Ss_Stone1_reloc.o" endseg beginseg diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index 3f868ecc3..0300144e1 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -625,11 +625,11 @@ void EffectSsSibuki_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos) { // EffectSsStone1 Spawn Functions -void EffectSsStone1_Spawn(GlobalContext* globalCtx, Vec3f* pos, s32 arg2) { +void EffectSsStone1_Spawn(GlobalContext* globalCtx, Vec3f* pos, s32 reg0) { EffectSsStone1InitParams initParams; initParams.pos = *pos; - initParams.unk_C = arg2; + initParams.reg0 = reg0; EffectSs_Spawn(globalCtx, EFFECT_SS_STONE1, 128, &initParams); } diff --git a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c index 714ce0b8c..06cfa5b18 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c @@ -5,23 +5,78 @@ */ #include "z_eff_ss_stone1.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define PARAMS ((EffectSsStone1InitParams*)initParamsx) -s32 EffectSsStone1_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +#define rReg0 regs[0] + +u32 EffectSsStone1_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsStone1_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsStone1_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Stone1_InitVars = { EFFECT_SS_STONE1, EffectSsStone1_Init, }; -#endif +typedef struct { + /* 0x00 */ TexturePtr texture; + /* 0x04 */ Color_RGBA8 primColor; + /* 0x08 */ Color_RGBA8 envColor; +} EffStoneDrawInfo; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Stone1/EffectSsStone1_Init.s") +static EffStoneDrawInfo sDrawInfo[] = { + { gEffStone8Tex, { 200, 0, 0, 255 }, { 0, 0, 0, 255 } }, + { gEffStone7Tex, { 255, 100, 0, 255 }, { 100, 0, 0, 255 } }, + { gEffStone6Tex, { 255, 200, 0, 255 }, { 200, 0, 0, 255 } }, + { gEffStone5Tex, { 255, 255, 0, 255 }, { 255, 0, 0, 255 } }, + { gEffStone4Tex, { 255, 255, 150, 255 }, { 255, 150, 0, 255 } }, + { gEffStone3Tex, { 255, 255, 255, 255 }, { 255, 255, 0, 255 } }, + { gEffStone2Tex, { 255, 255, 255, 255 }, { 0, 255, 0, 255 } }, + { gEffStone1Tex, { 255, 255, 255, 255 }, { 0, 255, 255, 255 } }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Stone1/EffectSsStone1_Draw.s") +u32 EffectSsStone1_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsStone1InitParams* initParams = PARAMS; + Vec3f pos = initParams->pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Stone1/EffectSsStone1_Update.s") + this->pos = pos; + this->vec = pos; + this->life = 8; + this->rReg0 = initParams->reg0; + this->draw = EffectSsStone1_Draw; + this->update = EffectSsStone1_Update; + + return 1; +} + +void EffectSsStone1_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + EffStoneDrawInfo* drawParams = &sDrawInfo[this->life]; + Vec3f mfVec; + f32 mfW; + f32 scale; + + OPEN_DISPS(gfxCtx); + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->pos, &mfVec, &mfW); + scale = (mfW < 1500.0f) ? 3.0f : (mfW / 1500.0f) * 3.0f; + Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C9BC(gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(drawParams->texture)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, drawParams->primColor.r, drawParams->primColor.g, drawParams->primColor.b, + 255); + gDPSetEnvColor(POLY_XLU_DISP++, drawParams->envColor.r, drawParams->envColor.g, drawParams->envColor.b, 255); + gSPDisplayList(POLY_XLU_DISP++, gEffStoneDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsStone1_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + if ((this->life == 6) && (this->rReg0 != 0)) { + iREG(50) = 0; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h index 566811a8a..365585a8e 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h +++ b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h @@ -5,7 +5,7 @@ typedef struct { /* 0x00 */ Vec3f pos; - /* 0x00 */ s32 unk_C; + /* 0x0C */ s32 reg0; } EffectSsStone1InitParams; // size = 0x10 extern const EffectSsInit Effect_Ss_Stone1_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 296d6273e..bf08aa356 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -430,7 +430,6 @@ D_040367B0 = 0x040367B0; D_040377B0 = 0x040377B0; D_04037850 = 0x04037850; D_0403A0F0 = 0x0403A0F0; -D_0403C190 = 0x0403C190; D_0403F230 = 0x0403F230; D_04044300 = 0x04044300; D_0404F250 = 0x0404F250; From 578e36cdbd67b5ee30b309fc00464829774b3ffc Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 17 Apr 2022 20:06:55 +0100 Subject: [PATCH 189/257] Bg_Ikana_Block (#761) * Bg_Ikana_Block * Fix --- spec | 3 +- .../ovl_Bg_Ikana_Block/z_bg_ikana_block.c | 351 ++++++++++++++++-- .../ovl_Bg_Ikana_Block/z_bg_ikana_block.h | 17 +- .../z_bg_ikana_rotaryroom.c | 15 +- 4 files changed, 344 insertions(+), 42 deletions(-) diff --git a/spec b/spec index 8328eaa43..958bb80f9 100644 --- a/spec +++ b/spec @@ -4187,8 +4187,7 @@ beginseg name "ovl_Bg_Ikana_Block" compress include "build/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.o" - include "build/data/ovl_Bg_Ikana_Block/ovl_Bg_Ikana_Block.data.o" - include "build/data/ovl_Bg_Ikana_Block/ovl_Bg_Ikana_Block.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ikana_Block/ovl_Bg_Ikana_Block_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c index 9d2fd67d9..f69302278 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c @@ -5,6 +5,7 @@ */ #include "z_bg_ikana_block.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -14,12 +15,16 @@ void BgIkanaBlock_Init(Actor* thisx, GlobalContext* globalCtx); void BgIkanaBlock_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgIkanaBlock_Update(Actor* thisx, GlobalContext* globalCtx); +void func_80B7F00C(BgIkanaBlock* this); void func_80B7F034(BgIkanaBlock* this, GlobalContext* globalCtx); +void func_80B7F0A4(BgIkanaBlock* this); void func_80B7F0D0(BgIkanaBlock* this, GlobalContext* globalCtx); +void func_80B7F1A8(BgIkanaBlock* this); void func_80B7F290(BgIkanaBlock* this, GlobalContext* globalCtx); +void func_80B7F360(BgIkanaBlock* this); void func_80B7F398(BgIkanaBlock* this, GlobalContext* globalCtx); +void func_80B7F564(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Ikana_Block_InitVars = { ACTOR_BG_IKANA_BLOCK, ACTORCAT_BG, @@ -32,58 +37,350 @@ const ActorInit Bg_Ikana_Block_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B7F640[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 250, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 250, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void func_80B7EA60(BgIkanaBlock* this) { + s32 phi_v0; -extern InitChainEntry D_80B7F640[]; + this->unk_17A &= ~(0x8 | 0x4 | 0x2 | 0x1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EA60.s") + if (fabsf(this->dyna.pushForce) > 0.1f) { + if (this->dyna.pushForce > 0.0f) { + phi_v0 = this->dyna.yRotation; + } else { + phi_v0 = BINANG_ROT180(this->dyna.yRotation); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EB30.s") + if ((phi_v0 < -0x6000) || (phi_v0 >= 0x6000)) { + this->unk_17A |= 8; + } else if (phi_v0 < -0x2000) { + this->unk_17A |= 2; + } else if (phi_v0 < 0x2000) { + this->unk_17A |= 4; + } else { + this->unk_17A |= 1; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EB64.s") +void func_80B7EB30(BgIkanaBlock* this) { + if (this->unk_17A & (0x8 | 0x4 | 0x2 | 0x1)) { + if (this->unk_17B < 127) { + this->unk_17B++; + } + } else { + this->unk_17B = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EB7C.s") +s32 func_80B7EB64(BgIkanaBlock* this, GlobalContext* globalCtx) { + return !(this->unk_17C & 8); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EB94.s") +s32 func_80B7EB7C(BgIkanaBlock* this, GlobalContext* globalCtx) { + return this->unk_17B > 10; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7ECFC.s") +s32 func_80B7EB94(BgIkanaBlock* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + CollisionPoly* sp54; + s32 sp50; + s32 sp4C = false; + s16 phi_a0; + f32 phi_f12; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7ED54.s") + if (this->dyna.pushForce > 0.0f) { + sp4C = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EDC4.s") + if (sp4C) { + phi_a0 = this->dyna.yRotation; + } else { + phi_a0 = BINANG_ROT180(this->dyna.yRotation); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EE70.s") + sp70.x = this->dyna.actor.world.pos.x; + sp70.y = this->dyna.actor.world.pos.y + this->unk_170 + 2.0f; + sp70.z = this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7EEB4.s") + Matrix_RotateY(phi_a0, MTXMODE_NEW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/BgIkanaBlock_Init.s") + if (sp4C) { + phi_f12 = 89.0f; + } else { + phi_f12 = 119.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/BgIkanaBlock_Destroy.s") + Matrix_GetStateTranslationAndScaledZ(phi_f12, &sp64); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F00C.s") + sp64.x += this->dyna.actor.world.pos.x; + sp64.y += this->dyna.actor.world.pos.y + this->unk_170 + 2.0f; + sp64.z += this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F034.s") + return !BgCheck_EntityLineTest3(&globalCtx->colCtx, &sp70, &sp64, &sp58, &sp54, true, false, false, true, &sp50, + &this->dyna.actor, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F0A4.s") +s32 func_80B7ECFC(BgIkanaBlock* this, GlobalContext* globalCtx) { + return func_80B7EB64(this, globalCtx) && func_80B7EB7C(this, globalCtx) && func_80B7EB94(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F0D0.s") +void func_80B7ED54(BgIkanaBlock* this) { + s32 pad; + Vec3f sp18; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F1A8.s") + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledY(30.0f, &sp18); + this->unk_170 = sp18.y - 30.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F290.s") +s32 func_80B7EDC4(BgIkanaBlock* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + s32 sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F360.s") + sp30.x = this->dyna.actor.world.pos.x; + sp30.y = this->dyna.actor.world.pos.y + this->unk_170 + 40.0f; + sp30.z = this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F398.s") + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5_2( + globalCtx, &globalCtx->colCtx, &this->dyna.actor.floorPoly, &sp2C, &this->dyna.actor, &sp30); + this->dyna.actor.floorBgId = sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/BgIkanaBlock_Update.s") + return ((this->dyna.actor.world.pos.y + this->unk_170) - this->dyna.actor.floorHeight) < 2.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Block/func_80B7F564.s") +s32 func_80B7EE70(BgIkanaBlock* this, GlobalContext* globalCtx) { + if (func_80B7EDC4(this, globalCtx)) { + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight - this->unk_170; + return true; + } + return false; +} + +s32 func_80B7EEB4(BgIkanaBlock* this, GlobalContext* globalCtx) { + func_80B7EDC4(this, globalCtx); + + if (this->dyna.actor.floorHeight > (BGCHECK_Y_MIN + 1.0f)) { + if (DynaPoly_GetActor(&globalCtx->colCtx, this->dyna.actor.floorBgId)) { + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight - this->unk_170; + return true; + } + } + return false; +} + +void BgIkanaBlock_Init(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaBlock* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gameplay_dangeon_keep_Colheader_007498); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->unk_15C = Lib_SegmentedToVirtual(gameplay_dangeon_keep_Matanimheader_01B370); + this->unk_174 = this->dyna.actor.shape.rot; + func_80B7ED54(this); + func_80B7F00C(this); +} + +void BgIkanaBlock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaBlock* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80B7F00C(BgIkanaBlock* this) { + this->unk_17C &= ~7; + this->unk_17D = 40; + this->actionFunc = func_80B7F034; +} + +void func_80B7F034(BgIkanaBlock* this, GlobalContext* globalCtx) { + if (this->unk_17D > 0) { + this->unk_17D--; + } + + if (func_80B7EEB4(this, globalCtx)) { + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = func_80B7F564; + func_80B7F0A4(this); + } +} + +void func_80B7F0A4(BgIkanaBlock* this) { + this->unk_17B = 0; + this->unk_17C &= ~7; + this->unk_17C |= 1; + this->actionFunc = func_80B7F0D0; +} + +void func_80B7F0D0(BgIkanaBlock* this, GlobalContext* globalCtx) { + s32 sp24 = 0; + s32 phi_v1; + + func_80B7EA60(this); + func_80B7EB30(this); + + if (this->unk_17C & 4) { + sp24 = 1; + } else if (func_80B7ECFC(this, globalCtx)) { + sp24 = 2; + } + + if ((sp24 != 2) && (this->unk_17A & (0x8 | 0x4 | 0x2 | 0x1))) { + Player* player = GET_PLAYER(globalCtx); + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } + + if (sp24 == 1) { + func_80B7F360(this); + } else if (sp24 == 2) { + func_80B7F1A8(this); + } +} + +void func_80B7F1A8(BgIkanaBlock* this) { + f32 temp_f0; + f32* phi_v0; + s32 phi_v0_2; + + if (this->unk_17A & (0x2 | 0x1)) { + this->unk_164 = &this->dyna.actor.world.pos.x; + phi_v0 = &this->dyna.actor.home.pos.x; + } else { + this->unk_164 = &this->dyna.actor.world.pos.z; + phi_v0 = &this->dyna.actor.home.pos.z; + } + + temp_f0 = (*this->unk_164 - *phi_v0) * 0.016666668f; + + if (temp_f0 >= 0.0f) { + temp_f0 += 0.5f; + } else { + temp_f0 -= 0.5f; + } + + if (this->unk_17A & (0x4 | 0x1)) { + phi_v0_2 = 1; + } else { + phi_v0_2 = -1; + } + + this->unk_168 = *phi_v0 + (((s32)temp_f0 + phi_v0_2) * 60.0f); + this->unk_16C = 0.0f; + this->unk_17C &= ~7; + this->unk_17C |= 2; + this->actionFunc = func_80B7F290; +} + +void func_80B7F290(BgIkanaBlock* this, GlobalContext* globalCtx) { + s32 pad; + + Math_StepToF(&this->unk_16C, 2.0f, 0.4f); + + if (Math_StepToF(this->unk_164, this->unk_168, this->unk_16C)) { + Player* player = GET_PLAYER(globalCtx); + + if (!func_80B7EB94(this, globalCtx)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + + if (func_80B7EDC4(this, globalCtx)) { + func_80B7F0A4(this); + } else { + func_80B7F360(this); + } + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + } +} + +void func_80B7F360(BgIkanaBlock* this) { + this->unk_17C &= ~7; + this->unk_17C |= 4; + this->unk_17D = 1; + this->dyna.actor.velocity.y = 0.0f; + this->actionFunc = func_80B7F398; +} + +void func_80B7F398(BgIkanaBlock* this, GlobalContext* globalCtx) { + if (this->unk_17D > 0) { + this->unk_17D--; + return; + } + + this->dyna.actor.velocity.y -= 2.0f; + this->dyna.actor.velocity.y *= 0.95f; + + if (this->dyna.actor.velocity.y < -30.0f) { + this->dyna.actor.velocity.y = -30.0f; + } + + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; + + if (func_80B7EE70(this, globalCtx)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Actor_PlaySfxAtPos( + &this->dyna.actor, + SurfaceType_GetSfx(&globalCtx->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) + SFX_FLAG); + func_80B7F0A4(this); + } +} + +void BgIkanaBlock_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaBlock* this = THIS; + + if ((this->dyna.actor.shape.rot.x != this->unk_174.x) || (this->dyna.actor.shape.rot.y != this->unk_174.y) || + (this->dyna.actor.shape.rot.z != this->unk_174.z)) { + this->unk_174 = this->dyna.actor.shape.rot; + func_80B7ED54(this); + } + + this->actionFunc(this, globalCtx); + + Actor_SetFocus(&this->dyna.actor, 30.0f); + + if (this->unk_17E != 0) { + if (this->unk_17F > 0) { + this->unk_17F--; + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->unk_17E = 0; + } else if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->unk_17F = 30; + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } + } +} + +void func_80B7F564(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgIkanaBlock* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + AnimatedMat_DrawStep(globalCtx, this->unk_15C, 0); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0xFF, 0xFF, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, gameplay_dangeon_keep_DL_0182A8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h index 112e4ad00..3ad797cba 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h @@ -8,15 +8,20 @@ struct BgIkanaBlock; typedef void (*BgIkanaBlockActionFunc)(struct BgIkanaBlock*, GlobalContext*); typedef struct BgIkanaBlock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ AnimatedMaterial* unk_15C; /* 0x0160 */ BgIkanaBlockActionFunc actionFunc; - /* 0x0164 */ char unk_164[0xC]; + /* 0x0164 */ f32* unk_164; + /* 0x0168 */ f32 unk_168; + /* 0x016C */ f32 unk_16C; /* 0x0170 */ f32 unk_170; - /* 0x0174 */ char unk_174[0x8]; + /* 0x0174 */ Vec3s unk_174; + /* 0x017A */ u8 unk_17A; + /* 0x017B */ s8 unk_17B; /* 0x017C */ u8 unk_17C; - /* 0x017D */ char unk_17D[0x1]; - /* 0x017E */ u8 unk_17E; + /* 0x017D */ s8 unk_17D; + /* 0x017E */ s8 unk_17E; + /* 0x017F */ s8 unk_17F; } BgIkanaBlock; // size = 0x180 extern const ActorInit Bg_Ikana_Block_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c index a3b234392..944ab5828 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c @@ -400,10 +400,10 @@ void func_80B80C88(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { Matrix_StatePush(); Matrix_InsertMatrix(&this->unk_204.unk_04, MTXMODE_APPLY); - Matrix_GetStateTranslation(&ikanaBlock->actor.world.pos); - func_80B80358(&ikanaBlock->actor.world.pos); + Matrix_GetStateTranslation(&ikanaBlock->dyna.actor.world.pos); + func_80B80358(&ikanaBlock->dyna.actor.world.pos); Matrix_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &ikanaBlock->actor.shape.rot, 0); + func_8018219C(&sp3C, &ikanaBlock->dyna.actor.shape.rot, 0); Matrix_StatePop(); } @@ -473,20 +473,21 @@ void func_80B80C88(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { s32 func_80B80F08(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { s32 pad; - BgIkanaBlock* sp40 = (BgIkanaBlock*)this->unk_204.unk_00; + BgIkanaBlock* ikanaBlock = (BgIkanaBlock*)this->unk_204.unk_00; Vec3f sp34; Vec3f sp28; s32 sp24 = false; - if (sp40 != NULL) { + if (ikanaBlock != NULL) { Matrix_StatePush(); Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_InsertTranslation(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); Matrix_GetStateTranslation(&sp34); - Matrix_SetStateRotationAndTranslation(sp40->actor.world.pos.x, sp40->actor.world.pos.y + sp40->unk_170, - sp40->actor.world.pos.z, &sp40->actor.shape.rot); + Matrix_SetStateRotationAndTranslation(ikanaBlock->dyna.actor.world.pos.x, + ikanaBlock->dyna.actor.world.pos.y + ikanaBlock->unk_170, + ikanaBlock->dyna.actor.world.pos.z, &ikanaBlock->dyna.actor.shape.rot); Matrix_GetStateTranslation(&sp28); Matrix_StatePop(); From ad42edb0340ba5e0e2f6e318b58fcb0af61312d1 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis Date: Sun, 17 Apr 2022 20:35:35 +0100 Subject: [PATCH 190/257] Add OoT's `namefixer.py` (#775) * Add OoT's namefixer.py * Absorb actorfixer into namefixer * Merge remote-tracking branch 'upstream/master' into namefixer * Remove problematic functions * Add sanity check * Review --- tools/{actorfixer.py => namefixer.py} | 247 +++++++++++++++++--------- 1 file changed, 159 insertions(+), 88 deletions(-) rename tools/{actorfixer.py => namefixer.py} (80%) diff --git a/tools/actorfixer.py b/tools/namefixer.py similarity index 80% rename from tools/actorfixer.py rename to tools/namefixer.py index 907b83a8b..08621f709 100755 --- a/tools/actorfixer.py +++ b/tools/namefixer.py @@ -1,12 +1,24 @@ #!/usr/bin/env python3 -import argparse, os +import os +import argparse -# There are a few commented out entries that would produce unexpected renames. -# They are left as a comment so people can just grab them. +# all occurrences of keys will be replaced by associated value +simpleReplace = { + # "Math_Rand_":"Rand_", + # "ACTORTYPE":"ACTORCAT", + # "DistToLink":"DistToPlayer", + # "HitItem":"HitInfo", +} -# "old": "new" -animdict = { +# all occurrences of keys will be replaced by associated value, +# if the occurence is the whole word +# for example, if there is a space before and an open parenthesis after, +# like for a function call: ` func_8002E4B4(` +# +# Custom behaviour can be enabled by using a tuple as the value (see +# explanation in replace_single below) +wordReplace = { "Actor_GetSwitchFlag": "Flags_GetSwitch", "atan_flip": "Math_Acot2F", "atans": "Math_Atan2S", @@ -88,25 +100,25 @@ animdict = { "func_801A89A8": "Audio_QueueSeqCmd", "func_8019F1C0": "Audio_PlaySfxAtPos", "func_801A72CC": "Audio_StopSfxByPos", - "SkelAnime_LodDrawLimb(": "SkelAnime_DrawLimbLod(", - "SkelAnime_LodDraw(": "SkelAnime_DrawLod(", - "SkelAnime_LodDrawLimbSV(": "SkelAnime_DrawFlexLimbLod(", - "SkelAnime_LodDrawSV(": "SkelAnime_DrawFlexLod(", - #"SkelAnime_DrawLimb(": "SkelAnime_DrawLimbOpa(", - #"SkelAnime_Draw(": "SkelAnime_DrawOpa(", - "SkelAnime_DrawLimbSV(": "SkelAnime_DrawFlexLimbOpa(", - "SkelAnime_DrawSV(": "SkelAnime_DrawFlexOpa(", - #"SkelAnime_AnimateFrame(": "SkelAnime_GetFrameData(", - "SkelAnime_GetTotalFrames(": "Animation_GetLength(", - "SkelAnime_GetFrameCount(": "Animation_GetLastFrame(", - "SkelAnime_Draw2Limb(": "SkelAnime_DrawLimb(", - "SkelAnime_Draw2(": "SkelAnime_Draw(", - "SkelAnime_DrawLimbSV2(": "SkelAnime_DrawFlexLimb(", - "SkelAnime_DrawSV2(": "SkelAnime_DrawFlex(", + "SkelAnime_LodDrawLimb": "SkelAnime_DrawLimbLod", + "SkelAnime_LodDraw": "SkelAnime_DrawLod", + "SkelAnime_LodDrawLimbSV": "SkelAnime_DrawFlexLimbLod", + "SkelAnime_LodDrawSV": "SkelAnime_DrawFlexLod", + # "SkelAnime_DrawLimb": "SkelAnime_DrawLimbOpa", # A different function is called this now + # "SkelAnime_Draw": "SkelAnime_DrawOpa", # A different function is called this now + "SkelAnime_DrawLimbSV": "SkelAnime_DrawFlexLimbOpa", + "SkelAnime_DrawSV": "SkelAnime_DrawFlexOpa", + # "SkelAnime_AnimateFrame": "SkelAnime_GetFrameData", # A different function is called this now + "SkelAnime_GetTotalFrames": "Animation_GetLength", + "SkelAnime_GetFrameCount": "Animation_GetLastFrame", + "SkelAnime_Draw2Limb": "SkelAnime_DrawLimb", + "SkelAnime_Draw2": "SkelAnime_Draw", + "SkelAnime_DrawLimbSV2": "SkelAnime_DrawFlexLimb", + "SkelAnime_DrawSV2": "SkelAnime_DrawFlex", "func_80134FFC": "SkelAnime_GetFrameData2", "func_801353D4": "Animation_GetLimbCount2", - "SkelAnime_GetTotalFrames2(": "Animation_GetLength2(", - "SkelAnime_GetFrameCount2(": "Animation_GetLastFrame2(", + "SkelAnime_GetTotalFrames2": "Animation_GetLength2", + "SkelAnime_GetFrameCount2": "Animation_GetLastFrame2", "SkelAnime_InterpolateVec3s": "SkelAnime_InterpFrameTable", "SkelAnime_AnimationCtxReset": "AnimationContext_Reset", "func_801358D4": "AnimationContext_SetNextQueue", @@ -125,7 +137,7 @@ animdict = { "SkelAnime_AnimationType4Loaded": "AnimationContext_CopyFalse", "SkelAnime_AnimationType5Loaded": "AnimationContext_MoveActor", "func_80135EE8": "AnimationContext_Update", - "SkelAnime_InitLinkAnimetion(": "SkelAnime_InitLink(", + "SkelAnime_InitLinkAnimetion": "SkelAnime_InitLink", "func_801360A8": "LinkAnimation_SetUpdateFunction", "func_801360E0": "LinkAnimation_Update", "func_80136104": "LinkAnimation_Morph", @@ -158,7 +170,7 @@ animdict = { "func_801370B0": "SkelAnime_LoopPartial", "func_8013713C": "SkelAnime_Once", "SkelAnime_ChangeAnimImpl": "Animation_ChangeImpl", - "SkelAnime_ChangeAnim(": "Animation_Change(", + "SkelAnime_ChangeAnim": "Animation_Change", "SkelAnime_ChangeAnimDefaultStop": "Animation_PlayOnce", "SkelAnime_ChangeAnimTransitionStop": "Animation_MorphToPlayOnce", "SkelAnime_ChangeAnimPlaybackStop": "Animation_PlayOnceSetSpeed", @@ -188,12 +200,12 @@ animdict = { "Actor_SetChestFlag": "Flags_SetTreasure", "Actor_SetAllChestFlag": "Flags_SetAllTreasure", "Actor_GetAllChestFlag": "Flags_GetAllTreasure", - "Actor_GetRoomCleared(": "Flags_GetClear(", - "Actor_SetRoomCleared(": "Flags_SetClear(", - "Actor_UnsetRoomCleared(": "Flags_UnsetClear(", - "Actor_GetRoomClearedTemp(": "Flags_GetClearTemp(", - "Actor_SetRoomClearedTemp(": "Flags_SetClearTemp(", - "Actor_UnsetRoomClearedTemp(": "Flags_UnsetTempClear(", + "Actor_GetRoomCleared": "Flags_GetClear", + "Actor_SetRoomCleared": "Flags_SetClear", + "Actor_UnsetRoomCleared": "Flags_UnsetClear", + "Actor_GetRoomClearedTemp": "Flags_GetClearTemp", + "Actor_SetRoomClearedTemp": "Flags_SetClearTemp", + "Actor_UnsetRoomClearedTemp": "Flags_UnsetTempClear", "Actor_GetCollectibleFlag": "Flags_GetCollectible", "Actor_SetCollectibleFlag": "Flags_SetCollectible", "func_800B8A1C": "Actor_PickUp", @@ -214,7 +226,7 @@ animdict = { "Actor_TitleCardCreate": "TitleCard_InitBossName", "func_800B867C": "Actor_TextboxIsClosing", "func_800BDC5C": "Actor_ChangeAnimationByInfo", - "Actor_ChangeAnimation(": "Actor_ChangeAnimationByInfo(", + "Actor_ChangeAnimation": "Actor_ChangeAnimationByInfo", "func_80152498": "Message_GetState", "func_800B8898": "Actor_GetScreenPos", "Audio_PlayActorSound2": "Actor_PlaySfxAtPos", @@ -222,8 +234,8 @@ animdict = { "Actor_IsFacingPlayerAndWithinRange": "Actor_IsFacingAndNearPlayer", "func_800BC8B8": "Actor_DrawDoorLock", "func_800B86C8": "Actor_ChangeFocus", - "zelda_malloc(": "ZeldaArena_Malloc(", - "zelda_mallocR(": "ZeldaArena_MallocR(", + "zelda_malloc": "ZeldaArena_Malloc", + "zelda_mallocR": "ZeldaArena_MallocR", "zelda_realloc": "ZeldaArena_Realloc", "zelda_free": "ZeldaArena_Free", "zelda_calloc": "ZeldaArena_Calloc", @@ -234,9 +246,9 @@ animdict = { "MainHeap_IsInitialized": "ZeldaArena_IsInitialized", "func_80138300": "Skin_GetLimbPos", "func_8013835C": "Skin_GetVertexPos", - # "BgCheck_RelocateMeshHeader": "CollisionHeader_GetVirtual", - # "BgCheck_AddActorMesh": "DynaPoly_SetBgActor", - # "BgCheck_RemoveActorMesh": "DynaPoly_DeleteBgActor", + "BgCheck_RelocateMeshHeader": "CollisionHeader_GetVirtual", + "BgCheck_AddActorMesh": "DynaPoly_SetBgActor", + "BgCheck_RemoveActorMesh": "DynaPoly_DeleteBgActor", "BgCheck_PolygonLinkedListNodeInit": "SSNode_SetValue", "BgCheck_PolygonLinkedListResetHead": "SSList_SetNull", "BgCheck_ScenePolygonListsNodeInsert": "SSNodeList_SetSSListHead", @@ -265,7 +277,7 @@ animdict = { "BgCheck_GetIsDefaultSpecialScene": "BgCheck_IsSmallMemScene", "BgCheck_GetSpecialSceneMaxMemory": "BgCheck_TryGetCustomMemsize", "BgCheck_CalcSubdivisionSize": "BgCheck_SetSubdivisionDimension", - "BgCheck_Init(": "BgCheck_Allocate(", + "BgCheck_Init": "BgCheck_Allocate", "func_800C3C00": "BgCheck_SetContextFlags", "func_800C3C14": "BgCheck_UnsetContextFlags", "BgCheck_GetActorMeshHeader": "BgCheck_GetCollisionHeader", @@ -379,7 +391,7 @@ animdict = { "func_8017CEF0": "Math3D_TriChkPointParaZIntersect", "func_8017D020": "Math3D_TriChkLineSegParaZIntersect", "Math3D_ColSphereLineSeg": "Math3D_LineVsSph", - "Math3D_ColSphereSphere(": "Math3D_SphVsSph(", + "Math3D_ColSphereSphere": "Math3D_SphVsSph", "func_8017F9C0": "Math3D_XZInSphere", "func_8017FA34": "Math3D_XYInSphere", "func_8017FAA8": "Math3D_YZInSphere", @@ -484,7 +496,7 @@ animdict = { "func_8015E750": "Message_FindCreditsMessage", - # Structs members + # Struct members "skelAnime.unk03": "skelAnime.taper", "skelAnime.animCurrentSeg": "skelAnime.animation", "skelAnime.initialFrame": "skelAnime.startFrame", @@ -505,6 +517,7 @@ animdict = { "actor.minVelocityY": "actor.terminalVelocity", "actor.yDistToWater": "actor.depthInWater", "actor.yDistToPlayer": "actor.playerHeightRel", + "gSaveContext.weekEventReg": "gSaveContext.save.weekEventReg", "gSaveContext.playerForm": "gSaveContext.save.playerForm", "gSaveContext.day": "gSaveContext.save.day", @@ -529,6 +542,11 @@ animdict = { "gSaveContext.permanentSceneFlags": "gSaveContext.save.permanentSceneFlags", "gSaveContext.bomberCode": "gSaveContext.save.bomberCode", "gSaveContext.skullTokenCount": "gSaveContext.save.skullTokenCount", + "gSaveContext.cutscene": "gSaveContext.save.cutscene", + "gSaveContext.health": "gSaveContext.save.playerData.health", + "gSaveContext.unk_1016": "gSaveContext.jinxTimer", + "gSaveContext.unk_3F58": "gSaveContext.sunsSongState", + "player->unk_A87": "player->exchangeItemId", "player->leftHandActor": "player->heldActor", "player->unk_384": "player->getItemId", @@ -547,8 +565,7 @@ animdict = { "globalCtx->envCtx.unk_E6": "globalCtx->envCtx.screenFillColor", "globalCtx->envCtx.unk_C3": "globalCtx->envCtx.lightSettingOverride", "globalCtx->envCtx.unk_DC": "globalCtx->envCtx.lightBlend", - "gSaveContext.unk_1016": "gSaveContext.jinxTimer", - "gSaveContext.unk_3F58": "gSaveContext.sunsSongState", + "globalCtx->msgCtx.unk1202A": "globalCtx->msgCtx.ocarinaMode", "globalCtx->msgCtx.unk1202C": "globalCtx->msgCtx.ocarinaAction", "globalCtx->msgCtx.unk11F22": "globalCtx->msgCtx.msgMode", @@ -572,65 +589,107 @@ animdict = { "CUR_UPG_VALUE_VOID": "GET_CUR_UPG_VALUE", "ICHAIN_F32_DIV1000(minVelocityY,": "ICHAIN_F32_DIV1000(terminalVelocity,", "ICHAIN_F32(minVelocityY,": "ICHAIN_F32(terminalVelocity,", + + # Example of custom behaviour: + # "PLAYER": ("GET_PLAYER(globalCtx)", {"ignore": (-1, '"PLAYER"')}), # ignore "PLAYER" in sSoundBankNames } -def replace_anim(file): - with open(file, 'r', encoding='utf-8') as infile: +# [a-zA-Z0-9_] +def is_word_char(c): + return (c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z') or (c >= '0' and c <= '9') or c == '_' + +def replace_single(file): + with open(file, 'r', encoding = 'utf-8') as infile: srcdata = infile.read() - funcs = list(animdict.keys()) - fixes = 0 - for func in funcs: - newfunc = animdict.get(func) - if(newfunc is None): - print("How did this happen?") - return -1 - if(func in srcdata): - fixes += 1 - print(func) - srcdata = srcdata.replace(func, newfunc) + changesCount = 0 - if(fixes > 0): - print('Changed', fixes,'entr' + ('y' if fixes == 1 else 'ies') + ' in',file) + for old, new in simpleReplace.items(): + # replace `old` with `new` + if old in srcdata: + changesCount += 1 + print(old, "->", new) + srcdata = srcdata.replace(old, new) + + for old, new in wordReplace.items(): + # `new` can be a tuple where the first element is what to replace `old` with, + # and the second element is a dict containing "custom behavior" properties. + if isinstance(new, tuple): + custom_behavior = True + new, custom_behavior_data = new + # The "ignore" data is a tuple where the first element is an offset relative to + # where `old` was found, and the string from that index must differ from the + # tuple's second element for the replacement to be done. + custom_behavior_ignore_data = custom_behavior_data.get("ignore") + custom_behavior_ignore = custom_behavior_ignore_data is not None + if custom_behavior_ignore: + custom_behavior_ignore_offset, custom_behavior_ignore_match = custom_behavior_ignore_data + else: + custom_behavior = False + # replace `old` with `new` if the occurence of `old` is the whole word + oldStartIdx = srcdata.find(old) + if oldStartIdx >= 0: + old_start_as_word = is_word_char(old[0]) + old_end_as_word = is_word_char(old[-1]) + replaceCount = 0 + while oldStartIdx >= 0: + replace = True + if old_start_as_word: + if oldStartIdx == 0: + pass + elif is_word_char(srcdata[oldStartIdx-1]): + replace = False + if old_end_as_word: + oldEndIdx = oldStartIdx + len(old) + if oldEndIdx >= len(srcdata): + pass + elif is_word_char(srcdata[oldEndIdx]): + replace = False + if replace and custom_behavior and custom_behavior_ignore: + if srcdata[oldStartIdx + custom_behavior_ignore_offset:].startswith(custom_behavior_ignore_match): + replace = False + if replace: + srcdata = srcdata[:oldStartIdx] + new + srcdata[oldEndIdx:] + replaceCount += 1 + oldStartIdx = srcdata.find(old, oldStartIdx + len(new)) + if replaceCount > 0: + changesCount += 1 + print(old, "->", new) + + if changesCount > 0: + print('Changed', changesCount, 'entry' if changesCount == 1 else 'entries', 'in', file) with open(file, 'w', encoding = 'utf-8', newline = '\n') as outfile: outfile.write(srcdata) - return 1 -def replace_anim_all(repo): - for subdir, dirs, files in os.walk(repo + os.sep + 'src'): +def replace_all(repo): + for subdir, dirs, files in os.walk(os.path.join(repo,'src')): for filename in files: - if(filename.endswith('.c')): - file = subdir + os.sep + filename - replace_anim(file) + if filename.endswith('.c') or filename.endswith('.h'): + file = os.path.join(subdir,filename) + replace_single(file) - for subdir, dirs, files in os.walk(repo + os.sep + 'asm'): + for subdir, dirs, files in os.walk(os.path.join(repo,'asm')): for filename in files: - if(filename.endswith('.s')): - file = subdir + os.sep + filename - replace_anim(file) + if filename.endswith('.s'): + file = os.path.join(subdir,filename) + replace_single(file) - for subdir, dirs, files in os.walk(repo + os.sep + 'data'): + for subdir, dirs, files in os.walk(os.path.join(repo,'data')): for filename in files: - if(filename.endswith('.s')): - file = subdir + os.sep + filename - replace_anim(file) + if filename.endswith('.s'): + file = os.path.join(subdir,filename) + replace_single(file) - for subdir, dirs, files in os.walk(repo + os.sep + 'docs'): + for subdir, dirs, files in os.walk(os.path.join(repo,'docs')): for filename in files: - if(filename.endswith('.md')): - file = subdir + os.sep + filename - replace_anim(file) + if filename.endswith('.md'): + file = os.path.join(subdir,filename) + replace_single(file) - for subdir, dirs, files in os.walk(repo + os.sep + 'tools' + os.sep + 'sizes'): - for filename in files: - if(filename.endswith('.csv')): - file = subdir + os.sep + filename - replace_anim(file) - return 1 def dictSanityCheck(): - keys = animdict.keys() - values = animdict.values() + keys = wordReplace.keys() + values = wordReplace.values() for k in keys: if k in values: print(f"Key '{k}' found in values") @@ -638,15 +697,27 @@ def dictSanityCheck(): print(f"Fix this by removing said key from the dictionary") exit(-1) -if __name__ == "__main__": - parser = argparse.ArgumentParser(description='Update to the new animation names') - parser.add_argument('file', help="source file to be processed. use . to process the whole repo", default = None) + keys = simpleReplace.keys() + values = {*wordReplace.values(), *simpleReplace.values()} + for k in keys: + for value in values: + if k in value: + print(f"Key '{k}' found in values") + print(f"This would produce unintended renames") + print(f"Fix this by removing said key from the dictionary") + exit(-1) +def main(): + parser = argparse.ArgumentParser(description='Apply function renames to a file') + parser.add_argument('file', help="source file to be processed. use . to process the whole repo") args = parser.parse_args() dictSanityCheck() - if(args.file == '.'): - replace_anim_all(os.curdir) + if args.file == '.': + replace_all(os.curdir) else: - replace_anim(args.file) + replace_single(args.file) + +if __name__ == "__main__": + main() From 776edea91a2c0598881712c7639abac250e9f5f7 Mon Sep 17 00:00:00 2001 From: louist103 <35883445+louist103@users.noreply.github.com> Date: Thu, 21 Apr 2022 18:56:34 -0400 Subject: [PATCH 191/257] git subrepo pull --force tools/ZAPD (#785) subrepo: subdir: "tools/ZAPD" merged: "87cb648b" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "87cb648b" git-subrepo: version: "0.4.3" origin: "???" commit: "???" --- tools/ZAPD/.gitrepo | 4 +- tools/ZAPD/ExporterTest/CollisionExporter.cpp | 8 +- tools/ZAPD/ExporterTest/ExporterTest.vcxproj | 318 ++--- tools/ZAPD/ZAPD/ZAPD.vcxproj | 699 ++++++----- tools/ZAPD/ZAPD/ZAPD.vcxproj.filters | 1118 +++++++++-------- tools/ZAPD/ZAPD/ZArray.cpp | 1 + tools/ZAPD/ZAPD/ZCollision.cpp | 31 +- tools/ZAPD/ZAPD/ZCollision.h | 5 +- tools/ZAPD/ZAPD/ZCollisionPoly.cpp | 76 ++ tools/ZAPD/ZAPD/ZCollisionPoly.h | 30 + tools/ZAPD/ZAPD/ZResource.cpp | 5 + tools/ZAPD/ZAPD/ZResource.h | 3 + tools/ZAPD/ZAPDUtils/Utils/BitConverter.h | 4 + tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj | 334 ++--- 14 files changed, 1389 insertions(+), 1247 deletions(-) create mode 100644 tools/ZAPD/ZAPD/ZCollisionPoly.cpp create mode 100644 tools/ZAPD/ZAPD/ZCollisionPoly.h diff --git a/tools/ZAPD/.gitrepo b/tools/ZAPD/.gitrepo index 5d67a3762..ddbb4547d 100644 --- a/tools/ZAPD/.gitrepo +++ b/tools/ZAPD/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/zeldaret/ZAPD.git branch = master - commit = efae567d3917afa341bd843ba185b3bd66d57429 - parent = 22c6551083172f5c506aecf8c31ad761afbbd658 + commit = 87cb648b4311d20673452111edaf4d38a5290c28 + parent = 06412c070f0240eacfaa860eee99b9c723245b7f method = merge cmdver = 0.4.3 diff --git a/tools/ZAPD/ExporterTest/CollisionExporter.cpp b/tools/ZAPD/ExporterTest/CollisionExporter.cpp index e00f5c1b0..87b9a05a2 100644 --- a/tools/ZAPD/ExporterTest/CollisionExporter.cpp +++ b/tools/ZAPD/ExporterTest/CollisionExporter.cpp @@ -50,10 +50,10 @@ void ExporterExample_Collision::Save(ZResource* res, [[maybe_unused]] fs::path o writer->Write(col->polygons[i].vtxA); writer->Write(col->polygons[i].vtxB); writer->Write(col->polygons[i].vtxC); - writer->Write(col->polygons[i].a); - writer->Write(col->polygons[i].b); - writer->Write(col->polygons[i].c); - writer->Write(col->polygons[i].d); + writer->Write(col->polygons[i].normX); + writer->Write(col->polygons[i].normY); + writer->Write(col->polygons[i].normZ); + writer->Write(col->polygons[i].dist); } writer->Seek(col->polyTypeDefSegmentOffset, SeekOffsetType::Start); diff --git a/tools/ZAPD/ExporterTest/ExporterTest.vcxproj b/tools/ZAPD/ExporterTest/ExporterTest.vcxproj index 839d45102..5bdfc7aa6 100644 --- a/tools/ZAPD/ExporterTest/ExporterTest.vcxproj +++ b/tools/ZAPD/ExporterTest/ExporterTest.vcxproj @@ -1,160 +1,160 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {65608eb0-1a47-45ad-ab66-192fb64c762c} - ExporterTest - 10.0 - ExporterExample - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - StaticLibrary - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - $(ProjectDir)..\ZAPD\;$(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - stdcpp17 - stdc11 - MultiThreadedDebug - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {65608eb0-1a47-45ad-ab66-192fb64c762c} + ExporterTest + 10.0 + ExporterExample + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + StaticLibrary + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + $(ProjectDir)..\ZAPD\;$(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + stdcpp17 + stdc11 + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZAPD.vcxproj b/tools/ZAPD/ZAPD/ZAPD.vcxproj index 431abb73b..f3bb35a3f 100644 --- a/tools/ZAPD/ZAPD/ZAPD.vcxproj +++ b/tools/ZAPD/ZAPD/ZAPD.vcxproj @@ -1,343 +1,362 @@ - - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36} - ZAPD - 10.0 - ZAPD - - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - $(OutDir);$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\packages\libpng-v142.1.6.37.2\build\native\lib\x64\v142\Debug\;$(LibraryPath) - $(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) - - - $(IncludePath) - - - $(SolutionDir)ZAPD\lib\tinyxml2;$(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)ZAPD\lib\elfio;$(SolutionDir)ZAPD\lib\stb;$(ProjectDir);$(IncludePath) - $(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)x64\Debug;$(SolutionDir)packages\libpng.1.6.28.1\build\native\lib\x64\v140\dynamic\Debug;$(LibraryPath) - - - - Level3 - Disabled - true - true - stdcpp17 - stdc11 - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - - true - - - - - Level3 - Disabled - true - true - stdcpp17 - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - EnableFastChecks - stdc11 - MultiThreadedDebug - - - true - ZAPDUtils.lib;/WHOLEARCHIVE:ExporterExample.lib;%(AdditionalDependencies) - false - - + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36} + ZAPD + 10.0 + ZAPD + + + + Application + true + v143 + MultiByte + + + Application + false + v143 + true + MultiByte + + + Application + true + v143 + MultiByte + + + Application + false + v143 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + $(OutDir);$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\packages\libpng-v142.1.6.37.2\build\native\lib\x64\v142\Debug\;$(LibraryPath) + $(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) + + + $(IncludePath) + + + $(SolutionDir)ZAPD\lib\tinyxml2;$(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)ZAPD\lib\elfio;$(SolutionDir)ZAPD\lib\stb;$(ProjectDir);$(IncludePath) + $(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)x64\Debug;$(SolutionDir)packages\libpng.1.6.28.1\build\native\lib\x64\v140\dynamic\Debug;$(LibraryPath) + + + + Level3 + Disabled + true + true + stdcpp17 + stdc11 + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + + cd .. mkdir build\ZAPD -python3 ZAPD/genbuildinfo.py - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - stdcpplatest - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - + python ZAPD/genbuildinfo.py + + + + + Level3 + Disabled + true + true + stdcpp17 + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + EnableFastChecks + stdc11 + MultiThreadedDebug + + + true + ZAPDUtils.lib;/WHOLEARCHIVE:ExporterExample.lib;%(AdditionalDependencies) + false + + + cd .. +mkdir build\ZAPD + python ZAPD/genbuildinfo.py + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + + + cd .. +mkdir build\ZAPD + python ZAPD/genbuildinfo.py + + + + + Level3 + MaxSpeed + true + true + true + true + stdcpplatest + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + true + + + cd .. +mkdir build\ZAPD + python ZAPD/genbuildinfo.py + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters b/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters index b8a7daaac..4de236fad 100644 --- a/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters +++ b/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters @@ -1,554 +1,566 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {02148456-5068-4613-8478-f10addc58e70} - - - {bcab3136-95ba-4839-833c-43d78ad6e335} - - - {dc06ed84-f6fe-4277-80f3-d62bd5cdbb98} - - - {6049c045-bc38-4221-b29e-ca6d4d8af4aa} - - - {490e3a08-047b-48d3-ab53-3a860a3b92aa} - - - {26c06845-8e8e-4b79-ad18-07c4f9c0f801} - - - {d45c420d-2378-47ac-92c5-80db9475c195} - - - {03cc56a2-e0e8-4167-80a0-98fb900a959a} - - - {73db0879-6df8-4f6a-8cc2-a1f836e9e796} - - - {be9a5be0-ec6a-4200-8e39-bb58c7da7aa8} - - - {7ee79d97-c6a8-4e82-93ef-37981f4d7838} - - - {85600275-99fe-491d-8189-bcc3dc1a8903} - - - {ba9990b0-1082-48bb-874c-6108534b5455} - - - {ce9d91b0-ba20-4296-bc2d-8630965bb392} - - - {730beb67-6d59-4849-9d9b-702c4a565fc0} - - - - - Source Files - - - Source Files\Z64\ZRoom - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files - - - Source Files\Z64 - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Libraries\libgfxd - - - Source Files\Z64 - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files\Z64\ZRoom\Commands - - - Source Files\Z64 - - - Source Files - - - Source Files - - - Source Files\Z64 - - - Source Files - - - Source Files\Z64 - - - Source Files\Z64 - - - Source Files - - - Source Files\Z64 - - - Source Files - - - - - Header Files\Z64\ZRoom - - - Header Files\Z64\ZRoom - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files\Libraries\elfio - - - Header Files - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Libraries - - - Header Files\Libraries - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files\Libraries\libgfxd - - - Header Files\Libraries\libgfxd - - - Header Files\Libraries\libgfxd - - - Header Files\Z64 - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64\ZRoom\Commands - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64\ZRoom\Commands - - - Header Files - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files\Z64 - - - Header Files - - - - - Resource Files - - - any\any - - - NuGet - - - - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {02148456-5068-4613-8478-f10addc58e70} + + + {bcab3136-95ba-4839-833c-43d78ad6e335} + + + {dc06ed84-f6fe-4277-80f3-d62bd5cdbb98} + + + {6049c045-bc38-4221-b29e-ca6d4d8af4aa} + + + {490e3a08-047b-48d3-ab53-3a860a3b92aa} + + + {26c06845-8e8e-4b79-ad18-07c4f9c0f801} + + + {d45c420d-2378-47ac-92c5-80db9475c195} + + + {03cc56a2-e0e8-4167-80a0-98fb900a959a} + + + {73db0879-6df8-4f6a-8cc2-a1f836e9e796} + + + {be9a5be0-ec6a-4200-8e39-bb58c7da7aa8} + + + {7ee79d97-c6a8-4e82-93ef-37981f4d7838} + + + {85600275-99fe-491d-8189-bcc3dc1a8903} + + + {ba9990b0-1082-48bb-874c-6108534b5455} + + + {ce9d91b0-ba20-4296-bc2d-8630965bb392} + + + {730beb67-6d59-4849-9d9b-702c4a565fc0} + + + + + Source Files + + + Source Files\Z64\ZRoom + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Z64 + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files + + + Source Files + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + + + Header Files\Z64\ZRoom + + + Header Files\Z64\ZRoom + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Libraries + + + Header Files\Libraries + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Libraries\libgfxd + + + Header Files\Libraries\libgfxd + + + Header Files\Libraries\libgfxd + + + Header Files\Z64 + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64 + + + Header Files\Z64\ZRoom\Commands + + + Header Files + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + + + Resource Files + + + any\any + + + NuGet + + + + + \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZArray.cpp b/tools/ZAPD/ZAPD/ZArray.cpp index b6d9e50e5..d4f55d6c8 100644 --- a/tools/ZAPD/ZAPD/ZArray.cpp +++ b/tools/ZAPD/ZAPD/ZArray.cpp @@ -106,6 +106,7 @@ std::string ZArray::GetBodySourceCode() const case ZResourceType::Pointer: case ZResourceType::Scalar: case ZResourceType::Vertex: + case ZResourceType::CollisionPoly: output += resList.at(i)->GetBodySourceCode(); break; diff --git a/tools/ZAPD/ZAPD/ZCollision.cpp b/tools/ZAPD/ZAPD/ZCollision.cpp index 0b04ca5c1..992332db7 100644 --- a/tools/ZAPD/ZAPD/ZCollision.cpp +++ b/tools/ZAPD/ZAPD/ZCollision.cpp @@ -61,18 +61,22 @@ void ZCollisionHeader::ParseRawData() currentPtr += vec.GetRawDataSize(); vertices.push_back(vec); } - + for (uint16_t i = 0; i < numPolygons; i++) - polygons.push_back(PolygonEntry(rawData, polySegmentOffset + (i * 16))); + { + ZCollisionPoly poly(parent); + poly.SetRawDataIndex(polySegmentOffset + (i * 16)); + poly.ParseRawData(); + polygons.push_back(poly); + } uint16_t highestPolyType = 0; - for (PolygonEntry poly : polygons) + for (ZCollisionPoly poly : polygons) { if (poly.type > highestPolyType) highestPolyType = poly.type; } - for (uint16_t i = 0; i < highestPolyType + 1; i++) polygonTypes.push_back( BitConverter::ToUInt64BE(rawData, polyTypeDefSegmentOffset + (i * 8))); @@ -149,16 +153,13 @@ void ZCollisionHeader::DeclareReferences(const std::string& prefix) for (size_t i = 0; i < polygons.size(); i++) { - declaration += StringHelper::Sprintf( - "\t{ 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X },", - polygons[i].type, polygons[i].vtxA, polygons[i].vtxB, polygons[i].vtxC, - polygons[i].a, polygons[i].b, polygons[i].c, polygons[i].d); + declaration += StringHelper::Sprintf("\t%s,", polygons[i].GetBodySourceCode().c_str()); if (i + 1 < polygons.size()) declaration += "\n"; } parent->AddDeclarationArray( - polySegmentOffset, DeclarationAlignment::Align4, polygons.size() * 16, "CollisionPoly", + polySegmentOffset, DeclarationAlignment::Align4, polygons.size() * 16, polygons[0].GetSourceTypeName().c_str(), StringHelper::Sprintf("%sPolygons", auxName.c_str()), polygons.size(), declaration); } @@ -254,18 +255,6 @@ size_t ZCollisionHeader::GetRawDataSize() const return 44; } -PolygonEntry::PolygonEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - vtxA = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - vtxB = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - vtxC = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - a = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); - b = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); - c = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12); - d = BitConverter::ToUInt16BE(rawData, rawDataIndex + 14); -} - WaterBoxHeader::WaterBoxHeader(const std::vector& rawData, uint32_t rawDataIndex) { xMin = BitConverter::ToInt16BE(rawData, rawDataIndex + 0); diff --git a/tools/ZAPD/ZAPD/ZCollision.h b/tools/ZAPD/ZAPD/ZCollision.h index 222fd25f9..7481a8526 100644 --- a/tools/ZAPD/ZAPD/ZCollision.h +++ b/tools/ZAPD/ZAPD/ZCollision.h @@ -4,7 +4,9 @@ #include "ZResource.h" #include "ZRoom/ZRoom.h" #include "ZVector.h" +#include "ZCollisionPoly.h" +#if 0 class PolygonEntry { public: @@ -14,6 +16,7 @@ public: PolygonEntry(const std::vector& rawData, uint32_t rawDataIndex); }; +#endif class WaterBoxHeader { @@ -78,7 +81,7 @@ public: waterBoxSegmentOffset; std::vector vertices; - std::vector polygons; + std::vector polygons; std::vector polygonTypes; std::vector waterBoxes; CameraDataList* camData = nullptr; diff --git a/tools/ZAPD/ZAPD/ZCollisionPoly.cpp b/tools/ZAPD/ZAPD/ZCollisionPoly.cpp new file mode 100644 index 000000000..eb2c14ab9 --- /dev/null +++ b/tools/ZAPD/ZAPD/ZCollisionPoly.cpp @@ -0,0 +1,76 @@ +#include "ZCollisionPoly.h" + +#include "Globals.h" +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +REGISTER_ZFILENODE(CollisionPoly, ZCollisionPoly); + +ZCollisionPoly::ZCollisionPoly(ZFile* nParent) : ZResource(nParent) +{ +} + +ZCollisionPoly::~ZCollisionPoly() +{ +} + +void ZCollisionPoly::ParseRawData() +{ + const auto& rawData = parent->GetRawData(); + type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + + vtxA = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + vtxB = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + vtxC = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); + + normX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); + normY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); + normZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12); + + dist = BitConverter::ToUInt16BE(rawData, rawDataIndex + 14); +} + +void ZCollisionPoly::DeclareReferences(const std::string& prefix) +{ + std::string declaration; + std::string auxName = name; + + if (name == "") + auxName = GetDefaultName(prefix); + + parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4,GetRawDataSize(), GetSourceTypeName(), name.c_str(),GetBodySourceCode()); +} + +std::string ZCollisionPoly::GetBodySourceCode() const +{ + std::string declaration; + + declaration += StringHelper::Sprintf("{0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X}", type, vtxA, vtxB, vtxC, normX, normY, normZ, dist); + return declaration; +} + +std::string ZCollisionPoly::GetDefaultName(const std::string& prefix) const +{ + return StringHelper::Sprintf("%sCollisionPoly_%06X", prefix.c_str(), rawDataIndex); +} + + +ZResourceType ZCollisionPoly::GetResourceType() const +{ + return ZResourceType::CollisionPoly; +} + +size_t ZCollisionPoly::GetRawDataSize() const +{ + return 16; +} + +std::string ZCollisionPoly::GetSourceTypeName() const +{ + return "CollisionPoly"; +} + +bool ZCollisionPoly::DoesSupportArray() const +{ + return true; +} \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZCollisionPoly.h b/tools/ZAPD/ZAPD/ZCollisionPoly.h new file mode 100644 index 000000000..9596d2253 --- /dev/null +++ b/tools/ZAPD/ZAPD/ZCollisionPoly.h @@ -0,0 +1,30 @@ +#pragma once + +#include "ZFile.h" +#include "ZResource.h" + + +class ZCollisionPoly : public ZResource +{ +public: + uint16_t type; + uint16_t vtxA, vtxB, vtxC; + uint16_t normX, normY, normZ; + uint16_t dist; + + ZCollisionPoly(ZFile* nParent); + ~ZCollisionPoly(); + + void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; + + std::string GetBodySourceCode() const override; + std::string GetDefaultName(const std::string& prefix) const override; + + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; + + bool DoesSupportArray() const override; + + size_t GetRawDataSize() const override; +}; \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZResource.cpp b/tools/ZAPD/ZAPD/ZResource.cpp index 2dfe6d5ea..8825cc97b 100644 --- a/tools/ZAPD/ZAPD/ZResource.cpp +++ b/tools/ZAPD/ZAPD/ZResource.cpp @@ -247,6 +247,11 @@ offset_t ZResource::GetRawDataIndex() const return rawDataIndex; } +void ZResource::SetRawDataIndex(offset_t nRawDataIndex) +{ + rawDataIndex = nRawDataIndex; +} + std::string ZResource::GetBodySourceCode() const { return "ERROR"; diff --git a/tools/ZAPD/ZAPD/ZResource.h b/tools/ZAPD/ZAPD/ZResource.h index c65c3c31b..35984679c 100644 --- a/tools/ZAPD/ZAPD/ZResource.h +++ b/tools/ZAPD/ZAPD/ZResource.h @@ -31,6 +31,7 @@ enum class ZResourceType Background, Blob, CollisionHeader, + CollisionPoly, Cutscene, DisplayList, Limb, @@ -150,6 +151,8 @@ public: [[nodiscard]] const std::string& GetOutName() const; void SetOutName(const std::string& nName); [[nodiscard]] offset_t GetRawDataIndex() const; + void SetRawDataIndex(offset_t nRawDataIndex); + /** * The size of the current struct being extracted, not counting data referenced by it */ diff --git a/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h b/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h index ac82c24ca..646fa1274 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h +++ b/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h @@ -11,6 +11,10 @@ #define ALIGN16(val) (((val) + 0xF) & ~0xF) #define ALIGN64(val) (((val) + 0x3F) & ~0x3F) +#ifdef _MSC_VER +#define __PRETTY_FUNCTION__ __FUNCSIG__ +#endif + class BitConverter { public: diff --git a/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj b/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj index 0a09666e0..c0ef260dd 100644 --- a/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj +++ b/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj @@ -1,168 +1,168 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {a2e01c3e-d647-45d1-9788-043debc1a908} - ZAPDUtils - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - StaticLibrary - true - v142 - MultiByte - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreadedDebug - Default - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {a2e01c3e-d647-45d1-9788-043debc1a908} + ZAPDUtils + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + StaticLibrary + true + v143 + MultiByte + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDebug + Default + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From c7753f43b0f246a0298eff8b8dc5e195b33f3b39 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 21 Apr 2022 17:30:29 -0600 Subject: [PATCH 192/257] Obj_Dora (#779) * Initial implementation of Obj_Dora * Final function and documentation for Obj Dora * Implemented review feedback * Moved enums inside dora c file, renamed temp to timeHalfHour * Cleaning, renaming, moving and converted float to easily searchable value --- assets/xml/objects/object_dora.xml | 27 +- spec | 3 +- src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c | 351 ++++++++++++++---- src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h | 11 +- .../ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c | 10 +- undefined_syms.txt | 5 - 6 files changed, 315 insertions(+), 92 deletions(-) diff --git a/assets/xml/objects/object_dora.xml b/assets/xml/objects/object_dora.xml index 6a0972666..ab4b09cf7 100644 --- a/assets/xml/objects/object_dora.xml +++ b/assets/xml/objects/object_dora.xml @@ -1,17 +1,18 @@  + - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/spec b/spec index 958bb80f9..dfac00aee 100644 --- a/spec +++ b/spec @@ -4059,8 +4059,7 @@ beginseg name "ovl_Obj_Dora" compress include "build/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.o" - include "build/data/ovl_Obj_Dora/ovl_Obj_Dora.data.o" - include "build/data/ovl_Obj_Dora/ovl_Obj_Dora.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Dora/ovl_Obj_Dora_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c index 1d77cc257..a1d149f3d 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c @@ -5,6 +5,7 @@ */ #include "z_obj_dora.h" +#include "assets/objects/object_dora/object_dora.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,25 @@ void ObjDora_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjDora_Update(Actor* thisx, GlobalContext* globalCtx); void ObjDora_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void ObjDora_SetupWait(ObjDora* this); +void ObjDora_Wait(ObjDora* this, GlobalContext* globalCtx); +void ObjDora_SetupMoveGong(ObjDora* this); +void ObjDora_MoveGong(ObjDora* this, GlobalContext* globalCtx); +s32 ObjDora_IsHalfHour(u16 time); +void ObjDora_UpdateCollision(ObjDora* this, GlobalContext* globalCtx); + +typedef enum { + /* 0x0 */ DORA_HIT_NONE, + /* 0x1 */ DORA_HIT_LIGHT, + /* 0x2 */ DORA_HIT_STRONG +} ObjDoraHitStrength; + +typedef enum { + /* 0x0 */ DORA_DMGEFF_NONE, + /* 0xE */ DORA_DMGEFF_STRONG = 0xE, + /* 0xF */ DORA_DMGEFF_LIGHT +} ObjDoraDamageEffect; + const ActorInit Obj_Dora_InitVars = { ACTOR_OBJ_DORA, ACTORCAT_NPC, @@ -28,104 +47,306 @@ const ActorInit Obj_Dora_InitVars = { (ActorFunc)ObjDora_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[6] = { -static ColliderTrisElementInit D_80B61310[6] = { +static ColliderTrisElementInit sTrisElementsInit[6] = { { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x00100000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x00100000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, -35.0f, 0.0f }, { 260.0f, -185.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x00100000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x00100000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 260.0f, -185.0f, 0.0f }, { 260.0f, -485.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 260.0f, -485.0f, 0.0f }, { 0.0f, -635.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, -635.0f, 0.0f }, { -260.0f, -485.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -260.0f, -485.0f, 0.0f }, { -260.0f, -185.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -260.0f, -185.0f, 0.0f }, { 0.0f, -35.0f, 0.0f }, { 0.0f, -335.0f, 0.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B61478 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_TRIS, }, - 6, D_80B61310, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_TRIS, + }, + 6, + sTrisElementsInit, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B61488 = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(2, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(0, 0x0), - /* Zora boomerang */ DMG_ENTRY(0, 0xF), - /* Normal arrow */ DMG_ENTRY(0, 0xF), - /* UNK_DMG_0x06 */ DMG_ENTRY(2, 0xF), - /* Hookshot */ DMG_ENTRY(0, 0xF), - /* Goron punch */ DMG_ENTRY(2, 0xE), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(1, 0xF), - /* Fire arrow */ DMG_ENTRY(0, 0xF), - /* Ice arrow */ DMG_ENTRY(0, 0xF), - /* Light arrow */ DMG_ENTRY(0, 0xF), - /* Goron spikes */ DMG_ENTRY(1, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0xF), - /* Deku bubble */ DMG_ENTRY(0, 0x0), - /* Deku launch */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0xF), - /* Zora punch */ DMG_ENTRY(0, 0xF), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(0, 0x0), +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(2, DORA_DMGEFF_LIGHT), + /* Horse trample */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Normal arrow */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* UNK_DMG_0x06 */ DMG_ENTRY(2, DORA_DMGEFF_LIGHT), + /* Hookshot */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Goron punch */ DMG_ENTRY(2, DORA_DMGEFF_STRONG), + /* Sword */ DMG_ENTRY(1, DORA_DMGEFF_LIGHT), + /* Goron pound */ DMG_ENTRY(1, DORA_DMGEFF_LIGHT), + /* Fire arrow */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Ice arrow */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Light arrow */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Goron spikes */ DMG_ENTRY(1, DORA_DMGEFF_LIGHT), + /* Deku spin */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Deku bubble */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Normal shield */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, DORA_DMGEFF_LIGHT), + /* Zora punch */ DMG_ENTRY(0, DORA_DMGEFF_LIGHT), + /* Spin attack */ DMG_ENTRY(1, DORA_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, DORA_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(0, DORA_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B614A8 = { 8, 0, 0, 0, MASS_HEAVY }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; -#endif +void ObjDora_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjDora* this = THIS; + s32 i; + s32 j; + Vec3f vtx[3]; + s32 buf = 0; + s32 buff2 = 0; -extern ColliderTrisElementInit D_80B61310[6]; -extern ColliderTrisInit D_80B61478; -extern DamageTable D_80B61488; -extern CollisionCheckInfoInit2 D_80B614A8; + Actor_SetScale(&this->actor, 0.1f); + ActorShape_Init(&this->actor.shape, 0.0f, &ActorShadow_DrawCircle, 36.0f); -extern UNK_TYPE D_06004160; + this->gongRotation.x = 0; + this->gongRotation.z = 0; + this->gongAngle.x = 0; + this->gongAngle.z = 0; + this->lastGongHitType = DORA_HIT_NONE; + this->rupeeDropTimer = 0; + this->collisionCooldownTimer = 0; + this->unk3AA = 0; + this->gongForce.x = 0.0f; + this->gongForce.y = 0.0f; + this->gongForce.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/ObjDora_Init.s") + Collider_InitTris(globalCtx, &this->colliderTris); + Collider_SetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTrisElements); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/ObjDora_Destroy.s") + Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60C9C.s") + for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { + for (j = 0; j < ARRAY_COUNT(vtx); j++) { + Matrix_MultiplyVector3fByState(&sTrisElementsInit[i].dim.vtx[j], &vtx[j]); + } + Collider_SetTrisVertices(&this->colliderTris, i, &vtx[0], &vtx[1], &vtx[2]); + } + ObjDora_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60CB0.s") +void ObjDora_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjDora* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60CC0.s") + Collider_DestroyTris(globalCtx, &this->colliderTris); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60D34.s") +void ObjDora_SetupWait(ObjDora* this) { + this->actionFunc = ObjDora_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60E54.s") +void ObjDora_Wait(ObjDora* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/func_80B60EE8.s") +void ObjDora_SetupMoveGong(ObjDora* this) { + if (this->lastGongHitType == DORA_HIT_LIGHT) { + this->gongForce.x = 2.0f; + this->gongForce.y = 5461.0f; + this->gongForce.z = 1820.0f; + } else { + this->gongForce.x = 4.0f; + this->gongForce.y = 12743.0f; + this->gongForce.z = 5461.0f; + } + this->gongAngle.x = 0; + this->gongAngle.z = 0; + this->actionFunc = ObjDora_MoveGong; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/ObjDora_Update.s") +void ObjDora_MoveGong(ObjDora* this, GlobalContext* globalCtx) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dora/ObjDora_Draw.s") + if ((this->gongForce.y < 182.0f) && (this->gongForce.z < 182.0f)) { + this->lastGongHitType = DORA_HIT_LIGHT; + ObjDora_SetupWait(this); + } + + Math_SmoothStepToF(&this->gongForce.x, 0, 0.2f, 0.2f, 0.1f); + Math_SmoothStepToF(&this->gongForce.y, 0, 0.5f, 54.0f, 18.0f); + Math_SmoothStepToF(&this->gongForce.z, 0, 0.5f, 54.0f, 18.0f); + this->gongAngle.x += 0x1555; + this->gongAngle.z += 0x238E; + this->gongRotation.x = Math_SinS(this->gongAngle.x) * this->gongForce.y; + this->gongRotation.z = Math_SinS(this->gongAngle.z) * this->gongForce.z; +} + +s32 ObjDora_IsHalfHour(u16 time) { + f32 timeHalfHour = time; + + timeHalfHour -= (CLOCK_TIME_F(0, 30) * (s32)(time / CLOCK_TIME_F(0, 30))); + if ((timeHalfHour < CLOCK_TIME_F(0, 1)) || (CLOCK_TIME_F(0, 29) < timeHalfHour)) { + return true; + } + + return false; +} + +void ObjDora_UpdateCollision(ObjDora* this, GlobalContext* globalCtx) { + Actor* itemDrop; + u16 time; + + if (this->colliderTris.base.acFlags & AC_HIT) { + time = gSaveContext.save.time; + this->colliderTris.base.acFlags &= ~AC_HIT; + this->collisionCooldownTimer = 5; + + switch (this->actor.colChkInfo.damageEffect) { + case DORA_DMGEFF_STRONG: + case DORA_DMGEFF_LIGHT: + if (this->actor.colChkInfo.damageEffect == DORA_DMGEFF_LIGHT) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DORA_S); + this->lastGongHitType = DORA_HIT_LIGHT; + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DORA_L); + this->lastGongHitType = DORA_HIT_STRONG; + } + + func_800BC848(&this->actor, globalCtx, 5, 10); + ObjDora_SetupMoveGong(this); + + if ((ObjDora_IsHalfHour(time) == true) && (this->rupeeDropTimer == 0)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + itemDrop = Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_BLUE); + itemDrop->world.rot.y = this->actor.world.rot.y; + itemDrop->world.rot.y += (s32)(Rand_Centered() * 90.0f * (0x10000 / 360.0f)); + itemDrop->velocity.y = 5.0f; + itemDrop->gravity = -1.0f; + this->rupeeDropTimer = 40; + } + break; + } + } + + if (this->rupeeDropTimer > 0) { + this->rupeeDropTimer--; + } + + if (this->collisionCooldownTimer > 0) { + this->collisionCooldownTimer--; + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + } +} + +void ObjDora_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjDora* this = THIS; + + this->actionFunc(this, globalCtx); + ObjDora_UpdateCollision(this, globalCtx); +} + +void ObjDora_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f position = { 0.0f, -61.5f, 0.0f }; + ObjDora* this = THIS; + f32 gongForceX; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->actionFunc == ObjDora_MoveGong) { + gongForceX = this->gongForce.x; + if ((globalCtx->state.frames % 2) != 0) { + gongForceX *= -1.0f; + } + + Matrix_StatePush(); + Matrix_InsertXRotation_s(this->gongRotation.x, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &gDoraGongDL); + + Matrix_InsertTranslation(position.x, position.y + gongForceX, position.z + gongForceX, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->gongRotation.z - this->gongRotation.x, MTXMODE_APPLY); + Matrix_InsertTranslation(-position.x, -position.y, -position.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &gDoraChainDL); + + Matrix_StatePop(); + } else { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &gDoraChainDL); + gSPDisplayList(POLY_OPA_DISP++, &gDoraGongDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h index a40405b34..a2dbbea16 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h @@ -9,9 +9,16 @@ typedef void (*ObjDoraActionFunc)(struct ObjDora*, GlobalContext*); typedef struct ObjDora { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x248]; + /* 0x0144 */ ColliderTris colliderTris; + /* 0x0164 */ ColliderTrisElement colliderTrisElements[6]; /* 0x038C */ ObjDoraActionFunc actionFunc; - /* 0x0390 */ char unk_390[0x1C]; + /* 0x0390 */ Vec3f gongForce; + /* 0x039C */ Vec2s gongAngle; + /* 0x03A0 */ s16 lastGongHitType; + /* 0x03A2 */ Vec2s gongRotation; // gongAngle * gongForce. Used in ObjDora_Draw. + /* 0x03A6 */ s16 rupeeDropTimer; + /* 0x03A8 */ s16 collisionCooldownTimer; + /* 0x03AA */ s16 unk3AA; // Set but not used } ObjDora; // size = 0x3AC extern const ActorInit Obj_Dora_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c index 6cf8e0751..d6a2df4cf 100644 --- a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c +++ b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c @@ -45,10 +45,10 @@ Vec3f D_80B6669C = { 150.0f, 425.0f, 40.0f }; Vec3f D_80B666A8 = { 0.0f, 140.0f, 40.0f }; Vec3f D_80B666B4 = { 0.0f, 565.0f, 40.0f }; -Gfx* D_80B666C0 = object_dora_DL_002080; -Gfx* D_80B666C4 = object_dora_DL_002180; -Gfx* D_80B666C8 = object_dora_DL_002380; -Gfx* D_80B666CC = object_dora_DL_002280; +Gfx* D_80B666C0 = gKendoKanbanTopRightDL; +Gfx* D_80B666C4 = gKendoKanbanTopLeftDL; +Gfx* D_80B666C8 = gKendoKanbanBottomRightDL; +Gfx* D_80B666CC = gKendoKanbanBottomLeftDL; Vec3f D_80B666D0 = { -300.0f, 850.0f, 40.0f }; Vec3f D_80B666DC = { 10.0f, 850.0f, 40.0f }; @@ -472,7 +472,7 @@ void ObjKendoKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_30C == OBJKENDOKANBAN_F_0) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_dora_DL_000180); + gSPDisplayList(POLY_OPA_DISP++, gKendoKanbanDL); } else { Matrix_InsertRotationAroundUnitVector_s(this->unk_302, &this->unk_2F0, MTXMODE_APPLY); Matrix_InsertTranslation(-this->unk_2E4.x, -this->unk_2E4.y, -this->unk_2E4.z, MTXMODE_APPLY); diff --git a/undefined_syms.txt b/undefined_syms.txt index bf08aa356..7a81b5674 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1632,11 +1632,6 @@ D_06000F00 = 0x06000F00; D_06000180 = 0x06000180; D_06000BA0 = 0x06000BA0; -// ovl_Obj_Dora - -D_06003FD0 = 0x06003FD0; -D_06004160 = 0x06004160; - // ovl_Obj_Jgame_Light D_060003A0 = 0x060003A0; From 232b901ccf20ad37cc9909c0435d9588e2298fb3 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Thu, 21 Apr 2022 18:04:37 -0700 Subject: [PATCH 193/257] En_Bbfall (Red Bubble) OK and documented (#780) * EnBbfall_Init OK * EnBbfall_Destroy, func_808BF5E0, and func_808BF734 OK * func_808BF578 and func_808BF7A0 OK * func_808BF4B4, func_808BF830, and func_808BF894 OK * func_808BF438, func_808BF514, func_808BF8DC OK * func_808BFA18 and func_808BFA3C OK * EnBbfall_Draw OK, thanks Tharo, Anon, and Maide! * LimbDraw functions OK * All functions OK, thanks Anon for the loop in Update! * Migrate data to C * Use generated reloc and object symbols * Port over a ton of documentation from EnBb * Use ARRAY_COUNT for all loops * Do a ton more documentation * Name unused animation in object_bb * Copy "floorType" variable name from OoT * Use enum values for collider type * Respond to reviews * Add comment explaining EnBbfall_IsTouchingLava --- assets/xml/objects/object_bb.xml | 2 +- spec | 3 +- src/overlays/actors/ovl_En_Bb/z_en_bb.c | 2 +- .../actors/ovl_En_Bbfall/z_en_bbfall.c | 778 +++++++++++++++--- .../actors/ovl_En_Bbfall/z_en_bbfall.h | 27 +- tools/disasm/functions.txt | 52 +- undefined_syms.txt | 6 - 7 files changed, 736 insertions(+), 134 deletions(-) diff --git a/assets/xml/objects/object_bb.xml b/assets/xml/objects/object_bb.xml index 3bd04c90e..c9c6a0a90 100644 --- a/assets/xml/objects/object_bb.xml +++ b/assets/xml/objects/object_bb.xml @@ -3,7 +3,7 @@ - + diff --git a/spec b/spec index dfac00aee..4ad4ae5c8 100644 --- a/spec +++ b/spec @@ -1057,8 +1057,7 @@ beginseg name "ovl_En_Bbfall" compress include "build/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.o" - include "build/data/ovl_En_Bbfall/ovl_En_Bbfall.data.o" - include "build/data/ovl_En_Bbfall/ovl_En_Bbfall.reloc.o" + include "build/src/overlays/actors/ovl_En_Bbfall/ovl_En_Bbfall_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index 82b3ab923..311c2f633 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -521,7 +521,7 @@ void EnBb_UpdateDamage(EnBb* this, GlobalContext* globalCtx) { this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); this->collider.base.atFlags &= ~AT_ON; if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || - (!(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { Actor_SetDropFlag(&this->actor, &this->collider.info); this->flameScaleY = 0.0f; this->flameScaleX = 0.0f; diff --git a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c index 8af8e650a..3ccd807d8 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c @@ -5,6 +5,7 @@ */ #include "z_en_bbfall.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_200) @@ -15,16 +16,25 @@ void EnBbfall_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBbfall_Update(Actor* thisx, GlobalContext* globalCtx); void EnBbfall_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808BF734(EnBbfall* this, GlobalContext* globalCtx); -void func_808BF830(EnBbfall* this, GlobalContext* globalCtx); -void func_808BF8DC(EnBbfall* this, GlobalContext* globalCtx); -void func_808BFA3C(EnBbfall* this, GlobalContext* globalCtx); -void func_808BFB4C(EnBbfall* this, GlobalContext* globalCtx); -void func_808BFE58(EnBbfall* this, GlobalContext* globalCtx); -void func_808C00A0(EnBbfall* this, GlobalContext* globalCtx); -void func_808C0178(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_SetupWaitForPlayer(EnBbfall* this); +void EnBbfall_WaitForPlayer(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_SetupEmerge(EnBbfall* this); +void EnBbfall_Emerge(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_SetupFly(EnBbfall* this); +void EnBbfall_Fly(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_SetupSinkIntoLava(EnBbfall* this); +void EnBbfall_SinkIntoLava(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_Down(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_Dead(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_Damage(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_Frozen(EnBbfall* this, GlobalContext* globalCtx); + +typedef enum { + /* -1 */ BBFALL_BODY_PART_DRAW_STATUS_BROKEN = -1, + /* 0 */ BBFALL_BODY_PART_DRAW_STATUS_ALIVE, + /* 1 */ BBFALL_BODY_PART_DRAW_STATUS_DEAD, +} EnBbfallBodyPartDrawStatus; -#if 0 const ActorInit En_Bbfall_InitVars = { ACTOR_EN_BBFALL, ACTORCAT_ENEMY, @@ -37,140 +47,720 @@ const ActorInit En_Bbfall_InitVars = { (ActorFunc)EnBbfall_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[3] = { -static ColliderJntSphElementInit D_808C0D30[3] = { +static ColliderJntSphElementInit sJntSphElementsInit[3] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x01, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x01, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x01, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x01, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_NONE, + OCELEM_NONE, + }, { 0, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x01, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x01, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_NONE, + OCELEM_NONE, + }, { 0, { { 0, 0, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808C0D9C = { - { COLTYPE_HIT3, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 3, D_808C0D30, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// static DamageTable sDamageTable = { -static DamageTable D_808C0DAC = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xE), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(1, 0x0), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0x0), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ EN_BBFALL_DMGEFF_NONE, + /* 0x1 */ EN_BBFALL_DMGEFF_STUN, + /* 0x3 */ EN_BBFALL_DMGEFF_ICE_ARROW = 0x3, + /* 0x4 */ EN_BBFALL_DMGEFF_LIGHT_ARROW, + /* 0x5 */ EN_BBFALL_DMGEFF_ZORA_MAGIC, + /* 0xE */ EN_BBFALL_DMGEFF_HOOKSHOT = 0xE, +} EnBbfallDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Ice arrow */ DMG_ENTRY(2, EN_BBFALL_DMGEFF_ICE_ARROW), + /* Light arrow */ DMG_ENTRY(2, EN_BBFALL_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_BBFALL_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_BBFALL_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808C0DCC = { 2, 20, 40, 50 }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 20, 40, 50 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808C0DD4[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 36, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 10, ICHAIN_STOP), }; -#endif +/** + * This maps a given limb based on its limbIndex to its appropriate index + * in the bodyPartsPos/Velocity arrays. An index of -1 indicates that the + * limb is not part of the bodyParts arrays. + */ +static s8 sLimbIndexToBodyPartsIndex[] = { + -1, -1, -1, -1, 0, -1, -1, -1, 1, -1, -1, -1, -1, 2, -1, 3, +}; -extern ColliderJntSphElementInit D_808C0D30[3]; -extern ColliderJntSphInit D_808C0D9C; -extern DamageTable D_808C0DAC; -extern CollisionCheckInfoInit D_808C0DCC; -extern InitChainEntry D_808C0DD4[]; +/** + * The last element of the bodyParts arrays is a duplicate of the cranium + * limb, which is then offset by a certain amount. There is no display list + * associated with this, so it is only used for effects. + */ +static Vec3f sDuplicateCraniumBodyPartOffset = { 1000.0f, -700.0f, 0.0f }; -extern UNK_TYPE D_06000184; -extern UNK_TYPE D_06000444; +void EnBbfall_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBbfall* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/EnBbfall_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_Init(globalCtx, &this->skelAnime, &gBubbleSkel, &gBubbleFlyingAnim, this->jointTable, this->morphTable, + BUBBLE_LIMB_MAX); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + ActorShape_Init(&this->actor.shape, 1500.0f, ActorShadow_DrawCircle, 35.0f); + this->timer = 0; + EnBbfall_SetupWaitForPlayer(this); + Actor_SetFocus(&this->actor, 0.0f); + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + this->collider.elements[i].dim.worldSphere.radius = this->collider.elements[i].dim.modelSphere.radius; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/EnBbfall_Destroy.s") +void EnBbfall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBbfall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF344.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF3B8.s") +void EnBbfall_Freeze(EnBbfall* this) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.4f; + this->drawDmgEffFrozenSteamScale = 0.6f; + this->timer = 80; + this->drawDmgEffAlpha = 1.0f; + this->actor.flags &= ~ACTOR_FLAG_200; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF438.s") +void EnBbfall_Thaw(EnBbfall* this, GlobalContext* globalCtx) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 0.2f, + 0.15f); + this->actor.flags |= ACTOR_FLAG_200; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF4B4.s") +/** + * Returns true if the Bubble is touching a floor that it should "sink into" (i.e., if it's touching lava). + */ +s32 EnBbfall_IsTouchingLava(EnBbfall* this, GlobalContext* globalCtx) { + if (!SurfaceType_IsWallDamage(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + u32 floorType = func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF514.s") + if ((floorType == 2) || (floorType == 3) || (floorType == 9)) { + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF578.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF5AC.s") +void EnBbfall_PlaySfx(EnBbfall* this) { + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_MOUTH); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF5E0.s") + func_800B9010(&this->actor, NA_SE_EN_BUBLEFALL_FIRE - SFX_FLAG); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF734.s") +/** + * Checks to see if the Bubble is touching a wall. If it is, and if the + * Bubble is facing directly "into" the wall, then rotate it away from + * the wall. + */ +void EnBbfall_CheckForWall(EnBbfall* this) { + s16 yawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF7A0.s") + if (this->actor.bgCheckFlags & 8) { + yawDiff = this->actor.shape.rot.y - this->actor.wallYaw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF830.s") + if (ABS_ALT(yawDiff) > 0x4000) { + this->actor.shape.rot.y = ((this->actor.wallYaw * 2) - this->actor.shape.rot.y) - 0x8000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF894.s") + this->actor.bgCheckFlags &= ~8; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BF8DC.s") +void EnBbfall_EnableColliders(EnBbfall* this) { + this->collider.elements[0].info.toucher.effect = ELEMTYPE_UNK1; // Fire + this->collider.elements[1].info.toucherFlags |= TOUCH_ON; + this->collider.elements[2].info.toucherFlags |= TOUCH_ON; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFA18.s") +void EnBbfall_DisableColliders(EnBbfall* this) { + this->collider.elements[0].info.toucher.effect = ELEMTYPE_UNK0; // Nothing + this->collider.elements[1].info.toucherFlags &= ~TOUCH_ON; + this->collider.elements[2].info.toucherFlags &= ~TOUCH_ON; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFA3C.s") +void EnBbfall_SetupWaitForPlayer(EnBbfall* this) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFAB4.s") + Animation_PlayLoop(&this->skelAnime, &gBubbleAttackAnim); + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.ocFlags1 &= ~OC1_ON; + this->flameScaleY = 0.8f; + this->flameScaleX = 1.0f; + this->flameOpacity = 255; + this->actor.colChkInfo.health = sColChkInfoInit.health; + this->actor.colorFilterTimer = 0; + this->isBgCheckCollisionEnabled = false; + this->actor.speedXZ = 0.0f; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actor.world.pos.y -= 90.0f; + for (i = 0; i < ARRAY_COUNT(this->flamePos); i++) { + Math_Vec3f_Copy(&this->flamePos[i], &this->actor.world.pos); + this->flamePos[i].y -= 47.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFB4C.s") + this->actor.bgCheckFlags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = EnBbfall_WaitForPlayer; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFCCC.s") +void EnBbfall_WaitForPlayer(EnBbfall* this, GlobalContext* globalCtx) { + if (this->timer != 0) { + this->timer--; + } else if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && (this->actor.xyzDistToPlayerSq <= SQ(250.0f))) { + EnBbfall_SetupEmerge(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFE58.s") +void EnBbfall_SetupEmerge(EnBbfall* this) { + this->actor.gravity = -1.0f; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->collider.base.atFlags |= AT_ON; + this->collider.base.acFlags |= AC_ON; + this->collider.base.ocFlags1 |= OC1_ON; + this->actor.velocity.y = 17.0f; + EnBbfall_EnableColliders(this); + this->actor.flags |= ACTOR_FLAG_1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLEFALL_APPEAR); + this->actionFunc = EnBbfall_Emerge; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808BFF8C.s") +void EnBbfall_Emerge(EnBbfall* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (this->actor.home.pos.y < this->actor.world.pos.y) { + EnBbfall_SetupFly(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C00A0.s") + EnBbfall_PlaySfx(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C013C.s") +void EnBbfall_SetupFly(EnBbfall* this) { + this->flameOpacity = 255; + this->isBgCheckCollisionEnabled = true; + this->actor.bgCheckFlags &= ~1; + this->actor.speedXZ = 5.0f; + this->actor.gravity = -1.0f; + this->actionFunc = EnBbfall_Fly; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C0178.s") +void EnBbfall_Fly(EnBbfall* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + Math_StepToF(&this->flameScaleY, 0.8f, 0.1f); + Math_StepToF(&this->flameScaleX, 1.0f, 0.1f); + EnBbfall_CheckForWall(this); + if (this->actor.bgCheckFlags & 1) { + if (EnBbfall_IsTouchingLava(this, globalCtx)) { + EnBbfall_SetupSinkIntoLava(this); + } else { + // Bounce upwards off the ground + this->actor.velocity.y *= -1.2f; + this->actor.velocity.y = CLAMP(this->actor.velocity.y, 8.0f, 12.0f); + this->actor.shape.rot.y += (s16)randPlusMinusPoint5Scaled(73728.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C01E0.s") + this->actor.bgCheckFlags &= ~1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/EnBbfall_Update.s") + this->actor.world.rot.y = this->actor.shape.rot.y; + EnBbfall_PlaySfx(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C07D4.s") +void EnBbfall_SetupSinkIntoLava(EnBbfall* this) { + this->isBgCheckCollisionEnabled = false; + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = EnBbfall_SinkIntoLava; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/func_808C080C.s") +void EnBbfall_SinkIntoLava(EnBbfall* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (this->actor.world.pos.y < (this->actor.floorHeight - 90.0f)) { + this->timer = 10; + EnBbfall_SetupWaitForPlayer(this); + } else { + EnBbfall_PlaySfx(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bbfall/EnBbfall_Draw.s") +void EnBbfall_SetupDown(EnBbfall* this) { + Animation_PlayLoop(&this->skelAnime, &gBubbleFlyingAnim); + this->collider.base.atFlags |= AT_ON; + this->timer = 200; + this->flameOpacity = 0; + this->collider.base.acFlags |= AC_ON; + this->actor.speedXZ = 2.0f; + this->flameScaleY = 0.0f; + this->flameScaleX = 0.0f; + this->actor.gravity = -2.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DOWN); + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnBbfall_Down; +} + +void EnBbfall_Down(EnBbfall* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + EnBbfall_CheckForWall(this); + + if (this->actor.bgCheckFlags & 1) { + if (EnBbfall_IsTouchingLava(this, globalCtx)) { + EnBbfall_SetupSinkIntoLava(this); + return; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + if (this->timer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_UP); + EnBbfall_EnableColliders(this); + this->actor.velocity.y = 8.0f; + EnBbfall_SetupFly(this); + return; + } + + if (this->actor.velocity.y < -14.0f) { + this->actor.velocity.y *= -0.7f; + } else { + this->actor.velocity.y = 10.0f; + } + + this->actor.bgCheckFlags &= ~1; + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 7.0f, 2, 2.0f, 0, 0, 0); + Math_ScaledStepToS(&this->actor.shape.rot.y, BINANG_ADD(this->actor.yawTowardsPlayer, 0x8000), 0xBB8); + } + + this->actor.world.rot.y = this->actor.shape.rot.y; + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + } + + if (this->timer > 0) { + this->timer--; + } +} + +void EnBbfall_SetupDead(EnBbfall* this, GlobalContext* globalCtx) { + Vec3f* bodyPartVelocity; + Vec3f posDiff; + f32 magnitude; + s32 i; + + func_800BE5CC(&this->actor, &this->collider, 0); + this->timer = 15; + this->actor.shape.rot.x += 0x4E20; + this->actor.speedXZ = 0.0f; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_BUBLE_DEAD); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x70); + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->bodyPartDrawStatus = BBFALL_BODY_PART_DRAW_STATUS_DEAD; + this->actor.gravity = -1.5f; + + bodyPartVelocity = &this->bodyPartsVelocity[0]; + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++, bodyPartVelocity++) { + Math_Vec3f_Diff(&this->bodyPartsPos[i], &this->actor.world.pos, &posDiff); + magnitude = Math3D_Vec3fMagnitude(&posDiff); + if (magnitude > 1.0f) { + magnitude = 2.5f / magnitude; + } + + bodyPartVelocity->x = posDiff.x * magnitude; + bodyPartVelocity->z = posDiff.z * magnitude; + bodyPartVelocity->y = Rand_ZeroFloat(3.5f) + 10.0f; + } + + this->actionFunc = EnBbfall_Dead; +} + +void EnBbfall_Dead(EnBbfall* this, GlobalContext* globalCtx) { + s32 i; + + this->timer--; + Math_SmoothStepToS(&this->actor.world.rot.z, 0x4000, 4, 0x1000, 0x400); + + if (this->timer == 0) { + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++) { + func_800B3030(globalCtx, &this->bodyPartsPos[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 2); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->bodyPartsPos[i], 11, NA_SE_EN_EXTINCT); + } + + Actor_MarkForDeath(&this->actor); + } else { + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++) { + Math_Vec3f_Sum(&this->bodyPartsPos[i], &this->bodyPartsVelocity[i], &this->bodyPartsPos[i]); + this->bodyPartsVelocity[i].y += this->actor.gravity; + } + } +} + +void EnBbfall_SetupDamage(EnBbfall* this) { + this->collider.base.acFlags &= ~AC_ON; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DAMAGE); + func_800BE5CC(&this->actor, &this->collider, 0); + + if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_ZORA_MAGIC) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffScale = 0.4f; + } else if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_STUN) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 20); + this->actor.speedXZ = 0.0f; + } else if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_HOOKSHOT) { + this->actor.speedXZ = 0.0f; + } else { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->actor.speedXZ = 7.0f; + } + + this->actionFunc = EnBbfall_Damage; +} + +void EnBbfall_Damage(EnBbfall* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ < 0.1f)) { + if (EnBbfall_IsTouchingLava(this, globalCtx)) { + EnBbfall_SetupSinkIntoLava(this); + } else { + EnBbfall_SetupDown(this); + } + } +} + +void EnBbfall_SetupFrozen(EnBbfall* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + + this->actor.gravity = -2.0f; + this->actionFunc = EnBbfall_Frozen; +} + +void EnBbfall_Frozen(EnBbfall* this, GlobalContext* globalCtx) { + DECR(this->timer); + + if (this->timer == 0) { + EnBbfall_Thaw(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + EnBbfall_SetupDead(this, globalCtx); + } else { + EnBbfall_SetupDown(this); + } + } +} + +void EnBbfall_UpdateDamage(EnBbfall* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + this->collider.base.atFlags &= ~AT_ON; + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + Actor_SetDropFlagJntSph(&this->actor, &this->collider); + this->flameOpacity = 0; + this->flameScaleY = 0.0f; + this->flameScaleX = 0.0f; + EnBbfall_DisableColliders(this); + EnBbfall_Thaw(this, globalCtx); + + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + + if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_ICE_ARROW) { + EnBbfall_Freeze(this); + if (this->actor.colChkInfo.health == 0) { + this->timer = 3; + this->collider.base.acFlags &= ~AC_ON; + } + + EnBbfall_SetupFrozen(this); + } else if (this->actor.colChkInfo.health == 0) { + EnBbfall_SetupDead(this, globalCtx); + } else { + EnBbfall_SetupDamage(this); + } + + if (this->actor.colChkInfo.damageEffect == EN_BBFALL_DMGEFF_LIGHT_ARROW) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.4f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->collider.elements[0].info.bumper.hitPos.x, + this->collider.elements[0].info.bumper.hitPos.y, + this->collider.elements[0].info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); + } + } + } else { + if (this->collider.base.atFlags & AT_BOUNCED) { + this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + EnBbfall_DisableColliders(this); + if (this->actionFunc != EnBbfall_Down) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; + this->actor.shape.rot.y = this->actor.world.rot.y; + EnBbfall_SetupDown(this); + } + } + } +} + +void EnBbfall_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBbfall* this = THIS; + Sphere16* sphere; + Vec3f diff; + s32 i; + f32 scale; + s32 pad[2]; + + EnBbfall_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + if (this->actionFunc != EnBbfall_Dead) { + Actor_MoveWithGravity(&this->actor); + if (this->isBgCheckCollisionEnabled) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 25.0f, 20.0f, 7); + } + + for (i = ARRAY_COUNT(this->flamePos) - 1; i >= 2; i--) { + Math_Vec3f_Diff(&this->flamePos[i - 2], &this->flamePos[i - 1], &diff); + Math_Vec3f_Scale(&diff, (i - 1) * 0.1f); + Math_Vec3f_Copy(&this->flamePos[i], &this->flamePos[i - 1]); + Math_Vec3f_Sum(&this->flamePos[i], &diff, &this->flamePos[i]); + } + + Math_Vec3f_Copy(&this->flamePos[1], &this->flamePos[0]); + Math_Vec3f_Copy(&this->flamePos[0], &this->actor.world.pos); + this->flamePos[0].y += 15.0f; + this->flamePos[0].y -= 47.0f * this->flameScaleY; + + for (i = 0, scale = this->flameScaleX; i < ARRAY_COUNT(this->colliderElements); i++, scale *= 0.7569f) { + sphere = &this->collider.elements[i].dim.worldSphere; + sphere->radius = 30.0f * scale; + sphere->center.x = this->flamePos[2 * i].x; + sphere->center.y = this->flamePos[2 * i].y + (47.0f * scale); + sphere->center.z = this->flamePos[2 * i].z; + } + + this->collider.elements[0].dim.worldSphere.radius = + CLAMP_MIN(this->collider.elements[0].dim.worldSphere.radius, 20); + + Math_Vec3s_ToVec3f(&this->actor.focus.pos, &this->collider.elements->dim.worldSphere.center); + + if (this->collider.base.atFlags & AT_ON) { + this->actor.flags |= ACTOR_FLAG_1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.ocFlags1 & OC1_ON) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.2f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.4f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.4f, 0.01f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + } +} + +s32 EnBbfall_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBbfall* this = THIS; + + if (this->bodyPartDrawStatus == BBFALL_BODY_PART_DRAW_STATUS_BROKEN) { + this->limbDList = *dList; + *dList = NULL; + } + + return false; +} + +void EnBbfall_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnBbfall* this = THIS; + MtxF* currentMatrixState; + + if (this->bodyPartDrawStatus == BBFALL_BODY_PART_DRAW_STATUS_ALIVE) { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + if (sLimbIndexToBodyPartsIndex[limbIndex] == 0) { + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->bodyPartsPos[0]); + } else if (sLimbIndexToBodyPartsIndex[limbIndex] == 3) { + Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->bodyPartsPos[3]); + Matrix_MultiplyVector3fByState(&sDuplicateCraniumBodyPartOffset, &this->bodyPartsPos[4]); + } else { + Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + } + } + } else if (this->bodyPartDrawStatus > BBFALL_BODY_PART_DRAW_STATUS_ALIVE) { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + } + + if (limbIndex == BUBBLE_LIMB_CRANIUM) { + this->bodyPartDrawStatus = BBFALL_BODY_PART_DRAW_STATUS_BROKEN; + } + } else { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + currentMatrixState = Matrix_GetCurrentState(); + currentMatrixState->mf[3][0] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].x; + currentMatrixState->mf[3][1] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].y; + currentMatrixState->mf[3][2] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].z; + Matrix_InsertZRotation_s(thisx->world.rot.z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->limbDList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} + +void EnBbfall_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnBbfall* this = THIS; + MtxF* currentMatrixState; + Gfx* gfx; + s32 opacity; + Vec3f* pos; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + POLY_OPA_DISP = &gfx[1]; + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnBbfall_OverrideLimbDraw, + EnBbfall_PostLimbDraw, &this->actor); + + if (this->flameOpacity > 0) { + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_RotateY( + ((Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) - this->actor.shape.rot.y) + 0x8000), + MTXMODE_APPLY); + Matrix_Scale(this->flameScaleX, this->flameScaleY, 1.0f, MTXMODE_APPLY); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + currentMatrixState = Matrix_GetCurrentState(); + + opacity = this->flameOpacity; + pos = &this->flamePos[0]; + + for (i = 0; i < ARRAY_COUNT(this->flamePos); i++, pos++) { + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + ((globalCtx->gameplayFrames + (i * 10)) * (-20 + i * 2)) & 0x1FF, 32, 128)); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, opacity); + currentMatrixState->mf[3][0] = pos->x; + currentMatrixState->mf[3][1] = pos->y; + currentMatrixState->mf[3][2] = pos->z; + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); + + opacity -= 35; + if (opacity < 0) { + break; + } + + Matrix_Scale(0.87f, 0.87f, 1.0f, MTXMODE_APPLY); + } + } + + Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h index 90c209b31..411c4b17f 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h @@ -2,16 +2,35 @@ #define Z_EN_BBFALL_H #include "global.h" +#include "objects/object_bb/object_bb.h" struct EnBbfall; typedef void (*EnBbfallActionFunc)(struct EnBbfall*, GlobalContext*); typedef struct EnBbfall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; - /* 0x0248 */ EnBbfallActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x218]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[BUBBLE_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[BUBBLE_LIMB_MAX]; + /* 0x248 */ EnBbfallActionFunc actionFunc; + /* 0x24C */ u8 flameOpacity; + /* 0x24D */ u8 isBgCheckCollisionEnabled; + /* 0x24E */ s8 bodyPartDrawStatus; + /* 0x24F */ u8 drawDmgEffType; + /* 0x250 */ s16 timer; + /* 0x254 */ f32 flameScaleY; + /* 0x258 */ f32 flameScaleX; + /* 0x25C */ f32 drawDmgEffAlpha; + /* 0x260 */ f32 drawDmgEffScale; + /* 0x264 */ f32 drawDmgEffFrozenSteamScale; + /* 0x268 */ Vec3f flamePos[6]; + /* 0x2B0 */ Vec3f bodyPartsPos[5]; + /* 0x2EC */ Vec3f bodyPartsVelocity[5]; + /* 0x328 */ Gfx* limbDList; + /* 0x32C */ UNK_TYPE1 unk_32C[0x58]; + /* 0x384 */ ColliderJntSph collider; + /* 0x3A4 */ ColliderJntSphElement colliderElements[3]; } EnBbfall; // size = 0x464 extern const ActorInit En_Bbfall_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 6a7b92683..4980f109b 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -6071,33 +6071,33 @@ 0x808BEE38:("EnDekunuts_Draw",), 0x808BF220:("EnBbfall_Init",), 0x808BF318:("EnBbfall_Destroy",), - 0x808BF344:("func_808BF344",), - 0x808BF3B8:("func_808BF3B8",), - 0x808BF438:("func_808BF438",), - 0x808BF4B4:("func_808BF4B4",), - 0x808BF514:("func_808BF514",), - 0x808BF578:("func_808BF578",), - 0x808BF5AC:("func_808BF5AC",), - 0x808BF5E0:("func_808BF5E0",), - 0x808BF734:("func_808BF734",), - 0x808BF7A0:("func_808BF7A0",), - 0x808BF830:("func_808BF830",), - 0x808BF894:("func_808BF894",), - 0x808BF8DC:("func_808BF8DC",), - 0x808BFA18:("func_808BFA18",), - 0x808BFA3C:("func_808BFA3C",), - 0x808BFAB4:("func_808BFAB4",), - 0x808BFB4C:("func_808BFB4C",), - 0x808BFCCC:("func_808BFCCC",), - 0x808BFE58:("func_808BFE58",), - 0x808BFF8C:("func_808BFF8C",), - 0x808C00A0:("func_808C00A0",), - 0x808C013C:("func_808C013C",), - 0x808C0178:("func_808C0178",), - 0x808C01E0:("func_808C01E0",), + 0x808BF344:("EnBbfall_Freeze",), + 0x808BF3B8:("EnBbfall_Thaw",), + 0x808BF438:("EnBbfall_IsTouchingLava",), + 0x808BF4B4:("EnBbfall_PlaySfx",), + 0x808BF514:("EnBbfall_CheckForWall",), + 0x808BF578:("EnBbfall_EnableColliders",), + 0x808BF5AC:("EnBbfall_DisableColliders",), + 0x808BF5E0:("EnBbfall_SetupWaitForPlayer",), + 0x808BF734:("EnBbfall_WaitForPlayer",), + 0x808BF7A0:("EnBbfall_SetupEmerge",), + 0x808BF830:("EnBbfall_Emerge",), + 0x808BF894:("EnBbfall_SetupFly",), + 0x808BF8DC:("EnBbfall_Fly",), + 0x808BFA18:("EnBbfall_SetupSinkIntoLava",), + 0x808BFA3C:("EnBbfall_SinkIntoLava",), + 0x808BFAB4:("EnBbfall_SetupDown",), + 0x808BFB4C:("EnBbfall_Down",), + 0x808BFCCC:("EnBbfall_SetupDead",), + 0x808BFE58:("EnBbfall_Dead",), + 0x808BFF8C:("EnBbfall_SetupDamage",), + 0x808C00A0:("EnBbfall_Damage",), + 0x808C013C:("EnBbfall_SetupFrozen",), + 0x808C0178:("EnBbfall_Frozen",), + 0x808C01E0:("EnBbfall_UpdateDamage",), 0x808C03EC:("EnBbfall_Update",), - 0x808C07D4:("func_808C07D4",), - 0x808C080C:("func_808C080C",), + 0x808C07D4:("EnBbfall_OverrideLimbDraw",), + 0x808C080C:("EnBbfall_PostLimbDraw",), 0x808C0A04:("EnBbfall_Draw",), 0x808C1030:("ArmsHook_SetupAction",), 0x808C103C:("ArmsHook_Init",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 7a81b5674..50065f57d 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1016,12 +1016,6 @@ D_0600D530 = 0x0600D530; D_060000A0 = 0x060000A0; D_060000C8 = 0x060000C8; -// ovl_En_Bbfall - -D_06000184 = 0x06000184; -D_06000444 = 0x06000444; -D_06001A30 = 0x06001A30; - // ovl_En_Bee D_0600005C = 0x0600005C; From 25f00ef995c83c84a12af523a397f1c214811460 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Thu, 21 Apr 2022 18:11:33 -0700 Subject: [PATCH 194/257] Document object_dekunuts (and minor cleanup of object_dnk) (#803) * Name all animations * Skeleton, limbs, and limb display lists * Remaning dlists * Limb enum * Name all textures * Minor cleanup on object_dnk * hair -> headdress --- assets/xml/objects/object_dekunuts.xml | 89 +++++++++++-------- assets/xml/objects/object_dnk.xml | 23 ++--- .../actors/ovl_En_Dekunuts/z_en_dekunuts.c | 43 +++++---- .../actors/ovl_En_Dekunuts/z_en_dekunuts.h | 5 +- src/overlays/actors/ovl_En_Dnk/z_en_dnk.c | 34 +++---- .../ovl_En_Guard_Nuts/z_en_guard_nuts.c | 4 +- .../ovl_En_Guard_Nuts/z_en_guard_nuts.h | 4 +- .../actors/ovl_En_Look_Nuts/z_en_look_nuts.c | 2 +- .../actors/ovl_En_Look_Nuts/z_en_look_nuts.h | 4 +- .../z_en_syateki_dekunuts.c | 25 +++--- .../z_en_syateki_dekunuts.h | 5 +- 11 files changed, 126 insertions(+), 112 deletions(-) diff --git a/assets/xml/objects/object_dekunuts.xml b/assets/xml/objects/object_dekunuts.xml index 2e9529d4c..8a45dd04a 100644 --- a/assets/xml/objects/object_dekunuts.xml +++ b/assets/xml/objects/object_dekunuts.xml @@ -1,42 +1,55 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dnk.xml b/assets/xml/objects/object_dnk.xml index 4e07a455c..ad69c7722 100644 --- a/assets/xml/objects/object_dnk.xml +++ b/assets/xml/objects/object_dnk.xml @@ -1,4 +1,5 @@  + @@ -33,17 +34,17 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c index 7461239d3..da9f37237 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -6,7 +6,6 @@ #include "z_en_dekunuts.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "objects/object_dekunuts/object_dekunuts.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) @@ -119,8 +118,8 @@ void EnDekunuts_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dekunuts_Skel_002468, &object_dekunuts_Anim_00326C, - this->jointTable, this->morphTable, 10); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuScrubSkel, &gDekuScrubIdleAnim, this->jointTable, + this->morphTable, DEKU_SCRUB_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->unk_194 = ENDEKUNUTS_GET_FF00(&this->actor); @@ -166,7 +165,7 @@ void func_808BD3B4(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BD428(EnDekunuts* this) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &object_dekunuts_Anim_003180, 0.0f); + Animation_PlayOnceSetSpeed(&this->skelAnime, &gDekuScrubUpAnim, 0.0f); this->unk_190 = Rand_S16Offset(100, 50); this->collider.dim.height = 5; Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); @@ -221,7 +220,7 @@ void func_808BD49C(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BD78C(EnDekunuts* this) { - Animation_PlayLoop(&this->skelAnime, &object_dekunuts_Anim_002FA4); + Animation_PlayLoop(&this->skelAnime, &gDekuScrubLookAroundAnim); this->unk_190 = 2; this->actionFunc = func_808BD7D4; } @@ -241,7 +240,7 @@ void func_808BD7D4(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BD870(EnDekunuts* this) { - Animation_MorphToLoop(&this->skelAnime, &object_dekunuts_Anim_00326C, -3.0f); + Animation_MorphToLoop(&this->skelAnime, &gDekuScrubIdleAnim, -3.0f); if (this->actionFunc == func_808BDA4C) { this->unk_190 = 4098; } else { @@ -280,7 +279,7 @@ void func_808BD8D8(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDA08(EnDekunuts* this) { - Animation_PlayOnce(&this->skelAnime, &object_dekunuts_Anim_000168); + Animation_PlayOnce(&this->skelAnime, &gDekuScrubSpitAnim); this->unk_190 = this->unk_194; this->actionFunc = func_808BDA4C; } @@ -324,7 +323,7 @@ void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_THROW); } } else if ((this->unk_190 >= 2) && Animation_OnFrame(&this->skelAnime, 12.0f)) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_000168, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubSpitAnim, -3.0f); if (this->unk_190 != 0) { this->unk_190--; } @@ -332,14 +331,14 @@ void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDC9C(EnDekunuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_002A5C, -5.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubBurrowAnim, -5.0f); this->unk_190 = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->actionFunc = func_808BDD54; } void func_808BDCF0(EnDekunuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_002A5C, -5.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubBurrowAnim, -5.0f); this->collider.base.acFlags &= ~AC_ON; this->unk_190 = 80; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); @@ -367,7 +366,7 @@ void func_808BDD54(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDE7C(EnDekunuts* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_002DD4, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubUnburrowAnim, -3.0f); this->collider.dim.height = 37; this->actor.colChkInfo.mass = 50; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); @@ -387,7 +386,7 @@ void func_808BDEF8(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BDF60(EnDekunuts* this) { - Animation_PlayLoop(&this->skelAnime, &object_dekunuts_Anim_003780); + Animation_PlayLoop(&this->skelAnime, &gDekuScrubRunAnim); this->unk_190 = 2; this->unk_18C = 0; this->collider.base.acFlags |= AC_ON; @@ -444,7 +443,7 @@ void func_808BDFB8(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BE1CC(EnDekunuts* this) { - Animation_PlayLoop(&this->skelAnime, &object_dekunuts_Anim_0033E4); + Animation_PlayLoop(&this->skelAnime, &gDekuScrubPantingAnim); this->unk_190 = 3; this->actor.speedXZ = 0.0f; if (this->unk_18D != 0) { @@ -467,7 +466,7 @@ void func_808BE22C(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BE294(EnDekunuts* this, s32 arg1) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dekunuts_Anim_00259C, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDekuScrubDamageAnim, -3.0f); if (this->actor.params == ENDEKUNUTS_GET_FF00_0) { this->actor.speedXZ = 10.0f; if (arg1 != 0) { @@ -480,7 +479,7 @@ void func_808BE294(EnDekunuts* this, s32 arg1) { this->actionFunc = func_808BE358; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CUTBODY); - Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, Animation_GetLastFrame(&object_dekunuts_Anim_00259C)); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, Animation_GetLastFrame(&gDekuScrubDamageAnim)); } void func_808BE358(EnDekunuts* this, GlobalContext* globalCtx) { @@ -519,7 +518,7 @@ void func_808BE3FC(EnDekunuts* this, GlobalContext* globalCtx) { } void func_808BE484(EnDekunuts* this) { - Animation_PlayOnce(&this->skelAnime, &object_dekunuts_Anim_002BD4); + Animation_PlayOnce(&this->skelAnime, &gDekuScrubDieAnim); this->actionFunc = func_808BE4D4; this->actor.speedXZ = 0.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); @@ -543,13 +542,13 @@ void func_808BE4D4(EnDekunuts* this, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_ETCETERA, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, 0, this->actor.home.rot.y, 0, 0x80); EffectSsHahen_SpawnBurst(globalCtx, &this->actor.home.pos, 6.0f, 0, 6, 2, 15, 64, 10, - object_dekunuts_DL_001F50); + gDekuScrubFlowerFragmentDL); Actor_MarkForDeath(&this->actor); } } void func_808BE680(EnDekunuts* this) { - Animation_MorphToLoop(&this->skelAnime, &object_dekunuts_Anim_00326C, -3.0f); + Animation_MorphToLoop(&this->skelAnime, &gDekuScrubIdleAnim, -3.0f); this->actionFunc = func_808BE6C4; } @@ -669,7 +668,7 @@ s32 EnDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d f32 currentFrame; if (this->actionFunc == func_808BDA4C) { - if (limbIndex == 5) { + if (limbIndex == DEKU_SCRUB_LIMB_SNOUT) { currentFrame = this->skelAnime.curFrame; if (currentFrame <= 6.0f) { arg2 = 1.0f - (currentFrame * 0.0833f); @@ -688,7 +687,7 @@ s32 EnDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d return 0; } Matrix_Scale(arg1, arg2, arg3, MTXMODE_APPLY); - } else if ((limbIndex == 2) && (this->actor.params == ENDEKUNUTS_GET_FF00_2)) { + } else if ((limbIndex == DEKU_SCRUB_LIMB_HEAD) && (this->actor.params == ENDEKUNUTS_GET_FF00_2)) { rot->z = this->actor.world.rot.x; } } @@ -723,7 +722,7 @@ void EnDekunuts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis } } - if (limbIndex == 2) { + if (limbIndex == DEKU_SCRUB_LIMB_HEAD) { Matrix_GetStateTranslation(&this->actor.focus.pos); } } @@ -739,7 +738,7 @@ void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.colorFilterTimer != 0) { func_800AE5A0(globalCtx); } - Gfx_DrawDListOpa(globalCtx, object_dekunuts_DL_001E50); + Gfx_DrawDListOpa(globalCtx, gDekuScrubFlowerDL); Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h index 3e1af35eb..39d0dd954 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h @@ -2,6 +2,7 @@ #define Z_EN_DEKUNUTS_H #include "global.h" +#include "objects/object_dekunuts/object_dekunuts.h" struct EnDekunuts; @@ -26,8 +27,8 @@ typedef struct EnDekunuts { /* 0x190 */ s16 unk_190; /* 0x192 */ s16 unk_192; /* 0x194 */ s16 unk_194; - /* 0x196 */ Vec3s jointTable[10]; - /* 0x1D2 */ Vec3s morphTable[10]; + /* 0x196 */ Vec3s jointTable[DEKU_SCRUB_LIMB_MAX]; + /* 0x1D2 */ Vec3s morphTable[DEKU_SCRUB_LIMB_MAX]; /* 0x210 */ f32 drawDmgEffAlpha; /* 0x214 */ f32 drawDmgEffScale; /* 0x218 */ f32 drawDmgEffFrozenSteamScale; diff --git a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c index 969c719fd..99c5d23d9 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -116,20 +116,20 @@ static AnimationInfoS sAnimations[] = { { &object_hintnuts_Anim_003128, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, { &object_hintnuts_Anim_0029BC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, { &object_hintnuts_Anim_002E84, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_000168, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_00259C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_002A5C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dekunuts_Anim_002A5C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_002BD4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_002DD4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_002FA4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_003180, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dekunuts_Anim_00326C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dekunuts_Anim_00326C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_0033E4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_003780, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dekunuts_Anim_003780, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dekunuts_Anim_002950, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuScrubSpitAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubDamageAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubBurrowAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDekuScrubBurrowAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubDieAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubUnburrowAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubLookAroundAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubUpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuScrubIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuScrubIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubPantingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuScrubRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuScrubStandingIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; s32 func_80A514F0(SkelAnime* skelAnime, s16 animIndex) { @@ -179,7 +179,7 @@ void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { switch (ENDNK_GET_3(&this->actor)) { case ENDNK_GET_3_0: SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, NULL, this->jointTable, - this->morphTable, 11); + this->morphTable, DEKU_PALACE_GUARD_LIMB_MAX); func_80A514F0(&this->skelAnime, 7); break; @@ -190,8 +190,8 @@ void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { break; case ENDNK_GET_3_2: - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dekunuts_Skel_002468, NULL, this->jointTable, - this->morphTable, 10); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuScrubSkel, NULL, this->jointTable, this->morphTable, + DEKU_SCRUB_LIMB_MAX); func_80A514F0(&this->skelAnime, 35); break; } 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 2434ca2cf..3a8cfdcd9 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 @@ -98,7 +98,7 @@ void EnGuardNuts_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, &gDekuPalaceGuardWaitAnim, this->jointTable, - this->morphTable, OBJECT_DNK_LIMB_MAX); + this->morphTable, DEKU_PALACE_GUARD_LIMB_MAX); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.targetMode = 1; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -355,7 +355,7 @@ s32 EnGuardNuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** Actor* thisx) { EnGuardNuts* this = THIS; - if (limbIndex == OBJECT_DNK_LIMB_HEAD) { + if (limbIndex == DEKU_PALACE_GUARD_LIMB_HEAD) { rot->x += this->headRot.x; rot->y += this->headRot.y; rot->z += this->headRot.z; 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 59f885563..4a42e4e5a 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 @@ -11,8 +11,8 @@ typedef void (*EnGuardNutsActionFunc)(struct EnGuardNuts*, GlobalContext*); typedef struct EnGuardNuts { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[OBJECT_DNK_LIMB_MAX]; - /* 0x1CA */ Vec3s morphTable[OBJECT_DNK_LIMB_MAX]; + /* 0x188 */ Vec3s jointTable[DEKU_PALACE_GUARD_LIMB_MAX]; + /* 0x1CA */ Vec3s morphTable[DEKU_PALACE_GUARD_LIMB_MAX]; /* 0x20C */ EnGuardNutsActionFunc actionFunc; /* 0x210 */ s16 eyeState; /* 0x212 */ s16 blinkTimer; diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c index 07b9e8db0..1bbf6fee4 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c @@ -104,7 +104,7 @@ void EnLookNuts_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, &gDekuPalaceGuardDigAnim, this->jointTable, - this->morphTable, OBJECT_DNK_LIMB_MAX); + this->morphTable, DEKU_PALACE_GUARD_LIMB_MAX); Actor_SetScale(&this->actor, 0.01f); this->actor.colChkInfo.damageTable = &sDamageTable; this->actor.colChkInfo.mass = MASS_IMMOVABLE; diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h index c06f0e2cd..e6eb6597a 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h @@ -15,8 +15,8 @@ typedef void (*EnLookNutsActionFunc)(struct EnLookNuts*, GlobalContext*); typedef struct EnLookNuts { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[OBJECT_DNK_LIMB_MAX]; - /* 0x01CA */ Vec3s morphTable[OBJECT_DNK_LIMB_MAX]; + /* 0x0188 */ Vec3s jointTable[DEKU_PALACE_GUARD_LIMB_MAX]; + /* 0x01CA */ Vec3s morphTable[DEKU_PALACE_GUARD_LIMB_MAX]; /* 0x020C */ EnLookNutsActionFunc actionFunc; /* 0x0210 */ Path *path; /* 0x0214 */ s16 currentPathIndex; // Index for the point where the deku guard is in its path diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c index 944838b3c..92168ef76 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c @@ -7,7 +7,6 @@ #include "z_en_syateki_dekunuts.h" #include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "objects/object_dekunuts/object_dekunuts.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) @@ -70,13 +69,13 @@ static ColliderCylinderInit sCylinderInit = { static Cylinder16 D_80A2CADC[] = { { 24, 40, 0, { 0, 0, 0 } } }; static AnimationInfo sAnimations[] = { - { &object_dekunuts_Anim_003180, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_dekunuts_Anim_002A5C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_dekunuts_Anim_00326C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, - { &object_dekunuts_Anim_002FA4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, - { &object_dekunuts_Anim_00259C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_dekunuts_Anim_002BD4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_dekunuts_Anim_002DD4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gDekuScrubUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gDekuScrubBurrowAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gDekuScrubIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &gDekuScrubLookAroundAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &gDekuScrubDamageAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gDekuScrubDieAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gDekuScrubUnburrowAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, }; static InitChainEntry sInitChain[] = { @@ -124,8 +123,8 @@ void EnSyatekiDekunuts_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dekunuts_Skel_002468, &object_dekunuts_Anim_002A5C, - this->jointTable, this->morphTable, 10); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuScrubSkel, &gDekuScrubBurrowAnim, this->jointTable, + this->morphTable, DEKU_SCRUB_LIMB_MAX); if (path == NULL) { Actor_MarkForDeath(&this->actor); return; @@ -147,7 +146,7 @@ void EnSyatekiDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80A2BE54(EnSyatekiDekunuts* this) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &object_dekunuts_Anim_003180, 0.0f); + Animation_PlayOnceSetSpeed(&this->skelAnime, &gDekuScrubUpAnim, 0.0f); this->actor.speedXZ = 0.0f; this->actor.world = this->actor.home; @@ -398,7 +397,7 @@ s32 EnSyatekiDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnSyatekiDekunuts* this = THIS; - if ((limbIndex == OBJECT_DEKUNUTS_LIMB_03) && (this->unk_1F0 == 1)) { + if ((limbIndex == DEKU_SCRUB_LIMB_HEADDRESS) && (this->unk_1F0 == 1)) { rot->z += this->unk_1F2; } @@ -428,7 +427,7 @@ void EnSyatekiDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, &object_dekunuts_DL_001E50); + gSPDisplayList(POLY_OPA_DISP++, gDekuScrubFlowerDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h index 4055dd6b8..50361894b 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h @@ -2,6 +2,7 @@ #define Z_EN_SYATEKI_DEKUNUTS_H #include "global.h" +#include "objects/object_dekunuts/object_dekunuts.h" #define EN_SYATEKI_DEKUNUTS_GET_PARAM_F(thisx) ((thisx)->params & 0xF) #define EN_SYATEKI_DEKUNUTS_GET_PARAM_F0(thisx) (((thisx)->params & 0xF0) >> 4) @@ -28,8 +29,8 @@ typedef struct EnSyatekiDekunuts { /* 0x1EE */ s16 unk_1EE; /* 0x1F0 */ s16 unk_1F0; /* 0x1F2 */ s16 unk_1F2; - /* 0x1F4 */ Vec3s jointTable[10]; - /* 0x230 */ Vec3s morphTable[10]; + /* 0x1F4 */ Vec3s jointTable[DEKU_SCRUB_LIMB_MAX]; + /* 0x230 */ Vec3s morphTable[DEKU_SCRUB_LIMB_MAX]; /* 0x26C */ UNK_TYPE1 unk_26C[0x4]; } EnSyatekiDekunuts; // size = 0x270 From 374c05fda312f841e3840d7c184e0885c20e21d7 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Thu, 21 Apr 2022 18:48:01 -0700 Subject: [PATCH 195/257] Document object_boss02 (#795) --- assets/xml/objects/object_boss02.xml | 216 ++++++++++-------- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 33 ++- src/overlays/actors/ovl_Boss_02/z_boss_02.h | 5 +- .../actors/ovl_En_Tanron5/z_en_tanron5.c | 22 +- 4 files changed, 151 insertions(+), 125 deletions(-) diff --git a/assets/xml/objects/object_boss02.xml b/assets/xml/objects/object_boss02.xml index 0370e1ae2..9a400554b 100644 --- a/assets/xml/objects/object_boss02.xml +++ b/assets/xml/objects/object_boss02.xml @@ -1,99 +1,125 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index 888a0587a..7cf9a94b7 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -7,7 +7,6 @@ #include "z_boss_02.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "overlays/actors/ovl_Item_B_Heart/z_item_b_heart.h" -#include "objects/object_boss02/object_boss02.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "prevent_bss_reordering.h" @@ -597,8 +596,8 @@ void Boss02_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_HEAVY; this->actor.colChkInfo.health = 20; Actor_SetScale(&this->actor, 0.01f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_boss02_Skel_009B10, &object_boss02_Anim_009C78, - this->jointTable, this->morphTable, 13); + SkelAnime_Init(globalCtx, &this->skelAnime, &gTwinmoldHeadSkel, &gTwinmoldHeadFlyAnim, this->jointTable, + this->morphTable, TWINMOLD_HEAD_LIMB_MAX); Collider_InitAndSetJntSph(globalCtx, &this->colliderSphere1, &this->actor, &sJntSphInit1, this->colliderSphere1Elements); Collider_InitAndSetJntSph(globalCtx, &this->colliderSphere2, &this->actor, &sJntSphInit2, @@ -637,7 +636,7 @@ void func_809DAA98(Boss02* this, GlobalContext* globalCtx) { void func_809DAAA8(Boss02* this, GlobalContext* globalCtx) { this->actionFunc = func_809DAB78; - Animation_MorphToLoop(&this->skelAnime, &object_boss02_Anim_009C78, 0.0f); + Animation_MorphToLoop(&this->skelAnime, &gTwinmoldHeadFlyAnim, 0.0f); if (D_809E042C->unk_1D20 != 0) { this->unk_0144 = 10; } else { @@ -1323,12 +1322,12 @@ void func_809DC78C(Actor* thisx, GlobalContext* globalCtx) { void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { static Gfx* D_809DFA9C[] = { - object_boss02_DL_00ECF0, object_boss02_DL_00EF90, object_boss02_DL_00F310, object_boss02_DL_00F690, - object_boss02_DL_00FA10, object_boss02_DL_00FD90, object_boss02_DL_010110, object_boss02_DL_010490, - object_boss02_DL_010810, object_boss02_DL_010B90, object_boss02_DL_010F10, object_boss02_DL_011290, - object_boss02_DL_011610, object_boss02_DL_011990, object_boss02_DL_011D10, object_boss02_DL_012090, - object_boss02_DL_012410, object_boss02_DL_012790, object_boss02_DL_012B10, object_boss02_DL_012E90, - object_boss02_DL_013210, object_boss02_DL_013590, + gTwinmoldBodySegment1DL, gTwinmoldBodySegment2DL, gTwinmoldBodySegment3DL, gTwinmoldBodySegment4DL, + gTwinmoldBodySegment5DL, gTwinmoldBodySegment6DL, gTwinmoldBodySegment7DL, gTwinmoldBodySegment8DL, + gTwinmoldBodySegment9DL, gTwinmoldBodySegment10DL, gTwinmoldBodySegment11DL, gTwinmoldBodySegment12DL, + gTwinmoldBodySegment13DL, gTwinmoldBodySegment14DL, gTwinmoldBodySegment15DL, gTwinmoldBodySegment16DL, + gTwinmoldBodySegment17DL, gTwinmoldBodySegment18DL, gTwinmoldBodySegment19DL, gTwinmoldBodySegment20DL, + gTwinmoldBodySegment21DL, gTwinmoldBodyTailDL, }; static Vec3f D_809DFAF4 = { -10000.0f, -100000.0f, -100000.0f }; GlobalContext* globalCtx = globalCtx2; @@ -1353,9 +1352,9 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_8012C28C(globalCtx->state.gfxCtx); if (this->actor.params == 0) { - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_boss02_Tex_0003A0)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gTwinmoldRedSkinTex)); } else { - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_boss02_Tex_0041A0)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gTwinmoldBlueSkinTex)); } gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); @@ -1528,7 +1527,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(D_809E0438); i++, effect++) { if (effect->unk_24 == 1) { if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_boss02_DL_000230); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 185, 140, 70, 128); flag++; } @@ -1549,7 +1548,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_boss02_DL_0002E0); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustModelDL); } } @@ -1598,7 +1597,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { for (i = 0, flag = false; i < ARRAY_COUNT(D_809E0438); i++, effect++) { if (effect->unk_24 == 2) { if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_boss02_DL_000230); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 30, 30, 30, 128); flag++; } @@ -1614,7 +1613,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_boss02_DL_0002E0); + gSPDisplayList(POLY_XLU_DISP++, gTwinmoldDustModelDL); } } @@ -2141,7 +2140,7 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { if (this->unk_1D1C == (u32)(KREG(92) + 125)) { TitleCard_InitBossName(&globalCtx->state, &globalCtx->actorCtx.titleCtxt, - Lib_SegmentedToVirtual(object_boss02_Tex_008650), 160, 180, 128, 40); + Lib_SegmentedToVirtual(gTwinmoldTitleCardTex), 160, 180, 128, 40); } if (this->unk_1D1C == (u32)(BREG(27) + 335)) { diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.h b/src/overlays/actors/ovl_Boss_02/z_boss_02.h index babf40b76..6c20814fb 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.h +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.h @@ -2,6 +2,7 @@ #define Z_BOSS_02_H #include "global.h" +#include "objects/object_boss02/object_boss02.h" struct Boss02; @@ -56,8 +57,8 @@ typedef struct Boss02 { /* 0x0B1C */ Vec3f unk_0B1C[200]; /* 0x147C */ Vec3f unk_147C[23]; /* 0x1590 */ SkelAnime skelAnime; - /* 0x15D4 */ Vec3s jointTable[13]; - /* 0x1622 */ Vec3s morphTable[13]; + /* 0x15D4 */ Vec3s jointTable[TWINMOLD_HEAD_LIMB_MAX]; + /* 0x1622 */ Vec3s morphTable[TWINMOLD_HEAD_LIMB_MAX]; /* 0x1670 */ Boss02ActionFunc actionFunc; /* 0x1674 */ struct Boss02* unk_1674; // points to the other's instance /* 0x1678 */ s32 unk_1678; diff --git a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c index ada39da61..1927b4edb 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c @@ -65,11 +65,11 @@ Vec2s D_80BE5DD4[] = { }; Gfx* D_80BE5E24[] = { - object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, - object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, - object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, - object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, - object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, + gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, + gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, + gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, gTwinmoldMajoraPillarDL, + gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, + gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, gTwinmoldPyramidRuinDL, }; f32 D_80BE5E74[] = { @@ -176,7 +176,7 @@ void EnTanron5_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_144 = 250; this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; } else { - this->unk_148 = object_boss02_DL_007A88; + this->unk_148 = gRuinFragmentDL; this->unk_144 = 150; } } else if (ENTANRON5_GET(&this->actor) == ENTANRON5_0) { @@ -194,7 +194,7 @@ void EnTanron5_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&child->actor, child->unk_19C); child->unk_148 = D_80BE5E24[i]; - if (child->unk_148 == object_boss02_DL_006FD0) { + if (child->unk_148 == gTwinmoldPyramidRuinDL) { child->actor.shape.rot.y = 0; } @@ -249,7 +249,7 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { Actor_SetScale(&this->actor, this->unk_19C * D_80BE5DD0); - if (this->unk_148 == object_boss02_DL_007D18) { + if (this->unk_148 == gTwinmoldMajoraPillarDL) { this->collider.dim.radius = 65.0f * D_80BE5DD0; this->collider.dim.height = 380.0f * D_80BE5DD0; } else if (this->unk_1A0 == 0) { @@ -280,7 +280,7 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { if ((KREG(19) != 0) || ((acHitInfo->toucher.dmgFlags & 0x05000202) && (D_80BE5DD0 < 0.5f)) || (ac->id == ACTOR_BOSS_02)) { - if (this->unk_148 == object_boss02_DL_007D18) { + if (this->unk_148 == gTwinmoldMajoraPillarDL) { Math_Vec3f_Copy(&spB8, &this->actor.world.pos); spB8.y += D_80BE5DD0 * 300.0f; @@ -366,11 +366,11 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { } Collider_UpdateCylinder(&this->actor, &this->collider); - if (this->unk_148 == object_boss02_DL_006FD0) { + if (this->unk_148 == gTwinmoldPyramidRuinDL) { this->collider.dim.pos.y = this->actor.floorHeight; } - if ((this->unk_148 == object_boss02_DL_007D18) || (D_80BE5DD0 < 0.5f)) { + if ((this->unk_148 == gTwinmoldMajoraPillarDL) || (D_80BE5DD0 < 0.5f)) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } else { f32 xDiff = player->actor.world.pos.x - this->actor.world.pos.x; From 81efaf8551c20ce352108d685c50e018f7a991b1 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Thu, 21 Apr 2022 19:22:07 -0700 Subject: [PATCH 196/257] En_Raf (Carnivorous Lily Pad) OK and documented, object_raf documented (#794) * EnRaf_Init OK * func_80A17060, func_80A18080, and func_80A180B4 OK * EnRaf_Destroy, func_80A1712C, func_80A171D8, and func_80A17414 OK * func_80A17464 and func_80A17530 OK * EnRaf_Draw OK * func_80A175E4, func_80A17848, and func_80A178A0 OK * func_80A18A90 OK * func_80A179C8 and func_80A17C6C OK * func_80A1859C OK * func_80A17D14 and EnRaf_Update OK * func_80A18B8C and func_80A18DA0 OK, EnRafParticle documented * func_80A16D40, func_80A16D6C, func_80A17D54, and func_80A17DDC OK * func_80A17E1C OK * Use object symbols * Import data to C and use generated reloc * Misc cleanup * Document animations and skeleton * Finish documenting object_raf * Some low-hanging fruit * Some actions I figured out * Name revival stuff * Document type stuff * Bob and player height stuff * Name a few more things (some of the names are bad but whatever) * Finally move Vec3f data inline like I've wanted to do for ages * Some more low-hanging fruit * limbRot name * Name the chew stuff * First pass names on everything, even if they're bad * Some last-minute stuff before PR * Respond to Elliptic's review * Manually specify texture dimensions * Format * Add comment about pointless check * Respond to Elliptic's second review --- assets/xml/objects/object_raf.xml | 92 ++- spec | 3 +- src/overlays/actors/ovl_En_Raf/z_en_raf.c | 917 ++++++++++++++++++++-- src/overlays/actors/ovl_En_Raf/z_en_raf.h | 56 +- tools/disasm/functions.txt | 46 +- tools/disasm/variables.txt | 14 +- undefined_syms.txt | 9 - 7 files changed, 1004 insertions(+), 133 deletions(-) diff --git a/assets/xml/objects/object_raf.xml b/assets/xml/objects/object_raf.xml index 26c0741ec..e3b4d2d93 100644 --- a/assets/xml/objects/object_raf.xml +++ b/assets/xml/objects/object_raf.xml @@ -1,42 +1,58 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index 4ad4ae5c8..065f9a715 100644 --- a/spec +++ b/spec @@ -2547,8 +2547,7 @@ beginseg name "ovl_En_Raf" compress include "build/src/overlays/actors/ovl_En_Raf/z_en_raf.o" - include "build/data/ovl_En_Raf/ovl_En_Raf.data.o" - include "build/data/ovl_En_Raf/ovl_En_Raf.reloc.o" + include "build/src/overlays/actors/ovl_En_Raf/ovl_En_Raf_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.c b/src/overlays/actors/ovl_En_Raf/z_en_raf.c index a32811620..4d880a389 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.c +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.c @@ -1,7 +1,7 @@ /* * File: z_en_raf.c * Overlay: ovl_En_Raf - * Description: Carnivorous Lilypad + * Description: Carnivorous Lily Pad */ #include "z_en_raf.h" @@ -15,16 +15,58 @@ void EnRaf_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRaf_Update(Actor* thisx, GlobalContext* globalCtx); void EnRaf_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A171D8(EnRaf* this, GlobalContext* globalCtx); -void func_80A17464(EnRaf* this, GlobalContext* globalCtx); -void func_80A175E4(EnRaf* this, GlobalContext* globalCtx); -void func_80A178A0(EnRaf* this, GlobalContext* globalCtx); -void func_80A17C6C(EnRaf* this, GlobalContext* globalCtx); -void func_80A17D54(EnRaf* this, GlobalContext* globalCtx); -void func_80A17E1C(EnRaf* this, GlobalContext* globalCtx); -void func_80A180B4(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupIdle(EnRaf* this); +void EnRaf_Idle(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupGrab(EnRaf* this); +void EnRaf_Grab(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupChew(EnRaf* this); +void EnRaf_Chew(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupThrow(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_Throw(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_Explode(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_PostDetonation(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_Convulse(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupDissolve(EnRaf* this); +void EnRaf_Dissolve(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_SetupDormant(EnRaf* this); +void EnRaf_Dormant(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_InitializeParticle(EnRaf* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, s16 timer); +void EnRaf_UpdateParticles(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_DrawParticles(EnRaf* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ EN_RAF_ANIMATION_IDLE, + /* 1 */ EN_RAF_ANIMATION_CLOSE, + /* 2 */ EN_RAF_ANIMATION_CHEW, + /* 3 */ EN_RAF_ANIMATION_SPIT, + /* 4 */ EN_RAF_ANIMATION_CONVULSE, + /* 5 */ EN_RAF_ANIMATION_DEATH, +} EnRafAnimationIndex; + +typedef enum { + /* 0 */ EN_RAF_ACTION_IDLE, + /* 1 */ EN_RAF_ACTION_GRAB, + /* 2 */ EN_RAF_ACTION_CHEW, + /* 3 */ EN_RAF_ACTION_THROW, + /* 4 */ EN_RAF_ACTION_EXPLODE, + /* 5 */ EN_RAF_ACTION_CONVULSE, + /* 6 */ EN_RAF_ACTION_DISSOLVE, + /* 7 */ EN_RAF_ACTION_DORMANT, +} EnRafAction; + +typedef enum { + /* 0 */ EN_RAF_GRAB_TARGET_PLAYER, + /* 1 */ EN_RAF_GRAB_TARGET_EXPLOSIVE, + /* 2 */ EN_RAF_GRAB_TARGET_GORON_PLAYER +} EnRafGrabTarget; + +typedef enum { + /* 0 */ EN_RAF_PETAL_SCALE_TYPE_DEAD, + /* 1 */ EN_RAF_PETAL_SCALE_TYPE_GRAB, + /* 2 */ EN_RAF_PETAL_SCALE_TYPE_CHEW, + /* 3 */ EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW +} EnRafPetalScaleType; -#if 0 const ActorInit En_Raf_InitVars = { ACTOR_EN_RAF, ACTORCAT_PROP, @@ -37,15 +79,71 @@ const ActorInit En_Raf_InitVars = { (ActorFunc)EnRaf_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A18EE0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 50, 10, -10, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80A1939C = { +static u8 sTeethClearPixelTableFirstPass[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, + 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, +}; + +static u8 sTeethClearPixelTableSecondPass[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +}; + +static u8 sPetalClearPixelTableFirstPass[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, + 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, + 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, + 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, + 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, + 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, + 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, + 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, +}; + +static u8 sPetalClearPixelTableSecondPass[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +}; + +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0xF), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -80,65 +178,786 @@ static DamageTable D_80A1939C = { /* Powder Keg */ DMG_ENTRY(0, 0xF), }; -#endif +/** + * Sets the `index`th pixel of the trap teeth texture to 0 (transparent black) + * according to the `clearPixelTable`. Only works if the texture uses 16-bit pixels. + */ +void EnRaf_ClearPixelTeeth(u16* texture, u8* clearPixelTable, s32 index) { + if ((index < (8 * 8)) && (clearPixelTable[index] != 0)) { + texture[index] = 0; + } +} -extern ColliderCylinderInit D_80A18EE0; -extern DamageTable D_80A1939C; +/** + * Sets the `index`th pixel of the trap petal texture to 0 (transparent black) + * according to the `clearPixelTable`. Only works if the texture uses 16-bit pixels. + */ +void EnRaf_ClearPixelPetal(u16* texture, u8* clearPixelTable, s32 index) { + if (clearPixelTable[index] != 0) { + texture[index] = 0; + } +} -extern UNK_TYPE D_06000108; -extern UNK_TYPE D_060024E0; -extern UNK_TYPE D_060032F8; +void EnRaf_Init(Actor* thisx, GlobalContext* globalCtx) { + EnRaf* this = THIS; + Vec3f limbScale = { 1.0f, 1.0f, 1.0f }; + s32 pad; + s32 i; + CollisionHeader* colHeader = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A16D40.s") + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&gCarnivorousLilyPadCol, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + this->dyna.actor.targetMode = 3; + this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCarnivorousLilyPadSkel, &gCarnivorousLilyPadSpitAnim, + this->jointTable, this->morphTable, CARNIVOROUS_LILY_PAD_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A16D6C.s") + for (i = 0; i < ARRAY_COUNT(this->limbScale); i++) { + Math_Vec3f_Copy(&this->targetLimbScale[i], &limbScale); + Math_Vec3f_Copy(&this->limbScale[i], &limbScale); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/EnRaf_Init.s") + this->dyna.actor.colChkInfo.damageTable = &sDamageTable; + this->dyna.actor.colChkInfo.health = BREG(1) + 2; + this->mainType = EN_RAF_GET_TYPE(&this->dyna.actor); + this->reviveTimer = EN_RAF_GET_REVIVE_TIMER(&this->dyna.actor); + this->switchFlag = EN_RAF_GET_SWITCH_FLAG(&this->dyna.actor); + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/EnRaf_Destroy.s") + if (this->reviveTimer == 31) { + this->reviveTimer = -1; + } else { + this->reviveTimer = 30; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17060.s") + if (((this->switchFlag >= 0) || (this->mainType == EN_RAF_TYPE_DORMANT) || + (gSaveContext.save.weekEventReg[12] & 1)) && + ((Flags_GetSwitch(globalCtx, this->switchFlag)) || (this->mainType == EN_RAF_TYPE_DORMANT))) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A1712C.s") + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; + i++) { + Math_Vec3f_Copy(&this->limbScale[i], &gZeroVec3f); + Math_Vec3f_Copy(&this->targetLimbScale[i], &gZeroVec3f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A171D8.s") + EnRaf_SetupDormant(this); + } else { + this->bobPhase = Rand_ZeroFloat(1.0f) * 20000.0f; + Actor_SetScale(&this->dyna.actor, 0.01f); + EnRaf_SetupIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17414.s") +void EnRaf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnRaf* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17464.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17530.s") +void EnRaf_ChangeAnimation(EnRaf* this, s32 index) { + static AnimationHeader* sAnimations[] = { + &gCarnivorousLilyPadSpitAnim, &gCarnivorousLilyPadCloseAnim, &gCarnivorousLilyPadChewAnim, + &gCarnivorousLilyPadSpitAnim, &gCarnivorousLilyPadConvulseAnim, &gCarnivorousLilyPadDeathAnim, + }; + static u8 sAnimationModes[] = { + ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, + }; + f32 startFrame = 0.0f; + f32 playSpeed = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A175E4.s") + this->endFrame = Animation_GetLastFrame(sAnimations[index]); + if (index == EN_RAF_ANIMATION_IDLE) { + startFrame = this->endFrame; + } else if (index == EN_RAF_ANIMATION_CLOSE) { + playSpeed = 2.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17848.s") + Animation_Change(&this->skelAnime, sAnimations[index], playSpeed, startFrame, this->endFrame, + sAnimationModes[index], -4.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A178A0.s") +void EnRaf_SetupIdle(EnRaf* this) { + Vec3f targetLimbScale = { 1.0f, 1.0f, 1.0f }; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A179C8.s") + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_IDLE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17C6C.s") + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; i++) { + Math_Vec3f_Copy(&this->targetLimbScale[i], &targetLimbScale); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17D14.s") + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW; + this->action = EN_RAF_ACTION_IDLE; + this->actionFunc = EnRaf_Idle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17D54.s") +/** + * Sits around waiting for the player or an explosive to get near in order to grab them. + */ +void EnRaf_Idle(EnRaf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Actor* explosive; + f32 xDiff; + f32 yDiff; + f32 zDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17DDC.s") + if (this->timer == 0) { + if ((player->transformation != PLAYER_FORM_DEKU) && + (this->dyna.actor.xzDistToPlayer < (BREG(48) + 80.0f) && (player->invincibilityTimer == 0) && + DynaPolyActor_IsInRidingMovingState(&this->dyna) && !(player->stateFlags1 & 0x8000000) && + globalCtx->grabPlayer(globalCtx, player))) { + player->actor.parent = &this->dyna.actor; + this->grabTarget = EN_RAF_GRAB_TARGET_PLAYER; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A17E1C.s") + if (player->transformation == PLAYER_FORM_GORON) { + this->grabTarget = EN_RAF_GRAB_TARGET_GORON_PLAYER; + } else { + player->unk_AE8 = 50; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A18080.s") + this->playerRotYWhenGrabbed = player->actor.world.rot.y; + EnRaf_SetupGrab(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A180B4.s") + if ((globalCtx->gameplayFrames % 2) == 0) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/EnRaf_Update.s") + explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + while (explosive != NULL) { + // This check is pointless, since EnRaf is never in the explosive category. + if ((EnRaf*)explosive == this) { + explosive = explosive->next; + continue; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A1859C.s") + xDiff = explosive->world.pos.x - this->dyna.actor.world.pos.x; + yDiff = explosive->world.pos.y - this->dyna.actor.world.pos.y; + zDiff = explosive->world.pos.z - this->dyna.actor.world.pos.z; + if ((fabsf(xDiff) < 80.0f) && (fabsf(yDiff) < 30.0f) && (fabsf(zDiff) < 80.0f) && + (explosive->update != NULL) && (explosive->velocity.y != 0.0f)) { + Actor_MarkForDeath(explosive); + this->grabTarget = EN_RAF_GRAB_TARGET_EXPLOSIVE; + this->collider.dim.radius = 30; + this->collider.dim.height = 90; + this->collider.dim.yShift = -10; + EnRaf_SetupGrab(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/EnRaf_Draw.s") + explosive = explosive->next; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A18A90.s") +void EnRaf_SetupGrab(EnRaf* this) { + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_CLOSE); + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_GRAB; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_DRINK); + this->action = EN_RAF_ACTION_GRAB; + this->actionFunc = EnRaf_Grab; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A18B8C.s") +/** + * Grabs the player or explosive that entered its range. + */ +void EnRaf_Grab(EnRaf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 curFrame = this->skelAnime.curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Raf/func_80A18DA0.s") + if ((this->grabTarget != EN_RAF_GRAB_TARGET_EXPLOSIVE) && (player->stateFlags2 & 0x80) && + (&this->dyna.actor == player->actor.parent)) { + Math_ApproachF(&player->actor.world.pos.x, this->dyna.actor.world.pos.x, 0.3f, 10.0f); + Math_ApproachF(&player->actor.world.pos.y, this->dyna.actor.world.pos.y, 0.3f, 10.0f); + Math_ApproachF(&player->actor.world.pos.z, this->dyna.actor.world.pos.z, 0.3f, 10.0f); + } + + if (this->endFrame <= curFrame) { + EnRaf_SetupChew(this); + } +} + +void EnRaf_SetupChew(EnRaf* this) { + s32 i; + + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_CHEW); + this->chewCount = 0; + for (i = 0; i < ARRAY_COUNT(this->chewLimbRot); i++) { + this->chewLimbRot[i].x = Rand_S16Offset(8, 8) << 8; + this->chewLimbRot[i].y = Rand_S16Offset(8, 8) << 8; + this->chewLimbRot[i].z = Rand_S16Offset(8, 8) << 8; + } + + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_CHEW; + this->action = EN_RAF_ACTION_CHEW; + this->actionFunc = EnRaf_Chew; +} + +/** + * Chews the player or explosive that was grabbed. If it grabbed a non-Goron player, it will deal + * damage to them and eventually throw them. If it grabbed a Goron player or explosive, it will + * instead explode after chewing them a bit. + */ +void EnRaf_Chew(EnRaf* this, GlobalContext* globalCtx) { + f32 targetChewScale; + f32 curFrame; + Player* player = GET_PLAYER(globalCtx); + + curFrame = this->skelAnime.curFrame; + targetChewScale = (BREG(51) / 100.0f) + 0.2f; + Math_ApproachF(&this->chewScale, targetChewScale, 0.2f, 0.03f); + + if ((player->stateFlags2 & 0x80) && (this->grabTarget != EN_RAF_GRAB_TARGET_EXPLOSIVE) && + (&this->dyna.actor == player->actor.parent)) { + Math_ApproachF(&player->actor.world.pos.x, this->dyna.actor.world.pos.x, 0.3f, 10.0f); + Math_ApproachF(&player->actor.world.pos.y, this->dyna.actor.world.pos.y, 0.3f, 10.0f); + Math_ApproachF(&player->actor.world.pos.z, this->dyna.actor.world.pos.z, 0.3f, 10.0f); + } + + if (this->endFrame <= curFrame) { + if (BREG(52) == 0) { + this->chewCount++; + } + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_EAT); + switch (this->grabTarget) { + case EN_RAF_GRAB_TARGET_PLAYER: + globalCtx->damagePlayer(globalCtx, -2); + func_800B8E58((Player*)this, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); + CollisionCheck_GreenBlood(globalCtx, NULL, &player->actor.world.pos); + if ((this->chewCount > (BREG(53) + 5)) || !(player->stateFlags2 & 0x80)) { + player->actor.freezeTimer = 10; + EnRaf_SetupThrow(this, globalCtx); + return; + } + break; + + case EN_RAF_GRAB_TARGET_EXPLOSIVE: + Actor_ApplyDamage(&this->dyna.actor); + if (this->chewCount > (BREG(54) + 4)) { + EnRaf_Explode(this, globalCtx); + return; + } + break; + + case EN_RAF_GRAB_TARGET_GORON_PLAYER: + if (this->chewCount > (BREG(54) + 4)) { + player->actor.parent = NULL; + player->unk_AE8 = 1000; + EnRaf_Explode(this, globalCtx); + } + break; + } + } +} + +void EnRaf_SetupThrow(EnRaf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_SPIT); + player->actor.freezeTimer = 10; + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW; + this->action = EN_RAF_ACTION_THROW; + this->actionFunc = EnRaf_Throw; +} + +/** + * Spits out the grabbed player. + */ +void EnRaf_Throw(EnRaf* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 curFrame = this->skelAnime.curFrame; + + if (Animation_OnFrame(&this->skelAnime, 10.0f)) { + player->actor.freezeTimer = 0; + player->actor.parent = NULL; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_THROW); + func_800B8D50(globalCtx, &this->dyna.actor, BREG(55) + 3.0f, this->playerRotYWhenGrabbed + 0x8000, + BREG(56) + 10.0f, 0); + } else if (curFrame < 10.0f) { + player->actor.freezeTimer = 10; + } + + if (this->endFrame <= curFrame) { + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW; + this->action = EN_RAF_ACTION_IDLE; + this->timer = 20; + this->actionFunc = EnRaf_Idle; + } +} + +/** + * Creates an explosion effect/sound and spawns particles. + */ +void EnRaf_Explode(EnRaf* this, GlobalContext* globalCtx) { + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; + Vec3f acceleration = { 0.0f, 0.0f, 0.0f }; + Vec3f explosionPos; + s32 i; + s32 pad; + + this->action = EN_RAF_ACTION_EXPLODE; + Math_Vec3f_Copy(&explosionPos, &this->dyna.actor.world.pos); + explosionPos.y += 10.0f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, explosionPos.x, explosionPos.y, explosionPos.z, 0, + 0, 0, CLEAR_TAG_SMALL_EXPLOSION); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_BOMB_EXPLOSION); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_DEAD); + if (this->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, this->switchFlag); + } + + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_DEAD; + for (i = 0; i < BREG(57) + 30; i++) { + acceleration.x = (Rand_ZeroOne() - 0.5f) * 0.5f; + acceleration.y = -0.3f; + acceleration.z = (Rand_ZeroOne() - 0.5f) * 0.5f; + velocity.x = Rand_ZeroOne() - 0.5f; + velocity.y = Rand_ZeroOne() * 10.0f; + velocity.z = Rand_ZeroOne() - 0.5f; + EnRaf_InitializeParticle(this, &this->dyna.actor.world.pos, &velocity, &acceleration, + (Rand_ZeroFloat(1.0f) / 500.0f) + 0.002f, 90); + } + + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; i++) { + Math_Vec3f_Copy(&this->targetLimbScale[i], &gZeroVec3f); + } + + this->timer = 5; + if (this->grabTarget == EN_RAF_GRAB_TARGET_EXPLOSIVE) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, 5); + this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); + } + + this->actionFunc = EnRaf_PostDetonation; +} + +/** + * Switches the lily pad to the "dead" state once the timer reaches 0. + */ +void EnRaf_PostDetonation(EnRaf* this, GlobalContext* globalCtx) { + if (this->timer == 0) { + this->collider.dim.radius = 50; + this->collider.dim.height = 10; + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, 6); + this->dyna.actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + EnRaf_SetupDormant(this); + } else if (this->grabTarget == EN_RAF_GRAB_TARGET_EXPLOSIVE) { + this->collider.dim.radius = 80; + this->collider.dim.height = 50; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void EnRaf_SetupConvulse(EnRaf* this) { + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_CONVULSE); + this->chewCount = 0; + this->action = EN_RAF_ACTION_CONVULSE; + this->actionFunc = EnRaf_Convulse; +} + +/** + * Plays the convulsing animation and sets the lily pad's switch flag to prevent it from + * ever coming back to life. When the water in Woodfall Temple is purified, this function + * and EnRaf_Dissolve are jointly responsible for controlling the lily pad's death. + */ +void EnRaf_Convulse(EnRaf* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->endFrame <= curFrame) { + this->chewCount++; + if (this->chewCount > (BREG(2) + 2)) { + if (this->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, this->switchFlag); + } + + EnRaf_SetupDissolve(this); + } + } +} + +void EnRaf_SetupDissolve(EnRaf* this) { + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_DEATH); + this->action = EN_RAF_ACTION_DISSOLVE; + this->dissolveTimer = 0; + this->actionFunc = EnRaf_Dissolve; +} + +/** + * Makes the trap petals on the lily pad dissolve and switches the lily pad to the "dead" state. + * When the water in Woodfall Temple is purified, this function and EnRaf_Convulse are jointly + * responsible for controlling the lily pad's death. + */ +void EnRaf_Dissolve(EnRaf* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + s32 i; + + if (this->endFrame <= curFrame) { + this->dissolveTimer++; + if (this->dissolveTimer < (BREG(3) + 105)) { + for (i = 0; i < (BREG(4) + 5); i++) { + EnRaf_ClearPixelPetal(Lib_SegmentedToVirtual(&gCarnivorousLilyPadTrapPetalTex), + sPetalClearPixelTableFirstPass, this->petalClearPixelFirstPassIndex); + EnRaf_ClearPixelTeeth(Lib_SegmentedToVirtual(&gCarnivorousLilyPadTrapTeethTex), + sTeethClearPixelTableFirstPass, this->teethClearPixelFirstPassIndex); + if (this->petalClearPixelFirstPassIndex < (16 * 32)) { + this->petalClearPixelFirstPassIndex++; + } + + if (this->teethClearPixelFirstPassIndex < (8 * 8)) { + this->teethClearPixelFirstPassIndex++; + } + } + } + } + + if (this->dissolveTimer > (BREG(5) + 50)) { + for (i = 0; i < (BREG(6) + 5); i++) { + EnRaf_ClearPixelPetal(Lib_SegmentedToVirtual(&gCarnivorousLilyPadTrapPetalTex), + sPetalClearPixelTableSecondPass, this->petalClearPixelSecondPassIndex); + EnRaf_ClearPixelTeeth(Lib_SegmentedToVirtual(&gCarnivorousLilyPadTrapTeethTex), + sTeethClearPixelTableSecondPass, this->teethClearPixelSecondPassIndex); + if (this->petalClearPixelSecondPassIndex < (16 * 32)) { + this->petalClearPixelSecondPassIndex++; + } + + if (this->teethClearPixelSecondPassIndex < (8 * 8)) { + this->teethClearPixelSecondPassIndex++; + } + } + } + + if (this->dissolveTimer > (BREG(7) + 160)) { + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; + i++) { + Math_Vec3f_Copy(&this->limbScale[i], &gZeroVec3f); + Math_Vec3f_Copy(&this->targetLimbScale[i], &gZeroVec3f); + } + + EnRaf_SetupDormant(this); + } +} + +void EnRaf_SetupDormant(EnRaf* this) { + if (this->action == EN_RAF_ACTION_EXPLODE) { + this->timer = 90; + } else { + this->action = EN_RAF_ACTION_DORMANT; + } + + this->actionFunc = EnRaf_Dormant; +} + +/** + * Simply sits around doing nothing. If the revive timer is non-zero, then this function + * will decrement the revive timer and revive the trap petals once it reaches 0. + */ +void EnRaf_Dormant(EnRaf* this, GlobalContext* globalCtx) { + Vec3f targetLimbScale = { 1.0f, 1.0f, 1.0f }; + s32 i; + + if (this->timer == 0) { + this->action = EN_RAF_ACTION_DORMANT; + } + + if (this->reviveTimer >= 0) { + DECR(this->reviveTimer); + + if (this->reviveTimer == 0) { + EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_SPIT); + + for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; + i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; i++) { + Math_Vec3f_Copy(&this->targetLimbScale[i], &targetLimbScale); + } + + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW; + this->action = EN_RAF_ACTION_IDLE; + this->reviveTimer = EN_RAF_GET_REVIVE_TIMER(&this->dyna.actor); + this->reviveTimer += 30; + this->actionFunc = EnRaf_Idle; + } + } +} + +void EnRaf_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRaf* this = THIS; + WaterBox* waterBox; + f32 ySurface; + Vec3f ripplePos; + s32 i; + + SkelAnime_Update(&this->skelAnime); + DECR(this->rippleTimer); + DECR(this->timer); + this->actionFunc(this, globalCtx); + + if ((this->action == EN_RAF_ACTION_IDLE) && (gSaveContext.save.weekEventReg[12] & 1)) { + this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_DEAD; + EnRaf_SetupConvulse(this); + return; + } + + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if ((this->heightDiffFromPlayer > -0.1f) && !this->isCurrentlyInRidingMovingState) { + this->heightDiffFromPlayer = -20.0f; + this->isCurrentlyInRidingMovingState = true; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_COMMON_WATER_MID); + } + } else { + this->isCurrentlyInRidingMovingState = false; + } + + this->bobPhase += 3000.0f; + this->bobOffset = 2.0f * Math_SinS(this->bobPhase); + if (this->mainType != EN_RAF_TYPE_NO_WATER_INTERACTIONS) { + ySurface = BREG(60) + (this->dyna.actor.world.pos.y - 60.0f); + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.z, &ySurface, &waterBox)) { + ySurface -= this->bobOffset + BREG(59); + Math_ApproachF(&this->dyna.actor.world.pos.y, this->heightDiffFromPlayer + ySurface, 0.5f, 40.0f); + if (this->rippleTimer == 0) { + this->rippleTimer = 30; + if (this->petalScaleType == EN_RAF_PETAL_SCALE_TYPE_CHEW) { + this->rippleTimer = 10; + } + + Math_Vec3f_Copy(&ripplePos, &this->dyna.actor.world.pos); + ripplePos.y = ySurface; + EffectSsGRipple_Spawn(globalCtx, &ripplePos, 650, 3150, 0); + } + } + } else { + Math_ApproachF(&this->dyna.actor.world.pos.y, + (this->dyna.actor.home.pos.y + this->heightDiffFromPlayer) - this->bobOffset, 0.5f, 40.0f); + } + + Math_ApproachZeroF(&this->heightDiffFromPlayer, 0.3f, 2.0f); + if (this->action == EN_RAF_ACTION_EXPLODE) { + EnRaf_UpdateParticles(this, globalCtx); + } + + for (i = 0; i < ARRAY_COUNT(this->limbScale); i++) { + if (this->action < EN_RAF_ACTION_EXPLODE) { + Math_ApproachF(&this->limbScale[i].x, this->targetLimbScale[i].x, 0.4f, 0.5f); + Math_ApproachF(&this->limbScale[i].y, this->targetLimbScale[i].y, 0.4f, 0.5f); + Math_ApproachF(&this->limbScale[i].z, this->targetLimbScale[i].z, 0.4f, 0.5f); + } else { + Math_ApproachF(&this->limbScale[i].x, this->targetLimbScale[i].x, 1.0f, 1.0f); + Math_ApproachF(&this->limbScale[i].y, this->targetLimbScale[i].y, 1.0f, 1.0f); + Math_ApproachF(&this->limbScale[i].z, this->targetLimbScale[i].z, 1.0f, 1.0f); + } + } + + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + if (this->action < EN_RAF_ACTION_EXPLODE) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +static s16 sGrabAnimationCheckFrames[] = { 0, 4, 6 }; + +static Vec3f sMiddleSegmentTargetScaleDuringGrab[] = { + { 1.0f, 1.0f, 1.0f }, + { 1.0f, 2.0f, 1.0f }, + { 0.0f, 1.5f, 0.7f }, +}; + +static Vec3f sUpperSegmentTargetScaleDuringGrab[] = { + { 1.0f, 1.0f, 1.0f }, + { 3.0f, 2.0f, 1.5f }, + { 1.5f, 1.2f, 0.8f }, +}; + +static s16 sSpitAnimationCheckFrames[] = { 0, 7, 9, 13, 19 }; + +static Vec3f sMiddleSegmentTargetScaleDuringSpit[] = { + { 1.0f, 1.5f, 0.7f }, { 1.0f, 2.0f, 1.5f }, { 1.0f, 2.0f, 0.5f }, { 1.0f, 2.0f, 0.5f }, { 1.0f, 1.0f, 1.0f }, +}; + +static Vec3f sUpperSegmentTargetScaleDuringSpit[] = { + { 1.5f, 1.5f, 1.7f }, { 1.5f, 1.5f, 1.3f }, { 3.0f, 1.0f, 0.5f }, { 1.0f, 1.0f, 0.5f }, { 1.0f, 1.0f, 1.0f }, +}; + +void EnRaf_TransformLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Actor* thisx) { + GlobalContext* globalCtx = globalCtx2; + EnRaf* this = THIS; + s32 i; + + switch (this->petalScaleType) { + case EN_RAF_PETAL_SCALE_TYPE_GRAB: + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_MIDDLE_SEGMENT)) { + for (i = 0; i < ARRAY_COUNT(sGrabAnimationCheckFrames); i++) { + if ((s16)this->skelAnime.curFrame == sGrabAnimationCheckFrames[i]) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sMiddleSegmentTargetScaleDuringGrab[i]); + } + } + } + + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_UPPER_SEGMENT)) { + for (i = 0; i < ARRAY_COUNT(sGrabAnimationCheckFrames); i++) { + if ((s16)this->skelAnime.curFrame == sGrabAnimationCheckFrames[i]) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sUpperSegmentTargetScaleDuringGrab[i]); + } + } + } + break; + + case EN_RAF_PETAL_SCALE_TYPE_CHEW: + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_MIDDLE_SEGMENT)) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sMiddleSegmentTargetScaleDuringGrab[2]); + } else if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_UPPER_SEGMENT)) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sUpperSegmentTargetScaleDuringGrab[2]); + } + + // These matrix operations make the trap petals look a bit more "wobbly" as it chews + // by stretching the limbs in various random directions. + if ((limbIndex > CARNIVOROUS_LILY_PAD_LIMB_FLOWER) && (limbIndex < CARNIVOROUS_LILY_PAD_LIMB_ROOTS)) { + Matrix_RotateY((this->chewLimbRot[limbIndex].y * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_InsertXRotation_s((this->chewLimbRot[limbIndex].x * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_InsertZRotation_s((this->chewLimbRot[limbIndex].z * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_Scale(this->chewScale + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-(this->chewLimbRot[limbIndex].z * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_InsertXRotation_s(-(this->chewLimbRot[limbIndex].x * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateY(-(this->chewLimbRot[limbIndex].y * globalCtx->gameplayFrames), MTXMODE_APPLY); + } + break; + + case EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW: + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_MIDDLE_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_MIDDLE_SEGMENT)) { + for (i = 0; i < ARRAY_COUNT(sSpitAnimationCheckFrames); i++) { + if ((s16)this->skelAnime.curFrame == sSpitAnimationCheckFrames[i]) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sMiddleSegmentTargetScaleDuringSpit[i]); + } + } + } + + if ((limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT) || + (limbIndex == CARNIVOROUS_LILY_PAD_LIMB_TRAP_2_UPPER_SEGMENT)) { + for (i = 0; i < 4; i++) { + if ((s16)this->skelAnime.curFrame == sSpitAnimationCheckFrames[i]) { + Math_Vec3f_Copy(&this->targetLimbScale[limbIndex], &sUpperSegmentTargetScaleDuringSpit[i]); + } + } + } + break; + } + + Matrix_Scale(this->limbScale[limbIndex].x, this->limbScale[limbIndex].y, this->limbScale[limbIndex].z, + MTXMODE_APPLY); +} + +void EnRaf_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnRaf* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, NULL, EnRaf_TransformLimbDraw, &this->dyna.actor); + + if (this->action == EN_RAF_ACTION_EXPLODE) { + EnRaf_DrawParticles(this, globalCtx); + } +} + +void EnRaf_InitializeParticle(EnRaf* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, + s16 timer) { + s16 i; + EnRafParticle* particle = this->particles; + + for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { + if (!particle->isVisible) { + particle->isVisible = true; + particle->position = *position; + particle->velocity = *velocity; + particle->acceleration = *acceleration; + particle->scale = scale; + particle->timer = timer; + particle->rotation.x = randPlusMinusPoint5Scaled(30000.0f); + particle->rotation.y = randPlusMinusPoint5Scaled(30000.0f); + particle->rotation.z = randPlusMinusPoint5Scaled(30000.0f); + return; + } + } +} + +void EnRaf_UpdateParticles(EnRaf* this, GlobalContext* globalCtx) { + s32 i; + EnRafParticle* particle = this->particles; + + for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { + if (particle->isVisible) { + particle->position.x += particle->velocity.x; + particle->position.y += particle->velocity.y; + particle->position.z += particle->velocity.z; + particle->rotation.x += 0xBB8; + particle->rotation.y += 0xBB8; + particle->rotation.z += 0xBB8; + particle->velocity.x += particle->acceleration.x; + particle->velocity.y += particle->acceleration.y; + particle->velocity.z += particle->acceleration.z; + + if (this->mainType != EN_RAF_TYPE_NO_WATER_INTERACTIONS) { + if (particle->position.y < (this->dyna.actor.world.pos.y - 10.0f)) { + EffectSsGSplash_Spawn(globalCtx, &particle->position, NULL, NULL, 0, particle->scale * 200000.0f); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &particle->position, 50, NA_SE_EV_BOMB_DROP_WATER); + particle->isVisible = false; + } + } else if (particle->position.y < (this->dyna.actor.world.pos.y - 10.0f)) { + Math_ApproachZeroF(&particle->scale, 0.2f, 0.001f); + if (particle->scale <= 0.0001f) { + particle->timer = 0; + } + } + + if (particle->timer != 0) { + particle->timer--; + } else { + particle->isVisible = false; + } + } + } +} + +void EnRaf_DrawParticles(EnRaf* this, GlobalContext* globalCtx) { + s16 i; + EnRafParticle* particle = this->particles; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { + if (particle->isVisible) { + Matrix_InsertTranslation(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); + Matrix_Scale(particle->scale, particle->scale, particle->scale, MTXMODE_APPLY); + Matrix_InsertXRotation_s(particle->rotation.x, MTXMODE_APPLY); + Matrix_RotateY(particle->rotation.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(particle->rotation.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gCarnivorousLilyPadParticleDL); + } + } + + CLOSE_DISPS(gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.h b/src/overlays/actors/ovl_En_Raf/z_en_raf.h index 95ddfc54d..f63924402 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.h +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.h @@ -2,16 +2,64 @@ #define Z_EN_RAF_H #include "global.h" +#include "objects/object_raf/object_raf.h" + +#define EN_RAF_GET_TYPE(thisx) (((thisx)->params >> 12) & 0xF) +#define EN_RAF_GET_REVIVE_TIMER(thisx) (((thisx)->params >> 7) & 0x1F) +#define EN_RAF_GET_SWITCH_FLAG(thisx) ((thisx)->params & 0x7F) + +typedef enum { + /* 0 */ EN_RAF_TYPE_NORMAL, + /* 1 */ EN_RAF_TYPE_DORMANT, // Spawns without trap, so it can't eat bombs/player + /* 2 */ EN_RAF_TYPE_NO_WATER_INTERACTIONS // Won't produce ripples, and particles won't produce splashes +} EnRafType; struct EnRaf; typedef void (*EnRafActionFunc)(struct EnRaf*, GlobalContext*); +typedef struct { + /* 0x00 */ u8 isVisible; + /* 0x04 */ Vec3f position; + /* 0x10 */ Vec3f velocity; + /* 0x1C */ Vec3f acceleration; + /* 0x28 */ Vec3s rotation; + /* 0x30 */ f32 scale; + /* 0x34 */ s16 timer; +} EnRafParticle; // size = 0x38 + typedef struct EnRaf { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xEC]; - /* 0x0230 */ EnRafActionFunc actionFunc; - /* 0x0234 */ char unk_234[0x8B0]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ Vec3s jointTable[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x230 */ EnRafActionFunc actionFunc; + /* 0x234 */ Vec3f limbScale[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x2C4 */ Vec3f targetLimbScale[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x354 */ Vec3s chewLimbRot[CARNIVOROUS_LILY_PAD_LIMB_MAX]; + /* 0x39C */ s16 grabTarget; + /* 0x39E */ u8 isCurrentlyInRidingMovingState; + /* 0x3A0 */ f32 endFrame; + /* 0x3A4 */ f32 chewScale; + /* 0x3A8 */ f32 bobOffset; + /* 0x3AC */ f32 heightDiffFromPlayer; + /* 0x3B0 */ f32 bobPhase; + /* 0x3B4 */ s16 timer; + /* 0x3B6 */ s16 dissolveTimer; + /* 0x3B8 */ s16 rippleTimer; + /* 0x3BA */ s16 reviveTimer; + /* 0x3BC */ s16 playerRotYWhenGrabbed; + /* 0x3BE */ s16 mainType; + /* 0x3C0 */ s16 switchFlag; + /* 0x3C2 */ s16 petalScaleType; + /* 0x3C4 */ s16 chewCount; + /* 0x3C6 */ s16 action; + /* 0x3C8 */ s16 petalClearPixelFirstPassIndex; + /* 0x3CA */ s16 teethClearPixelFirstPassIndex; + /* 0x3CC */ s16 petalClearPixelSecondPassIndex; + /* 0x3CE */ s16 teethClearPixelSecondPassIndex; + /* 0x3D0 */ ColliderCylinder collider; + /* 0x41C */ EnRafParticle particles[31]; } EnRaf; // size = 0xAE4 extern const ActorInit En_Raf_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4980f109b..9c47caf4d 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -9745,33 +9745,33 @@ 0x80A15D04:("EnGo_OverrideLimbDraw",), 0x80A15E38:("EnGo_TransfromLimbDraw",), 0x80A15FEC:("func_80A15FEC",), - 0x80A16D40:("func_80A16D40",), - 0x80A16D6C:("func_80A16D6C",), + 0x80A16D40:("EnRaf_ClearPixelTeeth",), + 0x80A16D6C:("EnRaf_ClearPixelPetal",), 0x80A16D90:("EnRaf_Init",), 0x80A17018:("EnRaf_Destroy",), - 0x80A17060:("func_80A17060",), - 0x80A1712C:("func_80A1712C",), - 0x80A171D8:("func_80A171D8",), - 0x80A17414:("func_80A17414",), - 0x80A17464:("func_80A17464",), - 0x80A17530:("func_80A17530",), - 0x80A175E4:("func_80A175E4",), - 0x80A17848:("func_80A17848",), - 0x80A178A0:("func_80A178A0",), - 0x80A179C8:("func_80A179C8",), - 0x80A17C6C:("func_80A17C6C",), - 0x80A17D14:("func_80A17D14",), - 0x80A17D54:("func_80A17D54",), - 0x80A17DDC:("func_80A17DDC",), - 0x80A17E1C:("func_80A17E1C",), - 0x80A18080:("func_80A18080",), - 0x80A180B4:("func_80A180B4",), + 0x80A17060:("EnRaf_ChangeAnimation",), + 0x80A1712C:("EnRaf_SetupIdle",), + 0x80A171D8:("EnRaf_Idle",), + 0x80A17414:("EnRaf_SetupGrab",), + 0x80A17464:("EnRaf_Grab",), + 0x80A17530:("EnRaf_SetupChew",), + 0x80A175E4:("EnRaf_Chew",), + 0x80A17848:("EnRaf_SetupThrow",), + 0x80A178A0:("EnRaf_Throw",), + 0x80A179C8:("EnRaf_Explode",), + 0x80A17C6C:("EnRaf_PostDetonation",), + 0x80A17D14:("EnRaf_SetupConvulse",), + 0x80A17D54:("EnRaf_Convulse",), + 0x80A17DDC:("EnRaf_SetupDissolve",), + 0x80A17E1C:("EnRaf_Dissolve",), + 0x80A18080:("EnRaf_SetupDormant",), + 0x80A180B4:("EnRaf_Dormant",), 0x80A181B4:("EnRaf_Update",), - 0x80A1859C:("func_80A1859C",), + 0x80A1859C:("EnRaf_TransformLimbDraw",), 0x80A18A08:("EnRaf_Draw",), - 0x80A18A90:("func_80A18A90",), - 0x80A18B8C:("func_80A18B8C",), - 0x80A18DA0:("func_80A18DA0",), + 0x80A18A90:("EnRaf_InitializeParticle",), + 0x80A18B8C:("EnRaf_UpdateParticles",), + 0x80A18DA0:("EnRaf_DrawParticles",), 0x80A19740:("ObjFunen_Init",), 0x80A19778:("ObjFunen_Draw",), 0x80A19910:("ObjRaillift_UpdatePosition",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index c96b82408..e497bbcf3 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -10887,10 +10887,10 @@ 0x80A16818:("jtbl_80A16818","UNK_PTR","",0x4), 0x80A18EC0:("En_Raf_InitVars","UNK_TYPE1","",0x1), 0x80A18EE0:("D_80A18EE0","UNK_TYPE1","",0x1), - 0x80A18F0C:("D_80A18F0C","UNK_TYPE1","",0x1), - 0x80A18F4C:("D_80A18F4C","UNK_TYPE1","",0x1), - 0x80A18F8C:("D_80A18F8C","UNK_TYPE1","",0x1), - 0x80A1918C:("D_80A1918C","UNK_TYPE1","",0x1), + 0x80A18F0C:("D_80A18F0C","u8","[0x40]",0x40), + 0x80A18F4C:("D_80A18F4C","u8","[0x40]",0x40), + 0x80A18F8C:("D_80A18F8C","u8","[0x200]",0x200), + 0x80A1918C:("D_80A1918C","u8","[0x200]",0x200), 0x80A1939C:("D_80A1939C","UNK_TYPE1","",0x1), 0x80A193BC:("D_80A193BC","UNK_TYPE4","",0x4), 0x80A193C8:("D_80A193C8","UNK_TYPE1","",0x1), @@ -10900,10 +10900,8 @@ 0x80A19400:("D_80A19400","UNK_TYPE4","",0x4), 0x80A1940C:("D_80A1940C","UNK_TYPE4","",0x4), 0x80A19418:("D_80A19418","UNK_TYPE2","",0x2), - 0x80A19420:("D_80A19420","UNK_TYPE1","",0x1), - 0x80A19438:("D_80A19438","UNK_TYPE1","",0x1), - 0x80A19444:("D_80A19444","UNK_TYPE1","",0x1), - 0x80A1945C:("D_80A1945C","UNK_TYPE1","",0x1), + 0x80A19420:("D_80A19420","Vec3f","[3]",0x24), + 0x80A19444:("D_80A19444","Vec3f","[3]",0x24), 0x80A19468:("D_80A19468","UNK_TYPE2","",0x2), 0x80A19474:("D_80A19474","UNK_TYPE1","",0x1), 0x80A194B0:("D_80A194B0","UNK_TYPE1","",0x1), diff --git a/undefined_syms.txt b/undefined_syms.txt index 50065f57d..a4921f34a 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1441,15 +1441,6 @@ D_06004340 = 0x06004340; D_06001A80 = 0x06001A80; -// ovl_En_Raf - -D_06000108 = 0x06000108; -D_06000A64 = 0x06000A64; -D_060024E0 = 0x060024E0; -D_06002EF8 = 0x06002EF8; -D_060032F8 = 0x060032F8; -D_06003428 = 0x06003428; - // ovl_En_Rat D_06000174 = 0x06000174; From bb784413b9882687ae815a7549b6debb72537713 Mon Sep 17 00:00:00 2001 From: nckwntzl <101551652+nckwntzl@users.noreply.github.com> Date: Thu, 21 Apr 2022 22:45:16 -0400 Subject: [PATCH 197/257] ObjBlockStop OK and documented (#788) * init and func_809466F0 matching * fully matching * renamed functions * added include and used oshihiki macro * fixed spec to use correct reloc * ran format * cleaned up comments * addressed the suggestions and used macro in ObjBlockstop_Update * fixed one more cast * ran format.sh * EllipticEllipsis changes * ran format * renamed CheckCollision to CheckForBlock --- spec | 3 +- .../ovl_Obj_Blockstop/z_obj_blockstop.c | 50 ++++++++++++++++--- tools/disasm/functions.txt | 4 +- 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/spec b/spec index 065f9a715..2aa537db5 100644 --- a/spec +++ b/spec @@ -1547,8 +1547,7 @@ beginseg name "ovl_Obj_Blockstop" compress include "build/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.o" - include "build/data/ovl_Obj_Blockstop/ovl_Obj_Blockstop.data.o" - include "build/data/ovl_Obj_Blockstop/ovl_Obj_Blockstop.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Blockstop/ovl_Obj_Blockstop_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c index 0d937d1c0..2d3a6f2d5 100644 --- a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c +++ b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c @@ -5,6 +5,7 @@ */ #include "z_obj_blockstop.h" +#include "overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.h" #define FLAGS (ACTOR_FLAG_10) @@ -13,9 +14,9 @@ void ObjBlockstop_Init(Actor* thisx, GlobalContext* globalCtx); void ObjBlockstop_Update(Actor* thisx, GlobalContext* globalCtx); -void func_809466F0(ObjBlockstop* this, GlobalContext* globalCtx); +void ObjBlockstop_CheckForBlock(ObjBlockstop* this, GlobalContext* globalCtx); +void ObjBlockstop_TryPlayCutscene(ObjBlockstop* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Blockstop_InitVars = { ACTOR_OBJ_BLOCKSTOP, ACTORCAT_PROP, @@ -28,12 +29,47 @@ const ActorInit Obj_Blockstop_InitVars = { (ActorFunc)NULL, }; -#endif +void ObjBlockstop_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjBlockstop* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Blockstop/ObjBlockstop_Init.s") + if (Flags_GetSwitch(globalCtx, this->actor.params)) { + Actor_MarkForDeath(&this->actor); + } + this->actionFunc = ObjBlockstop_CheckForBlock; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Blockstop/func_809466F0.s") +void ObjBlockstop_CheckForBlock(ObjBlockstop* this, GlobalContext* globalCtx) { + Actor* prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Blockstop/func_809467E8.s") + while (prop != NULL) { + if ((prop->id == ACTOR_OBJ_OSHIHIKI) && (fabsf(prop->world.pos.x - this->actor.world.pos.x) < 20.0f) && + (fabsf(prop->world.pos.z - this->actor.world.pos.z) < 20.0f) && + (fabsf(prop->world.pos.y - this->actor.world.pos.y) < 20.0f)) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Blockstop/ObjBlockstop_Update.s") + s32 params = OBJOSHIHIKI_GET_F(prop); + if (params < 3) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = ObjBlockstop_TryPlayCutscene; + } + } + prop = prop->next; + } +} + +void ObjBlockstop_TryPlayCutscene(ObjBlockstop* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + Flags_SetSwitch(globalCtx, this->actor.params); + if (ActorCutscene_GetLength(this->actor.cutscene) != -1) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } + Actor_MarkForDeath(&this->actor); + return; + } + ActorCutscene_SetIntentToPlay(this->actor.cutscene); +} + +void ObjBlockstop_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjBlockstop* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 9c47caf4d..f759c2f9f 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -7553,8 +7553,8 @@ 0x80946368:("func_80946368",), 0x80946400:("EnGe1_Draw",), 0x809466A0:("ObjBlockstop_Init",), - 0x809466F0:("func_809466F0",), - 0x809467E8:("func_809467E8",), + 0x809466F0:("ObjBlockstop_CheckForBlock",), + 0x809467E8:("ObjBlockstop_TryPlayCutscene",), 0x8094685C:("ObjBlockstop_Update",), 0x809468D0:("EnSda_Init",), 0x809468E0:("EnSda_Destroy",), From cc759afc9e3a219e753f88ffd681d40c914778f7 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Thu, 21 Apr 2022 20:21:42 -0700 Subject: [PATCH 198/257] Bg_Sinkai_Kabe OK and documented, object_sinkai_kabe documented (#786) * Bg_Sinkai_Kabe OK and documented, object_sinkai_kabe documented * Respond to Elliptic's review * Drop "child" from deepPythonChild --- assets/xml/objects/object_sinkai_kabe.xml | 3 +- spec | 3 +- .../ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c | 128 ++++++++++++++++-- .../ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h | 11 +- .../actors/ovl_En_Dragon/z_en_dragon.c | 10 -- .../actors/ovl_En_Dragon/z_en_dragon.h | 10 ++ tools/disasm/functions.txt | 2 +- undefined_syms.txt | 4 - 8 files changed, 141 insertions(+), 30 deletions(-) diff --git a/assets/xml/objects/object_sinkai_kabe.xml b/assets/xml/objects/object_sinkai_kabe.xml index 96f8531ad..3c23a73ce 100644 --- a/assets/xml/objects/object_sinkai_kabe.xml +++ b/assets/xml/objects/object_sinkai_kabe.xml @@ -1,5 +1,6 @@  + - + diff --git a/spec b/spec index 2aa537db5..045619bcd 100644 --- a/spec +++ b/spec @@ -4095,8 +4095,7 @@ beginseg name "ovl_Bg_Sinkai_Kabe" compress include "build/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.o" - include "build/data/ovl_Bg_Sinkai_Kabe/ovl_Bg_Sinkai_Kabe.data.o" - include "build/data/ovl_Bg_Sinkai_Kabe/ovl_Bg_Sinkai_Kabe.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Sinkai_Kabe/ovl_Bg_Sinkai_Kabe_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c index e5af3fe1f..e5bba655d 100644 --- a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c +++ b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c @@ -1,10 +1,18 @@ /* * File: z_bg_sinkai_kabe.c * Overlay: ovl_Bg_Sinkai_Kabe - * Description: Manages the Deep Pythons and Seahorse in Pinnacle Rock + * Description: Manages the Deep Pythons in Pinnacle Rock + * + * While its name describes one of its responsibilities ("Deep Sea Wall", aka the invisible + * wall blocking a Deep Python's den before you defeat it), it is also responsible for + * spawning in the Deep Pythons when the area first loads, as well as signalling to the + * Deep Python that it should extend its body. Furthermore, if the player defeats all + * eight Deep Pythons and spawns the second Seahorse, this actor is responsible for spawning + * it again if the player leaves and re-enters Pinnacle Rock. */ #include "z_bg_sinkai_kabe.h" +#include "objects/object_sinkai_kabe/object_sinkai_kabe.h" #define FLAGS (ACTOR_FLAG_10) @@ -14,7 +22,8 @@ void BgSinkaiKabe_Init(Actor* thisx, GlobalContext* globalCtx); void BgSinkaiKabe_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSinkaiKabe_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void BgSinkaiKabe_WaitForPlayer(BgSinkaiKabe* this, GlobalContext* globalCtx); + const ActorInit Bg_Sinkai_Kabe_InitVars = { ACTOR_BG_SINKAI_KABE, ACTORCAT_ITEMACTION, @@ -27,14 +36,117 @@ const ActorInit Bg_Sinkai_Kabe_InitVars = { (ActorFunc)NULL, }; -#endif +static s32 sCurrentPythonIndex = 0; -extern UNK_TYPE D_06000048; +void BgSinkaiKabe_Init(Actor* thisx, GlobalContext* globalCtx) { + BgSinkaiKabe* this = THIS; + s32 pad; + CollisionHeader* colHeader = NULL; + Vec3f pos; + s32 pad2; + s32 shouldSpawnSeahorse; + s32 cs; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/BgSinkaiKabe_Init.s") + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&gPinnacleRockPythonDenCol, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + Math_Vec3f_Copy(&pos, &this->dyna.actor.world.pos); + pos.x += Math_SinS(this->dyna.actor.world.rot.y + 0x8000) * 3000.0f; + pos.z += Math_CosS(this->dyna.actor.world.rot.y + 0x8000) * 3000.0f; + cs = this->dyna.actor.cutscene; + i = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/BgSinkaiKabe_Destroy.s") + // clang-format off + while (cs != -1) { this->cutscenes[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); i++; } + // clang-format on -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/func_80B6DA20.s") + this->dyna.actor.scale.x = 0.1f; + this->dyna.actor.scale.y = 0.1f; + this->dyna.actor.scale.z = 0.1f; + this->pythonIndex = sCurrentPythonIndex; + sCurrentPythonIndex++; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/BgSinkaiKabe_Update.s") + if (!(gSaveContext.save.weekEventReg[13] & 1)) { + this->deepPython = + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EN_DRAGON, pos.x, pos.y, pos.z, + 0, this->dyna.actor.world.rot.y, 1, this->dyna.actor.params); + + if (this->deepPython != NULL) { + EnDragon* dragon = (EnDragon*)this->deepPython; + + dragon->grabCutsceneIndex = this->cutscenes[0]; + dragon->deathCutsceneIndex = this->cutscenes[1]; + dragon->actor.cutscene = this->dyna.actor.cutscene; + Math_Vec3f_Copy(&dragon->burrowEntrancePos, &this->dyna.actor.world.pos); + dragon->pythonIndex = this->pythonIndex; + } + } else { + shouldSpawnSeahorse = false; + if (((this->dyna.actor.params == 0) && (gSaveContext.save.weekEventReg[83] & 0x10)) || + ((this->dyna.actor.params == 1) && (gSaveContext.save.weekEventReg[83] & 0x20)) || + ((this->dyna.actor.params == 2) && (gSaveContext.save.weekEventReg[83] & 0x40)) || + ((this->dyna.actor.params == 3) && (gSaveContext.save.weekEventReg[83] & 0x80)) || + ((this->dyna.actor.params == 4) && (gSaveContext.save.weekEventReg[84] & 1)) || + ((this->dyna.actor.params == 5) && (gSaveContext.save.weekEventReg[84] & 2)) || + ((this->dyna.actor.params == 6) && (gSaveContext.save.weekEventReg[84] & 4)) || + ((this->dyna.actor.params == 7) && (gSaveContext.save.weekEventReg[84] & 8))) { + shouldSpawnSeahorse = true; + } + + Math_Vec3f_Copy(&pos, &this->dyna.actor.home.pos); + pos.x += (Math_SinS(this->dyna.actor.world.rot.y + 0x8000) * 500.0f); + pos.y += -100.0f; + pos.z += (Math_CosS(this->dyna.actor.world.rot.y + 0x8000) * 500.0f); + if (shouldSpawnSeahorse) { + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OT, pos.x, pos.y, pos.z, 0, + this->dyna.actor.shape.rot.y, 0, 0x4000, this->dyna.actor.cutscene, + this->dyna.actor.unk20, NULL); + } + + Actor_MarkForDeath(&this->dyna.actor); + } + + this->actionFunc = BgSinkaiKabe_WaitForPlayer; +} + +void BgSinkaiKabe_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgSinkaiKabe* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +/** + * Extends this actor's Deep Python if the player gets close enough. + */ +void BgSinkaiKabe_WaitForPlayer(BgSinkaiKabe* this, GlobalContext* globalCtx) { + if (this->deepPython != NULL) { + if (this->deepPython->update != NULL) { + EnDragon* dragon = (EnDragon*)this->deepPython; + + if (dragon->action == DEEP_PYTHON_ACTION_IDLE) { + Player* player = GET_PLAYER(globalCtx); + + if ((this->dyna.actor.xzDistToPlayer < 500.0f) || + ((ABS_ALT(BINANG_SUB(this->dyna.actor.yawTowardsPlayer, this->dyna.actor.world.rot.y)) < 0x2000) && + (this->dyna.actor.xzDistToPlayer < 700.0f))) { + if (fabsf(this->dyna.actor.world.pos.y - player->actor.world.pos.y) < 400.0f) { + dragon->action = DEEP_PYTHON_ACTION_EXTEND; + } + } + } + } else { + this->deepPython = NULL; + } + } + + if (this->deepPython == NULL) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void BgSinkaiKabe_Update(Actor* thisx, GlobalContext* globalCtx) { + BgSinkaiKabe* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h index 5fb866529..1a29f512f 100644 --- a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h +++ b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.h @@ -2,16 +2,19 @@ #define Z_BG_SINKAI_KABE_H #include "global.h" +#include "overlays/actors/ovl_En_Dragon/z_en_dragon.h" struct BgSinkaiKabe; typedef void (*BgSinkaiKabeActionFunc)(struct BgSinkaiKabe*, GlobalContext*); typedef struct BgSinkaiKabe { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgSinkaiKabeActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x10]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgSinkaiKabeActionFunc actionFunc; + /* 0x160 */ Actor* deepPython; + /* 0x164 */ s16 cutscenes[2]; + /* 0x168 */ UNK_TYPE1 unk_168[0x4]; + /* 0x16C */ s32 pythonIndex; } BgSinkaiKabe; // size = 0x170 extern const ActorInit Bg_Sinkai_Kabe_InitVars; diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c index 5b7091d02..efd901eb3 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c @@ -31,16 +31,6 @@ typedef enum { /* 3 */ DEEP_PYTHON_ANIMATION_IDLE } DeepPythonAnimationIndex; -typedef enum { - /* 0 */ DEEP_PYTHON_ACTION_IDLE, - /* 1 */ DEEP_PYTHON_ACTION_EXTEND, - /* 2 */ DEEP_PYTHON_ACTION_GRAB, - /* 3 */ DEEP_PYTHON_ACTION_DAMAGE, - /* 4 */ DEEP_PYTHON_ACTION_RETREAT, - /* 5 */ DEEP_PYTHON_ACTION_SETUP_DEAD, - /* 6 */ DEEP_PYTHON_ACTION_DEAD, -} DeepPythonAction; - typedef enum { /* 0 */ DEEP_PYTHON_EXTEND_STATE_NOT_FULLY_EXTENDED, /* 1 */ DEEP_PYTHON_EXTEND_STATE_FULLY_EXTENDED, diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h index c7ec4d81e..5fe44083b 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h @@ -6,6 +6,16 @@ #define EN_DRAGON_GET_PYTHON_INDEX(thisx) (((thisx)->params >> 7) & 0x1F) +typedef enum { + /* 0 */ DEEP_PYTHON_ACTION_IDLE, + /* 1 */ DEEP_PYTHON_ACTION_EXTEND, + /* 2 */ DEEP_PYTHON_ACTION_GRAB, + /* 3 */ DEEP_PYTHON_ACTION_DAMAGE, + /* 4 */ DEEP_PYTHON_ACTION_RETREAT, + /* 5 */ DEEP_PYTHON_ACTION_SETUP_DEAD, + /* 6 */ DEEP_PYTHON_ACTION_DEAD, +} DeepPythonAction; + struct EnDragon; typedef void (*EnDragonActionFunc)(struct EnDragon*, GlobalContext*); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index f759c2f9f..161cabe5b 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -14278,7 +14278,7 @@ 0x80B6849C:("func_80B6849C",), 0x80B6D660:("BgSinkaiKabe_Init",), 0x80B6D9EC:("BgSinkaiKabe_Destroy",), - 0x80B6DA20:("func_80B6DA20",), + 0x80B6DA20:("BgSinkaiKabe_WaitForPlayer",), 0x80B6DB20:("BgSinkaiKabe_Update",), 0x80B6DBE0:("BgHakaCurtain_Init",), 0x80B6DC64:("BgHakaCurtain_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index a4921f34a..2ffe4ad8c 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -685,10 +685,6 @@ D_06001A60 = 0x06001A60; D_06001B40 = 0x06001B40; D_06002CE0 = 0x06002CE0; -// ovl_Bg_Sinkai_Kabe - -D_06000048 = 0x06000048; - // ovl_Bg_Spout_Fire D_06000040 = 0x06000040; From 10d9025267f912101e32c67a59ee34c15f4ca2a2 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Thu, 21 Apr 2022 20:41:08 -0700 Subject: [PATCH 199/257] Document En_Racedog (and some low-hanging fruit in En_Dg) (#782) * Dog color documentation * Simplify floats * Text ID and some speed doc * Macros for condition * Index documentation * Name the sprint speed multiplier * Racedog animations * Document a few things regarding the race start * Doc selection arrow stuff * Some low-hanging fruit * Some path stuff, mostly copied from Jg * Some speed docs * More race stuff * Add a ton of documentation, mostly so I can go to bed * Document rotation stuff (but I'm not super confident in it) * Port very low-hanging fruit from Racedog to Dg * Document cross-product stuff * Finish docs * Fix Aob_01 * First response to reviews * Change it to GetFloorRot --- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 10 +- src/overlays/actors/ovl_En_Dg/z_en_dg.c | 124 ++-- src/overlays/actors/ovl_En_Dg/z_en_dg.h | 20 +- .../actors/ovl_En_Racedog/z_en_racedog.c | 649 +++++++++++------- .../actors/ovl_En_Racedog/z_en_racedog.h | 43 +- tools/disasm/functions.txt | 34 +- 6 files changed, 528 insertions(+), 352 deletions(-) diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index 0705d7f06..b06b57ebd 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -598,7 +598,7 @@ s32 func_809C2504(EnAob01* this, GlobalContext* globalCtx) { Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (npc != NULL) { - if ((npc->id == ACTOR_EN_RACEDOG) && (func_800F2178(this->unk_430) == ((EnRacedog*)npc)->unk_1E8)) { + if ((npc->id == ACTOR_EN_RACEDOG) && (func_800F2178(this->unk_430) == ((EnRacedog*)npc)->currentPoint)) { ActorCutscene_Stop(this->unk_430); this->unk_3F4 = npc; this->unk_430 = ActorCutscene_GetAdditionalCutscene(this->unk_430); @@ -614,7 +614,7 @@ s32 func_809C2594(EnAob01* this, GlobalContext* globalCtx) { Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; while (npc != NULL) { - if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->unk_290 == ((EnRacedog*)npc)->unk_292)) { + if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->index == ((EnRacedog*)npc)->selectedDogIndex)) { this->unk_3F4 = npc; return true; } @@ -629,7 +629,7 @@ s32 func_809C25E4(EnAob01* this, GlobalContext* globalCtx) { s16 count = 0; while (npc != NULL) { - if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->unk_29C == 3)) { + if ((npc->id == ACTOR_EN_RACEDOG) && (((EnRacedog*)npc)->raceStatus == RACEDOG_RACE_STATUS_FINISHED)) { count++; } npc = npc->next; @@ -853,12 +853,12 @@ s32 func_809C2EC4(EnAob01* this, GlobalContext* globalCtx) { while (dog != NULL) { if (dog->id == ACTOR_EN_DG) { - this->unk_432 = ((EnDg*)dog)->unk_288; + this->unk_432 = ((EnDg*)dog)->selectedDogIndex; if (this->unk_432 == -1) { return false; } - if (this->unk_432 == ENDG_GET_3E0(dog)) { + if (this->unk_432 == ENDG_GET_INDEX(dog)) { return true; } } diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index dce730c48..23bd7e183 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -57,19 +57,32 @@ typedef struct { static D_8098C2A4_s D_8098C2A4 = { 0x0063, 0x0000 }; +/** + * Stores the state for the dogs milling about at the Doggy Racetrack. + */ typedef struct { - s16 unk_00; - s16 unk_02; - s16 unk_04; -} D_8098C2A8_s; + s16 color; // The dog's color, which is used as an index into sBaseSpeeds + s16 index; // The dog's index within sDogInfo + s16 textId; // The ID of the text to display when the dog is picked up +} RacetrackDogInfo; -static D_8098C2A8_s D_8098C2A8[] = { - { 3, 0, 0x3539 }, { 1, 1, 0x353A }, { 5, 2, 0x353B }, { 2, 3, 0x353C }, { 4, 4, 0x3538 }, - { 2, 5, 0x353E }, { 3, 6, 0x353F }, { 1, 7, 0x3540 }, { 1, 8, 0x3541 }, { 6, 9, 0x3542 }, - { 2, 10, 0x3543 }, { 3, 11, 0x3544 }, { 1, 12, 0x3545 }, { 4, 13, 0x3546 }, +/** + * A table of RacetrackDogInfo for every dog at the Doggy Racetrack. Note that the textId values + * in this table are updated by functions within this actor. + */ +static RacetrackDogInfo sRacetrackDogInfo[] = { + { DOG_COLOR_BEIGE, 0, 0x3539 }, { DOG_COLOR_WHITE, 1, 0x353A }, { DOG_COLOR_BLUE, 2, 0x353B }, + { DOG_COLOR_GRAY, 3, 0x353C }, { DOG_COLOR_BROWN, 4, 0x3538 }, { DOG_COLOR_GRAY, 5, 0x353E }, + { DOG_COLOR_BEIGE, 6, 0x353F }, { DOG_COLOR_WHITE, 7, 0x3540 }, { DOG_COLOR_WHITE, 8, 0x3541 }, + { DOG_COLOR_GOLD, 9, 0x3542 }, { DOG_COLOR_GRAY, 10, 0x3543 }, { DOG_COLOR_BEIGE, 11, 0x3544 }, + { DOG_COLOR_WHITE, 12, 0x3545 }, { DOG_COLOR_BROWN, 13, 0x3546 }, }; -static D_8098C2A8_s D_8098C2FC = { 0, -1, 0x353E }; +/** + * Stores the RacetrackDogInfo for the dog that is selected by the player. These values are just + * placeholders, and the actual value gets grabbed from sRacetrackDogInfo in func_80989E18. + */ +static RacetrackDogInfo sSelectedRacetrackDogInfo = { DOG_COLOR_DEFAULT, -1, 0x353E }; static ColliderCylinderInit sCylinderInit = { { @@ -252,29 +265,29 @@ void func_80989674(EnDg* this, GlobalContext* globalCtx) { s16 phi_a1; f32 sp30; - if (this->unk_1DC != NULL) { - phi_a1 = func_809895B4(this->unk_1DC, this->unk_1E0, &this->actor.world.pos, &sp30); + if (this->path != NULL) { + phi_a1 = func_809895B4(this->path, this->unk_1E0, &this->actor.world.pos, &sp30); if (this->actor.bgCheckFlags & 8) { phi_a1 = this->actor.wallYaw; } Math_SmoothStepToS(&this->actor.world.rot.y, phi_a1, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; - if (func_80989418(this, this->unk_1DC, this->unk_1E0)) { - if (this->unk_1E0 >= (this->unk_1DC->count - 1)) { + if (func_80989418(this, this->path, this->unk_1E0)) { + if (this->unk_1E0 >= (this->path->count - 1)) { this->unk_1E0 = 0; } else { this->unk_1E0++; } } - if ((this->unk_286 == 21) || ((this->unk_286 == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { + if ((this->index == 21) || ((this->index == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); - } else if (this->unk_286 == 20) { + } else if (this->index == 20) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); } else if (globalCtx->sceneNum == SCENE_CLOCKTOWER) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); - } else if (D_8098C2A8[this->unk_286].unk_04 & 0x11) { + } else if (sRacetrackDogInfo[this->index].textId & 0x11) { Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); } else { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); @@ -289,7 +302,7 @@ void func_80989864(EnDg* this, GlobalContext* globalCtx) { s16 mod = (this->actor.speedXZ > 6.0f) ? 2 : 3; Vec3f sp38; - if (((this->unk_286 + frame) % mod) == 0) { + if (((this->index + frame) % mod) == 0) { sp38.x = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.x; sp38.y = this->actor.world.pos.y; sp38.z = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.z; @@ -329,13 +342,13 @@ void func_80989A9C(EnDg* this, f32 arg1) { void func_80989ADC(EnDg* this, GlobalContext* globalCtx) { if (!(this->actor.bgCheckFlags & 0x20)) { - if ((this->unk_286 == 21) || ((this->unk_286 == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { + if ((this->index == 21) || ((this->index == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { func_80989140(&this->skelAnime, sAnimations, 1); - } else if (this->unk_286 == 20) { + } else if (this->index == 20) { func_80989140(&this->skelAnime, sAnimations, 2); } else if (globalCtx->sceneNum == SCENE_CLOCKTOWER) { func_80989140(&this->skelAnime, sAnimations, 2); - } else if (D_8098C2A8[this->unk_286].unk_04 & 0x11) { + } else if (sRacetrackDogInfo[this->index].textId & 0x11) { func_80989140(&this->skelAnime, sAnimations, 1); } else { func_80989140(&this->skelAnime, sAnimations, 2); @@ -345,38 +358,37 @@ void func_80989ADC(EnDg* this, GlobalContext* globalCtx) { } void func_80989BF8(EnDg* this) { - if (this->unk_286 < 14) { - if (this->unk_286 % 2) { - D_8098C2A8[this->unk_286].unk_04 = - 0x3538 + - ((gSaveContext.save.weekEventReg[42 + (this->unk_286 / 2)] & (0x10 | 0x20 | 0x40 | 0x80)) >> 4); + if (this->index < 14) { + if (this->index % 2) { + sRacetrackDogInfo[this->index].textId = + 0x3538 + ((gSaveContext.save.weekEventReg[42 + (this->index / 2)] & (0x10 | 0x20 | 0x40 | 0x80)) >> 4); } else { - D_8098C2A8[this->unk_286].unk_04 = - 0x3538 + (gSaveContext.save.weekEventReg[42 + (this->unk_286 / 2)] & (1 | 2 | 4 | 8)); + sRacetrackDogInfo[this->index].textId = + 0x3538 + (gSaveContext.save.weekEventReg[42 + (this->index / 2)] & (1 | 2 | 4 | 8)); } } else { Actor_MarkForDeath(&this->actor); } - if ((D_8098C2A8[this->unk_286].unk_04 >= 0x3547) || (D_8098C2A8[this->unk_286].unk_04 < 0x3538)) { - D_8098C2A8[this->unk_286].unk_04 = 0x353E; + if ((sRacetrackDogInfo[this->index].textId >= 0x3547) || (sRacetrackDogInfo[this->index].textId < 0x3538)) { + sRacetrackDogInfo[this->index].textId = 0x353E; } - if (D_8098C2A8[this->unk_286].unk_04 == 0x353D) { - D_8098C2A8[this->unk_286].unk_04 = 0x3538; + if (sRacetrackDogInfo[this->index].textId == 0x353D) { + sRacetrackDogInfo[this->index].textId = 0x3538; } } void func_80989D38(EnDg* this, GlobalContext* globalCtx) { - if (this->unk_286 == 21) { + if (this->index == 21) { if (CURRENT_DAY == 1) { Message_StartTextbox(globalCtx, 0x91C, NULL); } else { Message_StartTextbox(globalCtx, 0x91E, NULL); } - } else if ((this->unk_286 >= 0) && (this->unk_286 < 14)) { - Message_StartTextbox(globalCtx, D_8098C2A8[this->unk_286].unk_04, NULL); - } else if (this->unk_286 == 20) { + } else if ((this->index >= 0) && (this->index < 14)) { + Message_StartTextbox(globalCtx, sRacetrackDogInfo[this->index].textId, NULL); + } else if (this->index == 20) { Message_StartTextbox(globalCtx, 0x353D, NULL); } else { Message_StartTextbox(globalCtx, 0x627, NULL); @@ -384,7 +396,7 @@ void func_80989D38(EnDg* this, GlobalContext* globalCtx) { } void func_80989E18(EnDg* this, GlobalContext* globalCtx) { - D_8098C2A8_s* temp; + RacetrackDogInfo* temp; if ((D_8098C2A0 != 0) && !(this->unk_280 & 1)) { this->actor.flags |= ACTOR_FLAG_8000000; @@ -397,7 +409,7 @@ void func_80989E18(EnDg* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); this->unk_290 = 1; - D_8098C2FC = D_8098C2A8[this->unk_286]; + sSelectedRacetrackDogInfo = sRacetrackDogInfo[this->index]; if (D_8098C2A0 == 0) { this->actor.flags |= ACTOR_FLAG_8000000; D_8098C2A0 = 1; @@ -427,13 +439,13 @@ s32 func_80989FC8(GlobalContext* globalCtx) { while (enemy != NULL) { if (enemy->actor.id == ACTOR_EN_DG) { if (enemy->actor.isTargeted) { - D_8098C2A4.unk_00 = enemy->unk_286; + D_8098C2A4.unk_00 = enemy->index; return true; } dist = enemy->actor.xzDistToPlayer; if (dist < minDist) { - D_8098C2A4.unk_00 = enemy->unk_286; + D_8098C2A4.unk_00 = enemy->index; minDist = dist; } } @@ -455,7 +467,7 @@ void func_8098A064(EnDg* this, GlobalContext* globalCtx) { func_80989FC8(globalCtx); } - if (this->unk_286 == D_8098C2A4.unk_00) { + if (this->index == D_8098C2A4.unk_00) { if (!(this->unk_280 & 0x20)) { this->unk_280 |= 0x20; func_80989140(&this->skelAnime, sAnimations, 1); @@ -467,7 +479,7 @@ void func_8098A064(EnDg* this, GlobalContext* globalCtx) { } } } - } else if (this->unk_286 == D_8098C2A4.unk_00) { + } else if (this->index == D_8098C2A4.unk_00) { this->unk_280 &= ~0x20; D_8098C2A4.unk_00 = 99; func_80989ADC(this, globalCtx); @@ -1053,8 +1065,8 @@ void func_8098BA64(EnDg* this, GlobalContext* globalCtx) { D_8098C2A0 = 0; this->unk_280 &= ~1; } - this->unk_288 = -1; - D_8098C2FC.unk_02 = this->unk_288; + this->selectedDogIndex = -1; + sSelectedRacetrackDogInfo.index = this->selectedDogIndex; this->unk_28A = 100; Actor_MoveWithGravity(&this->actor); this->unk_280 |= 0x10; @@ -1114,7 +1126,7 @@ void EnDg_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_ProcessInitChain(&this->actor, sInitChain); - this->unk_1DC = SubS_GetPathByIndex(globalCtx, ENDG_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENDG_GET_PATH(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.0075f); this->actor.targetMode = 1; this->actor.gravity = -3.0f; @@ -1122,7 +1134,7 @@ void EnDg_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_280 = 0; this->unk_28E = 20; this->unk_284 = 10; - this->unk_286 = ENDG_GET_3E0(&this->actor); + this->index = ENDG_GET_INDEX(&this->actor); this->unk_28C = 0; this->unk_290 = 0; if (globalCtx->sceneNum == SCENE_F01_B) { @@ -1144,7 +1156,7 @@ void EnDg_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; Vec3f sp28 = { 0.0f, 0.0f, 0.0f }; - this->unk_288 = D_8098C2FC.unk_02; + this->selectedDogIndex = sSelectedRacetrackDogInfo.index; if (!(player->stateFlags1 & 0x20) || (globalCtx->sceneNum != SCENE_CLOCKTOWER)) { if (func_8098A1B4(this, globalCtx)) { func_8098A234(this, globalCtx); @@ -1194,25 +1206,31 @@ void EnDg_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); - switch (D_8098C2A8[this->unk_286].unk_00) { - case 3: + switch (sRacetrackDogInfo[this->index].color) { + case DOG_COLOR_BEIGE: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); break; - case 1: + + case DOG_COLOR_WHITE: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 0); break; - case 5: + + case DOG_COLOR_BLUE: gDPSetEnvColor(POLY_OPA_DISP++, 79, 79, 143, 0); break; - case 6: + + case DOG_COLOR_GOLD: gDPSetEnvColor(POLY_OPA_DISP++, 255, 207, 47, 0); break; - case 4: + + case DOG_COLOR_BROWN: gDPSetEnvColor(POLY_OPA_DISP++, 143, 79, 47, 0); break; - case 2: + + case DOG_COLOR_GRAY: gDPSetEnvColor(POLY_OPA_DISP++, 143, 143, 143, 0); break; + default: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); break; diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.h b/src/overlays/actors/ovl_En_Dg/z_en_dg.h index 09732ba81..ca85d4a4d 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.h +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.h @@ -4,12 +4,22 @@ #include "global.h" #include "objects/object_dog/object_dog.h" +typedef enum { + /* 0 */ DOG_COLOR_DEFAULT, // ends up just being treated as beige + /* 1 */ DOG_COLOR_WHITE, + /* 2 */ DOG_COLOR_GRAY, + /* 3 */ DOG_COLOR_BEIGE, + /* 4 */ DOG_COLOR_BROWN, + /* 5 */ DOG_COLOR_BLUE, + /* 6 */ DOG_COLOR_GOLD, +} DogColors; + struct EnDg; typedef void (*EnDgActionFunc)(struct EnDg*, GlobalContext*); -#define ENDG_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) -#define ENDG_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) +#define ENDG_GET_INDEX(thisx) (((thisx)->params & 0x3E0) >> 5) +#define ENDG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 0xA) typedef struct EnDg { /* 0x000 */ Actor actor; @@ -17,15 +27,15 @@ typedef struct EnDg { /* 0x148 */ UNK_TYPE1 unk_148[0x4]; /* 0x14C */ SkelAnime skelAnime; /* 0x190 */ ColliderCylinder collider; - /* 0x1DC */ Path* unk_1DC; + /* 0x1DC */ Path* path; /* 0x1E0 */ s32 unk_1E0; /* 0x1E4 */ Vec3s jointTable[DOG_LIMB_MAX]; /* 0x232 */ Vec3s morphTable[DOG_LIMB_MAX]; /* 0x280 */ u16 unk_280; /* 0x282 */ s16 unk_282; /* 0x284 */ s16 unk_284; - /* 0x286 */ s16 unk_286; - /* 0x288 */ s16 unk_288; + /* 0x286 */ s16 index; + /* 0x288 */ s16 selectedDogIndex; /* 0x28A */ s16 unk_28A; /* 0x28C */ s16 unk_28C; /* 0x28E */ s16 unk_28E; diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index 0166ed423..e6fb2535a 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -9,6 +9,7 @@ */ #include "z_en_racedog.h" +#include "overlays/actors/ovl_En_Dg/z_en_dg.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) @@ -19,26 +20,63 @@ void EnRacedog_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRacedog_Update(Actor* thisx, GlobalContext* globalCtx); void EnRacedog_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B24C14(EnRacedog* this, GlobalContext* globalCtx); -void func_80B24CB4(EnRacedog* this, GlobalContext* globalCtx); -void func_80B24E14(EnRacedog* this); -void func_80B24F08(EnRacedog* this); -void func_80B251EC(EnRacedog* this); -void func_80B252F8(EnRacedog* this); -void func_80B2538C(EnRacedog* this); -void func_80B25448(EnRacedog* this); -s32 func_80B25490(EnRacedog* this, Vec2f* arg1); -void func_80B255AC(EnRacedog* this, GlobalContext* globalCtx); -void func_80B256BC(EnRacedog* this); +void EnRacedog_RaceStart(EnRacedog* this, GlobalContext* globalCtx); +void EnRacedog_Race(EnRacedog* this, GlobalContext* globalCtx); +void EnRacedog_UpdateTextId(EnRacedog* this); +void EnRacedog_UpdateSpeed(EnRacedog* this); +void EnRacedog_CalculateFinalStretchTargetSpeed(EnRacedog* this); +void EnRacedog_UpdateRaceVariables(EnRacedog* this); +void EnRacedog_CheckForFinish(EnRacedog* this); +void EnRacedog_UpdateRunAnimationPlaySpeed(EnRacedog* this); +s32 EnRacedog_IsOverFinishLine(EnRacedog* this, Vec2f* arg1); +void EnRacedog_SpawnFloorDustRing(EnRacedog* this, GlobalContext* globalCtx); +void EnRacedog_PlayWalkSfx(EnRacedog* this); +/** + * Dogs can be in three conditions, which is indicated by the message it says when + * you pick it up prior to entering the race. + * If it starts with "Ruff!", it's in good condition. + * If it starts with "Rrr-Ruff!", it's in normal condition. + * If it starts with "Hoo-whine", it's in bad condition. + * These text boxes are grouped up like so: + * - 0x3538 - 0x353D: Good condition + * - 0x353E - 0x3541: Normal condition + * - 0x3542 - 0x3546: Bad condition + */ +#define DOG_IS_IN_GOOD_CONDITION(this) (sDogInfo[this->index].textId < 0x353E) +#define DOG_IS_IN_BAD_CONDITION(this) (sDogInfo[this->index].textId >= 0x3542) + +typedef enum { + /* 0 */ RACEDOG_ANIMATION_IDLE, + /* 1 */ RACEDOG_ANIMATION_WALK_1, + /* 2 */ RACEDOG_ANIMATION_RUN, + /* 3 */ RACEDOG_ANIMATION_BARK, + /* 4 */ RACEDOG_ANIMATION_SIT_DOWN_1, + /* 5 */ RACEDOG_ANIMATION_SIT_DOWN_2, + /* 6 */ RACEDOG_ANIMATION_LYING_DOWN_START_1, + /* 7 */ RACEDOG_ANIMATION_LYING_DOWN_LOOP, + /* 8 */ RACEDOG_ANIMATION_LYING_DOWN_START_2, + /* 9 */ RACEDOG_ANIMATION_LYING_DOWN_START_3, + /* 10 */ RACEDOG_ANIMATION_LYING_DOWN_START_4, + /* 11 */ RACEDOG_ANIMATION_WALK_2, + /* 12 */ RACEDOG_ANIMATION_JUMP, + /* 13 */ RACEDOG_ANIMATION_LONG_JUMP, + /* 14 */ RACEDOG_ANIMATION_JUMP_2, + /* 15 */ RACEDOG_ANIMATION_WALK_3, + /* 16 */ RACEDOG_ANIMATION_MAX +} RacedogAnimationIndex; + +/** + * Stores various information for each dog in the race, mostly related to speed. + */ typedef struct { - f32 unk_00; - f32 unk_04; - s16 unk_08; - s16 unk_0A; - s16 unk_0C; - s16 unk_0E; -} UnkRacedogStruct; + f32 sprintSpeedMultiplier; // Target speed is multiplied by this when the dog is in the last 1/4 of the race + f32 goodConditionSpeedMultiplier; // Target speed is multiplied by this if the dog is in good condition + s16 color; // The dog's color, which is used as an index into sBaseSpeeds + s16 index; // The dog's index within sDogInfo + s16 pointToUseSecondBaseSpeed; // When the dog is at or after this point, the second value in sBaseSpeeds is used + s16 textId; // Used to determine the dog's condition +} RaceDogInfo; const ActorInit En_Racedog_InitVars = { ACTOR_EN_RACEDOG, @@ -52,31 +90,65 @@ const ActorInit En_Racedog_InitVars = { (ActorFunc)EnRacedog_Draw, }; -static s16 D_80B25D40 = 0; +static s16 sNumberOfDogsFinished = 0; -static s16 D_80B25D44 = -1; +/** + * The furthest point along the race track path that any dog has reached. + */ +static s16 sFurthestPoint = -1; -static s16 D_80B25D48 = 0; +/** + * Starts counting up as soon as the first-place dog gets 3/4ths of the way through the race track, + * and stops counting up as soon as the first-place dog finishes. Used to scale up the sprint + * multiplier in EnRacedog_CalculateFinalStretchTargetSpeed. + */ +static s16 sSprintTimer = 0; -static s16 D_80B25D4C = -1; +/** + * The index of the dog currently in first place. It's determined by checking, for each dog on the track, + * if its current point along the race track path is greater than or equal to sFurthestPoint. + */ +static s16 sFirstPlaceIndex = -1; -static f32 D_80B25D50[][2] = { +/** + * The base speeds for each dog indexed by its color. The two values are used during different parts of the race. + * - At the very start of the race, all dogs will use the first value for their color, but only for a single point + * along the race track's path. After that, they will have a base speed of 5.0, regardless of what's in the table + * for their color. The sole exception to this is the blue dog, who will use its first value for the entire + * first 1/4th of the race. + * - For the last 3/4ths of the race, all dogs will check to see if their current point along the race track path is + * greater than or equal to the pointToUseSecondBaseSpeed for their RaceDogInfo. If it is, then they will use the + * second value for their color as their base speed; otherwise, they will use 5.0. + */ +static f32 sBaseSpeeds[][2] = { { 0.0f, 0.0f }, { 5.0f, 5.5f }, { 5.0f, 5.0f }, { 5.5f, 5.0f }, { 4.5f, 5.5f }, { 6.0f, 4.0f }, { 4.0f, 6.0f }, }; -static UnkRacedogStruct D_80B25D88[] = { - { -1.0f, 1.20000004768f, 3, 0, 9, 0x3539 }, { -1.0f, 1.20000004768f, 1, 1, 9, 0x353A }, - { -1.0f, 1.20000004768f, 5, 2, 10, 0x353B }, { -1.0f, 1.20000004768f, 2, 3, 9, 0x353C }, - { -1.0f, 1.20000004768f, 4, 4, 8, 0x353D }, { -1.0f, 1.20000004768f, 2, 5, 9, 0x353E }, - { -1.0f, 1.20000004768f, 3, 6, 9, 0x353F }, { -1.0f, 1.20000004768f, 1, 7, 9, 0x3540 }, - { -1.0f, 1.20000004768f, 1, 8, 9, 0x3541 }, { -1.0f, 1.20000004768f, 6, 9, 8, 0x3542 }, - { -1.0f, 1.20000004768f, 2, 10, 9, 0x3543 }, { -1.0f, 1.20000004768f, 3, 11, 9, 0x3544 }, - { -1.0f, 1.20000004768f, 1, 12, 9, 0x3545 }, { -1.0f, 1.20000004768f, 4, 13, 8, 0x3546 }, +/** + * A table of RaceDogInfo for every dog in the race. Note that the sprintSpeedMultiplier and + * textId values in this table are updated by functions within this actor. + */ +static RaceDogInfo sDogInfo[] = { + { -1.0f, 1.2f, DOG_COLOR_BEIGE, 0, 9, 0x3539 }, { -1.0f, 1.2f, DOG_COLOR_WHITE, 1, 9, 0x353A }, + { -1.0f, 1.2f, DOG_COLOR_BLUE, 2, 10, 0x353B }, { -1.0f, 1.2f, DOG_COLOR_GRAY, 3, 9, 0x353C }, + { -1.0f, 1.2f, DOG_COLOR_BROWN, 4, 8, 0x353D }, { -1.0f, 1.2f, DOG_COLOR_GRAY, 5, 9, 0x353E }, + { -1.0f, 1.2f, DOG_COLOR_BEIGE, 6, 9, 0x353F }, { -1.0f, 1.2f, DOG_COLOR_WHITE, 7, 9, 0x3540 }, + { -1.0f, 1.2f, DOG_COLOR_WHITE, 8, 9, 0x3541 }, { -1.0f, 1.2f, DOG_COLOR_GOLD, 9, 8, 0x3542 }, + { -1.0f, 1.2f, DOG_COLOR_GRAY, 10, 9, 0x3543 }, { -1.0f, 1.2f, DOG_COLOR_BEIGE, 11, 9, 0x3544 }, + { -1.0f, 1.2f, DOG_COLOR_WHITE, 12, 9, 0x3545 }, { -1.0f, 1.2f, DOG_COLOR_BROWN, 13, 8, 0x3546 }, }; -static UnkRacedogStruct D_80B25E68 = { -1.0f, 1.0, 0, -1, 0, 0x353E }; +/** + * Stores the RacedogInfo for the dog that is selected by the player. These values are just + * placeholders, and the actual value gets grabbed from sDogInfo in EnRacedog_Init. + */ +static RaceDogInfo sSelectedDogInfo = { -1.0f, 1.0, DOG_COLOR_DEFAULT, -1, 0, 0x353E }; -static Vec2f D_80B25E78[] = { +/** + * The XZ-coordinates used to determine if the dog is inside the finish line. + * They're a little bit bigger than the in-game visual. + */ +static Vec2f sFinishLineCoordinates[] = { { -3914.0f, 1283.0f }, { -3747.0f, 1104.0f }, { -3717.0f, 1169.0f }, @@ -140,7 +212,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static AnimationInfoS D_80B25EF0[] = { +static AnimationInfoS sAnimations[] = { { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, { &gDogRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogBarkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_LOOP_PARTIAL, -6 }, @@ -155,21 +227,21 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -void func_80B24630(SkelAnime* skelAnime, AnimationInfoS arg1[], s32 arg2) { +void EnRacedog_ChangeAnimation(SkelAnime* skelAnime, AnimationInfoS* animationInfo, s32 index) { f32 frameCount; - arg1 += arg2; - if (arg1->frameCount < 0) { - frameCount = Animation_GetLastFrame(arg1->animation); + animationInfo += index; + if (animationInfo->frameCount < 0) { + frameCount = Animation_GetLastFrame(animationInfo->animation); } else { - frameCount = arg1->frameCount; + frameCount = animationInfo->frameCount; } - Animation_Change(skelAnime, arg1->animation, arg1->playSpeed + (BREG(88) * 0.1f), arg1->startFrame, frameCount, - arg1->mode, arg1->morphFrames); + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed + (BREG(88) * 0.1f), + animationInfo->startFrame, frameCount, animationInfo->mode, animationInfo->morphFrames); } -void func_80B246F4(EnRacedog* this, GlobalContext* globalCtx) { +void EnRacedog_UpdateCollision(EnRacedog* this, GlobalContext* globalCtx) { this->collider.dim.pos.x = this->actor.world.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z; @@ -177,40 +249,44 @@ void func_80B246F4(EnRacedog* this, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 26.0f, 10.0f, 0.0f, 5); } -s16 func_80B2478C(Path* path, s32 arg1, Vec3f* pos, f32* arg3) { +/** + * Returns the Y-rotation the dog should have to move to the next point along the race track path. + * There is a small degree of randomness incorporated into this angle. + */ +s16 EnRacedog_GetYRotation(Path* path, s32 pointIndex, Vec3f* pos, f32* distSQ) { Vec3s* point; - f32 phi_f14; - f32 sp1C; + f32 xDiffRand; + f32 zDiffRand; f32 xDiff; f32 zDiff; if (path != NULL) { point = Lib_SegmentedToVirtual(path->points); - point = &point[arg1]; - phi_f14 = (randPlusMinusPoint5Scaled(100.0f) + point->x) - pos->x; - sp1C = (randPlusMinusPoint5Scaled(100.0f) + point->z) - pos->z; + point = &point[pointIndex]; + xDiffRand = (randPlusMinusPoint5Scaled(100.0f) + point->x) - pos->x; + zDiffRand = (randPlusMinusPoint5Scaled(100.0f) + point->z) - pos->z; xDiff = point->x - pos->x; zDiff = point->z - pos->z; } else { - phi_f14 = 0.0f; - sp1C = 0.0f; + xDiffRand = 0.0f; + zDiffRand = 0.0f; xDiff = 0.0f; zDiff = 0.0f; } - *arg3 = SQ(xDiff) + SQ(zDiff); - return RADF_TO_BINANG(Math_Acot2F(sp1C, phi_f14)); + *distSQ = SQ(xDiff) + SQ(zDiff); + return RADF_TO_BINANG(Math_Acot2F(zDiffRand, xDiffRand)); } -void func_80B248B8(EnRacedog* this, Vec3f* arg1) { - f32 sp20; - f32 sp1C; +void EnRacedog_GetFloorRot(EnRacedog* this, Vec3f* floorRot) { + f32 ny; + f32 nz; if (this->actor.floorPoly != NULL) { - sp20 = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); - sp1C = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); + ny = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); + nz = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); - arg1->x = -Math_Acot2F(1.0f, -sp1C * sp20); + floorRot->x = -Math_Acot2F(1.0f, -nz * ny); } } @@ -225,43 +301,51 @@ void EnRacedog_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_ProcessInitChain(&this->actor, sInitChain); - this->unk_1E0 = SubS_GetPathByIndex(globalCtx, ENRACEDOG_GET_PATH(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENRACEDOG_GET_PATH(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.0075f); this->actor.gravity = -3.0f; - if (ENRACEDOG_GET_3E0(&this->actor) < 14) { - this->unk_290 = ENRACEDOG_GET_3E0(&this->actor); + if (ENRACEDOG_GET_INDEX(&this->actor) < 14) { + this->index = ENRACEDOG_GET_INDEX(&this->actor); } else { Actor_MarkForDeath(&this->actor); } - this->unk_2BC = 0xFF; - this->unk_2C0 = 0x32; - this->unk_288 = 0xC; - this->unk_2A0.x = 0.0f; - this->unk_2A0.y = 0.0f; - this->unk_2A0.z = 0.0f; - this->unk_2C4 = 1.0f; + this->selectionArrowGreenPrimColor = 255; + this->selectionArrowGreenEnvColor = 50; + this->selectionArrowTimer = 12; + this->prevRot.x = 0.0f; + this->prevRot.y = 0.0f; + this->prevRot.z = 0.0f; + this->selectionArrowScale = 1.0f; - if ((D_80B25D88[this->unk_290].unk_0E >= 0x353F) && (this->unk_290 == (s16)Rand_ZeroFloat(20.0f))) { - this->unk_28C = 5; + // The first part of this check is a bit strange. If they intended to check for dogs that were + // in good condition, they should've stopped at 0x353D instead of 0x353E. Additionally, this + // runs before EnRacedog_UpdateTextId is called to set the text IDs to their "correct" values, + // meaning that the IDs are just whatever their default values in sDogInfo are. As a result, + // the blue dog, one beige dog, one white dog, one brown dog, and two gray dogs never bother + // to do the random 1/20 check here, regardless of anything else. + if ((sDogInfo[this->index].textId > 0x353E) && (this->index == (s16)Rand_ZeroFloat(20.0f))) { + this->extraTimeBeforeRaceStart = 5; } else { - this->unk_28C = 0; + this->extraTimeBeforeRaceStart = 0; } - this->unk_28A = 60; - this->unk_28A += this->unk_28C; - this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][0]; - this->unk_29C = 0; - this->unk_2B8 = -1; + this->raceStartTimer = 60; + this->raceStartTimer += this->extraTimeBeforeRaceStart; + this->targetSpeed = sBaseSpeeds[sDogInfo[this->index].color][0]; + this->raceStatus = RACEDOG_RACE_STATUS_BEFORE_POINT_9; + this->pointForCurrentTargetSpeed = -1; - func_80B24E14(this); + EnRacedog_UpdateTextId(this); this->actor.flags |= ACTOR_FLAG_10; this->actor.flags |= ACTOR_FLAG_20; - D_80B25E68 = D_80B25D88[(s16)((gSaveContext.eventInf[0] & 0xF8) >> 3)]; - this->unk_292 = D_80B25E68.unk_0A; - func_80B24630(&this->skelAnime, D_80B25EF0, 0); - D_80B25EF0->playSpeed = Rand_ZeroFloat(0.5f) + 1.0f; - this->actionFunc = func_80B24C14; + + sSelectedDogInfo = sDogInfo[(s16)((gSaveContext.eventInf[0] & 0xF8) >> 3)]; + this->selectedDogIndex = sSelectedDogInfo.index; + + EnRacedog_ChangeAnimation(&this->skelAnime, sAnimations, RACEDOG_ANIMATION_IDLE); + sAnimations[RACEDOG_ANIMATION_IDLE].playSpeed = Rand_ZeroFloat(0.5f) + 1.0f; + this->actionFunc = EnRacedog_RaceStart; } void EnRacedog_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -270,125 +354,150 @@ void EnRacedog_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } -void func_80B24C14(EnRacedog* this, GlobalContext* globalCtx) { - s16 phi_v1; - - if (this->unk_28A == 0) { - phi_v1 = 0; - } else { - this->unk_28A--; - phi_v1 = this->unk_28A; - } - - if (phi_v1 == 0) { - this->unk_28A = Rand_S16Offset(50, 50); - if (this->unk_28C == 0) { +/** + * This function makes the dog wait at the starting line until the race actually begins. + * It's also responsible for playing the starting shot sound once the race begins. + */ +void EnRacedog_RaceStart(EnRacedog* this, GlobalContext* globalCtx) { + if (DECR(this->raceStartTimer) == 0) { + this->raceStartTimer = Rand_S16Offset(50, 50); + if (this->extraTimeBeforeRaceStart == 0) { play_sound(NA_SE_SY_START_SHOT); } - func_80B24630(&this->skelAnime, D_80B25EF0, 2); - this->actionFunc = func_80B24CB4; + EnRacedog_ChangeAnimation(&this->skelAnime, sAnimations, RACEDOG_ANIMATION_RUN); + this->actionFunc = EnRacedog_Race; } } -void func_80B24CB4(EnRacedog* this, GlobalContext* globalCtx) { - s16 phi_a1; - f32 sp30; +/** + * This function handles the dog's behavior and state for the entire time the race is going. + */ +void EnRacedog_Race(EnRacedog* this, GlobalContext* globalCtx) { + s16 yRotation; + f32 distSq; this->collider.dim.radius = 15; - if (this->unk_1E0 != 0) { - phi_a1 = func_80B2478C(this->unk_1E0, this->unk_1E8, &this->actor.world.pos, &sp30); + if (this->path != NULL) { + yRotation = EnRacedog_GetYRotation(this->path, this->currentPoint, &this->actor.world.pos, &distSq); if (this->actor.bgCheckFlags & 8) { - phi_a1 = this->actor.wallYaw; + yRotation = this->actor.wallYaw; } - Math_SmoothStepToS(&this->actor.world.rot.y, phi_a1, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; - if (sp30 <= 2500.0f) { - this->unk_1E8++; - if (this->unk_1E8 >= (this->unk_1E0->count - 1)) { - this->unk_1E8 = 0; + if (distSq <= SQ(50.0f)) { + this->currentPoint++; + if (this->currentPoint >= (this->path->count - 1)) { + this->currentPoint = 0; } } - func_80B24F08(this); - if ((this->unk_1E8 >= ((this->unk_1E0->count / 4) * 3)) && (this->unk_290 == D_80B25D4C)) { - D_80B25D48++; + EnRacedog_UpdateSpeed(this); + + // Putting this after EnRacedog_UpdateSpeed will ensure that when EnRacedog_CalculateFinalStretchTargetSpeed + // is called for the first-place dog, the sprint timer will be 0, so the first-place dog will be guaranteed + // to have a sprint speed multiplier of 1. + if ((this->currentPoint >= ((this->path->count / 4) * 3)) && (this->index == sFirstPlaceIndex)) { + sSprintTimer++; } - func_80B252F8(this); - func_80B2538C(this); + EnRacedog_UpdateRaceVariables(this); + EnRacedog_CheckForFinish(this); Actor_MoveWithGravity(&this->actor); } - func_80B25448(this); - func_80B256BC(this); - func_80B255AC(this, globalCtx); + EnRacedog_UpdateRunAnimationPlaySpeed(this); + EnRacedog_PlayWalkSfx(this); + EnRacedog_SpawnFloorDustRing(this, globalCtx); } -void func_80B24E14(EnRacedog* this) { - if (this->unk_290 % 2) { - D_80B25D88[this->unk_290].unk_0E = - (((gSaveContext.save.weekEventReg[42 + (this->unk_290 / 2)]) & (0x10 | 0x20 | 0x40 | 0x80)) >> 4) + 0x3539; +/** + * Updates the text ID in sDogInfo based on what was set in the weekEventRegs by + * En_Aob_01. This makes it so sDogInfo can be used in other functions to determine + * the condition of the dog. + */ +void EnRacedog_UpdateTextId(EnRacedog* this) { + if (this->index % 2) { + sDogInfo[this->index].textId = + (((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & (0x10 | 0x20 | 0x40 | 0x80)) >> 4) + 0x3539; } else { - D_80B25D88[this->unk_290].unk_0E = - ((gSaveContext.save.weekEventReg[42 + (this->unk_290 / 2)]) & (1 | 2 | 4 | 8)) + 0x3539; + sDogInfo[this->index].textId = + ((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & (1 | 2 | 4 | 8)) + 0x3539; } - if ((D_80B25D88[this->unk_290].unk_0E >= 0x3547) || (D_80B25D88[this->unk_290].unk_0E < 0x3539)) { - D_80B25D88[this->unk_290].unk_0E = 0x353E; + // This makes sure the text ID is something in the range of 0x3539 to 0x3547. + if ((sDogInfo[this->index].textId >= 0x3547) || (sDogInfo[this->index].textId < 0x3539)) { + sDogInfo[this->index].textId = 0x353E; } - if (D_80B25D88[this->unk_290].unk_0E == 0x3547) { - D_80B25D88[this->unk_290].unk_0E = 0x3538; + + // Actual valid text IDs for the race dogs range between 0x3538 and 0x3546, so this + // code makes the two ranges match up. Perhaps the text got shifted? + if (sDogInfo[this->index].textId == 0x3547) { + sDogInfo[this->index].textId = 0x3538; } } -void func_80B24F08(EnRacedog* this) { - s32 temp_a0; - s32 temp_v1 = this->unk_1E0->count; +/** + * Responsible for calculating the dog's target speed and for making its actual speed + * approach the target speed. + */ +void EnRacedog_UpdateSpeed(EnRacedog* this) { + s32 quarterPathCount; + s32 pathCount = this->path->count; - if (this->unk_2B8 < this->unk_1E8) { - this->unk_2B8 = this->unk_1E8; - if (this->unk_1E8 == 0) { - this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][0]; + // Only update the target speed if the dog is at a further point along the path + // than it was when the target speed was last updated. + if (this->pointForCurrentTargetSpeed < this->currentPoint) { + this->pointForCurrentTargetSpeed = this->currentPoint; + if (this->currentPoint == 0) { + // The dog is at the very start of the race track. + this->targetSpeed = sBaseSpeeds[sDogInfo[this->index].color][0]; } else { - temp_a0 = temp_v1 / 4; - if (this->unk_1E8 < temp_a0) { - if (D_80B25D88[this->unk_290].unk_08 == 5) { - this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][0] + randPlusMinusPoint5Scaled(1.0f); + quarterPathCount = pathCount / 4; + if (this->currentPoint < quarterPathCount) { + // The dog is past the very start, but is still less than 1/4th of the way through the race track. + // This code will give the blue dog a higher base speed than any other dog (6.0 instead of 5.0). + if (sDogInfo[this->index].color == DOG_COLOR_BLUE) { + this->targetSpeed = sBaseSpeeds[sDogInfo[this->index].color][0] + randPlusMinusPoint5Scaled(1.0f); } else { - this->unk_298 = 5.0f + randPlusMinusPoint5Scaled(1.0f); + this->targetSpeed = 5.0f + randPlusMinusPoint5Scaled(1.0f); } - if ((D_80B25D88[this->unk_290].unk_0E < 0x353E) && (this->unk_290 != D_80B25D4C)) { - this->unk_298 *= D_80B25D88[this->unk_290].unk_04; + if (DOG_IS_IN_GOOD_CONDITION(this) && (this->index != sFirstPlaceIndex)) { + this->targetSpeed *= sDogInfo[this->index].goodConditionSpeedMultiplier; } - } else if (this->unk_1E8 < (temp_a0 * 3)) { - if (this->unk_1E8 < D_80B25D88[this->unk_290].unk_0C) { - this->unk_298 = 5.0f + randPlusMinusPoint5Scaled(1.0f); + } else if (this->currentPoint < (quarterPathCount * 3)) { + // The dog is between 1/4th and 3/4ths of the way through the race track. + if (this->currentPoint < sDogInfo[this->index].pointToUseSecondBaseSpeed) { + this->targetSpeed = 5.0f + randPlusMinusPoint5Scaled(1.0f); } else { - this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][1] + randPlusMinusPoint5Scaled(1.0f); + this->targetSpeed = sBaseSpeeds[sDogInfo[this->index].color][1] + randPlusMinusPoint5Scaled(1.0f); - if ((D_80B25D88[this->unk_290].unk_0E < 0x353E) && (this->unk_290 != D_80B25D4C)) { - this->unk_298 *= D_80B25D88[this->unk_290].unk_04; + if (DOG_IS_IN_GOOD_CONDITION(this) && (this->index != sFirstPlaceIndex)) { + this->targetSpeed *= sDogInfo[this->index].goodConditionSpeedMultiplier; } } - } else if (this->unk_1E8 < temp_v1) { - func_80B251EC(this); + } else if (this->currentPoint < pathCount) { + // The dog is more than 3/4ths of the way through the race track. + EnRacedog_CalculateFinalStretchTargetSpeed(this); } else { - this->unk_298 = randPlusMinusPoint5Scaled(1.0f) + 5.0f; + this->targetSpeed = randPlusMinusPoint5Scaled(1.0f) + 5.0f; } } } - if ((this->unk_1E8 != 0) || (this->unk_29C != 0)) { + // Seemingly the only point of this raceStatus check is to ensure this code still runs when + // the dog has finished the race and is at point 0 along their second lap. + if ((this->currentPoint != 0) || (this->raceStatus != RACEDOG_RACE_STATUS_BEFORE_POINT_9)) { this->actor.shape.rot.y = this->actor.world.rot.y; } - Math_ApproachF(&this->actor.speedXZ, this->unk_298, 0.5f, 3.0f); + Math_ApproachF(&this->actor.speedXZ, this->targetSpeed, 0.5f, 3.0f); - if (this->unk_290 == this->unk_292) { + // The dog that the player has selected has a slightly higher max speed than the other dogs. + if (this->index == this->selectedDogIndex) { if (this->actor.speedXZ > 7.5f) { this->actor.speedXZ = 7.5f; } @@ -399,66 +508,90 @@ void func_80B24F08(EnRacedog* this) { } } -void func_80B251EC(EnRacedog* this) { - f32 temp; +/** + * This function handles updating targetSpeed for the final stretch of the race, + * where the dog starts sprinting towards the finish line. + */ +void EnRacedog_CalculateFinalStretchTargetSpeed(EnRacedog* this) { + f32 sprintSpeedMultiplier; - if (D_80B25D88[this->unk_290].unk_00 == -1.0f) { - if (D_80B25D48 < 100.0f) { - D_80B25D88[this->unk_290].unk_00 = 200.0f / (200.0f - D_80B25D48); + // Dogs are only allowed to update their sprintSpeedMultiplier once, so its value will + // depend on the value of sSprintTimer when they first hit the 3/4th mark on the track. + if (sDogInfo[this->index].sprintSpeedMultiplier == -1.0f) { + if (sSprintTimer < 100.0f) { + sDogInfo[this->index].sprintSpeedMultiplier = 200.0f / (200.0f - sSprintTimer); } else { - D_80B25D88[this->unk_290].unk_00 = 2.0f; + sDogInfo[this->index].sprintSpeedMultiplier = 2.0f; } } - if (D_80B25D88[this->unk_290].unk_0E < 0x3542) { - temp = D_80B25D88[this->unk_290].unk_00; - this->unk_298 = temp * D_80B25D50[D_80B25D88[this->unk_290].unk_08][1]; + if (!DOG_IS_IN_BAD_CONDITION(this)) { + sprintSpeedMultiplier = sDogInfo[this->index].sprintSpeedMultiplier; + this->targetSpeed = sprintSpeedMultiplier * sBaseSpeeds[sDogInfo[this->index].color][1]; } - if ((D_80B25D88[this->unk_290].unk_0E < 0x353E) && (this->unk_290 != D_80B25D4C)) { - this->unk_298 *= D_80B25D88[this->unk_290].unk_04; + if (DOG_IS_IN_GOOD_CONDITION(this) && (this->index != sFirstPlaceIndex)) { + this->targetSpeed *= sDogInfo[this->index].goodConditionSpeedMultiplier; } } -void func_80B252F8(EnRacedog* this) { - if ((this->unk_1E8 >= 9) && (this->unk_29C == 0)) { - this->unk_29C = 1; +/** + * Responsible for updating the raceStatus variable for this dog, as well as updating the + * sFurthestPoint and sFirstPlaceIndex variables. + */ +void EnRacedog_UpdateRaceVariables(EnRacedog* this) { + if ((this->currentPoint >= 9) && (this->raceStatus == RACEDOG_RACE_STATUS_BEFORE_POINT_9)) { + this->raceStatus = RACEDOG_RACE_STATUS_BETWEEN_POINTS_9_AND_11; } - if ((this->unk_1E8 >= 0xB) && (this->unk_29C == 1)) { - this->unk_29C = 2; + if ((this->currentPoint >= 11) && (this->raceStatus == RACEDOG_RACE_STATUS_BETWEEN_POINTS_9_AND_11)) { + this->raceStatus = RACEDOG_RACE_STATUS_AFTER_POINT_11; } - if (((this->unk_1E8 >= D_80B25D44) || (this->unk_29C <= 0)) && (this->unk_1E8 > D_80B25D44)) { - D_80B25D44 = this->unk_1E8; - D_80B25D4C = this->unk_290; + if (((this->currentPoint >= sFurthestPoint) || (this->raceStatus <= RACEDOG_RACE_STATUS_BEFORE_POINT_9)) && + (this->currentPoint > sFurthestPoint)) { + sFurthestPoint = this->currentPoint; + sFirstPlaceIndex = this->index; } } -void func_80B2538C(EnRacedog* this) { - if (func_80B25490(this, D_80B25E78) && this->unk_29C == 2) { - D_80B25D40++; - if (D_80B25D40 == 1) { +/** + * Checks to see if this dog has finished the race. This function is responsible for changing the + * music when the first dog finishes the race, and it is also responsible for updating the event + * flags with what position the player's selected dog finished in. + */ +void EnRacedog_CheckForFinish(EnRacedog* this) { + if (EnRacedog_IsOverFinishLine(this, sFinishLineCoordinates) && + this->raceStatus == RACEDOG_RACE_STATUS_AFTER_POINT_11) { + sNumberOfDogsFinished++; + if (sNumberOfDogsFinished == 1) { Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000); play_sound(NA_SE_SY_START_SHOT); } - this->unk_29C = 3; - if (this->unk_290 == this->unk_292) { - gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 7) | (D_80B25D40 * 8); + this->raceStatus = RACEDOG_RACE_STATUS_FINISHED; + if (this->index == this->selectedDogIndex) { + gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 7) | (sNumberOfDogsFinished * 8); } } } -void func_80B25448(EnRacedog* this) { +/** + * Slows the dog's running speed animation if its speed is less than 3.0, and sets it + * to normal speed otherwise. + */ +void EnRacedog_UpdateRunAnimationPlaySpeed(EnRacedog* this) { if (this->actor.speedXZ < 3.0f) { - D_80B25EF0[2].playSpeed = 0.9f; + sAnimations[RACEDOG_ANIMATION_RUN].playSpeed = 0.9f; } else { - D_80B25EF0[2].playSpeed = 1.0f; + sAnimations[RACEDOG_ANIMATION_RUN].playSpeed = 1.0f; } } -s32 func_80B25490(EnRacedog* this, Vec2f* arg1) { +/** + * Returns true if the dog's current position is in the finish line. + */ +s32 EnRacedog_IsOverFinishLine(EnRacedog* this, Vec2f* finishLineCoordinates) { f32 xDistToTopFront; f32 zDistToTopFront; f32 xDistToBottomFront; @@ -467,53 +600,57 @@ s32 func_80B25490(EnRacedog* this, Vec2f* arg1) { f32 zDistToBottomFront; f32 zDistToTopBack; f32 xDistToTopBack; - f32 temp_f0; - f32 temp; + f32 frontPointsCrossProduct; + f32 crossProductTemp; - xDistToTopFront = this->actor.world.pos.x - arg1[0].x; - zDistToTopFront = this->actor.world.pos.z - arg1[0].z; - xDistToBottomFront = this->actor.world.pos.x - arg1[1].x; - zDistToBottomFront = this->actor.world.pos.z - arg1[1].z; - xDistToBottomBack = this->actor.world.pos.x - arg1[2].x; - zDistToBottomBack = this->actor.world.pos.z - arg1[2].z; - xDistToTopBack = this->actor.world.pos.x - arg1[3].x; - zDistToTopBack = this->actor.world.pos.z - arg1[3].z; + xDistToTopFront = this->actor.world.pos.x - finishLineCoordinates[0].x; + zDistToTopFront = this->actor.world.pos.z - finishLineCoordinates[0].z; + xDistToBottomFront = this->actor.world.pos.x - finishLineCoordinates[1].x; + zDistToBottomFront = this->actor.world.pos.z - finishLineCoordinates[1].z; + xDistToBottomBack = this->actor.world.pos.x - finishLineCoordinates[2].x; + zDistToBottomBack = this->actor.world.pos.z - finishLineCoordinates[2].z; + xDistToTopBack = this->actor.world.pos.x - finishLineCoordinates[3].x; + zDistToTopBack = this->actor.world.pos.z - finishLineCoordinates[3].z; - temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); - temp = (((xDistToBottomFront * zDistToBottomBack) - (xDistToBottomBack * zDistToBottomFront))); - if (temp_f0 * temp < 0.0f) { + // frontPointsCrossProduct is positive if the dog is to the left of the line formed by the front points + // crossProductTemp is positive if the dog is above the line formed by the bottom points + frontPointsCrossProduct = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); + crossProductTemp = (((xDistToBottomFront * zDistToBottomBack) - (xDistToBottomBack * zDistToBottomFront))); + if (frontPointsCrossProduct * crossProductTemp < 0.0f) { return false; } - temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); - temp = ((xDistToBottomBack * zDistToTopBack) - (xDistToTopBack * zDistToBottomBack)); - if (temp_f0 * temp < 0.0f) { + // crossProductTemp is positive if the dog is to the right of the line formed by the back points + frontPointsCrossProduct = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); + crossProductTemp = ((xDistToBottomBack * zDistToTopBack) - (xDistToTopBack * zDistToBottomBack)); + if (frontPointsCrossProduct * crossProductTemp < 0.0f) { return false; } - temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); - temp = ((xDistToTopBack * zDistToTopFront) - (xDistToTopFront * zDistToTopBack)); - if (temp_f0 * temp < 0.0f) { + // crossProductTemp is positive if the dog is below the line formed by the top points + frontPointsCrossProduct = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); + crossProductTemp = ((xDistToTopBack * zDistToTopFront) - (xDistToTopFront * zDistToTopBack)); + if (frontPointsCrossProduct * crossProductTemp < 0.0f) { return false; } return true; } -void func_80B255AC(EnRacedog* this, GlobalContext* globalCtx) { +void EnRacedog_SpawnFloorDustRing(EnRacedog* this, GlobalContext* globalCtx) { s16 curFrame = this->skelAnime.curFrame; s16 mod = (this->actor.speedXZ > 6.0f) ? 2 : 3; - Vec3f sp38; + Vec3f pos; - if (((this->unk_290 + curFrame) % mod) == 0) { - sp38.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(15.0f); - sp38.y = this->actor.world.pos.y; - sp38.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(15.0f); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &sp38, 10.0f, 0, 2.0f, 300, 0, true); + if (((this->index + curFrame) % mod) == 0) { + pos.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(15.0f); + pos.y = this->actor.world.pos.y; + pos.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(15.0f); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &pos, 10.0f, 0, 2.0f, 300, 0, true); } } -void func_80B256BC(EnRacedog* this) { +void EnRacedog_PlayWalkSfx(EnRacedog* this) { s16 curFrame = this->skelAnime.curFrame; if ((curFrame == 1) || (curFrame == 7)) { @@ -524,18 +661,20 @@ void func_80B256BC(EnRacedog* this) { void EnRacedog_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnRacedog* this = THIS; - Vec3f sp2C = { 0.0f, 0.0f, 0.0f }; + Vec3f floorRot = { 0.0f, 0.0f, 0.0f }; - this->unk_292 = D_80B25E68.unk_0A; + this->selectedDogIndex = sSelectedDogInfo.index; this->actionFunc(this, globalCtx); - func_80B246F4(this, globalCtx); - func_80B248B8(this, &sp2C); - Math_ApproachF(&this->unk_2AC.x, sp2C.x, 0.2f, 0.1f); + EnRacedog_UpdateCollision(this, globalCtx); + EnRacedog_GetFloorRot(this, &floorRot); + Math_ApproachF(&this->curRot.x, floorRot.x, 0.2f, 0.1f); - if (this->unk_2A0.x > 0.0f) { - if ((this->unk_2AC.x < 0.0f) && (this->unk_2AC.x > -0.1f)) { + if (this->prevRot.x > 0.0f) { + if ((this->curRot.x < 0.0f) && (this->curRot.x > -0.1f)) { + // Moves to the part of the running animation where the dog has four feet + // on the ground and is about to lift its feet off the ground. this->skelAnime.curFrame = 4.0f; this->actor.velocity.y = 5.5f; } @@ -545,51 +684,43 @@ void EnRacedog_Update(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.curFrame = 0.0f; } - this->unk_2A0 = this->unk_2AC; + this->prevRot = this->curRot; SkelAnime_Update(&this->skelAnime); } -void func_80B2583C(EnRacedog* this) { - s16 phi_v1; - - if (this->unk_288 >= 7) { - this->unk_2BC -= 0x10; - this->unk_2C0 += 8; - this->unk_2C4 += 0.05f; +void EnRacedog_UpdateSelectionArrow(EnRacedog* this) { + if (this->selectionArrowTimer > 6) { + this->selectionArrowGreenPrimColor -= 16; + this->selectionArrowGreenEnvColor += 8; + this->selectionArrowScale += 0.05f; } else { - this->unk_2BC += 0x10; - this->unk_2C0 -= 8; - this->unk_2C4 -= 0.05f; + this->selectionArrowGreenPrimColor += 16; + this->selectionArrowGreenEnvColor -= 8; + this->selectionArrowScale -= 0.05f; } - if (this->unk_288 == 0) { - phi_v1 = 0; - } else { - this->unk_288--; - phi_v1 = this->unk_288; - } - - if (phi_v1 == 0) { - this->unk_288 = 0xC; + if (DECR(this->selectionArrowTimer) == 0) { + this->selectionArrowTimer = 12; } } -void func_80B258D8(EnRacedog* this, GlobalContext* globalCtx) { - Vec3s sp48 = gZeroVec3s; - s32 phi_v0 = (this->unk_290 == this->unk_292) ? true : false; +void EnRacedog_DrawSelectionArrow(EnRacedog* this, GlobalContext* globalCtx) { + Vec3s rotation = gZeroVec3s; + s32 shouldDrawSelectionArrow = (this->index == this->selectedDogIndex) ? true : false; - if (phi_v0) { + if (shouldDrawSelectionArrow) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - func_80B2583C(this); + EnRacedog_UpdateSelectionArrow(this); Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, - this->actor.world.pos.z, &sp48); + this->actor.world.pos.z, &rotation); gDPPipeSync(POLY_OPA_DISP++); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 255, 255, this->unk_2BC, 0, 255); - gDPSetEnvColor(POLY_OPA_DISP++, 255, this->unk_2C0, 0, 255); - Matrix_Scale(this->unk_2C4 * 2.0f, this->unk_2C4 * 2.0f, this->unk_2C4 * 2.0f, MTXMODE_APPLY); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 255, 255, this->selectionArrowGreenPrimColor, 0, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, this->selectionArrowGreenEnvColor, 0, 255); + Matrix_Scale(this->selectionArrowScale * 2.0f, this->selectionArrowScale * 2.0f, + this->selectionArrowScale * 2.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gDogSelectionArrowEmptyDL); gSPDisplayList(POLY_OPA_DISP++, gDogSelectionArrowDL); @@ -606,14 +737,14 @@ s32 EnRacedog_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL void EnRacedog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { s32 pad; EnRacedog* this = THIS; - Vec3f sp1C = { 0.0f, 20.0f, 0.0f }; + Vec3f focusOffset = { 0.0f, 20.0f, 0.0f }; if (limbIndex == DOG_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&sp1C, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&focusOffset, &this->actor.focus.pos); } if (limbIndex == DOG_LIMB_TAIL) { - func_80B258D8(this, globalCtx); + EnRacedog_DrawSelectionArrow(this, globalCtx); } } @@ -626,32 +757,38 @@ void EnRacedog_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); - switch (D_80B25D88[this->unk_290].unk_08) { - case 3: + switch (sDogInfo[this->index].color) { + case DOG_COLOR_BEIGE: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); break; - case 1: + + case DOG_COLOR_WHITE: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 0); break; - case 5: + + case DOG_COLOR_BLUE: gDPSetEnvColor(POLY_OPA_DISP++, 79, 79, 143, 0); break; - case 6: + + case DOG_COLOR_GOLD: gDPSetEnvColor(POLY_OPA_DISP++, 255, 207, 47, 0); break; - case 4: + + case DOG_COLOR_BROWN: gDPSetEnvColor(POLY_OPA_DISP++, 143, 79, 47, 0); break; - case 2: + + case DOG_COLOR_GRAY: gDPSetEnvColor(POLY_OPA_DISP++, 143, 143, 143, 0); break; + default: gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); break; } Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(this->unk_2AC.x); + Matrix_RotateStateAroundXAxis(this->curRot.x); Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h index 19f7af7a5..a4406b04c 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h @@ -4,9 +4,20 @@ #include "global.h" #include "objects/object_dog/object_dog.h" -#define ENRACEDOG_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) +#define ENRACEDOG_GET_INDEX(thisx) (((thisx)->params & 0x3E0) >> 5) #define ENRACEDOG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 10) +/** + * The main point of this seems to be some very light anti-cheat detection. The dog + * must progress through these statuses in a linear order to finish the race. + */ +typedef enum { + /* 0 */ RACEDOG_RACE_STATUS_BEFORE_POINT_9, + /* 1 */ RACEDOG_RACE_STATUS_BETWEEN_POINTS_9_AND_11, + /* 2 */ RACEDOG_RACE_STATUS_AFTER_POINT_11, + /* 3 */ RACEDOG_RACE_STATUS_FINISHED +} RacedogRaceStatus; + struct EnRacedog; typedef void (*EnRacedogActionFunc)(struct EnRacedog*, GlobalContext*); @@ -18,26 +29,26 @@ typedef struct EnRacedog { /* 0x14C */ SkelAnime skelAnime; /* 0x190 */ ColliderCylinder collider; /* 0x1DC */ UNK_TYPE1 unk_1DC[0x4]; - /* 0x1E0 */ Path* unk_1E0; + /* 0x1E0 */ Path* path; /* 0x1E4 */ UNK_TYPE1 unk_1E4[0x4]; - /* 0x1E8 */ s32 unk_1E8; + /* 0x1E8 */ s32 currentPoint; /* 0x1EC */ Vec3s jointTable[DOG_LIMB_MAX]; /* 0x23A */ Vec3s morphTable[DOG_LIMB_MAX]; - /* 0x288 */ s16 unk_288; - /* 0x28A */ s16 unk_28A; - /* 0x28C */ s16 unk_28C; + /* 0x288 */ s16 selectionArrowTimer; + /* 0x28A */ s16 raceStartTimer; + /* 0x28C */ s16 extraTimeBeforeRaceStart; /* 0x28A */ UNK_TYPE1 unk_28E[0x2]; - /* 0x290 */ s16 unk_290; - /* 0x292 */ s16 unk_292; + /* 0x290 */ s16 index; + /* 0x292 */ s16 selectedDogIndex; /* 0x294 */ UNK_TYPE1 unk_294[0x4]; - /* 0x298 */ f32 unk_298; - /* 0x29C */ s16 unk_29C; - /* 0x2A0 */ Vec3f unk_2A0; - /* 0x2AC */ Vec3f unk_2AC; - /* 0x2B8 */ s32 unk_2B8; - /* 0x2BC */ s32 unk_2BC; - /* 0x2C0 */ s32 unk_2C0; - /* 0x2C4 */ f32 unk_2C4; + /* 0x298 */ f32 targetSpeed; + /* 0x29C */ s16 raceStatus; + /* 0x2A0 */ Vec3f prevRot; + /* 0x2AC */ Vec3f curRot; + /* 0x2B8 */ s32 pointForCurrentTargetSpeed; + /* 0x2BC */ s32 selectionArrowGreenPrimColor; + /* 0x2C0 */ s32 selectionArrowGreenEnvColor; + /* 0x2C4 */ f32 selectionArrowScale; } EnRacedog; // size = 0x2C8 extern const ActorInit En_Racedog_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 161cabe5b..92f36da06 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -13277,26 +13277,26 @@ 0x80B23F50:("ObjWind_Destroy",), 0x80B23F60:("ObjWind_Update",), 0x80B243C0:("ObjWind_Draw",), - 0x80B24630:("func_80B24630",), - 0x80B246F4:("func_80B246F4",), - 0x80B2478C:("func_80B2478C",), - 0x80B248B8:("func_80B248B8",), + 0x80B24630:("EnRacedog_ChangeAnimation",), + 0x80B246F4:("EnRacedog_UpdateCollision",), + 0x80B2478C:("EnRacedog_GetYRotation",), + 0x80B248B8:("EnRacedog_GetFloorRot",), 0x80B24930:("EnRacedog_Init",), 0x80B24BE8:("EnRacedog_Destroy",), - 0x80B24C14:("func_80B24C14",), - 0x80B24CB4:("func_80B24CB4",), - 0x80B24E14:("func_80B24E14",), - 0x80B24F08:("func_80B24F08",), - 0x80B251EC:("func_80B251EC",), - 0x80B252F8:("func_80B252F8",), - 0x80B2538C:("func_80B2538C",), - 0x80B25448:("func_80B25448",), - 0x80B25490:("func_80B25490",), - 0x80B255AC:("func_80B255AC",), - 0x80B256BC:("func_80B256BC",), + 0x80B24C14:("EnRacedog_RaceStart",), + 0x80B24CB4:("EnRacedog_Race",), + 0x80B24E14:("EnRacedog_UpdateTextId",), + 0x80B24F08:("EnRacedog_UpdateSpeed",), + 0x80B251EC:("EnRacedog_CalculateFinalStretchTargetSpeed",), + 0x80B252F8:("EnRacedog_UpdateRaceVariables",), + 0x80B2538C:("EnRacedog_CheckForFinish",), + 0x80B25448:("EnRacedog_UpdateRunAnimationPlaySpeed",), + 0x80B25490:("EnRacedog_IsOverFinishLine",), + 0x80B255AC:("EnRacedog_SpawnFloorDustRing",), + 0x80B256BC:("EnRacedog_PlayWalkSfx",), 0x80B25708:("EnRacedog_Update",), - 0x80B2583C:("func_80B2583C",), - 0x80B258D8:("func_80B258D8",), + 0x80B2583C:("EnRacedog_UpdateSelectionArrow",), + 0x80B258D8:("EnRacedog_DrawSelectionArrow",), 0x80B25A74:("EnRacedog_OverrideLimbDraw",), 0x80B25A90:("EnRacedog_PostLimbDraw",), 0x80B25B14:("EnRacedog_Draw",), From e50c346ab831a29716ae89ffd683072ae3a801e9 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Thu, 21 Apr 2022 21:11:54 -0700 Subject: [PATCH 200/257] SubS Shadows, Cutscenes, Exchange, and Planes (#773) * Bring code over * Rename * clean up variables.h * Bring over some more code as well as cleanup * remove newline in functions.h * format * Add plane functions * Remove from actorfixer * Add some more docs to plane functions * Use temp for better format * change func_8013E8F8 to return an s32 * rename origin back to pos * format * Add docs to SubS_ComputePlane * format * gfxContextPtr -> globalCtx * bss * Better docs of SubS_ComputePlane * Normal -> unitVec * Review pt. 1 * Update plane comment * SubS_ActorAndPlayerAreFacing -> SubS_ActorAndPlayerFaceEachOther * Add subs texture defines * Update include/z64math.h Co-authored-by: EllipticEllipsis Co-authored-by: EllipticEllipsis --- assets/xml/code/sub_s.xml | 4 +- include/functions.h | 20 +- include/variables.h | 6 - include/z64math.h | 4 + include/z64subs.h | 11 +- include/z_en_hy_code.h | 4 +- src/boot_O2_g3/yaz0.c | 1 - src/code/z_en_hy_code.c | 4 +- src/code/z_sub_s.c | 289 +++++++++++++++++- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 1 + src/overlays/actors/ovl_En_Ah/z_en_ah.c | 2 +- src/overlays/actors/ovl_En_Al/z_en_al.c | 4 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 4 +- .../actors/ovl_En_Bba_01/z_en_bba_01.c | 10 +- .../actors/ovl_En_Cne_01/z_en_cne_01.c | 10 +- src/overlays/actors/ovl_En_Dai/z_en_dai.c | 2 +- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 4 +- src/overlays/actors/ovl_En_Dnp/z_en_dnp.c | 2 +- src/overlays/actors/ovl_En_Dnq/z_en_dnq.c | 2 +- src/overlays/actors/ovl_En_Dns/z_en_dns.c | 2 +- .../actors/ovl_En_Dodongo/z_en_dodongo.c | 2 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 8 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 4 +- src/overlays/actors/ovl_En_Gs/z_en_gs.c | 8 +- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 8 +- src/overlays/actors/ovl_En_Ja/z_en_ja.c | 2 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 10 +- src/overlays/actors/ovl_En_Shn/z_en_shn.c | 2 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 4 +- src/overlays/actors/ovl_En_Tab/z_en_tab.c | 2 +- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 4 +- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 4 +- src/overlays/actors/ovl_En_Zo/z_en_zo.c | 21 +- src/overlays/actors/ovl_En_Zo/z_en_zo.h | 2 +- tools/disasm/functions.txt | 14 +- tools/disasm/variables.txt | 10 +- tools/sizes/code_functions.csv | 14 +- 37 files changed, 390 insertions(+), 115 deletions(-) diff --git a/assets/xml/code/sub_s.xml b/assets/xml/code/sub_s.xml index d48335ec7..03329f0c5 100644 --- a/assets/xml/code/sub_s.xml +++ b/assets/xml/code/sub_s.xml @@ -1,6 +1,6 @@ - - + + diff --git a/include/functions.h b/include/functions.h index d15fbbbfa..0cb86ad74 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2442,7 +2442,7 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, struct EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag); Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx); -s32 func_8013AD6C(GlobalContext* globalCtx); +s32 SubS_InCsMode(GlobalContext* globalCtx); s32 func_8013AD9C(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5); void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits); void func_8013AF00(f32* arg0, s32 arg1, s32 arg2); @@ -2459,10 +2459,10 @@ Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s s32 func_8013C068(Path* path, s32 arg1, Vec3f* arg2, f32 arg3, s32 arg4); s32 func_8013C624(Actor* actor, Path* path, s32* arg2, f32* arg3, s32 arg4, s32 arg5); s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst); -s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, s32 arg5); -void func_8013CC2C(s32 arg0, s32 arg1, u8* arg2, s32 arg3); -void func_8013CD64(Vec3f* arg0, Vec3f* arg1, u8* arg2, f32 arg3, u8 arg4, u8* arg5, s8* arg6); -void func_8013CF04(Actor* actor, GraphicsContext** gfxCtxPtr, u8* arg2); +s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 itemId, s32 type); +void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size); +void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], s8 parentBodyParts[]); +void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex); s16 func_8013D0E0(s16* arg0, s16 arg1, s16 arg2, f32 arg3, f32 arg4, f32 arg5); s32 func_8013D2E0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Vec3s* arg3, Vec3s* arg4, Vec3s* arg5, u16* arg6); s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); @@ -2487,12 +2487,12 @@ s32 SubS_ActorPathing_SetNextPoint(GlobalContext* globalCtx, ActorPathing* actor void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, s32* curIndex); s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type); s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes); -void func_8013E4B0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Plane* plane); -s32 func_8013E5CC(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2, Vec3f* arg3, Vec3f* arg4, Vec3f* arg5); +void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane); +s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersect); Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor); -s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, Vec3s* arg5, func_8013E748_arg6 arg6); -s32 func_8013E7C0(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2); -void func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, s16 arg5, s16 arg6); +s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, func_8013E748_VerifyFunc verifyFunc); +s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, void* data); +s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, s16 actorYawTol); s32 func_8013E950(Vec3f* arg0, Vec3f* arg1, s16 arg2, Vec3f* arg3, Vec3f* arg4, s16* arg5, s16* arg6, s16* arg7, s16* arg8, u16 arg9, u16 arg10, u16 arg11, u16 arg12); // void func_8013EC10(void); void func_8013EC44(f32 a, u8 b, u8 c, u8 d); diff --git a/include/variables.h b/include/variables.h index 605b63939..4acb019a4 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1349,12 +1349,6 @@ extern SceneTableEntry gSceneTable[]; extern UNK_PTR D_801C5C50; // extern UNK_TYPE1 D_801C5C9C; extern UNK_PTR D_801C5CB0; -extern MtxF sMtxFClear; -// extern UNK_TYPE1 D_801C5D10; -// extern UNK_TYPE1 D_801C5D20; -// extern UNK_TYPE1 D_801C5D60; -// extern UNK_TYPE1 D_801C5D80; -extern Vec3f D_801C5DB0; // extern UNK_TYPE1 D_801C5DD0; // extern UNK_TYPE1 D_801C5DE0; // extern UNK_TYPE1 D_801C5DF0; diff --git a/include/z64math.h b/include/z64math.h index de0285e6c..78e1743ec 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -49,6 +49,10 @@ typedef struct { /* 0x0C */ f32 radius; } Spheref; // size = 0x10 +/* +The plane paramaters are of form `ax + by + cz + d = 0` +where `(a,b,c)` is the plane's normal vector and d is the originDist + */ typedef struct { /* 0x00 */ Vec3f normal; /* 0x0C */ f32 originDist; diff --git a/include/z64subs.h b/include/z64subs.h index ca69e72cb..f01230fdb 100644 --- a/include/z64subs.h +++ b/include/z64subs.h @@ -4,16 +4,25 @@ #include "z64actor.h" #include "z64scene.h" +#include "code/sub_s/sub_s.h" + +extern Vec3f gOneVec3f; + typedef enum { /* 0 */ SUBS_CUTSCENE_SET_UNK_LINK_FIELDS, /* 1 */ SUBS_CUTSCENE_NORMAL, /* 2 */ SUBS_CUTSCENE_SET_FLAG } SubSCutsceneType; -typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, void*); +//! @TODO: rename based on func_8013E748 and func_800B8500 +typedef s32 (*func_8013E748_VerifyFunc)(struct GlobalContext*, Actor*, void*); typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); +#define SUBS_SHADOW_TEX_WIDTH 64 +#define SUBS_SHADOW_TEX_HEIGHT 64 +#define SUBS_SHADOW_TEX_SIZE ((s32)sizeof(u8[SUBS_SHADOW_TEX_HEIGHT][SUBS_SHADOW_TEX_WIDTH])) + #define ACTOR_PATHING_RETURN_TO_START (1 << 0) #define ACTOR_PATHING_SWITCH_DIRECTION (1 << 1) #define ACTOR_PATHING_MOVE_BACKWARDS (1 << 3) diff --git a/include/z_en_hy_code.h b/include/z_en_hy_code.h index 997a41233..970706760 100644 --- a/include/z_en_hy_code.h +++ b/include/z_en_hy_code.h @@ -72,8 +72,8 @@ typedef struct EnHy { } EnHy; // size = 0x3EC extern s8 gEnHyBodyParts[]; -extern s8 gEnHyBodyPartsIndex[]; -extern u8 gEnHyShadowSize[]; +extern s8 gEnHyParentBodyParts[]; +extern u8 gEnHyShadowSizes[]; s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex); EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx); diff --git a/src/boot_O2_g3/yaz0.c b/src/boot_O2_g3/yaz0.c index 5f8e5a0ed..80d819acc 100644 --- a/src/boot_O2_g3/yaz0.c +++ b/src/boot_O2_g3/yaz0.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" u8 sYaz0DataBuffer[0x400]; diff --git a/src/code/z_en_hy_code.c b/src/code/z_en_hy_code.c index 6b16cc91c..28c177068 100644 --- a/src/code/z_en_hy_code.c +++ b/src/code/z_en_hy_code.c @@ -37,9 +37,9 @@ static AnimationInfoS sAnimations[] = { s8 gEnHyBodyParts[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2 }; -s8 gEnHyBodyPartsIndex[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; +s8 gEnHyParentBodyParts[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; -u8 gEnHyShadowSize[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +u8 gEnHyShadowSizes[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { s16 frameCount; diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index c36365d48..b51de4897 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -10,7 +10,7 @@ s16 sPathDayFlags[] = { 0x40, 0x20, 0x10, 8, 4, 2, 1, 0 }; #include "code/sub_s/sub_s.c" -Vec3f D_801C5DB0 = { 1.0f, 1.0f, 1.0f }; +Vec3f gOneVec3f = { 1.0f, 1.0f, 1.0f }; s32 D_801C5DBC[] = { 0, 1 }; // Unused @@ -158,7 +158,15 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo return gfx; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AD6C.s") +s32 SubS_InCsMode(GlobalContext* globalCtx) { + s32 inCsMode = false; + + if (Play_InCsMode(globalCtx)) { + inCsMode = true; + } + + return inCsMode; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AD9C.s") @@ -333,13 +341,189 @@ s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst) { return true; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C964.s") +//! TODO: Needs docs with func_800B8500 +s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 itemId, s32 type) { + s32 ret = false; + s16 x; + s16 y; + f32 xzDistToPlayerTemp; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013CC2C.s") + Actor_GetScreenPos(globalCtx, actor, &x, &y); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013CD64.s") + switch (type) { + case 1: + yRange = fabsf(actor->playerHeightRel) + 1.0f; + xzRange = actor->xzDistToPlayer + 1.0f; + ret = Actor_PickUp(actor, globalCtx, itemId, xzRange, yRange); + break; + case 2: + if ((fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange)) { + ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + } + break; + case 3: + //! @bug: Both x and y conditionals are always true, || should be an && + if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT))) { + ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + } + break; + case 4: + yRange = fabsf(actor->playerHeightRel) + 1.0f; + xzRange = actor->xzDistToPlayer + 1.0f; + xzDistToPlayerTemp = actor->xzDistToPlayer; + actor->xzDistToPlayer = 0.0f; + actor->flags |= 0x10000; + ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + actor->xzDistToPlayer = xzDistToPlayerTemp; + break; + case 5: + //! @bug: Both x and y conditionals are always true, || should be an && + if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT)) && + (fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange) && actor->isTargeted) { + actor->flags |= 0x10000; + ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + } + break; + case 6: + //! @bug: Both x and y conditionals are always true, || should be an && + if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT)) && + (fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange)) { + actor->flags |= 0x10000; + ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + } + break; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013CF04.s") +const u8 sShadowMaps[4][12][12] = { + { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + }, + { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + }, + { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + }, + { + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, + { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, + { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, + { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }, + }, +}; + +void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size) { + s32 i; + s32 j; + s32 start; + + for (i = 0; i < 12; i++) { + start = ((startRow + i) * 64) + startCol - 390; + for (j = 0; j < 12; j++) { + if (sShadowMaps[size][i][j] != 0) { + if ((start + j >= 0) && (start + j < SUBS_SHADOW_TEX_SIZE)) { + tex[start + j] = 255; + } + } + } + } +} + +void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], + s8 parentBodyParts[]) { + Vec3f pos; + Vec3f startVec; + s32 i; + s32 parentBodyPart; + Vec3f* bodyPartPos; + s32 startCol; + s32 startRow; + + for (i = 0; i < bodyPartsNum; i++) { + if (parentBodyParts[i] >= 0) { + parentBodyPart = parentBodyParts[i]; + bodyPartPos = &bodyPartsPos[i]; + + pos.x = (bodyPartsPos[parentBodyPart].x - bodyPartPos->x) * tween + (bodyPartPos->x - worldPos->x); + pos.y = (bodyPartsPos[parentBodyPart].y - bodyPartPos->y) * tween + (bodyPartPos->y - worldPos->y); + pos.z = (bodyPartsPos[parentBodyPart].z - bodyPartPos->z) * tween + (bodyPartPos->z - worldPos->z); + } else { + bodyPartPos = &bodyPartsPos[i]; + + pos.x = bodyPartPos->x - worldPos->x; + pos.y = bodyPartPos->y - worldPos->y; + pos.z = bodyPartPos->z - worldPos->z; + } + + Matrix_MultiplyVector3fByState(&pos, &startVec); + startCol = 64.0f + startVec.x; + startRow = 64.0f - startVec.z; + SubS_FillShadowTex(startCol >> 1, startRow >> 1, tex, sizes[i]); + } +} + +void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex) { + s32 pad; + GraphicsContext* gfxCtx = gameState->gfxCtx; + + OPEN_DISPS(gfxCtx); + + func_8012C28C(gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, 100); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + Matrix_InsertTranslation(actor->world.pos.x, 0.0f, actor->world.pos.z, MTXMODE_NEW); + Matrix_Scale(0.6f, 1.0f, 0.6f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gShadowDL); + gDPLoadTextureBlock(POLY_OPA_DISP++, tex, G_IM_FMT_I, G_IM_SIZ_8b, SUBS_SHADOW_TEX_WIDTH, SUBS_SHADOW_TEX_HEIGHT, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); + gSPDisplayList(POLY_OPA_DISP++, gShadowVtxDL); + + CLOSE_DISPS(gfxCtx); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D0E0.s") @@ -688,9 +872,58 @@ s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes) { return i; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E4B0.s") +/** + * Computes a plane based on a point on the plane, a unit vector and two angles + * + * @param[in] point a point on the plane + * @param[in] unitVec the unit vector rotated that becomes the plane's normal + * @param[in] rot the angles to rotate with, uses just the x and y components + * @param[out] plane the computed plane + * + * Notes: + * The unit input vector is expected to already be normalized (only uses are with the z unit vector) + * + */ +void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane) { + f32 sin; + f32 cos; + f32 temp; + f32 unitVecZ; + f32 normY; + f32 unitVecYX; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E5CC.s") + sin = Math_SinS(-rot->x); + cos = Math_CosS(-rot->x); + unitVecZ = unitVec->z; + unitVecYX = unitVec->y; + + // Apply a rotation by -x about the X axis + temp = (unitVecZ * cos) - (unitVecYX * sin); + normY = (unitVecZ * sin) + (unitVecYX * cos); + + sin = Math_SinS(rot->y); + cos = Math_CosS(rot->y); + unitVecYX = unitVec->x; + plane->normal.y = normY; + + // Apply a rotation by y about the Y axis + plane->normal.z = (temp * cos) - (unitVecYX * sin); + plane->normal.x = (temp * sin) + (unitVecYX * cos); + + plane->originDist = -((point->x * plane->normal.x) + (plane->normal.y * point->y) + (plane->normal.z * point->z)); +} + +s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePointA, Vec3f* linePointB, + Vec3f* intersect) { + s32 lineSegVsPlane; + Plane plane; + + SubS_ConstructPlane(point, unitVec, rot, &plane); + lineSegVsPlane = Math3D_LineSegVsPlane(plane.normal.x, plane.normal.y, plane.normal.z, plane.originDist, linePointA, + linePointB, intersect, false); + + return lineSegVsPlane ? true : false; +} /** * Finds the first actor instance of a specified Id and category verified with a custom callback. @@ -714,10 +947,44 @@ Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actor return actorIter; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E748.s") +//! TODO: Needs docs with func_800B8500 +s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, + func_8013E748_VerifyFunc verifyFunc) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E7C0.s") + if ((verifyFunc == NULL) || ((verifyFunc != NULL) && verifyFunc(globalCtx, actor, data))) { + ret = func_800B8500(actor, globalCtx, xzRange, yRange, exchangeItemId); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E8F8.s") +s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, void* data) { + Player* player = GET_PLAYER(globalCtx); + Vec3s* yawTols = (Vec3s*)data; + s16 playerYaw = ABS(BINANG_SUB(Actor_YawBetweenActors(&player->actor, actor), player->actor.shape.rot.y)); + s16 actorYaw = ABS(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); + s32 areFacing = false; + s32 actorYawTol = ABS(yawTols->y); + s32 playerYawTol; + + if (actorYaw < (s16)actorYawTol) { + playerYawTol = ABS(yawTols->x); + if (playerYaw < (s16)playerYawTol) { + areFacing = true; + } + } + + return areFacing; +} + +//! TODO: Needs docs with func_800B8500 +s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, + s16 actorYawTol) { + Vec3s yawTols; + + yawTols.x = playerYawTol; + yawTols.y = actorYawTol; + return func_8013E748(actor, globalCtx, xzRange, yRange, exhangeItemId, &yawTols, SubS_ActorAndPlayerFaceEachOther); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E950.s") diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index 7cf9a94b7..4a9061207 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -4,6 +4,7 @@ * Description: Twinmold */ +#include "prevent_bss_reordering.h" #include "z_boss_02.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "overlays/actors/ovl_Item_B_Heart/z_item_b_heart.h" diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index be25dec24..5f0f7a5b2 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -541,7 +541,7 @@ void EnAh_Update(Actor* thisx, GlobalContext* globalCtx) { radius = this->collider.dim.radius + 60; height = this->collider.dim.height + 10; - func_8013C964(&this->actor, globalCtx, radius, height, 0, this->unk_2D8 & 7); + func_8013C964(&this->actor, globalCtx, radius, height, EXCH_ITEM_NONE, this->unk_2D8 & 7); if (!(this->unk_2D8 & 0x10)) { Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index e86f3971d..259c52614 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -647,7 +647,7 @@ s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* ar break; case 2: - this->unk_4F0 = 0; + this->unk_4F0 = EXCH_ITEM_NONE; this->unk_4EA = 0; func_80BDE27C(this, 2); break; @@ -660,7 +660,7 @@ s32 func_80BDF390(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; - this->unk_4F0 = 0; + this->unk_4F0 = EXCH_ITEM_NONE; this->unk_4C2 = 0; this->unk_4D4 = 40.0f; diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index ff2d7c48e..a2f28a6dd 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -384,7 +384,7 @@ s32 func_80BA9160(EnBaba* this, GlobalContext* globalCtx) { this->actor.world.pos.x = sp58.x; this->actor.world.pos.z = sp58.z; - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { sp54 = this->unk_430; sp50 = this->unk_42C; sp58 = this->actor.world.pos; @@ -401,7 +401,7 @@ s32 func_80BA9160(EnBaba* this, GlobalContext* globalCtx) { this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { this->unk_430 = sp54; this->unk_42C = sp50; this->unk_414 = sp58; diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index e502b6637..883d4dd60 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -308,7 +308,7 @@ void EnBba01_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* t void EnBba01_Draw(Actor* thisx, GlobalContext* globalCtx) { EnBba01* this = THIS; s32 i; - u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(u8[64][64])); + u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); u8* shadowTexIter; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -322,14 +322,14 @@ void EnBba01_Draw(Actor* thisx, GlobalContext* globalCtx) { EnBba01_TransformLimbDraw, &this->enHy.actor); Matrix_InsertXRotation_s(0, MTXMODE_NEW); - for (i = 0, shadowTexIter = shadowTex; i < (s32)sizeof(u8[64][64]); i++) { + for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { *shadowTexIter++ = 0; } for (i = 0; i < 5; i++) { - func_8013CD64(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, - ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSize, gEnHyBodyPartsIndex); + SubS_GenShadowTex(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, + ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSizes, gEnHyParentBodyParts); } - func_8013CF04(&this->enHy.actor, &globalCtx->state.gfxCtx, shadowTex); + SubS_DrawShadowTex(&this->enHy.actor, &globalCtx->state, shadowTex); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index e7c6ebc6e..53198c594 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -299,7 +299,7 @@ void EnCne01_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* t void EnCne01_Draw(Actor* thisx, GlobalContext* globalCtx) { EnCne01* this = THIS; s32 i; - u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(u8[64][64])); + u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); u8* shadowTexIter; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -314,14 +314,14 @@ void EnCne01_Draw(Actor* thisx, GlobalContext* globalCtx) { EnCne01_TransformLimbDraw, &this->enHy.actor); Matrix_InsertXRotation_s(0, MTXMODE_NEW); - for (i = 0, shadowTexIter = shadowTex; i < (s32)sizeof(u8[64][64]); i++) { + for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { *shadowTexIter++ = 0; } for (i = 0; i < 5; i++) { - func_8013CD64(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, - ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSize, gEnHyBodyPartsIndex); + SubS_GenShadowTex(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, + ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSizes, gEnHyParentBodyParts); } - func_8013CF04(&this->enHy.actor, &globalCtx->state.gfxCtx, shadowTex); + SubS_DrawShadowTex(&this->enHy.actor, &globalCtx->state, shadowTex); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index bd7de1418..f8118e199 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -564,7 +564,7 @@ void EnDai_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); func_80B3E834(this); if (!(this->unk_1CE & 0x200)) { - func_8013C964(&this->actor, globalCtx, 0.0f, 0.0f, 0, this->unk_1CE & 7); + func_8013C964(&this->actor, globalCtx, 0.0f, 0.0f, EXCH_ITEM_NONE, this->unk_1CE & 7); } func_80B3E460(this); } diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.c b/src/overlays/actors/ovl_En_Dno/z_en_dno.c index ceffe3d93..e774c8965 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -149,8 +149,8 @@ void func_80A715DC(EnDno* this, GlobalContext* globalCtx) { crace = (BgCraceMovebg*)SubS_FindActor(globalCtx, &crace->actor, ACTORCAT_BG, ACTOR_BG_CRACE_MOVEBG); if (crace != NULL) { if (ENDNO_GET_F(&crace->actor) == ENDNO_GET_F_0 && !(crace->unk_170 & 1)) { - if (func_8013E5CC(&crace->actor.home.pos, &crace->actor.home.rot, &D_80A73B2C, &this->actor.prevPos, - &this->actor.world.pos, &sp88)) { + if (SubS_LineSegVsPlane(&crace->actor.home.pos, &crace->actor.home.rot, &D_80A73B2C, + &this->actor.prevPos, &this->actor.world.pos, &sp88)) { Math_Vec3f_Diff(&this->actor.world.pos, &crace->actor.home.pos, &sp7C); Matrix_RotateY(-crace->actor.home.rot.y, MTXMODE_NEW); Matrix_MultiplyVector3fByState(&sp7C, &sp70); diff --git a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c index 13a02345d..3e9bd9f6e 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -410,7 +410,7 @@ void EnDnp_Update(Actor* thisx, GlobalContext* globalCtx) { if ((this->unk_322 & 0x400) && !(gSaveContext.save.weekEventReg[23] & 0x20)) { Actor_PickUp(&this->actor, globalCtx, GI_MAX, sp2C, sp28); } - func_8013C964(&this->actor, globalCtx, sp2C, sp28, 0, this->unk_322 & 7); + func_8013C964(&this->actor, globalCtx, sp2C, sp28, EXCH_ITEM_NONE, this->unk_322 & 7); Actor_SetFocus(&this->actor, 30.0f); func_80B3CC80(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c index 917a2d4d9..ae7f918f1 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -455,7 +455,7 @@ void EnDnq_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); this->unk_394 = this->actor.xzDistToPlayer; func_80A52C6C(this, globalCtx); - func_8013C964(&this->actor, globalCtx, this->unk_390, fabsf(this->actor.playerHeightRel) + 1.0f, 0, + func_8013C964(&this->actor, globalCtx, this->unk_390, fabsf(this->actor.playerHeightRel) + 1.0f, EXCH_ITEM_NONE, this->unk_37C & 7); this->actor.xzDistToPlayer = this->unk_394; Actor_SetFocus(&this->actor, 46.0f); diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c index e2c07cce7..6b7943504 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -554,7 +554,7 @@ void EnDns_Update(Actor* thisx, GlobalContext* globalCtx) { func_8092C934(this); func_8092C86C(this, globalCtx); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); - func_8013C964(&this->actor, globalCtx, 80.0f, 40.0f, 0, this->unk_2C6 & 7); + func_8013C964(&this->actor, globalCtx, 80.0f, 40.0f, EXCH_ITEM_NONE, this->unk_2C6 & 7); Actor_SetFocus(&this->actor, 34.0f); func_8092C6FC(this, globalCtx); func_8092C5C0(this); diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c index 20a44c01d..a630a0dcb 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -293,7 +293,7 @@ void EnDodongo_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_330.r = 255; this->unk_330.g = 10; this->unk_330.a = 200; - Math_Vec3f_Copy(&this->unk_314, &D_801C5DB0); + Math_Vec3f_Copy(&this->unk_314, &gOneVec3f); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 48.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &object_dodongo_Skel_008318, &object_dodongo_Anim_004C20, this->jointTable, this->morphTable, 31); 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 107c9a656..0c80ce319 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -1363,7 +1363,7 @@ s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { f32 temp_f0; door = func_8094DF90(globalCtx, this->unk_258); - if (!func_8013AD6C(globalCtx) && (this->unk_3C4 != 0)) { + if (!SubS_InCsMode(globalCtx) && (this->unk_3C4 != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if ((this->unk_3BA / (f32)this->unk_3B8) <= 0.9f) { door->unk_1A7 = this->unk_261; @@ -1412,7 +1412,7 @@ s32 func_8095097C(EnGm* this, GlobalContext* globalCtx) { this->actor.world.pos.x = sp58.x; this->actor.world.pos.z = sp58.z; - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { sp54 = this->unk_254; sp50 = this->unk_250; sp58 = this->actor.world.pos; @@ -1429,7 +1429,7 @@ s32 func_8095097C(EnGm* this, GlobalContext* globalCtx) { this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { this->unk_254 = sp54; this->unk_250 = sp50; this->unk_238 = sp58; @@ -1626,7 +1626,7 @@ void EnGm_Update(Actor* thisx, GlobalContext* globalCtx) { func_8094DFF8(this, globalCtx); func_8094E2D0(this); func_8094F2E8(this); - func_8013C964(&this->actor, globalCtx, this->unk_3B4, 30.0f, 0, this->unk_3A4 & 7); + func_8013C964(&this->actor, globalCtx, this->unk_3B4, 30.0f, EXCH_ITEM_NONE, this->unk_3A4 & 7); if ((this->unk_258 != 3) && (this->unk_258 != 5) && (this->unk_258 != 8)) { Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); 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 57c8dc044..9a15d26f5 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -1926,10 +1926,10 @@ void EnGo_Update(Actor* thisx, GlobalContext* globalCtx) { } else { phi_f0 = this->colliderCylinder.dim.radius + 40; } - func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, 0, this->unk_390 & 7); + func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, EXCH_ITEM_NONE, this->unk_390 & 7); } else if ((this->unk_390 & 0x200) && (this->unk_3EC != 0)) { phi_f0 = this->colliderCylinder.dim.radius + 40; - func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, 0, this->unk_390 & 7); + func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, EXCH_ITEM_NONE, this->unk_390 & 7); } if ((ENGO_GET_F(&this->actor) != ENGO_F_8) && (ENGO_GET_F(&this->actor) != ENGO_F_2) && 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 cfd252d07..37f56469d 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -154,8 +154,8 @@ void EnGs_Init(Actor* thisx, GlobalContext* globalCtx) { func_80997AFC(this->unk_194, &this->unk_1FA); this->unk_1F4 = this->unk_1FA; - Math_Vec3f_Copy(&this->unk_1B0[0], &D_801C5DB0); - Math_Vec3f_Copy(&this->unk_1B0[1], &D_801C5DB0); + Math_Vec3f_Copy(&this->unk_1B0[0], &gOneVec3f); + Math_Vec3f_Copy(&this->unk_1B0[1], &gOneVec3f); SubS_FillCutscenesList(&this->actor, this->unk_212, ARRAY_COUNT(this->unk_212)); func_801A5080(0); if (this->actor.params == ENGS_1) { @@ -183,8 +183,8 @@ void func_80997D38(EnGs* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 0) { if (this->actor.xzDistToPlayer <= D_8099A408[this->actor.params]) { - func_8013E8F8(&this->actor, globalCtx, D_8099A408[this->actor.params], D_8099A408[this->actor.params], 0, - 0x2000, 0x2000); + func_8013E8F8(&this->actor, globalCtx, D_8099A408[this->actor.params], D_8099A408[this->actor.params], + EXCH_ITEM_NONE, 0x2000, 0x2000); } } 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 7f847cf08..ed747c640 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -702,7 +702,7 @@ s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { f32 temp; s32 pad; - if (!func_8013AD6C(globalCtx) && (this->unk_3EC != 0)) { + if (!SubS_InCsMode(globalCtx) && (this->unk_3EC != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_3E2 / this->unk_3E0) <= 0.9f) { door->unk_1A7 = this->unk_2A4; @@ -748,7 +748,7 @@ s32 func_80BF25E8(EnIg* this, GlobalContext* globalCtx) { this->actor.world.pos.x = sp58.x; this->actor.world.pos.z = sp58.z; - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { sp54 = this->unk_294; sp50 = this->unk_290; sp58 = this->actor.world.pos; @@ -765,7 +765,7 @@ s32 func_80BF25E8(EnIg* this, GlobalContext* globalCtx) { this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { this->unk_294 = sp54; this->unk_290 = sp50; this->unk_278 = sp58; @@ -918,7 +918,7 @@ void EnIg_Update(Actor* thisx, GlobalContext* globalCtx) { func_80BF1258(this); func_80BF13E4(this); func_80BF15EC(this); - func_8013C964(&this->actor, globalCtx, 60.0f, 30.0f, 0, this->unk_3D0 & 7); + func_8013C964(&this->actor, globalCtx, 60.0f, 30.0f, EXCH_ITEM_NONE, this->unk_3D0 & 7); Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); func_80BF1354(this, globalCtx); 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 392d8091e..5c57c883f 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -379,7 +379,7 @@ void EnJa_Update(Actor* thisx, GlobalContext* globalCtx) { radius = this->collider.dim.radius + 30; height = this->collider.dim.height + 10; - func_8013C964(&this->actor, globalCtx, radius, height, 0, this->unk_340 & 7); + func_8013C964(&this->actor, globalCtx, radius, height, EXCH_ITEM_NONE, this->unk_340 & 7); if (this->unk_1D8.unk_00 != 2) { Actor_MoveWithGravity(&this->actor); diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 2736fc71a..21f9487ad 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -1086,7 +1086,7 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if (arg2->unk0 == 24) { Flags_UnsetSwitch(globalCtx, 0); Flags_UnsetSwitch(globalCtx, 1); - this->unk_394 = 0; + this->unk_394 = EXCH_ITEM_NONE; this->unk_368 = 60.0f; func_80AF7E98(this, 9); } @@ -1274,7 +1274,7 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; - this->unk_394 = 0; + this->unk_394 = EXCH_ITEM_NONE; this->unk_356 = 0; this->unk_368 = 40.0f; @@ -1409,7 +1409,7 @@ s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { Vec3f* sp28; f32 temp; - if (!func_8013AD6C(globalCtx) && (this->unk_374 != 0)) { + if (!SubS_InCsMode(globalCtx) && (this->unk_374 != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_36E / this->unk_36C) <= 0.9f) { door->unk_1A7 = this->unk_260; @@ -1457,7 +1457,7 @@ s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { this->actor.world.pos.x = sp58.x; this->actor.world.pos.z = sp58.z; - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { sp54 = this->unk_254; sp50 = this->unk_250; sp58 = this->actor.world.pos; @@ -1474,7 +1474,7 @@ s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { this->unk_254 = sp54; this->unk_250 = sp50; this->unk_238 = sp58; diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.c b/src/overlays/actors/ovl_En_Shn/z_en_shn.c index 92d4c7514..0a717ff2b 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.c +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.c @@ -380,7 +380,7 @@ void EnShn_Update(Actor* thisx, GlobalContext* globalCtx) { func_80AE6130(this); func_80AE63A8(this, globalCtx); this->unk_2E0 = 0; - func_8013C964(&this->actor, globalCtx, 120.0f, 40.0f, 0, this->unk_1D8 & 7); + func_8013C964(&this->actor, globalCtx, 120.0f, 40.0f, EXCH_ITEM_NONE, this->unk_1D8 & 7); } s32 EnShn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index dafed18c5..0503d0c56 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -758,7 +758,7 @@ s32 func_80BABFD4(EnSuttari* this, GlobalContext* globalCtx) { } this->actor.world.pos.x = sp58.x; this->actor.world.pos.z = sp58.z; - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { sp54 = this->unk424; sp50 = this->unk420; sp58 = this->actor.world.pos; @@ -772,7 +772,7 @@ s32 func_80BABFD4(EnSuttari* this, GlobalContext* globalCtx) { sp64 = this->unk408; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } - if (func_8013AD6C(globalCtx)) { + if (SubS_InCsMode(globalCtx)) { this->unk424 = sp54; this->unk420 = sp50; this->unk408 = sp58; diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index 48a1bc064..2d3ae2040 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -541,7 +541,7 @@ void EnTab_Update(Actor* thisx, GlobalContext* globalCtx) { radius = this->collider.dim.radius + this->unk_30C; height = this->collider.dim.height + 10; - func_8013C964(&this->actor, globalCtx, radius, height, 0, this->unk_2FC & 7); + func_8013C964(&this->actor, globalCtx, radius, height, EXCH_ITEM_NONE, this->unk_2FC & 7); Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); func_80BE0620(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 976a5ac31..830c86471 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -486,7 +486,7 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { } if (!(this->unk_3CE & 8) && !(this->unk_2CA & 0x10) && (this->actor.xzDistToPlayer < 100.0f)) { - func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, 0, 0x4000, 0x4000); + func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, EXCH_ITEM_NONE, 0x4000, 0x4000); } return false; @@ -695,7 +695,7 @@ void func_80AED940(EnTk* this, GlobalContext* globalCtx) { func_80AEDE10(this, globalCtx); } else if (!(this->unk_2CA & 0x80)) { if (this->actor.xzDistToPlayer < 100.0f) { - func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, 0, 0x4000, 0x4000); + func_8013E8F8(&this->actor, globalCtx, 100.0f, 100.0f, EXCH_ITEM_NONE, 0x4000, 0x4000); } } else { func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index ea0e8ae44..25c676cb6 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -1130,7 +1130,7 @@ void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.save.weekEventReg[16] & 0x10) { func_80A86924(this, 5); } else { - this->unk_388 = 0; + this->unk_388 = EXCH_ITEM_NONE; } this->actionFunc = func_80A87FD0; @@ -1156,7 +1156,7 @@ void EnTru_Update(Actor* thisx, GlobalContext* globalCtx) { func_80A86DB8(this); radius = this->collider.dim.worldSphere.radius + 30; - this->unk_388 = !(this->unk_34E & 0x80) ? 0 : 0; + this->unk_388 = !(this->unk_34E & 0x80) ? EXCH_ITEM_NONE : EXCH_ITEM_NONE; func_8013C964(&this->actor, globalCtx, radius, 20.0f, this->unk_388, this->unk_34E & 7); func_80A8697C(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 0f91171fb..8759d3b86 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -99,9 +99,9 @@ static AnimationInfoS sAnimations[] = { { &gZoraWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; -s8 D_8099F578[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2, -1, -1, -1, -1 }; -s8 D_8099F58C[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; -u8 D_8099F59C[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +s8 sBodyParts[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2, -1, -1, -1, -1 }; +s8 sParentBodyParts[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; +u8 sShadowSizes[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; s32 EnZo_SetAnimation(SkelAnime* skelAnime, s16 index) { s16 frameCount; @@ -310,8 +310,8 @@ void EnZo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Vec3f sp30 = { 400.0f, 0.0f, 0.0f }; Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - if (D_8099F578[limbIndex] >= 0) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->unk_364[D_8099F578[limbIndex]]); + if (sBodyParts[limbIndex] >= 0) { + Matrix_MultiplyVector3fByState(&zeroVec, &this->bodyPartsPos[sBodyParts[limbIndex]]); } if (limbIndex == 15) { Matrix_MultiplyVector3fByState(&sp30, &this->actor.focus.pos); @@ -336,9 +336,9 @@ static Gfx sTransparencyDlist[] = { void EnZo_Draw(Actor* thisx, GlobalContext* globalCtx) { EnZo* this = THIS; s32 i; - u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(u8) * SQ(64)); + u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); u8* shadowTexIter; - TexturePtr eyeTextures[] = { &gZoraEyeOpenTex, &gZoraEyeHalfTex, &gZoraEyeClosedTex }; + TexturePtr eyeTextures[] = { gZoraEyeOpenTex, gZoraEyeHalfTex, gZoraEyeClosedTex }; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); @@ -354,14 +354,15 @@ void EnZo_Draw(Actor* thisx, GlobalContext* globalCtx) { EnZo_OverrideLimbDraw, EnZo_PostLimbDraw, &this->actor, POLY_OPA_DISP); Matrix_InsertXRotation_s(0, 0); - for (i = 0, shadowTexIter = shadowTex; i < (s32)sizeof(u8) * SQ(64); i++) { + for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { *shadowTexIter = 0; shadowTexIter++; } for (i = 0; i < 5; i++) { - func_8013CD64(this->unk_364, &this->actor.world.pos, shadowTex, i / 5.0f, 15, D_8099F59C, D_8099F58C); + SubS_GenShadowTex(this->bodyPartsPos, &this->actor.world.pos, shadowTex, i / 5.0f, + ARRAY_COUNT(this->bodyPartsPos), sShadowSizes, sParentBodyParts); } - func_8013CF04(&this->actor, &globalCtx->state.gfxCtx, shadowTex); + SubS_DrawShadowTex(&this->actor, &globalCtx->state, shadowTex); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.h b/src/overlays/actors/ovl_En_Zo/z_en_zo.h index 0b9f8dab1..155c947d4 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.h +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.h @@ -30,7 +30,7 @@ typedef struct EnZo { /* 0x0300 */ UNK_TYPE1 unk_300[0x12]; /* 0x0312 */ s16 limbRotY[20]; /* 0x033A */ s16 limbRotZ[20]; - /* 0x0364 */ Vec3f unk_364[15]; + /* 0x0364 */ Vec3f bodyPartsPos[15]; /* 0x041A */ UNK_TYPE1 unk_41A[0x6]; /* 0x041E */ s16 eyeIndex; /* 0x0420 */ s16 blinkTimer; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 92f36da06..407187627 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2658,7 +2658,7 @@ 0x8013A7C0:("SubS_FindDoor",), 0x8013A860:("SubS_DrawTransformFlexLimb",), 0x8013AB00:("SubS_DrawTransformFlex",), - 0x8013AD6C:("func_8013AD6C",), + 0x8013AD6C:("SubS_InCsMode",), 0x8013AD9C:("func_8013AD9C",), 0x8013AED4:("SubS_UpdateFlags",), 0x8013AF00:("func_8013AF00",), @@ -2676,9 +2676,9 @@ 0x8013C624:("func_8013C624",), 0x8013C8B8:("SubS_CopyPointFromPathCheckBounds",), 0x8013C964:("func_8013C964",), - 0x8013CC2C:("func_8013CC2C",), - 0x8013CD64:("func_8013CD64",), - 0x8013CF04:("func_8013CF04",), + 0x8013CC2C:("SubS_FillShadowTex",), + 0x8013CD64:("SubS_GenShadowTex",), + 0x8013CF04:("SubS_DrawShadowTex",), 0x8013D0E0:("func_8013D0E0",), 0x8013D2E0:("func_8013D2E0",), 0x8013D5E8:("SubS_AngleDiffLessEqual",), @@ -2703,11 +2703,11 @@ 0x8013E1C8:("SubS_ChangeAnimationBySpeedInfo",), 0x8013E2D4:("SubS_StartActorCutscene",), 0x8013E3B8:("SubS_FillCutscenesList",), - 0x8013E4B0:("func_8013E4B0",), - 0x8013E5CC:("func_8013E5CC",), + 0x8013E4B0:("SubS_ConstructPlane",), + 0x8013E5CC:("SubS_LineSegVsPlane",), 0x8013E640:("SubS_FindActorCustom",), 0x8013E748:("func_8013E748",), - 0x8013E7C0:("func_8013E7C0",), + 0x8013E7C0:("SubS_ActorAndPlayerFaceEachOther",), 0x8013E8F8:("func_8013E8F8",), 0x8013E950:("func_8013E950",), 0x8013EC10:("func_8013EC10",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index e497bbcf3..6b1a7fcb7 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -920,8 +920,8 @@ 0x801BC288:("D_801BC288","Gfx","[3]",0x18), 0x801BC2A0:("D_801BC2A0","UNK_TYPE1","",0x1), 0x801BC3F0:("gEnHyBodyParts","UNK_TYPE1","",0x1), - 0x801BC400:("gEnHyBodyPartsIndex","UNK_TYPE1","",0x1), - 0x801BC410:("gEnHyShadowSize","s32",[],0x10), + 0x801BC400:("gEnHyParentBodyParts","UNK_TYPE1","",0x1), + 0x801BC410:("gEnHyShadowSizes","s32",[],0x10), 0x801BC420:("sReactionTextIds","u16","[]",0x140A), 0x801BD830:("actorCutscenesGlobalCutscenes","ActorCutscene","[8]",0x80), 0x801BD8B0:("actorCutsceneCurrent","s16","",0x2), @@ -1971,9 +1971,9 @@ 0x801C5CD0:("sMtxFClear","MtxF","",0x40), 0x801C5D10:("D_801C5D10","UNK_TYPE1","",0x1), 0x801C5D20:("D_801C5D20","UNK_TYPE1","",0x1), - 0x801C5D60:("D_801C5D60","UNK_TYPE1","",0x1), - 0x801C5D80:("D_801C5D80","UNK_TYPE1","",0x1), - 0x801C5DB0:("D_801C5DB0","UNK_TYPE1","",0x1), + 0x801C5D60:("gShadowDL","UNK_TYPE1","",0x1), + 0x801C5D80:("gShadowVtxDL","UNK_TYPE1","",0x1), + 0x801C5DB0:("gOneVec3f","UNK_TYPE1","",0x1), 0x801C5DD0:("D_801C5DD0","UNK_TYPE1","",0x1), 0x801C5DE0:("D_801C5DE0","UNK_TYPE1","",0x1), 0x801C5DF0:("D_801C5DF0","UNK_TYPE1","",0x1), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index a1267e0d3..8452179ab 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2172,7 +2172,7 @@ asm/non_matchings/code/z_snap/func_8013A530.s,func_8013A530,0x8013A530,0xA4 asm/non_matchings/code/z_sub_s/SubS_FindDoor.s,SubS_FindDoor,0x8013A7C0,0x28 asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlexLimb.s,SubS_DrawTransformFlexLimb,0x8013A860,0xA8 asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlex.s,SubS_DrawTransformFlex,0x8013AB00,0x9B -asm/non_matchings/code/z_sub_s/func_8013AD6C.s,func_8013AD6C,0x8013AD6C,0xC +asm/non_matchings/code/z_sub_s/SubS_InCsMode.s,SubS_InCsMode,0x8013AD6C,0xC asm/non_matchings/code/z_sub_s/func_8013AD9C.s,func_8013AD9C,0x8013AD9C,0x4E asm/non_matchings/code/z_sub_s/SubS_UpdateFlags.s,SubS_UpdateFlags,0x8013AED4,0xB asm/non_matchings/code/z_sub_s/func_8013AF00.s,func_8013AF00,0x8013AF00,0x44 @@ -2190,9 +2190,9 @@ asm/non_matchings/code/z_sub_s/func_8013C068.s,func_8013C068,0x8013C068,0x16F asm/non_matchings/code/z_sub_s/func_8013C624.s,func_8013C624,0x8013C624,0xA5 asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathCheckBounds.s,SubS_CopyPointFromPathCheckBounds,0x8013C8B8,0x2B asm/non_matchings/code/z_sub_s/func_8013C964.s,func_8013C964,0x8013C964,0xB2 -asm/non_matchings/code/z_sub_s/func_8013CC2C.s,func_8013CC2C,0x8013CC2C,0x4E -asm/non_matchings/code/z_sub_s/func_8013CD64.s,func_8013CD64,0x8013CD64,0x68 -asm/non_matchings/code/z_sub_s/func_8013CF04.s,func_8013CF04,0x8013CF04,0x77 +asm/non_matchings/code/z_sub_s/SubS_FillShadowTex.s,SubS_FillShadowTex,0x8013CC2C,0x4E +asm/non_matchings/code/z_sub_s/SubS_GenShadowTex.s,SubS_GenShadowTex,0x8013CD64,0x68 +asm/non_matchings/code/z_sub_s/SubS_DrawShadowTex.s,SubS_DrawShadowTex,0x8013CF04,0x77 asm/non_matchings/code/z_sub_s/func_8013D0E0.s,func_8013D0E0,0x8013D0E0,0x80 asm/non_matchings/code/z_sub_s/func_8013D2E0.s,func_8013D2E0,0x8013D2E0,0xC2 asm/non_matchings/code/z_sub_s/SubS_AngleDiffLessEqual.s,SubS_AngleDiffLessEqual,0x8013D5E8,0x18 @@ -2217,11 +2217,11 @@ asm/non_matchings/code/z_sub_s/SubS_ActorPathing_SetNextPoint.s,SubS_ActorPathin asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationBySpeedInfo.s,SubS_ChangeAnimationBySpeedInfo,0x8013E1C8,0x43 asm/non_matchings/code/z_sub_s/SubS_StartActorCutscene.s,SubS_StartActorCutscene,0x8013E2D4,0x39 asm/non_matchings/code/z_sub_s/SubS_FillCutscenesList.s,SubS_FillCutscenesList,0x8013E3B8,0x3E -asm/non_matchings/code/z_sub_s/func_8013E4B0.s,func_8013E4B0,0x8013E4B0,0x47 -asm/non_matchings/code/z_sub_s/func_8013E5CC.s,func_8013E5CC,0x8013E5CC,0x1D +asm/non_matchings/code/z_sub_s/SubS_ConstructPlane.s,SubS_ConstructPlane,0x8013E4B0,0x47 +asm/non_matchings/code/z_sub_s/SubS_LineSegVsPlane.s,SubS_LineSegVsPlane,0x8013E5CC,0x1D asm/non_matchings/code/z_sub_s/SubS_FindActorCustom.s,SubS_FindActorCustom,0x8013E640,0x42 asm/non_matchings/code/z_sub_s/func_8013E748.s,func_8013E748,0x8013E748,0x1E -asm/non_matchings/code/z_sub_s/func_8013E7C0.s,func_8013E7C0,0x8013E7C0,0x4E +asm/non_matchings/code/z_sub_s/SubS_ActorAndPlayerFaceEachOther.s,SubS_ActorAndPlayerFaceEachOther,0x8013E7C0,0x4E asm/non_matchings/code/z_sub_s/func_8013E8F8.s,func_8013E8F8,0x8013E8F8,0x16 asm/non_matchings/code/z_sub_s/func_8013E950.s,func_8013E950,0x8013E950,0xB0 asm/non_matchings/code/code_8013EC10/func_8013EC10.s,func_8013EC10,0x8013EC10,0xD From 31f0e19b576e944959b6aa4c5c771d09121352dd Mon Sep 17 00:00:00 2001 From: EllipticEllipsis Date: Fri, 22 Apr 2022 05:48:41 +0100 Subject: [PATCH 201/257] Enable full IDO warnings (#781) * Fix a lot of IDO warnings (and some Clang ones) * Format * Put FULL_DISASM=0 back * Fix bss --- Makefile | 2 +- include/functions.h | 4 ++-- include/z64animation.h | 5 +++- src/code/audio/audio_load.c | 2 ++ src/code/graph.c | 2 +- src/code/z_actor.c | 2 +- src/code/z_bgcheck.c | 4 +++- src/code/z_demo.c | 1 + src/code/z_eff_blure.c | 3 +-- src/code/z_lights.c | 2 +- src/code/z_quake.c | 2 +- src/code/z_scene.c | 6 ++--- src/code/z_scene_proc.c | 2 +- src/code/z_skelanime.c | 20 ++++++++-------- src/code/z_sram_NES.c | 2 +- .../actors/ovl_Bg_Ingate/z_bg_ingate.c | 1 - .../actors/ovl_Door_Warp1/z_door_warp1.c | 1 + .../actors/ovl_En_Aob_01/z_en_aob_01.c | 1 - src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 1 - src/overlays/actors/ovl_En_Gb2/z_en_gb2.c | 1 - src/overlays/actors/ovl_En_Go/z_en_go.c | 17 ++++++------- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 1 - .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 13 +++------- .../actors/ovl_En_Look_Nuts/z_en_look_nuts.c | 2 ++ .../actors/ovl_En_Ma_Yto/z_en_ma_yto.c | 24 ++++++++----------- .../ovl_En_Po_Sisters/z_en_po_sisters.c | 2 +- src/overlays/actors/ovl_En_Rg/z_en_rg.c | 1 + src/overlays/actors/ovl_En_Sw/z_en_sw.c | 4 ++++ .../actors/ovl_En_Tanron5/z_en_tanron5.c | 3 ++- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 2 +- src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c | 7 ++---- .../actors/ovl_Obj_Driftice/z_obj_driftice.c | 1 + .../actors/ovl_Obj_Nozoki/z_obj_nozoki.c | 1 + .../actors/ovl_Obj_Switch/z_obj_switch.c | 8 +++---- .../actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c | 2 +- .../ovl_Obj_Vspinyroll/z_obj_vspinyroll.c | 1 + tools/disasm/functions.txt | 4 ++-- 37 files changed, 78 insertions(+), 79 deletions(-) diff --git a/Makefile b/Makefile index 7326b88a7..ac7174e89 100644 --- a/Makefile +++ b/Makefile @@ -100,7 +100,7 @@ ASFLAGS := -march=vr4300 -32 -Iinclude MIPS_VERSION := -mips2 # we support Microsoft extensions such as anonymous structs, which the compiler does support but warns for their usage. Surpress the warnings with -woff. -CFLAGS += -G 0 -non_shared -Xfullwarn -Xcpluscomm $(IINC) -nostdinc -Wab,-r4300_mul -woff 624,649,838,712 +CFLAGS += -G 0 -non_shared -fullwarn -verbose -Xcpluscomm $(IINC) -nostdinc -Wab,-r4300_mul -woff 624,649,838,712,516 # Use relocations and abi fpr names in the dump OBJDUMP_FLAGS := -d -r -z -Mreg-names=32 diff --git a/include/functions.h b/include/functions.h index 0cb86ad74..501b45776 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2237,7 +2237,7 @@ void Scene_HeaderCmdPathList(GlobalContext* globalCtx, SceneCmd* cmd); void Scene_HeaderCmdTransiActorList(GlobalContext* globalCtx, SceneCmd* cmd); void Door_InitContext(GameState* gameState, DoorContext* doorCtx); void Scene_HeaderCmdEnvLightSettings(GlobalContext* globalCtx, SceneCmd* cmd); -s32 Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex); +void Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex); void Scene_HeaderCmdSkyboxSettings(GlobalContext* globalCtx, SceneCmd* cmd); void Scene_HeaderCmdSkyboxDisables(GlobalContext* globalCtx, SceneCmd* cmd); void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd); @@ -2887,7 +2887,7 @@ void* GameAlloc_Malloc(GameAlloc* this, size_t size); void GameAlloc_Free(GameAlloc* this, void* data); void GameAlloc_Cleanup(GameAlloc* this); void GameAlloc_Init(GameAlloc* this); -void* Graph_FaultClient(void); +void Graph_FaultClient(void); void Graph_InitTHGA(TwoHeadGfxArena* arena, Gfx* buffer, s32 size); void Graph_SetNextGfxPool(GraphicsContext* gfxCtx); GameStateOverlay* Graph_GetNextGameState(GameState* gameState); diff --git a/include/z64animation.h b/include/z64animation.h index 974b8bea0..58ddb34df 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -187,7 +187,10 @@ typedef struct SkelAnime { /* 0x24 */ Vec3s* morphTable; // Table of values used to morph between animations /* 0x28 */ f32 morphWeight; // Weight of the current animation morph as a fraction in [0,1] /* 0x2C */ f32 morphRate; // Reciprocal of the number of frames in the morph - /* 0x30 */ s32 (*update)(); // Can be Loop, Partial loop, Play once, Morph, or Tapered morph. Link only has Loop, Play once, and Morph + /* 0x30 */ union { + s32 (*normal)(struct SkelAnime*);// Can be Loop, Partial loop, Play once, Morph, or Tapered morph + s32 (*link)(struct GlobalContext*, struct SkelAnime*); // Loop, Play once, and Morph + } update; /* 0x34 */ s8 initFlags; // Flags used when initializing Link's skeleton /* 0x35 */ u8 moveFlags; // Flags used for animations that move the actor in worldspace. /* 0x36 */ s16 prevRot; // Previous rotation in worldspace. diff --git a/src/code/audio/audio_load.c b/src/code/audio/audio_load.c index b63f8192b..8faf565ea 100644 --- a/src/code/audio/audio_load.c +++ b/src/code/audio/audio_load.c @@ -459,6 +459,7 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { if (instrument->normalRangeHi != 0x7F) { return AudioLoad_SyncLoadSample(instrument->highNotesSound.sample, fontId); } + // TODO: is this missing return UB? } else if (instId == 0x7F) { Drum* drum = AudioPlayback_GetDrum(fontId, drumId); @@ -468,6 +469,7 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { AudioLoad_SyncLoadSample(drum->sound.sample, fontId); return 0; } + // TODO: is this missing return UB? } void AudioLoad_AsyncLoad(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue) { diff --git a/src/code/graph.c b/src/code/graph.c index 8059d1f63..128aa0ee4 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -13,7 +13,7 @@ GfxMasterList* gGfxMasterDL; CfbInfo sGraphCfbInfos[3]; OSTime sGraphTaskStartTime; -void* Graph_FaultClient(void) { +void Graph_FaultClient(void) { FaultDrawer_DrawText(30, 100, "ShowFrameBuffer PAGE 0/1"); osViSwapBuffer(SysCfb_GetFbPtr(0)); osViSetMode(D_801FBB88); diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 93eeeddc7..24bc91a17 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -240,7 +240,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx } actor->shape.unk_17 &= ~spB8; - if (!mapper->l.l) {} // POSSIBLE FAKE MATCH + if ((uintptr_t)mapper->l.l) {} // POSSIBLE FAKE MATCH } } diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index b2891de90..028f68011 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -4441,11 +4441,13 @@ s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx, return false; } +// boolean s32 WaterBox_GetSurface1(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { - WaterBox_GetSurface1_2(globalCtx, colCtx, x, z, ySurface, outWaterBox); + return WaterBox_GetSurface1_2(globalCtx, colCtx, x, z, ySurface, outWaterBox); } +// boolean s32 WaterBox_GetSurface1_2(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { s32 bgId; diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 0af7dfb4d..762be4538 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1418,6 +1418,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, } } #else +void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cutscenePtr); #pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_ProcessCommands.s") #endif diff --git a/src/code/z_eff_blure.c b/src/code/z_eff_blure.c index b17799aff..6ab70f1ef 100644 --- a/src/code/z_eff_blure.c +++ b/src/code/z_eff_blure.c @@ -309,6 +309,7 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3 Vec3s sp30; f32 mode4Param; EffectBlureElement* elem = &this->elements[index]; + Vec3s* unusedPtr = &sp30; // Optimized out but seems necessary to match stack usage switch (this->calcMode) { case 1: @@ -367,8 +368,6 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3 break; } - sp30 = sp30; // Optimized out but seems necessary to match stack usage - if (this->flags & 0x10) { color1->r = color1->g = color1->b = color1->a = 255; color2->r = color2->g = color2->b = color2->a = 255; diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 2b0db8ad4..5d47b4153 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -216,7 +216,7 @@ void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, GlobalCo } } -LightNode* Lights_FindBufSlot() { +LightNode* Lights_FindBufSlot(void) { LightNode* ret; if (sLightsBuffer.numOccupied >= LIGHTS_BUFFER_SIZE) { diff --git a/src/code/z_quake.c b/src/code/z_quake.c index ee4fa3a6d..d57dc8e54 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -638,7 +638,7 @@ void Distortion_Update(void) { sDistortionContext.countdown = 2; player = GET_PLAYER(globalCtx); - if (&player->actor != NULL) { + if (player != NULL) { Actor_GetWorldPosShapeRot(&playerPosRot, &player->actor); } diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 8a9bdd4e7..b03990702 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -341,7 +341,7 @@ void Scene_HeaderCmdEnvLightSettings(GlobalContext* globalCtx, SceneCmd* cmd) { * Loads different texture files for each region of the world. * These later are stored in segment 0x06, and used in maps. */ -s32 Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) { +void Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) { static RomFile sceneTextureFiles[9] = { { 0, 0 }, // Default { SEGMENT_ROM_START(scene_texture_01), SEGMENT_ROM_END(scene_texture_01) }, @@ -358,10 +358,8 @@ s32 Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) { if (size != 0) { globalCtx->roomCtx.unk74 = THA_AllocEndAlign16(&globalCtx->state.heap, size); - return DmaMgr_SendRequest0(globalCtx->roomCtx.unk74, vromStart, size); + DmaMgr_SendRequest0(globalCtx->roomCtx.unk74, vromStart, size); } - - // UB: Undefined behaviour to not have a return statement here, but it breaks matching to add one. } // SceneTableEntry Header Command 0x11: Skybox Settings diff --git a/src/code/z_scene_proc.c b/src/code/z_scene_proc.c index f7f71a2dd..8f369008f 100644 --- a/src/code/z_scene_proc.c +++ b/src/code/z_scene_proc.c @@ -234,7 +234,7 @@ f32 Scene_LagrangeInterp(s32 n, f32 x[], f32 fx[], f32 xp) { s32 i; s32 j; - for (i = 0, weightsPtr = weights, xPtr1 = x, fxPtr = fx, weightsPtr = weightsPtr; i < n; i++) { + for (i = 0, xPtr1 = x, fxPtr = fx, weightsPtr = weights; i < n; i++) { for (xVal = *xPtr1, m = 1.0f, j = 0, xPtr2 = x; j < n; j++) { if (j != i) { m *= xVal - (*xPtr2); diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 8ad36c891..6563eecfc 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1238,9 +1238,9 @@ void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkel */ void LinkAnimation_SetUpdateFunction(SkelAnime* skelAnime) { if (skelAnime->mode <= ANIMMODE_LOOP_INTERP) { - skelAnime->update = LinkAnimation_Loop; + skelAnime->update.link = LinkAnimation_Loop; } else { - skelAnime->update = LinkAnimation_Once; + skelAnime->update.link = LinkAnimation_Once; } skelAnime->morphWeight = 0.0f; } @@ -1250,7 +1250,7 @@ void LinkAnimation_SetUpdateFunction(SkelAnime* skelAnime) { * finishes. */ s32 LinkAnimation_Update(GlobalContext* globalCtx, SkelAnime* skelAnime) { - return skelAnime->update(globalCtx, skelAnime); + return skelAnime->update.link(globalCtx, skelAnime); } /** @@ -1355,7 +1355,7 @@ void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAn SkelAnime_CopyFrameTable(skelAnime, skelAnime->morphTable, skelAnime->jointTable); morphFrames = -morphFrames; } else { - skelAnime->update = LinkAnimation_Morph; + skelAnime->update.link = LinkAnimation_Morph; AnimationContext_SetLoadFrame(globalCtx, animation, (s32)startFrame, skelAnime->limbCount, skelAnime->morphTable); } @@ -1599,11 +1599,11 @@ void SkelAnime_InitSkin(GameState* gameState, SkelAnime* skelAnime, SkeletonHead */ void SkelAnime_SetUpdate(SkelAnime* skelAnime) { if (skelAnime->mode <= ANIMMODE_LOOP_INTERP) { - skelAnime->update = SkelAnime_LoopFull; + skelAnime->update.normal = SkelAnime_LoopFull; } else if (skelAnime->mode <= ANIMMODE_ONCE_INTERP) { - skelAnime->update = SkelAnime_Once; + skelAnime->update.normal = SkelAnime_Once; } else { - skelAnime->update = SkelAnime_LoopPartial; + skelAnime->update.normal = SkelAnime_LoopPartial; } } @@ -1612,7 +1612,7 @@ void SkelAnime_SetUpdate(SkelAnime* skelAnime) { * finishes. */ s32 SkelAnime_Update(SkelAnime* skelAnime) { - return skelAnime->update(skelAnime); + return skelAnime->update.normal(skelAnime); } /** @@ -1774,10 +1774,10 @@ void Animation_ChangeImpl(SkelAnime* skelAnime, AnimationHeader* animation, f32 morphFrames = -morphFrames; } else { if (taper != ANIMTAPER_NONE) { - skelAnime->update = SkelAnime_MorphTaper; + skelAnime->update.normal = SkelAnime_MorphTaper; skelAnime->taper = taper; } else { - skelAnime->update = SkelAnime_Morph; + skelAnime->update.normal = SkelAnime_Morph; } SkelAnime_GetFrameData(animation, startFrame, skelAnime->limbCount, skelAnime->morphTable); } diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 52acc9379..90b60809e 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -1495,7 +1495,7 @@ void func_80146DF8(SramContext* sramCtx) { } void Sram_InitSram(GameState* gameState, SramContext* sramCtx) { - if (&gSaveContext.save) {} + if (gSaveContext.save.entranceIndex) {} // Required to match func_801A3D98(gSaveContext.options.audioSetting); } diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index 8c55cc2f3..11936a9d2 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -300,7 +300,6 @@ void func_809543D4(BgIngate* this, GlobalContext* globalCtx) { gSaveContext.save.weekEventReg[90] &= (u8)~0x40; func_8019F208(); } else { - this = this; func_800B7298(globalCtx, &this->dyna.actor, 6); this->unk160 &= ~0x4; this->actionFunc = func_809541B8; diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index b2b05230f..dd41ac015 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -1093,6 +1093,7 @@ static Color_RGB8 D_808BBB50[] = { { 0, 50, 200 }, { 120, 150, 0 }, }; +void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BB4F4.s") #endif diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index b06b57ebd..9bfd07939 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -669,7 +669,6 @@ void func_809C2730(EnAob01* this, GlobalContext* globalCtx) { void func_809C2788(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x20; if (func_809C25E4(this, globalCtx)) { - globalCtx = globalCtx; if (func_801A8A50(0) != 0x41) { globalCtx->nextEntranceIndex = 0x7C10; gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & (u8)~7) | 3; diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index 38ab1c5d2..09ed84312 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -775,7 +775,6 @@ void EnBigpo_AdjustPoAlpha(EnBigpo* this, s32 alphaDiff) { this->actor.scale.x = newXYScale; this->actor.scale.z = newXYScale; this->actor.scale.y = (0.007f - (0.007f * lowerAlpha)) + 0.007f; - lowerAlpha = lowerAlpha; } else { Actor_SetScale(&this->actor, lowerAlpha * 0.007f); this->actor.world.pos.y = this->savedHeight + (lowerAlpha * 15.0f); 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 82010f193..947afd914 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -982,7 +982,6 @@ s32 EnGb2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnGb2* this = THIS; if (limbIndex == 7) { - limbIndex = limbIndex; Matrix_RotateY(this->unk_270.y, MTXMODE_APPLY); } 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 9a15d26f5..c05de7ab8 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -213,7 +213,7 @@ static AnimationInfoS sAnimations[] = { { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; -EnGoStruct* func_80A10FD0(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6) { +EnGoStruct* func_80A10FD0(EnGoStruct* ptr, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6) { s32 i; for (i = 16; i < 32; i++, ptr++) { @@ -233,7 +233,7 @@ EnGoStruct* func_80A10FD0(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, return ptr; } -void func_80A11144(EnGoStruct ptr[], GlobalContext* globalCtx) { +void func_80A11144(EnGoStruct* ptr, GlobalContext* globalCtx) { s32 pad; s32 i; s32 flag = false; @@ -279,7 +279,7 @@ void func_80A11144(EnGoStruct ptr[], GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -void func_80A1143C(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6, s32 arg7) { +void func_80A1143C(EnGoStruct* ptr, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6, s32 arg7) { s32 i; for (i = 16; i < 32; i++, ptr++) { @@ -299,7 +299,7 @@ void func_80A1143C(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg } } -void func_80A115B4(EnGoStruct ptr[], GlobalContext* globalCtx) { +void func_80A115B4(EnGoStruct* ptr, GlobalContext* globalCtx) { static TexturePtr D_80A16644[] = { gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, }; @@ -355,7 +355,7 @@ void func_80A115B4(EnGoStruct ptr[], GlobalContext* globalCtx) { } #ifdef NON_MATCHING -void func_80A118F8(EnGoStruct ptr[32], Vec3f arg1) { +void func_80A118F8(EnGoStruct* ptr, Vec3f arg1) { static u8 D_80A1667C[] = { 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, }; @@ -400,10 +400,11 @@ void func_80A118F8(EnGoStruct ptr[32], Vec3f arg1) { static u8 D_80A1667C[] = { 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, }; +void func_80A118F8(EnGoStruct* ptr, Vec3f arg1); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A118F8.s") #endif -void func_80A11BF8(EnGoStruct ptr[], f32 arg1) { +void func_80A11BF8(EnGoStruct* ptr, f32 arg1) { f32 test; f32 test2; f32 x; @@ -449,7 +450,7 @@ void func_80A11BF8(EnGoStruct ptr[], f32 arg1) { } #ifdef NON_MATCHING -void func_80A11EC0(EnGoStruct ptr[], GlobalContext* globalCtx, Gfx arg2[], Gfx arg3[], u8 arg4) { +void func_80A11EC0(EnGoStruct* ptr, GlobalContext* globalCtx, Gfx* arg2, Gfx* arg3, u8 arg4) { s32 i; u8 flag = false; @@ -484,6 +485,7 @@ void func_80A11EC0(EnGoStruct ptr[], GlobalContext* globalCtx, Gfx arg2[], Gfx a CLOSE_DISPS(globalCtx->state.gfxCtx); } #else +void func_80A11EC0(EnGoStruct* ptr, GlobalContext* globalCtx, Gfx* arg2, Gfx* arg3, u8 arg4); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A11EC0.s") #endif @@ -1976,7 +1978,6 @@ s32 EnGo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, s32 idx; if ((ENGO_GET_F(&this->actor) == ENGO_F_8) && (limbIndex == 10)) { - limbIndex = limbIndex; Matrix_GetStateTranslation(&sp30); sp30.y = this->actor.world.pos.y; Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp30); 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 440ac3578..d71ac41af 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -4555,7 +4555,6 @@ void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { if (this->type == HORSE_2) { Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); } else { - curFrame = curFrame; Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); } EnHorse_RandomOffset(&sp64, 10.0f, &this->frontRightHoof); diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 8d2f416a7..c80b9432c 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -3956,21 +3956,14 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { Vec3f sp4C; Vec3f sp40; s16 diff; - s8 temp_v1; + s16 pad; s16 sp3A; - s8 temp_v0; + s16 pad2; func_80B44700(this); func_80B44EFC(this, globalCtx); func_80B43E6C(this, 6, 2000, 100); - if (1) {} - temp_v1 = this->pathIndex; - temp_v0 = this->endPoint; - phi_a2 = temp_v0 - 1; - if (temp_v1 < temp_v0) { - phi_a2 = temp_v1; - } else if (temp_v1_3) { - } + phi_a2 = ((this->pathIndex < this->endPoint) ? this->pathIndex : this->endPoint - 1); Math_Vec3s_ToVec3f(&sp4C, &this->pathPoints[phi_a2]); Math_Vec3s_ToVec3f(&sp40, &this->pathPoints[phi_a2 + 1]); diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c index 1bbf6fee4..73a559a70 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c @@ -169,6 +169,7 @@ void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx) { sp34 = SubS_GetDistSqAndOrientPath(this->path, this->currentPathIndex, &this->actor.world.pos, &sp30); } + //! @bug sp30 is uninitialised if path == NULL. Fix by enclosing everything in the path NULL check. if (sp30 < 10.0f) { if (this->path != NULL) { this->currentPathIndex++; @@ -181,6 +182,7 @@ void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx) { } } } + Math_SmoothStepToS(&this->actor.shape.rot.y, sp34, 1, 0x1388, 0); this->actor.world.rot.y = this->actor.shape.rot.y; } diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c index bd92db4bc..5847aa897 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -22,7 +22,6 @@ void EnMaYto_ChooseAction(EnMaYto* this, GlobalContext* globalCtx); s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupKeepLookingForRomani(EnMaYto* this); void EnMaYto_KeepLookingForRomani(EnMaYto* this, GlobalContext* globalCtx); - void EnMaYto_SetupDefaultWait(EnMaYto* this); void EnMaYto_DefaultWait(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupDefaultDialogueHandler(EnMaYto* this); @@ -44,7 +43,6 @@ void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this); void EnMaYto_AfterMilkRunInit(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupAfterMilkRunDialogueHandler(EnMaYto* this); void EnMaYto_AfterMilkRunDialogueHandler(EnMaYto* this, GlobalContext* globalCtx); - void EnMaYto_AfterMilkRunChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupPostMilkRunGiveReward(EnMaYto* this); void EnMaYto_PostMilkRunGiveReward(EnMaYto* this, GlobalContext* globalCtx); @@ -53,7 +51,6 @@ void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupBeginWarmFuzzyFeelingCs(EnMaYto* this); void EnMaYto_BeginWarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupWarmFuzzyFeelingCs(EnMaYto* this); - void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx); void EnMaYto_SetupPostMilkRunWaitDialogueEnd(EnMaYto* this); void EnMaYto_PostMilkRunWaitDialogueEnd(EnMaYto* this, GlobalContext* globalCtx); @@ -68,9 +65,8 @@ void func_80B90E50(EnMaYto* this, s16); void EnMaYto_SetRomaniFaceExpression(EnMaYto* this, s16 overrideEyeTexIndex, s16 mouthTexIndex); void EnMaYto_SetFaceExpression(EnMaYto* this, s16 overrideEyeTexIndex, s16 mouthIndex); void EnMaYto_InitFaceExpression(EnMaYto* this); -s32 EnMaYto_HasSpokeToPlayerToday(); - -s32 EnMaYto_HasSpokeToPlayer(void); +s32 EnMaYto_HasSpokenToPlayerToday(void); +s32 EnMaYto_HasSpokenToPlayer(void); void EnMaYto_SetTalkedFlag(void); const ActorInit En_Ma_Yto_InitVars = { @@ -1129,7 +1125,7 @@ void EnMaYto_DefaultStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; } } else { - if (EnMaYto_HasSpokeToPlayer()) { + if (EnMaYto_HasSpokenToPlayer()) { Message_StartTextbox(globalCtx, 0x3394, &this->actor); this->textId = 0x3394; } else { @@ -1140,7 +1136,7 @@ void EnMaYto_DefaultStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { } } } else if (CURRENT_DAY == 3) { - if (EnMaYto_HasSpokeToPlayerToday()) { + if (EnMaYto_HasSpokenToPlayerToday()) { EnMaYto_SetFaceExpression(this, 0, 3); Message_StartTextbox(globalCtx, 0x33C5, &this->actor); this->textId = 0x33C5; @@ -1186,7 +1182,7 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; } } else { - if (EnMaYto_HasSpokeToPlayer()) { + if (EnMaYto_HasSpokenToPlayer()) { Message_StartTextbox(globalCtx, 0x339F, &this->actor); this->textId = 0x339F; } else { @@ -1198,7 +1194,7 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; case 2: - if (EnMaYto_HasSpokeToPlayer()) { + if (EnMaYto_HasSpokenToPlayer()) { Message_StartTextbox(globalCtx, 0x33A6, &this->actor); this->textId = 0x33A6; func_80151BB4(globalCtx, 6); @@ -1210,7 +1206,7 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { break; case 3: - if (EnMaYto_HasSpokeToPlayer()) { + if (EnMaYto_HasSpokenToPlayer()) { Message_StartTextbox(globalCtx, 0x33A8, &this->actor); this->textId = 0x33A8; func_80151BB4(globalCtx, 6); @@ -1249,7 +1245,7 @@ void EnMaYto_BarnStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { } } } else { - if (EnMaYto_HasSpokeToPlayer()) { + if (EnMaYto_HasSpokenToPlayer()) { this->unk31E = 2; EnMaYto_SetFaceExpression(this, 5, 3); Message_StartTextbox(globalCtx, 0x33B3, &this->actor); @@ -1357,7 +1353,7 @@ void EnMaYto_InitFaceExpression(EnMaYto* this) { } } -s32 EnMaYto_HasSpokeToPlayerToday(void) { +s32 EnMaYto_HasSpokenToPlayerToday(void) { switch (CURRENT_DAY) { case 1: if (gSaveContext.save.weekEventReg[13] & 4) { @@ -1380,7 +1376,7 @@ s32 EnMaYto_HasSpokeToPlayerToday(void) { return false; } -s32 EnMaYto_HasSpokeToPlayer(void) { +s32 EnMaYto_HasSpokenToPlayer(void) { // Please note each case doesn't have their respective `break`s. switch (CURRENT_DAY) { case 3: diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index 1cd7a4f83..29dc269d4 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c @@ -219,7 +219,7 @@ void func_80B1A768(EnPoSisters* this, GlobalContext* globalCtx) { Math_StepToF(&this->unk_2EC, 170.0f, 10.0f); } sp20 = this->unk_2EC; - } else if (this->unk_18D != 0) { + } else if (this->unk_18D != 0) { // An else would be sufficient sp20 = this->actor.parent->xzDistToPlayer; } diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index 13d4a93e9..09d2093ce 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -401,6 +401,7 @@ s32 func_80BF43FC(EnRg* this) { return phi_s4; } #else +s32 func_80BF43FC(EnRg* this); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rg/func_80BF43FC.s") #endif diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index f0d1a3aa7..91d602f87 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -450,6 +450,7 @@ void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 } } #else +void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 arg4); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808D94D0.s") #endif @@ -816,6 +817,7 @@ void func_808DA578(EnSw* this, GlobalContext* globalCtx) { this->unk_414 = temp_f0; } #else +void func_808DA578(EnSw* this, GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DA578.s") #endif @@ -854,6 +856,7 @@ void func_808DA6FC(EnSw* this, GlobalContext* globalCtx) { this->unk_414 = sp4C; } #else +void func_808DA6FC(EnSw* this, GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DA6FC.s") #endif @@ -1013,6 +1016,7 @@ void func_808DACF4(EnSw* this, GlobalContext* globalCtx) { this->unk_414 = sp4C; } #else +void func_808DACF4(EnSw* this, GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DACF4.s") #endif diff --git a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c index 1927b4edb..85baedbc8 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c @@ -309,7 +309,8 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { spAC = 780.0f; this->unk_19C *= 1.5f; } - + // TODO: determine if unk_1A0 ever has a different value from these 3, which will cause UB from spAC + // being uninitialised this->actor.world.pos.y -= D_80BE5DD0 * spAC; Actor_SetScale(&this->actor, this->unk_19C * D_80BE5DD0); Math_Vec3f_Copy(&spB8, &this->actor.world.pos); diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index 25c676cb6..7cf13c6af 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -320,6 +320,7 @@ void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } #else +void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru/func_80A85F84.s") #endif @@ -580,7 +581,6 @@ s32 func_80A86DB8(EnTru* this) { if (this->skelAnime.curFrame < 57.0f) { if (DECR(this->unk_36C) == 0) { - this = this; this->unk_36C = Rand_S16Offset(8, 8); this->unk_36E = 2; } else { diff --git a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c index dd57b99e4..14e25c57d 100644 --- a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c +++ b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c @@ -119,19 +119,16 @@ s32 func_80A35510(ObjBell* this, s32 arg1) { if (((arg1 == 0) && (this->unk_21C < 1000.0f)) || ((arg1 == 1) && (this->unk_21C < 4000.0f)) || (arg1 == 2)) { phi_a3 = true; - } else { - phi_a3 = phi_a3; } switch (arg1) { case 0: - this->unk_21C += this->unk_21C > 1000.0f ? 250.0f : 1000.0f; + this->unk_21C += ((this->unk_21C > 1000.0f) ? 250.0f : 1000.0f); break; case 1: - this->unk_21C += this->unk_21C > 3000.0f ? 750.0f : 3000.0f; + this->unk_21C += ((this->unk_21C > 3000.0f) ? 750.0f : 3000.0f); break; case 2: - if (1) {} this->unk_21C += 9000.0f; break; } diff --git a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c index abd30b256..660e68b6d 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c @@ -198,6 +198,7 @@ void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* *arg2 = (s32)temp_f22 + arg0->unk_00[2]; } #else +void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* arg3); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66930.s") #endif diff --git a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c index c0ce7408e..2ff0e093e 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c @@ -6,6 +6,7 @@ #include "z_obj_nozoki.h" #include "objects/object_secom_obj/object_secom_obj.h" +#include "prevent_bss_reordering.h" #define FLAGS (ACTOR_FLAG_10) diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c index 7bea97826..bfe1f24b1 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -241,10 +241,10 @@ void ObjSwitch_InitTrisCollider(ObjSwitch* this, GlobalContext* globalCtx, Colli } Actor* ObjSwitch_SpawnIce(ObjSwitch* this, GlobalContext* globalCtx) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_OBJ_ICE_POLY, - this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 25.0f, this->dyna.actor.world.pos.z, - this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, this->dyna.actor.world.rot.z, - 0xFF32); + return Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_OBJ_ICE_POLY, + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 25.0f, + this->dyna.actor.world.pos.z, this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, + this->dyna.actor.world.rot.z, 0xFF32); } void ObjSwitch_SetSwitchFlagState(ObjSwitch* this, GlobalContext* globalCtx, s32 setFlag) { diff --git a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c index d13a3bb4d..95f0eb3a8 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -87,7 +87,7 @@ static InitChainEntry sInitChain[] = { * angle can differ from the target angle if the panel is in * the middle of rotating. */ -s32 ObjTokeidai_GetTargetSunMoonPanelRotation() { +s32 ObjTokeidai_GetTargetSunMoonPanelRotation(void) { if (gSaveContext.save.isNight) { return 0x8000; } diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c index 9c5d22bac..9e36e5a2a 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c @@ -223,6 +223,7 @@ s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s3 return sp9C; } #else +s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C8D8.s") #endif diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 407187627..564373b6f 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -14808,8 +14808,8 @@ 0x80B90E84:("EnMaYto_SetRomaniFaceExpression",), 0x80B90EC8:("EnMaYto_SetFaceExpression",), 0x80B90EF0:("EnMaYto_InitFaceExpression",), - 0x80B90F84:("EnMaYto_HasSpokeToPlayerToday",), - 0x80B91014:("EnMaYto_HasSpokeToPlayer",), + 0x80B90F84:("EnMaYto_HasSpokenToPlayerToday",), + 0x80B91014:("EnMaYto_HasSpokenToPlayer",), 0x80B9109C:("EnMaYto_SetTalkedFlag",), 0x80B9110C:("EnMaYto_Update",), 0x80B91154:("EnMaYto_OverrideLimbDraw",), From 51dcbd728ed62eb2b661911284ce8821a3a8a451 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 24 Apr 2022 17:09:41 +0100 Subject: [PATCH 202/257] Demo_Effect (#764) * Demo_Effect * PR * PR * Fix --- assets/xml/objects/object_efc_tw.xml | 11 +- spec | 3 +- .../actors/ovl_Demo_Effect/z_demo_effect.c | 293 +++++++++++++++++- .../actors/ovl_Demo_Effect/z_demo_effect.h | 12 +- undefined_syms.txt | 6 - 5 files changed, 295 insertions(+), 30 deletions(-) diff --git a/assets/xml/objects/object_efc_tw.xml b/assets/xml/objects/object_efc_tw.xml index 4d4c1029c..3cb6468b9 100644 --- a/assets/xml/objects/object_efc_tw.xml +++ b/assets/xml/objects/object_efc_tw.xml @@ -1,10 +1,13 @@  - + + + + - - - + + + diff --git a/spec b/spec index 045619bcd..c047e1c35 100644 --- a/spec +++ b/spec @@ -1116,8 +1116,7 @@ beginseg name "ovl_Demo_Effect" compress include "build/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.o" - include "build/data/ovl_Demo_Effect/ovl_Demo_Effect.data.o" - include "build/data/ovl_Demo_Effect/ovl_Demo_Effect.reloc.o" + include "build/src/overlays/actors/ovl_Demo_Effect/ovl_Demo_Effect_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c index 18be6991c..108f128ae 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c @@ -5,6 +5,8 @@ */ #include "z_demo_effect.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_efc_tw/object_efc_tw.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,11 +17,14 @@ void DemoEffect_Destroy(Actor* thisx, GlobalContext* globalCtx); void DemoEffect_Update(Actor* thisx, GlobalContext* globalCtx); void func_808CD940(DemoEffect* this, GlobalContext* globalCtx); +void func_808CD998(DemoEffect* this, GlobalContext* globalCtx); void func_808CDBDC(DemoEffect* this, GlobalContext* globalCtx); void func_808CDCEC(DemoEffect* this, GlobalContext* globalCtx); void func_808CDD70(DemoEffect* this, GlobalContext* globalCtx); +void func_808CDDE0(DemoEffect* this, GlobalContext* globalCtx); +void func_808CDFF8(Actor* thisx, GlobalContext* globalCtx); +void func_808CE078(Actor* thisx, GlobalContext* globalCtx2); -#if 0 const ActorInit Demo_Effect_InitVars = { ACTOR_DEMO_EFFECT, ACTORCAT_BG, @@ -32,33 +37,287 @@ const ActorInit Demo_Effect_InitVars = { (ActorFunc)NULL, }; -#endif +void DemoEffect_Init(Actor* thisx, GlobalContext* globalCtx) { + static s16 D_808CE2C0[] = { + OBJECT_EFC_TW, OBJECT_EFC_TW, OBJECT_EFC_TW, OBJECT_EFC_TW, GAMEPLAY_KEEP, + GAMEPLAY_KEEP, GAMEPLAY_KEEP, GAMEPLAY_KEEP, GAMEPLAY_KEEP, + }; + s32 pad; + DemoEffect* this = THIS; + s32 sp3C = DEMOEFFECT_GET_FF(&this->actor); + s32 phi_v1; + s32 pad2; + Color_RGB8 sp24[] = { + { 200, 200, 0 }, { 255, 40, 100 }, { 50, 255, 0 }, { 0, 0, 255 }, { 255, 255, 80 }, + }; -extern UNK_TYPE D_06000050; -extern UNK_TYPE D_06000060; + if (D_808CE2C0[sp3C] == 1) { + phi_v1 = 0; + } else { + phi_v1 = Object_GetIndex(&globalCtx->objectCtx, D_808CE2C0[sp3C]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/DemoEffect_Init.s") + if (phi_v1 >= 0) { + this->unk_164 = phi_v1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/DemoEffect_Destroy.s") + Actor_SetScale(&this->actor, 0.2f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CD940.s") + switch (sp3C) { + case 0: + case 1: + this->actor.flags |= ACTOR_FLAG_2000000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CD998.s") + case 2: + case 3: + this->unk_174 = func_808CDFF8; + this->unk_170 = func_808CD998; + this->unk_168[0] = 0; + this->unk_168[1] = 100; + this->unk_168[2] = 255; + SkelCurve_Clear(&this->skelCurve); + this->unk_16C = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDAD0.s") + case 4: + case 5: + case 6: + case 7: + case 8: + this->unk_168[0] = sp24[sp3C - 4].r; + this->unk_168[1] = sp24[sp3C - 4].g; + this->unk_168[2] = sp24[sp3C - 4].b; + Actor_SetScale(&this->actor, 0.0f); + this->unk_174 = func_808CE078; + this->unk_170 = func_808CDDE0; + this->unk_16C = 0; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDBDC.s") + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + this->actionFunc = func_808CD940; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDCEC.s") +u8 D_808CE2D4[] = { + 1, 1, 2, 0, 1, 1, 2, 0, 1, 2, 0, 2, 1, 0, 1, 0, 2, 0, 2, 2, 0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDD70.s") +void DemoEffect_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DemoEffect* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDDE0.s") + switch (DEMOEFFECT_GET_FF(&this->actor)) { + case 0: + case 1: + case 2: + case 3: + SkelCurve_Destroy(globalCtx, &this->skelCurve); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/DemoEffect_Update.s") +void func_808CD940(DemoEffect* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_164)) { + this->actor.objBankIndex = this->unk_164; + this->actor.draw = this->unk_174; + this->actionFunc = this->unk_170; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDE78.s") +void func_808CD998(DemoEffect* this, GlobalContext* globalCtx) { + s32 sp34 = DEMOEFFECT_GET_FF(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CDFF8.s") + if (SkelCurve_Init(globalCtx, &this->skelCurve, &object_efc_tw_Skel_0012E8, &object_efc_tw_CurveAnim_000050)) {} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Effect/func_808CE078.s") + SkelCurve_SetAnim(&this->skelCurve, &object_efc_tw_CurveAnim_000050, 1.0f, 59.0f, 1.0f, 1.7f); + SkelCurve_Update(globalCtx, &this->skelCurve); + this->actionFunc = func_808CDCEC; + + switch (sp34) { + case 0: + Actor_SetScale(&this->actor, 0.16800001f); + break; + + case 1: + Actor_SetScale(&this->actor, 0.08400001f); + break; + + case 2: + Actor_SetScale(&this->actor, 0.16800001f); + break; + + case 3: + Actor_SetScale(&this->actor, 0.28f); + break; + + default: + Actor_SetScale(&this->actor, 0.014f); + break; + } +} + +void func_808CDAD0(f32 arg0) { + s32 i; + Vtx* temp_v0 = Lib_SegmentedToVirtual(object_efc_tw_Vtx_000060); + u8 sp24[3]; + + sp24[0] = 0; + sp24[1] = (s8)(202.0f * arg0); + sp24[2] = (s8)(255.0f * arg0); + + for (i = 0; i < ARRAY_COUNT(D_808CE2D4); i++) { + if (D_808CE2D4[i] != 0) { + temp_v0[i].v.cn[3] = sp24[D_808CE2D4[i]]; + } + } +} + +void func_808CDBDC(DemoEffect* this, GlobalContext* globalCtx) { + s32 params = DEMOEFFECT_GET_FF(&this->actor); + f32 temp_f0; + f32 temp_f12; + + this->unk_16C++; + if (this->unk_16C <= 100) { + temp_f12 = (100 - this->unk_16C) * 0.01f; + temp_f0 = temp_f12 * 0.14f; + + switch (params) { + case 0: + temp_f0 *= 1.2f; + break; + + case 1: + temp_f0 *= 0.6f; + break; + + case 2: + temp_f0 *= 1.2f; + break; + + case 3: + temp_f0 *= 2.0f; + break; + } + + this->actor.scale.x = temp_f0; + this->actor.scale.z = temp_f0; + func_808CDAD0(temp_f12); + func_800B8FE8(&this->actor, NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); + } else { + func_808CDAD0(1.0f); + Actor_MarkForDeath(&this->actor); + } +} + +void func_808CDCEC(DemoEffect* this, GlobalContext* globalCtx) { + func_800B8FE8(&this->actor, NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); + + if (SkelCurve_Update(globalCtx, &this->skelCurve)) { + SkelCurve_SetAnim(&this->skelCurve, &object_efc_tw_CurveAnim_000050, 1.0f, 60.0f, 59.0f, 0.0f); + this->actionFunc = func_808CDBDC; + this->unk_16C = 0; + } +} + +void func_808CDD70(DemoEffect* this, GlobalContext* globalCtx) { + Actor_SetScale(&this->actor, this->actor.scale.x - 0.02f); + + this->unk_16C++; + if (this->actor.scale.x < 0.02f) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_808CDDE0(DemoEffect* this, GlobalContext* globalCtx) { + Actor_SetScale(&this->actor, (this->actor.scale.x * 0.5f) + 0.2f); + + this->unk_16C++; + if (this->unk_16C >= 3) { + this->actionFunc = func_808CDD70; + } +} + +void DemoEffect_Update(Actor* thisx, GlobalContext* globalCtx) { + DemoEffect* this = THIS; + + this->actionFunc(this, globalCtx); +} + +s32 func_808CDE78(GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, Actor* thisx) { + s32 pad; + DemoEffect* this = THIS; + u32 sp4C = globalCtx->gameplayFrames; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, this->unk_168[0], this->unk_168[1], this->unk_168[2], 255); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (sp4C * 6) % 1024, 255 - ((sp4C * 16) % 256), 0x100, 0x40, + 1, (sp4C * 4) % 512, 127 - ((sp4C * 12) % 128), 0x80, 0x20)); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (limbIndex == 0) { + LimbTransform* transform = skelCuve->transforms; + + transform->scale.x = 0x400; + transform->scale.y = 0x400; + transform->scale.z = transform->scale.x; + } + + return true; +} + +void func_808CDFF8(Actor* thisx, GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + DemoEffect* this = THIS; + + OPEN_DISPS(gfxCtx); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 25); + + Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); + SkelCurve_Draw(&this->actor, globalCtx, &this->skelCurve, func_808CDE78, NULL, 1, &this->actor); + + CLOSE_DISPS(gfxCtx); +} + +void func_808CE078(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + DemoEffect* this = THIS; + s16 sp46 = (this->unk_16C * 0x400) & 0xFFFF; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, this->unk_168[0], this->unk_168[1], this->unk_168[2], 255); + + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_StatePush(); + Matrix_InsertZRotation_s(sp46, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023288); + + Matrix_StatePop(); + Matrix_InsertZRotation_s(sp46 * -1, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023288); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + D_801F4E32 = 1; + D_801F4E38.x = thisx->world.pos.x; + D_801F4E38.y = thisx->world.pos.y; + D_801F4E38.z = thisx->world.pos.z; + + D_801F4E44 = thisx->scale.x * 60.0f; + D_801F4E48 = thisx->scale.x * 50.0f; + D_801F4E4C = thisx->scale.x * 250.0f; +} diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h index 1943f4387..8216708c5 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h @@ -6,10 +6,20 @@ struct DemoEffect; typedef void (*DemoEffectActionFunc)(struct DemoEffect*, GlobalContext*); +typedef void (*DemoEffectUnkFunc)(struct DemoEffect*, GlobalContext*); +typedef void (*DemoEffectUnkFunc2)(Actor*, GlobalContext*); + +#define DEMOEFFECT_GET_FF(thisx) ((thisx)->params & 0xFF) typedef struct DemoEffect { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x34]; + /* 0x0144 */ SkelAnimeCurve skelCurve; + /* 0x0164 */ u8 unk_164; + /* 0x0165 */ UNK_TYPE1 unk_165[3]; + /* 0x0168 */ u8 unk_168[3]; + /* 0x016C */ s16 unk_16C; + /* 0x0170 */ DemoEffectUnkFunc unk_170; + /* 0x0174 */ DemoEffectUnkFunc2 unk_174; /* 0x0178 */ DemoEffectActionFunc actionFunc; } DemoEffect; // size = 0x17C diff --git a/undefined_syms.txt b/undefined_syms.txt index 2ffe4ad8c..eca7f5967 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -840,12 +840,6 @@ D_060134D0 = 0x060134D0; D_06013828 = 0x06013828; D_06014040 = 0x06014040; -// ovl_Demo_Effect - -D_06000050 = 0x06000050; -D_06000060 = 0x06000060; -D_060012E8 = 0x060012E8; - // ovl_Demo_Moonend D_06001214 = 0x06001214; From de853e8643d0b14167084f3f93fc192fc169bea1 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Mon, 25 Apr 2022 02:34:55 +1000 Subject: [PATCH 203/257] `do_action_static` OK and Documented (#802) * do_action_static OK * Add in week_static * Spacing * Oops * Swap order --- assets/xml/interface/do_action_static.xml | 57 +++++++++++++++++++++++ assets/xml/interface/week_static.xml | 2 +- assets/xml/misc/story_static.xml | 2 +- spec | 9 ++-- 4 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 assets/xml/interface/do_action_static.xml diff --git a/assets/xml/interface/do_action_static.xml b/assets/xml/interface/do_action_static.xml new file mode 100644 index 000000000..3fdd1e404 --- /dev/null +++ b/assets/xml/interface/do_action_static.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/interface/week_static.xml b/assets/xml/interface/week_static.xml index 6b21b80c0..12cc885fa 100644 --- a/assets/xml/interface/week_static.xml +++ b/assets/xml/interface/week_static.xml @@ -1,5 +1,5 @@ - + diff --git a/assets/xml/misc/story_static.xml b/assets/xml/misc/story_static.xml index d53f3f857..9a15d8c4f 100644 --- a/assets/xml/misc/story_static.xml +++ b/assets/xml/misc/story_static.xml @@ -1,5 +1,5 @@ - + diff --git a/spec b/spec index c047e1c35..c99293c3b 100644 --- a/spec +++ b/spec @@ -376,13 +376,15 @@ beginseg name "story_static" compress romalign 0x1000 - include "build/baserom/story_static.o" + include "build/assets/misc/story_static/story_static.o" + number 7 endseg beginseg name "do_action_static" romalign 0x1000 - include "build/baserom/do_action_static.o" + include "build/assets/interface/do_action_static/do_action_static.o" + number 9 endseg beginseg @@ -9145,7 +9147,8 @@ endseg beginseg name "week_static" romalign 0x1000 - include "build/baserom/week_static.o" + include "build/assets/interface/week_static/week_static.o" + number 9 endseg beginseg From 07ce7c8ab30b0093497d65b1c54919d654744e88 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sun, 24 Apr 2022 09:51:41 -0700 Subject: [PATCH 204/257] Document object_okuta and ovl_en_syateki_okuta assets (#804) * Document object_okuta * Document ovl_en_syateki_okuta assets * Leg -> Arm --- assets/xml/objects/object_okuta.xml | 123 ++++++++++-------- assets/xml/overlays/ovl_En_Syateki_Okuta.xml | 16 +-- .../ovl_En_Syateki_Okuta/z_en_syateki_okuta.c | 30 ++--- .../ovl_En_Syateki_Okuta/z_en_syateki_okuta.h | 4 +- 4 files changed, 93 insertions(+), 80 deletions(-) diff --git a/assets/xml/objects/object_okuta.xml b/assets/xml/objects/object_okuta.xml index e71f65a1c..e10afa135 100644 --- a/assets/xml/objects/object_okuta.xml +++ b/assets/xml/objects/object_okuta.xml @@ -1,59 +1,72 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Syateki_Okuta.xml b/assets/xml/overlays/ovl_En_Syateki_Okuta.xml index 0f4de7c4e..0e5054c19 100644 --- a/assets/xml/overlays/ovl_En_Syateki_Okuta.xml +++ b/assets/xml/overlays/ovl_En_Syateki_Okuta.xml @@ -1,13 +1,13 @@ - - - - - - - - + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c index 94f2f3495..617577884 100644 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c +++ b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c @@ -61,12 +61,12 @@ static ColliderCylinderInit sCylinderInit = { }; static AnimationInfo sAnimations[] = { - { &object_okuta_Anim_00044C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_okuta_Anim_003958, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_okuta_Anim_003B24, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_okuta_Anim_003EE4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, - { &object_okuta_Anim_00466C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_okuta_Anim_004204, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gOctorokShootAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gOctorokDieAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gOctorokHideAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gOctorokFloatAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &gOctorokAppearAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gOctorokHitAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, }; #include "assets/overlays/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.c" @@ -94,8 +94,8 @@ void EnSyatekiOkuta_Init(Actor* thisx, GlobalContext* globalCtx) { s32 bgId; Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_okuta_Skel_0033D0, &object_okuta_Anim_00466C, this->jointTable, - this->morphTable, OBJECT_OKUTA_LIMB_MAX); + SkelAnime_Init(globalCtx, &this->skelAnime, &gOctorokSkel, &gOctorokAppearAnim, this->jointTable, this->morphTable, + OCTOROK_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -153,7 +153,7 @@ s32 func_80A361F4(EnSyatekiOkuta* this) { } void func_80A36260(EnSyatekiOkuta* this) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &object_okuta_Anim_00466C, 0.0f); + Animation_PlayOnceSetSpeed(&this->skelAnime, &gOctorokAppearAnim, 0.0f); this->actor.draw = NULL; this->actionFunc = func_80A362A8; } @@ -173,7 +173,7 @@ void func_80A362A8(EnSyatekiOkuta* this, GlobalContext* globalCtx) { } void func_80A362F8(EnSyatekiOkuta* this) { - Animation_PlayOnceSetSpeed(&this->skelAnime, &object_okuta_Anim_00466C, 0.0f); + Animation_PlayOnceSetSpeed(&this->skelAnime, &gOctorokAppearAnim, 0.0f); this->actor.draw = NULL; Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_80A36350; @@ -474,10 +474,10 @@ s32 EnSyatekiOkuta_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx curFrame += this->unk_2A4; } - if (limbIndex == OBJECT_OKUTA_LIMB_0E) { + if (limbIndex == OCTOROK_LIMB_HEAD) { sp20 = this->unk_1D8; Matrix_Scale(sp20.x, sp20.y, sp20.z, MTXMODE_APPLY); - } else if ((limbIndex == OBJECT_OKUTA_LIMB_0F) && (func_80A370EC(this, curFrame, &sp20))) { + } else if ((limbIndex == OCTOROK_LIMB_SNOUT) && (func_80A370EC(this, curFrame, &sp20))) { Matrix_Scale(sp20.x, sp20.y, sp20.z, MTXMODE_APPLY); } @@ -493,7 +493,7 @@ void EnSyatekiOkuta_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_2A6 == 1) { gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); } else { - gSPSegment(POLY_OPA_DISP++, 0x08, ovl_En_Syateki_Okuta_DL_001640); + gSPSegment(POLY_OPA_DISP++, 0x08, gShootingGalleryOctorokBlueMaterialDL); } SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSyatekiOkuta_OverrideLimbDraw, @@ -512,9 +512,9 @@ void EnSyatekiOkuta_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (this->unk_2A6 == 2) { - gSPDisplayList(POLY_XLU_DISP++, ovl_En_Syateki_Okuta_DL_001A98); + gSPDisplayList(POLY_XLU_DISP++, gShootingGalleryOctorokCrossDL); } else { - gSPDisplayList(POLY_XLU_DISP++, ovl_En_Syateki_Okuta_DL_001B18); + gSPDisplayList(POLY_XLU_DISP++, gShootingGalleryOctorokCircleDL); } } diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h index e083f26e1..17fafe94d 100644 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h +++ b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h @@ -16,8 +16,8 @@ typedef struct EnSyatekiOkuta { /* 0x188 */ EnSyatekiOkutaActionFunc actionFunc; /* 0x18C */ ColliderCylinder collider; /* 0x1DC */ Vec3f unk_1D8; - /* 0x1E4 */ Vec3s jointTable[OBJECT_OKUTA_LIMB_MAX]; - /* 0x244 */ Vec3s morphTable[OBJECT_OKUTA_LIMB_MAX]; + /* 0x1E4 */ Vec3s jointTable[OCTOROK_LIMB_MAX]; + /* 0x244 */ Vec3s morphTable[OCTOROK_LIMB_MAX]; /* 0x2A4 */ s16 unk_2A4; /* 0x2A6 */ s16 unk_2A6; /* 0x2A8 */ UNK_TYPE1 unk_2A8[0x2]; From d0d36b603dc46277fb3d0ccc67caa0b1a8eeb4ac Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sun, 24 Apr 2022 10:14:14 -0700 Subject: [PATCH 205/257] Document object_shn (Shooting Gallery Men and Swamp Guide) (#805) * Limbs, skeleton, limb DLs, main textures * Finish documenting object_shn * Name the eyeIndex variable in syateki_man * Use limb enum in syateki_man * One more limb enum I forgot, sorry * Respond to Elliptic's review --- assets/xml/objects/object_shn.xml | 214 ++++++++++-------- src/overlays/actors/ovl_En_Shn/z_en_shn.c | 20 +- src/overlays/actors/ovl_En_Shn/z_en_shn.h | 4 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 71 +++--- .../ovl_En_Syateki_Man/z_en_syateki_man.h | 10 +- tools/disasm/functions.txt | 2 +- 6 files changed, 175 insertions(+), 146 deletions(-) diff --git a/assets/xml/objects/object_shn.xml b/assets/xml/objects/object_shn.xml index 1b94600ab..4a8e01867 100644 --- a/assets/xml/objects/object_shn.xml +++ b/assets/xml/objects/object_shn.xml @@ -1,97 +1,125 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.c b/src/overlays/actors/ovl_En_Shn/z_en_shn.c index 0a717ff2b..2ab16fb6a 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.c +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.c @@ -64,10 +64,10 @@ const ActorInit En_Shn_InitVars = { }; static AnimationInfoS sAnimations[] = { - { &object_shn_Anim_00D9D0, 1.0f, 0, -1, 0, 0 }, - { &object_shn_Anim_00D9D0, 1.0f, 0, -1, 0, -4 }, - { &object_shn_Anim_00E6C4, 1.0f, 0, -1, 0, 0 }, - { &object_shn_Anim_00E6C4, 1.0f, 0, -1, 0, -4 }, + { &gBurlyGuyHandsOnTableAnim, 1.0f, 0, -1, 0, 0 }, + { &gBurlyGuyHandsOnTableAnim, 1.0f, 0, -1, 0, -4 }, + { &gSwampGuideChinScratchAnim, 1.0f, 0, -1, 0, 0 }, + { &gSwampGuideChinScratchAnim, 1.0f, 0, -1, 0, -4 }, }; static s32 D_80AE7258[] = { 0, 2, 3, 8, 10, 1 }; @@ -345,8 +345,8 @@ void EnShn_Init(Actor* thisx, GlobalContext* globalCtx) { EnShn* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gObjectShnSkel, NULL, this->jointTable, this->morphTable, - OBJECT_SHN_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBurlyGuySkel, NULL, this->jointTable, this->morphTable, + BURLY_GUY_LIMB_MAX); this->unk_2E8 = -1; if (gSaveContext.save.weekEventReg[23] & 8) { func_80AE615C(this, 0); @@ -386,16 +386,16 @@ void EnShn_Update(Actor* thisx, GlobalContext* globalCtx) { s32 EnShn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnShn* this = THIS; - if (limbIndex == OBJECT_SHN_LIMB_HEAD) { + if (limbIndex == BURLY_GUY_LIMB_HEAD) { func_80AE6488(this, globalCtx); - *dList = gObjectShnSwampGuideHead; + *dList = gSwampGuideHeadDL; } return false; } Vec3f D_80AE7270 = { 1200.0f, 0.0f, 0.0f }; void EnShn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { - if (limbIndex == OBJECT_SHN_LIMB_HEAD) { + if (limbIndex == BURLY_GUY_LIMB_HEAD) { Matrix_MultiplyVector3fByState(&D_80AE7270, &thisx->focus.pos); Math_Vec3s_Copy(&thisx->focus.rot, &thisx->world.rot); } @@ -418,7 +418,7 @@ void EnShn_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi phi_v0 = 0; } - if (limbIndex == OBJECT_SHN_LIMB_HEAD) { + if (limbIndex == BURLY_GUY_LIMB_HEAD) { func_8013AD9C((this->unk_2BA + 0x4000), (this->unk_2BC + this->actor.shape.rot.y + 0x4000), &this->unk_1E8, &this->unk_1F4, phi_v0, phi_v1); Matrix_StatePop(); diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.h b/src/overlays/actors/ovl_En_Shn/z_en_shn.h index bb54a8815..22e10ca32 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.h +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.h @@ -20,8 +20,8 @@ typedef struct EnShn { /* 0x1E4 */ Player* shnPlayerRef; /* 0x1E8 */ Vec3f unk_1E8; /* 0x1F4 */ Vec3s unk_1F4; - /* 0x1FA */ Vec3s jointTable[OBJECT_SHN_LIMB_MAX]; - /* 0x25A */ Vec3s morphTable[OBJECT_SHN_LIMB_MAX]; + /* 0x1FA */ Vec3s jointTable[BURLY_GUY_LIMB_MAX]; + /* 0x25A */ Vec3s morphTable[BURLY_GUY_LIMB_MAX]; /* 0x2BA */ s16 unk_2BA; /* 0x2BC */ s16 unk_2BC; /* 0x2BE */ s16 unk_2BE; diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index e69c7e5ab..1bc5484ff 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -5,7 +5,6 @@ */ #include "z_en_syateki_man.h" -#include "objects/object_shn/object_shn.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_8000000) @@ -48,9 +47,9 @@ const ActorInit En_Syateki_Man_InitVars = { }; static AnimationInfo sAnimations[] = { - { &object_shn_Anim_00D9D0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_shn_Anim_00DFEC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_shn_Anim_00D2F8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gBurlyGuyHandsOnTableAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gSwampShootingGalleryManHeadScratchLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gSwampShootingGalleryManHeadScratchEndAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, }; static s16 D_809C91C8[] = { @@ -132,11 +131,11 @@ void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 1; Actor_SetScale(&this->actor, 0.01f); if (globalCtx->sceneNum == SCENE_SYATEKI_MORI) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gObjectShnSkel, &object_shn_Anim_00DFEC, this->jointTable, - this->morphTable, OBJECT_SHN_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBurlyGuySkel, &gSwampShootingGalleryManHeadScratchLoopAnim, + this->jointTable, this->morphTable, BURLY_GUY_LIMB_MAX); } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gObjectShnSkel, &object_shn_Anim_00D9D0, this->jointTable, - this->morphTable, OBJECT_SHN_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBurlyGuySkel, &gBurlyGuyHandsOnTableAnim, this->jointTable, + this->morphTable, BURLY_GUY_LIMB_MAX); } this->actor.colChkInfo.cylRadius = 100; @@ -154,8 +153,8 @@ void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_284 = 0; this->unk_194 = 0; this->unk_282 = 0; - this->unk_264 = 0; - this->unk_266 = 0; + this->eyeIndex = 0; + this->blinkTimer = 0; if (globalCtx->sceneNum == SCENE_SYATEKI_MORI) { this->path = sp34; @@ -408,7 +407,7 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { break; } - if (this->skelAnime.animation == &object_shn_Anim_00D2F8) { + if (this->skelAnime.animation == &gSwampShootingGalleryManHeadScratchEndAnim) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); } @@ -1203,32 +1202,32 @@ void func_809C8BF0(EnSyatekiMan* this, GlobalContext* globalCtx) { } } -void func_809C8DE8(EnSyatekiMan* this) { - switch (this->unk_266) { +void EnSyatekiMan_Blink(EnSyatekiMan* this) { + switch (this->blinkTimer) { case 1: - this->unk_264 = 2; + this->eyeIndex = 2; break; case 2: - this->unk_264 = 1; + this->eyeIndex = 1; break; case 40: - this->unk_266 = 0; + this->blinkTimer = 0; default: - this->unk_264 = 0; + this->eyeIndex = 0; break; } - this->unk_266++; + this->blinkTimer++; } void EnSyatekiMan_Update(Actor* thisx, GlobalContext* globalCtx) { EnSyatekiMan* this = THIS; this->actionFunc(this, globalCtx); - func_809C8DE8(this); + EnSyatekiMan_Blink(this); this->actor.focus.pos.y = 70.0f; Actor_SetFocus(&this->actor, 70.0f); if (this->unk_26A != 1) { @@ -1241,16 +1240,16 @@ s32 EnSyatekiMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** Actor* thisx) { EnSyatekiMan* this = THIS; - if ((globalCtx->sceneNum == SCENE_SYATEKI_MIZU) && (limbIndex == 15)) { - *dList = object_shn_DL_00F2D0; + if ((globalCtx->sceneNum == SCENE_SYATEKI_MIZU) && (limbIndex == BURLY_GUY_LIMB_HEAD)) { + *dList = gTownShootingGalleryManHeadDL; } - if (limbIndex == 15) { + if (limbIndex == BURLY_GUY_LIMB_HEAD) { Matrix_InsertTranslation(3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_InsertZRotation_s(this->unk_258.x, MTXMODE_APPLY); Matrix_InsertXRotation_s(this->unk_258.y, MTXMODE_APPLY); Matrix_InsertTranslation(-3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); - } else if (limbIndex == 8) { + } else if (limbIndex == BURLY_GUY_LIMB_TORSO) { Matrix_InsertXRotation_s(-this->unk_25E.y, MTXMODE_APPLY); } @@ -1261,36 +1260,36 @@ void EnSyatekiMan_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL EnSyatekiMan* this = THIS; Vec3f sp18 = { 1600.0f, 0.0f, 0.0f }; - if (limbIndex == 15) { + if (limbIndex == BURLY_GUY_LIMB_HEAD) { Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); } } void EnSyatekiMan_Draw(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr D_809C94B8[] = { - object_shn_Tex_005AC8, - object_shn_Tex_0062C8, - object_shn_Tex_0062C8, + static TexturePtr sEyeTextures[] = { + gSwampShootingGalleryManEyeOpenTex, + gSwampShootingGalleryManEyeHalfTex, + gSwampShootingGalleryManEyeHalfTex, }; EnSyatekiMan* this = THIS; s32 pad; if (globalCtx->sceneNum == SCENE_SYATEKI_MIZU) { - D_809C94B8[0] = object_shn_Tex_00FB90; - D_809C94B8[1] = object_shn_Tex_010390; - D_809C94B8[2] = object_shn_Tex_010390; + sEyeTextures[0] = gTownShootingGalleryManEyeOpenTex; + sEyeTextures[1] = gTownShootingGalleryManEyeClosedTex; + sEyeTextures[2] = gTownShootingGalleryManEyeClosedTex; } else { - D_809C94B8[0] = object_shn_Tex_005AC8; - D_809C94B8[1] = object_shn_Tex_0062C8; - D_809C94B8[2] = object_shn_Tex_0062C8; + sEyeTextures[0] = gSwampShootingGalleryManEyeOpenTex; + sEyeTextures[1] = gSwampShootingGalleryManEyeHalfTex; + sEyeTextures[2] = gSwampShootingGalleryManEyeHalfTex; } OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C5B0(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_809C94B8[this->unk_264])); - gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_809C94B8[this->unk_264])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnSyatekiMan_OverrideLimbDraw, EnSyatekiMan_PostLimbDraw, &this->actor); diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h index 80f2a1068..16585ac84 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h @@ -2,6 +2,8 @@ #define Z_EN_SYATEKI_MAN_H #include "global.h" +#include "objects/object_shn/object_shn.h" + struct EnSyatekiMan; @@ -24,12 +26,12 @@ typedef struct EnSyatekiMan { /* 0x018C */ Path* path; /* 0x0190 */ s32 unk_190; /* 0x0194 */ s32 unk_194; - /* 0x0198 */ Vec3s jointTable[16]; - /* 0x01F8 */ Vec3s morphTable[16]; + /* 0x0198 */ Vec3s jointTable[BURLY_GUY_LIMB_MAX]; + /* 0x01F8 */ Vec3s morphTable[BURLY_GUY_LIMB_MAX]; /* 0x0258 */ Vec3s unk_258; /* 0x025E */ Vec3s unk_25E; - /* 0x0264 */ s16 unk_264; - /* 0x0266 */ s16 unk_266; + /* 0x0264 */ s16 eyeIndex; + /* 0x0266 */ s16 blinkTimer; /* 0x0268 */ UNK_TYPE1 unk268[0x2]; /* 0x026A */ s16 unk_26A; /* 0x026C */ s16 unk_26C; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 564373b6f..ee7db6a8f 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -9107,7 +9107,7 @@ 0x809C8808:("func_809C8808",), 0x809C898C:("func_809C898C",), 0x809C8BF0:("func_809C8BF0",), - 0x809C8DE8:("func_809C8DE8",), + 0x809C8DE8:("EnSyatekiMan_Blink",), 0x809C8E44:("EnSyatekiMan_Update",), 0x809C8EE4:("EnSyatekiMan_OverrideLimbDraw",), 0x809C8FAC:("EnSyatekiMan_PostLimbDraw",), From 02f4785df83d2d97fff4b76cb4c4ff890cb0b7e0 Mon Sep 17 00:00:00 2001 From: Kristopher Early <1191258+MrPolymorph@users.noreply.github.com> Date: Tue, 26 Apr 2022 22:12:13 +0100 Subject: [PATCH 206/257] Bg_Open_Spot OK (#783) * Fully Matched Bg_Open_Spot * addressing review comments variable names inline with convension variable naming clarity * remove redundant return. change padding type * texScroll to texScrolls --- assets/xml/objects/object_open_obj.xml | 10 ++-- spec | 3 +- .../actors/ovl_Bg_Open_Spot/z_bg_open_spot.c | 51 ++++++++++++++----- .../actors/ovl_Bg_Open_Spot/z_bg_open_spot.h | 2 +- undefined_syms.txt | 7 ++- 5 files changed, 48 insertions(+), 25 deletions(-) diff --git a/assets/xml/objects/object_open_obj.xml b/assets/xml/objects/object_open_obj.xml index ea1664a88..74a4101bd 100644 --- a/assets/xml/objects/object_open_obj.xml +++ b/assets/xml/objects/object_open_obj.xml @@ -4,11 +4,11 @@ - - - - - + + + + + diff --git a/spec b/spec index c99293c3b..57a044124 100644 --- a/spec +++ b/spec @@ -3439,8 +3439,7 @@ beginseg name "ovl_Bg_Open_Spot" compress include "build/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.o" - include "build/data/ovl_Bg_Open_Spot/ovl_Bg_Open_Spot.data.o" - include "build/data/ovl_Bg_Open_Spot/ovl_Bg_Open_Spot.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Open_Spot/ovl_Bg_Open_Spot_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c index b776253e6..48d2cd4f2 100644 --- a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c +++ b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.c @@ -1,10 +1,11 @@ /* * File: z_bg_open_spot.c * Overlay: ovl_Bg_Open_Spot - * Description: Star Light Rays in Intro Scene + * Description: Spotlights that shine on the Skull Kid when he turns Link + * into a Deku Scrub. */ - #include "z_bg_open_spot.h" +#include "objects/object_open_obj/object_open_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -13,8 +14,8 @@ void BgOpenSpot_Init(Actor* thisx, GlobalContext* globalCtx); void BgOpenSpot_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgOpenSpot_Update(Actor* thisx, GlobalContext* globalCtx); +void BgOpenSpot_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Open_Spot_InitVars = { ACTOR_BG_OPEN_SPOT, ACTORCAT_PROP, @@ -27,25 +28,49 @@ const ActorInit Bg_Open_Spot_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80ACB3B0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 560, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void BgOpenSpot_Init(Actor* thisx, GlobalContext* globalCtx) { + BgOpenSpot* this = THIS; -extern InitChainEntry D_80ACB3B0[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + this->texScrolls = Lib_SegmentedToVirtual(gSpotlightTexAnim); +} -extern UNK_TYPE D_06001A60; -extern UNK_TYPE D_06002CE0; +void BgOpenSpot_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Spot/BgOpenSpot_Init.s") +void BgOpenSpot_Update(Actor* thisx, GlobalContext* globalCtx) { + BgOpenSpot* this = THIS; + u32 action; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Spot/BgOpenSpot_Destroy.s") + if (Cutscene_CheckActorAction(globalCtx, 0x7D)) { + action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x7D)]->action; + if (action == 1) { + this->actor.draw = NULL; + } else if (action == 2) { + this->actor.draw = BgOpenSpot_Draw; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Spot/BgOpenSpot_Update.s") +void BgOpenSpot_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgOpenSpot* this = (BgOpenSpot*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Spot/func_80ACB2B0.s") + AnimatedMat_Draw(globalCtx, this->texScrolls); + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_BAYER); + gSPDisplayList(POLY_XLU_DISP++, gSpotlightLeftDL); + gSPDisplayList(POLY_XLU_DISP++, gSpotlightRightDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.h b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.h index cf4fa2f8d..3a2b92125 100644 --- a/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.h +++ b/src/overlays/actors/ovl_Bg_Open_Spot/z_bg_open_spot.h @@ -7,7 +7,7 @@ struct BgOpenSpot; typedef struct BgOpenSpot { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ AnimatedMaterial* texScrolls; } BgOpenSpot; // size = 0x148 extern const ActorInit Bg_Open_Spot_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index eca7f5967..1ef7e6942 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -679,11 +679,10 @@ D_06000098 = 0x06000098; D_060003E8 = 0x060003E8; D_06001640 = 0x06001640; -// ovl_Bg_Open_Spot -D_06001A60 = 0x06001A60; -D_06001B40 = 0x06001B40; -D_06002CE0 = 0x06002CE0; +// ovl_Bg_Sinkai_Kabe + +D_06000048 = 0x06000048; // ovl_Bg_Spout_Fire From 0ccd71c2da5c078878b6428e40952ab221ff8ead Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 30 Apr 2022 07:41:08 -0700 Subject: [PATCH 207/257] Document object_wf (#796) * Document object_wf * Respond to Elliptic's review * Fix warning --- assets/xml/objects/object_wf.xml | 244 ++++++++++-------- .../ovl_En_Syateki_Wf/z_en_syateki_wf.c | 31 ++- .../ovl_En_Syateki_Wf/z_en_syateki_wf.h | 7 +- src/overlays/actors/ovl_En_Wf/z_en_wf.c | 97 ++++--- src/overlays/actors/ovl_En_Wf/z_en_wf.h | 7 +- tools/disasm/functions.txt | 2 +- 6 files changed, 210 insertions(+), 178 deletions(-) diff --git a/assets/xml/objects/object_wf.xml b/assets/xml/objects/object_wf.xml index 4775552e2..3d9ce392d 100644 --- a/assets/xml/objects/object_wf.xml +++ b/assets/xml/objects/object_wf.xml @@ -1,110 +1,142 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c index ff6595044..e72cb296d 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c @@ -6,7 +6,6 @@ #include "z_en_syateki_wf.h" #include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" -#include "objects/object_wf/object_wf.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) @@ -115,13 +114,13 @@ const ActorInit En_Syateki_Wf_InitVars = { }; static AnimationInfo sAnimations[] = { - { &object_wf_Anim_00A3CC, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, - { &object_wf_Anim_005700, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_wf_Anim_005700, 1.0f, 0.0f, 4.0f, ANIMMODE_ONCE, 1.0f }, - { &object_wf_Anim_005700, 1.0f, 4.0f, 8.0f, ANIMMODE_ONCE, 1.0f }, - { &object_wf_Anim_004A90, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_wf_Anim_009A50, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 8.0f }, - { &object_wf_Anim_0053D0, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gWolfosWaitingAnim, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &gWolfosRunningAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gWolfosRunningAnim, 1.0f, 0.0f, 4.0f, ANIMMODE_ONCE, 1.0f }, + { &gWolfosRunningAnim, 1.0f, 4.0f, 8.0f, ANIMMODE_ONCE, 1.0f }, + { &gWolfosBackflippingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &gWolfosDamagedAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 8.0f }, + { &gWolfosRearingUpFallingOverAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, }; static InitChainEntry sInitChain[] = { @@ -134,10 +133,10 @@ static Vec3f D_80A20FC4 = { 0.0f, 0.5f, 0.0f }; static Vec3f D_80A20FD0 = { 1200.0f, 0.0f, 0.0f }; static TexturePtr sEyeTextures[] = { - object_wf_Tex_007AA8, - object_wf_Tex_0082A8, - object_wf_Tex_0084A8, - object_wf_Tex_0082A8, + gWolfosNormalEyeOpenTex, + gWolfosNormalEyeHalfTex, + gWolfosNormalEyeNarrowTex, + gWolfosNormalEyeHalfTex, }; void EnSyatekiWf_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -181,11 +180,11 @@ void EnSyatekiWf_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->unk_300); Collider_SetCylinder(globalCtx, &this->unk_300, &this->actor, &sCylinderInit2); Collider_InitJntSph(globalCtx, &this->unk_34C); - Collider_SetJntSph(globalCtx, &this->unk_34C, &this->actor, &sJntSphInit, &this->unk_36C); + Collider_SetJntSph(globalCtx, &this->unk_34C, &this->actor, &sJntSphInit, this->unk_36C); this->unk_34C.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_wf_Skel_0095D0, &object_wf_Anim_00A3CC, this->jointTable, - this->morphTable, 22); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWolfosNormalSkel, &gWolfosWaitingAnim, this->jointTable, + this->morphTable, WOLFOS_NORMAL_LIMB_MAX); Actor_SetScale(&this->actor, 0.01f); this->actor.hintId = 0x4C; @@ -461,7 +460,7 @@ void EnSyatekiWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi Vec3f sp18; Collider_UpdateSpheres(limbIndex, &this->unk_34C); - if (limbIndex == OBJECT_WF_2_LIMB_06) { + if (limbIndex == WOLFOS_NORMAL_LIMB_TAIL) { Matrix_MultiplyVector3fByState(&D_80A20FD0, &sp18); this->unk_300.dim.pos.x = sp18.x; this->unk_300.dim.pos.y = sp18.y; diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h index 23977fa02..a43c76f77 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.h @@ -2,6 +2,7 @@ #define Z_EN_SYATEKI_WF_H #include "global.h" +#include "objects/object_wf/object_wf.h" #define EN_SYATEKI_WF_GET_PARAM_F0(thisx) (((thisx)->params & 0xF0) >> 4) #define EN_SYATEKI_WF_GET_PARAM_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) @@ -13,8 +14,8 @@ typedef void (*EnSyatekiWfActionFunc)(struct EnSyatekiWf*, GlobalContext*); typedef struct EnSyatekiWf { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[22]; - /* 0x20C */ Vec3s morphTable[22]; + /* 0x188 */ Vec3s jointTable[WOLFOS_NORMAL_LIMB_MAX]; + /* 0x20C */ Vec3s morphTable[WOLFOS_NORMAL_LIMB_MAX]; /* 0x290 */ UNK_TYPE1 unk_290[0x4]; /* 0x294 */ EnSyatekiWfActionFunc actionFunc; /* 0x298 */ s16 unk_298; @@ -29,7 +30,7 @@ typedef struct EnSyatekiWf { /* 0x2B4 */ ColliderCylinder unk_2B4; /* 0x300 */ ColliderCylinder unk_300; /* 0x34C */ ColliderJntSph unk_34C; - /* 0x36C */ ColliderJntSphElement unk_36C; + /* 0x36C */ ColliderJntSphElement unk_36C[1]; /* 0x3AC */ UNK_TYPE1 unk_3AC[0x20]; } EnSyatekiWf; // size = 0x3CC diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.c b/src/overlays/actors/ovl_En_Wf/z_en_wf.c index 3b92a8eab..fdd82b864 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -7,7 +7,6 @@ #include "z_en_wf.h" #include "overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h" #include "overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h" -#include "objects/object_wf/object_wf.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) @@ -240,18 +239,18 @@ static DamageTable sDamageTable2 = { static CollisionCheckInfoInit sColChkInfoInit = { 8, 50, 100, MASS_HEAVY }; -static TexturePtr D_809942B0[] = { - object_wf_Tex_007AA8, - object_wf_Tex_0082A8, - object_wf_Tex_0084A8, - object_wf_Tex_0082A8, +static TexturePtr sNormalEyeTextures[] = { + gWolfosNormalEyeOpenTex, + gWolfosNormalEyeHalfTex, + gWolfosNormalEyeNarrowTex, + gWolfosNormalEyeHalfTex, }; -static TexturePtr D_809942C0[] = { - object_wf_Tex_000300, - object_wf_Tex_0027D8, - object_wf_Tex_0029D8, - object_wf_Tex_0027D8, +static TexturePtr sWhiteEyeTextures[] = { + gWolfosWhiteEyeOpenTex, + gWolfosWhiteEyeHalfTex, + gWolfosWhiteEyeNarrowTex, + gWolfosWhiteEyeHalfTex, }; static InitChainEntry sInitChain[] = { @@ -318,16 +317,16 @@ void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.0075f); if (this->actor.params == 0) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_wf_Skel_0095D0, &object_wf_Anim_00A3CC, - this->jointTable, this->morphTable, 22); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWolfosNormalSkel, &gWolfosWaitingAnim, this->jointTable, + this->morphTable, WOLFOS_NORMAL_LIMB_MAX); this->actor.hintId = 0x4C; CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable2, &sColChkInfoInit); this->collider1.elements[0].info.toucher.damage = 8; this->collider1.elements[1].info.toucher.damage = 8; this->actor.colChkInfo.health = 6; } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_wf_Skel_003BC0, &object_wf_Anim_00A3CC, - this->jointTable, this->morphTable, 22); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWolfosWhiteSkel, &gWolfosWaitingAnim, this->jointTable, + this->morphTable, WOLFOS_WHITE_LIMB_MAX); this->actor.hintId = 0x57; CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable1, &sColChkInfoInit); } @@ -342,9 +341,9 @@ void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 5); if (D_809942D8 == 0) { - for (i = 0; i < ARRAY_COUNT(D_809942B0); i++) { - D_809942B0[i] = Lib_SegmentedToVirtual(D_809942B0[i]); - D_809942C0[i] = Lib_SegmentedToVirtual(D_809942C0[i]); + for (i = 0; i < ARRAY_COUNT(sNormalEyeTextures); i++) { + sNormalEyeTextures[i] = Lib_SegmentedToVirtual(sNormalEyeTextures[i]); + sWhiteEyeTextures[i] = Lib_SegmentedToVirtual(sWhiteEyeTextures[i]); } D_809942D8 = 1; } @@ -382,14 +381,14 @@ void func_80990854(EnWf* this, GlobalContext* globalCtx) { } } -void func_809908E0(EnWf* this) { - if (this->unk_294 != 0) { - this->unk_294++; - if (this->unk_294 == 4) { - this->unk_294 = 0; +void EnWf_Blink(EnWf* this) { + if (this->eyeIndex != 0) { + this->eyeIndex++; + if (this->eyeIndex == 4) { + this->eyeIndex = 0; } } else if (Rand_ZeroOne() < 0.05f) { - this->unk_294 = 1; + this->eyeIndex = 1; } } @@ -550,7 +549,7 @@ void func_80990F50(EnWf* this, GlobalContext* globalCtx) { } void func_80990FC8(EnWf* this) { - Animation_Change(&this->skelAnime, &object_wf_Anim_0053D0, 0.5f, 0.0f, 7.0f, 3, 0.0f); + Animation_Change(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, 0.5f, 0.0f, 7.0f, 3, 0.0f); this->unk_2A0 = 5; this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80991040; @@ -573,7 +572,7 @@ void func_80991040(EnWf* this, GlobalContext* globalCtx) { void func_809910F0(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; this->actor.speedXZ = 0.0f; - Animation_Change(&this->skelAnime, &object_wf_Anim_0053D0, 0.5f, 0.0f, 7.0f, 3, -5.0f); + Animation_Change(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, 0.5f, 0.0f, 7.0f, 3, -5.0f); this->unk_2A0 = 5; this->actionFunc = func_80991174; } @@ -592,7 +591,7 @@ void func_80991174(EnWf* this, GlobalContext* globalCtx) { void func_80991200(EnWf* this) { this->collider2.base.acFlags |= AC_ON; - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_00A3CC, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosWaitingAnim, -4.0f); this->unk_2A0 = (s32)Rand_ZeroFloat(10.0f) + 2; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_80991280; @@ -643,7 +642,7 @@ void func_80991280(EnWf* this, GlobalContext* globalCtx) { void func_80991438(EnWf* this) { this->collider2.base.acFlags |= AC_ON; - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.speedXZ = 8.0f; this->actionFunc = func_8099149C; @@ -704,7 +703,7 @@ void func_8099149C(EnWf* this, GlobalContext* globalCtx) { } void func_80991738(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_009808, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosSidesteppingAnim, -4.0f); this->actionFunc = func_8099177C; } @@ -756,7 +755,7 @@ void func_8099177C(EnWf* this, GlobalContext* globalCtx) { void func_80991948(EnWf* this) { this->collider2.base.acFlags |= AC_ON; - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); if (Rand_ZeroOne() > 0.5f) { this->unk_29A = 16000; } else { @@ -810,7 +809,7 @@ void func_809919F4(EnWf* this, GlobalContext* globalCtx) { void func_80991C04(EnWf* this) { this->collider2.base.acFlags |= AC_ON; - Animation_PlayOnce(&this->skelAnime, &object_wf_Anim_004638); + Animation_PlayOnce(&this->skelAnime, &gWolfosSlashingAnim); this->collider1.base.atFlags &= ~AT_BOUNCED; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->unk_2A0 = 7; @@ -880,7 +879,7 @@ void func_80991FD8(EnWf* this) { if (this->skelAnime.curFrame > 15.0f) { phi_f0 = 15.0f; } - Animation_Change(&this->skelAnime, &object_wf_Anim_004638, -0.5f, this->skelAnime.curFrame - 1.0f, phi_f0, 3, 0.0f); + Animation_Change(&this->skelAnime, &gWolfosSlashingAnim, -0.5f, this->skelAnime.curFrame - 1.0f, phi_f0, 3, 0.0f); this->collider1.base.atFlags &= ~AT_ON; this->actionFunc = func_80992068; } @@ -923,7 +922,7 @@ void func_80992068(EnWf* this, GlobalContext* globalCtx) { void func_8099223C(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; - Animation_MorphToPlayOnce(&this->skelAnime, &object_wf_Anim_004A90, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWolfosBackflippingAnim, -3.0f); this->unk_2A0 = 0; this->actor.speedXZ = -6.0f; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; @@ -973,7 +972,7 @@ void func_809923E4(EnWf* this, GlobalContext* globalCtx) { void func_8099245C(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; - Animation_MorphToPlayOnce(&this->skelAnime, &object_wf_Anim_009A50, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWolfosDamagedAnim, -4.0f); if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -4.0f; } @@ -1021,8 +1020,8 @@ void func_809924EC(EnWf* this, GlobalContext* globalCtx) { void func_809926D0(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; - Animation_Change(&this->skelAnime, &object_wf_Anim_004A90, -1.0f, - Animation_GetLastFrame(&object_wf_Anim_004A90.common), 0.0f, 2, -3.0f); + Animation_Change(&this->skelAnime, &gWolfosBackflippingAnim, -1.0f, + Animation_GetLastFrame(&gWolfosBackflippingAnim.common), 0.0f, 2, -3.0f); this->unk_2A0 = 0; this->actor.speedXZ = 6.5f; this->actor.velocity.y = 15.0f; @@ -1053,8 +1052,8 @@ void func_8099282C(EnWf* this) { this->collider1.base.atFlags &= ~AT_ON; this->unk_2A0 = 10; this->actor.speedXZ = 0.0f; - Animation_Change(&this->skelAnime, &object_wf_Anim_004C44, -1.0f, - Animation_GetLastFrame(&object_wf_Anim_004C44.common), 0.0f, 2, -2.0f); + Animation_Change(&this->skelAnime, &gWolfosBlockingAnim, -1.0f, Animation_GetLastFrame(&gWolfosBlockingAnim.common), + 0.0f, 2, -2.0f); this->actionFunc = func_809928CC; } @@ -1091,7 +1090,7 @@ void func_80992A74(EnWf* this, GlobalContext* globalCtx) { f32 temp_f0; this->collider2.base.acFlags |= AC_ON; - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); player = GET_PLAYER(globalCtx); temp_f0 = Math_SinS((player->actor.shape.rot.y + this->unk_29A) - this->actor.yawTowardsPlayer); if (temp_f0 > 0.0f) { @@ -1153,7 +1152,7 @@ void func_80992B8C(EnWf* this, GlobalContext* globalCtx) { void func_80992D6C(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; - Animation_MorphToPlayOnce(&this->skelAnime, &object_wf_Anim_0053D0, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, -4.0f); this->actor.world.rot.y = this->actor.yawTowardsPlayer; if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -6.0f; @@ -1205,7 +1204,7 @@ void func_80992E0C(EnWf* this, GlobalContext* globalCtx) { } void func_80992FD4(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_00A3CC, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosWaitingAnim, -4.0f); this->actionFunc = func_80993018; } @@ -1232,7 +1231,7 @@ void func_80993018(EnWf* this, GlobalContext* globalCtx) { } void func_80993148(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); this->actor.speedXZ = 0.0f; this->actionFunc = func_80993194; } @@ -1277,7 +1276,7 @@ void func_80993194(EnWf* this, GlobalContext* globalCtx) { } void func_80993350(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_APPEAR); this->actionFunc = func_809933A0; } @@ -1317,7 +1316,7 @@ void func_809933A0(EnWf* this, GlobalContext* globalCtx) { } void func_80993524(EnWf* this) { - Animation_MorphToLoop(&this->skelAnime, &object_wf_Anim_005700, -4.0f); + Animation_MorphToLoop(&this->skelAnime, &gWolfosRunningAnim, -4.0f); this->actor.speedXZ = 6.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->actionFunc = func_8099357C; @@ -1477,7 +1476,7 @@ void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { func_8099386C(this, globalCtx); if (this->actionFunc != func_809923E4) { - func_809908E0(this); + EnWf_Blink(this); } this->actionFunc(this, globalCtx); @@ -1535,7 +1534,7 @@ void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { s32 EnWf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnWf* this = THIS; - if ((limbIndex == 17) || (limbIndex == 18)) { + if ((limbIndex == WOLFOS_NORMAL_LIMB_HEAD) || (limbIndex == WOLFOS_NORMAL_LIMB_EYES)) { rot->y -= this->unk_29E; } return false; @@ -1554,7 +1553,7 @@ void EnWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Matrix_GetStateTranslation(&this->limbPos[D_809942FC[limbIndex]]); } - if (limbIndex == 6) { + if (limbIndex == WOLFOS_NORMAL_LIMB_TAIL) { Matrix_GetStateTranslationAndScaledX(1200.0f, &sp20); this->collider3.dim.pos.x = sp20.x; this->collider3.dim.pos.y = sp20.y; @@ -1571,9 +1570,9 @@ void EnWf_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); if (this->actor.params == 0) { - gSPSegment(POLY_OPA_DISP++, 0x08, D_809942B0[this->unk_294]); + gSPSegment(POLY_OPA_DISP++, 0x08, sNormalEyeTextures[this->eyeIndex]); } else { - gSPSegment(POLY_OPA_DISP++, 0x08, D_809942C0[this->unk_294]); + gSPSegment(POLY_OPA_DISP++, 0x08, sWhiteEyeTextures[this->eyeIndex]); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.h b/src/overlays/actors/ovl_En_Wf/z_en_wf.h index e697ef072..94cfb18e7 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.h +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.h @@ -2,6 +2,7 @@ #define Z_EN_WF_H #include "global.h" +#include "objects/object_wf/object_wf.h" struct EnWf; @@ -12,10 +13,10 @@ typedef void (*EnWfActionFunc)(struct EnWf*, GlobalContext*); typedef struct EnWf { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ Vec3s jointTable[22]; - /* 0x020C */ Vec3s morphTable[22]; + /* 0x0188 */ Vec3s jointTable[WOLFOS_NORMAL_LIMB_MAX]; + /* 0x020C */ Vec3s morphTable[WOLFOS_NORMAL_LIMB_MAX]; /* 0x0290 */ EnWfActionFunc actionFunc; - /* 0x0294 */ u8 unk_294; + /* 0x0294 */ u8 eyeIndex; /* 0x0295 */ u8 unk_295; /* 0x0296 */ u8 drawDmgEffType; /* 0x0298 */ s16 unk_298; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index ee7db6a8f..e42433b9b 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -8429,7 +8429,7 @@ 0x80990784:("EnWf_Destroy",), 0x809907D4:("func_809907D4",), 0x80990854:("func_80990854",), - 0x809908E0:("func_809908E0",), + 0x809908E0:("EnWf_Blink",), 0x80990948:("func_80990948",), 0x80990C6C:("func_80990C6C",), 0x80990E4C:("func_80990E4C",), From e67fb5cf16416248048fe331b4b4162e58794c0b Mon Sep 17 00:00:00 2001 From: Rozelette Date: Sat, 21 May 2022 11:08:19 -0500 Subject: [PATCH 208/257] code_801323D0 (z_schedule) (#509) * OK * Initial documentation pass * Pass 2. Add script by Tharo * Renamed source file * Documentation cleanup * Update to latest master * Feedback * Bad merge * Permissions * Clang format * Feedback * format * Use calculation instead of constant * Rename as per suggestions * Fix bss ordering and minor merge conflicts (from Maide) * Update to current codebase and address feedback * Fixup names to match new enums * Format * Fix duplicate include * BSS shenanigans --- include/functions.h | 25 +- include/z64.h | 11 +- include/z64schedule.h | 248 +++++++++ spec | 3 +- src/boot_O2_g3/idle.c | 1 + src/code/code_801323D0.c | 41 -- src/code/graph.c | 1 - src/code/z_bgcheck.c | 1 - src/code/z_collision_check.c | 1 - src/code/z_demo.c | 1 - src/code/z_schedule.c | 283 ++++++++++ src/overlays/actors/ovl_Boss_06/z_boss_06.c | 1 + src/overlays/actors/ovl_En_Ah/z_en_ah.c | 42 +- src/overlays/actors/ovl_En_Al/z_en_al.c | 43 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 43 +- src/overlays/actors/ovl_En_Door/z_en_door.c | 248 +++++++-- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 182 +++++-- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 136 +++-- src/overlays/actors/ovl_En_Ig/z_en_ig.h | 4 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 2 + src/overlays/actors/ovl_En_Ja/z_en_ja.c | 33 +- src/overlays/actors/ovl_En_Kusa/z_en_kusa.c | 1 + src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c | 1 + src/overlays/actors/ovl_En_Pm/z_en_pm.c | 492 ++++++++++++++---- .../actors/ovl_En_Suttari/z_en_suttari.c | 141 +++-- src/overlays/actors/ovl_En_Tab/z_en_tab.c | 40 +- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 42 +- .../actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c | 1 + tools/disasm/files.txt | 4 +- tools/disasm/functions.txt | 40 +- tools/namefixer.py | 2 +- tools/overlayhelpers/scheduledis.py | 264 ++++++++++ 32 files changed, 1872 insertions(+), 506 deletions(-) create mode 100644 include/z64schedule.h delete mode 100644 src/code/code_801323D0.c create mode 100644 src/code/z_schedule.c create mode 100755 tools/overlayhelpers/scheduledis.py diff --git a/include/functions.h b/include/functions.h index 501b45776..622dfcffb 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2007,7 +2007,7 @@ s32 func_80123810(GlobalContext* globalCtx); void func_80123AA4(Player* player, s32 arg1); // void func_80123BD4(void); // void func_80123C58(void); -void Player_SetEquipmentData(GlobalContext* globalCtx, Player* this); +void Player_SetEquipmentData(GlobalContext* globalCtx, Player* this); void func_80123D50(GlobalContext* globalCtx, Player* player, UNK_TYPE arg2, UNK_TYPE arg3); void func_80123DA4(Player* player); // void func_80123DC0(void); @@ -2299,26 +2299,7 @@ s32 Entrance_GetSceneNum(u16 entranceIndex); s32 Entrance_GetSceneNumAbsolute(u16 entranceIndex); s32 Entrance_GetSpawnNum(u16 entranceIndex); s32 Entrance_GetTransitionFlags(u16 entranceIndex); -// void func_801323D0(void); -// void func_80132428(void); -// void func_80132494(void); -// void func_801326B8(void); -// void func_801328F0(void); -// void func_80132920(void); -// void func_80132938(void); -// void func_80132954(void); -// void func_8013296C(void); -// void func_80132A18(void); -// void func_80132A3C(void); -// void func_80132A80(void); -// void func_80132AD8(void); -// void func_80132B24(void); -// void func_80132B84(void); -// void func_80132D70(void); -// void func_80132E9C(void); -// void func_80132FDC(void); -// void func_80133000(void); -UNK_TYPE func_80133038(GlobalContext* globalCtx, UNK_TYPE* arg1, struct_80133038_arg2* arg2); +s32 Schedule_RunScript(GlobalContext* globalCtx, u8* script, ScheduleResult* result); void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod); void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod); void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, s32 lod, Mtx** mtx); @@ -2566,7 +2547,7 @@ s32 func_80142440(SkyboxContext* skyboxCtx, Vtx* vtx, s32 arg2, s32 arg3, s32 ar void func_80143148(SkyboxContext* skyboxCtx, s32 arg1); void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyType); -void func_801434E4(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); +void func_801434E4(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z); void SkyboxDraw_SetColors(SkyboxContext* skyboxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB); void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y, f32 z); diff --git a/include/z64.h b/include/z64.h index 1ef496df3..e5533234a 100644 --- a/include/z64.h +++ b/include/z64.h @@ -39,6 +39,7 @@ #include "z64player.h" #include "z64save.h" #include "z64scene.h" +#include "z64schedule.h" #include "z64skin.h" #include "z64subs.h" #include "z64transition.h" @@ -883,7 +884,7 @@ typedef struct { /* 0x12070 */ s32 unk12070; /* 0x12074 */ UNK_TYPE1 pad12074[0x4]; /* 0x12078 */ s32 bankRupeesSelected; - /* 0x1207C */ s32 bankRupees; + /* 0x1207C */ s32 bankRupees; /* 0x12080 */ MessageTableEntry* messageEntryTable; /* 0x12084 */ MessageTableEntry* messageEntryTableNes; /* 0x12088 */ UNK_TYPE4 unk12088; @@ -1223,7 +1224,7 @@ typedef struct { /* 0x12C */ UNK_TYPE1 pad_12C[0x4]; /* 0x130 */ OSThread thread; } AudioMgr; // size = 0x2E0 - + typedef struct { /* 0x00 */ MtxF displayMatrix; /* 0x40 */ Actor* actor; @@ -1397,12 +1398,6 @@ typedef struct { /* 0x24 */ s16 unk_24; } struct_800BD888_arg1; // size = 0x28 -typedef struct { - /* 0x0 */ u8 unk0; - /* 0x4 */ s32 unk4; - /* 0x8 */ s32 unk8; // game script pointer? -} struct_80133038_arg2; // size = 0xC - typedef struct { /* 0x00 */ u32 type; /* 0x04 */ u32 setScissor; diff --git a/include/z64schedule.h b/include/z64schedule.h new file mode 100644 index 000000000..f5dfb2be8 --- /dev/null +++ b/include/z64schedule.h @@ -0,0 +1,248 @@ +#ifndef Z64SCHEDULE_H +#define Z64SCHEDULE_H + +#include "ultra64.h" + +/* + Schedule is a subsystem that acts as a way to make decisions based on the + time and scene (and a limited selection of items). It is utilized by writing + a script that is encoded into bytecode and ran, returning the result in a + struct. The returned result can be a value or a encoded time value. + + The scripts contain 2 kinds of instructions: + - Checks with branches (relative offsets, either 1-byte offsets (short, *_S), + or 2-byte offsets (long, *_L)) + - Returns + + Scripts are stored as u8[]. They are built using the macros are the bottom of + this file. The scheduledis.py script can be used to convert any scripts in + actor data into the macros. +*/ + +// Macro to convert the time format used in the save struct into the format used in Schedule +#define SCHEDULE_CONVERT_TIME(time) ((time) - 0x10000 / 360 * 90) +#define SCHEDULE_TIME_NOW SCHEDULE_CONVERT_TIME(gSaveContext.save.time) + +typedef enum { + /* 00 */ SCHEDULE_CMD_ID_CHECK_FLAG_S, // Checks if a weekEventReg flag is set and branches if so, short range branch + /* 01 */ SCHEDULE_CMD_ID_CHECK_FLAG_L, // Checks if a weekEventReg flag is set and branches if so, long range branch + /* 02 */ SCHEDULE_CMD_ID_CHECK_TIME_RANGE_S, // Checks if the current time is within the range of the two provided times and branches if so, short range branch + /* 03 */ SCHEDULE_CMD_ID_CHECK_TIME_RANGE_L, // Checks if the current time is within the range of the two provided times and branches if so, long range branch + /* 04 */ SCHEDULE_CMD_ID_RET_VAL_L, // Ends script and returns 2-byte value (Note: bugged as the return value size is only 1 byte in the struct) + /* 05 */ SCHEDULE_CMD_ID_RET_NONE, // Ends script without returning anything + /* 06 */ SCHEDULE_CMD_ID_RET_EMPTY, // Ends script and indicates return without changing existing value + /* 07 */ SCHEDULE_CMD_ID_NOP, // No-Op + /* 08 */ SCHEDULE_CMD_ID_CHECK_MISC_S, // Special check based on items or masks and branches if check passes, short range branch + /* 09 */ SCHEDULE_CMD_ID_RET_VAL_S, // Ends script and returns byte value + /* 10 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_S, // Checks if the current scene is not SceneNum and branches if so, short range branch + /* 11 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_L, // Checks if the current scene is not SceneNum and branches if so, long range branch + /* 12 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_S, // Checks if the current day is not Day and branches if so, short range branch + /* 13 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_L, // Checks if the current day is not Day and branches if so, long range branch + /* 14 */ SCHEDULE_CMD_ID_RET_TIME, // Returns 2 time values + /* 15 */ SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_S, // Branches if the current time is less than the command time, short range branch + /* 16 */ SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_L, // Branches if the current time is less than the command time, long range branch + /* 17 */ SCHEDULE_CMD_ID_BRANCH_S, // Always branch, short range branch + /* 18 */ SCHEDULE_CMD_ID_BRANCH_L, // Always branch, long range branch +} ScheduleCommandId; + +typedef enum { + /* 0 */ SCHEDULE_CHECK_MISC_ROOM_KEY, + /* 1 */ SCHEDULE_CHECK_MISC_LETTER_TO_KAFEI, + /* 2 */ SCHEDULE_CHECK_MISC_MASK_ROMANI, +} ScheduleCheckMisc; + +typedef struct { + /* 0x0 */ u8 result; + /* 0x4 */ s32 time0; + /* 0x8 */ s32 time1; + /* 0xC */ s32 hasResult; +} ScheduleResult; // size = 0x10 + +typedef struct { + /* 0x0 */ u8 cmd; +} ScheduleCmdBase; // size = 0x1 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 flagByte; + /* 0x2 */ u8 flagMask; + /* 0x3 */ s8 offset; +} ScheduleCmdCheckFlagS; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 flagByte; + /* 0x2 */ u8 flagMask; + /* 0x3 */ u8 offsetH; + /* 0x4 */ u8 offsetL; +} ScheduleCmdCheckFlagL; // size = 0x5 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 startHr; + /* 0x2 */ u8 startMin; + /* 0x3 */ u8 endHr; + /* 0x4 */ u8 endMin; + /* 0x5 */ s8 offset; +} ScheduleCmdCheckTimeRangeS; // size = 0x6 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 startHr; + /* 0x2 */ u8 startMin; + /* 0x3 */ u8 endHr; + /* 0x4 */ u8 endMin; + /* 0x5 */ u8 offsetH; + /* 0x6 */ u8 offsetL; +} ScheduleCmdCheckTimeRangeL; // size = 0x7 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 retH; + /* 0x2 */ u8 retL; +} ScheduleCmdReturnValueL; // size = 0x3 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 unk1; + /* 0x2 */ u8 unk2; + /* 0x3 */ u8 unk3; +} ScheduleCmdNop; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 which; + /* 0x2 */ s8 offset; +} ScheduleCmdCheckMiscS; // size = 0x3 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 result; +} ScheduleCmdReturnValueS; // size = 0x2 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 sceneH; + /* 0x2 */ u8 sceneL; + /* 0x3 */ s8 offset; +} ScheduleCmdCheckNotInSceneS; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 sceneH; + /* 0x2 */ u8 sceneL; + /* 0x3 */ u8 offsetH; + /* 0x4 */ u8 offsetL; +} ScheduleCmdCheckNotInSceneL; // size = 0x5 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 dayH; + /* 0x2 */ u8 dayL; + /* 0x3 */ s8 offset; +} ScheduleCmdCheckNotInDayS; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 dayH; + /* 0x2 */ u8 dayL; + /* 0x3 */ u8 offsetH; + /* 0x4 */ u8 offsetL; +} ScheduleCmdCheckNotInDayL; // size = 0x5 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 time0Hr; + /* 0x2 */ u8 time0Min; + /* 0x3 */ u8 time1Hr; + /* 0x4 */ u8 time1Min; + /* 0x5 */ u8 result; +} ScheduleCmdReturnTime; // size = 0x6 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 timeHr; + /* 0x2 */ u8 timeMin; + /* 0x3 */ s8 offset; +} ScheduleCmdCheckBeforeTimeS; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 timeHr; + /* 0x2 */ u8 timeMin; + /* 0x3 */ u8 offsetH; + /* 0x4 */ u8 offsetL; +} ScheduleCmdCheckBeforeTimeL; // size = 0x5 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ s8 offset; +} ScheduleCmdBranchS; // size = 0x2 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 offsetH; + /* 0x2 */ u8 offsetL; +} ScheduleCmdBranchL; // size = 0x3 + +#define SCHEDULE_PACK_S16(val) \ + ((val) >> 8) & 0xFF, (val) & 0xFF + +#define SCHEDULE_CMD_CHECK_FLAG_S(index, mask, offset) \ + SCHEDULE_CMD_ID_CHECK_FLAG_S, (index), (mask), (offset) + +#define SCHEDULE_CMD_CHECK_FLAG_L(index, mask, offset) \ + SCHEDULE_CMD_ID_CHECK_FLAG_L, (index), (mask), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_CHECK_TIME_RANGE_S(startHr, startMin, endHr, endMin, offset) \ + SCHEDULE_CMD_ID_CHECK_TIME_RANGE_S, (startHr), (startMin), (endHr), (endMin), (offset) + +#define SCHEDULE_CMD_CHECK_TIME_RANGE_L(startHr, startMin, endHr, endMin, offset) \ + SCHEDULE_CMD_ID_CHECK_TIME_RANGE_L, (startHr), (startMin), (endHr), (endMin), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_RET_VAL_L(result) \ + SCHEDULE_CMD_ID_RET_VAL_L, SCHEDULE_PACK_S16(result) + +#define SCHEDULE_CMD_RET_NONE() \ + SCHEDULE_CMD_ID_RET_NONE + +#define SCHEDULE_CMD_RET_EMPTY() \ + SCHEDULE_CMD_ID_RET_EMPTY, + +#define SCHEDULE_CMD_NOP(unk0, unk1, unk2) \ + SCHEDULE_CMD_ID_NOP, (unk0), (unk1), (unk2) + +#define SCHEDULE_CMD_CHECK_MISC_S(which, offset) \ + SCHEDULE_CMD_ID_CHECK_MISC_S, (which), (offset) + +#define SCHEDULE_CMD_RET_VAL_S(result) \ + SCHEDULE_CMD_ID_RET_VAL_S, (result) + +#define SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(scene, offset) \ + SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_S, SCHEDULE_PACK_S16(scene), (offset) + +#define SCHEDULE_CMD_CHECK_NOT_IN_SCENE_L(scene, offset) \ + SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_L, SCHEDULE_PACK_S16(scene), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(day, offset) \ + SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_S, SCHEDULE_PACK_S16(day), (offset) + +#define SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(day, offset) \ + SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_L, SCHEDULE_PACK_S16(day), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_RET_TIME(time0Hr, time0Min, time1Hr, time1Min, result) \ + SCHEDULE_CMD_ID_RET_TIME, (time0Hr), (time0Min), (time1Hr), (time1Min), (result) + +#define SCHEDULE_CMD_CHECK_BEFORE_TIME_S(timeHr, timeMin, offset) \ + SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_S, (timeHr), (timeMin), (offset) + +#define SCHEDULE_CMD_CHECK_BEFORE_TIME_L(timeHr, timeMin, offset) \ + SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_L, (timeHr), (timeMin), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_BRANCH_S(offset) \ + SCHEDULE_CMD_ID_BRANCH_S, (offset) + +#define SCHEDULE_CMD_BRANCH_L(offset) \ + SCHEDULE_CMD_ID_BRANCH_L, SCHEDULE_PACK_S16(offset) + +#endif diff --git a/spec b/spec index 57a044124..a2d9a9ef3 100644 --- a/spec +++ b/spec @@ -522,8 +522,7 @@ beginseg include "build/data/code/code_801C2730.data.o" include "build/src/code/z_scene_proc.o" include "build/src/code/z_scene_table.o" - include "build/src/code/code_801323D0.o" - include "build/data/code/code_801C5C50.data.o" + include "build/src/code/z_schedule.o" include "build/src/code/z_skelanime.o" include "build/src/code/z_skin.o" include "build/src/code/z_skin_awb.o" diff --git a/src/boot_O2_g3/idle.c b/src/boot_O2_g3/idle.c index 942435fa7..da93f13fd 100644 --- a/src/boot_O2_g3/idle.c +++ b/src/boot_O2_g3/idle.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" u8 D_80096B20 = 1; diff --git a/src/code/code_801323D0.c b/src/code/code_801323D0.c deleted file mode 100644 index 1457f537d..000000000 --- a/src/code/code_801323D0.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_801323D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132428.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132494.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_801326B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_801328F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132920.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132938.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132954.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_8013296C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132A18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132A3C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132A80.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132AD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132B24.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132B84.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132D70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132E9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132FDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80133000.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80133038.s") diff --git a/src/code/graph.c b/src/code/graph.c index 128aa0ee4..28327c35f 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #include "system_malloc.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 028f68011..f0ebe5911 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #include "vt.h" diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index 4b7f48696..a08e3f822 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" Vec3f D_801EDE00; diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 762be4538..c9c6253d3 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" diff --git a/src/code/z_schedule.c b/src/code/z_schedule.c new file mode 100644 index 000000000..4c57a57d4 --- /dev/null +++ b/src/code/z_schedule.c @@ -0,0 +1,283 @@ +#include "global.h" + +#define SCHEDULE_CALC_TIME(hour, minute, dest, temp) \ + (temp) = (hour)*60.0f; \ + (temp) += (minute); \ + (dest) = (temp) * (0x10000 / 60 / 24.0f); \ + (dest) = SCHEDULE_CONVERT_TIME(dest); + +s32 Schedule_CheckFlagS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckFlagS* cmd = (ScheduleCmdCheckFlagS*)*script; + u16 flag = (cmd->flagByte << 8) | cmd->flagMask; + + if (gSaveContext.save.weekEventReg[flag >> 8] & (flag & 0xFF)) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckFlagL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckFlagL* cmd = (ScheduleCmdCheckFlagL*)*script; + u16 flag = (cmd->flagByte << 8) | cmd->flagMask; + + if (gSaveContext.save.weekEventReg[flag >> 8] & (flag & 0xFF)) { + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_CheckTimeRangeS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + s32 inRange = false; + ScheduleCmdCheckTimeRangeS* cmd = (ScheduleCmdCheckTimeRangeS*)*script; + f32 f; + u16 start; + u16 end; + u16 now; + + SCHEDULE_CALC_TIME(cmd->startHr, cmd->startMin, start, f); + + SCHEDULE_CALC_TIME(cmd->endHr, cmd->endMin, end, f); + end--; + + now = SCHEDULE_TIME_NOW; + + if ((start <= now) && (now <= end)) { + inRange = true; + } + + if (inRange == true) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckTimeRangeL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + s32 inRange = false; + ScheduleCmdCheckTimeRangeL* cmd = (ScheduleCmdCheckTimeRangeL*)*script; + f32 f; + u16 start; + u16 end; + u16 now; + + SCHEDULE_CALC_TIME(cmd->startHr, cmd->startMin, start, f); + + SCHEDULE_CALC_TIME(cmd->endHr, cmd->endMin, end, f); + end--; + + now = SCHEDULE_TIME_NOW; + + if ((start <= now) && (now <= end)) { + inRange = true; + } + + if (inRange == true) { + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_ReturnValueL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdReturnValueL* cmd = (ScheduleCmdReturnValueL*)*script; + + //! @bug result is a u8, value is truncated + result->result = (cmd->retH << 8) | cmd->retL; + result->hasResult = true; + + return true; +} + +s32 Schedule_ReturnNone(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + result->hasResult = false; + + return true; +} + +s32 Schedule_ReturnEmpty(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + result->hasResult = true; + + return true; +} + +s32 Schedule_Nop(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + return false; +} + +s32 Schedule_CheckMiscS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckMiscS* cmd = (ScheduleCmdCheckMiscS*)*script; + + if (((cmd->which == SCHEDULE_CHECK_MISC_ROOM_KEY) && (INV_CONTENT(ITEM_ROOM_KEY) == ITEM_ROOM_KEY)) || + ((cmd->which == SCHEDULE_CHECK_MISC_LETTER_TO_KAFEI) && + (INV_CONTENT(ITEM_LETTER_TO_KAFEI) == ITEM_LETTER_TO_KAFEI)) || + ((cmd->which == SCHEDULE_CHECK_MISC_MASK_ROMANI) && (Player_GetMask(globalCtx) == PLAYER_MASK_ROMANI))) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_ReturnValueS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdReturnValueS* cmd = (ScheduleCmdReturnValueS*)*script; + + result->result = cmd->result; + result->hasResult = true; + + return true; +} + +s32 Schedule_CheckNotInSceneS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckNotInSceneS* cmd = (ScheduleCmdCheckNotInSceneS*)*script; + s16 scene = (cmd->sceneH << 8) | cmd->sceneL; + + if (scene != globalCtx->sceneNum) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckNotInSceneL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckNotInSceneL* cmd = (ScheduleCmdCheckNotInSceneL*)*script; + s16 scene = (cmd->sceneH << 8) | cmd->sceneL; + + if (scene != globalCtx->sceneNum) { + *script = *script + (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_CheckNotInDayS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckNotInDayS* cmd = (ScheduleCmdCheckNotInDayS*)*script; + s16 day = (cmd->dayH << 8) | cmd->dayL; + + if (day != (s16)gSaveContext.save.day) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckNotInDayL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckNotInDayL* cmd = (ScheduleCmdCheckNotInDayL*)*script; + s16 day = (cmd->dayH << 8) | cmd->dayL; + + if (day != (s16)gSaveContext.save.day) { + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_ReturnTime(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdReturnTime* cmd = (ScheduleCmdReturnTime*)*script; + f32 f; + u16 time0; + u16 time1; + + SCHEDULE_CALC_TIME(cmd->time0Hr, cmd->time0Min, time0, f); + + SCHEDULE_CALC_TIME(cmd->time1Hr, cmd->time1Min, time1, f); + time1--; + + result->result = cmd->result; + result->time0 = time0; + result->time1 = time1; + result->hasResult = true; + + return true; +} + +s32 Schedule_CheckBeforeTimeS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckBeforeTimeS* cmd = (ScheduleCmdCheckBeforeTimeS*)*script; + f32 f; + u16 testTime; + u16 now; + + SCHEDULE_CALC_TIME(cmd->timeHr, cmd->timeMin, testTime, f); + + now = SCHEDULE_TIME_NOW; + + if (now < testTime) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckBeforeTimeL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckBeforeTimeL* cmd = (ScheduleCmdCheckBeforeTimeL*)*script; + f32 f; + u16 testTime; + u16 now; + + SCHEDULE_CALC_TIME(cmd->timeHr, cmd->timeMin, testTime, f); + + now = SCHEDULE_TIME_NOW; + + if (now < testTime) { + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_BranchS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdBranchS* cmd = (ScheduleCmdBranchS*)*script; + + *script += cmd->offset; + return false; +} + +s32 Schedule_BranchL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdBranchL* cmd = (ScheduleCmdBranchL*)*script; + + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + return false; +} + +static s32 (*sScheduleCmdFuncs[])(GlobalContext*, u8**, ScheduleResult*) = { + Schedule_CheckFlagS, Schedule_CheckFlagL, Schedule_CheckTimeRangeS, Schedule_CheckTimeRangeL, + Schedule_ReturnValueL, Schedule_ReturnNone, Schedule_ReturnEmpty, Schedule_Nop, + Schedule_CheckMiscS, Schedule_ReturnValueS, Schedule_CheckNotInSceneS, Schedule_CheckNotInSceneL, + Schedule_CheckNotInDayS, Schedule_CheckNotInDayL, Schedule_ReturnTime, Schedule_CheckBeforeTimeS, + Schedule_CheckBeforeTimeL, Schedule_BranchS, Schedule_BranchL, +}; + +static u8 sScheduleCmdSizes[] = { + sizeof(ScheduleCmdCheckFlagS), + sizeof(ScheduleCmdCheckFlagL), + sizeof(ScheduleCmdCheckTimeRangeS), + sizeof(ScheduleCmdCheckTimeRangeL), + sizeof(ScheduleCmdReturnValueL), + sizeof(ScheduleCmdBase), + sizeof(ScheduleCmdBase), + sizeof(ScheduleCmdNop), + sizeof(ScheduleCmdCheckMiscS), + sizeof(ScheduleCmdReturnValueS), + sizeof(ScheduleCmdCheckNotInSceneS), + sizeof(ScheduleCmdCheckNotInSceneL), + sizeof(ScheduleCmdCheckNotInDayS), + sizeof(ScheduleCmdCheckNotInDayL), + sizeof(ScheduleCmdReturnTime), + sizeof(ScheduleCmdCheckBeforeTimeS), + sizeof(ScheduleCmdCheckBeforeTimeL), + sizeof(ScheduleCmdBranchS), + sizeof(ScheduleCmdBranchL), +}; + +s32 Schedule_RunScript(GlobalContext* globalCtx, u8* script, ScheduleResult* result) { + u8 size; + s32 stop; + + do { + size = sScheduleCmdSizes[*script]; + stop = (*sScheduleCmdFuncs[*script])(globalCtx, &script, result); + script += size; + } while (!stop); + + return result->hasResult; +} diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index 5a88f67c6..311d07a75 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -4,6 +4,7 @@ * Description: Igos du Ikana window - curtains and ray effects */ +#include "prevent_bss_reordering.h" #include "z_boss_06.h" #include "overlays/actors/ovl_En_Knight/z_en_knight.h" #include "objects/gameplay_keep/gameplay_keep.h" diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index 5f0f7a5b2..732b3e37b 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -19,9 +19,24 @@ void EnAh_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BD36B8(EnAh* this, GlobalContext* globalCtx); void func_80BD3768(EnAh* this, GlobalContext* globalCtx); -s32 D_80BD3DB0[] = { - 0x0A00611D, 0x0C000303, 0x0400010C, 0x00021102, 0x15001700, 0x08003220, 0x03040001, - 0x05040003, 0x050A0010, 0x120C0003, 0x0D021200, 0x06000105, 0x0E120006, 0x00020505, +static u8 D_80BD3DB0[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x21 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x0B - 0x08), + /* 0x08 */ SCHEDULE_CMD_RET_VAL_L(1), + /* 0x0B */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x20 - 0x0F), + /* 0x0F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 0, 23, 0, 0x1D - 0x15), + /* 0x15 */ SCHEDULE_CMD_CHECK_FLAG_S(0x32, 0x20, 0x1C - 0x19), + /* 0x19 */ SCHEDULE_CMD_RET_VAL_L(1), + /* 0x1C */ SCHEDULE_CMD_RET_NONE(), + /* 0x1D */ SCHEDULE_CMD_RET_VAL_L(3), + /* 0x20 */ SCHEDULE_CMD_RET_NONE(), + /* 0x21 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_OMOYA, 0x37 - 0x25), + /* 0x25 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x36 - 0x29), + /* 0x29 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x30 - 0x2F), + /* 0x2F */ SCHEDULE_CMD_RET_NONE(), + /* 0x30 */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 2), + /* 0x36 */ SCHEDULE_CMD_RET_NONE(), + /* 0x37 */ SCHEDULE_CMD_RET_NONE(), }; s32 D_80BD3DE8[] = { 0x0E28FF0C, 0x10000000 }; @@ -361,7 +376,7 @@ s32 func_80BD3320(EnAh* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId return ret; } -s32 func_80BD3374(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BD3374(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3EC4.pos); @@ -373,7 +388,7 @@ s32 func_80BD3374(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80BD33FC(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BD33FC(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3ED8.pos); @@ -385,7 +400,7 @@ s32 func_80BD33FC(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80BD3484(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BD3484(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80BD3320(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AN)) { @@ -404,12 +419,12 @@ s32 func_80BD3484(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BD3548(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BD3548(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret; this->unk_2D8 = 0; - switch (arg2->unk0) { + switch (arg2->result) { default: ret = false; break; @@ -457,19 +472,18 @@ void func_80BD3658(EnAh* this, GlobalContext* globalCtx) { } void func_80BD36B8(EnAh* this, GlobalContext* globalCtx) { - s32 pad; - struct_80133038_arg2 sp18; + ScheduleResult sp18; - if (!func_80133038(globalCtx, D_80BD3DB0, &sp18) || - ((this->unk_1DC != sp18.unk0) && !func_80BD3548(this, globalCtx, &sp18))) { + if (!Schedule_RunScript(globalCtx, D_80BD3DB0, &sp18) || + ((this->unk_1DC != sp18.result) && !func_80BD3548(this, globalCtx, &sp18))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp18.unk0 = 0; + sp18.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_1DC = sp18.unk0; + this->unk_1DC = sp18.result; func_80BD3658(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index 259c52614..149f82d45 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -19,10 +19,22 @@ void EnAl_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BDF5E8(EnAl* this, GlobalContext* globalCtx); void func_80BDF6C4(EnAl* this, GlobalContext* globalCtx); -s32 D_80BDFC70[] = { - 0x0C00030D, 0x02120006, 0x0001050E, 0x12000600, 0x02020800, 0x0A002F02, 0x0A000A37, - 0x23020A37, 0x0B2D0D02, 0x0B2D1400, 0x01050E0B, 0x2D140001, 0x0C000206, 0x0E0A370B, - 0x2D010E0A, 0x370B2D03, 0x0E0A000A, 0x37010400, 0x01000000, +static u8 D_80BDFC70[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x11 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x0B - 0x0A), + /* 0x0A */ SCHEDULE_CMD_RET_NONE(), + /* 0x0B */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 2), + /* 0x11 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(8, 0, 10, 0, 0x46 - 0x17), + /* 0x17 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 10, 55, 0x40 - 0x1D), + /* 0x1D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 55, 11, 45, 0x30 - 0x23), + /* 0x23 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 45, 20, 0, 0x2A - 0x29), + /* 0x29 */ SCHEDULE_CMD_RET_NONE(), + /* 0x2A */ SCHEDULE_CMD_RET_TIME(11, 45, 20, 0, 1), + /* 0x30 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x3A - 0x34), + /* 0x34 */ SCHEDULE_CMD_RET_TIME(10, 55, 11, 45, 1), + /* 0x3A */ SCHEDULE_CMD_RET_TIME(10, 55, 11, 45, 3), + /* 0x40 */ SCHEDULE_CMD_RET_TIME(10, 0, 10, 55, 1), + /* 0x46 */ SCHEDULE_CMD_RET_VAL_L(1), }; s32 D_80BDFCBC[] = { @@ -623,7 +635,7 @@ s32 func_80BDF064(EnAl* this, GlobalContext* globalCtx) { return false; } -s32 func_80BDF244(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BDF244(EnAl* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; Actor* sp20 = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_GM); Actor* temp_v0 = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TOTO); @@ -638,10 +650,10 @@ s32 func_80BDF244(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, ScheduleResult* arg2) { SubS_UpdateFlags(&this->unk_4C2, 3, 7); - switch (arg2->unk0) { + switch (arg2->result) { case 1: func_80BDE27C(this, 0); break; @@ -655,7 +667,7 @@ s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80BDF390(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BDF390(EnAl* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret; this->actor.flags |= ACTOR_FLAG_1; @@ -664,7 +676,7 @@ s32 func_80BDF390(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_4C2 = 0; this->unk_4D4 = 40.0f; - switch (arg2->unk0) { + switch (arg2->result) { case 3: ret = func_80BDF244(this, globalCtx, arg2); break; @@ -734,20 +746,19 @@ void func_80BDF578(EnAl* this, GlobalContext* globalCtx) { } void func_80BDF5E8(EnAl* this, GlobalContext* globalCtx) { - u32* unk14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp20; + ScheduleResult sp20; - this->unk_4E0 = REG(15) + *unk14; - if (!func_80133038(globalCtx, D_80BDFC70, &sp20) || - ((this->unk_35C != sp20.unk0) && !func_80BDF390(this, globalCtx, &sp20))) { + this->unk_4E0 = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BDFC70, &sp20) || + ((this->unk_35C != sp20.result) && !func_80BDF390(this, globalCtx, &sp20))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp20.unk0 = 0; + sp20.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_35C = sp20.unk0; + this->unk_35C = sp20.result; this->unk_368 = func_80BDE384(this, globalCtx); func_80BDF578(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index a2f28a6dd..4d9c7bad3 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -107,8 +107,16 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -s32 D_80BAA488[] = { - 0x0C000119, 0x0A006E14, 0x02000000, 0x1E080F00, 0x1E030400, 0x01050E00, 0x00001E02, 0x05050000, +static u8 D_80BAA488[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0x1D - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_BACKTOWN, 0x1C - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 30, 0x16 - 0x0E), + /* 0x0E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(0, 30, 0x15 - 0x12), + /* 0x12 */ SCHEDULE_CMD_RET_VAL_L(1), + /* 0x15 */ SCHEDULE_CMD_RET_NONE(), + /* 0x16 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 30, 2), + /* 0x1C */ SCHEDULE_CMD_RET_NONE(), + /* 0x1D */ SCHEDULE_CMD_RET_NONE(), }; s32 D_80BAA4A8[] = { -1, -1, 0 }; @@ -305,13 +313,13 @@ void func_80BA8DF4(EnBaba* this, GlobalContext* globalCtx) { } } -s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u16 sp26 = (u16)(gSaveContext.save.time - 0x3FFC); u16 temp; u8 sp23 = ENBABA_GET_3F00(&this->actor); - if (D_80BAA4A8[arg2->unk0] >= 0) { - this->unk_410 = SubS_GetAdditionalPath(globalCtx, sp23, D_80BAA4A8[arg2->unk0]); + if (D_80BAA4A8[arg2->result] >= 0) { + this->unk_410 = SubS_GetAdditionalPath(globalCtx, sp23, D_80BAA4A8[arg2->result]); } if (this->unk_410 == NULL) { @@ -321,13 +329,13 @@ s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* if ((this->unk_434 != 0) && (this->unk_436 >= 0)) { temp = sp26; } else { - temp = arg2->unk4; + temp = arg2->time0; } - if (arg2->unk8 < temp) { - this->unk_424 = (temp - arg2->unk8) + 0xFFFF; + if (arg2->time1 < temp) { + this->unk_424 = (temp - arg2->time1) + 0xFFFF; } else { - this->unk_424 = arg2->unk8 - temp; + this->unk_424 = arg2->time1 - temp; } this->unk_430 = sp26 - temp; @@ -339,10 +347,10 @@ s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* return true; } -s32 func_80BA9110(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BA9110(EnBaba* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret; - switch (arg2->unk0) { + switch (arg2->result) { default: ret = false; break; @@ -583,21 +591,20 @@ void func_80BA9B24(EnBaba* this, GlobalContext* globalCtx) { } void func_80BA9B80(EnBaba* this, GlobalContext* globalCtx) { - u32* unk14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp20; + ScheduleResult sp20; - this->unk_436 = REG(15) + *unk14; + this->unk_436 = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!func_80133038(globalCtx, D_80BAA488, &sp20) || - ((this->unk_434 != sp20.unk0) && !func_80BA9110(this, globalCtx, &sp20))) { + if (!Schedule_RunScript(globalCtx, D_80BAA488, &sp20) || + ((this->unk_434 != sp20.result) && !func_80BA9110(this, globalCtx, &sp20))) { this->unk_40A &= ~0x80; this->actor.flags &= ~ACTOR_FLAG_1; - sp20.unk0 = false; + sp20.result = false; } else { this->unk_40A |= 0x80; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_434 = sp20.unk0; + this->unk_434 = sp20.result; func_80BA93AC(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.c b/src/overlays/actors/ovl_En_Door/z_en_door.c index bb1c574e2..fe65bb30d 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -38,104 +38,243 @@ void func_808670F0(EnDoor*, GlobalContext*); void func_80866A5C(EnDoor*, GlobalContext*); u8 D_808675D0[] = { - 0x0C, 0x00, 0x03, 0x0E, 0x02, 0x06, 0x00, 0x17, 0x00, 0x08, - 0x02, 0x00, 0x00, 0x06, 0x00, 0x02, 0x09, 0x07, 0x05, 0x00, + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x12 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 23, 0, 0x12 - 0x0A), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 6, 0, 0x12 - 0x10), + /* 0x10 */ SCHEDULE_CMD_RET_VAL_S(7), + /* 0x12 */ SCHEDULE_CMD_RET_NONE(), }; u8 D_808675E4[] = { - 0x0F, 0x09, 0x00, 0x47, 0x0F, 0x0C, 0x00, 0x15, 0x0C, 0x00, 0x01, 0x13, 0x11, 0x00, 0x0F, 0x0D, - 0x00, 0x0A, 0x0F, 0x0F, 0x00, 0x07, 0x0F, 0x00, 0x00, 0x02, 0x09, 0x09, 0x05, 0x09, 0x08, 0x0C, - 0x00, 0x02, 0x19, 0x00, 0x1C, 0x08, 0x07, 0x0F, 0x0D, 0x00, 0x02, 0x09, 0x09, 0x05, 0x0F, 0x0D, - 0x00, 0xEA, 0x0F, 0x11, 0x00, 0xE7, 0x0F, 0x00, 0x00, 0xE2, 0x09, 0x09, 0x0F, 0x0D, 0x00, 0xDC, - 0x0F, 0x0D, 0x00, 0xD9, 0x0F, 0x12, 0x00, 0x01, 0x05, 0x09, 0x09, 0x09, 0x09, 0x00, 0x00, 0x00, + /* 0x00 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(9, 0, 0x4B - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(12, 0, 0x1D - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0x1F - 0x0C), + /* 0x0C */ SCHEDULE_CMD_BRANCH_S(0x0), + /* 0x0E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x1C - 0x12), + /* 0x12 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(15, 0, 0x1D - 0x16), + /* 0x16 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(0, 0, 0x1C - 0x1A), + /* 0x1A */ SCHEDULE_CMD_RET_VAL_S(9), + /* 0x1C */ SCHEDULE_CMD_RET_NONE(), + /* 0x1D */ SCHEDULE_CMD_RET_VAL_S(8), + /* 0x1F */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x3C - 0x23), + /* 0x23 */ SCHEDULE_CMD_CHECK_FLAG_S(0x1C, 0x08, 0x2E - 0x27), + /* 0x27 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x2D - 0x2B), + /* 0x2B */ SCHEDULE_CMD_RET_VAL_S(9), + /* 0x2D */ SCHEDULE_CMD_RET_NONE(), + /* 0x2E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x1C - 0x32), + /* 0x32 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(17, 0, 0x1D - 0x36), + /* 0x36 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(0, 0, 0x1C - 0x3A), + /* 0x3A */ SCHEDULE_CMD_RET_VAL_S(9), + /* 0x3C */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x1C - 0x40), + /* 0x40 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x1D - 0x44), + /* 0x44 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(18, 0, 0x49 - 0x48), + /* 0x48 */ SCHEDULE_CMD_RET_NONE(), + /* 0x49 */ SCHEDULE_CMD_RET_VAL_S(9), + /* 0x4B */ SCHEDULE_CMD_RET_VAL_S(9), }; u8 D_80867634[] = { - 0x02, 0x06, 0x00, 0x17, 0x00, 0x02, 0x09, 0x1C, 0x05, 0x00, 0x00, 0x00, + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 23, 0, 0x8 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_VAL_S(28), + /* 0x8 */ SCHEDULE_CMD_RET_NONE(), }; u8 D_80867640[] = { - 0x02, 0x15, 0x00, 0x16, 0x00, 0x01, 0x05, 0x09, 0x0B, 0x00, 0x00, 0x00, + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 0, 22, 0, 0x7 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), + /* 0x7 */ SCHEDULE_CMD_RET_VAL_S(11), }; + u8 D_8086764C[] = { - 0x02, 0x16, 0x00, 0x05, 0x00, 0x02, 0x09, 0x0A, 0x05, 0x00, 0x00, 0x00, + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(22, 0, 5, 0, 0x8 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_VAL_S(10), + /* 0x8 */ SCHEDULE_CMD_RET_NONE(), }; + u8 D_80867658[] = { - 0x0C, 0x00, 0x02, 0x0F, 0x00, 0x1C, 0x08, 0x02, 0x09, 0x0C, 0x02, 0x0F, 0x0A, 0x16, 0x00, - 0x02, 0x09, 0x0C, 0x05, 0x0C, 0x00, 0x03, 0x11, 0x0F, 0x0D, 0x00, 0x0D, 0x00, 0x33, 0x08, - 0x02, 0x09, 0x0C, 0x0F, 0x16, 0x00, 0x02, 0x09, 0x0C, 0x05, 0x09, 0x0C, 0x00, 0x00, + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x13 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x1C, 0x08, 0x0A - 0x08), + /* 0x08 */ SCHEDULE_CMD_RET_VAL_S(12), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 10, 22, 0, 0x12 - 0x10), + /* 0x10 */ SCHEDULE_CMD_RET_VAL_S(12), + /* 0x12 */ SCHEDULE_CMD_RET_NONE(), + /* 0x13 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x28 - 0x17), + /* 0x17 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x28 - 0x1B), + /* 0x1B */ SCHEDULE_CMD_CHECK_FLAG_S(0x33, 0x08, 0x21 - 0x1F), + /* 0x1F */ SCHEDULE_CMD_RET_VAL_S(12), + /* 0x21 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x27 - 0x25), + /* 0x25 */ SCHEDULE_CMD_RET_VAL_S(12), + /* 0x27 */ SCHEDULE_CMD_RET_NONE(), + /* 0x28 */ SCHEDULE_CMD_RET_VAL_S(12), }; -u8 D_80867684[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_80867684[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_80867688[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x0F, 0x05, 0x00 }; +u8 D_80867688[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(15), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_80867690[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x10, 0x05, 0x00 }; +u8 D_80867690[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(16), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_80867698[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x11, 0x05, 0x00 }; +u8 D_80867698[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(17), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; u8 D_808676A0[] = { - 0x02, 0x0A, 0x00, 0x15, 0x00, 0x0F, 0x02, 0x16, 0x00, 0x05, 0x00, 0x02, - 0x09, 0x12, 0x08, 0x02, 0x02, 0x09, 0x22, 0x09, 0x21, 0x05, 0x00, 0x00, + /* 0x00 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 21, 0, 0x15 - 0x06), + /* 0x06 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(22, 0, 5, 0, 0x0E - 0x0C), + /* 0x0C */ SCHEDULE_CMD_RET_VAL_S(18), + /* 0x0E */ SCHEDULE_CMD_CHECK_MISC_S(SCHEDULE_CHECK_MISC_MASK_ROMANI, 0x13 - 0x11), + /* 0x11 */ SCHEDULE_CMD_RET_VAL_S(34), + /* 0x13 */ SCHEDULE_CMD_RET_VAL_S(33), + /* 0x15 */ SCHEDULE_CMD_RET_NONE(), }; u8 D_808676B8[] = { - 0x08, 0x00, 0x14, 0x0C, 0x00, 0x03, 0x07, 0x0F, 0x08, 0x00, 0x01, 0x05, - 0x09, 0x13, 0x02, 0x08, 0x00, 0x14, 0x1E, 0x02, 0x09, 0x13, 0x05, 0x05, + /* 0x00 */ SCHEDULE_CMD_CHECK_MISC_S(SCHEDULE_CHECK_MISC_ROOM_KEY, 0x17 - 0x03), + /* 0x03 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x0E - 0x07), + /* 0x07 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(8, 0, 0x0C - 0x0B), + /* 0x0B */ SCHEDULE_CMD_RET_NONE(), + /* 0x0C */ SCHEDULE_CMD_RET_VAL_S(19), + /* 0x0E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(8, 0, 20, 30, 0x16 - 0x14), + /* 0x14 */ SCHEDULE_CMD_RET_VAL_S(19), + /* 0x16 */ SCHEDULE_CMD_RET_NONE(), + /* 0x17 */ SCHEDULE_CMD_RET_NONE(), }; -u8 D_808676D0[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_808676D0[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_808676D4[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_808676D4[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_808676D8[] = { 0x0C, 0x00, 0x03, 0x05, 0x0F, 0x12, 0x00, 0x01, 0x05, 0x09, 0x14, 0x00 }; +u8 D_808676D8[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x9 - 0x4), + /* 0x4 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(18, 0, 0x9 - 0x8), + /* 0x8 */ SCHEDULE_CMD_RET_NONE(), + /* 0x9 */ SCHEDULE_CMD_RET_VAL_S(20), +}; -u8 D_808676E4[] = { 0x08, 0x00, 0x02, 0x09, 0x16, 0x05, 0x00, 0x00 }; +u8 D_808676E4[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_MISC_S(SCHEDULE_CHECK_MISC_ROOM_KEY, 0x5 - 0x3), + /* 0x3 */ SCHEDULE_CMD_RET_VAL_S(22), + /* 0x5 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_808676EC[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_808676EC[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; u8 D_808676F0[] = { - 0x0C, 0x00, 0x03, 0x05, 0x0F, 0x0A, 0x00, 0x07, 0x05, 0x02, - 0x0A, 0x00, 0x14, 0x00, 0xF9, 0x09, 0x15, 0x00, 0x00, 0x00, + /* 0x0 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x9 - 0x4), + /* 0x4 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(10, 0, 0xF - 0x8), + /* 0x8 */ SCHEDULE_CMD_RET_NONE(), + /* 0x9 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 20, 0, 0x8 - 0xF), + /* 0xF */ SCHEDULE_CMD_RET_VAL_S(21), }; -u8 D_80867704[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_80867708[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_8086770C[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_80867710[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_80867704[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_80867714[] = { 0x0F, 0x14, 0x00, 0x02, 0x09, 0x17, 0x05, 0x00 }; +u8 D_80867708[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_8086770C[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867710[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867714[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(23), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; u8 D_8086771C[] = { - 0x0C, 0x00, 0x01, 0x07, 0x0F, 0x02, 0x1E, 0x02, 0x09, 0x18, 0x05, 0x0C, - 0x00, 0x03, 0xFB, 0x0F, 0x14, 0x00, 0xF7, 0x09, 0x0C, 0x00, 0x00, 0x00, + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0x0B - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(2, 30, 0x0A - 0x08), + /* 0x08 */ SCHEDULE_CMD_RET_VAL_S(24), + /* 0x0A */ SCHEDULE_CMD_RET_NONE(), + /* 0x0B */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x0A - 0x0F), + /* 0x0F */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x0A - 0x13), + /* 0x13 */ SCHEDULE_CMD_RET_VAL_S(12), }; -u8 D_80867734[] = { 0x0F, 0x14, 0x00, 0x02, 0x09, 0x19, 0x05, 0x00 }; +u8 D_80867734[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(25), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_8086773C[] = { 0x0F, 0x14, 0x00, 0x02, 0x09, 0x1A, 0x05, 0x00 }; +u8 D_8086773C[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(26), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; u8 D_80867744[] = { - 0x0C, 0x00, 0x02, 0x04, 0x00, 0x63, 0x80, 0x06, 0x0F, 0x14, 0x00, 0x08, - 0x09, 0x1B, 0x0F, 0x12, 0x00, 0x02, 0x09, 0x1B, 0x05, 0x00, 0x00, 0x00, + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x08 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x63, 0x80, 0x0E - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x14 - 0x0C), + /* 0x0C */ SCHEDULE_CMD_RET_VAL_S(27), + /* 0x0E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(18, 0, 0x14 - 0x12), + /* 0x12 */ SCHEDULE_CMD_RET_VAL_S(27), + /* 0x14 */ SCHEDULE_CMD_RET_NONE(), }; u8 D_8086775C[] = { - 0x00, 0x34, 0x20, 0x17, 0x00, 0x4B, 0x20, 0x13, 0x00, 0x0E, 0x04, 0x02, 0x09, 0x1D, - 0x00, 0x3B, 0x01, 0x08, 0x00, 0x3D, 0x02, 0x02, 0x09, 0x1E, 0x09, 0x1F, 0x05, 0x05, + /* 0x00 */ SCHEDULE_CMD_CHECK_FLAG_S(0x34, 0x20, 0x1B - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x4B, 0x20, 0x1B - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_FLAG_S(0x0E, 0x04, 0x0E - 0x0C), + /* 0x0C */ SCHEDULE_CMD_RET_VAL_S(29), + /* 0x0E */ SCHEDULE_CMD_CHECK_FLAG_S(0x3B, 0x01, 0x1A - 0x12), + /* 0x12 */ SCHEDULE_CMD_CHECK_FLAG_S(0x3D, 0x02, 0x18 - 0x16), + /* 0x16 */ SCHEDULE_CMD_RET_VAL_S(30), + /* 0x18 */ SCHEDULE_CMD_RET_VAL_S(31), + /* 0x1A */ SCHEDULE_CMD_RET_NONE(), + /* 0x1B */ SCHEDULE_CMD_RET_NONE(), }; -u8 D_80867778[] = { 0x09, 0x20, 0x00, 0x00 }; -u8 D_8086777C[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_80867780[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_80867784[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x23, 0x05, 0x00 }; +u8 D_80867778[] = { + /* 0x0 */ SCHEDULE_CMD_RET_VAL_S(32), +}; -// void* seems to keep the compiler happy. -void* D_8086778C[] = { - &D_808675D0, &D_808675E4, &D_80867634, &D_80867640, &D_8086764C, &D_80867658, &D_80867684, &D_80867688, - &D_80867690, &D_80867698, &D_808676A0, &D_808676B8, &D_808676D0, &D_808676D4, &D_808676D8, &D_808676E4, - &D_808676EC, &D_808676F0, &D_80867704, &D_80867708, &D_8086770C, &D_80867710, &D_80867714, &D_8086771C, - &D_80867734, &D_8086773C, &D_80867744, &D_8086775C, &D_80867778, &D_8086777C, &D_80867780, &D_80867784, +u8 D_8086777C[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867780[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867784[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(35), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8* D_8086778C[] = { + D_808675D0, D_808675E4, D_80867634, D_80867640, D_8086764C, D_80867658, D_80867684, D_80867688, + D_80867690, D_80867698, D_808676A0, D_808676B8, D_808676D0, D_808676D4, D_808676D8, D_808676E4, + D_808676EC, D_808676F0, D_80867704, D_80867708, D_8086770C, D_80867710, D_80867714, D_8086771C, + D_80867734, D_8086773C, D_80867744, D_8086775C, D_80867778, D_8086777C, D_80867780, D_80867784, }; const ActorInit En_Door_InitVars = { @@ -336,7 +475,6 @@ void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { s32 temp_a1_2; s32 temp_t0; u8 temp_a1; - s32 pad; if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state) && (this->dyna.actor.textId == 0x1821)) { D_80867BC0[0] = 1; @@ -396,10 +534,10 @@ void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { this->dyna.actor.textId = baseTextId + textIdOffset; } } else if ((this->unk_1A4 == 5) && (playerPosRelToDoor.z > 0.0f)) { - struct_80133038_arg2 sp30; + ScheduleResult sp30; - if (func_80133038(globalCtx, D_8086778C[this->switchFlag], &sp30) != 0) { - this->dyna.actor.textId = sp30.unk0 + 0x1800; + if (Schedule_RunScript(globalCtx, D_8086778C[this->switchFlag], &sp30) != 0) { + this->dyna.actor.textId = sp30.result + 0x1800; player->doorType = ((this->dyna.actor.textId == 0x1821) && (D_80867BC0[0] != 0)) ? 5 : -1; } 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 0c80ce319..e598fe78f 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -20,21 +20,102 @@ void EnGm_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80950CDC(EnGm* this, GlobalContext* globalCtx); void func_80950DB8(EnGm* this, GlobalContext* globalCtx); -static u32 D_80951820[] = { - 0x0D000101, 0x360A0061, 0x25020600, 0x09001902, 0x0900090A, 0x0D02090A, 0x090F0105, 0x0E090A09, 0x0F0F0E09, - 0x00090A18, 0x0E060009, 0x00060A00, 0x6C490209, 0x0A090F3D, 0x02090F0A, 0x0031020A, 0x000A0525, 0x020C0F0C, - 0x1419020C, 0x140C320D, 0x020C320C, 0x3701050E, 0x0C320C37, 0x0C0E0C14, 0x0C32160E, 0x0C0F0C14, 0x0B0E0A00, - 0x0A050A0E, 0x090F0A00, 0x150E090A, 0x090F090B, 0x00120085, 0x020A000A, 0x0579020A, 0x050A0A6D, 0x020A0A0A, - 0x1E61020A, 0x1E0A2855, 0x020A280A, 0x2D49020A, 0x2D0A373D, 0x020A370B, 0x2D31020B, 0x2D0B3725, 0x020B370C, - 0x0019020C, 0x000C0F0D, 0x020C0F0C, 0x1401050E, 0x0C0F0C14, 0x110E0C00, 0x0C0F1D0E, 0x0B370C00, 0x130E0B2D, - 0x0B371C0E, 0x0A370B2D, 0x020E0A2D, 0x0A371B0E, 0x0A280A2D, 0x120E0A1E, 0x0A281A0E, 0x0A0A0A1E, 0x010E0A05, - 0x0A0A190E, 0x0A000A05, 0x100A0015, 0x31020C37, 0x0D002502, 0x0D000D19, 0x19020D19, 0x15050D02, 0x15370505, - 0x01050E15, 0x37050505, 0x0E0D1915, 0x05030E0D, 0x000D191E, 0x0E0C370D, 0x0014050D, 0x000200AB, 0x01320100, - 0x880A0061, 0x31020600, 0x12002502, 0x12001500, 0x19021500, 0x150A0D02, 0x150A150F, 0x01050E15, 0x0A150F0F, - 0x0E150015, 0x0A180E12, 0x00150006, 0x0E060012, 0x00070A00, 0x6C250215, 0x0A150F19, 0x02150F15, 0x190D0215, - 0x19151E01, 0x050E1519, 0x151E0E0E, 0x150F1519, 0x170E150A, 0x150F0D0A, 0x00152502, 0x151E152D, 0x1902152D, - 0x160A0D02, 0x160A0600, 0x01050E16, 0x0A060005, 0x0E152D16, 0x0A1E0E15, 0x1E152D14, 0x050A0061, 0x19020600, - 0x12000D02, 0x12000600, 0x01050E00, 0x00000008, 0x0E060012, 0x00070505, +static u8 D_80951820[] = { + /* 0x000 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(1, 0x13B - 0x005), + /* 0x005 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x02E - 0x009), + /* 0x009 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 9, 0, 0x028 - 0x00F), + /* 0x00F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 0, 9, 10, 0x022 - 0x015), + /* 0x015 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 10, 9, 15, 0x01C - 0x01B), + /* 0x01B */ SCHEDULE_CMD_RET_NONE(), + /* 0x01C */ SCHEDULE_CMD_RET_TIME(9, 10, 9, 15, 15), + /* 0x022 */ SCHEDULE_CMD_RET_TIME(9, 0, 9, 10, 24), + /* 0x028 */ SCHEDULE_CMD_RET_TIME(6, 0, 9, 0, 6), + /* 0x02E */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x07B - 0x032), + /* 0x032 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 10, 9, 15, 0x075 - 0x038), + /* 0x038 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 15, 10, 0, 0x06F - 0x03E), + /* 0x03E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 10, 5, 0x069 - 0x044), + /* 0x044 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 15, 12, 20, 0x063 - 0x04A), + /* 0x04A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 20, 12, 50, 0x05D - 0x050), + /* 0x050 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 50, 12, 55, 0x057 - 0x056), + /* 0x056 */ SCHEDULE_CMD_RET_NONE(), + /* 0x057 */ SCHEDULE_CMD_RET_TIME(12, 50, 12, 55, 12), + /* 0x05D */ SCHEDULE_CMD_RET_TIME(12, 20, 12, 50, 22), + /* 0x063 */ SCHEDULE_CMD_RET_TIME(12, 15, 12, 20, 11), + /* 0x069 */ SCHEDULE_CMD_RET_TIME(10, 0, 10, 5, 10), + /* 0x06F */ SCHEDULE_CMD_RET_TIME(9, 15, 10, 0, 21), + /* 0x075 */ SCHEDULE_CMD_RET_TIME(9, 10, 9, 15, 9), + /* 0x07B */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_L(SCENE_SONCHONOIE, 0x105 - 0x080), + /* 0x080 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 10, 5, 0x0FF - 0x086), + /* 0x086 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 5, 10, 10, 0x0F9 - 0x08C), + /* 0x08C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 10, 10, 30, 0x0F3 - 0x092), + /* 0x092 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 30, 10, 40, 0x0ED - 0x098), + /* 0x098 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 40, 10, 45, 0x0E7 - 0x09E), + /* 0x09E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 45, 10, 55, 0x0E1 - 0x0A4), + /* 0x0A4 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 55, 11, 45, 0x0DB - 0x0AA), + /* 0x0AA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 45, 11, 55, 0x0D5 - 0x0B0), + /* 0x0B0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 55, 12, 0, 0x0CF - 0x0B6), + /* 0x0B6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 0, 12, 15, 0x0C9 - 0x0BC), + /* 0x0BC */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 15, 12, 20, 0x0C3 - 0x0C2), + /* 0x0C2 */ SCHEDULE_CMD_RET_NONE(), + /* 0x0C3 */ SCHEDULE_CMD_RET_TIME(12, 15, 12, 20, 17), + /* 0x0C9 */ SCHEDULE_CMD_RET_TIME(12, 0, 12, 15, 29), + /* 0x0CF */ SCHEDULE_CMD_RET_TIME(11, 55, 12, 0, 19), + /* 0x0D5 */ SCHEDULE_CMD_RET_TIME(11, 45, 11, 55, 28), + /* 0x0DB */ SCHEDULE_CMD_RET_TIME(10, 55, 11, 45, 2), + /* 0x0E1 */ SCHEDULE_CMD_RET_TIME(10, 45, 10, 55, 27), + /* 0x0E7 */ SCHEDULE_CMD_RET_TIME(10, 40, 10, 45, 18), + /* 0x0ED */ SCHEDULE_CMD_RET_TIME(10, 30, 10, 40, 26), + /* 0x0F3 */ SCHEDULE_CMD_RET_TIME(10, 10, 10, 30, 1), + /* 0x0F9 */ SCHEDULE_CMD_RET_TIME(10, 5, 10, 10, 25), + /* 0x0FF */ SCHEDULE_CMD_RET_TIME(10, 0, 10, 5, 16), + /* 0x105 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x13A - 0x109), + /* 0x109 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 55, 13, 0, 0x134 - 0x10F), + /* 0x10F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 0, 13, 25, 0x12E - 0x115), + /* 0x115 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 25, 21, 5, 0x128 - 0x11B), + /* 0x11B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 55, 5, 5, 0x122 - 0x121), + /* 0x121 */ SCHEDULE_CMD_RET_NONE(), + /* 0x122 */ SCHEDULE_CMD_RET_TIME(21, 55, 5, 5, 5), + /* 0x128 */ SCHEDULE_CMD_RET_TIME(13, 25, 21, 5, 3), + /* 0x12E */ SCHEDULE_CMD_RET_TIME(13, 0, 13, 25, 30), + /* 0x134 */ SCHEDULE_CMD_RET_TIME(12, 55, 13, 0, 20), + /* 0x13A */ SCHEDULE_CMD_RET_NONE(), + /* 0x13B */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(2, 0x1EB - 0x140), + /* 0x140 */ SCHEDULE_CMD_CHECK_FLAG_L(0x32, 0x01, 0x1CD - 0x145), + /* 0x145 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x17A - 0x149), + /* 0x149 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 18, 0, 0x174 - 0x14F), + /* 0x14F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 21, 0, 0x16E - 0x155), + /* 0x155 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 0, 21, 10, 0x168 - 0x15B), + /* 0x15B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 10, 21, 15, 0x162 - 0x161), + /* 0x161 */ SCHEDULE_CMD_RET_NONE(), + /* 0x162 */ SCHEDULE_CMD_RET_TIME(21, 10, 21, 15, 15), + /* 0x168 */ SCHEDULE_CMD_RET_TIME(21, 0, 21, 10, 24), + /* 0x16E */ SCHEDULE_CMD_RET_TIME(18, 0, 21, 0, 6), + /* 0x174 */ SCHEDULE_CMD_RET_TIME(6, 0, 18, 0, 7), + /* 0x17A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x1A3 - 0x17E), + /* 0x17E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 10, 21, 15, 0x19D - 0x184), + /* 0x184 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 15, 21, 25, 0x197 - 0x18A), + /* 0x18A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 25, 21, 30, 0x191 - 0x190), + /* 0x190 */ SCHEDULE_CMD_RET_NONE(), + /* 0x191 */ SCHEDULE_CMD_RET_TIME(21, 25, 21, 30, 14), + /* 0x197 */ SCHEDULE_CMD_RET_TIME(21, 15, 21, 25, 23), + /* 0x19D */ SCHEDULE_CMD_RET_TIME(21, 10, 21, 15, 13), + /* 0x1A3 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x1CC - 0x1A7), + /* 0x1A7 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 30, 21, 45, 0x1C6 - 0x1AD), + /* 0x1AD */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 45, 22, 10, 0x1C0 - 0x1B3), + /* 0x1B3 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(22, 10, 6, 0, 0x1BA - 0x1B9), + /* 0x1B9 */ SCHEDULE_CMD_RET_NONE(), + /* 0x1BA */ SCHEDULE_CMD_RET_TIME(22, 10, 6, 0, 5), + /* 0x1C0 */ SCHEDULE_CMD_RET_TIME(21, 45, 22, 10, 30), + /* 0x1C6 */ SCHEDULE_CMD_RET_TIME(21, 30, 21, 45, 20), + /* 0x1CC */ SCHEDULE_CMD_RET_NONE(), + /* 0x1CD */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x1EA - 0x1D1), + /* 0x1D1 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 18, 0, 0x1E4 - 0x1D7), + /* 0x1D7 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x1DE - 0x1DD), + /* 0x1DD */ SCHEDULE_CMD_RET_NONE(), + /* 0x1DE */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 0, 8), + /* 0x1E4 */ SCHEDULE_CMD_RET_TIME(6, 0, 18, 0, 7), + /* 0x1EA */ SCHEDULE_CMD_RET_NONE(), + /* 0x1EB */ SCHEDULE_CMD_RET_NONE(), }; static s32 D_80951A0C[] = { @@ -889,7 +970,7 @@ s32 func_8094F53C(EnGm* this, GlobalContext* globalCtx) { return false; } -s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2, u8 arg3, s16 arg4) { +s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 arg3, s16 arg4) { u8 sp4F = ENGM_GET_FF(&this->actor); Vec3s* sp48; Vec3f sp3C; @@ -901,8 +982,8 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; actor = func_8094DEE0(this, globalCtx, arg3, arg4); - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->unk0]); + if (D_80951A0C[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); } if ((actor != NULL) && (actor->update != NULL)) { @@ -919,8 +1000,8 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp56 = gSaveContext.save.time - 0x3FFC; +s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = ENGM_GET_FF(&this->actor); EnDoor* door; Vec3s* sp4C; @@ -930,10 +1011,10 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; this->unk_234 = NULL; - door = func_8094DF90(globalCtx, arg2->unk0); + door = func_8094DF90(globalCtx, arg2->result); - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80951A0C[arg2->unk0]); + if (D_80951A0C[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80951A0C[arg2->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { @@ -952,8 +1033,8 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_261 = 75; } - this->unk_3B8 = arg2->unk8 - arg2->unk4; - this->unk_3BA = sp56 - arg2->unk4; + this->unk_3B8 = arg2->time1 - arg2->time0; + this->unk_3BA = sp56 - arg2->time0; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; @@ -965,16 +1046,16 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp2E = gSaveContext.save.time - 0x3FFC; +s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = ENGM_GET_FF(&this->actor); s32 pad; s32 ret = false; this->unk_234 = NULL; - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80951A0C[arg2->unk0]); + if (D_80951A0C[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80951A0C[arg2->result]); } if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { @@ -985,13 +1066,13 @@ s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if ((this->unk_258 < 9) && (this->unk_258 != 0) && (this->unk_3C4 >= 0)) { phi_v1 = sp2E; } else { - phi_v1 = arg2->unk4; + phi_v1 = arg2->time0; } - if (arg2->unk8 < phi_v1) { - this->unk_248 = (phi_v1 - arg2->unk8) + 0xFFFF; + if (arg2->time1 < phi_v1) { + this->unk_248 = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_248 = arg2->unk8 - phi_v1; + this->unk_248 = arg2->time1 - phi_v1; } this->unk_254 = sp2E - phi_v1; @@ -1010,7 +1091,7 @@ s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FCC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_8094FCC4(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951D90 = { 64.0f, 0.0f, -122.0f }; s32 ret = false; @@ -1030,7 +1111,7 @@ s32 func_8094FCC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FD88(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_8094FD88(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_8094F7D0(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_RECEPGIRL)) { @@ -1043,7 +1124,7 @@ s32 func_8094FD88(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; Actor* al; @@ -1064,7 +1145,7 @@ s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951D9C = { 64.0f, 0.0f, -122.0f }; u8 sp4F = ENGM_GET_FF(&this->actor); Vec3s* sp48; @@ -1075,8 +1156,8 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->unk0]); + if (D_80951A0C[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); } if (this->unk_234 != NULL) { @@ -1106,7 +1187,7 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80950088(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80950088(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951DA8 = { 278.0f, 0.0f, 223.0f }; static Vec3s D_80951DB4 = { 0x0000, 0xC000, 0x0000 }; s32 pad; @@ -1121,7 +1202,7 @@ s32 func_80950088(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80950120(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80950120(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951DBC = { -525.0f, 214.0f, 515.0f }; static Vec3s D_80951DC8 = { 0x0000, 0x38E0, 0x0000 }; s32 pad; @@ -1136,7 +1217,7 @@ s32 func_80950120(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951DD0 = { -334.0f, 225.0f, 903.0f }; static Vec3s D_80951DDC = { 0x0000, 0x7FFF, 0x0000 }; s32 pad; @@ -1157,7 +1238,7 @@ s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80950280(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80950280(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 phi_v1; this->actor.flags |= ACTOR_FLAG_1; @@ -1168,7 +1249,7 @@ s32 func_80950280(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_3CC = 8; this->unk_3B4 = 40.0f; - switch (arg2->unk0) { + switch (arg2->result) { case 1: phi_v1 = func_8094FD88(this, globalCtx, arg2); break; @@ -1493,21 +1574,20 @@ void func_80950C24(EnGm* this, GlobalContext* globalCtx) { } void func_80950CDC(EnGm* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp20; + ScheduleResult sp20; - this->unk_3C4 = REG(15) + *unk_14; + this->unk_3C4 = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!func_80133038(globalCtx, (void*)&D_80951820, &sp20) || - ((this->unk_258 != sp20.unk0) && !func_80950280(this, globalCtx, &sp20))) { + if (!Schedule_RunScript(globalCtx, D_80951820, &sp20) || + ((this->unk_258 != sp20.result) && !func_80950280(this, globalCtx, &sp20))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp20.unk0 = 0; + sp20.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_258 = sp20.unk0; + this->unk_258 = sp20.result; this->unk_268 = func_8094F074(this, globalCtx); func_80950C24(this, globalCtx); } 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 ed747c640..bbb706326 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -20,13 +20,44 @@ void EnIg_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BF2AF8(EnIg* this, GlobalContext* globalCtx); void func_80BF2BD4(EnIg* this, GlobalContext* globalCtx); -static s32 D_80BF3260[] = { - 0x0D000100, 0xB10A006C, 0x4E020F19, 0x0F2D4202, 0x0F2D0F32, 0x36004B10, 0x1050210, 0x32103725, - 0x02103711, 0x0F190211, 0x0F12000D, 0x02120006, 0x0001050E, 0x12000600, 0x040E110F, 0x0600020E, - 0x1037110F, 0x0B0E1032, 0x1037060E, 0x0F2D0F32, 0x050E0F19, 0x0F2D0A0A, 0x00615A02, 0x0F2D0F32, - 0x4E020F32, 0x100A4202, 0x100A101E, 0x36004B10, 0x1902101E, 0x10320D02, 0x10321037, 0x01050E10, - 0x32103708, 0x0E101E10, 0x320D0210, 0x1E10320D, 0x02103210, 0x3701050E, 0x10321037, 0x090E101E, - 0x10320E0E, 0x100A101E, 0x030E0F32, 0x100A0C0E, 0x0F2D0F32, 0x07050500, +static u8 D_80BF3260[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(1, 0xB6 - 0x05), + /* 0x05 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x57 - 0x09), + /* 0x09 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 25, 15, 45, 0x51 - 0x0F), + /* 0x0F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 45, 15, 50, 0x4B - 0x15), + /* 0x15 */ SCHEDULE_CMD_CHECK_FLAG_S(0x4B, 0x10, 0x1A - 0x19), + /* 0x19 */ SCHEDULE_CMD_RET_NONE(), + /* 0x1A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 50, 16, 55, 0x45 - 0x20), + /* 0x20 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 55, 17, 15, 0x3F - 0x26), + /* 0x26 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(17, 15, 18, 0, 0x39 - 0x2C), + /* 0x2C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x33 - 0x32), + /* 0x32 */ SCHEDULE_CMD_RET_NONE(), + /* 0x33 */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 4), + /* 0x39 */ SCHEDULE_CMD_RET_TIME(17, 15, 6, 0, 2), + /* 0x3F */ SCHEDULE_CMD_RET_TIME(16, 55, 17, 15, 11), + /* 0x45 */ SCHEDULE_CMD_RET_TIME(16, 50, 16, 55, 6), + /* 0x4B */ SCHEDULE_CMD_RET_TIME(15, 45, 15, 50, 5), + /* 0x51 */ SCHEDULE_CMD_RET_TIME(15, 25, 15, 45, 10), + /* 0x57 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0xB5 - 0x5B), + /* 0x5B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 45, 15, 50, 0xAF - 0x61), + /* 0x61 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 50, 16, 10, 0xA9 - 0x67), + /* 0x67 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 10, 16, 30, 0xA3 - 0x6D), + /* 0x6D */ SCHEDULE_CMD_CHECK_FLAG_S(0x4B, 0x10, 0x8A - 0x71), + /* 0x71 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 30, 16, 50, 0x84 - 0x77), + /* 0x77 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 50, 16, 55, 0x7E - 0x7D), + /* 0x7D */ SCHEDULE_CMD_RET_NONE(), + /* 0x7E */ SCHEDULE_CMD_RET_TIME(16, 50, 16, 55, 8), + /* 0x84 */ SCHEDULE_CMD_RET_TIME(16, 30, 16, 50, 13), + /* 0x8A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 30, 16, 50, 0x9D - 0x90), + /* 0x90 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 50, 16, 55, 0x97 - 0x96), + /* 0x96 */ SCHEDULE_CMD_RET_NONE(), + /* 0x97 */ SCHEDULE_CMD_RET_TIME(16, 50, 16, 55, 9), + /* 0x9D */ SCHEDULE_CMD_RET_TIME(16, 30, 16, 50, 14), + /* 0xA3 */ SCHEDULE_CMD_RET_TIME(16, 10, 16, 30, 3), + /* 0xA9 */ SCHEDULE_CMD_RET_TIME(15, 50, 16, 10, 12), + /* 0xAF */ SCHEDULE_CMD_RET_TIME(15, 45, 15, 50, 7), + /* 0xB5 */ SCHEDULE_CMD_RET_NONE(), + /* 0xB6 */ SCHEDULE_CMD_RET_NONE(), }; static s32 D_80BF3318[] = { -1, -1, 3, 1, 3, 1, 2, 0, 3, 5, 0, 3, 1, 2, 4 }; @@ -233,7 +264,7 @@ void func_80BF13E4(EnIg* this) { Actor* func_80BF146C(EnIg* this, GlobalContext* globalCtx) { Actor* retActor; - if (this->unk_298.unk0 == 3) { + if (this->scheduleResult == 3) { retActor = func_80BF1150(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AN); } else { retActor = &GET_PLAYER(globalCtx)->actor; @@ -361,7 +392,7 @@ s32 func_80BF17BC(EnIg* this, GlobalContext* globalCtx) { } s32* func_80BF1920(EnIg* this, GlobalContext* globalCtx) { - switch (this->unk_298.unk0) { + switch (this->scheduleResult) { case 3: this->unk_3F8 = func_80BF17BC; return D_80BF335C; @@ -395,8 +426,8 @@ s32 func_80BF19A0(EnIg* this, GlobalContext* globalCtx) { this->unk_3F6 = 0; this->unk_3F8 = NULL; this->actor.child = this->unk_2A8; - this->unk_298.unk4 = func_80BF1920(this, globalCtx); - if ((this->unk_298.unk0 != 2) && (this->unk_298.unk0 != 3) && (this->unk_298.unk0 != 4)) { + this->unk_29C = func_80BF1920(this, globalCtx); + if ((this->scheduleResult != 2) && (this->scheduleResult != 3) && (this->scheduleResult != 4)) { this->unk_3D0 |= 0x20; } this->actionFunc = func_80BF2BD4; @@ -417,7 +448,7 @@ void func_80BF1A60(EnIg* this, GlobalContext* globalCtx) { } s32 func_80BF1AE0(EnIg* this, GlobalContext* globalCtx) { - switch (this->unk_298.unk0) { + switch (this->scheduleResult) { case 3: func_80BF1284(this, 0); break; @@ -465,7 +496,7 @@ s32 func_80BF1B40(EnIg* this, GlobalContext* globalCtx) { return false; } -s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2, s32 arg3, s32 arg4) { +s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2, s32 arg3, s32 arg4) { u8 sp4F = ENIG_GET_FF(&this->actor); Vec3s* sp48; Vec3f sp3C; @@ -477,8 +508,8 @@ s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar sp2C = func_80BF1150(this, globalCtx, arg3, arg4); this->unk_274 = NULL; - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->unk0]); + if (D_80BF3318[arg2->result] >= 0) { + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { @@ -495,7 +526,7 @@ s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return sp24; } -s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 sp2C = 0; if (func_80BF1C44(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AN)) { @@ -508,8 +539,8 @@ s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return sp2C; } -s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp56 = gSaveContext.save.time - 0x3FFC; +s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = ENIG_GET_FF(&this->actor); EnDoor* door; Vec3s* sp4C; @@ -519,10 +550,10 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; this->unk_274 = NULL; - door = func_80BF1200(globalCtx, arg2->unk0); + door = func_80BF1200(globalCtx, arg2->result); - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp55, D_80BF3318[arg2->unk0]); + if (D_80BF3318[arg2->result] >= 0) { + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp55, D_80BF3318[arg2->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { @@ -541,8 +572,8 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_2A4 = 75; } - this->unk_3E0 = arg2->unk8 - arg2->unk4; - this->unk_3E2 = sp56 - arg2->unk4; + this->unk_3E0 = arg2->time1 - arg2->time0; + this->unk_3E2 = sp56 - arg2->time0; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3D0 |= 0x100; func_80BF1284(this, 3); @@ -553,8 +584,8 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp2E = gSaveContext.save.time - 0x3FFC; +s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = ENIG_GET_FF(&this->actor); s32 temp_t8; @@ -562,8 +593,8 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_274 = NULL; - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80BF3318[arg2->unk0]); + if (D_80BF3318[arg2->result] >= 0) { + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80BF3318[arg2->result]); } if ((this->unk_274 != NULL) && (this->unk_274->count < 3)) { @@ -571,17 +602,17 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } if (this->unk_274 != NULL) { - temp_t8 = this->unk_298.unk0; + temp_t8 = this->scheduleResult; if ((temp_t8 < 10) && (temp_t8 != 0) && (this->unk_3EC >= 0)) { phi_v1 = sp2E; } else { - phi_v1 = arg2->unk4; + phi_v1 = arg2->time0; } - if (arg2->unk8 < phi_v1) { - this->unk_288 = (phi_v1 - arg2->unk8) + 0xFFFF; + if (arg2->time1 < phi_v1) { + this->unk_288 = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_288 = arg2->unk8 - phi_v1; + this->unk_288 = arg2->time1 - phi_v1; } this->unk_294 = sp2E - phi_v1; @@ -602,7 +633,7 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u8 sp4F = ENIG_GET_FF(&this->actor); Vec3f sp40; Vec3f sp34; @@ -612,8 +643,8 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_274 = NULL; - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->unk0]); + if (D_80BF3318[arg2->result] >= 0) { + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); } if ((this->unk_274 != 0) && (this->unk_274->count >= 2)) { @@ -625,7 +656,7 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->actor.world.pos, &sp40); Math_Vec3f_Copy(&this->actor.prevPos, &sp40); - switch (arg2->unk0) { + switch (arg2->result) { case 2: this->actor.home.rot.y = this->actor.world.rot.y; this->actor.home.rot.y += 0x8000; @@ -647,14 +678,14 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BF2368(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BF2368(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; this->actor.targetMode = 0; this->unk_3D0 = 0; this->actor.flags |= ACTOR_FLAG_1; - switch (arg2->unk0) { + switch (arg2->result) { case 5: case 6: case 7: @@ -697,7 +728,7 @@ s32 func_80BF2400(EnIg* this, GlobalContext* globalCtx) { } s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { - EnDoor* door = func_80BF1200(globalCtx, this->unk_298.unk0); + EnDoor* door = func_80BF1200(globalCtx, this->scheduleResult); Vec3f sp38; f32 temp; s32 pad; @@ -807,7 +838,7 @@ s32 func_80BF293C(EnIg* this, GlobalContext* globalCtx) { } void func_80BF2A50(EnIg* this, GlobalContext* globalCtx) { - switch (this->unk_298.unk0) { + switch (this->scheduleResult) { case 10: case 11: case 12: @@ -840,22 +871,21 @@ void func_80BF2A50(EnIg* this, GlobalContext* globalCtx) { } void func_80BF2AF8(EnIg* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp20; + ScheduleResult sp20; - this->unk_3EC = REG(15) + *unk_14; + this->unk_3EC = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!func_80133038(globalCtx, D_80BF3260, &sp20) || - ((this->unk_298.unk0 != sp20.unk0) && !func_80BF2368(this, globalCtx, &sp20))) { + if (!Schedule_RunScript(globalCtx, D_80BF3260, &sp20) || + ((this->scheduleResult != sp20.result) && !func_80BF2368(this, globalCtx, &sp20))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp20.unk0 = 0; + sp20.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } this->unk_2A8 = func_80BF146C(this, globalCtx); - this->unk_298.unk0 = sp20.unk0; + this->scheduleResult = sp20.result; func_80BF2A50(this, globalCtx); } @@ -864,14 +894,14 @@ void func_80BF2BD4(EnIg* this, GlobalContext* globalCtx) { Vec3f sp38; Vec3f sp2C; - if (func_8010BF58(&this->actor, globalCtx, this->unk_298.unk4, this->unk_3F8, &this->unk_298.unk8)) { + if (func_8010BF58(&this->actor, globalCtx, this->unk_29C, this->unk_3F8, &this->unk_2A0)) { SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 &= ~0x20; this->unk_3D0 |= 0x200; this->unk_3EE = 20; - this->unk_298.unk8 = 0; + this->unk_2A0 = 0; this->actionFunc = func_80BF2AF8; - } else if (((this->unk_298.unk0 != 2) && (this->unk_298.unk0 != 4)) && + } else if (((this->scheduleResult != 2) && (this->scheduleResult != 4)) && ((this->unk_2A8 != NULL) && (this->unk_2A8->update != NULL))) { Math_Vec3f_Copy(&sp38, &this->unk_2A8->world.pos); Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); @@ -892,7 +922,7 @@ void EnIg_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitAndSetSphere(globalCtx, &this->collider2, &this->actor, &sSphereInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); Actor_SetScale(&this->actor, 0.01f); - this->unk_298.unk0 = 0; + this->scheduleResult = 0; this->actor.gravity = 0.0f; this->actionFunc = func_80BF2AF8; this->actionFunc(this, globalCtx); @@ -914,7 +944,7 @@ void EnIg_Update(Actor* thisx, GlobalContext* globalCtx) { func_80BF1B40(this, globalCtx); - if (this->unk_298.unk0 != 0) { + if (this->scheduleResult != 0) { func_80BF1258(this); func_80BF13E4(this); func_80BF15EC(this); @@ -1003,7 +1033,7 @@ void EnIg_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnIg* this = THIS; - if (this->unk_298.unk0 != 0) { + if (this->scheduleResult != 0) { func_8012C28C(globalCtx->state.gfxCtx); OPEN_DISPS(globalCtx->state.gfxCtx); 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 200c751b1..21abb08ac 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.h +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.h @@ -26,7 +26,9 @@ typedef struct EnIg { /* 0x028C */ s32 unk_28C; /* 0x0290 */ s32 unk_290; /* 0x0294 */ s32 unk_294; - /* 0x0298 */ struct_80133038_arg2 unk_298; + /* 0x0298 */ u8 scheduleResult; + /* 0x029C */ s32* unk_29C; + /* 0x02A0 */ s32 unk_2A0; /* 0x02A4 */ s8 unk_2A4; /* 0x02A8 */ Actor* unk_2A8; /* 0x02AC */ UNK_TYPE1 unk2AC[0x4]; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index c80b9432c..80a5c7651 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -3,6 +3,8 @@ * Overlay: ovl_En_Invadepoh * Description: Ranch nighttime actors */ + +#include "prevent_bss_reordering.h" #include "z_en_invadepoh.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/gameplay_keep/gameplay_keep.h" 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 5c57c883f..b02b6f4ee 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -22,8 +22,16 @@ void func_80BC2EA4(EnJa* this); void func_80BC32D8(EnJa* this, GlobalContext* globalCtx); void func_80BC3594(EnJa* this, GlobalContext* globalCtx); -s32 D_80BC35F0[] = { - 0x0C000301, 0x05020600, 0x1200080A, 0x00610304, 0x0002050A, 0x006C0304, 0x00010500, +static u8 D_80BC35F0[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x05 - 0x04), + /* 0x04 */ SCHEDULE_CMD_RET_NONE(), + /* 0x05 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 18, 0, 0x13 - 0x0B), + /* 0x0B */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x12 - 0x0F), + /* 0x0F */ SCHEDULE_CMD_RET_VAL_L(2), + /* 0x12 */ SCHEDULE_CMD_RET_NONE(), + /* 0x13 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x1A - 0x17), + /* 0x17 */ SCHEDULE_CMD_RET_VAL_L(1), + /* 0x1A */ SCHEDULE_CMD_RET_NONE(), }; s32 D_80BC360C[] = { @@ -231,7 +239,7 @@ void func_80BC1E40(EnJa* this, GlobalContext* globalCtx) { this->unk_374 = sp20; } -s32 func_80BC1FC8(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BC1FC8(EnJa* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80BC1AE0(this, globalCtx)) { @@ -244,7 +252,7 @@ s32 func_80BC1FC8(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BC203C(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BC203C(EnJa* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80BC1AE0(this, globalCtx)) { @@ -261,12 +269,12 @@ s32 func_80BC203C(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BC20D0(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BC20D0(EnJa* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; this->unk_340 = 0; - switch (arg2->unk0) { + switch (arg2->result) { case 1: ret = func_80BC1FC8(this, globalCtx, arg2); if (ret == 1) {} @@ -291,20 +299,19 @@ void func_80BC2150(EnJa* this, GlobalContext* globalCtx) { } void func_80BC21A8(EnJa* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp18; + ScheduleResult sp18; - this->unk_35C = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BC35F0, &sp18) || - ((this->unk_1D8.unk_00 != sp18.unk0) && !func_80BC20D0(this, globalCtx, &sp18))) { + this->unk_35C = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BC35F0, &sp18) || + ((this->unk_1D8.unk_00 != sp18.result) && !func_80BC20D0(this, globalCtx, &sp18))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp18.unk0 = 0; + sp18.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_1D8.unk_00 = sp18.unk0; + this->unk_1D8.unk_00 = sp18.result; func_80BC2150(this, globalCtx); } 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 02bd93aef..4c9f10ff8 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -4,6 +4,7 @@ * Description: Grass / Bush */ +#include "prevent_bss_reordering.h" #include "z_en_kusa.h" #include "objects/object_kusa/object_kusa.h" #include "objects/gameplay_keep/gameplay_keep.h" diff --git a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c index 1b8d1ccbc..e4e821427 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -4,6 +4,7 @@ * Description: Keaton grass */ +#include "prevent_bss_reordering.h" #include "z_en_kusa2.h" #include "objects/gameplay_field_keep/gameplay_field_keep.h" #include "objects/gameplay_keep/gameplay_keep.h" diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 21f9487ad..4d5961732 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -20,69 +20,365 @@ void EnPm_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx); void func_80AFA5FC(EnPm* this, GlobalContext* globalCtx); -// Game scripts -static UNK_TYPE D_80AFAD80[] = { - 0x0D000102, 0x3B030900, 0x0C00010B, 0x030C000D, 0x0100F902, 0x0D010F00, 0x12020F00, 0x00050105, 0x0A002E06, - 0x0E0F0000, 0x0508050A, 0x006D3102, 0x0D010D04, 0x25020D04, 0x0D151902, 0x0E300E38, 0x0D020E38, 0x0F000105, - 0x0E0E380F, 0x00020E0E, 0x300E383E, 0x0E0D040D, 0x15350E0D, 0x010D0401, 0x0A006F31, 0x020D040D, 0x1525020D, - 0x150D2719, 0x020E260E, 0x300D020E, 0x300E3801, 0x050E0E30, 0x0E383D0E, 0x0E260E30, 0x3C0E0D15, 0x0D27370E, - 0x0D040D15, 0x360A006C, 0x31020D27, 0x0D382502, 0x0D380E00, 0x19020E1A, 0x0E1E0D02, 0x0E1E0E26, 0x01050E0E, - 0x1E0E263B, 0x0E0E1A0E, 0x1E0B0E0D, 0x380E000A, 0x0E0D270D, 0x38380A00, 0x613D020D, 0x380E0031, 0x020E000E, - 0x0825020E, 0x080E1219, 0x020E120E, 0x1A0D020E, 0x1A0E1E01, 0x050E0E1A, 0x0E1E0D0E, 0x0E120E1A, 0x3A0E0E08, - 0x0E12100E, 0x0E000E08, 0x390E0D38, 0x0E000C05, 0x0A002E06, 0x0E0C000D, 0x0109050A, 0x006D3102, 0x09000903, - 0x25020903, 0x09111902, 0x0B2B0B39, 0x0D020B39, 0x0C000105, 0x0E0B390C, 0x00020E0B, 0x2B0B3934, 0x0E090309, - 0x11260E09, 0x00090301, 0x0A006F61, 0x02090309, 0x11550209, 0x11091F49, 0x02091F09, 0x233D0209, 0x23093131, - 0x020A390B, 0x0B25020B, 0x0B0B1919, 0x020B190B, 0x1D0D020B, 0x1D0B2B01, 0x050E0B1D, 0x0B2B320E, 0x0B190B1D, - 0x070E0B0B, 0x0B19300E, 0x0A390B0B, 0x2F0E0923, 0x0931290E, 0x091F0923, 0x030E0911, 0x091F280E, 0x09030911, - 0x270A006E, 0x25020931, 0x0A031902, 0x0A030A07, 0x0D020A07, 0x0A150105, 0x0E0A070A, 0x152B0E0A, 0x030A0704, - 0x0E09310A, 0x032A0A00, 0x6C61020A, 0x150A2355, 0x020A230A, 0x2749020A, 0x270A353D, 0x020A350A, 0x3931020A, - 0x390B0B25, 0x020B0B0B, 0x1919020B, 0x190B1D0D, 0x020B1D0B, 0x2B01050E, 0x0B1D0B2B, 0x330E0B19, 0x0B1D070E, - 0x0B0B0B19, 0x310E0A39, 0x0B0B2E0E, 0x0A350A39, 0x060E0A27, 0x0A352D0E, 0x0A230A27, 0x050E0A15, 0x0A232C05, - 0x0D000201, 0xCF011C08, 0x00A50309, 0x000C00FE, 0xC6030C00, 0x0D01008C, 0x020D010F, 0x007E0200, 0x00020001, - 0x050A006D, 0x31020000, 0x00042502, 0x0004001F, 0x1902011D, 0x01380D02, 0x01380200, 0x01050E01, 0x38020002, - 0x0E011D01, 0x384F0E00, 0x04001F4A, 0x0E000000, 0x04010A00, 0x6F3D0200, 0x04001F31, 0x02001F00, 0x3A250200, - 0x3A010219, 0x02010201, 0x1D0D0201, 0x1D013801, 0x050E011D, 0x01384E0E, 0x0102011D, 0x4D0E003A, 0x0102120E, - 0x001F003A, 0x4C0E0004, 0x001F4B05, 0x0A002E03, 0x04000E05, 0x0A002E06, 0x0E0C000D, 0x01140503, 0x09000C00, - 0xFE21030C, 0x000D0101, 0x0C020D01, 0x11001202, 0x11000005, 0x01050A00, 0x2E060E11, 0x00000508, 0x050A006D, - 0x31020D01, 0x0D042502, 0x0D040D0F, 0x19021023, 0x10390D02, 0x10391100, 0x01050E10, 0x39110002, 0x0E102310, - 0x39490E0D, 0x040D0F3F, 0x0E0D010D, 0x04010A00, 0x6F31020D, 0x040D0F25, 0x020D0F0D, 0x1E19020D, 0x340E2D0D, - 0x02100F10, 0x2301050E, 0x100F1023, 0x480E0D34, 0x0E2D430E, 0x0D0F0D1E, 0x410E0D04, 0x0D0F400A, 0x006C1902, - 0x0D1E0D34, 0x0D020D34, 0x0E320105, 0x0E0D340E, 0x32440E0D, 0x1E0D3442, 0x0A007068, 0x020E2D0F, 0x055C0C00, - 0x0231020F, 0x050F1425, 0x020F140F, 0x1919020F, 0x190F280D, 0x020F2810, 0x0F01050E, 0x0F28100F, 0x510E0F19, - 0x0F28110E, 0x0F140F19, 0x500E0F05, 0x0F141702, 0x0F050F14, 0x1B020F14, 0x0F320F02, 0x0F32100F, 0x03040000, - 0x0E0F3210, 0x0F470E0F, 0x140F3219, 0x0E0F050F, 0x14170E0E, 0x2D0F0546, 0x050A002E, 0x060E0C00, 0x0D011505, - 0x0D000301, 0x6F011C08, 0x013F011C, 0x10010C03, 0x09000C00, 0xFCED030C, 0x000D0100, 0xF6020D01, 0x0F000F02, - 0x12000600, 0x01050A00, 0x2E030400, 0x18050A00, 0x6D31020D, 0x000D0125, 0x020D050D, 0x0F19020E, 0x2D0E370D, - 0x020E370F, 0x0001050E, 0x0E370F00, 0x020E0E2D, 0x0E37340E, 0x0D050D0F, 0x260E0D00, 0x0D01010A, 0x006F4902, - 0x0D050D0F, 0x3D020D0F, 0x0D193102, 0x0D190D23, 0x25020E0F, 0x0E191902, 0x0E190E23, 0x0D020E23, 0x0E2D0105, - 0x0E0E230E, 0x2D320E0E, 0x190E2330, 0x0E0E0F0E, 0x192F0E0D, 0x190D2329, 0x0E0D0F0D, 0x19280E0D, 0x050D0F27, - 0x0A006E19, 0x020D230D, 0x2D0D020D, 0x2D0D3701, 0x050E0D2D, 0x0D372B0E, 0x0D230D2D, 0x2A0A006C, 0x3D020D37, - 0x0E053102, 0x0E050E0F, 0x25020E0F, 0x0E191902, 0x0E190E23, 0x0D020E23, 0x0E2D0105, 0x0E0E230E, 0x2D330E0E, - 0x190E2331, 0x0E0E0F0E, 0x192E0E0E, 0x050E0F2D, 0x0E0D370E, 0x052C050A, 0x002E0304, 0x00160503, 0x09000C00, - 0xFBE1020C, 0x000D0116, 0x030D0111, 0x00FDD202, 0x12000600, 0x01050A00, 0x2E030400, 0x18050A00, 0x2E060E0C, - 0x000D0115, 0x05030900, 0x0C00FBB3, 0x020C000D, 0x0116030D, 0x010F00FE, 0xD5021200, 0x06000105, 0x0A002E03, - 0x04001805, 0x0A002E03, 0x04001405, 0x05000000, +static u8 D_80AFAD80[] = { + /* 0x000 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(1, 0x240 - 0x005), + /* 0x005 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x00C), + /* 0x00C */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(12, 0, 13, 1, 0x10C - 0x013), + /* 0x013 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 15, 0, 0x02B - 0x019), + /* 0x019 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 0, 0, 5, 0x020 - 0x01F), + /* 0x01F */ SCHEDULE_CMD_RET_NONE(), + /* 0x020 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x02A - 0x024), + /* 0x024 */ SCHEDULE_CMD_RET_TIME(15, 0, 0, 5, 8), + /* 0x02A */ SCHEDULE_CMD_RET_NONE(), + /* 0x02B */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x060 - 0x02F), + /* 0x02F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 13, 4, 0x05A - 0x035), + /* 0x035 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 4, 13, 21, 0x054 - 0x03B), + /* 0x03B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 48, 14, 56, 0x04E - 0x041), + /* 0x041 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 56, 15, 0, 0x048 - 0x047), + /* 0x047 */ SCHEDULE_CMD_RET_NONE(), + /* 0x048 */ SCHEDULE_CMD_RET_TIME(14, 56, 15, 0, 2), + /* 0x04E */ SCHEDULE_CMD_RET_TIME(14, 48, 14, 56, 62), + /* 0x054 */ SCHEDULE_CMD_RET_TIME(13, 4, 13, 21, 53), + /* 0x05A */ SCHEDULE_CMD_RET_TIME(13, 1, 13, 4, 1), + /* 0x060 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x095 - 0x064), + /* 0x064 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 4, 13, 21, 0x08F - 0x06A), + /* 0x06A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 21, 13, 39, 0x089 - 0x070), + /* 0x070 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 38, 14, 48, 0x083 - 0x076), + /* 0x076 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 48, 14, 56, 0x07D - 0x07C), + /* 0x07C */ SCHEDULE_CMD_RET_NONE(), + /* 0x07D */ SCHEDULE_CMD_RET_TIME(14, 48, 14, 56, 61), + /* 0x083 */ SCHEDULE_CMD_RET_TIME(14, 38, 14, 48, 60), + /* 0x089 */ SCHEDULE_CMD_RET_TIME(13, 21, 13, 39, 55), + /* 0x08F */ SCHEDULE_CMD_RET_TIME(13, 4, 13, 21, 54), + /* 0x095 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x0CA - 0x099), + /* 0x099 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 39, 13, 56, 0x0C4 - 0x09F), + /* 0x09F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 56, 14, 0, 0x0BE - 0x0A5), + /* 0x0A5 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 26, 14, 30, 0x0B8 - 0x0AB), + /* 0x0AB */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 30, 14, 38, 0x0B2 - 0x0B1), + /* 0x0B1 */ SCHEDULE_CMD_RET_NONE(), + /* 0x0B2 */ SCHEDULE_CMD_RET_TIME(14, 30, 14, 38, 59), + /* 0x0B8 */ SCHEDULE_CMD_RET_TIME(14, 26, 14, 30, 11), + /* 0x0BE */ SCHEDULE_CMD_RET_TIME(13, 56, 14, 0, 10), + /* 0x0C4 */ SCHEDULE_CMD_RET_TIME(13, 39, 13, 56, 56), + /* 0x0CA */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x10B - 0x0CE), + /* 0x0CE */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 56, 14, 0, 0x105 - 0x0D4), + /* 0x0D4 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 0, 14, 8, 0x0FF - 0x0DA), + /* 0x0DA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 8, 14, 18, 0x0F9 - 0x0E0), + /* 0x0E0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 18, 14, 26, 0x0F3 - 0x0E6), + /* 0x0E6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 26, 14, 30, 0x0ED - 0x0EC), + /* 0x0EC */ SCHEDULE_CMD_RET_NONE(), + /* 0x0ED */ SCHEDULE_CMD_RET_TIME(14, 26, 14, 30, 13), + /* 0x0F3 */ SCHEDULE_CMD_RET_TIME(14, 18, 14, 26, 58), + /* 0x0F9 */ SCHEDULE_CMD_RET_TIME(14, 8, 14, 18, 16), + /* 0x0FF */ SCHEDULE_CMD_RET_TIME(14, 0, 14, 8, 57), + /* 0x105 */ SCHEDULE_CMD_RET_TIME(13, 56, 14, 0, 12), + /* 0x10B */ SCHEDULE_CMD_RET_NONE(), + /* 0x10C */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x116 - 0x110), + /* 0x110 */ SCHEDULE_CMD_RET_TIME(12, 0, 13, 1, 9), + /* 0x116 */ SCHEDULE_CMD_RET_NONE(), + /* 0x117 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x14C - 0x11B), + /* 0x11B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 0, 9, 3, 0x146 - 0x121), + /* 0x121 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 3, 9, 17, 0x140 - 0x127), + /* 0x127 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 43, 11, 57, 0x13A - 0x12D), + /* 0x12D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 57, 12, 0, 0x134 - 0x133), + /* 0x133 */ SCHEDULE_CMD_RET_NONE(), + /* 0x134 */ SCHEDULE_CMD_RET_TIME(11, 57, 12, 0, 2), + /* 0x13A */ SCHEDULE_CMD_RET_TIME(11, 43, 11, 57, 52), + /* 0x140 */ SCHEDULE_CMD_RET_TIME(9, 3, 9, 17, 38), + /* 0x146 */ SCHEDULE_CMD_RET_TIME(9, 0, 9, 3, 1), + /* 0x14C */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x1B1 - 0x150), + /* 0x150 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 3, 9, 17, 0x1AB - 0x156), + /* 0x156 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 17, 9, 31, 0x1A5 - 0x15C), + /* 0x15C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 31, 9, 35, 0x19F - 0x162), + /* 0x162 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 35, 9, 49, 0x199 - 0x168), + /* 0x168 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 57, 11, 11, 0x193 - 0x16E), + /* 0x16E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 11, 11, 25, 0x18D - 0x174), + /* 0x174 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 25, 11, 29, 0x187 - 0x17A), + /* 0x17A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 29, 11, 43, 0x181 - 0x180), + /* 0x180 */ SCHEDULE_CMD_RET_NONE(), + /* 0x181 */ SCHEDULE_CMD_RET_TIME(11, 29, 11, 43, 50), + /* 0x187 */ SCHEDULE_CMD_RET_TIME(11, 25, 11, 29, 7), + /* 0x18D */ SCHEDULE_CMD_RET_TIME(11, 11, 11, 25, 48), + /* 0x193 */ SCHEDULE_CMD_RET_TIME(10, 57, 11, 11, 47), + /* 0x199 */ SCHEDULE_CMD_RET_TIME(9, 35, 9, 49, 41), + /* 0x19F */ SCHEDULE_CMD_RET_TIME(9, 31, 9, 35, 3), + /* 0x1A5 */ SCHEDULE_CMD_RET_TIME(9, 17, 9, 31, 40), + /* 0x1AB */ SCHEDULE_CMD_RET_TIME(9, 3, 9, 17, 39), + /* 0x1B1 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_BACKTOWN, 0x1DA - 0x1B5), + /* 0x1B5 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 49, 10, 3, 0x1D4 - 0x1BB), + /* 0x1BB */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 3, 10, 7, 0x1CE - 0x1C1), + /* 0x1C1 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 7, 10, 21, 0x1C8 - 0x1C7), + /* 0x1C7 */ SCHEDULE_CMD_RET_NONE(), + /* 0x1C8 */ SCHEDULE_CMD_RET_TIME(10, 7, 10, 21, 43), + /* 0x1CE */ SCHEDULE_CMD_RET_TIME(10, 3, 10, 7, 4), + /* 0x1D4 */ SCHEDULE_CMD_RET_TIME(9, 49, 10, 3, 42), + /* 0x1DA */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x23F - 0x1DE), + /* 0x1DE */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 21, 10, 35, 0x239 - 0x1E4), + /* 0x1E4 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 35, 10, 39, 0x233 - 0x1EA), + /* 0x1EA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 39, 10, 53, 0x22D - 0x1F0), + /* 0x1F0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 53, 10, 57, 0x227 - 0x1F6), + /* 0x1F6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 57, 11, 11, 0x221 - 0x1FC), + /* 0x1FC */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 11, 11, 25, 0x21B - 0x202), + /* 0x202 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 25, 11, 29, 0x215 - 0x208), + /* 0x208 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 29, 11, 43, 0x20F - 0x20E), + /* 0x20E */ SCHEDULE_CMD_RET_NONE(), + /* 0x20F */ SCHEDULE_CMD_RET_TIME(11, 29, 11, 43, 51), + /* 0x215 */ SCHEDULE_CMD_RET_TIME(11, 25, 11, 29, 7), + /* 0x21B */ SCHEDULE_CMD_RET_TIME(11, 11, 11, 25, 49), + /* 0x221 */ SCHEDULE_CMD_RET_TIME(10, 57, 11, 11, 46), + /* 0x227 */ SCHEDULE_CMD_RET_TIME(10, 53, 10, 57, 6), + /* 0x22D */ SCHEDULE_CMD_RET_TIME(10, 39, 10, 53, 45), + /* 0x233 */ SCHEDULE_CMD_RET_TIME(10, 35, 10, 39, 5), + /* 0x239 */ SCHEDULE_CMD_RET_TIME(10, 21, 10, 35, 44), + /* 0x23F */ SCHEDULE_CMD_RET_NONE(), + /* 0x240 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(2, 0x414 - 0x245), + /* 0x245 */ SCHEDULE_CMD_CHECK_FLAG_L(0x1C, 0x08, 0x2EF - 0x24A), + /* 0x24A */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x251), + /* 0x251 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(12, 0, 13, 1, 0x2E4 - 0x258), + /* 0x258 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 15, 0, 0x2DC - 0x25E), + /* 0x25E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 2, 0, 0x265 - 0x264), + /* 0x264 */ SCHEDULE_CMD_RET_NONE(), + /* 0x265 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x29A - 0x269), + /* 0x269 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 4, 0x294 - 0x26F), + /* 0x26F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 4, 0, 31, 0x28E - 0x275), + /* 0x275 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 29, 1, 56, 0x288 - 0x27B), + /* 0x27B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 56, 2, 0, 0x282 - 0x281), + /* 0x281 */ SCHEDULE_CMD_RET_NONE(), + /* 0x282 */ SCHEDULE_CMD_RET_TIME(1, 56, 2, 0, 2), + /* 0x288 */ SCHEDULE_CMD_RET_TIME(1, 29, 1, 56, 79), + /* 0x28E */ SCHEDULE_CMD_RET_TIME(0, 4, 0, 31, 74), + /* 0x294 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 4, 1), + /* 0x29A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x2DB - 0x29E), + /* 0x29E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 4, 0, 31, 0x2D5 - 0x2A4), + /* 0x2A4 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 31, 0, 58, 0x2CF - 0x2AA), + /* 0x2AA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 58, 1, 2, 0x2C9 - 0x2B0), + /* 0x2B0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 2, 1, 29, 0x2C3 - 0x2B6), + /* 0x2B6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 29, 1, 56, 0x2BD - 0x2BC), + /* 0x2BC */ SCHEDULE_CMD_RET_NONE(), + /* 0x2BD */ SCHEDULE_CMD_RET_TIME(1, 29, 1, 56, 78), + /* 0x2C3 */ SCHEDULE_CMD_RET_TIME(1, 2, 1, 29, 77), + /* 0x2C9 */ SCHEDULE_CMD_RET_TIME(0, 58, 1, 2, 18), + /* 0x2CF */ SCHEDULE_CMD_RET_TIME(0, 31, 0, 58, 76), + /* 0x2D5 */ SCHEDULE_CMD_RET_TIME(0, 4, 0, 31, 75), + /* 0x2DB */ SCHEDULE_CMD_RET_NONE(), + /* 0x2DC */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x2E3 - 0x2E0), + /* 0x2E0 */ SCHEDULE_CMD_RET_VAL_L(14), + /* 0x2E3 */ SCHEDULE_CMD_RET_NONE(), + /* 0x2E4 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x2EE - 0x2E8), + /* 0x2E8 */ SCHEDULE_CMD_RET_TIME(12, 0, 13, 1, 20), + /* 0x2EE */ SCHEDULE_CMD_RET_NONE(), + /* 0x2EF */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x2F6), + /* 0x2F6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(12, 0, 13, 1, 0x409 - 0x2FD), + /* 0x2FD */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 17, 0, 0x315 - 0x303), + /* 0x303 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(17, 0, 0, 5, 0x30A - 0x309), + /* 0x309 */ SCHEDULE_CMD_RET_NONE(), + /* 0x30A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x314 - 0x30E), + /* 0x30E */ SCHEDULE_CMD_RET_TIME(17, 0, 0, 5, 8), + /* 0x314 */ SCHEDULE_CMD_RET_NONE(), + /* 0x315 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x34A - 0x319), + /* 0x319 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 13, 4, 0x344 - 0x31F), + /* 0x31F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 4, 13, 15, 0x33E - 0x325), + /* 0x325 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 35, 16, 57, 0x338 - 0x32B), + /* 0x32B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 57, 17, 0, 0x332 - 0x331), + /* 0x331 */ SCHEDULE_CMD_RET_NONE(), + /* 0x332 */ SCHEDULE_CMD_RET_TIME(16, 57, 17, 0, 2), + /* 0x338 */ SCHEDULE_CMD_RET_TIME(16, 35, 16, 57, 73), + /* 0x33E */ SCHEDULE_CMD_RET_TIME(13, 4, 13, 15, 63), + /* 0x344 */ SCHEDULE_CMD_RET_TIME(13, 1, 13, 4, 1), + /* 0x34A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x37F - 0x34E), + /* 0x34E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 4, 13, 15, 0x379 - 0x354), + /* 0x354 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 15, 13, 30, 0x373 - 0x35A), + /* 0x35A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 52, 14, 45, 0x36D - 0x360), + /* 0x360 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 15, 16, 35, 0x367 - 0x366), + /* 0x366 */ SCHEDULE_CMD_RET_NONE(), + /* 0x367 */ SCHEDULE_CMD_RET_TIME(16, 15, 16, 35, 72), + /* 0x36D */ SCHEDULE_CMD_RET_TIME(13, 52, 14, 45, 67), + /* 0x373 */ SCHEDULE_CMD_RET_TIME(13, 15, 13, 30, 65), + /* 0x379 */ SCHEDULE_CMD_RET_TIME(13, 4, 13, 15, 64), + /* 0x37F */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x39C - 0x383), + /* 0x383 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 30, 13, 52, 0x396 - 0x389), + /* 0x389 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 52, 14, 50, 0x390 - 0x38F), + /* 0x38F */ SCHEDULE_CMD_RET_NONE(), + /* 0x390 */ SCHEDULE_CMD_RET_TIME(13, 52, 14, 50, 68), + /* 0x396 */ SCHEDULE_CMD_RET_TIME(13, 30, 13, 52, 66), + /* 0x39C */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ALLEY, 0x408 - 0x3A0), + /* 0x3A0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 45, 15, 5, 0x402 - 0x3A6), + /* 0x3A6 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x3DB - 0x3AA), + /* 0x3AA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 5, 15, 20, 0x3D5 - 0x3B0), + /* 0x3B0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 20, 15, 25, 0x3CF - 0x3B6), + /* 0x3B6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 25, 15, 40, 0x3C9 - 0x3BC), + /* 0x3BC */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 40, 16, 15, 0x3C3 - 0x3C2), + /* 0x3C2 */ SCHEDULE_CMD_RET_NONE(), + /* 0x3C3 */ SCHEDULE_CMD_RET_TIME(15, 40, 16, 15, 81), + /* 0x3C9 */ SCHEDULE_CMD_RET_TIME(15, 25, 15, 40, 17), + /* 0x3CF */ SCHEDULE_CMD_RET_TIME(15, 20, 15, 25, 80), + /* 0x3D5 */ SCHEDULE_CMD_RET_TIME(15, 5, 15, 20, 23), + /* 0x3DB */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 5, 15, 20, 0x3FC - 0x3E1), + /* 0x3E1 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 20, 15, 50, 0x3F6 - 0x3E7), + /* 0x3E7 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 50, 16, 15, 0x3F0 - 0x3ED), + /* 0x3ED */ SCHEDULE_CMD_RET_VAL_L(0), + /* 0x3F0 */ SCHEDULE_CMD_RET_TIME(15, 50, 16, 15, 71), + /* 0x3F6 */ SCHEDULE_CMD_RET_TIME(15, 20, 15, 50, 25), + /* 0x3FC */ SCHEDULE_CMD_RET_TIME(15, 5, 15, 20, 23), + /* 0x402 */ SCHEDULE_CMD_RET_TIME(14, 45, 15, 5, 70), + /* 0x408 */ SCHEDULE_CMD_RET_NONE(), + /* 0x409 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x413 - 0x40D), + /* 0x40D */ SCHEDULE_CMD_RET_TIME(12, 0, 13, 1, 21), + /* 0x413 */ SCHEDULE_CMD_RET_NONE(), + /* 0x414 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(3, 0x588 - 0x419), + /* 0x419 */ SCHEDULE_CMD_CHECK_FLAG_L(0x1C, 0x08, 0x55D - 0x41E), + /* 0x41E */ SCHEDULE_CMD_CHECK_FLAG_L(0x1C, 0x10, 0x52F - 0x423), + /* 0x423 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x42A), + /* 0x42A */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(12, 0, 13, 1, 0x527 - 0x431), + /* 0x431 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 15, 0, 0x446 - 0x437), + /* 0x437 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x43E - 0x43D), + /* 0x43D */ SCHEDULE_CMD_RET_NONE(), + /* 0x43E */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x445 - 0x442), + /* 0x442 */ SCHEDULE_CMD_RET_VAL_L(24), + /* 0x445 */ SCHEDULE_CMD_RET_NONE(), + /* 0x446 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x47B - 0x44A), + /* 0x44A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 0, 13, 1, 0x475 - 0x450), + /* 0x450 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 5, 13, 15, 0x46F - 0x456), + /* 0x456 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 45, 14, 55, 0x469 - 0x45C), + /* 0x45C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 55, 15, 0, 0x463 - 0x462), + /* 0x462 */ SCHEDULE_CMD_RET_NONE(), + /* 0x463 */ SCHEDULE_CMD_RET_TIME(14, 55, 15, 0, 2), + /* 0x469 */ SCHEDULE_CMD_RET_TIME(14, 45, 14, 55, 52), + /* 0x46F */ SCHEDULE_CMD_RET_TIME(13, 5, 13, 15, 38), + /* 0x475 */ SCHEDULE_CMD_RET_TIME(13, 0, 13, 1, 1), + /* 0x47B */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x4C8 - 0x47F), + /* 0x47F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 5, 13, 15, 0x4C2 - 0x485), + /* 0x485 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 15, 13, 25, 0x4BC - 0x48B), + /* 0x48B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 25, 13, 35, 0x4B6 - 0x491), + /* 0x491 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 15, 14, 25, 0x4B0 - 0x497), + /* 0x497 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 25, 14, 35, 0x4AA - 0x49D), + /* 0x49D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 35, 14, 45, 0x4A4 - 0x4A3), + /* 0x4A3 */ SCHEDULE_CMD_RET_NONE(), + /* 0x4A4 */ SCHEDULE_CMD_RET_TIME(14, 35, 14, 45, 50), + /* 0x4AA */ SCHEDULE_CMD_RET_TIME(14, 25, 14, 35, 48), + /* 0x4B0 */ SCHEDULE_CMD_RET_TIME(14, 15, 14, 25, 47), + /* 0x4B6 */ SCHEDULE_CMD_RET_TIME(13, 25, 13, 35, 41), + /* 0x4BC */ SCHEDULE_CMD_RET_TIME(13, 15, 13, 25, 40), + /* 0x4C2 */ SCHEDULE_CMD_RET_TIME(13, 5, 13, 15, 39), + /* 0x4C8 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_BACKTOWN, 0x4E5 - 0x4CC), + /* 0x4CC */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 35, 13, 45, 0x4DF - 0x4D2), + /* 0x4D2 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 45, 13, 55, 0x4D9 - 0x4D8), + /* 0x4D8 */ SCHEDULE_CMD_RET_NONE(), + /* 0x4D9 */ SCHEDULE_CMD_RET_TIME(13, 45, 13, 55, 43), + /* 0x4DF */ SCHEDULE_CMD_RET_TIME(13, 35, 13, 45, 42), + /* 0x4E5 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x526 - 0x4E9), + /* 0x4E9 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 55, 14, 5, 0x520 - 0x4EF), + /* 0x4EF */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 5, 14, 15, 0x51A - 0x4F5), + /* 0x4F5 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 15, 14, 25, 0x514 - 0x4FB), + /* 0x4FB */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 25, 14, 35, 0x50E - 0x501), + /* 0x501 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 35, 14, 45, 0x508 - 0x507), + /* 0x507 */ SCHEDULE_CMD_RET_NONE(), + /* 0x508 */ SCHEDULE_CMD_RET_TIME(14, 35, 14, 45, 51), + /* 0x50E */ SCHEDULE_CMD_RET_TIME(14, 25, 14, 35, 49), + /* 0x514 */ SCHEDULE_CMD_RET_TIME(14, 15, 14, 25, 46), + /* 0x51A */ SCHEDULE_CMD_RET_TIME(14, 5, 14, 15, 45), + /* 0x520 */ SCHEDULE_CMD_RET_TIME(13, 55, 14, 5, 44), + /* 0x526 */ SCHEDULE_CMD_RET_NONE(), + /* 0x527 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x52E - 0x52B), + /* 0x52B */ SCHEDULE_CMD_RET_VAL_L(22), + /* 0x52E */ SCHEDULE_CMD_RET_NONE(), + /* 0x52F */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x536), + /* 0x536 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 0, 13, 1, 0x552 - 0x53C), + /* 0x53C */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(13, 1, 17, 0, 0x315 - 0x543), + /* 0x543 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x54A - 0x549), + /* 0x549 */ SCHEDULE_CMD_RET_NONE(), + /* 0x54A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x551 - 0x54E), + /* 0x54E */ SCHEDULE_CMD_RET_VAL_L(24), + /* 0x551 */ SCHEDULE_CMD_RET_NONE(), + /* 0x552 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x55C - 0x556), + /* 0x556 */ SCHEDULE_CMD_RET_TIME(12, 0, 13, 1, 21), + /* 0x55C */ SCHEDULE_CMD_RET_NONE(), + /* 0x55D */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x564), + /* 0x564 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 0, 13, 1, 0x580 - 0x56A), + /* 0x56A */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(13, 1, 15, 0, 0x446 - 0x571), + /* 0x571 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x578 - 0x577), + /* 0x577 */ SCHEDULE_CMD_RET_NONE(), + /* 0x578 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x57F - 0x57C), + /* 0x57C */ SCHEDULE_CMD_RET_VAL_L(24), + /* 0x57F */ SCHEDULE_CMD_RET_NONE(), + /* 0x580 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x587 - 0x584), + /* 0x584 */ SCHEDULE_CMD_RET_VAL_L(20), + /* 0x587 */ SCHEDULE_CMD_RET_NONE(), + /* 0x588 */ SCHEDULE_CMD_RET_NONE(), }; -static UNK_TYPE D_80AFB30C[] = { - 0x0A002E2E, 0x02000000, 0x0A220200, 0x0A000D19, 0x02000D00, 0x170D0200, 0x17001A01, 0x050E0017, 0x001A200E, - 0x000D0017, 0x5304001B, 0x0E000000, 0x0A520A00, 0x6D190200, 0x17001A0D, 0x02001A00, 0x2401050E, 0x001A0024, - 0x540E0017, 0x001A210A, 0x006F1902, 0x001A0024, 0x0D020024, 0x002E0105, 0x0E002400, 0x2E560E00, 0x1A002455, - 0x0A006C19, 0x02002E00, 0x380D0200, 0x38003B01, 0x050E0038, 0x003B220E, 0x002E0038, 0x570A0015, 0x25020038, - 0x003B1902, 0x003B0109, 0x0D020109, 0x01280105, 0x0E010901, 0x281C0E00, 0x3B010958, 0x0E003800, 0x3B240500, +static u8 D_80AFB30C[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x32 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 10, 0x2C - 0x0A), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 10, 0, 13, 0x29 - 0x10), + /* 0x10 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 13, 0, 23, 0x23 - 0x16), + /* 0x16 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 23, 0, 26, 0x1D - 0x1C), + /* 0x1C */ SCHEDULE_CMD_RET_NONE(), + /* 0x1D */ SCHEDULE_CMD_RET_TIME(0, 23, 0, 26, 32), + /* 0x23 */ SCHEDULE_CMD_RET_TIME(0, 13, 0, 23, 83), + /* 0x29 */ SCHEDULE_CMD_RET_VAL_L(27), + /* 0x2C */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 10, 82), + /* 0x32 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x4F - 0x36), + /* 0x36 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 23, 0, 26, 0x49 - 0x3C), + /* 0x3C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 26, 0, 36, 0x43 - 0x42), + /* 0x42 */ SCHEDULE_CMD_RET_NONE(), + /* 0x43 */ SCHEDULE_CMD_RET_TIME(0, 26, 0, 36, 84), + /* 0x49 */ SCHEDULE_CMD_RET_TIME(0, 23, 0, 26, 33), + /* 0x4F */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x6C - 0x53), + /* 0x53 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 26, 0, 36, 0x66 - 0x59), + /* 0x59 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 36, 0, 46, 0x60 - 0x5F), + /* 0x5F */ SCHEDULE_CMD_RET_NONE(), + /* 0x60 */ SCHEDULE_CMD_RET_TIME(0, 36, 0, 46, 86), + /* 0x66 */ SCHEDULE_CMD_RET_TIME(0, 26, 0, 36, 85), + /* 0x6C */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x89 - 0x70), + /* 0x70 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 46, 0, 56, 0x83 - 0x76), + /* 0x76 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 56, 0, 59, 0x7D - 0x7C), + /* 0x7C */ SCHEDULE_CMD_RET_NONE(), + /* 0x7D */ SCHEDULE_CMD_RET_TIME(0, 56, 0, 59, 34), + /* 0x83 */ SCHEDULE_CMD_RET_TIME(0, 46, 0, 56, 87), + /* 0x89 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0xB2 - 0x8D), + /* 0x8D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 56, 0, 59, 0xAC - 0x93), + /* 0x93 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 59, 1, 9, 0xA6 - 0x99), + /* 0x99 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 9, 1, 40, 0xA0 - 0x9F), + /* 0x9F */ SCHEDULE_CMD_RET_NONE(), + /* 0xA0 */ SCHEDULE_CMD_RET_TIME(1, 9, 1, 40, 28), + /* 0xA6 */ SCHEDULE_CMD_RET_TIME(0, 59, 1, 9, 88), + /* 0xAC */ SCHEDULE_CMD_RET_TIME(0, 56, 0, 59, 36), + /* 0xB2 */ SCHEDULE_CMD_RET_NONE(), }; -static UNK_TYPE D_80AFB3C0[] = { - 0x0A006C19, 0x02000A00, 0x0D0D0200, 0x0D001701, 0x050E000D, 0x00175A0E, 0x000A000D, 0x230A0015, - 0x19020000, 0x000A0D02, 0x000A000D, 0x01050E00, 0x0A000D25, 0x0E000000, 0x0A590500, +static u8 D_80AFB3C0[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x1D - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 10, 0, 13, 0x17 - 0x0A), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 13, 0, 23, 0x11 - 0x10), + /* 0x10 */ SCHEDULE_CMD_RET_NONE(), + /* 0x11 */ SCHEDULE_CMD_RET_TIME(0, 13, 0, 23, 90), + /* 0x17 */ SCHEDULE_CMD_RET_TIME(0, 10, 0, 13, 35), + /* 0x1D */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x3A - 0x21), + /* 0x21 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 10, 0x34 - 0x27), + /* 0x27 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 10, 0, 13, 0x2E - 0x2D), + /* 0x2D */ SCHEDULE_CMD_RET_NONE(), + /* 0x2E */ SCHEDULE_CMD_RET_TIME(0, 10, 0, 13, 37), + /* 0x34 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 10, 89), + /* 0x3A */ SCHEDULE_CMD_RET_NONE(), }; -static UNK_TYPE D_80AFB3FC[] = { - 0x0A006C19, 0x02120006, 0x000D0205, 0x00050A01, 0x050E0500, 0x050A5B0E, 0x12000600, 0x1D050000, +static u8 D_80AFB3FC[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x1D - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x17 - 0x0A), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(5, 0, 5, 10, 0x11 - 0x10), + /* 0x10 */ SCHEDULE_CMD_RET_NONE(), + /* 0x11 */ SCHEDULE_CMD_RET_TIME(5, 0, 5, 10, 91), + /* 0x17 */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 29), + /* 0x1D */ SCHEDULE_CMD_RET_NONE(), }; -static UNK_TYPE D_80AFB41C[] = { - 0x0A006C0D, 0x02000000, 0x0A01050E, 0x0000000A, 0x5B050000, +static u8 D_80AFB41C[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x11 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 10, 0x0B - 0x0A), + /* 0x0A */ SCHEDULE_CMD_RET_NONE(), + /* 0x0B */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 10, 91), + /* 0x11 */ SCHEDULE_CMD_RET_NONE(), }; static s32 D_80AFB430[] = { @@ -904,7 +1200,7 @@ s32 func_80AF8DD4(EnPm* this, GlobalContext* globalCtx) { return 0; } -s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2, u8 actorCat, s16 actorId) { +s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 actorCat, s16 actorId) { u8 sp4F = this->actor.params & 0xFF; Vec3s* sp48; Vec3f sp3C; @@ -915,8 +1211,8 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; sp2C = func_80AF7CB0(this, globalCtx, actorCat, actorId); - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->unk0]); + if (D_80AFB430[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { @@ -934,8 +1230,8 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp56 = gSaveContext.save.time - 0x3FFC; +s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = this->actor.params & 0xFF; EnDoor* door; Vec3s* sp4C; @@ -945,9 +1241,9 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; this->unk_234 = NULL; - door = func_80AF7D60(globalCtx, arg2->unk0); - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80AFB430[arg2->unk0]); + door = func_80AF7D60(globalCtx, arg2->result); + if (D_80AFB430[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80AFB430[arg2->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { @@ -966,8 +1262,8 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_260 = 0x4B; } - this->unk_36C = arg2->unk8 - arg2->unk4; - this->unk_36E = sp56 - arg2->unk4; + this->unk_36C = arg2->time1 - arg2->time0; + this->unk_36E = sp56 - arg2->time0; this->actor.flags &= ~ACTOR_FLAG_1; if (gSaveContext.save.weekEventReg[90] & 8) { this->unk_356 |= 0x800; @@ -982,8 +1278,8 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp2E = (u16)(gSaveContext.save.time - 0x3FFC); +s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = this->actor.params & 0xFF; s32 pad; @@ -991,8 +1287,8 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80AFB430[arg2->unk0]); + if (D_80AFB430[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80AFB430[arg2->result]); } if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { @@ -1003,13 +1299,13 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if ((this->unk_258 < 38) && (this->unk_258 != 0) && (this->unk_374 >= 0)) { phi_v1 = sp2E; } else { - phi_v1 = arg2->unk4; + phi_v1 = arg2->time0; } - if (arg2->unk8 < phi_v1) { - this->unk_248 = (phi_v1 - arg2->unk8) + 0xFFFF; + if (arg2->time1 < phi_v1) { + this->unk_248 = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_248 = arg2->unk8 - phi_v1; + this->unk_248 = arg2->time1 - phi_v1; } this->unk_254 = sp2E - phi_v1; @@ -1023,7 +1319,7 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Flags_UnsetSwitch(globalCtx, 0); } - switch (arg2->unk0) { + switch (arg2->result) { case 83: case 84: case 85: @@ -1062,7 +1358,7 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u8 sp4F = this->actor.params & 0xFF; Vec3f sp40; Vec3f sp34; @@ -1071,8 +1367,8 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; this->unk_234 = NULL; - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->unk0]); + if (D_80AFB430[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); } if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { @@ -1083,7 +1379,7 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); Math_Vec3f_Copy(&this->actor.prevPos, &sp40); - if (arg2->unk0 == 24) { + if (arg2->result == 24) { Flags_UnsetSwitch(globalCtx, 0); Flags_UnsetSwitch(globalCtx, 1); this->unk_394 = EXCH_ITEM_NONE; @@ -1095,7 +1391,7 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u8 sp4F = this->actor.params & 0xFF; Vec3f sp40; Vec3f sp34; @@ -1104,13 +1400,13 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; s32 phi_a3 = -1; - switch (arg2->unk0) { + switch (arg2->result) { case 3: case 4: case 5: case 6: case 7: - phi_a3 = arg2->unk0 - 3; + phi_a3 = arg2->result - 3; break; case 19: @@ -1123,7 +1419,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } this->unk_234 = NULL; - phi_a3 = D_80AFB430[arg2->unk0]; + phi_a3 = D_80AFB430[arg2->result]; if (phi_a3 >= 0) { this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, phi_a3); } @@ -1137,7 +1433,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->actor.world.pos, &sp40); Math_Vec3f_Copy(&this->actor.prevPos, &sp40); - switch (arg2->unk0) { + switch (arg2->result) { case 27: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROOM_CARTAIN); Flags_SetSwitch(globalCtx, 0); @@ -1169,7 +1465,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar gSaveContext.save.weekEventReg[60] |= 4; default: - if (arg2->unk0 == 0x1D) { + if (arg2->result == 0x1D) { this->actor.world.rot.y = BINANG_ROT180(this->actor.world.rot.y); } SubS_UpdateFlags(&this->unk_356, 3, 7); @@ -1182,7 +1478,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF98A0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF98A0(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_MM3, 116.0f, 26.0f, -219.0f, 0, @@ -1193,7 +1489,7 @@ s32 func_80AF98A0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80AFB8EC = { 116.0f, 26.0f, -219.0f }; static Vec3s D_80AFB8F8 = { 0x0000, 0xC0BA, 0x0000 }; s32 pad; @@ -1205,7 +1501,7 @@ s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->actor.targetMode = 6; this->actor.gravity = -1.0f; this->unk_368 = 80.0f; - if (arg2->unk0 == 14) { + if (arg2->result == 14) { this->unk_356 &= ~0x200; func_80AF7E98(this, 13); } else { @@ -1215,7 +1511,7 @@ s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80AF9A0C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF9A0C(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AN)) { @@ -1233,7 +1529,7 @@ s32 func_80AF9A0C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF9AB0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF9AB0(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_TEST3)) { @@ -1251,7 +1547,7 @@ s32 func_80AF9AB0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AL)) { @@ -1269,7 +1565,7 @@ s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret; this->actor.flags |= ACTOR_FLAG_1; @@ -1278,7 +1574,7 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_356 = 0; this->unk_368 = 40.0f; - switch (arg2->unk0) { + switch (arg2->result) { case 16: ret = func_80AF9A0C(this, globalCtx, arg2); break; @@ -1688,13 +1984,13 @@ void func_80AFA438(EnPm* this, GlobalContext* globalCtx) { } void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { - static UNK_PTR D_80AFB900[] = { + static u8* D_80AFB900[] = { D_80AFAD80, D_80AFB30C, D_80AFB3C0, D_80AFB3FC, D_80AFB41C, }; u16 time = gSaveContext.save.time; u16 sp3C = 0; + ScheduleResult sp2C; u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp2C; this->unk_374 = REG(15) + *unk_14; if (this->unk_38C != 0) { @@ -1703,17 +1999,17 @@ void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { gSaveContext.save.time = time; } - if (!func_80133038(globalCtx, D_80AFB900[this->unk_38C], &sp2C) || - ((this->unk_258 != sp2C.unk0) && !func_80AF9BF8(this, globalCtx, &sp2C))) { + if (!Schedule_RunScript(globalCtx, D_80AFB900[this->unk_38C], &sp2C) || + ((this->unk_258 != sp2C.result) && !func_80AF9BF8(this, globalCtx, &sp2C))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp2C.unk0 = 0; + sp2C.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_258 = sp2C.unk0; + this->unk_258 = sp2C.result; this->unk_268 = func_80AF8040(this, globalCtx); func_80AFA438(this, globalCtx); if (this->unk_38C != 0) { diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 0503d0c56..a4e6cfd41 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -124,13 +124,54 @@ static u16 D_80BAE800[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6, }; -static UNK_TYPE D_80BAE820[] = { - 0xC00027C, 0x210877, 0xA006D31, 0x2000000, 0x19250200, 0x19001E19, 0x2010F01, 0x140D0201, 0x14012D01, - 0x50E0114, 0x12D0E0E, 0x10F0114, 0x70E0019, 0x1E060E, 0x19, 0xD0A000D, 0x3D020019, 0x1E3102, - 0x1E002D, 0x2502002D, 0x1001902, 0x100010F, 0xD02010F, 0x1140105, 0xE010F01, 0x14090E01, 0x10F0B, - 0xE002D01, 0x20E00, 0x1E002D0A, 0xE001900, 0x1E080505, 0xC000125, 0xA006E20, 0x2120000, 0x14140200, - 0x14001E08, 0xF001E03, 0x4000405, 0xE001400, 0x1E0F0E12, 0x1403, 0x50C0003, 0x270A0013, 0x22021200, - 0x13001602, 0x13001319, 0xD021319, 0x105, 0xE131900, 0x10400, 0x50E1200, 0x13000C05, 0x5000000, +static u8 D_80BAE820[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x80 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x21, 0x08, 0x7F - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x3D - 0x0C), + /* 0x0C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 25, 0x37 - 0x12), + /* 0x12 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 25, 0, 30, 0x31 - 0x18), + /* 0x18 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 15, 1, 20, 0x2B - 0x1E), + /* 0x1E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 20, 1, 45, 0x25 - 0x24), + /* 0x24 */ SCHEDULE_CMD_RET_NONE(), + /* 0x25 */ SCHEDULE_CMD_RET_TIME(1, 20, 1, 45, 14), + /* 0x2B */ SCHEDULE_CMD_RET_TIME(1, 15, 1, 20, 7), + /* 0x31 */ SCHEDULE_CMD_RET_TIME(0, 25, 0, 30, 6), + /* 0x37 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 25, 13), + /* 0x3D */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_AYASHIISHOP, 0x7E - 0x41), + /* 0x41 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 25, 0, 30, 0x78 - 0x47), + /* 0x47 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 30, 0, 45, 0x72 - 0x4D), + /* 0x4D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 45, 1, 0, 0x6C - 0x53), + /* 0x53 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 0, 1, 15, 0x66 - 0x59), + /* 0x59 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 15, 1, 20, 0x60 - 0x5F), + /* 0x5F */ SCHEDULE_CMD_RET_NONE(), + /* 0x60 */ SCHEDULE_CMD_RET_TIME(1, 15, 1, 20, 9), + /* 0x66 */ SCHEDULE_CMD_RET_TIME(1, 0, 1, 15, 11), + /* 0x6C */ SCHEDULE_CMD_RET_TIME(0, 45, 1, 0, 2), + /* 0x72 */ SCHEDULE_CMD_RET_TIME(0, 30, 0, 45, 10), + /* 0x78 */ SCHEDULE_CMD_RET_TIME(0, 25, 0, 30, 8), + /* 0x7E */ SCHEDULE_CMD_RET_NONE(), + /* 0x7F */ SCHEDULE_CMD_RET_NONE(), + /* 0x80 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0xA9 - 0x84), + /* 0x84 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_BACKTOWN, 0xA8 - 0x88), + /* 0x88 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 0, 20, 0xA2 - 0x8E), + /* 0x8E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 20, 0, 30, 0x9C - 0x94), + /* 0x94 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(0, 30, 0x9B - 0x98), + /* 0x98 */ SCHEDULE_CMD_RET_VAL_L(4), + /* 0x9B */ SCHEDULE_CMD_RET_NONE(), + /* 0x9C */ SCHEDULE_CMD_RET_TIME(0, 20, 0, 30, 15), + /* 0xA2 */ SCHEDULE_CMD_RET_TIME(18, 0, 0, 20, 3), + /* 0xA8 */ SCHEDULE_CMD_RET_NONE(), + /* 0xA9 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0xD4 - 0xAD), + /* 0xAD */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_IKANA, 0xD3 - 0xB1), + /* 0xB1 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 19, 0, 0xCD - 0xB7), + /* 0xB7 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(19, 0, 19, 25, 0xCA - 0xBD), + /* 0xBD */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(19, 25, 0, 0, 0xC4 - 0xC3), + /* 0xC3 */ SCHEDULE_CMD_RET_NONE(), + /* 0xC4 */ SCHEDULE_CMD_RET_TIME(19, 25, 0, 0, 1), + /* 0xCA */ SCHEDULE_CMD_RET_VAL_L(5), + /* 0xCD */ SCHEDULE_CMD_RET_TIME(18, 0, 19, 0, 12), + /* 0xD3 */ SCHEDULE_CMD_RET_NONE(), + /* 0xD4 */ SCHEDULE_CMD_RET_NONE(), }; static s32 D_80BAE8F8[] = { @@ -633,12 +674,12 @@ void func_80BABB90(EnSuttari* this, s32 arg1) { } } -s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg2* unkStruct) { - u16 sp26 = gSaveContext.save.time - 0x3FFC; +s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { + u16 sp26 = SCHEDULE_TIME_NOW; u16 pad1; u8 sp23 = ENSUTTARI_GET_PATH(&this->actor); u16 pad2; - UNK_TYPE sp1C = D_80BAE8F8[unkStruct->unk0]; + UNK_TYPE sp1C = D_80BAE8F8[unkStruct->result]; u16 phi_a0; if (sp1C >= 0) { @@ -650,12 +691,12 @@ s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg if ((this->unk428 != 0 && this->unk428 < 0xC) && (this->unk42A >= 0)) { phi_a0 = sp26; } else { - phi_a0 = unkStruct->unk4; + phi_a0 = unkStruct->time0; } - if (unkStruct->unk8 < phi_a0) { - this->unk418 = (phi_a0 - unkStruct->unk8) + 0xFFFF; + if (unkStruct->time1 < phi_a0) { + this->unk418 = (phi_a0 - unkStruct->time1) + 0xFFFF; } else { - this->unk418 = unkStruct->unk8 - phi_a0; + this->unk418 = unkStruct->time1 - phi_a0; } this->unk424 = sp26 - phi_a0; phi_a0 = this->unk404->count - 2; @@ -666,7 +707,7 @@ s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg return 1; } -s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg2* unkStruct) { +s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { s32 pad; EnDoor* sp48; u8 sp47; @@ -677,12 +718,12 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg UNK_TYPE sp24; sp47 = ENSUTTARI_GET_PATH(&this->actor); - sp44 = gSaveContext.save.time - 0x3FFC; + sp44 = SCHEDULE_TIME_NOW; if (this->unk428 == 10 || this->unk428 == 11 || this->unk428 == 2) { return 0; } sp48 = (EnDoor*)SubS_FindNearestActor(&this->actor, globalCtx, ACTORCAT_DOOR, ACTOR_EN_DOOR); - sp24 = D_80BAE8F8[unkStruct->unk0]; + sp24 = D_80BAE8F8[unkStruct->result]; if ((sp48 != NULL) && (sp24 >= 0)) { this->unk404 = SubS_GetAdditionalPath(globalCtx, sp47, sp24); } @@ -692,9 +733,9 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg sp28 = Lib_SegmentedToVirtual(this->unk404->points); Math_Vec3s_ToVec3f(&sp38, &sp28[0]); Math_Vec3s_ToVec3f(&sp2C, &sp28[1]); - this->unk434 = sp44 - unkStruct->unk4; - this->unk436 = unkStruct->unk8 - unkStruct->unk4; - if (unkStruct->unk0 != 10 && unkStruct->unk0 != 11) { + this->unk434 = sp44 - unkStruct->time0; + this->unk436 = unkStruct->time1 - unkStruct->time0; + if (unkStruct->result != 10 && unkStruct->result != 11) { sp48->unk_1A7 = 0x4B; } Math_Vec3f_Copy(&this->unk438, &sp38); @@ -704,10 +745,10 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg return 1; } -s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg2* unkStruct) { +s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { s32 ret; - switch (unkStruct->unk0) { + switch (unkStruct->result) { case 15: case 14: case 13: @@ -1059,18 +1100,17 @@ void func_80BACE4C(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 unkStruct; + ScheduleResult unkStruct; - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || + ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.unk0 = 0; + unkStruct.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; + this->unk428 = unkStruct.result; func_80BAC2FC(this, globalCtx); func_80BAB434(this); if (this->unk428 == 5) { @@ -1084,18 +1124,17 @@ void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 unkStruct; + ScheduleResult unkStruct; - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || + ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.unk0 = 0; + unkStruct.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; + this->unk428 = unkStruct.result; func_80BAC2FC(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { Message_StartTextbox(globalCtx, 0x2A3A, &this->actor); @@ -1206,8 +1245,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 unkStruct; + ScheduleResult unkStruct; s16 curFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); @@ -1215,22 +1253,22 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { this->animationIndex = 2; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || + ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.unk0 = 0; + unkStruct.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; + this->unk428 = unkStruct.result; func_80BAC2FC(this, globalCtx); if ((this->unk430 == 1) && (this->unk404->unk1 == 0xFF)) { Actor_MarkForDeath(&this->actor); return; } func_80BAB434(this); - if ((this->flags1 & 0x20) && (this->unk430 == 0) && (unkStruct.unk0 != 7)) { + if ((this->flags1 & 0x20) && (this->unk430 == 0) && (unkStruct.result != 7)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { Message_StartTextbox(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; @@ -1242,8 +1280,7 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 unkStruct; + ScheduleResult unkStruct; s16 curFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); @@ -1254,21 +1291,21 @@ void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { this->animationIndex = 2; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || + ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.unk0 = 0; + unkStruct.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; + this->unk428 = unkStruct.result; func_80BAC2FC(this, globalCtx); if ((this->unk430 == 1) && (this->unk404->unk1 == 0xFF)) { Actor_MarkForDeath(&this->actor); return; } - if ((this->flags1 & 0x20) && (unkStruct.unk0 != 9)) { + if ((this->flags1 & 0x20) && (unkStruct.result != 9)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { Message_StartTextbox(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index 2d3ae2040..f1c9c6bbc 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -20,9 +20,22 @@ void EnTab_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BE127C(EnTab* this, GlobalContext* globalCtx); void func_80BE1348(EnTab* this, GlobalContext* globalCtx); -s32 D_80BE18D0[] = { - 0x0C000320, 0x0A00151B, 0x02093212, 0x010F0212, 0x00060003, 0x0400000E, 0x12000600, 0x020E0932, 0x12010105, - 0x0A001519, 0x02093215, 0x050D0215, 0x37050501, 0x050E1537, 0x0505020E, 0x09321505, 0x01050000, +static u8 D_80BE18D0[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x24 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x23 - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 50, 18, 1, 0x1D - 0x0E), + /* 0x0E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x17 - 0x14), + /* 0x14 */ SCHEDULE_CMD_RET_VAL_L(0), + /* 0x17 */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 2), + /* 0x1D */ SCHEDULE_CMD_RET_TIME(9, 50, 18, 1, 1), + /* 0x23 */ SCHEDULE_CMD_RET_NONE(), + /* 0x24 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x41 - 0x28), + /* 0x28 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 50, 21, 5, 0x3B - 0x2E), + /* 0x2E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 55, 5, 5, 0x35 - 0x34), + /* 0x34 */ SCHEDULE_CMD_RET_NONE(), + /* 0x35 */ SCHEDULE_CMD_RET_TIME(21, 55, 5, 5, 2), + /* 0x3B */ SCHEDULE_CMD_RET_TIME(9, 50, 21, 5, 1), + /* 0x41 */ SCHEDULE_CMD_RET_NONE(), }; s32 D_80BE1914[] = { @@ -353,7 +366,7 @@ s32* func_80BE0E04(EnTab* this, GlobalContext* globalCtx) { return NULL; } -s32 func_80BE0F04(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BE0F04(EnTab* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; EnGm* sp28 = func_80BE04E0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_GM); @@ -372,7 +385,7 @@ s32 func_80BE0F04(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* a return ret; } -s32 func_80BE0FC4(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BE0FC4(EnTab* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; Math_Vec3f_Copy(&this->actor.world.pos, &D_80BE1B04); @@ -386,12 +399,12 @@ s32 func_80BE0FC4(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* a return true; } -s32 func_80BE1060(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BE1060(EnTab* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret; this->unk_2FC = 0; - switch (arg2->unk0) { + switch (arg2->result) { case 1: ret = func_80BE0F04(this, globalCtx, arg2); break; @@ -459,21 +472,20 @@ void func_80BE1224(EnTab* this, GlobalContext* globalCtx) { } void func_80BE127C(EnTab* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp18; + ScheduleResult sp18; - this->unk_31A = REG(15) + *unk_14; + this->unk_31A = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!func_80133038(globalCtx, D_80BE18D0, &sp18) || - ((this->unk_1D8 != sp18.unk0) && !func_80BE1060(this, globalCtx, &sp18))) { + if (!Schedule_RunScript(globalCtx, D_80BE18D0, &sp18) || + ((this->unk_1D8 != sp18.result) && !func_80BE1060(this, globalCtx, &sp18))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp18.unk0 = 0; + sp18.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_1D8 = sp18.unk0; + this->unk_1D8 = sp18.result; func_80BE1224(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 830c86471..d239a6cb7 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -24,8 +24,8 @@ void func_80AECB0C(EnTk* this, GlobalContext* globalCtx); void func_80AECB6C(EnTk* this, GlobalContext* globalCtx); void func_80AECE0C(EnTk* this, GlobalContext* globalCtx); s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx); -s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2); -s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2); +s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2); +s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2); void func_80AED4F8(EnTk* this, GlobalContext* globalCtx); void func_80AED610(EnTk* this, GlobalContext* globalCtx); void func_80AED898(EnTk* this, GlobalContext* globalCtx); @@ -62,11 +62,11 @@ void func_80AEF5F4(Actor* thisx, GlobalContext* globalCtx); static s32 D_80AF0050; -static u32 D_80AEF800[] = { - 0x03060012, - 0x00000105, - 0x0E060012, - 0x00010500, +static u8 D_80AEF800[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(6, 0, 18, 0, 0x8 - 0x7), + /* 0x7 */ SCHEDULE_CMD_RET_NONE(), + /* 0x8 */ SCHEDULE_CMD_RET_TIME(6, 0, 18, 0, 1), + /* 0xE */ SCHEDULE_CMD_RET_NONE(), }; const ActorInit En_Tk_InitVars = { @@ -313,8 +313,8 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { s32 temp3; f32 sp48; f32 sp44; + ScheduleResult sp34; u8 temp4; - struct_80133038_arg2 sp34; this->actor.textId = 0; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { @@ -347,14 +347,14 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { this->unk_2DC -= temp3; this->unk_2E0 += REG(15); - if (func_80133038(globalCtx, (UNK_TYPE*)D_80AEF800, &sp34)) { - if ((this->unk_3CC != sp34.unk0) && !func_80AED354(this, globalCtx, &sp34)) { + if (Schedule_RunScript(globalCtx, D_80AEF800, &sp34)) { + if ((this->unk_3CC != sp34.result) && !func_80AED354(this, globalCtx, &sp34)) { return; } - temp4 = sp34.unk0; + temp4 = sp34.result; } else { - sp34.unk0 = 0; - temp4 = sp34.unk0; + sp34.result = 0; + temp4 = sp34.result; } if (!temp4 && (this->unk_3CC != 0)) { @@ -365,7 +365,7 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { this->actor.draw = EnTk_Draw; } - this->unk_3CC = sp34.unk0; + this->unk_3CC = sp34.result; func_80AECE0C(this, globalCtx); if (this->unk_3CE & 8) { @@ -492,20 +492,20 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { return false; } -s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 phi_v1 = false; - if (arg2->unk0 != 0) { + if (arg2->result != 0) { phi_v1 = func_80AED38C(this, globalCtx, arg2); } return phi_v1; } -s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp1E = gSaveContext.save.time - 0x3FFC; +s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp1E = SCHEDULE_TIME_NOW; u8 params = ENTK_GET_F800(&this->actor); u16 phi_a1; - s32 idx = arg2->unk0 - 1; + s32 idx = arg2->result - 1; this->unk_3C8 = SubS_GetAdditionalPath(globalCtx, params, D_80AEF8E8[idx + 1]); if (this->unk_3C8 == 0) { @@ -515,10 +515,10 @@ s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if ((this->unk_3CC <= 0) && (this->unk_3CC != 0) && (this->unk_3D0 >= 0)) { phi_a1 = sp1E; } else { - phi_a1 = arg2->unk4; + phi_a1 = arg2->time0; } - this->unk_3E4 = arg2->unk8 - phi_a1; + this->unk_3E4 = arg2->time1 - phi_a1; this->unk_3F0 = sp1E - phi_a1; phi_a1 = this->unk_3C8->count - 2; this->unk_3E8 = this->unk_3E4 / phi_a1; diff --git a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c index a8745c015..f91385daa 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c +++ b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c @@ -4,6 +4,7 @@ * Description: Unused OoT Saria's Song Ocarina Effect */ +#include "prevent_bss_reordering.h" #include "z_oceff_wipe3.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index cd1bbac2f..d8cd09c99 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -418,7 +418,7 @@ 0x8012F2E0 : "z_scene", 0x801307C0 : "z_scene_proc", 0x801322C0 : "z_scene_table", - 0x801323D0 : "code_801323D0", + 0x801323D0 : "z_schedule", 0x801330E0 : "z_skelanime", 0x80137970 : "z_skin", 0x80138410 : "z_skin_awb", @@ -554,7 +554,7 @@ 0x801C2730 : "", 0x801C3B60 : "z_scene_proc", 0x801C3CA0 : "z_scene_table", - 0x801C5C50 : "", + 0x801C5C50 : "z_schedule", 0x801C5CB0 : "z_skelanime", 0x801C5CD0 : "z_skin_matrix", 0x801C5D10 : "z_sub_s", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e42433b9b..fe4697ca9 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2499,26 +2499,26 @@ 0x80132338:("Entrance_GetSceneNumAbsolute",), 0x80132374:("Entrance_GetSpawnNum",), 0x801323A0:("Entrance_GetTransitionFlags",), - 0x801323D0:("func_801323D0",), - 0x80132428:("func_80132428",), - 0x80132494:("func_80132494",), - 0x801326B8:("func_801326B8",), - 0x801328F0:("func_801328F0",), - 0x80132920:("func_80132920",), - 0x80132938:("func_80132938",), - 0x80132954:("func_80132954",), - 0x8013296C:("func_8013296C",), - 0x80132A18:("func_80132A18",), - 0x80132A3C:("func_80132A3C",), - 0x80132A80:("func_80132A80",), - 0x80132AD8:("func_80132AD8",), - 0x80132B24:("func_80132B24",), - 0x80132B84:("func_80132B84",), - 0x80132D70:("func_80132D70",), - 0x80132E9C:("func_80132E9C",), - 0x80132FDC:("func_80132FDC",), - 0x80133000:("func_80133000",), - 0x80133038:("func_80133038",), + 0x801323D0:("Schedule_CheckFlagS",), + 0x80132428:("Schedule_CheckFlagL",), + 0x80132494:("Schedule_CheckTimeRangeS",), + 0x801326B8:("Schedule_CheckTimeRangeL",), + 0x801328F0:("Schedule_ReturnValueL",), + 0x80132920:("Schedule_ReturnNone",), + 0x80132938:("Schedule_ReturnEmpty",), + 0x80132954:("Schedule_Nop",), + 0x8013296C:("Schedule_CheckMiscS",), + 0x80132A18:("Schedule_ReturnValueS",), + 0x80132A3C:("Schedule_CheckSceneS",), + 0x80132A80:("Schedule_CheckSceneL",), + 0x80132AD8:("Schedule_CheckDayS",), + 0x80132B24:("Schedule_CheckDayL",), + 0x80132B84:("Schedule_ReturnTime",), + 0x80132D70:("Schedule_CheckBeforeTimeS",), + 0x80132E9C:("Schedule_CheckBeforeTimeL",), + 0x80132FDC:("Schedule_BranchL",), + 0x80133000:("Schedule_JumpL",), + 0x80133038:("Schedule_RunScript",), 0x801330E0:("SkelAnime_DrawLimbLod",), 0x801332F0:("SkelAnime_DrawLod",), 0x801334A0:("SkelAnime_DrawFlexLimbLod",), diff --git a/tools/namefixer.py b/tools/namefixer.py index 08621f709..db7d97e82 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -494,7 +494,7 @@ wordReplace = { "func_80158FB0": "Message_LoadTimeNES", "func_8015926C": "Message_LoadAreaTextNES", "func_8015E750": "Message_FindCreditsMessage", - + "func_80133038": "Schedule_RunScript", # Struct members "skelAnime.unk03": "skelAnime.taper", diff --git a/tools/overlayhelpers/scheduledis.py b/tools/overlayhelpers/scheduledis.py new file mode 100755 index 000000000..b441b94c7 --- /dev/null +++ b/tools/overlayhelpers/scheduledis.py @@ -0,0 +1,264 @@ +#!/usr/bin/env python3 +# +# MM Event Script Disassembler +# + +import argparse, os, struct, math +from actor_symbols import resolve_symbol + +cmd_info = [ + ('SCHEDULE_CMD_CHECK_FLAG_S', 0x04, '>BBb', (2, )), + ('SCHEDULE_CMD_CHECK_FLAG_L', 0x05, '>BBh', (2, )), + ('SCHEDULE_CMD_CHECK_TIME_RANGE_S', 0x06, '>BBBBb', (4, )), + ('SCHEDULE_CMD_CHECK_TIME_RANGE_L', 0x07, '>BBBBh', (4, )), + ('SCHEDULE_CMD_RET_VAL_L', 0x03, '>H', ( )), + ('SCHEDULE_CMD_RET_NONE', 0x01, '', ( )), + ('SCHEDULE_CMD_RET_EMPTY', 0x01, '', ( )), + ('SCHEDULE_CMD_NOP', 0x04, '>BBB', ( )), + ('SCHEDULE_CMD_CHECK_MISC_S', 0x03, '>Bb', (1, )), + ('SCHEDULE_CMD_RET_VAL_S', 0x02, '>B', ( )), + ('SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S', 0x04, '>Hb', (1, )), + ('SCHEDULE_CMD_CHECK_NOT_IN_SCENE_L', 0x05, '>Hh', (1, )), + ('SCHEDULE_CMD_CHECK_NOT_IN_DAY_S', 0x04, '>Hb', (1, )), + ('SCHEDULE_CMD_CHECK_NOT_IN_DAY_L', 0x05, '>Hh', (1, )), + ('SCHEDULE_CMD_RET_TIME', 0x06, '>BBBBB', ( )), + ('SCHEDULE_CMD_CHECK_BEFORE_TIME_S', 0x04, '>BBb', (2, )), + ('SCHEDULE_CMD_CHECK_BEFORE_TIME_L', 0x05, '>BBh', (2, )), + ('SCHEDULE_CMD_BRANCH_S', 0x02, '>b', (0, )), + ('SCHEDULE_CMD_BRANCH_L', 0x03, '>h', (0, )), +] + +scene_names = [ + 'SCENE_20SICHITAI2', + 'SCENE_UNSET_1', + 'SCENE_UNSET_2', + 'SCENE_UNSET_3', + 'SCENE_UNSET_4', + 'SCENE_UNSET_5', + 'SCENE_UNSET_6', + 'SCENE_KAKUSIANA', + 'SCENE_SPOT00', + 'SCENE_UNSET_9', + 'SCENE_WITCH_SHOP', + 'SCENE_LAST_BS', + 'SCENE_HAKASHITA', + 'SCENE_AYASHIISHOP', + 'SCENE_UNSET_E', + 'SCENE_UNSET_F', + 'SCENE_OMOYA', + 'SCENE_BOWLING', + 'SCENE_SONCHONOIE', + 'SCENE_IKANA', + 'SCENE_KAIZOKU', + 'SCENE_MILK_BAR', + 'SCENE_INISIE_N', + 'SCENE_TAKARAYA', + 'SCENE_INISIE_R', + 'SCENE_OKUJOU', + 'SCENE_OPENINGDAN', + 'SCENE_MITURIN', + 'SCENE_13HUBUKINOMITI', + 'SCENE_CASTLE', + 'SCENE_DEKUTES', + 'SCENE_MITURIN_BS', + 'SCENE_SYATEKI_MIZU', + 'SCENE_HAKUGIN', + 'SCENE_ROMANYMAE', + 'SCENE_PIRATE', + 'SCENE_SYATEKI_MORI', + 'SCENE_SINKAI', + 'SCENE_YOUSEI_IZUMI', + 'SCENE_KINSTA1', + 'SCENE_KINDAN2', + 'SCENE_TENMON_DAI', + 'SCENE_LAST_DEKU', + 'SCENE_22DEKUCITY', + 'SCENE_KAJIYA', + 'SCENE_00KEIKOKU', + 'SCENE_POSTHOUSE', + 'SCENE_LABO', + 'SCENE_DANPEI2TEST', + 'SCENE_UNSET_31', + 'SCENE_16GORON_HOUSE', + 'SCENE_33ZORACITY', + 'SCENE_8ITEMSHOP', + 'SCENE_F01', + 'SCENE_INISIE_BS', + 'SCENE_30GYOSON', + 'SCENE_31MISAKI', + 'SCENE_TAKARAKUJI', + 'SCENE_UNSET_3A', + 'SCENE_TORIDE', + 'SCENE_FISHERMAN', + 'SCENE_GORONSHOP', + 'SCENE_DEKU_KING', + 'SCENE_LAST_GORON', + 'SCENE_24KEMONOMITI', + 'SCENE_F01_B', + 'SCENE_F01C', + 'SCENE_BOTI', + 'SCENE_HAKUGIN_BS', + 'SCENE_20SICHITAI', + 'SCENE_21MITURINMAE', + 'SCENE_LAST_ZORA', + 'SCENE_11GORONNOSATO2', + 'SCENE_SEA', + 'SCENE_35TAKI', + 'SCENE_REDEAD', + 'SCENE_BANDROOM', + 'SCENE_11GORONNOSATO', + 'SCENE_GORON_HAKA', + 'SCENE_SECOM', + 'SCENE_10YUKIYAMANOMURA', + 'SCENE_TOUGITES', + 'SCENE_DANPEI', + 'SCENE_IKANAMAE', + 'SCENE_DOUJOU', + 'SCENE_MUSICHOUSE', + 'SCENE_IKNINSIDE', + 'SCENE_MAP_SHOP', + 'SCENE_F40', + 'SCENE_F41', + 'SCENE_10YUKIYAMANOMURA2', + 'SCENE_14YUKIDAMANOMITI', + 'SCENE_12HAKUGINMAE', + 'SCENE_17SETUGEN', + 'SCENE_17SETUGEN2', + 'SCENE_SEA_BS', + 'SCENE_RANDOM', + 'SCENE_YADOYA', + 'SCENE_KONPEKI_ENT', + 'SCENE_INSIDETOWER', + 'SCENE_26SARUNOMORI', + 'SCENE_LOST_WOODS', + 'SCENE_LAST_LINK', + 'SCENE_SOUGEN', + 'SCENE_BOMYA', + 'SCENE_KYOJINNOMA', + 'SCENE_KOEPONARACE', + 'SCENE_GORONRACE', + 'SCENE_TOWN', + 'SCENE_ICHIBA', + 'SCENE_BACKTOWN', + 'SCENE_CLOCKTOWER', + 'SCENE_ALLEY' +] + +def read_bytes(data_file, offset, len): + data_file.seek(offset) + return bytearray(data_file.read(len)) + +def calc_length(data_file, offset): + off = 0 + cmd = None + branch_targets = [] + + # Parse script, just keeping track of branches, until we find the end + while any([branch >= off for branch in branch_targets]) or cmd not in [0x04, 0x05, 0x06, 0x09]: + cmd = read_bytes(data_file, offset + off, 1)[0] + + cmd_len = cmd_info[cmd][1] + cmd_args = cmd_info[cmd][2] + + if len(cmd_args) > 1: + arg_values = struct.unpack(cmd_args, read_bytes(data_file, offset + off + 1, cmd_len - 1)) + for i in cmd_info[cmd][3]: + branch_targets.append(off + arg_values[i] + cmd_len) + + off += cmd_len + + return off + +def disassemble_unk_script(data_file, offset): + off = 0 + cmd = None + branch_targets = [] + script_len = calc_length(data_file, offset); + script_len_num_digits = 0 if script_len == 1 else int(math.ceil(math.log(script_len - 1, 16))) + + out = "static u8 sScheduleScript[] = {\n" + + # Keep trying to disassemble until it hits a terminator and no commands branch past it + while any([branch >= off for branch in branch_targets]) or cmd not in [0x04, 0x05, 0x06, 0x09]: + cmd = read_bytes(data_file, offset + off, 1)[0] + + cmd_name = cmd_info[cmd][0] + cmd_len = cmd_info[cmd][1] + cmd_args = cmd_info[cmd][2] + + args_formatted = [] + if len(cmd_args) > 1: # handle args + arg_values = struct.unpack(cmd_args, read_bytes(data_file, offset + off + 1, cmd_len - 1)) + for i,(arg_value,arg_type) in enumerate(zip(arg_values, cmd_args[1:]),0): + arg_formatted = "" + if arg_type == "h": + arg_formatted = f"{arg_value:#x}" + elif arg_type == "b": + arg_formatted = f"{arg_value:#x}" + elif arg_type == "H": + if (cmd == 0x0A or cmd == 0x0B) and (arg_value < len(scene_names)): + arg_formatted = scene_names[arg_value] + else: + arg_formatted = f"{arg_value}" + elif arg_type == "B": + if cmd == 0x00 or cmd == 0x01: + arg_formatted = f"0x{arg_value:02X}" + elif cmd == 0x08: + if arg_value == 0: + arg_formatted = "SCHEDULE_CHECK_MISC_ROOM_KEY" + elif arg_value == 1: + arg_formatted = "SCHEDULE_CHECK_MISC_LETTER_TO_KAFEI" + elif arg_value == 2: + arg_formatted = "SCHEDULE_CHECK_MISC_MASK_ROMANI" + else: + arg_formatted = f"0x{arg_value:02X}" + else: + arg_formatted = f"{arg_value:2}" + elif arg_type == "S": + if arg_value < len(scene_names): + arg_formatted = scene_names[arg_value] + else: + arg_formatted = f"0x{arg_value:04X}" + + if i in cmd_info[cmd][3]: # skip argument indices + # add skip args to branch targets, and change the output to absolute differences rather than relative offsets + arg_value += cmd_len + branch_targets.append(off + arg_value) + if arg_value == cmd_len: + arg_formatted == "0" + else: + arg_formatted = f"0x{off + arg_value:0{script_len_num_digits}X} - 0x{off + cmd_len:0{script_len_num_digits}X}" + args_formatted.append(arg_formatted) + + args = ", ".join(args_formatted) if len(args_formatted) != 0 else "" + + out += f" /* 0x{off:0{script_len_num_digits}X} */ {cmd_name}({args}),\n" + + off += cmd_len + + out = out.strip() + out += "\n};" + + print(out) + +def hex_parse(s): + return int(s, 16) + +def main(): + parser = argparse.ArgumentParser(description="Disassembles MM event scripts") + parser.add_argument('address', help="VRAM or ROM address to disassemble at", type=hex_parse) + args = parser.parse_args() + + file_result = resolve_symbol(args.address) + + if file_result[0] is None: + print("Invalid address") + return + + print(hex(file_result[1]), "in", file_result[0].split(os.sep)[-1]) + + with open(file_result[0],"rb") as data_file: + disassemble_unk_script(data_file, file_result[1]) + +if __name__ == "__main__": + main() From 8ba8780bb55d8e9eb4ce216612cf3347f8e303cd Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Wed, 25 May 2022 16:59:36 -0700 Subject: [PATCH 209/257] En_Snowman (Eeno and snowballs) OK and documented. object_snowman documented (#818) * EnSnowman_Init OK * EnSnowman_Destroy OK * func_80B173D0 OK and better match for EnSnowman_Init * EnSnowman_Draw OK * func_80B19948 OK * func_80B19998 OK * func_80B19718 OK * func_80B1746C and func_80B177EC OK * Match a ton of functions * func_80B18B30 OK * func_80B180A4 OK * func_80B18C7C OK * func_80B18124 OK * EnSnowman_Update OK * func_80B17144 OK * func_80B19474 OK * func_80B18F50 OK * All functions OK * Import data to C * Use object symbols * Misc cleanup * Fully document object_snowman * Low hanging fruit * Document snowman types * Some more minor stuff * Some more minor cleanup and naming * Name some more functions * More names * Even more names * Turns out, they're called Eeno! * limbPos -> bodyPartsPos as per Fig's suggestion * Update some more names * Committing so I can push up stuff for the snowballPos naming * More names + use generated reloc * First pass name on every function * First pass names on all struct vars * Document the mega eeno glitch * Get rid of garbage "split dead" naming * First pass documentation on combine state * Better names and some documentation * Last doc pass before PR * Respond to Elliptic's review * / 100.0f -> * 0.01f --- assets/xml/objects/object_snowman.xml | 118 +- spec | 3 +- .../actors/ovl_En_Snowman/z_en_snowman.c | 1225 +++++++++++++++-- .../actors/ovl_En_Snowman/z_en_snowman.h | 48 +- tools/disasm/functions.txt | 70 +- tools/disasm/variables.txt | 6 +- undefined_syms.txt | 13 - 7 files changed, 1268 insertions(+), 215 deletions(-) diff --git a/assets/xml/objects/object_snowman.xml b/assets/xml/objects/object_snowman.xml index 91b650a75..fde2d911f 100644 --- a/assets/xml/objects/object_snowman.xml +++ b/assets/xml/objects/object_snowman.xml @@ -1,49 +1,77 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index a2d9a9ef3..f6b19ee8a 100644 --- a/spec +++ b/spec @@ -3820,8 +3820,7 @@ beginseg name "ovl_En_Snowman" compress include "build/src/overlays/actors/ovl_En_Snowman/z_en_snowman.o" - include "build/data/ovl_En_Snowman/ovl_En_Snowman.data.o" - include "build/data/ovl_En_Snowman/ovl_En_Snowman.reloc.o" + include "build/src/overlays/actors/ovl_En_Snowman/ovl_En_Snowman_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c index 32d38ecb9..683685889 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c @@ -1,7 +1,7 @@ /* * File: z_en_snowman.c * Overlay: ovl_En_Snowman - * Description: Enos + * Description: Eeno */ #include "z_en_snowman.h" @@ -15,21 +15,52 @@ void EnSnowman_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSnowman_Update(Actor* thisx, GlobalContext* globalCtx); void EnSnowman_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B1746C(EnSnowman* this, GlobalContext* globalCtx); -void func_80B178B8(EnSnowman* this, GlobalContext* globalCtx); -void func_80B17A58(EnSnowman* this, GlobalContext* globalCtx); -void func_80B17D78(EnSnowman* this, GlobalContext* globalCtx); -void func_80B17EFC(EnSnowman* this, GlobalContext* globalCtx); -void func_80B17FE0(EnSnowman* this, GlobalContext* globalCtx); -void func_80B18124(EnSnowman* this, GlobalContext* globalCtx); -void func_80B183A4(EnSnowman* this, GlobalContext* globalCtx); -void func_80B1848C(EnSnowman* this, GlobalContext* globalCtx); -void func_80B1861C(EnSnowman* this, GlobalContext* globalCtx); -void func_80B189C4(EnSnowman* this, GlobalContext* globalCtx); -void func_80B18A04(EnSnowman* this, GlobalContext* globalCtx); -void func_80B18C7C(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupMoveSnowPile(EnSnowman* this); +void EnSnowman_MoveSnowPile(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupEmerge(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Emerge(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupReadySnowball(EnSnowman* this); +void EnSnowman_ReadySnowball(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupThrowSnowball(EnSnowman* this); +void EnSnowman_ThrowSnowball(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupIdle(EnSnowman* this); +void EnSnowman_Idle(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupSubmerge(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Submerge(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Melt(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Stun(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Damaged(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupDead(EnSnowman* this); +void EnSnowman_Dead(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupSplitDoNothing(EnSnowman* this); +void EnSnowman_SplitDoNothing(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupMarkForDeath(EnSnowman* this); +void EnSnowman_MarkForDeath(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_CreateSplitEeno(EnSnowman* this, Vec3f* basePos, s32 yRot); +void EnSnowman_SetupCombine(EnSnowman* this, GlobalContext* globalCtx, Vec3f* combinePos); +void EnSnowman_Combine(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_UpdateSnowball(Actor* thisx, GlobalContext* globalCtx); +void EnSnowman_DrawSnowPile(Actor* thisx, GlobalContext* globalCtx); +void EnSnowman_DrawSnowball(Actor* thisx, GlobalContext* globalCtx); + +typedef enum { + // Indicates that this split Eeno is not currently trying to combine into a large Eeno. + /* 0 */ EN_SNOWMAN_COMBINE_STATE_NONE, + + // Indicates that this split Eeno is actively trying to combine into a large Eeno again. + // Eenos in this state can both absorb other Eenos and start being absorbed themselves. + /* 1 */ EN_SNOWMAN_COMBINE_STATE_ACTIVE, + + // Indicates that this Eeno cannot absorb other Eenos to combine into a large Eeno. + // It can still be absorbed by Eenos in the EN_SNOWMAN_COMBINE_STATE_ACTIVE state. + /* 2 */ EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION, + + // Indicates that either this Eeno is shrinking having been absorbed by another Eeno, or that + // this Eeno is a fully-combined large Eeno and is done trying to combine with other split + // Eenos. In both cases, this Eeno cannot be absorbed by any other Eeno. + /* 3 */ EN_SNOWMAN_COMBINE_STATE_BEING_ABSORBED_OR_DONE, +} EnSnowmanCombineState; -#if 0 const ActorInit En_Snowman_InitVars = { ACTOR_EN_SNOWMAN, ACTORCAT_ENEMY, @@ -42,155 +73,1125 @@ const ActorInit En_Snowman_InitVars = { (ActorFunc)EnSnowman_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B19A00 = { - { COLTYPE_HIT4, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sEenoCylinderInit = { + { + COLTYPE_HIT4, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0.0f, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 60, 80, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B19A2C = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_NONE | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sSnowballCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, { 60, 80, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B19A58 = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(1, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0xF), - /* Goron punch */ DMG_ENTRY(2, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(1, 0x0), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ EN_SNOWMAN_DMGEFF_NONE, + /* 0x1 */ EN_SNOWMAN_DMGEFF_STUN, + /* 0x2 */ EN_SNOWMAN_DMGEFF_MELT, + /* 0x4 */ EN_SNOWMAN_DMGEFF_LIGHT_ORB = 0x4, + /* 0x5 */ EN_SNOWMAN_DMGEFF_ELECTRIC_STUN, + /* 0xF */ EN_SNOWMAN_DMGEFF_HOOKSHOT = 0xF, // Damages small Eenos, pulls the player towards large Eenos +} EnTalkGibudDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(2, EN_SNOWMAN_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, EN_SNOWMAN_DMGEFF_MELT), + /* Ice arrow */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Light arrow */ DMG_ENTRY(2, EN_SNOWMAN_DMGEFF_LIGHT_ORB), + /* Goron spikes */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_ELECTRIC_STUN), + /* Normal shield */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80B19A78 = { 2, 60, 80, 150 }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 60, 80, 150 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B19AAC[] = { +static Color_RGBA8 sDustPrimColor = { 250, 250, 250, 255 }; + +static Color_RGBA8 sDustEnvColor = { 180, 180, 180, 255 }; + +static Vec3f sDustVelocity = { 0.0f, 1.5f, 0.0f }; + +static Gfx* sSnowballDLs[] = { + gEenoSmallSnowballDL, + gEenoLargeSnowballDL, + gEenoSmallSnowballDL, +}; + +static Gfx* sSnowballFragmentDLs[] = { + gEenoSnowballFragment1DL, + gEenoSnowballFragment2DL, + gEenoSnowballFragment3DL, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 20, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), }; -#endif +void EnSnowman_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSnowman* this = THIS; + s32 attackRange; -extern ColliderCylinderInit D_80B19A00; -extern ColliderCylinderInit D_80B19A2C; -extern DamageTable D_80B19A58; -extern CollisionCheckInfoInit D_80B19A78; -extern InitChainEntry D_80B19AAC[]; + Actor_ProcessInitChain(thisx, sInitChain); + attackRange = EN_SNOWMAN_GET_ATTACK_RANGE(thisx); + if (attackRange == 0xFF) { + attackRange = 0; + } -extern UNK_TYPE D_06000404; -extern UNK_TYPE D_06004628; -extern UNK_TYPE D_060046D8; -extern UNK_TYPE D_06004F14; -extern UNK_TYPE D_0600554C; -extern UNK_TYPE D_060058CC; + thisx->params &= 7; + if (EN_SNOWMAN_GET_TYPE(thisx) < EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gEenoSkel, &gEenoEmergeAnim, this->jointTable, + this->morphTable, EENO_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->snowPileSkelAnime, &gEenoSnowPileSkel, &gEenoSnowPileMoveAnim, + this->snowPileJointTable, this->snowPileMorphTable, EENO_SNOW_PILE_LIMB_MAX); + CollisionCheck_SetInfo(&thisx->colChkInfo, &sDamageTable, &sColChkInfoInit); + Collider_InitAndSetCylinder(globalCtx, &this->collider, thisx, &sEenoCylinderInit); + if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_LARGE) { + thisx->flags |= ACTOR_FLAG_400; + Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_SNOWMAN, thisx->world.pos.x, + thisx->world.pos.y, thisx->world.pos.z, 0, 0, 0, EN_SNOWMAN_TYPE_SPLIT); + thisx->parent = Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SNOWMAN, + thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 0, + 0, 0, EN_SNOWMAN_TYPE_SPLIT, -1, thisx->unk20, NULL); + if ((thisx->child == NULL) || (thisx->parent == NULL)) { + if (thisx->child != NULL) { + Actor_MarkForDeath(thisx->child); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/EnSnowman_Init.s") + if (thisx->parent != NULL) { + Actor_MarkForDeath(thisx->parent); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/EnSnowman_Destroy.s") + Actor_MarkForDeath(thisx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B16FC0.s") + // Makes each split Eeno the parent or child of other split Eenos + thisx->parent->child = thisx; + thisx->child->child = thisx->parent; + thisx->parent->parent = thisx->child; + if (1) {} + Actor_SetScale(thisx, 0.02f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17144.s") + this->eenoScale = thisx->scale.x * 100.0f; + this->attackRange = (240.0f * this->eenoScale) + (attackRange * 0.1f * 40.0f); + if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_SPLIT) { + EnSnowman_SetupSplitDoNothing(this); + } else { + EnSnowman_SetupMoveSnowPile(this); + } + } else { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B173D0.s") + thisx->flags &= ~ACTOR_FLAG_1; + Collider_InitAndSetCylinder(globalCtx, &this->collider, thisx, &sSnowballCylinderInit); + thisx->world.rot.y = Actor_YawBetweenActors(thisx, &player->actor); + thisx->velocity.y = (Actor_XZDistanceBetweenActors(thisx, &player->actor) * 0.035f) + -5.0f; + thisx->velocity.y = CLAMP_MAX(thisx->velocity.y, 3.5f); + if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { + thisx->speedXZ = 15.0f; + } else { + thisx->speedXZ = 22.5f; + thisx->velocity.y *= 1.5f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B1746C.s") + thisx->world.pos.x += thisx->speedXZ * Math_SinS(thisx->world.rot.y); + thisx->world.pos.y += thisx->velocity.y; + thisx->world.pos.z += thisx->speedXZ * Math_CosS(thisx->world.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B177EC.s") + if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { + this->collider.dim.radius = 8; + this->collider.dim.height = 12; + this->collider.dim.yShift = -6; + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 10.0f); + } else { + this->collider.dim.radius = 50; + this->collider.dim.height = 122; + this->collider.dim.yShift = -8; + this->collider.info.toucher.damage = 16; + thisx->world.pos.y -= 32.0f; + Actor_SetScale(thisx, 0.006f); + ActorShape_Init(&thisx->shape, 16000.0f / 3.0f, ActorShadow_DrawCircle, 170.0f); + thisx->gravity = -1.5f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B178B8.s") + thisx->flags |= ACTOR_FLAG_10; + thisx->update = EnSnowman_UpdateSnowball; + thisx->draw = EnSnowman_DrawSnowball; + this->work.timer = 5; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B179D0.s") +void EnSnowman_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSnowman* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17A58.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17CE8.s") +/** + * Spawns a circle of snow-colored dust around the actor. + */ +void EnSnowman_SpawnCircularDustEffect(EnSnowman* this, GlobalContext* globalCtx) { + s16 angle = 0; + Vec3f pos; + f32 offset; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17D78.s") + pos.y = (Rand_ZeroFloat(10.0f) * this->eenoScale) + this->actor.world.pos.y; + for (i = 0; i < 16; i++) { + offset = (Rand_ZeroFloat(10.0f) + 20.0f) * this->eenoScale; + pos.x = (Math_SinS(angle) * offset) + this->actor.world.pos.x; + pos.z = (Math_CosS(angle) * offset) + this->actor.world.pos.z; + func_800B0DE0(globalCtx, &pos, &sDustVelocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, + this->eenoScale * 400.0f, 10); + angle += 0x1000; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17EB4.s") +/** + * Spawns a batch of large snowball fragments and some snow-colored dust at snowballPos. + */ +void EnSnowman_SpawnBigSnowballFragmentEffects(EnSnowman* this, GlobalContext* globalCtx) { + static Vec3f sAccel = { 0.0f, -1.0f, 0.0f }; + s16 altitude; + s16 azimuth; + Vec3f pos; + Vec3f velocity; + f32 speed; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17EFC.s") + for (i = 0; i < 15; i++) { + altitude = Rand_S16Offset(0x1800, 0x2800); + azimuth = ((u32)Rand_Next() >> 0x10); + speed = Rand_ZeroFloat(3.0f) + 8.0f; + velocity.x = (speed * Math_CosS(altitude)) * Math_SinS(azimuth); + velocity.y = speed * Math_SinS(altitude); + velocity.z = (speed * Math_CosS(altitude)) * Math_CosS(azimuth); + pos.x = (Rand_ZeroFloat(10.0f) * velocity.x) + this->snowballPos.x; + pos.y = (Rand_ZeroFloat(8.0f) * velocity.y) + this->snowballPos.y; + pos.z = (Rand_ZeroFloat(10.0f) * velocity.z) + this->snowballPos.z; + EffectSsHahen_Spawn(globalCtx, &pos, &velocity, &sAccel, 0, + Rand_S16Offset((((i % 3) * 50) + 50), (((i % 3) * 25) + 25)), 452, 20, + sSnowballFragmentDLs[i % 3]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17F4C.s") + func_800B0DE0(globalCtx, &this->snowballPos, &gZeroVec3f, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 1000, 150); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17FE0.s") +void EnSnowman_SetupMoveSnowPile(EnSnowman* this) { + Animation_PlayLoop(&this->snowPileSkelAnime, &gEenoSnowPileMoveAnim); + this->actor.scale.y = this->actor.scale.x; + this->actor.speedXZ = 2.0f; + this->actor.draw = EnSnowman_DrawSnowPile; + this->work.timer = 40; + this->turningOnSteepSlope = false; + this->collider.dim.radius = this->eenoScale * 30.0f; + this->collider.dim.height = this->eenoScale * 10.0f; + this->actionFunc = EnSnowman_MoveSnowPile; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B180A4.s") +/** + * Moves around beneath the snow as a snow pile. + */ +void EnSnowman_MoveSnowPile(EnSnowman* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f combinePos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18124.s") + SkelAnime_Update(&this->snowPileSkelAnime); + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + func_800B9010(&this->actor, NA_SE_EN_YMAJIN_MOVE - SFX_FLAG); + } else { + func_800B9010(&this->actor, NA_SE_EN_YMAJIN_MINI_MOVE - SFX_FLAG); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18380.s") + if (this->work.timer > 0) { + this->work.timer--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B183A4.s") + if (this->work.timer == 0) { + this->collider.base.acFlags |= AC_ON; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B183C4.s") + if ((this->combineTimer == 0) && (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SPLIT)) { + // Sets the combinePos to be the average position of all living split Eenos. + if ((this->actor.parent->colChkInfo.health != 0) && (this->actor.child->colChkInfo.health != 0)) { + combinePos.x = + (this->actor.parent->world.pos.x + this->actor.child->world.pos.x + this->actor.world.pos.x) * + (1.0f / 3.0f); + combinePos.z = + (this->actor.parent->world.pos.z + this->actor.child->world.pos.z + this->actor.world.pos.z) * + (1.0f / 3.0f); + } else if (this->actor.parent->colChkInfo.health != 0) { + combinePos.x = (this->actor.parent->world.pos.x + this->actor.world.pos.x) / 2.0f; + combinePos.z = (this->actor.parent->world.pos.z + this->actor.world.pos.z) / 2.0f; + } else if (this->actor.child->colChkInfo.health != 0) { + combinePos.x = (this->actor.child->world.pos.x + this->actor.world.pos.x) / 2.0f; + combinePos.z = (this->actor.child->world.pos.z + this->actor.world.pos.z) / 2.0f; + } else { + combinePos.x = this->actor.world.pos.x; + combinePos.z = this->actor.world.pos.z; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B1848C.s") + combinePos.y = this->actor.world.pos.y; + EnSnowman_SetupCombine((EnSnowman*)this->actor.parent, globalCtx, &combinePos); + EnSnowman_SetupCombine((EnSnowman*)this->actor.child, globalCtx, &combinePos); + EnSnowman_SetupCombine(this, globalCtx, &combinePos); + } else if ((this->work.timer == 0) && (fabsf(this->actor.playerHeightRel) < 60.0f) && + (this->actor.xzDistToPlayer < this->attackRange) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && + !(player->stateFlags1 & 0x800000)) { + EnSnowman_SetupEmerge(this, globalCtx); + } else if (this->snowPileTargetRotY != this->actor.shape.rot.y) { + if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->snowPileTargetRotY, 0x100)) { + this->turningOnSteepSlope = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18600.s") + this->actor.world.rot.y = this->actor.shape.rot.y; + } else if (this->actor.bgCheckFlags & 8) { + this->snowPileTargetRotY = this->actor.wallYaw; + } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 200.0f) { + this->snowPileTargetRotY = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + (Rand_Next() >> 0x14); + } else if (Rand_ZeroOne() < 0.02f) { + this->snowPileTargetRotY += (s16)((((u32)Rand_Next() >> 0x13) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B1861C.s") +void EnSnowman_SetupEmerge(EnSnowman* this, GlobalContext* globalCtx) { + Animation_PlayOnce(&this->skelAnime, &gEenoEmergeAnim); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_SURFACE); + this->collider.dim.radius = this->eenoScale * 40.0f; + this->collider.dim.height = this->eenoScale * 25.0f; + this->actor.draw = EnSnowman_Draw; + this->actor.scale.y = this->actor.scale.x * 0.4f; + this->actor.speedXZ = 0.0f; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + EnSnowman_SpawnCircularDustEffect(this, globalCtx); + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = EnSnowman_Emerge; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18908.s") +/** + * Emerge from beneath the snow and face the player. + */ +void EnSnowman_Emerge(EnSnowman* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B189C4.s") + Math_StepToF(&this->actor.scale.y, this->actor.scale.x, + (this->actor.scale.x * 0.6f) / Animation_GetLastFrame(&gEenoEmergeAnim)); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x1000); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B189D4.s") + if (SkelAnime_Update(&this->skelAnime)) { + if (this->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE) { + EnSnowman_SetupSubmerge(this, globalCtx); + } else if (!(player->stateFlags1 & 0x800000) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + this->collider.base.acFlags |= AC_ON; + this->work.snowballsToThrowBeforeIdling = 3; + EnSnowman_SetupReadySnowball(this); + } else { + this->collider.base.acFlags |= AC_ON; + this->actor.scale.y = this->actor.scale.x; + EnSnowman_SetupIdle(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18A04.s") +void EnSnowman_SetupReadySnowball(EnSnowman* this) { + this->actor.scale.y = this->actor.scale.x; + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + this->fwork.frameToStartHoldingSnowball = 15.0f; + Animation_PlayOnce(&this->skelAnime, &gEenoLargeSnowballCreateAnim); + } else { + this->fwork.frameToStartHoldingSnowball = 6.0f; + Animation_PlayOnce(&this->skelAnime, &gEenoSmallSnowballCreateAnim); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18A28.s") + this->actionFunc = EnSnowman_ReadySnowball; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18B30.s") +/** + * Plays the animation of the Eeno creating a snowball and spawns some snow-colored dust + * near the snowball at the appropriate part of their animation. + */ +void EnSnowman_ReadySnowball(EnSnowman* this, GlobalContext* globalCtx) { + Vec3f pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18BB4.s") + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x1000); + if ((EN_SNOWMAN_GET_TYPE(&this->actor) != EN_SNOWMAN_TYPE_LARGE) && this->isHoldingSnowball && + ((globalCtx->gameplayFrames % 2) != 0)) { + pos.x = randPlusMinusPoint5Scaled(10.0f) + this->snowballPos.x; + pos.y = randPlusMinusPoint5Scaled(10.0f) + this->snowballPos.y; + pos.z = randPlusMinusPoint5Scaled(10.0f) + this->snowballPos.z; + func_800B0DE0(globalCtx, &pos, &sDustVelocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 500, 30); + } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + if ((this->skelAnime.curFrame > 3.0f) && (this->skelAnime.curFrame < 14.0f) && + ((globalCtx->gameplayFrames % 2) != 0)) { + pos.x = (this->actor.world.pos.x + (70.0f * Math_SinS(this->actor.shape.rot.y))) + + randPlusMinusPoint5Scaled(40.0f); + pos.y = this->actor.world.pos.y + randPlusMinusPoint5Scaled(20.0f); + pos.z = (this->actor.world.pos.z + (70.0f * Math_CosS(this->actor.shape.rot.y))) + + randPlusMinusPoint5Scaled(40.0f); + func_800B0DE0(globalCtx, &pos, &sDustVelocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 1000, 150); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18C7C.s") + if (SkelAnime_Update(&this->skelAnime)) { + EnSnowman_SetupThrowSnowball(this); + } else if (Animation_OnFrame(&this->skelAnime, this->fwork.frameToStartHoldingSnowball)) { + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_HOLD_SNOW); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_MINI_HOLD); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18F50.s") + this->isHoldingSnowball = true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/EnSnowman_Update.s") +void EnSnowman_SetupThrowSnowball(EnSnowman* this) { + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Animation_PlayOnce(&this->skelAnime, &gEenoLargeSnowballThrowAnim); + this->fwork.frameToThrowSnowball = 17.0f; + } else { + Animation_PlayOnce(&this->skelAnime, &gEenoSmallSnowballThrowAnim); + this->fwork.frameToThrowSnowball = 15.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B19474.s") + this->work.snowballsToThrowBeforeIdling--; + this->actionFunc = EnSnowman_ThrowSnowball; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B19718.s") +/** + * Throws the snowball the Eeno is holding at the player. If there are still more snowballs + * to throw before idling, this function is responsible for calling EnSnowman_SetupReadySnowball + * so it can eventually throw another one. Otherwise, this function will call EnSnowman_SetupIdle + * to transition the Eeno into an idle state. + */ +void EnSnowman_ThrowSnowball(EnSnowman* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 params; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/EnSnowman_Draw.s") + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x1000); + if (SkelAnime_Update(&this->skelAnime)) { + if ((this->work.snowballsToThrowBeforeIdling != 0) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && + !(player->stateFlags1 & 0x800000)) { + EnSnowman_SetupReadySnowball(this); + } else { + this->work.snowballsToThrowBeforeIdling = 0; + EnSnowman_SetupIdle(this); + } + } else if (Animation_OnFrame(&this->skelAnime, this->fwork.frameToThrowSnowball)) { + this->isHoldingSnowball = false; + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + params = EN_SNOWMAN_TYPE_LARGE_SNOWBALL; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_THROW); + } else { + params = EN_SNOWMAN_TYPE_SMALL_SNOWBALL; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_MINI_THROW); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B19948.s") + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SNOWMAN, this->snowballPos.x, this->snowballPos.y, + this->snowballPos.z, 0, this->actor.yawTowardsPlayer, 0, params); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B19998.s") +void EnSnowman_SetupIdle(EnSnowman* this) { + Animation_PlayLoop(&this->skelAnime, &gEenoIdleAnim); + this->work.timer = 60; + this->actionFunc = EnSnowman_Idle; +} + +/** + * Simply makes the Eeno wait around for a bit before submerging back into the snow. + */ +void EnSnowman_Idle(EnSnowman* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (this->work.timer > 0) { + this->work.timer--; + } else { + EnSnowman_SetupSubmerge(this, globalCtx); + } +} + +void EnSnowman_SetupSubmerge(EnSnowman* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gEenoEmergeAnim, -1.0f, Animation_GetLastFrame(&gEenoEmergeAnim), 0.0f, + ANIMMODE_ONCE, -3.0f); + EnSnowman_SpawnCircularDustEffect(this, globalCtx); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_HIDE); + this->actionFunc = EnSnowman_Submerge; +} + +/** + * Submerge beneath the snow and become a snow pile. + */ +void EnSnowman_Submerge(EnSnowman* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.scale.y, this->actor.scale.x * 0.4f, + (this->actor.scale.x * 0.6f) / Animation_GetLastFrame(&gEenoEmergeAnim)); + + if (SkelAnime_Update(&this->skelAnime)) { + if (this->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE) { + this->actor.draw = EnSnowman_DrawSnowPile; + this->collider.base.acFlags |= AC_ON; + + // Calling EnSnowman_SetupCombine while EnSnowman_Submerge is our actionFunc will result + // in the broken target scale bug described in EnSnowman_SetupCombine. + EnSnowman_SetupCombine(this, globalCtx, &this->combinePos); + } else { + EnSnowman_SetupMoveSnowPile(this); + } + } +} + +void EnSnowman_SetupMelt(EnSnowman* this) { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 50); + this->collider.base.acFlags &= ~AC_ON; + this->work.timer = 50; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.scale.y = this->actor.scale.x; + this->actor.speedXZ = 0.0f; + this->actionFunc = EnSnowman_Melt; +} + +/** + * Spawns smoke and shrinks the Eeno down until the timer runs out, then kills the Eeno. + */ +void EnSnowman_Melt(EnSnowman* this, GlobalContext* globalCtx) { + Vec3f smokeVelocity; + Vec3f smokePos; + + this->work.timer--; + if ((this->work.timer >= 38) && (!(this->work.timer & 1))) { + smokeVelocity.y = (this->work.timer - 38) * (1.0f / 12.0f); + smokeVelocity.x = randPlusMinusPoint5Scaled(1.5f) * smokeVelocity.y; + smokeVelocity.z = randPlusMinusPoint5Scaled(1.5f) * smokeVelocity.y; + smokeVelocity.y += 0.8f; + smokePos.x = ((smokeVelocity.x >= 0.0f ? 1.0f : -1.0f) * Rand_ZeroFloat(20.0f) * this->eenoScale) + + this->actor.world.pos.x; + smokePos.z = ((smokeVelocity.z >= 0.0f ? 1.0f : -1.0f) * Rand_ZeroFloat(20.0f) * this->eenoScale) + + this->actor.world.pos.z; + smokePos.y = this->actor.world.pos.y + 3.0f; + EffectSsIceSmoke_Spawn(globalCtx, &smokePos, &smokeVelocity, &gZeroVec3f, this->eenoScale * 300.0f); + } + + if (this->work.timer == 0) { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SPLIT) { + EnSnowman_SetupSplitDoNothing(this); + } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Actor_MarkForDeath(this->actor.parent); + Actor_MarkForDeath(this->actor.child); + Actor_MarkForDeath(&this->actor); + } else { + Actor_MarkForDeath(&this->actor); + } + } + + this->actor.scale.y = this->work.timer * 0.0002f * this->eenoScale; + this->actor.scale.x = (this->eenoScale * (1.4f * 0.01f)) - (0.4f * this->actor.scale.y); + this->actor.scale.z = (this->eenoScale * (1.4f * 0.01f)) - (0.4f * this->actor.scale.y); +} + +void EnSnowman_SetupStun(EnSnowman* this) { + if (this->actionFunc != EnSnowman_Stun) { + this->prevActionFunc = this->actionFunc; + } + + this->actionFunc = EnSnowman_Stun; +} + +/** + * Simply makes the Eeno do absolutely nothing until the stun is over. + * Once the stun is over, this swaps the actionFunc back to what it was before the stun. + */ +void EnSnowman_Stun(EnSnowman* this, GlobalContext* globalCtx) { + if (this->actor.colorFilterTimer == 0) { + this->actionFunc = this->prevActionFunc; + } +} + +void EnSnowman_SetupDamaged(EnSnowman* this) { + Animation_PlayLoop(&this->skelAnime, &gEenoDamageAnim); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->collider.base.acFlags &= ~AC_ON; + this->work.timer = 20; + this->actor.draw = EnSnowman_Draw; + this->actor.scale.y = this->actor.scale.x; + this->actor.speedXZ = 10.0f; + func_800BE504(&this->actor, &this->collider); + + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_DAMAGE); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_MINI_DAMAGE); + } + + this->actionFunc = EnSnowman_Damaged; +} + +/** + * Plays the damage animation and spins the Eeno around. + * Once it's done spinning, it will spawn three small split-off Eenos if the Eeno is a large one. + * Otherwise, it will either submerge underground (if it has health remaining) or die. + */ +void EnSnowman_Damaged(EnSnowman* this, GlobalContext* globalCtx) { + s32 rotationalVelocityScale; + + SkelAnime_Update(&this->skelAnime); + rotationalVelocityScale = CLAMP_MAX(this->work.timer, 10); + this->actor.shape.rot.y += rotationalVelocityScale * 0x300; + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Math_StepToF(&this->actor.scale.y, 1.3f * 0.01f, 0.7f * 0.001f); + this->actor.scale.x = this->actor.scale.y; + this->actor.scale.z = this->actor.scale.y; + } + + if (this->work.timer > 0) { + this->work.timer--; + } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_SPLIT); + EnSnowman_SpawnCircularDustEffect(this, globalCtx); + this->drawDmgEffAlpha = 0.0f; + EnSnowman_CreateSplitEeno((EnSnowman*)this->actor.parent, &this->actor.world.pos, + this->actor.shape.rot.y + 0x10000 / 3); + EnSnowman_CreateSplitEeno((EnSnowman*)this->actor.child, &this->actor.world.pos, + this->actor.shape.rot.y - 0x10000 / 3); + EnSnowman_CreateSplitEeno(this, &this->actor.world.pos, this->actor.shape.rot.y); + + // This is a hack to reuse EnSnowman_SpawnBigSnowballFragmentEffects, since it + // draws the fragments at snowballPos. + Math_Vec3f_Copy(&this->snowballPos, &this->actor.world.pos); + EnSnowman_SpawnBigSnowballFragmentEffects(this, globalCtx); + } else if (this->actor.colChkInfo.health != 0) { + this->collider.base.acFlags |= AC_ON; + EnSnowman_SetupSubmerge(this, globalCtx); + } else { + EnSnowman_SetupDead(this); + } +} + +void EnSnowman_SetupDead(EnSnowman* this) { + this->drawDmgEffAlpha = 0.0f; + this->actionFunc = EnSnowman_Dead; +} + +/** + * Spawns snow-colored dust and snowball fragments and kills the Eeno. + */ +void EnSnowman_Dead(EnSnowman* this, GlobalContext* globalCtx) { + static Vec3f sAccel = { 0.0f, -0.5f, 0.0f }; + Vec3f velocity; + Vec3f pos; + s16 altitude; + s16 azimuth; + f32 speed; + s32 i; + + for (i = 0; i < 15; i++) { + altitude = Rand_S16Offset(0x1000, 0x3000); + azimuth = ((u32)Rand_Next() >> 0x10); + speed = Rand_ZeroFloat(2.0f) + 4.0f; + velocity.x = (speed * Math_CosS(altitude)) * Math_SinS(azimuth); + velocity.y = speed * Math_SinS(altitude); + velocity.z = (speed * Math_CosS(altitude)) * Math_CosS(azimuth); + pos.x = (Rand_ZeroFloat(6.0f) * velocity.x) + this->actor.world.pos.x; + pos.y = (Rand_ZeroFloat(3.0f) * velocity.y) + this->actor.world.pos.y; + pos.z = (Rand_ZeroFloat(6.0f) * velocity.z) + this->actor.world.pos.z; + EffectSsHahen_Spawn(globalCtx, &pos, &velocity, &sAccel, 0, + Rand_S16Offset((((i % 3) * 20) + 20), (((i % 3) * 10) + 10)), 452, 20, + sSnowballFragmentDLs[i % 3]); + } + + func_800B0DE0(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 500, + 30); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_YMAJIN_DEAD_BREAK); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SPLIT) { + EnSnowman_SetupSplitDoNothing(this); + } else { + Actor_MarkForDeath(&this->actor); + } +} + +/** + * There are some cases where a split Eeno shouldn't do anything, but we don't want to mark it for death. + * This is because we want to keep it around until *all* split Eenos are killed. + * + * This function is called whenever we want to put a split Eeno into this "do nothing" state. It disables + * collision and turns off drawing for the Eeno. If all three split Eenos are killed, this function is + * responsible for marking all of them for death. + */ +void EnSnowman_SetupSplitDoNothing(EnSnowman* this) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.acFlags &= ~AC_HIT; + this->actor.draw = NULL; + if (this->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE) { + this->combineState = EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION; + } + + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_10); + if ((this->actor.parent != NULL) && (((EnSnowman*)this->actor.parent)->actionFunc == EnSnowman_SplitDoNothing)) { + if ((this->actor.child != NULL) && (((EnSnowman*)this->actor.child)->actionFunc == EnSnowman_SplitDoNothing)) { + EnSnowman_SetupMarkForDeath((EnSnowman*)this->actor.parent); + EnSnowman_SetupMarkForDeath((EnSnowman*)this->actor.child); + Actor_MarkForDeath(&this->actor); + } + } + + this->actionFunc = EnSnowman_SplitDoNothing; +} + +void EnSnowman_SplitDoNothing(EnSnowman* this, GlobalContext* globalCtx) { +} + +/** + * Turns off collision on the Eeno before calling Actor_MarkForDeath on it. + */ +void EnSnowman_SetupMarkForDeath(EnSnowman* this) { + this->collider.base.acFlags &= ~(AC_ON | AC_HIT); + this->collider.base.ocFlags1 &= ~(OC1_ON | OC1_HIT); + this->actionFunc = EnSnowman_MarkForDeath; +} + +/** + * Simply calls Actor_MarkForDeath on the Eeno. + */ +void EnSnowman_MarkForDeath(EnSnowman* this, GlobalContext* globalCtx) { + Actor_MarkForDeath(&this->actor); +} + +/** + * Creates a small split Eeno with a certain Y-rotation and at a certain offset from basePos. + */ +void EnSnowman_CreateSplitEeno(EnSnowman* this, Vec3f* basePos, s32 yRot) { + this->actor.flags |= ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + this->actor.shape.rot.y = yRot; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->combineState = EN_SNOWMAN_COMBINE_STATE_NONE; + this->actor.colChkInfo.health = 2; + this->eenoScale = 1.0f; + this->actor.world.pos.x = (Math_SinS(yRot) * 40.0f) + basePos->x; + this->actor.world.pos.y = basePos->y; + this->actor.world.pos.z = (Math_CosS(yRot) * 40.0f) + basePos->z; + this->combineTimer = 600; + this->actor.params = EN_SNOWMAN_TYPE_SPLIT; + this->actor.flags &= ~ACTOR_FLAG_400; + this->collider.base.ocFlags1 |= OC1_ON; + this->collider.base.acFlags &= ~AC_ON; + EnSnowman_SetupMoveSnowPile(this); +} + +/** + * Absorbs the smaller Eeno into the larger one. The smaller Eeno's target scale is set to + * zero so it gradually disappears, and its collision is disabled, while the larger Eeno's + * target scale increases. + */ +void EnSnowman_AbsorbEeno(EnSnowman* smallerEeno, EnSnowman* largerEeno) { + Actor_PlaySfxAtPos(&largerEeno->actor, NA_SE_EN_YMAJIN_UNITE); + largerEeno->fwork.targetScaleDuringCombine += 0.005f; + smallerEeno->combineState = EN_SNOWMAN_COMBINE_STATE_BEING_ABSORBED_OR_DONE; + smallerEeno->collider.base.ocFlags1 &= ~OC1_HIT; + smallerEeno->collider.base.acFlags &= ~AC_HIT; + smallerEeno->collider.base.ocFlags1 &= ~OC1_ON; + smallerEeno->collider.base.acFlags &= ~AC_ON; + smallerEeno->fwork.targetScaleDuringCombine = 0.0f; +} + +void EnSnowman_SetupCombine(EnSnowman* this, GlobalContext* globalCtx, Vec3f* combinePos) { + if (this->actor.colChkInfo.health == 0) { + this->combineState = EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION; + } else { + this->actor.flags |= ACTOR_FLAG_10; + Math_Vec3f_Copy(&this->combinePos, combinePos); + this->combineState = EN_SNOWMAN_COMBINE_STATE_ACTIVE; + + if (this->actionFunc != EnSnowman_Submerge) { + this->combineTimer = 400; + + //! @bug: Skipping this based the current actionFunc results in whatever is currently in fwork + //! being treated as the target scale when this function is called from EnSnowman_Submerge. + //! Since the only other things that get put in fwork are animation frame numbers, this results + //! in an enormous target scale, potentially creating the so-called "Mega Eeno" glitch. + //! It can still fail to become a Mega Eeno if it gets absorbed before it gets a chance to call + //! EnSnowman_Combine, though. + this->fwork.targetScaleDuringCombine = 0.01f; + } + + //! @bug: If an Eeno is in the middle of submerging, its draw function will still be EnSnowman_Draw. + //! It will call EnSnowman_SetupSubmerge again, resulting in the submerge animation playing twice. + if (this->actor.draw == EnSnowman_DrawSnowPile) { + this->actor.speedXZ = 3.0f; + this->actionFunc = EnSnowman_Combine; + } else { + this->isHoldingSnowball = false; + this->actor.speedXZ = 0.0f; + + // At this point, the combineState is EN_SNOWMAN_COMBINE_STATE_ACTIVE, and the actionFunc + // will be set to EnSnowman_Submerge. When the submerging animation is complete with this + // combineState, EnSnowman_Submerge will call EnSnowman_SetupCombine, causing the broken + // target scale bug described above. + EnSnowman_SetupSubmerge(this, globalCtx); + } + } +} + +/** + * Makes the small, split-off Eenos try to combine into a large Eeno by absorbing each other. + */ +void EnSnowman_Combine(EnSnowman* this, GlobalContext* globalCtx) { + EnSnowman* parent; + EnSnowman* child; + + SkelAnime_Update(&this->snowPileSkelAnime); + parent = (EnSnowman*)this->actor.parent; + child = (EnSnowman*)this->actor.child; + Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->combinePos), 0x1000); + this->actor.world.rot.y = this->actor.shape.rot.y; + + if (this->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE) { + if (this->collider.base.ocFlags1 & OC1_HIT) { + if ((this->collider.base.oc == this->actor.parent) && + (parent->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE)) { + if (this->actor.scale.x < this->actor.parent->scale.x) { + EnSnowman_AbsorbEeno(this, parent); + } else { + EnSnowman_AbsorbEeno(parent, this); + } + } else if ((this->collider.base.oc == this->actor.child) && + (child->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE)) { + if (this->actor.scale.x < this->actor.child->scale.x) { + EnSnowman_AbsorbEeno(this, child); + } else { + EnSnowman_AbsorbEeno(child, this); + } + } + } + + if (parent->combineState == EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION) { + EnSnowman_AbsorbEeno(parent, this); + } + + if (child->combineState == EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION) { + EnSnowman_AbsorbEeno(child, this); + } + } + + if ((this->combineTimer == 0) && (parent->fwork.targetScaleDuringCombine > 0.0f) && + (child->fwork.targetScaleDuringCombine > 0.0f) && (this->fwork.targetScaleDuringCombine < 0.011f) && + (this->combineState != EN_SNOWMAN_COMBINE_STATE_BEING_ABSORBED_OR_DONE)) { + this->combineState = EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION; + this->fwork.targetScaleDuringCombine = 0.0f; + } + + if (Actor_XZDistanceToPoint(&this->actor, &this->combinePos) < 20.0f) { + this->actor.speedXZ = 0.0f; + } + + if (Math_StepToF(&this->actor.scale.x, this->fwork.targetScaleDuringCombine, 0.0005f)) { + if (this->fwork.targetScaleDuringCombine < 0.01f) { + EnSnowman_SetupSplitDoNothing(this); + } else if (this->fwork.targetScaleDuringCombine > 0.018f) { + Actor_SetScale(&this->actor, 0.02f); + this->actor.params = EN_SNOWMAN_TYPE_LARGE; + this->actor.flags |= ACTOR_FLAG_400; + this->collider.base.ocFlags1 |= OC1_ON; + this->combineState = EN_SNOWMAN_COMBINE_STATE_BEING_ABSORBED_OR_DONE; + this->eenoScale = 2.0f; + EnSnowman_SetupMoveSnowPile(this); + } + } + + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; +} + +void EnSnowman_UpdateDamage(EnSnowman* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&this->actor, &this->collider.info); + if ((this->actor.colChkInfo.damageEffect != EN_SNOWMAN_DMGEFF_HOOKSHOT) || + (EN_SNOWMAN_GET_TYPE(&this->actor) != EN_SNOWMAN_TYPE_LARGE)) { + if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_MELT) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_ApplyDamage(&this->actor); + EnSnowman_SetupMelt(this); + } else { + if ((this->actionFunc == EnSnowman_MoveSnowPile) || (this->actionFunc == EnSnowman_Combine)) { + EnSnowman_SetupEmerge(this, globalCtx); + } else if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_STUN) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + EnSnowman_SetupStun(this); + } else if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_ELECTRIC_STUN) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + EnSnowman_SetupStun(this); + } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + if (this->isHoldingSnowball == true) { + this->isHoldingSnowball = false; + EnSnowman_SpawnBigSnowballFragmentEffects(this, globalCtx); + } + + EnSnowman_SetupDamaged(this); + } else { + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + + EnSnowman_SetupDamaged(this); + } + } + + if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_LIGHT_ORB) { + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_LARGE_LIGHT_RAYS); + } + } + } +} + +void EnSnowman_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSnowman* this = THIS; + f32 wallCheckRadius; + + if (this->actionFunc != EnSnowman_SplitDoNothing) { + DECR(this->combineTimer); + + EnSnowman_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + + if (this->actionFunc != EnSnowman_MarkForDeath) { + Actor_MoveWithGravity(&this->actor); + if ((EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) && + (this->actionFunc == EnSnowman_ReadySnowball)) { + wallCheckRadius = (this->skelAnime.curFrame * (1.0f / 60.0f)) + 1.0f; + wallCheckRadius = CLAMP_MAX(wallCheckRadius, 1.3f); + wallCheckRadius *= this->collider.dim.radius; + } else { + wallCheckRadius = this->collider.dim.radius; + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, wallCheckRadius, 0.0f, 0x1D); + if ((this->actor.floorPoly != NULL) && ((this->actor.floorPoly->normal.y * SHT_MINV) < 0.7f)) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); + if (!this->turningOnSteepSlope) { + this->snowPileTargetRotY = Math_FAtan2F(this->actor.floorPoly->normal.z * SHT_MINV, + this->actor.floorPoly->normal.x * SHT_MINV); + this->turningOnSteepSlope = true; + } + } else { + func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->actor.draw == EnSnowman_Draw) { + Actor_SetFocus(&this->actor, this->actor.scale.y * 1800.0f); + } else { + Actor_SetFocus(&this->actor, this->actor.scale.y * 720.0f); + } + + if (this->drawDmgEffAlpha > 0.0f) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } + } + } +} + +void EnSnowman_UpdateSnowball(Actor* thisx, GlobalContext* globalCtx) { + EnSnowman* this = THIS; + s16 scale; + s32 i; + + if (this->work.timer > 0) { + this->work.timer--; + } else { + this->collider.base.ocFlags1 |= OC1_ON; + } + + if ((this->actor.bgCheckFlags & 8) || (this->actor.bgCheckFlags & 1) || (this->actor.bgCheckFlags & 0x10) || + (this->collider.base.atFlags & AT_HIT) || (this->collider.base.acFlags & AC_HIT) || + (this->collider.base.ocFlags1 & OC1_HIT)) { + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { + scale = 10; + for (i = 0; i < 3; i++) { + EffectSsHahen_SpawnBurst(globalCtx, &thisx->world.pos, 5.0f, 0, scale, scale >> 1, 3, 452, 20, + sSnowballFragmentDLs[i]); + scale *= 2; + } + + func_800B0DE0(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, + 500, 30); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_SMALL_SNOWBALL_BROKEN); + } else { + // EnSnowman_SpawnBigSnowballFragmentEffects only fworks with snowballPos, so we need + // to copy the snowball actor's current position into snowballPos to make this fwork. + Math_Vec3f_Copy(&this->snowballPos, &this->actor.world.pos); + EnSnowman_SpawnBigSnowballFragmentEffects(this, globalCtx); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_SNOWBALL_BROKEN); + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_IT_REFLECTION_WOOD); + Actor_MarkForDeath(&this->actor); + } else { + this->actor.shape.rot.x += 0xF00; + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, this->collider.dim.radius * 0.6f, + this->collider.dim.height - this->collider.dim.yShift, 0x1F); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +/** + * This maps a given limb based on its limbIndex to its appropriate index + * in the bodyPartsPos array. An index of -1 indicates that the limb is + * not part of the bodyPartsPos array. + */ +static s8 sLimbIndexToBodyPartsPosIndex[] = { + -1, -1, -1, -1, -1, -1, 0, 1, -1, 2, 3, 4, +}; + +/** + * The last five elements of the bodyPartsPos array are duplicates of the body + * bottom limb, each offset by a certain certain amount. + */ +static Vec3f sBodyBottomBodyPartOffsets[] = { + { 2000.0f, 3000.0f, 0.0f }, { 2000.0f, -2000.0f, 0.0f }, { 3000.0f, 0.0f, 0.0f }, + { 1000.0f, 0.0f, 3000.0f }, { 1000.0f, 0.0f, -3000.0f }, +}; + +void EnSnowman_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnSnowman* this = THIS; + Gfx* gfx; + s32 i; + + if (sLimbIndexToBodyPartsPosIndex[limbIndex] != -1) { + if (sLimbIndexToBodyPartsPosIndex[limbIndex] == 4) { + for (i = 0; i < 5; i++) { + Matrix_MultiplyVector3fByState(&sBodyBottomBodyPartOffsets[i], &this->bodyPartsPos[i + 4]); + } + } else { + Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsPosIndex[limbIndex]]); + } + } + + if ((limbIndex == EENO_LIMB_RIGHT_HAND) && (this->isHoldingSnowball == true)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + if (EN_SNOWMAN_GET_TYPE(thisx) != EN_SNOWMAN_TYPE_LARGE) { + Matrix_InsertTranslation(800.0f, -600.0f, 0.0f, MTXMODE_APPLY); + } else { + Matrix_InsertTranslation(300.0f, -2300.0f, -1900.0f, MTXMODE_APPLY); + Matrix_Scale(0.3f, 0.3f, 0.3f, MTXMODE_APPLY); + } + + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], sSnowballDLs[EN_SNOWMAN_GET_TYPE(&this->actor)]); + + POLY_OPA_DISP = &gfx[2]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + Matrix_GetStateTranslation(&this->snowballPos); + } +} + +void EnSnowman_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSnowman* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnSnowman_PostLimbDraw, &this->actor); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale * this->eenoScale, 0.0f, this->drawDmgEffAlpha, this->drawDmgEffType); +} + +void EnSnowman_DrawSnowPile(Actor* thisx, GlobalContext* globalCtx) { + EnSnowman* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->snowPileSkelAnime.skeleton, this->snowPileSkelAnime.jointTable, + this->snowPileSkelAnime.dListCount, NULL, NULL, &this->actor); +} + +void EnSnowman_DrawSnowball(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, sSnowballDLs[EN_SNOWMAN_GET_TYPE(thisx) - EN_SNOWMAN_TYPE_SMALL_SNOWBALL]); +} diff --git a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.h b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.h index ceb711202..07d7f98c3 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.h +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.h @@ -2,16 +2,56 @@ #define Z_EN_SNOWMAN_H #include "global.h" +#include "objects/object_snowman/object_snowman.h" + +#define EN_SNOWMAN_GET_TYPE(thisx) ((thisx)->params) +#define EN_SNOWMAN_GET_ATTACK_RANGE(thisx) (((thisx)->params >> 8) & 0xFF) + +typedef enum { + /* 0 */ EN_SNOWMAN_TYPE_SMALL, + /* 1 */ EN_SNOWMAN_TYPE_LARGE, + /* 2 */ EN_SNOWMAN_TYPE_SPLIT, + /* 3 */ EN_SNOWMAN_TYPE_SMALL_SNOWBALL, + /* 4 */ EN_SNOWMAN_TYPE_LARGE_SNOWBALL, +} EnSnowmanType; struct EnSnowman; typedef void (*EnSnowmanActionFunc)(struct EnSnowman*, GlobalContext*); typedef struct EnSnowman { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x13C]; - /* 0x0280 */ EnSnowmanActionFunc actionFunc; - /* 0x0284 */ char unk_284[0xF4]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ SkelAnime snowPileSkelAnime; + /* 0x1CC */ Vec3s jointTable[EENO_LIMB_MAX]; + /* 0x214 */ Vec3s morphTable[EENO_LIMB_MAX]; + /* 0x25C */ Vec3s snowPileJointTable[EENO_SNOW_PILE_LIMB_MAX]; + /* 0x26E */ Vec3s snowPileMorphTable[EENO_SNOW_PILE_LIMB_MAX]; + /* 0x280 */ EnSnowmanActionFunc actionFunc; + /* 0x284 */ EnSnowmanActionFunc prevActionFunc; + /* 0x288 */ u8 isHoldingSnowball; + /* 0x289 */ u8 combineState; + /* 0x28A */ u8 turningOnSteepSlope; + /* 0x28B */ u8 drawDmgEffType; + /* 0x28C */ union { + s16 timer; + s16 snowballsToThrowBeforeIdling; + } work; + /* 0x28E */ s16 snowPileTargetRotY; + /* 0x290 */ s16 combineTimer; + /* 0x294 */ f32 eenoScale; + /* 0x298 */ union { + f32 frameToStartHoldingSnowball; + f32 frameToThrowSnowball; + f32 targetScaleDuringCombine; + } fwork; + /* 0x29C */ f32 attackRange; + /* 0x2A0 */ f32 drawDmgEffAlpha; + /* 0x2A4 */ f32 drawDmgEffScale; + /* 0x2A8 */ Vec3f combinePos; + /* 0x2B4 */ Vec3f snowballPos; + /* 0x2C0 */ Vec3f bodyPartsPos[9]; + /* 0x32C */ ColliderCylinder collider; } EnSnowman; // size = 0x378 extern const ActorInit En_Snowman_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index fe4697ca9..4967ab0a2 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -13112,43 +13112,43 @@ 0x80B16808:("BgHakuginSwitch_Draw",), 0x80B16B00:("EnSnowman_Init",), 0x80B16F94:("EnSnowman_Destroy",), - 0x80B16FC0:("func_80B16FC0",), - 0x80B17144:("func_80B17144",), - 0x80B173D0:("func_80B173D0",), - 0x80B1746C:("func_80B1746C",), - 0x80B177EC:("func_80B177EC",), - 0x80B178B8:("func_80B178B8",), - 0x80B179D0:("func_80B179D0",), - 0x80B17A58:("func_80B17A58",), - 0x80B17CE8:("func_80B17CE8",), - 0x80B17D78:("func_80B17D78",), - 0x80B17EB4:("func_80B17EB4",), - 0x80B17EFC:("func_80B17EFC",), - 0x80B17F4C:("func_80B17F4C",), - 0x80B17FE0:("func_80B17FE0",), - 0x80B180A4:("func_80B180A4",), - 0x80B18124:("func_80B18124",), - 0x80B18380:("func_80B18380",), - 0x80B183A4:("func_80B183A4",), - 0x80B183C4:("func_80B183C4",), - 0x80B1848C:("func_80B1848C",), - 0x80B18600:("func_80B18600",), - 0x80B1861C:("func_80B1861C",), - 0x80B18908:("func_80B18908",), - 0x80B189C4:("func_80B189C4",), - 0x80B189D4:("func_80B189D4",), - 0x80B18A04:("func_80B18A04",), - 0x80B18A28:("func_80B18A28",), - 0x80B18B30:("func_80B18B30",), - 0x80B18BB4:("func_80B18BB4",), - 0x80B18C7C:("func_80B18C7C",), - 0x80B18F50:("func_80B18F50",), + 0x80B16FC0:("EnSnowman_SpawnCircularDustEffect",), + 0x80B17144:("EnSnowman_SpawnBigSnowballFragmentEffects",), + 0x80B173D0:("EnSnowman_SetupMoveSnowPile",), + 0x80B1746C:("EnSnowman_MoveSnowPile",), + 0x80B177EC:("EnSnowman_SetupEmerge",), + 0x80B178B8:("EnSnowman_Emerge",), + 0x80B179D0:("EnSnowman_SetupReadySnowball",), + 0x80B17A58:("EnSnowman_ReadySnowball",), + 0x80B17CE8:("EnSnowman_SetupThrowSnowball",), + 0x80B17D78:("EnSnowman_ThrowSnowball",), + 0x80B17EB4:("EnSnowman_SetupIdle",), + 0x80B17EFC:("EnSnowman_Idle",), + 0x80B17F4C:("EnSnowman_SetupSubmerge",), + 0x80B17FE0:("EnSnowman_Submerge",), + 0x80B180A4:("EnSnowman_SetupMelt",), + 0x80B18124:("EnSnowman_Melt",), + 0x80B18380:("EnSnowman_SetupStun",), + 0x80B183A4:("EnSnowman_Stun",), + 0x80B183C4:("EnSnowman_SetupDamaged",), + 0x80B1848C:("EnSnowman_Damaged",), + 0x80B18600:("EnSnowman_SetupDead",), + 0x80B1861C:("EnSnowman_Dead",), + 0x80B18908:("EnSnowman_SetupSplitDoNothing",), + 0x80B189C4:("EnSnowman_SplitDoNothing",), + 0x80B189D4:("EnSnowman_SetupMarkForDeath",), + 0x80B18A04:("EnSnowman_MarkForDeath",), + 0x80B18A28:("EnSnowman_CreateSplitEeno",), + 0x80B18B30:("EnSnowman_AbsorbEeno",), + 0x80B18BB4:("EnSnowman_SetupCombine",), + 0x80B18C7C:("EnSnowman_Combine",), + 0x80B18F50:("EnSnowman_UpdateDamage",), 0x80B1918C:("EnSnowman_Update",), - 0x80B19474:("func_80B19474",), - 0x80B19718:("func_80B19718",), + 0x80B19474:("EnSnowman_UpdateSnowball",), + 0x80B19718:("EnSnowman_PostLimbDraw",), 0x80B198B0:("EnSnowman_Draw",), - 0x80B19948:("func_80B19948",), - 0x80B19998:("func_80B19998",), + 0x80B19948:("EnSnowman_DrawSnowPile",), + 0x80B19998:("EnSnowman_DrawSnowball",), 0x80B19F60:("TGSw_ActionDecider",), 0x80B1A008:("TGSw_ActionExecuteOneShot",), 0x80B1A15C:("TGSw_Init",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 6b1a7fcb7..5827c7261 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -13908,10 +13908,8 @@ 0x80B19AAC:("D_80B19AAC","UNK_TYPE1","",0x1), 0x80B19AB8:("D_80B19AB8","UNK_TYPE1","",0x1), 0x80B19AC4:("D_80B19AC4","UNK_TYPE1","",0x1), - 0x80B19AD0:("D_80B19AD0","UNK_TYPE1","",0x1), - 0x80B19ADA:("D_80B19ADA","UNK_TYPE1","",0x1), - 0x80B19ADC:("D_80B19ADC","UNK_TYPE1","",0x1), - 0x80B19B18:("D_80B19B18","UNK_TYPE1","",0x1), + 0x80B19AD0:("D_80B19AD0","s8","[12]",0xC), + 0x80B19ADC:("D_80B19ADC","Vec3f","[5]",0x3C), 0x80B19B20:("D_80B19B20","f32","",0x4), 0x80B19B24:("D_80B19B24","f32","",0x4), 0x80B19B28:("D_80B19B28","f32","",0x4), diff --git a/undefined_syms.txt b/undefined_syms.txt index 1ef7e6942..1567d0b70 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1458,19 +1458,6 @@ D_06000650 = 0x06000650; D_06000828 = 0x06000828; D_06000A10 = 0x06000A10; -// ovl_En_Snowman - -D_06000404 = 0x06000404; -D_060007B4 = 0x060007B4; -D_060045A0 = 0x060045A0; -D_06004628 = 0x06004628; -D_060046D8 = 0x060046D8; -D_06004A90 = 0x06004A90; -D_06004F14 = 0x06004F14; -D_0600544C = 0x0600544C; -D_0600554C = 0x0600554C; -D_060058CC = 0x060058CC; - // ovl_En_Snowwd D_06000198 = 0x06000198; From 3374f41d1ceeb46cb1c82e5b2529dfb5ffbe563c Mon Sep 17 00:00:00 2001 From: Parker Burnett Date: Wed, 25 May 2022 18:16:04 -0600 Subject: [PATCH 210/257] En_wiz_brock OK and documented (#817) * wiz brock OK * wiz_brok OK and documented * fixing text * fixing PR comments * addressing PR * fixing comma for format --- assets/xml/objects/object_wiz.xml | 6 +- spec | 3 +- .../actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c | 119 ++++++++++++++++-- .../actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h | 12 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 7 -- 6 files changed, 123 insertions(+), 28 deletions(-) diff --git a/assets/xml/objects/object_wiz.xml b/assets/xml/objects/object_wiz.xml index d9c8a1589..947cab3c7 100644 --- a/assets/xml/objects/object_wiz.xml +++ b/assets/xml/objects/object_wiz.xml @@ -8,7 +8,7 @@ - + @@ -40,11 +40,11 @@ - + - + diff --git a/spec b/spec index f6b19ee8a..e62c6ef3b 100644 --- a/spec +++ b/spec @@ -2837,8 +2837,7 @@ beginseg name "ovl_En_Wiz_Brock" compress include "build/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.o" - include "build/data/ovl_En_Wiz_Brock/ovl_En_Wiz_Brock.data.o" - include "build/data/ovl_En_Wiz_Brock/ovl_En_Wiz_Brock.reloc.o" + include "build/src/overlays/actors/ovl_En_Wiz_Brock/ovl_En_Wiz_Brock_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c index d6ae08331..d3fffb667 100644 --- a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c +++ b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c @@ -5,17 +5,29 @@ */ #include "z_en_wiz_brock.h" +#include "objects/object_wiz/object_wiz.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_8000000) #define THIS ((EnWizBrock*)thisx) +typedef enum { + PLATFORM_TYPE_INACTIVE, + PLATFORM_TYPE_FIRE, + PLATFORM_TYPE_ICE, + PLATFORM_TYPE_MAX, +} PlatformType; + void EnWizBrock_Init(Actor* thisx, GlobalContext* globalCtx); void EnWizBrock_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWizBrock_Update(Actor* thisx, GlobalContext* globalCtx); void EnWizBrock_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnWizBrock_SetupUpdateStatus(EnWizBrock* this, GlobalContext* globalCtx); +void EnWizBrock_UpdateStatus(EnWizBrock* this, GlobalContext* globalCtx); + +s16 platformCount = 0; + const ActorInit En_Wiz_Brock_InitVars = { ACTOR_EN_WIZ_BROCK, ACTORCAT_PROP, @@ -28,19 +40,106 @@ const ActorInit En_Wiz_Brock_InitVars = { (ActorFunc)EnWizBrock_Draw, }; -#endif +void EnWizBrock_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWizBrock* this = THIS; + CollisionHeader* colHeader = NULL; -extern UNK_TYPE D_060010E8; -extern UNK_TYPE D_06001690; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_wiz_Colheader_001690, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + this->dyna.actor.colChkInfo.health = 3; + this->unk_1A6 = 0; + Actor_SetScale(&this->dyna.actor, 0.01f); + this->platformNum = platformCount++; + this->actionFunc = EnWizBrock_SetupUpdateStatus; + this->dyna.actor.scale.x = this->dyna.actor.scale.y = this->dyna.actor.scale.z = 0.01f; + this->alpha = 255.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/EnWizBrock_Init.s") +void EnWizBrock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWizBrock* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/EnWizBrock_Destroy.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/func_80A490E4.s") +void EnWizBrock_SetupUpdateStatus(EnWizBrock* this, GlobalContext* globalCtx) { + this->actionFunc = EnWizBrock_UpdateStatus; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/func_80A490FC.s") +/** + * @brief Checks the platform status, when the Wizzrobe is defeated, which triggers timer to + * count up to 30 at which point the platforms are despawned. + */ +void EnWizBrock_UpdateStatus(EnWizBrock* this, GlobalContext* globalCtx) { + if (this->platformType == PLATFORM_TYPE_INACTIVE) { + if (this->dyna.actor.colChkInfo.health != PLATFORM_TYPE_MAX) { + this->platformType = this->dyna.actor.colChkInfo.health; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/EnWizBrock_Update.s") + if (this->dyna.actor.colChkInfo.health == 0) { + this->timer++; + if (this->timer > (BREG(49) + 30)) { + Math_ApproachZeroF(&this->dyna.actor.scale.y, (BREG(50) / 10.0f) + 0.3f, (BREG(51) / 10000.0f) + 0.003f); + Math_ApproachZeroF(&this->alpha, (BREG(52) / 10.0f) + 1.0f, (BREG(53) / 10.0f) + 35.0f); + Math_ApproachF(&this->dyna.actor.scale.x, (BREG(54) / 100.0f) + 0.02f, (BREG(55) / 100.0f) + 0.2f, + (BREG(56) / 1000.0f) + 0.002f); + this->dyna.actor.scale.z = this->dyna.actor.scale.x; + if (this->dyna.actor.scale.y < 0.001f) { + Actor_MarkForDeath(&this->dyna.actor); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz_Brock/EnWizBrock_Draw.s") +void EnWizBrock_Update(Actor* thisx, GlobalContext* globalCtx) { + EnWizBrock* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void EnWizBrock_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnWizBrock* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); + if (this->dyna.actor.colChkInfo.health != 0) { + Scene_SetRenderModeXlu(globalCtx, 0, 1); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + Gfx_DrawDListOpa(globalCtx, gWizzrobePlatform); + + } else { + Scene_SetRenderModeXlu(globalCtx, 1, 2); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, (s16)this->alpha); + Gfx_DrawDListXlu(globalCtx, gWizzrobePlatform); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (this->platformType != PLATFORM_TYPE_INACTIVE) { + OPEN_DISPS(globalCtx->state.gfxCtx); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&gWizzrobePlatformTexAnim)); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); + if (this->platformType == PLATFORM_TYPE_FIRE) { + gDPSetEnvColor(POLY_XLU_DISP++, 255, 00, 100, (s16)this->alpha); + } else { + gDPSetEnvColor(POLY_XLU_DISP++, 50, 00, 255, (s16)this->alpha); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, &gWizzrobePlatformCenter); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h index 30932c5ac..ac900777e 100644 --- a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h +++ b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h @@ -8,10 +8,14 @@ struct EnWizBrock; typedef void (*EnWizBrockActionFunc)(struct EnWizBrock*, GlobalContext*); typedef struct EnWizBrock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x5C]; - /* 0x01A0 */ EnWizBrockActionFunc actionFunc; - /* 0x01A4 */ char unk_1A4[0xC]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ UNK_TYPE1 unk_15C[0x44]; + /* 0x1A0 */ EnWizBrockActionFunc actionFunc; + /* 0x1A4 */ s16 timer; // Counter for despawing blocks (Max of 37) + /* 0x1A6 */ s16 unk_1A6; // TODO: set but not used maybe used in wizzrobe? + /* 0x1A8 */ s16 platformNum; // Numeric identifier for platform + /* 0x1AA */ s16 platformType; // Determines element type for platform (ice/fire) + /* 0x1AC */ f32 alpha; } EnWizBrock; // size = 0x1B0 extern const ActorInit En_Wiz_Brock_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4967ab0a2..eac58c3e6 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10469,8 +10469,8 @@ 0x80A483B4:("EnWiz_Draw",), 0x80A48FE0:("EnWizBrock_Init",), 0x80A490B0:("EnWizBrock_Destroy",), - 0x80A490E4:("func_80A490E4",), - 0x80A490FC:("func_80A490FC",), + 0x80A490E4:("EnWizBrock_SetupUpdateStatus",), + 0x80A490FC:("EnWizBrock_UpdateStatus",), 0x80A492E4:("EnWizBrock_Update",), 0x80A49308:("EnWizBrock_Draw",), 0x80A496A0:("EnWizFire_Init",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 1567d0b70..1d5ea0bd3 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1555,13 +1555,6 @@ D_060025F0 = 0x060025F0; D_060066C0 = 0x060066C0; D_0600B320 = 0x0600B320; -// ovl_En_Wiz_Brock - -D_060010E8 = 0x060010E8; -D_06001690 = 0x06001690; -D_06005870 = 0x06005870; -D_06005C64 = 0x06005C64; - // ovl_En_Zl4 D_06013328 = 0x06013328; From 6f2531cc66824ba7e09de5983bef71542c1b7dcb Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 25 May 2022 17:55:04 -0700 Subject: [PATCH 211/257] Door_Warp1 OK (#816) * Match doorwarp1 * pad --- spec | 4 - .../actors/ovl_Door_Warp1/z_door_warp1.c | 89 +++++++------------ 2 files changed, 33 insertions(+), 60 deletions(-) diff --git a/spec b/spec index e62c6ef3b..83cc52b26 100644 --- a/spec +++ b/spec @@ -1026,11 +1026,7 @@ beginseg name "ovl_Door_Warp1" compress include "build/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_Door_Warp1/ovl_Door_Warp1_reloc.o" -#else - include "build/data/ovl_Door_Warp1/ovl_Door_Warp1.reloc.o" -#endif endseg beginseg diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index dd41ac015..163619876 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -1019,11 +1019,9 @@ void func_808BB4C4(DoorWarp1* this, GlobalContext* globalCtx) { Gfx_DrawDListOpa(globalCtx, object_warp1_DL_0076C0); } -#ifdef NON_MATCHING -// GraphicsContext should be compiler-managed? void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; - GraphicsContext* gfxCtx; + s32 pad; Color_RGB8 sp64[] = { { 50, 150, 0 }, { 100, 150, 200 }, @@ -1065,7 +1063,10 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_004690); - gfxCtx = globalCtx->state.gfxCtx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_warp1_Matanimheader_007238)); Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, @@ -1073,10 +1074,6 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { Matrix_RotateY(this->dyna.actor.world.rot.y, MTXMODE_APPLY); Matrix_Scale(1.0f, 0.0f, 1.0f, MTXMODE_APPLY); - CLOSE_DISPS(globalCtx->state.gfxCtx); - - OPEN_DISPS(gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, sp64[sp60].r, sp64[sp60].g, sp64[sp60].b, 255); @@ -1086,16 +1083,6 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -#else -static Color_RGB8 D_808BBB50[] = { - { 50, 150, 0 }, - { 100, 150, 200 }, - { 0, 50, 200 }, - { 120, 150, 0 }, -}; -void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BB4F4.s") -#endif void DoorWarp1_Draw(Actor* thisx, GlobalContext* globalCtx) { DoorWarp1* this = THIS; @@ -1123,54 +1110,44 @@ void DoorWarp1_Draw(Actor* thisx, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// casting/macro on temp_s1/s0 void func_808BB8D4(DoorWarp1* this, GlobalContext* globalCtx, s32 arg2) { - static Vec3f D_808BBB5C = { 0.0f, 0.05f, 0.0f }; - static Vec3f D_808BBB68 = { 0.0f, 0.25f, 0.0f }; - Vec3f sp9C; - Color_RGBA8 sp98; - Color_RGBA8 sp94; + static Vec3f sVelocity = { 0.0f, 0.05f, 0.0f }; + static Vec3f sAccel = { 0.0f, 0.25f, 0.0f }; + Vec3f pos; + Color_RGBA8 primColor; + Color_RGBA8 envColor; s32 i; - s16 temp_s0; - s32 temp_s1; - s32 phi_s2; + s32 rand; + s16 scale; + s32 life; for (i = 0; i < arg2; i++) { - temp_s1 = (Rand_ZeroOne() * 0x10000); - temp_s0 = temp_s1 - 0x8000; + rand = (Rand_ZeroOne() * 0x10000); - sp9C.x = (-Math_SinS(temp_s0) * 35.0f) + this->dyna.actor.world.pos.x; - sp9C.y = this->dyna.actor.world.pos.y; - temp_s0 = (s16)(temp_s1 - 0x8000); - sp9C.z = Math_CosS(temp_s0) * 35.0f + this->dyna.actor.world.pos.z; + pos.x = (-Math_SinS(rand - 0x8000) * 35.0f) + this->dyna.actor.world.pos.x; + pos.y = this->dyna.actor.world.pos.y; + pos.z = (Math_CosS(rand - 0x8000) * 35.0f) + this->dyna.actor.world.pos.z; - D_808BBB5C.x = 0.0f; - D_808BBB68.y = 0.25f; + primColor.r = 255; + primColor.g = 255; + primColor.b = 255; + envColor.r = 200; + envColor.g = 200; + envColor.b = 255; - sp98.r = 255; - sp98.g = 255; - sp98.b = 255; - sp94.r = 200; - sp94.g = 200; - sp94.b = 255; + sAccel.y = 0.25f; + sVelocity.x = 0.0f; + sVelocity.z = 0.0f; - D_808BBB5C.z = 0.0f; + scale = (Rand_ZeroOne() * 1000.0f) + 800.0f; - temp_s1 = (s16)((Rand_ZeroOne() * 1000.0f) + 800.0f); - - phi_s2 = 27; + life = 27; if (arg2 >= 2) { - phi_s2 = 8; - D_808BBB68.y = 1.8f; - D_808BBB5C.x = -Math_SinS(temp_s0) * 5.0f; - D_808BBB5C.z = Math_CosS(temp_s0) * 5.0f; + life = 8; + sAccel.y = 1.8f; + sVelocity.x = -Math_SinS(rand - 0x8000) * 5.0f; + sVelocity.z = Math_CosS(rand - 0x8000) * 5.0f; } - EffectSsKiraKira_SpawnDispersed(globalCtx, &sp9C, &D_808BBB5C, &D_808BBB68, &sp98, &sp94, temp_s1, phi_s2); + EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &sVelocity, &sAccel, &primColor, &envColor, scale, life); } } -#else -static Vec3f D_808BBB5C = { 0.0f, 0.05f, 0.0f }; -static Vec3f D_808BBB68 = { 0.0f, 0.25f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Warp1/func_808BB8D4.s") -#endif From e227684d9b35c8bb05bd0f1b9912487a6a4b0021 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Thu, 26 May 2022 02:04:10 +0100 Subject: [PATCH 212/257] En_Boom (#813) * En_Boom * Match (thanks Anon) * Update src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c Co-authored-by: Derek Hensley Co-authored-by: Anghelo Carvajal Co-authored-by: Derek Hensley --- include/functions.h | 2 +- include/z64actor.h | 3 + spec | 3 +- src/code/z_en_item00.c | 4 +- .../actors/ovl_Arms_Hook/z_arms_hook.c | 4 +- .../actors/ovl_Arms_Hook/z_arms_hook.h | 3 +- src/overlays/actors/ovl_En_Arrow/z_en_arrow.c | 9 +- src/overlays/actors/ovl_En_Arrow/z_en_arrow.h | 8 +- src/overlays/actors/ovl_En_Boom/z_en_boom.c | 319 ++++++++++++++++-- src/overlays/actors/ovl_En_Boom/z_en_boom.h | 10 +- tools/disasm/variables.txt | 24 +- 11 files changed, 331 insertions(+), 58 deletions(-) diff --git a/include/functions.h b/include/functions.h index 622dfcffb..0f3a2e671 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2051,7 +2051,7 @@ s32 func_801242B4(Player* player); // void func_80125D4C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_801262C8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_801263FC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -s32 func_80126440(GlobalContext* globalCtx, Collider* param_2, s32* param_3, Vec3f* param_4, Vec3f* param_5); +s32 func_80126440(GlobalContext* globalCtx, ColliderQuad* collider, WeaponInfo* weaponInfo, Vec3f* arg3, Vec3f* arg4); // void func_801265C8(void); // void func_8012669C(void); // void func_80126808(void); diff --git a/include/z64actor.h b/include/z64actor.h index ee73ae8af..c7724bcd7 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -256,6 +256,9 @@ struct EnItem00; typedef void (*EnItem00ActionFunc)(struct EnItem00*, struct GlobalContext*); +#define ENITEM00_GET_8000(thisx) ((thisx)->params & 0x8000) +#define ENITEM00_GET_7F00(thisx) (((thisx)->params & 0x7F00) >> 8) + typedef struct EnItem00 { /* 0x000 */ Actor actor; /* 0x144 */ EnItem00ActionFunc actionFunc; diff --git a/spec b/spec index 83cc52b26..46402feea 100644 --- a/spec +++ b/spec @@ -924,8 +924,7 @@ beginseg name "ovl_En_Boom" compress include "build/src/overlays/actors/ovl_En_Boom/z_en_boom.o" - include "build/data/ovl_En_Boom/ovl_En_Boom.data.o" - include "build/data/ovl_En_Boom/ovl_En_Boom.reloc.o" + include "build/src/overlays/actors/ovl_En_Boom/ovl_En_Boom_reloc.o" endseg beginseg diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index b8fa0f4f1..3bec8471b 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -68,9 +68,9 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { f32 shadowOffset = 980.0f; f32 shadowScale = 6.0f; s32 getItemId = GI_NONE; - s32 sp30 = (this->actor.params & 0x8000) ? 1 : 0; + s32 sp30 = ENITEM00_GET_8000(&this->actor) ? 1 : 0; - this->collectibleFlag = (this->actor.params & 0x7F00) >> 8; + this->collectibleFlag = ENITEM00_GET_7F00(&this->actor); thisx->params &= 0xFF; // Has to be thisx to match diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index 009405238..b0a61382c 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -312,13 +312,13 @@ void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_MultiplyVector3fByState(&D_808C1C10, &this->unk1E0); Matrix_MultiplyVector3fByState(&D_808C1C28, &sp5C); Matrix_MultiplyVector3fByState(&D_808C1C34, &sp50); - this->unk1C4 = 0; + this->unk1C4.active = false; } else { Matrix_MultiplyVector3fByState(&D_808C1C1C, &this->unk1E0); Matrix_MultiplyVector3fByState(&D_808C1C40, &sp5C); Matrix_MultiplyVector3fByState(&D_808C1C4C, &sp50); } - func_80126440(globalCtx, &this->collider.base, &this->unk1C4, &sp5C, &sp50); + func_80126440(globalCtx, &this->collider, &this->unk1C4, &sp5C, &sp50); func_8012C28C(globalCtx->state.gfxCtx); func_80122868(globalCtx, player); diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h index ecccf5ff0..527d37b61 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h @@ -10,8 +10,7 @@ typedef void (*ArmsHookActionFunc)(struct ArmsHook*, GlobalContext*); typedef struct ArmsHook { /* 0x000 */ Actor actor; /* 0x144 */ ColliderQuad collider; - /* 0x1C4 */ s32 unk1C4; - /* 0x1C8 */ char unk1C8[0x18]; + /* 0x1C4 */ WeaponInfo unk1C4; /* 0x1E0 */ Vec3f unk1E0; /* 0x1EC */ Vec3f unk1EC; /* 0x1F8 */ Actor* grabbed; diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index f1dc5c6f6..45cc5bdae 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -581,7 +581,7 @@ void func_8088B88C(GlobalContext* globalCtx, EnArrow* this, EnArrowUnkStruct* ar Matrix_MultiplyVector3fByState(&arg2->unk_48, &this->unk_234); if (func_8088ACE0 == this->actionFunc) { - if (this->unk_244 == 0) { + if (!this->unk_244.active) { sp4C = arg2->unk_00; } else { sp4C = arg2->unk_18[globalCtx->gameplayFrames % 2]; @@ -591,9 +591,10 @@ void func_8088B88C(GlobalContext* globalCtx, EnArrow* this, EnArrowUnkStruct* ar if (this->actor.params < ENARROW_8) { sp30 = this->actor.params < ENARROW_6; if (this->unk_264 == 0) { - sp30 &= func_80126440(globalCtx, &this->collider.base, &this->unk_244, &sp40, &sp34); - } else if (sp30 && (sp40.x == this->unk_248) && (sp40.y == this->unk_24C) && (sp40.z == this->unk_250) && - (sp34.x == this->unk_254) && (sp34.y == this->unk_258) && (sp34.z == this->unk_25C)) { + sp30 &= func_80126440(globalCtx, &this->collider, &this->unk_244, &sp40, &sp34); + } else if (sp30 && (sp40.x == this->unk_244.tip.x) && (sp40.y == this->unk_244.tip.y) && + (sp40.z == this->unk_244.tip.z) && (sp34.x == this->unk_244.base.x) && + (sp34.y == this->unk_244.base.y) && (sp34.z == this->unk_244.base.z)) { sp30 = false; } if (sp30) { diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h index f318cf152..654e8bea6 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h @@ -43,13 +43,7 @@ typedef struct EnArrow { /* 0x228 */ Vec3f unk_228; /* 0x234 */ Vec3f unk_234; /* 0x240 */ s32 unk_240; - /* 0x244 */ s32 unk_244; - /* 0x248 */ f32 unk_248; - /* 0x24C */ f32 unk_24C; - /* 0x250 */ f32 unk_250; - /* 0x254 */ f32 unk_254; - /* 0x258 */ f32 unk_258; - /* 0x25C */ f32 unk_25C; + /* 0x244 */ WeaponInfo unk_244; /* 0x260 */ u8 unk_260; // timer in OoT /* 0x261 */ u8 unk_261; // hitFlags in OoT /* 0x262 */ u8 unk_262; diff --git a/src/overlays/actors/ovl_En_Boom/z_en_boom.c b/src/overlays/actors/ovl_En_Boom/z_en_boom.c index 930b1b597..15347d0ea 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -5,6 +5,7 @@ */ #include "z_en_boom.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,11 +16,9 @@ void EnBoom_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBoom_Update(Actor* thisx, GlobalContext* globalCtx); void EnBoom_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBoom_SetupAction(EnBoom* this, EnBoomActionFunc actionFunc); void func_808A2918(EnBoom* this, GlobalContext* globalCtx); -void EnBoom_SetupAction(EnBoom* this, EnBoomActionFunc actionFunc); - -#if 0 const ActorInit En_Boom_InitVars = { ACTOR_EN_BOOM, ACTORCAT_ITEMACTION, @@ -32,34 +31,316 @@ const ActorInit En_Boom_InitVars = { (ActorFunc)EnBoom_Draw, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_808A3010 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_TYPE_PLAYER, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK2, { 0x00000010, 0x00, 0x02 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_NEAREST | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_TYPE_PLAYER, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK2, + { 0x00000010, 0x00, 0x02 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_NEAREST | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808A3060[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(targetMode, 5, ICHAIN_CONTINUE), ICHAIN_VEC3S(shape.rot, 0, ICHAIN_STOP), }; -#endif +void EnBoom_SetupAction(EnBoom* this, EnBoomActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern ColliderQuadInit D_808A3010; -extern InitChainEntry D_808A3060[]; +void func_808A24DC(EnBoom* this, GlobalContext* globalCtx) { + WaterBox* sp54; + f32 sp50 = this->actor.world.pos.y; + u16 sp4E = this->actor.bgCheckFlags & 0x20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/EnBoom_SetupAction.s") + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, + &sp54) && + (this->actor.world.pos.y < sp50)) { + Vec3f sp40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/func_808A24DC.s") + this->actor.bgCheckFlags |= 0x20; + sp40.x = this->actor.world.pos.x; + sp40.y = this->actor.world.pos.y - 20.0f; + sp40.z = this->actor.world.pos.z; + EffectSsBubble_Spawn(globalCtx, &sp40, 20.0f, 10.0f, 20.0f, 0.13f); + } else { + this->actor.bgCheckFlags &= ~0x20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/EnBoom_Init.s") + if ((this->actor.bgCheckFlags & 0x40) && ((this->actor.bgCheckFlags & 0x20) != sp4E)) { + Vec3f sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/EnBoom_Destroy.s") + Math_Vec3f_Diff(&this->actor.world.pos, &this->actor.prevPos, &sp34); + if (sp34.y != 0.0f) { + f32 temp_fv0 = sqrtf(SQ(sp34.x) + SQ(sp34.z)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/func_808A2918.s") + if (temp_fv0 != 0.0f) { + temp_fv0 = (((sp50 - this->actor.prevPos.y) / sp34.y) * temp_fv0) / temp_fv0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/EnBoom_Update.s") + sp34.x = this->actor.prevPos.x + (sp34.x * temp_fv0); + sp34.y = sp50; + sp34.z = this->actor.prevPos.z + (sp34.z * temp_fv0); + EffectSsGSplash_Spawn(globalCtx, &sp34, NULL, NULL, 0, 300); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Boom/EnBoom_Draw.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); + + EffectSsGRipple_Spawn(globalCtx, &sp34, 100, 500, 0); + EffectSsGRipple_Spawn(globalCtx, &sp34, 100, 500, 4); + EffectSsGRipple_Spawn(globalCtx, &sp34, 100, 500, 8); + } + + this->actor.bgCheckFlags |= 0x40; +} + +void EnBoom_Init(Actor* thisx, GlobalContext* globalCtx) { + static u8 D_808A3068[4] = { 255, 255, 100, 255 }; + static u8 D_808A306C[4] = { 255, 255, 100, 64 }; + static u8 D_808A3070[4] = { 255, 255, 100, 0 }; + static u8 D_808A3074[4] = { 255, 255, 100, 0 }; + s32 pad; + EnBoom* this = THIS; + EffectBlureInit1 sp30; + s32 i; + + this->actor.room = -1; + Actor_ProcessInitChain(&this->actor, sInitChain); + + for (i = 0; i < 4; i++) { + sp30.p1StartColor[i] = D_808A3068[i]; + sp30.p2StartColor[i] = D_808A306C[i]; + sp30.p1EndColor[i] = D_808A3070[i]; + sp30.p2EndColor[i] = D_808A3074[i]; + } + + sp30.elemDuration = 8; + sp30.unkFlag = 0; + sp30.calcMode = 0; + + Effect_Add(globalCtx, &this->effectIndex, 1, 0, 0, &sp30); + + Collider_InitQuad(globalCtx, &this->collider); + Collider_SetQuad(globalCtx, &this->collider, &this->actor, &sQuadInit); + EnBoom_SetupAction(this, func_808A2918); +} + +void EnBoom_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBoom* this = THIS; + Player* player = GET_PLAYER(globalCtx); + Actor* temp; + + if (player != NULL) { + Effect_Destroy(globalCtx, this->effectIndex); + Collider_DestroyQuad(globalCtx, &this->collider); + + temp = this->actor.child; + if (temp != NULL) { + temp->parent = NULL; + player->boomerangActor = temp; + } else { + temp = this->actor.parent; + if (temp != NULL) { + temp->child = NULL; + } else { + player->boomerangActor = NULL; + player->stateFlags1 &= ~0x2000000; + } + } + player->stateFlags3 |= 0x800000; + } +} + +void func_808A2918(EnBoom* this, GlobalContext* globalCtx) { + Actor* sp7C; + Player* player = GET_PLAYER(globalCtx); + s32 sp74; + s16 sp72; + s16 sp70; + s16 sp6E; + s16 sp6C; + Actor* temp; + f32 sp64; + f32 distXYZ; + + sp7C = this->player; + + if (sp7C != NULL) { + sp72 = Actor_YawToPoint(&this->actor, &sp7C->focus.pos); + sp70 = this->actor.world.rot.y - sp72; + sp6E = Actor_PitchToPoint(&this->actor, &sp7C->focus.pos); + sp6C = this->actor.world.rot.x - sp6E; + + sp64 = (200.0f - Math_Vec3f_DistXYZ(&this->actor.world.pos, &sp7C->focus.pos)) * 0.005f; + if (sp64 < 0.12f) { + sp64 = 0.12f; + } + + if ((&player->actor != sp7C) && ((sp7C->update == NULL) || ((this->unk_1CF < 0) && (ABS_ALT(sp70) > 0x4000)))) { + this->player = NULL; + } else { + if (this->unk_1CE != 0) { + this->unk_1CE--; + this->actor.world.rot.y += (this->actor.params == 0) ? 0x190 : -0x190; + } else { + if (this->unk_1CF > 0) { + this->unk_1CF--; + } else { + this->unk_1CF = -1; + } + + Math_ScaledStepToS(&this->actor.world.rot.y, sp72, + (this->unk_1CF > 0) ? 1000 : (s16)(((sp70 < 0) ? -sp70 : sp70) * sp64)); + } + + Math_ScaledStepToS(&this->actor.world.rot.x, sp6E, ABS_ALT(sp6C) * sp64); + } + } + + Actor_SetSpeeds(&this->actor, 12.0f); + Actor_MoveWithGravity(&this->actor); + func_808A24DC(this, globalCtx); + func_800B9010(&this->actor, NA_SE_IT_BOOMERANG_FLY - SFX_FLAG); + + if ((this->collider.base.atFlags & AT_HIT) && (((this->collider.base.at->id == ACTOR_EN_ITEM00) && + (this->collider.base.at->params != ITEM00_HEART_CONTAINER) && + (this->collider.base.at->params != ITEM00_HEART_PIECE)) || + (this->collider.base.at->id == ACTOR_EN_SI))) { + this->unk_1C8 = this->collider.base.at; + if (this->collider.base.at->id == ACTOR_EN_SI) { + this->collider.base.at->flags |= 0x2000; + } + } + + if (DECR(this->unk_1CC) != 0) { + s32 sp5C; + Vec3f sp50; + s32 pad; + + sp74 = BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.prevPos, &this->actor.world.pos, &sp50, + &this->actor.wallPoly, true, true, true, true, &sp5C); + if (sp74 != 0) { + if (func_800B90AC(globalCtx, &this->actor, this->actor.wallPoly, sp5C, &sp50)) { + sp74 = 0; + } else { + CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &sp50); + } + } + + if (sp74 != 0) { + this->actor.world.rot.x = -this->actor.world.rot.x; + this->actor.world.rot.y += 0x8000; + this->player = &player->actor; + this->unk_1CC = 0; + } + } + + if (this->unk_1CC <= 16) { + distXYZ = Math_Vec3f_DistXYZ(&this->actor.world.pos, &player->actor.focus.pos); + + if (&player->actor != this->player) { + if (this->player == 0) { + this->unk_1CE = 8; + } + this->player = &player->actor; + } + + if (distXYZ < 40.0f) { + sp7C = this->unk_1C8; + if (sp7C != NULL) { + Math_Vec3f_Copy(&sp7C->world.pos, &player->actor.world.pos); + if (sp7C->id == ACTOR_EN_ITEM00) { + sp7C->gravity = -0.9f; + sp7C->bgCheckFlags &= ~3; + } else { + sp7C->flags &= -0x2001; + } + } + Actor_MarkForDeath(&this->actor); + } + } + + sp7C = this->unk_1C8; + if (sp7C != NULL) { + if (sp7C->update == NULL) { + this->unk_1C8 = NULL; + } else { + Math_Vec3f_Copy(&sp7C->world.pos, &this->actor.world.pos); + } + } +} + +void EnBoom_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBoom* this = THIS; + Player* player = GET_PLAYER(globalCtx); + Actor* actor; + + if (!(player->stateFlags1 & 0x20000000)) { + this->actionFunc(this, globalCtx); + + if (((actor = this->actor.child) != NULL) || ((actor = this->actor.parent) != NULL)) { + this->actor.focus.pos.x = (this->actor.world.pos.x + actor->world.pos.x) * 0.5f; + this->actor.focus.pos.y = (this->actor.world.pos.y + actor->world.pos.y) * 0.5f; + this->actor.focus.pos.z = (this->actor.world.pos.z + actor->world.pos.z) * 0.5f; + } else { + Actor_SetFocus(&this->actor, 0.0f); + } + + if (this->actor.params != 0) { + this->unk_1CD--; + } else { + this->unk_1CD++; + } + } +} + +typedef struct { + /* 0x00 */ Gfx* unk_00; + /* 0x04 */ Vec3f unk_04; + /* 0x10 */ Vec3f unk_10; +} EnBoomStruct; + +EnBoomStruct D_808A3078[] = { + { gameplay_keep_DL_06FE20, { -960.0f, 0.0f, 0.0f }, { 960.0f, 0.0f, 0.0f } }, + { gameplay_keep_DL_06FF68, { -960.0f, 0.0f, 0.0f }, { 960.0f, 0.0f, 0.0f } }, +}; + +void EnBoom_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBoom* this = THIS; + EnBoomStruct* sp58 = &D_808A3078[this->actor.params]; + Vec3f sp4C; + Vec3f sp40; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + + Matrix_InsertZRotation_s((this->actor.params != 0) ? 0x1F40 : -0x1F40, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->actor.world.rot.x, MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&sp58->unk_04, &sp4C); + Matrix_MultiplyVector3fByState(&sp58->unk_10, &sp40); + + if (func_80126440(globalCtx, &this->collider, &this->weaponInfo, &sp4C, &sp40)) { + EffectBlure_AddVertex(Effect_GetByIndex(this->effectIndex), &sp4C, &sp40); + } + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_RotateY(this->unk_1CD * 0x2EE0, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sp58->unk_00); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Boom/z_en_boom.h b/src/overlays/actors/ovl_En_Boom/z_en_boom.h index 906e592a5..0aa09f15b 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.h +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.h @@ -9,7 +9,15 @@ typedef void (*EnBoomActionFunc)(struct EnBoom*, GlobalContext*); typedef struct EnBoom { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xAC]; + /* 0x0144 */ ColliderQuad collider; + /* 0x01C4 */ Actor* player; + /* 0x01C8 */ Actor* unk_1C8; + /* 0x01CC */ u8 unk_1CC; + /* 0x01CD */ u8 unk_1CD; + /* 0x01CE */ u8 unk_1CE; + /* 0x01CF */ s8 unk_1CF; + /* 0x01D0 */ s32 effectIndex; + /* 0x01D4 */ WeaponInfo weaponInfo; /* 0x01F0 */ EnBoomActionFunc actionFunc; } EnBoom; // size = 0x1F4 diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 5827c7261..fd8ee4d45 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -6351,24 +6351,12 @@ 0x808A2300:("D_808A2300","f32","",0x4), 0x808A2304:("D_808A2304","f32","",0x4), 0x808A2FF0:("En_Boom_InitVars","UNK_TYPE1","",0x1), - 0x808A3010:("D_808A3010","UNK_TYPE1","",0x1), - 0x808A3060:("D_808A3060","UNK_TYPE1","",0x1), - 0x808A3068:("D_808A3068","UNK_TYPE1","",0x1), - 0x808A3069:("D_808A3069","UNK_TYPE1","",0x1), - 0x808A306A:("D_808A306A","UNK_TYPE1","",0x1), - 0x808A306B:("D_808A306B","UNK_TYPE1","",0x1), - 0x808A306C:("D_808A306C","UNK_TYPE1","",0x1), - 0x808A306D:("D_808A306D","UNK_TYPE1","",0x1), - 0x808A306E:("D_808A306E","UNK_TYPE1","",0x1), - 0x808A306F:("D_808A306F","UNK_TYPE1","",0x1), - 0x808A3070:("D_808A3070","UNK_TYPE1","",0x1), - 0x808A3071:("D_808A3071","UNK_TYPE1","",0x1), - 0x808A3072:("D_808A3072","UNK_TYPE1","",0x1), - 0x808A3073:("D_808A3073","UNK_TYPE1","",0x1), - 0x808A3074:("D_808A3074","UNK_TYPE1","",0x1), - 0x808A3075:("D_808A3075","UNK_TYPE1","",0x1), - 0x808A3076:("D_808A3076","UNK_TYPE1","",0x1), - 0x808A3077:("D_808A3077","UNK_TYPE1","",0x1), + 0x808A3010:("sQuadInit","UNK_TYPE1","",0x1), + 0x808A3060:("sInitChain","UNK_TYPE1","",0x1), + 0x808A3068:("D_808A3068","Color_RGBA8","",0x4), + 0x808A306C:("D_808A306C","Color_RGBA8","",0x4), + 0x808A3070:("D_808A3070","Color_RGBA8","",0x4), + 0x808A3074:("D_808A3074","Color_RGBA8","",0x4), 0x808A3078:("D_808A3078","UNK_TYPE4","",0x4), 0x808A30B0:("D_808A30B0","f32","",0x4), 0x808A30B4:("D_808A30B4","f32","",0x4), From 0fb3fb8634530301452e9fcb84f163e0aeeae3c1 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Thu, 26 May 2022 02:09:57 +0100 Subject: [PATCH 213/257] Bg_Ikana_Bombwall (#812) --- spec | 5 +- .../z_bg_ikana_bombwall.c | 343 ++++++++++++++++-- .../z_bg_ikana_bombwall.h | 9 +- undefined_syms.txt | 2 - 4 files changed, 321 insertions(+), 38 deletions(-) diff --git a/spec b/spec index 46402feea..c50c3cdd0 100644 --- a/spec +++ b/spec @@ -4627,8 +4627,11 @@ beginseg name "ovl_Bg_Ikana_Bombwall" compress include "build/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.o" - include "build/data/ovl_Bg_Ikana_Bombwall/ovl_Bg_Ikana_Bombwall.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Bg_Ikana_Bombwall/ovl_Bg_Ikana_Bombwall_reloc.o" +#else include "build/data/ovl_Bg_Ikana_Bombwall/ovl_Bg_Ikana_Bombwall.reloc.o" +#endif endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c index f183a7164..a5176bc64 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c @@ -5,6 +5,7 @@ */ #include "z_bg_ikana_bombwall.h" +#include "objects/object_ikana_obj/object_ikana_obj.h" #define FLAGS (ACTOR_FLAG_10000000) @@ -15,7 +16,15 @@ void BgIkanaBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgIkanaBombwall_Update(Actor* thisx, GlobalContext* globalCtx); void BgIkanaBombwall_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80BD4F18(BgIkanaBombwall* this); +void func_80BD4F2C(BgIkanaBombwall* this, GlobalContext* globalCtx); +void func_80BD4F88(BgIkanaBombwall* this); +void func_80BD4F9C(BgIkanaBombwall* this, GlobalContext* globalCtx); +void func_80BD4FF8(BgIkanaBombwall* this); +void func_80BD503C(BgIkanaBombwall* this, GlobalContext* globalCtx); +void func_80BD5118(BgIkanaBombwall* this); +void func_80BD5134(BgIkanaBombwall* this, GlobalContext* globalCtx); + const ActorInit Bg_Ikana_Bombwall_InitVars = { ACTOR_BG_IKANA_BOMBWALL, ACTORCAT_BG, @@ -28,65 +37,335 @@ const ActorInit Bg_Ikana_Bombwall_InitVars = { (ActorFunc)BgIkanaBombwall_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BD5270 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 80, 80, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BD529C = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 50, 20, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BD52D0[] = { +s16 D_80BD52C8[] = { + 32, + 21, + 15, + 8, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; +Gfx* D_80BD52E0[] = { + object_ikana_obj_DL_000378, + object_ikana_obj_DL_000048, +}; + +#ifdef NON_MATCHING +void func_80BD4720(BgIkanaBombwall* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spE0; + Vec3f spD4; + Vec3f spC8; + Vec3f spBC; + f32 temp_fs0; + f32 phi_fs1; + s16 phi_s0; + s16 temp; + s16 phi_t0; + + Matrix_StatePush(); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + temp_fs0 = 0.0f; + phi_fs1 = 0.0f; + + for (i = 0; i < 30; i++) { + temp_fs0 += 60.0f + (Rand_ZeroOne() * 20.0f); + if (temp_fs0 > 75.0f) { + temp_fs0 -= 150.0f; + } + spC8.x = temp_fs0; + + phi_fs1 += 5; + spC8.y = phi_fs1; + + spC8.z = (Rand_ZeroOne() * 20.0f) - 10.0f; + + spBC.x = ((Rand_ZeroOne() - 0.5f) * 5.0f) + (temp_fs0 * 0.053333335f); + spBC.y = (Rand_ZeroOne() * 7.0f) - 2.0f; + spBC.z = (Rand_ZeroOne() * 4.0f) - 2.0f; + + Matrix_MultiplyVector3fByState(&spC8, &spE0); + Matrix_MultiplyVector3fByState(&spBC, &spD4); + + spE0.x += this->dyna.actor.world.pos.x; + spE0.y += this->dyna.actor.world.pos.y; + spE0.z += this->dyna.actor.world.pos.z; + + if ((i & 3) == 0) { + phi_s0 = 32; + func_800BBFB0(globalCtx, &spE0, 50.0f, 2, 100, 120, 1); + } else { + phi_s0 = 64; + } + + if (i & 1) { + phi_s0 |= 1; + phi_t0 = 1; + } else { + phi_t0 = 0; + } + + if (D_80BD52C8[i & 3] >= 16) { + temp = -550; + } else { + temp = -450; + } + + EffectSsKakera_Spawn(globalCtx, &spE0, &spD4, &spE0, temp, phi_s0, 30, 0, 0, D_80BD52C8[i & 3], phi_t0, 0, 50, + -1, OBJECT_IKANA_OBJ, object_ikana_obj_DL_000288); + } + + Matrix_StatePop(); +} +#else +void func_80BD4720(BgIkanaBombwall* this, GlobalContext* globalCtx); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4720.s") #endif -extern ColliderCylinderInit D_80BD5270; -extern ColliderCylinderInit D_80BD529C; -extern InitChainEntry D_80BD52D0[]; +void func_80BD4A14(BgIkanaBombwall* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spD8; + Vec3f spCC; + f32 temp_fs0; + f32 temp_fs1; + f32 temp_fs3; + s16 temp_v1; + s16 phi_s2; + s32 phi_t0; + s16 phi_v0; + s32 phi_v1; -extern UNK_TYPE D_06000288; -extern UNK_TYPE D_06000488; + temp_fs3 = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4720.s") + for (i = 0, phi_s2 = 0; i < 28; i++, phi_s2 += 0x924) { + temp_fs3 += 20.0f + (Rand_ZeroOne() * 10.0f); + if (temp_fs3 > 60.0f) { + temp_fs3 -= 60.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4A14.s") + temp_fs0 = Math_SinS(phi_s2); + temp_fs1 = Math_CosS(phi_s2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/BgIkanaBombwall_Init.s") + spD8.x = (temp_fs0 * temp_fs3) + this->dyna.actor.world.pos.x; + spD8.y = this->dyna.actor.world.pos.y; + spD8.z = (temp_fs1 * temp_fs3) + this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/BgIkanaBombwall_Destroy.s") + spCC.x = ((Rand_ZeroOne() - 0.5f) * 3.0f * temp_fs0) + ((temp_fs0 * temp_fs3) * 0.033333335f); + spCC.y = (Rand_ZeroOne() * 18.0f) + 4.0f; + spCC.z = ((Rand_ZeroOne() - 0.5f) * 3.0f * temp_fs1) + ((temp_fs1 * temp_fs3) * 0.033333335f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4E44.s") + temp_v1 = (Rand_Next() & 3) + (i >> 1) + 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4EAC.s") + if ((i & 3) == 0) { + phi_v0 = 32; + } else { + phi_v0 = 64; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4F18.s") + if (temp_v1 >= 15) { + phi_v0 |= 1; + phi_v1 = 1; + phi_t0 = -550; + } else { + phi_v1 = 0; + phi_t0 = -400; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4F2C.s") + EffectSsKakera_Spawn(globalCtx, &spD8, &spCC, &spD8, phi_t0, phi_v0, 30, 0, 0, temp_v1, phi_v1, 0, 50, -1, + OBJECT_IKANA_OBJ, object_ikana_obj_DL_000288); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4F88.s") + if ((i & 3) == 0) { + spD8.y += 30.0f; + func_800BBFB0(globalCtx, &spD8, 50.0f, 2, 70, 110, 1); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4F9C.s") +void BgIkanaBombwall_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgIkanaBombwall* this = THIS; + s32 sp2C = BGIKANABOMBWALL_GET_100(&this->dyna.actor); + s32 sp28; + s32 sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4FF8.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + Collider_InitCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD503C.s") + if (Flags_GetSwitch(globalCtx, BGIKANABOMBWALL_GET_SWITCHFLAG(&this->dyna.actor))) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD5118.s") + if (sp2C == 0) { + sp28 = &object_ikana_obj_Colheader_000488; + sp24 = &sCylinderInit1; + } else { + sp28 = &object_ikana_obj_Colheader_000128; + sp24 = &sCylinderInit2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD5134.s") + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, sp28); + Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, sp24); + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/BgIkanaBombwall_Update.s") + if (sp2C == 0) { + func_80BD4F18(this); + } else { + func_80BD4F88(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/BgIkanaBombwall_Draw.s") +void BgIkanaBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaBombwall* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +s32 func_80BD4E44(BgIkanaBombwall* this) { + if (this->collider.base.acFlags & AC_HIT) { + if ((this->collider.base.ac != NULL) && + (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->collider.base.ac->world.pos) < SQ(75.0f))) { + return true; + } + } + return false; +} + +s32 func_80BD4EAC(BgIkanaBombwall* this) { + if (this->collider.base.acFlags & AC_HIT) { + if ((this->collider.base.ac != NULL) && + (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->collider.base.ac->world.pos) < SQ(80.0f))) { + return true; + } + } + return false; +} + +void func_80BD4F18(BgIkanaBombwall* this) { + this->actionFunc = func_80BD4F2C; +} + +void func_80BD4F2C(BgIkanaBombwall* this, GlobalContext* globalCtx) { + if (func_80BD4E44(this)) { + func_80BD4FF8(this); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80BD4F88(BgIkanaBombwall* this) { + this->actionFunc = func_80BD4F9C; +} + +void func_80BD4F9C(BgIkanaBombwall* this, GlobalContext* globalCtx) { + if (func_80BD4EAC(this)) { + func_80BD4FF8(this); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80BD4FF8(BgIkanaBombwall* this) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->actionFunc = func_80BD503C; +} + +void func_80BD503C(BgIkanaBombwall* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (!BGIKANABOMBWALL_GET_100(&this->dyna.actor)) { + func_80BD4720(this, globalCtx); + } else { + func_80BD4A14(this, globalCtx); + } + this->dyna.actor.draw = NULL; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 60, NA_SE_EV_WALL_BROKEN); + Flags_SetSwitch(globalCtx, BGIKANABOMBWALL_GET_SWITCHFLAG(&this->dyna.actor)); + if (!BGIKANABOMBWALL_GET_100(&this->dyna.actor)) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } + func_80BD5118(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void func_80BD5118(BgIkanaBombwall* this) { + this->unk_1AC = 30; + this->actionFunc = func_80BD5134; +} + +void func_80BD5134(BgIkanaBombwall* this, GlobalContext* globalCtx) { + if (!BGIKANABOMBWALL_GET_100(&this->dyna.actor)) { + this->unk_1AC--; + if (this->unk_1AC <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + } + } else if (this->dyna.actor.cutscene >= 0) { + if (ActorCutscene_GetCurrentIndex() != this->dyna.actor.cutscene) { + Actor_MarkForDeath(&this->dyna.actor); + } + } else { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void BgIkanaBombwall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaBombwall* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgIkanaBombwall_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, D_80BD52E0[BGIKANABOMBWALL_GET_100(thisx)]); +} diff --git a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.h b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.h index 42b0596d8..37921ba53 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.h @@ -7,11 +7,14 @@ struct BgIkanaBombwall; typedef void (*BgIkanaBombwallActionFunc)(struct BgIkanaBombwall*, GlobalContext*); +#define BGIKANABOMBWALL_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define BGIKANABOMBWALL_GET_100(thisx) (((thisx)->params >> 8) & 1) + typedef struct BgIkanaBombwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderCylinder collider; /* 0x01A8 */ BgIkanaBombwallActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x01AC */ s8 unk_1AC; } BgIkanaBombwall; // size = 0x1B0 extern const ActorInit Bg_Ikana_Bombwall_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 1d5ea0bd3..91ead11f3 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -617,9 +617,7 @@ D_06000C90 = 0x06000C90; // ovl_Bg_Ikana_Bombwall -D_06000128 = 0x06000128; D_06000288 = 0x06000288; -D_06000488 = 0x06000488; // ovl_Bg_Ikana_Dharma From 9fcf1bd55b2732b494a22e0850988f86fc0db95a Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Thu, 26 May 2022 11:33:31 +1000 Subject: [PATCH 214/257] Match 9 Various NON_MATCHING functions (#811) * Match func_80A3C8D8 (obj_vspinyroll OK) * `EnHorse_Update` OK * Match EnHorse_Init & EnHorse_FleePlayer (en_horse OK) * Fake match func_80BF43FC (en_rg OK) * func_80A66930 + func_80A671E0 (obj_driftice OK) * Match func_80940588 (goroiwa OK) * Match func_80ABBFC0 (@anon) Co-authored-by: hensldm * PR Suggestions * PR suggestions --- spec | 24 -- .../z_bg_hakugin_bombwall.c | 13 +- src/overlays/actors/ovl_Boss_06/z_boss_06.c | 2 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 2 +- .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 14 +- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 284 ++++++++---------- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 2 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 2 +- src/overlays/actors/ovl_En_Rg/z_en_rg.c | 14 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 2 +- src/overlays/actors/ovl_En_Trt/z_en_trt.c | 2 +- .../actors/ovl_Obj_Driftice/z_obj_driftice.c | 24 +- .../ovl_Obj_Spidertent/z_obj_spidertent.c | 8 +- .../actors/ovl_Obj_Switch/z_obj_switch.c | 3 +- .../ovl_Obj_Vspinyroll/z_obj_vspinyroll.c | 35 +-- .../ovl_Obj_Vspinyroll/z_obj_vspinyroll.h | 10 +- 16 files changed, 175 insertions(+), 266 deletions(-) diff --git a/spec b/spec index c50c3cdd0..1a733af09 100644 --- a/spec +++ b/spec @@ -821,11 +821,7 @@ beginseg name "ovl_En_Horse" compress include "build/src/overlays/actors/ovl_En_Horse/z_en_horse.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_En_Horse/ovl_En_Horse_reloc.o" -#else - include "build/data/ovl_En_Horse/ovl_En_Horse.reloc.o" -#endif endseg beginseg @@ -1501,11 +1497,7 @@ beginseg name "ovl_En_Goroiwa" compress include "build/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_En_Goroiwa/ovl_En_Goroiwa_reloc.o" -#else - include "build/data/ovl_En_Goroiwa/ovl_En_Goroiwa.reloc.o" -#endif endseg beginseg @@ -2765,11 +2757,7 @@ beginseg name "ovl_Obj_Vspinyroll" compress include "build/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_Obj_Vspinyroll/ovl_Obj_Vspinyroll_reloc.o" -#else - include "build/data/ovl_Obj_Vspinyroll/ovl_Obj_Vspinyroll.reloc.o" -#endif endseg beginseg @@ -3001,11 +2989,7 @@ beginseg name "ovl_Obj_Driftice" compress include "build/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_Obj_Driftice/ovl_Obj_Driftice_reloc.o" -#else - include "build/data/ovl_Obj_Driftice/ovl_Obj_Driftice.reloc.o" -#endif endseg beginseg @@ -3287,11 +3271,7 @@ beginseg name "ovl_Bg_Hakugin_Bombwall" compress include "build/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/ovl_Bg_Hakugin_Bombwall_reloc.o" -#else - include "build/data/ovl_Bg_Hakugin_Bombwall/ovl_Bg_Hakugin_Bombwall.reloc.o" -#endif endseg beginseg @@ -4878,11 +4858,7 @@ beginseg name "ovl_En_Rg" compress include "build/src/overlays/actors/ovl_En_Rg/z_en_rg.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_En_Rg/ovl_En_Rg_reloc.o" -#else - include "build/data/ovl_En_Rg/ovl_En_Rg.reloc.o" -#endif endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c index 1f0030d28..bf3e44154 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c @@ -121,10 +121,8 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#ifdef NON_MATCHING -// Breaks relocs void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { - s32 temp; + f32 temp; Vec3f spF0; Vec3f spE4; Vec3f spD8; @@ -138,13 +136,13 @@ void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); for (i = 0; i < 6; i++) { - temp = i + 1; + temp = (i + 1) * (80.0f / 3.0f); for (j = 0; j < ARRAY_COUNT(D_80ABD020); j++) { spD8.x = D_80ABD020[j] + (s32)((u32)Rand_Next() >> 0x1C); - spD8.y = ((Rand_ZeroOne() - 0.5f) * 15.0f) + (temp * 26.666666f); + spD8.y = ((Rand_ZeroOne() - 0.5f) * 15.0f) + temp; spD8.z = (Rand_ZeroOne() * 20.0f) - 10.0f; - spCC.x = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (spD8.x * 0.07777778f); + spCC.x = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (spD8.x * (7.0f / 90.0f)); spCC.y = (Rand_ZeroOne() * 7.0f) - 2.0f; spCC.z = spD8.z * 0.3f; @@ -176,9 +174,6 @@ void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABBFC0.s") -#endif void func_80ABC2E0(BgHakuginBombwall* this, GlobalContext* globalCtx) { s32 pad; diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index 311d07a75..db1a954d0 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -512,7 +512,7 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { u16 pad; u8 spD3; u8 spD2; - s32 maxColor = 255; // Possible FAKE MATCH + s32 maxColor = 255; //! FAKE: f32 sp68; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index a69730bed..04d4100b1 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -603,7 +603,7 @@ void EnFsn_UpdateCursorAnim(EnFsn* this) { void EnFsn_UpdateStickDirectionPromptAnim(EnFsn* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - s32 maxColor = 255; // POSSIBLY FAKE + s32 maxColor = 255; //! FAKE: if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; 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 dd8d95c23..7f6db7264 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -739,24 +739,22 @@ void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// Stack void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGBA8* arg3, Color_RGBA8* arg4, f32 arg5) { Gfx* phi_s7; Vec3f sp100; Vec3f spF4; Vec3f spE8; f32 temp_f20; - s32 phi_fp; + f32 spB0; s32 j; s32 i; s32 phi_s0; s32 spD0; s16 spCE; - s16 spC8; - f32 spB0; - f32 spAC; s16 spA8; + s16 phi_fp; + s16 spC8; + f32 spAC; spD0 = (s32)(arg5 * 35.0f) + 6; temp_f20 = (arg5 + 0.1f) * 0.5f; @@ -815,10 +813,6 @@ void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGB } } } -#else -void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGBA8* arg3, Color_RGBA8* arg4, f32 arg5); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_80940588.s") -#endif void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA8* arg3, Color_RGBA8* arg4, f32 arg5) { s32 i; 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 d71ac41af..54e388bc2 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -673,16 +673,16 @@ void func_8087C9F8(EnHorse* this) { void func_8087CA04(EnHorse* this, GlobalContext* globalCtx) { } -#ifdef NON_MATCHING void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; EnHorse* this = THIS; + Skin* skin = &this->skin; Actor_ProcessInitChain(&this->actor, sInitChain); EnHorse_ClearDustFlags(&this->dustFlags); D_801BDAA4 = 0; Skin_Setup(&this->skin); - this->riderPos = this->actor.world.pos; + this->riderPos = thisx->world.pos; this->unk_52C = 0; this->noInputTimer = 0; this->riderPos.y += 70.0f; @@ -702,19 +702,19 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { return; } this->unk_1EC |= 1; - this->actor.update = func_8087D540; + thisx->update = func_8087D540; } else if (ENHORSE_GET_4000(&this->actor)) { this->type = HORSE_2; this->unk_528 = 64.8f; this->boostSpeed = 15; if ((this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HORSE_LINK_CHILD)) < 0) { - this->actor.objBankIndex = Object_Spawn(&globalCtx->objectCtx, OBJECT_HORSE_LINK_CHILD); + thisx->objBankIndex = Object_Spawn(&globalCtx->objectCtx, OBJECT_HORSE_LINK_CHILD); Actor_SetObjectDependency(globalCtx, &this->actor); Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); this->unk_1EC |= 0x200; } else { - this->actor.update = func_8087D540; + thisx->update = func_8087D540; } } else if (ENHORSE_GET_2000(&this->actor)) { this->type = HORSE_3; @@ -724,46 +724,46 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { return; } this->unk_1EC |= 1; - this->actor.update = func_8087D540; + thisx->update = func_8087D540; } else { this->type = HORSE_EPONA; this->boostSpeed = 15; Actor_MarkForDeath(&this->actor); } - this->actor.params &= ~0xE000; - if (this->actor.params == 0x1FFF) { - this->actor.params = ENHORSE_1; + thisx->params &= ~0xE000; + if (thisx->params == 0x1FFF) { + thisx->params = ENHORSE_1; } - if (this->actor.params == ENHORSE_3) { + if (thisx->params == ENHORSE_3) { this->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP | ENHORSE_UNRIDEABLE; - } else if (this->actor.params == ENHORSE_8) { + } else if (thisx->params == ENHORSE_8) { this->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP; if (CHECK_QUEST_ITEM(14)) { this->stateFlags &= ~ENHORSE_CANT_JUMP; this->stateFlags |= ENHORSE_FLAG_26; } - } else if (this->actor.params == ENHORSE_13) { + } else if (thisx->params == ENHORSE_13) { this->stateFlags = ENHORSE_FLAG_29; this->unk_1EC |= 0x10; - } else if (this->actor.params == ENHORSE_4) { + } else if (thisx->params == ENHORSE_4) { this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; - this->actor.flags |= ACTOR_FLAG_80000000; - } else if (this->actor.params == ENHORSE_5) { + thisx->flags |= ACTOR_FLAG_80000000; + } else if (thisx->params == ENHORSE_5) { this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; - this->actor.flags |= ACTOR_FLAG_80000000; - } else if (this->actor.params == ENHORSE_15) { + thisx->flags |= ACTOR_FLAG_80000000; + } else if (thisx->params == ENHORSE_15) { this->stateFlags = ENHORSE_UNRIDEABLE | ENHORSE_FLAG_7; - } else if (this->actor.params == ENHORSE_17) { + } else if (thisx->params == ENHORSE_17) { this->stateFlags = 0; this->unk_1EC |= 8; - } else if (this->actor.params == ENHORSE_18) { + } else if (thisx->params == ENHORSE_18) { this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; - this->actor.flags |= ACTOR_FLAG_80000000; - } else if (this->actor.params == ENHORSE_1) { + thisx->flags |= ACTOR_FLAG_80000000; + } else if (thisx->params == ENHORSE_1) { this->stateFlags = ENHORSE_FLAG_7; - } else if ((this->actor.params == ENHORSE_19) || (this->actor.params == ENHORSE_20)) { + } else if ((thisx->params == ENHORSE_19) || (thisx->params == ENHORSE_20)) { this->stateFlags = ENHORSE_CANT_JUMP | ENHORSE_UNRIDEABLE; } else { this->stateFlags = 0; @@ -774,10 +774,10 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { this->stateFlags |= ENHORSE_FLAG_25; } - this->actor.gravity = -3.5f; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); + thisx->gravity = -3.5f; + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawHorse, 20.0f); this->action = ENHORSE_ACT_IDLE; - this->actor.speedXZ = 0.0f; + thisx->speedXZ = 0.0f; if (this->type == HORSE_2) { sJntSphInit.elements[0].dim.limb = 13; @@ -800,7 +800,7 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { this->colliderCylinder1.dim.radius = 50; } - CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + CollisionCheck_SetInfo(&thisx->colChkInfo, NULL, &sColChkInfoInit); if (this->type == HORSE_2) { Actor_SetScale(&this->actor, 0.00648f); @@ -810,11 +810,11 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_SetScale(&this->actor, 0.01f); } - this->actor.focus.pos = this->actor.world.pos; + thisx->focus.pos = thisx->world.pos; this->playerControlled = false; - this->actor.focus.pos.y += 70.0f; + thisx->focus.pos.y += 70.0f; - if (!(this->unk_1EC & 1) && !(this->unk_1EC & 0x200) && (this->actor.update == EnHorse_Update)) { + if (!(this->unk_1EC & 1) && !(this->unk_1EC & 0x200) && (thisx->update == EnHorse_Update)) { Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); } @@ -828,71 +828,69 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { EnHorse_ResetRace(this, globalCtx); EnHorse_ResetHorsebackArchery(this, globalCtx); - if (this->actor.params == ENHORSE_2) { + if (thisx->params == ENHORSE_2) { this->unk_53C = 0; EnHorse_InitInactive(this); - } else if (this->actor.params == ENHORSE_3) { + } else if (thisx->params == ENHORSE_3) { EnHorse_InitIngoHorse(this); - this->rider = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, 1, 1); + this->rider = + (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, + thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, 1, 1); this->unk_398 = 14.34f; - } else if (this->actor.params == ENHORSE_4) { + } else if (thisx->params == ENHORSE_4) { func_80881634(this); this->unk_398 = 14.34f; - this->rider = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, 1, 1); + this->rider = + (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, + thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, 1, 1); this->unk_1EC |= 0x100; - } else if (this->actor.params == ENHORSE_5) { + } else if (thisx->params == ENHORSE_5) { func_80881634(this); this->unk_398 = 14.525f; - this->rider = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, 1, 2); + this->rider = + (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, + thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, 1, 2); this->unk_1EC |= 0x100; - } else if (this->actor.params == ENHORSE_9) { + } else if (thisx->params == ENHORSE_9) { EnHorse_InitCutscene(this, globalCtx); - } else if (this->actor.params == ENHORSE_10) { + } else if (thisx->params == ENHORSE_10) { EnHorse_InitHorsebackArchery(this); func_80112AFC(globalCtx); - } else if (this->actor.params == ENHORSE_14) { + } else if (thisx->params == ENHORSE_14) { func_808846F0(this, globalCtx); if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(globalCtx)) { Actor_MarkForDeath(&this->actor); } - } else if (this->actor.params == ENHORSE_16) { + } else if (thisx->params == ENHORSE_16) { func_8087C9F8(this); - } else if (this->actor.params == ENHORSE_15) { + } else if (thisx->params == ENHORSE_15) { EnHorse_ResetIdleAnimation(this); - } else if (this->actor.params == ENHORSE_18) { + } else if (thisx->params == ENHORSE_18) { func_80884994(this); - } else if (this->actor.params == ENHORSE_19) { + } else if (thisx->params == ENHORSE_19) { EnIn* in; func_80884D04(this, globalCtx); - in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, 1, 1); + in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, + thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, 1, 1); this->rider = in; in->unk4AC |= (0x20 | 0x4); - } else if (this->actor.params == ENHORSE_20) { + } else if (thisx->params == ENHORSE_20) { EnIn* in; func_80884D04(this, globalCtx); - in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, - this->actor.shape.rot.y, 1, 1); + in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, + thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, 1, 1); this->rider = in; in->unk4AC |= (0x20 | 0x8 | 0x4); } else { EnHorse_StartIdleRidable(this); } - this->actor.shape.rot.z = 0; - this->actor.world.rot.z = this->actor.shape.rot.z; - this->actor.home.rot.z = this->actor.shape.rot.z; - this->unk_3EC = this->actor.world.rot.y; + thisx->shape.rot.z = 0; + thisx->world.rot.z = thisx->shape.rot.z; + thisx->home.rot.z = thisx->shape.rot.z; + this->unk_3EC = thisx->world.rot.y; this->unk_538 = 0; if (this->unk_1EC & 0x100) { @@ -906,9 +904,6 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { this->colliderCylinder2.info.bumper.dmgFlags = 0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Init.s") -#endif void func_8087D540(Actor* thisx, GlobalContext* globalCtx) { EnHorse* this = THIS; @@ -2952,13 +2947,12 @@ void EnHorse_UpdateHorsebackArchery(EnHorse* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 distToHome; f32 playerDistToHome; f32 distToPlayer; - s32 nextAnim; + s32 nextAnim = this->animationIdx; s32 animFinished; s16 yaw; @@ -3098,10 +3092,6 @@ void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx) { -3.0f); } } -#else -void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_FleePlayer.s") -#endif void func_80883B70(EnHorse* this, CsCmdActorAction* action) { this->actor.world.pos.x = action->startPos.x; @@ -4156,37 +4146,36 @@ s32 EnHorse_RandInt(f32 arg0) { return Rand_ZeroOne() * arg0; } -#ifdef NON_MATCHING -void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { - static EnHorseActionFunc sActionFuncs[] = { - EnHorse_Frozen, - EnHorse_Inactive, - EnHorse_Idle, - EnHorse_FollowPlayer, - EnHorse_UpdateIngoRace, - func_808819D8, - func_80881398, - EnHorse_MountedIdle, - EnHorse_MountedIdleWhinneying, - EnHorse_MountedTurn, - EnHorse_MountedWalk, - EnHorse_MountedTrot, - EnHorse_MountedGallop, - EnHorse_MountedRearing, - EnHorse_Stopping, - EnHorse_Reverse, - EnHorse_LowJump, - EnHorse_HighJump, - EnHorse_CutsceneUpdate, - EnHorse_UpdateHorsebackArchery, - EnHorse_FleePlayer, - func_80884718, - func_8087CA04, - func_808848C8, - func_80884A40, - func_80884E0C, - }; - s32 pad; +static EnHorseActionFunc sActionFuncs[] = { + EnHorse_Frozen, + EnHorse_Inactive, + EnHorse_Idle, + EnHorse_FollowPlayer, + EnHorse_UpdateIngoRace, + func_808819D8, + func_80881398, + EnHorse_MountedIdle, + EnHorse_MountedIdleWhinneying, + EnHorse_MountedTurn, + EnHorse_MountedWalk, + EnHorse_MountedTrot, + EnHorse_MountedGallop, + EnHorse_MountedRearing, + EnHorse_Stopping, + EnHorse_Reverse, + EnHorse_LowJump, + EnHorse_HighJump, + EnHorse_CutsceneUpdate, + EnHorse_UpdateHorsebackArchery, + EnHorse_FleePlayer, + func_80884718, + func_8087CA04, + func_808848C8, + func_80884A40, + func_80884E0C, +}; +void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; EnHorse* this = THIS; Vec3f dustAcc = { 0.0f, 0.0f, 0.0f }; Vec3f dustVel = { 0.0f, 1.0f, 0.0f }; @@ -4200,7 +4189,7 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); } - this->lastYaw = this->actor.shape.rot.y; + this->lastYaw = thisx->shape.rot.y; EnHorse_UpdateStick(this, globalCtx); EnHorse_UpdatePlayerDir(this, globalCtx); @@ -4222,13 +4211,13 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { sActionFuncs[this->action](this, globalCtx); this->stateFlags &= ~ENHORSE_OBSTACLE; - this->unk_3EC = this->actor.world.rot.y; + this->unk_3EC = thisx->world.rot.y; if ((this->animationIdx == ENHORSE_ANIM_STOPPING) || (this->animationIdx == ENHORSE_ANIM_REARING)) { this->skin.skelAnime.jointTable[0].y += 0x154; } this->curFrame = this->skin.skelAnime.curFrame; - this->lastPos = this->actor.world.pos; + this->lastPos = thisx->world.pos; if (!(this->stateFlags & ENHORSE_INACTIVE)) { if ((this->action == ENHORSE_ACT_STOPPING) || (this->action == ENHORSE_ACT_MOUNTED_REARING) || @@ -4241,7 +4230,7 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { } if (ActorCutscene_GetCurrentIndex() != -1) { - this->actor.speedXZ = 0.0f; + thisx->speedXZ = 0.0f; } if (this->action != ENHORSE_ACT_25) { @@ -4251,11 +4240,11 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->rider != NULL) { if ((this->action == ENHORSE_ACT_INGO_RACE) || (this->action == ENHORSE_ACT_MOUNTED_IDLE) || (this->action == ENHORSE_ACT_25)) { - this->rider->actor.world.pos.x = this->actor.world.pos.x; - this->rider->actor.world.pos.y = this->actor.world.pos.y + 10.0f; - this->rider->actor.world.pos.z = this->actor.world.pos.z; - this->rider->actor.shape.rot.x = this->actor.shape.rot.x; - this->rider->actor.shape.rot.y = this->actor.shape.rot.y; + this->rider->actor.world.pos.x = thisx->world.pos.x; + this->rider->actor.world.pos.y = thisx->world.pos.y + 10.0f; + this->rider->actor.world.pos.z = thisx->world.pos.z; + this->rider->actor.shape.rot.x = thisx->shape.rot.x; + this->rider->actor.shape.rot.y = thisx->shape.rot.y; } else if (this->action == ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING) { EnIn* in = this->rider; s16 jnt = in->jointTable[0].y; @@ -4263,14 +4252,14 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { in->actor.world.pos.x = this->riderPos.x; in->actor.world.pos.y = this->riderPos.y - (jnt * 0.01f * this->unk_528 * 0.01f); in->actor.world.pos.z = this->riderPos.z; - in->actor.shape.rot.x = this->actor.shape.rot.x; - in->actor.shape.rot.y = this->actor.shape.rot.y; + in->actor.shape.rot.x = thisx->shape.rot.x; + in->actor.shape.rot.y = thisx->shape.rot.y; } } if (this->colliderJntSph.elements->info.ocElemFlags & OCELEM_HIT) { - if (this->actor.speedXZ > 10.0f) { - this->actor.speedXZ -= 1.0f; + if (thisx->speedXZ > 10.0f) { + thisx->speedXZ -= 1.0f; } } @@ -4309,22 +4298,22 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->type == HORSE_2) { this->colliderCylinder1.dim.pos.x = - (s16)(Math_SinS(this->actor.shape.rot.y) * 11.0f) + this->colliderCylinder1.dim.pos.x; + (s16)(Math_SinS(thisx->shape.rot.y) * 11.0f) + this->colliderCylinder1.dim.pos.x; this->colliderCylinder1.dim.pos.z = - (s16)(Math_CosS(this->actor.shape.rot.y) * 11.0f) + this->colliderCylinder1.dim.pos.z; + (s16)(Math_CosS(thisx->shape.rot.y) * 11.0f) + this->colliderCylinder1.dim.pos.z; this->colliderCylinder2.dim.pos.x = - (s16)(Math_SinS(this->actor.shape.rot.y) * -18.0f) + this->colliderCylinder2.dim.pos.x; + (s16)(Math_SinS(thisx->shape.rot.y) * -18.0f) + this->colliderCylinder2.dim.pos.x; this->colliderCylinder2.dim.pos.z = - (s16)(Math_CosS(this->actor.shape.rot.y) * -18.0f) + this->colliderCylinder2.dim.pos.z; + (s16)(Math_CosS(thisx->shape.rot.y) * -18.0f) + this->colliderCylinder2.dim.pos.z; } else { this->colliderCylinder1.dim.pos.x = - (s16)(Math_SinS(this->actor.shape.rot.y) * 6.6000004f) + this->colliderCylinder1.dim.pos.x; + (s16)(Math_SinS(thisx->shape.rot.y) * 6.6000004f) + this->colliderCylinder1.dim.pos.x; this->colliderCylinder1.dim.pos.z = - (s16)(Math_CosS(this->actor.shape.rot.y) * 6.6000004f) + this->colliderCylinder1.dim.pos.z; + (s16)(Math_CosS(thisx->shape.rot.y) * 6.6000004f) + this->colliderCylinder1.dim.pos.z; this->colliderCylinder2.dim.pos.x = - (s16)(Math_SinS(this->actor.shape.rot.y) * -10.8f) + this->colliderCylinder2.dim.pos.x; + (s16)(Math_SinS(thisx->shape.rot.y) * -10.8f) + this->colliderCylinder2.dim.pos.x; this->colliderCylinder2.dim.pos.z = - (s16)(Math_CosS(this->actor.shape.rot.y) * -10.8f) + this->colliderCylinder2.dim.pos.z; + (s16)(Math_CosS(thisx->shape.rot.y) * -10.8f) + this->colliderCylinder2.dim.pos.z; } CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder1.base); @@ -4346,18 +4335,18 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { EnHorse_UpdateBgCheckInfo(this, globalCtx); EnHorse_CheckFloors(this, globalCtx); - if (this->actor.world.pos.y < this->yFront) { - if (this->actor.world.pos.y < this->yBack) { + if (thisx->world.pos.y < this->yFront) { + if (thisx->world.pos.y < this->yBack) { if (this->yBack < this->yFront) { - this->actor.world.pos.y = this->yBack; + thisx->world.pos.y = this->yBack; } else { - this->actor.world.pos.y = this->yFront; + thisx->world.pos.y = this->yFront; } } } - this->actor.focus.pos = this->actor.world.pos; - this->actor.focus.pos.y += 70.0f; + thisx->focus.pos = thisx->world.pos; + thisx->focus.pos.y += 70.0f; if ((Rand_ZeroOne() < 0.025f) && (this->blinkTimer == 0)) { this->blinkTimer++; @@ -4368,13 +4357,13 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { } } - if ((this->actor.speedXZ == 0.0f) && !(this->stateFlags & ENHORSE_FLAG_19)) { - this->actor.colChkInfo.mass = MASS_IMMOVABLE; + if ((thisx->speedXZ == 0.0f) && !(this->stateFlags & ENHORSE_FLAG_19)) { + thisx->colChkInfo.mass = MASS_IMMOVABLE; } else { - this->actor.colChkInfo.mass = MASS_HEAVY; + thisx->colChkInfo.mass = MASS_HEAVY; } - if (this->actor.speedXZ >= 5.0f) { + if (thisx->speedXZ >= 5.0f) { this->colliderCylinder1.base.atFlags |= AT_ON; } else { this->colliderCylinder1.base.atFlags &= ~AT_ON; @@ -4400,39 +4389,6 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { this->stateFlags &= ~ENHORSE_DRAW; } } -#else -EnHorseActionFunc sActionFuncs[] = { - EnHorse_Frozen, - EnHorse_Inactive, - EnHorse_Idle, - EnHorse_FollowPlayer, - EnHorse_UpdateIngoRace, - func_808819D8, - func_80881398, - EnHorse_MountedIdle, - EnHorse_MountedIdleWhinneying, - EnHorse_MountedTurn, - EnHorse_MountedWalk, - EnHorse_MountedTrot, - EnHorse_MountedGallop, - EnHorse_MountedRearing, - EnHorse_Stopping, - EnHorse_Reverse, - EnHorse_LowJump, - EnHorse_HighJump, - EnHorse_CutsceneUpdate, - EnHorse_UpdateHorsebackArchery, - EnHorse_FleePlayer, - func_80884718, - func_8087CA04, - func_808848C8, - func_80884A40, - func_80884E0C, -}; -Vec3f D_808891C8 = { 0.0f, 0.0f, 0.0f }; -Vec3f D_808891D4 = { 0.0f, 1.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Update.s") -#endif s32 EnHorse_PlayerDirToMountSide(EnHorse* this, GlobalContext* globalCtx, Player* player) { if (this->playerDir == PLAYER_DIR_SIDE_L) { 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 c3194461d..855cb0556 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -170,7 +170,7 @@ void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx) { i = 0; tempCutscene = this->actor.cutscene; while (tempCutscene != -1) { - // This might be a fake match, no others found yet + //! FAKE: tempCutscene = ActorCutscene_GetAdditionalCutscene(this->actorCutscenes[i] = tempCutscene); i++; } diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index 3464314b1..a1c276cad 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -1277,7 +1277,7 @@ void EnOssan_UpdateCursorAnim(EnOssan* this) { void EnOssan_UpdateStickDirectionPromptAnim(EnOssan* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - s32 maxColor = 255; // POSSIBLY FAKE + s32 maxColor = 255; //! FAKE: if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index 09d2093ce..a75e0f489 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -368,7 +368,6 @@ s32 func_80BF42BC(EnRg* this, f32 arg1) { return false; } -#ifdef NON_MATCHING s32 func_80BF43FC(EnRg* this) { Vec3f sp9C; Vec3f sp90; @@ -378,11 +377,11 @@ s32 func_80BF43FC(EnRg* this) { f32 phi_f20 = 0.0f; s32 temp_s7 = ENRG_GET_7F80(&this->actor); s32 phi_s4 = -1; - s16 phi_s6 = 0; s32 temp_s5 = this->unk_344; + s16 phi_s6 = 0; s32 phi_s0 = D_80BF57E4[this->unk_344][temp_s7]; - while (true) { + do { SubS_CopyPointFromPathCheckBounds(this->path, phi_s0 - 1, &sp9C); SubS_CopyPointFromPathCheckBounds(this->path, phi_s0 + 1, &sp90); if (Math3D_PointDistToLine2D(this->actor.world.pos.x, this->actor.world.pos.z, sp9C.x, sp9C.z, sp90.x, sp90.z, @@ -393,17 +392,10 @@ s32 func_80BF43FC(EnRg* this) { phi_s4 = phi_s0; } phi_s0++; - if ((temp_s5 == 18) || (phi_s0 >= D_80BF57E4[temp_s5 + 1][temp_s7])) { - break; - } - } + } while ((temp_s5 != 18) && (phi_s0 < D_80BF57E4[temp_s5 + 1][temp_s7])); return phi_s4; } -#else -s32 func_80BF43FC(EnRg* this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rg/func_80BF43FC.s") -#endif s32 func_80BF4560(EnRg* this, GlobalContext* globalCtx) { s32 temp_v0 = SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index fc2ba1432..2bf6e61b5 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -1191,7 +1191,7 @@ void EnSob1_UpdateCursorAnim(EnSob1* this) { void EnSob1_UpdateStickDirectionPromptAnim(EnSob1* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - s32 maxColor = 255; // POSSIBLY FAKE + s32 maxColor = 255; //! FAKE: if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.c b/src/overlays/actors/ovl_En_Trt/z_en_trt.c index dde803708..897a1d3ab 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -1221,7 +1221,7 @@ void EnTrt_UpdateCursorAnim(EnTrt* this) { void EnTrt_UpdateStickDirectionPromptAnim(EnTrt* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - s32 maxColor = 255; // POSSIBLY FAKE + s32 maxColor = 255; //! FAKE: if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; diff --git a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c index 660e68b6d..abc8d6c85 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c @@ -148,7 +148,6 @@ f32 func_80A667F0(ObjDrifticeStruct3* arg0, ObjDriftice* this) { return temp_f20; } -#ifdef NON_MATCHING void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* arg3) { ObjDrifticeStruct3* temp_s0; f32 temp_f22 = 0.0f; @@ -157,6 +156,7 @@ void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* if (this->unk_248 > 0) { f32 temp_f20 = this->dyna.actor.xzDistToPlayer * this->unk_240 * 0.0007075472f; + if (temp_f20 > 1.0f) { temp_f20 = 1.0f; } else if (temp_f20 < 0.01f) { @@ -195,12 +195,9 @@ void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* temp_f22 *= arg0->unk_08; - *arg2 = (s32)temp_f22 + arg0->unk_00[2]; + //! FAKE: + *arg2 = arg0->unk_00[2] + (s32)((void)0, temp_f22); } -#else -void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* arg3); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66930.s") -#endif void func_80A66C4C(ObjDrifticeStruct4* arg0, ObjDriftice* this, s16* arg2, s16* arg3) { ObjDrifticeStruct3* temp_s0; @@ -340,8 +337,6 @@ void func_80A671CC(ObjDriftice* this) { this->actionFunc = func_80A671E0; } -#ifdef NON_MATCHING -// stack void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx) { f32 phi_f0; Vec3f sp40; @@ -349,12 +344,12 @@ void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx) { f32 phi_f12; Vec3s* points; s32 sp30; - Vec3s* points2; + Actor* thisx = &this->dyna.actor; Math_Vec3s_ToVec3f(&sp40, &(&this->unk_16C[this->unk_164])[this->unk_168]); - Math_Vec3f_Diff(&sp40, &this->dyna.actor.world.pos, &this->dyna.actor.velocity); + Math_Vec3f_Diff(&sp40, &this->dyna.actor.world.pos, &thisx->velocity); - sp3C = Math3D_Vec3fMagnitude(&this->dyna.actor.velocity); + sp3C = Math3D_Vec3fMagnitude(&thisx->velocity); if (sp3C < (this->unk_23C * 8.0f)) { phi_f0 = this->unk_23C * 0.4f; phi_f12 = this->unk_23C * 0.05f; @@ -391,8 +386,8 @@ void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx) { this->unk_164 = this->unk_160; } - points2 = &this->unk_16C[0]; - if ((points2->x != points->x) || (points2->y != points->y) || (points2->z != points->z)) { + if ((this->unk_16C[0].x != points->x) || (this->unk_16C[0].y != points->y) || + (this->unk_16C[0].z != points->z)) { func_80A6743C(this); func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); sp30 = false; @@ -405,9 +400,6 @@ void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx) { } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671E0.s") -#endif void func_80A6743C(ObjDriftice* this) { this->actionFunc = func_80A67450; diff --git a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c index 1bc0f57b2..1981c3b30 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c @@ -557,7 +557,8 @@ void ObjSpidertent_Init(Actor* thisx, GlobalContext* globalCtx) { ColliderTrisElementInit* element; Vec3f sp70[3]; Vec3f sp64; - s32 i, j; + s32 i; + s32 j; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); @@ -698,8 +699,9 @@ void func_80B30AD4(ObjSpidertent* this) { void func_80B30AF8(ObjSpidertent* this, GlobalContext* globalCtx) { ObjSpidertentStruct* temp_s0 = &D_80B31350[OBJSPIDERTENT_GET_1(&this->dyna.actor)]; TriNorm* triNorm; - s32 i, j; - ObjSpidertentStruct2* ptr; + s32 i; + s32 j; + s32 pad; Vec3f sp60; f32 sp5C; diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c index bfe1f24b1..ceb35bc7e 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -397,7 +397,8 @@ void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { } if (type == OBJSWITCH_TYPE_EYE) { if (sIsSegmentTableInit == false) { - s32 i, j; + s32 i; + s32 j; sIsSegmentTableInit = true; diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c index 9e36e5a2a..5f2aed7a9 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c @@ -141,15 +141,15 @@ void func_80A3C7E8(ObjVspinyroll* this) { s32 index = D_80A3D450[OBJVSPINYROLL_GET_4000(&this->dyna.actor)] * 120.0f * (1.0f / 58.0f); index += 2; - this->unk_38C = index * 4; + this->unk_1A8.unk_1E4 = index * 4; tempf = ((D_80A3D450[OBJVSPINYROLL_GET_4000(&this->dyna.actor)] * 120.0f) - 2.0f) / (index - 1); phi_f2 = 1.0f; - for (i = 0, j = 0; i < this->unk_38C; i++) { - this->unk_1A8[i].unk_00.x = D_80A3D4C4[j]; - this->unk_1A8[i].unk_00.y = phi_f2; - this->unk_1A8[i].unk_00.z = D_80A3D4B4[j]; + for (i = 0, j = 0; i < this->unk_1A8.unk_1E4; i++) { + this->unk_1A8.unk_000[i].unk_00.x = D_80A3D4C4[j]; + this->unk_1A8.unk_000[i].unk_00.y = phi_f2; + this->unk_1A8.unk_000[i].unk_00.z = D_80A3D4B4[j]; j++; if (j >= 4) { @@ -159,11 +159,10 @@ void func_80A3C7E8(ObjVspinyroll* this) { } } -#ifdef NON_MATCHING s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3) { s32 pad; - ObjVspinyrollStruct2* ptr = &this->unk_1A8[0]; - s32 pad2; + ObjVspinyrollStruct3* unk_1A8 = &this->unk_1A8; + ObjVspinyrollStruct2* ptr; s32 i; Vec3f spE4; Vec3f spD8; @@ -177,9 +176,11 @@ s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s3 spE4.z = 0.0f; sp9C = false; - this->unk_388 = NULL; + unk_1A8->unk_1E0 = NULL; + + for (i = 0; i < unk_1A8->unk_1E4; i++) { + ptr = &unk_1A8->unk_000[i]; - for (i = 0; i < this->unk_38C; i++, ptr++) { spE4.x = ptr->unk_00.x; spE4.y = ptr->unk_00.y; func_80A3C4E0(&spD8, &spE4, this->dyna.actor.world.rot.y); @@ -193,8 +194,8 @@ s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s3 spCC.x += 30.0f * this->unk_3B4.x; spCC.z += 30.0f * this->unk_3B4.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spD8, &spCC, &spC0, &this->unk_1A8[i].collisionPoly, true, - false, false, true, &this->unk_1A8[i].bgId, &this->dyna.actor, 0.0f)) { + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spD8, &spCC, &spC0, &unk_1A8->unk_000[i].collisionPoly, true, + false, false, true, &unk_1A8->unk_000[i].bgId, &this->dyna.actor, 0.0f)) { if ((arg3 != 0) && (this->dyna.actor.flags & ACTOR_FLAG_40)) { spA8.x = ptr->unk_00.x * 0.2f; spA8.y = ptr->unk_00.y; @@ -215,17 +216,13 @@ s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s3 temp_f20 = temp_f0; sp9C = true; Math_Vec3f_Diff(&spC0, &spCC, arg2); - this->unk_388 = ptr; + unk_1A8->unk_1E0 = ptr; } } } return sp9C; } -#else -s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C8D8.s") -#endif s32 func_80A3CB94(ObjVspinyroll* this, GlobalContext* globalCtx, s32 arg2) { Vec3f sp1C; @@ -239,8 +236,8 @@ s32 func_80A3CB94(ObjVspinyroll* this, GlobalContext* globalCtx, s32 arg2) { } DynaPolyActor* func_80A3CBF0(ObjVspinyroll* this, GlobalContext* globalCtx) { - if (this->unk_388 != NULL) { - return DynaPoly_GetActor(&globalCtx->colCtx, this->unk_388->bgId); + if (this->unk_1A8.unk_1E0 != NULL) { + return DynaPoly_GetActor(&globalCtx->colCtx, this->unk_1A8.unk_1E0->bgId); } return NULL; } diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h index af1048267..15879f86e 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h @@ -21,12 +21,16 @@ typedef struct { /* 0x10 */ s32 bgId; } ObjVspinyrollStruct2; // size = 0x14 +typedef struct { + /* 0x000 */ ObjVspinyrollStruct2 unk_000[24]; + /* 0x1E0 */ ObjVspinyrollStruct2* unk_1E0; + /* 0x1E4 */ s32 unk_1E4; +} ObjVspinyrollStruct3; // size = 0x1E8 + typedef struct ObjVspinyroll { /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ColliderCylinder collider; - /* 0x01A8 */ ObjVspinyrollStruct2 unk_1A8[24]; - /* 0x0388 */ ObjVspinyrollStruct2* unk_388; - /* 0x038C */ s32 unk_38C; + /* 0x01A8 */ ObjVspinyrollStruct3 unk_1A8; /* 0x0390 */ ObjVspinyrollActionFunc actionFunc; /* 0x0394 */ f32 unk_394; /* 0x0398 */ s32 unk_398; From c2c724063478869146bdc35fe454df61735c24b9 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Thu, 26 May 2022 11:36:49 +1000 Subject: [PATCH 215/257] Improve Various Matchings and Cleanup (#809) * Improve various matchings and cleanup * Fix warnings * Missed 2 * Few hex to dec * PR Suggestions * More PR Suggestions * Document time calculation * Improved use of macros * DAY_LENGTH macro * More cleanup of functions Co-authored-by: hensldm * Missing a space * PR Suggestions * Use DAY_LENGTH more --- include/macros.h | 1 + include/z64save.h | 4 +- src/code/z_actor.c | 11 ++-- src/code/z_demo.c | 14 ++--- src/code/z_en_item00.c | 5 +- src/code/z_message.c | 10 ++-- src/code/z_message_nes.c | 21 ++++---- src/code/z_scene.c | 20 +++---- .../ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c | 9 +--- src/overlays/actors/ovl_Boss_06/z_boss_06.c | 2 +- .../actors/ovl_Dm_Ravine/z_dm_ravine.c | 5 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 7 +-- .../actors/ovl_Door_Shutter/z_door_shutter.c | 4 +- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 27 +++++----- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 16 +++--- src/overlays/actors/ovl_En_Bom/z_en_bom.c | 10 ++-- .../actors/ovl_En_Bomjimb/z_en_bomjimb.c | 7 +-- .../actors/ovl_En_Elfgrp/z_en_elfgrp.c | 5 +- .../actors/ovl_En_Fishing/z_en_fishing.c | 6 +-- .../actors/ovl_En_Floormas/z_en_floormas.c | 4 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 5 +- src/overlays/actors/ovl_En_Gk/z_en_gk.c | 2 +- .../ovl_En_Guard_Nuts/z_en_guard_nuts.c | 2 +- .../actors/ovl_En_Guruguru/z_en_guruguru.c | 2 +- .../z_en_horse_game_check.c | 8 +-- .../z_en_horse_game_check.h | 2 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 5 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 8 +-- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 10 ++-- .../actors/ovl_En_Kanban/z_en_kanban.c | 2 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 6 +-- .../actors/ovl_En_Ma_Yts/z_en_ma_yts.c | 4 +- .../actors/ovl_En_Minifrog/z_en_minifrog.c | 9 ++-- src/overlays/actors/ovl_En_Mm3/z_en_mm3.c | 19 +++---- src/overlays/actors/ovl_En_Ms/z_en_ms.c | 6 +-- .../actors/ovl_En_Mt_tag/z_en_mt_tag.c | 2 +- src/overlays/actors/ovl_En_Muto/z_en_muto.c | 13 +++-- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 11 ++-- src/overlays/actors/ovl_En_Prz/z_en_prz.c | 14 +++-- .../actors/ovl_En_Recepgirl/z_en_recepgirl.c | 8 +-- .../actors/ovl_En_Scopenuts/z_en_scopenuts.c | 2 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 6 +-- .../actors/ovl_En_Suttari/z_en_suttari.c | 8 +-- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 53 +++++++++---------- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 17 ++---- .../ovl_En_Weather_Tag/z_en_weather_tag.c | 9 ++-- src/overlays/actors/ovl_En_Yb/z_en_yb.c | 2 +- src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c | 10 ++-- src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c | 6 +-- .../ovl_Obj_Warpstone/z_obj_warpstone.c | 2 +- 50 files changed, 190 insertions(+), 251 deletions(-) diff --git a/include/macros.h b/include/macros.h index 5e9c062c9..bb7315b3d 100644 --- a/include/macros.h +++ b/include/macros.h @@ -51,6 +51,7 @@ #define CLOCK_TIME(hr, min) (s32)(((hr) * 60 + (min)) * 0x10000 / (24 * 60)) #define CLOCK_TIME_MINUTE (CLOCK_TIME(0, 1)) +#define DAY_LENGTH (CLOCK_TIME(24, 0)) #define TIME_TO_MINUTES_F(time) ((time) * ((24.0f * 60.0f) / 0x10000)) // 0.021972656f #define CLOCK_TIME_F(hr, min) (((hr) * 60.0f + (min)) * (0x10000 / (24.0f * 60.0f))) diff --git a/include/z64save.h b/include/z64save.h index 2595b3c27..260701473 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -129,9 +129,9 @@ typedef struct Save { /* 0x000C */ u16 time; // "zelda_time" /* 0x000E */ u16 owlSaveLocation; /* 0x0010 */ s32 isNight; // "asahiru_fg" - /* 0x0014 */ u32 daySpeed; // "change_zelda_time" + /* 0x0014 */ s32 daySpeed; // "change_zelda_time" /* 0x0018 */ s32 day; // "totalday" - /* 0x001C */ u32 daysElapsed; // "eventday" + /* 0x001C */ s32 daysElapsed; // "eventday" /* 0x0020 */ u8 playerForm; // "player_character" /* 0x0021 */ u8 snowheadCleared; // "spring_flag" /* 0x0022 */ u8 hasTatl; // "bell_flag" diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 24bc91a17..2d75505d0 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -195,7 +195,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx CollisionPoly* spF8; s32 bgId; f32 floorHeight[2]; - f32 pad; + Light* firstLight = &mapper->l.l[0]; f32 shadowAlpha; f32 shadowScaleX; f32 shadowScaleZ; @@ -239,8 +239,6 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx IREG(88) + 80, IREG(89) + 60, IREG(90) + 40, 30000, 200, 60); } actor->shape.unk_17 &= ~spB8; - - if ((uintptr_t)mapper->l.l) {} // POSSIBLE FAKE MATCH } } @@ -252,7 +250,8 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx shadowScaleZ = 1.0f - (distToFloor * (1.0f / 70.0f)); shadowScaleX = actor->shape.shadowScale * shadowScaleZ * actor->scale.x; - for (lightPtr = mapper->l.l, j = 0; j < numLights; lightPtr++, j++) { + lightPtr = firstLight; + for (j = 0; j < numLights; j++) { if (lightPtr->l.dir[1] > 0) { lightNum = (lightPtr->l.col[0] + lightPtr->l.col[1] + lightPtr->l.col[2]) * ABS_ALT(lightPtr->l.dir[1]); @@ -263,9 +262,10 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx shadowScaleZ); } } + lightPtr++; } - for (j = 0; j < 2; lightPtr++, j++) { + for (j = 0; j < 2; j++) { if (lightPtr->l.dir[1] > 0) { lightNum = ((lightPtr->l.col[0] + lightPtr->l.col[1] + lightPtr->l.col[2]) * ABS_ALT(lightPtr->l.dir[1])) - @@ -275,6 +275,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx shadowScaleZ); } } + lightPtr++; } } feetPosPtr++; diff --git a/src/code/z_demo.c b/src/code/z_demo.c index c9c6253d3..01ed87e70 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -132,7 +132,6 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs u8 isStartFrame = false; f32 progress; SceneTableEntry* loadedScene; - u16 time; if ((csCtx->frames < cmd->startFrame) || ((csCtx->frames >= cmd->endFrame) && (cmd->endFrame != cmd->startFrame))) { return; @@ -250,11 +249,9 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs break; case 0x12: if (!gSaveContext.save.isNight) { - time = gSaveContext.save.time; - gSaveContext.save.time = time - (u16)REG(15); + gSaveContext.save.time = ((void)0, gSaveContext.save.time) - (u16)REG(15); } else { - time = gSaveContext.save.time; - gSaveContext.save.time = time - (u16)(2 * REG(15)); + gSaveContext.save.time = ((void)0, gSaveContext.save.time) - (u16)(2 * REG(15)); } break; case 0x13: @@ -328,10 +325,9 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs D_801BB15C = csCtx->frames; if (REG(15) != 0) { - time = gSaveContext.save.time; - gSaveContext.save.time = (u16)REG(15) + time; - time = gSaveContext.save.time; - gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + time; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); + gSaveContext.save.time = + ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.daySpeed); } } break; diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 3bec8471b..1c600bfa0 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -815,8 +815,6 @@ void EnItem00_DrawHeartPiece(EnItem00* this, GlobalContext* globalCtx) { } s16 func_800A7650(s16 dropId) { - s16 healthCapacity; - if ((((dropId == ITEM00_BOMBS_A) || (dropId == ITEM00_BOMBS_0) || (dropId == ITEM00_BOMBS_B)) && (INV_CONTENT(ITEM_BOMB) == ITEM_NONE)) || (((dropId == ITEM00_ARROWS_10) || (dropId == ITEM00_ARROWS_30) || (dropId == ITEM00_ARROWS_40) || @@ -828,8 +826,7 @@ s16 func_800A7650(s16 dropId) { } if (dropId == ITEM00_HEART) { - healthCapacity = gSaveContext.save.playerData.healthCapacity; - if (healthCapacity == gSaveContext.save.playerData.health) { + if (((void)0, gSaveContext.save.playerData.healthCapacity) == ((void)0, gSaveContext.save.playerData.health)) { return ITEM00_RUPEE_GREEN; } } diff --git a/src/code/z_message.c b/src/code/z_message.c index f41c713f6..2a90f38ca 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -405,23 +405,23 @@ void func_80151BB4(GlobalContext* globalCtx, u8 arg1) { u32 func_80151C9C(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; - u8 flag; while (true) { if (msgCtx->unk120B1 == 0) { - return 0; + return false; } msgCtx->unk120B1--; if ((gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] & (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]) == 0) { - flag = gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8]; gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] = - flag | (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]; + ((void)0, gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8]) | + (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]; + if ((D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]] != 0) && CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { func_80151938(globalCtx, D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]]); play_sound(NA_SE_SY_SCHEDULE_WRITE); - return 1; + return true; } } } diff --git a/src/code/z_message_nes.c b/src/code/z_message_nes.c index 1de839d68..485f016ff 100644 --- a/src/code/z_message_nes.c +++ b/src/code/z_message_nes.c @@ -193,29 +193,32 @@ void Message_LoadTimeNES(GlobalContext* globalCtx, u8 arg1, s32* offset, f32* ar s16 p = *decodedBufPos; s32 o = *offset; f32 f = *arg3; - u32 dayTime; + u32 timeLeft; s16 digits[4]; - f32 timeInMinutes; - s32 day; + f32 timeLeftInMinutes; s16 i; if (arg1 == 0xCF) { - day = gSaveContext.save.day; - dayTime = 0x40000 - ((day % 5) << 16) - (u16)(-0x4000 + gSaveContext.save.time); + // Calculates the time left before the moon crashes. + // The day begins at CLOCK_TIME(6, 0) so it must be offset. + timeLeft = (4 - CURRENT_DAY) * DAY_LENGTH - (u16)(((void)0, gSaveContext.save.time) - CLOCK_TIME(6, 0)); } else { - dayTime = 0x10000 - (u16)(-0x4000 + gSaveContext.save.time); + // Calculates the time left before a new day. + // The day begins at CLOCK_TIME(6, 0) so it must be offset. + timeLeft = DAY_LENGTH - (u16)(((void)0, gSaveContext.save.time) - CLOCK_TIME(6, 0)); } - timeInMinutes = TIME_TO_MINUTES_F(dayTime); + + timeLeftInMinutes = TIME_TO_MINUTES_F(timeLeft); digits[0] = 0; - digits[1] = (timeInMinutes / 60.0f); + digits[1] = (timeLeftInMinutes / 60.0f); while (digits[1] >= 10) { digits[0]++; digits[1] -= 10; } digits[2] = 0; - digits[3] = (s32)timeInMinutes % 60; + digits[3] = (s32)timeLeftInMinutes % 60; while (digits[3] >= 10) { digits[2]++; digits[3] -= 10; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index b03990702..b9dbb35dd 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -142,11 +142,9 @@ void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id) { // SceneTableEntry Header Command 0x00: Spawn List void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) { - GlobalContext* globalCtx2 = globalCtx; s32 loadedCount; - void* nextObject; s16 playerObjectId; - u8 playerForm; + void* nextObject; globalCtx->linkActorEntry = (ActorEntry*)Lib_SegmentedToVirtual(cmd->spawnList.segment) + globalCtx->setupEntranceList[globalCtx->curSpawn].spawn; @@ -158,11 +156,10 @@ void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) { } loadedCount = Object_Spawn(&globalCtx->objectCtx, OBJECT_LINK_CHILD); - nextObject = globalCtx2->objectCtx.status[globalCtx2->objectCtx.num].segment; + nextObject = globalCtx->objectCtx.status[globalCtx->objectCtx.num].segment; globalCtx->objectCtx.num = loadedCount; globalCtx->objectCtx.spawnedObjectCount = loadedCount; - playerForm = gSaveContext.save.playerForm; - playerObjectId = gLinkFormObjectIndexes[playerForm]; + playerObjectId = gLinkFormObjectIndexes[(void)0, gSaveContext.save.playerForm]; gActorOverlayTable[0].initInfo->objectId = playerObjectId; Object_Spawn(&globalCtx->objectCtx, playerObjectId); @@ -378,8 +375,6 @@ void Scene_HeaderCmdSkyboxDisables(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x10: Time Settings void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { - u32 dayTime; - if (cmd->timeSettings.hour != 0xFF && cmd->timeSettings.min != 0xFF) { gSaveContext.environmentTime = gSaveContext.save.time = (u16)(((cmd->timeSettings.hour + (cmd->timeSettings.min / 60.0f)) * 60.0f) / 0.021972656f); @@ -399,12 +394,9 @@ void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { REG(15) = globalCtx->envCtx.timeIncrement; } - dayTime = gSaveContext.save.time; - globalCtx->envCtx.unk_4 = -(Math_SinS(dayTime - 0x8000) * 120.0f) * 25.0f; - dayTime = gSaveContext.save.time; - globalCtx->envCtx.unk_8 = (Math_CosS(dayTime - 0x8000) * 120.0f) * 25.0f; - dayTime = gSaveContext.save.time; - globalCtx->envCtx.unk_C = (Math_CosS(dayTime - 0x8000) * 20.0f) * 25.0f; + globalCtx->envCtx.unk_4 = -(Math_SinS(((void)0, gSaveContext.save.time) - 0x8000) * 120.0f) * 25.0f; + globalCtx->envCtx.unk_8 = (Math_CosS(((void)0, gSaveContext.save.time) - 0x8000) * 120.0f) * 25.0f; + globalCtx->envCtx.unk_C = (Math_CosS(((void)0, gSaveContext.save.time) - 0x8000) * 20.0f) * 25.0f; if (globalCtx->envCtx.timeIncrement == 0 && gSaveContext.save.cutscene < 0xFFF0) { gSaveContext.environmentTime = gSaveContext.save.time; diff --git a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c index 53ddd7b81..d562d1a7e 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Rot/z_bg_ctower_rot.c @@ -82,17 +82,12 @@ void BgCtowerRot_CorridorRotate(BgCtowerRot* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); Vec3f offset; f32 rotZ; - f32 rotZtmp; Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); - if (offset.z > 1100.0f) { - rotZ = 0.0f; - } else { - rotZtmp = CLAMP_MAX(1100.0f - offset.z, 1000.0f); - rotZ = rotZtmp; - } + rotZ = CLAMP(1100.0f - offset.z, 0.0f, 1000.0f); func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 17); this->dyna.actor.shape.rot.z = rotZ * 16.384f; + if (globalCtx->csCtx.frames == 132) { play_sound(NA_SE_SY_SPIRAL_DASH); } diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index db1a954d0..f73423d5e 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -522,7 +522,7 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { temp_v0 = gSaveContext.save.time; if (temp_v0 > CLOCK_TIME(12, 0)) { - temp_v0 = 0xFFFF - temp_v0; + temp_v0 = (DAY_LENGTH - 1) - temp_v0; } sp68 = (f32)temp_v0 / 0x8000; spD3 = ((10.0f * sp68) + 105.0f) * this->unk_19C; diff --git a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c index bb8b735a4..25a68056e 100644 --- a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c +++ b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c @@ -29,9 +29,10 @@ const ActorInit Dm_Ravine_InitVars = { }; void DmRavine_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; DmRavine* this = THIS; - u8 flag = gSaveContext.save.weekEventReg[0]; - if (((flag & 0x10) | cREG(0)) != 0) { + + if (((((void)0, gSaveContext.save.weekEventReg[0]) & 0x10) | cREG(0)) != 0) { Actor_MarkForDeath(&this->actor); return; } diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index 08e515d26..b778f3fcc 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -1512,7 +1512,6 @@ void func_80AA27EC(DmStk* this, GlobalContext* globalCtx) { void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { DmStk* this = THIS; - u16 time; if (this->actor.params != 1) { if (this->unk_2E0 == 33) { @@ -1569,11 +1568,9 @@ void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { (globalCtx->msgCtx.currentTextId == 0x5E6) && !FrameAdvance_IsEnabled(&globalCtx->state) && (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { - time = gSaveContext.save.time; - gSaveContext.save.time = (u16)REG(15) + time; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); if (REG(15) != 0) { - time = gSaveContext.save.time; - gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + time; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.daySpeed); } } } diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index 01430acc3..999eec485 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -570,9 +570,7 @@ void func_808A1884(DoorShutter* this, GlobalContext* globalCtx) { if (DoorShutter_SetupDoor(this, globalCtx) && !(player->stateFlags1 & 0x800)) { DoorShutter_SetupAction(this, func_808A1C50); if (ActorCutscene_GetCurrentIndex() == 0x7D) { - s8 data = gSaveContext.respawn[RESTART_MODE_DOWN].data; - - func_801226E0(globalCtx, data); + func_801226E0(globalCtx, ((void)0, gSaveContext.respawn[RESTART_MODE_DOWN].data)); player->unk_A86 = -1; func_800B7298(globalCtx, NULL, 0x73); } diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index 9bfd07939..28b6251a1 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -100,11 +100,8 @@ void func_809C10B0(EnAob01* this, s32 arg1) { } void func_809C1124(void) { - u16 time = gSaveContext.save.time; - - gSaveContext.save.time = (u16)REG(15) + time; - time = gSaveContext.save.time; - gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + time; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.daySpeed); } void func_809C1158(EnAob01* this, GlobalContext* globalCtx) { @@ -882,8 +879,8 @@ void func_809C2F34(EnAob01* this, GlobalContext* globalCtx) { void func_809C2FA0(void) { u8 i; - u8 idx; - u8 idx2; + u8 rand; + u8 index; u8 orig; u8 orig2; u8 sp44[7]; @@ -892,11 +889,11 @@ void func_809C2FA0(void) { }; for (i = 0; i < ARRAY_COUNT(sp34); i++) { - idx = Rand_ZeroFloat(14.0f); + rand = Rand_ZeroFloat(14.0f); orig = sp34[i]; - sp34[i] = sp34[idx]; - sp34[idx] = orig; + sp34[i] = sp34[rand]; + sp34[rand] = orig; } for (i = 0; i < ARRAY_COUNT(sp44); i++) { @@ -906,14 +903,14 @@ void func_809C2FA0(void) { for (i = 0; i < ARRAY_COUNT(sp34); i++) { orig2 = sp34[i]; - idx2 = i / 2; + index = i / 2; if (i % 2) { - sp44[idx2] |= orig2 << 0x4; - idx = gSaveContext.save.weekEventReg[42 + idx2]; - gSaveContext.save.weekEventReg[42 + idx2] = idx | sp44[idx2]; + sp44[index] |= orig2 << 0x4; + gSaveContext.save.weekEventReg[42 + index] = + ((void)0, gSaveContext.save.weekEventReg[42 + index]) | sp44[index]; } else { - sp44[idx2] |= orig2; + sp44[index] |= orig2; } } } diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 818515446..20173ed15 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -116,8 +116,7 @@ void func_809CCEE8(EnBji01* this, GlobalContext* globalCtx) { } void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { - s32 tempDay; - f32 tempTimeBeforeMoonCrash; + f32 timeBeforeMoonCrash; switch (this->actor.params) { case ENBJI01_PARAMS_DEFAULT: @@ -180,10 +179,11 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { this->textId = 0x5EA; break; case 3: - tempDay = gSaveContext.save.day; - tempTimeBeforeMoonCrash = - ((-(tempDay % 5 << 0x10) - ((u16)(gSaveContext.save.time - 0x4000))) + 0x40000); - if (tempTimeBeforeMoonCrash < CLOCK_TIME_F(1, 0)) { /* 1 hr */ + // Calculates the time left before the moon crashes. + // The day begins at CLOCK_TIME(6, 0) so it must be offset. + timeBeforeMoonCrash = (4 - CURRENT_DAY) * DAY_LENGTH - + (u16)(((void)0, gSaveContext.save.time) - CLOCK_TIME(6, 0)); + if (timeBeforeMoonCrash < CLOCK_TIME_F(1, 0)) { this->textId = 0x5E8; } else { this->textId = 0x5EB; @@ -207,7 +207,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { } break; case 4: - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.params = ENBJI01_PARAMS_FINISHED_CONVERSATION; switch (globalCtx->msgCtx.choiceIndex) { @@ -235,7 +235,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { } break; case 5: - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { this->actor.flags &= ~ACTOR_FLAG_10000; switch (globalCtx->msgCtx.currentTextId) { case 0x5DE: diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/src/overlays/actors/ovl_En_Bom/z_en_bom.c index eeae2b8de..70805438f 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -675,14 +675,14 @@ void func_808726DC(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* ar f32 temp_f26 = Math_Vec3f_DistXYZ(arg3, arg1); s32 spB0; f32 temp_f2; - f32 sqrt; + f32 distXZ; Math_Vec3f_Copy(&ptr->unk_00, arg1); Math_Vec3f_Diff(arg2, arg1, &spCC); ptr->unk_18 = Math_FAtan2F(spCC.z, spCC.x); - sqrt = sqrtf(SQ(spCC.x) + SQ(spCC.z)); - ptr->unk_1A = Math_FAtan2F(sqrt, spCC.y); + distXZ = sqrtf(SQXZ(spCC)); + ptr->unk_1A = Math_FAtan2F(distXZ, spCC.y); spB0 = (arg4 / 240) + 1; @@ -721,8 +721,8 @@ void func_808726DC(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* ar } ptr2->unk_18 = Math_FAtan2F(spCC.z, spCC.x); - sqrt = sqrtf(SQ(spCC.x) + SQ(spCC.z)); - ptr2->unk_1A = Math_FAtan2F(sqrt, spCC.y); + distXZ = sqrtf(SQXZ(spCC)); + ptr2->unk_1A = Math_FAtan2F(distXZ, spCC.y); ptr2->unk_18 = (s16)CLAMP(BINANG_SUB(ptr2->unk_18, ptr->unk_18), -8000, 8000) + ptr->unk_18; ptr2->unk_1A = (s16)CLAMP(BINANG_SUB(ptr2->unk_1A, ptr->unk_1A), -8000, 8000) + ptr->unk_1A; diff --git a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c index c18a94209..1657e031c 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -656,7 +656,6 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { 0x0721, 0x0722, 0x0723, 0x0724, 0x072C, }; Player* player = GET_PLAYER(globalCtx); - s16 idx; func_80C012E0(this); func_80C0113C(this, 21, 1.0f); @@ -683,10 +682,8 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { return; } - idx = gSaveContext.save.bombersCaughtNum; - Message_StartTextbox(globalCtx, D_80C03230[idx], &this->actor); - idx = gSaveContext.save.bombersCaughtNum; - gSaveContext.save.bombersCaughtOrder[idx] = this->unk_2C8 + 1; + Message_StartTextbox(globalCtx, D_80C03230[((void)0, gSaveContext.save.bombersCaughtNum)], &this->actor); + gSaveContext.save.bombersCaughtOrder[((void)0, gSaveContext.save.bombersCaughtNum)] = this->unk_2C8 + 1; gSaveContext.save.bombersCaughtNum++; if (gSaveContext.save.bombersCaughtNum > 4) { diff --git a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c index 3acd2adf5..de1959ab4 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c @@ -177,14 +177,11 @@ void EnElfgrp_Destroy(Actor* thisx, GlobalContext* globalCtx) { } s32 func_80A39BD0(GlobalContext* globalCtx, s32 arg2) { - s8 sp1F; - if ((arg2 < 1) || (arg2 >= 5)) { return 0; } - sp1F = gSaveContext.save.inventory.strayFairies[arg2 - 1]; - return (sp1F - func_80A39C1C(globalCtx, arg2)) + 10; + return (((void)0, gSaveContext.save.inventory.strayFairies[arg2 - 1]) - func_80A39C1C(globalCtx, arg2)) + 10; } s32 func_80A39C1C(GlobalContext* globalCtx, s32 arg1) { 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 eccee0fe9..6dc9ff081 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -1069,7 +1069,7 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { } } else if (effect->type == FS_EFF_RAIN_DROP) { if (effect->pos.y < WATER_SURFACE_Y(globalCtx)) { - f32 sqDistXZ = SQ(effect->pos.x) + SQ(effect->pos.z); + f32 sqDistXZ = SQXZ(effect->pos); if (sqDistXZ > SQ(920.0f)) { effect->pos.y = WATER_SURFACE_Y(globalCtx) + ((sqrtf(sqDistXZ) - 920.0f) * 0.11f); @@ -1106,7 +1106,7 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { Math_ApproachS(&sEffOwnerHatRot.x, 0, 20, 100); Math_ApproachS(&sEffOwnerHatRot.z, -0x4000, 20, 100); - sqDistXZ = SQ(effect->pos.x) + SQ(effect->pos.z); + sqDistXZ = SQXZ(effect->pos); bottomY = WATER_SURFACE_Y(globalCtx) + ((sqrtf(sqDistXZ) - 920.0f) * 0.147f); if (effect->pos.y > (bottomY - 10.0f)) { @@ -5188,7 +5188,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { spFC.x = sLurePos.x - player->actor.world.pos.x; spFC.z = sLurePos.z - player->actor.world.pos.z; - lureDistXZ = sqrtf(SQ(spFC.x) + SQ(spFC.z)); + lureDistXZ = sqrtf(SQXZ(spFC)); Matrix_InsertYRotation_f(Math_Acot2F(spFC.z, spFC.x), MTXMODE_NEW); sp114.x = 0.0f; diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index de7d34024..75d6ce63b 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -713,15 +713,13 @@ void func_808D2040(EnFloormas* this, GlobalContext* globalCtx) { void func_808D217C(EnFloormas* this, Player* player) { Vec3f* ptr; - u8 playerForm; Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 36.0f, 45.0f, ANIMMODE_ONCE, -3.0f); this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; func_808D08D0(this); - playerForm = gSaveContext.save.playerForm; - ptr = &D_808D3900[playerForm]; + ptr = &D_808D3900[(void)0, gSaveContext.save.playerForm]; this->actor.home.pos.x = ptr->z * Math_SinS(this->actor.shape.rot.y); this->actor.home.pos.y = CLAMP(-this->actor.playerHeightRel, ptr->x, ptr->y); this->actor.home.pos.z = ptr->z * Math_CosS(this->actor.shape.rot.y); diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index b67a3080e..2b234d36b 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -652,9 +652,8 @@ void func_80962A10(EnFu* this, GlobalContext* globalCtx) { } if ((gSaveContext.save.playerForm == PLAYER_FORM_DEKU) && gSaveContext.save.playerData.magicAcquired) { - s16 temp = gSaveContext.unk_3F30; - - Parameter_AddMagic(globalCtx, temp + (gSaveContext.save.playerData.doubleMagic * 48) + 48); + Parameter_AddMagic(globalCtx, + ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 48) + 48); } func_80962F10(this); 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 059f18c9c..e6ede8065 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -741,7 +741,7 @@ void func_80B51B40(EnGk* this, GlobalContext* globalCtx) { this->unk_1E4 |= 2; } } - } else if ((temp_v0 == 4) && (Message_ShouldAdvance(globalCtx) != 0)) { + } else if ((temp_v0 == 4) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); 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 3a8cfdcd9..726287c0b 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 @@ -228,7 +228,7 @@ void func_80ABB590(EnGuardNuts* this, GlobalContext* globalCtx) { if ((this->guardTextIndex == 3) && (this->animIndex == WAIT_HEAD_TILT_ANIM)) { EnGuardNuts_ChangeAnim(this, WAIT_HEAD_TILT_ANIM); } - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { if (D_80ABBE38[this->guardTextIndex] != 1) { if (D_80ABBE38[this->guardTextIndex] == 2) { func_801477B4(globalCtx); 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 8844062b8..3830864d1 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -207,7 +207,7 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { } } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (Message_ShouldAdvance(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->headZRotTarget = 0; if ((this->textIdIndex == 13) || (this->textIdIndex == 14)) { diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c index 7b9fa684e..6b9a8dda1 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c @@ -252,7 +252,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x40000; gSaveContext.unk_3DD0[4] = 6; - SET_RACE_FLAGS(RACE_FLAG_4) + SET_RACE_FLAGS(RACE_FLAG_4); this->unk_174 = 60; } @@ -285,7 +285,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x40000; gSaveContext.unk_3DD0[4] = 6; - SET_RACE_FLAGS(RACE_FLAG_3) + SET_RACE_FLAGS(RACE_FLAG_3); this->unk_174 = 60; } @@ -318,7 +318,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x02000000; gSaveContext.unk_3DD0[4] = 6; - SET_RACE_FLAGS(RACE_FLAG_3) + SET_RACE_FLAGS(RACE_FLAG_3); this->unk_174 = 60; } @@ -347,7 +347,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x800; gSaveContext.unk_3DD0[4] = 6; - SET_RACE_FLAGS(RACE_FLAG_2) + SET_RACE_FLAGS(RACE_FLAG_2); this->unk_174 = 60; } return true; diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h index 1e4bf4f5a..886187b49 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h @@ -39,7 +39,7 @@ enum { gSaveContext.save.weekEventReg[92] &= (u8)~RACE_FLAGS; \ gSaveContext.save.weekEventReg[92] = \ gSaveContext.save.weekEventReg[92] | (u8)((gSaveContext.save.weekEventReg[92] & ~RACE_FLAGS) | (flag)); \ - } + } (void)0 typedef struct EnHorseGameCheck { /* 0x000 */ DynaPolyActor dyna; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 80a5c7651..557b96b31 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -874,9 +874,7 @@ s32 func_80B44234(EnInvadepoh* this, Vec3f* vec) { } void func_80B442E4(EnInvadepoh* this) { - s32 pad; - s32 sp18 = gSaveContext.save.time; - s32 temp_v1_2 = sp18 - func_80B43A24(this->actor.params & 7); + s32 temp_v1_2 = ((void)0, (s32)gSaveContext.save.time) - func_80B43A24(this->actor.params & 7); if (D_80B4E940 == 1) { this->clockTime = 0.0f; @@ -1001,6 +999,7 @@ void func_80B44700(EnInvadepoh* this) { this->clockTime = 1.0f; } else { f32 new_var = 0.00153374229558f; + this->clockTime = (currentTime + new_var4) * new_var; this->clockTime = CLAMP(this->clockTime, 0.0f, 1.0f); } 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 9412e5594..2fe0853cd 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -358,7 +358,7 @@ void EnJg_GoronShrineIdle(EnJg* this, GlobalContext* globalCtx) { } void EnJg_GoronShrineTalk(EnJg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (Message_ShouldAdvance(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if ((this->textId == 0xDCC) || (this->textId == 0xDDD) || (this->textId == 0xDE0)) { // There is nothing more to say after these lines, so end the current conversation. globalCtx->msgCtx.msgMode = 0x43; @@ -425,7 +425,7 @@ void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, GlobalContext* globalCtx) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } } else if (this->animationIndex == EN_JG_ANIMATION_SURPRISE_LOOP) { - if ((messageState == 5) && (Message_ShouldAdvance(globalCtx))) { + if ((messageState == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->flags &= ~FLAG_LOOKING_AT_PLAYER; @@ -480,7 +480,7 @@ void EnJg_Talk(EnJg* this, GlobalContext* globalCtx) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } - if ((messageState == 5) && (Message_ShouldAdvance(globalCtx))) { + if ((messageState == 5) && Message_ShouldAdvance(globalCtx)) { temp = this->textId; if ((temp == 0xDB4) || (temp == 0xDB5) || (temp == 0xDC4) || (temp == 0xDC6)) { // There is nothing more to say after these lines, so end the current conversation. @@ -600,7 +600,7 @@ void EnJg_FrozenIdle(EnJg* this, GlobalContext* globalCtx) { } void EnJg_EndFrozenInteraction(EnJg* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx) != 0) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->actionFunc = EnJg_FrozenIdle; 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 855cb0556..53dd9e671 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -415,7 +415,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { this->unkState1A8 = 0; } - if (this->unkMsgState1AC == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx) != 0) { + if ((this->unkMsgState1AC == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (this->unkMsgState1AC == 5) { // bad song input @@ -560,7 +560,7 @@ void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx) { * before actually teaching */ void EnKakasi_OcarinaRemark(EnKakasi* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx) != 0) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_80152434(globalCtx, 0x35); this->unkState1A8 = 0; if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -734,8 +734,8 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { func_8096FAAC(this, globalCtx); - if (this->unkState1A8 != 0 && Message_GetState(&globalCtx->msgCtx) == this->unkMsgState1AC && - Message_ShouldAdvance(globalCtx) != 0) { + if ((this->unkState1A8 != 0) && (Message_GetState(&globalCtx->msgCtx) == this->unkMsgState1AC) && + Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); @@ -1101,7 +1101,7 @@ void EnKakasi_IdleRisen(EnKakasi* this, GlobalContext* globalCtx) { void EnKakasi_RisenDialogue(EnKakasi* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx) != 0) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); EnKakasi_SetupIdleRisen(this); } diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c index 33474cda5..dee9a5049 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -995,7 +995,7 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { f32 shadowAlpha; if (dayTime >= CLOCK_TIME(12, 0)) { - dayTime = 0xFFFF - dayTime; + dayTime = (DAY_LENGTH - 1) - dayTime; } shadowAlpha = (dayTime * 0.00275f) + 10.0f; diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index 031f2113f..8905a862d 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -357,7 +357,7 @@ void EnMa4_Wait(EnMa4* this, GlobalContext* globalCtx) { // Chooses the next dialogue based on player's selection void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x3339: if (globalCtx->msgCtx.choiceIndex == 0) { @@ -491,7 +491,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 aux; - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x2390: func_801477B4(globalCtx); @@ -643,7 +643,7 @@ void EnMa4_DialogueHandler(EnMa4* this, GlobalContext* globalCtx) { break; case 6: // End conversation - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { if ((globalCtx->msgCtx.unk120B1 == 0) || !CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { EnMa4_SetupWait(this); } diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c index 29eb6cdcc..721e2f742 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c @@ -359,7 +359,7 @@ void EnMaYts_DialogueHandler(EnMaYts* this, GlobalContext* globalCtx) { break; case 6: // End conversation - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { EnMaYts_SetupStartDialogue(this); } break; @@ -426,7 +426,7 @@ void EnMaYts_EndCreditsHandler(EnMaYts* this, GlobalContext* globalCtx) { // Select the following dialogue based on the current one, and an appropiate face expression void EnMaYts_ChooseNextDialogue(EnMaYts* this, GlobalContext* globalCtx) { - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x335F: EnMaYts_SetFaceExpression(this, 0, 2); diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index 27192800e..3e67b4db6 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -255,10 +255,9 @@ void EnMinifrog_SpawnDust(EnMinifrog* this, GlobalContext* globalCtx) { } void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, GlobalContext* globalCtx) { - u8 flag; - EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { EnMinifrog_SetJumpState(this); @@ -270,6 +269,7 @@ void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, GlobalContext* globalCtx) { case 0xD87: // "Ah! You need not say a thing. Upon seeing that face, I understand!" ... func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; + case 0xD82: // "What has brought you all this way?" if (gSaveContext.save.weekEventReg[33] & 0x80) { // Mountain village is unfrozen func_80151938(globalCtx, 0xD83); // "Could it be... Has spring finally come to the mountains?" @@ -277,10 +277,11 @@ void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, GlobalContext* globalCtx) { func_80151938(globalCtx, 0xD86); // "Could it be... You came all this way looking for me?" } - flag = gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8]; gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] = - flag | (u8)isFrogReturnedFlags[this->frogIndex]; + ((void)0, gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8]) | + (u8)isFrogReturnedFlags[this->frogIndex]; break; + case 0xD85: // "I understand. I shall head for the mountains immediately." default: func_801477B4(globalCtx); diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index 396a3f040..393b253a9 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -375,24 +375,17 @@ void func_80A6FBA0(EnMm3* this) { void func_80A6FBFC(EnMm3* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - OSTime a; - OSTime b; if (gSaveContext.unk_3DD0[0] == 0x10) { player->stateFlags1 &= ~0x20; this->actor.flags |= ACTOR_FLAG_10000; - if (gSaveContext.unk_3DE0[0] >= 0x5DD) { - gSaveContext.unk_3DE0[0] = 0x5DC; - } else { - a = gSaveContext.unk_3DE0[0]; - if (a >= (OSTime)(995 - XREG(16))) { - b = gSaveContext.unk_3DE0[0]; - if ((OSTime)(XREG(17) + 1005) >= b) { - gSaveContext.unk_3DE0[0] = 1000; - } - } + if (gSaveContext.unk_3DE0[0] > 1500) { + gSaveContext.unk_3DE0[0] = 1500; + } else if ((((void)0, gSaveContext.unk_3DE0[0]) >= (OSTime)(995 - XREG(16))) && + (((void)0, gSaveContext.unk_3DE0[0]) <= (OSTime)(1005 + XREG(17)))) { + gSaveContext.unk_3DE0[0] = 1000; } - } else if (gSaveContext.unk_3DE0[0] >= 0x5DD) { + } else if (gSaveContext.unk_3DE0[0] > 1500) { gSaveContext.unk_3DD0[0] = 15; gSaveContext.unk_3DC8 = osGetTime(); } diff --git a/src/overlays/actors/ovl_En_Ms/z_en_ms.c b/src/overlays/actors/ovl_En_Ms/z_en_ms.c index 729e36d49..4135fe701 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.c @@ -99,13 +99,13 @@ void EnMs_Wait(EnMs* this, GlobalContext* globalCtx) { void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 6: - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { this->actionFunc = EnMs_Wait; } break; case 5: - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); Actor_PickUp(&this->actor, globalCtx, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, this->actor.playerHeightRel); @@ -114,7 +114,7 @@ void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { break; case 4: - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: // yes func_801477B4(globalCtx); diff --git a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c index 6952f10c2..aa96b13c1 100644 --- a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c +++ b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c @@ -453,7 +453,7 @@ void EnMttag_PotentiallyRestartRace(EnMttag* this, GlobalContext* globalCtx) { * responded to the Goron Elder's son's question. */ void EnMttag_HandleCantWinChoice(EnMttag* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && (Message_ShouldAdvance(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex != 0) { // Exit the race func_8019F230(); diff --git a/src/overlays/actors/ovl_En_Muto/z_en_muto.c b/src/overlays/actors/ovl_En_Muto/z_en_muto.c index 4aed3132f..c4b2beffc 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.c +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.c @@ -133,11 +133,14 @@ void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { Player* player; this->actor.textId = sTextIds[this->textIdIndex]; - if (!this->isInMayorsRoom && (player = GET_PLAYER(globalCtx))->transformation == PLAYER_FORM_DEKU) { - if (!(gSaveContext.save.weekEventReg[88] & 8)) { - this->actor.textId = 0x62C; - } else { - this->actor.textId = 0x62B; + if (!this->isInMayorsRoom) { + player = GET_PLAYER(globalCtx); + if (player->transformation == PLAYER_FORM_DEKU) { + if (!(gSaveContext.save.weekEventReg[88] & 8)) { + this->actor.textId = 0x62C; + } else { + this->actor.textId = 0x62B; + } } } diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 4d5961732..633526f81 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -1105,12 +1105,11 @@ void func_80AF8AC8(EnPm* this) { void func_80AF8BA8(s32 arg0) { static u16 D_80AFB8D4[] = { - 0x1B02, 0x1B04, 0x1B08, 0x1B10, 0x1B20, 0x0000, + 0x1B02, 0x1B04, 0x1B08, 0x1B10, 0x1B20, }; static u16 D_80AFB8E0[] = { - 0x1B40, 0x1B80, 0x1C01, 0x1C02, 0x1C04, 0x0000, + 0x1B40, 0x1B80, 0x1C01, 0x1C02, 0x1C04, }; - s32 temp; if (!(gSaveContext.save.weekEventReg[88] & 2)) { if (gSaveContext.save.weekEventReg[D_80AFB8D4[arg0] >> 8] & @@ -1129,9 +1128,8 @@ void func_80AF8BA8(s32 arg0) { } } - temp = gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8]; gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8] = - temp | (D_80AFB8E0[arg0] & (1 | 2 | 4 | 0x38 | 0x40 | 0x80)); + ((void)0, gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8]) | (u8)D_80AFB8E0[arg0]; } void func_80AF8C68(EnPm* this, GlobalContext* globalCtx) { @@ -1990,9 +1988,8 @@ void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { u16 time = gSaveContext.save.time; u16 sp3C = 0; ScheduleResult sp2C; - u32* unk_14 = &gSaveContext.save.daySpeed; - this->unk_374 = REG(15) + *unk_14; + this->unk_374 = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (this->unk_38C != 0) { time = gSaveContext.save.time - D_801F4E78; sp3C = gSaveContext.save.time; diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.c b/src/overlays/actors/ovl_En_Prz/z_en_prz.c index 29df2aa2c..797d898ac 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.c +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.c @@ -312,9 +312,8 @@ void func_80A76748(EnPrz* this) { void func_80A767A8(EnPrz* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnPr* pr = (EnPr*)this->actor.parent; - f32 sqrt; + f32 distXZ; s32 pad[2]; - u8 playerForm; if (func_80A762C0(this, globalCtx)) { func_80A75F18(this, 0); @@ -323,10 +322,10 @@ void func_80A767A8(EnPrz* this, GlobalContext* globalCtx) { return; } - sqrt = sqrtf(SQ(player->actor.world.pos.x - this->actor.parent->home.pos.x) + - SQ(player->actor.world.pos.z - this->actor.parent->home.pos.z)); + distXZ = sqrtf(SQ(player->actor.world.pos.x - this->actor.parent->home.pos.x) + + SQ(player->actor.world.pos.z - this->actor.parent->home.pos.z)); - if (!(player->stateFlags1 & 0x8000000) || (pr->unk_2C8 < sqrt)) { + if (!(player->stateFlags1 & 0x8000000) || (pr->unk_2C8 < distXZ)) { this->unk_1F2 = 100; this->skelAnime.playSpeed = 1.0f; func_80A76388(this); @@ -354,9 +353,8 @@ void func_80A767A8(EnPrz* this, GlobalContext* globalCtx) { this->unk_1C8 = 1; } - playerForm = gSaveContext.save.playerForm; - this->unk_1D8.y = - (player->actor.world.pos.y + D_80A771E0[playerForm]) + randPlusMinusPoint5Scaled((2.0f * this->unk_1E6) + 1.0f); + this->unk_1D8.y = (player->actor.world.pos.y + D_80A771E0[((void)0, gSaveContext.save.playerForm)]) + + randPlusMinusPoint5Scaled((2.0f * this->unk_1E6) + 1.0f); func_80A76070(this, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_1D8), globalCtx); } diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c index 8c2f5b6c8..56846543e 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -120,7 +120,7 @@ void EnRecepgirl_SetupTalk(EnRecepgirl* this) { } void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx) { - u8 temp_v0_2; + u8 talkState; if (SkelAnime_Update(&this->skelAnime)) { if (this->skelAnime.animation == &object_bg_Anim_00A280) { @@ -140,11 +140,11 @@ void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx) { } } - temp_v0_2 = Message_GetState(&globalCtx->msgCtx); - if (temp_v0_2 == 2) { + talkState = Message_GetState(&globalCtx->msgCtx); + if (talkState == 2) { this->actor.textId = 0x2ADC; // hear directions again? EnRecepgirl_SetupWait(this); - } else if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { + } else if ((talkState == 5) && Message_ShouldAdvance(globalCtx)) { if (this->actor.textId == 0x2AD9) { // "Welcome..." Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c index dc7715fa0..d522a4751 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -331,7 +331,7 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { } } } else if (temp_v0 == 4) { - if (Message_ShouldAdvance(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: if (gSaveContext.save.playerData.rupees < this->unk_358) { diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index 2bf6e61b5..003f731b0 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -607,8 +607,8 @@ void EnSob1_Hello(EnSob1* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if ((talkState == 5) && (Message_ShouldAdvance(globalCtx)) && - (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)))) { + if ((talkState == 5) && Message_ShouldAdvance(globalCtx) && + !EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { if (this->welcomeTextId == 0x68A) { // Welcome text when wearing Kafei's mask EnSob1_EndInteraction(globalCtx, this); } else { @@ -1084,7 +1084,7 @@ void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnGirlA* item; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (Message_ShouldAdvance(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { EnSob1_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index a4e6cfd41..40ebeb21b 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -227,12 +227,8 @@ void EnSuttari_SetNextEntrance(GlobalContext* globalCtx, u16 nextEntranceIndex) } void EnSuttari_UpdateTime(void) { - u32* unk_14 = &gSaveContext.save.daySpeed; - u16 time = gSaveContext.save.time; - - gSaveContext.save.time = (u16)REG(15) + time; - time = gSaveContext.save.time; - gSaveContext.save.time = (u16)*unk_14 + time; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.daySpeed); } s32 func_80BAA904(EnSuttari* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 91d602f87..512e90d4f 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -885,38 +885,33 @@ void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; func_808D8ED0(this, globalCtx); } - return; - if (1) {} - } - - if (ENSW_GET_3(&this->actor)) { + } else if (ENSW_GET_3(&this->actor)) { this->actionFunc = func_808DAEB4; - return; - } - - if (this->actor.bgCheckFlags & 1) { - f32 temp_f2; - - this->actor.shape.yOffset = 400.0f; - temp_f2 = fabsf(this->actor.velocity.y) * 0.6f; - this->actor.velocity.y = temp_f2; - this->unk_448 = temp_f2; - this->actor.speedXZ = 0.0f; - if ((s32)temp_f2 != 0) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); - } else { - this->actionFunc = func_808DAEB4; - this->actor.velocity.y = 0.0f; - } - if ((s32)this->actor.velocity.y >= 2) { - func_808D8940(this, globalCtx); - } } else { - Math_ApproachF(&this->actor.shape.yOffset, 400.0f, 0.3f, 1000.0f); - } + if (this->actor.bgCheckFlags & 1) { + f32 temp_f2; - Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + this->actor.shape.yOffset = 400.0f; + temp_f2 = fabsf(this->actor.velocity.y) * 0.6f; + this->actor.velocity.y = temp_f2; + this->unk_448 = temp_f2; + this->actor.speedXZ = 0.0f; + if ((s32)temp_f2 != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALTURA_BOUND); + } else { + this->actionFunc = func_808DAEB4; + this->actor.velocity.y = 0.0f; + } + if ((s32)this->actor.velocity.y >= 2) { + func_808D8940(this, globalCtx); + } + } else { + Math_ApproachF(&this->actor.shape.yOffset, 400.0f, 0.3f, 1000.0f); + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + } } void func_808DAA60(EnSw* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 1bc5484ff..52ea1d8f1 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -1097,26 +1097,19 @@ void func_809C898C(EnSyatekiMan* this, GlobalContext* globalCtx) { }; static s32 D_809C94A8 = 0; Player* player = GET_PLAYER(globalCtx); - s32 sp30; - s32 pad; - u64 sp20; - - sp20 = gSaveContext.unk_3DE0[1]; - sp30 = (sp20 * 0.1f) + 1.0f; + s32 sp30 = (((void)0, gSaveContext.unk_3DE0[1]) * 0.1f) + 1.0f; if (sp30 < 0x2EF) { s32 temp; - // clang-format off if (D_809C94A8 == 0) { - sp20 = gSaveContext.unk_3DE0[1]; temp = sp20 % 0x1F4; + temp = ((void)0, gSaveContext.unk_3DE0[1]) % 500; } else { - sp20 = gSaveContext.unk_3DE0[1]; temp = (sp20 + 250) % 0x1F4; + temp = (((void)0, gSaveContext.unk_3DE0[1]) + 250) % 500; } - //clang-format on if (temp < 100) { - this->unk_26C = 0x50; + this->unk_26C = 80; } if (this->unk_26E != 0) { @@ -1292,7 +1285,7 @@ void EnSyatekiMan_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnSyatekiMan_OverrideLimbDraw, EnSyatekiMan_PostLimbDraw, &this->actor); + EnSyatekiMan_OverrideLimbDraw, EnSyatekiMan_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c index f4d999fae..0f81d088d 100644 --- a/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c +++ b/src/overlays/actors/ovl_En_Weather_Tag/z_en_weather_tag.c @@ -482,18 +482,15 @@ void func_80967608(EnWeatherTag* this, GlobalContext* globalCtx) { void EnWeatherTag_Update(Actor* thisx, GlobalContext* globalCtx) { EnWeatherTag* this = THIS; - u16 oldTime; this->actionFunc(this, globalCtx); if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && (globalCtx->msgCtx.currentTextId == 0x5E6) && (!FrameAdvance_IsEnabled(&globalCtx->state)) && (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { - oldTime = gSaveContext.save.time; - gSaveContext.save.time = (u16)REG(0xF) + oldTime; // cast req - if (REG(0xF) != 0) { - oldTime = gSaveContext.save.time; - gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + oldTime; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); + if (REG(15) != 0) { + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.daySpeed); } } } diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.c b/src/overlays/actors/ovl_En_Yb/z_en_yb.c index 25cf4c473..724d01710 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -287,7 +287,7 @@ void EnYb_Talk(EnYb* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; EnYb_UpdateAnimation(this, globalCtx); - if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx) != 0) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.currentTextId) { case 0x147D: // I am counting on you func_801477B4(globalCtx); diff --git a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c index 15bef2ca5..1382e3d1b 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c @@ -351,7 +351,7 @@ void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 i; f32 temp; - u16 phi_a0; + u16 time; if (!(this->unk_210 & 1) && func_8012405C(globalCtx)) { Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); @@ -369,13 +369,13 @@ void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (MIRRAY3_GET_F(&this->actor) == MIRRAY3_F_1) { - phi_a0 = gSaveContext.save.time; + time = gSaveContext.save.time; - if (phi_a0 > CLOCK_TIME(12, 0)) { - phi_a0 = 0xFFFF - phi_a0; + if (time > CLOCK_TIME(12, 0)) { + time = (DAY_LENGTH - 1) - time; } - temp = (phi_a0 * (1.0f / 0x8000)); + temp = (time * (1.0f / 0x8000)); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x78, 255, 255, 255, (u8)(s8)(100 * this->unk_214)); gDPSetEnvColor(POLY_XLU_DISP++, 218, 225, (u8)((100.0f * temp) + 105.0f), 255); diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c index 8a822bea4..e058ec7c4 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -290,7 +290,6 @@ void ObjChan_InitPot(ObjChan* this, GlobalContext* globalCtx) { void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx) { s32 potBreaks; - s16 temp_v0_2; s32 phi_v1; potBreaks = false; @@ -311,9 +310,8 @@ void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_CHANDELIER_BROKEN); func_80BB9A1C((ObjChan*)this->actor.parent, 40.0f); if (this->myPotIndex == 4) { - temp_v0_2 = gSaveContext.save.weekEventReg[0x25]; - if (!(temp_v0_2 & 0x10)) { - gSaveContext.save.weekEventReg[0x25] = temp_v0_2 | 0x10; + if (!(((void)0, gSaveContext.save.weekEventReg[0x25]) & 0x10)) { + gSaveContext.save.weekEventReg[0x25] = ((void)0, gSaveContext.save.weekEventReg[0x25]) | 0x10; Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MM, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0x8000, this->actor.cutscene, this->actor.unk20, NULL); diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c index fde0406f1..052d6610a 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c @@ -138,7 +138,7 @@ void ObjWarpstone_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->isTalking) { if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { this->isTalking = false; - } else if ((Message_GetState(&globalCtx->msgCtx) == 4) && (Message_ShouldAdvance(globalCtx))) { + } else if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex != 0) { func_8019F208(); globalCtx->msgCtx.msgMode = 0x4D; From af1a4b01ef376f2c0a66ec4a7660395716ee7f60 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Thu, 26 May 2022 02:40:34 +0100 Subject: [PATCH 216/257] En_Scopecrow (#808) * En_Scopecrow * PR --- spec | 3 +- .../actors/ovl_En_Scopecrow/z_en_scopecrow.c | 324 ++++++++++++++++-- .../actors/ovl_En_Scopecrow/z_en_scopecrow.h | 21 +- undefined_syms.txt | 5 - 4 files changed, 318 insertions(+), 35 deletions(-) diff --git a/spec b/spec index 1a733af09..137ff6249 100644 --- a/spec +++ b/spec @@ -4546,8 +4546,7 @@ beginseg name "ovl_En_Scopecrow" compress include "build/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.o" - include "build/data/ovl_En_Scopecrow/ovl_En_Scopecrow.data.o" - include "build/data/ovl_En_Scopecrow/ovl_En_Scopecrow.reloc.o" + include "build/src/overlays/actors/ovl_En_Scopecrow/ovl_En_Scopecrow_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c index bf0b6a839..5743f4a48 100644 --- a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c +++ b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c @@ -18,7 +18,6 @@ void EnScopecrow_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BCD590(EnScopecrow* this, GlobalContext* globalCtx); void func_80BCD640(EnScopecrow* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Scopecrow_InitVars = { ACTOR_EN_SCOPECROW, ACTORCAT_NPC, @@ -31,47 +30,324 @@ const ActorInit En_Scopecrow_InitVars = { (ActorFunc)EnScopecrow_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80BCDB70[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 60, 0 }, 50 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80BCDB94 = { - { COLTYPE_HIT3, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80BCDB70, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -#endif +void func_80BCD000(EnScopecrow* this, GlobalContext* globalCtx) { + this->collider.elements->dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.elements->dim.worldSphere.center.y = + sJntSphInit.elements[0].dim.modelSphere.center.y + this->actor.world.pos.y; + this->collider.elements->dim.worldSphere.center.z = this->actor.world.pos.z; -extern ColliderJntSphElementInit D_80BCDB70[1]; -extern ColliderJntSphInit D_80BCDB94; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -extern UNK_TYPE D_060010C0; +s32 func_80BCD09C(s16 arg0) { + switch (arg0) { + case 0: + if (gSaveContext.save.weekEventReg[53] & 4) { + return true; + } + return false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD000.s") + case 1: + if (gSaveContext.save.weekEventReg[53] & 0x80) { + return true; + } + return false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD09C.s") + case 2: + if (gSaveContext.save.weekEventReg[54] & 1) { + return true; + } + return false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD1AC.s") + case 3: + if (gSaveContext.save.weekEventReg[54] & 2) { + return true; + } + return false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD2BC.s") + case 4: + if (gSaveContext.save.weekEventReg[54] & 4) { + return true; + } + return false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD334.s") + case 5: + if (gSaveContext.save.weekEventReg[54] & 8) { + return true; + } + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD4D0.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD590.s") +s32 func_80BCD1AC(s16 arg0) { + switch (arg0) { + case 0: + if (!(gSaveContext.save.weekEventReg[53] & 4)) { + gSaveContext.save.weekEventReg[53] |= 4; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/func_80BCD640.s") + case 1: + if (!(gSaveContext.save.weekEventReg[53] & 0x80)) { + gSaveContext.save.weekEventReg[53] |= 0x80; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/EnScopecrow_Init.s") + case 2: + if (!(gSaveContext.save.weekEventReg[54] & 1)) { + gSaveContext.save.weekEventReg[54] |= 1; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/EnScopecrow_Destroy.s") + case 3: + if (!(gSaveContext.save.weekEventReg[54] & 2)) { + gSaveContext.save.weekEventReg[54] |= 2; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/EnScopecrow_Update.s") + case 4: + if (!(gSaveContext.save.weekEventReg[54] & 4)) { + gSaveContext.save.weekEventReg[54] |= 4; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Scopecrow/EnScopecrow_Draw.s") + case 5: + if (!(gSaveContext.save.weekEventReg[54] & 8)) { + gSaveContext.save.weekEventReg[54] |= 8; + return true; + } + break; + } + + return false; +} + +void func_80BCD2BC(EnScopecrow* this, GlobalContext* globalCtx) { + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SC_RUPPE, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, + this->actor.shape.rot.y, this->actor.shape.rot.z, this->actor.params, + this->actor.cutscene, this->actor.unk20, NULL); +} + +s32 func_80BCD334(EnScopecrow* this, Path* path, s32 pointIndex) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 sp58 = path->count; + s32 index = pointIndex; + s32 ret = false; + f32 phi_fa0; + f32 phi_fa1; + Vec3f sp3C; + Vec3f sp30; + + Math_Vec3s_ToVec3f(&sp30, &points[index]); + + if (index == 0) { + phi_fa0 = points[1].x - points[0].x; + phi_fa1 = points[1].z - points[0].z; + } else if ((sp58 - 1) == index) { + phi_fa0 = points[sp58 - 1].x - points[sp58 - 2].x; + phi_fa1 = points[sp58 - 1].z - points[sp58 - 2].z; + } else { + phi_fa0 = points[index + 1].x - points[index - 1].x; + phi_fa1 = points[index + 1].z - points[index - 1].z; + } + + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_fa0, phi_fa1)), &sp3C.z, &sp3C.y, &sp3C.x); + + if (((this->actor.world.pos.x * sp3C.z) + (sp3C.y * this->actor.world.pos.z) + sp3C.x) > 0.0f) { + ret = true; + } + return ret; +} + +f32 func_80BCD4D0(Path* path, s32 count, Vec3f* arg2, Vec3s* arg3) { + Vec3s* temp; + Vec3f sp20; + Vec3s* points; + + if (path != NULL) { + temp = Lib_SegmentedToVirtual(path->points); + points = temp + count; + + sp20.x = points->x; + sp20.y = points->y; + sp20.z = points->z; + } + + arg3->y = Math_Vec3f_Yaw(arg2, &sp20); + arg3->x = Math_Vec3f_Pitch(arg2, &sp20); + return sp20.y - arg2->y; +} + +void func_80BCD590(EnScopecrow* this, GlobalContext* globalCtx) { + Vec3f sp1C; + + func_80169474(globalCtx, &this->actor.world.pos, &sp1C); + + if ((sp1C.x >= 130.0f) && (sp1C.x < 190.0f) && (sp1C.y >= 90.0f) && (sp1C.y < 150.0f)) { + this->actor.draw = EnScopecrow_Draw; + this->actionFunc = func_80BCD640; + } +} + +void func_80BCD640(EnScopecrow* this, GlobalContext* globalCtx) { + Vec3s sp30; + + if (this->path != NULL) { + func_80BCD4D0(this->path, this->unk_1FC, &this->actor.world.pos, &sp30); + if (this->actor.bgCheckFlags & 8) { + sp30.y = this->actor.wallYaw; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, sp30.y, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->actor.world.rot.x, -sp30.x, 4, 0x3E8, 1); + + if (func_80BCD334(this, this->path, this->unk_1FC)) { + if ((this->unk_1FC == this->unk_262) && func_80BCD1AC(this->unk_260)) { + func_80BCD2BC(this, globalCtx); + } + + if (this->unk_1FC >= (this->path->count - 1)) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_1FC++; + } + } + } + + Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 1.0f); + Actor_MoveWithoutGravity(&this->actor); + this->unk_264 += 0x1000; + this->actor.shape.yOffset = Math_SinS(this->unk_264) * 500.0f; +} + +void EnScopecrow_Init(Actor* thisx, GlobalContext* globalCtx) { + EnScopecrow* this = THIS; + Vec3s* temp; + CollisionPoly* sp4C; + Vec3s* points; + Vec3f sp3C; + + this->unk_260 = ENSCOPECROW_GET_1F(&this->actor); + if ((this->unk_260 < 0) || (this->unk_260 >= 6)) { + this->unk_260 = 0; + } + + if (func_80BCD09C(this->unk_260)) { + this->path = SubS_GetPathByIndex(globalCtx, ENSCOPECROW_GET_PATH(&this->actor), 0x3F); + this->unk_262 = ENSCOPECROW_GET_3E0(&this->actor); + + if (this->path != NULL) { + if ((this->unk_262 <= 0) || ((this->path->count - 1) < this->unk_262)) { + this->unk_262 = this->path->count - 1; + } + + temp = Lib_SegmentedToVirtual(this->path->points); + points = temp + this->unk_262; + + sp3C.x = points->x; + sp3C.y = points->y; + sp3C.z = points->z; + + this->actor.world.pos = sp3C; + this->actor.world.pos.y = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp4C, &sp3C); + if (this->actor.world.pos.y == BGCHECK_Y_MIN) { + Actor_MarkForDeath(&this->actor); + } + + func_80BCD2BC(this, globalCtx); + Actor_MarkForDeath(&this->actor); + return; + } + + Actor_MarkForDeath(&this->actor); + return; + } + + if (globalCtx->actorCtx.unk5 & 2) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, + OBJECT_CROW_LIMB_MAX); + ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); + + Collider_InitJntSph(globalCtx, &this->collider); + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; + + Actor_SetScale(&this->actor, 0.03f); + this->path = SubS_GetPathByIndex(globalCtx, ENSCOPECROW_GET_PATH(&this->actor), 0x3F); + this->unk_262 = ENSCOPECROW_GET_3E0(&this->actor); + + if (this->path != NULL) { + if ((this->unk_262 <= 0) || ((this->path->count - 1) < this->unk_262)) { + this->unk_262 = this->path->count - 1; + } + this->actor.draw = NULL; + this->actor.gravity = 0.0f; + this->actionFunc = func_80BCD590; + return; + } + + Actor_MarkForDeath(&this->actor); + return; + } + + Actor_MarkForDeath(&this->actor); +} + +void EnScopecrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnScopecrow* this = THIS; + + Collider_DestroyJntSph(globalCtx, &this->collider); +} + +void EnScopecrow_Update(Actor* thisx, GlobalContext* globalCtx) { + EnScopecrow* this = THIS; + + this->actionFunc(this, globalCtx); + + SkelAnime_Update(&this->skelAnime); + func_80BCD000(this, globalCtx); +} + +void EnScopecrow_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnScopecrow* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.h b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.h index 2b5b38eae..72469bd75 100644 --- a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.h +++ b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.h @@ -2,16 +2,29 @@ #define Z_EN_SCOPECROW_H #include "global.h" +#include "objects/object_crow/object_crow.h" struct EnScopecrow; typedef void (*EnScopecrowActionFunc)(struct EnScopecrow*, GlobalContext*); +#define ENSCOPECROW_GET_1F(thisx) ((thisx)->params & 0x1F) +#define ENSCOPECROW_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) +#define ENSCOPECROW_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 0xA) + typedef struct EnScopecrow { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnScopecrowActionFunc actionFunc; - /* 0x018C */ char unk_18C[0xDC]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnScopecrowActionFunc actionFunc; + /* 0x18C */ Vec3s jointTable[OBJECT_CROW_LIMB_MAX]; + /* 0x1C2 */ Vec3s morphTable[OBJECT_CROW_LIMB_MAX]; + /* 0x1F8 */ Path* path; + /* 0x1FC */ s32 unk_1FC; + /* 0x200 */ ColliderJntSph collider; + /* 0x220 */ ColliderJntSphElement colliderElements[1]; + /* 0x260 */ s16 unk_260; + /* 0x262 */ s16 unk_262; + /* 0x264 */ s16 unk_264; } EnScopecrow; // size = 0x268 extern const ActorInit En_Scopecrow_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 91ead11f3..f24e3b627 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1444,11 +1444,6 @@ D_06003A20 = 0x06003A20; D_0600D768 = 0x0600D768; D_0600D8D8 = 0x0600D8D8; -// ovl_En_Scopecrow - -D_060000F0 = 0x060000F0; -D_060010C0 = 0x060010C0; - // ovl_En_Slime D_060004C0 = 0x060004C0; From a6e90d144cef5ac16327b9315acd50722d279bf1 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 25 May 2022 18:44:09 -0700 Subject: [PATCH 217/257] SubS models (#807) * Bring model code over * SubS_UpdateLimb * SubS_TurnToPoint * SubS_TurnToPointMultiTarget * Adjust comment * Another comment * Review * options as structs * bss * adj -> step, SubS_TurnToPointMultiTarget -> SubS_TurnToPointStep, various comment cleanups * Fix SubS_TurnToPointStep header comment --- include/functions.h | 8 +- include/z64subs.h | 14 ++ include/z_en_hy_code.h | 4 +- src/boot_O2_g3/z_std_dma.c | 1 - src/code/z_sub_s.c | 179 +++++++++++++++++- src/overlays/actors/ovl_Dm_An/z_dm_an.c | 32 ++-- src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c | 24 +-- src/overlays/actors/ovl_En_Ah/z_en_ah.c | 31 +-- src/overlays/actors/ovl_En_Al/z_en_al.c | 18 +- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 57 +++--- .../actors/ovl_En_Aob_01/z_en_aob_01.h | 6 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 39 ++-- src/overlays/actors/ovl_En_Baba/z_en_baba.h | 6 +- .../actors/ovl_En_Bba_01/z_en_bba_01.c | 27 +-- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 20 +- .../actors/ovl_En_Bji_01/z_en_bji_01.h | 8 +- .../actors/ovl_En_Cne_01/z_en_cne_01.c | 27 +-- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 24 +-- src/overlays/actors/ovl_En_Go/z_en_go.c | 26 +-- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 18 +- src/overlays/actors/ovl_En_In/z_en_in.c | 39 ++-- src/overlays/actors/ovl_En_In/z_en_in.h | 6 +- src/overlays/actors/ovl_En_Ja/z_en_ja.c | 26 +-- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 22 +-- src/overlays/actors/ovl_En_Shn/z_en_shn.c | 18 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 55 +++--- .../actors/ovl_En_Suttari/z_en_suttari.h | 6 +- src/overlays/actors/ovl_En_Tab/z_en_tab.c | 20 +- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 22 +-- src/overlays/actors/ovl_En_Zo/z_en_zo.c | 23 ++- src/overlays/actors/ovl_En_Zo/z_en_zo.h | 2 +- tools/disasm/functions.txt | 12 +- tools/namefixer.py | 23 ++- tools/sizes/code_functions.csv | 8 +- 34 files changed, 535 insertions(+), 316 deletions(-) diff --git a/include/functions.h b/include/functions.h index 0f3a2e671..e3f700d72 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2424,7 +2424,7 @@ struct EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag); Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx); s32 SubS_InCsMode(GlobalContext* globalCtx); -s32 func_8013AD9C(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5); +s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot); void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits); void func_8013AF00(f32* arg0, s32 arg1, s32 arg2); s32 func_8013B010(f32* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, f32* arg6); @@ -2444,8 +2444,8 @@ s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRang void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size); void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], s8 parentBodyParts[]); void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex); -s16 func_8013D0E0(s16* arg0, s16 arg1, s16 arg2, f32 arg3, f32 arg4, f32 arg5); -s32 func_8013D2E0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Vec3s* arg3, Vec3s* arg4, Vec3s* arg5, u16* arg6); +s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax); +s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, TurnOptionsSet* options); s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); Path* SubS_GetPathByIndex(GlobalContext* globalCtx, s16 pathIndex, s16 max); s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst); @@ -2474,7 +2474,7 @@ Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actor s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, func_8013E748_VerifyFunc verifyFunc); s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, void* data); s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, s16 actorYawTol); -s32 func_8013E950(Vec3f* arg0, Vec3f* arg1, s16 arg2, Vec3f* arg3, Vec3f* arg4, s16* arg5, s16* arg6, s16* arg7, s16* arg8, u16 arg9, u16 arg10, u16 arg11, u16 arg12); +s32 SubS_TurnToPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax); // void func_8013EC10(void); void func_8013EC44(f32 a, u8 b, u8 c, u8 d); void func_8013ECE0(f32 xyzDistToPlayerSq, u8 arg1, u8 arg2, u8 arg3); diff --git a/include/z64subs.h b/include/z64subs.h index f01230fdb..3b13d2add 100644 --- a/include/z64subs.h +++ b/include/z64subs.h @@ -38,6 +38,20 @@ typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); #define ACTOR_PATHING_REACHED_END \ (ACTOR_PATHING_REACHED_END_PERMANENT | ACTOR_PATHING_REACHED_END_TEMPORARY) +typedef struct TurnOptions { + /* 0x0 */ u16 rotMax; // binary angles + /* 0x2 */ u16 slowness; // larger for slower rotation, cannot be 0 + /* 0x4 */ u16 rotStepMin; // degrees + /* 0x6 */ u16 rotStepMax; // degrees +} TurnOptions; // size = 0x8 + +typedef struct TurnOptionsSet { + /* 0x00 */ TurnOptions headRotX; + /* 0x08 */ TurnOptions headRotY; + /* 0x10 */ TurnOptions torsoRotX; + /* 0x18 */ TurnOptions torsoRotY; +} TurnOptionsSet; // size = 0x20 + struct ActorPathing; typedef void (*ActorPathingComputeFunc)(struct GlobalContext*, struct ActorPathing*); typedef s32 (*ActorPathingUpdateFunc)(struct GlobalContext*, struct ActorPathing*); diff --git a/include/z_en_hy_code.h b/include/z_en_hy_code.h index 970706760..a0f9bcdd4 100644 --- a/include/z_en_hy_code.h +++ b/include/z_en_hy_code.h @@ -57,10 +57,10 @@ typedef struct EnHy { /* 0x205 */ u8 isRightFootOnGround; /* 0x206 */ Vec3s jointTable[ENHY_LIMB_MAX]; /* 0x266 */ Vec3s morphTable[ENHY_LIMB_MAX]; - /* 0x2C6 */ Vec3s focusTarget; + /* 0x2C6 */ Vec3s turnTarget; /* 0x2CC */ Vec3s headRot; /* 0x2D2 */ Vec3s torsoRot; - /* 0x2D8 */ Vec3s tmpFocusTarget; + /* 0x2D8 */ Vec3s tmpTurnTarget; /* 0x2DE */ Vec3s tmpHeadRot; /* 0x2E4 */ Vec3s tmpTorsoRot; /* 0x2EA */ s16 limbRotTableY[16]; diff --git a/src/boot_O2_g3/z_std_dma.c b/src/boot_O2_g3/z_std_dma.c index 10d84dcb0..d9c7fb221 100644 --- a/src/boot_O2_g3/z_std_dma.c +++ b/src/boot_O2_g3/z_std_dma.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" u32 sDmaMgrDmaBuffSize = 0x2000; diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index b51de4897..58812abc9 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -168,7 +168,47 @@ s32 SubS_InCsMode(GlobalContext* globalCtx) { return inCsMode; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AD9C.s") +/** + * Computes a limb's position and rotation for use in TransformLimbDraws + * + * @param[in] newRotZ value to override newRot's Z value if override is true + * @param[in] newRotY value to override newRot's Y value if override is true + * @param[out] pos limb's computed position + * @param[out] rot limb's computed rotation + * @param[in] stepRot boolean, step towards newRot instead of setting directly + * @param[in] overrideRot boolean, override newRot with the specified input. + * + * Note: + * If overrideRot is true, the rotation will automatically step instead of setting directly + */ +s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot) { + Vec3f newPos; + Vec3f zeroVec = gZeroVec3f; + Vec3s newRot; + MtxF curState; + + Matrix_MultiplyVector3fByState(&zeroVec, &newPos); + Matrix_CopyCurrentState(&curState); + func_8018219C(&curState, &newRot, MTXMODE_NEW); + *pos = newPos; + + if (!stepRot && !overrideRot) { + rot->x = newRot.x; + rot->y = newRot.y; + rot->z = newRot.z; + return true; + } + + if (overrideRot) { + newRot.z = newRotZ; + newRot.y = newRotY; + } + + Math_SmoothStepToS(&rot->x, newRot.x, 3, 0x2AA8, 0xB6); + Math_SmoothStepToS(&rot->y, newRot.y, 3, 0x2AA8, 0xB6); + Math_SmoothStepToS(&rot->z, newRot.z, 3, 0x2AA8, 0xB6); + return true; +} void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits) { *flags = (*flags & ~unsetBits) | setBits; @@ -525,9 +565,93 @@ void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex) { CLOSE_DISPS(gfxCtx); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D0E0.s") +/** + * Computes the rotation based on the options and target rotation value + * + * @param[in,out] rot the computed rotation + * @param[in] rotMax the max rotation in binary angles + * @param[in] target the target rotation value + * @param[in] slowness how slow to rotate, the larger the number the slower the rotation, cannot be 0 + * @param[in] stepMin the minimun step in degrees + * @param[in] stepMax the maximum step in degrees + */ +s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax) { + s16 prevRot = *rot; + f32 step; + f32 prevRotStep; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D2E0.s") + step = (f32)(target - *rot) * (360.0f / (f32)0x10000); + step *= gFramerateDivisorHalf; + prevRotStep = step; + if (step >= 0.0f) { + step /= slowness; + step = CLAMP(step, stepMin, stepMax); + *rot += (s16)((step * (f32)0x10000) / 360.0f); + if (prevRotStep < stepMin) { + *rot = target; + } + if (rotMax != 0) { + *rot = CLAMP(*rot, -rotMax, rotMax); + } + } else { + step = (step / slowness) * -1.0f; + step = CLAMP(step, stepMin, stepMax); + *rot -= (s16)((step * (f32)0x10000) / 360.0f); + if (-stepMin < prevRotStep) { + *rot = target; + } + if (rotMax != 0) { + *rot = CLAMP(*rot, -rotMax, rotMax); + } + } + + return prevRot - *rot; +} + +/** + * Computes the necessary HeadRot and TorsoRot to smoothly turn an actors's head and torso to a point + * + * @param[in] point the point to turn to + * @param[in] focusPos the actor's focus postion + * @param[in] shapeRot the actor's shape rotation + * @param[in,out] turnTarget the intermediate target step that headRot and torsoRot step towards + * @param[in,out] headRot the computed head rotation + * @param[in,out] torsoRot the computed torso rotation + * @param[in] options various options to adjust how the actor turns, see `SubS_ComputeTurnToPointRot and + * TurnOptions/TurnOptionsSet` + * + */ +s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, + TurnOptionsSet* options) { + s16 pitch; + s16 yaw; + s16 pad; + s16 targetY; + f32 diffX = point->x - focusPos->x; + s16 targetX; + f32 diffZ = point->z - focusPos->z; + + yaw = Math_FAtan2F(diffZ, diffX); + pitch = Math_FAtan2F(sqrtf(SQ(diffX) + SQ(diffZ)), point->y - focusPos->y); + Math_SmoothStepToS(&turnTarget->x, pitch, 4, 0x2710, 0); + Math_SmoothStepToS(&turnTarget->y, yaw, 4, 0x2710, 0); + + targetX = + SubS_ComputeTurnToPointRot(&headRot->x, options->headRotX.rotMax, turnTarget->x, options->headRotX.slowness, + options->headRotX.rotStepMin, options->headRotX.rotStepMax); + //! @bug: torsoRotX uses headRotX slowness + SubS_ComputeTurnToPointRot(&torsoRot->x, options->torsoRotX.rotMax, targetX, options->headRotX.slowness, + options->torsoRotX.rotStepMin, options->torsoRotX.rotStepMax); + + targetY = turnTarget->y - shapeRot->y; + SubS_ComputeTurnToPointRot(&headRot->y, options->headRotY.rotMax, targetY - torsoRot->y, options->headRotY.slowness, + options->headRotY.rotStepMin, options->headRotY.rotStepMax); + SubS_ComputeTurnToPointRot(&torsoRot->y, options->torsoRotY.rotMax, targetY - headRot->y, + options->torsoRotY.slowness, options->torsoRotY.rotStepMin, + options->torsoRotY.rotStepMax); + + return true; +} s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB) { return (ABS_ALT(BINANG_SUB(angleB, angleA)) <= threshold) ? true : false; @@ -987,4 +1111,51 @@ s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRang return func_8013E748(actor, globalCtx, xzRange, yRange, exhangeItemId, &yawTols, SubS_ActorAndPlayerFaceEachOther); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E950.s") +/** + * Computes the necessary HeadRot and TorsoRot steps to be added to the normal rotation to smoothly turn an actors's + * head and torso to a point + * + * @param[in] worldPos the actor's world position + * @param[in] focusPos the actor's focus position + * @param[in] shapeYRot the actor's shape's Y rotation + * @param[in] yawTarget the target point to determine desired yaw + * @param[in] pitchTarget the target point to determine desired pitch + * @param[in,out] headZRotStep the computed actors' head's Z rotation step + * @param[in,out] headXRotStep the computed actors' head's X rotation step + * @param[in,out] torsoZRotStep the computed actors' torso's Z rotation step + * @param[in,out] torsoXRotStep the computed actors' torso's X rotation step + * @param[in] headZRotStepMax the max head's Z rotation step + * @param[in] headXRotStepMax the max head's X rotation step + * @param[in] torsoZRotStepMax the max torso's Z rotation step + * @param[in] torsoXRotStepMax the max torso's X rotation step + */ +s32 SubS_TurnToPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, + s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, + u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax) { + s16 yaw = Math_Vec3f_Yaw(worldPos, yawTarget) - shapeYRot; + s16 pad; + s16 pad2; + s16 pitch = Math_Vec3f_Pitch(focusPos, pitchTarget); + + if (BINANG_ADD(headXRotStepMax, torsoXRotStepMax) >= (s16)ABS(yaw)) { + Math_ApproachS(headXRotStep, yaw - *torsoXRotStep, 4, 0x2AA8); + *headXRotStep = CLAMP(*headXRotStep, -headXRotStepMax, headXRotStepMax); + Math_ApproachS(torsoXRotStep, yaw - *headXRotStep, 4, 0x2AA8); + *torsoXRotStep = CLAMP(*torsoXRotStep, -torsoXRotStepMax, torsoXRotStepMax); + } else { + Math_ApproachS(headXRotStep, 0, 4, 0x2AA8); + Math_ApproachS(torsoXRotStep, 0, 4, 0x2AA8); + } + + if (BINANG_ADD(headZRotStepMax, torsoZRotStepMax) >= (s16)ABS(pitch)) { + Math_ApproachS(headZRotStep, pitch - *torsoZRotStep, 4, 0x2AA8); + *headZRotStep = CLAMP(*headZRotStep, -headZRotStepMax, headZRotStepMax); + Math_ApproachS(torsoZRotStep, pitch - *headZRotStep, 4, 0x2AA8); + *torsoZRotStep = CLAMP(*torsoZRotStep, -torsoZRotStepMax, torsoZRotStepMax); + } else { + Math_ApproachS(headZRotStep, 0, 4, 0x2AA8); + Math_ApproachS(torsoZRotStep, 0, 4, 0x2AA8); + } + + return true; +} diff --git a/src/overlays/actors/ovl_Dm_An/z_dm_an.c b/src/overlays/actors/ovl_Dm_An/z_dm_an.c index 2c23601f7..18548675d 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.c +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.c @@ -301,25 +301,25 @@ void func_80C1CD80(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* void func_80C1CEFC(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { DmAn* this = THIS; - s16 phi_v1; - s16 phi_v0; + s16 stepRot; + s16 overrideRot; if (!(this->unk_2AE & 1)) { if (this->unk_2AE & 2) { - phi_v0 = 1; + overrideRot = true; } else { - phi_v0 = 0; + overrideRot = false; } - phi_v1 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + stepRot = false; + overrideRot = false; } if (limbIndex == OBJECT_AN1_LIMB_09) { - func_8013AD9C(this->unk_2BE + this->unk_2C2 + 0x4000, - this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, &this->unk_1A4, - phi_v1, phi_v0); + SubS_UpdateLimb(this->unk_2BE + this->unk_2C2 + 0x4000, + this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, + &this->unk_1A4, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); @@ -328,8 +328,8 @@ void func_80C1CEFC(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { Matrix_InsertZRotation_s(this->unk_1A4.z, MTXMODE_APPLY); Matrix_StatePush(); } else if (limbIndex == OBJECT_AN1_LIMB_02) { - func_8013AD9C(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, - &this->unk_1AA, phi_v1, phi_v0); + SubS_UpdateLimb(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, + &this->unk_1AA, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); @@ -342,13 +342,13 @@ void func_80C1CEFC(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { TexturePtr D_80C1D2E8[] = { object_an1_Tex_00E6E0, - &object_an1_Tex_00F7A0, - &object_an1_Tex_0101A0, + object_an1_Tex_00F7A0, + object_an1_Tex_0101A0, }; TexturePtr D_80C1D2F4[] = { - &object_an1_Tex_00E1E0, &object_an1_Tex_00EFA0, &object_an1_Tex_00F3A0, &object_an1_Tex_00EFA0, - &object_an1_Tex_00FDA0, &object_an1_Tex_00F9A0, &object_an1_Tex_0103A0, + object_an1_Tex_00E1E0, object_an1_Tex_00EFA0, object_an1_Tex_00F3A0, object_an1_Tex_00EFA0, + object_an1_Tex_00FDA0, object_an1_Tex_00F9A0, object_an1_Tex_0103A0, }; void func_80C1D0B0(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c index 88a99ad53..969b7a80b 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c @@ -301,25 +301,25 @@ void DmGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec void DmGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { DmGm* this = THIS; - s16 phi_v1; - s16 phi_v0; + s16 stepRot; + s16 overrideRot; if (!(this->unk_2AE & 1)) { if (this->unk_2AE & 2) { - phi_v0 = 1; + overrideRot = true; } else { - phi_v0 = 0; + overrideRot = false; } - phi_v1 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + stepRot = false; + overrideRot = false; } if (limbIndex == OBJECT_AN1_LIMB_09) { - func_8013AD9C(this->unk_2BE + this->unk_2C2 + 0x4000, - this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, &this->unk_1A4, - phi_v1, phi_v0); + SubS_UpdateLimb(this->unk_2BE + this->unk_2C2 + 0x4000, + this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, + &this->unk_1A4, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); @@ -328,8 +328,8 @@ void DmGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this Matrix_InsertZRotation_s(this->unk_1A4.z, MTXMODE_APPLY); Matrix_StatePush(); } else if (limbIndex == OBJECT_AN1_LIMB_02) { - func_8013AD9C(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, - &this->unk_1AA, phi_v1, phi_v0); + SubS_UpdateLimb(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, + &this->unk_1AA, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index 732b3e37b..405c2ffb4 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -564,7 +564,7 @@ void EnAh_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80BD3AA8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnAh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnAh* this = THIS; if (limbIndex == 7) { @@ -573,27 +573,27 @@ void func_80BD3AA8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } } -void func_80BD3AF8(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnAh_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnAh* this = THIS; - s32 phi_v1; - s32 phi_v0; + s32 stepRot; + s32 overrideRot; if (!(this->unk_2D8 & 0x80)) { if (this->unk_2D8 & 0x20) { - phi_v0 = 1; + overrideRot = true; } else { - phi_v0 = 0; + overrideRot = false; } - phi_v1 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + stepRot = false; + overrideRot = false; } if (limbIndex == 7) { - func_8013AD9C(BINANG_ADD(this->unk_2EC + this->unk_2F0, 0x4000), - BINANG_ADD(this->unk_2EE + this->unk_2F2 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, - this->unk_200, phi_v1, phi_v0); + SubS_UpdateLimb(BINANG_ADD(this->unk_2EC + this->unk_2F0, 0x4000), + BINANG_ADD(this->unk_2EE + this->unk_2F2 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, + this->unk_200, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); @@ -602,8 +602,8 @@ void func_80BD3AF8(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { Matrix_InsertZRotation_s(this->unk_200[0].z, MTXMODE_APPLY); Matrix_StatePush(); } else if (limbIndex == 2) { - func_8013AD9C(BINANG_ADD(this->unk_2F0, 0x4000), BINANG_ADD(this->unk_2F2 + this->actor.shape.rot.y, 0x4000), - &this->unk_1E8[1], &this->unk_200[1], phi_v1, phi_v0); + SubS_UpdateLimb(BINANG_ADD(this->unk_2F0, 0x4000), BINANG_ADD(this->unk_2F2 + this->actor.shape.rot.y, 0x4000), + &this->unk_1E8[1], &this->unk_200[1], stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_1E8[1].x, this->unk_1E8[1].y, this->unk_1E8[1].z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); @@ -626,7 +626,8 @@ void EnAh_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80BD3F0C[this->unk_2FC])); SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, NULL, func_80BD3AA8, func_80BD3AF8, &this->actor); + this->skelAnime.dListCount, NULL, EnAh_PostLimbDraw, EnAh_TransformLimbDraw, + &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index 149f82d45..063c50b61 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -871,24 +871,24 @@ void EnAl_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec void EnAl_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnAl* this = THIS; - s32 phi_v0; - s32 phi_v1; + s32 stepRot; + s32 overrideRot; if (!(this->unk_4C2 & 0x200)) { if (this->unk_4C2 & 0x80) { - phi_v1 = 1; + overrideRot = true; } else { - phi_v1 = 0; + overrideRot = false; } - phi_v0 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + overrideRot = false; + stepRot = false; } if (limbIndex == 16) { - func_8013AD9C(this->unk_4DC + 0x4000, this->unk_4DE + this->actor.shape.rot.y + 0x4000, &this->unk_36C, - &this->unk_378, phi_v0, phi_v1); + SubS_UpdateLimb(this->unk_4DC + 0x4000, this->unk_4DE + this->actor.shape.rot.y + 0x4000, &this->unk_36C, + &this->unk_378, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_36C.x, this->unk_36C.y, this->unk_36C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index 28b6251a1..b949b4be3 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -462,24 +462,29 @@ void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { } void func_809C1EC8(EnAob01* this, GlobalContext* globalCtx) { - static u16 D_809C392C[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; + static TurnOptionsSet sTurnOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + }; Player* player = GET_PLAYER(globalCtx); - Vec3f sp30; + Vec3f point; SkelAnime_Update(&this->skelAnime); if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer)) { - sp30.x = player->actor.world.pos.x; - sp30.y = player->bodyPartsPos[7].y + 3.0f; - sp30.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk_2D4, &this->unk_2DA, - &this->unk_2E0, D_809C392C); + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; + SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, + &this->torsoRot, &sTurnOptions); } else { - Math_SmoothStepToS(&this->unk_2D4.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2D4.y, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2DA.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2DA.y, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2E0.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2E0.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.y, 0, 4, 0x3E8, 1); } func_809C10B0(this, 3); SubS_FillLimbRotTables(globalCtx, this->unk_2F8, this->unk_318, ARRAY_COUNT(this->unk_2F8)); @@ -500,9 +505,9 @@ void func_809C2060(EnAob01* this, GlobalContext* globalCtx) { } } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_2D2 & 0x100)) { this->unk_2D2 &= ~0x100; - this->unk_2E6 = this->unk_2D4; - this->unk_2EC = this->unk_2DA; - this->unk_2F2 = this->unk_2E0; + this->unk_2E6 = this->turnTarget; + this->unk_2EC = this->headRot; + this->unk_2F2 = this->torsoRot; func_809C16DC(this, globalCtx); this->actionFunc = func_809C21E0; } else { @@ -751,9 +756,9 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { } if (Actor_HasParent(&this->actor, globalCtx)) { - this->unk_2D4 = this->unk_2E6; - this->unk_2DA = this->unk_2EC; - this->unk_2E0 = this->unk_2F2; + this->turnTarget = this->unk_2E6; + this->headRot = this->unk_2EC; + this->torsoRot = this->unk_2F2; this->actor.parent = NULL; this->actor.shape.rot.y = this->actor.world.rot.y; if (gSaveContext.save.weekEventReg[8] & 0x20) { @@ -822,9 +827,9 @@ void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, this->unk_210, &this->actor); this->actionFunc = func_809C2A64; } else { - this->unk_2D4 = this->unk_2E6; - this->unk_2DA = this->unk_2EC; - this->unk_2E0 = this->unk_2F2; + this->turnTarget = this->unk_2E6; + this->headRot = this->unk_2EC; + this->torsoRot = this->unk_2F2; this->unk_434 = 0; this->actor.shape.rot.y = this->actor.world.rot.y; @@ -995,14 +1000,14 @@ s32 EnAob01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2DA.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2DA.x * -1, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->headRot.x * -1, MTXMODE_APPLY); Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == MAMAMU_YAN_LIMB_TORSO) { - Matrix_InsertXRotation_s(this->unk_2E0.y * -1, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2E0.x * -1, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->torsoRot.y * -1, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->torsoRot.x * -1, MTXMODE_APPLY); } if ((limbIndex == MAMAMU_YAN_LIMB_TORSO) || (limbIndex == MAMAMU_YAN_LIMB_LEFT_UPPER_ARM) || diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h index 69e15f658..d4ed3e71e 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h @@ -21,9 +21,9 @@ typedef struct EnAob01 { /* 0x212 */ Vec3s jointTable[MAMAMU_YAN_LIMB_MAX]; /* 0x272 */ Vec3s morphTable[MAMAMU_YAN_LIMB_MAX]; /* 0x2D2 */ u16 unk_2D2; - /* 0x2D4 */ Vec3s unk_2D4; - /* 0x2DA */ Vec3s unk_2DA; - /* 0x2E0 */ Vec3s unk_2E0; + /* 0x2D4 */ Vec3s turnTarget; + /* 0x2DA */ Vec3s headRot; + /* 0x2E0 */ Vec3s torsoRot; /* 0x2E6 */ Vec3s unk_2E6; /* 0x2EC */ Vec3s unk_2EC; /* 0x2F2 */ Vec3s unk_2F2; diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index 4d9c7bad3..9295b03a5 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -121,7 +121,12 @@ static u8 D_80BAA488[] = { s32 D_80BAA4A8[] = { -1, -1, 0 }; -u16 D_80BAA4B4[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; +static TurnOptionsSet sTurnOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, +}; s32 func_80BA8820(EnBaba* this, GlobalContext* globalCtx) { this->unk_144 = (EnOssan*)SubS_FindActor(globalCtx, &this->unk_144->actor, ACTORCAT_NPC, ACTOR_EN_OSSAN); @@ -285,25 +290,25 @@ s32 func_80BA8D2C(EnBaba* this, f32 arg1) { void func_80BA8DF4(EnBaba* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f sp30; + Vec3f point; SkelAnime_Update(&this->skelAnime); if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer) && !(this->unk_40A & 4)) { - sp30.x = player->actor.world.pos.x; - sp30.y = player->bodyPartsPos[7].y + 3.0f; - sp30.z = player->actor.world.pos.z; + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk_2DE, &this->unk_2E4, - &this->unk_2EA, D_80BAA4B4); + SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, + &this->torsoRot, &sTurnOptions); } else { - Math_SmoothStepToS(&this->unk_2DE.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2DE.y, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2E4.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2E4.y, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2EA.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk_2EA.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.y, 0, 4, 0x3E8, 1); } SubS_FillLimbRotTables(globalCtx, this->unk_302, this->unk_326, ARRAY_COUNT(this->unk_302)); @@ -696,14 +701,14 @@ s32 EnBaba_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList if (limbIndex == 6) { Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2E4.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk_2E4.x, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->headRot.x, MTXMODE_APPLY); Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == 5) { - Matrix_InsertXRotation_s(-this->unk_2EA.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk_2EA.x, MTXMODE_APPLY); + Matrix_InsertXRotation_s(-this->torsoRot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->torsoRot.x, MTXMODE_APPLY); } if ((limbIndex == 6) && (this->unk_1E2 != 0) && ((globalCtx->state.frames % 2) == 0)) { diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.h b/src/overlays/actors/ovl_En_Baba/z_en_baba.h index d26e68625..6a21168b6 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.h +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.h @@ -32,9 +32,9 @@ typedef struct EnBaba { /* 0x01EA */ UNK_TYPE1 unk1EA[0x1C]; /* 0x0206 */ Vec3s jointTable[18]; /* 0x0272 */ Vec3s morphTable[18]; - /* 0x02DE */ Vec3s unk_2DE; - /* 0x02E4 */ Vec3s unk_2E4; - /* 0x02EA */ Vec3s unk_2EA; + /* 0x02DE */ Vec3s turnTarget; + /* 0x02E4 */ Vec3s headRot; + /* 0x02EA */ Vec3s torsoRot; /* 0x02F0 */ UNK_TYPE1 unk2F0[0x12]; /* 0x0302 */ s16 unk_302[18]; /* 0x0326 */ s16 unk_326[18]; diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index 883d4dd60..61d4df146 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -97,22 +97,27 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0), }; -u16 D_809CCCD8[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; +static TurnOptionsSet sTurnOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, +}; void EnBba01_UpdateModel(EnBba01* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f focus; + Vec3f point; EnHy_UpdateSkelAnime(&this->enHy, globalCtx); if (SubS_AngleDiffLessEqual(this->enHy.actor.shape.rot.y, 0x36B0, this->enHy.actor.yawTowardsPlayer)) { - focus.x = player->actor.world.pos.x; - focus.y = player->bodyPartsPos[7].y + 3.0f; - focus.z = player->actor.world.pos.z; - func_8013D2E0(&focus, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.focusTarget, - &this->enHy.headRot, &this->enHy.torsoRot, D_809CCCD8); + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; + SubS_TurnToPoint(&point, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.turnTarget, + &this->enHy.headRot, &this->enHy.torsoRot, &sTurnOptions); } else { - Math_SmoothStepToS(&this->enHy.focusTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->enHy.focusTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.turnTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.turnTarget.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.headRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.headRot.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.torsoRot.x, 0, 4, 0x3E8, 1); @@ -129,7 +134,7 @@ s32 EnBba01_TestIsTalking(EnBba01* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->enHy.actor, &globalCtx->state)) { isTalking = true; this->enHy.textId = 0x10B9; // Invalid textId, produces empty textbox - this->enHy.tmpFocusTarget = this->enHy.focusTarget; + this->enHy.tmpTurnTarget = this->enHy.turnTarget; this->enHy.tmpHeadRot = this->enHy.headRot; this->enHy.tmpTorsoRot = this->enHy.torsoRot; this->enHy.tmpActionFunc = this->enHy.actionFunc; @@ -192,7 +197,7 @@ void EnBba01_Talk(EnHy* this, GlobalContext* globalCtx) { break; case 2: this->actor.textId = 0; - this->focusTarget = this->tmpFocusTarget; + this->turnTarget = this->tmpTurnTarget; this->headRot = this->tmpHeadRot; this->torsoRot = this->tmpTorsoRot; this->actor.shape.rot.y = this->actor.world.rot.y; diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 20173ed15..43c09df0c 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -73,14 +73,14 @@ static AnimationSpeedInfo D_809CDC7C[] = { void func_809CCDE0(EnBji01* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f sp58; + Vec3f pitchTarget; s32 pad[2]; - Math_Vec3f_Copy(&sp58, &player->actor.world.pos); - sp58.y = player->bodyPartsPos[7].y + 3.0f; - func_8013E950(&this->actor.world.pos, &this->actor.focus.pos, this->actor.shape.rot.y, &player->actor.world.pos, - &sp58, &this->headZRotAdj, &this->headXRotAdj, &this->torsoZRotAdj, &this->torsoXRotAdj, 0x1554, - 0x1FFE, 0xE38, 0x1C70); + Math_Vec3f_Copy(&pitchTarget, &player->actor.world.pos); + pitchTarget.y = player->bodyPartsPos[7].y + 3.0f; + SubS_TurnToPointStep(&this->actor.world.pos, &this->actor.focus.pos, this->actor.shape.rot.y, + &player->actor.world.pos, &pitchTarget, &this->headZRotStep, &this->headXRotStep, + &this->torsoZRotStep, &this->torsoXRotStep, 0x1554, 0x1FFE, 0xE38, 0x1C70); } void func_809CCE98(EnBji01* this, GlobalContext* globalCtx) { @@ -406,12 +406,12 @@ s32 EnBji01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis } switch (limbIndex) { case BJI_LIMB_TORSO: - rot->x += this->torsoXRotAdj; - rot->z += this->torsoZRotAdj; + rot->x += this->torsoXRotStep; + rot->z += this->torsoZRotStep; break; case BJI_LIMB_HEAD: - rot->x += this->headXRotAdj; - rot->z += this->headZRotAdj; + rot->x += this->headXRotStep; + rot->z += this->headZRotStep; break; } return false; diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.h b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.h index b1ed3f8af..c49da8bd2 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.h +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.h @@ -45,10 +45,10 @@ typedef struct EnBji01 { /* 0x29C */ s16 eyeTexIndex; /* 0x29E */ s16 blinkSeqIndex; /* 0x2A0 */ s16 blinkTimer; - /* 0x2A2 */ s16 torsoZRotAdj; - /* 0x2A4 */ s16 torsoXRotAdj; - /* 0x2A6 */ s16 headZRotAdj; - /* 0x2A8 */ s16 headXRotAdj; + /* 0x2A2 */ s16 torsoZRotStep; + /* 0x2A4 */ s16 torsoXRotStep; + /* 0x2A6 */ s16 headZRotStep; + /* 0x2A8 */ s16 headXRotStep; /* 0x2AA */ u16 textId; /* 0x2AC */ s16 cutscenes[1]; /* 0x2B0 */ ObjMoonStone* moonsTear; diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index 53198c594..e65e0dfe9 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -89,22 +89,27 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0), }; -u16 D_809CBF58[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; +static TurnOptionsSet sTurnOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, +}; void EnCne01_UpdateModel(EnCne01* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f focus; + Vec3f point; EnHy_UpdateSkelAnime(&this->enHy, globalCtx); if (SubS_AngleDiffLessEqual(this->enHy.actor.shape.rot.y, 0x36B0, this->enHy.actor.yawTowardsPlayer)) { - focus.x = player->actor.world.pos.x; - focus.y = player->bodyPartsPos[7].y + 3.0f; - focus.z = player->actor.world.pos.z; - func_8013D2E0(&focus, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.focusTarget, - &this->enHy.headRot, &this->enHy.torsoRot, D_809CBF58); + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; + SubS_TurnToPoint(&point, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.turnTarget, + &this->enHy.headRot, &this->enHy.torsoRot, &sTurnOptions); } else { - Math_SmoothStepToS(&this->enHy.focusTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->enHy.focusTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.turnTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.turnTarget.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.headRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.headRot.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.torsoRot.x, 0, 4, 0x3E8, 1); @@ -121,7 +126,7 @@ s32 EnCne01_TestIsTalking(EnCne01* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->enHy.actor, &globalCtx->state)) { isTalking = true; this->enHy.textId = 0x10B9; // Invalid textId, produces empty textbox - this->enHy.tmpFocusTarget = this->enHy.focusTarget; + this->enHy.tmpTurnTarget = this->enHy.turnTarget; this->enHy.tmpHeadRot = this->enHy.headRot; this->enHy.tmpTorsoRot = this->enHy.torsoRot; this->enHy.tmpActionFunc = this->enHy.actionFunc; @@ -182,7 +187,7 @@ void EnCne01_Talk(EnHy* this, GlobalContext* globalCtx) { break; case 2: this->actor.textId = 0; - this->focusTarget = this->tmpFocusTarget; + this->turnTarget = this->tmpTurnTarget; this->headRot = this->tmpHeadRot; this->torsoRot = this->tmpTorsoRot; this->actor.shape.rot.y = this->actor.world.rot.y; 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 e598fe78f..8430547ab 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -1779,25 +1779,25 @@ void EnGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec void EnGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnGm* this = THIS; - s32 phi_v0 = 1; - s32 phi_v1 = 0; + s32 overrideRot = true; + s32 stepRot = false; if (!(this->unk_3A4 & 0x200)) { if (this->unk_3A4 & 0x80) { - phi_v0 = 1; - phi_v1 = 1; + overrideRot = true; + stepRot = true; } else { - phi_v0 = 0; - phi_v1 = 1; + overrideRot = false; + stepRot = true; } } else { - phi_v0 = 0; + overrideRot = false; } if (limbIndex == 16) { - func_8013AD9C(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, phi_v1, phi_v0); + 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); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); @@ -1806,8 +1806,8 @@ void EnGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this Matrix_InsertZRotation_s(this->unk_2A8.z, MTXMODE_APPLY); Matrix_StatePush(); } else if (limbIndex == 9) { - func_8013AD9C(BINANG_ADD(this->unk_3C0, 0x4000), BINANG_ADD(this->unk_3C2 + this->actor.shape.rot.y, 0x4000), - &this->unk_29C, &this->unk_2AE, phi_v1, phi_v0); + 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_StatePop(); Matrix_InsertTranslation(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); 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 c05de7ab8..c34b3e9a3 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -2011,30 +2011,30 @@ s32 EnGo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnGo_TransfromLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnGo* this = THIS; u16 temp_v0; - s32 phi_v1; - s32 phi_v0; + s32 stepRot; + s32 overrideRot; if (this->unk_390 & 0x40) { - phi_v1 = false; + stepRot = false; } else { - phi_v1 = true; + stepRot = true; } if (this->unk_390 & 0x10) { - phi_v0 = true; + overrideRot = true; } else { - phi_v0 = false; + overrideRot = false; } - if (!phi_v1) { - phi_v0 = false; + if (!stepRot) { + overrideRot = false; } switch (limbIndex) { case 17: - func_8013AD9C(this->unk_3B0 + this->unk_3B4 + 0x4000, - this->unk_3B2 + this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_290, - &this->unk_2A8, phi_v1, phi_v0); + SubS_UpdateLimb(this->unk_3B0 + this->unk_3B4 + 0x4000, + this->unk_3B2 + this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_290, + &this->unk_2A8, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); @@ -2045,8 +2045,8 @@ void EnGo_TransfromLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this break; case 10: - func_8013AD9C(this->unk_3B4 + 0x4000, this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_29C, - &this->unk_2AE, phi_v1, phi_v0); + SubS_UpdateLimb(this->unk_3B4 + 0x4000, this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_29C, + &this->unk_2AE, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); 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 bbb706326..c9f4f9b70 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -997,24 +997,24 @@ void EnIg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec void EnIg_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx, Gfx** gfx) { EnIg* this = THIS; - s32 phi_v0; - s32 phi_v1; + s32 stepRot; + s32 overrideRot; if (!(this->unk_3D0 & 0x200)) { if (this->unk_3D0 & 0x80) { - phi_v1 = 1; + overrideRot = true; } else { - phi_v1 = 0; + overrideRot = false; } - phi_v0 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + overrideRot = false; + stepRot = false; } if (limbIndex == 9) { - func_8013AD9C(this->unk_3E8 + 0x4000, this->unk_3EA + this->actor.shape.rot.y + 0x4000, &this->unk_2D4, - &this->unk_2E6, phi_v0, phi_v1); + SubS_UpdateLimb(this->unk_3E8 + 0x4000, this->unk_3EA + this->actor.shape.rot.y + 0x4000, &this->unk_2D4, + &this->unk_2E6, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_2D4.x, this->unk_2D4.y, this->unk_2D4.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); 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 758543f45..7dcaf7b64 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -139,8 +139,11 @@ static AnimationInfoS sAnimations[] = { { &object_in_Anim_019EB4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, }; -static u16 D_808F6C0C[] = { - 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6, +static TurnOptionsSet sTurnOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, }; s32 func_808F30B0(SkelAnime* skelAnime, s16 animIndex) { @@ -228,24 +231,24 @@ s32 func_808F33B8(void) { void func_808F3414(EnIn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f sp30; + Vec3f point; if (this->unk23D == 0) { this->unk494 = SkelAnime_Update(&this->skelAnime); } if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { - sp30.x = player->actor.world.pos.x; - sp30.y = player->bodyPartsPos[7].y + 3.0f; - sp30.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk352, &this->unk358, - &this->unk35E, D_808F6C0C); + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; + SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, + &this->torsoRot, &sTurnOptions); } else { - Math_SmoothStepToS(&this->unk352.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk352.y, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk358.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk358.y, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk35E.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk35E.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.y, 0, 4, 0x3E8, 1); } func_808F322C(this, 3); func_808F3178(this, globalCtx); @@ -1541,14 +1544,14 @@ s32 EnIn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (limbIndex == 16) { Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk358.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk358.x, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->headRot.x, MTXMODE_APPLY); Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); func_808F6334(this, globalCtx); } if (limbIndex == 9) { - Matrix_RotateY(this->unk35E.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk35E.x, MTXMODE_APPLY); + Matrix_RotateY(this->torsoRot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->torsoRot.x, MTXMODE_APPLY); } if (limbIndex == 9 || limbIndex == 10 || limbIndex == 13) { rot->y += (s16)(Math_SinS(this->unk376[limbIndex]) * 200.0f); 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 0a6f4be75..ae339ecaa 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.h +++ b/src/overlays/actors/ovl_En_In/z_en_in.h @@ -36,9 +36,9 @@ typedef struct EnIn { /* 0x261 */ u8 unk261; /* 0x262 */ Vec3s jointTable[20]; /* 0x2DA */ Vec3s morphTable[20]; - /* 0x352 */ Vec3s unk352; - /* 0x358 */ Vec3s unk358; - /* 0x35E */ Vec3s unk35E; + /* 0x352 */ Vec3s turnTarget; + /* 0x358 */ Vec3s headRot; + /* 0x35E */ Vec3s torsoRot; /* 0x364 */ char unk364[0x12]; /* 0x376 */ s16 unk376[20]; /* 0x39E */ s16 unk39E[20]; 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 b02b6f4ee..e6bc31eea 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -523,30 +523,30 @@ void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec void EnJa_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnJa* this = THIS; - s32 phi_v1; - s32 phi_v0; + s32 stepRot; + s32 overrideRot; if (this->unk_340 & 0x10) { - phi_v1 = false; + stepRot = false; } else { - phi_v1 = true; + stepRot = true; } if (this->unk_340 & 0x20) { - phi_v0 = true; + overrideRot = true; } else { - phi_v0 = false; + overrideRot = false; } - if (!phi_v1) { - phi_v0 = false; + if (!stepRot) { + overrideRot = false; } if (limbIndex != 8) { if (limbIndex == 15) { - func_8013AD9C(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, phi_v1, phi_v0); + 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); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_1EC.x, this->unk_1EC.y, this->unk_1EC.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); @@ -556,8 +556,8 @@ void EnJa_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this Matrix_StatePush(); } } else { - func_8013AD9C(this->unk_358 + 0x4000, this->unk_35A + this->actor.shape.rot.y + 0x4000, &this->unk_1F8, - &this->unk_27A, phi_v1, phi_v0); + SubS_UpdateLimb(this->unk_358 + 0x4000, this->unk_35A + this->actor.shape.rot.y + 0x4000, &this->unk_1F8, + &this->unk_27A, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(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); diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 633526f81..b19f64c4d 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -2143,26 +2143,26 @@ void EnPm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -void EnPm_TransformLimbDraw(GlobalContext* globalCtx, s32 arg1, Actor* thisx, Gfx** gfx) { +void EnPm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx, Gfx** gfx) { EnPm* this = THIS; - s32 phi_v0; - s32 phi_v1; + s32 stepRot; + s32 overrideRot; if (!(this->unk_356 & 0x200)) { if (this->unk_356 & 0x80) { - phi_v1 = 1; + overrideRot = true; } else { - phi_v1 = 0; + overrideRot = false; } - phi_v0 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + overrideRot = false; + stepRot = false; } - if (arg1 == 15) { - func_8013AD9C(this->unk_370 + 0x4000, this->unk_372 + this->actor.shape.rot.y + 0x4000, &this->unk_284, - &this->unk_290, phi_v0, phi_v1); + if (limbIndex == 15) { + SubS_UpdateLimb(this->unk_370 + 0x4000, this->unk_372 + this->actor.shape.rot.y + 0x4000, &this->unk_284, + &this->unk_290, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_284.x, this->unk_284.y, this->unk_284.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.c b/src/overlays/actors/ovl_En_Shn/z_en_shn.c index 2ab16fb6a..808f38d5a 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.c +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.c @@ -403,24 +403,24 @@ void EnShn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve void EnShn_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnShn* this = THIS; - s32 phi_v0; - s32 phi_v1; + s32 stepRot; + s32 overrideRot; if (!(this->unk_1D8 & 0x20)) { if (this->unk_1D8 & 0x10) { - phi_v1 = 1; + overrideRot = true; } else { - phi_v1 = 0; + overrideRot = false; } - phi_v0 = 1; + stepRot = true; } else { - phi_v1 = 0; - phi_v0 = 0; + overrideRot = false; + stepRot = false; } if (limbIndex == BURLY_GUY_LIMB_HEAD) { - func_8013AD9C((this->unk_2BA + 0x4000), (this->unk_2BC + this->actor.shape.rot.y + 0x4000), &this->unk_1E8, - &this->unk_1F4, phi_v0, phi_v1); + SubS_UpdateLimb((this->unk_2BA + 0x4000), (this->unk_2BC + this->actor.shape.rot.y + 0x4000), &this->unk_1E8, + &this->unk_1F4, stepRot, overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_1E8.x, this->unk_1E8.y, this->unk_1E8.z, 0); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 1); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 40ebeb21b..319cbbabd 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -120,8 +120,11 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xE), }; -static u16 D_80BAE800[] = { - 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6, +static TurnOptionsSet sTurnOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, }; static u8 D_80BAE820[] = { @@ -516,7 +519,7 @@ void EnSuttari_GetPaths(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f sp30; + Vec3f point; if (this->flags1 & 0x80) { EnSuttari_UpdateCollider(this, globalCtx); @@ -524,18 +527,18 @@ void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (!(this->flags1 & 4) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer)) { - sp30.x = player->actor.world.pos.x; - sp30.y = player->bodyPartsPos[7].y + 3.0f; - sp30.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk2D6, &this->unk2DC, - &this->unk2E2, D_80BAE800); + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; + SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, + &this->torsoRot, &sTurnOptions); } else { - Math_SmoothStepToS(&this->unk2D6.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2D6.y, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2DC.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2DC.y, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2E2.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2E2.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->torsoRot.y, 0, 4, 0x3E8, 1); } } SubS_FillLimbRotTables(globalCtx, this->unk2FA, this->unk31A, ARRAY_COUNT(this->unk2FA)); @@ -1014,12 +1017,12 @@ void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { func_80BAB434(this); if (player->transformation == PLAYER_FORM_GORON || player->transformation == PLAYER_FORM_ZORA) { if (this->actor.playerHeightRel < 60.0f && this->actor.xzDistToPlayer < 500.0f) { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; this->actionFunc = func_80BACBB0; } } else if ((player->transformation == PLAYER_FORM_HUMAN) && GET_CUR_EQUIP_VALUE(EQUIP_SWORD) != 0) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; func_80BAAB78(this, globalCtx); this->actionFunc = func_80BADA9C; } else if (this->actor.xzDistToPlayer < 200.0f) { @@ -1034,7 +1037,7 @@ void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 target; - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; if (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_DEKU) { this->actionFunc = func_80BACA14; } @@ -1064,7 +1067,7 @@ void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { void func_80BACD2C(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; if (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_DEKU) { this->actionFunc = func_80BACA14; } @@ -1232,7 +1235,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { this->flags2 |= 4; EnSuttari_SetNextEntrance(globalCtx, 0xD670); } else { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; Math_ApproachF(&this->actor.speedXZ, 4.0f, 0.2f, 0.5f); Actor_MoveWithGravity(&this->actor); func_80BAB374(this, globalCtx); @@ -1330,7 +1333,7 @@ void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (this->flags1 & 1) { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; func_80BAA9B4(this); } else if ((this->animationIndex == 7) && (curFrame == frameCount)) { this->animationIndex = 1; @@ -1406,14 +1409,14 @@ void func_80BADE14(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[1] == -0x63) { this->actor.speedXZ = 0.0f; } else { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); } Actor_MoveWithGravity(&this->actor); } void func_80BADE8C(EnSuttari* this, GlobalContext* globalCtx) { - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; @@ -1430,7 +1433,7 @@ void func_80BADF3C(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[0] == -0x63) { Actor_MarkForDeath(&this->actor); } - this->unk3F2 = this->unk2DC.y; + this->unk3F2 = this->headRot.y; if (DECR(this->unk3F6) == 0) { Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); } @@ -1501,13 +1504,13 @@ s32 EnSuttari_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL if (!(this->flags1 & 4)) { Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_InsertXRotation_s(this->unk3F2, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk2DC.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->headRot.x, MTXMODE_APPLY); Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } } if (limbIndex == 8) { - Matrix_InsertXRotation_s(-this->unk2E2.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk2E2.x, MTXMODE_APPLY); + Matrix_InsertXRotation_s(-this->torsoRot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->torsoRot.x, MTXMODE_APPLY); } if (limbIndex == 8 || limbIndex == 9 || limbIndex == 0xC) { rot->y += (s16)(Math_SinS(this->unk2FA[limbIndex]) * 200.0f); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h index c6f8cc153..2fbdff53b 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h @@ -27,9 +27,9 @@ typedef struct EnSuttari { /* 0x1FC */ UNK_TYPE1 unk_1FC[0x1A]; /* 0x216 */ Vec3s jointTable[16]; /* 0x276 */ Vec3s morphTable[16]; - /* 0x2D6 */ Vec3s unk2D6; - /* 0x2DC */ Vec3s unk2DC; - /* 0x2E2 */ Vec3s unk2E2; + /* 0x2D6 */ Vec3s turnTarget; + /* 0x2DC */ Vec3s headRot; + /* 0x2E2 */ Vec3s torsoRot; /* 0x2E8 */ UNK_TYPE1 unk_2E8[0x12]; /* 0x2FA */ s16 unk2FA[16]; /* 0x31A */ s16 unk31A[16]; diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index f1c9c6bbc..7c36af46f 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -584,25 +584,25 @@ void EnTab_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve void EnTab_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnTab* this = THIS; - s32 phi_v0; - s32 phi_v1; + s32 rotStep; + s32 overrideStep; if (!(this->unk_2FC & 0x40)) { if (this->unk_2FC & 0x10) { - phi_v1 = 1; + overrideStep = true; } else { - phi_v1 = 0; + overrideStep = false; } - phi_v0 = 1; + rotStep = true; } else { - phi_v1 = 0; - phi_v0 = 0; + overrideStep = false; + rotStep = false; } if (limbIndex == 9) { - func_8013AD9C(BINANG_ADD(this->unk_312 + this->unk_316, 0x4000), - BINANG_ADD(this->unk_314 + this->unk_318 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, - this->unk_200, phi_v0, phi_v1); + SubS_UpdateLimb(BINANG_ADD(this->unk_312 + this->unk_316, 0x4000), + BINANG_ADD(this->unk_314 + this->unk_318 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, + this->unk_200, rotStep, overrideStep); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index 7cf13c6af..3390b8422 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -1195,32 +1195,32 @@ void EnTru_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve void EnTru_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnTru* this = THIS; s32 pad[3]; - s32 sp2C; - s32 phi_v1; + s32 overrideRot; + s32 stepRot; if (this->unk_34E & 0x10) { - phi_v1 = false; + stepRot = false; } else { - phi_v1 = true; + stepRot = true; } if (this->unk_34E & 0x20) { - sp2C = true; + overrideRot = true; } else { - sp2C = false; + overrideRot = false; } - if (!phi_v1) { - sp2C = false; + if (!stepRot) { + overrideRot = false; } if (limbIndex == 21) { - func_8013AD9C(this->unk_366, this->unk_368 + this->actor.shape.rot.y, &this->unk_1EC, &this->unk_204, phi_v1, - sp2C); + SubS_UpdateLimb(this->unk_366, this->unk_368 + this->actor.shape.rot.y, &this->unk_1EC, &this->unk_204, stepRot, + overrideRot); Matrix_StatePop(); Matrix_InsertTranslation(this->unk_1EC.x, this->unk_1EC.y, this->unk_1EC.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - if (sp2C) { + if (overrideRot) { s16 oldZ = this->unk_204.z; this->unk_204.z = this->unk_204.x; diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 8759d3b86..95738b211 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -174,20 +174,25 @@ void EnZo_UpdateCollider(EnZo* this, GlobalContext* globalCtx) { } void EnZo_LookAtPlayer(EnZo* this, GlobalContext* globalCtx) { - static u16 D_8099F5AC[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; + static TurnOptionsSet sTurnOptions = { + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + { 0xFA0, 4, 1, 3 }, + { 0x1770, 4, 1, 6 }, + }; Player* player = GET_PLAYER(globalCtx); - Vec3f focus; + Vec3f point; SkelAnime_Update(&this->skelAnime); if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { - focus.x = player->actor.world.pos.x; - focus.y = player->bodyPartsPos[7].y + 3.0f; - focus.z = player->actor.world.pos.z; - func_8013D2E0(&focus, &this->actor.focus.pos, &this->actor.shape.rot, &this->headRotTarget, &this->headRot, - &this->upperBodyRot, D_8099F5AC); + point.x = player->actor.world.pos.x; + point.y = player->bodyPartsPos[7].y + 3.0f; + point.z = player->actor.world.pos.z; + SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, + &this->upperBodyRot, &sTurnOptions); } else { - Math_SmoothStepToS(&this->headRotTarget.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->headRotTarget.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 1000, 1); Math_SmoothStepToS(&this->headRot.x, 0, 4, 1000, 1); Math_SmoothStepToS(&this->headRot.y, 0, 4, 1000, 1); diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.h b/src/overlays/actors/ovl_En_Zo/z_en_zo.h index 155c947d4..b5faef776 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.h +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.h @@ -24,7 +24,7 @@ typedef struct EnZo { /* 0x01FD */ u8 isRightFootGrounded; /* 0x01FE */ Vec3s jointTable[20]; /* 0x0276 */ Vec3s morphTable[20]; - /* 0x02EE */ Vec3s headRotTarget; + /* 0x02EE */ Vec3s turnTarget; /* 0x02F4 */ Vec3s headRot; /* 0x02FA */ Vec3s upperBodyRot; /* 0x0300 */ UNK_TYPE1 unk_300[0x12]; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index eac58c3e6..0c114748a 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2659,7 +2659,7 @@ 0x8013A860:("SubS_DrawTransformFlexLimb",), 0x8013AB00:("SubS_DrawTransformFlex",), 0x8013AD6C:("SubS_InCsMode",), - 0x8013AD9C:("func_8013AD9C",), + 0x8013AD9C:("SubS_UpdateLimb",), 0x8013AED4:("SubS_UpdateFlags",), 0x8013AF00:("func_8013AF00",), 0x8013B010:("func_8013B010",), @@ -2679,8 +2679,8 @@ 0x8013CC2C:("SubS_FillShadowTex",), 0x8013CD64:("SubS_GenShadowTex",), 0x8013CF04:("SubS_DrawShadowTex",), - 0x8013D0E0:("func_8013D0E0",), - 0x8013D2E0:("func_8013D2E0",), + 0x8013D0E0:("SubS_ComputeTurnToPointRot",), + 0x8013D2E0:("SubS_TurnToPoint",), 0x8013D5E8:("SubS_AngleDiffLessEqual",), 0x8013D648:("SubS_GetPathByIndex",), 0x8013D68C:("SubS_CopyPointFromPath",), @@ -2709,7 +2709,7 @@ 0x8013E748:("func_8013E748",), 0x8013E7C0:("SubS_ActorAndPlayerFaceEachOther",), 0x8013E8F8:("func_8013E8F8",), - 0x8013E950:("func_8013E950",), + 0x8013E950:("SubS_TurnToPointStep",), 0x8013EC10:("func_8013EC10",), 0x8013EC44:("func_8013EC44",), 0x8013ECE0:("func_8013ECE0",), @@ -15758,8 +15758,8 @@ 0x80BD3854:("EnAh_Init",), 0x80BD396C:("EnAh_Destroy",), 0x80BD3998:("EnAh_Update",), - 0x80BD3AA8:("func_80BD3AA8",), - 0x80BD3AF8:("func_80BD3AF8",), + 0x80BD3AA8:("EnAh_PostLimbDraw",), + 0x80BD3AF8:("EnAh_TransformLimbDraw",), 0x80BD3CAC:("EnAh_Draw",), 0x80BD4090:("ObjHgdoor_SetChild",), 0x80BD40D0:("func_80BD40D0",), diff --git a/tools/namefixer.py b/tools/namefixer.py index db7d97e82..7ce3790db 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -422,10 +422,6 @@ wordReplace = { "func_8016A0AC": "Play_IsUnderwater", "func_801690CC": "Play_InCsMode", "func_8017D2FC": "Math3D_LineSegVsPlane", - "func_8013A7C0": "SubS_FindDoor", - "func_8013E640": "SubS_FindActorCustom", - "func_ActorCategoryIterateById": "SubS_FindActor", - "func_8013BB7C": "SubS_FindNearestActor", "func_800A81F0": "EffectBlure_AddVertex", "func_800A8514": "EffectBlure_AddSpace", "Effect_GetParams": "Effect_GetByIndex", @@ -443,11 +439,6 @@ wordReplace = { "func_800EE2F4": "Cutscene_IsPlaying", "func_801343C0": "SkelAnime_DrawTransformFlexOpa", "func_80134148": "SkelAnime_DrawTransformFlexLimbOpa", - "func_8013AB00": "SubS_DrawTransformFlex", - "func_8013A860": "SubS_DrawTransformFlexLimb", - "func_8013BC6C": "SubS_ChangeAnimationByInfoS", - "func_8013E1C8": "SubS_ChangeAnimationBySpeedInfo", - "func_8013D9C8": "SubS_FillLimbRotTables", "func_80114E90": "Interface_HasEmptyBottle", "func_80114F2C": "Interface_HasItemInBottle", "func_80123C90": "Player_SetEquipmentData", @@ -455,13 +446,23 @@ wordReplace = { "Quake2_SetType": "Distortion_SetType", "Quake2_SetCountdown": "Distortion_SetCountdown", "func_800BE680": "Actor_DrawDamageEffects", + "func_8012F22C": "Inventory_GetSkullTokenCount", + + "func_8013AB00": "SubS_DrawTransformFlex", + "func_8013A860": "SubS_DrawTransformFlexLimb", + "func_8013BC6C": "SubS_ChangeAnimationByInfoS", + "func_8013E1C8": "SubS_ChangeAnimationBySpeedInfo", + "func_8013D9C8": "SubS_FillLimbRotTables", + "func_8013A7C0": "SubS_FindDoor", + "func_8013E640": "SubS_FindActorCustom", + "func_ActorCategoryIterateById": "SubS_FindActor", + "func_8013BB7C": "SubS_FindNearestActor", "func_8013E2D4": "SubS_StartActorCutscene", "func_8013E3B8": "SubS_FillCutscenesList", "func_8013AED4": "SubS_UpdateFlags", "func_8013D8DC": "SubS_IsObjectLoaded", "func_8013D924": "SubS_GetObjectIndex", "func_8013D5E8": "SubS_AngleDiffLessEqual", - "func_8012F22C": "Inventory_GetSkullTokenCount", "func_8013DCE0": "SubS_ActorPathing_Init", "func_8013DE04": "SubS_ActorPathing_Update", "func_8013DF3C": "SubS_ActorPathing_ComputePointInfo", @@ -480,6 +481,8 @@ wordReplace = { "func_8013DB90": "SubS_IsFloorAbove", "func_8013DC40": "SubS_CopyPointFromPathList", "func_8013DCCC": "SubS_GetPathCount", + "func_8013AD9C": "SubS_UpdateLimb", + "func_8013D2E0": "SubS_TurnToPoint", "func_80147624": "Message_ShouldAdvance", "func_80147734": "Message_ShouldAdvanceSilent", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 8452179ab..ffff2a55b 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2173,7 +2173,7 @@ asm/non_matchings/code/z_sub_s/SubS_FindDoor.s,SubS_FindDoor,0x8013A7C0,0x28 asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlexLimb.s,SubS_DrawTransformFlexLimb,0x8013A860,0xA8 asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlex.s,SubS_DrawTransformFlex,0x8013AB00,0x9B asm/non_matchings/code/z_sub_s/SubS_InCsMode.s,SubS_InCsMode,0x8013AD6C,0xC -asm/non_matchings/code/z_sub_s/func_8013AD9C.s,func_8013AD9C,0x8013AD9C,0x4E +asm/non_matchings/code/z_sub_s/SubS_UpdateLimb.s,SubS_UpdateLimb,0x8013AD9C,0x4E asm/non_matchings/code/z_sub_s/SubS_UpdateFlags.s,SubS_UpdateFlags,0x8013AED4,0xB asm/non_matchings/code/z_sub_s/func_8013AF00.s,func_8013AF00,0x8013AF00,0x44 asm/non_matchings/code/z_sub_s/func_8013B010.s,func_8013B010,0x8013B010,0x2E @@ -2193,8 +2193,8 @@ asm/non_matchings/code/z_sub_s/func_8013C964.s,func_8013C964,0x8013C964,0xB2 asm/non_matchings/code/z_sub_s/SubS_FillShadowTex.s,SubS_FillShadowTex,0x8013CC2C,0x4E asm/non_matchings/code/z_sub_s/SubS_GenShadowTex.s,SubS_GenShadowTex,0x8013CD64,0x68 asm/non_matchings/code/z_sub_s/SubS_DrawShadowTex.s,SubS_DrawShadowTex,0x8013CF04,0x77 -asm/non_matchings/code/z_sub_s/func_8013D0E0.s,func_8013D0E0,0x8013D0E0,0x80 -asm/non_matchings/code/z_sub_s/func_8013D2E0.s,func_8013D2E0,0x8013D2E0,0xC2 +asm/non_matchings/code/z_sub_s/SubS_ComputeTurnToPointRot.s,SubS_ComputeTurnToPointRot,0x8013D0E0,0x80 +asm/non_matchings/code/z_sub_s/SubS_TurnToPoint.s,SubS_TurnToPoint,0x8013D2E0,0xC2 asm/non_matchings/code/z_sub_s/SubS_AngleDiffLessEqual.s,SubS_AngleDiffLessEqual,0x8013D5E8,0x18 asm/non_matchings/code/z_sub_s/SubS_GetPathByIndex.s,SubS_GetPathByIndex,0x8013D648,0x11 asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPath.s,SubS_CopyPointFromPath,0x8013D68C,0x25 @@ -2223,7 +2223,7 @@ asm/non_matchings/code/z_sub_s/SubS_FindActorCustom.s,SubS_FindActorCustom,0x801 asm/non_matchings/code/z_sub_s/func_8013E748.s,func_8013E748,0x8013E748,0x1E asm/non_matchings/code/z_sub_s/SubS_ActorAndPlayerFaceEachOther.s,SubS_ActorAndPlayerFaceEachOther,0x8013E7C0,0x4E asm/non_matchings/code/z_sub_s/func_8013E8F8.s,func_8013E8F8,0x8013E8F8,0x16 -asm/non_matchings/code/z_sub_s/func_8013E950.s,func_8013E950,0x8013E950,0xB0 +asm/non_matchings/code/z_sub_s/SubS_TurnToPointStep.s,SubS_TurnToPointStep,0x8013E950,0xB0 asm/non_matchings/code/code_8013EC10/func_8013EC10.s,func_8013EC10,0x8013EC10,0xD asm/non_matchings/code/code_8013EC10/func_8013EC44.s,func_8013EC44,0x8013EC44,0x27 asm/non_matchings/code/code_8013EC10/func_8013ECE0.s,func_8013ECE0,0x8013ECE0,0x2F From c2afdf6eb01398ce0f237268da3dbd20247c8c33 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 25 May 2022 19:01:46 -0700 Subject: [PATCH 218/257] EffectSsLightning OK (#800) * OK * Document and gameplay keep * cleanup * Rotate -> Rot * Update description --- assets/xml/objects/gameplay_keep.xml | 18 +-- spec | 3 +- .../z_eff_ss_lightning.c | 144 +++++++++++++++++- tools/disasm/functions.txt | 2 +- 4 files changed, 147 insertions(+), 20 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 41b144120..8328b14ab 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1062,15 +1062,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/spec b/spec index 137ff6249..b223f113c 100644 --- a/spec +++ b/spec @@ -1857,8 +1857,7 @@ beginseg name "ovl_Effect_Ss_Lightning" compress include "build/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.o" - include "build/data/ovl_Effect_Ss_Lightning/ovl_Effect_Ss_Lightning.data.o" - include "build/data/ovl_Effect_Ss_Lightning/ovl_Effect_Ss_Lightning.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Lightning/ovl_Effect_Ss_Lightning_reloc.o" endseg beginseg diff --git a/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c b/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c index ad2ef29a5..15fdcfc50 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c +++ b/src/overlays/effects/ovl_Effect_Ss_Lightning/z_eff_ss_lightning.c @@ -1,29 +1,157 @@ /* * File: z_eff_ss_lightning.c * Overlay: ovl_Effect_Ss_Lightning - * Description: + * Description: Electric Discharge */ #include "z_eff_ss_lightning.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rPrimColorR regs[0] +#define rPrimColorG regs[1] +#define rPrimColorB regs[2] +#define rPrimColorA regs[3] +#define rEnvColorR regs[4] +#define rEnvColorG regs[5] +#define rEnvColorB regs[6] +#define rEnvColorA regs[7] +#define rNumBolts regs[8] +#define rScale regs[9] +#define rYaw regs[10] +#define rLifespan regs[11] #define PARAMS ((EffectSsLightningInitParams*)initParamsx) -s32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsLightning_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 +TexturePtr sLightningTextures[] = { + gEffLightning1Tex, gEffLightning2Tex, gEffLightning3Tex, gEffLightning4Tex, + gEffLightning5Tex, gEffLightning6Tex, gEffLightning7Tex, gEffLightning8Tex, +}; + const EffectSsInit Effect_Ss_Lightning_InitVars = { EFFECT_SS_LIGHTNING, EffectSsLightning_Init, }; -#endif +static s32 sIsDesegmented = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Lightning/EffectSsLightning_Init.s") +u32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsLightningInitParams* initParams = PARAMS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Lightning/func_8097A794.s") + this->pos = initParams->pos; + this->gfx = gEffLightningDL; + this->life = initParams->life; + this->draw = EffectSsLightning_Draw; + this->update = EffectSsLightning_Update; + this->rPrimColorR = initParams->primColor.r; + this->rPrimColorG = initParams->primColor.g; + this->rPrimColorB = initParams->primColor.b; + this->rPrimColorA = initParams->primColor.a; + this->rEnvColorR = initParams->envColor.r; + this->rEnvColorG = initParams->envColor.g; + this->rEnvColorB = initParams->envColor.b; + this->rEnvColorA = initParams->envColor.a; + this->rNumBolts = initParams->numBolts; + this->rScale = initParams->scale; + this->rYaw = initParams->yaw; + this->rLifespan = initParams->life; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Lightning/EffectSsLightning_Draw.s") + if (!sIsDesegmented) { + for (i = 0; i < ARRAY_COUNT(sLightningTextures); i++) { + sLightningTextures[i] = Lib_SegmentedToVirtual(sLightningTextures[i]); + } + sIsDesegmented = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Lightning/EffectSsLightning_Update.s") + return 1; +} + +void EffectSsLightning_NewLightning(GlobalContext* globalCtx, Vec3f* pos, s32 yaw, EffectSs* this) { + EffectSs newLightning; + + EffectSS_Delete(&newLightning); + newLightning = *this; + newLightning.pos = *pos; + newLightning.rNumBolts--; + newLightning.rYaw = yaw; + newLightning.life = newLightning.rLifespan; + + EffectSS_Copy(globalCtx, &newLightning); +} + +void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + MtxF mfResult; + MtxF mfTrans; + MtxF mfScale; + MtxF mfRot; + MtxF mfTransBillboard; + MtxF mfTransBillboardRot; + Mtx* mtx; + f32 yScale; + s32 texIndex; + f32 xzScale; + + OPEN_DISPS(gfxCtx); + + yScale = this->rScale * 0.01f; + texIndex = this->rLifespan - this->life; + + if (texIndex >= ARRAY_COUNT(sLightningTextures)) { + texIndex = ARRAY_COUNT(sLightningTextures) - 1; + } + + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + xzScale = yScale * 0.6f; + SkinMatrix_SetScale(&mfScale, xzScale, yScale, xzScale); + SkinMatrix_SetRotateRPY(&mfRot, this->vec.x, this->vec.y, this->rYaw); + SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfRot, &mfTransBillboardRot); + SkinMatrix_MtxFMtxFMult(&mfTransBillboardRot, &mfScale, &mfResult); + + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C9BC(gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, sLightningTextures[texIndex]); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, + this->rPrimColorA); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsLightning_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + s32 pad; + Vec3f pos; + s32 yaw; + f32 scale; + s32 sign; + + if ((this->rNumBolts != 0) && ((this->life + 1) == this->rLifespan)) { + sign = (Rand_ZeroOne() < 0.5f) ? -1 : 1; + yaw = this->rYaw + sign * ((s32)((Rand_ZeroOne() * 3640.0f)) + 0xE38); + scale = (this->rScale * 0.01f) * 80.0f; + + pos.y = this->pos.y + (Math_SinS(this->rYaw - 0x4000) * scale); + + scale = Math_CosS(this->rYaw - 0x4000) * scale; + pos.x = this->pos.x - (Math_CosS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx))) * scale); + pos.z = this->pos.z + (Math_SinS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx))) * scale); + + EffectSsLightning_NewLightning(globalCtx, &pos, yaw, this); + + if (Rand_ZeroOne() < 0.1f) { + EffectSsLightning_NewLightning(globalCtx, &pos, (this->rYaw * 2) - yaw, this); + } + } +} diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 0c114748a..86758415a 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -8165,7 +8165,7 @@ 0x8097A548:("EffectSsGFire_Draw",), 0x8097A5F0:("EffectSsGFire_Update",), 0x8097A680:("EffectSsLightning_Init",), - 0x8097A794:("func_8097A794",), + 0x8097A794:("EffectSsLightning_NewLightning",), 0x8097A838:("EffectSsLightning_Draw",), 0x8097AA98:("EffectSsLightning_Update",), 0x8097AD60:("EffectSsDtBubble_Init",), From 0582c636b84462754b27713a1ff3b69a7974f599 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis Date: Thu, 26 May 2022 03:06:21 +0100 Subject: [PATCH 219/257] Contributing docs refresh (#793) * Contributing docs refresh * Apply suggestions from code review Co-authored-by: LtPeriwinkle <62761190+LtPeriwinkle@users.noreply.github.com> * Link MM tutorial * Add link to XML spec * Review Co-authored-by: LtPeriwinkle <62761190+LtPeriwinkle@users.noreply.github.com> --- .github/pull_request_template.md | 9 -- .gitignore | 1 + CONTRIBUTING.md | 133 ++++++++---------- README.md | 24 ++-- REVIEWING.md | 67 --------- docs/REVIEWING.md | 59 ++++++++ docs/STYLE.md | 232 +++++++++++++++++++++++++++++++ 7 files changed, 362 insertions(+), 163 deletions(-) delete mode 100644 .github/pull_request_template.md delete mode 100644 REVIEWING.md create mode 100644 docs/REVIEWING.md create mode 100644 docs/STYLE.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index 299e41853..000000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,9 +0,0 @@ -Before opening this PR, ensure the following: -- `./format.sh` was run to apply standard formatting. -- `make` successfully builds a matching ROM. -- No new compiler warnings were introduced during the build process. - - Can be verified locally by running `tools/warnings_count/check_new_warnings.sh` -- New variables & functions should follow standard naming conventions. -- Comments and variables have correct spelling. ---- - diff --git a/.gitignore b/.gitignore index a2acf29c3..80fe09807 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,7 @@ tools/mips_to_c/ # Docs !docs/**/*.png +docs/doxygen/ !.vscode/extensions.json # Per-user configuration diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3ee29e99e..e0839bb2d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,5 @@ -Contributing to the Majora's Mask Decompilation Project -======================================================= +# Contributing to the Majora's Mask Decompilation Project + Thanks for helping us reverse engineer *The Legend of Zelda: Majora's Mask* for the N64! All contributions are welcome. This is a group effort, and even small contributions can make a difference. Some tasks also don't require much knowledge to get started. @@ -10,21 +10,19 @@ For general information about the project, see [our readme](https://github.com/z Most discussions happen on our [Discord Server](https://discord.zelda64.dev) where you are welcome to ask if you need help getting started, or if you have any questions regarding this project and other decompilation projects. -Useful Links ------------- - -- [Discord](https://discord.zelda64.dev/) - Primary discussion platform. -- [Google Sheets reservation board](https://docs.google.com/spreadsheets/d/1X83YCPRa532v-Zo0WgUsJ2kB1X9RxBta5_p9aWA8uro) - We use this to track decompilation progress, not GitHub Issues. +## Useful Links - [Installation guide](https://github.com/zeldaret/mm/blob/master/README.md#installation) - Instructions for getting this repository set up and built on your machine. -- [Code Review Guidelines](REVIEWING.md) - These are the guidelines that reviewers will be using when reviewing your code. Good to be familiar with these before submitting your code. +- [Style Guide](docs/STYLE.md) - Description of the project style that we ask contributors to adhere to. +- [Code Review Guidelines](docs/REVIEWING.md) - These are the guidelines that reviewers will be using when reviewing your code. Good to be familiar with these before submitting your code. -- [Zelda 64 Reverse Engineering Website](https://zelda64.dev/) - Our homepage, with links to other resources. -- [Introduction to OOT decomp](https://github.com/zeldaret/oot/blob/master/docs/tutorial/contents.md) - A very detailed tutorial on how to get started with decomp. For OOT, but largely applicable to MM as well. -- The `#resources` channel on the Discord contains many more links +- [Zelda 64 Reverse Engineering Website](https://zelda64.dev/mm) - Our homepage, with FAQ and progress graph :chart_with_upwards_trend:. +- [MM decomp tutorial](docs/tutorial/contents.md) Detailed tutorial for learning in general how decomp works and how to decompile a small, simple file. +- [Introduction to OOT decomp](https://github.com/zeldaret/oot/blob/master/docs/tutorial/contents.md) - The tutorial the MM one was based on. For OOT, but largely applicable to MM as well. Covers slightly different topics, including how to get your data OK with `vbindiff`. +- The `#resources` channel on the Discord contains many more links on specific details of decompiling IDO MIPS code. -Getting Started ---------------- + +## Getting Started ### What should I know to take part? @@ -32,11 +30,14 @@ Basic knowledge of C, particularly arrays and pointers, is extremely useful. Kno You should be familiar with using git and GitHub. There are a number of tutorials available online, [such as this one](https://github.com/firstcontributions/first-contributions) which can help you get started. -The most useful knowledge to have is a general understanding of how the game works. An afternoon of constructive mucking about in the [OOT Practice Rom](http://practicerom.com/) (aka GZ) or the [MM Practice Rom](https://kz.zeldacodes.org/) (aka KZ) will be very beneficial if you have not looked at either of the N64 Zelda's internals before. -The [OOT Decompilation Project](https://github.com/zeldaret/oot) is farther along than this project, so it can also be a great resource. +The most useful knowledge to have is a general understanding of how the game works. An afternoon of constructive mucking about in the [MM Practice Rom](https://kz.zeldacodes.org/) (aka KZ) or the [OoT Practice Rom](http://practicerom.com/) (aka GZ) will be very beneficial if you have not looked at either of the N64 Zelda's internals before. + +The [OoT Decompilation Project](https://github.com/zeldaret/oot) is farther along than this project, so it can also be a great resource. This project only uses *publicly available code*. -Anyone who wishes to contribute to the OOT or MM projects **must not have accessed leaked source code at any point in time** for Nintendo 64 SDK, iQue player SDK, libultra, Ocarina of Time, Majora's Mask, Animal Crossing/Animal Forest, or any other game that shares the same game engine or significant portions of code to a Zelda 64 game or any other console similar to the Nintendo 64. + + +**N.B.** Anyone who wishes to contribute to the OOT or MM projects **must not have accessed leaked source code at any point in time** for Nintendo 64 SDK, iQue player SDK, libultra, Ocarina of Time, Majora's Mask, Animal Crossing/Animal Forest, or any other game that shares the same game engine or significant portions of code to a Zelda 64 game or any other console similar to the Nintendo 64. ### Environment Setup @@ -46,53 +47,28 @@ You should be able to build a matching ROM before you start making any changes. ### First Contribution Usually, the best place to get started is to decompile an actor overlay. -An *actor* is any thing in the game that moves or performs actions or interactions. This includes things like Link, enemies, NPCs, doors, pots, etc. +An *actor* is any thing in the game that moves or performs actions or interactions. This includes things like Link, enemies, NPCs, doors, pots, etc. Actors are good for a first file because they are generally small, self-contained systems. -You should [join the Discord](https://discord.zelda64.dev/) to say hello and get suggestions on where to start on the `#mm-decomp` channel. +We recommend that you [join the Discord](https://discord.zelda64.dev/) to say hello and get suggestions on where to start on the `#mm-decomp` channel. -We track who is working on what on the [Google Sheets reservation board](https://docs.google.com/spreadsheets/d/1X83YCPRa532v-Zo0WgUsJ2kB1X9RxBta5_p9aWA8uro). -After joining the Discord, open the Google Sheets reservation board so you can claim your code file and avoid duplicate work. +We track who is working on what on some Google Sheets available in the Discord. Once you've decided on or been recommended a good first file, mark it as Reserved. -The work flow is: Reserve a file, decompile it, submit a PR, and then repeat while addressing review comments. The expectation is that one reservation goes to one file which ends up in a one file PR. +The workflow is: +- Reserve a file, +- decompile it, +- submit a PR, +- repeat while addressing review comments. -Please note that unless it is communicated beforehand you will be expected to fully complete the file if you reserve it on Google Sheets reservation board. Exceptions are always easy to approve if it's communicated to the team. Real life circumstances can prevent someone from finishing. In these cases they should link their repo/branch in the Google Sheets reservation board and unreserve immediately. Communicate any issues with your reservations as early as possible. +The expectation is that one reservation goes to one file which ends up in a one file PR, although naturally some files are more sensibly worked on as a group, for example two actors that work together. This also does not apply to large asset files like `gameplay_keep`: you can just reserve the parts that are used in your files. -Style Guide & Conventions -------------------------- +If possible, we expect reserved files to be completed. If you find you cannot complete a file, because it is intractable for one reason or another, or real-life circumstances get in the way, please talk to one of the leads in Discord; we may find someone else interested in helping you finish, or who is happy to take over the file from you completely. If you unreserve a file on which you have useful progress, please leave a link to your branch in the Notes column on the Google Sheet that the next person who works on the file can use. -Most of the C formatting style is enforced by the `format.sh` script which is based on `clang-format`. -Running `./format.sh` will apply our standard style to all `.c` files in the repository. -There are some conventions that cannot be automatically enforced. +## Style Guide & Conventions -### Naming Scheme +See the [Style Guide](docs/STYLE.md). -The following overlays are good examples of our naming conventions: - -- [`ovl_Dm_Ravine`](src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c) -- [`ovl_En_Jc_Mato`](src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c) - -These files demonstrate the following: - -- Word order in names are from least-to-most specific (`DM_RAVINE_STATE_ACTIVE`, not `DM_RAVINE_ACTIVE_STATE`) -- Functions, structs, unions, enums, and typedefs are `TitleCase` (`DmRavine`) - - "Methods" for objects separate the object from the verb with an underscore (`DmRavine_Init`) -- Variable names are `camelCase` (`actionFunc`) - - Global variables start with `g` (`gSaveContext`) - - Static global variables start with `s` (`sSphereInit`) -- Macros and enum constants are `SCREAMING_SNAKE_CASE` (`DM_RAVINE_STATE_ACTIVE`) -- Public structs, enums, and constants should be defined in the header file in the following cases: - - The primary `Actor` struct (`DmRavine`) - - The actor's `InitVars`, as an `extern` symbol (`Dm_Ravine_InitVars`) - - Types used in other public declarations, like `actionFunc` typedefs (`DmRavineActionFunc`) - - Macros and enums for accessing & setting actor `params` - - The struct/enum/define is needed by other files -- Trailing commas in array and struct definitions (see `EnJcMatoDamageTable`) -- Constants converted to whichever looks best in context: hexadecimal, decimal, or float - - Rotation angles should always be in hexadecimal -- Define macros for bitwise access to `actor->params` - -### `NON_MATCHING` & `NON_EQUIVALENT` +## `NON_MATCHING` and `NON_EQUIVALENT` If you make significant progress on decompiling a function, but can't get it to match perfectly, you can use a `NON_MATCHING` block to commit your code but have it excluded from the build, like so: @@ -102,20 +78,23 @@ void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v) { // ... } #else +void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v); #pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnWaterDroplets.s") #endif ``` -Before using `NON_MATCHING`, first try to use the [decomp-permuter](tools/decomp-permuter) tool to find a closer match. +Before PRing with a `NON_MATCHING`, you can try +- using the [decomp-permuter](tools/decomp-permuter) to find a closer match, +- Asking in `#mm-decomp-help` in Discord; the easiest way to allow other people to play around with the function you are stuck on is to make a scratch on [decomp.me](http://decomp.me). `NON_EQUIVALENT` can be used with the same syntax as `NON_MATCHING`, but it is used to mark sections of code which do not match *and* do not have the same behavior as the original code. -### Matching vs. Documenting +## Matching and Documenting Usually, the first step of decompiling a section of code is to get it *matching*: to produce a C version of the code that can be compiled into an identical ROM. However, the goal of this project is to produce a codebase that can be understood and modified. -So, beyond producing matching C code, the next steps are *documenting* the code. +Therefore once C code produces matching assembly, the next step is to *document* the code. Documenting is more than just adding comments. Documenting also includes: @@ -123,22 +102,19 @@ Documenting is more than just adding comments. Documenting also includes: - Using (or adding) constants, enums, and macros when possible - Explaining sections of code that are not straightforward -Overlays are not required to be documented at this time, but `code/` and `boot/` should be documented. When documentation on a file has been started it should be as complete as possible. +Overlays are not required to be documented at this time, but files from `code/` and `boot/` should be documented. When documentation on a file has been started it should be as complete as reasonable. -For right now, object segment symbols should not be documented/renamed. -These will be given names when object reconstruction is ready. -However, it can be useful to add comments with name suggestions. +See the [Style Guide](docs/STYLE.md) for more details on documentation style. -Pull Requests (PRs) -------------------- +## Pull Requests (PRs) ### Checklist Before opening a PR, walk through the following steps to ensure that your code conforms to the style guide and conventions. -- `./format.sh` was run to apply standard formatting. - `make` successfully builds a matching ROM. +- `./format.sh` was run to apply standard formatting. - No new compiler warnings were introduced during the build process. - Can be verified locally by running `tools/warnings_count/check_new_warnings.sh` - New variables & functions should follow standard naming conventions. @@ -148,15 +124,28 @@ Feel free to reach out on the Discord if you have any questions about these step ### Pull Request Process -After opening a PR, the Jenkins server will verify your changes. -If there is an error, double-check that you can successfully `make clean && make` locally. If the build is OK, the next thing to check is that all added/modified files were `git add`-ed to your commit. The final check before posting on Discord for help is that there are no new warnings added to the code causing Jenkins to fail. You can check this by running: `tools/warnings_count/check_new_warnings.sh`. +After opening a PR, the Jenkins agent will test formatting, the contents of the spec, build the rom and check for warnings. +If there is an error, double-check that you can successfully +```bash +make disasm +./extract_assets.py -f +make clean +make +``` +locally. If the build is `OK`, the next thing to check is that all added/modified files were `git add`-ed to your commit. The final check before posting on Discord for help is that there are no new warnings added to the code causing Jenkins to fail. You can check this by running: `tools/warnings_count/check_new_warnings.sh`. -Each PR needs a review from one reviewer and the project lead. +Each PR needs a review from two reviewers, at least one a project lead, and final approval from Kenix. -The PR author marks the comments as resolved: the commenter may not have permissions to do so. -Once all comments are addressed, it is courteous to ping the reviewer on either Discord or GitHub via re-requesting a review. +If the PR author agrees with a reviewer's suggestion, they make the change and resolve the conversation. If they disagree, have a better idea, or want to comment on something, they should at least leave a comment, and discuss it in Discord if it's not going to be resolved quickly, since long conversations on GitHub are hard to read. -After all the comments are addressed and at least one contributor has approved the review, the project lead can then review and merge the code. -The project lead is also responsible for ensuring that all of these procedures are followed. +Once all comments is addressed and all reviewers have approved, the PR will be merged. -Throughout the PR process, you (the author) should update the row on [Google Sheets reservation board](https://docs.google.com/spreadsheets/d/1X83YCPRa532v-Zo0WgUsJ2kB1X9RxBta5_p9aWA8uro) with the appropriate information as the decompilation process progresses. +Project leads are responsible for ensuring that these conventions are followed. + +### Some git notes + +- You should work on a branch on your fork separate from your copy of master: it is always useful to have a clean master branch around if you need to fix something. +- When a PR is merged into master, it may conflict with your work. While your branch is private (in particular, not used for a PR), you can rebase, but when your branch is public/used for a PR always merge master instead of rebasing: it makes it much easier for people to understand what you changed since the last review. +- We squash commits when merging, so your commit history does not have to be completely spotless. + +Throughout the PR process, you (the author) should update the rows on the appropriate Google Sheets with the appropriate information as the decompilation process progresses. diff --git a/README.md b/README.md index c3ce27e97..f48230b90 100644 --- a/README.md +++ b/README.md @@ -17,15 +17,15 @@ ```diff - WARNING! - -The ROM this repository builds while has a matching checksum cannot be 'shifted' due -to hardcoded pointers which have yet to be dumped. Thus this repository is currently -in an experimental and research phase and cannot currently be used traditionally as a -source code base for general changes. +This repository is a work in progress, and while it can be used to make certain changes, it's +still constantly evolving. If you wish to use it for modding purposes in its current state, +please be aware that the codebase could drastically change at any time. Also note that some +parts of the ROM may not be 'shiftable' yet, so modifying them could currently be difficult. ``` -This is a WIP **decompilation** of ***The Legend of Zelda: Majora's Mask***. The purpose of the project is to recreate a source code base for the game from scratch, using information found inside the game along with static and/or dynamic analysis. **It is not producing a PC port.** For more information you can get in touch with the team on our [Discord server](https://discord.zelda64.dev). +This is a WIP **decompilation** of ***The Legend of Zelda: Majora's Mask***. The purpose of the project is to recreate a source code base for the game from scratch, using information found inside the game along with static and/or dynamic analysis. **It is not, and will not, produce a PC port.** For frequently asked questions, you can visit [our website](https://zelda64.dev/mm), and for more information you can get in touch with the team on our [Discord server](https://discord.zelda64.dev). -The only build currently supported is N64 US, but other versions are planned to be supported. +The only version currently supported is N64 US, but we intend to eventually support every retail version of the original game (i.e. not versions of MM3D, which is a totally different game). It currently builds the following ROM: * mm.us.rev1.rom.z64 `md5: 2a0a8acb61538235bc1094d297fb6556` @@ -137,16 +137,10 @@ The disadvantage that the ordering of the terminal output is scrambled, so for d ## Contributing All contributions are welcome. This is a group effort, and even small contributions can make a difference. -Some tasks also don't require much knowledge to get started. +Some work also doesn't require much knowledge to get started. Please note that is is our strict policy that *Anyone who wishes to contribute to the OOT or MM projects **must not have accessed leaked source code at any point in time** for Nintendo 64 SDK, iQue player SDK, libultra, Ocarina of Time, Majora's Mask, Animal Crossing/Animal Forest, or any other game that shares the same game engine or significant portions of code to a Zelda 64 game or any other console similar to the Nintendo 64.* -Most discussions happen on our [Discord Server](https://discord.zelda64.dev), where you are welcome to ask if you need help getting started, or if you have any questions regarding this project and other decompilation projects. +Most discussions happen on our [Discord Server](https://discord.zelda64.dev), where you are welcome to ask if you need help getting started, or if you have any questions regarding this project or ZeldaRET's other decompilation projects. -For more information on getting started, see our [Contributing Guide](CONTRIBUTING.md) and our [Code Review Guidelines](REVIEWING.md) to see what code quality guidelines we follow. - - -## FAQ - -### Q: Why does MM use transient assembly? -A: It is the view of the MM project leads that transient asm is safer than storing the disassembly in the repo. We feel like the C code is more transformative than a straight disassembly. \ No newline at end of file +For more information on getting started, see our [Contributing Guide](CONTRIBUTING.md), [Style Guide](docs/STYLE.md) and our [Code Review Guidelines](docs/REVIEWING.md) to see what code quality guidelines we follow. diff --git a/REVIEWING.md b/REVIEWING.md deleted file mode 100644 index 74f9dbac5..000000000 --- a/REVIEWING.md +++ /dev/null @@ -1,67 +0,0 @@ -Reviewing Pull Requests to the Majora's Mask Decompilation Project -======================================================= - -Thanks for helping us reverse engineer *The Legend of Zelda: Majora's Mask* for the N64! -We invite all contributors to participate in our code review program. Every review submitted helps us keep code quality high and code merged in more quickly. - -This document is meant to be a set of tips and guidelines for reviewers of pull requests to the project. -For general information about the project, see [our readme](https://github.com/zeldaret/mm/blob/master/README.md). - -Most discussions happen on our [Discord Server](https://discord.zelda64.dev) where you are welcome to ask if you need help getting started, or if you have any questions regarding this project and other decompilation projects. - -Useful Links ------------- - -- [Discord](https://discord.zelda64.dev/) - Primary discussion platform. -- [Google Sheets reservation board](https://docs.google.com/spreadsheets/d/1X83YCPRa532v-Zo0WgUsJ2kB1X9RxBta5_p9aWA8uro) - We use this to track decompilation progress, not GitHub Issues. - -- [Contributing guide](https://github.com/zeldaret/mm/blob/master/CONTRIBUTING.md) - Instructions for contributors. -- [Installation guide](https://github.com/zeldaret/mm/blob/master/README.md#installation) - Instructions for getting this repository set up and built on your machine. - -- [Zelda 64 Reverse Engineering Website](https://zelda64.dev/) - Our homepage, with links to other resources. -- [Introduction to OOT decomp](https://github.com/zeldaret/oot/blob/master/docs/tutorial/contents.md) - A very detailed tutorial on how to get started with decomp. For OOT, but largely applicable to MM as well. -- The `#resources` channel on the Discord contains many more links - -Getting Started ---------------- - -### What should I know to take part in the review process? - -You should first get yourself familiar with our [Contributing guide](https://github.com/zeldaret/mm/blob/master/CONTRIBUTING.md). It is also recommended that you have already successfully submitted a merged pull request to understand how the process works before submitting a review. - -Pull Requests (PRs) ------------- - -### How to review a Pull Request - -- When reviewing a PR it is suggested that you follow the checklist outlined in this section. -- You are not required to check for all of the items in the checklist. It is meant as a guide. -- Once the PR author has addressed all of your comments, you should add a comment with approval to the PR to signify to the project leads that this PR has been through peer review. -- If someone does not address your comments and expresses that a different way is better than yours, look for feedback from other contributors. The project lead will have final say in these situations. All decisions will generally be guided by a consensus of contributors. - -### Reviewer Checklist -- [ ] Jenkins build is successful. - - [ ] `make` builds a matching ROM. - - [ ] Any new compiler warnings that were added are required for matching. Ensure there is good reason if the warnings files have changed. `./tools/warnings_count/warnings_build_current.txt` and `./tools/warnings_count/warnings_setup_current.txt` -- [ ] Files with NON_MATCHING functions have equivalent behaviour. (This will only be reviewed once we have shiftability since equivalence testing is easiest in game) -- [ ] `code` and `boot` segment files should be documented as much as possible. Overlays with documentation should be complete. - - [ ] Overlays with documentation should have macros to define access to parameters if the parameter uses bitwise access. The params should have an enum when it makes sense. -- [ ] `format.sh` was run. -- [ ] Comments and variables have correct spelling. -- [ ] The following should be declared in an Actor header file. There should be nothing else in the Actor header file. - - [ ] Main Actor struct - - [ ] Extern'd initVar data. - - [ ] Types used in the actor struct. Specific example would be actionFunc typedefs. - - [ ] Param field macros and/or enums. - - [ ] For any other additional `enum`/`struct`/`define`/`function`/`global`, there needs to be evidence it is needed in another file. -- [ ] New variables and functions should follow standard naming conventions. - - [ ] Constants are converted to whichever looks best in context: hexadecimal, decimal, or float - - [ ] Rotation angles should always be in hexadecimal - - [ ] Colour values should always be in decimal. - - [ ] Functions, structs, unions, enums, and typedefs are `TitleCase` (`DmRavine`) - - [ ] "Methods" for objects separate the system from the verb with an underscore (`DmRavine_Init`) - - [ ] Variable names are `camelCase` (`actionFunc`) - - [ ] Global variables start with `g` (`gSaveContext`) - - [ ] Static global variables start with `s` (`sSphereInit`) - - [ ] Macros and enum constants are `SCREAMING_SNAKE_CASE` (`DM_RAVINE_STATE_ACTIVE`) - - [ ] Trailing commas in array and struct definitions (see `EnJcMatoDamageTable`) diff --git a/docs/REVIEWING.md b/docs/REVIEWING.md new file mode 100644 index 000000000..11545fb27 --- /dev/null +++ b/docs/REVIEWING.md @@ -0,0 +1,59 @@ +# Reviewing Pull Requests to the Majora's Mask Decompilation Project + +Thanks for helping us reverse engineer *The Legend of Zelda: Majora's Mask*! +We encourage all contributors to participate in code review: this is your codebase too! +Every review submitted helps us keep code quality high and code merged in more quickly. + +This document is meant to be a set of tips and guidelines for reviewers of pull requests to the project. +For general information about the project, see [our readme](https://github.com/zeldaret/mm/blob/master/README.md). + +Most discussions happen on our [Discord Server](https://discord.zelda64.dev) where you are welcome to ask if you need help getting started, or if you have any questions regarding this project and other decompilation projects. + +Other links are available in the [CONTRIBUTING.md](CONTRIBUTING.md) + + +## Getting Started + +### What should I know to take part in the review process? + +You should first famiiarise yourself with our [Contributing guide](CONTRIBUTING.md) and [Style guide](docs/STYLE.md). It is also recommended that you have already successfully submitted a merged pull request to understand how the process works before submitting a review. + + +## Pull Requests (PRs) + +### How to review a Pull Request + +- When reviewing a PR it is suggested that you follow the checklist outlined in this section. +- You are not required to go through *every* item in the checklist. It is meant as a guide; if you have only one thing you want to mention, that's fine too. +- Once the PR author has addressed all of your comments, you should add a review with approval to the PR to signify to the project leads that this PR has been through peer review. +- If someone does not address your comments and expresses that a different way is better than yours, look for feedback from other contributors (we encourage discussing this sort of thing in Discord, since long GitHub conversations get hard to read). The project leads will have final say in these situations. All decisions are generally guided by a consensus of contributors. + +### Reviewer Checklist +- [ ] Jenkins build is successful. + - [ ] `make` builds a matching ROM. + - [ ] `format.sh` was run. + - [ ] `spec` contains correct relocation files. + - [ ] Any new compiler warnings that were added are required for matching. Ensure there is good reason if the warnings files have changed. +- [ ] Files with `NON_MATCHING` functions have equivalent behaviour. +- [ ] `code` and `boot` segment files should be documented as much as possible. Overlays with documentation should be as complete as is reasonable. + - [ ] Overlays should have macros to define access to parameters if the parameter uses bitwise access. The params should have an enum when it makes sense. +- [ ] Comments and variables have correct spelling. +- [ ] The following should be declared in an Actor header file. There should be nothing else in the Actor header file. + - [ ] Main Actor struct + - [ ] Extern'd initVar data. + - [ ] Types used in the actor struct. Specific example would be actionFunc typedefs. + - [ ] Param field macros and/or enums. + - [ ] For any other additional `enum`/`struct`/`define`/`function`/`global`, there needs to be evidence it is needed in another file. +- [ ] New variables and functions should follow standard naming conventions. + - [ ] Constants are converted to whichever looks best in context: hexadecimal, decimal, or float + - [ ] Rotation angles should always be in hexadecimal + - [ ] Colour values should always be in decimal. + - [ ] Functions, structs, unions, enums, and typedefs are `TitleCase` (`DmRavine`) + - [ ] Functions within a system separate the system from the function's own subname with an underscore (`DmRavine_Init`) + - [ ] Variable names are `camelCase` (`actionFunc`) + - [ ] Global variables start with `g` (`gSaveContext`) + - [ ] Static global variables start with `s` (`sSphereInit`) + - [ ] Macros and enum constants are `SCREAMING_SNAKE_CASE` (`DM_RAVINE_STATE_ACTIVE`) + - [ ] Trailing commas in array and struct definitions chosen to make it look best (see e.g. `EnJcMatoDamageTable`) + +etc. diff --git a/docs/STYLE.md b/docs/STYLE.md new file mode 100644 index 000000000..6524e05d6 --- /dev/null +++ b/docs/STYLE.md @@ -0,0 +1,232 @@ +# Majora's Mask decompilation style guide + +In general, completed documented files are a good place to look to understand project style in general. + +## Types + +Use the types from `ultratypes.h`, not the standard C types: i.e. `u8`,`s8`,`s16`,`u16`,`s32`,`u32`,`f32` rather than `char`, `short`, `int`, `float` and their `signed`/`unsigned` varieties. + +We always write our enums and structs as `typedef`s. (Usually one can't use an enum typedef as a function argument since enum typedefs are implicitly `s32`.) + +## Naming + +Names are "big-endian": the most significant/largest part of the system goes first, e.g. `DM_RAVINE_STATE_ACTIVE` rather than `DM_RAVINE_ACTIVE_STATE`. + +| Type | Style | Example | +| -------------------- | ----------------------- | ----------------------- | +| Local variables | camelCase | `yawToPlayer` | +| Global variables | gCamelCase | `gSaveContext` | +| Static variables[^1] | sCamelCase | `sZeroVec` | +| Struct members | camelCase | `actionFunc` | +| Struct names | PascalCase | `EnFirefly` | +| Enum types | PascalCase | `EnFireflyMainType` | +| Enum values | SCREAMING_SNAKE_CASE | `AT_ON` | +| Defines/macros | SCREAMING_SNAKE_CASE | `SCREEN_WIDTH`,`ABS(x)` | +| Functions | SystemName_FunctionName | `Actor_SpawnAsChild` | +| Files | snake_case | `z_en_firefly.c` | + +[^1]: including in-function static + +Action functions are usually named with a simple present-tense verb or verb phrase: `{...}_Talk`, `{...}_Wait`, `{...}_FallToGround`, etc. Setup functions are `Setup{name of action}`. + +Ideally names should be both short and clear, although it's better to be clear than short. + +## Formatting + +A lot of formatting is done by clang-format, such as + +- indent is 4 spaces, tabs are not used +- case labels indented +- 120 column limit +- brackets go on the same line (`if (1) {`) +- pointer goes on type (`s32* var;` not `s32 *var;`) + +There are various other conventions that it does not catch, though: + +- Blank line between declarations and code: + ```c + s32 var; + + func(); + ``` +- combine declarations and definitions if possible: + ```c + s32 var = 0; + + func(); + ``` + instead of + ```c + s32 var; + + var = 0; + func(); + ``` +- blank lines between switch cases if they're long (use your judgement). + + +## Numbers + +### dec(imal) + +- timers +- colours and alpha +- Usually array accesses and sizes + +### hex(adecimal) + +- angles (for now; the code itself is very inconsistent with round hex, round dec, and degrees) +- Addresses +- Bitmasks (i.e. `& 0x80` etc.) +- Struct offset comments + +Numbers below `10`/`0xA` do not need the `0x` if by themselves in code. + +### Booleans + +If a function returns only `0` or `1`, and is used as a boolean (i.e. in conditionals), replace the returns by `false` and `true`. (We do not use `bool`, partly because is a C99 thing, and partly because the original has used almost every integer type as a boolean return at some point!) + +### Floats + +Floats usually need an `f` on the end to match, or IDO will use doubles. Our floats are always of the form `1.0f`, even when the decimal part is zero. + +## Conditionals/Loops + +- Spacing out conditional or loop blocks from surrounding code often makes them easier to read. +- Avoid assigning or mutating variables in conditionals if possible (including `++`/`--`), avoid side effects in the loop increment slot (i.e. incrementing/assigning to loop variables is fine, something like `*a = b++` is not). +- We *always* use `{}` on conditional/loop blocks, even if they're one line (clang-tidy will enforce this). +- When conditions are `&&`d or `||`d together, use brackets around each that includes an arithmetic comparison or bitwise operator (i.e. not `!var` or `func()`, but ones with `==` or `&` etc.) +- Flag checks or functions that return booleans do not need the `== 0`/`!= 0`. +- Prefer `if-else` over `if { return; }`, i.e. + ```c + if (cond) { + foo(); + } else { + bar(); + } + ``` + over + ```c + if (cond) { + foo(); + return; + } + bar(); + ``` +**Exception**: After `Actor_MarkForDeath` or sometimes setting the action function, if it makes sense to do so (this expresses the finality a bit better). + +## Macros and enums + +Become familiar with the various defines and enums we have available. There are too many to list all of them here, but the following are common: + +- Those in `macros.h` + - `ABS`, `ABS_ALT`, + - `CLAMP` and friends, + - `BINANG_*`, which are used for angles, especially when there's a lot of `s16` casts around +- `MTXMODE` for many of the `sys_matrix` functions +- CollisionCheck flags: `AT_ON` and so on. Pick the appropriate one for the collider type. +- Actor flags, `ACTOR_FLAG_N`. + +Damage flag enums are not being used at present: we want to wait until we have a better idea what the common groupings should be. + +Pre-C99, commas at the end of the last item in an enum will cause a compiler warning, so leave them off. + +All compound flag lists (e.g. `ACTOR_FLAG_4 | ACTOR_FLAG_8`) should be listed in *ascending* order + +## Arrays + +- It's better to not hardcode array sizes (easier to mod) +- Use `sizeof` or `ARRAY_COUNT`/`ARRAY_COUNTU` where it makes sense, e.g. in loops that are using an array. +- clang-format sometimes does weird things to array formatting. Experiment with and without a comma after the last element and see which looks better. + +## GlobalCtx2 + +In some particular instances, IDO requires the function argument `globalCtx` to be cast to a second variable of the same type to match. In these particular instances, the function argument should be renamed to `globalCtx2` and than this `globalCtx2` just assigned to a stack variable called `globalCtx`. This cast should occur before the actor `THIS` cast is made. For example in `z_en_firefly.c` +```c +void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnFirefly* this = THIS; +``` + +In other places the cast is actually not explictly needed, but a stack `pad` variable is still needed. For this there should just be a stack variable called `pad` of type `s32` before the actor `THIS` cast. For example in `z_bg_goron_oyu` +```c +void BgGoronOyu_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgGoronOyu* this = THIS; + CollisionHeader* colHeader = NULL; +``` + +In general, pads should be `s32`, or `s16`/`s8` if required. + + +## Documentation and Comments + +Documentation includes: +- Naming functions +- Naming struct variables +- Naming data +- Naming local variables +- Describing the general purpose of the file +- Describing any unusual, interesting or strange features of how the file or parts of its content work +- Labelling and explaining bugs +- Making enums or defines for significant numbers for the file, like actor params values. +- Naming the contents of the asset file(s) the file may use (for an actor, the object(s) it uses) + +If you are not sure what something does, it is better to leave it unnamed than name it wrongly. It is fine to make a note of something you are not sure about when PRing, it means the reviewers will pay special attention to it. + +We use comments for: +- Top of file: a short description of the system. For actors there is already a brief description of our current understanding, but feel free to add to it. +- For function descriptions, we use multiline comments, + ```c + /** + * Describe what the function does + */ + ``` + These are *optional*: if you think the code is clear enough, you do not need to put a comment. You can use Doxygen formatting if you think it adds something, but it is also not required. +- If something in a function is strange, or unintuitive, do leave a comment explaining what's going on. We use `//` for this. +- We also use `//` for temporary comments above a function. Feel free to use `TODO:` in these if appropriate. +- A bug should be commented with an `//! @bug Bug description` above the code that causes the bug. + +## What goes where + +This section mostly applies to actors. + +### Functions + +All functions should go in the main C file in the same order as the assembly (the latter is required to match anyway). (We may make exceptions for particularly large files with a particular organisational structure, but we ask that you check on Discord first before doing this) + +### Data + +- If in doubt, leave all the data at the top of the file. Reviewers will decide for you. +- Data must go in the same order as in the assembly files, but is only constrained by other data, not functions or rodata. +- Some data has to be inline static to match. Generally it's better to not use `static` on data outside funtions until the file is matching, since `static` data is left out of the mapfile and this makes debugging harder. +- *This is even more true of bss, where we have trouble with IDO unpredictably reordering it in certain files.* +- For small arrays or simple data that is used in only one function, we usually inline it, if it fits in the ordering. +- Generally data that is only used by the draw functions is put down near them: this is one of the few consistencies in ordering of actors' functions. + +### Enums and defines + +- Actors that bitpack params should have macros made for each access or write that is made. `z_en_dg.h` has an undocumented example, + ```c + #define ENDG_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) + #define ENDG_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) + ``` + while `z_en_firefly.h` has a documented one, + ```c + #define KEESE_INVISIBLE (1 << 0xF) + #define KEESE_GET_MAIN_TYPE(thisx) ((thisx)->params & 0x7FFF) + ``` +- In a similar manner, actors that use `home.rot.(x|y|z)` like params should also macros made for accesses and writes. (See, e.g. `z_obj_bean.h`.) +- Stuff that only the actor itself will use goes in the C file unless needed in the header. +- Anything actor-specific that might be used by another file goes in the header, in particular params access macros. +- Anything that is expected to have widespread use should go in `macros.h` or an appropriate header in `include`. + +### Objects + +Are covered in the [ZAPD extraction xml spec](../tools/ZAPD/docs/zapd_extraction_xml_reference.md). Symbol names are `gPrefixDescriptionSuffix` for symbols accessed from the header (they will be global). Texture OutNames are in snake_case since they are filenames. + +## Above all else + +*All of the above is subservient to matching.* Sometimes IDO cares about newlines, for example. + +If you are not sure about any of the above, please ask in Discord. From 6d3bcc5cbb8f5a479d4b0a260cbff92d2e6decfb Mon Sep 17 00:00:00 2001 From: Isghj <42048411+isghj5@users.noreply.github.com> Date: Wed, 25 May 2022 19:11:07 -0700 Subject: [PATCH 220/257] `EnFamos` OK with `object_famos` (#789) * EnFamos: redo begin * EnFamos: back to where I was previously * EnFamos: matched looping draw function * EnFamos: OK * Famos: some docs * Famos: some docs * Famos: sfx convert pass * EnFamos: some docs * EnFamos: more docs * Enfamos: more docks * EnFamos: more doc * EnFamos: more docks * EnFamos: mass to dec * Famos: limb enum * Famos: more docs all functions named * Famos: all struct mapped * Apply suggestions from code review Co-authored-by: EllipticEllipsis * Famos: fix declaration order * Famos: requested changes * Famos: draw func using proper sSetupDL indexing * Famos: fix text anim mismatch, change tlut to match gFamos SnakeCase * Famos: formater pls * Famos: requested changes * Famos: more requested changes * Apply suggestions from code review Co-authored-by: Derek Hensley * Update assets/xml/objects/object_famos.xml Co-authored-by: Tom Overton * Famos: requested changes and format pass * Apply suggestions from code review Co-authored-by: EllipticEllipsis * Famos: more requested changes * Famos: more requested changes * Famos: another change * Apply suggestions from code review Co-authored-by: EllipticEllipsis * Famos: made define macro for agro distance * Famos: separated conditions on separate lines Co-authored-by: Isghj8 Co-authored-by: EllipticEllipsis Co-authored-by: Derek Hensley Co-authored-by: Tom Overton --- assets/xml/objects/object_famos.xml | 51 +- spec | 3 +- src/code/z_bgcheck.c | 3 - src/overlays/actors/ovl_En_Famos/z_en_famos.c | 853 ++++++++++++++++-- src/overlays/actors/ovl_En_Famos/z_en_famos.h | 52 +- tools/disasm/functions.txt | 74 +- 6 files changed, 893 insertions(+), 143 deletions(-) diff --git a/assets/xml/objects/object_famos.xml b/assets/xml/objects/object_famos.xml index 4466f9b30..cbbf0057c 100644 --- a/assets/xml/objects/object_famos.xml +++ b/assets/xml/objects/object_famos.xml @@ -1,28 +1,31 @@  + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index b223f113c..a92016e25 100644 --- a/spec +++ b/spec @@ -969,8 +969,7 @@ beginseg name "ovl_En_Famos" compress include "build/src/overlays/actors/ovl_En_Famos/z_en_famos.o" - include "build/data/ovl_En_Famos/ovl_En_Famos.data.o" - include "build/data/ovl_En_Famos/ovl_En_Famos.reloc.o" + include "build/src/overlays/actors/ovl_En_Famos/ovl_En_Famos_reloc.o" endseg beginseg diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index f0ebe5911..58c71c33e 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -4208,9 +4208,6 @@ s32 func_800C9AE4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return (func_800C9A4C(colCtx, poly, bgId) & 4) ? true : false; } -/** - * unused - */ u32 func_800C9B18(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 26 & 0xF; } diff --git a/src/overlays/actors/ovl_En_Famos/z_en_famos.c b/src/overlays/actors/ovl_En_Famos/z_en_famos.c index 23da2fb30..cc8c799ee 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.c +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.c @@ -1,10 +1,12 @@ /* * File: z_en_famos.c * Overlay: ovl_En_Famos - * Description: Death Armos + * Description: Death Armos (floating statue enemy in Inverted Stone Tower Temple) */ #include "z_en_famos.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) @@ -15,7 +17,39 @@ void EnFamos_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFamos_Update(Actor* thisx, GlobalContext* globalCtx); void EnFamos_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnFamos_SetupAttackDebris(EnFamos* this); +void EnFamos_SetupDeathDebris(EnFamos* this); +s32 EnFamos_IsPlayerSeen(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupStillIdle(EnFamos* this); +void EnFamos_StillIdle(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupPathingIdle(EnFamos* this); +void EnFamos_PathingIdle(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupTurnHome(EnFamos* this); +void EnFamos_TurnHome(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupReturnHome(EnFamos* this); +void EnFamos_ReturnHome(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupAlert(EnFamos* this); +void EnFamos_Alert(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupChase(EnFamos* this); +void EnFamos_Chase(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupAttackAim(EnFamos* this); +void EnFamos_AttackAim(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupAttack(EnFamos* this); +void EnFamos_Attack(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupFinishAttack(EnFamos* this); +void EnFamos_FinishAttack(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupAttackRebound(EnFamos* this); +void EnFamos_AttackRebound(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupScanForPlayer(EnFamos* this); +void EnFamos_ScanForPlayer(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupDeathSlam(EnFamos* this); +void EnFamos_DeathSlam(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupDeathExplosion(EnFamos* this); +void EnFamos_DeathExplosion(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_SetupDeathFade(EnFamos* this); +void EnFamos_DeathFade(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_DrawDebris(EnFamos* this, GlobalContext* globalCtx); + const ActorInit En_Famos_InitVars = { ACTOR_EN_FAMOS, ACTORCAT_ENEMY, @@ -28,133 +62,810 @@ const ActorInit En_Famos_InitVars = { (ActorFunc)EnFamos_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808AE600 = { - { COLTYPE_METAL, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x20000000, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_METAL, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x20000000, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 80, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808AE62C = { - { COLTYPE_NONE, AT_NONE | AT_TYPE_ENEMY, AC_NONE, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_NONE, + AT_NONE | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 70, 10, 0, { 0, 0, 0 } }, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_808AE658[2] = { +// the emblem at the from and the back is one limb running front to back through the torso +// this is both sides of the emblem, front and back +static ColliderJntSphElementInit sJntSphElementsInit[2] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00002000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 2, { { 2500, 0, 0 }, 20 }, 100 }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00002000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { FAMOS_LIMB_EMBLEM, { { 2500, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00002000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 2, { { -1500, 0, 0 }, 20 }, 100 }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00002000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { FAMOS_LIMB_EMBLEM, { { -1500, 0, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808AE6A0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_808AE658, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808AE6B8[] = { +typedef enum { + /* 0 */ FAMOS_ANIMATED_MAT_NORMAL, // normal is greenish + /* 1 */ FAMOS_ANIMATED_MAT_FLIPPED // flipped is orange/yellowish +} FamosAnimatedMatArrayIndexes; + +static AnimatedMaterial* sEmblemAnimatedMats[] = { + gFamosNormalGlowingEmblemTexAnim, + gFamosFlippedGlowingEmblemTexAnim, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 15, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3500, ICHAIN_STOP), }; -#endif +static s32 sAnimatedMaterialsDesgmented = false; -extern ColliderCylinderInit D_808AE600; -extern ColliderCylinderInit D_808AE62C; -extern ColliderJntSphElementInit D_808AE658[2]; -extern ColliderJntSphInit D_808AE6A0; -extern InitChainEntry D_808AE6B8[]; +void EnFamos_Init(Actor* thisx, GlobalContext* globalCtx) { + EnFamos* this = THIS; + Path* path; + s32 i; -extern UNK_TYPE D_060000F8; -extern UNK_TYPE D_06003DC8; + Actor_ProcessInitChain(&this->actor, sInitChain); + if (GET_FAMOS_PATH(thisx) != 0xFF) { + path = &globalCtx->setupPathList[this->actor.params]; + this->pathPoints = Lib_SegmentedToVirtual(path->points); + this->pathNodeCount = path->count; + if (this->pathNodeCount == 1) { + this->pathPoints = NULL; + this->pathNodeCount = 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/EnFamos_Init.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawSquare, 30.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gFamosSkeleton, &gFamosIdleAnim, this->jointTable, this->morphTable, + FAMOS_LIMB_MAX); + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); + Collider_InitAndSetJntSph(globalCtx, &this->emblemCollider, &this->actor, &sJntSphInit, + this->emblemColliderElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/EnFamos_Destroy.s") + if (!sAnimatedMaterialsDesgmented) { // init animated materials + for (i = 0; i < ARRAY_COUNT(sEmblemAnimatedMats); i++) { + sEmblemAnimatedMats[i] = Lib_SegmentedToVirtual(sEmblemAnimatedMats[i]); + } + sAnimatedMaterialsDesgmented = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ACB58.s") + this->actor.colChkInfo.mass = 250; + this->baseHeight = this->actor.world.pos.y; + // params: [this->actor.shape.rot.x] is used to set aggro distance + this->aggroDistance = (GET_FAMOS_AGGRO_DISTANCE(thisx) <= 0) ? (200.0f) : (this->actor.shape.rot.x * 40.0f * 0.1f); + this->actor.shape.rot.x = 0; + this->actor.world.rot.x = 0; + this->hasFinishedRotating = true; + this->isCalm = true; + if (this->pathPoints != NULL) { + EnFamos_SetupPathingIdle(this); + } else { + EnFamos_SetupStillIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ACD2C.s") +void EnFamos_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFamos* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ACF1C.s") + Collider_DestroyCylinder(globalCtx, &this->collider1); + Collider_DestroyCylinder(globalCtx, &this->collider2); + Collider_DestroyJntSph(globalCtx, &this->emblemCollider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ACF98.s") +/** + * Sets 20 rocks to draw from an explosion on the ground (slam attack). + */ +void EnFamos_SetupAttackDebris(EnFamos* this) { + EnFamosRock* rock; + f32 randFloat; + s16 randOffset; + s16 randVelDirection; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD05C.s") + this->debrisTimer = 40; + rock = &this->rocks[0]; + for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { + randVelDirection = Rand_Next() >> 0x10; + randOffset = Rand_S16Offset(0x1800, 0x2800); + randFloat = Rand_ZeroFloat(5.0f) + 5.0f; + rock->velocity.x = randFloat * Math_CosS(randOffset) * Math_SinS(randVelDirection); + rock->velocity.y = Math_SinS(randOffset) * randFloat + 3.0f; + rock->velocity.z = randFloat * Math_CosS(randOffset) * Math_CosS(randVelDirection); + rock->rotation.x = Rand_Next() >> 0x10; + rock->rotation.y = Rand_Next() >> 0x10; + rock->rotation.z = Rand_Next() >> 0x10; + rock->pos.x = (Math_SinS(randVelDirection) * 20.0f) + this->actor.world.pos.x; + rock->pos.y = this->actor.floorHeight; + rock->pos.z = (Math_CosS(randVelDirection) * 20.0f) + this->actor.world.pos.z; + rock->scale = Rand_ZeroFloat(0.0015f) + (2.0f * 0.001f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD170.s") +/** + * Sets 20 rocks to draw from an explosion on death. + */ +void EnFamos_SetupDeathDebris(EnFamos* this) { + f32 randFloat; + s16 randSmaller; + s16 randVelDirection; + EnFamosRock* rock; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD18C.s") + this->debrisTimer = 40; + rock = &this->rocks[0]; + for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { + randVelDirection = Rand_Next() >> 0x10; + randSmaller = (u32)Rand_Next() >> 0x12; + randFloat = Rand_ZeroFloat(6.0f) + 7.0f; + rock->velocity.x = randFloat * Math_CosS(randSmaller) * Math_SinS(randVelDirection); + rock->velocity.y = Math_SinS(randSmaller) * randFloat + 4.5f; + rock->velocity.z = randFloat * Math_CosS(randSmaller) * Math_CosS(randVelDirection); + rock->rotation.x = Rand_Next() >> 0x10; + rock->rotation.y = Rand_Next() >> 0x10; + rock->rotation.z = Rand_Next() >> 0x10; + rock->pos.x = Math_SinS(randVelDirection) * 20.0f + this->actor.world.pos.x; + rock->pos.y = randPlusMinusPoint5Scaled(60.0f) + (this->actor.world.pos.y + 40.0f); + rock->pos.z = Math_CosS(randVelDirection) * 20.0f + this->actor.world.pos.z; + rock->scale = Rand_ZeroFloat(0.002f) + (2.5f * 0.001f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD1F0.s") +s32 EnFamos_IsPlayerSeen(EnFamos* this, GlobalContext* globalCtx) { + if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && + (Actor_XZDistanceToPoint(&GET_PLAYER(globalCtx)->actor, &this->calmPos) < this->aggroDistance) && + Actor_IsFacingPlayer(&this->actor, 0x5000)) { + return true; + } else { + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD294.s") +void EnFamos_UpdateBobbingHeight(EnFamos* this) { + if (this->hoverTimer == 0) { + this->hoverTimer = 30; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD31C.s") + this->hoverTimer--; + this->actor.world.pos.y = (Math_SinS(this->hoverTimer * 0x888) * 10.0f) + this->baseHeight; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD378.s") + if (ABS_ALT(this->flipRot) > 0x4000) { // is famos upside down + func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT_REVERSE - SFX_FLAG); + } else { + func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT - SFX_FLAG); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD3E8.s") +/** + * Checks if emblem has been hit with light arrow. + * Also checks if previously flipped; handles flip status. + */ +void EnFamos_UpdateFlipStatus(EnFamos* this) { + u8 hasFinishedRotating; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD42C.s") + if (this->emblemCollider.base.acFlags & AC_HIT) { // light arrow collision, flip + this->emblemCollider.base.acFlags &= ~AC_HIT; + if (this->hasFinishedRotating == true) { + if (this->animatedMaterialIndex != FAMOS_ANIMATED_MAT_NORMAL) { + this->animatedMaterialIndex = FAMOS_ANIMATED_MAT_NORMAL; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FAMOS_REVERSE2); + } else { + this->animatedMaterialIndex = FAMOS_ANIMATED_MAT_FLIPPED; + this->flippedTimer = 100; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FAMOS_REVERSE1); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DAMAGE); + } + this->hasFinishedRotating = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD54C.s") + } else if (this->flippedTimer > 0) { + this->flippedTimer--; + if (this->flippedTimer == 0) { + if (this->animatedMaterialIndex != FAMOS_ANIMATED_MAT_NORMAL) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FAMOS_REVERSE2); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD5B0.s") + this->animatedMaterialIndex = FAMOS_ANIMATED_MAT_NORMAL; + this->hasFinishedRotating = false; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD66C.s") + if (this->hasFinishedRotating == false) { + if (this->animatedMaterialIndex != FAMOS_ANIMATED_MAT_NORMAL) { + hasFinishedRotating = Math_ScaledStepToS(&this->flipRot, -0x8000, 0x1000); + } else { + hasFinishedRotating = Math_ScaledStepToS(&this->flipRot, 0, 0x1000); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD68C.s") + this->hasFinishedRotating = hasFinishedRotating; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD7EC.s") +/** + * If Famos path is 0xFF, famos hovers stationary in the air + * facing forward, only bobbing up and down, without a path to follow. + */ +void EnFamos_SetupStillIdle(EnFamos* this) { + this->actionFunc = EnFamos_StillIdle; + this->actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD840.s") +void EnFamos_StillIdle(EnFamos* this, GlobalContext* globalCtx) { + EnFamos_UpdateBobbingHeight(this); + if (this->isCalm) { + Math_Vec3f_Copy(&this->calmPos, &this->actor.world.pos); + } + if (EnFamos_IsPlayerSeen(this, globalCtx)) { + EnFamos_SetupAlert(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD888.s") +/** + * Regular Famos follows a path until seeing the player. + */ +void EnFamos_SetupPathingIdle(EnFamos* this) { + if (this->isCalm) { + this->currentPathNode++; + if (this->currentPathNode == this->pathNodeCount) { + this->currentPathNode = 0; + } + } else { + this->isCalm = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AD8B8.s") + Math_Vec3s_ToVec3f(&this->targetDest, &this->pathPoints[this->currentPathNode]); + this->targetYaw = Actor_YawToPoint(&this->actor, &this->targetDest); + this->actionFunc = EnFamos_PathingIdle; + this->actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADA74.s") +void EnFamos_PathingIdle(EnFamos* this, GlobalContext* globalCtx) { + EnFamos_UpdateBobbingHeight(this); + if (this->isCalm) { + Math_Vec3f_Copy(&this->calmPos, &this->actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADAE8.s") + if (EnFamos_IsPlayerSeen(this, globalCtx)) { + EnFamos_SetupAlert(this); + } else if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->targetYaw, 0x200)) { + EnFamos_SetupReturnHome(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADB4C.s") +/** + * Famos lost player; Turning to face back toward home. + */ +void EnFamos_SetupTurnHome(EnFamos* this) { + this->targetYaw = Actor_YawToPoint(&this->actor, &this->calmPos); + Math_Vec3f_Copy(&this->targetDest, &this->calmPos); + this->actionFunc = EnFamos_TurnHome; + this->actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADB70.s") +void EnFamos_TurnHome(EnFamos* this, GlobalContext* globalCtx) { + EnFamos_UpdateBobbingHeight(this); + if (EnFamos_IsPlayerSeen(this, globalCtx)) { + EnFamos_SetupAlert(this); + } else if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->targetYaw, 0x200)) { + EnFamos_SetupReturnHome(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADC40.s") +/** + * Famos has finished rotating toward home; Take off flying in straight line. + */ +void EnFamos_SetupReturnHome(EnFamos* this) { + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.x = -Actor_PitchToPoint(&this->actor, &this->targetDest); + this->actionFunc = EnFamos_ReturnHome; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADC64.s") +void EnFamos_ReturnHome(EnFamos* this, GlobalContext* globalCtx) { + f32 distanceToHome = Actor_XZDistanceToPoint(&this->actor, &this->targetDest); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADD20.s") + this->actor.shape.rot.y = Actor_YawToPoint(&this->actor, &this->targetDest); + this->actor.world.rot.y = this->actor.shape.rot.y; + EnFamos_UpdateBobbingHeight(this); + if (this->isCalm) { + Math_Vec3f_Copy(&this->calmPos, &this->actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADDA8.s") + if (EnFamos_IsPlayerSeen(this, globalCtx)) { + EnFamos_SetupAlert(this); + } else if (distanceToHome < 20.0f) { + if (this->pathPoints != NULL) { + EnFamos_SetupPathingIdle(this); + } else { + EnFamos_SetupStillIdle(this); + } + } else if (distanceToHome < 40.0f) { + Math_StepToF(&this->actor.speedXZ, 0.5f, 0.3f); + } else { + Math_StepToF(&this->actor.speedXZ, 3.0f, 0.3f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADE00.s") +/** + * Famos has spotted the player; delayed by surprise. + */ +void EnFamos_SetupAlert(EnFamos* this) { + this->actor.world.rot.y = this->actor.shape.rot.y; + this->stateTimer = 8; + this->actor.speedXZ = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADE74.s") + if (this->isCalm == true) { + this->isCalm = false; + Math_Vec3f_Copy(&this->calmPos, &this->actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADFA4.s") + this->actionFunc = EnFamos_Alert; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808ADFF0.s") +void EnFamos_Alert(EnFamos* this, GlobalContext* globalCtx) { + if (ABS_ALT(this->flipRot) > 0x4000) { + func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT_REVERSE - SFX_FLAG); + } else { + func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT - SFX_FLAG); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AE030.s") + this->stateTimer--; + if (this->stateTimer == 0) { + this->actor.world.pos.y = this->baseHeight; + EnFamos_SetupChase(this); + } else { + this->actor.world.pos.y = Math_SinS(this->stateTimer * 0x1000) * 30.0f + this->baseHeight; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/EnFamos_Update.s") +/** + * Famos has spotted the player; Begin chasing to attack. + */ +void EnFamos_SetupChase(EnFamos* this) { + this->hoverTimer = 0; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnFamos_Chase; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AE304.s") +void EnFamos_Chase(EnFamos* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f abovePlayerPos; + u32 surfaceType; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AE3A8.s") + EnFamos_UpdateBobbingHeight(this); + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x800); + this->actor.world.rot.y = this->actor.shape.rot.y; + abovePlayerPos.x = player->actor.world.pos.x; + abovePlayerPos.y = player->actor.world.pos.y + 100.0f; + abovePlayerPos.z = player->actor.world.pos.z; + this->actor.world.rot.x = -Actor_PitchToPoint(&this->actor, &abovePlayerPos); + Math_StepToF(&this->actor.speedXZ, 6.0f, 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/func_808AE3FC.s") + surfaceType = func_800C9B18(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + if ((this->actor.xzDistToPlayer < 30.0f) && (this->actor.floorHeight > BGCHECK_Y_MIN) && // close enough + (surfaceType != 0xC && surfaceType != 0xD)) { + EnFamos_SetupAttackAim(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Famos/EnFamos_Draw.s") + } else if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || + (this->aggroDistance < Actor_XZDistanceToPoint(&GET_PLAYER(globalCtx)->actor, &this->calmPos)) || + !Actor_IsFacingPlayer(&this->actor, 0x6000)) { + EnFamos_SetupScanForPlayer(this); + } +} + +void EnFamos_SetupAttackAim(EnFamos* this) { + Animation_PlayOnce(&this->skelAnime, &gFamosShakeAnim); + this->actor.speedXZ = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_VOICE); + this->actionFunc = EnFamos_AttackAim; +} + +void EnFamos_AttackAim(EnFamos* this, GlobalContext* globalCtx) { + func_800B9010(&this->actor, NA_SE_EN_LAST1_FALL_OLD - SFX_FLAG); + if (SkelAnime_Update(&this->skelAnime)) { + EnFamos_SetupAttack(this); + } +} + +void EnFamos_SetupAttack(EnFamos* this) { + this->actor.world.rot.x = -0x4000; + this->collider1.base.atFlags |= AT_ON; + this->stateTimer = 4; + this->actionFunc = EnFamos_Attack; +} + +void EnFamos_Attack(EnFamos* this, GlobalContext* globalCtx) { + s32 hitFloor; + u32 surfaceType; + + Math_StepToF(&this->actor.speedXZ, 20.0f, 2.0f); + this->stateTimer--; + if (this->stateTimer == 0) { + this->emblemCollider.base.acFlags &= ~AC_ON; + } + + surfaceType = func_800C9B18(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + hitFloor = this->actor.bgCheckFlags & 1; + if (hitFloor || (this->actor.floorHeight == BGCHECK_Y_MIN) || (surfaceType == 0xC) || (surfaceType == 0xD)) { + this->collider1.base.atFlags &= ~AT_ON; + this->collider2.base.atFlags |= AT_ON; + if (hitFloor) { + func_800DFD04(globalCtx->cameraPtrs[globalCtx->activeCamera], 2, 15, 10); // camera shake? + func_8013ECE0(this->actor.xyzDistToPlayerSq, 180, 20, 100); + EnFamos_SetupAttackDebris(this); + + // spawn crator on floor + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TEST, this->actor.world.pos.x, + this->actor.floorHeight, this->actor.world.pos.z, 0, 0, 0, 0x0); + + if (this->actor.child != NULL) { + Actor_SetScale(this->actor.child, 0.015f); + } + + if (this->animatedMaterialIndex != FAMOS_ANIMATED_MAT_NORMAL) { + this->cratorDespawnTimer = 70; + EnFamos_SetupDeathSlam(this); + } else { + this->cratorDespawnTimer = 20; + EnFamos_SetupFinishAttack(this); + } + } else { + this->emblemCollider.base.acFlags |= AC_ON; + EnFamos_SetupAttackRebound(this); + } + } else { + func_800B9010(&this->actor, NA_SE_EN_LAST1_FALL_OLD - SFX_FLAG); + } +} + +/** + * Attack has hit; Wait for animation to finish before recovering from attack. + */ +void EnFamos_SetupFinishAttack(EnFamos* this) { + Animation_PlayOnce(&this->skelAnime, &gFamosIdleAnim); + SkelAnime_Update(&this->skelAnime); + this->emblemCollider.base.acFlags |= AC_ON; + this->stateTimer = 3; + this->actor.speedXZ = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_EXPLOSION); + this->actionFunc = EnFamos_FinishAttack; +} + +void EnFamos_FinishAttack(EnFamos* this, GlobalContext* globalCtx) { + if (this->stateTimer == 0) { + this->collider2.base.atFlags &= ~AT_ON; + } + + this->stateTimer--; + if (SkelAnime_Update(&this->skelAnime)) { + EnFamos_SetupAttackRebound(this); + } +} + +void EnFamos_SetupAttackRebound(EnFamos* this) { + this->actor.world.rot.x = 0x4000; + this->actionFunc = EnFamos_AttackRebound; + this->actor.speedXZ = 0.0f; +} + +void EnFamos_AttackRebound(EnFamos* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 5.0f, 0.3f); + if (this->actor.speedXZ > 1.0f) { + if (ABS_ALT(this->flipRot) > 0x4000) { + func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT_REVERSE - SFX_FLAG); + } else { + func_800B9010(&this->actor, NA_SE_EN_FAMOS_FLOAT - SFX_FLAG); + } + } + + if ((this->baseHeight < this->actor.world.pos.y) || (this->actor.bgCheckFlags & 0x10)) { // touching ceiling + this->actor.speedXZ = 0.0f; + EnFamos_SetupChase(this); + } +} + +/** + * Looking around for player. + */ +void EnFamos_SetupScanForPlayer(EnFamos* this) { + this->stateTimer = 60; + this->actionFunc = EnFamos_ScanForPlayer; + this->actor.speedXZ = 0.0f; +} + +void EnFamos_ScanForPlayer(EnFamos* this, GlobalContext* globalCtx) { + EnFamos_UpdateBobbingHeight(this); + this->stateTimer--; + + if (EnFamos_IsPlayerSeen(this, globalCtx)) { + EnFamos_SetupAlert(this); + } else if (this->stateTimer == 0) { + EnFamos_SetupTurnHome(this); + } else { + this->actor.shape.rot.y = (s32)(Math_SinS(this->stateTimer * 0x888) * 8192.0f) + this->actor.world.rot.y; + } +} + +/** + * Famos was upside down and hit the ground headfirst. This kills the Famos. + */ +void EnFamos_SetupDeathSlam(EnFamos* this) { + this->emblemCollider.base.acFlags &= ~AC_ON; + this->stateTimer = 20; + this->actor.speedXZ = 0.0f; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->flippedTimer = -1; + this->actor.world.pos.y = this->actor.floorHeight - 60.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DEAD); + this->actionFunc = EnFamos_DeathSlam; +} + +void EnFamos_DeathSlam(EnFamos* this, GlobalContext* globalCtx) { + if (this->stateTimer == 17) { + this->collider2.base.atFlags &= ~AT_ON; + } + + if (this->stateTimer == 0) { + EnFamos_SetupDeathExplosion(this); + } else { + this->stateTimer--; + } +} + +void EnFamos_SetupDeathExplosion(EnFamos* this) { + this->actor.world.rot.x = 0x4000; + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, false, 4); + this->stateTimer = 25; + Math_Vec3f_Copy(&this->targetDest, &this->actor.world.pos); + this->actor.flags |= ACTOR_FLAG_10; + this->actionFunc = EnFamos_DeathExplosion; +} + +void EnFamos_DeathExplosion(EnFamos* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 3.0f, 0.3f); + if (this->actor.colorFilterTimer == 0) { + Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, false, 4); + } + + this->actor.world.pos.x = randPlusMinusPoint5Scaled(5.0f) + this->targetDest.x; + this->actor.world.pos.z = randPlusMinusPoint5Scaled(5.0f) + this->targetDest.z; + if (this->stateTimer == 1) { + EnBom* explosion = + (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, 0, 0, 0, ENBOM_0); + if (explosion != NULL) { + explosion->timer = 0; // instant explosion + } + this->stateTimer--; + + } else if (this->stateTimer == 0) { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, + (0xD << 4)); // random item from droptable 0xD + EnFamos_SetupDeathFade(this); + + } else { + this->stateTimer--; + } +} + +void EnFamos_SetupDeathFade(EnFamos* this) { + EnFamos_SetupDeathDebris(this); + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.shape.shadowDraw = NULL; + this->actionFunc = EnFamos_DeathFade; + this->actor.speedXZ = 0.0f; +} + +void EnFamos_DeathFade(EnFamos* this, GlobalContext* globalCtx) { + Actor* enBom; + + if (this->debrisTimer == 0) { + enBom = this->actor.child; + if (enBom != NULL) { + enBom->parent = NULL; + } + Actor_MarkForDeath(&this->actor); + } +} + +void EnFamos_UpdateDebrisPosRot(EnFamos* this) { + EnFamosRock* rock; + s32 i; + + rock = &this->rocks[0]; + for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { + rock->velocity.y -= 1.0f; + Math_Vec3f_Sum(&rock->pos, &rock->velocity, &rock->pos); + // all casts seem required + rock->rotation.x += (s16)(((u32)Rand_Next() >> 0x17) + 0x700); + rock->rotation.y += (s16)(((u32)Rand_Next() >> 0x17) + 0x900); + rock->rotation.z += (s16)(((u32)Rand_Next() >> 0x17) + 0xB00); + } +} + +void EnFamos_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFamos* this = THIS; + f32 oldHeight; + s32 oldHoverTimer; // save old value to test if changed + + if (this->debrisTimer <= 0 || + (this->debrisTimer--, EnFamos_UpdateDebrisPosRot(this), (this->actionFunc != EnFamos_DeathFade))) { + oldHoverTimer = this->hoverTimer; + EnFamos_UpdateFlipStatus(this); + if (this->cratorDespawnTimer > 0) { + this->cratorDespawnTimer--; + if (this->cratorDespawnTimer == 0) { + this->actor.child->parent = NULL; // child is EnTest (Crator after stomp) + } + } + + this->actionFunc(this, globalCtx); + oldHeight = this->actor.world.pos.y; + Actor_MoveWithoutGravity(&this->actor); + if (oldHoverTimer != this->hoverTimer) { // test if updated in actionFunc + this->baseHeight += this->actor.world.pos.y - oldHeight; + } + + if (this->flippedTimer >= 0) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 35.0f, 30.0f, 80.0f, 0x1F); + if ((this->actionFunc == EnFamos_Attack) && (this->animatedMaterialIndex != FAMOS_ANIMATED_MAT_NORMAL) && + (this->actor.bgCheckFlags & 1)) { // touch floor + this->actor.world.pos.y -= 60.0f; + } + } + + this->actor.focus.rot.y = this->actor.shape.rot.y; + Collider_UpdateCylinder(&this->actor, &this->collider1); + if (this->collider1.base.atFlags & AT_ON) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + if (this->emblemCollider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->emblemCollider.base); + } + + if (this->collider2.base.atFlags & AC_ON) { + Collider_UpdateCylinder(&this->actor, &this->collider2); + this->collider2.dim.pos.y = this->actor.floorHeight; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } + } +} + +s32 EnFamos_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnFamos* this = THIS; + + if (limbIndex == FAMOS_LIMB_BODY) { + Matrix_InsertTranslation(0.0f, 4000.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->flipRot, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -4000.0f, 0.0f, MTXMODE_APPLY); + + } else if (this->flippedTimer < 0) { // if set to -1, famos is dying + if ((limbIndex == FAMOS_LIMB_SWORD) || (limbIndex == FAMOS_LIMB_SHIELD) || (limbIndex == FAMOS_LIMB_HEAD)) { + *dList = NULL; + } + } + + return false; +} + +void EnFamos_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnFamos* this = THIS; + + if (limbIndex == FAMOS_LIMB_EMBLEM) { + Matrix_GetStateTranslation(&this->actor.focus.pos); + Collider_UpdateSpheres(limbIndex, &this->emblemCollider); + } +} + +void EnFamos_DrawDebris(EnFamos* this, GlobalContext* globalCtx) { + s32 i; + + if (this->debrisTimer > 0) { + Gfx* dispOpa; + EnFamosRock* rock; + + OPEN_DISPS(globalCtx->state.gfxCtx); + dispOpa = POLY_OPA_DISP; + + gSPDisplayList(&dispOpa[0], &sSetupDL[6 * 0x19]); + + gDPSetPrimColor(&dispOpa[1], 0, 0x80, 255, 255, 255, 255); + + gDPSetEnvColor(&dispOpa[2], 255, 255, 255, 255); + + rock = &this->rocks[0]; + for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { + + Matrix_SetStateRotationAndTranslation(rock->pos.x, rock->pos.y, rock->pos.z, &rock->rotation); + Matrix_Scale(rock->scale, rock->scale, rock->scale, MTXMODE_APPLY); + + gSPMatrix(&dispOpa[3 + i * 2], Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(&dispOpa[4 + i * 2], &gameplay_keep_DL_06AB30); // greenish brown rock DL + } + + POLY_OPA_DISP = &dispOpa[3 + (ARRAY_COUNT(this->rocks) * 2)]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnFamos_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnFamos* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + if (this->actionFunc != EnFamos_DeathFade) { + AnimatedMat_Draw(globalCtx, sEmblemAnimatedMats[this->animatedMaterialIndex]); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnFamos_OverrideLimbDraw, + EnFamos_PostLimbDraw, &this->actor); + if (this->actor.colorFilterTimer != 0) { + func_800AE5A0(globalCtx); + } + } + EnFamos_DrawDebris(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Famos/z_en_famos.h b/src/overlays/actors/ovl_En_Famos/z_en_famos.h index c38e87e7d..a3db181e6 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.h +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.h @@ -2,18 +2,58 @@ #define Z_EN_FAMOS_H #include "global.h" +#include "objects/object_famos/object_famos.h" struct EnFamos; typedef void (*EnFamosActionFunc)(struct EnFamos*, GlobalContext*); +typedef struct EnFamosRock { + /* 00 */ Vec3f pos; + /* 0C */ Vec3f velocity; + /* 18 */ Vec3s rotation; + /* 20 */ f32 scale; +} EnFamosRock; // size = 0x24 + +#define GET_FAMOS_PATH(thisx) (thisx->params) +#define GET_FAMOS_AGGRO_DISTANCE(thisx) (thisx->shape.rot.x) + +// stateTimer gets reused: +// after spotting player, counts frames until first attack (8) +// after lost aggro, measures frames looking around before returning to home (60) +// before smash attack, counts frames before disabling emblem colider (4) +// after smash attack collision, counts frames before rising (3) +// after smash attack finish, counts frames rising above ground before next attempt (20) + typedef struct EnFamos { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x8C]; - /* 0x01D0 */ EnFamosActionFunc actionFunc; - /* 0x01D4 */ char unk_1D4[0x440]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[FAMOS_LIMB_MAX]; + /* 0x1AC */ Vec3s morphTable[FAMOS_LIMB_MAX]; + /* 0x1D0 */ EnFamosActionFunc actionFunc; + /* 0x1D4 */ u8 animatedMaterialIndex; + /* 0x1D5 */ u8 hasFinishedRotating; // stable up or down + /* 0x1D6 */ u8 pathNodeCount; + /* 0x1D7 */ u8 currentPathNode; + /* 0x1D8 */ u8 isCalm; // is NOT aware of player + /* 0x1DA */ s16 hoverTimer; // start 30, decr to 0, repeat: for trig height adjustment when hovering + /* 0x1DC */ s16 stateTimer; // reused for different actionFunc + /* 0x1DE */ s16 debrisTimer; // also counts frames until despawning bom after death + /* 0x1E0 */ s16 flippedTimer; // frames until it flips right side up + /* 0x1E2 */ s16 cratorDespawnTimer; + /* 0x1E4 */ s16 targetYaw; + /* 0x1E6 */ s16 flipRot; // is used to detect if the actor has been flipped upside down by light arrows + /* 0x1E8 */ Vec3s* pathPoints; + /* 0x1EC */ f32 baseHeight; // because hover can hit the floor, we need to keep track so famos cannot by adjusted/moved by terain + /* 0x1F0 */ f32 aggroDistance; + /* 0x1F4 */ Vec3f targetDest; + /* 0x200 */ Vec3f calmPos; + // havent figured out what the difference between the colliders are, only one cylinder is visible in KZ + /* 0x20C */ ColliderCylinder collider1; + /* 0x258 */ ColliderCylinder collider2; + /* 0x2A4 */ ColliderJntSph emblemCollider; + /* 0x2C4 */ ColliderJntSphElement emblemColliderElements[2]; + /* 0x344 */ EnFamosRock rocks[20]; } EnFamos; // size = 0x614 -extern const ActorInit En_Famos_InitVars; - #endif // Z_EN_FAMOS_H diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 86758415a..c4f1a053b 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -5821,44 +5821,44 @@ 0x808ABF30:("EnOssan_PartTimeWorker_Draw",), 0x808AC920:("EnFamos_Init",), 0x808ACB08:("EnFamos_Destroy",), - 0x808ACB58:("func_808ACB58",), - 0x808ACD2C:("func_808ACD2C",), - 0x808ACF1C:("func_808ACF1C",), - 0x808ACF98:("func_808ACF98",), - 0x808AD05C:("func_808AD05C",), - 0x808AD170:("func_808AD170",), - 0x808AD18C:("func_808AD18C",), - 0x808AD1F0:("func_808AD1F0",), - 0x808AD294:("func_808AD294",), - 0x808AD31C:("func_808AD31C",), - 0x808AD378:("func_808AD378",), - 0x808AD3E8:("func_808AD3E8",), - 0x808AD42C:("func_808AD42C",), - 0x808AD54C:("func_808AD54C",), - 0x808AD5B0:("func_808AD5B0",), - 0x808AD66C:("func_808AD66C",), - 0x808AD68C:("func_808AD68C",), - 0x808AD7EC:("func_808AD7EC",), - 0x808AD840:("func_808AD840",), - 0x808AD888:("func_808AD888",), - 0x808AD8B8:("func_808AD8B8",), - 0x808ADA74:("func_808ADA74",), - 0x808ADAE8:("func_808ADAE8",), - 0x808ADB4C:("func_808ADB4C",), - 0x808ADB70:("func_808ADB70",), - 0x808ADC40:("func_808ADC40",), - 0x808ADC64:("func_808ADC64",), - 0x808ADD20:("func_808ADD20",), - 0x808ADDA8:("func_808ADDA8",), - 0x808ADE00:("func_808ADE00",), - 0x808ADE74:("func_808ADE74",), - 0x808ADFA4:("func_808ADFA4",), - 0x808ADFF0:("func_808ADFF0",), - 0x808AE030:("func_808AE030",), + 0x808ACB58:("EnFamos_SetupAttackDebris",), + 0x808ACD2C:("EnFamos_SetupDeathDebris",), + 0x808ACF1C:("EnFamos_IsPlayerSeen",), + 0x808ACF98:("EnFamos_UpdateBobbingHeight",), + 0x808AD05C:("EnFamos_UpdateFlipStatus",), + 0x808AD170:("EnFamos_SetupStillIdle",), + 0x808AD18C:("EnFamos_StillIdle",), + 0x808AD1F0:("EnFamos_SetupPathingIdle",), + 0x808AD294:("EnFamos_PathingIdle",), + 0x808AD31C:("EnFamos_SetupTurnHome",), + 0x808AD378:("EnFamos_TurnHome",), + 0x808AD3E8:("EnFamos_SetupReturnHome",), + 0x808AD42C:("EnFamos_ReturnHome",), + 0x808AD54C:("EnFamos_SetupAlert",), + 0x808AD5B0:("EnFamos_Alert",), + 0x808AD66C:("EnFamos_SetupChase",), + 0x808AD68C:("EnFamos_Chase",), + 0x808AD7EC:("EnFamos_SetupAttackAim",), + 0x808AD840:("EnFamos_AttackAim",), + 0x808AD888:("EnFamos_SetupAttack",), + 0x808AD8B8:("EnFamos_Attack",), + 0x808ADA74:("EnFamos_SetupFinishAttack",), + 0x808ADAE8:("EnFamos_FinishAttack",), + 0x808ADB4C:("EnFamos_SetupAttackRebound",), + 0x808ADB70:("EnFamos_AttackRebound",), + 0x808ADC40:("EnFamos_SetupScanForPlayer",), + 0x808ADC64:("EnFamos_ScanForPlayer",), + 0x808ADD20:("EnFamos_SetupDeathSlam",), + 0x808ADDA8:("EnFamos_DeathSlam",), + 0x808ADE00:("EnFamos_SetupDeathExplosion",), + 0x808ADE74:("EnFamos_DeathExplosion",), + 0x808ADFA4:("EnFamos_SetupDeathFade",), + 0x808ADFF0:("EnFamos_DeathFade",), + 0x808AE030:("EnFamos_UpdateDebrisPosRot",), 0x808AE0EC:("EnFamos_Update",), - 0x808AE304:("func_808AE304",), - 0x808AE3A8:("func_808AE3A8",), - 0x808AE3FC:("func_808AE3FC",), + 0x808AE304:("EnFamos_OverrideLimbDraw",), + 0x808AE3A8:("EnFamos_PostLimbDraw",), + 0x808AE3FC:("EnFamos_DrawDebris",), 0x808AE530:("EnFamos_Draw",), 0x808AE8C0:("EnBombf_SetupAction",), 0x808AE8CC:("EnBombf_Init",), From f1d1d8320675469e241bc5ee374af905e42a24bd Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 25 May 2022 19:15:28 -0700 Subject: [PATCH 221/257] Makefile Changes (#727) * Change makefile so rom doesn't need to match by default for compression, also change JenkinsFile to split off compression step from building * Swap uncompressed and compressed in all target * Forgot to change check warnings stage name * Intentionally produce non_matching * Fix * Add assets target * Jenkins assets * Update update_current_warnings * .make_options config file * Change comment at top * Add toggle options for CC_CHECK and OBJDUMP * Small cleanup * Whitespace * More * bin dumping * Whitespace * Review * Fix comment --- .gitignore | 1 + Jenkinsfile | 22 ++++++- Makefile | 66 +++++++++++++------ .../warnings_count/update_current_warnings.sh | 4 +- .../warnings_assets_current.txt | 0 .../warnings_compress_current.txt | 0 6 files changed, 71 insertions(+), 22 deletions(-) create mode 100644 tools/warnings_count/warnings_assets_current.txt create mode 100644 tools/warnings_count/warnings_compress_current.txt diff --git a/.gitignore b/.gitignore index 80fe09807..aa3f65077 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,4 @@ docs/doxygen/ # Per-user configuration .python-version +.make_options diff --git a/Jenkinsfile b/Jenkinsfile index 3ebfd3614..fb60f0aca 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -36,6 +36,16 @@ pipeline { sh 'bash -c "./tools/warnings_count/compare_warnings.sh setup"' } } + stage('Assets') { + steps { + sh 'bash -c "make -j assets 2> >(tee tools/warnings_count/warnings_assets_new.txt)"' + } + } + stage('Check assets warnings') { + steps { + sh 'bash -c "./tools/warnings_count/compare_warnings.sh assets"' + } + } stage('Disasm') { steps { sh 'bash -c "make -j disasm 2> >(tee tools/warnings_count/warnings_disasm_new.txt)"' @@ -48,7 +58,7 @@ pipeline { } stage('Build') { steps { - sh 'bash -c "make -j all 2> >(tee tools/warnings_count/warnings_build_new.txt)"' + sh 'bash -c "make -j uncompressed 2> >(tee tools/warnings_count/warnings_build_new.txt)"' } } stage('Check build warnings') { @@ -56,6 +66,16 @@ pipeline { sh 'bash -c "./tools/warnings_count/compare_warnings.sh build"' } } + stage('Compress') { + steps { + sh 'bash -c "make -j compressed 2> >(tee tools/warnings_count/warnings_compress_new.txt)"' + } + } + stage('Check compress warnings') { + steps { + sh 'bash -c "./tools/warnings_count/compare_warnings.sh compress"' + } + } stage('Report Progress') { when { branch 'master' diff --git a/Makefile b/Makefile index ac7174e89..f33f60848 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,11 @@ +# Build options can be changed by modifying the makefile or by building with 'make SETTING=value'. +# It is also possible to override the settings in Defaults in a file called .make_options as 'SETTING=value'. + +-include .make_options + MAKEFLAGS += --no-builtin-rules -# Build options can either be changed by modifying the makefile, or by building with 'make SETTING=value' +#### Defaults #### # If COMPARE is 1, check the output md5sum after building COMPARE ?= 1 @@ -14,6 +19,14 @@ WERROR ?= 0 KEEP_MDEBUG ?= 0 # Disassembles all asm from the ROM instead of skipping files which are entirely in C FULL_DISASM ?= 0 +# Check code syntax with host compiler +RUN_CC_CHECK ?= 1 +# Dump build object files +OBJDUMP_BUILD ?= 0 +# Number of threads to disassmble, extract, and compress with +N_THREADS ?= $(shell nproc) + +#### Setup #### ifeq ($(NON_MATCHING),1) CFLAGS := -DNON_MATCHING @@ -45,9 +58,8 @@ else endif endif -N_THREADS ?= $(shell nproc) - #### Tools #### + ifeq ($(shell type mips-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0) MIPS_BINUTILS_PREFIX := mips-linux-gnu- else @@ -86,8 +98,15 @@ else endif # Check code syntax with host compiler -CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable -Wno-missing-braces -Wno-int-conversion -Wno-unused-but-set-variable -Wno-unused-label -CC_CHECK := gcc -fno-builtin -fsyntax-only -funsigned-char -fdiagnostics-color -std=gnu89 -D _LANGUAGE_C -D NON_MATCHING $(IINC) -nostdinc $(CHECK_WARNINGS) +ifneq ($(RUN_CC_CHECK),0) + CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable -Wno-missing-braces -Wno-int-conversion -Wno-unused-but-set-variable -Wno-unused-label + CC_CHECK := gcc -fno-builtin -fsyntax-only -funsigned-char -fdiagnostics-color -std=gnu89 -D _LANGUAGE_C -D NON_MATCHING $(IINC) -nostdinc $(CHECK_WARNINGS) + ifneq ($(WERROR), 0) + CC_CHECK += -Werror + endif +else + CC_CHECK := @: +endif CPP := cpp ELF2ROM := tools/buildtools/elf2rom @@ -103,12 +122,20 @@ MIPS_VERSION := -mips2 CFLAGS += -G 0 -non_shared -fullwarn -verbose -Xcpluscomm $(IINC) -nostdinc -Wab,-r4300_mul -woff 624,649,838,712,516 # Use relocations and abi fpr names in the dump -OBJDUMP_FLAGS := -d -r -z -Mreg-names=32 +OBJDUMP_FLAGS := --disassemble --reloc --disassemble-zeroes -Mreg-names=32 + +ifneq ($(OBJDUMP_BUILD), 0) + OBJDUMP_CMD = $(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) + OBJCOPY_BIN = $(OBJCOPY) -O binary $@ $@.bin +else + OBJDUMP_CMD = @: + OBJCOPY_BIN = @: +endif ifeq ($(shell getconf LONG_BIT), 32) # Work around memory allocation bug in QEMU export QEMU_GUEST_BASE := 1 -else +else ifneq ($(RUN_CC_CHECK),0) # Ensure that gcc treats the code as 32-bit CC_CHECK += -m32 endif @@ -116,11 +143,7 @@ endif # rom compression flags COMPFLAGS := --threads $(N_THREADS) ifneq ($(NON_MATCHING),1) - COMPFLAGS += --matching -endif - -ifneq ($(WERROR), 0) - CC_CHECK += -Werror + COMPFLAGS += --matching endif #### Files #### @@ -229,14 +252,14 @@ ifeq ($(COMPARE),1) @md5sum -c checksum.md5 endif -.PHONY: all uncompressed compressed clean assetclean distclean disasm init setup +.PHONY: all uncompressed compressed clean assetclean distclean assets disasm init setup .DEFAULT_GOAL := uncompressed -all: compressed +all: uncompressed compressed $(ROM): $(ELF) $(ELF2ROM) -cic 6105 $< $@ -$(ROMC): uncompressed +$(ROMC): $(ROM) python3 tools/z64compress_wrapper.py $(COMPFLAGS) $(ROM) $@ $(ELF) build/$(SPEC) $(ELF): $(TEXTURE_FILES_OUT) $(ASSET_FILES_OUT) $(O_FILES) build/ldscript.txt build/undefined_syms.txt @@ -263,6 +286,8 @@ setup: $(MAKE) -C tools python3 tools/fixbaserom.py python3 tools/extract_baserom.py + +assets: python3 extract_assets.py -j $(N_THREADS) ## Assembly generation @@ -278,6 +303,7 @@ diff-init: uncompressed init: $(MAKE) distclean $(MAKE) setup + $(MAKE) assets $(MAKE) disasm $(MAKE) all $(MAKE) diff-init @@ -296,7 +322,7 @@ build/asm/%.o: asm/%.s build/assets/%.o: assets/%.c $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - $(OBJCOPY) -O binary $@ $@.bin + $(OBJCOPY_BIN) $(RM_MDEBUG) build/baserom/%.o: baserom/% @@ -308,7 +334,7 @@ build/data/%.o: data/%.s build/src/overlays/%.o: src/overlays/%.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) + $(OBJDUMP_CMD) # TODO: `() || true` is currently necessary to suppress `Error 1 (ignored)` make warnings caused by `test`, but this will go away if # the following is moved to a separate rule that is only run once when all the required objects have been compiled. $(ZAPD) bovl -eh -i $@ -cfg $< --outputpath $(@D)/$(notdir $(@D))_reloc.s @@ -318,21 +344,21 @@ build/src/overlays/%.o: src/overlays/%.c build/src/%.o: src/%.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) + $(OBJDUMP_CMD) $(RM_MDEBUG) build/src/libultra/libc/ll.o: src/libultra/libc/ll.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< python3 tools/set_o32abi_bit.py $@ - @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) + $(OBJDUMP_CMD) $(RM_MDEBUG) build/src/libultra/libc/llcvt.o: src/libultra/libc/llcvt.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< python3 tools/set_o32abi_bit.py $@ - @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) + $(OBJDUMP_CMD) $(RM_MDEBUG) # Build C files from assets diff --git a/tools/warnings_count/update_current_warnings.sh b/tools/warnings_count/update_current_warnings.sh index afbc4a423..f2cff34c5 100755 --- a/tools/warnings_count/update_current_warnings.sh +++ b/tools/warnings_count/update_current_warnings.sh @@ -8,5 +8,7 @@ cd "$DIR/../.." make distclean make setup 2> tools/warnings_count/warnings_setup_current.txt +make assets 2> tools/warnings_count/warnings_assets_current.txt make disasm 2> tools/warnings_count/warnings_disasm_current.txt -make all 2> tools/warnings_count/warnings_build_current.txt +make uncompressed 2> tools/warnings_count/warnings_build_current.txt +make compressed 2> tools/warnings_count/warnings_compress_current.txt diff --git a/tools/warnings_count/warnings_assets_current.txt b/tools/warnings_count/warnings_assets_current.txt new file mode 100644 index 000000000..e69de29bb diff --git a/tools/warnings_count/warnings_compress_current.txt b/tools/warnings_count/warnings_compress_current.txt new file mode 100644 index 000000000..e69de29bb From 12b995093fa0b3430669dbbf39321399422d5744 Mon Sep 17 00:00:00 2001 From: Isghj <42048411+isghj5@users.noreply.github.com> Date: Wed, 25 May 2022 19:19:38 -0700 Subject: [PATCH 222/257] `EnNwc` OK and three objects documented (`object_niw` and `object_nwc` and `object_hs`) and some Actor docs( `EnNiw` and `EnAttackNiw` and `EnHg`) (#715) * EnNwc: OK and some Niw Docs * Update src/overlays/actors/ovl_En_Nwc/z_en_nwc.c Co-authored-by: Parker Burnett * Update src/overlays/actors/ovl_En_Nwc/z_en_nwc.c Co-authored-by: Parker Burnett * Update src/overlays/actors/ovl_En_Nwc/z_en_nwc.c Co-authored-by: Parker Burnett * EnNwc: Overwrite->Override * EnAttackNiw: fix merges * AttackNiw and Niw: some docs * formater pass * EnNwc: fixed savecontext change * Niw and Attackniw: more docs * Apply suggestions from code review Co-authored-by: Anghelo Carvajal * Nwc,Niw: requested doc changes * Nwc: extracted and marked broken texture * Apply suggestions from code review Co-authored-by: Derek Hensley * EnNwc: more requested changes * Nwc: more requested changes * Apply suggestions from code review Co-authored-by: Derek Hensley * EnHs: object_hs documented, some ovl_En_Hs docs * EnHs: animation names * EnHs: some text docs * EnHs: fear anim changed to shivering now that we know it was used in OOT * EnHs: more docs and format pass * Apply suggestions from code review Co-authored-by: Derek Hensley * EnHs: more docs and updates to var name changes * Niw,Nwc,Hs: added description to object files * Hs: changed from playerOffset to offset Co-authored-by: Isghj8 Co-authored-by: Parker Burnett Co-authored-by: Anghelo Carvajal Co-authored-by: Derek Hensley --- assets/xml/objects/object_hs.xml | 62 +- assets/xml/objects/object_niw.xml | 66 +- assets/xml/objects/object_nwc.xml | 46 +- include/functions.h | 2 +- spec | 3 +- .../ovl_En_Attack_Niw/z_en_attack_niw.c | 479 +++++++------ .../ovl_En_Attack_Niw/z_en_attack_niw.h | 83 +-- src/overlays/actors/ovl_En_Hs/z_en_hs.c | 168 ++--- src/overlays/actors/ovl_En_Hs/z_en_hs.h | 22 +- src/overlays/actors/ovl_En_Niw/z_en_niw.c | 641 +++++++++--------- src/overlays/actors/ovl_En_Niw/z_en_niw.h | 99 +-- src/overlays/actors/ovl_En_Nwc/z_en_nwc.c | 506 +++++++++++++- src/overlays/actors/ovl_En_Nwc/z_en_nwc.h | 28 +- tools/disasm/functions.txt | 52 +- 14 files changed, 1411 insertions(+), 846 deletions(-) diff --git a/assets/xml/objects/object_hs.xml b/assets/xml/objects/object_hs.xml index 0d36c4ff1..ae025f327 100644 --- a/assets/xml/objects/object_hs.xml +++ b/assets/xml/objects/object_hs.xml @@ -1,8 +1,9 @@  + - - - + + + @@ -13,35 +14,38 @@ - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + diff --git a/assets/xml/objects/object_niw.xml b/assets/xml/objects/object_niw.xml index e49426560..0e533fb6e 100644 --- a/assets/xml/objects/object_niw.xml +++ b/assets/xml/objects/object_niw.xml @@ -1,38 +1,40 @@  + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_nwc.xml b/assets/xml/objects/object_nwc.xml index 77b395b58..8c67159ce 100644 --- a/assets/xml/objects/object_nwc.xml +++ b/assets/xml/objects/object_nwc.xml @@ -1,29 +1,57 @@  + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + diff --git a/include/functions.h b/include/functions.h index e3f700d72..0e12b35a5 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3498,7 +3498,7 @@ void func_801A0238(s32 arg0, s32 arg1); // void func_801A05F0(void); void func_801A0654(Vec3f* arg0, u16 sfxId, s32 arg2); void func_801A0810(Vec3f* arg0, u16 sfxId, u8 arg2); -// void func_801A0868(void); +void func_801A0868(Vec3f* pos, u16 sfxId, u8 val); // void func_801A09D4(void); // void Audio_SplitBgmChannels(void); // void func_801A0E44(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); diff --git a/spec b/spec index a92016e25..5cb8e7123 100644 --- a/spec +++ b/spec @@ -1510,8 +1510,7 @@ beginseg name "ovl_En_Nwc" compress include "build/src/overlays/actors/ovl_En_Nwc/z_en_nwc.o" - include "build/data/ovl_En_Nwc/ovl_En_Nwc.data.o" - include "build/data/ovl_En_Nwc/ovl_En_Nwc.reloc.o" + include "build/src/overlays/actors/ovl_En_Nwc/ovl_En_Nwc_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c index b100f692f..548e1e68d 100644 --- a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c +++ b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.c @@ -1,7 +1,7 @@ /* * File: z_en_attack_niw.c * Overlay: ovl_En_Attack_Niw - * Description: Attacking cucco + * Description: Attacking Cucco */ #include "z_en_attack_niw.h" @@ -16,9 +16,9 @@ void EnAttackNiw_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx); void EnAttackNiw_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80958634(EnAttackNiw* this, GlobalContext* globalCtx); -void func_80958974(EnAttackNiw* this, GlobalContext* globalCtx); -void func_80958BE4(EnAttackNiw* this, GlobalContext* globalCtx); +void EnAttackNiw_EnterViewFromOffscreen(EnAttackNiw* this, GlobalContext* globalCtx); +void EnAttackNiw_AimAtPlayer(EnAttackNiw* this, GlobalContext* globalCtx); +void EnAttackNiw_FlyAway(EnAttackNiw* this, GlobalContext* globalCtx); const ActorInit En_Attack_Niw_InitVars = { ACTOR_EN_ATTACK_NIW, @@ -43,289 +43,305 @@ void EnAttackNiw_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_niw_Skel_002530, &object_niw_Anim_0000E8, this->jointTable, - this->morphTable, OBJECT_NIW_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gNiwSkeleton, &gNiwIdleAnim, this->jointTable, this->morphTable, + NIW_LIMB_MAX); + // probably copy pasted from EnNiw, which has this same code, but AttackNiw has no params if (this->actor.params < 0) { - this->actor.params = 0; + this->actor.params = ATTACK_NIW_REGULAR; } Actor_SetScale(&this->actor, 0.01f); this->actor.gravity = 0.0f; - this->unk_290.x = randPlusMinusPoint5Scaled(100.0f); - this->unk_290.y = randPlusMinusPoint5Scaled(10.0f); - this->unk_290.z = randPlusMinusPoint5Scaled(100.0f); + this->randomTargetCenterOffset.x = randPlusMinusPoint5Scaled(100.0f); + this->randomTargetCenterOffset.y = randPlusMinusPoint5Scaled(10.0f); + this->randomTargetCenterOffset.z = randPlusMinusPoint5Scaled(100.0f); Actor_SetScale(&this->actor, 0.01f); - this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags &= ~ACTOR_FLAG_1; // Unnecessary: this actor does not start with this flag this->actor.shape.rot.y = this->actor.world.rot.y = (Rand_ZeroOne() - 0.5f) * 60000.0f; - this->actionFunc = func_80958634; + this->actionFunc = EnAttackNiw_EnterViewFromOffscreen; } void EnAttackNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnAttackNiw* this = THIS; EnNiw* parent = (EnNiw*)this->actor.parent; - if ((thisx->parent != NULL) && (thisx->parent->update != NULL)) { - if (parent->unk290 > 0) { - parent->unk290--; + if (this->actor.parent != NULL && this->actor.parent->update != NULL) { + if (parent->attackNiwCount > 0) { + parent->attackNiwCount--; } } } -void func_80958228(EnAttackNiw* this, GlobalContext* globalCtx, s16 arg2) { - if (this->unk_24C == 0) { - if (arg2 == 0) { - this->unk_25C = 0.0f; +/** + * Summary: instead of using SkelAnime animations AttackNiw modifies head+wings directly to create animations + * + * EnNiw has its own version of this function, probably copy paste since AttackNiw only uses two animationState (2/5) + */ +void EnAttackNiw_AnimateWingHead(EnAttackNiw* this, GlobalContext* globalCtx, s16 animationState) { + if (this->unkTimer24C == 0) { + if (animationState == 0) { + this->targetBodyRotY = 0.0f; } else { - this->unk_25C = -10000.0f; + this->targetBodyRotY = -10000.0f; } - this->unk_286++; - this->unk_24C = 3; - if ((this->unk_286 % 2) == 0) { - this->unk_25C = 0.0f; - if (arg2 == 0) { - this->unk_24C = Rand_ZeroFloat(30.0f); + + this->clearRotYToggleTimer++; + this->unkTimer24C = 3; + if ((this->clearRotYToggleTimer % 2) == 0) { + this->targetBodyRotY = 0.0f; + if (animationState == 0) { + this->unkTimer24C = Rand_ZeroFloat(30.0f); } } } - if (this->unk_250 == 0) { - this->unk_28A++; - this->unk_28A &= 1; + if (this->unkTimer250 == 0) { + this->unkToggle28A++; + this->unkToggle28A &= 1; - switch (arg2) { - case 0: - this->unk_264 = 0.0f; - this->unk_260 = 0.0f; + switch (animationState) { // only case 2 and 5 are ever called in AttackNiw + case NIW_ANIMATION_STILL: + this->targetLeftWingRotZ = 0.0f; + this->targetRightWingRotZ = 0.0f; break; - case 1: - this->unk_250 = 3; - this->unk_264 = 7000.0f; - this->unk_260 = 7000.0f; - if (this->unk_28A == 0) { - this->unk_264 = 0.0f; - this->unk_260 = 0.0f; + case NIW_ANIMATION_HEAD_PECKING: + this->unkTimer250 = 3; + this->targetLeftWingRotZ = 7000.0f; + this->targetRightWingRotZ = 7000.0f; + if (this->unkToggle28A == 0) { + this->targetLeftWingRotZ = 0.0f; + this->targetRightWingRotZ = 0.0f; } break; - case 2: - this->unk_250 = 2; - this->unk_264 = -10000.0f; - this->unk_260 = -10000.0f; - this->unk_278 = 25000.0f; - this->unk_270 = 25000.0f; - this->unk_27C = 6000.0f; - this->unk_274 = 6000.0f; - if (this->unk_28A == 0) { - this->unk_270 = 8000.0f; - this->unk_278 = 8000.0f; + case NIW_ANIMATION_PECKING_AND_WAVING: + this->unkTimer250 = 2; + this->targetLeftWingRotZ = -10000.0f; + this->targetRightWingRotZ = -10000.0f; + this->targetLeftWingRotY = 25000.0f; + this->targetRightWingRotY = 25000.0f; + this->targetLeftWingRotX = 6000.0f; + this->targetRightWingRotX = 6000.0f; + if (this->unkToggle28A == 0) { + this->targetRightWingRotY = 8000.0f; + this->targetLeftWingRotY = 8000.0f; } break; - case 3: - this->unk_250 = 2; - this->unk_270 = 10000.0f; - this->unk_278 = 10000.0f; - if (this->unk_28A == 0) { - this->unk_270 = 3000.0f; - this->unk_278 = 3000.0f; + case NIW_ANIMATION_PECKING_AND_FORFLAPPING: + this->unkTimer250 = 2; + this->targetRightWingRotY = 10000.0f; + this->targetLeftWingRotY = 10000.0f; + if (this->unkToggle28A == 0) { + this->targetRightWingRotY = 3000.0f; + this->targetLeftWingRotY = 3000.0f; } break; - case 4: - this->unk_24E = 5; - this->unk_24C = this->unk_24E; + case NIW_ANIMATION_FREEZE: + this->unusedTimer24E = 5; + this->unkTimer24C = this->unusedTimer24E; break; - case 5: - this->unk_250 = 5; - this->unk_270 = 14000.0f; - this->unk_278 = 14000.0f; - if (this->unk_28A == 0) { - this->unk_270 = 10000.0f; - this->unk_278 = 10000.0f; + case NIW_ANIMATION_PECKING_SLOW_FORFLAPPING: + this->unkTimer250 = 5; + this->targetRightWingRotY = 14000.0f; + this->targetLeftWingRotY = 14000.0f; + if (this->unkToggle28A == 0) { + this->targetRightWingRotY = 10000.0f; + this->targetLeftWingRotY = 10000.0f; } break; } } - if (this->unk_280 != this->unk_2B8) { - Math_ApproachF(&this->unk_2B8, this->unk_280, 0.5f, 4000.0f); + if (this->targetHeadRotZ != this->headRotZ) { + Math_ApproachF(&this->headRotZ, this->targetHeadRotZ, 0.5f, 4000.0f); } - if (this->unk_25C != this->unk_2B4) { - Math_ApproachF(&this->unk_2B4, this->unk_25C, 0.5f, 4000.0f); + if (this->targetBodyRotY != this->upperBodyRotY) { + Math_ApproachF(&this->upperBodyRotY, this->targetBodyRotY, 0.5f, 4000.0f); } - if (this->unk_264 != this->unk_29C) { - Math_ApproachF(&this->unk_29C, this->unk_264, 0.8f, 7000.0f); + if (this->targetLeftWingRotZ != this->leftWingRotZ) { + Math_ApproachF(&this->leftWingRotZ, this->targetLeftWingRotZ, 0.8f, 7000.0f); } - if (this->unk_278 != this->unk_2A0) { - Math_ApproachF(&this->unk_2A0, this->unk_278, 0.8f, 7000.0f); + if (this->targetLeftWingRotY != this->leftWingRotY) { + Math_ApproachF(&this->leftWingRotY, this->targetLeftWingRotY, 0.8f, 7000.0f); } - if (this->unk_27C != this->unk_2A4) { - Math_ApproachF(&this->unk_2A4, this->unk_27C, 0.8f, 7000.0f); + if (this->targetLeftWingRotX != this->leftWingRotX) { + Math_ApproachF(&this->leftWingRotX, this->targetLeftWingRotX, 0.8f, 7000.0f); } - if (this->unk_260 != this->unk_2A8) { - Math_ApproachF(&this->unk_2A8, this->unk_260, 0.8f, 7000.0f); + if (this->targetRightWingRotZ != this->rightWingRotZ) { + Math_ApproachF(&this->rightWingRotZ, this->targetRightWingRotZ, 0.8f, 7000.0f); } - if (this->unk_270 != this->unk_2AC) { - Math_ApproachF(&this->unk_2AC, this->unk_270, 0.8f, 7000.0f); + if (this->targetRightWingRotY != this->rightWingRotY) { + Math_ApproachF(&this->rightWingRotY, this->targetRightWingRotY, 0.8f, 7000.0f); } - if (this->unk_274 != this->unk_2B0) { - Math_ApproachF(&this->unk_2B0, this->unk_274, 0.8f, 7000.0f); + if (this->targetRightWingRotX != this->rightWingRotX) { + Math_ApproachF(&this->rightWingRotX, this->targetRightWingRotX, 0.8f, 7000.0f); } } -s32 func_809585B0(EnAttackNiw* this, GlobalContext* globalCtx) { - s16 sp1E; - s16 sp1C; +s32 EnAttackNiw_IsOnScreen(EnAttackNiw* this, GlobalContext* globalCtx) { + s16 posX; + s16 posY; - Actor_SetFocus(&this->actor, this->unk_2DC); - Actor_GetScreenPos(globalCtx, &this->actor, &sp1E, &sp1C); + Actor_SetFocus(&this->actor, this->targetHeight); + Actor_GetScreenPos(globalCtx, &this->actor, &posX, &posY); - if ((this->actor.projectedPos.z < -20.0f) || (sp1E < 0) || (sp1E > SCREEN_WIDTH) || (sp1C < 0) || - (sp1C > SCREEN_HEIGHT)) { + if ((this->actor.projectedPos.z < -20.0f) || (posX < 0) || (posX > SCREEN_WIDTH) || (posY < 0) || + (posY > SCREEN_HEIGHT)) { return false; } return true; } -void func_80958634(EnAttackNiw* this, GlobalContext* globalCtx) { - s16 sp4E; - s16 sp4C; - Vec3f temp; - Vec3f sp34; +void EnAttackNiw_EnterViewFromOffscreen(EnAttackNiw* this, GlobalContext* globalCtx) { + s16 posX; + s16 posY; + Vec3f viewOffset; + Vec3f flightTarget; s32 pad; this->actor.speedXZ = 10.0f; - temp.x = (this->unk_290.x + globalCtx->view.at.x) - globalCtx->view.eye.x; - temp.y = (this->unk_290.y + globalCtx->view.at.y) - globalCtx->view.eye.y; - temp.z = (this->unk_290.z + globalCtx->view.at.z) - globalCtx->view.eye.z; + // randomTargetCenterOffset is set in _Init, only needs to be set once + // but the view is moving, so now we need to re-calculate the spot in space + viewOffset.x = this->randomTargetCenterOffset.x + globalCtx->view.at.x - globalCtx->view.eye.x; + viewOffset.y = this->randomTargetCenterOffset.y + globalCtx->view.at.y - globalCtx->view.eye.y; + viewOffset.z = this->randomTargetCenterOffset.z + globalCtx->view.at.z - globalCtx->view.eye.z; - sp34.x = globalCtx->view.at.x + temp.x; - sp34.y = globalCtx->view.at.y + temp.y; - sp34.z = globalCtx->view.at.z + temp.z; + // this is the 3D spot in space where the cucco is trying to fly into (until it lands or gets close) + flightTarget.x = globalCtx->view.at.x + viewOffset.x; + flightTarget.y = globalCtx->view.at.y + viewOffset.y; + flightTarget.z = globalCtx->view.at.z + viewOffset.z; - this->unk_2CC = Math_Vec3f_Yaw(&this->actor.world.pos, &sp34); - this->unk_2C8 = Math_Vec3f_Pitch(&this->actor.world.pos, &sp34) * -1.0f; + this->targetRotY = Math_Vec3f_Yaw(&this->actor.world.pos, &flightTarget); + this->targetRotX = Math_Vec3f_Pitch(&this->actor.world.pos, &flightTarget) * -1.0f; - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2CC, 5, this->unk_2D4, 0); - Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2C8, 5, this->unk_2D4, 0); - Math_ApproachF(&this->unk_2D4, 5000.0f, 1.0f, 100.0f); + Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRotY, 5, this->rotStep, 0); + Math_SmoothStepToS(&this->actor.world.rot.x, this->targetRotX, 5, this->rotStep, 0); + Math_ApproachF(&this->rotStep, 5000.0f, 1.0f, 100.0f); - Actor_SetFocus(&this->actor, this->unk_2DC); - Actor_GetScreenPos(globalCtx, &this->actor, &sp4E, &sp4C); + Actor_SetFocus(&this->actor, this->targetHeight); + Actor_GetScreenPos(globalCtx, &this->actor, &posX, &posY); - if (this->actor.bgCheckFlags & 8) { - this->unk_2CC = this->actor.yawTowardsPlayer; - this->unk_2C8 = this->actor.world.rot.x - 3000.0f; - this->unk_252 = 0; - this->unk_254 = 100; - this->unk_2D4 = 0.0f; - this->unk_27C = 0.0f; - this->unk_274 = 0.0f; - this->unk_250 = this->unk_252; - this->unk_24E = this->unk_252; - this->unk_24C = this->unk_252; + if (this->actor.bgCheckFlags & 8) { // touching a wall + this->targetRotY = this->actor.yawTowardsPlayer; + this->targetRotX = this->actor.world.rot.x - 3000.0f; + this->hopTimer = 0; + this->randomAngleChangeTimer = 100; + this->rotStep = 0.0f; + this->targetLeftWingRotX = 0.0f; + this->targetRightWingRotX = 0.0f; + this->unkTimer250 = this->hopTimer; + this->unusedTimer24E = this->hopTimer; + this->unkTimer24C = this->hopTimer; this->actor.gravity = -0.2f; - this->unk_280 = 0.0f; - this->actionFunc = func_80958974; - this->unk_2D8 = 5.0f; - } else if (((this->actor.projectedPos.z > 0.0f) && (fabsf(sp34.x - this->actor.world.pos.x) < 50.0f) && - (fabsf(sp34.y - this->actor.world.pos.y) < 50.0f) && - (fabsf(sp34.z - this->actor.world.pos.z) < 50.0f)) || - (this->actor.bgCheckFlags & 1)) { - this->unk_252 = 0; - this->unk_250 = this->unk_252; - this->unk_24E = this->unk_252; - this->unk_24C = this->unk_252; - this->unk_2D4 = 0.0f; - this->unk_274 = 0.0f; - this->unk_27C = 0.0f; - this->unk_2CC = this->actor.yawTowardsPlayer; - this->unk_2C8 = this->actor.world.rot.x - 2000.0f; - this->actor.gravity = -0.2f; - this->unk_280 = 0.0f; - this->actionFunc = func_80958974; - this->unk_2D8 = 5.0f; - } else { - this->unk_24C = 10; - this->unk_25C = -10000.0f; - this->unk_280 = -3000.0f; - func_80958228(this, globalCtx, 2); + this->targetHeadRotZ = 0.0f; + this->actionFunc = EnAttackNiw_AimAtPlayer; + this->targetXZSpeed = 5.0f; + + } else if (((this->actor.projectedPos.z > 0.0f) && (fabsf(flightTarget.x - this->actor.world.pos.x) < 50.0f) && + (fabsf(flightTarget.y - this->actor.world.pos.y) < 50.0f) && + (fabsf(flightTarget.z - this->actor.world.pos.z) < 50.0f)) || + (this->actor.bgCheckFlags & 1)) { // touching ground or with close distance of target + // reset state + this->hopTimer = 0; + this->unkTimer250 = this->hopTimer; + this->unusedTimer24E = this->hopTimer; + this->unkTimer24C = this->hopTimer; + this->rotStep = 0.0f; + this->targetRightWingRotX = 0.0f; + this->targetLeftWingRotX = 0.0f; + + this->targetRotY = this->actor.yawTowardsPlayer; // start turn to face player + this->targetRotX = this->actor.world.rot.x - 2000.0f; // bank into the turn + this->actor.gravity = -0.2f; // start gentle decent (no longer flying without gravity) + this->targetHeadRotZ = 0.0f; + this->actionFunc = EnAttackNiw_AimAtPlayer; + this->targetXZSpeed = 5.0f; + + } else { // keep flying at the flightTarget for now + this->unkTimer24C = 10; + this->targetBodyRotY = -10000.0f; + this->targetHeadRotZ = -3000.0f; + EnAttackNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); } } -void func_80958974(EnAttackNiw* this, GlobalContext* globalCtx) { - if (!func_809585B0(this, globalCtx)) { +void EnAttackNiw_AimAtPlayer(EnAttackNiw* this, GlobalContext* globalCtx) { + if (!EnAttackNiw_IsOnScreen(this, globalCtx)) { Actor_MarkForDeath(&this->actor); return; } - if (this->actor.bgCheckFlags & 1) { - if (this->unk_252 == 0) { - this->unk_252 = 3; + if (this->actor.bgCheckFlags & 1) { // touching floor + if (this->hopTimer == 0) { + this->hopTimer = 3; this->actor.velocity.y = 3.5f; } - if (this->actor.gravity != -2.0f) { - this->unk_2CC = this->actor.yawTowardsPlayer; - this->unk_25A = 50; - this->unk_254 = 100; - this->unk_270 = 14000.0f; - this->unk_278 = 14000.0f; - this->unk_274 = 0.0f; - this->unk_27C = 0.0f; - this->unk_260 = 0.0f; - this->unk_264 = 0.0f; - this->unk_2C8 = 0.0f; + if (this->actor.gravity != -2.0f) { // first landing + this->targetRotY = this->actor.yawTowardsPlayer; + this->unkTimer25A = 50; + this->randomAngleChangeTimer = 100; + this->targetRightWingRotY = 14000.0f; + this->targetLeftWingRotY = 14000.0f; + this->targetRightWingRotX = 0.0f; + this->targetLeftWingRotX = 0.0f; + this->targetRightWingRotZ = 0.0f; + this->targetLeftWingRotZ = 0.0f; + this->targetRotX = 0.0f; this->actor.gravity = -2.0f; } } - if (this->unk_254 == 50) { - this->unk_2CC = randPlusMinusPoint5Scaled(200.0f) + this->actor.yawTowardsPlayer; + if (this->randomAngleChangeTimer == 50) { + this->targetRotY = randPlusMinusPoint5Scaled(200.0f) + this->actor.yawTowardsPlayer; } - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2CC, 2, this->unk_2D4, 0); - Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2C8, 2, this->unk_2D4, 0); - Math_ApproachF(&this->unk_2D4, 10000.0f, 1.0f, 1000.0f); - Math_ApproachF(&this->actor.speedXZ, this->unk_2D8, 0.9f, 1.0f); + Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRotY, 2, this->rotStep, 0); + Math_SmoothStepToS(&this->actor.world.rot.x, this->targetRotX, 2, this->rotStep, 0); + Math_ApproachF(&this->rotStep, 10000.0f, 1.0f, 1000.0f); + Math_ApproachF(&this->actor.speedXZ, this->targetXZSpeed, 0.9f, 1.0f); - if ((this->actor.gravity == -2.0f) && (this->unk_25A == 0) && - ((this->actor.bgCheckFlags & 8) || (this->unk_254 == 0))) { - this->unk_2D8 = 0.0f; + if (this->actor.gravity == -2.0f && this->unkTimer25A == 0 && + (this->actor.bgCheckFlags & 8 || this->randomAngleChangeTimer == 0)) { + this->targetXZSpeed = 0.0f; this->actor.gravity = 0.0f; - this->unk_2D4 = 0.0f; - this->unk_2C8 = this->actor.world.rot.x - 5000.0f; - this->actionFunc = func_80958BE4; - } else if (this->actor.bgCheckFlags & 1) { - func_80958228(this, globalCtx, 5); + this->rotStep = 0.0f; + this->targetRotX = this->actor.world.rot.x - 5000.0f; + this->actionFunc = EnAttackNiw_FlyAway; + + } else if (this->actor.bgCheckFlags & 1) { // touching floor + EnAttackNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_SLOW_FORFLAPPING); + } else { - func_80958228(this, globalCtx, 2); + EnAttackNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); } } -void func_80958BE4(EnAttackNiw* this, GlobalContext* globalCtx) { - if (!func_809585B0(this, globalCtx)) { +void EnAttackNiw_FlyAway(EnAttackNiw* this, GlobalContext* globalCtx) { + if (!EnAttackNiw_IsOnScreen(this, globalCtx)) { Actor_MarkForDeath(&this->actor); return; } - Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2C8, 5, this->unk_2D4, 0); - Math_ApproachF(&this->unk_2D4, 5000.0f, 1.0f, 100.0f); + Math_SmoothStepToS(&this->actor.world.rot.x, this->targetRotX, 5, this->rotStep, 0); + Math_ApproachF(&this->rotStep, 5000.0f, 1.0f, 100.0f); Math_ApproachF(&this->actor.velocity.y, 5.0f, 0.3f, 1.0f); - func_80958228(this, globalCtx, 2); + EnAttackNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); } void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx) { @@ -334,37 +350,17 @@ void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx) { EnNiw* parent; Player* player = GET_PLAYER(globalCtx); s32 pad2; - Vec3f sp30; + Vec3f splashPos; - this->unk_284++; + this->unusedCounter284++; - if (this->unk_24C != 0) { - this->unk_24C--; - } - - if (this->unk_250 != 0) { - this->unk_250--; - } - - if (this->unk_252 != 0) { - this->unk_252--; - } - - if (this->unk_256 != 0) { - this->unk_256--; - } - - if (this->unk_258 != 0) { - this->unk_258--; - } - - if (this->unk_254 != 0) { - this->unk_254--; - } - - if (this->unk_25A != 0) { - this->unk_25A--; - } + DECR(this->unkTimer24C); + DECR(this->unkTimer250); + DECR(this->hopTimer); + DECR(this->crySfxTimer); + DECR(this->flutterSfxTimer); + DECR(this->randomAngleChangeTimer); + DECR(this->unkTimer25A); this->actor.shape.rot = this->actor.world.rot; this->actor.shape.shadowScale = 15.0f; @@ -373,45 +369,48 @@ void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); - if (this->actionFunc == func_80958634) { + if (this->actionFunc == EnAttackNiw_EnterViewFromOffscreen) { Actor_MoveWithoutGravity(&this->actor); } else { Actor_MoveWithGravity(&this->actor); } - if (this->actor.floorHeight <= -32000.0f) { + if (this->actor.floorHeight <= BGCHECK_Y_MIN) { // under the world Actor_MarkForDeath(&this->actor); - } else if ((this->actor.bgCheckFlags & 0x20) && (this->actionFunc != func_80958BE4)) { - Math_Vec3f_Copy(&sp30, &this->actor.world.pos); - sp30.y += this->actor.depthInWater; - EffectSsGSplash_Spawn(globalCtx, &sp30, NULL, NULL, 0, 400); - this->unk_2D4 = 0.0f; + } else if ((this->actor.bgCheckFlags & 0x20) && // on or below water + (this->actionFunc != EnAttackNiw_FlyAway)) { + Math_Vec3f_Copy(&splashPos, &this->actor.world.pos); + splashPos.y += this->actor.depthInWater; + EffectSsGSplash_Spawn(globalCtx, &splashPos, NULL, NULL, 0, 400); + this->rotStep = 0.0f; this->actor.gravity = 0.0f; - this->unk_2D8 = 0.0f; - this->unk_2C8 = this->actor.world.rot.x - 5000.0f; - this->actionFunc = func_80958BE4; + this->targetXZSpeed = 0.0f; + this->targetRotX = this->actor.world.rot.x - 5000.0f; + this->actionFunc = EnAttackNiw_FlyAway; + } else { - f32 temp = 20.0f; + f32 viewOffset = 20.0f; label: - if (this->actor.xyzDistToPlayerSq < SQ(temp)) { + if (this->actor.xyzDistToPlayerSq < SQ(viewOffset)) { parent = (EnNiw*)this->actor.parent; if ((this->actor.parent->update != NULL) && (this->actor.parent != NULL) && (parent != NULL) && - (parent->unusedTimer25E == 0) && (player->invincibilityTimer == 0)) { + (parent->unkAttackNiwTimer == 0) && (player->invincibilityTimer == 0)) { + // this updates some player values based on what we pass, need player decomp to know what this is doing func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); - parent->unusedTimer25E = 70; + parent->unkAttackNiwTimer = 70; } } - if (this->unk_256 == 0) { - this->unk_256 = 30; + if (this->crySfxTimer == 0) { + this->crySfxTimer = 30; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_A); } - if (this->unk_258 == 0) { - this->unk_258 = 7; + if (this->flutterSfxTimer == 0) { + this->flutterSfxTimer = 7; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); } } @@ -421,24 +420,24 @@ s32 EnAttackNiw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** Actor* thisx) { EnAttackNiw* this = THIS; - if (limbIndex == OBJECT_NIW_LIMB_0D) { - rot->y += (s16)this->unk_2B4; + if (limbIndex == NIW_LIMB_UPPER_BODY) { + rot->y += (s16)this->upperBodyRotY; } - if (limbIndex == OBJECT_NIW_LIMB_0F) { - rot->z += (s16)this->unk_2B8; + if (limbIndex == NIW_LIMB_HEAD) { + rot->z += (s16)this->headRotZ; } - if (limbIndex == OBJECT_NIW_LIMB_0B) { - rot->x += (s16)this->unk_2B0; - rot->y += (s16)this->unk_2AC; - rot->z += (s16)this->unk_2A8; + if (limbIndex == NIW_LIMB_RIGHT_WING_ROOT) { + rot->x += (s16)this->rightWingRotX; + rot->y += (s16)this->rightWingRotY; + rot->z += (s16)this->rightWingRotZ; } - if (limbIndex == OBJECT_NIW_LIMB_07) { - rot->x += (s16)this->unk_2A4; - rot->y += (s16)this->unk_2A0; - rot->z += (s16)this->unk_29C; + if (limbIndex == NIW_LIMB_LEFT_WING_ROOT) { + rot->x += (s16)this->leftWingRotX; + rot->y += (s16)this->leftWingRotY; + rot->z += (s16)this->leftWingRotZ; } return false; } diff --git a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h index 4d3243ef5..c4dcaf8d0 100644 --- a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h +++ b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h @@ -11,49 +11,52 @@ typedef void (*EnAttackNiwActionFunc)(struct EnAttackNiw*, GlobalContext*); typedef struct EnAttackNiw { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[OBJECT_NIW_LIMB_MAX]; - /* 0x1E8 */ Vec3s morphTable[OBJECT_NIW_LIMB_MAX]; + /* 0x188 */ Vec3s jointTable[NIW_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[NIW_LIMB_MAX]; /* 0x248 */ EnAttackNiwActionFunc actionFunc; - /* 0x24C */ s16 unk_24C; - /* 0x24E */ s16 unk_24E; - /* 0x250 */ s16 unk_250; - /* 0x252 */ s16 unk_252; - /* 0x254 */ s16 unk_254; - /* 0x256 */ s16 unk_256; - /* 0x258 */ s16 unk_258; - /* 0x25A */ s16 unk_25A; - /* 0x25C */ f32 unk_25C; - /* 0x260 */ f32 unk_260; - /* 0x264 */ f32 unk_264; - /* 0x268 */ UNK_TYPE1 unk268[8]; - /* 0x270 */ f32 unk_270; - /* 0x274 */ f32 unk_274; - /* 0x278 */ f32 unk_278; - /* 0x27C */ f32 unk_27C; - /* 0x280 */ f32 unk_280; - /* 0x284 */ s16 unk_284; - /* 0x286 */ s16 unk_286; - /* 0x288 */ UNK_TYPE1 unk288[2]; - /* 0x28A */ s16 unk_28A; - /* 0x28C */ UNK_TYPE1 unk28C[4]; - /* 0x290 */ Vec3f unk_290; - /* 0x29C */ f32 unk_29C; - /* 0x2A0 */ f32 unk_2A0; - /* 0x2A4 */ f32 unk_2A4; - /* 0x2A8 */ f32 unk_2A8; - /* 0x2AC */ f32 unk_2AC; - /* 0x2B0 */ f32 unk_2B0; - /* 0x2B4 */ f32 unk_2B4; - /* 0x2B8 */ f32 unk_2B8; - /* 0x2BC */ UNK_TYPE1 unk2BC[0xC]; - /* 0x2C8 */ f32 unk_2C8; - /* 0x2CC */ f32 unk_2CC; - /* 0x2D0 */ UNK_TYPE1 unk2D0[4]; - /* 0x2D4 */ f32 unk_2D4; - /* 0x2D8 */ f32 unk_2D8; - /* 0x2DC */ f32 unk_2DC; + /* 0x24C */ s16 unkTimer24C; // control behavior in _UpdateRotations + /* 0x24E */ s16 unusedTimer24E; // set never read + /* 0x250 */ s16 unkTimer250; // control behavior in _UpdateRotations + /* 0x252 */ s16 hopTimer; + /* 0x254 */ s16 randomAngleChangeTimer; + /* 0x256 */ s16 crySfxTimer; + /* 0x258 */ s16 flutterSfxTimer; + /* 0x25A */ s16 unkTimer25A; // set to 50 in run at player, locks fly away without water? + /* 0x25C */ f32 targetBodyRotY; + /* 0x260 */ f32 targetRightWingRotZ; + /* 0x264 */ f32 targetLeftWingRotZ; + /* 0x268 */ f32 unusedRotations[2]; // in EnNiw this is an array of targetRot + /* 0x270 */ f32 targetRightWingRotY; + /* 0x274 */ f32 targetRightWingRotX; + /* 0x278 */ f32 targetLeftWingRotY; + /* 0x27C */ f32 targetLeftWingRotX; + /* 0x280 */ f32 targetHeadRotZ; + /* 0x284 */ s16 unusedCounter284; // incremented in _Update, never read + /* 0x286 */ s16 clearRotYToggleTimer; + /* 0x288 */ UNK_TYPE1 pad288[2]; + /* 0x28A */ s16 unkToggle28A; + /* 0x28C */ UNK_TYPE1 pad28C[4]; + /* 0x290 */ Vec3f randomTargetCenterOffset; // see EnAttackNiw_EnterViewFromOffscreen + /* 0x29C */ f32 leftWingRotZ; + /* 0x2A0 */ f32 leftWingRotY; + /* 0x2A4 */ f32 leftWingRotX; + /* 0x2A8 */ f32 rightWingRotZ; + /* 0x2AC */ f32 rightWingRotY; + /* 0x2B0 */ f32 rightWingRotX; + /* 0x2B4 */ f32 upperBodyRotY; + /* 0x2B8 */ f32 headRotZ; + /* 0x2BC */ UNK_TYPE1 pad2BC[0xC]; // unused rotations? + /* 0x2C8 */ f32 targetRotX; + /* 0x2CC */ f32 targetRotY; + /* 0x2D0 */ UNK_TYPE1 pad2D0[4]; + /* 0x2D4 */ f32 rotStep; + /* 0x2D8 */ f32 targetXZSpeed; + /* 0x2DC */ f32 targetHeight; // never set, but sent to Actor_SetFocus } EnAttackNiw; // size = 0x2E0 extern const ActorInit En_Attack_Niw_InitVars; + +#define ATTACK_NIW_REGULAR 0 // spawned by EnNiw + #endif // Z_EN_ATTACK_NIW_H 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 e15e3adb3..5e886bcc0 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -18,8 +18,8 @@ void EnHs_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80952FE0(EnHs* this, GlobalContext* globalCtx); void func_80953098(EnHs* this, GlobalContext* globalCtx); void func_80953180(EnHs* this, GlobalContext* globalCtx); -void func_809532C0(EnHs* this, GlobalContext* globalCtx); -void func_809532D0(EnHs* this, GlobalContext* globalCtx); +void EnHs_DoNothing(EnHs* this, GlobalContext* globalCtx); +void EnHs_SceneTransitToBunnyHoodDialogue(EnHs* this, GlobalContext* globalCtx); void func_80953354(EnHs* this, GlobalContext* globalCtx); void func_8095345C(EnHs* this, GlobalContext* globalCtx); @@ -61,12 +61,12 @@ void func_80952C50(EnHs* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 i; - for (i = 0; i < ARRAY_COUNT(this->unk_2A4); i++) { - Math_Vec3f_Copy(&this->unk_2A4[i], &player->actor.world.pos); + for (i = 0; i < ARRAY_COUNT(this->nwcPos); i++) { + Math_Vec3f_Copy(&this->nwcPos[i], &player->actor.world.pos); } - this->actor.home.rot.x = 0; - this->actor.home.rot.z = 0; + this->actor.home.rot.x = 0; // reset adult transformed count + this->actor.home.rot.z = 0; // reset chick count } void EnHs_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -74,17 +74,19 @@ void EnHs_Init(Actor* thisx, GlobalContext* globalCtx) { EnHs* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_hs_Skel_006260, &object_hs_Anim_0005C0, this->jointTable, - this->morphTable, OBJECT_HS_LIMB_MAX); - Animation_PlayLoop(&this->skelAnime, &object_hs_Anim_0005C0); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gHsSkeleton, &gHsIdleAnim, this->jointTable, this->morphTable, + OBJECT_HS_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gHsIdleAnim); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_8095345C; + if (globalCtx->curSpawn == 1) { this->actor.flags |= ACTOR_FLAG_10000; } - this->unk_2A0 = 0; + + this->stateFlags = 0; this->actor.targetMode = 6; func_80952C50(this, globalCtx); } @@ -102,56 +104,56 @@ void func_80952DFC(GlobalContext* globalCtx) { func_80151BB4(globalCtx, 0x10); } -void func_80952E50(Vec3f* dst, Vec3f src, f32 arg2) { - Vec3f sp1C; - f32 temp_f0; +void EnHs_UpdateChickPos(Vec3f* dst, Vec3f src, f32 offset) { + Vec3f diff; + f32 distance; - Math_Vec3f_Diff(&src, dst, &sp1C); + Math_Vec3f_Diff(&src, dst, &diff); - temp_f0 = SQ(sp1C.x) + SQ(sp1C.z); + distance = SQ(diff.x) + SQ(diff.z); // gets un-squared after we check if we are too close - if (SQ(arg2) > temp_f0) { + if (SQ(offset) > distance) { return; } - temp_f0 = sqrtf(temp_f0); - sp1C.x *= (temp_f0 - arg2) / temp_f0; - sp1C.z *= (temp_f0 - arg2) / temp_f0; + distance = sqrtf(distance); + diff.x *= (distance - offset) / distance; + diff.z *= (distance - offset) / distance; - dst->x += sp1C.x; - dst->z += sp1C.z; + dst->x += diff.x; + dst->z += diff.z; } void func_80952F00(EnHs* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 i; - f32 phi_f20; + f32 offset; - if (this->actor.home.rot.z >= 20) { - phi_f20 = 15.0f; + if (this->actor.home.rot.z >= 20) { // current chick count >= 10 + offset = 15.0f; } else { - phi_f20 = 10.0f; + offset = 10.0f; } - func_80952E50(&this->unk_2A4[0], player->actor.world.pos, phi_f20); + EnHs_UpdateChickPos(&this->nwcPos[0], player->actor.world.pos, offset); - for (i = 1; i < ARRAY_COUNT(this->unk_2A4); i++) { - func_80952E50(&this->unk_2A4[i], this->unk_2A4[i - 1], phi_f20); + for (i = 1; i < ARRAY_COUNT(this->nwcPos); i++) { + EnHs_UpdateChickPos(&this->nwcPos[i], this->nwcPos[i - 1], offset); } } void func_80952FE0(EnHs* this, GlobalContext* globalCtx) { - if (this->unk_2A2 < 40) { - Math_SmoothStepToS(&this->unk_294.y, 0x1F40, 6, 0x1838, 0x64); - } else if (this->unk_2A2 < 80) { - Math_SmoothStepToS(&this->unk_294.y, -0x1F40, 6, 0x1838, 0x64); + if (this->stateTimer < 40) { + Math_SmoothStepToS(&this->headRot.y, 0x1F40, 6, 0x1838, 0x64); + } else if (this->stateTimer < 80) { + Math_SmoothStepToS(&this->headRot.y, -0x1F40, 6, 0x1838, 0x64); } else { this->actionFunc = func_80953180; - this->unk_2A0 &= ~4; + this->stateFlags &= ~4; func_80151938(globalCtx, 0x33F6); func_80952DFC(globalCtx); } - this->unk_2A2++; + this->stateTimer++; } void func_80953098(EnHs* this, GlobalContext* globalCtx) { @@ -159,10 +161,10 @@ void func_80953098(EnHs* this, GlobalContext* globalCtx) { this->actor.parent = NULL; this->actionFunc = func_8095345C; this->actor.flags |= ACTOR_FLAG_10000; - this->unk_2A0 |= 0x10; + this->stateFlags |= 0x10; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); } else { - this->unk_2A0 |= 8; + this->stateFlags |= 8; if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 10000.0f, 50.0f); } else { @@ -174,31 +176,31 @@ void func_80953098(EnHs* this, GlobalContext* globalCtx) { void func_80953180(EnHs* this, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.currentTextId) { - case 0x33F4: - case 0x33F6: + case 0x33F4: // text: laughing that they are all roosters (!) + case 0x33F6: // text: Grog regrets not being able to see his chicks reach adult hood func_801477B4(globalCtx); this->actionFunc = func_8095345C; break; - case 0x33F7: + case 0x33F7: // text: notice his chicks are grown up, happy, wants to give you bunny hood this->actor.flags &= ~ACTOR_FLAG_10000; func_801477B4(globalCtx); this->actionFunc = func_80953098; func_80953098(this, globalCtx); break; - case 0x33F9: + case 0x33F9: // text: laughing that they are all roosters (.) this->actor.flags &= ~ACTOR_FLAG_10000; func_801477B4(globalCtx); this->actionFunc = func_8095345C; break; - case 0x33F5: + case 0x33F5: // He heard from his gramps (?) the moon is going to fall globalCtx->msgCtx.unk11F10 = 0; this->actionFunc = func_80952FE0; - this->unk_2A2 = 0; - this->unk_294.z = 0; - this->unk_2A0 |= 4; + this->stateTimer = 0; + this->headRot.z = 0; + this->stateFlags |= 4; break; default: @@ -209,34 +211,34 @@ void func_80953180(EnHs* this, GlobalContext* globalCtx) { } } -void func_809532C0(EnHs* this, GlobalContext* globalCtx) { +void EnHs_DoNothing(EnHs* this, GlobalContext* globalCtx) { } -void func_809532D0(EnHs* this, GlobalContext* globalCtx) { - if (DECR(this->unk_2A2) == 0) { - globalCtx->nextEntranceIndex = globalCtx->setupExitList[ENHS_GET_F(&this->actor)]; +void EnHs_SceneTransitToBunnyHoodDialogue(EnHs* this, GlobalContext* globalCtx) { + if (DECR(this->stateTimer) == 0) { + globalCtx->nextEntranceIndex = globalCtx->setupExitList[HS_GET_EXIT_INDEX(&this->actor)]; globalCtx->sceneLoadFlag = 0x14; gSaveContext.save.weekEventReg[25] |= 8; - this->actionFunc = func_809532C0; + this->actionFunc = EnHs_DoNothing; } } void func_80953354(EnHs* this, GlobalContext* globalCtx) { if (!Play_InCsMode(globalCtx)) { func_800B7298(globalCtx, &this->actor, 7); - this->actionFunc = func_809532D0; + this->actionFunc = EnHs_SceneTransitToBunnyHoodDialogue; } } void func_809533A0(EnHs* this, GlobalContext* globalCtx) { u16 sp1E; - if ((globalCtx->curSpawn == 1) && !(this->unk_2A0 & 0x20)) { + if ((globalCtx->curSpawn == 1) && !(this->stateFlags & 0x20)) { sp1E = 0x33F7; - this->unk_2A0 |= 0x20; - } else if (this->unk_2A0 & 0x10) { + this->stateFlags |= 0x20; + } else if (this->stateFlags & 0x10) { sp1E = 0x33F9; - this->unk_2A0 &= ~0x10; + this->stateFlags &= ~0x10; } else if (gSaveContext.save.weekEventReg[25] & 8) { sp1E = 0x33F4; } else { @@ -254,21 +256,21 @@ void func_8095345C(EnHs* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80953180; func_809533A0(this, globalCtx); - if (this->unk_2A0 & 8) { + if (this->stateFlags & 8) { func_80952DFC(globalCtx); - this->unk_2A0 &= ~8; + this->stateFlags &= ~8; } - } else if (this->actor.home.rot.x >= 20) { + } else if (this->actor.home.rot.x >= 20) { // chicks turned adult >= 10 this->actionFunc = func_80953354; - this->unk_2A2 = 40; + this->stateTimer = 40; } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_10000)) { func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); - this->unk_2A0 |= 1; + this->stateFlags |= 1; } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x2000, globalCtx)) { func_800B8614(&this->actor, globalCtx, 130.0f); - this->unk_2A0 |= 1; + this->stateFlags |= 1; } else { - this->unk_2A0 &= ~1; + this->stateFlags &= ~1; } } @@ -290,17 +292,17 @@ void EnHs_Update(Actor* thisx, GlobalContext* globalCtx) { func_80952F00(this, globalCtx); - if (this->unk_2A0 & 4) { - Math_SmoothStepToS(&this->unk_294.x, 0, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_29A.x, 0, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_29A.y, 0, 6, 0x1838, 0x64); - } else if (this->unk_2A0 & 1) { - func_800E9250(globalCtx, &this->actor, &this->unk_294, &this->unk_29A, this->actor.focus.pos); + if (this->stateFlags & 4) { + Math_SmoothStepToS(&this->headRot.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unusedRot.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unusedRot.y, 0, 6, 0x1838, 0x64); + } else if (this->stateFlags & 1) { + func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unusedRot, this->actor.focus.pos); } else { - Math_SmoothStepToS(&this->unk_294.x, 0x3200, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_294.y, 0, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_29A.x, 0, 6, 0x1838, 0x64); - Math_SmoothStepToS(&this->unk_29A.y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->headRot.x, 0x3200, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->headRot.y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unusedRot.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unusedRot.y, 0, 6, 0x1838, 0x64); } } @@ -308,29 +310,33 @@ s32 EnHs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnHs* this = THIS; switch (limbIndex) { - case OBJECT_HS_LIMB_09: - rot->x += this->unk_294.y; - rot->z += this->unk_294.x; + case HS_LIMB_HEAD: + rot->x += this->headRot.y; + rot->z += this->headRot.x; break; - case OBJECT_HS_LIMB_0A: - rot->x += this->unk_294.y; - rot->z += this->unk_294.x; + case HS_LIMB_HAIR_SPIKES: + rot->x += this->headRot.y; + rot->z += this->headRot.x; break; - case OBJECT_HS_LIMB_0B: + case HS_LIMB_HIDDEN_HAIR: + // for some reason this hair is always removed here in the Override limb + // if you do re-enable, make sure you add the head rot like above *dList = NULL; return false; + // these two limbs both have empty enddisplaylist, they do nothing + // at the same time (params == HS_TYPE_UNK1) is always false, because vanilla params is 0xFE01 case OBJECT_HS_LIMB_0C: - if (this->actor.params == ENHS_1) { + if (this->actor.params == HS_TYPE_UNK1) { *dList = NULL; return false; } break; case OBJECT_HS_LIMB_0D: - if (this->actor.params == ENHS_1) { + if (this->actor.params == HS_TYPE_UNK1) { *dList = NULL; return false; } @@ -342,7 +348,7 @@ s32 EnHs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnHs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnHs* this = THIS; - if (limbIndex == OBJECT_HS_LIMB_09) { + if (limbIndex == HS_LIMB_HEAD) { Matrix_MultiplyVector3fByState(&D_8095393C, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.h b/src/overlays/actors/ovl_En_Hs/z_en_hs.h index 0a50ee360..62fc1d2a1 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.h +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.h @@ -8,9 +8,17 @@ struct EnHs; typedef void (*EnHsActionFunc)(struct EnHs*, GlobalContext*); -#define ENHS_GET_F(thisx) ((thisx)->params & 0xF) +#define HS_GET_EXIT_INDEX(thisx) ((thisx)->params & 0xF) -#define ENHS_1 1 +#define HS_TYPE_UNK1 1 + +// params mystery: Vanilla Grog is 0xFE01 +// 0xFE00 space is never checked in Grog code +// at the same time, type UNK1 is only checked directly with params == 1, no &F +// so HS_TYPE_UNK1 is never valid and is unused, as 0xFE00 is still present even if its not doing anything else + +// The count of [chicks following the player] is stored in [this->actor.home.rot.z] (incremented by 2) +// The count of [chicks transformed into adult] is stored in [this->actor.home.rot.x] (incremented by 2) typedef struct EnHs { /* 0x0000 */ Actor actor; @@ -18,11 +26,11 @@ typedef struct EnHs { /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ Vec3s jointTable[OBJECT_HS_LIMB_MAX]; /* 0x0234 */ Vec3s morphTable[OBJECT_HS_LIMB_MAX]; - /* 0x0294 */ Vec3s unk_294; - /* 0x029A */ Vec3s unk_29A; - /* 0x02A0 */ u16 unk_2A0; - /* 0x02A2 */ s16 unk_2A2; - /* 0x02A4 */ Vec3f unk_2A4[20]; + /* 0x0294 */ Vec3s headRot; + /* 0x029A */ Vec3s unusedRot; // probably not chest, as chest is same limb as lower body + /* 0x02A0 */ u16 stateFlags; + /* 0x02A2 */ s16 stateTimer; // reused for different actionFunc + /* 0x02A4 */ Vec3f nwcPos[20]; // actual chick position are even values, odd values seem to be extra values for smoother chain /* 0x0394 */ EnHsActionFunc actionFunc; } EnHs; // size = 0x398 diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index f6e398a33..e3be9ae03 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -5,7 +5,7 @@ */ #include "z_en_niw.h" -#include "objects/object_niw/object_niw.h" +#include "overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000) @@ -30,12 +30,23 @@ void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx); void EnNiw_UpdateFeather(EnNiw* this, GlobalContext* globalCtx); void EnNiw_DrawFeathers(EnNiw* this, GlobalContext* globalCtx); void EnNiw_CheckRage(EnNiw* this, GlobalContext* globalCtx); -void func_80891320(EnNiw* this, GlobalContext* globalCtx, s16 arg2); +void EnNiw_AnimateWingHead(EnNiw* this, GlobalContext* globalCtx, s16 animationState); void EnNiw_SpawnFeather(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale); -// turned on during cucco storm, but not read by anything? -// maybe read by En_Attack_Niw -s16 D_80893460 = false; +s16 sCuccoStormActive = false; + +// why wouldnt they just use actionFunc? +enum EnNiwState { + /* 0 */ NIW_STATE_IDLE, + /* 1 */ NIW_STATE_ANGRY1, // 1/2/3 are stages of summoning cucco storm + /* 2 */ NIW_STATE_ANGRY2, + /* 3 */ NIW_STATE_ANGRY3, + /* 4 */ NIW_STATE_HELD, + /* 5 */ NIW_STATE_FALLING, + /* 6 */ NIW_STATE_SWIMMING, + /* 7 */ NIW_STATE_RUNNING, + /* 8 */ NIW_STATE_HOPPING, +}; const ActorInit En_Niw_InitVars = { ACTOR_EN_NIW, @@ -49,15 +60,11 @@ const ActorInit En_Niw_InitVars = { (ActorFunc)EnNiw_Draw, }; -static f32 D_80893484[] = { - 5000.0f, - -5000.0f, -}; -static f32 D_80893486[] = { - 5000.0f, - 3000.0f, - 4000.0f, -}; +static f32 sHeadRotations[] = { 5000.0f, -5000.0f }; + +static f32 sRunningAngles[] = { 5000.0f, 3000.0f }; + +static f32 sUnusedValue = 4000.0f; static ColliderCylinderInit sCylinderInit = { { @@ -109,8 +116,8 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { EnNiw* this = THIS; Vec3f dTemp = D_808934C4; - if (this->actor.params < 0) { // all neg values become zero - this->actor.params = ENNIW_TYPE_REGULAR; + if (this->actor.params < 0) { // all scene spawned cucco are (-1) + this->actor.params = NIW_TYPE_REGULAR; } Math_Vec3f_Copy(&this->unk2BC, &dTemp); @@ -122,32 +129,36 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 25.0f); - SkelAnime_InitFlex(globalCtx, &this->skelanime, &object_niw_Skel_002530, &object_niw_Anim_0000E8, this->jointTable, - this->morphTable, ENNIW_LIMBCOUNT); + SkelAnime_InitFlex(globalCtx, &this->skelanime, &gNiwSkeleton, &gNiwIdleAnim, this->jointTable, this->morphTable, + NIW_LIMB_MAX); Math_Vec3f_Copy(&this->unk2A4, &this->actor.world.pos); Math_Vec3f_Copy(&this->unk2B0, &this->actor.world.pos); this->unk308 = 10.0f; Actor_SetScale(&this->actor, 0.01f); - if (this->niwType == ENNIW_TYPE_UNK1) { + if (this->niwType == NIW_TYPE_UNK1) { + // @Bug this unused variant is broken and crashes on spawn (EnNiw_Update expects a parent, NULL) + // if modified to change niwType to TYPE_REGULAR here, new size is smaller than normal + // theory: was meant to be a small hand held cucco for grog to show the player Actor_SetScale(&this->actor, (BREG(86) / 10000.0f) + 0.004f); } // random health between 10-20 + // health at zero triggers cucco storm not death this->actor.colChkInfo.health = Rand_ZeroFloat(9.99f) + 10.0f; this->actor.colChkInfo.mass = MASS_IMMOVABLE; - if (this->niwType == ENNIW_TYPE_REGULAR) { + if (this->niwType == NIW_TYPE_REGULAR) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); } - if (this->niwType == ENNIW_TYPE_UNK2) { - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + if (this->niwType == NIW_TYPE_HELD) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); this->sfxTimer1 = 30; - this->unkTimer250 = 30; + this->heldTimer = 30; this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF - this->unknownState28E = 4; + this->niwState = NIW_STATE_HELD; this->actionFunc = EnNiw_Held; this->actor.speedXZ = 0.0f; this->unk2BC.z = 0.0f; @@ -161,105 +172,119 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { void EnNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnNiw* this = THIS; - if (this->niwType == ENNIW_TYPE_REGULAR) { + if (this->niwType == NIW_TYPE_REGULAR) { Collider_DestroyCylinder(globalCtx, &this->collider); } } -void func_80891320(EnNiw* this, GlobalContext* globalCtx, s16 arg2) { - f32 tempOne = 1.0f; +/** + * Summary: instead of using SkelAnime animations, Niw modifies head+wings directly to create animations + * + * AttackNiw has a copy of this function that it barely uses + */ +void EnNiw_AnimateWingHead(EnNiw* this, GlobalContext* globalCtx, s16 animationState) { + f32 tempOne = 1.0f; // hopefully fake match, but no luck if (this->unkTimer24C == 0) { - if (arg2 == 0) { - this->unk264[0] = 0.0f; + // targetLimbRots[0] is bodyRotY + if (animationState == NIW_ANIMATION_STILL) { + this->targetLimbRots[0] = 0.0f; } else { - this->unk264[0] = (-10000.0f) * tempOne; + this->targetLimbRots[0] = -10000.0f * tempOne; } + this->unk292 += 1; this->unkTimer24C = 3; if ((this->unk292 % 2) == 0) { - this->unk264[0] = 0.0f; - if (arg2 == 0) { + this->targetLimbRots[0] = 0.0f; + if (animationState == NIW_ANIMATION_STILL) { this->unkTimer24C = Rand_ZeroFloat(30.0f); } } } + if (this->unkTimer24E == 0) { - this->unk296++; - this->unk296 &= 1; - switch (arg2) { - case 0: - this->unk264[2] = 0.0f; - this->unk264[1] = 0.0f; + this->unkToggle296++; + this->unkToggle296 &= 1; + + switch (animationState) { + case NIW_ANIMATION_STILL: + this->targetLimbRots[2] = 0.0f; // both wingRotZ + this->targetLimbRots[1] = 0.0f; break; - case 1: + case NIW_ANIMATION_HEAD_PECKING: this->unkTimer24E = 3; - this->unk264[2] = 7000.0f * tempOne; - this->unk264[1] = 7000.0f * tempOne; - if (this->unk296 == 0) { - this->unk264[2] = 0.0f; - this->unk264[1] = 0.0f; + this->targetLimbRots[2] = 7000.0f * tempOne; // both wingRotZ + this->targetLimbRots[1] = 7000.0f * tempOne; + if (this->unkToggle296 == 0) { + this->targetLimbRots[2] = 0.0f; // both wingRotZ + this->targetLimbRots[1] = 0.0f; } break; - case 2: + + case NIW_ANIMATION_PECKING_AND_WAVING: this->unkTimer24E = 2; - this->unk264[2] = -10000.0f; - this->unk264[1] = -10000.0f; - this->unk264[7] = 25000.0f; - this->unk264[5] = 25000.0f; - this->unk264[8] = 6000.0f; - this->unk264[6] = 6000.0f; - if (this->unk296 == 0) { - this->unk264[7] = 8000.0f; - this->unk264[5] = 8000.0f; + this->targetLimbRots[2] = -10000.0f; // both wingRotZ + this->targetLimbRots[1] = -10000.0f; + this->targetLimbRots[7] = 25000.0f; // both wingRotY + this->targetLimbRots[5] = 25000.0f; + this->targetLimbRots[8] = 6000.0f; // both wingRotX + this->targetLimbRots[6] = 6000.0f; + if (this->unkToggle296 == 0) { + this->targetLimbRots[7] = 8000.0f; // both wingRotY + this->targetLimbRots[5] = 8000.0f; } break; - case 3: + + case NIW_ANIMATION_PECKING_AND_FORFLAPPING: this->unkTimer24E = 2; - this->unk264[5] = 10000.0f; - this->unk264[7] = 10000.0f; - if (this->unk296 == 0) { - this->unk264[5] = 3000.0f; - this->unk264[7] = 3000.0f; + this->targetLimbRots[5] = 10000.0f; // both wingRotY + this->targetLimbRots[7] = 10000.0f; + if (this->unkToggle296 == 0) { + this->targetLimbRots[5] = 3000.0f; // both wingRotY + this->targetLimbRots[7] = 3000.0f; } break; - case 4: + + case NIW_ANIMATION_FREEZE: this->unkTimer24C = 5; break; - case 5: + + case NIW_ANIMATION_PECKING_SLOW_FORFLAPPING: this->unkTimer24E = 5; - this->unk264[5] = 14000.0f; - this->unk264[7] = 14000.0f; - if (this->unk296 == 0) { - this->unk264[5] = 10000.0f; - this->unk264[7] = 10000.0f; + this->targetLimbRots[5] = 14000.0f; // both wingRotY + this->targetLimbRots[7] = 14000.0f; + if (this->unkToggle296 == 0) { + this->targetLimbRots[5] = 10000.0f; // both wingRotY + this->targetLimbRots[7] = 10000.0f; } break; } } - if (this->unk264[9] != this->limbFRot) { - Math_ApproachF(&this->limbFRot, this->unk264[9], 0.5f, 4000.0f); + + if (this->targetLimbRots[9] != this->headRotY) { + Math_ApproachF(&this->headRotY, this->targetLimbRots[9], 0.5f, 4000.0f); } - if (this->unk264[0] != this->limbDRot) { - Math_ApproachF(&this->limbDRot, this->unk264[0], 0.5f, 4000.0f); + if (this->targetLimbRots[0] != this->upperBodyRotY) { + Math_ApproachF(&this->upperBodyRotY, this->targetLimbRots[0], 0.5f, 4000.0f); } - if (this->unk264[2] != this->limb7Rotz) { - Math_ApproachF(&this->limb7Rotz, this->unk264[2], 0.8f, 7000.0f); + if (this->targetLimbRots[2] != this->leftWingRotZ) { + Math_ApproachF(&this->leftWingRotZ, this->targetLimbRots[2], 0.8f, 7000.0f); } - if (this->unk264[7] != this->limb7Roty) { - Math_ApproachF(&this->limb7Roty, this->unk264[7], 0.8f, 7000.0f); + if (this->targetLimbRots[7] != this->leftWingRotY) { + Math_ApproachF(&this->leftWingRotY, this->targetLimbRots[7], 0.8f, 7000.0f); } - if (this->unk264[8] != this->limb7Rotx) { - Math_ApproachF(&this->limb7Rotx, this->unk264[8], 0.8f, 7000.0f); + if (this->targetLimbRots[8] != this->leftWingRotX) { + Math_ApproachF(&this->leftWingRotX, this->targetLimbRots[8], 0.8f, 7000.0f); } - if (this->unk264[1] != this->limbBRotz) { - Math_ApproachF(&this->limbBRotz, this->unk264[1], 0.8f, 7000.0f); + if (this->targetLimbRots[1] != this->rightWingRotZ) { + Math_ApproachF(&this->rightWingRotZ, this->targetLimbRots[1], 0.8f, 7000.0f); } - if (this->unk264[5] != this->limbBRoty) { - Math_ApproachF(&this->limbBRoty, this->unk264[5], 0.8f, 7000.0f); + if (this->targetLimbRots[5] != this->rightWingRotY) { + Math_ApproachF(&this->rightWingRotY, this->targetLimbRots[5], 0.8f, 7000.0f); } - if (this->unk264[6] != this->limbBRotx) { - Math_ApproachF(&this->limbBRotx, this->unk264[6], 0.8f, 7000.0f); + if (this->targetLimbRots[6] != this->rightWingRotX) { + Math_ApproachF(&this->rightWingRotX, this->targetLimbRots[6], 0.8f, 7000.0f); } } @@ -270,7 +295,7 @@ void EnNiw_SpawnAttackNiw(EnNiw* this, GlobalContext* globalCtx) { Vec3f newNiwPos; Actor* attackNiw; - if ((this->unkTimer252 == 0) && (this->unk290 < 7)) { + if (this->attackNiwSpawnTimer == 0 && this->attackNiwCount < 7) { xView = globalCtx->view.at.x - globalCtx->view.eye.x; yView = globalCtx->view.at.y - globalCtx->view.eye.y; zView = globalCtx->view.at.z - globalCtx->view.eye.z; @@ -278,54 +303,57 @@ void EnNiw_SpawnAttackNiw(EnNiw* this, GlobalContext* globalCtx) { newNiwPos.y = randPlusMinusPoint5Scaled(0.3f) + (globalCtx->view.eye.y + 50.0f + (yView * 0.5f)); newNiwPos.z = ((Rand_ZeroOne() - 0.5f) * zView) + globalCtx->view.eye.z; attackNiw = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ATTACK_NIW, newNiwPos.x, - newNiwPos.y, newNiwPos.z, 0, 0, 0, 0); + newNiwPos.y, newNiwPos.z, 0, 0, 0, ATTACK_NIW_REGULAR); - if (attackNiw) { - this->unk290++; - this->unkTimer252 = 10; + if (attackNiw != NULL) { + this->attackNiwCount++; + this->attackNiwSpawnTimer = 10; } } } -void func_808917F8(EnNiw* this, GlobalContext* globalCtx, s32 arg2) { - f32 phi_f2; +void EnNiw_UpdateRunning(EnNiw* this, GlobalContext* globalCtx, s32 isStormCucco) { + f32 runningDirection; f32 targetRotY; - f32* D_8089348CPtr = D_80893486; + f32* runningAngles = sRunningAngles; - if (this->unkTimer250 == 0) { - this->unkTimer250 = 3; - if (this->actor.bgCheckFlags & 1) { - // hit floor - this->actor.velocity.y = 3.5f; // hop up? + if (this->hopTimer == 0) { + this->hopTimer = 3; + if (this->actor.bgCheckFlags & 1) { // hit floor + this->actor.velocity.y = 3.5f; // hopping up while running away } } - if (this->unkTimer252 == 0) { - this->unk29A++; - this->unk29A &= 1; - this->unkTimer252 = 5; + + if (this->runningDirectionTimer == 0) { + this->isRunningRight++; + this->isRunningRight &= 1; + this->runningDirectionTimer = 5; } - if (this->unk29A == 0) { - phi_f2 = D_8089348CPtr[arg2]; + + if (this->isRunningRight == false) { + runningDirection = runningAngles[isStormCucco]; } else { - phi_f2 = -D_8089348CPtr[arg2]; + runningDirection = -runningAngles[isStormCucco]; } - if (arg2 == 1 && (this->unkTimer254 == 0 || (this->actor.bgCheckFlags & 8))) { - this->unkTimer254 = 150; + + if (isStormCucco == true && + (this->runAwayTimer == 0 || (this->actor.bgCheckFlags & 8))) { // bgCheckFlags 8: hit a wall + this->runAwayTimer = 150; if (this->yawTimer == 0) { this->yawTimer = 70; this->yawTowardsPlayer = this->actor.yawTowardsPlayer; } } - targetRotY = this->yawTowardsPlayer + phi_f2; + + targetRotY = this->yawTowardsPlayer + runningDirection; Math_SmoothStepToS(&this->actor.world.rot.y, targetRotY, 3, this->unk300, 0); Math_ApproachF(&this->unk300, 3000.0f, 1.0f, 500.0f); - func_80891320(this, globalCtx, 5); + EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_SLOW_FORFLAPPING); } void EnNiw_SetupIdle(EnNiw* this) { - Animation_Change(&this->skelanime, &object_niw_Anim_0000E8, 1.0f, 0.0f, - Animation_GetLastFrame(&object_niw_Anim_0000E8), 0, -10.0f); - this->unknownState28E = 0; + Animation_Change(&this->skelanime, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), 0, -10.0f); + this->niwState = NIW_STATE_IDLE; this->actionFunc = EnNiw_Idle; } @@ -334,40 +362,39 @@ void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { f32 posZ2; f32 posX1 = randPlusMinusPoint5Scaled(100.0f); f32 posZ1 = randPlusMinusPoint5Scaled(100.0f); - s16 s16tmp; + s16 nextAnimation; - if (this->niwType == ENNIW_TYPE_REGULAR) { - if (Actor_HasParent(&this->actor, globalCtx)) { - // picked up + if (this->niwType == NIW_TYPE_REGULAR) { + if (Actor_HasParent(&this->actor, globalCtx)) { // picked up Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; - this->unkTimer250 = 30; + this->heldTimer = 30; this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF - this->unknownState28E = 4; + this->niwState = NIW_STATE_HELD; this->actor.speedXZ = 0.0f; this->actionFunc = EnNiw_Held; return; } else { Actor_LiftActor(&this->actor, globalCtx); } - } else { - this->unkTimer252 = 10; + } else { // NIW_TYPE_UNK1 || NIW_TYPE_HELD + this->unkIdleTimer2 = 10; } - s16tmp = 0; - if (this->unkTimer252 != 0) { + nextAnimation = NIW_ANIMATION_STILL; // probably a scoped variable here, where their scope was different + if (this->unkIdleTimer2 != 0) { if (Rand_ZeroFloat(3.99f) < 1.0f) { - this->unk2EA++; - this->unk2EA &= 1; + this->headRotationToggle++; + this->headRotationToggle &= 1; } - Math_ApproachF(&this->unk264[9], D_80893484[this->unk2EA], 0.5f, 4000.0f); + + Math_ApproachF(&this->targetLimbRots[9], sHeadRotations[this->headRotationToggle], 0.5f, 4000.0f); // head rot } - if ((this->unkTimer252 == 0) && (this->unkTimer250 == 0)) { + if (this->unkIdleTimer2 == 0 && this->unkIdleTimer == 0) { this->unk298++; - if (this->unk298 > 7) { - this->unkTimer252 = Rand_ZeroFloat(30.0f); + this->unkIdleTimer2 = Rand_ZeroFloat(30.0f); this->unk298 = Rand_ZeroFloat(3.99f); if (posX1 < 0.0f) { @@ -385,17 +412,17 @@ void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { this->unk2B0.z = this->unk2A4.z + posZ1; } else { - this->unkTimer250 = 4; - if (this->actor.bgCheckFlags & 1) { + this->unkIdleTimer = 4; + if (this->actor.bgCheckFlags & 1) { // hit floor this->actor.speedXZ = 0.0f; - this->actor.velocity.y = 3.5f; + this->actor.velocity.y = 3.5f; // hopping up and down } } } - if (this->unkTimer250 != 0) { - Math_ApproachZeroF(&this->unk264[9], 0.5f, 4000.0f); - s16tmp = 1; + if (this->unkIdleTimer != 0) { + Math_ApproachZeroF(&this->targetLimbRots[9], 0.5f, 4000.0f); // head rot + nextAnimation = NIW_ANIMATION_HEAD_PECKING; Math_ApproachF(&this->actor.world.pos.x, this->unk2B0.x, 1.0f, this->unk300); Math_ApproachF(&this->actor.world.pos.z, this->unk2B0.z, 1.0f, this->unk300); Math_ApproachF(&this->unk300, 3.0f, 1.0f, 0.3f); @@ -411,33 +438,34 @@ void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { } if ((posX2 == 0.0f) && (posZ2 == 0.0f)) { - this->unkTimer250 = 0; + this->unkIdleTimer = 0; this->unk298 = 7; } Math_SmoothStepToS(&this->actor.world.rot.y, Math_Atan2S(posX2, posZ2), 3, this->unk304, 0); Math_ApproachF(&this->unk304, 10000.0f, 1.0f, 1000.0f); } - func_80891320(this, globalCtx, s16tmp); + + EnNiw_AnimateWingHead(this, globalCtx, nextAnimation); } void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx) { Vec3f vec3fcopy = D_808934DC; s16 rotZ; - if (this->unkTimer250 == 0) { + if (this->heldTimer == 0) { this->unk29E = 2; - this->unkTimer250 = (s32)(Rand_ZeroFloat(1.0f) * 10.0f) + 10; + this->heldTimer = (s32)(Rand_ZeroFloat(1.0f) * 10.0f) + 10; } this->actor.shape.rot.x = (s16)randPlusMinusPoint5Scaled(5000.0f) + this->actor.world.rot.x; this->actor.shape.rot.y = (s16)randPlusMinusPoint5Scaled(5000.0f) + this->actor.world.rot.y; this->actor.shape.rot.z = (s16)randPlusMinusPoint5Scaled(5000.0f) + this->actor.world.rot.z; - if (this->niwType == ENNIW_TYPE_REGULAR) { + if (this->niwType == NIW_TYPE_REGULAR) { if (Actor_HasNoParent(&this->actor, globalCtx)) { this->actor.shape.rot.z = 0; rotZ = this->actor.shape.rot.z; - this->unknownState28E = 5; + this->niwState = NIW_STATE_FALLING; this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnNiw_Thrown; this->actor.shape.rot.y = rotZ; @@ -449,9 +477,9 @@ void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx) { this->actor.velocity.y = 8.0f; this->actor.speedXZ = 4.0f; this->actor.gravity = -2.0f; - this->unknownState28E = 5; + this->niwState = NIW_STATE_FALLING; this->unk2EC = 0; - this->niwType = ENNIW_TYPE_REGULAR; + this->niwType = NIW_TYPE_REGULAR; this->actor.shape.rot.y = rotZ; this->actor.shape.rot.x = rotZ; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -459,29 +487,29 @@ void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnNiw_Thrown; } - func_80891320(this, globalCtx, 2); + + EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); } -// action function: recently thrown, and also hopping on the floor void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx) { if (this->unk2EC == 0) { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & 1) { // hit floor this->unk2EC = 1; - this->unkTimer252 = 80; // hop timer + this->hoppingTimer = 80; // hop timer this->actor.speedXZ = 0.0f; this->actor.velocity.y = 4.0f; } else { return; // wait until back on floor } } else { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & 1) { // hit floor this->sfxTimer1 = 0; this->actor.velocity.y = 4.0f; // vertical hop this->unk29E = 1; } - if (this->unkTimer252 == 0) { - this->unkTimer254 = 100; - this->unkTimer250 = 0; + if (this->hoppingTimer == 0) { + this->runAwayTimer = 100; + this->heldTimer = 0; this->unk2EC = 0; EnNiw_SetupRunAway(this); return; @@ -493,20 +521,19 @@ void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; this->unk2EC = 0; - this->unkTimer250 = 30; + this->heldTimer = 30; this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF - this->unknownState28E = 4; + this->niwState = NIW_STATE_HELD; this->actionFunc = EnNiw_Held; this->actor.speedXZ = 0.0f; } else { - if (this->unkTimer252 > 5) { + if (this->hoppingTimer > 5) { Actor_LiftActor(&this->actor, globalCtx); } - func_80891320(this, globalCtx, 2); + EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); } } -// action func: swimming and flying away after swimming void EnNiw_Swimming(EnNiw* this, GlobalContext* globalCtx) { Vec3f ripplePos; @@ -517,73 +544,74 @@ void EnNiw_Swimming(EnNiw* this, GlobalContext* globalCtx) { } this->actor.speedXZ = 2.0f; - if (this->actor.bgCheckFlags & 0x20) { - // still touching water + if (this->actor.bgCheckFlags & 0x20) { // touching water this->actor.gravity = 0.0f; if (this->actor.depthInWater > 15.0f) { this->actor.world.pos.y += 2.0f; } - if (this->unkTimer250 == 0) { - this->unkTimer250 = 30; + if (this->swimRippleTimer == 0) { + this->swimRippleTimer = 30; Math_Vec3f_Copy(&ripplePos, &this->actor.world.pos); ripplePos.y += this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &ripplePos, 100, 500, 30); } - if (this->actor.bgCheckFlags & 8) { - this->actor.velocity.y = 10.0f; + if (this->actor.bgCheckFlags & 8) { // hit a wall + this->actor.velocity.y = 10.0f; // fly up in straight line this->actor.speedXZ = 1.0f; } } else { this->actor.gravity = -2.0f; - if (this->actor.bgCheckFlags & 8) { - // has hit a wall - this->actor.velocity.y = 10.0f; // to the moon + if (this->actor.bgCheckFlags & 8) { // hit a wall + this->actor.velocity.y = 10.0f; // fly up in straight line this->actor.speedXZ = 1.0f; this->actor.gravity = 0.0f; } else { this->actor.speedXZ = 4.0f; } - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & 1) { // hit floor this->actor.gravity = -2.0f; - this->unkTimer254 = 100; - this->unkTimer250 = 0; + this->runAwayTimer = 100; + this->swimRippleTimer = 0; this->actor.velocity.y = 0.0f; if (!this->isStormActive) { EnNiw_SetupRunAway(this); } else { - this->unknownState28E = 3; + this->niwState = NIW_STATE_ANGRY3; this->actionFunc = EnNiw_CuccoStorm; } } } - func_80891320(this, globalCtx, 2); + + EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); } void EnNiw_Trigger(EnNiw* this, GlobalContext* globalCtx) { - s32 value; + s32 state; + + // Possible Fake Match: the weird way this state is set if (1) { - value = 1; + state = NIW_STATE_ANGRY1; } - this->unkTimer252 = 10; - this->unknownState28E = this->unk29C = value; + this->cuccoStormTimer = 10; + this->niwState = this->nextAnimation = state; // NIW_ANIMATION_HEAD_PECKING this->actionFunc = EnNiw_Upset; } void EnNiw_Upset(EnNiw* this, GlobalContext* globalCtx) { // assumption: CuccoStorm is split into smaller parts because it used to be a cutscene in OOT this->sfxTimer1 = 100; - if (this->unkTimer252 == 0) { - this->unkTimer252 = 60; + if (this->cuccoStormTimer == 0) { + this->cuccoStormTimer = 60; this->unkTimer24C = 10; - this->unk29C = 4; - this->unknownState28E = 2; + this->nextAnimation = NIW_ANIMATION_FREEZE; + this->niwState = NIW_STATE_ANGRY2; this->actionFunc = EnNiw_SetupCuccoStorm; } - func_80891320(this, globalCtx, this->unk29C); + EnNiw_AnimateWingHead(this, globalCtx, this->nextAnimation); } // the long crow with head back before they descend @@ -591,45 +619,46 @@ void EnNiw_SetupCuccoStorm(EnNiw* this, GlobalContext* globalCtx) { f32 viewY; this->sfxTimer1 = 100; - if (this->unkTimer252 == 40) { + if (this->cuccoStormTimer == 40) { viewY = 14000.0f; - this->unk264[0] = 10000.0f; - this->unk264[7] = this->unk264[5] = viewY; - this->unk264[6] = 0.0f; - this->unk264[8] = 0.0f; - this->unk264[1] = 0.0f; - this->unk264[2] = 0.0f; + this->targetLimbRots[0] = 10000.0f; // body rot + this->targetLimbRots[7] = this->targetLimbRots[5] = viewY; + this->targetLimbRots[6] = 0.0f; + this->targetLimbRots[8] = 0.0f; + this->targetLimbRots[1] = 0.0f; + this->targetLimbRots[2] = 0.0f; this->unkTimer24C = 10; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); } - if (this->unkTimer252 == 0) { - this->unkTimer252 = 10; + + if (this->cuccoStormTimer == 0) { + this->cuccoStormTimer = 10; this->yawTowardsPlayer = this->actor.yawTowardsPlayer; this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF - this->unknownState28E = 3; + this->niwState = NIW_STATE_ANGRY3; this->actionFunc = EnNiw_CuccoStorm; } - func_80891320(this, globalCtx, this->unk29C); + + EnNiw_AnimateWingHead(this, globalCtx, this->nextAnimation); } void EnNiw_CuccoStorm(EnNiw* this, GlobalContext* globalCtx) { EnNiw_SpawnAttackNiw(this, globalCtx); - if (this->unkTimer252 == 1) { + if (this->cuccoStormTimer == 1) { // not countdown to 0? mistype? this->actor.speedXZ = 3.0f; - this->unk29A = Rand_ZeroFloat(1.99f); - this->unkTimer250 = 0; - this->unkTimer24E = this->unkTimer250; - this->unkTimer24C = this->unkTimer250; + this->isRunningRight = Rand_ZeroFloat(1.99f); + this->generalTimer1 = 0; + this->unkTimer24E = this->generalTimer1; + this->unkTimer24C = this->generalTimer1; } else { - func_808917F8(this, globalCtx, 1); + EnNiw_UpdateRunning(this, globalCtx, true); } } void EnNiw_SetupRunAway(EnNiw* this) { - Animation_Change(&this->skelanime, &object_niw_Anim_0000E8, 1.0f, 0.0f, - Animation_GetLastFrame(&object_niw_Anim_0000E8), 0, -10.0f); - this->unk29A = Rand_ZeroFloat(1.99f); - this->unknownState28E = 7; + Animation_Change(&this->skelanime, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), 0, -10.0f); + this->isRunningRight = Rand_ZeroFloat(1.99f); + this->niwState = NIW_STATE_RUNNING; this->actionFunc = EnNiw_RunAway; this->actor.speedXZ = 4.0f; } @@ -641,22 +670,21 @@ void EnNiw_RunAway(EnNiw* this, GlobalContext* globalCtx) { f32 dX; f32 dZ; - if (this->unkTimer254 == 0) { + if (this->runAwayTimer == 0) { this->unk2A4.x = this->unk2B0.x = this->actor.world.pos.x; this->unk2A4.y = this->unk2B0.y = this->actor.world.pos.y; this->unk2A4.z = this->unk2B0.z = this->actor.world.pos.z; - - this->unkTimer252 = this->unkTimer250 = this->unk298 = 0; + this->generalTimer2 = this->generalTimer1 = this->unk298 = 0; this->unk300 = this->unk304 = 0; - this->actor.speedXZ = 0; - - this->unk264[8] = 0; - this->unk264[6] = 0; - this->unk264[5] = 0; - this->unk264[7] = 0; + this->targetLimbRots[8] = 0; + this->targetLimbRots[6] = 0; + this->targetLimbRots[5] = 0; + this->targetLimbRots[7] = 0; Math_Vec3f_Copy(&this->unk2BC, &tempVec3f); + EnNiw_SetupIdle(this); + } else { if (this->unk2BC.x != 90000.0f) { dX = this->actor.world.pos.x - this->unk2BC.x; @@ -666,25 +694,27 @@ void EnNiw_RunAway(EnNiw* this, GlobalContext* globalCtx) { dZ = this->actor.world.pos.z - player->actor.world.pos.z; } this->yawTowardsPlayer = Math_Atan2S(dX, dZ); - func_808917F8(this, globalCtx, 0); - func_80891320(this, globalCtx, 2); + EnNiw_UpdateRunning(this, globalCtx, false); + EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); } } void EnNiw_LandBeforeIdle(EnNiw* this, GlobalContext* globalCtx) { - if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & 1) { // hit floor EnNiw_SetupIdle(this); } } void EnNiw_CheckRage(EnNiw* this, GlobalContext* globalCtx) { - if (!this->isStormActive && (this->unkTimer260 == 0) && (this->niwType == ENNIW_TYPE_REGULAR)) { - if ((this->unknownState28E != 7) && (this->unk2BC.x != 90000.0f)) { - this->unkTimer260 = 10; + if (!this->isStormActive && this->iframeTimer == 0 && this->niwType == NIW_TYPE_REGULAR) { + + // is this used? this is before we even know if we've been hit + if (this->niwState != NIW_STATE_RUNNING && this->unk2BC.x != 90000.0f) { + this->iframeTimer = 10; this->sfxTimer1 = 30; this->unk29E = 1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow - this->unkTimer254 = 100; + this->runAwayTimer = 100; this->unk2EC = 0; EnNiw_SetupRunAway(this); } @@ -696,32 +726,32 @@ void EnNiw_CheckRage(EnNiw* this, GlobalContext* globalCtx) { this->actor.colChkInfo.health--; } - if ((!D_80893460) && (this->actor.colChkInfo.health == 0)) { - // now you've done it - this->unkTimer254 = 100; - D_80893460 = true; + if (!sCuccoStormActive && this->actor.colChkInfo.health == 0) { + this->runAwayTimer = 100; // main cucco will run away after storm starts + sCuccoStormActive = true; this->unk298 = 0; this->sfxTimer1 = 10000; this->unk2A4.x = this->unk2B0.x = this->actor.world.pos.x; this->unk2A4.y = this->unk2B0.y = this->actor.world.pos.y; this->unk2A4.z = this->unk2B0.z = this->actor.world.pos.z; - this->unkTimer252 = this->unkTimer250 = this->unk298; + this->generalTimer2 = this->generalTimer1 = this->unk298; - this->unk264[8] = 0.0f; - this->unk264[6] = 0.0f; - this->unk264[5] = 0.0f; - this->unk264[7] = 0.0f; + this->targetLimbRots[8] = 0.0f; + this->targetLimbRots[6] = 0.0f; + this->targetLimbRots[5] = 0.0f; + this->targetLimbRots[7] = 0.0f; this->isStormActive = true; this->actionFunc = EnNiw_Trigger; this->unk304 = 0.0f; this->unk300 = 0.0f; this->actor.speedXZ = 0.0f; + } else { - this->unkTimer260 = 10; + this->iframeTimer = 10; this->sfxTimer1 = 30; this->unk29E = 1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow - this->unkTimer254 = 100; + this->runAwayTimer = 100; this->unk2EC = 0; EnNiw_SetupRunAway(this); } @@ -737,10 +767,9 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { s16 pad1; s16 featherCount; Vec3f pos; - Vec3f spB8; - Vec3f spAC; - s32 pad2[9]; - s16 temp29C; + Vec3f vel; + Vec3f accel; + s32 pad2[10]; f32 featherScale; f32 viewAtToEyeNormY; f32 floorHeight; @@ -749,16 +778,16 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { this->unusedCounter28C++; - if (this->niwType == ENNIW_TYPE_UNK1) { + if (this->niwType == NIW_TYPE_UNK1) { this->actor.shape.rot.y = this->actor.world.rot.y = this->actor.parent->shape.rot.y; } - if (this->unknownState28E != 0) { - this->unk264[9] = 0.0f; + if (this->niwState != NIW_STATE_IDLE) { + this->targetLimbRots[9] = 0.0f; // head rot } if (this->unk29E != 0) { - featherCount = ENNIW_FEATHERCOUNT; + featherCount = NIW_FEATHER_COUNT; if (this->unk29E == 2) { featherCount = 4; } @@ -768,20 +797,20 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { pos.z = randPlusMinusPoint5Scaled(10.0f) + this->actor.world.pos.z; featherScale = Rand_ZeroFloat(6.0f) + 6.0f; - if ((this->unk29E == 2) && (this->unk308 != 0)) { + if (this->unk29E == 2 && this->unk308 != 0) { pos.y += 10.0f; } if (this->unk308 == 0) { featherScale = Rand_ZeroFloat(2.0f) + 2.0f; } - spB8.x = randPlusMinusPoint5Scaled(3.0f); - spB8.y = (Rand_ZeroFloat(2.0f) * 0.5f) + 2.0f; - spB8.z = randPlusMinusPoint5Scaled(3.0f); - spAC.z = spAC.x = 0.0f; - spAC.y = -0.15000000596f; + vel.x = randPlusMinusPoint5Scaled(3.0f); + vel.y = Rand_ZeroFloat(2.0f) * 0.5f + 2.0f; + vel.z = randPlusMinusPoint5Scaled(3.0f); + accel.z = accel.x = 0.0f; + accel.y = -0.15f; - EnNiw_SpawnFeather(this, &pos, &spB8, &spAC, featherScale); + EnNiw_SpawnFeather(this, &pos, &vel, &accel, featherScale); } this->unk29E = 0; } @@ -790,15 +819,15 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { DECR(this->unkTimer24C); DECR(this->unkTimer24E); - DECR(this->unkTimer250); - DECR(this->unkTimer252); - DECR(this->unkTimer254); + DECR(this->generalTimer1); + DECR(this->generalTimer2); + DECR(this->runAwayTimer); DECR(this->sfxTimer1); DECR(this->flutterSfxTimer); DECR(this->unusedTimer25A); DECR(this->yawTimer); - DECR(this->unusedTimer25E); - DECR(this->unkTimer260); + DECR(this->unkAttackNiwTimer); + DECR(this->iframeTimer); this->actor.shape.rot = this->actor.world.rot; this->actor.shape.shadowScale = 15.0f; @@ -808,7 +837,7 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1F); - // if cucco is off the map? + // if cucco is off the map if (this->actor.floorHeight <= BGCHECK_Y_MIN || this->actor.floorHeight >= BGCHECK_Y_MAX) { Vec3f viewAtToEye; @@ -820,7 +849,7 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.x = this->actor.home.pos.x; this->actor.world.pos.z = this->actor.home.pos.z; - this->actor.world.pos.y = (this->actor.home.pos.y + globalCtx->view.eye.y) + (viewAtToEyeNormY * 160.0f); + this->actor.world.pos.y = this->actor.home.pos.y + globalCtx->view.eye.y + (viewAtToEyeNormY * 160.0f); if (this->actor.world.pos.y < this->actor.home.pos.y) { this->actor.world.pos.y = this->actor.home.pos.y + 300.0f; @@ -833,75 +862,74 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk304 = 0.0f; this->unk300 = 0.0f; - this->unusedFloat2FC = 0.0f; + this->unusedFloat2FC = 0.0f; // assigned here but never used after this->unusedFloat2F8 = 0.0f; this->unusedFloat2F4 = 0.0f; - this->limbBRotx = 0.0f; - this->limbBRoty = 0.0f; - this->limbBRotz = 0.0f; - this->limb7Rotx = 0.0f; - this->limb7Roty = 0.0f; - this->limb7Rotz = 0.0f; - this->limbDRot = 0.0f; - this->limbFRot = 0.0f; + this->rightWingRotX = 0.0f; + this->rightWingRotY = 0.0f; + this->rightWingRotZ = 0.0f; + this->leftWingRotX = 0.0f; + this->leftWingRotY = 0.0f; + this->leftWingRotZ = 0.0f; + this->upperBodyRotY = 0.0f; + this->headRotY = 0.0f; // clang-format off - this->isStormActive = this->unusedCounter28C = this->unk292 = this->unk29E = this->unk298 = this->unk29A = this->unk29C = 0; + this->isStormActive = this->unusedCounter28C = this->unk292 = this->unk29E = this->unk298 = this->isRunningRight = this->nextAnimation = 0; // clang-format on for (i = 0; i < 10; i++) { - this->unk264[i] = 0.0f; + this->targetLimbRots[i] = 0.0f; } - this->unknownState28E = 8; + this->niwState = NIW_STATE_HOPPING; this->isStormActive = false; this->actionFunc = EnNiw_LandBeforeIdle; return; + } - } else if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 15.0f) && - (this->unknownState28E != 6)) { + if ((this->actor.bgCheckFlags & 0x20) && // touching water + this->actor.depthInWater > 15.0f && this->niwState != NIW_STATE_SWIMMING) { this->actor.velocity.y = 0.0f; this->actor.gravity = 0.0f; Math_Vec3f_Copy(&pos, &this->actor.world.pos); pos.y += this->actor.depthInWater; - this->unkTimer250 = 30; + this->swimRippleTimer = 30; EffectSsGSplash_Spawn(globalCtx, &pos, 0, 0, 0, 400); - this->unkTimer252 = 0; - this->unknownState28E = 6; + this->generalTimer2 = 0; + this->niwState = NIW_STATE_SWIMMING; this->actionFunc = EnNiw_Swimming; + return; + } - } else { - if (this->isStormActive && (this->actor.xyzDistToPlayerSq < (SQ(dist))) && (player->invincibilityTimer == 0)) { - func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); + if (this->isStormActive && (this->actor.xyzDistToPlayerSq < SQ(dist)) && player->invincibilityTimer == 0) { + func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); + } + + EnNiw_CheckRage(this, globalCtx); + if (this->flutterSfxTimer == 0 && this->niwState == NIW_STATE_HELD) { + this->flutterSfxTimer = 7; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); + } + + if (this->sfxTimer1 == 0) { + if (this->niwState != NIW_STATE_IDLE) { + this->sfxTimer1 = 30; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_A); + } else { + this->sfxTimer1 = 300; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_N); } + } - EnNiw_CheckRage(this, globalCtx); - if ((this->flutterSfxTimer == 0) && (this->unknownState28E == 4)) { - this->flutterSfxTimer = 7; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); - } + if (!this->isStormActive && this->niwType == NIW_TYPE_REGULAR) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->sfxTimer1 == 0) { - if (this->unknownState28E != 0) { - this->sfxTimer1 = 30; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_A); // attack cluck - } else { - this->sfxTimer1 = 300; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_N); // cluck - } - } + if (globalCtx) {} - if (!this->isStormActive) { - if (this->niwType == ENNIW_TYPE_REGULAR) { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - - if (globalCtx) {} - - if ((this->unknownState28E != 4) && (this->unknownState28E != 5)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - } + if (this->niwState != NIW_STATE_HELD && this->niwState != NIW_STATE_FALLING) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } } } @@ -909,21 +937,21 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { s32 EnNiw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnNiw* this = THIS; - if (limbIndex == 13) { - rot->y += (s16)this->limbDRot; + if (limbIndex == NIW_LIMB_UPPER_BODY) { + rot->y += (s16)this->upperBodyRotY; } - if (limbIndex == 15) { - rot->y += (s16)this->limbFRot; + if (limbIndex == NIW_LIMB_HEAD) { + rot->y += (s16)this->headRotY; } - if (limbIndex == 11) { - rot->x += (s16)this->limbBRotx; - rot->y += (s16)this->limbBRoty; - rot->z += (s16)this->limbBRotz; + if (limbIndex == NIW_LIMB_RIGHT_WING_ROOT) { + rot->x += (s16)this->rightWingRotX; + rot->y += (s16)this->rightWingRotY; + rot->z += (s16)this->rightWingRotZ; } - if (limbIndex == 7) { - rot->x += (s16)this->limb7Rotx; - rot->y += (s16)this->limb7Roty; - rot->z += (s16)this->limb7Rotz; + if (limbIndex == NIW_LIMB_LEFT_WING_ROOT) { + rot->x += (s16)this->leftWingRotX; + rot->y += (s16)this->leftWingRotY; + rot->z += (s16)this->leftWingRotZ; } return false; } @@ -939,7 +967,7 @@ void EnNiw_Draw(Actor* thisx, GlobalContext* globalCtx) { void EnNiw_SpawnFeather(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 scale) { s16 i; - EnNiwFeather* feather = this->feathers; + EnNiwFeather* feather = &this->feathers[0]; for (i = 0; i < ARRAY_COUNT(this->feathers); i++, feather++) { if (feather->isEnabled == false) { @@ -957,7 +985,7 @@ void EnNiw_SpawnFeather(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 s } void EnNiw_UpdateFeather(EnNiw* this, GlobalContext* globalCtx) { - EnNiwFeather* feather = this->feathers; + EnNiwFeather* feather = &this->feathers[0]; f32 featherVelocityGoal = 0.05f; s16 i; @@ -988,7 +1016,6 @@ void EnNiw_UpdateFeather(EnNiw* this, GlobalContext* globalCtx) { } } -// feather draw function void EnNiw_DrawFeathers(EnNiw* this, GlobalContext* globalCtx) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; u8 isMaterialApplied = false; diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.h b/src/overlays/actors/ovl_En_Niw/z_en_niw.h index 5a03215bc..7c8b3e07e 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.h +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.h @@ -2,6 +2,7 @@ #define Z_EN_NIW_H #include "global.h" +#include "objects/object_niw/object_niw.h" struct EnNiw; @@ -19,55 +20,67 @@ typedef struct { /* 0x0034 */ u8 timer; } EnNiwFeather; // size = 0x38 -#define ENNIW_LIMBCOUNT 16 -#define ENNIW_FEATHERCOUNT 20 +#define NIW_FEATHER_COUNT 20 typedef struct EnNiw { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelanime; - /* 0x188 */ Vec3s jointTable[ENNIW_LIMBCOUNT]; - /* 0x1E8 */ Vec3s morphTable[ENNIW_LIMBCOUNT]; + /* 0x188 */ Vec3s jointTable[NIW_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[NIW_LIMB_MAX]; /* 0x248 */ EnNiwActionFunc actionFunc; - /* 0x24C */ s16 unkTimer24C; + /* 0x24C */ s16 unkTimer24C; // set to 10, checked in mystery func /* 0x24E */ s16 unkTimer24E; - /* 0x250 */ s16 unkTimer250; - /* 0x252 */ s16 unkTimer252; - /* 0x254 */ s16 unkTimer254; + /* 0x250 */ union { + s16 generalTimer1; // default name for reset/decr + s16 hopTimer; // every 3 frames while running/idling + s16 swimRippleTimer; // how often swimming cucco spawns ripples + s16 heldTimer; // timer until updating unk29E + s16 unkIdleTimer; // not sure what _Idle is doing with it yet + }; + /* 0x252 */ union { + s16 generalTimer2; // default name for reset/decr + s16 hoppingTimer; // hopping after being thrown before running + s16 attackNiwSpawnTimer; // delay between re-attempting to spawn more attack_niw + s16 runningDirectionTimer; // delay between direction changes when running + s16 cuccoStormTimer; // delay between stages of summoning the storm + s16 unkIdleTimer2; // not sure what _Idle is doing with it yet + }; + /* 0x254 */ s16 runAwayTimer; /* 0x256 */ s16 sfxTimer1; /* 0x258 */ s16 flutterSfxTimer; /* 0x25A */ s16 unusedTimer25A; - /* 0x25C */ s16 yawTimer; // every 70 frames rechecks yawToPlayer - /* 0x25E */ s16 unusedTimer25E; - /* 0x260 */ s16 unkTimer260; - /* 0x264 */ f32 unk264[10]; + /* 0x25C */ s16 yawTimer; // every 70 frames rechecks yawToPlayer + /* 0x25E */ s16 unkAttackNiwTimer; // every 70 frames, updates some player unk values + /* 0x260 */ s16 iframeTimer; + /* 0x264 */ f32 targetLimbRots[10]; /* 0x28C */ s16 unusedCounter28C; - /* 0x28E */ s16 unknownState28E; - /* 0x290 */ s16 unk290; + /* 0x28E */ s16 niwState; + /* 0x290 */ s16 attackNiwCount; /* 0x292 */ s16 unk292; /* 0x294 */ s16 pad294; - /* 0x296 */ s16 unk296; + /* 0x296 */ s16 unkToggle296; /* 0x298 */ s16 unk298; - /* 0x29C */ s16 unk29A; - /* 0x29C */ u16 unk29C; - /* 0x29E */ s16 unk29E; - /* 0x2A0 */ s16 isStormActive; + /* 0x29C */ s16 isRunningRight; // toggle (direction cucco is turning while running) + /* 0x29C */ u16 nextAnimation; + /* 0x29E */ s16 unk29E; // three states 0/1/2 + /* 0x2A0 */ s16 isStormActive; // we have a data value shared between all cucco, this shouldn't need to exist /* 0x2A2 */ s16 niwType; /* 0x2A4 */ Vec3f unk2A4; /* 0x2B0 */ Vec3f unk2B0; - /* 0x2BC */ Vec3f unk2BC; - /* 0x2C8 */ f32 limb7Rotz; - /* 0x2CC */ f32 limb7Roty; - /* 0x2D0 */ f32 limb7Rotx; - /* 0x2D4 */ f32 limbBRotz; - /* 0x2D8 */ f32 limbBRoty; - /* 0x2DC */ f32 limbBRotx; - /* 0x2E0 */ f32 limbDRot; - /* 0x2E4 */ f32 limbFRot; + /* 0x2BC */ Vec3f unk2BC; // init from data (90000 on all three) + /* 0x2C8 */ f32 leftWingRotZ; + /* 0x2CC */ f32 leftWingRotY; + /* 0x2D0 */ f32 leftWingRotX; + /* 0x2D4 */ f32 rightWingRotZ; + /* 0x2D8 */ f32 rightWingRotY; + /* 0x2DC */ f32 rightWingRotX; + /* 0x2E0 */ f32 upperBodyRotY; + /* 0x2E4 */ f32 headRotY; /* 0x2E8 */ s16 yawTowardsPlayer; - /* 0x2EA */ s16 unk2EA; + /* 0x2EA */ s16 headRotationToggle; /* 0x2EC */ s16 unk2EC; /* 0x2EE */ UNK_TYPE1 pad2EE[0x6]; - /* 0x2F4 */ f32 unusedFloat2F4; + /* 0x2F4 */ f32 unusedFloat2F4; // set in EnNiw_Update if Cucco falls off map, never read /* 0x2F8 */ f32 unusedFloat2F8; /* 0x2FC */ f32 unusedFloat2FC; /* 0x300 */ f32 unk300; @@ -75,16 +88,26 @@ typedef struct EnNiw { /* 0x308 */ f32 unk308; /* 0x30C */ s32 pad30C; /* 0x310 */ ColliderCylinder collider; - /* 0x35C */ EnNiwFeather feathers[ENNIW_FEATHERCOUNT]; + /* 0x35C */ EnNiwFeather feathers[NIW_FEATHER_COUNT]; } EnNiw; // size = 0x7BC // in init, any value below zero becomes zero -// however, in vanilla, only 0xFFFF (-1) exists -#define ENNIW_TYPE_VANILLA 0xFFFF -#define ENNIW_TYPE_REGULAR 0 -#define ENNIW_TYPE_UNK1 1 -#define ENNIW_TYPE_UNK2 2 -// the attacking cuccos are not here, they are a different actor: -// ovl_En_Attack_Niw +// however, in vanilla, only 0xFFFF (-1) exists in scene spawns, actors can spawn 0x0 +#define NIW_TYPE_VANILLA 0xFFFF +#define NIW_TYPE_REGULAR 0 +#define NIW_TYPE_UNK1 1 +#define NIW_TYPE_HELD 2 // spawns held by the bomber kid in east clock town during hide and seek +// the attacking cuccos are not here, they are a different actor: [ ovl_En_Attack_Niw ] + +typedef enum { + /* 0 */ NIW_ANIMATION_STILL, + /* 1 */ NIW_ANIMATION_HEAD_PECKING, // forward and backward, feeding + /* 2 */ NIW_ANIMATION_PECKING_AND_WAVING, // wings move along their axis, like human hand waving + /* 3 */ NIW_ANIMATION_PECKING_AND_FORFLAPPING, // (unused) low (yaw based) flapping, forward and back + /* 4 */ NIW_ANIMATION_FREEZE, // used during Cucco Storm + /* 5 */ NIW_ANIMATION_PECKING_SLOW_FORFLAPPING, // wing speed half that of 3 + +} EnNiwHeadAndWingAnimationState; + #endif // Z_EN_NIW_H diff --git a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c index 4c0fdce1e..8d254b728 100644 --- a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c +++ b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c @@ -2,9 +2,14 @@ * File: z_en_nwc.c * Overlay: ovl_En_Nwc * Description: Cucco chick + * + * This actor requires object_niw to be present for the transformation during Breman Mask March + * EnHs (Grog) must also be present to maintain the count of the EnNwc in the march */ #include "z_en_nwc.h" +#include "overlays/actors/ovl_En_Niw/z_en_niw.h" +#include "objects/object_nwc/object_nwc.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,15 +20,27 @@ void EnNwc_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnNwc_Update(Actor* thisx, GlobalContext* globalCtx); void EnNwc_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809448A4(EnNwc* this, GlobalContext* globalCtx); -void func_809449D0(EnNwc* this, GlobalContext* globalCtx); -void func_80944A50(EnNwc* this, GlobalContext* globalCtx); -void func_80944E44(EnNwc* this, GlobalContext* globalCtx); -void func_80944EFC(EnNwc* this, GlobalContext* globalCtx); -void func_80944FA8(EnNwc* this, GlobalContext* globalCtx); -void func_8094506C(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_LoadNiwSkeleton(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_CrowAtTheEnd(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_Follow(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_HopForward(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_RunAway(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_Turn(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_CheckForBreman(EnNwc* this, GlobalContext* globalCtx); + +void EnNwc_DrawAdultBody(Actor* thisx, GlobalContext* globalCtx); +s32 EnNwc_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); +EnHs* EnNwc_FindGrog(GlobalContext* globalCtx); + +enum EnNiwState { + /* -1 */ NWC_STATE_NIW_LOADED = -1, // set after loading object_niw + /* 0 */ NWC_STATE_CHECK_BREMAN = 0, // checking for breman mask + /* 1 */ NWC_STATE_TURNING, // turning to face a new direction to explore + /* 2 */ NWC_STATE_HOPPING_FORWARD, // hopping to go explore + /* 3 */ NWC_STATE_FOLLOWING, // following the player + /* 4 */ NWC_STATE_RUNNING, // running from the player after failed breman march +}; -#if 0 const ActorInit En_Nwc_InitVars = { ACTOR_EN_NWC, ACTORCAT_PROP, @@ -36,47 +53,474 @@ const ActorInit En_Nwc_InitVars = { (ActorFunc)EnNwc_Draw, }; -#endif +Color_RGBA8 sPrimColor = { 255, 255, 255, 255 }; -extern UNK_TYPE D_060000E8; -extern UNK_TYPE D_060002E8; +Color_RGBA8 sEnvColor = { 80, 80, 80, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/EnNwc_Init.s") +void EnNwc_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 niwObjectIndex; + EnNwc* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/EnNwc_Destroy.s") + niwObjectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_NIW); + if (niwObjectIndex < 0) { + // niw object does not exist, we need it for tranformation, despawn + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944320.s") + if (gSaveContext.save.weekEventReg[25] & 8) { + // if breman mask was already used, replace with adult EnNiw + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_NIW, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, NIW_TYPE_REGULAR); + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944554.s") + this->niwObjectIndex = niwObjectIndex; + this->nwcObjectIndex = this->actor.objBankIndex; + this->grog = EnNwc_FindGrog(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944590.s") + this->footRotY = this->footRotZ = 0; + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = EnNwc_LoadNiwSkeleton; + this->hasGrownUp = false; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 6.0f); + this->actor.velocity.y = 0.0f; + this->actor.terminalVelocity = -9.0f; + this->actor.gravity = -1.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_809445D4.s") +void EnNwc_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnNwc* this = THIS; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944630.s") +void EnNwc_SpawnDust(EnNwc* this, GlobalContext* globalCtx) { + Vec3f pos; + Vec3f vec5; + Vec3f vel; + Vec3f accel; + s16 yaw; + s16 pitch; + Vec3f eye = GET_ACTIVE_CAM(globalCtx)->eye; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_809447A8.s") + yaw = Math_Vec3f_Yaw(&eye, &this->actor.world.pos); + pitch = -Math_Vec3f_Pitch(&eye, &this->actor.world.pos); + vec5.x = this->actor.world.pos.x - 5.0f * Math_SinS(yaw) * Math_CosS(pitch); + vec5.y = this->actor.world.pos.y - 5.0f * Math_SinS(pitch); + vec5.z = this->actor.world.pos.z - 5.0f * Math_CosS(yaw) * Math_CosS(pitch); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944818.s") + for (i = 0; i < 5; i++) { + vel.x = randPlusMinusPoint5Scaled(4.0f); + vel.y = randPlusMinusPoint5Scaled(4.0f); + vel.z = randPlusMinusPoint5Scaled(4.0f); + accel.x = -vel.x * 0.1f; + accel.y = -vel.y * 0.1f; + accel.z = -vel.z * 0.1f; + pos.x = vec5.x + vel.x; + pos.y = vec5.y + vel.y; + pos.z = vec5.z + vel.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_809448A4.s") + func_800B0F80(globalCtx, &pos, &vel, &accel, &sPrimColor, &sEnvColor, 300, 30, 10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_809449D0.s") +EnHs* EnNwc_FindGrog(GlobalContext* globalCtx) { + Actor* grogSearch = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944A50.s") + while (grogSearch != NULL) { + if (grogSearch->id == ACTOR_EN_HS) { + return (EnHs*)grogSearch; + } + grogSearch = grogSearch->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944E44.s") + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944EFC.s") +s32 EnNwc_PlayerReleasedBremanMarch(EnNwc* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80944FA8.s") + // Weird: home.rot.x holds count of chicks having transformed into adult. + // Weird: Its incremented by 1 unlike chicks following, so it should max at 10. + if (this->grog->actor.home.rot.x >= 20) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_8094506C.s") + if (player->stateFlags3 & 0x20000000) { // breman mask march + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/EnNwc_Update.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/EnNwc_Draw.s") +/** + * Summary: Checks 1) if grog exists, 2) player is using breman mask, 3) and within range. + * Used to identify if the chick should be captured by breman mask. + */ +s32 EnNwc_IsFound(EnNwc* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_8094529C.s") + if (this->grog == NULL) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nwc/func_80945310.s") + if (player->stateFlags3 & 0x20000000 && // breman mask march + this->actor.xzDistToPlayer < 100.0f) { + return true; + } + + return false; +} + +void EnNwc_ChangeState(EnNwc* this, s16 newState) { + this->actor.speedXZ = 0.0f; + switch (newState) { + case NWC_STATE_CHECK_BREMAN: + this->stateTimer = 10; + this->actionFunc = EnNwc_CheckForBreman; + break; + case NWC_STATE_TURNING: + this->stateTimer = Rand_ZeroFloat(20.0f) + 15.0f; + this->actionFunc = EnNwc_Turn; + this->fallingRotY = (s16)(s32)randPlusMinusPoint5Scaled(65536.0f); + break; + case NWC_STATE_HOPPING_FORWARD: + this->stateTimer = Rand_ZeroFloat(20.0f) + 15.0f; + this->actionFunc = EnNwc_HopForward; + break; + case NWC_STATE_FOLLOWING: + this->actionFunc = EnNwc_Follow; + this->transformTimer = 0; + this->randomRot = (s16)(s32)randPlusMinusPoint5Scaled(10000.0f); + break; + case NWC_STATE_RUNNING: + this->actor.world.rot.y = this->actor.home.rot.z * 0x3000 & 0xFFFF; // Fake Match?: & 0xFFFF + this->actor.shape.rot.y = this->actor.world.rot.y; + this->stateTimer = Rand_ZeroFloat(40.0f) + 120.0f; + this->actionFunc = EnNwc_RunAway; + break; + } + + this->state = newState; +} + +/** + * Summary: Changes the current actor state + * If previously random behavior -> check if breman mask is active + * If previously checking for breman -> select random (NWC_STATE_TURNING, NWC_STATE_HOPPING_FORWARD) + */ +void EnNwc_ToggleState(EnNwc* this) { + this->actor.speedXZ = 0.0f; + if (this->state != NWC_STATE_CHECK_BREMAN) { + EnNwc_ChangeState(this, NWC_STATE_CHECK_BREMAN); + } else { + EnNwc_ChangeState(this, Rand_ZeroFloat(2.0f) + 1.0f); + } +} + +void EnNwc_CheckFound(EnNwc* this, GlobalContext* globalCtx) { + if (EnNwc_IsFound(this, globalCtx)) { + u8 currentChickCount = (this->grog->actor.home.rot.z / 2); + + if (currentChickCount > 9) { + currentChickCount = 9; + } + + // save our current chick order + this->actor.home.rot.z = this->grog->actor.home.rot.z + 1; + + // if < 10 chicks, increment grog's chick counter + if (this->grog->actor.home.rot.z < 20) { + this->grog->actor.home.rot.z += 2; + } + + EnNwc_ChangeState(this, NWC_STATE_FOLLOWING); + func_801A0868(&D_801DB4A4, NA_SE_SY_CHICK_JOIN_CHIME, currentChickCount); + } +} + +void EnNwc_LoadNiwSkeleton(EnNwc* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->niwObjectIndex)) { + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->niwObjectIndex].segment); + + SkelAnime_InitFlex(globalCtx, &this->niwSkeleton, &gNiwSkeleton, &gNiwIdleAnim, this->jointTable, + this->morphTable, NIW_LIMB_MAX); + Animation_Change(&this->niwSkeleton, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), 0, 0.0f); + + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->nwcObjectIndex].segment); + this->state = NWC_STATE_NIW_LOADED; + EnNwc_ToggleState(this); + } +} + +void EnNwc_CrowAtTheEnd(EnNwc* this, GlobalContext* globalCtx) { + // I guess grog handles the scene transit? + Math_SmoothStepToS(&this->upperBodyRotY, 0x2710, 2, 0x1B58, 0x3E8); + Math_SmoothStepToS(&this->footRotZ, 0, 2, 0x1B58, 0x3E8); + Math_SmoothStepToS(&this->footRotY, 0x36B0, 2, 0x1B58, 0x3E8); +} + +/** + * Summary: Controls the Chick when following Breman Mask. + * + * ActionFunc for NWC Type: NWC_STATE_FOLLOWING + */ +void EnNwc_Follow(EnNwc* this, GlobalContext* globalCtx) { + Vec3f* chickCoords = this->grog->nwcPos; + Vec3f targetVector; + s32 pad; + s16 newRotY; + + this->stateTimer++; + if (this->hasGrownUp & 1) { + s16 targetUpperBodyRot = 0; + s16 targetFootRot = 0; + + if (this->actor.speedXZ > 0.0f) { + if (this->stateTimer & 4) { + targetFootRot = 0x1B58; + targetUpperBodyRot = -0x2710; + } + if ((this->stateTimer & 3) == 3) { + this->actor.velocity.y = 2.0f; // hop up and down + } + } + Math_SmoothStepToS(&this->footRotZ, targetFootRot, 2, 0x1B58, 0x3E8); + Math_SmoothStepToS(&this->upperBodyRotY, targetUpperBodyRot, 2, 0x1B58, 0x3E8); + + } else { // NOT grown up + if ((this->stateTimer & 3) == 3 && this->stateTimer & 20) { + this->actor.velocity.y = 2.0f; // hop up and down + } + if ((this->stateTimer & 0x1B) == 24) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_SONG); + } + } + + if (this->grog->actor.home.rot.z >= 20 && // all 10 chicks have been found + (this->hasGrownUp & 1) == false) { + this->transformTimer += 2; + if (this->transformTimer >= (s32)(s16)((this->actor.home.rot.z * 0x1E) + 0x1E)) { + // it is our turn to transform + this->hasGrownUp |= 1; + this->grog->actor.home.rot.x += 2; // increment grog's adult tranformation counter + EnNwc_SpawnDust(this, globalCtx); + Actor_SetScale(&this->actor, 0.002f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_TO_CHICKEN); + } + } + + Math_Vec3f_Diff(&chickCoords[this->actor.home.rot.z], &this->actor.world.pos, &targetVector); + if (SQXZ(targetVector) < SQ(5.0f)) { // too close to keep moving, stop + this->actor.speedXZ = 0.0f; + + // first nwc in the line follows player, the rest follow the previous one + if (this->actor.home.rot.z == 1) { + newRotY = this->actor.yawTowardsPlayer; + } else { + // for some reason the array is 10 * 2, incremented by 2, so this is "index - 1" + newRotY = Math_Vec3f_Yaw(&this->actor.world.pos, &chickCoords[this->actor.home.rot.z - 2]); + } + + } else { // not too close: keep moving + this->randomRot += (s16)randPlusMinusPoint5Scaled(1500.0f); + if (this->randomRot > 0x1388) { + this->randomRot = 0x1388; + } else if (this->randomRot < -0x1388) { + this->randomRot = -0x1388; + } + this->actor.speedXZ = 2.0f; + newRotY = Math_Vec3f_Yaw(&this->actor.world.pos, &chickCoords[this->actor.home.rot.z]) + this->randomRot; + } + + this->actor.world.rot.y = newRotY; + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 0xBB8, 0xC8); + + if (EnNwc_PlayerReleasedBremanMarch(this, globalCtx)) { + this->grog->actor.home.rot.x = 0; // reset adult count + this->grog->actor.home.rot.z = 0; // reset chick follow count + + EnNwc_ChangeState(this, NWC_STATE_RUNNING); + + if (this->hasGrownUp & 1) { + EnNwc_SpawnDust(this, globalCtx); + } + + this->hasGrownUp &= ~1; + Actor_SetScale(&this->actor, 0.01f); + } + + if (this->actor.scale.x < 0.01f) { + this->actor.scale.x += 0.002f; + Actor_SetScale(&this->actor, this->actor.scale.x); + } + + if (this->grog->actor.home.rot.x >= 20) { // all chicks have turned into adult cucco, stop and crow + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); + this->actionFunc = EnNwc_CrowAtTheEnd; + this->actor.speedXZ = 0.0f; + Actor_SetScale(&this->actor, 0.01f); + } +} + +/** + * Summary: Chick is Walking (Hopping) in a straight line. + * + * ActionFunc for NWC Type: NWC_STATE_HOPPING_FORWARD + */ +void EnNwc_HopForward(EnNwc* this, GlobalContext* globalCtx) { + if (DECR(this->stateTimer) == 0) { + EnNwc_ToggleState(this); + return; + } + + if ((this->stateTimer & 3) == 3) { + this->actor.velocity.y = 2.0f; // hop up and down + } + if ((this->stateTimer & 0xB) == 8) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_SONG); + } + + // they only move forward while off the ground, which gives the visual of them hopping to move + if (this->actor.bgCheckFlags & 0x1) { // touching floor + this->actor.speedXZ = 0.0f; + } else { + this->actor.speedXZ = 2.0f; + } +} + +/** + * Summary: Chick is Running Away from player (Breman Mask was dropped). + * + * ActionFunc for NWC Type: NWC_STATE_RUNNING + */ +void EnNwc_RunAway(EnNwc* this, GlobalContext* globalCtx) { + if (DECR(this->stateTimer) == 0) { + EnNwc_ToggleState(this); + return; + } + + if ((this->stateTimer & 3) == 3) { + this->actor.velocity.y = 2.0f; // hop up and down + } + if ((this->stateTimer & 0xB) == 8) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_SONG); + } + + this->actor.speedXZ = 2.0f; + if (this->actor.bgCheckFlags & 0x8) { // touching wall + EnNwc_ToggleState(this); + } +} + +/** + * Summary: Chick is turning to face a new direction. + * + * ActionFunc for NWC Type: NWC_STATE_TURNING + */ +void EnNwc_Turn(EnNwc* this, GlobalContext* globalCtx) { + if (DECR(this->stateTimer) == 0) { + EnNwc_ToggleState(this); + return; + } + + if ((this->stateTimer & 7) == 7) { + this->actor.velocity.y = 2.0f; // vertical hop + } + + if ((this->stateTimer & 0xB) == 8) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_SONG); + } + + // they only rotate when off the ground, giving the visual that they turn by hopping + if (!(this->actor.bgCheckFlags & 0x1)) { // NOT touching floor + Math_SmoothStepToS(&this->actor.shape.rot.y, this->fallingRotY, 0xA, 0x1000, 0x800); + this->actor.world.rot.y = this->actor.shape.rot.y; + } +} + +/** + * Summary: Chick is standing still. + * Looking around, can see the player with the Breman Mask + * + * ActionFunc for NWC Type: NWC_STATE_CHECK_BREMAN + */ +void EnNwc_CheckForBreman(EnNwc* this, GlobalContext* globalCtx) { + if (DECR(this->stateTimer) == 0) { + EnNwc_ToggleState(this); + } + + EnNwc_CheckFound(this, globalCtx); +} + +void EnNwc_Update(Actor* thisx, GlobalContext* globalCtx) { + EnNwc* this = THIS; + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 5); + this->actionFunc(this, globalCtx); + if (this->hasGrownUp & 1) { + this->actor.objBankIndex = this->niwObjectIndex; + this->actor.draw = EnNwc_DrawAdultBody; + this->actor.shape.shadowScale = 15.0f; + } else { + this->actor.objBankIndex = this->nwcObjectIndex; + this->actor.draw = EnNwc_Draw; + this->actor.shape.shadowScale = 6.0f; + } + + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(0x3C, 0x3C); + } + + if (this->blinkTimer == 1 || this->blinkTimer == 3) { + this->blinkState = true; + } else { + this->blinkState = false; + } +} + +void EnNwc_Draw(Actor* thisx, GlobalContext* globalCtx) { + TexturePtr eyeTextures[] = { gNwcEyeOpenTex, gNwcEyeClosedTex }; + EnNwc* this = THIS; + Gfx* dispHead; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + dispHead = POLY_OPA_DISP; + + gSPSegment(&dispHead[0], 0x08, Lib_SegmentedToVirtual(eyeTextures[this->blinkState])); + + gSPMatrix(&dispHead[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(&dispHead[2], &gNwcBodyDL); + + POLY_OPA_DISP = &dispHead[3]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +s32 EnNwc_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnNwc* this = THIS; + + if (limbIndex == NIW_LIMB_UPPER_BODY) { + rot->y += this->upperBodyRotY; + } + if (limbIndex == NIW_LIMB_RIGHT_WING_ROOT || limbIndex == NIW_LIMB_LEFT_WING_ROOT) { + rot->y += this->footRotY; + rot->z += this->footRotZ; + } + + return false; +} + +void EnNwc_DrawAdultBody(Actor* thisx, GlobalContext* globalCtx) { + EnNwc* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->niwSkeleton.skeleton, this->niwSkeleton.jointTable, + this->niwSkeleton.dListCount, EnNwc_OverrideLimbDraw, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h index ccdfb59bb..3815852af 100644 --- a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h +++ b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h @@ -2,15 +2,37 @@ #define Z_EN_NWC_H #include "global.h" +#include "objects/object_niw/object_niw.h" +#include "overlays/actors/ovl_En_Hs/z_en_hs.h" // grog + struct EnNwc; typedef void (*EnNwcActionFunc)(struct EnNwc*, GlobalContext*); typedef struct EnNwc { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x120]; - /* 0x0264 */ EnNwcActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime niwSkeleton; // this skeleton is for when the chicks grow up into adults during the breman march + /* 0x188 */ Vec3s jointTable[NIW_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[NIW_LIMB_MAX]; + /* 0x248 */ s8 niwObjectIndex; + /* 0x249 */ s8 nwcObjectIndex; + /* 0x24A */ s16 blinkState; + /* 0x24C */ s16 blinkTimer; + /* 0x250 */ EnHs* grog; + /* 0x254 */ s16 stateTimer; // count frames to next state change + /* 0x256 */ union { + s16 mixedValue256; // default name for reset + s16 transformTimer; // frames since transformation sequence started + s16 fallingRotY; // target rotation if off the ground in state 1 + }; + /* 0x258 */ s16 randomRot; + /* 0x25A */ s16 state; + /* 0x25C */ u16 hasGrownUp; // treated as both a boolean and a flag variable (0x1) + /* 0x25E */ s16 footRotY; + /* 0x260 */ s16 footRotZ; + /* 0x262 */ s16 upperBodyRotY; + /* 0x264 */ EnNwcActionFunc actionFunc; } EnNwc; // size = 0x268 extern const ActorInit En_Nwc_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index c4f1a053b..e552ca336 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -5424,9 +5424,9 @@ 0x808908D0:("func_808908D0",), 0x80891060:("EnNiw_Init",), 0x808912E8:("EnNiw_Destroy",), - 0x80891320:("func_80891320",), + 0x80891320:("EnNiw_AnimateWingHead",), 0x808916B0:("EnNiw_SpawnAttackNiw",), - 0x808917F8:("func_808917F8",), + 0x808917F8:("EnNiw_UpdateRunning",), 0x80891974:("EnNiw_SetupIdle",), 0x808919E8:("EnNiw_Idle",), 0x80891D78:("EnNiw_Held",), @@ -7514,24 +7514,24 @@ 0x80943EE4:("EnDaiku_Draw",), 0x809441E0:("EnNwc_Init",), 0x80944310:("EnNwc_Destroy",), - 0x80944320:("func_80944320",), - 0x80944554:("func_80944554",), - 0x80944590:("func_80944590",), - 0x809445D4:("func_809445D4",), - 0x80944630:("func_80944630",), - 0x809447A8:("func_809447A8",), - 0x80944818:("func_80944818",), - 0x809448A4:("func_809448A4",), - 0x809449D0:("func_809449D0",), - 0x80944A50:("func_80944A50",), - 0x80944E44:("func_80944E44",), - 0x80944EFC:("func_80944EFC",), - 0x80944FA8:("func_80944FA8",), - 0x8094506C:("func_8094506C",), + 0x80944320:("EnNwc_SpawnDust",), + 0x80944554:("EnNwc_FindGrog",), + 0x80944590:("EnNwc_PlayerReleasedBremanMarch",), + 0x809445D4:("EnNwc_IsFound",), + 0x80944630:("EnNwc_ChangeState",), + 0x809447A8:("EnNwc_ToggleState",), + 0x80944818:("EnNwc_CheckFound",), + 0x809448A4:("EnNwc_LoadNiwSkeleton",), + 0x809449D0:("EnNwc_CrowAtTheEnd",), + 0x80944A50:("EnNwc_Follow",), + 0x80944E44:("EnNwc_HopForward",), + 0x80944EFC:("EnNwc_RunAway",), + 0x80944FA8:("EnNwc_Turn",), + 0x8094506C:("EnNwc_CheckForBreman",), 0x809450C0:("EnNwc_Update",), 0x809451D8:("EnNwc_Draw",), - 0x8094529C:("func_8094529C",), - 0x80945310:("func_80945310",), + 0x8094529C:("EnNwc_OverrideLimbDraw",), + 0x80945310:("EnNwc_DrawAdultBody",), 0x809454F0:("ItemInbox_Init",), 0x80945524:("ItemInbox_Destroy",), 0x80945534:("ItemInbox_Idle",), @@ -7641,13 +7641,13 @@ 0x80952CC8:("EnHs_Init",), 0x80952DD0:("EnHs_Destroy",), 0x80952DFC:("func_80952DFC",), - 0x80952E50:("func_80952E50",), + 0x80952E50:("EnHs_UpdateChickPos",), 0x80952F00:("func_80952F00",), 0x80952FE0:("func_80952FE0",), 0x80953098:("func_80953098",), 0x80953180:("func_80953180",), - 0x809532C0:("func_809532C0",), - 0x809532D0:("func_809532D0",), + 0x809532C0:("EnHs_DoNothing",), + 0x809532D0:("EnHs_SceneTransitToBunnyHoodDialogue",), 0x80953354:("func_80953354",), 0x809533A0:("func_809533A0",), 0x8095345C:("func_8095345C",), @@ -7680,11 +7680,11 @@ 0x80956954:("EnKanban_Draw",), 0x809580C0:("EnAttackNiw_Init",), 0x809581F4:("EnAttackNiw_Destroy",), - 0x80958228:("func_80958228",), - 0x809585B0:("func_809585B0",), - 0x80958634:("func_80958634",), - 0x80958974:("func_80958974",), - 0x80958BE4:("func_80958BE4",), + 0x80958228:("EnAttackNiw_AnimateWingHead",), + 0x809585B0:("EnAttackNiw_IsOnScreen",), + 0x80958634:("EnAttackNiw_EnterViewFromOffscreen",), + 0x80958974:("EnAttackNiw_AimAtPlayer",), + 0x80958BE4:("EnAttackNiw_FlyAway",), 0x80958CA8:("EnAttackNiw_Update",), 0x80958F6C:("EnAttackNiw_OverrideLimbDraw",), 0x8095909C:("EnAttackNiw_Draw",), From e1477702ca139175af769347a3ad0d7a13a31fde Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 25 May 2022 19:23:27 -0700 Subject: [PATCH 223/257] EffectSsKirakira OK (#801) * OK * cleanup * KiraKira -> Kirakira --- assets/xml/objects/gameplay_keep.xml | 2 +- include/functions.h | 8 +- spec | 3 +- src/code/z_effect_soft_sprite_old_init.c | 16 +- src/code/z_en_item00.c | 4 +- .../ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c | 2 +- .../actors/ovl_Door_Warp1/z_door_warp1.c | 2 +- src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c | 4 +- src/overlays/actors/ovl_En_Am/z_en_am.c | 2 +- src/overlays/actors/ovl_En_Arrow/z_en_arrow.c | 2 +- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 2 +- .../actors/ovl_En_Elforg/z_en_elforg.c | 2 +- src/overlays/actors/ovl_En_Gg2/z_en_gg2.c | 2 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 2 +- src/overlays/actors/ovl_En_Test6/z_en_test6.c | 4 +- src/overlays/actors/ovl_En_Zog/z_en_zog.c | 2 +- .../ovl_Obj_Bigicicle/z_obj_bigicicle.c | 2 +- .../actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c | 2 +- .../z_eff_ss_kirakira.c | 144 ++++++++++++++++-- .../z_eff_ss_kirakira.h | 2 +- tools/disasm/functions.txt | 8 +- tools/namefixer.py | 5 + tools/sizes/code_functions.csv | 8 +- 23 files changed, 180 insertions(+), 50 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 8328b14ab..f73e9252f 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1180,7 +1180,7 @@ - + diff --git a/include/functions.h b/include/functions.h index 0e12b35a5..8c04ba259 100644 --- a/include/functions.h +++ b/include/functions.h @@ -541,11 +541,11 @@ void func_800B139C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* void func_800B13D8(Vec3f* srcPos, f32 randScale, Vec3f* newPos, Vec3f* velocity, Vec3f* accel); void func_800B14D4(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos); void func_800B1598(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos); -void EffectSsKiraKira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel); -void EffectSsKiraKira_SpawnSmall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); +void EffectSsKirakira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel); +void EffectSsKirakira_SpawnSmall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); void EffectSsGSpk_SpawnSmall(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor); -void EffectSsKiraKira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life); -// void EffectSsKiraKira_SpawnFocused(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7, UNK_TYPE4 param_8); +void EffectSsKirakira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life); +// void EffectSsKirakira_SpawnFocused(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE2 param_7, UNK_TYPE4 param_8); // void EffectSsBomb2_SpawnFade(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4); void EffectSsBomb2_SpawnLayered(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep); // void EffectSsBlast_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, Color_RGBA8* param_5, Color_RGBA8* param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10); diff --git a/spec b/spec index 5cb8e7123..5c30f08c1 100644 --- a/spec +++ b/spec @@ -1784,8 +1784,7 @@ beginseg name "ovl_Effect_Ss_Kirakira" compress include "build/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.o" - include "build/data/ovl_Effect_Ss_Kirakira/ovl_Effect_Ss_Kirakira.data.o" - include "build/data/ovl_Effect_Ss_Kirakira/ovl_Effect_Ss_Kirakira.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Kirakira/ovl_Effect_Ss_Kirakira_reloc.o" endseg beginseg diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index 0300144e1..1e9b25573 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -206,21 +206,21 @@ void func_800B1598(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) { } } -void EffectSsKiraKira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { +void EffectSsKirakira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { Color_RGBA8 primColor = { 255, 255, 200, 255 }; Color_RGBA8 envColor = { 255, 200, 0, 0 }; - EffectSsKiraKira_SpawnDispersed(globalCtx, pos, velocity, accel, &primColor, &envColor, 1000, 16); + EffectSsKirakira_SpawnDispersed(globalCtx, pos, velocity, accel, &primColor, &envColor, 1000, 16); } -void EffectSsKiraKira_SpawnSmall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsKirakira_SpawnSmall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor) { - EffectSsKiraKira_SpawnDispersed(globalCtx, pos, velocity, accel, primColor, envColor, 1000, 16); + EffectSsKirakira_SpawnDispersed(globalCtx, pos, velocity, accel, primColor, envColor, 1000, 16); } -void EffectSsKiraKira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsKirakira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life) { - EffectSsKiraKiraInitParams initParams; + EffectSsKirakiraInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); Math_Vec3f_Copy(&initParams.velocity, velocity); @@ -239,9 +239,9 @@ void EffectSsKiraKira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f EffectSs_Spawn(globalCtx, EFFECT_SS_KIRAKIRA, 128, &initParams); } -void EffectSsKiraKira_SpawnFocused(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsKirakira_SpawnFocused(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life) { - EffectSsKiraKiraInitParams initParams; + EffectSsKirakiraInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); Math_Vec3f_Copy(&initParams.velocity, velocity); diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 1c600bfa0..6b01753cc 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -346,7 +346,7 @@ void func_800A6650(EnItem00* this, GlobalContext* globalCtx) { pos.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(10.0f); pos.y = this->actor.world.pos.y + randPlusMinusPoint5Scaled(10.0f); pos.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(10.0f); - EffectSsKiraKira_SpawnSmall(globalCtx, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14); + EffectSsKirakira_SpawnSmall(globalCtx, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14); } if ((this->actor.bgCheckFlags & 3) != 0) { if (this->actor.velocity.y > -2.0f) { @@ -403,7 +403,7 @@ void func_800A6780(EnItem00* this, GlobalContext* globalCtx) { pos.x = this->actor.world.pos.x + ((Rand_ZeroOne() - 0.5f) * 10.0f); pos.y = this->actor.world.pos.y + ((Rand_ZeroOne() - 0.5f) * 10.0f); pos.z = this->actor.world.pos.z + ((Rand_ZeroOne() - 0.5f) * 10.0f); - EffectSsKiraKira_SpawnSmall(globalCtx, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14); + EffectSsKirakira_SpawnSmall(globalCtx, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14); } if (this->actor.bgCheckFlags & 0x0003) { diff --git a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c index 6e27d1dc9..7e5c39c2f 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c @@ -147,7 +147,7 @@ void BgKin2Fence_SpawnEyeSparkles(BgKin2Fence* this, GlobalContext* globalCtx, s for (i = 0; i < 2; i++) { Matrix_MultiplyVector3fByState(&eyeSparkleSpawnPositions[mask][i], &sp58); - EffectSsKiraKira_SpawnDispersed(globalCtx, &sp58, &gZeroVec3f, &gZeroVec3f, &primColor, &envColor, 6000, -10); + EffectSsKirakira_SpawnDispersed(globalCtx, &sp58, &gZeroVec3f, &gZeroVec3f, &primColor, &envColor, 6000, -10); } } diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index 163619876..fa94a5981 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -1148,6 +1148,6 @@ void func_808BB8D4(DoorWarp1* this, GlobalContext* globalCtx, s32 arg2) { sVelocity.x = -Math_SinS(rand - 0x8000) * 5.0f; sVelocity.z = Math_CosS(rand - 0x8000) * 5.0f; } - EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &sVelocity, &sAccel, &primColor, &envColor, scale, life); + EffectSsKirakira_SpawnDispersed(globalCtx, &pos, &sVelocity, &sAccel, &primColor, &envColor, scale, life); } } diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c index e53635603..856b459a3 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -296,7 +296,7 @@ void func_80919768(Actor* thisx, GlobalContext* globalCtx2) { gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); } @@ -352,7 +352,7 @@ void func_809199FC(Actor* thisx, GlobalContext* globalCtx2) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); } diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.c b/src/overlays/actors/ovl_En_Am/z_en_am.c index c5b9381f6..20092f5b0 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -196,7 +196,7 @@ void EnAm_SpawnEffects(EnAm* this, GlobalContext* globalCtx) { effectPos.x = randPlusMinusPoint5Scaled(65.0f) + this->actor.world.pos.x; effectPos.y = randPlusMinusPoint5Scaled(10.0f) + (this->actor.world.pos.y + 40.0f); effectPos.z = randPlusMinusPoint5Scaled(65.0f) + this->actor.world.pos.z; - EffectSsKiraKira_SpawnSmall(globalCtx, &effectPos, &sVelocity, &sAccel, &D_808B1118, &D_808B111C); + EffectSsKirakira_SpawnSmall(globalCtx, &effectPos, &sVelocity, &sAccel, &D_808B1118, &D_808B111C); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_WALK); Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 4.0f, 3, 8.0f, 300, 15, 0); diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index 45cc5bdae..e60419846 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -731,7 +731,7 @@ void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(sp5C, sp5C, sp5C, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); Matrix_StatePop(); Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index 62d455147..a3a433cf1 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -1259,7 +1259,7 @@ void func_8088F5F4(EnElf* this, GlobalContext* globalCtx, s32 sparkleLife) { envColor.g = this->outerColor.g; envColor.b = this->outerColor.b; - EffectSsKiraKira_SpawnDispersed(globalCtx, &sparklePos, &sparkleVelocity, &sparkleAccel, &primColor, &envColor, + EffectSsKirakira_SpawnDispersed(globalCtx, &sparklePos, &sparkleVelocity, &sparkleAccel, &primColor, &envColor, 1000, sparkleLife); } } diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index 36ad91c0f..7676a9b78 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -176,7 +176,7 @@ void EnElforg_SpawnSparkles(EnElforg* this, GlobalContext* globalCtx, s32 life) index = (this->area < STRAY_FAIRY_AREA_CLOCK_TOWN || this->area >= STRAY_FAIRY_AREA_MAX) ? STRAY_FAIRY_AREA_CLOCK_TOWN : this->area; - EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &sVelocity, &sAcceleration, &sPrimColors[index], + EffectSsKirakira_SpawnDispersed(globalCtx, &pos, &sVelocity, &sAcceleration, &sPrimColors[index], &sEnvColors[index], 1000, life); } 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 ebe127fcf..f45cafa53 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -269,7 +269,7 @@ void func_80B3B4B0(EnGg2* this, GlobalContext* globalCtx) { sp64.x = (Rand_Centered() * 50.0f) + this->unk_304.x; sp64.y = this->unk_304.y; sp64.z = (Rand_Centered() * 50.0f) + this->unk_304.z; - EffectSsKiraKira_SpawnDispersed(globalCtx, &sp64, &D_80B3C088, &D_80B3C094, &sp60, &sp5C, 3000, 40); + EffectSsKirakira_SpawnDispersed(globalCtx, &sp64, &D_80B3C088, &D_80B3C094, &sp60, &sp5C, 3000, 40); } } diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 557b96b31..6c698234b 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -1577,7 +1577,7 @@ void func_80B45EC8(EnInvadepoh* this, GlobalContext* globalCtx, s32 arg2) { spA8.y = ((Rand_ZeroOne() * 180.0f) + this->actor.world.pos.y) - 90.0f; spA8.z = (spA8.z * 100.0f) + this->actor.world.pos.z; - EffectSsKiraKira_SpawnDispersed(globalCtx, &spA8, &sp9C, &sp90, &D_80B4EC18, &D_80B4EC1C, 6000, -40); + EffectSsKirakira_SpawnDispersed(globalCtx, &spA8, &sp9C, &sp90, &D_80B4EC18, &D_80B4EC1C, 6000, -40); } } diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index de1a18241..78b370c3b 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -237,7 +237,7 @@ void func_80A90D34(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 210, 210, 230, 128); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 0); gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -289,7 +289,7 @@ void func_80A90FC0(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 220, 220, 230, 192); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 0); gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.c b/src/overlays/actors/ovl_En_Zog/z_en_zog.c index f4514a9aa..2a990bc26 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -398,7 +398,7 @@ void func_80B93DE8(Vec3f* arg0, GlobalContext* globalCtx, s32 arg2) { sp2C.x = randPlusMinusPoint5Scaled(30.0f) + arg0->x; sp2C.y = arg0->y + 3.0f; sp2C.z = randPlusMinusPoint5Scaled(30.0f) + arg0->z; - EffectSsKiraKira_SpawnDispersed(globalCtx, &sp2C, &D_80B9598C, &D_80B95998, &D_80B959A4, &D_80B959A8, 1000, arg2); + EffectSsKirakira_SpawnDispersed(globalCtx, &sp2C, &D_80B9598C, &D_80B95998, &D_80B959A4, &D_80B959A8, 1000, arg2); } s32 func_80B93EA0(EnZog* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c index b4a85a3a0..8a1ae2df7 100644 --- a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c +++ b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c @@ -302,7 +302,7 @@ void ObjBigicicle_Update(Actor* thisx, GlobalContext* globalCtx) { sp44.z = (((215.0f + Rand_ZeroFloat(65.0f)) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)) * this->actor.scale.z) + this->actor.world.pos.z; - EffectSsKiraKira_SpawnDispersed(globalCtx, &sp44, &gZeroVec3f, &gZeroVec3f, &D_80AE9894, &D_80AE9898, 2000, 5); + EffectSsKirakira_SpawnDispersed(globalCtx, &sp44, &gZeroVec3f, &gZeroVec3f, &D_80AE9894, &D_80AE9898, 2000, 5); } CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); diff --git a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c index d6ac6f342..bdffb1b52 100644 --- a/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c +++ b/src/overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.c @@ -260,7 +260,7 @@ void func_80931A38(ObjIcePoly* this, GlobalContext* globalCtx) { } sp6C.z = (phi_v0 * (15.0f + (sp58 * 15.0f)) * this->actor.scale.z) + this->actor.world.pos.z; - EffectSsKiraKira_SpawnDispersed(globalCtx, &sp6C, &gZeroVec3f, &gZeroVec3f, &D_80932378, &D_8093237C, 2000, 5); + EffectSsKirakira_SpawnDispersed(globalCtx, &sp6C, &gZeroVec3f, &gZeroVec3f, &D_80932378, &D_8093237C, 2000, 5); } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.c b/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.c index b78891a2e..4c7c01ca3 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.c +++ b/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.c @@ -1,33 +1,159 @@ /* * File: z_eff_ss_kirakira.c * Overlay: ovl_Effect_Ss_Kirakira - * Description: + * Description: Sparkles */ #include "z_eff_ss_kirakira.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rRotSpeed regs[0] +#define rYaw regs[1] +#define rPrimColorR regs[2] +#define rPrimColorG regs[3] +#define rPrimColorB regs[4] +#define rPrimColorA regs[5] +#define rEnvColorR regs[6] +#define rEnvColorG regs[7] +#define rEnvColorB regs[8] +#define rEnvColorA regs[9] +#define rAlphaStep regs[10] +#define rScale regs[11] +#define rLifespan regs[12] #define PARAMS ((EffectSsKirakiraInitParams*)initParamsx) -s32 EffectSsKirakira_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsKirakira_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void func_80977DB4(GlobalContext* globalCtx, u32 index, EffectSs* this); void func_80977E6C(GlobalContext* globalCtx, u32 index, EffectSs* this); void func_80977F28(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsKirakira_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Kirakira_InitVars = { EFFECT_SS_KIRAKIRA, EffectSsKirakira_Init, }; -#endif +u32 EffectSsKirakira_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsKirakiraInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Kirakira/EffectSsKirakira_Init.s") + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Kirakira/EffectSsKirakira_Draw.s") + if ((this->life = initParams->life) < 0) { + this->life = -this->life; + this->gfx = gEffSparklesDL; + this->update = func_80977F28; + this->rEnvColorA = initParams->scale; + this->rScale = 0; + } else { + this->gfx = gEffSparklesDL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Kirakira/func_80977DB4.s") + if (initParams->updateMode == 0) { + this->update = func_80977DB4; + } else { + this->update = func_80977E6C; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Kirakira/func_80977E6C.s") + this->rEnvColorA = initParams->envColor.a; + this->rScale = initParams->scale; + if (this->rScale < 0) { + this->gfx = gameplay_keep_DL_06A800; + this->rScale = -this->rScale; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Kirakira/func_80977F28.s") + this->draw = EffectSsKirakira_Draw; + this->rRotSpeed = initParams->rotSpeed; + this->rYaw = initParams->yaw; + this->rPrimColorR = initParams->primColor.r; + this->rPrimColorG = initParams->primColor.g; + this->rPrimColorB = initParams->primColor.b; + this->rPrimColorA = initParams->primColor.a; + this->rEnvColorR = initParams->envColor.r; + this->rEnvColorG = initParams->envColor.g; + this->rEnvColorB = initParams->envColor.b; + this->rAlphaStep = initParams->alphaStep; + this->rLifespan = initParams->life; + + return 1; +} + +void EffectSsKirakira_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx; + f32 scale = this->rScale / 10000.0f; + s32 pad; + MtxF mfTrans; + MtxF mfRot; + MtxF mfScale; + MtxF mfTransBillboard; + MtxF mfTransBillboardRot; + MtxF mfResult; + Mtx* mtx; + + gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + + SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); + SkinMatrix_SetRotateRPY(&mfRot, 0, 0, this->rYaw); + SkinMatrix_SetScale(&mfScale, scale, scale, 1.0f); + SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfRot, &mfTransBillboardRot); + SkinMatrix_MtxFMtxFMult(&mfTransBillboardRot, &mfScale, &mfResult); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, + (((s8)((55.0f / this->rLifespan) * this->life) + 200))); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + } + + CLOSE_DISPS(gfxCtx); +} + +void func_80977DB4(GlobalContext* globalCtx, u32 index, EffectSs* this) { + this->accel.x = (Rand_ZeroOne() * 0.4f) - 0.2f; + this->accel.z = (Rand_ZeroOne() * 0.4f) - 0.2f; + this->rEnvColorA += this->rAlphaStep; + + if (this->rEnvColorA < 0) { + this->rEnvColorA = 0; + this->rAlphaStep = -this->rAlphaStep; + } else if (this->rEnvColorA > 255) { + this->rEnvColorA = 255; + this->rAlphaStep = -this->rAlphaStep; + } + + this->rYaw += this->rRotSpeed; +} + +void func_80977E6C(GlobalContext* globalCtx, u32 index, EffectSs* this) { + this->velocity.x *= 0.95f; + this->velocity.z *= 0.95f; + this->accel.x = randPlusMinusPoint5Scaled(0.2f); + this->accel.z = randPlusMinusPoint5Scaled(0.2f); + this->rEnvColorA += this->rAlphaStep; + + if (this->rEnvColorA < 0) { + this->rEnvColorA = 0; + this->rAlphaStep = -this->rAlphaStep; + } else if (this->rEnvColorA > 255) { + this->rEnvColorA = 255; + this->rAlphaStep = -this->rAlphaStep; + } + + this->rYaw += this->rRotSpeed; +} + +void func_80977F28(GlobalContext* globalCtx, u32 index, EffectSs* this) { + this->rScale = this->rEnvColorA * Math_SinS((32768.0f / this->rLifespan) * this->life); +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.h b/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.h index c3020f590..66e73e0a5 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.h +++ b/src/overlays/effects/ovl_Effect_Ss_Kirakira/z_eff_ss_kirakira.h @@ -15,7 +15,7 @@ typedef struct { /* 0x34 */ s16 rotSpeed; /* 0x36 */ s16 yaw; /* 0x38 */ u8 updateMode; -} EffectSsKiraKiraInitParams; // size = 0x3C +} EffectSsKirakiraInitParams; // size = 0x3C extern const EffectSsInit Effect_Ss_Kirakira_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e552ca336..017df4ba1 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -596,10 +596,10 @@ 0x800B13D8:("func_800B13D8",), 0x800B14D4:("func_800B14D4",), 0x800B1598:("func_800B1598",), - 0x800B165C:("EffectSsKiraKira_SpawnSmallYellow",), - 0x800B16B8:("EffectSsKiraKira_SpawnSmall",), - 0x800B16F4:("EffectSsKiraKira_SpawnDispersed",), - 0x800B1830:("EffectSsKiraKira_SpawnFocused",), + 0x800B165C:("EffectSsKirakira_SpawnSmallYellow",), + 0x800B16B8:("EffectSsKirakira_SpawnSmall",), + 0x800B16F4:("EffectSsKirakira_SpawnDispersed",), + 0x800B1830:("EffectSsKirakira_SpawnFocused",), 0x800B1908:("EffectSsBomb2_SpawnFade",), 0x800B1970:("EffectSsBomb2_SpawnLayered",), 0x800B19E0:("EffectSsBlast_Spawn",), diff --git a/tools/namefixer.py b/tools/namefixer.py index 7ce3790db..c4a83d13f 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -499,6 +499,11 @@ wordReplace = { "func_8015E750": "Message_FindCreditsMessage", "func_80133038": "Schedule_RunScript", + "EffectSsKiraKira_SpawnSmallYellow": "EffectSsKirakira_SpawnSmallYellow", + "EffectSsKiraKira_SpawnSmall": "EffectSsKirakira_SpawnSmall", + "EffectSsKiraKira_SpawnDispersed": "EffectSsKirakira_SpawnDispersed", + "EffectSsKiraKira_SpawnFocused": "EffectSsKirakira_SpawnFocused", + # Struct members "skelAnime.unk03": "skelAnime.taper", "skelAnime.animCurrentSeg": "skelAnime.animation", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index ffff2a55b..2989dbfb6 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -110,10 +110,10 @@ asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800B139C.s,func_800B13 asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800B13D8.s,func_800B13D8,0x800B13D8,0x3F asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800B14D4.s,func_800B14D4,0x800B14D4,0x31 asm/non_matchings/code/z_effect_soft_sprite_old_init/func_800B1598.s,func_800B1598,0x800B1598,0x31 -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKiraKira_SpawnSmallYellow.s,EffectSsKiraKira_SpawnSmallYellow,0x800B165C,0x17 -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKiraKira_SpawnSmall.s,EffectSsKiraKira_SpawnSmall,0x800B16B8,0xF -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKiraKira_SpawnDispersed.s,EffectSsKiraKira_SpawnDispersed,0x800B16F4,0x4F -asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKiraKira_SpawnFocused.s,EffectSsKiraKira_SpawnFocused,0x800B1830,0x36 +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKirakira_SpawnSmallYellow.s,EffectSsKirakira_SpawnSmallYellow,0x800B165C,0x17 +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKirakira_SpawnSmall.s,EffectSsKirakira_SpawnSmall,0x800B16B8,0xF +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKirakira_SpawnDispersed.s,EffectSsKirakira_SpawnDispersed,0x800B16F4,0x4F +asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsKirakira_SpawnFocused.s,EffectSsKirakira_SpawnFocused,0x800B1830,0x36 asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsBomb2_SpawnFade.s,EffectSsBomb2_SpawnFade,0x800B1908,0x1A asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsBomb2_SpawnLayered.s,EffectSsBomb2_SpawnLayered,0x800B1970,0x1C asm/non_matchings/code/z_effect_soft_sprite_old_init/EffectSsBlast_Spawn.s,EffectSsBlast_Spawn,0x800B19E0,0x24 From 8049dec3393c4ade687dbdfd84d3ccde73168ab0 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis Date: Thu, 26 May 2022 04:24:39 +0100 Subject: [PATCH 224/257] `sys_matrix` OK, documented, rename some other mathematics functions (#787) * Import data and bss, add some name options * Decomp rest of stack functions, remove RSPMatrix, split header * sys_matrix OK (thanks Tharo) Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> * pragma weaks in sinf and cosf, change documentation change mcros to use 0x8000 * Rename sinf and cosf * Correct initialisation of sMtxFClear * More minor cleanup * Rename stack functions * Matrix_InsertMatrix -> Matrix_Mult * The big transpose rename * Fix MirRay_DrawReflectedBeam * Matrix_InsertTranslation -> Matrix_Translate * Matrix_Insert.Rotation_s -> Matrix_Rotate$1S + RotateY -> RotateYS * Matrix_Insert(.)Rotation_f -> Matrix_Rotate$1F * Matrix_RotateStateAroundXAxis -> Matrix_RotateXFApply Matrix_SetStateXRotation -> Matrix_RotateXFNew * Matrix_MultiplyVector3fByState -> Matrix_MultVec3f * Matrix_MultiplyVector3fXZByCurrentState -> Matrix_MultVec3fXZ * Matrix_GetStateTranslation -> Matrix_MultZero * Matrix_GetStateTranslationAndScaled(.) -> Matrix_MultVec$1 * Matrix_FromRSPMatrix -> Matrix_MtxToMtxF * Matrix_MultiplyVector3fByMatrix -> Matrix_MultVec3fExt * Matrix_TransposeXYZ -> Matrix_Transpose * Matrix_ToRSPMatrix -> Matrix_MtxFToMtx * Matrix_AppendToPolyOpaDisp -> Matrix_MtxFToNewMtx and document the conversion functions * Matrix_NormalizeXYZ -> Matrix_ReplaceRotation * Matrix_InsertRotationAroundUnitVector_f -> Matrix_RotateAxisF and S * Matrix_InsertRotation -> Matrix_RotateZYX * Document the last functions * Small cleanup * Matrix_JointPosition -> Matrix_TranslateRotateZYX * Matrix_SetStateRotationAndTranslation -> Matrix_SetTranslateRotateYXZ * func_8018219C -> Matrix_MtxFToYXZRot * func_801822C4 -> Matrix_MtxFToZYXRot * Fix files * Format * Review 1 * Renames * Fix warning in EnDragon * Format * Convert `mode` to an actual enum * Add enums, typedefs, externs to sys_matrix header * Review * One more * More review * Fix function names * Format * Fix names * Format * Review * engineer's review * Fix build * Format * Fix again Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> --- docs/tutorial/documenting.md | 8 +- docs/tutorial/draw_functions.md | 14 +- include/PR/gbi.h | 365 +++- include/PR/ultratypes.h | 12 +- include/functions.h | 51 +- include/sys_matrix.h | 81 + include/variables.h | 2 - include/z64.h | 23 +- include/z64math.h | 8 +- spec | 2 - src/boot_O2/boot_80086760.c | 4 +- src/boot_O2/mtxuty-cvt.c | 13 +- src/code/sys_matrix.c | 1935 ++++++++++++++++- src/code/z_actor.c | 93 +- src/code/z_bgcheck.c | 24 +- src/code/z_collision_check.c | 4 +- src/code/z_debug_display.c | 8 +- src/code/z_eff_footmark.c | 2 +- src/code/z_fcurve_data_skelanime.c | 6 +- src/code/z_fireobj.c | 2 +- src/code/z_lights.c | 2 +- src/code/z_skelanime.c | 92 +- src/code/z_skin.c | 18 +- src/code/z_skin_matrix.c | 529 +++-- src/code/z_sub_s.c | 30 +- src/code/z_view.c | 16 +- src/code/z_vr_box_draw.c | 16 +- src/libultra/gu/cosf.c | 23 +- src/libultra/gu/perspective.c | 2 +- src/libultra/gu/position.c | 12 +- src/libultra/gu/rotate.c | 4 +- src/libultra/gu/sinf.c | 23 +- .../actors/ovl_Arms_Hook/z_arms_hook.c | 19 +- .../actors/ovl_Arrow_Fire/z_arrow_fire.c | 32 +- .../actors/ovl_Arrow_Ice/z_arrow_ice.c | 16 +- .../actors/ovl_Arrow_Light/z_arrow_light.c | 16 +- .../ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c | 16 +- .../ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c | 70 +- .../ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c | 38 +- .../z_bg_dblue_waterfall.c | 8 +- .../actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c | 8 +- .../z_bg_hakugin_bombwall.c | 14 +- .../ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c | 10 +- .../ovl_Bg_Ikana_Block/z_bg_ikana_block.c | 12 +- .../z_bg_ikana_bombwall.c | 10 +- .../z_bg_ikana_rotaryroom.c | 249 ++- .../ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c | 10 +- .../ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c | 32 +- .../actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c | 12 +- .../actors/ovl_Bg_Spdweb/z_bg_spdweb.c | 8 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 71 +- src/overlays/actors/ovl_Boss_03/z_boss_03.c | 129 +- src/overlays/actors/ovl_Boss_04/z_boss_04.c | 116 +- src/overlays/actors/ovl_Boss_06/z_boss_06.c | 46 +- .../actors/ovl_Demo_Effect/z_demo_effect.c | 10 +- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 29 +- .../actors/ovl_Demo_Syoten/z_demo_syoten.c | 12 +- src/overlays/actors/ovl_Dm_An/z_dm_an.c | 32 +- .../actors/ovl_Dm_Char00/z_dm_char00.c | 4 +- .../actors/ovl_Dm_Char01/z_dm_char01.c | 2 +- .../actors/ovl_Dm_Char05/z_dm_char05.c | 23 +- src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c | 32 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 12 +- .../actors/ovl_Door_Shutter/z_door_shutter.c | 12 +- .../actors/ovl_Door_Warp1/z_door_warp1.c | 28 +- src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c | 22 +- src/overlays/actors/ovl_En_Ah/z_en_ah.c | 26 +- .../ovl_En_Akindonuts/z_en_akindonuts.c | 2 +- src/overlays/actors/ovl_En_Al/z_en_al.c | 30 +- src/overlays/actors/ovl_En_Am/z_en_am.c | 2 +- src/overlays/actors/ovl_En_Ani/z_en_ani.c | 4 +- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 14 +- src/overlays/actors/ovl_En_Arrow/z_en_arrow.c | 22 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 16 +- src/overlays/actors/ovl_En_Baguo/z_en_baguo.c | 8 +- src/overlays/actors/ovl_En_Bb/z_en_bb.c | 18 +- .../actors/ovl_En_Bba_01/z_en_bba_01.c | 20 +- .../actors/ovl_En_Bbfall/z_en_bbfall.c | 18 +- .../actors/ovl_En_Bigokuta/z_en_bigokuta.c | 6 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 36 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 58 +- .../actors/ovl_En_Bigslime/z_en_bigslime.h | 2 +- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 2 +- src/overlays/actors/ovl_En_Bom/z_en_bom.c | 34 +- .../actors/ovl_En_Bom_Chu/z_en_bom_chu.c | 32 +- src/overlays/actors/ovl_En_Bombf/z_en_bombf.c | 4 +- src/overlays/actors/ovl_En_Boom/z_en_boom.c | 13 +- src/overlays/actors/ovl_En_Bu/z_en_bu.c | 8 +- src/overlays/actors/ovl_En_Butte/z_en_butte.c | 12 +- src/overlays/actors/ovl_En_Cha/z_en_cha.c | 4 +- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.c | 61 +- .../actors/ovl_En_Cne_01/z_en_cne_01.c | 20 +- src/overlays/actors/ovl_En_Cow/z_en_cow.c | 2 +- src/overlays/actors/ovl_En_Crow/z_en_crow.c | 4 +- src/overlays/actors/ovl_En_Dai/z_en_dai.c | 24 +- .../actors/ovl_En_Daiku2/z_en_daiku2.c | 12 +- .../actors/ovl_En_Dekunuts/z_en_dekunuts.c | 12 +- src/overlays/actors/ovl_En_Dg/z_en_dg.c | 16 +- .../actors/ovl_En_Dinofos/z_en_dinofos.c | 14 +- src/overlays/actors/ovl_En_Dnb/z_en_dnb.c | 36 +- src/overlays/actors/ovl_En_Dnk/z_en_dnk.c | 28 +- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 16 +- src/overlays/actors/ovl_En_Dnp/z_en_dnp.c | 18 +- src/overlays/actors/ovl_En_Dns/z_en_dns.c | 18 +- .../actors/ovl_En_Dodongo/z_en_dodongo.c | 12 +- .../actors/ovl_En_Dragon/z_en_dragon.c | 8 +- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 4 +- .../actors/ovl_En_Elfbub/z_en_elfbub.c | 8 +- .../actors/ovl_En_Elforg/z_en_elforg.c | 2 +- .../actors/ovl_En_Encount2/z_en_encount2.c | 6 +- src/overlays/actors/ovl_En_Fall/z_en_fall.c | 17 +- src/overlays/actors/ovl_En_Famos/z_en_famos.c | 10 +- src/overlays/actors/ovl_En_Fg/z_en_fg.c | 16 +- .../actors/ovl_En_Firefly/z_en_firefly.c | 8 +- src/overlays/actors/ovl_En_Fish2/z_en_fish2.c | 12 +- .../actors/ovl_En_Fishing/z_en_fishing.c | 354 +-- .../actors/ovl_En_Floormas/z_en_floormas.c | 16 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 2 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 50 +- .../actors/ovl_En_Fu_Kago/z_en_fu_kago.c | 12 +- .../actors/ovl_En_Fu_Mato/z_en_fu_mato.c | 12 +- src/overlays/actors/ovl_En_Fz/z_en_fz.c | 18 +- .../actors/ovl_En_Gakufu/z_en_gakufu.c | 7 +- src/overlays/actors/ovl_En_Gb2/z_en_gb2.c | 4 +- src/overlays/actors/ovl_En_Geg/z_en_geg.c | 56 +- src/overlays/actors/ovl_En_Gg/z_en_gg.c | 40 +- src/overlays/actors/ovl_En_Gg2/z_en_gg2.c | 6 +- src/overlays/actors/ovl_En_Giant/z_en_giant.c | 4 +- .../actors/ovl_En_Ginko_Man/z_en_ginko_man.c | 12 +- src/overlays/actors/ovl_En_GirlA/z_en_girla.c | 2 +- src/overlays/actors/ovl_En_Gk/z_en_gk.c | 48 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 30 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 77 +- .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 20 +- src/overlays/actors/ovl_En_Gs/z_en_gs.c | 30 +- .../ovl_En_Guard_Nuts/z_en_guard_nuts.c | 2 +- .../actors/ovl_En_Hakurock/z_en_hakurock.c | 2 +- .../actors/ovl_En_Hanabi/z_en_hanabi.c | 10 +- src/overlays/actors/ovl_En_Hg/z_en_hg.c | 6 +- src/overlays/actors/ovl_En_Hgo/z_en_hgo.c | 6 +- .../actors/ovl_En_Hint_Skb/z_en_hint_skb.c | 8 +- src/overlays/actors/ovl_En_Holl/z_en_holl.c | 2 +- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 2 +- .../z_en_horse_game_check.c | 16 +- src/overlays/actors/ovl_En_Hs/z_en_hs.c | 2 +- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 20 +- src/overlays/actors/ovl_En_In/z_en_in.c | 20 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 88 +- src/overlays/actors/ovl_En_Ishi/z_en_ishi.c | 12 +- src/overlays/actors/ovl_En_Ja/z_en_ja.c | 54 +- .../actors/ovl_En_Jc_Mato/z_en_jc_mato.c | 2 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 14 +- .../actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c | 2 +- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 2 +- src/overlays/actors/ovl_En_Kame/z_en_kame.c | 6 +- .../actors/ovl_En_Kanban/z_en_kanban.c | 61 +- .../actors/ovl_En_Karebaba/z_en_karebaba.c | 23 +- src/overlays/actors/ovl_En_Kbt/z_en_kbt.c | 2 +- src/overlays/actors/ovl_En_Kgy/z_en_kgy.c | 12 +- src/overlays/actors/ovl_En_Kusa/z_en_kusa.c | 2 +- src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c | 6 +- src/overlays/actors/ovl_En_Light/z_en_light.c | 6 +- .../actors/ovl_En_Look_Nuts/z_en_look_nuts.c | 8 +- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 2 +- .../actors/ovl_En_Ma_Yto/z_en_ma_yto.c | 2 +- .../actors/ovl_En_Ma_Yts/z_en_ma_yts.c | 2 +- .../actors/ovl_En_Maruta/z_en_maruta.c | 22 +- .../actors/ovl_En_Minifrog/z_en_minifrog.c | 4 +- src/overlays/actors/ovl_En_Mk/z_en_mk.c | 2 +- src/overlays/actors/ovl_En_Mm/z_en_mm.c | 6 +- src/overlays/actors/ovl_En_Mm3/z_en_mm3.c | 4 +- .../actors/ovl_En_Mushi2/z_en_mushi2.c | 28 +- src/overlays/actors/ovl_En_Niw/z_en_niw.c | 8 +- .../actors/ovl_En_Nutsball/z_en_nutsball.c | 6 +- src/overlays/actors/ovl_En_Osk/z_en_osk.c | 6 +- src/overlays/actors/ovl_En_Osn/z_en_osn.c | 16 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 8 +- src/overlays/actors/ovl_En_Ot/z_en_ot.c | 52 +- src/overlays/actors/ovl_En_Owl/z_en_owl.c | 8 +- .../actors/ovl_En_Pamera/z_en_pamera.c | 2 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 30 +- .../actors/ovl_En_Pametfrog/z_en_pametfrog.h | 6 +- .../actors/ovl_En_Peehat/z_en_peehat.c | 44 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 24 +- .../actors/ovl_En_Po_Fusen/z_en_po_fusen.c | 6 +- .../ovl_En_Po_Sisters/z_en_po_sisters.c | 20 +- src/overlays/actors/ovl_En_Poh/z_en_poh.c | 23 +- src/overlays/actors/ovl_En_Pr/z_en_pr.c | 6 +- src/overlays/actors/ovl_En_Pr2/z_en_pr2.c | 6 +- src/overlays/actors/ovl_En_Prz/z_en_prz.c | 4 +- .../actors/ovl_En_Racedog/z_en_racedog.c | 14 +- src/overlays/actors/ovl_En_Raf/z_en_raf.c | 20 +- .../actors/ovl_En_Rail_Skb/z_en_rail_skb.c | 8 +- .../actors/ovl_En_Railgibud/z_en_railgibud.c | 2 +- src/overlays/actors/ovl_En_Rd/z_en_rd.c | 2 +- .../actors/ovl_En_Recepgirl/z_en_recepgirl.c | 4 +- src/overlays/actors/ovl_En_Rg/z_en_rg.c | 22 +- src/overlays/actors/ovl_En_Rr/z_en_rr.c | 34 +- src/overlays/actors/ovl_En_Rsn/z_en_rsn.c | 4 +- .../actors/ovl_En_Scopenuts/z_en_scopenuts.c | 2 +- src/overlays/actors/ovl_En_Sda/z_en_sda.c | 27 +- .../actors/ovl_En_Sellnuts/z_en_sellnuts.c | 4 +- src/overlays/actors/ovl_En_Shn/z_en_shn.c | 20 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 6 +- .../actors/ovl_En_Snowman/z_en_snowman.c | 10 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 4 +- src/overlays/actors/ovl_En_Ssh/z_en_ssh.c | 28 +- src/overlays/actors/ovl_En_St/z_en_st.c | 5 +- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 10 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 36 +- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 56 +- .../ovl_En_Syateki_Crow/z_en_syateki_crow.c | 4 +- .../z_en_syateki_dekunuts.c | 2 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 12 +- .../ovl_En_Syateki_Okuta/z_en_syateki_okuta.c | 4 +- .../ovl_En_Syateki_Wf/z_en_syateki_wf.c | 2 +- src/overlays/actors/ovl_En_Tab/z_en_tab.c | 16 +- .../ovl_En_Talk_Gibud/z_en_talk_gibud.c | 2 +- .../actors/ovl_En_Tanron1/z_en_tanron1.c | 34 +- .../actors/ovl_En_Tanron2/z_en_tanron2.c | 41 +- .../actors/ovl_En_Tanron3/z_en_tanron3.c | 10 +- .../actors/ovl_En_Tanron4/z_en_tanron4.c | 2 +- .../actors/ovl_En_Tanron5/z_en_tanron5.c | 4 +- src/overlays/actors/ovl_En_Test/z_en_test.c | 6 +- src/overlays/actors/ovl_En_Test6/z_en_test6.c | 55 +- src/overlays/actors/ovl_En_Test7/z_en_test7.c | 22 +- .../actors/ovl_En_Thiefbird/z_en_thiefbird.c | 18 +- src/overlays/actors/ovl_En_Tite/z_en_tite.c | 16 +- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 6 +- src/overlays/actors/ovl_En_Trt/z_en_trt.c | 22 +- src/overlays/actors/ovl_En_Trt2/z_en_trt2.c | 24 +- src/overlays/actors/ovl_En_Tru/z_en_tru.c | 46 +- .../actors/ovl_En_Tru_Mt/z_en_tru_mt.c | 48 +- src/overlays/actors/ovl_En_Tsn/z_en_tsn.c | 2 +- src/overlays/actors/ovl_En_Vm/z_en_vm.c | 13 +- .../actors/ovl_En_Wallmas/z_en_wallmas.c | 18 +- .../actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c | 4 +- .../ovl_En_Water_Effect/z_en_water_effect.c | 52 +- src/overlays/actors/ovl_En_Wf/z_en_wf.c | 4 +- .../actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c | 4 +- .../actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c | 65 +- src/overlays/actors/ovl_En_Yb/z_en_yb.c | 8 +- src/overlays/actors/ovl_En_Zo/z_en_zo.c | 22 +- src/overlays/actors/ovl_En_Zob/z_en_zob.c | 2 +- src/overlays/actors/ovl_En_Zog/z_en_zog.c | 8 +- .../actors/ovl_En_Zoraegg/z_en_zoraegg.c | 26 +- src/overlays/actors/ovl_En_Zos/z_en_zos.c | 10 +- src/overlays/actors/ovl_En_Zot/z_en_zot.c | 14 +- src/overlays/actors/ovl_En_Zov/z_en_zov.c | 6 +- src/overlays/actors/ovl_En_Zow/z_en_zow.c | 20 +- src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c | 62 +- src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c | 6 +- src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c | 8 +- .../actors/ovl_Obj_Armos/z_obj_armos.c | 8 +- src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c | 20 +- src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c | 22 +- .../actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c | 2 +- src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c | 32 +- src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c | 12 +- .../actors/ovl_Obj_Dhouse/z_obj_dhouse.c | 12 +- src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c | 18 +- .../actors/ovl_Obj_Entotu/z_obj_entotu.c | 9 +- .../ovl_Obj_Flowerpot/z_obj_flowerpot.c | 12 +- .../actors/ovl_Obj_Funen/z_obj_funen.c | 2 +- .../actors/ovl_Obj_Grass/z_obj_grass.c | 6 +- .../actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c | 32 +- .../actors/ovl_Obj_Hariko/z_obj_hariko.c | 8 +- .../ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c | 24 +- .../actors/ovl_Obj_Iceblock/z_obj_iceblock.c | 26 +- .../ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c | 24 +- .../actors/ovl_Obj_Kinoko/z_obj_kinoko.c | 2 +- .../ovl_Obj_Lightswitch/z_obj_lightswitch.c | 14 +- .../ovl_Obj_Moon_Stone/z_obj_moon_stone.c | 2 +- .../actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c | 2 +- .../actors/ovl_Obj_Smork/z_obj_smork.c | 5 +- .../actors/ovl_Obj_Snowball/z_obj_snowball.c | 8 +- .../ovl_Obj_Snowball2/z_obj_snowball2.c | 6 +- .../ovl_Obj_Spidertent/z_obj_spidertent.c | 16 +- .../ovl_Obj_Spinyroll/z_obj_spinyroll.c | 2 +- .../actors/ovl_Obj_Switch/z_obj_switch.c | 40 +- .../actors/ovl_Obj_Syokudai/z_obj_syokudai.c | 6 +- .../ovl_Obj_Tokei_Step/z_obj_tokei_step.c | 24 +- .../actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c | 48 +- src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c | 2 +- .../ovl_Obj_Vspinyroll/z_obj_vspinyroll.c | 24 +- .../ovl_Obj_Warpstone/z_obj_warpstone.c | 16 +- src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c | 12 +- .../ovl_Object_Kankyo/z_object_kankyo.c | 24 +- .../actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c | 10 +- .../z_eff_en_ice_block.c | 6 +- .../ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c | 2 +- .../ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c | 6 +- .../effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c | 4 +- .../ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c | 2 +- .../ovl_Effect_Ss_Stick/z_eff_ss_stick.c | 4 +- .../ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c | 2 +- .../gamestates/ovl_daytelop/z_daytelop.c | 2 +- .../gamestates/ovl_opening/z_opening.c | 2 +- src/overlays/gamestates/ovl_title/z_title.c | 6 +- tools/disasm/functions.txt | 74 +- tools/namefixer.py | 112 +- tools/sizes/boot_functions.csv | 4 +- tools/sizes/code_functions.csv | 70 +- 303 files changed, 5474 insertions(+), 3324 deletions(-) create mode 100644 include/sys_matrix.h diff --git a/docs/tutorial/documenting.md b/docs/tutorial/documenting.md index a5e64d2a9..7e8435da9 100644 --- a/docs/tutorial/documenting.md +++ b/docs/tutorial/documenting.md @@ -235,8 +235,8 @@ void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *thisx) { EnRecepgirl* this = THIS; if (limbIndex == 5) { - Matrix_RotateY(0x400 - this->unk_2AE.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.focus.pos); + Matrix_RotateYS(0x400 - this->unk_2AE.x, MTXMODE_APPLY); + Matrix_MultVecX(500.0f, &this->actor.focus.pos); } } @@ -426,8 +426,8 @@ void EnRecepgirl_UnkLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi EnRecepgirl* this = THIS; if (limbIndex == 5) { - Matrix_RotateY(0x400 - this->unk_2AE.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.focus.pos); + Matrix_RotateYS(0x400 - this->unk_2AE.x, MTXMODE_APPLY); + Matrix_MultVecX(500.0f, &this->actor.focus.pos); } } ``` diff --git a/docs/tutorial/draw_functions.md b/docs/tutorial/draw_functions.md index eae1c121e..4eb22bf4f 100644 --- a/docs/tutorial/draw_functions.md +++ b/docs/tutorial/draw_functions.md @@ -163,22 +163,22 @@ As for the TransformLimbDraw, it has a much simpler prototype. mips2c gives ```C void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *actor) { if (limbIndex == 5) { - Matrix_RotateY((s16) (0x400 - actor->unk2AE), 1); - Matrix_GetStateTranslationAndScaledX(500.0f, (Vec3f *) &actor->focus); + Matrix_RotateYS((s16) (0x400 - actor->unk2AE), 1); + Matrix_MultVecX(500.0f, (Vec3f *) &actor->focus); } } ``` There is only minor cleanup needed here: - recasting the last argument, -- replacing the last argument of `Matrix_RotateY` by the enum `MTXMODE_APPLY` (which means "use the current matrix instead of starting from a new identity matrix"), and the first argument by `0x400 - this->unk_2AE.x`. +- replacing the last argument of `Matrix_RotateYS` by the enum `MTXMODE_APPLY` (which means "use the current matrix instead of starting from a new identity matrix"), and the first argument by `0x400 - this->unk_2AE.x`. - `(Vec3f *) &actor->focus` to `&actor->focus.pos` (this is the same issue as `(Actor*)this`, where mips2c doesn't climb deep enough into the struct). ```C void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *thisx) { EnRecepgirl* this = THIS; if (limbIndex == 5) { - Matrix_RotateY(0x400 - this->unk_2AE.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.focus.pos); + Matrix_RotateYS(0x400 - this->unk_2AE.x, MTXMODE_APPLY); + Matrix_MultVecX(500.0f, &this->actor.focus.pos); } } ``` @@ -213,7 +213,7 @@ void ObjTree_Draw(Actor *thisx, GlobalContext *globalCtx) { temp_s0->polyOpa.p = temp_v0_2 + 8; temp_v0_2->words.w1 = (u32) &D_06000680; temp_v0_2->words.w0 = 0xDE000000; - Matrix_InsertRotation(sp36, 0, sp34, 1); + Matrix_RotateZYX(sp36, 0, sp34, 1); temp_v0_3 = temp_s0->polyOpa.p; temp_s0->polyOpa.p = temp_v0_3 + 8; temp_v0_3->words.w0 = 0xDA380003; @@ -286,7 +286,7 @@ void ObjTree_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_06000680); - Matrix_InsertRotation(sp36, 0, sp34, MTXMODE_APPLY); + Matrix_RotateZYX(sp36, 0, sp34, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_060007C8); diff --git a/include/PR/gbi.h b/include/PR/gbi.h index ace2cd2e8..8e5aefe8e 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -1347,60 +1347,329 @@ typedef union { long int force_structure_alignment[4]; } Hilite; -#define gdSPDefLights0(ar,ag,ab) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ { 0, 0, 0},0,{ 0, 0, 0},0,{ 0, 0, 0},0}}} } -#define gdSPDefLights1(ar,ag,ab,r1,g1,b1,x1,y1,z1) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}} } -#define gdSPDefLights2(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}} } -#define gdSPDefLights3(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}} } -#define gdSPDefLights4(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}} } -#define gdSPDefLights5(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \ - {{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}} } +#define gdSPDefLights0(ar,ag,ab) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { 0, 0, 0 }, 0, \ + { 0, 0, 0 }, 0, \ + { 0, 0, 0 }, 0 \ + }} \ + } \ + } +#define gdSPDefLights1(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }} \ + } \ + } -#define gdSPDefLights6(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5,r6,g6,b6,x6,y6,z6) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \ - {{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}, \ - {{ {r6,g6,b6},0,{r6,g6,b6},0,{x6,y6,z6},0}}} } +#define gdSPDefLights2(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1, \ + r2,g2,b2, \ + x2,y2,z2) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }}, \ + {{ \ + { r2, g2, b2 }, 0, \ + { r2, g2, b2 }, 0, \ + { x2, y2, z2 }, 0 \ + }} \ + } \ + } +#define gdSPDefLights3(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1, \ + r2,g2,b2, \ + x2,y2,z2, \ + r3,g3,b3, \ + x3,y3,z3) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }}, \ + {{ \ + { r2, g2, b2 }, 0, \ + { r2, g2, b2 }, 0, \ + { x2, y2, z2 }, 0 \ + }}, \ + {{ \ + { r3, g3, b3 }, 0, \ + { r3, g3, b3 }, 0, \ + { x3, y3, z3 }, 0 \ + }} \ + } \ + } -#define gdSPDefLights7(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5,r6,g6,b6,x6,y6,z6,r7,g7,b7,x7,y7,z7) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \ - {{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}, \ - {{ {r6,g6,b6},0,{r6,g6,b6},0,{x6,y6,z6},0}}, \ - {{ {r7,g7,b7},0,{r7,g7,b7},0,{x7,y7,z7},0}}} } +#define gdSPDefLights4(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1, \ + r2,g2,b2, \ + x2,y2,z2, \ + r3,g3,b3, \ + x3,y3,z3, \ + r4,g4,b4, \ + x4,y4,z4) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }}, \ + {{ \ + { r2, g2, b2 }, 0, \ + { r2, g2, b2 }, 0, \ + { x2, y2, z2 }, 0 \ + }}, \ + {{ \ + { r3, g3, b3 }, 0, \ + { r3, g3, b3 }, 0, \ + { x3, y3, z3 }, 0 \ + }}, \ + {{ \ + { r4, g4, b4 }, 0, \ + { r4, g4, b4 }, 0, \ + { x4, y4, z4 }, 0 \ + }} \ + } \ + } +#define gdSPDefLights5(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1, \ + r2,g2,b2, \ + x2,y2,z2, \ + r3,g3,b3, \ + x3,y3,z3, \ + r4,g4,b4, \ + x4,y4,z4, \ + r5,g5,b5, \ + x5,y5,z5) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }}, \ + {{ \ + { r2, g2, b2 }, 0, \ + { r2, g2, b2 }, 0, \ + { x2, y2, z2 }, 0 \ + }}, \ + {{ \ + { r3, g3, b3 }, 0, \ + { r3, g3, b3 }, 0, \ + { x3, y3, z3 }, 0 \ + }}, \ + {{ \ + { r4, g4, b4 }, 0, \ + { r4, g4, b4 }, 0, \ + { x4, y4, z4 }, 0 \ + }}, \ + {{ \ + { r5, g5, b5 }, 0, \ + { r5, g5, b5 }, 0, \ + { x5, y5, z5 }, 0 \ + }} \ + } \ + } -#define gdSPDefLookAt(rightx,righty,rightz,upx,upy,upz) \ - { {{ {{0,0,0},0,{0,0,0},0,{rightx,righty,rightz},0}}, \ - { {{0,0x80,0},0,{0,0x80,0},0,{upx,upy,upz},0}}} } +#define gdSPDefLights6(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1, \ + r2,g2,b2, \ + x2,y2,z2, \ + r3,g3,b3, \ + x3,y3,z3, \ + r4,g4,b4, \ + x4,y4,z4, \ + r5,g5,b5, \ + x5,y5,z5, \ + r6,g6,b6, \ + x6,y6,z6) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }}, \ + {{ \ + { r2, g2, b2 }, 0, \ + { r2, g2, b2 }, 0, \ + { x2, y2, z2 }, 0 \ + }}, \ + {{ \ + { r3, g3, b3 }, 0, \ + { r3, g3, b3 }, 0, \ + { x3, y3, z3 }, 0 \ + }}, \ + {{ \ + { r4, g4, b4 }, 0, \ + { r4, g4, b4 }, 0, \ + { x4, y4, z4 }, 0 \ + }}, \ + {{ \ + { r5, g5, b5 }, 0, \ + { r5, g5, b5 }, 0, \ + { x5, y5, z5 }, 0 \ + }}, \ + {{ \ + { r6, g6, b6 }, 0, \ + { r6, g6, b6 }, 0, \ + { x6, y6, z6 }, 0 \ + }} \ + } \ + } + +#define gdSPDefLights7(ar,ag,ab, \ + r1,g1,b1, \ + x1,y1,z1, \ + r2,g2,b2, \ + x2,y2,z2, \ + r3,g3,b3, \ + x3,y3,z3, \ + r4,g4,b4, \ + x4,y4,z4, \ + r5,g5,b5, \ + x5,y5,z5, \ + r6,g6,b6, \ + x6,y6,z6, \ + r7,g7,b7, \ + x7,y7,z7) \ + { \ + {{ \ + { ar, ag, ab }, 0, \ + { ar, ag, ab }, 0 \ + }}, \ + { \ + {{ \ + { r1, g1, b1 }, 0, \ + { r1, g1, b1 }, 0, \ + { x1, y1, z1 }, 0 \ + }}, \ + {{ \ + { r2, g2, b2 }, 0, \ + { r2, g2, b2 }, 0, \ + { x2, y2, z2 }, 0 \ + }}, \ + {{ \ + { r3, g3, b3 }, 0, \ + { r3, g3, b3 }, 0, \ + { x3, y3, z3 }, 0 \ + }}, \ + {{ \ + { r4, g4, b4 }, 0, \ + { r4, g4, b4 }, 0, \ + { x4, y4, z4 }, 0 \ + }}, \ + {{ \ + { r5, g5, b5 }, 0, \ + { r5, g5, b5 }, 0, \ + { x5, y5, z5 }, 0 \ + }}, \ + {{ \ + { r6, g6, b6 }, 0, \ + { r6, g6, b6 }, 0, \ + { x6, y6, z6 }, 0 \ + }}, \ + {{ \ + { r7, g7, b7 }, 0, \ + { r7, g7, b7 }, 0, \ + { x7, y7, z7 }, 0 \ + }} \ + } \ + } + +#define gdSPDefLookAt(rightx,righty,rightz,upx,upy,upz) \ + {{ \ + {{ \ + { 0, 0, 0 }, 0, \ + { 0, 0, 0 }, 0, \ + { rightx, righty, rightz }, 0 \ + }}, \ + {{ \ + { 0, 0x80, 0 }, 0, \ + { 0, 0x80, 0 }, 0, \ + { upx, upy, upz }, 0 \ + }} \ + }} + +#define qs1616(e) ((s32)((e) * 0x00010000)) + +#define IPART(x) ((qs1616(x) >> 16) & 0xFFFF) +#define FPART(x) (qs1616(x) & 0xFFFF) + +#define gdSPDefMtx( \ + xx, yx, zx, wx, \ + xy, yy, zy, wy, \ + xz, yz, zz, wz, \ + xw, yw, zw, ww) \ + {{ \ + (IPART(xx) << 0x10) | IPART(xy), \ + (IPART(xz) << 0x10) | IPART(xw), \ + (IPART(yx) << 0x10) | IPART(yy), \ + (IPART(yz) << 0x10) | IPART(yw), \ + (IPART(zx) << 0x10) | IPART(zy), \ + (IPART(zz) << 0x10) | IPART(zw), \ + (IPART(wx) << 0x10) | IPART(wy), \ + (IPART(wz) << 0x10) | IPART(ww), \ + (FPART(xx) << 0x10) | FPART(xy), \ + (FPART(xz) << 0x10) | FPART(xw), \ + (FPART(yx) << 0x10) | FPART(yy), \ + (FPART(yz) << 0x10) | FPART(yw), \ + (FPART(zx) << 0x10) | FPART(zy), \ + (FPART(zz) << 0x10) | FPART(zw), \ + (FPART(wx) << 0x10) | FPART(wy), \ + (FPART(wz) << 0x10) | FPART(ww), \ + }} /* * Graphics DMA Packet diff --git a/include/PR/ultratypes.h b/include/PR/ultratypes.h index 0e6f4cf39..8b4e1a82c 100644 --- a/include/PR/ultratypes.h +++ b/include/PR/ultratypes.h @@ -27,6 +27,10 @@ typedef void* TexturePtr; typedef long int Mtx_t[4][4]; typedef union { Mtx_t m; + struct { + u16 intPart[4][4]; + u16 fracPart[4][4]; + }; long long int forc_structure_alignment; } Mtx; // size = 0x40 @@ -34,10 +38,10 @@ typedef float MtxF_t[4][4]; typedef union { MtxF_t mf; struct { - float xx, xy, xz, xw, - yx, yy, yz, yw, - zx, zy, zz, zw, - wx, wy, wz, ww; + float xx, yx, zx, wx, + xy, yy, zy, wy, + xz, yz, zz, wz, + xw, yw, zw, ww; }; } MtxF; // size = 0x40 diff --git a/include/functions.h b/include/functions.h index 8c04ba259..b4ff2ad8d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -148,8 +148,8 @@ void GfxPrint_Open(GfxPrint* printer, Gfx* dList); Gfx* GfxPrint_Close(GfxPrint* printer); s32 GfxPrint_VPrintf(GfxPrint* printer, const char* fmt, va_list args); s32 GfxPrint_Printf(GfxPrint* printer, const char* fmt, ...); -void MtxConv_F2L(MatrixInternal* m1, MtxF* m2); -void MtxConv_L2F(MtxF* m1, MatrixInternal* m2); +void MtxConv_F2L(Mtx* m1, MtxF* m2); +void MtxConv_L2F(MtxF* m1, Mtx* m2); void __assert(const char* file, u32 lineNum); // void func_800862B4(void); void* SystemArena_MallocMin1(u32 size); @@ -220,7 +220,7 @@ OSIntMask osSetIntMask(OSIntMask im); // OSIntMask osGetIntMask(void); // void osVoiceSetWord(void); // void guScale(void); -f32 __sinf(f32 __x); +f32 sinf(f32 __x); s16 sins(u16 x); OSTask* _VirtualToPhysicalTask(OSTask* intp); void osSpTaskLoad(OSTask* intp); @@ -377,7 +377,7 @@ void __osRestoreInt(OSIntMask im); void __osViInit(void); void __osViSwapContext(void); OSMesgQueue* osPiGetCmdQueue(void); -f32 __cosf(f32 __x); +f32 cosf(f32 __x); s32 osEPiReadIo(OSPiHandle* pihandle, u32 devAddr, u32* data); void osViSetSpecialFeatures(u32 func); s16 coss(u16 x); @@ -3072,53 +3072,12 @@ s32 Math3D_XYInSphere(Sphere16* sphere, f32 x, f32 y); s32 Math3D_YZInSphere(Sphere16* sphere, f32 y, f32 z); // void func_8017FB1C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); // void func_8017FD44(void); + u16 Math_GetAtan2Tbl(f32 opposite, f32 adjacent); s16 Math_Atan2S(f32 opposite, f32 adjacent); f32 Math_Atan2F(f32 opposite, f32 adjacent); s16 Math_FAtan2F(f32 adjacent, f32 opposite); f32 Math_Acot2F(f32 adjacent, f32 opposite); -void Matrix_StateAlloc(GameState* gameState); -void Matrix_StatePush(void); -void Matrix_StatePop(void); -void Matrix_CopyCurrentState(MtxF* matrix); -void Matrix_SetCurrentState(MtxF* matrix); -MtxF* Matrix_GetCurrentState(void); -void Matrix_InsertMatrix(MtxF* matrix, s32 appendToState); -void Matrix_InsertTranslation(f32 x, f32 y, f32 z, s32 appendToState); -void Matrix_Scale(f32 xScale, f32 yScale, f32 zScale, s32 appendToState); -void Matrix_InsertXRotation_s(s16 rotation, s32 appendToState); -void Matrix_InsertXRotation_f(f32 rotation, s32 appendToState); -void Matrix_RotateStateAroundXAxis(f32 rotation); -void Matrix_SetStateXRotation(f32 rotation); -void Matrix_RotateY(s16 rotation, s32 appendToState); -void Matrix_InsertYRotation_f(f32 rotation, s32 appendToState); -void Matrix_InsertZRotation_s(s16 rotation, s32 appendToState); -void Matrix_InsertZRotation_f(f32 rotation, s32 appendToState); -void Matrix_InsertRotation(s16 xRotation, s16 yRotation, s16 zRotation, s32 appendToState); -void Matrix_JointPosition(Vec3f* position, Vec3s* rotation); -void Matrix_RotateAndTranslateState(Vec3f* translation, Vec3s* rotation); -void Matrix_SetStateRotationAndTranslation(f32 x, f32 y, f32 z, Vec3s* rotation); -RSPMatrix* Matrix_ToRSPMatrix(MtxF* src, RSPMatrix* dst); -Mtx* Matrix_ToMtx(Mtx* dest); -RSPMatrix* Matrix_GetStateAsRSPMatrix(RSPMatrix* matrix); -Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx); -RSPMatrix* Matrix_AppendStateToPolyOpaDisp(GraphicsContext* gfxCtx); -void Matrix_AppendToPolyOpaDisp(MtxF* mtx, GraphicsContext* gfxCtx); -void Matrix_MultiplyVector3fByState(Vec3f* src, Vec3f* dst); -void Matrix_GetStateTranslation(Vec3f* dst); -void Matrix_GetStateTranslationAndScaledX(f32 scale, Vec3f* dst); -void Matrix_GetStateTranslationAndScaledY(f32 scale, Vec3f* dst); -void Matrix_GetStateTranslationAndScaledZ(f32 scale, Vec3f* dst); -void Matrix_MultiplyVector3fXZByCurrentState(Vec3f* src, Vec3f* dst); -void Matrix_MtxFCopy(MtxF* dst, MtxF* src); -void Matrix_FromRSPMatrix(Mtx* src, MtxF* dst); -void Matrix_MultiplyVector3fByMatrix(Vec3f* src, Vec3f* dst, MtxF* matrix); -void Matrix_TransposeXYZ(MtxF* matrix); -void Matrix_NormalizeXYZ(MtxF* matrix); -void func_8018219C(MtxF* pfParm1, Vec3s* psParm2, s32 iParm3); -// void func_801822C4(void); -void Matrix_InsertRotationAroundUnitVector_f(f32 rotation, Vec3f* vector, s32 appendToState); -void Matrix_InsertRotationAroundUnitVector_s(s16 rotation, Vec3f* vector, s32 appendToState); u64* SysUcode_GetUCodeBoot(void); size_t SysUcode_GetUCodeBootSize(void); diff --git a/include/sys_matrix.h b/include/sys_matrix.h new file mode 100644 index 000000000..536322624 --- /dev/null +++ b/include/sys_matrix.h @@ -0,0 +1,81 @@ +#ifndef SYS_MATRIX_H +#define SYS_MATRIX_H + +#include "z64math.h" + + +struct GraphicsContext; +struct GameState; + + +typedef enum { + /* 0 */ MTXMODE_NEW, // generates a new matrix + /* 1 */ MTXMODE_APPLY // applies transformation to the current matrix +} MatrixMode; + + +extern Mtx gIdentityMtx; +extern MtxF gIdentityMtxF; + + +/* Stack operations */ + +void Matrix_Init(struct GameState* gameState); +void Matrix_Push(void); +void Matrix_Pop(void); +void Matrix_Get(MtxF* dest); +void Matrix_Put(MtxF* src); +MtxF* Matrix_GetCurrent(void); + +/* Basic operations */ + +void Matrix_Mult(MtxF* matrix, MatrixMode mode); +void Matrix_Translate(f32 x, f32 y, f32 z, MatrixMode mode); +void Matrix_Scale(f32 x, f32 y, f32 z, MatrixMode mode); +void Matrix_RotateXS(s16 x, MatrixMode mode); +void Matrix_RotateXF(f32 x, MatrixMode mode); +void Matrix_RotateXFApply(f32 x); +void Matrix_RotateXFNew(f32 x); +void Matrix_RotateYS(s16 y, MatrixMode mode); +void Matrix_RotateYF(f32 y, MatrixMode mode); +void Matrix_RotateZS(s16 z, MatrixMode mode); +void Matrix_RotateZF(f32 z, MatrixMode mode); + +/* Compound operations */ + +void Matrix_RotateZYX(s16 x, s16 y, s16 z, MatrixMode mode); +void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rot); +void Matrix_SetTranslateRotateYXZ(f32 x, f32 y, f32 z, Vec3s* rot); + +/* Conversion and allocation operations */ + +Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest); +Mtx* Matrix_ToMtx(Mtx* dest); +Mtx* Matrix_NewMtx(struct GraphicsContext* gfxCtx); +Mtx* Matrix_MtxFToNewMtx(MtxF* src, struct GraphicsContext* gfxCtx); + +/* Vector operations */ + +void Matrix_MultVec3f(Vec3f* src, Vec3f* dest); +void Matrix_MultZero(Vec3f* dest); +void Matrix_MultVecX(f32 x, Vec3f* dest); +void Matrix_MultVecY(f32 y, Vec3f* dest); +void Matrix_MultVecZ(f32 z, Vec3f* dest); +void Matrix_MultVec3fXZ(Vec3f* src, Vec3f* dest); + +/* Copy and another conversion */ + +void Matrix_MtxFCopy(MtxF* dest, MtxF* src); +void Matrix_MtxToMtxF(Mtx* src, MtxF* dest); + +/* Miscellaneous */ + +void Matrix_MultVec3fExt(Vec3f* src, Vec3f* dest, MtxF* mf); +void Matrix_Transpose(MtxF* mf); +void Matrix_ReplaceRotation(MtxF* mf); +void Matrix_MtxFToYXZRot(MtxF* src, Vec3s* dest, s32 nonUniformScale); +void Matrix_MtxFToZYXRot(MtxF* src, Vec3s* dest, s32 nonUniformScale); +void Matrix_RotateAxisF(f32 angle, Vec3f* axis, MatrixMode mode); +void Matrix_RotateAxisS(s16 angle, Vec3f* axis, MatrixMode mode); + +#endif diff --git a/include/variables.h b/include/variables.h index 4acb019a4..c37938555 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1574,8 +1574,6 @@ extern UNK_PTR D_801D1540; // extern f32 sFactorialTbl[13]; extern Vec3f gZeroVec3f; extern Vec3s gZeroVec3s; -extern Mtx gIdentityMtx; -extern MtxF gIdentityMtxF; // extern UNK_TYPE1 D_801D1E70; extern s16 gLowPassFilterData[]; extern s16 gHighPassFilterData[]; diff --git a/include/z64.h b/include/z64.h index e5533234a..7f1dfd701 100644 --- a/include/z64.h +++ b/include/z64.h @@ -23,6 +23,7 @@ #include "sfx.h" #include "message_data_static.h" +#include "sys_matrix.h" #include "z64actor.h" #include "z64animation.h" #include "z64audio.h" @@ -304,11 +305,6 @@ typedef struct { /* 0x10 */ OSTime resetTime; } NmiBuff; // size >= 0x18 -typedef struct { - /* 0x00 */ s16 intPart[16]; - /* 0x20 */ u16 fracPart[16]; -} RSPMatrix; // size = 0x40 - typedef struct { /* 0x0 */ s8 letterboxTarget; /* 0x1 */ s8 letterboxMagnitude; @@ -383,13 +379,6 @@ typedef struct { /* 0x1A */ s16 unk1A; } s80874650; // size = 0x1C -typedef struct { - /* 0x00 */ f32 x[4]; - /* 0x10 */ f32 y[4]; - /* 0x20 */ f32 z[4]; - /* 0x30 */ f32 w[4]; -} z_Matrix; // size = 0x40 - typedef union { F3DVertexColor color; F3DVertexNormal normal; @@ -1421,16 +1410,6 @@ typedef struct { /* 0x14 */ Gfx* monoDl; } VisMono; // size = 0x18 -typedef enum { - MTXMODE_NEW, // generates a new matrix - MTXMODE_APPLY // applies transformation to the current matrix -} MatrixMode; - -typedef struct { - /* 0x00 */ u16 intPart[4][4]; - /* 0x20 */ u16 fracPart[4][4]; -} MatrixInternal; // size = 0x40 - typedef struct DebugDispObject { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3s rot; diff --git a/include/z64math.h b/include/z64math.h index 78e1743ec..33f05bb0a 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -1,5 +1,5 @@ -#ifndef _Z64MATH_H_ -#define _Z64MATH_H_ +#ifndef Z64MATH_H +#define Z64MATH_H #include "ultra64.h" @@ -111,7 +111,7 @@ typedef struct { // Trig macros #define DEGF_TO_BINANG(degreesf) (s16)(degreesf * 182.04167f + .5f) -#define RADF_TO_BINANG(radf) (s16)(radf * (32768.0f / M_PI)) +#define RADF_TO_BINANG(radf) (s16)(radf * (0x8000 / M_PI)) #define RADF_TO_DEGF(radf) (radf * (180.0f / M_PI)) #define DEGF_TO_RADF(degf) (degf * (M_PI / 180.0f)) #define BINANG_ROT180(angle) ((s16)(angle + 0x8000)) @@ -119,7 +119,7 @@ typedef struct { #define BINANG_ADD(a, b) ((s16)(a + b)) #define DEG_TO_RAD(degrees) ((degrees) * (M_PI / 180.0f)) #define BINANG_TO_DEGF(binang) ((f32)binang * (360.0001525f / 65535.0f)) -#define BINANG_TO_RAD(binang) (((f32)binang / 32768.0f) * M_PI) +#define BINANG_TO_RAD(binang) (((f32)binang / 0x8000) * M_PI) // Vector macros #define SQXZ(vec) ((vec.x) * (vec.x) + (vec.z) * (vec.z)) diff --git a/spec b/spec index 5c30f08c1..273170579 100644 --- a/spec +++ b/spec @@ -598,8 +598,6 @@ beginseg include "build/data/code/code_801D15B0.data.o" include "build/src/code/sys_math_atan.o" include "build/src/code/sys_matrix.o" - include "build/data/code/sys_matrix.data.o" - include "build/data/code/sys_matrix.bss.o" include "build/src/code/sys_ucode.o" include "build/src/code/code_80182CE0.o" include "build/data/code/code_801D1E70.data.o" diff --git a/src/boot_O2/boot_80086760.c b/src/boot_O2/boot_80086760.c index 3c75bcd3f..398a1e41a 100644 --- a/src/boot_O2/boot_80086760.c +++ b/src/boot_O2/boot_80086760.c @@ -14,11 +14,11 @@ extern f32 func_80086D18(f32 x); s32 gUseAtanContFrac; /** - * Tangent function computed using libultra __sinf and __cosf + * Tangent function computed using libultra sinf and cosf */ // Math_FTanF f32 func_80086760(f32 x) { - return __sinf(x) / __cosf(x); + return sinf(x) / cosf(x); } // Unused diff --git a/src/boot_O2/mtxuty-cvt.c b/src/boot_O2/mtxuty-cvt.c index 221dbf554..2c1634392 100644 --- a/src/boot_O2/mtxuty-cvt.c +++ b/src/boot_O2/mtxuty-cvt.c @@ -1,18 +1,19 @@ #include "global.h" -void MtxConv_F2L(MatrixInternal* m1, MtxF* m2) { +void MtxConv_F2L(Mtx* mtx, MtxF* mf) { s32 i; s32 j; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { - s32 value = (m2->mf[i][j] * 0x10000); - m1->intPart[i][j] = value >> 16; - m1->fracPart[i][j] = value; + s32 value = (mf->mf[i][j] * 0x10000); + + mtx->intPart[i][j] = value >> 16; + mtx->fracPart[i][j] = value; } } } -void MtxConv_L2F(MtxF* m1, MatrixInternal* m2) { - guMtxL2F(m1, (Mtx*)m2); +void MtxConv_L2F(MtxF* mtx, Mtx* mf) { + guMtxL2F(mtx, mf); } diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index a09d95200..f2ed19c38 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -1,89 +1,1944 @@ +/** + * @file sys_matrix.c + * @brief: Matrix system that mostly uses a matrix stack, and concerns affine transformations. + * + * @note The RSP matrix format (and hence the `MtxF` format) is column-major: vectors are presumed to be row vectors, + * and matrices as a column of row vectors. This means that, for example, a translation matrix + * \f[ + * \begin{pmatrix} + * 1 & 0 & 0 & x \\ + * 0 & 1 & 0 & y \\ + * 0 & 0 & 1 & z \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * will be stored as + * + * { { 1, 0, 0, 0 }, + * { 0, 1, 0, 0 }, + * { 0, 0, 1, 0 }, + * { x, y, z, 1 }, } + * + * @note As such, we label the elements in column-major order so we can follow the same conventions for multiplying + * matrices as the rest of the world, i.e. that \f$ [AB]_{ij} = \sum_k A_{ik} B_{kj} \f$. + * + * This file is primarily concerned with matrices representing affine transformations, implemented using an augmented + * matrix formalism, + * + * \f[ + * \begin{pmatrix} + * A & b \\ + * 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ A \f$ is a \f$ 3 \times 3 \f$ matrix (the *linear part*) and \f$ b \f$ a \f$ 3 \times 1 \f$ matrix, i.e. a + * 3D vector (the *translation part*), and most of the functions assume that the matrices have this form. + * + * Throughout this file, `mode` indicates whether to multiply the matrix on top of the stack by the new construction + * (APPLY), or to just overwrite it (NEW). + */ + #include "global.h" -void Matrix_StateAlloc(GameState* gameState) { - sMatrixStack = (MtxF*)THA_AllocEndAlign16(&gameState->heap, 0x500); +/* data */ + +// clang-format off +Mtx gIdentityMtx = gdSPDefMtx( + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f +); +// clang-format on + +MtxF gIdentityMtxF = { { + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f, 1.0f }, +} }; + +/* bss */ + +MtxF* sMatrixStack; //!< original name: "Matrix_stack" +MtxF* sCurrentMatrix; //!< original name: "Matrix_now" + +#define MATRIX_STACK_SIZE 20 + +/* Stack operations */ + +/** + * @brief Create the matrix stack and set the pointer to the top of it. + * + * @remark original name: "new_Matrix" + */ +void Matrix_Init(GameState* gameState) { + sMatrixStack = THA_AllocEndAlign16(&gameState->heap, MATRIX_STACK_SIZE * sizeof(MtxF)); sCurrentMatrix = sMatrixStack; } -void Matrix_StatePush(void) { +/** + * @brief Place a new matrix on the top of the stack and move the stack pointer up. + * + * @remark original name: "Matrix_push" + */ +void Matrix_Push(void) { MtxF* prev = sCurrentMatrix; sCurrentMatrix++; Matrix_MtxFCopy(sCurrentMatrix, prev); } -void Matrix_StatePop(void) { +/** + * @brief Discard the top matrix on the stack and move stack pointer to the next one down. + * + * @remark original name: "Matrix_pull" + */ +void Matrix_Pop(void) { sCurrentMatrix--; } -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_CopyCurrentState.s") +/** + * @brief Copy the top matrix from the stack. + * + * @param[out] dest Matrix into which to copy. + * + * @remark original name: "Matrix_get" + */ +void Matrix_Get(MtxF* dest) { + Matrix_MtxFCopy(dest, sCurrentMatrix); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_SetCurrentState.s") +/** + * @brief Overwrite the top matrix on the stack. + * + * @param[in] src Matrix from which to copy. + * + * @remark original name: "Matrix_put" + */ +void Matrix_Put(MtxF* src) { + Matrix_MtxFCopy(sCurrentMatrix, src); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetCurrentState.s") +/** + * @brief Return pointer to the top of the matrix stack. + * + * @return pointer to top matrix on the stack. + * + * @remark original name: get_Matrix_now + */ +MtxF* Matrix_GetCurrent(void) { + return sCurrentMatrix; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertMatrix.s") +/* General transformation matrix functions */ -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertTranslation.s") +/** + * @brief General multiplication of current by a matrix. + * - APPLY: current * mf -> current + * - NEW: mf -> current + * + * @param mf Matrix to multiply by. + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_mult" + */ +void Matrix_Mult(MtxF* mf, MatrixMode mode) { + MtxF* cmf = Matrix_GetCurrent(); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_Scale.s") + if (mode == MTXMODE_APPLY) { + SkinMatrix_MtxFMtxFMult(cmf, mf, cmf); + } else { + Matrix_MtxFCopy(sCurrentMatrix, mf); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertXRotation_s.s") +/** + * @brief Right-multiply current by a translation matrix T. + * - APPLY: current * T -> current + * - NEW: T -> current + * + * T is given by + * + * \f[ + * \begin{pmatrix} + * 1 & 0 & 0 & x \\ + * 0 & 1 & 0 & y \\ + * 0 & 0 & 1 & z \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} . + * \f] + * + * @param x translation distance in the x direction. + * @param y translation distance in the y direction. + * @param z translation distance in the z direction. + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_translate" + */ +void Matrix_Translate(f32 x, f32 y, f32 z, MatrixMode mode) { + MtxF* cmf = sCurrentMatrix; + f32 tempX; + f32 tempY; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertXRotation_f.s") + if (mode == MTXMODE_APPLY) { + tempX = cmf->xx; + tempY = cmf->xy; + cmf->xw += tempX * x + tempY * y + cmf->xz * z; + tempX = cmf->yx; + tempY = cmf->yy; + cmf->yw += tempX * x + tempY * y + cmf->yz * z; + tempX = cmf->zx; + tempY = cmf->zy; + cmf->zw += tempX * x + tempY * y + cmf->zz * z; + tempX = cmf->wx; + tempY = cmf->wy; + cmf->ww += tempX * x + tempY * y + cmf->wz * z; + } else { + SkinMatrix_SetTranslate(cmf, x, y, z); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_RotateStateAroundXAxis.s") +/** + * @brief Right-multiply by the diagonal scale matrix S = diag(x,y,z,1). + * - APPLY: current * S -> current + * - NEW: S -> current + * + * S is given by + * + * \f[ + * \begin{pmatrix} + * x & 0 & 0 & 0 \\ + * 0 & y & 0 & 0 \\ + * 0 & 0 & z & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} . + * \f] + * + * @param x scale in x direction. + * @param y scale in y direction. + * @param z scale in z direction. + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_scale" + */ +void Matrix_Scale(f32 x, f32 y, f32 z, MatrixMode mode) { + MtxF* cmf = sCurrentMatrix; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_SetStateXRotation.s") + if (mode == MTXMODE_APPLY) { + cmf->xx *= x; + cmf->yx *= x; + cmf->zx *= x; + cmf->xy *= y; + cmf->yy *= y; + cmf->zy *= y; + cmf->xz *= z; + cmf->yz *= z; + cmf->zz *= z; + cmf->wx *= x; + cmf->wy *= y; + cmf->wz *= z; + } else { + SkinMatrix_SetScale(cmf, x, y, z); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_RotateY.s") +/** + * @brief Right-multiply by a rotation about the x axis + * - APPLY: current * R -> current + * - NEW: R -> current + * + * R is given by + * + * \f[ + * \begin{pmatrix} + * 1 & 0 & 0 & 0 \\ + * 0 & c & -s & 0 \\ + * 0 & s & c & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ c = \cos x, s = \sin x \f$. + * + * @note The same as Matrix_RotateXF(), but uses a binary angle. + * + * @param x rotation angle (binary). + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_RotateX" + */ +void Matrix_RotateXS(s16 x, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempY; + f32 tempZ; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertYRotation_f.s") + if (mode == MTXMODE_APPLY) { + if (x != 0) { + cmf = sCurrentMatrix; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertZRotation_s.s") + sin = Math_SinS(x); + cos = Math_CosS(x); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertZRotation_f.s") + tempY = cmf->xy; + tempZ = cmf->xz; + cmf->xy = tempY * cos + tempZ * sin; + cmf->xz = tempZ * cos - tempY * sin; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertRotation.s") + tempY = cmf->yy; + tempZ = cmf->yz; + cmf->yy = tempY * cos + tempZ * sin; + cmf->yz = tempZ * cos - tempY * sin; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_JointPosition.s") + tempY = cmf->zy; + tempZ = cmf->zz; + cmf->zy = tempY * cos + tempZ * sin; + cmf->zz = tempZ * cos - tempY * sin; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_SetStateRotationAndTranslation.s") + tempY = cmf->wy; + tempZ = cmf->wz; + cmf->wy = tempY * cos + tempZ * sin; + cmf->wz = tempZ * cos - tempY * sin; + } + } else { + cmf = sCurrentMatrix; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_ToRSPMatrix.s") + if (x != 0) { + sin = Math_SinS(x); + cos = Math_CosS(x); + } else { + sin = 0.0f; + cos = 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_ToMtx.s") + cmf->yx = 0.0f; + cmf->zx = 0.0f; + cmf->wx = 0.0f; + cmf->xy = 0.0f; + cmf->wy = 0.0f; + cmf->xz = 0.0f; + cmf->wz = 0.0f; + cmf->xw = 0.0f; + cmf->yw = 0.0f; + cmf->zw = 0.0f; + cmf->xx = 1.0f; + cmf->ww = 1.0f; + cmf->yy = cos; + cmf->zz = cos; + cmf->zy = sin; + cmf->yz = -sin; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_NewMtx.s") +// Unused +/** + * @brief Right-multiply by a rotation about the x axis. + * - APPLY: current * R -> current + * - NEW: R -> current + * + * R is given by + * + * \f[ + * \begin{pmatrix} + * 1 & 0 & 0 & 0 \\ + * 0 & c & -s & 0 \\ + * 0 & s & c & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ c = \cos x, s = \sin x \f$. + * + * @note The same as Matrix_RotateXS(), but uses a float angle in radians. + * + * @param x rotation angle (radians). + * @param mode APPLY or NEW. + * + * @remark original name may have been "Matrix_RotateX", but clashed with the previous function. + */ +void Matrix_RotateXF(f32 x, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempY; + f32 tempZ; + f32 zero = 0.0; + f32 one = 1.0; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_AppendToPolyOpaDisp.s") + if (mode == MTXMODE_APPLY) { + if (x != 0) { + cmf = sCurrentMatrix; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fByState.s") + sin = sinf(x); + cos = cosf(x); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslation.s") + tempY = cmf->xy; + tempZ = cmf->xz; + cmf->xy = tempY * cos + tempZ * sin; + cmf->xz = tempZ * cos - tempY * sin; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledX.s") + tempY = cmf->yy; + tempZ = cmf->yz; + cmf->yy = tempY * cos + tempZ * sin; + cmf->yz = tempZ * cos - tempY * sin; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledY.s") + tempY = cmf->zy; + tempZ = cmf->zz; + cmf->zy = tempY * cos + tempZ * sin; + cmf->zz = tempZ * cos - tempY * sin; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledZ.s") + tempY = cmf->wy; + tempZ = cmf->wz; + cmf->wy = tempY * cos + tempZ * sin; + cmf->wz = tempZ * cos - tempY * sin; + } + } else { + cmf = sCurrentMatrix; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fXZByCurrentState.s") + if (x != 0) { + sin = sinf(x); + cos = cosf(x); + } else { + sin = zero; + cos = one; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MtxFCopy.s") + cmf->xx = one; + cmf->yx = zero; + cmf->zx = zero; + cmf->wx = zero; + cmf->xy = zero; + cmf->yy = cos; + cmf->zy = sin; + cmf->wy = zero; + cmf->xz = zero; + cmf->yz = -sin; + cmf->zz = cos; + cmf->wz = zero; + cmf->xw = zero; + cmf->yw = zero; + cmf->zw = zero; + cmf->ww = one; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_FromRSPMatrix.s") +/** + * @brief Right-multiply by a rotation about the x axis. + * current * R -> current + * + * @note Matrix_RotateXF() with mode APPLY. + * + * @param x rotation angle (radians). + */ +void Matrix_RotateXFApply(f32 x) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempY; + f32 tempZ; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fByMatrix.s") + if (x != 0.0f) { + cmf = sCurrentMatrix; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_TransposeXYZ.s") + sin = sins(RADF_TO_BINANG(x)) * SHT_MINV; + cos = coss(RADF_TO_BINANG(x)) * SHT_MINV; -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_NormalizeXYZ.s") + tempY = cmf->xy; + tempZ = cmf->xz; + cmf->xy = (tempY * cos) + (tempZ * sin); + cmf->xz = (tempZ * cos) - (tempY * sin); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_8018219C.s") + tempY = cmf->yy; + tempZ = cmf->yz; + cmf->yy = (tempY * cos) + (tempZ * sin); + cmf->yz = (tempZ * cos) - (tempY * sin); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_801822C4.s") + tempY = cmf->zy; + tempZ = cmf->zz; + cmf->zy = (tempY * cos) + (tempZ * sin); + cmf->zz = (tempZ * cos) - (tempY * sin); -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_f.s") + tempY = cmf->wy; + tempZ = cmf->wz; + cmf->wy = (tempY * cos) + (tempZ * sin); + cmf->wz = (tempZ * cos) - (tempY * sin); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_s.s") +/** + * @brief Replace current by a rotation about the x axis. + * R -> current + * + * @note Matrix_RotateXF() with mode NEW. + * + * @param x rotation angle (radians). + */ +void Matrix_RotateXFNew(f32 x) { + MtxF* cmf = sCurrentMatrix; + s32 pad[2]; + f32 sin; + f32 cos; + + cmf->xx = 1.0f; + cmf->yx = 0.0f; + cmf->zx = 0.0f; + cmf->wx = 0.0f; + cmf->xy = 0.0f; + cmf->wy = 0.0f; + cmf->xz = 0.0f; + cmf->wz = 0.0f; + cmf->xw = 0.0f; + cmf->yw = 0.0f; + cmf->zw = 0.0f; + cmf->ww = 1.0f; + + if (x != 0.0f) { + sin = sinf(x); + cos = cosf(x); + + cmf->yy = cos; + cmf->zz = cos; + cmf->yz = -sin; + cmf->zy = sin; + } else { + cmf->yy = 1.0f; + cmf->zy = 0.0f; + cmf->yz = 0.0f; + cmf->zz = 1.0f; + } +} + +/** + * @brief Right-multiply by a rotation about the y axis + * - APPLY: current * R -> current + * - NEW: R -> current + * + * R is given by + * + * \f[ + * \begin{pmatrix} + * c & 0 & s & 0 \\ + * 0 & 1 & 0 & 0 \\ + * -s & 0 & c & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ c = \cos y, s = \sin y \f$. + * + * @note The same as Matrix_RotateYF(), but uses a binary angle. + * + * @param y rotation angle (binary). + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_RotateY" + */ +void Matrix_RotateYS(s16 y, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempX; + f32 tempZ; + + if (mode == MTXMODE_APPLY) { + if (y != 0) { + cmf = sCurrentMatrix; + + sin = Math_SinS(y); + cos = Math_CosS(y); + + tempX = cmf->xx; + tempZ = cmf->xz; + cmf->xx = tempX * cos - tempZ * sin; + cmf->xz = tempX * sin + tempZ * cos; + + tempX = cmf->yx; + tempZ = cmf->yz; + cmf->yx = tempX * cos - tempZ * sin; + cmf->yz = tempX * sin + tempZ * cos; + + tempX = cmf->zx; + tempZ = cmf->zz; + cmf->zx = tempX * cos - tempZ * sin; + cmf->zz = tempX * sin + tempZ * cos; + + tempX = cmf->wx; + tempZ = cmf->wz; + cmf->wx = tempX * cos - tempZ * sin; + cmf->wz = tempX * sin + tempZ * cos; + } + } else { + cmf = sCurrentMatrix; + + if (y != 0) { + sin = Math_SinS(y); + cos = Math_CosS(y); + } else { + sin = 0.0f; + cos = 1.0f; + } + + cmf->yx = 0.0f; + cmf->wx = 0.0f; + cmf->xy = 0.0f; + cmf->zy = 0.0f; + cmf->wy = 0.0f; + cmf->yz = 0.0f; + cmf->wz = 0.0f; + cmf->xw = 0.0f; + cmf->yw = 0.0f; + cmf->zw = 0.0f; + cmf->yy = 1.0f; + cmf->ww = 1.0f; + cmf->xx = cos; + cmf->zz = cos; + cmf->zx = -sin; + cmf->xz = sin; + } +} + +/** + * @brief Right-multiply by a rotation about the y axis. + * - APPLY: current * R -> current + * - NEW: R -> current + * + * R is given by + * + * \f[ + * \begin{pmatrix} + * c & 0 & s & 0 \\ + * 0 & 1 & 0 & 0 \\ + * -s & 0 & c & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ c = \cos y, s = \sin y \f$. + * + * @note The same as Matrix_RotateYS(), but uses a float angle in radians. + * + * @param y rotation angle (radians). + * @param mode APPLY or NEW. + * + * @remark original name may have been "Matrix_RotateY", but clashed with the previous function. + */ +void Matrix_RotateYF(f32 y, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempX; + f32 tempZ; + f32 zero = 0.0; + f32 one = 1.0; + + if (mode == MTXMODE_APPLY) { + if (y != 0.0f) { + cmf = sCurrentMatrix; + + sin = sinf(y); + cos = cosf(y); + + tempX = cmf->xx; + tempZ = cmf->xz; + cmf->xx = tempX * cos - tempZ * sin; + cmf->xz = tempX * sin + tempZ * cos; + + tempX = cmf->yx; + tempZ = cmf->yz; + cmf->yx = tempX * cos - tempZ * sin; + cmf->yz = tempX * sin + tempZ * cos; + + tempX = cmf->zx; + tempZ = cmf->zz; + cmf->zx = tempX * cos - tempZ * sin; + cmf->zz = tempX * sin + tempZ * cos; + + tempX = cmf->wx; + tempZ = cmf->wz; + cmf->wx = tempX * cos - tempZ * sin; + cmf->wz = tempX * sin + tempZ * cos; + } + } else { + cmf = sCurrentMatrix; + + if (y != 0.0f) { + sin = sinf(y); + cos = cosf(y); + } else { + cos = one; + sin = zero; + } + + cmf->yx = zero; + cmf->wx = zero; + cmf->xy = zero; + cmf->zy = zero; + cmf->wy = zero; + cmf->yz = zero; + cmf->wz = zero; + cmf->xw = zero; + cmf->yw = zero; + cmf->zw = zero; + cmf->yy = one; + cmf->ww = one; + cmf->xx = cos; + cmf->zz = cos; + cmf->zx = -sin; + cmf->xz = sin; + } +} + +/** + * @brief Right-multiply by a rotation about the z axis. + * - APPLY: current * R -> current + * - NEW: R -> current + * + * R is given by + * + * \f[ + * \begin{pmatrix} + * c & -s & 0 & 0 \\ + * s & c & 0 & 0 \\ + * 0 & 0 & 1 & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ c = \cos z, s = \sin z \f$. + * + * @note The same as Matrix_RotateZF, but uses a binary angle. + * + * @param z rotation angle (binary). + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_RotateZ" + */ +void Matrix_RotateZS(s16 z, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempX; + f32 tempY; + f32 zero = 0.0; + f32 one = 1.0; + + if (mode == MTXMODE_APPLY) { + if (z != 0) { + cmf = sCurrentMatrix; + + sin = Math_SinS(z); + cos = Math_CosS(z); + + tempX = cmf->xx; + tempY = cmf->xy; + cmf->xx = tempX * cos + tempY * sin; + cmf->xy = tempY * cos - tempX * sin; + + tempX = cmf->yx; + tempY = cmf->yy; + cmf->yx = tempX * cos + tempY * sin; + cmf->yy = tempY * cos - tempX * sin; + + tempX = cmf->zx; + tempY = cmf->zy; + cmf->zx = tempX * cos + tempY * sin; + cmf->zy = tempY * cos - tempX * sin; + + tempX = cmf->wx; + tempY = cmf->wy; + cmf->wx = tempX * cos + tempY * sin; + cmf->wy = tempY * cos - tempX * sin; + } + } else { + cmf = sCurrentMatrix; + + if (z != 0) { + sin = Math_SinS(z); + cos = Math_CosS(z); + } else { + sin = zero; + cos = one; + } + + cmf->zx = zero; + cmf->wx = zero; + cmf->zy = zero; + cmf->wy = zero; + cmf->xz = zero; + cmf->yz = zero; + cmf->wz = zero; + cmf->xw = zero; + cmf->yw = zero; + cmf->zw = zero; + cmf->zz = one; + cmf->ww = one; + cmf->xx = cos; + cmf->yy = cos; + cmf->yx = sin; + cmf->xy = -sin; + } +} + +/** + * @brief Right-multiply by a rotation about the z axis. + * - APPLY: current * R -> current + * - NEW: R -> current + * + * R is given by + * + * \f[ + * \begin{pmatrix} + * c & -s & 0 & 0 \\ + * s & c & 0 & 0 \\ + * 0 & 0 & 1 & 0 \\ + * 0 & 0 & 0 & 1 + * \end{pmatrix} + * \f] + * + * where \f$ c = \cos z, s = \sin z \f$. + * + * @note The same as Matrix_RotateYS(), but uses a float angle in radians. + * + * @param z rotation angle (radians). + * @param mode APPLY or NEW. + * + * @remark original name may have been "Matrix_RotateZ", but clashed with the previous function. + */ +void Matrix_RotateZF(f32 z, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 tempX; + f32 tempY; + + if (mode == MTXMODE_APPLY) { + if (z != 0) { + cmf = sCurrentMatrix; + + sin = sinf(z); + cos = cosf(z); + + tempX = cmf->xx; + tempY = cmf->xy; + cmf->xx = tempX * cos + tempY * sin; + cmf->xy = tempY * cos - tempX * sin; + + tempX = cmf->yx; + tempY = cmf->yy; + cmf->yx = tempX * cos + tempY * sin; + cmf->yy = tempY * cos - tempX * sin; + + tempX = cmf->zx; + tempY = cmf->zy; + cmf->zx = tempX * cos + tempY * sin; + cmf->zy = tempY * cos - tempX * sin; + + tempX = cmf->wx; + tempY = cmf->wy; + cmf->wx = tempX * cos + tempY * sin; + cmf->wy = tempY * cos - tempX * sin; + } + } else { + cmf = sCurrentMatrix; + + if (z != 0) { + sin = sinf(z); + cos = cosf(z); + } else { + sin = 0.0f; + cos = 1.0f; + } + + cmf->zx = 0.0f; + cmf->wx = 0.0f; + cmf->zy = 0.0f; + cmf->wy = 0.0f; + cmf->xz = 0.0f; + cmf->yz = 0.0f; + cmf->wz = 0.0f; + cmf->xw = 0.0f; + cmf->yw = 0.0f; + cmf->zw = 0.0f; + cmf->zz = 1.0f; + cmf->ww = 1.0f; + cmf->xx = cos; + cmf->yy = cos; + cmf->yx = sin; + cmf->xy = -sin; + } +} + +/** + * @brief Rotate using ZYX Tait-Bryan angles. + * - APPLY: current Rz Ry Rx -> current + * - NEW: Rz Ry Rx -> current + * + * This means a (column) vector is first rotated around X, then around Y, then around Z, then (if `mode` is APPLY) gets + * transformed by what the matrix was before adding the ZYX rotation. + * + * See previous functions for the forms of Rz, Ry, Rx + * + * @param x binary angle to rotate about x axis + * @param y binary angle to rotate about y axis + * @param z binary angle to rotate about z axis + * @param mode APPLY or NEW + * + * @remark original name: "Matrix_RotateXYZ", changed to reflect rotation order. + */ +void Matrix_RotateZYX(s16 x, s16 y, s16 z, MatrixMode mode) { + MtxF* cmf = sCurrentMatrix; + f32 temp1; + f32 temp2; + f32 sin; + f32 cos; + + if (mode == MTXMODE_APPLY) { + if (z != 0) { // Added in MM, OoT always follows the nonzero path + sin = Math_SinS(z); + cos = Math_CosS(z); + + temp1 = cmf->xx; + temp2 = cmf->xy; + cmf->xx = temp1 * cos + temp2 * sin; + cmf->xy = temp2 * cos - temp1 * sin; + + temp1 = cmf->yx; + temp2 = cmf->yy; + cmf->yx = temp1 * cos + temp2 * sin; + cmf->yy = temp2 * cos - temp1 * sin; + + temp1 = cmf->zx; + temp2 = cmf->zy; + cmf->zx = temp1 * cos + temp2 * sin; + cmf->zy = temp2 * cos - temp1 * sin; + + temp1 = cmf->wx; + temp2 = cmf->wy; + cmf->wx = temp1 * cos + temp2 * sin; + cmf->wy = temp2 * cos - temp1 * sin; + } + + if (y != 0) { + sin = Math_SinS(y); + cos = Math_CosS(y); + + temp1 = cmf->xx; + temp2 = cmf->xz; + cmf->xx = temp1 * cos - temp2 * sin; + cmf->xz = temp1 * sin + temp2 * cos; + + temp1 = cmf->yx; + temp2 = cmf->yz; + cmf->yx = temp1 * cos - temp2 * sin; + cmf->yz = temp1 * sin + temp2 * cos; + + temp1 = cmf->zx; + temp2 = cmf->zz; + cmf->zx = temp1 * cos - temp2 * sin; + cmf->zz = temp1 * sin + temp2 * cos; + + temp1 = cmf->wx; + temp2 = cmf->wz; + cmf->wx = temp1 * cos - temp2 * sin; + cmf->wz = temp1 * sin + temp2 * cos; + } + + if (x != 0) { + sin = Math_SinS(x); + cos = Math_CosS(x); + + temp1 = cmf->xy; + temp2 = cmf->xz; + cmf->xy = temp1 * cos + temp2 * sin; + cmf->xz = temp2 * cos - temp1 * sin; + + temp1 = cmf->yy; + temp2 = cmf->yz; + cmf->yy = temp1 * cos + temp2 * sin; + cmf->yz = temp2 * cos - temp1 * sin; + + temp1 = cmf->zy; + temp2 = cmf->zz; + cmf->zy = temp1 * cos + temp2 * sin; + cmf->zz = temp2 * cos - temp1 * sin; + + temp1 = cmf->wy; + temp2 = cmf->wz; + cmf->wy = temp1 * cos + temp2 * sin; + cmf->wz = temp2 * cos - temp1 * sin; + } + } else { + SkinMatrix_SetRotateRPY(cmf, x, y, z); + } +} + +/** + * @brief Translate and rotate using ZYX Tait-Bryan angles. + * current T Rz Ry Rx -> current + * + * This means a (column) vector is first rotated around X, then around Y, then around Z, then translated, then gets + * transformed by whatever the matrix was previously. + * + * @param translation vector by which to translate. + * @param rot vector of rotation angles. + * + * @remark original name appears to be "Matrix_softcv3_mult" + */ +void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rot) { + MtxF* cmf = sCurrentMatrix; + f32 sin = Math_SinS(rot->z); + f32 cos = Math_CosS(rot->z); + f32 temp1; + f32 temp2; + + // No check for z != 0, presumably since translation is interleaved. + temp1 = cmf->xx; + temp2 = cmf->xy; + cmf->xw += temp1 * translation->x + temp2 * translation->y + cmf->xz * translation->z; + cmf->xx = temp1 * cos + temp2 * sin; + cmf->xy = temp2 * cos - temp1 * sin; + + temp1 = cmf->yx; + temp2 = cmf->yy; + cmf->yw += temp1 * translation->x + temp2 * translation->y + cmf->yz * translation->z; + cmf->yx = temp1 * cos + temp2 * sin; + cmf->yy = temp2 * cos - temp1 * sin; + + temp1 = cmf->zx; + temp2 = cmf->zy; + cmf->zw += temp1 * translation->x + temp2 * translation->y + cmf->zz * translation->z; + cmf->zx = temp1 * cos + temp2 * sin; + cmf->zy = temp2 * cos - temp1 * sin; + + temp1 = cmf->wx; + temp2 = cmf->wy; + cmf->ww += temp1 * translation->x + temp2 * translation->y + cmf->wz * translation->z; + cmf->wx = temp1 * cos + temp2 * sin; + cmf->wy = temp2 * cos - temp1 * sin; + + if (rot->y != 0) { + sin = Math_SinS(rot->y); + cos = Math_CosS(rot->y); + + temp1 = cmf->xx; + temp2 = cmf->xz; + cmf->xx = temp1 * cos - temp2 * sin; + cmf->xz = temp1 * sin + temp2 * cos; + + temp1 = cmf->yx; + temp2 = cmf->yz; + cmf->yx = temp1 * cos - temp2 * sin; + cmf->yz = temp1 * sin + temp2 * cos; + + temp1 = cmf->zx; + temp2 = cmf->zz; + cmf->zx = temp1 * cos - temp2 * sin; + cmf->zz = temp1 * sin + temp2 * cos; + + temp1 = cmf->wx; + temp2 = cmf->wz; + cmf->wx = temp1 * cos - temp2 * sin; + cmf->wz = temp1 * sin + temp2 * cos; + } + + if (rot->x != 0) { + sin = Math_SinS(rot->x); + cos = Math_CosS(rot->x); + + temp1 = cmf->xy; + temp2 = cmf->xz; + cmf->xy = temp1 * cos + temp2 * sin; + cmf->xz = temp2 * cos - temp1 * sin; + + temp1 = cmf->yy; + temp2 = cmf->yz; + cmf->yy = temp1 * cos + temp2 * sin; + cmf->yz = temp2 * cos - temp1 * sin; + + temp1 = cmf->zy; + temp2 = cmf->zz; + cmf->zy = temp1 * cos + temp2 * sin; + cmf->zz = temp2 * cos - temp1 * sin; + + temp1 = cmf->wy; + temp2 = cmf->wz; + cmf->wy = temp1 * cos + temp2 * sin; + cmf->wz = temp2 * cos - temp1 * sin; + } +} + +/** + * @brief Set current to a general translation and rotation using YXZ Tait-Bryan angles: T Ry Rx Rz -> current + * + * This means a (column) vector is first rotated around Y, then around X, then around Z, then translated, then gets + * transformed by whatever the matrix was previously. + * + * @param x amount to translate in X direction. + * @param y amount to translate in Y direction. + * @param z amount to translate in Z direction. + * @param rot vector of rotation angles. + * + * @remark original name appears to be "Matrix_softcv3_load" + */ +void Matrix_SetTranslateRotateYXZ(f32 x, f32 y, f32 z, Vec3s* rot) { + MtxF* cmf = sCurrentMatrix; + f32 sinY = Math_SinS(rot->y); + f32 cosY = Math_CosS(rot->y); + f32 cosTemp; + f32 sinTemp; + + cmf->xx = cosY; + cmf->zx = -sinY; + cmf->xw = x; + cmf->yw = y; + cmf->zw = z; + cmf->wx = 0.0f; + cmf->wy = 0.0f; + cmf->wz = 0.0f; + cmf->ww = 1.0f; + + if (rot->x != 0) { + sinTemp = Math_SinS(rot->x); + cosTemp = Math_CosS(rot->x); + + cmf->zz = cosY * cosTemp; + cmf->zy = cosY * sinTemp; + cmf->xz = sinY * cosTemp; + cmf->xy = sinY * sinTemp; + cmf->yz = -sinTemp; + cmf->yy = cosTemp; + } else { + cmf->zz = cosY; + cmf->xz = sinY; + cmf->yz = 0.0f; + cmf->zy = 0.0f; + cmf->xy = 0.0f; + cmf->yy = 1.0f; + } + + if (rot->z != 0) { + sinTemp = Math_SinS(rot->z); + cosTemp = Math_CosS(rot->z); + + sinY = cmf->xx; + cosY = cmf->xy; + cmf->xx = sinY * cosTemp + cosY * sinTemp; + cmf->xy = cosY * cosTemp - sinY * sinTemp; + + sinY = cmf->zx; + cosY = cmf->zy; + cmf->zx = sinY * cosTemp + cosY * sinTemp; + cmf->zy = cosY * cosTemp - sinY * sinTemp; + + cosY = cmf->yy; + cmf->yx = cosY * sinTemp; + cmf->yy = cosY * cosTemp; + } else { + cmf->yx = 0.0f; + } +} + +/** + * @brief Converts a floating-point MtxF to a fixed-point RSP-compatible matrix. + * + * @param[in] src MtxF to convert. + * @param[out] dest mtx to output to. + * + * @return dest + * + * @remark original name: "_MtxF_to_Mtx" + */ +Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest) { + s32 temp; + u16* intPart = (u16*)&dest->m[0][0]; + u16* fracPart = (u16*)&dest->m[2][0]; + + // For some reason the first 9 elements use the intPart temp for the fractional part. + temp = src->xx * 0x10000; + intPart[0] = (temp >> 0x10); + intPart[16 + 0] = temp; + + temp = src->yx * 0x10000; + intPart[1] = (temp >> 0x10); + intPart[16 + 1] = temp; + + temp = src->zx * 0x10000; + intPart[2] = (temp >> 0x10); + intPart[16 + 2] = temp; + + temp = src->wx * 0x10000; + intPart[3] = (temp >> 0x10); + intPart[16 + 3] = temp; + + temp = src->xy * 0x10000; + intPart[4] = (temp >> 0x10); + intPart[16 + 4] = temp; + + temp = src->yy * 0x10000; + intPart[5] = (temp >> 0x10); + intPart[16 + 5] = temp; + + temp = src->zy * 0x10000; + intPart[6] = (temp >> 0x10); + intPart[16 + 6] = temp; + + temp = src->wy * 0x10000; + intPart[7] = (temp >> 0x10); + intPart[16 + 7] = temp; + + temp = src->xz * 0x10000; + intPart[8] = (temp >> 0x10); + intPart[16 + 8] = temp; + + temp = src->yz * 0x10000; + intPart[9] = (temp >> 0x10); + fracPart[9] = temp; + + temp = src->zz * 0x10000; + intPart[10] = (temp >> 0x10); + fracPart[10] = temp; + + temp = src->wz * 0x10000; + intPart[11] = (temp >> 0x10); + fracPart[11] = temp; + + temp = src->xw * 0x10000; + intPart[12] = (temp >> 0x10); + fracPart[12] = temp; + + temp = src->yw * 0x10000; + intPart[13] = (temp >> 0x10); + fracPart[13] = temp; + + temp = src->zw * 0x10000; + intPart[14] = (temp >> 0x10); + fracPart[14] = temp; + + temp = src->ww * 0x10000; + intPart[15] = (temp >> 0x10); + fracPart[15] = temp; + + return dest; +} + +/** + * @brief Converts current to a fixed-point RSP-compatible matrix. + * + * @note Debug uses Matrix_CheckFloats to test current first. + * + * @param[out] dest mtx to output to. + * + * @return dest + * + * @remark original name: "_Matrix_to_Mtx" + */ +Mtx* Matrix_ToMtx(Mtx* dest) { + return Matrix_MtxFToMtx(sCurrentMatrix, dest); +} + +/** + * @brief Converts current to a RSP-compatible matrix and saves it to allocated space in the OPA buffer. + * + * @param[in,out] gfxCtx Graphics context. + * + * @return allocated mtx. + * + * @remark original name: "_Matrix_to_Mtx_new" + */ +Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx) { + return Matrix_ToMtx(GRAPH_ALLOC(gfxCtx, sizeof(Mtx))); +} + +// Unused +/** + * @brief Converts src to a RSP-compatible matrix and saves it to allocated space in the OPA buffer. + * + * @param[in] src MtxF to convert. + * @param[in,out] gfxCtx Graphics context. + * + * @return allocated mtx. + * + * @remark original name unknown, likely close to "_Matrix_MtxF_to_Mtx_new" + */ +Mtx* Matrix_MtxFToNewMtx(MtxF* src, GraphicsContext* gfxCtx) { + return Matrix_MtxFToMtx(src, GRAPH_ALLOC(gfxCtx, sizeof(Mtx))); +} + +/** + * @brief Calculates current * (src,1) and writes its components to dest. + * + * This assumes that current has the form + * + * \f[ + * M = + * \begin{pmatrix} + * A & b \\ + * 0 & 1 + * \end{pmatrix} + * \f] + * + * where A is \f$ 3 \times 3 \f$ and b \f$ 3 \times 1 \f$, and so calculates + * + * \f[ + * MX = + * \begin{pmatrix} + * A & b \\ + * 0 & 1 + * \end{pmatrix} + * \begin{pmatrix} + * x \\ + * 1 + * \end{pmatrix} + * = + * \begin{pmatrix} + * Ax + b \\ + * 1 + * \end{pmatrix} + * \f] + * + * and discards the extra w component (1). + * + * @param[in] src input vector + * @param[out] dest output vector + * + * @remark original name: "Matrix_Position" + */ +void Matrix_MultVec3f(Vec3f* src, Vec3f* dest) { + MtxF* cmf = sCurrentMatrix; + + dest->x = cmf->xw + (cmf->xx * src->x + cmf->xy * src->y + cmf->xz * src->z); + dest->y = cmf->yw + (cmf->yx * src->x + cmf->yy * src->y + cmf->yz * src->z); + dest->z = cmf->zw + (cmf->zx * src->x + cmf->zy * src->y + cmf->zz * src->z); +} + +/** + * @brief Multiply the vector `(0, 0, 0, 1)` by current. + * + * Can also see it as obtaining the translation vector part of current, but the former interpretation is consistent with + * the other functions nearby. + * + * @note Special case of Matrix_MultVec3f() with `src = { 0, 0, 0 }`; the same assumptions apply. + * + * @param[out] dest output vector. + * + * @remark original name: "Matrix_Position_Zero" + */ +void Matrix_MultZero(Vec3f* dest) { + MtxF* cmf = sCurrentMatrix; + + dest->x = cmf->xw; + dest->y = cmf->yw; + dest->z = cmf->zw; +} + +/** + * @brief Multiply the vector `(x, 0, 0, 1)` by current. + * + * I.e. calculate \f$ A(x, 0, 0) + b \f$. + * + * @note Special case of Matrix_MultVec3f() with `src = { x, 0, 0 }`; the same assumptions apply. + * + * @param[in] x multiplier of unit vector in x direction. + * @param[out] dest output vector. + * + * @remark original name: "Matrix_Position_VecX" + */ +void Matrix_MultVecX(f32 x, Vec3f* dest) { + MtxF* cmf = sCurrentMatrix; + + dest->x = cmf->xw + cmf->xx * x; + dest->y = cmf->yw + cmf->yx * x; + dest->z = cmf->zw + cmf->zx * x; +} + +/** + * @brief Multiply the vector `(0, y, 0, 1)` by current. + * + * I.e. calculate \f$ A(0, y, 0) + b \f$. + * + * @note Special case of Matrix_MultVec3f() with `src = { 0, y, 0 }`; the same assumptions apply. + * + * @param[in] y multiplier of unit vector in y direction. + * @param[out] dest output vector. + * + * @remark original name is most likely "Matrix_Position_VecY" by analogy with the other two. + */ +void Matrix_MultVecY(f32 y, Vec3f* dest) { + MtxF* cmf = sCurrentMatrix; + + dest->x = cmf->xw + cmf->xy * y; + dest->y = cmf->yw + cmf->yy * y; + dest->z = cmf->zw + cmf->zy * y; +} + +/** + * @brief Multiply the vector `(0, 0, z, 1)` by current. + * + * I.e. calculate \f$ A(0, 0, z) + b \f$. + * + * @note Special case of Matrix_MultVec3f() with `src = { 0, 0, z }`; the same assumptions apply. + * + * @param[in] z multiplier of unit vector in z direction. + * @param[out] dest output vector. + * + * @remark original name: "Matrix_Position_VecZ" + */ +void Matrix_MultVecZ(f32 z, Vec3f* dest) { + MtxF* cmf = sCurrentMatrix; + + dest->x = cmf->xw + cmf->xz * z; + dest->y = cmf->yw + cmf->yz * z; + dest->z = cmf->zw + cmf->zz * z; +} + +/** + * @brief Calculates current * (src,1) and writes its x and z components to dest. + * + * The same as Matrix_MultVec3f(), but only applies to the x and z components; the same assumptions apply. + * + * @note Unlike the previous functions, does *not* just multiply (x, 0, z, 1) and save the x,y,z components. + * + * @param[in] src input vector. + * @param[out] dest output vector. + */ +void Matrix_MultVec3fXZ(Vec3f* src, Vec3f* dest) { + MtxF* cmf = sCurrentMatrix; + + dest->x = cmf->xw + (cmf->xx * src->x + cmf->xy * src->y + cmf->xz * src->z); + dest->z = cmf->zw + (cmf->zx * src->x + cmf->zy * src->y + cmf->zz * src->z); +} + +/** + * @brief Copies the matrix src into dest. + * + * @param[out] dest matrix to copy to. + * @param[in] src matrix to copy from. + * + * @remark original name: "Matrix_copy_MtxF" + */ +void Matrix_MtxFCopy(MtxF* dest, MtxF* src) { + f32 fv0; + f32 fv1; + + // This ought to be a loop, but all attempts to match it as one have so far failed. + if (1) { + fv0 = src->mf[0][0]; + fv1 = src->mf[0][1]; + dest->mf[0][0] = fv0; + dest->mf[0][1] = fv1; + fv0 = src->mf[0][2]; + fv1 = src->mf[0][3]; + dest->mf[0][2] = fv0; + dest->mf[0][3] = fv1; + } + if (1) { + fv0 = src->mf[1][0]; + fv1 = src->mf[1][1]; + dest->mf[1][0] = fv0; + dest->mf[1][1] = fv1; + fv0 = src->mf[1][2]; + fv1 = src->mf[1][3]; + dest->mf[1][2] = fv0; + dest->mf[1][3] = fv1; + } + if (1) { + fv0 = src->mf[2][0]; + fv1 = src->mf[2][1]; + dest->mf[2][0] = fv0; + dest->mf[2][1] = fv1; + fv0 = src->mf[2][2]; + fv1 = src->mf[2][3]; + dest->mf[2][2] = fv0; + dest->mf[2][3] = fv1; + } + if (1) { + fv0 = src->mf[3][0]; + fv1 = src->mf[3][1]; + dest->mf[3][0] = fv0; + dest->mf[3][1] = fv1; + fv0 = src->mf[3][2]; + fv1 = src->mf[3][3]; + dest->mf[3][2] = fv0; + dest->mf[3][3] = fv1; + } +} + +/** + * @brief Converts fixed-point RSP-compatible matrix to an MtxF. + * + * @param[in] src mtx to convert + * @param[out] dest MtxF to output to + * + * @remark original name: "Matrix_MtxtoMtxF" + */ +void Matrix_MtxToMtxF(Mtx* src, MtxF* dest) { + u16* intPart = (u16*)&src->m[0][0]; + u16* fracPart = (u16*)&src->m[2][0]; + + dest->xx = ((intPart[0] << 0x10) | fracPart[0]) * (1 / (f32)0x10000); + dest->yx = ((intPart[1] << 0x10) | fracPart[1]) * (1 / (f32)0x10000); + dest->zx = ((intPart[2] << 0x10) | fracPart[2]) * (1 / (f32)0x10000); + dest->wx = ((intPart[3] << 0x10) | fracPart[3]) * (1 / (f32)0x10000); + dest->xy = ((intPart[4] << 0x10) | fracPart[4]) * (1 / (f32)0x10000); + dest->yy = ((intPart[5] << 0x10) | fracPart[5]) * (1 / (f32)0x10000); + dest->zy = ((intPart[6] << 0x10) | fracPart[6]) * (1 / (f32)0x10000); + dest->wy = ((intPart[7] << 0x10) | fracPart[7]) * (1 / (f32)0x10000); + dest->xz = ((intPart[8] << 0x10) | fracPart[8]) * (1 / (f32)0x10000); + dest->yz = ((intPart[9] << 0x10) | fracPart[9]) * (1 / (f32)0x10000); + dest->zz = ((intPart[10] << 0x10) | fracPart[10]) * (1 / (f32)0x10000); + dest->wz = ((intPart[11] << 0x10) | fracPart[11]) * (1 / (f32)0x10000); + dest->xw = ((intPart[12] << 0x10) | fracPart[12]) * (1 / (f32)0x10000); + dest->yw = ((intPart[13] << 0x10) | fracPart[13]) * (1 / (f32)0x10000); + dest->zw = ((intPart[14] << 0x10) | fracPart[14]) * (1 / (f32)0x10000); + dest->ww = ((intPart[15] << 0x10) | fracPart[15]) * (1 / (f32)0x10000); +} + +// Unused +/** + * @brief Calculates mf * (src,1) and writes its components to dest. + * + * This is the same as Matrix_MultVec3f() but using a specified matrix rather than the current one; the same + * assumptions apply. + * + * @param[in] src input vector + * @param[out] dest output vector + * @param[in] mf matrix to multiply by + */ +void Matrix_MultVec3fExt(Vec3f* src, Vec3f* dest, MtxF* mf) { + dest->x = mf->xw + (mf->xx * src->x + mf->xy * src->y + mf->xz * src->z); + dest->y = mf->yw + (mf->yx * src->x + mf->yy * src->y + mf->yz * src->z); + dest->z = mf->zw + (mf->zx * src->x + mf->zy * src->y + mf->zz * src->z); +} + +/** + * @brief Overwrite the linear part of mf with its transpose (ignores the translational part). + * + * Viz., + * + * \f[ + * \begin{pmatrix} + * A & b \\ + * 0 & 1 + * \end{pmatrix} + * \longrightarrow + * \begin{pmatrix} + * A^T & b \\ + * 0 & 1 + * \end{pmatrix} + * \f] + * + * @param[in,out] mf matrix to transpose + * + * @remark original name: "Matrix_reverse" + */ +void Matrix_Transpose(MtxF* mf) { + f32 temp; + + temp = mf->yx; + mf->yx = mf->xy; + mf->xy = temp; + + temp = mf->zx; + mf->zx = mf->xz; + mf->xz = temp; + + temp = mf->zy; + mf->zy = mf->yz; + mf->yz = temp; +} + +/** + * @brief Decompose the linear part A of current into B * S, where B has normalised columns and S is diagonal, and + * replace B by `mf`. + * + * Since B is typically a rotation matrix, and the linear part R * S to `mf` * S, this operation can be + * seen as replacing the B rotation with `mf`, hence the function name. + * + * @param[in] mf matrix whose linear part will replace the normalised part of A. + */ +void Matrix_ReplaceRotation(MtxF* mf) { + MtxF* cmf = sCurrentMatrix; + f32 acc; + f32 component; + f32 curColNorm; + + // compute the Euclidean norm of the first column of the current matrix + acc = cmf->xx; + acc *= acc; + component = cmf->yx; + acc += SQ(component); + component = cmf->zx; + acc += SQ(component); + curColNorm = sqrtf(acc); + + cmf->xx = mf->xx * curColNorm; + cmf->yx = mf->yx * curColNorm; + cmf->zx = mf->zx * curColNorm; + + // second column + acc = cmf->xy; + acc *= acc; + component = cmf->yy; + acc += SQ(component); + component = cmf->zy; + acc += SQ(component); + curColNorm = sqrtf(acc); + + cmf->xy = mf->xy * curColNorm; + cmf->yy = mf->yy * curColNorm; + cmf->zy = mf->zy * curColNorm; + + // third column + acc = cmf->xz; + acc *= acc; + component = cmf->yz; + acc += SQ(component); + component = cmf->zz; + acc += SQ(component); + curColNorm = sqrtf(acc); + + cmf->xz = mf->xz * curColNorm; + cmf->yz = mf->yz * curColNorm; + cmf->zz = mf->zz * curColNorm; +} + +/** + * @brief Extract the YXZ Tait-Bryan rotation angles from the linear part \f$ A \f$ of a matrix. + * + * \f$ A \f$ should have orthogonal columns; the most general matrix of this form can be written as \f$ RS \f$ + * with \f$ S \f$ a scale matrix. + * + * If A has columns with the same norm (such as if it is just a rotation matrix), it is sufficient (and faster) to use + * `nonUniformScale` off: `nonUniformScale` being set enables extraction of the angles from a matrix with columns that + * are orthogonal but have different scales, at the cost of requiring extra calculation. + * + * @param[in] src Matrix to extract angles from. + * @param[out] dest vector to write angles to. + * @param[in] nonUniformScale boolean: true enables handling matrices with differently-scaled columns. + * + * @remark original name: "Matrix_to_rotate_new"? + */ +void Matrix_MtxFToYXZRot(MtxF* src, Vec3s* dest, s32 nonUniformScale) { + f32 temp; + f32 temp2; + f32 temp3; + f32 temp4; + + temp = src->xz; + temp *= temp; + temp += SQ(src->zz); + dest->x = Math_Atan2S(-src->yz, sqrtf(temp)); + + if ((dest->x == 0x4000) || (dest->x == -0x4000)) { + // cos(x) = 0 if either of these is true, and we get gimbal locking + // (https://en.wikipedia.org/wiki/Gimbal_lock#Loss_of_a_degree_of_freedom_with_Euler_angles); fix z to make y + // well-defined. + dest->z = 0; + + dest->y = Math_Atan2S(-src->zx, src->xx); + } else { + dest->y = Math_Atan2S(src->xz, src->zz); + + if (!nonUniformScale) { + // assume the columns have the same normalisation + dest->z = Math_Atan2S(src->yx, src->yy); + } else { + temp = src->xx; + temp2 = src->zx; + temp3 = src->zy; + + // find norm of the first column + temp *= temp; + temp += SQ(temp2); + temp2 = src->yx; + temp += SQ(temp2); + // temp = xx^2+zx^2+yx^2 == 1 for a rotation matrix + temp = sqrtf(temp); + temp = temp2 / temp; // yx in normalised column + + // find norm of the second column + temp2 = src->xy; + temp2 *= temp2; + temp2 += SQ(temp3); + temp3 = src->yy; + temp2 += SQ(temp3); + // temp2 = xy^2+zy^2+yy^2 == 1 for a rotation matrix + temp2 = sqrtf(temp2); + temp2 = temp3 / temp2; // yy in normalised column + + // for a rotation matrix, temp == yx and temp2 == yy which is the same as in the !nonUniformScale branch + dest->z = Math_Atan2S(temp, temp2); + } + } +} + +/** + * @brief Extract the ZYX Tait-Bryan rotation angles from the linear part \f$ A \f$ of a matrix. + * + * \f$ A \f$ should have orthogonal columns; the most general matrix of this form can be written as \f$ RS \f$ + * with \f$ S \f$ a scale matrix. + * + * If A has columns with the same norm (such as if it is just a rotation matrix), it is sufficient (and faster) to use + * `nonUniformScale` off: `nonUniformScale` being set enables extraction of the angles from a matrix with columns that + * are orthogonal but have different scales, at the cost of requiring extra calculation. + * + * @param[in] src Matrix to extract angles from. + * @param[out] dest vector to write angles to. + * @param[in] nonUniformScale boolean: true enables handling matrices with unnormalised columns. + * + * @remark original name: "Matrix_to_rotate2_new"? + * + * See Matrix_MtxFToYXZRot() for full inline documentation. + */ +void Matrix_MtxFToZYXRot(MtxF* src, Vec3s* dest, s32 nonUniformScale) { + f32 temp; + f32 temp2; + f32 temp3; + f32 temp4; + + temp = src->xx; + temp *= temp; + temp += SQ(src->yx); + dest->y = Math_Atan2S(-src->zx, sqrtf(temp)); + + if ((dest->y == 0x4000) || (dest->y == -0x4000)) { + dest->x = 0; + dest->z = Math_Atan2S(-src->xy, src->yy); + } else { + dest->z = Math_Atan2S(src->yx, src->xx); + + if (!nonUniformScale) { + dest->x = Math_Atan2S(src->zy, src->zz); + } else { + temp = src->xy; + temp2 = src->yy; + temp3 = src->yz; + + temp *= temp; + temp += SQ(temp2); + temp2 = src->zy; + temp += SQ(temp2); + temp = sqrtf(temp); + temp = temp2 / temp; + + temp2 = src->xz; + temp2 *= temp2; + temp2 += SQ(temp3); + temp3 = src->zz; + temp2 += SQ(temp3); + temp2 = sqrtf(temp2); + temp2 = temp3 / temp2; + + dest->x = Math_Atan2S(temp, temp2); + } + } +} + +/** + * @brief Rotate by `angle` radians about `axis`, which is assumed to be a unit vector. + * + * @param angle rotation angle (radians). + * @param axis axis about which to rotate, must be a unit vector. + * @param mode APPLY or NEW. + * + * @remark original name may have been "Matrix_RotateVector", but clashed with the next function. + */ +void Matrix_RotateAxisF(f32 angle, Vec3f* axis, MatrixMode mode) { + MtxF* cmf; + f32 sin; + f32 cos; + f32 versin; + f32 temp1; + f32 temp2; + f32 temp3; + f32 temp4; + f32 temp5; + + if (mode == MTXMODE_APPLY) { + if (angle != 0) { + cmf = sCurrentMatrix; + + sin = sinf(angle); + cos = cosf(angle); + + temp1 = cmf->xx; + temp2 = cmf->xy; + temp3 = cmf->xz; + temp4 = (axis->x * temp1 + axis->y * temp2 + axis->z * temp3) * (1.0f - cos); + cmf->xx = temp1 * cos + axis->x * temp4 + sin * (temp2 * axis->z - temp3 * axis->y); + cmf->xy = temp2 * cos + axis->y * temp4 + sin * (temp3 * axis->x - temp1 * axis->z); + cmf->xz = temp3 * cos + axis->z * temp4 + sin * (temp1 * axis->y - temp2 * axis->x); + + temp1 = cmf->yx; + temp2 = cmf->yy; + temp3 = cmf->yz; + temp4 = (axis->x * temp1 + axis->y * temp2 + axis->z * temp3) * (1.0f - cos); + cmf->yx = temp1 * cos + axis->x * temp4 + sin * (temp2 * axis->z - temp3 * axis->y); + cmf->yy = temp2 * cos + axis->y * temp4 + sin * (temp3 * axis->x - temp1 * axis->z); + cmf->yz = temp3 * cos + axis->z * temp4 + sin * (temp1 * axis->y - temp2 * axis->x); + + temp1 = cmf->zx; + temp2 = cmf->zy; + temp3 = cmf->zz; + temp4 = (axis->x * temp1 + axis->y * temp2 + axis->z * temp3) * (1.0f - cos); + cmf->zx = temp1 * cos + axis->x * temp4 + sin * (temp2 * axis->z - temp3 * axis->y); + cmf->zy = temp2 * cos + axis->y * temp4 + sin * (temp3 * axis->x - temp1 * axis->z); + cmf->zz = temp3 * cos + axis->z * temp4 + sin * (temp1 * axis->y - temp2 * axis->x); + } + } else { + cmf = sCurrentMatrix; + + if (angle != 0) { + sin = sinf(angle); + cos = cosf(angle); + versin = 1.0f - cos; + + cmf->xx = axis->x * axis->x * versin + cos; + cmf->yy = axis->y * axis->y * versin + cos; + cmf->zz = axis->z * axis->z * versin + cos; + + if (0) {} + + temp2 = axis->x * versin * axis->y; + temp3 = axis->z * sin; + cmf->yx = temp2 + temp3; + cmf->xy = temp2 - temp3; + + temp2 = axis->x * versin * axis->z; + temp3 = axis->y * sin; + cmf->zx = temp2 - temp3; + cmf->xz = temp2 + temp3; + + temp2 = axis->y * versin * axis->z; + temp3 = axis->x * sin; + cmf->zy = temp2 + temp3; + cmf->yz = temp2 - temp3; + + cmf->wx = cmf->wy = cmf->wz = cmf->xw = cmf->yw = cmf->zw = 0.0f; + cmf->ww = 1.0f; + } else { + cmf->xx = 1.0f; + cmf->yx = 0.0f; + cmf->zx = 0.0f; + cmf->wx = 0.0f; + cmf->xy = 0.0f; + cmf->yy = 1.0f; + cmf->zy = 0.0f; + cmf->wy = 0.0f; + cmf->xz = 0.0f; + cmf->yz = 0.0f; + cmf->zz = 1.0f; + cmf->wz = 0.0f; + cmf->xw = 0.0f; + cmf->yw = 0.0f; + cmf->zw = 0.0f; + cmf->ww = 1.0f; + } + } +} + +/** + * @brief Rotate by binary angle `angle` about `axis`, which is assumed to be a unit vector. + * + * @param angle rotation angle (binary). + * @param axis axis about which to rotate, must be a unit vector. + * @param mode APPLY or NEW. + * + * @remark original name: "Matrix_RotateVector" + */ +void Matrix_RotateAxisS(s16 angle, Vec3f* axis, MatrixMode mode) { + MtxF* cmf; + f32 cos; + f32 sin; + f32 versin; + f32 temp1; + f32 temp2; + f32 temp3; + f32 temp4; + + if (mode == MTXMODE_APPLY) { + if (angle != 0) { + cmf = sCurrentMatrix; + + sin = Math_SinS(angle); + cos = Math_CosS(angle); + + temp1 = cmf->xx; + temp2 = cmf->xy; + temp3 = cmf->xz; + temp4 = (axis->x * temp1 + axis->y * temp2 + axis->z * temp3) * (1.0f - cos); + cmf->xx = temp1 * cos + axis->x * temp4 + sin * (temp2 * axis->z - temp3 * axis->y); + cmf->xy = temp2 * cos + axis->y * temp4 + sin * (temp3 * axis->x - temp1 * axis->z); + cmf->xz = temp3 * cos + axis->z * temp4 + sin * (temp1 * axis->y - temp2 * axis->x); + + temp1 = cmf->yx; + temp2 = cmf->yy; + temp3 = cmf->yz; + temp4 = (axis->x * temp1 + axis->y * temp2 + axis->z * temp3) * (1.0f - cos); + cmf->yx = temp1 * cos + axis->x * temp4 + sin * (temp2 * axis->z - temp3 * axis->y); + cmf->yy = temp2 * cos + axis->y * temp4 + sin * (temp3 * axis->x - temp1 * axis->z); + cmf->yz = temp3 * cos + axis->z * temp4 + sin * (temp1 * axis->y - temp2 * axis->x); + + temp1 = cmf->zx; + temp2 = cmf->zy; + temp3 = cmf->zz; + temp4 = (axis->x * temp1 + axis->y * temp2 + axis->z * temp3) * (1.0f - cos); + cmf->zx = temp1 * cos + axis->x * temp4 + sin * (temp2 * axis->z - temp3 * axis->y); + cmf->zy = temp2 * cos + axis->y * temp4 + sin * (temp3 * axis->x - temp1 * axis->z); + cmf->zz = temp3 * cos + axis->z * temp4 + sin * (temp1 * axis->y - temp2 * axis->x); + } + } else { + cmf = sCurrentMatrix; + + if (angle != 0) { + sin = Math_SinS(angle); + cos = Math_CosS(angle); + versin = 1.0f - cos; + + cmf->xx = axis->x * axis->x * versin + cos; + cmf->yy = axis->y * axis->y * versin + cos; + cmf->zz = axis->z * axis->z * versin + cos; + + if (0) {} + + temp2 = axis->x * versin * axis->y; + temp3 = axis->z * sin; + cmf->yx = temp2 + temp3; + cmf->xy = temp2 - temp3; + + temp2 = axis->x * versin * axis->z; + temp3 = axis->y * sin; + cmf->zx = temp2 - temp3; + cmf->xz = temp2 + temp3; + + temp2 = axis->y * versin * axis->z; + temp3 = axis->x * sin; + cmf->zy = temp2 + temp3; + cmf->yz = temp2 - temp3; + + cmf->wx = cmf->wy = cmf->wz = cmf->xw = cmf->yw = cmf->zw = 0.0f; + cmf->ww = 1.0f; + } else { + cmf->xx = 1.0f; + cmf->yx = 0.0f; + cmf->zx = 0.0f; + cmf->wx = 0.0f; + cmf->xy = 0.0f; + cmf->yy = 1.0f; + cmf->zy = 0.0f; + cmf->wy = 0.0f; + cmf->xz = 0.0f; + cmf->yz = 0.0f; + cmf->zz = 1.0f; + cmf->wz = 0.0f; + cmf->xw = 0.0f; + cmf->yw = 0.0f; + cmf->zw = 0.0f; + cmf->ww = 1.0f; + } + } +} diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 2d75505d0..6d0b9573d 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -92,10 +92,10 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf } func_800C0094(actor->floorPoly, actor->world.pos.x, actor->floorHeight, actor->world.pos.z, &mtx); - Matrix_SetCurrentState(&mtx); + Matrix_Put(&mtx); if ((dlist != gCircleShadowDL) || (actor->scale.x != actor->scale.z)) { - Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY); } shadowScale *= actor->shape.shadowScale; @@ -151,8 +151,8 @@ void ActorShadow_DrawFoot(GlobalContext* globalCtx, Light* light, MtxF* arg2, s3 sp58 = Math_FAtan2F(dir2, dir0); shadowScaleZ *= (4.5f - (light->l.dir[1] * 0.035f)); shadowScaleZ = CLAMP_MIN(shadowScaleZ, 1.0f); - Matrix_SetCurrentState(arg2); - Matrix_RotateY(sp58, MTXMODE_APPLY); + Matrix_Put(arg2); + Matrix_RotateYS(sp58, MTXMODE_APPLY); Matrix_Scale(shadowScaleX, 1.0f, shadowScaleX * shadowScaleZ, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); @@ -301,9 +301,9 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx void Actor_SetFeetPos(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* leftFootPos, s32 rightFootIndex, Vec3f* rightFootPos) { if (limbIndex == leftFootIndex) { - Matrix_MultiplyVector3fByState(leftFootPos, &actor->shape.feetPos[FOOT_LEFT]); + Matrix_MultVec3f(leftFootPos, &actor->shape.feetPos[FOOT_LEFT]); } else if (limbIndex == rightFootIndex) { - Matrix_MultiplyVector3fByState(rightFootPos, &actor->shape.feetPos[FOOT_RIGHT]); + Matrix_MultVec3f(rightFootPos, &actor->shape.feetPos[FOOT_RIGHT]); } } @@ -533,22 +533,22 @@ void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx) { var2 = ((entry->unkC - 120.0f) * 0.001f) + 0.15f; } - Matrix_InsertTranslation(entry->pos.x, entry->pos.y, 0.0f, MTXMODE_NEW); + Matrix_Translate(entry->pos.x, entry->pos.y, 0.0f, MTXMODE_NEW); Matrix_Scale(var2, 0.15f, 1.0f, MTXMODE_APPLY); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, entry->color.r, entry->color.g, entry->color.b, (u8)alpha); - Matrix_InsertZRotation_s((targetCtx->unk4B * 512), MTXMODE_APPLY); + Matrix_RotateZS((targetCtx->unk4B * 512), MTXMODE_APPLY); for (i = 0; i < 4; i++) { - Matrix_InsertZRotation_s(0x4000, MTXMODE_APPLY); - Matrix_StatePush(); - Matrix_InsertTranslation(entry->unkC, entry->unkC, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(0x4000, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(entry->unkC, entry->unkC, 0.0f, MTXMODE_APPLY); gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(OVERLAY_DISP++, gZTargetLockOnTriangleDL); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -566,10 +566,10 @@ void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x07); - Matrix_InsertTranslation(actor->focus.pos.x, - actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y) + 17.0f, - actor->focus.pos.z, MTXMODE_NEW); - Matrix_RotateY((globalCtx->gameplayFrames * 3000), MTXMODE_APPLY); + Matrix_Translate(actor->focus.pos.x, + actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y) + 17.0f, + actor->focus.pos.z, MTXMODE_NEW); + Matrix_RotateYS((globalCtx->gameplayFrames * 3000), MTXMODE_APPLY); Matrix_Scale((iREG(27) + 35) / 1000.0f, (iREG(28) + 60) / 1000.0f, (iREG(29) + 50) / 1000.0f, MTXMODE_APPLY); @@ -2511,14 +2511,13 @@ void Actor_Draw(GlobalContext* globalCtx, Actor* actor) { Lights_Draw(light, globalCtx->state.gfxCtx); if (actor->flags & ACTOR_FLAG_1000) { - Matrix_SetStateRotationAndTranslation( + Matrix_SetTranslateRotateYXZ( actor->world.pos.x + globalCtx->mainCamera.skyboxOffset.x, actor->world.pos.y + ((actor->shape.yOffset * actor->scale.y) + globalCtx->mainCamera.skyboxOffset.y), actor->world.pos.z + globalCtx->mainCamera.skyboxOffset.z, &actor->shape.rot); } else { - Matrix_SetStateRotationAndTranslation(actor->world.pos.x, - actor->world.pos.y + (actor->shape.yOffset * actor->scale.y), - actor->world.pos.z, &actor->shape.rot); + Matrix_SetTranslateRotateYXZ(actor->world.pos.x, actor->world.pos.y + (actor->shape.yOffset * actor->scale.y), + actor->world.pos.z, &actor->shape.rot); } Matrix_Scale(actor->scale.x, actor->scale.y, actor->scale.z, MTXMODE_APPLY); @@ -3543,14 +3542,14 @@ void Actor_SpawnBodyParts(Actor* actor, GlobalContext* globalCtx, s32 arg2, Gfx* MtxF* currentMatrix; if (*dList != NULL) { - currentMatrix = Matrix_GetCurrentState(); + currentMatrix = Matrix_GetCurrent(); spawnedPart = Actor_SpawnAsChild(&globalCtx->actorCtx, actor, globalCtx, ACTOR_EN_PART, currentMatrix->mf[3][0], currentMatrix->mf[3][1], currentMatrix->mf[3][2], 0, 0, actor->objBankIndex, arg2); if (spawnedPart != NULL) { part = (EnPart*)spawnedPart; - func_8018219C(currentMatrix, &part->actor.shape.rot, 0); + Matrix_MtxFToYXZRot(currentMatrix, &part->actor.shape.rot, false); part->unk_150 = *dList; Math_Vec3f_Copy(&part->actor.scale, &actor->scale); } @@ -3772,9 +3771,9 @@ void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx) sp54 = BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &sp44, &sp48); if (sp44 != NULL) { func_800C0094(sp44, arg0->x, sp54, arg0->z, &sp58); - Matrix_SetCurrentState(&sp58); + Matrix_Put(&sp58); } else { - Matrix_InsertTranslation(arg0->x, arg0->y, arg0->z, MTXMODE_NEW); + Matrix_Translate(arg0->x, arg0->y, arg0->z, MTXMODE_NEW); } Matrix_Scale(arg1->x, 1.0f, arg1->z, MTXMODE_APPLY); @@ -3841,16 +3840,16 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, entry->yShift, 500.0f, MTXMODE_APPLY); - Matrix_CopyCurrentState(&baseMtxF); + Matrix_Translate(0.0f, entry->yShift, 500.0f, MTXMODE_APPLY); + Matrix_Get(&baseMtxF); - chainsTranslateX = __sinf(entry->chainAngle - chainRotZ) * -(10 - frame) * 0.1f * entry->chainLength; - chainsTranslateY = __cosf(entry->chainAngle - chainRotZ) * (10 - frame) * 0.1f * entry->chainLength; + chainsTranslateX = sinf(entry->chainAngle - chainRotZ) * -(10 - frame) * 0.1f * entry->chainLength; + chainsTranslateY = cosf(entry->chainAngle - chainRotZ) * (10 - frame) * 0.1f * entry->chainLength; for (i = 0; i < 4; i++) { - Matrix_SetCurrentState(&baseMtxF); - Matrix_InsertZRotation_f(chainRotZ, MTXMODE_APPLY); - Matrix_InsertTranslation(chainsTranslateX, chainsTranslateY, 0.0f, MTXMODE_APPLY); + Matrix_Put(&baseMtxF); + Matrix_RotateZF(chainRotZ, MTXMODE_APPLY); + Matrix_Translate(chainsTranslateX, chainsTranslateY, 0.0f, MTXMODE_APPLY); if (entry->chainsScale != 1.0f) { Matrix_Scale(entry->chainsScale, entry->chainsScale, entry->chainsScale, MTXMODE_APPLY); } @@ -3867,7 +3866,7 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { chainRotZ += rotZStep; } - Matrix_SetCurrentState(&baseMtxF); + Matrix_Put(&baseMtxF); Matrix_Scale(frame * 0.1f, frame * 0.1f, frame * 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4516,7 +4515,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP u32 gameplayFrames = globalCtx->gameplayFrames; f32 effectAlphaScaled; - currentMatrix = Matrix_GetCurrentState(); + currentMatrix = Matrix_GetCurrent(); // Apply sfx along with damage effect if ((actor != NULL) && (effectAlpha > 0.05f) && (globalCtx->gameOverCtx.state == 0)) { @@ -4565,15 +4564,15 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP gDPSetEnvColor(POLY_XLU_DISP++, KREG(20) + 200, KREG(21) + 200, KREG(22) + 255, (u8)alpha); - Matrix_InsertTranslation(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); + Matrix_Translate(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); Matrix_Scale(frozenScale, frozenScale, frozenScale, MTXMODE_APPLY); if (limbIndex & 1) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } if (limbIndex & 2) { - Matrix_InsertZRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateZF(M_PI, MTXMODE_APPLY); } gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -4604,8 +4603,8 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, twoTexScrollParam * 3, twoTexScrollParam * -12, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(steamScale, steamScale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -4625,7 +4624,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP type = 255; } - Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Put(&globalCtx->billboardMtxF); Matrix_Scale((effectScale * 0.005f) * 1.35f, (effectScale * 0.005f), (effectScale * 0.005f) * 1.35f, MTXMODE_APPLY); @@ -4651,7 +4650,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, ((limbIndex * 10 + gameplayFrames) * -20) & 0x1FF, 32, 128)); - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); currentMatrix->mf[3][0] = limbPos->x; currentMatrix->mf[3][1] = limbPos->y; currentMatrix->mf[3][2] = limbPos->z; @@ -4688,12 +4687,12 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 100, 128); } - Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Put(&globalCtx->billboardMtxF); Matrix_Scale(lightOrbsScale, lightOrbsScale, 1.0f, MTXMODE_APPLY); // Apply and draw a light orb over each limb of frozen actor for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { - Matrix_InsertZRotation_f(randPlusMinusPoint5Scaled(2 * M_PI), MTXMODE_APPLY); + Matrix_RotateZF(randPlusMinusPoint5Scaled(2 * M_PI), MTXMODE_APPLY); currentMatrix->mf[3][0] = limbPos->x; currentMatrix->mf[3][1] = limbPos->y; currentMatrix->mf[3][2] = limbPos->z; @@ -4726,14 +4725,14 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP gDPSetEnvColor(POLY_XLU_DISP++, (u8)(sREG(20) + 255), (u8)(sREG(21) + 255), (u8)sREG(22), (u8)sREG(23)); - Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Put(&globalCtx->billboardMtxF); Matrix_Scale(electricSparksScale, electricSparksScale, electricSparksScale, MTXMODE_APPLY); // Every limb draws two electric sparks at random orientations for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { // first electric spark - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); + Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI)); + Matrix_RotateZF(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); currentMatrix->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; currentMatrix->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; currentMatrix->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; @@ -4744,8 +4743,8 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP gSPDisplayList(POLY_XLU_DISP++, gElectricSparkVtxDL); // second electric spark - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); + Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI)); + Matrix_RotateZF(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); currentMatrix->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; currentMatrix->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; currentMatrix->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 58c71c33e..0667bd84b 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -248,20 +248,20 @@ void func_800C0094(CollisionPoly* poly, f32 tx, f32 ty, f32 tz, MtxF* dest) { phi_f12 = 0.0f; } dest->xx = z_f14; - dest->xy = (-nx) * phi_f14; - dest->xz = (-nx) * phi_f12; - dest->yx = nx; + dest->yx = (-nx) * phi_f14; + dest->zx = (-nx) * phi_f12; + dest->xy = nx; dest->yy = ny; - dest->yz = nz; - dest->zx = 0.0f; - dest->zy = -phi_f12; + dest->zy = nz; + dest->xz = 0.0f; + dest->yz = -phi_f12; dest->zz = phi_f14; - dest->wx = tx; - dest->wy = ty; - dest->wz = tz; - dest->xw = 0.0f; - dest->yw = 0.0f; - dest->zw = 0.0f; + dest->xw = tx; + dest->yw = ty; + dest->zw = tz; + dest->wx = 0.0f; + dest->wy = 0.0f; + dest->wz = 0.0f; dest->ww = 1.0f; } diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index a08e3f822..7ac956e5d 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -3691,7 +3691,7 @@ void Collider_UpdateSpheres(s32 limb, ColliderJntSph* collider) { D_801EE1C0.x = collider->elements[i].dim.modelSphere.center.x; D_801EE1C0.y = collider->elements[i].dim.modelSphere.center.y; D_801EE1C0.z = collider->elements[i].dim.modelSphere.center.z; - Matrix_MultiplyVector3fByState(&D_801EE1C0, &D_801EE1D0); + Matrix_MultVec3f(&D_801EE1C0, &D_801EE1D0); collider->elements[i].dim.worldSphere.center.x = D_801EE1D0.x; collider->elements[i].dim.worldSphere.center.y = D_801EE1D0.y; collider->elements[i].dim.worldSphere.center.z = D_801EE1D0.z; @@ -3733,7 +3733,7 @@ void Collider_UpdateSphere(s32 limb, ColliderSphere* collider) { D_801EE1E0.x = collider->dim.modelSphere.center.x; D_801EE1E0.y = collider->dim.modelSphere.center.y; D_801EE1E0.z = collider->dim.modelSphere.center.z; - Matrix_MultiplyVector3fByState(&D_801EE1E0, &D_801EE1F0); + Matrix_MultVec3f(&D_801EE1E0, &D_801EE1F0); collider->dim.worldSphere.center.x = D_801EE1F0.x; collider->dim.worldSphere.center.y = D_801EE1F0.y; collider->dim.worldSphere.center.z = D_801EE1F0.z; diff --git a/src/code/z_debug_display.c b/src/code/z_debug_display.c index ab3478fa1..fb7378751 100644 --- a/src/code/z_debug_display.c +++ b/src/code/z_debug_display.c @@ -68,10 +68,10 @@ void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, GlobalCo func_8012C6FC(globalCtx->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, dispObj->color.r, dispObj->color.g, dispObj->color.b, dispObj->color.a); - Matrix_InsertTranslation(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, MTXMODE_NEW); + Matrix_Translate(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, MTXMODE_NEW); Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertRotation(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZYX(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, MTXMODE_APPLY); gDPLoadTextureBlock(POLY_XLU_DISP++, texture, G_IM_FMT_I, G_IM_SIZ_8b, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -94,7 +94,7 @@ void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, GlobalContex gSPSetLights1(POLY_XLU_DISP++, sDebugDisplayLight1); - Matrix_SetStateRotationAndTranslation(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, &dispObj->rot); + Matrix_SetTranslateRotateYXZ(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, &dispObj->rot); Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/code/z_eff_footmark.c b/src/code/z_eff_footmark.c index d246aaffa..f959867fe 100644 --- a/src/code/z_eff_footmark.c +++ b/src/code/z_eff_footmark.c @@ -106,7 +106,7 @@ void EffFootmark_Draw(GlobalContext* globalCtx) { for (footmark = globalCtx->footprintInfo, i = 0; i < 100; i++, footmark++) { if (footmark->actor != NULL) { - Matrix_SetCurrentState(&footmark->displayMatrix); + Matrix_Put(&footmark->displayMatrix); Matrix_Scale(footmark->size * (1.0f / 0x100) * 0.7f, 1, footmark->size * (1.0f / 0x100), MTXMODE_APPLY); gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD); diff --git a/src/code/z_fcurve_data_skelanime.c b/src/code/z_fcurve_data_skelanime.c index e22b5f351..c8eb927fa 100644 --- a/src/code/z_fcurve_data_skelanime.c +++ b/src/code/z_fcurve_data_skelanime.c @@ -104,7 +104,7 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); if (overrideLimbDraw == NULL || (overrideLimbDraw != NULL && overrideLimbDraw(globalCtx, skelCurve, limbIndex, thisx))) { @@ -126,7 +126,7 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* pos.y = transform->y; pos.z = transform->z; - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); if (lod == 0) { @@ -164,7 +164,7 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* SkelCurve_DrawLimb(globalCtx, limb->firstChildIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->nextLimbIdx != LIMB_DONE) { SkelCurve_DrawLimb(globalCtx, limb->nextLimbIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); diff --git a/src/code/z_fireobj.c b/src/code/z_fireobj.c index 379ebda1d..f627c6394 100644 --- a/src/code/z_fireobj.c +++ b/src/code/z_fireobj.c @@ -159,7 +159,7 @@ void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { vec.x = 0; vec.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000; vec.z = 0; - Matrix_SetStateRotationAndTranslation(fire->position.x, fire->position.y, fire->position.z, &vec); + Matrix_SetTranslateRotateYXZ(fire->position.x, fire->position.y, fire->position.z, &vec); Matrix_Scale(fire->xScale, fire->yScale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 5d47b4153..e9fae530a 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -431,7 +431,7 @@ void Lights_DrawGlow(GlobalContext* globalCtx) { gDPSetPrimColor(dl++, 0, 0, params->color[0], params->color[1], params->color[2], 50); - Matrix_InsertTranslation(params->x, params->y, params->z, MTXMODE_NEW); + Matrix_Translate(params->x, params->y, params->z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(dl++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 6563eecfc..0a3334bc8 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -33,7 +33,7 @@ void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skele OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; rot = jointTable[limbIndex]; @@ -44,7 +44,7 @@ void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skele dList = limb->dLists[lod]; if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, actor) == 0)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -63,7 +63,7 @@ void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skele SkelAnime_DrawLimbLod(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, lod); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { SkelAnime_DrawLimbLod(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, @@ -91,7 +91,7 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); pos.x = jointTable[0].x; @@ -102,7 +102,7 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa dList = rootLimb->dLists[lod]; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -123,7 +123,7 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa lod); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -143,7 +143,7 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -157,7 +157,7 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s newDList = limbDList = limb->dLists[lod]; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Matrix_ToMtx(*mtx); gSPMatrix(POLY_OPA_DISP++, *mtx, G_MTX_LOAD); @@ -178,7 +178,7 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s lod, mtx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { SkelAnime_DrawFlexLimbLod(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, @@ -211,7 +211,7 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi OPEN_DISPS(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); pos.x = jointTable[0].x; @@ -223,7 +223,7 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi newDList = limbDList = rootLimb->dLists[lod]; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -246,7 +246,7 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi actor, lod, &mtx); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -263,7 +263,7 @@ void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skele OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -274,7 +274,7 @@ void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skele dList = limb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -292,7 +292,7 @@ void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skele SkelAnime_DrawLimbOpa(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { SkelAnime_DrawLimbOpa(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor); @@ -318,7 +318,7 @@ void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); pos.x = jointTable[0].x; @@ -329,7 +329,7 @@ void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa dList = rootLimb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -347,7 +347,7 @@ void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa SkelAnime_DrawLimbOpa(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -363,7 +363,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -376,7 +376,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s newDList = limbDList = limb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Matrix_ToMtx(*limbMatricies); gSPMatrix(POLY_OPA_DISP++, *limbMatricies, G_MTX_LOAD); @@ -397,7 +397,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s limbMatricies); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { SkelAnime_DrawFlexLimbOpa(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, @@ -430,7 +430,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); @@ -442,7 +442,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi newDList = limbDList = rootLimb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -467,7 +467,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi actor, &mtx); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -483,7 +483,7 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -496,8 +496,8 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, newDList = limbDList = limb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); - Matrix_StatePush(); + Matrix_TranslateRotateZYX(&pos, &rot); + Matrix_Push(); transformLimbDraw(globalCtx, limbIndex, actor); @@ -514,7 +514,7 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, (*mtx)++; } } - Matrix_StatePop(); + Matrix_Pop(); } if (postLimbDraw != NULL) { @@ -526,7 +526,7 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, transformLimbDraw, actor, mtx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { SkelAnime_DrawTransformFlexLimbOpa(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, @@ -566,7 +566,7 @@ void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, V gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); @@ -578,8 +578,8 @@ void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, V newDList = limbDList = rootLimb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor)) { - Matrix_JointPosition(&pos, &rot); - Matrix_StatePush(); + Matrix_TranslateRotateZYX(&pos, &rot); + Matrix_Push(); transformLimbDraw(globalCtx, 1, actor); @@ -595,7 +595,7 @@ void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, V Matrix_ToMtx(mtx++); } } - Matrix_StatePop(); + Matrix_Pop(); } if (postLimbDraw != NULL) { @@ -607,7 +607,7 @@ void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, V postLimbDraw, transformLimbDraw, actor, &mtx); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -660,7 +660,7 @@ Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton Vec3f pos; Vec3s rot; - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -673,7 +673,7 @@ Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton dList = limb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(&gfx[1], dList); @@ -690,7 +690,7 @@ Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton gfx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { gfx = SkelAnime_DrawLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, @@ -716,7 +716,7 @@ Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable return NULL; } - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); @@ -729,7 +729,7 @@ Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable dList = rootLimb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(&gfx[1], dList); @@ -746,7 +746,7 @@ Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable actor, gfx); } - Matrix_StatePop(); + Matrix_Pop(); return gfx; } @@ -763,7 +763,7 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel Vec3f pos; Vec3s rot; - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; @@ -776,7 +776,7 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel newDList = limbDList = limb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { gSPMatrix(&gfx[0], Matrix_ToMtx(*mtx), G_MTX_LOAD); gSPDisplayList(&gfx[1], newDList); @@ -799,7 +799,7 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel actor, mtx, gfx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { gfx = SkelAnime_DrawFlexLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, @@ -832,7 +832,7 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT gSPSegment(gfx++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); @@ -845,7 +845,7 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT newDList = limbDList = rootLimb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); + Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { gSPMatrix(&gfx[0], Matrix_ToMtx(mtx), G_MTX_LOAD); gSPDisplayList(&gfx[1], newDList); @@ -868,7 +868,7 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT actor, &mtx, gfx); } - Matrix_StatePop(); + Matrix_Pop(); return gfx; } diff --git a/src/code/z_skin.c b/src/code/z_skin.c index 808a00da0..de449c02d 100644 --- a/src/code/z_skin.c +++ b/src/code/z_skin.c @@ -13,13 +13,13 @@ void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* mod Vec3f normal; Vec3f sp44; - wTemp.x = mtx->wx; - wTemp.y = mtx->wy; - wTemp.z = mtx->wz; + wTemp.x = mtx->xw; + wTemp.y = mtx->yw; + wTemp.z = mtx->zw; - mtx->wx = 0.0f; - mtx->wy = 0.0f; - mtx->wz = 0.0f; + mtx->xw = 0.0f; + mtx->yw = 0.0f; + mtx->zw = 0.0f; for (vertexEntry = skinVertices; vertexEntry < &skinVertices[modifEntry->vtxCount]; vertexEntry++) { vtx = &vtxBuf[vertexEntry->index]; @@ -39,9 +39,9 @@ void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* mod vtx->n.n[2] = normal.z; } - mtx->wx = wTemp.x; - mtx->wy = wTemp.y; - mtx->wz = wTemp.z; + mtx->xw = wTemp.x; + mtx->yw = wTemp.y; + mtx->zw = wTemp.z; } void Skin_ApplyLimbModifications(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3) { diff --git a/src/code/z_skin_matrix.c b/src/code/z_skin_matrix.c index f355aec9b..9b30a3c0b 100644 --- a/src/code/z_skin_matrix.c +++ b/src/code/z_skin_matrix.c @@ -1,13 +1,11 @@ #include "global.h" -// clang-format off -MtxF sMtxFClear = { - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f, -}; -// clang-format on +MtxF sMtxFClear = { { + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f, 1.0f }, +} }; /** * Multiplies a 4 component row vector [ src , 1 ] by the matrix mf and writes the resulting 4 components to xyzDest @@ -16,10 +14,10 @@ MtxF sMtxFClear = { * \f[ [\texttt{xyzDest}, \texttt{wDest}] = [\texttt{src}, 1] \cdot [mf] \f] */ void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest) { - xyzDest->x = mf->wx + ((src->x * mf->xx) + (src->y * mf->yx) + (src->z * mf->zx)); - xyzDest->y = mf->wy + ((src->x * mf->xy) + (src->y * mf->yy) + (src->z * mf->zy)); - xyzDest->z = mf->wz + ((src->x * mf->xz) + (src->y * mf->yz) + (src->z * mf->zz)); - *wDest = mf->ww + ((src->x * mf->xw) + (src->y * mf->yw) + (src->z * mf->zw)); + xyzDest->x = mf->xw + ((src->x * mf->xx) + (src->y * mf->xy) + (src->z * mf->xz)); + xyzDest->y = mf->yw + ((src->x * mf->yx) + (src->y * mf->yy) + (src->z * mf->yz)); + xyzDest->z = mf->zw + ((src->x * mf->zx) + (src->y * mf->zy) + (src->z * mf->zz)); + *wDest = mf->ww + ((src->x * mf->wx) + (src->y * mf->wy) + (src->z * mf->wz)); } /** @@ -29,21 +27,22 @@ void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDe */ void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, Vec3f* src, Vec3f* dest) { f32 mx = mf->xx; - f32 my = mf->yx; - f32 mz = mf->zx; - f32 mw = mf->wx; + f32 my = mf->xy; + f32 mz = mf->xz; + f32 mw = mf->xw; + dest->x = mw + ((src->x * mx) + (src->y * my) + (src->z * mz)); - mx = mf->xy; + mx = mf->yx; my = mf->yy; - mz = mf->zy; - mw = mf->wy; + mz = mf->yz; + mw = mf->yw; dest->y = mw + ((src->x * mx) + (src->y * my) + (src->z * mz)); - mx = mf->xz; - my = mf->yz; + mx = mf->zx; + my = mf->zy; mz = mf->zz; - mw = mf->wz; + mw = mf->zw; dest->z = mw + ((src->x * mx) + (src->y * my) + (src->z * mz)); } @@ -59,122 +58,122 @@ void SkinMatrix_MtxFMtxFMult(MtxF* mfB, MtxF* mfA, MtxF* dest) { //---COL1--- f32 cx = mfB->xx; - f32 cy = mfB->yx; - f32 cz = mfB->zx; - f32 cw = mfB->wx; + f32 cy = mfB->xy; + f32 cz = mfB->xz; + f32 cw = mfB->xw; //-------- rx = mfA->xx; - ry = mfA->xy; - rz = mfA->xz; - rw = mfA->xw; + ry = mfA->yx; + rz = mfA->zx; + rw = mfA->wx; dest->xx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->yx; + rx = mfA->xy; ry = mfA->yy; - rz = mfA->yz; - rw = mfA->yw; - dest->yx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - - rx = mfA->zx; - ry = mfA->zy; - rz = mfA->zz; - rw = mfA->zw; - dest->zx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - - rx = mfA->wx; - ry = mfA->wy; - rz = mfA->wz; - rw = mfA->ww; - dest->wx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - - //---2Col--- - cx = mfB->xy; - cy = mfB->yy; - cz = mfB->zy; - cw = mfB->wy; - //-------- - rx = mfA->xx; - ry = mfA->xy; - rz = mfA->xz; - rw = mfA->xw; + rz = mfA->zy; + rw = mfA->wy; dest->xy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->yx; - ry = mfA->yy; - rz = mfA->yz; - rw = mfA->yw; - dest->yy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - - rx = mfA->zx; - ry = mfA->zy; + rx = mfA->xz; + ry = mfA->yz; rz = mfA->zz; - rw = mfA->zw; - dest->zy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - - rx = mfA->wx; - ry = mfA->wy; - rz = mfA->wz; - rw = mfA->ww; - dest->wy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - - //---3Col--- - cx = mfB->xz; - cy = mfB->yz; - cz = mfB->zz; - cw = mfB->wz; - //-------- - rx = mfA->xx; - ry = mfA->xy; - rz = mfA->xz; - rw = mfA->xw; + rw = mfA->wz; dest->xz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->yx; + rx = mfA->xw; + ry = mfA->yw; + rz = mfA->zw; + rw = mfA->ww; + dest->xw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + //---2Col--- + cx = mfB->yx; + cy = mfB->yy; + cz = mfB->yz; + cw = mfB->yw; + //-------- + rx = mfA->xx; + ry = mfA->yx; + rz = mfA->zx; + rw = mfA->wx; + dest->yx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->xy; ry = mfA->yy; - rz = mfA->yz; - rw = mfA->yw; + rz = mfA->zy; + rw = mfA->wy; + dest->yy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->xz; + ry = mfA->yz; + rz = mfA->zz; + rw = mfA->wz; dest->yz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->zx; - ry = mfA->zy; + rx = mfA->xw; + ry = mfA->yw; + rz = mfA->zw; + rw = mfA->ww; + dest->yw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + //---3Col--- + cx = mfB->zx; + cy = mfB->zy; + cz = mfB->zz; + cw = mfB->zw; + //-------- + rx = mfA->xx; + ry = mfA->yx; + rz = mfA->zx; + rw = mfA->wx; + dest->zx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->xy; + ry = mfA->yy; + rz = mfA->zy; + rw = mfA->wy; + dest->zy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + + rx = mfA->xz; + ry = mfA->yz; rz = mfA->zz; - rw = mfA->zw; + rw = mfA->wz; dest->zz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->wx; - ry = mfA->wy; - rz = mfA->wz; + rx = mfA->xw; + ry = mfA->yw; + rz = mfA->zw; rw = mfA->ww; - dest->wz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + dest->zw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); //---4Col--- - cx = mfB->xw; - cy = mfB->yw; - cz = mfB->zw; + cx = mfB->wx; + cy = mfB->wy; + cz = mfB->wz; cw = mfB->ww; //-------- rx = mfA->xx; - ry = mfA->xy; - rz = mfA->xz; - rw = mfA->xw; - dest->xw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + ry = mfA->yx; + rz = mfA->zx; + rw = mfA->wx; + dest->wx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->yx; + rx = mfA->xy; ry = mfA->yy; - rz = mfA->yz; - rw = mfA->yw; - dest->yw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + rz = mfA->zy; + rw = mfA->wy; + dest->wy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->zx; - ry = mfA->zy; + rx = mfA->xz; + ry = mfA->yz; rz = mfA->zz; - rw = mfA->zw; - dest->zw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); + rw = mfA->wz; + dest->wz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); - rx = mfA->wx; - ry = mfA->wy; - rz = mfA->wz; + rx = mfA->xw; + ry = mfA->yw; + rz = mfA->zw; rw = mfA->ww; dest->ww = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw); } @@ -188,39 +187,39 @@ void SkinMatrix_GetClear(MtxF** mfp) { void SkinMatrix_Clear(MtxF* mf) { mf->xx = 1.0f; - mf->xy = 0.0f; - mf->xz = 0.0f; - mf->xw = 0.0f; mf->yx = 0.0f; - mf->yy = 1.0f; - mf->yz = 0.0f; - mf->yw = 0.0f; mf->zx = 0.0f; - mf->zy = 0.0f; - mf->zz = 1.0f; - mf->zw = 0.0f; mf->wx = 0.0f; + mf->xy = 0.0f; + mf->yy = 1.0f; + mf->zy = 0.0f; mf->wy = 0.0f; + mf->xz = 0.0f; + mf->yz = 0.0f; + mf->zz = 1.0f; mf->wz = 0.0f; + mf->xw = 0.0f; + mf->yw = 0.0f; + mf->zw = 0.0f; mf->ww = 1.0f; } void SkinMatrix_MtxFCopy(MtxF* src, MtxF* dest) { dest->xx = src->xx; - dest->xy = src->xy; - dest->xz = src->xz; - dest->xw = src->xw; dest->yx = src->yx; - dest->yy = src->yy; - dest->yz = src->yz; - dest->yw = src->yw; dest->zx = src->zx; - dest->zy = src->zy; - dest->zz = src->zz; - dest->zw = src->zw; dest->wx = src->wx; + dest->xy = src->xy; + dest->yy = src->yy; + dest->zy = src->zy; dest->wy = src->wy; + dest->xz = src->xz; + dest->yz = src->yz; + dest->zz = src->zz; dest->wz = src->wz; + dest->xw = src->xw; + dest->yw = src->yw; + dest->zw = src->zw; dest->ww = src->ww; } @@ -282,18 +281,18 @@ s32 SkinMatrix_Invert(MtxF* src, MtxF* dest) { * Produces a matrix which scales x,y,z components of vectors or x,y,z rows of matrices (when applied on LHS) */ void SkinMatrix_SetScale(MtxF* mf, f32 x, f32 y, f32 z) { - mf->xy = 0.0f; - mf->xz = 0.0f; - mf->xw = 0.0f; mf->yx = 0.0f; - mf->yz = 0.0f; - mf->yw = 0.0f; mf->zx = 0.0f; - mf->zy = 0.0f; - mf->zw = 0.0f; mf->wx = 0.0f; + mf->xy = 0.0f; + mf->zy = 0.0f; mf->wy = 0.0f; + mf->xz = 0.0f; + mf->yz = 0.0f; mf->wz = 0.0f; + mf->xw = 0.0f; + mf->yw = 0.0f; + mf->zw = 0.0f; mf->ww = 1.0f; mf->xx = x; mf->yy = y; @@ -307,16 +306,16 @@ void SkinMatrix_SetRotateRPY(MtxF* mf, s16 roll, s16 pitch, s16 yaw) { f32 cos2; f32 sin = Math_SinS(yaw); f32 cos = Math_CosS(yaw); - f32 yx; + f32 xy; f32 sin2; - f32 zx; + f32 xz; f32 yy; - f32 zy; + f32 yz; mf->yy = cos; - mf->yx = -sin; - mf->xw = mf->yw = mf->zw = 0; + mf->xy = -sin; mf->wx = mf->wy = mf->wz = 0; + mf->xw = mf->yw = mf->zw = 0; mf->ww = 1; if (pitch != 0) { @@ -324,19 +323,19 @@ void SkinMatrix_SetRotateRPY(MtxF* mf, s16 roll, s16 pitch, s16 yaw) { cos2 = Math_CosS(pitch); mf->xx = cos * cos2; - mf->zx = cos * sin2; + mf->xz = cos * sin2; - mf->xy = sin * cos2; - mf->zy = sin * sin2; - mf->xz = -sin2; + mf->yx = sin * cos2; + mf->yz = sin * sin2; + mf->zx = -sin2; mf->zz = cos2; } else { mf->xx = cos; if (1) {} if (1) {} - zx = sin; // required to match - mf->xy = sin; - mf->xz = mf->zx = mf->zy = 0; + xz = sin; // required to match + mf->yx = sin; + mf->zx = mf->xz = mf->yz = 0; mf->zz = 1; } @@ -344,22 +343,22 @@ void SkinMatrix_SetRotateRPY(MtxF* mf, s16 roll, s16 pitch, s16 yaw) { sin2 = Math_SinS(roll); cos2 = Math_CosS(roll); - yx = mf->yx; - zx = mf->zx; - mf->yx = (yx * cos2) + (zx * sin2); - mf->zx = (zx * cos2) - (yx * sin2); + xy = mf->xy; + xz = mf->xz; + mf->xy = (xy * cos2) + (xz * sin2); + mf->xz = (xz * cos2) - (xy * sin2); if (1) {} - zy = mf->zy; + yz = mf->yz; yy = mf->yy; - mf->yy = (yy * cos2) + (zy * sin2); - mf->zy = (zy * cos2) - (yy * sin2); + mf->yy = (yy * cos2) + (yz * sin2); + mf->yz = (yz * cos2) - (yy * sin2); if (cos2) {} - mf->yz = mf->zz * sin2; + mf->zy = mf->zz * sin2; mf->zz = mf->zz * cos2; } else { - mf->yz = 0; + mf->zy = 0; } } @@ -370,23 +369,23 @@ void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch) { f32 cos2; f32 sin; f32 cos; - f32 xz; + f32 zx; f32 sin2; - f32 yz; + f32 zy; f32 xx; - f32 yx; + f32 xy; sin = Math_SinS(roll); cos = Math_CosS(roll); mf->xx = cos; - mf->xz = -sin; - mf->zw = 0; - mf->yw = 0; - mf->xw = 0; + mf->zx = -sin; mf->wz = 0; mf->wy = 0; mf->wx = 0; + mf->zw = 0; + mf->yw = 0; + mf->xw = 0; mf->ww = 1; if (yaw != 0) { @@ -394,19 +393,19 @@ void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch) { cos2 = Math_CosS(yaw); mf->zz = cos * cos2; - mf->yz = cos * sin2; + mf->zy = cos * sin2; - mf->zx = sin * cos2; - mf->yx = sin * sin2; - mf->zy = -sin2; + mf->xz = sin * cos2; + mf->xy = sin * sin2; + mf->yz = -sin2; mf->yy = cos2; } else { mf->zz = cos; if (1) {} if (1) {} - yx = sin; // required to match - mf->zx = sin; - mf->yx = mf->yz = mf->zy = 0; + xy = sin; // required to match + mf->xz = sin; + mf->xy = mf->zy = mf->yz = 0; mf->yy = 1; } @@ -414,19 +413,19 @@ void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch) { sin2 = Math_SinS(pitch); cos2 = Math_CosS(pitch); xx = mf->xx; - yx = mf->yx; - mf->xx = (xx * cos2) + (yx * sin2); - mf->yx = yx * cos2 - (xx * sin2); + xy = mf->xy; + mf->xx = (xx * cos2) + (xy * sin2); + mf->xy = xy * cos2 - (xx * sin2); if (1) {} - yz = mf->yz; - xz = mf->xz; - mf->xz = (xz * cos2) + (yz * sin2); - mf->yz = (yz * cos2) - (xz * sin2); + zy = mf->zy; + zx = mf->zx; + mf->zx = (zx * cos2) + (zy * sin2); + mf->zy = (zy * cos2) - (zx * sin2); if (cos2) {} - mf->xy = mf->yy * sin2; + mf->yx = mf->yy * sin2; mf->yy = mf->yy * cos2; } else { - mf->xy = 0; + mf->yx = 0; } } @@ -434,22 +433,22 @@ void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch) { * Produces a matrix which translates a vector by amounts in the x, y and z directions */ void SkinMatrix_SetTranslate(MtxF* mf, f32 x, f32 y, f32 z) { - mf->xy = 0.0f; - mf->xz = 0.0f; - mf->xw = 0.0f; mf->yx = 0.0f; - mf->yz = 0.0f; - mf->yw = 0.0f; mf->zx = 0.0f; + mf->wx = 0.0f; + mf->xy = 0.0f; mf->zy = 0.0f; - mf->zw = 0.0f; + mf->wy = 0.0f; + mf->xz = 0.0f; + mf->yz = 0.0f; + mf->wz = 0.0f; mf->xx = 1.0f; mf->yy = 1.0f; mf->zz = 1.0f; mf->ww = 1.0f; - mf->wx = x; - mf->wy = y; - mf->wz = z; + mf->xw = x; + mf->yw = y; + mf->zw = z; } /** @@ -515,19 +514,19 @@ void SkinMatrix_MtxFToMtx(MtxF* src, Mtx* dest) { m1[0] = (temp >> 0x10); m1[16 + 0] = temp & 0xFFFF; - temp = src->xy * 0x10000; + temp = src->yx * 0x10000; m1[1] = (temp >> 0x10); m1[16 + 1] = temp & 0xFFFF; - temp = src->xz * 0x10000; + temp = src->zx * 0x10000; m1[2] = (temp >> 0x10); m1[16 + 2] = temp & 0xFFFF; - temp = src->xw * 0x10000; + temp = src->wx * 0x10000; m1[3] = (temp >> 0x10); m1[16 + 3] = temp & 0xFFFF; - temp = src->yx * 0x10000; + temp = src->xy * 0x10000; m1[4] = (temp >> 0x10); m1[16 + 4] = temp & 0xFFFF; @@ -535,19 +534,19 @@ void SkinMatrix_MtxFToMtx(MtxF* src, Mtx* dest) { m1[5] = (temp >> 0x10); m1[16 + 5] = temp & 0xFFFF; - temp = src->yz * 0x10000; + temp = src->zy * 0x10000; m1[6] = (temp >> 0x10); m1[16 + 6] = temp & 0xFFFF; - temp = src->yw * 0x10000; + temp = src->wy * 0x10000; m1[7] = (temp >> 0x10); m1[16 + 7] = temp & 0xFFFF; - temp = src->zx * 0x10000; + temp = src->xz * 0x10000; m1[8] = (temp >> 0x10); m1[16 + 8] = temp & 0xFFFF; - temp = src->zy * 0x10000; + temp = src->yz * 0x10000; m1[9] = (temp >> 0x10); m2[9] = temp & 0xFFFF; @@ -555,19 +554,19 @@ void SkinMatrix_MtxFToMtx(MtxF* src, Mtx* dest) { m1[10] = (temp >> 0x10); m2[10] = temp & 0xFFFF; - temp = src->zw * 0x10000; + temp = src->wz * 0x10000; m1[11] = (temp >> 0x10); m2[11] = temp & 0xFFFF; - temp = src->wx * 0x10000; + temp = src->xw * 0x10000; m1[12] = (temp >> 0x10); m2[12] = temp & 0xFFFF; - temp = src->wy * 0x10000; + temp = src->yw * 0x10000; m1[13] = (temp >> 0x10); m2[13] = temp & 0xFFFF; - temp = src->wz * 0x10000; + temp = src->zw * 0x10000; m1[14] = (temp >> 0x10); m2[14] = temp & 0xFFFF; @@ -612,21 +611,21 @@ void SkinMatrix_SetRotateAroundVec(MtxF* mf, s16 a, f32 x, f32 y, f32 z) { xz = x * z; mf->xx = (1.0f - xx) * cosA + xx; - mf->xy = (1.0f - cosA) * xy + z * sinA; - mf->xz = (1.0f - cosA) * xz - y * sinA; - mf->xw = 0.0f; + mf->yx = (1.0f - cosA) * xy + z * sinA; + mf->zx = (1.0f - cosA) * xz - y * sinA; + mf->wx = 0.0f; - mf->yx = (1.0f - cosA) * xy - z * sinA; + mf->xy = (1.0f - cosA) * xy - z * sinA; mf->yy = (1.0f - yy) * cosA + yy; - mf->yz = (1.0f - cosA) * yz + x * sinA; - mf->yw = 0.0f; + mf->zy = (1.0f - cosA) * yz + x * sinA; + mf->wy = 0.0f; - mf->zx = (1.0f - cosA) * xz + y * sinA; - mf->zy = (1.0f - cosA) * yz - x * sinA; + mf->xz = (1.0f - cosA) * xz + y * sinA; + mf->yz = (1.0f - cosA) * yz - x * sinA; mf->zz = (1.0f - zz) * cosA + zz; - mf->zw = 0.0f; + mf->wz = 0.0f; - mf->wx = mf->wy = mf->wz = 0.0f; + mf->xw = mf->yw = mf->zw = 0.0f; mf->ww = 1.0f; } @@ -642,27 +641,27 @@ void SkinMatrix_SetXRotation(MtxF* mf, s16 a) { cosA = 1.0f; } - mf->xy = 0.0f; - mf->xz = 0.0f; - mf->xw = 0.0f; - mf->yx = 0.0f; - mf->yw = 0.0f; - mf->zx = 0.0f; - mf->zw = 0.0f; - mf->wx = 0.0f; + + mf->xy = 0.0f; mf->wy = 0.0f; + + mf->xz = 0.0f; mf->wz = 0.0f; + mf->xw = 0.0f; + mf->yw = 0.0f; + mf->zw = 0.0f; + mf->xx = 1.0f; mf->ww = 1.0f; mf->yy = cosA; mf->zz = cosA; - mf->yz = sinA; - mf->zy = -sinA; + mf->zy = sinA; + mf->yz = -sinA; } void SkinMatrix_MulXRotation(MtxF* mf, s16 a) { @@ -675,25 +674,25 @@ void SkinMatrix_MulXRotation(MtxF* mf, s16 a) { sinA = Math_SinS(a); cosA = Math_CosS(a); - ry = mf->yx; - rz = mf->zx; - mf->yx = ry * cosA + rz * sinA; - mf->zx = rz * cosA - ry * sinA; + ry = mf->xy; + rz = mf->xz; + mf->xy = ry * cosA + rz * sinA; + mf->xz = rz * cosA - ry * sinA; ry = mf->yy; - rz = mf->zy; + rz = mf->yz; mf->yy = ry * cosA + rz * sinA; - mf->zy = rz * cosA - ry * sinA; + mf->yz = rz * cosA - ry * sinA; - ry = mf->yz; + ry = mf->zy; rz = mf->zz; - mf->yz = ry * cosA + rz * sinA; + mf->zy = ry * cosA + rz * sinA; mf->zz = rz * cosA - ry * sinA; - ry = mf->yw; - rz = mf->zw; - mf->yw = ry * cosA + rz * sinA; - mf->zw = rz * cosA - ry * sinA; + ry = mf->wy; + rz = mf->wz; + mf->wy = ry * cosA + rz * sinA; + mf->wz = rz * cosA - ry * sinA; } } @@ -709,27 +708,27 @@ void SkinMatrix_SetYRotation(MtxF* mf, s16 a) { cosA = 1.0f; } - mf->xy = 0.0f; - mf->xw = 0.0f; - mf->yx = 0.0f; - mf->yz = 0.0f; - mf->yw = 0.0f; - - mf->zy = 0.0f; - mf->zw = 0.0f; - mf->wx = 0.0f; + + mf->xy = 0.0f; + mf->zy = 0.0f; mf->wy = 0.0f; + + mf->yz = 0.0f; mf->wz = 0.0f; + mf->xw = 0.0f; + mf->yw = 0.0f; + mf->zw = 0.0f; + mf->yy = 1.0f; mf->ww = 1.0f; mf->xx = cosA; mf->zz = cosA; - mf->xz = -sinA; - mf->zx = sinA; + mf->zx = -sinA; + mf->xz = sinA; } void SkinMatrix_MulYRotation(MtxF* mf, s16 a) { @@ -743,24 +742,24 @@ void SkinMatrix_MulYRotation(MtxF* mf, s16 a) { cosA = Math_CosS(a); rx = mf->xx; - rz = mf->zx; + rz = mf->xz; mf->xx = rx * cosA - rz * sinA; - mf->zx = rx * sinA + rz * cosA; + mf->xz = rx * sinA + rz * cosA; - rx = mf->xy; - rz = mf->zy; - mf->xy = rx * cosA - rz * sinA; - mf->zy = rx * sinA + rz * cosA; + rx = mf->yx; + rz = mf->yz; + mf->yx = rx * cosA - rz * sinA; + mf->yz = rx * sinA + rz * cosA; - rx = mf->xz; + rx = mf->zx; rz = mf->zz; - mf->xz = rx * cosA - rz * sinA; + mf->zx = rx * cosA - rz * sinA; mf->zz = rx * sinA + rz * cosA; - rx = mf->xw; - rz = mf->zw; - mf->xw = rx * cosA - rz * sinA; - mf->zw = rx * sinA + rz * cosA; + rx = mf->wx; + rz = mf->wz; + mf->wx = rx * cosA - rz * sinA; + mf->wz = rx * sinA + rz * cosA; } } @@ -776,25 +775,25 @@ void SkinMatrix_SetZRotation(MtxF* mf, s16 a) { cosA = 1.0f; } - mf->xz = 0.0f; - mf->xw = 0.0f; - - mf->yz = 0.0f; - mf->yw = 0.0f; - mf->zx = 0.0f; - mf->zy = 0.0f; - mf->zw = 0.0f; - mf->wx = 0.0f; + + mf->zy = 0.0f; mf->wy = 0.0f; + + mf->xz = 0.0f; + mf->yz = 0.0f; mf->wz = 0.0f; + mf->xw = 0.0f; + mf->yw = 0.0f; + mf->zw = 0.0f; + mf->zz = 1.0f; mf->ww = 1.0f; mf->xx = cosA; mf->yy = cosA; - mf->xy = sinA; - mf->yx = -sinA; + mf->yx = sinA; + mf->xy = -sinA; } diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 58812abc9..3e5443bc6 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -53,7 +53,7 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** Vec3f pos; Vec3s rot; - Matrix_StatePush(); + Matrix_Push(); limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); limbIndex++; rot = jointTable[limbIndex]; @@ -63,8 +63,8 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** newDList = limbDList = limb->dList; if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); - Matrix_StatePush(); + Matrix_TranslateRotateZYX(&pos, &rot); + Matrix_Push(); transformLimbDraw(globalCtx, limbIndex, actor, &gfx); @@ -77,7 +77,7 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** Matrix_ToMtx(*mtx); (*mtx)++; } - Matrix_StatePop(); + Matrix_Pop(); } if (postLimbDraw != NULL) { postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, actor, &gfx); @@ -86,7 +86,7 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** gfx = SubS_DrawTransformFlexLimb(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, transformLimbDraw, actor, mtx, gfx); } - Matrix_StatePop(); + Matrix_Pop(); if (limb->sibling != LIMB_DONE) { gfx = SubS_DrawTransformFlexLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, transformLimbDraw, actor, mtx, gfx); @@ -119,7 +119,7 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo } gSPSegment(gfx++, 0x0D, mtx); - Matrix_StatePush(); + Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); pos.x = jointTable->x; pos.y = jointTable->y; @@ -129,8 +129,8 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo limbDList = rootLimb->dList; if (overrideLimbDraw == NULL || !overrideLimbDraw(globalCtx, 1, &newDlist, &pos, &rot, actor, &gfx)) { - Matrix_JointPosition(&pos, &rot); - Matrix_StatePush(); + Matrix_TranslateRotateZYX(&pos, &rot); + Matrix_Push(); transformLimbDraw(globalCtx, 1, actor, &gfx); @@ -143,7 +143,7 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo Matrix_ToMtx(mtx); mtx++; } - Matrix_StatePop(); + Matrix_Pop(); } if (postLimbDraw != NULL) { @@ -154,7 +154,7 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo gfx = SubS_DrawTransformFlexLimb(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, transformLimbDraw, actor, &mtx, gfx); } - Matrix_StatePop(); + Matrix_Pop(); return gfx; } @@ -187,9 +187,9 @@ s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRo Vec3s newRot; MtxF curState; - Matrix_MultiplyVector3fByState(&zeroVec, &newPos); - Matrix_CopyCurrentState(&curState); - func_8018219C(&curState, &newRot, MTXMODE_NEW); + Matrix_MultVec3f(&zeroVec, &newPos); + Matrix_Get(&curState); + Matrix_MtxFToYXZRot(&curState, &newRot, MTXMODE_NEW); *pos = newPos; if (!stepRot && !overrideRot) { @@ -538,7 +538,7 @@ void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween pos.z = bodyPartPos->z - worldPos->z; } - Matrix_MultiplyVector3fByState(&pos, &startVec); + Matrix_MultVec3f(&pos, &startVec); startCol = 64.0f + startVec.x; startRow = 64.0f - startVec.z; SubS_FillShadowTex(startCol >> 1, startRow >> 1, tex, sizes[i]); @@ -554,7 +554,7 @@ void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex) { func_8012C28C(gfxCtx); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, 100); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); - Matrix_InsertTranslation(actor->world.pos.x, 0.0f, actor->world.pos.z, MTXMODE_NEW); + Matrix_Translate(actor->world.pos.x, 0.0f, actor->world.pos.z, MTXMODE_NEW); Matrix_Scale(0.6f, 1.0f, 0.6f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gShadowDL); diff --git a/src/code/z_view.c b/src/code/z_view.c index d11a18201..915c196b7 100644 --- a/src/code/z_view.c +++ b/src/code/z_view.c @@ -262,15 +262,15 @@ s32 View_StepDistortion(View* view, Mtx* projectionMtx) { F32_LERPIMP(view->curDistortionScale.z, view->distortionScale.z, view->distortionSpeed); } - Matrix_FromRSPMatrix(projectionMtx, &projectionMtxF); - Matrix_SetCurrentState(&projectionMtxF); - Matrix_RotateStateAroundXAxis(view->curDistortionDirRot.x); - Matrix_InsertYRotation_f(view->curDistortionDirRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_f(view->curDistortionDirRot.z, MTXMODE_APPLY); + Matrix_MtxToMtxF(projectionMtx, &projectionMtxF); + Matrix_Put(&projectionMtxF); + Matrix_RotateXFApply(view->curDistortionDirRot.x); + Matrix_RotateYF(view->curDistortionDirRot.y, MTXMODE_APPLY); + Matrix_RotateZF(view->curDistortionDirRot.z, MTXMODE_APPLY); Matrix_Scale(view->curDistortionScale.x, view->curDistortionScale.y, view->curDistortionScale.z, MTXMODE_APPLY); - Matrix_InsertZRotation_f(-view->curDistortionDirRot.z, MTXMODE_APPLY); - Matrix_InsertYRotation_f(-view->curDistortionDirRot.y, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(-view->curDistortionDirRot.x); + Matrix_RotateZF(-view->curDistortionDirRot.z, MTXMODE_APPLY); + Matrix_RotateYF(-view->curDistortionDirRot.y, MTXMODE_APPLY); + Matrix_RotateXFApply(-view->curDistortionDirRot.x); Matrix_ToMtx(projectionMtx); return true; diff --git a/src/code/z_vr_box_draw.c b/src/code/z_vr_box_draw.c index d7f99eed9..326fcb3e2 100644 --- a/src/code/z_vr_box_draw.c +++ b/src/code/z_vr_box_draw.c @@ -3,11 +3,11 @@ Mtx* sSkyboxDrawMatrix; Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z) { - Matrix_InsertTranslation(x, y, z, MTXMODE_NEW); + Matrix_Translate(x, y, z, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(skyboxCtx->rotX); - Matrix_InsertYRotation_f(skyboxCtx->rotY, MTXMODE_APPLY); - Matrix_InsertZRotation_f(skyboxCtx->rotZ, MTXMODE_APPLY); + Matrix_RotateXFApply(skyboxCtx->rotX); + Matrix_RotateYF(skyboxCtx->rotY, MTXMODE_APPLY); + Matrix_RotateZF(skyboxCtx->rotZ, MTXMODE_APPLY); return Matrix_ToMtx(sSkyboxDrawMatrix); } @@ -30,11 +30,11 @@ void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyb sSkyboxDrawMatrix = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); - Matrix_InsertTranslation(x, y, z, MTXMODE_NEW); + Matrix_Translate(x, y, z, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(skyboxCtx->rotX); - Matrix_InsertYRotation_f(skyboxCtx->rotY, MTXMODE_APPLY); - Matrix_InsertZRotation_f(skyboxCtx->rotZ, MTXMODE_APPLY); + Matrix_RotateXFApply(skyboxCtx->rotX); + Matrix_RotateYF(skyboxCtx->rotY, MTXMODE_APPLY); + Matrix_RotateZF(skyboxCtx->rotZ, MTXMODE_APPLY); Matrix_ToMtx(sSkyboxDrawMatrix); gSPMatrix(POLY_OPA_DISP++, sSkyboxDrawMatrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/libultra/gu/cosf.c b/src/libultra/gu/cosf.c index b71ba7234..65330e9a6 100644 --- a/src/libultra/gu/cosf.c +++ b/src/libultra/gu/cosf.c @@ -1,22 +1,25 @@ #include "libc/math.h" #include "macros.h" -// A slightly tweaked form of the coefficients of the Maclaurin series of sine up to x^9 -// [https://mathworld.wolfram.com/MaclaurinSeries.html]. -// The commented versions do not match. +#pragma weak cosf = __cosf + +// Coefficients of a degree 9 polynomial approximation of sine. It is not the Maclaurin polynamial, but some as-yet +// undetermined more uniform approximation. static const du P[] = { - { 1.0 }, // 1 - { -0.16666659550427756 }, // -1/3! = 1/6 - { 0.008333066246082155 }, // 1/5! = 1/120 - { -0.0001980960290193795 }, // -1/7! = -1/5040 - { 0.000002605780637968037 }, // 1/9! = 1/362880 + { 1.0 }, + { -0.16666659550427756 }, + { 0.008333066246082155 }, + { -0.0001980960290193795 }, + { 0.000002605780637968037 }, }; static const du rpi = { 1 / 3.14159265358979323846 }; // 1/M_PI, "reciprocal of pi" +// pihi + pilo is the closest double to pi, this representation allows more precise calculations since pi itself is not +// an exact float static const du pihi = { 3.1415926218032837 }; -static const du pilo = { 3.178650954705639E-8 }; // pihi + pilo is the closest double to pi +static const du pilo = { 3.178650954705639E-8 }; static const fu zero = { 0x00000000 }; @@ -28,7 +31,7 @@ f32 __cosf(f32 x) { f32 absx; f64 dx; // x promoted to double f64 xSq; // square of dx - f64 polyApprox; // Most of Maclaurin polynomial of sin(x) of degree 9 + f64 polyApprox; // Most of the polynomial approximation to sin(x) f64 dn; // n promoted to double s32 n; // number of multiples of pi away from the first half-period f64 result; diff --git a/src/libultra/gu/perspective.c b/src/libultra/gu/perspective.c index 2af2d6ac5..d3dab2ef4 100644 --- a/src/libultra/gu/perspective.c +++ b/src/libultra/gu/perspective.c @@ -7,7 +7,7 @@ void guPerspectiveF(float mf[4][4], u16* perspNorm, float fovy, float aspect, fl guMtxIdentF(mf); fovy *= 3.1415926 / 180.0; - cot = __cosf(fovy / 2) / __sinf(fovy / 2); + cot = cosf(fovy / 2) / sinf(fovy / 2); mf[0][0] = cot / aspect; mf[1][1] = cot; diff --git a/src/libultra/gu/position.c b/src/libultra/gu/position.c index 589d4f4a3..95bd65fe3 100644 --- a/src/libultra/gu/position.c +++ b/src/libultra/gu/position.c @@ -13,12 +13,12 @@ void guPositionF(f32 mf[4][4], f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f3 pitch *= D_80134D00; yaw *= D_80134D00; - sinr = __sinf(rot); - cosr = __cosf(rot); - sinp = __sinf(pitch); - cosp = __cosf(pitch); - sinh = __sinf(yaw); - cosh = __cosf(yaw); + sinr = sinf(rot); + cosr = cosf(rot); + sinp = sinf(pitch); + cosp = cosf(pitch); + sinh = sinf(yaw); + cosh = cosf(yaw); mf[0][0] = (cosp * cosh) * scale; mf[0][1] = (cosp * sinh) * scale; diff --git a/src/libultra/gu/rotate.c b/src/libultra/gu/rotate.c index c79c733bb..11d00ff73 100644 --- a/src/libultra/gu/rotate.c +++ b/src/libultra/gu/rotate.c @@ -16,8 +16,8 @@ void guRotateF(float m[4][4], float a, float x, float y, float z) { a = a * D_80097F90; - sine = __sinf(a); - cosine = __cosf(a); + sine = sinf(a); + cosine = cosf(a); ab = x * y * (1 - cosine); bc = y * z * (1 - cosine); diff --git a/src/libultra/gu/sinf.c b/src/libultra/gu/sinf.c index 746d141a4..963bc2022 100644 --- a/src/libultra/gu/sinf.c +++ b/src/libultra/gu/sinf.c @@ -1,22 +1,25 @@ #include "libc/math.h" #include "macros.h" -// A slightly tweaked form of the coefficients of the Maclaurin series of sine up to x^9 -// [https://mathworld.wolfram.com/MaclaurinSeries.html]. -// The commented versions do not match. +#pragma weak sinf = __sinf + +// Coefficients of a degree 9 polynomial approximation of sine. It is not the Maclaurin polynamial, but some as-yet +// undetermined more uniform approximation. static const du P[] = { - { 1.0 }, // 1 - { -0.16666659550427756 }, // -1/3! = 1/6 - { 0.008333066246082155 }, // 1/5! = 1/120 - { -0.0001980960290193795 }, // -1/7! = -1/5040 - { 0.000002605780637968037 }, // 1/9! = 1/362880 + { 1.0 }, + { -0.16666659550427756 }, + { 0.008333066246082155 }, + { -0.0001980960290193795 }, + { 0.000002605780637968037 }, }; static const du rpi = { 1 / 3.14159265358979323846 }; // 1/M_PI, "reciprocal of pi" +// pihi + pilo is the closest double to pi, this representation allows more precise calculations since pi itself is not +// an exact float static const du pihi = { 3.1415926218032837 }; -static const du pilo = { 3.178650954705639E-8 }; // pihi + pilo is the closest double to pi +static const du pilo = { 3.178650954705639E-8 }; static const fu zero = { 0x00000000 }; @@ -26,7 +29,7 @@ static const fu zero = { 0x00000000 }; f32 __sinf(f32 x) { f64 dx; // x promoted to double f64 xSq; // square of dx - f64 polyApprox; // Most of Maclaurin polynomial of sin(x) of degree 9 + f64 polyApprox; // Most of the polynomial approximation to sin(x) f64 dn; // n promoted to double s32 n; // number of multiples of pi away from the first half-period f64 result; diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index b0a61382c..16aa93bd9 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -309,14 +309,14 @@ void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); if ((ArmsHook_Shoot != this->actionFunc) || (this->timer <= 0)) { - Matrix_MultiplyVector3fByState(&D_808C1C10, &this->unk1E0); - Matrix_MultiplyVector3fByState(&D_808C1C28, &sp5C); - Matrix_MultiplyVector3fByState(&D_808C1C34, &sp50); + Matrix_MultVec3f(&D_808C1C10, &this->unk1E0); + Matrix_MultVec3f(&D_808C1C28, &sp5C); + Matrix_MultVec3f(&D_808C1C34, &sp50); this->unk1C4.active = false; } else { - Matrix_MultiplyVector3fByState(&D_808C1C1C, &this->unk1E0); - Matrix_MultiplyVector3fByState(&D_808C1C40, &sp5C); - Matrix_MultiplyVector3fByState(&D_808C1C4C, &sp50); + Matrix_MultVec3f(&D_808C1C1C, &this->unk1E0); + Matrix_MultVec3f(&D_808C1C40, &sp5C); + Matrix_MultVec3f(&D_808C1C4C, &sp50); } func_80126440(globalCtx, &this->collider, &this->unk1C4, &sp5C, &sp50); func_8012C28C(globalCtx->state.gfxCtx); @@ -324,13 +324,12 @@ void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_link_child_DL_01D960); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); Math_Vec3f_Diff(&player->rightHandWorld.pos, &this->actor.world.pos, &sp68); sp48 = SQXZ(sp68); sp4C = sqrtf(SQXZ(sp68)); - Matrix_RotateY(Math_Atan2S(sp68.x, sp68.z), MTXMODE_APPLY); - Matrix_InsertXRotation_s(Math_Atan2S(-sp68.y, sp4C), MTXMODE_APPLY); + Matrix_RotateYS(Math_Atan2S(sp68.x, sp68.z), MTXMODE_APPLY); + Matrix_RotateXS(Math_Atan2S(-sp68.y, sp4C), MTXMODE_APPLY); f0 = sqrtf(SQ(sp68.y) + sp48); Matrix_Scale(0.015f, 0.015f, f0 * 0.01f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c index 0b9bedbb8..6a2590259 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -225,15 +225,15 @@ void FireArrow_SetQuadVerticies(ArrowFire* this) { Vec3f sp2C; Vec3f sp20; - Matrix_MultiplyVector3fByState(&D_80922284, &sp44); - Matrix_MultiplyVector3fByState(&D_80922290, &sp38); - Matrix_MultiplyVector3fByState(&D_8092229C, &sp2C); - Matrix_MultiplyVector3fByState(&D_809222A8, &sp20); + Matrix_MultVec3f(&D_80922284, &sp44); + Matrix_MultVec3f(&D_80922290, &sp38); + Matrix_MultVec3f(&D_8092229C, &sp2C); + Matrix_MultVec3f(&D_809222A8, &sp20); Collider_SetQuadVertices(&this->collider1, &sp44, &sp38, &sp2C, &sp20); - Matrix_MultiplyVector3fByState(&D_809222B4, &sp44); - Matrix_MultiplyVector3fByState(&D_809222C0, &sp38); - Matrix_MultiplyVector3fByState(&D_809222CC, &sp2C); - Matrix_MultiplyVector3fByState(&D_809222D8, &sp20); + Matrix_MultVec3f(&D_809222B4, &sp44); + Matrix_MultVec3f(&D_809222C0, &sp38); + Matrix_MultVec3f(&D_809222CC, &sp2C); + Matrix_MultVec3f(&D_809222D8, &sp20); Collider_SetQuadVertices(&this->collider2, &sp44, &sp38, &sp2C, &sp20); } @@ -249,10 +249,10 @@ void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx) { Actor* transform = (arrow->unk_261 & 2) ? &this->actor : &arrow->actor; OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); - Matrix_RotateY(transform->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(transform->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(transform->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(transform->shape.rot.z, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); if (this->screenFillIntensity > 0.0f) { @@ -271,16 +271,16 @@ void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, this->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); - Matrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY); + Matrix_RotateZYX(0x4000, 0, 0, MTXMODE_APPLY); if (this->timer != 0) { - Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); } else { - Matrix_InsertTranslation(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); } Matrix_Scale(this->radius * 0.2f, this->height * 4.0f, this->radius * 0.2f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c index 8a402dfbe..6ae539178 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -196,10 +196,10 @@ void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); - Matrix_RotateY(transform->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(transform->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(transform->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(transform->shape.rot.z, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); // Draw blue effect over the screen when arrow hits @@ -217,14 +217,14 @@ void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C2DC(globalCtx->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 170, 255, 255, (s32)(this->alpha * 0.5f) & 0xFF); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 128); - Matrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY); + Matrix_RotateZYX(0x4000, 0, 0, MTXMODE_APPLY); if (this->timer != 0) { - Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); } else { - Matrix_InsertTranslation(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); } Matrix_Scale(this->radius * 0.2f, this->height * 3.0f, this->radius * 0.2f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gIceArrowMaterialDL); gSPDisplayList(POLY_XLU_DISP++, diff --git a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c index ac8eb1ae9..1b25b8fbb 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c @@ -190,10 +190,10 @@ void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); - Matrix_RotateY(transform->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(transform->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(transform->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(transform->shape.rot.z, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); if (this->screenFillIntensity > 0.0f) { POLY_XLU_DISP = func_8012BFC4(POLY_XLU_DISP); @@ -210,14 +210,14 @@ void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, this->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 128); - Matrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY); + Matrix_RotateZYX(0x4000, 0, 0, MTXMODE_APPLY); if (this->timer != 0) { - Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); } else { - Matrix_InsertTranslation(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); } Matrix_Scale(this->radius * 0.2f, this->height * 4.0f, this->radius * 0.2f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gLightArrowMaterialDL); diff --git a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c index 09876c350..6ac390ce5 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c @@ -74,15 +74,15 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { s16 rotZ = this->dyna.actor.shape.rot.z & 0x1FFF; if (flag40 && (rotZ < 0x1B58) && (rotZ >= 0x1388)) { - Matrix_RotateY(this->dyna.actor.home.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.home.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.home.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->dyna.actor.home.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.home.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.home.rot.z, MTXMODE_APPLY); for (i = 0; i < 4; i++) { if ((u32)Rand_Next() >= 0x40000000) { splashOffset.x = sExitSplashOffsets[i].x - (Rand_ZeroOne() * 30.0f); splashOffset.y = sExitSplashOffsets[i].y; splashOffset.z = sExitSplashOffsets[i].z; - Matrix_MultiplyVector3fByState(&splashOffset, &splashSpawnPos); + Matrix_MultVec3f(&splashOffset, &splashSpawnPos); splashSpawnPos.x += this->dyna.actor.world.pos.x + ((Rand_ZeroOne() * 20.0f) - 10.0f); splashSpawnPos.y += this->dyna.actor.world.pos.y; splashSpawnPos.z += this->dyna.actor.world.pos.z + ((Rand_ZeroOne() * 20.0f) - 10.0f); @@ -92,15 +92,15 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { } if ((rotZ < 0x1F4) && (rotZ >= 0)) { if (flag40) { - Matrix_RotateY(this->dyna.actor.home.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.home.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.home.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->dyna.actor.home.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.home.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.home.rot.z, MTXMODE_APPLY); for (i = 0; i < 3; i++) { for (j = 0; j < 2; j++) { splashOffset.x = sEnterSplashOffsets[i].x + (Rand_ZeroOne() * 10.0f); splashOffset.y = sEnterSplashOffsets[i].y; splashOffset.z = sEnterSplashOffsets[i].z; - Matrix_MultiplyVector3fByState(&splashOffset, &splashSpawnPos); + Matrix_MultVec3f(&splashOffset, &splashSpawnPos); splashSpawnPos.x += this->dyna.actor.world.pos.x + ((Rand_ZeroOne() * 20.0f) - 10.0f); splashSpawnPos.y += this->dyna.actor.world.pos.y; splashSpawnPos.z += this->dyna.actor.world.pos.z + ((Rand_ZeroOne() * 20.0f) - 10.0f); diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c index 07693307b..0c5b92496 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c @@ -110,22 +110,22 @@ void func_80B823B0(BgDblueBalance* this) { s32 pad; Vec3f sp28; - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); sp28.x = -138.28f; sp28.y = 0.0f; sp28.z = 0.0f; if (this->unk_15C != NULL) { - Matrix_MultiplyVector3fByState(&sp28, &this->unk_15C->dyna.actor.world.pos); + Matrix_MultVec3f(&sp28, &this->unk_15C->dyna.actor.world.pos); } sp28.x = 138.28f; if (this->unk_160 != NULL) { - Matrix_MultiplyVector3fByState(&sp28, &this->unk_160->dyna.actor.world.pos); + Matrix_MultVec3f(&sp28, &this->unk_160->dyna.actor.world.pos); } } @@ -136,16 +136,16 @@ s32 func_80B82454(BgDblueBalance* this, GlobalContext* globalCtx) { Vec3f sp48; Vec3f sp3C; - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); sp48.x = -138.28f; sp48.y = 0.0f; sp48.z = 0.0f; - Matrix_MultiplyVector3fByState(&sp48, &sp3C); + Matrix_MultVec3f(&sp48, &sp3C); this->unk_15C = (BgDblueBalance*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_DBLUE_BALANCE, sp3C.x, sp3C.y, sp3C.z, 0, this->dyna.actor.shape.rot.y, 0, 0x100); @@ -157,7 +157,7 @@ s32 func_80B82454(BgDblueBalance* this, GlobalContext* globalCtx) { } sp48.x = 138.28f; - Matrix_MultiplyVector3fByState(&sp48, &sp3C); + Matrix_MultVec3f(&sp48, &sp3C); this->unk_160 = (BgDblueBalance*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_DBLUE_BALANCE, sp3C.x, sp3C.y, sp3C.z, 0, this->dyna.actor.shape.rot.y, 0, 0x200); @@ -212,20 +212,20 @@ void func_80B8264C(BgDblueBalance* this) { } } - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); for (i = 0, phi_s0 = &this->unk_188[0], phi_s2 = 0; i < ARRAY_COUNT(this->unk_188); i++, phi_s2 += 0x2000, phi_s0++) { phi_s0->unk_0C = this->dyna.actor.shape.rot.x + phi_s2; - Matrix_StatePush(); - Matrix_InsertXRotation_s(phi_s0->unk_0C, MTXMODE_NEW); - Matrix_InsertTranslation(-545.0f, 0.0f, 270.0f, MTXMODE_APPLY); - Matrix_GetStateTranslation(&sp78); - Matrix_StatePop(); - Matrix_MultiplyVector3fByState(&sp78, &phi_s0->unk_00); + Matrix_Push(); + Matrix_RotateXS(phi_s0->unk_0C, MTXMODE_NEW); + Matrix_Translate(-545.0f, 0.0f, 270.0f, MTXMODE_APPLY); + Matrix_MultZero(&sp78); + Matrix_Pop(); + Matrix_MultVec3f(&sp78, &phi_s0->unk_00); temp_f0 = (sp78.z - 135.0f); if (sp78.z > 135.0f) { @@ -486,10 +486,10 @@ void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx) { if (this->unk_182) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_WATER_BOUND); sp5C = this->unk_15C; - Matrix_StatePush(); - Matrix_RotateY(BINANG_SUB(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(45.0f, &sp60); - Matrix_StatePop(); + Matrix_Push(); + Matrix_RotateYS(BINANG_SUB(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); + Matrix_MultVecZ(45.0f, &sp60); + Matrix_Pop(); sp50.x = sp5C->dyna.actor.world.pos.x + sp60.x; sp50.y = this->unk_228; @@ -511,10 +511,10 @@ void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx) { if (this->unk_182) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_WATER_BOUND); sp3C = this->unk_160; - Matrix_StatePush(); - Matrix_RotateY(BINANG_ADD(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(30.0f, &sp40); - Matrix_StatePop(); + Matrix_Push(); + Matrix_RotateYS(BINANG_ADD(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); + Matrix_MultVecZ(30.0f, &sp40); + Matrix_Pop(); sp30.x = sp3C->dyna.actor.world.pos.x + sp40.x; sp30.y = this->unk_228; @@ -653,9 +653,9 @@ void BgDblueBalance_Draw(Actor* thisx, GlobalContext* globalCtx) { if (!(BGDBLUEBALANCE_GET_300(&this->dyna.actor)) && (this->unk_160 != NULL)) { AnimatedMat_Draw(globalCtx, D_80B83C74); sp38 = this->unk_160; - Matrix_SetStateRotationAndTranslation(sp38->dyna.actor.world.pos.x, sp38->dyna.actor.world.pos.y, - sp38->dyna.actor.world.pos.z, &sp38->dyna.actor.shape.rot); - Matrix_InsertTranslation(30.0f, 15.0f, 0.0f, MTXMODE_APPLY); + Matrix_SetTranslateRotateYXZ(sp38->dyna.actor.world.pos.x, sp38->dyna.actor.world.pos.y, + sp38->dyna.actor.world.pos.z, &sp38->dyna.actor.shape.rot); + Matrix_Translate(30.0f, 15.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(sp38->dyna.actor.scale.x, sp38->dyna.actor.scale.y, sp38->dyna.actor.scale.z, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -708,9 +708,9 @@ void func_80B83758(Actor* thisx, GlobalContext* globalCtx) { for (i = 0, ptr = &this->unk_188[0]; i < ARRAY_COUNT(this->unk_188); i++, ptr++) { if (ptr->unk_0E != 0) { - Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(ptr->unk_0C, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(ptr->unk_0C, MTXMODE_APPLY); Matrix_Scale(ptr->unk_10, ptr->unk_10, ptr->unk_10, MTXMODE_APPLY); temp = ptr->unk_0E * (f32)this->unk_183 * 0.003921569f; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c index 3a12f286d..857eb43cf 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.c @@ -259,9 +259,9 @@ void BgDblueMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_178 = func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC); this->unk_1CC = D_80A2B96C[this->unk_178]; this->unk_1CE = this->unk_1CC; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledX(2240.0f, &this->unk_190); - Matrix_GetStateTranslationAndScaledX(-10.0f, &this->unk_19C); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVecX(2240.0f, &this->unk_190); + Matrix_MultVecX(-10.0f, &this->unk_19C); Math_Vec3f_Sum(&this->unk_190, &this->dyna.actor.world.pos, &this->unk_190); Math_Vec3f_Sum(&this->unk_19C, &this->dyna.actor.world.pos, &this->unk_19C); D_80A2BBF0 = this; @@ -591,10 +591,10 @@ void func_80A2ABD0(BgDblueMovebg* this, GlobalContext* globalCtx) { } for (j = 0; j < ARRAY_COUNT(this->unk_1D8[0]); j++) { - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x + (j * 0x2000), MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&D_80A2B988, &spAC); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.shape.rot.x + (j * 0x2000), MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultVec3f(&D_80A2B988, &spAC); Math_Vec3f_Sum(&this->dyna.actor.world.pos, &spAC, &spAC); Math_Vec3f_Copy(&this->unk_238[i][j], &spAC); temp_f20 = spAC.y - this->unk_2F8[i]->world.pos.y; @@ -770,7 +770,7 @@ void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { Gfx* gfx; Gfx* gfx2; - Matrix_StatePush(); + Matrix_Push(); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -808,7 +808,7 @@ void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { } } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -817,11 +817,11 @@ void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); gfx = func_8012C2B4(POLY_XLU_DISP); for (i = 0; i < ARRAY_COUNT(this->unk_1D8[0]); i++) { @@ -834,11 +834,11 @@ void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { (s32)(((globalCtx->gameplayFrames % 128) * -9.0f) / this->unk_1F8[j][i]), 0x20, 0x20, 1, 0, 0, 0x20, 0x20)); } - Matrix_StatePush(); - Matrix_InsertXRotation_s(i * 0x2000, MTXMODE_APPLY); - Matrix_InsertTranslation(1785.0f, 0.0f, 270.0f, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateXS(i * 0x2000, MTXMODE_APPLY); + Matrix_Translate(1785.0f, 0.0f, 270.0f, MTXMODE_APPLY); if (j != 0) { - Matrix_InsertZRotation_s(-0x8000, MTXMODE_APPLY); + Matrix_RotateZS(-0x8000, MTXMODE_APPLY); } Matrix_Scale(this->unk_1F8[j][i] * this->dyna.actor.scale.x, this->unk_1F8[j][i] * this->dyna.actor.scale.y, @@ -849,7 +849,7 @@ void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { gDPSetEnvColor(gfx++, 255, 255, 255, this->unk_1D8[j][i]); gSPDisplayList(gfx++, object_dblue_object_DL_00CD10); - Matrix_StatePop(); + Matrix_Pop(); } } } diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c index cd3b8a9d6..fcec4ebb3 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c @@ -314,10 +314,10 @@ void func_80B84610(BgDblueWaterfall* this, GlobalContext* globalCtx) { } } - Matrix_StatePush(); - Matrix_RotateY(BINANG_ADD(this->actor.yawTowardsPlayer, 0x4000), MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(this->unk_1A8, &sp34); - Matrix_StatePop(); + Matrix_Push(); + Matrix_RotateYS(BINANG_ADD(this->actor.yawTowardsPlayer, 0x4000), MTXMODE_NEW); + Matrix_MultVecZ(this->unk_1A8, &sp34); + Matrix_Pop(); player->actor.world.pos.x += sp34.x; player->actor.world.pos.z += sp34.z; diff --git a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c index 7cb4aab5e..6985878fe 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c +++ b/src/overlays/actors/ovl_Bg_Haka_Tomb/z_bg_haka_tomb.c @@ -118,10 +118,10 @@ void BgHakaTomb_Update(Actor* thisx, GlobalContext* globalCtx) { Vec3f vec; this->actionFunc(this, globalCtx); - Matrix_RotateY(this->dyna.actor.world.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.world.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.world.rot.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&D_80BD68A4, &vec); + Matrix_RotateYS(this->dyna.actor.world.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.world.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.world.rot.z, MTXMODE_APPLY); + Matrix_MultVec3f(&D_80BD68A4, &vec); Math_Vec3f_Sum(&this->dyna.actor.world.pos, &vec, &this->dyna.actor.focus.pos); } diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c index bf3e44154..20d68e7a4 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c @@ -133,7 +133,7 @@ void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { s32 i; s32 j; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); for (i = 0; i < 6; i++) { temp = (i + 1) * (80.0f / 3.0f); @@ -146,8 +146,8 @@ void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { spCC.y = (Rand_ZeroOne() * 7.0f) - 2.0f; spCC.z = spD8.z * 0.3f; - Matrix_MultiplyVector3fByState(&spD8, &spF0); - Matrix_MultiplyVector3fByState(&spCC, &spE4); + Matrix_MultVec3f(&spD8, &spF0); + Matrix_MultVec3f(&spCC, &spE4); spF0.x += this->dyna.actor.world.pos.x; spF0.y += this->dyna.actor.world.pos.y; @@ -245,7 +245,7 @@ void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx) { spA8.y = 0.0f; spB4.y = 0.3f; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); for (i = 0, phi_s1 = 0; i < 21; i++, phi_s1 += 0x618) { temp_f20 = Math_SinS(phi_s1); @@ -261,9 +261,9 @@ void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx) { spB4.x = spA8.x * -0.09f; spB4.z = spA8.z * -0.09f; - Matrix_MultiplyVector3fByState(&sp9C, &spC0); - Matrix_MultiplyVector3fByState(&spA8, &spCC); - Matrix_MultiplyVector3fByState(&spB4, &spD8); + Matrix_MultVec3f(&sp9C, &spC0); + Matrix_MultVec3f(&spA8, &spCC); + Matrix_MultVec3f(&spB4, &spD8); spC0.x += this->dyna.actor.world.pos.x; spC0.y += this->dyna.actor.world.pos.y; diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index 1ad88f3f8..a7f20b7b4 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -230,7 +230,7 @@ BgHakuginPostUnkStruct1* func_80A9B32C(BgHakuginPostUnkStruct* unkStruct, BgHaku } void func_80A9B384(Vec3f* arg0) { - MtxF* matrix = Matrix_GetCurrentState(); + MtxF* matrix = Matrix_GetCurrent(); matrix->mf[3][0] = arg0->x; matrix->mf[3][1] = arg0->y; @@ -1010,8 +1010,8 @@ void func_80A9D61C(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); for (i = 0; i < D_80A9E028.count; i++) { @@ -1032,8 +1032,8 @@ void func_80A9D61C(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(D_80A9E028.unk_02A4); i++) { unkStruct2 = &D_80A9E028.unk_02A4[i]; if (unkStruct2->unk_2C > 0) { - Matrix_SetStateRotationAndTranslation(unkStruct2->unk_04.x, unkStruct2->unk_04.y, unkStruct2->unk_04.z, - &unkStruct2->unk_20); + Matrix_SetTranslateRotateYXZ(unkStruct2->unk_04.x, unkStruct2->unk_04.y, unkStruct2->unk_04.z, + &unkStruct2->unk_20); Matrix_Scale(unkStruct2->unk_00, unkStruct2->unk_00, unkStruct2->unk_00, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c index f69302278..b7ebb4f40 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.c @@ -111,7 +111,7 @@ s32 func_80B7EB94(BgIkanaBlock* this, GlobalContext* globalCtx) { sp70.y = this->dyna.actor.world.pos.y + this->unk_170 + 2.0f; sp70.z = this->dyna.actor.world.pos.z; - Matrix_RotateY(phi_a0, MTXMODE_NEW); + Matrix_RotateYS(phi_a0, MTXMODE_NEW); if (sp4C) { phi_f12 = 89.0f; @@ -119,7 +119,7 @@ s32 func_80B7EB94(BgIkanaBlock* this, GlobalContext* globalCtx) { phi_f12 = 119.0f; } - Matrix_GetStateTranslationAndScaledZ(phi_f12, &sp64); + Matrix_MultVecZ(phi_f12, &sp64); sp64.x += this->dyna.actor.world.pos.x; sp64.y += this->dyna.actor.world.pos.y + this->unk_170 + 2.0f; @@ -137,10 +137,10 @@ void func_80B7ED54(BgIkanaBlock* this) { s32 pad; Vec3f sp18; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(30.0f, &sp18); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultVecY(30.0f, &sp18); this->unk_170 = sp18.y - 30.0f; } diff --git a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c index a5176bc64..bc08c9451 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c @@ -109,8 +109,8 @@ void func_80BD4720(BgIkanaBombwall* this, GlobalContext* globalCtx) { s16 temp; s16 phi_t0; - Matrix_StatePush(); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); temp_fs0 = 0.0f; phi_fs1 = 0.0f; @@ -130,8 +130,8 @@ void func_80BD4720(BgIkanaBombwall* this, GlobalContext* globalCtx) { spBC.y = (Rand_ZeroOne() * 7.0f) - 2.0f; spBC.z = (Rand_ZeroOne() * 4.0f) - 2.0f; - Matrix_MultiplyVector3fByState(&spC8, &spE0); - Matrix_MultiplyVector3fByState(&spBC, &spD4); + Matrix_MultVec3f(&spC8, &spE0); + Matrix_MultVec3f(&spBC, &spD4); spE0.x += this->dyna.actor.world.pos.x; spE0.y += this->dyna.actor.world.pos.y; @@ -161,7 +161,7 @@ void func_80BD4720(BgIkanaBombwall* this, GlobalContext* globalCtx) { -1, OBJECT_IKANA_OBJ, object_ikana_obj_DL_000288); } - Matrix_StatePop(); + Matrix_Pop(); } #else void func_80BD4720(BgIkanaBombwall* this, GlobalContext* globalCtx); diff --git a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c index 944ab5828..d395fd6ee 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c @@ -140,8 +140,8 @@ CollisionHeader* D_80B82218[] = { &object_ikana_obj_Colheader_006368, &object_ik void func_80B802E0(BgIkanaRotaryroom* this) { s32 pad; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); @@ -164,21 +164,21 @@ void func_80B80440(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { s32 pad; Vec3f sp50; - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); if (Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor))) { - Matrix_InsertTranslation(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); + Matrix_Translate(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); } else { - Matrix_InsertTranslation(D_80B8216C.x, D_80B8216C.y, D_80B8216C.z, MTXMODE_APPLY); + Matrix_Translate(D_80B8216C.x, D_80B8216C.y, D_80B8216C.z, MTXMODE_APPLY); } - Matrix_GetStateTranslation(&sp50); + Matrix_MultZero(&sp50); func_80B80358(&sp50); this->unk_204.unk_00 = Actor_SpawnAsChildAndCutscene( &globalCtx->actorCtx, globalCtx, ACTOR_BG_IKANA_BLOCK, sp50.x, sp50.y, sp50.z, this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, -1, ActorCutscene_GetAdditionalCutscene(this->dyna.actor.cutscene), this->dyna.actor.unk20, NULL); - Matrix_StatePop(); + Matrix_Pop(); } void func_80B80550(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { @@ -200,12 +200,12 @@ void func_80B80550(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { } actor = globalCtx->actorCtx.actorLists[ACTORCAT_DOOR].first; - Matrix_StatePush(); + Matrix_Push(); sp60.x = BINANG_ROT180(this->dyna.actor.home.rot.x); sp60.y = this->dyna.actor.home.rot.y; sp60.z = this->dyna.actor.home.rot.z; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &sp60); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &sp60); while (actor != NULL) { if (actor->id == ACTOR_DOOR_SHUTTER) { @@ -215,24 +215,24 @@ void func_80B80550(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { ptr = &D_80B82184[spC8][i]; if ((Math3D_Vec3fDistSq(&spB4, &D_80B82184[spC8][i].unk_04) < SQ(250.0f)) && - ((ptr->unk_00 ^ spC4) && (ptr->unk_01 == 0U))) { - Matrix_StatePush(); - Matrix_InsertTranslation(spB4.x, spB4.y, spB4.z, MTXMODE_APPLY); - Matrix_RotateY(actor->shape.rot.y - this->dyna.actor.home.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(actor->shape.rot.x - this->dyna.actor.home.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z - this->dyna.actor.home.rot.z, MTXMODE_APPLY); - Matrix_GetStateTranslation(&actor->world.pos); + ((ptr->unk_00 ^ spC4) && (ptr->unk_01 == 0))) { + Matrix_Push(); + Matrix_Translate(spB4.x, spB4.y, spB4.z, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y - this->dyna.actor.home.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(actor->shape.rot.x - this->dyna.actor.home.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z - this->dyna.actor.home.rot.z, MTXMODE_APPLY); + Matrix_MultZero(&actor->world.pos); func_80B80358(&actor->world.pos); - Matrix_CopyCurrentState(&sp68); - func_8018219C(&sp68, &actor->shape.rot, 0); - Matrix_StatePop(); + Matrix_Get(&sp68); + Matrix_MtxFToYXZRot(&sp68, &actor->shape.rot, false); + Matrix_Pop(); } } } actor = actor->next; } - Matrix_StatePop(); + Matrix_Pop(); } BgIkanaRotaryroomStruct4* func_80B80778(BgIkanaRotaryroom* this, GlobalContext* globalCtx, Actor* arg2) { @@ -246,21 +246,20 @@ BgIkanaRotaryroomStruct4* func_80B80778(BgIkanaRotaryroom* this, GlobalContext* if (1) {} if (arg2->id == ACTOR_DOOR_SHUTTER) { - Matrix_StatePush(); + Matrix_Push(); for (i = 0; i < ARRAY_COUNT(D_80B82184); i++) { ptr = &D_80B82184[temp_s3][i]; if ((ptr->unk_01 == 0) && - (Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot), - Matrix_MultiplyVector3fByState(&ptr->unk_04, &sp68), - (Math3D_Vec3fDistSq(&arg2->world.pos, &sp68) < SQ(250.0f)))) { + (Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot), + Matrix_MultVec3f(&ptr->unk_04, &sp68), (Math3D_Vec3fDistSq(&arg2->world.pos, &sp68) < SQ(250.0f)))) { sp58 = ptr; break; } } - Matrix_StatePop(); + Matrix_Pop(); } return sp58; } @@ -270,24 +269,24 @@ void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { Actor* actor = this->unk_204.unk_00; s32 i; - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertZRotation_s(-this->dyna.actor.shape.rot.z, MTXMODE_NEW); - Matrix_InsertXRotation_s(-this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_RotateY(-this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(-this->dyna.actor.world.pos.x, -this->dyna.actor.world.pos.y, - -this->dyna.actor.world.pos.z, MTXMODE_APPLY); + Matrix_RotateZS(-this->dyna.actor.shape.rot.z, MTXMODE_NEW); + Matrix_RotateXS(-this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateYS(-this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(-this->dyna.actor.world.pos.x, -this->dyna.actor.world.pos.y, -this->dyna.actor.world.pos.z, + MTXMODE_APPLY); if (actor != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); - Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&this->unk_204.unk_04); + Matrix_Translate(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&this->unk_204.unk_04); - Matrix_StatePop(); + Matrix_Pop(); } for (i = 0; i < ARRAY_COUNT(this->unk_248); i++) { @@ -300,15 +299,15 @@ void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { if (func_80B80778(this, globalCtx, actor) && (i < 2)) { this->unk_248[i].unk_00 = actor; - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); - Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&this->unk_248[i].unk_04); + Matrix_Translate(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&this->unk_248[i].unk_04); - Matrix_StatePop(); + Matrix_Pop(); i++; } actor = actor->next; @@ -324,15 +323,15 @@ void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { if ((actor->id == ACTOR_EN_TORCH2) && (actor->update != NULL) && (i < ARRAY_COUNT(this->unk_2D0))) { this->unk_2D0[i].unk_00 = actor; - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); - Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&this->unk_2D0[i].unk_04); + Matrix_Translate(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&this->unk_2D0[i].unk_04); - Matrix_StatePop(); + Matrix_Pop(); i++; } actor = actor->next; @@ -350,15 +349,15 @@ void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { this->unk_3E0[i].unk_44 = actor->shape.rot; this->unk_3E0[i].unk_4C = 0.0f; - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); - Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&this->unk_3E0[i].unk_04); + Matrix_Translate(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&this->unk_3E0[i].unk_04); - Matrix_StatePop(); + Matrix_Pop(); i++; } actor = actor->next; @@ -368,18 +367,18 @@ void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { if (actor->update != NULL) { this->unk_520.unk_40 = actor->shape.rot; - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); - Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&this->unk_520.unk_00); + Matrix_Translate(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&this->unk_520.unk_00); - Matrix_StatePop(); + Matrix_Pop(); } - Matrix_StatePop(); + Matrix_Pop(); } void func_80B80C88(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { @@ -392,83 +391,83 @@ void func_80B80C88(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { s32 i; MtxF sp3C; - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); if (ikanaBlock != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertMatrix(&this->unk_204.unk_04, MTXMODE_APPLY); - Matrix_GetStateTranslation(&ikanaBlock->dyna.actor.world.pos); + Matrix_Mult(&this->unk_204.unk_04, MTXMODE_APPLY); + Matrix_MultZero(&ikanaBlock->dyna.actor.world.pos); func_80B80358(&ikanaBlock->dyna.actor.world.pos); - Matrix_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &ikanaBlock->dyna.actor.shape.rot, 0); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &ikanaBlock->dyna.actor.shape.rot, false); - Matrix_StatePop(); + Matrix_Pop(); } for (i = 0; i < ARRAY_COUNT(this->unk_248); i++) { ptr = this->unk_248[i].unk_00; if (ptr != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertMatrix(&this->unk_248[i].unk_04, MTXMODE_APPLY); - Matrix_GetStateTranslation(&ptr->world.pos); + Matrix_Mult(&this->unk_248[i].unk_04, MTXMODE_APPLY); + Matrix_MultZero(&ptr->world.pos); func_80B80358(&ptr->world.pos); - Matrix_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &ptr->shape.rot, 0); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &ptr->shape.rot, false); - Matrix_StatePop(); + Matrix_Pop(); } } for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { ptr2 = this->unk_2D0[i].unk_00; if (ptr2 != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertMatrix(&this->unk_2D0[i].unk_04, MTXMODE_APPLY); - Matrix_GetStateTranslation(&ptr2->world.pos); + Matrix_Mult(&this->unk_2D0[i].unk_04, MTXMODE_APPLY); + Matrix_MultZero(&ptr2->world.pos); func_80B80358(&ptr2->world.pos); - Matrix_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &ptr2->shape.rot, 0); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &ptr2->shape.rot, false); - Matrix_StatePop(); + Matrix_Pop(); } } for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { ptr3 = this->unk_3E0[i].unk_00; if (ptr3 != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertMatrix(&this->unk_3E0[i].unk_04, MTXMODE_APPLY); - Matrix_GetStateTranslation(&ptr3->world.pos); + Matrix_Mult(&this->unk_3E0[i].unk_04, MTXMODE_APPLY); + Matrix_MultZero(&ptr3->world.pos); func_80B80358(&ptr3->world.pos); - Matrix_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &ptr3->shape.rot, 0); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &ptr3->shape.rot, false); - Matrix_StatePop(); + Matrix_Pop(); } } player = GET_PLAYER(globalCtx); if (player != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertMatrix(&this->unk_520.unk_00, MTXMODE_APPLY); - Matrix_GetStateTranslation(&player->actor.world.pos); + Matrix_Mult(&this->unk_520.unk_00, MTXMODE_APPLY); + Matrix_MultZero(&player->actor.world.pos); Math_Vec3f_Copy(&player->actor.home.pos, &player->actor.world.pos); func_80B80358(&player->actor.world.pos); - Matrix_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &player->actor.shape.rot, 0); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &player->actor.shape.rot, false); - Matrix_StatePop(); + Matrix_Pop(); player->actor.freezeTimer = 2; } - Matrix_StatePop(); + Matrix_Pop(); } s32 func_80B80F08(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { @@ -479,18 +478,18 @@ s32 func_80B80F08(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { s32 sp24 = false; if (ikanaBlock != NULL) { - Matrix_StatePush(); + Matrix_Push(); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); - Matrix_InsertTranslation(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); - Matrix_GetStateTranslation(&sp34); - Matrix_SetStateRotationAndTranslation(ikanaBlock->dyna.actor.world.pos.x, - ikanaBlock->dyna.actor.world.pos.y + ikanaBlock->unk_170, - ikanaBlock->dyna.actor.world.pos.z, &ikanaBlock->dyna.actor.shape.rot); - Matrix_GetStateTranslation(&sp28); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Translate(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); + Matrix_MultZero(&sp34); + Matrix_SetTranslateRotateYXZ(ikanaBlock->dyna.actor.world.pos.x, + ikanaBlock->dyna.actor.world.pos.y + ikanaBlock->unk_170, + ikanaBlock->dyna.actor.world.pos.z, &ikanaBlock->dyna.actor.shape.rot); + Matrix_MultZero(&sp28); - Matrix_StatePop(); + Matrix_Pop(); if (Math3D_Vec3fDistSq(&sp34, &sp28) < 3.0f) { if (!Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor))) { @@ -604,14 +603,14 @@ void func_80B81234(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { } ptr->unk_4C.y += ptr->unk_48; - Matrix_StatePush(); + Matrix_Push(); - Matrix_RotateY(player->actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(player->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(player->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(sp44, &sp4C); + Matrix_RotateYS(player->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(player->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(player->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultVecY(sp44, &sp4C); - Matrix_StatePop(); + Matrix_Pop(); temp_f0 = BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &sp40, &sp3C, NULL, &sp58); if (ptr->unk_4C.y <= temp_f0) { @@ -666,15 +665,15 @@ void func_80B81570(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { s32 pad; s32 pad2; - Matrix_StatePush(); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); for (i = 0; i < ARRAY_COUNT(D_80B821C4); i++) { sp64.x = D_80B821C4[i].x; sp64.y = D_80B821C4[i].y; sp64.z = D_80B821C4[i].z; - Matrix_MultiplyVector3fByState(&sp64, &sp70); + Matrix_MultVec3f(&sp64, &sp70); sp70.x += this->dyna.actor.world.pos.x; sp70.y += this->dyna.actor.world.pos.y; @@ -683,7 +682,7 @@ void func_80B81570(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, sp70.x, sp70.y, sp70.z, 0, 0, 0, 1); } - Matrix_StatePop(); + Matrix_Pop(); } s32 func_80B816A4(BgIkanaRotaryroom* this) { diff --git a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c index 7e5c39c2f..37d176f5a 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Fence/z_bg_kin2_fence.c @@ -142,11 +142,11 @@ void BgKin2Fence_SpawnEyeSparkles(BgKin2Fence* this, GlobalContext* globalCtx, s Vec3f sp58; s32 pad[2]; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); for (i = 0; i < 2; i++) { - Matrix_MultiplyVector3fByState(&eyeSparkleSpawnPositions[mask][i], &sp58); + Matrix_MultVec3f(&eyeSparkleSpawnPositions[mask][i], &sp58); EffectSsKirakira_SpawnDispersed(globalCtx, &sp58, &gZeroVec3f, &gZeroVec3f, &primColor, &envColor, 6000, -10); } } @@ -160,8 +160,8 @@ void BgKin2Fence_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_kin2_obj_Colheader_000908); Collider_InitJntSph(globalCtx, &this->collider); Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit, this->colliderElements); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); for (i = 0; i < 4; i++) { diff --git a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c index dc504ecb7..499fb034a 100644 --- a/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c +++ b/src/overlays/actors/ovl_Bg_Kin2_Shelf/z_bg_kin2_shelf.c @@ -77,22 +77,22 @@ s32 func_80B6FB30(BgKin2Shelf* this, GlobalContext* globalCtx) { spA4 = D_80B70750[temp_v1] + ((this->dyna.pushForce < 0.0f) ? 28.0f : -2.0f) + D_80B70768[temp_v1]; - Matrix_InsertTranslation(0.0f, 10.0f, D_80B70760[temp_v1], MTXMODE_NEW); - Matrix_RotateY(spA2, MTXMODE_APPLY); + Matrix_Translate(0.0f, 10.0f, D_80B70760[temp_v1], MTXMODE_NEW); + Matrix_RotateYS(spA2, MTXMODE_APPLY); sp58.x = 0.0f; sp58.y = 0.0f; sp58.z = 0.0f; - Matrix_MultiplyVector3fByState(&sp58, &sp94); + Matrix_MultVec3f(&sp58, &sp94); sp58.z = spA4; - Matrix_MultiplyVector3fByState(&sp58, &sp88); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); - Matrix_MultiplyVector3fByState(&sp94, &sp7C); - Matrix_MultiplyVector3fByState(&sp88, &sp70); + Matrix_MultVec3f(&sp58, &sp88); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_MultVec3f(&sp94, &sp7C); + Matrix_MultVec3f(&sp88, &sp70); return BgCheck_EntityLineTest3(&globalCtx->colCtx, &sp7C, &sp70, &sp64, &sp54, true, false, false, true, &sp50, &this->dyna.actor, 0.0f); @@ -119,22 +119,22 @@ s32 func_80B6FCA4(BgKin2Shelf* this, GlobalContext* globalCtx) { spA0 = D_80B70758[0] + ((this->dyna.pushForce < 0.0f) ? 28.0f : -2.0f) + D_80B70770[0]; - Matrix_InsertTranslation(0.0f, 10.0f, *D_80B70760, MTXMODE_NEW); - Matrix_RotateY(sp9E, MTXMODE_APPLY); + Matrix_Translate(0.0f, 10.0f, *D_80B70760, MTXMODE_NEW); + Matrix_RotateYS(sp9E, MTXMODE_APPLY); sp54.x = 0.0f; sp54.y = 0.0f; sp54.z = 0.0f; - Matrix_MultiplyVector3fByState(&sp54, &sp90); + Matrix_MultVec3f(&sp54, &sp90); sp54.z = spA0; - Matrix_MultiplyVector3fByState(&sp54, &sp84); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); - Matrix_MultiplyVector3fByState(&sp90, &sp78); - Matrix_MultiplyVector3fByState(&sp84, &sp6C); + Matrix_MultVec3f(&sp54, &sp84); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_MultVec3f(&sp90, &sp78); + Matrix_MultVec3f(&sp84, &sp6C); return BgCheck_EntityLineTest3(&globalCtx->colCtx, &sp78, &sp6C, &sp60, &sp50, true, false, false, true, &sp4C, &this->dyna.actor, 0.0f); diff --git a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c index 186376d9b..d30fd2d74 100644 --- a/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c +++ b/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.c @@ -391,14 +391,14 @@ void BgNumaHana_Draw(Actor* thisx, GlobalContext* globalCtx2) { innerPetalPosRot = &this->innerPetalPosRot[i]; outerPetalPosRot = &this->outerPetalPosRot[i]; - Matrix_SetStateRotationAndTranslation(innerPetalPosRot->pos.x, innerPetalPosRot->pos.y, innerPetalPosRot->pos.z, - &innerPetalPosRot->rot); + Matrix_SetTranslateRotateYXZ(innerPetalPosRot->pos.x, innerPetalPosRot->pos.y, innerPetalPosRot->pos.z, + &innerPetalPosRot->rot); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerInnerPetalDL); - Matrix_SetStateRotationAndTranslation(outerPetalPosRot->pos.x, outerPetalPosRot->pos.y, outerPetalPosRot->pos.z, - &outerPetalPosRot->rot); + Matrix_SetTranslateRotateYXZ(outerPetalPosRot->pos.x, outerPetalPosRot->pos.y, outerPetalPosRot->pos.z, + &outerPetalPosRot->rot); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerOuterPetalDL); @@ -406,8 +406,8 @@ void BgNumaHana_Draw(Actor* thisx, GlobalContext* globalCtx2) { objectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_SYOKUDAI); if ((objectIndex >= 0) && (Object_IsLoaded(&globalCtx->objectCtx, objectIndex))) { - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 64.5f, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 64.5f, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_Scale(1.5f, 1.5f, 1.5f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[objectIndex].segment); diff --git a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c index d1847009c..5e3eed13b 100644 --- a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c +++ b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c @@ -186,12 +186,12 @@ void func_809CE068(BgSpdweb* this) { s32 i; s32 j; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); for (i = 0; i < this->collider.count; i++) { for (j = 0; j < ARRAY_COUNT(sp64); j++) { - Matrix_MultiplyVector3fByState(this->collider.elements[i].dim.vtx + j, &sp64[j]); + Matrix_MultVec3f(this->collider.elements[i].dim.vtx + j, &sp64[j]); } Collider_SetTrisVertices(&this->collider, i, &sp64[0], &sp64[1], &sp64[2]); } @@ -513,7 +513,7 @@ void BgSpdweb_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[2], object_spdweb_DL_000060); } else { - Matrix_InsertTranslation(0.0f, (thisx->home.pos.y - thisx->world.pos.y) * 10.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, (thisx->home.pos.y - thisx->world.pos.y) * 10.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(1.0f, ((thisx->home.pos.y - thisx->world.pos.y) + 10.0f) * 0.1f, 1.0f, MTXMODE_APPLY); gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index 4a9061207..12d59b530 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -912,8 +912,8 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { this->unk_0152 = 15; if ((s16)(BREG(71) + 140) < this->unk_0146[1]) { if (this->unk_0146[0] == 0) { - Matrix_RotateY(Math_Atan2S(-player->actor.world.pos.x, -player->actor.world.pos.z), MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(1500.0f * D_809DF5B0, &spA4); + Matrix_RotateYS(Math_Atan2S(-player->actor.world.pos.x, -player->actor.world.pos.z), MTXMODE_NEW); + Matrix_MultVecZ(1500.0f * D_809DF5B0, &spA4); this->unk_0146[0] = 50; this->unk_01B0.x = player->actor.world.pos.x + spA4.x; this->unk_01B0.y = randPlusMinusPoint5Scaled(500.0f * D_809DF5B0) + (600.0f * D_809DF5B0); @@ -1023,15 +1023,14 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { sp9C = Rand_ZeroFloat(M_PI); for (i = 0; i < 15; i++) { - Matrix_InsertYRotation_f(((2.0f * (i * M_PI)) / 15.0f) + sp9C, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ((10 - this->unk_0146[0]) * (D_809DF5B0 * 300.0f) * 0.1f, - &sp90); + Matrix_RotateYF(((2.0f * (i * M_PI)) / 15.0f) + sp9C, MTXMODE_NEW); + Matrix_MultVecZ((10 - this->unk_0146[0]) * (D_809DF5B0 * 300.0f) * 0.1f, &sp90); spD0.x = this->unk_0170.x + sp90.x; spD0.y = this->unk_0170.y + (1000.0f * D_809DF5B0); spD0.z = this->unk_0170.z + sp90.z; if (BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &sp8C, &sp88, &spD0) != BGCHECK_Y_MIN) { spA0 = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp8C, &spD0); - Matrix_GetStateTranslationAndScaledZ(5.0f * D_809DF5B0, &sp70); + Matrix_MultVecZ(5.0f * D_809DF5B0, &sp70); sp70.y = 2.0f * D_809DF5B0; sp64.y = 0.3f * D_809DF5B0; sp64.z = 0.0f; @@ -1376,14 +1375,14 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { } idx = (this->unk_014E + 196) % ARRAY_COUNT(this->unk_01BC); - Matrix_InsertTranslation(this->unk_01BC[idx].x, this->unk_01BC[idx].y, this->unk_01BC[idx].z, MTXMODE_NEW); - Matrix_InsertYRotation_f(this->unk_0B1C[idx].y + spA8, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(spAC - this->unk_0B1C[idx].x); + Matrix_Translate(this->unk_01BC[idx].x, this->unk_01BC[idx].y, this->unk_01BC[idx].z, MTXMODE_NEW); + Matrix_RotateYF(this->unk_0B1C[idx].y + spA8, MTXMODE_APPLY); + Matrix_RotateXFApply(spAC - this->unk_0B1C[idx].x); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 250.0f, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(150.0f, &this->unk_147C[0]); + Matrix_Translate(0.0f, 0.0f, 250.0f, MTXMODE_APPLY); + Matrix_MultVecZ(150.0f, &this->unk_147C[0]); this->unk_0188 = this->unk_017C; - Matrix_GetStateTranslationAndScaledZ(300.0f, &this->unk_017C); + Matrix_MultVecZ(300.0f, &this->unk_017C); Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk_017C); if ((this->unk_0156 & 1) && (this->unk_0158 == 0)) { @@ -1407,14 +1406,13 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { spA0 = spA8; } - Matrix_InsertTranslation(this->unk_01BC[phi_v0].x, this->unk_01BC[phi_v0].y, this->unk_01BC[phi_v0].z, - MTXMODE_NEW); - Matrix_InsertYRotation_f(this->unk_0B1C[phi_v0].y + spA0, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(spA4 - this->unk_0B1C[phi_v0].x); - Matrix_InsertZRotation_f(this->unk_0B1C[phi_v0].z, MTXMODE_APPLY); + Matrix_Translate(this->unk_01BC[phi_v0].x, this->unk_01BC[phi_v0].y, this->unk_01BC[phi_v0].z, MTXMODE_NEW); + Matrix_RotateYF(this->unk_0B1C[phi_v0].y + spA0, MTXMODE_APPLY); + Matrix_RotateXFApply(spA4 - this->unk_0B1C[phi_v0].x); + Matrix_RotateZF(this->unk_0B1C[phi_v0].z, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_InsertYRotation_f(M_PI / 2, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(-(M_PI / 2)); + Matrix_RotateYF(M_PI / 2, MTXMODE_APPLY); + Matrix_RotateXFApply(-(M_PI / 2)); Matrix_ToMtx(mtxIter); gSPMatrix(POLY_OPA_DISP++, mtxIter, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1436,13 +1434,13 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { phi_f12 = 200.0f; } - Matrix_GetStateTranslationAndScaledX(phi_f12, &this->unk_147C[i + 1]); + Matrix_MultVecX(phi_f12, &this->unk_147C[i + 1]); if (i == 21) { Actor* child = this->actor.child; if (child != NULL) { - Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.child->world.pos); + Matrix_MultVecX(500.0f, &this->actor.child->world.pos); } func_809DA50C(1, &this->colliderSphere2, &this->unk_147C[i + 1]); @@ -1543,8 +1541,8 @@ void func_809DD2F8(GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, effect->unk_26 + (i * 3), (effect->unk_26 + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1562,9 +1560,9 @@ void func_809DD2F8(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x01, 100, 100, 120, 255); flag++; } - Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); - Matrix_RotateY(effect->unk_30, MTXMODE_APPLY); - Matrix_InsertXRotation_s(effect->unk_2E, MTXMODE_APPLY); + Matrix_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); + Matrix_RotateYS(effect->unk_30, MTXMODE_APPLY); + Matrix_RotateXS(effect->unk_2E, MTXMODE_APPLY); Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, MTXMODE_APPLY); @@ -1584,8 +1582,8 @@ void func_809DD2F8(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)effect->unk_2C); - Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1608,8 +1606,8 @@ void func_809DD2F8(GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, effect->unk_26 + (i * 3), (effect->unk_26 + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -2021,8 +2019,8 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { } if ((this->unk_1D18 != 0) && (this->unk_1D22 != 0)) { - Matrix_RotateY(player->actor.shape.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(this->unk_1D64, &sp58); + Matrix_RotateYS(player->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVecZ(this->unk_1D64, &sp58); this->unk_1D24.x = player->actor.world.pos.x + sp58.x; this->unk_1D24.y = player->actor.world.pos.y + sp58.y + this->unk_1D68; @@ -2033,8 +2031,8 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { this->unk_1D30.z = player->actor.world.pos.z; this->unk_1D54 = Math_SinS(this->unk_1D14 * 1512) * this->unk_1D58; - Matrix_InsertZRotation_f(this->unk_1D54, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(1.0f, &this->unk_1D3C); + Matrix_RotateZF(this->unk_1D54, MTXMODE_APPLY); + Matrix_MultVecY(1.0f, &this->unk_1D3C); Play_CameraSetAtEyeUp(globalCtx, this->unk_1D22, &this->unk_1D30, &this->unk_1D24, &this->unk_1D3C); ShrinkWindow_SetLetterboxTarget(27); } @@ -2084,9 +2082,8 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { } this->unk_0150 += 0x4000; sp58 = (Math_SinS(this->unk_0150) * (BREG(19) + 5)) * 0.1f; - Matrix_InsertZRotation_f(Math_SinS(this->unk_1D1C * 0x3000) * ((KREG(28) * 0.001f) + 0.017f), - MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledY(1.0f, &this->unk_1D3C); + Matrix_RotateZF(Math_SinS(this->unk_1D1C * 0x3000) * ((KREG(28) * 0.001f) + 0.017f), MTXMODE_NEW); + Matrix_MultVecY(1.0f, &this->unk_1D3C); func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); } diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.c b/src/overlays/actors/ovl_Boss_03/z_boss_03.c index 31e8fb0ae..1959ba26b 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -491,10 +491,10 @@ void Boss03_Init(Actor* thisx, GlobalContext* globalCtx2) { f32 rand; rand = Boss03_RandZeroOne(); - Matrix_InsertYRotation_f((rand * M_PI * 0.2f) + ((2.0f * M_PI / 5.0f) * i), MTXMODE_NEW); + Matrix_RotateYF((rand * M_PI * 0.2f) + ((2.0f * M_PI / 5.0f) * i), MTXMODE_NEW); rand = Boss03_RandZeroOne(); - Matrix_GetStateTranslationAndScaledZ((rand * 800.0f) + 400.0f, &sp70); + Matrix_MultVecZ((rand * 800.0f) + 400.0f, &sp70); rand = Boss03_RandZeroOne(); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_03, sp70.x, sp70.y, sp70.z, 0, rand * 0x10000, 0, @@ -574,8 +574,8 @@ void func_809E34B8(Boss03* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); xDiff = this->unk_268.x - this->actor.world.pos.x; yDiff = this->unk_268.y - this->actor.world.pos.y; @@ -589,10 +589,10 @@ void func_809E34B8(Boss03* this, GlobalContext* globalCtx) { Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, this->unk_27C); - Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); if ((this->workTimer[WORK_TIMER_UNK2_A] == 0) && (this->actor.bgCheckFlags & 8)) { - Matrix_GetStateTranslationAndScaledZ(-500.0f, &this->unk_268); + Matrix_MultVecZ(-500.0f, &this->unk_268); this->unk_268.y = Rand_ZeroFloat(100.0f) + 150.0f; this->workTimer[WORK_TIMER_UNK2_A] = 60; this->workTimer[WORK_TIMER_UNK0_A] = Rand_ZeroFloat(60.0f) + 60.0f; @@ -677,7 +677,7 @@ void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx) { Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, this->unk_27C); - Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); Actor_MoveWithoutGravityReverse(&this->actor); Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); @@ -706,10 +706,9 @@ void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx) { sp44 = 100.0f; } - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(sp44, &sp50); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_MultVecZ(sp44, &sp50); xDiff = sp50.x - player->actor.world.pos.x; zDiff = sp50.z - player->actor.world.pos.z; @@ -774,7 +773,7 @@ void Boss03_CatchPlayer(Boss03* this, GlobalContext* globalCtx) { 5, 0x100); Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, this->unk_27C); - Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); Actor_MoveWithoutGravityReverse(&this->actor); Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, this->unk_274 * 2); @@ -834,12 +833,12 @@ void Boss03_SetupChewPlayer(Boss03* this, GlobalContext* globalCtx) { this->actionFunc = Boss03_ChewPlayer; pitchAngle = Math_FAtan2F(this->actor.world.pos.z, this->actor.world.pos.x); - Matrix_RotateY(pitchAngle, MTXMODE_NEW); + Matrix_RotateYS(pitchAngle, MTXMODE_NEW); out.x = 0.0f; out.y = 200.0f; out.z = 700.0f; - Matrix_MultiplyVector3fByState(&out, &this->unk_268); + Matrix_MultVec3f(&out, &this->unk_268); this->unk_276 = 0x800; this->unk_242 = 0; @@ -864,8 +863,8 @@ void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); xDiff = this->unk_268.x - this->actor.world.pos.x; yDiff = this->unk_268.y - this->actor.world.pos.y; @@ -877,7 +876,7 @@ void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx) { -0.5f, 5, 0x100); Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); - Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); switch (this->unk_242) { case 0: @@ -1041,7 +1040,7 @@ void Boss03_Charge(Boss03* this, GlobalContext* globalCtx) { this->actor.shape.rot = this->actor.world.rot; Math_ApproachF(&this->actor.speedXZ, 25.0f, 1.0f, 3.0f); - Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + Math_ApproachF(&this->unk_260, sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); Actor_MoveWithoutGravityReverse(&this->actor); if (this->actor.speedXZ >= 20.0f) { @@ -1394,12 +1393,11 @@ void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx) { phi_f2 = CLAMP_MAX(phi_f2, 0.12f); sp5C = Math_SinS(this->unk_240 * sp5A) * phi_f2; - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); - Matrix_InsertYRotation_f(sp5C, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.world.rot.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(100.0f, &this->csCamAt); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_RotateYF(sp5C, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.world.rot.x, MTXMODE_APPLY); + Matrix_MultVecZ(100.0f, &this->csCamAt); this->csCamEye = this->actor.world.pos; @@ -1491,8 +1489,8 @@ void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx) { this->csCamTargetAt.z = this->actor.world.pos.z; this->unk_568 += this->unk_56C; - Matrix_InsertYRotation_f(this->unk_568, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp90, &this->csCamTargetEye); + Matrix_RotateYF(this->unk_568, MTXMODE_NEW); + Matrix_MultVec3f(&sp90, &this->csCamTargetEye); this->csCamTargetEye.x += this->actor.world.pos.x; this->csCamTargetEye.y += this->waterHeight; @@ -1517,8 +1515,8 @@ void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.world.pos.y, Math_SinS(this->unk_240 * 0x1000) * 80.0f + this->waterHeight, 1.0f, 10.0f); this->actor.shape.rot.z += 0x100; - Matrix_RotateY(this->unk_2BE, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(500.0f, &sp84); + Matrix_RotateYS(this->unk_2BE, MTXMODE_NEW); + Matrix_MultVecZ(500.0f, &sp84); Math_ApproachF(&this->actor.world.pos.x, sp84.x, 0.1f, 5.0f); Math_ApproachF(&this->actor.world.pos.z, sp84.z, 0.1f, 5.0f); @@ -1692,10 +1690,10 @@ void Boss03_SpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx) { player->actor.shape.rot.y = player->actor.world.rot.y = this->actor.world.rot.y + 0x8000; - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y + this->unk_2BE, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(340.0f, &this->csCamEye); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y + this->unk_2BE, MTXMODE_APPLY); + Matrix_MultVecZ(340.0f, &this->csCamEye); this->csCamAt.x = this->actor.world.pos.x; this->csCamAt.y = this->actor.world.pos.y; @@ -2065,8 +2063,8 @@ void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { if (this->unk_290 != 0) { this->unk_294 += 0.1f; this->unk_298 += 0.12f; - this->leftFinYRot = __sinf(this->unk_294) * 1280.0f; - this->rightFinYRot = __sinf(this->unk_298) * 1280.0f; + this->leftFinYRot = sinf(this->unk_294) * 1280.0f; + this->rightFinYRot = sinf(this->unk_298) * 1280.0f; } else { Math_ApproachS(&this->rightFinYRot, 0, 0xA, 0x100); Math_ApproachS(&this->leftFinYRot, 0, 0xA, 0x100); @@ -2132,8 +2130,8 @@ void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { yRot = 0.0f; for (j = 0, i = 0; i < 20; j++) { - Matrix_InsertYRotation_f(yRot, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(60.000004f) + 312.0f, &dropletPos); + Matrix_RotateYF(yRot, MTXMODE_NEW); + Matrix_MultVecZ(Rand_ZeroFloat(60.000004f) + 312.0f, &dropletPos); dropletPos.x += this->unk_284 + randPlusMinusPoint5Scaled(40.0f); dropletPos.y = PLATFORM_HEIGHT; dropletPos.z += this->unk_28C + randPlusMinusPoint5Scaled(40.0f); @@ -2236,12 +2234,12 @@ void Boss03_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V Player* player = GET_PLAYER(globalCtx); if (limbIndex == GYORG_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_809E9148, &this->actor.focus.pos); + Matrix_MultVec3f(&D_809E9148, &this->actor.focus.pos); } sphereElementIndex = sGyorgSphElementIndices[limbIndex]; if (sphereElementIndex >= 0) { - Matrix_MultiplyVector3fByState(&D_809E9154[sphereElementIndex], &spherePos); + Matrix_MultVec3f(&D_809E9154[sphereElementIndex], &spherePos); if (sphereElementIndex < 2) { if ((this->actionFunc == Boss03_Stunned) && (this->waterHeight < player->actor.world.pos.y)) { @@ -2258,9 +2256,9 @@ void Boss03_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V MtxF mf; D_809E91B4.x = this->unk_2C4 + 300.0f; - Matrix_MultiplyVector3fByState(&D_809E91B4, &this->insideJawPos); - Matrix_CopyCurrentState(&mf); - func_8018219C(&mf, &this->unk_2A2, 0); + Matrix_MultVec3f(&D_809E91B4, &this->insideJawPos); + Matrix_Get(&mf); + Matrix_MtxFToYXZRot(&mf, &this->unk_2A2, false); } } @@ -2276,8 +2274,8 @@ void Boss03_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 900, 1099); } - Matrix_InsertYRotation_f(this->unk_260, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -600.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateYF(this->unk_260, MTXMODE_APPLY); + Matrix_Translate(0.0f, -600.0f, 0.0f, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, Boss03_OverrideLimbDraw, Boss03_PostLimbDraw, &this->actor); POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); @@ -2346,11 +2344,11 @@ void Boss03_UpdateEffects(GlobalContext* globalCtx) { eff->alphaDelta = Rand_ZeroFloat(4.0f) + 5.0f; for (j = 0; j < 4; j++) { - Matrix_InsertYRotation_f((2.0f * (j * M_PI)) / 6.0f, 0); + Matrix_RotateYF((2.0f * (j * M_PI)) / 6.0f, MTXMODE_NEW); sp94.x = 0.0f; sp94.y = Rand_ZeroFloat(4.0f) + 2.0f; sp94.z = Rand_ZeroFloat(1.5f) + 1.5f; - Matrix_MultiplyVector3fByState(&sp94, &velocity); + Matrix_MultVec3f(&sp94, &velocity); Boss03_SpawnEffectSplash(globalCtx, &eff->pos, &velocity); } } @@ -2413,9 +2411,9 @@ void Boss03_DrawEffects(GlobalContext* globalCtx) { flag = true; } - Matrix_InsertTranslation(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); Matrix_Scale(eff->unk_34.x, eff->unk_34.x, 1.0f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -2444,18 +2442,17 @@ void Boss03_DrawEffects(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)eff->unk_40, (u8)((((void)0, eff->unk_40) + 55.0f)), 225, 150); - Matrix_InsertTranslation(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); if (eff->type == GYORG_EFFECT_DROPLET) { - Matrix_InsertYRotation_f(Camera_GetInputDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) * - (M_PI / 0x8000), - MTXMODE_APPLY); + Matrix_RotateYF(Camera_GetInputDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) * (M_PI / 0x8000), + MTXMODE_APPLY); } else { // GYORG_EFFECT_SPLASH - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); } Matrix_Scale(eff->unk_34.x, eff->unk_34.y, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_f(eff->unk_34.z, MTXMODE_APPLY); + Matrix_RotateZF(eff->unk_34.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042B0); @@ -2481,10 +2478,10 @@ void Boss03_DrawEffects(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s16)eff->unk_40, ((void)0, ((s16)eff->unk_40) + 55), 225, eff->alpha); - Matrix_InsertTranslation(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); Matrix_Scale(eff->unk_34.x, 1.0f, eff->unk_34.x, MTXMODE_APPLY); - Matrix_InsertYRotation_f(eff->unk_34.z, MTXMODE_APPLY); + Matrix_RotateYF(eff->unk_34.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042F8); @@ -2610,27 +2607,27 @@ void Boss03_SeaweedDraw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(0x4000, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateZS(0x4000, MTXMODE_APPLY); // The indices looks a bit random... - Matrix_RotateY(this->jointTable[5].x * -5.0f * 0.1f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->jointTable[3].y * -5.0f * 0.1f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->jointTable[2].z * 6.0f * 0.1f, MTXMODE_APPLY); + Matrix_RotateYS(this->jointTable[5].x * -5.0f * 0.1f, MTXMODE_APPLY); + Matrix_RotateXS(this->jointTable[3].y * -5.0f * 0.1f, MTXMODE_APPLY); + Matrix_RotateZS(this->jointTable[2].z * 6.0f * 0.1f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(sGyorgSeaweedDLs); i++, mtx++) { - Matrix_RotateY(this->jointTable[i].x + this->morphTable[i].x, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->jointTable[i].y + this->morphTable[i].y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->jointTable[i].z + this->morphTable[i].z, MTXMODE_APPLY); + Matrix_RotateYS(this->jointTable[i].x + this->morphTable[i].x, MTXMODE_APPLY); + Matrix_RotateXS(this->jointTable[i].y + this->morphTable[i].y, MTXMODE_APPLY); + Matrix_RotateZS(this->jointTable[i].z + this->morphTable[i].z, MTXMODE_APPLY); Matrix_ToMtx(mtx); gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, sGyorgSeaweedDLs[i]); - Matrix_GetStateTranslation(&this->seaweedSegmentPositions[i]); - Matrix_InsertTranslation(4000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultZero(&this->seaweedSegmentPositions[i]); + Matrix_Translate(4000.0f, 0.0f, 0.0f, MTXMODE_APPLY); } CLOSE_DISPS(globalCtx->state.gfxCtx); 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 b74d9c66b..659fdbe3f 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -214,8 +214,8 @@ void Boss04_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk_6F6 = 82; phi_s0_2 = 0; for (i = 0; i < 82; i++) { - Matrix_RotateY(phi_s0_2, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(phi_f20, &sp90); + Matrix_RotateYS(phi_s0_2, MTXMODE_NEW); + Matrix_MultVecZ(phi_f20, &sp90); Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TANRON2, this->unk_6E8 + sp90.x, phi_f24, this->unk_6F0 + sp90.z, 0, 0, 0, i); phi_f20 += 2.5f; @@ -245,7 +245,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { this->unk_1FE = 15; if ((this->unk_708 != 0) && (this->unk_708 < 10)) { this->actor.world.pos.y = (Math_SinS(this->unk_1F4 * 512) * 10.0f) + (this->actor.floorHeight + 160.0f); - Matrix_RotateY(this->actor.yawTowardsPlayer, MTXMODE_NEW); + Matrix_RotateYS(this->actor.yawTowardsPlayer, MTXMODE_NEW); } switch (this->unk_708) { @@ -339,7 +339,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { case 1: player->actor.shape.rot.y = 0x7FFF; player->actor.world.rot.y = player->actor.shape.rot.y; - Matrix_GetStateTranslationAndScaledZ(-100.0f, &this->unk_70C); + Matrix_MultVecZ(-100.0f, &this->unk_70C); this->unk_70C.x += player->actor.world.pos.x; this->unk_70C.y = Player_GetHeight(player) + player->actor.world.pos.y + 36.0f; @@ -358,7 +358,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { case 2: case 3: - Matrix_GetStateTranslationAndScaledZ(500.0f, &this->unk_70C); + Matrix_MultVecZ(500.0f, &this->unk_70C); this->unk_70C.x += this->actor.world.pos.x; this->unk_70C.y += this->actor.world.pos.y - 50.0f; this->unk_70C.z += this->actor.world.pos.z; @@ -591,82 +591,82 @@ void func_809ED50C(Boss04* this) { this->unk_2DE += this->unk_2E2; this->unk_2DC += this->unk_2E0; - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 10.0f, MTXMODE_APPLY); - Matrix_GetStateTranslation(&this->unk_6BC); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 10.0f, MTXMODE_APPLY); + Matrix_MultZero(&this->unk_6BC); Matrix_Scale(this->actor.scale.x * 13.0f, this->actor.scale.y * 13.0f, this->actor.scale.z * 16.0f, MTXMODE_APPLY); - Matrix_RotateY(this->unk_2DC, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2DE, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_2DC, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2DE, MTXMODE_APPLY); + Matrix_Push(); for (i = 0; i < ARRAY_COUNT(this->unk_2E4); i++) { - Matrix_RotateStateAroundXAxis(0.3926991f); - Matrix_GetStateTranslationAndScaledZ(100.0f, &this->unk_2E4[i]); + Matrix_RotateXFApply(0.3926991f); + Matrix_MultVecZ(100.0f, &this->unk_2E4[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(38.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(38.0f, 0.0f, 0.0f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->unk_3A4); i++) { - Matrix_RotateStateAroundXAxis(0.41887903f); - Matrix_GetStateTranslationAndScaledZ(92.0f, &this->unk_3A4[i]); + Matrix_RotateXFApply(0.41887903f); + Matrix_MultVecZ(92.0f, &this->unk_3A4[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(-38.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(-38.0f, 0.0f, 0.0f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->unk_458); i++) { - Matrix_RotateStateAroundXAxis(0.41887903f); - Matrix_GetStateTranslationAndScaledZ(92.0f, &this->unk_458[i]); + Matrix_RotateXFApply(0.41887903f); + Matrix_MultVecZ(92.0f, &this->unk_458[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(71.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(71.0f, 0.0f, 0.0f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->unk_50C); i++) { - Matrix_RotateStateAroundXAxis(0.5711987f); - Matrix_GetStateTranslationAndScaledZ(71.0f, &this->unk_50C[i]); + Matrix_RotateXFApply(0.5711987f); + Matrix_MultVecZ(71.0f, &this->unk_50C[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(-71.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(-71.0f, 0.0f, 0.0f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->unk_590); i++) { - Matrix_RotateStateAroundXAxis(0.5711987f); - Matrix_GetStateTranslationAndScaledZ(71.0f, &this->unk_590[i]); + Matrix_RotateXFApply(0.5711987f); + Matrix_MultVecZ(71.0f, &this->unk_590[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(92.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(92.0f, 0.0f, 0.0f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->unk_614); i++) { - Matrix_RotateStateAroundXAxis(1.0471976f); - Matrix_GetStateTranslationAndScaledZ(38.0f, &this->unk_614[i]); + Matrix_RotateXFApply(1.0471976f); + Matrix_MultVecZ(38.0f, &this->unk_614[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(-92.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(-92.0f, 0.0f, 0.0f, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->unk_65C); i++) { - Matrix_RotateStateAroundXAxis(1.0471976f); - Matrix_GetStateTranslationAndScaledZ(38.0f, &this->unk_65C[i]); + Matrix_RotateXFApply(1.0471976f); + Matrix_MultVecZ(38.0f, &this->unk_65C[i]); } - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(100.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(100.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_GetStateTranslation(&this->unk_6A4); - Matrix_StatePop(); - Matrix_InsertTranslation(-100.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_GetStateTranslation(&this->unk_6B0); + Matrix_MultZero(&this->unk_6A4); + Matrix_Pop(); + Matrix_Translate(-100.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultZero(&this->unk_6B0); } void Boss04_Update(Actor* thisx, GlobalContext* globalCtx2) { @@ -805,10 +805,10 @@ void Boss04_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V Vec3f sp18; if (limbIndex == 1) { - Matrix_GetStateTranslationAndScaledY(-500.0f, &this->actor.focus.pos); - Matrix_MultiplyVector3fByState(&D_809EE228, &sp18); + Matrix_MultVecY(-500.0f, &this->actor.focus.pos); + Matrix_MultVec3f(&D_809EE228, &sp18); func_809EC040(0, &this->collider1, &sp18); - Matrix_MultiplyVector3fByState(&D_809EE234, &sp18); + Matrix_MultVec3f(&D_809EE234, &sp18); func_809EC040(0, &this->collider2, &sp18); } } @@ -824,7 +824,7 @@ void Boss04_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 900, 1099); } - Matrix_InsertTranslation(0.0f, 0.0f, 800.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 800.0f, MTXMODE_APPLY); Matrix_Scale(this->unk_6F8, this->unk_6FC, this->unk_700, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, Boss04_OverrideLimbDraw, Boss04_PostLimbDraw, &this->actor); @@ -837,9 +837,9 @@ void Boss04_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 150); gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004510); - Matrix_InsertTranslation(this->unk_6BC.x, this->actor.floorHeight, this->unk_6BC.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -20.0f, MTXMODE_APPLY); + Matrix_Translate(this->unk_6BC.x, this->actor.floorHeight, this->unk_6BC.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -20.0f, MTXMODE_APPLY); Matrix_Scale(this->unk_6F8 * 1.8f, 0.0f, this->unk_700 * 2.8f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index f73423d5e..07016aff9 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -467,15 +467,14 @@ void Boss06_Update(Actor* thisx, GlobalContext* globalCtx) { phi_f24 = 0.0f; for (i = 0; i < 1024; i++) { - temp_f22 = - (((__sinf(phi_f24) * this->unk_1D4) + 1.0f) * ((__sinf(phi_f26) * this->unk_1D0) + this->unk_1D0)) + - this->unk_1CC; + temp_f22 = (((sinf(phi_f24) * this->unk_1D4) + 1.0f) * ((sinf(phi_f26) * this->unk_1D0) + this->unk_1D0)) + + this->unk_1CC; phi_f26 += (M_PI / 64); phi_f24 += 0.030679617f; - Matrix_InsertZRotation_f(i * (M_PI / 512), MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledY(temp_f22, &sp7C); + Matrix_RotateZF(i * (M_PI / 512), MTXMODE_NEW); + Matrix_MultVecY(temp_f22, &sp7C); sp7C.x += 32.0f + this->unk_1BC; sp7C.y += 32.0f + this->unk_1C0; @@ -573,10 +572,10 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { } AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_knight_Matanimheader_019360)); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y - 234.0f, - this->actor.world.pos.z + 30.0f, 0); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y - 234.0f, this->actor.world.pos.z + 30.0f, + MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -1112.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -1112.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 155, 255, maxColor, (u8)((140.0f * sp68) + 115.0f), spD3); @@ -590,18 +589,18 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { if (this->unk_144 & 1) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(&this->unk_200)); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + this->unk_1A8, - this->actor.world.pos.z, MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + this->unk_1A8, this->actor.world.pos.z, + MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, 0.0f, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_knight_DL_0193B0); if (this->unk_1D8 > 0.0f) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 84.0f, - this->actor.world.pos.z - 2.0f, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + 84.0f, this->actor.world.pos.z - 2.0f, + MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); func_809F2120(1, 0x71A5, 0x263A); gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 0); @@ -609,18 +608,18 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < ARRAY_COUNT(D_809F4370); i++) { if ((fabsf(D_809F4370[i].x - 32.0f) < 30.0f) && (fabsf(D_809F4370[i].y - 32.0f) < 30.0f)) { - Matrix_StatePush(); + Matrix_Push(); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, ((globalCtx->gameplayFrames + (i * 10)) * -20) % 512, 0x20, 0x80)); - Matrix_InsertTranslation((D_809F4370[i].x - 32.0f) * -2.4f, (D_809F4370[i].y - 32.0f) * -2.4f, 0.0f, - MTXMODE_APPLY); - Matrix_InsertZRotation_f(i * (M_PI / 64), MTXMODE_APPLY); + Matrix_Translate((D_809F4370[i].x - 32.0f) * -2.4f, (D_809F4370[i].y - 32.0f) * -2.4f, 0.0f, + MTXMODE_APPLY); + Matrix_RotateZF(i * (M_PI / 64), MTXMODE_APPLY); if (func_809F2140() < 0.5f) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } Matrix_Scale(-0.02f / 10.0f, -this->unk_1D8, 1.0f, MTXMODE_APPLY); @@ -629,7 +628,7 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); - Matrix_StatePop(); + Matrix_Pop(); } } } else { @@ -640,16 +639,15 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { if (this->unk_1DC > 0.0f) { u8 temp_s2 = (this->unk_1E0 - 50.0f) + (50.0f * sp68); - Matrix_InsertTranslation(this->actor.world.pos.x + this->unk_1B0, - this->actor.world.pos.y + 84.0f + this->unk_1B4, - (this->actor.world.pos.z - 2.0f) + spE0, MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x + this->unk_1B0, this->actor.world.pos.y + 84.0f + this->unk_1B4, + (this->actor.world.pos.z - 2.0f) + spE0, MTXMODE_NEW); gSPDisplayList(POLY_XLU_DISP++, gLightOrb1DL); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, (u8)((140.0f * sp68) + 115.0f), temp_s2); gDPSetEnvColor(POLY_XLU_DISP++, 255, 205, (u8)((100.0f * sp68) + 65.0f), 128); Matrix_Scale(this->unk_1DC, this->unk_1DC, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(globalCtx->gameplayFrames * 64, MTXMODE_APPLY); + Matrix_RotateZS(globalCtx->gameplayFrames * 64, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c index 108f128ae..48ef3cd3d 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c @@ -297,15 +297,15 @@ void func_808CE078(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, this->unk_168[0], this->unk_168[1], this->unk_168[2], 255); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_StatePush(); - Matrix_InsertZRotation_s(sp46, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateZS(sp46, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023288); - Matrix_StatePop(); - Matrix_InsertZRotation_s(sp46 * -1, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_RotateZS(sp46 * -1, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023288); diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index b51fc64ec..2c676abbf 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -153,12 +153,9 @@ void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globa Math_SmoothStepToF(&this->particles[i].scale, 0.1, 0.1f, 0.001f, 0.00001f); Math_SmoothStepToF(&this->particles[i].speed, this->particles[i].speedTarget, 0.5f, 0.2f, 0.02f); - this->particles[i].posOffset.x += - __sinf(this->particles[i].speedClock.x) * this->particles[i].speed; - this->particles[i].posOffset.y += - __sinf(this->particles[i].speedClock.y) * this->particles[i].speed; - this->particles[i].posOffset.z += - __sinf(this->particles[i].speedClock.z) * this->particles[i].speed; + this->particles[i].posOffset.x += sinf(this->particles[i].speedClock.x) * this->particles[i].speed; + this->particles[i].posOffset.y += sinf(this->particles[i].speedClock.y) * this->particles[i].speed; + this->particles[i].posOffset.z += sinf(this->particles[i].speedClock.z) * this->particles[i].speed; switch ((i >> 1) & 3) { case 0: @@ -205,7 +202,7 @@ void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globa this->particles[i].LostWoodsSkyFishPosOffsetMax, 0.5f, 2.0f, 0.2f); this->particles[i].LostWoodsSkyFishSpeedXZClock += this->particles[i].LostWoodsSkyFishSpeedXZ; - this->particles[i].posOffset.y += __sinf(this->particles[i].speedClock.y); + this->particles[i].posOffset.y += sinf(this->particles[i].speedClock.y); this->particles[i].speedClock.x += 0.2f * Rand_ZeroOne(); // unused calculation this->particles[i].speedClock.y += this->particles[i].LostWoodsSkyFishSpeedY; this->particles[i].speedClock.z += 0.1f * Rand_ZeroOne(); // unused calculation @@ -377,9 +374,9 @@ void DemoKakyo_MoonSparklesActionFunc(DemoKankyo* this, GlobalContext* globalCtx Math_SmoothStepToF(&this->particles[i].scale, 0.2f, 0.1f, 0.001f, 0.00001f); Math_SmoothStepToF(&this->particles[i].speed, this->particles[i].speedTarget, 0.5f, 0.2f, 0.02f); - this->particles[i].posOffset.x += __sinf(this->particles[i].speedClock.x) * this->particles[i].speed; - this->particles[i].posOffset.y += __sinf(this->particles[i].speedClock.y) * this->particles[i].speed; - this->particles[i].posOffset.z += __sinf(this->particles[i].speedClock.z) * this->particles[i].speed; + this->particles[i].posOffset.x += sinf(this->particles[i].speedClock.x) * this->particles[i].speed; + this->particles[i].posOffset.y += sinf(this->particles[i].speedClock.y) * this->particles[i].speed; + this->particles[i].posOffset.z += sinf(this->particles[i].speedClock.z) * this->particles[i].speed; switch ((i >> 1) & 3) { case 0: @@ -536,7 +533,7 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, GlobalContext* globalCtx2) { // checking if particle is on screen if (screenPos.x >= 0.0f && screenPos.x < SCREEN_WIDTH && screenPos.y >= 0.0f && screenPos.y < SCREEN_HEIGHT) { - Matrix_InsertTranslation(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); + Matrix_Translate(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); scaleAlpha = this->particles[i].alpha / 50.0f; if (scaleAlpha > 1.0f) { scaleAlpha = 1.0f; @@ -586,8 +583,8 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, GlobalContext* globalCtx2) { break; } - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_f(DEGF_TO_RADF(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -625,7 +622,7 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { // checking if particle is on screen if (screenPos.x >= 0.0f && screenPos.x < SCREEN_WIDTH && screenPos.y >= 0.0f && screenPos.y < SCREEN_HEIGHT) { - Matrix_InsertTranslation(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); + Matrix_Translate(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); alphaScale = this->particles[i].alpha / 50.0f; if (alphaScale > 1.0f) { alphaScale = 1.0f; @@ -657,9 +654,9 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_XLU_DISP++, &gLightOrb1DL); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_f(DEGF_TO_RADF(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c index aa25fddfd..72f101d18 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c @@ -489,7 +489,7 @@ void func_80C173B4(Actor* thisx, GlobalContext* globalCtx) { if (matrix != NULL) { func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); func_8018450C(globalCtx, &this->unk_144, matrix, (void*)func_80C170F8, 0, &this->actor); } } @@ -518,14 +518,14 @@ void DemoSyoten_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C2DC(globalCtx->state.gfxCtx); if (this->unk_3E4 & 4) { - Matrix_InsertZRotation_s(-this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateZS(-this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); Matrix_Scale(1.0f, 5.0f, 1.0f, MTXMODE_APPLY); } if (this->unk_3E4 & 1) { - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); } if (this->unk_3E4 & 8) { @@ -555,7 +555,7 @@ void func_80C17690(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); if (this->unk_3E4 & 8) { func_80C17468(globalCtx); diff --git a/src/overlays/actors/ovl_Dm_An/z_dm_an.c b/src/overlays/actors/ovl_Dm_An/z_dm_an.c index 18548675d..19f7844ac 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.c +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.c @@ -280,21 +280,21 @@ void func_80C1CD80(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* if ((limbIndex == OBJECT_AN1_LIMB_05) && (this->unk_2D4 != 0)) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_JointPosition(&D_80C1D2C8, &D_80C1D2D4); + Matrix_Push(); + Matrix_TranslateRotateZYX(&D_80C1D2C8, &D_80C1D2D4); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2A].segment); gSPDisplayList(POLY_OPA_DISP++, gMoonMaskDL); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2B].segment); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == OBJECT_AN1_LIMB_09) { - Matrix_MultiplyVector3fByState(&D_80C1D2DC, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80C1D2DC, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } } @@ -320,23 +320,23 @@ void func_80C1CEFC(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { SubS_UpdateLimb(this->unk_2BE + this->unk_2C2 + 0x4000, this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, &this->unk_1A4, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_1A4.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_1A4.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_1A4.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_1A4.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1A4.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_1A4.z, MTXMODE_APPLY); + Matrix_Push(); } else if (limbIndex == OBJECT_AN1_LIMB_02) { SubS_UpdateLimb(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, &this->unk_1AA, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_1AA.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_1AA.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_1AA.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_1AA.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1AA.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_1AA.z, MTXMODE_APPLY); + Matrix_Push(); } } diff --git a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c index c72634216..ce9f844d0 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c @@ -901,8 +901,8 @@ s32 DmChar00_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi if (limbIndex == 6) { sp28 = ((Math_SinS(this->unk_262 * 0x1000) * 0.1f) + 1.0f) * 0.012f * (this->actor.scale.x * 124.99999f); - Matrix_MultiplyVector3fByState(&D_80AA7808, &sp1C); - Matrix_InsertTranslation(sp1C.x, sp1C.y, sp1C.z, MTXMODE_NEW); + Matrix_MultVec3f(&D_80AA7808, &sp1C); + Matrix_Translate(sp1C.x, sp1C.y, sp1C.z, MTXMODE_NEW); Matrix_Scale(sp28, sp28, sp28, MTXMODE_APPLY); } return false; diff --git a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c index b4537b1af..375edda4a 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -411,7 +411,7 @@ void DmChar01_Draw(Actor* thisx, GlobalContext* globalCtx) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_0110B8)); Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_010FD8); Gfx_DrawDListXlu(globalCtx, object_mtoride_DL_010EF0); - Matrix_InsertTranslation(0.0f, 10.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 10.0f, 0.0f, MTXMODE_APPLY); } AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_009D70)); diff --git a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c index 956f7317c..94935db3c 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c @@ -671,7 +671,7 @@ void func_80AADC00(Actor* thisx, GlobalContext* globalCtx) { } if (globalCtx->csCtx.actorActions[actionIndex]->action == 4) { - Matrix_InsertTranslation(-600.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(-600.0f, 0.0f, 0.0f, MTXMODE_APPLY); Gfx_DrawDListOpa(globalCtx, object_dmask_DL_001E70); } } @@ -716,8 +716,8 @@ void DmChar05_Draw(Actor* thisx, GlobalContext* globalCtx) { void func_80AADD9C(GlobalContext* globalCtx, DmChar05* this) { if (this->actor.objBankIndex == this->unk_18F) { - Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); - Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); GetItem_Draw(globalCtx, GID_44); } @@ -729,8 +729,8 @@ void func_80AADD9C(GlobalContext* globalCtx, DmChar05* this) { void func_80AADE78(GlobalContext* globalCtx, DmChar05* this) { if (this->actor.objBankIndex == this->unk_18F) { - Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); - Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); GetItem_Draw(globalCtx, GID_45); } @@ -742,8 +742,8 @@ void func_80AADE78(GlobalContext* globalCtx, DmChar05* this) { void func_80AADF54(GlobalContext* globalCtx, DmChar05* this) { if (this->actor.objBankIndex == this->unk_18F) { - Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); - Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); GetItem_Draw(globalCtx, GID_6B); } @@ -756,8 +756,8 @@ void func_80AADF54(GlobalContext* globalCtx, DmChar05* this) { void func_80AAE030(GlobalContext* globalCtx, DmChar05* this) { if (this->unk_18E != 0) { if (this->actor.objBankIndex == this->unk_18F) { - Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); - Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); GetItem_Draw(globalCtx, GID_03); } @@ -776,9 +776,8 @@ void func_80AAE114(GlobalContext* globalCtx, DmChar05* this) { sp34 = DMCHAR05_GET(&this->actor) - DMCHAR05_5; if (this->actor.objBankIndex == this->unk_18F) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); GetItem_Draw(globalCtx, sp24[sp34]); } diff --git a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c index 969b7a80b..a6970e050 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c @@ -280,21 +280,21 @@ void DmGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if ((limbIndex == OBJECT_AN1_LIMB_05) && (this->unk_2D4 != 0)) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_JointPosition(&D_80C25218, &D_80C25224); + Matrix_Push(); + Matrix_TranslateRotateZYX(&D_80C25218, &D_80C25224); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2A].segment); gSPDisplayList(POLY_OPA_DISP++, gMoonMaskDL); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2B].segment); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == OBJECT_AN1_LIMB_09) { - Matrix_MultiplyVector3fByState(&D_80C2522C, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80C2522C, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } } @@ -320,23 +320,23 @@ void DmGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this SubS_UpdateLimb(this->unk_2BE + this->unk_2C2 + 0x4000, this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, &this->unk_1A4, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_1A4.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_1A4.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_1A4.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_1A4.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1A4.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_1A4.z, MTXMODE_APPLY); + Matrix_Push(); } else if (limbIndex == OBJECT_AN1_LIMB_02) { SubS_UpdateLimb(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, &this->unk_1AA, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_1AA.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_1AA.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_1AA.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_1AA.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1AA.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_1AA.z, MTXMODE_APPLY); + Matrix_Push(); } } diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index b778f3fcc..782ef8679 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -1618,7 +1618,7 @@ void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V DmStk* this = THIS; if (limbIndex == 17) { - Matrix_GetStateTranslation(&this->unk_304); + Matrix_MultZero(&this->unk_304); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1658,7 +1658,7 @@ void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V if (Cutscene_CheckActorAction(globalCtx, 513) && (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 513)]->action == 2) && (this->unk_337 >= 0)) { - Matrix_StatePush(); + Matrix_Push(); Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_337].segment); @@ -1670,7 +1670,7 @@ void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_336].segment); - Matrix_StatePop(); + Matrix_Pop(); } break; } @@ -1706,9 +1706,9 @@ void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V break; case 5: - Matrix_InsertTranslation(-20.0f, -660.0f, 860.0f, MTXMODE_APPLY); - Matrix_RotateY(0x6142, MTXMODE_APPLY); - Matrix_InsertXRotation_s(-0x1988, MTXMODE_APPLY); + Matrix_Translate(-20.0f, -660.0f, 860.0f, MTXMODE_APPLY); + Matrix_RotateYS(0x6142, MTXMODE_APPLY); + Matrix_RotateXS(-0x1988, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index 999eec485..fe52a8288 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -673,9 +673,9 @@ void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); if (this->unk_164 == 7) { - Matrix_InsertTranslation(0.0f, 64.96f, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.home.rot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -64.96f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 64.96f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.home.rot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, -64.96f, 0.0f, MTXMODE_APPLY); } if (sp44->unk_04 != 0) { @@ -687,10 +687,10 @@ void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { s16 yaw = this->actor.shape.rot.y - Math_Vec3f_Yaw(&globalCtx->view.eye, &this->actor.world.pos); if (ABS_ALT(yaw) < 0x4000) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } } else if (this->actor.room == transitionEntry->sides[0].room) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } } else if (this->doorType == 5) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_808A22DC[this->unk_15E])); @@ -700,7 +700,7 @@ void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, sp44->unk_00); if ((this->unk_168 != 0.0f) && (sp44->unk_04 != 0)) { - Matrix_InsertTranslation(0.0f, sp44->unk_08 * (1.0f - this->unk_168), sp44->translateZ, MTXMODE_APPLY); + Matrix_Translate(0.0f, sp44->unk_08 * (1.0f - this->unk_168), sp44->translateZ, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index fa94a5981..6217361f2 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -972,8 +972,8 @@ void func_808BAE9C(DoorWarp1* this, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255.0f * sp84, 255, 255, (u8)this->unk_1B4); gDPSetEnvColor(POLY_XLU_DISP++, 0, 255.0f * sp84, 255, 255); - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 1.0f, - this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 1.0f, this->dyna.actor.world.pos.z, + MTXMODE_NEW); phi_f12 = 1.0f; if (this->unk_203 != 0) { phi_f12 = this->unk_204 * phi_f12; @@ -981,19 +981,19 @@ void func_808BAE9C(DoorWarp1* this, GlobalContext* globalCtx) { Matrix_Scale(phi_f12, phi_f12, phi_f12, MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 0x0A, Matrix_NewMtx(globalCtx->state.gfxCtx)); - Matrix_StatePush(); + Matrix_Push(); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, sp94 & 0xFF, -((s16)(2.0f * this->unk_1AC) & 0x1FF), 0x100, 0x100, 1, sp94 & 0xFF, -((s16)(2.0f * this->unk_1AC) & 0x1FF), 0x100, 0x100)); - Matrix_InsertTranslation(0.0f, this->unk_1A4 * 230.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->unk_1A4 * 230.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(((this->unk_1C6 * sp90) / 100.0f) + 1.0f, 1.0f, ((this->unk_1C6 * sp90) / 100.0f) + 1.0f, MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(globalCtx->state.gfxCtx)); gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_0001A0); - Matrix_StatePop(); + Matrix_Pop(); if (this->unk_1B0 > 0.0f) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255.0f * sp84, 255, 255, (u8)this->unk_1B0); @@ -1004,7 +1004,7 @@ void func_808BAE9C(DoorWarp1* this, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, sp94 & 0xFF, -((s16)this->unk_1AC & 0x1FF), 0x100, 0x100, 1, sp94 & 0xFF, -((s16)this->unk_1AC & 0x1FF), 0x100, 0x100)); - Matrix_InsertTranslation(0.0f, this->unk_1A8 * 60.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->unk_1A8 * 60.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(((this->unk_1C8 * sp8C) / 100.0f) + 1.0f, 1.0f, ((this->unk_1C8 * sp8C) / 100.0f) + 1.0f, MTXMODE_APPLY); @@ -1031,8 +1031,8 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { s32 sp60 = 0; if (this->unk_1D4 != 0) { - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + this->unk_1A4, - this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + this->unk_1A4, + this->dyna.actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(4.0f, this->unk_1AC, 4.0f, MTXMODE_APPLY); AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_warp1_Matanimheader_0044D8)); Gfx_DrawDListXlu(globalCtx, object_warp1_DL_003230); @@ -1049,9 +1049,9 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { } } - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.world.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.world.rot.y, MTXMODE_APPLY); Matrix_Scale(1.0f, this->unk_1A8, 1.0f, MTXMODE_APPLY); AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_warp1_Matanimheader_0057D8)); @@ -1069,9 +1069,9 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { OPEN_DISPS(globalCtx->state.gfxCtx); AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_warp1_Matanimheader_007238)); - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.world.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.world.rot.y, MTXMODE_APPLY); Matrix_Scale(1.0f, 0.0f, 1.0f, MTXMODE_APPLY); func_8012C2DC(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c index 856b459a3..211b32412 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -283,14 +283,14 @@ void func_80919768(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < ARRAY_COUNT(this->distanceTraveled); i++) { if (*distanceTraveled < 1.0f) { aux = 1.0f - SQ(*distanceTraveled); - Matrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); - Matrix_RotateY(sp92, MTXMODE_APPLY); - Matrix_InsertTranslation(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)), - initialPositions->y * ((this->dy * aux) + (1.0f - this->dy)), - initialPositions->z * ((this->dz * aux) + (1.0f - this->dz)), MTXMODE_APPLY); + Matrix_Translate(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(sp92, MTXMODE_APPLY); + Matrix_Translate(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)), + initialPositions->y * ((this->dy * aux) + (1.0f - this->dy)), + initialPositions->z * ((this->dz * aux) + (1.0f - this->dz)), MTXMODE_APPLY); Matrix_Scale(this->scalingFactor, this->scalingFactor, this->scalingFactor, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -339,15 +339,15 @@ void func_809199FC(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (*distanceTraveled * 255.0f)); aux = 1.0f - SQ(*distanceTraveled); - Matrix_InsertMatrix(&player->mf_CC4, MTXMODE_NEW); - Matrix_InsertTranslation(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)), - (initialPositions->y * (1.0f - *distanceTraveled)) + 320.0f, - (initialPositions->z * (1.0f - *distanceTraveled)) + -20.0f, MTXMODE_APPLY); + Matrix_Mult(&player->mf_CC4, MTXMODE_NEW); + Matrix_Translate(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)), + (initialPositions->y * (1.0f - *distanceTraveled)) + 320.0f, + (initialPositions->z * (1.0f - *distanceTraveled)) + -20.0f, MTXMODE_APPLY); Matrix_Scale(*distanceTraveled * this->scalingFactor, *distanceTraveled * this->scalingFactor, *distanceTraveled * this->scalingFactor, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index 405c2ffb4..dd719d6fb 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -568,7 +568,7 @@ void EnAh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnAh* this = THIS; if (limbIndex == 7) { - Matrix_MultiplyVector3fByState(&D_80BD3F00, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BD3F00, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } } @@ -594,23 +594,23 @@ void EnAh_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this SubS_UpdateLimb(BINANG_ADD(this->unk_2EC + this->unk_2F0, 0x4000), BINANG_ADD(this->unk_2EE + this->unk_2F2 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, this->unk_200, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_200[0].y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_200[0].x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_200[0].z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_200[0].y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_200[0].x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_200[0].z, MTXMODE_APPLY); + Matrix_Push(); } else if (limbIndex == 2) { SubS_UpdateLimb(BINANG_ADD(this->unk_2F0, 0x4000), BINANG_ADD(this->unk_2F2 + this->actor.shape.rot.y, 0x4000), &this->unk_1E8[1], &this->unk_200[1], stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1E8[1].x, this->unk_1E8[1].y, this->unk_1E8[1].z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_1E8[1].x, this->unk_1E8[1].y, this->unk_1E8[1].z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_200[1].y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_200[1].x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_200[1].z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_200[1].y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_200[1].x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_200[1].z, MTXMODE_APPLY); + Matrix_Push(); } } diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c index 70e98fc15..22b2a0228 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -1699,7 +1699,7 @@ void EnAkindonuts_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Act } if (limbIndex == 24) { - Matrix_RotateY(this->unk_352, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_352, MTXMODE_APPLY); } } diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index 063c50b61..a14b2e106 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -839,31 +839,31 @@ void EnAl_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec switch (limbIndex) { case 3: - Matrix_CopyCurrentState(&this->unk_190[0]); + Matrix_Get(&this->unk_190[0]); break; case 11: - Matrix_CopyCurrentState(&this->unk_190[1]); + Matrix_Get(&this->unk_190[1]); break; case 12: - Matrix_CopyCurrentState(&this->unk_190[2]); + Matrix_Get(&this->unk_190[2]); break; case 13: - Matrix_CopyCurrentState(&this->unk_190[3]); + Matrix_Get(&this->unk_190[3]); break; case 14: - Matrix_CopyCurrentState(&this->unk_190[4]); + Matrix_Get(&this->unk_190[4]); break; case 15: - Matrix_CopyCurrentState(&this->unk_190[5]); + Matrix_Get(&this->unk_190[5]); break; case 16: - Matrix_MultiplyVector3fByState(&D_80BE0070, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BE0070, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); break; } @@ -889,13 +889,13 @@ void EnAl_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this if (limbIndex == 16) { SubS_UpdateLimb(this->unk_4DC + 0x4000, this->unk_4DE + this->actor.shape.rot.y + 0x4000, &this->unk_36C, &this->unk_378, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_36C.x, this->unk_36C.y, this->unk_36C.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_36C.x, this->unk_36C.y, this->unk_36C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_378.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_378.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_378.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_378.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_378.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_378.z, MTXMODE_APPLY); + Matrix_Push(); } } @@ -907,13 +907,13 @@ void EnAl_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, 0.0f, 850.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 850.0f, MTXMODE_APPLY); SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnAl_OverrideLimbDraw, EnAl_PostLimbDraw, EnAl_TransformLimbDraw, &this->actor); for (i = 0; i < ARRAY_COUNT(this->unk_190); i++) { - Matrix_SetCurrentState(&this->unk_190[i]); + Matrix_Put(&this->unk_190[i]); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.c b/src/overlays/actors/ovl_En_Am/z_en_am.c index 20092f5b0..00c07327e 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -551,7 +551,7 @@ void EnAm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec phi_s3 = 0; } for (i = 0; i < phi_s3; i++, phi_s2++, phi_s1++) { - Matrix_MultiplyVector3fByState(phi_s1, phi_s2); + Matrix_MultVec3f(phi_s1, phi_s2); } } diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.c b/src/overlays/actors/ovl_En_Ani/z_en_ani.c index 43e9de4f0..098d91be4 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -331,7 +331,7 @@ void EnAni_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve static Vec3f D_809686A4 = { 800.0f, 500.0f, 0.0f }; if (limbIndex == ANI_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_809686A4, &thisx->focus.pos); + Matrix_MultVec3f(&D_809686A4, &thisx->focus.pos); } } @@ -342,7 +342,7 @@ void EnAni_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, 0.0f, -1000.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -1000.0f, MTXMODE_APPLY); func_8012C5B0(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeState])); diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index b949b4be3..1d74c45ae 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -999,15 +999,15 @@ s32 EnAob01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis } if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->headRot.x * -1, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->headRot.x * -1, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == MAMAMU_YAN_LIMB_TORSO) { - Matrix_InsertXRotation_s(this->torsoRot.y * -1, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->torsoRot.x * -1, MTXMODE_APPLY); + Matrix_RotateXS(this->torsoRot.y * -1, MTXMODE_APPLY); + Matrix_RotateZS(this->torsoRot.x * -1, MTXMODE_APPLY); } if ((limbIndex == MAMAMU_YAN_LIMB_TORSO) || (limbIndex == MAMAMU_YAN_LIMB_LEFT_UPPER_ARM) || @@ -1023,7 +1023,7 @@ void EnAob01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnAob01* this = THIS; if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_809C3968, &this->actor.focus.pos); + Matrix_MultVec3f(&D_809C3968, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index e60419846..0a8eeffce 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -579,15 +579,15 @@ void func_8088B88C(GlobalContext* globalCtx, EnArrow* this, EnArrowUnkStruct* ar Vec3f sp34; s32 sp30; - Matrix_MultiplyVector3fByState(&arg2->unk_48, &this->unk_234); + Matrix_MultVec3f(&arg2->unk_48, &this->unk_234); if (func_8088ACE0 == this->actionFunc) { if (!this->unk_244.active) { sp4C = arg2->unk_00; } else { sp4C = arg2->unk_18[globalCtx->gameplayFrames % 2]; } - Matrix_MultiplyVector3fByState(&sp4C[0], &sp40); - Matrix_MultiplyVector3fByState(&sp4C[1], &sp34); + Matrix_MultVec3f(&sp4C[0], &sp40); + Matrix_MultVec3f(&sp4C[1], &sp34); if (this->actor.params < ENARROW_8) { sp30 = this->actor.params < ENARROW_6; if (this->unk_264 == 0) { @@ -666,7 +666,7 @@ void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(this->bubble.unk_144 * sp9C, this->bubble.unk_144 * sp9C, this->bubble.unk_144 * spA0, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 460.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 460.0f, MTXMODE_APPLY); if (this->actor.speedXZ == 0.0f) { func_800B8118(&this->actor, globalCtx, MTXMODE_NEW); @@ -677,7 +677,7 @@ void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { COMBINED, 0, ENVIRONMENT, 0, COMBINED, 0, ENVIRONMENT, 0); gDPSetEnvColor(POLY_XLU_DISP++, 230, 225, 150, spA4); - Matrix_NormalizeXYZ(&gIdentityMtxF); + Matrix_ReplaceRotation(&gIdentityMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -718,8 +718,8 @@ void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { sp5C = 150.0f; } - Matrix_StatePush(); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); if (this->actor.speedXZ == 0.0f) { phi_v0 = 0; @@ -727,21 +727,21 @@ void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { phi_v0 = (globalCtx->gameplayFrames % 256) * 4000; } - Matrix_InsertZRotation_s(phi_v0, MTXMODE_APPLY); + Matrix_RotateZS(phi_v0, MTXMODE_APPLY); Matrix_Scale(sp5C, sp5C, sp5C, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); - Matrix_StatePop(); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); CLOSE_DISPS(globalCtx->state.gfxCtx); } else if (this->actor.velocity.y != 0.0f) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_058BA0); diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index 9295b03a5..e6dd15a32 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -700,19 +700,19 @@ s32 EnBaba_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList EnBaba* this = THIS; if (limbIndex == 6) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->headRot.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + 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); } if (limbIndex == 5) { - Matrix_InsertXRotation_s(-this->torsoRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->torsoRot.x, MTXMODE_APPLY); + Matrix_RotateXS(-this->torsoRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->torsoRot.x, MTXMODE_APPLY); } if ((limbIndex == 6) && (this->unk_1E2 != 0) && ((globalCtx->state.frames % 2) == 0)) { - Matrix_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if ((limbIndex == 5) || (limbIndex == 10) || (limbIndex == 14)) { @@ -736,7 +736,7 @@ void EnBaba_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V this->actor.focus.pos.x = this->actor.world.pos.x; this->actor.focus.pos.y = this->actor.world.pos.y; this->actor.focus.pos.z = this->actor.world.pos.z; - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c index 8e70d5d6b..88fc11072 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c @@ -498,10 +498,10 @@ void EnBaguo_DrawRockParticles(EnBaguo* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { if (particle->isVisible) { - Matrix_InsertTranslation(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); - Matrix_InsertXRotation_s(particle->rotation.x, MTXMODE_APPLY); - Matrix_RotateY(particle->rotation.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(particle->rotation.z, MTXMODE_APPLY); + Matrix_Translate(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); + Matrix_RotateXS(particle->rotation.x, MTXMODE_APPLY); + Matrix_RotateYS(particle->rotation.y, MTXMODE_APPLY); + Matrix_RotateZS(particle->rotation.z, MTXMODE_APPLY); Matrix_Scale(particle->scale, particle->scale, particle->scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index 311c2f633..f48976cd6 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -640,17 +640,17 @@ void EnBb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (this->bodyPartDrawStatus == BB_BODY_PART_DRAW_STATUS_ALIVE) { if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { if (sLimbIndexToBodyPartsIndex[limbIndex] == 0) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->bodyPartsPos[0]); + Matrix_MultVecX(1000.0f, &this->bodyPartsPos[0]); } else if (sLimbIndexToBodyPartsIndex[limbIndex] == 3) { - Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->bodyPartsPos[3]); - Matrix_MultiplyVector3fByState(&sDuplicateCraniumBodyPartOffset, &this->bodyPartsPos[4]); + Matrix_MultVecX(-1000.0f, &this->bodyPartsPos[3]); + Matrix_MultVec3f(&sDuplicateCraniumBodyPartOffset, &this->bodyPartsPos[4]); } else { - Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + Matrix_MultZero(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); } } } else if (this->bodyPartDrawStatus > BB_BODY_PART_DRAW_STATUS_ALIVE) { if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + Matrix_MultZero(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); } if (limbIndex == BUBBLE_LIMB_CRANIUM) { @@ -660,11 +660,11 @@ void EnBb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { OPEN_DISPS(globalCtx->state.gfxCtx); - currentMatrixState = Matrix_GetCurrentState(); + currentMatrixState = Matrix_GetCurrent(); currentMatrixState->mf[3][0] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].x; currentMatrixState->mf[3][1] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].y; currentMatrixState->mf[3][2] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].z; - Matrix_InsertZRotation_s(thisx->world.rot.z, MTXMODE_APPLY); + Matrix_RotateZS(thisx->world.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->limbDList); @@ -689,9 +689,9 @@ void EnBb_Draw(Actor* thisx, GlobalContext* globalCtx) { EnBb_PostLimbDraw, &this->actor); if (this->flameScaleX > 0.0f) { - currentMatrixState = Matrix_GetCurrentState(); + currentMatrixState = Matrix_GetCurrent(); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY( + Matrix_RotateYS( ((Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) - this->actor.shape.rot.y) + 0x8000), MTXMODE_APPLY); Matrix_Scale(this->flameScaleX, this->flameScaleY, 1.0f, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index 61d4df146..f2c70dac8 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -255,7 +255,7 @@ s32 EnBba01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis bodyPart = gEnHyBodyParts[limbIndex]; if (bodyPart >= 0) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.bodyPartsPos[bodyPart]); + Matrix_MultVec3f(&zeroVec, &this->enHy.bodyPartsPos[bodyPart]); } if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { @@ -266,20 +266,20 @@ s32 EnBba01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->enHy.headRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->enHy.headRot.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->enHy.headRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->enHy.headRot.x, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == BBA_LIMB_BAG) { - Matrix_InsertXRotation_s(-this->enHy.torsoRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->enHy.torsoRot.x, MTXMODE_APPLY); + Matrix_RotateXS(-this->enHy.torsoRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->enHy.torsoRot.x, MTXMODE_APPLY); } if ((limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) && this->enHy.inMsgState3 && ((globalCtx->state.frames % 2) == 0)) { - Matrix_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if ((limbIndex == BBA_LIMB_BAG) || (limbIndex == BBA_LIMB_TORSO) || (limbIndex == BBA_LIMB_LEFT_FOREARM)) { @@ -303,7 +303,7 @@ void EnBba01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.actor.focus.pos); + Matrix_MultVec3f(&zeroVec, &this->enHy.actor.focus.pos); } } @@ -325,7 +325,7 @@ void EnBba01_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawTransformFlexOpa(globalCtx, this->enHy.skelAnime.skeleton, this->enHy.skelAnime.jointTable, this->enHy.skelAnime.dListCount, EnBba01_OverrideLimbDraw, EnBba01_PostLimbDraw, EnBba01_TransformLimbDraw, &this->enHy.actor); - Matrix_InsertXRotation_s(0, MTXMODE_NEW); + Matrix_RotateXS(0, MTXMODE_NEW); for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { *shadowTexIter++ = 0; diff --git a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c index 3ccd807d8..9e55e8508 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c @@ -674,17 +674,17 @@ void EnBbfall_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (this->bodyPartDrawStatus == BBFALL_BODY_PART_DRAW_STATUS_ALIVE) { if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { if (sLimbIndexToBodyPartsIndex[limbIndex] == 0) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->bodyPartsPos[0]); + Matrix_MultVecX(1000.0f, &this->bodyPartsPos[0]); } else if (sLimbIndexToBodyPartsIndex[limbIndex] == 3) { - Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->bodyPartsPos[3]); - Matrix_MultiplyVector3fByState(&sDuplicateCraniumBodyPartOffset, &this->bodyPartsPos[4]); + Matrix_MultVecX(-1000.0f, &this->bodyPartsPos[3]); + Matrix_MultVec3f(&sDuplicateCraniumBodyPartOffset, &this->bodyPartsPos[4]); } else { - Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + Matrix_MultZero(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); } } } else if (this->bodyPartDrawStatus > BBFALL_BODY_PART_DRAW_STATUS_ALIVE) { if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + Matrix_MultZero(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); } if (limbIndex == BUBBLE_LIMB_CRANIUM) { @@ -694,11 +694,11 @@ void EnBbfall_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { OPEN_DISPS(globalCtx->state.gfxCtx); - currentMatrixState = Matrix_GetCurrentState(); + currentMatrixState = Matrix_GetCurrent(); currentMatrixState->mf[3][0] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].x; currentMatrixState->mf[3][1] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].y; currentMatrixState->mf[3][2] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].z; - Matrix_InsertZRotation_s(thisx->world.rot.z, MTXMODE_APPLY); + Matrix_RotateZS(thisx->world.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->limbDList); @@ -727,12 +727,12 @@ void EnBbfall_Draw(Actor* thisx, GlobalContext* globalCtx2) { if (this->flameOpacity > 0) { func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY( + Matrix_RotateYS( ((Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) - this->actor.shape.rot.y) + 0x8000), MTXMODE_APPLY); Matrix_Scale(this->flameScaleX, this->flameScaleY, 1.0f, MTXMODE_APPLY); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - currentMatrixState = Matrix_GetCurrentState(); + currentMatrixState = Matrix_GetCurrent(); opacity = this->flameOpacity; pos = &this->flamePos[0]; diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c index 8431d6706..e25d1e02a 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -636,12 +636,12 @@ void EnBigokuta_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis if (limbPosIndex != -1) { if (limbPosIndex < 6) { - Matrix_GetStateTranslationAndScaledX(800.0f, &this->limbPos[limbPosIndex]); + Matrix_MultVecX(800.0f, &this->limbPos[limbPosIndex]); } else if (limbPosIndex < 8) { - Matrix_GetStateTranslation(&this->limbPos[limbPosIndex]); + Matrix_MultZero(&this->limbPos[limbPosIndex]); } else { for (i = 0; i < ARRAY_COUNT(D_80AC45D0); i++) { - Matrix_MultiplyVector3fByState(&D_80AC45D0[i], &this->limbPos[limbPosIndex + i]); + Matrix_MultVec3f(&D_80AC45D0[i], &this->limbPos[limbPosIndex + i]); } } } diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index 09ed84312..acf465f83 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -734,9 +734,9 @@ void EnBigpo_BurnAwayDeath(EnBigpo* this, GlobalContext* globalCtx) { void EnBigpo_SetupLanternDrop(EnBigpo* this, GlobalContext* globalCtx) { this->actor.draw = EnBigpo_DrawLantern; this->actor.shape.shadowDraw = NULL; - this->actor.world.pos.x = this->drawMtxF.wx; - this->actor.world.pos.y = this->drawMtxF.wy; - this->actor.world.pos.z = this->drawMtxF.wz; + this->actor.world.pos.x = this->drawMtxF.xw; + this->actor.world.pos.y = this->drawMtxF.yw; + this->actor.world.pos.z = this->drawMtxF.zw; Actor_SetScale(&this->actor, 0.014f); this->actor.gravity = -1.0f; @@ -1249,31 +1249,31 @@ void EnBigpo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (limbIndex == 7) { // we scale the vec3f... then do nothing with it? - Matrix_GetStateTranslationAndScaledY(1400.0f, &unusedVec); + Matrix_MultVecY(1400.0f, &unusedVec); if ((this->actionFunc == EnBigpo_BurnAwayDeath) && (this->idleTimer > 18)) { if (this->actor.scale.x != 0.0f) { Matrix_Scale(0.014f / this->actor.scale.x, 0.014f / this->actor.scale.x, 0.014f / this->actor.scale.x, 1); } } - Matrix_CopyCurrentState(&this->drawMtxF); + Matrix_Get(&this->drawMtxF); } limbByte = D_80B65078[limbIndex]; if (limbByte != -1) { if (limbByte < 3) { - Matrix_GetStateTranslation(&this->limbPos[limbByte]); + Matrix_MultZero(&this->limbPos[limbByte]); } else if (limbByte == 3) { - Matrix_GetStateTranslationAndScaledX(3000.0f, &this->limbPos[limbByte]); + Matrix_MultVecX(3000.0f, &this->limbPos[limbByte]); } else if (limbByte == 4) { - Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->limbPos[limbByte]); + Matrix_MultVecY(-2000.0f, &this->limbPos[limbByte]); } else { v2ptr = &this->limbPos[limbByte + 1]; v1ptr = D_80B65084; - Matrix_GetStateTranslationAndScaledX(-4000.0f, &this->limbPos[limbByte]); + Matrix_MultVecX(-4000.0f, &this->limbPos[limbByte]); for (i = limbByte + 1; i < ARRAY_COUNT(this->limbPos); i++) { - Matrix_MultiplyVector3fByState(v1ptr, v2ptr); + Matrix_MultVec3f(v1ptr, v2ptr); v2ptr++; v1ptr++; } @@ -1315,7 +1315,7 @@ void EnBigpo_DrawMainBigpo(Actor* thisx, GlobalContext* globalCtx) { this->actor.scale.x * 71.428566f * this->drawDmgEffScale, 0.0f, this->drawDmgEffAlpha, ACTOR_DRAW_DMGEFF_LIGHT_ORBS); - Matrix_SetCurrentState(&this->drawMtxF); + Matrix_Put(&this->drawMtxF); EnBigpo_DrawLantern(&this->actor, globalCtx); if (this->actionFunc == EnBigpo_SpawnCutsceneStage6) { EnBigpo_DrawCircleFlames(&this->actor, globalCtx); @@ -1344,7 +1344,7 @@ void EnBigpo_DrawScoopSoul(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.z, this->mainColor.r, this->mainColor.g, this->mainColor.b, this->mainColor.a * 2); - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1386,7 +1386,7 @@ void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(&dispHead[1], 0x0A, Gfx_EnvColor(globalCtx->state.gfxCtx, 160, 0, 255, this->mainColor.a)); - Matrix_GetStateTranslationAndScaledY(1400.0f, &vec2); + Matrix_MultVecY(1400.0f, &vec2); Lights_PointGlowSetInfo(&this->fires[0].info, vec2.x + vec1.x, vec2.y + vec1.y, vec2.z + vec1.z, this->lanternColor.r, this->lanternColor.g, this->lanternColor.b, this->lanternColor.a); @@ -1415,11 +1415,11 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { MtxF* mtfxPtr; s32 i; - mtfxPtr = Matrix_GetCurrentState(); + mtfxPtr = Matrix_GetCurrent(); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_NEW); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_NEW); if (this->actionFunc == EnBigpo_SpawnCutsceneStage6) { Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); fireRadius = 500; @@ -1439,9 +1439,9 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { Lights_PointNoGlowSetInfo(&this->fires[i].info, this->fires[i].pos.x, this->fires[i].pos.y, this->fires[i].pos.z, 170, 255, 255, fireRadius); - mtfxPtr->wx = firePtr->pos.x; - mtfxPtr->wy = firePtr->pos.y; - mtfxPtr->wz = firePtr->pos.z; + mtfxPtr->xw = firePtr->pos.x; + mtfxPtr->yw = firePtr->pos.y; + mtfxPtr->zw = firePtr->pos.z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index 5428e701a..1a507b5b6 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -2873,35 +2873,35 @@ void EnBigslime_UpdateGekko(Actor* thisx, GlobalContext* globalCtx) { void EnBigslime_SetSysMatrix(Vec3f* pos, GlobalContext* globalCtx, Gfx* shadowDList, f32 scaleX, f32 scalez, f32 scaleY, s16 rotation, f32 alpha) { f32 yDistMinY; - f32 xz; - MtxF* sysMatrix = Matrix_GetCurrentState(); + f32 zx; + MtxF* sysMatrix = Matrix_GetCurrent(); yDistMinY = pos->y - scaleY - GBT_ROOM_5_MIN_Y; yDistMinY = CLAMP((yDistMinY), 0.0f, (GBT_ROOM_5_CENTER_Y - GBT_ROOM_5_MIN_Y) / 2); - xz = 1.0f - (yDistMinY * (1.0f / 1550.0f)); + zx = 1.0f - (yDistMinY * (1.0f / 1550.0f)); OPEN_DISPS(globalCtx->state.gfxCtx); POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); - sysMatrix->xx = xz; + sysMatrix->xx = zx; sysMatrix->yy = 1.0f; - sysMatrix->zz = xz; - sysMatrix->xz = sysMatrix->xy = 0.0f; - sysMatrix->yz = sysMatrix->yx = 0.0f; - sysMatrix->zy = sysMatrix->zx = 0.0f; - sysMatrix->wx = pos->x; - sysMatrix->wy = GBT_ROOM_5_MIN_Y; - sysMatrix->wz = pos->z; - sysMatrix->xw = sysMatrix->yw = sysMatrix->zw = 0.0f; + sysMatrix->zz = zx; + sysMatrix->zx = sysMatrix->yx = 0.0f; + sysMatrix->zy = sysMatrix->xy = 0.0f; + sysMatrix->yz = sysMatrix->xz = 0.0f; + sysMatrix->xw = pos->x; + sysMatrix->yw = GBT_ROOM_5_MIN_Y; + sysMatrix->zw = pos->z; + sysMatrix->wx = sysMatrix->wy = sysMatrix->wz = 0.0f; sysMatrix->ww = 1.0f; - Matrix_RotateY(rotation, MTXMODE_APPLY); + Matrix_RotateYS(rotation, MTXMODE_APPLY); Matrix_Scale(scaleX, 1.0f, scalez, MTXMODE_APPLY); if (shadowDList != gBigslimeShadowDL) { gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, 0, COMBINED); } - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (u8)(alpha * xz)); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (u8)(alpha * zx)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, shadowDList); CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -2940,14 +2940,14 @@ void EnBigslime_DrawMinislime(EnBigslime* this, GlobalContext* globalCtx2) { Lights_Draw(lights, globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); func_800B8118(&minislime->actor, globalCtx, 0); - Matrix_SetStateRotationAndTranslation(minislime->actor.world.pos.x, minislime->actor.world.pos.y, - minislime->actor.world.pos.z, &minislime->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(minislime->actor.world.pos.x, minislime->actor.world.pos.y, + minislime->actor.world.pos.z, &minislime->actor.shape.rot); Matrix_Scale(minislime->actor.scale.x, minislime->actor.scale.y, minislime->actor.scale.z, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, minislime->actor.shape.shadowAlpha); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, &gMinislimeNormalDL); if (minislime->frozenAlpha > 0) { - Matrix_InsertTranslation(0.0f, (0.1f - minislime->frozenScale) * -4000.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, (0.1f - minislime->frozenScale) * -4000.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(0.1f, minislime->frozenScale, 0.1f, MTXMODE_APPLY); AnimatedMat_Draw(globalCtx, this->minislimeFrozenTexAnim); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, minislime->frozenAlpha); @@ -2999,18 +2999,18 @@ void EnBigslime_DrawBigslime(Actor* thisx, GlobalContext* globalCtx) { // Draw bubbles inside Bigslime if (this->actor.scale.x > 0.0f) { - Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Put(&globalCtx->billboardMtxF); Matrix_Scale(0.0050000003f, 0.0050000003f, 0.0050000003f, MTXMODE_APPLY); - billboardMtxF = Matrix_GetCurrentState(); + billboardMtxF = Matrix_GetCurrent(); for (i = 0; i < 28; i++) { bubblesInfoPtr = &bubblesInfo[i]; dynamicVtx = &sBigslimeDynamicVtx[this->dynamicVtxState][bubblesInfoPtr->v]; - billboardMtxF->wx = + billboardMtxF->xw = dynamicVtx->n.ob[0] * this->actor.scale.x * bubblesInfoPtr->scaleVtx + this->actor.world.pos.x; - billboardMtxF->wy = + billboardMtxF->yw = dynamicVtx->n.ob[1] * this->actor.scale.y * bubblesInfoPtr->scaleVtx + this->actor.world.pos.y; - billboardMtxF->wz = + billboardMtxF->zw = dynamicVtx->n.ob[2] * this->actor.scale.z * bubblesInfoPtr->scaleVtx + this->actor.world.pos.z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -3048,16 +3048,16 @@ void EnBigslime_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis Vec3f rightFootOffset; if (limbIndex == GEKKO_LIMB_HEAD) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); this->actor.focus.rot.y = this->gekkoRot.y; } if (limbPosIndex[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[limbPosIndex[limbIndex]]); + Matrix_MultZero(&this->limbPos[limbPosIndex[limbIndex]]); } if (limbIndex == GEKKO_LIMB_R_ANKLE) { - Matrix_MultiplyVector3fByState(&rightFootOffsetRef, &rightFootOffset); + Matrix_MultVec3f(&rightFootOffsetRef, &rightFootOffset); this->gekkoCollider.dim.pos.y = rightFootOffset.y; } } @@ -3087,7 +3087,7 @@ void EnBigslime_DrawGekko(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); Math_Vec3f_Sum(&this->actor.world.pos, &this->gekkoPosOffset, &gekkoPos); - Matrix_SetStateRotationAndTranslation(gekkoPos.x, gekkoPos.y, gekkoPos.z, &this->gekkoRot); + Matrix_SetTranslateRotateYXZ(gekkoPos.x, gekkoPos.y, gekkoPos.z, &this->gekkoRot); Matrix_Scale(this->gekkoScale, this->gekkoScale, this->gekkoScale, MTXMODE_APPLY); SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &gekkoPos, &this->gekkoProjectedPos); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -3131,7 +3131,7 @@ void EnBigslime_DrawShatteringEffects(EnBigslime* this, GlobalContext* globalCtx Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->gameplayFrames % 128, (u8)(globalCtx->gameplayFrames * 8), 32, 64, 1, (-globalCtx->gameplayFrames * 2) % 64, 0, 16, 16)); - Matrix_InsertTranslation(this->frozenPos.x, this->frozenPos.y, this->frozenPos.z, MTXMODE_NEW); + Matrix_Translate(this->frozenPos.x, this->frozenPos.y, this->frozenPos.z, MTXMODE_NEW); Matrix_Scale(this->shockwaveScale, this->shockwaveScale, this->shockwaveScale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, &gBigslimeShockwaveDL); @@ -3144,8 +3144,8 @@ void EnBigslime_DrawShatteringEffects(EnBigslime* this, GlobalContext* globalCtx for (i = 0; i < BIGSLIME_NUM_ICE_SHARD; i++) { iceShardEffect = &this->iceShardEffect[i]; if (iceShardEffect->isActive > false) { - Matrix_SetStateRotationAndTranslation(iceShardEffect->pos.x, iceShardEffect->pos.y, iceShardEffect->pos.z, - &iceShardEffect->rotation); + Matrix_SetTranslateRotateYXZ(iceShardEffect->pos.x, iceShardEffect->pos.y, iceShardEffect->pos.z, + &iceShardEffect->rotation); Matrix_Scale(iceShardEffect->scale, iceShardEffect->scale, iceShardEffect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h index f59a934bc..579ec5d50 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h @@ -97,7 +97,7 @@ typedef struct EnBigslime { /* 0x02C4 */ s16 numGekkoPosGrabPlayer; // The Gekko will melee-attack link at 6 positions while engulfed in bigslime /* 0x02C6 */ s16 subCamId; /* 0x02C8 */ s16 subCamYawGrabPlayer; - /* 0x02CA */ s16 rotation; // is always 0, used in Matrix_RotateY + /* 0x02CA */ s16 rotation; // is always 0, used in Matrix_RotateYS /* 0x02CC */ s16 itemDropTimer; // items only drop when zero, Set to 40 then decrements, prevents itemDrop spam /* 0x02CE */ Vec3s gekkoRot; /* 0x02D4 */ Vec3f gekkoPosOffset; // Used when Bigslime grabs link diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 43c09df0c..c60971034 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -428,7 +428,7 @@ void EnBji01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, sp20.x += temp_f4 * 0.1f; sp20.y += temp_f4 * 0.1f; sp20.z += temp_f4 * 0.1f; - Matrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); + Matrix_MultVec3f(&sp20, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/src/overlays/actors/ovl_En_Bom/z_en_bom.c index 70805438f..48550b656 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -383,8 +383,8 @@ void func_808715B8(EnBom* this, GlobalContext* globalCtx) { spCC = Rand_ZeroFloat(M_PI); for (i = 0; i < 15; i++) { - Matrix_InsertYRotation_f(((2.0f * (i * M_PI)) / 15.0f) + spCC, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ((10 - this->timer) * 300.0f * 0.1f, &spC0); + Matrix_RotateYF(((2.0f * (i * M_PI)) / 15.0f) + spCC, MTXMODE_NEW); + Matrix_MultVecZ((10 - this->timer) * 300.0f * 0.1f, &spC0); spB4.x = this->actor.world.pos.x + spC0.x; spB4.y = this->actor.world.pos.y + 500.0f; spB4.z = this->actor.world.pos.z + spC0.z; @@ -400,7 +400,7 @@ void func_808715B8(EnBom* this, GlobalContext* globalCtx) { sp84 = D_80872E94; sp80 = D_80872E94; } - Matrix_GetStateTranslationAndScaledZ(5.0f, &sp94); + Matrix_MultVecZ(5.0f, &sp94); sp88.x = sp88.z = 0.0f; sp94.y = 2.0f; sp88.y = 0.2f; @@ -606,14 +606,14 @@ void EnBom_Draw(Actor* thisx, GlobalContext* globalCtx) { if (!this->isPowderKeg) { func_800B8050(&this->actor, globalCtx, 0); - Matrix_MultiplyVector3fByState(&D_80872EE0, &this->actor.home.pos); + Matrix_MultVec3f(&D_80872EE0, &this->actor.home.pos); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_015FA0); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -629,15 +629,15 @@ void EnBom_Draw(Actor* thisx, GlobalContext* globalCtx) { s16 sp4A = this->actor.world.rot.y - this->actor.shape.rot.y; f32 sp44 = (1000.0f / Math_CosS(ABS_ALT((s16)(this->unk_1FA % 10922)) - 0x1555)) + -1000.0f; - Matrix_RotateY(sp4A, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, sp44, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_1FA, MTXMODE_APPLY); - Matrix_RotateY(-sp4A, MTXMODE_APPLY); + Matrix_RotateYS(sp4A, MTXMODE_APPLY); + Matrix_Translate(0.0f, sp44, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1FA, MTXMODE_APPLY); + Matrix_RotateYS(-sp4A, MTXMODE_APPLY); } - Matrix_MultiplyVector3fByState(&D_80872EEC, &this->actor.home.pos); - Matrix_MultiplyVector3fByState(&D_80872EF8, &sp58); - Matrix_MultiplyVector3fByState(&D_80872F04, &sp4C); + Matrix_MultVec3f(&D_80872EEC, &this->actor.home.pos); + Matrix_MultVec3f(&D_80872EF8, &sp58); + Matrix_MultVec3f(&D_80872F04, &sp4C); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -776,8 +776,8 @@ void func_80872BC0(GlobalContext* globalCtx, s32 arg1) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_InsertRotation(ptr->unk_1A, ptr->unk_18, 0, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateZYX(ptr->unk_1A, ptr->unk_18, 0, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -787,8 +787,8 @@ void func_80872BC0(GlobalContext* globalCtx, s32 arg1) { ptr2 = &D_80874650[1]; for (i = 1; i < temp_s5; i++, ptr2++) { - Matrix_InsertTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, MTXMODE_NEW); - Matrix_InsertRotation(ptr2->unk_1A, ptr2->unk_18, 0, MTXMODE_APPLY); + Matrix_Translate(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, MTXMODE_NEW); + Matrix_RotateZYX(ptr2->unk_1A, ptr2->unk_18, 0, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c index fc63795de..541fc071c 100644 --- a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c +++ b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c @@ -136,8 +136,8 @@ s32 EnBomChu_UpdateFloorPoly(EnBomChu* this, CollisionPoly* floorPoly, GlobalCon } Math_Vec3f_Scale(&vec, 1.0f / magnitude); - Matrix_InsertRotationAroundUnitVector_f(angle, &vec, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&this->axisLeft, &vec); + Matrix_RotateAxisF(angle, &vec, MTXMODE_NEW); + Matrix_MultVec3f(&this->axisLeft, &vec); Math_Vec3f_Copy(&this->axisLeft, &vec); Math3D_CrossProduct(&this->axisLeft, &normal, &this->axisForwards); @@ -156,18 +156,18 @@ void EnBomChu_UpdateRotation(EnBomChu* this) { MtxF mf; mf.xx = this->axisLeft.x; - mf.xy = this->axisLeft.y; - mf.xz = this->axisLeft.z; + mf.yx = this->axisLeft.y; + mf.zx = this->axisLeft.z; - mf.yx = this->axisUp.x; + mf.xy = this->axisUp.x; mf.yy = this->axisUp.y; - mf.yz = this->axisUp.z; + mf.zy = this->axisUp.z; - mf.zx = this->axisForwards.x; - mf.zy = this->axisForwards.y; + mf.xz = this->axisForwards.x; + mf.yz = this->axisForwards.y; mf.zz = this->axisForwards.z; - func_8018219C(&mf, &this->actor.world.rot, 0); + Matrix_MtxFToYXZRot(&mf, &this->actor.world.rot, false); this->actor.world.rot.x = -this->actor.world.rot.x; } @@ -205,13 +205,13 @@ s32 EnBomChu_IsOnCollisionPoly(GlobalContext* globalCtx, Vec3f* posA, Vec3f* pos void EnBomChu_SetupMove(EnBomChu* this) { func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(1.0f, &this->axisUp); - Matrix_GetStateTranslationAndScaledZ(1.0f, &this->axisForwards); - Matrix_GetStateTranslationAndScaledX(1.0f, &this->axisLeft); + Matrix_MultVecY(1.0f, &this->axisUp); + Matrix_MultVecZ(1.0f, &this->axisForwards); + Matrix_MultVecX(1.0f, &this->axisLeft); this->actor.world.rot.x = -this->actor.shape.rot.x; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -564,7 +564,7 @@ void EnBomChu_Draw(Actor* thisx, GlobalContext* globalCtx) { colorIntensity = blinkTime / (f32)blinkHalfPeriod; gDPSetEnvColor(POLY_OPA_DISP++, (s32)(colorIntensity * 209.0f) + 9, (s32)(colorIntensity * 34.0f) + 9, (s32)(colorIntensity * -35.0f) + 35, 255); - Matrix_InsertTranslation(this->visualJitter * (1.0f / BOMBCHU_SCALE), 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->visualJitter * (1.0f / BOMBCHU_SCALE), 0.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gBombchuDL); diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c index fef26002b..d4633c02d 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -450,7 +450,7 @@ Gfx* func_808AF86C(GraphicsContext* gfxCtx, GlobalContext* globalCtx) { Gfx* head = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 6); Gfx* gfx = head; - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(gfx++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPEndDisplayList(gfx++); @@ -473,7 +473,7 @@ void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, object_bombf_DL_000340); gSPDisplayList(POLY_OPA_DISP++, object_bombf_DL_000530); - Matrix_InsertTranslation(0.0f, 1000.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 1000.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(this->unk_204, this->unk_204, this->unk_204, MTXMODE_APPLY); } diff --git a/src/overlays/actors/ovl_En_Boom/z_en_boom.c b/src/overlays/actors/ovl_En_Boom/z_en_boom.c index 15347d0ea..4c3f6b241 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -325,19 +325,18 @@ void EnBoom_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); - - Matrix_InsertZRotation_s((this->actor.params != 0) ? 0x1F40 : -0x1F40, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.world.rot.x, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&sp58->unk_04, &sp4C); - Matrix_MultiplyVector3fByState(&sp58->unk_10, &sp40); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_RotateZS((this->actor.params != 0) ? 0x1F40 : -0x1F40, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.world.rot.x, MTXMODE_APPLY); + Matrix_MultVec3f(&sp58->unk_04, &sp4C); + Matrix_MultVec3f(&sp58->unk_10, &sp40); if (func_80126440(globalCtx, &this->collider, &this->weaponInfo, &sp4C, &sp40)) { EffectBlure_AddVertex(Effect_GetByIndex(this->effectIndex), &sp4C, &sp40); } func_8012C28C(globalCtx->state.gfxCtx); - Matrix_RotateY(this->unk_1CD * 0x2EE0, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_1CD * 0x2EE0, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, sp58->unk_00); diff --git a/src/overlays/actors/ovl_En_Bu/z_en_bu.c b/src/overlays/actors/ovl_En_Bu/z_en_bu.c index 937759ff6..ec0a0a6c2 100644 --- a/src/overlays/actors/ovl_En_Bu/z_en_bu.c +++ b/src/overlays/actors/ovl_En_Bu/z_en_bu.c @@ -53,10 +53,10 @@ void EnBu_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->displayListPtr); diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.c b/src/overlays/actors/ovl_En_Butte/z_en_butte.c index ea70a1480..0042442ff 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.c +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.c @@ -144,12 +144,12 @@ void func_8091C178(EnButte* this, GlobalContext* globalCtx) { sp48 = CLAMP(sp48, 0, 255); func_800DFC90(&sp40, GET_ACTIVE_CAM(globalCtx)); - Matrix_RotateY(sp40.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(sp40.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(sp40.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&D_8091D3A4, &sp4C); - Matrix_SetStateRotationAndTranslation(this->actor.focus.pos.x + sp4C.x, this->actor.focus.pos.y + sp4C.y, - this->actor.focus.pos.z + sp4C.z, &sp40); + Matrix_RotateYS(sp40.y, MTXMODE_NEW); + Matrix_RotateXS(sp40.x, MTXMODE_APPLY); + Matrix_RotateZS(sp40.z, MTXMODE_APPLY); + Matrix_MultVec3f(&D_8091D3A4, &sp4C); + Matrix_SetTranslateRotateYXZ(this->actor.focus.pos.x + sp4C.x, this->actor.focus.pos.y + sp4C.y, + this->actor.focus.pos.z + sp4C.z, &sp40); Matrix_Scale(D_8091D39C, D_8091D39C, D_8091D39C, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Cha/z_en_cha.c b/src/overlays/actors/ovl_En_Cha/z_en_cha.c index 0f340da3a..ae704672d 100644 --- a/src/overlays/actors/ovl_En_Cha/z_en_cha.c +++ b/src/overlays/actors/ovl_En_Cha/z_en_cha.c @@ -116,7 +116,7 @@ void EnCha_Draw(Actor* thisx, GlobalContext* globalCtx) { EnCha* this = THIS; Gfx_DrawDListOpa(globalCtx, object_cha_DL_000710); - Matrix_InsertTranslation(-1094.0f, 4950.0f, 9.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.home.rot.x, MTXMODE_APPLY); + Matrix_Translate(-1094.0f, 4950.0f, 9.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.home.rot.x, MTXMODE_APPLY); Gfx_DrawDListOpa(globalCtx, object_cha_DL_000958); } diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index cddff71cc..beb2f2d17 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -427,9 +427,9 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < 54; i++) { lightRayMaxScale = sLightRayMaxScale[thisx->params] + Rand_ZeroFloat(sLightRayMaxScale[thisx->params]); - Matrix_InsertYRotation_f(Rand_ZeroFloat(M_PI * 2), MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(M_PI * 2)); - Matrix_GetStateTranslationAndScaledZ(lightRayMaxScale, &vel); + Matrix_RotateYF(Rand_ZeroFloat(M_PI * 2), MTXMODE_NEW); + Matrix_RotateXFApply(Rand_ZeroFloat(M_PI * 2)); + Matrix_MultVecZ(lightRayMaxScale, &vel); accel.x = vel.x * -0.03f; accel.y = vel.y * -0.03f; accel.z = vel.z * -0.03f; @@ -478,8 +478,8 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { if (thisx->params != CLEAR_TAG_POP) { pos.y = this->actor.world.pos.y; for (i = 0; i < 18; i++) { - vel.x = __sinf(i * (33.0f / 40.0f)) * i * .5f; - vel.z = __cosf(i * (33.0f / 40.0f)) * i * .5f; + vel.x = sinf(i * (33.0f / 40.0f)) * i * .5f; + vel.z = cosf(i * (33.0f / 40.0f)) * i * .5f; vel.y = Rand_ZeroFloat(8.0f) + 7.0f; vel.x += randPlusMinusPoint5Scaled(0.5f); @@ -500,9 +500,9 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { pos = this->actor.world.pos; for (i = 0; i < 44; i++) { lightRayMaxScale = sLightRayMaxScale[thisx->params] + Rand_ZeroFloat(sLightRayMaxScale[thisx->params]); - Matrix_InsertYRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - Matrix_GetStateTranslationAndScaledZ(lightRayMaxScale, &vel); + Matrix_RotateYF(Rand_ZeroFloat(2 * M_PI), MTXMODE_NEW); + Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI)); + Matrix_MultVecZ(lightRayMaxScale, &vel); accel.x = vel.x * -0.03f; accel.y = vel.y * -0.03f; accel.z = vel.z * -0.03f; @@ -809,10 +809,10 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { } // Draw the debris effect. - Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); - Matrix_InsertYRotation_f(effect->rotationY, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(effect->rotationX); + Matrix_RotateYF(effect->rotationY, MTXMODE_APPLY); + Matrix_RotateXFApply(effect->rotationX); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gClearTagDebrisEffectDL); } @@ -828,7 +828,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, (s8)effect->primColor.a); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)effect->primColor.a); func_800C0094(this->actor.floorPoly, effect->position.x, effect->position.y, effect->position.z, &mtxF); - Matrix_SetCurrentState(&mtxF); + Matrix_Put(&mtxF); Matrix_Scale(effect->scale, 1.0f, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_030100); @@ -853,7 +853,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (s8)(effect->primColor.a * 0.7f)); func_800C0094(this->actor.floorPoly, effect->position.x, this->actor.floorHeight, effect->position.z, &mtxF); - Matrix_SetCurrentState(&mtxF); + Matrix_Put(&mtxF); Matrix_Scale(effect->scale * 3.0f, 1.0f, effect->scale * 3.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagFlashEffectGroundDL); @@ -881,10 +881,10 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gSPSegment( POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, -effect->actionTimer * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->smokeScaleX * effect->scale, effect->smokeScaleY * effect->scale, 1.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 20.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 20.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagFireEffectDL); } @@ -907,8 +907,8 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gSPSegment( POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, -effect->actionTimer * 15, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagFireEffectDL); @@ -929,8 +929,8 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Draw the flash billboard effect. gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (s8)effect->primColor.a); - Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(2.0f * effect->scale, 2.0f * effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagFlashEffectDL); @@ -954,12 +954,12 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Draw the light ray effect. gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)effect->primColor.r, (u8)effect->primColor.g, (u8)effect->primColor.b, (u8)effect->primColor.a); - Matrix_InsertTranslation(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(effect->rotationY, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(effect->rotationX); - Matrix_InsertZRotation_f(effect->rotationZ, MTXMODE_APPLY); + Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_RotateYF(effect->rotationY, MTXMODE_APPLY); + Matrix_RotateXFApply(effect->rotationX); + Matrix_RotateZF(effect->rotationZ, MTXMODE_APPLY); Matrix_Scale(effect->scale * 0.5f, effect->scale * 0.5f, effect->maxScale * effect->scale, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(M_PI / 2); + Matrix_RotateXFApply(M_PI / 2); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gClearTagLightRayEffectDL); } @@ -979,8 +979,8 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Apply material 16 times along a circle to give the appearance of a splash for (j = 0; j < 16; j++) { - Matrix_InsertYRotation_f(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(effect->maxScale, &vec); + Matrix_RotateYF(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_NEW); + Matrix_MultVecZ(effect->maxScale, &vec); /** * Get the water surface at point (`x`, `ySurface`, `z`). `ySurface` doubles as position y input * returns true if point is within the xz boundaries of an active water box, else false @@ -991,10 +991,9 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { effect->position.z + vec.z, &ySurface, &waterBox)) { if ((effect->position.y - ySurface) < 200.0f) { // Draw the splash effect. - Matrix_InsertTranslation(effect->position.x + vec.x, ySurface, effect->position.z + vec.z, - MTXMODE_NEW); - Matrix_InsertYRotation_f(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(effect->rotationX); + Matrix_Translate(effect->position.x + vec.x, ySurface, effect->position.z + vec.z, MTXMODE_NEW); + Matrix_RotateYF(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_APPLY); + Matrix_RotateXFApply(effect->rotationX); Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gExplosionSplashDL); diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index e65e0dfe9..1a35e8e50 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -245,7 +245,7 @@ s32 EnCne01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis bodyPart = gEnHyBodyParts[limbIndex]; if (bodyPart >= 0) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.bodyPartsPos[bodyPart]); + Matrix_MultVec3f(&zeroVec, &this->enHy.bodyPartsPos[bodyPart]); } if (limbIndex == CNE_LIMB_HEAD) { @@ -257,19 +257,19 @@ s32 EnCne01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == CNE_LIMB_HEAD) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->enHy.headRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->enHy.headRot.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->enHy.headRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->enHy.headRot.x, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == CNE_LIMB_TORSO) { - Matrix_InsertXRotation_s(-this->enHy.torsoRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->enHy.torsoRot.x, MTXMODE_APPLY); + Matrix_RotateXS(-this->enHy.torsoRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->enHy.torsoRot.x, MTXMODE_APPLY); } if ((limbIndex == CNE_LIMB_HEAD) && this->enHy.inMsgState3 && ((globalCtx->state.frames % 2) == 0)) { - Matrix_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if ((limbIndex == CNE_LIMB_TORSO) || (limbIndex == CNE_LIMB_LEFT_UPPER_ARM) || @@ -294,7 +294,7 @@ void EnCne01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } if (limbIndex == CNE_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.actor.focus.pos); + Matrix_MultVec3f(&zeroVec, &this->enHy.actor.focus.pos); } } @@ -317,7 +317,7 @@ void EnCne01_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawTransformFlexOpa(globalCtx, this->enHy.skelAnime.skeleton, this->enHy.skelAnime.jointTable, this->enHy.skelAnime.dListCount, EnCne01_OverrideLimbDraw, EnCne01_PostLimbDraw, EnCne01_TransformLimbDraw, &this->enHy.actor); - Matrix_InsertXRotation_s(0, MTXMODE_NEW); + Matrix_RotateXS(0, MTXMODE_NEW); for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { *shadowTexIter++ = 0; diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index 772d054ab..c3396fe29 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -414,7 +414,7 @@ void EnCow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnCow* this = THIS; if (limbIndex == COW_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_8099D63C, &this->actor.focus.pos); + Matrix_MultVec3f(&D_8099D63C, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.c b/src/overlays/actors/ovl_En_Crow/z_en_crow.c index bf77b1897..3ab93e1be 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.c +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.c @@ -551,12 +551,12 @@ void EnCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V EnCrow* this = (EnCrow*)thisx; if (limbIndex == OBJECT_CROW_LIMB_BODY) { - Matrix_GetStateTranslationAndScaledX(2500.0f, this->bodyPartsPos); + Matrix_MultVecX(2500.0f, this->bodyPartsPos); return; } if ((limbIndex == OBJECT_CROW_LIMB_RIGHT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_LEFT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_TAIL)) { - Matrix_GetStateTranslation(&this->bodyPartsPos[(limbIndex >> 1) - 1]); + Matrix_MultZero(&this->bodyPartsPos[(limbIndex >> 1) - 1]); } } diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index f8118e199..184a8b81b 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -74,7 +74,7 @@ void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { isDisplayListSet = true; } - Matrix_StatePush(); + Matrix_Push(); alpha = (particle->unk_02 / (f32)particle->unk_01); alpha *= 255.0f; @@ -85,15 +85,15 @@ void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (particle->unk_02 + (i * 3)) * 3, (particle->unk_02 + (i * 3)) * 15, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - Matrix_InsertTranslation(particle->unk_10.x, particle->unk_10.y, particle->unk_10.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(particle->unk_10.x, particle->unk_10.y, particle->unk_10.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(particle->unk_34, particle->unk_34, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_dai_DL_0002E8); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -580,7 +580,7 @@ s32 EnDai_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk_1E4); + Matrix_MultVec3f(&gZeroVec3f, &this->unk_1E4); } if (limbIndex == 10) { @@ -602,15 +602,15 @@ void EnDai_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve D_80B3FE4C.x = sREG(0); D_80B3FE4C.y = sREG(1); D_80B3FE4C.z = sREG(2); - Matrix_MultiplyVector3fByState(&D_80B3FE4C, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B3FE4C, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); - Matrix_CopyCurrentState(&sp24); - func_8018219C(&sp24, &sp64, 0); + Matrix_Get(&sp24); + Matrix_MtxFToYXZRot(&sp24, &sp64, false); this->unk_1D4 = BINANG_SUB(sp64.y, 0x4000); break; case 10: - Matrix_CopyCurrentState(&this->unk_18C); + Matrix_Get(&this->unk_18C); break; } } @@ -662,7 +662,7 @@ void func_80B3F78C(EnDai* this, GlobalContext* globalCtx) { this->skelAnime.dListCount, EnDai_OverrideLimbDraw, EnDai_PostLimbDraw, EnDai_TransformLimbDraw, &this->actor, POLY_XLU_DISP); if (this->unk_1CE & 0x40) { - Matrix_SetCurrentState(&this->unk_18C); + Matrix_Put(&this->unk_18C); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_dai_DL_00C538); @@ -694,7 +694,7 @@ void func_80B3F920(EnDai* this, GlobalContext* globalCtx) { POLY_OPA_DISP = SubS_DrawTransformFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnDai_OverrideLimbDraw, EnDai_PostLimbDraw, EnDai_TransformLimbDraw, &this->actor, POLY_OPA_DISP); - Matrix_SetCurrentState(&this->unk_18C); + Matrix_Put(&this->unk_18C); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dai_DL_00C538); @@ -713,7 +713,7 @@ void func_80B3F920(EnDai* this, GlobalContext* globalCtx) { POLY_XLU_DISP = SubS_DrawTransformFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnDai_OverrideLimbDraw, EnDai_PostLimbDraw, EnDai_TransformLimbDraw, &this->actor, POLY_XLU_DISP); - Matrix_SetCurrentState(&this->unk_18C); + Matrix_Put(&this->unk_18C); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_dai_DL_00C538); diff --git a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c index 64a8c3d9b..167c11835 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -549,17 +549,17 @@ void func_80BE7718(EnDaiku2* this, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { if (particle->isEnabled) { - Matrix_StatePush(); - Matrix_InsertTranslation(particle->unk_04.x, particle->unk_04.y, particle->unk_04.z, MTXMODE_NEW); - Matrix_InsertXRotation_s(particle->unk_28.x, MTXMODE_APPLY); - Matrix_RotateY(particle->unk_28.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(particle->unk_28.z, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(particle->unk_04.x, particle->unk_04.y, particle->unk_04.z, MTXMODE_NEW); + Matrix_RotateXS(particle->unk_28.x, MTXMODE_APPLY); + Matrix_RotateYS(particle->unk_28.y, MTXMODE_APPLY); + Matrix_RotateZS(particle->unk_28.z, MTXMODE_APPLY); Matrix_Scale(particle->unk_30, particle->unk_30, particle->unk_30, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_bombiwa_DL_0009E0); - Matrix_StatePop(); + Matrix_Pop(); } } } diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c index da9f37237..9486507bc 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -710,20 +710,20 @@ void EnDekunuts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis if (value != -1) { if (value < 3) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[value]); + Matrix_MultVecX(1000.0f, &this->limbPos[value]); } else { - Matrix_GetStateTranslation(&this->limbPos[value]); + Matrix_MultZero(&this->limbPos[value]); ptr1 = &D_808BEFA4[0]; ptr2 = &this->limbPos[value + 1]; for (i = value + 1; i < ARRAY_COUNT(this->limbPos); i++) { - Matrix_MultiplyVector3fByState(ptr1, ptr2); + Matrix_MultVec3f(ptr1, ptr2); ptr1++, ptr2++; } } } if (limbIndex == DEKU_SCRUB_LIMB_HEAD) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } @@ -732,8 +732,8 @@ void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDekunuts_OverrideLimbDraw, EnDekunuts_PostLimbDraw, &this->actor); - Matrix_SetStateRotationAndTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, - &this->actor.home.rot); + Matrix_SetTranslateRotateYXZ(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, + &this->actor.home.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (this->actor.colorFilterTimer != 0) { func_800AE5A0(globalCtx); diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index 23bd7e183..b56063880 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -202,8 +202,8 @@ void func_8098933C(EnDg* this, Vec3f* arg1) { sp20 = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); sp1C = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); - __sinf(0.0f); - __cosf(0.0f); + sinf(0.0f); + cosf(0.0f); arg1->x = -Math_Acot2F(1.0f, -sp1C * sp20); arg1->z = Math_Acot2F(1.0f, -sp24 * sp20); } @@ -1190,9 +1190,9 @@ void EnDg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (limbIndex == DOG_LIMB_HEAD) { if (this->actionFunc == func_8098BBEC) { sp20.x = 5000.0f; - Matrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); + Matrix_MultVec3f(&sp20, &this->actor.focus.pos); } else if (this->actionFunc != func_8098BC54) { - Matrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); + Matrix_MultVec3f(&sp20, &this->actor.focus.pos); } } } @@ -1236,10 +1236,10 @@ void EnDg_Draw(Actor* thisx, GlobalContext* globalCtx) { break; } - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(this->unk_294.x); - Matrix_InsertZRotation_f(this->unk_294.z, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateXFApply(this->unk_294.x); + Matrix_RotateZF(this->unk_294.z, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnDg_OverrideLimbDraw, EnDg_PostLimbDraw, &this->actor); diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index e06e2e776..d093f29ff 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -1429,15 +1429,15 @@ void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Collider_UpdateSpheres(limbIndex, &this->colliderJntSph); if (D_8089E3B0[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[D_8089E3B0[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_8089E3B0[limbIndex]]); } if ((limbIndex == 14) && (this->unk_292 != this->unk_290) && ((this->actionFunc == func_8089C56C) || (this->actionFunc == func_8089C2A8))) { Math_Vec3f_Copy(&sp74, &this->colliderQuad.dim.quad[0]); Math_Vec3f_Copy(&sp80, &this->colliderQuad.dim.quad[1]); - Matrix_MultiplyVector3fByState(&D_8089E38C, &sp68); - Matrix_MultiplyVector3fByState(&D_8089E398, &sp5C); + Matrix_MultVec3f(&D_8089E38C, &sp68); + Matrix_MultVec3f(&D_8089E398, &sp5C); Collider_SetQuadVertices(&this->colliderQuad, &sp5C, &sp68, &sp74, &sp80); if (this->colliderQuad.base.atFlags & AT_ON) { EffectBlure_AddVertex(Effect_GetByIndex(this->unk_2A0), &sp68, &sp5C); @@ -1446,18 +1446,18 @@ void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } if (limbIndex == 4) { - Matrix_GetStateTranslationAndScaledX(300.0f, &this->actor.shape.feetPos[0]); + Matrix_MultVecX(300.0f, &this->actor.shape.feetPos[0]); } else if (limbIndex == 7) { - Matrix_GetStateTranslationAndScaledX(300.0f, &this->actor.shape.feetPos[1]); + Matrix_MultVecX(300.0f, &this->actor.shape.feetPos[1]); } if ((limbIndex == 16) && (this->actionFunc == func_8089B580)) { if ((this->skelAnime.curFrame > 38.0f) && (this->skelAnime.curFrame <= 55.0f) && (this->unk_292 != this->unk_290)) { - sp48 = Matrix_GetCurrentState(); + sp48 = Matrix_GetCurrent(); sp58 = 48 - (s32)this->skelAnime.curFrame; sp58 = CLAMP_MIN(sp58, 0); - Matrix_MultiplyVector3fByState(&D_8089E3A4, &sp4C); + Matrix_MultVec3f(&D_8089E3A4, &sp4C); sp4C.x -= sp48->mf[3][0]; sp4C.y -= sp48->mf[3][1]; sp4C.z -= sp48->mf[3][2]; diff --git a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c index d074753be..914e0f355 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c @@ -159,17 +159,17 @@ void func_80A50510(EnDnb* this, GlobalContext* globalCtx) { func_8012C2DC(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - Matrix_StatePush(); - Matrix_InsertTranslation(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, this->particles[i].unk_0C.z, - MTXMODE_NEW); - Matrix_InsertXRotation_s(this->particles[i].unk_18.x, MTXMODE_APPLY); - Matrix_RotateY(this->particles[i].unk_18.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->particles[i].unk_18.z, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, this->particles[i].unk_0C.z, + MTXMODE_NEW); + Matrix_RotateXS(this->particles[i].unk_18.x, MTXMODE_APPLY); + Matrix_RotateYS(this->particles[i].unk_18.y, MTXMODE_APPLY); + Matrix_RotateZS(this->particles[i].unk_18.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gfx[i]); - Matrix_StatePop(); + Matrix_Pop(); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -184,17 +184,17 @@ void func_80A5063C(EnDnb* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - Matrix_StatePush(); - Matrix_InsertTranslation(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, this->particles[i].unk_0C.z, - MTXMODE_NEW); - Matrix_InsertXRotation_s(this->particles[i].unk_18.x, MTXMODE_APPLY); - Matrix_RotateY(this->particles[i].unk_18.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->particles[i].unk_18.z, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, this->particles[i].unk_0C.z, + MTXMODE_NEW); + Matrix_RotateXS(this->particles[i].unk_18.x, MTXMODE_APPLY); + Matrix_RotateYS(this->particles[i].unk_18.y, MTXMODE_APPLY); + Matrix_RotateZS(this->particles[i].unk_18.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gfx[i]); - Matrix_StatePop(); + Matrix_Pop(); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -275,16 +275,16 @@ s32 func_80A50950(EnDnbUnkStruct* arg0, GlobalContext* globalCtx2) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 0); isGfxSetup = true; } - Matrix_StatePush(); + Matrix_Push(); if (1) {}; arg0->unk_24 = (arg0->unk_01 / (f32)arg0->unk_02) * 255.0f; gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)arg0->unk_24); - Matrix_InsertTranslation(arg0->unk_0C.x, arg0->unk_0C.y, arg0->unk_0C.z, MTXMODE_NEW); + Matrix_Translate(arg0->unk_0C.x, arg0->unk_0C.y, arg0->unk_0C.z, MTXMODE_NEW); Matrix_Scale(arg0->unk_04, arg0->unk_04, 1.0f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -292,7 +292,7 @@ s32 func_80A50950(EnDnbUnkStruct* arg0, GlobalContext* globalCtx2) { gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A50CBC[idx])); gSPDisplayList(POLY_XLU_DISP++, object_hanareyama_obj_DL_000020); - Matrix_StatePop(); + Matrix_Pop(); sp5C += 1; } } diff --git a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c index 99c5d23d9..62b040c9e 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -285,10 +285,10 @@ void func_80A51AA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Vec3s sp3C; if (limbIndex == 2) { - Matrix_MultiplyVector3fByState(&sp50, &sp44); - Matrix_CopyCurrentState(&sp5C); - func_8018219C(&sp5C, &sp3C, 0); - Matrix_InsertTranslation(sp44.x, sp44.y, sp44.z, MTXMODE_NEW); + Matrix_MultVec3f(&sp50, &sp44); + Matrix_Get(&sp5C); + Matrix_MtxFToYXZRot(&sp5C, &sp3C, false); + Matrix_Translate(sp44.x, sp44.y, sp44.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (this->unk_28C & 0x10) { if (this->unk_28C & 0x20) { @@ -311,9 +311,9 @@ void func_80A51AA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* this->unk_294 = sp3C.z; } - Matrix_RotateY(this->unk_292, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_290, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_294, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_292, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_290, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_294, MTXMODE_APPLY); } OPEN_DISPS(globalCtx->state.gfxCtx); @@ -361,10 +361,10 @@ void func_80A51DA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Vec3s sp3C; if (limbIndex == 2) { - Matrix_MultiplyVector3fByState(&sp50, &sp44); - Matrix_CopyCurrentState(&sp5C); - func_8018219C(&sp5C, &sp3C, 0); - Matrix_InsertTranslation(sp44.x, sp44.y, sp44.z, MTXMODE_NEW); + Matrix_MultVec3f(&sp50, &sp44); + Matrix_Get(&sp5C); + Matrix_MtxFToYXZRot(&sp5C, &sp3C, false); + Matrix_Translate(sp44.x, sp44.y, sp44.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (this->unk_28C & 0x10) { @@ -388,9 +388,9 @@ void func_80A51DA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* this->unk_294 = sp3C.z; } - Matrix_RotateY(this->unk_292, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_290, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_294, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_292, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_290, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_294, MTXMODE_APPLY); } OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.c b/src/overlays/actors/ovl_En_Dno/z_en_dno.c index e774c8965..326f3fbf2 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -152,8 +152,8 @@ void func_80A715DC(EnDno* this, GlobalContext* globalCtx) { if (SubS_LineSegVsPlane(&crace->actor.home.pos, &crace->actor.home.rot, &D_80A73B2C, &this->actor.prevPos, &this->actor.world.pos, &sp88)) { Math_Vec3f_Diff(&this->actor.world.pos, &crace->actor.home.pos, &sp7C); - Matrix_RotateY(-crace->actor.home.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp7C, &sp70); + Matrix_RotateYS(-crace->actor.home.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp7C, &sp70); if ((fabsf(sp70.x) < 100.0f) && (sp70.y >= -10.0f) && (sp70.y <= 180.0f) && (sp70.z < 0.0f)) { crace->unk_170 |= 1; } @@ -970,7 +970,7 @@ void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve func_8012C28C(globalCtx->state.gfxCtx); if (limbIndex == 13) { Matrix_Scale(this->unk_454, this->unk_454, this->unk_454, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_45C, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_45C, MTXMODE_APPLY); } gfxOpa = POLY_OPA_DISP; @@ -986,13 +986,13 @@ void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); frames = globalCtx->gameplayFrames; - Matrix_MultiplyVector3fByState(&D_80A73B40, &sp84); + Matrix_MultVec3f(&D_80A73B40, &sp84); func_80A711D0(this, globalCtx, &sp84); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(0.15f, 0.15f, 1.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -3200.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, -3200.0f, 0.0f, MTXMODE_APPLY); gfxXlu = func_8012C2B4(POLY_XLU_DISP); gSPMatrix(gfxXlu, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1004,7 +1004,7 @@ void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve POLY_XLU_DISP = gfxXlu + 5; - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c index 3e9bd9f6e..a4ea26f37 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -425,9 +425,9 @@ s32 func_80B3D974(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar Vec3s sp6C; MtxF sp2C; - Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp74); - Matrix_CopyCurrentState(&sp2C); - func_8018219C(&sp2C, &sp6C, 0); + Matrix_MultVec3f(&gZeroVec3f, &sp74); + Matrix_Get(&sp2C); + Matrix_MtxFToYXZRot(&sp2C, &sp6C, false); *arg2 = sp74; if (arg4 == 0) { if (arg5 != 0) { @@ -468,13 +468,13 @@ void EnDnp_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi if (limbIndex == 12) { func_80B3D974(this->unk_330 + 0x4000, this->unk_332 + this->actor.shape.rot.y + 0x4000, &this->unk_1D8, &this->unk_1E4, phi_v1, phi_v0); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1D8.x, this->unk_1D8.y, this->unk_1D8.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_1D8.x, this->unk_1D8.y, this->unk_1D8.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_1E4.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_1E4.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_1E4.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_1E4.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1E4.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_1E4.z, MTXMODE_APPLY); + Matrix_Push(); } } diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c index 6b7943504..1cad6dd8f 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -380,8 +380,8 @@ void func_8092D108(EnDns* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); - Matrix_SetStateRotationAndTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, - &this->actor.home.rot); + Matrix_SetTranslateRotateYXZ(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, + &this->actor.home.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -566,9 +566,9 @@ s32 func_8092D954(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar Vec3s sp6C; MtxF sp2C; - Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp74); - Matrix_CopyCurrentState(&sp2C); - func_8018219C(&sp2C, &sp6C, 0); + Matrix_MultVec3f(&gZeroVec3f, &sp74); + Matrix_Get(&sp2C); + Matrix_MtxFToYXZRot(&sp2C, &sp6C, false); *arg2 = sp74; if (arg4 == 0) { @@ -617,11 +617,11 @@ void EnDns_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve if (limbIndex == KINGS_CHAMBER_DEKU_GUARD_LIMB_HEAD) { func_8092D954(this->unk_2CC, this->unk_2CE + this->actor.shape.rot.y, &this->unk_218, &this->unk_224, phi_v1, phi_v0); - Matrix_InsertTranslation(this->unk_218.x, this->unk_218.y, this->unk_218.z, MTXMODE_NEW); + Matrix_Translate(this->unk_218.x, this->unk_218.y, this->unk_218.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_224.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_224.z, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_224.x, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_224.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_224.z, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_224.x, MTXMODE_APPLY); } OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c index a630a0dcb..914ee2bca 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -1081,16 +1081,16 @@ void EnDodongo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Collider_UpdateSpheres(limbIndex, &this->collider1); Collider_UpdateSpheres(limbIndex, &this->collider2); if (D_80879388[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[D_80879388[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_80879388[limbIndex]]); } if (limbIndex == 7) { - Matrix_MultiplyVector3fByState(&D_80879370, &this->unk_308); - Matrix_MultiplyVector3fByState(&D_8087937C, &this->limbPos[0]); - Matrix_GetStateTranslation(&this->actor.focus.pos); - Matrix_GetStateTranslationAndScaledY(-200.0f, &this->limbPos[1]); + Matrix_MultVec3f(&D_80879370, &this->unk_308); + Matrix_MultVec3f(&D_8087937C, &this->limbPos[0]); + Matrix_MultZero(&this->actor.focus.pos); + Matrix_MultVecY(-200.0f, &this->limbPos[1]); } else if (limbIndex == 13) { - Matrix_GetStateTranslationAndScaledX(1600.0f, &this->unk_320); + Matrix_MultVecX(1600.0f, &this->unk_320); } if ((limbIndex == 30) && (this->actionFunc == func_80878424) && (this->timer != this->unk_304)) { diff --git a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c index efd901eb3..a37d8f828 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c @@ -725,7 +725,7 @@ void EnDragon_UpdateDamage(EnDragon* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); u32 sp30; - if ((this->action == DEEP_PYTHON_ACTION_EXTEND)) { + if (this->action == DEEP_PYTHON_ACTION_EXTEND) { if ((this->collider.elements[2].info.bumperFlags & BUMP_HIT) || (this->collider.elements[3].info.bumperFlags & BUMP_HIT) || (this->collider.elements[4].info.bumperFlags & BUMP_HIT) || @@ -816,15 +816,15 @@ void EnDragon_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f playerGrabOffsetFromJawPos = { 350.0f, -120.0f, -60.0f }; if (limbIndex == DEEP_PYTHON_LIMB_JAW) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->jawPos); + Matrix_MultVec3f(&gZeroVec3f, &this->jawPos); playerGrabOffsetFromJawPos.x = 350.0f; playerGrabOffsetFromJawPos.y = -120.0f; playerGrabOffsetFromJawPos.z = -60.0f; - Matrix_MultiplyVector3fByState(&playerGrabOffsetFromJawPos, &this->playerGrabPosition); + Matrix_MultVec3f(&playerGrabOffsetFromJawPos, &this->playerGrabPosition); } if (limbIndex == DEEP_PYTHON_LIMB_HEAD_AND_COLLAR_ROOT) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->focusPos); + Matrix_MultVec3f(&gZeroVec3f, &this->focusPos); } Collider_UpdateSpheres(limbIndex, &this->collider); diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index a3a433cf1..f71c0b30d 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -1558,8 +1558,8 @@ s32 EnElf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } scale *= this->actor.scale.x * 124.99999f; - Matrix_MultiplyVector3fByState(&zeroVec, &sp34); - Matrix_InsertTranslation(sp34.x, sp34.y, sp34.z, MTXMODE_NEW); + Matrix_MultVec3f(&zeroVec, &sp34); + Matrix_Translate(sp34.x, sp34.y, sp34.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); } diff --git a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c index 3693b258b..ec64038ce 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c @@ -153,12 +153,12 @@ void EnElfbub_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, 0.0f, 1.0f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(0.0f, 0.0f, 1.0f, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(this->xyScale + 1.0f, this->xyScale + 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->zRot, MTXMODE_APPLY); + Matrix_RotateZS(this->zRot, MTXMODE_APPLY); Matrix_Scale(this->xScale + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->zRot * -1, MTXMODE_APPLY); + Matrix_RotateZS(this->zRot * -1, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_bubble_DL_001000); diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index 7676a9b78..16139fa08 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -611,7 +611,7 @@ void EnElforg_Draw(Actor* thisx, GlobalContext* globalCtx) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gStrayFairyClockTownTexAnim)); break; } - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index 83f04b013..ea7ee7aa4 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -274,7 +274,7 @@ void EnEncount2_DrawParticles(EnEncount2* this, GlobalContext* globalCtx) { func_8012C2DC(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->particles); i++, sPtr++) { if (sPtr->enabled) { - Matrix_InsertTranslation(sPtr->pos.x, sPtr->pos.y, sPtr->pos.z, MTXMODE_NEW); + Matrix_Translate(sPtr->pos.x, sPtr->pos.y, sPtr->pos.z, MTXMODE_NEW); Matrix_Scale(sPtr->scale, sPtr->scale, sPtr->scale, MTXMODE_APPLY); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); @@ -282,8 +282,8 @@ void EnEncount2_DrawParticles(EnEncount2* this, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 255, sPtr->alpha); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_f(DEGTORAD(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZF(DEGTORAD(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB58); diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.c b/src/overlays/actors/ovl_En_Fall/z_en_fall.c index dabd62e0f..b84eb3d74 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -737,7 +737,7 @@ void EnFall_Moon_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - Matrix_MultiplyVector3fByState(sFocusOffset, &this->actor.focus.pos); + Matrix_MultVec3f(sFocusOffset, &this->actor.focus.pos); primColor = (this->eyeGlowIntensity * 200.0f) + 40.0f; gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, primColor, primColor, primColor, 255); @@ -807,11 +807,11 @@ void EnFall_LodMoon_DrawWithLerp(Actor* thisx, GlobalContext* globalCtx) { translation.x = (-(globalCtx->view.eye.x - thisx->world.pos.x) * scale) + globalCtx->view.eye.x; translation.y = (-(globalCtx->view.eye.y - thisx->world.pos.y) * scale) + globalCtx->view.eye.y; translation.z = (-(globalCtx->view.eye.z - thisx->world.pos.z) * scale) + globalCtx->view.eye.z; - Matrix_InsertTranslation(translation.x, translation.y, translation.z, MTXMODE_NEW); + Matrix_Translate(translation.x, translation.y, translation.z, MTXMODE_NEW); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); - Matrix_RotateY(thisx->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(thisx->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(thisx->shape.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(thisx->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(thisx->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(thisx->shape.rot.z, MTXMODE_APPLY); } EnFall_LodMoon_Draw(thisx, globalCtx); @@ -870,11 +870,10 @@ void EnFall_RisingDebris_Draw(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(debrisParticles); i++) { if (debrisParticles[i].modelIndex < 3) { - Matrix_InsertTranslation(debrisParticles[i].pos.x, debrisParticles[i].pos.y, debrisParticles[i].pos.z, - MTXMODE_NEW); + Matrix_Translate(debrisParticles[i].pos.x, debrisParticles[i].pos.y, debrisParticles[i].pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_InsertRotation(debrisParticles[i].rot.x, debrisParticles[i].rot.y, debrisParticles[i].rot.z, - MTXMODE_APPLY); + Matrix_RotateZYX(debrisParticles[i].rot.x, debrisParticles[i].rot.y, debrisParticles[i].rot.z, + MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, sDebrisModelDLists[debrisParticles[i].modelIndex]); diff --git a/src/overlays/actors/ovl_En_Famos/z_en_famos.c b/src/overlays/actors/ovl_En_Famos/z_en_famos.c index cc8c799ee..42ff95aba 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.c +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.c @@ -799,9 +799,9 @@ s32 EnFamos_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis EnFamos* this = THIS; if (limbIndex == FAMOS_LIMB_BODY) { - Matrix_InsertTranslation(0.0f, 4000.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->flipRot, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -4000.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 4000.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->flipRot, MTXMODE_APPLY); + Matrix_Translate(0.0f, -4000.0f, 0.0f, MTXMODE_APPLY); } else if (this->flippedTimer < 0) { // if set to -1, famos is dying if ((limbIndex == FAMOS_LIMB_SWORD) || (limbIndex == FAMOS_LIMB_SHIELD) || (limbIndex == FAMOS_LIMB_HEAD)) { @@ -816,7 +816,7 @@ void EnFamos_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnFamos* this = THIS; if (limbIndex == FAMOS_LIMB_EMBLEM) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); Collider_UpdateSpheres(limbIndex, &this->emblemCollider); } } @@ -840,7 +840,7 @@ void EnFamos_DrawDebris(EnFamos* this, GlobalContext* globalCtx) { rock = &this->rocks[0]; for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { - Matrix_SetStateRotationAndTranslation(rock->pos.x, rock->pos.y, rock->pos.z, &rock->rotation); + Matrix_SetTranslateRotateYXZ(rock->pos.x, rock->pos.y, rock->pos.z, &rock->rotation); Matrix_Scale(rock->scale, rock->scale, rock->scale, MTXMODE_APPLY); gSPMatrix(&dispOpa[3 + i * 2], Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_En_Fg/z_en_fg.c b/src/overlays/actors/ovl_En_Fg/z_en_fg.c index 060678506..bd3bd9e29 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.c +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.c @@ -377,16 +377,16 @@ void EnFg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if ((limbIndex == 7) || (limbIndex == 8)) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Push(); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, *dList); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&vec1, &this->actor.focus.pos); + Matrix_MultVec3f(&vec1, &this->actor.focus.pos); } } @@ -398,9 +398,9 @@ void EnFg_Draw(Actor* thisx, GlobalContext* globalCtx) { { 120, 130, 230, 255 }, { 190, 190, 190, 255 }, { 0, 0, 0, 255 }, }; - Matrix_StatePush(); + Matrix_Push(); EnFg_DrawDust(globalCtx, &this->dustEffect[0]); - Matrix_StatePop(); + Matrix_Pop(); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); @@ -471,8 +471,8 @@ void EnFg_DrawDust(GlobalContext* globalCtx, EnFgEffectDust* dustEffect) { alpha = (255.0f / 16.0f) * dustEffect->timer; gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, alpha); gDPPipeSync(POLY_XLU_DISP++); - Matrix_InsertTranslation(dustEffect->pos.x, dustEffect->pos.y, dustEffect->pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(dustEffect->pos.x, dustEffect->pos.y, dustEffect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(dustEffect->xyScale, dustEffect->xyScale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c index 711b4ca6e..677edb81a 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -760,7 +760,7 @@ void EnFirefly_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList ((this->auraType == KEESE_AURA_FIRE) || (this->auraType == KEESE_AURA_ICE)) && ((limbIndex == 15) || (limbIndex == 21))) { if (this->actionFunc != EnFirefly_Die) { - Matrix_GetStateTranslation(&auraPos); + Matrix_MultZero(&auraPos); auraPos.x += Rand_ZeroFloat(5.0f); auraPos.y += Rand_ZeroFloat(5.0f); auraPos.z += Rand_ZeroFloat(5.0f); @@ -793,11 +793,11 @@ void EnFirefly_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } if (limbIndex == 15) { - Matrix_GetStateTranslation(&this->limbPos[0]); + Matrix_MultZero(&this->limbPos[0]); } else if (limbIndex == 21) { - Matrix_GetStateTranslation(&this->limbPos[1]); + Matrix_MultZero(&this->limbPos[1]); } else if (limbIndex == 10) { - Matrix_GetStateTranslation(&this->limbPos[2]); + Matrix_MultZero(&this->limbPos[2]); } } diff --git a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c index f86cda7d8..bceaa7225 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -1053,23 +1053,23 @@ void EnFish2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if ((limbIndex == 20) || (limbIndex == 21)) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Push(); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, *dList); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == 14) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk_318); + Matrix_MultVec3f(&gZeroVec3f, &this->unk_318); } if (limbIndex == 17) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk_300); + Matrix_MultVec3f(&gZeroVec3f, &this->unk_300); } Collider_UpdateSpheres(limbIndex, &this->collider); @@ -1161,7 +1161,7 @@ void func_80B2B180(EnFish2* this, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(this->unk_3F8); i++, ptr++) { if (ptr->unk_00) { - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_14, ptr->unk_14, ptr->unk_14, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); 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 6dc9ff081..668033cd6 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -570,9 +570,9 @@ void EnFishing_SpawnRainDrop(FishingEffect* effect, Vec3f* pos, Vec3f* rot) { effect->unk_34 = rot->x; effect->unk_38 = rot->y; effect->unk_3C = rot->z; - Matrix_InsertYRotation_f(rot->y, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(rot->x); - Matrix_MultiplyVector3fByState(&velSrc, &effect->vel); + Matrix_RotateYF(rot->y, MTXMODE_NEW); + Matrix_RotateXFApply(rot->x); + Matrix_MultVec3f(&velSrc, &effect->vel); break; } @@ -896,14 +896,14 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { fish->type = FS_GROUP_FISH_NORMAL; if (i <= 20) { - fish->unk_10.x = fish->pos.x = __sinf(sFishGroupAngle1) * 720.0f; - fish->unk_10.z = fish->pos.z = __cosf(sFishGroupAngle1) * 720.0f; + fish->unk_10.x = fish->pos.x = sinf(sFishGroupAngle1) * 720.0f; + fish->unk_10.z = fish->pos.z = cosf(sFishGroupAngle1) * 720.0f; } else if (i <= 40) { - fish->unk_10.x = fish->pos.x = __sinf(sFishGroupAngle2) * 720.0f; - fish->unk_10.z = fish->pos.z = __cosf(sFishGroupAngle2) * 720.0f; + fish->unk_10.x = fish->pos.x = sinf(sFishGroupAngle2) * 720.0f; + fish->unk_10.z = fish->pos.z = cosf(sFishGroupAngle2) * 720.0f; } else { - fish->unk_10.x = fish->pos.x = __sinf(sFishGroupAngle3) * 720.0f; - fish->unk_10.z = fish->pos.z = __cosf(sFishGroupAngle3) * 720.0f; + fish->unk_10.x = fish->pos.x = sinf(sFishGroupAngle3) * 720.0f; + fish->unk_10.z = fish->pos.z = cosf(sFishGroupAngle3) * 720.0f; } fish->unk_10.y = fish->pos.y = -35.0f; @@ -1150,7 +1150,7 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); gDPPipeSync(POLY_XLU_DISP++); @@ -1164,7 +1164,7 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, effect->alpha); - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_Scale(effect->unk_30, 1.0f, effect->unk_30, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1187,8 +1187,8 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 180, 180, 180, effect->alpha); - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1215,8 +1215,8 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, effect->timer + (i * 3), (effect->timer + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1238,8 +1238,8 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { flag++; } - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1261,10 +1261,10 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { flag++; } - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(effect->unk_38, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(effect->unk_34); - Matrix_InsertZRotation_f(effect->unk_3C, MTXMODE_APPLY); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateYF(effect->unk_38, MTXMODE_APPLY); + Matrix_RotateXFApply(effect->unk_34); + Matrix_RotateZF(effect->unk_3C, MTXMODE_APPLY); Matrix_Scale(0.002f, 1.0f, 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1288,7 +1288,7 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { flag++; } - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_Scale(effect->unk_30, 1.0f, effect->unk_30, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1315,9 +1315,9 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { rotY = M_PI; } - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_InsertYRotation_f(rotY, MTXMODE_APPLY); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_RotateYF(rotY, MTXMODE_APPLY); Matrix_Scale(effect->unk_30, effect->unk_30, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1330,19 +1330,19 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { effect = firstEffect; if (effect->type == FS_EFF_OWNER_HAT) { - Matrix_InsertTranslation(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f((sEffOwnerHatRot.y * M_PI) / 32768, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis((sEffOwnerHatRot.x * M_PI) / 32768); - Matrix_InsertZRotation_f((sEffOwnerHatRot.z * M_PI) / 32768, MTXMODE_APPLY); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateYF((sEffOwnerHatRot.y * M_PI) / 32768, MTXMODE_APPLY); + Matrix_RotateXFApply((sEffOwnerHatRot.x * M_PI) / 32768); + Matrix_RotateZF((sEffOwnerHatRot.z * M_PI) / 32768, MTXMODE_APPLY); Matrix_Scale(effect->unk_30, effect->unk_30, effect->unk_30, MTXMODE_APPLY); - Matrix_InsertTranslation(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(M_PI / 2); + Matrix_Translate(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXFApply(M_PI / 2); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHatDL); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1358,7 +1358,7 @@ void EnFishing_DrawStreamSplash(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, 50); - Matrix_InsertTranslation(670.0f, -24.0f, -600.0f, MTXMODE_NEW); + Matrix_Translate(670.0f, -24.0f, -600.0f, MTXMODE_NEW); Matrix_Scale(0.02f, 1.0f, 0.02f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1494,9 +1494,9 @@ void EnFishing_UpdateLine(GlobalContext* globalCtx, Vec3f* basePos, Vec3f* pos, (rot + i - 1)->y = ry; (rot + i - 1)->x = rx; - Matrix_InsertYRotation_f(ry, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(rx); - Matrix_MultiplyVector3fByState(&posSrc, &posStep); + Matrix_RotateYF(ry, MTXMODE_NEW); + Matrix_RotateXFApply(rx); + Matrix_MultVec3f(&posSrc, &posStep); (pos + i)->x = (pos + i - 1)->x + posStep.x; (pos + i)->y = (pos + i - 1)->y + posStep.y; @@ -1527,9 +1527,9 @@ void EnFishing_UpdateLinePos(Vec3f* pos) { dist = sqrtf(SQ(dx) + SQ(dz)); rx = -Math_Acot2F(dist, dy); - Matrix_InsertYRotation_f(ry, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(rx); - Matrix_MultiplyVector3fByState(&posSrc, &posStep); + Matrix_RotateYF(ry, MTXMODE_NEW); + Matrix_RotateXFApply(rx); + Matrix_MultVec3f(&posSrc, &posStep); (pos + i)->x = (pos + i + 1)->x + posStep.x; (pos + i)->y = (pos + i + 1)->y + posStep.y; @@ -1551,7 +1551,7 @@ void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); if ((D_8090CD14 == 3) && ((pos->y > WATER_SURFACE_Y(globalCtx)) || ((D_8090CD0C != 0) && hookIndex))) { offsetY = 0.0f; @@ -1569,15 +1569,15 @@ void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, dist = sqrtf(SQ(dx) + SQ(dz)); rx = -Math_Acot2F(dist, dy); - Matrix_InsertYRotation_f(ry, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(rx); - Matrix_MultiplyVector3fByState(&posSrc, &posStep); + Matrix_RotateYF(ry, MTXMODE_NEW); + Matrix_RotateXFApply(rx); + Matrix_MultVec3f(&posSrc, &posStep); refPos->x = pos->x + posStep.x; refPos->y = pos->y + posStep.y; refPos->z = pos->z + posStep.z; - Matrix_InsertTranslation(pos->x, pos->y, pos->z, MTXMODE_NEW); + Matrix_Translate(pos->x, pos->y, pos->z, MTXMODE_NEW); if ((player->actor.speedXZ == 0.0f) && (D_809101B4 == 0.0f)) { Math_ApproachF(&sLureHookRotY[hookIndex], ry, 0.1f, 0.3f); @@ -1585,31 +1585,31 @@ void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, sLureHookRotY[hookIndex] = ry; } - Matrix_InsertYRotation_f(sLureHookRotY[hookIndex], MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(rx); + Matrix_RotateYF(sLureHookRotY[hookIndex], MTXMODE_APPLY); + Matrix_RotateXFApply(rx); Matrix_Scale(0.0039999997f, 0.0039999997f, 0.005f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingLureHookDL); - Matrix_InsertZRotation_f(M_PI / 2, MTXMODE_APPLY); + Matrix_RotateZF(M_PI / 2, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingLureHookDL); if ((hookIndex == 1) && (D_8090CD0C != 0)) { Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(250.0f, 0.0f, -1400.0f, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_Translate(250.0f, 0.0f, -1400.0f, MTXMODE_APPLY); + Matrix_Push(); if (D_8090CD10 != 0) { FishingEffect* effect = globalCtx->specialEffects; MtxF mf; - Matrix_MultiplyVector3fByState(&sZeroVec, &effect->pos); - Matrix_CopyCurrentState(&mf); - func_8018219C(&mf, &sEffOwnerHatRot, 0); + Matrix_MultVec3f(&sZeroVec, &effect->pos); + Matrix_Get(&mf); + Matrix_MtxFToYXZRot(&mf, &sEffOwnerHatRot, false); D_8090CD10 = 0; D_8090CD0C = 0; @@ -1620,15 +1620,15 @@ void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, effect->accel = sZeroVec; } - Matrix_StatePop(); - Matrix_InsertTranslation(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(M_PI / 2); + Matrix_Pop(); + Matrix_Translate(-1250.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXFApply(M_PI / 2); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHatDL); } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1665,11 +1665,11 @@ void EnFishing_UpdateSinkingLure(GlobalContext* globalCtx) { } if (D_8090CD14 == 5) { - Matrix_InsertYRotation_f(player->actor.shape.rot.y * (M_PI / 32768), MTXMODE_NEW); + Matrix_RotateYF(player->actor.shape.rot.y * (M_PI / 32768), MTXMODE_NEW); sp94.x = 5.0f; sp94.y = 0.0f; sp94.z = 3.0f; - Matrix_MultiplyVector3fByState(&sp94, &sp88); + Matrix_MultVec3f(&sp94, &sp88); } for (i = 1; i < SINKING_LURE_SEG_COUNT; i++) { @@ -1690,9 +1690,9 @@ void EnFishing_UpdateSinkingLure(GlobalContext* globalCtx) { dist = sqrtf(SQ(dx) + SQ(dz)); rx = -Math_Acot2F(dist, dy); - Matrix_InsertYRotation_f(ry, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(rx); - Matrix_MultiplyVector3fByState(&posSrc, &posStep); + Matrix_RotateYF(ry, MTXMODE_NEW); + Matrix_RotateXFApply(rx); + Matrix_MultVec3f(&posSrc, &posStep); (pos + i)->x = (pos + i - 1)->x + posStep.x; (pos + i)->y = (pos + i - 1)->y + posStep.y; @@ -1720,10 +1720,10 @@ void EnFishing_DrawSinkingLure(GlobalContext* globalCtx) { for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { if ((i + D_80911F20) < SINKING_LURE_SEG_COUNT) { - Matrix_InsertTranslation(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); + Matrix_Translate(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); scale = sSinkingLureSizes[i + D_80911F20] * 0.04f; Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1737,10 +1737,10 @@ void EnFishing_DrawSinkingLure(GlobalContext* globalCtx) { for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { if ((i + D_80911F20) < SINKING_LURE_SEG_COUNT) { - Matrix_InsertTranslation(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); + Matrix_Translate(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); scale = sSinkingLureSizes[i + D_80911F20] * 0.04f; Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1764,7 +1764,7 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); if (D_8090CD54 != 0) { Vec3f posTemp = sLurePos; @@ -1778,11 +1778,11 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* sLurePos = sFishingHookedFish->fishMouthPos; if ((D_8090CD14 == 5) && (D_80917206 == 2)) { - Matrix_InsertYRotation_f(player->actor.shape.rot.y * (M_PI / 32768), MTXMODE_NEW); + Matrix_RotateYF(player->actor.shape.rot.y * (M_PI / 32768), MTXMODE_NEW); posSrc.x = 2.0f; posSrc.y = 0.0f; posSrc.z = 0.0f; - Matrix_MultiplyVector3fByState(&posSrc, &posStep); + Matrix_MultVec3f(&posSrc, &posStep); sLurePos.x += posStep.x; sLurePos.z += posStep.z; } @@ -1798,13 +1798,13 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* } if (D_80917206 != 2) { - Matrix_InsertTranslation(sLurePos.x, sLurePos.y, sLurePos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(sLureRot.y + D_80917254, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(sLureRot.x); + Matrix_Translate(sLurePos.x, sLurePos.y, sLurePos.z, MTXMODE_NEW); + Matrix_RotateYF(sLureRot.y + D_80917254, MTXMODE_APPLY); + Matrix_RotateXFApply(sLureRot.x); Matrix_Scale(0.0039999997f, 0.0039999997f, 0.0039999997f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, D_80917258, MTXMODE_APPLY); - Matrix_InsertZRotation_f(M_PI / 2, MTXMODE_APPLY); - Matrix_InsertYRotation_f(M_PI / 2, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, D_80917258, MTXMODE_APPLY); + Matrix_RotateZF(M_PI / 2, MTXMODE_APPLY); + Matrix_RotateYF(M_PI / 2, MTXMODE_APPLY); func_8012C28C(globalCtx->state.gfxCtx); @@ -1814,16 +1814,16 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* posSrc.x = -850.0f; posSrc.y = 0.0f; posSrc.z = 0.0f; - Matrix_MultiplyVector3fByState(&posSrc, &D_80917218); + Matrix_MultVec3f(&posSrc, &D_80917218); posSrc.x = 500.0f; posSrc.z = -300.0f; - Matrix_MultiplyVector3fByState(&posSrc, &hookPos[0]); + Matrix_MultVec3f(&posSrc, &hookPos[0]); EnFishing_DrawLureHook(globalCtx, &hookPos[0], &sLureHookRefPos[0], 0); posSrc.x = 2100.0f; posSrc.z = -50.0f; - Matrix_MultiplyVector3fByState(&posSrc, &hookPos[1]); + Matrix_MultVec3f(&posSrc, &hookPos[1]); EnFishing_DrawLureHook(globalCtx, &hookPos[1], &sLureHookRefPos[1], 1); } @@ -1850,9 +1850,9 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) * 0.001f; - Matrix_InsertTranslation(sRodTipPos.x, sRodTipPos.y, sRodTipPos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(ry, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(rx); + Matrix_Translate(sRodTipPos.x, sRodTipPos.y, sRodTipPos.z, MTXMODE_NEW); + Matrix_RotateYF(ry, MTXMODE_APPLY); + Matrix_RotateXFApply(rx); Matrix_Scale(D_809101C8, 1.0f, dist, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1877,9 +1877,9 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* dist = sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) * 0.001f; - Matrix_InsertTranslation((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); - Matrix_InsertYRotation_f(ry, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(rx); + Matrix_Translate((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); + Matrix_RotateYF(ry, MTXMODE_APPLY); + Matrix_RotateXFApply(rx); Matrix_Scale(D_809101C8, 1.0f, dist, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1888,9 +1888,9 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* break; } - Matrix_InsertTranslation((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); - Matrix_InsertYRotation_f((lineRot + i)->y, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis((lineRot + i)->x); + Matrix_Translate((linePos + i)->x, (linePos + i)->y, (linePos + i)->z, MTXMODE_NEW); + Matrix_RotateYF((lineRot + i)->y, MTXMODE_APPLY); + Matrix_RotateXFApply((lineRot + i)->x); Matrix_Scale(D_809101C8, 1.0f, 0.005f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1899,7 +1899,7 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* } } - Matrix_StatePop(); + Matrix_Pop(); func_8012C2DC(globalCtx->state.gfxCtx); CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -2001,34 +2001,34 @@ void EnFishing_DrawRod(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 155, 0, 255); - Matrix_InsertMatrix(&player->mf_CC4, MTXMODE_NEW); + Matrix_Mult(&player->mf_CC4, MTXMODE_NEW); if (sLinkAge != 1) { - Matrix_InsertTranslation(0.0f, 400.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 400.0f, 0.0f, MTXMODE_APPLY); } else { - Matrix_InsertTranslation(0.0f, 230.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 230.0f, 0.0f, MTXMODE_APPLY); } if (D_8090CD14 == 5) { - Matrix_InsertYRotation_f(1.7592919f, MTXMODE_APPLY); + Matrix_RotateYF(1.7592919f, MTXMODE_APPLY); } else { - Matrix_InsertYRotation_f(1.288053f, MTXMODE_APPLY); + Matrix_RotateYF(1.288053f, MTXMODE_APPLY); } - Matrix_RotateStateAroundXAxis(-0.6283185f); - Matrix_InsertZRotation_f((player->unk_B08[0] * 0.5f) + 0.4712389f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis((D_8090CD40 + 20.0f) * 0.01f * M_PI); + Matrix_RotateXFApply(-0.6283185f); + Matrix_RotateZF((player->unk_B08[0] * 0.5f) + 0.4712389f, MTXMODE_APPLY); + Matrix_RotateXFApply((D_8090CD40 + 20.0f) * 0.01f * M_PI); Matrix_Scale(0.70000005f, 0.70000005f, 0.70000005f, MTXMODE_APPLY); spC0 = (D_8090CD3C * (((player->unk_B08[1] - 1.0f) * -0.25f) + 0.5f)) + (D_8090CD2C + D_8090CD38); - Matrix_InsertTranslation(0.0f, 0.0f, -1300.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -1300.0f, MTXMODE_APPLY); for (i = 0; i < 22; i++) { - Matrix_InsertYRotation_f(sRodBendRatios[i] * D_8090CD28 * 0.5f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(sRodBendRatios[i] * spC0 * 0.5f); + Matrix_RotateYF(sRodBendRatios[i] * D_8090CD28 * 0.5f, MTXMODE_APPLY); + Matrix_RotateXFApply(sRodBendRatios[i] * spC0 * 0.5f); - Matrix_StatePush(); + Matrix_Push(); Matrix_Scale(sRodScales[i], sRodScales[i], 0.52f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -2046,11 +2046,11 @@ void EnFishing_DrawRod(GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, gFishingRodSegmentDL); - Matrix_StatePop(); - Matrix_InsertTranslation(0.0f, 0.0f, 500.0f, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_Translate(0.0f, 0.0f, 500.0f, MTXMODE_APPLY); if (i == 21) { - Matrix_MultiplyVector3fByState(&sRodTipOffset, &sRodTipPos); + Matrix_MultVec3f(&sRodTipOffset, &sRodTipPos); } } @@ -2175,11 +2175,11 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { if (D_80917204 == 18) { D_8090CD14 = 1; sLurePos = sRodTipPos; - Matrix_InsertYRotation_f(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); + Matrix_RotateYF(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); sp90.x = 0.0f; sp90.y = 0.0f; sp90.z = 25.0f; - Matrix_MultiplyVector3fByState(&sp90, &D_80917238); + Matrix_MultVec3f(&sp90, &D_80917238); D_80917238.y = 15.0f; D_80917248.x = D_80917248.z = 0.0f; D_80917248.y = -1.0f; @@ -2292,8 +2292,8 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { sp7C = Rand_ZeroFloat(1.5f) + 0.5f; sp78 = Rand_ZeroFloat(6.28f); - sp9C.x = __sinf(sp78) * sp7C; - sp9C.z = __cosf(sp78) * sp7C; + sp9C.x = sinf(sp78) * sp7C; + sp9C.z = cosf(sp78) * sp7C; sp9C.y = Rand_ZeroFloat(3.0f) + 3.0f; spA8 = sLurePos; @@ -2471,17 +2471,17 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { sp90.y = 0.0f; sp90.z = D_809101B4; - Matrix_InsertYRotation_f(sLureRot.y, MTXMODE_NEW); + Matrix_RotateYF(sLureRot.y, MTXMODE_NEW); if (D_80917206 == 2) { s8 requiredScopeTemp; - Matrix_MultiplyVector3fByState(&sp90, &sp64); + Matrix_MultVec3f(&sp90, &sp64); D_80917278.x = sp64.x; D_80917278.z = sp64.z; phi_f0 = 10.0f; } else { - Matrix_MultiplyVector3fByState(&sp90, &D_80917278); + Matrix_MultVec3f(&sp90, &D_80917278); phi_f0 = 0.0f; } @@ -2648,8 +2648,8 @@ s32 func_809033F0(EnFishing* this, GlobalContext* globalCtx, u8 ignorePosCheck) speedXZ = (Rand_ZeroFloat(1.5f) + 0.5f) * scale; angle = Rand_ZeroFloat(6.28f); - vel.x = __sinf(angle) * speedXZ; - vel.z = __cosf(angle) * speedXZ; + vel.x = sinf(angle) * speedXZ; + vel.z = cosf(angle) * speedXZ; vel.y = (Rand_ZeroFloat(3.0f) + 3.0f) * scale; pos = this->actor.world.pos; @@ -2695,8 +2695,8 @@ void func_809036BC(EnFishing* this, GlobalContext* globalCtx) { speedXZ = (Rand_ZeroFloat(1.5f) + 0.5f) * scale; angle = Rand_ZeroFloat(6.28f); - vel.x = __sinf(angle) * speedXZ; - vel.z = __cosf(angle) * speedXZ; + vel.x = sinf(angle) * speedXZ; + vel.z = cosf(angle) * speedXZ; vel.y = Rand_ZeroFloat(2.0f) + 2.0f; pos = this->actor.world.pos; @@ -2721,8 +2721,8 @@ void func_809038A4(EnFishing* this, Input* input) { sp24 = SQ(sp34.x) + SQ(sp34.y) + SQ(sp34.z); if ((D_8090CD14 == 3) && (this->unk_19A == 0) && (D_8090CD0C == 0)) { - Matrix_InsertYRotation_f((-this->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp34, &sp28); + Matrix_RotateYF((-this->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); + Matrix_MultVec3f(&sp34, &sp28); if ((sp28.z > 0.0f) || (this->unk_1A4 < 40.0f)) { if ((this->unk_150 == 7) && (sp24 < SQ(200.0f))) { @@ -2945,10 +2945,10 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_184 += this->unk_190; - temp = __cosf(this->unk_184); + temp = cosf(this->unk_184); this->unk_164 = this->unk_166 + (temp * this->unk_194); - temp = __cosf(this->unk_184 + -1.2f); + temp = cosf(this->unk_184 + -1.2f); this->unk_16E = this->unk_166 + (temp * this->unk_194 * 1.6f); } else { Actor_SetScale(&this->actor, this->unk_1A4 * 65.0f * 0.000001f); @@ -2959,11 +2959,11 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_184 += this->unk_190 * 0.8f; for (i = 0; i < 3; i++) { - temp = __cosf(this->unk_184 + (i * 2.1f)); + temp = cosf(this->unk_184 + (i * 2.1f)); this->unk_1C4[i] = this->unk_166 + (temp * this->unk_194 * 2.0f); } - temp = __cosf(this->unk_184 + 0.4f); + temp = cosf(this->unk_184 + 0.4f); this->unk_164 = (this->unk_194 * temp * 2.0f) * 0.6f; } @@ -3246,8 +3246,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } sp10C.y = 0.0f; sp10C.z = 0.0f; - Matrix_InsertYRotation_f(sLureRot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp10C, &sp100); + Matrix_RotateYF(sLureRot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp10C, &sp100); this->unk_1AC.x = sLurePos.x + sp100.x; this->unk_1AC.z = sLurePos.z + sp100.z; @@ -3378,8 +3378,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { sp10C.y = 0.0f; sp10C.z = 30.0f; - Matrix_InsertYRotation_f(sLureRot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp10C, &sp100); + Matrix_RotateYF(sLureRot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp10C, &sp100); this->unk_1AC.x = sLurePos.x + sp100.x; this->unk_1AC.z = sLurePos.z + sp100.z; @@ -3607,10 +3607,10 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { for (spA2 = 0; spA2 < 100; spA2++) { - Matrix_InsertYRotation_f(randPlusMinusPoint5Scaled(2.3561945f) + - (((this->actor.yawTowardsPlayer + 0x8000) / 32768.0f) * M_PI), - MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp10C, &sp100); + Matrix_RotateYF(randPlusMinusPoint5Scaled(2.3561945f) + + (((this->actor.yawTowardsPlayer + 0x8000) / 32768.0f) * M_PI), + MTXMODE_NEW); + Matrix_MultVec3f(&sp10C, &sp100); this->unk_1AC.x = this->actor.world.pos.x + sp100.x; this->unk_1AC.z = this->actor.world.pos.z + sp100.z; @@ -3812,8 +3812,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { sp10C.y = 10.0f; sp10C.z = 50.0f; } - Matrix_InsertYRotation_f((player->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp10C, &sCameraEye); + Matrix_RotateYF((player->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); + Matrix_MultVec3f(&sp10C, &sCameraEye); sCameraEye.x += player->actor.world.pos.x; sCameraEye.y += player->actor.world.pos.y; @@ -3855,7 +3855,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { sp10C.x = 4.0f; sp10C.y = -10.0f; sp10C.z = 5.0f; - Matrix_MultiplyVector3fByState(&sp10C, &sp100); + Matrix_MultVec3f(&sp10C, &sp100); Math_ApproachF(&this->actor.world.pos.x, player->bodyPartsPos[15].x + sp100.x, 1.0f, 6.0f); Math_ApproachF(&this->actor.world.pos.y, player->bodyPartsPos[15].y + sp100.y, 1.0f, 6.0f); Math_ApproachF(&this->actor.world.pos.z, player->bodyPartsPos[15].z + sp100.z, 1.0f, 6.0f); @@ -4199,7 +4199,7 @@ void EnFishing_FishPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d EnFishing* this = THIS; if (limbIndex == 13) { - Matrix_MultiplyVector3fByState(&sFishMouthOffset, &this->fishMouthPos); + Matrix_MultVec3f(&sFishMouthOffset, &this->fishMouthPos); } } @@ -4223,7 +4223,7 @@ void EnFishing_LoachPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** EnFishing* this = THIS; if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&sLoachMouthOffset, &this->fishMouthPos); + Matrix_MultVec3f(&sLoachMouthOffset, &this->fishMouthPos); } } @@ -4232,24 +4232,24 @@ void EnFishing_DrawFish(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(((this->unk_15A + this->actor.shape.rot.y) / 32768.0f) * M_PI, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(((this->unk_158 + this->actor.shape.rot.x) / 32768.0f) * M_PI); - Matrix_InsertZRotation_f(((this->unk_15C + this->actor.shape.rot.z) / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYF(((this->unk_15A + this->actor.shape.rot.y) / 32768.0f) * M_PI, MTXMODE_APPLY); + Matrix_RotateXFApply(((this->unk_158 + this->actor.shape.rot.x) / 32768.0f) * M_PI); + Matrix_RotateZF(((this->unk_15C + this->actor.shape.rot.z) / 32768.0f) * M_PI, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (this->unk_148 == 0) { - Matrix_InsertYRotation_f((this->unk_164 * (M_PI / 32768)) - (M_PI / 2), MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, this->unk_164 * 10.0f * 0.01f, MTXMODE_APPLY); + Matrix_RotateYF((this->unk_164 * (M_PI / 32768)) - (M_PI / 2), MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, this->unk_164 * 10.0f * 0.01f, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnFishing_FishOverrideLimbDraw, EnFishing_FishPostLimbDraw, &this->actor); } else { - Matrix_InsertTranslation(0.0f, 0.0f, 3000.0f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(this->unk_164 * (M_PI / 32768), MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -3000.0f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(-(M_PI / 2), MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 3000.0f, MTXMODE_APPLY); + Matrix_RotateYF(this->unk_164 * (M_PI / 32768), MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -3000.0f, MTXMODE_APPLY); + Matrix_RotateYF(-(M_PI / 2), MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnFishing_LoachOverrideLimbDraw, EnFishing_LoachPostLimbDraw, @@ -4359,7 +4359,7 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); for (i = 0; i < POND_PROP_COUNT; i++) { if (prop->type == FS_PROP_REED) { @@ -4369,11 +4369,11 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { } if (prop->shouldDraw) { - Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Translate(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); Matrix_Scale(prop->scale, prop->scale, prop->scale, MTXMODE_APPLY); - Matrix_InsertYRotation_f(prop->rotY, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(prop->rotX); - Matrix_InsertYRotation_f(prop->reedAngle, MTXMODE_APPLY); + Matrix_RotateYF(prop->rotY, MTXMODE_APPLY); + Matrix_RotateXFApply(prop->rotX); + Matrix_RotateYF(prop->reedAngle, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4394,7 +4394,7 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { } if (prop->shouldDraw) { - Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Translate(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); Matrix_Scale(prop->scale, prop->scale, prop->scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -4416,11 +4416,11 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { } if (prop->shouldDraw) { - Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Translate(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); Matrix_Scale(prop->scale, 1.0f, prop->scale, MTXMODE_APPLY); - Matrix_InsertYRotation_f(prop->lilyPadAngle * (M_PI / 32768), MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 20.0f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(prop->rotY, MTXMODE_APPLY); + Matrix_RotateYF(prop->lilyPadAngle * (M_PI / 32768), MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 20.0f, MTXMODE_APPLY); + Matrix_RotateYF(prop->rotY, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4441,9 +4441,9 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { } if (prop->shouldDraw) { - Matrix_InsertTranslation(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); + Matrix_Translate(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); Matrix_Scale(prop->scale, prop->scale, prop->scale, MTXMODE_APPLY); - Matrix_InsertYRotation_f(prop->rotY, MTXMODE_APPLY); + Matrix_RotateYF(prop->rotY, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4454,7 +4454,7 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { prop++; } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -4487,9 +4487,9 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { refPos = &player->actor.world.pos; } - basePos[0].x = __sinf(sFishGroupAngle1) * 720.0f; + basePos[0].x = sinf(sFishGroupAngle1) * 720.0f; basePos[0].y = -35.0f; - basePos[0].z = __cosf(sFishGroupAngle1) * 720.0f; + basePos[0].z = cosf(sFishGroupAngle1) * 720.0f; temp1 = refPos->x - basePos[0].x; temp2 = refPos->z - basePos[0].z; @@ -4504,9 +4504,9 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { Math_ApproachF(&sFishGroupAngle1, 0.7f, 1.0f, 0.001f); } - basePos[1].x = __sinf(sFishGroupAngle2) * 720.0f; + basePos[1].x = sinf(sFishGroupAngle2) * 720.0f; basePos[1].y = -35.0f; - basePos[1].z = __cosf(sFishGroupAngle2) * 720.0f; + basePos[1].z = cosf(sFishGroupAngle2) * 720.0f; temp1 = refPos->x - basePos[1].x; temp2 = refPos->z - basePos[1].z; @@ -4521,9 +4521,9 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { Math_ApproachF(&sFishGroupAngle2, 2.3f, 1.0f, 0.001f); } - basePos[2].x = __sinf(sFishGroupAngle3) * 720.0f; + basePos[2].x = sinf(sFishGroupAngle3) * 720.0f; basePos[2].y = -35.0f; - basePos[2].z = __cosf(sFishGroupAngle3) * 720.0f; + basePos[2].z = cosf(sFishGroupAngle3) * 720.0f; temp1 = refPos->x - basePos[2].x; temp2 = refPos->z - basePos[2].z; @@ -4635,7 +4635,7 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { Math_ApproachF(&fish->unk_34, 1.0f, 1.0f, 0.1f); Math_ApproachF(&fish->unk_38, 0.4f, 1.0f, 0.04f); fish->unk_30 += fish->unk_34; - fish->unk_2C = (__cosf(fish->unk_30) * fish->unk_38) + offset; + fish->unk_2C = (cosf(fish->unk_30) * fish->unk_38) + offset; } } @@ -4669,9 +4669,9 @@ void EnFishing_DrawGroupFishes(GlobalContext* globalCtx) { } if (fish->shouldDraw) { - Matrix_InsertTranslation(fish->pos.x, fish->pos.y, fish->pos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(((f32)fish->unk_3E * M_PI) / 32768.0f, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis((-(f32)fish->unk_3C * M_PI) / 32768.0f); + Matrix_Translate(fish->pos.x, fish->pos.y, fish->pos.z, MTXMODE_NEW); + Matrix_RotateYF(((f32)fish->unk_3E * M_PI) / 32768.0f, MTXMODE_APPLY); + Matrix_RotateXFApply((-(f32)fish->unk_3C * M_PI) / 32768.0f); Matrix_Scale(fish->unk_2C * scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -5189,12 +5189,12 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { spFC.x = sLurePos.x - player->actor.world.pos.x; spFC.z = sLurePos.z - player->actor.world.pos.z; lureDistXZ = sqrtf(SQXZ(spFC)); - Matrix_InsertYRotation_f(Math_Acot2F(spFC.z, spFC.x), MTXMODE_NEW); + Matrix_RotateYF(Math_Acot2F(spFC.z, spFC.x), MTXMODE_NEW); sp114.x = 0.0f; sp114.y = 0.0f; sp114.z = 100.0f; - Matrix_MultiplyVector3fByState(&sp114, &spFC); + Matrix_MultVec3f(&sp114, &spFC); if (D_8090CD14 == 1) { camAtFraction = 0.2f; @@ -5214,7 +5214,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { } sp114.z = -80.0f; - Matrix_MultiplyVector3fByState(&sp114, &sp108); + Matrix_MultVec3f(&sp114, &sp108); sp108.x += player->actor.world.pos.x; sp108.y += player->actor.world.pos.y; sp108.z += player->actor.world.pos.z; @@ -5270,7 +5270,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { sp114.x = 0.0f; sp114.y = 0.0f; sp114.z = 100.0f; - Matrix_MultiplyVector3fByState(&sp114, &spFC); + Matrix_MultVec3f(&sp114, &spFC); Math_ApproachF(&sCameraEye.x, sp108.x, 0.3f, fabsf(spFC.x) * D_80911F4C); Math_ApproachF(&sCameraEye.y, sp108.y, 0.3f, 20.0f * D_80911F4C); @@ -5369,7 +5369,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { D_8090CD54 = 1; Math_ApproachF(&D_80911F64, 71.0f, 0.5f, 3.0f); - Matrix_InsertYRotation_f(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); + Matrix_RotateYF(BINANG_TO_RAD(player->actor.shape.rot.y), MTXMODE_NEW); sp114.x = Math_SinS(globalCtx->gameplayFrames * 0x1000); sp114.y = D_80911F64; @@ -5378,7 +5378,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { sp114.y -= 20.0f; } - Matrix_MultiplyVector3fByState(&sp114, &sp108); + Matrix_MultVec3f(&sp114, &sp108); sSinkingLureBasePos.x = player->actor.world.pos.x + sp108.x; sSinkingLureBasePos.y = player->actor.world.pos.y + sp108.y; @@ -5396,7 +5396,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { sp114.z = -35.0f; } - Matrix_MultiplyVector3fByState(&sp114, &sCameraEye); + Matrix_MultVec3f(&sp114, &sCameraEye); sCameraEye.x += player->actor.world.pos.x; sCameraEye.y += player->actor.world.pos.y; sCameraEye.z += player->actor.world.pos.z; @@ -5484,8 +5484,8 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { speedXZ = Rand_ZeroFloat(1.5f) + 1.5f; angle = Rand_ZeroFloat(6.28f); - vel.x = __sinf(angle) * speedXZ; - vel.z = __cosf(angle) * speedXZ; + vel.x = sinf(angle) * speedXZ; + vel.z = cosf(angle) * speedXZ; vel.y = Rand_ZeroFloat(3.0f) + 2.0f; pos = player->actor.world.pos; @@ -5600,7 +5600,7 @@ void EnFishing_OwnerPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** if (limbIndex == 8) { // Head OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_MultiplyVector3fByState(&sZeroVec, &sOwnerHeadPos); + Matrix_MultVec3f(&sZeroVec, &sOwnerHeadPos); if (D_8090CD08 == 1) { gSPDisplayList(POLY_OPA_DISP++, gFishingOwnerHatDL); @@ -5672,7 +5672,7 @@ void EnFishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx) { D_8090CCF4 = true; - Matrix_InsertTranslation(130.0f, 40.0f, 1300.0f, MTXMODE_NEW); + Matrix_Translate(130.0f, 40.0f, 1300.0f, MTXMODE_NEW); Matrix_Scale(0.08f, 0.12f, 0.14f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index 75d6ce63b..e7fb183c1 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -1160,23 +1160,23 @@ void EnFloormas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis EnFloormas* this = THIS; if (D_808D393C[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[D_808D393C[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_808D393C[limbIndex]]); } if (limbIndex == WALLMASTER_LIMB_WRIST) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[9]); - Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->limbPos[10]); + Matrix_MultVecX(1000.0f, &this->limbPos[9]); + Matrix_MultVecX(-1000.0f, &this->limbPos[10]); } else if (limbIndex == WALLMASTER_LIMB_HAND) { - Matrix_StatePush(); - Matrix_InsertTranslation(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(M_PI / 3, MTXMODE_APPLY); - Matrix_InsertZRotation_f(M_PI / 12, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); + Matrix_RotateYF(M_PI / 3, MTXMODE_APPLY); + Matrix_RotateZF(M_PI / 12, MTXMODE_APPLY); Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList((*gfx)++, gWallmasterLittleFingerDL); - Matrix_StatePop(); + Matrix_Pop(); } } diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index 04d4100b1..670bafff2 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -1566,7 +1566,7 @@ s32 EnFsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, s32 limbRotTableIdx; if (limbIndex == FSN_LIMB_HEAD) { - Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); } if (ENFSN_IS_BACKROOM(&this->actor)) { switch (limbIndex) { diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index 2b234d36b..77450f9ab 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -361,10 +361,10 @@ void func_8096209C(EnFu* this, GlobalContext* globalCtx) { sp34 = D_80964B24; } - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp34, &this->actor.focus.pos); - Matrix_StatePop(); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp34, &this->actor.focus.pos); + Matrix_Pop(); this->actor.focus.pos.x += this->actor.world.pos.x; this->actor.focus.pos.y += this->actor.world.pos.y; this->actor.focus.pos.z += this->actor.world.pos.z; @@ -1347,17 +1347,17 @@ s32 EnFu_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnFu* this = THIS; if (limbIndex == 9) { - Matrix_InsertTranslation(1600.0f, 300.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_524[1], MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_524[0], MTXMODE_APPLY); - Matrix_RotateY(this->unk_524[2], MTXMODE_APPLY); - Matrix_InsertTranslation(-1600.0f, -300.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1600.0f, 300.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_524[1], MTXMODE_APPLY); + Matrix_RotateZS(this->unk_524[0], MTXMODE_APPLY); + Matrix_RotateYS(this->unk_524[2], MTXMODE_APPLY); + Matrix_Translate(-1600.0f, -300.0f, 0.0f, MTXMODE_APPLY); } else if (limbIndex == 20) { - Matrix_InsertTranslation(1800.0f, 200.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_52A[1], MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_52A[0], MTXMODE_APPLY); - Matrix_RotateY(this->unk_52A[2], MTXMODE_APPLY); - Matrix_InsertTranslation(-1800.0f, -200.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1800.0f, 200.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_52A[1], MTXMODE_APPLY); + Matrix_RotateZS(this->unk_52A[0], MTXMODE_APPLY); + Matrix_RotateYS(this->unk_52A[2], MTXMODE_APPLY); + Matrix_Translate(-1800.0f, -200.0f, 0.0f, MTXMODE_APPLY); } return false; } @@ -1368,9 +1368,9 @@ void EnFu_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnFu* this = THIS; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80964C28, &this->unk_508); + Matrix_MultVec3f(&D_80964C28, &this->unk_508); } else if (limbIndex == 20) { - Matrix_MultiplyVector3fByState(&D_80964C34, &this->unk_514); + Matrix_MultVec3f(&D_80964C34, &this->unk_514); } } @@ -1378,9 +1378,9 @@ void EnFu_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnFu* this = THIS; - Matrix_StatePush(); + Matrix_Push(); func_80964950(globalCtx, this->unk_2D8, ARRAY_COUNT(this->unk_2D8)); - Matrix_StatePop(); + Matrix_Pop(); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1431,11 +1431,11 @@ void func_809647EC(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { ptr->unk_08.y += ptr->unk_20.y; ptr->unk_08.x += 2.0f * Math_SinS(ptr->unk_2C); ptr->unk_08.z += 2.0f * Math_CosS(ptr->unk_2C); - Matrix_StatePush(); - Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); - Matrix_RotateY(yaw, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&sp44, &ptr->unk_08); - Matrix_StatePop(); + Matrix_Push(); + Matrix_Translate(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + Matrix_RotateYS(yaw, MTXMODE_APPLY); + Matrix_MultVec3f(&sp44, &ptr->unk_08); + Matrix_Pop(); ptr->unk_2C += 6000; } } @@ -1456,8 +1456,8 @@ void func_80964950(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { gSPDisplayList(POLY_OPA_DISP++, object_mu_DL_00B0A0); flag = true; } - Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(ptr->unk_00, ptr->unk_00, ptr->unk_00, MTXMODE_APPLY); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_05E6F0)); diff --git a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c index ad92b34d6..ef4c8b6bb 100644 --- a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c +++ b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.c @@ -366,17 +366,17 @@ void func_80AD0340(EnFuKago* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(D_80AD061C); i++, ptr++) { - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &this->dyna.actor.shape.rot); - Matrix_InsertTranslation(ptr->unk_24.x, ptr->unk_24.y, ptr->unk_24.z, MTXMODE_APPLY); - Matrix_InsertRotation(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); - Matrix_InsertTranslation(-ptr->unk_24.x, -ptr->unk_24.y, -ptr->unk_24.z, MTXMODE_APPLY); + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &this->dyna.actor.shape.rot); + Matrix_Translate(ptr->unk_24.x, ptr->unk_24.y, ptr->unk_24.z, MTXMODE_APPLY); + Matrix_RotateZYX(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + Matrix_Translate(-ptr->unk_24.x, -ptr->unk_24.y, -ptr->unk_24.z, MTXMODE_APPLY); Matrix_Scale(scale->x, scale->y, scale->z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_80AD061C[i]); - Matrix_StatePop(); + Matrix_Pop(); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c index ec0209729..4591eab65 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c @@ -406,8 +406,8 @@ void func_80ACF1F4(EnFuMato* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); for (i = 0; i < 2; i++) { - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_24); + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_24); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -430,7 +430,7 @@ void func_80ACF1F4(EnFuMato* this, GlobalContext* globalCtx) { break; } - Matrix_StatePop(); + Matrix_Pop(); temp_s4 = (temp_s4 + 3) % ARRAY_COUNT(this->unk_1B8); ptr++; @@ -449,14 +449,14 @@ void func_80ACF3F4(EnFuMato* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(D_80ACF63C); i++, ptr++) { - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_24); + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_24); Matrix_Scale(scale->x, scale->y, scale->z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[i]); - Matrix_StatePop(); + Matrix_Pop(); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.c b/src/overlays/actors/ovl_En_Fz/z_en_fz.c index 067e8c50d..bd6f66e34 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -259,13 +259,13 @@ void func_80932784(EnFz* this, GlobalContext* globalCtx) { sp5C.y = this->actor.world.pos.y + 20.0f; sp5C.z = this->actor.world.pos.z; - Matrix_InsertTranslation(sp5C.x, sp5C.y, sp5C.z, MTXMODE_NEW); - Matrix_InsertRotation(this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(sp5C.x, sp5C.y, sp5C.z, MTXMODE_NEW); + Matrix_RotateZYX(this->actor.shape.rot.x, this->actor.shape.rot.y, this->actor.shape.rot.z, MTXMODE_APPLY); sp44.x = sp44.y = 0.0f; sp44.z = 440.0f; - Matrix_MultiplyVector3fByState(&sp44, &this->unk_22C); + Matrix_MultVec3f(&sp44, &this->unk_22C); if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp5C, &this->unk_22C, &sp50, &sp3C, true, false, false, true, &sp40)) { Math_Vec3f_Copy(&this->unk_22C, &sp50); @@ -620,7 +620,7 @@ void func_809334B8(EnFz* this, GlobalContext* globalCtx) { sp58.y = this->actor.world.pos.y + 20.0f; sp58.z = this->actor.world.pos.z; - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); sp64.x = 0.0f; sp64.y = -2.0f; @@ -629,7 +629,7 @@ void func_809334B8(EnFz* this, GlobalContext* globalCtx) { : 0.0f) + 20; - Matrix_MultiplyVector3fByState(&sp64, &sp4C); + Matrix_MultVec3f(&sp64, &sp4C); if ((this->unk_BCA & 7) == 0) { sp3F = 1; @@ -737,7 +737,7 @@ void func_809338E0(EnFz* this, GlobalContext* globalCtx) { sp58.y = this->actor.world.pos.y + 20.0f; sp58.z = this->actor.world.pos.z; - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); sp64.x = 0.0f; sp64.y = -2.0f; @@ -746,7 +746,7 @@ void func_809338E0(EnFz* this, GlobalContext* globalCtx) { : 0.0f) + 20; - Matrix_MultiplyVector3fByState(&sp64, &sp4C); + Matrix_MultVec3f(&sp64, &sp4C); if (!(this->unk_BC6 & 7)) { sp3F = 1; @@ -1013,8 +1013,8 @@ void func_80934464(EnFz* this, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (ptr->unk_01 + (i * 3)) * 3, (ptr->unk_01 + (i * 3)) * 15, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(ptr->unk_30, ptr->unk_30, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c index 1d9175b49..de6a752d8 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c @@ -265,9 +265,8 @@ void EnGakufu_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x02, globalCtx->interfaceCtx.parameterSegment); for (i = 0; (i < ARRAY_COUNT(this->buttonIndex)) && (this->buttonIndex[i] != OCARINA_BTN_INVALID); i++) { - Matrix_StatePush(); - Matrix_InsertTranslation(30 * i - 105, sOcarinaBtnWallYOffsets[this->buttonIndex[i]] * 7.5f, 1.0f, - MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(30 * i - 105, sOcarinaBtnWallYOffsets[this->buttonIndex[i]] * 7.5f, 1.0f, MTXMODE_APPLY); Matrix_Scale(0.6f, 0.6f, 0.6f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -284,7 +283,7 @@ void EnGakufu_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, gGakufuButtonIndexDL); - Matrix_StatePop(); + Matrix_Pop(); } gSPSegment(POLY_XLU_DISP++, 0x02, globalCtx->sceneSegment); 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 947afd914..41783a1b7 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -982,7 +982,7 @@ s32 EnGb2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnGb2* this = THIS; if (limbIndex == 7) { - Matrix_RotateY(this->unk_270.y, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_270.y, MTXMODE_APPLY); } if (limbIndex == 1) { @@ -997,7 +997,7 @@ void EnGb2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Vec3f sp18 = { 2400.0f, 0.0f, 0.0f }; if (limbIndex == 7) { - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); } } 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 d022058dd..79e5a3480 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -915,9 +915,9 @@ s32 func_80BB3728(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar Vec3s sp68; MtxF sp28; - Matrix_MultiplyVector3fByState(&sp70, &sp7C); - Matrix_CopyCurrentState(&sp28); - func_8018219C(&sp28, &sp68, 0); + Matrix_MultVec3f(&sp70, &sp7C); + Matrix_Get(&sp28); + Matrix_MtxFToYXZRot(&sp28, &sp68, false); *arg2 = sp7C; if (!arg4 && !arg5) { @@ -967,12 +967,12 @@ void EnGeg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve sp2C.y += 2.0f * Rand_Centered(); sp2C.z += Rand_Centered(); - Matrix_MultiplyVector3fByState(&D_80BB407C, &this->unk_4B4); - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp38, &this->unk_4C0[0]); - Matrix_MultiplyVector3fByState(&sp2C, &this->unk_4C0[1]); - Matrix_StatePop(); + Matrix_MultVec3f(&D_80BB407C, &this->unk_4B4); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp38, &this->unk_4C0[0]); + Matrix_MultVec3f(&sp2C, &this->unk_4C0[1]); + Matrix_Pop(); } } @@ -998,13 +998,13 @@ void EnGeg_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi func_80BB3728(this->unk_468 + this->unk_46C + 0x4000, this->unk_46A + this->unk_46E + this->actor.shape.rot.y + 0x4000, &this->unk_470, &this->unk_47C, phi_v0, phi_v1); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_470.x, this->unk_470.y, this->unk_470.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_470.x, this->unk_470.y, this->unk_470.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_47C.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_47C.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_47C.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_47C.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_47C.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_47C.z, MTXMODE_APPLY); + Matrix_Push(); break; case 10: @@ -1022,13 +1022,13 @@ void EnGeg_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi func_80BB3728(this->unk_46C + 0x4000, this->unk_46E + this->actor.shape.rot.y + 0x4000, &this->unk_484, &this->unk_490, phi_v0, phi_v1); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_484.x, this->unk_484.y, this->unk_484.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_484.x, this->unk_484.y, this->unk_484.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_490.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_490.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_490.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_490.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_490.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_490.z, MTXMODE_APPLY); + Matrix_Push(); break; } } @@ -1062,14 +1062,14 @@ void func_80BB3CB4(EnGeg* this, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, - this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, + this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_InsertXRotation_s(sp24, MTXMODE_APPLY); + Matrix_RotateXS(sp24, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_oF1d_map_DL_0091A8); 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 3d80cc847..2683e1296 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -509,7 +509,7 @@ void func_80B35C84(EnGgStruct* ptr, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); for (i = sp74; i < phi_s7; i += temp) { temp_f20 = i * 0.14f; @@ -520,22 +520,22 @@ void func_80B35C84(EnGgStruct* ptr, GlobalContext* globalCtx) { if (1) {} - Matrix_InsertTranslation(temp_f22, temp_f24, temp_f26, MTXMODE_NEW); + Matrix_Translate(temp_f22, temp_f24, temp_f26, MTXMODE_NEW); Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); } - Matrix_StatePop(); + Matrix_Pop(); - Matrix_StatePush(); + Matrix_Push(); for (i = sp74; i < phi_s7; i += temp) { temp_f20 = i * 0.14f; @@ -544,20 +544,20 @@ void func_80B35C84(EnGgStruct* ptr, GlobalContext* globalCtx) { temp_f26 = ptr->unk_0C.z + (ptr->unk_18.z * temp_f20) + (0.5f * ptr->unk_24.z * temp_f20 * temp_f20); temp_f20 = Rand_ZeroOne() * 0.003f; - Matrix_InsertTranslation(temp_f22, temp_f24, temp_f26, MTXMODE_NEW); + Matrix_Translate(temp_f22, temp_f24, temp_f26, MTXMODE_NEW); Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); } - Matrix_StatePop(); + Matrix_Pop(); gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -583,7 +583,7 @@ void func_80B3610C(EnGgStruct* ptr, GlobalContext* globalCtx) { if (phi_s4 > 0) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); for (i = 0; i < phi_s4; i++) { if (ptr->unk_48 != 0) { @@ -596,22 +596,22 @@ void func_80B3610C(EnGgStruct* ptr, GlobalContext* globalCtx) { temp_f28 = ptr->unk_0C.z + (ptr->unk_18.z * i) + (0.5f * ptr->unk_24.z * i * i); temp_f20 = Rand_ZeroOne() * 0.003f; - Matrix_InsertTranslation((Rand_Centered() * (100.0f * phi_f22)) + temp_f24, temp_f26, - ((30.0f * phi_f22) * Rand_Centered()) + temp_f28, MTXMODE_NEW); + Matrix_Translate((Rand_Centered() * (100.0f * phi_f22)) + temp_f24, temp_f26, + ((30.0f * phi_f22) * Rand_Centered()) + temp_f28, MTXMODE_NEW); Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); } - Matrix_StatePop(); + Matrix_Pop(); gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -739,7 +739,7 @@ s32 EnGg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnGg* this = THIS; if (limbIndex == 2) { - Matrix_InsertZRotation_s(this->unk_2E8, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2E8, MTXMODE_APPLY); } return false; } @@ -764,12 +764,12 @@ void EnGg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&D_80B36DF0, &this->unk_320); - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp30, &this->unk_32C); - Matrix_MultiplyVector3fByState(&sp24, &this->unk_338); - Matrix_StatePop(); + Matrix_MultVec3f(&D_80B36DF0, &this->unk_320); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp30, &this->unk_32C); + Matrix_MultVec3f(&sp24, &this->unk_338); + Matrix_Pop(); } } 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 f45cafa53..46f0b657c 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -457,11 +457,11 @@ s32 func_80B3BD44(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p if ((this->unk_2EE != 5) && (this->unk_2EE != 7)) { if (limbIndex == 1) { - Matrix_RotateY(this->unk_2F6, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_2F6, MTXMODE_APPLY); } if (limbIndex == 2) { - Matrix_InsertZRotation_s(this->unk_2F4, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2F4, MTXMODE_APPLY); } } return false; @@ -471,7 +471,7 @@ void func_80B3BDC0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnGg2* this = THIS; if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&D_80B3C0A0, &this->unk_304); + Matrix_MultVec3f(&D_80B3C0A0, &this->unk_304); } } 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 90d945e2a..26dfcb756 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -485,7 +485,7 @@ void EnGiant_PostLimbDrawXlu(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis EnGiant* this = THIS; if (limbIndex == GIANT_LIMB_HEAD) { - Matrix_CopyCurrentState(&this->headDrawMtxF); + Matrix_Get(&this->headDrawMtxF); } } @@ -517,7 +517,7 @@ void EnGiant_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnGiant_PostLimbDrawXlu, thisx, POLY_XLU_DISP); - Matrix_InsertMatrix(&this->headDrawMtxF, MTXMODE_NEW); + Matrix_Mult(&this->headDrawMtxF, MTXMODE_NEW); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGiantBeardDL); 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 34b0e36b4..300987214 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 @@ -636,13 +636,13 @@ s32 EnGinkoMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d } if (limbIndex == 15) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->limb15Rot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->limb15Rot.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + 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) { - Matrix_InsertXRotation_s(-this->limb8Rot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->limb8Rot.x, MTXMODE_APPLY); + Matrix_RotateXS(-this->limb8Rot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->limb8Rot.x, MTXMODE_APPLY); } return false; diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c index b509d4500..45fe0c132 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -597,7 +597,7 @@ void EnGirlA_Update(Actor* thisx, GlobalContext* globalCtx) { void EnGirlA_Draw(Actor* thisx, GlobalContext* globalCtx) { EnGirlA* this = THIS; - Matrix_RotateY(this->rotY, MTXMODE_APPLY); + Matrix_RotateYS(this->rotY, MTXMODE_APPLY); if (this->drawFunc != NULL) { this->drawFunc(&this->actor, globalCtx, 0); } 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 e6ede8065..ae9dd8553 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -403,9 +403,9 @@ s32 func_80B50ED4(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 ar Vec3s sp68; MtxF sp28; - Matrix_MultiplyVector3fByState(&sp70, &sp7C); - Matrix_CopyCurrentState(&sp28); - func_8018219C(&sp28, &sp68, 0); + Matrix_MultVec3f(&sp70, &sp7C); + Matrix_Get(&sp28); + Matrix_MtxFToYXZRot(&sp28, &sp68, false); *arg2 = sp7C; @@ -1146,17 +1146,17 @@ void EnGk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec this->actor.focus.pos.y = this->actor.world.pos.y + phi_f0; this->actor.focus.pos.z = this->actor.world.pos.z; - Matrix_MultiplyVector3fByState(&sp58, &this->actor.focus.pos); - Matrix_MultiplyVector3fByState(&sp34, &this->unk_2E8); - Matrix_MultiplyVector3fByState(&sp28, &this->unk_2F4); + Matrix_MultVec3f(&sp58, &this->actor.focus.pos); + Matrix_MultVec3f(&sp34, &this->unk_2E8); + Matrix_MultVec3f(&sp28, &this->unk_2F4); - Matrix_StatePush(); + Matrix_Push(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp4C, &this->unk_30C); - Matrix_MultiplyVector3fByState(&sp40, &this->unk_300); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sp4C, &this->unk_30C); + Matrix_MultVec3f(&sp40, &this->unk_300); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -1182,15 +1182,15 @@ void EnGk_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { this->unk_320 + this->unk_324 + this->actor.shape.rot.y + 0x4000, &this->unk_328, &this->unk_334, phi_v0, phi_v1); - Matrix_StatePop(); + Matrix_Pop(); - Matrix_InsertTranslation(this->unk_328.x, this->unk_328.y, this->unk_328.z, MTXMODE_NEW); + Matrix_Translate(this->unk_328.x, this->unk_328.y, this->unk_328.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_334.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_334.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_334.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_334.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_334.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_334.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_Push(); break; case 9: @@ -1208,15 +1208,15 @@ void EnGk_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { func_80B50ED4(this->unk_322 + 0x4000, this->unk_324 + this->actor.shape.rot.y + 0x4000, &this->unk_33C, &this->unk_348, phi_v0, phi_v1); - Matrix_StatePop(); + Matrix_Pop(); - Matrix_InsertTranslation(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_Translate(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_348.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_348.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_348.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_348.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_348.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_348.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_Push(); break; } } @@ -1239,7 +1239,7 @@ void EnGk_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); if ((ENGK_GET_F(&this->actor) == ENGK_F_0) && (gSaveContext.save.weekEventReg[22] & 4)) { - Matrix_InsertXRotation_s(-0x4000, MTXMODE_APPLY); + Matrix_RotateXS(-0x4000, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_gk_DL_006688); 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 8430547ab..07699e7de 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -874,7 +874,7 @@ void func_8094F3D0(EnGm* this, GlobalContext* globalCtx) { this->unk_3AC = 0.0f; } Math_SmoothStepToF(&this->unk_3B0, this->unk_3AC, 0.8f, 40.0f, 10.0f); - Matrix_InsertTranslation(this->unk_3B0, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->unk_3B0, 0.0f, 0.0f, MTXMODE_APPLY); this->unk_3F0 = sp28; } @@ -1759,7 +1759,7 @@ void EnGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec s32 pad2; if ((ActorCutscene_GetCurrentIndex() == -1) && (limbIndex == 16)) { - Matrix_MultiplyVector3fByState(&D_80951E24, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80951E24, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } @@ -1772,7 +1772,7 @@ void EnGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec CLOSE_DISPS(globalCtx->state.gfxCtx); if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp30); + Matrix_MultVec3f(&gZeroVec3f, &sp30); Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp30); } } @@ -1798,23 +1798,23 @@ void EnGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this 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); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_2A8.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2A8.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2A8.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_2A8.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2A8.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2A8.z, MTXMODE_APPLY); + Matrix_Push(); } else if (limbIndex == 9) { 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_StatePop(); - Matrix_InsertTranslation(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_2AE.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2AE.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2AE.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_2AE.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2AE.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2AE.z, MTXMODE_APPLY); + Matrix_Push(); } } 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 c34b3e9a3..27c307777 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -253,7 +253,7 @@ void func_80A11144(EnGoStruct* ptr, GlobalContext* globalCtx) { flag = true; } - Matrix_StatePush(); + Matrix_Push(); temp = ((f32)ptr->unk_02 / ptr->unk_01); temp *= 255; @@ -263,15 +263,15 @@ void func_80A11144(EnGoStruct* ptr, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (ptr->unk_02 + (i * 3)) * 3, (ptr->unk_02 + (i * 3)) * 15, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(ptr->unk_34, ptr->unk_34, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_003258); - Matrix_StatePop(); + Matrix_Pop(); if (globalCtx->state.gfxCtx) {} } } @@ -328,7 +328,7 @@ void func_80A115B4(EnGoStruct* ptr, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014CF0); flag = true; } - Matrix_StatePush(); + Matrix_Push(); temp = (f32)ptr->unk_02 / ptr->unk_01; @@ -337,16 +337,16 @@ void func_80A115B4(EnGoStruct* ptr, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, D_80A16670[(s32)ptr->unk_00 - 4].r, D_80A16670[(s32)ptr->unk_00 - 4].g, D_80A16670[(s32)ptr->unk_00 - 4].b, 0); - Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_34, ptr->unk_34, 1.0f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A16644[(s32)(temp * 7.0f)])); gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014D00); - Matrix_StatePop(); + Matrix_Pop(); } if (globalCtx->state.gfxCtx) {} } @@ -465,12 +465,12 @@ void func_80A11EC0(EnGoStruct* ptr, GlobalContext* globalCtx, Gfx* arg2, Gfx* ar flag = true; } - Matrix_StatePush(); - Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_Push(); + Matrix_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); Matrix_Scale(0.08f, 0.08f, 0.08f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(ptr->unk_0A.z, MTXMODE_APPLY); - Matrix_InsertXRotation_s(ptr->unk_0A.x, MTXMODE_APPLY); - Matrix_RotateY(ptr->unk_0A.y, MTXMODE_APPLY); + Matrix_RotateZS(ptr->unk_0A.z, MTXMODE_APPLY); + Matrix_RotateXS(ptr->unk_0A.x, MTXMODE_APPLY); + Matrix_RotateYS(ptr->unk_0A.y, MTXMODE_APPLY); if (1) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -478,7 +478,7 @@ void func_80A11EC0(EnGoStruct* ptr, GlobalContext* globalCtx, Gfx* arg2, Gfx* ar gSPDisplayList(POLY_OPA_DISP++, arg3); } - Matrix_StatePop(); + Matrix_Pop(); } } @@ -1067,14 +1067,13 @@ void func_80A137C0(EnGo* this, GlobalContext* globalCtx, f32 arg2, f32 arg3) { u32 frames2; if (this->unk_390 & 0x400) { - Matrix_StatePush(); + Matrix_Push(); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(arg2 * 0.7f, arg2 * 0.8f, arg2, MTXMODE_APPLY); func_800B8118(&this->actor, globalCtx, 0); @@ -1088,7 +1087,7 @@ void func_80A137C0(EnGo* this, GlobalContext* globalCtx, f32 arg2, f32 arg3) { CLOSE_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -1951,12 +1950,12 @@ void func_80A15B80(EnGo* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, - this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, + this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); if (this->unk_390 & 0x100) { Matrix_Scale(this->actor.scale.x * 8.0f, this->actor.scale.y * 8.0f, this->actor.scale.z * 8.0f, MTXMODE_APPLY); @@ -1964,7 +1963,7 @@ void func_80A15B80(EnGo* this, GlobalContext* globalCtx) { Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); } - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, (this->unk_390 & 0x100) ? object_oF1d_map_DL_001560 : object_oF1d_map_DL_0091A8); @@ -1978,7 +1977,7 @@ s32 EnGo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, s32 idx; if ((ENGO_GET_F(&this->actor) == ENGO_F_8) && (limbIndex == 10)) { - Matrix_GetStateTranslation(&sp30); + Matrix_MultZero(&sp30); sp30.y = this->actor.world.pos.y; Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp30); } @@ -2035,25 +2034,25 @@ void EnGo_TransfromLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this SubS_UpdateLimb(this->unk_3B0 + this->unk_3B4 + 0x4000, this->unk_3B2 + this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_290, &this->unk_2A8, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_290.x, this->unk_290.y, this->unk_290.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_2A8.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2A8.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2A8.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_2A8.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2A8.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2A8.z, MTXMODE_APPLY); + Matrix_Push(); break; case 10: SubS_UpdateLimb(this->unk_3B4 + 0x4000, this->unk_3B6 + this->actor.shape.rot.y + 0x4000, &this->unk_29C, &this->unk_2AE, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_29C.x, this->unk_29C.y, this->unk_29C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_2AE.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2AE.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2AE.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_2AE.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2AE.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2AE.z, MTXMODE_APPLY); + Matrix_Push(); break; } } @@ -2073,7 +2072,7 @@ void func_80A15FEC(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A1670C[this->unk_3BE])); if (this->unk_3DC == 14) { - Matrix_InsertTranslation(0.0f, 0.0f, -4000.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -4000.0f, MTXMODE_APPLY); } SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnGo_OverrideLimbDraw, NULL, EnGo_TransfromLimbDraw, 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 7f6db7264..f17a75f6a 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -560,12 +560,12 @@ void func_8093FAA4(EnGoroiwa* this, GlobalContext* globalCtx) { sp64 = this->unk_1B4; } - Matrix_InsertRotationAroundUnitVector_f(sp7C, &sp64, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&sp24); - func_8018219C(&sp24, &this->actor.shape.rot, MTXMODE_NEW); + Matrix_RotateAxisF(sp7C, &sp64, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&sp24); + Matrix_MtxFToYXZRot(&sp24, &this->actor.shape.rot, false); } void func_8093FC00(EnGoroiwa* this) { @@ -1349,8 +1349,8 @@ void func_8094220C(EnGoroiwa* this, GlobalContext* globalCtx) { ptr->unk_18 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &ptr->unk_28, &spD0, &this->actor, &spC4); if (ptr->unk_10 <= 0.0f) { - Matrix_InsertRotation(ptr->unk_1C, ptr->unk_1E, ptr->unk_20, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&D_80942E6C, &spB8); + Matrix_RotateZYX(ptr->unk_1C, ptr->unk_1E, ptr->unk_20, MTXMODE_NEW); + Matrix_MultVec3f(&D_80942E6C, &spB8); temp_f20 = this->unk_1DC * 0.9f; if (spB8.y > 0.0f) { @@ -1566,7 +1566,7 @@ void func_80942B1C(EnGoroiwa* this, GlobalContext* globalCtx) { sp80.y = ptr->unk_1E; sp80.z = ptr->unk_20; - Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &sp80); + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &sp80); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Gfx_DrawDListOpa(globalCtx, phi_fp); @@ -1580,7 +1580,7 @@ void func_80942B1C(EnGoroiwa* this, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, ptr->unk_2C); func_800C0094(ptr->unk_28, ptr->unk_00.x, ptr->unk_18, ptr->unk_00.z, &sp88); - Matrix_SetCurrentState(&sp88); + Matrix_Put(&sp88); Matrix_Scale(this->actor.scale.x * 7.5f, 1.0f, this->actor.scale.z * 7.5f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), 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 37f56469d..a97de7b80 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -349,8 +349,8 @@ f32 func_80998334(EnGs* this, GlobalContext* globalCtx, f32* arg2, f32* arg3, s1 if (arg9 == 0) { sp2C = Math_SmoothStepToF(arg2, *arg3, arg5, arg6, arg7); - this->unk_1B0[0].x = (__sinf(DEGF_TO_RADF((*arg4 % arg8) * (1.0f / arg8) * 360.0f)) * *arg2) + 1.0f; - this->unk_1B0[0].y = 1.0f - (__sinf(DEGF_TO_RADF((*arg4 % arg8) * (1.0f / arg8) * 360.0f)) * *arg2); + this->unk_1B0[0].x = (sinf(DEGF_TO_RADF((*arg4 % arg8) * (1.0f / arg8) * 360.0f)) * *arg2) + 1.0f; + this->unk_1B0[0].y = 1.0f - (sinf(DEGF_TO_RADF((*arg4 % arg8) * (1.0f / arg8) * 360.0f)) * *arg2); (*arg4)++; } return sp2C; @@ -383,8 +383,8 @@ void func_809985B8(EnGs* this, GlobalContext* globalCtx) { if (SubS_StartActorCutscene(&this->actor, this->unk_212[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { Player* player = GET_PLAYER(globalCtx); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(160.0f, &sp38); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVecZ(160.0f, &sp38); Math_Vec3f_Sum(&player->actor.world.pos, &sp38, &player->actor.world.pos); Math_Vec3f_Copy(&player->actor.prevPos, &player->actor.world.pos); this->unk_200 = 0.0f; @@ -725,8 +725,8 @@ s32 func_80998F9C(EnGs* this, GlobalContext* globalCtx) { sp40 = Math_SmoothStepToF(&this->unk_1EC, this->unk_1F0, 0.8f, 0.02f, 0.001f); this->unk_1B0[0].x = this->unk_1E4 + 1.0f; this->unk_1B0[0].y = this->unk_1DC + 1.0f; - this->unk_1B0[0].x += __sinf(DEGF_TO_RADF((this->unk_1D4 % 10) * 0.1f * 360.0f)) * this->unk_1EC; - this->unk_1B0[0].y += __sinf(DEGF_TO_RADF((this->unk_1D4 % 10) * 0.1f * 360.0f)) * this->unk_1EC; + this->unk_1B0[0].x += sinf(DEGF_TO_RADF((this->unk_1D4 % 10) * 0.1f * 360.0f)) * this->unk_1EC; + this->unk_1B0[0].y += sinf(DEGF_TO_RADF((this->unk_1D4 % 10) * 0.1f * 360.0f)) * this->unk_1EC; this->unk_1D4++; if ((sp48 == 0.0f) && (sp44 == 0.0f) && (sp40 == 0.0f)) { this->unk_216 = 0; @@ -1070,16 +1070,16 @@ void EnGs_Draw(Actor* thisx, GlobalContext* globalCtx) { frames = globalCtx->gameplayFrames; func_8012C28C(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); if (this->unk_19A & 1) { - Matrix_RotateY(this->unk_19E[0].y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_19E[0].x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_19E[0].z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_19E[0].y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_19E[0].x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_19E[0].z, MTXMODE_APPLY); Matrix_Scale(this->unk_1B0[0].x, this->unk_1B0[0].y, this->unk_1B0[0].z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_19E[1].y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_19E[1].x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_19E[1].z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_19E[1].y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_19E[1].x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_19E[1].z, MTXMODE_APPLY); } gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1088,11 +1088,11 @@ void EnGs_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, object_gs_DL_0009D0); gSPDisplayList(POLY_OPA_DISP++, object_gs_DL_000A60); - Matrix_StatePop(); + Matrix_Pop(); if (this->unk_19A & 2) { func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(0.05f, -0.05f, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); 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 726287c0b..1394efff7 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 @@ -374,7 +374,7 @@ void EnGuardNuts_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnGuardNuts_OverrideLimbDraw, NULL, &this->actor); - Matrix_InsertTranslation(this->guardPos.x, this->actor.floorHeight, this->guardPos.z, MTXMODE_NEW); + Matrix_Translate(this->guardPos.x, this->actor.floorHeight, this->guardPos.z, MTXMODE_NEW); Matrix_Scale(0.015f, 0.015f, 0.015f, 1); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c index 108d62afd..d8551103d 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -350,7 +350,7 @@ void func_80B228F4(Actor* thisx, GlobalContext* globalCtx) { void EnHakurock_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(-100.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(-100.0f, 0.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_boss_hakugin_DL_011100); gSPDisplayList(POLY_OPA_DISP++, object_boss_hakugin_DL_011178); 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 d7ec6103f..f90ed476b 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -153,15 +153,15 @@ void func_80B22FA8(EnHanabiStruct* arg0, GlobalContext* globalCtx2) { for (i = 0; i < 400; i++, arg0++) { if (arg0->unk_00 == 1) { - Matrix_InsertTranslation(arg0->unk_08.x, arg0->unk_08.y, arg0->unk_08.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(arg0->unk_08.x, arg0->unk_08.y, arg0->unk_08.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); if (arg0->unk_01 < 40) { Matrix_Scale(arg0->unk_04 * 0.025f * arg0->unk_01, arg0->unk_04 * 0.025f * arg0->unk_01, 1.0f, MTXMODE_APPLY); } else { Matrix_Scale(arg0->unk_04, arg0->unk_04, 1.0f, MTXMODE_APPLY); } - Matrix_InsertZRotation_s(globalCtx->gameplayFrames * 4864, MTXMODE_APPLY); + Matrix_RotateZS(globalCtx->gameplayFrames * 4864, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -348,7 +348,7 @@ void EnHanabi_Update(Actor* thisx, GlobalContext* globalCtx) { void EnHanabi_Draw(Actor* thisx, GlobalContext* globalCtx) { EnHanabi* this = THIS; - Matrix_StatePush(); + Matrix_Push(); func_80B22FA8(this->unk_148, globalCtx); - Matrix_StatePop(); + Matrix_Pop(); } 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 0bbef0b9e..2b77feacf 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -402,9 +402,9 @@ s32 EnHg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnHg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnHg* this = THIS; if (limbIndex == HG_LIMB_HEAD) { - Matrix_CopyCurrentState(&this->unk1D8); + Matrix_Get(&this->unk1D8); } else if (limbIndex == HG_LIMB_PELVIS) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } @@ -415,7 +415,7 @@ void EnHg_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnHg_OverrideLimbDraw, EnHg_PostLimbDraw, &this->actor); - Matrix_SetCurrentState(&this->unk1D8); + Matrix_Put(&this->unk1D8); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_harfgibud_DL_005E28); CLOSE_DISPS(globalCtx->state.gfxCtx); 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 2aa217846..a16e0d94a 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -361,8 +361,8 @@ void EnHgo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnHgo* this = THIS; if (limbIndex == HGO_LIMB_PELVIS) { - Matrix_CopyCurrentState(&this->unk_1D8); - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_Get(&this->unk_1D8); + Matrix_MultZero(&this->actor.focus.pos); } } @@ -374,7 +374,7 @@ void EnHgo_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->unk_30C])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnHgo_OverrideLimbDraw, &EnHgo_PostLimbDraw, &this->actor); - Matrix_SetCurrentState(&this->unk_1D8); + Matrix_Put(&this->unk_1D8); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_harfgibud_DL_00F248); CLOSE_DISPS(globalCtx->state.gfxCtx); 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 51a408e6e..c9b9485ce 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 @@ -852,9 +852,9 @@ s32 EnHintSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL CLOSE_DISPS(globalCtx->state.gfxCtx); } else if (limbIndex == 10) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } else if ((limbIndex == 12) && (this->unk_3DE == 1)) { - Matrix_InsertZRotation_s(0x71C, MTXMODE_APPLY); + Matrix_RotateZS(0x71C, MTXMODE_APPLY); } if (((limbIndex == 11) || (limbIndex == 12)) && (this->unk_3E8 & 2)) { @@ -883,10 +883,10 @@ void EnHintSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList 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)) { - Matrix_GetStateTranslation(&this->limbPos[this->limbCount]); + Matrix_MultZero(&this->limbPos[this->limbCount]); this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_3E8 & 2)) { - Matrix_MultiplyVector3fByState(&D_80C21E70, &this->limbPos[this->limbCount]); + Matrix_MultVec3f(&D_80C21E70, &this->limbPos[this->limbCount]); this->limbCount++; } } diff --git a/src/overlays/actors/ovl_En_Holl/z_en_holl.c b/src/overlays/actors/ovl_En_Holl/z_en_holl.c index 8d5816c16..c3d577e7a 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -330,7 +330,7 @@ void EnHoll_Draw(Actor* thisx, GlobalContext* globalCtx) { } dl = Gfx_CallSetupDL(dl, dlIndex); if (this->playerSide == EN_HOLL_BEHIND) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } gSPMatrix(dl++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(dl++, 0, 0, 0, 0, 0, this->alpha); 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 54e388bc2..a0756abdf 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -4675,7 +4675,7 @@ s32 func_80888D18(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p EnHorse* this = THIS; if (limbIndex == 3) { - Matrix_MultiplyVector3fByState(&sp1C, &this->riderPos); + Matrix_MultVec3f(&sp1C, &this->riderPos); } return false; } diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c index 6b9a8dda1..ae5f25c87 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c @@ -77,12 +77,12 @@ s32 func_808F8AA0(EnHorseGameCheck* this, GlobalContext* globalCtx) { func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, this->dyna.actor.world.pos.z, &sp38); - Matrix_SetCurrentState(&sp38); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Put(&sp38); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.y, MTXMODE_APPLY); - Matrix_CopyCurrentState(&sp38); + Matrix_Get(&sp38); - func_8018219C(&sp38, &this->dyna.actor.shape.rot, 1); + Matrix_MtxFToYXZRot(&sp38, &this->dyna.actor.shape.rot, true); this->dyna.actor.world.rot = this->dyna.actor.shape.rot; return true; } @@ -373,12 +373,12 @@ s32 func_808F96E4(EnHorseGameCheck* this, GlobalContext* globalCtx) { func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, this->dyna.actor.world.pos.z, &sp38); - Matrix_SetCurrentState(&sp38); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Put(&sp38); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.y, MTXMODE_APPLY); - Matrix_CopyCurrentState(&sp38); + Matrix_Get(&sp38); - func_8018219C(&sp38, &this->dyna.actor.shape.rot, 1); + Matrix_MtxFToYXZRot(&sp38, &this->dyna.actor.shape.rot, true); this->dyna.actor.world.rot = this->dyna.actor.shape.rot; return true; } 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 5e886bcc0..1e9fdfbf9 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -349,7 +349,7 @@ void EnHs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnHs* this = THIS; if (limbIndex == HS_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_8095393C, &this->actor.focus.pos); + Matrix_MultVec3f(&D_8095393C, &this->actor.focus.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 c9f4f9b70..e687b770d 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -973,7 +973,7 @@ void EnIg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Vec3f sp2C; if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&D_80BF3528, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BF3528, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); gSPDisplayList((*gfx)++, object_dai_DL_008710); @@ -986,12 +986,12 @@ void EnIg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (limbIndex == 9) { gSPDisplayList((*gfx)++, object_dai_DL_008B00); - Matrix_MultiplyVector3fByState(&D_80BF351C, &sp2C); + Matrix_MultVec3f(&D_80BF351C, &sp2C); Math_Vec3f_ToVec3s(&this->collider2.dim.worldSphere.center, &sp2C); } if (limbIndex == 10) { - Matrix_CopyCurrentState(&this->unk_190); + Matrix_Get(&this->unk_190); } } @@ -1015,13 +1015,13 @@ void EnIg_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this if (limbIndex == 9) { SubS_UpdateLimb(this->unk_3E8 + 0x4000, this->unk_3EA + this->actor.shape.rot.y + 0x4000, &this->unk_2D4, &this->unk_2E6, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_2D4.x, this->unk_2D4.y, this->unk_2D4.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_2D4.x, this->unk_2D4.y, this->unk_2D4.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_2E6.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2E6.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2E6.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_2E6.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2E6.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2E6.z, MTXMODE_APPLY); + Matrix_Push(); } } @@ -1045,7 +1045,7 @@ void EnIg_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = SubS_DrawTransformFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnIg_OverrideLimbDraw, EnIg_PostLimbDraw, EnIg_TransformLimbDraw, &this->actor, POLY_OPA_DISP); - Matrix_SetCurrentState(&this->unk_190); + Matrix_Put(&this->unk_190); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dai_DL_00C538); 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 7dcaf7b64..ef4db6f9e 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -1482,7 +1482,7 @@ void func_808F6334(EnIn* this, GlobalContext* globalCtx) { this->unk4C4 += this->unk4C0 != 0.0f ? 40.0f : -40.0f; this->unk4C4 = CLAMP(this->unk4C4, 0.0f, 80.0f); - Matrix_InsertTranslation(this->unk4C4, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->unk4C4, 0.0f, 0.0f, MTXMODE_APPLY); if (&this->actor == player->targetActor && !(globalCtx->msgCtx.currentTextId >= 0xFF && globalCtx->msgCtx.currentTextId <= 0x200) && newUnk4C8 == 3 && this->unk4C8 == 3) { @@ -1543,15 +1543,15 @@ s32 EnIn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, CLOSE_DISPS(globalCtx->state.gfxCtx); if (limbIndex == 16) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->headRot.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + 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, globalCtx); } if (limbIndex == 9) { - Matrix_RotateY(this->torsoRot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->torsoRot.x, MTXMODE_APPLY); + Matrix_RotateYS(this->torsoRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->torsoRot.x, MTXMODE_APPLY); } if (limbIndex == 9 || limbIndex == 10 || limbIndex == 13) { rot->y += (s16)(Math_SinS(this->unk376[limbIndex]) * 200.0f); @@ -1581,16 +1581,16 @@ void EnIn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Vec3f sp44 = { 0.0f, 0.0f, 0.0f }; if (limbIndex == 16) { - Matrix_MultiplyVector3fByState(&sp50, &this->unk4B4); + 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) { - Matrix_MultiplyVector3fByState(&sp44, &this->unk248); + Matrix_MultVec3f(&sp44, &this->unk248); } if (limbIndex == 7) { - Matrix_MultiplyVector3fByState(&sp44, &this->unk254); + Matrix_MultVec3f(&sp44, &this->unk254); } if (this->unk23C == 0) { if (!(this->unk4AC & 8)) { diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 6c698234b..2eace7815 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -1325,11 +1325,11 @@ void func_80B454BC(EnInvadepoh* this, GlobalContext* globalCtx) { } void EnInvadepoh_SetSysMatrix(Vec3f* vec) { - MtxF* sysMatrix = Matrix_GetCurrentState(); + MtxF* sysMatrix = Matrix_GetCurrent(); - sysMatrix->wx = vec->x; - sysMatrix->wy = vec->y; - sysMatrix->wz = vec->z; + sysMatrix->xw = vec->x; + sysMatrix->yw = vec->y; + sysMatrix->zw = vec->z; } s32 func_80B45550(EnInvadepoh* this, GlobalContext* globalCtx, f32 range, s32 arg3) { @@ -2388,16 +2388,16 @@ void func_80B48060(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); Math_ScaledStepToS(&this->actor.shape.rot.x, D_80B4EDC0[temp], 0x32); if (this->actor.child != NULL) { - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - &this->actor.shape.rot); - Matrix_InsertTranslation(0, 57.0f, -36.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x * -0.7f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z * -0.7f, MTXMODE_APPLY); - Matrix_GetStateTranslation(&this->actor.child->world.pos); - Matrix_CopyCurrentState(&unkMtx); - func_8018219C(&unkMtx, &this->actor.child->shape.rot, 0); - Matrix_StatePop(); + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_Translate(0, 57.0f, -36.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x * -0.7f, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z * -0.7f, MTXMODE_APPLY); + Matrix_MultZero(&this->actor.child->world.pos); + Matrix_Get(&unkMtx); + Matrix_MtxFToYXZRot(&unkMtx, &this->actor.child->shape.rot, false); + Matrix_Pop(); } } @@ -4314,7 +4314,7 @@ void func_80B4D7B8(GlobalContext* globalCtx) { temp_v0 = globalCtx->gameplayFrames; temp_s5 = (temp_v0 + ((0x10 * i) & 0xFFU)) & 0x7F; temp_s6 = (u8)(temp_v0 * -0xF); - Matrix_InsertTranslation(phi_s2->unk4.x, phi_s2->unk4.y, phi_s2->unk4.z, MTXMODE_NEW); + Matrix_Translate(phi_s2->unk4.x, phi_s2->unk4.y, phi_s2->unk4.z, MTXMODE_NEW); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, phi_s2->unk2); @@ -4343,22 +4343,22 @@ void func_80B4D9F4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnInvadepoh* this = THIS; if ((limbIndex == 12) && (this->alienBeamAlpha != 0)) { - Matrix_StatePush(); - Matrix_InsertZRotation_s(-0x53ED, MTXMODE_APPLY); - Matrix_RotateY(-0x3830, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateZS(-0x53ED, MTXMODE_APPLY); + Matrix_RotateYS(-0x3830, MTXMODE_APPLY); Matrix_Scale(1.0f, 1.0f, 1.5f, MTXMODE_APPLY); - Matrix_CopyCurrentState(&D_80B502A0); - Matrix_StatePop(); + Matrix_Get(&D_80B502A0); + Matrix_Pop(); } else if ((limbIndex == 13) && (this->alienBeamAlpha != 0)) { - Matrix_StatePush(); - Matrix_InsertZRotation_s(-0x53ED, MTXMODE_APPLY); - Matrix_RotateY(-0x47D0, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateZS(-0x53ED, MTXMODE_APPLY); + Matrix_RotateYS(-0x47D0, MTXMODE_APPLY); Matrix_Scale(1.0f, 1.0f, 1.5f, MTXMODE_APPLY); - Matrix_CopyCurrentState(&D_80B502E0); - Matrix_StatePop(); + Matrix_Get(&D_80B502E0); + Matrix_Pop(); } if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&D_80B4EE24, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B4EE24, &this->actor.focus.pos); } } @@ -4369,7 +4369,7 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(spCC); func_8012C2DC(spCC); - Matrix_StatePush(); + Matrix_Push(); if (this->drawAlien) { Gfx* new_var6; Gfx* spBC; @@ -4399,10 +4399,10 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(spBC++); gDPSetPrimColor(spBC++, 0, 255, 240, 180, 100, 60); gDPSetEnvColor(spBC++, 255, 255, 255, this->alienBeamAlpha * (150.0f / 255.0f)); - Matrix_InsertMatrix(&D_80B502A0, MTXMODE_NEW); + Matrix_Mult(&D_80B502A0, MTXMODE_NEW); gSPMatrix(spBC++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(spBC++, object_uch_DL_000080); - Matrix_InsertMatrix(&D_80B502E0, MTXMODE_NEW); + Matrix_Mult(&D_80B502E0, MTXMODE_NEW); gSPMatrix(spBC++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(spBC++, object_uch_DL_000080); spB8->polyXlu.p = spBC; @@ -4410,8 +4410,8 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { } if (this->drawAlienDeathEffect) { - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 68.0f, - this->actor.world.pos.z, &this->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y + 68.0f, this->actor.world.pos.z, + &this->actor.shape.rot); Matrix_Scale(this->alienDeathEffectScale.x, this->alienDeathEffectScale.y, this->alienDeathEffectScale.z, MTXMODE_APPLY); gSPMatrix(spCC->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -4431,12 +4431,12 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { gDPSetDither(gfx++, G_CD_NOISE); gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(60.0f, &sp80); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_NEW); + Matrix_MultVecZ(60.0f, &sp80); sp74.x = thisx->world.pos.x + sp80.x; sp74.y = thisx->world.pos.y + sp80.y + 68.0f; sp74.z = thisx->world.pos.z + sp80.z; - Matrix_InsertTranslation(sp74.x, sp74.y, sp74.z, MTXMODE_NEW); + Matrix_Translate(sp74.x, sp74.y, sp74.z, MTXMODE_NEW); Matrix_Scale(0.25f, 0.25f, 0.25f, MTXMODE_APPLY); alpha2 = this->alienAlpha * (100.0f / 255.0f); gSPDisplayList(gfx++, gameplay_keep_DL_029CB0); @@ -4450,7 +4450,7 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { } } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(spCC); } @@ -4502,7 +4502,7 @@ void func_80B4E2AC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* gSPDisplayList(POLY_OPA_DISP++, object_ma1_DL_0003B0); CLOSE_DISPS(globalCtx->state.gfxCtx); } else if (limbIndex == 14) { - Matrix_MultiplyVector3fByState(&D_80B4EE30, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B4EE30, &this->actor.focus.pos); } } @@ -4522,16 +4522,16 @@ void func_80B4E3F0(Actor* thisx, GlobalContext* globalCtx) { s32 pad[2]; Vec3f sp5C; - Matrix_StatePush(); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(200.0f, &sp5C); - Matrix_StatePop(); + Matrix_Push(); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_NEW); + Matrix_MultVecZ(200.0f, &sp5C); + Matrix_Pop(); sp5C.x += thisx->world.pos.x; sp5C.y += thisx->world.pos.y; sp5C.z += thisx->world.pos.z; EnInvadepoh_SetSysMatrix(&sp5C); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_InsertZRotation_s(((EnInvadepoh*)thisx)->unk304, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_RotateZS(((EnInvadepoh*)thisx)->unk304, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -4563,7 +4563,7 @@ void func_80B4E61C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnInvadepoh* this = THIS; if (limbIndex == DOG_LIMB_HEAD) { - Matrix_GetStateTranslationAndScaledY(20.0f, &this->actor.focus.pos); + Matrix_MultVecY(20.0f, &this->actor.focus.pos); } } @@ -4597,7 +4597,7 @@ void func_80B4E784(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnInvadepoh* this = THIS; if (limbIndex == 9) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c index ac42d0c7a..9b60a41dd 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -309,11 +309,11 @@ void func_8095DFF0(EnIshi* this, GlobalContext* globalCtx) { if (temp >= 0) { sp3C = Item_DropCollectible(globalCtx, &this->actor.world.pos, temp | (ENISHI_GET_FE00(&this->actor) << 8)); if (sp3C != NULL) { - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(1.0f, &sp30); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultVecY(1.0f, &sp30); sp2C = Math3D_Parallel(&sp30, &D_8095F778); if (sp2C < 0.707f) { temp_v1_2 = Math_FAtan2F(sp30.z, sp30.x) - sp3C->world.rot.y; @@ -326,7 +326,7 @@ void func_8095DFF0(EnIshi* this, GlobalContext* globalCtx) { } sp3C->velocity.y *= temp_f2; } - Matrix_StatePop(); + Matrix_Pop(); } } } 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 e6bc31eea..5659e5ba9 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -235,7 +235,7 @@ void func_80BC1E40(EnJa* this, GlobalContext* globalCtx) { this->unk_34C += (this->unk_348 != 0.0f) ? 60.0f : -60.0f; this->unk_34C = CLAMP(this->unk_34C, 0.0f, 120.0f); - Matrix_InsertTranslation(this->unk_34C, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->unk_34C, 0.0f, 0.0f, MTXMODE_APPLY); this->unk_374 = sp20; } @@ -420,18 +420,18 @@ void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec s32 pad2; if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&D_80BC3780, &this->actor.focus.pos); + 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)) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_JointPosition(&D_80BC3774, &D_80BC37A4); + Matrix_Push(); + Matrix_TranslateRotateZYX(&D_80BC3774, &D_80BC37A4); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BA30); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -441,9 +441,9 @@ void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec ((this->skelAnime.curFrame >= 35.0f) && (this->skelAnime.curFrame <= 47.0f)))) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_InsertTranslation(D_80BC378C.x, D_80BC378C.y, D_80BC378C.z, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Push(); + Matrix_Translate(D_80BC378C.x, D_80BC378C.y, D_80BC378C.z, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gDPPipeSync(POLY_OPA_DISP++); @@ -473,17 +473,17 @@ void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BCC8); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } else if (limbIndex == 14) { if ((this->skelAnime.curFrame >= 0.0f) && (this->skelAnime.curFrame <= 18.0f)) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); - Matrix_InsertTranslation(D_80BC3798.x, D_80BC3798.y, D_80BC3798.z, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(D_80BC3798.x, D_80BC3798.y, D_80BC3798.z, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gDPPipeSync(POLY_OPA_DISP++); @@ -513,7 +513,7 @@ void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BCC8); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -547,24 +547,24 @@ void EnJa_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this 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); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1EC.x, this->unk_1EC.y, this->unk_1EC.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_1EC.x, this->unk_1EC.y, this->unk_1EC.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_274.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_274.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_274.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_274.y, MTXMODE_APPLY); + 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_StatePop(); - Matrix_InsertTranslation(this->unk_1F8.x, this->unk_1F8.y, this->unk_1F8.z, MTXMODE_NEW); + 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_RotateY(this->unk_27A.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_27A.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_27A.z, MTXMODE_APPLY); - Matrix_StatePush(); + 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(); } } @@ -725,8 +725,8 @@ void func_80BC33C0(EnJaStruct* ptr, GlobalContext* globalCtx) { if (((ptr->unk_0E < 0) || (ptr->unk_0E >= 19)) && ((ptr->unk_0E < 83) || (ptr->unk_0E >= 103))) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); switch (ptr->unk_0C) { 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 4e50ceba6..6afe9c1a0 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 @@ -162,6 +162,6 @@ void EnJcMato_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_000390); - Matrix_MultiplyVector3fByState(&movement, &this->pos); + Matrix_MultVec3f(&movement, &this->pos); CLOSE_DISPS(globalCtx->state.gfxCtx); } 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 2fe0853cd..8f2408495 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -1004,10 +1004,10 @@ s32 EnJg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (this->flags & FLAG_LOOKING_AT_PLAYER) { Math_SmoothStepToS(&this->rootRotationWhenTalking, this->actor.yawTowardsPlayer - this->actor.shape.rot.y, 5, 0x1000, 0x100); - Matrix_RotateY(this->rootRotationWhenTalking, MTXMODE_APPLY); + Matrix_RotateYS(this->rootRotationWhenTalking, MTXMODE_APPLY); } else { Math_SmoothStepToS(&this->rootRotationWhenTalking, 0, 5, 0x1000, 0x100); - Matrix_RotateY(this->rootRotationWhenTalking, MTXMODE_APPLY); + Matrix_RotateYS(this->rootRotationWhenTalking, MTXMODE_APPLY); } } @@ -1018,14 +1018,14 @@ void EnJg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnJg* this = THIS; if (limbIndex == GORON_ELDER_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&sFocusOffset, &this->actor.focus.pos); + Matrix_MultVec3f(&sFocusOffset, &this->actor.focus.pos); } if (limbIndex == GORON_ELDER_LIMB_LOWER_LIP) { - Matrix_MultiplyVector3fByState(&sBreathPosOffset, &this->breathPos); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sBreathVelOffset, &this->breathVelocity); - Matrix_MultiplyVector3fByState(&sBreathAccelOffset, &this->breathAccel); + Matrix_MultVec3f(&sBreathPosOffset, &this->breathPos); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sBreathVelOffset, &this->breathVelocity); + Matrix_MultVec3f(&sBreathAccelOffset, &this->breathAccel); } } 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 104e2bc3c..c16fa4147 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 @@ -626,7 +626,7 @@ s32 EnJgamesTsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** void EnJgamesTsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { if (limbIndex == OBJECT_TSN_LIMB_0F) { - Matrix_GetStateTranslation(&thisx->focus.pos); + Matrix_MultZero(&thisx->focus.pos); } } 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 53dd9e671..78441bc41 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -1148,7 +1148,7 @@ void EnKakasi_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnKakasi* this = THIS; if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk1BC); + 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 e457ec219..d2a1f9902 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -770,7 +770,7 @@ void func_80AD8AF8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnKame* this = THIS; if (D_80AD8EA4[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[D_80AD8EA4[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_80AD8EA4[limbIndex]]); } if (limbIndex == 1) { @@ -779,13 +779,13 @@ void func_80AD8AF8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Vec3f* ptr2; if (this->actor.shape.shadowDraw == NULL) { - Matrix_GetStateTranslation(&this->actor.world.pos); + Matrix_MultZero(&this->actor.world.pos); } ptr2 = D_80AD8E68; ptr = &this->limbPos[5]; for (i = 0; i < ARRAY_COUNT(D_80AD8E68); i++) { - Matrix_MultiplyVector3fByState(ptr2, ptr); + Matrix_MultVec3f(ptr2, ptr); ptr2++; ptr++; } diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c index dee9a5049..921cb9633 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -339,8 +339,8 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { piece->pieceType = PIECE_WHOLE_SIGN; } - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sPieceOffsets[piece->pieceType], &offset); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sPieceOffsets[piece->pieceType], &offset); piece->actor.world.pos.x += offset.x; piece->actor.world.pos.y += offset.y; piece->actor.world.pos.z += offset.z; @@ -549,9 +549,9 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { } else { Vec3f spC8; - Matrix_SetStateXRotation(this->floorRot.x); - Matrix_InsertZRotation_f(this->floorRot.z, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(KREG(20) + 10.0f, &spC8); + Matrix_RotateXFNew(this->floorRot.x); + Matrix_RotateZF(this->floorRot.z, MTXMODE_APPLY); + Matrix_MultVecY(KREG(20) + 10.0f, &spC8); Math_ApproachF(&this->actor.velocity.x, spC8.x, 0.5f, (KREG(21) * 0.01f) + 0.1f); Math_ApproachF(&this->actor.velocity.z, spC8.z, 0.5f, (KREG(21) * 0.01f) + 0.3f); this->actor.world.rot.y = Math_Atan2S(spC8.x, spC8.z); @@ -855,8 +855,8 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } - Matrix_RotateY(signpost->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sPieceOffsets[this->pieceType], &offset); + Matrix_RotateYS(signpost->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&sPieceOffsets[this->pieceType], &offset); distX = Math_SmoothStepToF(&this->actor.world.pos.x, signpost->actor.world.pos.x + offset.x, 1.0f, 3.0f, 0.0f); distY = @@ -927,24 +927,23 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, object_kanban_DL_000C30); if (this->actionState != ENKANBAN_SIGN) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(this->floorRot.x); - Matrix_InsertZRotation_f(this->floorRot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateXFApply(this->floorRot.x); + Matrix_RotateZF(this->floorRot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); zShift = fabsf(Math_SinS(this->spinRot.x) * this->pieceHeight); zShift2 = fabsf(Math_SinS(this->spinRot.z) * this->pieceWidth); zShift = CLAMP_MIN(zShift, zShift2); zShift *= -(f32)this->direction; - Matrix_InsertTranslation(0.0f, 0.0f, zShift, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->spinRot.x, MTXMODE_APPLY); - Matrix_RotateY(this->spinRot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(this->offset.x, this->offset.y, this->offset.z - 100.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, zShift, MTXMODE_APPLY); + Matrix_RotateXS(this->spinRot.x, MTXMODE_APPLY); + Matrix_RotateYS(this->spinRot.z, MTXMODE_APPLY); + Matrix_Translate(this->offset.x, this->offset.y, this->offset.z - 100.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -960,7 +959,7 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { phi_f0 = -15.0f; } this->actor.world.pos.y = this->actor.home.pos.y + phi_f0; - Matrix_InsertTranslation(0.0f, 0.0f, -100.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -100.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (this->partFlags == 0xFFFF) { @@ -976,8 +975,8 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->cutMarkAlpha != 0) { f32 cutOffset = (this->cutType == CUT_POST) ? -1200.0f : 0.0f; - Matrix_InsertTranslation(0.0f, 4400.0f + cutOffset, 200.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_f(sCutAngles[this->cutType], MTXMODE_APPLY); + Matrix_Translate(0.0f, 4400.0f + cutOffset, 200.0f, MTXMODE_APPLY); + Matrix_RotateZF(sCutAngles[this->cutType], MTXMODE_APPLY); Matrix_Scale(0.0f, 10.0f, 2.0f, MTXMODE_APPLY); gDPPipeSync(POLY_XLU_DISP++); @@ -1011,21 +1010,21 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { zShift = ((this->actor.world.pos.y - this->actor.floorHeight) * -50.0f) / 100.0f; } - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z + zShift, - MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(this->floorRot.x); - Matrix_InsertZRotation_f(this->floorRot.z, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z + zShift, + MTXMODE_NEW); + Matrix_RotateXFApply(this->floorRot.x); + Matrix_RotateZF(this->floorRot.z, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, 0.0f, this->actor.scale.z, MTXMODE_APPLY); if (this->actionState == ENKANBAN_SIGN) { - Matrix_RotateStateAroundXAxis(-M_PI / 5); + Matrix_RotateXFApply(-M_PI / 5); } - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->spinRot.x, MTXMODE_APPLY); - Matrix_RotateY(this->spinRot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(this->offset.x, this->offset.y, this->offset.z, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateXS(this->spinRot.x, MTXMODE_APPLY); + Matrix_RotateYS(this->spinRot.z, MTXMODE_APPLY); + Matrix_Translate(this->offset.x, this->offset.y, this->offset.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); for (i = 0; i < ARRAY_COUNT(sShadowTexFlags); i++) { diff --git a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c index 7a59e702c..94452e054 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c @@ -633,7 +633,7 @@ void func_808F280C(EnKarebaba* this, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); func_800C0094(this->unk_22C, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, &sp40); - Matrix_InsertMatrix(&sp40, MTXMODE_NEW); + Matrix_Mult(&sp40, MTXMODE_NEW); Matrix_Scale(0.15f, 1.0f, 0.15f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -656,7 +656,7 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->actionFunc == func_808F21A4) { if ((this->unk_1EE > 40) || (this->unk_1EE & 1)) { - Matrix_InsertTranslation(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -665,8 +665,7 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { } else if (this->actionFunc != func_808F254C) { func_800AE2A0(globalCtx, &D_808F2E28, 1, 2); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); if ((this->actionFunc == func_808F241C) || (this->actionFunc == func_808F200C) || (this->actionFunc == func_808F15B0)) { @@ -674,7 +673,7 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { } Matrix_Scale(sp8C, sp8C, sp8C, MTXMODE_APPLY); - Matrix_InsertRotation(this->actor.shape.rot.x, this->actor.shape.rot.y, 0, MTXMODE_APPLY); + Matrix_RotateZYX(this->actor.shape.rot.x, this->actor.shape.rot.y, 0, MTXMODE_APPLY); if (this->actor.params == ENKAREBABA_2) { sp94 = 1; @@ -685,15 +684,15 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { } for (i = 0; i < sp94; i++) { - Matrix_InsertTranslation(0.0f, 0.0f, -2000.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -2000.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, D_808F2E2C[i]); - Matrix_GetStateTranslation(&this->limbPos[1 + i]); + Matrix_MultZero(&this->limbPos[1 + i]); if ((i == 0) && (this->actionFunc == func_808F1C84)) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } @@ -701,25 +700,25 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { } func_800AE2A0(globalCtx, &D_808F2E28, 1, 2); - Matrix_InsertTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, MTXMODE_NEW); + Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, MTXMODE_NEW); if (this->actionFunc != func_808F15B0) { sp8C = 0.01f; } Matrix_Scale(sp8C, sp8C, sp8C, MTXMODE_APPLY); - Matrix_RotateY(this->actor.home.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.home.rot.y, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_0010F0); if (this->actionFunc == func_808F1C84) { - Matrix_InsertRotation(-0x4000, this->actor.shape.rot.y - this->actor.home.rot.y, 0, MTXMODE_APPLY); + Matrix_RotateZYX(-0x4000, this->actor.shape.rot.y - this->actor.home.rot.y, 0, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_001828); - Matrix_GetStateTranslation(&this->limbPos[3]); + Matrix_MultZero(&this->limbPos[3]); } func_800AE5A0(globalCtx); 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 9a42980db..095378137 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c @@ -537,7 +537,7 @@ void EnKbt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnKbt* this = THIS; if (limbIndex == OBJECT_KBT_LIMB_09) { - Matrix_MultiplyVector3fByState(&D_80B34B84, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B34B84, &this->actor.focus.pos); } } 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 176a556e5..cc184cfed 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -1121,11 +1121,11 @@ void EnKgy_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnKgy* this = THIS; if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&D_80B432D8, &this->unk_2A8); + Matrix_MultVec3f(&D_80B432D8, &this->unk_2A8); } if (limbIndex == 16) { - Matrix_MultiplyVector3fByState(&D_80B432E4, &this->unk_2C0); + Matrix_MultVec3f(&D_80B432E4, &this->unk_2C0); } } @@ -1137,9 +1137,9 @@ void func_80B43074(EnKgy* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); func_800B8050(&this->actor, globalCtx, MTXMODE_NEW); - Matrix_StatePush(); - Matrix_InsertTranslation(-800.0f, 3100.0f, 8400.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(-800.0f, 3100.0f, 8400.0f, MTXMODE_APPLY); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); if (func_80B40D8C(globalCtx)) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_kgy_Matanimheader_00F6A0)); @@ -1161,7 +1161,7 @@ void func_80B43074(EnKgy* this, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePop(); + Matrix_Pop(); } void EnKgy_Draw(Actor* thisx, GlobalContext* globalCtx) { 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 4c9f10ff8..1767f3c86 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -117,7 +117,7 @@ static InitChainEntry sInitChain[] = { * */ void EnKusa_ApplySway(MtxF* matrix) { - MtxF* mtxState = Matrix_GetCurrentState(); + MtxF* mtxState = Matrix_GetCurrent(); f32* tmp = &mtxState->mf[0][0]; f32* tmp2 = &matrix->mf[0][0]; s32 i; diff --git a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c index e4e821427..6ba532cef 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -241,7 +241,7 @@ void func_80A5B508(void) { void func_80A5B954(MtxF* matrix, f32 arg1) { s32 i; - MtxF* temp = Matrix_GetCurrentState(); + MtxF* temp = Matrix_GetCurrent(); f32* tmp = (f32*)&temp->mf[0]; f32* tmp2 = (f32*)&matrix->mf[0]; @@ -1325,7 +1325,7 @@ void func_80A5E6F0(Actor* thisx, GlobalContext* globalCtx) { EnKusa2UnkBssSubStruct2* s = &D_80A5F1C0.unk_0480[i]; if (s->unk_2C > 0) { - Matrix_SetStateRotationAndTranslation(s->unk_04.x, s->unk_04.y, s->unk_04.z, &s->unk_20); + Matrix_SetTranslateRotateYXZ(s->unk_04.x, s->unk_04.y, s->unk_04.z, &s->unk_20); Matrix_Scale(s->unk_00, s->unk_00, s->unk_00, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -1369,7 +1369,7 @@ void func_80A5E9B4(Actor* thisx, GlobalContext* globalCtx) { sp18.x = thisx->shape.rot.x + D_80A5EAFC.x; sp18.y = thisx->shape.rot.y + D_80A5EAFC.y; sp18.z = thisx->shape.rot.z + D_80A5EAFC.z; - Matrix_SetStateRotationAndTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, &sp18); + Matrix_SetTranslateRotateYXZ(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, &sp18); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); Gfx_DrawDListOpa(globalCtx, gKusaBushType1); } diff --git a/src/overlays/actors/ovl_En_Light/z_en_light.c b/src/overlays/actors/ovl_En_Light/z_en_light.c index f815147a2..9dc919e0e 100644 --- a/src/overlays/actors/ovl_En_Light/z_en_light.c +++ b/src/overlays/actors/ovl_En_Light/z_en_light.c @@ -186,11 +186,11 @@ void EnLight_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); } - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y), - MTXMODE_APPLY); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y), + MTXMODE_APPLY); if (ENLIGHT_GET_1(&this->actor)) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c index 73a559a70..774acf118 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c @@ -334,11 +334,11 @@ void EnLookNuts_Update(Actor* thisx, GlobalContext* globalCtx) { effectPos.x += Math_SinS((this->actor.world.rot.y + (s16)this->headRotation.y)) * 10.0f; effectPos.y += 30.0f; effectPos.z += Math_CosS((this->actor.world.rot.y + (s16)this->headRotation.y)) * 10.0f; - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); effectVelOffset.z = 20.0f; - Matrix_MultiplyVector3fByState(&effectVelOffset, &effectVel); - Matrix_StatePop(); + Matrix_MultVec3f(&effectVelOffset, &effectVel); + Matrix_Pop(); if (!this->isPlayerDetected) { s16 drawFlag = 1; if (gSaveContext.save.isNight) { diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index 8905a862d..226059ae2 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -1052,7 +1052,7 @@ void EnMa4_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Vec3f sp28 = { 800.0f, 0.0f, 0.0f }; if (limbIndex == MA1_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&sp28, &this->actor.focus.pos); + Matrix_MultVec3f(&sp28, &this->actor.focus.pos); } else if (limbIndex == MA1_LIMB_HAND_LEFT) { if (this->hasBow == true) { OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c index 5847aa897..52c6a2998 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -1451,7 +1451,7 @@ void EnMaYto_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnMaYto* this = THIS; if (limbIndex == MA2_LIMB_HEAD) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c index 721e2f742..f5bf0625b 100644 --- a/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c +++ b/src/overlays/actors/ovl_En_Ma_Yts/z_en_ma_yts.c @@ -526,7 +526,7 @@ void EnMaYts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnMaYts* this = THIS; if (limbIndex == MA1_LIMB_HEAD) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } else if (limbIndex == MA1_LIMB_HAND_LEFT) { if (this->hasBow == true) { OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c index 9d6f6312e..cc56a5e5e 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c @@ -621,10 +621,10 @@ void func_80B38060(EnMaruta* this, Vec3f* arg1) { } void func_80B3828C(Vec3f* arg0, Vec3f* arg1, s16 arg2, s16 arg3, s32 arg4) { - Matrix_StatePush(); - Matrix_InsertRotation(arg2, arg3, arg4, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(arg0, arg1); - Matrix_StatePop(); + Matrix_Push(); + Matrix_RotateZYX(arg2, arg3, arg4, MTXMODE_NEW); + Matrix_MultVec3f(arg0, arg1); + Matrix_Pop(); } void func_80B382E4(GlobalContext* globalCtx, Vec3f arg1) { @@ -672,10 +672,10 @@ void EnMaruta_Draw(Actor* thisx, GlobalContext* globalCtx) { } else { sp50 = D_80B387E4[this->unk_210]; - Matrix_StatePush(); - Matrix_InsertTranslation(sp50.x, sp50.y, sp50.z, MTXMODE_APPLY); - Matrix_InsertRotationAroundUnitVector_s(this->unk_218, &this->unk_194, MTXMODE_APPLY); - Matrix_InsertTranslation(-sp50.x, -sp50.y, -sp50.z, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(sp50.x, sp50.y, sp50.z, MTXMODE_APPLY); + Matrix_RotateAxisS(this->unk_218, &this->unk_194, MTXMODE_APPLY); + Matrix_Translate(-sp50.x, -sp50.y, -sp50.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -687,12 +687,12 @@ void EnMaruta_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_1A0 != NULL) { for (i = 0; i < ARRAY_COUNT(this->unk_1A4); i++) { - Matrix_MultiplyVector3fByState(&this->unk_1A0[i], &this->unk_1A4[i]); + Matrix_MultVec3f(&this->unk_1A0[i], &this->unk_1A4[i]); } - Matrix_MultiplyVector3fByState(&sp50, &this->unk_204); + Matrix_MultVec3f(&sp50, &this->unk_204); } - Matrix_StatePop(); + Matrix_Pop(); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index 3e67b4db6..d8b4296cb 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -620,14 +620,14 @@ void EnMinifrog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis if ((limbIndex == 7) || (limbIndex == 8)) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, *dList); CLOSE_DISPS(globalCtx->state.gfxCtx); } if (limbIndex == 4) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } } 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 8c20b4106..b0e468ab2 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -474,7 +474,7 @@ void EnMk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnMk* this = THIS; if (limbIndex == OBJECT_MK_LIMB_0B) { - Matrix_MultiplyVector3fByState(&D_8095A2A0, &this->actor.focus.pos); + Matrix_MultVec3f(&D_8095A2A0, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Mm/z_en_mm.c b/src/overlays/actors/ovl_En_Mm/z_en_mm.c index 5f79cf9e4..7cdddfcfd 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -212,9 +212,9 @@ void EnMm_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_190 != 0) { s16 rotY = this->actor.world.rot.y - this->actor.shape.rot.y; - Matrix_RotateY(rotY, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_190, MTXMODE_APPLY); - Matrix_RotateY(-rotY, MTXMODE_APPLY); + Matrix_RotateYS(rotY, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_190, MTXMODE_APPLY); + Matrix_RotateYS(-rotY, MTXMODE_APPLY); } gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_055628); diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index 393b253a9..6ee806d2e 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -534,7 +534,7 @@ s32 EnMm3_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, rot->x += this->unk_2A0.y; rot->z += this->unk_2A0.x; if ((this->unk_2B0 & 2) && ((globalCtx->gameplayFrames % 3) == 0)) { - Matrix_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); } } return false; @@ -544,7 +544,7 @@ void EnMm3_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnMm3* this = THIS; if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&D_80A704F0, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80A704F0, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c index 60de87422..4afae5793 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -106,7 +106,7 @@ static InitChainEntry sInitChain[] = { static f32 D_80A6BA14[] = { 0.06f, 0.1f, 0.13f }; void func_80A687A0(EnMushi2* this) { - MtxF* matrix = Matrix_GetCurrentState(); + MtxF* matrix = Matrix_GetCurrent(); matrix->mf[3][0] += this->unk_348 * this->unk_31C.x; matrix->mf[3][1] += this->unk_348 * this->unk_31C.y; @@ -114,8 +114,8 @@ void func_80A687A0(EnMushi2* this) { } void func_80A68808(EnMushi2* this) { - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - &this->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); } @@ -283,12 +283,12 @@ void func_80A68ED8(EnMushi2* this) { } void func_80A68F24(EnMushi2* this) { - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&D_80A6B9A0, &this->unk_310); - Matrix_MultiplyVector3fByState(&D_80A6B9AC, &this->unk_31C); - Matrix_MultiplyVector3fByState(&D_80A6B9B8, &this->unk_328); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultVec3f(&D_80A6B9A0, &this->unk_310); + Matrix_MultVec3f(&D_80A6B9AC, &this->unk_31C); + Matrix_MultVec3f(&D_80A6B9B8, &this->unk_328); } s32 func_80A68F9C(EnMushi2* this, s16 arg1) { @@ -298,7 +298,7 @@ s32 func_80A68F9C(EnMushi2* this, s16 arg1) { return false; } - matrix = Matrix_GetCurrentState(); + matrix = Matrix_GetCurrent(); matrix->mf[0][0] = this->unk_310.x; matrix->mf[0][1] = this->unk_310.y; @@ -320,7 +320,7 @@ s32 func_80A68F9C(EnMushi2* this, s16 arg1) { matrix->mf[3][2] = 0.0f; matrix->mf[3][3] = 0.0f; - Matrix_RotateY(arg1, MTXMODE_APPLY); + Matrix_RotateYS(arg1, MTXMODE_APPLY); this->unk_310.x = matrix->mf[0][0]; this->unk_310.y = matrix->mf[0][1]; @@ -345,7 +345,7 @@ s32 func_80A690C4(EnMushi2* this, s16 arg1) { return false; } - matrix = Matrix_GetCurrentState(); + matrix = Matrix_GetCurrent(); matrix->mf[0][0] = this->unk_310.x; matrix->mf[0][1] = this->unk_310.y; @@ -367,7 +367,7 @@ s32 func_80A690C4(EnMushi2* this, s16 arg1) { matrix->mf[3][2] = 0.0f; matrix->mf[3][3] = 0.0f; - Matrix_InsertXRotation_s(arg1, MTXMODE_APPLY); + Matrix_RotateXS(arg1, MTXMODE_APPLY); this->unk_310.x = matrix->mf[0][0]; this->unk_310.y = matrix->mf[0][1]; @@ -435,7 +435,7 @@ void func_80A69388(EnMushi2* this) { D_80A6B9C4.mf[2][1] = this->unk_328.y; D_80A6B9C4.mf[2][2] = this->unk_328.z; - func_8018219C(&D_80A6B9C4, &this->actor.world.rot, 0); + Matrix_MtxFToYXZRot(&D_80A6B9C4, &this->actor.world.rot, false); this->actor.shape.rot = this->actor.world.rot; } diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index e3be9ae03..493666856 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -1033,11 +1033,11 @@ void EnNiw_DrawFeathers(EnNiw* this, GlobalContext* globalCtx) { isMaterialApplied++; } - Matrix_InsertTranslation(feather->pos.x, feather->pos.y, feather->pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(feather->pos.x, feather->pos.y, feather->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(feather->scale, feather->scale, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_f(feather->zRot, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -1000.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZF(feather->zRot, MTXMODE_APPLY); + Matrix_Translate(0.0f, -1000.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c index 3eed47b71..87100d17f 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -112,7 +112,7 @@ void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx2) { if ((player->currentShield == PLAYER_SHIELD_HEROS_SHIELD) && (this->collider.base.atFlags & AT_HIT) && (this->collider.base.atFlags & AT_TYPE_ENEMY) && (this->collider.base.atFlags & AT_BOUNCED)) { EnNutsball_InitColliderParams(this); - func_8018219C(&player->shieldMf, &worldRot, 0); + Matrix_MtxFToYXZRot(&player->shieldMf, &worldRot, false); this->actor.world.rot.y = BINANG_ROT180(worldRot.y); this->timer = 20; } else { @@ -171,8 +171,8 @@ void EnNutsball_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.home.rot.z, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.home.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_058BA0); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Osk/z_en_osk.c b/src/overlays/actors/ovl_En_Osk/z_en_osk.c index 30d9a1666..20c0dd19d 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.c +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.c @@ -505,7 +505,7 @@ void func_80BF6C54(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnOsk* this = THIS; if (limbIndex == 1) { - Matrix_MultiplyVector3fByState(&D_80BF7024, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BF7024, &this->actor.focus.pos); } } @@ -539,8 +539,8 @@ void EnOsk_Draw(Actor* thisx, GlobalContext* globalCtx) { sp80.y = -(Math_SinS(sp60) * 15.0f); sp80.z = -(15.0f * (Math_CosS(sp62)) * Math_CosS(sp60)); - Matrix_InsertTranslation(this->actor.focus.pos.x + sp80.x, this->actor.focus.pos.y + sp80.y, - sp80.z = this->actor.focus.pos.z + sp80.z, MTXMODE_NEW); + Matrix_Translate(this->actor.focus.pos.x + sp80.x, this->actor.focus.pos.y + sp80.y, + sp80.z = this->actor.focus.pos.z + sp80.z, MTXMODE_NEW); sp80.z = Math_SinS(globalCtx->gameplayFrames << 0xE); sp80.z = ((sp80.z + 1.0f) * 0.1f) + 2.0f; diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.c b/src/overlays/actors/ovl_En_Osn/z_en_osn.c index 48a87b30e..90cd6785f 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -854,7 +854,7 @@ s32 EnOsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnOsn* this = (EnOsn*)thisx; if (this->unk_1F0 && limbIndex == 11) { - Matrix_InsertXRotation_s(this->unk_1D8.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1D8.y, MTXMODE_APPLY); } if ((this->unk_1EC == 9 || this->unk_1EC == 8) && limbIndex == 10) { *dList = NULL; @@ -868,18 +868,18 @@ void EnOsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Vec3s sp28 = { 0x9920, -0x384, -0x320 }; if (limbIndex == 11) { - Matrix_MultiplyVector3fByState(&sp30, &thisx->focus.pos); + Matrix_MultVec3f(&sp30, &thisx->focus.pos); } if (((this->unk_1EC == 17) || (this->unk_1EC == 21) || (this->unk_1EC == 22)) && (limbIndex == 6)) { - Matrix_StatePush(); - Matrix_InsertTranslation(-400.0f, 1100.0f, -200.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(sp28.x, MTXMODE_APPLY); - Matrix_RotateY(sp28.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(sp28.z, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(-400.0f, 1100.0f, -200.0f, MTXMODE_APPLY); + Matrix_RotateXS(sp28.x, MTXMODE_APPLY); + Matrix_RotateYS(sp28.y, MTXMODE_APPLY); + Matrix_RotateZS(sp28.z, MTXMODE_APPLY); gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList((*gfx)++, &object_osn_DL_0192A0); - Matrix_StatePop(); + Matrix_Pop(); } } diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index a1c276cad..ff85b7625 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -1673,7 +1673,7 @@ s32 EnOssan_CuriosityShopMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limb EnOssan* this = THIS; if (limbIndex == FSN_LIMB_HEAD) { - Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); } return false; } @@ -1683,8 +1683,8 @@ s32 EnOssan_PartTimeWorker_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIn EnOssan* this = THIS; if (limbIndex == ANI_LIMB_HEAD) { - Matrix_InsertXRotation_s(this->headRotPartTimeWorker.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->headRotPartTimeWorker.x, MTXMODE_APPLY); + Matrix_RotateXS(this->headRotPartTimeWorker.y, MTXMODE_APPLY); + Matrix_RotateZS(this->headRotPartTimeWorker.x, MTXMODE_APPLY); } return false; } @@ -1705,7 +1705,7 @@ void EnOssan_PartTimeWorker_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex EnOssan* this = THIS; if (limbIndex == ANI_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&sPartTimeWorkerFocusOffset, &this->actor.focus.pos); + Matrix_MultVec3f(&sPartTimeWorkerFocusOffset, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index 7573947e6..8ef3e1bfc 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -181,8 +181,8 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { &bgId, &this->actor.world.pos) + 50.0f; if (gSaveContext.save.weekEventReg[84] & 0x10) { - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(52.519997f, &sp64); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVecZ(52.519997f, &sp64); Math_Vec3f_Sum(&this->actor.world.pos, &sp64, &sp64); this->unk_360 = (EnOt*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OT, sp64.x, sp64.y, sp64.z, 0, BINANG_ROT180(this->actor.shape.rot.y), 1, @@ -206,8 +206,8 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { } else if ((D_80B5E888 != NULL) && (D_80B5E888->unk_32C & 1)) { this->unk_360 = D_80B5E888; this->unk_360->unk_360 = this; - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(800.0f, &sp58); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_NEW); + Matrix_MultVecZ(800.0f, &sp58); Math_Vec3f_Sum(&this->actor.world.pos, &sp58, &sp58); Math_Vec3f_Copy(&this->unk_360->actor.world.pos, &sp58); Math_Vec3f_Copy(&this->unk_360->actor.prevPos, &sp58); @@ -354,8 +354,8 @@ void func_80B5BFB8(EnOt* this, GlobalContext* globalCtx) { if (Actor_DistanceBetweenActors(&this->actor, &this->unk_360->actor) <= 52.519997f) { this->unk_73C = 50; - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(52.519997f, &sp34); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_NEW); + Matrix_MultVecZ(52.519997f, &sp34); this->unk_360->actor.world.pos.x = this->actor.world.pos.x + sp34.x; this->unk_360->actor.world.pos.y = this->actor.world.pos.y + sp34.y; this->unk_360->actor.world.pos.z = this->actor.world.pos.z + sp34.z; @@ -437,9 +437,9 @@ void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx) { Vec3f sp38; this->unk_3A0 += 0x2D8; - Matrix_RotateY(this->unk_3A0, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(26.259998f, &sp5C); - Matrix_GetStateTranslationAndScaledZ(-26.259998f, &sp50); + Matrix_RotateYS(this->unk_3A0, MTXMODE_NEW); + Matrix_MultVecZ(26.259998f, &sp5C); + Matrix_MultVecZ(-26.259998f, &sp50); this->unk_348.x = this->unk_394.x + sp5C.x; this->unk_348.y = this->unk_394.y; this->unk_348.z = this->unk_394.z + sp5C.z; @@ -461,17 +461,17 @@ void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 12.0f)) { - Matrix_RotateY(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_NEW); + Matrix_RotateYS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_NEW); sp38.x = 1.0f; sp38.y = 8.1f; sp38.z = 0.0f; - Matrix_MultiplyVector3fByState(&sp38, &sp44); + Matrix_MultVec3f(&sp38, &sp44); Math_Vec3f_Sum(&this->unk_74C, &sp44, &sp44); func_80B5DF58(this->unk_3A4, 1, &sp44, &this->actor.shape.rot, 10); sp38.x = -1.0f; sp38.y = 8.1f; sp38.z = 0.0f; - Matrix_MultiplyVector3fByState(&sp38, &sp44); + Matrix_MultVec3f(&sp38, &sp44); Math_Vec3f_Sum(&this->unk_74C, &sp44, &sp44); func_80B5DF58(this->unk_3A4, 2, &sp44, &this->actor.shape.rot, 10); } @@ -500,9 +500,9 @@ void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx) { Vec3f sp30; sp3E = Actor_YawToPoint(&player->actor, &this->unk_394); - Matrix_RotateY(BINANG_ADD(sp3E, 0x4000), MTXMODE_NEW); + Matrix_RotateYS(BINANG_ADD(sp3E, 0x4000), MTXMODE_NEW); if (this->unk_33C == 2) { - Matrix_GetStateTranslationAndScaledZ(26.259998f, &sp30); + Matrix_MultVecZ(26.259998f, &sp30); } else { if (this->unk_73C == 0) { gSaveContext.save.weekEventReg[84] |= 0x10; @@ -519,7 +519,7 @@ void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx) { } else { this->unk_73C--; } - Matrix_GetStateTranslationAndScaledZ(-26.259998f, &sp30); + Matrix_MultVecZ(-26.259998f, &sp30); } this->unk_348.x = this->unk_394.x + sp30.x; this->unk_348.y = this->unk_394.y; @@ -711,8 +711,8 @@ void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx) { this->unk_360 = D_80B5E888; this->unk_360->unk_360 = this; - Matrix_RotateY(this->actor.home.rot.y, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(800.0f, &sp2C); + Matrix_RotateYS(this->actor.home.rot.y, MTXMODE_NEW); + Matrix_MultVecZ(800.0f, &sp2C); Math_Vec3f_Sum(&this->actor.world.pos, &sp2C, &this->unk_360->actor.world.pos); Math_Vec3f_Copy(&this->unk_360->actor.prevPos, &this->unk_360->actor.world.pos); this->unk_32C &= ~0x800; @@ -1024,9 +1024,9 @@ void EnOt_Draw(Actor* thisx, GlobalContext* globalCtx) { EnOt* this = THIS; Gfx* gfx; - Matrix_StatePush(); + Matrix_Push(); func_80B5E1D8(globalCtx, this->unk_3A4, 10); - Matrix_StatePop(); + Matrix_Pop(); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1038,7 +1038,7 @@ void EnOt_Draw(Actor* thisx, GlobalContext* globalCtx) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_ot_Matanimheader_0005F8)); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnOt_PostLimbDraw, &this->actor); - Matrix_InsertTranslation(this->unk_378.x, this->unk_378.y, this->unk_378.z, MTXMODE_NEW); + Matrix_Translate(this->unk_378.x, this->unk_378.y, this->unk_378.z, MTXMODE_NEW); Matrix_Scale(0.0882f, 0.0882f, 0.0882f, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1068,11 +1068,11 @@ void EnOt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec gSPDisplayList(&gfx[0], object_ot_DL_0004A0); POLY_OPA_DISP = &gfx[1]; - Matrix_MultiplyVector3fByState(&D_80B5E410, &this->unk_74C); + Matrix_MultVec3f(&D_80B5E410, &this->unk_74C); CLOSE_DISPS(globalCtx->state.gfxCtx); } else if (limbIndex == 1) { - Matrix_GetStateTranslation(&this->unk_378); + Matrix_MultZero(&this->unk_378); this->unk_32C |= 0x400; } } @@ -1123,8 +1123,8 @@ void func_80B5E078(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2) { sp54.x = arg1->unk_30; sp54.y = arg1->unk_34; sp54.z = 0.0f; - Matrix_RotateY(temp, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&sp54, &arg1->unk_0C); + Matrix_RotateYS(temp, MTXMODE_NEW); + Matrix_MultVec3f(&sp54, &arg1->unk_0C); Math_Vec3f_Sum(&arg1->unk_0C, &arg1->unk_50, &arg1->unk_0C); arg1->unk_4C--; } @@ -1148,8 +1148,8 @@ void func_80B5E1D8(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2) { if (globalCtx) {} } - Matrix_InsertTranslation(arg1->unk_0C.x, arg1->unk_0C.y, arg1->unk_0C.z, MTXMODE_NEW); - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_Translate(arg1->unk_0C.x, arg1->unk_0C.y, arg1->unk_0C.z, MTXMODE_NEW); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); Matrix_Scale(arg1->unk_04, arg1->unk_04, arg1->unk_04, MTXMODE_APPLY); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_05E6F0)); diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index ab8f721ae..d324c8d92 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -1136,7 +1136,7 @@ void EnOwl_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } if (limbIndex == 3) { - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); } } @@ -1166,9 +1166,9 @@ void func_8095D074(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, 500.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_3D8 - 0x4000, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -500.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 500.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_3D8 - 0x4000, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -500.0f, MTXMODE_APPLY); if (this->unk_3DC >= 0x20) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index 06cf9b22d..e17cba0e2 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -546,7 +546,7 @@ void EnPamera_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnPamera* this = THIS; if (limbIndex == PAMERA_LIMB_HAIR) { - Matrix_MultiplyVector3fByState(&D_80BDA5F0, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BDA5F0, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c index 542238a17..86b2eb671 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -278,16 +278,16 @@ void func_8086A238(EnPametfrog* this) { MtxF unkMtx; unkMtx.xx = this->unk_2E8.x; - unkMtx.xy = this->unk_2E8.y; - unkMtx.xz = this->unk_2E8.z; - unkMtx.yx = this->unk_2DC.x; + unkMtx.yx = this->unk_2E8.y; + unkMtx.zx = this->unk_2E8.z; + unkMtx.xy = this->unk_2DC.x; unkMtx.yy = this->unk_2DC.y; - unkMtx.yz = this->unk_2DC.z; - unkMtx.zx = this->unk_2D0.x; - unkMtx.zy = this->unk_2D0.y; + unkMtx.zy = this->unk_2DC.z; + unkMtx.xz = this->unk_2D0.x; + unkMtx.yz = this->unk_2D0.y; unkMtx.zz = this->unk_2D0.z; - func_8018219C(&unkMtx, &this->actor.shape.rot, 0); + Matrix_MtxFToYXZRot(&unkMtx, &this->actor.shape.rot, false); this->actor.world.rot.x = -this->actor.shape.rot.x; this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.world.rot.z = this->actor.shape.rot.z; @@ -315,8 +315,8 @@ s32 func_8086A2CC(EnPametfrog* this, CollisionPoly* floorPoly) { Math3D_CrossProduct(&this->unk_2DC, &floorNorm, &vec2); EnPametfrog_Vec3fNormalize(&vec2); - Matrix_InsertRotationAroundUnitVector_f(rotation, &vec2, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&this->unk_2E8, &vec2); + Matrix_RotateAxisF(rotation, &vec2, MTXMODE_NEW); + Matrix_MultVec3f(&this->unk_2E8, &vec2); Math_Vec3f_Copy(&this->unk_2E8, &vec2); Math3D_CrossProduct(&this->unk_2E8, &floorNorm, &this->unk_2D0); EnPametfrog_Vec3fNormalize(&this->unk_2D0); @@ -683,8 +683,8 @@ void EnPametfrog_WallPause(EnPametfrog* this, GlobalContext* globalCtx) { } else { SkelAnime_Update(&this->skelAnime); this->timer--; - Matrix_InsertRotationAroundUnitVector_f(this->wallRotation, &this->unk_2DC, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&this->unk_2D0, &vec); + Matrix_RotateAxisF(this->wallRotation, &this->unk_2DC, MTXMODE_NEW); + Matrix_MultVec3f(&this->unk_2D0, &vec); Math_Vec3f_Copy(&this->unk_2D0, &vec); Math3D_CrossProduct(&this->unk_2DC, &this->unk_2D0, &this->unk_2E8); func_8086A238(this); @@ -1395,9 +1395,9 @@ void EnPametfrog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi s8 index; if (limbIndex == GEKKO_LIMB_HEAD) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); this->actor.focus.rot.y = this->actor.shape.rot.y; - Matrix_GetStateTranslationAndScaledY(2500.0f, &vec); + Matrix_MultVecY(2500.0f, &vec); center = &this->collider.elements[0].dim.worldSphere.center; center->x = vec.x; center->y = vec.y; @@ -1410,7 +1410,7 @@ void EnPametfrog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi index = limbPosIndex[limbIndex]; if (index != -1) { - Matrix_GetStateTranslation(&this->limbPos[index]); + Matrix_MultZero(&this->limbPos[index]); } } @@ -1418,7 +1418,7 @@ void EnPametfrog_Draw(Actor* thisx, GlobalContext* globalCtx) { EnPametfrog* this = THIS; func_8012C28C(globalCtx->state.gfxCtx); - Matrix_RotateY(this->spinYaw, MTXMODE_APPLY); + Matrix_RotateYS(this->spinYaw, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnPametfrog_PostLimbDraw, &this->actor); Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h index 2b21f3ea3..1a10575cf 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h @@ -68,9 +68,9 @@ typedef struct EnPametfrog { /* 0x2C4 */ f32 drawDmgEffAlpha; /* 0x2C8 */ f32 drawDmgEffScale; /* 0x2CC */ f32 drawDmgEffFrozenSteamScale; - /* 0x2D0 */ Vec3f unk_2D0; // MtxF zx/zy/zz - /* 0x2DC */ Vec3f unk_2DC; // MtxF yx/yy/yz: wallNorm/floorNorm/Base of Gekko walking??? - /* 0x2E8 */ Vec3f unk_2E8; // MtxF xx/xy/xz + /* 0x2D0 */ Vec3f unk_2D0; // MtxF xz/yz/zz + /* 0x2DC */ Vec3f unk_2DC; // MtxF xy/yy/zy: wallNorm/floorNorm/Base of Gekko walking??? + /* 0x2E8 */ Vec3f unk_2E8; // MtxF xx/yx/zx /* 0x2F4 */ Vec3f limbPos[12]; /* 0x384 */ ColliderJntSph collider; /* 0x3A4 */ ColliderJntSphElement colElement[2]; diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c index a5321bf26..708bae3ef 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -843,19 +843,19 @@ s32 EnPeehat_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi OPEN_DISPS(globalCtx->state.gfxCtx); Gfx* gfx = POLY_OPA_DISP; - Matrix_StatePush(); - Matrix_RotateStateAroundXAxis(this->unk_2BC * 0.115f); - Matrix_InsertYRotation_f(this->unk_2BC * 0.13f, MTXMODE_APPLY); - Matrix_InsertZRotation_f(this->unk_2BC * 0.1f, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateXFApply(this->unk_2BC * 0.115f); + Matrix_RotateYF(this->unk_2BC * 0.13f, MTXMODE_APPLY); + Matrix_RotateZF(this->unk_2BC * 0.1f, MTXMODE_APPLY); Matrix_Scale(1.0f - this->unk_2C4, this->unk_2C4 + 1.0f, 1.0f - this->unk_2C4, MTXMODE_APPLY); - Matrix_InsertZRotation_f(-(this->unk_2BC * 0.1f), MTXMODE_APPLY); - Matrix_InsertYRotation_f(-(this->unk_2BC * 0.13f), MTXMODE_APPLY); - Matrix_RotateStateAroundXAxis(-(this->unk_2BC * 0.115f)); + Matrix_RotateZF(-(this->unk_2BC * 0.1f), MTXMODE_APPLY); + Matrix_RotateYF(-(this->unk_2BC * 0.13f), MTXMODE_APPLY); + Matrix_RotateXFApply(-(this->unk_2BC * 0.115f)); gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], *dList); - Matrix_StatePop(); + Matrix_Pop(); POLY_OPA_DISP = &gfx[2]; @@ -882,31 +882,31 @@ void EnPeehat_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList Gfx* gfx; if (index != -1) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->limbPos[index]); - Matrix_GetStateTranslationAndScaledX(4000.0f, &this->limbPos[index + 1]); + Matrix_MultVecX(2000.0f, &this->limbPos[index]); + Matrix_MultVecX(4000.0f, &this->limbPos[index + 1]); } if (limbIndex == 4) { - Matrix_GetStateTranslationAndScaledZ(5500.0f, &this->unk_2D4[0]); - Matrix_GetStateTranslationAndScaledZ(-5500.0f, &this->unk_2D4[1]); + Matrix_MultVecZ(5500.0f, &this->unk_2D4[0]); + Matrix_MultVecZ(-5500.0f, &this->unk_2D4[1]); } else if ((limbIndex == 3) && (thisx->params == 0)) { Vec3f* vec = &D_80899570[0]; Vec3f* vec2 = &this->limbPos[12]; for (i = 0; i < ARRAY_COUNT(D_80899570); i++, vec++, vec2++) { - Matrix_MultiplyVector3fByState(vec, vec2); + Matrix_MultVec3f(vec, vec2); } - Matrix_GetStateTranslationAndScaledX(3000.0f, vec2++); - Matrix_GetStateTranslationAndScaledX(-400.0f, vec2); + Matrix_MultVecX(3000.0f, vec2++); + Matrix_MultVecX(-400.0f, vec2); OPEN_DISPS(globalCtx->state.gfxCtx); gfx = POLY_OPA_DISP; - Matrix_InsertTranslation(-1000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(-1000.0f, 0.0f, 0.0f, MTXMODE_APPLY); Collider_UpdateSphere(0, &this->colliderSphere); - Matrix_InsertTranslation(500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertYRotation_f(3.2f, MTXMODE_APPLY); + Matrix_Translate(500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateYF(3.2f, MTXMODE_APPLY); Matrix_Scale(0.3f, 0.2f, 0.2f, MTXMODE_APPLY); gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -932,11 +932,11 @@ void EnPeehat_Draw(Actor* thisx, GlobalContext* globalCtx) { (this->actor.params == 0) ? EnPeehat_PostLimbDraw : NULL, &this->actor); if ((this->actor.speedXZ != 0.0f) || (this->actor.velocity.y != 0.0f)) { - Matrix_GetStateTranslationAndScaledZ(4500.0f, &sp40); - Matrix_GetStateTranslationAndScaledZ(-4500.0f, &sp4C); - Matrix_GetStateTranslationAndScaledX(4500.0f, &sp58); + Matrix_MultVecZ(4500.0f, &sp40); + Matrix_MultVecZ(-4500.0f, &sp4C); + Matrix_MultVecX(4500.0f, &sp58); Collider_SetTrisVertices(&this->colliderTris, 0, &sp40, &sp4C, &sp58); - Matrix_GetStateTranslationAndScaledX(-4500.0f, &sp58); + Matrix_MultVecX(-4500.0f, &sp58); Collider_SetTrisVertices(&this->colliderTris, 1, &sp40, &sp58, &sp4C); } diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index b19f64c4d..bc41461d9 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -1038,7 +1038,7 @@ s32 func_80AF87C4(EnPm* this, GlobalContext* globalCtx) { } void func_80AF8890(EnPm* this, Gfx** gfx, s32 arg2) { - Matrix_StatePush(); + Matrix_Push(); switch (arg2) { case 0: @@ -1060,7 +1060,7 @@ void func_80AF8890(EnPm* this, Gfx** gfx, s32 arg2) { break; } - Matrix_StatePop(); + Matrix_Pop(); } void func_80AF898C(EnPm* this) { @@ -1150,7 +1150,7 @@ void func_80AF8C68(EnPm* this, GlobalContext* globalCtx) { this->unk_360 = 0.0f; } Math_SmoothStepToF(&this->unk_364, this->unk_360, 0.8f, 40.0f, 10.0f); - Matrix_InsertTranslation(this->unk_364, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->unk_364, 0.0f, 0.0f, MTXMODE_APPLY); this->unk_388 = sp28; } @@ -2116,7 +2116,7 @@ void EnPm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec switch (limbIndex) { case 15: if (ActorCutscene_GetCurrentIndex() == -1) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->actor.focus.pos); + Matrix_MultVec3f(&gZeroVec3f, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } if ((this->unk_356 & 0x8000) && !(gSaveContext.save.weekEventReg[90] & 4)) { @@ -2132,10 +2132,10 @@ void EnPm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec case 8: if ((this->unk_258 == 9) || (this->unk_258 == 20) || (this->unk_258 == 21) || (this->unk_258 == 22)) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp2C); + Matrix_MultVec3f(&gZeroVec3f, &sp2C); Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp2C); } else if (this->unk_258 == 24) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp2C); + Matrix_MultVec3f(&gZeroVec3f, &sp2C); Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp2C); } func_80AF8890(this, gfx, 2); @@ -2163,13 +2163,13 @@ void EnPm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this if (limbIndex == 15) { SubS_UpdateLimb(this->unk_370 + 0x4000, this->unk_372 + this->actor.shape.rot.y + 0x4000, &this->unk_284, &this->unk_290, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_284.x, this->unk_284.y, this->unk_284.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_284.x, this->unk_284.y, this->unk_284.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_290.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_290.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_290.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_290.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_290.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_290.z, MTXMODE_APPLY); + Matrix_Push(); } } diff --git a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c index d6c9d7065..42fd2b418 100644 --- a/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c +++ b/src/overlays/actors/ovl_En_Po_Fusen/z_en_po_fusen.c @@ -288,10 +288,10 @@ s32 EnPoFusen_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL yScale = yScale * yScale; xRot = ((Math_SinS(this->randXZRotChange) * 2730.0f)); zRot = ((Math_CosS(this->randXZRotChange) * 2730.0f)); - Matrix_InsertRotation(xRot, 0, zRot, MTXMODE_APPLY); + Matrix_RotateZYX(xRot, 0, zRot, MTXMODE_APPLY); Matrix_Scale(xScale, yScale, zScale, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-zRot, MTXMODE_APPLY); - Matrix_InsertXRotation_s(-xRot, MTXMODE_APPLY); + Matrix_RotateZS(-zRot, MTXMODE_APPLY); + Matrix_RotateXS(-xRot, MTXMODE_APPLY); } else if (limbIndex == 3) { rot->y += this->limb3Rot; } else if (limbIndex == 6) { diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index 29dc269d4..bb128935d 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c @@ -1057,14 +1057,14 @@ void EnPoSisters_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi f32 temp_f2; if (D_80B1DB08[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[D_80B1DB08[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_80B1DB08[limbIndex]]); } else if (limbIndex == 9) { - Matrix_GetStateTranslationAndScaledY(-2500.0f, &this->limbPos[4]); - Matrix_GetStateTranslationAndScaledY(3000.0f, &this->limbPos[5]); + Matrix_MultVecY(-2500.0f, &this->limbPos[4]); + Matrix_MultVecY(3000.0f, &this->limbPos[5]); } else if (limbIndex == 10) { - Matrix_GetStateTranslationAndScaledY(-4000.0f, &this->limbPos[6]); + Matrix_MultVecY(-4000.0f, &this->limbPos[6]); } else if (limbIndex == 11) { - Matrix_GetStateTranslationAndScaledX(3000.0f, &this->limbPos[7]); + Matrix_MultVecX(3000.0f, &this->limbPos[7]); } if ((this->actionFunc == func_80B1BA90) && (this->unk_192 >= 8) && (limbIndex == 9)) { @@ -1078,7 +1078,7 @@ void EnPoSisters_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi this->unk_22C[end] = this->unk_22C[end - 1]; } - Matrix_MultiplyVector3fByState(&D_80B1DAFC, this->unk_22C); + Matrix_MultVec3f(&D_80B1DAFC, this->unk_22C); } if (this->unk_190 > 0) { @@ -1100,7 +1100,7 @@ void EnPoSisters_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi } if (!(this->unk_191 & 0x80)) { - Matrix_CopyCurrentState(&this->unk_358); + Matrix_Get(&this->unk_358); } } } @@ -1136,7 +1136,7 @@ void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { } if (!(this->unk_191 & 0x80)) { - Matrix_SetCurrentState(&this->unk_358); + Matrix_Put(&this->unk_358); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_po_sisters_DL_0027B0); @@ -1163,8 +1163,8 @@ void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, temp_s7->r, temp_s7->g, temp_s7->b, phi_s5); - Matrix_InsertTranslation(this->unk_22C[i].x, this->unk_22C[i].y, this->unk_22C[i].z, MTXMODE_NEW); - Matrix_InsertRotation(0, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), 0, MTXMODE_APPLY); + Matrix_Translate(this->unk_22C[i].x, this->unk_22C[i].y, this->unk_22C[i].z, MTXMODE_NEW); + Matrix_RotateZYX(0, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), 0, MTXMODE_APPLY); if (this->actionFunc == func_80B1BA90) { f32 phi_f0; diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.c b/src/overlays/actors/ovl_En_Poh/z_en_poh.c index 22f590c44..478c306b0 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -567,9 +567,9 @@ void func_80B2DC50(EnPoh* this, GlobalContext* globalCtx) { this->actor.update = func_80B2F328; this->actor.draw = func_80B2F37C; this->actor.shape.shadowDraw = NULL; - this->actor.world.pos.x = this->unk_3D8.wx; - this->actor.world.pos.y = this->unk_3D8.wy; - this->actor.world.pos.z = this->unk_3D8.wz; + this->actor.world.pos.x = this->unk_3D8.xw; + this->actor.world.pos.y = this->unk_3D8.yw; + this->actor.world.pos.z = this->unk_3D8.zw; Actor_SetScale(&this->actor, 0.01f); this->actor.flags |= ACTOR_FLAG_10; this->actor.gravity = -1.0f; @@ -888,7 +888,7 @@ void EnPoh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Matrix_Scale(0.01f / this->actor.scale.x, 0.01f / this->actor.scale.x, 0.01f / this->actor.scale.x, MTXMODE_APPLY); } - Matrix_CopyCurrentState(&this->unk_3D8); + Matrix_Get(&this->unk_3D8); func_80B2C910(&sp60, globalCtx); Lights_PointGlowSetInfo(&this->lightInfo, this->colliderSph.elements[0].dim.worldSphere.center.x + (s32)sp60.x, this->colliderSph.elements[0].dim.worldSphere.center.y + (s32)sp60.y, @@ -899,19 +899,19 @@ void EnPoh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve temp_s3 = D_80B2F71C[limbIndex]; if (temp_s3 != -1) { if (temp_s3 < 4) { - Matrix_GetStateTranslation(&this->limbPos[temp_s3]); + Matrix_MultZero(&this->limbPos[temp_s3]); } else if (temp_s3 == 4) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->limbPos[temp_s3]); + Matrix_MultVecX(2000.0f, &this->limbPos[temp_s3]); } else { s32 i; Vec3f* vec = &this->limbPos[temp_s3 + 2]; Vec3f* vec2 = &D_80B2F734[0]; - Matrix_GetStateTranslationAndScaledX(-2000.0f, &this->limbPos[temp_s3]); - Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->limbPos[temp_s3 + 1]); + Matrix_MultVecX(-2000.0f, &this->limbPos[temp_s3]); + Matrix_MultVecY(-2000.0f, &this->limbPos[temp_s3 + 1]); for (i = temp_s3 + 2; i < ARRAY_COUNT(this->limbPos); i++, vec++, vec2++) { - Matrix_MultiplyVector3fByState(vec2, vec); + Matrix_MultVec3f(vec2, vec); } } } @@ -952,7 +952,7 @@ void EnPoh_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(&gfx[0]); gDPSetEnvColor(&gfx[1], this->unk_198, this->unk_199, this->unk_19A, 255); - Matrix_SetCurrentState(&this->unk_3D8); + Matrix_Put(&this->unk_3D8); gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[3], object_po_DL_002D28); @@ -1007,8 +1007,7 @@ void func_80B2F37C(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 170, 255, this->unk_197); gDPSetEnvColor(POLY_XLU_DISP++, this->unk_194, this->unk_195, this->unk_196, 255); - Matrix_InsertYRotation_f((Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 32768), - MTXMODE_APPLY); + Matrix_RotateYF((Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 32768), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_po_DL_003850); diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.c b/src/overlays/actors/ovl_En_Pr/z_en_pr.c index 8c5d417f3..8f3a30d75 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.c +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.c @@ -574,13 +574,13 @@ void EnPr_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnPr* this = THIS; if (limbIndex == 2) { - Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&sp24, &this->unk_2D4); + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultVec3f(&sp24, &this->unk_2D4); } if ((limbIndex == 0) || (limbIndex == 1) || (limbIndex == 2) || (limbIndex == 3) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9)) { - Matrix_GetStateTranslation(&this->limbPos[this->unk_228]); + Matrix_MultZero(&this->limbPos[this->unk_228]); this->unk_228++; if (this->unk_228 >= ARRAY_COUNT(this->limbPos)) { this->unk_228 = 0; 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 6bb60f174..797433892 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c @@ -710,10 +710,10 @@ void func_80A75950(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* if (this->unk_1E0 < 10) { if (limbIndex == 2) { - Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_GetStateTranslation(&this->unk_270); + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultZero(&this->unk_270); } - Matrix_GetStateTranslation(&this->unk_234[limbIndex]); + Matrix_MultZero(&this->unk_234[limbIndex]); } } diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.c b/src/overlays/actors/ovl_En_Prz/z_en_prz.c index 797d898ac..99cc24158 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.c +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.c @@ -494,8 +494,8 @@ void func_80A76FCC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnPrz* this = THIS; if (limbIndex == 2) { - Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&sp1C, &this->unk_1CC); + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultVec3f(&sp1C, &this->unk_1CC); } } diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index e6fb2535a..cf6b1d63f 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -713,8 +713,8 @@ void EnRacedog_DrawSelectionArrow(EnRacedog* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); EnRacedog_UpdateSelectionArrow(this); - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, - this->actor.world.pos.z, &rotation); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, + &rotation); gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 255, 255, this->selectionArrowGreenPrimColor, 0, 255); @@ -740,7 +740,7 @@ void EnRacedog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Vec3f focusOffset = { 0.0f, 20.0f, 0.0f }; if (limbIndex == DOG_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&focusOffset, &this->actor.focus.pos); + Matrix_MultVec3f(&focusOffset, &this->actor.focus.pos); } if (limbIndex == DOG_LIMB_TAIL) { @@ -787,10 +787,10 @@ void EnRacedog_Draw(Actor* thisx, GlobalContext* globalCtx) { break; } - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(this->curRot.x); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateXFApply(this->curRot.x); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnRacedog_OverrideLimbDraw, EnRacedog_PostLimbDraw, &this->actor); diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.c b/src/overlays/actors/ovl_En_Raf/z_en_raf.c index 4d880a389..fb3b1070e 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.c +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.c @@ -829,13 +829,13 @@ void EnRaf_TransformLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Actor* th // These matrix operations make the trap petals look a bit more "wobbly" as it chews // by stretching the limbs in various random directions. if ((limbIndex > CARNIVOROUS_LILY_PAD_LIMB_FLOWER) && (limbIndex < CARNIVOROUS_LILY_PAD_LIMB_ROOTS)) { - Matrix_RotateY((this->chewLimbRot[limbIndex].y * globalCtx->gameplayFrames), MTXMODE_APPLY); - Matrix_InsertXRotation_s((this->chewLimbRot[limbIndex].x * globalCtx->gameplayFrames), MTXMODE_APPLY); - Matrix_InsertZRotation_s((this->chewLimbRot[limbIndex].z * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateYS((this->chewLimbRot[limbIndex].y * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateXS((this->chewLimbRot[limbIndex].x * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateZS((this->chewLimbRot[limbIndex].z * globalCtx->gameplayFrames), MTXMODE_APPLY); Matrix_Scale(this->chewScale + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-(this->chewLimbRot[limbIndex].z * globalCtx->gameplayFrames), MTXMODE_APPLY); - Matrix_InsertXRotation_s(-(this->chewLimbRot[limbIndex].x * globalCtx->gameplayFrames), MTXMODE_APPLY); - Matrix_RotateY(-(this->chewLimbRot[limbIndex].y * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateZS(-(this->chewLimbRot[limbIndex].z * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateXS(-(this->chewLimbRot[limbIndex].x * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_RotateYS(-(this->chewLimbRot[limbIndex].y * globalCtx->gameplayFrames), MTXMODE_APPLY); } break; @@ -948,11 +948,11 @@ void EnRaf_DrawParticles(EnRaf* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { if (particle->isVisible) { - Matrix_InsertTranslation(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); + Matrix_Translate(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); Matrix_Scale(particle->scale, particle->scale, particle->scale, MTXMODE_APPLY); - Matrix_InsertXRotation_s(particle->rotation.x, MTXMODE_APPLY); - Matrix_RotateY(particle->rotation.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(particle->rotation.z, MTXMODE_APPLY); + Matrix_RotateXS(particle->rotation.x, MTXMODE_APPLY); + Matrix_RotateYS(particle->rotation.y, MTXMODE_APPLY); + Matrix_RotateZS(particle->rotation.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gCarnivorousLilyPadParticleDL); diff --git a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c index e1971c182..99d30f14c 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.c @@ -1099,9 +1099,9 @@ s32 EnRailSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL } else if (limbIndex == 10) { Vec3f sp24 = { 0.0f, 1000.0f, 0.0f }; - Matrix_MultiplyVector3fByState(&sp24, &this->actor.focus.pos); + Matrix_MultVec3f(&sp24, &this->actor.focus.pos); } else if ((limbIndex == 12) && (this->unk_3FA == 1)) { - Matrix_InsertZRotation_s(1820, MTXMODE_APPLY); + Matrix_RotateZS(1820, MTXMODE_APPLY); } if (((limbIndex == 11) || (limbIndex == 12)) && (this->unk_402 & 2)) { @@ -1129,10 +1129,10 @@ void EnRailSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList 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)) { - Matrix_GetStateTranslation(&this->limbPos[this->limbCount]); + Matrix_MultZero(&this->limbPos[this->limbCount]); this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_402 & 2)) { - Matrix_MultiplyVector3fByState(&D_80B734D0, &this->limbPos[this->limbCount]); + Matrix_MultVec3f(&D_80B734D0, &this->limbPos[this->limbCount]); this->limbCount++; } } 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 70d9fb708..ba6043f52 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -1060,7 +1060,7 @@ void EnRailgibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi (limbIndex == GIBDO_LIMB_LEFT_FOREARM) || (limbIndex == GIBDO_LIMB_LEFT_HAND) || (limbIndex == GIBDO_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || (limbIndex == GIBDO_LIMB_RIGHT_FOREARM) || (limbIndex == GIBDO_LIMB_RIGHT_HAND) || (limbIndex == GIBDO_LIMB_HEAD) || (limbIndex == GIBDO_LIMB_PELVIS))) { - Matrix_GetStateTranslation(&this->limbPos[this->limbIndex]); + Matrix_MultZero(&this->limbPos[this->limbIndex]); this->limbIndex++; } } diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/src/overlays/actors/ovl_En_Rd/z_en_rd.c index 0326c13b7..c24a5e5a9 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -1317,7 +1317,7 @@ void EnRd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec (limbIndex == REDEAD_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || (limbIndex == REDEAD_LIMB_RIGHT_FOREARM) || (limbIndex == REDEAD_LIMB_RIGHT_HAND) || (limbIndex == REDEAD_LIMB_HEAD) || (limbIndex == REDEAD_LIMB_PELVIS))) { - Matrix_GetStateTranslation(&this->limbPos[this->limbIndex]); + Matrix_MultZero(&this->limbPos[this->limbIndex]); this->limbIndex++; } } diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c index 56846543e..13ab86f52 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -196,8 +196,8 @@ void EnRecepgirl_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Acto EnRecepgirl* this = THIS; if (limbIndex == 5) { - Matrix_RotateY(0x400 - this->headRot.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.focus.pos); + Matrix_RotateYS(0x400 - this->headRot.x, MTXMODE_APPLY); + Matrix_MultVecX(500.0f, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index a75e0f489..c5f2954f9 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -175,7 +175,7 @@ void func_80BF3920(EnRgStruct* ptr, GlobalContext* globalCtx) { phi_fp = true; } - Matrix_StatePush(); + Matrix_Push(); if (globalCtx) {} temp_f20 = (f32)ptr->unk_02 / ptr->unk_01; @@ -185,9 +185,9 @@ void func_80BF3920(EnRgStruct* ptr, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, D_80BF5960[ptr->unk_00 - 4].r, D_80BF5960[ptr->unk_00 - 4].g, D_80BF5960[ptr->unk_00 - 4].b, 0); - Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_34, ptr->unk_34, 1.0f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -195,7 +195,7 @@ void func_80BF3920(EnRgStruct* ptr, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BF5934[idx])); gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014D00); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -804,14 +804,14 @@ void func_80BF547C(EnRg* this, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, - this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, + this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, -this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->actor.shape.yOffset, 0.0f, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_oF1d_map_DL_0091A8); diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.c b/src/overlays/actors/ovl_En_Rr/z_en_rr.c index 4bd5bcf32..2ad27aab5 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -887,7 +887,7 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (this->unk_1E8 * 0) & 0x7F, (this->unk_1E8 * 0) & 0x3F, 0x20, 0x10, 1, (this->unk_1E8 * 0) & 0x3F, (this->unk_1E8 * -6) & 0x7F, 0x20, 0x10)); - Matrix_StatePush(); + Matrix_Push(); Matrix_Scale((1.0f + this->unk_324[0].unk_10) * this->unk_324[0].unk_08, 1.0f, (1.0f + this->unk_324[0].unk_10) * this->unk_324[0].unk_08, MTXMODE_APPLY); @@ -895,38 +895,38 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - Matrix_GetStateTranslationAndScaledZ(1842.1053f, vecPtr++); - Matrix_GetStateTranslationAndScaledZ(-1842.1053f, vecPtr++); - Matrix_GetStateTranslationAndScaledX(1842.1053f, vecPtr++); - Matrix_GetStateTranslationAndScaledX(-1842.1053f, vecPtr++); - Matrix_StatePop(); + Matrix_MultVecZ(1842.1053f, vecPtr++); + Matrix_MultVecZ(-1842.1053f, vecPtr++); + Matrix_MultVecX(1842.1053f, vecPtr++); + Matrix_MultVecX(-1842.1053f, vecPtr++); + Matrix_Pop(); for (i = 1; i < ARRAY_COUNT(this->unk_324); i++) { temp_f20 = this->unk_324[i].unk_08 * (this->unk_324[i].unk_10 + 1.0f); ptr = &this->unk_324[i]; - Matrix_InsertTranslation(0.0f, ptr->unk_00 + 1000.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertRotation(ptr->unk_1A.x, ptr->unk_1A.y, ptr->unk_1A.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_Translate(0.0f, ptr->unk_00 + 1000.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZYX(ptr->unk_1A.x, ptr->unk_1A.y, ptr->unk_1A.z, MTXMODE_APPLY); + Matrix_Push(); Matrix_Scale(temp_f20, 1.0f, temp_f20, MTXMODE_APPLY); Matrix_ToMtx(matrix); if ((i & 1) != 0) { - Matrix_RotateY(0x2000, MTXMODE_APPLY); + Matrix_RotateYS(0x2000, MTXMODE_APPLY); } - Matrix_GetStateTranslationAndScaledZ(1842.1053f, vecPtr++); - Matrix_GetStateTranslationAndScaledZ(-1842.1053f, vecPtr++); - Matrix_GetStateTranslationAndScaledX(1842.1053f, vecPtr++); - Matrix_GetStateTranslationAndScaledX(-1842.1053f, vecPtr++); - Matrix_StatePop(); + Matrix_MultVecZ(1842.1053f, vecPtr++); + Matrix_MultVecZ(-1842.1053f, vecPtr++); + Matrix_MultVecX(1842.1053f, vecPtr++); + Matrix_MultVecX(-1842.1053f, vecPtr++); + Matrix_Pop(); matrix++; if (i == 3) { - Matrix_GetStateTranslation(&spA4); + Matrix_MultZero(&spA4); } } - Matrix_GetStateTranslation(&this->unk_228); + Matrix_MultZero(&this->unk_228); this->collider2.dim.pos.x = ((this->unk_228.x - spA4.x) * 0.85f) + spA4.x; this->collider2.dim.pos.y = ((this->unk_228.y - spA4.y) * 0.85f) + spA4.y; this->collider2.dim.pos.z = ((this->unk_228.z - spA4.z) * 0.85f) + spA4.z; diff --git a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c index cb110f780..3a29b5081 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c @@ -68,7 +68,7 @@ s32 EnRsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnRsn* this = THIS; if (limbIndex == 14) { - Matrix_InsertXRotation_s(this->unk1D8.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk1D8.y, MTXMODE_APPLY); } return false; } @@ -80,7 +80,7 @@ void EnRsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Vec3f sp18 = D_80C26028; if (limbIndex == 14) { - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c index d522a4751..3f0ae6154 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -817,7 +817,7 @@ void EnScopenuts_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Acto } if (limbIndex == 24) { - Matrix_RotateY(this->unk_340, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_340, MTXMODE_APPLY); } } diff --git a/src/overlays/actors/ovl_En_Sda/z_en_sda.c b/src/overlays/actors/ovl_En_Sda/z_en_sda.c index 0103b1d62..fc4f91308 100644 --- a/src/overlays/actors/ovl_En_Sda/z_en_sda.c +++ b/src/overlays/actors/ovl_En_Sda/z_en_sda.c @@ -138,7 +138,7 @@ void func_809469C0(Player* player, u8* shadowTexture, f32 arg2) { sp88.z = D_80947EA0[i].z - player->actor.world.pos.z; } - Matrix_MultiplyVector3fByState(&sp88, &sp7C); + Matrix_MultVec3f(&sp88, &sp7C); sp7C.x *= (1.0f + (BREG(49) / 100.0f)); sp7C.y *= (1.0f + (BREG(49) / 100.0f)); temp_t0 = sp7C.x + 32.0f; @@ -240,7 +240,7 @@ void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, GlobalContext } } - Matrix_SetStateXRotation((BREG(50) + 70) / 100.0f); + Matrix_RotateXFNew((BREG(50) + 70) / 100.0f); for (i = 0; i < 18; i++) { if (D_80947AFC[i] >= 0) { @@ -258,31 +258,31 @@ void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, GlobalContext } if (this->actor.params != ENSDA_1) { - func_8018219C(&player->shieldMf, &sp178, false); + Matrix_MtxFToYXZRot(&player->shieldMf, &sp178, false); sp178.y += (KREG(87) * 0x8000) + 0x8000; sp178.x *= (KREG(88) - 1); - Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&D_80947A60, &sp16C); - Matrix_RotateY(sp178.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(sp178.x, MTXMODE_APPLY); + Matrix_Mult(&player->shieldMf, MTXMODE_NEW); + Matrix_MultVec3f(&D_80947A60, &sp16C); + Matrix_RotateYS(sp178.y, MTXMODE_NEW); + Matrix_RotateXS(sp178.x, MTXMODE_APPLY); for (i = 0; i < 22; i++) { - Matrix_MultiplyVector3fByState(&D_80947B10[i], &sp188); + Matrix_MultVec3f(&D_80947B10[i], &sp188); sp64[i].x = (((KREG(82) / 100.0f) + 4.0f) * sp188.x) + sp16C.x; sp64[i].y = (((KREG(82) / 100.0f) + 4.0f) * sp188.y) + sp16C.y; sp64[i].z = (((KREG(82) / 100.0f) + 4.0f) * sp188.z) + sp16C.z; } - Matrix_SetStateXRotation((BREG(50) + 70) / 100.0f); + Matrix_RotateXFNew((BREG(50) + 70) / 100.0f); for (i = 0; i < 22; i++) { sp194.x = sp64[i].x - player->actor.world.pos.x; sp194.y = sp64[i].y - player->actor.world.pos.y + KREG(80) + 16.0f; sp194.z = sp64[i].z - player->actor.world.pos.z; - Matrix_MultiplyVector3fByState(&sp194, &sp188); + Matrix_MultVec3f(&sp194, &sp188); sp188.x *= (1.0f + (KREG(90) / 100.0f)); sp188.y *= (1.0f + (KREG(90) / 100.0f)); @@ -328,16 +328,15 @@ void func_80947668(u8* shadowTexture, Player* player, GlobalContext* globalCtx) gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 0, 0, 0, (BREG(52) + 50)); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 0); - Matrix_InsertTranslation(player->actor.world.pos.x, player->actor.floorHeight, player->actor.world.pos.z, - MTXMODE_NEW); - Matrix_InsertYRotation_f(BREG(51) / 100.0f, MTXMODE_APPLY); + Matrix_Translate(player->actor.world.pos.x, player->actor.floorHeight, player->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYF(BREG(51) / 100.0f, MTXMODE_APPLY); Matrix_Scale(1.0f, 1.0f, (BREG(63) / 10.0f) + 1.0f, MTXMODE_APPLY); tempx = (BREG(62) / 10.0f) + 2.0f; tempz = ((player->actor.world.pos.y - player->actor.floorHeight + BREG(54)) * (BREG(55) - 5) / 10.0f) + BREG(58) - 20.0f; - Matrix_InsertTranslation(tempx, 0.0f, tempz, MTXMODE_APPLY); + Matrix_Translate(tempx, 0.0f, tempz, MTXMODE_APPLY); Matrix_Scale(((BREG(56) - 250) / 1000.0f) + 0.6f, 1.0f, ((BREG(59) - 250) / 1000.0f) + 0.6f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c index 5735d1e28..0d53b127e 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -1101,7 +1101,7 @@ s32 EnSellnuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d } if (limbIndex == 24) { - Matrix_InsertXRotation_s(this->unk_342, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_342, MTXMODE_APPLY); } if (limbIndex == 26) { @@ -1131,7 +1131,7 @@ void EnSellnuts_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor } if (limbIndex == 24) { - Matrix_RotateY(this->unk_344, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_344, MTXMODE_APPLY); } } diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.c b/src/overlays/actors/ovl_En_Shn/z_en_shn.c index 808f38d5a..0b9905ba5 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.c +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.c @@ -184,7 +184,7 @@ void func_80AE6488(EnShn* this, GlobalContext* globalCtx) { tempMsgState = Message_GetState(&globalCtx->msgCtx); this->unk_2D4 += (this->unk_2D0 != 0.0f) ? 40.0f : -40.0f; this->unk_2D4 = CLAMP(this->unk_2D4, 0.0f, 80.0f); - Matrix_InsertTranslation(this->unk_2D4, 0.0f, 0.0f, 1); + Matrix_Translate(this->unk_2D4, 0.0f, 0.0f, MTXMODE_APPLY); if ((&this->actor == player->targetActor) && ((globalCtx->msgCtx.currentTextId < 0xFF) || (globalCtx->msgCtx.currentTextId >= 0x201)) && (tempMsgState == 3) && (this->msgState == 3)) { @@ -396,7 +396,7 @@ s32 EnShn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f D_80AE7270 = { 1200.0f, 0.0f, 0.0f }; void EnShn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { if (limbIndex == BURLY_GUY_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_80AE7270, &thisx->focus.pos); + Matrix_MultVec3f(&D_80AE7270, &thisx->focus.pos); Math_Vec3s_Copy(&thisx->focus.rot, &thisx->world.rot); } } @@ -419,15 +419,15 @@ void EnShn_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi } if (limbIndex == BURLY_GUY_LIMB_HEAD) { - SubS_UpdateLimb((this->unk_2BA + 0x4000), (this->unk_2BC + this->actor.shape.rot.y + 0x4000), &this->unk_1E8, + SubS_UpdateLimb(this->unk_2BA + 0x4000, this->unk_2BC + this->actor.shape.rot.y + 0x4000, &this->unk_1E8, &this->unk_1F4, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1E8.x, this->unk_1E8.y, this->unk_1E8.z, 0); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 1); - Matrix_RotateY(this->unk_1F4.y, 1); - Matrix_InsertXRotation_s(this->unk_1F4.x, 1); - Matrix_InsertZRotation_s(this->unk_1F4.z, 1); - Matrix_StatePush(); + Matrix_Pop(); + Matrix_Translate(this->unk_1E8.x, this->unk_1E8.y, this->unk_1E8.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_1F4.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_1F4.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_1F4.z, MTXMODE_APPLY); + Matrix_Push(); } } diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index f7fca7448..6d3a118f4 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -1087,7 +1087,7 @@ s32 EnSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } if (limbIndex == 10) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); } return false; @@ -1112,10 +1112,10 @@ void EnSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve 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)) { - Matrix_GetStateTranslation(&this->limbPos[this->limbCount]); + Matrix_MultZero(&this->limbPos[this->limbCount]); this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_3D8 & 2)) { - Matrix_MultiplyVector3fByState(&D_80997564, &this->limbPos[this->limbCount]); + Matrix_MultVec3f(&D_80997564, &this->limbPos[this->limbCount]); this->limbCount++; } } diff --git a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c index 683685889..ef0ad1b57 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c @@ -1144,10 +1144,10 @@ void EnSnowman_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList if (sLimbIndexToBodyPartsPosIndex[limbIndex] != -1) { if (sLimbIndexToBodyPartsPosIndex[limbIndex] == 4) { for (i = 0; i < 5; i++) { - Matrix_MultiplyVector3fByState(&sBodyBottomBodyPartOffsets[i], &this->bodyPartsPos[i + 4]); + Matrix_MultVec3f(&sBodyBottomBodyPartOffsets[i], &this->bodyPartsPos[i + 4]); } } else { - Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsPosIndex[limbIndex]]); + Matrix_MultZero(&this->bodyPartsPos[sLimbIndexToBodyPartsPosIndex[limbIndex]]); } } @@ -1157,9 +1157,9 @@ void EnSnowman_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList gfx = POLY_OPA_DISP; if (EN_SNOWMAN_GET_TYPE(thisx) != EN_SNOWMAN_TYPE_LARGE) { - Matrix_InsertTranslation(800.0f, -600.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(800.0f, -600.0f, 0.0f, MTXMODE_APPLY); } else { - Matrix_InsertTranslation(300.0f, -2300.0f, -1900.0f, MTXMODE_APPLY); + Matrix_Translate(300.0f, -2300.0f, -1900.0f, MTXMODE_APPLY); Matrix_Scale(0.3f, 0.3f, 0.3f, MTXMODE_APPLY); } @@ -1170,7 +1170,7 @@ void EnSnowman_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList CLOSE_DISPS(globalCtx->state.gfxCtx); - Matrix_GetStateTranslation(&this->snowballPos); + Matrix_MultZero(&this->snowballPos); } } diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index 003f731b0..08c1a8aaf 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -1586,7 +1586,7 @@ s32 EnSob1_BombShopkeeper_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbInd EnSob1* this = THIS; if (limbIndex == 15) { - Matrix_InsertXRotation_s(this->headRot, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot, MTXMODE_APPLY); } return false; } @@ -1675,7 +1675,7 @@ void EnSob1_BombShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { EnSob1_DrawStickDirectionPrompt(globalCtx, this); frames = globalCtx->gameplayFrames; func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 0x08, 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 d880c4873..b9ccdb579 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -172,10 +172,10 @@ void EnSsh_AddBlureVertex(EnSsh* this) { p2Base.y *= this->colliderScale; p2Base.z *= this->colliderScale; - Matrix_StatePush(); - Matrix_MultiplyVector3fByState(&p1Base, &p1); - Matrix_MultiplyVector3fByState(&p2Base, &p2); - Matrix_StatePop(); + Matrix_Push(); + Matrix_MultVec3f(&p1Base, &p1); + Matrix_MultVec3f(&p2Base, &p2); + Matrix_Pop(); EffectBlure_AddVertex(Effect_GetByIndex(this->blureIdx), &p1, &p2); } @@ -425,11 +425,11 @@ void EnSsh_Sway(EnSsh* this) { swayVecBase.y = Math_CosS(swayAngle) * temp_f20; swayVecBase.z = 0.0f; - Matrix_StatePush(); - Matrix_InsertTranslation(this->ceilingPos.x, this->ceilingPos.y, this->ceilingPos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(this->actor.world.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&swayVecBase, &swayVec); - Matrix_StatePop(); + Matrix_Push(); + Matrix_Translate(this->ceilingPos.x, this->ceilingPos.y, this->ceilingPos.z, MTXMODE_NEW); + Matrix_RotateYF(this->actor.world.rot.y * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_MultVec3f(&swayVecBase, &swayVec); + Matrix_Pop(); this->actor.shape.rot.z = -(swayAngle * 2); this->actor.world.pos.x = swayVec.x; @@ -592,11 +592,11 @@ s32 EnSsh_SetCylinderOC(EnSsh* this, GlobalContext* globalCtx) { colliderOffsets[i].y *= this->colliderScale; colliderOffsets[i].z *= this->colliderScale; - Matrix_StatePush(); - Matrix_InsertTranslation(colliderPos.x, colliderPos.y, colliderPos.z, MTXMODE_NEW); - Matrix_InsertYRotation_f(BINANG_TO_RAD(this->initialYaw), MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&colliderOffsets[i], &colliderPos); - Matrix_StatePop(); + Matrix_Push(); + Matrix_Translate(colliderPos.x, colliderPos.y, colliderPos.z, MTXMODE_NEW); + Matrix_RotateYF(BINANG_TO_RAD(this->initialYaw), MTXMODE_APPLY); + Matrix_MultVec3f(&colliderOffsets[i], &colliderPos); + Matrix_Pop(); this->collider1[3 + i].dim.pos.x = colliderPos.x; this->collider1[3 + i].dim.pos.y = colliderPos.y; diff --git a/src/overlays/actors/ovl_En_St/z_en_st.c b/src/overlays/actors/ovl_En_St/z_en_st.c index a50bf92b4..e2915a614 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -247,9 +247,8 @@ void func_808A54B0(EnSt* this, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_2C0].segment); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(0.06f, 0.12f, 0.06f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index 82e314d60..23b1b6223 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -665,7 +665,7 @@ void func_80B68310(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* if (limbIndex == 15) { s32 pad; - Matrix_MultiplyVector3fByState(&D_80B6D200, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B6D200, &this->actor.focus.pos); if (!ENSTH_GET_100(&this->actor)) { OPEN_DISPS(globalCtx->state.gfxCtx); @@ -678,16 +678,16 @@ void func_80B68310(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* if (this->unk_29C & 1) { if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_29F)) { - Matrix_StatePush(); - Matrix_InsertZRotation_s(0x3A98, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 190.0f, 0.0f, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateZS(0x3A98, MTXMODE_APPLY); + Matrix_Translate(0.0f, 190.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_OPA_DISP++, 0x0A, globalCtx->objectCtx.status[this->unk_29F].segment); gSPDisplayList(POLY_OPA_DISP++, object_mask_truth_DL_0001A0); - Matrix_StatePop(); + Matrix_Pop(); } } diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 319cbbabd..4a7e56682 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -439,11 +439,11 @@ void func_80BAAFDC(EnSuttari* this, GlobalContext* globalCtx) { effectPos.x += Math_SinS(this->actor.world.rot.y + this->unk3F4) * 10.0f; effectPos.y += 60.0f; effectPos.z += Math_CosS(this->actor.world.rot.y + this->unk3F4) * 10.0f; - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); effectVelOffset.z = 20.0f; - Matrix_MultiplyVector3fByState(&effectVelOffset, &effectVel); - Matrix_StatePop(); + Matrix_MultVec3f(&effectVelOffset, &effectVel); + Matrix_Pop(); if (this->unk3F0 == 0) { EffectSsSolderSrchBall_Spawn(globalCtx, &effectPos, &effectVel, &gZeroVec3f, 50, &this->unk3F0, 1); } @@ -471,11 +471,11 @@ void func_80BAB1A0(EnSuttari* this, GlobalContext* globalCtx) { effectPos.x += Math_SinS(this->actor.world.rot.y + this->unk3F4) * 350.0f; effectPos.y += 60.0f; effectPos.z += Math_CosS(this->actor.world.rot.y + this->unk3F4) * 350.0f; - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); effectVelOffset.z = 20.0f; - Matrix_MultiplyVector3fByState(&effectVelOffset, &effectVel); - Matrix_StatePop(); + Matrix_MultVec3f(&effectVelOffset, &effectVel); + Matrix_Pop(); if (this->unk3F0 == 0) { EffectSsSolderSrchBall_Spawn(globalCtx, &effectPos, &effectVel, &gZeroVec3f, 50, &this->unk3F0, 1); } @@ -1502,15 +1502,15 @@ s32 EnSuttari_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL if (limbIndex == 15) { *dList = object_boj_DL_00AF90; if (!(this->flags1 & 4)) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk3F2, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->headRot.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->unk3F2, MTXMODE_APPLY); + Matrix_RotateZS(-this->headRot.x, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } } if (limbIndex == 8) { - Matrix_InsertXRotation_s(-this->torsoRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->torsoRot.x, MTXMODE_APPLY); + Matrix_RotateXS(-this->torsoRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->torsoRot.x, MTXMODE_APPLY); } if (limbIndex == 8 || limbIndex == 9 || limbIndex == 0xC) { rot->y += (s16)(Math_SinS(this->unk2FA[limbIndex]) * 200.0f); @@ -1530,15 +1530,15 @@ void EnSuttari_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList if (((this->flags1 & 8) && (this->flags1 & 0x10)) || ((this->flags1 & 2) && !(this->flags1 & 0x20)) || ((this->flags1 & 4) && !(this->flags1 & 0x20))) { if (limbIndex == 8) { - curState = Matrix_GetCurrentState(); - Matrix_MultiplyVector3fByState(&D_80BAE95C, &this->unk3F8); + curState = Matrix_GetCurrent(); + Matrix_MultVec3f(&D_80BAE95C, &this->unk3F8); if (this->actor.child == NULL) { if (this->flags1 & 0x100) { bombBag = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_NIMOTSU, curState->mf[3][0], curState->mf[3][1], curState->mf[3][2], 0, 0, 0, -1); if (bombBag != NULL) { - func_8018219C(curState, &bombBag->shape.rot, 0); + Matrix_MtxFToYXZRot(curState, &bombBag->shape.rot, false); } } else { func_8012C28C(globalCtx->state.gfxCtx); @@ -1550,7 +1550,7 @@ void EnSuttari_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } } if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&D_80BAE950, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BAE950, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 512e90d4f..0188b323c 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -277,8 +277,8 @@ void func_808D90F0(EnSw* this, s32 arg1, s16 arg2) { temp = arg2; } - Matrix_InsertRotationAroundUnitVector_f(BINANG_TO_RAD(temp), &this->unk_368, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&this->unk_350, &sp2C); + Matrix_RotateAxisF(BINANG_TO_RAD(temp), &this->unk_368, MTXMODE_NEW); + Matrix_MultVec3f(&this->unk_350, &sp2C); Math_Vec3f_Copy(&this->unk_350, &sp2C); Math3D_CrossProduct(&this->unk_368, &this->unk_350, &this->unk_35C); } @@ -316,8 +316,8 @@ s32 func_808D91C4(EnSw* this, CollisionPoly* arg1) { } Math_Vec3f_Scale(&sp2C, 1.0f / temp_f0); - Matrix_InsertRotationAroundUnitVector_f(sp4C, &sp2C, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&this->unk_35C, &sp2C); + Matrix_RotateAxisF(sp4C, &sp2C, MTXMODE_NEW); + Matrix_MultVec3f(&this->unk_35C, &sp2C); Math_Vec3f_Copy(&this->unk_35C, &sp2C); Math3D_CrossProduct(&this->unk_35C, &sp38, &this->unk_350); @@ -336,15 +336,15 @@ void func_808D93BC(EnSw* this) { MtxF sp18; sp18.xx = this->unk_35C.x; - sp18.xy = this->unk_35C.y; - sp18.xz = this->unk_35C.z; - sp18.yx = this->unk_368.x; + sp18.yx = this->unk_35C.y; + sp18.zx = this->unk_35C.z; + sp18.xy = this->unk_368.x; sp18.yy = this->unk_368.y; - sp18.yz = this->unk_368.z; - sp18.zx = this->unk_350.x; - sp18.zy = this->unk_350.y; + sp18.zy = this->unk_368.z; + sp18.xz = this->unk_350.x; + sp18.yz = this->unk_350.y; sp18.zz = this->unk_350.z; - func_8018219C(&sp18, &this->actor.world.rot, 0); + Matrix_MtxFToYXZRot(&sp18, &this->actor.world.rot, false); this->actor.world.rot.x = -this->actor.world.rot.x; } @@ -459,30 +459,30 @@ void func_808D9894(EnSw* this, Vec3f* vec) { MtxF sp1C; sp1C.xx = this->unk_35C.x; - sp1C.yx = this->unk_35C.y; - sp1C.zx = this->unk_35C.z; - sp1C.wx = 0.0f; - - sp1C.xy = this->unk_368.x; - sp1C.yy = this->unk_368.y; - sp1C.zy = this->unk_368.z; - sp1C.wy = 0.0f; - - sp1C.xz = this->unk_350.x; - sp1C.yz = this->unk_350.y; - sp1C.zz = this->unk_350.z; - sp1C.wz = 0.0f; - + sp1C.xy = this->unk_35C.y; + sp1C.xz = this->unk_35C.z; sp1C.xw = 0.0f; + + sp1C.yx = this->unk_368.x; + sp1C.yy = this->unk_368.y; + sp1C.yz = this->unk_368.z; sp1C.yw = 0.0f; + + sp1C.zx = this->unk_350.x; + sp1C.zy = this->unk_350.y; + sp1C.zz = this->unk_350.z; sp1C.zw = 0.0f; + + sp1C.wx = 0.0f; + sp1C.wy = 0.0f; + sp1C.wz = 0.0f; sp1C.ww = 0.0f; - Matrix_SetCurrentState(&sp1C); + Matrix_Put(&sp1C); sp5C.x = vec->x - this->actor.world.pos.x; sp5C.y = vec->y - this->actor.world.pos.y; sp5C.z = vec->z - this->actor.world.pos.z; - Matrix_MultiplyVector3fByState(&sp5C, vec); + Matrix_MultVec3f(&sp5C, vec); } s32 func_808D9968(EnSw* this, GlobalContext* globalCtx) { @@ -1317,7 +1317,7 @@ void EnSw_Draw(Actor* thisx, GlobalContext* globalCtx) { func_800B8050(&this->actor, globalCtx, MTXMODE_NEW); } func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertXRotation_s(-0x3C72, MTXMODE_APPLY); + Matrix_RotateXS(-0x3C72, MTXMODE_APPLY); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSw_OverrideLimbDraw, NULL, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c index 23a16debc..b45da318d 100644 --- a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c +++ b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.c @@ -304,12 +304,12 @@ void EnSyatekiCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d Vec3f* sp1C; if (limbIndex == OBJECT_CROW_LIMB_BODY) { - Matrix_MultiplyVector3fByState(&D_809CB0D8, &this->unk_144[0]); + Matrix_MultVec3f(&D_809CB0D8, &this->unk_144[0]); this->unk_144[0].y -= 20.0f; } else if ((limbIndex == OBJECT_CROW_LIMB_RIGHT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_LEFT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_TAIL)) { sp1C = &this->unk_144[(limbIndex >> 1) - 1]; - Matrix_MultiplyVector3fByState(&D_809CB050, sp1C); + Matrix_MultVec3f(&D_809CB050, sp1C); sp1C->y -= 20.0f; } } diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c index 92168ef76..bd5dece41 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.c @@ -423,7 +423,7 @@ void EnSyatekiDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(temp_f20.x, temp_f20.y, temp_f20.z, MTXMODE_NEW); + Matrix_Translate(temp_f20.x, temp_f20.y, temp_f20.z, MTXMODE_NEW); Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 52ea1d8f1..6ea613a6b 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -1238,12 +1238,12 @@ s32 EnSyatekiMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** } if (limbIndex == BURLY_GUY_LIMB_HEAD) { - Matrix_InsertTranslation(3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_258.x, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_258.y, MTXMODE_APPLY); - Matrix_InsertTranslation(-3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_258.x, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_258.y, MTXMODE_APPLY); + Matrix_Translate(-3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); } else if (limbIndex == BURLY_GUY_LIMB_TORSO) { - Matrix_InsertXRotation_s(-this->unk_25E.y, MTXMODE_APPLY); + Matrix_RotateXS(-this->unk_25E.y, MTXMODE_APPLY); } return false; @@ -1254,7 +1254,7 @@ void EnSyatekiMan_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL Vec3f sp18 = { 1600.0f, 0.0f, 0.0f }; if (limbIndex == BURLY_GUY_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c index 617577884..34afad373 100644 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c +++ b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.c @@ -500,8 +500,8 @@ void EnSyatekiOkuta_Draw(Actor* thisx, GlobalContext* globalCtx) { NULL, &this->actor); func_8012C2DC(globalCtx->state.gfxCtx); if (this->actionFunc == func_80A365EC) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 30.0f, - this->actor.world.pos.z + 20.0f, 0); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + 30.0f, this->actor.world.pos.z + 20.0f, + MTXMODE_NEW); if (this->unk_2AA >= 256) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 210, 64, 32, 255); diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c index e72cb296d..0a0b3f66c 100644 --- a/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c +++ b/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.c @@ -461,7 +461,7 @@ void EnSyatekiWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi Collider_UpdateSpheres(limbIndex, &this->unk_34C); if (limbIndex == WOLFOS_NORMAL_LIMB_TAIL) { - Matrix_MultiplyVector3fByState(&D_80A20FD0, &sp18); + Matrix_MultVec3f(&D_80A20FD0, &sp18); this->unk_300.dim.pos.x = sp18.x; this->unk_300.dim.pos.y = sp18.y; this->unk_300.dim.pos.z = sp18.z; diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index 7c36af46f..5745da0fd 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -266,7 +266,7 @@ void func_80BE0A98(EnTab* this, GlobalContext* globalCtx) { this->unk_308 += (this->unk_304 != 0.0f) ? 40.0f : -40.0f; this->unk_308 = CLAMP(this->unk_308, 0.0f, 80.0f); - Matrix_InsertTranslation(this->unk_308, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->unk_308, 0.0f, 0.0f, MTXMODE_APPLY); if ((&this->actor == player->targetActor) && ((globalCtx->msgCtx.currentTextId < 0xFF) || (globalCtx->msgCtx.currentTextId > 0x200)) && (sp20 == 3) && @@ -577,7 +577,7 @@ void EnTab_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnTab* this = THIS; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80BE1B18, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BE1B18, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } } @@ -603,13 +603,13 @@ void EnTab_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) SubS_UpdateLimb(BINANG_ADD(this->unk_312 + this->unk_316, 0x4000), BINANG_ADD(this->unk_314 + this->unk_318 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, this->unk_200, rotStep, overrideStep); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_200[0].y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_200[0].x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_200[0].z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_200[0].y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_200[0].x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_200[0].z, MTXMODE_APPLY); + Matrix_Push(); } } diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c index a2324aaf6..a52c9391d 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c @@ -1173,7 +1173,7 @@ void EnTalkGibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi (limbIndex == GIBDO_LIMB_LEFT_FOREARM) || (limbIndex == GIBDO_LIMB_LEFT_HAND) || (limbIndex == GIBDO_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || (limbIndex == GIBDO_LIMB_RIGHT_FOREARM) || (limbIndex == GIBDO_LIMB_RIGHT_HAND) || (limbIndex == GIBDO_LIMB_HEAD) || (limbIndex == GIBDO_LIMB_PELVIS))) { - Matrix_GetStateTranslation(&this->limbPos[this->limbIndex]); + Matrix_MultZero(&this->limbPos[this->limbIndex]); this->limbIndex++; } } diff --git a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c index b7e5588f7..0f8b56068 100644 --- a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c +++ b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c @@ -264,9 +264,9 @@ void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { Math_ApproachS(&ptr->unk_1A, ptr->unk_20, 2, this->unk_158); Math_ApproachS(&ptr->unk_18, ptr->unk_1E, 2, this->unk_158); - Matrix_RotateY(ptr->unk_1A, MTXMODE_NEW); - Matrix_InsertXRotation_s(-ptr->unk_18, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(6.0f, &ptr->unk_0C); + Matrix_RotateYS(ptr->unk_1A, MTXMODE_NEW); + Matrix_RotateXS(-ptr->unk_18, MTXMODE_APPLY); + Matrix_MultVecZ(6.0f, &ptr->unk_0C); if (phi_s2 != NULL) { temp.x = phi_s2->x - ptr->unk_00.x; @@ -277,9 +277,9 @@ void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { ptr->unk_20 = Math_Atan2S(temp.x, temp.z); ptr->unk_1E = Math_Atan2S(temp.y, sqrtf(SQXZ(temp))); - Matrix_RotateY(ptr->unk_20, MTXMODE_NEW); - Matrix_InsertXRotation_s(-ptr->unk_1E, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(-20.0f, &ptr->unk_0C); + Matrix_RotateYS(ptr->unk_20, MTXMODE_NEW); + Matrix_RotateXS(-ptr->unk_1E, MTXMODE_APPLY); + Matrix_MultVecZ(-20.0f, &ptr->unk_0C); if (phi_f28 >= 100000.0f) { ptr->unk_28 = 1; @@ -299,8 +299,8 @@ void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { } else { ptr->unk_1A += ptr->unk_2A; Math_ApproachS(&ptr->unk_18, 0, 0xA, 0x1000); - Matrix_RotateY(ptr->unk_1A, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(ptr->unk_30, &spA4); + Matrix_RotateYS(ptr->unk_1A, MTXMODE_NEW); + Matrix_MultVecZ(ptr->unk_30, &spA4); ptr->unk_0C.x = spA4.x; ptr->unk_0C.z = spA4.z; @@ -315,9 +315,9 @@ void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { ptr->unk_20 = Math_Atan2S(temp.x, temp.z); ptr->unk_1E = Math_Atan2S(temp.y, sqrtf(SQXZ(temp))); - Matrix_RotateY(ptr->unk_20, MTXMODE_NEW); - Matrix_InsertXRotation_s(-ptr->unk_1E, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(-20.0f, &ptr->unk_0C); + Matrix_RotateYS(ptr->unk_20, MTXMODE_NEW); + Matrix_RotateXS(-ptr->unk_1E, MTXMODE_APPLY); + Matrix_MultVecZ(-20.0f, &ptr->unk_0C); ptr->unk_3C = ptr->unk_00.y - 1000.0f; ptr->unk_30 = 5.0f; @@ -378,9 +378,9 @@ void func_80BB5AAC(EnTanron1* this, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001888); flag++; } - Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_RotateY(ptr->unk_1A, MTXMODE_APPLY); - Matrix_InsertXRotation_s(ptr->unk_18 * -1, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateYS(ptr->unk_1A, MTXMODE_APPLY); + Matrix_RotateXS(ptr->unk_18 * -1, MTXMODE_APPLY); Matrix_Scale(1.2f, ptr->unk_2C, 1.2f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -403,9 +403,9 @@ void func_80BB5AAC(EnTanron1* this, GlobalContext* globalCtx) { flag++; } - Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_RotateY(ptr->unk_1A, MTXMODE_APPLY); - Matrix_InsertXRotation_s(ptr->unk_18 * -1, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateYS(ptr->unk_1A, MTXMODE_APPLY); + Matrix_RotateXS(ptr->unk_18 * -1, MTXMODE_APPLY); Matrix_Scale(1.0f, ptr->unk_2C, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c index e391669e5..66ee6080e 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c @@ -261,8 +261,8 @@ void func_80BB6BD8(EnTanron2* this, GlobalContext* globalCtx) { } break; } - Matrix_RotateY(sp32, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(this->actor.speedXZ, &this->actor.velocity); + Matrix_RotateYS(sp32, MTXMODE_NEW); + Matrix_MultVecZ(this->actor.speedXZ, &this->actor.velocity); this->actor.velocity.y = Rand_ZeroFloat(5.0f) + 12.0f; this->unk_14E = 5; } @@ -359,9 +359,9 @@ void func_80BB71C8(EnTanron2* this, GlobalContext* globalCtx) { Vec3f sp90; for (i = 0; i < 15; i++) { - Matrix_InsertYRotation_f(Rand_ZeroFloat(6.2831855f), MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(6.2831855f)); - Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(10.0f) + 5.0f, &spA8); + Matrix_RotateYF(Rand_ZeroFloat(6.2831855f), MTXMODE_NEW); + Matrix_RotateXFApply(Rand_ZeroFloat(6.2831855f)); + Matrix_MultVecZ(Rand_ZeroFloat(10.0f) + 5.0f, &spA8); sp90.x = this->actor.world.pos.x + spA8.x; sp90.y = this->actor.world.pos.y + spA8.y; sp90.z = this->actor.world.pos.z + spA8.z; @@ -436,13 +436,13 @@ void func_80BB7578(EnTanron2* this, GlobalContext* globalCtx) { } else { this->unk_154 = 15; if (this->actionFunc != func_80BB69FC) { - Matrix_RotateY(this->actor.yawTowardsPlayer, MTXMODE_NEW); + Matrix_RotateYS(this->actor.yawTowardsPlayer, MTXMODE_NEW); if ((acHitInfo->toucher.dmgFlags & 0x300000) != 0) { this->unk_154 = 10; - Matrix_GetStateTranslationAndScaledZ(-10.0f, &this->actor.velocity); + Matrix_MultVecZ(-10.0f, &this->actor.velocity); } else { this->unk_156 = 15; - Matrix_GetStateTranslationAndScaledZ(-20.0f, &this->actor.velocity); + Matrix_MultVecZ(-20.0f, &this->actor.velocity); damage = this->actor.colChkInfo.damage; this->actor.colChkInfo.health -= damage; func_80BB7398(this, globalCtx); @@ -464,10 +464,10 @@ void func_80BB7578(EnTanron2* this, GlobalContext* globalCtx) { block_18: func_80BB6B80(this); this->unk_158 = 2; - Matrix_RotateY(Math_Atan2S(this->actor.world.pos.x - D_80BB8450->unk_6BC.x, - this->actor.world.pos.z - D_80BB8450->unk_6BC.z), - MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(10.0f, &this->actor.velocity); + Matrix_RotateYS(Math_Atan2S(this->actor.world.pos.x - D_80BB8450->unk_6BC.x, + this->actor.world.pos.z - D_80BB8450->unk_6BC.z), + MTXMODE_NEW); + Matrix_MultVecZ(10.0f, &this->actor.velocity); this->unk_152 = Rand_ZeroFloat(100.0f) + 200.0f; } else if (D_80BB8450->unk_1F6 == 10) { Actor_MarkForDeath(&this->actor); @@ -624,13 +624,13 @@ void EnTanron2_Draw(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < ARRAY_COUNT(D_80BB8458); i++) { if (D_80BB8458[i] != NULL) { - Matrix_InsertTranslation(D_80BB8458[i]->actor.world.pos.x, D_80BB8458[i]->actor.world.pos.y, - D_80BB8458[i]->actor.world.pos.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(D_80BB8458[i]->actor.world.pos.x, D_80BB8458[i]->actor.world.pos.y, + D_80BB8458[i]->actor.world.pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(D_80BB8458[i]->actor.scale.x, D_80BB8458[i]->actor.scale.y, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(D_80BB8458[i]->unk_14A, MTXMODE_APPLY); + Matrix_RotateZS(D_80BB8458[i]->unk_14A, MTXMODE_APPLY); Matrix_Scale(0.13f, 0.14299999f, 0.13f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-D_80BB8458[i]->unk_14A, MTXMODE_APPLY); + Matrix_RotateZS(-D_80BB8458[i]->unk_14A, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -646,8 +646,7 @@ void EnTanron2_Draw(Actor* thisx, GlobalContext* globalCtx2) { tanron2 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; while (tanron2 != NULL) { if ((tanron2->params < 100) && (((EnTanron2*)tanron2)->unk_15B != 0)) { - Matrix_InsertTranslation(tanron2->world.pos.x, D_80BB8450->actor.floorHeight, tanron2->world.pos.z, - MTXMODE_NEW); + Matrix_Translate(tanron2->world.pos.x, D_80BB8450->actor.floorHeight, tanron2->world.pos.z, MTXMODE_NEW); Matrix_Scale(0.6f, 0.0f, 0.6f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -668,8 +667,8 @@ void EnTanron2_Draw(Actor* thisx, GlobalContext* globalCtx2) { while (tanron2 != NULL) { if ((tanron2->params < 100) && (((EnTanron2*)tanron2)->unk_15B != 0) && (tanron2->world.pos.y <= tanron2->floorHeight)) { - Matrix_InsertTranslation(tanron2->world.pos.x, D_80BB8450->actor.floorHeight + 2.0f, tanron2->world.pos.z, - MTXMODE_NEW); + Matrix_Translate(tanron2->world.pos.x, D_80BB8450->actor.floorHeight + 2.0f, tanron2->world.pos.z, + MTXMODE_NEW); Matrix_Scale(D_80BB8454, 0.0f, D_80BB8454, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c index 15d307326..5e6bd32ee 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c @@ -135,9 +135,9 @@ void EnTanron3_SpawnBubbles(EnTanron3* this, GlobalContext* globalCtx) { Vec3f acceleration; for (i = 0; i < 20; i++) { - Matrix_InsertYRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_NEW); - Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(3.0f) + 2.0f, &velocity); + Matrix_RotateYF(Rand_ZeroFloat(2 * M_PI), MTXMODE_NEW); + Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI)); + Matrix_MultVecZ(Rand_ZeroFloat(3.0f) + 2.0f, &velocity); acceleration.x = velocity.x * -0.05f; acceleration.y = velocity.y * -0.05f; acceleration.z = velocity.z * -0.05f; @@ -232,8 +232,8 @@ void EnTanron3_Live(EnTanron3* this, GlobalContext* globalCtx) { // opposite direction and swim away. In both cases, the fish's target y-position // will be slightly above the halfway point of the water. atanTemp = Math_FAtan2F(this->targetPos.z, this->targetPos.x); - Matrix_RotateY(atanTemp, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(700.0f, &this->targetPos); + Matrix_RotateYS(atanTemp, MTXMODE_NEW); + Matrix_MultVecZ(700.0f, &this->targetPos); this->targetPos.y = 250.0f; extraScaleY = 150.0f; diff --git a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c index 969a87cf6..48eea6828 100644 --- a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c +++ b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c @@ -276,7 +276,7 @@ void EnTanron4_Draw(Actor* thisx, GlobalContext* globalCtx) { EnTanron4* this = THIS; if (this->timeInfluence < 1400.0f) { - Matrix_InsertZRotation_s(this->roll, MTXMODE_APPLY); + Matrix_RotateZS(this->roll, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, NULL, &this->actor); } diff --git a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c index 85baedbc8..09da81cee 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c @@ -517,8 +517,8 @@ void func_80BE5C10(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(texture)); - Matrix_InsertTranslation(0.0f, 200.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_198, MTXMODE_APPLY); + Matrix_Translate(0.0f, 200.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_198, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.c b/src/overlays/actors/ovl_En_Test/z_en_test.c index 7f99833b4..e3e22939f 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -145,8 +145,8 @@ void func_80863048(GlobalContext* globalCtx, EnTestStruct* arg1) { continue; } - Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); - Matrix_InsertRotation(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + Matrix_RotateZYX(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); Matrix_Scale(ptr->unk_2C, ptr->unk_2C, ptr->unk_2C, MTXMODE_APPLY); mtx = Matrix_NewMtx(globalCtx->state.gfxCtx); @@ -182,7 +182,7 @@ void EnTest_Init(Actor* thisx, GlobalContext* globalCtx2) { thisx->world.pos.y = thisx->floorHeight; func_800C0094(thisx->floorPoly, thisx->world.pos.x, thisx->floorHeight, thisx->world.pos.z, &sp38); - func_8018219C(&sp38, &thisx->shape.rot, 1); + Matrix_MtxFToYXZRot(&sp38, &thisx->shape.rot, true); thisx->world.rot = thisx->shape.rot; this->unk_20A = func_800C9BB8(&globalCtx->colCtx, thisx->floorPoly, sp34); } diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index 78b370c3b..2efb3eb6b 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -214,7 +214,7 @@ void func_80A90D34(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) OPEN_DISPS(globalCtx->state.gfxCtx); if (ptr->unk_00 != 0) { - Matrix_InsertTranslation(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_Translate(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); Matrix_Scale(ptr->unk_04 * 0.02f, ptr->unk_04 * 0.02f, ptr->unk_04 * 0.02f, MTXMODE_APPLY); POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); @@ -224,11 +224,11 @@ void func_80A90D34(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); } - Matrix_InsertTranslation(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_Translate(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); Matrix_Scale(2.0f * ptr->unk_04, 2.0f * ptr->unk_04, 2.0f * ptr->unk_04, MTXMODE_APPLY); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_s(globalCtx->state.frames * 512, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 2.0f, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(globalCtx->state.frames * 512, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 2.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -267,20 +267,20 @@ void func_80A90FC0(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) gSPSegment(POLY_OPA_DISP++, 0x07, gfx2); - Matrix_InsertTranslation(sp64.x, sp64.y, sp64.z, MTXMODE_NEW); + Matrix_Translate(sp64.x, sp64.y, sp64.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_04 * 0.018f, ptr->unk_04 * 0.018f, ptr->unk_04 * 0.018f, MTXMODE_APPLY); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A9402C[ptr->unk_00])); gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); } - Matrix_InsertTranslation(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_Translate(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); Matrix_Scale(ptr->unk_04 * 2.5f, ptr->unk_04 * 2.5f, ptr->unk_04 * 2.5f, MTXMODE_APPLY); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_s(globalCtx->state.frames * 256, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 4.0f, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(globalCtx->state.frames * 256, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 4.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1117,10 +1117,10 @@ void func_80A93298(EnTest6* this, GlobalContext* globalCtx) { temp_s3 += 0x1000; cos = Math_CosS(temp_s3) * this->unk_150; sin = Math_SinS(temp_s3) * this->unk_150; - Matrix_InsertTranslation(cos, phi_f24, sin, MTXMODE_NEW); - Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_Translate(cos, phi_f24, sin, MTXMODE_NEW); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(phi_s2, MTXMODE_APPLY); + Matrix_RotateZS(phi_s2, MTXMODE_APPLY); gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); @@ -1131,10 +1131,10 @@ void func_80A93298(EnTest6* this, GlobalContext* globalCtx) { temp_s4 += 0x1000; cos = Math_CosS(temp_s4) * this->unk_150; sin = Math_SinS(temp_s4) * this->unk_150; - Matrix_InsertTranslation(cos, phi_f24, sin, MTXMODE_NEW); - Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_Translate(cos, phi_f24, sin, MTXMODE_NEW); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-phi_s2, MTXMODE_APPLY); + Matrix_RotateZS(-phi_s2, MTXMODE_APPLY); gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); @@ -1203,11 +1203,11 @@ void func_80A9369C(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < 51; i++) { temp_f20 = Math_CosS(phi_s2) * this->unk_150; temp_f22 = Math_SinS(phi_s2) * this->unk_150; - Matrix_InsertZRotation_s(this->unk_27E, MTXMODE_NEW); - Matrix_InsertTranslation(phi_f26, temp_f20, temp_f22, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_27E, MTXMODE_NEW); + Matrix_Translate(phi_f26, temp_f20, temp_f22, MTXMODE_APPLY); Matrix_Scale(0.85f, 0.85f, 0.85f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(phi_s2, MTXMODE_APPLY); - Matrix_InsertZRotation_s(sp78, MTXMODE_APPLY); + Matrix_RotateXS(phi_s2, MTXMODE_APPLY); + Matrix_RotateZS(sp78, MTXMODE_APPLY); gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(this->unk_148++, 0, 0xFF, this->unk_280, this->unk_280, this->unk_280, 255); @@ -1247,10 +1247,10 @@ void func_80A939E8(EnTest6* this, GlobalContext* globalCtx2) { this->unk_148 = POLY_XLU_DISP; for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { - Matrix_InsertTranslation(this->unk_20C[i].x, this->unk_20C[i].y, this->unk_20C[i].z, MTXMODE_NEW); + Matrix_Translate(this->unk_20C[i].x, this->unk_20C[i].y, this->unk_20C[i].z, MTXMODE_NEW); Matrix_Scale(0.3f, 0.3f, 0.3f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(-0x4000, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_278, MTXMODE_APPLY); + Matrix_RotateXS(-0x4000, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_278, MTXMODE_APPLY); gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1265,16 +1265,15 @@ void func_80A939E8(EnTest6* this, GlobalContext* globalCtx2) { if (this->unk_254 != NULL) { for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { temp_f20 = Rand_ZeroOne() * 0.0025f; - Matrix_InsertTranslation((*this->unk_254)[i].x, (*this->unk_254)[i].y, (*this->unk_254)[i].z, - MTXMODE_NEW); + Matrix_Translate((*this->unk_254)[i].x, (*this->unk_254)[i].y, (*this->unk_254)[i].z, MTXMODE_NEW); Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 128, 128, 128, this->unk_282 >> 1); gDPSetEnvColor(POLY_XLU_DISP++, 230, 230, 180, this->unk_282); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_278 + (i << 2), MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_278 + (i << 2), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.c b/src/overlays/actors/ovl_En_Test7/z_en_test7.c index c5fda21f0..8aacf408d 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -332,7 +332,7 @@ void func_80AF14FC(GlobalContext* globalCtx2, EnTest7Struct2* arg1) { func_8012C1C0(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); @@ -348,18 +348,18 @@ void func_80AF14FC(GlobalContext* globalCtx2, EnTest7Struct2* arg1) { continue; } - Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); if (ptr->unk_00 == 1) { - Matrix_InsertRotation(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + Matrix_RotateZYX(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); } else { SkinMatrix_SetRotateYRP(&sp6C, ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z); - Matrix_InsertMatrix(&sp6C, MTXMODE_APPLY); + Matrix_Mult(&sp6C, MTXMODE_APPLY); } Matrix_Scale(ptr->unk_2C, ptr->unk_2C, ptr->unk_2C, MTXMODE_APPLY); if (ptr->unk_00 == 2) { - Matrix_InsertTranslation(0.0f, 30.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 30.0f, 0.0f, MTXMODE_APPLY); } temp_v0 = Matrix_NewMtx(globalCtx->state.gfxCtx); @@ -371,7 +371,7 @@ void func_80AF14FC(GlobalContext* globalCtx2, EnTest7Struct2* arg1) { if (ptr) {} - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -939,7 +939,7 @@ s32 func_80AF31D0(GlobalContext* globalCtx, SkeletonInfo* skeletonInfo, s32 limb Vec3f sp18; if ((*dList != NULL) && (Rand_ZeroOne() < 0.03f)) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp18); + Matrix_MultVec3f(&gZeroVec3f, &sp18); func_80AF0C30(this->unk_15C, &sp18, 0); } return true; @@ -961,15 +961,15 @@ void EnTest7_Draw(Actor* thisx, GlobalContext* globalCtx) { } if (this->unk_144 & 2) { - Matrix_StatePush(); - Matrix_InsertTranslation(0.0f, 4000.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertRotation(0, this->unk_148.unk_10, 0, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(0.0f, 4000.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZYX(0, this->unk_148.unk_10, 0, MTXMODE_APPLY); Matrix_Scale(this->unk_148.unk_08 * 100.0f, this->unk_148.unk_0C * 100.0f, this->unk_148.unk_08 * 100.0f, MTXMODE_APPLY); sp40 = this->unk_148.unk_00; AnimatedMat_DrawStep(globalCtx, Lib_SegmentedToVirtual(&gameplay_keep_Matanimheader_0815D0), sp40); Gfx_DrawDListXlu(globalCtx, gameplay_keep_DL_080FC8); - Matrix_StatePop(); + Matrix_Pop(); } func_80AF14FC(globalCtx, this->unk_15C); diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index 5a89347e7..faeb3163e 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -1066,7 +1066,7 @@ void EnThiefbird_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi OPEN_DISPS(globalCtx->state.gfxCtx); gfx = POLY_OPA_DISP; - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], this->unk_3E4); POLY_OPA_DISP = &gfx[2]; @@ -1098,11 +1098,11 @@ void EnThiefbird_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi idx = D_80C13698[limbIndex]; if (idx != -1) { if (idx == 9) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[idx]); + Matrix_MultVecX(1000.0f, &this->limbPos[idx]); } else { - Matrix_GetStateTranslation(&this->limbPos[idx]); + Matrix_MultZero(&this->limbPos[idx]); if ((idx == 3) || (idx == 5)) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->limbPos[idx + 1]); + Matrix_MultVecX(2000.0f, &this->limbPos[idx + 1]); } } } @@ -1123,11 +1123,11 @@ void func_80C13354(EnThiefbird* this, GlobalContext* globalCtx2) { for (i = 0; i < ARRAY_COUNT(this->unk_3F0); i++, ptr++) { if (ptr->unk_22 != 0) { - Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_RotateY(ptr->unk_1E, MTXMODE_APPLY); - Matrix_InsertZRotation_s(ptr->unk_20, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -10.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_RotateYS(ptr->unk_1E, MTXMODE_APPLY); + Matrix_RotateZS(ptr->unk_20, MTXMODE_APPLY); + Matrix_Translate(0.0f, -10.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(ptr->unk_18, ptr->unk_18, 1.0f, MTXMODE_APPLY); gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Tite/z_en_tite.c b/src/overlays/actors/ovl_En_Tite/z_en_tite.c index 7839e4585..153bb8722 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -1121,14 +1121,14 @@ void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V if (this->unk_2BA == 0) { idx = D_80896B70[limbIndex]; if (idx != -1) { - Matrix_GetStateTranslation(&this->limbPos[idx]); + Matrix_MultZero(&this->limbPos[idx]); if (idx >= 1) { - Matrix_GetStateTranslationAndScaledX(2500.0f, &this->limbPos[idx + 4]); + Matrix_MultVecX(2500.0f, &this->limbPos[idx + 4]); } } } else if (this->unk_2BA > 0) { if (D_80896B8C[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[D_80896B8C[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_80896B8C[limbIndex]]); } if (limbIndex == 24) { @@ -1137,11 +1137,11 @@ void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V } else if (D_80896B8C[limbIndex] != -1) { OPEN_DISPS(globalCtx->state.gfxCtx); - matrix = Matrix_GetCurrentState(); - matrix->wx = this->limbPos[D_80896B8C[limbIndex]].x; - matrix->wy = this->limbPos[D_80896B8C[limbIndex]].y; - matrix->wz = this->limbPos[D_80896B8C[limbIndex]].z; - Matrix_InsertZRotation_s(this->actor.world.rot.z, MTXMODE_APPLY); + matrix = Matrix_GetCurrent(); + matrix->xw = this->limbPos[D_80896B8C[limbIndex]].x; + matrix->yw = this->limbPos[D_80896B8C[limbIndex]].y; + matrix->zw = this->limbPos[D_80896B8C[limbIndex]].z; + Matrix_RotateZS(this->actor.world.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, this->unk_3A8); diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index d239a6cb7..4f61ac43f 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -1353,11 +1353,11 @@ void EnTk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (this->unk_2B0 != 2) { switch (limbIndex) { case 16: - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); break; case 14: - Matrix_MultiplyVector3fByState(&D_80AEFA84, &this->unk_2B4); + Matrix_MultVec3f(&D_80AEFA84, &this->unk_2B4); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1384,7 +1384,7 @@ void EnTk_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AEFA90[this->unk_2C2])); - Matrix_RotateY(this->unk_318, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_318, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTk_OverrideLimbDraw, EnTk_PostLimbDraw, &this->actor); diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.c b/src/overlays/actors/ovl_En_Trt/z_en_trt.c index 897a1d3ab..470f4908a 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -1697,9 +1697,9 @@ void EnTrt_UpdateHeadPosAndRot(s16 pitch, s16 yaw, Vec3f* pos, Vec3s* rot, s32 i Vec3s newRot; MtxF currentState; - Matrix_MultiplyVector3fByState(&zeroVec, &newPos); - Matrix_CopyCurrentState(¤tState); - func_8018219C(¤tState, &newRot, MTXMODE_NEW); + Matrix_MultVec3f(&zeroVec, &newPos); + Matrix_Get(¤tState); + Matrix_MtxFToYXZRot(¤tState, &newRot, false); *pos = newPos; if (isFullyAwake) { newRot.x += pitch; @@ -1740,11 +1740,11 @@ void EnTrt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } if (limbIndex == 21) { EnTrt_UpdateHeadPosAndRot(this->headPitch, this->headYaw, &this->headPos, &this->headRot, isFullyAwake); - Matrix_InsertTranslation(this->headPos.x, this->headPos.y, this->headPos.z, MTXMODE_NEW); + Matrix_Translate(this->headPos.x, this->headPos.y, this->headPos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->headRot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->headRot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->headRot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->headRot.z, MTXMODE_APPLY); } } @@ -1752,11 +1752,11 @@ void EnTrt_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi EnTrt* this = THIS; if (limbIndex == 21) { - Matrix_InsertTranslation(this->headPos.x, this->headPos.y, this->headPos.z, MTXMODE_NEW); + Matrix_Translate(this->headPos.x, this->headPos.y, this->headPos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->headRot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->headRot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->headRot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->headRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->headRot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->headRot.z, MTXMODE_APPLY); } } diff --git a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c index 0af7ac4bb..f2b8c9138 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -854,9 +854,9 @@ void func_80AD5394(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4) { Vec3s sp68; MtxF sp28; - Matrix_MultiplyVector3fByState(&sp70, &sp7C); - Matrix_CopyCurrentState(&sp28); - func_8018219C(&sp28, &sp68, 0); + Matrix_MultVec3f(&sp70, &sp7C); + Matrix_Get(&sp28); + Matrix_MtxFToYXZRot(&sp28, &sp68, false); *arg2 = sp7C; @@ -895,12 +895,12 @@ void EnTrt2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V if (limbIndex == 21) { func_80AD5394(this->unk_3D4, this->unk_3D6, &this->unk_3C8, &this->unk_3C2, phi_v0); - Matrix_InsertTranslation(this->unk_3C8.x, this->unk_3C8.y, this->unk_3C8.z, MTXMODE_NEW); + Matrix_Translate(this->unk_3C8.x, this->unk_3C8.y, this->unk_3C8.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_3C2.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_3C2.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_3C2.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&sp30, &this->actor.focus.pos); + Matrix_RotateYS(this->unk_3C2.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_3C2.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_3C2.z, MTXMODE_APPLY); + Matrix_MultVec3f(&sp30, &this->actor.focus.pos); } } @@ -908,11 +908,11 @@ void EnTrt2_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* th EnTrt2* this = THIS; if (limbIndex == 21) { - Matrix_InsertTranslation(this->unk_3C8.x, this->unk_3C8.y, this->unk_3C8.z, MTXMODE_NEW); + Matrix_Translate(this->unk_3C8.x, this->unk_3C8.y, this->unk_3C8.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_3C2.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_3C2.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_3C2.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_3C2.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_3C2.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_3C2.z, MTXMODE_APPLY); } } diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index 3390b8422..d428553f8 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -176,10 +176,10 @@ void func_80A85788(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, -arg0->unk_02 * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(arg0->unk_28, arg0->unk_28, 1.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 14.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 14.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -234,8 +234,8 @@ void func_80A85BCC(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)alpha); - Matrix_InsertTranslation(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(arg0->unk_28, arg0->unk_28, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -286,7 +286,7 @@ void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { flag = true; } - Matrix_StatePush(); + Matrix_Push(); do { alpha = (f32)arg0->unk_02 / arg0->unk_01; @@ -303,9 +303,9 @@ void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, D_80A8B25C[arg0->unk_00 - 3].r, D_80A8B25C[arg0->unk_00 - 3].g, D_80A8B25C[arg0->unk_00 - 3].b, 0); - Matrix_InsertTranslation(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); + Matrix_Translate(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); Matrix_Scale(arg0->unk_28, arg0->unk_28, 1.0f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -313,7 +313,7 @@ void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A8B280[idx])); gSPDisplayList(POLY_XLU_DISP++, object_tru_DL_01A830); - Matrix_StatePop(); + Matrix_Pop(); } } @@ -478,7 +478,7 @@ s32 func_80A86B0C(EnTru* this, GlobalContext* globalCtx) { s32 func_80A86BAC(EnTru* this, GlobalContext* globalCtx) { if (this->unk_34E & 0x400) { - Matrix_StatePush(); + Matrix_Push(); func_8012C28C(globalCtx->state.gfxCtx); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -497,30 +497,30 @@ s32 func_80A86BAC(EnTru* this, GlobalContext* globalCtx) { break; } - Matrix_InsertXRotation_s(-0x4000, MTXMODE_APPLY); + Matrix_RotateXS(-0x4000, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_0020C8); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } if (this->unk_34E & 0x800) { - Matrix_StatePush(); + Matrix_Push(); func_8012C2DC(globalCtx->state.gfxCtx); OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(POLY_XLU_DISP++); - Matrix_InsertXRotation_s(-0x4000, MTXMODE_APPLY); + Matrix_RotateXS(-0x4000, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_tru_DL_001F90); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1168,13 +1168,13 @@ s32 EnTru_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnTru* this = THIS; if (limbIndex == 21) { - Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_MultZero(&this->actor.focus.pos); Math_Vec3f_ToVec3s(&this->collider.dim.worldSphere.center, &this->actor.focus.pos); this->actor.focus.pos.x = (this->actor.focus.pos.x / 10.0f) * 10.0f; this->actor.focus.pos.y = ((this->actor.focus.pos.y + 10.0f) / 10.0f) * 10.0f; this->actor.focus.pos.z = (this->actor.focus.pos.z / 10.0f) * 10.0f; Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); - Matrix_MultiplyVector3fByState(&D_80A8B3FC, &this->unk_1F8); + Matrix_MultVec3f(&D_80A8B3FC, &this->unk_1F8); } if (!(this->unk_34E & 0x200) && (limbIndex == 14)) { @@ -1217,8 +1217,8 @@ void EnTru_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi if (limbIndex == 21) { SubS_UpdateLimb(this->unk_366, this->unk_368 + this->actor.shape.rot.y, &this->unk_1EC, &this->unk_204, stepRot, overrideRot); - Matrix_StatePop(); - Matrix_InsertTranslation(this->unk_1EC.x, this->unk_1EC.y, this->unk_1EC.z, MTXMODE_NEW); + Matrix_Pop(); + Matrix_Translate(this->unk_1EC.x, this->unk_1EC.y, this->unk_1EC.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (overrideRot) { s16 oldZ = this->unk_204.z; @@ -1226,10 +1226,10 @@ void EnTru_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi this->unk_204.z = this->unk_204.x; this->unk_204.x = oldZ; } - Matrix_RotateY(this->unk_204.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_204.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_204.z, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_RotateYS(this->unk_204.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_204.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_204.z, MTXMODE_APPLY); + Matrix_Push(); } } diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c index e191cc3cd..3be859a99 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c @@ -455,9 +455,9 @@ void func_80B76ED4(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4) { Vec3s sp68; MtxF sp28; - Matrix_MultiplyVector3fByState(&sp70, &sp7C); - Matrix_CopyCurrentState(&sp28); - func_8018219C(&sp28, &sp68, 0); + Matrix_MultVec3f(&sp70, &sp7C); + Matrix_Get(&sp28); + Matrix_MtxFToYXZRot(&sp28, &sp68, false); *arg2 = sp7C; @@ -479,11 +479,11 @@ s32 EnTruMt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis EnTruMt* this = THIS; if (limbIndex == OBJECT_TRU_LIMB_15) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk_35C); + Matrix_MultVec3f(&gZeroVec3f, &this->unk_35C); } if (limbIndex == OBJECT_TRU_LIMB_15) { - Matrix_MultiplyVector3fByState(&D_80B7765C, &this->unk_350); + Matrix_MultVec3f(&D_80B7765C, &this->unk_350); } return false; } @@ -501,11 +501,11 @@ void EnTruMt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, phi_v0 = 0; } func_80B76ED4(this->unk_348, this->unk_34A, &this->unk_33C, &this->unk_336, phi_v0); - Matrix_InsertTranslation(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_Translate(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_336.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_336.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_336.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_336.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_336.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_336.z, MTXMODE_APPLY); } if (limbIndex == OBJECT_TRU_LIMB_0E) { @@ -513,11 +513,11 @@ void EnTruMt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_MultiplyVector3fByState(&D_80B77668, &this->unk_370); - Matrix_InsertTranslation(this->unk_370.x, this->unk_370.y, this->unk_370.z, MTXMODE_NEW); - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_38E.z, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_38E.x, MTXMODE_APPLY); + Matrix_MultVec3f(&D_80B77668, &this->unk_370); + Matrix_Translate(this->unk_370.x, this->unk_370.y, this->unk_370.z, MTXMODE_NEW); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_RotateZS(this->unk_38E.z, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_38E.x, MTXMODE_APPLY); Matrix_Scale(0.008f, 0.008f, 0.008f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -525,15 +525,15 @@ void EnTruMt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, CLOSE_DISPS(globalCtx->state.gfxCtx); - sp54 = Matrix_GetCurrentState(); + sp54 = Matrix_GetCurrent(); if ((this->actor.child == NULL) || (this->actor.child->update == NULL)) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_JC_MATO, sp54->wx, sp54->wy, - sp54->wz, this->unk_38E.x, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_JC_MATO, sp54->xw, sp54->yw, + sp54->zw, this->unk_38E.x, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), this->unk_38E.z, -1); } else if (!((EnJcMato*)this->actor.child)->hitFlag) { - this->actor.child->world.pos.x = sp54->wx; - this->actor.child->world.pos.y = sp54->wy; - this->actor.child->world.pos.z = sp54->wz; + this->actor.child->world.pos.x = sp54->xw; + this->actor.child->world.pos.y = sp54->yw; + this->actor.child->world.pos.z = sp54->zw; this->actor.child->world.rot = this->unk_38E; this->actor.child->world.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); @@ -547,11 +547,11 @@ void EnTruMt_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* t EnTruMt* this = THIS; if (limbIndex == OBJECT_TRU_LIMB_15) { - Matrix_InsertTranslation(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_Translate(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateY(this->unk_336.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_336.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_336.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_336.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_336.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_336.z, MTXMODE_APPLY); } } diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c index e999e5c5c..217d32540 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c @@ -614,7 +614,7 @@ void EnTsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Vec3f sp18 = D_80AE11BC; if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + Matrix_MultVec3f(&sp18, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Vm/z_en_vm.c b/src/overlays/actors/ovl_En_Vm/z_en_vm.c index 6103cb577..77449c7a3 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.c +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.c @@ -483,9 +483,9 @@ void EnVm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (limbIndex == OBJECT_VM_LIMB_02) { sp4C = NULL; - Matrix_GetStateTranslation(&this->actor.focus.pos); - Matrix_GetStateTranslationAndScaledZ(1600.0f, &this->unk_228); - Matrix_GetStateTranslationAndScaledZ(this->unk_224 * 71.428566f, &this->unk_234); + Matrix_MultZero(&this->actor.focus.pos); + Matrix_MultVecZ(1600.0f, &this->unk_228); + Matrix_MultVecZ(this->unk_224 * 71.428566f, &this->unk_234); if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.focus.pos, &this->unk_234, &sp5C, &sp4C, true, true, false, true, &sp48)) { @@ -526,7 +526,7 @@ void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(&gfx[0], &sSetupDL[6 * 60]); gDPSetColorDither(&gfx[1], G_CD_DISABLE); - Matrix_InsertTranslation(this->unk_234.x, this->unk_234.y + 10.0f, this->unk_234.z, MTXMODE_NEW); + Matrix_Translate(this->unk_234.x, this->unk_234.y + 10.0f, this->unk_234.z, MTXMODE_NEW); Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -543,9 +543,8 @@ void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(&gfx[0], 0x08, func_8012CB28(globalCtx->state.gfxCtx, 0, this->unk_212)); - Matrix_InsertTranslation(this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z, - MTXMODE_NEW); - Matrix_InsertRotation(this->unk_216, this->unk_218 + this->actor.shape.rot.y, 0, MTXMODE_APPLY); + Matrix_Translate(this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z, MTXMODE_NEW); + Matrix_RotateZYX(this->unk_216, this->unk_218 + this->actor.shape.rot.y, 0, MTXMODE_APPLY); Matrix_Scale(this->unk_220, this->unk_220, this->unk_224 * 0.0015f, MTXMODE_APPLY); gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c index 1b88d692b..8ebb04c22 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c @@ -670,7 +670,7 @@ void EnWallmas_DrawShadow(EnWallmas* this, GlobalContext* globalCtx) { gDPSetPrimColor(&gfx[1], 0, 0, 0, 0, 0, 255); func_800C0094(this->actor.floorPoly, this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, &mf); - Matrix_InsertMatrix(&mf, MTXMODE_NEW); + Matrix_Mult(&mf, MTXMODE_NEW); if ((this->actionFunc != EnWallmas_WaitToDrop) && (this->actionFunc != EnWallmas_ReturnToCeiling) && (this->actionFunc != EnWallmas_TakePlayer) && (this->actionFunc != EnWallmas_WaitForSwitchFlag)) { @@ -709,21 +709,21 @@ void EnWallmas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Gfx* gfx; if (sLimbIndexToLimbPosIndex[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[sLimbIndexToLimbPosIndex[limbIndex]]); + Matrix_MultZero(&this->limbPos[sLimbIndexToLimbPosIndex[limbIndex]]); } if (limbIndex == WALLMASTER_LIMB_WRIST) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[9]); - Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->limbPos[10]); + Matrix_MultVecX(1000.0f, &this->limbPos[9]); + Matrix_MultVecX(-1000.0f, &this->limbPos[10]); } else if (limbIndex == WALLMASTER_LIMB_HAND) { OPEN_DISPS(globalCtx->state.gfxCtx); gfx = POLY_OPA_DISP; - Matrix_StatePush(); - Matrix_InsertTranslation(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); - Matrix_RotateY(0x2AAA, MTXMODE_APPLY); - Matrix_InsertZRotation_s(0xAAA, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Translate(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); + Matrix_RotateYS(0x2AAA, MTXMODE_APPLY); + Matrix_RotateZS(0xAAA, MTXMODE_APPLY); Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -731,7 +731,7 @@ void EnWallmas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList POLY_OPA_DISP = &gfx[2]; - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c index 51ef3ef38..4065bdf39 100644 --- a/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c +++ b/src/overlays/actors/ovl_En_Warp_Uzu/z_en_warp_uzu.c @@ -80,8 +80,8 @@ void func_80A66208(EnWarpUzu* this, GlobalContext* globalCtx) { Vec3f sp24; this->actor.textId = 0; - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&D_80A664FC, &sp24); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&D_80A664FC, &sp24); Math_Vec3f_Sum(&this->actor.world.pos, &sp24, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.shape.rot); this->actionFunc = func_80A66278; diff --git a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c index 127bcc1c2..df347dc36 100644 --- a/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c +++ b/src/overlays/actors/ovl_En_Water_Effect/z_en_water_effect.c @@ -225,8 +225,8 @@ void EnWaterEffect_Update(Actor* thisx, GlobalContext* globalCtx2) { } for (j = 0; j < 12; j++) { - Matrix_InsertYRotation_f((2.0f * (j * M_PI)) / 5.5f, MTXMODE_NEW); - Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(1.5f) + 1.5f, &spA4); + Matrix_RotateYF((2.0f * (j * M_PI)) / 5.5f, MTXMODE_NEW); + Matrix_MultVecZ(Rand_ZeroFloat(1.5f) + 1.5f, &spA4); spA4.y = Rand_ZeroFloat(4.0f) + 2.0f; func_80A58908(this, &ptr->unk_04, &spA4, ptr->unk_2A); } @@ -293,16 +293,16 @@ void EnWaterEffect_Draw(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)ptr->unk_38, (u8)(((void)0, ptr->unk_38) + 55.0f), 225, 150); - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); if (ptr->unk_00 == 1) { - Matrix_RotateY(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); + Matrix_RotateYS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); } else { - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); } Matrix_Scale(ptr->unk_2C.x, ptr->unk_2C.y, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_f(ptr->unk_2C.z, MTXMODE_APPLY); + Matrix_RotateZF(ptr->unk_2C.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042B0); @@ -326,9 +326,9 @@ void EnWaterEffect_Draw(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)ptr->unk_38, (u8)(((void)0, ptr->unk_38) + 55.0f), 225, ptr->unk_3C); - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_2C.x, 1.0f, ptr->unk_2C.x, MTXMODE_APPLY); - Matrix_InsertYRotation_f(ptr->unk_2C.z, MTXMODE_APPLY); + Matrix_RotateYF(ptr->unk_2C.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042F8); @@ -530,18 +530,18 @@ void func_80A5A184(Actor* thisx, GlobalContext* globalCtx2) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (ptr->unk_01 * -20) & 0x1FF, 0x20, 0x80)); - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); if (ptr->unk_2A >= 2) { - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); } else { - Matrix_RotateY(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); + Matrix_RotateYS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); } Matrix_Scale(ptr->unk_2C.x, ptr->unk_2C.y, 1.0f, MTXMODE_APPLY); if ((i & 1) != 0) { - Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + Matrix_RotateYF(M_PI, MTXMODE_APPLY); } gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -549,8 +549,8 @@ void func_80A5A184(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0043E8); if ((ptr->unk_2A & 1) == 0) { - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y + 5.0f, ptr->unk_04.z, MTXMODE_NEW); - Matrix_InsertXRotation_s(ptr->unk_28, MTXMODE_APPLY); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y + 5.0f, ptr->unk_04.z, MTXMODE_NEW); + Matrix_RotateXS(ptr->unk_28, MTXMODE_APPLY); Matrix_Scale(ptr->unk_2C.z, ptr->unk_2C.z, ptr->unk_2C.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -610,16 +610,16 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); func_8012C2DC(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 165, 235, 255, 128); - Matrix_StatePush(); - Matrix_StatePush(); - Matrix_StatePush(); + Matrix_Push(); + Matrix_Push(); + Matrix_Push(); if ((this->actor.params == ENWATEREFFECT_777) || (this->actor.params == ENWATEREFFECT_778)) { if (this->unk_E2C > 1.0f) { @@ -633,7 +633,7 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000420); } - Matrix_StatePop(); + Matrix_Pop(); if (this->unk_E30 > 1.0f) { func_8012C2DC(globalCtx->state.gfxCtx); @@ -645,10 +645,10 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)this->unk_E30); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000730); } - Matrix_StatePop(); + Matrix_Pop(); } else { - Matrix_StatePop(); - Matrix_StatePop(); + Matrix_Pop(); + Matrix_Pop(); } if ((this->unk_E34 > 1.0f) && (this->actor.params != ENWATEREFFECT_780)) { @@ -661,7 +661,7 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_000A48); } - Matrix_StatePop(); + Matrix_Pop(); if ((this->actor.params == ENWATEREFFECT_777) || (this->actor.params == ENWATEREFFECT_780)) { func_8012C2DC(globalCtx->state.gfxCtx); @@ -690,9 +690,9 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)ptr->unk_38, (u8)(((void)0, ptr->unk_38) + 55.0f), 225, ptr->unk_3C); - Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_2C.x, 1.0f, ptr->unk_2C.x, MTXMODE_APPLY); - Matrix_InsertYRotation_f(ptr->unk_2C.z, MTXMODE_APPLY); + Matrix_RotateYF(ptr->unk_2C.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.c b/src/overlays/actors/ovl_En_Wf/z_en_wf.c index fdd82b864..89e765b98 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -1550,11 +1550,11 @@ void EnWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Collider_UpdateSpheres(limbIndex, &this->collider1); if (D_809942FC[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->limbPos[D_809942FC[limbIndex]]); + Matrix_MultZero(&this->limbPos[D_809942FC[limbIndex]]); } if (limbIndex == WOLFOS_NORMAL_LIMB_TAIL) { - Matrix_GetStateTranslationAndScaledX(1200.0f, &sp20); + Matrix_MultVecX(1200.0f, &sp20); this->collider3.dim.pos.x = sp20.x; this->collider3.dim.pos.y = sp20.y; this->collider3.dim.pos.z = sp20.z; diff --git a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c index d3fffb667..ddfa6af47 100644 --- a/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c +++ b/src/overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.c @@ -108,8 +108,8 @@ void EnWizBrock_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); if (this->dyna.actor.colChkInfo.health != 0) { Scene_SetRenderModeXlu(globalCtx, 0, 1); diff --git a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c index 80dd47feb..53713bbb1 100644 --- a/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c +++ b/src/overlays/actors/ovl_En_Wiz_Fire/z_en_wiz_fire.c @@ -134,9 +134,9 @@ void func_80A4984C(EnWizFire* this, GlobalContext* globalCtx) { } this->unk_16E = 0; - Matrix_StatePush(); - Matrix_RotateY(this->actor.world.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->actor.world.rot.x, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->actor.world.rot.x, MTXMODE_APPLY); if (this->unk_162 != 0) { sp44.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; @@ -144,8 +144,8 @@ void func_80A4984C(EnWizFire* this, GlobalContext* globalCtx) { sp44.z = 12.0f; } - Matrix_MultiplyVector3fByState(&sp44, &this->actor.velocity); - Matrix_StatePop(); + Matrix_MultVec3f(&sp44, &this->actor.velocity); + Matrix_Pop(); this->actor.world.rot.x = this->actor.world.rot.y = this->actor.world.rot.z = 0; this->unk_168 = 50; if (this->unk_162 != 0) { @@ -202,11 +202,11 @@ void func_80A49A44(EnWizFire* this, GlobalContext* globalCtx) { if (this->unk_162 == 1) { this->unk_16A = 10; - Matrix_StatePush(); - Matrix_RotateY((s16)randPlusMinusPoint5Scaled(0x100) + this->actor.world.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS((s16)randPlusMinusPoint5Scaled(0x100) + this->actor.world.rot.y, MTXMODE_NEW); sp54.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; - Matrix_MultiplyVector3fByState(&sp54, &this->actor.velocity); - Matrix_StatePop(); + Matrix_MultVec3f(&sp54, &this->actor.velocity); + Matrix_Pop(); this->actor.velocity.y = 6.0f; this->actor.gravity = -0.7f; @@ -629,8 +629,7 @@ void func_80A4B0C8(EnWizFire* this, GlobalContext* globalCtx) { if ((this->unk_162 == 0) && (this->unk_160 == 2)) { func_8012C28C(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(this->unk_1F0, this->unk_1F0, this->unk_1F0, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -645,7 +644,7 @@ void func_80A4B0C8(EnWizFire* this, GlobalContext* globalCtx) { -globalCtx->state.frames & 0x7F, 0x20, 0x40, 1, globalCtx->state.frames & 0xFF, globalCtx->state.frames & 0xFF, 0x10, 0x10)); - Matrix_RotateY(0, MTXMODE_APPLY); + Matrix_RotateYS(0, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_005750); @@ -664,9 +663,8 @@ void func_80A4B33C(EnWizFire* this, GlobalContext* globalCtx2) { if ((this->unk_162 == 0) && (this->unk_160 == 2)) { func_8012C28C(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Push(); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(this->unk_1F0, this->unk_1F0, this->unk_1F0, MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 0x08, @@ -678,11 +676,10 @@ void func_80A4B33C(EnWizFire* this, GlobalContext* globalCtx2) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 245, 255, 128); gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003120); - Matrix_StatePop(); - Matrix_StatePush(); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Pop(); + Matrix_Push(); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, globalCtx->state.frames % 128, @@ -698,10 +695,9 @@ void func_80A4B33C(EnWizFire* this, GlobalContext* globalCtx2) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003640); - Matrix_StatePop(); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, - MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Pop(); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (-globalCtx->state.frames * 3) % 128, 0, 0x20, 0x20, 1, @@ -728,7 +724,7 @@ void EnWizFire_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_8012C28C(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); for (i = 9; i >= this->unk_16E; i--) { f32 temp_f20 = this->actor.scale.x - (i * -0.0019f); @@ -742,11 +738,11 @@ void EnWizFire_Draw(Actor* thisx, GlobalContext* globalCtx2) { gDPSetEnvColor(POLY_XLU_DISP++, 220, 255, 235, 0); } - Matrix_InsertTranslation(this->unk_178[i].x, this->unk_178[i].y + this->actor.shape.yOffset, - this->unk_178[i].z, MTXMODE_NEW); + Matrix_Translate(this->unk_178[i].x, this->unk_178[i].y + this->actor.shape.yOffset, this->unk_178[i].z, + MTXMODE_NEW); Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_InsertZRotation_s(this->actor.world.rot.z, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_RotateZS(this->actor.world.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -754,7 +750,7 @@ void EnWizFire_Draw(Actor* thisx, GlobalContext* globalCtx2) { } } - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -771,8 +767,7 @@ void func_80A4BAB4(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight + 20.0f, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight + 20.0f, this->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(this->unk_14C + this->unk_154, this->unk_14C + this->unk_158, this->unk_14C + this->unk_15C, MTXMODE_APPLY); @@ -782,7 +777,7 @@ void func_80A4BAB4(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 100, 50, 0, (s8)this->unk_1FC); gDPSetEnvColor(POLY_XLU_DISP++, 200, 235, 245, 255); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_002630); @@ -865,8 +860,8 @@ void func_80A4BF78(EnWizFire* this, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (ptr->unk_01 * 3) & 0x7F, (ptr->unk_01 * 0xF) & 0xFF, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - Matrix_InsertTranslation(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(ptr->unk_0C, ptr->unk_0C, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.c b/src/overlays/actors/ovl_En_Yb/z_en_yb.c index 724d01710..b23282c31 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -430,10 +430,10 @@ void EnYb_PostLimbDrawOpa(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnYb* this = THIS; if (limbIndex == YB_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_80BFB2F4, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BFB2F4, &this->actor.focus.pos); } if (limbIndex == YB_LIMB_LEGS_ROOT) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->shadowPos); + Matrix_MultVec3f(&gZeroVec3f, &this->shadowPos); } } @@ -441,10 +441,10 @@ void EnYb_PostLimbDrawXlu(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnYb* this = THIS; if (limbIndex == YB_LIMB_HEAD) { - Matrix_MultiplyVector3fByState(&D_80BFB300, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BFB300, &this->actor.focus.pos); } if (limbIndex == YB_LIMB_LEGS_ROOT) { - Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->shadowPos); + Matrix_MultVec3f(&gZeroVec3f, &this->shadowPos); } } diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 95738b211..2c5f76f2e 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -292,15 +292,15 @@ s32 EnZo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, EnZo* this = THIS; if (limbIndex == 15) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->headRot.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + 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); } if (limbIndex == 8) { - Matrix_InsertXRotation_s(-this->upperBodyRot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->upperBodyRot.x, MTXMODE_APPLY); + Matrix_RotateXS(-this->upperBodyRot.y, MTXMODE_APPLY); + Matrix_RotateZS(-this->upperBodyRot.x, MTXMODE_APPLY); } if ((limbIndex == 8) || (limbIndex == 9) || (limbIndex == 12)) { @@ -316,16 +316,16 @@ void EnZo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; if (sBodyParts[limbIndex] >= 0) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->bodyPartsPos[sBodyParts[limbIndex]]); + Matrix_MultVec3f(&zeroVec, &this->bodyPartsPos[sBodyParts[limbIndex]]); } if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&sp30, &this->actor.focus.pos); + Matrix_MultVec3f(&sp30, &this->actor.focus.pos); } if (limbIndex == 4) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->leftFootPos); + Matrix_MultVec3f(&zeroVec, &this->leftFootPos); } if (limbIndex == 7) { - Matrix_MultiplyVector3fByState(&zeroVec, &this->rightFootPos); + Matrix_MultVec3f(&zeroVec, &this->rightFootPos); } } @@ -357,7 +357,7 @@ void EnZo_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnZo_OverrideLimbDraw, EnZo_PostLimbDraw, &this->actor, POLY_OPA_DISP); - Matrix_InsertXRotation_s(0, 0); + Matrix_RotateXS(0, MTXMODE_NEW); for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { *shadowTexIter = 0; diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.c b/src/overlays/actors/ovl_En_Zob/z_en_zob.c index 6e9ddb5c0..24b03ab5f 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.c +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.c @@ -749,7 +749,7 @@ void func_80BA0FAC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnZob* this = THIS; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80BA1120, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BA1120, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Zog/z_en_zog.c b/src/overlays/actors/ovl_En_Zog/z_en_zog.c index 2a990bc26..925eaeec0 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -1003,12 +1003,12 @@ void EnZog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve D_80B959B8.y = 1000.0f; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80B959B8, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B959B8, &this->actor.focus.pos); } D_80B959B8.y = 0.0f; if (limbIndex == 1) { - Matrix_MultiplyVector3fByState(&D_80B959B8, &this->unk_2F0); + Matrix_MultVec3f(&D_80B959B8, &this->unk_2F0); } if ((this->unk_30A & 2) && (limbIndex == 17)) { @@ -1026,12 +1026,12 @@ void func_80B95598(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* D_80B959C4.y = 1000.0f; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80B959C4, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B959C4, &this->actor.focus.pos); } D_80B959C4.y = 0.0f; if (limbIndex == 1) { - Matrix_MultiplyVector3fByState(&D_80B959C4, &this->unk_2F0); + Matrix_MultVec3f(&D_80B959C4, &this->unk_2F0); } if ((this->unk_30A & 2) && (limbIndex == 17)) { diff --git a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c index 61be7c8e7..b65da70e2 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c @@ -682,7 +682,7 @@ void func_80B32F04(Actor* thisx, GlobalContext* globalCtx) { Vec3f sp4C; s32 pad2; - Matrix_StatePush(); + Matrix_Push(); sp4C = GET_ACTIVE_CAM(globalCtx)->eye; @@ -693,14 +693,14 @@ void func_80B32F04(Actor* thisx, GlobalContext* globalCtx) { sp78 = -(15.0f * Math_SinS(sp60)); sp7C = -((15.0f * Math_CosS(sp62)) * Math_CosS(sp60)); - Matrix_InsertTranslation(this->actor.world.pos.x + sp74, this->actor.world.pos.y + sp78 + 6.0f, - temp_f2 = this->actor.world.pos.z + sp7C, 0); + Matrix_Translate(this->actor.world.pos.x + sp74, this->actor.world.pos.y + sp78 + 6.0f, + temp_f2 = this->actor.world.pos.z + sp7C, MTXMODE_NEW); sp7C = Math_SinS(globalCtx->gameplayFrames * 0x4000); Matrix_Scale(this->actor.scale.x * (((sp7C + 1.0f) * 0.1f) + 9.0f), this->actor.scale.y * (((sp7C + 1.0f) * 0.1f) + 9.0f), - this->actor.scale.z * (((sp7C + 1.0f) * 0.1f) + 9.0f), 1); + this->actor.scale.z * (((sp7C + 1.0f) * 0.1f) + 9.0f), MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); gfx = POLY_XLU_DISP; @@ -716,7 +716,7 @@ void func_80B32F04(Actor* thisx, GlobalContext* globalCtx) { POLY_XLU_DISP = gfx; - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -726,7 +726,7 @@ void func_80B331C8(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); Matrix_Scale(this->unk_1E0, this->unk_1E0, this->unk_1E0, MTXMODE_APPLY); @@ -745,7 +745,7 @@ void func_80B331C8(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, object_zoraegg_DL_005250); } - Matrix_StatePop(); + Matrix_Pop(); func_80B32F04(thisx, globalCtx); @@ -773,7 +773,7 @@ s32 EnZoraegg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL } void func_80B333DC(GlobalContext* globalCtx, Gfx** dList, f32 arg2) { - Matrix_StatePush(); + Matrix_Push(); Matrix_Scale(arg2, arg2, arg2, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -781,7 +781,7 @@ void func_80B333DC(GlobalContext* globalCtx, Gfx** dList, f32 arg2) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, *dList); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -796,7 +796,7 @@ void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList switch (limbIndex) { case 2: temp_f20 = this->unk_1EE * 0.01f; - Matrix_StatePush(); + Matrix_Push(); Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -809,7 +809,7 @@ void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList break; case 4: - Matrix_StatePop(); + Matrix_Pop(); break; case 5: @@ -824,7 +824,7 @@ void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList switch (limbIndex) { case 2: temp_f20 = (this->unk_1EE * 0.005f) + 0.5f; - Matrix_StatePush(); + Matrix_Push(); Matrix_Scale(1.0f, temp_f20, temp_f20, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -849,7 +849,7 @@ void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList CLOSE_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePop(); + Matrix_Pop(); break; case 5: diff --git a/src/overlays/actors/ovl_En_Zos/z_en_zos.c b/src/overlays/actors/ovl_En_Zos/z_en_zos.c index 419d3325e..0f299f255 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.c +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.c @@ -693,7 +693,7 @@ void func_80BBC500(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* static Vec3f D_80BBC750 = { 0.0f, 0.0f, 0.0f }; if (limbIndex == 9) { - Matrix_MultiplyVector3fByState(&D_80BBC750, &thisx->focus.pos); + Matrix_MultVec3f(&D_80BBC750, &thisx->focus.pos); } } @@ -718,9 +718,9 @@ void EnZos_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(&gfx[0], 0x08, Lib_SegmentedToVirtual(D_80BBC75C[this->unk_2AC])); - Matrix_StatePush(); - Matrix_RotateY(this->actor.home.rot.y - this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -974.4f, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateYS(this->actor.home.rot.y - this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -974.4f, MTXMODE_APPLY); gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[2], object_zos_DL_0136E0); @@ -728,7 +728,7 @@ void EnZos_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = &gfx[4]; - Matrix_StatePop(); + Matrix_Pop(); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, func_80BBC4E4, func_80BBC500, &this->actor); diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index bfab9fcf6..1cf8ad992 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -1356,15 +1356,15 @@ s32 EnZot_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, s32 pad; if (limbIndex == 15) { - Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_2C4.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2C4.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2C4.y, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2C4.x, MTXMODE_APPLY); + Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } if (limbIndex == 8) { - Matrix_InsertXRotation_s(this->unk_2CA.y * -1, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_2CA.x * -1, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_2CA.y * -1, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_2CA.x * -1, MTXMODE_APPLY); } if (((this->unk_2F0 == 8) || (this->unk_2F0 == 9)) && @@ -1380,7 +1380,7 @@ void EnZot_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnZot* this = THIS; if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&D_80B99934, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80B99934, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.c b/src/overlays/actors/ovl_En_Zov/z_en_zov.c index f593709cf..4bb5f2a5a 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.c +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.c @@ -535,17 +535,17 @@ void EnZov_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve EnZov* this = THIS; if (limbIndex == 12) { - Matrix_MultiplyVector3fByState(&D_80BD2744, &this->actor.focus.pos); + Matrix_MultVec3f(&D_80BD2744, &this->actor.focus.pos); Math_Vec3f_Copy(&this->unk_2FC, &this->actor.focus.pos); this->unk_2FC.y += 10.0f; } if (limbIndex == 18) { - Matrix_MultiplyVector3fByState(&D_80BD2750, &this->unk_308); + Matrix_MultVec3f(&D_80BD2750, &this->unk_308); } if (limbIndex == 13) { - Matrix_MultiplyVector3fByState(&D_80BD2750, &this->unk_314); + Matrix_MultVec3f(&D_80BD2750, &this->unk_314); } } diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.c b/src/overlays/actors/ovl_En_Zow/z_en_zow.c index ff258fc20..d29141499 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -196,7 +196,7 @@ void func_80BDC830(EnZowStruct* ptr, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, ptr->unk_0F); - Matrix_InsertTranslation(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_Translate(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_04, 1.0f, ptr->unk_04, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -227,8 +227,8 @@ void func_80BDC9DC(EnZowStruct* ptr, GlobalContext* globalCtx) { flag = true; } - Matrix_InsertTranslation(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(ptr->unk_04, ptr->unk_04, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -260,8 +260,8 @@ void func_80BDCB84(EnZowStruct* ptr, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 180, 180, 180, ptr->unk_0F); - Matrix_InsertTranslation(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Translate(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(ptr->unk_04, ptr->unk_04, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -294,8 +294,8 @@ void func_80BDCDA8(EnZow* this, EnZowStruct* ptr) { temp_f22 = Rand_ZeroOne() * 6.28f; sp78.y = (Rand_ZeroOne() * 3.0f) + 3.0f; - sp78.x = __sinf(temp_f22) * temp_f20; - sp78.z = __cosf(temp_f22) * temp_f20; + sp78.x = sinf(temp_f22) * temp_f20; + sp78.z = cosf(temp_f22) * temp_f20; sp84 = this->actor.world.pos; sp84.x += sp78.x * 6.0f; @@ -603,7 +603,7 @@ Vec3f D_80BDDD4C = { 400.0f, 0.0f, 0.0f }; void func_80BDDAA0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { if (limbIndex == 15) { - Matrix_MultiplyVector3fByState(&D_80BDDD4C, &thisx->focus.pos); + Matrix_MultVec3f(&D_80BDDD4C, &thisx->focus.pos); } } @@ -619,13 +619,13 @@ void EnZow_Draw(Actor* thisx, GlobalContext* globalCtx) { }; EnZow* this = THIS; - Matrix_StatePush(); + Matrix_Push(); func_80BDC830(this->unk_2D0, globalCtx); func_80BDC9DC(this->unk_2D0, globalCtx); func_80BDCB84(this->unk_2D0, globalCtx); - Matrix_StatePop(); + Matrix_Pop(); if (this->unk_2CE != 0) { OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c index c6de60ce2..eee9de294 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c @@ -399,9 +399,9 @@ void MirRay_SetIntensity(MirRay* this, GlobalContext* globalCtx) { this->reflectIntensity = 0.0f; - if (MirRay_CheckInFrustum(&this->sourcePt, &this->poolPt, shieldMtx->wx, shieldMtx->wy, shieldMtx->wz, + if (MirRay_CheckInFrustum(&this->sourcePt, &this->poolPt, shieldMtx->xw, shieldMtx->yw, shieldMtx->zw, this->sourceEndRad, this->poolEndRad)) { - temp_f0 = sqrtf(SQ(shieldMtx->zz) + (SQ(shieldMtx->zx) + SQ(shieldMtx->zy))); + temp_f0 = sqrtf(SQ(shieldMtx->zz) + (SQ(shieldMtx->xz) + SQ(shieldMtx->yz))); if (temp_f0 == 0.0f) { this->reflectRange = 1.0f; } else { @@ -415,7 +415,7 @@ void MirRay_SetIntensity(MirRay* this, GlobalContext* globalCtx) { sp4C[1] = this->poolPt.y - this->sourcePt.y; sp4C[2] = this->poolPt.z - this->sourcePt.z; - temp_f2 = (-shieldMtx->zx * sp4C[0]) - (shieldMtx->zy * sp4C[1]) - (shieldMtx->zz * sp4C[2]); + temp_f2 = (-shieldMtx->xz * sp4C[0]) - (shieldMtx->yz * sp4C[1]) - (shieldMtx->zz * sp4C[2]); if (temp_f2 < 0.0f) { temp_f0_2 = sqrtf(SQ(sp4C[0]) + SQ(sp4C[1]) + SQ(sp4C[2])); @@ -439,17 +439,17 @@ void MirRay_SetupReflectionPolys(MirRay* this, GlobalContext* globalCtx, MirRayS CollisionPoly* outPoly; f32 sp60[3]; - sp60[0] = -(shieldMtx->zx * this->reflectRange) * this->reflectIntensity * 400.0f; - sp60[1] = -(shieldMtx->zy * this->reflectRange) * this->reflectIntensity * 400.0f; + sp60[0] = -(shieldMtx->xz * this->reflectRange) * this->reflectIntensity * 400.0f; + sp60[1] = -(shieldMtx->yz * this->reflectRange) * this->reflectIntensity * 400.0f; sp60[2] = -(shieldMtx->zz * this->reflectRange) * this->reflectIntensity * 400.0f; for (i = 0; i < ARRAY_COUNT(this->shieldCorners); i++) { posA.x = - (shieldMtx->wx + (this->shieldCorners[i].x * shieldMtx->xx)) + (this->shieldCorners[i].y * (*shieldMtx).yx); + (shieldMtx->xw + (this->shieldCorners[i].x * shieldMtx->xx)) + (this->shieldCorners[i].y * (*shieldMtx).xy); posA.y = - (shieldMtx->wy + (this->shieldCorners[i].x * shieldMtx->xy)) + (this->shieldCorners[i].y * (*shieldMtx).yy); + (shieldMtx->yw + (this->shieldCorners[i].x * shieldMtx->yx)) + (this->shieldCorners[i].y * (*shieldMtx).yy); posA.z = - (shieldMtx->wz + (this->shieldCorners[i].x * shieldMtx->xz)) + (this->shieldCorners[i].y * (*shieldMtx).yz); + (shieldMtx->zw + (this->shieldCorners[i].x * shieldMtx->zx)) + (this->shieldCorners[i].y * (*shieldMtx).zy); posB.x = sp60[0] + posA.x; posB.y = sp60[1] + posA.y; @@ -501,25 +501,25 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe Vec3f vecA; Vec3f vecC; - spE8[0] = -(shieldMtx->zx * this->reflectRange) * this->reflectIntensity * 400.0f; - spE8[1] = -(shieldMtx->zy * this->reflectRange) * this->reflectIntensity * 400.0f; + spE8[0] = -(shieldMtx->xz * this->reflectRange) * this->reflectIntensity * 400.0f; + spE8[1] = -(shieldMtx->yz * this->reflectRange) * this->reflectIntensity * 400.0f; spE8[2] = -(shieldMtx->zz * this->reflectRange) * this->reflectIntensity * 400.0f; - vecB.x = shieldMtx->wx; - vecB.y = shieldMtx->wy; - vecB.z = shieldMtx->wz; + vecB.x = shieldMtx->xw; + vecB.y = shieldMtx->yw; + vecB.z = shieldMtx->zw; vecD.x = spE8[0] + vecB.x; vecD.y = spE8[1] + vecB.y; vecD.z = spE8[2] + vecB.z; vecA.x = vecB.x + (shieldMtx->xx * 300.0f); - vecA.y = vecB.y + (shieldMtx->xy * 300.0f); - vecA.z = vecB.z + (shieldMtx->xz * 300.0f); + vecA.y = vecB.y + (shieldMtx->yx * 300.0f); + vecA.z = vecB.z + (shieldMtx->zx * 300.0f); vecC.x = vecD.x + (shieldMtx->xx * 300.0f); - vecC.y = vecD.y + (shieldMtx->xy * 300.0f); - vecC.z = vecD.z + (shieldMtx->xz * 300.0f); + vecC.y = vecD.y + (shieldMtx->yx * 300.0f); + vecC.z = vecD.z + (shieldMtx->zx * 300.0f); Collider_SetQuadVertices(&this->collider2, &vecA, &vecB, &vecC, &vecD); @@ -547,8 +547,8 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe reflection[i].opacity = (s32)(reflection[i].opacity * 1.275f); sp10C.x = (shieldMtx->xx * 100.0f) + vecB.x; - sp10C.y = (shieldMtx->xy * 100.0f) + vecB.y; - sp10C.z = (shieldMtx->xz * 100.0f) + vecB.z; + sp10C.y = (shieldMtx->yx * 100.0f) + vecB.y; + sp10C.z = (shieldMtx->zx * 100.0f) + vecB.z; sp100.x = (spE8[0] * 4.0f) + sp10C.x; sp100.y = (spE8[1] * 4.0f) + sp10C.y; @@ -556,21 +556,21 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe reflection[i].mtx.xx = reflection[i].mtx.yy = reflection[i].mtx.zz = reflection[i].mtx.ww = 1.0f; - reflection[i].mtx.xy = reflection[i].mtx.xz = reflection[i].mtx.xw = reflection[i].mtx.yx = - reflection[i].mtx.yz = reflection[i].mtx.yw = reflection[i].mtx.zx = reflection[i].mtx.zy = - reflection[i].mtx.zw = reflection[i].mtx.wx = reflection[i].mtx.wy = reflection[i].mtx.wz = + reflection[i].mtx.yx = reflection[i].mtx.zx = reflection[i].mtx.wx = reflection[i].mtx.xy = + reflection[i].mtx.zy = reflection[i].mtx.wy = reflection[i].mtx.xz = reflection[i].mtx.yz = + reflection[i].mtx.wz = reflection[i].mtx.xw = reflection[i].mtx.yw = reflection[i].mtx.zw = 0.0f; if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], reflection[i].reflectionPoly->dist, &sp10C, &sp100, &intersection, 1)) { reflection[i].mtx.xx = intersection.x - sp118.x; - reflection[i].mtx.xy = intersection.y - sp118.y; - reflection[i].mtx.xz = intersection.z - sp118.z; + reflection[i].mtx.yx = intersection.y - sp118.y; + reflection[i].mtx.zx = intersection.z - sp118.z; } - sp10C.x = (shieldMtx->yx * 100.0f) + vecB.x; + sp10C.x = (shieldMtx->xy * 100.0f) + vecB.x; sp10C.y = (shieldMtx->yy * 100.0f) + vecB.y; - sp10C.z = (shieldMtx->yz * 100.0f) + vecB.z; + sp10C.z = (shieldMtx->zy * 100.0f) + vecB.z; sp100.x = (spE8[0] * 4.0f) + sp10C.x; sp100.y = (spE8[1] * 4.0f) + sp10C.y; @@ -578,9 +578,9 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], reflection[i].reflectionPoly->dist, &sp10C, &sp100, &intersection, 1)) { - reflection[i].mtx.yx = intersection.x - sp118.x; + reflection[i].mtx.xy = intersection.x - sp118.x; reflection[i].mtx.yy = intersection.y - sp118.y; - reflection[i].mtx.yz = intersection.z - sp118.z; + reflection[i].mtx.zy = intersection.z - sp118.z; } } else { reflection[i].reflectionPoly = NULL; @@ -603,7 +603,7 @@ void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx) { this->reflectIntensity = 0.0f; if (!D_808E3BF0 && !this->unLit && func_80124088(globalCtx)) { - Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); + Matrix_Mult(&player->shieldMf, MTXMODE_NEW); MirRay_SetIntensity(this, globalCtx); if (this->reflectIntensity <= 0.0f) { @@ -640,9 +640,9 @@ void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(reflection); i++) { if (reflection[i].reflectionPoly != NULL) { - Matrix_InsertTranslation(reflection[i].pos.x, reflection[i].pos.y, reflection[i].pos.z, MTXMODE_NEW); + Matrix_Translate(reflection[i].pos.x, reflection[i].pos.y, reflection[i].pos.z, MTXMODE_NEW); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); - Matrix_InsertMatrix(&reflection[i].mtx, MTXMODE_APPLY); + Matrix_Mult(&reflection[i].mtx, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c index 1382e3d1b..f5209c392 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c @@ -354,7 +354,7 @@ void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx) { u16 time; if (!(this->unk_210 & 1) && func_8012405C(globalCtx)) { - Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); + Matrix_Mult(&player->shieldMf, MTXMODE_NEW); func_80B9E544(this, globalCtx); if (this->unk_214 <= 0.1f) { @@ -406,9 +406,9 @@ void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(sp8C); i++) { if (sp8C[i].unk_4C != NULL) { - Matrix_InsertTranslation(sp8C[i].unk_00.x, sp8C[i].unk_00.y, sp8C[i].unk_00.z, MTXMODE_NEW); + Matrix_Translate(sp8C[i].unk_00.x, sp8C[i].unk_00.y, sp8C[i].unk_00.z, MTXMODE_NEW); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); - Matrix_InsertMatrix(&sp8C[i].unk_0C, MTXMODE_APPLY); + Matrix_Mult(&sp8C[i].unk_0C, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c index 5237d9021..97865650d 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c @@ -123,7 +123,7 @@ void func_80ACBA10(ObjAqua* this) { func_800C0094(this->actor.floorPoly, this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, &sp2C); - func_8018219C(&sp2C, &this->actor.shape.rot, 0); + Matrix_MtxFToYXZRot(&sp2C, &this->actor.shape.rot, false); } s32 func_80ACBA60(ObjAqua* this, GlobalContext* globalCtx) { @@ -284,12 +284,12 @@ void ObjAqua_Draw(Actor* thisx, GlobalContext* globalCtx) { if (actionFuncTemp) { s16 rotation = Math_SinS(this->unk_198) * 8000.0f; - Matrix_InsertZRotation_s(rotation, MTXMODE_APPLY); + Matrix_RotateZS(rotation, MTXMODE_APPLY); Matrix_Scale(1.3f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(rotation * -1, MTXMODE_APPLY); + Matrix_RotateZS(rotation * -1, MTXMODE_APPLY); Matrix_Scale(10.0f / 13.0f, 1.0f, 1.0f, MTXMODE_APPLY); } - Matrix_RotateY(yaw, MTXMODE_APPLY); + Matrix_RotateYS(yaw, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c index 998e85d68..3e72b809e 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c @@ -346,9 +346,9 @@ void func_809A5960(ObjArmos* this, GlobalContext* globalCtx) { Vec3f sp28; sp28.x = Math_SinS(this->dyna.actor.shape.rot.y); - Matrix_SetStateRotationAndTranslation( - (sp28.x * -9.0f) + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - (Math_CosS(this->dyna.actor.shape.rot.y) * -9.0f) + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ((sp28.x * -9.0f) + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + (Math_CosS(this->dyna.actor.shape.rot.y) * -9.0f) + this->dyna.actor.world.pos.z, + &this->dyna.actor.shape.rot); Matrix_Scale(0.014f, 0.014f, 0.014f, MTXMODE_APPLY); func_8012C28C(globalCtx->state.gfxCtx); @@ -374,7 +374,7 @@ void func_809A5A3C(ObjArmos* this, GlobalContext* globalCtx) { func_800C0094(this->dyna.actor.floorPoly, this->unk_250.x, this->dyna.actor.floorHeight, this->unk_250.z, &sp48); - Matrix_SetCurrentState(&sp48); + Matrix_Put(&sp48); Matrix_Scale(0.6f, 1.0f, 0.6f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c index a02f7f604..3ee4be021 100644 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c @@ -140,10 +140,10 @@ s32 func_80936D58(ObjBean* this, GlobalContext* globalCtx) { Vec3f sp88; MtxF sp48; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&D_80939018, &spAC); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultVec3f(&D_80939018, &spAC); Math_Vec3f_Sum(&this->dyna.actor.world.pos, &spAC, &spA0); Math_Vec3f_Diff(&this->dyna.actor.world.pos, &spAC, &sp94); @@ -154,10 +154,10 @@ s32 func_80936D58(ObjBean* this, GlobalContext* globalCtx) { this->dyna.actor.world.pos.z = (COLPOLY_GET_NORMAL(this->dyna.actor.floorPoly->normal.z) * 1.9f) + sp88.z; func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, &sp48); - Matrix_SetCurrentState(&sp48); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_CopyCurrentState(&sp48); - func_8018219C(&sp48, &this->dyna.actor.shape.rot, 0); + Matrix_Put(&sp48); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Get(&sp48); + Matrix_MtxFToYXZRot(&sp48, &this->dyna.actor.shape.rot, false); return true; } return false; @@ -948,8 +948,8 @@ void func_80938E00(Actor* thisx, GlobalContext* globalCtx) { } if (this->unk_1FE & 1) { - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_Scale(this->unk_1B8, this->unk_1B8, this->unk_1B8, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c index 14e25c57d..602311116 100644 --- a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c +++ b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c @@ -213,13 +213,13 @@ void func_80A358FC(ObjBell* this, GlobalContext* globalCtx) { } void func_80A359B4(Actor* thisx, GlobalContext* globalCtx) { - Matrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); + Matrix_Translate(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 2600.0f, 0.0f, MTXMODE_APPLY); - Matrix_RotateY(thisx->world.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(thisx->world.rot.x, MTXMODE_APPLY); - Matrix_RotateY(-thisx->world.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -2600.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 2600.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateYS(thisx->world.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(thisx->world.rot.x, MTXMODE_APPLY); + Matrix_RotateYS(-thisx->world.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, -2600.0f, 0.0f, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -231,9 +231,9 @@ void func_80A359B4(Actor* thisx, GlobalContext* globalCtx) { } void func_80A35B18(Actor* thisx, GlobalContext* globalCtx) { - Matrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); + Matrix_Translate(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, MTXMODE_NEW); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); - Matrix_RotateY(thisx->shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(thisx->shape.rot.y, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -242,7 +242,7 @@ void func_80A35B18(Actor* thisx, GlobalContext* globalCtx) { } void func_80A35BD4(Actor* thisx, GlobalContext* globalCtx) { - Matrix_InsertTranslation(thisx->world.pos.x, thisx->world.pos.y - 4.0f, thisx->world.pos.z, MTXMODE_NEW); + Matrix_Translate(thisx->world.pos.x, thisx->world.pos.y - 4.0f, thisx->world.pos.z, MTXMODE_NEW); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); @@ -290,9 +290,9 @@ void ObjBell_Draw(Actor* thisx, GlobalContext* globalCtx) { func_80A35BD4(thisx, globalCtx); func_80A359B4(thisx, globalCtx); Math_Vec3s_ToVec3f(&sp30, &this->collider1.dim.modelSphere.center); - Matrix_MultiplyVector3fByState(&sp30, &sp24); + Matrix_MultVec3f(&sp30, &sp24); Math_Vec3f_ToVec3s(&this->collider1.dim.worldSphere.center, &sp24); Math_Vec3s_ToVec3f(&sp30, &this->collider2.dim.modelSphere.center); - Matrix_MultiplyVector3fByState(&sp30, &sp24); + Matrix_MultVec3f(&sp30, &sp24); Math_Vec3f_ToVec3s(&this->collider2.dim.worldSphere.center, &sp24); } diff --git a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c index 8a09c6f01..55304d195 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c @@ -516,7 +516,7 @@ void func_8093A608(Actor* thisx, GlobalContext* globalCtx) { ptr = &this->unk_190[i]; if (ptr->unk_1A == 0) { - Matrix_SetStateRotationAndTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, &ptr->unk_14); + Matrix_SetTranslateRotateYXZ(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, &ptr->unk_14); Matrix_Scale(ptr->unk_00, ptr->unk_00, ptr->unk_00, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c index e058ec7c4..c90e5d8f8 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -137,11 +137,11 @@ void ObjChan_CalculatePotPosition(Vec3f* childPosOut, Vec3s* childRotOut, Vec3f* s16 childAngle) { Vec3f offset; - Matrix_RotateY(parentRot->y, MTXMODE_NEW); - Matrix_InsertXRotation_s(parentRot->x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(parentRot->z, MTXMODE_APPLY); - Matrix_RotateY(childAngle, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledX(-280.0f, &offset); + Matrix_RotateYS(parentRot->y, MTXMODE_NEW); + Matrix_RotateXS(parentRot->x, MTXMODE_APPLY); + Matrix_RotateZS(parentRot->z, MTXMODE_APPLY); + Matrix_RotateYS(childAngle, MTXMODE_APPLY); + Matrix_MultVecX(-280.0f, &offset); childPosOut->x = parentPos->x + offset.x; childPosOut->y = parentPos->y + offset.y; @@ -239,11 +239,11 @@ void ObjChan_ChandelierAction(ObjChan* this2, GlobalContext* globalCtx) { this->stateFlags &= ~OBJCHAN_STATE_CUTSCENE; ActorCutscene_Stop(this->cutscenes[0]); } - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_RotateY(this->rotation, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledY(this->unk1CC, &this->actor.world.pos); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->rotation, MTXMODE_APPLY); + Matrix_MultVecY(this->unk1CC, &this->actor.world.pos); Math_Vec3f_Sum(&this->actor.world.pos, &this->unk1C0, &this->actor.world.pos); Collider_UpdateCylinder(&this->actor, &this->collider); for (i = 0; i < 5; i++) { @@ -373,7 +373,7 @@ void ObjChan_Draw(Actor* thisx, GlobalContext* globalCtx) { Gfx* xlu; OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_RotateY(this->rotation, MTXMODE_APPLY); + Matrix_RotateYS(this->rotation, MTXMODE_APPLY); opa = Gfx_CallSetupDL(POLY_OPA_DISP, 0x19); gSPMatrix(&opa[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); @@ -387,11 +387,11 @@ void ObjChan_Draw(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - Matrix_StatePush(); + Matrix_Push(); if (this->stateFlags & OBJCHAN_STATE_ON_FIRE) { ObjChan_DrawFire(this, globalCtx); } - Matrix_StatePop(); + Matrix_Pop(); } void ObjChan_DrawPot(Actor* thisx, GlobalContext* globalCtx) { @@ -418,11 +418,11 @@ void ObjChan_DrawFire(ObjChan* this, GlobalContext* globalCtx) { sp4C = globalCtx->gameplayFrames; - Matrix_RotateY(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y - this->rotation + 0x8000, - MTXMODE_APPLY); + Matrix_RotateYS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y - this->rotation + 0x8000, + MTXMODE_APPLY); Matrix_Scale(sObjChanFlameSize[OBJCHAN_SUBTYPE(&this->actor)].x * this->flameSize, sObjChanFlameSize[OBJCHAN_SUBTYPE(&this->actor)].y * this->flameSize, 1.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, sObjChanFlameYOffset[OBJCHAN_SUBTYPE(&this->actor)], 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, sObjChanFlameYOffset[OBJCHAN_SUBTYPE(&this->actor)], 0.0f, MTXMODE_APPLY); dl = func_8012C2B4(POLY_XLU_DISP); gSPMatrix(&dl[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); diff --git a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c index 573b34fdc..737f9ef46 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c @@ -554,12 +554,12 @@ void ObjComb_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + (118.0f * this->actor.scale.y), - this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -(this->actor.scale.y * 118.0f), 0.0f, MTXMODE_APPLY); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + (118.0f * this->actor.scale.y), + this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Translate(0.0f, -(this->actor.scale.y * 118.0f), 0.0f, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c index bec773c2f..c6eef8626 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c @@ -241,8 +241,8 @@ void func_80B12E7C(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* Vec3f sp88; ObjDhouseStruct2* ptr2; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); - Matrix_MultiplyVector3fXZByCurrentState(&D_80B13FC4, &sp94); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3fXZ(&D_80B13FC4, &sp94); sp94.y = 100.0f; func_80B12A50(ptr, ptr3, &spA0); @@ -511,9 +511,9 @@ void func_80B13C08(Actor* thisx, GlobalContext* globalCtx) { for (i = 0, ptr = &this->unk_160[0], ptr3 = &D_80B13E90[0]; i < ARRAY_COUNT(this->unk_160); i++, ptr3++, ptr++) { if (ptr->unk_1E >= 0) { - Matrix_SetStateRotationAndTranslation(ptr->unk_00.x + ptr3->unk_08.x, ptr->unk_00.y + ptr3->unk_08.y, - ptr->unk_00.z + ptr3->unk_08.z, &ptr->unk_18); - Matrix_InsertTranslation(-ptr3->unk_08.x, -ptr3->unk_08.y, -ptr3->unk_08.z, MTXMODE_APPLY); + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x + ptr3->unk_08.x, ptr->unk_00.y + ptr3->unk_08.y, + ptr->unk_00.z + ptr3->unk_08.z, &ptr->unk_18); + Matrix_Translate(-ptr3->unk_08.x, -ptr3->unk_08.y, -ptr3->unk_08.z, MTXMODE_APPLY); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), @@ -525,7 +525,7 @@ void func_80B13C08(Actor* thisx, GlobalContext* globalCtx) { for (i = 0, ptr2 = &this->unk_240[0]; i < ARRAY_COUNT(this->unk_240); i++, ptr2++) { if (ptr2->unk_28 > 0) { - Matrix_SetStateRotationAndTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &ptr2->unk_1C); + Matrix_SetTranslateRotateYXZ(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &ptr2->unk_1C); Matrix_Scale(ptr2->unk_18, ptr2->unk_18, ptr2->unk_18, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c index a1d149f3d..163dd851d 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c @@ -193,13 +193,13 @@ void ObjDora_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTrisElements); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - &this->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { for (j = 0; j < ARRAY_COUNT(vtx); j++) { - Matrix_MultiplyVector3fByState(&sTrisElementsInit[i].dim.vtx[j], &vtx[j]); + Matrix_MultVec3f(&sTrisElementsInit[i].dim.vtx[j], &vtx[j]); } Collider_SetTrisVertices(&this->colliderTris, i, &vtx[0], &vtx[1], &vtx[2]); } @@ -329,19 +329,19 @@ void ObjDora_Draw(Actor* thisx, GlobalContext* globalCtx) { gongForceX *= -1.0f; } - Matrix_StatePush(); - Matrix_InsertXRotation_s(this->gongRotation.x, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateXS(this->gongRotation.x, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, &gDoraGongDL); - Matrix_InsertTranslation(position.x, position.y + gongForceX, position.z + gongForceX, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->gongRotation.z - this->gongRotation.x, MTXMODE_APPLY); - Matrix_InsertTranslation(-position.x, -position.y, -position.z, MTXMODE_APPLY); + Matrix_Translate(position.x, position.y + gongForceX, position.z + gongForceX, MTXMODE_APPLY); + Matrix_RotateXS(this->gongRotation.z - this->gongRotation.x, MTXMODE_APPLY); + Matrix_Translate(-position.x, -position.y, -position.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, &gDoraChainDL); - Matrix_StatePop(); + Matrix_Pop(); } else { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, &gDoraChainDL); diff --git a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c index 8ed237927..7d662432a 100644 --- a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c +++ b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c @@ -97,9 +97,9 @@ void func_80A349C0(ObjEntotu* this) { } void func_80A34A44(ObjEntotu* this, GlobalContext* globalCtx) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -129,10 +129,9 @@ void func_80A34B28(ObjEntotu* this, GlobalContext* globalCtx) { } if (this->unk_1B8.x > 0.0f) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c index 16ac7e8e9..57964559d 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -176,7 +176,7 @@ void func_80A1B3D0(void) { } void func_80A1B840(MtxF* matrix) { - MtxF* temp = Matrix_GetCurrentState(); + MtxF* temp = Matrix_GetCurrent(); f32* tmp = (f32*)&temp->mf[0]; f32* tmp2 = (f32*)&matrix->mf[0]; s32 i; @@ -208,9 +208,9 @@ void func_80A1B9CC(ObjFlowerpot* this, GlobalContext* globalCtx) { } void func_80A1BA04(ObjFlowerpot* this, Vec3f* arg1) { - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - &this->actor.shape.rot); - Matrix_MultiplyVector3fByState(&D_80A1D408, arg1); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_MultVec3f(&D_80A1D408, arg1); } void func_80A1BA44(ObjFlowerpot* this, GlobalContext* globalCtx) { @@ -404,8 +404,8 @@ void ObjFlowerpot_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitJntSph(globalCtx, &this->collider); Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); - Matrix_SetStateRotationAndTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, - &this->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, + &this->actor.shape.rot); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); Collider_UpdateSpheres(1, &this->collider); diff --git a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c index 2ec24e73e..7bdaa8654 100644 --- a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c +++ b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c @@ -35,7 +35,7 @@ void ObjFunen_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - 0x8000), MTXMODE_APPLY); + Matrix_RotateYS((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - 0x8000), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH); diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c index d95cc0631..51f2febc7 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c @@ -86,7 +86,7 @@ s32 func_809A9110(GlobalContext* globalCtx, Vec3f* arg1) { void func_809A91FC(MtxF* matrix) { s32 i; - MtxF* temp = Matrix_GetCurrentState(); + MtxF* temp = Matrix_GetCurrent(); f32* tmp = &temp->xx; f32* tmp2 = &matrix->xx; @@ -457,7 +457,7 @@ void func_809AA54C(Actor* thisx, GlobalContext* globalCtx2) { if ((ptr2->unk_0F & 1) && (ptr2->unk_10 == 255)) { sp70.y = ptr2->unk_0C; - Matrix_SetStateRotationAndTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp70); + Matrix_SetTranslateRotateYXZ(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp70); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (ptr2->unk_0F & 2) { func_809A91FC(&this->unk_2F88[j]); @@ -497,7 +497,7 @@ void func_809AA798(Actor* thisx, GlobalContext* globalCtx) { if ((ptr2->unk_0F & 1) && (ptr2->unk_10 > 0) && (ptr2->unk_10 < 255)) { sp6C.y = ptr2->unk_0C; - Matrix_SetStateRotationAndTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp6C); + Matrix_SetTranslateRotateYXZ(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp6C); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c index 4b96d3a77..d3199e8d8 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c @@ -131,19 +131,19 @@ void ObjHakaisi_Init(Actor* thisx, GlobalContext* globalCtx) { func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, this->dyna.actor.world.pos.z, &sp3C); - Matrix_SetCurrentState(&sp3C); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Put(&sp3C); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&sp3C); - func_8018219C(&sp3C, &this->dyna.actor.shape.rot, 1); + Matrix_Get(&sp3C); + Matrix_MtxFToYXZRot(&sp3C, &this->dyna.actor.shape.rot, true); this->dyna.actor.world.rot = this->dyna.actor.shape.rot; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&D_80B155B0, &this->dyna.actor.focus.pos); + Matrix_MultVec3f(&D_80B155B0, &this->dyna.actor.focus.pos); for (i = 0; i < ARRAY_COUNT(D_80B155BC); i++) { - Matrix_MultiplyVector3fByState(&D_80B155BC[i], &this->unk_160[i]); + Matrix_MultVec3f(&D_80B155BC[i], &this->unk_160[i]); } func_80B1444C(this); @@ -386,8 +386,8 @@ void func_80B15264(ObjHakaisi* this) { s32 pad; s16 sp32 = Rand_Next(); - Matrix_InsertRotation(Rand_Next(), Rand_Next(), Rand_Next(), MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&D_80B15600, &this->unk_184); + Matrix_RotateZYX(Rand_Next(), Rand_Next(), Rand_Next(), MTXMODE_NEW); + Matrix_MultVec3f(&D_80B15600, &this->unk_184); this->dyna.actor.gravity = -1.0f; this->unk_19C = Rand_Next() >> 0x12; this->dyna.actor.velocity.x = Math_SinS(sp32) * 4.0f; @@ -409,13 +409,13 @@ void func_80B15330(ObjHakaisi* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->dyna.actor); } - Matrix_InsertRotationAroundUnitVector_s(this->unk_19C, &this->unk_184, MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&sp34); + Matrix_RotateAxisS(this->unk_19C, &this->unk_184, MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&sp34); - func_8018219C(&sp34, &this->dyna.actor.shape.rot, 0); + Matrix_MtxFToYXZRot(&sp34, &this->dyna.actor.shape.rot, false); } void func_80B1544C(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c index f07b9c6d4..840488810 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c @@ -91,14 +91,14 @@ void ObjHariko_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_StatePush(); - Matrix_InsertXRotation_s(this->headRotation.x, MTXMODE_APPLY); - Matrix_RotateY(this->headRotation.y, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateXS(this->headRotation.x, MTXMODE_APPLY); + Matrix_RotateYS(this->headRotation.y, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gHarikoBodyDL); gSPDisplayList(POLY_OPA_DISP++, gHarikoFaceDL); - Matrix_StatePop(); + Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c index 06293bf40..3fc7f84b1 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -439,8 +439,8 @@ void func_80A54E10(ObjHugebombiwa* this) { s32 pad; Vec3f sp84; - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); for (i = 0, phi_s2 = 0x1000; i < 20; i++, phi_s2 += 0x4000) { ptr = &this->unk_190[i]; @@ -455,7 +455,7 @@ void func_80A54E10(ObjHugebombiwa* this) { sp84.y = (i + 1) * 10.0f; sp84.z = fabsf(Math_CosS(phi_s2)) * temp_f20_2; - Matrix_MultiplyVector3fByState(&sp84, &ptr->unk_0C); + Matrix_MultVec3f(&sp84, &ptr->unk_0C); ptr->unk_0C.x += this->actor.world.pos.x; ptr->unk_0C.y += this->actor.world.pos.y; @@ -471,7 +471,7 @@ void func_80A54E10(ObjHugebombiwa* this) { this->unk_4B0 = 0; this->unk_4B2 = 100; - Matrix_StatePop(); + Matrix_Pop(); this->actionFunc = func_80A55064; } @@ -534,8 +534,8 @@ void func_80A55310(ObjHugebombiwa* this) { s16 phi_s2; Vec3f sp84; - Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_Push(); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); for (i = 0, phi_s2 = 0x1000; i < ARRAY_COUNT(this->unk_190); i++, phi_s2 += 0x4000) { ptr = &this->unk_190[i]; @@ -549,7 +549,7 @@ void func_80A55310(ObjHugebombiwa* this) { sp84.x = Math_SinS(phi_s2) * temp_f20_2; sp84.y = (i + 1) * 14.0f; sp84.z = fabsf(Math_CosS(phi_s2)) * temp_f20_2; - Matrix_MultiplyVector3fByState(&sp84, &ptr->unk_0C); + Matrix_MultVec3f(&sp84, &ptr->unk_0C); ptr->unk_0C.x += this->actor.world.pos.x; ptr->unk_0C.y += this->actor.world.pos.y; @@ -567,7 +567,7 @@ void func_80A55310(ObjHugebombiwa* this) { this->unk_4B0 = 0; this->unk_4B2 = 100; - Matrix_StatePop(); + Matrix_Pop(); this->actionFunc = func_80A55564; } @@ -671,7 +671,7 @@ void ObjHugebombiwa_Draw(Actor* thisx, GlobalContext* globalCtx) { ptr = &this->unk_190[i]; if (ptr->unk_24 == 0) { - Matrix_SetStateRotationAndTranslation(ptr->unk_0C.x, ptr->unk_0C.y, ptr->unk_0C.z, &ptr->unk_1C); + Matrix_SetTranslateRotateYXZ(ptr->unk_0C.x, ptr->unk_0C.y, ptr->unk_0C.z, &ptr->unk_1C); Matrix_Scale(ptr->unk_00.x, ptr->unk_00.x, ptr->unk_00.x, MTXMODE_APPLY); gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -708,10 +708,10 @@ void func_80A55B34(Actor* thisx, GlobalContext* globalCtx) { continue; } - Matrix_SetStateRotationAndTranslation(ptr->unk_0C.x, ptr->unk_0C.y + (325.0f * ptr->unk_00.y), ptr->unk_0C.z, - &ptr->unk_1C); + Matrix_SetTranslateRotateYXZ(ptr->unk_0C.x, ptr->unk_0C.y + (325.0f * ptr->unk_00.y), ptr->unk_0C.z, + &ptr->unk_1C); Matrix_Scale(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -325.0f, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, -325.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_bombiwa_DL_0009E0); diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c index 582c3a299..a4db0d04e 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -866,26 +866,26 @@ void func_80A25440(ObjIceblock* this) { if (this->unk_2B0 == 3) { sp24 = this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); sp34.x = this->unk_248.x; sp34.y = this->unk_248.y - sp24; sp34.z = this->unk_248.z; - Matrix_MultiplyVector3fByState(&sp34, &sp28); + Matrix_MultVec3f(&sp34, &sp28); sp34.x = this->dyna.actor.world.pos.x; sp34.y = this->dyna.actor.world.pos.y + sp24; sp34.z = this->dyna.actor.world.pos.z; Math_Vec3f_Sum(&sp34, &sp28, &temp_s1->world.pos); - Matrix_RotateY(this->unk_254.y + this->dyna.actor.home.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk_254.x + this->dyna.actor.home.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->unk_254.z + this->dyna.actor.home.rot.z, MTXMODE_APPLY); - Matrix_CopyCurrentState(&sp40); - func_8018219C(&sp40, &temp_s1->shape.rot, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_254.y + this->dyna.actor.home.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_254.x + this->dyna.actor.home.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_254.z + this->dyna.actor.home.rot.z, MTXMODE_APPLY); + Matrix_Get(&sp40); + Matrix_MtxFToYXZRot(&sp40, &temp_s1->shape.rot, true); } else { Math_Vec3f_Sum(&this->dyna.actor.world.pos, &this->unk_248, &temp_s1->world.pos); } @@ -1534,8 +1534,8 @@ void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { ptr = &this->unk_1B4[i]; sp70.x = ptr->unk_00; sp70.y = ptr->unk_02; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &sp70); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &sp70); Matrix_Scale(ptr->unk_04, ptr->unk_08, ptr->unk_0C, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1544,8 +1544,8 @@ void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gIceBlockIceBergSublimatingAirTexAnim)); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 20.0f, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 20.0f, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_Scale(this->unk_2B4, this->unk_2B4, this->unk_2B4, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c index d6a2df4cf..1ca1c4b58 100644 --- a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c +++ b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.c @@ -173,13 +173,13 @@ void ObjKendoKanban_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitTris(globalCtx, &this->colliderTris); Collider_SetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTrisElements); - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - &this->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { for (j = 0; j < ARRAY_COUNT(sp70); j++) { - Matrix_MultiplyVector3fByState(&sTrisElementsInit[i].dim.vtx[j], &sp70[j]); + Matrix_MultVec3f(&sTrisElementsInit[i].dim.vtx[j], &sp70[j]); } Collider_SetTrisVertices(&this->colliderTris, i, &sp70[0], &sp70[1], &sp70[2]); } @@ -339,14 +339,14 @@ void func_80B65DA8(ObjKendoKanban* this, GlobalContext* globalCtx) { this->unk_2FC = index; this->unk_2E4 = this->unk_29C[index]; - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - &this->actor.shape.rot); + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_MultiplyVector3fByState(&this->unk_2E4, &this->actor.world.pos); + Matrix_MultVec3f(&this->unk_2E4, &this->actor.world.pos); this->actor.world.pos = sp5C; this->actor.prevPos = this->actor.world.pos; - Matrix_StatePop(); + Matrix_Pop(); } Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); @@ -474,8 +474,8 @@ void ObjKendoKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gKendoKanbanDL); } else { - Matrix_InsertRotationAroundUnitVector_s(this->unk_302, &this->unk_2F0, MTXMODE_APPLY); - Matrix_InsertTranslation(-this->unk_2E4.x, -this->unk_2E4.y, -this->unk_2E4.z, MTXMODE_APPLY); + Matrix_RotateAxisS(this->unk_302, &this->unk_2F0, MTXMODE_APPLY); + Matrix_Translate(-this->unk_2E4.x, -this->unk_2E4.y, -this->unk_2E4.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -499,10 +499,10 @@ void ObjKendoKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { - Matrix_MultiplyVector3fByState(&this->unk_29C[i], &this->unk_26C[i]); + Matrix_MultVec3f(&this->unk_29C[i], &this->unk_26C[i]); } - Matrix_MultiplyVector3fByState(&this->unk_2CC, &this->unk_2D8); + Matrix_MultVec3f(&this->unk_2CC, &this->unk_2D8); } #else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Draw.s") diff --git a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c index 740439ead..33cadc8f6 100644 --- a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c +++ b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c @@ -81,7 +81,7 @@ void ObjKinoko_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetRenderMode(&gfx[2], G_RM_PASS, G_RM_ZB_CLD_SURF2); gSPMatrix(&gfx[3], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[4], &gameplay_keep_DL_029D10[2]); - Matrix_InsertXRotation_s(-0x4000, 1); + Matrix_RotateXS(-0x4000, MTXMODE_APPLY); gSPMatrix(&gfx[5], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[6], &gameplay_keep_DL_029D10[2]); POLY_XLU_DISP = &gfx[7]; diff --git a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c index e9456bac1..b1d54899b 100644 --- a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c +++ b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c @@ -89,9 +89,9 @@ void ObjLightswitch_InitCollider(ObjLightswitch* this, GlobalContext* globalCtx) Collider_InitJntSph(globalCtx, &this->collider); Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, &this->elements); this->actor.colChkInfo.mass = MASS_IMMOVABLE; - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, - this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), - this->actor.world.pos.z, &this->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, + this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), + this->actor.world.pos.z, &this->actor.shape.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); } @@ -384,13 +384,13 @@ void ObjLightSwitch_DrawOpa(ObjLightswitch* this, GlobalContext* globalCtx) { tempRot.x = this->actor.shape.rot.x; tempRot.y = this->actor.shape.rot.y; tempRot.z = this->actor.shape.rot.z + this->edgeRot; - Matrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); + Matrix_SetTranslateRotateYXZ(tempPos.x, tempPos.y, tempPos.z, &tempRot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_lightswitch_DL_000398); tempRot.z = this->actor.shape.rot.z - this->edgeRot; - Matrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); + Matrix_SetTranslateRotateYXZ(tempPos.x, tempPos.y, tempPos.z, &tempRot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_lightswitch_DL_000408); @@ -420,13 +420,13 @@ void ObjLightSwitch_DrawXlu(ObjLightswitch* this, GlobalContext* globalCtx) { tempRot.x = this->actor.shape.rot.x; tempRot.y = this->actor.shape.rot.y; tempRot.z = this->actor.shape.rot.z + this->edgeRot; - Matrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); + Matrix_SetTranslateRotateYXZ(tempPos.x, tempPos.y, tempPos.z, &tempRot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_lightswitch_DL_000398); tempRot.z = this->actor.shape.rot.z - this->edgeRot; - Matrix_SetStateRotationAndTranslation(tempPos.x, tempPos.y, tempPos.z, &tempRot); + Matrix_SetTranslateRotateYXZ(tempPos.x, tempPos.y, tempPos.z, &tempRot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_lightswitch_DL_000408); diff --git a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c index 546f0db16..d6d780a04 100644 --- a/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c +++ b/src/overlays/actors/ovl_Obj_Moon_Stone/z_obj_moon_stone.c @@ -151,7 +151,7 @@ void ObjMoonStone_Draw(Actor* thisx, GlobalContext* globalCtx) { AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_gi_reserve00_Matanimheader_001C60)); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_gi_reserve00_DL_000D78); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_gi_reserve00_DL_000C80); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c index fa3b46cf7..fac52301a 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -588,7 +588,7 @@ void ObjOshihiki_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); if (ObjOshihiki_MoveWithBlockUnder(this, globalCtx)) { - Matrix_InsertTranslation(this->underDistX * 10.0f, 0.0f, this->underDistZ * 10.0f, MTXMODE_APPLY); + Matrix_Translate(this->underDistX * 10.0f, 0.0f, this->underDistZ * 10.0f, MTXMODE_APPLY); } this->stateFlags &= ~PUSHBLOCK_MOVE_UNDER; diff --git a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c index ded17da2d..83e286e97 100644 --- a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c +++ b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c @@ -108,10 +108,9 @@ void func_80A3D9C4(ObjSmork* this, GlobalContext* globalCtx) { } if (this->unk_1B8 > 0.0f) { - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c index 15a63746b..3979479f6 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c @@ -687,8 +687,8 @@ void func_80B047C0(ObjSnowball* this, GlobalContext* globalCtx) { ptr->unk_18 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &ptr->unk_28, &sp98, &this->actor, &sp9C); if (ptr->unk_10 <= 0.0f) { - Matrix_InsertRotation(ptr->unk_1C.x, ptr->unk_1C.y, ptr->unk_1C.z, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&D_80B04FE4, &sp88); + Matrix_RotateZYX(ptr->unk_1C.x, ptr->unk_1C.y, ptr->unk_1C.z, MTXMODE_NEW); + Matrix_MultVec3f(&D_80B04FE4, &sp88); sp84 = this->unk_20C * 60.0f * 0.9f; if (sp88.y > 0.0f) { @@ -812,7 +812,7 @@ void func_80B04D34(Actor* thisx, GlobalContext* globalCtx) { sp80.y = ptr->unk_1C.y; sp80.z = ptr->unk_1C.z; - Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &sp80); + Matrix_SetTranslateRotateYXZ(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &sp80); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Gfx_DrawDListOpa(globalCtx, object_goroiwa_DL_0082D0); @@ -826,7 +826,7 @@ void func_80B04D34(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, ptr->unk_2C); func_800C0094(ptr->unk_28, ptr->unk_00.x, ptr->unk_18, ptr->unk_00.z, &sp88); - Matrix_SetCurrentState(&sp88); + Matrix_Put(&sp88); Matrix_Scale(this->actor.scale.x * 7.5f, 1.0f, this->actor.scale.z * 7.5f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), diff --git a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c index 229cdf516..5356e2e88 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c @@ -79,9 +79,9 @@ Gfx* D_80B3A91C[] = { Vec3f D_80B3A92C = { 0.0f, 0.3f, 0.0f }; void func_80B38E20(ObjSnowball2* this) { - Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, - this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), - this->actor.world.pos.z, &this->actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, + this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), + this->actor.world.pos.z, &this->actor.shape.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); } diff --git a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c index 1981c3b30..37ceb7268 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c @@ -478,8 +478,8 @@ void func_80B300F4(ObjSpidertent* thisx, GlobalContext* globalCtx, TriNorm* triN for (i = 0; i < sp80->unk_0F; i++) { temp_f2 = (Rand_ZeroOne() * temp_f24) + phi_f22; - Matrix_InsertRotationAroundUnitVector_f(temp_f2, &spAC, MTXMODE_NEW); - Matrix_MultiplyVector3fByState(&spA0, &sp94); + Matrix_RotateAxisF(temp_f2, &spAC, MTXMODE_NEW); + Matrix_MultVec3f(&spA0, &sp94); if (arg5 == 0) { spC4.x = (sp94.x * arg4) + arg3->x; @@ -571,23 +571,23 @@ void ObjSpidertent_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_LoadMesh(globalCtx, &this->dyna, ptr->unk_04); Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, D_80B31350[temp_s1].unk_08, this->colliderElements); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); sp64.x = ptr->unk_10 * 1.2f; sp64.y = ptr->unk_10 * 1.2f; sp64.z = ptr->unk_10 * 1.2f; - Matrix_MultiplyVector3fByState(&sp64, &this->dyna.actor.focus.pos); - Matrix_InsertTranslation(ptr->unk_10, ptr->unk_14 + 5.0f, ptr->unk_18, MTXMODE_APPLY); + Matrix_MultVec3f(&sp64, &this->dyna.actor.focus.pos); + Matrix_Translate(ptr->unk_10, ptr->unk_14 + 5.0f, ptr->unk_18, MTXMODE_APPLY); Matrix_Scale(ptr->unk_0C, ptr->unk_0C, ptr->unk_0C, MTXMODE_APPLY); - Matrix_InsertTranslation(-ptr->unk_10, -ptr->unk_14, -ptr->unk_18, MTXMODE_APPLY); + Matrix_Translate(-ptr->unk_10, -ptr->unk_14, -ptr->unk_18, MTXMODE_APPLY); for (i = 0; i < 6; i++) { element = &ptr->unk_08->elements[i]; for (j = 0; j < ARRAY_COUNT(sp70); j++) { - Matrix_MultiplyVector3fByState(&element->dim.vtx[j], &sp70[j]); + Matrix_MultVec3f(&element->dim.vtx[j], &sp70[j]); } Collider_SetTrisVertices(&this->collider, i, &sp70[0], &sp70[1], &sp70[2]); diff --git a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c index 20f4a1c50..2b15ef0b6 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c @@ -694,7 +694,7 @@ void ObjSpinyroll_Draw(Actor* thisx, GlobalContext* globalCtx) { sp84.z = this->dyna.actor.shape.rot.z; for (i = 0; i < phi_s4; i++) { - Matrix_SetStateRotationAndTranslation(phi_f22, temp_f30, phi_f24, &sp84); + Matrix_SetTranslateRotateYXZ(phi_f22, temp_f30, phi_f24, &sp84); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c index ceb35bc7e..8b61f265b 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -208,10 +208,10 @@ void ObjSwitch_InitJntSphCollider(ObjSwitch* this, GlobalContext* globalCtx, Col Collider_InitJntSph(globalCtx, &this->colliderJntSph); Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->dyna.actor, init, this->colliderJntSphElements); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.y + - (this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y), - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y + + (this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y), + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->colliderJntSph); } @@ -224,20 +224,20 @@ void ObjSwitch_InitTrisCollider(ObjSwitch* this, GlobalContext* globalCtx, Colli Collider_InitTris(globalCtx, &this->colliderTris); Collider_SetTris(globalCtx, &this->colliderTris, &this->dyna.actor, init, this->colliderTrisElements); - Matrix_StatePush(); - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.y + - this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Push(); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y + + this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { if (this) {} for (j = 0; j < ARRAY_COUNT(vtx); j++) { - Matrix_MultiplyVector3fByState(&init->elements[i].dim.vtx[j], &vtx[j]); + Matrix_MultVec3f(&init->elements[i].dim.vtx[j], &vtx[j]); } Collider_SetTrisVertices(&this->colliderTris, i, &vtx[0], &vtx[1], &vtx[2]); } - Matrix_StatePop(); + Matrix_Pop(); } Actor* ObjSwitch_SpawnIce(ObjSwitch* this, GlobalContext* globalCtx) { @@ -640,15 +640,15 @@ s32 ObjSwitch_IsEyeSwitchHit(ObjSwitch* this) { Vec3f sp2C; Vec3f sp20; - Matrix_StatePush(); - Matrix_RotateY(acActor->world.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(acActor->world.rot.x, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(1.0f, &sp2C); - Matrix_RotateY(actor->shape.rot.y, MTXMODE_NEW); - Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); - Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); - Matrix_GetStateTranslationAndScaledZ(1.0f, &sp20); - Matrix_StatePop(); + Matrix_Push(); + Matrix_RotateYS(acActor->world.rot.y, MTXMODE_NEW); + Matrix_RotateXS(acActor->world.rot.x, MTXMODE_APPLY); + Matrix_MultVecZ(1.0f, &sp2C); + Matrix_RotateYS(actor->shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_MultVecZ(1.0f, &sp20); + Matrix_Pop(); if ((Math3D_Parallel(&sp2C, &sp20) < COS_OF_5_PI_DIV_8)) { return true; } 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 2996ce5ae..9001ea27a 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -312,9 +312,9 @@ void ObjSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx) { (this->flameTexScroll * -OBJ_SYOKUDAI_SNUFF_DEFAULT) & 0x1FF, 0x20, 0x80)); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - Matrix_InsertTranslation(0.0f, OBJ_SYOKUDAI_FLAME_HEIGHT, 0.0f, MTXMODE_APPLY); - Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - thisx->shape.rot.y), - MTXMODE_APPLY); + Matrix_Translate(0.0f, OBJ_SYOKUDAI_FLAME_HEIGHT, 0.0f, MTXMODE_APPLY); + Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - thisx->shape.rot.y), + MTXMODE_APPLY); Matrix_Scale(flameScale, flameScale, flameScale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); diff --git a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c index b46f2626e..1567e90cc 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Step/z_obj_tokei_step.c @@ -52,11 +52,11 @@ static InitChainEntry sInitChain[] = { }; void ObjTokeiStep_SetSysMatrix(ObjTokeiStepPanel* panel) { - MtxF* mtx = Matrix_GetCurrentState(); + MtxF* mtx = Matrix_GetCurrent(); - mtx->wx = panel->pos.x; - mtx->wy = panel->pos.y; - mtx->wz = panel->pos.z; + mtx->xw = panel->pos.x; + mtx->yw = panel->pos.y; + mtx->zw = panel->pos.z; } void ObjTokeiStep_AddQuake(ObjTokeiStep* this, GlobalContext* globalCtx) { @@ -75,13 +75,13 @@ void ObjTokeiStep_SpawnDust(ObjTokeiStep* this, ObjTokeiStepPanel* panel, Global Vec3f dustSpawnOffset; Vec3f dustSpawnPos; - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); dustSpawnOffset.y = 115.0f; dustSpawnOffset.z = -10.0f; for (i = 0; i < 7; i++) { dustSpawnOffset.x = sDustSpawnXOffsets[i]; - Matrix_MultiplyVector3fByState(&dustSpawnOffset, &dustSpawnPos); + Matrix_MultVec3f(&dustSpawnOffset, &dustSpawnPos); dustSpawnPos.x += panel->pos.x; dustSpawnPos.y += panel->pos.y; dustSpawnPos.z += panel->pos.z; @@ -96,15 +96,15 @@ void ObjTokeiStep_InitSteps(ObjTokeiStep* this) { Vec3f panelOffset; s32 pad; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); panelOffset.x = 0.0f; panelOffset.y = 0.0f; for (i = 0; i < ARRAY_COUNT(this->panels); i++) { panel = &this->panels[i]; panelOffset.z = i * -20.0f; - Matrix_MultiplyVector3fByState(&panelOffset, &panel->pos); + Matrix_MultVec3f(&panelOffset, &panel->pos); panel->posChangeY = 0.0f; panel->numBounces = 0; } @@ -115,15 +115,15 @@ void ObjTokeiStep_InitStepsOpen(ObjTokeiStep* this) { ObjTokeiStepPanel* panel; Vec3f panelOffset; - Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, - this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); panelOffset.x = 0.0f; for (i = 0; i < ARRAY_COUNT(this->panels); i++) { panel = &this->panels[i]; panelOffset.y = sPanelXOffsets[i]; panelOffset.z = i * -20.0f; - Matrix_MultiplyVector3fByState(&panelOffset, &panel->pos); + Matrix_MultVec3f(&panelOffset, &panel->pos); } } diff --git a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c index 95f0eb3a8..546e29a8e 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -819,22 +819,22 @@ void ObjTokeidai_Clock_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -1791.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(-this->xRotation, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 1791.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -1791.0f, MTXMODE_APPLY); + Matrix_RotateXS(-this->xRotation, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 1791.0f, MTXMODE_APPLY); - Matrix_StatePush(); - Matrix_InsertZRotation_s(-this->minuteRingOrExteriorGearRotation, MTXMODE_APPLY); + Matrix_Push(); + Matrix_RotateZS(-this->minuteRingOrExteriorGearRotation, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gClockTowerMinuteRingDL); - Matrix_StatePop(); + Matrix_Pop(); - Matrix_InsertTranslation(0.0f, 0.0f, this->clockFaceZTranslation, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, this->clockFaceZTranslation, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gClockTowerClockCenterAndHandDL); - Matrix_InsertZRotation_s(-this->clockFaceRotation * 2, MTXMODE_APPLY); + Matrix_RotateZS(-this->clockFaceRotation * 2, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_WALL_CLOCK || OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_SMALL_WALL_CLOCK) { @@ -843,8 +843,8 @@ void ObjTokeidai_Clock_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_OPA_DISP++, gClockTowerClockFace); } - Matrix_InsertTranslation(0.0f, -1112.0f, -19.6f, MTXMODE_APPLY); - Matrix_RotateY((s16)this->sunMoonPanelRotation, MTXMODE_APPLY); + Matrix_Translate(0.0f, -1112.0f, -19.6f, MTXMODE_APPLY); + Matrix_RotateYS(this->sunMoonPanelRotation, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gClockTowerSunAndMoonPanelDL); @@ -856,12 +856,12 @@ void ObjTokeidai_Counterweight_Draw(Actor* thisx, GlobalContext* globalCtx) { u32 gameplayFrames = globalCtx->gameplayFrames; ObjTokeidai* this = THIS; - Matrix_RotateY(-this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, -5480.0f, 80.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(-this->xRotation, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 5480.0f, -80.0f, MTXMODE_APPLY); - Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(-this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, -5480.0f, 80.0f, MTXMODE_APPLY); + Matrix_RotateXS(-this->xRotation, MTXMODE_APPLY); + Matrix_Translate(0.0f, 5480.0f, -80.0f, MTXMODE_APPLY); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -888,13 +888,13 @@ void ObjTokeidai_ExteriorGear_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -1791.0f, MTXMODE_APPLY); - Matrix_RotateY(-this->actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(-this->xRotation, MTXMODE_APPLY); - Matrix_RotateY(thisx->shape.rot.y, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 1791.0f, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->minuteRingOrExteriorGearRotation, MTXMODE_APPLY); + Matrix_Translate(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -1791.0f, MTXMODE_APPLY); + Matrix_RotateYS(-this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(-this->xRotation, MTXMODE_APPLY); + Matrix_RotateYS(thisx->shape.rot.y, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 1791.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->minuteRingOrExteriorGearRotation, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_8012C28C(globalCtx->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gClockTowerExteriorGearDL); diff --git a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c index e19edead3..223ebad74 100644 --- a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c +++ b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c @@ -189,7 +189,7 @@ void ObjTree_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_tree_DL_000680); - Matrix_InsertRotation(xRot, 0, zRot, MTXMODE_APPLY); + Matrix_RotateZYX(xRot, 0, zRot, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_tree_DL_0007C8); diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c index 5f2aed7a9..067bd58ec 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c @@ -252,9 +252,9 @@ s32 func_80A3CC30(ObjVspinyroll* this, GlobalContext* globalCtx) { } void func_80A3CC84(f32 arg0) { - MtxF* matrix = Matrix_GetCurrentState(); + MtxF* matrix = Matrix_GetCurrent(); - matrix->wy += arg0; + matrix->yw += arg0; } void ObjVspinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -416,11 +416,11 @@ void ObjVspinyroll_Update(Actor* thisx, GlobalContext* globalCtx2) { void ObjVspinyroll_Draw(Actor* thisx, GlobalContext* globalCtx) { ObjVspinyroll* this = THIS; - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, - this->dyna.actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z + 0x4000, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x + this->unk_3C6, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->dyna.actor.shape.rot.z + 0x4000, MTXMODE_APPLY); + Matrix_RotateXS(this->dyna.actor.shape.rot.x + this->unk_3C6, MTXMODE_APPLY); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); Gfx_DrawDListOpa(globalCtx, object_spinyroll_DL_000460); } @@ -436,11 +436,11 @@ void func_80A3D2C0(Actor* thisx, GlobalContext* globalCtx) { sp3C.z = this->dyna.actor.shape.rot.z + 0x4000; func_8012C28C(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, - this->dyna.actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateY(sp3C.y, MTXMODE_APPLY); - Matrix_InsertZRotation_s(sp3C.z, MTXMODE_APPLY); - Matrix_InsertXRotation_s(sp3C.x, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateYS(sp3C.y, MTXMODE_APPLY); + Matrix_RotateZS(sp3C.z, MTXMODE_APPLY); + Matrix_RotateXS(sp3C.x, MTXMODE_APPLY); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c index 052d6610a..c676b4960 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c @@ -169,21 +169,21 @@ void ObjWarpstone_Draw(Actor* thisx, GlobalContext* globalCtx2) { if (this->dyna.actor.home.rot.x != 0) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 34.0f, - this->dyna.actor.world.pos.z, MTXMODE_NEW); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, 30.0f, MTXMODE_APPLY); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 34.0f, + this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 30.0f, MTXMODE_APPLY); Matrix_Scale(this->dyna.actor.velocity.x, this->dyna.actor.velocity.x, this->dyna.actor.velocity.x, MTXMODE_APPLY); - Matrix_StatePush(); + Matrix_Push(); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 255, 255, 200, this->dyna.actor.home.rot.x); gDPSetEnvColor(POLY_XLU_DISP++, 100, 200, 0, 255); - Matrix_InsertZRotation_f((((globalCtx->gameplayFrames * 1500) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); + Matrix_RotateZF((((globalCtx->gameplayFrames * 1500) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); - Matrix_StatePop(); - Matrix_InsertZRotation_f((~((globalCtx->gameplayFrames * 1200) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); + Matrix_Pop(); + Matrix_RotateZF((~((globalCtx->gameplayFrames * 1200) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c index 3ed787918..3dfea0818 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c @@ -85,15 +85,15 @@ void ObjYasi_Update(Actor* thisx, GlobalContext* globalCtx) { void ObjYasi_Draw(Actor* thisx, GlobalContext* globalCtx) { ObjYasi* this = THIS; - Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, - MTXMODE_NEW); + Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); if (this->dyna.actor.shape.rot.x != 0) { - Matrix_RotateY(this->dyna.actor.home.rot.y, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); - Matrix_RotateY(BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.home.rot.y), MTXMODE_APPLY); + Matrix_RotateYS(this->dyna.actor.home.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateYS(BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.home.rot.y), MTXMODE_APPLY); } else { - Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); } Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index 324e53fee..2f976f2cc 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -268,8 +268,8 @@ void func_808DC454(ObjectKankyo* this, GlobalContext* globalCtx) { phi_f20 = globalCtx->envCtx.windSpeed / 120.0f; phi_f20 = CLAMP(phi_f20, 0.0f, 1.0f); - this->unk_14C[i].unk_0C += __sinf((this->unk_144 + (i * 100.0f)) * 0.01f) + (spC4 * 10.0f * phi_f20); - this->unk_14C[i].unk_14 += __cosf((this->unk_148 + (i * 100.0f)) * 0.01f) + (spBC * 10.0f * phi_f20); + this->unk_14C[i].unk_0C += sinf((this->unk_144 + (i * 100.0f)) * 0.01f) + (spC4 * 10.0f * phi_f20); + this->unk_14C[i].unk_14 += cosf((this->unk_148 + (i * 100.0f)) * 0.01f) + (spBC * 10.0f * phi_f20); this->unk_14C[i].unk_10 -= this->unk_14C[i].unk_18 - (spC0 * 3.0f * (globalCtx->envCtx.windSpeed / 100.0f)); @@ -431,8 +431,8 @@ void func_808DCDB4(ObjectKankyo* this, GlobalContext* globalCtx) { temp_f20 = globalCtx->envCtx.windSpeed / 120.0f; temp_f20 = CLAMP(temp_f20, 0.0f, 1.0f); - this->unk_14C[i].unk_0C += __sinf((this->unk_144 + i) * 0.01f) + (spA0 * 10.0f * temp_f20); - this->unk_14C[i].unk_14 += __cosf((this->unk_148 + i) * 0.01f) + (sp9C * 10.0f * temp_f20); + this->unk_14C[i].unk_0C += sinf((this->unk_144 + i) * 0.01f) + (spA0 * 10.0f * temp_f20); + this->unk_14C[i].unk_14 += cosf((this->unk_148 + i) * 0.01f) + (sp9C * 10.0f * temp_f20); if ((i % 2) == 0) { this->unk_14C[i].unk_10 += this->unk_14C[i].unk_18; @@ -557,7 +557,7 @@ void func_808DD3C8(Actor* thisx, GlobalContext* globalCtx2) { gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust5Tex)); } - Matrix_InsertTranslation(spC4.x, spC4.y, spC4.z, MTXMODE_NEW); + Matrix_Translate(spC4.x, spC4.y, spC4.z, MTXMODE_NEW); tempf = (i & 7) * 0.008f; Matrix_Scale(0.05f + tempf, 0.05f + tempf, 0.05f + tempf, MTXMODE_APPLY); temp_f2 = Math_Vec3f_DistXYZ(&spC4, &globalCtx->view.eye) / 300.0f; @@ -566,7 +566,7 @@ void func_808DD3C8(Actor* thisx, GlobalContext* globalCtx2) { gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)(160.0f * temp_f2)); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -616,7 +616,7 @@ void func_808DD970(Actor* thisx, GlobalContext* globalCtx2) { func_80169474(globalCtx, &spBC, &spB0); if ((spB0.x >= 0.0f) && (spB0.x < 320.0f) && (spB0.y >= 0.0f) && (spB0.y < 240.0f)) { - Matrix_InsertTranslation(spBC.x, spBC.y, spBC.z, MTXMODE_NEW); + Matrix_Translate(spBC.x, spBC.y, spBC.z, MTXMODE_NEW); Matrix_Scale(0.03f, 0.03f, 0.03f, MTXMODE_APPLY); temp_f0 = Math_Vec3f_DistXYZ(&spBC, &globalCtx->view.eye); temp_f0 = (u8)(255.0f * phi_f26) * (1.0f - (temp_f0 / 300.0f)); @@ -625,7 +625,7 @@ void func_808DD970(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 55, temp_f0); gDPSetEnvColor(POLY_XLU_DISP++, 55, 50, 255, temp_f0); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -679,12 +679,12 @@ void func_808DDE9C(Actor* thisx, GlobalContext* globalCtx2) { continue; } - Matrix_InsertTranslation(temp_f20, temp_f22, temp_f2, MTXMODE_NEW); + Matrix_Translate(temp_f20, temp_f22, temp_f2, MTXMODE_NEW); gSPMatrix(POLY_XLU_DISP++, &D_01000000, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); - Matrix_RotateY((s16)this->unk_14C[2].unk_04 + (s16)(i << 5), MTXMODE_APPLY); - Matrix_InsertXRotation_s((s16)this->unk_14C[2].unk_00 + (s16)(i << 5), MTXMODE_APPLY); + Matrix_RotateYS((s16)this->unk_14C[2].unk_04 + (s16)(i << 5), MTXMODE_APPLY); + Matrix_RotateXS((s16)this->unk_14C[2].unk_00 + (s16)(i << 5), MTXMODE_APPLY); if (this->unk_114C == 0) { Matrix_Scale(0.5f, 1.0f, 0.5f, MTXMODE_APPLY); @@ -715,7 +715,7 @@ void func_808DDE9C(Actor* thisx, GlobalContext* globalCtx2) { continue; } - Matrix_InsertTranslation(temp_f20, temp_f22, temp_f2, MTXMODE_NEW); + Matrix_Translate(temp_f20, temp_f22, temp_f2, MTXMODE_NEW); temp_f12 = (Rand_ZeroOne() * 0.05f) + 0.05f; Matrix_Scale(temp_f12, temp_f12, temp_f12, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c index a16821f00..a54ca583c 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c +++ b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c @@ -87,12 +87,12 @@ void OceffWipe6_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(activeCamEye.x + quakeOffset.x, activeCamEye.y + quakeOffset.y, - activeCamEye.z + quakeOffset.z, MTXMODE_NEW); + Matrix_Translate(activeCamEye.x + quakeOffset.x, activeCamEye.y + quakeOffset.y, activeCamEye.z + quakeOffset.z, + MTXMODE_NEW); Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); - Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_InsertXRotation_s(0x708, MTXMODE_APPLY); - Matrix_InsertTranslation(0.0f, 0.0f, -z, MTXMODE_APPLY); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_RotateXS(0x708, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); AnimatedMat_Draw(globalCtx, ovl_Oceff_Wipe6_Matanimheader_000338); gSPDisplayList(POLY_XLU_DISP++, gOceff6DL); diff --git a/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c b/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c index 29ac6b18b..a2449af92 100644 --- a/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c +++ b/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.c @@ -66,10 +66,10 @@ void EffectEnIceBlock_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) globalCtx->objectCtx.status[this->rObjId].segment); // object: OBJECT_ICE_BLOCK func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_InsertZRotation_s(this->rRot, MTXMODE_APPLY); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZS(this->rRot, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c index 41a8f92ff..6627e1c87 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c +++ b/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.c @@ -51,7 +51,7 @@ void EffectSsBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { OPEN_DISPS(gfxCtx); - Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c b/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c index d2ea02f7c..a345f0b5c 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c +++ b/src/overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.c @@ -100,9 +100,9 @@ void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { } } - Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); - Matrix_RotateY(this->rYaw, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->rPitch, MTXMODE_APPLY); + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->rYaw, MTXMODE_APPLY); + Matrix_RotateXS(this->rPitch, MTXMODE_APPLY); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); if ((((this->rReg4 >> 7) & 1) << 7) == 0x80) { diff --git a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c index 26901bac5..2e8646a54 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c +++ b/src/overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.c @@ -128,7 +128,7 @@ void EffectSsSbn_DrawSliding(GlobalContext* globalCtx, u32 index, EffectSs* this func_800C0094(this->gfx, this->pos.x, this->pos.y, this->pos.z, &mtx); SkinMatrix_MulYRotation(&mtx, this->rRotAngle); - Matrix_InsertMatrix(&mtx, MTXMODE_NEW); + Matrix_Mult(&mtx, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); Matrix_Scale(0.05f, 0.05f, 0.05f, MTXMODE_APPLY); @@ -168,7 +168,7 @@ void EffectSsSbn_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { func_800C0094(this->gfx, this->pos.x, this->pos.y, this->pos.z, &mtx); SkinMatrix_MulYRotation(&mtx, this->rRotAngle); - Matrix_InsertMatrix(&mtx, MTXMODE_NEW); + Matrix_Mult(&mtx, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); Matrix_Scale(0.05f, 0.05f, 0.05f, MTXMODE_APPLY); diff --git a/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c b/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c index d4356f90c..5d30ecf04 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c +++ b/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.c @@ -67,7 +67,7 @@ void EffectSsSibuki_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { OPEN_DISPS(gfxCtx); - Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_8012C28C(gfxCtx); diff --git a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c index d26135729..adca90668 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.c @@ -46,9 +46,9 @@ void EffectSsStick_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { OPEN_DISPS(gfxCtx); - Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Scale(0.01f, 0.0025f, 0.01f, MTXMODE_APPLY); - Matrix_InsertRotation(0, this->rYaw, 0, MTXMODE_APPLY); + Matrix_RotateZYX(0, this->rYaw, 0, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_8012C28C(gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->rObjBankIndex].segment); diff --git a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c index 06cfa5b18..abcd52393 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c @@ -62,7 +62,7 @@ void EffectSsStone1_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->pos, &mfVec, &mfW); scale = (mfW < 1500.0f) ? 3.0f : (mfW / 1500.0f) * 3.0f; - Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_8012C9BC(gfxCtx); diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c index 0ac471162..df16aae5b 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c @@ -226,7 +226,7 @@ void Daytelop_Init(GameState* thisx) { DaytelopContext* this = (DaytelopContext*)thisx; Game_SetFramerateDivisor(thisx, 1); - Matrix_StateAlloc(thisx); + Matrix_Init(thisx); ShrinkWindow_Destroy(); View_Init(&this->view, thisx->gfxCtx); thisx->main = Daytelop_Main; diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index f0dd8190e..c705cb708 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -50,7 +50,7 @@ void Opening_Init(GameState* thisx) { OpeningContext* this = (OpeningContext*)thisx; Game_SetFramerateDivisor(&this->gameState, 1); - Matrix_StateAlloc(&this->gameState); + Matrix_Init(&this->gameState); ShrinkWindow_Init(); View_Init(&this->view, this->gameState.gfxCtx); this->gameState.main = Opening_Main; diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index afeafe09f..1c32f6490 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -80,9 +80,9 @@ void Title_Draw(GameState* thisx) { Title_RenderView(this, 0.0f, 150.0f, 300.0f); func_8012C28C(this->gameState.gfxCtx); - Matrix_InsertTranslation(-53.0f, -5.0f, 0.0f, MTXMODE_NEW); + Matrix_Translate(-53.0f, -5.0f, 0.0f, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_InsertRotation(0, titleRotation, 0, MTXMODE_APPLY); + Matrix_RotateZYX(0, titleRotation, 0, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(this->gameState.gfxCtx), G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gNintendo64LogoNDL); @@ -159,7 +159,7 @@ void Title_Init(GameState* thisx) { DmaMgr_SendRequest0(this->staticSegment, (uintptr_t)_nintendo_rogo_staticSegmentRomStart, segmentSize); Game_SetFramerateDivisor(thisx, 1); - Matrix_StateAlloc(thisx); + Matrix_Init(thisx); ShrinkWindow_Init(); View_Init(&this->view, thisx->gfxCtx); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 017df4ba1..bdb5188e3 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -251,7 +251,7 @@ 0x800880B0:("osGetIntMask",), 0x80088110:("osVoiceSetWord",), 0x800882A0:("guScale",), - 0x80088350:("__sinf",), + 0x80088350:("sinf",), 0x80088510:("sins",), 0x80088580:("_VirtualToPhysicalTask",), 0x8008868C:("osSpTaskLoad",), @@ -410,7 +410,7 @@ 0x80091AF0:("__osViInit",), 0x80091C10:("__osViSwapContext",), 0x80091F10:("osPiGetCmdQueue",), - 0x80091F40:("__cosf",), + 0x80091F40:("cosf",), 0x800920B0:("osEPiReadIo",), 0x80092100:("osViSetSpecialFeatures",), 0x80092260:("coss",), @@ -3354,45 +3354,45 @@ 0x801800CC:("Math_Atan2F",), 0x80180100:("Math_FAtan2F",), 0x8018012C:("Math_Acot2F",), - 0x80180160:("Matrix_StateAlloc",), - 0x8018019C:("Matrix_StatePush",), - 0x801801CC:("Matrix_StatePop",), - 0x801801E8:("Matrix_CopyCurrentState",), - 0x8018020C:("Matrix_SetCurrentState",), - 0x80180234:("Matrix_GetCurrentState",), - 0x80180244:("Matrix_InsertMatrix",), - 0x8018029C:("Matrix_InsertTranslation",), + 0x80180160:("Matrix_Init",), + 0x8018019C:("Matrix_Push",), + 0x801801CC:("Matrix_Pop",), + 0x801801E8:("Matrix_Get",), + 0x8018020C:("Matrix_Put",), + 0x80180234:("Matrix_GetCurrent",), + 0x80180244:("Matrix_Mult",), + 0x8018029C:("Matrix_Translate",), 0x8018039C:("Matrix_Scale",), - 0x80180478:("Matrix_InsertXRotation_s",), - 0x80180610:("Matrix_InsertXRotation_f",), - 0x801807B8:("Matrix_RotateStateAroundXAxis",), - 0x80180900:("Matrix_SetStateXRotation",), - 0x801809AC:("Matrix_RotateY",), - 0x80180B48:("Matrix_InsertYRotation_f",), - 0x80180CF8:("Matrix_InsertZRotation_s",), - 0x80180E90:("Matrix_InsertZRotation_f",), - 0x8018103C:("Matrix_InsertRotation",), - 0x801812FC:("Matrix_JointPosition",), - 0x80181650:("Matrix_SetStateRotationAndTranslation",), - 0x801817FC:("Matrix_ToRSPMatrix",), + 0x80180478:("Matrix_RotateXS",), + 0x80180610:("Matrix_RotateXF",), + 0x801807B8:("Matrix_RotateXFApply",), + 0x80180900:("Matrix_RotateXFNew",), + 0x801809AC:("Matrix_RotateYS",), + 0x80180B48:("Matrix_RotateYF",), + 0x80180CF8:("Matrix_RotateZS",), + 0x80180E90:("Matrix_RotateZF",), + 0x8018103C:("Matrix_RotateZYX",), + 0x801812FC:("Matrix_TranslateRotateZYX",), + 0x80181650:("Matrix_SetTranslateRotateYXZ",), + 0x801817FC:("Matrix_MtxFToMtx",), 0x80181A18:("Matrix_ToMtx",), 0x80181A40:("Matrix_NewMtx",), - 0x80181A6C:("Matrix_AppendToPolyOpaDisp",), - 0x80181A98:("Matrix_MultiplyVector3fByState",), - 0x80181B50:("Matrix_GetStateTranslation",), - 0x80181B78:("Matrix_GetStateTranslationAndScaledX",), - 0x80181BC4:("Matrix_GetStateTranslationAndScaledY",), - 0x80181C10:("Matrix_GetStateTranslationAndScaledZ",), - 0x80181C5C:("Matrix_MultiplyVector3fXZByCurrentState",), + 0x80181A6C:("Matrix_MtxFToNewMtx",), + 0x80181A98:("Matrix_MultVec3f",), + 0x80181B50:("Matrix_MultZero",), + 0x80181B78:("Matrix_MultVecX",), + 0x80181BC4:("Matrix_MultVecY",), + 0x80181C10:("Matrix_MultVecZ",), + 0x80181C5C:("Matrix_MultVec3fXZ",), 0x80181CDC:("Matrix_MtxFCopy",), - 0x80181D64:("Matrix_FromRSPMatrix",), - 0x80181FB8:("Matrix_MultiplyVector3fByMatrix",), - 0x80182068:("Matrix_TransposeXYZ",), - 0x801820A0:("Matrix_NormalizeXYZ",), - 0x8018219C:("func_8018219C",), - 0x801822C4:("func_801822C4",), - 0x801823EC:("Matrix_InsertRotationAroundUnitVector_f",), - 0x8018284C:("Matrix_InsertRotationAroundUnitVector_s",), + 0x80181D64:("Matrix_MtxToMtxF",), + 0x80181FB8:("Matrix_MultVec3fExt",), + 0x80182068:("Matrix_Transpose",), + 0x801820A0:("Matrix_ReplaceRotation",), + 0x8018219C:("Matrix_MtxFToYXZRot",), + 0x801822C4:("Matrix_MtxFToZYXRot",), + 0x801823EC:("Matrix_RotateAxisF",), + 0x8018284C:("Matrix_RotateAxisS",), 0x80182C90:("SysUcode_GetUCodeBoot",), 0x80182CA0:("SysUcode_GetUCodeBootSize",), 0x80182CBC:("SysUcode_GetUCode",), diff --git a/tools/namefixer.py b/tools/namefixer.py index c4a83d13f..1d6c89a7b 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -22,42 +22,80 @@ wordReplace = { "Actor_GetSwitchFlag": "Flags_GetSwitch", "atan_flip": "Math_Acot2F", "atans": "Math_Atan2S", - "SysMatrix_StateAlloc": "Matrix_StateAlloc", - "SysMatrix_StatePush": "Matrix_StatePush", - "SysMatrix_CopyCurrentState": "Matrix_CopyCurrentState", - "SysMatrix_SetCurrentState": "Matrix_SetCurrentState", - "SysMatrix_InsertTranslation": "Matrix_InsertTranslation", - "SysMatrix_InsertMatrix": "Matrix_InsertMatrix", - "SysMatrix_Scale": "Matrix_Scale", - "SysMatrix_InsertXRotation_s": "Matrix_InsertXRotation_s", - "SysMatrix_InsertXRotation_f": "Matrix_InsertXRotation_f", - "SysMatrix_RotateStateAroundXAxis": "Matrix_RotateStateAroundXAxis", - "SysMatrix_SetStateXRotation": "Matrix_SetStateXRotation", - "SysMatrix_RotateY": "Matrix_RotateY", - "SysMatrix_InsertYRotation_f": "Matrix_InsertYRotation_f", - "SysMatrix_InsertZRotation_s": "Matrix_InsertZRotation_s", - "SysMatrix_InsertZRotation_f": "Matrix_InsertZRotation_f", - "SysMatrix_InsertRotation": "Matrix_InsertRotation", - "SysMatrix_JointPosition": "Matrix_JointPosition", - "SysMatrix_SetStateRotationAndTranslation": "Matrix_SetStateRotationAndTranslation", - "SysMatrix_ToRSPMatrix": "Matrix_ToRSPMatrix", - "SysMatrix_ToMtx": "Matrix_ToMtx", - "SysMatrix_NewMtx": "Matrix_NewMtx", - "SysMatrix_AppendToPolyOpaDisp": "Matrix_AppendToPolyOpaDisp", - "SysMatrix_MultiplyVector3fByState": "Matrix_MultiplyVector3fByState", - "SysMatrix_GetStateTranslation": "Matrix_GetStateTranslation", - "SysMatrix_GetStateTranslationAndScaledX": "Matrix_GetStateTranslationAndScaledX", - "SysMatrix_GetStateTranslationAndScaledY": "Matrix_GetStateTranslationAndScaledY", - "SysMatrix_GetStateTranslationAndScaledZ": "Matrix_GetStateTranslationAndScaledZ", - "SysMatrix_MultiplyVector3fXZByCurrentState": "Matrix_MultiplyVector3fXZByCurrentState", - "SysMatrix_MtxFCopy": "Matrix_MtxFCopy", - "SysMatrix_FromRSPMatrix": "Matrix_FromRSPMatrix", - "SysMatrix_MultiplyVector3fByMatrix": "Matrix_MultiplyVector3fByMatrix", - "SysMatrix_TransposeXYZ": "Matrix_TransposeXYZ", - "SysMatrix_NormalizeXYZ": "Matrix_NormalizeXYZ", - "SysMatrix_InsertRotationAroundUnitVector_f": "Matrix_InsertRotationAroundUnitVector_f", - "SysMatrix_InsertRotationAroundUnitVector_s": "Matrix_InsertRotationAroundUnitVector_s", - "SysMatrix_GetStateAsRSPMatrix": "Matrix_GetStateAsRSPMatrix", + + # "SysMatrix_StateAlloc": "Matrix_StateAlloc", + # "SysMatrix_StatePush": "Matrix_StatePush", + # "SysMatrix_StatePop": "Matrix_StatePop", + # "SysMatrix_GetCurrentState": "Matrix_GetCurrentState", + # "SysMatrix_CopyCurrentState": "Matrix_CopyCurrentState", + # "SysMatrix_SetCurrentState": "Matrix_SetCurrentState", + # "SysMatrix_InsertTranslation": "Matrix_InsertTranslation", + # "SysMatrix_InsertMatrix": "Matrix_InsertMatrix", + # "SysMatrix_Scale": "Matrix_Scale", + # "SysMatrix_InsertXRotation_s": "Matrix_InsertXRotation_s", + # "SysMatrix_InsertXRotation_f": "Matrix_InsertXRotation_f", + # "SysMatrix_RotateStateAroundXAxis": "Matrix_RotateStateAroundXAxis", + # "SysMatrix_SetStateXRotation": "Matrix_SetStateXRotation", + # "SysMatrix_RotateY": "Matrix_RotateY", + # "SysMatrix_InsertYRotation_f": "Matrix_InsertYRotation_f", + # "SysMatrix_InsertZRotation_s": "Matrix_InsertZRotation_s", + # "SysMatrix_InsertZRotation_f": "Matrix_InsertZRotation_f", + # "SysMatrix_InsertRotation": "Matrix_InsertRotation", + # "SysMatrix_JointPosition": "Matrix_JointPosition", + # "SysMatrix_SetStateRotationAndTranslation": "Matrix_SetStateRotationAndTranslation", + # "SysMatrix_ToRSPMatrix": "Matrix_ToRSPMatrix", + # "SysMatrix_ToMtx": "Matrix_ToMtx", + # "SysMatrix_NewMtx": "Matrix_NewMtx", + # "SysMatrix_AppendToPolyOpaDisp": "Matrix_AppendToPolyOpaDisp", + # "SysMatrix_MultiplyVector3fByState": "Matrix_MultiplyVector3fByState", + # "SysMatrix_GetStateTranslation": "Matrix_GetStateTranslation", + # "SysMatrix_GetStateTranslationAndScaledX": "Matrix_GetStateTranslationAndScaledX", + # "SysMatrix_GetStateTranslationAndScaledY": "Matrix_GetStateTranslationAndScaledY", + # "SysMatrix_GetStateTranslationAndScaledZ": "Matrix_GetStateTranslationAndScaledZ", + # "SysMatrix_MultiplyVector3fXZByCurrentState": "Matrix_MultiplyVector3fXZByCurrentState", + # "SysMatrix_MtxFCopy": "Matrix_MtxFCopy", + # "SysMatrix_FromRSPMatrix": "Matrix_FromRSPMatrix", + # "SysMatrix_MultiplyVector3fByMatrix": "Matrix_MultiplyVector3fByMatrix", + # "SysMatrix_TransposeXYZ": "Matrix_TransposeXYZ", + # "SysMatrix_NormalizeXYZ": "Matrix_NormalizeXYZ", + # "SysMatrix_InsertRotationAroundUnitVector_f": "Matrix_InsertRotationAroundUnitVector_f", + # "SysMatrix_InsertRotationAroundUnitVector_s": "Matrix_InsertRotationAroundUnitVector_s", + # "SysMatrix_GetStateAsRSPMatrix": "Matrix_GetStateAsRSPMatrix", + + "Matrix_StateAlloc": "Matrix_Init", + "Matrix_StatePush": "Matrix_Push", + "Matrix_StatePop": "Matrix_Pop", + "Matrix_CopyCurrentState": "Matrix_Get", + "Matrix_SetCurrentState": "Matrix_Put", + "Matrix_GetCurrentState": "Matrix_GetCurrent", + "Matrix_InsertMatrix": "Matrix_Mult", + "Matrix_InsertTranslation": "Matrix_Translate", + "Matrix_InsertXRotation_s": "Matrix_RotateXS", + "Matrix_InsertXRotation_f": "Matrix_RotateXF", + "Matrix_RotateStateAroundXAxis": "Matrix_RotateXFApply", + "Matrix_SetStateXRotation": "Matrix_RotateXFNew", + # "Matrix_RotateY": "Matrix_RotateYS", + "Matrix_InsertYRotation_f": "Matrix_RotateYF", + "Matrix_InsertZRotation_s": "Matrix_RotateZS", + "Matrix_InsertZRotation_f": "Matrix_RotateZF", + "Matrix_InsertRotation": "Matrix_RotateZYX", + "Matrix_JointPosition": "Matrix_TranslateRotateZYX", + "Matrix_SetStateRotationAndTranslation": "Matrix_SetTranslateRotateYXZ", + "Matrix_ToRSPMatrix": "Matrix_MtxFToMtx", + "Matrix_MultiplyVector3fByState": "Matrix_MultVec3f", + "Matrix_GetStateTranslation": "Matrix_MultZero", + "Matrix_GetStateTranslationAndScaledX": "Matrix_MultVecX", + "Matrix_GetStateTranslationAndScaledY": "Matrix_MultVecY", + "Matrix_GetStateTranslationAndScaledZ": "Matrix_MultVecZ", + "Matrix_MultiplyVector3fXZByCurrentState": "Matrix_MultVec3fXZ", + "Matrix_FromRSPMatrix": "Matrix_MtxToMtxF", + "Matrix_TransposeXYZ": "Matrix_Transpose", + "Matrix_NormalizeXYZ": "Matrix_ReplaceRotation", + "func_8018219C": "Matrix_MtxFToYXZRot", + "func_801822C4": "Matrix_MtxFToZYXRot", + "Matrix_InsertRotationAroundUnitVector_f": "Matrix_RotateAxisF", + "Matrix_InsertRotationAroundUnitVector_s": "Matrix_RotateAxisS", + "func_800B78B8": "Actor_UpdateBgCheckInfo", "func_8012403C": "Player_GetMask", "func_8012404c": "Player_RemoveMask", @@ -184,8 +222,6 @@ wordReplace = { "func_80137748": "SkelAnime_UpdateTranslation", "func_801378B8": "Animation_OnFrame", "SkelAnime_CopyVec3s": "SkelAnime_CopyFrameTable", - "SysMatrix_StatePop": "Matrix_StatePop", - "SysMatrix_GetCurrentState": "Matrix_GetCurrentState", "Actor_SetObjectSegment": "Actor_SetObjectDependency", "func_800B3FC0": "ActorShadow_DrawCircle", "func_800B4024": "ActorShadow_DrawSquare", diff --git a/tools/sizes/boot_functions.csv b/tools/sizes/boot_functions.csv index 6c5c92e16..a86be3b83 100644 --- a/tools/sizes/boot_functions.csv +++ b/tools/sizes/boot_functions.csv @@ -248,7 +248,7 @@ asm/non_matchings/boot/setintmask/osSetIntMask.s,osSetIntMask,0x80088010,0x28 asm/non_matchings/boot/getintmask/osGetIntMask.s,osGetIntMask,0x800880B0,0x18 asm/non_matchings/boot/voicesetword/osVoiceSetWord.s,osVoiceSetWord,0x80088110,0x64 asm/non_matchings/boot/guScale/guScale.s,guScale,0x800882A0,0x2C -asm/non_matchings/boot/sinf/__sinf.s,__sinf,0x80088350,0x70 +asm/non_matchings/boot/sinf/sinf.s,sinf,0x80088350,0x70 asm/non_matchings/boot/sins/sins.s,sins,0x80088510,0x1C asm/non_matchings/boot/sptask/_VirtualToPhysicalTask.s,_VirtualToPhysicalTask,0x80088580,0x43 asm/non_matchings/boot/sptask/osSpTaskLoad.s,osSpTaskLoad,0x8008868C,0x5A @@ -407,7 +407,7 @@ asm/non_matchings/boot/interrupt/__osRestoreInt.s,__osRestoreInt,0x80091AD0,0x8 asm/non_matchings/boot/vi/__osViInit.s,__osViInit,0x80091AF0,0x48 asm/non_matchings/boot/viswapcontext/__osViSwapContext.s,__osViSwapContext,0x80091C10,0xC0 asm/non_matchings/boot/pigetcmdq/osPiGetCmdQueue.s,osPiGetCmdQueue,0x80091F10,0xC -asm/non_matchings/boot/cosf/__cosf.s,__cosf,0x80091F40,0x5C +asm/non_matchings/boot/cosf/cosf.s,cosf,0x80091F40,0x5C asm/non_matchings/boot/epiread/osEPiReadIo.s,osEPiReadIo,0x800920B0,0x14 asm/non_matchings/boot/visetspecial/osViSetSpecialFeatures.s,osViSetSpecialFeatures,0x80092100,0x58 asm/non_matchings/boot/coss/coss.s,coss,0x80092260,0xC diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 2989dbfb6..5b7c0d71d 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2868,45 +2868,45 @@ asm/non_matchings/code/sys_math_atan/Math_Atan2S.s,Math_Atan2S,0x8017FEE4,0x7A asm/non_matchings/code/sys_math_atan/Math_Atan2F.s,Math_Atan2F,0x801800CC,0xD asm/non_matchings/code/sys_math_atan/Math_FAtan2F.s,Math_FAtan2F,0x80180100,0xB asm/non_matchings/code/sys_math_atan/Math_Acot2F.s,Math_Acot2F,0x8018012C,0xD -asm/non_matchings/code/sys_matrix/Matrix_StateAlloc.s,Matrix_StateAlloc,0x80180160,0xF -asm/non_matchings/code/sys_matrix/Matrix_StatePush.s,Matrix_StatePush,0x8018019C,0xC -asm/non_matchings/code/sys_matrix/Matrix_StatePop.s,Matrix_StatePop,0x801801CC,0x7 -asm/non_matchings/code/sys_matrix/Matrix_CopyCurrentState.s,Matrix_CopyCurrentState,0x801801E8,0x9 -asm/non_matchings/code/sys_matrix/Matrix_SetCurrentState.s,Matrix_SetCurrentState,0x8018020C,0xA -asm/non_matchings/code/sys_matrix/Matrix_GetCurrentState.s,Matrix_GetCurrentState,0x80180234,0x4 -asm/non_matchings/code/sys_matrix/Matrix_InsertMatrix.s,Matrix_InsertMatrix,0x80180244,0x16 -asm/non_matchings/code/sys_matrix/Matrix_InsertTranslation.s,Matrix_InsertTranslation,0x8018029C,0x40 +asm/non_matchings/code/sys_matrix/Matrix_Init.s,Matrix_Init,0x80180160,0xF +asm/non_matchings/code/sys_matrix/Matrix_Push.s,Matrix_Push,0x8018019C,0xC +asm/non_matchings/code/sys_matrix/Matrix_Pop.s,Matrix_Pop,0x801801CC,0x7 +asm/non_matchings/code/sys_matrix/Matrix_Get.s,Matrix_Get,0x801801E8,0x9 +asm/non_matchings/code/sys_matrix/Matrix_Put.s,Matrix_Put,0x8018020C,0xA +asm/non_matchings/code/sys_matrix/Matrix_GetCurrent.s,Matrix_GetCurrent,0x80180234,0x4 +asm/non_matchings/code/sys_matrix/Matrix_Mult.s,Matrix_Mult,0x80180244,0x16 +asm/non_matchings/code/sys_matrix/Matrix_Translate.s,Matrix_Translate,0x8018029C,0x40 asm/non_matchings/code/sys_matrix/Matrix_Scale.s,Matrix_Scale,0x8018039C,0x37 -asm/non_matchings/code/sys_matrix/Matrix_InsertXRotation_s.s,Matrix_InsertXRotation_s,0x80180478,0x66 -asm/non_matchings/code/sys_matrix/Matrix_InsertXRotation_f.s,Matrix_InsertXRotation_f,0x80180610,0x6A -asm/non_matchings/code/sys_matrix/Matrix_RotateStateAroundXAxis.s,Matrix_RotateStateAroundXAxis,0x801807B8,0x52 -asm/non_matchings/code/sys_matrix/Matrix_SetStateXRotation.s,Matrix_SetStateXRotation,0x80180900,0x2B -asm/non_matchings/code/sys_matrix/Matrix_RotateY.s,Matrix_RotateY,0x801809AC,0x67 -asm/non_matchings/code/sys_matrix/Matrix_InsertYRotation_f.s,Matrix_InsertYRotation_f,0x80180B48,0x6C -asm/non_matchings/code/sys_matrix/Matrix_InsertZRotation_s.s,Matrix_InsertZRotation_s,0x80180CF8,0x66 -asm/non_matchings/code/sys_matrix/Matrix_InsertZRotation_f.s,Matrix_InsertZRotation_f,0x80180E90,0x6B -asm/non_matchings/code/sys_matrix/Matrix_InsertRotation.s,Matrix_InsertRotation,0x8018103C,0xB0 +asm/non_matchings/code/sys_matrix/Matrix_RotateXS.s,Matrix_RotateXS,0x80180478,0x66 +asm/non_matchings/code/sys_matrix/Matrix_RotateXF.s,Matrix_RotateXF,0x80180610,0x6A +asm/non_matchings/code/sys_matrix/Matrix_RotateXFApply.s,Matrix_RotateXFApply,0x801807B8,0x52 +asm/non_matchings/code/sys_matrix/Matrix_RotateXFNew.s,Matrix_RotateXFNew,0x80180900,0x2B +asm/non_matchings/code/sys_matrix/Matrix_RotateYS.s,Matrix_RotateYS,0x801809AC,0x67 +asm/non_matchings/code/sys_matrix/Matrix_RotateYF.s,Matrix_RotateYF,0x80180B48,0x6C +asm/non_matchings/code/sys_matrix/Matrix_RotateZS.s,Matrix_RotateZS,0x80180CF8,0x66 +asm/non_matchings/code/sys_matrix/Matrix_RotateZF.s,Matrix_RotateZF,0x80180E90,0x6B +asm/non_matchings/code/sys_matrix/Matrix_RotateZYX.s,Matrix_RotateZYX,0x8018103C,0xB0 asm/non_matchings/code/sys_matrix/Matrix_RotateAndTranslateState.s,Matrix_RotateAndTranslateState,0x801812FC,0xD5 -asm/non_matchings/code/sys_matrix/Matrix_SetStateRotationAndTranslation.s,Matrix_SetStateRotationAndTranslation,0x80181650,0x6B -asm/non_matchings/code/sys_matrix/Matrix_ToRSPMatrix.s,Matrix_ToRSPMatrix,0x801817FC,0x87 -asm/non_matchings/code/sys_matrix/Matrix_GetStateAsRSPMatrix.s,Matrix_GetStateAsRSPMatrix,0x80181A18,0xA +asm/non_matchings/code/sys_matrix/Matrix_SetTranslateRotateYXZ.s,Matrix_SetTranslateRotateYXZ,0x80181650,0x6B +asm/non_matchings/code/sys_matrix/Matrix_MtxFToMtx.s,Matrix_MtxFToMtx,0x801817FC,0x87 +asm/non_matchings/code/sys_matrix/Matrix_ToMtx.s,Matrix_ToMtx,0x80181A18,0xA asm/non_matchings/code/sys_matrix/Matrix_NewMtx.s,Matrix_NewMtx,0x80181A40,0xB -asm/non_matchings/code/sys_matrix/Matrix_AppendToPolyOpaDisp.s,Matrix_AppendToPolyOpaDisp,0x80181A6C,0xB -asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fByState.s,Matrix_MultiplyVector3fByState,0x80181A98,0x2E -asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslation.s,Matrix_GetStateTranslation,0x80181B50,0xA -asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledX.s,Matrix_GetStateTranslationAndScaledX,0x80181B78,0x13 -asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledY.s,Matrix_GetStateTranslationAndScaledY,0x80181BC4,0x13 -asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledZ.s,Matrix_GetStateTranslationAndScaledZ,0x80181C10,0x13 -asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fXZByCurrentState.s,Matrix_MultiplyVector3fXZByCurrentState,0x80181C5C,0x20 +asm/non_matchings/code/sys_matrix/Matrix_MtxFToNewMtx.s,Matrix_MtxFToNewMtx,0x80181A6C,0xB +asm/non_matchings/code/sys_matrix/Matrix_MultVec3f.s,Matrix_MultVec3f,0x80181A98,0x2E +asm/non_matchings/code/sys_matrix/Matrix_MultZero.s,Matrix_MultZero,0x80181B50,0xA +asm/non_matchings/code/sys_matrix/Matrix_MultVecX.s,Matrix_MultVecX,0x80181B78,0x13 +asm/non_matchings/code/sys_matrix/Matrix_MultVecY.s,Matrix_MultVecY,0x80181BC4,0x13 +asm/non_matchings/code/sys_matrix/Matrix_MultVecZ.s,Matrix_MultVecZ,0x80181C10,0x13 +asm/non_matchings/code/sys_matrix/Matrix_MultVec3fXZ.s,Matrix_MultVec3fXZ,0x80181C5C,0x20 asm/non_matchings/code/sys_matrix/Matrix_MtxFCopy.s,Matrix_MtxFCopy,0x80181CDC,0x22 -asm/non_matchings/code/sys_matrix/Matrix_FromRSPMatrix.s,Matrix_FromRSPMatrix,0x80181D64,0x95 -asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fByMatrix.s,Matrix_MultiplyVector3fByMatrix,0x80181FB8,0x2C -asm/non_matchings/code/sys_matrix/Matrix_TransposeXYZ.s,Matrix_TransposeXYZ,0x80182068,0xE -asm/non_matchings/code/sys_matrix/Matrix_NormalizeXYZ.s,Matrix_NormalizeXYZ,0x801820A0,0x3F -asm/non_matchings/code/sys_matrix/func_8018219C.s,func_8018219C,0x8018219C,0x4A -asm/non_matchings/code/sys_matrix/func_801822C4.s,func_801822C4,0x801822C4,0x4A -asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_f.s,Matrix_InsertRotationAroundUnitVector_f,0x801823EC,0x118 -asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_s.s,Matrix_InsertRotationAroundUnitVector_s,0x8018284C,0x111 +asm/non_matchings/code/sys_matrix/Matrix_MtxToMtxF.s,Matrix_MtxToMtxF,0x80181D64,0x95 +asm/non_matchings/code/sys_matrix/Matrix_MultVec3fExt.s,Matrix_MultVec3fExt,0x80181FB8,0x2C +asm/non_matchings/code/sys_matrix/Matrix_Transpose.s,Matrix_Transpose,0x80182068,0xE +asm/non_matchings/code/sys_matrix/Matrix_ReplaceRotation.s,Matrix_ReplaceRotation,0x801820A0,0x3F +asm/non_matchings/code/sys_matrix/Matrix_MtxFToYXZRot.s,Matrix_MtxFToYXZRot,0x8018219C,0x4A +asm/non_matchings/code/sys_matrix/Matrix_MtxFToZYXRot.s,Matrix_MtxFToZYXRot,0x801822C4,0x4A +asm/non_matchings/code/sys_matrix/Matrix_RotateAxisF.s,Matrix_RotateAxisF,0x801823EC,0x118 +asm/non_matchings/code/sys_matrix/Matrix_RotateAxisS.s,Matrix_RotateAxisS,0x8018284C,0x111 asm/non_matchings/code/sys_ucode/SysUcode_GetUCodeBoot.s,SysUcode_GetUCodeBoot,0x80182C90,0x4 asm/non_matchings/code/sys_ucode/SysUcode_GetUCodeBootSize.s,SysUcode_GetUCodeBootSize,0x80182CA0,0x7 asm/non_matchings/code/sys_ucode/SysUcode_GetUCode.s,SysUcode_GetUCode,0x80182CBC,0x4 From ec43a32c2677dbaea2f4332ba5a624ec7759b711 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Sat, 18 Jun 2022 10:33:59 -0400 Subject: [PATCH 225/257] z_en_box.c, z_demo_tre_lgt.c OK, some object_box documentation (#703) * All functions attempted, 2 NON_MATCHINGs * z_en_box OK, more documentation * format * en_box cleanups, fix GI item table * z_demo_tre_lgt OK * format.sh * pr suggestions 1 * object_box improvements * Merge remote-tracking branch 'origin/master' into z_en_box * Revert "Merge remote-tracking branch 'origin/master' into z_en_box" This reverts commit 5aacdf26e49c91fadc6f50dc2b9e19935a8f3ec4. * more suggested changes * fix comment --- assets/xml/objects/object_box.xml | 87 +-- include/functions.h | 2 +- include/z64item.h | 30 +- spec | 6 +- src/code/z_actor.c | 15 +- .../actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c | 145 +++- .../actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h | 14 +- src/overlays/actors/ovl_En_Box/z_en_box.c | 693 +++++++++++++++++- src/overlays/actors/ovl_En_Box/z_en_box.h | 62 +- src/overlays/actors/ovl_En_GirlA/z_en_girla.c | 90 +-- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 2 +- src/overlays/actors/ovl_En_Tsn/z_en_tsn.c | 2 +- src/overlays/actors/ovl_En_Zow/z_en_zow.c | 2 +- tools/disasm/functions.txt | 44 +- tools/disasm/variables.txt | 4 +- 15 files changed, 1006 insertions(+), 192 deletions(-) diff --git a/assets/xml/objects/object_box.xml b/assets/xml/objects/object_box.xml index fb1fb3fd5..85e788633 100644 --- a/assets/xml/objects/object_box.xml +++ b/assets/xml/objects/object_box.xml @@ -1,52 +1,53 @@  - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/include/functions.h b/include/functions.h index b4ff2ad8d..a29024850 100644 --- a/include/functions.h +++ b/include/functions.h @@ -794,7 +794,7 @@ void func_800BE3D0(Actor* actor, s16 angle, Vec3s* arg2); void func_800BE504(Actor* actor, ColliderCylinder* collider); void func_800BE568(Actor* actor, ColliderSphere* collider); void func_800BE5CC(Actor* actor, ColliderJntSph* collider, s32 colliderIndex); -s32 func_800BE63C(struct EnBox* chest); +s32 Actor_IsSmallChest(struct EnBox* chest); void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 limbPosCount, f32 effectScale, f32 frozenSteamScale, f32 effectAlpha, u8 type); void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s32 limbPosCount, s32 effectsPerLimb, f32 scale, f32 scaleRange); diff --git a/include/z64item.h b/include/z64item.h index 785d56577..2281ded92 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -279,6 +279,7 @@ typedef enum { /* 0x0A */ GI_RECOVERY_HEART, /* 0x0C */ GI_HEART_PIECE = 0x0C, /* 0x0D */ GI_HEART_CONTAINER, + /* 0x11 */ GI_STRAY_FAIRY = 0x11, /* 0x16 */ GI_BOMBS_10 = 0x16, /* 0x19 */ GI_STICKS_1 = 0x19, /* 0x1A */ GI_BOMBCHUS_10, @@ -298,22 +299,25 @@ typedef enum { /* 0x33 */ GI_SHIELD_MIRROR, /* 0x35 */ GI_MAGIC_BEANS = 0x35, /* 0x3C */ GI_KEY_SMALL = 0x3C, - /* 0x3E */ GI_MAP = 0x3E, + /* 0x3D */ GI_KEY_BOSS, + /* 0x3E */ GI_MAP, /* 0x3F */ GI_COMPASS, /* 0x50 */ GI_50 = 0x50, /* 0x52 */ GI_SCALE_GOLD = 0x52, // Assumed, used in En_Fishing /* 0x59 */ GI_BOTTLE_POTION_RED = 0x59, - /* 0x5B */ GI_POTION_RED = 0x5B, + /* 0x5A */ GI_BOTTLE, + /* 0x5B */ GI_POTION_RED, /* 0x5C */ GI_POTION_GREEN, /* 0x5D */ GI_POTION_BLUE, /* 0x5E */ GI_FAIRY, /* 0x60 */ GI_MILK_BOTTLE = 0x60, + /* 0x76 */ GI_ICE_TRAP = 0x76, /* 0x78 */ GI_MASK_DEKU = 0x78, /* 0x79 */ GI_MASK_GORON, /* 0x7A */ GI_MASK_ZORA, /* 0x7B */ GI_MASK_FIERCE_DEITY, - /* 0x7C */ GI_MASK_TRUTH, - /* 0x7D */ GI_MASK_KAFEIS_MASK, + /* 0x7C */ GI_MASK_CAPTAIN, + /* 0x7D */ GI_MASK_GIANT, /* 0x7E */ GI_MASK_ALL_NIGHT, /* 0x7F */ GI_MASK_BUNNY, /* 0x80 */ GI_MASK_KEATON, @@ -326,27 +330,31 @@ typedef enum { /* 0x87 */ GI_MASK_GIBDO, /* 0x88 */ GI_MASK_DON_GERO, /* 0x89 */ GI_MASK_KAMARO, - /* 0x8A */ GI_MASK_CAPTAIN, + /* 0x8A */ GI_MASK_TRUTH, /* 0x8B */ GI_MASK_STONE, /* 0x8C */ GI_MASK_BREMEN, /* 0x8D */ GI_MASK_BLAST, /* 0x8E */ GI_MASK_SCENTS, - /* 0x8F */ GI_MASK_GIANT, - /* 0x92 */ GI_MILK = 0x92, - /* 0x95 */ GI_95 = 0x95, + /* 0x8F */ GI_MASK_KAFEIS_MASK, + /* 0x91 */ GI_CHATEAU = 0x91, + /* 0x92 */ GI_MILK, + /* 0x93 */ GI_GOLD_DUST, + /* 0x94 */ GI_EEL, // Unused bottled eel + /* 0x95 */ GI_SEAHORSE, /* 0x96 */ GI_MOON_TEAR, /* 0x97 */ GI_DEED_LAND, /* 0x98 */ GI_DEED_SWAMP, /* 0x99 */ GI_DEED_MOUNTAIN, /* 0x9A */ GI_DEED_OCEAN, - /* 0x9B */ GI_SWORD_GREAT_FAIRY = 0x9B, + /* 0x9B */ GI_SWORD_GREAT_FAIRY, /* 0x9C */ GI_SWORD_KOKIRI, /* 0x9D */ GI_SWORD_RAZOR, /* 0x9E */ GI_SWORD_GILDED, /* 0x9F */ GI_SHIELD_HERO_2, // Code that treats this as hero's shield is unused, so take with a grain of salt /* 0xA1 */ GI_LETTER_TO_MAMA = 0xA1, - /* 0xA9 */ GI_BOTTLE = 0xA9, - /* 0xAB */ GI_PENDANT_OF_MEMORIES = 0xAB, + /* 0xA9 */ GI_BOTTLE_STOLEN = 0xA9, // buy back stolen bottle + /* 0xAA */ GI_LETTER_TO_KAFEI, + /* 0xAB */ GI_PENDANT_OF_MEMORIES, /* 0xBA */ GI_MAX = 0xBA } GetItemID; diff --git a/spec b/spec index 273170579..d0351563a 100644 --- a/spec +++ b/spec @@ -768,8 +768,7 @@ beginseg name "ovl_En_Box" compress include "build/src/overlays/actors/ovl_En_Box/z_en_box.o" - include "build/data/ovl_En_Box/ovl_En_Box.data.o" - include "build/data/ovl_En_Box/ovl_En_Box.reloc.o" + include "build/src/overlays/actors/ovl_En_Box/ovl_En_Box_reloc.o" endseg beginseg @@ -1193,8 +1192,7 @@ beginseg name "ovl_Demo_Tre_Lgt" compress include "build/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.o" - include "build/data/ovl_Demo_Tre_Lgt/ovl_Demo_Tre_Lgt.data.o" - include "build/data/ovl_Demo_Tre_Lgt/ovl_Demo_Tre_Lgt.reloc.o" + include "build/src/overlays/actors/ovl_Demo_Tre_Lgt/ovl_Demo_Tre_Lgt_reloc.o" endseg beginseg diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 6d0b9573d..9325d315c 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -2003,11 +2003,11 @@ s32 Actor_PickUp(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRa if (!(player->stateFlags1 & 0x3C7080) && Player_GetExplosiveHeld(player) < 0) { if ((actor->xzDistToPlayer <= xzRange) && (fabsf(actor->playerHeightRel) <= fabsf(yRange))) { - if (((getItemId == GI_MASK_CIRCUS_LEADER) || (getItemId == GI_PENDANT_OF_MEMORIES) || - (getItemId == GI_DEED_LAND) || - (((player->heldActor != NULL) || (actor == player->targetActor)) && + if ((getItemId == GI_MASK_CIRCUS_LEADER || getItemId == GI_PENDANT_OF_MEMORIES || + getItemId == GI_DEED_LAND || + ((player->heldActor != NULL || actor == player->targetActor) && (getItemId > GI_NONE && getItemId < GI_MAX))) || - (!(player->stateFlags1 & 0x20000800))) { + !(player->stateFlags1 & 0x20000800)) { s16 yawDiff = actor->yawTowardsPlayer - player->actor.shape.rot.y; s32 absYawDiff = ABS_ALT(yawDiff); @@ -4482,9 +4482,10 @@ void func_800BE5CC(Actor* actor, ColliderJntSph* collider, s32 colliderIndex) { } } -s32 func_800BE63C(struct EnBox* chest) { - if ((chest->unk_1F1 == 5) || (chest->unk_1F1 == 6) || (chest->unk_1F1 == 7) || (chest->unk_1F1 == 8) || - (chest->unk_1F1 == 0xC)) { +s32 Actor_IsSmallChest(struct EnBox* chest) { + if (chest->type == ENBOX_TYPE_SMALL || chest->type == ENBOX_TYPE_SMALL_INVISIBLE || + chest->type == ENBOX_TYPE_SMALL_ROOM_CLEAR || chest->type == ENBOX_TYPE_SMALL_SWITCH_FLAG_FALL || + chest->type == ENBOX_TYPE_SMALL_SWITCH_FLAG) { return true; } return false; diff --git a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c index 060a201d7..6d921c4c6 100644 --- a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c +++ b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c @@ -5,6 +5,8 @@ */ #include "z_demo_tre_lgt.h" +#include "overlays/actors/ovl_En_Box/z_en_box.h" +#include "objects/object_box/object_box.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +17,24 @@ void DemoTreLgt_Destroy(Actor* thisx, GlobalContext* globalCtx); void DemoTreLgt_Update(Actor* thisx, GlobalContext* globalCtx); void DemoTreLgt_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void DemoTreLgt_SetupWait(DemoTreLgt* this); + +void DemoTreLgt_Wait(DemoTreLgt* this, GlobalContext* globalCtx); +void DemoTreLgt_SetupAnimate(DemoTreLgt* this, GlobalContext* globalCtx, f32 frame); +void DemoTreLgt_Animate(DemoTreLgt* this, GlobalContext* globalCtx); + +typedef struct { + f32 unk0; + f32 unk4; + f32 unk8; + f32 unkC; +} DemoTreLgtInfo; + +static DemoTreLgtInfo D_808E1490[2] = { + { 1.0f, 136.0f, 190.0f, 40.0f }, + { 1.0f, 136.0f, 220.0f, 50.0f }, +}; + const ActorInit Demo_Tre_Lgt_InitVars = { ACTOR_DEMO_TRE_LGT, ACTORCAT_ITEMACTION, @@ -28,24 +47,126 @@ const ActorInit Demo_Tre_Lgt_InitVars = { (ActorFunc)DemoTreLgt_Draw, }; -#endif +static TransformUpdateIndex* sBoxLightAnimations[] = { + &gBoxLightAdultCurveAnim, + &gBoxLightChildCurveAnim, +}; -extern UNK_TYPE D_06007D78; +static DemoTreLgtActionFunc sActionFuncs[] = { + DemoTreLgt_Wait, + DemoTreLgt_Animate, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/DemoTreLgt_Init.s") +void DemoTreLgt_Init(Actor* thisx, GlobalContext* globalCtx) { + DemoTreLgt* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/DemoTreLgt_Destroy.s") + SkelCurve_Init(globalCtx, &this->skelCurve, &gBoxLightCurveSkel, sBoxLightAnimations[0]); + this->colorAlpha1 = 255; + this->colorAlpha2 = 255; + this->status = 0; + //! @bug Zora Link should also use animationType 0 + if (gSaveContext.save.playerForm == PLAYER_FORM_FIERCE_DEITY) { + this->animationType = 0; + } else { + this->animationType = 1; + } + DemoTreLgt_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/func_808E0EE8.s") +void DemoTreLgt_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DemoTreLgt* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/func_808E0EF4.s") + SkelCurve_Destroy(globalCtx, &this->skelCurve); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/func_808E0F4C.s") +void DemoTreLgt_SetupWait(DemoTreLgt* this) { + this->action = DEMO_TRE_LGT_ACTION_WAIT; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/func_808E0FE0.s") +void DemoTreLgt_Wait(DemoTreLgt* this, GlobalContext* globalCtx) { + EnBox* chest = (EnBox*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/DemoTreLgt_Update.s") + if (chest != NULL) { + if (Animation_OnFrame(&chest->skelAnime, 10.0f)) { + DemoTreLgt_SetupAnimate(this, globalCtx, chest->skelAnime.curFrame); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/func_808E12A4.s") +void DemoTreLgt_SetupAnimate(DemoTreLgt* this, GlobalContext* globalCtx, f32 frame) { + this->action = DEMO_TRE_LGT_ACTION_ANIMATE; + SkelCurve_SetAnim(&this->skelCurve, sBoxLightAnimations[this->animationType], 1.0f, + D_808E1490[this->animationType].unk4 + D_808E1490[this->animationType].unk8, frame, 1.0f); + SkelCurve_Update(globalCtx, &this->skelCurve); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Tre_Lgt/DemoTreLgt_Draw.s") +void DemoTreLgt_Animate(DemoTreLgt* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelCurve.animCurFrame; + + if (curFrame < D_808E1490[this->animationType].unk4) { + this->colorAlpha1 = 255; + } else if (curFrame <= (D_808E1490[this->animationType].unk4 + D_808E1490[this->animationType].unk8)) { + this->colorAlpha1 = + ((D_808E1490[this->animationType].unk4 - curFrame) / D_808E1490[this->animationType].unk8) * 255 + 255; + } else { + this->colorAlpha1 = 0; + } + + if (curFrame < D_808E1490[this->animationType].unkC) { + this->colorAlpha2 = 255; + } else if (curFrame < (D_808E1490[this->animationType].unkC + 10.0f)) { + this->colorAlpha2 = ((D_808E1490[this->animationType].unkC - curFrame) / 10.0f) * 255 + 255; + } else { + this->colorAlpha2 = 0; + } + if (curFrame > 30.0f) { + if (!(this->status & 1)) { + this->status |= 1; + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_TRE_BOX_FLASH); + } + } + if (SkelCurve_Update(globalCtx, &this->skelCurve)) { + Actor_MarkForDeath(&this->actor); + } +} + +void DemoTreLgt_Update(Actor* thisx, GlobalContext* globalCtx) { + DemoTreLgt* this = THIS; + + sActionFuncs[this->action](this, globalCtx); +} + +s32 DemoTreLgt_OverrideLimbDraw(GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, Actor* thisx) { + s32 pad; + DemoTreLgt* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (globalCtx->state.frames * 2) % 256, 0, 64, 32, 1, + (globalCtx->state.frames * -2) % 256, 0, 64, 32)); + + if (limbIndex == OBJECT_BOX_LIGHT_LIMB_01) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 180, this->colorAlpha1); + } else if (limbIndex == OBJECT_BOX_LIGHT_LIMB_13 || limbIndex == OBJECT_BOX_LIGHT_LIMB_07 || + limbIndex == OBJECT_BOX_LIGHT_LIMB_04 || limbIndex == OBJECT_BOX_LIGHT_LIMB_10) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 180, this->colorAlpha2); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + return true; +} + +void DemoTreLgt_Draw(Actor* thisx, GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + DemoTreLgt* this = THIS; + + OPEN_DISPS(gfxCtx); + if (this->action == DEMO_TRE_LGT_ACTION_ANIMATE) { + func_8012C2DC(gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 0, 0); + SkelCurve_Draw(&this->actor, globalCtx, &this->skelCurve, DemoTreLgt_OverrideLimbDraw, NULL, 1, &this->actor); + } + CLOSE_DISPS(gfxCtx); +} diff --git a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h index 07e2a9bc8..08677b803 100644 --- a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h +++ b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h @@ -5,11 +5,23 @@ struct DemoTreLgt; +typedef void (*DemoTreLgtActionFunc)(struct DemoTreLgt* this, GlobalContext* globalCtx); + typedef struct DemoTreLgt { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x34]; + /* 0x144 */ SkelAnimeCurve skelCurve; + /* 0x164 */ s32 action; + /* 0x168 */ u32 colorAlpha1; + /* 0x16C */ u32 colorAlpha2; + /* 0x170 */ u8 status; + /* 0x174 */ s32 animationType; } DemoTreLgt; // size = 0x178 +typedef enum { + /* 0x00 */ DEMO_TRE_LGT_ACTION_WAIT, // wait until animation is needed + /* 0x01 */ DEMO_TRE_LGT_ACTION_ANIMATE +} DemoTreLgtAction; + extern const ActorInit Demo_Tre_Lgt_InitVars; #endif // Z_DEMO_TRE_LGT_H diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.c b/src/overlays/actors/ovl_En_Box/z_en_box.c index 7367f49bc..1259df33e 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -5,9 +5,39 @@ */ #include "z_en_box.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_box/object_box.h" +#include "overlays/actors/ovl_En_Elforg/z_en_elforg.h" #define FLAGS 0x00000000 +/* +set on init unless treasure flag is set +if clear, chest moves (Actor_MoveForward) (falls, likely) +ends up cleared from SWITCH_FLAG_FALL types when switch flag is set +*/ +#define ENBOX_MOVE_IMMOBILE (1 << 0) +/* +set in the logic for SWITCH_FLAG_FALL types +otherwise unused +*/ +#define ENBOX_MOVE_UNUSED (1 << 1) +/* +set with 50% chance on init for SWITCH_FLAG_FALL types +only used for SWITCH_FLAG_FALL types +ends up "blinking" (set/clear every frame) once switch flag is set, +if some collision-related condition (?) is met +only used for signum of z rotation +*/ +#define ENBOX_MOVE_FALL_ANGLE_SIDE (1 << 2) +/* +when set, gets cleared next EnBox_Update call and clip to the floor +*/ +#define ENBOX_MOVE_STICK_TO_GROUND (1 << 4) +#define ENBOX_MOVE_0x20 (1 << 5) +#define ENBOX_MOVE_0x40 (1 << 6) +#define ENBOX_MOVE_0x80 (1 << 7) + #define THIS ((EnBox*)thisx) void EnBox_Init(Actor* thisx, GlobalContext* globalCtx); @@ -15,7 +45,17 @@ void EnBox_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBox_Update(Actor* thisx, GlobalContext* globalCtx); void EnBox_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnBox_FallOnSwitchFlag(EnBox* this, GlobalContext* globalCtx); +void EnBox_AppearSwitchFlag(EnBox* this, GlobalContext* globalCtx); +void EnBox_AppearOnRoomClear(EnBox* this, GlobalContext* globalCtx); +void func_80868AFC(EnBox* this, GlobalContext* globalCtx); +void func_80868B74(EnBox* this, GlobalContext* globalCtx); +void EnBox_WaitOpen(EnBox* this, GlobalContext* globalCtx); +void EnBox_Open(EnBox* this, GlobalContext* globalCtx); + +void func_80867FBC(func_80867BDC_a0* arg0, GlobalContext* globalCtx, s32 arg2); +void func_80867FE4(func_80867BDC_a0* arg0, GlobalContext* globalCtx); + const ActorInit En_Box_InitVars = { ACTOR_EN_BOX, ACTORCAT_CHEST, @@ -28,66 +68,653 @@ const ActorInit En_Box_InitVars = { (ActorFunc)EnBox_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80869B50[] = { +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 0, ICHAIN_STOP), }; -#endif +typedef struct { + f32 data[5]; +} EnBox_PlaybackSpeed; // 0x14 -extern InitChainEntry D_80869B50[]; +static EnBox_PlaybackSpeed sPlaybackSpeed = { { 1.5f, 1.0f, 1.5f, 1.0f, 1.5f } }; -extern UNK_TYPE D_0600043C; -extern UNK_TYPE D_06000DB0; +static AnimationHeader* sBigChestAnimations[5] = { + &gBoxBigChestOpenAdultAnim, &gBoxBigChestOpenGoronAnim, &gBoxBigChestOpenAdultAnim, + &gBoxBigChestOpenDekuAnim, &gBoxBigChestOpenChildAnim, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867BD0.s") +void EnBox_SetupAction(EnBox* this, EnBoxActionFunc func) { + this->actionFunc = func; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867BDC.s") +void func_80867BDC(func_80867BDC_a0* arg0, GlobalContext* globalCtx, Vec3f* pos) { + arg0->pos = *pos; + arg0->unk_0C = NULL; + arg0->unk_10 = NULL; + arg0->unk_14 = 0; + arg0->unk_18 = 0; + arg0->unk_1C = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867C14.s") +void func_80867C14(func_80867BDC_a0* arg0, GlobalContext* globalCtx) { + arg0->unk_18++; + if (arg0->unk_18 > 85) { + arg0->unk_18 = 85; + } + if (arg0->unk_18 != 85) { + arg0->unk_1C = arg0->unk_18 - 28; + if (arg0->unk_18 - 28 < 0) { + arg0->unk_1C = 0; + } + } else { + arg0->unk_1C++; + if (arg0->unk_1C > 85) { + func_80867FE4(arg0, globalCtx); + } + } + arg0->unk_14++; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867C8C.s") +void func_80867C8C(func_80867BDC_a0* arg0, GlobalContext* globalCtx) { + s32 temp_s6 = arg0->unk_18 - arg0->unk_1C; + s32 i; + f32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867FBC.s") + if (temp_s6 > 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + Matrix_Push(); + for (i = 0; i < temp_s6; i++) { + f32 temp_f0 = (f32)i / temp_s6; + s16 temp_s0 = ((f32)arg0->unk_18 - arg0->unk_1C) * temp_f0 + arg0->unk_1C; + f32 temp_f24 = 1.0f - (temp_s0 * 0.011764706f); + f32 temp_f26 = Rand_ZeroOne() * 0.03f * temp_f0 * temp_f24; + f32 temp_f28; + f32 temp_f30 = Math_SinS(temp_s0 * 0x9A6) * 45.0f + arg0->pos.x; + f32 phi_f24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80867FE4.s") + if (arg0->unk_20 != 0) { + phi_f24 = arg0->pos.y - (0.03f * temp_s0) - (0.01f * temp_s0 * temp_s0); + } else { + phi_f24 = arg0->pos.y + (0.03f * temp_s0) + (0.01f * temp_s0 * temp_s0); + } + temp_f28 = (Math_CosS(temp_s0 * 0x9A6) * 45.0f) + arg0->pos.z; + Matrix_Translate(2.0f * Rand_Centered() + temp_f30, 2.0f * Rand_Centered() + phi_f24, + 2.0f * Rand_Centered() + temp_f28, MTXMODE_NEW); + Matrix_Scale(temp_f26, temp_f26, temp_f26, MTXMODE_APPLY); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + } + Matrix_Pop(); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_8086800C.s") +void func_80867FBC(func_80867BDC_a0* arg0, GlobalContext* globalCtx, s32 arg2) { + arg0->unk_0C = func_80867C14; + arg0->unk_10 = func_80867C8C; + arg0->unk_20 = arg2; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/EnBox_Init.s") +void func_80867FE4(func_80867BDC_a0* arg0, GlobalContext* globalCtx) { + arg0->unk_0C = NULL; + arg0->unk_10 = NULL; + func_80867BDC(arg0, globalCtx, &arg0->pos); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/EnBox_Destroy.s") +void EnBox_ClipToGround(EnBox* this, GlobalContext* globalCtx) { + s32 pad; + CollisionPoly* poly; + s32 bgId; + Vec3f pos; + f32 floorHeight; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868630.s") + if (!(this->movementFlags & ENBOX_MOVE_0x80)) { + pos = this->dyna.actor.world.pos; + pos.y += 1.0f; + floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &poly, &bgId, &this->dyna.actor, &pos); + if (floorHeight != BGCHECK_Y_MIN) { + this->dyna.actor.world.pos.y = floorHeight; + this->dyna.actor.floorHeight = floorHeight; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868734.s") +void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { + s16 cutsceneIdx; + EnBox* this = (EnBox*)thisx; + s32 pad; + CollisionHeader* colHeader; + f32 animFrame; + f32 animFrameEnd; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_808687E8.s") + colHeader = NULL; + animFrame = 0.0f; + animFrameEnd = Animation_GetLastFrame(&gBoxChestOpenAnim); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&gBoxChestCol, &colHeader); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868944.s") + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + this->movementFlags = 0; + this->type = ENBOX_GET_TYPE(&this->dyna.actor); + this->iceSmokeTimer = 0; + this->unk_1F3 = 0; + this->dyna.actor.gravity = -5.5f; + this->dyna.actor.terminalVelocity = -50.0f; + this->switchFlag = ENBOX_GET_SWITCH_FLAG(&this->dyna.actor); + this->dyna.actor.floorHeight = this->dyna.actor.world.pos.y; + if (this->dyna.actor.world.rot.x == 180) { + this->movementFlags |= ENBOX_MOVE_0x80; + this->dyna.actor.world.rot.x = 0x7FFF; + this->collectableFlag = 0; + } else { + func_800C636C(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->collectableFlag = (this->dyna.actor.world.rot.x & 0x7F); + this->dyna.actor.world.rot.x = 0; + } + thisx->shape.rot.x = this->dyna.actor.world.rot.x; + this->getItem = ENBOX_GET_ITEM(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_808689E8.s") + if (Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor)) || this->getItem == GI_NONE) { + this->alpha = 255; + this->iceSmokeTimer = 100; + EnBox_SetupAction(this, EnBox_Open); + this->movementFlags |= ENBOX_MOVE_STICK_TO_GROUND; + animFrame = animFrameEnd; + } else if ((this->type == ENBOX_TYPE_BIG_SWITCH_FLAG_FALL || this->type == ENBOX_TYPE_SMALL_SWITCH_FLAG_FALL) && + !Flags_GetSwitch(globalCtx, this->switchFlag)) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if (Rand_ZeroOne() < 0.5f) { + this->movementFlags |= ENBOX_MOVE_FALL_ANGLE_SIDE; + } + this->unk_1A0 = -12; + EnBox_SetupAction(this, EnBox_FallOnSwitchFlag); + this->alpha = 0; + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + this->dyna.actor.flags |= ACTOR_FLAG_10; + } else if ((this->type == ENBOX_TYPE_BIG_ROOM_CLEAR || this->type == ENBOX_TYPE_SMALL_ROOM_CLEAR) && + !Flags_GetClear(globalCtx, this->dyna.actor.room)) { + EnBox_SetupAction(this, EnBox_AppearOnRoomClear); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if (this->movementFlags & ENBOX_MOVE_0x80) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 50.0f; + } else { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 50.0f; + } + this->alpha = 0; + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + this->dyna.actor.flags |= ACTOR_FLAG_10; + } else if (this->type == ENBOX_TYPE_BIG_SONG_ZELDAS_LULLABY || this->type == ENBOX_TYPE_BIG_SONG_SUNS) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868A6C.s") + } else if ((this->type == ENBOX_TYPE_BIG_SWITCH_FLAG || this->type == ENBOX_TYPE_SMALL_SWITCH_FLAG) && + !Flags_GetSwitch(globalCtx, this->switchFlag)) { + EnBox_SetupAction(this, EnBox_AppearSwitchFlag); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if (this->movementFlags & ENBOX_MOVE_0x80) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 50.0f; + } else { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 50.0f; + } + this->alpha = 0; + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + this->dyna.actor.flags |= ACTOR_FLAG_10; + } else { + if (this->type == ENBOX_TYPE_BIG_INVISIBLE || this->type == ENBOX_TYPE_SMALL_INVISIBLE) { + this->dyna.actor.flags |= ACTOR_FLAG_80; + } + EnBox_SetupAction(this, EnBox_WaitOpen); + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + this->movementFlags |= ENBOX_MOVE_STICK_TO_GROUND; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868AFC.s") + if (this->getItem == GI_STRAY_FAIRY && !Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868B74.s") + this->dyna.actor.shape.rot.y += 0x8000; + this->dyna.actor.home.rot.z = this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80868CC8.s") + SkelAnime_Init(globalCtx, &this->skelAnime, &gBoxChestSkel, &gBoxChestOpenAnim, this->jointTable, this->morphTable, + OBJECT_BOX_CHEST_LIMB_MAX); + Animation_Change(&this->skelAnime, &gBoxChestOpenAnim, 1.5f, animFrame, animFrameEnd, ANIMMODE_ONCE, 0.0f); + if (Actor_IsSmallChest(this)) { + Actor_SetScale(&this->dyna.actor, 0.0075f); + Actor_SetFocus(&this->dyna.actor, 20.0f); + } else { + Actor_SetScale(&this->dyna.actor, 0.01f); + Actor_SetFocus(&this->dyna.actor, 40.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80869020.s") + this->cutsceneIdxA = -1; + this->cutsceneIdxB = -1; + cutsceneIdx = this->dyna.actor.cutscene; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_808692E0.s") + while (cutsceneIdx != -1) { + if (func_800F2178(cutsceneIdx) == 1) { + this->cutsceneIdxB = cutsceneIdx; + } else { + this->cutsceneIdxA = cutsceneIdx; + } + cutsceneIdx = ActorCutscene_GetAdditionalCutscene(cutsceneIdx); + } + func_80867BDC(&this->unk_1F4, globalCtx, &this->dyna.actor.home.pos); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/EnBox_Update.s") +void EnBox_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBox* this = (EnBox*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80869600.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80869850.s") +void EnBox_RandomDustKinematic(EnBox* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { + f32 randomRadius = Rand_ZeroOne() * 25.0f; + s16 randomAngle = Rand_ZeroOne() * 0x10000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_80869874.s") + *pos = this->dyna.actor.world.pos; + pos->x += Math_SinS(randomAngle) * randomRadius; + pos->z += Math_CosS(randomAngle) * randomRadius; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/func_808698B4.s") + velocity->y = 1.0f; + velocity->x = Math_SinS(randomAngle); + velocity->z = Math_CosS(randomAngle); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Box/EnBox_Draw.s") + accel->x = 0.0f; + accel->y = 0.0f; + accel->z = 0.0f; +} + +void EnBox_SpawnDust(EnBox* this, GlobalContext* globalCtx) { + s32 i; + Vec3f pos; + Vec3f velocity; + Vec3f accel; + + for (i = 0; i < 20; i++) { + EnBox_RandomDustKinematic(this, &pos, &velocity, &accel); + func_800B1280(globalCtx, &pos, &velocity, &accel, 100, 30, 15); + } +} + +void EnBox_Fall(EnBox* this, GlobalContext* globalCtx) { + f32 yDiff; + + this->alpha = 255; + this->movementFlags &= ~ENBOX_MOVE_IMMOBILE; + if (this->dyna.actor.bgCheckFlags & 1) { + this->movementFlags |= ENBOX_MOVE_UNUSED; + if (this->movementFlags & ENBOX_MOVE_FALL_ANGLE_SIDE) { + this->movementFlags &= ~ENBOX_MOVE_FALL_ANGLE_SIDE; + } else { + this->movementFlags |= ENBOX_MOVE_FALL_ANGLE_SIDE; + } + if (this->type == ENBOX_TYPE_BIG_SWITCH_FLAG_FALL) { + this->dyna.actor.velocity.y = -this->dyna.actor.velocity.y * 0.55f; + } else { + this->dyna.actor.velocity.y = -this->dyna.actor.velocity.y * 0.65f; + } + if (this->dyna.actor.velocity.y < 5.5f) { + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; + EnBox_SetupAction(this, EnBox_WaitOpen); + } + Audio_PlaySfxAtPos(&this->dyna.actor.projectedPos, NA_SE_EV_TRE_BOX_BOUND); + EnBox_SpawnDust(this, globalCtx); + } + yDiff = this->dyna.actor.world.pos.y - this->dyna.actor.floorHeight; + if (this->movementFlags & ENBOX_MOVE_FALL_ANGLE_SIDE) { + this->dyna.actor.shape.rot.z = yDiff * 50.0f; + } else { + this->dyna.actor.shape.rot.z = -yDiff * 50.0f; + } +} + +void EnBox_FallOnSwitchFlag(EnBox* this, GlobalContext* globalCtx) { + func_800B8C50(&this->dyna.actor, globalCtx); + if (this->unk_1A0 >= 0) { + EnBox_SetupAction(this, EnBox_Fall); + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } else if (this->unk_1A0 >= -11) { + this->unk_1A0++; + } else if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->unk_1A0++; + } +} + +void EnBox_AppearSwitchFlag(EnBox* this, GlobalContext* globalCtx) { + func_800B8C50(&this->dyna.actor, globalCtx); + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + if (ActorCutscene_GetCanPlayNext(this->cutsceneIdxA)) { + ActorCutscene_StartAndSetUnkLinkFields(this->cutsceneIdxA, &this->dyna.actor); + EnBox_SetupAction(this, func_80868AFC); + this->unk_1A0 = -30; + } else { + ActorCutscene_SetIntentToPlay(this->cutsceneIdxA); + } + } +} + +void EnBox_AppearOnRoomClear(EnBox* this, GlobalContext* globalCtx) { + func_800B8C50(&this->dyna.actor, globalCtx); + if (Flags_GetClearTemp(globalCtx, this->dyna.actor.room)) { + if (ActorCutscene_GetCanPlayNext(this->cutsceneIdxA)) { + ActorCutscene_StartAndSetUnkLinkFields(this->cutsceneIdxA, &this->dyna.actor); + Flags_SetClear(globalCtx, this->dyna.actor.room); + EnBox_SetupAction(this, func_80868AFC); + this->unk_1A0 = -30; + } else { + ActorCutscene_SetIntentToPlay(this->cutsceneIdxA); + } + } +} + +void func_80868AFC(EnBox* this, GlobalContext* globalCtx) { + if (func_800F22C4(this->cutsceneIdxA, &this->dyna.actor) != 0 || this->unk_1A0 != 0) { + EnBox_SetupAction(this, func_80868B74); + this->unk_1A0 = 0; + func_80867FBC(&this->unk_1F4, globalCtx, (this->movementFlags & ENBOX_MOVE_0x80) != 0); + Audio_PlaySfxAtPos(&this->dyna.actor.projectedPos, NA_SE_EV_TRE_BOX_APPEAR); + } +} + +void func_80868B74(EnBox* this, GlobalContext* globalCtx) { + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if (this->unk_1A0 < 0) { + this->unk_1A0++; + } else if (this->unk_1A0 < 40) { + if (this->movementFlags & ENBOX_MOVE_0x80) { + this->dyna.actor.world.pos.y -= 1.25f; + } else { + this->dyna.actor.world.pos.y += 1.25f; + } + this->unk_1A0++; + if (this->cutsceneIdxA != -1 && ActorCutscene_GetCurrentIndex() == this->cutsceneIdxA) { + if (this->unk_1A0 == 2) { + func_800B724C(globalCtx, &this->dyna.actor, 4); + } else if (this->unk_1A0 == 22) { + func_800B724C(globalCtx, &this->dyna.actor, 1); + } + } + } else if (this->unk_1A0 < 60) { + this->alpha += 12; + this->unk_1A0++; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + } else { + EnBox_SetupAction(this, EnBox_WaitOpen); + ActorCutscene_Stop(this->dyna.actor.cutscene); + } +} + +void EnBox_WaitOpen(EnBox* this, GlobalContext* globalCtx) { + s32 pad; + AnimationHeader* animHeader; + f32 frameCount; + f32 playbackSpeed; + EnBox_PlaybackSpeed playbackSpeedTable; + Player* player; + Vec3f offset; + + this->alpha = 255; + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + if (this->unk_1EC != 0 && (this->cutsceneIdxB < 0 || ActorCutscene_GetCurrentIndex() == this->cutsceneIdxB || + ActorCutscene_GetCurrentIndex() == -1)) { + if (this->unk_1EC < 0) { + animHeader = &gBoxChestOpenAnim; + playbackSpeed = 1.5f; + } else { + u8 playerForm; + + playbackSpeedTable = sPlaybackSpeed; + playerForm = gSaveContext.save.playerForm; + animHeader = sBigChestAnimations[playerForm]; + playbackSpeed = playbackSpeedTable.data[playerForm]; + } + + frameCount = Animation_GetLastFrame(animHeader); + Animation_Change(&this->skelAnime, animHeader, playbackSpeed, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); + EnBox_SetupAction(this, EnBox_Open); + if (this->unk_1EC > 0) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_DEMO_TRE_LGT, + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, + -1); + func_801A3098(0x2B | 0x900); + } + + if (this->getItem == GI_STRAY_FAIRY) { + this->movementFlags |= ENBOX_MOVE_0x20; + } else { + if (this->getItem == GI_HEART_PIECE || this->getItem == GI_BOTTLE) { + Flags_SetCollectible(globalCtx, this->collectableFlag); + } + Flags_SetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor)); + } + } else { + player = GET_PLAYER(globalCtx); + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); + if (offset.z > -50.0f && offset.z < 0.0f && fabsf(offset.y) < 10.0f && fabsf(offset.x) < 20.0f && + Player_IsFacingActor(&this->dyna.actor, 0x3000, globalCtx)) { + if ((this->getItem == GI_HEART_PIECE || this->getItem == GI_BOTTLE) && + Flags_GetCollectible(globalCtx, this->collectableFlag)) { + this->getItem = GI_RECOVERY_HEART; + } + if (this->getItem == GI_MASK_CAPTAIN && INV_CONTENT(ITEM_MASK_CAPTAIN) == ITEM_MASK_CAPTAIN) { + this->getItem = GI_RECOVERY_HEART; + } + if (this->getItem == GI_MASK_GIANT && INV_CONTENT(ITEM_MASK_GIANT) == ITEM_MASK_GIANT) { + this->getItem = GI_RECOVERY_HEART; + } + Actor_PickUpNearby(&this->dyna.actor, globalCtx, -this->getItem); + } + if (Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { + EnBox_SetupAction(this, EnBox_Open); + } + } +} + +void EnBox_Open(EnBox* this, GlobalContext* globalCtx) { + s32 pad; + + this->dyna.actor.flags &= ~ACTOR_FLAG_80; + + if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_1EC > 0) { + if (this->unk_1EC < 120) { + this->unk_1EC++; + } else { + Math_StepToF(&this->unk_1A8, 0.0f, 0.05f); + } + } else if (this->unk_1EC > -120) { + this->unk_1EC--; + } else { + Math_StepToF(&this->unk_1A8, 0.0f, 0.05f); + } + if (this->movementFlags & ENBOX_MOVE_0x20) { + this->movementFlags &= ~ENBOX_MOVE_0x20; + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EN_ELFORG, + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, this->dyna.actor.world.rot.z, + ((ENBOX_GET_CHEST_FLAG(&this->dyna.actor) & 0x7F) << 9) | STRAY_FAIRY_TYPE_CHEST); + } else if (this->movementFlags & ENBOX_MOVE_0x40) { + this->movementFlags &= ~ENBOX_MOVE_0x40; + } + } else { + f32 waterSurface; + WaterBox* waterBox; + s32 bgId; + u16 sfxId = 0; + + if (Animation_OnFrame(&this->skelAnime, gSaveContext.save.playerForm == PLAYER_FORM_DEKU ? 14.0f : 30.0f)) { + sfxId = NA_SE_EV_TBOX_UNLOCK; + } else if (Animation_OnFrame(&this->skelAnime, + gSaveContext.save.playerForm == PLAYER_FORM_DEKU ? 15.0f : 90.0f)) { + sfxId = NA_SE_EV_TBOX_OPEN; + } + if (sfxId != 0) { + Audio_PlaySfxAtPos(&this->dyna.actor.projectedPos, sfxId); + } + if (this->skelAnime.jointTable[3].z > 0) { + this->unk_1A8 = (0x7D00 - this->skelAnime.jointTable[3].z) * 0.00006f; + if (this->unk_1A8 < 0.0f) { + this->unk_1A8 = 0.0f; + } else if (this->unk_1A8 > 1.0f) { + this->unk_1A8 = 1.0f; + } + } + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.z, &waterSurface, &waterBox, &bgId) && + this->dyna.actor.floorHeight < waterSurface) { + EffectSsBubble_Spawn(globalCtx, &this->dyna.actor.world.pos, 5.0f, 2.0f, 20.0f, 0.3f); + } + } +} + +void EnBox_SpawnIceSmoke(EnBox* this, GlobalContext* globalCtx) { + Vec3f pos; + Vec3f velocity = { 0, 1.0f, 0 }; + Vec3f accel = { 0, 0, 0 }; + f32 randomf; + + this->iceSmokeTimer++; + //! @bug sfxId should be NA_SE_EN_MIMICK_BREATH, but uses OoT's sfxId value + func_800B9010(&this->dyna.actor, NA_SE_EN_LAST3_COIL_ATTACK_OLD - SFX_FLAG); + if (Rand_ZeroOne() < 0.3f) { + randomf = 2.0f * Rand_ZeroOne() - 1.0f; + pos = this->dyna.actor.world.pos; + pos.x += randomf * 20.0f * Math_SinS(this->dyna.actor.world.rot.y + 0x4000); + pos.z += randomf * 20.0f * Math_CosS(this->dyna.actor.world.rot.y + 0x4000); + + randomf = 2.0f * Rand_ZeroOne() - 1.0f; + velocity.x = randomf * 1.6f * Math_SinS(this->dyna.actor.world.rot.y); + velocity.y = 1.8f; + velocity.z = randomf * 1.6f * Math_CosS(this->dyna.actor.world.rot.y); + EffectSsIceSmoke_Spawn(globalCtx, &pos, &velocity, &accel, 150); + } +} + +void EnBox_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBox* this = (EnBox*)thisx; + + if (this->movementFlags & ENBOX_MOVE_STICK_TO_GROUND) { + this->movementFlags &= ~ENBOX_MOVE_STICK_TO_GROUND; + EnBox_ClipToGround(this, globalCtx); + } + if (this->getItem == GI_STRAY_FAIRY && !Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { + globalCtx->actorCtx.unk5 |= 8; + } + this->actionFunc(this, globalCtx); + if (this->movementFlags & ENBOX_MOVE_0x80) { + this->movementFlags |= ENBOX_MOVE_IMMOBILE; + } + if (!(this->movementFlags & ENBOX_MOVE_IMMOBILE)) { + Actor_MoveWithGravity(&this->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 0x1C); + } + Actor_SetFocus(&this->dyna.actor, 40.0f); + if (this->getItem == GI_ICE_TRAP && this->actionFunc == EnBox_Open && this->skelAnime.curFrame > 45.0f && + this->iceSmokeTimer < 100) { + EnBox_SpawnIceSmoke(this, globalCtx); + } + if (this->unk_1F4.unk_0C != NULL) { + this->unk_1F4.unk_0C(&this->unk_1F4, globalCtx); + } +} + +void EnBox_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnBox* this = THIS; + s32 pad; + + if (limbIndex == OBJECT_BOX_CHEST_LIMB_01) { + gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + if (this->type == ENBOX_TYPE_BIG_ORNATE) { + gSPDisplayList((*gfx)++, &gBoxChestBaseOrnateDL); + } else if (Actor_IsSmallChest(this)) { + if (this->getItem == GI_KEY_SMALL) { + gSPDisplayList((*gfx)++, &gBoxChestBaseGildedDL); + } else { + gSPDisplayList((*gfx)++, &gBoxChestBaseDL); + } + } else { + gSPDisplayList((*gfx)++, &gBoxChestBaseGildedDL); + } + } else if (limbIndex == OBJECT_BOX_CHEST_LIMB_03) { + gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + if (this->type == ENBOX_TYPE_BIG_ORNATE) { + gSPDisplayList((*gfx)++, &gBoxChestLidOrnateDL); + } else if (Actor_IsSmallChest(this)) { + if (this->getItem == GI_KEY_SMALL) { + gSPDisplayList((*gfx)++, &gBoxChestLidGildedDL); + } else { + gSPDisplayList((*gfx)++, &gBoxChestLidDL); + } + } else { + gSPDisplayList((*gfx)++, &gBoxChestLidGildedDL); + } + } +} + +Gfx* EnBox_SetRenderMode1(GraphicsContext* gfxCtx) { + Gfx* dl = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + + gSPEndDisplayList(dl); + return dl; +} + +Gfx* EnBox_SetRenderMode2(GraphicsContext* gfxCtx) { + Gfx* dl = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + Gfx* cur = dl; + + gDPSetRenderMode( + cur++, AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | G_RM_FOG_SHADE_A, + AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)); + + gSPEndDisplayList(cur++); + return dl; +} + +Gfx* EnBox_SetRenderMode3(GraphicsContext* gfxCtx) { + Gfx* dl = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + Gfx* cur = dl; + + gDPSetRenderMode(cur++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPEndDisplayList(cur++); + return dl; +} + +void EnBox_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBox* this = (EnBox*)thisx; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + if (this->unk_1F4.unk_10 != NULL) { + this->unk_1F4.unk_10(&this->unk_1F4, globalCtx); + } + if ((this->alpha == 255 && this->type != ENBOX_TYPE_BIG_INVISIBLE && this->type != ENBOX_TYPE_SMALL_INVISIBLE) || + (!CHECK_FLAG_ALL(this->dyna.actor.flags, ACTOR_FLAG_80) && + (this->type == ENBOX_TYPE_BIG_INVISIBLE || this->type == ENBOX_TYPE_SMALL_INVISIBLE))) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x08, EnBox_SetRenderMode1(globalCtx->state.gfxCtx)); + func_8012C28C(globalCtx->state.gfxCtx); + POLY_OPA_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, + EnBox_PostLimbDraw, &this->dyna.actor, POLY_OPA_DISP); + } else if (this->alpha != 0) { + gDPPipeSync(POLY_XLU_DISP++); + func_8012C2DC(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); + if (this->type == ENBOX_TYPE_BIG_INVISIBLE || this->type == ENBOX_TYPE_SMALL_INVISIBLE) { + gSPSegment(POLY_XLU_DISP++, 0x08, EnBox_SetRenderMode3(globalCtx->state.gfxCtx)); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, EnBox_SetRenderMode2(globalCtx->state.gfxCtx)); + } + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, + EnBox_PostLimbDraw, &this->dyna.actor, POLY_XLU_DISP); + } + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.h b/src/overlays/actors/ovl_En_Box/z_en_box.h index aa7c425d2..02d9d95f9 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.h +++ b/src/overlays/actors/ovl_En_Box/z_en_box.h @@ -2,22 +2,68 @@ #define Z_EN_BOX_H #include "global.h" +#include "objects/object_box/object_box.h" struct EnBox; +struct func_80867BDC_a0; typedef void (*EnBoxActionFunc)(struct EnBox*, GlobalContext*); +typedef void (*EnBoxUnkFunc)(struct func_80867BDC_a0* arg0, GlobalContext* globalCtx); + +typedef struct func_80867BDC_a0 { + /* 0x00 */ Vec3f pos; + /* 0x0C */ EnBoxUnkFunc unk_0C; + /* 0x10 */ EnBoxUnkFunc unk_10; + /* 0x14 */ s32 unk_14; + /* 0x18 */ s32 unk_18; + /* 0x1C */ s32 unk_1C; + /* 0x20 */ s32 unk_20; +} func_80867BDC_a0; //size 0x24 + +typedef enum { + /* 0 */ ENBOX_TYPE_BIG, // big + /* 1 */ ENBOX_TYPE_BIG_ROOM_CLEAR, // appear on room clear, store temp clear as permanent clear + /* 2 */ ENBOX_TYPE_BIG_ORNATE, // boss key chest + /* 3 */ ENBOX_TYPE_BIG_SWITCH_FLAG_FALL, // falling, appear on switch flag set + /* 4 */ ENBOX_TYPE_BIG_INVISIBLE, // big, revealed with lens of truth or when opened + /* 5 */ ENBOX_TYPE_SMALL, // small + /* 6 */ ENBOX_TYPE_SMALL_INVISIBLE, // small, revealed with lens of truth or when opened + /* 7 */ ENBOX_TYPE_SMALL_ROOM_CLEAR, // use room clear, store temp clear as perm clear + /* 8 */ ENBOX_TYPE_SMALL_SWITCH_FLAG_FALL, // falling, appear on switch flag set + /* 9 */ ENBOX_TYPE_BIG_SONG_ZELDAS_LULLABY,// NOT IMPLEMENTED, behaves like big chest + /* 10 */ ENBOX_TYPE_BIG_SONG_SUNS, // NOT IMPLEMENTED, behaves like big chest + /* 11 */ ENBOX_TYPE_BIG_SWITCH_FLAG, // big, appear on switch flag set + /* 12 */ ENBOX_TYPE_SMALL_SWITCH_FLAG // small, appear on switch flag set +} EnBoxType; typedef struct EnBox { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xAC]; - /* 0x01F0 */ char unk_1F0[0x01]; - /* 0x01F1 */ u8 unk_1F1; - /* 0x01F2 */ char unk_1F2[0x02]; - /* 0x01F4 */ char unk_1F4[0x0C]; - /* 0x0200 */ EnBoxActionFunc actionFunc; - /* 0x0204 */ char unk_204[0x20]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ SkelAnime skelAnime; + /* 0x01A0 */ s32 unk_1A0; + /* 0x01A4 */ UNK_TYPE1 unk_1A4[0x04]; + /* 0x01A8 */ f32 unk_1A8; + /* 0x01AC */ EnBoxActionFunc actionFunc; + /* 0x01B0 */ Vec3s jointTable[OBJECT_BOX_CHEST_LIMB_MAX]; + /* 0x01CE */ Vec3s morphTable[OBJECT_BOX_CHEST_LIMB_MAX]; + /* 0x01EC */ s16 unk_1EC; + /* 0x01EE */ u8 movementFlags; + /* 0x01EF */ u8 alpha; + /* 0x01F0 */ u8 switchFlag; + /* 0x01F1 */ u8 type; + /* 0x01F2 */ u8 iceSmokeTimer; + /* 0x01F3 */ s8 unk_1F3; + /* 0x01F4 */ func_80867BDC_a0 unk_1F4; + /* 0x0218 */ s16 cutsceneIdxA; + /* 0x021A */ s16 cutsceneIdxB; + /* 0x021C */ s32 getItem; + /* 0x0220 */ s32 collectableFlag; } EnBox; // size = 0x224 extern const ActorInit En_Box_InitVars; +#define ENBOX_GET_TYPE(thisx) (((thisx)->params >> 12) & 0xF) +#define ENBOX_GET_ITEM(thisx) (((thisx)->params >> 5) & 0x7F) +#define ENBOX_GET_CHEST_FLAG(thisx) ((thisx)->params & 0x1F) +#define ENBOX_GET_SWITCH_FLAG(thisx) ((thisx)->world.rot.z) + #endif // Z_EN_BOX_H diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c index 45fe0c132..846989c0c 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -31,7 +31,7 @@ s32 EnGirlA_CanBuyBombBag20BombShop(GlobalContext* globalCtx, EnGirlA* this); s32 EnGirlA_CanBuyBombBag30BombShop(GlobalContext* globalCtx, EnGirlA* this); s32 EnGirlA_CanBuyBombchus(GlobalContext* globalCtx, EnGirlA* this); s32 EnGirlA_CanBuyBombs(GlobalContext* globalCtx, EnGirlA* this); -s32 EnGirlA_CanBuyBottle(GlobalContext* globalCtx, EnGirlA* this); +s32 EnGirlA_CanBuyBottleStolen(GlobalContext* globalCtx, EnGirlA* this); s32 EnGirlA_CanBuySword(GlobalContext* globalCtx, EnGirlA* this); s32 EnGirlA_CanBuyShieldMirror(GlobalContext* globalCtx, EnGirlA* this); s32 EnGirlA_CanBuyFairy(GlobalContext* globalCtx, EnGirlA* this); @@ -64,91 +64,91 @@ const ActorInit En_GirlA_InitVars = { }; static ShopItemEntry sShopItemEntries[] = { - { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X083F, 0X0840, GI_POTION_RED, EnGirlA_CanBuyPotionRed, + { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0x083F, 0x0840, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0X0841, 0X0842, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, + { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0x0841, 0x0842, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_BLUE, func_800B8050, 1, 0X0843, 0X0844, GI_POTION_BLUE, EnGirlA_CanBuyPotionBlue, + { OBJECT_GI_LIQUID, GID_POTION_BLUE, func_800B8050, 1, 0x0843, 0x0844, GI_POTION_BLUE, EnGirlA_CanBuyPotionBlue, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOTTLE_04, GID_FAIRY, func_800B8050, 1, 0X06B6, 0X06B7, GI_FAIRY, EnGirlA_CanBuyFairy, + { OBJECT_GI_BOTTLE_04, GID_FAIRY, func_800B8050, 1, 0x06B6, 0x06B7, GI_FAIRY, EnGirlA_CanBuyFairy, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_LARGE, func_800B8050, 50, 0X06BA, 0X06BB, GI_ARROWS_40, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_LARGE, func_800B8050, 50, 0x06BA, 0x06BB, GI_ARROWS_40, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0X06B2, 0X06B3, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, + { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0x06B2, 0x06B3, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0X06AE, 0X06AF, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, + { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0x06AE, 0x06AF, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, EnGirlA_BuyShieldHero, EnGirlA_BuyFanfare }, - { OBJECT_GI_STICK, GID_STICK, NULL, 1, 0X06B4, 0X06B5, GI_STICKS_1, EnGirlA_CanBuyStick, EnGirlA_BuyStick, + { OBJECT_GI_STICK, GID_STICK, NULL, 1, 0x06B4, 0x06B5, GI_STICKS_1, EnGirlA_CanBuyStick, EnGirlA_BuyStick, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, func_800B8050, 30, 0X06B8, 0X06B9, GI_ARROWS_30, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, func_800B8050, 30, 0x06B8, 0x06B9, GI_ARROWS_30, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_NUTS, GID_NUTS, func_800B8118, 10, 0X06B0, 0X06B1, GI_NUTS_10, EnGirlA_CanBuyNuts, EnGirlA_BuyNuts, + { OBJECT_GI_NUTS, GID_NUTS, func_800B8118, 10, 0x06B0, 0x06B1, GI_NUTS_10, EnGirlA_CanBuyNuts, EnGirlA_BuyNuts, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X06AC, 0X06AD, GI_POTION_RED, EnGirlA_CanBuyPotionRed, + { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0x06AC, 0x06AD, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOTTLE_04, GID_FAIRY, func_800B8050, 1, 0X06D3, 0X06D4, GI_FAIRY, EnGirlA_CanBuyFairy, + { OBJECT_GI_BOTTLE_04, GID_FAIRY, func_800B8050, 1, 0x06D3, 0x06D4, GI_FAIRY, EnGirlA_CanBuyFairy, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, func_800B8050, 30, 0X06D5, 0X06D6, GI_ARROWS_30, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, func_800B8050, 30, 0x06D5, 0x06D6, GI_ARROWS_30, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_LARGE, func_800B8050, 50, 0X06D7, 0X06D8, GI_ARROWS_40, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_LARGE, func_800B8050, 50, 0x06D7, 0x06D8, GI_ARROWS_40, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0X06CF, 0X06D0, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, + { OBJECT_GI_LIQUID, GID_POTION_GREEN, func_800B8050, 1, 0x06CF, 0x06D0, GI_POTION_GREEN, EnGirlA_CanBuyPotionGreen, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_NUTS, GID_NUTS, func_800B8118, 10, 0X06CD, 0X06CE, GI_NUTS_10, EnGirlA_CanBuyNuts, EnGirlA_BuyNuts, + { OBJECT_GI_NUTS, GID_NUTS, func_800B8118, 10, 0x06CD, 0x06CE, GI_NUTS_10, EnGirlA_CanBuyNuts, EnGirlA_BuyNuts, EnGirlA_BuyFanfare }, - { OBJECT_GI_STICK, GID_STICK, NULL, 1, 0X06D1, 0X06D2, GI_STICKS_1, EnGirlA_CanBuyStick, EnGirlA_BuyStick, + { OBJECT_GI_STICK, GID_STICK, NULL, 1, 0x06D1, 0x06D2, GI_STICKS_1, EnGirlA_CanBuyStick, EnGirlA_BuyStick, EnGirlA_BuyFanfare }, - { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0X06CB, 0X06CC, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, + { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0x06CB, 0x06CC, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, EnGirlA_BuyShieldHero, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X06C9, 0X06CA, GI_POTION_RED, EnGirlA_CanBuyPotionRed, + { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0x06C9, 0x06CA, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_MASK06, GID_MASK_ALL_NIGHT, func_800B8050, 1, 0X29D9, 0X29DA, GI_MASK_ALL_NIGHT, + { OBJECT_GI_MASK06, GID_MASK_ALL_NIGHT, func_800B8050, 1, 0x29D9, 0x29DA, GI_MASK_ALL_NIGHT, EnGirlA_CanBuyMaskAllNight, EnGirlA_BuyMaskAllNight, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_20, func_800B8050, 1, 0X29DB, 0X29DC, GI_BOMB_BAG_20, + { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_20, func_800B8050, 1, 0x29DB, 0x29DC, GI_BOMB_BAG_20, EnGirlA_CanBuyBombBagCuriosityShop, EnGirlA_BuyBombBag, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_30, func_800B8050, 2, 0X29DB, 0X29DC, GI_BOMB_BAG_30, + { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_30, func_800B8050, 2, 0x29DB, 0x29DC, GI_BOMB_BAG_30, EnGirlA_CanBuyBombBagCuriosityShop, EnGirlA_BuyBombBag, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_40, func_800B8050, 3, 0X29DB, 0X29DC, GI_BOMB_BAG_40, + { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_40, func_800B8050, 3, 0x29DB, 0x29DC, GI_BOMB_BAG_40, EnGirlA_CanBuyBombBagCuriosityShop, EnGirlA_BuyBombBag, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_20, func_800B8050, 1, 0X0654, 0X0655, GI_BOMB_BAG_20, + { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_20, func_800B8050, 1, 0x0654, 0x0655, GI_BOMB_BAG_20, EnGirlA_CanBuyBombBag20BombShop, EnGirlA_BuyBombBag, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_30, func_800B8050, 2, 0X0656, 0X0657, GI_BOMB_BAG_30, + { OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_30, func_800B8050, 2, 0x0656, 0x0657, GI_BOMB_BAG_30, EnGirlA_CanBuyBombBag30BombShop, EnGirlA_BuyBombBag, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMB_2, GID_BOMBCHU, func_800B8050, 10, 0X0652, 0X0653, GI_BOMBCHUS_10, EnGirlA_CanBuyBombchus, + { OBJECT_GI_BOMB_2, GID_BOMBCHU, func_800B8050, 10, 0x0652, 0x0653, GI_BOMBCHUS_10, EnGirlA_CanBuyBombchus, EnGirlA_BuyBombchus, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0X0650, 0X0651, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, + { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0x0650, 0x0651, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, EnGirlA_BuyFanfare }, - { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0X12DB, 0X12DC, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, + { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0x12DB, 0x12DC, GI_SHIELD_HERO, EnGirlA_CanBuyShieldHero, EnGirlA_BuyShieldHero, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0X12DD, 0X12DE, GI_ARROWS_10, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0x12DD, 0x12DE, GI_ARROWS_10, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X12DF, 0X12E0, GI_POTION_RED, EnGirlA_CanBuyPotionRed, + { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0x12DF, 0x12E0, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0X0BC5, 0X0BC6, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, + { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0x0BC5, 0x0BC6, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0X0BC7, 0X0BC8, GI_ARROWS_10, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0x0BC7, 0x0BC8, GI_ARROWS_10, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X0BC9, 0X0BCA, GI_POTION_RED, EnGirlA_CanBuyPotionRed, + { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0x0BC9, 0x0BCA, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0X0BCB, 0X0BCC, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, + { OBJECT_GI_BOMB_1, GID_BOMB, func_800B8050, 10, 0x0BCB, 0x0BCC, GI_BOMBS_10, EnGirlA_CanBuyBombs, EnGirlA_BuyBombs, EnGirlA_BuyFanfare }, - { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0X0BCD, 0X0BCE, GI_ARROWS_10, EnGirlA_CanBuyArrows, + { OBJECT_GI_ARROW, GID_ARROWS_SMALL, func_800B8050, 10, 0x0BCD, 0x0BCE, GI_ARROWS_10, EnGirlA_CanBuyArrows, EnGirlA_BuyArrows, EnGirlA_BuyFanfare }, - { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0X0BCF, 0X0BD0, GI_POTION_RED, EnGirlA_CanBuyPotionRed, + { OBJECT_GI_LIQUID, GID_POTION_RED, func_800B8050, 1, 0x0BCF, 0x0BD0, GI_POTION_RED, EnGirlA_CanBuyPotionRed, EnGirlA_BuyBottleItem, EnGirlA_BuyFanfare }, - { OBJECT_GI_BOTTLE, GID_BOTTLE, func_800B8050, 1, 0X29F8, 0X29F9, GI_BOTTLE, EnGirlA_CanBuyBottle, + { OBJECT_GI_BOTTLE, GID_BOTTLE, func_800B8050, 1, 0x29F8, 0x29F9, GI_BOTTLE_STOLEN, EnGirlA_CanBuyBottleStolen, EnGirlA_BuyBottle, EnGirlA_BuyFanfare }, - { OBJECT_GI_SWORD_4, GID_SWORD_GREAT_FAIRY, func_800B8050, 4, 0X29F2, 0X29F3, GI_SWORD_GREAT_FAIRY, + { OBJECT_GI_SWORD_4, GID_SWORD_GREAT_FAIRY, func_800B8050, 4, 0x29F2, 0x29F3, GI_SWORD_GREAT_FAIRY, EnGirlA_CanBuySword, EnGirlA_BuySword, EnGirlA_BuyFanfare }, - { OBJECT_GI_SWORD_1, GID_SWORD_KOKIRI, func_800B8050, 1, 0X29F4, 0X29F5, GI_SWORD_KOKIRI, EnGirlA_CanBuySword, + { OBJECT_GI_SWORD_1, GID_SWORD_KOKIRI, func_800B8050, 1, 0x29F4, 0x29F5, GI_SWORD_KOKIRI, EnGirlA_CanBuySword, EnGirlA_BuySword, EnGirlA_BuyFanfare }, - { OBJECT_GI_SWORD_2, GID_SWORD_RAZOR, func_800B8050, 2, 0X29F4, 0X29F5, GI_SWORD_RAZOR, EnGirlA_CanBuySword, + { OBJECT_GI_SWORD_2, GID_SWORD_RAZOR, func_800B8050, 2, 0x29F4, 0x29F5, GI_SWORD_RAZOR, EnGirlA_CanBuySword, EnGirlA_BuySword, EnGirlA_BuyFanfare }, - { OBJECT_GI_SWORD_3, GID_SWORD_GILDED, func_800B8050, 3, 0X29F4, 0X29F5, GI_SWORD_GILDED, EnGirlA_CanBuySword, + { OBJECT_GI_SWORD_3, GID_SWORD_GILDED, func_800B8050, 3, 0x29F4, 0x29F5, GI_SWORD_GILDED, EnGirlA_CanBuySword, EnGirlA_BuySword, EnGirlA_BuyFanfare }, - { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0X29F6, 0X29F7, GI_SHIELD_HERO_2, EnGirlA_CanBuyShieldHero, + { OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, func_800B8050, 1, 0x29F6, 0x29F7, GI_SHIELD_HERO_2, EnGirlA_CanBuyShieldHero, EnGirlA_BuyShieldHero, EnGirlA_BuyFanfare }, - { OBJECT_GI_SHIELD_3, GID_SHIELD_MIRROR, func_800B8050, 1, 0X29F6, 0X29F7, GI_SHIELD_MIRROR, + { OBJECT_GI_SHIELD_3, GID_SHIELD_MIRROR, func_800B8050, 1, 0x29F6, 0x29F7, GI_SHIELD_MIRROR, EnGirlA_CanBuyShieldMirror, EnGirlA_BuyShieldMirror, EnGirlA_BuyFanfare }, }; @@ -341,7 +341,7 @@ s32 EnGirlA_CanBuyBombs(GlobalContext* globalCtx, EnGirlA* this) { return CANBUY_RESULT_SUCCESS_2; } -s32 EnGirlA_CanBuyBottle(GlobalContext* globalCtx, EnGirlA* this) { +s32 EnGirlA_CanBuyBottleStolen(GlobalContext* globalCtx, EnGirlA* this) { if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { return CANBUY_RESULT_NEED_RUPEES; } diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index 23b1b6223..6d89bef7b 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -486,7 +486,7 @@ void func_80B67B50(EnSth* this, GlobalContext* globalCtx) { } else { this->unk_29C &= ~1; gSaveContext.save.weekEventReg[34] |= 8; - Actor_PickUp(&this->actor, globalCtx, GI_MASK_CAPTAIN, 10000.0f, 50.0f); + Actor_PickUp(&this->actor, globalCtx, GI_MASK_TRUTH, 10000.0f, 50.0f); } } diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c index 217d32540..1a357dcd8 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c @@ -299,7 +299,7 @@ void func_80AE0460(EnTsn* this, GlobalContext* globalCtx) { ENTSN_SET_Z(&this->unk_1D8->actor, false); this->actionFunc = func_80AE0418; } else { - Actor_PickUp(&this->actor, globalCtx, GI_95, 2000.0f, 1000.0f); + Actor_PickUp(&this->actor, globalCtx, GI_SEAHORSE, 2000.0f, 1000.0f); } } diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.c b/src/overlays/actors/ovl_En_Zow/z_en_zow.c index d29141499..2f1b4a1a4 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -333,7 +333,7 @@ void EnZow_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } -AnimationHeader* sAnimations[] = { &object_zo_Anim_004168, &gZoraSurfacingAnim, &gZoraSurfacingAnim }; +static AnimationHeader* sAnimations[] = { &object_zo_Anim_004168, &gZoraSurfacingAnim, &gZoraSurfacingAnim }; void func_80BDD04C(EnZow* this, s16 arg1, u8 arg2) { if ((arg1 >= 0) && (arg1 < 3)) { diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index bdb5188e3..5989a3114 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -892,7 +892,7 @@ 0x800BE504:("func_800BE504",), 0x800BE568:("func_800BE568",), 0x800BE5CC:("func_800BE5CC",), - 0x800BE63C:("func_800BE63C",), + 0x800BE63C:("Actor_IsSmallChest",), 0x800BE680:("Actor_DrawDamageEffects",), 0x800BF7CC:("Actor_SpawnIceEffects",), 0x800BF9A0:("ActorOverlayTable_FaultPrint",), @@ -4912,7 +4912,7 @@ 0x80863E48:("EnGirlA_CanBuyBombBag30BombShop",), 0x80863EC8:("EnGirlA_CanBuyBombchus",), 0x80863F94:("EnGirlA_CanBuyBombs",), - 0x80864034:("EnGirlA_CanBuyBottle",), + 0x80864034:("EnGirlA_CanBuyBottleStolen",), 0x8086406C:("EnGirlA_CanBuySword",), 0x808640A4:("EnGirlA_CanBuyShieldMirror",), 0x80864108:("EnGirlA_CanBuyFairy",), @@ -4962,31 +4962,31 @@ 0x8086732C:("EnDoor_Update",), 0x80867350:("EnDoor_OverrideLimbDraw",), 0x808674B0:("EnDoor_Draw",), - 0x80867BD0:("func_80867BD0",), + 0x80867BD0:("EnBox_SetupAction",), 0x80867BDC:("func_80867BDC",), 0x80867C14:("func_80867C14",), 0x80867C8C:("func_80867C8C",), 0x80867FBC:("func_80867FBC",), 0x80867FE4:("func_80867FE4",), - 0x8086800C:("func_8086800C",), + 0x8086800C:("EnBox_ClipToGround",), 0x808680AC:("EnBox_Init",), 0x808685FC:("EnBox_Destroy",), - 0x80868630:("func_80868630",), - 0x80868734:("func_80868734",), - 0x808687E8:("func_808687E8",), - 0x80868944:("func_80868944",), - 0x808689E8:("func_808689E8",), - 0x80868A6C:("func_80868A6C",), + 0x80868630:("EnBox_RandomDustKinematic",), + 0x80868734:("EnBox_SpawnDust",), + 0x808687E8:("EnBox_Fall",), + 0x80868944:("EnBox_FallOnSwitchFlag",), + 0x808689E8:("EnBox_AppearSwitchFlag",), + 0x80868A6C:("EnBox_AppearOnRoomClear",), 0x80868AFC:("func_80868AFC",), 0x80868B74:("func_80868B74",), - 0x80868CC8:("func_80868CC8",), - 0x80869020:("func_80869020",), - 0x808692E0:("func_808692E0",), + 0x80868CC8:("EnBox_WaitOpen",), + 0x80869020:("EnBox_Open",), + 0x808692E0:("EnBox_SpawnIceSmoke",), 0x808694A0:("EnBox_Update",), - 0x80869600:("func_80869600",), - 0x80869850:("func_80869850",), - 0x80869874:("func_80869874",), - 0x808698B4:("func_808698B4",), + 0x80869600:("EnBox_PostLimbDraw",), + 0x80869850:("EnBox_SetRenderMode1",), + 0x80869874:("EnBox_SetRenderMode2",), + 0x808698B4:("EnBox_SetRenderMode3",), 0x808698F4:("EnBox_Draw",), 0x80869D90:("EnPametfrog_Init",), 0x80869F90:("EnPametfrog_Destroy",), @@ -6508,12 +6508,12 @@ 0x808E0DA8:("EnEncount1_Update",), 0x808E0E40:("DemoTreLgt_Init",), 0x808E0EBC:("DemoTreLgt_Destroy",), - 0x808E0EE8:("func_808E0EE8",), - 0x808E0EF4:("func_808E0EF4",), - 0x808E0F4C:("func_808E0F4C",), - 0x808E0FE0:("func_808E0FE0",), + 0x808E0EE8:("DemoTreLgt_SetupWait",), + 0x808E0EF4:("DemoTreLgt_Wait",), + 0x808E0F4C:("DemoTreLgt_SetupAnimate",), + 0x808E0FE0:("DemoTreLgt_Animate",), 0x808E1270:("DemoTreLgt_Update",), - 0x808E12A4:("func_808E12A4",), + 0x808E12A4:("DemoTreLgt_OverrideLimbDraw",), 0x808E13FC:("DemoTreLgt_Draw",), 0x808E1560:("EnEncount2_Init",), 0x808E16B4:("EnEncount2_Destroy",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index fd8ee4d45..9529203e4 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -7047,8 +7047,8 @@ 0x808E0DF8:("D_808E0DF8","UNK_TYPE1","",0x1), 0x808E1490:("D_808E1490","UNK_TYPE1","",0x1), 0x808E14B0:("Demo_Tre_Lgt_InitVars","UNK_TYPE1","",0x1), - 0x808E14D0:("D_808E14D0","UNK_TYPE4","",0x4), - 0x808E14D8:("D_808E14D8","UNK_TYPE1","",0x1), + 0x808E14D0:("sBoxLightAnimations","UNK_TYPE4","[2]",0x8), + 0x808E14D8:("sActionFuncs","UNK_TYPE4","[2]",0x8), 0x808E1ED0:("En_Encount2_InitVars","UNK_TYPE1","",0x1), 0x808E1EF0:("D_808E1EF0","UNK_TYPE1","",0x1), 0x808E1F14:("D_808E1F14","UNK_TYPE1","",0x1), From e729f104429cacdc915e27887090ceb8d956c9ab Mon Sep 17 00:00:00 2001 From: Kristopher Early <1191258+MrPolymorph@users.noreply.github.com> Date: Sun, 19 Jun 2022 02:29:44 +0100 Subject: [PATCH 226/257] Yasi descriptive names (#831) * Cleaned up yasi by giving symbols descriptive names * renamed variables to palm tree * Adding descriptive comment to root of xml asset file Co-authored-by: MrPolymorph <{ID}+{username}@users.noreply.github.com> --- assets/xml/objects/object_obj_yasi.xml | 15 ++++++++------- src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c | 6 +++--- src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/assets/xml/objects/object_obj_yasi.xml b/assets/xml/objects/object_obj_yasi.xml index b7d2c1fd1..a8e153edd 100644 --- a/assets/xml/objects/object_obj_yasi.xml +++ b/assets/xml/objects/object_obj_yasi.xml @@ -1,11 +1,12 @@  + - - - - - - - + + + + + + + diff --git a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c index 3dfea0818..4e9bb84b2 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c @@ -42,11 +42,11 @@ void ObjYasi_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_obj_yasi_Colheader_001428); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gPalmTreeCol); this->dyna.actor.home.rot.y = 0; - if (OBJYASI_IS_WIDE(thisx)) { + if (PALM_TREE_IS_WIDE(thisx)) { this->dyna.actor.scale.x = 0.2f; this->dyna.actor.scale.z = 0.2f; } @@ -97,5 +97,5 @@ void ObjYasi_Draw(Actor* thisx, GlobalContext* globalCtx) { } Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); - Gfx_DrawDListOpa(globalCtx, object_obj_yasi_DL_000360); + Gfx_DrawDListOpa(globalCtx, gPalmTreeDL); } diff --git a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h index f4ab9ca9c..d1fdc6aed 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h @@ -11,6 +11,6 @@ typedef struct ObjYasi { extern const ActorInit Obj_Yasi_InitVars; -#define OBJYASI_IS_WIDE(thisx) ((thisx)->params & 1) +#define PALM_TREE_IS_WIDE(thisx) ((thisx)->params & 1) #endif // Z_OBJ_YASI_H From b6362cacbe5cf2d7ad541ce14d24ebb11417a8fe Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sat, 18 Jun 2022 18:37:31 -0700 Subject: [PATCH 227/257] ClearTag cleanup (#830) --- assets/xml/objects/gameplay_keep.xml | 18 +++++----- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.c | 34 +++++++++++++------ .../actors/ovl_En_Clear_Tag/z_en_clear_tag.h | 12 ------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index f73e9252f..6b624857f 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1044,15 +1044,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index beb2f2d17..bfc6102b0 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -11,6 +11,18 @@ #define THIS ((EnClearTag*)thisx) +typedef enum { + /* 0x00 */ CLEAR_TAG_EFFECT_AVAILABLE, + /* 0x01 */ CLEAR_TAG_EFFECT_DEBRIS, + /* 0x02 */ CLEAR_TAG_EFFECT_FIRE, // never set to, remnant of OoT + /* 0x03 */ CLEAR_TAG_EFFECT_SMOKE, + /* 0x04 */ CLEAR_TAG_EFFECT_FLASH, + /* 0x05 */ CLEAR_TAG_EFFECT_LIGHT_RAYS, + /* 0x06 */ CLEAR_TAG_EFFECT_SHOCKWAVE, + /* 0x07 */ CLEAR_TAG_EFFECT_SPLASH, + /* 0x08 */ CLEAR_TAG_EFFECT_ISOLATED_SMOKE, +} ClearTagEffectType; + void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx); void EnClearTag_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnClearTag_Update(Actor* thisx, GlobalContext* globalCtx); @@ -82,15 +94,15 @@ static f32 sLightRayMaxScale[] = { 25.0f, 100.0f, 48.0f, 20.0f, 32.0f, }; -static TexturePtr sSplashTex[] = { - gExplosionSplashTex1, - gExplosionSplashTex2, - gExplosionSplashTex3, - gExplosionSplashTex4, - gExplosionSplashTex5, - gExplosionSplashTex6, - gExplosionSplashTex7, - gExplosionSplashTex8, +static TexturePtr sWaterSplashTextures[] = { + gEffWaterSplash1Tex, + gEffWaterSplash2Tex, + gEffWaterSplash3Tex, + gEffWaterSplash4Tex, + gEffWaterSplash5Tex, + gEffWaterSplash6Tex, + gEffWaterSplash7Tex, + gEffWaterSplash8Tex, NULL, NULL, NULL, @@ -972,7 +984,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 200); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 200); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sSplashTex[effect->actionTimer])); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sWaterSplashTextures[effect->actionTimer])); func_8012C9BC(gfxCtx); gSPClearGeometryMode(POLY_XLU_DISP++, G_CULL_BACK); isMaterialApplied++; @@ -996,7 +1008,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { Matrix_RotateXFApply(effect->rotationX); Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gExplosionSplashDL); + gSPDisplayList(POLY_XLU_DISP++, gEffWaterSplashDL); } } } diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h index 61c4a638b..a2d188cba 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h @@ -5,18 +5,6 @@ struct EnClearTag; -typedef enum { - /* 0x00 */ CLEAR_TAG_EFFECT_AVAILABLE, - /* 0x01 */ CLEAR_TAG_EFFECT_DEBRIS, - /* 0x02 */ CLEAR_TAG_EFFECT_FIRE, // never set to, remnant of OoT - /* 0x03 */ CLEAR_TAG_EFFECT_SMOKE, - /* 0x04 */ CLEAR_TAG_EFFECT_FLASH, - /* 0x05 */ CLEAR_TAG_EFFECT_LIGHT_RAYS, - /* 0x06 */ CLEAR_TAG_EFFECT_SHOCKWAVE, - /* 0x07 */ CLEAR_TAG_EFFECT_SPLASH, - /* 0x08 */ CLEAR_TAG_EFFECT_ISOLATED_SMOKE, -} ClearTagEffectType; - typedef struct EnClearTagEffect { /* 0x00 */ u8 type; /* 0x01 */ u8 actionTimer; From d1b75e4c4b9fa365b9ba39e431734c150bfc9f40 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 18 Jun 2022 18:46:41 -0700 Subject: [PATCH 228/257] VisMono OK and documented (#829) * VisMono OK and documented * Add some more parentheses * Fix functions.h * Respond to hansldm's review --- include/PR/gbi.h | 1 + include/functions.h | 12 +- include/variables.h | 2 +- include/z64.h | 6 +- src/code/game.c | 6 +- src/code/z_rcp.c | 8 +- src/code/z_vismono.c | 177 +++++++++++++++++- .../fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c | 2 +- tools/disasm/functions.txt | 10 +- tools/sizes/code_functions.csv | 10 +- 10 files changed, 200 insertions(+), 34 deletions(-) diff --git a/include/PR/gbi.h b/include/PR/gbi.h index 8e5aefe8e..34ec8af31 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -216,6 +216,7 @@ #define GPACK_RGBA5551(r, g, b, a) ((((r)<<8) & 0xf800) | \ (((g)<<3) & 0x7c0) | \ (((b)>>2) & 0x3e) | ((a) & 0x1)) +#define GPACK_IA16(i, a) (((i) << 8) | (a)) #define GPACK_ZDZ(z, dz) ((z) << 2 | (dz)) /* diff --git a/include/functions.h b/include/functions.h index a29024850..1f19f5da4 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2534,12 +2534,12 @@ void func_80140E80(void* param_1); // void func_8014151C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_80141678(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_80141778(void); -void func_801418B0(void* arg0); -void func_80141900(void* arg0); -// void func_80141924(void); -// void func_80141C34(void); -void VisMono_Draw(void* arg0, Gfx** gfx, u32 arg2); -// void func_8014204C(void); +void VisMono_Init(VisMono* this); +void VisMono_Destroy(VisMono* this); +// void VisMono_DesaturateTLUT(u16* tlut); +// void VisMono_DesaturateDList(Gfx* gfx); +void VisMono_Draw(VisMono* this, Gfx** gfxp); +// void VisMono_DrawOld(VisMono* this); void func_801420C0(void* arg0); void func_801420F4(void* arg0); void func_80142100(void* arg0, Gfx** gfx, u32 arg2); diff --git a/include/variables.h b/include/variables.h index c37938555..e8f8d5a3e 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3562,7 +3562,7 @@ extern u16 gFramebuffer0[SCREEN_HEIGHT][SCREEN_WIDTH]; // other segments extern GfxMasterList D_0E000000; extern Mtx D_01000000; -extern UNK_TYPE D_0F000000; +extern u16 D_0F000000[]; #endif diff --git a/include/z64.h b/include/z64.h index 7f1dfd701..5852b9212 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1404,10 +1404,10 @@ typedef struct { typedef struct { /* 0x00 */ u32 unk_00; /* 0x04 */ u32 setScissor; - /* 0x08 */ Color_RGBA8 primColor; - /* 0x0C */ Color_RGBA8 envColor; + /* 0x08 */ Color_RGBA8_u32 primColor; + /* 0x0C */ Color_RGBA8_u32 envColor; /* 0x10 */ u16* tlut; - /* 0x14 */ Gfx* monoDl; + /* 0x14 */ Gfx* dList; } VisMono; // size = 0x18 typedef struct DebugDispObject { diff --git a/src/code/game.c b/src/code/game.c index 2713be299..6f796bc12 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -52,7 +52,7 @@ void GameState_SetFBFilter(Gfx** gfx, u32 arg1) { sMonoColors.envColor.g = R_FB_FILTER_ENV_COLOR(1); sMonoColors.envColor.b = R_FB_FILTER_ENV_COLOR(2); sMonoColors.envColor.a = R_FB_FILTER_A; - VisMono_Draw(&sMonoColors, &dlist, arg1); + VisMono_Draw(&sMonoColors, &dlist); } } } @@ -213,7 +213,7 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g func_80140CE0(&D_801F8010); func_801420C0(&D_801F8020); - func_801418B0(&sMonoColors); + VisMono_Init(&sMonoColors); func_80140898(&D_801F8048); func_801773A0(&D_801F7FF0); func_8013ED9C(); @@ -235,7 +235,7 @@ void GameState_Destroy(GameState* gameState) { func_801773C4(&D_801F7FF0); func_80140D04(&D_801F8010); func_801420F4(&D_801F8020); - func_80141900(&sMonoColors); + VisMono_Destroy(&sMonoColors); func_80140900(&D_801F8048); THA_Dt(&gameState->heap); GameAlloc_Cleanup(&gameState->alloc); diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index f4ffd43c1..1d13be316 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -1239,11 +1239,11 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g gSPDisplayList(&masterGfx[0], D_0E000000.syncSegments); gSPDisplayList(&masterGfx[1], sFillSetupDL); - gDPSetColorImage(&masterGfx[2], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, &D_0F000000); + gDPSetColorImage(&masterGfx[2], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, D_0F000000); if (zbuffer != NULL) { gDPSetDepthImage(&masterGfx[3], zbuffer); } else { - gDPSetDepthImage(&masterGfx[3], &D_0F000000); + gDPSetDepthImage(&masterGfx[3], D_0F000000); } gSPEndDisplayList(&masterGfx[4]); @@ -1267,7 +1267,7 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g gDPSetRenderMode(&masterGfx[3], G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(&masterGfx[4], (GPACK_RGBA5551(255, 255, 240, 0) << 16) | GPACK_RGBA5551(255, 255, 240, 0)); gSPDisplayList(&masterGfx[5], D_0E000000.clearFillRect); - gDPSetColorImage(&masterGfx[6], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, &D_0F000000); + gDPSetColorImage(&masterGfx[6], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, D_0F000000); gSPEndDisplayList(&masterGfx[7]); } @@ -1275,7 +1275,7 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g masterGfx = gGfxMasterDL->clearFrameBuffer; - gDPSetColorImage(&masterGfx[0], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, &D_0F000000); + gDPSetColorImage(&masterGfx[0], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, D_0F000000); gDPSetCycleType(&masterGfx[1], G_CYC_FILL); gDPSetRenderMode(&masterGfx[2], G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(&masterGfx[3], (GPACK_RGBA5551(r, g, b, 1) << 16) | GPACK_RGBA5551(r, g, b, 1)); diff --git a/src/code/z_vismono.c b/src/code/z_vismono.c index 6c0d1ef22..b28ed2aa6 100644 --- a/src/code/z_vismono.c +++ b/src/code/z_vismono.c @@ -1,14 +1,179 @@ +/* + * File: z_vismono.c + * Description: Color frame buffer effect to desaturate the colors. + */ + #include "global.h" #include "system_malloc.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/func_801418B0.s") +// Height of the fragments the color frame buffer (CFB) is split into. +// It is the maximum amount of lines such that all rgba16 SCREEN_WIDTH-long lines fit into +// the half of tmem (0x800 bytes) dedicated to color-indexed data. +#define VISMONO_CFBFRAG_HEIGHT (0x800 / (SCREEN_WIDTH * G_IM_SIZ_16b_BYTES)) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/func_80141900.s") +// Maximum size of the dlist written by `VisMono_DesaturateDList`. +// `VisMono_DesaturateDList` consistently uses `VISMONO_DLSIZE - 2` double words, so this can be 2 less. +#define VISMONO_DLSIZE (3 + SCREEN_HEIGHT / VISMONO_CFBFRAG_HEIGHT * (7 + 2 + 2 + 3) + 2 + 2) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/func_80141924.s") +// How much each color component contributes to the desaturated result. +// These coefficients are close to what the YUV color space defines Y (luminance) as: +// https://en.wikipedia.org/wiki/YUV#Conversion_to/from_RGB +#define VISMONO_FAC_RED 2 +#define VISMONO_FAC_GREEN 4 +#define VISMONO_FAC_BLUE 1 +#define VISMONO_FAC_NORM (0x1F * VISMONO_FAC_RED + 0x1F * VISMONO_FAC_GREEN + 0x1F * VISMONO_FAC_BLUE) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/func_80141C34.s") +void VisMono_Init(VisMono* this) { + bzero(this, sizeof(VisMono)); + this->unk_00 = 0; + this->setScissor = false; + this->primColor.r = 255; + this->primColor.g = 255; + this->primColor.b = 255; + this->primColor.a = 255; + this->envColor.r = 0; + this->envColor.g = 0; + this->envColor.b = 0; + this->envColor.a = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/VisMono_Draw.s") +void VisMono_Destroy(VisMono* this) { + SystemArena_Free(this->dList); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/func_8014204C.s") +void VisMono_DesaturateTLUT(u16* tlut) { + s32 i; + + for (i = 0; i < 256; i++) { + // `tlut[i]` is a IA16 color + // `i` corresponds to either byte of a RGBA16 color RRRR_RGGG GGBB_BBBA from the color frame buffer + + // The high byte I (intensity) corresponds to `i` being interpreted as the high byte RRRR_RGGG + // I = (RRRRR * FAC_RED + GGG00 * FAC_GREEN) * (255 / FAC_NORM) + + // The low byte A (alpha) corresponds to `i` being interpreted as the low byte GGBB_BBBA + // A = (000GG * FAC_GREEN + BBBBB * FAC_BLUE) * (255 / FAC_NORM) + + // Note: I + A = (RRRRR * FAC_RED + GGGGG * FAC_GREEN + BBBBB * FAC_BLUE) * (255 / FAC_NORM) + + tlut[i] = GPACK_IA16( + (((i >> 3) & 0x1F) * VISMONO_FAC_RED + ((i << 2) & 0x1F) * VISMONO_FAC_GREEN) * 255 / VISMONO_FAC_NORM, + (((i >> 6) & 0x1F) * VISMONO_FAC_GREEN + ((i >> 1) & 0x1F) * VISMONO_FAC_BLUE) * 255 / VISMONO_FAC_NORM); + } +} + +Gfx* VisMono_DesaturateDList(Gfx* gfx) { + s32 y; + s32 height = VISMONO_CFBFRAG_HEIGHT; + u16* cfbFrag = D_0F000000; + + gDPPipeSync(gfx++); + // `G_TT_IA16`: use color-indexed images, and IA16 palettes + gDPSetOtherMode(gfx++, + G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_IA16 | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_2CYCLE | G_PM_1PRIMITIVE, + G_AC_NONE | G_ZS_PRIM | GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) | G_RM_CLD_SURF2); + // First color cycle sums texel 1 alpha and texel 0 color + // By using IA16 palettes, this means summing A (from the IA16 color texel 1 maps to) + // with I (from the IA16 color texel 0 maps to) + gDPSetCombineLERP(gfx++, 1, 0, TEXEL1_ALPHA, TEXEL0, 0, 0, 0, 1, PRIMITIVE, ENVIRONMENT, COMBINED, ENVIRONMENT, 0, + 0, 0, PRIMITIVE); + + for (y = 0; y <= SCREEN_HEIGHT - height; y += height) { + // Load a few lines of the color frame buffer + gDPLoadTextureBlock(gfx++, cfbFrag, G_IM_FMT_CI, G_IM_SIZ_8b, SCREEN_WIDTH * 2, height, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + + // Set texel 0 to be a CI8 image with width `SCREEN_WIDTH * 2` and height `VISMONO_CFBFRAG_HEIGHT` + // Its position in texture image space is shifted along +S by 2 + gDPSetTile(gfx++, G_IM_FMT_CI, G_IM_SIZ_8b, SCREEN_WIDTH * 2 * G_IM_SIZ_8b_LINE_BYTES / 8, 0x0, G_TX_RENDERTILE, + 0, G_TX_NOMIRROR | G_TX_CLAMP, 0, 0, G_TX_NOMIRROR | G_TX_CLAMP, 0, 0); + gDPSetTileSize(gfx++, G_TX_RENDERTILE, 2 << 2, 0, (SCREEN_WIDTH * 2 + 1) << 2, + (VISMONO_CFBFRAG_HEIGHT - 1) << 2); + + // Set texel 1 to be a CI8 image with width `SCREEN_WIDTH * 2` and height `VISMONO_CFBFRAG_HEIGHT` + // Its position in texture image space is shifted along +S by 1 + gDPSetTile(gfx++, G_IM_FMT_CI, G_IM_SIZ_8b, SCREEN_WIDTH * 2 * G_IM_SIZ_8b_LINE_BYTES / 8, 0x0, 1, 1, + G_TX_NOMIRROR | G_TX_CLAMP, 0, 0, G_TX_NOMIRROR | G_TX_CLAMP, 0, 0); + gDPSetTileSize(gfx++, 1, 1 << 2, 0, (SCREEN_WIDTH * 2) << 2, (VISMONO_CFBFRAG_HEIGHT - 1) << 2); + + // Draw a `SCREEN_WIDTH` wide, `height` high rectangle. + // Texture coordinate T (vertical) starts at 0 and changes by one each line (dtdy = 1) + // Texture coordinate S (horizontal) starts at 2 and changes by two each column (dsdx = 2) + + // Because texel 0 is shifted by 2 and texel 1 only by 1 along +S, + // a pixel at S coordinates s = 2+2*n will look at the 2*n-th byte of texel 0 and the 2*n+1-th byte of texel 1. + // (in "s = 2+2*n" the first "2" is the starting S coordinate and the second "2" is the dsdx value) + + // The 2*n-th byte of texel 0 is the high byte of the n-th RGBA16 color of the color frame buffer. + // The 2*n+1-th byte of texel 1 is the low byte of the n-th RGBA16 color of the color frame buffer. + + // With the TLUT computed by `VisMono_DesaturateTLUT`: + // The 2*n-th byte of texel 0 maps to a IA16 color where the high byte I (intensity) corresponds to + // the high byte of the n-th RGBA16 color of the color frame buffer. + // The 2*n+1-th byte of texel 1 maps to a IA16 color where the low byte A (alpha) corresponds to + // the low byte of the n-th RGBA16 color of the color frame buffer. + + // Since the combiner is in part set up to sum texel 0 color (I, intensity) with texel 1 alpha (A, alpha), + // the resulting color in the drawn rectangle is a desaturated color as defined by the `VISMONO_FAC_*` values. + + gSPTextureRectangle(gfx++, 0, y << 2, SCREEN_WIDTH << 2, (y + height) << 2, G_TX_RENDERTILE, 2 << 5, 0, 2 << 10, + 1 << 10); + cfbFrag += SCREEN_WIDTH * height; + } + + gDPPipeSync(gfx++); + gSPEndDisplayList(gfx++); + return gfx; +} + +void VisMono_Draw(VisMono* this, Gfx** gfxp) { + Gfx* gfx = *gfxp; + u16* tlut; + Gfx* dList; + Gfx* dListEnd; + + if (this->tlut) { + tlut = this->tlut; + } else { + tlut = Graph_DlistAlloc(&gfx, 256 * G_IM_SIZ_16b_BYTES); + VisMono_DesaturateTLUT(tlut); + } + + if (this->dList) { + dList = this->dList; + } else { + dList = Graph_DlistAlloc(&gfx, VISMONO_DLSIZE * sizeof(Gfx)); + dListEnd = VisMono_DesaturateDList(dList); + } + + gDPPipeSync(gfx++); + + if (this->setScissor == true) { + gSPDisplayList(gfx++, D_0E000000.setScissor); + } + + gDPSetColor(gfx++, G_SETPRIMCOLOR, this->primColor.rgba); + gDPSetColor(gfx++, G_SETENVCOLOR, this->envColor.rgba); + + gDPLoadTLUT_pal256(gfx++, tlut); + + gSPDisplayList(gfx++, dList); + + gDPPipeSync(gfx++); + + *gfxp = gfx; +} + +void VisMono_DrawOld(VisMono* this) { + if (this->tlut == NULL) { + this->tlut = SystemArena_Malloc(256 * G_IM_SIZ_16b_BYTES); + VisMono_DesaturateTLUT(this->tlut); + } + + if (this->dList == NULL) { + this->dList = SystemArena_Malloc(VISMONO_DLSIZE * sizeof(Gfx)); + VisMono_DesaturateDList(this->dList); + } +} diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c index 4c27fe134..87f5638ac 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c @@ -31,7 +31,7 @@ const TransitionInit TransitionWipe5_InitVars = { #endif -extern UNK_TYPE D_0F000000; +extern u16 D_0F000000[]; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_Start.s") diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 5989a3114..a0eae0028 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2769,12 +2769,12 @@ 0x8014151C:("func_8014151C",), 0x80141678:("func_80141678",), 0x80141778:("func_80141778",), - 0x801418B0:("func_801418B0",), - 0x80141900:("func_80141900",), - 0x80141924:("func_80141924",), - 0x80141C34:("func_80141C34",), + 0x801418B0:("VisMono_Init",), + 0x80141900:("VisMono_Destroy",), + 0x80141924:("VisMono_DesaturateTLUT",), + 0x80141C34:("VisMono_DesaturateDList",), 0x80141E60:("VisMono_Draw",), - 0x8014204C:("func_8014204C",), + 0x8014204C:("VisMono_DrawOld",), 0x801420C0:("func_801420C0",), 0x801420F4:("func_801420F4",), 0x80142100:("func_80142100",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 5b7c0d71d..bb57bb8a8 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2283,12 +2283,12 @@ asm/non_matchings/code/code_80140E80/func_80141200.s,func_80141200,0x80141200,0x asm/non_matchings/code/code_80140E80/func_8014151C.s,func_8014151C,0x8014151C,0x57 asm/non_matchings/code/code_80140E80/func_80141678.s,func_80141678,0x80141678,0x40 asm/non_matchings/code/code_80140E80/func_80141778.s,func_80141778,0x80141778,0x4E -asm/non_matchings/code/z_vismono/func_801418B0.s,func_801418B0,0x801418B0,0x14 -asm/non_matchings/code/z_vismono/func_80141900.s,func_80141900,0x80141900,0x9 -asm/non_matchings/code/z_vismono/func_80141924.s,func_80141924,0x80141924,0xC4 -asm/non_matchings/code/z_vismono/func_80141C34.s,func_80141C34,0x80141C34,0x8B +asm/non_matchings/code/z_vismono/VisMono_Init.s,VisMono_Init,0x801418B0,0x14 +asm/non_matchings/code/z_vismono/VisMono_Destroy.s,VisMono_Destroy,0x80141900,0x9 +asm/non_matchings/code/z_vismono/VisMono_DesaturateTLUT.s,VisMono_DesaturateTLUT,0x80141924,0xC4 +asm/non_matchings/code/z_vismono/VisMono_DesaturateDList.s,VisMono_DesaturateDList,0x80141C34,0x8B asm/non_matchings/code/z_vismono/VisMono_Draw.s,VisMono_Draw,0x80141E60,0x7B -asm/non_matchings/code/z_vismono/func_8014204C.s,func_8014204C,0x8014204C,0x1D +asm/non_matchings/code/z_vismono/VisMono_DrawOld.s,VisMono_DrawOld,0x8014204C,0x1D asm/non_matchings/code/code_801420C0/func_801420C0.s,func_801420C0,0x801420C0,0xD asm/non_matchings/code/code_801420C0/func_801420F4.s,func_801420F4,0x801420F4,0x3 asm/non_matchings/code/code_801420C0/func_80142100.s,func_80142100,0x80142100,0xD0 From 03ba9178537f722c2670e69fbb3d3a677f896f57 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sat, 18 Jun 2022 18:51:58 -0700 Subject: [PATCH 229/257] Dm_Stk (Skull Kid) documented, object_stk and object_stk3 fully documented, object_stk2 mostly documented (#827) * Most of object_stk done * Document the original name for every animation * First pass names on every single animation * Enum for animations * Enum for limbs * Very low hanging fruit in dm_stk * Document a lot more in dm_stk * Name most remaining struct vars * Name a bunch of functions * First pass names to all sound functions * Name most functions * Name all other object symbols used by dm_stk * Name all remaining functions and struct vars * Much better animation names and documentation * Lots more function documentation * Document some stuff * Name the title cutscene thing * Last little bit of cleanup * Format * Rename SFX functions * Fix typo in header comment * Respond to Elliptic's review * Respond to Elliptic's clarification about Version1/2 * hitCount -> deflectCount * Take into account some of the feedback that was given for DmZl4 --- assets/xml/objects/object_stk.xml | 240 ++-- assets/xml/objects/object_stk2.xml | 131 +- assets/xml/objects/object_stk3.xml | 15 +- src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c | 4 +- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c | 1328 ++++++++++++--------- src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h | 73 +- tools/disasm/functions.txt | 72 +- 7 files changed, 1087 insertions(+), 776 deletions(-) diff --git a/assets/xml/objects/object_stk.xml b/assets/xml/objects/object_stk.xml index 68e8ae26b..9698e335e 100644 --- a/assets/xml/objects/object_stk.xml +++ b/assets/xml/objects/object_stk.xml @@ -1,110 +1,138 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_stk2.xml b/assets/xml/objects/object_stk2.xml index fe62266a8..2aab5947e 100644 --- a/assets/xml/objects/object_stk2.xml +++ b/assets/xml/objects/object_stk2.xml @@ -1,86 +1,105 @@  + - + + - + - - + + - - - - - - + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + - + - + - - - - - - - - - + + + + + + + + + - + - - + + - - + + - + - - - - - + + + + + - + - + - - - - - - + + + + + + - + - - - - - - - - - - - + + + + + + + + + + + diff --git a/assets/xml/objects/object_stk3.xml b/assets/xml/objects/object_stk3.xml index dbd5da652..7b45bf201 100644 --- a/assets/xml/objects/object_stk3.xml +++ b/assets/xml/objects/object_stk3.xml @@ -1,11 +1,12 @@  + - - - - - - - + + + + + + + diff --git a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c index 4d5a20114..88932cd71 100644 --- a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c +++ b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c @@ -30,7 +30,7 @@ const ActorInit Dm_Sa_InitVars = { (ActorFunc)DmSa_Draw, }; -static AnimationInfo D_80A2ED00[] = { { &object_stk_Anim_00CC94, 1.0f, 0, -1.0f, ANIMMODE_LOOP, 0 } }; +static AnimationInfo D_80A2ED00[] = { { &gSkullKidTPoseAnim, 1.0f, 0, -1.0f, ANIMMODE_LOOP, 0 } }; void func_80A2E960(SkelAnime* arg0, AnimationInfo* animations, u16 index) { f32 frameCount; @@ -52,7 +52,7 @@ void DmSa_Init(Actor* thisx, GlobalContext* globalCtx) { this->alpha = 0xFF; this->actor.targetArrowOffset = 3000.0f; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_stk_Skel_013328, NULL, NULL, NULL, 0); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSkullKidSkel, NULL, NULL, NULL, 0); func_80A2E960(&this->skelAnime, D_80A2ED00, 0); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = DmSa_DoNothing; diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index 782ef8679..10cd5550c 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -1,11 +1,14 @@ /* * File: z_dm_stk.c * Overlay: ovl_Dm_Stk - * Description: Skull Kid (cutscene) + * Description: Skull Kid. Also manages Majora's Mask in the cutscene where its backstory is explained. + * + * This actor is responsible for some somewhat unintuitive things. For example, during certain cutscenes, + * it is responsible for handling the player's sound effects as well. As another example, this actor makes + * time pass when the player looks through the Astral Observatory telescope. */ #include "z_dm_stk.h" -#include "objects/object_stk/object_stk.h" #include "objects/object_stk2/object_stk2.h" #include "objects/object_stk3/object_stk3.h" @@ -18,20 +21,134 @@ void DmStk_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmStk_Update(Actor* thisx, GlobalContext* globalCtx); void DmStk_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80AA16F4(DmStk* this, GlobalContext* globalCtx); -void func_80AA1704(DmStk* this, GlobalContext* globalCtx); -void func_80AA1714(DmStk* this, GlobalContext* globalCtx); -void func_80AA17F8(DmStk* this, GlobalContext* globalCtx); -void func_80AA18D8(DmStk* this, GlobalContext* globalCtx); -void func_80AA192C(DmStk* this, GlobalContext* globalCtx); -void func_80AA1998(DmStk* this, GlobalContext* globalCtx); -void func_80AA19EC(DmStk* this, GlobalContext* globalCtx); -void func_80AA1A50(DmStk* this, GlobalContext* globalCtx); -void func_80AA1AC8(DmStk* this, GlobalContext* globalCtx); -void func_80AA1B9C(DmStk* this, GlobalContext* globalCtx); -void func_80AA1C64(DmStk* this, GlobalContext* globalCtx); -void func_80AA2720(DmStk* this, GlobalContext* globalCtx); -void func_80AA27EC(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_DoNothing(DmStk* this, GlobalContext* globalCtx); +void DmStk_DoNothing(DmStk* this, GlobalContext* globalCtx); +void DmStk_WaitForTelescope(DmStk* this, GlobalContext* globalCtx); +void DmStk_StartTelescopeCutscene(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_StartIntroCutsceneVersion1(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_WaitForIntroCutsceneVersion1ToEnd(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_StartIntroCutsceneVersion2(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_WaitForIntroCutsceneVersion2ToEnd(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_StartDropOcarinaCutscene(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_WaitForDropOcarinaCutsceneToEnd(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_DeflectHit(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_WaitForDeflectionToEnd(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_IdleWithOcarina(DmStk* this, GlobalContext* globalCtx); +void DmStk_ClockTower_Idle(DmStk* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ SK_ANIMATION_SHAKE_HEAD, + /* 1 */ SK_ANIMATION_WALK, + /* 2 */ SK_ANIMATION_LOOK_AROUND, // Not used in the final game + /* 3 */ SK_ANIMATION_IDLE, + /* 4 */ SK_ANIMATION_UNUSED_IDLE, // Unused duplicate of SK_ANIMATION_IDLE + /* 5 */ SK_ANIMATION_BENT_OVER_HEAD_TWITCH, + /* 6 */ SK_ANIMATION_GLITCHY_HORSE_RIDE_START, // Not used in the final game + /* 7 */ SK_ANIMATION_RECLINING_FLOAT, + /* 8 */ SK_ANIMATION_CURSE_START, + /* 9 */ SK_ANIMATION_CURSE_LOOP, + /* 10 */ SK_ANIMATION_LAUGH_START, + /* 11 */ SK_ANIMATION_LAUGH_LOOP, + /* 12 */ SK_ANIMATION_HIDE_OCARINA_START, + /* 13 */ SK_ANIMATION_HIDE_OCARINA_LOOP, + /* 14 */ SK_ANIMATION_PICK_UP_OCARINA_AND_START_PLAYING, + /* 15 */ SK_ANIMATION_PLAY_OCARINA_AND_LAUGH, + /* 16 */ SK_ANIMATION_PICK_UP_OCARINA, // Not used in the final game + /* 17 */ SK_ANIMATION_LOOK_AT_OCARINA, // Not used in the final game + /* 18 */ SK_ANIMATION_KICK_OVER_LINK, + /* 19 */ SK_ANIMATION_SEARCH_LINK, + /* 20 */ SK_ANIMATION_UNUSED_KICK_OVER_LINK, // Unused duplicate of SK_ANIMATION_KICK_OVER_LINK + /* 21 */ SK_ANIMATION_UNUSED_SEARCH_LINK, // Unused duplicate of SK_ANIMATION_SEARCH_LINK + /* 22 */ SK_ANIMATION_HORSE_RIDE_START, + /* 23 */ SK_ANIMATION_HORSE_RIDE_LOOP, + /* 24 */ SK_ANIMATION_RAISE_MASK_START, + /* 25 */ SK_ANIMATION_RAISE_MASK_LOOP, + /* 26 */ SK_ANIMATION_LOWER_MASK, + /* 27 */ SK_ANIMATION_JUMP_WHILE_HIDING_OCARINA, + /* 28 */ SK_ANIMATION_HORSE_RIDE_AND_ROTATE, // Used when Link gets thrown off his horse + /* 29 */ SK_ANIMATION_PLAY_OCARINA_WHILE_FLOATING, + /* 30 */ SK_ANIMATION_FLOATING_TURN_AROUND, + /* 31 */ SK_ANIMATION_OCARINA_JUGGLE, + /* 32 */ SK_ANIMATION_CALL_DOWN_MOON_START, + /* 33 */ SK_ANIMATION_CALL_DOWN_MOON_LOOP, + /* 34 */ SK_ANIMATION_SMACK_FAIRY_START, + /* 35 */ SK_ANIMATION_SMACK_FAIRY_LOOP, + /* 36 */ SK_ANIMATION_HIT_BY_BUBBLE, + /* 37 */ SK_ANIMATION_DROP_OCARINA, + /* 38 */ SK_ANIMATION_FLOATING_ARMS_CROSSED, + /* 39 */ SK_ANIMATION_DEFLECT_ATTACK, + /* 40 */ SK_ANIMATION_TELESCOPE_LOOK_UP_START, + /* 41 */ SK_ANIMATION_TELESCOPE_LOOK_UP_LOOP, + /* 42 */ SK_ANIMATION_SURPRISE_START, + /* 43 */ SK_ANIMATION_SURPRISE_LOOP, + /* 44 */ SK_ANIMATION_LOOK_AROUND_FOR_GIANTS_START, + /* 45 */ SK_ANIMATION_LOOK_AROUND_FOR_GIANTS_LOOP, + /* 46 */ SK_ANIMATION_HOLD_HEAD_AND_SHAKE_START, + /* 47 */ SK_ANIMATION_HOLD_HEAD_AND_SHAKE_LOOP, + /* 48 */ SK_ANIMATION_HOLD_HEAD_AND_SCREAM_START, + /* 49 */ SK_ANIMATION_HOLD_HEAD_AND_SCREAM_LOOP, + /* 50 */ SK_ANIMATION_HUDDLE_WITH_FAIRIES, + /* 51 */ SK_ANIMATION_SEARCH_MASK_SALESMAN, + /* 52 */ SK_ANIMATION_HOLD_UP_MASK_START, + /* 53 */ SK_ANIMATION_HOLD_UP_MASK_LOOP, + /* 54 */ SK_ANIMATION_SHIVER, + /* 55 */ SK_ANIMATION_DRAW, + /* 56 */ SK_ANIMATION_BENT_OVER_LOOK_UP, + /* 57 */ SK_ANIMATION_SPANK, + /* 58 */ SK_ANIMATION_HIP_SHAKE_AND_JUMP, + /* 59 */ SK_ANIMATION_PLAY_FLUTE, + /* 60 */ SK_ANIMATION_CARTWHEEL, + /* 61 */ SK_ANIMATION_LIE_FLAT, + /* 62 */ SK_ANIMATION_DANGLE_FROM_MASK_START, + /* 63 */ SK_ANIMATION_DANGLE_FROM_MASK_LOOP, + /* 64 */ SK_ANIMATION_DROPPED_FROM_MASK, + /* 65 */ SK_ANIMATION_LOOK_UP_AT_GIANTS, + /* 66 */ SK_ANIMATION_ASHAMED_START, + /* 67 */ SK_ANIMATION_ASHAMED_LOOP, + /* 68 */ SK_ANIMATION_LOOK_LEFT_START, + /* 69 */ SK_ANIMATION_LOOK_LEFT_LOOP, + /* 70 */ SK_ANIMATION_SNIFF, + /* 71 */ SK_ANIMATION_LAUGH_AFTER_SNIFF, +} SkullKidAnimationIndex; + +typedef enum { + /* 0 */ SK_MASK_TYPE_NO_MASK, + /* 1 */ SK_MASK_TYPE_NORMAL, + /* 2 */ SK_MASK_TYPE_GLOWING_EYES, + /* 3 */ SK_MASK_TYPE_FADING_OUT, + /* 9 */ SK_MASK_TYPE_RAISED = 9, +} SkullKidMaskType; + +typedef enum { + /* 0 */ SK_HAND_TYPE_HOLDING_LINK_MASK_AND_FLUTE, + /* 1 */ SK_HAND_TYPE_HOLDING_LINK_MASK, + /* 2 */ SK_HAND_TYPE_HOLDING_MAJORAS_MASK, + /* 3 */ SK_HAND_TYPE_HOLDING_OCARINA, + /* 4 */ SK_HAND_TYPE_JUGGLING_OR_DROPPING_OCARINA, + /* 5 */ SK_HAND_TYPE_HOLDING_MAJORAS_MASK_AND_FLUTE, + /* 6 */ SK_HAND_TYPE_HOLDING_FLUTE, + /* 9 */ SK_HAND_TYPE_DEFAULT = 9, +} SkullKidHandType; + +typedef enum { + /* 0 */ SK_FADE_IN_STATE_NONE, + /* 1 */ SK_FADE_IN_STATE_START, + /* 2 */ SK_FADE_IN_STATE_INCREASE_FOG, + /* 3 */ SK_FADE_IN_STATE_INCREASE_ALPHA, +} SkullKidFadeInState; + +typedef enum { + /* 0 */ SK_FADE_OUT_STATE_NONE, + /* 1 */ SK_FADE_OUT_STATE_FADING_OUT, +} SkullKidFadeOutState; + +typedef enum { + /* 0 */ SK_DEKU_PIPES_CS_STATE_NOT_READY, + /* 1 */ SK_DEKU_PIPES_CS_STATE_READY, + /* 2 */ SK_DEKU_PIPES_CS_STATE_PLAYER_USED_OCARINA, + /* 3 */ SK_DEKU_PIPES_CS_STATE_START, + /* 4 */ SK_DEKU_PIPES_CS_STATE_END +} SkullKidDekuPipesCutsceneState; const ActorInit Dm_Stk_InitVars = { ACTOR_DM_STK, @@ -103,101 +220,111 @@ static DamageTable sDamageTable = { }; static AnimationInfo sAnimations[] = { - { &object_stk_Anim_01C21C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk_Anim_01D3D0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk_Anim_001030, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk_Anim_01D008, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk_Anim_01D008, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk_Anim_015C14, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_0070DC, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_00D830, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_00055C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_00130C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_00C270, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_00CBB8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_01AA80, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_01D07C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_016910, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_018ED0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_01DDE0, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_01EF50, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_02DC64, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_02E9A0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_02DC64, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_02E9A0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_0035C8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_0049C8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_0259F4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_0266C8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_026CF4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_01C114, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_004580, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_020CAC, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_02200C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_02336C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk_Anim_002774, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk_Anim_003068, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_0101A4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_010B60, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_02A2D8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_01F9E4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_029A04, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_02AD54, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk_Anim_00BB2C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk_Anim_00C964, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_0110B4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_011FB0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_012A58, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_0141E4, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_00E6EC, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_00EEC0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_027CF4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_028F28, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_03323C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_031210, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_0322FC, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_032AE0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_03021C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_036964, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk_Anim_016508, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk_Anim_015028, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk_Anim_014920, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_02FA70, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_037B94, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_03967C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_03967C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk2_Anim_03A8F8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk2_Anim_034FD8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk3_Anim_005F44, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk3_Anim_002CD8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk3_Anim_0039F0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk3_Anim_004554, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk3_Anim_0051C0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_stk3_Anim_001374, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_stk3_Anim_001EDC, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidShakeHeadAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidWalkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidLookAroundAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidIdleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidIdleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidBentOverHeadTwitchAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidGlitchyHorseRideStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidRecliningFloatAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidCurseStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidCurseLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidLaughStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLaughLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHideOcarinaStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHideOcarinaLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidPickUpOcarinaAndStartPlayingAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidPlayOcarinaAndLaughAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidPickUpOcarinaAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLookAtOcarinaAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidKickOverLinkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidSearchLinkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidKickOverLinkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidSearchLinkAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHorseRideStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHorseRideLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidRaiseMaskStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidRaiseMaskLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidLowerMaskAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidJumpWhileHidingOcarinaAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHorseRideAndRotateAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidPlayOcarinaWhileFloatingAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidFloatingTurnAroundAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidOcarinaJuggleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidCallDownMoonStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidCallDownMoonLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidSmackFairyStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidSmackFairyLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHitByBubbleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidDropOcarinaAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidFloatingArmsCrossedAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidDeflectAttackAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidTelescopeLookUpStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidTelescopeLookUpLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidSurpriseStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidSurpriseLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidLookAroundForGiantsStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLookAroundForGiantsLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHoldHeadAndShakeStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHoldHeadAndShakeLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHoldHeadAndScreamStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHoldHeadAndScreamLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHuddleWithFairiesAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidSearchMaskSalesmanAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHoldUpMaskStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidHoldUpMaskLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidShiverAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidDrawAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidBentOverLookUpAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidSpankAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidHipShakeAndJumpAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidPlayFluteAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidCartwheelAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidDangleFromMaskStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidDangleFromMaskStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidDangleFromMaskLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidDroppedFromMaskAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLookUpAtGiantsAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidAshamedStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidAshamedLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidLookLeftStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLookLeftLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gSkullKidSniffAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &gSkullKidLaughAfterSniffAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, }; -void func_80A9FDB0(DmStk* this, GlobalContext* globalCtx) { - s32 objectIdx; +/** + * Ensures the correct object for the current animation is in segment 6. + */ +void DmStk_LoadObjectForAnimation(DmStk* this, GlobalContext* globalCtx) { + s32 objectIndex; - if (((this->unk_2E0 >= 0) && (this->unk_2E0 <= 5)) || (this->unk_2E0 == 32) || (this->unk_2E0 == 33) || - (this->unk_2E0 == 40) || (this->unk_2E0 == 41)) { - objectIdx = this->unk_336; - } else if (this->unk_2E0 > 64) { - objectIdx = this->unk_338; + if (((this->animationId >= SK_ANIMATION_SHAKE_HEAD) && (this->animationId <= SK_ANIMATION_BENT_OVER_HEAD_TWITCH)) || + (this->animationId == SK_ANIMATION_CALL_DOWN_MOON_START) || + (this->animationId == SK_ANIMATION_CALL_DOWN_MOON_LOOP) || + (this->animationId == SK_ANIMATION_TELESCOPE_LOOK_UP_START) || + (this->animationId == SK_ANIMATION_TELESCOPE_LOOK_UP_LOOP)) { + objectIndex = this->objectStkObjectIndex; + } else if (this->animationId >= SK_ANIMATION_LOOK_UP_AT_GIANTS) { + objectIndex = this->objectStk3ObjectIndex; } else { - objectIdx = this->unk_337; + objectIndex = this->objectStk2ObjectIndex; } - if (objectIdx >= 0) { - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[objectIdx].segment); + if (objectIndex >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[objectIndex].segment); } } -void func_80A9FE3C(DmStk* this, GlobalContext* globalCtx, SkelAnime* skelAnime, AnimationInfo* animation, u16 index) { - func_80A9FDB0(this, globalCtx); +/** + * This function is always called with unusedExtraOffset = 0. + */ +void DmStk_ChangeAnimation(DmStk* this, GlobalContext* globalCtx, SkelAnime* skelAnime, AnimationInfo* animation, + u16 unusedExtraOffset) { + DmStk_LoadObjectForAnimation(this, globalCtx); - animation += index; + animation += unusedExtraOffset; Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, (animation->frameCount < 0.0f) ? Animation_GetLastFrame(&animation->animation->common) @@ -205,7 +332,12 @@ void func_80A9FE3C(DmStk* this, GlobalContext* globalCtx, SkelAnime* skelAnime, animation->mode, animation->morphFrames); } -void func_80A9FED8(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the first part of the intro cutscene, i.e., the cutscene + * that starts when the player start a new game and ends when the screen fades to white + * after Skull Kid steals Epona. + */ +void DmStk_PlaySfxForIntroCutsceneFirstPart(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames + 20) { case 1195: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); @@ -291,13 +423,22 @@ void func_80A9FED8(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA00CC(DmStk* this, GlobalContext* globalCtx) { +/** + * This is supposed to play a bell sound in the title cutscene where the Skull Kid is + * looking at the moon on top of the Clock Tower. However, it doesn't actually play + * any sound in-game, since all sound effects are muted when it plays. + */ +void DmStk_PlaySfxForTitleCutscene(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.frames == 535) { func_8019F128(NA_SE_EV_CLOCK_TOWER_BELL); } } -void func_80AA0100(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the second part of the intro cutscene, i.e., the cutscene + * that starts after the fade-to-white and ends when the player gains control. + */ +void DmStk_PlaySfxForIntroCutsceneSecondPart(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 78: case 89: @@ -325,7 +466,11 @@ void func_80AA0100(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0158(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the cutscene where Skull Kid steals Majora's Mask from + * the Happy Mask Salesman. + */ +void DmStk_PlaySfxForObtainingMajorasMaskCutscene(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 18: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_GASAGOSO); @@ -341,7 +486,12 @@ void func_80AA0158(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA01C0(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the first part of the curse cutscene, i.e., the cutscene + * that starts when Link falls down the large hole and ends with a fade-to-black to + * the hallucinatory Deku Scrubs scene. + */ +void DmStk_PlaySfxForCurseCutsceneFirstPart(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 415: func_801A479C(&this->actor.projectedPos, NA_SE_EN_STALKIDS_FLOAT, 100); @@ -362,7 +512,12 @@ void func_80AA01C0(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0264(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the second part of the curse cutscene, i.e., the cutscene + * that starts once the hallucinatory Deku Scrubs scene is over and ends when the player + * gains control. + */ +void DmStk_PlaySfxForCurseCutsceneSecondPart(DmStk* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); switch (globalCtx->csCtx.frames) { @@ -410,8 +565,13 @@ void func_80AA0264(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0420(DmStk* this, GlobalContext* globalCtx) { - static s32 D_80AA3CB8 = 0; +/** + * Handles sound effects for the intro cutscene at the top of the Clock Tower. Specifically, + * it handles the variation of the cutscene that plays the first time the player reaches the + * top of the Clock Tower, which is slightly longer. + */ +void DmStk_PlaySfxForClockTowerIntroCutsceneVersion1(DmStk* this, GlobalContext* globalCtx) { + static s32 sMoonCallTimer = 0; switch (globalCtx->csCtx.frames) { case 140: @@ -436,7 +596,7 @@ void func_80AA0420(DmStk* this, GlobalContext* globalCtx) { break; } - if ((this->unk_2E0 == 31) && (globalCtx->csCtx.frames < 700)) { + if ((this->animationId == SK_ANIMATION_OCARINA_JUGGLE) && (globalCtx->csCtx.frames < 700)) { if (Animation_OnFrame(&this->skelAnime, 5.0f) || Animation_OnFrame(&this->skelAnime, 25.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_OTEDAMA1); } else if (Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 40.0f)) { @@ -445,33 +605,44 @@ void func_80AA0420(DmStk* this, GlobalContext* globalCtx) { } if (globalCtx->csCtx.frames >= 700) { - if (D_80AA3CB8 < 128) { - if ((D_80AA3CB8 & 0x1F) == 0) { + if (sMoonCallTimer < 128) { + if ((sMoonCallTimer & 0x1F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON); - } else if ((D_80AA3CB8 & 0x1F) == 16) { + } else if ((sMoonCallTimer & 0x1F) == 16) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); } - D_80AA3CB8++; + + sMoonCallTimer++; } } else { - D_80AA3CB8 = 0; + sMoonCallTimer = 0; } } -void func_80AA05F0(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the cutscene where Skull Kid drops the Ocarina of Time. + */ +void DmStk_PlaySfxForDroppingOcarinaCutscene(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.frames == 3) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL06_SURPRISED); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); } } -void func_80AA0634(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the cutscene where Skull Kid is shivering in the rain. + */ +void DmStk_PlaySfxForShiveringInRainCutscene(DmStk* this, GlobalContext* globalCtx) { if ((globalCtx->csCtx.frames >= 642) && (globalCtx->csCtx.frames < 845)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_NE_STAL23_COLD - SFX_FLAG); } } -void func_80AA066C(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the cutscene where Skull Kid is playing with Tatl and Tael + * in Termina Field. + */ +void DmStk_PlaySfxForPlayingWithFairiesCutscene(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 58: case 61: @@ -493,7 +664,12 @@ void func_80AA066C(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA071C(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the first part of the ending cutscene, i.e., the cutscene + * that starts after the Dawn of the New Day screen and ends with a fade to black as + * the Giants are walking away. + */ +void DmStk_PlaySfxForEndingCutsceneFirstPart(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 5: func_801A4A28(12); @@ -505,7 +681,11 @@ void func_80AA071C(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA076C(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the second part of the ending cutscene, i.e., the cutscene + * that starts after a fade-to-black and ends after the credits start. + */ +void DmStk_PlaySfxForEndingCutsceneSecondPart(DmStk* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); switch (globalCtx->csCtx.frames) { @@ -554,7 +734,7 @@ void func_80AA076C(DmStk* this, GlobalContext* globalCtx) { break; } - if (this->unk_2E0 == 0) { + if (this->animationId == SK_ANIMATION_SHAKE_HEAD) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); } @@ -562,19 +742,24 @@ void func_80AA076C(DmStk* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 28.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_RIDE); } - } else if (this->unk_2E0 == 71) { + } else if (this->animationId == SK_ANIMATION_LAUGH_AFTER_SNIFF) { if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f) || Animation_OnFrame(&this->skelAnime, 12.0f) || Animation_OnFrame(&this->skelAnime, 18.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); } - } else if ((this->unk_2E0 == 70) && + } else if ((this->animationId == SK_ANIMATION_SNIFF) && (Animation_OnFrame(&this->skelAnime, 16.0f) || Animation_OnFrame(&this->skelAnime, 23.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_NOSE); } } -void func_80AA09DC(DmStk* this, GlobalContext* globalCtx) { - static s32 D_80AA3CBC = 0; +/** + * Handles sound effects for the intro cutscene at the top of the Clock Tower. Specifically, + * it handles the variation of the cutscene that plays the second or later time the player + * reaches the top of the Clock Tower, which is slightly shorter. + */ +void DmStk_PlaySfxForClockTowerIntroCutsceneVersion2(DmStk* this, GlobalContext* globalCtx) { + static s32 sMoonCallTimer = 0; switch (globalCtx->csCtx.frames) { case 40: @@ -596,27 +781,32 @@ void func_80AA09DC(DmStk* this, GlobalContext* globalCtx) { } if (globalCtx->csCtx.frames >= 408) { - if (D_80AA3CBC < 128) { - if ((D_80AA3CBC & 0x1F) == 0) { + if (sMoonCallTimer < 128) { + if ((sMoonCallTimer & 0x1F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON); - } else if ((D_80AA3CBC & 0x1F) == 16) { + } else if ((sMoonCallTimer & 0x1F) == 16) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STAL20_CALL_MOON2); } - D_80AA3CBC++; + + sMoonCallTimer++; } } else { - D_80AA3CBC = 0; + sMoonCallTimer = 0; } } -void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { - this->unk_310.x = this->actor.projectedPos.x; - this->unk_310.y = this->actor.projectedPos.y; - this->unk_310.z = this->actor.projectedPos.z; +/** + * Handles sound effects for the cutscene that plays after the player plays the + * Oath to Order at the top of the Clock Tower. + */ +void DmStk_PlaySfxForCutsceneAfterPlayingOathToOrder(DmStk* this, GlobalContext* globalCtx) { + this->oathToOrderCutsceneVoicePos.x = this->actor.projectedPos.x; + this->oathToOrderCutsceneVoicePos.y = this->actor.projectedPos.y; + this->oathToOrderCutsceneVoicePos.z = this->actor.projectedPos.z; switch (globalCtx->csCtx.frames) { case 64: - Audio_PlaySfxAtPos(&this->unk_310, NA_SE_EN_STAL06_SURPRISED); + Audio_PlaySfxAtPos(&this->oathToOrderCutsceneVoicePos, NA_SE_EN_STAL06_SURPRISED); break; case 327: @@ -636,11 +826,11 @@ void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { case 486: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_MASK_OFF); - Audio_PlaySfxAtPos(&this->unk_310, NA_SE_EN_STAL08_CRY_BIG); + Audio_PlaySfxAtPos(&this->oathToOrderCutsceneVoicePos, NA_SE_EN_STAL08_CRY_BIG); break; case 496: - Audio_PlaySfxAtPos(&this->unk_310, NA_SE_EN_STAL09_SCREAM); + Audio_PlaySfxAtPos(&this->oathToOrderCutsceneVoicePos, NA_SE_EN_STAL09_SCREAM); break; case 590: @@ -652,7 +842,7 @@ void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { break; case 594: - Audio_PlaySfxAtPos(&this->unk_310, NA_SE_EN_STAL24_SCREAM2); + Audio_PlaySfxAtPos(&this->oathToOrderCutsceneVoicePos, NA_SE_EN_STAL24_SCREAM2); break; } @@ -679,7 +869,12 @@ void func_80AA0B08(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0DA8(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the cutscene before the player warps to the moon. Specifically, + * it handles the variation of the cutscene that plays the first time the player warps to the + * moon, which is slightly longer. + */ +void DmStk_PlaySfxForMoonWarpCutsceneVersion1(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 551: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_PULLED); @@ -696,7 +891,12 @@ void func_80AA0DA8(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0E1C(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for the cutscene before the player warps to the moon. Specifically, + * it handles the variation of the cutscene that plays the second or later time the player + * warps to the moon, which is slightly shorter. + */ +void DmStk_PlaySfxForMoonWarpCutsceneVersion2(DmStk* this, GlobalContext* globalCtx) { switch (globalCtx->csCtx.frames) { case 311: Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_PULLED); @@ -713,31 +913,34 @@ void func_80AA0E1C(DmStk* this, GlobalContext* globalCtx) { } } -void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles sound effects for all cutscenes. + */ +void DmStk_PlaySfxForCutscenes(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state != 0) { switch (globalCtx->sceneNum) { case SCENE_LOST_WOODS: if (gSaveContext.sceneSetupIndex == 1) { - func_80A9FED8(this, globalCtx); + DmStk_PlaySfxForIntroCutsceneFirstPart(this, globalCtx); } else if (gSaveContext.sceneSetupIndex == 0) { - func_80AA0100(this, globalCtx); + DmStk_PlaySfxForIntroCutsceneSecondPart(this, globalCtx); } else if ((gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.currentCsIndex == 0)) { - func_80AA0158(this, globalCtx); + DmStk_PlaySfxForObtainingMajorasMaskCutscene(this, globalCtx); } break; case SCENE_CLOCKTOWER: if (gSaveContext.sceneSetupIndex == 1) { - func_80AA00CC(this, globalCtx); + DmStk_PlaySfxForTitleCutscene(this, globalCtx); } break; case SCENE_OPENINGDAN: if (gSaveContext.sceneSetupIndex == 0) { if (globalCtx->csCtx.currentCsIndex == 0) { - func_80AA01C0(this, globalCtx); + DmStk_PlaySfxForCurseCutsceneFirstPart(this, globalCtx); } else if (globalCtx->csCtx.currentCsIndex == 1) { - func_80AA0264(this, globalCtx); + DmStk_PlaySfxForCurseCutsceneSecondPart(this, globalCtx); } } break; @@ -745,19 +948,19 @@ void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { case SCENE_OKUJOU: if (gSaveContext.sceneSetupIndex == 0) { if (globalCtx->csCtx.currentCsIndex == 0) { - func_80AA0420(this, globalCtx); + DmStk_PlaySfxForClockTowerIntroCutsceneVersion1(this, globalCtx); } else if (globalCtx->csCtx.currentCsIndex == 1) { - func_80AA05F0(this, globalCtx); + DmStk_PlaySfxForDroppingOcarinaCutscene(this, globalCtx); } else if (globalCtx->csCtx.currentCsIndex == 2) { - func_80AA09DC(this, globalCtx); + DmStk_PlaySfxForClockTowerIntroCutsceneVersion2(this, globalCtx); } else if (globalCtx->csCtx.currentCsIndex == 3) { - func_80AA0B08(this, globalCtx); + DmStk_PlaySfxForCutsceneAfterPlayingOathToOrder(this, globalCtx); } } else if (gSaveContext.sceneSetupIndex == 2) { if (globalCtx->csCtx.currentCsIndex == 0) { - func_80AA0DA8(this, globalCtx); + DmStk_PlaySfxForMoonWarpCutsceneVersion1(this, globalCtx); } else if (globalCtx->csCtx.currentCsIndex == 1) { - func_80AA0E1C(this, globalCtx); + DmStk_PlaySfxForMoonWarpCutsceneVersion2(this, globalCtx); } } break; @@ -765,35 +968,35 @@ void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { case SCENE_00KEIKOKU: if (gSaveContext.sceneSetupIndex == 3) { if (globalCtx->csCtx.currentCsIndex == 0) { - func_80AA0634(this, globalCtx); + DmStk_PlaySfxForShiveringInRainCutscene(this, globalCtx); } else if (globalCtx->csCtx.currentCsIndex == 2) { - func_80AA066C(this, globalCtx); + DmStk_PlaySfxForPlayingWithFairiesCutscene(this, globalCtx); } } else if (gSaveContext.sceneSetupIndex == 7) { if (globalCtx->csCtx.currentCsIndex == 0) { - func_80AA071C(this, globalCtx); + DmStk_PlaySfxForEndingCutsceneFirstPart(this, globalCtx); } else if (globalCtx->csCtx.currentCsIndex == 1) { - func_80AA076C(this, globalCtx); + DmStk_PlaySfxForEndingCutsceneSecondPart(this, globalCtx); } } break; } } - if (this->unk_2E0 == 1) { + if (this->animationId == SK_ANIMATION_WALK) { if (Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 6.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_WALK); } - } else if (this->unk_2E0 == 19) { + } else if (this->animationId == SK_ANIMATION_SEARCH_LINK) { if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 13.0f) || Animation_OnFrame(&this->skelAnime, 20.0f) || Animation_OnFrame(&this->skelAnime, 27.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_CALM_HIT); } - } else if (this->unk_2E0 == 14) { + } else if (this->animationId == SK_ANIMATION_PICK_UP_OCARINA_AND_START_PLAYING) { if (Animation_OnFrame(&this->skelAnime, 3.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_PUT_OUT_ITEM); } - } else if (this->unk_2E0 == 15) { + } else if (this->animationId == SK_ANIMATION_PLAY_OCARINA_AND_LAUGH) { if (Animation_OnFrame(&this->skelAnime, 14.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_UNSKILLFUL_OCARINA); } @@ -808,42 +1011,43 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; DmStk* this = THIS; - this->unk_33B = 1; - if (this->actor.params != 1) { - this->unk_33A = 0; - this->unk_336 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK); - this->unk_337 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK2); - this->unk_338 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK3); - if (this->unk_336 < 0) { + this->shouldDraw = true; + if (DM_STK_GET_TYPE(&this->actor) != DM_STK_TYPE_MAJORAS_MASK) { + this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_NOT_READY; + this->objectStkObjectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK); + this->objectStk2ObjectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK2); + this->objectStk3ObjectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STK3); + if (this->objectStkObjectIndex < 0) { Actor_MarkForDeath(&this->actor); } - this->unk_328 = 0; - this->unk_339 = 0; - this->unk_32C = 1; - this->unk_2E0 = 3; - this->unk_2E8 = globalCtx->lightCtx.unk7; - this->unk_2EC = globalCtx->lightCtx.unk8; - this->unk_2F0 = globalCtx->lightCtx.unk9; + this->tatlMessageTimer = 0; + this->deflectCount = 0; + this->maskType = SK_MASK_TYPE_NORMAL; + this->animationId = SK_ANIMATION_IDLE; + this->fogR = globalCtx->lightCtx.unk7; + this->fogG = globalCtx->lightCtx.unk8; + this->fogB = globalCtx->lightCtx.unk9; if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1)) { - this->unk_2E4 = 0; - this->unk_2F8 = 0; - this->unk_2FC = 1000; - this->unk_300 = 1.0f; - this->actionFunc = func_80AA1704; + this->alpha = 0; + this->fogN = 0; + this->fogF = 1000; + this->fogScale = 1.0f; + this->actionFunc = DmStk_DoNothing; } else if (globalCtx->sceneNum == SCENE_OKUJOU) { - this->unk_2E4 = 255; - this->unk_2F8 = 996; - this->unk_2FC = 1000; - this->unk_300 = 0.7f; - this->unk_335 = 0; + this->alpha = 255; + this->fogN = 996; + this->fogF = 1000; + this->fogScale = 0.7f; + this->hasBeenHit = false; Collider_InitCylinder(globalCtx, &this->collider); if (gSaveContext.save.entranceIndex == 0x2C00) { if (gSaveContext.sceneSetupIndex == 0) { if (gSaveContext.unk_3DD0[3] == 0) { + // Starts a 5 minute (300 second) timer until the moon falls. func_8010E9F0(3, 300); XREG(80) = 200; XREG(81) = 115; @@ -851,32 +1055,35 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { sCylinderInit.base.colType = COLTYPE_WOOD; - this->actionFunc = func_80AA18D8; + this->actionFunc = DmStk_ClockTower_StartIntroCutsceneVersion1; } else { sCylinderInit.base.colType = COLTYPE_WOOD; - this->actionFunc = func_80AA1998; + this->actionFunc = DmStk_ClockTower_StartIntroCutsceneVersion2; } } else if (gSaveContext.sceneSetupIndex == 3) { - this->unk_2E0 = 38; + this->animationId = SK_ANIMATION_FLOATING_ARMS_CROSSED; if (gSaveContext.unk_3DD0[3] == 0) { + // This code is called when the Giants fail to stop the moon. + // Starts a 1 minute (60 second) timer until the moon falls. func_8010E9F0(3, 60); XREG(80) = 200; XREG(81) = 115; } + this->actor.world.pos.y = 120.0f; sCylinderInit.base.colType = COLTYPE_WOOD; - this->actionFunc = func_80AA27EC; + this->actionFunc = DmStk_ClockTower_Idle; } else { - this->unk_2E0 = 38; - this->actionFunc = func_80AA16F4; + this->animationId = SK_ANIMATION_FLOATING_ARMS_CROSSED; + this->actionFunc = DmStk_ClockTower_DoNothing; } } else { - this->unk_33A = 1; - this->unk_2E0 = 38; + this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_READY; + this->animationId = SK_ANIMATION_FLOATING_ARMS_CROSSED; this->actor.world.pos.y = 120.0f; sCylinderInit.base.colType = COLTYPE_WOOD; - this->actionFunc = func_80AA27EC; + this->actionFunc = DmStk_ClockTower_Idle; } Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -886,35 +1093,37 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { if (!(globalCtx->actorCtx.unk5 & 2)) { Actor_MarkForDeath(&this->actor); } - this->unk_32C = 2; - this->unk_2E4 = 255; - this->unk_2F8 = 996; - this->unk_2FC = 1000; - this->unk_300 = 0.7f; - this->unk_2E0 = 5; - this->actionFunc = func_80AA1714; + + this->maskType = SK_MASK_TYPE_GLOWING_EYES; + this->alpha = 255; + this->fogN = 996; + this->fogF = 1000; + this->fogScale = 0.7f; + this->animationId = SK_ANIMATION_BENT_OVER_HEAD_TWITCH; + this->actionFunc = DmStk_WaitForTelescope; } else { if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(globalCtx)) { Actor_MarkForDeath(&this->actor); } - this->unk_32C = 2; - this->unk_2E4 = 255; - this->unk_2F8 = 996; - this->unk_2FC = 1000; - this->unk_300 = 0.7f; - this->actionFunc = func_80AA1704; + + this->maskType = SK_MASK_TYPE_GLOWING_EYES; + this->alpha = 255; + this->fogN = 996; + this->fogF = 1000; + this->fogScale = 0.7f; + this->actionFunc = DmStk_DoNothing; } - this->unk_32D = 9; - this->unk_32E = 0; - this->unk_32F = 0; - this->unk_330 = 0; - this->unk_2E4 = this->unk_2E4; + this->handType = SK_HAND_TYPE_DEFAULT; + this->fadeInState = SK_FADE_IN_STATE_NONE; + this->fadeOutState = SK_FADE_OUT_STATE_NONE; + this->fadeOutTimer = 0; + this->alpha = this->alpha; this->actor.targetArrowOffset = 1100.0f; - this->unk_334 = 99; + this->csAction = 99; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_stk_Skel_013328, NULL, NULL, NULL, 0); - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSkullKidSkel, NULL, NULL, NULL, 0); + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); } Actor_SetScale(&this->actor, 0.01f); @@ -929,111 +1138,121 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { void DmStk_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void func_80AA16F4(DmStk* this, GlobalContext* globalCtx) { +void DmStk_ClockTower_DoNothing(DmStk* this, GlobalContext* globalCtx) { } -void func_80AA1704(DmStk* this, GlobalContext* globalCtx) { +void DmStk_DoNothing(DmStk* this, GlobalContext* globalCtx) { } -void func_80AA1714(DmStk* this, GlobalContext* globalCtx) { - Vec3f sp1C; +/** + * Waits around until the player zooms the telescope in on Skull Kid, + * then starts the telescope cutscene. + */ +void DmStk_WaitForTelescope(DmStk* this, GlobalContext* globalCtx) { + Vec3f screenPos; if (!(gSaveContext.save.weekEventReg[74] & 0x20)) { - func_80169474(globalCtx, &this->actor.world.pos, &sp1C); + func_80169474(globalCtx, &this->actor.world.pos, &screenPos); if (globalCtx->view.fovy < 25.0f) { - if ((sp1C.x >= 70.0f) && (sp1C.x < 250.0f) && (sp1C.y >= 30.0f) && (sp1C.y < 210.0f)) { + if ((screenPos.x >= 70.0f) && (screenPos.x < 250.0f) && (screenPos.y >= 30.0f) && (screenPos.y < 210.0f)) { func_800FE484(); - this->actionFunc = func_80AA17F8; + this->actionFunc = DmStk_StartTelescopeCutscene; } } } } -void func_80AA17F8(DmStk* this, GlobalContext* globalCtx) { - s16 sp1E = this->actor.cutscene; - s16 sp1C = ActorCutscene_GetAdditionalCutscene(sp1E); - s16 sp18 = ActorCutscene_GetAdditionalCutscene(sp1C); +/** + * Plays the cutscene in the telescope where the Moon's Tear falls. + */ +void DmStk_StartTelescopeCutscene(DmStk* this, GlobalContext* globalCtx) { + s16 dayOneAndTwoCutscene = this->actor.cutscene; + s16 dayThreeCutscene = ActorCutscene_GetAdditionalCutscene(dayOneAndTwoCutscene); + s16 finalHoursCutscene = ActorCutscene_GetAdditionalCutscene(dayThreeCutscene); s16 cutscene; if (gSaveContext.save.day < 3) { - cutscene = sp1E; + cutscene = dayOneAndTwoCutscene; } else if ((gSaveContext.save.weekEventReg[8] & 0x40) || ((CURRENT_DAY == 3) && (gSaveContext.save.time < CLOCK_TIME(6, 0)))) { - cutscene = sp18; + cutscene = finalHoursCutscene; } else { - cutscene = sp1C; + cutscene = dayThreeCutscene; } if (ActorCutscene_GetCanPlayNext(cutscene)) { ActorCutscene_Start(cutscene, &this->actor); func_800FE498(); - this->actionFunc = func_80AA1704; + this->actionFunc = DmStk_DoNothing; } else { ActorCutscene_SetIntentToPlay(cutscene); } } -void func_80AA18D8(DmStk* this, GlobalContext* globalCtx) { +void DmStk_ClockTower_StartIntroCutsceneVersion1(DmStk* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(9)) { ActorCutscene_Start(9, &this->actor); - this->actionFunc = func_80AA192C; + this->actionFunc = DmStk_ClockTower_WaitForIntroCutsceneVersion1ToEnd; } else { ActorCutscene_SetIntentToPlay(9); } } -void func_80AA192C(DmStk* this, GlobalContext* globalCtx) { +void DmStk_ClockTower_WaitForIntroCutsceneVersion1ToEnd(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state == 0) { - this->unk_2E0 = 33; - this->unk_32D = 3; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); - this->actionFunc = func_80AA2720; + this->animationId = SK_ANIMATION_CALL_DOWN_MOON_LOOP; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); + this->actionFunc = DmStk_ClockTower_IdleWithOcarina; } } -void func_80AA1998(DmStk* this, GlobalContext* globalCtx) { - if (ActorCutscene_GetCanPlayNext(0xB)) { - ActorCutscene_Start(0xB, &this->actor); - this->actionFunc = func_80AA19EC; +void DmStk_ClockTower_StartIntroCutsceneVersion2(DmStk* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(11)) { + ActorCutscene_Start(11, &this->actor); + this->actionFunc = DmStk_ClockTower_WaitForIntroCutsceneVersion2ToEnd; } else { - ActorCutscene_SetIntentToPlay(0xB); + ActorCutscene_SetIntentToPlay(11); } } -void func_80AA19EC(DmStk* this, GlobalContext* globalCtx) { +void DmStk_ClockTower_WaitForIntroCutsceneVersion2ToEnd(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state == 0) { - this->unk_2E0 = 38; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); - this->actionFunc = func_80AA27EC; + this->animationId = SK_ANIMATION_FLOATING_ARMS_CROSSED; + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); + this->actionFunc = DmStk_ClockTower_Idle; } } -void func_80AA1A50(DmStk* this, GlobalContext* globalCtx) { - if (ActorCutscene_GetCanPlayNext(0xA)) { +void DmStk_ClockTower_StartDropOcarinaCutscene(DmStk* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(10)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DAMAGE); - ActorCutscene_Start(0xA, &this->actor); + ActorCutscene_Start(10, &this->actor); this->actor.shape.rot.x = 0; this->actor.world.rot.x = this->actor.shape.rot.x; this->actor.shape.rot.y = this->actor.shape.rot.x; this->actor.world.rot.y = this->actor.shape.rot.x; - this->actionFunc = func_80AA1AC8; + this->actionFunc = DmStk_ClockTower_WaitForDropOcarinaCutsceneToEnd; } else { - ActorCutscene_SetIntentToPlay(0xA); + ActorCutscene_SetIntentToPlay(10); } } -void func_80AA1AC8(DmStk* this, GlobalContext* globalCtx) { +void DmStk_ClockTower_WaitForDropOcarinaCutsceneToEnd(DmStk* this, GlobalContext* globalCtx) { if ((globalCtx->csCtx.state != 0) && (globalCtx->csCtx.frames > 20)) { - this->actionFunc = func_80AA27EC; + this->actionFunc = DmStk_ClockTower_Idle; } } -void func_80AA1AF8(DmStk* this, GlobalContext* globalCtx) { +/** + * Makes Skull Kid bob up and down and face the player. + */ +void DmStk_ClockTower_AdjustHeightAndRotation(DmStk* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 sin; - this->unk_32A += 0x4B0; - sin = Math_SinS(this->unk_32A) * 10.0f; + this->bobPhase += 0x4B0; + sin = Math_SinS(this->bobPhase) * 10.0f; Math_SmoothStepToF(&this->actor.world.pos.y, 160.0f + sin, 0.2f, 1.0f, 0.0001f); this->actor.world.rot.y = Actor_YawBetweenActors(&this->actor, &player->actor); @@ -1043,148 +1262,161 @@ void func_80AA1AF8(DmStk* this, GlobalContext* globalCtx) { this->actor.shape.rot.x = this->actor.world.rot.x; } -void func_80AA1B9C(DmStk* this, GlobalContext* globalCtx) { +/** + * Starts the deflection animation and, depending on how many times Skull Kid has been hit, + * prints a message taunting the player. + */ +void DmStk_ClockTower_DeflectHit(DmStk* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - func_80AA1AF8(this, globalCtx); - this->unk_339++; - if (this->unk_339 >= 3) { - this->unk_339 = 0; + DmStk_ClockTower_AdjustHeightAndRotation(this, globalCtx); + this->deflectCount++; + if (this->deflectCount >= 3) { + this->deflectCount = 0; if (!(player->stateFlags2 & 0x8000000)) { + // That won't do you any good Message_StartTextbox(globalCtx, 0x2013, &this->actor); } } - this->unk_2E0 = 39; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + this->animationId = SK_ANIMATION_DEFLECT_ATTACK; + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_DOWN_K); - this->actionFunc = func_80AA1C64; + this->actionFunc = DmStk_ClockTower_WaitForDeflectionToEnd; } -void func_80AA1C64(DmStk* this, GlobalContext* globalCtx) { - func_80AA1AF8(this, globalCtx); +/** + * Resets Skull Kid back to his idle state once the deflection animation ends. + * If he is hit again before the animation ends, this function will make his deflection restart. + */ +void DmStk_ClockTower_WaitForDeflectionToEnd(DmStk* this, GlobalContext* globalCtx) { + DmStk_ClockTower_AdjustHeightAndRotation(this, globalCtx); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->unk_2E0 = 38; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); - this->actionFunc = func_80AA27EC; + this->animationId = SK_ANIMATION_FLOATING_ARMS_CROSSED; + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); + this->actionFunc = DmStk_ClockTower_Idle; } if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { - this->actionFunc = func_80AA1B9C; + this->actionFunc = DmStk_ClockTower_DeflectHit; } } -void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { +/** + * Updates a variety of states based on Skull Kid's current cutscene, including his current + * animation, his hand/mask type, his fade in/fade out state, and his current cutscene action. + */ +void DmStk_UpdateCutscenes(DmStk* this, GlobalContext* globalCtx) { s32 pad; - s32 temp_v0; + s32 actorActionIndex; if (Cutscene_CheckActorAction(globalCtx, 107)) { - temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 107); + actorActionIndex = Cutscene_GetActorActionIndex(globalCtx, 107); - if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[temp_v0]->startFrame) { - if (this->unk_334 != globalCtx->csCtx.actorActions[temp_v0]->action) { - this->unk_334 = globalCtx->csCtx.actorActions[temp_v0]->action; + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actorActionIndex]->startFrame) { + if (this->csAction != globalCtx->csCtx.actorActions[actorActionIndex]->action) { + this->csAction = globalCtx->csCtx.actorActions[actorActionIndex]->action; if (globalCtx->sceneNum == SCENE_CLOCKTOWER) { - this->unk_32D = 6; + this->handType = SK_HAND_TYPE_HOLDING_FLUTE; } else { - this->unk_32D = 9; + this->handType = SK_HAND_TYPE_DEFAULT; } - switch (globalCtx->csCtx.actorActions[temp_v0]->action) { + switch (globalCtx->csCtx.actorActions[actorActionIndex]->action) { case 0: case 1: - this->unk_2E0 = 3; + this->animationId = SK_ANIMATION_IDLE; break; case 2: - this->unk_2E0 = 1; + this->animationId = SK_ANIMATION_WALK; break; case 3: - this->unk_2E0 = 20; + this->animationId = SK_ANIMATION_UNUSED_KICK_OVER_LINK; break; case 4: - this->unk_2E0 = 18; + this->animationId = SK_ANIMATION_KICK_OVER_LINK; break; case 6: - this->unk_2E0 = 16; - this->unk_32D = 3; + this->animationId = SK_ANIMATION_PICK_UP_OCARINA; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; break; case 7: - this->unk_2E0 = 14; - this->unk_32D = 3; + this->animationId = SK_ANIMATION_PICK_UP_OCARINA_AND_START_PLAYING; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; break; case 8: - this->unk_2E0 = 0; + this->animationId = SK_ANIMATION_SHAKE_HEAD; break; case 9: - this->unk_2E0 = 3; - this->unk_32E = 1; + this->animationId = SK_ANIMATION_IDLE; + this->fadeInState = SK_FADE_IN_STATE_START; break; case 12: - this->unk_2E0 = 12; - this->unk_32D = 3; + this->animationId = SK_ANIMATION_HIDE_OCARINA_START; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; break; case 13: - this->unk_2E0 = 27; - this->unk_32D = 3; + this->animationId = SK_ANIMATION_JUMP_WHILE_HIDING_OCARINA; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; break; case 14: - this->unk_2E0 = 22; + this->animationId = SK_ANIMATION_HORSE_RIDE_START; break; case 15: - this->unk_2E0 = 23; + this->animationId = SK_ANIMATION_HORSE_RIDE_LOOP; break; case 16: - this->unk_2E0 = 28; + this->animationId = SK_ANIMATION_HORSE_RIDE_AND_ROTATE; break; case 17: - this->unk_2E0 = 7; + this->animationId = SK_ANIMATION_RECLINING_FLOAT; break; case 18: - this->unk_2E0 = 8; + this->animationId = SK_ANIMATION_CURSE_START; break; case 19: - this->unk_2E0 = 10; + this->animationId = SK_ANIMATION_LAUGH_START; break; case 20: - this->unk_2E0 = 24; + this->animationId = SK_ANIMATION_RAISE_MASK_START; break; case 21: - this->unk_2E0 = 26; + this->animationId = SK_ANIMATION_LOWER_MASK; break; case 22: - this->unk_2E0 = 29; + this->animationId = SK_ANIMATION_PLAY_OCARINA_WHILE_FLOATING; if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { - this->unk_32D = 3; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; case 23: - this->unk_2E0 = 30; - this->unk_32D = 4; + this->animationId = SK_ANIMATION_FLOATING_TURN_AROUND; + this->handType = SK_HAND_TYPE_JUGGLING_OR_DROPPING_OCARINA; break; case 24: - this->unk_2E0 = 32; + this->animationId = SK_ANIMATION_CALL_DOWN_MOON_START; if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { - this->unk_32D = 3; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; @@ -1193,148 +1425,148 @@ void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { break; case 26: - this->unk_2E0 = 34; + this->animationId = SK_ANIMATION_SMACK_FAIRY_START; if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { - this->unk_32D = 3; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; case 27: - this->unk_2E0 = 36; + this->animationId = SK_ANIMATION_HIT_BY_BUBBLE; if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { - this->unk_32D = 3; + this->handType = SK_HAND_TYPE_HOLDING_OCARINA; } break; case 28: - this->unk_2E0 = 37; - this->unk_32D = 4; + this->animationId = SK_ANIMATION_DROP_OCARINA; + this->handType = SK_HAND_TYPE_JUGGLING_OR_DROPPING_OCARINA; break; case 30: - this->unk_2E0 = 38; + this->animationId = SK_ANIMATION_FLOATING_ARMS_CROSSED; break; case 31: - this->unk_2E0 = 39; + this->animationId = SK_ANIMATION_DEFLECT_ATTACK; break; case 32: - this->unk_2E0 = 42; + this->animationId = SK_ANIMATION_SURPRISE_START; break; case 33: - this->unk_2E0 = 44; + this->animationId = SK_ANIMATION_LOOK_AROUND_FOR_GIANTS_START; break; case 34: - this->unk_2E0 = 46; + this->animationId = SK_ANIMATION_HOLD_HEAD_AND_SHAKE_START; break; case 35: - this->unk_2E0 = 48; + this->animationId = SK_ANIMATION_HOLD_HEAD_AND_SCREAM_START; break; case 36: - this->unk_2E0 = 50; + this->animationId = SK_ANIMATION_HUDDLE_WITH_FAIRIES; break; case 37: - this->unk_2E0 = 51; + this->animationId = SK_ANIMATION_SEARCH_MASK_SALESMAN; break; case 38: - this->unk_2E0 = 52; + this->animationId = SK_ANIMATION_HOLD_UP_MASK_START; break; case 39: - this->unk_2E0 = 54; + this->animationId = SK_ANIMATION_SHIVER; break; case 40: - this->unk_2E0 = 55; + this->animationId = SK_ANIMATION_DRAW; break; case 41: - this->unk_2E0 = 40; + this->animationId = SK_ANIMATION_TELESCOPE_LOOK_UP_START; break; case 42: - this->unk_2E0 = 5; + this->animationId = SK_ANIMATION_BENT_OVER_HEAD_TWITCH; break; case 43: - this->unk_2E0 = 56; + this->animationId = SK_ANIMATION_BENT_OVER_LOOK_UP; break; case 44: - this->unk_2E0 = 57; + this->animationId = SK_ANIMATION_SPANK; break; case 45: - this->unk_2E0 = 58; - this->unk_32F = 1; + this->animationId = SK_ANIMATION_HIP_SHAKE_AND_JUMP; + this->fadeOutState = SK_FADE_OUT_STATE_FADING_OUT; break; case 46: - this->unk_32D = 6; - this->unk_2E0 = 59; + this->handType = SK_HAND_TYPE_HOLDING_FLUTE; + this->animationId = SK_ANIMATION_PLAY_FLUTE; break; case 47: - this->unk_2E0 = 60; + this->animationId = SK_ANIMATION_CARTWHEEL; break; case 48: - this->unk_2E0 = 60; + this->animationId = SK_ANIMATION_CARTWHEEL; break; case 49: - this->unk_2E0 = 65; + this->animationId = SK_ANIMATION_LOOK_UP_AT_GIANTS; break; case 50: - this->unk_2E0 = 66; + this->animationId = SK_ANIMATION_ASHAMED_START; break; case 51: - this->unk_2E0 = 68; + this->animationId = SK_ANIMATION_LOOK_LEFT_START; break; case 52: - this->unk_2E0 = 70; + this->animationId = SK_ANIMATION_SNIFF; break; case 53: - this->unk_2E0 = 60; + this->animationId = SK_ANIMATION_CARTWHEEL; break; case 54: - this->unk_2E0 = 61; + this->animationId = SK_ANIMATION_LIE_FLAT; break; case 55: - this->unk_2E0 = 62; + this->animationId = SK_ANIMATION_DANGLE_FROM_MASK_START; break; case 56: - this->unk_2E0 = 64; + this->animationId = SK_ANIMATION_DROPPED_FROM_MASK; break; case 57: - this->unk_2E0 = 65; + this->animationId = SK_ANIMATION_LOOK_UP_AT_GIANTS; break; case 58: - this->unk_2E0 = 66; + this->animationId = SK_ANIMATION_ASHAMED_START; break; case 59: - this->unk_2E0 = 68; + this->animationId = SK_ANIMATION_LOOK_LEFT_START; break; case 60: - this->unk_2E0 = 70; + this->animationId = SK_ANIMATION_SNIFF; break; case 5: @@ -1342,129 +1574,131 @@ void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { break; default: - this->unk_2E0 = 0; + this->animationId = SK_ANIMATION_SHAKE_HEAD; break; } - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); } } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actorActionIndex); } else { - this->unk_334 = 99; + this->csAction = 99; } - if (this->unk_32E == 1) { - Math_SmoothStepToF(&this->unk_300, 0.7f, 0.1f, 0.007f, 0.005f); - if (this->unk_300 < 0.71f) { - this->unk_300 = 0.7f; - this->unk_2F8 = 800; - this->unk_32E++; - } - this->unk_2E8 = globalCtx->lightCtx.unk7 * this->unk_300; - this->unk_2EC = globalCtx->lightCtx.unk8 * this->unk_300; - this->unk_2F0 = globalCtx->lightCtx.unk9 * this->unk_300; - - } else if (this->unk_32E == 2) { - if (this->unk_2F8 < 996) { - this->unk_2F8 += 10; + if (this->fadeInState == SK_FADE_IN_STATE_START) { + Math_SmoothStepToF(&this->fogScale, 0.7f, 0.1f, 0.007f, 0.005f); + if (this->fogScale < 0.71f) { + this->fogScale = 0.7f; + this->fogN = 800; + this->fadeInState++; } - if (this->unk_2F8 > 996) { - this->unk_32E++; - this->unk_2F8 = 996; - } - } else if (this->unk_32E == 3) { - if (this->unk_2E4 < 128) { - this->unk_2E4 += 3; + this->fogR = globalCtx->lightCtx.unk7 * this->fogScale; + this->fogG = globalCtx->lightCtx.unk8 * this->fogScale; + this->fogB = globalCtx->lightCtx.unk9 * this->fogScale; + } else if (this->fadeInState == SK_FADE_IN_STATE_INCREASE_FOG) { + if (this->fogN < 996) { + this->fogN += 10; } - if (this->unk_2E4 < 255) { - this->unk_2E4 += 20; + if (this->fogN > 996) { + this->fadeInState++; + this->fogN = 996; + } + } else if (this->fadeInState == SK_FADE_IN_STATE_INCREASE_ALPHA) { + if (this->alpha < 128) { + this->alpha += 3; + } + + if (this->alpha < 255) { + this->alpha += 20; } else { - this->unk_2E4 = 255; - this->unk_32E = 0; + this->alpha = 255; + this->fadeInState = SK_FADE_IN_STATE_NONE; } } - if (this->unk_32F == 1) { - if (this->unk_330 > 40) { - this->unk_32C = 3; + if (this->fadeOutState == SK_FADE_OUT_STATE_FADING_OUT) { + if (this->fadeOutTimer > 40) { + this->maskType = SK_MASK_TYPE_FADING_OUT; } - this->unk_330++; - if (this->unk_330 >= 44) { - this->unk_2E4 -= 35; - if (this->unk_2E4 < 0) { - this->unk_2E4 = 0; - this->unk_32F = 0; + this->fadeOutTimer++; + if (this->fadeOutTimer >= 44) { + this->alpha -= 35; + if (this->alpha < 0) { + this->alpha = 0; + this->fadeOutState = SK_FADE_OUT_STATE_NONE; gSaveContext.save.weekEventReg[12] |= 4; if (!(globalCtx->actorCtx.unk5 & 2)) { Actor_MarkForDeath(&this->actor); } else { - this->unk_33B = 0; + this->shouldDraw = false; } } } } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - switch (this->unk_2E0) { - case 2: - case 8: - case 10: - case 12: - case 14: - case 16: - case 18: - case 20: - case 22: - case 24: - case 30: - case 32: - case 34: - case 40: - case 42: - case 44: - case 46: - case 48: - case 52: - case 62: - case 66: - case 68: - case 70: - this->unk_2E0++; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + switch (this->animationId) { + case SK_ANIMATION_LOOK_AROUND: + case SK_ANIMATION_CURSE_START: + case SK_ANIMATION_LAUGH_START: + case SK_ANIMATION_HIDE_OCARINA_START: + case SK_ANIMATION_PICK_UP_OCARINA_AND_START_PLAYING: + case SK_ANIMATION_PICK_UP_OCARINA: + case SK_ANIMATION_KICK_OVER_LINK: + case SK_ANIMATION_UNUSED_KICK_OVER_LINK: + case SK_ANIMATION_HORSE_RIDE_START: + case SK_ANIMATION_RAISE_MASK_START: + case SK_ANIMATION_FLOATING_TURN_AROUND: + case SK_ANIMATION_CALL_DOWN_MOON_START: + case SK_ANIMATION_SMACK_FAIRY_START: + case SK_ANIMATION_TELESCOPE_LOOK_UP_START: + case SK_ANIMATION_SURPRISE_START: + case SK_ANIMATION_LOOK_AROUND_FOR_GIANTS_START: + case SK_ANIMATION_HOLD_HEAD_AND_SHAKE_START: + case SK_ANIMATION_HOLD_HEAD_AND_SCREAM_START: + case SK_ANIMATION_HOLD_UP_MASK_START: + case SK_ANIMATION_DANGLE_FROM_MASK_START: + case SK_ANIMATION_ASHAMED_START: + case SK_ANIMATION_LOOK_LEFT_START: + case SK_ANIMATION_SNIFF: + this->animationId++; + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); break; - case 26: - this->unk_2E0 = 3; - this->unk_32C = 1; - this->unk_32D = 9; - func_80A9FE3C(this, globalCtx, &this->skelAnime, &sAnimations[this->unk_2E0], 0); + case SK_ANIMATION_LOWER_MASK: + this->animationId = SK_ANIMATION_IDLE; + this->maskType = SK_MASK_TYPE_NORMAL; + this->handType = SK_HAND_TYPE_DEFAULT; + DmStk_ChangeAnimation(this, globalCtx, &this->skelAnime, &sAnimations[this->animationId], 0); break; } } - if (((this->unk_2E0 == 24) && (this->skelAnime.curFrame >= 16.0f)) || (this->unk_2E0 == 25) || - (this->unk_2E0 == 26)) { - this->unk_32C = 9; - this->unk_32D = 2; - } else if (((this->unk_2E0 >= 50) && (this->unk_2E0 < 56)) || ((this->unk_2E0 > 58) && (this->unk_2E0 <= 60)) || + if (((this->animationId == SK_ANIMATION_RAISE_MASK_START) && (this->skelAnime.curFrame >= 16.0f)) || + (this->animationId == SK_ANIMATION_RAISE_MASK_LOOP) || (this->animationId == SK_ANIMATION_LOWER_MASK)) { + this->maskType = SK_MASK_TYPE_RAISED; + this->handType = SK_HAND_TYPE_HOLDING_MAJORAS_MASK; + } else if (((this->animationId >= SK_ANIMATION_HUDDLE_WITH_FAIRIES) && (this->animationId <= SK_ANIMATION_DRAW)) || + ((this->animationId >= SK_ANIMATION_PLAY_FLUTE) && (this->animationId <= SK_ANIMATION_CARTWHEEL)) || ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7))) { - this->unk_32C = 0; - if ((this->unk_2E0 == 52) || (this->unk_2E0 == 53)) { - this->unk_32D = 5; + this->maskType = SK_MASK_TYPE_NO_MASK; + if ((this->animationId == SK_ANIMATION_HOLD_UP_MASK_START) || + (this->animationId == SK_ANIMATION_HOLD_UP_MASK_LOOP)) { + this->handType = SK_HAND_TYPE_HOLDING_MAJORAS_MASK_AND_FLUTE; } } - if (this->unk_2E0 == 64) { - this->unk_32C = 0; + if (this->animationId == SK_ANIMATION_DROPPED_FROM_MASK) { + this->maskType = SK_MASK_TYPE_NO_MASK; } } -void func_80AA26CC(DmStk* this, GlobalContext* globalCtx) { +void DmStk_UpdateCollision(DmStk* this, GlobalContext* globalCtx) { s32 pad; Collider_UpdateCylinder(&this->actor, &this->collider); @@ -1472,40 +1706,54 @@ void func_80AA26CC(DmStk* this, GlobalContext* globalCtx) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } -void func_80AA2720(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles Skull Kid when he is at the top of the Clock Tower with the Ocarina of Time. + * If he is hit in this state, he will drop the Ocarina. + * + * If the player waits a while while Skull Kid is in this state, they will see a message + * from Tatl telling them to hurry up and do something. + */ +void DmStk_ClockTower_IdleWithOcarina(DmStk* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (globalCtx->csCtx.state == 0) { - func_80AA1AF8(this, globalCtx); + DmStk_ClockTower_AdjustHeightAndRotation(this, globalCtx); this->actor.flags |= ACTOR_FLAG_1; - this->unk_328++; - if (this->unk_328 > 800) { - this->unk_328 = 0; + this->tatlMessageTimer++; + if (this->tatlMessageTimer > 800) { + this->tatlMessageTimer = 0; if (!(player->stateFlags2 & 0x8000000)) { + // Why are you just standing around? Message_StartTextbox(globalCtx, 0x2014, &this->actor); } } + if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { - this->unk_335 = 1; - this->actionFunc = func_80AA1A50; + this->hasBeenHit = true; + this->actionFunc = DmStk_ClockTower_StartDropOcarinaCutscene; } } } -void func_80AA27EC(DmStk* this, GlobalContext* globalCtx) { +/** + * Handles Skull Kid when he is at the top of the Clock Tower after the Ocarina of Time + * has been returned to the player. + * If he is hit in this state, he will just deflect the attack. + */ +void DmStk_ClockTower_Idle(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state == 0) { - func_80AA1AF8(this, globalCtx); + DmStk_ClockTower_AdjustHeightAndRotation(this, globalCtx); this->actor.flags |= ACTOR_FLAG_1; - if (this->unk_2E0 == 33) { + if (this->animationId == SK_ANIMATION_CALL_DOWN_MOON_LOOP) { this->actor.targetArrowOffset = 3100.0f; } else { this->actor.targetArrowOffset = 200.0f; } if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { - this->unk_335 = 1; - this->actionFunc = func_80AA1B9C; + this->hasBeenHit = true; + this->actionFunc = DmStk_ClockTower_DeflectHit; } } } @@ -1513,57 +1761,60 @@ void func_80AA27EC(DmStk* this, GlobalContext* globalCtx) { void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { DmStk* this = THIS; - if (this->actor.params != 1) { - if (this->unk_2E0 == 33) { + if (DM_STK_GET_TYPE(&this->actor) != DM_STK_TYPE_MAJORAS_MASK) { + if (this->animationId == SK_ANIMATION_CALL_DOWN_MOON_LOOP) { Actor_SetFocus(&this->actor, 40.0f); } else { Actor_SetFocus(&this->actor, 6.0f); } - func_80A9FDB0(this, globalCtx); + DmStk_LoadObjectForAnimation(this, globalCtx); - if (this->unk_2E0 != 61) { + if (this->animationId != SK_ANIMATION_LIE_FLAT) { SkelAnime_Update(&this->skelAnime); } - this->unk_2E4 = this->unk_2E4; + this->alpha = this->alpha; this->actionFunc(this, globalCtx); if (globalCtx->sceneNum == SCENE_OKUJOU) { - func_80AA26CC(this, globalCtx); + DmStk_UpdateCollision(this, globalCtx); } - func_80AA1D1C(this, globalCtx); - func_80AA0E90(this, globalCtx); + DmStk_UpdateCutscenes(this, globalCtx); + DmStk_PlaySfxForCutscenes(this, globalCtx); - switch (this->unk_33A) { - case 1: + // This handles the cutscene where the player takes out the Deku Pipes for the first time. + switch (this->dekuPipesCutsceneState) { + case SK_DEKU_PIPES_CS_STATE_READY: if (func_800B8718(&this->actor, &globalCtx->state)) { - this->unk_33A = 2; + this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_PLAYER_USED_OCARINA; } else { func_800B874C(&this->actor, globalCtx, this->actor.xzDistToPlayer, fabsf(this->actor.playerHeightRel)); } break; - case 2: - if (ActorCutscene_GetCanPlayNext(0x10)) { - this->unk_33A = 3; - ActorCutscene_Start(0x10, &this->actor); - this->actionFunc = func_80AA27EC; + case SK_DEKU_PIPES_CS_STATE_PLAYER_USED_OCARINA: + if (ActorCutscene_GetCanPlayNext(16)) { + this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_START; + ActorCutscene_Start(16, &this->actor); + this->actionFunc = DmStk_ClockTower_Idle; } else { - ActorCutscene_SetIntentToPlay(0x10); + ActorCutscene_SetIntentToPlay(16); } break; - case 3: + case SK_DEKU_PIPES_CS_STATE_START: if (globalCtx->csCtx.state == 0) { - this->unk_33A = 4; + this->dekuPipesCutsceneState = SK_DEKU_PIPES_CS_STATE_END; } break; } + // This code is responsible for making in-game time pass while using the telescope in the Astral Observatory. + // Skull Kid is always loaded in the scene, even if he isn't visible, hence why time always passes. if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && (globalCtx->msgCtx.currentTextId == 0x5E6) && !FrameAdvance_IsEnabled(&globalCtx->state) && (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && @@ -1585,27 +1836,28 @@ void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { s32 DmStk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { DmStk* this = THIS; - if (limbIndex == 15) { - if ((this->unk_32D == 0) || (this->unk_32D == 1) || (this->unk_32D == 3)) { + if (limbIndex == SKULL_KID_LIMB_RIGHT_HAND) { + if ((this->handType == SK_HAND_TYPE_HOLDING_LINK_MASK_AND_FLUTE) || + (this->handType == SK_HAND_TYPE_HOLDING_LINK_MASK) || (this->handType == SK_HAND_TYPE_HOLDING_OCARINA)) { *dList = NULL; } - } else if (limbIndex == 12) { - switch (this->unk_32D) { - case 1: - case 2: - case 3: - case 4: - case 6: + } else if (limbIndex == SKULL_KID_LIMB_LEFT_HAND) { + switch (this->handType) { + case SK_HAND_TYPE_HOLDING_LINK_MASK: + case SK_HAND_TYPE_HOLDING_MAJORAS_MASK: + case SK_HAND_TYPE_HOLDING_OCARINA: + case SK_HAND_TYPE_JUGGLING_OR_DROPPING_OCARINA: + case SK_HAND_TYPE_HOLDING_FLUTE: *dList = NULL; break; - case 9: - if (this->unk_2E4 == 255) { + case SK_HAND_TYPE_DEFAULT: + if (this->alpha == 255) { *dList = NULL; } break; } - } else if (limbIndex == 17) { + } else if (limbIndex == SKULL_KID_LIMB_HEAD) { *dList = NULL; } @@ -1617,58 +1869,60 @@ void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V s32 pad2; DmStk* this = THIS; - if (limbIndex == 17) { - Matrix_MultZero(&this->unk_304); + if (limbIndex == SKULL_KID_LIMB_HEAD) { + Matrix_MultZero(&this->headPos); OPEN_DISPS(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if ((this->unk_2E0 == 69) || (this->unk_2E0 == 11) || (this->unk_2E0 == 71)) { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00AEC0); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00AE30); + if ((this->animationId == SK_ANIMATION_LOOK_LEFT_LOOP) || (this->animationId == SK_ANIMATION_LAUGH_LOOP) || + (this->animationId == SK_ANIMATION_LAUGH_AFTER_SNIFF)) { + gSPDisplayList(POLY_OPA_DISP++, gSkullKidLaughingHeadDL); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidLaughingEyesDL); } else { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00A5C0); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00A530); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidNormalHeadDL); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidNormalEyesDL); } - switch (this->unk_32C) { - case 0: + switch (this->maskType) { + case SK_MASK_TYPE_NO_MASK: break; - case 1: + case SK_MASK_TYPE_NORMAL: if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.frames < 1400)) { - if (this->unk_2F8 == this->unk_2FC) { - this->unk_2FC = this->unk_2F8; + if (this->fogN == this->fogF) { + this->fogF = this->fogN; } - POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, this->unk_2E8, this->unk_2EC, this->unk_2F0, - this->unk_2F4, this->unk_2F8, this->unk_2FC); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_006BB0); + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, this->fogR, this->fogG, this->fogB, this->fogA, + this->fogN, this->fogF); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask1DL); POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); } else { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_006BB0); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask1DL); } break; - case 2: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_006BB0); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_005870); + case SK_MASK_TYPE_GLOWING_EYES: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask1DL); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMaskEyesDL); if (Cutscene_CheckActorAction(globalCtx, 513) && (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 513)]->action == 2) && - (this->unk_337 >= 0)) { + (this->objectStk2ObjectIndex >= 0)) { Matrix_Push(); Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_337].segment); + gSegments[6] = + PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objectStk2ObjectIndex].segment); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_337].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->objectStk2ObjectIndex].segment); - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_stk2_Matanimheader_008658)); - Gfx_DrawDListOpa(globalCtx, object_stk2_DL_007840); - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_336].segment); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gSkullKidMajorasMaskCurseOverlayTexAnim)); + Gfx_DrawDListOpa(globalCtx, gSkullKidMajorasMaskCurseOverlayDL); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objectStkObjectIndex].segment); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->unk_336].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->objectStkObjectIndex].segment); Matrix_Pop(); } @@ -1677,85 +1931,85 @@ void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V CLOSE_DISPS(globalCtx->state.gfxCtx); - } else if (limbIndex == 15) { + } else if (limbIndex == SKULL_KID_LIMB_RIGHT_HAND) { OPEN_DISPS(globalCtx->state.gfxCtx); - if (this->unk_32D != 5) { + if (this->handType != SK_HAND_TYPE_HOLDING_MAJORAS_MASK_AND_FLUTE) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); } - switch (this->unk_32D) { - case 0: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_009AC0); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0046B0); + switch (this->handType) { + case SK_HAND_TYPE_HOLDING_LINK_MASK_AND_FLUTE: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidUntexturedRightHand); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidLinkMask2DL); break; - case 1: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_009710); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0053C0); + case SK_HAND_TYPE_HOLDING_LINK_MASK: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMaskHoldingRightHand); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidLinkMask3DL); break; - case 3: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_009DA0); + case SK_HAND_TYPE_HOLDING_OCARINA: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaHoldingRightHand); if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && (gSaveContext.sceneSetupIndex == 1)) { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00CAD0); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaOfTimeDL); } break; - case 5: + case SK_HAND_TYPE_HOLDING_MAJORAS_MASK_AND_FLUTE: Matrix_Translate(-20.0f, -660.0f, 860.0f, MTXMODE_APPLY); Matrix_RotateYS(0x6142, MTXMODE_APPLY); Matrix_RotateXS(-0x1988, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_006BB0); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask1DL); break; } CLOSE_DISPS(globalCtx->state.gfxCtx); - } else if (limbIndex == 12) { + } else if (limbIndex == SKULL_KID_LIMB_LEFT_HAND) { OPEN_DISPS(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - switch (this->unk_32D) { - case 0: + switch (this->handType) { + case SK_HAND_TYPE_HOLDING_LINK_MASK_AND_FLUTE: break; - case 1: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0084C0); + case SK_HAND_TYPE_HOLDING_LINK_MASK: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidUntexturedLeftHand); break; - case 2: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0090C0); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0079F0); + case SK_HAND_TYPE_HOLDING_MAJORAS_MASK: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidTwoFingersExtendedLeftHand); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidMajorasMask2DL); break; - case 3: + case SK_HAND_TYPE_HOLDING_OCARINA: if ((globalCtx->sceneNum != SCENE_LOST_WOODS) || (gSaveContext.sceneSetupIndex != 1)) { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_00CAD0); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaOfTimeDL); } - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0090C0); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidTwoFingersExtendedLeftHand); break; - case 4: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0090C0); + case SK_HAND_TYPE_JUGGLING_OR_DROPPING_OCARINA: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidTwoFingersExtendedLeftHand); break; - case 6: - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_008A80); - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_016620); + case SK_HAND_TYPE_HOLDING_FLUTE: + gSPDisplayList(POLY_OPA_DISP++, gSkullKidFluteHoldingLeftHand); + gSPDisplayList(POLY_OPA_DISP++, gSkullKidFluteDL); break; - case 9: - if (this->unk_2E4 == 255) { - gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_0087B0); + case SK_HAND_TYPE_DEFAULT: + if (this->alpha == 255) { + gSPDisplayList(POLY_OPA_DISP++, gSkullKidOpenLeftHand); } break; } @@ -1773,25 +2027,25 @@ void DmStk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve void DmStk_Draw(Actor* thisx, GlobalContext* globalCtx) { DmStk* this = THIS; - if (this->unk_33B != 0) { - if (this->actor.params == 1) { - Gfx_DrawDListOpa(globalCtx, object_stk_DL_006BB0); + if (this->shouldDraw) { + if (DM_STK_GET_TYPE(&this->actor) == DM_STK_TYPE_MAJORAS_MASK) { + Gfx_DrawDListOpa(globalCtx, gSkullKidMajorasMask1DL); return; } - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_336].segment); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objectStkObjectIndex].segment); OPEN_DISPS(globalCtx->state.gfxCtx); - this->unk_2E4 = this->unk_2E4; + this->alpha = this->alpha; func_8012C28C(globalCtx->state.gfxCtx); - if (this->unk_2E4 < 255) { + if (this->alpha < 255) { func_8012C2DC(globalCtx->state.gfxCtx); Scene_SetRenderModeXlu(globalCtx, 1, 2); gDPPipeSync(POLY_XLU_DISP++); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_2E4); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h index 2b8c54383..4e69c1dfc 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h @@ -2,44 +2,53 @@ #define Z_DM_STK_H #include "global.h" +#include "objects/object_stk/object_stk.h" struct DmStk; typedef void (*DmStkActionFunc)(struct DmStk*, GlobalContext*); +#define DM_STK_GET_TYPE(thisx) ((thisx)->params) + +typedef enum { + /* 0 */ DM_STK_TYPE_SKULL_KID, + /* 1 */ DM_STK_TYPE_MAJORAS_MASK, +} DmStkType; + typedef struct DmStk { - /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnime skelAnime; - /* 0x0188 */ UNK_TYPE1 unk_188[0x108]; - /* 0x0290 */ DmStkActionFunc actionFunc; - /* 0x0294 */ ColliderCylinder collider; - /* 0x02E0 */ s16 unk_2E0; - /* 0x02E4 */ s32 unk_2E4; - /* 0x02E8 */ u32 unk_2E8; - /* 0x02EC */ u32 unk_2EC; - /* 0x02F0 */ u32 unk_2F0; - /* 0x02F4 */ s32 unk_2F4; - /* 0x02F8 */ s32 unk_2F8; - /* 0x02FC */ s32 unk_2FC; - /* 0x0300 */ f32 unk_300; - /* 0x0304 */ Vec3f unk_304; - /* 0x0310 */ Vec3f unk_310; - /* 0x031C */ UNK_TYPE1 unk31C[0xC]; - /* 0x0328 */ u16 unk_328; - /* 0x032A */ u16 unk_32A; - /* 0x032C */ u8 unk_32C; - /* 0x032D */ u8 unk_32D; - /* 0x032E */ u8 unk_32E; - /* 0x032F */ u8 unk_32F; - /* 0x0330 */ s32 unk_330; - /* 0x0334 */ u8 unk_334; - /* 0x0335 */ u8 unk_335; - /* 0x0336 */ s8 unk_336; - /* 0x0337 */ s8 unk_337; - /* 0x0338 */ s8 unk_338; - /* 0x0339 */ u8 unk_339; - /* 0x033A */ u8 unk_33A; - /* 0x033B */ u8 unk_33B; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[SKULL_KID_LIMB_MAX]; // Not used, since it's allocated dynamically instead. + /* 0x20C */ Vec3s morphTable[SKULL_KID_LIMB_MAX]; // Not used, since it's allocated dynamically instead. + /* 0x290 */ DmStkActionFunc actionFunc; + /* 0x294 */ ColliderCylinder collider; + /* 0x2E0 */ s16 animationId; + /* 0x2E4 */ s32 alpha; + /* 0x2E8 */ u32 fogR; + /* 0x2EC */ u32 fogG; + /* 0x2F0 */ u32 fogB; + /* 0x2F4 */ s32 fogA; + /* 0x2F8 */ s32 fogN; + /* 0x2FC */ s32 fogF; + /* 0x300 */ f32 fogScale; + /* 0x304 */ Vec3f headPos; // set but never used + /* 0x310 */ Vec3f oathToOrderCutsceneVoicePos; + /* 0x31C */ UNK_TYPE1 unk31C[0xC]; + /* 0x328 */ u16 tatlMessageTimer; + /* 0x32A */ u16 bobPhase; + /* 0x32C */ u8 maskType; + /* 0x32D */ u8 handType; + /* 0x32E */ u8 fadeInState; + /* 0x32F */ u8 fadeOutState; + /* 0x330 */ s32 fadeOutTimer; + /* 0x334 */ u8 csAction; + /* 0x335 */ u8 hasBeenHit; // set but never used + /* 0x336 */ s8 objectStkObjectIndex; + /* 0x337 */ s8 objectStk2ObjectIndex; + /* 0x338 */ s8 objectStk3ObjectIndex; + /* 0x339 */ u8 deflectCount; + /* 0x33A */ u8 dekuPipesCutsceneState; + /* 0x33B */ u8 shouldDraw; } DmStk; // size = 0x33C extern const ActorInit Dm_Stk_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index a0eae0028..637e1c229 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -11463,44 +11463,44 @@ 0x80A9FA58:("func_80A9FA58",), 0x80A9FB54:("DmOpstage_Update",), 0x80A9FBB8:("DmOpstage_Draw",), - 0x80A9FDB0:("func_80A9FDB0",), - 0x80A9FE3C:("func_80A9FE3C",), - 0x80A9FED8:("func_80A9FED8",), - 0x80AA00CC:("func_80AA00CC",), - 0x80AA0100:("func_80AA0100",), - 0x80AA0158:("func_80AA0158",), - 0x80AA01C0:("func_80AA01C0",), - 0x80AA0264:("func_80AA0264",), - 0x80AA0420:("func_80AA0420",), - 0x80AA05F0:("func_80AA05F0",), - 0x80AA0634:("func_80AA0634",), - 0x80AA066C:("func_80AA066C",), - 0x80AA071C:("func_80AA071C",), - 0x80AA076C:("func_80AA076C",), - 0x80AA09DC:("func_80AA09DC",), - 0x80AA0B08:("func_80AA0B08",), - 0x80AA0DA8:("func_80AA0DA8",), - 0x80AA0E1C:("func_80AA0E1C",), - 0x80AA0E90:("func_80AA0E90",), + 0x80A9FDB0:("DmStk_LoadObjectForAnimation",), + 0x80A9FE3C:("DmStk_ChangeAnimation",), + 0x80A9FED8:("DmStk_PlaySfxForIntroCutsceneFirstPart",), + 0x80AA00CC:("DmStk_PlaySfxForTitleCutscene",), + 0x80AA0100:("DmStk_PlaySfxForIntroCutsceneSecondPart",), + 0x80AA0158:("DmStk_PlaySfxForObtainingMajorasMaskCutscene",), + 0x80AA01C0:("DmStk_PlaySfxForCurseCutsceneFirstPart",), + 0x80AA0264:("DmStk_PlaySfxForCurseCutsceneSecondPart",), + 0x80AA0420:("DmStk_PlaySfxForClockTowerIntroCutsceneVersion1",), + 0x80AA05F0:("DmStk_PlaySfxForDroppingOcarinaCutscene",), + 0x80AA0634:("DmStk_PlaySfxForShiveringInRainCutscene",), + 0x80AA066C:("DmStk_PlaySfxForPlayingWithFairiesCutscene",), + 0x80AA071C:("DmStk_PlaySfxForEndingCutsceneFirstPart",), + 0x80AA076C:("DmStk_PlaySfxForEndingCutsceneSecondPart",), + 0x80AA09DC:("DmStk_PlaySfxForClockTowerIntroCutsceneVersion2",), + 0x80AA0B08:("DmStk_PlaySfxForCutsceneAfterPlayingOathToOrder",), + 0x80AA0DA8:("DmStk_PlaySfxForMoonWarpCutsceneVersion1",), + 0x80AA0E1C:("DmStk_PlaySfxForMoonWarpCutsceneVersion2",), + 0x80AA0E90:("DmStk_PlaySfxForCutscenes",), 0x80AA1234:("DmStk_Init",), 0x80AA16E4:("DmStk_Destroy",), - 0x80AA16F4:("func_80AA16F4",), - 0x80AA1704:("func_80AA1704",), - 0x80AA1714:("func_80AA1714",), - 0x80AA17F8:("func_80AA17F8",), - 0x80AA18D8:("func_80AA18D8",), - 0x80AA192C:("func_80AA192C",), - 0x80AA1998:("func_80AA1998",), - 0x80AA19EC:("func_80AA19EC",), - 0x80AA1A50:("func_80AA1A50",), - 0x80AA1AC8:("func_80AA1AC8",), - 0x80AA1AF8:("func_80AA1AF8",), - 0x80AA1B9C:("func_80AA1B9C",), - 0x80AA1C64:("func_80AA1C64",), - 0x80AA1D1C:("func_80AA1D1C",), - 0x80AA26CC:("func_80AA26CC",), - 0x80AA2720:("func_80AA2720",), - 0x80AA27EC:("func_80AA27EC",), + 0x80AA16F4:("DmStk_ClockTower_DoNothing",), + 0x80AA1704:("DmStk_DoNothing",), + 0x80AA1714:("DmStk_WaitForTelescope",), + 0x80AA17F8:("DmStk_StartTelescopeCutscene",), + 0x80AA18D8:("DmStk_ClockTower_StartIntroCutsceneVersion1",), + 0x80AA192C:("DmStk_ClockTower_WaitForIntroCutsceneVersion1ToEnd",), + 0x80AA1998:("DmStk_ClockTower_StartIntroCutsceneVersion2",), + 0x80AA19EC:("DmStk_ClockTower_WaitForIntroCutsceneVersion2ToEnd",), + 0x80AA1A50:("DmStk_ClockTower_StartDropOcarinaCutscene",), + 0x80AA1AC8:("DmStk_ClockTower_WaitForDropOcarinaCutsceneToEnd",), + 0x80AA1AF8:("DmStk_ClockTower_AdjustHeightAndRotation",), + 0x80AA1B9C:("DmStk_ClockTower_DeflectHit",), + 0x80AA1C64:("DmStk_ClockTower_WaitForDeflectionToEnd",), + 0x80AA1D1C:("DmStk_UpdateCutscenes",), + 0x80AA26CC:("DmStk_UpdateCollision",), + 0x80AA2720:("DmStk_ClockTower_IdleWithOcarina",), + 0x80AA27EC:("DmStk_ClockTower_Idle",), 0x80AA2884:("DmStk_Update",), 0x80AA2B14:("DmStk_OverrideLimbDraw",), 0x80AA2BC0:("DmStk_PostLimbDraw2",), From 271b7c78276f7488f4c75328d79364f3a1cd423d Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 18 Jun 2022 18:56:10 -0700 Subject: [PATCH 230/257] Gfxprint OK (#826) * Match last two functions as well as some cleanup * One more small cleanup * Reviews * format * Move internal GFXP_FLAG defines to c file * Format --- include/PR/gbi.h | 12 +-- include/functions.h | 17 +-- include/gfxprint.h | 49 +++++++++ include/variables.h | 4 +- include/z64.h | 22 +--- src/boot_O2/gfxprint.c | 188 +++++++++++++++++++++------------ src/boot_O2_g3/fault_drawer.c | 1 + src/code/sys_matrix.c | 2 +- tools/disasm/functions.txt | 2 +- tools/disasm/variables.txt | 4 +- tools/sizes/boot_functions.csv | 2 +- 11 files changed, 183 insertions(+), 120 deletions(-) create mode 100644 include/gfxprint.h diff --git a/include/PR/gbi.h b/include/PR/gbi.h index 34ec8af31..fa27a5f11 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -3878,7 +3878,7 @@ _DW({ \ #define gDPLoadTextureBlock_4b(pkt, timg, fmt, width, height, \ pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ +_DW({ \ gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \ gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, \ cmt, maskt, shiftt, cms, masks, shifts); \ @@ -3893,7 +3893,7 @@ _DW({ \ gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ ((height)-1) << G_TEXTURE_IMAGE_FRAC); \ -} +}) /* Load fix rww 27jun95 */ /* The S at the end means odd lines are already word Swapped */ @@ -4246,7 +4246,7 @@ _DW({ \ #define gDPLoadMultiTile_4b(pkt, timg, tmem, rtile, fmt, width, height, \ uls, ult, lrs, lrt, pal, \ cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ +_DW({ \ gDPSetTextureImage(pkt, fmt, G_IM_SIZ_8b, ((width)>>1), timg); \ gDPSetTile(pkt, fmt, G_IM_SIZ_8b, \ (((((lrs)-(uls)+1)>>1)+7)>>3), tmem, \ @@ -4268,7 +4268,7 @@ _DW({ \ (ult)<words.w0 = (_SHIFTL(G_SETPRIMCOLOR, 24, 8) | _SHIFTL(m, 8, 8) | _SHIFTL(l, 0, 8)); \ - _g->words.w1 = (rgba); \ - } - -void GfxPrint_InitDlist(GfxPrint* this) { +void GfxPrint_Setup(GfxPrint* this) { s32 width = 16; s32 height = 256; s32 i; - gDPPipeSync(this->dlist++); - gDPSetOtherMode(this->dlist++, + gDPPipeSync(this->dList++); + gDPSetOtherMode(this->dList++, G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_IA16 | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PRIM | G_RM_XLU_SURF | G_RM_XLU_SURF2); - gDPSetCombineMode(this->dlist++, G_CC_DECALRGBA, G_CC_DECALRGBA); - gDPLoadTextureBlock_4b(this->dlist++, sGfxPrintFontData, G_IM_FMT_CI, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP, + gDPSetCombineMode(this->dList++, G_CC_DECALRGBA, G_CC_DECALRGBA); + gDPLoadTextureBlock_4b(this->dList++, sGfxPrintFontData, G_IM_FMT_CI, width, height, 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); - gDPLoadTLUT(this->dlist++, 64, 256, sGfxPrintFontTLUT); + gDPLoadTLUT(this->dList++, 64, 256, sGfxPrintFontTLUT); for (i = 1; i < 4; i++) { - gDPSetTile(this->dlist++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2, i, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, + gDPSetTile(this->dList++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2, i, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPSetTileSize(this->dlist++, i * 2, 0, 0, 60, 1020); + gDPSetTileSize(this->dList++, i * 2, 0, 0, 60, 1020); } - gDPSetPrimColorMod(this->dlist++, 0, 0, this->color.rgba); + gDPSetColor(this->dList++, G_SETPRIMCOLOR, this->color.rgba); - gDPLoadMultiTile_4b(this->dlist++, sGfxPrintUnkData, 0, 1, G_IM_FMT_CI, 2, 8, 0, 0, 1, 7, 4, + gDPLoadMultiTile_4b(this->dList++, sGfxPrintRainbowData, 0, 1, G_IM_FMT_CI, 2, 8, 0, 0, 1, 7, 4, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 1, 3, G_TX_NOLOD, G_TX_NOLOD); - gDPLoadTLUT(this->dlist++, 16, 320, sGfxPrintUnkTLUT); + gDPLoadTLUT(this->dList++, 16, 320, sGfxPrintRainbowTLUT); for (i = 1; i < 4; i++) { - gDPSetTile(this->dlist++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2 + 1, 4, G_TX_NOMIRROR | G_TX_WRAP, 3, + gDPSetTile(this->dList++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0, i * 2 + 1, 4, G_TX_NOMIRROR | G_TX_WRAP, 3, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 1, G_TX_NOLOD); - gDPSetTileSize(this->dlist++, i * 2 + 1, 0, 0, 4, 28); + gDPSetTileSize(this->dList++, i * 2 + 1, 0, 0, 4, 28); } } @@ -53,8 +53,8 @@ void GfxPrint_SetColor(GfxPrint* this, u32 r, u32 g, u32 b, u32 a) { this->color.g = g; this->color.b = b; this->color.a = a; - gDPPipeSync(this->dlist++); - gDPSetPrimColorMod(this->dlist++, 0, 0, this->color.rgba); + gDPPipeSync(this->dList++); + gDPSetColor(this->dList++, G_SETPRIMCOLOR, this->color.rgba); } void GfxPrint_SetPosPx(GfxPrint* this, s32 x, s32 y) { @@ -71,108 +71,156 @@ void GfxPrint_SetBasePosPx(GfxPrint* this, s32 x, s32 y) { this->baseY = y << 2; } -/* regalloc in the final gSPTextureRectangle */ -#ifdef NON_MATCHING void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c) { u32 tile = (c & 0xFF) * 2; + u16 s = c & 4; + u16 t = c >> 3; - if (this->flag & GFXPRINT_UPDATE_MODE) { - this->flag &= ~GFXPRINT_UPDATE_MODE; + if (this->flags & GFXP_FLAG_UPDATE) { + this->flags &= ~GFXP_FLAG_UPDATE; - gDPPipeSync(this->dlist++); - if (this->flag & GFXPRINT_USE_RGBA16) { - gDPSetTextureLUT(this->dlist++, G_TT_RGBA16); - gDPSetCycleType(this->dlist++, G_CYC_2CYCLE); - gDPSetRenderMode(this->dlist++, G_RM_OPA_CI, G_RM_XLU_SURF2); - gDPSetCombineMode(this->dlist++, G_CC_INTERFERENCE, G_CC_PASS2); + gDPPipeSync(this->dList++); + if (this->flags & GFXP_FLAG_RAINBOW) { + gDPSetTextureLUT(this->dList++, G_TT_RGBA16); + gDPSetCycleType(this->dList++, G_CYC_2CYCLE); + gDPSetRenderMode(this->dList++, G_RM_OPA_CI, G_RM_XLU_SURF2); + gDPSetCombineMode(this->dList++, G_CC_INTERFERENCE, G_CC_PASS2); } else { - gDPSetTextureLUT(this->dlist++, G_TT_IA16); - gDPSetCycleType(this->dlist++, G_CYC_1CYCLE); - gDPSetRenderMode(this->dlist++, G_RM_XLU_SURF, G_RM_XLU_SURF2); - gDPSetCombineMode(this->dlist++, G_CC_MODULATEIDECALA_PRIM, G_CC_MODULATEIDECALA_PRIM); + gDPSetTextureLUT(this->dList++, G_TT_IA16); + gDPSetCycleType(this->dList++, G_CYC_1CYCLE); + gDPSetRenderMode(this->dList++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetCombineMode(this->dList++, G_CC_MODULATEIDECALA_PRIM, G_CC_MODULATEIDECALA_PRIM); } } - if (this->flag & GFXPRINT_FLAG4) { - gDPSetPrimColorMod(this->dlist++, 0, 0, 0); + if (this->flags & GFXP_FLAG_SHADOW) { + gDPSetColor(this->dList++, G_SETPRIMCOLOR, 0); - gSPTextureRectangle(this->dlist++, this->posX + 4, this->posY + 4, this->posX + 4 + 32, this->posY + 4 + 32, - (c & 3) << 1, (u16)(c & 4) * 64, (u16)(c >> 3) * 256, 1024, 1024); + gSPTextureRectangle(this->dList++, this->posX + 4, this->posY + 4, this->posX + 4 + 32, this->posY + 4 + 32, + tile, s << 6, t << 8, 1 << 10, 1 << 10); - gDPSetPrimColorMod(this->dlist++, 0, 0, this->color.rgba); + gDPSetColor(this->dList++, G_SETPRIMCOLOR, this->color.rgba); } - gSPTextureRectangle(this->dlist++, this->posX, this->posY, this->posX + 32, this->posY + 32, (u16)(tile & 7), - (u16)(c & 4) * 64, (u16)(c >> 3) * 256, 1024, 1024); + gSPTextureRectangle(this->dList++, this->posX, this->posY, this->posX + 32, this->posY + 32, tile, s << 6, t << 8, + 1 << 10, 1 << 10); this->posX += 32; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/boot/gfxprint/GfxPrint_PrintCharImpl.s") -#endif -#pragma GLOBAL_ASM("asm/non_matchings/boot/gfxprint/GfxPrint_PrintChar.s") +void GfxPrint_PrintChar(GfxPrint* this, u8 c) { + if (c == ' ') { + this->posX += 32; + } else if (c > ' ' && c < 0x7F) { + GfxPrint_PrintCharImpl(this, c); + } else if (c >= 0xA0 && c < 0xE0) { + if (this->flags & GFXP_FLAG_HIRAGANA) { + if (c < 0xC0) { + c -= 0x20; + } else { + c += 0x20; + } + } + GfxPrint_PrintCharImpl(this, c); + } else { + switch (c) { + case '\0': + break; + case '\n': + this->posY += 32; + case '\r': + this->posX = this->baseX; + break; + case '\t': + do { + GfxPrint_PrintCharImpl(this, ' '); + } while ((this->posX - this->baseX) % 256); + break; + case GFXP_HIRAGANA_CHAR: + this->flags |= GFXP_FLAG_HIRAGANA; + break; + case GFXP_KATAKANA_CHAR: + this->flags &= ~GFXP_FLAG_HIRAGANA; + break; + case GFXP_RAINBOW_ON_CHAR: + this->flags |= GFXP_FLAG_RAINBOW; + this->flags |= GFXP_FLAG_UPDATE; + break; + case GFXP_RAINBOW_OFF_CHAR: + this->flags &= ~GFXP_FLAG_RAINBOW; + this->flags |= GFXP_FLAG_UPDATE; + break; + case GFXP_UNUSED_CHAR: + default: + break; + } + } +} void GfxPrint_PrintStringWithSize(GfxPrint* this, const void* buffer, size_t charSize, size_t charCount) { const char* str = (const char*)buffer; size_t count = charSize * charCount; - while (count) { + while (count != 0) { GfxPrint_PrintChar(this, *str++); count--; } } void GfxPrint_PrintString(GfxPrint* this, const char* str) { - while (*str) { - GfxPrint_PrintChar(this, *(str++)); + while (*str != '\0') { + GfxPrint_PrintChar(this, *str++); } } -GfxPrint* GfxPrint_Callback(GfxPrint* this, const char* str, size_t size) { +void* GfxPrint_Callback(void* arg, const char* str, size_t size) { + GfxPrint* this = arg; + GfxPrint_PrintStringWithSize(this, str, sizeof(char), size); + return this; } void GfxPrint_Init(GfxPrint* this) { - this->flag &= ~GFXPRINT_OPEN; + this->flags &= ~GFXP_FLAG_OPEN; this->callback = GfxPrint_Callback; - - this->dlist = NULL; + this->dList = NULL; this->posX = 0; this->posY = 0; this->baseX = 0; this->baseY = 0; this->color.rgba = 0; - this->flag &= ~GFXPRINT_FLAG1; - this->flag &= ~GFXPRINT_USE_RGBA16; - this->flag |= GFXPRINT_FLAG4; - this->flag |= GFXPRINT_UPDATE_MODE; + + this->flags &= ~GFXP_FLAG_HIRAGANA; + this->flags &= ~GFXP_FLAG_RAINBOW; + this->flags |= GFXP_FLAG_SHADOW; + this->flags |= GFXP_FLAG_UPDATE; } void GfxPrint_Destroy(GfxPrint* this) { } -void GfxPrint_Open(GfxPrint* this, Gfx* dlist) { - if (!(this->flag & GFXPRINT_OPEN)) { - this->flag |= GFXPRINT_OPEN; - this->dlist = dlist; - GfxPrint_InitDlist(this); +void GfxPrint_Open(GfxPrint* this, Gfx* dList) { + if (!(this->flags & GFXP_FLAG_OPEN)) { + this->flags |= GFXP_FLAG_OPEN; + this->dList = dList; + GfxPrint_Setup(this); } } Gfx* GfxPrint_Close(GfxPrint* this) { Gfx* ret; - this->flag &= ~GFXPRINT_OPEN; - ret = this->dlist; - this->dlist = NULL; + this->flags &= ~GFXP_FLAG_OPEN; + ret = this->dList; + this->dList = NULL; + return ret; } s32 GfxPrint_VPrintf(GfxPrint* this, const char* fmt, va_list args) { - return PrintUtils_VPrintf((PrintCallback*)&this->callback, fmt, args); + return PrintUtils_VPrintf(&this->callback, fmt, args); } s32 GfxPrint_Printf(GfxPrint* this, const char* fmt, ...) { diff --git a/src/boot_O2_g3/fault_drawer.c b/src/boot_O2_g3/fault_drawer.c index eacfc56d1..8efc930ec 100644 --- a/src/boot_O2_g3/fault_drawer.c +++ b/src/boot_O2_g3/fault_drawer.c @@ -41,6 +41,7 @@ FaultDrawer sFaultDrawerDefault = { NULL, // inputCallback }; +//! TODO: Needs to be extracted #pragma GLOBAL_ASM("asm/non_matchings/boot/fault_drawer/sFaultDrawerFont.s") void FaultDrawer_SetOsSyncPrintfEnabled(u32 enabled) { diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index f2ed19c38..4e517c810 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -38,7 +38,7 @@ * Throughout this file, `mode` indicates whether to multiply the matrix on top of the stack by the new construction * (APPLY), or to just overwrite it (NEW). */ - +#include "prevent_bss_reordering.h" #include "global.h" /* data */ diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 637e1c229..7e2be3b0a 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -137,7 +137,7 @@ 0x80085468:("StackCheck_GetState",), 0x800854E0:("StackCheck_CheckAll",), 0x80085538:("StackCheck_Check",), - 0x80085570:("GfxPrint_InitDlist",), + 0x80085570:("GfxPrint_Setup",), 0x800859BC:("GfxPrint_SetColor",), 0x80085A08:("GfxPrint_SetPosPx",), 0x80085A2C:("GfxPrint_SetPos",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 9529203e4..1223f31fa 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -32,8 +32,8 @@ 0x80096C40:("sStackInfoListStart","StackEntry*","",0x4), 0x80096C44:("sStackInfoListEnd","StackEntry*","",0x4), 0x80096C50:("sGfxPrintFontTLUT","u16","[64]",0x80), - 0x80096CD0:("sGfxPrintUnkTLUT","u16","[16]",0x20), - 0x80096CF0:("sGfxPrintUnkData","u8","[8]",0x8), + 0x80096CD0:("sGfxPrintRainbowTLUT","u16","[16]",0x20), + 0x80096CF0:("sGfxPrintRainbowData","u8","[8]",0x8), 0x80096CF8:("sGfxPrintFontData","u8","[0x800]",0x800), 0x80097500:("sInitFuncs","void*","",0x4), 0x80097504:("sNew","char","[4]",0x4), diff --git a/tools/sizes/boot_functions.csv b/tools/sizes/boot_functions.csv index a86be3b83..bbcf6d5de 100644 --- a/tools/sizes/boot_functions.csv +++ b/tools/sizes/boot_functions.csv @@ -134,7 +134,7 @@ asm/non_matchings/boot/stackcheck/StackCheck_Cleanup.s,StackCheck_Cleanup,0x8008 asm/non_matchings/boot/stackcheck/StackCheck_GetState.s,StackCheck_GetState,0x80085468,0x1E asm/non_matchings/boot/stackcheck/StackCheck_CheckAll.s,StackCheck_CheckAll,0x800854E0,0x16 asm/non_matchings/boot/stackcheck/StackCheck_Check.s,StackCheck_Check,0x80085538,0xE -asm/non_matchings/boot/gfxprint/GfxPrint_InitDlist.s,GfxPrint_InitDlist,0x80085570,0x113 +asm/non_matchings/boot/gfxprint/GfxPrint_Setup.s,GfxPrint_Setup,0x80085570,0x113 asm/non_matchings/boot/gfxprint/GfxPrint_SetColor.s,GfxPrint_SetColor,0x800859BC,0x13 asm/non_matchings/boot/gfxprint/GfxPrint_SetPosPx.s,GfxPrint_SetPosPx,0x80085A08,0x9 asm/non_matchings/boot/gfxprint/GfxPrint_SetPos.s,GfxPrint_SetPos,0x80085A2C,0xA From b3104f898b50a5679ebdcfdb1ef364f1e924c65f Mon Sep 17 00:00:00 2001 From: Isghj <42048411+isghj5@users.noreply.github.com> Date: Sat, 18 Jun 2022 19:00:48 -0700 Subject: [PATCH 231/257] `Effect_Ss_Extra` (points that appear above targets in Swamp Archery Minigame) and `object_yabusame_point` (#822) * EffectExtra: start * EffectExtra: matched * EffectExtra: docs * EffectExtra: warnings * Update src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update assets/xml/objects/object_yabusame_point.xml Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * EffectExtra: fixes * Update src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c Co-authored-by: Derek Hensley God damn it lenovo * Extra delete * EffectExtra: namefixer * EffectExtra: updated brief description Co-authored-by: Isghj8 Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --- assets/xml/objects/object_yabusame_point.xml | 6 +- spec | 3 +- .../ovl_Effect_Ss_Extra/z_eff_ss_extra.c | 84 +++++++++++++++++-- 3 files changed, 81 insertions(+), 12 deletions(-) diff --git a/assets/xml/objects/object_yabusame_point.xml b/assets/xml/objects/object_yabusame_point.xml index 856d94cfe..a7a3cac85 100644 --- a/assets/xml/objects/object_yabusame_point.xml +++ b/assets/xml/objects/object_yabusame_point.xml @@ -1,6 +1,8 @@  - - + + + + diff --git a/spec b/spec index d0351563a..0d3ee9e29 100644 --- a/spec +++ b/spec @@ -1965,8 +1965,7 @@ beginseg name "ovl_Effect_Ss_Extra" compress include "build/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.o" - include "build/data/ovl_Effect_Ss_Extra/ovl_Effect_Ss_Extra.data.o" - include "build/data/ovl_Effect_Ss_Extra/ovl_Effect_Ss_Extra.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Extra/ovl_Effect_Ss_Extra_reloc.o" endseg beginseg diff --git a/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c b/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c index cd0359ae3..1de32d6ce 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c +++ b/src/overlays/effects/ovl_Effect_Ss_Extra/z_eff_ss_extra.c @@ -1,29 +1,97 @@ /* * File: z_eff_ss_extra.c * Overlay: ovl_Effect_Ss_Extra - * Description: + * Description: The floating points that pop-up in Swamp Bow Minigame + * i.e. 100 points for hitting the deku scrubs in the background */ #include "z_eff_ss_extra.h" +#include "objects/object_yabusame_point/object_yabusame_point.h" #define PARAMS ((EffectSsExtraInitParams*)initParamsx) -s32 EffectSsExtra_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsExtra_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsExtra_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsExtra_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 +static s16 sScores[] = { 30, 60, 100 }; + const EffectSsInit Effect_Ss_Extra_InitVars = { EFFECT_SS_EXTRA, EffectSsExtra_Init, }; -#endif +static TexturePtr sPointTextures[] = { gYabusamePoint30Tex, gYabusamePoint60Tex, gYabusamePoint100Tex }; -extern UNK_TYPE D_06000DC0; +#define rObjId regs[0] +#define rTimer regs[1] +#define rScoreIndex regs[2] +#define rScale regs[3] -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Extra/EffectSsExtra_Init.s") +u32 EffectSsExtra_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + s32 pad; + EffectSsExtraInitParams* params = PARAMS; + s32 objIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Extra/EffectSsExtra_Draw.s") + objIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_YABUSAME_POINT); + if ((objIndex >= 0) && (Object_IsLoaded(&globalCtx->objectCtx, objIndex))) { + void* segBackup = gSegments[6]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Extra/EffectSsExtra_Update.s") + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[objIndex].segment); + + this->pos = params->pos; + this->velocity = params->velocity; + this->accel = params->accel; + this->draw = EffectSsExtra_Draw; + this->update = EffectSsExtra_Update; + this->life = 50; + this->rScoreIndex = params->scoreIdx; + this->rScale = params->scale; + this->rTimer = 5; + this->rObjId = objIndex; + + gSegments[6] = segBackup; + return 1; + } + return 0; +} + +void EffectSsExtra_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + s32 pad; + f32 scale; + void* storedSegment; + + scale = this->rScale / 100.0f; + storedSegment = globalCtx->objectCtx.status[this->rObjId].segment; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSegments[6] = PHYSICAL_TO_VIRTUAL(storedSegment); + + gSPSegment(POLY_XLU_DISP++, 0x06, storedSegment); + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sPointTextures[this->rScoreIndex])); + + gSPDisplayList(POLY_XLU_DISP++, &gYabusamePointDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EffectSsExtra_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + if (this->rTimer != 0) { + this->rTimer--; + } else { + this->velocity.y = 0.0f; + } + + if (this->rTimer == 1) { + globalCtx->interfaceCtx.unk_25C = sScores[this->rScoreIndex]; + } +} From e3c0c5c3fa79773ed5dc413fd38bac3b498dd30d Mon Sep 17 00:00:00 2001 From: Kristopher Early <1191258+MrPolymorph@users.noreply.github.com> Date: Sun, 19 Jun 2022 03:08:42 +0100 Subject: [PATCH 232/257] Obj_Tokei_Turret OK (#820) * actor fully matched * named collision parameters] * fixed spec reloc.o * Addressing Review Comments! * Addressing Additional Review Comments * fixing enum names Co-authored-by: MrPolymorph <{ID}+{username}@users.noreply.github.com> --- assets/xml/objects/object_tokei_turret.xml | 27 ++++----- spec | 3 +- .../ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c | 58 +++++++++++++++---- .../ovl_Obj_Tokei_Turret/z_obj_tokei_turret.h | 10 +++- undefined_syms.txt | 8 --- 5 files changed, 70 insertions(+), 36 deletions(-) diff --git a/assets/xml/objects/object_tokei_turret.xml b/assets/xml/objects/object_tokei_turret.xml index edca7c5c2..3ed158d83 100644 --- a/assets/xml/objects/object_tokei_turret.xml +++ b/assets/xml/objects/object_tokei_turret.xml @@ -1,17 +1,18 @@  + - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/spec b/spec index 0d3ee9e29..358e7362e 100644 --- a/spec +++ b/spec @@ -4211,8 +4211,7 @@ beginseg name "ovl_Obj_Tokei_Turret" compress include "build/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.o" - include "build/data/ovl_Obj_Tokei_Turret/ovl_Obj_Tokei_Turret.data.o" - include "build/data/ovl_Obj_Tokei_Turret/ovl_Obj_Tokei_Turret.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Tokei_Turret/ovl_Obj_Tokei_Turret_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c b/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c index 327183cfd..29ea1f8a8 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c +++ b/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.c @@ -5,6 +5,7 @@ */ #include "z_obj_tokei_turret.h" +#include "objects/object_tokei_turret/object_tokei_turret.h" #define FLAGS 0x00000000 @@ -15,7 +16,6 @@ void ObjTokeiTurret_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjTokeiTurret_Update(Actor* thisx, GlobalContext* globalCtx); void ObjTokeiTurret_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Tokei_Turret_InitVars = { ACTOR_OBJ_TOKEI_TURRET, ACTORCAT_BG, @@ -28,23 +28,59 @@ const ActorInit Obj_Tokei_Turret_InitVars = { (ActorFunc)ObjTokeiTurret_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B91EC0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void ObjTokeiTurret_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjTokeiTurret* this = THIS; + s32 tier; -extern InitChainEntry D_80B91EC0[]; + tier = OBJ_TOKEI_TURRET_TIER_TYPE(thisx); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); -extern UNK_TYPE D_060026A0; -extern UNK_TYPE D_06002A88; + if ((tier == TURRET_TIER_BASE) || (tier == TURRET_TIER_TOP)) { + this->dyna.actor.uncullZoneDownward = this->dyna.actor.uncullZoneScale = 240.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Turret/ObjTokeiTurret_Init.s") + if (tier == TURRET_TIER_BASE) { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTownTurretBaseCol); + } else { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClockTownTurretPlatformCol); + } + } else { + this->dyna.actor.uncullZoneDownward = this->dyna.actor.uncullZoneScale = 1300.0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Turret/ObjTokeiTurret_Destroy.s") +void ObjTokeiTurret_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjTokeiTurret* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Turret/ObjTokeiTurret_Update.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tokei_Turret/ObjTokeiTurret_Draw.s") +void ObjTokeiTurret_Update(Actor* thisx, GlobalContext* globalCtx) { +} + +void ObjTokeiTurret_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjTokeiTurret* this = THIS; + Gfx* gfx; + + if (OBJ_TOKEI_TURRET_TIER_TYPE(thisx) == TURRET_TIER_TOP) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + gSPDisplayList(gfx++, gClockTownTurretPlatformTopDL); + POLY_OPA_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else if (OBJ_TOKEI_TURRET_TIER_TYPE(thisx) == TURRET_TIER_BASE) { + Gfx_DrawDListOpa(globalCtx, gClockTownTurretPlatformBaseDL); + } else { + Gfx_DrawDListOpa(globalCtx, gClockTownFlagsDL); + } +} diff --git a/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.h b/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.h index 42cb6f5d7..7a2db071e 100644 --- a/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.h +++ b/src/overlays/actors/ovl_Obj_Tokei_Turret/z_obj_tokei_turret.h @@ -3,11 +3,17 @@ #include "global.h" +#define OBJ_TOKEI_TURRET_TIER_TYPE(thisx) ((thisx)->params & 3) + +typedef enum { + /* 0 */ TURRET_TIER_BASE, + /* 1 */ TURRET_TIER_TOP, +} TurretTierType; + struct ObjTokeiTurret; typedef struct ObjTokeiTurret { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x18]; + /* 0x000 */ DynaPolyActor dyna; } ObjTokeiTurret; // size = 0x15C extern const ActorInit Obj_Tokei_Turret_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index f24e3b627..29dbf71be 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1627,14 +1627,6 @@ D_06001CB0 = 0x06001CB0; D_06001400 = 0x06001400; -// ovl_Obj_Tokei_Turret - -D_06002508 = 0x06002508; -D_060026A0 = 0x060026A0; -D_06002A88 = 0x06002A88; -D_06002D80 = 0x06002D80; -D_06003038 = 0x06003038; - // ovl_Obj_Toudai D_060023B0 = 0x060023B0; From dd8221c7981d40a1a92e86e196b5495012629f11 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 19 Jun 2022 03:19:33 +0100 Subject: [PATCH 233/257] En_Time_Tag (#810) * En_Time_Tag * BSS * PR * PR --- include/z64.h | 8 +- include/z64player.h | 1 - spec | 3 +- .../actors/ovl_En_Time_Tag/z_en_time_tag.c | 268 ++++++++++++++++-- .../actors/ovl_En_Time_Tag/z_en_time_tag.h | 5 + 5 files changed, 261 insertions(+), 24 deletions(-) diff --git a/include/z64.h b/include/z64.h index 77f6a5ce0..a54ef333a 100644 --- a/include/z64.h +++ b/include/z64.h @@ -794,12 +794,18 @@ typedef struct { /* 0x24 */ u32 flags; } PreRenderParams; // size = 0x28 +typedef struct { + /* 0x00 */ u8 unk00; + /* 0x01 */ u8 unk01; +} MsgCtx11F00; + typedef struct { /* 0x00000 */ View view; /* 0x00168 */ Font font; /* 0x11EF4 */ char unk_11EF4[0x4]; /* 0x11EF8 */ UNK_PTR unk11EF8; - /* 0x11EFC */ UNK_TYPE1 unk11EFC[0x8]; + /* 0x11EFC */ UNK_TYPE1 unk11EFC[0x4]; + /* 0x11F00 */ MsgCtx11F00* unk11F00; /* 0x11F04 */ u16 currentTextId; /* 0x11F06 */ UNK_TYPE1 pad11F06[0x4]; /* 0x11F0A */ u8 unk11F0A; diff --git a/include/z64player.h b/include/z64player.h index 4066e2baf..3a3d10dc9 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -188,7 +188,6 @@ typedef struct { typedef void (*PlayerFuncD58)(struct GlobalContext*, struct Player*); - typedef struct Player { /* 0x000 */ Actor actor; /* 0x144 */ s8 currentShield; diff --git a/spec b/spec index 358e7362e..dc4eaa6b5 100644 --- a/spec +++ b/spec @@ -3387,8 +3387,7 @@ beginseg name "ovl_En_Time_Tag" compress include "build/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.o" - include "build/data/ovl_En_Time_Tag/ovl_En_Time_Tag.data.o" - include "build/data/ovl_En_Time_Tag/ovl_En_Time_Tag.reloc.o" + include "build/src/overlays/actors/ovl_En_Time_Tag/ovl_En_Time_Tag_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c index cd0403c71..382bf2fdb 100644 --- a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c +++ b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.c @@ -5,6 +5,7 @@ */ #include "z_en_time_tag.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" #define FLAGS (ACTOR_FLAG_10) @@ -29,7 +30,6 @@ void func_80ACA724(EnTimeTag* this, GlobalContext* globalCtx); void func_80ACA7C4(EnTimeTag* this, GlobalContext* globalCtx); void func_80ACA840(EnTimeTag* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Time_Tag_InitVars = { ACTOR_EN_TIME_TAG, ACTORCAT_ITEMACTION, @@ -42,40 +42,268 @@ const ActorInit En_Time_Tag_InitVars = { (ActorFunc)NULL, }; -#endif +void EnTimeTag_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTimeTag* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/EnTimeTag_Init.s") + this->actionFunc = func_80ACA840; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/EnTimeTag_Destroy.s") + switch (ENTIMETAG_GET_E000(&this->actor)) { + case 4: + if ((gSaveContext.save.weekEventReg[8] & 0x40) || (CURRENT_DAY != 3)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.home.rot.x = 0; + this->actor.home.rot.y = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80AC9FD4.s") + case 2: + this->actionFunc = func_80ACA0A8; + this->actor.flags |= ACTOR_FLAG_2000000; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80AC9FE4.s") + case 1: + this->actionFunc = func_80ACA268; + this->actor.flags |= ACTOR_FLAG_2000000; + if (CHECK_QUEST_ITEM(QUEST_SONG_SOARING)) { + this->actor.textId = 0xC02; + return; + } + this->actor.textId = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA0A8.s") + case 3: + this->actionFunc = func_80ACA5F8; + this->actor.textId = 0; + this->actor.home.rot.x = 0; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA12C.s") +void EnTimeTag_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA184.s") +void func_80AC9FD4(EnTimeTag* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA208.s") +void func_80AC9FE4(EnTimeTag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actionFunc = func_80AC9FD4; + gSaveContext.unk_3DD0[3] = 0; + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && + CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { + gSaveContext.save.weekEventReg[25] |= 2; + } + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA268.s") +void func_80ACA0A8(EnTimeTag* this, GlobalContext* globalCtx) { + EnTimeTag* this2 = this; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA348.s") + if ((globalCtx->msgCtx.ocarinaMode == 3) && (globalCtx->msgCtx.unk1202E == 4)) { + if (this->actor.cutscene != -1) { + this->actionFunc = func_80AC9FE4; + ActorCutscene_SetIntentToPlay(this2->actor.cutscene); + gSaveContext.unk_3DD0[3] = 0; + } + globalCtx->msgCtx.ocarinaMode = 4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA3C0.s") +void func_80ACA12C(EnTimeTag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { + this->actionFunc = func_80ACA268; + this->actor.textId = 0xC02; + Item_Give(globalCtx, ITEM_SONG_SOARING); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA418.s") +void func_80ACA184(EnTimeTag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + this->actionFunc = func_80ACA12C; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA5F8.s") +void func_80ACA208(EnTimeTag* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = func_80ACA268; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA714.s") +void func_80ACA268(EnTimeTag* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (this->actor.textId == 0) { + this->actionFunc = func_80ACA184; + } else { + this->actionFunc = func_80ACA208; + } + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + (Flags_GetSwitch(globalCtx, ENTIMETAG_GET_SWITCHFLAG(&this->actor)) || + CHECK_QUEST_ITEM(QUEST_SONG_SOARING))) { + this->actor.flags |= ACTOR_FLAG_1; + func_800B8614(&this->actor, globalCtx, 110.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA724.s") +void func_80ACA348(EnTimeTag* this, GlobalContext* globalCtx) { + if (this->actor.home.rot.x > 0) { + this->actor.home.rot.x--; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA7C4.s") + if (this->actor.home.rot.z != 0) { + func_80151938(globalCtx, 0x1230); + } else { + func_80151938(globalCtx, 0x122D); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/func_80ACA840.s") + this->actionFunc = func_80ACA418; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Time_Tag/EnTimeTag_Update.s") +void func_80ACA3C0(EnTimeTag* this, GlobalContext* globalCtx) { + if ((globalCtx->msgCtx.unk11F00->unk01 == 0) && (globalCtx->msgCtx.msgMode == 0x1B)) { + this->actor.home.rot.x = 5; + this->actionFunc = func_80ACA348; + globalCtx->msgCtx.unk11F10 = 0; + globalCtx->msgCtx.msgMode = 0; + } +} + +void func_80ACA418(EnTimeTag* this, GlobalContext* globalCtx) { + switch (Message_GetState(&globalCtx->msgCtx)) { + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x101C: + case 0x101D: + case 0x101E: + case 0x122D: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x101F: + case 0x122A: + case 0x1230: + func_801477B4(globalCtx); + this->actionFunc = func_80ACA5F8; + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + break; + + case 0x122B: + func_80152434(globalCtx, 0x3F); + this->actionFunc = func_80ACA3C0; + this->actor.home.rot.z = 0; + break; + + case 0x122E: + func_80152434(globalCtx, 0x40); + this->actionFunc = func_80ACA3C0; + this->actor.home.rot.z = 1; + break; + } + } + break; + + case 2: + this->actionFunc = func_80ACA5F8; + break; + } + + if (this->actor.home.rot.x != 0) { + if (this->actor.cutscene == -1) { + this->actor.home.rot.x = 0; + } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + this->actor.home.rot.x = 0; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} + +void func_80ACA5F8(EnTimeTag* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (ENTIMETAG_GET_SWITCHFLAG(&this->actor) == 1) { + Message_StartTextbox(globalCtx, 0x101C, &this->actor); + } else { + Message_StartTextbox(globalCtx, 0x122B, &this->actor); + } + this->actor.home.rot.x = 1; + } else { + Message_StartTextbox(globalCtx, 0x122A, &this->actor); + if (0) {} + ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 4; + Actor_ChangeFocus(&this->actor, globalCtx, GET_PLAYER(globalCtx)->tatlActor); + this->actor.home.rot.x = 0; + } + this->actionFunc = func_80ACA418; + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 110.0f); + } +} + +void func_80ACA714(EnTimeTag* this, GlobalContext* globalCtx) { +} + +void func_80ACA724(EnTimeTag* this, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 5) { + globalCtx->nextEntranceIndex = globalCtx->setupExitList[ENTIMETAG_GET_1F(&this->actor)]; + globalCtx->sceneLoadFlag = 0x14; + if (!ENTIMETAG_GET_E000(&this->actor)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_OC_DOOR_OPEN); + } + this->actionFunc = func_80ACA714; + } +} + +void func_80ACA7C4(EnTimeTag* this, GlobalContext* globalCtx) { + if (!(gSaveContext.save.weekEventReg[63] & 1) && !(gSaveContext.save.weekEventReg[63] & 2)) { + func_800B7298(globalCtx, &this->actor, 7); + Message_StartTextbox(globalCtx, ENTIMETAG_GET_1FE0(&this->actor) + 0x1883, NULL); + this->actionFunc = func_80ACA724; + } +} + +void func_80ACA840(EnTimeTag* this, GlobalContext* globalCtx) { + s16 temp_ft4; + s16 temp_hi; + + if ((globalCtx->sceneNum != SCENE_YADOYA) || (INV_CONTENT(ITEM_ROOM_KEY) != ITEM_ROOM_KEY)) { + temp_ft4 = gSaveContext.save.time * (24.0f / 0x10000); // TIME_TO_HOURS_F + temp_hi = (s32)TIME_TO_MINUTES_F(gSaveContext.save.time) % 60; + if (gSaveContext.save.weekEventReg[63] & 1) { + if (gSaveContext.save.weekEventReg[63] & 2) { + this->actionFunc = func_80ACA7C4; + } else if ((temp_ft4 == this->actor.home.rot.x) && (temp_hi == this->actor.home.rot.y)) { + gSaveContext.save.weekEventReg[63] |= 2; + } + } else if ((temp_ft4 == this->actor.home.rot.x) && (temp_hi == this->actor.home.rot.y) && + !Play_InCsMode(globalCtx)) { + func_800B7298(globalCtx, &this->actor, 7); + Message_StartTextbox(globalCtx, ENTIMETAG_GET_1FE0(&this->actor) + 0x1883, NULL); + this->actionFunc = func_80ACA724; + } + } +} + +void EnTimeTag_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTimeTag* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h index 7c2a6c00c..531b0aa90 100644 --- a/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h +++ b/src/overlays/actors/ovl_En_Time_Tag/z_en_time_tag.h @@ -7,6 +7,11 @@ struct EnTimeTag; typedef void (*EnTimeTagActionFunc)(struct EnTimeTag*, GlobalContext*); +#define ENTIMETAG_GET_1F(thisx) ((thisx)->params & 0x1F) +#define ENTIMETAG_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define ENTIMETAG_GET_1FE0(thisx) (((thisx)->params & 0x1FE0) >> 0x5) +#define ENTIMETAG_GET_E000(thisx) (((thisx)->params & 0xE000) >> 0xD) + typedef struct EnTimeTag { /* 0x0000 */ Actor actor; /* 0x0144 */ EnTimeTagActionFunc actionFunc; From 98ba7557513725f9dba6de8afcc02388a9eac96e Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 19 Jun 2022 03:23:25 +0100 Subject: [PATCH 234/257] En_Horse_Link_Child (#806) * EnHorseLinkChild * PR * PR --- include/z64skin.h | 4 +- spec | 3 +- .../z_en_horse_link_child.c | 573 ++++++++++++++++-- .../z_en_horse_link_child.h | 14 +- tools/disasm/functions.txt | 4 +- undefined_syms.txt | 5 - 6 files changed, 551 insertions(+), 52 deletions(-) diff --git a/include/z64skin.h b/include/z64skin.h index adb2f9b0f..3d0969fb2 100644 --- a/include/z64skin.h +++ b/include/z64skin.h @@ -78,8 +78,8 @@ typedef struct { /* 0x04C */ SkelAnime skelAnime; } Skin; // size = 0x90 -typedef void (*SkinPostDraw)(struct Actor*, struct GlobalContext*, Skin*); -typedef s32 (*SkinOverrideLimbDraw)(struct Actor*, struct GlobalContext*, s32, Skin*); +typedef void (*SkinPostDraw)(struct Actor* thisx, struct GlobalContext* globalCtx, Skin* skin); +typedef s32 (*SkinOverrideLimbDraw)(struct Actor* thisx, struct GlobalContext* globalCtx, s32 limbIndex, Skin* skin); #define SKIN_DRAW_FLAG_CUSTOM_TRANSFORMS (1 << 0) #define SKIN_DRAW_FLAG_CUSTOM_MATRIX (1 << 1) diff --git a/spec b/spec index dc4eaa6b5..54a782654 100644 --- a/spec +++ b/spec @@ -1169,8 +1169,7 @@ beginseg name "ovl_En_Horse_Link_Child" compress include "build/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.o" - include "build/data/ovl_En_Horse_Link_Child/ovl_En_Horse_Link_Child.data.o" - include "build/data/ovl_En_Horse_Link_Child/ovl_En_Horse_Link_Child.reloc.o" + include "build/src/overlays/actors/ovl_En_Horse_Link_Child/ovl_En_Horse_Link_Child_reloc.o" endseg beginseg 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 da62a57e0..26295c6eb 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 @@ -5,6 +5,7 @@ */ #include "z_en_horse_link_child.h" +#include "objects/object_horse_link_child/object_horse_link_child.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) @@ -15,7 +16,16 @@ void EnHorseLinkChild_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHorseLinkChild_Update(Actor* thisx, GlobalContext* globalCtx); void EnHorseLinkChild_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_808DEA0C(EnHorseLinkChild* this, GlobalContext* globalCtx); +void func_808DEB14(EnHorseLinkChild* this, GlobalContext* globalCtx); +void func_808DECA0(EnHorseLinkChild* this); +void func_808DED40(EnHorseLinkChild* this, GlobalContext* globalCtx); +void func_808DEFE8(EnHorseLinkChild* this); +void func_808DF194(EnHorseLinkChild* this, GlobalContext* globalCtx); +void func_808DF620(EnHorseLinkChild* this, GlobalContext* globalCtx); +void func_808DF788(EnHorseLinkChild* this); +void func_808DF838(EnHorseLinkChild* this, GlobalContext* globalCtx); + const ActorInit En_Horse_Link_Child_InitVars = { ACTOR_EN_HORSE_LINK_CHILD, ACTORCAT_BG, @@ -28,77 +38,560 @@ const ActorInit En_Horse_Link_Child_InitVars = { (ActorFunc)EnHorseLinkChild_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_808DFED4[1] = { +AnimationHeader* D_808DFEC0[] = { &object_horse_link_child_Anim_006D44, &object_horse_link_child_Anim_007468 }; + +AnimationHeader* D_808DFEC8[] = { &object_horse_link_child_Anim_007D50, &object_horse_link_child_Anim_0043AC, + &object_horse_link_child_Anim_002F98 }; + +static ColliderJntSphElementInit sJntSphElementsInit[] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 13, { { 0, 0, 0 }, 10 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808DFEF8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1 | OC2_UNK1, COLSHAPE_JNTSPH, }, - 1, D_808DFED4, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808DFF08 = { 10, 35, 100, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 10, 35, 100, MASS_HEAVY }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808DFF2C[] = { +s32 D_808DFF10[] = { 1, 19 }; + +f32 D_808DFF18[] = { 1.0f, 1.0f, 1.5f, 1.5f, 1.5f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_STOP), }; -#endif +EnHorseLinkChildUnkFunc D_808DFF30[] = { + func_808DEA0C, func_808DED40, func_808DEB14, func_808DF194, func_808DF838, func_808DF620, +}; -extern ColliderJntSphElementInit D_808DFED4[1]; -extern ColliderJntSphInit D_808DFEF8; -extern CollisionCheckInfoInit D_808DFF08; -extern InitChainEntry D_808DFF2C[]; +TexturePtr D_808DFF48[] = { object_horse_link_child_Tex_001D28, object_horse_link_child_Tex_001928, + object_horse_link_child_Tex_001B28 }; -extern UNK_TYPE D_06002F98; +s8 D_808DFF54[] = { 0, 1, 2, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DE5C0.s") +void func_808DE5C0(EnHorseLinkChild* this) { + if ((D_808DFF10[this->unk_1E8] < this->skin.skelAnime.curFrame) && + ((this->unk_1E8 != 0) || !(D_808DFF10[1] < this->skin.skelAnime.curFrame))) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_WALK); + this->unk_1E8++; + if (this->unk_1E8 >= 2) { + this->unk_1E8 = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DE660.s") +void func_808DE660(EnHorseLinkChild* this) { + if (this->unk_148 == 2) { + func_808DE5C0(this); + } else if (this->skin.skelAnime.curFrame == 0.0f) { + if ((this->unk_148 == 3) || (this->unk_148 == 4)) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else if (this->unk_148 == 1) { + if (Rand_ZeroOne() > 0.5f) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_GROAN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DE728.s") +f32 func_808DE728(EnHorseLinkChild* this) { + f32 phi_fv1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/EnHorseLinkChild_Init.s") + if (this->unk_148 == 2) { + phi_fv1 = D_808DFF18[this->unk_148] * this->actor.speedXZ * (1.0f / 2.0f); + } else if (this->unk_148 == 3) { + phi_fv1 = D_808DFF18[this->unk_148] * this->actor.speedXZ * (1.0f / 3.0f); + } else if (this->unk_148 == 4) { + phi_fv1 = D_808DFF18[this->unk_148] * this->actor.speedXZ * (1.0f / 5.0f); + } else { + phi_fv1 = D_808DFF18[this->unk_148]; + } + return phi_fv1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/EnHorseLinkChild_Destroy.s") +void EnHorseLinkChild_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHorseLinkChild* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DE9A8.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Actor_SetScale(&this->actor, 0.00648f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DEA0C.s") + this->actor.gravity = -3.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DEA54.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DEB14.s") + this->unk_144 = 1; + this->actor.speedXZ = 0.0f; + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 70.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DECA0.s") + Skin_Init(&globalCtx->state, &this->skin, &object_horse_link_child_Skel_00A480, + &object_horse_link_child_Anim_002F98); + this->unk_148 = 0; + Animation_PlayOnce(&this->skin.skelAnime, D_808DFEC0[0]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DED40.s") + Collider_InitCylinder(globalCtx, &this->colldierCylinder); + Collider_InitJntSph(globalCtx, &this->colliderJntSph); + Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, this->colliderJntSphElements); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DEFE8.s") + this->unk_1E8 = 0; + this->unk_1E4 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF088.s") + if (gSaveContext.sceneSetupIndex >= 4) { + func_808DEFE8(this); + } else { + func_808DEFE8(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF194.s") + this->actor.home.rot.z = this->actor.world.rot.z = this->actor.shape.rot.z = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF560.s") +void EnHorseLinkChild_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHorseLinkChild* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF620.s") + Skin_Free(&globalCtx->state, &this->skin); + Collider_DestroyCylinder(globalCtx, &this->colldierCylinder); + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF788.s") +void func_808DE9A8(EnHorseLinkChild* this) { + this->unk_144 = 0; + this->unk_148++; + if (this->unk_148 >= ARRAY_COUNT(D_808DFF18)) { + this->unk_148 = 0; + } + Animation_PlayOnce(&this->skin.skelAnime, D_808DFEC0[this->unk_148]); + this->skin.skelAnime.playSpeed = func_808DE728(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DF838.s") +void func_808DEA0C(EnHorseLinkChild* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_808DE9A8(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/EnHorseLinkChild_Update.s") +void func_808DEA54(EnHorseLinkChild* this, s32 arg1) { + this->unk_144 = 2; + this->actor.speedXZ = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DFC3C.s") + if ((arg1 != 0) && (arg1 != 1)) { + arg1 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/func_808DFDC8.s") + if (arg1 != this->unk_148) { + this->unk_148 = arg1; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Link_Child/EnHorseLinkChild_Draw.s") +void func_808DEB14(EnHorseLinkChild* this, GlobalContext* globalCtx) { + f32 sp44 = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + s32 phi_v0; + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if ((sp44 < 1000.0f) && (sp44 > 70.0f)) { + func_808DECA0(this); + return; + } + + if (this->unk_148 == 1) { + phi_v0 = 0; + } else { + phi_v0 = 1; + } + + if (phi_v0 != this->unk_148) { + this->unk_148 = phi_v0; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); + } else { + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, 0.0f); + } + } +} + +void func_808DECA0(EnHorseLinkChild* this) { + this->unk_144 = 1; + this->unk_148 = 0; + this->actor.speedXZ = 0.0f; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); +} + +void func_808DED40(EnHorseLinkChild* this, GlobalContext* globalCtx) { + f32 temp_fv0; + s16 temp_a0; + s32 phi_v0; + + if ((this->unk_148 == 4) || (this->unk_148 == 3) || (this->unk_148 == 2)) { + temp_a0 = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; + if (temp_a0 > 0x12C) { + this->actor.world.rot.y += 0x12C; + } else if (temp_a0 < -0x12C) { + this->actor.world.rot.y -= 0x12C; + } else { + this->actor.world.rot.y += temp_a0; + } + this->actor.shape.rot.y = this->actor.world.rot.y; + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + temp_fv0 = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + if (temp_fv0 > 1000.0f) { + func_808DEA54(this, 0); + return; + } + + if ((temp_fv0 < 1000.0f) && (temp_fv0 >= 300.0f)) { + phi_v0 = 4; + this->actor.speedXZ = 6.0f; + } else if ((temp_fv0 < 300.0f) && (temp_fv0 >= 150.0f)) { + phi_v0 = 3; + this->actor.speedXZ = 4.0f; + } else if ((temp_fv0 < 150.0f) && (temp_fv0 >= 70.0f)) { + phi_v0 = 2; + this->unk_1E8 = 0; + this->actor.speedXZ = 2.0f; + } else { + func_808DEA54(this, 1); + return; + } + + if (phi_v0 != this->unk_148) { + this->unk_148 = phi_v0; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); + } else { + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, 0.0f); + } + } +} + +void func_808DEFE8(EnHorseLinkChild* this) { + this->unk_144 = 3; + this->unk_148 = 0; + this->actor.speedXZ = 0.0f; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); +} + +void func_808DF088(EnHorseLinkChild* this, GlobalContext* globalCtx) { + if ((this->unk_148 == 4) || (this->unk_148 == 3) || (this->unk_148 == 2)) { + Player* player = GET_PLAYER(globalCtx); + s16 sp32; + s32 phi_v0; + s32 pad; + + if (Math3D_Distance(&player->actor.world.pos, &this->actor.home.pos) < 250.0f) { + sp32 = player->actor.shape.rot.y; + if (Actor_YawBetweenActors(&this->actor, &player->actor) > 0) { + phi_v0 = 1; + } else { + phi_v0 = -1; + } + sp32 += (phi_v0 << 0xE); + } else { + sp32 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos) - this->actor.world.rot.y; + } + + if (sp32 > 0x12C) { + this->actor.world.rot.y += 0x12C; + } else if (sp32 < -0x12C) { + this->actor.world.rot.y += -0x12C; + } else { + this->actor.world.rot.y += sp32; + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + } +} + +void func_808DF194(EnHorseLinkChild* this, GlobalContext* globalCtx) { + Player* player; + f32 sp50; + s32 sp4C; + s32 sp48; + + func_808DF088(this, globalCtx); + + player = GET_PLAYER(globalCtx); + sp50 = Actor_XZDistanceBetweenActors(&this->actor, &player->actor); + sp48 = this->unk_148; + sp4C = SkelAnime_Update(&this->skin.skelAnime); + + if ((sp4C != 0) || (this->unk_148 == 1) || (this->unk_148 == 0)) { + if ((gSaveContext.save.weekEventReg[1] & 0x20)) { + f32 sp44 = Math3D_Distance(&this->actor.world.pos, &this->actor.home.pos); + s32 pad; + + if (Math3D_Distance(&player->actor.world.pos, &this->actor.home.pos) > 250.0f) { + if (sp44 >= 300.0f) { + sp48 = 4; + this->actor.speedXZ = 6.0f; + } else if ((sp44 < 300.0f) && (sp44 >= 150.0f)) { + sp48 = 3; + this->actor.speedXZ = 4.0f; + } else if ((sp44 < 150.0f) && (sp44 >= 70.0f)) { + sp48 = 2; + this->unk_1E8 = 0; + this->actor.speedXZ = 2.0f; + } else { + this->actor.speedXZ = 0.0f; + if (this->unk_148 == 0) { + sp48 = (sp4C == 1) ? 1 : 0; + } else { + sp48 = (sp4C == 1) ? 0 : 1; + } + } + } else if (sp50 < 200.0f) { + sp48 = 4; + this->actor.speedXZ = 6.0f; + } else if (sp50 < 300.0f) { + sp48 = 3; + this->actor.speedXZ = 4.0f; + } else if (sp50 < 400.0f) { + sp48 = 2; + this->unk_1E8 = 0; + this->actor.speedXZ = 2.0f; + } else { + this->actor.speedXZ = 0.0f; + if (this->unk_148 == 0) { + sp48 = (sp4C == 1) ? 1 : 0; + } else { + sp48 = (sp4C == 1) ? 0 : 1; + } + } + } else { + this->actor.speedXZ = 0.0f; + if (this->unk_148 == 0) { + sp48 = (sp4C == 1) ? 1 : 0; + } else { + sp48 = (sp4C == 1) ? 0 : 1; + } + } + } + + if ((sp48 != this->unk_148) || (sp4C == 1)) { + this->unk_148 = sp48; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); + } else { + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), + this->skin.skelAnime.curFrame, Animation_GetLastFrame(D_808DFEC0[this->unk_148]), + ANIMMODE_ONCE, 0.0f); + } +} + +void func_808DF560(EnHorseLinkChild* this) { + this->unk_144 = 5; + + if (Rand_ZeroOne() > 0.5f) { + this->unk_148 = 0; + } else { + this->unk_148 = 1; + } + + D_801BDAA4 = 0; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, 0.0f); +} + +void func_808DF620(EnHorseLinkChild* this, GlobalContext* globalCtx) { + s16 sp36; + + if (D_801BDAA4 != 0) { + D_801BDAA4 = 0; + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + func_808DF788(this); + return; + } + + this->actor.speedXZ = 0.0f; + sp36 = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor) - this->actor.world.rot.y; + + if ((Math_CosS(sp36) < 0.7071f) && (this->unk_148 == 2)) { + func_800F415C(&this->actor, &GET_PLAYER(globalCtx)->actor.world.pos, 0x12C); + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (Math_CosS(sp36) < 0.0f) { + this->unk_148 = 2; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], D_808DFF18[this->unk_148], 0.0f, + Animation_GetLastFrame(D_808DFEC8[0]), ANIMMODE_ONCE, -5.0f); + } else { + func_808DF560(this); + } + } +} + +void func_808DF788(EnHorseLinkChild* this) { + this->unk_1DC = 0; + this->unk_144 = 4; + this->unk_148 = 2; + this->unk_1E0 = 0; + this->actor.speedXZ = 2.0f; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); +} + +void func_808DF838(EnHorseLinkChild* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 phi_fv0; + s32 phi_v0; + + this->unk_1DC++; + if (this->unk_1DC > 300) { + this->unk_1E0 = 1; + } + + if ((this->unk_148 == 4) || (this->unk_148 == 3) || (this->unk_148 == 2)) { + if (this->unk_1E0 == 0) { + func_800F415C(&this->actor, &player->actor.world.pos, 0x12C); + } else { + func_800F415C(&this->actor, &this->actor.home.pos, 0x12C); + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (this->unk_1E0 == 0) { + phi_fv0 = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + } else { + phi_fv0 = Math3D_Distance(&this->actor.world.pos, &this->actor.home.pos); + } + + if (this->unk_1E0 == 0) { + if (phi_fv0 >= 300.0f) { + phi_v0 = 4; + this->actor.speedXZ = 6.0f; + } else if (phi_fv0 >= 150.0f) { + phi_v0 = 3; + this->actor.speedXZ = 4.0f; + } else { + phi_v0 = 2; + this->unk_1E8 = 0; + this->actor.speedXZ = 2.0f; + } + } else if (phi_fv0 >= 300.0f) { + phi_v0 = 4; + this->actor.speedXZ = 6.0f; + } else if (phi_fv0 >= 150.0f) { + phi_v0 = 3; + this->actor.speedXZ = 4.0f; + } else if (phi_fv0 >= 70.0f) { + phi_v0 = 2; + this->unk_1E8 = 0; + this->actor.speedXZ = 2.0f; + } else { + func_808DF560(this); + return; + } + + if (phi_v0 != this->unk_148) { + this->unk_148 = phi_v0; + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, -5.0f); + } else { + Animation_Change(&this->skin.skelAnime, D_808DFEC0[this->unk_148], func_808DE728(this), 0.0f, + Animation_GetLastFrame(D_808DFEC0[this->unk_148]), ANIMMODE_ONCE, 0.0f); + } + } +} + +void EnHorseLinkChild_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHorseLinkChild* this = THIS; + + D_808DFF30[this->unk_144](this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 55.0f, 100.0f, 0x1D); + + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 70.0f; + + if ((Rand_ZeroOne() < 0.025f) && (this->unk_1E4 == 0)) { + this->unk_1E4++; + } else if (this->unk_1E4 > 0) { + this->unk_1E4++; + if (this->unk_1E4 >= 4) { + this->unk_1E4 = 0; + } + } + + Collider_UpdateCylinder(&this->actor, &this->colldierCylinder); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colldierCylinder.base); + + func_808DE660(this); +} + +void EnHorseLinkChild_PostSkinDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { + Vec3f sp4C; + Vec3f sp40; + EnHorseLinkChild* this = THIS; + s32 i; + + for (i = 0; i < this->colliderJntSph.count; i++) { + sp4C.x = this->colliderJntSph.elements[i].dim.modelSphere.center.x; + sp4C.y = this->colliderJntSph.elements[i].dim.modelSphere.center.y; + sp4C.z = this->colliderJntSph.elements[i].dim.modelSphere.center.z; + + Skin_GetLimbPos(skin, this->colliderJntSph.elements[i].dim.limb, &sp4C, &sp40); + + this->colliderJntSph.elements[i].dim.worldSphere.center.x = sp40.x; + this->colliderJntSph.elements[i].dim.worldSphere.center.y = sp40.y; + this->colliderJntSph.elements[i].dim.worldSphere.center.z = sp40.z; + this->colliderJntSph.elements[i].dim.worldSphere.radius = + this->colliderJntSph.elements[i].dim.modelSphere.radius * this->colliderJntSph.elements[i].dim.scale; + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); +} + +s32 EnHorseLinkChild_OverrideSkinDraw(Actor* thisx, GlobalContext* globalCtx, s32 limbIndex, Skin* skin) { + EnHorseLinkChild* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (limbIndex == OBJECT_HORSE_LINK_CHILD_LIMB_0D) { + u8 index = D_808DFF54[this->unk_1E4]; + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_808DFF48[index])); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + return true; +} + +void EnHorseLinkChild_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHorseLinkChild* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + func_80138258(&this->actor, globalCtx, &this->skin, EnHorseLinkChild_PostSkinDraw, + EnHorseLinkChild_OverrideSkinDraw, true); +} diff --git a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h index ecc816c52..0cdbdda9a 100644 --- a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h +++ b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h @@ -6,9 +6,21 @@ struct EnHorseLinkChild; +typedef void (*EnHorseLinkChildUnkFunc)(struct EnHorseLinkChild*, GlobalContext*); + typedef struct EnHorseLinkChild { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x158]; + /* 0x144 */ s32 unk_144; + /* 0x148 */ s32 unk_148; + /* 0x14C */ Skin skin; + /* 0x1DC */ s32 unk_1DC; + /* 0x1DC */ s32 unk_1E0; + /* 0x1E4 */ u8 unk_1E4; + /* 0x1E8 */ s32 unk_1E8; + /* 0x1EC */ ColliderCylinder colldierCylinder; + /* 0x238 */ ColliderJntSph colliderJntSph; + /* 0x258 */ ColliderJntSphElement colliderJntSphElements[1]; + /* 0x298 */ UNK_TYPE1 unk298[4]; } EnHorseLinkChild; // size = 0x29C extern const ActorInit En_Horse_Link_Child_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 7e2be3b0a..dbe8f14a6 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -6492,8 +6492,8 @@ 0x808DF788:("func_808DF788",), 0x808DF838:("func_808DF838",), 0x808DFB14:("EnHorseLinkChild_Update",), - 0x808DFC3C:("func_808DFC3C",), - 0x808DFDC8:("func_808DFDC8",), + 0x808DFC3C:("EnHorseLinkChild_PostSkinDraw",), + 0x808DFDC8:("EnHorseLinkChild_OverrideSkinDraw",), 0x808DFE3C:("EnHorseLinkChild_Draw",), 0x808E01A0:("DoorAna_SetupAction",), 0x808E01AC:("DoorAna_Init",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 29dbf71be..15bcad8c1 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1205,11 +1205,6 @@ D_0600B644 = 0x0600B644; D_0600F248 = 0x0600F248; D_06012A58 = 0x06012A58; -// ovl_En_Horse_Link_Child - -D_06002F98 = 0x06002F98; -D_0600A480 = 0x0600A480; - // ovl_En_Ik D_06000CE8 = 0x06000CE8; From 9bf84176d4dee29f4370f50228dcd1d9ee6d0107 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 18 Jun 2022 19:28:55 -0700 Subject: [PATCH 235/257] Load OK (#792) * Progress * cleanup * Fix comment * progress * OK * Review pt1 * Update comments * update comments some more * Renamings * Add headers and some parens cleanup * Remove zelda64 * PR review * bss * Explain each relocation type a bit in the header comment * Relocate_Addr macro * Split off into z64load.h * Adjust comment slightly based on OOT review * OverlayRelocationType -> MIPSRelocationType * Last bit of cleanup from OoT * format * Split off functions --- include/functions.h | 7 +- include/ultra64.h | 1 + include/ultra64/r4300.h | 367 ++++++++++++++++++++++++++++++++ include/variables.h | 4 +- include/z64.h | 9 - include/z64load.h | 31 +++ spec | 1 - src/boot_O2/loadfragment.c | 188 +++++++++++++++- src/boot_O2/loadfragment2.c | 194 +++++++++-------- src/code/z_DLF.c | 1 + src/code/z_actor.c | 1 + src/code/z_effect_soft_sprite.c | 1 + src/code/z_kaleido_manager.c | 1 + src/code/z_overlay.c | 1 + tools/disasm/functions.txt | 2 +- tools/disasm/variables.txt | 4 +- 16 files changed, 699 insertions(+), 114 deletions(-) create mode 100644 include/ultra64/r4300.h create mode 100644 include/z64load.h diff --git a/include/functions.h b/include/functions.h index 737b0ff81..b60aa04fa 100644 --- a/include/functions.h +++ b/include/functions.h @@ -104,12 +104,7 @@ void FaultDrawer_SetInputCallback(FaultDrawerCallback callback); void FaultDrawer_Init(void); void func_80084940(void); void func_80084968(void); -void Load_Relocate(u32 allocatedVRamAddr, OverlayRelocationSection* overlayInfo, u32 vRamStart); -s32 Load_LoadOverlay(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 allocatedVRamAddr, u32 allocatedBytes); -void* Load_AllocateAndLoad(u32 vRomStart, u32 vRomEnd, u32 vRamStart); -void Load2_Relocate(u32 allocatedVRamAddr, OverlayRelocationSection* overlayInfo, u32 vRamStart); -s32 Load2_LoadOverlay(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd, u32 allocatedVRamAddr); -void* Overlay_AllocateAndLoad(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd); + void PadUtils_Init(Input* input); void func_80085150(void); void PadUtils_ResetPressRel(Input* input); diff --git a/include/ultra64.h b/include/ultra64.h index 49323cc2b..6ffb26ff6 100644 --- a/include/ultra64.h +++ b/include/ultra64.h @@ -13,6 +13,7 @@ #include "ultra64/rcp.h" #include "ultra64/rdp.h" #include "ultra64/rsp.h" +#include "ultra64/r4300.h" #include "ultra64/vi.h" #endif diff --git a/include/ultra64/r4300.h b/include/ultra64/r4300.h new file mode 100644 index 000000000..30e8a9ea8 --- /dev/null +++ b/include/ultra64/r4300.h @@ -0,0 +1,367 @@ +#ifndef ULTRA64_R4300_H +#define ULTRA64_R4300_H + +#ifdef _LANGUAGE_C +#include "PR/ultratypes.h" +#define U32(x) ((u32)x) +#define C_REG(x) (x) +#else +#define U32(x) (x) +#define C_REG(x) $x +#endif + +// Segment base addresses and sizes +#define KUBASE 0 +#define KUSIZE 0x80000000 +#define K0BASE 0x80000000 +#define K0SIZE 0x20000000 +#define K1BASE 0xA0000000 +#define K1SIZE 0x20000000 +#define K2BASE 0xC0000000 +#define K2SIZE 0x20000000 + +// Exception vectors +#define SIZE_EXCVEC 0x80 // Size of an exc. vec +#define UT_VEC K0BASE // utlbmiss vector +#define R_VEC (K1BASE + 0x1FC00000) // reset vector +#define XUT_VEC (K0BASE + 0x80) // extended address tlbmiss +#define ECC_VEC (K0BASE + 0x100) // Ecc exception vector +#define E_VEC (K0BASE + 0x180) // Gen. exception vector + +// Address conversion macros +#define K0_TO_K1(x) (U32(x) | 0xA0000000) // kseg0 to kseg1 +#define K1_TO_K0(x) (U32(x) & 0x9FFFFFFF) // kseg1 to kseg0 +#define K0_TO_PHYS(x) (U32(x) & 0x1FFFFFFF) // kseg0 to physical +#define K1_TO_PHYS(x) (U32(x) & 0x1FFFFFFF) // kseg1 to physical +#define KDM_TO_PHYS(x) (U32(x) & 0x1FFFFFFF) // direct mapped to physical +#define PHYS_TO_K0(x) (U32(x) | 0x80000000) // physical to kseg0 +#define PHYS_TO_K1(x) (U32(x) | 0xA0000000) // physical to kseg1 + +// Address predicates +#define IS_KSEG0(x) (U32(x) >= K0BASE && U32(x) < K1BASE) +#define IS_KSEG1(x) (U32(x) >= K1BASE && U32(x) < K2BASE) +#define IS_KSEGDM(x) (U32(x) >= K0BASE && U32(x) < K2BASE) +#define IS_KSEG2(x) (U32(x) >= K2BASE && U32(x) < KPTE_SHDUBASE) +#define IS_KPTESEG(x) (U32(x) >= KPTE_SHDUBASE) +#define IS_KUSEG(x) (U32(x) < K0BASE) + +// TLB size constants +#define NTLBENTRIES 31 /* entry 31 is reserved by rdb */ + +#define TLBHI_VPN2MASK 0xFFFFE000 +#define TLBHI_VPN2SHIFT 13 +#define TLBHI_PIDMASK 0xFF +#define TLBHI_PIDSHIFT 0 +#define TLBHI_NPID 255 // 255 to fit in 8 bits + +#define TLBLO_PFNMASK 0x3FFFFFC0 +#define TLBLO_PFNSHIFT 6 +#define TLBLO_CACHMASK 0x38 // cache coherency algorithm +#define TLBLO_CACHSHIFT 3 +#define TLBLO_UNCACHED 0x10 // not cached +#define TLBLO_NONCOHRNT 0x18 // Cacheable non-coherent +#define TLBLO_EXLWR 0x28 // Exclusive write +#define TLBLO_D 0x4 // writeable +#define TLBLO_V 0x2 // valid bit +#define TLBLO_G 0x1 // global access bit + +#define TLBINX_PROBE 0x80000000 +#define TLBINX_INXMASK 0x3F +#define TLBINX_INXSHIFT 0 + +#define TLBRAND_RANDMASK 0x3F +#define TLBRAND_RANDSHIFT 0 + +#define TLBWIRED_WIREDMASK 0x3F + +#define TLBCTXT_BASEMASK 0xFF800000 +#define TLBCTXT_BASESHIFT 23 +#define TLBCTXT_BASEBITS 9 + +#define TLBCTXT_VPNMASK 0x7FFFF0 +#define TLBCTXT_VPNSHIFT 4 + +#define TLBPGMASK_4K 0x0 +#define TLBPGMASK_16K 0x6000 +#define TLBPGMASK_64K 0x1E000 + +/* + * Status register + */ +#define SR_CUMASK 0xF0000000 // coproc usable bits + +#define SR_CU3 0x80000000 // Coprocessor 3 usable +#define SR_CU2 0x40000000 // Coprocessor 2 usable +#define SR_CU1 0x20000000 // Coprocessor 1 usable +#define SR_CU0 0x10000000 // Coprocessor 0 usable +#define SR_RP 0x08000000 // Reduced power (quarter speed) +#define SR_FR 0x04000000 // MIPS III FP register mode +#define SR_RE 0x02000000 // Reverse endian +#define SR_ITS 0x01000000 // Instruction trace support +#define SR_BEV 0x00400000 // Use boot exception vectors +#define SR_TS 0x00200000 // TLB shutdown +#define SR_SR 0x00100000 // Soft reset occured +#define SR_CH 0x00040000 // Cache hit for last 'cache' op +#define SR_CE 0x00020000 // Create ECC +#define SR_DE 0x00010000 // ECC of parity does not cause error + +// Interrupt enable bits +// (NOTE: bits set to 1 enable the corresponding level interrupt) +#define SR_IMASK 0x0000FF00 // Interrupt mask +#define SR_IMASK8 0x00000000 // mask level 8 +#define SR_IMASK7 0x00008000 // mask level 7 +#define SR_IMASK6 0x0000C000 // mask level 6 +#define SR_IMASK5 0x0000E000 // mask level 5 +#define SR_IMASK4 0x0000F000 // mask level 4 +#define SR_IMASK3 0x0000F800 // mask level 3 +#define SR_IMASK2 0x0000FC00 // mask level 2 +#define SR_IMASK1 0x0000FE00 // mask level 1 +#define SR_IMASK0 0x0000FF00 // mask level 0 + +#define SR_IBIT8 0x00008000 // bit level 8 +#define SR_IBIT7 0x00004000 // bit level 7 +#define SR_IBIT6 0x00002000 // bit level 6 +#define SR_IBIT5 0x00001000 // bit level 5 +#define SR_IBIT4 0x00000800 // bit level 4 +#define SR_IBIT3 0x00000400 // bit level 3 +#define SR_IBIT2 0x00000200 // bit level 2 +#define SR_IBIT1 0x00000100 // bit level 1 + +#define SR_IMASKSHIFT 8 + +#define SR_KX 0x00000080 // extended-addr TLB vec in kernel +#define SR_SX 0x00000040 // xtended-addr TLB vec supervisor +#define SR_UX 0x00000020 // xtended-addr TLB vec in user mode +#define SR_KSU_MASK 0x00000018 // mode mask +#define SR_KSU_USR 0x00000010 // user mode +#define SR_KSU_SUP 0x00000008 // supervisor mode +#define SR_KSU_KER 0x00000000 // kernel mode +#define SR_ERL 0x00000004 // Error level, 1=>cache error +#define SR_EXL 0x00000002 // Exception level, 1=>exception +#define SR_IE 0x00000001 // interrupt enable, 1=>enable + +// Cause Register +#define CAUSE_BD 0x80000000 // Branch delay slot +#define CAUSE_CEMASK 0x30000000 // coprocessor error +#define CAUSE_CESHIFT 28 + +// Interrupt pending bits +#define CAUSE_IP8 0x00008000 // External level 8 pending - COMPARE +#define CAUSE_IP7 0x00004000 // External level 7 pending - INT4 +#define CAUSE_IP6 0x00002000 // External level 6 pending - INT3 +#define CAUSE_IP5 0x00001000 // External level 5 pending - INT2 +#define CAUSE_IP4 0x00000800 // External level 4 pending - INT1 +#define CAUSE_IP3 0x00000400 // External level 3 pending - INT0 +#define CAUSE_SW2 0x00000200 // Software level 2 pending +#define CAUSE_SW1 0x00000100 // Software level 1 pending + +#define CAUSE_IPMASK 0x0000FF00 // Pending interrupt mask +#define CAUSE_IPSHIFT 8 + +#define CAUSE_EXCMASK 0x0000007C // Cause code bits +#define CAUSE_EXCSHIFT 2 + +// Cause register exception codes + +#define EXC_CODE(x) ((x) << 2) + +// Hardware exception codes +#define EXC_INT EXC_CODE(0) // interrupt +#define EXC_MOD EXC_CODE(1) // TLB mod +#define EXC_RMISS EXC_CODE(2) // Read TLB Miss +#define EXC_WMISS EXC_CODE(3) // Write TLB Miss +#define EXC_RADE EXC_CODE(4) // Read Address Error +#define EXC_WADE EXC_CODE(5) // Write Address Error +#define EXC_IBE EXC_CODE(6) // Instruction Bus Error +#define EXC_DBE EXC_CODE(7) // Data Bus Error +#define EXC_SYSCALL EXC_CODE(8) // SYSCALL +#define EXC_BREAK EXC_CODE(9) // BREAKpoint +#define EXC_II EXC_CODE(10) // Illegal Instruction +#define EXC_CPU EXC_CODE(11) // CoProcessor Unusable +#define EXC_OV EXC_CODE(12) // OVerflow +#define EXC_TRAP EXC_CODE(13) // Trap exception +#define EXC_VCEI EXC_CODE(14) // Virt. Coherency on Inst. fetch +#define EXC_FPE EXC_CODE(15) // Floating Point Exception +#define EXC_WATCH EXC_CODE(23) // Watchpoint reference +#define EXC_VCED EXC_CODE(31) // Virt. Coherency on data read + +// C0_PRID Defines +#define C0_IMPMASK 0xFF00 +#define C0_IMPSHIFT 8 +#define C0_REVMASK 0xFF +#define C0_MAJREVMASK 0xF0 +#define C0_MAJREVSHIFT 4 +#define C0_MINREVMASK 0xF + +// Coprocessor 0 operations +#define C0_READI 0x1 // read ITLB entry addressed by C0_INDEX +#define C0_WRITEI 0x2 // write ITLB entry addressed by C0_INDEX +#define C0_WRITER 0x6 // write ITLB entry addressed by C0_RAND +#define C0_PROBE 0x8 // probe for ITLB entry addressed by TLBHI +#define C0_RFE 0x10 // restore for exception + +// 'cache' instruction definitions + +// Target cache +#define CACH_PI 0x0 // specifies primary inst. cache +#define CACH_PD 0x1 // primary data cache +#define CACH_SI 0x2 // secondary instruction cache +#define CACH_SD 0x3 // secondary data cache + +// Cache operations +#define C_IINV 0x0 // index invalidate (inst, 2nd inst) +#define C_IWBINV 0x0 // index writeback inval (d, sd) +#define C_ILT 0x4 // index load tag (all) +#define C_IST 0x8 // index store tag (all) +#define C_CDX 0xC // create dirty exclusive (d, sd) +#define C_HINV 0x10 // hit invalidate (all) +#define C_HWBINV 0x14 // hit writeback inv. (d, sd) +#define C_FILL 0x14 // fill (i) +#define C_HWB 0x18 // hit writeback (i, d, sd) +#define C_HSV 0x1C // hit set virt. (si, sd) + +// Cache size definitions +#define ICACHE_SIZE 0x4000 // 16K +#define ICACHE_LINESIZE 32 // 8 words +#define ICACHE_LINEMASK (ICACHE_LINESIZE - 1) + +#define DCACHE_SIZE 0x2000 // 8K +#define DCACHE_LINESIZE 16 // 4 words +#define DCACHE_LINEMASK (DCACHE_LINESIZE - 1) + +// C0_CONFIG register definitions +#define CONFIG_CM 0x80000000 // 1 == Master-Checker enabled +#define CONFIG_EC 0x70000000 // System Clock ratio +#define CONFIG_EC_1_1 0x6 // System Clock ratio 1 :1 +#define CONFIG_EC_3_2 0x7 // System Clock ratio 1.5 :1 +#define CONFIG_EC_2_1 0x0 // System Clock ratio 2 :1 +#define CONFIG_EC_3_1 0x1 // System Clock ratio 3 :1 +#define CONFIG_EP 0x0F000000 // Transmit Data Pattern +#define CONFIG_SB 0x00C00000 // Secondary cache block size + +#define CONFIG_SS 0x00200000 // Split scache: 0 == I&D combined +#define CONFIG_SW 0x00100000 // scache port: 0==128, 1==64 +#define CONFIG_EW 0x000C0000 // System Port width: 0==64, 1==32 +#define CONFIG_SC 0x00020000 // 0 -> 2nd cache present +#define CONFIG_SM 0x00010000 // 0 -> Dirty Shared Coherency enable +#define CONFIG_BE 0x00008000 // Endian-ness: 1 --> BE +#define CONFIG_EM 0x00004000 // 1 -> ECC mode, 0 -> parity +#define CONFIG_EB 0x00002000 // Block order:1->sequent,0->subblock + +#define CONFIG_IC 0x00000E00 // Primary Icache size +#define CONFIG_DC 0x000001C0 // Primary Dcache size +#define CONFIG_IB 0x00000020 // Icache block size +#define CONFIG_DB 0x00000010 // Dcache block size +#define CONFIG_CU 0x00000008 // Update on Store-conditional +#define CONFIG_K0 0x00000007 // K0SEG Coherency algorithm + +#define CONFIG_UNCACHED 0x00000002 // K0 is uncached +#define CONFIG_NONCOHRNT 0x00000003 +#define CONFIG_COHRNT_EXLWR 0x00000005 +#define CONFIG_SB_SHFT 22 // shift SB to bit position 0 +#define CONFIG_IC_SHFT 9 // shift IC to bit position 0 +#define CONFIG_DC_SHFT 6 // shift DC to bit position 0 +#define CONFIG_BE_SHFT 15 // shift BE to bit position 0 + +// C0_TAGLO definitions for setting/getting cache states and physaddr bits +#define SADDRMASK 0xFFFFE000 // 31..13 -> scache paddr bits 35..17 +#define SVINDEXMASK 0x00000380 // 9..7: prim virt index bits 14..12 +#define SSTATEMASK 0x00001C00 // bits 12..10 hold scache line state +#define SINVALID 0x00000000 // invalid --> 000 == state 0 +#define SCLEANEXCL 0x00001000 // clean exclusive --> 100 == state 4 +#define SDIRTYEXCL 0x00001400 // dirty exclusive --> 101 == state 5 +#define SECC_MASK 0x0000007F // low 7 bits are ecc for the tag +#define SADDR_SHIFT 4 // shift STagLo (31..13) to 35..17 + +#define PADDRMASK 0xFFFFFF00 // PTagLo31..8->prim paddr bits35..12 +#define PADDR_SHIFT 4 // roll bits 35..12 down to 31..8 +#define PSTATEMASK 0x00C0 // bits 7..6 hold primary line state +#define PINVALID 0x0000 // invalid --> 000 == state 0 +#define PCLEANEXCL 0x0080 // clean exclusive --> 10 == state 2 +#define PDIRTYEXCL 0x00C0 // dirty exclusive --> 11 == state 3 +#define PPARITY_MASK 0x0001 // low bit is parity bit (even). + +// C0_CACHE_ERR definitions. +#define CACHERR_ER 0x80000000 // 0: inst ref, 1: data ref +#define CACHERR_EC 0x40000000 // 0: primary, 1: secondary +#define CACHERR_ED 0x20000000 // 1: data error +#define CACHERR_ET 0x10000000 // 1: tag error +#define CACHERR_ES 0x08000000 // 1: external ref, e.g. snoo +#define CACHERR_EE 0x04000000 // error on SysAD bus +#define CACHERR_EB 0x02000000 // complicated, see spec. +#define CACHERR_EI 0x01000000 // complicated, see spec. +#define CACHERR_SIDX_MASK 0x003FFFF8 // secondary cache index +#define CACHERR_PIDX_MASK 0x00000007 // primary cache index +#define CACHERR_PIDX_SHIFT 12 // bits 2..0 are paddr14..12 + +/* + * R4000 family supports hardware watchpoints: + * C0_WATCHLO: + * bits 31..3 are bits 31..3 of physaddr to watch + * bit 2: reserved; must be written as 0. + * bit 1: when set causes a watchpoint trap on load accesses to paddr. + * bit 0: when set traps on stores to paddr; + * C0_WATCHHI + * bits 31..4 are reserved and must be written as zeros. + * bits 3..0 are bits 35..32 of the physaddr to watch + */ +#define WATCHLO_WTRAP 0x00000001 +#define WATCHLO_RTRAP 0x00000002 +#define WATCHLO_ADDRMASK 0xFFFFFFF8 +#define WATCHLO_VALIDMASK 0xFFFFFFFB +#define WATCHHI_VALIDMASK 0x0000000F + +// Coprocessor 0 registers +#define C0_INX C_REG(0) +#define C0_RAND C_REG(1) +#define C0_ENTRYLO0 C_REG(2) +#define C0_ENTRYLO1 C_REG(3) +#define C0_CONTEXT C_REG(4) +#define C0_PAGEMASK C_REG(5) // page mask +#define C0_WIRED C_REG(6) // # wired entries in tlb +#define C0_BADVADDR C_REG(8) +#define C0_COUNT C_REG(9) // free-running counter +#define C0_ENTRYHI C_REG(10) +#define C0_COMPARE C_REG(11) // counter comparison reg. +#define C0_SR C_REG(12) +#define C0_CAUSE C_REG(13) +#define C0_EPC C_REG(14) +#define C0_PRID C_REG(15) // revision identifier +#define C0_CONFIG C_REG(16) // hardware configuration +#define C0_LLADDR C_REG(17) // load linked address +#define C0_WATCHLO C_REG(18) // watchpoint +#define C0_WATCHHI C_REG(19) // watchpoint +#define C0_ECC C_REG(26) // S-cache ECC and primary parity +#define C0_CACHE_ERR C_REG(27) // cache error status +#define C0_TAGLO C_REG(28) // cache operations +#define C0_TAGHI C_REG(29) // cache operations +#define C0_ERROR_EPC C_REG(30) // ECC error prg. counter + +// floating-point status register +#define C1_FPCSR C_REG(31) + +#define FPCSR_FS 0x01000000 // flush denorm to zero +#define FPCSR_C 0x00800000 // condition bit +#define FPCSR_CE 0x00020000 // cause: unimplemented operation +#define FPCSR_CV 0x00010000 // cause: invalid operation +#define FPCSR_CZ 0x00008000 // cause: division by zero +#define FPCSR_CO 0x00004000 // cause: overflow +#define FPCSR_CU 0x00002000 // cause: underflow +#define FPCSR_CI 0x00001000 // cause: inexact operation +#define FPCSR_EV 0x00000800 // enable: invalid operation +#define FPCSR_EZ 0x00000400 // enable: division by zero +#define FPCSR_EO 0x00000200 // enable: overflow +#define FPCSR_EU 0x00000100 // enable: underflow +#define FPCSR_EI 0x00000080 // enable: inexact operation +#define FPCSR_FV 0x00000040 // flag: invalid operation +#define FPCSR_FZ 0x00000020 // flag: division by zero +#define FPCSR_FO 0x00000010 // flag: overflow +#define FPCSR_FU 0x00000008 // flag: underflow +#define FPCSR_FI 0x00000004 // flag: inexact operation +#define FPCSR_RM_MASK 0x00000003 // rounding mode mask +#define FPCSR_RM_RN 0x00000000 // round to nearest +#define FPCSR_RM_RZ 0x00000001 // round to zero +#define FPCSR_RM_RP 0x00000002 // round to positive infinity +#define FPCSR_RM_RM 0x00000003 // round to negative infinity + +#endif diff --git a/include/variables.h b/include/variables.h index c40ba1084..20b42dd71 100644 --- a/include/variables.h +++ b/include/variables.h @@ -35,8 +35,8 @@ extern const char* sCpuExceptions[18]; extern const char* sFpuExceptions[6]; extern FaultDrawer* sFaultDrawContext; extern FaultDrawer sFaultDrawerDefault; -// extern UNK_TYPE4 D_80096C20; -extern UNK_TYPE4 D_80096C30; +extern s32 gLoadLogSeverity; +extern s32 gLoad2LogSeverity; extern StackEntry* sStackInfoListStart; extern StackEntry* sStackInfoListEnd; // extern UNK_TYPE1 sGfxPrintFontTLUT; diff --git a/include/z64.h b/include/z64.h index a54ef333a..a0119f2f8 100644 --- a/include/z64.h +++ b/include/z64.h @@ -290,15 +290,6 @@ typedef enum IRQ_TYPE { IRQ_PRENMI_4 = 0x2A1 } IRQ_TYPE; -typedef struct { - /* 0x00 */ u32 textSize; - /* 0x04 */ u32 dataSize; - /* 0x08 */ u32 rodataSize; - /* 0x0C */ u32 bssSize; - /* 0x10 */ u32 nRelocations; - /* 0x14 */ u32 relocations[1]; -} OverlayRelocationSection; // size >= 0x18 - typedef struct { /* 0x00 */ u32 resetting; /* 0x04 */ u32 resetCount; diff --git a/include/z64load.h b/include/z64load.h new file mode 100644 index 000000000..8570faf25 --- /dev/null +++ b/include/z64load.h @@ -0,0 +1,31 @@ +#ifndef Z64LOAD_H +#define Z64LOAD_H + +#include "PR/ultratypes.h" + +#define RELOCATE_ADDR(addr, vRamStart, allocu32) ((addr) - (vRamStart) + (allocu32)) + +#define RELOC_SECTION(reloc) ((reloc) >> 30) +#define RELOC_OFFSET(reloc) ((reloc) & 0xFFFFFF) +#define RELOC_TYPE_MASK(reloc) ((reloc) & 0x3F000000) +#define RELOC_TYPE_SHIFT 24 + +/* MIPS Relocation Types */ +#define R_MIPS_32 2 +#define R_MIPS_26 4 +#define R_MIPS_HI16 5 +#define R_MIPS_LO16 6 + +typedef struct { + /* 0x00 */ u32 textSize; + /* 0x04 */ u32 dataSize; + /* 0x08 */ u32 rodataSize; + /* 0x0C */ u32 bssSize; + /* 0x10 */ u32 nRelocations; + /* 0x14 */ u32 relocations[1]; +} OverlayRelocationSection; // size >= 0x18 + +size_t Load2_LoadOverlay(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, uintptr_t vRamEnd, void* allocatedVRamAddr); +void* Load2_AllocateAndLoad(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, uintptr_t vRamEnd); + +#endif diff --git a/spec b/spec index 54a782654..cdf130b1d 100644 --- a/spec +++ b/spec @@ -29,7 +29,6 @@ beginseg include "build/src/boot_O2_g3/fault_drawer.o" include "build/src/boot_O2/boot_80084940.o" include "build/src/boot_O2/loadfragment.o" - include "build/data/boot/loadfragment.data.o" include "build/src/boot_O2/loadfragment2.o" include "build/src/boot_O2/padutils.o" include "build/src/boot_O2/stackcheck.o" diff --git a/src/boot_O2/loadfragment.c b/src/boot_O2/loadfragment.c index 968fb464a..17ed6b8ef 100644 --- a/src/boot_O2/loadfragment.c +++ b/src/boot_O2/loadfragment.c @@ -1,8 +1,190 @@ +/** + * @file loadfragment.c + * + * Functions used to process and relocate overlays + * + * @note: + * These are completly unused in favor of the functions in `loadfragment2.c`. + * + * The main difference between them seems to be the lack of vRamEnd arguments here. + * Instead they are calculated on the fly. + */ #include "global.h" #include "system_malloc.h" +#include "z64load.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/loadfragment/Load_Relocate.s") +s32 gLoadLogSeverity = 2; -#pragma GLOBAL_ASM("asm/non_matchings/boot/loadfragment/Load_LoadOverlay.s") +void Load_Relocate(void* allocatedVRamAddr, OverlayRelocationSection* ovl, uintptr_t vRamStart) { + u32 sections[4]; + u32* relocDataP; + u32 reloc; + uintptr_t relocatedAddress; + u32 i; + u32* luiInstRef; + uintptr_t allocu32 = (uintptr_t)allocatedVRamAddr; + u32* regValP; + u32* luiRefs[32]; + u32 luiVals[32]; + u32 isLoNeg; -#pragma GLOBAL_ASM("asm/non_matchings/boot/loadfragment/Load_AllocateAndLoad.s") + if (gLoadLogSeverity >= 3) {} + + sections[0] = 0; + sections[1] = allocu32; + sections[2] = allocu32 + ovl->textSize; + sections[3] = sections[2] + ovl->dataSize; + + for (i = 0; i < ovl->nRelocations; i++) { + reloc = ovl->relocations[i]; + relocDataP = (u32*)(sections[RELOC_SECTION(reloc)] + RELOC_OFFSET(reloc)); + + switch (RELOC_TYPE_MASK(reloc)) { + case R_MIPS_32 << RELOC_TYPE_SHIFT: + // Handles 32-bit address relocation, used for things such as jump tables and pointers in data. + // Just relocate the full address + + // Check address is valid for relocation + if ((*relocDataP & 0x0F000000) == 0) { + *relocDataP = RELOCATE_ADDR(*relocDataP, vRamStart, allocu32); + } else if (gLoadLogSeverity >= 3) { + } + break; + + case R_MIPS_26 << RELOC_TYPE_SHIFT: + // Handles 26-bit address relocation, used for jumps and jals. + // Extract the address from the target field of the J-type MIPS instruction. + // Relocate the address and update the instruction. + + *relocDataP = + (*relocDataP & 0xFC000000) | + ((RELOCATE_ADDR(PHYS_TO_K0((*relocDataP & 0x03FFFFFF) << 2), vRamStart, allocu32) & 0x0FFFFFFF) >> + 2); + break; + + case R_MIPS_HI16 << RELOC_TYPE_SHIFT: + // Handles relocation for a hi/lo pair, part 1. + // Store the reference to the LUI instruction (hi) using the `rt` register of the instruction. + // This will be updated later in the `R_MIPS_LO16` section. + + luiRefs[(*relocDataP >> 0x10) & 0x1F] = relocDataP; + luiVals[(*relocDataP >> 0x10) & 0x1F] = *relocDataP; + break; + + case R_MIPS_LO16 << RELOC_TYPE_SHIFT: + // Handles relocation for a hi/lo pair, part 2. + // Grab the stored LUI (hi) from the `R_MIPS_HI16` section using the `rs` register of the instruction. + // The full address is calculated, relocated, and then used to update both the LUI and lo instructions. + // If the lo part is negative, add 1 to the LUI value. + // Note: The lo instruction is assumed to have a signed immediate. + + luiInstRef = luiRefs[(*relocDataP >> 0x15) & 0x1F]; + regValP = &luiVals[(*relocDataP >> 0x15) & 0x1F]; + + // Check address is valid for relocation + if ((((*luiInstRef << 0x10) + (s16)*relocDataP) & 0x0F000000) == 0) { + relocatedAddress = RELOCATE_ADDR((*regValP << 0x10) + (s16)*relocDataP, vRamStart, allocu32); + isLoNeg = (relocatedAddress & 0x8000) ? 1 : 0; + *luiInstRef = (*luiInstRef & 0xFFFF0000) | (((relocatedAddress >> 0x10) & 0xFFFF) + isLoNeg); + *relocDataP = (*relocDataP & 0xFFFF0000) | (relocatedAddress & 0xFFFF); + } else if (gLoadLogSeverity >= 3) { + } + break; + } + } +} + +size_t Load_LoadOverlay(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, void* allocatedVRamAddr, + size_t allocatedBytes) { + size_t size = vRomEnd - vRomStart; + void* end; + s32 pad; + OverlayRelocationSection* ovl; + + if (gLoadLogSeverity >= 3) {} + if (gLoadLogSeverity >= 3) {} + + end = (uintptr_t)allocatedVRamAddr + size; + DmaMgr_SendRequest0(allocatedVRamAddr, vRomStart, size); + + ovl = (OverlayRelocationSection*)((uintptr_t)end - ((s32*)end)[-1]); + + if (gLoadLogSeverity >= 3) {} + + if (allocatedBytes < ovl->bssSize + size) { + if (gLoadLogSeverity >= 3) {} + return 0; + } + + allocatedBytes = ovl->bssSize + size; + + if (gLoadLogSeverity >= 3) {} + + Load_Relocate(allocatedVRamAddr, ovl, vRamStart); + + if (ovl->bssSize != 0) { + if (gLoadLogSeverity >= 3) {} + bzero(end, ovl->bssSize); + } + + osWritebackDCache(allocatedVRamAddr, allocatedBytes); + osInvalICache(allocatedVRamAddr, allocatedBytes); + + if (gLoadLogSeverity >= 3) {} + + return allocatedBytes; +} + +void* Load_AllocateAndLoad(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart) { + size_t size = vRomEnd - vRomStart; + void* end; + void* allocatedVRamAddr; + uintptr_t ovlOffset; + OverlayRelocationSection* ovl; + size_t allocatedBytes; + + if (gLoadLogSeverity >= 3) {} + + allocatedVRamAddr = SystemArena_MallocR(size); + end = (uintptr_t)allocatedVRamAddr + size; + + if (gLoadLogSeverity >= 3) {} + + DmaMgr_SendRequest0(allocatedVRamAddr, vRomStart, size); + + if (gLoadLogSeverity >= 3) {} + + ovlOffset = (uintptr_t)end - 4; + ovl = (OverlayRelocationSection*)((uintptr_t)end - ((s32*)end)[-1]); + + if (1) {} + + allocatedBytes = ovl->bssSize + size; + + allocatedVRamAddr = SystemArena_Realloc(allocatedVRamAddr, allocatedBytes); + + if (gLoadLogSeverity >= 3) {} + + if (allocatedVRamAddr == NULL) { + if (gLoadLogSeverity >= 3) {} + return allocatedVRamAddr; + } + + end = (uintptr_t)allocatedVRamAddr + size; + ovl = (OverlayRelocationSection*)((uintptr_t)end - *(uintptr_t*)ovlOffset); + + if (gLoadLogSeverity >= 3) {} + + Load_Relocate(allocatedVRamAddr, ovl, vRamStart); + + if (ovl->bssSize != 0) { + if (gLoadLogSeverity >= 3) {} + bzero(end, ovl->bssSize); + } + + osInvalICache(allocatedVRamAddr, allocatedBytes); + + if (gLoadLogSeverity >= 3) {} + + return allocatedVRamAddr; +} diff --git a/src/boot_O2/loadfragment2.c b/src/boot_O2/loadfragment2.c index c324b80d5..51b651c2b 100644 --- a/src/boot_O2/loadfragment2.c +++ b/src/boot_O2/loadfragment2.c @@ -1,120 +1,134 @@ +/** + * @file loadfragment2.c + * + * Functions used to process and relocate overlays + * + */ #include "global.h" #include "system_malloc.h" +#include "z64load.h" -UNK_TYPE4 D_80096C30 = 2; +s32 gLoad2LogSeverity = 2; -#ifdef NON_MATCHING -// This needs lots of work. Mostly regalloc and getting the address of D_80096C30 placed in s5 at the beginning of the -// function -void Load2_Relocate(u32 allocatedVRamAddr, OverlayRelocationSection* overlayInfo, u32 vRamStart) { - s32 sectionLocations[4]; - u32* regReferences[32]; - u32 regValues[32]; +void Load2_Relocate(void* allocatedVRamAddr, OverlayRelocationSection* ovl, uintptr_t vRamStart) { + u32 sections[4]; + u32* relocDataP; + u32 reloc; + uintptr_t relocatedAddress; u32 i; - u32 relocatedAddress; - s32 signedOffset; - u32* lastInst; - u32* inst; - u32 relocation; - u32 relocationIndex; + u32* luiInstRef; + uintptr_t allocu32 = (uintptr_t)allocatedVRamAddr; + u32* regValP; + u32* luiRefs[32]; + u32 luiVals[32]; + u32 isLoNeg; - sectionLocations[0] = 0; - sectionLocations[1] = allocatedVRamAddr; - sectionLocations[2] = overlayInfo->textSize + allocatedVRamAddr; - sectionLocations[3] = sectionLocations[2] + overlayInfo->dataSize; - for (i = 0, relocationIndex = 0; i < overlayInfo->nRelocations; relocationIndex++) { - relocation = overlayInfo->relocations[relocationIndex]; - i++; - inst = (u32*)(sectionLocations[relocation >> 0x1e] + (relocation & 0xffffff)); + if (gLoad2LogSeverity >= 3) {} - switch (relocation & 0x3f000000) { - case 0x2000000: - if ((*inst & 0xf000000) == 0) { - *inst = (*inst - vRamStart) + allocatedVRamAddr; + sections[0] = 0; + sections[1] = allocu32; + sections[2] = allocu32 + ovl->textSize; + sections[3] = sections[2] + ovl->dataSize; + + for (i = 0; i < ovl->nRelocations; i++) { + reloc = ovl->relocations[i]; + relocDataP = (u32*)(sections[RELOC_SECTION(reloc)] + RELOC_OFFSET(reloc)); + + switch (RELOC_TYPE_MASK(reloc)) { + case R_MIPS_32 << RELOC_TYPE_SHIFT: + // Handles 32-bit address relocation, used for things such as jump tables and pointers in data. + // Just relocate the full address + + // Check address is valid for relocation + if ((*relocDataP & 0x0F000000) == 0) { + *relocDataP = RELOCATE_ADDR(*relocDataP, vRamStart, allocu32); + } else if (gLoad2LogSeverity >= 3) { } - /* - else { - if (D_80096C30 > 2) { - ; - } - } - */ break; - case 0x4000000: - *inst = - (*inst & 0xfc000000) | - ((((((*inst & 0x3ffffff) << 2 | 0x80000000) - vRamStart) + allocatedVRamAddr) & 0xfffffff) >> 2); + + case R_MIPS_26 << RELOC_TYPE_SHIFT: + // Handles 26-bit address relocation, used for jumps and jals. + // Extract the address from the target field of the J-type MIPS instruction. + // Relocate the address and update the instruction. + + *relocDataP = + (*relocDataP & 0xFC000000) | + ((RELOCATE_ADDR(PHYS_TO_K0((*relocDataP & 0x03FFFFFF) << 2), vRamStart, allocu32) & 0x0FFFFFFF) >> + 2); break; - case 0x5000000: - regReferences[*inst >> 0x10 & 0x1f] = inst; - regValues[*inst >> 0x10 & 0x1f] = *inst; + + case R_MIPS_HI16 << RELOC_TYPE_SHIFT: + // Handles relocation for a hi/lo pair, part 1. + // Store the reference to the LUI instruction (hi) using the `rt` register of the instruction. + // This will be updated later in the `R_MIPS_LO16` section. + + luiRefs[(*relocDataP >> 0x10) & 0x1F] = relocDataP; + luiVals[(*relocDataP >> 0x10) & 0x1F] = *relocDataP; break; - case 0x6000000: - lastInst = regReferences[*inst >> 0x15 & 0x1f]; - signedOffset = (s16)*inst; - if (((signedOffset + *lastInst * 0x10000) & 0xf000000) == 0) { - relocatedAddress = - ((signedOffset + regValues[*inst >> 0x15 & 0x1f] * 0x10000) - vRamStart) + allocatedVRamAddr; - *lastInst = (((relocatedAddress >> 0x10) & 0xFFFF) + ((relocatedAddress & 0x8000) ? 1 : 0)) | - (*lastInst & 0xffff0000); - *inst = (*inst & 0xffff0000) | (relocatedAddress & 0xffff); + + case R_MIPS_LO16 << RELOC_TYPE_SHIFT: + // Handles relocation for a hi/lo pair, part 2. + // Grab the stored LUI (hi) from the `R_MIPS_HI16` section using the `rs` register of the instruction. + // The full address is calculated, relocated, and then used to update both the LUI and lo instructions. + // If the lo part is negative, add 1 to the LUI value. + // Note: The lo instruction is assumed to have a signed immediate. + + luiInstRef = luiRefs[(*relocDataP >> 0x15) & 0x1F]; + regValP = &luiVals[(*relocDataP >> 0x15) & 0x1F]; + + // Check address is valid for relocation + if ((((*luiInstRef << 0x10) + (s16)*relocDataP) & 0x0F000000) == 0) { + relocatedAddress = RELOCATE_ADDR((*regValP << 0x10) + (s16)*relocDataP, vRamStart, allocu32); + isLoNeg = (relocatedAddress & 0x8000) ? 1 : 0; + *luiInstRef = (*luiInstRef & 0xFFFF0000) | (((relocatedAddress >> 0x10) & 0xFFFF) + isLoNeg); + *relocDataP = (*relocDataP & 0xFFFF0000) | (relocatedAddress & 0xFFFF); + } else if (gLoad2LogSeverity >= 3) { } break; } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/boot/loadfragment2/Load2_Relocate.s") -#endif -#ifdef NON_MATCHING -// Very minor stack stuff with a saved value -s32 Load2_LoadOverlay(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd, u32 allocatedVRamAddr) { - int nbytes; - u32 pad; - size_t size; +size_t Load2_LoadOverlay(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, uintptr_t vRamEnd, + void* allocatedVRamAddr) { + s32 pad[2]; + s32 size = vRomEnd - vRomStart; void* end; - OverlayRelocationSection* overlayInfo; + OverlayRelocationSection* ovl; - size = vRomEnd - vRomStart; - - if (1) { - ; - } + if (gLoad2LogSeverity >= 3) {} + if (gLoad2LogSeverity >= 3) {} + end = (uintptr_t)allocatedVRamAddr + size; DmaMgr_SendRequest0(allocatedVRamAddr, vRomStart, size); - end = (void*)(allocatedVRamAddr + size); - overlayInfo = (OverlayRelocationSection*)((int)end - *(int*)((int)end + -4)); + ovl = (OverlayRelocationSection*)((uintptr_t)end - ((s32*)end)[-1]); - if (1) { - ; + if (gLoad2LogSeverity >= 3) {} + if (gLoad2LogSeverity >= 3) {} + + Load2_Relocate(allocatedVRamAddr, ovl, vRamStart); + + if (ovl->bssSize != 0) { + if (gLoad2LogSeverity >= 3) {} + bzero(end, ovl->bssSize); } - Load2_Relocate(allocatedVRamAddr, overlayInfo, vRamStart); - - if (overlayInfo->bssSize != 0) { - bzero(end, overlayInfo->bssSize); - } - - nbytes = vRamEnd - vRamStart; - - osWritebackDCache((void*)allocatedVRamAddr, nbytes); - osInvalICache((void*)allocatedVRamAddr, nbytes); - return nbytes; -} -#else -#pragma GLOBAL_ASM("asm/non_matchings/boot/loadfragment2/Load2_LoadOverlay.s") -#endif - -void* Overlay_AllocateAndLoad(u32 vRomStart, u32 vRomEnd, u32 vRamStart, u32 vRamEnd) { - void* allocatedVRamAddr; - size_t size; - size = vRamEnd - vRamStart; - allocatedVRamAddr = SystemArena_MallocR(size); + + osWritebackDCache(allocatedVRamAddr, size); + osInvalICache(allocatedVRamAddr, size); + + if (gLoad2LogSeverity >= 3) {} + + return size; +} + +void* Load2_AllocateAndLoad(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, uintptr_t vRamEnd) { + void* allocatedVRamAddr = SystemArena_MallocR(vRamEnd - vRamStart); + if (allocatedVRamAddr != NULL) { - Load2_LoadOverlay(vRomStart, vRomEnd, vRamStart, vRamEnd, (u32)allocatedVRamAddr); + Load2_LoadOverlay(vRomStart, vRomEnd, vRamStart, vRamEnd, allocatedVRamAddr); } return allocatedVRamAddr; diff --git a/src/code/z_DLF.c b/src/code/z_DLF.c index 4c57aca01..862463b76 100644 --- a/src/code/z_DLF.c +++ b/src/code/z_DLF.c @@ -1,5 +1,6 @@ #include "global.h" #include "system_malloc.h" +#include "z64load.h" #pragma GLOBAL_ASM("asm/non_matchings/code/z_DLF/Overlay_LoadGameState.s") diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 9325d315c..bbabeafd5 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -4,6 +4,7 @@ */ #include "global.h" +#include "z64load.h" #include "overlays/actors/ovl_En_Horse/z_en_horse.h" #include "overlays/actors/ovl_En_Part/z_en_part.h" #include "overlays/actors/ovl_En_Box/z_en_box.h" diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index fd1d0212c..56eab9e8a 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64load.h" EffectSsInfo sEffectSsInfo = { NULL, 0, 0 }; diff --git a/src/code/z_kaleido_manager.c b/src/code/z_kaleido_manager.c index 5e89f49e9..73656d65d 100644 --- a/src/code/z_kaleido_manager.c +++ b/src/code/z_kaleido_manager.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64load.h" #define KALEIDO_OVERLAY(name) \ { \ diff --git a/src/code/z_overlay.c b/src/code/z_overlay.c index f635331c9..a358cefe6 100644 --- a/src/code/z_overlay.c +++ b/src/code/z_overlay.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64load.h" #pragma GLOBAL_ASM("asm/non_matchings/code/z_overlay/func_801651B0.s") diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index dbe8f14a6..f037221be 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -114,7 +114,7 @@ 0x80084CD0:("Load_AllocateAndLoad",), 0x80084DB0:("Load2_Relocate",), 0x8008501C:("Load2_LoadOverlay",), - 0x800850C8:("Overlay_AllocateAndLoad",), + 0x800850C8:("Load2_AllocateAndLoad",), 0x80085130:("PadUtils_Init",), 0x80085150:("func_80085150",), 0x80085158:("PadUtils_ResetPressRel",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 1223f31fa..e0bf5a65a 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -27,8 +27,8 @@ 0x80096BC8:("sFpuExceptions","char*","[6]",0x18), 0x80096BE0:("sFaultDrawContext","FaultDrawer*","",0x4), 0x80096BE4:("sFaultDrawerDefault","FaultDrawer","",0x3c), - 0x80096C20:("D_80096C20","UNK_TYPE4","",0x4), - 0x80096C30:("D_80096C30","UNK_TYPE4","",0x4), + 0x80096C20:("gLoadLogSeverity","UNK_TYPE4","",0x4), + 0x80096C30:("gLoad2LogSeverity","UNK_TYPE4","",0x4), 0x80096C40:("sStackInfoListStart","StackEntry*","",0x4), 0x80096C44:("sStackInfoListEnd","StackEntry*","",0x4), 0x80096C50:("sGfxPrintFontTLUT","u16","[64]",0x80), From 5ae4ef87cd8b1bd94cdc63174bfe6bd3f8183723 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 18 Jun 2022 19:33:53 -0700 Subject: [PATCH 236/257] Sob1 Objects Documented (#814) * Start zora * Finish zora * BombShopkeeper with some cleanup * Goron and don gero mask * Small thing * format * PR comments * bombshopkeeper -> bomb_shopkeeper * gEffShockwaveDL --- assets/xml/objects/gameplay_keep.xml | 4 +- assets/xml/objects/object_mask_gero.xml | 19 +- assets/xml/objects/object_mastergolon.xml | 3 +- assets/xml/objects/object_masterzoora.xml | 3 +- assets/xml/objects/object_oF1d_map.xml | 230 ++++++++++-------- assets/xml/objects/object_rs.xml | 108 ++++---- assets/xml/objects/object_zo.xml | 112 +++++---- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.c | 2 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 2 + src/overlays/actors/ovl_En_Fsn/z_en_fsn.h | 2 +- src/overlays/actors/ovl_En_Geg/z_en_geg.c | 38 +-- src/overlays/actors/ovl_En_Go/z_en_go.c | 46 ++-- src/overlays/actors/ovl_En_Ossan/z_en_ossan.h | 3 +- src/overlays/actors/ovl_En_Rg/z_en_rg.c | 19 +- src/overlays/actors/ovl_En_Rsn/z_en_rsn.c | 16 +- src/overlays/actors/ovl_En_Rsn/z_en_rsn.h | 2 +- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 176 +++++++------- src/overlays/actors/ovl_En_Sob1/z_en_sob1.h | 17 +- src/overlays/actors/ovl_En_Zo/z_en_zo.c | 17 +- src/overlays/actors/ovl_En_Zo/z_en_zo.h | 5 +- src/overlays/actors/ovl_En_Zot/z_en_zot.c | 8 +- src/overlays/actors/ovl_En_Zow/z_en_zow.c | 14 +- .../ovl_Object_Kankyo/z_object_kankyo.c | 2 +- 23 files changed, 464 insertions(+), 384 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 6b624857f..d4a4ac277 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1001,8 +1001,8 @@ - - + + diff --git a/assets/xml/objects/object_mask_gero.xml b/assets/xml/objects/object_mask_gero.xml index b6acf6c17..b6f4a6117 100644 --- a/assets/xml/objects/object_mask_gero.xml +++ b/assets/xml/objects/object_mask_gero.xml @@ -1,13 +1,14 @@  + - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_mastergolon.xml b/assets/xml/objects/object_mastergolon.xml index ae481332c..35eb9d285 100644 --- a/assets/xml/objects/object_mastergolon.xml +++ b/assets/xml/objects/object_mastergolon.xml @@ -1,5 +1,6 @@  + - + diff --git a/assets/xml/objects/object_masterzoora.xml b/assets/xml/objects/object_masterzoora.xml index c4f8735d7..f21b99b50 100644 --- a/assets/xml/objects/object_masterzoora.xml +++ b/assets/xml/objects/object_masterzoora.xml @@ -1,5 +1,6 @@  + - + diff --git a/assets/xml/objects/object_oF1d_map.xml b/assets/xml/objects/object_oF1d_map.xml index 6c3af0778..a55e9c9ea 100644 --- a/assets/xml/objects/object_oF1d_map.xml +++ b/assets/xml/objects/object_oF1d_map.xml @@ -1,108 +1,142 @@  + - - - - - - - + + + + + + + + + + + + + + - + - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_rs.xml b/assets/xml/objects/object_rs.xml index 01099db47..fe58a7555 100644 --- a/assets/xml/objects/object_rs.xml +++ b/assets/xml/objects/object_rs.xml @@ -1,53 +1,63 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zo.xml b/assets/xml/objects/object_zo.xml index 8fc22ae46..d2a16cfac 100644 --- a/assets/xml/objects/object_zo.xml +++ b/assets/xml/objects/object_zo.xml @@ -1,28 +1,39 @@  + + - - - - - - + + + + + + + + + + + - + - - - - - - - - - - + + + + + + + + + + + + + + @@ -42,37 +53,44 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index bfc6102b0..9b089d836 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -843,7 +843,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { Matrix_Put(&mtxF); Matrix_Scale(effect->scale, 1.0f, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_030100); + gSPDisplayList(POLY_XLU_DISP++, gEffShockwaveDL); } } } diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index 670bafff2..bfeca2143 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -1410,6 +1410,8 @@ void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx) { EnFsn* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + + // Note: adding 1 to FSN_LIMB_MAX due to bug in object_fsn, see bug in object_fsn.xml SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFsnSkel, &gFsnIdleAnim, this->jointTable, this->morphTable, FSN_LIMB_MAX + 1); if (ENFSN_IS_SHOP(&this->actor)) { diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h index 5fabf59ad..66cde7a2a 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h @@ -28,7 +28,7 @@ typedef struct EnFsn { /* 0x24E */ s16 limbRotZTable[19]; /* 0x274 */ Vec3s headRot; /* 0x27A */ Vec3s unk27A; // Set but never used - /* 0x280 */ Vec3s jointTable[FSN_LIMB_MAX + 1]; + /* 0x280 */ Vec3s jointTable[FSN_LIMB_MAX + 1]; // Note: adding 1 to FSN_LIMB_MAX due to bug in object_fsn, see bug in object_fsn.xml /* 0x2F2 */ Vec3s morphTable[FSN_LIMB_MAX + 1]; /* 0x364 */ s16 eyeTextureIdx; /* 0x366 */ s16 blinkTimer; 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 79e5a3480..a2efb787a 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -126,14 +126,14 @@ static DamageTable sDamageTable = { }; static AnimationInfoS sAnimations[] = { - { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_oF1d_map_Anim_0039D8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &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 }, { &object_taisou_Anim_0016C8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_taisou_Anim_004DD4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_taisou_Anim_00283C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, @@ -142,11 +142,11 @@ static AnimationInfoS sAnimations[] = { { &object_taisou_Anim_002C48, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_taisou_Anim_0031D8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_taisou_Anim_005790, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_oF1d_map_Anim_003650, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronCoverEarsAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_hakugin_demo_Anim_002704, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_oF1d_map_Anim_0135E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_oF1d_map_Anim_014CE0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronShiveringSurprisedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronStandingIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; u16 func_80BB16D0(EnGeg* this) { @@ -866,8 +866,8 @@ void EnGeg_Init(Actor* thisx, GlobalContext* globalCtx) { } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, &object_oF1d_map_Anim_012DE0, - this->jointTable, this->morphTable, 18); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronSkel, &gGoronUnrollAnim, this->jointTable, this->morphTable, + GORON_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->colliderCylinder); Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); @@ -954,7 +954,7 @@ void EnGeg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve OPEN_DISPS(globalCtx->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, object_oF1d_map_DL_004DB0); + gSPDisplayList(POLY_OPA_DISP++, gGoronDonGeroMaskDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1035,10 +1035,10 @@ void EnGeg_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi void func_80BB3BE0(EnGeg* this, GlobalContext* globalCtx) { static TexturePtr D_80BB4088[] = { - object_oF1d_map_Tex_010438, - object_oF1d_map_Tex_010C38, - object_oF1d_map_Tex_011038, - object_oF1d_map_Tex_010838, + gGoronEyeOpenTex, + gGoronEyeHalfTex, + gGoronEyeClosedTex, + gGoronEyeClosed2Tex, }; s32 pad; @@ -1072,7 +1072,7 @@ void func_80BB3CB4(EnGeg* this, GlobalContext* globalCtx) { Matrix_RotateXS(sp24, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_oF1d_map_DL_0091A8); + gSPDisplayList(POLY_OPA_DISP++, gGoronRolledUpDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } 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 27c307777..659473e30 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -187,16 +187,16 @@ static DamageTable sDamageTable = { }; static AnimationInfoS sAnimations[] = { - { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_oF1d_map_Anim_0039D8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_oF1d_map_Anim_003650, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_oF1d_map_Anim_0135E8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &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, 0 }, + { &gGoronShiverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronShiverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gGoronDropKegAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gGoronCoverEarsAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronShiveringSurprisedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, { &object_taisou_Anim_004DD4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &object_taisou_Anim_0016C8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, @@ -249,7 +249,7 @@ void func_80A11144(EnGoStruct* ptr, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_0031A0); + gSPDisplayList(POLY_XLU_DISP++, gGoronSteamMaterialDL); flag = true; } @@ -269,7 +269,7 @@ void func_80A11144(EnGoStruct* ptr, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_003258); + gSPDisplayList(POLY_XLU_DISP++, gGoronSteamModelDL); Matrix_Pop(); if (globalCtx->state.gfxCtx) {} @@ -325,7 +325,7 @@ void func_80A115B4(EnGoStruct* ptr, GlobalContext* globalCtx) { if ((ptr->unk_00 >= 4) && (ptr->unk_00 < 7)) { if (!flag) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014CF0); + gSPDisplayList(POLY_XLU_DISP++, gGoronDustMaterialDL); flag = true; } Matrix_Push(); @@ -344,7 +344,7 @@ void func_80A115B4(EnGoStruct* ptr, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A16644[(s32)(temp * 7.0f)])); - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014D00); + gSPDisplayList(POLY_XLU_DISP++, gGoronDustModelDL); Matrix_Pop(); } @@ -516,9 +516,12 @@ void func_80A1203C(EnGo* this) { } void func_80A1213C(EnGo* this, GlobalContext* globalCtx) { - func_80A11EC0(this->unk_3F8, globalCtx, object_oF1d_map_DL_0003D0, object_oF1d_map_DL_000458, 1); - func_80A11EC0(this->unk_3F8, globalCtx, object_oF1d_map_DL_0008C0, object_oF1d_map_DL_000948, 2); - func_80A11EC0(this->unk_3F8, globalCtx, object_oF1d_map_DL_000D50, object_oF1d_map_DL_000DD8, 3); + func_80A11EC0(this->unk_3F8, globalCtx, gGoronLargeSnowballFragmentMaterialDL, gGoronLargeSnowballFragmentModelDL, + 1); + func_80A11EC0(this->unk_3F8, globalCtx, gGoronMediumSnowballFragmentMaterialDL, gGoronMediumSnowballFragmentModelDL, + 2); + func_80A11EC0(this->unk_3F8, globalCtx, gGoronSmallSnowballFragmentMaterialDL, gGoronSmallSnowballFragmentModelDL, + 3); func_80A11144(this->unk_3F8, globalCtx); func_80A115B4(this->unk_3F8, globalCtx); } @@ -1459,8 +1462,8 @@ void func_80A14798(EnGo* this, GlobalContext* globalCtx) { if ((this->unk_288 < 0) || SubS_IsObjectLoaded(this->unk_288, globalCtx) || (this->unk_289 < 0) || SubS_IsObjectLoaded(this->unk_289, globalCtx)) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, - this->morphTable, 18); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronSkel, NULL, this->jointTable, this->morphTable, + GORON_LIMB_MAX); this->unk_3DC = -1; func_80A12C48(this, globalCtx, 2); @@ -1966,7 +1969,7 @@ void func_80A15B80(EnGo* this, GlobalContext* globalCtx) { Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, (this->unk_390 & 0x100) ? object_oF1d_map_DL_001560 : object_oF1d_map_DL_0091A8); + gSPDisplayList(POLY_OPA_DISP++, (this->unk_390 & 0x100) ? gGoronSnowballDL : gGoronRolledUpDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -2059,8 +2062,7 @@ void EnGo_TransfromLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this void func_80A15FEC(Actor* thisx, GlobalContext* globalCtx) { static TexturePtr D_80A1670C[] = { - object_oF1d_map_Tex_010438, object_oF1d_map_Tex_010C38, object_oF1d_map_Tex_011038, - object_oF1d_map_Tex_010C38, object_oF1d_map_Tex_010838, + gGoronEyeOpenTex, gGoronEyeHalfTex, gGoronEyeClosedTex, gGoronEyeHalfTex, gGoronEyeClosed2Tex, }; EnGo* this = THIS; diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h index 58c638d8e..00ed6814a 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h @@ -6,7 +6,8 @@ #include "objects/object_ani/object_ani.h" #include "objects/object_fsn/object_fsn.h" -#define ENOSSAN_LIMB_MAX MAX(FSN_LIMB_MAX + 1, ANI_LIMB_MAX) +// Note: adding 1 to FSN_LIMB_MAX due to bug in object_fsn, see bug in object_fsn.xml +#define ENOSSAN_LIMB_MAX MAX((s32)FSN_LIMB_MAX + 1, (s32)ANI_LIMB_MAX) struct EnOssan; diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index c5f2954f9..43042ccd0 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -119,8 +119,8 @@ s32 D_80BF57E4[][4] = { }; AnimationInfoS D_80BF5914[] = { - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronUnrollAnim, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronUnrollAnim, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; TexturePtr D_80BF5934[] = { @@ -153,8 +153,7 @@ EffectTireMarkInit D_80BF59F0 = { }; TexturePtr D_80BF59F8[] = { - object_oF1d_map_Tex_010438, object_oF1d_map_Tex_010C38, object_oF1d_map_Tex_011038, - object_oF1d_map_Tex_010C38, object_oF1d_map_Tex_010838, + gGoronEyeOpenTex, gGoronEyeHalfTex, gGoronEyeClosedTex, gGoronEyeHalfTex, gGoronEyeClosed2Tex, }; void func_80BF3920(EnRgStruct* ptr, GlobalContext* globalCtx) { @@ -170,8 +169,8 @@ void func_80BF3920(EnRgStruct* ptr, GlobalContext* globalCtx) { for (i = 0; i < 32; i++, ptr++) { if ((ptr->unk_00 >= 4) && (ptr->unk_00 < 7)) { if (!phi_fp) { - POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, sizeof(Gfx) * 0); - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014CF0); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + gSPDisplayList(POLY_XLU_DISP++, gGoronDustMaterialDL); phi_fp = true; } @@ -193,7 +192,7 @@ void func_80BF3920(EnRgStruct* ptr, GlobalContext* globalCtx) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); idx = temp_f20 * 7.0f; gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BF5934[idx])); - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014D00); + gSPDisplayList(POLY_XLU_DISP++, gGoronDustModelDL); Matrix_Pop(); } @@ -728,8 +727,8 @@ void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.save.entranceIndex == 0xD010) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, - this->morphTable, 18); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronSkel, NULL, this->jointTable, this->morphTable, + GORON_LIMB_MAX); this->unk_334 = -1; func_80BF409C(this, 0); @@ -814,7 +813,7 @@ void func_80BF547C(EnRg* this, GlobalContext* globalCtx) { Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_oF1d_map_DL_0091A8); + gSPDisplayList(POLY_OPA_DISP++, gGoronRolledUpDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c index 3a29b5081..2d8eaa643 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c @@ -30,7 +30,7 @@ const ActorInit En_Rsn_InitVars = { (ActorFunc)EnRsn_Draw, }; -static AnimationInfo sAnimations[] = { { &object_rs_Anim_00788C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f } }; +static AnimationInfo sAnimations[] = { { &gBombShopkeeperSwayAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f } }; void func_80C25D40(EnRsn* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); @@ -44,7 +44,7 @@ void EnRsn_Init(Actor* thisx, GlobalContext* globalCtx) { EnRsn* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rs_Skel_009220, &object_rs_Anim_009120, NULL, NULL, 0); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBombShopkeeperSkel, &gBombShopkeeperWalkAnim, NULL, NULL, 0); this->actor.flags &= ~ACTOR_FLAG_1; func_80C25D40(this); } @@ -67,20 +67,18 @@ void EnRsn_Update(Actor* thisx, GlobalContext* globalCtx) { s32 EnRsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnRsn* this = THIS; - if (limbIndex == 14) { + if (limbIndex == BOMB_SHOPKEEPER_LIMB_RIGHT_HAND) { Matrix_RotateXS(this->unk1D8.y, MTXMODE_APPLY); } return false; } -static Vec3f D_80C26028 = { 0.0f, 0.0f, 0.0f }; - void EnRsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnRsn* this = THIS; - Vec3f sp18 = D_80C26028; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; - if (limbIndex == 14) { - Matrix_MultVec3f(&sp18, &this->actor.focus.pos); + if (limbIndex == BOMB_SHOPKEEPER_LIMB_RIGHT_HAND) { + Matrix_MultVec3f(&zeroVec, &this->actor.focus.pos); } } @@ -89,7 +87,7 @@ void EnRsn_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C5B0(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_rs_Tex_005458)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gBombShopkeeperEyeTex)); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnRsn_OverrideLimbDraw, EnRsn_PostLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.h b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.h index b9a607a1c..926bc6d32 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.h +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.h @@ -9,7 +9,7 @@ typedef void (*EnRsnActionFunc)(struct EnRsn*, GlobalContext*); typedef struct EnRsn { /* 0x000 */ Actor actor; - /* 0x144 */ char unk144[0x4C]; + /* 0x144 */ UNK_TYPE1 unk144[0x4C]; /* 0x190 */ SkelAnime skelAnime; /* 0x1D4 */ EnRsnActionFunc actionFunc; /* 0x1D8 */ Vec3s unk1D8; diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index 08c1a8aaf..a20556a31 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -5,11 +5,8 @@ */ #include "z_en_sob1.h" -#include "objects/object_rs/object_rs.h" -#include "objects/object_zo/object_zo.h" #include "objects/object_mastergolon/object_mastergolon.h" #include "objects/object_masterzoora/object_masterzoora.h" -#include "objects/object_oF1d_map/object_oF1d_map.h" #include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) @@ -53,12 +50,18 @@ void EnSob1_Blink(EnSob1* this); s32 EnSob1_TakeItemOffShelf(EnSob1* this); s32 EnSob1_ReturnItemToShelf(EnSob1* this); -s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); +s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIndex, Vec3f* pos, f32* distSq); + +typedef enum { + /* 0 */ BOMB_SHOPKEEPER_ANIM_WALK, + /* 1 */ BOMB_SHOPKEEPER_ANIM_SIT_AT_COUNTER_START, + /* 2 */ BOMB_SHOPKEEPER_ANIM_SIT_AT_COUNTER_LOOP +} BombShopkeeperAnimation; static AnimationInfoS sAnimationsBombShopkeeper[] = { - { &object_rs_Anim_009120, 2.0f, 0, -1, ANIMMODE_LOOP, 20 }, - { &object_rs_Anim_008268, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_rs_Anim_0087BC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gBombShopkeeperWalkAnim, 2.0f, 0, -1, ANIMMODE_LOOP, 20 }, + { &gBombShopkeeperSitAtCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gBombShopkeeperSitAtCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; const ActorInit En_Sob1_InitVars = { @@ -153,10 +156,10 @@ static Vec3f sPosOffset[] = { { 0.0f, -4.0f, 0.0f }, }; -void EnSob1_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animations, s32 idx) { +void EnSob1_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index) { f32 frameCount; - animations += idx; + animations += index; if (animations->frameCount < 0) { frameCount = Animation_GetLastFrame(animations->animation); } else { @@ -355,20 +358,20 @@ void EnSob1_SpawnShopItems(EnSob1* this, GlobalContext* globalCtx, ShopItem* sho s32 EnSob1_GetObjIndices(EnSob1* this, GlobalContext* globalCtx, s16* objIds) { if (objIds[1] != OBJECT_ID_MAX) { - this->objIndices[1] = Object_GetIndex(&globalCtx->objectCtx, objIds[1]); - if (this->objIndices[1] < 0) { + this->unusedObjIndex = Object_GetIndex(&globalCtx->objectCtx, objIds[1]); + if (this->unusedObjIndex < 0) { return false; } } else { - this->objIndices[1] = -1; + this->unusedObjIndex = -1; } if (objIds[2] != OBJECT_ID_MAX) { - this->objIndices[2] = Object_GetIndex(&globalCtx->objectCtx, objIds[2]); - if (this->objIndices[2] < 0) { + this->shopkeeperAnimObjIndex = Object_GetIndex(&globalCtx->objectCtx, objIds[2]); + if (this->shopkeeperAnimObjIndex < 0) { return false; } } else { - this->objIndices[2] = -1; + this->shopkeeperAnimObjIndex = -1; } return true; } @@ -398,8 +401,8 @@ void EnSob1_Init(Actor* thisx, GlobalContext* globalCtx) { } objIds = sObjectIds[this->shopType]; - this->objIndices[0] = Object_GetIndex(&globalCtx->objectCtx, objIds[0]); - if (this->objIndices[0] < 0) { + this->mainObjIndex = Object_GetIndex(&globalCtx->objectCtx, objIds[0]); + if (this->mainObjIndex < 0) { Actor_MarkForDeath(&this->actor); return; } @@ -423,7 +426,7 @@ void EnSob1_UpdateCursorPos(GlobalContext* globalCtx, EnSob1* this) { f32 xOffset = 0.0f; f32 yOffset = 17.0f; - Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); + Actor_GetScreenPos(globalCtx, &this->items[this->cursorIndex]->actor, &x, &y); this->cursorPos.x = x + xOffset; this->cursorPos.y = y + yOffset; this->cursorPos.z = 1.2f; @@ -464,7 +467,7 @@ s32 EnSob1_TestEndInteraction(EnSob1* this, GlobalContext* globalCtx, Input* inp s32 EnSob1_TestCancelOption(EnSob1* this, GlobalContext* globalCtx, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(globalCtx, this->items[this->cursorIndex]->actor.textId); return true; } return false; @@ -638,7 +641,7 @@ s32 EnSob1_FacingShopkeeperDialogResult(EnSob1* this, GlobalContext* globalCtx) void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { s32 pad[2]; u8 talkState = Message_GetState(&globalCtx->msgCtx); - u8 cursorIdx; + u8 cursorIndex; if (this->cutsceneState == ENSOB1_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -661,9 +664,9 @@ void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { if (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { if (!Message_ShouldAdvance(globalCtx) || !EnSob1_FacingShopkeeperDialogResult(this, globalCtx)) { if (this->stickAccumX > 0) { - cursorIdx = EnSob1_SetCursorIndexFromNeutral(this, 2); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnSob1_SetCursorIndexFromNeutral(this, 2); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; EnSob1_SetupAction(this, EnSob1_LookToShelf); func_8011552C(globalCtx, 6); this->stickRightPrompt.isEnabled = false; @@ -709,17 +712,17 @@ void EnSob1_EndWalk(EnSob1* this, GlobalContext* globalCtx) { s32 pad; f32 distSq; s16 curFrame = this->skelAnime.curFrame / this->skelAnime.playSpeed; - s16 animLastFrame = Animation_GetLastFrame(&object_rs_Anim_009120) / (s16)this->skelAnime.playSpeed; + s16 animLastFrame = Animation_GetLastFrame(&gBombShopkeeperWalkAnim) / (s16)this->skelAnime.playSpeed; Math_SmoothStepToS(&this->actor.world.rot.y, - EnSob1_GetDistSqAndOrient(this->path, this->pathPointsIdx - 1, &this->actor.world.pos, &distSq), - 4, 1000, 1); + EnSob1_GetDistSqAndOrient(this->path, this->waypoint - 1, &this->actor.world.pos, &distSq), 4, + 1000, 1); this->actor.shape.rot.y = this->actor.world.rot.y; Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); if (distSq < 12.0f) { this->actor.speedXZ = 0.0f; if (animLastFrame == curFrame) { - EnSob1_ChangeAnim(&this->skelAnime, sAnimationsBombShopkeeper, 1); + EnSob1_ChangeAnim(&this->skelAnime, sAnimationsBombShopkeeper, BOMB_SHOPKEEPER_ANIM_SIT_AT_COUNTER_START); EnSob1_SetupAction(this, EnSob1_SetupIdle); } } @@ -729,8 +732,8 @@ void EnSob1_EndWalk(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_SetupIdle(EnSob1* this, GlobalContext* globalCtx) { s16 curFrame = this->skelAnime.curFrame; - if (Animation_GetLastFrame(&object_rs_Anim_008268) == curFrame) { - EnSob1_ChangeAnim(&this->skelAnime, sAnimationsBombShopkeeper, 2); + if (Animation_GetLastFrame(&gBombShopkeeperSitAtCounterStartAnim) == curFrame) { + EnSob1_ChangeAnim(&this->skelAnime, sAnimationsBombShopkeeper, BOMB_SHOPKEEPER_ANIM_SIT_AT_COUNTER_LOOP); EnSob1_SetupAction(this, EnSob1_Idle); } EnSob1_Walking(this, globalCtx); @@ -750,13 +753,13 @@ void EnSob1_Walk(EnSob1* this, GlobalContext* globalCtx) { } if (this->path != NULL) { Math_SmoothStepToS(&this->actor.world.rot.y, - EnSob1_GetDistSqAndOrient(this->path, this->pathPointsIdx, &this->actor.world.pos, &distSq), - 4, 1000, 1); + EnSob1_GetDistSqAndOrient(this->path, this->waypoint, &this->actor.world.pos, &distSq), 4, + 1000, 1); this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.speedXZ = 2.0f; if (distSq < SQ(5.0f)) { - this->pathPointsIdx++; - if ((this->path->count - 1) < this->pathPointsIdx) { + this->waypoint++; + if ((this->path->count - 1) < this->waypoint) { this->actor.speedXZ = 0.0f; EnSob1_SetupAction(this, EnSob1_EndWalk); } @@ -842,7 +845,7 @@ void EnSob1_LookToShelf(EnSob1* this, GlobalContext* globalCtx) { this->cutsceneState = ENSOB1_CUTSCENESTATE_PLAYING; EnSob1_UpdateCursorPos(globalCtx, this); EnSob1_SetupAction(this, EnSob1_BrowseShelf); - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(globalCtx, this->items[this->cursorIndex]->actor.textId); } else { ActorCutscene_SetIntentToPlay(this->cutscene); } @@ -850,7 +853,7 @@ void EnSob1_LookToShelf(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_CursorLeftRight(GlobalContext* globalCtx, EnSob1* this) { - u8 curTemp = this->cursorIdx; + u8 curTemp = this->cursorIndex; if (this->stickAccumX < 0) { if (curTemp != 2) { @@ -859,20 +862,20 @@ void EnSob1_CursorLeftRight(GlobalContext* globalCtx, EnSob1* this) { EnSob1_SetupLookToShopkeeperFromShelf(globalCtx, this); } if (this->items[curTemp] != NULL) { - this->cursorIdx = curTemp; + this->cursorIndex = curTemp; } } else if (this->stickAccumX > 0) { if (curTemp != 0) { curTemp--; } if (this->items[curTemp] != NULL) { - this->cursorIdx = curTemp; + this->cursorIndex = curTemp; } } } s32 EnSob1_HasPlayerSelectedItem(GlobalContext* globalCtx, EnSob1* this, Input* input) { - EnGirlA* item = this->items[this->cursorIdx]; + EnGirlA* item = this->items[this->cursorIndex]; if (EnSob1_TestEndInteraction(this, globalCtx, input)) { return true; @@ -880,7 +883,7 @@ s32 EnSob1_HasPlayerSelectedItem(GlobalContext* globalCtx, EnSob1* this, Input* if (EnSob1_TestItemSelected(globalCtx)) { if (!item->isOutOfStock) { this->tmpActionFunc = this->actionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->choiceTextId); + func_80151938(globalCtx, this->items[this->cursorIndex]->choiceTextId); play_sound(NA_SE_SY_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; @@ -897,8 +900,8 @@ s32 EnSob1_HasPlayerSelectedItem(GlobalContext* globalCtx, EnSob1* this, Input* void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); s32 pad; - u8 prevCursorIdx = this->cursorIdx; - u8 cursorIdx; + u8 prevCursorIndex = this->cursorIndex; + u8 cursorIndex; if (!EnSob1_ReturnItemToShelf(this)) { this->delayTimer = 3; @@ -912,9 +915,9 @@ void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { func_8011552C(globalCtx, 6); if (!EnSob1_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(globalCtx))) { EnSob1_CursorLeftRight(globalCtx, this); - cursorIdx = this->cursorIdx; - if (cursorIdx != prevCursorIdx) { - func_80151938(globalCtx, this->items[cursorIdx]->actor.textId); + cursorIndex = this->cursorIndex; + if (cursorIndex != prevCursorIndex) { + func_80151938(globalCtx, this->items[cursorIndex]->actor.textId); play_sound(NA_SE_SY_CURSOR); } } @@ -925,7 +928,7 @@ void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_SetupBuyItemWithFanfare(GlobalContext* globalCtx, EnSob1* this) { Player* player = GET_PLAYER(globalCtx); - Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; player->stateFlags2 &= ~0x20000000; @@ -945,7 +948,7 @@ void EnSob1_SetupCanBuy(GlobalContext* globalCtx, EnSob1* this, u16 textId) { } void EnSob1_HandleCanBuyItem(GlobalContext* globalCtx, EnSob1* this) { - EnGirlA* item = this->items[this->cursorIdx]; + EnGirlA* item = this->items[this->cursorIndex]; EnGirlA* item2; switch (item->canBuyFunc(globalCtx, item)) { @@ -955,7 +958,7 @@ void EnSob1_HandleCanBuyItem(GlobalContext* globalCtx, EnSob1* this) { this->cutsceneState = ENSOB1_CUTSCENESTATE_STOPPED; } func_8019F208(); - item2 = this->items[this->cursorIdx]; + item2 = this->items[this->cursorIndex]; item2->buyFanfareFunc(globalCtx, item2); EnSob1_SetupBuyItemWithFanfare(globalCtx, this); this->drawCursor = 0; @@ -1026,7 +1029,7 @@ void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx) { case 1: func_8019F230(); this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(globalCtx, this->items[this->cursorIndex]->actor.textId); break; } } @@ -1037,7 +1040,7 @@ void EnSob1_CannotBuy(EnSob1* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 5) { if (Message_ShouldAdvance(globalCtx)) { this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(globalCtx, this->items[this->cursorIndex]->actor.textId); } } } @@ -1048,10 +1051,10 @@ void EnSob1_CanBuy(EnSob1* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnSob1_ResetItemPosition(this); - item = this->items[this->cursorIdx]; + item = this->items[this->cursorIndex]; item->restockFunc(globalCtx, item); this->actionFunc = this->tmpActionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(globalCtx, this->items[this->cursorIndex]->actor.textId); } } @@ -1060,7 +1063,7 @@ void EnSob1_BuyItemWithFanfare(EnSob1* this, GlobalContext* globalCtx) { this->actor.parent = NULL; EnSob1_SetupAction(this, EnSob1_SetupItemPurchased); } else { - Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIdx]->getItemId, 300.0f, 300.0f); + Actor_PickUp(&this->actor, globalCtx, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); } } @@ -1086,7 +1089,7 @@ void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { EnSob1_ResetItemPosition(this); - item = this->items[this->cursorIdx]; + item = this->items[this->cursorIndex]; item->restockFunc(globalCtx, item); player->actor.shape.rot.y += 0x8000; player->stateFlags2 |= 0x20000000; @@ -1098,7 +1101,7 @@ void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_PositionSelectedItem(EnSob1* this) { Vec3f selectedItemPosition = sSelectedItemPositions[this->shopType]; - u8 i = this->cursorIdx; + u8 i = this->cursorIndex; EnGirlA* item; ShopItem* shopItem = &sShops[this->shopType][i]; Vec3f worldPos; @@ -1159,7 +1162,7 @@ void EnSob1_UpdateItemSelectedProperty(EnSob1* this) { this->drawCursor == 0) { item->isSelected = false; } else { - item->isSelected = this->cursorIdx == i ? true : false; + item->isSelected = this->cursorIndex == i ? true : false; } } } @@ -1247,14 +1250,14 @@ void EnSob1_UpdateStickDirectionPromptAnim(EnSob1* this) { this->stickLeftPrompt.stickTexY = 95.0f; } -s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq) { +s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIndex, Vec3f* pos, f32* distSq) { Vec3s* points; f32 diffX; f32 diffZ; if (path != NULL) { points = Lib_SegmentedToVirtual(path->points); - points = &points[pointIdx]; + points = &points[pointIndex]; diffX = points->x - pos->x; diffZ = points->z - pos->z; } else { @@ -1283,33 +1286,34 @@ void EnSob1_WaitForBlink(EnSob1* this) { void EnSob1_Blink(EnSob1* this) { s16 decr = this->blinkTimer - 1; - s16 eyeTextureIdxTemp; + s16 eyeTextureIndexTemp; if (decr != 0) { this->blinkTimer = decr; return; } - eyeTextureIdxTemp = this->eyeTexIndex + 1; - if (eyeTextureIdxTemp > 2) { + eyeTextureIndexTemp = this->eyeTexIndex + 1; + if (eyeTextureIndexTemp > 2) { this->eyeTexIndex = 0; this->blinkTimer = (s32)(Rand_ZeroOne() * 60.0f) + 20; this->blinkFunc = EnSob1_WaitForBlink; } else { - this->eyeTexIndex = eyeTextureIdxTemp; + this->eyeTexIndex = eyeTextureIndexTemp; this->blinkTimer = 1; } } void EnSob1_ChangeObject(EnSob1* this, GlobalContext* globalCtx) { - gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->shopkeeperAnimObjIndex].segment); } s32 EnSob1_AreObjectsLoaded(EnSob1* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndices[0])) { - if (this->objIndices[1] >= 0 && !Object_IsLoaded(&globalCtx->objectCtx, this->objIndices[1])) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->mainObjIndex)) { + if (this->unusedObjIndex >= 0 && !Object_IsLoaded(&globalCtx->objectCtx, this->unusedObjIndex)) { return false; } - if (this->objIndices[2] >= 0 && !Object_IsLoaded(&globalCtx->objectCtx, this->objIndices[2])) { + if (this->shopkeeperAnimObjIndex >= 0 && + !Object_IsLoaded(&globalCtx->objectCtx, this->shopkeeperAnimObjIndex)) { return false; } return true; @@ -1318,27 +1322,28 @@ s32 EnSob1_AreObjectsLoaded(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_ZoraShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, 20); - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); - Animation_Change(&this->skelAnime, &object_masterzoora_Anim_00078C, 1.0f, 0.0f, - Animation_GetLastFrame(&object_masterzoora_Anim_00078C), 0, 0.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, + ZORA_LIMB_MAX); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->shopkeeperAnimObjIndex].segment); + Animation_Change(&this->skelAnime, &gZoraShopkeeperAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gZoraShopkeeperAnim), + ANIMMODE_LOOP, 0.0f); this->actor.draw = EnSob1_ZoraShopkeeper_Draw; this->changeObjectFunc = EnSob1_ChangeObject; } void EnSob1_GoronShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, - this->morphTable, 18); - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); - Animation_Change(&this->skelAnime, &object_mastergolon_Anim_0000FC, 1.0f, 0.0f, - Animation_GetLastFrame(&object_mastergolon_Anim_0000FC), 0, 0.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronSkel, NULL, this->jointTable, this->morphTable, + GORON_LIMB_MAX); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->shopkeeperAnimObjIndex].segment); + Animation_Change(&this->skelAnime, &gGoronShopkeeperAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gGoronShopkeeperAnim), + ANIMMODE_LOOP, 0.0f); this->actor.draw = EnSob1_GoronShopkeeper_Draw; this->changeObjectFunc = EnSob1_ChangeObject; } void EnSob1_BombShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rs_Skel_009220, &object_rs_Anim_009120, this->jointTable, - this->morphTable, 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBombShopkeeperSkel, &gBombShopkeeperWalkAnim, this->jointTable, + this->morphTable, BOMB_SHOPKEEPER_LIMB_MAX); this->actor.draw = EnSob1_BombShopkeeper_Draw; this->changeObjectFunc = NULL; this->skelAnime.playSpeed = 2.0f; @@ -1351,7 +1356,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { if (EnSob1_AreObjectsLoaded(this, globalCtx)) { this->actor.flags &= ~ACTOR_FLAG_10; - this->actor.objBankIndex = this->objIndices[0]; + this->actor.objBankIndex = this->mainObjIndex; Actor_SetObjectDependency(globalCtx, &this->actor); posOffset = &sPosOffset[this->shopType]; this->actor.world.pos.x += posOffset->x; @@ -1370,7 +1375,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.colChkInfo.cylRadius = 50; this->wasTalkedToWhileWalking = false; - this->pathPointsIdx = 0; + this->waypoint = 0; if (this->shopType == BOMB_SHOP) { this->path = SubS_GetPathByIndex(globalCtx, ENSOB1_GET_PATH(&this->actor), 0x1F); @@ -1385,7 +1390,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { this->stickAccumY = 0; this->stickAccumX = 0; - this->cursorIdx = 0; + this->cursorIndex = 0; this->cursorPos.z = 1.2f; this->cursorColor.r = 0; this->cursorColor.g = 80; @@ -1575,7 +1580,7 @@ s32 EnSob1_ZoraShopkeeper_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbInd Actor* thisx) { EnSob1* this = THIS; - if (limbIndex == 15) { + if (limbIndex == ZORA_LIMB_HEAD) { rot->x += this->headRot; } return false; @@ -1585,7 +1590,7 @@ s32 EnSob1_BombShopkeeper_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbInd Actor* thisx) { EnSob1* this = THIS; - if (limbIndex == 15) { + if (limbIndex == BOMB_SHOPKEEPER_LIMB_HEAD) { Matrix_RotateXS(this->headRot, MTXMODE_APPLY); } return false; @@ -1594,8 +1599,8 @@ s32 EnSob1_BombShopkeeper_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbInd void EnSob1_BombShopkeeper_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { OPEN_DISPS(globalCtx->state.gfxCtx); - if (limbIndex == 11) { - gSPDisplayList(POLY_OPA_DISP++, object_rs_DL_000970); + if (limbIndex == BOMB_SHOPKEEPER_LIMB_LEFT_HAND) { + gSPDisplayList(POLY_OPA_DISP++, gBombShopkeeperBombDL); } CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1634,8 +1639,7 @@ void EnSob1_ZoraShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { } void EnSob1_GoronShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr sGoronShopkeeperEyeTextures[] = { object_oF1d_map_Tex_010438, object_oF1d_map_Tex_010C38, - object_oF1d_map_Tex_011038 }; + static TexturePtr sGoronShopkeeperEyeTextures[] = { gGoronEyeOpenTex, gGoronEyeHalfTex, gGoronEyeClosedTex }; EnSob1* this = THIS; s32 pad; s32 i; @@ -1663,7 +1667,7 @@ void EnSob1_BombShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_rs_Tex_005458)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gBombShopkeeperEyeTex)); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnSob1_BombShopkeeper_OverrideLimbDraw, EnSob1_BombShopkeeper_PostLimbDraw, &this->actor); for (i = 0; i < ARRAY_COUNT(this->items); i++) { diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h index c1dfd3849..a854d4c3f 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.h @@ -3,6 +3,11 @@ #include "global.h" #include "overlays/actors/ovl_En_GirlA/z_en_girla.h" +#include "objects/object_rs/object_rs.h" +#include "objects/object_zo/object_zo.h" +#include "objects/object_oF1d_map/object_oF1d_map.h" + +#define ENSOB1_LIMB_MAX MAX(MAX((s32)ZORA_LIMB_MAX, (s32)BOMB_SHOPKEEPER_LIMB_MAX), (s32)GORON_LIMB_MAX) struct EnSob1; @@ -27,13 +32,15 @@ typedef struct EnSob1 { /* 0x190 */ EnSob1ActionFunc changeObjectFunc; /* 0x194 */ ColliderCylinder collider; /* 0x1E0 */ Path* path; - /* 0x1E4 */ s32 pathPointsIdx; + /* 0x1E4 */ s32 waypoint; /* 0x1E8 */ s16 delayTimer; - /* 0x1EA */ s8 objIndices[3]; + /* 0x1EA */ s8 mainObjIndex; + /* 0x1EB */ s8 unusedObjIndex; + /* 0x1EC */ s8 shopkeeperAnimObjIndex; /* 0x1EE */ s16 headRot; /* 0x1F0 */ s16 headRotTarget; - /* 0x1F2 */ Vec3s jointTable[20]; - /* 0x26A */ Vec3s morphTable[20]; + /* 0x1F2 */ Vec3s jointTable[ENSOB1_LIMB_MAX]; + /* 0x26A */ Vec3s morphTable[ENSOB1_LIMB_MAX]; /* 0x2E2 */ s16 eyeTexIndex; /* 0x2E4 */ s16 blinkTimer; /* 0x2E8 */ EnSob1BlinkFunc blinkFunc; @@ -45,7 +52,7 @@ typedef struct EnSob1 { /* 0x31C */ f32 cursorAnimTween; /* 0x320 */ u8 cursorAnimState; /* 0x321 */ u8 drawCursor; - /* 0x322 */ u8 cursorIdx; + /* 0x322 */ u8 cursorIndex; /* 0x324 */ StickDirectionPrompt stickLeftPrompt; /* 0x35C */ StickDirectionPrompt stickRightPrompt; /* 0x394 */ f32 arrowAnimTween; diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 2c5f76f2e..28c493497 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -5,7 +5,6 @@ */ #include "z_en_zo.h" -#include "objects/object_zo/object_zo.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) @@ -257,7 +256,8 @@ void EnZo_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, 20); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, + ZORA_LIMB_MAX); EnZo_SetAnimation(&this->skelAnime, 0); Collider_InitCylinder(globalCtx, &this->collider); @@ -291,19 +291,20 @@ s32 EnZo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Gfx** gfx) { EnZo* this = THIS; - if (limbIndex == 15) { + if (limbIndex == ZORA_LIMB_HEAD) { 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); } - if (limbIndex == 8) { + if (limbIndex == ZORA_LIMB_TORSO) { Matrix_RotateXS(-this->upperBodyRot.y, MTXMODE_APPLY); Matrix_RotateZS(-this->upperBodyRot.x, MTXMODE_APPLY); } - if ((limbIndex == 8) || (limbIndex == 9) || (limbIndex == 12)) { + if ((limbIndex == ZORA_LIMB_TORSO) || (limbIndex == ZORA_LIMB_LEFT_UPPER_ARM) || + (limbIndex == ZORA_LIMB_RIGHT_UPPER_ARM)) { rot->y += (s16)(Math_SinS(this->limbRotY[limbIndex]) * 200.0f); rot->z += (s16)(Math_CosS(this->limbRotZ[limbIndex]) * 200.0f); } @@ -318,13 +319,13 @@ void EnZo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (sBodyParts[limbIndex] >= 0) { Matrix_MultVec3f(&zeroVec, &this->bodyPartsPos[sBodyParts[limbIndex]]); } - if (limbIndex == 15) { + if (limbIndex == ZORA_LIMB_HEAD) { Matrix_MultVec3f(&sp30, &this->actor.focus.pos); } - if (limbIndex == 4) { + if (limbIndex == ZORA_LIMB_LEFT_FOOT) { Matrix_MultVec3f(&zeroVec, &this->leftFootPos); } - if (limbIndex == 7) { + if (limbIndex == ZORA_LIMB_RIGHT_FOOT) { Matrix_MultVec3f(&zeroVec, &this->rightFootPos); } } diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.h b/src/overlays/actors/ovl_En_Zo/z_en_zo.h index b5faef776..adf8b6bae 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.h +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.h @@ -2,6 +2,7 @@ #define Z_EN_ZO_H #include "global.h" +#include "objects/object_zo/object_zo.h" struct EnZo; @@ -22,8 +23,8 @@ typedef struct EnZo { /* 0x01F0 */ Vec3f rightFootPos; /* 0x01FC */ u8 isLeftFootGrounded; /* 0x01FD */ u8 isRightFootGrounded; - /* 0x01FE */ Vec3s jointTable[20]; - /* 0x0276 */ Vec3s morphTable[20]; + /* 0x01FE */ Vec3s jointTable[ZORA_LIMB_MAX]; + /* 0x0276 */ Vec3s morphTable[ZORA_LIMB_MAX]; /* 0x02EE */ Vec3s turnTarget; /* 0x02F4 */ Vec3s headRot; /* 0x02FA */ Vec3s upperBodyRot; diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index 1cf8ad992..69deb43d6 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -87,7 +87,7 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_80B97100; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, &gZoraIdleAnim, this->jointTable, this->morphTable, 20); - Animation_PlayLoop(&this->skelAnime, &object_zo_Anim_00DE20); + Animation_PlayLoop(&this->skelAnime, &gZoraStandAnim); this->unk_2F0 = 0; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -235,9 +235,9 @@ void EnZot_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80B96BEC(EnZot* this, s16 arg1, u8 arg2) { static AnimationHeader* sAnimations[] = { - &object_zo_Anim_00DE20, &gZoraWalkAnim, &object_zo_Anim_00F4E8, &object_zo_Anim_00E400, - &object_zo_Anim_00FDF0, &object_zo_Anim_010B18, &object_zo_Anim_011424, &object_zo_Anim_00EDF0, - &object_zo_Anim_00DF54, &object_zo_Anim_00DF54, + &gZoraStandAnim, &gZoraWalkAnim, &gZoraSitAnim, &gZoraRunAnim, + &gZoraFixSpeakerStartAnim, &gZoraFixSpeakerLoopAnim, &gZoraFixSpeakerEndAnim, &gZoraBobHandAnim, + &gZoraListenAnim, &gZoraListenAnim, }; if ((arg1 >= 0) && (arg1 < 10)) { diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.c b/src/overlays/actors/ovl_En_Zow/z_en_zow.c index 2f1b4a1a4..c0751b078 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -188,7 +188,7 @@ void func_80BDC830(EnZowStruct* ptr, GlobalContext* globalCtx) { if (ptr->unk_00 == 1) { if (!flag) { gDPPipeSync(POLY_XLU_DISP++); - gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_00D220); + gSPDisplayList(POLY_XLU_DISP++, gZoraRippleMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 155, 0); if (1) {} flag = true; @@ -201,7 +201,7 @@ void func_80BDC830(EnZowStruct* ptr, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_00D288); + gSPDisplayList(POLY_XLU_DISP++, gZoraRippleModelDL); } } @@ -219,7 +219,7 @@ void func_80BDC9DC(EnZowStruct* ptr, GlobalContext* globalCtx) { for (i = 0; i < 15; i++, ptr++) { if (ptr->unk_00 == 3) { if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_0029F0); + gSPDisplayList(POLY_XLU_DISP++, gZoraBubbleMaterialDL); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 150, 150, 150, 0); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); @@ -233,7 +233,7 @@ void func_80BDC9DC(EnZowStruct* ptr, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_002A50); + gSPDisplayList(POLY_XLU_DISP++, gZoraBubbleModelDL); } } @@ -251,7 +251,7 @@ void func_80BDCB84(EnZowStruct* ptr, GlobalContext* globalCtx) { for (i = 0; i < 15; i++, ptr++) { if (ptr->unk_00 == 2) { if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_002BA0); + gSPDisplayList(POLY_XLU_DISP++, gZoraSplashMaterialDL); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, 0); if (1) {} @@ -266,7 +266,7 @@ void func_80BDCB84(EnZowStruct* ptr, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_002C10); + gSPDisplayList(POLY_XLU_DISP++, gZoraSplashModelDL); } } @@ -333,7 +333,7 @@ void EnZow_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } -static AnimationHeader* sAnimations[] = { &object_zo_Anim_004168, &gZoraSurfacingAnim, &gZoraSurfacingAnim }; +static AnimationHeader* sAnimations[] = { &gZoraTreadingWaterAnim, &gZoraSurfacingAnim, &gZoraSurfacingAnim }; void func_80BDD04C(EnZow* this, s16 arg1, u8 arg2) { if ((arg1 >= 0) && (arg1 < 3)) { diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index 2f976f2cc..e81799873 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -721,7 +721,7 @@ void func_808DDE9C(Actor* thisx, GlobalContext* globalCtx2) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_030100); + gSPDisplayList(POLY_XLU_DISP++, gEffShockwaveDL); } } From af0123de1eb774aebb88b26e5d719b3406f51eb9 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis Date: Sun, 19 Jun 2022 03:38:10 +0100 Subject: [PATCH 237/257] `z_fcurve_data` OK, match last function in `z_fcurve_data_skelanime`, document SkelCurve system (#776) * Match SkelCurve_Update Co-authored-by: Kelebek1 <34639600+Kelebek1@users.noreply.github.com> * Match and document z_fcurve_data * Begin documenting SkelCurve * More documentation * Deformat header * Pluralise knotCount * Sort out jointTable * Rename frameCount * Format * More documentation * Cleanup on DemoEffect * Remove space on typedef * Format, couple of fixes in the header * Review * Oops * Fix EnBox, DemoTreLgt, use macros in EnTorch Co-authored-by: Kelebek1 <34639600+Kelebek1@users.noreply.github.com> --- include/functions.h | 8 - include/os_internal.h | 2 +- include/z64.h | 1 + include/z64animation.h | 50 ---- include/z64curve.h | 68 +++++ include/z64item.h | 6 +- include/z64math.h | 18 +- src/code/z_fcurve_data.c | 85 ++++++- src/code/z_fcurve_data_skelanime.c | 239 +++++++++++------- src/code/z_skelanime.c | 4 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 18 +- .../actors/ovl_Demo_Effect/z_demo_effect.c | 197 ++++++++------- .../actors/ovl_Demo_Effect/z_demo_effect.h | 31 ++- .../actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c | 13 +- .../actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h | 8 +- src/overlays/actors/ovl_En_Box/z_en_box.c | 57 +++-- src/overlays/actors/ovl_En_Box/z_en_box.h | 11 +- src/overlays/actors/ovl_En_Torch/z_en_torch.c | 7 +- tools/disasm/functions.txt | 4 +- tools/disasm/variables.txt | 5 +- 20 files changed, 505 insertions(+), 327 deletions(-) create mode 100644 include/z64curve.h diff --git a/include/functions.h b/include/functions.h index b60aa04fa..b802ee28a 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1454,14 +1454,6 @@ s16 ActorCutscene_GetCurrentCamera(s16 index); s16 func_800F21CC(void); s32 func_800F22C4(s16 param_1, Actor* actor); void ActorCutscene_SetReturnCamera(s16 index); -// void func_800F23E0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -f32 func_800F2478(f32 target, TransformData* transData, s32 refIdx); -void SkelCurve_Clear(SkelAnimeCurve* skelCurve); -s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, TransformUpdateIndex* transUpdIdx); -void SkelCurve_Destroy(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve); -void SkelCurve_SetAnim(SkelAnimeCurve* skelCurve, TransformUpdateIndex* transUpdIdx, f32 arg2, f32 animFinalFrame, f32 animCurFrame, f32 animSpeed); -s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve); -void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx); void FireObj_SetPosition(FireObj* fire, Vec3f* pos); void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire); void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init, Actor* actor); diff --git a/include/os_internal.h b/include/os_internal.h index 3c6d4eee4..b4f98bffa 100644 --- a/include/os_internal.h +++ b/include/os_internal.h @@ -1,7 +1,7 @@ #ifndef _OS_INTERNAL_H_ #define _OS_INTERNAL_H_ -typedef struct { +typedef struct { /* 0x00 */ OSMesgQueue* queue; /* 0x04 */ OSMesg msg; } __osHwInt; // size = 0x08 diff --git a/include/z64.h b/include/z64.h index a0119f2f8..6331a456a 100644 --- a/include/z64.h +++ b/include/z64.h @@ -30,6 +30,7 @@ #include "z64audio.h" #include "z64bgcheck.h" #include "z64collision_check.h" +#include "z64curve.h" #include "z64cutscene.h" #include "z64dma.h" #include "z64effect.h" diff --git a/include/z64animation.h b/include/z64animation.h index 58ddb34df..ced59e457 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -224,56 +224,6 @@ typedef void (*AnimationEntryCallback)(struct GlobalContext*, AnimationEntryData extern u32 link_animetion_segment; -// fcurve_skelanime structs -typedef struct { - /* 0x0000 */ u16 unk00; // appears to be flags - /* 0x0002 */ s16 unk02; - /* 0x0004 */ s16 unk04; - /* 0x0006 */ s16 unk06; - /* 0x0008 */ f32 unk08; -} TransformData; // size = 0xC - -typedef struct { - /* 0x0000 */ u8* refIndex; - /* 0x0004 */ TransformData* transformData; - /* 0x0008 */ s16* copyValues; - /* 0x000C */ s16 unk0C; - /* 0x000E */ s16 unk10; -} TransformUpdateIndex; // size 0x10 - -typedef struct { - /* 0x0000 */ u8 firstChildIdx; - /* 0x0001 */ u8 nextLimbIdx; - /* 0x0004 */ Gfx* dList[2]; -} SkelCurveLimb; // size >= 0x8 - -typedef struct { - /* 0x0000 */ SkelCurveLimb** limbs; - /* 0x0004 */ u8 limbCount; -} SkelCurveLimbList; // size = 0x8 - -typedef struct { - /* 0x0000 */ Vec3s scale; - /* 0x0006 */ Vec3s rot; - /* 0x000C */ Vec3s pos; -} LimbTransform; // size = 0x12 - -typedef struct { - /* 0x0000 */ u8 limbCount; - /* 0x0004 */ SkelCurveLimb** limbList; - /* 0x0008 */ TransformUpdateIndex* transUpdIdx; - /* 0x000C */ f32 unk0C; // seems to be unused - /* 0x0010 */ f32 animFinalFrame; - /* 0x0014 */ f32 animSpeed; - /* 0x0018 */ f32 animCurFrame; - /* 0x001C */ LimbTransform* transforms; -} SkelAnimeCurve; // size = 0x20 - -typedef s32 (*OverrideCurveLimbDraw)(struct GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, - struct Actor* actor); -typedef void (*PostCurveLimbDraw)(struct GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, - struct Actor* actor); - typedef struct { /* 0x00 */ AnimationHeader* animation; /* 0x04 */ f32 playSpeed; diff --git a/include/z64curve.h b/include/z64curve.h new file mode 100644 index 000000000..2e6e539ba --- /dev/null +++ b/include/z64curve.h @@ -0,0 +1,68 @@ +#ifndef Z64_CURVE_H +#define Z64_CURVE_H + +#include "PR/ultratypes.h" +#include "z64math.h" + +struct GlobalContext; + +typedef struct { + /* 0x0 */ u16 flags; // Only the bottom two bits are used, although others are set in objects + /* 0x2 */ s16 abscissa; // knot input value + /* 0x4 */ s16 leftGradient; // left derivative at the point + /* 0x6 */ s16 rightGradient; // right derivative at the point + /* 0x8 */ f32 ordinate; // output value +} CurveInterpKnot; // size = 0xC + +typedef struct { + /* 0x0 */ u8* knotCounts; + /* 0x4 */ CurveInterpKnot* interpolationData; + /* 0x8 */ s16* constantData; + /* 0xC */ s16 unk_0C; // Set but not used, always 1 in objects + /* 0xE */ s16 frameCount; // Not used, inferred from use in objects +} CurveAnimationHeader; // size = 0x10 + +typedef struct { + /* 0x0 */ u8 child; + /* 0x1 */ u8 sibling; + /* 0x4 */ Gfx* dList[2]; +} SkelCurveLimb; // size = 0xC + +typedef struct { + /* 0x0 */ SkelCurveLimb** limbs; + /* 0x4 */ u8 limbCount; +} CurveSkeletonHeader; // size = 0x8 + +typedef struct { + /* 0x00 */ u8 limbCount; + /* 0x04 */ SkelCurveLimb** skeleton; + /* 0x08 */ CurveAnimationHeader* animation; + /* 0x0C */ f32 unk_0C; // set but not used + /* 0x10 */ f32 endFrame; + /* 0x14 */ f32 playSpeed; + /* 0x18 */ f32 curFrame; + /* 0x1C */ s16 (*jointTable)[9]; +} SkelCurve; // size = 0x20 + +typedef s32 (*OverrideCurveLimbDraw)(struct GlobalContext* globalCtx, SkelCurve* skelCuve, s32 limbIndex, struct Actor* actor); +typedef void (*PostCurveLimbDraw)(struct GlobalContext* globalCtx, SkelCurve* skelCuve, s32 limbIndex, struct Actor* actor); + + + +f32 Curve_Interpolate(f32 x, CurveInterpKnot* knots, s32 knotCount); + +void SkelCurve_Clear(SkelCurve* skelCurve); +s32 SkelCurve_Init(struct GlobalContext* globalCtx, SkelCurve* skelCurve, CurveSkeletonHeader* skeletonHeaderSeg, CurveAnimationHeader* animation); +void SkelCurve_Destroy(struct GlobalContext* globalCtx, SkelCurve* skelCurve); +void SkelCurve_SetAnim(SkelCurve* skelCurve, CurveAnimationHeader* animation, f32 arg2, f32 endFrame, f32 curFrame, f32 playSpeed); +s32 SkelCurve_Update(struct GlobalContext* globalCtx, SkelCurve* skelCurve); +void SkelCurve_Draw(Actor* actor, struct GlobalContext* globalCtx, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx); + + +// ZAPD compatibility typedefs +// TODO: Remove when ZAPD adds support for them +typedef CurveInterpKnot TransformData; +typedef CurveAnimationHeader TransformUpdateIndex; +typedef CurveSkeletonHeader SkelCurveLimbList; + +#endif // Z64_CURVE_H diff --git a/include/z64item.h b/include/z64item.h index 2281ded92..81fdbe066 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -280,7 +280,9 @@ typedef enum { /* 0x0C */ GI_HEART_PIECE = 0x0C, /* 0x0D */ GI_HEART_CONTAINER, /* 0x11 */ GI_STRAY_FAIRY = 0x11, - /* 0x16 */ GI_BOMBS_10 = 0x16, + /* 0x14 */ GI_BOMBS_1 = 0x14, + /* 0x15 */ GI_BOMBS_5, + /* 0x16 */ GI_BOMBS_10, /* 0x19 */ GI_STICKS_1 = 0x19, /* 0x1A */ GI_BOMBCHUS_10, /* 0x1B */ GI_BOMB_BAG_20, @@ -298,6 +300,8 @@ typedef enum { /* 0x32 */ GI_SHIELD_HERO = 0x32, /* 0x33 */ GI_SHIELD_MIRROR, /* 0x35 */ GI_MAGIC_BEANS = 0x35, + /* 0x36 */ GI_BOMBCHUS_1, + /* 0x3A */ GI_BOMBCHUS_5 = 0x3A, /* 0x3C */ GI_KEY_SMALL = 0x3C, /* 0x3D */ GI_KEY_BOSS, /* 0x3E */ GI_MAP, diff --git a/include/z64math.h b/include/z64math.h index 33f05bb0a..0095e12ab 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -109,17 +109,19 @@ typedef struct { #define IS_ZERO(f) (fabsf(f) < 0.008f) -// Trig macros -#define DEGF_TO_BINANG(degreesf) (s16)(degreesf * 182.04167f + .5f) -#define RADF_TO_BINANG(radf) (s16)(radf * (0x8000 / M_PI)) -#define RADF_TO_DEGF(radf) (radf * (180.0f / M_PI)) -#define DEGF_TO_RADF(degf) (degf * (M_PI / 180.0f)) +// Angle conversion macros +#define DEG_TO_BINANG(degrees) (s16)((degrees) * (0x8000 / 180.0f)) +#define DEGF_TO_BINANG(degreesf) (s16)((degreesf) * 182.04167f + .5f) +#define RADF_TO_BINANG(radf) (s16)((radf) * (0x8000 / M_PI)) +#define RADF_TO_DEGF(radf) ((radf) * (180.0f / M_PI)) +#define DEGF_TO_RADF(degf) ((degf) * (M_PI / 180.0f)) +#define BINANG_TO_DEGF(binang) ((f32)binang * (360.0001525f / 65535.0f)) +#define BINANG_TO_RAD(binang) (((f32)binang / 0x8000) * M_PI) + +// Angle arithmetic macros #define BINANG_ROT180(angle) ((s16)(angle + 0x8000)) #define BINANG_SUB(a, b) ((s16)(a - b)) #define BINANG_ADD(a, b) ((s16)(a + b)) -#define DEG_TO_RAD(degrees) ((degrees) * (M_PI / 180.0f)) -#define BINANG_TO_DEGF(binang) ((f32)binang * (360.0001525f / 65535.0f)) -#define BINANG_TO_RAD(binang) (((f32)binang / 0x8000) * M_PI) // Vector macros #define SQXZ(vec) ((vec.x) * (vec.x) + (vec.z) * (vec.z)) diff --git a/src/code/z_fcurve_data.c b/src/code/z_fcurve_data.c index a0bf887e1..5c0aa066a 100644 --- a/src/code/z_fcurve_data.c +++ b/src/code/z_fcurve_data.c @@ -1,5 +1,86 @@ +/** + * @file z_fcurve_data.c + * @brief Interpolation functions for use with Curve SkelAnime + */ #include "global.h" +#include "z64curve.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data/func_800F23E0.s") +#define FCURVE_INTERP_CUBIC 0 // Interpolate using a Hermite cubic spline +#define FCURVE_INTERP_NONE 1 // Return the value at the left endpoint instead of interpolating +#define FCURVE_INTERP_LINEAR 2 // Interpolate linearly -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data/func_800F2478.s") +/** + * Hermite cubic spline interpolation between two endpoints, a,b. More information available at + * https://en.wikipedia.org/wiki/Cubic_Hermite_spline + * + * @param t interpolation parameter rescaled to lie in [0,1], (x-a)/(b-a) + * @param interval distance (b-a) between the endpoints + * @param y0 p(a) + * @param y1 p(b) + * @param m0 p'(a) + * @param m1 p'(b) + * @return f32 p(t), value of the cubic interpolating polynomial + */ +f32 Curve_CubicHermiteSpline(f32 t, f32 interval, f32 y0, f32 y1, f32 m0, f32 m1) { + f32 t2 = t * t; + f32 t3 = t2 * t; + f32 t3x2 = t3 * 2.0f; + f32 t2x3 = t2 * 3.0f; + + // Hermite basis cubics h_{ij} satisfy h_{ij}^{(j)}(i) = 1, the other three values being 0 + f32 h00 = t3x2 - t2x3 + 1.0f; // h_{00}(t) = 2t^3 - 3t^2 + 1 + f32 h01 = t2x3 - t3x2; // h_{01}(t) = 3t^2 - 2t^3 + f32 h10 = t3 - t2 * 2.0f + t; // h_{10}(t) = t^3 - 2t^2 + t + f32 h11 = t3 - t2; // h_{11}(t) = t^3 - t^2 + + f32 ret = h00 * y0; + + ret += h01 * y1; + ret += h10 * m0 * interval; + ret += h11 * m1 * interval; + + return ret; +} + +/** + * Interpolates based on an array of CurveInterpKnot. + * + * @param x point at which to interpolate. + * @param knots Beginning of CurveInterpKnot array to use. + * @param knotCount number of knots to read from the array. + * @return f32 interpolated value + */ +f32 Curve_Interpolate(f32 x, CurveInterpKnot* knots, s32 knotCount) { + // If outside the entire interpolation interval, return the value at the near endpoint. + if (x <= knots[0].abscissa) { + return knots[0].ordinate; + } else if (x >= knots[knotCount - 1].abscissa) { + return knots[knotCount - 1].ordinate; + } else { + s32 cur; + + for (cur = 0;; cur++) { + s32 next = cur + 1; + + // Find the subinterval in which x lies + if (x < knots[next].abscissa) { + if (knots[cur].flags & FCURVE_INTERP_NONE) { + // No interpolation + return knots[cur].ordinate; + } else if (knots[cur].flags & FCURVE_INTERP_LINEAR) { + // Linear interpolation + return knots[cur].ordinate + + ((x - (f32)knots[cur].abscissa) / ((f32)knots[next].abscissa - (f32)knots[cur].abscissa)) * + (knots[next].ordinate - knots[cur].ordinate); + } else { + // Cubic interpolation + f32 diff = (f32)knots[next].abscissa - (f32)knots[cur].abscissa; + f32 t = (x - (f32)knots[cur].abscissa) / ((f32)knots[next].abscissa - (f32)knots[cur].abscissa); + + return Curve_CubicHermiteSpline(t, diff * (1.0f / 30.0f), knots[cur].ordinate, knots[next].ordinate, + knots[cur].rightGradient, knots[next].leftGradient); + } + } + } + } +} diff --git a/src/code/z_fcurve_data_skelanime.c b/src/code/z_fcurve_data_skelanime.c index c8eb927fa..b40a1c351 100644 --- a/src/code/z_fcurve_data_skelanime.c +++ b/src/code/z_fcurve_data_skelanime.c @@ -1,130 +1,187 @@ +/** + * @file z_fcurve_data_skelanime.c + * @brief Curve skeleton animation system + * + * A curve skeleton has a fixed number of limbs, each of which has 9 properties that may be changed by the animation: + * - 3 scales, + * - 3 rotations, + * - 3 positions + * (note the position is stored in the animations instead of being stored in the limbs like SkelAnime would). Otherwise + * the structure is similar to an ordinary SkelAnime-compatible skeleton. + * + * The animations are significantly more complex than SkelAnime. A curve animation consists of 4 parts: + * - a header (CurveAnimationHeader) + * - a list of counts, one for each of the 9 properties of each limb (u8) + * - a list of interpolation data (CurveInterpKnot). The length is the sum of the counts. + * - a list of constant data (s16[9]). The length is the number of 0s in counts. + * + * If the interpolation count for a property is 0, the value of the property is copied from the next number in the + * constant data; there are no gaps for nonzero interpolation count. + * If the interpolation count N for a property is larger than 0, the next N elements of the interpolation data array + * are used to interpolate the value of the property, using Curve_Interpolate. + * + * Curve limbs may use LOD: + * - lower detail draws only the first displaylist + * - higher detail draws both. + */ + #include "global.h" +#include "z64curve.h" -void SkelCurve_Clear(SkelAnimeCurve* skelCurve) { +void SkelCurve_Clear(SkelCurve* skelCurve) { skelCurve->limbCount = 0; - skelCurve->limbList = NULL; - skelCurve->transUpdIdx = NULL; - skelCurve->animCurFrame = 0.0f; - skelCurve->animSpeed = 0.0f; - skelCurve->animFinalFrame = 0.0f; - skelCurve->unk0C = 0.0f; - skelCurve->transforms = NULL; + skelCurve->skeleton = NULL; + skelCurve->animation = NULL; + skelCurve->curFrame = 0.0f; + skelCurve->playSpeed = 0.0f; + skelCurve->endFrame = 0.0f; + skelCurve->unk_0C = 0.0f; + skelCurve->jointTable = NULL; } -s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, - TransformUpdateIndex* transUpdIdx) { +/** + * Initialises the SkelCurve struct and mallocs the joint table. + * + * @return bool always true + */ +s32 SkelCurve_Init(GlobalContext* globalCtx, SkelCurve* skelCurve, CurveSkeletonHeader* skeletonHeaderSeg, + CurveAnimationHeader* animation) { SkelCurveLimb** limbs; - SkelCurveLimbList* limbList = Lib_SegmentedToVirtual(limbListSeg); + CurveSkeletonHeader* skeletonHeader = Lib_SegmentedToVirtual(skeletonHeaderSeg); - skelCurve->limbCount = limbList->limbCount; - skelCurve->limbList = Lib_SegmentedToVirtual(limbList->limbs); + skelCurve->limbCount = skeletonHeader->limbCount; + skelCurve->skeleton = Lib_SegmentedToVirtual(skeletonHeader->limbs); - skelCurve->transforms = ZeldaArena_Malloc(sizeof(*skelCurve->transforms) * skelCurve->limbCount); + skelCurve->jointTable = ZeldaArena_Malloc(sizeof(*skelCurve->jointTable) * skelCurve->limbCount); - do { - skelCurve->animCurFrame = 0.0f; - } while (0); - return 1; + skelCurve->curFrame = 0.0f; + return true; } -void SkelCurve_Destroy(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve) { - if (skelCurve->transforms != NULL) { - ZeldaArena_Free(skelCurve->transforms); +/** + * Frees the joint table. + */ +void SkelCurve_Destroy(GlobalContext* globalCtx, SkelCurve* skelCurve) { + if (skelCurve->jointTable != NULL) { + ZeldaArena_Free(skelCurve->jointTable); } } -void SkelCurve_SetAnim(SkelAnimeCurve* skelCurve, TransformUpdateIndex* transUpdIdx, f32 arg2, f32 animFinalFrame, - f32 animCurFrame, f32 animSpeed) { - skelCurve->unk0C = arg2 - skelCurve->animSpeed; - skelCurve->animFinalFrame = animFinalFrame; - skelCurve->animCurFrame = animCurFrame; - skelCurve->animSpeed = animSpeed; - skelCurve->transUpdIdx = transUpdIdx; +void SkelCurve_SetAnim(SkelCurve* skelCurve, CurveAnimationHeader* animation, f32 arg2, f32 endFrame, f32 curFrame, + f32 playSpeed) { + skelCurve->unk_0C = arg2 - skelCurve->playSpeed; + skelCurve->endFrame = endFrame; + skelCurve->curFrame = curFrame; + skelCurve->playSpeed = playSpeed; + skelCurve->animation = animation; } -#ifdef NON_MATCHING -/* Should be functionally equivalent, also migrating rodata makes it a lot cleaner */ -s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve) { - s16* transforms; - u8* transformRefIdx; - TransformUpdateIndex* transformIndex; - u16* transformCopyValues; - s32 i; - s32 ret = 0; - s32 k; - TransformData* transData; - f32 transformValue; - s32 j; +typedef enum { + /* 0 */ SKELCURVE_VEC_TYPE_SCALE, + /* 1 */ SKELCURVE_VEC_TYPE_ROTATION, + /* 2 */ SKELCURVE_VEC_TYPE_POSIITON, + /* 3 */ SKELCURVE_VEC_TYPE_MAX +} SkelCurveVecType; - transformIndex = Lib_SegmentedToVirtual(skelCurve->transUpdIdx); - transformRefIdx = Lib_SegmentedToVirtual(transformIndex->refIndex); - transData = Lib_SegmentedToVirtual(transformIndex->transformData); - transformCopyValues = Lib_SegmentedToVirtual(transformIndex->copyValues); - transforms = (s16*)skelCurve->transforms; +#define SKELCURVE_SCALE_SCALE 1024.0f +#define SKELCURVE_SCALE_POSITION 100 - skelCurve->animCurFrame += skelCurve->animSpeed * (globalCtx->state.framerateDivisor * 0.5f); +/** + * The only animation updating function. + * + * @return bool true when the animation has finished. + */ +s32 SkelCurve_Update(GlobalContext* globalCtx, SkelCurve* skelCurve) { + s16* jointData; + u8* knotCounts; + CurveAnimationHeader* animation; + u16* constantData; + s32 curLimb; + s32 ret = false; + s32 coord; + CurveInterpKnot* startKnot; + s32 vecType; - if ((skelCurve->animSpeed >= 0.0f && skelCurve->animCurFrame > skelCurve->animFinalFrame) || - (skelCurve->animSpeed < 0.0f && skelCurve->animCurFrame < skelCurve->animFinalFrame)) { - skelCurve->animCurFrame = skelCurve->animFinalFrame; - ret = 1; + animation = Lib_SegmentedToVirtual(skelCurve->animation); + knotCounts = Lib_SegmentedToVirtual(animation->knotCounts); + startKnot = Lib_SegmentedToVirtual(animation->interpolationData); + constantData = Lib_SegmentedToVirtual(animation->constantData); + jointData = *skelCurve->jointTable; + + skelCurve->curFrame += skelCurve->playSpeed * ((s32)globalCtx->state.framerateDivisor * 0.5f); + + if (((skelCurve->playSpeed >= 0.0f) && (skelCurve->curFrame > skelCurve->endFrame)) || + ((skelCurve->playSpeed < 0.0f) && (skelCurve->curFrame < skelCurve->endFrame))) { + skelCurve->curFrame = skelCurve->endFrame; + ret = true; } - for (i = 0; i < skelCurve->limbCount; i++) { - for (j = 0; j < 3; j++) { - for (k = 0; k < 3; k++, transformRefIdx++, transforms++) { - if (*transformRefIdx == 0) { - transformValue = *transformCopyValues; - *transforms = transformValue; - transformCopyValues++; + for (curLimb = 0; curLimb < skelCurve->limbCount; curLimb++) { + + // scale/rotation/position + for (vecType = SKELCURVE_VEC_TYPE_SCALE; vecType < SKELCURVE_VEC_TYPE_MAX; vecType++) { + + // x/y/z + for (coord = 0; coord < 3; coord++) { + f32 transformValue; + + if (*knotCounts == 0) { + transformValue = *constantData; + *jointData = transformValue; + constantData++; } else { - transformValue = func_800F2478(skelCurve->animCurFrame, transData, *transformRefIdx); - transData += *transformRefIdx; - if (j == 0) { - *transforms = transformValue * 1024.0f; - } else if (j == 1) { - *transforms = transformValue * (32768.0f / 180.0f); - } else { - *transforms = transformValue * 100.0f; + transformValue = Curve_Interpolate(skelCurve->curFrame, startKnot, *knotCounts); + startKnot += *knotCounts; + if (vecType == SKELCURVE_VEC_TYPE_SCALE) { + // Rescaling allows for more refined scaling using an s16 + *jointData = transformValue * SKELCURVE_SCALE_SCALE; + } else if (vecType == SKELCURVE_VEC_TYPE_ROTATION) { + // Convert value from degrees to a binary angle + *jointData = DEG_TO_BINANG(transformValue); + } else { // SKELCURVE_VEC_TYPE_POSIITON + // Model to world scale conversion + *jointData = transformValue * SKELCURVE_SCALE_POSITION; } } + knotCounts++; + jointData++; } } } return ret; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/SkelCurve_Update.s") -#endif -void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* skelCurve, +/** + * Recursively draws limbs with appropriate properties. + */ +void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) { - SkelCurveLimb* limb = Lib_SegmentedToVirtual(skelCurve->limbList[limbIndex]); + SkelCurveLimb* limb = Lib_SegmentedToVirtual(skelCurve->skeleton[limbIndex]); OPEN_DISPS(globalCtx->state.gfxCtx); Matrix_Push(); - if (overrideLimbDraw == NULL || - (overrideLimbDraw != NULL && overrideLimbDraw(globalCtx, skelCurve, limbIndex, thisx))) { + if ((overrideLimbDraw == NULL) || + ((overrideLimbDraw != NULL) && overrideLimbDraw(globalCtx, skelCurve, limbIndex, thisx))) { Vec3f scale; Vec3s rot; Vec3f pos; Gfx* dList; - Vec3s* transform = (Vec3s*)&skelCurve->transforms[limbIndex]; + s16* jointData = skelCurve->jointTable[limbIndex]; - scale.x = transform->x / 1024.0f; - scale.y = transform->y / 1024.0f; - scale.z = transform->z / 1024.0f; - transform++; - rot.x = transform->x; - rot.y = transform->y; - rot.z = transform->z; - transform++; - pos.x = transform->x; - pos.y = transform->y; - pos.z = transform->z; + scale.x = jointData[0] / SKELCURVE_SCALE_SCALE; + scale.y = jointData[1] / SKELCURVE_SCALE_SCALE; + scale.z = jointData[2] / SKELCURVE_SCALE_SCALE; + jointData += 3; + rot.x = jointData[0]; + rot.y = jointData[1]; + rot.z = jointData[2]; + jointData += 3; + pos.x = jointData[0]; + pos.y = jointData[1]; + pos.z = jointData[2]; Matrix_TranslateRotateZYX(&pos, &rot); Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); @@ -160,22 +217,22 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* postLimbDraw(globalCtx, skelCurve, limbIndex, thisx); } - if (limb->firstChildIdx != LIMB_DONE) { - SkelCurve_DrawLimb(globalCtx, limb->firstChildIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); + if (limb->child != LIMB_DONE) { + SkelCurve_DrawLimb(globalCtx, limb->child, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); } Matrix_Pop(); - if (limb->nextLimbIdx != LIMB_DONE) { - SkelCurve_DrawLimb(globalCtx, limb->nextLimbIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); + if (limb->sibling != LIMB_DONE) { + SkelCurve_DrawLimb(globalCtx, limb->sibling, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); } CLOSE_DISPS(globalCtx->state.gfxCtx); } -void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, +void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) { - if (skelCurve->transforms != NULL) { + if (skelCurve->jointTable != NULL) { SkelCurve_DrawLimb(globalCtx, 0, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx); } } diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 0a3334bc8..4c77b3669 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -627,9 +627,7 @@ void SkelAnime_GetFrameData(AnimationHeader* animation, s32 frame, s32 limbCount for (i = 0; i < limbCount; i++) { // Debug prints here, this is needed to prevent loop unrolling - if (0) { - if (0) {}; - } + if ((frameTable == NULL) || (jointIndices == NULL) || (dynamicData == NULL)) {} frameTable->x = jointIndices->x >= staticIndexMax ? dynamicData[jointIndices->x] : frameData[jointIndices->x]; frameTable->y = jointIndices->y >= staticIndexMax ? dynamicData[jointIndices->y] : frameData[jointIndices->y]; frameTable->z = jointIndices->z >= staticIndexMax ? dynamicData[jointIndices->z] : frameData[jointIndices->z]; diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index 12d59b530..bad5f7383 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -32,15 +32,15 @@ void func_809DD2F8(GlobalContext* globalCtx); void func_809DD934(Boss02* this, GlobalContext* globalCtx); void func_809DEAC4(Boss02* this, GlobalContext* globalCtx); -static u8 D_809E0420; -static u8 D_809E0421; -static u8 D_809E0422; -static Boss02* D_809E0424; -static Boss02* D_809E0428; -static Boss02* D_809E042C; -static u8 D_809E0430; -static DoorWarp1* D_809E0434; -static Boss02Effects D_809E0438[150]; +u8 D_809E0420; +u8 D_809E0421; +u8 D_809E0422; +Boss02* D_809E0424; +Boss02* D_809E0428; +Boss02* D_809E042C; +u8 D_809E0430; +DoorWarp1* D_809E0434; +Boss02Effects D_809E0438[150]; static DamageTable sDamageTable1 = { /* Deku Nut */ DMG_ENTRY(0, 0x0), diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c index 48ef3cd3d..01e8852fc 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c @@ -38,59 +38,64 @@ const ActorInit Demo_Effect_InitVars = { }; void DemoEffect_Init(Actor* thisx, GlobalContext* globalCtx) { - static s16 D_808CE2C0[] = { + static s16 sEffectTypeObjects[] = { OBJECT_EFC_TW, OBJECT_EFC_TW, OBJECT_EFC_TW, OBJECT_EFC_TW, GAMEPLAY_KEEP, GAMEPLAY_KEEP, GAMEPLAY_KEEP, GAMEPLAY_KEEP, GAMEPLAY_KEEP, }; s32 pad; DemoEffect* this = THIS; - s32 sp3C = DEMOEFFECT_GET_FF(&this->actor); - s32 phi_v1; + s32 type = DEMO_EFFECT_GET_TYPE(&this->actor); + s32 objectIndex; s32 pad2; - Color_RGB8 sp24[] = { + Color_RGB8 colors[] = { { 200, 200, 0 }, { 255, 40, 100 }, { 50, 255, 0 }, { 0, 0, 255 }, { 255, 255, 80 }, }; - if (D_808CE2C0[sp3C] == 1) { - phi_v1 = 0; + if (sEffectTypeObjects[type] == GAMEPLAY_KEEP) { + objectIndex = 0; } else { - phi_v1 = Object_GetIndex(&globalCtx->objectCtx, D_808CE2C0[sp3C]); + objectIndex = Object_GetIndex(&globalCtx->objectCtx, sEffectTypeObjects[type]); } - if (phi_v1 >= 0) { - this->unk_164 = phi_v1; + if (objectIndex < 0) { + // assert on debug + } else { + this->initObjectIndex = objectIndex; } Actor_SetScale(&this->actor, 0.2f); - switch (sp3C) { - case 0: - case 1: + switch (type) { + case DEMO_EFFECT_TYPE_0: + case DEMO_EFFECT_TYPE_1: this->actor.flags |= ACTOR_FLAG_2000000; - case 2: - case 3: - this->unk_174 = func_808CDFF8; - this->unk_170 = func_808CD998; - this->unk_168[0] = 0; - this->unk_168[1] = 100; - this->unk_168[2] = 255; + case DEMO_EFFECT_TYPE_2: + case DEMO_EFFECT_TYPE_3: + this->initDrawFunc = func_808CDFF8; + this->initActionFunc = func_808CD998; + this->envXluColor[0] = 0; + this->envXluColor[1] = 100; + this->envXluColor[2] = 255; SkelCurve_Clear(&this->skelCurve); - this->unk_16C = 0; + this->timer = 0; break; - case 4: - case 5: - case 6: - case 7: - case 8: - this->unk_168[0] = sp24[sp3C - 4].r; - this->unk_168[1] = sp24[sp3C - 4].g; - this->unk_168[2] = sp24[sp3C - 4].b; + case DEMO_EFFECT_TYPE_4: + case DEMO_EFFECT_TYPE_5: + case DEMO_EFFECT_TYPE_6: + case DEMO_EFFECT_TYPE_7: + case DEMO_EFFECT_TYPE_8: + this->envXluColor[0] = colors[type - 4].r; + this->envXluColor[1] = colors[type - 4].g; + this->envXluColor[2] = colors[type - 4].b; Actor_SetScale(&this->actor, 0.0f); - this->unk_174 = func_808CE078; - this->unk_170 = func_808CDDE0; - this->unk_16C = 0; + this->initDrawFunc = func_808CE078; + this->initActionFunc = func_808CDDE0; + this->timer = 0; + break; + + default: break; } @@ -98,33 +103,32 @@ void DemoEffect_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_808CD940; } -u8 D_808CE2D4[] = { - 1, 1, 2, 0, 1, 1, 2, 0, 1, 2, 0, 2, 1, 0, 1, 0, 2, 0, 2, 2, 0, -}; - void DemoEffect_Destroy(Actor* thisx, GlobalContext* globalCtx) { DemoEffect* this = THIS; - switch (DEMOEFFECT_GET_FF(&this->actor)) { - case 0: - case 1: - case 2: - case 3: + switch (DEMO_EFFECT_GET_TYPE(&this->actor)) { + case DEMO_EFFECT_TYPE_0: + case DEMO_EFFECT_TYPE_1: + case DEMO_EFFECT_TYPE_2: + case DEMO_EFFECT_TYPE_3: SkelCurve_Destroy(globalCtx, &this->skelCurve); break; + + default: + break; } } void func_808CD940(DemoEffect* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_164)) { - this->actor.objBankIndex = this->unk_164; - this->actor.draw = this->unk_174; - this->actionFunc = this->unk_170; + if (Object_IsLoaded(&globalCtx->objectCtx, this->initObjectIndex)) { + this->actor.objBankIndex = this->initObjectIndex; + this->actor.draw = this->initDrawFunc; + this->actionFunc = this->initActionFunc; } } void func_808CD998(DemoEffect* this, GlobalContext* globalCtx) { - s32 sp34 = DEMOEFFECT_GET_FF(&this->actor); + s32 type = DEMO_EFFECT_GET_TYPE(&this->actor); if (SkelCurve_Init(globalCtx, &this->skelCurve, &object_efc_tw_Skel_0012E8, &object_efc_tw_CurveAnim_000050)) {} @@ -132,20 +136,20 @@ void func_808CD998(DemoEffect* this, GlobalContext* globalCtx) { SkelCurve_Update(globalCtx, &this->skelCurve); this->actionFunc = func_808CDCEC; - switch (sp34) { - case 0: + switch (type) { + case DEMO_EFFECT_TYPE_0: Actor_SetScale(&this->actor, 0.16800001f); break; - case 1: + case DEMO_EFFECT_TYPE_1: Actor_SetScale(&this->actor, 0.08400001f); break; - case 2: + case DEMO_EFFECT_TYPE_2: Actor_SetScale(&this->actor, 0.16800001f); break; - case 3: + case DEMO_EFFECT_TYPE_3: Actor_SetScale(&this->actor, 0.28f); break; @@ -155,53 +159,57 @@ void func_808CD998(DemoEffect* this, GlobalContext* globalCtx) { } } -void func_808CDAD0(f32 arg0) { +void func_808CDAD0(f32 alphaScale) { + static u8 sAlphaTypes[] = { 1, 1, 2, 0, 1, 1, 2, 0, 1, 2, 0, 2, 1, 0, 1, 0, 2, 0, 2, 2, 0 }; + Vtx* vtx = Lib_SegmentedToVirtual(object_efc_tw_Vtx_000060); s32 i; - Vtx* temp_v0 = Lib_SegmentedToVirtual(object_efc_tw_Vtx_000060); - u8 sp24[3]; + u8 alphas[3]; - sp24[0] = 0; - sp24[1] = (s8)(202.0f * arg0); - sp24[2] = (s8)(255.0f * arg0); + alphas[0] = 0; + alphas[1] = (s32)(202.0f * alphaScale); + alphas[2] = (s32)(255.0f * alphaScale); - for (i = 0; i < ARRAY_COUNT(D_808CE2D4); i++) { - if (D_808CE2D4[i] != 0) { - temp_v0[i].v.cn[3] = sp24[D_808CE2D4[i]]; + for (i = 0; i < ARRAY_COUNT(sAlphaTypes); i++) { + if (sAlphaTypes[i] != 0) { + vtx[i].v.cn[3] = alphas[sAlphaTypes[i]]; } } } void func_808CDBDC(DemoEffect* this, GlobalContext* globalCtx) { - s32 params = DEMOEFFECT_GET_FF(&this->actor); - f32 temp_f0; - f32 temp_f12; + s32 type = DEMO_EFFECT_GET_TYPE(&this->actor); + f32 scale; + f32 alphaScale; - this->unk_16C++; - if (this->unk_16C <= 100) { - temp_f12 = (100 - this->unk_16C) * 0.01f; - temp_f0 = temp_f12 * 0.14f; + this->timer++; + if (this->timer <= 100) { + alphaScale = (100 - this->timer) * 0.01f; + scale = alphaScale * 0.14f; - switch (params) { - case 0: - temp_f0 *= 1.2f; + switch (type) { + case DEMO_EFFECT_TYPE_0: + scale *= 1.2f; break; - case 1: - temp_f0 *= 0.6f; + case DEMO_EFFECT_TYPE_1: + scale *= 0.6f; break; - case 2: - temp_f0 *= 1.2f; + case DEMO_EFFECT_TYPE_2: + scale *= 1.2f; break; - case 3: - temp_f0 *= 2.0f; + case DEMO_EFFECT_TYPE_3: + scale *= 2.0f; + break; + + default: break; } - this->actor.scale.x = temp_f0; - this->actor.scale.z = temp_f0; - func_808CDAD0(temp_f12); + this->actor.scale.x = scale; + this->actor.scale.z = scale; + func_808CDAD0(alphaScale); func_800B8FE8(&this->actor, NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); } else { func_808CDAD0(1.0f); @@ -215,14 +223,14 @@ void func_808CDCEC(DemoEffect* this, GlobalContext* globalCtx) { if (SkelCurve_Update(globalCtx, &this->skelCurve)) { SkelCurve_SetAnim(&this->skelCurve, &object_efc_tw_CurveAnim_000050, 1.0f, 60.0f, 59.0f, 0.0f); this->actionFunc = func_808CDBDC; - this->unk_16C = 0; + this->timer = 0; } } void func_808CDD70(DemoEffect* this, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, this->actor.scale.x - 0.02f); - this->unk_16C++; + this->timer++; if (this->actor.scale.x < 0.02f) { Actor_MarkForDeath(&this->actor); } @@ -231,8 +239,8 @@ void func_808CDD70(DemoEffect* this, GlobalContext* globalCtx) { void func_808CDDE0(DemoEffect* this, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, (this->actor.scale.x * 0.5f) + 0.2f); - this->unk_16C++; - if (this->unk_16C >= 3) { + this->timer++; + if (this->timer >= 3) { this->actionFunc = func_808CDD70; } } @@ -243,29 +251,28 @@ void DemoEffect_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); } -s32 func_808CDE78(GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, Actor* thisx) { +s32 func_808CDE78(GlobalContext* globalCtx, SkelCurve* skelCurve, s32 limbIndex, Actor* thisx) { s32 pad; DemoEffect* this = THIS; - u32 sp4C = globalCtx->gameplayFrames; + u32 frames = globalCtx->gameplayFrames; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, 255); - gDPSetEnvColor(POLY_XLU_DISP++, this->unk_168[0], this->unk_168[1], this->unk_168[2], 255); + gDPSetEnvColor(POLY_XLU_DISP++, this->envXluColor[0], this->envXluColor[1], this->envXluColor[2], 255); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (sp4C * 6) % 1024, 255 - ((sp4C * 16) % 256), 0x100, 0x40, - 1, (sp4C * 4) % 512, 127 - ((sp4C * 12) % 128), 0x80, 0x20)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (frames * 6) % 1024, 255 - ((frames * 16) % 256), 0x100, + 0x40, 1, (frames * 4) % 512, 127 - ((frames * 12) % 128), 0x80, 0x20)); CLOSE_DISPS(globalCtx->state.gfxCtx); if (limbIndex == 0) { - LimbTransform* transform = skelCuve->transforms; + s16* transform = skelCurve->jointTable[0]; - transform->scale.x = 0x400; - transform->scale.y = 0x400; - transform->scale.z = transform->scale.x; + transform[2] = transform[0] = 1024; + transform[1] = 1024; } return true; @@ -288,24 +295,24 @@ void func_808CDFF8(Actor* thisx, GlobalContext* globalCtx) { void func_808CE078(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; DemoEffect* this = THIS; - s16 sp46 = (this->unk_16C * 0x400) & 0xFFFF; + s16 zRot = (this->timer * 0x400) & 0xFFFF; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); - gDPSetEnvColor(POLY_XLU_DISP++, this->unk_168[0], this->unk_168[1], this->unk_168[2], 255); + gDPSetEnvColor(POLY_XLU_DISP++, this->envXluColor[0], this->envXluColor[1], this->envXluColor[2], 255); Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); Matrix_Push(); - Matrix_RotateZS(sp46, MTXMODE_APPLY); + Matrix_RotateZS(zRot, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023288); Matrix_Pop(); - Matrix_RotateZS(sp46 * -1, MTXMODE_APPLY); + Matrix_RotateZS(-zRot, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023288); diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h index 8216708c5..775bfcb0f 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h @@ -2,24 +2,35 @@ #define Z_DEMO_EFFECT_H #include "global.h" +#include "z64curve.h" struct DemoEffect; typedef void (*DemoEffectActionFunc)(struct DemoEffect*, GlobalContext*); -typedef void (*DemoEffectUnkFunc)(struct DemoEffect*, GlobalContext*); -typedef void (*DemoEffectUnkFunc2)(Actor*, GlobalContext*); -#define DEMOEFFECT_GET_FF(thisx) ((thisx)->params & 0xFF) +#define DEMO_EFFECT_GET_TYPE(thisx) ((thisx)->params & 0xFF) + +typedef enum { + /* 0 */ DEMO_EFFECT_TYPE_0, + /* 1 */ DEMO_EFFECT_TYPE_1, + /* 2 */ DEMO_EFFECT_TYPE_2, + /* 3 */ DEMO_EFFECT_TYPE_3, + /* 4 */ DEMO_EFFECT_TYPE_4, + /* 5 */ DEMO_EFFECT_TYPE_5, + /* 6 */ DEMO_EFFECT_TYPE_6, + /* 7 */ DEMO_EFFECT_TYPE_7, + /* 8 */ DEMO_EFFECT_TYPE_8 +} DemoEffectType; typedef struct DemoEffect { /* 0x0000 */ Actor actor; - /* 0x0144 */ SkelAnimeCurve skelCurve; - /* 0x0164 */ u8 unk_164; - /* 0x0165 */ UNK_TYPE1 unk_165[3]; - /* 0x0168 */ u8 unk_168[3]; - /* 0x016C */ s16 unk_16C; - /* 0x0170 */ DemoEffectUnkFunc unk_170; - /* 0x0174 */ DemoEffectUnkFunc2 unk_174; + /* 0x0144 */ SkelCurve skelCurve; + /* 0x0164 */ u8 initObjectIndex; + /* 0x0165 */ u8 primXluColor[3]; + /* 0x0168 */ u8 envXluColor[3]; + /* 0x016C */ s16 timer; + /* 0x0170 */ DemoEffectActionFunc initActionFunc; + /* 0x0174 */ ActorFunc initDrawFunc; /* 0x0178 */ DemoEffectActionFunc actionFunc; } DemoEffect; // size = 0x17C diff --git a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c index 6d921c4c6..d76de38a3 100644 --- a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c +++ b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c @@ -52,6 +52,11 @@ static TransformUpdateIndex* sBoxLightAnimations[] = { &gBoxLightChildCurveAnim, }; +typedef enum { + /* 0x00 */ DEMO_TRE_LGT_ACTION_WAIT, // wait until animation is needed + /* 0x01 */ DEMO_TRE_LGT_ACTION_ANIMATE +} DemoTreLgtAction; + static DemoTreLgtActionFunc sActionFuncs[] = { DemoTreLgt_Wait, DemoTreLgt_Animate, @@ -101,7 +106,7 @@ void DemoTreLgt_SetupAnimate(DemoTreLgt* this, GlobalContext* globalCtx, f32 fra } void DemoTreLgt_Animate(DemoTreLgt* this, GlobalContext* globalCtx) { - f32 curFrame = this->skelCurve.animCurFrame; + f32 curFrame = this->skelCurve.curFrame; if (curFrame < D_808E1490[this->animationType].unk4) { this->colorAlpha1 = 255; @@ -136,7 +141,7 @@ void DemoTreLgt_Update(Actor* thisx, GlobalContext* globalCtx) { sActionFuncs[this->action](this, globalCtx); } -s32 DemoTreLgt_OverrideLimbDraw(GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, Actor* thisx) { +s32 DemoTreLgt_OverrideLimbDraw(GlobalContext* globalCtx, SkelCurve* skelCuve, s32 limbIndex, Actor* thisx) { s32 pad; DemoTreLgt* this = THIS; @@ -148,8 +153,8 @@ s32 DemoTreLgt_OverrideLimbDraw(GlobalContext* globalCtx, SkelAnimeCurve* skelCu if (limbIndex == OBJECT_BOX_LIGHT_LIMB_01) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 180, this->colorAlpha1); - } else if (limbIndex == OBJECT_BOX_LIGHT_LIMB_13 || limbIndex == OBJECT_BOX_LIGHT_LIMB_07 || - limbIndex == OBJECT_BOX_LIGHT_LIMB_04 || limbIndex == OBJECT_BOX_LIGHT_LIMB_10) { + } else if ((limbIndex == OBJECT_BOX_LIGHT_LIMB_13) || (limbIndex == OBJECT_BOX_LIGHT_LIMB_07) || + (limbIndex == OBJECT_BOX_LIGHT_LIMB_04) || (limbIndex == OBJECT_BOX_LIGHT_LIMB_10)) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 180, this->colorAlpha2); } diff --git a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h index 08677b803..27f6d09b1 100644 --- a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h +++ b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.h @@ -2,6 +2,7 @@ #define Z_DEMO_TRE_LGT_H #include "global.h" +#include "z64curve.h" struct DemoTreLgt; @@ -9,7 +10,7 @@ typedef void (*DemoTreLgtActionFunc)(struct DemoTreLgt* this, GlobalContext* glo typedef struct DemoTreLgt { /* 0x000 */ Actor actor; - /* 0x144 */ SkelAnimeCurve skelCurve; + /* 0x144 */ SkelCurve skelCurve; /* 0x164 */ s32 action; /* 0x168 */ u32 colorAlpha1; /* 0x16C */ u32 colorAlpha2; @@ -17,11 +18,6 @@ typedef struct DemoTreLgt { /* 0x174 */ s32 animationType; } DemoTreLgt; // size = 0x178 -typedef enum { - /* 0x00 */ DEMO_TRE_LGT_ACTION_WAIT, // wait until animation is needed - /* 0x01 */ DEMO_TRE_LGT_ACTION_ANIMATE -} DemoTreLgtAction; - extern const ActorInit Demo_Tre_Lgt_InitVars; #endif // Z_DEMO_TRE_LGT_H diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.c b/src/overlays/actors/ovl_En_Box/z_en_box.c index 1259df33e..2b01b6e05 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -126,7 +126,7 @@ void func_80867C8C(func_80867BDC_a0* arg0, GlobalContext* globalCtx) { for (i = 0; i < temp_s6; i++) { f32 temp_f0 = (f32)i / temp_s6; s16 temp_s0 = ((f32)arg0->unk_18 - arg0->unk_1C) * temp_f0 + arg0->unk_1C; - f32 temp_f24 = 1.0f - (temp_s0 * 0.011764706f); + f32 temp_f24 = 1.0f - (temp_s0 * (1 / 85.0f)); f32 temp_f26 = Rand_ZeroOne() * 0.03f * temp_f0 * temp_f24; f32 temp_f28; f32 temp_f30 = Math_SinS(temp_s0 * 0x9A6) * 45.0f + arg0->pos.x; @@ -186,9 +186,9 @@ void EnBox_ClipToGround(EnBox* this, GlobalContext* globalCtx) { } void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { - s16 cutsceneIdx; - EnBox* this = (EnBox*)thisx; s32 pad; + EnBox* this = THIS; + s16 cutsceneIdx; CollisionHeader* colHeader; f32 animFrame; f32 animFrameEnd; @@ -227,7 +227,7 @@ void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { EnBox_SetupAction(this, EnBox_Open); this->movementFlags |= ENBOX_MOVE_STICK_TO_GROUND; animFrame = animFrameEnd; - } else if ((this->type == ENBOX_TYPE_BIG_SWITCH_FLAG_FALL || this->type == ENBOX_TYPE_SMALL_SWITCH_FLAG_FALL) && + } else if (((this->type == ENBOX_TYPE_BIG_SWITCH_FLAG_FALL) || (this->type == ENBOX_TYPE_SMALL_SWITCH_FLAG_FALL)) && !Flags_GetSwitch(globalCtx, this->switchFlag)) { func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); if (Rand_ZeroOne() < 0.5f) { @@ -238,7 +238,7 @@ void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { this->alpha = 0; this->movementFlags |= ENBOX_MOVE_IMMOBILE; this->dyna.actor.flags |= ACTOR_FLAG_10; - } else if ((this->type == ENBOX_TYPE_BIG_ROOM_CLEAR || this->type == ENBOX_TYPE_SMALL_ROOM_CLEAR) && + } else if (((this->type == ENBOX_TYPE_BIG_ROOM_CLEAR) || (this->type == ENBOX_TYPE_SMALL_ROOM_CLEAR)) && !Flags_GetClear(globalCtx, this->dyna.actor.room)) { EnBox_SetupAction(this, EnBox_AppearOnRoomClear); func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); @@ -250,9 +250,9 @@ void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { this->alpha = 0; this->movementFlags |= ENBOX_MOVE_IMMOBILE; this->dyna.actor.flags |= ACTOR_FLAG_10; - } else if (this->type == ENBOX_TYPE_BIG_SONG_ZELDAS_LULLABY || this->type == ENBOX_TYPE_BIG_SONG_SUNS) { + } else if ((this->type == ENBOX_TYPE_BIG_SONG_ZELDAS_LULLABY) || (this->type == ENBOX_TYPE_BIG_SONG_SUNS)) { - } else if ((this->type == ENBOX_TYPE_BIG_SWITCH_FLAG || this->type == ENBOX_TYPE_SMALL_SWITCH_FLAG) && + } else if (((this->type == ENBOX_TYPE_BIG_SWITCH_FLAG) || (this->type == ENBOX_TYPE_SMALL_SWITCH_FLAG)) && !Flags_GetSwitch(globalCtx, this->switchFlag)) { EnBox_SetupAction(this, EnBox_AppearSwitchFlag); func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); @@ -265,7 +265,7 @@ void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { this->movementFlags |= ENBOX_MOVE_IMMOBILE; this->dyna.actor.flags |= ACTOR_FLAG_10; } else { - if (this->type == ENBOX_TYPE_BIG_INVISIBLE || this->type == ENBOX_TYPE_SMALL_INVISIBLE) { + if ((this->type == ENBOX_TYPE_BIG_INVISIBLE) || (this->type == ENBOX_TYPE_SMALL_INVISIBLE)) { this->dyna.actor.flags |= ACTOR_FLAG_80; } EnBox_SetupAction(this, EnBox_WaitOpen); @@ -273,7 +273,7 @@ void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { this->movementFlags |= ENBOX_MOVE_STICK_TO_GROUND; } - if (this->getItem == GI_STRAY_FAIRY && !Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { + if ((this->getItem == GI_STRAY_FAIRY) && !Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { this->dyna.actor.flags |= ACTOR_FLAG_10; } @@ -307,7 +307,7 @@ void EnBox_Init(Actor* thisx, GlobalContext* globalCtx) { } void EnBox_Destroy(Actor* thisx, GlobalContext* globalCtx) { - EnBox* this = (EnBox*)thisx; + EnBox* this = THIS; DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); } @@ -414,7 +414,7 @@ void EnBox_AppearOnRoomClear(EnBox* this, GlobalContext* globalCtx) { } void func_80868AFC(EnBox* this, GlobalContext* globalCtx) { - if (func_800F22C4(this->cutsceneIdxA, &this->dyna.actor) != 0 || this->unk_1A0 != 0) { + if ((func_800F22C4(this->cutsceneIdxA, &this->dyna.actor) != 0) || (this->unk_1A0 != 0)) { EnBox_SetupAction(this, func_80868B74); this->unk_1A0 = 0; func_80867FBC(&this->unk_1F4, globalCtx, (this->movementFlags & ENBOX_MOVE_0x80) != 0); @@ -433,7 +433,7 @@ void func_80868B74(EnBox* this, GlobalContext* globalCtx) { this->dyna.actor.world.pos.y += 1.25f; } this->unk_1A0++; - if (this->cutsceneIdxA != -1 && ActorCutscene_GetCurrentIndex() == this->cutsceneIdxA) { + if ((this->cutsceneIdxA != -1) && ActorCutscene_GetCurrentIndex() == this->cutsceneIdxA) { if (this->unk_1A0 == 2) { func_800B724C(globalCtx, &this->dyna.actor, 4); } else if (this->unk_1A0 == 22) { @@ -461,8 +461,8 @@ void EnBox_WaitOpen(EnBox* this, GlobalContext* globalCtx) { this->alpha = 255; this->movementFlags |= ENBOX_MOVE_IMMOBILE; - if (this->unk_1EC != 0 && (this->cutsceneIdxB < 0 || ActorCutscene_GetCurrentIndex() == this->cutsceneIdxB || - ActorCutscene_GetCurrentIndex() == -1)) { + if ((this->unk_1EC != 0) && ((this->cutsceneIdxB < 0) || (ActorCutscene_GetCurrentIndex() == this->cutsceneIdxB) || + (ActorCutscene_GetCurrentIndex() == -1))) { if (this->unk_1EC < 0) { animHeader = &gBoxChestOpenAnim; playbackSpeed = 1.5f; @@ -489,7 +489,7 @@ void EnBox_WaitOpen(EnBox* this, GlobalContext* globalCtx) { if (this->getItem == GI_STRAY_FAIRY) { this->movementFlags |= ENBOX_MOVE_0x20; } else { - if (this->getItem == GI_HEART_PIECE || this->getItem == GI_BOTTLE) { + if ((this->getItem == GI_HEART_PIECE) || (this->getItem == GI_BOTTLE)) { Flags_SetCollectible(globalCtx, this->collectableFlag); } Flags_SetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor)); @@ -499,14 +499,14 @@ void EnBox_WaitOpen(EnBox* this, GlobalContext* globalCtx) { Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); if (offset.z > -50.0f && offset.z < 0.0f && fabsf(offset.y) < 10.0f && fabsf(offset.x) < 20.0f && Player_IsFacingActor(&this->dyna.actor, 0x3000, globalCtx)) { - if ((this->getItem == GI_HEART_PIECE || this->getItem == GI_BOTTLE) && + if (((this->getItem == GI_HEART_PIECE) || (this->getItem == GI_BOTTLE)) && Flags_GetCollectible(globalCtx, this->collectableFlag)) { this->getItem = GI_RECOVERY_HEART; } - if (this->getItem == GI_MASK_CAPTAIN && INV_CONTENT(ITEM_MASK_CAPTAIN) == ITEM_MASK_CAPTAIN) { + if ((this->getItem == GI_MASK_CAPTAIN) && (INV_CONTENT(ITEM_MASK_CAPTAIN) == ITEM_MASK_CAPTAIN)) { this->getItem = GI_RECOVERY_HEART; } - if (this->getItem == GI_MASK_GIANT && INV_CONTENT(ITEM_MASK_GIANT) == ITEM_MASK_GIANT) { + if ((this->getItem == GI_MASK_GIANT) && (INV_CONTENT(ITEM_MASK_GIANT) == ITEM_MASK_GIANT)) { this->getItem = GI_RECOVERY_HEART; } Actor_PickUpNearby(&this->dyna.actor, globalCtx, -this->getItem); @@ -568,7 +568,7 @@ void EnBox_Open(EnBox* this, GlobalContext* globalCtx) { } if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.z, &waterSurface, &waterBox, &bgId) && - this->dyna.actor.floorHeight < waterSurface) { + (this->dyna.actor.floorHeight < waterSurface)) { EffectSsBubble_Spawn(globalCtx, &this->dyna.actor.world.pos, 5.0f, 2.0f, 20.0f, 0.3f); } } @@ -598,13 +598,13 @@ void EnBox_SpawnIceSmoke(EnBox* this, GlobalContext* globalCtx) { } void EnBox_Update(Actor* thisx, GlobalContext* globalCtx) { - EnBox* this = (EnBox*)thisx; + EnBox* this = THIS; if (this->movementFlags & ENBOX_MOVE_STICK_TO_GROUND) { this->movementFlags &= ~ENBOX_MOVE_STICK_TO_GROUND; EnBox_ClipToGround(this, globalCtx); } - if (this->getItem == GI_STRAY_FAIRY && !Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { + if ((this->getItem == GI_STRAY_FAIRY) && !Flags_GetTreasure(globalCtx, ENBOX_GET_CHEST_FLAG(&this->dyna.actor))) { globalCtx->actorCtx.unk5 |= 8; } this->actionFunc(this, globalCtx); @@ -616,8 +616,8 @@ void EnBox_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 0x1C); } Actor_SetFocus(&this->dyna.actor, 40.0f); - if (this->getItem == GI_ICE_TRAP && this->actionFunc == EnBox_Open && this->skelAnime.curFrame > 45.0f && - this->iceSmokeTimer < 100) { + if ((this->getItem == GI_ICE_TRAP) && (this->actionFunc == EnBox_Open) && (this->skelAnime.curFrame > 45.0f) && + (this->iceSmokeTimer < 100)) { EnBox_SpawnIceSmoke(this, globalCtx); } if (this->unk_1F4.unk_0C != NULL) { @@ -626,8 +626,8 @@ void EnBox_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnBox_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { - EnBox* this = THIS; s32 pad; + EnBox* this = THIS; if (limbIndex == OBJECT_BOX_CHEST_LIMB_01) { gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -688,16 +688,17 @@ Gfx* EnBox_SetRenderMode3(GraphicsContext* gfxCtx) { } void EnBox_Draw(Actor* thisx, GlobalContext* globalCtx) { - EnBox* this = (EnBox*)thisx; s32 pad; + EnBox* this = THIS; OPEN_DISPS(globalCtx->state.gfxCtx); if (this->unk_1F4.unk_10 != NULL) { this->unk_1F4.unk_10(&this->unk_1F4, globalCtx); } - if ((this->alpha == 255 && this->type != ENBOX_TYPE_BIG_INVISIBLE && this->type != ENBOX_TYPE_SMALL_INVISIBLE) || + if (((this->alpha == 255) && (this->type != ENBOX_TYPE_BIG_INVISIBLE) && + (this->type != ENBOX_TYPE_SMALL_INVISIBLE)) || (!CHECK_FLAG_ALL(this->dyna.actor.flags, ACTOR_FLAG_80) && - (this->type == ENBOX_TYPE_BIG_INVISIBLE || this->type == ENBOX_TYPE_SMALL_INVISIBLE))) { + ((this->type == ENBOX_TYPE_BIG_INVISIBLE) || (this->type == ENBOX_TYPE_SMALL_INVISIBLE)))) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); gSPSegment(POLY_OPA_DISP++, 0x08, EnBox_SetRenderMode1(globalCtx->state.gfxCtx)); @@ -708,7 +709,7 @@ void EnBox_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); func_8012C2DC(globalCtx->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); - if (this->type == ENBOX_TYPE_BIG_INVISIBLE || this->type == ENBOX_TYPE_SMALL_INVISIBLE) { + if ((this->type == ENBOX_TYPE_BIG_INVISIBLE) || (this->type == ENBOX_TYPE_SMALL_INVISIBLE)) { gSPSegment(POLY_XLU_DISP++, 0x08, EnBox_SetRenderMode3(globalCtx->state.gfxCtx)); } else { gSPSegment(POLY_XLU_DISP++, 0x08, EnBox_SetRenderMode2(globalCtx->state.gfxCtx)); diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.h b/src/overlays/actors/ovl_En_Box/z_en_box.h index 02d9d95f9..6d7da31a5 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.h +++ b/src/overlays/actors/ovl_En_Box/z_en_box.h @@ -36,6 +36,13 @@ typedef enum { /* 12 */ ENBOX_TYPE_SMALL_SWITCH_FLAG // small, appear on switch flag set } EnBoxType; +#define ENBOX_GET_TYPE(thisx) (((thisx)->params >> 12) & 0xF) +#define ENBOX_GET_ITEM(thisx) (((thisx)->params >> 5) & 0x7F) +#define ENBOX_GET_CHEST_FLAG(thisx) ((thisx)->params & 0x1F) +#define ENBOX_GET_SWITCH_FLAG(thisx) ((thisx)->world.rot.z) +// Codegen in EnTorch_Init() requires leaving out the & 0x7F for `item` +#define ENBOX_PARAMS(type, item, chestFlag) ((((type) & 0xF) << 12) | ((item) << 5) | ((chestFlag) & 0x1F)) + typedef struct EnBox { /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ SkelAnime skelAnime; @@ -61,9 +68,5 @@ typedef struct EnBox { extern const ActorInit En_Box_InitVars; -#define ENBOX_GET_TYPE(thisx) (((thisx)->params >> 12) & 0xF) -#define ENBOX_GET_ITEM(thisx) (((thisx)->params >> 5) & 0x7F) -#define ENBOX_GET_CHEST_FLAG(thisx) ((thisx)->params & 0x1F) -#define ENBOX_GET_SWITCH_FLAG(thisx) ((thisx)->world.rot.z) #endif // Z_EN_BOX_H diff --git a/src/overlays/actors/ovl_En_Torch/z_en_torch.c b/src/overlays/actors/ovl_En_Torch/z_en_torch.c index fc06cff18..7ca536b6a 100644 --- a/src/overlays/actors/ovl_En_Torch/z_en_torch.c +++ b/src/overlays/actors/ovl_En_Torch/z_en_torch.c @@ -5,6 +5,7 @@ */ #include "z_en_torch.h" +#include "overlays/actors/ovl_En_Box/z_en_box.h" #define FLAGS 0x00000000 @@ -17,7 +18,9 @@ const ActorInit En_Torch_InitVars = { (ActorFunc)EnTorch_Init, (ActorFunc)NULL, (ActorFunc)NULL, (ActorFunc)NULL, }; -static u8 sChestContents[] = { 0x02, 0x04, 0x05, 0x06, 0x36, 0x3A, 0x14, 0x14 }; +static u8 sChestContents[] = { + GI_RUPEE_BLUE, GI_RUPEE_RED, GI_RUPEE_PURPLE, GI_RUPEE_SILVER, GI_BOMBCHUS_1, GI_BOMBCHUS_5, GI_BOMBS_1, GI_BOMBS_1, +}; void EnTorch_Init(Actor* thisx, GlobalContext* globalCtx) { EnTorch* this = THIS; @@ -25,6 +28,6 @@ void EnTorch_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOX, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, - (sChestContents[(returnData >> 0x5) & 0x7] << 0x5) | 0x5000 | (returnData & 0x1F)); + ENBOX_PARAMS(ENBOX_TYPE_SMALL, sChestContents[(returnData >> 0x5) & 0x7], returnData)); Actor_MarkForDeath(&this->actor); } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index f037221be..4307c8e37 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1661,8 +1661,8 @@ 0x800F21CC:("func_800F21CC",), 0x800F22C4:("func_800F22C4",), 0x800F23C4:("ActorCutscene_SetReturnCamera",), - 0x800F23E0:("func_800F23E0",), - 0x800F2478:("func_800F2478",), + 0x800F23E0:("Curve_CubicHermiteSpline",), + 0x800F2478:("Curve_Interpolate",), 0x800F2620:("SkelCurve_Clear",), 0x800F2650:("SkelCurve_Init",), 0x800F26C0:("SkelCurve_Destroy",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index e0bf5a65a..336b844df 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -6826,9 +6826,8 @@ 0x808CD5E8:("D_808CD5E8","f32","",0x4), 0x808CE290:("Demo_Effect_InitVars","UNK_TYPE1","",0x1), 0x808CE2B0:("D_808CE2B0","UNK_TYPE4","",0x4), - 0x808CE2C0:("D_808CE2C0","UNK_TYPE1","",0x1), - 0x808CE2D4:("D_808CE2D4","UNK_TYPE1","",0x1), - 0x808CE2D5:("D_808CE2D5","UNK_TYPE1","",0x1), + 0x808CE2C0:("sEffectTypeObjects","s16","",0x12), + 0x808CE2D4:("sAlphaTypes","u8","",0x15), 0x808CE2F0:("jtbl_808CE2F0","UNK_PTR","",0x4), 0x808CE314:("D_808CE314","f32","",0x4), 0x808CE318:("D_808CE318","f32","",0x4), From 56c517dc0741be9c033e204b564528c46562c730 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 19 Jun 2022 03:45:09 +0100 Subject: [PATCH 238/257] Obj_Toge (#815) * Obj_Toge * Wat * One more thing * PR * PR * a Co-authored-by: EllipticEllipsis --- include/functions.h | 2 +- spec | 3 +- src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c | 281 ++++++++++++++++-- src/overlays/actors/ovl_Obj_Toge/z_obj_toge.h | 23 +- undefined_syms.txt | 4 - 5 files changed, 277 insertions(+), 36 deletions(-) diff --git a/include/functions.h b/include/functions.h index b802ee28a..92db30a01 100644 --- a/include/functions.h +++ b/include/functions.h @@ -563,7 +563,7 @@ void EffectSsKakera_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, // void EffectSsIcePiece_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, UNK_TYPE4 uParm3, Vec3f* pzParm4, Vec3f* param_5, UNK_TYPE4 param_6); // void EffectSsIcePiece_SpawnBurst(void); // void EffectSsEnIce_SpawnFlyingVec3f(UNK_TYPE4 uParm1, Actor* pzParm2, Vec3f* pzParm3, Color_RGBA8* pzParm4, Color_RGBA8* param_5, UNK_TYPE4 param_6); -// void func_800B2B44(void); +void func_800B2B44(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, f32 arg3); // void func_800B2B7C(void); void EffectSsEnIce_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s32 life); // void EffectSsFireTail_Spawn(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, UNK_TYPE4 uParm4, Vec3f* param_5, UNK_TYPE2 param_6, Color_RGBA8* param_7, Color_RGBA8* param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE4 param_11); diff --git a/spec b/spec index cdf130b1d..f6fb137b2 100644 --- a/spec +++ b/spec @@ -2213,8 +2213,7 @@ beginseg name "ovl_Obj_Toge" compress include "build/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.o" - include "build/data/ovl_Obj_Toge/ovl_Obj_Toge.data.o" - include "build/data/ovl_Obj_Toge/ovl_Obj_Toge.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Toge/ovl_Obj_Toge_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c index 0471b6bd7..f8425b40a 100644 --- a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c +++ b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c @@ -5,6 +5,7 @@ */ #include "z_obj_toge.h" +#include "objects/object_trap/object_trap.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,11 +16,13 @@ void ObjToge_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjToge_Update(Actor* thisx, GlobalContext* globalCtx); void ObjToge_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_809A4744(ObjToge* this); void func_809A477C(ObjToge* this, GlobalContext* globalCtx); +void func_809A4804(ObjToge* this); void func_809A481C(ObjToge* this, GlobalContext* globalCtx); +void func_809A488C(ObjToge* this); void func_809A48AC(ObjToge* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Toge_InitVars = { ACTOR_OBJ_TOGE, ACTORCAT_PROP, @@ -32,52 +35,280 @@ const ActorInit Obj_Toge_InitVars = { (ActorFunc)ObjToge_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809A4CB0 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 20, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809A4D14[] = { +f32 D_809A4CDC[] = { 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, 12.0f, 14.0f, 16.0f }; + +s16 D_809A4CFC[] = { 0, 10, 20, 30, 40, 50, 60, 70 }; + +f32 D_809A4D0C[] = { 1.0f, 2.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(terminalVelocity, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 150, ICHAIN_STOP), }; -#endif +void func_809A41C0(ObjToge* this, GlobalContext* globalCtx) { + Vec3f sp1C = this->actor.world.pos; -extern ColliderCylinderInit D_809A4CB0; -extern InitChainEntry D_809A4D14[]; + sp1C.y += 10.0f; + sp1C.z += 10.0f; + func_800B2B44(globalCtx, &this->actor, &sp1C, 1.8f); -extern UNK_TYPE D_06001400; + sp1C.x += 10.0f; + sp1C.z -= 20.0f; + func_800B2B44(globalCtx, &this->actor, &sp1C, 1.8f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A41C0.s") + sp1C.x -= 20.0f; + func_800B2B44(globalCtx, &this->actor, &sp1C, 1.8f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A42A0.s") +void func_809A42A0(ObjToge* this, GlobalContext* globalCtx) { + Vec3f sp54; + s32 i; + s16 phi_s0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A43A8.s") + sp54.y = this->actor.world.pos.y + 15.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A43EC.s") + for (i = 0, phi_s0 = 0; i < 5; i++, phi_s0 += 0x3333) { + sp54.x = (Math_SinS(phi_s0) * 15.0f) + this->actor.world.pos.x; + sp54.z = (Math_CosS(phi_s0) * 15.0f) + this->actor.world.pos.z; + func_800B2B44(globalCtx, &this->actor, &sp54, (Rand_ZeroOne() * 0.6f) + 2.8f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/ObjToge_Init.s") +void func_809A43A8(ObjToge* this, GlobalContext* globalCtx) { + if (!OBJTOGE_GET_4000(&this->actor)) { + func_809A41C0(this, globalCtx); + } else { + func_809A42A0(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/ObjToge_Destroy.s") +s32 func_809A43EC(ObjToge* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp_fv1 = player->actor.world.pos.x - this->unk_1B8; + f32 temp_fa0 = player->actor.world.pos.z - this->unk_1BC; + f32 temp = -(this->unk_1CC * temp_fa0) + (temp_fv1 * this->unk_1C8); + f32 temp2 = (this->unk_1CC * temp_fv1) + (temp_fa0 * this->unk_1C8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A4744.s") + return fabsf(temp) <= this->unk_1C0 && fabsf(temp2) <= this->unk_1C4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A477C.s") +void ObjToge_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjToge* this = THIS; + Path* path; + Vec3s* sp40; + s16 sp3E; + s32 sp38 = OBJTOGE_GET_4000(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A4804.s") + Actor_ProcessInitChain(thisx, sInitChain); + Actor_SetScale(thisx, D_809A4D0C[sp38] * 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A481C.s") + sp3E = thisx->home.rot.z; + thisx->home.rot.z = thisx->world.rot.z = thisx->shape.rot.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A488C.s") + Collider_InitCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/func_809A48AC.s") + if (OBJTOGE_GET_PATH(thisx) == 0xFF) { + Actor_MarkForDeath(thisx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/ObjToge_Update.s") + path = &globalCtx->setupPathList[OBJTOGE_GET_PATH(thisx)]; + if (path->count != 2) { + Actor_MarkForDeath(thisx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Toge/ObjToge_Draw.s") + sp40 = Lib_SegmentedToVirtual(path->points); + Math_Vec3s_ToVec3f(&this->unk_198[0], &sp40[0]); + Math_Vec3s_ToVec3f(&this->unk_198[1], &sp40[1]); + Math_Vec3f_Copy(&thisx->world.pos, &this->unk_198[0]); + thisx->world.rot.y = Math_Vec3f_Yaw(&this->unk_198[0], &this->unk_198[1]); + this->unk_194 = 0; + thisx->speedXZ = 0.0f; + + if (sp3E > 0) { + s16 sp36; + + this->unk_1B4 = true; + this->unk_1B8 = (this->unk_198[0].x + this->unk_198[1].x) * 0.5f; + this->unk_1BC = (this->unk_198[0].z + this->unk_198[1].z) * 0.5f; + + sp36 = Math_Vec3f_Yaw(&this->unk_198[0], &this->unk_198[1]); + this->unk_1C8 = Math_CosS(sp36); + this->unk_1CC = Math_SinS(sp36); + this->unk_1C0 = sp3E * 7.5f; + this->unk_1C4 = Math3D_Distance(&this->unk_198[0], &this->unk_198[1]) * 0.5f; + } else { + this->unk_1B4 = false; + } + + Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); + Collider_UpdateCylinder(thisx, &this->collider); + thisx->colChkInfo.mass = MASS_IMMOVABLE; + + if (sp38 == 1) { + this->collider.dim.radius = 60; + this->collider.dim.height = 40; + } + + if (this->unk_1B4) { + func_809A4804(this); + } else { + func_809A4744(this); + } +} + +void ObjToge_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjToge* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void func_809A4744(ObjToge* this) { + this->actionFunc = func_809A477C; + this->unk_1B0 = 0; + this->unk_1B2 = D_809A4CFC[OBJTOGE_GET_3800(&this->actor)]; +} + +void func_809A477C(ObjToge* this, GlobalContext* globalCtx) { + if (this->unk_1B2 > 0) { + this->unk_1B2--; + } + + if (this->unk_1B0 >= 0x1770) { + this->unk_1B0 = 0x1770; + func_809A488C(this); + } else if ((this->unk_1B0 > 0) || (this->unk_1B2 <= 0)) { + this->unk_1B0 += 200; + } + + if (!this->unk_1B4) { + this->actor.shape.rot.y += this->unk_1B0; + } +} + +void func_809A4804(ObjToge* this) { + this->actionFunc = func_809A481C; + this->unk_1B0 = 0; +} + +void func_809A481C(ObjToge* this, GlobalContext* globalCtx) { + if (this->unk_1B0 >= 0x1770) { + this->unk_1B0 = 0x1770; + func_809A488C(this); + } else if ((this->unk_1B0 > 0) || func_809A43EC(this, globalCtx)) { + this->unk_1B0 += 200; + } + this->actor.shape.rot.y += this->unk_1B0; +} + +void func_809A488C(ObjToge* this) { + this->actor.speedXZ = 1.0f; + this->actionFunc = func_809A48AC; +} + +void func_809A48AC(ObjToge* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp30 = this->unk_194 ^ 1; + + if (this->unk_1B4 && (this->unk_194 == 1)) { + Math_StepToF(&this->actor.speedXZ, 2.0f, 0.4f); + } else { + Math_StepToF(&this->actor.speedXZ, D_809A4CDC[OBJTOGE_GET_700(&this->actor)], 1.5f); + this->actor.shape.rot.y += 0x1770; + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, D_809A4D0C[OBJTOGE_GET_4000(&this->actor)] * 30.0f, 0.0f, + 0x81); + + if (this->actor.bgCheckFlags & 8) { + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_198[this->unk_194]); + this->unk_194 = sp30; + if (this->unk_1B4 && (this->unk_194 == 0)) { + func_809A4804(this); + } else { + func_809A4744(this); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SPINE_TRAP_MOVE); + } else { + s16 yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_198[sp30]) - this->actor.world.rot.y; + + yaw = ABS_ALT(yaw); + if ((yaw > 0x4000) || (yaw == -0x8000)) { + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_198[this->unk_194]); + this->unk_194 = sp30; + if (this->unk_1B4 && (this->unk_194 == 0)) { + func_809A4804(this); + } else { + func_809A4744(this); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SPINE_TRAP_MOVE); + } + } +} + +void ObjToge_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjToge* this = THIS; + ColliderCylinder* collider = &this->collider; + + if (this->collider.base.acFlags & AC_HIT) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x1000) { + func_809A43A8(this, globalCtx); + Actor_SetColorFilter(&this->actor, 0, 250, 0, 250); + } + collider->base.acFlags &= ~AC_HIT; + } + + if (this->actor.colorFilterTimer == 0) { + if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { + func_800B8DD4(globalCtx, &this->actor, 6.0f, this->actor.yawTowardsPlayer, 6.0f, 4); + } + + this->actionFunc(this, globalCtx); + + Collider_UpdateCylinder(&this->actor, &this->collider); + if (this->actor.xzDistToPlayer < 1000.0f) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } + + if ((this->actor.flags & ACTOR_FLAG_40) || (this->actor.xzDistToPlayer < 300.0f)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &collider->base); + } else { + this->collider.base.ocFlags1 &= ~OC1_HIT; + this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; + } +} + +void ObjToge_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjToge* this = THIS; + + func_800B8050(&this->actor, globalCtx, 1); + Gfx_DrawDListOpa(globalCtx, object_trap_DL_001400); +} diff --git a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.h b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.h index c67e0b97f..3908b2c7e 100644 --- a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.h +++ b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.h @@ -7,11 +7,26 @@ struct ObjToge; typedef void (*ObjTogeActionFunc)(struct ObjToge*, GlobalContext*); +#define OBJTOGE_GET_PATH(thisx) ((thisx)->params & 0xFF) +#define OBJTOGE_GET_700(thisx) (((thisx)->params >> 8) & 7) +#define OBJTOGE_GET_3800(thisx) (((thisx)->params >> 0xB) & 7) +#define OBJTOGE_GET_4000(thisx) (((thisx)->params >> 0xE) & 1) + typedef struct ObjToge { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; - /* 0x0190 */ ObjTogeActionFunc actionFunc; - /* 0x0194 */ char unk_194[0x3C]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ ObjTogeActionFunc actionFunc; + /* 0x194 */ s32 unk_194; + /* 0x198 */ Vec3f unk_198[2]; + /* 0x1B0 */ s16 unk_1B0; + /* 0x1B2 */ s16 unk_1B2; + /* 0x1B4 */ u8 unk_1B4; + /* 0x1B8 */ f32 unk_1B8; + /* 0x1BC */ f32 unk_1BC; + /* 0x1C0 */ f32 unk_1C0; + /* 0x1C4 */ f32 unk_1C4; + /* 0x1C8 */ f32 unk_1C8; + /* 0x1CC */ f32 unk_1CC; } ObjToge; // size = 0x1D0 extern const ActorInit Obj_Toge_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 15bcad8c1..b0a275ace 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1618,10 +1618,6 @@ D_06001100 = 0x06001100; D_06001140 = 0x06001140; D_06001CB0 = 0x06001CB0; -// ovl_Obj_Toge - -D_06001400 = 0x06001400; - // ovl_Obj_Toudai D_060023B0 = 0x060023B0; From 7ca70d496dfdcab4a4132eb1e02887d7a1715637 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis Date: Sun, 19 Jun 2022 04:14:55 +0100 Subject: [PATCH 239/257] Change `Rand_Next` to `u32`, document `rand.c` a bit more (#819) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Change Rand_Next to u32, document rand.c a bit more * Clean up the quotes a bit, add another note * Format * — -> - * Review * Remove unnecessary casts * Remove quote, reformat the comments * Fix new files * Make docs a bit more consistent and specific * Format --- include/functions.h | 2 +- src/boot_O2/rand.c | 60 +++++++++++-------- src/code/sys_math_atan.c | 48 +++++++-------- src/code/z_actor.c | 2 +- .../ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c | 6 +- .../ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c | 4 +- .../z_bg_dblue_waterfall.c | 2 +- .../z_bg_hakugin_bombwall.c | 16 ++--- .../ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c | 14 ++--- src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c | 4 +- src/overlays/actors/ovl_En_Bb/z_en_bb.c | 2 +- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 4 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 20 +++---- .../actors/ovl_En_Dodongo/z_en_dodongo.c | 4 +- src/overlays/actors/ovl_En_Famos/z_en_famos.c | 25 ++++---- src/overlays/actors/ovl_En_Fish/z_en_fish.c | 8 +-- .../actors/ovl_En_Fu_Mato/z_en_fu_mato.c | 2 +- .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 10 ++-- .../actors/ovl_En_Hakurock/z_en_hakurock.c | 20 +++---- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 2 +- src/overlays/actors/ovl_En_Ishi/z_en_ishi.c | 6 +- .../actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c | 2 +- src/overlays/actors/ovl_En_Kame/z_en_kame.c | 2 +- .../actors/ovl_En_Kendo_Js/z_en_kendo_js.c | 4 +- src/overlays/actors/ovl_En_Kusa/z_en_kusa.c | 12 ++-- src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c | 54 ++++++++--------- .../actors/ovl_En_Minislime/z_en_minislime.c | 12 ++-- .../actors/ovl_En_Mushi2/z_en_mushi2.c | 8 +-- .../actors/ovl_En_Peehat/z_en_peehat.c | 2 +- src/overlays/actors/ovl_En_Skb/z_en_skb.c | 2 +- .../actors/ovl_En_Snowman/z_en_snowman.c | 8 +-- .../actors/ovl_En_Thiefbird/z_en_thiefbird.c | 2 +- .../actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c | 4 +- .../actors/ovl_Obj_Dhouse/z_obj_dhouse.c | 36 +++++------ .../ovl_Obj_Flowerpot/z_obj_flowerpot.c | 12 ++-- .../actors/ovl_Obj_Grass/z_obj_grass.c | 10 ++-- .../actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c | 2 +- .../actors/ovl_Obj_Hamishi/z_obj_hamishi.c | 2 +- .../ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c | 4 +- .../actors/ovl_Obj_Iceblock/z_obj_iceblock.c | 6 +- .../actors/ovl_Obj_Kibako2/z_obj_kibako2.c | 2 +- .../actors/ovl_Obj_Snowball/z_obj_snowball.c | 10 ++-- .../ovl_Obj_Snowball2/z_obj_snowball2.c | 10 ++-- 43 files changed, 239 insertions(+), 228 deletions(-) diff --git a/include/functions.h b/include/functions.h index 92db30a01..7e01d5afe 100644 --- a/include/functions.h +++ b/include/functions.h @@ -171,7 +171,7 @@ f64 func_80086D6C(f64 param_1); s32 func_80086D8C(f32 param_1); s32 func_80086DAC(f64 param_1); -s32 Rand_Next(void); +u32 Rand_Next(void); void Rand_Seed(u32 seed); f32 Rand_ZeroOne(void); f32 Rand_Centered(void); diff --git a/src/boot_O2/rand.c b/src/boot_O2/rand.c index de603590e..2db64e9d5 100644 --- a/src/boot_O2/rand.c +++ b/src/boot_O2/rand.c @@ -1,33 +1,39 @@ #include "global.h" -// The latest generated random number, used to generate the next number in the sequence. +//! The latest generated random number, used to generate the next number in the sequence. static u32 sRandInt = 1; -// Space to store a value to be re-interpreted as a float. -// This can't be static because it is used in z_kankyo +//! Space to store a value to be re-interpreted as a float. +//! This can't be static because it is used in z_kankyo. u32 sRandFloat; +//! These values are recommended by the algorithms book *Numerical Recipes in C. The Art of Scientific Computing*, 2nd +//! Edition, 1992, ISBN 0-521-43108-5. (p. 284): +//! > This is about as good as any 32-bit linear congruential generator, entirely adequate for many uses. #define RAND_MULTIPLIER 1664525 #define RAND_INCREMENT 1013904223 /** - * Gets the next integer in the sequence of pseudo-random numbers. + * Generates the next pseudo-random integer. */ -s32 Rand_Next(void) { - return sRandInt = (sRandInt * 1664525) + 1013904223; +u32 Rand_Next(void) { + return sRandInt = (sRandInt * RAND_MULTIPLIER) + RAND_INCREMENT; } /** - * Seeds the pseudo-random number generator by providing a starting value. + * Seeds the internal pseudo-random number generator with a provided starting value. */ void Rand_Seed(u32 seed) { sRandInt = seed; } /** - * Returns a pseudo-random floating-point number between 0.0f and 1.0f, by generating - * the next integer and masking it to an IEEE-754 compliant floating-point number - * between 1.0f and 2.0f, returning the result subtract 1.0f. + * Returns a pseudo-random float between 0.0f and 1.0f from the internal PRNG. + * + * @note Works by generating the next integer, masking it to an IEEE-754 compliant float between 1.0f and 2.0f, and + * subtracting 1.0f. + * + * @remark This is also recommended by Numerical Recipes, pp. 284-5. */ f32 Rand_ZeroOne(void) { sRandInt = (sRandInt * RAND_MULTIPLIER) + RAND_INCREMENT; @@ -36,8 +42,7 @@ f32 Rand_ZeroOne(void) { } /** - * Returns a pseudo-random floating-point number between -0.5f and 0.5f by the same - * manner in which Rand_ZeroOne generates its result. + * Returns a pseudo-random float between -0.5f and 0.5f in the same way as Rand_ZeroOne(). */ f32 Rand_Centered(void) { sRandInt = (sRandInt * RAND_MULTIPLIER) + RAND_INCREMENT; @@ -45,40 +50,47 @@ f32 Rand_Centered(void) { return *((f32*)&sRandFloat) - 1.5f; } +//! All functions below are unused variants of the above four, that use a provided random number variable instead of the +//! internal `sRandInt` + /** - * Seeds a pseudo-random number at rndNum with a provided seed. + * Seeds a provided pseudo-random number with a provided starting value. + * + * @see Rand_Seed */ void Rand_Seed_Variable(u32* rndNum, u32 seed) { *rndNum = seed; } /** - * Generates the next pseudo-random integer from the provided rndNum. + * Generates the next pseudo-random number from the provided rndNum. + * + * @see Rand_Next */ u32 Rand_Next_Variable(u32* rndNum) { return *rndNum = (*rndNum * RAND_MULTIPLIER) + RAND_INCREMENT; } /** - * Generates the next pseudo-random floating-point number between 0.0f and - * 1.0f from the provided rndNum. + * Generates the next pseudo-random float between 0.0f and 1.0f from the provided rndNum. + * + * @see Rand_ZeroOne */ f32 Rand_ZeroOne_Variable(u32* rndNum) { u32 next = (*rndNum * RAND_MULTIPLIER) + RAND_INCREMENT; - // clang-format off - *rndNum = next; sRandFloat = (next >> 9) | 0x3F800000; - // clang-format on + + sRandFloat = ((*rndNum = next) >> 9) | 0x3F800000; return *((f32*)&sRandFloat) - 1.0f; } /** - * Generates the next pseudo-random floating-point number between -0.5f and - * 0.5f from the provided rndNum. + * Generates the next pseudo-random float between -0.5f and 0.5f from the provided rndNum. + * + * @see Rand_ZeroOne, Rand_Centered */ f32 Rand_Centered_Variable(u32* rndNum) { u32 next = (*rndNum * RAND_MULTIPLIER) + RAND_INCREMENT; - // clang-format off - *rndNum = next; sRandFloat = (next >> 9) | 0x3F800000; - // clang-format on + + sRandFloat = ((*rndNum = next) >> 9) | 0x3F800000; return *((f32*)&sRandFloat) - 1.5f; } diff --git a/src/code/sys_math_atan.c b/src/code/sys_math_atan.c index 09f355d64..d68e1e293 100644 --- a/src/code/sys_math_atan.c +++ b/src/code/sys_math_atan.c @@ -77,57 +77,57 @@ u16 sATan2Tbl[] = { 0x1FF6, 0x1FFB, 0x2000, }; -u16 Math_GetAtan2Tbl(f32 opposite, f32 adjacent) { - return sATan2Tbl[(s32)((opposite / adjacent) * 0x400)]; +u16 Math_GetAtan2Tbl(f32 y, f32 x) { + return sATan2Tbl[(s32)((y / x) * 0x400)]; } -s16 Math_Atan2S(f32 opposite, f32 adjacent) { +s16 Math_Atan2S(f32 y, f32 x) { s32 angle; - if (opposite == 0.0f) { - if (adjacent >= 0.0f) { + if (y == 0.0f) { + if (x >= 0.0f) { angle = 0; } else { angle = 0x8000; } - } else if (adjacent == 0.0f) { - if (opposite >= 0.0f) { + } else if (x == 0.0f) { + if (y >= 0.0f) { angle = 0x4000; } else { angle = 0xC000; } - } else if (opposite >= 0.0f) { - if (adjacent >= 0.0f) { - if (opposite <= adjacent) { - angle = Math_GetAtan2Tbl(opposite, adjacent); + } else if (y >= 0.0f) { + if (x >= 0.0f) { + if (y <= x) { + angle = Math_GetAtan2Tbl(y, x); } else { - angle = 0x4000 - Math_GetAtan2Tbl(adjacent, opposite); + angle = 0x4000 - Math_GetAtan2Tbl(x, y); } } else { - if (-adjacent < opposite) { - angle = Math_GetAtan2Tbl(-adjacent, opposite) + 0x4000; + if (-x < y) { + angle = Math_GetAtan2Tbl(-x, y) + 0x4000; } else { - angle = 0x8000 - Math_GetAtan2Tbl(opposite, -adjacent); + angle = 0x8000 - Math_GetAtan2Tbl(y, -x); } } - } else if (adjacent < 0.0f) { - if (-opposite <= -adjacent) { - angle = Math_GetAtan2Tbl(-opposite, -adjacent) + 0x8000; + } else if (x < 0.0f) { + if (-y <= -x) { + angle = Math_GetAtan2Tbl(-y, -x) + 0x8000; } else { - angle = 0xC000 - Math_GetAtan2Tbl(-adjacent, -opposite); + angle = 0xC000 - Math_GetAtan2Tbl(-x, -y); } } else { - if (adjacent < -opposite) { - angle = Math_GetAtan2Tbl(adjacent, -opposite) + 0xC000; + if (x < -y) { + angle = Math_GetAtan2Tbl(x, -y) + 0xC000; } else { - angle = -Math_GetAtan2Tbl(-opposite, adjacent); + angle = -Math_GetAtan2Tbl(-y, x); } } return angle; } -f32 Math_Atan2F(f32 opposite, f32 adjacent) { - return Math_Atan2S(opposite, adjacent) * (M_PI / 0x8000); +f32 Math_Atan2F(f32 y, f32 x) { + return Math_Atan2S(y, x) * (M_PI / 0x8000); } s16 Math_FAtan2F(f32 adjacent, f32 opposite) { diff --git a/src/code/z_actor.c b/src/code/z_actor.c index bbabeafd5..4e1e641de 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -4782,7 +4782,7 @@ void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos yaw = Actor_YawToPoint(actor, limbPos); for (j = 0; j < effectsPerLimb; j++) { - randomYaw = (Rand_Next() >> 0x13) + yaw; + randomYaw = ((s32)Rand_Next() >> 0x13) + yaw; velocity.z = Rand_ZeroFloat(5.0f); diff --git a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c index 6ac390ce5..2bcc31b5b 100644 --- a/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c +++ b/src/overlays/actors/ovl_Bg_Ctower_Gear/z_bg_ctower_gear.c @@ -78,7 +78,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { Matrix_RotateXS(this->dyna.actor.home.rot.x, MTXMODE_APPLY); Matrix_RotateZS(this->dyna.actor.home.rot.z, MTXMODE_APPLY); for (i = 0; i < 4; i++) { - if ((u32)Rand_Next() >= 0x40000000) { + if (Rand_Next() >= 0x40000000) { splashOffset.x = sExitSplashOffsets[i].x - (Rand_ZeroOne() * 30.0f); splashOffset.y = sExitSplashOffsets[i].y; splashOffset.z = sExitSplashOffsets[i].z; @@ -86,7 +86,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { splashSpawnPos.x += this->dyna.actor.world.pos.x + ((Rand_ZeroOne() * 20.0f) - 10.0f); splashSpawnPos.y += this->dyna.actor.world.pos.y; splashSpawnPos.z += this->dyna.actor.world.pos.z + ((Rand_ZeroOne() * 20.0f) - 10.0f); - EffectSsGSplash_Spawn(globalCtx, &splashSpawnPos, NULL, NULL, 0, ((u32)Rand_Next() >> 25) + 340); + EffectSsGSplash_Spawn(globalCtx, &splashSpawnPos, NULL, NULL, 0, (Rand_Next() >> 25) + 340); } } } @@ -104,7 +104,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { splashSpawnPos.x += this->dyna.actor.world.pos.x + ((Rand_ZeroOne() * 20.0f) - 10.0f); splashSpawnPos.y += this->dyna.actor.world.pos.y; splashSpawnPos.z += this->dyna.actor.world.pos.z + ((Rand_ZeroOne() * 20.0f) - 10.0f); - EffectSsGSplash_Spawn(globalCtx, &splashSpawnPos, NULL, NULL, 0, ((u32)Rand_Next() >> 25) + 280); + EffectSsGSplash_Spawn(globalCtx, &splashSpawnPos, NULL, NULL, 0, (Rand_Next() >> 25) + 280); } } } diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c index 0c5b92496..da3943141 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c @@ -276,7 +276,7 @@ void func_80B8296C(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2) { for (i = 0; i < ARRAY_COUNT(D_80B83A94); i++) { temp_f0 = Rand_ZeroOne(); temp_f20 = 1.0f - SQ(temp_f0); - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { temp_f20 = -temp_f20; } @@ -285,7 +285,7 @@ void func_80B8296C(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2) { temp_f0 = Rand_ZeroOne(); temp_f20 = 1.0f - SQ(temp_f0); - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { temp_f20 = -temp_f20; } sp60.z = (temp_f20 * arg2) + arg1->z; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c index fcec4ebb3..a9777972d 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c @@ -295,7 +295,7 @@ void func_80B84610(BgDblueWaterfall* this, GlobalContext* globalCtx) { if (this->unk_1A7 <= 0) { this->unk_1A7 = 16; } else { - this->unk_1A7 -= (s8)((u32)Rand_Next() >> 0x1F); + this->unk_1A7 -= (s8)(Rand_Next() >> 0x1F); } if (this->unk_1A7 >= 6) { diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c index 20d68e7a4..1103c6d81 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.c @@ -138,7 +138,7 @@ void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { for (i = 0; i < 6; i++) { temp = (i + 1) * (80.0f / 3.0f); for (j = 0; j < ARRAY_COUNT(D_80ABD020); j++) { - spD8.x = D_80ABD020[j] + (s32)((u32)Rand_Next() >> 0x1C); + spD8.x = D_80ABD020[j] + (s32)(Rand_Next() >> 0x1C); spD8.y = ((Rand_ZeroOne() - 0.5f) * 15.0f) + temp; spD8.z = (Rand_ZeroOne() * 20.0f) - 10.0f; @@ -159,11 +159,11 @@ void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { phi_s0 = 64; } - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 |= 1; phi_s1 = 1; func_800B0E48(globalCtx, &spF0, &gZeroVec3f, &D_80ABCFB4, &D_80ABCFAC, &D_80ABCFB0, - ((u32)Rand_Next() >> 0x1B) + 70, ((u32)Rand_Next() >> 0x1A) + 60); + (Rand_Next() >> 0x1B) + 70, (Rand_Next() >> 0x1A) + 60); } else { phi_s1 = 0; } @@ -224,7 +224,7 @@ void func_80ABC2E0(BgHakuginBombwall* this, GlobalContext* globalCtx) { if ((i & 1) == 0) { func_800B0E48(globalCtx, &spC8, &D_80ABD034, &D_80ABCFB4, &D_80ABCFAC, &D_80ABCFB0, - ((u32)Rand_Next() >> 0x1B) + 60, ((u32)Rand_Next() >> 0x1A) + 50); + (Rand_Next() >> 0x1B) + 60, (Rand_Next() >> 0x1A) + 50); } } } @@ -269,8 +269,8 @@ void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx) { spC0.y += this->dyna.actor.world.pos.y; spC0.z += this->dyna.actor.world.pos.z; - func_800B0E48(globalCtx, &spC0, &spCC, &spD8, &D_80ABCFAC, &D_80ABCFB0, ((u32)Rand_Next() >> 0x1A) + 60, - ((u32)Rand_Next() >> 0x1B) + 60); + func_800B0E48(globalCtx, &spC0, &spCC, &spD8, &D_80ABCFAC, &D_80ABCFB0, (Rand_Next() >> 0x1A) + 60, + (Rand_Next() >> 0x1B) + 60); } } @@ -303,8 +303,8 @@ void func_80ABC7FC(BgHakuginBombwall* this, GlobalContext* globalCtx) { spB8.x = spAC.x * -0.095f; spB8.z = spAC.z * -0.095f; - func_800B0E48(globalCtx, &spA0, &spAC, &spB8, &D_80ABCFAC, &D_80ABCFB0, ((u32)Rand_Next() >> 0x1A) + 60, - ((u32)Rand_Next() >> 0x1B) + 60); + func_800B0E48(globalCtx, &spA0, &spAC, &spB8, &D_80ABCFAC, &D_80ABCFB0, (Rand_Next() >> 0x1A) + 60, + (Rand_Next() >> 0x1B) + 60); } } diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index a7f20b7b4..f0831055f 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -343,9 +343,9 @@ void func_80A9B554(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU temp_f0 = spAC.z; unkStruct2->unk_10.z = ((Rand_ZeroOne() * 60.0f - 30.0f) + temp_f28 * 50.0f) * temp_f22 + temp_f0 * temp_f20; unkStruct2->unk_1C = 0.90999997f - (0.04f - unkStruct2->unk_00) * (500.0f / 19.0f) * 0.02f; - unkStruct2->unk_20.x = Rand_Next() >> 0x10; - unkStruct2->unk_20.y = Rand_Next() >> 0x10; - unkStruct2->unk_20.z = Rand_Next() >> 0x10; + unkStruct2->unk_20.x = (s32)Rand_Next() >> 0x10; + unkStruct2->unk_20.y = (s32)Rand_Next() >> 0x10; + unkStruct2->unk_20.z = (s32)Rand_Next() >> 0x10; unkStruct2->unk_26 = (Rand_Next() & 0x3FFF) - 0x1FFF; unkStruct2->unk_28 = (Rand_Next() & 0x1FFF) - 0xFFF; unkStruct2->unk_2A = (Rand_Next() & 0x1FFF) - 0xFFF; @@ -359,7 +359,7 @@ void func_80A9B554(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU spA0.y = (Rand_ZeroOne() * 1.2f - 0.1f) * spE4 + spB8.y; spA0.z = Math_CosS(val) * temp_f20 + spB8.z; func_800B0E48(globalCtx, &spA0, &gZeroVec3f, &D_80A9D8EC, &D_80A9D8E4, &D_80A9D8E8, - (Rand_Next() >> 0x1A) + 0x82, (Rand_Next() >> 0x1A) + 0x6E); + ((s32)Rand_Next() >> 0x1A) + 0x82, ((s32)Rand_Next() >> 0x1A) + 0x6E); } unkStruct1Temp = func_80A9B32C(unkStruct, unkStruct1); @@ -386,9 +386,9 @@ void func_80A9B554(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostU unkStruct2->unk_10.y = 0.0f; unkStruct2->unk_10.z = Rand_ZeroOne() + temp_f28 * 7.0f; unkStruct2->unk_1C = 0.90999997f - (0.04f - unkStruct2->unk_00) * (500.0f / 19.0f) * 0.075f; - unkStruct2->unk_20.x = Rand_Next() >> 0x10; - unkStruct2->unk_20.y = Rand_Next() >> 0x10; - unkStruct2->unk_20.z = Rand_Next() >> 0x10; + unkStruct2->unk_20.x = (s32)Rand_Next() >> 0x10; + unkStruct2->unk_20.y = (s32)Rand_Next() >> 0x10; + unkStruct2->unk_20.z = (s32)Rand_Next() >> 0x10; unkStruct2->unk_26 = (Rand_Next() & 0x1FFF) - 0xFFF; unkStruct2->unk_28 = (Rand_Next() & 0x1FFF) - 0xFFF; unkStruct2->unk_2A = (Rand_Next() & 0x1FFF) - 0xFFF; diff --git a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c index 71f1d2b6a..ccf8e2d43 100644 --- a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c +++ b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c @@ -47,7 +47,7 @@ void BgLotus_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &thisx->floorPoly, &bgId, &this->dyna.actor, &this->dyna.actor.world.pos); this->timer2 = 96; - this->dyna.actor.world.rot.y = Rand_Next() >> 0x10; + this->dyna.actor.world.rot.y = (s32)Rand_Next() >> 0x10; this->actionFunc = BgLotus_Wait; } @@ -82,7 +82,7 @@ void BgLotus_Wait(BgLotus* this, GlobalContext* globalCtx) { if (this->timer2 == 0) { this->timer2 = 96; - this->dyna.actor.world.rot.y += (s16)(Rand_Next() >> 0x12); + this->dyna.actor.world.rot.y += (s16)((s32)Rand_Next() >> 0x12); } } diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index f48976cd6..65d582eb3 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -241,7 +241,7 @@ void EnBb_SetupFlyIdle(EnBb* this) { if ((this->actor.xzDistToPlayer < (this->attackRange + 120.0f)) || (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 300.0f)) { - this->targetYRotation += (s16)(Rand_Next() >> 0x11); + this->targetYRotation += (s16)((s32)Rand_Next() >> 0x11); } this->collider.base.atFlags |= AT_ON; diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index acf465f83..4c4261a4c 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -505,7 +505,7 @@ void EnBigpo_WarpingOut(EnBigpo* this, GlobalContext* globalCtx) { void EnBigpo_SetupWarpIn(EnBigpo* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); f32 distance = CLAMP_MIN(this->actor.xzDistToPlayer, 200.0f); - s16 randomYaw = (Rand_Next() >> 0x14) + this->actor.yawTowardsPlayer; + s16 randomYaw = ((s32)Rand_Next() >> 0x14) + this->actor.yawTowardsPlayer; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKIDS_APPEAR); Animation_PlayLoop(&this->skelAnime, &gBigpoAwakenStretchAnim); @@ -565,7 +565,7 @@ void EnBigpo_IdleFlying(EnBigpo* this, GlobalContext* globalCtx) { } if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->unk208, 0x200) && (Rand_ZeroOne() < 0.075f)) { - this->unk208 += (s16)((((u32)Rand_Next() >> 0x14) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); + this->unk208 += (s16)(((Rand_Next() >> 0x14) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); } this->actor.world.rot.y = this->actor.shape.rot.y; diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index 1a507b5b6..0e3c9b20a 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -2089,9 +2089,9 @@ void EnBigslime_SetupIdleLookAround(EnBigslime* this) { this->idleTimer = 60; this->actor.speedXZ = 0.0f; if (BINANG_SUB(Actor_YawToPoint(&this->actor, &this->actor.home.pos), this->gekkoRot.y) > 0) { - this->gekkoYaw = this->gekkoRot.y + ((u32)Rand_Next() >> 20) + 0x2000; + this->gekkoYaw = this->gekkoRot.y + (Rand_Next() >> 20) + 0x2000; } else { - this->gekkoYaw = this->gekkoRot.y - ((u32)Rand_Next() >> 20) - 0x2000; + this->gekkoYaw = this->gekkoRot.y - (Rand_Next() >> 20) - 0x2000; } this->actionFunc = EnBigslime_IdleLookAround; } @@ -2111,9 +2111,9 @@ void EnBigslime_IdleLookAround(EnBigslime* this, GlobalContext* globalCtx) { if ((this->skelAnime.animation == &gGekkoNervousIdleAnim) && Math_ScaledStepToS(&this->gekkoRot.y, this->gekkoYaw, 0x400)) { if (BINANG_SUB(Actor_YawToPoint(&this->actor, &this->actor.home.pos), this->gekkoRot.y) > 0) { - this->gekkoYaw = this->gekkoRot.y + ((u32)Rand_Next() >> 20) + 0x2000; + this->gekkoYaw = this->gekkoRot.y + (Rand_Next() >> 20) + 0x2000; } else { - this->gekkoYaw = this->gekkoRot.y - ((u32)Rand_Next() >> 20) - 0x2000; + this->gekkoYaw = this->gekkoRot.y - (Rand_Next() >> 20) - 0x2000; } } @@ -2700,9 +2700,9 @@ void EnBigslime_AddIceShardEffect(EnBigslime* this, GlobalContext* globalCtx) { iceShardEffect->pos.x = (targetVtx->n.ob[0] * this->actor.scale.x) + this->actor.world.pos.x; iceShardEffect->pos.y = (targetVtx->n.ob[1] * this->actor.scale.y) + this->actor.world.pos.y; iceShardEffect->pos.z = (targetVtx->n.ob[2] * this->actor.scale.z) + this->actor.world.pos.z; - iceShardEffect->rotation.x = Rand_Next() >> 0x10; - iceShardEffect->rotation.y = Rand_Next() >> 0x10; - iceShardEffect->rotation.z = Rand_Next() >> 0x10; + iceShardEffect->rotation.x = (s32)Rand_Next() >> 0x10; + iceShardEffect->rotation.y = (s32)Rand_Next() >> 0x10; + iceShardEffect->rotation.z = (s32)Rand_Next() >> 0x10; iceShardEffect->isActive = true; randPitch = Rand_S16Offset(0x1000, 0x3000); vtxZ = targetVtx->n.ob[2]; @@ -2742,9 +2742,9 @@ void EnBigslime_UpdateEffects(EnBigslime* this) { if (iceShardEffect->pos.y < (GBT_ROOM_5_MIN_Y - 20.0f)) { iceShardEffect->isActive = false; } - iceShardEffect->rotation.x += (s16)(((u32)Rand_Next() >> 0x17) + 0x700); - iceShardEffect->rotation.y += (s16)(((u32)Rand_Next() >> 0x17) + 0x900); - iceShardEffect->rotation.z += (s16)(((u32)Rand_Next() >> 0x17) + 0xB00); + iceShardEffect->rotation.x += (s16)((Rand_Next() >> 0x17) + 0x700); + iceShardEffect->rotation.y += (s16)((Rand_Next() >> 0x17) + 0x900); + iceShardEffect->rotation.z += (s16)((Rand_Next() >> 0x17) + 0xB00); } } diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c index 914ee2bca..c31b534a1 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -449,7 +449,7 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { f32 temp_f20; Math_Vec3f_Copy(&sp68, &this->limbPos[0]); - sp66 = (Rand_Next() >> 0x12) + this->actor.shape.rot.y; + sp66 = ((s32)Rand_Next() >> 0x12) + this->actor.shape.rot.y; temp_f20 = Math_CosS(sp66); temp_f22 = Math_SinS(sp66); @@ -482,7 +482,7 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { sp62 = this->unk_334 * 25.0f; func_800B0EB0(globalCtx, &sp68, &sp80, &sp74, &this->unk_32C, &this->unk_330, sp64, sp62, 0x14); - sp66 = ((u32)Rand_Next() >> 0x13) + this->actor.shape.rot.y; + sp66 = (Rand_Next() >> 0x13) + this->actor.shape.rot.y; temp_f20 = Math_CosS(sp66); temp_f22 = Math_SinS(sp66); diff --git a/src/overlays/actors/ovl_En_Famos/z_en_famos.c b/src/overlays/actors/ovl_En_Famos/z_en_famos.c index 42ff95aba..32ce1988f 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.c +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.c @@ -226,15 +226,15 @@ void EnFamos_SetupAttackDebris(EnFamos* this) { this->debrisTimer = 40; rock = &this->rocks[0]; for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { - randVelDirection = Rand_Next() >> 0x10; + randVelDirection = (s32)Rand_Next() >> 0x10; randOffset = Rand_S16Offset(0x1800, 0x2800); randFloat = Rand_ZeroFloat(5.0f) + 5.0f; rock->velocity.x = randFloat * Math_CosS(randOffset) * Math_SinS(randVelDirection); rock->velocity.y = Math_SinS(randOffset) * randFloat + 3.0f; rock->velocity.z = randFloat * Math_CosS(randOffset) * Math_CosS(randVelDirection); - rock->rotation.x = Rand_Next() >> 0x10; - rock->rotation.y = Rand_Next() >> 0x10; - rock->rotation.z = Rand_Next() >> 0x10; + rock->rotation.x = (s32)Rand_Next() >> 0x10; + rock->rotation.y = (s32)Rand_Next() >> 0x10; + rock->rotation.z = (s32)Rand_Next() >> 0x10; rock->pos.x = (Math_SinS(randVelDirection) * 20.0f) + this->actor.world.pos.x; rock->pos.y = this->actor.floorHeight; rock->pos.z = (Math_CosS(randVelDirection) * 20.0f) + this->actor.world.pos.z; @@ -255,15 +255,15 @@ void EnFamos_SetupDeathDebris(EnFamos* this) { this->debrisTimer = 40; rock = &this->rocks[0]; for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { - randVelDirection = Rand_Next() >> 0x10; - randSmaller = (u32)Rand_Next() >> 0x12; + randVelDirection = (s32)Rand_Next() >> 0x10; + randSmaller = Rand_Next() >> 0x12; randFloat = Rand_ZeroFloat(6.0f) + 7.0f; rock->velocity.x = randFloat * Math_CosS(randSmaller) * Math_SinS(randVelDirection); rock->velocity.y = Math_SinS(randSmaller) * randFloat + 4.5f; rock->velocity.z = randFloat * Math_CosS(randSmaller) * Math_CosS(randVelDirection); - rock->rotation.x = Rand_Next() >> 0x10; - rock->rotation.y = Rand_Next() >> 0x10; - rock->rotation.z = Rand_Next() >> 0x10; + rock->rotation.x = (s32)Rand_Next() >> 0x10; + rock->rotation.y = (s32)Rand_Next() >> 0x10; + rock->rotation.z = (s32)Rand_Next() >> 0x10; rock->pos.x = Math_SinS(randVelDirection) * 20.0f + this->actor.world.pos.x; rock->pos.y = randPlusMinusPoint5Scaled(60.0f) + (this->actor.world.pos.y + 40.0f); rock->pos.z = Math_CosS(randVelDirection) * 20.0f + this->actor.world.pos.z; @@ -735,10 +735,9 @@ void EnFamos_UpdateDebrisPosRot(EnFamos* this) { for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { rock->velocity.y -= 1.0f; Math_Vec3f_Sum(&rock->pos, &rock->velocity, &rock->pos); - // all casts seem required - rock->rotation.x += (s16)(((u32)Rand_Next() >> 0x17) + 0x700); - rock->rotation.y += (s16)(((u32)Rand_Next() >> 0x17) + 0x900); - rock->rotation.z += (s16)(((u32)Rand_Next() >> 0x17) + 0xB00); + rock->rotation.x += (s16)((Rand_Next() >> 0x17) + 0x700); + rock->rotation.y += (s16)((Rand_Next() >> 0x17) + 0x900); + rock->rotation.z += (s16)((Rand_Next() >> 0x17) + 0xB00); } } diff --git a/src/overlays/actors/ovl_En_Fish/z_en_fish.c b/src/overlays/actors/ovl_En_Fish/z_en_fish.c index 6c9f813fd..d456f48ed 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.c +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.c @@ -210,8 +210,8 @@ void EnFish_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); this->actor.colChkInfo.mass = this->unk_25C * 30.0f; - this->unk_244 = (u32)Rand_Next() >> 0x10; - this->unk_246 = (u32)Rand_Next() >> 0x10; + this->unk_244 = Rand_Next() >> 0x10; + this->unk_246 = Rand_Next() >> 0x10; if (sp36 == ENFISH_0) { this->actor.flags |= ACTOR_FLAG_10; @@ -707,12 +707,12 @@ void func_8091EFE8(Actor* thisx, GlobalContext* globalCtx) { this->actor.speedXZ *= 0.5f; } - if (!((u32)Rand_Next() >> 0x1B) || ((this->actor.bgCheckFlags & 8) && !((u32)Rand_Next() >> 0x1E)) || + if (((Rand_Next() >> 0x1B) == 0) || ((this->actor.bgCheckFlags & 8) && ((Rand_Next() >> 0x1E) == 0)) || !(this->actor.bgCheckFlags & 0x20)) { temp_f0 = Rand_ZeroOne(); sp34 = (1.0f - SQ(temp_f0)) * sp3C->home.rot.x; sp30 = Rand_ZeroOne() * sp3C->home.rot.z; - sp2E = (u32)Rand_Next() >> 0x10; + sp2E = Rand_Next() >> 0x10; this->actor.home.pos.x = (Math_SinS(sp2E) * sp34) + sp3C->world.pos.x; this->actor.home.pos.y = sp3C->world.pos.y + sp30; this->actor.home.pos.z = (Math_CosS(sp2E) * sp34) + sp3C->world.pos.z; diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c index 4591eab65..7fe1d6e58 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.c @@ -201,7 +201,7 @@ void func_80ACE850(EnFuMato* this, GlobalContext* globalCtx) { s32 phi_s2; s32 i; - this->unk_308 = (u32)Rand_Next() % ARRAY_COUNT(this->unk_1B8); + this->unk_308 = Rand_Next() % ARRAY_COUNT(this->unk_1B8); this->unk_302 = 1; this->dyna.actor.gravity = -1.0f; this->dyna.actor.velocity.y = Rand_ZeroOne(); 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 f17a75f6a..e4b822546 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -599,7 +599,7 @@ void func_8093FC6C(EnGoroiwa* this, GlobalContext* globalCtx) { temp = 0x10000 / sp80; for (i = 0, phi_s0 = 0; i < sp80; i++, phi_s0 += temp) { - temp_s3 = (u32)Rand_Next() >> 0x10; + temp_s3 = Rand_Next() >> 0x10; temp_f20 = Math_SinS(temp_s3); temp_f22 = Math_CosS(temp_s3); @@ -701,7 +701,7 @@ void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { phi_s1 = D_80942E0C[sp120][0]; phi_s3 = 1; phi_f22 = 0.8f; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -779,7 +779,7 @@ void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGB phi_s7 = arg2[0]; phi_fp = -0x190; spC8 = 1; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -856,7 +856,7 @@ void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA if ((i & 3) == 1) { phi_s1 = arg2[1]; phi_s2 = -0x154; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -864,7 +864,7 @@ void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA } else { phi_s1 = arg2[0]; phi_s2 = -0x190; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; diff --git a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c index d8551103d..63da6c329 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -102,7 +102,7 @@ void func_80B21BE0(BossHakugin* parent, Vec3f* arg1, s32 arg2) { Math_Vec3f_Copy(&gohtParticle->unk_0, arg1); sp2C = Rand_S16Offset(0x1000, 0x3000); - sp2E = (u32)Rand_Next() >> 0x10; + sp2E = Rand_Next() >> 0x10; sp28 = Rand_ZeroFloat(5.0f) + 10.0f; gohtParticle->unk_C.x = (sp28 * Math_CosS(sp2C)) * Math_SinS(sp2E); gohtParticle->unk_C.y = (Math_SinS(sp2C) * sp28); @@ -120,9 +120,9 @@ void func_80B21BE0(BossHakugin* parent, Vec3f* arg1, s32 arg2) { gohtParticle->unk_0.z = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtParticle->unk_C.z) + arg1->z; gohtParticle->unk_1A = 0; } - gohtParticle->unk_1C.x = Rand_Next() >> 0x10; - gohtParticle->unk_1C.y = Rand_Next() >> 0x10; - gohtParticle->unk_1C.z = Rand_Next() >> 0x10; + gohtParticle->unk_1C.x = (s32)Rand_Next() >> 0x10; + gohtParticle->unk_1C.y = (s32)Rand_Next() >> 0x10; + gohtParticle->unk_1C.z = (s32)Rand_Next() >> 0x10; gohtParticle->unk_18 = 0x28; return; } @@ -189,10 +189,10 @@ void func_80B220A8(EnHakurock* this) { this->actor.speedXZ = Rand_ZeroFloat(3.5f) + 2.5f; this->actor.velocity.y = Rand_ZeroFloat(4.5f) + 18.0f; Actor_SetScale(&this->actor, (Rand_ZeroFloat(5.0f) + 15.0f) * 0.001f); - this->actor.world.rot.y = (Rand_Next() >> 0x12) + this->actor.parent->shape.rot.y + 0x8000; - this->actor.shape.rot.x = Rand_Next() >> 0x10; - this->actor.shape.rot.y = Rand_Next() >> 0x10; - this->actor.shape.rot.z = Rand_Next() >> 0x10; + this->actor.world.rot.y = ((s32)Rand_Next() >> 0x12) + this->actor.parent->shape.rot.y + 0x8000; + this->actor.shape.rot.x = (s32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = (s32)Rand_Next() >> 0x10; + this->actor.shape.rot.z = (s32)Rand_Next() >> 0x10; this->collider.dim.radius = (this->actor.scale.x * 2500.0f); this->collider.dim.yShift = -this->collider.dim.radius; this->collider.dim.height = this->collider.dim.radius * 2; @@ -222,8 +222,8 @@ void func_80B222AC(EnHakurock* this, GlobalContext* globalCtx) { s16 angle; this->actor.draw = EnHakurock_Draw; - angle = (Rand_Next() >> 0x13) + player->actor.shape.rot.y; - this->actor.shape.rot.y = Rand_Next() >> 0x10; + angle = ((s32)Rand_Next() >> 0x13) + player->actor.shape.rot.y; + this->actor.shape.rot.y = (s32)Rand_Next() >> 0x10; this->actor.world.pos.x = (Math_SinS(angle) * 600.0f) + player->actor.world.pos.x; this->actor.world.pos.y = player->actor.world.pos.y + 700.0f; this->actor.world.pos.z = (Math_CosS(angle) * 600.0f) + player->actor.world.pos.z; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 2eace7815..4c9dcc0e8 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -2656,7 +2656,7 @@ void func_80B48AD4(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->actionTimer > 0) { temp_v1_3 = this->actionTimer & 0x1F; if ((temp_v1_3 == 0) && (Rand_ZeroOne() < 0.3f)) { - temp_v1_3 = Rand_Next() % 4; + temp_v1_3 = (s32)Rand_Next() % 4; if (temp_v1_3 != this->rand) { this->rand = temp_v1_3; if (this->rand == 0) { diff --git a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c index 9b60a41dd..6f29acf4a 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -203,8 +203,8 @@ void func_8095D804(Actor* thisx, GlobalContext* globalCtx) { spC4.y += (Rand_ZeroOne() * 7.0f) + 6.0f; spC4.z += (Rand_ZeroOne() - 0.5f) * 11.0f; - EffectSsKakera_Spawn(globalCtx, &spB8, &spC4, &spB8, -420, (Rand_Next() > 0) ? 65 : 33, 30, 5, 0, D_8095F74C[i], - 3, 10, 40, -1, temp, phi_s4); + EffectSsKakera_Spawn(globalCtx, &spB8, &spC4, &spB8, -420, ((s32)Rand_Next() > 0) ? 65 : 33, 30, 5, 0, + D_8095F74C[i], 3, 10, 40, -1, temp, phi_s4); } } @@ -389,7 +389,7 @@ void EnIshi_Init(Actor* thisx, GlobalContext* globalCtx) { } if ((this->actor.shape.rot.y == 0) && !(this->unk_197 & 2)) { - this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = this->actor.world.rot.y = Rand_Next() >> 0x10; } Actor_SetScale(&this->actor, D_8095F6B8[sp34]); 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 c16fa4147..9e00b09e4 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 @@ -313,7 +313,7 @@ void func_80C14230(EnJgameTsn* this, GlobalContext* globalCtx) { s32 rand; if ((this->unk_2FC > 100) || func_80C14BCC(this, globalCtx)) { - rand = (u32)Rand_Next() % 3; + rand = Rand_Next() % 3; this->unk_2FC = 0; if (rand < this->unk_218) { 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 d2a1f9902..ab3e8531f 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -230,7 +230,7 @@ void func_80AD7254(EnKame* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->unk_2A4, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 40.0f) { - this->unk_2A4 = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + (Rand_Next() >> 0x14); + this->unk_2A4 = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + ((s32)Rand_Next() >> 0x14); } this->unk_29E--; 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 92053374a..5b32a556b 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 @@ -600,8 +600,8 @@ void func_80B274BC(EnKendoJs* this, GlobalContext* globalCtx) { } play_sound(NA_SE_SY_FOUND); - func_80B279F0(this, globalCtx, ((Rand_Next() & 0xFF) % 3) + 1); - func_80B279F0(this, globalCtx, ((Rand_Next() & 0xFF) % 3) + 4); + func_80B279F0(this, globalCtx, (((s32)Rand_Next() & 0xFF) % 3) + 1); + func_80B279F0(this, globalCtx, (((s32)Rand_Next() & 0xFF) % 3) + 4); this->unk_290 = 0; this->unk_284++; } else if (this->unk_290 == 120) { 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 1767f3c86..fb20fcd67 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -381,7 +381,7 @@ void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = ((u32)Rand_Next() >> 0x10); + this->actor.shape.rot.y = (Rand_Next() >> 0x10); this->actor.home.rot.y = this->actor.shape.rot.y; this->actor.world.rot.y = this->actor.shape.rot.y; } @@ -401,11 +401,11 @@ void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx) { EnKusa_SetupWaitObject(this); if (D_809366B4) { - D_80936CD8 = ((u32)Rand_Next() >> 0x10); - D_80936CDA = ((u32)Rand_Next() >> 0x10); - D_80936CDC = ((u32)Rand_Next() >> 0x10); - D_80936CDE = ((u32)Rand_Next() >> 0x10); - D_80936CE0 = ((u32)Rand_Next() >> 0x10); + D_80936CD8 = Rand_Next() >> 0x10; + D_80936CDA = Rand_Next() >> 0x10; + D_80936CDC = Rand_Next() >> 0x10; + D_80936CDE = Rand_Next() >> 0x10; + D_80936CE0 = Rand_Next() >> 0x10; D_809366B4 = false; EnKusa_Sway(); kusaGameplayFrames = globalCtx->gameplayFrames; diff --git a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c index 6ba532cef..8852319df 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -102,7 +102,7 @@ void func_80A5B160(EnKusa2* this, GlobalContext* globalCtx) { ptr = this->unk_194; actor = (EnKusa2*)Actor_SpawnAsChildAndCutscene( &globalCtx->actorCtx, globalCtx, ACTOR_EN_KUSA2, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, (u32)Rand_Next() >> 0x10, 0, 1, this->actor.cutscene, this->actor.unk20, NULL); + this->actor.world.pos.z, 0, Rand_Next() >> 0x10, 0, 1, this->actor.cutscene, this->actor.unk20, NULL); *ptr = actor; if (*ptr != NULL) { @@ -117,8 +117,8 @@ void func_80A5B160(EnKusa2* this, GlobalContext* globalCtx) { ptr = &this->unk_194[i]; actor = (EnKusa2*)Actor_SpawnAsChildAndCutscene( &globalCtx->actorCtx, globalCtx, ACTOR_EN_KUSA2, (Math_SinS(temp_s1) * 80.0f) + this->actor.world.pos.x, - this->actor.world.pos.y, (Math_CosS(temp_s1) * 80.0f) + this->actor.world.pos.z, 0, - (u32)Rand_Next() >> 0x10, 0, 1, this->actor.cutscene, this->actor.unk20, NULL); + this->actor.world.pos.y, (Math_CosS(temp_s1) * 80.0f) + this->actor.world.pos.z, 0, Rand_Next() >> 0x10, + 0, 1, this->actor.cutscene, this->actor.unk20, NULL); *ptr = actor; if (*ptr != NULL) { (*ptr)->actor.room = this->actor.room; @@ -741,7 +741,7 @@ void func_80A5CD0C(EnKusa2* this) { s32 pad; for (i = 0; i < 2; i++) { - temp_s0 = (u32)Rand_Next() & 0xFFFF; + temp_s0 = Rand_Next() & 0xFFFF; temp_f20 = Rand_ZeroOne() * 30.0f; spA8.x = Math_SinS(temp_s0) * temp_f20; @@ -756,13 +756,13 @@ void func_80A5CD0C(EnKusa2* this) { spA8.y += this->actor.world.pos.y; spA8.z += this->actor.world.pos.z; - sp94.x = (u32)Rand_Next() & 0xFFFF; - sp94.y = (u32)Rand_Next() & 0xFFFF; - sp94.z = (u32)Rand_Next() & 0xFFFF; + sp94.x = Rand_Next() & 0xFFFF; + sp94.y = Rand_Next() & 0xFFFF; + sp94.z = Rand_Next() & 0xFFFF; - sp8C.x = ((u32)Rand_Next() % 0x4000) - 0x1FFF; - sp8C.y = ((u32)Rand_Next() % 0x2000) - 0xFFF; - sp8C.z = ((u32)Rand_Next() % 0x4000) - 0x1FFF; + sp8C.x = (Rand_Next() % 0x4000) - 0x1FFF; + sp8C.y = (Rand_Next() % 0x2000) - 0xFFF; + sp8C.z = (Rand_Next() % 0x4000) - 0x1FFF; func_80A5C2FC(&D_80A5F1C0, (Rand_ZeroOne() * 0.4f) + 0.02f, &spA8, &sp9C, &sp94, &sp8C); } @@ -779,7 +779,7 @@ void func_80A5CF44(EnKusa2* this) { s32 phi_s2; for (i = 0, phi_s2 = 0; i < 8; i++, phi_s2 += 0x2000) { - temp_s0 = ((u32)Rand_Next() % 0x2000) + phi_s2; + temp_s0 = (Rand_Next() % 0x2000) + phi_s2; temp_f20 = Rand_ZeroOne() * 30.0f; spA8.x = Math_SinS(temp_s0) * temp_f20; @@ -798,9 +798,9 @@ void func_80A5CF44(EnKusa2* this) { sp94.y = Rand_Next() & 0xFFFF; sp94.z = Rand_Next() & 0xFFFF; - sp8C.x = ((u32)Rand_Next() % 0x4000) - 0x1FFF; - sp8C.y = ((u32)Rand_Next() % 0x2000) - 0xFFF; - sp8C.z = ((u32)Rand_Next() % 0x4000) - 0x1FFF; + sp8C.x = (Rand_Next() % 0x4000) - 0x1FFF; + sp8C.y = (Rand_Next() % 0x2000) - 0xFFF; + sp8C.z = (Rand_Next() % 0x4000) - 0x1FFF; func_80A5C2FC(&D_80A5F1C0, (Rand_ZeroOne() * 0.45f) + 0.04f, &spA8, &sp9C, &sp94, &sp8C); } @@ -819,7 +819,7 @@ void func_80A5D178(EnKusa2* this) { s32 pad; for (i = 0; i < 8; i++) { - temp_s0 = (u32)Rand_Next(); + temp_s0 = Rand_Next(); temp_f22 = Math_SinS(temp_s0); temp_f20 = Math_CosS(temp_s0); temp_f24 = (Rand_ZeroOne() * 40.0f) + 10.0f; @@ -836,12 +836,12 @@ void func_80A5D178(EnKusa2* this) { spB0.y += this->actor.world.pos.y; spB0.z += this->actor.world.pos.z; - sp9C.x = (u32)Rand_Next() & 0xFFFF; - sp9C.y = (u32)Rand_Next() & 0xFFFF; - sp9C.z = (u32)Rand_Next() & 0xFFFF; + sp9C.x = Rand_Next() & 0xFFFF; + sp9C.y = Rand_Next() & 0xFFFF; + sp9C.z = Rand_Next() & 0xFFFF; sp94.x = Rand_S16Offset(-12000, 24000); - sp94.y = ((u32)Rand_Next() % 0x4000) - 0x1FFF; + sp94.y = (Rand_Next() % 0x4000) - 0x1FFF; sp94.z = Rand_S16Offset(-12000, 24000); func_80A5C2FC(&D_80A5F1C0, (Rand_ZeroOne() * 0.38f) + 0.02f, &spB0, &spA4, &sp9C, &sp94); } @@ -868,11 +868,11 @@ void EnKusa2_Init(Actor* thisx, GlobalContext* globalCtx) { D_80A5EAEC = 0; D_80A60900 = globalCtx->gameplayFrames; func_80A5CAD4(&D_80A5F1C0); - D_80A60B08 = (u32)Rand_Next() >> 0x10; - D_80A60B0A = (u32)Rand_Next() >> 0x10; - D_80A60B0C = (u32)Rand_Next() >> 0x10; - D_80A60B0E = (u32)Rand_Next() >> 0x10; - D_80A60B10 = (u32)Rand_Next() >> 0x10; + D_80A60B08 = Rand_Next() >> 0x10; + D_80A60B0A = Rand_Next() >> 0x10; + D_80A60B0C = Rand_Next() >> 0x10; + D_80A60B0E = Rand_Next() >> 0x10; + D_80A60B10 = Rand_Next() >> 0x10; func_80A5B508(); } func_80A5D5E0(this); @@ -1048,14 +1048,14 @@ void func_80A5D9C8(EnKusa2* this, GlobalContext* globalCtx) { sp30.y = this->actor.world.pos.y + 20.0f; sp30.z = this->actor.world.pos.z; - if ((u32)Rand_Next() < 0xFFFFFFF) { + if (Rand_Next() < 0xFFFFFFF) { func_80A5CD0C(this); } this->unk_1D0--; if (this->unk_1D0 <= 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KUSAMUSHI_VIBE); - this->unk_1D0 = ((u32)Rand_Next() >> 0x1D) + 14; + this->unk_1D0 = (Rand_Next() >> 0x1D) + 14; } this->actor.floorHeight = @@ -1152,7 +1152,7 @@ void func_80A5DEB4(EnKusa2* this, GlobalContext* globalCtx) { func_80A5BF38(this, 4); func_80A5BF84(this, globalCtx); - if ((u32)Rand_Next() < 0xFFFFFFF) { + if (Rand_Next() < 0xFFFFFFF) { func_80A5CD0C(this); } diff --git a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c index 4efc18714..68f587ba3 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -192,9 +192,9 @@ void EnMinislime_AddIceShardEffect(EnMinislime* this) { iceShardEffect->pos.y = this->actor.world.pos.y + (((iceShardEffect->vel.y * 2.0f) - 1.0f) * 400.0f * this->actor.scale.y); iceShardEffect->pos.z = this->actor.world.pos.z + (400.0f * this->actor.scale.z) * iceShardEffect->vel.z; - iceShardEffect->rotation.x = Rand_Next() >> 0x10; - iceShardEffect->rotation.y = Rand_Next() >> 0x10; - iceShardEffect->rotation.z = Rand_Next() >> 0x10; + iceShardEffect->rotation.x = (s32)Rand_Next() >> 0x10; + iceShardEffect->rotation.y = (s32)Rand_Next() >> 0x10; + iceShardEffect->rotation.z = (s32)Rand_Next() >> 0x10; iceShardEffect->isActive = true; Math_Vec3f_ScaleAndStore(&iceShardEffect->vel, Rand_ZeroFloat(3.0f) + 7.0f, &iceShardEffect->vel); iceShardEffect->scale = (Rand_ZeroFloat(6.0f) + 2.0f) * 0.001f; @@ -276,8 +276,8 @@ void EnMinislime_SetupBreakFromBigslime(EnMinislime* this) { this->actor.gravity = -1.0f; this->frozenScale = 0.1f; this->actor.world.rot.x = Rand_S16Offset(0x800, 0x800); - this->actor.shape.rot.x = (s16)(Rand_Next() >> 0x10); - this->actor.shape.rot.z = (s16)(Rand_Next() >> 0x10); + this->actor.shape.rot.x = (s32)Rand_Next() >> 0x10; + this->actor.shape.rot.z = (s32)Rand_Next() >> 0x10; this->actor.scale.x = 0.15f; this->actor.scale.y = 0.075f; this->actor.scale.z = 0.15f; @@ -437,7 +437,7 @@ void EnMinislime_Idle(EnMinislime* this, GlobalContext* globalCtx) { if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 200.0f) { this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); } else { - this->actor.world.rot.y += (s16)(Rand_Next() >> 19); + this->actor.world.rot.y += (s16)((s32)Rand_Next() >> 0x13); } } this->idleTimer = 20; diff --git a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c index 4afae5793..e08969c6b 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -618,7 +618,7 @@ void func_80A69ADC(Actor* thisx) { if (Rand_ZeroOne() < this->unk_358) { this->unk_366 = (sp44 >= 0.0f) ? 2000 : -2000; } else { - this->unk_366 = (Rand_Next() > 0) ? 2000 : -2000; + this->unk_366 = ((s32)Rand_Next() > 0) ? 2000 : -2000; } this->unk_366 += (s16)(((Rand_ZeroOne() * (1.0f - this->unk_358)) - 0.5f) * 0x400); } else { @@ -634,7 +634,7 @@ void func_80A69CE0(Actor* thisx) { this->unk_360 = Rand_ZeroOne() * 1500.0f; this->unk_364 = 0; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { this->unk_366 = 2000; } else { this->unk_366 = -2000; @@ -770,7 +770,7 @@ void EnMushi2_Init(Actor* thisx, GlobalContext* globalCtx) { if (sp3C != 0) { func_80A69F5C(&this->actor, globalCtx); - this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.world.rot.y = Rand_Next() >> 0x10; func_80A6AE14(this); } else { func_80A6A300(this); @@ -1034,7 +1034,7 @@ void func_80A6AE7C(EnMushi2* this, GlobalContext* globalCtx) { temp_f2 = this->actor.scale.x - (1.0f / 20000.0f); Actor_SetScale(&this->actor, CLAMP_MIN(temp_f2, 0.001f)); if ((this->actor.flags & ACTOR_FLAG_40) && (this->actor.depthInWater > 5.0f) && - (this->actor.depthInWater < 30.0f) && ((Rand_Next() & 0x1FF) < this->unk_368)) { + (this->actor.depthInWater < 30.0f) && ((s32)(Rand_Next() & 0x1FF) < this->unk_368)) { EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, -5.0f, 5.0f, 5.0f, ((Rand_ZeroOne() * 4.0f) + 2.0f) * this->actor.scale.x); } diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c index 708bae3ef..4f65a541c 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -249,7 +249,7 @@ void func_80897258(GlobalContext* globalCtx, EnPeehat* this, Vec3f* arg2, f32 ar static Vec3f D_80899558 = { 0.0f, 8.0f, 0.0f }; static Vec3f D_80899564 = { 0.0f, -1.5f, 0.0f }; Vec3f sp44; - s16 sp42 = Rand_Next() >> 0x10; + s16 sp42 = (s32)Rand_Next() >> 0x10; s32 temp_v1; sp44.y = this->actor.floorHeight; diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.c b/src/overlays/actors/ovl_En_Skb/z_en_skb.c index 6d3a118f4..c98c279ce 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -478,7 +478,7 @@ void func_8099556C(EnSkb* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 22.5f)) { - this->unk_3D4 = (u32)Rand_Next() % 0x7D0; + this->unk_3D4 = Rand_Next() % 0x7D0; } this->actor.shape.rot.x = Math_SinS(this->unk_3D4 * sp26) * 20000.0f; diff --git a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c index ef0ad1b57..2b579bf8d 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c @@ -319,7 +319,7 @@ void EnSnowman_SpawnBigSnowballFragmentEffects(EnSnowman* this, GlobalContext* g for (i = 0; i < 15; i++) { altitude = Rand_S16Offset(0x1800, 0x2800); - azimuth = ((u32)Rand_Next() >> 0x10); + azimuth = Rand_Next() >> 0x10; speed = Rand_ZeroFloat(3.0f) + 8.0f; velocity.x = (speed * Math_CosS(altitude)) * Math_SinS(azimuth); velocity.y = speed * Math_SinS(altitude); @@ -406,9 +406,9 @@ void EnSnowman_MoveSnowPile(EnSnowman* this, GlobalContext* globalCtx) { } else if (this->actor.bgCheckFlags & 8) { this->snowPileTargetRotY = this->actor.wallYaw; } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 200.0f) { - this->snowPileTargetRotY = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + (Rand_Next() >> 0x14); + this->snowPileTargetRotY = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + ((s32)Rand_Next() >> 0x14); } else if (Rand_ZeroOne() < 0.02f) { - this->snowPileTargetRotY += (s16)((((u32)Rand_Next() >> 0x13) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); + this->snowPileTargetRotY += (s16)(((Rand_Next() >> 0x13) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); } } @@ -746,7 +746,7 @@ void EnSnowman_Dead(EnSnowman* this, GlobalContext* globalCtx) { for (i = 0; i < 15; i++) { altitude = Rand_S16Offset(0x1000, 0x3000); - azimuth = ((u32)Rand_Next() >> 0x10); + azimuth = (Rand_Next() >> 0x10); speed = Rand_ZeroFloat(2.0f) + 4.0f; velocity.x = (speed * Math_CosS(altitude)) * Math_SinS(azimuth); velocity.y = speed * Math_SinS(altitude); diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c index faeb3163e..f64250240 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -196,7 +196,7 @@ void func_80C10984(EnThiefbird* this, s32 arg1) { ptr->unk_0C.z = randPlusMinusPoint5Scaled(5.0f); ptr->unk_1C = Rand_ZeroFloat(1000.0f); ptr->unk_18 = (Rand_ZeroFloat(20.0f) + 40.0f) * 0.0001f; - ptr->unk_1E = Rand_Next() >> 0x10; + ptr->unk_1E = (s32)Rand_Next() >> 0x10; arg1--; if (arg1 == 0) { break; diff --git a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c index 55304d195..8cf2039b4 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c @@ -193,7 +193,7 @@ void ObjBombiwa_Init(Actor* thisx, GlobalContext* globalCtx) { if (sp34 == OBJBOMBIWA_100_0) { if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = this->actor.world.rot.y = Rand_Next() >> 0x10; } func_80939594(this, globalCtx); } @@ -387,7 +387,7 @@ void func_8093A080(ObjBombiwa* this) { ptr->unk_10 = i + 3.0f; ptr->unk_14.x = phi_s2; - ptr->unk_14.y = (u32)Rand_Next() >> 0x10; + ptr->unk_14.y = Rand_Next() >> 0x10; ptr->unk_14.z = 0; ptr->unk_1A = 0; } diff --git a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c index c6eef8626..22df1af73 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c @@ -263,13 +263,13 @@ void func_80B12E7C(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr2->unk_18 = (Rand_ZeroOne() * 0.057f) + 0.003f; - ptr2->unk_1C.x = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.y = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.z = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.x = Rand_Next() >> 0x10; + ptr2->unk_1C.y = Rand_Next() >> 0x10; + ptr2->unk_1C.z = Rand_Next() >> 0x10; - ptr2->unk_22 = ((u32)Rand_Next() >> 0x11) - 0x3FFF; - ptr2->unk_24 = ((u32)Rand_Next() >> 0x13) - 0xFFF; - ptr2->unk_26 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_22 = (Rand_Next() >> 0x11) - 0x3FFF; + ptr2->unk_24 = (Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = (Rand_Next() >> 0x12) - 0x1FFF; ptr2->unk_29 = 0; ptr2->unk_28 = 40; @@ -307,13 +307,13 @@ void func_80B13170(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr2->unk_00.y = (ptr2->unk_00.y * 23.0f) + sp98.y + 15.0f; ptr2->unk_00.z = (ptr2->unk_00.z * 80.0f) + sp98.z; - ptr2->unk_1C.x = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.y = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.z = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.x = Rand_Next() >> 0x10; + ptr2->unk_1C.y = Rand_Next() >> 0x10; + ptr2->unk_1C.z = Rand_Next() >> 0x10; - ptr2->unk_22 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; - ptr2->unk_24 = ((u32)Rand_Next() >> 0x13) - 0xFFF; - ptr2->unk_26 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_22 = (Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_24 = (Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = (Rand_Next() >> 0x12) - 0x1FFF; ptr2->unk_28 = 40; @@ -356,13 +356,13 @@ void func_80B13474(ObjDhouse* this, GlobalContext* globalCtx, Vec3f* arg2) { ptr2->unk_00.y = ((ptr2->unk_00.y - 0.4f) * 20.0f) + arg2->y; ptr2->unk_00.z = (ptr2->unk_00.z * 40.0f) + arg2->z; - ptr2->unk_1C.x = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.y = (u32)Rand_Next() >> 0x10; - ptr2->unk_1C.z = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.x = Rand_Next() >> 0x10; + ptr2->unk_1C.y = Rand_Next() >> 0x10; + ptr2->unk_1C.z = Rand_Next() >> 0x10; - ptr2->unk_22 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; - ptr2->unk_24 = ((u32)Rand_Next() >> 0x13) - 0xFFF; - ptr2->unk_26 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_22 = (Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_24 = (Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = (Rand_Next() >> 0x12) - 0x1FFF; ptr2->unk_28 = 40; ptr2->unk_18 = (Rand_ZeroOne() * 0.07f) + 0.003f; diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c index 57964559d..d03912b14 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -399,7 +399,7 @@ void ObjFlowerpot_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = this->actor.world.rot.y = Rand_Next() >> 0x10; } Collider_InitJntSph(globalCtx, &this->collider); @@ -415,11 +415,11 @@ void ObjFlowerpot_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A1C818(this); if (D_80A1D404) { - D_80A1DA38 = (u32)Rand_Next() >> 0x10; - D_80A1DA3A = (u32)Rand_Next() >> 0x10; - D_80A1DA3C = (u32)Rand_Next() >> 0x10; - D_80A1DA3E = (u32)Rand_Next() >> 0x10; - D_80A1DA40 = (u32)Rand_Next() >> 0x10; + D_80A1DA38 = Rand_Next() >> 0x10; + D_80A1DA3A = Rand_Next() >> 0x10; + D_80A1DA3C = Rand_Next() >> 0x10; + D_80A1DA3E = Rand_Next() >> 0x10; + D_80A1DA40 = Rand_Next() >> 0x10; D_80A1D404 = false; func_80A1B3D0(); D_80A1D830 = globalCtx->gameplayFrames; diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c index 51f2febc7..705325429 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c @@ -146,11 +146,11 @@ void ObjGrass_Init(Actor* thisx, GlobalContext* globalCtx) { } this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->unk_3288 = (u32)Rand_Next() >> 0x10; - this->unk_328A = (u32)Rand_Next() >> 0x10; - this->unk_328C = (u32)Rand_Next() >> 0x10; - this->unk_328E = (u32)Rand_Next() >> 0x10; - this->unk_3290 = (u32)Rand_Next() >> 0x10; + this->unk_3288 = Rand_Next() >> 0x10; + this->unk_328A = Rand_Next() >> 0x10; + this->unk_328C = Rand_Next() >> 0x10; + this->unk_328E = Rand_Next() >> 0x10; + this->unk_3290 = Rand_Next() >> 0x10; } void ObjGrass_Destroy(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c index d3199e8d8..c6dac659e 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c @@ -389,7 +389,7 @@ void func_80B15264(ObjHakaisi* this) { Matrix_RotateZYX(Rand_Next(), Rand_Next(), Rand_Next(), MTXMODE_NEW); Matrix_MultVec3f(&D_80B15600, &this->unk_184); this->dyna.actor.gravity = -1.0f; - this->unk_19C = Rand_Next() >> 0x12; + this->unk_19C = (s32)Rand_Next() >> 0x12; this->dyna.actor.velocity.x = Math_SinS(sp32) * 4.0f; this->dyna.actor.velocity.z = Math_CosS(sp32) * 4.0f; this->dyna.actor.velocity.y = 7.0f; diff --git a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c index 10d8891ef..7b8377cee 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c @@ -170,7 +170,7 @@ void ObjHamishi_Init(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.shape.rot.y == 0) { - this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = Rand_Next() >> 0x10; this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.home.rot.y = this->actor.shape.rot.y; } diff --git a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c index 3fc7f84b1..c31eeb151 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -463,7 +463,7 @@ void func_80A54E10(ObjHugebombiwa* this) { ptr->unk_18 = (i * 1.04f) + 2.4f; ptr->unk_1C.x = phi_s2; - ptr->unk_1C.y = (u32)Rand_Next() >> 0x10; + ptr->unk_1C.y = Rand_Next() >> 0x10; ptr->unk_1C.z = 0; ptr->unk_22 = Rand_ZeroFloat(5000.0f); ptr->unk_24 = 0; @@ -558,7 +558,7 @@ void func_80A55310(ObjHugebombiwa* this) { ptr->unk_18 = (i * 1.04f) + 2.4f; ptr->unk_1C.x = phi_s2; - ptr->unk_1C.y = (u32)Rand_Next() >> 0x10; + ptr->unk_1C.y = Rand_Next() >> 0x10; ptr->unk_1C.z = 0; ptr->unk_22 = Rand_ZeroFloat(5000.0f); diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c index a4db0d04e..1a6d96c73 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -106,8 +106,8 @@ void func_80A2311C(Vec3f* arg0, Vec3f* arg1, s16 arg2) { void func_80A2319C(ObjIceblock* this, f32 arg1) { s32 i; - s16 temp_s1 = (u32)Rand_Next() >> 0x10; - s16 temp_s2 = (u32)Rand_Next() >> 0x10; + s16 temp_s1 = Rand_Next() >> 0x10; + s16 temp_s2 = Rand_Next() >> 0x10; ObjIceBlockUnkStruct* ptr; for (i = 0; i < ARRAY_COUNT(this->unk_1B4); i++) { @@ -1364,7 +1364,7 @@ void func_80A265C0(ObjIceblock* this, GlobalContext* globalCtx) { ptr->unk_0C = Rand_S16Offset(300, 300); ptr->unk_0E = Rand_S16Offset(900, 600); ptr->unk_04 = (2.0f * Rand_ZeroOne()) + 1.0f; - ptr->unk_14 = (u32)Rand_Next() >> 0x10; + ptr->unk_14 = Rand_Next() >> 0x10; func_80A24B74(this, globalCtx); } diff --git a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c index c0e5d8b4b..194989ad5 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c @@ -121,7 +121,7 @@ void ObjKibako2_SpawnSkulltula(ObjKibako2* this, GlobalContext* globalCtx) { if (ObjKibako2_ContainsSkulltula(this, globalCtx)) { actorSpawnParam = KIBAKO2_SKULLTULA_SPAWN_PARAM(&this->dyna.actor); - yRotation = ((u32)Rand_Next() >> 0x11) + this->dyna.actor.yawTowardsPlayer + 0xC000; + yRotation = (Rand_Next() >> 0x11) + this->dyna.actor.yawTowardsPlayer + 0xC000; skulltula = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SW, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, yRotation, 0, actorSpawnParam); diff --git a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c index 3979479f6..b3464d744 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c @@ -205,7 +205,7 @@ void func_80B030F8(ObjSnowball* this, GlobalContext* globalCtx) { gravity = -400; phi_s4 = 1; phi_f22 = 0.8f; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -245,7 +245,7 @@ void func_80B030F8(ObjSnowball* this, GlobalContext* globalCtx) { temp_f26 = this->unk_20C * 60.0f; for (i = 0, phi_s6 = 0; i < 16; i++, phi_s6 += 0x1000) { - temp_s0 = (u32)Rand_Next() >> 0x10; + temp_s0 = Rand_Next() >> 0x10; temp_f20 = Math_SinS(temp_s0); temp_f22 = Math_CosS(temp_s0); @@ -368,7 +368,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { temp_s1 = D_80B04FC8[0]; phi_s2 = -400; phi_s3 = 1; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -377,7 +377,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { temp_s1 = D_80B04FC8[1]; phi_s2 = -340; phi_s3 = 1; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -474,7 +474,7 @@ void ObjSnowball_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.y += 20.0f * phi_f20; this->actor.uncullZoneScale = 150.0f * phi_f20; this->actor.uncullZoneDownward = 300.0f * phi_f20; - this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = Rand_Next() >> 0x10; this->unk_20C = phi_f20; if (sp34) { diff --git a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c index 5356e2e88..3737a5426 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c @@ -145,7 +145,7 @@ void func_80B39108(ObjSnowball2* this, GlobalContext* globalCtx) { for (i = 0, phi_s5 = 0; i < 11; i++, phi_s5 += (0x10000 / 11)) { temp_s3 = (s32)(Rand_ZeroOne() * 5957.0f) + phi_s5; - if (((u32)Rand_Next() >> 0x1E) == 0) { + if ((Rand_Next() >> 0x1E) == 0) { phi_s1 = 0x20; } else { phi_s1 = 0x40; @@ -234,7 +234,7 @@ void func_80B39638(GlobalContext* globalCtx, Vec3f* arg1) { f32 temp_f2; s32 i; - D_80B3A938 += (s16)((u32)Rand_Next() >> 0x11); + D_80B3A938 += (s16)(Rand_Next() >> 0x11); for (i = 0; i < 2; i++) { D_80B3A938 += 0x8000; @@ -319,7 +319,7 @@ void ObjSnowball2_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitJntSph(globalCtx, &this->collider); this->actor.shape.rot.x = 0; this->actor.shape.rot.z = 0; - this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.shape.rot.y = Rand_Next() >> 0x10; ActorShape_Init(&this->actor.shape, 200.0f, NULL, 12.5f); this->actor.shape.shadowAlpha = 130; Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); @@ -480,7 +480,7 @@ void func_80B3A13C(ObjSnowball2* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 0x40) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); } - } else if ((((globalCtx->gameplayFrames % 16) == 0) || (((u32)Rand_Next() >> 0x10) == 0)) && + } else if ((((globalCtx->gameplayFrames % 16) == 0) || ((Rand_Next() >> 0x10) == 0)) && (this->actor.depthInWater < (1200.0f * this->actor.scale.y))) { func_80B395EC(&this->actor, globalCtx); } @@ -567,7 +567,7 @@ void func_80B3A500(ObjSnowball2* this, GlobalContext* globalCtx) { this->actor.velocity.y += this->actor.gravity; this->actor.world.pos.y += this->actor.velocity.y; - if (((globalCtx->gameplayFrames % 16) == 0) || (((u32)Rand_Next() >> 0x10) == 0)) { + if (((globalCtx->gameplayFrames % 16) == 0) || ((Rand_Next() >> 0x10) == 0)) { func_80B395C4(globalCtx, &this->actor.home.pos); } From 9831e5e063da421a5dc86b9438c7d59f9f17706a Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 19 Jun 2022 15:05:12 -0700 Subject: [PATCH 240/257] Effect Kfire OK (#837) * OK * Small change * Matrix renames * else if --- spec | 3 +- .../ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c | 92 +++++++++++++++++-- 2 files changed, 87 insertions(+), 8 deletions(-) diff --git a/spec b/spec index f6fb137b2..fc536a6a4 100644 --- a/spec +++ b/spec @@ -1908,8 +1908,7 @@ beginseg name "ovl_Effect_Ss_K_Fire" compress include "build/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.o" - include "build/data/ovl_Effect_Ss_K_Fire/ovl_Effect_Ss_K_Fire.data.o" - include "build/data/ovl_Effect_Ss_K_Fire/ovl_Effect_Ss_K_Fire.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_K_Fire/ovl_Effect_Ss_K_Fire_reloc.o" endseg beginseg diff --git a/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c b/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c index b477545c2..e93210b89 100644 --- a/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c +++ b/src/overlays/effects/ovl_Effect_Ss_K_Fire/z_eff_ss_k_fire.c @@ -5,23 +5,103 @@ */ #include "z_eff_ss_k_fire.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rAlpha regs[0] +#define rScroll regs[2] +#define rType regs[3] +#define rYScale regs[4] +#define rXZScale regs[5] +#define rScaleMax regs[6] #define PARAMS ((EffectSsKFireInitParams*)initParamsx) -s32 EffectSsKFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsKFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsKFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsKFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_K_Fire_InitVars = { EFFECT_SS_K_FIRE, EffectSsKFire_Init, }; -#endif +u32 EffectSsKFire_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsKFireInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_K_Fire/EffectSsKFire_Init.s") + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; + this->life = 100; + this->rScaleMax = initParams->scaleMax; + this->rAlpha = 255; + this->rScroll = Rand_ZeroFloat(5.0f) - 25; + this->rType = initParams->type; + this->draw = EffectSsKFire_Draw; + this->update = EffectSsKFire_Update; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_K_Fire/EffectSsKFire_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_K_Fire/EffectSsKFire_Update.s") +void EffectSsKFire_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + s32 pad; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + f32 xzScale; + f32 yScale; + + xzScale = this->rXZScale / 10000.0f; + yScale = this->rYScale / 10000.0f; + + OPEN_DISPS(gfxCtx); + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(xzScale, yScale, xzScale, MTXMODE_APPLY); + func_8012C2DC(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, + globalCtx->state.frames * this->rScroll, 0x20, 0x80)); + + if (this->rType >= 100) { + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, this->rAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 0); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, this->rAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, 0); + } + + gDPPipeSync(POLY_XLU_DISP++); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + + if ((index % 2) != 0) { + Matrix_RotateYF(M_PI, MTXMODE_APPLY); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsKFire_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + if (this->rXZScale < this->rScaleMax) { + this->rXZScale += 4; + this->rYScale += 4; + + if (this->rXZScale > this->rScaleMax) { + this->rXZScale = this->rScaleMax; + + if (this->rType != 3) { + this->rYScale = this->rScaleMax; + } + } + } else if (this->rAlpha > 0) { + this->rAlpha -= 10; + if (this->rAlpha <= 0) { + this->rAlpha = 0; + this->life = 0; + } + } + + if (this->rType == 3) { + this->rYScale++; + } +} From 1a37ef95d1807ea40cb9e236f08152c29c999435 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 19 Jun 2022 15:10:21 -0700 Subject: [PATCH 241/257] Effect Icesmoke OK (#838) * Ok * Name DL and tex * Matrix renames --- assets/xml/objects/gameplay_keep.xml | 4 +- spec | 3 +- .../z_eff_ss_ice_smoke.c | 66 +++++++++++++++++-- 3 files changed, 62 insertions(+), 11 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index d4a4ac277..969954b32 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1114,8 +1114,8 @@ - - + + diff --git a/spec b/spec index fc536a6a4..3ca89286a 100644 --- a/spec +++ b/spec @@ -2152,8 +2152,7 @@ beginseg name "ovl_Effect_Ss_Ice_Smoke" compress include "build/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.o" - include "build/data/ovl_Effect_Ss_Ice_Smoke/ovl_Effect_Ss_Ice_Smoke.data.o" - include "build/data/ovl_Effect_Ss_Ice_Smoke/ovl_Effect_Ss_Ice_Smoke.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/ovl_Effect_Ss_Ice_Smoke_reloc.o" endseg beginseg diff --git a/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c b/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c index 71be8c0d6..4571bb790 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c +++ b/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/z_eff_ss_ice_smoke.c @@ -1,27 +1,79 @@ /* * File: z_eff_ss_ice_smoke.c * Overlay: ovl_Effect_Ss_Ice_Smoke - * Description: + * Description: Ice Smoke */ #include "z_eff_ss_ice_smoke.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rAlpha regs[0] +#define rScale regs[1] +#define rScrollX regs[2] +#define rScrollY regs[3] #define PARAMS ((EffectSsIceSmokeInitParams*)initParamsx) -s32 EffectSsIceSmoke_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsIceSmoke_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsIceSmoke_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsIceSmoke_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Ice_Smoke_InitVars = { EFFECT_SS_ICE_SMOKE, EffectSsIceSmoke_Init, }; -#endif +u32 EffectSsIceSmoke_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsIceSmokeInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Smoke/EffectSsIceSmoke_Init.s") + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &initParams->velocity); + Math_Vec3f_Copy(&this->accel, &initParams->accel); + this->rAlpha = 0; + this->rScale = ABS_ALT(initParams->scale); + if (initParams->scale < 0) { + this->rScrollX = 1; + this->rScrollY = 2; + } else { + this->rScrollX = 3; + this->rScrollY = 15; + } + this->life = 50; + this->draw = EffectSsIceSmoke_Draw; + this->update = EffectSsIceSmoke_Update; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Smoke/EffectSsIceSmoke_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Smoke/EffectSsIceSmoke_Update.s") +void EffectSsIceSmoke_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + s32 pad; + Mtx* mtx; + f32 scale; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 235, 235, this->rAlpha); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, this->rScrollX * this->life, this->rScrollY * this->life, + 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + scale = this->rScale * 0.0001f; + Matrix_Scale(scale, scale, 1.0f, MTXMODE_APPLY); + mtx = Matrix_NewMtx(globalCtx->state.gfxCtx); + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffIceSmokeDL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EffectSsIceSmoke_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + if (this->life < 10) { + Math_StepToS(&this->rAlpha, 0, 10); + } else if (this->rAlpha < 100) { + this->rAlpha += 10; + } +} From 689ef2fe0b919f21cc557373bb2a3a662fb5e028 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 19 Jun 2022 15:18:54 -0700 Subject: [PATCH 242/257] Effect Icepiece OK (#839) * OK * Final cleanup * format * PR plus forgot to rename Matrix_RotateY --- assets/xml/objects/gameplay_keep.xml | 2 +- spec | 3 +- .../z_eff_ss_ice_piece.c | 71 +++++++++++++++++-- 3 files changed, 66 insertions(+), 10 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 969954b32..e1a35f83b 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1110,7 +1110,7 @@ - + diff --git a/spec b/spec index 3ca89286a..4991f66a7 100644 --- a/spec +++ b/spec @@ -1930,8 +1930,7 @@ beginseg name "ovl_Effect_Ss_Ice_Piece" compress include "build/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.o" - include "build/data/ovl_Effect_Ss_Ice_Piece/ovl_Effect_Ss_Ice_Piece.data.o" - include "build/data/ovl_Effect_Ss_Ice_Piece/ovl_Effect_Ss_Ice_Piece.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/ovl_Effect_Ss_Ice_Piece_reloc.o" endseg beginseg diff --git a/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c b/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c index 5bd800a20..0fa12d248 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c +++ b/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/z_eff_ss_ice_piece.c @@ -1,27 +1,84 @@ /* * File: z_eff_ss_ice_piece.c * Overlay: ovl_Effect_Ss_Ice_Piece - * Description: + * Description: Ice Shards */ #include "z_eff_ss_ice_piece.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rLifespan regs[0] +#define rYaw regs[1] +#define rPitch regs[2] +#define rRotSpeed regs[3] +#define rScale regs[4] #define PARAMS ((EffectSsIcePieceInitParams*)initParamsx) -s32 EffectSsIcePiece_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsIcePiece_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsIcePiece_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsIcePiece_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Ice_Piece_InitVars = { EFFECT_SS_ICE_PIECE, EffectSsIcePiece_Init, }; -#endif +u32 EffectSsIcePiece_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsIcePieceInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Piece/EffectSsIcePiece_Init.s") + this->pos = initParams->pos; + this->vec = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; + this->life = initParams->life; + this->draw = EffectSsIcePiece_Draw; + this->update = EffectSsIcePiece_Update; + this->rLifespan = initParams->life; + this->rScale = initParams->scale * 100.0f; + this->rYaw = Math_FAtan2F(initParams->velocity.z, initParams->velocity.x); + this->rPitch = 0; + this->rRotSpeed = + ((fabsf(initParams->velocity.x) + fabsf(initParams->velocity.y)) * 100.0f) * (Rand_ZeroFloat(1.0f) + 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Piece/EffectSsIcePiece_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Ice_Piece/EffectSsIcePiece_Update.s") +void EffectSsIcePiece_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s32 pad; + f32 scale = this->rScale * 0.01f; + u32 frames = globalCtx->state.frames; + f32 alpha; + + OPEN_DISPS(gfxCtx); + + if ((this->rLifespan > 0) && (this->life < (this->rLifespan >> 1))) { + alpha = (this->life * 2.0f) / this->rLifespan; + alpha *= 255.0f; + } else { + alpha = 255.0f; + } + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_RotateYS(this->rYaw, MTXMODE_APPLY); + Matrix_RotateXS(this->rPitch, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C2DC(globalCtx->state.gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 100, (s32)alpha & 0xFF); + func_800BCC68(&this->pos, globalCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, frames % 256, 0x20, 0x10, 1, 0, (2 * frames) % 256, 0x40, + 0x20)); + gSPDisplayList(POLY_XLU_DISP++, gEffIceFragmentDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsIcePiece_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + this->rPitch += this->rRotSpeed; + this->velocity.x *= 0.85f; + this->velocity.y *= 0.85f; + this->velocity.z *= 0.85f; +} From 67345d9be5119b4ceb69d796aa980acb25d1cab1 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sun, 19 Jun 2022 19:28:48 -0300 Subject: [PATCH 243/257] z_bg_astr_bombwall decompiled (#841) * z_bg_astr_bombwall decompiled * review fixes * formatting * pr review fixes * PR review fixes * PR review fixes Co-authored-by: SonicDcer --- include/PR/gbi.h | 1 + spec | 3 +- .../ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c | 199 +++++++++++++++--- .../ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.h | 15 +- undefined_syms.txt | 7 - 5 files changed, 179 insertions(+), 46 deletions(-) diff --git a/include/PR/gbi.h b/include/PR/gbi.h index fa27a5f11..f7b249af8 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -284,6 +284,7 @@ #define G_TEXTURE_GEN 0x00040000 #define G_TEXTURE_GEN_LINEAR 0x00080000 #define G_LOD 0x00100000 /* NOT IMPLEMENTED */ +#define G_LIGHTING_POSITIONAL 0x00400000 #if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) # define G_CLIPPING 0x00800000 #else diff --git a/spec b/spec index 4991f66a7..1e34c3bf2 100644 --- a/spec +++ b/spec @@ -5002,8 +5002,7 @@ beginseg name "ovl_Bg_Astr_Bombwall" compress include "build/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.o" - include "build/data/ovl_Bg_Astr_Bombwall/ovl_Bg_Astr_Bombwall.data.o" - include "build/data/ovl_Bg_Astr_Bombwall/ovl_Bg_Astr_Bombwall.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Astr_Bombwall/ovl_Bg_Astr_Bombwall_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c index f2608b583..1e4a9b3d0 100644 --- a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.c @@ -5,6 +5,7 @@ */ #include "z_bg_astr_bombwall.h" +#include "objects/object_astr_obj/object_astr_obj.h" #define FLAGS 0x00000000 @@ -15,7 +16,13 @@ void BgAstrBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgAstrBombwall_Update(Actor* thisx, GlobalContext* globalCtx); void BgAstrBombwall_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80C0A378(BgAstrBombwall* this); +void func_80C0A38C(BgAstrBombwall* this, GlobalContext* globalCtx); +void func_80C0A400(BgAstrBombwall* this, GlobalContext* globalCtx); +void func_80C0A418(BgAstrBombwall* this, GlobalContext* globalCtx); +void func_80C0A458(BgAstrBombwall* this, GlobalContext* globalCtx); +void func_80C0A4BC(BgAstrBombwall* this, GlobalContext* globalCtx); + const ActorInit Bg_Astr_Bombwall_InitVars = { ACTOR_BG_ASTR_BOMBWALL, ACTORCAT_BG, @@ -28,59 +35,191 @@ const ActorInit Bg_Astr_Bombwall_InitVars = { (ActorFunc)BgAstrBombwall_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_80C0A620[2] = { +static ColliderTrisElementInit sTrisElementsInit[2] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -70.0f, 0.0f, 3.0f }, { 70.0f, 0.0f, 3.0f }, { -70.0f, 200.0f, 3.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 70.0f, 0.0f, 3.0f }, { 70.0f, 200.0f, 3.0f }, { -70.0f, 200.0f, 3.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80C0A698 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 2, D_80C0A620, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 2, + sTrisElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80C0A6A8[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; -#endif +void BgAstrBombwall_InitCollider(ColliderTrisInit* init, Vec3f* pos, Vec3s* rot, ColliderTris* collider) { + s32 i; + s32 j; + Vec3f sp54[3]; -extern ColliderTrisElementInit D_80C0A620[2]; -extern ColliderTrisInit D_80C0A698; -extern InitChainEntry D_80C0A6A8[]; + Matrix_RotateYS(rot->y, MTXMODE_NEW); + Matrix_RotateXS(rot->x, MTXMODE_APPLY); + Matrix_RotateZS(rot->z, MTXMODE_APPLY); -extern UNK_TYPE D_06002178; -extern UNK_TYPE D_06002380; -extern UNK_TYPE D_06002498; + for (i = 0; i < init->count; i++) { + for (j = 0; j < 3; j++) { // https://decomp.me/scratch/JrEnl + Matrix_MultVec3f(&(init->elements + i)->dim.vtx[j], &sp54[j]); //! FAKE MATCH: + Math_Vec3f_Sum(&sp54[j], pos, &sp54[j]); + } + Collider_SetTrisVertices(collider, i, &sp54[0], &sp54[1], &sp54[2]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C09ED0.s") +void BgAstrBombwall_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgAstrBombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/BgAstrBombwall_Init.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_astr_obj_Colheader_002498); + Collider_InitTris(globalCtx, &this->collider); + if (Flags_GetSwitch(globalCtx, BGASTRBOMBWALL_GET_SWITCHFLAG(thisx))) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + this->dyna.actor.flags |= ACTOR_FLAG_10000000; + if (!Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit, this->colliderElements)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + BgAstrBombwall_InitCollider(&sTrisInit, &this->dyna.actor.world.pos, &this->dyna.actor.shape.rot, &this->collider); + SubS_FillCutscenesList(&this->dyna.actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + func_80C0A378(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/BgAstrBombwall_Destroy.s") +void BgAstrBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgAstrBombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A120.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A378.s") +void func_80C0A120(BgAstrBombwall* this, GlobalContext* globalCtx) { + s32 i; + Vec3f vec; + Vec3f pos; + s16 var_v0; + Vec3f velocity; + f32 rand; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A38C.s") + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + for (i = 0; i < 30; i++) { + vec.x = Rand_Centered() * 140.0f; + vec.y = Rand_ZeroOne() * 200.0f; + vec.z = 0.0f; + Matrix_MultVec3f(&vec, &pos); + Math_Vec3f_Sum(&this->dyna.actor.world.pos, &pos, &pos); + func_800BBFB0(globalCtx, &pos, 50.0f, 2, Rand_ZeroOne() * 120.0f + 20.0f, Rand_ZeroOne() * 240.0f + 20.0f, 0); + velocity.x = Rand_ZeroOne() * 2.5f; + velocity.y = (Rand_ZeroOne() * 2.5f) + 1.0f; + velocity.z = Rand_ZeroOne() * 2.5f; + rand = Rand_ZeroOne(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A400.s") + if (rand < 0.2f) { + var_v0 = 0x60; + } else if (rand < 0.6f) { + var_v0 = 0x40; + } else { + var_v0 = 0x20; + } + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -260, var_v0, 20, 0, 0, 10, 0, 0, 50, -1, + OBJECT_ASTR_OBJ, object_astr_obj_DL_002178); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A418.s") +void func_80C0A378(BgAstrBombwall* this) { + this->actionFunc = func_80C0A38C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A458.s") +void func_80C0A38C(BgAstrBombwall* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Flags_SetSwitch(globalCtx, BGASTRBOMBWALL_GET_SWITCHFLAG(&this->dyna.actor)); + func_80C0A400(this, globalCtx); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/func_80C0A4BC.s") +void func_80C0A400(BgAstrBombwall* this, GlobalContext* globalCtx) { + this->actionFunc = func_80C0A418; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/BgAstrBombwall_Update.s") +void func_80C0A418(BgAstrBombwall* this, GlobalContext* globalCtx) { + if (SubS_StartActorCutscene(&this->dyna.actor, this->cutscenes[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + func_80C0A458(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Astr_Bombwall/BgAstrBombwall_Draw.s") +void func_80C0A458(BgAstrBombwall* this, GlobalContext* globalCtx) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = NULL; + func_80C0A120(this, globalCtx); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); + this->actionFunc = func_80C0A4BC; +} + +void func_80C0A4BC(BgAstrBombwall* this, GlobalContext* globalCtx) { +} + +void BgAstrBombwall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgAstrBombwall* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgAstrBombwall_Draw(Actor* thixs, GlobalContext* globalCtx) { + { + Gfx* opa; + + OPEN_DISPS(globalCtx->state.gfxCtx); + opa = POLY_OPA_DISP; + gSPDisplayList(&opa[0], &sSetupDL[25 * 6]); + gSPMatrix(&opa[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSetGeometryMode(&opa[2], G_LIGHTING_POSITIONAL); + gSPDisplayList(&opa[3], object_astr_obj_DL_002380); + POLY_OPA_DISP = &opa[4]; + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + { + Gfx* xlu; + + OPEN_DISPS(globalCtx->state.gfxCtx); + xlu = POLY_XLU_DISP; + gSPDisplayList(&xlu[0], &sSetupDL[25 * 6]); + gSPMatrix(&xlu[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSetGeometryMode(&xlu[2], G_LIGHTING_POSITIONAL); + gSPDisplayList(&xlu[3], object_astr_obj_DL_0022E0); + POLY_XLU_DISP = &xlu[4]; + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.h b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.h index 89b891f9b..413f14cdd 100644 --- a/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.h +++ b/src/overlays/actors/ovl_Bg_Astr_Bombwall/z_bg_astr_bombwall.h @@ -5,15 +5,16 @@ struct BgAstrBombwall; +#define BGASTRBOMBWALL_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) + typedef void (*BgAstrBombwallActionFunc)(struct BgAstrBombwall*, GlobalContext*); - typedef struct BgAstrBombwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgAstrBombwallActionFunc actionFunc; - /* 0x0160 */ char unk_160[0xDC]; -} BgAstrBombwall; // size = 0x23C - + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgAstrBombwallActionFunc actionFunc; + /* 0x160 */ ColliderTris collider; + /* 0x180 */ ColliderTrisElement colliderElements[2]; + /* 0x238 */ s16 cutscenes[1]; +} BgAstrBombwall; extern const ActorInit Bg_Astr_Bombwall_InitVars; #endif // Z_BG_ASTR_BOMBWALL_H diff --git a/undefined_syms.txt b/undefined_syms.txt index b0a275ace..2cc3b09a5 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -540,13 +540,6 @@ D_06011AB8 = 0x06011AB8; D_06012A80 = 0x06012A80; D_06013138 = 0x06013138; -// ovl_Bg_Astr_Bombwall - -D_06002178 = 0x06002178; -D_060022E0 = 0x060022E0; -D_06002380 = 0x06002380; -D_06002498 = 0x06002498; - // ovl_Bg_Botihasira D_06000638 = 0x06000638; From ab7625db65e66c4a3b67233dce8a664b410a5761 Mon Sep 17 00:00:00 2001 From: Isghj <42048411+isghj5@users.noreply.github.com> Date: Sun, 19 Jun 2022 15:36:07 -0700 Subject: [PATCH 244/257] `DmZl` OK and some docs of `object_zl4` (Child Zelda used in one cutscene) (#834) * DmZl: start * DmZl: progress * DmZl4: progress * DmZl: OK * DmZl: data integrated * DmZl: object docs * DmZl: more object docs * DmZl: more docs * DmZl: Some Zl4 animations * ObjectZl4: docs * DmZl: formater pass * DmZl: more docs * DmZl: docs * DmZl: params documentation * Apply suggestions from code review Co-authored-by: Derek Hensley * DmZl: requested changes, minor fixes, formater pass * Update src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c Co-authored-by: Tom Overton * Update assets/xml/objects/object_zl4.xml Co-authored-by: Tom Overton * DmZl: some requested changes * DmZl: Change Eye Texture names for accuracy, formatter pass * DmZl: Eye texture indexes specified * DmZl: fixed struct variable names * DmZl: some requested changes * DmZl: removed comment * DmZl: change to unused index * DmZl: changed some xml comments * DmZl: requested changes 1 * Update src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c Co-authored-by: Derek Hensley * DmZl: fixing issues, formatter pass * DmZl: moved switch case * DmZl: fixed object reference, wrong file * Update src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c Co-authored-by: EllipticEllipsis * Update assets/xml/objects/object_zl4.xml Co-authored-by: EllipticEllipsis * DmZl: mouth and eye state comments Co-authored-by: Isghj8 Co-authored-by: Derek Hensley Co-authored-by: Tom Overton Co-authored-by: EllipticEllipsis --- assets/xml/objects/object_zl4.xml | 281 ++++++++++++++---------- spec | 3 +- src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c | 273 +++++++++++++++++++++-- src/overlays/actors/ovl_Dm_Zl/z_dm_zl.h | 20 +- tools/disasm/functions.txt | 12 +- 5 files changed, 440 insertions(+), 149 deletions(-) diff --git a/assets/xml/objects/object_zl4.xml b/assets/xml/objects/object_zl4.xml index dafdef8cd..65596c370 100644 --- a/assets/xml/objects/object_zl4.xml +++ b/assets/xml/objects/object_zl4.xml @@ -1,125 +1,164 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index 1e34c3bf2..d43222b06 100644 --- a/spec +++ b/spec @@ -2704,8 +2704,7 @@ beginseg name "ovl_Dm_Zl" compress include "build/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.o" - include "build/data/ovl_Dm_Zl/ovl_Dm_Zl.data.o" - include "build/data/ovl_Dm_Zl/ovl_Dm_Zl.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Zl/ovl_Dm_Zl_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c index fc9d21b3d..a4c285233 100644 --- a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c +++ b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c @@ -1,7 +1,7 @@ /* * File: z_dm_zl.c * Overlay: ovl_Dm_Zl - * Description: Child Zelda (Cutscenes) + * Description: Child Zelda (Re-learning Song of Time cutscene) */ #include "z_dm_zl.h" @@ -15,9 +15,8 @@ void DmZl_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmZl_Update(Actor* thisx, GlobalContext* globalCtx); void DmZl_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A382FC(DmZl* this, GlobalContext* globalCtx); +void DmZl_DoNothing(DmZl* this, GlobalContext* globalCtx); -#if 0 const ActorInit Dm_Zl_InitVars = { ACTOR_DM_ZL, ACTORCAT_ITEMACTION, @@ -30,27 +29,269 @@ const ActorInit Dm_Zl_InitVars = { (ActorFunc)DmZl_Draw, }; -#endif +static AnimationInfo sAnimations[] = { + { &gDmZl4FacingAwayHandsOverEmblemLoop, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, + { &gDmZl4TurningAround2Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -10.0f }, + { &gDmZl4HandsOverEmblemLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, + { &gDmZl4GivingItemStartAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -10.0f }, + { &gDmZl4GivingItemLoopAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, + { &gDmZl4RaisingOcarinaToPlayAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -10.0f }, + { &gDmZl4PlayingOcarinaAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f }, +}; -extern UNK_TYPE D_0600DE08; -extern UNK_TYPE D_0600E038; +typedef enum { + /* 0 */ ZELDA_ANIM_FACING_AWAY, + /* 1 */ ZELDA_ANIM_TURNING_TOWARD_PLAYER, + /* 2 */ ZELDA_ANIM_FACING_PLAYER, + /* 3 */ ZELDA_ANIM_GIVING_OCARINA_START, + /* 4 */ ZELDA_ANIM_GIVING_OCARINA, + /* 5 */ ZELDA_ANIM_PLAYING_OCARINA_START, + /* 6 */ ZELDA_ANIM_PLAYING_OCARINA, + /* 7 */ ZELDA_ANIM_MAX, +} DmZlAnimations; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A38190.s") +static TexturePtr sMouthTextures[] = { + gZl4MouthNeutralTex, + gZl4MouthOpenSmilingTex, + gZl4MouthFrowningTex, + gZl4MouthOpenTex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/DmZl_Init.s") +typedef enum { + /* 0 */ ZELDA_MOUTH_NEUTRAL, + /* 1 */ ZELDA_MOUTH_SMILING, + /* 2 */ ZELDA_MOUTH_FROWNING, + /* 3 */ ZELDA_MOUTH_OPEN, +} DmZlMouthTextures; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/DmZl_Destroy.s") +static TexturePtr sEyeTextures[] = { + gDmZl4EyeOpenNormalTex, + gDmZl4EyeHalfTex, + gDmZl4EyeClosedTex, + gDmZl4EyeWideTex, + gDmZl4EyeHappyTex, + gDmZl4EyeOpenLookingLeftTex, + gDmZl4EyeOpenLookingRightTex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A382FC.s") +typedef enum { + /* 0 */ ZELDA_EYE_OPEN_NORMAL, + /* 1 */ ZELDA_EYE_BLINKING, + /* 2 */ ZELDA_EYE_CLOSED, + /* 3 */ ZELDA_EYE_WIDE, + /* 4 */ ZELDA_EYE_HAPPY, + /* 5 */ ZELDA_EYE_OPEN_LOOKING_LEFT, + /* 6 */ ZELDA_EYE_OPEN_LOOKING_RIGHT, +} DmZlEyeTextures; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A3830C.s") +// Unused in MM +typedef enum { + /* 0 */ ZELDA_EYE_STATE_NORMAL, + /* 1 */ ZELDA_EYE_STATE_CLOSED, + /* 2 */ ZELDA_EYE_STATE_LOOKING_LEFT, + /* 3 */ ZELDA_EYE_STATE_LOOKING_RIGHT, + /* 4 */ ZELDA_EYE_STATE_WIDE, + /* 5 */ ZELDA_EYE_STATE_HAPPY, + /* 6 */ ZELDA_EYE_STATE_CLOSED2, +} DmZlEyeStates; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A38468.s") +/** + * This function is always called with unusedExtraOffset = 0. + */ +void DmZl_ChangeAnimation(SkelAnime* skelAnime, AnimationInfo animation[], u16 unusedExtraOffset) { + f32 endFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/DmZl_Update.s") + animation += unusedExtraOffset; + endFrame = (animation->frameCount < 0.0f) ? Animation_GetLastFrame(animation->animation) : animation->frameCount; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A3862C.s") + Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, endFrame, + animation->mode, animation->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/func_80A38648.s") +void DmZl_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DmZl* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Zl/DmZl_Draw.s") + this->animationIndex = ZELDA_ANIM_FACING_AWAY; + this->unk_2BA = 0; + this->actor.targetArrowOffset = 1000.0f; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + // these three set to NULL should mean they are dynamically allocated + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZl4Skeleton, NULL, NULL, NULL, 0); + DmZl_ChangeAnimation(&this->skelAnime, &sAnimations[this->animationIndex], 0); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = DmZl_DoNothing; +} + +void DmZl_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void DmZl_DoNothing(DmZl* this, GlobalContext* globalCtx) { +} + +void DmZl_UpdateCutscene(DmZl* this, GlobalContext* globalCtx) { + s32 actionIndex; + + if (Cutscene_CheckActorAction(globalCtx, 0x66)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 0x66); + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + s16 nextAnimationIndex = ZELDA_ANIM_FACING_AWAY; + + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + default: + case 1: + break; + case 2: + nextAnimationIndex = ZELDA_ANIM_TURNING_TOWARD_PLAYER; + break; + case 3: + nextAnimationIndex = ZELDA_ANIM_GIVING_OCARINA_START; + break; + case 4: + nextAnimationIndex = ZELDA_ANIM_PLAYING_OCARINA_START; + break; + } + + if (nextAnimationIndex != this->animationIndex) { + this->animationIndex = nextAnimationIndex; + DmZl_ChangeAnimation(&this->skelAnime, &sAnimations[this->animationIndex], 0); + } + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + actionIndex = this->animationIndex; + + if ((actionIndex == ZELDA_ANIM_TURNING_TOWARD_PLAYER) || (actionIndex == ZELDA_ANIM_GIVING_OCARINA_START) || + (actionIndex == ZELDA_ANIM_PLAYING_OCARINA_START)) { + // these animations don't loop at the end, they lead into the next animation + this->animationIndex++; + DmZl_ChangeAnimation(&this->skelAnime, &sAnimations[this->animationIndex], 0); + } + } +} + +/** + * Updates the eye blinking and state, and mouth textures. + */ +void DmZl_UpdateFace(DmZl* this) { + if (this->blinkTimer > 0) { + this->blinkTimer--; + } else { + this->blinkTimer = 0; + } + + if (this->blinkTimer < 3) { + this->eyeTextureIndexRight = this->blinkTimer; + this->eyeTextureIndexLeft = this->blinkTimer; + } + + // nextEyeState is never changed by this actor in MM, only ZELDA_EYE_STATE_NORMAL used. + switch (this->nextEyeState) { + case ZELDA_EYE_STATE_NORMAL: + if (this->blinkTimer == 0) { + this->blinkTimer = Rand_S16Offset(30, 30); + } + break; + case ZELDA_EYE_STATE_CLOSED: + if (this->blinkTimer == 0) { + this->eyeTextureIndexLeft = this->eyeTextureIndexRight = ZELDA_EYE_CLOSED; + } + break; + case ZELDA_EYE_STATE_LOOKING_LEFT: + if (this->blinkTimer == 0) { + this->eyeTextureIndexLeft = ZELDA_EYE_OPEN_LOOKING_LEFT; + this->eyeTextureIndexRight = ZELDA_EYE_OPEN_LOOKING_RIGHT; + } + break; + case ZELDA_EYE_STATE_LOOKING_RIGHT: + if (this->blinkTimer == 0) { + this->eyeTextureIndexLeft = ZELDA_EYE_OPEN_LOOKING_RIGHT; + this->eyeTextureIndexRight = ZELDA_EYE_OPEN_LOOKING_LEFT; + } + break; + case ZELDA_EYE_STATE_WIDE: + if (this->blinkTimer == 0) { + this->eyeTextureIndexLeft = this->eyeTextureIndexRight = ZELDA_EYE_WIDE; + } + break; + case ZELDA_EYE_STATE_HAPPY: + if (this->blinkTimer == 0) { + this->eyeTextureIndexLeft = this->eyeTextureIndexRight = ZELDA_EYE_HAPPY; + } + break; + case ZELDA_EYE_STATE_CLOSED2: + if (this->blinkTimer >= 3) { + this->blinkTimer = 0; + } + break; + } + + // nextMouthState is never changed by this actor in MM, only ZELDA_MOUTH_NEUTRAL used. + switch (this->nextMouthState) { + default: + this->mouthTextureIndex = ZELDA_MOUTH_NEUTRAL; + break; + case ZELDA_MOUTH_SMILING: + this->mouthTextureIndex = ZELDA_MOUTH_SMILING; + break; + case ZELDA_MOUTH_FROWNING: + this->mouthTextureIndex = ZELDA_MOUTH_FROWNING; + break; + case ZELDA_MOUTH_OPEN: + this->mouthTextureIndex = ZELDA_MOUTH_OPEN; + break; + } + + if (this->animationIndex == ZELDA_ANIM_PLAYING_OCARINA) { + this->eyeTextureIndexLeft = this->eyeTextureIndexRight = ZELDA_EYE_CLOSED; + } +} + +void DmZl_Update(Actor* thisx, GlobalContext* globalCtx) { + DmZl* this = THIS; + + DmZl_UpdateFace(this); + SkelAnime_Update(&this->skelAnime); + DmZl_UpdateCutscene(this, globalCtx); + this->actionFunc(this, globalCtx); +} + +s32 DmZl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + return false; +} + +void DmZl_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + DmZl* this = THIS; + + if (limbIndex == ZL4_LIMB_RIGHT_HAND) { + if ((this->animationIndex >= ZELDA_ANIM_GIVING_OCARINA_START) && + (this->animationIndex <= ZELDA_ANIM_PLAYING_OCARINA)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, gDmZl4OcarinaDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} + +void DmZl_Draw(Actor* thisx, GlobalContext* globalCtx) { + DmZl* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTextureIndexRight])); + + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTextureIndexLeft])); + + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(sMouthTextures[this->mouthTextureIndex])); + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + DmZl_OverrideLimbDraw, DmZl_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.h b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.h index c3b985850..ec3e44296 100644 --- a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.h +++ b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.h @@ -2,16 +2,28 @@ #define Z_DM_ZL_H #include "global.h" +#include "objects/object_zl4/object_zl4.h" struct DmZl; typedef void (*DmZlActionFunc)(struct DmZl*, GlobalContext*); typedef struct DmZl { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x11C]; - /* 0x0260 */ DmZlActionFunc actionFunc; - /* 0x0264 */ char unk_264[0x70]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[ZL4_LIMB_MAX]; // these tables are not referenced directly, loaded dynamically + /* 0x1F4 */ Vec3s morphTable[ZL4_LIMB_MAX]; + /* 0x260 */ DmZlActionFunc actionFunc; + /* 0x264 */ ColliderCylinder collider; // unused, assumed to be here based on OoT documentation + /* 0x2B0 */ s16 animationIndex; + /* 0x2B2 */ u8 eyeTextureIndexLeft; + /* 0x2B3 */ u8 eyeTextureIndexRight; + /* 0x2B4 */ u8 mouthTextureIndex; + /* 0x2B5 */ u8 nextEyeState; // used to control eye state, but not set by our actor, outside of actor? + /* 0x2B6 */ u8 nextMouthState; // used to control mouth state, but not set by our actor, outside of actor? + /* 0x2B8 */ s16 blinkTimer; + /* 0x2BA */ s16 unk_2BA; // set but not used by this actor. + /* 0x2BC */ UNK_TYPE1 pad2BC[0x18]; // unused by DmZl } DmZl; // size = 0x2D4 extern const ActorInit Dm_Zl_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4307c8e37..e59790cf3 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -10244,15 +10244,15 @@ 0x80A37EE0:("ObjShutter_Destroy",), 0x80A37EF0:("ObjShutter_Update",), 0x80A3803C:("ObjShutter_Draw",), - 0x80A38190:("func_80A38190",), + 0x80A38190:("DmZl_ChangeAnimation",), 0x80A3822C:("DmZl_Init",), 0x80A382EC:("DmZl_Destroy",), - 0x80A382FC:("func_80A382FC",), - 0x80A3830C:("func_80A3830C",), - 0x80A38468:("func_80A38468",), + 0x80A382FC:("DmZl_DoNothing",), + 0x80A3830C:("DmZl_UpdateCutscene",), + 0x80A38468:("DmZl_UpdateFace",), 0x80A385D4:("DmZl_Update",), - 0x80A3862C:("func_80A3862C",), - 0x80A38648:("func_80A38648",), + 0x80A3862C:("DmZl_OverrideLimbDraw",), + 0x80A38648:("DmZl_PostLimbDraw",), 0x80A3869C:("DmZl_Draw",), 0x80A389A0:("func_80A389A0",), 0x80A38A68:("func_80A38A68",), From 3997776e5bf24d8cefaa0013eee6e5cee4c6d4a3 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sun, 19 Jun 2022 19:45:00 -0300 Subject: [PATCH 245/257] obj_boat decompiled (#842) * obj_boat decompiled * PR review fixes * pr review fixes * PR Review fixes * PR review fixes * final cleanup Co-authored-by: SonicDcer --- spec | 3 +- src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c | 161 ++++++++++++++++-- src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h | 16 +- undefined_syms.txt | 5 - 4 files changed, 161 insertions(+), 24 deletions(-) diff --git a/spec b/spec index d43222b06..5fd1d01e9 100644 --- a/spec +++ b/spec @@ -4284,8 +4284,7 @@ beginseg name "ovl_Obj_Boat" compress include "build/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.o" - include "build/data/ovl_Obj_Boat/ovl_Obj_Boat.data.o" - include "build/data/ovl_Obj_Boat/ovl_Obj_Boat.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Boat/ovl_Obj_Boat_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c index 880d72b3f..bda85a450 100644 --- a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c +++ b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c @@ -5,6 +5,7 @@ */ #include "z_obj_boat.h" +#include "objects/object_kaizoku_obj/object_kaizoku_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,8 @@ void ObjBoat_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjBoat_Update(Actor* thisx, GlobalContext* globalCtx); void ObjBoat_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B9B428(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Obj_Boat_InitVars = { ACTOR_OBJ_BOAT, ACTORCAT_BG, @@ -28,31 +30,162 @@ const ActorInit Obj_Boat_InitVars = { (ActorFunc)ObjBoat_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B9B680[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), }; -#endif +s16 func_80B9AF50(ObjBoat* this, Vec3f* arg0) { + s16 yaw; + Vec3s* temp = &this->unk_164[(s32)this->unk_15C]; -extern InitChainEntry D_80B9B680[]; + Math_Vec3s_ToVec3f(arg0, &temp[this->unk_15D]); + yaw = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, arg0); -extern UNK_TYPE D_06007630; -extern UNK_TYPE D_06009A88; + return ((this->unk_15D > 0) ? yaw : (yaw + 0x8000)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/func_80B9AF50.s") +void ObjBoat_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + Path* path; + ObjBoat* this = THIS; + Vec3f sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/ObjBoat_Init.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_kaizoku_obj_Colheader_009A88); + if (thisx->params < 0) { + this->dyna.actor.update = func_80B9B428; + } else { + path = &globalCtx->setupPathList[OBJBOAT_GET_PATH(thisx)]; + this->unk_163 = path->count - 1; + this->unk_164 = Lib_SegmentedToVirtual(path->points); + this->unk_15D = 1; + this->dyna.actor.world.pos.x = this->unk_164[this->unk_15C].x; + this->dyna.actor.world.pos.z = this->unk_164[this->unk_15C].z; + this->dyna.actor.shape.rot.y = func_80B9AF50(this, &sp24); + this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y; + this->unk_15D = -this->unk_15D; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/ObjBoat_Destroy.s") +void ObjBoat_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjBoat* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/func_80B9B124.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/ObjBoat_Update.s") +void func_80B9B124(ObjBoat* this) { + this->unk_160 += 1000; + this->dyna.actor.world.pos.y = Math_SinS(this->unk_160) + this->dyna.actor.home.pos.y; + this->dyna.actor.shape.rot.x = Math_SinS(this->unk_160) * 100.0f; + this->dyna.actor.shape.rot.z = Math_SinS(this->unk_160 * 2) * 50.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/func_80B9B428.s") +void ObjBoat_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjBoat* this = THIS; + Player* player = GET_PLAYER(globalCtx); + s32 temp = DynaPolyActor_IsInRidingMovingState(&this->dyna); + f32 sp3C = 0.0f; + s16 sp3A = this->dyna.actor.shape.rot.y; + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Boat/ObjBoat_Draw.s") + if ((temp != 0) || ((DynaPolyActor_IsInRidingFallingState(&this->dyna)))) { + if ((this->unk_15F == 0) && (OBJBOAT_GET_4000(thisx) || ((temp != 0) && (this->unk_15C == this->unk_15E)))) { + this->unk_15D = -this->unk_15D; + if (this->unk_15D > 0) { + this->unk_15E = this->unk_163; + } else { + this->unk_15E = 0; + } + this->unk_15F = 60; + } + } else if (this->dyna.actor.speedXZ == 0.0f) { + if (this->unk_15F != 0) { + this->unk_15F--; + } + } + if (this->unk_15C != this->unk_15E) { + sp3A = func_80B9AF50(this, &sp2C); + if (Math_Vec3f_DistXZ(&this->dyna.actor.world.pos, &sp2C) < 200.0f) { + this->unk_15C += this->unk_15D; + if (this->unk_15C == this->unk_15E) { + if (OBJBOAT_GET_4000(thisx)) { + this->unk_15C = 0; + } else if (this->dyna.actor.speedXZ == 0.0f) { + this->unk_15C = 0; + this->unk_15D = -1; + } + } + } else { + sp3C = this->unk_15D * (OBJBOAT_GET_4000(thisx) ? 5.0f : 3.0f); + } + } + if (player->csMode != 0x1A) { + Math_ScaledStepToS(&this->dyna.actor.shape.rot.y, sp3A, (s16)(s32)(fabsf(this->dyna.actor.speedXZ) * 40.0f)); + this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y; + Math_StepToF(&this->dyna.actor.speedXZ, sp3C, 0.05f); + Actor_MoveWithGravity(&this->dyna.actor); + if (this->dyna.actor.speedXZ != 0.0f) { + func_800B9010(&this->dyna.actor, NA_SE_EV_PIRATE_SHIP - SFX_FLAG); + } + } + func_80B9B124(this); +} + +void func_80B9B428(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjBoat* this = THIS; + + if (Cutscene_CheckActorAction(globalCtx, 511)) { + CsCmdActorAction* actionIndex = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 511)]; + if (this->unk_15F != actionIndex->action) { + this->dyna.actor.shape.rot.x = actionIndex->urot.x; + if (actionIndex->action != 1) { + Path* path = &globalCtx->setupPathList[OBJBOAT_GET_PATH(&this->dyna.actor)]; + + if (actionIndex->action == 3) { + path = &globalCtx->setupPathList[path->unk1]; + } + this->unk_163 = path->count; + this->unk_164 = Lib_SegmentedToVirtual(path->points); + Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, this->unk_164); + this->dyna.actor.speedXZ = actionIndex->urot.z * (45.0f / 0x2000); + this->unk_164++; + this->unk_15C = 1; + } + this->unk_15F = actionIndex->action; + } else { + if (actionIndex->action != 1) { + Vec3f vec; + f32 step; + + Math_Vec3s_ToVec3f(&vec, this->unk_164); + step = Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &vec, this->dyna.actor.speedXZ); + if ((this->unk_15C < this->unk_163) && (step < this->dyna.actor.speedXZ)) { + this->unk_164++; + this->unk_15C++; + } + } + if (actionIndex->action != 3) { + func_80B9B124(this); + if (actionIndex->action == 2) { + func_800B9010(&this->dyna.actor, NA_SE_EV_PIRATE_SHIP - SFX_FLAG); + } + } else { + this->dyna.actor.shape.rot.y += 0x7D0; + this->dyna.actor.shape.rot.x += 0x3E8; + this->dyna.actor.shape.rot.z += 0x1F4; + } + } + } +} + +void ObjBoat_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjBoat* this = THIS; + + Gfx_DrawDListOpa(globalCtx, object_kaizoku_obj_DL_007630); +} diff --git a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h index 988dd6a2b..110b89dde 100644 --- a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h +++ b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h @@ -3,12 +3,22 @@ #include "global.h" +#define OBJBOAT_GET_PATH(thisx) (((thisx)->params >> 7) & 0x1F) +#define OBJBOAT_GET_4000(thisx) ((thisx)->params & 0x4000) + struct ObjBoat; typedef struct ObjBoat { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x24]; -} ObjBoat; // size = 0x168 + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ u8 unk_15C; + /* 0x15D */ s8 unk_15D; + /* 0x15E */ u8 unk_15E; + /* 0x15F */ u8 unk_15F; + /* 0x160 */ s16 unk_160; + /* 0x162 */ UNK_TYPE1 pad_162; + /* 0x163 */ u8 unk_163; + /* 0x164 */ Vec3s* unk_164; +} ObjBoat; extern const ActorInit Obj_Boat_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 2cc3b09a5..b78891090 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1552,11 +1552,6 @@ D_06000168 = 0x06000168; D_060003F8 = 0x060003F8; D_060004B0 = 0x060004B0; -// ovl_Obj_Boat - -D_06007630 = 0x06007630; -D_06009A88 = 0x06009A88; - // ovl_Obj_Chikuwa D_06000D10 = 0x06000D10; From aea2e67f79323b3f942e10e919c860aa8bfc66fa Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sun, 19 Jun 2022 19:52:45 -0300 Subject: [PATCH 246/257] z_en_sc_ruppe decompiled (#843) * z_en_sc_ruppe decompiled * PR Review fixes * PR Review fixes * PR review fixes * pr review fixes * pr review fixes * Ruppe -> Rupee Co-authored-by: SonicDcer --- spec | 3 +- .../actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c | 164 ++++++++++++++++-- .../actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.h | 16 +- 3 files changed, 163 insertions(+), 20 deletions(-) diff --git a/spec b/spec index 5fd1d01e9..74362de6b 100644 --- a/spec +++ b/spec @@ -4627,8 +4627,7 @@ beginseg name "ovl_En_Sc_Ruppe" compress include "build/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.o" - include "build/data/ovl_En_Sc_Ruppe/ovl_En_Sc_Ruppe.data.o" - include "build/data/ovl_En_Sc_Ruppe/ovl_En_Sc_Ruppe.reloc.o" + include "build/src/overlays/actors//ovl_En_Sc_Ruppe/ovl_En_Sc_Ruppe_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c index 357d41ba7..f568b1c41 100644 --- a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c +++ b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.c @@ -5,6 +5,7 @@ */ #include "z_en_sc_ruppe.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,10 +16,13 @@ void EnScRuppe_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnScRuppe_Update(Actor* thisx, GlobalContext* globalCtx); void EnScRuppe_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BD6A8C(EnScRuppe* this, GlobalContext* globalCtx); void func_80BD6B18(EnScRuppe* this, GlobalContext* globalCtx); -#if 0 +typedef struct { + /* 0x0 */ TexturePtr tex; + /* 0x4 */ s16 amount; +} RuppeInfo; + const ActorInit En_Sc_Ruppe_InitVars = { ACTOR_EN_SC_RUPPE, ACTORCAT_NPC, @@ -31,29 +35,157 @@ const ActorInit En_Sc_Ruppe_InitVars = { (ActorFunc)EnScRuppe_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BD6E40 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_NO_PUSH | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +RuppeInfo sRupeeInfo[] = { + { gameplay_keep_Tex_061FC0, 1 }, // Green rupee + { gameplay_keep_Tex_061FE0, 5 }, // Blue rupee + { gameplay_keep_Tex_062000, 20 }, // Red rupee + { gameplay_keep_Tex_062040, 200 }, // Orange rupee + { gameplay_keep_Tex_062020, 50 }, // Purple rupee + { gameplay_keep_Tex_062060, 10 }, // (unused) +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_NO_PUSH | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 30, 0, { 0, 0, 0 } }, }; -#endif +void EnScRuppe_UpdateCollision(EnScRuppe* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 32.0f, 30.0f, 0.0f, 4); +} -extern ColliderCylinderInit D_80BD6E40; +s32 func_80BD697C(s16 ruppeIndex) { + switch (ruppeIndex) { + case RUPEE_GREEN: + if (gSaveContext.save.weekEventReg[53] & 4) { + gSaveContext.save.weekEventReg[53] &= (u8)~4; + return true; + } + break; + case RUPEE_BLUE: + if (gSaveContext.save.weekEventReg[53] & 0x80) { + gSaveContext.save.weekEventReg[53] &= (u8)~0x80; + return true; + } + break; + case RUPEE_RED: + if (gSaveContext.save.weekEventReg[54] & 1) { + gSaveContext.save.weekEventReg[54] &= (u8)~1; + return true; + } + break; + case RUPEE_ORANGE: + if (gSaveContext.save.weekEventReg[54] & 2) { + gSaveContext.save.weekEventReg[54] &= (u8)~2; + return true; + } + break; + case RUPEE_PURPLE: + if (gSaveContext.save.weekEventReg[54] & 4) { + gSaveContext.save.weekEventReg[54] &= (u8)~4; + return true; + } + break; + case RUPEE_UNUSED: + if ((gSaveContext.save.weekEventReg[54] & 8)) { + gSaveContext.save.weekEventReg[54] &= (u8)~8; + return true; + } + break; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/func_80BD6910.s") +void func_80BD6A8C(EnScRuppe* this, GlobalContext* globalCtx) { + if (this->collider.base.ocFlags1 & OC1_HIT) { + this->ruppeDisplayTime = 0; + this->actor.gravity = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_GET_RUPY); + func_801159EC(sRupeeInfo[this->ruppeIndex].amount); + this->actionFunc = func_80BD6B18; + } + this->actor.shape.rot.y += 0x1F4; + Actor_MoveWithGravity(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/func_80BD697C.s") +void func_80BD6B18(EnScRuppe* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/func_80BD6A8C.s") + if (this->ruppeDisplayTime > 30) { + if (func_80BD697C(this->ruppeIndex)) { + Actor_MarkForDeath(&this->actor); + } + } else { + f32 scale; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/func_80BD6B18.s") + this->ruppeDisplayTime++; + this->actor.world.pos = player->actor.world.pos; + this->actor.world.pos.y += 40.0f; + scale = (30.0f - this->ruppeDisplayTime) * 0.001f; + Actor_SetScale(&this->actor, scale); + } + this->actor.shape.rot.y += 0x3E8; + Actor_MoveWithGravity(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/EnScRuppe_Init.s") +void EnScRuppe_Init(Actor* thisx, GlobalContext* globalCtx) { + EnScRuppe* this = THIS; + ColliderCylinder* collider = &this->collider; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/EnScRuppe_Destroy.s") + Collider_InitCylinder(globalCtx, collider); + Collider_InitAndSetCylinder(globalCtx, collider, &this->actor, &sCylinderInit); + Actor_SetScale(&this->actor, 0.03f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 10.0f); + this->ruppeIndex = SCRUPPE_GET_TYPE(thisx); + if ((this->ruppeIndex < RUPEE_GREEN) || (this->ruppeIndex >= RUPEE_UNUSED)) { + this->ruppeIndex = RUPEE_GREEN; + } + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80BD6A8C; + this->actor.gravity = -0.5f; + this->actor.shape.yOffset = 700.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/EnScRuppe_Update.s") +void EnScRuppe_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnScRuppe* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sc_Ruppe/EnScRuppe_Draw.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnScRuppe_Update(Actor* thisx, GlobalContext* globalCtx) { + EnScRuppe* this = THIS; + + this->actionFunc(this, globalCtx); + EnScRuppe_UpdateCollision(this, globalCtx); +} + +void EnScRuppe_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32* pad; + EnScRuppe* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_800B8050(&this->actor, globalCtx, 0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sRupeeInfo[this->ruppeIndex].tex)); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.h b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.h index ad9aa6915..13140be43 100644 --- a/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.h +++ b/src/overlays/actors/ovl_En_Sc_Ruppe/z_en_sc_ruppe.h @@ -3,17 +3,29 @@ #include "global.h" +#define SCRUPPE_GET_TYPE(thisx) ((thisx)->params & 0x1F) + struct EnScRuppe; typedef void (*EnScRuppeActionFunc)(struct EnScRuppe*, GlobalContext*); typedef struct EnScRuppe { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; + /* 0x0144 */ ColliderCylinder collider; /* 0x0190 */ EnScRuppeActionFunc actionFunc; - /* 0x0194 */ char unk_194[0x4]; + /* 0x194 */ s16 ruppeDisplayTime; + /* 0x196 */ s16 ruppeIndex; } EnScRuppe; // size = 0x198 +typedef enum { + /* 0 */ RUPEE_GREEN, + /* 1 */ RUPEE_BLUE, + /* 2 */ RUPEE_RED, + /* 3 */ RUPEE_ORANGE, + /* 4 */ RUPEE_PURPLE, + /* 5 */ RUPEE_UNUSED, +} RupeeType; + extern const ActorInit En_Sc_Ruppe_InitVars; #endif // Z_EN_SC_RUPPE_H From 9e6bc5db8b664176f8e61ad955638e860a7cd400 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sun, 19 Jun 2022 20:00:03 -0300 Subject: [PATCH 247/257] ovl_en_hata decompiled (#844) * z_en_hara progress * ovl_En_Hata Decompiled * PR review fixes * pr review fixes * PR review fixes * format * PR review fixes Co-authored-by: SonicDcer --- spec | 3 +- src/overlays/actors/ovl_En_Hata/z_en_hata.c | 76 ++++++++++++++++++--- src/overlays/actors/ovl_En_Hata/z_en_hata.h | 13 +++- tools/disasm/functions.txt | 2 +- undefined_syms.txt | 6 -- 5 files changed, 79 insertions(+), 21 deletions(-) diff --git a/spec b/spec index 74362de6b..86ed09a52 100644 --- a/spec +++ b/spec @@ -877,8 +877,7 @@ beginseg name "ovl_En_Hata" compress include "build/src/overlays/actors/ovl_En_Hata/z_en_hata.o" - include "build/data/ovl_En_Hata/ovl_En_Hata.data.o" - include "build/data/ovl_En_Hata/ovl_En_Hata.reloc.o" + include "build/src/overlays/actors/ovl_En_Hata/ovl_En_Hata_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Hata/z_en_hata.c b/src/overlays/actors/ovl_En_Hata/z_en_hata.c index 10c8df4e7..1d7914d5a 100644 --- a/src/overlays/actors/ovl_En_Hata/z_en_hata.c +++ b/src/overlays/actors/ovl_En_Hata/z_en_hata.c @@ -5,6 +5,7 @@ */ #include "z_en_hata.h" +#include "objects/object_hata/object_hata.h" #define FLAGS 0x00000000 @@ -12,10 +13,9 @@ void EnHata_Init(Actor* thisx, GlobalContext* globalCtx); void EnHata_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnHata_Update(Actor* thisx, GlobalContext* globalCtx); +void EnHata_Update(Actor* thisx, GlobalContext* globalCtx2); void EnHata_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Hata_InitVars = { ACTOR_EN_HATA, ACTORCAT_PROP, @@ -28,16 +28,74 @@ const ActorInit En_Hata_InitVars = { (ActorFunc)EnHata_Draw, }; -#endif +void EnHata_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHata* this = THIS; + s32 rand; + f32 endFrame; -extern UNK_TYPE D_06002FD0; + SkelAnime_Init(globalCtx, &this->skelAnime, &object_hata_Skel_002FD0, NULL, this->jointTable, this->morphTable, + OBJECT_HATA_LIMB_MAX); + endFrame = Animation_GetLastFrame(&object_hata_Anim_000444); + Animation_Change(&this->skelAnime, &object_hata_Anim_000444, 1.0f, 0.0f, endFrame, ANIMMODE_LOOP, 0.0f); + rand = Rand_ZeroFloat(endFrame); + this->skelAnime.curFrame = rand; + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_hata_Colheader_0000C0); + Actor_SetScale(&this->dyna.actor, 0.013f); + this->dyna.actor.uncullZoneScale = 500.0f; + this->dyna.actor.uncullZoneDownward = 500.0f; + this->dyna.actor.uncullZoneForward = 2200.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hata/EnHata_Init.s") +void EnHata_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHata* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hata/EnHata_Destroy.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hata/EnHata_Update.s") +void EnHata_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnHata* this = THIS; + Vec3f sp34; + f32 phi_fv0; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hata/func_8089EC68.s") + phi_fv0 = CLAMP(globalCtx->envCtx.windSpeed / 120.0f, 0.0f, 1.0f); + this->skelAnime.playSpeed = 2.75f * phi_fv0; + this->skelAnime.playSpeed += 1.0f + Rand_ZeroFloat(1.25f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hata/EnHata_Draw.s") + sp34.x = globalCtx->envCtx.windDir.x; + sp34.y = globalCtx->envCtx.windDir.y + ((1.0f - phi_fv0) * 240.0f); + sp34.y = CLAMP(sp34.y, -118.0f, 118.0f); + sp34.z = globalCtx->envCtx.windDir.z; + + phi_fv0 = CLAMP(phi_fv0, 0.1f, 0.4f); + Math_ApproachF(&this->unk_2A4.x, sp34.x, phi_fv0, 1000.0f); + Math_ApproachF(&this->unk_2A4.y, sp34.y, phi_fv0, 1000.0f); + Math_ApproachF(&this->unk_2A4.z, sp34.z, phi_fv0, 1000.0f); + + sp34 = this->unk_2A4; + this->unk_29C = Math_Vec3f_Pitch(&gZeroVec3f, &sp34); + this->unk_29C = -this->unk_29C; + this->unk_2A0 = Math_Vec3f_Yaw(&gZeroVec3f, &sp34); + this->unk_2A0 += -0x4000; + SkelAnime_Update(&this->skelAnime); +} + +s32 EnHata_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnHata* this = THIS; + + if ((limbIndex == OBJECT_HATA_LIMB_04) || (limbIndex == OBJECT_HATA_LIMB_0D)) { + rot->y += this->unk_29C; + rot->z += this->unk_2A0; + } + return false; +} + +void EnHata_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHata* this = THIS; + + func_8012C5B0(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnHata_OverrideLimbDraw, NULL, + &this->dyna.actor); +} diff --git a/src/overlays/actors/ovl_En_Hata/z_en_hata.h b/src/overlays/actors/ovl_En_Hata/z_en_hata.h index f80403933..fc96f302a 100644 --- a/src/overlays/actors/ovl_En_Hata/z_en_hata.h +++ b/src/overlays/actors/ovl_En_Hata/z_en_hata.h @@ -2,13 +2,20 @@ #define Z_EN_HATA_H #include "global.h" +#include "objects/object_hata/object_hata.h" struct EnHata; typedef struct EnHata { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x16C]; -} EnHata; // size = 0x2B0 + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ Vec3s jointTable[OBJECT_HATA_LIMB_MAX]; + /* 0x21E */ Vec3s morphTable[OBJECT_HATA_LIMB_MAX]; + /* 0x29C */ s16 unk_29C; + /* 0x29E */ UNK_TYPE1 pad_29E[2]; + /* 0x2A0 */ s16 unk_2A0; + /* 0x2A4 */ Vec3f unk_2A4; +} EnHata; /* size = 0x2B0 */ extern const ActorInit En_Hata_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e59790cf3..52f48248c 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -5605,7 +5605,7 @@ 0x8089E8E0:("EnHata_Init",), 0x8089E9DC:("EnHata_Destroy",), 0x8089EA10:("EnHata_Update",), - 0x8089EC68:("func_8089EC68",), + 0x8089EC68:("EnHata_OverrideLimbDraw",), 0x8089ECBC:("EnHata_Draw",), 0x8089ED90:("EnZl1_Init",), 0x8089EDA0:("EnZl1_Destroy",), diff --git a/undefined_syms.txt b/undefined_syms.txt index b78891090..10fb6a39a 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1186,12 +1186,6 @@ D_0600A808 = 0x0600A808; D_06000F9C = 0x06000F9C; D_06003F00 = 0x06003F00; -// ovl_En_Hata - -D_060000C0 = 0x060000C0; -D_06000444 = 0x06000444; -D_06002FD0 = 0x06002FD0; - // ovl_En_Hgo D_0600B644 = 0x0600B644; From 1ce5d136774c08d250c4b6fad473022630a334d2 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sun, 19 Jun 2022 20:07:13 -0300 Subject: [PATCH 248/257] z_dm_opstage decompiled (#845) * z_dm_opstage progress * z_dm_opstage decompiled * pr review fixes * pr review fixes * pr review fixes * params var removal * macro tunning + params removal * final (hopefully) * prototype was unnecessary * pr review changes * pr review fixes Co-authored-by: SonicDcer --- spec | 3 +- .../actors/ovl_Dm_Opstage/z_dm_opstage.c | 106 +++++++++++++++--- .../actors/ovl_Dm_Opstage/z_dm_opstage.h | 19 +++- undefined_syms.txt | 12 -- 4 files changed, 105 insertions(+), 35 deletions(-) diff --git a/spec b/spec index 86ed09a52..402f593c7 100644 --- a/spec +++ b/spec @@ -3133,8 +3133,7 @@ beginseg name "ovl_Dm_Opstage" compress include "build/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.o" - include "build/data/ovl_Dm_Opstage/ovl_Dm_Opstage.data.o" - include "build/data/ovl_Dm_Opstage/ovl_Dm_Opstage.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Opstage/ovl_Dm_Opstage_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c index ef81bc467..565c14ea3 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c @@ -5,6 +5,7 @@ */ #include "z_dm_opstage.h" +#include "objects/object_keikoku_demo/object_keikoku_demo.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,11 +16,8 @@ void DmOpstage_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmOpstage_Update(Actor* thisx, GlobalContext* globalCtx); void DmOpstage_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A9FA58(DmOpstage* this, GlobalContext* globalCtx); +void DmOpstage_FollowCutsceneScript(DmOpstage* this, GlobalContext* globalCtx); -void DmOpstage_SetupAction(DmOpstage* this, DmOpstageActionFunc actionFunc); - -#if 0 const ActorInit Dm_Opstage_InitVars = { ACTOR_DM_OPSTAGE, ACTORCAT_ITEMACTION, @@ -32,26 +30,102 @@ const ActorInit Dm_Opstage_InitVars = { (ActorFunc)DmOpstage_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A9FD30[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 300, ICHAIN_STOP), }; -#endif +void DmOpstage_SetupAction(DmOpstage* this, DmOpstageActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern InitChainEntry D_80A9FD30[]; +void DmOpstage_Init(Actor* thisx, GlobalContext* globalCtx) { + DmOpstage* this = THIS; -extern UNK_TYPE D_06000978; -extern UNK_TYPE D_06001C98; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DmOpstage_SetupAction(this, DmOpstage_FollowCutsceneScript); + Actor_SetScale(&this->dyna.actor, 0.1f); + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DM_OPSTAGE_TYPE_FLOOR) { + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_keikoku_demo_Colheader_001C98); + } + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) > DM_OPSTAGE_TYPE_FLOOR) { + this->pos.x = this->dyna.actor.world.pos.x; + this->pos.y = this->dyna.actor.world.pos.y; + this->pos.z = this->dyna.actor.world.pos.z; + this->dyna.actor.world.pos.x = 0.0f; + this->dyna.actor.world.pos.y = 0.0f; + this->dyna.actor.world.pos.z = 0.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_SetupAction.s") +void DmOpstage_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DmOpstage* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Init.s") + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DM_OPSTAGE_TYPE_FLOOR) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Destroy.s") +void DmOpstage_FollowCutsceneScript(DmOpstage* this, GlobalContext* globalCtx) { + s32 actionIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/func_80A9FA58.s") + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) == DM_OPSTAGE_TYPE_FLOOR) { + if (Cutscene_CheckActorAction(globalCtx, 0x73)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 0x73); + if (globalCtx->csCtx.actorActions[actionIndex]->action == 2) { + this->dyna.actor.scale.x = 0.075f; + this->dyna.actor.scale.z = 0.3f; + } else { + this->dyna.actor.scale.x = 0.1f; + this->dyna.actor.scale.z = 0.1f; + } + Cutscene_ActorTranslateAndYaw(&this->dyna.actor, globalCtx, actionIndex); + } + } else if (Cutscene_CheckActorAction(globalCtx, DMOPSTAGE_GET_08(&this->dyna.actor) + 0x74)) { + Cutscene_ActorTranslateAndYaw( + &this->dyna.actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, DMOPSTAGE_GET_08(&this->dyna.actor) + 0x74)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Update.s") +void DmOpstage_Update(Actor* thisx, GlobalContext* globalCtx) { + DmOpstage* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Opstage/DmOpstage_Draw.s") + this->actionFunc(this, globalCtx); + if ((globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0) && + (globalCtx->csCtx.frames == 480)) { + func_8019F128(NA_SE_EV_NAVY_FLY_REBIRTH); + } +} + +void DmOpstage_Draw(Actor* thisx, GlobalContext* globalCtx) { + DmOpstage* this = THIS; + + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) > DM_OPSTAGE_TYPE_FLOOR) { + Matrix_Translate(this->dyna.actor.world.pos.x + this->pos.x, this->dyna.actor.world.pos.y + this->pos.y, + this->dyna.actor.world.pos.z + this->pos.z, MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.world.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + } + switch (DMOPSTAGE_GET_TYPE(&this->dyna.actor)) { + case DM_OPSTAGE_TYPE_FLOOR: + Gfx_DrawDListOpa(globalCtx, object_keikoku_demo_DL_000978); + Gfx_DrawDListXlu(globalCtx, object_keikoku_demo_DL_000970); + break; + + case DM_OPSTAGE_TYPE_TREE1: + Gfx_DrawDListOpa(globalCtx, object_keikoku_demo_DL_002878); + Gfx_DrawDListXlu(globalCtx, object_keikoku_demo_DL_002870); + break; + + case DM_OPSTAGE_TYPE_TREE2: + Gfx_DrawDListOpa(globalCtx, object_keikoku_demo_DL_003068); + Gfx_DrawDListXlu(globalCtx, object_keikoku_demo_DL_003060); + break; + + case DM_OPSTAGE_TYPE_TREE3: + Gfx_DrawDListOpa(globalCtx, object_keikoku_demo_DL_003728); + Gfx_DrawDListXlu(globalCtx, object_keikoku_demo_DL_003720); + break; + } +} diff --git a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h index b0d0637e6..96fa6d31b 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h @@ -3,17 +3,26 @@ #include "global.h" +#define DMOPSTAGE_GET_TYPE(thisx) (((thisx)->params & 0xFF)) +#define DMOPSTAGE_GET_08(thisx) (((thisx)->params >> 8) & 0xFF) + struct DmOpstage; typedef void (*DmOpstageActionFunc)(struct DmOpstage*, GlobalContext*); - typedef struct DmOpstage { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x5C]; - /* 0x01A0 */ DmOpstageActionFunc actionFunc; - /* 0x01A4 */ char unk_1A4[0xC]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ UNK_TYPE1 pad_15C[0x44]; + /* 0x1A0 */ DmOpstageActionFunc actionFunc; + /* 0x1A4 */ Vec3f pos; } DmOpstage; // size = 0x1B0 +typedef enum { + /* 0 */ DM_OPSTAGE_TYPE_FLOOR, + /* 1 */ DM_OPSTAGE_TYPE_TREE1, + /* 2 */ DM_OPSTAGE_TYPE_TREE2, + /* 3 */ DM_OPSTAGE_TYPE_TREE3, +} DmOpStageTypes; + extern const ActorInit Dm_Opstage_InitVars; #endif // Z_DM_OPSTAGE_H diff --git a/undefined_syms.txt b/undefined_syms.txt index 10fb6a39a..be8e81289 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -881,18 +881,6 @@ D_0600E748 = 0x0600E748; D_0600005C = 0x0600005C; D_06001398 = 0x06001398; -// ovl_Dm_Opstage - -D_06000970 = 0x06000970; -D_06000978 = 0x06000978; -D_06001C98 = 0x06001C98; -D_06002870 = 0x06002870; -D_06002878 = 0x06002878; -D_06003060 = 0x06003060; -D_06003068 = 0x06003068; -D_06003720 = 0x06003720; -D_06003728 = 0x06003728; - // ovl_Dm_Tsg D_06002D30 = 0x06002D30; From f0c1e17fd002fab26ccdbb5041fda67d05c3fa44 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sun, 19 Jun 2022 20:13:25 -0300 Subject: [PATCH 249/257] ovl_Dm_Bal decompiled (#846) * All functions match, data import problem present * * importing succeed * final clean up * fixed warnings * pr fixes * pr review fixes * PR review fix * pr review fixes * fixes Co-authored-by: SonicDcer --- spec | 3 +- src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c | 177 ++++++++++++++++++++-- src/overlays/actors/ovl_Dm_Bal/z_dm_bal.h | 19 ++- tools/disasm/functions.txt | 4 +- 4 files changed, 178 insertions(+), 25 deletions(-) diff --git a/spec b/spec index 402f593c7..8cba55b21 100644 --- a/spec +++ b/spec @@ -5162,8 +5162,7 @@ beginseg name "ovl_Dm_Bal" compress include "build/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.o" - include "build/data/ovl_Dm_Bal/ovl_Dm_Bal.data.o" - include "build/data/ovl_Dm_Bal/ovl_Dm_Bal.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Bal/ovl_Dm_Bal_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c index aa4abb91d..93845cc5c 100644 --- a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c +++ b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c @@ -15,9 +15,9 @@ void DmBal_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmBal_Update(Actor* thisx, GlobalContext* globalCtx); void DmBal_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80C1EAC4(DmBal* this); void func_80C1EAD8(DmBal* this, GlobalContext* globalCtx); -#if 0 const ActorInit Dm_Bal_InitVars = { ACTOR_DM_BAL, ACTORCAT_NPC, @@ -30,31 +30,176 @@ const ActorInit Dm_Bal_InitVars = { (ActorFunc)DmBal_Draw, }; -#endif +static AnimationInfo D_80C1F170[] = { + { &object_bal_Anim_0005FC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_bal_Anim_000840, 1.5f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_bal_Anim_000840, 1.5f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_bal_Anim_00A7DC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_bal_Anim_00B1E8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_bal_Anim_00B604, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_bal_Anim_00C498, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_bal_Anim_00C8D8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_bal_Anim_00C8D8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_bal_Anim_00C498, 1.0f, 23.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_bal_Anim_00D530, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_bal_Anim_000C78, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -2.0f }, + { &object_bal_Anim_00CB78, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -2.0f }, + { &object_bal_Anim_001804, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -2.0f }, +}; -extern UNK_TYPE D_060005FC; -extern UNK_TYPE D_06001804; +void DmBal_Init(Actor* thisx, GlobalContext* globalCtx) { + DmBal* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/DmBal_Init.s") + this->actor.targetMode = 1; + this->actor.uncullZoneForward = 3000.0f; + Actor_SetScale(&this->actor, 0.02f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_bal_Skel_00A6D0, &object_bal_Anim_0005FC, this->jointTable, + this->morphTable, OBJECT_BAL_LIMB_MAX); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + this->timer = 60; + this->eyeIndex = 0; + this->unk_336 = 0; + func_80C1EAC4(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/DmBal_Destroy.s") +void DmBal_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EAC4.s") +void func_80C1EAC4(DmBal* this) { + this->actionFunc = func_80C1EAD8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EAD8.s") +void func_80C1EAD8(DmBal* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EAE8.s") +void func_80C1EAE8(DmBal* this, GlobalContext* globalCtx) { + static u16 D_80C1F2C0 = 0x63; + s32 actionIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EC60.s") + if (Cutscene_CheckActorAction(globalCtx, 0x238)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 0x238); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1ED0C.s") + if (D_80C1F2C0 != globalCtx->csCtx.actorActions[actionIndex]->action) { + D_80C1F2C0 = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + case 1: + this->unk_336 = 0; + this->eyeIndex = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80C1F170, 0); + break; + case 2: + this->unk_336 = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80C1F170, 12); + break; + case 3: + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80C1F170, 13); + break; + } + } else if (D_80C1F2C0 == 3) { + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + this->unk_336 = 1; + } else if (Animation_OnFrame(&this->skelAnime, 29.0f)) { + this->unk_336 = 0; + this->eyeIndex = 0; + } + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + this->actor.home.pos = this->actor.world.pos; + } else { + this->unk_336 = 0; + this->eyeIndex = 0; + D_80C1F2C0 = 0x63; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1ED64.s") +void func_80C1EC60(DmBal* this, GlobalContext* globalCtx) { + f32 temp_fv1_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/DmBal_Update.s") + this->unk_338 += 0x320; + this->unk_33A += 0x3E8; + this->scale.y = this->scale.z = Math_CosS(this->unk_338) * 0.1f + 1.0f; + temp_fv1_2 = (Math_SinS(this->unk_338) * 0.1f) + 1.0f; + this->scale.x = SQ(temp_fv1_2); + this->actor.world.pos.y = this->actor.home.pos.y + (Math_SinS(this->unk_338) * 25.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EF80.s") +void func_80C1ED0C(DmBal* this) { + if (this->unk_336 == 1) { + this->eyeIndex = 1; + } else if (this->timer >= 4) { + this->timer--; + } else if (this->timer != 0) { + this->eyeIndex = 1; + this->timer--; + } else { + this->eyeIndex = 0; + this->timer = 60; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1F060.s") +void func_80C1ED64(DmBal* this, GlobalContext* globalCtx, Vec3f* arg2, Vec3f* arg3, f32 arg4) { + Actor* paper = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PAPER, arg2->x, arg2->y, arg2->z, 0, 0, 0, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/DmBal_Draw.s") + if (paper != NULL) { + paper->velocity = *arg3; + paper->gravity = arg4; + } +} + +Vec3f D_80C1F2C4 = { 0.0f, 9.0f, 0.0f }; + +void DmBal_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DmBal* this = THIS; + Vec3f sp3C; + Vec3f sp30; + + if (Animation_OnFrame(&this->skelAnime, 29.0f) && (this->skelAnime.animation == &object_bal_Anim_001804)) { + sp3C = this->actor.world.pos; + sp30 = D_80C1F2C4; + sp3C.x += 7.0f * Math_SinS(this->actor.shape.rot.y); + sp3C.y += 2.5f; + sp3C.z += 7.0f * Math_CosS(this->actor.shape.rot.y); + sp30.x = Math_SinS(this->actor.shape.rot.y) * 5.0f; + sp30.z = Math_CosS(this->actor.shape.rot.y) * 5.0f; + func_80C1ED64(this, globalCtx, &sp3C, &sp30, -0.4f); + func_80C1ED64(this, globalCtx, &sp3C, &sp30, -0.5f); + } + this->actionFunc(this, globalCtx); + func_80C1EAE8(this, globalCtx); + func_80C1EC60(this, globalCtx); + func_80C1ED0C(this); + SkelAnime_Update(&this->skelAnime); +} + +s32 DmBal_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + DmBal* this = THIS; + Vec3s rots; + + if (limbIndex == 6) { + rots.x = Math_SinS(this->unk_33A) * 3640.0f; + rots.z = Math_CosS(this->unk_33A) * 3640.0f; + Matrix_RotateZYX(rots.x, 0, rots.z, MTXMODE_APPLY); + Matrix_Scale(this->scale.x, this->scale.y, this->scale.z, MTXMODE_APPLY); + Matrix_RotateZS(-rots.z, MTXMODE_APPLY); + Matrix_RotateXS(-rots.x, MTXMODE_APPLY); + } + return false; +} + +void DmBal_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +} + +TexturePtr sEyeTextures[] = { object_bal_Tex_006050, object_bal_Tex_0094D0 }; + +void DmBal_Draw(Actor* thisx, GlobalContext* globalCtx) { + DmBal* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIndex])); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + DmBal_OverrideLimbDraw, DmBal_PostLimbDraw, &this->actor); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.h b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.h index 19c481ab6..1a09abb1b 100644 --- a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.h +++ b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.h @@ -2,17 +2,26 @@ #define Z_DM_BAL_H #include "global.h" +#include "objects/object_bal/object_bal.h" struct DmBal; typedef void (*DmBalActionFunc)(struct DmBal*, GlobalContext*); typedef struct DmBal { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ DmBalActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x1B0]; -} DmBal; // size = 0x33C + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ DmBalActionFunc actionFunc; + /* 0x18C */ Vec3f scale; + /* 0x198 */ s32 eyeIndex; + /* 0x262 */ Vec3s jointTable[OBJECT_BAL_LIMB_MAX]; + /* 0x19C */ Vec3s morphTable[OBJECT_BAL_LIMB_MAX]; + /* 0x328 */ UNK_TYPE1 pad_328[12]; + /* 0x334 */ s16 timer; + /* 0x336 */ s16 unk_336; + /* 0x338 */ s16 unk_338; + /* 0x33A */ s16 unk_33A; +} DmBal; /* size = 0x33C */ extern const ActorInit Dm_Bal_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 52f48248c..87d94e6ea 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16997,8 +16997,8 @@ 0x80C1ED0C:("func_80C1ED0C",), 0x80C1ED64:("func_80C1ED64",), 0x80C1EDE4:("DmBal_Update",), - 0x80C1EF80:("func_80C1EF80",), - 0x80C1F060:("func_80C1F060",), + 0x80C1EF80:("DmBal_OverrideLimbDraw",), + 0x80C1F060:("DmBal_PostLimbDraw",), 0x80C1F078:("DmBal_Draw",), 0x80C1F3D0:("EnPaper_Init",), 0x80C1F45C:("EnPaper_Destroy",), From 8d6b4d68ad5a821c13124cb072bddb6cd46a6503 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sun, 19 Jun 2022 20:18:03 -0300 Subject: [PATCH 250/257] ovl_Bg_Keikoku_Saku decompiled (#847) * ovl_Bg_Keikoku_Saku decompiled * reloc change * BGKEIKOKUSAKU_GET_SWITCHFLAG name fix * pr review fixes * pr review fixes Co-authored-by: SonicDcer --- spec | 3 +- .../ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c | 76 ++++++++++++++++--- .../ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.h | 13 ++-- undefined_syms.txt | 5 -- 4 files changed, 73 insertions(+), 24 deletions(-) diff --git a/spec b/spec index 8cba55b21..6740d7e1e 100644 --- a/spec +++ b/spec @@ -2891,8 +2891,7 @@ beginseg name "ovl_Bg_Keikoku_Saku" compress include "build/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.o" - include "build/data/ovl_Bg_Keikoku_Saku/ovl_Bg_Keikoku_Saku.data.o" - include "build/data/ovl_Bg_Keikoku_Saku/ovl_Bg_Keikoku_Saku.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Keikoku_Saku/ovl_Bg_Keikoku_Saku_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c b/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c index 0e7488a9a..24f18bb2f 100644 --- a/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c +++ b/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.c @@ -5,6 +5,7 @@ */ #include "z_bg_keikoku_saku.h" +#include "objects/object_keikoku_obj/object_keikoku_obj.h" #define FLAGS 0x00000000 @@ -15,7 +16,10 @@ void BgKeikokuSaku_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgKeikokuSaku_Update(Actor* thisx, GlobalContext* globalCtx); void BgKeikokuSaku_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A5389C(BgKeikokuSaku* this, GlobalContext* globalCtx); +void func_80A538E0(BgKeikokuSaku* this, GlobalContext* globalCtx); +void func_80A53994(BgKeikokuSaku* this, GlobalContext* globalCtx); + const ActorInit Bg_Keikoku_Saku_InitVars = { ACTOR_BG_KEIKOKU_SAKU, ACTORCAT_ITEMACTION, @@ -28,21 +32,71 @@ const ActorInit Bg_Keikoku_Saku_InitVars = { (ActorFunc)BgKeikokuSaku_Draw, }; -#endif +void BgKeikokuSaku_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgKeikokuSaku* this = THIS; + CollisionHeader* colHeader = NULL; -extern UNK_TYPE D_06001640; -extern UNK_TYPE D_06002300; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_keikoku_obj_Colheader_002300, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + this->switchFlag = BGKEIKOKUSAKU_GET_SWITCHFLAG(thisx); + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->dyna.actor.world.pos.z = 2659.0f; + } else { + this->actionFunc = func_80A5389C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/BgKeikokuSaku_Init.s") +void BgKeikokuSaku_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgKeikokuSaku* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/BgKeikokuSaku_Destroy.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/func_80A5389C.s") +void func_80A5389C(BgKeikokuSaku* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->actionFunc = func_80A538E0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/func_80A538E0.s") +void func_80A538E0(BgKeikokuSaku* this, GlobalContext* globalCtx) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_METALGATE_OPEN - SFX_FLAG); + this->dyna.actor.world.pos.z -= 2.0f + BREG(8); + if (this->dyna.actor.world.pos.z < (BREG(9) + 2660.0f)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP); + this->timer = 30; + this->actionFunc = func_80A53994; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/func_80A53994.s") +void func_80A53994(BgKeikokuSaku* this, GlobalContext* globalCtx) { + if (this->timer == 0) { + this->actionFunc = func_80A5389C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/BgKeikokuSaku_Update.s") +void BgKeikokuSaku_Update(Actor* thisx, GlobalContext* globalCtx) { + BgKeikokuSaku* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/BgKeikokuSaku_Draw.s") + if (this->timer) { + this->timer--; + } + this->dyna.actor.world.pos.x = BREG(5) + this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.y = BREG(6) + this->dyna.actor.home.pos.y; + this->dyna.actor.world.pos.z = BREG(7) + this->dyna.actor.home.pos.z; + this->dyna.actor.scale.x = (BREG(10) / 1000.0f) + 0.1f; + this->dyna.actor.scale.y = (BREG(11) / 1000.0f) + 0.1f; + this->dyna.actor.scale.z = (BREG(12) / 1000.0f) + 0.1f; + this->actionFunc(this, globalCtx); +} + +void BgKeikokuSaku_Draw(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_keikoku_obj_DL_001640); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.h b/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.h index 6092edcb4..8fa663460 100644 --- a/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.h +++ b/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.h @@ -3,17 +3,18 @@ #include "global.h" +#define BGKEIKOKUSAKU_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) + struct BgKeikokuSaku; typedef void (*BgKeikokuSakuActionFunc)(struct BgKeikokuSaku*, GlobalContext*); typedef struct BgKeikokuSaku { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgKeikokuSakuActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x4]; -} BgKeikokuSaku; // size = 0x164 - + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgKeikokuSakuActionFunc actionFunc; + /* 0x160 */ s16 switchFlag; + /* 0x162 */ s16 timer; +} BgKeikokuSaku; // Size = 0x164 extern const ActorInit Bg_Keikoku_Saku_InitVars; #endif // Z_BG_KEIKOKU_SAKU_H diff --git a/undefined_syms.txt b/undefined_syms.txt index be8e81289..64a46e14c 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -644,11 +644,6 @@ D_06012700 = 0x06012700; D_06012728 = 0x06012728; D_06012788 = 0x06012788; -// ovl_Bg_Keikoku_Saku - -D_06001640 = 0x06001640; -D_06002300 = 0x06002300; - // ovl_Bg_Kin2_Bombwall D_06000128 = 0x06000128; From 2c10d510228e77368fd80efc92e5743d0416591a Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sun, 19 Jun 2022 20:21:44 -0300 Subject: [PATCH 251/257] ovl_Bg_Ikninside OK (#848) * ovl_Bg_Ikninside decompiled * PR review fixes * pr review fixes * pr review fixes Co-authored-by: SonicDcer --- spec | 3 +- .../actors/ovl_Bg_Ikninside/z_bg_ikninside.c | 132 +++++++++++++++--- .../actors/ovl_Bg_Ikninside/z_bg_ikninside.h | 12 +- undefined_syms.txt | 5 - 4 files changed, 124 insertions(+), 28 deletions(-) diff --git a/spec b/spec index 6740d7e1e..e407bad50 100644 --- a/spec +++ b/spec @@ -4936,8 +4936,7 @@ beginseg name "ovl_Bg_Ikninside" compress include "build/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.o" - include "build/data/ovl_Bg_Ikninside/ovl_Bg_Ikninside.data.o" - include "build/data/ovl_Bg_Ikninside/ovl_Bg_Ikninside.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ikninside/ovl_Bg_Ikninside_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c index a09bcba87..2c2244425 100644 --- a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c +++ b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c @@ -5,6 +5,7 @@ */ #include "z_bg_ikninside.h" +#include "objects/object_ikninside_obj/object_ikninside_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,8 @@ void BgIkninside_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgIkninside_Update(Actor* thisx, GlobalContext* globalCtx); void BgIkninside_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80C072D0(BgIkninside* this, GlobalContext* globalCtx); + const ActorInit Bg_Ikninside_InitVars = { ACTOR_BG_IKNINSIDE, ACTORCAT_BG, @@ -28,30 +30,128 @@ const ActorInit Bg_Ikninside_InitVars = { (ActorFunc)BgIkninside_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C076A8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x80000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static Gfx* D_80C076A0[] = { object_ikninside_obj_DL_00A748, object_ikninside_obj_DL_00A5A8 }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x80000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 32, 32, 0, { 0, 0, 0 } }, }; -#endif +void BgIkninside_Init(Actor* thisx, GlobalContext* globalCtx) { + BgIkninside* this = THIS; + CollisionHeader* colHeader = NULL; + s32 pad; -extern ColliderCylinderInit D_80C076A8; + Actor_SetScale(&this->dyna.actor, 0.1f); + this->actionFunc = func_80C072D0; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_ikninside_obj_Colheader_00DE48, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + if (Flags_GetSwitch(globalCtx, DMIKNINSIDE_GET_SWITCH(thisx))) { + Actor_MarkForDeath(&this->dyna.actor); + } +} -extern UNK_TYPE D_0600CC78; -extern UNK_TYPE D_0600DE48; +void BgIkninside_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIkninside* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/BgIkninside_Init.s") + Collider_DestroyCylinder(globalCtx, &this->collider); + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/BgIkninside_Destroy.s") +void func_80C07220(BgIkninside* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/func_80C07220.s") +void func_80C07230(BgIkninside* this, GlobalContext* globalCtx) { + if (this->dyna.actor.cutscene == -1) { + this->actionFunc = func_80C07220; + } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } else if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->actionFunc = func_80C07220; + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/func_80C07230.s") +static Vec3f D_80C076D4 = { 0.0f, -1.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/func_80C072D0.s") +void func_80C072D0(BgIkninside* this, GlobalContext* globalCtx) { + s16 altitude; + s16 azimuth; + Vec3f pos; + Vec3f velocity; + f32 speed; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/BgIkninside_Update.s") + if (this->collider.base.acFlags & AC_HIT) { + if ((this->collider.info.acHitInfo != NULL) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000000)) { + for (i = 0; i < 20; i++) { + altitude = Rand_S16Offset(0x1800, 0x2800); + azimuth = (u32)Rand_Next() >> 0x10; + speed = Rand_ZeroFloat(3.0f) + 8.0f; + velocity.x = speed * Math_CosS(altitude) * Math_SinS(azimuth); + velocity.y = speed * Math_SinS(altitude) + Rand_ZeroFloat(5.0f); + velocity.z = speed * Math_CosS(altitude) * Math_CosS(azimuth); + pos.x = Rand_ZeroFloat(10.0f) * velocity.x + this->dyna.actor.world.pos.x; + pos.y = Rand_ZeroFloat(1.0f) * velocity.y + this->dyna.actor.world.pos.y; + pos.z = Rand_ZeroFloat(10.0f) * velocity.z + this->dyna.actor.world.pos.z; + EffectSsHahen_Spawn(globalCtx, &pos, &velocity, &D_80C076D4, 0, 30, OBJECT_IKNINSIDE_OBJ, 25, + D_80C076A0[i & 1]); + } + Flags_SetSwitch(globalCtx, DMIKNINSIDE_GET_SWITCH(&this->dyna.actor)); + this->actionFunc = func_80C07230; + this->dyna.actor.draw = NULL; + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } else { + this->timer = 20; + } + } + if (this->timer > 0) { + if ((this->timer % 2) != 0) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 1.0f; + } else { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + } + this->timer--; + } else { + this->timer = 0; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikninside/BgIkninside_Draw.s") +void BgIkninside_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIkninside* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgIkninside_Draw(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(globalCtx->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, object_ikninside_obj_DL_00CC78); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.h b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.h index a9253f419..954b15b0c 100644 --- a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.h +++ b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.h @@ -5,14 +5,16 @@ struct BgIkninside; +#define DMIKNINSIDE_GET_SWITCH(thisx) (((thisx)->params & 0xFE00) >> 9) + typedef void (*BgIkninsideActionFunc)(struct BgIkninside*, GlobalContext*); typedef struct BgIkninside { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x68]; - /* 0x01AC */ BgIkninsideActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ UNK_TYPE1 pad_1A8[2]; + /* 0x1AA */ s16 timer; + /* 0x1AC */ BgIkninsideActionFunc actionFunc; } BgIkninside; // size = 0x1B0 -extern const ActorInit Bg_Ikninside_InitVars; - #endif // Z_BG_IKNINSIDE_H diff --git a/undefined_syms.txt b/undefined_syms.txt index 64a46e14c..403905235 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -626,11 +626,6 @@ D_06001AD8 = 0x06001AD8; D_06001E18 = 0x06001E18; D_06002358 = 0x06002358; -// ovl_Bg_Ikninside - -D_0600CC78 = 0x0600CC78; -D_0600DE48 = 0x0600DE48; - // ovl_Bg_Iknv_Doukutu D_0600DB60 = 0x0600DB60; From 064b3e5493ba554ff3b97732ea4190b5df633c73 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sun, 19 Jun 2022 20:31:01 -0300 Subject: [PATCH 252/257] ovl_Obj_Rotlift decompiled (#850) * ovl_Obj_Rotlift decompiled * fixes * fixes 2 * format * PR review fixes * PR review fixes * PR review fixes * PR review fixes * PR review fixes * pr review fixes Co-authored-by: SonicDcer --- spec | 3 +- .../actors/ovl_Obj_Rotlift/z_obj_rotlift.c | 113 ++++++++++++++++-- .../actors/ovl_Obj_Rotlift/z_obj_rotlift.h | 9 +- 3 files changed, 110 insertions(+), 15 deletions(-) diff --git a/spec b/spec index e407bad50..6dc4c4285 100644 --- a/spec +++ b/spec @@ -4229,8 +4229,7 @@ beginseg name "ovl_Obj_Rotlift" compress include "build/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.o" - include "build/data/ovl_Obj_Rotlift/ovl_Obj_Rotlift.data.o" - include "build/data/ovl_Obj_Rotlift/ovl_Obj_Rotlift.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Rotlift/ovl_Obj_Rotlift_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c index 6163c753c..b17827e0a 100644 --- a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c +++ b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c @@ -5,17 +5,25 @@ */ #include "z_obj_rotlift.h" +#include "objects/object_rotlift/object_rotlift.h" #define FLAGS 0x00000000 #define THIS ((ObjRotlift*)thisx) -void ObjRotlift_Init(Actor* thisx, GlobalContext* globalCtx); +void ObjRotlift_Init(Actor* thisx, GlobalContext* globalCtx2); void ObjRotlift_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjRotlift_Update(Actor* thisx, GlobalContext* globalCtx); void ObjRotlift_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void ObjRotlift_MoveDekuFlowers(ObjRotlift* this); + +typedef struct ModelInfo { + /* 0x0 */ Gfx* dList; + /* 0x4 */ AnimatedMaterial* animMat; + /* 0x8 */ CollisionHeader* colHeader; +} ModelInfo; // size = 0xC + const ActorInit Obj_Rotlift_InitVars = { ACTOR_OBJ_ROTLIFT, ACTORCAT_BG, @@ -28,24 +36,107 @@ const ActorInit Obj_Rotlift_InitVars = { (ActorFunc)ObjRotlift_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B96178[] = { +struct ModelInfo sModelInfo[] = { + { + object_rotlift_DL_000400, + object_rotlift_Matanimheader_001F98, + &object_rotlift_Colheader_002190, + }, + { + object_rotlift_DL_002CE0, + object_rotlift_Matanimheader_004A08, + &object_rotlift_Colheader_004DF0, + }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 800, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), }; -#endif +void ObjRotlift_MoveDekuFlowers(ObjRotlift* this) { + ObjEtcetera** dekuFlower = this->dekuFlowers; + ObjEtcetera* curDekuFlower; + f32 posOffset = 300.0f; + s32 i; -extern InitChainEntry D_80B96178[]; + for (i = 0; i < ARRAY_COUNT(this->dekuFlowers); i++, dekuFlower++) { + curDekuFlower = *dekuFlower; + if (curDekuFlower->dyna.actor.update == NULL) { + *dekuFlower = NULL; + } else { + curDekuFlower->dyna.actor.world.pos.x = + this->dyna.actor.world.pos.x + posOffset * Math_SinS(this->dyna.actor.shape.rot.y); + curDekuFlower->dyna.actor.world.pos.y = this->dyna.actor.world.pos.y + 380.0f * this->dyna.actor.scale.y; + curDekuFlower->dyna.actor.world.pos.z = + this->dyna.actor.world.pos.z + posOffset * Math_CosS(this->dyna.actor.shape.rot.y); + curDekuFlower->dyna.actor.shape.rot.y = this->dyna.actor.shape.rot.y; + } + posOffset -= 600.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/func_80B95E20.s") +void ObjRotlift_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjRotlift* this = THIS; + s32 type = OBJROTLIFT_GET_TYPE(&this->dyna.actor); + s32 dekuFlowerType; + s32 i; + ModelInfo* modelInfo; + ObjEtcetera** dekuFlowers; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/ObjRotlift_Init.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + if (type == 0) { + for (dekuFlowers = this->dekuFlowers, i = 0; i < ARRAY_COUNT(this->dekuFlowers); i++, dekuFlowers++) { + if (!OBJROTLIFT_GET_4000(thisx) || (i != 0)) { + dekuFlowerType = 0; + } else { + dekuFlowerType = 0x100; + } + *dekuFlowers = (ObjEtcetera*)Actor_SpawnAsChild( + &globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_OBJ_ETCETERA, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, this->dyna.actor.shape.rot.x, + this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, dekuFlowerType); + } + ObjRotlift_MoveDekuFlowers(this); + } + DynaPolyActor_Init(&this->dyna, 3); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/ObjRotlift_Destroy.s") + modelInfo = &sModelInfo[type]; + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, modelInfo->colHeader); + modelInfo->animMat = Lib_SegmentedToVirtual(modelInfo->animMat); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/ObjRotlift_Update.s") +void ObjRotlift_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjRotlift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Rotlift/ObjRotlift_Draw.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void ObjRotlift_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjRotlift* this = THIS; + s16 angShift; + s32 angVelocity; + + if (OBJROTLIFT_GET_TYPE(&this->dyna.actor) == 0) { + ObjRotlift_MoveDekuFlowers(this); + } + if (thisx->params >= 0) { + angVelocity = -0xC8; + } else { + angVelocity = 0xC8; + } + angShift = angVelocity; + this->dyna.actor.shape.rot.y += angShift; +} + +void ObjRotlift_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjRotlift* this = THIS; + ModelInfo* modelInfo = &sModelInfo[OBJROTLIFT_GET_TYPE(&this->dyna.actor)]; + + AnimatedMat_Draw(globalCtx, modelInfo->animMat); + Gfx_DrawDListOpa(globalCtx, modelInfo->dList); +} diff --git a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.h b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.h index a58a6b621..cc627a295 100644 --- a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.h +++ b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.h @@ -3,11 +3,16 @@ #include "global.h" +#include "overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h" + +#define OBJROTLIFT_GET_TYPE(thisx) ((thisx)->params & 1) +#define OBJROTLIFT_GET_4000(thisx) ((thisx)->params & 0x4000) + struct ObjRotlift; typedef struct ObjRotlift { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x20]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjEtcetera* dekuFlowers[2]; } ObjRotlift; // size = 0x164 extern const ActorInit Obj_Rotlift_InitVars; From a039a2f34a65ec9b85763664b30981f715563558 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sun, 19 Jun 2022 16:38:51 -0700 Subject: [PATCH 253/257] BgIkanaDharma (punchable pillar segments in STT) OK (#851) * Bg_Ikana_Dharma decompiled * Bg_Ikana_Dharma more stuff * remove & from function pointers * use THIS macro * use THIS macro * return -> else * GET_PLAYER * slightly better match (this2 only used once) * fix warnings; name variables * better match in BgIkanaDharma_Init; more param macros * Rebase to latest master and some minor cleanup * More cleanup * Document object * Respond to isghj5's review * Respond to Elliptic's review * Better pack macro * Respond to hensldm's review Co-authored-by: immibis --- assets/xml/objects/object_ikana_obj.xml | 6 +- spec | 4 +- .../ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c | 232 ++++++++++++++++-- .../ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.h | 11 +- tools/disasm/functions.txt | 14 +- undefined_syms.txt | 5 - 6 files changed, 228 insertions(+), 44 deletions(-) diff --git a/assets/xml/objects/object_ikana_obj.xml b/assets/xml/objects/object_ikana_obj.xml index 66398991b..6040495ab 100644 --- a/assets/xml/objects/object_ikana_obj.xml +++ b/assets/xml/objects/object_ikana_obj.xml @@ -9,8 +9,8 @@ - - + + @@ -38,7 +38,7 @@ - + diff --git a/spec b/spec index 6dc4c4285..ac6a462aa 100644 --- a/spec +++ b/spec @@ -4802,9 +4802,7 @@ beginseg name "ovl_Bg_Ikana_Dharma" compress include "build/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.o" - include "build/data/ovl_Bg_Ikana_Dharma/ovl_Bg_Ikana_Dharma.data.o" - include "build/data/ovl_Bg_Ikana_Dharma/ovl_Bg_Ikana_Dharma.bss.o" - include "build/data/ovl_Bg_Ikana_Dharma/ovl_Bg_Ikana_Dharma.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ikana_Dharma/ovl_Bg_Ikana_Dharma_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c index 2fb508c79..6048a8c9c 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.c @@ -5,6 +5,7 @@ */ #include "z_bg_ikana_dharma.h" +#include "assets/objects/object_ikana_obj/object_ikana_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,13 @@ void BgIkanaDharma_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgIkanaDharma_Update(Actor* thisx, GlobalContext* globalCtx); void BgIkanaDharma_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void BgIkanaDharma_SetupWaitForHit(BgIkanaDharma* this); +void BgIkanaDharma_WaitForHit(BgIkanaDharma* this, GlobalContext* globalCtx); +void BgIkanaDharma_SetupStartCutscene(BgIkanaDharma* this); +void BgIkanaDharma_StartCutscene(BgIkanaDharma* this, GlobalContext* globalCtx); +void BgIkanaDharma_SetupWaitForCutsceneToEnd(BgIkanaDharma* this); +void BgIkanaDharma_WaitForCutsceneToEnd(BgIkanaDharma* this, GlobalContext* globalCtx); + const ActorInit Bg_Ikana_Dharma_InitVars = { ACTOR_BG_IKANA_DHARMA, ACTORCAT_BG, @@ -28,47 +35,226 @@ const ActorInit Bg_Ikana_Dharma_InitVars = { (ActorFunc)BgIkanaDharma_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BECAD0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000100, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000100, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 98, 10, 25, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BECAFC[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 320, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 320, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1100, ICHAIN_STOP), }; -#endif +static BgIkanaDharma* sFirstHitBgIkanaDharma; -extern ColliderCylinderInit D_80BECAD0; -extern InitChainEntry D_80BECAFC[]; +void BgIkanaDharma_SpawnEffects(BgIkanaDharma* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f pos; + Vec3f velocity; + Vec3f accel; + s32 i; + f32 initialRadius = this->dyna.actor.scale.x * 200.0f; + f32 initialY = this->dyna.actor.scale.y * 50.0f; -extern UNK_TYPE D_060008C8; -extern UNK_TYPE D_06000C50; + for (i = 0; i < 4; i++) { + f32 speed = (Rand_ZeroOne() * 5.0f) + 5.0f; + s16 angle = ((u32)Rand_Next() >> 0x12) + this->dyna.actor.world.rot.y + 0x6000; + f32 dirX = Math_SinS(angle); + f32 dirZ = Math_CosS(angle); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC240.s") + pos.x = (dirX * initialRadius) + this->dyna.actor.world.pos.x; + pos.y = this->dyna.actor.world.pos.y + initialY; + pos.z = (dirZ * initialRadius) + this->dyna.actor.world.pos.z; + velocity.x = speed * dirX; + velocity.y = Rand_ZeroOne() + 0.5f; + velocity.z = speed * dirZ; + accel.x = velocity.x * -0.05f; + accel.y = -0.15f; + accel.z = velocity.z * -0.05f; + EffectSsKirakira_SpawnSmallYellow(globalCtx, &pos, &velocity, &accel); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/BgIkanaDharma_Init.s") +void BgIkanaDharma_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BgIkanaDharma* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/BgIkanaDharma_Destroy.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.scale.x = 0.3f; + this->dyna.actor.scale.y = 0.1f; + this->dyna.actor.scale.z = 0.3f; + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gStoneTowerTemplePunchablePillarCol); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + if (!BGIKANADHARMA_IS_CHILD(&this->dyna.actor)) { + f32 segmentY = this->dyna.actor.world.pos.y; + s32 numSegments = BGIKANADHARMA_NUM_SEGMENTS(&this->dyna.actor); + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC5C4.s") + for (i = 0; i < numSegments; i++) { + segmentY += 60.0f; + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_BG_IKANA_DHARMA, + this->dyna.actor.world.pos.x, segmentY, this->dyna.actor.world.pos.z, + this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, + this->dyna.actor.shape.rot.z, BGIKANADHARMA_PARAMS(0, true, 0), + this->dyna.actor.cutscene, this->dyna.actor.unk20, NULL); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC5E0.s") + this->dyna.actor.bgCheckFlags |= 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC758.s") + BgIkanaDharma_SetupWaitForHit(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC790.s") +void BgIkanaDharma_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaDharma* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC7EC.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); + if (sFirstHitBgIkanaDharma == this) { + sFirstHitBgIkanaDharma = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/func_80BEC808.s") +void BgIkanaDharma_SetupWaitForHit(BgIkanaDharma* this) { + this->actionFunc = BgIkanaDharma_WaitForHit; + this->dyna.actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/BgIkanaDharma_Update.s") +void BgIkanaDharma_WaitForHit(BgIkanaDharma* this, GlobalContext* globalCtx) { + s32 wasHit = (this->collider.base.acFlags & AC_HIT) != 0; + Player* player = GET_PLAYER(globalCtx); + BgIkanaDharma* this2 = this; + s32 tempAngle1; + s32 tempAngle2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Dharma/BgIkanaDharma_Draw.s") + if (wasHit) { + this->collider.base.acFlags &= ~AC_HIT; + } + + if (wasHit && sFirstHitBgIkanaDharma == NULL) { + sFirstHitBgIkanaDharma = this2; + Flags_SetSwitch(globalCtx, BGIKANADHARMA_GET_SWITCHFLAG(&this->dyna.actor)); + tempAngle1 = BINANG_ADD(this->dyna.actor.yawTowardsPlayer, 0x8000); + tempAngle2 = (BINANG_SUB(player->actor.shape.rot.y, tempAngle1) >> 1); + this->dyna.actor.world.rot.y = tempAngle1 + tempAngle2 + 0xF000; + this->dyna.actor.speedXZ = 20.0f; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DARUMA_VANISH); + BgIkanaDharma_SetupStartCutscene(this); + } else if ((this->dyna.actor.flags & ACTOR_FLAG_40) == ACTOR_FLAG_40 && sFirstHitBgIkanaDharma == NULL && + this->dyna.actor.xzDistToPlayer < 420.0f) { + tempAngle1 = BINANG_SUB(this->dyna.actor.yawTowardsPlayer, player->actor.shape.rot.y); + tempAngle1 = ABS_ALT(tempAngle1); + + if (tempAngle1 > 0x4000) { + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void BgIkanaDharma_SetupStartCutscene(BgIkanaDharma* this) { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->actionFunc = BgIkanaDharma_StartCutscene; +} + +void BgIkanaDharma_StartCutscene(BgIkanaDharma* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + BgIkanaDharma_SetupWaitForCutsceneToEnd(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void BgIkanaDharma_SetupWaitForCutsceneToEnd(BgIkanaDharma* this) { + this->cutsceneFramesRemaining = 10; + this->actionFunc = BgIkanaDharma_WaitForCutsceneToEnd; +} + +void BgIkanaDharma_WaitForCutsceneToEnd(BgIkanaDharma* this, GlobalContext* globalCtx) { + if (this->cutsceneFramesRemaining > 0) { + this->cutsceneFramesRemaining--; + + if (this->cutsceneFramesRemaining == 0) { + if (sFirstHitBgIkanaDharma == this) { + sFirstHitBgIkanaDharma = NULL; + } + + ActorCutscene_Stop(this->dyna.actor.cutscene); + } + } + + if (Math_StepToF(&this->dyna.actor.scale.y, 0.0f, 1.0f / 300.0f) != 0) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + this->dyna.actor.scale.x = this->dyna.actor.scale.y * 3.0f; + this->dyna.actor.scale.z = this->dyna.actor.scale.y * 3.0f; + BgIkanaDharma_SpawnEffects(this, globalCtx); + } +} + +void BgIkanaDharma_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaDharma* this = THIS; + + this->actionFunc(this, globalCtx); + if (this->actionFunc == BgIkanaDharma_WaitForHit) { + DynaPolyActor* actorBelow; + s32 pad[2]; + + func_800B4AEC(globalCtx, &this->dyna.actor, 30.0f); + actorBelow = DynaPoly_GetActor(&globalCtx->colCtx, this->dyna.actor.floorBgId); + if (actorBelow == NULL) { + Actor_MoveWithGravity(&this->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + if (this->dyna.actor.bgCheckFlags & 2) { + s16 quake = Quake_Add(globalCtx->cameraPtrs[globalCtx->activeCamera], 3); + + Quake_SetSpeed(quake, 21536); + Quake_SetQuakeValues(quake, 4, 0, 0, 0); + Quake_SetCountdown(quake, 12); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else { + if (actorBelow->actor.id == ACTOR_BG_IKANA_DHARMA) { + this->dyna.actor.world.pos.y = actorBelow->actor.world.pos.y + 60.0f; + } else { + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight; + } + + this->dyna.actor.velocity.y = 0.0f; + } + } else { + f32 wallCheckRadius = this->dyna.actor.scale.x * 300.0f; + wallCheckRadius = CLAMP_MIN(wallCheckRadius, 2.0f); + + Actor_MoveWithGravity(&this->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 20.0f, wallCheckRadius, 0.0f, 5); + } + + Actor_SetFocus(&this->dyna.actor, 40.0f); +} + +void BgIkanaDharma_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaDharma* this = THIS; + + Gfx_DrawDListOpa(globalCtx, gStoneTowerTemplePunchablePillarDL); +} diff --git a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.h b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.h index ddd81e7d8..bf769a1a1 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Dharma/z_bg_ikana_dharma.h @@ -3,15 +3,20 @@ #include "global.h" +#define BGIKANADHARMA_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F) +#define BGIKANADHARMA_IS_CHILD(thisx) (((thisx)->params >> 5) & 1) +#define BGIKANADHARMA_NUM_SEGMENTS(thisx) ((thisx)->params & 0xF) +#define BGIKANADHARMA_PARAMS(switchFlag, isChild, numSegments) (((switchFlag & 0x7F) << 8) | ((isChild & 1) << 5) | (numSegments & 0xF)) + struct BgIkanaDharma; typedef void (*BgIkanaDharmaActionFunc)(struct BgIkanaDharma*, GlobalContext*); typedef struct BgIkanaDharma { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderCylinder collider; /* 0x01A8 */ BgIkanaDharmaActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x01AC */ s8 cutsceneFramesRemaining; } BgIkanaDharma; // size = 0x1B0 extern const ActorInit Bg_Ikana_Dharma_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 87d94e6ea..2c74907d5 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16220,15 +16220,15 @@ 0x80BEC080:("EffLastday_Update",), 0x80BEC0A4:("func_80BEC0A4",), 0x80BEC0DC:("EffLastday_Draw",), - 0x80BEC240:("func_80BEC240",), + 0x80BEC240:("BgIkanaDharma_SpawnEffects",), 0x80BEC3F4:("BgIkanaDharma_Init",), 0x80BEC560:("BgIkanaDharma_Destroy",), - 0x80BEC5C4:("func_80BEC5C4",), - 0x80BEC5E0:("func_80BEC5E0",), - 0x80BEC758:("func_80BEC758",), - 0x80BEC790:("func_80BEC790",), - 0x80BEC7EC:("func_80BEC7EC",), - 0x80BEC808:("func_80BEC808",), + 0x80BEC5C4:("BgIkanaDharma_SetupWaitForHit",), + 0x80BEC5E0:("BgIkanaDharma_WaitForHit",), + 0x80BEC758:("BgIkanaDharma_SetupStartCutscene",), + 0x80BEC790:("BgIkanaDharma_StartCutscene",), + 0x80BEC7EC:("BgIkanaDharma_SetupWaitForCutsceneToEnd",), + 0x80BEC808:("BgIkanaDharma_WaitForCutsceneToEnd",), 0x80BEC8C0:("BgIkanaDharma_Update",), 0x80BECA80:("BgIkanaDharma_Draw",), 0x80BECBE0:("func_80BECBE0",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 403905235..f2f9c6af1 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -612,11 +612,6 @@ D_06000C90 = 0x06000C90; D_06000288 = 0x06000288; -// ovl_Bg_Ikana_Dharma - -D_060008C8 = 0x060008C8; -D_06000C50 = 0x06000C50; - // ovl_Bg_Ikana_Mirror D_060014B0 = 0x060014B0; From d318b1f2854e98e2510812dd09e7c84b14f17622 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 19 Jun 2022 16:49:20 -0700 Subject: [PATCH 254/257] SubS Time Paths (Finale) (#823) * Merge in sub_s_models * Update subs DL names * Unused Weight pathing * Function headers for weightpathing * TimePathing WIP * Timepathing, still unsure about unk184 * Move subs functions from functions.h to z64subs.h * Add fake comment * Some cleanup and renames * Renames/cleanup of actors that use timepath * Cleanup * More cleanup * Rename unk stuff * Merge in upstream/master * TimeElapsed -> elapsedTime * Fix * Final cleanup * Fix waypoint comments * Review pt. 1 * Add clarifying comment to SubS_TimePathing_FillWeightArray * format.sh * Fix order comments * weightArray -> knots * Review pt 1 * Review pt 2 * Update src/code/z_sub_s.c Co-authored-by: EllipticEllipsis * Update src/code/z_sub_s.c Co-authored-by: EllipticEllipsis Co-authored-by: Maide <34639600+Kelebek1@users.noreply.github.com> Co-authored-by: Tom Overton Co-authored-by: EllipticEllipsis --- assets/xml/code/sub_s.xml | 4 +- include/functions.h | 56 +-- include/z64subs.h | 115 ++++- src/code/z_sub_s.c | 470 +++++++++++++++++- .../actors/ovl_Bg_Ingate/z_bg_ingate.c | 68 +-- .../actors/ovl_Bg_Ingate/z_bg_ingate.h | 16 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 66 +-- src/overlays/actors/ovl_En_Baba/z_en_baba.h | 16 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 107 ++-- src/overlays/actors/ovl_En_Gm/z_en_gm.h | 16 +- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 110 ++-- src/overlays/actors/ovl_En_Ig/z_en_ig.h | 16 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 115 ++--- src/overlays/actors/ovl_En_Pm/z_en_pm.h | 16 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 160 +++--- .../actors/ovl_En_Suttari/z_en_suttari.h | 17 +- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 105 ++-- src/overlays/actors/ovl_En_Tk/z_en_tk.h | 16 +- tools/disasm/functions.txt | 18 +- tools/disasm/variables.txt | 7 +- tools/sizes/code_functions.csv | 18 +- 21 files changed, 1004 insertions(+), 528 deletions(-) diff --git a/assets/xml/code/sub_s.xml b/assets/xml/code/sub_s.xml index 03329f0c5..76db7e32c 100644 --- a/assets/xml/code/sub_s.xml +++ b/assets/xml/code/sub_s.xml @@ -1,6 +1,6 @@ - - + + diff --git a/include/functions.h b/include/functions.h index 7e01d5afe..372f4d5fc 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2392,61 +2392,7 @@ void func_8013A46C(s32 flag); u32 func_8013A4C4(s32 flag); s16 func_8013A504(s16 val); s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax, s16 angleError); -struct EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag); -Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); -Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx); -s32 SubS_InCsMode(GlobalContext* globalCtx); -s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot); -void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits); -void func_8013AF00(f32* arg0, s32 arg1, s32 arg2); -s32 func_8013B010(f32* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, f32* arg6); -void func_8013B0C8(s32 arg0, f32 arg1, s32 arg2, f32* arg3, f32* arg4); -void func_8013B350(Vec3f* arg0, f32* arg1, f32 arg2, s32 arg3, s32 arg4, Vec3s* arg5, f32* arg6); -s32 func_8013B6B0(Path* path, f32* arg1, s32* arg2, s32 arg3, s32 arg4, s32* arg5, f32* arg6, Vec3f* arg7, s32 arg8); -void func_8013B878(GlobalContext* globalCtx, Path* path, s32 arg2, Vec3f* arg3); -Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max); -Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId); -s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index); -s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex); -Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex); -s32 func_8013C068(Path* path, s32 arg1, Vec3f* arg2, f32 arg3, s32 arg4); -s32 func_8013C624(Actor* actor, Path* path, s32* arg2, f32* arg3, s32 arg4, s32 arg5); -s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst); -s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 itemId, s32 type); -void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size); -void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], s8 parentBodyParts[]); -void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex); -s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax); -s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, TurnOptionsSet* options); -s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); -Path* SubS_GetPathByIndex(GlobalContext* globalCtx, s16 pathIndex, s16 max); -s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst); -s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq); -s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep); -s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); -s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx); -s8 SubS_GetObjectIndex(s16 id, GlobalContext* globalCtx); -Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); -s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs); -s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove); -s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst); -u8 SubS_GetPathCount(Path* paths, s32 index); -void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags); -s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc); -void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* actorPath); -s32 SubS_ActorPathing_MoveWithGravity(GlobalContext* globalCtx, ActorPathing* actorPath); -s32 SubS_ActorPathing_MoveWithoutGravityReverse(GlobalContext* globalCtx, ActorPathing* actorPath); -s32 SubS_ActorPathing_SetNextPoint(GlobalContext* globalCtx, ActorPathing* actorPath); -void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, s32* curIndex); -s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type); -s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes); -void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane); -s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersect); -Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor); -s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, func_8013E748_VerifyFunc verifyFunc); -s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, void* data); -s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, s16 actorYawTol); -s32 SubS_TurnToPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax); + // void func_8013EC10(void); void func_8013EC44(f32 a, u8 b, u8 c, u8 d); void func_8013ECE0(f32 xyzDistToPlayerSq, u8 arg1, u8 arg2, u8 arg3); diff --git a/include/z64subs.h b/include/z64subs.h index 3b13d2add..b39842195 100644 --- a/include/z64subs.h +++ b/include/z64subs.h @@ -8,6 +8,8 @@ extern Vec3f gOneVec3f; +#define SUBS_TIME_PATHING_ORDER 3 + typedef enum { /* 0 */ SUBS_CUTSCENE_SET_UNK_LINK_FIELDS, /* 1 */ SUBS_CUTSCENE_NORMAL, @@ -23,6 +25,20 @@ typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); #define SUBS_SHADOW_TEX_HEIGHT 64 #define SUBS_SHADOW_TEX_SIZE ((s32)sizeof(u8[SUBS_SHADOW_TEX_HEIGHT][SUBS_SHADOW_TEX_WIDTH])) +typedef struct TurnOptions { + /* 0x0 */ u16 rotMax; // binary angles + /* 0x2 */ u16 slowness; // larger for slower rotation, cannot be 0 + /* 0x4 */ u16 rotStepMin; // degrees + /* 0x6 */ u16 rotStepMax; // degrees +} TurnOptions; // size = 0x8 + +typedef struct TurnOptionsSet { + /* 0x00 */ TurnOptions headRotX; + /* 0x08 */ TurnOptions headRotY; + /* 0x10 */ TurnOptions torsoRotX; + /* 0x18 */ TurnOptions torsoRotY; +} TurnOptionsSet; // size = 0x20 + #define ACTOR_PATHING_RETURN_TO_START (1 << 0) #define ACTOR_PATHING_SWITCH_DIRECTION (1 << 1) #define ACTOR_PATHING_MOVE_BACKWARDS (1 << 3) @@ -38,20 +54,6 @@ typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); #define ACTOR_PATHING_REACHED_END \ (ACTOR_PATHING_REACHED_END_PERMANENT | ACTOR_PATHING_REACHED_END_TEMPORARY) -typedef struct TurnOptions { - /* 0x0 */ u16 rotMax; // binary angles - /* 0x2 */ u16 slowness; // larger for slower rotation, cannot be 0 - /* 0x4 */ u16 rotStepMin; // degrees - /* 0x6 */ u16 rotStepMax; // degrees -} TurnOptions; // size = 0x8 - -typedef struct TurnOptionsSet { - /* 0x00 */ TurnOptions headRotX; - /* 0x08 */ TurnOptions headRotY; - /* 0x10 */ TurnOptions torsoRotX; - /* 0x18 */ TurnOptions torsoRotY; -} TurnOptionsSet; // size = 0x20 - struct ActorPathing; typedef void (*ActorPathingComputeFunc)(struct GlobalContext*, struct ActorPathing*); typedef s32 (*ActorPathingUpdateFunc)(struct GlobalContext*, struct ActorPathing*); @@ -80,4 +82,89 @@ typedef struct ActorPathing { /* 0x68 */ ActorPathingUpdateFunc setNextPointFunc; // Return true if should compute and update again } ActorPathing; // size = 0x6C +struct EnDoor* SubS_FindDoor(struct GlobalContext* globalCtx, s32 switchFlag); + +Gfx* SubS_DrawTransformFlexLimb(struct GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); +Gfx* SubS_DrawTransformFlex(struct GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx); + +s32 SubS_InCsMode(struct GlobalContext* globalCtx); + +s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot); + +void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits); + +void SubS_TimePathing_FillKnots(f32 knots[], s32 order, s32 numPoints); +s32 SubS_TimePathing_ComputeProgress(f32* progress, s32 elapsedTime, s32 waypointTime, s32 totalTime, s32 pathCount, s32 order, f32 knots[]); +void SubS_TimePathing_ComputeWeights(s32 order, f32 progress, s32 waypoint, f32 knots[], f32 weights[]); +void SubS_TimePathing_ComputeTargetPosXZ(f32* x, f32* z, f32 progress, s32 order, s32 waypoint, Vec3s points[], f32 knots[]); +s32 SubS_TimePathing_Update(Path* path, f32* progress, s32* elapsedTime, s32 waypointTime, s32 totalTime, s32* waypoint, f32 knots[], Vec3f* targetPos, s32 timeSpeed); +void SubS_TimePathing_ComputeInitialY(struct GlobalContext* globalCtx, Path* path, s32 waypoint, Vec3f* targetPos); + +Path* SubS_GetAdditionalPath(struct GlobalContext* globalCtx, u8 pathIndex, s32 max); + +Actor* SubS_FindNearestActor(Actor* actor, struct GlobalContext* globalCtx, u8 actorCategory, s16 actorId); + +s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index); + +s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex); + +Path* SubS_GetDayDependentPath(struct GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex); + +s32 SubS_WeightPathing_ComputePoint(Path* path, s32 waypoint, Vec3f* point, f32 progress, s32 direction); +s32 SubS_WeightPathing_Move(Actor* actor, Path* path, s32* waypoint, f32* progress, s32 direction, s32 returnStart); + +s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst); + +s32 func_8013C964(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 itemId, s32 type); + +void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size); +void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], s8 parentBodyParts[]); +void SubS_DrawShadowTex(Actor* actor, struct GameState* gameState, u8* tex); + +s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax); +s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, TurnOptionsSet* options); + +s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); + +Path* SubS_GetPathByIndex(struct GlobalContext* globalCtx, s16 pathIndex, s16 max); +s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst); +s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq); +s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep); +s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); + +s8 SubS_IsObjectLoaded(s8 index, struct GlobalContext* globalCtx); +s8 SubS_GetObjectIndex(s16 id, struct GlobalContext* globalCtx); + +Actor* SubS_FindActor(struct GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); + +s32 SubS_FillLimbRotTables(struct GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs); + +s32 SubS_IsFloorAbove(struct GlobalContext* globalCtx, Vec3f* pos, f32 distAbove); + +s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst); +u8 SubS_GetPathCountFromPathList(Path* paths, s32 pathIndex); + +void SubS_ActorPathing_Init(struct GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags); +s32 SubS_ActorPathing_Update(struct GlobalContext* globalCtx, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc); +void SubS_ActorPathing_ComputePointInfo(struct GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_MoveWithGravity(struct GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_MoveWithoutGravityReverse(struct GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_SetNextPoint(struct GlobalContext* globalCtx, ActorPathing* actorPath); + +void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, s32* curIndex); + +s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type); +s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes); + +void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane); +s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersect); + +Actor* SubS_FindActorCustom(struct GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor); + +s32 func_8013E748(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, func_8013E748_VerifyFunc verifyFunc); +s32 SubS_ActorAndPlayerFaceEachOther(struct GlobalContext* globalCtx, Actor* actor, void* data); +s32 func_8013E8F8(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, s16 actorYawTol); + +s32 SubS_TurnToPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax); + #endif diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 3e5443bc6..d5b4f33b2 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -178,8 +178,7 @@ s32 SubS_InCsMode(GlobalContext* globalCtx) { * @param[in] stepRot boolean, step towards newRot instead of setting directly * @param[in] overrideRot boolean, override newRot with the specified input. * - * Note: - * If overrideRot is true, the rotation will automatically step instead of setting directly + * @note if overrideRot is true, the rotation will automatically step instead of setting directly */ s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot) { Vec3f newPos; @@ -214,17 +213,273 @@ void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits) { *flags = (*flags & ~unsetBits) | setBits; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AF00.s") +/** + * Fills the knot array to be used with time paths + * + * The default knot array just pads with `order` duplicate knots of the first knot at the front and of the last knot + * at the end. + * + * @param[out] knots an array of values that are used to compute the progress and the individual weights + * @param[in] order the order of the interpolation i.e. the number of points in the interpolation + * @param[in] numPoints the number of points to fill, generally the path count + order + * + * @note Same note as SubS_TimePathing_Update() + */ +void SubS_TimePathing_FillKnots(f32 knots[], s32 order, s32 numPoints) { + s32 i; + f32 val = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B010.s") + for (i = 0; i < numPoints; i++) { + if ((i >= order) && (i < (numPoints - order + 1))) { + val += 1.0f; + } + knots[i] = val; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B0C8.s") +typedef enum { + /* 0 */ SUBS_TIME_PATHING_PROGRESS_STATUS_ERROR, + /* 1 */ SUBS_TIME_PATHING_PROGRESS_STATUS_STILL_ON_PATH, + /* 2 */ SUBS_TIME_PATHING_PROGRESS_STATUS_SHOULD_REACH_END +} SUBS_TIME_PATHING_PROGRESS_STATUS; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B350.s") +/** + * Computes the progress to be used with time paths + * + * @param[out] progress the progress along the path, used to compute the weights + * @param[in] elapsedTime how much time has passed + * @param[in] waypointTime how much time per each waypoint + * @param[in] totalTime how much time the path should take to travel + * @param[in] pathCount the path count + * @param[in] order the order of the interpolation i.e. the number of points in the interpolation + * @param[in] knots see SubS_TimePathing_FillKnots() + * + * @return see SUBS_TIME_PATHING_PROGRESS_STATUS + */ +s32 SubS_TimePathing_ComputeProgress(f32* progress, s32 elapsedTime, s32 waypointTime, s32 totalTime, s32 pathCount, + s32 order, f32 knots[]) { + s32 i; + s32 j; + s32 k; + f32 waypointTimeInv; // The fraction of a waypoint a single unit of time contains -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B6B0.s") + *progress = 0.0f; + if ((waypointTime <= 0) || (elapsedTime < 0)) { + return SUBS_TIME_PATHING_PROGRESS_STATUS_ERROR; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B878.s") + // When using the knots from SubS_TimePathing_FillKnots() these nested loops seem to simplify to + // *progress = (f32)elapsedTime / (f32)waypointTime; + waypointTimeInv = 1.0f / waypointTime; + k = 0; + for (i = order - 1; i < pathCount; i++) { + for (j = 0; j < waypointTime; j++) { + if (k == elapsedTime) { + break; + } + *progress += (knots[i + 1] - knots[i]) * waypointTimeInv; + k++; + } + } + + return (elapsedTime == totalTime) ? SUBS_TIME_PATHING_PROGRESS_STATUS_SHOULD_REACH_END + : SUBS_TIME_PATHING_PROGRESS_STATUS_STILL_ON_PATH; +} + +/** + * Computes the interpolation weights to be used with time paths + * + * Seems to use some kind of B-Spline interpolation algorithm + * + * @param[in] order the order of the interpolation i.e. the number of points in the interpolation, max is 10 + * @param[in] progress see SubS_TimePathing_ComputeProgress() + * @param[in] waypoint the current waypoint + * @param[in] knots see SubS_TimePathing_FillKnots() + * @param[out] weights how much to weight each point considered + */ +void SubS_TimePathing_ComputeWeights(s32 order, f32 progress, s32 waypoint, f32 knots[], f32 weights[]) { + f32 weightsTemp[10][11]; + s32 i; + s32 j; + s32 k; + + for (i = 0; i < order; i++) { + for (j = 0; j < order + 1; j++) { + weightsTemp[i][j] = 0.0f; + } + } + + weightsTemp[0][order - 1] = 1.0f; + + for (i = 1; i < order; i++) { + for (j = waypoint - i, k = (order - 1) - i; j <= waypoint; j++, k++) { + if (knots[j + i] != knots[j]) { + weightsTemp[i][k] = ((progress - knots[j]) / (knots[j + i] - knots[j])) * weightsTemp[i - 1][k]; + } else { + weightsTemp[i][k] = 0.0f; + } + + if (knots[j + i + 1] != knots[j + 1]) { + weightsTemp[i][k] += + ((knots[j + i + 1] - progress) / (knots[j + i + 1] - knots[j + 1])) * weightsTemp[i - 1][k + 1]; + } + } + } + for (j = 0; j < order; j++) { + weights[j] = weightsTemp[order - 1][j]; + } +} + +/** + * Computes the X and Z component of the position to move to in time based paths + * + * @param[out] x computed x position + * @param[out] z computed z position + * @param[in] progress see SubS_TimePathing_ComputeProgress() + * @param[in] order the order of the interpolation i.e. the number of points in the interpolation, max is 10 + * @param[in] waypoint the current waypoint + * @param[in] points the path's points + * @param[in] knots see SubS_TimePathing_FillKnots() + */ +void SubS_TimePathing_ComputeTargetPosXZ(f32* x, f32* z, f32 progress, s32 order, s32 waypoint, Vec3s points[], + f32 knots[]) { + f32 xPos; + f32 zPos; + f32 weights[11]; + f32 weightedX; + f32 weightedZ; + f32 weightedTotal; + s32 i; + + SubS_TimePathing_ComputeWeights(order, progress, waypoint, knots, weights); + weightedTotal = 0.0f; + weightedZ = 0.0f; + weightedX = 0.0f; + + for (i = 0; i < order; i++) { + xPos = points[waypoint - order + i + 1].x; + zPos = points[waypoint - order + i + 1].z; + + weightedX += weights[i] * xPos; + weightedZ += weights[i] * zPos; + weightedTotal += weights[i]; + } + *x = weightedX / weightedTotal; + *z = weightedZ / weightedTotal; +} + +/** + * Updates a time based path that an actor follows by: + * - Computing the X and Z components of the next point to move to + * - Updating the waypoint + * - Updating the time + * + * @param[in] path + * @param[out] progress see SubS_TimePathing_ComputeProgress() + * @param[in,out] elapsedTime how much time has passed + * @param[in] waypointTime how much time per each waypoint + * @param[in] totalTime how much time the path should take to travel + * @param[in,out] waypoint the current waypoint, this and the previous two points will be used to compute the targetPos + * @param[in] knots see SubS_TimePathing_FillKnots() + * @param[out] targetPos the computed position to move to + * @param[in] timeSpeed how fast time moves + * + * @return s32 returns true when the end has been reached. + * + * @note This system/function makes a couple of assumptions about the order used: + * 1. the order is assumed to be 3, see SUBS_TIME_PATHING_ORDER + * 2. even if SUBS_TIME_PATHING_ORDER is updated, the order can only be a max of 10 + */ +s32 SubS_TimePathing_Update(Path* path, f32* progress, s32* elapsedTime, s32 waypointTime, s32 totalTime, s32* waypoint, + f32 knots[], Vec3f* targetPos, s32 timeSpeed) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 state; + f32 endX; + f32 endZ; + s32 reachedEnd = false; + + if (*waypoint >= path->count) { + state = SUBS_TIME_PATHING_PROGRESS_STATUS_SHOULD_REACH_END; + } else { + state = SubS_TimePathing_ComputeProgress(progress, *elapsedTime, waypointTime, totalTime, path->count, + SUBS_TIME_PATHING_ORDER, knots); + } + + switch (state) { + case SUBS_TIME_PATHING_PROGRESS_STATUS_STILL_ON_PATH: + reachedEnd = false; + SubS_TimePathing_ComputeTargetPosXZ(&targetPos->x, &targetPos->z, *progress, SUBS_TIME_PATHING_ORDER, + *waypoint, points, knots); + break; + case SUBS_TIME_PATHING_PROGRESS_STATUS_SHOULD_REACH_END: + endX = points[path->count - 1].x; + endZ = points[path->count - 1].z; + targetPos->x = endX * 1; + targetPos->z = endZ * 1; + reachedEnd = true; + break; + } + + *elapsedTime += timeSpeed; + if (*elapsedTime >= totalTime) { + *elapsedTime = totalTime; + } else if (*elapsedTime < 0) { + *elapsedTime = 0; + } + *waypoint = (*elapsedTime / waypointTime) + (SUBS_TIME_PATHING_ORDER - 1); + + return reachedEnd; +} + +/** + * Computes the initial Y component of a time based path + * + * @param[in] globalCtx + * @param[in] path + * @param[in] waypoint the current waypoint, this and the previous two points will be used to compute the target pos + * @param[out] targetPos the computed position to move to, only the Y component has meaning + * + * @note Same note as SubS_TimePathing_Update() + */ +void SubS_TimePathing_ComputeInitialY(GlobalContext* globalCtx, Path* path, s32 waypoint, Vec3f* targetPos) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + Vec3f posA; + Vec3f posB; + Vec3f posResult; + s32 i = waypoint - (SUBS_TIME_PATHING_ORDER - 1); + s16 max; + s16 min; + s32 isSetup; + CollisionPoly* outPoly = NULL; + s32 bgId = 0; + + max = 0; + min = 0; + isSetup = false; + for (; i <= waypoint; i++) { + if (isSetup) { + if (max < points[i].y) { + max = points[i].y; + } + if (points[i].y < min) { + min = points[i].y; + } + } else { + max = min = points[i].y; + } + isSetup = true; + } + max += 30; + min -= 30; + posA = *targetPos; + posB = *targetPos; + posA.y = max; + posB.y = min; + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posResult, &outPoly, true, true, true, true, + &bgId)) { + targetPos->y = posResult.y; + } +} Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max) { Path* path; @@ -362,9 +617,189 @@ Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s return path; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C068.s") +/** + * Computes the point to move toward using a weight based algorithm that considers 4 points along the path + * + * @param path + * @param waypoint the current waypoint, this and the previous three points will be used to compute the point + * @param point the point computed + * @param progress the main weight value used to compute the weights for the points considered + * @param direction the direciton along the path to move, 1 for forwards, anything else for backwards + * + * @note only computes X and Z components of the point + */ +s32 SubS_WeightPathing_ComputePoint(Path* path, s32 waypoint, Vec3f* point, f32 progress, s32 direction) { + s32 i; + f32 weight0; + f32 weight1; + f32 weight2; + f32 weight3; + s32 lastPoint; + s32 secondLastPoint; + s32 secondPoint; + s32 firstPoint; + f32 xPoints[4]; + f32 zPoints[4]; + f32 oneMinusProgress; + f32 squared; + f32 cubed; + Vec3s* points; + s32 count = path->count; + s32 pointIndex; + s32 tmp; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C624.s") + if (path == NULL) { + return false; + } + if (direction == 1) { + if (waypoint <= 2) { + pointIndex = 2; + } else { + pointIndex = (waypoint == 3) ? 3 : waypoint; + } + for (i = 0; i < 4; i++, pointIndex--) { + if (pointIndex <= 0) { + pointIndex = 0; + } + points = Lib_SegmentedToVirtual(path->points); + points = &points[pointIndex]; + xPoints[i] = points->x; + zPoints[i] = points->z; + } + lastPoint = count - 1; + secondLastPoint = count - 2; + secondPoint = 3; + firstPoint = 2; + } else { + if (waypoint >= count - 3) { + pointIndex = count - 3; + } else { + tmp = waypoint + 4; + pointIndex = (count == tmp) ? count - 4 : waypoint; + } + for (i = 0; i < 4; i++, pointIndex++) { + if (pointIndex >= path->count) { + pointIndex = path->count - 1; + } + points = Lib_SegmentedToVirtual(path->points); + points = &points[pointIndex]; + xPoints[i] = points->x; + zPoints[i] = points->z; + } + lastPoint = 0; + secondLastPoint = 1; + secondPoint = count - 4; + firstPoint = count - 3; + } + if (waypoint == lastPoint) { + oneMinusProgress = 1.0f - progress; + squared = progress * progress; + cubed = progress * squared; + weight0 = oneMinusProgress * oneMinusProgress * oneMinusProgress; + weight1 = (1.75f * cubed) - (4.5f * squared) + (3.0f * progress); + weight2 = ((-11.0f / 12.0f) * cubed) + (1.5f * squared); + weight3 = (1.0f / 6.0f) * cubed; + } else if (waypoint == secondLastPoint) { + oneMinusProgress = 1.0f - progress; + squared = progress * progress; + cubed = progress * squared; + weight0 = oneMinusProgress * oneMinusProgress * oneMinusProgress * ((void)0, 0.25f); //! FAKE: + weight1 = ((7.0f / 12.0f) * cubed) - (1.25f * squared) + (0.25f * progress) + (7.0f / 12.0f); + weight2 = (-0.5f * cubed) + (0.5f * squared) + (progress * 0.5f) + (1.0f / 6.0f); + weight3 = cubed * (1.0f / 6.0f); + } else if (waypoint == secondPoint) { + oneMinusProgress = 1.0f - progress; + squared = oneMinusProgress * oneMinusProgress; + cubed = oneMinusProgress * squared; + weight0 = (1.0f / 6.0f) * cubed; + weight1 = (-0.5f * cubed) + (0.5f * squared) + (0.5f * oneMinusProgress) + (1.0f / 6.0f); + weight2 = ((7.0f / 12.0f) * cubed) - (1.25f * squared) + (0.25f * oneMinusProgress) + (7.0f / 12.0f); + weight3 = progress * progress * progress * 0.25f; + } else if (((direction == 1) && (firstPoint >= waypoint)) || ((direction != 1) && (waypoint >= firstPoint))) { + oneMinusProgress = 1.0f - progress; + squared = oneMinusProgress * oneMinusProgress; + cubed = oneMinusProgress * squared; + weight0 = (1.0f / 6.0f) * cubed; + weight1 = ((-11.0f / 12.0f) * cubed) + (1.5f * squared); + weight2 = (1.75f * cubed) - (4.5f * squared) + (3.0f * oneMinusProgress); + weight3 = progress * progress * progress; + } else { + oneMinusProgress = 1.0f - progress; + squared = progress * progress; + cubed = squared * progress; + weight0 = oneMinusProgress * oneMinusProgress; + weight0 = oneMinusProgress * weight0 / 6.0f; + weight1 = (cubed * 0.5f) - squared + (2.0f / 3.0f); + weight2 = (cubed / -2.0f) + (squared * 0.5f) + (progress * 0.5f) + (1.0f / 6.0f); + weight3 = cubed / 6.0f; + } + point->x = (weight0 * xPoints[0]) + (weight1 * xPoints[1]) + (weight2 * xPoints[2]) + (weight3 * xPoints[3]); + point->z = (weight0 * zPoints[0]) + (weight1 * zPoints[1]) + (weight2 * zPoints[2]) + (weight3 * zPoints[3]); + + return true; +} + +// WeightPathing System is completely unused +/** + * Moves an actor based on a weight based algorithm that takes into account 4 points along the path + * + * @param actor + * @param path + * @param waypoint the current waypoint, this and the previous three points will be used to move forward + * @param progress the progress towards a given waypoint, used to compute the weights + * @param direction the direction along the path to move, 1 for forwards, anything else for backwards + * @param returnStart boolean, true if the actor should wrap back to start when reaching the end + * + * @return s32 true if actor reached the end of the path in this iteration, false otherwise + */ +s32 SubS_WeightPathing_Move(Actor* actor, Path* path, s32* waypoint, f32* progress, s32 direction, s32 returnStart) { + Vec3f worldPos = actor->world.pos; + Vec3f velocity = actor->velocity; + Vec3f point; + f32 dist; + + if (((direction != 1) && (*waypoint >= (path->count - 2))) || ((direction == 1) && (*waypoint < 2))) { + return false; + } + while (true) { + if (!SubS_WeightPathing_ComputePoint(path, *waypoint, &point, *progress, direction) || + ((s32)(actor->speedXZ * 10000.0f) == 0)) { + return false; + } + dist = Math_Vec3f_DistXZ(&actor->world.pos, &point); + actor->world.rot.y = Math_Vec3f_Yaw(&actor->world.pos, &point); + Actor_MoveWithGravity(actor); + if (Math_Vec3f_DistXZ(&actor->world.pos, &point) < dist) { + break; + } + *progress += 0.1f; + if (*progress >= 1.1f) { + if (direction != 1) { + (*waypoint)++; + if (*waypoint >= (path->count - 2)) { + if (returnStart) { + *waypoint = 0; + } else { + return true; + } + } + } else { + (*waypoint)--; + if (*waypoint < 2) { + if (returnStart) { + *waypoint = path->count - 2; + } else { + return true; + } + } + } + *progress = 0.0f; + } + actor->world.pos = worldPos; + actor->velocity = velocity; + } + return false; +} s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst) { Vec3s* point; @@ -557,10 +992,10 @@ void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex) { Matrix_Translate(actor->world.pos.x, 0.0f, actor->world.pos.z, MTXMODE_NEW); Matrix_Scale(0.6f, 1.0f, 0.6f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gShadowDL); + gSPDisplayList(POLY_OPA_DISP++, gShadowMaterialDL); gDPLoadTextureBlock(POLY_OPA_DISP++, tex, G_IM_FMT_I, G_IM_SIZ_8b, SUBS_SHADOW_TEX_WIDTH, SUBS_SHADOW_TEX_HEIGHT, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); - gSPDisplayList(POLY_OPA_DISP++, gShadowVtxDL); + gSPDisplayList(POLY_OPA_DISP++, gShadowModelDL); CLOSE_DISPS(gfxCtx); } @@ -617,9 +1052,7 @@ s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f * @param[in,out] turnTarget the intermediate target step that headRot and torsoRot step towards * @param[in,out] headRot the computed head rotation * @param[in,out] torsoRot the computed torso rotation - * @param[in] options various options to adjust how the actor turns, see `SubS_ComputeTurnToPointRot and - * TurnOptions/TurnOptionsSet` - * + * @param[in] options various options to adjust how the actor turns, see SubS_ComputeTurnToPointRot() */ s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, TurnOptionsSet* options) { @@ -781,8 +1214,8 @@ s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f return false; } -u8 SubS_GetPathCount(Path* paths, s32 index) { - Path* path = &paths[index]; +u8 SubS_GetPathCountFromPathList(Path* paths, s32 pathIndex) { + Path* path = &paths[pathIndex]; return path->count; } @@ -1004,8 +1437,7 @@ s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes) { * @param[in] rot the angles to rotate with, uses just the x and y components * @param[out] plane the computed plane * - * Notes: - * The unit input vector is expected to already be normalized (only uses are with the z unit vector) + * @note the unit input vector is expected to already be normalized (only uses are with the z unit vector) * */ void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane) { diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index 11936a9d2..1cda3dc8c 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -73,45 +73,47 @@ void func_80953B40(BgIngate* this) { s32 temp; if (!(gSaveContext.eventInf[3] & 0x20)) { - this->unk180 = 0xFA0; - this->unk168 = 4; + this->timePathTotalTime = 4 * 1000; + this->timePathTimeSpeed = 4; } else { - this->unk180 = 0x7D0; - this->unk168 = 1; + this->timePathTotalTime = 1 * 2000; + this->timePathTimeSpeed = 1; } - temp = this->unk164->count - 2; - this->unk184 = this->unk180 / temp; - this->unk188 = 2; - this->unk18C = 0; + temp = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / temp; + this->timePathWaypoint = SUBS_TIME_PATHING_ORDER - 1; + this->timePathElapsedTime = 0; this->unk160 &= ~0x1; this->unk160 &= ~0x2; } s32 func_80953BEC(BgIngate* this) { - f32 sp74[265]; + f32 knots[265]; Vec3f sp68; Vec3f sp5C; - Vec3f unkVec; + Vec3f timePathTargetPos; s16 yaw; - func_8013AF00(sp74, 3, this->unk164->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk160 & 1)) { - unkVec = gZeroVec3f; - func_8013B6B0(this->unk164, &this->unk17C, &this->unk18C, this->unk184, this->unk180, &this->unk188, sp74, - &unkVec, this->unk168); + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); this->unk160 |= 1; } else { - unkVec = this->unk170; + timePathTargetPos = this->timePathTargetPos; } - this->dyna.actor.world.pos.x = unkVec.x; - this->dyna.actor.world.pos.z = unkVec.z; - this->unk170 = gZeroVec3f; - if (func_8013B6B0(this->unk164, &this->unk17C, &this->unk18C, this->unk184, this->unk180, &this->unk188, sp74, - &this->unk170, this->unk168) != 0) { + this->dyna.actor.world.pos.x = timePathTargetPos.x; + this->dyna.actor.world.pos.z = timePathTargetPos.z; + this->timePathTargetPos = gZeroVec3f; + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk160 |= 2; } else { sp68 = this->dyna.actor.world.pos; - sp5C = this->unk170; + sp5C = this->timePathTargetPos; yaw = Math_Vec3f_Yaw(&sp68, &sp5C); this->dyna.actor.world.rot.y = yaw; this->dyna.actor.shape.rot.y = yaw; @@ -164,7 +166,7 @@ void func_80953F14(BgIngate* this, GlobalContext* globalCtx) { player->actor.focus.rot.y = player->actor.shape.rot.y; this->unk160 |= 0x10; func_80953DA8(this, globalCtx); - if (this->unk164 != NULL) { + if (this->timePath != NULL) { func_80953B40(this); } this->unk16E = -1; @@ -188,7 +190,7 @@ void func_80953F9C(BgIngate* this, GlobalContext* globalCtx) { if (this->unk160 & 2) { - if (this->unk164->unk1 != 0xFF) { + if (this->timePath->unk1 != 0xFF) { func_80953E38(globalCtx); func_800B7298(globalCtx, &this->dyna.actor, 7); this->dyna.actor.textId = 0x9E4; @@ -205,7 +207,7 @@ void func_80953F9C(BgIngate* this, GlobalContext* globalCtx) { } this->actionFunc = func_809542A0; } - } else if ((ActorCutscene_GetCurrentIndex() == -1) && (this->unk164 != NULL)) { + } else if ((ActorCutscene_GetCurrentIndex() == -1) && (this->timePath != NULL)) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CRUISER - SFX_FLAG); func_80953BEC(this); } @@ -259,9 +261,9 @@ void func_809542A0(BgIngate* this, GlobalContext* globalCtx) { void func_80954340(BgIngate* this, GlobalContext* globalCtx) { if (!DECR(this->unk16A)) { - if (this->unk164 != NULL) { + if (this->timePath != NULL) { func_800B7298(globalCtx, &this->dyna.actor, 6); - this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; + this->timePath = &globalCtx->setupPathList[this->timePath->unk1]; func_80953F14(this, globalCtx); func_800FE484(); } @@ -285,8 +287,8 @@ void func_809543D4(BgIngate* this, GlobalContext* globalCtx) { func_800FE498(); func_8019F208(); } else { - if (this->unk164 != NULL) { - this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; + if (this->timePath != NULL) { + this->timePath = &globalCtx->setupPathList[this->timePath->unk1]; } func_80953F14(this, globalCtx); gSaveContext.save.weekEventReg[90] &= (u8)~0x40; @@ -327,7 +329,7 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk160 |= 0x8; this->unk160 |= 0x10; Actor_SetScale(&this->dyna.actor, 1.0f); - this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + this->timePath = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); this->dyna.actor.room = -1; if (gSaveContext.save.weekEventReg[20] & 2) { gSaveContext.save.weekEventReg[90] &= (u8)~0x40; @@ -349,9 +351,9 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actionFunc = func_80953F8C; } } - this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); - if (this->unk164 != NULL) { - sp38 = Lib_SegmentedToVirtual(this->unk164->points); + this->timePath = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); + if (this->timePath != NULL) { + sp38 = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp2C, &sp38[0]); Math_Vec3s_ToVec3f(&sp20, &sp38[1]); this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&sp2C, &sp20); @@ -360,7 +362,7 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->dyna.actor.world.pos.y = -15.0f; this->dyna.actor.world.pos.z = sp2C.z; } - this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + this->timePath = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); } else { Actor_MarkForDeath(&this->dyna.actor); } diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h index 08d062e6c..81b7bec9b 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h @@ -13,17 +13,17 @@ typedef struct BgIngate { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ BgIngateActionFunc actionFunc; /* 0x160 */ u16 unk160; - /* 0x164 */ Path* unk164; - /* 0x168 */ s16 unk168; + /* 0x164 */ Path* timePath; + /* 0x168 */ s16 timePathTimeSpeed; /* 0x16A */ s16 unk16A; /* 0x16C */ s16 unk16C; /* 0x16E */ s16 unk16E; - /* 0x170 */ Vec3f unk170; - /* 0x17C */ f32 unk17C; - /* 0x180 */ s32 unk180; - /* 0x184 */ s32 unk184; - /* 0x188 */ s32 unk188; - /* 0x18C */ s32 unk18C; + /* 0x170 */ Vec3f timePathTargetPos; + /* 0x17C */ f32 timePathProgress; + /* 0x180 */ s32 timePathTotalTime; + /* 0x184 */ s32 timePathWaypointTime; + /* 0x188 */ s32 timePathWaypoint; + /* 0x18C */ s32 timePathElapsedTime; } BgIngate; // size = 0x190 extern const ActorInit Bg_Ingate_InitVars; diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index e6dd15a32..c10741fdf 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -319,35 +319,35 @@ void func_80BA8DF4(EnBaba* this, GlobalContext* globalCtx) { } s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, ScheduleResult* arg2) { - u16 sp26 = (u16)(gSaveContext.save.time - 0x3FFC); + u16 sp26 = SCHEDULE_TIME_NOW; u16 temp; u8 sp23 = ENBABA_GET_3F00(&this->actor); if (D_80BAA4A8[arg2->result] >= 0) { - this->unk_410 = SubS_GetAdditionalPath(globalCtx, sp23, D_80BAA4A8[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp23, D_80BAA4A8[arg2->result]); } - if (this->unk_410 == NULL) { + if (this->timePath == NULL) { return false; } - if ((this->unk_434 != 0) && (this->unk_436 >= 0)) { + if ((this->unk_434 != 0) && (this->timePathTimeSpeed >= 0)) { temp = sp26; } else { temp = arg2->time0; } if (arg2->time1 < temp) { - this->unk_424 = (temp - arg2->time1) + 0xFFFF; + this->timePathTotalTime = (temp - arg2->time1) + 0xFFFF; } else { - this->unk_424 = arg2->time1 - temp; + this->timePathTotalTime = arg2->time1 - temp; } - this->unk_430 = sp26 - temp; - temp = this->unk_410->count - 2; - this->unk_428 = this->unk_424 / temp; + this->timePathElapsedTime = sp26 - temp; + temp = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / temp; this->unk_438 = 0; - this->unk_42C = (this->unk_430 / this->unk_428) + 2; + this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_43C = 0; return true; } @@ -372,52 +372,54 @@ s32 func_80BA9110(EnBaba* this, GlobalContext* globalCtx, ScheduleResult* arg2) } s32 func_80BA9160(EnBaba* this, GlobalContext* globalCtx) { - f32 sp7C[265]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54 = 0; s32 sp50 = 0; s32 pad; - func_8013AF00(sp7C, 3, this->unk_410->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (this->unk_438 == 0) { - sp58 = gZeroVec3f; + timePathTargetPos = gZeroVec3f; - func_8013B6B0(this->unk_410, &this->unk_420, &this->unk_430, this->unk_428, this->unk_424, &this->unk_42C, sp7C, - &sp58, this->unk_436); - func_8013B878(globalCtx, this->unk_410, this->unk_42C, &sp58); - this->actor.world.pos.y = sp58.y; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk_438 = 1; } else { - sp58 = this->unk_414; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (SubS_InCsMode(globalCtx)) { - sp54 = this->unk_430; - sp50 = this->unk_42C; - sp58 = this->actor.world.pos; + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_414 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_410, &this->unk_420, &this->unk_430, this->unk_428, this->unk_424, &this->unk_42C, sp7C, - &this->unk_414, this->unk_436)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_43C = 1; } else { sp70 = this->actor.world.pos; - sp64 = this->unk_414; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } if (SubS_InCsMode(globalCtx)) { - this->unk_430 = sp54; - this->unk_42C = sp50; - this->unk_414 = sp58; + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } return false; @@ -598,7 +600,7 @@ void func_80BA9B24(EnBaba* this, GlobalContext* globalCtx) { void func_80BA9B80(EnBaba* this, GlobalContext* globalCtx) { ScheduleResult sp20; - this->unk_436 = REG(15) + ((void)0, gSaveContext.save.daySpeed); + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (!Schedule_RunScript(globalCtx, D_80BAA488, &sp20) || ((this->unk_434 != sp20.result) && !func_80BA9110(this, globalCtx, &sp20))) { diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.h b/src/overlays/actors/ovl_En_Baba/z_en_baba.h index 6a21168b6..51a986bf0 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.h +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.h @@ -43,15 +43,15 @@ typedef struct EnBaba { /* 0x0406 */ UNK_TYPE1 unk406[4]; /* 0x040A */ u16 unk_40A; /* 0x040C */ s32 unk_40C; - /* 0x0410 */ Path* unk_410; - /* 0x0414 */ Vec3f unk_414; - /* 0x0420 */ f32 unk_420; - /* 0x0424 */ s32 unk_424; - /* 0x0428 */ s32 unk_428; - /* 0x042C */ s32 unk_42C; - /* 0x0430 */ s32 unk_430; + /* 0x0410 */ Path* timePath; + /* 0x0414 */ Vec3f timePathTargetPos; + /* 0x0420 */ f32 timePathProgress; + /* 0x0424 */ s32 timePathTotalTime; + /* 0x0428 */ s32 timePathWaypointTime; + /* 0x042C */ s32 timePathWaypoint; + /* 0x0430 */ s32 timePathElapsedTime; /* 0x0434 */ u8 unk_434; - /* 0x0436 */ s16 unk_436; + /* 0x0436 */ s16 timePathTimeSpeed; /* 0x0438 */ s32 unk_438; /* 0x043C */ s32 unk_43C; } EnBaba; // size = 0x440 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 07699e7de..8e43a095a 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -979,18 +979,18 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; actor = func_8094DEE0(this, globalCtx, arg3, arg4); if (D_80951A0C[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); } if ((actor != NULL) && (actor->update != NULL)) { - if (this->unk_234 != NULL) { - sp48 = Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); + if (this->timePath != NULL) { + sp48 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->timePath->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->timePath->count - 1]); this->actor.shape.shadowDraw = NULL; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); Math_Vec3f_Copy(&this->actor.world.pos, &sp30); @@ -1010,16 +1010,16 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; door = func_8094DF90(globalCtx, arg2->result); if (D_80951A0C[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80951A0C[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp55, D_80951A0C[arg2->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { - if (this->unk_234 != NULL) { - sp4C = Lib_SegmentedToVirtual(this->unk_234->points); + if (this->timePath != NULL) { + sp4C = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); Math_Vec3s_ToVec3f(&sp34, &sp4C[1]); Math_Vec3f_Copy(&this->unk_278, &sp40); @@ -1053,32 +1053,33 @@ s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; if (D_80951A0C[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80951A0C[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp2B, D_80951A0C[arg2->result]); } - if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { - this->unk_234 = NULL; + if ((this->timePath != NULL) && (this->timePath->count < 3)) { + this->timePath = NULL; } - if (this->unk_234 != NULL) { - if ((this->unk_258 < 9) && (this->unk_258 != 0) && (this->unk_3C4 >= 0)) { + if (this->timePath != NULL) { + if ((this->unk_258 < 9) && (this->unk_258 != 0) && (this->timePathTimeSpeed >= 0)) { phi_v1 = sp2E; } else { phi_v1 = arg2->time0; } if (arg2->time1 < phi_v1) { - this->unk_248 = (phi_v1 - arg2->time1) + 0xFFFF; + this->timePathTotalTime = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_248 = arg2->time1 - phi_v1; + this->timePathTotalTime = arg2->time1 - phi_v1; } - this->unk_254 = sp2E - phi_v1; - phi_v1 = this->unk_234->count - 2; - this->unk_24C = this->unk_248 / phi_v1; - this->unk_250 = (this->unk_254 / this->unk_24C) + 2; + this->timePathElapsedTime = sp2E - phi_v1; + phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / phi_v1; + this->timePathWaypoint = + (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_3A4 &= ~0x8; this->unk_3A4 &= ~0x10; SubS_UpdateFlags(&this->unk_3A4, 3, 7); @@ -1154,16 +1155,16 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; if (D_80951A0C[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); } - if (this->unk_234 != NULL) { - sp48 = Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); + if (this->timePath != NULL) { + sp48 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->timePath->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->timePath->count - 1]); this->actor.shape.shadowDraw = NULL; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); if (this->unk_258 == 0) { @@ -1444,7 +1445,7 @@ s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { f32 temp_f0; door = func_8094DF90(globalCtx, this->unk_258); - if (!SubS_InCsMode(globalCtx) && (this->unk_3C4 != 0)) { + if (!SubS_InCsMode(globalCtx) && (this->timePathTimeSpeed != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if ((this->unk_3BA / (f32)this->unk_3B8) <= 0.9f) { door->unk_1A7 = this->unk_261; @@ -1459,7 +1460,7 @@ s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { sp38.y = 0.0f; sp38.z = this->unk_3BA * temp_f0; Lib_Vec3f_TranslateAndRotateY(&this->unk_278, this->actor.world.rot.y, &sp38, &this->actor.world.pos); - this->unk_3BA += this->unk_3C4; + this->unk_3BA += this->timePathTimeSpeed; if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } @@ -1469,51 +1470,53 @@ s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { } s32 func_8095097C(EnGm* this, GlobalContext* globalCtx) { - f32 sp7C[0x109]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54 = 0; s32 sp50 = 0; s32 pad2; - func_8013AF00(sp7C, 3, this->unk_234->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk_3A4 & 8)) { - sp58 = gZeroVec3f; - func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, - &sp58, this->unk_3C4); - func_8013B878(globalCtx, this->unk_234, this->unk_250, &sp58); - this->actor.world.pos.y = sp58.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk_3A4 |= 8; } else { - sp58 = this->unk_238; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (SubS_InCsMode(globalCtx)) { - sp54 = this->unk_254; - sp50 = this->unk_250; - sp58 = this->actor.world.pos; + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_238 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, - &this->unk_238, this->unk_3C4)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_3A4 |= 0x10; } else { sp70 = this->actor.world.pos; - sp64 = this->unk_238; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } if (SubS_InCsMode(globalCtx)) { - this->unk_254 = sp54; - this->unk_250 = sp50; - this->unk_238 = sp58; + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } else if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } @@ -1576,7 +1579,7 @@ void func_80950C24(EnGm* this, GlobalContext* globalCtx) { void func_80950CDC(EnGm* this, GlobalContext* globalCtx) { ScheduleResult sp20; - this->unk_3C4 = REG(15) + ((void)0, gSaveContext.save.daySpeed); + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (!Schedule_RunScript(globalCtx, D_80951820, &sp20) || ((this->unk_258 != sp20.result) && !func_80950280(this, globalCtx, &sp20))) { 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 63b6b8f57..1dd161757 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.h +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.h @@ -18,13 +18,13 @@ typedef struct EnGm { /* 0x018C */ EnGmUnkFunc2 unk_18C; /* 0x0190 */ ColliderCylinder colliderCylinder; /* 0x01DC */ ColliderSphere colliderSphere; - /* 0x0234 */ Path* unk_234; - /* 0x0238 */ Vec3f unk_238; - /* 0x0244 */ f32 unk_244; - /* 0x0248 */ s32 unk_248; - /* 0x024C */ s32 unk_24C; - /* 0x0250 */ s32 unk_250; - /* 0x0254 */ s32 unk_254; + /* 0x0234 */ Path* timePath; + /* 0x0238 */ Vec3f timePathTargetPos; + /* 0x0244 */ f32 timePathProgress; + /* 0x0248 */ s32 timePathTotalTime; + /* 0x024C */ s32 timePathWaypointTime; + /* 0x0250 */ s32 timePathWaypoint; + /* 0x0254 */ s32 timePathElapsedTime; /* 0x0258 */ u8 unk_258; /* 0x0259 */ u8 unk_259; /* 0x025C */ s32 unk_25C; @@ -54,7 +54,7 @@ typedef struct EnGm { /* 0x03BE */ s16 unk_3BE; /* 0x03C0 */ s16 unk_3C0; /* 0x03C2 */ s16 unk_3C2; - /* 0x03C4 */ s16 unk_3C4; + /* 0x03C4 */ s16 timePathTimeSpeed; /* 0x03C6 */ s16 unk_3C6; /* 0x03C8 */ s16 unk_3C8; /* 0x03CA */ s16 unk_3CA; 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 e687b770d..f15f15d59 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -506,17 +506,17 @@ s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2, s3 s32 sp24 = false; sp2C = func_80BF1150(this, globalCtx, arg3, arg4); - this->unk_274 = NULL; + this->timePath = NULL; if (D_80BF3318[arg2->result] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { - if (this->unk_274 != NULL) { - sp48 = Lib_SegmentedToVirtual(this->unk_274->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_274->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_274->count - 1]); + if (this->timePath != NULL) { + sp48 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->timePath->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->timePath->count - 1]); this->actor.shape.shadowDraw = NULL; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); Math_Vec3f_Copy(&this->actor.world.pos, &sp30); @@ -549,16 +549,16 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_274 = NULL; + this->timePath = NULL; door = func_80BF1200(globalCtx, arg2->result); if (D_80BF3318[arg2->result] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp55, D_80BF3318[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp55, D_80BF3318[arg2->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { - if (this->unk_274 != NULL) { - sp4C = Lib_SegmentedToVirtual(this->unk_274->points); + if (this->timePath != NULL) { + sp4C = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); Math_Vec3s_ToVec3f(&sp34, &sp4C[1]); Math_Vec3f_Copy(&this->unk_2B0, &sp40); @@ -588,39 +588,39 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = ENIG_GET_FF(&this->actor); - s32 temp_t8; + s32 pad; s32 ret = false; - this->unk_274 = NULL; + this->timePath = NULL; if (D_80BF3318[arg2->result] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80BF3318[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp2B, D_80BF3318[arg2->result]); } - if ((this->unk_274 != NULL) && (this->unk_274->count < 3)) { - this->unk_274 = NULL; + if ((this->timePath != NULL) && (this->timePath->count < 3)) { + this->timePath = NULL; } - if (this->unk_274 != NULL) { - temp_t8 = this->scheduleResult; - if ((temp_t8 < 10) && (temp_t8 != 0) && (this->unk_3EC >= 0)) { + if (this->timePath != NULL) { + if ((this->scheduleResult < 10) && (this->scheduleResult != 0) && (this->timePathTimeSpeed >= 0)) { phi_v1 = sp2E; } else { phi_v1 = arg2->time0; } if (arg2->time1 < phi_v1) { - this->unk_288 = (phi_v1 - arg2->time1) + 0xFFFF; + this->timePathTotalTime = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_288 = arg2->time1 - phi_v1; + this->timePathTotalTime = arg2->time1 - phi_v1; } - this->unk_294 = sp2E - phi_v1; + this->timePathElapsedTime = sp2E - phi_v1; - phi_v1 = (this->unk_274->count - 2) & 0xFFFF; + phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); - this->unk_28C = this->unk_288 / phi_v1; - this->unk_290 = (this->unk_294 / this->unk_28C) + 2; + this->timePathWaypointTime = this->timePathTotalTime / phi_v1; + this->timePathWaypoint = + (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_3D0 &= ~0x8; this->unk_3D0 &= ~0x10; @@ -641,16 +641,16 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_274 = NULL; + this->timePath = NULL; if (D_80BF3318[arg2->result] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); } - if ((this->unk_274 != 0) && (this->unk_274->count >= 2)) { - sp30 = Lib_SegmentedToVirtual(this->unk_274->points); - Math_Vec3s_ToVec3f(&sp40, &sp30[this->unk_274->count - 1]); - Math_Vec3s_ToVec3f(&sp34, &sp30[this->unk_274->count - 2]); + if ((this->timePath != 0) && (this->timePath->count >= 2)) { + sp30 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp40, &sp30[this->timePath->count - 1]); + Math_Vec3s_ToVec3f(&sp34, &sp30[this->timePath->count - 2]); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp34, &sp40); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); @@ -733,7 +733,7 @@ s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { f32 temp; s32 pad; - if (!SubS_InCsMode(globalCtx) && (this->unk_3EC != 0)) { + if (!SubS_InCsMode(globalCtx) && (this->timePathTimeSpeed != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_3E2 / this->unk_3E0) <= 0.9f) { door->unk_1A7 = this->unk_2A4; @@ -747,7 +747,7 @@ s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { sp38.y = 0.0f; sp38.z = this->unk_3E2 * temp; Lib_Vec3f_TranslateAndRotateY(&this->unk_2B0, this->actor.world.rot.y, &sp38, &this->actor.world.pos); - this->unk_3E2 += this->unk_3EC; + this->unk_3E2 += this->timePathTimeSpeed; if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } @@ -756,50 +756,52 @@ s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { } s32 func_80BF25E8(EnIg* this, GlobalContext* globalCtx) { - f32 sp7C[265]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54 = 0; s32 sp50 = 0; s32 pad; - func_8013AF00(sp7C, 3, this->unk_274->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk_3D0 & 8)) { - sp58 = gZeroVec3f; - func_8013B6B0(this->unk_274, &this->unk_284, &this->unk_294, this->unk_28C, this->unk_288, &this->unk_290, sp7C, - &sp58, this->unk_3EC); - func_8013B878(globalCtx, this->unk_274, this->unk_290, &sp58); - this->actor.world.pos.y = sp58.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk_3D0 |= 8; } else { - sp58 = this->unk_278; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (SubS_InCsMode(globalCtx)) { - sp54 = this->unk_294; - sp50 = this->unk_290; - sp58 = this->actor.world.pos; + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_278 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_274, &this->unk_284, &this->unk_294, this->unk_28C, this->unk_288, &this->unk_290, sp7C, - &this->unk_278, this->unk_3EC)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_3D0 |= 0x10; } else { sp70 = this->actor.world.pos; - sp64 = this->unk_278; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } if (SubS_InCsMode(globalCtx)) { - this->unk_294 = sp54; - this->unk_290 = sp50; - this->unk_278 = sp58; + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } else if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } @@ -873,7 +875,7 @@ void func_80BF2A50(EnIg* this, GlobalContext* globalCtx) { void func_80BF2AF8(EnIg* this, GlobalContext* globalCtx) { ScheduleResult sp20; - this->unk_3EC = REG(15) + ((void)0, gSaveContext.save.daySpeed); + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (!Schedule_RunScript(globalCtx, D_80BF3260, &sp20) || ((this->scheduleResult != sp20.result) && !func_80BF2368(this, globalCtx, &sp20))) { 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 21abb08ac..9acf34ae9 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.h +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.h @@ -19,13 +19,13 @@ typedef struct EnIg { /* 0x0190 */ MtxF unk_190; /* 0x01D0 */ ColliderCylinder collider1; /* 0x021C */ ColliderSphere collider2; - /* 0x0274 */ Path* unk_274; - /* 0x0278 */ Vec3f unk_278; - /* 0x0284 */ f32 unk_284; - /* 0x0288 */ s32 unk_288; - /* 0x028C */ s32 unk_28C; - /* 0x0290 */ s32 unk_290; - /* 0x0294 */ s32 unk_294; + /* 0x0274 */ Path* timePath; + /* 0x0278 */ Vec3f timePathTargetPos; + /* 0x0284 */ f32 timePathProgress; + /* 0x0288 */ s32 timePathTotalTime; + /* 0x028C */ s32 timePathWaypointTime; + /* 0x0290 */ s32 timePathWaypoint; + /* 0x0294 */ s32 timePathElapsedTime; /* 0x0298 */ u8 scheduleResult; /* 0x029C */ s32* unk_29C; /* 0x02A0 */ s32 unk_2A0; @@ -50,7 +50,7 @@ typedef struct EnIg { /* 0x03E6 */ s16 unk_3E6; /* 0x03E8 */ s16 unk_3E8; /* 0x03EA */ s16 unk_3EA; - /* 0x03EC */ s16 unk_3EC; + /* 0x03EC */ s16 timePathTimeSpeed; /* 0x03EE */ s16 unk_3EE; /* 0x03F0 */ s16 unk_3F0; /* 0x03F2 */ s16 unk_3F2; diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index bc41461d9..43fb03da4 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -1207,17 +1207,17 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; sp2C = func_80AF7CB0(this, globalCtx, actorCat, actorId); if (D_80AFB430[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { - if (this->unk_234 != NULL) { - sp48 = Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); + if (this->timePath != NULL) { + sp48 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->timePath->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->timePath->count - 1]); this->actor.shape.shadowDraw = NULL; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); Math_Vec3f_Copy(&this->actor.world.pos, &sp30); @@ -1238,15 +1238,15 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s16 temp; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; door = func_80AF7D60(globalCtx, arg2->result); if (D_80AFB430[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80AFB430[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp55, D_80AFB430[arg2->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { - if (this->unk_234 != 0) { - sp4C = Lib_SegmentedToVirtual(this->unk_234->points); + if (this->timePath != 0) { + sp4C = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); Math_Vec3s_ToVec3f(&sp34, &sp4C[1]); Math_Vec3f_Copy(&this->unk_26C, &sp40); @@ -1283,33 +1283,34 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; if (D_80AFB430[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80AFB430[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp2B, D_80AFB430[arg2->result]); } - if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { - this->unk_234 = NULL; + if ((this->timePath != NULL) && (this->timePath->count < 3)) { + this->timePath = NULL; } - if (this->unk_234 != 0) { - if ((this->unk_258 < 38) && (this->unk_258 != 0) && (this->unk_374 >= 0)) { + if (this->timePath != 0) { + if ((this->unk_258 < 38) && (this->unk_258 != 0) && (this->timePathTimeSpeed >= 0)) { phi_v1 = sp2E; } else { phi_v1 = arg2->time0; } if (arg2->time1 < phi_v1) { - this->unk_248 = (phi_v1 - arg2->time1) + 0xFFFF; + this->timePathTotalTime = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_248 = arg2->time1 - phi_v1; + this->timePathTotalTime = arg2->time1 - phi_v1; } - this->unk_254 = sp2E - phi_v1; - phi_v1 = this->unk_234->count - 2; - this->unk_24C = this->unk_248 / phi_v1; - this->unk_250 = (this->unk_254 / this->unk_24C) + 2; + this->timePathElapsedTime = sp2E - phi_v1; + phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / phi_v1; + this->timePathWaypoint = + (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_356 &= ~8; this->unk_356 &= ~0x10; if (this->unk_258 == 27) { @@ -1364,13 +1365,13 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; if (D_80AFB430[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); } - if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { - sp30 = Lib_SegmentedToVirtual(this->unk_234->points); + if ((this->timePath != 0) && (this->timePath->count >= 2)) { + sp30 = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp30[0]); Math_Vec3s_ToVec3f(&sp34, &sp30[1]); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); @@ -1416,16 +1417,16 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } - this->unk_234 = NULL; + this->timePath = NULL; phi_a3 = D_80AFB430[arg2->result]; if (phi_a3 >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, phi_a3); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, phi_a3); } - if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { - sp30 = Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp40, &sp30[this->unk_234->count - 1]); - Math_Vec3s_ToVec3f(&sp34, &sp30[this->unk_234->count - 2]); + if ((this->timePath != 0) && (this->timePath->count >= 2)) { + sp30 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp40, &sp30[this->timePath->count - 1]); + Math_Vec3s_ToVec3f(&sp34, &sp30[this->timePath->count - 2]); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp34, &sp40); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); @@ -1703,7 +1704,7 @@ s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { Vec3f* sp28; f32 temp; - if (!SubS_InCsMode(globalCtx) && (this->unk_374 != 0)) { + if (!SubS_InCsMode(globalCtx) && (this->timePathTimeSpeed != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_36E / this->unk_36C) <= 0.9f) { door->unk_1A7 = this->unk_260; @@ -1717,7 +1718,7 @@ s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { sp38.y = 0.0f; sp38.z = this->unk_36E * temp; Lib_Vec3f_TranslateAndRotateY(&this->unk_26C, this->actor.world.rot.y, &sp38, &this->actor.world.pos); - this->unk_36E += this->unk_374; + this->unk_36E += this->timePathTimeSpeed; if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK); } @@ -1726,52 +1727,54 @@ s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { } s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { - f32 sp7C[265]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54; s32 sp50; sp50 = 0; sp54 = 0; - func_8013AF00(sp7C, 3, this->unk_234->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk_356 & 8)) { - sp58 = gZeroVec3f; - func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, - &sp58, this->unk_374); - func_8013B878(globalCtx, this->unk_234, this->unk_250, &sp58); - this->actor.world.pos.y = sp58.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk_356 |= 8; } else { - sp58 = this->unk_238; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (SubS_InCsMode(globalCtx)) { - sp54 = this->unk_254; - sp50 = this->unk_250; - sp58 = this->actor.world.pos; + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_238 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, - &this->unk_238, this->unk_374)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_356 |= 0x10; } else { sp70 = this->actor.world.pos; - sp64 = this->unk_238; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } if (SubS_InCsMode(globalCtx)) { - this->unk_254 = sp54; - this->unk_250 = sp50; - this->unk_238 = sp58; + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } else if ((this->unk_258 != 91) && (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK); @@ -1989,7 +1992,7 @@ void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { u16 sp3C = 0; ScheduleResult sp2C; - this->unk_374 = REG(15) + ((void)0, gSaveContext.save.daySpeed); + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (this->unk_38C != 0) { time = gSaveContext.save.time - D_801F4E78; sp3C = gSaveContext.save.time; diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.h b/src/overlays/actors/ovl_En_Pm/z_en_pm.h index 6d545373b..7a8c2be77 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.h +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.h @@ -16,13 +16,13 @@ typedef struct EnPm { /* 0x018C */ EnPmFunc2 unk_18C; /* 0x0190 */ ColliderCylinder colliderCylinder; /* 0x01DC */ ColliderSphere colliderSphere; - /* 0x0234 */ Path* unk_234; - /* 0x0238 */ Vec3f unk_238; - /* 0x0244 */ f32 unk_244; - /* 0x0248 */ s32 unk_248; - /* 0x024C */ s32 unk_24C; - /* 0x0250 */ s32 unk_250; - /* 0x0254 */ s32 unk_254; + /* 0x0234 */ Path* timePath; + /* 0x0238 */ Vec3f timePathTargetPos; + /* 0x0244 */ f32 timePathProgress; + /* 0x0248 */ s32 timePathTotalTime; + /* 0x024C */ s32 timePathWaypointTime; + /* 0x0250 */ s32 timePathWaypoint; + /* 0x0254 */ s32 timePathElapsedTime; /* 0x0258 */ u8 unk_258; /* 0x025C */ UNK_TYPE* unk_25C; /* 0x0260 */ s8 unk_260; @@ -44,7 +44,7 @@ typedef struct EnPm { /* 0x036E */ s16 unk_36E; /* 0x0370 */ s16 unk_370; /* 0x0372 */ s16 unk_372; - /* 0x0374 */ s16 unk_374; + /* 0x0374 */ s16 timePathTimeSpeed; /* 0x0376 */ s16 unk_376; /* 0x0378 */ s16 unk_378; /* 0x037C */ EnPmFunc unk_37C; diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 4a7e56682..21b0dd9a2 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -673,68 +673,66 @@ void func_80BABB90(EnSuttari* this, s32 arg1) { } } -s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { +s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* scheduleResult) { u16 sp26 = SCHEDULE_TIME_NOW; u16 pad1; u8 sp23 = ENSUTTARI_GET_PATH(&this->actor); u16 pad2; - UNK_TYPE sp1C = D_80BAE8F8[unkStruct->result]; + s32 sp1C = D_80BAE8F8[scheduleResult->result]; u16 phi_a0; if (sp1C >= 0) { - this->unk404 = SubS_GetAdditionalPath(globalCtx, sp23, sp1C); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp23, sp1C); } - if (this->unk404 == NULL) { + if (this->timePath == NULL) { return 0; } - if ((this->unk428 != 0 && this->unk428 < 0xC) && (this->unk42A >= 0)) { + if ((this->unk428 != 0 && this->unk428 < 0xC) && (this->timePathTimeSpeed >= 0)) { phi_a0 = sp26; } else { - phi_a0 = unkStruct->time0; + phi_a0 = scheduleResult->time0; } - if (unkStruct->time1 < phi_a0) { - this->unk418 = (phi_a0 - unkStruct->time1) + 0xFFFF; + if (scheduleResult->time1 < phi_a0) { + this->timePathTotalTime = (phi_a0 - scheduleResult->time1) + 0xFFFF; } else { - this->unk418 = unkStruct->time1 - phi_a0; + this->timePathTotalTime = scheduleResult->time1 - phi_a0; } - this->unk424 = sp26 - phi_a0; - phi_a0 = this->unk404->count - 2; + this->timePathElapsedTime = sp26 - phi_a0; + phi_a0 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); this->unk42C = 0; - this->unk41C = this->unk418 / phi_a0; - this->unk420 = (this->unk424 / this->unk41C) + 2; + this->timePathWaypointTime = this->timePathTotalTime / phi_a0; + this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk430 = 0; return 1; } -s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { +s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* scheduleResult) { s32 pad; EnDoor* sp48; - u8 sp47; - u16 sp44; + u8 sp47 = ENSUTTARI_GET_PATH(&this->actor); + u16 sp44 = SCHEDULE_TIME_NOW; Vec3f sp38; Vec3f sp2C; Vec3s* sp28; - UNK_TYPE sp24; + s32 sp24; - sp47 = ENSUTTARI_GET_PATH(&this->actor); - sp44 = SCHEDULE_TIME_NOW; if (this->unk428 == 10 || this->unk428 == 11 || this->unk428 == 2) { return 0; } sp48 = (EnDoor*)SubS_FindNearestActor(&this->actor, globalCtx, ACTORCAT_DOOR, ACTOR_EN_DOOR); - sp24 = D_80BAE8F8[unkStruct->result]; + sp24 = D_80BAE8F8[scheduleResult->result]; if ((sp48 != NULL) && (sp24 >= 0)) { - this->unk404 = SubS_GetAdditionalPath(globalCtx, sp47, sp24); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp47, sp24); } - if ((sp48 == NULL) || (this->unk404 == NULL)) { + if ((sp48 == NULL) || (this->timePath == NULL)) { return 0; } - sp28 = Lib_SegmentedToVirtual(this->unk404->points); + sp28 = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp38, &sp28[0]); Math_Vec3s_ToVec3f(&sp2C, &sp28[1]); - this->unk434 = sp44 - unkStruct->time0; - this->unk436 = unkStruct->time1 - unkStruct->time0; - if (unkStruct->result != 10 && unkStruct->result != 11) { + this->unk434 = sp44 - scheduleResult->time0; + this->unk436 = scheduleResult->time1 - scheduleResult->time0; + if (scheduleResult->result != 10 && scheduleResult->result != 11) { sp48->unk_1A7 = 0x4B; } Math_Vec3f_Copy(&this->unk438, &sp38); @@ -744,15 +742,15 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unk return 1; } -s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { +s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* scheduleResult) { s32 ret; - switch (unkStruct->result) { + switch (scheduleResult->result) { case 15: case 14: case 13: case 12: - ret = func_80BABC48(this, globalCtx, unkStruct); + ret = func_80BABC48(this, globalCtx, scheduleResult); break; case 11: case 10: @@ -760,7 +758,7 @@ s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unk case 8: case 7: case 6: - ret = func_80BABDD8(this, globalCtx, unkStruct); + ret = func_80BABDD8(this, globalCtx, scheduleResult); break; case 5: case 4: @@ -777,45 +775,47 @@ s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unk } s32 func_80BABFD4(EnSuttari* this, GlobalContext* globalCtx) { - f32 sp7C[265]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54 = 0; s32 sp50 = 0; s32 pad; - func_8013AF00(sp7C, 3, this->unk404->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (this->unk42C == 0) { - sp58 = gZeroVec3f; - func_8013B6B0(this->unk404, &this->unk414, &this->unk424, this->unk41C, this->unk418, &this->unk420, sp7C, - &sp58, this->unk42A); - func_8013B878(globalCtx, this->unk404, this->unk420, &sp58); - this->actor.world.pos.y = sp58.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk42C = 1; } else { - sp58 = this->unk408; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (SubS_InCsMode(globalCtx)) { - sp54 = this->unk424; - sp50 = this->unk420; - sp58 = this->actor.world.pos; + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk408 = gZeroVec3f; - if (func_8013B6B0(this->unk404, &this->unk414, &this->unk424, this->unk41C, this->unk418, &this->unk420, sp7C, - &this->unk408, this->unk42A)) { + this->timePathTargetPos = gZeroVec3f; + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk430 = 1; } else { sp70 = this->actor.world.pos; - sp64 = this->unk408; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } if (SubS_InCsMode(globalCtx)) { - this->unk424 = sp54; - this->unk420 = sp50; - this->unk408 = sp58; + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } return 0; } @@ -837,7 +837,7 @@ s32 func_80BAC220(EnSuttari* this, GlobalContext* globalCtx) { sp3C.z = this->unk434 * tmp; Lib_Vec3f_TranslateAndRotateY(&this->unk438, this->actor.world.rot.y, &sp3C, &sp30); this->actor.world.pos = sp30; - this->unk434 += this->unk42A; + this->unk434 += this->timePathTimeSpeed; return 0; } @@ -1099,17 +1099,17 @@ void func_80BACE4C(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { - ScheduleResult unkStruct; + ScheduleResult scheduleResult; - this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &scheduleResult) || + ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, globalCtx, &scheduleResult))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.result = 0; + scheduleResult.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.result; + this->unk428 = scheduleResult.result; func_80BAC2FC(this, globalCtx); func_80BAB434(this); if (this->unk428 == 5) { @@ -1123,17 +1123,17 @@ void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { - ScheduleResult unkStruct; + ScheduleResult scheduleResult; - this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &scheduleResult) || + ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, globalCtx, &scheduleResult))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.result = 0; + scheduleResult.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.result; + this->unk428 = scheduleResult.result; func_80BAC2FC(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { Message_StartTextbox(globalCtx, 0x2A3A, &this->actor); @@ -1244,7 +1244,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { - ScheduleResult unkStruct; + ScheduleResult scheduleResult; s16 curFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); @@ -1252,22 +1252,22 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { this->animationIndex = 2; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &scheduleResult) || + ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, globalCtx, &scheduleResult))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.result = 0; + scheduleResult.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.result; + this->unk428 = scheduleResult.result; func_80BAC2FC(this, globalCtx); - if ((this->unk430 == 1) && (this->unk404->unk1 == 0xFF)) { + if ((this->unk430 == 1) && (this->timePath->unk1 == 0xFF)) { Actor_MarkForDeath(&this->actor); return; } func_80BAB434(this); - if ((this->flags1 & 0x20) && (this->unk430 == 0) && (unkStruct.result != 7)) { + if ((this->flags1 & 0x20) && (this->unk430 == 0) && (scheduleResult.result != 7)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { Message_StartTextbox(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; @@ -1279,7 +1279,7 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { - ScheduleResult unkStruct; + ScheduleResult scheduleResult; s16 curFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); @@ -1290,21 +1290,21 @@ void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { this->animationIndex = 2; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &scheduleResult) || + ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, globalCtx, &scheduleResult))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.result = 0; + scheduleResult.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.result; + this->unk428 = scheduleResult.result; func_80BAC2FC(this, globalCtx); - if ((this->unk430 == 1) && (this->unk404->unk1 == 0xFF)) { + if ((this->unk430 == 1) && (this->timePath->unk1 == 0xFF)) { Actor_MarkForDeath(&this->actor); return; } - if ((this->flags1 & 0x20) && (unkStruct.result != 9)) { + if ((this->flags1 & 0x20) && (scheduleResult.result != 9)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { Message_StartTextbox(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h index 2fbdff53b..1fefc6f23 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h @@ -39,16 +39,15 @@ typedef struct EnSuttari { /* 0x3F4 */ s16 unk3F4; /* 0x3F6 */ s16 unk3F6; /* 0x3F8 */ Vec3f unk3F8; - /* 0x404 */ Path* unk404; - /* 0x408 */ Vec3f unk408; - /* 0x414 */ f32 unk414; - /* 0x418 */ s32 unk418; - /* 0x41C */ s32 unk41C; - /* 0x420 */ s32 unk420; - /* 0x424 */ s32 unk424; + /* 0x404 */ Path* timePath; + /* 0x408 */ Vec3f timePathTargetPos; + /* 0x414 */ f32 timePathProgress; + /* 0x418 */ s32 timePathTotalTime; + /* 0x41C */ s32 timePathWaypointTime; + /* 0x420 */ s32 timePathWaypoint; + /* 0x424 */ s32 timePathElapsedTime; /* 0x428 */ u8 unk428; - /* 0x429 */ UNK_TYPE1 unk_429[0x1]; - /* 0x42A */ s16 unk42A; + /* 0x42A */ s16 timePathTimeSpeed; /* 0x42C */ s32 unk42C; /* 0x430 */ s32 unk430; /* 0x434 */ s16 unk434; diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 4f61ac43f..4dcea5b0d 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -343,7 +343,7 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { this->unk_2DC += (REG(15) * sp44) - temp2; temp3 = this->unk_2DC; - this->unk_3D0 = temp2 + temp3; + this->timePathTimeSpeed = temp2 + temp3; this->unk_2DC -= temp3; this->unk_2E0 += REG(15); @@ -384,88 +384,89 @@ void func_80AECE0C(EnTk* this, GlobalContext* globalCtx) { s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { EnDoor* door; - f32 spA0[265]; + f32 knots[265]; Vec3f sp94; Vec3f sp88; - Vec3f sp7C; + Vec3f timePathTargetPos; s32 sp78; s32 sp74; - Actor* door2; - Actor* door1; - s32 pad2[1]; + s32 pad; - func_8013AF00(spA0, 3, this->unk_3C8->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk_3CE & 4)) { - sp7C = gZeroVec3f; - func_8013B6B0(this->unk_3C8, &this->unk_3E0, &this->unk_3F0, this->unk_3E8, this->unk_3E4, &this->unk_3EC, spA0, - &sp7C, this->unk_3D0); - func_8013B878(globalCtx, this->unk_3C8, this->unk_3EC, &sp7C); - this->actor.world.pos.y = sp7C.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; } else { - sp7C = this->unk_3D4; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp7C.x; - this->actor.world.pos.z = sp7C.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (!(this->unk_3CE & 4)) { Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); this->unk_3CE |= 4; } - if ((globalCtx->unk_18B4A != 0) || (this->unk_3D0 == 0)) { - sp78 = this->unk_3F0; - sp74 = this->unk_3EC; - sp7C = this->actor.world.pos; + if ((globalCtx->unk_18B4A != 0) || (this->timePathTimeSpeed == 0)) { + sp78 = this->timePathElapsedTime; + sp74 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_3D4 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_3C8, &this->unk_3E0, &this->unk_3F0, this->unk_3E8, this->unk_3E4, &this->unk_3EC, spA0, - &this->unk_3D4, this->unk_3D0)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_3CE |= 8; } else { sp94 = this->actor.world.pos; - sp88 = this->unk_3D4; + sp88 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp94, &sp88); } - if ((globalCtx->unk_18B4A != 0) || (this->unk_3D0 == 0)) { - this->unk_3F0 = sp78; - this->unk_3EC = sp74; - this->unk_3D4 = sp7C; + if ((globalCtx->unk_18B4A != 0) || (this->timePathTimeSpeed == 0)) { + this->timePathElapsedTime = sp78; + this->timePathWaypoint = sp74; + this->timePathTargetPos = timePathTargetPos; } door = NULL; if (!(this->unk_2CA & 0xC00)) { - door1 = NULL; - label: + Actor* doorIter = NULL; + do { - door1 = SubS_FindActor(globalCtx, door1, ACTORCAT_DOOR, ACTOR_EN_DOOR); - if (door1 != NULL) { - if (Actor_XZDistanceBetweenActors(&this->actor, door1) <= 120.0f) { - if (ABS(BINANG_SUB(Actor_YawToPoint(&this->actor, &door1->world.pos), this->actor.shape.rot.y)) <= - 0x2000) { + doorIter = SubS_FindActor(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); + if (doorIter != NULL) { + if (Actor_XZDistanceBetweenActors(&this->actor, doorIter) <= 120.0f) { + if (ABS(BINANG_SUB(Actor_YawToPoint(&this->actor, &doorIter->world.pos), + this->actor.shape.rot.y)) <= 0x2000) { this->unk_2CA |= 0x400; - door = (EnDoor*)door1; + door = (EnDoor*)doorIter; break; } } - door1 = door1->next; + doorIter = doorIter->next; } - } while (door1 != NULL); + } while (doorIter != NULL); } else { - door2 = NULL; + Actor* doorIter = NULL; + do { - door2 = SubS_FindActor(globalCtx, door2, ACTORCAT_DOOR, ACTOR_EN_DOOR); - if (door2 != NULL) { - if (Actor_XZDistanceBetweenActors(&this->actor, door2) <= 160.0f) { - door = (EnDoor*)door2; + doorIter = SubS_FindActor(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); + if (doorIter != NULL) { + if (Actor_XZDistanceBetweenActors(&this->actor, doorIter) <= 160.0f) { + door = (EnDoor*)doorIter; break; } - door2 = door2->next; + doorIter = doorIter->next; } - } while (door2 != NULL); + } while (doorIter != NULL); } if ((door != NULL) && (this->unk_2CA & 0x400)) { @@ -507,22 +508,22 @@ s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u16 phi_a1; s32 idx = arg2->result - 1; - this->unk_3C8 = SubS_GetAdditionalPath(globalCtx, params, D_80AEF8E8[idx + 1]); - if (this->unk_3C8 == 0) { + this->timePath = SubS_GetAdditionalPath(globalCtx, params, D_80AEF8E8[idx + 1]); + if (this->timePath == NULL) { return false; } - if ((this->unk_3CC <= 0) && (this->unk_3CC != 0) && (this->unk_3D0 >= 0)) { + if ((this->unk_3CC <= 0) && (this->unk_3CC != 0) && (this->timePathTimeSpeed >= 0)) { phi_a1 = sp1E; } else { phi_a1 = arg2->time0; } - this->unk_3E4 = arg2->time1 - phi_a1; - this->unk_3F0 = sp1E - phi_a1; - phi_a1 = this->unk_3C8->count - 2; - this->unk_3E8 = this->unk_3E4 / phi_a1; - this->unk_3EC = (this->unk_3F0 / this->unk_3E8) + 2; + this->timePathTotalTime = arg2->time1 - phi_a1; + this->timePathElapsedTime = sp1E - phi_a1; + phi_a1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / phi_a1; + this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_3CE &= ~4; this->unk_3CE &= ~8; return true; diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.h b/src/overlays/actors/ovl_En_Tk/z_en_tk.h index 119ae2b2b..ade05d6be 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.h +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.h @@ -51,16 +51,16 @@ typedef struct EnTk { /* 0x0324 */ Vec3f unk_324[6]; /* 0x036C */ s32 unk_36C; /* 0x0370 */ UNK_TYPE1 unk370[0x58]; - /* 0x03C8 */ Path* unk_3C8; + /* 0x03C8 */ Path* timePath; /* 0x03CC */ u8 unk_3CC; /* 0x03CE */ u16 unk_3CE; - /* 0x03D0 */ s32 unk_3D0; - /* 0x03D4 */ Vec3f unk_3D4; - /* 0x03E0 */ f32 unk_3E0; - /* 0x03E4 */ s32 unk_3E4; - /* 0x03E8 */ s32 unk_3E8; - /* 0x03EC */ s32 unk_3EC; - /* 0x03F0 */ s32 unk_3F0; + /* 0x03D0 */ s32 timePathTimeSpeed; + /* 0x03D4 */ Vec3f timePathTargetPos; + /* 0x03E0 */ f32 timePathProgress; + /* 0x03E4 */ s32 timePathTotalTime; + /* 0x03E8 */ s32 timePathWaypointTime; + /* 0x03EC */ s32 timePathWaypoint; + /* 0x03F0 */ s32 timePathElapsedTime; } EnTk; // size = 0x3F4 extern const ActorInit En_Tk_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 2c74907d5..6c0b5d2d7 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2661,19 +2661,19 @@ 0x8013AD6C:("SubS_InCsMode",), 0x8013AD9C:("SubS_UpdateLimb",), 0x8013AED4:("SubS_UpdateFlags",), - 0x8013AF00:("func_8013AF00",), - 0x8013B010:("func_8013B010",), - 0x8013B0C8:("func_8013B0C8",), - 0x8013B350:("func_8013B350",), - 0x8013B6B0:("func_8013B6B0",), - 0x8013B878:("func_8013B878",), + 0x8013AF00:("SubS_TimePathing_FillKnots",), + 0x8013B010:("SubS_TimePathing_ComputeProgress",), + 0x8013B0C8:("SubS_TimePathing_ComputeWeights",), + 0x8013B350:("SubS_TimePathing_ComputeTargetPosXZ",), + 0x8013B6B0:("SubS_TimePathing_Update",), + 0x8013B878:("SubS_TimePathing_ComputeInitialY",), 0x8013BB34:("SubS_GetAdditionalPath",), 0x8013BB7C:("SubS_FindNearestActor",), 0x8013BC6C:("SubS_ChangeAnimationByInfoS",), 0x8013BD40:("SubS_HasReachedPoint",), 0x8013BEDC:("SubS_GetDayDependentPath",), - 0x8013C068:("func_8013C068",), - 0x8013C624:("func_8013C624",), + 0x8013C068:("SubS_WeightPathing_ComputePoint",), + 0x8013C624:("SubS_WeightPathing_Move",), 0x8013C8B8:("SubS_CopyPointFromPathCheckBounds",), 0x8013C964:("func_8013C964",), 0x8013CC2C:("SubS_FillShadowTex",), @@ -2693,7 +2693,7 @@ 0x8013D9C8:("SubS_FillLimbRotTables",), 0x8013DB90:("SubS_IsFloorAbove",), 0x8013DC40:("SubS_CopyPointFromPathList",), - 0x8013DCCC:("SubS_GetPathCount",), + 0x8013DCCC:("SubS_GetPathCountFromPathList",), 0x8013DCE0:("SubS_ActorPathing_Init",), 0x8013DE04:("SubS_ActorPathing_Update",), 0x8013DF3C:("SubS_ActorPathing_ComputePointInfo",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 336b844df..602916a8e 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -1971,8 +1971,8 @@ 0x801C5CD0:("sMtxFClear","MtxF","",0x40), 0x801C5D10:("D_801C5D10","UNK_TYPE1","",0x1), 0x801C5D20:("D_801C5D20","UNK_TYPE1","",0x1), - 0x801C5D60:("gShadowDL","UNK_TYPE1","",0x1), - 0x801C5D80:("gShadowVtxDL","UNK_TYPE1","",0x1), + 0x801C5D60:("gShadowMaterialDL","UNK_TYPE1","",0x1), + 0x801C5D80:("gShadowModelDL","UNK_TYPE1","",0x1), 0x801C5DB0:("gOneVec3f","UNK_TYPE1","",0x1), 0x801C5DD0:("D_801C5DD0","UNK_TYPE1","",0x1), 0x801C5DE0:("D_801C5DE0","UNK_TYPE1","",0x1), @@ -15954,8 +15954,7 @@ 0x80BD68A0:("D_80BD68A0","UNK_TYPE1","",0x1), 0x80BD68A4:("D_80BD68A4","UNK_TYPE1","",0x1), 0x80BD6DF0:("En_Sc_Ruppe_InitVars","UNK_TYPE1","",0x1), - 0x80BD6E10:("D_80BD6E10","UNK_TYPE1","",0x1), - 0x80BD6E14:("D_80BD6E14","UNK_TYPE1","",0x1), + 0x80BD6E10:("D_80BD6E10","UNK_TYPE1","",0x30), 0x80BD6E40:("D_80BD6E40","UNK_TYPE1","",0x1), 0x80BD6E70:("jtbl_80BD6E70","UNK_PTR","",0x4), 0x80BD6E88:("D_80BD6E88","f32","",0x4), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index bb57bb8a8..b3e5db147 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2175,19 +2175,19 @@ asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlex.s,SubS_DrawTransformFlex,0 asm/non_matchings/code/z_sub_s/SubS_InCsMode.s,SubS_InCsMode,0x8013AD6C,0xC asm/non_matchings/code/z_sub_s/SubS_UpdateLimb.s,SubS_UpdateLimb,0x8013AD9C,0x4E asm/non_matchings/code/z_sub_s/SubS_UpdateFlags.s,SubS_UpdateFlags,0x8013AED4,0xB -asm/non_matchings/code/z_sub_s/func_8013AF00.s,func_8013AF00,0x8013AF00,0x44 -asm/non_matchings/code/z_sub_s/func_8013B010.s,func_8013B010,0x8013B010,0x2E -asm/non_matchings/code/z_sub_s/func_8013B0C8.s,func_8013B0C8,0x8013B0C8,0xA2 -asm/non_matchings/code/z_sub_s/func_8013B350.s,func_8013B350,0x8013B350,0xD8 -asm/non_matchings/code/z_sub_s/func_8013B6B0.s,func_8013B6B0,0x8013B6B0,0x72 -asm/non_matchings/code/z_sub_s/func_8013B878.s,func_8013B878,0x8013B878,0xAF +asm/non_matchings/code/z_sub_s/SubS_TimePathing_FillKnots.s,SubS_TimePathing_FillKnots,0x8013AF00,0x44 +asm/non_matchings/code/z_sub_s/SubS_TimePathing_ComputeProgress.s,SubS_TimePathing_ComputeProgress,0x8013B010,0x2E +asm/non_matchings/code/z_sub_s/SubS_TimePathing_ComputeWeights.s,SubS_TimePathing_ComputeWeights,0x8013B0C8,0xA2 +asm/non_matchings/code/z_sub_s/SubS_TimePathing_ComputeTargetPosXZ.s,SubS_TimePathing_ComputeTargetPosXZ,0x8013B350,0xD8 +asm/non_matchings/code/z_sub_s/SubS_TimePathing_Update.s,SubS_TimePathing_Update,0x8013B6B0,0x72 +asm/non_matchings/code/z_sub_s/SubS_TimePathing_ComputeInitialY.s,SubS_TimePathing_ComputeInitialY,0x8013B878,0xAF asm/non_matchings/code/z_sub_s/SubS_GetAdditionalPath.s,SubS_GetAdditionalPath,0x8013BB34,0x12 asm/non_matchings/code/z_sub_s/SubS_FindNearestActor.s,SubS_FindNearestActor,0x8013BB7C,0x3C asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationByInfoS.s,SubS_ChangeAnimationByInfoS,0x8013BC6C,0x35 asm/non_matchings/code/z_sub_s/SubS_HasReachedPoint.s,SubS_HasReachedPoint,0x8013BD40,0x67 asm/non_matchings/code/z_sub_s/SubS_GetDayDependentPath.s,SubS_GetDayDependentPath,0x8013BEDC,0x63 -asm/non_matchings/code/z_sub_s/func_8013C068.s,func_8013C068,0x8013C068,0x16F -asm/non_matchings/code/z_sub_s/func_8013C624.s,func_8013C624,0x8013C624,0xA5 +asm/non_matchings/code/z_sub_s/SubS_WeightPathing_ComputePoint.s,SubS_WeightPathing_ComputePoint,0x8013C068,0x16F +asm/non_matchings/code/z_sub_s/SubS_WeightPathing_Move.s,SubS_WeightPathing_Move,0x8013C624,0xA5 asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathCheckBounds.s,SubS_CopyPointFromPathCheckBounds,0x8013C8B8,0x2B asm/non_matchings/code/z_sub_s/func_8013C964.s,func_8013C964,0x8013C964,0xB2 asm/non_matchings/code/z_sub_s/SubS_FillShadowTex.s,SubS_FillShadowTex,0x8013CC2C,0x4E @@ -2207,7 +2207,7 @@ asm/non_matchings/code/z_sub_s/SubS_FindActor.s,SubS_FindActor,0x8013D960,0x1A asm/non_matchings/code/z_sub_s/SubS_FillLimbRotTables.s,SubS_FillLimbRotTables,0x8013D9C8,0x72 asm/non_matchings/code/z_sub_s/SubS_IsFloorAbove.s,SubS_IsFloorAbove,0x8013DB90,0x2C asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathList.s,SubS_CopyPointFromPathList,0x8013DC40,0x23 -asm/non_matchings/code/z_sub_s/SubS_GetPathCount.s,SubS_GetPathCount,0x8013DCCC,0x5 +asm/non_matchings/code/z_sub_s/SubS_GetPathCountFromPathList.s,SubS_GetPathCountFromPathList,0x8013DCCC,0x5 asm/non_matchings/code/z_sub_s/SubS_ActorPathing_Init.s,SubS_ActorPathing_Init,0x8013DCE0,0x49 asm/non_matchings/code/z_sub_s/SubS_ActorPathing_Update.s,SubS_ActorPathing_Update,0x8013DE04,0x4E asm/non_matchings/code/z_sub_s/SubS_ActorPathing_ComputePointInfo.s,SubS_ActorPathing_ComputePointInfo,0x8013DF3C,0x46 From 9682995b04f93732c1ae143f66d2933b29dfd5b5 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 19 Jun 2022 16:57:23 -0700 Subject: [PATCH 255/257] Controller Macros Update (#852) * macros * Format, I will remember 1 day --- include/macros.h | 8 +++--- src/code/flg_set.c | 2 +- src/code/z_kaleido_setup.c | 2 +- src/code/z_message.c | 6 ++--- .../actors/ovl_Arms_Hook/z_arms_hook.c | 2 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 4 +-- src/overlays/actors/ovl_Boss_03/z_boss_03.c | 2 +- .../actors/ovl_En_Fishing/z_en_fishing.c | 10 ++++---- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 22 ++++++++-------- src/overlays/actors/ovl_En_Mag/z_en_mag.c | 18 ++++++------- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 25 ++++++++++--------- src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 21 ++++++++-------- .../actors/ovl_En_Tanron2/z_en_tanron2.c | 2 +- src/overlays/actors/ovl_En_Test6/z_en_test6.c | 4 +-- src/overlays/actors/ovl_En_Trt/z_en_trt.c | 23 +++++++++-------- src/overlays/gamestates/ovl_select/z_select.c | 2 +- 16 files changed, 79 insertions(+), 74 deletions(-) diff --git a/include/macros.h b/include/macros.h index bb7315b3d..ddf3dcc87 100644 --- a/include/macros.h +++ b/include/macros.h @@ -111,10 +111,10 @@ #define CAPACITY(upg, value) gUpgradeCapacities[upg][value] #define CUR_CAPACITY(upg) CAPACITY(upg, CUR_UPG_VALUE(upg)) -#define CONTROLLER1(globalCtx) (&(globalCtx)->state.input[0]) -#define CONTROLLER2(globalCtx) (&(globalCtx)->state.input[1]) -#define CONTROLLER3(globalCtx) (&(globalCtx)->state.input[2]) -#define CONTROLLER4(globalCtx) (&(globalCtx)->state.input[3]) +#define CONTROLLER1(gameState) (&(gameState)->input[0]) +#define CONTROLLER2(gameState) (&(gameState)->input[1]) +#define CONTROLLER3(gameState) (&(gameState)->input[2]) +#define CONTROLLER4(gameState) (&(gameState)->input[3]) #define CHECK_BTN_ALL(state, combo) (~((state) | ~(combo)) == 0) #define CHECK_BTN_ANY(state, combo) (((state) & (combo)) != 0) diff --git a/src/code/flg_set.c b/src/code/flg_set.c index 53be7b68d..715d3756f 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -135,7 +135,7 @@ static s32 sTimer = 0; void FlagSet_Update(GameState* gameState) { GlobalContext* globalCtx = (GlobalContext*)gameState; - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); /* Intra-byte navigation */ diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 5a234ea44..5ed36d551 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -60,7 +60,7 @@ void func_800F4A10(GlobalContext* globalCtx) { } void KaleidoSetup_Update(GlobalContext* globalCtx) { - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); MessageContext* msgCtx = &globalCtx->msgCtx; Player* player = GET_PLAYER(globalCtx); PauseContext* pauseCtx = &globalCtx->pauseCtx; diff --git a/src/code/z_message.c b/src/code/z_message.c index 2a90f38ca..d8e2d5c8a 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -67,7 +67,7 @@ void func_80147564(GlobalContext* globalCtx) { s32 Message_ShouldAdvance(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; - Input* controller = CONTROLLER1(globalCtx); + Input* controller = CONTROLLER1(&globalCtx->state); if ((msgCtx->unk12020 == 0x10) || (msgCtx->unk12020 == 0x11)) { if (CHECK_BTN_ALL(controller->press.button, BTN_A)) { @@ -86,7 +86,7 @@ s32 Message_ShouldAdvance(GlobalContext* globalCtx) { s32 Message_ShouldAdvanceSilent(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; - Input* controller = CONTROLLER1(globalCtx); + Input* controller = CONTROLLER1(&globalCtx->state); if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { return CHECK_BTN_ALL(controller->press.button, BTN_A); @@ -117,7 +117,7 @@ void func_801477B4(GlobalContext* globalCtx) { void func_80148B98(GlobalContext* globalCtx, u8 arg1) { static s16 held = 0; MessageContext* msgCtx = &globalCtx->msgCtx; - Input* curInput = CONTROLLER1(globalCtx); + Input* curInput = CONTROLLER1(&globalCtx->state); if ((curInput->rel.stick_y > 29) && held == 0) { held = 1; diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index 16aa93bd9..18d5792d6 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -271,7 +271,7 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_IT_HOOKSHOT_REFLECT); } } else { - if (CHECK_BTN_ANY(CONTROLLER1(globalCtx)->press.button, + if (CHECK_BTN_ANY(CONTROLLER1(&globalCtx->state)->press.button, BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { s32 pad; this->timer = 1; diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index bad5f7383..900ca2a7d 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -1664,7 +1664,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { case 1: if ((this->unk_1D14 < 80U) && (D_809E0420 != 0) && - CHECK_BTN_ANY(CONTROLLER1(globalCtx)->press.button, + CHECK_BTN_ANY(CONTROLLER1(&globalCtx->state)->press.button, BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT)) { this->unk_1D18++; this->unk_1D78 = 1; @@ -1713,7 +1713,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { case 10: if ((this->unk_1D14 < 30U) && (D_809E0421 != 0) && - CHECK_BTN_ANY(CONTROLLER1(globalCtx)->press.button, + CHECK_BTN_ANY(CONTROLLER1(&globalCtx->state)->press.button, BTN_A | BTN_B | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT)) { this->unk_1D18++; this->unk_1D78 = 1; diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.c b/src/overlays/actors/ovl_Boss_03/z_boss_03.c index 1959ba26b..9691940d1 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -848,7 +848,7 @@ void Boss03_SetupChewPlayer(Boss03* this, GlobalContext* globalCtx) { void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); f32 jawZRotTarget; f32 xDiff; f32 yDiff; 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 668033cd6..dfd978d10 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -1923,7 +1923,7 @@ void EnFishing_DrawRod(GlobalContext* globalCtx) { f32 spC8; f32 spC4; f32 spC0; - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); Player* player = GET_PLAYER(globalCtx); s32 pad; @@ -2075,7 +2075,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { Vec3f spA8; Vec3f sp9C; Vec3f sp90; - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); D_809171FE++; @@ -2864,7 +2864,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { EnFishing* this = THIS; GlobalContext* globalCtx = globalCtx2; Player* player = GET_PLAYER(globalCtx); - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); f32 spD8; f32 phi_f0; f32 phi_f2; @@ -5052,7 +5052,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { f32 lureDistXZ; Camera* camera; Player* player = GET_PLAYER(globalCtx); - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); playerShadowAlpha = player->actor.shape.shadowAlpha; @@ -5621,7 +5621,7 @@ TexturePtr sFishingOwnerEyeTexs[] = { void EnFishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnFishing* this = THIS; - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index bfeca2143..233c0fe61 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -127,11 +127,11 @@ s32 EnFsn_TestItemSelected(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A); } - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_CUP); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_CUP); } u16 EnFsn_GetWelcome(GlobalContext* globalCtx) { @@ -483,8 +483,8 @@ s32 EnFsn_HasPlayerSelectedItem(EnFsn* this, GlobalContext* globalCtx, Input* in } void EnFsn_UpdateJoystickInputState(EnFsn* this, GlobalContext* globalCtx) { - s8 stickX = CONTROLLER1(globalCtx)->rel.stick_x; - s8 stickY = CONTROLLER1(globalCtx)->rel.stick_y; + s8 stickX = CONTROLLER1(&globalCtx->state)->rel.stick_x; + s8 stickY = CONTROLLER1(&globalCtx->state)->rel.stick_y; if (this->stickAccumX == 0) { if (stickX > 30 || stickX < -30) { @@ -882,7 +882,8 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { } } else if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { + if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state)) && + Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -1108,7 +1109,7 @@ void EnFsn_BrowseShelf(EnFsn* this, GlobalContext* globalCtx) { EnFsn_UpdateCursorPos(this, globalCtx); if (talkstate == 5) { func_8011552C(globalCtx, 6); - if (!EnFsn_HasPlayerSelectedItem(this, globalCtx, CONTROLLER1(globalCtx))) { + if (!EnFsn_HasPlayerSelectedItem(this, globalCtx, CONTROLLER1(&globalCtx->state))) { EnFsn_CursorLeftRight(this); if (this->cursorIdx != prevCursorIdx) { play_sound(NA_SE_SY_CURSOR); @@ -1210,7 +1211,8 @@ void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx) { if (EnFsn_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnFsn_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { + if (!EnFsn_TestCancelOption(this, globalCtx, CONTROLLER1(&globalCtx->state)) && + Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnFsn_HandleCanPlayerBuyItem(this, globalCtx); @@ -1330,7 +1332,7 @@ void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx) { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && + if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state)) && (!Message_ShouldAdvance(globalCtx) || !EnFsn_FacingShopkeeperDialogResult(this, globalCtx)) && this->stickAccumX > 0) { cursorIdx = EnFsn_SetCursorIndexFromNeutral(this); diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c index 907ba619b..ae1022413 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -235,9 +235,9 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.fileNum != 0xFEDC) { if (this->state == MAG_STATE_INITIAL) { - if (CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_START) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B)) { + if (CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_START) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B)) { if (!EnvFlags_Get(globalCtx, 4)) { play_sound(NA_SE_SY_PIECE_OF_HEART); @@ -378,9 +378,9 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { EnMag_UpdateDisplayEffectColors(&this->actor); if (sInputDelayTimer == 0) { - if (CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_START) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B)) { + if (CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_START) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B)) { if (globalCtx->sceneLoadFlag != 0x14) { Audio_SetCutsceneFlag(false); D_801BB12C++; @@ -427,9 +427,9 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { // Appear fully immediately if called during fade-in states. if ((this->state > MAG_STATE_INITIAL) && (this->state < MAG_STATE_CALLED)) { - if (CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_START) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B)) { + if (CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_START) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B)) { play_sound(NA_SE_SY_PIECE_OF_HEART); this->state = MAG_STATE_CALLED; } diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index ff85b7625..be1def264 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -199,11 +199,11 @@ s32 EnOssan_TestItemSelected(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A); } - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_CUP); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_CUP); } void EnOssan_CheckValidSpawn(EnOssan* this) { @@ -453,8 +453,8 @@ void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_UpdateJoystickInputState(GlobalContext* globalCtx, EnOssan* this) { - s8 stickX = CONTROLLER1(globalCtx)->rel.stick_x; - s8 stickY = CONTROLLER1(globalCtx)->rel.stick_y; + s8 stickX = CONTROLLER1(&globalCtx->state)->rel.stick_x; + s8 stickY = CONTROLLER1(&globalCtx->state)->rel.stick_y; this->moveHorizontal = this->moveVertical = false; @@ -574,7 +574,7 @@ void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { } else if (this->flags & END_INTERACTION) { this->flags &= ~END_INTERACTION; EnOssan_EndInteraction(globalCtx, this); - } else if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { + } else if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { EnOssan_StartShopping(globalCtx, this); } else { return; @@ -631,7 +631,7 @@ void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { } else { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && + if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state)) && (!Message_ShouldAdvance(globalCtx) || !EnOssan_FacingShopkeeperDialogResult(this, globalCtx))) { if (this->stickAccumX < 0) { cursorIdx = EnOssan_SetCursorIndexFromNeutral(this, 4); @@ -854,7 +854,7 @@ void EnOssan_BrowseLeftShelf(EnOssan* this, GlobalContext* globalCtx) { EnOssan_UpdateCursorPos(globalCtx, this); if (talkState == 5) { func_8011552C(globalCtx, 6); - if (!EnOssan_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(globalCtx))) { + if (!EnOssan_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(&globalCtx->state))) { if (this->moveHorizontal) { if (this->stickAccumX > 0) { cursorIdx = EnOssan_CursorRight(this, this->cursorIdx, 4); @@ -912,7 +912,7 @@ void EnOssan_BrowseRightShelf(EnOssan* this, GlobalContext* globalCtx) { EnOssan_UpdateCursorPos(globalCtx, this); if (talkState == 5) { func_8011552C(globalCtx, 6); - if (!EnOssan_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(globalCtx))) { + if (!EnOssan_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(&globalCtx->state))) { if (this->moveHorizontal != 0) { if (this->stickAccumX < 0) { cursorIdx = EnOssan_CursorRight(this, this->cursorIdx, 0); @@ -1053,7 +1053,8 @@ void EnOssan_SelectItem(EnOssan* this, GlobalContext* globalCtx) { if (EnOssan_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnOssan_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { + if (!EnOssan_TestCancelOption(this, globalCtx, CONTROLLER1(&globalCtx->state)) && + Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnOssan_HandleCanBuyItem(globalCtx, this); @@ -1124,7 +1125,7 @@ void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); - if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { + if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index a20556a31..ef47146b9 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -177,11 +177,11 @@ s32 EnSob1_TestItemSelected(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A); } - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_CUP); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_CUP); } u16 EnSob1_GetTalkOption(EnSob1* this, GlobalContext* globalCtx) { @@ -555,8 +555,8 @@ void EnSob1_Idle(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_UpdateJoystickInputState(GlobalContext* globalCtx, EnSob1* this) { - s8 stickX = CONTROLLER1(globalCtx)->rel.stick_x; - s8 stickY = CONTROLLER1(globalCtx)->rel.stick_y; + s8 stickX = CONTROLLER1(&globalCtx->state)->rel.stick_x; + s8 stickY = CONTROLLER1(&globalCtx->state)->rel.stick_y; if (this->stickAccumX == 0) { if (stickX > 30 || stickX < -30) { @@ -611,7 +611,7 @@ void EnSob1_Hello(EnSob1* this, GlobalContext* globalCtx) { } } if ((talkState == 5) && Message_ShouldAdvance(globalCtx) && - !EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { + !EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { if (this->welcomeTextId == 0x68A) { // Welcome text when wearing Kafei's mask EnSob1_EndInteraction(globalCtx, this); } else { @@ -661,7 +661,7 @@ void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { } else { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { + if (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { if (!Message_ShouldAdvance(globalCtx) || !EnSob1_FacingShopkeeperDialogResult(this, globalCtx)) { if (this->stickAccumX > 0) { cursorIndex = EnSob1_SetCursorIndexFromNeutral(this, 2); @@ -913,7 +913,7 @@ void EnSob1_BrowseShelf(EnSob1* this, GlobalContext* globalCtx) { EnSob1_UpdateCursorPos(globalCtx, this); if (talkState == 5) { func_8011552C(globalCtx, 6); - if (!EnSob1_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(globalCtx))) { + if (!EnSob1_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(&globalCtx->state))) { EnSob1_CursorLeftRight(globalCtx, this); cursorIndex = this->cursorIndex; if (cursorIndex != prevCursorIndex) { @@ -1021,7 +1021,8 @@ void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx) { if (EnSob1_TakeItemOffShelf(this) && talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnSob1_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { + if (!EnSob1_TestCancelOption(this, globalCtx, CONTROLLER1(&globalCtx->state)) && + Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnSob1_HandleCanBuyItem(globalCtx, this); diff --git a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c index 66ee6080e..6f52cfed7 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c @@ -564,7 +564,7 @@ void EnTanron2_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_159 = 1; } - input = CONTROLLER3(globalCtx); + input = CONTROLLER3(&globalCtx->state); if (CHECK_BTN_ALL(input->press.button, BTN_L)) { this->unk_158 = 1; } diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index 2efb3eb6b..5cca94ff0 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -407,7 +407,7 @@ void func_80A916F0(EnTest6* this, GlobalContext* globalCtx) { } void func_80A91760(EnTest6* this, GlobalContext* globalCtx) { - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); s16 temp_s0; Player* player = GET_PLAYER(globalCtx); Camera* sp78; @@ -628,7 +628,7 @@ void func_80A92118(EnTest6* this, GlobalContext* globalCtx) { } void func_80A92188(EnTest6* this, GlobalContext* globalCtx) { - Input* input = CONTROLLER1(globalCtx); + Input* input = CONTROLLER1(&globalCtx->state); Player* player = GET_PLAYER(globalCtx); Camera* camera; s32 pad; diff --git a/src/overlays/actors/ovl_En_Trt/z_en_trt.c b/src/overlays/actors/ovl_En_Trt/z_en_trt.c index 470f4908a..17094ac7f 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -114,11 +114,11 @@ s32 EnTrt_TestItemSelected(GlobalContext* globalCtx) { MessageContext* msgCtx = &globalCtx->msgCtx; if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A); } - return CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B) || - CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_CUP); + return CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_A) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_B) || + CHECK_BTN_ALL(CONTROLLER1(&globalCtx->state)->press.button, BTN_CUP); } void EnTrt_SpawnShopItems(EnTrt* this, GlobalContext* globalCtx, ShopItem* shopItem) { @@ -257,8 +257,8 @@ void EnTrt_StartShopping(GlobalContext* globalCtx, EnTrt* this) { } void EnTrt_UpdateJoystickInputState(GlobalContext* globalCtx, EnTrt* this) { - s8 stickX = CONTROLLER1(globalCtx)->rel.stick_x; - s8 stickY = CONTROLLER1(globalCtx)->rel.stick_y; + s8 stickX = CONTROLLER1(&globalCtx->state)->rel.stick_x; + s8 stickY = CONTROLLER1(&globalCtx->state)->rel.stick_y; if (this->stickAccumX == 0) { if (stickX > 30 || stickX < -30) { @@ -314,7 +314,7 @@ void EnTrt_Hello(EnTrt* this, GlobalContext* globalCtx) { } if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { play_sound(NA_SE_SY_MESSAGE_PASS); - if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { + if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { EnTrt_StartShopping(globalCtx, this); } } @@ -520,7 +520,7 @@ void EnTrt_FaceShopkeeper(EnTrt* this, GlobalContext* globalCtx) { this->cutsceneState = ENTRT_CUTSCENESTATE_WAITING; } else if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { + if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { if ((!Message_ShouldAdvance(globalCtx) || !EnTrt_FacingShopkeeperDialogResult(this, globalCtx)) && (this->stickAccumX > 0)) { cursorIdx = EnTrt_SetCursorIndexFromNeutral(this, 2); @@ -622,7 +622,7 @@ void EnTrt_BrowseShelf(EnTrt* this, GlobalContext* globalCtx) { EnTrt_UpdateCursorPos(globalCtx, this); if (talkState == 5) { func_8011552C(globalCtx, 6); - if (!EnTrt_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(globalCtx))) { + if (!EnTrt_HasPlayerSelectedItem(globalCtx, this, CONTROLLER1(&globalCtx->state))) { EnTrt_CursorLeftRight(globalCtx, this); if (this->cursorIdx != prevCursorIdx) { func_80151938(globalCtx, EnTrt_GetItemTextId(this)); @@ -707,7 +707,8 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { if (EnTrt_TakeItemOffShelf(this)) { if (talkState == 4) { func_8011552C(globalCtx, 6); - if (!EnTrt_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { + if (!EnTrt_TestCancelOption(this, globalCtx, CONTROLLER1(&globalCtx->state)) && + Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnTrt_HandleCanBuyItem(globalCtx, this); @@ -1098,7 +1099,7 @@ void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx) { EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); - if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { + if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(&globalCtx->state))) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 53dbc266f..ea650803e 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -357,7 +357,7 @@ static SceneSelectEntry sScenes[] = { void Select_UpdateMenu(SelectContext* this) { s32 playerForm; - Input* controller1 = CONTROLLER1(this); + Input* controller1 = CONTROLLER1(&this->state); s32 stickY; s32 pad[2]; s16 i; From 6d371502e1fcc7777035fd977df518bb0e3aab1c Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Sun, 19 Jun 2022 17:11:47 -0700 Subject: [PATCH 256/257] Actor effect cleanup (#828) * Change "particle" to "effect" in most actors * Undo accidental comment change * Effect count defines * Make struct names consistent * Fix minislime * Change particle to effect in Demo_Kankyo * Some tiny things I missed --- include/z64.h | 2 +- .../actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c | 6 +- .../actors/ovl_Boss_Hakugin/z_boss_hakugin.h | 8 +- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 413 +++++++++--------- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.h | 8 +- src/overlays/actors/ovl_En_Baguo/z_en_baguo.c | 110 +++-- src/overlays/actors/ovl_En_Baguo/z_en_baguo.h | 14 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 32 +- .../actors/ovl_En_Bigslime/z_en_bigslime.h | 6 +- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.c | 98 ++--- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.h | 8 +- src/overlays/actors/ovl_En_Dai/z_en_dai.c | 71 ++- src/overlays/actors/ovl_En_Dai/z_en_dai.h | 8 +- .../actors/ovl_En_Daiku2/z_en_daiku2.c | 64 +-- .../actors/ovl_En_Daiku2/z_en_daiku2.h | 8 +- src/overlays/actors/ovl_En_Dnb/z_en_dnb.c | 88 ++-- src/overlays/actors/ovl_En_Dnb/z_en_dnb.h | 6 +- .../actors/ovl_En_Encount2/z_en_encount2.c | 62 +-- .../actors/ovl_En_Encount2/z_en_encount2.h | 12 +- src/overlays/actors/ovl_En_Fall/z_en_fall.c | 95 ++-- src/overlays/actors/ovl_En_Fall/z_en_fall.h | 2 +- .../actors/ovl_En_Hakurock/z_en_hakurock.c | 40 +- .../actors/ovl_En_Minislime/z_en_minislime.c | 22 +- src/overlays/actors/ovl_En_Raf/z_en_raf.c | 117 +++-- src/overlays/actors/ovl_En_Raf/z_en_raf.h | 14 +- src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c | 6 +- tools/disasm/functions.txt | 30 +- 27 files changed, 673 insertions(+), 677 deletions(-) diff --git a/include/z64.h b/include/z64.h index 6331a456a..a7895b186 100644 --- a/include/z64.h +++ b/include/z64.h @@ -705,7 +705,7 @@ typedef struct { /* 0xEC */ u8 unk_EC; /* 0xED */ u8 unk_ED; /* 0xEE */ u8 unk_EE[4]; - /* 0xF2 */ u8 unk_F2[8]; // [3] is used by both DemoKankyo and ObjectKankyo particle count + /* 0xF2 */ u8 unk_F2[8]; // [3] is used by both DemoKankyo and ObjectKankyo effect count /* 0xFA */ u8 unk_FA[4]; } EnvironmentContext; // size = 0x100 diff --git a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c index d064a3cb4..aae5930ed 100644 --- a/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c +++ b/src/overlays/actors/ovl_Bg_Goron_Oyu/z_bg_goron_oyu.c @@ -20,7 +20,7 @@ void func_80B40100(BgGoronOyu* this, GlobalContext* globalCtx); void func_80B400C8(BgGoronOyu* this, GlobalContext* globalCtx); void func_80B401F8(BgGoronOyu* this, GlobalContext* globalCtx); void BgGoronOyu_UpdateWaterBoxInfo(BgGoronOyu* this, GlobalContext* globalCtx); -void BgGoronOyu_SpawnParticles(BgGoronOyu* this, GlobalContext* globalCtx); +void BgGoronOyu_SpawnEffects(BgGoronOyu* this, GlobalContext* globalCtx); void func_80B40160(BgGoronOyu* this, GlobalContext* globalCtx); const ActorInit Bg_Goron_Oyu_InitVars = { @@ -108,7 +108,7 @@ void BgGoronOyu_UpdateWaterBoxInfo(BgGoronOyu* this, GlobalContext* globalCtx) { } } -void BgGoronOyu_SpawnParticles(BgGoronOyu* this, GlobalContext* globalCtx) { +void BgGoronOyu_SpawnEffects(BgGoronOyu* this, GlobalContext* globalCtx) { s16 scale; Vec3f pos1; Vec3f pos2; @@ -178,7 +178,7 @@ void BgGoronOyu_Update(Actor* thisx, GlobalContext* globalCtx) { BgGoronOyu* this = THIS; this->actionFunc(this, globalCtx); - BgGoronOyu_SpawnParticles(this, globalCtx); + BgGoronOyu_SpawnEffects(this, globalCtx); } void BgGoronOyu_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h index 3b5882692..3aa7d122a 100644 --- a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h +++ b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h @@ -7,21 +7,23 @@ struct BossHakugin; typedef void (*BossHakuginActionFunc)(struct BossHakugin*, GlobalContext*); -typedef struct BossHakuginParticle { +typedef struct BossHakuginEffect { /* 0x00 */ Vec3f unk_0; /* 0x0C */ Vec3f unk_C; /* 0x18 */ s16 unk_18; /* 0x1A */ s16 unk_1A; /* 0x1C */ Vec3s unk_1C; /* 0x24 */ f32 unk_24; -} BossHakuginParticle; // size = 0x28 +} BossHakuginEffect; // size = 0x28 + +#define BOSS_HAKUGIN_EFFECT_COUNT 180 typedef struct BossHakugin { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_0144[0x44]; /* 0x0188 */ BossHakuginActionFunc actionFunc; /* 0x018C */ char unk_018C[0x86C]; - /* 0x09F8 */ BossHakuginParticle unk_9F8[180]; + /* 0x09F8 */ BossHakuginEffect unk_9F8[BOSS_HAKUGIN_EFFECT_COUNT]; /* 0x2618 */ char unk_2618[0x11F8]; } BossHakugin; // size = 0x3810 diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index 2c676abbf..179d480de 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -1,7 +1,7 @@ /* * File: z_demo_kankyo.c * Overlay: ovl_Demo_Kankyo - * Description: Background Lost Woods/Giant's Chamber/Moon Particles + * Description: Background Lost Woods/Giant's Chamber/Moon Effects */ #include "z_demo_kankyo.h" @@ -44,7 +44,7 @@ void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globa s32 pad; s32 i; f32 randSkyfishParticleNum; - f32 repositionLimit; // Distance from posCenter when particles are relocated. Always set to 130.0f + f32 repositionLimit; // Distance from posCenter when effects are relocated. Always set to 130.0f f32 eyeToAtNormX; f32 eyeToAtNormY; f32 eyeToAtNormZ; @@ -61,13 +61,13 @@ void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globa } else { Actor_MarkForDeath(&this->actor); } - } else if (globalCtx->envCtx.unk_F2[3] < DEMOKANKYO_PARTICLE_COUNT) { + } else if (globalCtx->envCtx.unk_F2[3] < DEMOKANKYO_EFFECT_COUNT) { globalCtx->envCtx.unk_F2[3] += 16; } // note: DemoKankyo can crash if placed in an area that snows (ObjectKankyo) - // because they both use unk_F2 as a particle counter, - // causing DemoKankyo to write beyond its particle array boundry + // because they both use unk_F2 as an effect counter, + // causing DemoKankyo to write beyond its efffect array boundry // this crash can occur if the two actors are in different scenes connected by an exit // e.g. if you add DemoKankyo to GoronShrine, you will crash entering/leaving through door for (i = 0; i < globalCtx->envCtx.unk_F2[3]; i++) { @@ -81,53 +81,53 @@ void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globa eyeToAtNormY = eyeToAt.y / eyeToAtMag; eyeToAtNormZ = eyeToAt.z / eyeToAtMag; - switch (this->particles[i].state) { + switch (this->effects[i].state) { case DEMO_KANKYO_STATE_INIT: - this->particles[i].posBase.x = globalCtx->view.eye.x + (eyeToAtNormX * 80.0f); - this->particles[i].posBase.y = globalCtx->view.eye.y + (eyeToAtNormY * 80.0f); - this->particles[i].posBase.z = globalCtx->view.eye.z + (eyeToAtNormZ * 80.0f); + this->effects[i].posBase.x = globalCtx->view.eye.x + (eyeToAtNormX * 80.0f); + this->effects[i].posBase.y = globalCtx->view.eye.y + (eyeToAtNormY * 80.0f); + this->effects[i].posBase.z = globalCtx->view.eye.z + (eyeToAtNormZ * 80.0f); - this->particles[i].posOffset.x = (Rand_ZeroOne() - 0.5f) * 160.0f; - this->particles[i].posOffset.y = 30.0f; - this->particles[i].posOffset.z = (Rand_ZeroOne() - 0.5f) * 160.0f; + this->effects[i].posOffset.x = (Rand_ZeroOne() - 0.5f) * 160.0f; + this->effects[i].posOffset.y = 30.0f; + this->effects[i].posOffset.z = (Rand_ZeroOne() - 0.5f) * 160.0f; - this->particles[i].speedTarget = (Rand_ZeroOne() * 1.6f) + 0.5f; - this->particles[i].alpha = 0; - this->particles[i].alphaClock = Rand_ZeroOne() * 65535; // random 0 to max of u16 - this->particles[i].scale = 0.1f; + this->effects[i].speedTarget = (Rand_ZeroOne() * 1.6f) + 0.5f; + this->effects[i].alpha = 0; + this->effects[i].alphaClock = Rand_ZeroOne() * 65535; // random 0 to max of u16 + this->effects[i].scale = 0.1f; // speedClock is angles in radians, // should have used Rand_ZeroOne() * 2 * M_PI // however, due to properties of sine waves, this is effectively still random - this->particles[i].speedClock.x = Rand_ZeroOne() * 360.0f; - this->particles[i].speedClock.y = Rand_ZeroOne() * 360.0f; - this->particles[i].speedClock.z = Rand_ZeroOne() * 360.0f; - this->particles[i].pad50 = 0; - this->particles[i].state += DEMO_KANKYO_STATE_SINGLE; + this->effects[i].speedClock.x = Rand_ZeroOne() * 360.0f; + this->effects[i].speedClock.y = Rand_ZeroOne() * 360.0f; + this->effects[i].speedClock.z = Rand_ZeroOne() * 360.0f; + this->effects[i].pad50 = 0; + this->effects[i].state += DEMO_KANKYO_STATE_SINGLE; break; case DEMO_KANKYO_STATE_SINGLE: case DEMO_KANKYO_STATE_SKYFISH: - this->particles[i].alphaClock++; + this->effects[i].alphaClock++; posCenterX = globalCtx->view.eye.x + (eyeToAtNormX * 80.0f); posCenterY = globalCtx->view.eye.y + (eyeToAtNormY * 80.0f); posCenterZ = globalCtx->view.eye.z + (eyeToAtNormZ * 80.0f); - this->particles[i].posOffsetPrev.x = this->particles[i].posOffset.x; - this->particles[i].posOffsetPrev.y = this->particles[i].posOffset.y; - this->particles[i].posOffsetPrev.z = this->particles[i].posOffset.z; + this->effects[i].posOffsetPrev.x = this->effects[i].posOffset.x; + this->effects[i].posOffsetPrev.y = this->effects[i].posOffset.y; + this->effects[i].posOffsetPrev.z = this->effects[i].posOffset.z; - if (this->particles[i].state == DEMO_KANKYO_STATE_SINGLE) { + if (this->effects[i].state == DEMO_KANKYO_STATE_SINGLE) { - // The first 32 particles will become skyfish particles + // The first 32 effects will become skyfish particles // This block is also init code and only runs once if (i < 32) { if (Rand_ZeroOne() < 0.5f) { - this->particles[i].LostWoodsSkyFishSpeedXZ = (s16)(Rand_ZeroOne() * 200.0f) + 200; + this->effects[i].LostWoodsSkyFishSpeedXZ = (s16)(Rand_ZeroOne() * 200.0f) + 200; } else { - this->particles[i].LostWoodsSkyFishSpeedXZ = -200 - (s16)(Rand_ZeroOne() * 200.0f); + this->effects[i].LostWoodsSkyFishSpeedXZ = -200 - (s16)(Rand_ZeroOne() * 200.0f); } - this->particles[i].LostWoodsSkyFishPosOffsetMax = (s16)(Rand_ZeroOne() * 50.0f) + 15; - this->particles[i].LostWoodsSkyFishSpeedY = ((Rand_ZeroOne() * 10.0f) + 10.0f) * 0.01f; + this->effects[i].LostWoodsSkyFishPosOffsetMax = (s16)(Rand_ZeroOne() * 50.0f) + 15; + this->effects[i].LostWoodsSkyFishSpeedY = ((Rand_ZeroOne() * 10.0f) + 10.0f) * 0.01f; // Only the 31st particle matters as sLostWoodsSkyFishParticleNum will be overwritten // every particle until the last skyfish particle is initialized @@ -145,147 +145,134 @@ void DemoKakyo_LostWoodsSparkleActionFunc(DemoKankyo* this, GlobalContext* globa if ((i & sLostWoodsSkyFishParticleNum) == 0) { // Head particle - this->particles[i].posOffset.y = 0.0f; + this->effects[i].posOffset.y = 0.0f; } - this->particles[i].state = DEMO_KANKYO_STATE_SKYFISH; - this->particles[i].speedTarget = 0.0f; + this->effects[i].state = DEMO_KANKYO_STATE_SKYFISH; + this->effects[i].speedTarget = 0.0f; } - Math_SmoothStepToF(&this->particles[i].scale, 0.1, 0.1f, 0.001f, 0.00001f); - Math_SmoothStepToF(&this->particles[i].speed, this->particles[i].speedTarget, 0.5f, 0.2f, 0.02f); - this->particles[i].posOffset.x += sinf(this->particles[i].speedClock.x) * this->particles[i].speed; - this->particles[i].posOffset.y += sinf(this->particles[i].speedClock.y) * this->particles[i].speed; - this->particles[i].posOffset.z += sinf(this->particles[i].speedClock.z) * this->particles[i].speed; + Math_SmoothStepToF(&this->effects[i].scale, 0.1, 0.1f, 0.001f, 0.00001f); + Math_SmoothStepToF(&this->effects[i].speed, this->effects[i].speedTarget, 0.5f, 0.2f, 0.02f); + this->effects[i].posOffset.x += sinf(this->effects[i].speedClock.x) * this->effects[i].speed; + this->effects[i].posOffset.y += sinf(this->effects[i].speedClock.y) * this->effects[i].speed; + this->effects[i].posOffset.z += sinf(this->effects[i].speedClock.z) * this->effects[i].speed; switch ((i >> 1) & 3) { case 0: - this->particles[i].speedClock.x += 0.008f; - this->particles[i].speedClock.y += 0.05f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.015f; + this->effects[i].speedClock.x += 0.008f; + this->effects[i].speedClock.y += 0.05f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.015f; break; case 1: - this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); - this->particles[i].speedClock.y += 0.05f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.005f * Rand_ZeroOne(); + this->effects[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->effects[i].speedClock.y += 0.05f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.005f * Rand_ZeroOne(); break; case 2: - this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); - this->particles[i].speedClock.y += 0.4f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.004f * Rand_ZeroOne(); + this->effects[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->effects[i].speedClock.y += 0.4f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.004f * Rand_ZeroOne(); break; case 3: - this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); - this->particles[i].speedClock.y += 0.08f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.05f * Rand_ZeroOne(); + this->effects[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->effects[i].speedClock.y += 0.08f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.05f * Rand_ZeroOne(); break; } - } else if (this->particles[i].state == DEMO_KANKYO_STATE_SKYFISH) { + } else if (this->effects[i].state == DEMO_KANKYO_STATE_SKYFISH) { if ((i & sLostWoodsSkyFishParticleNum) == 0) { // Head particle - Math_SmoothStepToF(&this->particles[i].scale, 0.25f, 0.1f, 0.001f, 0.00001f); + Math_SmoothStepToF(&this->effects[i].scale, 0.25f, 0.1f, 0.001f, 0.00001f); - Math_SmoothStepToF(&this->particles[i].posBase.x, player->actor.world.pos.x, 0.5f, 1.0f, 0.2f); - Math_SmoothStepToF(&this->particles[i].posBase.y, player->actor.world.pos.y + 50.0f, 0.5f, 1.0f, + Math_SmoothStepToF(&this->effects[i].posBase.x, player->actor.world.pos.x, 0.5f, 1.0f, 0.2f); + Math_SmoothStepToF(&this->effects[i].posBase.y, player->actor.world.pos.y + 50.0f, 0.5f, 1.0f, 0.2f); - Math_SmoothStepToF(&this->particles[i].posBase.z, player->actor.world.pos.z, 0.5f, 1.0f, 0.2f); + Math_SmoothStepToF(&this->effects[i].posBase.z, player->actor.world.pos.z, 0.5f, 1.0f, 0.2f); - Math_SmoothStepToF(&this->particles[i].posOffset.x, - Math_SinS(this->particles[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * - this->particles[i].LostWoodsSkyFishPosOffsetMax, + Math_SmoothStepToF(&this->effects[i].posOffset.x, + Math_SinS(this->effects[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * + this->effects[i].LostWoodsSkyFishPosOffsetMax, 0.5f, 2.0f, 0.2f); - Math_SmoothStepToF(&this->particles[i].posOffset.z, - Math_CosS(this->particles[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * - this->particles[i].LostWoodsSkyFishPosOffsetMax, + Math_SmoothStepToF(&this->effects[i].posOffset.z, + Math_CosS(this->effects[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * + this->effects[i].LostWoodsSkyFishPosOffsetMax, 0.5f, 2.0f, 0.2f); - this->particles[i].LostWoodsSkyFishSpeedXZClock += this->particles[i].LostWoodsSkyFishSpeedXZ; - this->particles[i].posOffset.y += sinf(this->particles[i].speedClock.y); - this->particles[i].speedClock.x += 0.2f * Rand_ZeroOne(); // unused calculation - this->particles[i].speedClock.y += this->particles[i].LostWoodsSkyFishSpeedY; - this->particles[i].speedClock.z += 0.1f * Rand_ZeroOne(); // unused calculation + this->effects[i].LostWoodsSkyFishSpeedXZClock += this->effects[i].LostWoodsSkyFishSpeedXZ; + this->effects[i].posOffset.y += sinf(this->effects[i].speedClock.y); + this->effects[i].speedClock.x += 0.2f * Rand_ZeroOne(); // unused calculation + this->effects[i].speedClock.y += this->effects[i].LostWoodsSkyFishSpeedY; + this->effects[i].speedClock.z += 0.1f * Rand_ZeroOne(); // unused calculation - this->particles[i].posOffset.x = - Math_SinS(this->particles[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * - this->particles[i].LostWoodsSkyFishPosOffsetMax; - this->particles[i].posOffset.z = - Math_CosS(this->particles[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * - this->particles[i].LostWoodsSkyFishPosOffsetMax; + this->effects[i].posOffset.x = + Math_SinS(this->effects[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * + this->effects[i].LostWoodsSkyFishPosOffsetMax; + this->effects[i].posOffset.z = + Math_CosS(this->effects[i].LostWoodsSkyFishSpeedXZClock - 0x8000) * + this->effects[i].LostWoodsSkyFishPosOffsetMax; } else { // Tail Particles - Math_SmoothStepToF(&this->particles[i].scale, 0.1, 0.1f, 0.001f, 0.00001f); + Math_SmoothStepToF(&this->effects[i].scale, 0.1, 0.1f, 0.001f, 0.00001f); // Unused calculation, speed only used in posOffset calculations, // but posOffset gets overwritten for tail particles immediately below - Math_SmoothStepToF(&this->particles[i].speed, 1.5f, 0.5f, 0.1f, 0.0002f); + Math_SmoothStepToF(&this->effects[i].speed, 1.5f, 0.5f, 0.1f, 0.0002f); // particles in the skyfish's tail are moved to the previous position of the particle directly // in front - this->particles[i].posOffset.x = - this->particles[i - 1].posOffsetPrev.x + - (this->particles[i - 1].posBase.x - this->particles[i].posBase.x); - this->particles[i].posOffset.y = - this->particles[i - 1].posOffsetPrev.y + - (this->particles[i - 1].posBase.y - this->particles[i].posBase.y); - this->particles[i].posOffset.z = - this->particles[i - 1].posOffsetPrev.z + - (this->particles[i - 1].posBase.z - this->particles[i].posBase.z); + this->effects[i].posOffset.x = this->effects[i - 1].posOffsetPrev.x + + (this->effects[i - 1].posBase.x - this->effects[i].posBase.x); + this->effects[i].posOffset.y = this->effects[i - 1].posOffsetPrev.y + + (this->effects[i - 1].posBase.y - this->effects[i].posBase.y); + this->effects[i].posOffset.z = this->effects[i - 1].posOffsetPrev.z + + (this->effects[i - 1].posBase.z - this->effects[i].posBase.z); } } - if ((this->particles[i].state != DEMO_KANKYO_STATE_SKYFISH) && - ((((this->particles[i].posBase.x + this->particles[i].posOffset.x) - posCenterX) > - repositionLimit) || - (((this->particles[i].posBase.x + this->particles[i].posOffset.x) - posCenterX) < - -repositionLimit) || - (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - posCenterY) > - repositionLimit) || - (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - posCenterY) < - -repositionLimit) || - (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - posCenterZ) > - repositionLimit) || - (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - posCenterZ) < - -repositionLimit))) { - if (((this->particles[i].posOffset.x + this->particles[i].posBase.x) - posCenterX) > - repositionLimit) { - this->particles[i].posOffset.x = 0.0f; - this->particles[i].posBase.x = posCenterX - repositionLimit; + if ((this->effects[i].state != DEMO_KANKYO_STATE_SKYFISH) && + ((((this->effects[i].posBase.x + this->effects[i].posOffset.x) - posCenterX) > repositionLimit) || + (((this->effects[i].posBase.x + this->effects[i].posOffset.x) - posCenterX) < -repositionLimit) || + (((this->effects[i].posBase.y + this->effects[i].posOffset.y) - posCenterY) > repositionLimit) || + (((this->effects[i].posBase.y + this->effects[i].posOffset.y) - posCenterY) < -repositionLimit) || + (((this->effects[i].posBase.z + this->effects[i].posOffset.z) - posCenterZ) > repositionLimit) || + (((this->effects[i].posBase.z + this->effects[i].posOffset.z) - posCenterZ) < -repositionLimit))) { + if (((this->effects[i].posOffset.x + this->effects[i].posBase.x) - posCenterX) > repositionLimit) { + this->effects[i].posOffset.x = 0.0f; + this->effects[i].posBase.x = posCenterX - repositionLimit; } - if (((this->particles[i].posBase.x + this->particles[i].posOffset.x) - posCenterX) < - -repositionLimit) { - this->particles[i].posOffset.x = 0.0f; - this->particles[i].posBase.x = posCenterX + repositionLimit; + if (((this->effects[i].posBase.x + this->effects[i].posOffset.x) - posCenterX) < -repositionLimit) { + this->effects[i].posOffset.x = 0.0f; + this->effects[i].posBase.x = posCenterX + repositionLimit; } - if (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - posCenterY) > 50.0f) { - this->particles[i].posOffset.y = 0.0f; - this->particles[i].posBase.y = posCenterY - 50.0f; + if (((this->effects[i].posBase.y + this->effects[i].posOffset.y) - posCenterY) > 50.0f) { + this->effects[i].posOffset.y = 0.0f; + this->effects[i].posBase.y = posCenterY - 50.0f; } - if (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - posCenterY) < -50.0f) { - this->particles[i].posOffset.y = 0.0f; - this->particles[i].posBase.y = posCenterY + 50.0f; + if (((this->effects[i].posBase.y + this->effects[i].posOffset.y) - posCenterY) < -50.0f) { + this->effects[i].posOffset.y = 0.0f; + this->effects[i].posBase.y = posCenterY + 50.0f; } - if (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - posCenterZ) > - repositionLimit) { - this->particles[i].posOffset.z = 0.0f; - this->particles[i].posBase.z = posCenterZ - repositionLimit; + if (((this->effects[i].posBase.z + this->effects[i].posOffset.z) - posCenterZ) > repositionLimit) { + this->effects[i].posOffset.z = 0.0f; + this->effects[i].posBase.z = posCenterZ - repositionLimit; } - if (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - posCenterZ) < - -repositionLimit) { - this->particles[i].posOffset.z = 0.0f; - this->particles[i].posBase.z = posCenterZ + repositionLimit; + if (((this->effects[i].posBase.z + this->effects[i].posOffset.z) - posCenterZ) < -repositionLimit) { + this->effects[i].posOffset.z = 0.0f; + this->effects[i].posBase.z = posCenterZ + repositionLimit; } } break; case DEMO_KANKYO_STATE_DISABLED: - this->particles[i].state = DEMO_KANKYO_STATE_INIT; + this->effects[i].state = DEMO_KANKYO_STATE_INIT; break; } } @@ -317,7 +304,7 @@ void DemoKakyo_MoonSparklesActionFunc(DemoKankyo* this, GlobalContext* globalCtx s32 pad1; Vec3f worldPos; - if (globalCtx->envCtx.unk_F2[3] < DEMOKANKYO_PARTICLE_COUNT) { + if (globalCtx->envCtx.unk_F2[3] < DEMOKANKYO_EFFECT_COUNT) { globalCtx->envCtx.unk_F2[3] += 16; } @@ -332,38 +319,38 @@ void DemoKakyo_MoonSparklesActionFunc(DemoKankyo* this, GlobalContext* globalCtx halfScreenHeight = SCREEN_HEIGHT / 2; for (i = 0; i < globalCtx->envCtx.unk_F2[3]; i++) { - switch (this->particles[i].state) { + switch (this->effects[i].state) { case DEMO_KANKYO_STATE_INIT: - this->particles[i].posBase.x = globalCtx->view.eye.x + (eyeToAtNormX * halfScreenHeight); - this->particles[i].posBase.y = globalCtx->view.eye.y + (eyeToAtNormY * halfScreenHeight); - this->particles[i].posBase.z = globalCtx->view.eye.z + (eyeToAtNormZ * halfScreenHeight); + this->effects[i].posBase.x = globalCtx->view.eye.x + (eyeToAtNormX * halfScreenHeight); + this->effects[i].posBase.y = globalCtx->view.eye.y + (eyeToAtNormY * halfScreenHeight); + this->effects[i].posBase.z = globalCtx->view.eye.z + (eyeToAtNormZ * halfScreenHeight); - this->particles[i].posOffset.x = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); - this->particles[i].posOffset.y = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); - this->particles[i].posOffset.z = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); + this->effects[i].posOffset.x = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); + this->effects[i].posOffset.y = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); + this->effects[i].posOffset.z = (Rand_ZeroOne() - 0.5f) * (2.0f * halfScreenHeight); - this->particles[i].speedTarget = (Rand_ZeroOne() * 1.6f) + 0.5f; - this->particles[i].alpha = 0; - this->particles[i].alphaClock = (Rand_ZeroOne() * 65535); - this->particles[i].scale = 0.2f; + this->effects[i].speedTarget = (Rand_ZeroOne() * 1.6f) + 0.5f; + this->effects[i].alpha = 0; + this->effects[i].alphaClock = (Rand_ZeroOne() * 65535); + this->effects[i].scale = 0.2f; // speedClock is angles in radians, // should have used Rand_ZeroOne() * 2 * M_PI // however, due to properties of sine waves, this is effectively still random - this->particles[i].speedClock.x = Rand_ZeroOne() * 360.0f; - this->particles[i].speedClock.y = Rand_ZeroOne() * 360.0f; - this->particles[i].speedClock.z = Rand_ZeroOne() * 360.0f; + this->effects[i].speedClock.x = Rand_ZeroOne() * 360.0f; + this->effects[i].speedClock.y = Rand_ZeroOne() * 360.0f; + this->effects[i].speedClock.z = Rand_ZeroOne() * 360.0f; - this->particles[i].pad50 = 0; - this->particles[i].state += DEMO_KANKYO_STATE_SINGLE; + this->effects[i].pad50 = 0; + this->effects[i].state += DEMO_KANKYO_STATE_SINGLE; break; case DEMO_KANKYO_STATE_SINGLE: case DEMO_KANKYO_STATE_SKYFISH: - this->particles[i].alphaClock++; + this->effects[i].alphaClock++; if (this->actor.params == DEMO_KANKYO_TYPE_MOON) { // this function gets reused for giants too - this->particles[i].posBase.y = + this->effects[i].posBase.y = globalCtx->view.eye.y + (eyeToAtNormY * halfScreenHeight) + (SCREEN_HEIGHT / 3); } @@ -371,76 +358,76 @@ void DemoKakyo_MoonSparklesActionFunc(DemoKankyo* this, GlobalContext* globalCtx newEye.y = globalCtx->view.eye.y + (eyeToAtNormY * halfScreenHeight); newEye.z = globalCtx->view.eye.z + (eyeToAtNormZ * halfScreenHeight); - Math_SmoothStepToF(&this->particles[i].scale, 0.2f, 0.1f, 0.001f, 0.00001f); - Math_SmoothStepToF(&this->particles[i].speed, this->particles[i].speedTarget, 0.5f, 0.2f, 0.02f); + Math_SmoothStepToF(&this->effects[i].scale, 0.2f, 0.1f, 0.001f, 0.00001f); + Math_SmoothStepToF(&this->effects[i].speed, this->effects[i].speedTarget, 0.5f, 0.2f, 0.02f); - this->particles[i].posOffset.x += sinf(this->particles[i].speedClock.x) * this->particles[i].speed; - this->particles[i].posOffset.y += sinf(this->particles[i].speedClock.y) * this->particles[i].speed; - this->particles[i].posOffset.z += sinf(this->particles[i].speedClock.z) * this->particles[i].speed; + this->effects[i].posOffset.x += sinf(this->effects[i].speedClock.x) * this->effects[i].speed; + this->effects[i].posOffset.y += sinf(this->effects[i].speedClock.y) * this->effects[i].speed; + this->effects[i].posOffset.z += sinf(this->effects[i].speedClock.z) * this->effects[i].speed; switch ((i >> 1) & 3) { case 0: - this->particles[i].speedClock.x += 0.008f; - this->particles[i].speedClock.y += 0.05f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.015f; + this->effects[i].speedClock.x += 0.008f; + this->effects[i].speedClock.y += 0.05f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.015f; break; case 1: - this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); - this->particles[i].speedClock.y += 0.05f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.005f * Rand_ZeroOne(); + this->effects[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->effects[i].speedClock.y += 0.05f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.005f * Rand_ZeroOne(); break; case 2: - this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); - this->particles[i].speedClock.y += 0.4f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.004f * Rand_ZeroOne(); + this->effects[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->effects[i].speedClock.y += 0.4f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.004f * Rand_ZeroOne(); break; case 3: - this->particles[i].speedClock.x += 0.01f * Rand_ZeroOne(); - this->particles[i].speedClock.y += 0.08f * Rand_ZeroOne(); - this->particles[i].speedClock.z += 0.05f * Rand_ZeroOne(); + this->effects[i].speedClock.x += 0.01f * Rand_ZeroOne(); + this->effects[i].speedClock.y += 0.08f * Rand_ZeroOne(); + this->effects[i].speedClock.z += 0.05f * Rand_ZeroOne(); break; } - if (((this->particles[i].posBase.x + this->particles[i].posOffset.x) - newEye.x) > halfScreenHeight) { - this->particles[i].posBase.x = newEye.x - halfScreenHeight; + if (((this->effects[i].posBase.x + this->effects[i].posOffset.x) - newEye.x) > halfScreenHeight) { + this->effects[i].posBase.x = newEye.x - halfScreenHeight; } - if (((this->particles[i].posBase.x + this->particles[i].posOffset.x) - newEye.x) < -halfScreenHeight) { - this->particles[i].posBase.x = newEye.x + halfScreenHeight; + if (((this->effects[i].posBase.x + this->effects[i].posOffset.x) - newEye.x) < -halfScreenHeight) { + this->effects[i].posBase.x = newEye.x + halfScreenHeight; } - worldPos.x = this->particles[i].posBase.x + this->particles[i].posOffset.x; - worldPos.y = this->particles[i].posBase.y + this->particles[i].posOffset.y; - worldPos.z = this->particles[i].posBase.z + this->particles[i].posOffset.z; + worldPos.x = this->effects[i].posBase.x + this->effects[i].posOffset.x; + worldPos.y = this->effects[i].posBase.y + this->effects[i].posOffset.y; + worldPos.z = this->effects[i].posBase.z + this->effects[i].posOffset.z; randZeroOne = Math_Vec3f_DistXZ(&worldPos, &globalCtx->view.eye) / 200.0f; randZeroOne = CLAMP(randZeroOne, 0.0f, 1.0f); halfScreenWidth = 100.0f + randZeroOne + 60.0f; // range 160 to 161...? thats about half screen width - // I think this code is shifting the particles 1 frame -> half screen at a time to keep it in-view - if (halfScreenWidth < ((this->particles[i].posBase.y + this->particles[i].posOffset.y) - newEye.y)) { - this->particles[i].posBase.y = newEye.y - halfScreenWidth; + // I think this code is shifting the effects 1 frame -> half screen at a time to keep it in-view + if (halfScreenWidth < ((this->effects[i].posBase.y + this->effects[i].posOffset.y) - newEye.y)) { + this->effects[i].posBase.y = newEye.y - halfScreenWidth; } - if (((this->particles[i].posBase.y + this->particles[i].posOffset.y) - newEye.y) < -halfScreenWidth) { - this->particles[i].posBase.y = newEye.y + halfScreenWidth; + if (((this->effects[i].posBase.y + this->effects[i].posOffset.y) - newEye.y) < -halfScreenWidth) { + this->effects[i].posBase.y = newEye.y + halfScreenWidth; } - if (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - newEye.z) > halfScreenHeight) { - this->particles[i].posBase.z = newEye.z - halfScreenHeight; + if (((this->effects[i].posBase.z + this->effects[i].posOffset.z) - newEye.z) > halfScreenHeight) { + this->effects[i].posBase.z = newEye.z - halfScreenHeight; } - if (((this->particles[i].posBase.z + this->particles[i].posOffset.z) - newEye.z) < -halfScreenHeight) { - this->particles[i].posBase.z = newEye.z + halfScreenHeight; + if (((this->effects[i].posBase.z + this->effects[i].posOffset.z) - newEye.z) < -halfScreenHeight) { + this->effects[i].posBase.z = newEye.z + halfScreenHeight; } break; case DEMO_KANKYO_STATE_DISABLED: - this->particles[i].state = DEMO_KANKYO_STATE_INIT; + this->effects[i].state = DEMO_KANKYO_STATE_INIT; break; } } @@ -454,7 +441,7 @@ void DemoKankyo_Init(Actor* thisx, GlobalContext* globalCtx) { // This must be a single line to match, possibly a macro? // clang-format off - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { this->particles[i].state = DEMO_KANKYO_STATE_INIT; } + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { this->effects[i].state = DEMO_KANKYO_STATE_INIT; } // clang-format on if (1) {}; @@ -524,9 +511,9 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB10); for (i = 0; i < globalCtx->envCtx.unk_F2[3]; i++) { - worldPos.x = this->particles[i].posBase.x + this->particles[i].posOffset.x; - worldPos.y = this->particles[i].posBase.y + this->particles[i].posOffset.y; - worldPos.z = this->particles[i].posBase.z + this->particles[i].posOffset.z; + worldPos.x = this->effects[i].posBase.x + this->effects[i].posOffset.x; + worldPos.y = this->effects[i].posBase.y + this->effects[i].posOffset.y; + worldPos.z = this->effects[i].posBase.z + this->effects[i].posOffset.z; func_80169474(globalCtx, &worldPos, &screenPos); // unnamed Play_ function, func_800C016C from OoT @@ -534,52 +521,52 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, GlobalContext* globalCtx2) { if (screenPos.x >= 0.0f && screenPos.x < SCREEN_WIDTH && screenPos.y >= 0.0f && screenPos.y < SCREEN_HEIGHT) { Matrix_Translate(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); - scaleAlpha = this->particles[i].alpha / 50.0f; + scaleAlpha = this->effects[i].alpha / 50.0f; if (scaleAlpha > 1.0f) { scaleAlpha = 1.0f; } - Matrix_Scale(this->particles[i].scale * scaleAlpha, this->particles[i].scale * scaleAlpha, - this->particles[i].scale * scaleAlpha, MTXMODE_APPLY); + Matrix_Scale(this->effects[i].scale * scaleAlpha, this->effects[i].scale * scaleAlpha, + this->effects[i].scale * scaleAlpha, MTXMODE_APPLY); // adjust transparency of this particle if (i < 32) { // Skyfish particles - if (this->particles[i].state != DEMO_KANKYO_STATE_SKYFISH) { + if (this->effects[i].state != DEMO_KANKYO_STATE_SKYFISH) { // still initializing - if (this->particles[i].alpha > 0) { // NOT DECR - this->particles[i].alpha--; + if (this->effects[i].alpha > 0) { // NOT DECR + this->effects[i].alpha--; } - } else if (this->particles[i].alpha < 100) { - this->particles[i].alpha++; + } else if (this->effects[i].alpha < 100) { + this->effects[i].alpha++; } - } else if (this->particles[i].state != DEMO_KANKYO_STATE_SKYFISH) { - if ((this->particles[i].alphaClock & 31) < 16) { - if (this->particles[i].alpha < 235) { - this->particles[i].alpha += 20; + } else if (this->effects[i].state != DEMO_KANKYO_STATE_SKYFISH) { + if ((this->effects[i].alphaClock & 31) < 16) { + if (this->effects[i].alpha < 235) { + this->effects[i].alpha += 20; } - } else if (this->particles[i].alpha > 20) { - this->particles[i].alpha -= 20; + } else if (this->effects[i].alpha > 20) { + this->effects[i].alpha -= 20; } - } else if ((this->particles[i].alphaClock & 15) < 8) { - if (this->particles[i].alpha < 255) { - this->particles[i].alpha += 100; + } else if ((this->effects[i].alphaClock & 15) < 8) { + if (this->effects[i].alpha < 255) { + this->effects[i].alpha += 100; } - } else if (this->particles[i].alpha > 10) { - this->particles[i].alpha -= 10; + } else if (this->effects[i].alpha > 10) { + this->effects[i].alpha -= 10; } gDPPipeSync(POLY_XLU_DISP++); switch (i & 1) { case 0: // gold particles - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 155, this->particles[i].alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 0, this->particles[i].alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 155, this->effects[i].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 0, this->effects[i].alpha); break; case 1: // silver particles - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, this->particles[i].alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, this->particles[i].alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, this->effects[i].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, this->effects[i].alpha); break; } @@ -613,42 +600,42 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { func_8012C2DC(gfxCtx); for (i = 0; i < globalCtx->envCtx.unk_F2[3]; i++) { - worldPos.x = this->particles[i].posBase.x + this->particles[i].posOffset.x; - worldPos.y = this->particles[i].posBase.y + this->particles[i].posOffset.y; - worldPos.z = this->particles[i].posBase.z + this->particles[i].posOffset.z; + worldPos.x = this->effects[i].posBase.x + this->effects[i].posOffset.x; + worldPos.y = this->effects[i].posBase.y + this->effects[i].posOffset.y; + worldPos.z = this->effects[i].posBase.z + this->effects[i].posOffset.z; func_80169474(globalCtx, &worldPos, &screenPos); // unnamed Play_ function, func_800C016C from OoT - // checking if particle is on screen + // checking if effect is on screen if (screenPos.x >= 0.0f && screenPos.x < SCREEN_WIDTH && screenPos.y >= 0.0f && screenPos.y < SCREEN_HEIGHT) { Matrix_Translate(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); - alphaScale = this->particles[i].alpha / 50.0f; + alphaScale = this->effects[i].alpha / 50.0f; if (alphaScale > 1.0f) { alphaScale = 1.0f; } - Matrix_Scale(this->particles[i].scale * alphaScale, this->particles[i].scale * alphaScale, - this->particles[i].scale * alphaScale, MTXMODE_APPLY); + Matrix_Scale(this->effects[i].scale * alphaScale, this->effects[i].scale * alphaScale, + this->effects[i].scale * alphaScale, MTXMODE_APPLY); alphaScale = Math_Vec3f_DistXYZ(&worldPos, &globalCtx->view.eye) / 300.0f; alphaScale = CLAMP(1.0f - alphaScale, 0.0f, 1.0f); if (this->actor.params == DEMO_KANKYO_TYPE_GIANTS) { - this->particles[i].alpha = 255.0f * alphaScale; + this->effects[i].alpha = 255.0f * alphaScale; } else { - this->particles[i].alpha = 160.0f * alphaScale; + this->effects[i].alpha = 160.0f * alphaScale; } gDPPipeSync(POLY_XLU_DISP++); switch (i & 1) { // half/half slightly different shades of yellow/tan case 0: - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 230, 230, 220, this->particles[i].alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 230, 230, 30, this->particles[i].alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 230, 230, 220, this->effects[i].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 230, 230, 30, this->effects[i].alpha); break; case 1: - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 200, 190, this->particles[i].alpha); - gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 30, this->particles[i].alpha); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 200, 190, this->effects[i].alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 30, this->effects[i].alpha); break; } diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h index d70616ed6..e614117ee 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.h @@ -18,18 +18,18 @@ typedef struct { /* 0x03C */ u16 alphaClock; /* 0x03E */ u16 LostWoodsSkyFishSpeedXZClock; /* 0x040 */ u8 alpha; - /* 0x044 */ f32 scale; // size of the particle + /* 0x044 */ f32 scale; // size of the effect /* 0x048 */ u16 LostWoodsSkyFishSpeedXZ; // the x-z speed (angular velocity) the lost woods skyfish oscillates around player. pos or neg 200-400 /* 0x04A */ u16 LostWoodsSkyFishPosOffsetMax; // The x-z range the lost woods skyfish oscillates around player. random value between 15-65 /* 0x04C */ f32 LostWoodsSkyFishSpeedY; // the y speed (angular velocity) the lost woods skyfish oscillates around player. /* 0x050 */ u16 pad50; // unused, always assigned to 0, nothing else in this actor uses it -} DemoKankyoParticle; // size = 0x54 +} DemoKankyoEffect; // size = 0x54 -#define DEMOKANKYO_PARTICLE_COUNT 64 +#define DEMOKANKYO_EFFECT_COUNT 64 typedef struct DemoKankyo { /* 0x0000 */ Actor actor; - /* 0x0144 */ DemoKankyoParticle particles[DEMOKANKYO_PARTICLE_COUNT]; + /* 0x0144 */ DemoKankyoEffect effects[DEMOKANKYO_EFFECT_COUNT]; /* 0x1644 */ DemoKankyoActionFunc actionFunc; /* 0x1648 */ s32 objectId; /* 0x164C */ u8 isSafeToDrawGiants; diff --git a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c index 88fc11072..66ba49919 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c @@ -22,10 +22,9 @@ void EnBaguo_Roll(EnBaguo* this, GlobalContext* globalCtx); void EnBaguo_SetupRetreatUnderground(EnBaguo* this); void EnBaguo_RetreatUnderground(EnBaguo* this, GlobalContext* globalCtx); void EnBaguo_DrawBody(Actor* thisx, GlobalContext* globalCtx); -void EnBaguo_InitializeParticle(EnBaguo* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, - s16 timer); -void EnBaguo_UpdateParticles(EnBaguo* this, GlobalContext* globalCtx); -void EnBaguo_DrawRockParticles(EnBaguo* this, GlobalContext* globalCtx); +void EnBaguo_InitializeEffect(EnBaguo* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, s16 timer); +void EnBaguo_UpdateEffects(EnBaguo* this, GlobalContext* globalCtx); +void EnBaguo_DrawEffects(EnBaguo* this, GlobalContext* globalCtx); typedef enum { /* 0x0 */ NEJIRON_ACTION_INACTIVE, // The Nejiron is either underground or emerging from underground @@ -311,7 +310,7 @@ void EnBaguo_PostDetonation(EnBaguo* this, GlobalContext* globalCtx) { void EnBaguo_CheckForDetonation(EnBaguo* this, GlobalContext* globalCtx) { Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - Vec3f acceleration = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.0f, 0.0f }; s32 i; // In order to match, this variable must act as both a boolean to check if @@ -335,15 +334,15 @@ void EnBaguo_CheckForDetonation(EnBaguo* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; this->actor.shape.shadowScale = 0.0f; - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - acceleration.x = (Rand_ZeroOne() - 0.5f) * 8.0f; - acceleration.y = -1.0f; - acceleration.z = (Rand_ZeroOne() - 0.5f) * 8.0f; + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + accel.x = (Rand_ZeroOne() - 0.5f) * 8.0f; + accel.y = -1.0f; + accel.z = (Rand_ZeroOne() - 0.5f) * 8.0f; velocity.x = (Rand_ZeroOne() - 0.5f) * 14.0f; velocity.y = Rand_ZeroOne() * 30.0f; velocity.z = (Rand_ZeroOne() - 0.5f) * 14.0f; - EnBaguo_InitializeParticle(this, &this->actor.focus.pos, &velocity, &acceleration, - (Rand_ZeroFloat(1.0f) * 0.01f) + 0.003f, 90); + EnBaguo_InitializeEffect(this, &this->actor.focus.pos, &velocity, &accel, + (Rand_ZeroFloat(1.0f) * 0.01f) + 0.003f, 90); } Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, @@ -368,7 +367,7 @@ void EnBaguo_Update(Actor* thisx, GlobalContext* globalCtx) { EnBaguo* this = THIS; Actor_SetFocus(&this->actor, 30.0f); - EnBaguo_UpdateParticles(this, globalCtx); + EnBaguo_UpdateEffects(this, globalCtx); EnBaguo_CheckForDetonation(this, globalCtx); this->actionFunc(this, globalCtx); @@ -432,77 +431,76 @@ void EnBaguo_DrawBody(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - EnBaguo_DrawRockParticles(this, globalCtx); + EnBaguo_DrawEffects(this, globalCtx); } -void EnBaguo_InitializeParticle(EnBaguo* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, - s16 timer) { +void EnBaguo_InitializeEffect(EnBaguo* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, s16 timer) { s16 i; - NejironParticle* particle = this->particles; + NejironEffect* effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (!particle->isVisible) { - particle->isVisible = true; - particle->position = *position; - particle->velocity = *velocity; - particle->acceleration = *acceleration; - particle->scale = scale; - particle->timer = timer; - particle->rotation.x = (s16)randPlusMinusPoint5Scaled(30000.0f); - particle->rotation.y = (s16)randPlusMinusPoint5Scaled(30000.0f); - particle->rotation.z = (s16)randPlusMinusPoint5Scaled(30000.0f); + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (!effect->isEnabled) { + effect->isEnabled = true; + effect->pos = *pos; + effect->velocity = *velocity; + effect->accel = *accel; + effect->scale = scale; + effect->timer = timer; + effect->rotation.x = (s16)randPlusMinusPoint5Scaled(30000.0f); + effect->rotation.y = (s16)randPlusMinusPoint5Scaled(30000.0f); + effect->rotation.z = (s16)randPlusMinusPoint5Scaled(30000.0f); return; } } } -void EnBaguo_UpdateParticles(EnBaguo* this, GlobalContext* globalCtx) { +void EnBaguo_UpdateEffects(EnBaguo* this, GlobalContext* globalCtx) { s32 i; - NejironParticle* particle = this->particles; + NejironEffect* effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isVisible) { - particle->position.x += particle->velocity.x; - particle->position.y += particle->velocity.y; - particle->position.z += particle->velocity.z; - particle->rotation.x += 0xBB8; - particle->rotation.y += 0xBB8; - particle->rotation.z += 0xBB8; - particle->velocity.x += particle->acceleration.x; - particle->velocity.y += particle->acceleration.y; - particle->velocity.z += particle->acceleration.z; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + effect->pos.x += effect->velocity.x; + effect->pos.y += effect->velocity.y; + effect->pos.z += effect->velocity.z; + effect->rotation.x += 0xBB8; + effect->rotation.y += 0xBB8; + effect->rotation.z += 0xBB8; + effect->velocity.x += effect->accel.x; + effect->velocity.y += effect->accel.y; + effect->velocity.z += effect->accel.z; - if (particle->position.y < (this->actor.world.pos.y - 10.0f)) { - Math_ApproachZeroF(&particle->scale, 0.2f, 0.001f); - if (particle->scale <= 0.0001f) { - particle->timer = 0; + if (effect->pos.y < (this->actor.world.pos.y - 10.0f)) { + Math_ApproachZeroF(&effect->scale, 0.2f, 0.001f); + if (effect->scale <= 0.0001f) { + effect->timer = 0; } } - if (particle->timer != 0) { - particle->timer--; + if (effect->timer != 0) { + effect->timer--; } else { - particle->isVisible = false; + effect->isEnabled = false; } } } } -void EnBaguo_DrawRockParticles(EnBaguo* this, GlobalContext* globalCtx) { +void EnBaguo_DrawEffects(EnBaguo* this, GlobalContext* globalCtx) { s16 i; - NejironParticle* particle = this->particles; + NejironEffect* effect = this->effects; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; OPEN_DISPS(gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isVisible) { - Matrix_Translate(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); - Matrix_RotateXS(particle->rotation.x, MTXMODE_APPLY); - Matrix_RotateYS(particle->rotation.y, MTXMODE_APPLY); - Matrix_RotateZS(particle->rotation.z, MTXMODE_APPLY); - Matrix_Scale(particle->scale, particle->scale, particle->scale, MTXMODE_APPLY); + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateXS(effect->rotation.x, MTXMODE_APPLY); + Matrix_RotateYS(effect->rotation.y, MTXMODE_APPLY); + Matrix_RotateZS(effect->rotation.z, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_OPA_DISP++, 0, 1, 255, 255, 255, 255); diff --git a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.h b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.h index 133e68b3d..553a77f48 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.h +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.h @@ -12,15 +12,17 @@ typedef void (*EnBaguoActionFunc)(struct EnBaguo*, GlobalContext*); * When a Nejiron explodes, rock particles fly out from where it exploded. * This struct governs how these rock particles behave. */ -typedef struct NejironParticle { - /* 0x00 */ u8 isVisible; - /* 0x04 */ Vec3f position; +typedef struct NejironEffect { + /* 0x00 */ u8 isEnabled; + /* 0x04 */ Vec3f pos; /* 0x10 */ Vec3f velocity; - /* 0x1C */ Vec3f acceleration; + /* 0x1C */ Vec3f accel; /* 0x28 */ Vec3s rotation; /* 0x30 */ f32 scale; /* 0x34 */ s16 timer; -} NejironParticle; // size = 0x38 +} NejironEffect; // size = 0x38 + +#define EN_BAGUO_EFFECT_COUNT 30 typedef struct EnBaguo { /* 0x000 */ Actor actor; @@ -39,7 +41,7 @@ typedef struct EnBaguo { /* 0x1D0 */ Vec3f targetRotation; /* 0x1DC */ ColliderJntSph collider; /* 0x1FC */ ColliderJntSphElement colliderElements[1]; - /* 0x23C */ NejironParticle particles[30]; + /* 0x23C */ NejironEffect effects[EN_BAGUO_EFFECT_COUNT]; } EnBaguo; // size = 0x8CC extern const ActorInit En_Baguo_InitVars; diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index 0e3c9b20a..c546ba780 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -2700,10 +2700,10 @@ void EnBigslime_AddIceShardEffect(EnBigslime* this, GlobalContext* globalCtx) { iceShardEffect->pos.x = (targetVtx->n.ob[0] * this->actor.scale.x) + this->actor.world.pos.x; iceShardEffect->pos.y = (targetVtx->n.ob[1] * this->actor.scale.y) + this->actor.world.pos.y; iceShardEffect->pos.z = (targetVtx->n.ob[2] * this->actor.scale.z) + this->actor.world.pos.z; - iceShardEffect->rotation.x = (s32)Rand_Next() >> 0x10; - iceShardEffect->rotation.y = (s32)Rand_Next() >> 0x10; - iceShardEffect->rotation.z = (s32)Rand_Next() >> 0x10; - iceShardEffect->isActive = true; + iceShardEffect->rot.x = (s32)Rand_Next() >> 0x10; + iceShardEffect->rot.y = (s32)Rand_Next() >> 0x10; + iceShardEffect->rot.z = (s32)Rand_Next() >> 0x10; + iceShardEffect->isEnabled = true; randPitch = Rand_S16Offset(0x1000, 0x3000); vtxZ = targetVtx->n.ob[2]; vtxX = targetVtx->n.ob[0]; @@ -2715,9 +2715,9 @@ void EnBigslime_AddIceShardEffect(EnBigslime* this, GlobalContext* globalCtx) { xzDist = Math_CosS(randPitch) * randFloat; } - iceShardEffect->vel.x = targetVtx->n.ob[0] * xzDist; - iceShardEffect->vel.y = Math_SinS(randPitch) * randFloat; - iceShardEffect->vel.z = targetVtx->n.ob[2] * xzDist; + iceShardEffect->velocity.x = targetVtx->n.ob[0] * xzDist; + iceShardEffect->velocity.y = Math_SinS(randPitch) * randFloat; + iceShardEffect->velocity.z = targetVtx->n.ob[2] * xzDist; iceShardEffect->scale = 0.001f * (Rand_ZeroFloat(6.0f) + 2.0f); } } @@ -2736,15 +2736,15 @@ void EnBigslime_UpdateEffects(EnBigslime* this) { // Update ice shards for (i = 0; i < BIGSLIME_NUM_ICE_SHARD; i++) { iceShardEffect = &this->iceShardEffect[i]; - if (iceShardEffect->isActive > false) { - iceShardEffect->vel.y += -1.0f; - Math_Vec3f_Sum(&iceShardEffect->pos, &iceShardEffect->vel, &iceShardEffect->pos); + if (iceShardEffect->isEnabled > false) { + iceShardEffect->velocity.y += -1.0f; + Math_Vec3f_Sum(&iceShardEffect->pos, &iceShardEffect->velocity, &iceShardEffect->pos); if (iceShardEffect->pos.y < (GBT_ROOM_5_MIN_Y - 20.0f)) { - iceShardEffect->isActive = false; + iceShardEffect->isEnabled = false; } - iceShardEffect->rotation.x += (s16)((Rand_Next() >> 0x17) + 0x700); - iceShardEffect->rotation.y += (s16)((Rand_Next() >> 0x17) + 0x900); - iceShardEffect->rotation.z += (s16)((Rand_Next() >> 0x17) + 0xB00); + iceShardEffect->rot.x += (s16)((Rand_Next() >> 0x17) + 0x700); + iceShardEffect->rot.y += (s16)((Rand_Next() >> 0x17) + 0x900); + iceShardEffect->rot.z += (s16)((Rand_Next() >> 0x17) + 0xB00); } } @@ -3143,9 +3143,9 @@ void EnBigslime_DrawShatteringEffects(EnBigslime* this, GlobalContext* globalCtx for (i = 0; i < BIGSLIME_NUM_ICE_SHARD; i++) { iceShardEffect = &this->iceShardEffect[i]; - if (iceShardEffect->isActive > false) { + if (iceShardEffect->isEnabled > false) { Matrix_SetTranslateRotateYXZ(iceShardEffect->pos.x, iceShardEffect->pos.y, iceShardEffect->pos.z, - &iceShardEffect->rotation); + &iceShardEffect->rot); Matrix_Scale(iceShardEffect->scale, iceShardEffect->scale, iceShardEffect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h index 579ec5d50..1005ccff5 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h @@ -42,9 +42,9 @@ typedef struct { typedef struct { /* 0x00 */ Vec3f pos; - /* 0x0C */ Vec3f vel; - /* 0x18 */ s16 isActive; - /* 0x1A */ Vec3s rotation; + /* 0x0C */ Vec3f velocity; + /* 0x18 */ s16 isEnabled; + /* 0x1A */ Vec3s rot; /* 0x20 */ f32 scale; } EnBigslimeIceShardEffect; // size = 0x24 diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index 9b089d836..dd20b9a25 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -114,7 +114,7 @@ static TexturePtr sWaterSplashTextures[] = { * Creates a debris effect. * Debris effects are spawned by an explosion. */ -void EnClearTag_CreateDebrisEffect(EnClearTag* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, +void EnClearTag_CreateDebrisEffect(EnClearTag* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, f32 rotationZ) { EnClearTagEffect* effect = this->effect; s16 i; @@ -124,9 +124,9 @@ void EnClearTag_CreateDebrisEffect(EnClearTag* this, Vec3f* position, Vec3f* vel if (effect->type == CLEAR_TAG_EFFECT_AVAILABLE) { effect->type = CLEAR_TAG_EFFECT_DEBRIS; - effect->position = *position; + effect->pos = *pos; effect->velocity = *velocity; - effect->acceleration = *acceleration; + effect->accel = *accel; effect->scale = scale; @@ -149,7 +149,7 @@ void EnClearTag_CreateDebrisEffect(EnClearTag* this, Vec3f* position, Vec3f* vel * Creates a smoke effect. * Smoke effects are spawned by an explosion. */ -void EnClearTag_CreateSmokeEffect(EnClearTag* this, Vec3f* position, f32 scale) { +void EnClearTag_CreateSmokeEffect(EnClearTag* this, Vec3f* pos, f32 scale) { s16 i; EnClearTagEffect* effect = this->effect; @@ -159,9 +159,9 @@ void EnClearTag_CreateSmokeEffect(EnClearTag* this, Vec3f* position, f32 scale) effect->actionTimer = Rand_ZeroFloat(100.0f); effect->type = CLEAR_TAG_EFFECT_SMOKE; - effect->position = *position; + effect->pos = *pos; effect->velocity = sZeroVector; - effect->acceleration = sZeroVector; + effect->accel = sZeroVector; effect->scale = scale; effect->maxScale = 2.0f * scale; @@ -185,7 +185,7 @@ void EnClearTag_CreateSmokeEffect(EnClearTag* this, Vec3f* position, f32 scale) * Creates an isolated smoke effect without an explosion. * Smoke effects are spawned directly. */ -void EnClearTag_CreateIsolatedSmokeEffect(EnClearTag* this, Vec3f* position, f32 scale) { +void EnClearTag_CreateIsolatedSmokeEffect(EnClearTag* this, Vec3f* pos, f32 scale) { s16 i; EnClearTagEffect* effect = this->effect; @@ -195,9 +195,9 @@ void EnClearTag_CreateIsolatedSmokeEffect(EnClearTag* this, Vec3f* position, f32 effect->actionTimer = Rand_ZeroFloat(100.0f); effect->type = CLEAR_TAG_EFFECT_ISOLATED_SMOKE; - effect->position = *position; + effect->pos = *pos; effect->velocity = sZeroVector; - effect->acceleration = sZeroVector; + effect->accel = sZeroVector; effect->scale = scale; effect->maxScale = 2.0f * scale; @@ -229,7 +229,7 @@ void EnClearTag_CreateIsolatedSmokeEffect(EnClearTag* this, Vec3f* position, f32 * Flash effects are spawned by an explosion or a pop. * Flash effects have two components: 1) a billboard flash, and 2) a light effect on the ground. */ -void EnClearTag_CreateFlashEffect(EnClearTag* this, Vec3f* position, f32 scale, f32 floorHeight) { +void EnClearTag_CreateFlashEffect(EnClearTag* this, Vec3f* pos, f32 scale, f32 floorHeight) { EnClearTagEffect* effect = this->effect; s16 i; @@ -238,9 +238,9 @@ void EnClearTag_CreateFlashEffect(EnClearTag* this, Vec3f* position, f32 scale, if (effect->type == CLEAR_TAG_EFFECT_AVAILABLE) { effect->type = CLEAR_TAG_EFFECT_FLASH; - effect->position = *position; + effect->pos = *pos; effect->velocity = sZeroVector; - effect->acceleration = sZeroVector; + effect->accel = sZeroVector; effect->scale = 0.0f; effect->maxScale = scale * 3.0f; @@ -259,7 +259,7 @@ void EnClearTag_CreateFlashEffect(EnClearTag* this, Vec3f* position, f32 scale, * Creates a light ray effect. * Light ray effects are spawned by an explosion or pop. */ -void EnClearTag_CreateLightRayEffect(EnClearTag* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, +void EnClearTag_CreateLightRayEffect(EnClearTag* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, f32 maxScaleTarget, s16 alphaDecrementSpeed) { EnClearTagEffect* effect = this->effect; s16 i; @@ -271,9 +271,9 @@ void EnClearTag_CreateLightRayEffect(EnClearTag* this, Vec3f* position, Vec3f* v effect->type = CLEAR_TAG_EFFECT_LIGHT_RAYS; - effect->position = *position; + effect->pos = *pos; effect->velocity = *velocity; - effect->acceleration = *acceleration; + effect->accel = *accel; effect->scale = scale / 1000.0f; effect->maxScale = 1.0f; @@ -303,8 +303,8 @@ void EnClearTag_CreateLightRayEffect(EnClearTag* this, Vec3f* position, Vec3f* v * Creates an isolated light ray effect without an explosion or pop. * Light ray effects are spawned directly. */ -void EnClearTag_CreateIsolatedLightRayEffect(EnClearTag* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, - f32 scale, f32 maxScaleTarget, s16 colorIndex, s16 alphaDecrementSpeed) { +void EnClearTag_CreateIsolatedLightRayEffect(EnClearTag* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, + f32 maxScaleTarget, s16 colorIndex, s16 alphaDecrementSpeed) { EnClearTagEffect* effect = this->effect; s16 i; @@ -313,9 +313,9 @@ void EnClearTag_CreateIsolatedLightRayEffect(EnClearTag* this, Vec3f* position, if (effect->type == CLEAR_TAG_EFFECT_AVAILABLE) { effect->type = CLEAR_TAG_EFFECT_LIGHT_RAYS; - effect->position = *position; + effect->pos = *pos; effect->velocity = *velocity; - effect->acceleration = *acceleration; + effect->accel = *accel; effect->scale = scale / 1000.0f; effect->maxScale = 1.0f; @@ -345,7 +345,7 @@ void EnClearTag_CreateIsolatedLightRayEffect(EnClearTag* this, Vec3f* position, * Creates a shockwave effect * This effect uses concentric ring floor shadows that travel radially outward along the floor poly */ -void EnClearTag_CreateShockwaveEffect(EnClearTag* this, Vec3f* position, f32 maxScale, s16 actionTimer) { +void EnClearTag_CreateShockwaveEffect(EnClearTag* this, Vec3f* pos, f32 maxScale, s16 actionTimer) { EnClearTagEffect* effect = this->effect; s16 i; @@ -354,9 +354,9 @@ void EnClearTag_CreateShockwaveEffect(EnClearTag* this, Vec3f* position, f32 max if (effect->type == CLEAR_TAG_EFFECT_AVAILABLE) { effect->type = CLEAR_TAG_EFFECT_SHOCKWAVE; - effect->position = *position; + effect->pos = *pos; effect->velocity = sZeroVector; - effect->acceleration = sZeroVector; + effect->accel = sZeroVector; effect->maxScale = maxScale; effect->scale = 0.0f; @@ -374,7 +374,7 @@ void EnClearTag_CreateShockwaveEffect(EnClearTag* this, Vec3f* position, f32 max * Creates a splash effect * This effect is used when EnClearTag is spawned above a waterbox */ -void EnClearTag_CreateSplashEffect(EnClearTag* this, Vec3f* position, s16 effectsTimer) { +void EnClearTag_CreateSplashEffect(EnClearTag* this, Vec3f* pos, s16 effectsTimer) { s16 i; EnClearTagEffect* effect = this->effect; @@ -385,9 +385,9 @@ void EnClearTag_CreateSplashEffect(EnClearTag* this, Vec3f* position, s16 effect effect->actionTimer = Rand_ZeroFloat(100.0f); effect->type = CLEAR_TAG_EFFECT_SPLASH; - effect->position = *position; + effect->pos = *pos; effect->velocity = sZeroVector; - effect->acceleration = sZeroVector; + effect->accel = sZeroVector; effect->scale = 0.0f; effect->maxScale = 0.0f; @@ -645,13 +645,13 @@ void EnClearTag_UpdateEffects(EnClearTag* this, GlobalContext* globalCtx) { effect->actionTimer++; // Perform effect physics. - effect->position.x += effect->velocity.x; - originalYPosition = effect->position.y; - effect->position.y += effect->velocity.y; - effect->position.z += effect->velocity.z; - effect->velocity.x += effect->acceleration.x; - effect->velocity.y += effect->acceleration.y; - effect->velocity.z += effect->acceleration.z; + effect->pos.x += effect->velocity.x; + originalYPosition = effect->pos.y; + effect->pos.y += effect->velocity.y; + effect->pos.z += effect->velocity.z; + effect->velocity.x += effect->accel.x; + effect->velocity.y += effect->accel.y; + effect->velocity.z += effect->accel.z; if (effect->type == CLEAR_TAG_EFFECT_DEBRIS) { // Clamp the velocity to -5.0 @@ -661,12 +661,12 @@ void EnClearTag_UpdateEffects(EnClearTag* this, GlobalContext* globalCtx) { // While the effect is falling check if it has hit the ground. if (effect->velocity.y < 0.0f) { - sphereCenter = effect->position; + sphereCenter = effect->pos; sphereCenter.y += 5.0f; // Check if the debris has hit the ground. if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &sphereCenter, 11.0f)) { - effect->position.y = originalYPosition; + effect->pos.y = originalYPosition; // Bounce the debris effect. if (effect->bounces <= 0) { @@ -675,14 +675,13 @@ void EnClearTag_UpdateEffects(EnClearTag* this, GlobalContext* globalCtx) { effect->effectsTimer = Rand_ZeroFloat(20.0f) + 25.0f; } else { // The Debris effect is done bouncing. Set its velocity and acceleration to 0. - effect->velocity.x = effect->velocity.z = effect->acceleration.y = effect->velocity.y = - 0.0f; + effect->velocity.x = effect->velocity.z = effect->accel.y = effect->velocity.y = 0.0f; } } } // Rotate the debris effect. - if (effect->acceleration.y != 0.0f) { + if (effect->accel.y != 0.0f) { effect->rotationY += 0.5f; effect->rotationX += 0.35f; } @@ -821,7 +820,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { } // Draw the debris effect. - Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); Matrix_RotateYF(effect->rotationY, MTXMODE_APPLY); Matrix_RotateXFApply(effect->rotationX); @@ -839,7 +838,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, (s8)effect->primColor.a); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)effect->primColor.a); - func_800C0094(this->actor.floorPoly, effect->position.x, effect->position.y, effect->position.z, &mtxF); + func_800C0094(this->actor.floorPoly, effect->pos.x, effect->pos.y, effect->pos.z, &mtxF); Matrix_Put(&mtxF); Matrix_Scale(effect->scale, 1.0f, effect->scale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -863,8 +862,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Draw the ground flash effect. gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (s8)(effect->primColor.a * 0.7f)); - func_800C0094(this->actor.floorPoly, effect->position.x, this->actor.floorHeight, effect->position.z, - &mtxF); + func_800C0094(this->actor.floorPoly, effect->pos.x, this->actor.floorHeight, effect->pos.z, &mtxF); Matrix_Put(&mtxF); Matrix_Scale(effect->scale * 3.0f, 1.0f, effect->scale * 3.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -893,7 +891,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gSPSegment( POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, -effect->actionTimer * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->smokeScaleX * effect->scale, effect->smokeScaleY * effect->scale, 1.0f, MTXMODE_APPLY); Matrix_Translate(0.0f, 20.0f, 0.0f, MTXMODE_APPLY); @@ -919,7 +917,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { gSPSegment( POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, -effect->actionTimer * 15, 32, 64, 1, 0, 0, 32, 32)); - Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(effect->scale, effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -941,7 +939,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Draw the flash billboard effect. gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (s8)effect->primColor.a); - Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(2.0f * effect->scale, 2.0f * effect->scale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -966,7 +964,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { // Draw the light ray effect. gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)effect->primColor.r, (u8)effect->primColor.g, (u8)effect->primColor.b, (u8)effect->primColor.a); - Matrix_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_RotateYF(effect->rotationY, MTXMODE_APPLY); Matrix_RotateXFApply(effect->rotationX); Matrix_RotateZF(effect->rotationZ, MTXMODE_APPLY); @@ -998,12 +996,12 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { * returns true if point is within the xz boundaries of an active water box, else false * `ySurface` returns the water box's surface, while `outWaterBox` returns a pointer to the WaterBox */ - ySurface = effect->position.y; - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, effect->position.x + vec.x, - effect->position.z + vec.z, &ySurface, &waterBox)) { - if ((effect->position.y - ySurface) < 200.0f) { + ySurface = effect->pos.y; + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, effect->pos.x + vec.x, effect->pos.z + vec.z, + &ySurface, &waterBox)) { + if ((effect->pos.y - ySurface) < 200.0f) { // Draw the splash effect. - Matrix_Translate(effect->position.x + vec.x, ySurface, effect->position.z + vec.z, MTXMODE_NEW); + Matrix_Translate(effect->pos.x + vec.x, ySurface, effect->pos.z + vec.z, MTXMODE_NEW); Matrix_RotateYF(2.0f * (j * M_PI) * (1.0f / 16.0f), MTXMODE_APPLY); Matrix_RotateXFApply(effect->rotationX); Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h index a2d188cba..c14cc36fd 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h @@ -8,9 +8,9 @@ struct EnClearTag; typedef struct EnClearTagEffect { /* 0x00 */ u8 type; /* 0x01 */ u8 actionTimer; - /* 0x04 */ Vec3f position; + /* 0x04 */ Vec3f pos; /* 0x10 */ Vec3f velocity; - /* 0x1C */ Vec3f acceleration; + /* 0x1C */ Vec3f accel; /* 0x28 */ Color_RGBAf primColor; /* 0x38 */ Color_RGBAf envColor; /* 0x48 */ s16 bounces; @@ -27,9 +27,11 @@ typedef struct EnClearTagEffect { /* 0x6C */ f32 smokeScaleX; } EnClearTagEffect; // size = 0x70 +#define EN_CLEAR_TAG_EFFECT_COUNT 103 + typedef struct EnClearTag { /* 0x0000 */ Actor actor; - /* 0x0144 */ EnClearTagEffect effect[103]; + /* 0x0144 */ EnClearTagEffect effect[EN_CLEAR_TAG_EFFECT_COUNT]; /* 0x2E54 */ u8 cameraState; /* 0x2E56 */ s16 activeTimer; // Actor Marked for Death when timer runs out /* 0x2E58 */ UNK_TYPE1 unk2E58[0xC]; diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c index 184a8b81b..9d7304ec4 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -33,28 +33,27 @@ const ActorInit En_Dai_InitVars = { static Vec3f D_80B3FBF0 = { 1.0f, 1.0f, 1.0f }; -EnDaiParticle* func_80B3DFF0(EnDaiParticle* particle, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, - s32 arg6) { +EnDaiEffect* func_80B3DFF0(EnDaiEffect* effect, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6) { s32 i; - for (i = 0; i < 32; i++, particle++) { - if (!particle->isEnabled) { - particle->isEnabled = true; - particle->unk_01 = (Rand_ZeroOne() * (2.0f * (arg6 / 3.0f))) + (arg6 / 3.0f); - particle->unk_02 = particle->unk_01; - particle->unk_10 = arg1; - particle->unk_1C = arg2; - particle->unk_28 = arg3; - particle->unk_34 = arg4; - particle->unk_38 = arg5; - return particle; + for (i = 0; i < EN_DAI_EFFECT_COUNT; i++, effect++) { + if (!effect->isEnabled) { + effect->isEnabled = true; + effect->unk_01 = (Rand_ZeroOne() * (2.0f * (arg6 / 3.0f))) + (arg6 / 3.0f); + effect->unk_02 = effect->unk_01; + effect->unk_10 = arg1; + effect->unk_1C = arg2; + effect->unk_28 = arg3; + effect->unk_34 = arg4; + effect->unk_38 = arg5; + return effect; } } return NULL; } -void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { +void func_80B3E168(EnDaiEffect* effect, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; s32 pad; s32 isDisplayListSet = false; @@ -65,8 +64,8 @@ void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { func_8012C2DC(globalCtx->state.gfxCtx); - for (i = 0; i < 32; i++, particle++) { - if (particle->isEnabled == true) { + for (i = 0; i < EN_DAI_EFFECT_COUNT; i++, effect++) { + if (effect->isEnabled == true) { gDPPipeSync(POLY_XLU_DISP++); if (!isDisplayListSet) { @@ -76,18 +75,18 @@ void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { Matrix_Push(); - alpha = (particle->unk_02 / (f32)particle->unk_01); + alpha = (effect->unk_02 / (f32)effect->unk_01); alpha *= 255.0f; gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (u8)alpha); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (particle->unk_02 + (i * 3)) * 3, - (particle->unk_02 + (i * 3)) * 15, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (effect->unk_02 + (i * 3)) * 3, + (effect->unk_02 + (i * 3)) * 15, 0x20, 0x40, 1, 0, 0, 0x20, 0x20)); - Matrix_Translate(particle->unk_10.x, particle->unk_10.y, particle->unk_10.z, MTXMODE_NEW); + Matrix_Translate(effect->unk_10.x, effect->unk_10.y, effect->unk_10.z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); - Matrix_Scale(particle->unk_34, particle->unk_34, 1.0f, MTXMODE_APPLY); + Matrix_Scale(effect->unk_34, effect->unk_34, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -101,23 +100,23 @@ void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { } s32 func_80B3E460(EnDai* this) { - EnDaiParticle* particle = &this->particles[0]; + EnDaiEffect* effect = this->effects; s32 i; s32 count; - for (i = 0, count = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isEnabled && particle->unk_02) { - particle->unk_10.x += particle->unk_28.x; - particle->unk_02--; - particle->unk_10.y += particle->unk_28.y; - particle->unk_10.z += particle->unk_28.z; - particle->unk_28.x += particle->unk_1C.x; - particle->unk_28.y += particle->unk_1C.y; - particle->unk_28.z += particle->unk_1C.z; - particle->unk_34 += particle->unk_38; + for (i = 0, count = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled && effect->unk_02) { + effect->unk_10.x += effect->unk_28.x; + effect->unk_02--; + effect->unk_10.y += effect->unk_28.y; + effect->unk_10.z += effect->unk_28.z; + effect->unk_28.x += effect->unk_1C.x; + effect->unk_28.y += effect->unk_1C.y; + effect->unk_28.z += effect->unk_1C.z; + effect->unk_34 += effect->unk_38; count++; - } else if (particle->isEnabled) { - particle->isEnabled = false; + } else if (effect->isEnabled) { + effect->isEnabled = false; } } @@ -125,7 +124,7 @@ s32 func_80B3E460(EnDai* this) { } s32 func_80B3E5B4(EnDai* this, GlobalContext* globalCtx) { - func_80B3E168(this->particles, globalCtx); + func_80B3E168(this->effects, globalCtx); return 0; } @@ -325,7 +324,7 @@ s32 func_80B3E96C(EnDai* this, GlobalContext* globalCtx) { sp5C.y = -40.0f; Lib_Vec3f_TranslateAndRotateY(&this->unk_1E4, this->unk_1D4, &sp50, &sp74); - func_80B3DFF0(this->particles, sp74, sp68, sp5C, 0.03f, 0.04f, 0x10); + func_80B3DFF0(this->effects, sp74, sp68, sp5C, 0.03f, 0.04f, 0x10); } return 0; diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.h b/src/overlays/actors/ovl_En_Dai/z_en_dai.h index 758cd1bc4..4c7e167b9 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.h +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.h @@ -7,7 +7,7 @@ struct EnDai; typedef void (*EnDaiActionFunc)(struct EnDai*, GlobalContext*); -typedef struct EnDaiParticle { +typedef struct EnDaiEffect { /* 0x00 */ u8 isEnabled; /* 0x01 */ u8 unk_01; /* 0x02 */ u8 unk_02; @@ -17,7 +17,9 @@ typedef struct EnDaiParticle { /* 0x28 */ Vec3f unk_28; /* 0x34 */ f32 unk_34; /* 0x38 */ f32 unk_38; -} EnDaiParticle; // size = 0x3C +} EnDaiEffect; // size = 0x3C + +#define EN_DAI_EFFECT_COUNT 32 typedef struct EnDai { /* 0x000 */ Actor actor; @@ -39,7 +41,7 @@ typedef struct EnDai { /* 0x1FC */ Vec3f unk_1FC; /* 0x208 */ Vec3s jointTable[19]; /* 0x27A */ Vec3s morphTable[19]; - /* 0x2EC */ EnDaiParticle particles[32]; + /* 0x2EC */ EnDaiEffect effects[EN_DAI_EFFECT_COUNT]; /* 0xA6C */ s32 unk_A6C; /* 0xA70 */ s32 unk_A70; } EnDai; // size = 0xA74 diff --git a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c index 167c11835..a8d4df8e6 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -493,19 +493,19 @@ void EnDaiku2_Draw(Actor* thisx, GlobalContext* globalCtx) { void func_80BE7504(EnDaiku2* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 arg4, s16 arg5) { s16 i; - EnDaiku2Particle* particle = &this->particles[0]; + EnDaiku2Effect* effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (!particle->isEnabled) { - particle->isEnabled = true; - particle->unk_04 = *arg1; - particle->unk_10 = *arg2; - particle->unk_1C = *arg3; - particle->unk_30 = arg4; - particle->unk_34 = arg5; - particle->unk_28.x = randPlusMinusPoint5Scaled(30000.0f); - particle->unk_28.y = randPlusMinusPoint5Scaled(30000.0f); - particle->unk_28.z = randPlusMinusPoint5Scaled(30000.0f); + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (!effect->isEnabled) { + effect->isEnabled = true; + effect->unk_04 = *arg1; + effect->unk_10 = *arg2; + effect->unk_1C = *arg3; + effect->unk_30 = arg4; + effect->unk_34 = arg5; + effect->unk_28.x = randPlusMinusPoint5Scaled(30000.0f); + effect->unk_28.y = randPlusMinusPoint5Scaled(30000.0f); + effect->unk_28.z = randPlusMinusPoint5Scaled(30000.0f); break; } } @@ -513,20 +513,20 @@ void func_80BE7504(EnDaiku2* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f32 ar void func_80BE7600(EnDaiku2* this, GlobalContext* globalCtx) { s32 i; - EnDaiku2Particle* particle = &this->particles[0]; + EnDaiku2Effect* effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isEnabled) { - particle->unk_04.x += particle->unk_10.x; - particle->unk_28.x += 0x100; - particle->unk_28.z += 0x130; - particle->unk_04.y += particle->unk_10.y; - particle->unk_04.z += particle->unk_10.z; - particle->unk_10.y += particle->unk_1C.y; - if (particle->unk_34 != 0) { - particle->unk_34 -= 1; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + effect->unk_04.x += effect->unk_10.x; + effect->unk_28.x += 0x100; + effect->unk_28.z += 0x130; + effect->unk_04.y += effect->unk_10.y; + effect->unk_04.z += effect->unk_10.z; + effect->unk_10.y += effect->unk_1C.y; + if (effect->unk_34 != 0) { + effect->unk_34 -= 1; } else { - particle->isEnabled = false; + effect->isEnabled = false; } } } @@ -535,7 +535,7 @@ void func_80BE7600(EnDaiku2* this, GlobalContext* globalCtx) { void func_80BE7718(EnDaiku2* this, GlobalContext* globalCtx) { s32 i; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - EnDaiku2Particle* particle = &this->particles[0]; + EnDaiku2Effect* effect = this->effects; s32 objectIdx; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -547,14 +547,14 @@ void func_80BE7718(EnDaiku2* this, GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[objectIdx].segment); - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isEnabled) { + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { Matrix_Push(); - Matrix_Translate(particle->unk_04.x, particle->unk_04.y, particle->unk_04.z, MTXMODE_NEW); - Matrix_RotateXS(particle->unk_28.x, MTXMODE_APPLY); - Matrix_RotateYS(particle->unk_28.y, MTXMODE_APPLY); - Matrix_RotateZS(particle->unk_28.z, MTXMODE_APPLY); - Matrix_Scale(particle->unk_30, particle->unk_30, particle->unk_30, MTXMODE_APPLY); + Matrix_Translate(effect->unk_04.x, effect->unk_04.y, effect->unk_04.z, MTXMODE_NEW); + Matrix_RotateXS(effect->unk_28.x, MTXMODE_APPLY); + Matrix_RotateYS(effect->unk_28.y, MTXMODE_APPLY); + Matrix_RotateZS(effect->unk_28.z, MTXMODE_APPLY); + Matrix_Scale(effect->unk_30, effect->unk_30, effect->unk_30, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_bombiwa_DL_0009E0); diff --git a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.h b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.h index 5baadf2f0..3a0cc5ca3 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.h +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.h @@ -17,7 +17,7 @@ enum { /* 127 */ ENDAIKU2_GET_7F_127 = 127, }; -typedef struct EnDaiku2Particle { +typedef struct EnDaiku2Effect { /* 0x00 */ u8 isEnabled; /* 0x04 */ Vec3f unk_04; /* 0x10 */ Vec3f unk_10; @@ -25,7 +25,9 @@ typedef struct EnDaiku2Particle { /* 0x28 */ Vec3s unk_28; /* 0x30 */ f32 unk_30; /* 0x34 */ s16 unk_34; -} EnDaiku2Particle; // size = 0x38 +} EnDaiku2Effect; // size = 0x38 + +#define EN_DAIKU2_EFFECT_COUNT 50 typedef struct EnDaiku2 { /* 0x000 */ Actor actor; @@ -47,7 +49,7 @@ typedef struct EnDaiku2 { /* 0x284 */ f32 unk_284; /* 0x288 */ s16 unk_288; /* 0x28A */ s16 unk_28A; - /* 0x28C */ EnDaiku2Particle particles[50]; + /* 0x28C */ EnDaiku2Effect effects[EN_DAIKU2_EFFECT_COUNT]; /* 0xD7C */ ColliderCylinder collider; } EnDaiku2; // size = 0xDC8 diff --git a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c index 914e0f355..50970a4be 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c @@ -33,50 +33,50 @@ const ActorInit En_Dnb_InitVars = { (ActorFunc)EnDnb_Draw, }; -void func_80A4FDD0(EnDnbParticle* particle, EnDnb* this, s16* alloc, s32 idx) { +void func_80A4FDD0(EnDnbEffect* effect, EnDnb* this, s16* alloc, s32 idx) { Vec3f sp1C; s32 idx2 = idx * 3; sp1C.x = alloc[idx2 + 0] + this->dyna.actor.world.pos.x; sp1C.y = alloc[idx2 + 1] + this->dyna.actor.world.pos.y; sp1C.z = alloc[idx2 + 2] + this->dyna.actor.world.pos.z; - particle->unk_00 = sp1C; - particle->unk_0C = sp1C; - particle->unk_24 = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &sp1C); - particle->unk_18 = gZeroVec3s; + effect->unk_00 = sp1C; + effect->unk_0C = sp1C; + effect->unk_24 = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &sp1C); + effect->unk_18 = gZeroVec3s; } -s32 func_80A4FEBC(EnDnbParticle* particle, f32 arg1) { +s32 func_80A4FEBC(EnDnbEffect* effect, f32 arg1) { s32 ret = false; - if ((DECR(particle->unk_26) == 0) && (arg1 < particle->unk_0C.y)) { - Math_ApproachF(&particle->unk_30, 1.0f, 0.4f, 1.0f); - particle->unk_2C += particle->unk_34; - particle->unk_0C.x += particle->unk_30 * Math_SinS(particle->unk_24); - particle->unk_0C.z += particle->unk_30 * Math_CosS(particle->unk_24); - particle->unk_0C.y += particle->unk_2C; - if (particle->unk_0C.y <= arg1) { - particle->unk_0C.y = arg1; + if ((DECR(effect->unk_26) == 0) && (arg1 < effect->unk_0C.y)) { + Math_ApproachF(&effect->unk_30, 1.0f, 0.4f, 1.0f); + effect->unk_2C += effect->unk_34; + effect->unk_0C.x += effect->unk_30 * Math_SinS(effect->unk_24); + effect->unk_0C.z += effect->unk_30 * Math_CosS(effect->unk_24); + effect->unk_0C.y += effect->unk_2C; + if (effect->unk_0C.y <= arg1) { + effect->unk_0C.y = arg1; } - particle->unk_18.x += particle->unk_1E.x; - particle->unk_18.y += particle->unk_1E.y; - particle->unk_18.z += particle->unk_1E.z; + effect->unk_18.x += effect->unk_1E.x; + effect->unk_18.y += effect->unk_1E.y; + effect->unk_18.z += effect->unk_1E.z; ret = true; } return ret; } -void func_80A4FFE8(EnDnbParticle* particle, s16 arg1) { - particle->unk_0C = particle->unk_00; - particle->unk_1E.x = (Rand_ZeroOne() - 0.5f) * 400.0f; - particle->unk_1E.y = (Rand_ZeroOne() - 0.5f) * 400.0f; - particle->unk_1E.z = (Rand_ZeroOne() - 0.5f) * 400.0f; - particle->unk_18 = gZeroVec3s; - particle->unk_30 = 40.0f; - particle->unk_2C = 0.0f; - particle->unk_26 = arg1; - particle->unk_34 = (Rand_ZeroOne() * -2.0f) - 2.0f; +void func_80A4FFE8(EnDnbEffect* effect, s16 arg1) { + effect->unk_0C = effect->unk_00; + effect->unk_1E.x = (Rand_ZeroOne() - 0.5f) * 400.0f; + effect->unk_1E.y = (Rand_ZeroOne() - 0.5f) * 400.0f; + effect->unk_1E.z = (Rand_ZeroOne() - 0.5f) * 400.0f; + effect->unk_18 = gZeroVec3s; + effect->unk_30 = 40.0f; + effect->unk_2C = 0.0f; + effect->unk_26 = arg1; + effect->unk_34 = (Rand_ZeroOne() * -2.0f) - 2.0f; } s32 func_80A500F8(EnDnb* this) { @@ -108,8 +108,8 @@ void EnDnb_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_hanareyama_obj_Colheader_004D8C); alloc = Lib_SegmentedToVirtual(object_hanareyama_obj_Vec_004710); - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - func_80A4FDD0(&this->particles[i], this, alloc, i); + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + func_80A4FDD0(&this->effects[i], this, alloc, i); } Actor_SetScale(&this->dyna.actor, 1.0f); @@ -126,8 +126,8 @@ void EnDnb_Update(Actor* thisx, GlobalContext* globalCtx) { s32 i; if (this->unk_0D30 == 0) { - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - func_80A4FFE8(&this->particles[i], ((53 - i) / 18) * 4); + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + func_80A4FFE8(&this->effects[i], ((53 - i) / 18) * 4); } for (i = 0; i < ARRAY_COUNT(this->unk_0D38); i++) { @@ -141,8 +141,8 @@ void EnDnb_Update(Actor* thisx, GlobalContext* globalCtx) { func_80A500F8(this); } - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { - func_80A4FEBC(&this->particles[i], this->dyna.actor.world.pos.y); + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + func_80A4FEBC(&this->effects[i], this->dyna.actor.world.pos.y); } this->unk_0D30--; @@ -158,13 +158,12 @@ void func_80A50510(EnDnb* this, GlobalContext* globalCtx) { func_8012C2DC(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { Matrix_Push(); - Matrix_Translate(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, this->particles[i].unk_0C.z, - MTXMODE_NEW); - Matrix_RotateXS(this->particles[i].unk_18.x, MTXMODE_APPLY); - Matrix_RotateYS(this->particles[i].unk_18.y, MTXMODE_APPLY); - Matrix_RotateZS(this->particles[i].unk_18.z, MTXMODE_APPLY); + Matrix_Translate(this->effects[i].unk_0C.x, this->effects[i].unk_0C.y, this->effects[i].unk_0C.z, MTXMODE_NEW); + Matrix_RotateXS(this->effects[i].unk_18.x, MTXMODE_APPLY); + Matrix_RotateYS(this->effects[i].unk_18.y, MTXMODE_APPLY); + Matrix_RotateZS(this->effects[i].unk_18.z, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gfx[i]); @@ -183,13 +182,12 @@ void func_80A5063C(EnDnb* this, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->particles); i++) { + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { Matrix_Push(); - Matrix_Translate(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, this->particles[i].unk_0C.z, - MTXMODE_NEW); - Matrix_RotateXS(this->particles[i].unk_18.x, MTXMODE_APPLY); - Matrix_RotateYS(this->particles[i].unk_18.y, MTXMODE_APPLY); - Matrix_RotateZS(this->particles[i].unk_18.z, MTXMODE_APPLY); + Matrix_Translate(this->effects[i].unk_0C.x, this->effects[i].unk_0C.y, this->effects[i].unk_0C.z, MTXMODE_NEW); + Matrix_RotateXS(this->effects[i].unk_18.x, MTXMODE_APPLY); + Matrix_RotateYS(this->effects[i].unk_18.y, MTXMODE_APPLY); + Matrix_RotateZS(this->effects[i].unk_18.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gfx[i]); diff --git a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.h b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.h index d5ec9554a..17ee19abe 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.h +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.h @@ -16,7 +16,7 @@ typedef struct { /* 0x2C */ f32 unk_2C; /* 0x30 */ f32 unk_30; /* 0x34 */ f32 unk_34; -} EnDnbParticle; // size = 0x38 +} EnDnbEffect; // size = 0x38 typedef struct { /* 0x00 */ u8 isEnabled; @@ -29,10 +29,12 @@ typedef struct { /* 0x24 */ f32 unk_24; } EnDnbUnkStruct; // size = 0x28 +#define EN_DNB_EFFECT_COUNT 54 + typedef struct EnDnb { /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ UNK_TYPE1 unk_015C[0x4]; - /* 0x0160 */ EnDnbParticle particles[54]; + /* 0x0160 */ EnDnbEffect effects[EN_DNB_EFFECT_COUNT]; /* 0x0D30 */ s16 unk_0D30; /* 0x0D32 */ s16 unk_0D32; /* 0x0D34 */ s16 unk_0D34; diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index ea7ee7aa4..62d33b0ea 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -21,9 +21,9 @@ void EnEncount2_Idle(EnEncount2* this, GlobalContext* globalCtx); void EnEncount2_Popped(EnEncount2* this, GlobalContext* globalCtx); void EnEncount2_Die(EnEncount2* this, GlobalContext* globalCtx); void EnEncount2_SetIdle(EnEncount2* this); -void EnEncount2_InitParticles(EnEncount2* this, Vec3f* pos, s16 fadeDelay); -void EnEncount2_UpdateParticles(EnEncount2* this, GlobalContext* globalCtx); -void EnEncount2_DrawParticles(EnEncount2* this, GlobalContext* globalCtx); +void EnEncount2_InitEffects(EnEncount2* this, Vec3f* pos, s16 fadeDelay); +void EnEncount2_UpdateEffects(EnEncount2* this, GlobalContext* globalCtx); +void EnEncount2_DrawEffects(EnEncount2* this, GlobalContext* globalCtx); const ActorInit En_Encount2_InitVars = { ACTOR_EN_ENCOUNT2, @@ -166,8 +166,8 @@ void EnEncount2_Popped(EnEncount2* this, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, curPos.x, curPos.y, curPos.z, 255, 255, 200, CLEAR_TAG_LARGE_EXPLOSION); - for (i = 0; i < ARRAY_COUNT(this->particles) / 2; ++i) { - EnEncount2_InitParticles(this, &curPos, 10); + for (i = 0; i < ARRAY_COUNT(this->effects) / 2; ++i) { + EnEncount2_InitEffects(this, &curPos, 10); } Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_MUJURA_BALLOON_BROKEN); @@ -195,7 +195,7 @@ void EnEncount2_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->dyna.actor, this->scale); this->actionFunc(this, globalCtx); Actor_MoveWithGravity(&this->dyna.actor); - EnEncount2_UpdateParticles(this, globalCtx); + EnEncount2_UpdateEffects(this, globalCtx); if (!this->isPopped) { Collider_UpdateSpheresElement(&this->collider, 0, &this->dyna.actor); @@ -210,16 +210,16 @@ void EnEncount2_Draw(Actor* thisx, GlobalContext* globalCtx) { Gfx_DrawDListOpa(globalCtx, object_fusen_DL_000A00); Gfx_DrawDListOpa(globalCtx, object_fusen_DL_000D78); } - EnEncount2_DrawParticles(this, globalCtx); + EnEncount2_DrawEffects(this, globalCtx); } -void EnEncount2_InitParticles(EnEncount2* this, Vec3f* pos, s16 fadeDelay) { +void EnEncount2_InitEffects(EnEncount2* this, Vec3f* pos, s16 fadeDelay) { s16 i; - EnEncount2Particle* sPtr = this->particles; + EnEncount2Effect* sPtr = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, sPtr++) { - if (!sPtr->enabled) { - sPtr->enabled = true; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, sPtr++) { + if (!sPtr->isEnabled) { + sPtr->isEnabled = true; sPtr->pos = *pos; sPtr->alphaFadeDelay = fadeDelay; sPtr->alpha = 0xFF; @@ -228,9 +228,9 @@ void EnEncount2_InitParticles(EnEncount2* this, Vec3f* pos, s16 fadeDelay) { sPtr->accel.y = (Rand_ZeroOne() - 0.5f) * 10.0f; sPtr->accel.z = (Rand_ZeroOne() - 0.5f) * 10.0f; - sPtr->vel.x = Rand_ZeroOne() - 0.5f; - sPtr->vel.y = Rand_ZeroOne() - 0.5f; - sPtr->vel.z = Rand_ZeroOne() - 0.5f; + sPtr->velocity.x = Rand_ZeroOne() - 0.5f; + sPtr->velocity.y = Rand_ZeroOne() - 0.5f; + sPtr->velocity.z = Rand_ZeroOne() - 0.5f; sPtr->scale = (Rand_ZeroFloat(1.0f) * 0.5f) + 2.0f; return; @@ -238,42 +238,42 @@ void EnEncount2_InitParticles(EnEncount2* this, Vec3f* pos, s16 fadeDelay) { } } -void EnEncount2_UpdateParticles(EnEncount2* this, GlobalContext* globalCtx) { +void EnEncount2_UpdateEffects(EnEncount2* this, GlobalContext* globalCtx) { s32 i; - EnEncount2Particle* sPtr = this->particles; + EnEncount2Effect* sPtr = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, sPtr++) { - if (sPtr->enabled) { - sPtr->pos.x += sPtr->vel.x; - sPtr->pos.y += sPtr->vel.y; - sPtr->pos.z += sPtr->vel.z; - sPtr->vel.x += sPtr->accel.x; - sPtr->vel.y += sPtr->accel.y; - sPtr->vel.z += sPtr->accel.z; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, sPtr++) { + if (sPtr->isEnabled) { + sPtr->pos.x += sPtr->velocity.x; + sPtr->pos.y += sPtr->velocity.y; + sPtr->pos.z += sPtr->velocity.z; + sPtr->velocity.x += sPtr->accel.x; + sPtr->velocity.y += sPtr->accel.y; + sPtr->velocity.z += sPtr->accel.z; if (sPtr->alphaFadeDelay != 0) { sPtr->alphaFadeDelay--; } else { sPtr->alpha -= 10; if (sPtr->alpha < 10) { - sPtr->enabled = 0; + sPtr->isEnabled = 0; } } } } } -void EnEncount2_DrawParticles(EnEncount2* this, GlobalContext* globalCtx) { +void EnEncount2_DrawEffects(EnEncount2* this, GlobalContext* globalCtx) { s16 i; - EnEncount2Particle* sPtr; + EnEncount2Effect* sPtr; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; OPEN_DISPS(gfxCtx); - sPtr = this->particles; + sPtr = this->effects; func_8012C28C(gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->particles); i++, sPtr++) { - if (sPtr->enabled) { + for (i = 0; i < ARRAY_COUNT(this->effects); i++, sPtr++) { + if (sPtr->isEnabled) { Matrix_Translate(sPtr->pos.x, sPtr->pos.y, sPtr->pos.z, MTXMODE_NEW); Matrix_Scale(sPtr->scale, sPtr->scale, sPtr->scale, MTXMODE_APPLY); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h index f2ce8832f..a95c1e014 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h @@ -7,16 +7,18 @@ struct EnEncount2; typedef void (*EnEncount2ActionFunc)(struct EnEncount2*, GlobalContext*); -typedef struct EnEncount2Particle{ - /* 0x00 */ u8 enabled; +typedef struct EnEncount2Effect{ + /* 0x00 */ u8 isEnabled; /* 0x04 */ Vec3f pos; /* 0x10 */ UNK_TYPE4 unk10; /* 0x14 */ s16 alpha; /* 0x16 */ s16 alphaFadeDelay; // frame count before alpha fade starts - /* 0x18 */ Vec3f vel; + /* 0x18 */ Vec3f velocity; /* 0x24 */ Vec3f accel; /* 0x30 */ f32 scale; -} EnEncount2Particle; // size = 0x34 +} EnEncount2Effect; // size = 0x34 + +#define EN_ENCOUNT2_EFFECT_COUNT 200 typedef struct EnEncount2 { /* 0x0000 */ DynaPolyActor dyna; @@ -28,7 +30,7 @@ typedef struct EnEncount2 { /* 0x016C */ f32 oscillationAngle; /* 0x0170 */ ColliderJntSph collider; /* 0x0190 */ ColliderJntSphElement colElement; - /* 0x01D0 */ EnEncount2Particle particles[200]; + /* 0x01D0 */ EnEncount2Effect effects[EN_ENCOUNT2_EFFECT_COUNT]; } EnEncount2; // size = 0x2A70 #define GET_ENCOUNT2_SWITCH_FLAG(actor) ((s16)(((Actor*)actor)->params & 0x7F)) diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.c b/src/overlays/actors/ovl_En_Fall/z_en_fall.c index b84eb3d74..d426b7c59 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -56,9 +56,11 @@ typedef struct { Vec3f pos; Vec3f velocity; Vec3s rot; -} EnFallDebrisParticle; +} EnFallDebrisEffect; -EnFallDebrisParticle debrisParticles[50]; +#define EN_FALL_DEBRIS_EFFECT_COUNT 50 + +EnFallDebrisEffect debrisEffects[EN_FALL_DEBRIS_EFFECT_COUNT]; const ActorInit En_Fall_InitVars = { ACTOR_EN_FALL, @@ -115,13 +117,13 @@ void EnFall_Moon_AdjustScaleAndPosition(EnFall* this, GlobalContext* globalCtx) } } -void EnFall_RisingDebris_ResetParticles(EnFall* this) { +void EnFall_RisingDebris_ResetEffects(EnFall* this) { s32 i; - for (i = 0; i < ARRAY_COUNT(debrisParticles); i++) { - debrisParticles[i].modelIndex = 3; + for (i = 0; i < ARRAY_COUNT(debrisEffects); i++) { + debrisEffects[i].modelIndex = 3; } - this->activeDebrisParticleCount = 0; + this->activeDebrisEffectCount = 0; } void EnFall_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -252,7 +254,7 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actor.update = EnFall_RisingDebris_Update; this->actor.draw = EnFall_RisingDebris_Draw; this->scale = 1.0f; - EnFall_RisingDebris_ResetParticles(this); + EnFall_RisingDebris_ResetEffects(this); Actor_SetScale(&this->actor, 1.0f); this->actor.shape.rot.x = 0; break; @@ -631,47 +633,47 @@ void EnFall_Fireball_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, this->scale * 1.74f); } -void EnFall_RisingDebris_UpdateParticles(EnFall* this) { +void EnFall_RisingDebris_UpdateEffects(EnFall* this) { s32 i; - for (i = 0; i < ARRAY_COUNT(debrisParticles); i++) { - if (debrisParticles[i].modelIndex < 3) { - debrisParticles[i].pos.x += debrisParticles[i].velocity.x; - debrisParticles[i].pos.y += debrisParticles[i].velocity.y; - debrisParticles[i].pos.z += debrisParticles[i].velocity.z; - debrisParticles[i].rot.x += 0x64; - debrisParticles[i].rot.y += 0xC8; - debrisParticles[i].rot.z += 0x12C; - if ((this->actor.world.pos.y + 3000.0f) < debrisParticles[i].pos.y) { - debrisParticles[i].modelIndex = 3; - this->activeDebrisParticleCount--; + for (i = 0; i < ARRAY_COUNT(debrisEffects); i++) { + if (debrisEffects[i].modelIndex < 3) { + debrisEffects[i].pos.x += debrisEffects[i].velocity.x; + debrisEffects[i].pos.y += debrisEffects[i].velocity.y; + debrisEffects[i].pos.z += debrisEffects[i].velocity.z; + debrisEffects[i].rot.x += 0x64; + debrisEffects[i].rot.y += 0xC8; + debrisEffects[i].rot.z += 0x12C; + if ((this->actor.world.pos.y + 3000.0f) < debrisEffects[i].pos.y) { + debrisEffects[i].modelIndex = 3; + this->activeDebrisEffectCount--; } } } } -s32 EnFall_RisingDebris_InitializeParticles(EnFall* this) { +s32 EnFall_RisingDebris_InitializeEffect(EnFall* this) { s16 angle; s32 i; f32 scale; - for (i = 0; i < ARRAY_COUNT(debrisParticles); i++) { - if (debrisParticles[i].modelIndex >= 3) { - debrisParticles[i].modelIndex = (s32)Rand_ZeroFloat(3.0f); - debrisParticles[i].pos.x = this->actor.world.pos.x; - debrisParticles[i].pos.y = this->actor.world.pos.y; - debrisParticles[i].pos.z = this->actor.world.pos.z; + for (i = 0; i < ARRAY_COUNT(debrisEffects); i++) { + if (debrisEffects[i].modelIndex >= 3) { + debrisEffects[i].modelIndex = (s32)Rand_ZeroFloat(3.0f); + debrisEffects[i].pos.x = this->actor.world.pos.x; + debrisEffects[i].pos.y = this->actor.world.pos.y; + debrisEffects[i].pos.z = this->actor.world.pos.z; angle = randPlusMinusPoint5Scaled(0x10000); scale = (1.0f - (Rand_ZeroFloat(1.0f) * Rand_ZeroFloat(1.0f))) * 3000.0f; - debrisParticles[i].pos.x += Math_SinS(angle) * scale; - debrisParticles[i].pos.z += Math_CosS(angle) * scale; - debrisParticles[i].velocity.x = 0.0f; - debrisParticles[i].velocity.z = 0.0f; - debrisParticles[i].velocity.y = 80.0f; - debrisParticles[i].rot.x = randPlusMinusPoint5Scaled(0x10000); - debrisParticles[i].rot.y = randPlusMinusPoint5Scaled(0x10000); - debrisParticles[i].rot.z = randPlusMinusPoint5Scaled(0x10000); - this->activeDebrisParticleCount++; + debrisEffects[i].pos.x += Math_SinS(angle) * scale; + debrisEffects[i].pos.z += Math_CosS(angle) * scale; + debrisEffects[i].velocity.x = 0.0f; + debrisEffects[i].velocity.z = 0.0f; + debrisEffects[i].velocity.y = 80.0f; + debrisEffects[i].rot.x = randPlusMinusPoint5Scaled(0x10000); + debrisEffects[i].rot.y = randPlusMinusPoint5Scaled(0x10000); + debrisEffects[i].rot.z = randPlusMinusPoint5Scaled(0x10000); + this->activeDebrisEffectCount++; return true; } } @@ -685,14 +687,14 @@ void EnFall_RisingDebris_Update(Actor* thisx, GlobalContext* globalCtx) { if (Cutscene_CheckActorAction(globalCtx, 451)) { if (Cutscene_CheckActorAction(globalCtx, 451) && globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 451)]->action == 2) { - EnFall_RisingDebris_UpdateParticles(this); - EnFall_RisingDebris_InitializeParticles(this); - } else if (this->activeDebrisParticleCount != 0) { - EnFall_RisingDebris_ResetParticles(this); + EnFall_RisingDebris_UpdateEffects(this); + EnFall_RisingDebris_InitializeEffect(this); + } else if (this->activeDebrisEffectCount != 0) { + EnFall_RisingDebris_ResetEffects(this); } } else if (thisx->home.rot.x != 0) { - EnFall_RisingDebris_UpdateParticles(this); - EnFall_RisingDebris_InitializeParticles(this); + EnFall_RisingDebris_UpdateEffects(this); + EnFall_RisingDebris_InitializeEffect(this); } } @@ -868,15 +870,14 @@ void EnFall_RisingDebris_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); - for (i = 0; i < ARRAY_COUNT(debrisParticles); i++) { - if (debrisParticles[i].modelIndex < 3) { - Matrix_Translate(debrisParticles[i].pos.x, debrisParticles[i].pos.y, debrisParticles[i].pos.z, MTXMODE_NEW); + for (i = 0; i < ARRAY_COUNT(debrisEffects); i++) { + if (debrisEffects[i].modelIndex < 3) { + Matrix_Translate(debrisEffects[i].pos.x, debrisEffects[i].pos.y, debrisEffects[i].pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_RotateZYX(debrisParticles[i].rot.x, debrisParticles[i].rot.y, debrisParticles[i].rot.z, - MTXMODE_APPLY); + Matrix_RotateZYX(debrisEffects[i].rot.x, debrisEffects[i].rot.y, debrisEffects[i].rot.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, sDebrisModelDLists[debrisParticles[i].modelIndex]); + gSPDisplayList(POLY_OPA_DISP++, sDebrisModelDLists[debrisEffects[i].modelIndex]); } } diff --git a/src/overlays/actors/ovl_En_Fall/z_en_fall.h b/src/overlays/actors/ovl_En_Fall/z_en_fall.h index 620c0590a..308b8ba9b 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.h +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.h @@ -40,7 +40,7 @@ typedef struct EnFall { /* 0x154 */ u16 flags; /* 0x158 */ union { s32 fireballAlpha; - s32 activeDebrisParticleCount; + s32 activeDebrisEffectCount; }; /* 0x15C */ union { s16 fireballYTexScroll1; diff --git a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c index 63da6c329..8feabc0c7 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -94,36 +94,36 @@ void func_80B21BE0(BossHakugin* parent, Vec3f* arg1, s32 arg2) { s32 i; for (i = 0; i < ARRAY_COUNT(parent->unk_9F8); i++) { - BossHakuginParticle* gohtParticle = &parent->unk_9F8[i]; - if (gohtParticle->unk_18 < 0) { + BossHakuginEffect* gohtEffect = &parent->unk_9F8[i]; + if (gohtEffect->unk_18 < 0) { s16 sp2E; s16 sp2C; f32 sp28; - Math_Vec3f_Copy(&gohtParticle->unk_0, arg1); + Math_Vec3f_Copy(&gohtEffect->unk_0, arg1); sp2C = Rand_S16Offset(0x1000, 0x3000); sp2E = Rand_Next() >> 0x10; sp28 = Rand_ZeroFloat(5.0f) + 10.0f; - gohtParticle->unk_C.x = (sp28 * Math_CosS(sp2C)) * Math_SinS(sp2E); - gohtParticle->unk_C.y = (Math_SinS(sp2C) * sp28); - gohtParticle->unk_C.z = (sp28 * Math_CosS(sp2C)) * Math_CosS(sp2E); + gohtEffect->unk_C.x = (sp28 * Math_CosS(sp2C)) * Math_SinS(sp2E); + gohtEffect->unk_C.y = (Math_SinS(sp2C) * sp28); + gohtEffect->unk_C.z = (sp28 * Math_CosS(sp2C)) * Math_CosS(sp2E); if ((arg2 == 1) || (arg2 == 3)) { - gohtParticle->unk_24 = ((Rand_ZeroFloat(5.0f) + 25.0f) * 0.0012f); - gohtParticle->unk_0.x = ((Rand_ZeroFloat(2.0f) + 9.0f) * gohtParticle->unk_C.x) + arg1->x; - gohtParticle->unk_0.y = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtParticle->unk_C.y) + arg1->y; - gohtParticle->unk_0.z = ((Rand_ZeroFloat(2.0f) + 9.0f) * gohtParticle->unk_C.z) + arg1->z; - gohtParticle->unk_1A = 1; + gohtEffect->unk_24 = ((Rand_ZeroFloat(5.0f) + 25.0f) * 0.0012f); + gohtEffect->unk_0.x = ((Rand_ZeroFloat(2.0f) + 9.0f) * gohtEffect->unk_C.x) + arg1->x; + gohtEffect->unk_0.y = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtEffect->unk_C.y) + arg1->y; + gohtEffect->unk_0.z = ((Rand_ZeroFloat(2.0f) + 9.0f) * gohtEffect->unk_C.z) + arg1->z; + gohtEffect->unk_1A = 1; } else { - gohtParticle->unk_24 = ((Rand_ZeroFloat(5.0f) + 18.0f) * 0.0001f); - gohtParticle->unk_0.x = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtParticle->unk_C.x) + arg1->x; - gohtParticle->unk_0.y = ((Rand_ZeroFloat(3.0f) + 1.0f) * gohtParticle->unk_C.y) + arg1->y; - gohtParticle->unk_0.z = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtParticle->unk_C.z) + arg1->z; - gohtParticle->unk_1A = 0; + gohtEffect->unk_24 = ((Rand_ZeroFloat(5.0f) + 18.0f) * 0.0001f); + gohtEffect->unk_0.x = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtEffect->unk_C.x) + arg1->x; + gohtEffect->unk_0.y = ((Rand_ZeroFloat(3.0f) + 1.0f) * gohtEffect->unk_C.y) + arg1->y; + gohtEffect->unk_0.z = ((Rand_ZeroFloat(2.0f) + 3.0f) * gohtEffect->unk_C.z) + arg1->z; + gohtEffect->unk_1A = 0; } - gohtParticle->unk_1C.x = (s32)Rand_Next() >> 0x10; - gohtParticle->unk_1C.y = (s32)Rand_Next() >> 0x10; - gohtParticle->unk_1C.z = (s32)Rand_Next() >> 0x10; - gohtParticle->unk_18 = 0x28; + gohtEffect->unk_1C.x = (s32)Rand_Next() >> 0x10; + gohtEffect->unk_1C.y = (s32)Rand_Next() >> 0x10; + gohtEffect->unk_1C.z = (s32)Rand_Next() >> 0x10; + gohtEffect->unk_18 = 0x28; return; } } diff --git a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c index 68f587ba3..2ffb3d0ba 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -185,18 +185,18 @@ void EnMinislime_AddIceShardEffect(EnMinislime* this) { for (; i < i_end; i++) { iceShardEffect = &bigslime->iceShardEffect[i]; vecSph.pitch = Rand_S16Offset(0x1000, 0x3000); - iceShardEffect->vel.x = Math_CosS(vecSph.pitch) * Math_SinS(vecSph.yaw); - iceShardEffect->vel.y = Math_SinS(vecSph.pitch); - iceShardEffect->vel.z = Math_CosS(vecSph.pitch) * Math_CosS(vecSph.yaw); - iceShardEffect->pos.x = this->actor.world.pos.x + (400.0f * this->actor.scale.x) * iceShardEffect->vel.x; + iceShardEffect->velocity.x = Math_CosS(vecSph.pitch) * Math_SinS(vecSph.yaw); + iceShardEffect->velocity.y = Math_SinS(vecSph.pitch); + iceShardEffect->velocity.z = Math_CosS(vecSph.pitch) * Math_CosS(vecSph.yaw); + iceShardEffect->pos.x = this->actor.world.pos.x + (400.0f * this->actor.scale.x) * iceShardEffect->velocity.x; iceShardEffect->pos.y = - this->actor.world.pos.y + (((iceShardEffect->vel.y * 2.0f) - 1.0f) * 400.0f * this->actor.scale.y); - iceShardEffect->pos.z = this->actor.world.pos.z + (400.0f * this->actor.scale.z) * iceShardEffect->vel.z; - iceShardEffect->rotation.x = (s32)Rand_Next() >> 0x10; - iceShardEffect->rotation.y = (s32)Rand_Next() >> 0x10; - iceShardEffect->rotation.z = (s32)Rand_Next() >> 0x10; - iceShardEffect->isActive = true; - Math_Vec3f_ScaleAndStore(&iceShardEffect->vel, Rand_ZeroFloat(3.0f) + 7.0f, &iceShardEffect->vel); + this->actor.world.pos.y + (((iceShardEffect->velocity.y * 2.0f) - 1.0f) * 400.0f * this->actor.scale.y); + iceShardEffect->pos.z = this->actor.world.pos.z + (400.0f * this->actor.scale.z) * iceShardEffect->velocity.z; + iceShardEffect->rot.x = (s32)Rand_Next() >> 0x10; + iceShardEffect->rot.y = (s32)Rand_Next() >> 0x10; + iceShardEffect->rot.z = (s32)Rand_Next() >> 0x10; + iceShardEffect->isEnabled = true; + Math_Vec3f_ScaleAndStore(&iceShardEffect->velocity, Rand_ZeroFloat(3.0f) + 7.0f, &iceShardEffect->velocity); iceShardEffect->scale = (Rand_ZeroFloat(6.0f) + 2.0f) * 0.001f; vecSph.yaw += 0x1999; } diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.c b/src/overlays/actors/ovl_En_Raf/z_en_raf.c index fb3b1070e..225feec70 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.c +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.c @@ -30,9 +30,9 @@ void EnRaf_SetupDissolve(EnRaf* this); void EnRaf_Dissolve(EnRaf* this, GlobalContext* globalCtx); void EnRaf_SetupDormant(EnRaf* this); void EnRaf_Dormant(EnRaf* this, GlobalContext* globalCtx); -void EnRaf_InitializeParticle(EnRaf* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, s16 timer); -void EnRaf_UpdateParticles(EnRaf* this, GlobalContext* globalCtx); -void EnRaf_DrawParticles(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_InitializeEffect(EnRaf* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, s16 timer); +void EnRaf_UpdateEffects(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_DrawEffects(EnRaf* this, GlobalContext* globalCtx); typedef enum { /* 0 */ EN_RAF_ANIMATION_IDLE, @@ -494,11 +494,11 @@ void EnRaf_Throw(EnRaf* this, GlobalContext* globalCtx) { } /** - * Creates an explosion effect/sound and spawns particles. + * Creates an explosion effect/sound and spawns effects. */ void EnRaf_Explode(EnRaf* this, GlobalContext* globalCtx) { Vec3f velocity = { 0.0f, 0.0f, 0.0f }; - Vec3f acceleration = { 0.0f, 0.0f, 0.0f }; + Vec3f accel = { 0.0f, 0.0f, 0.0f }; Vec3f explosionPos; s32 i; s32 pad; @@ -516,14 +516,14 @@ void EnRaf_Explode(EnRaf* this, GlobalContext* globalCtx) { this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_DEAD; for (i = 0; i < BREG(57) + 30; i++) { - acceleration.x = (Rand_ZeroOne() - 0.5f) * 0.5f; - acceleration.y = -0.3f; - acceleration.z = (Rand_ZeroOne() - 0.5f) * 0.5f; + accel.x = (Rand_ZeroOne() - 0.5f) * 0.5f; + accel.y = -0.3f; + accel.z = (Rand_ZeroOne() - 0.5f) * 0.5f; velocity.x = Rand_ZeroOne() - 0.5f; velocity.y = Rand_ZeroOne() * 10.0f; velocity.z = Rand_ZeroOne() - 0.5f; - EnRaf_InitializeParticle(this, &this->dyna.actor.world.pos, &velocity, &acceleration, - (Rand_ZeroFloat(1.0f) / 500.0f) + 0.002f, 90); + EnRaf_InitializeEffect(this, &this->dyna.actor.world.pos, &velocity, &accel, + (Rand_ZeroFloat(1.0f) / 500.0f) + 0.002f, 90); } for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; i++) { @@ -742,7 +742,7 @@ void EnRaf_Update(Actor* thisx, GlobalContext* globalCtx) { Math_ApproachZeroF(&this->heightDiffFromPlayer, 0.3f, 2.0f); if (this->action == EN_RAF_ACTION_EXPLODE) { - EnRaf_UpdateParticles(this, globalCtx); + EnRaf_UpdateEffects(this, globalCtx); } for (i = 0; i < ARRAY_COUNT(this->limbScale); i++) { @@ -875,84 +875,83 @@ void EnRaf_Draw(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.dListCount, NULL, NULL, EnRaf_TransformLimbDraw, &this->dyna.actor); if (this->action == EN_RAF_ACTION_EXPLODE) { - EnRaf_DrawParticles(this, globalCtx); + EnRaf_DrawEffects(this, globalCtx); } } -void EnRaf_InitializeParticle(EnRaf* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, - s16 timer) { +void EnRaf_InitializeEffect(EnRaf* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, s16 timer) { s16 i; - EnRafParticle* particle = this->particles; + EnRafEffect* effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (!particle->isVisible) { - particle->isVisible = true; - particle->position = *position; - particle->velocity = *velocity; - particle->acceleration = *acceleration; - particle->scale = scale; - particle->timer = timer; - particle->rotation.x = randPlusMinusPoint5Scaled(30000.0f); - particle->rotation.y = randPlusMinusPoint5Scaled(30000.0f); - particle->rotation.z = randPlusMinusPoint5Scaled(30000.0f); + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (!effect->isEnabled) { + effect->isEnabled = true; + effect->pos = *pos; + effect->velocity = *velocity; + effect->accel = *accel; + effect->scale = scale; + effect->timer = timer; + effect->rotation.x = randPlusMinusPoint5Scaled(30000.0f); + effect->rotation.y = randPlusMinusPoint5Scaled(30000.0f); + effect->rotation.z = randPlusMinusPoint5Scaled(30000.0f); return; } } } -void EnRaf_UpdateParticles(EnRaf* this, GlobalContext* globalCtx) { +void EnRaf_UpdateEffects(EnRaf* this, GlobalContext* globalCtx) { s32 i; - EnRafParticle* particle = this->particles; + EnRafEffect* effect = this->effects; - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isVisible) { - particle->position.x += particle->velocity.x; - particle->position.y += particle->velocity.y; - particle->position.z += particle->velocity.z; - particle->rotation.x += 0xBB8; - particle->rotation.y += 0xBB8; - particle->rotation.z += 0xBB8; - particle->velocity.x += particle->acceleration.x; - particle->velocity.y += particle->acceleration.y; - particle->velocity.z += particle->acceleration.z; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + effect->pos.x += effect->velocity.x; + effect->pos.y += effect->velocity.y; + effect->pos.z += effect->velocity.z; + effect->rotation.x += 0xBB8; + effect->rotation.y += 0xBB8; + effect->rotation.z += 0xBB8; + effect->velocity.x += effect->accel.x; + effect->velocity.y += effect->accel.y; + effect->velocity.z += effect->accel.z; if (this->mainType != EN_RAF_TYPE_NO_WATER_INTERACTIONS) { - if (particle->position.y < (this->dyna.actor.world.pos.y - 10.0f)) { - EffectSsGSplash_Spawn(globalCtx, &particle->position, NULL, NULL, 0, particle->scale * 200000.0f); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &particle->position, 50, NA_SE_EV_BOMB_DROP_WATER); - particle->isVisible = false; + if (effect->pos.y < (this->dyna.actor.world.pos.y - 10.0f)) { + EffectSsGSplash_Spawn(globalCtx, &effect->pos, NULL, NULL, 0, effect->scale * 200000.0f); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &effect->pos, 50, NA_SE_EV_BOMB_DROP_WATER); + effect->isEnabled = false; } - } else if (particle->position.y < (this->dyna.actor.world.pos.y - 10.0f)) { - Math_ApproachZeroF(&particle->scale, 0.2f, 0.001f); - if (particle->scale <= 0.0001f) { - particle->timer = 0; + } else if (effect->pos.y < (this->dyna.actor.world.pos.y - 10.0f)) { + Math_ApproachZeroF(&effect->scale, 0.2f, 0.001f); + if (effect->scale <= 0.0001f) { + effect->timer = 0; } } - if (particle->timer != 0) { - particle->timer--; + if (effect->timer != 0) { + effect->timer--; } else { - particle->isVisible = false; + effect->isEnabled = false; } } } } -void EnRaf_DrawParticles(EnRaf* this, GlobalContext* globalCtx) { +void EnRaf_DrawEffects(EnRaf* this, GlobalContext* globalCtx) { s16 i; - EnRafParticle* particle = this->particles; + EnRafEffect* effect = this->effects; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; OPEN_DISPS(gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->particles); i++, particle++) { - if (particle->isVisible) { - Matrix_Translate(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); - Matrix_Scale(particle->scale, particle->scale, particle->scale, MTXMODE_APPLY); - Matrix_RotateXS(particle->rotation.x, MTXMODE_APPLY); - Matrix_RotateYS(particle->rotation.y, MTXMODE_APPLY); - Matrix_RotateZS(particle->rotation.z, MTXMODE_APPLY); + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); + Matrix_RotateXS(effect->rotation.x, MTXMODE_APPLY); + Matrix_RotateYS(effect->rotation.y, MTXMODE_APPLY); + Matrix_RotateZS(effect->rotation.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gCarnivorousLilyPadParticleDL); diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.h b/src/overlays/actors/ovl_En_Raf/z_en_raf.h index f63924402..2fc92fb2b 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.h +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.h @@ -11,7 +11,7 @@ typedef enum { /* 0 */ EN_RAF_TYPE_NORMAL, /* 1 */ EN_RAF_TYPE_DORMANT, // Spawns without trap, so it can't eat bombs/player - /* 2 */ EN_RAF_TYPE_NO_WATER_INTERACTIONS // Won't produce ripples, and particles won't produce splashes + /* 2 */ EN_RAF_TYPE_NO_WATER_INTERACTIONS // Won't produce ripples, and effects won't produce splashes } EnRafType; struct EnRaf; @@ -19,14 +19,16 @@ struct EnRaf; typedef void (*EnRafActionFunc)(struct EnRaf*, GlobalContext*); typedef struct { - /* 0x00 */ u8 isVisible; - /* 0x04 */ Vec3f position; + /* 0x00 */ u8 isEnabled; + /* 0x04 */ Vec3f pos; /* 0x10 */ Vec3f velocity; - /* 0x1C */ Vec3f acceleration; + /* 0x1C */ Vec3f accel; /* 0x28 */ Vec3s rotation; /* 0x30 */ f32 scale; /* 0x34 */ s16 timer; -} EnRafParticle; // size = 0x38 +} EnRafEffect; // size = 0x38 + +#define EN_RAF_EFFECT_COUNT 31 typedef struct EnRaf { /* 0x000 */ DynaPolyActor dyna; @@ -59,7 +61,7 @@ typedef struct EnRaf { /* 0x3CC */ s16 petalClearPixelSecondPassIndex; /* 0x3CE */ s16 teethClearPixelSecondPassIndex; /* 0x3D0 */ ColliderCylinder collider; - /* 0x41C */ EnRafParticle particles[31]; + /* 0x41C */ EnRafEffect effects[EN_RAF_EFFECT_COUNT]; } EnRaf; // size = 0xAE4 extern const ActorInit En_Raf_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c index c90e5d8f8..832000b0c 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -66,7 +66,7 @@ static InitChainEntry sInitChain[] = { void ObjChan_InitChandelier(ObjChan* this2, GlobalContext* globalCtx); void ObjChan_InitPot(ObjChan* this, GlobalContext* globalCtx); -void ObjChan_CreateSmashParticles(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_CreateSmashEffects(ObjChan* this, GlobalContext* globalCtx); void ObjChan_DrawPot(Actor* thisx, GlobalContext* globalCtx); void ObjChan_DrawFire(ObjChan* this, GlobalContext* globalCtx); @@ -305,7 +305,7 @@ void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx) { } } if (potBreaks) { - ObjChan_CreateSmashParticles(this, globalCtx); + ObjChan_CreateSmashEffects(this, globalCtx); ((ObjChan*)this->actor.parent)->pots[this->myPotIndex] = NULL; SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_CHANDELIER_BROKEN); func_80BB9A1C((ObjChan*)this->actor.parent, 40.0f); @@ -321,7 +321,7 @@ void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx) { } } -void ObjChan_CreateSmashParticles(ObjChan* this, GlobalContext* globalCtx) { +void ObjChan_CreateSmashEffects(ObjChan* this, GlobalContext* globalCtx) { s16 new_var = 0; s32 phi_s0; Vec3f spDC; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 6c0b5d2d7..6477dd98c 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -6523,9 +6523,9 @@ 0x808E18A8:("EnEncount2_Die",), 0x808E18F8:("EnEncount2_Update",), 0x808E19C4:("EnEncount2_Draw",), - 0x808E1A24:("EnEncount2_InitParticles",), - 0x808E1B4C:("EnEncount2_UpdateParticles",), - 0x808E1C9C:("EnEncount2_DrawParticles",), + 0x808E1A24:("EnEncount2_InitEffects",), + 0x808E1B4C:("EnEncount2_UpdateEffects",), + 0x808E1C9C:("EnEncount2_DrawEffects",), 0x808E1FE0:("EnFireRock_Init",), 0x808E1FF0:("EnFireRock_Destroy",), 0x808E2000:("EnFireRock_Update",), @@ -9769,9 +9769,9 @@ 0x80A181B4:("EnRaf_Update",), 0x80A1859C:("EnRaf_TransformLimbDraw",), 0x80A18A08:("EnRaf_Draw",), - 0x80A18A90:("EnRaf_InitializeParticle",), - 0x80A18B8C:("EnRaf_UpdateParticles",), - 0x80A18DA0:("EnRaf_DrawParticles",), + 0x80A18A90:("EnRaf_InitializeEffect",), + 0x80A18B8C:("EnRaf_UpdateEffects",), + 0x80A18DA0:("EnRaf_DrawEffects",), 0x80A19740:("ObjFunen_Init",), 0x80A19778:("ObjFunen_Draw",), 0x80A19910:("ObjRaillift_UpdatePosition",), @@ -10308,9 +10308,9 @@ 0x80A3BC88:("EnBaguo_Update",), 0x80A3BE24:("EnBaguo_PostLimbDraw",), 0x80A3BE60:("EnBaguo_DrawBody",), - 0x80A3BF0C:("EnBaguo_InitializeParticle",), - 0x80A3C008:("EnBaguo_UpdateParticles",), - 0x80A3C17C:("EnBaguo_DrawRockParticles",), + 0x80A3BF0C:("EnBaguo_InitializeEffect",), + 0x80A3C008:("EnBaguo_UpdateEffects",), + 0x80A3C17C:("EnBaguo_DrawEffects",), 0x80A3C4E0:("func_80A3C4E0",), 0x80A3C560:("func_80A3C560",), 0x80A3C658:("func_80A3C658",), @@ -10908,7 +10908,7 @@ 0x80A6B3F8:("EnMushi2_Update",), 0x80A6B8D0:("EnMushi2_Draw",), 0x80A6BF90:("EnFall_Moon_AdjustScaleAndPosition",), - 0x80A6C1DC:("EnFall_RisingDebris_ResetParticles",), + 0x80A6C1DC:("EnFall_RisingDebris_ResetEffects",), 0x80A6C22C:("EnFall_Init",), 0x80A6C39C:("EnFall_Destroy",), 0x80A6C3AC:("EnFall_MoonsTear_GetTerminaFieldMoon",), @@ -10925,8 +10925,8 @@ 0x80A6D0DC:("EnFall_Update",), 0x80A6D100:("EnFall_FireBall_SetPerVertexAlpha",), 0x80A6D220:("EnFall_FireBall_Update",), - 0x80A6D444:("EnFall_RisingDebris_UpdateParticles",), - 0x80A6D504:("EnFall_RisingDebris_InitializeParticles",), + 0x80A6D444:("EnFall_RisingDebris_UpdateEffects",), + 0x80A6D504:("EnFall_RisingDebris_InitializeEffect",), 0x80A6D698:("EnFall_RisingDebris_Update",), 0x80A6D75C:("EnFall_FireRing_Update",), 0x80A6D88C:("EnFall_Moon_Draw",), @@ -13669,8 +13669,8 @@ 0x80B40100:("func_80B40100",), 0x80B40160:("func_80B40160",), 0x80B401F8:("func_80B401F8",), - 0x80B40308:("func_80B40308",), - 0x80B40394:("func_80B40394",), + 0x80B40308:("BgGoronOyu_UpdateWaterBoxInfo",), + 0x80B40394:("BgGoronOyu_SpawnEffects",), 0x80B4056C:("BgGoronOyu_Init",), 0x80B40628:("BgGoronOyu_Destroy",), 0x80B4065C:("BgGoronOyu_Update",), @@ -15380,7 +15380,7 @@ 0x80BB9F24:("ObjChan_ChandelierAction",), 0x80BBA2FC:("ObjChan_InitPot",), 0x80BBA314:("ObjChan_PotAction",), - 0x80BBA488:("ObjChan_CreateSmashParticles",), + 0x80BBA488:("ObjChan_CreateSmashEffects",), 0x80BBA738:("ObjChan_Update",), 0x80BBA78C:("ObjChan_Draw",), 0x80BBA894:("ObjChan_DrawPot",), From 37d3934e2c6866185b3ba76bad40224336a7a1f9 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 19 Jun 2022 17:16:30 -0700 Subject: [PATCH 257/257] Code_800E8EA0 Docs (#832) * Start * Add notes from OOT * D_801D0D50 -> gDbgCamEnabled * Rotation Functions * Text function * RotateBack -> RotateForward * Flags functions * Document rotation func returns * Remove comment from play * Rename play function, add notes about Flags, add notes about focus * Update notes a little * Update src/code/code_800E8EA0.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Fix apostrophes * Bring over OoT changes * TurnTo -> Track in SubS systesm * format and remove OoT specific comment * Remove old comments * namefixer Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --- docs/tutorial/documenting.md | 4 +- docs/tutorial/other_functions.md | 12 +- include/functions.h | 22 +-- include/variables.h | 2 +- include/z64subs.h | 22 +-- include/z_en_hy_code.h | 4 +- src/code/code_800E8EA0.c | 153 +++++++++++------- src/code/z_actor.c | 2 +- src/code/z_demo.c | 2 +- src/code/z_play.c | 6 +- src/code/z_sub_s.c | 49 +++--- src/overlays/actors/ovl_En_Ani/z_en_ani.c | 2 +- .../actors/ovl_En_Aob_01/z_en_aob_01.c | 16 +- .../actors/ovl_En_Aob_01/z_en_aob_01.h | 2 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 10 +- src/overlays/actors/ovl_En_Baba/z_en_baba.h | 2 +- .../actors/ovl_En_Bba_01/z_en_bba_01.c | 14 +- .../actors/ovl_En_Bji_01/z_en_bji_01.c | 6 +- .../actors/ovl_En_Cne_01/z_en_cne_01.c | 14 +- src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 2 +- src/overlays/actors/ovl_En_Gb2/z_en_gb2.c | 2 +- src/overlays/actors/ovl_En_Gg/z_en_gg.c | 2 +- src/overlays/actors/ovl_En_Gg2/z_en_gg2.c | 2 +- .../actors/ovl_En_Ginko_Man/z_en_ginko_man.c | 4 +- src/overlays/actors/ovl_En_Gk/z_en_gk.c | 2 +- src/overlays/actors/ovl_En_Hgo/z_en_hgo.c | 4 +- src/overlays/actors/ovl_En_Holl/z_en_holl.c | 2 +- src/overlays/actors/ovl_En_Hs/z_en_hs.c | 2 +- src/overlays/actors/ovl_En_In/z_en_in.c | 108 ++++++------- src/overlays/actors/ovl_En_In/z_en_in.h | 2 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 3 +- .../actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c | 2 +- .../actors/ovl_En_Kendo_Js/z_en_kendo_js.c | 2 +- src/overlays/actors/ovl_En_Kgy/z_en_kgy.c | 2 +- src/overlays/actors/ovl_En_Mk/z_en_mk.c | 2 +- src/overlays/actors/ovl_En_Mm3/z_en_mm3.c | 2 +- src/overlays/actors/ovl_En_Osn/z_en_osn.c | 2 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 2 +- .../actors/ovl_En_Pamera/z_en_pamera.c | 6 +- .../actors/ovl_En_Recepgirl/z_en_recepgirl.c | 2 +- src/overlays/actors/ovl_En_Rsn/z_en_rsn.c | 2 +- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 2 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 10 +- .../actors/ovl_En_Suttari/z_en_suttari.h | 2 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 2 +- .../ovl_En_Talk_Gibud/z_en_talk_gibud.c | 3 +- src/overlays/actors/ovl_En_Test4/z_en_test4.c | 2 +- src/overlays/actors/ovl_En_Tsn/z_en_tsn.c | 2 +- src/overlays/actors/ovl_En_Zo/z_en_zo.c | 10 +- src/overlays/actors/ovl_En_Zo/z_en_zo.h | 2 +- src/overlays/actors/ovl_En_Zob/z_en_zob.c | 2 +- src/overlays/actors/ovl_En_Zot/z_en_zot.c | 2 +- src/overlays/actors/ovl_En_Zov/z_en_zov.c | 2 +- tools/disasm/functions.txt | 26 +-- tools/disasm/variables.txt | 2 +- tools/namefixer.py | 4 + tools/sizes/code_functions.csv | 26 +-- 57 files changed, 323 insertions(+), 279 deletions(-) diff --git a/docs/tutorial/documenting.md b/docs/tutorial/documenting.md index 7e8435da9..e31a31969 100644 --- a/docs/tutorial/documenting.md +++ b/docs/tutorial/documenting.md @@ -216,7 +216,7 @@ void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) { Vec3s sp30; this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); func_80C100DC(this); } @@ -287,7 +287,7 @@ That's probably as much as we can do on functions for now. Next let's think abou - data/bss - intrafunction/stack variables -and this is roughly the order of preference for naming them (although not necessarily the logical order to determine what they do). This actor is quite limited in the last category: only `sp30` is unnamed at the moment. Even though `func_800E9250` is decomped, the purpose of the argument in which `sp30` is placed is not clear (and, indeed, is not named), so it's probably best to leave it unnamed for now. (With greater experience, you might analyse `func_800E9250` to work out what this argument is for, but let's not worry about that for now.) +and this is roughly the order of preference for naming them (although not necessarily the logical order to determine what they do). This actor is quite limited in the last category: only `sp30` is unnamed at the moment. Even though `Actor_TrackPlayer` is decomped, the purpose of the argument in which `sp30` is placed is not clear (and, indeed, is not named), so it's probably best to leave it unnamed for now. (With greater experience, you might analyse `Actor_TrackPlayer` to work out what this argument is for, but let's not worry about that for now.) As for the struct, there are two unnamed variables at the moment: ```C diff --git a/docs/tutorial/other_functions.md b/docs/tutorial/other_functions.md index 796939dd8..f9a189d6b 100644 --- a/docs/tutorial/other_functions.md +++ b/docs/tutorial/other_functions.md @@ -422,7 +422,7 @@ void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) { ? sp30; this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, (Actor *) this, this + 0x2AE, (Vec3s *) &sp30, (bitwise Vec3f) this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z); + Actor_TrackPlayer(globalCtx, (Actor *) this, this + 0x2AE, (Vec3s *) &sp30, (bitwise Vec3f) this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z); func_80C100DC(this); } ``` @@ -440,13 +440,13 @@ void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) { ? sp30; this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, this + 0x2AE, (Vec3s *) &sp30, (bitwise Vec3f) this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z); + Actor_TrackPlayer(globalCtx, &this->actor, this + 0x2AE, (Vec3s *) &sp30, (bitwise Vec3f) this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z); func_80C100DC(this); } ``` -Now, our problem is `func_800E9250`. The arguments all look terrible! Indeed, if we look at the actual function in `src/code/code_800E8EA0.c` (found by searching), we find that it should be +Now, our problem is `Actor_TrackPlayer`. The arguments all look terrible! Indeed, if we look at the actual function in `src/code/code_800E8EA0.c` (found by searching), we find that it should be ```C -s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5) +s32 Actor_TrackPlayer(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos) ``` So mips2c has made a bit of a mess here: - the third argument should be a `Vec3s`. Hence `this + 0x2AE` is a `Vec3s*`, and so `this->unk_2AE` is a `Vec3s` @@ -460,7 +460,7 @@ void EnRecepgirl_Update(EnRecepgirl *this, GlobalContext *globalCtx) { Vec3s sp30; this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); func_80C100DC(this); } ``` @@ -490,7 +490,7 @@ void EnRecepgirl_Update(Actor *thisx, GlobalContext *globalCtx) { Vec3s sp30; this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2AE, &sp30, this->actor.focus.pos); func_80C100DC(this); } ``` diff --git a/include/functions.h b/include/functions.h index 372f4d5fc..30453cf8d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1353,15 +1353,15 @@ void CollisionCheck_SpawnShieldParticlesMetalSound(GlobalContext* globalCtx, Vec void CollisionCheck_SpawnShieldParticlesMetal2(GlobalContext* globalCtx, Vec3f* v); void CollisionCheck_SpawnShieldParticlesWood(GlobalContext* globalCtx, Vec3f* v, Vec3f* pos); s32 CollisionCheck_CylSideVsLineSeg(f32 radius, f32 height, f32 offset, Vec3f* actorPos, Vec3f* itemPos, Vec3f* itemProjPos, Vec3f* out1, Vec3f* out2); -void func_800E8EA0(GlobalContext* globalCtx, Actor* actor, u16 textId); -s32 nop_800E8ED0(UNK_TYPE4 param_1); -void nop_800E8EE0(UNK_TYPE4 param_1); -s32 nop_800E8EEC(UNK_TYPE4 param_1); -void nop_800E8EFC(UNK_TYPE4 param_1); -s32 func_800E8F08(Vec3s* param_1, Vec3s* param_2); -s32 func_800E8FA4(Actor* actor, Vec3f* param_2, Vec3s* param_3, Vec3s* param_4); -s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, f32 param_5); -s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5); +void Actor_ContinueText(GlobalContext* globalCtx, Actor* actor, u16 textId); +s32 Flags_GetEventChkInf(s32 flag); +void Flags_SetEventChkInf(s32 flag); +s32 Flags_GetInfTable(s32 flag); +void Flags_SetInfTable(s32 flag); +s32 Actor_TrackNone(Vec3s* headRot, Vec3s* torsoRot); +s32 Actor_TrackPoint(Actor* actor, Vec3f* target, Vec3s* headRot, Vec3s* torsoRot); +s32 Actor_TrackPlayerSetFocusHeight(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, f32 focusPosYAdj); +s32 Actor_TrackPlayer(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos); void SaveContext_Init(void); void GameInfo_Init(void); // void DebugDisplay_Init(void); @@ -2392,8 +2392,8 @@ void func_8013A46C(s32 flag); u32 func_8013A4C4(s32 flag); s16 func_8013A504(s16 val); s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax, s16 angleError); - // void func_8013EC10(void); + void func_8013EC44(f32 a, u8 b, u8 c, u8 d); void func_8013ECE0(f32 xyzDistToPlayerSq, u8 arg1, u8 arg2, u8 arg3); void func_8013ED9C(void); @@ -2678,7 +2678,7 @@ s32 func_80169FFC(GameState* gameState); s32 FrameAdvance_IsEnabled(GameState* gameState); s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw); s32 Play_IsUnderwater(GlobalContext* globalCtx, Vec3f* pos); -s32 func_8016A168(void); +s32 Play_IsDebugCamEnabled(void); void Play_AssignPlayerActorCsIdsFromScene(GameState* gameState, s32 cutscene); void func_8016A268(GameState* gameState, s16 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5); void Play_Init(GameState* gameState); diff --git a/include/variables.h b/include/variables.h index 20b42dd71..cbe125ad5 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1503,7 +1503,7 @@ extern KaleidoMgrOverlay* gKaleidoMgrCurOvl; extern const TransitionInit TransitionFade_InitVars; // extern UNK_TYPE1 D_801D0D00; extern const TransitionInit TransitionCircle_InitVars; -extern UNK_TYPE4 D_801D0D50; +extern s32 gDbgCamEnabled; // extern UNK_TYPE1 D_801D0D54; // extern UNK_TYPE2 D_801D0D58; // extern UNK_TYPE2 D_801D0D5C; diff --git a/include/z64subs.h b/include/z64subs.h index b39842195..96e0366bf 100644 --- a/include/z64subs.h +++ b/include/z64subs.h @@ -25,19 +25,19 @@ typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); #define SUBS_SHADOW_TEX_HEIGHT 64 #define SUBS_SHADOW_TEX_SIZE ((s32)sizeof(u8[SUBS_SHADOW_TEX_HEIGHT][SUBS_SHADOW_TEX_WIDTH])) -typedef struct TurnOptions { +typedef struct TrackOptions { /* 0x0 */ u16 rotMax; // binary angles /* 0x2 */ u16 slowness; // larger for slower rotation, cannot be 0 /* 0x4 */ u16 rotStepMin; // degrees /* 0x6 */ u16 rotStepMax; // degrees -} TurnOptions; // size = 0x8 +} TrackOptions; // size = 0x8 -typedef struct TurnOptionsSet { - /* 0x00 */ TurnOptions headRotX; - /* 0x08 */ TurnOptions headRotY; - /* 0x10 */ TurnOptions torsoRotX; - /* 0x18 */ TurnOptions torsoRotY; -} TurnOptionsSet; // size = 0x20 +typedef struct TrackOptionsSet { + /* 0x00 */ TrackOptions headRotX; + /* 0x08 */ TrackOptions headRotY; + /* 0x10 */ TrackOptions torsoRotX; + /* 0x18 */ TrackOptions torsoRotY; +} TrackOptionsSet; // size = 0x20 #define ACTOR_PATHING_RETURN_TO_START (1 << 0) #define ACTOR_PATHING_SWITCH_DIRECTION (1 << 1) @@ -121,8 +121,8 @@ void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size); void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], s8 parentBodyParts[]); void SubS_DrawShadowTex(Actor* actor, struct GameState* gameState, u8* tex); -s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax); -s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, TurnOptionsSet* options); +s16 SubS_ComputeTrackPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax); +s32 SubS_TrackPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, TrackOptionsSet* options); s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); @@ -165,6 +165,6 @@ s32 func_8013E748(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f3 s32 SubS_ActorAndPlayerFaceEachOther(struct GlobalContext* globalCtx, Actor* actor, void* data); s32 func_8013E8F8(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, s16 actorYawTol); -s32 SubS_TurnToPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax); +s32 SubS_TrackPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax); #endif diff --git a/include/z_en_hy_code.h b/include/z_en_hy_code.h index a0f9bcdd4..7c67226cf 100644 --- a/include/z_en_hy_code.h +++ b/include/z_en_hy_code.h @@ -57,10 +57,10 @@ typedef struct EnHy { /* 0x205 */ u8 isRightFootOnGround; /* 0x206 */ Vec3s jointTable[ENHY_LIMB_MAX]; /* 0x266 */ Vec3s morphTable[ENHY_LIMB_MAX]; - /* 0x2C6 */ Vec3s turnTarget; + /* 0x2C6 */ Vec3s trackTarget; /* 0x2CC */ Vec3s headRot; /* 0x2D2 */ Vec3s torsoRot; - /* 0x2D8 */ Vec3s tmpTurnTarget; + /* 0x2D8 */ Vec3s tmptrackTarget; /* 0x2DE */ Vec3s tmpHeadRot; /* 0x2E4 */ Vec3s tmpTorsoRot; /* 0x2EA */ s16 limbRotTableY[16]; diff --git a/src/code/code_800E8EA0.c b/src/code/code_800E8EA0.c index d95f53269..6fb787451 100644 --- a/src/code/code_800E8EA0.c +++ b/src/code/code_800E8EA0.c @@ -1,107 +1,148 @@ #include "global.h" -void func_800E8EA0(GlobalContext* globalCtx, Actor* actor, u16 textId) { +void Actor_ContinueText(GlobalContext* globalCtx, Actor* actor, u16 textId) { func_80151938(globalCtx, textId); actor->textId = textId; } -s32 nop_800E8ED0(UNK_TYPE4 param_1) { - return 0; +/** + * EventCheckInf does not exist, so this always returns false + */ +s32 Flags_GetEventChkInf(s32 flag) { + return false; } -void nop_800E8EE0(UNK_TYPE4 param_1) { +/** + * EventCheckInf does not exist, so this does nothing + */ +void Flags_SetEventChkInf(s32 flag) { } -s32 nop_800E8EEC(UNK_TYPE4 param_1) { - return 0; +/** + * InfTable does not exist, so this always returns false + */ +s32 Flags_GetInfTable(s32 flag) { + return false; } -void nop_800E8EFC(UNK_TYPE4 param_1) { +/** + * InfTable does not exist, so this does nothing + */ +void Flags_SetInfTable(s32 flag) { } -s32 func_800E8F08(Vec3s* param_1, Vec3s* param_2) { - Math_SmoothStepToS(¶m_1->y, 0, 6, 6200, 100); - Math_SmoothStepToS(¶m_1->x, 0, 6, 6200, 100); - Math_SmoothStepToS(¶m_2->y, 0, 6, 6200, 100); - Math_SmoothStepToS(¶m_2->x, 0, 6, 6200, 100); - return 1; +s32 Actor_TrackNone(Vec3s* headRot, Vec3s* torsoRot) { + Math_SmoothStepToS(&headRot->y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&headRot->x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&torsoRot->y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&torsoRot->x, 0, 6, 0x1838, 0x64); + return true; } -s32 func_800E8FA4(Actor* actor, Vec3f* param_2, Vec3s* param_3, Vec3s* param_4) { +s32 Actor_TrackPoint(Actor* actor, Vec3f* target, Vec3s* headRot, Vec3s* torsoRot) { s16 targetPitch; s16 targetYaw; - s16 yawDiffFromTarget; + s16 yawDiff; - targetPitch = Math_Vec3f_Pitch(&actor->focus.pos, param_2); - targetYaw = Math_Vec3f_Yaw(&actor->focus.pos, param_2) - actor->world.rot.y; + targetPitch = Math_Vec3f_Pitch(&actor->focus.pos, target); + targetYaw = Math_Vec3f_Yaw(&actor->focus.pos, target) - actor->world.rot.y; - Math_SmoothStepToS(¶m_3->x, targetPitch, 6, 2000, 1); - param_3->x = CLAMP(param_3->x, -6000, 6000); + Math_SmoothStepToS(&headRot->x, targetPitch, 6, 0x7D0, 1); + headRot->x = CLAMP(headRot->x, -0x1770, 0x1770); - yawDiffFromTarget = Math_SmoothStepToS(¶m_3->y, targetYaw, 6, 2000, 1); - param_3->y = CLAMP(param_3->y, -8000, 8000); + yawDiff = Math_SmoothStepToS(&headRot->y, targetYaw, 6, 0x7D0, 1); + headRot->y = CLAMP(headRot->y, -0x1F40, 0x1F40); - if (yawDiffFromTarget != 0) { - if (ABS_ALT(param_3->y) < 8000) { - return 0; - } + if ((yawDiff != 0) && (ABS_ALT(headRot->y) < 0x1F40)) { + return false; } - Math_SmoothStepToS(¶m_4->y, targetYaw - param_3->y, 4, 2000, 1); - param_4->y = CLAMP(param_4->y, -12000, 12000); + Math_SmoothStepToS(&torsoRot->y, targetYaw - headRot->y, 4, 0x7D0, 1); + torsoRot->y = CLAMP(torsoRot->y, -0x2EE0, 0x2EE0); - return 1; + return true; } -s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, f32 param_5) { +/** + * Same as Actor_TrackPlayer, except use the actor's world position as the focus point, with the height + * specified. + * + * @param play + * @param actor + * @param headRot the computed actor's head's rotation step + * @param torsoRot the computed actor's torso's rotation step + * @param focusHeight the height of the focus point relative to their world position + * + * @return true if rotated towards player, false if rotations were stepped back to zero. + * + * @note same note as Actor_TrackPlayer + */ +s32 Actor_TrackPlayerSetFocusHeight(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, + f32 focusHeight) { Player* player = GET_PLAYER(globalCtx); - s16 sVar3; - Vec3f local_14; + s16 yaw; + Vec3f target; actor->focus.pos = actor->world.pos; - actor->focus.pos.y += param_5; + actor->focus.pos.y += focusHeight; - if (((globalCtx->csCtx).state == 0) && (D_801D0D50 == 0)) { - sVar3 = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); - if (sVar3 >= 0x4300) { - func_800E8F08(param_3, param_4); - return 0; + if (!((globalCtx->csCtx.state != 0) || gDbgCamEnabled)) { + yaw = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); + if (yaw >= 0x4300) { + Actor_TrackNone(headRot, torsoRot); + return false; } } - if (((globalCtx->csCtx).state != 0) || (D_801D0D50 != 0)) { - local_14 = globalCtx->view.eye; + if ((globalCtx->csCtx.state != 0) || gDbgCamEnabled) { + target = globalCtx->view.eye; } else { - local_14 = player->actor.focus.pos; + target = player->actor.focus.pos; } - func_800E8FA4(actor, &local_14, param_3, param_4); + Actor_TrackPoint(actor, &target, headRot, torsoRot); - return 1; + return true; } -s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5) { +/** + * Computes the necessary HeadRot and TorsoRot steps to be added to the normal rotation to smoothly turn an actors's + * head and torso towards the player if within a certain yaw, else smoothly returns the rotations back to zero. + * Also sets the focus position with the specified point. + * + * @param play + * @param actor + * @param headRot the computed actor's head's rotation step + * @param torsoRot the computed actor's torso's rotation step + * @param focusPos the point to set as the actor's focus position + * + * @return true if rotated towards player, false if rotations were stepped back to zero. + * + * @note if in a cutscene or debug camera is enabled, the computed rotation will instead turn towards the view eye no + * matter the yaw. + */ +s32 Actor_TrackPlayer(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos) { Player* player = GET_PLAYER(globalCtx); - s16 sVar3; - Vec3f local_14; + s16 yaw; + Vec3f target; - actor->focus.pos = param_5; + actor->focus.pos = focusPos; - if (((globalCtx->csCtx).state == 0) && (D_801D0D50 == 0)) { - sVar3 = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); - if (sVar3 >= 0x4300) { - func_800E8F08(param_3, param_4); - return 0; + if (!((globalCtx->csCtx.state != 0) || gDbgCamEnabled)) { + yaw = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); + if (yaw >= 0x4300) { + Actor_TrackNone(headRot, torsoRot); + return false; } } - if (((globalCtx->csCtx).state != 0) || (D_801D0D50 != 0)) { - local_14 = globalCtx->view.eye; + if ((globalCtx->csCtx.state != 0) || gDbgCamEnabled) { + target = globalCtx->view.eye; } else { - local_14 = player->actor.focus.pos; + target = player->actor.focus.pos; } - func_800E8FA4(actor, &local_14, param_3, param_4); + Actor_TrackPoint(actor, &target, headRot, torsoRot); - return 1; + return true; } diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 4e1e641de..ddc22949b 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -4281,7 +4281,7 @@ s16 func_800BDB6C(Actor* actor, GlobalContext* globalCtx, s16 arg2, f32 arg3) { Player* player = GET_PLAYER(globalCtx); f32 phi_f2; - if ((globalCtx->csCtx.state != 0) || (D_801D0D50 != 0)) { + if ((globalCtx->csCtx.state != 0) || gDbgCamEnabled) { phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &globalCtx->view.eye) * 0.25f; } else { phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &player->actor.world.pos); diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 01ed87e70..67a4d5608 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -917,7 +917,7 @@ s32 Cutscene_Command_Camera(GlobalContext* globalCtx, u8* cmd) { bcopy(cmd, &sp1C, sizeof(s32)); cmd += sizeof(s32); - if (func_8016A168() == 0) { + if (!Play_IsDebugCamEnabled()) { func_80161998(cmd, &sCutsceneCameraInfo); } return sp1C + sizeof(s32); diff --git a/src/code/z_play.c b/src/code/z_play.c index aa360934e..7d13ee8ee 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -309,10 +309,8 @@ s32 Play_IsUnderwater(GlobalContext* globalCtx, Vec3f* pos) { } } -// z_demo and EnTest4 -// This data appears to be a boolean. It is only set by Play_Init. -s32 func_8016A168(void) { - return D_801D0D50; +s32 Play_IsDebugCamEnabled(void) { + return gDbgCamEnabled; } // A mapping from playerActorCsIds to sGlobalCamDataSettings indices. diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index d5b4f33b2..4968185d0 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -1010,7 +1010,7 @@ void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex) { * @param[in] stepMin the minimun step in degrees * @param[in] stepMax the maximum step in degrees */ -s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax) { +s16 SubS_ComputeTrackPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax) { s16 prevRot = *rot; f32 step; f32 prevRotStep; @@ -1046,42 +1046,42 @@ s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f /** * Computes the necessary HeadRot and TorsoRot to smoothly turn an actors's head and torso to a point * - * @param[in] point the point to turn to + * @param[in] target the point to turn to * @param[in] focusPos the actor's focus postion * @param[in] shapeRot the actor's shape rotation - * @param[in,out] turnTarget the intermediate target step that headRot and torsoRot step towards + * @param[in,out] trackTarget the intermediate target step that headRot and torsoRot step towards * @param[in,out] headRot the computed head rotation * @param[in,out] torsoRot the computed torso rotation - * @param[in] options various options to adjust how the actor turns, see SubS_ComputeTurnToPointRot() + * @param[in] options various options to adjust how the actor turns, see SubS_ComputeTrackPointRot() */ -s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, - TurnOptionsSet* options) { +s32 SubS_TrackPoint(Vec3f* target, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* trackTarget, Vec3s* headRot, + Vec3s* torsoRot, TrackOptionsSet* options) { s16 pitch; s16 yaw; s16 pad; s16 targetY; - f32 diffX = point->x - focusPos->x; + f32 diffX = target->x - focusPos->x; s16 targetX; - f32 diffZ = point->z - focusPos->z; + f32 diffZ = target->z - focusPos->z; yaw = Math_FAtan2F(diffZ, diffX); - pitch = Math_FAtan2F(sqrtf(SQ(diffX) + SQ(diffZ)), point->y - focusPos->y); - Math_SmoothStepToS(&turnTarget->x, pitch, 4, 0x2710, 0); - Math_SmoothStepToS(&turnTarget->y, yaw, 4, 0x2710, 0); + pitch = Math_FAtan2F(sqrtf(SQ(diffX) + SQ(diffZ)), target->y - focusPos->y); + Math_SmoothStepToS(&trackTarget->x, pitch, 4, 0x2710, 0); + Math_SmoothStepToS(&trackTarget->y, yaw, 4, 0x2710, 0); targetX = - SubS_ComputeTurnToPointRot(&headRot->x, options->headRotX.rotMax, turnTarget->x, options->headRotX.slowness, - options->headRotX.rotStepMin, options->headRotX.rotStepMax); + SubS_ComputeTrackPointRot(&headRot->x, options->headRotX.rotMax, trackTarget->x, options->headRotX.slowness, + options->headRotX.rotStepMin, options->headRotX.rotStepMax); //! @bug: torsoRotX uses headRotX slowness - SubS_ComputeTurnToPointRot(&torsoRot->x, options->torsoRotX.rotMax, targetX, options->headRotX.slowness, - options->torsoRotX.rotStepMin, options->torsoRotX.rotStepMax); + SubS_ComputeTrackPointRot(&torsoRot->x, options->torsoRotX.rotMax, targetX, options->headRotX.slowness, + options->torsoRotX.rotStepMin, options->torsoRotX.rotStepMax); - targetY = turnTarget->y - shapeRot->y; - SubS_ComputeTurnToPointRot(&headRot->y, options->headRotY.rotMax, targetY - torsoRot->y, options->headRotY.slowness, - options->headRotY.rotStepMin, options->headRotY.rotStepMax); - SubS_ComputeTurnToPointRot(&torsoRot->y, options->torsoRotY.rotMax, targetY - headRot->y, - options->torsoRotY.slowness, options->torsoRotY.rotStepMin, - options->torsoRotY.rotStepMax); + targetY = trackTarget->y - shapeRot->y; + SubS_ComputeTrackPointRot(&headRot->y, options->headRotY.rotMax, targetY - torsoRot->y, options->headRotY.slowness, + options->headRotY.rotStepMin, options->headRotY.rotStepMax); + SubS_ComputeTrackPointRot(&torsoRot->y, options->torsoRotY.rotMax, targetY - headRot->y, + options->torsoRotY.slowness, options->torsoRotY.rotStepMin, + options->torsoRotY.rotStepMax); return true; } @@ -1438,7 +1438,6 @@ s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes) { * @param[out] plane the computed plane * * @note the unit input vector is expected to already be normalized (only uses are with the z unit vector) - * */ void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane) { f32 sin; @@ -1561,9 +1560,9 @@ s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRang * @param[in] torsoZRotStepMax the max torso's Z rotation step * @param[in] torsoXRotStepMax the max torso's X rotation step */ -s32 SubS_TurnToPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, - s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, - u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax) { +s32 SubS_TrackPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, + s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, + u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax) { s16 yaw = Math_Vec3f_Yaw(worldPos, yawTarget) - shapeYRot; s16 pad; s16 pad2; diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.c b/src/overlays/actors/ovl_En_Ani/z_en_ani.c index 098d91be4..2f03bec06 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -292,7 +292,7 @@ void EnAni_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); this->actionFunc(this, globalCtx); if (this->actor.xzDistToPlayer < 100.0f && !(this->stateFlags & ANI_STATE_CLIMBING)) { - func_800E9250(globalCtx, &this->actor, &this->headRot, &this->chestRot, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->headRot, &this->chestRot, this->actor.focus.pos); this->chestRot.x = this->chestRot.y = this->chestRot.z = 0; } else { Math_SmoothStepToS(&this->headRot.x, 0, 0x6, 0x1838, 0x64); diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index 1d74c45ae..3fc7566a5 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -462,7 +462,7 @@ void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { } void func_809C1EC8(EnAob01* this, GlobalContext* globalCtx) { - static TurnOptionsSet sTurnOptions = { + static TrackOptionsSet sTrackOptions = { { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 }, { 0xFA0, 4, 1, 3 }, @@ -476,11 +476,11 @@ void func_809C1EC8(EnAob01* this, GlobalContext* globalCtx) { point.x = player->actor.world.pos.x; point.y = player->bodyPartsPos[7].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, - &this->torsoRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); @@ -505,7 +505,7 @@ void func_809C2060(EnAob01* this, GlobalContext* globalCtx) { } } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_2D2 & 0x100)) { this->unk_2D2 &= ~0x100; - this->unk_2E6 = this->turnTarget; + this->unk_2E6 = this->trackTarget; this->unk_2EC = this->headRot; this->unk_2F2 = this->torsoRot; func_809C16DC(this, globalCtx); @@ -756,7 +756,7 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { } if (Actor_HasParent(&this->actor, globalCtx)) { - this->turnTarget = this->unk_2E6; + this->trackTarget = this->unk_2E6; this->headRot = this->unk_2EC; this->torsoRot = this->unk_2F2; this->actor.parent = NULL; @@ -827,7 +827,7 @@ void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, this->unk_210, &this->actor); this->actionFunc = func_809C2A64; } else { - this->turnTarget = this->unk_2E6; + this->trackTarget = this->unk_2E6; this->headRot = this->unk_2EC; this->torsoRot = this->unk_2F2; diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h index d4ed3e71e..3f8558744 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.h @@ -21,7 +21,7 @@ typedef struct EnAob01 { /* 0x212 */ Vec3s jointTable[MAMAMU_YAN_LIMB_MAX]; /* 0x272 */ Vec3s morphTable[MAMAMU_YAN_LIMB_MAX]; /* 0x2D2 */ u16 unk_2D2; - /* 0x2D4 */ Vec3s turnTarget; + /* 0x2D4 */ Vec3s trackTarget; /* 0x2DA */ Vec3s headRot; /* 0x2E0 */ Vec3s torsoRot; /* 0x2E6 */ Vec3s unk_2E6; diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index c10741fdf..b0c32be57 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -121,7 +121,7 @@ static u8 D_80BAA488[] = { s32 D_80BAA4A8[] = { -1, -1, 0 }; -static TurnOptionsSet sTurnOptions = { +static TrackOptionsSet sTrackOptions = { { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 }, { 0xFA0, 4, 1, 3 }, @@ -300,11 +300,11 @@ void func_80BA8DF4(EnBaba* this, GlobalContext* globalCtx) { point.y = player->bodyPartsPos[7].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, - &this->torsoRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.h b/src/overlays/actors/ovl_En_Baba/z_en_baba.h index 51a986bf0..f95020f95 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.h +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.h @@ -32,7 +32,7 @@ typedef struct EnBaba { /* 0x01EA */ UNK_TYPE1 unk1EA[0x1C]; /* 0x0206 */ Vec3s jointTable[18]; /* 0x0272 */ Vec3s morphTable[18]; - /* 0x02DE */ Vec3s turnTarget; + /* 0x02DE */ Vec3s trackTarget; /* 0x02E4 */ Vec3s headRot; /* 0x02EA */ Vec3s torsoRot; /* 0x02F0 */ UNK_TYPE1 unk2F0[0x12]; diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index f2c70dac8..2f932023a 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -97,7 +97,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0), }; -static TurnOptionsSet sTurnOptions = { +static TrackOptionsSet sTrackOptions = { { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 }, { 0xFA0, 4, 1, 3 }, @@ -113,11 +113,11 @@ void EnBba01_UpdateModel(EnBba01* this, GlobalContext* globalCtx) { point.x = player->actor.world.pos.x; point.y = player->bodyPartsPos[7].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.turnTarget, - &this->enHy.headRot, &this->enHy.torsoRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.trackTarget, + &this->enHy.headRot, &this->enHy.torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->enHy.turnTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->enHy.turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.trackTarget.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.headRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.headRot.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.torsoRot.x, 0, 4, 0x3E8, 1); @@ -134,7 +134,7 @@ s32 EnBba01_TestIsTalking(EnBba01* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->enHy.actor, &globalCtx->state)) { isTalking = true; this->enHy.textId = 0x10B9; // Invalid textId, produces empty textbox - this->enHy.tmpTurnTarget = this->enHy.turnTarget; + this->enHy.tmptrackTarget = this->enHy.trackTarget; this->enHy.tmpHeadRot = this->enHy.headRot; this->enHy.tmpTorsoRot = this->enHy.torsoRot; this->enHy.tmpActionFunc = this->enHy.actionFunc; @@ -197,7 +197,7 @@ void EnBba01_Talk(EnHy* this, GlobalContext* globalCtx) { break; case 2: this->actor.textId = 0; - this->turnTarget = this->tmpTurnTarget; + this->trackTarget = this->tmptrackTarget; this->headRot = this->tmpHeadRot; this->torsoRot = this->tmpTorsoRot; this->actor.shape.rot.y = this->actor.world.rot.y; diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index c60971034..3524343d8 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -78,9 +78,9 @@ void func_809CCDE0(EnBji01* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&pitchTarget, &player->actor.world.pos); pitchTarget.y = player->bodyPartsPos[7].y + 3.0f; - SubS_TurnToPointStep(&this->actor.world.pos, &this->actor.focus.pos, this->actor.shape.rot.y, - &player->actor.world.pos, &pitchTarget, &this->headZRotStep, &this->headXRotStep, - &this->torsoZRotStep, &this->torsoXRotStep, 0x1554, 0x1FFE, 0xE38, 0x1C70); + SubS_TrackPointStep(&this->actor.world.pos, &this->actor.focus.pos, this->actor.shape.rot.y, + &player->actor.world.pos, &pitchTarget, &this->headZRotStep, &this->headXRotStep, + &this->torsoZRotStep, &this->torsoXRotStep, 0x1554, 0x1FFE, 0xE38, 0x1C70); } void func_809CCE98(EnBji01* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index 1a35e8e50..3d96cd494 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -89,7 +89,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0), }; -static TurnOptionsSet sTurnOptions = { +static TrackOptionsSet sTrackOptions = { { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 }, { 0xFA0, 4, 1, 3 }, @@ -105,11 +105,11 @@ void EnCne01_UpdateModel(EnCne01* this, GlobalContext* globalCtx) { point.x = player->actor.world.pos.x; point.y = player->bodyPartsPos[7].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.turnTarget, - &this->enHy.headRot, &this->enHy.torsoRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.trackTarget, + &this->enHy.headRot, &this->enHy.torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->enHy.turnTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->enHy.turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.trackTarget.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.headRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.headRot.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->enHy.torsoRot.x, 0, 4, 0x3E8, 1); @@ -126,7 +126,7 @@ s32 EnCne01_TestIsTalking(EnCne01* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->enHy.actor, &globalCtx->state)) { isTalking = true; this->enHy.textId = 0x10B9; // Invalid textId, produces empty textbox - this->enHy.tmpTurnTarget = this->enHy.turnTarget; + this->enHy.tmptrackTarget = this->enHy.trackTarget; this->enHy.tmpHeadRot = this->enHy.headRot; this->enHy.tmpTorsoRot = this->enHy.torsoRot; this->enHy.tmpActionFunc = this->enHy.actionFunc; @@ -187,7 +187,7 @@ void EnCne01_Talk(EnHy* this, GlobalContext* globalCtx) { break; case 2: this->actor.textId = 0; - this->turnTarget = this->tmpTurnTarget; + this->trackTarget = this->tmptrackTarget; this->headRot = this->tmpHeadRot; this->torsoRot = this->tmpTorsoRot; this->actor.shape.rot.y = this->actor.world.rot.y; diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index 233c0fe61..8cd9d31b8 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -1449,7 +1449,7 @@ void EnFsn_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); Actor_MoveWithGravity(&this->actor); - func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unk27A, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->headRot, &this->unk27A, this->actor.focus.pos); SubS_FillLimbRotTables(globalCtx, this->limbRotYTable, this->limbRotZTable, ARRAY_COUNT(this->limbRotYTable)); EnFsn_Blink(this); if (ENFSN_IS_SHOP(&this->actor) && EnFsn_HasItemsToSell()) { 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 41783a1b7..2aadee0ca 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -974,7 +974,7 @@ void EnGb2_Update(Actor* thisx, GlobalContext* globalCtx) { if (!(this->unk_26C & 0x100)) { func_80B0F5E0(this, globalCtx); } - func_800E9250(globalCtx, &this->actor, &this->unk_270, &this->unk_276, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_270, &this->unk_276, this->actor.focus.pos); } s32 EnGb2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, 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 2683e1296..8aa0666d5 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -730,7 +730,7 @@ void EnGg_Update(Actor* thisx, GlobalContext* globalCtx) { } func_80B35634(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); func_80B351A4(this); } 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 46f0b657c..03f50e7aa 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -439,7 +439,7 @@ void EnGg2_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_MoveWithoutGravity(&this->actor); SkelAnime_Update(&this->skelAnime); func_80B3B8A4(this); - func_800E9250(globalCtx, &this->actor, &this->unk_1E0, &this->unk_1E6, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_1E0, &this->unk_1E6, this->actor.focus.pos); if ((this->unk_2EE == 5) || (this->unk_2EE == 7)) { func_800B9010(&this->actor, NA_SE_EN_SHARP_FLOAT - SFX_FLAG); 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 300987214..32b063b86 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 @@ -612,9 +612,9 @@ void EnGinkoMan_SwitchAnimation(EnGinkoMan* this, GlobalContext* globalCtx) { void EnGinkoMan_FacePlayer(EnGinkoMan* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (this->skelAnime.animation != &object_boj_Anim_004A7C) { - func_800E9250(globalCtx, &this->actor, &this->limb15Rot, &this->limb8Rot, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->limb15Rot, &this->limb8Rot, this->actor.focus.pos); } else { - func_800E8F08(&this->limb15Rot, &this->limb8Rot); + Actor_TrackNone(&this->limb15Rot, &this->limb8Rot); } } 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 ae9dd8553..ec367af9b 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -1082,7 +1082,7 @@ void EnGk_Update(Actor* thisx, GlobalContext* globalCtx) { ((ENGK_GET_F(&this->actor) == ENGK_F_0) && !(gSaveContext.save.weekEventReg[22] & 4))) { func_80B507A0(this, globalCtx); SkelAnime_Update(&this->skelAnime); - func_800E9250(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); if (ENGK_GET_F(&this->actor) == ENGK_F_1) { func_80B5123C(this, globalCtx); } 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 a16e0d94a..813800efb 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -315,7 +315,7 @@ s32 func_80BD0898(EnHgo* this, GlobalContext* globalCtx) { } void func_80BD0B8C(EnHgo* this, GlobalContext* globalCtx) { - func_800E9250(globalCtx, &this->actor, &this->unk_300, &this->unk_306, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_300, &this->unk_306, this->actor.focus.pos); if (this->unk_30E > 2) { this->unk_30E--; } else if (this->unk_30E == 2) { @@ -337,7 +337,7 @@ void EnHgo_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); SkelAnime_Update(&this->skelAnime); if (func_80BD0898(this, globalCtx)) { - func_800E8F08(&this->unk_300, &this->unk_306); + Actor_TrackNone(&this->unk_300, &this->unk_306); } else if (this->actionFunc != func_80BD0410) { if (this->actionFunc != func_80BD0434) { Collider_UpdateCylinder(&this->actor, &this->collider); diff --git a/src/overlays/actors/ovl_En_Holl/z_en_holl.c b/src/overlays/actors/ovl_En_Holl/z_en_holl.c index c3d577e7a..01db67792 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -218,7 +218,7 @@ void EnHoll_VisibleIdle(EnHoll* this, GlobalContext* globalCtx) { void EnHoll_TransparentIdle(EnHoll* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s32 useViewEye = D_801D0D50 || globalCtx->csCtx.state != 0; + s32 useViewEye = gDbgCamEnabled || globalCtx->csCtx.state != 0; Vec3f transformedPlayerPos; f32 enHollTop; f32 playerDistFromCentralPlane; 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 1e9fdfbf9..60eb90c50 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -297,7 +297,7 @@ void EnHs_Update(Actor* thisx, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->unusedRot.x, 0, 6, 0x1838, 0x64); Math_SmoothStepToS(&this->unusedRot.y, 0, 6, 0x1838, 0x64); } else if (this->stateFlags & 1) { - func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unusedRot, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->headRot, &this->unusedRot, this->actor.focus.pos); } else { Math_SmoothStepToS(&this->headRot.x, 0x3200, 6, 0x1838, 0x64); Math_SmoothStepToS(&this->headRot.y, 0, 6, 0x1838, 0x64); 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 ef4db6f9e..7d8848fd4 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -139,7 +139,7 @@ static AnimationInfoS sAnimations[] = { { &object_in_Anim_019EB4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, }; -static TurnOptionsSet sTurnOptions = { +static TrackOptionsSet sTrackOptions = { { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 }, { 0xFA0, 4, 1, 3 }, @@ -240,11 +240,11 @@ void func_808F3414(EnIn* this, GlobalContext* globalCtx) { point.x = player->actor.world.pos.x; point.y = player->bodyPartsPos[7].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, - &this->torsoRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); @@ -585,15 +585,15 @@ s32 func_808F4150(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext } else if (this->unk4AC & 8) { func_808F4108(this, globalCtx, 0x3475); } else { - func_800E8EA0(globalCtx, &this->actor, 0x3475); + Actor_ContinueText(globalCtx, &this->actor, 0x3475); } } else { play_sound(NA_SE_SY_ERROR); - func_800E8EA0(globalCtx, &this->actor, 0x3473); + Actor_ContinueText(globalCtx, &this->actor, 0x3473); } } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x3472); + Actor_ContinueText(globalCtx, &this->actor, 0x3472); } return 0; } @@ -608,13 +608,13 @@ s32 func_808F4270(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext func_801159EC(-fee); if (!(gSaveContext.save.weekEventReg[57] & 1)) { if (arg4 != 0) { - func_800E8EA0(globalCtx, &this->actor, 0x3474); + Actor_ContinueText(globalCtx, &this->actor, 0x3474); } else { func_808F4108(this, globalCtx, 0x3474); } } else { if (arg4 != 0) { - func_800E8EA0(globalCtx, &this->actor, 0x3475); + Actor_ContinueText(globalCtx, &this->actor, 0x3475); } else { func_808F4108(this, globalCtx, 0x3475); } @@ -622,14 +622,14 @@ s32 func_808F4270(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext } else { play_sound(NA_SE_SY_ERROR); if (arg4 != 0) { - func_800E8EA0(globalCtx, &this->actor, 0x3473); + Actor_ContinueText(globalCtx, &this->actor, 0x3473); } else { func_808F4108(this, globalCtx, 0x3473); } } } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x3472); + Actor_ContinueText(globalCtx, &this->actor, 0x3472); } return 0; } @@ -649,7 +649,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { switch (textId) { case 0x34AF: - func_800E8EA0(globalCtx, &this->actor, 0x34B0); + Actor_ContinueText(globalCtx, &this->actor, 0x34B0); ret = false; break; case 0x34A9: @@ -670,11 +670,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; break; case 0x34AD: - func_800E8EA0(globalCtx, &this->actor, 0x34AE); + Actor_ContinueText(globalCtx, &this->actor, 0x34AE); ret = false; break; case 0x34B1: - func_800E8EA0(globalCtx, &this->actor, 0x34B2); + Actor_ContinueText(globalCtx, &this->actor, 0x34B2); ret = false; break; default: @@ -686,11 +686,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { switch (textId) { case 0x3458: gSaveContext.save.weekEventReg[15] |= 8; - func_800E8EA0(globalCtx, &this->actor, 0x3459); + Actor_ContinueText(globalCtx, &this->actor, 0x3459); ret = false; break; case 0x3459: - func_800E8EA0(globalCtx, &this->actor, 0x345A); + Actor_ContinueText(globalCtx, &this->actor, 0x345A); ret = false; break; case 0x345A: @@ -702,15 +702,15 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = true; break; case 0x345C: - func_800E8EA0(globalCtx, &this->actor, 0x345D); + Actor_ContinueText(globalCtx, &this->actor, 0x345D); ret = false; break; case 0x345D: - func_800E8EA0(globalCtx, &this->actor, 0x345E); + Actor_ContinueText(globalCtx, &this->actor, 0x345E); ret = false; break; case 0x345E: - func_800E8EA0(globalCtx, &this->actor, 0x345F); + Actor_ContinueText(globalCtx, &this->actor, 0x345F); ret = false; break; case 0x345F: @@ -718,11 +718,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = true; break; case 0x3460: - func_800E8EA0(globalCtx, &this->actor, 0x3461); + Actor_ContinueText(globalCtx, &this->actor, 0x3461); ret = false; break; case 0x3461: - func_800E8EA0(globalCtx, &this->actor, 0x3462); + Actor_ContinueText(globalCtx, &this->actor, 0x3462); ret = false; break; case 0x3462: @@ -735,15 +735,15 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { switch (textId) { case 0x3463: gSaveContext.save.weekEventReg[15] |= 0x10; - func_800E8EA0(globalCtx, &this->actor, 0x3464); + Actor_ContinueText(globalCtx, &this->actor, 0x3464); ret = false; break; case 0x3464: - func_800E8EA0(globalCtx, &this->actor, 0x3465); + Actor_ContinueText(globalCtx, &this->actor, 0x3465); ret = false; break; case 0x3465: - func_800E8EA0(globalCtx, &this->actor, 0x3466); + Actor_ContinueText(globalCtx, &this->actor, 0x3466); ret = false; break; case 0x3466: @@ -756,17 +756,17 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_801159EC(-globalCtx->msgCtx.unk1206C); ret = true; } else { - func_800E8EA0(globalCtx, &this->actor, 0x3469); + Actor_ContinueText(globalCtx, &this->actor, 0x3469); ret = false; } } else { play_sound(NA_SE_SY_ERROR); - func_800E8EA0(globalCtx, &this->actor, 0x3468); + Actor_ContinueText(globalCtx, &this->actor, 0x3468); ret = false; } } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x3467); + Actor_ContinueText(globalCtx, &this->actor, 0x3467); ret = false; } break; @@ -777,11 +777,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = true; break; case 0x346B: - func_800E8EA0(globalCtx, &this->actor, 0x346C); + Actor_ContinueText(globalCtx, &this->actor, 0x346C); ret = false; break; case 0x346C: - func_800E8EA0(globalCtx, &this->actor, 0x3466); + Actor_ContinueText(globalCtx, &this->actor, 0x3466); ret = false; break; case 0x346A: @@ -797,11 +797,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; break; case 0x3470: - func_800E8EA0(globalCtx, &this->actor, 0x3471); + Actor_ContinueText(globalCtx, &this->actor, 0x3471); ret = false; break; case 0x3483: - func_800E8EA0(globalCtx, &this->actor, 0x3471); + Actor_ContinueText(globalCtx, &this->actor, 0x3471); ret = false; break; case 0x3471: @@ -872,7 +872,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; break; case 0x3476: - func_800E8EA0(globalCtx, &this->actor, 0x3477); + Actor_ContinueText(globalCtx, &this->actor, 0x3477); func_808F30B0(&this->skelAnime, 1); func_808F30B0(&this->unk4A4->skelAnime, 7); ret = false; @@ -886,7 +886,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_808F30B0(&this->skelAnime, 1); func_808F30B0(&this->unk4A4->skelAnime, 7); if (INV_CONTENT(ITEM_MASK_GARO) == ITEM_MASK_GARO) { - func_800E8EA0(globalCtx, &this->actor, 0x347E); + Actor_ContinueText(globalCtx, &this->actor, 0x347E); ret = false; } else { gSaveContext.save.weekEventReg[56] |= 8; @@ -901,12 +901,12 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); ret = true; } else { - func_800E8EA0(globalCtx, &this->actor, 0x347F); + Actor_ContinueText(globalCtx, &this->actor, 0x347F); ret = false; } break; case 0x347F: - func_800E8EA0(globalCtx, &this->actor, 0x3480); + Actor_ContinueText(globalCtx, &this->actor, 0x3480); ret = false; break; case 0x3480: @@ -944,12 +944,12 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 4: switch (textId) { case 0x3486: - func_800E8EA0(globalCtx, &this->actor, 0x3487); + Actor_ContinueText(globalCtx, &this->actor, 0x3487); gSaveContext.save.weekEventReg[16] |= 1; ret = false; break; case 0x3487: - func_800E8EA0(globalCtx, &this->actor, 0x3488); + Actor_ContinueText(globalCtx, &this->actor, 0x3488); ret = false; break; case 0x3488: @@ -963,11 +963,11 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_80151BB4(globalCtx, 0x11); break; case 0x348B: - func_800E8EA0(globalCtx, &this->actor, 0x348C); + Actor_ContinueText(globalCtx, &this->actor, 0x348C); ret = false; break; case 0x348C: - func_800E8EA0(globalCtx, &this->actor, 0x348D); + Actor_ContinueText(globalCtx, &this->actor, 0x348D); ret = false; break; case 0x348D: @@ -985,17 +985,17 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x348E: case 0x34B3: - func_800E8EA0(globalCtx, &this->actor, 0x348F); + Actor_ContinueText(globalCtx, &this->actor, 0x348F); gSaveContext.save.weekEventReg[16] |= 2; ret = false; break; case 0x3493: - func_800E8EA0(globalCtx, &this->actor, 0x3494); + Actor_ContinueText(globalCtx, &this->actor, 0x3494); ret = false; break; case 0x348F: case 0x3494: - func_800E8EA0(globalCtx, &this->actor, 0x3490); + Actor_ContinueText(globalCtx, &this->actor, 0x3490); ret = false; break; case 0x3490: @@ -1008,17 +1008,17 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_801159EC(-globalCtx->msgCtx.unk1206C); ret = true; } else { - func_800E8EA0(globalCtx, &this->actor, 0x3469); + Actor_ContinueText(globalCtx, &this->actor, 0x3469); ret = false; } } else { play_sound(NA_SE_SY_ERROR); - func_800E8EA0(globalCtx, &this->actor, 0x3468); + Actor_ContinueText(globalCtx, &this->actor, 0x3468); ret = false; } } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x3491); + Actor_ContinueText(globalCtx, &this->actor, 0x3491); ret = false; } break; @@ -1062,7 +1062,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_80151BB4(globalCtx, 0x11); break; case 0x3474: - func_800E8EA0(globalCtx, &this->actor, 0x3475); + Actor_ContinueText(globalCtx, &this->actor, 0x3475); ret = false; break; case 0x3475: @@ -1077,7 +1077,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_808F30B0(&this->skelAnime, 1); func_808F30B0(&this->unk4A4->skelAnime, 7); if (INV_CONTENT(ITEM_MASK_GARO) == ITEM_MASK_GARO) { - func_800E8EA0(globalCtx, &this->actor, 0x34A1); + Actor_ContinueText(globalCtx, &this->actor, 0x34A1); ret = false; } else { gSaveContext.save.weekEventReg[56] |= 8; @@ -1105,12 +1105,12 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { Actor_PickUp(&this->actor, globalCtx, GI_MILK, 500.0f, 100.0f); ret = true; } else { - func_800E8EA0(globalCtx, &this->actor, 0x34A2); + Actor_ContinueText(globalCtx, &this->actor, 0x34A2); ret = false; } break; case 0x34A2: - func_800E8EA0(globalCtx, &this->actor, 0x34A3); + Actor_ContinueText(globalCtx, &this->actor, 0x34A3); ret = false; break; case 0x34A3: @@ -1119,13 +1119,13 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = true; break; case 0x3499: - func_800E8EA0(globalCtx, &this->actor, 0x349A); + Actor_ContinueText(globalCtx, &this->actor, 0x349A); func_808F30B0(&this->skelAnime, 1); func_808F30B0(&this->unk4A4->skelAnime, 7); ret = false; break; case 0x349A: - func_800E8EA0(globalCtx, &this->actor, 0x349B); + Actor_ContinueText(globalCtx, &this->actor, 0x349B); ret = false; break; case 0x349B: @@ -1134,7 +1134,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; } else { func_8019F230(); - func_800E8EA0(globalCtx, &this->actor, 0x349C); + Actor_ContinueText(globalCtx, &this->actor, 0x349C); ret = false; } break; @@ -1154,7 +1154,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3498: case 0x34A6: - func_800E8EA0(globalCtx, &this->actor, 0x3471); + Actor_ContinueText(globalCtx, &this->actor, 0x3471); ret = false; break; case 0x3471: 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 ae339ecaa..e0667e0c2 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.h +++ b/src/overlays/actors/ovl_En_In/z_en_in.h @@ -36,7 +36,7 @@ typedef struct EnIn { /* 0x261 */ u8 unk261; /* 0x262 */ Vec3s jointTable[20]; /* 0x2DA */ Vec3s morphTable[20]; - /* 0x352 */ Vec3s turnTarget; + /* 0x352 */ Vec3s trackTarget; /* 0x358 */ Vec3s headRot; /* 0x35E */ Vec3s torsoRot; /* 0x364 */ char unk364[0x12]; 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 8f2408495..5c7d0d4fe 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -992,7 +992,8 @@ void EnJg_Update(Actor* thisx, GlobalContext* globalCtx) { EnJg_SpawnBreath(this, globalCtx); } - func_800E9250(globalCtx, &this->actor, &this->unusedRotation1, &this->unusedRotation2, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unusedRotation1, &this->unusedRotation2, + this->actor.focus.pos); } this->actionFunc(this, globalCtx); } 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 9e00b09e4..4d9f9b82f 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 @@ -586,7 +586,7 @@ void func_80C14D14(EnJgameTsn* this, GlobalContext* globalCtx) { } void func_80C14D58(EnJgameTsn* this, GlobalContext* globalCtx) { - func_800E9250(globalCtx, &this->actor, &this->unk_2EC, &this->unk_2F2, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2EC, &this->unk_2F2, this->actor.focus.pos); if (DECR(this->unk_2FA) == 0) { this->unk_2FA = Rand_S16Offset(60, 60); 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 5b32a556b..fac169b9d 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 @@ -741,7 +741,7 @@ void EnKendoJs_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); SkelAnime_Update(&this->skelAnime); - func_800E9250(globalCtx, &this->actor, &this->unk_278, &this->unk_27E, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_278, &this->unk_27E, this->actor.focus.pos); func_80B279AC(this, globalCtx); func_80B27880(this, globalCtx); } 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 cc184cfed..dec6be3f8 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -1090,7 +1090,7 @@ void EnKgy_Update(Actor* thisx, GlobalContext* globalCtx) { sp30.z = 0; sp30.y = 0; sp30.x = 0; - func_800E9250(globalCtx, &this->actor, &this->unk_2CC, &sp30, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2CC, &sp30, this->actor.focus.pos); } else { Math_SmoothStepToS(&this->unk_2CC.x, 0, 6, 6200, 100); Math_SmoothStepToS(&this->unk_2CC.y, 0, 6, 6200, 100); 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 b0e468ab2..0071673b4 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -451,7 +451,7 @@ void EnMk_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if ((this->unk_27A & 1) && !Cutscene_CheckActorAction(globalCtx, 0x7F)) { - func_800E9250(globalCtx, &this->actor, &this->unk_270, &sp38, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_270, &sp38, this->actor.focus.pos); } else { Math_SmoothStepToS(&this->unk_270.x, 0, 6, 0x1838, 0x64); Math_SmoothStepToS(&this->unk_270.y, 0, 6, 0x1838, 0x64); diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index 6ee806d2e..58f915f30 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -517,7 +517,7 @@ void EnMm3_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (this->unk_2B0 & 1) { - func_800E9250(globalCtx, &this->actor, &this->unk_2A0, &this->unk_2A6, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2A0, &this->unk_2A6, this->actor.focus.pos); } Collider_UpdateCylinder(&this->actor, &this->collider); diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.c b/src/overlays/actors/ovl_En_Osn/z_en_osn.c index 90cd6785f..a214bd72f 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -846,7 +846,7 @@ void EnOsn_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; } } - func_800E9250(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); } s32 EnOsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index be1def264..95c75b24b 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -1554,7 +1554,7 @@ void EnOssan_Update(Actor* thisx, GlobalContext* globalCtx) { EnOssan_UpdateItemSelectedProperty(this); EnOssan_UpdateStickDirectionPromptAnim(this); EnOssan_UpdateCursorAnim(this); - func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unk2CC, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->headRot, &this->unk2CC, this->actor.focus.pos); this->actionFunc(this, globalCtx); Actor_SetFocus(&this->actor, 90.0f); SkelAnime_Update(&this->skelAnime); diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index e17cba0e2..7ca549ca4 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -511,9 +511,9 @@ void func_80BD94E0(EnPamera* this, GlobalContext* globalCtx) { if ((this->actionFunc != func_80BD8B70) && (this->actionFunc != func_80BD8964) && (this->actionFunc != func_80BD909C) && (this->actionFunc != func_80BD8D1C) && ((this->actionFunc != func_80BD8DB0) || (this->actor.speedXZ == 3.0f))) { - func_800E9250(globalCtx, &this->actor, &this->limb9Rot, &this->limb8Rot, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->limb9Rot, &this->limb8Rot, this->actor.focus.pos); } else { - func_800E8F08(&this->limb9Rot, &this->limb8Rot); + Actor_TrackNone(&this->limb9Rot, &this->limb8Rot); } } @@ -856,7 +856,7 @@ void func_80BDA344(Actor* thisx, GlobalContext* globalCtx) { if (!(gSaveContext.save.weekEventReg[61] & 4)) { gSaveContext.save.weekEventReg[61] |= 4; } - func_800E8F08(&this->limb9Rot, &this->limb8Rot); + Actor_TrackNone(&this->limb9Rot, &this->limb8Rot); } else { func_80BD94E0(this, globalCtx); if (this->actionFunc == func_80BD994C) { diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c index 13ab86f52..94f697601 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -178,7 +178,7 @@ void EnRecepgirl_Update(Actor* thisx, GlobalContext* globalCtx) { Vec3s sp30; this->actionFunc(this, globalCtx); - func_800E9250(globalCtx, &this->actor, &this->headRot, &sp30, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->headRot, &sp30, this->actor.focus.pos); EnRecepgirl_UpdateEyes(this); } diff --git a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c index 2d8eaa643..3681deadd 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c @@ -61,7 +61,7 @@ void EnRsn_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); Actor_MoveWithGravity(&this->actor); SkelAnime_Update(&this->skelAnime); - func_800E9250(globalCtx, &this->actor, &this->unk1D8, &this->unk1DE, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk1D8, &this->unk1DE, this->actor.focus.pos); } s32 EnRsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index 6d89bef7b..58a4f1c59 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -635,7 +635,7 @@ void func_80B680A8(Actor* thisx, GlobalContext* globalCtx) { if (func_80B6703C(this, globalCtx) && !(this->unk_29C & 8) && (this->unk_29A != 5)) { sp38.x = sp38.y = sp38.z = 0; - func_800E9250(globalCtx, &this->actor, &this->unk_294, &sp38, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_294, &sp38, this->actor.focus.pos); } else { Math_SmoothStepToS(&this->unk_294.x, 0, 6, 6200, 100); Math_SmoothStepToS(&this->unk_294.y, 0, 6, 6200, 100); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 21b0dd9a2..6290bde81 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -120,7 +120,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xE), }; -static TurnOptionsSet sTurnOptions = { +static TrackOptionsSet sTrackOptions = { { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 }, { 0xFA0, 4, 1, 3 }, @@ -530,11 +530,11 @@ void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { point.x = player->actor.world.pos.x; point.y = player->bodyPartsPos[7].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, - &this->torsoRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h index 1fefc6f23..5418f182e 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h @@ -27,7 +27,7 @@ typedef struct EnSuttari { /* 0x1FC */ UNK_TYPE1 unk_1FC[0x1A]; /* 0x216 */ Vec3s jointTable[16]; /* 0x276 */ Vec3s morphTable[16]; - /* 0x2D6 */ Vec3s turnTarget; + /* 0x2D6 */ Vec3s trackTarget; /* 0x2DC */ Vec3s headRot; /* 0x2E2 */ Vec3s torsoRot; /* 0x2E8 */ UNK_TYPE1 unk_2E8[0x12]; diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 6ea613a6b..b5509e6c8 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -1225,7 +1225,7 @@ void EnSyatekiMan_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetFocus(&this->actor, 70.0f); if (this->unk_26A != 1) { SkelAnime_Update(&this->skelAnime); - func_800E9250(globalCtx, &this->actor, &this->unk_258, &this->unk_25E, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_258, &this->unk_25E, this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c index a52c9391d..9b78916c4 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c @@ -777,7 +777,8 @@ void EnTalkGibud_PassiveIdle(EnTalkGibud* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); EnTalkGibud_SetupTalk(this); } else if (this->actor.xzDistToPlayer < 100.0f && !(this->collider.base.acFlags & AC_HIT)) { - func_800E9250(globalCtx, &this->actor, &this->headRotation, &this->upperBodyRotation, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->headRotation, &this->upperBodyRotation, + this->actor.focus.pos); func_800B8614(&this->actor, globalCtx, 100.0f); } else { Math_SmoothStepToS(&this->headRotation.y, 0, 1, 100, 0); diff --git a/src/overlays/actors/ovl_En_Test4/z_en_test4.c b/src/overlays/actors/ovl_En_Test4/z_en_test4.c index 729a82a70..bfe6a5b55 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -370,7 +370,7 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if ((globalCtx->unk_18B4A == 0) && !Play_InCsMode(globalCtx) && (globalCtx->numSetupActors <= 0) && - (globalCtx->roomCtx.unk31 == 0) && (func_8016A168() == 0)) { + (globalCtx->roomCtx.unk31 == 0) && (!Play_IsDebugCamEnabled())) { s16 temp_a2; u16 temp_a0 = D_80A43364[this->unk_144]; s16 temp_a3; diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c index 1a357dcd8..02023b4ef 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c @@ -568,7 +568,7 @@ void EnTsn_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (this->unk_220 & 1) { - func_800E9250(globalCtx, &this->actor, &this->unk_222, &this->unk_228, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_222, &this->unk_228, this->actor.focus.pos); } else { Math_SmoothStepToS(&this->unk_222.x, 0, 6, 0x1838, 0x64); Math_SmoothStepToS(&this->unk_222.y, 0, 6, 0x1838, 0x64); diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 28c493497..31fb3a853 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -173,7 +173,7 @@ void EnZo_UpdateCollider(EnZo* this, GlobalContext* globalCtx) { } void EnZo_LookAtPlayer(EnZo* this, GlobalContext* globalCtx) { - static TurnOptionsSet sTurnOptions = { + static TrackOptionsSet sTrackOptions = { { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 }, { 0xFA0, 4, 1, 3 }, @@ -187,11 +187,11 @@ void EnZo_LookAtPlayer(EnZo* this, GlobalContext* globalCtx) { point.x = player->actor.world.pos.x; point.y = player->bodyPartsPos[7].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, - &this->upperBodyRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->upperBodyRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->trackTarget.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->trackTarget.y, 0, 4, 1000, 1); Math_SmoothStepToS(&this->headRot.x, 0, 4, 1000, 1); Math_SmoothStepToS(&this->headRot.y, 0, 4, 1000, 1); diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.h b/src/overlays/actors/ovl_En_Zo/z_en_zo.h index adf8b6bae..fcc753ba5 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.h +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.h @@ -25,7 +25,7 @@ typedef struct EnZo { /* 0x01FD */ u8 isRightFootGrounded; /* 0x01FE */ Vec3s jointTable[ZORA_LIMB_MAX]; /* 0x0276 */ Vec3s morphTable[ZORA_LIMB_MAX]; - /* 0x02EE */ Vec3s turnTarget; + /* 0x02EE */ Vec3s trackTarget; /* 0x02F4 */ Vec3s headRot; /* 0x02FA */ Vec3s upperBodyRot; /* 0x0300 */ UNK_TYPE1 unk_300[0x12]; diff --git a/src/overlays/actors/ovl_En_Zob/z_en_zob.c b/src/overlays/actors/ovl_En_Zob/z_en_zob.c index 24b03ab5f..33e26e7e5 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.c +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.c @@ -726,7 +726,7 @@ void EnZob_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->unk_2F4 & 1) { - func_800E9250(globalCtx, &this->actor, &this->unk_2F6, &this->unk_2FC, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2F6, &this->unk_2FC, this->actor.focus.pos); } else { Math_SmoothStepToS(&this->unk_2F6.x, 0, 6, 6200, 100); Math_SmoothStepToS(&this->unk_2F6.y, 0, 6, 6200, 100); diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index 69deb43d6..ca197eb12 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -1324,7 +1324,7 @@ void EnZot_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if (!(this->unk_2F2 & 8)) { if (!(this->unk_2F2 & 4) && func_80B96DF0(this, globalCtx)) { - func_800E9250(globalCtx, &this->actor, &this->unk_2C4, &this->unk_2CA, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2C4, &this->unk_2CA, this->actor.focus.pos); } else { Math_SmoothStepToS(&this->unk_2C4.x, 0, 6, 6200, 100); Math_SmoothStepToS(&this->unk_2C4.y, 0, 6, 6200, 100); diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.c b/src/overlays/actors/ovl_En_Zov/z_en_zov.c index 4bb5f2a5a..5979178f1 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.c +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.c @@ -482,7 +482,7 @@ void EnZov_Update(Actor* thisx, GlobalContext* globalCtx) { } if ((this->unk_320 & 1) && func_80BD15A4(this, globalCtx)) { - func_800E9250(globalCtx, &this->actor, &this->unk_2F0, &this->unk_2F6, this->actor.focus.pos); + Actor_TrackPlayer(globalCtx, &this->actor, &this->unk_2F0, &this->unk_2F6, this->actor.focus.pos); } else { if ((this->unk_320 & 0x10) && (this->unk_322 == 0)) { Math_SmoothStepToS(&this->unk_2F0.x, -0x1B58, 6, 0x1838, 0x64); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 6477dd98c..997a062fe 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1509,15 +1509,15 @@ 0x800E86C0:("CollisionCheck_SpawnShieldParticlesMetal2",), 0x800E86E0:("CollisionCheck_SpawnShieldParticlesWood",), 0x800E8784:("CollisionCheck_CylSideVsLineSeg",), - 0x800E8EA0:("func_800E8EA0",), - 0x800E8ED0:("nop_800E8ED0",), - 0x800E8EE0:("nop_800E8EE0",), - 0x800E8EEC:("nop_800E8EEC",), - 0x800E8EFC:("nop_800E8EFC",), - 0x800E8F08:("func_800E8F08",), - 0x800E8FA4:("func_800E8FA4",), - 0x800E9138:("func_800E9138",), - 0x800E9250:("func_800E9250",), + 0x800E8EA0:("Actor_ContinueText",), + 0x800E8ED0:("Flags_GetEventChkInf",), + 0x800E8EE0:("Flags_SetEventChkInf",), + 0x800E8EEC:("Flags_GetInfTable",), + 0x800E8EFC:("Flags_SetInfTable",), + 0x800E8F08:("Actor_TrackNone",), + 0x800E8FA4:("Actor_TrackPoint",), + 0x800E9138:("Actor_TrackPlayerSetFocusHeight",), + 0x800E9250:("Actor_TrackPlayer",), 0x800E9360:("SaveContext_Init",), 0x800E93E0:("GameInfo_Init",), 0x800E9470:("DebugDisplay_Init",), @@ -2679,8 +2679,8 @@ 0x8013CC2C:("SubS_FillShadowTex",), 0x8013CD64:("SubS_GenShadowTex",), 0x8013CF04:("SubS_DrawShadowTex",), - 0x8013D0E0:("SubS_ComputeTurnToPointRot",), - 0x8013D2E0:("SubS_TurnToPoint",), + 0x8013D0E0:("SubS_ComputeTrackPointRot",), + 0x8013D2E0:("SubS_TrackPoint",), 0x8013D5E8:("SubS_AngleDiffLessEqual",), 0x8013D648:("SubS_GetPathByIndex",), 0x8013D68C:("SubS_CopyPointFromPath",), @@ -2709,7 +2709,7 @@ 0x8013E748:("func_8013E748",), 0x8013E7C0:("SubS_ActorAndPlayerFaceEachOther",), 0x8013E8F8:("func_8013E8F8",), - 0x8013E950:("SubS_TurnToPointStep",), + 0x8013E950:("SubS_TrackPointStep",), 0x8013EC10:("func_8013EC10",), 0x8013EC44:("func_8013EC44",), 0x8013ECE0:("func_8013ECE0",), @@ -3036,7 +3036,7 @@ 0x8016A01C:("FrameAdvance_IsEnabled",), 0x8016A02C:("func_8016A02C",), 0x8016A0AC:("Play_IsUnderwater",), - 0x8016A168:("func_8016A168",), + 0x8016A168:("Play_IsDebugCamEnabled",), 0x8016A178:("Play_AssignPlayerActorCsIdsFromScene",), 0x8016A268:("func_8016A268",), 0x8016A2C8:("Play_Init",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 602916a8e..d643adfcb 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2171,7 +2171,7 @@ 0x801D0CD8:("TransitionFade_InitVars","UNK_PTR","",0x4), 0x801D0D00:("D_801D0D00","UNK_TYPE1","",0x1), 0x801D0D28:("TransitionCircle_InitVars","UNK_PTR","",0x4), - 0x801D0D50:("D_801D0D50","UNK_TYPE4","",0x4), + 0x801D0D50:("gDbgCamEnabled","UNK_TYPE4","",0x4), 0x801D0D54:("D_801D0D54","UNK_TYPE1","",0x1), 0x801D0D58:("D_801D0D58","UNK_TYPE2","",0x2), 0x801D0D5C:("D_801D0D5C","UNK_TYPE2","",0x2), diff --git a/tools/namefixer.py b/tools/namefixer.py index 1d6c89a7b..b273b05ca 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -540,6 +540,10 @@ wordReplace = { "EffectSsKiraKira_SpawnDispersed": "EffectSsKirakira_SpawnDispersed", "EffectSsKiraKira_SpawnFocused": "EffectSsKirakira_SpawnFocused", + "func_800E8F08": "Actor_TrackNone", + "func_800E8FA4": "Actor_TrackPoint", + "func_800E9250": "Actor_TrackPlayer", + # Struct members "skelAnime.unk03": "skelAnime.taper", "skelAnime.animCurrentSeg": "skelAnime.animation", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index b3e5db147..03717a020 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1023,15 +1023,15 @@ asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnShieldParticlesMeta asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnShieldParticlesMetal2.s,CollisionCheck_SpawnShieldParticlesMetal2,0x800E86C0,0x8 asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnShieldParticlesWood.s,CollisionCheck_SpawnShieldParticlesWood,0x800E86E0,0x29 asm/non_matchings/code/z_collision_check/CollisionCheck_CylSideVsLineSeg.s,CollisionCheck_CylSideVsLineSeg,0x800E8784,0x1C7 -asm/non_matchings/code/code_800E8EA0/func_800E8EA0.s,func_800E8EA0,0x800E8EA0,0xC -asm/non_matchings/code/code_800E8EA0/nop_800E8ED0.s,nop_800E8ED0,0x800E8ED0,0x4 -asm/non_matchings/code/code_800E8EA0/nop_800E8EE0.s,nop_800E8EE0,0x800E8EE0,0x3 -asm/non_matchings/code/code_800E8EA0/nop_800E8EEC.s,nop_800E8EEC,0x800E8EEC,0x4 -asm/non_matchings/code/code_800E8EA0/nop_800E8EFC.s,nop_800E8EFC,0x800E8EFC,0x3 -asm/non_matchings/code/code_800E8EA0/func_800E8F08.s,func_800E8F08,0x800E8F08,0x27 -asm/non_matchings/code/code_800E8EA0/func_800E8FA4.s,func_800E8FA4,0x800E8FA4,0x65 -asm/non_matchings/code/code_800E8EA0/func_800E9138.s,func_800E9138,0x800E9138,0x46 -asm/non_matchings/code/code_800E8EA0/func_800E9250.s,func_800E9250,0x800E9250,0x44 +asm/non_matchings/code/code_800E8EA0/Actor_ContinueText.s,Actor_ContinueText,0x800E8EA0,0xC +asm/non_matchings/code/code_800E8EA0/Flags_GetEventChkInf.s,Flags_GetEventChkInf,0x800E8ED0,0x4 +asm/non_matchings/code/code_800E8EA0/Flags_SetEventChkInf.s,Flags_SetEventChkInf,0x800E8EE0,0x3 +asm/non_matchings/code/code_800E8EA0/Flags_GetInfTable.s,Flags_GetInfTable,0x800E8EEC,0x4 +asm/non_matchings/code/code_800E8EA0/Flags_SetInfTable.s,Flags_SetInfTable,0x800E8EFC,0x3 +asm/non_matchings/code/code_800E8EA0/Actor_TrackNone.s,Actor_TrackNone,0x800E8F08,0x27 +asm/non_matchings/code/code_800E8EA0/Actor_TrackPoint.s,Actor_TrackPoint,0x800E8FA4,0x65 +asm/non_matchings/code/code_800E8EA0/Actor_TrackPlayerSetFocusHeight.s,Actor_TrackPlayerSetFocusHeight,0x800E9138,0x46 +asm/non_matchings/code/code_800E8EA0/Actor_TrackPlayer.s,Actor_TrackPlayer,0x800E9250,0x44 asm/non_matchings/code/z_common_data/func_800E9360.s,func_800E9360,0x800E9360,0x20 asm/non_matchings/code/z_debug/GameInfo_Init.s,GameInfo_Init,0x800E93E0,0x24 asm/non_matchings/code/z_debug_display/DebugDisplay_Init.s,DebugDisplay_Init,0x800E9470,0x6 @@ -2193,8 +2193,8 @@ asm/non_matchings/code/z_sub_s/func_8013C964.s,func_8013C964,0x8013C964,0xB2 asm/non_matchings/code/z_sub_s/SubS_FillShadowTex.s,SubS_FillShadowTex,0x8013CC2C,0x4E asm/non_matchings/code/z_sub_s/SubS_GenShadowTex.s,SubS_GenShadowTex,0x8013CD64,0x68 asm/non_matchings/code/z_sub_s/SubS_DrawShadowTex.s,SubS_DrawShadowTex,0x8013CF04,0x77 -asm/non_matchings/code/z_sub_s/SubS_ComputeTurnToPointRot.s,SubS_ComputeTurnToPointRot,0x8013D0E0,0x80 -asm/non_matchings/code/z_sub_s/SubS_TurnToPoint.s,SubS_TurnToPoint,0x8013D2E0,0xC2 +asm/non_matchings/code/z_sub_s/SubS_ComputeTrackPointRot.s,SubS_ComputeTrackPointRot,0x8013D0E0,0x80 +asm/non_matchings/code/z_sub_s/SubS_TrackPoint.s,SubS_TrackPoint,0x8013D2E0,0xC2 asm/non_matchings/code/z_sub_s/SubS_AngleDiffLessEqual.s,SubS_AngleDiffLessEqual,0x8013D5E8,0x18 asm/non_matchings/code/z_sub_s/SubS_GetPathByIndex.s,SubS_GetPathByIndex,0x8013D648,0x11 asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPath.s,SubS_CopyPointFromPath,0x8013D68C,0x25 @@ -2223,7 +2223,7 @@ asm/non_matchings/code/z_sub_s/SubS_FindActorCustom.s,SubS_FindActorCustom,0x801 asm/non_matchings/code/z_sub_s/func_8013E748.s,func_8013E748,0x8013E748,0x1E asm/non_matchings/code/z_sub_s/SubS_ActorAndPlayerFaceEachOther.s,SubS_ActorAndPlayerFaceEachOther,0x8013E7C0,0x4E asm/non_matchings/code/z_sub_s/func_8013E8F8.s,func_8013E8F8,0x8013E8F8,0x16 -asm/non_matchings/code/z_sub_s/SubS_TurnToPointStep.s,SubS_TurnToPointStep,0x8013E950,0xB0 +asm/non_matchings/code/z_sub_s/SubS_TrackPointStep.s,SubS_TrackPointStep,0x8013E950,0xB0 asm/non_matchings/code/code_8013EC10/func_8013EC10.s,func_8013EC10,0x8013EC10,0xD asm/non_matchings/code/code_8013EC10/func_8013EC44.s,func_8013EC44,0x8013EC44,0x27 asm/non_matchings/code/code_8013EC10/func_8013ECE0.s,func_8013ECE0,0x8013ECE0,0x2F @@ -2550,7 +2550,7 @@ asm/non_matchings/code/z_play/func_80169FFC.s,func_80169FFC,0x80169FFC,0x8 asm/non_matchings/code/z_play/FrameAdvance_IsEnabled.s,FrameAdvance_IsEnabled,0x8016A01C,0x4 asm/non_matchings/code/z_play/func_8016A02C.s,func_8016A02C,0x8016A02C,0x20 asm/non_matchings/code/z_play/Play_IsUnderwater.s,Play_IsUnderwater,0x8016A0AC,0x2F -asm/non_matchings/code/z_play/func_8016A168.s,func_8016A168,0x8016A168,0x4 +asm/non_matchings/code/z_play/Play_IsDebugCamEnabled.s,Play_IsDebugCamEnabled,0x8016A168,0x4 asm/non_matchings/code/z_play/func_8016A178.s,func_8016A178,0x8016A178,0x3C asm/non_matchings/code/z_play/func_8016A268.s,func_8016A268,0x8016A268,0x18 asm/non_matchings/code/z_play/Play_Init.s,Play_Init,0x8016A2C8,0x252